Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 1 | /* |
| 2 | * vsp1_uds.c -- R-Car VSP1 Up and Down Scaler |
| 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/v4l2-subdev.h> |
| 18 | |
| 19 | #include "vsp1.h" |
Laurent Pinchart | 5e8dbbf | 2015-11-22 20:29:25 -0200 | [diff] [blame] | 20 | #include "vsp1_dl.h" |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 21 | #include "vsp1_uds.h" |
| 22 | |
| 23 | #define UDS_MIN_SIZE 4U |
| 24 | #define UDS_MAX_SIZE 8190U |
| 25 | |
| 26 | #define UDS_MIN_FACTOR 0x0100 |
| 27 | #define UDS_MAX_FACTOR 0xffff |
| 28 | |
| 29 | /* ----------------------------------------------------------------------------- |
| 30 | * Device Access |
| 31 | */ |
| 32 | |
Laurent Pinchart | 5e8dbbf | 2015-11-22 20:29:25 -0200 | [diff] [blame] | 33 | static inline void vsp1_uds_write(struct vsp1_uds *uds, struct vsp1_dl_list *dl, |
| 34 | u32 reg, u32 data) |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 35 | { |
Laurent Pinchart | 5e8dbbf | 2015-11-22 20:29:25 -0200 | [diff] [blame] | 36 | vsp1_dl_list_write(dl, reg + uds->entity.index * VI6_UDS_OFFSET, data); |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | /* ----------------------------------------------------------------------------- |
| 40 | * Scaling Computation |
| 41 | */ |
| 42 | |
Laurent Pinchart | 07a23c6 | 2016-06-19 23:19:43 -0300 | [diff] [blame] | 43 | void vsp1_uds_set_alpha(struct vsp1_entity *entity, struct vsp1_dl_list *dl, |
Laurent Pinchart | 5e8dbbf | 2015-11-22 20:29:25 -0200 | [diff] [blame] | 44 | unsigned int alpha) |
Laurent Pinchart | bdc2df6 | 2014-05-30 21:45:48 -0300 | [diff] [blame] | 45 | { |
Laurent Pinchart | 07a23c6 | 2016-06-19 23:19:43 -0300 | [diff] [blame] | 46 | struct vsp1_uds *uds = to_uds(&entity->subdev); |
| 47 | |
Laurent Pinchart | 5e8dbbf | 2015-11-22 20:29:25 -0200 | [diff] [blame] | 48 | vsp1_uds_write(uds, dl, VI6_UDS_ALPVAL, |
| 49 | alpha << VI6_UDS_ALPVAL_VAL0_SHIFT); |
Laurent Pinchart | bdc2df6 | 2014-05-30 21:45:48 -0300 | [diff] [blame] | 50 | } |
| 51 | |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 52 | /* |
| 53 | * uds_output_size - Return the output size for an input size and scaling ratio |
| 54 | * @input: input size in pixels |
| 55 | * @ratio: scaling ratio in U4.12 fixed-point format |
| 56 | */ |
| 57 | static unsigned int uds_output_size(unsigned int input, unsigned int ratio) |
| 58 | { |
| 59 | if (ratio > 4096) { |
| 60 | /* Down-scaling */ |
| 61 | unsigned int mp; |
| 62 | |
| 63 | mp = ratio / 4096; |
| 64 | mp = mp < 4 ? 1 : (mp < 8 ? 2 : 4); |
| 65 | |
| 66 | return (input - 1) / mp * mp * 4096 / ratio + 1; |
| 67 | } else { |
| 68 | /* Up-scaling */ |
| 69 | return (input - 1) * 4096 / ratio + 1; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | /* |
| 74 | * uds_output_limits - Return the min and max output sizes for an input size |
| 75 | * @input: input size in pixels |
| 76 | * @minimum: minimum output size (returned) |
| 77 | * @maximum: maximum output size (returned) |
| 78 | */ |
| 79 | static void uds_output_limits(unsigned int input, |
| 80 | unsigned int *minimum, unsigned int *maximum) |
| 81 | { |
| 82 | *minimum = max(uds_output_size(input, UDS_MAX_FACTOR), UDS_MIN_SIZE); |
| 83 | *maximum = min(uds_output_size(input, UDS_MIN_FACTOR), UDS_MAX_SIZE); |
| 84 | } |
| 85 | |
| 86 | /* |
| 87 | * uds_passband_width - Return the passband filter width for a scaling ratio |
| 88 | * @ratio: scaling ratio in U4.12 fixed-point format |
| 89 | */ |
| 90 | static unsigned int uds_passband_width(unsigned int ratio) |
| 91 | { |
| 92 | if (ratio >= 4096) { |
| 93 | /* Down-scaling */ |
| 94 | unsigned int mp; |
| 95 | |
| 96 | mp = ratio / 4096; |
| 97 | mp = mp < 4 ? 1 : (mp < 8 ? 2 : 4); |
| 98 | |
| 99 | return 64 * 4096 * mp / ratio; |
| 100 | } else { |
| 101 | /* Up-scaling */ |
| 102 | return 64; |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | static unsigned int uds_compute_ratio(unsigned int input, unsigned int output) |
| 107 | { |
| 108 | /* TODO: This is an approximation that will need to be refined. */ |
| 109 | return (input - 1) * 4096 / (output - 1); |
| 110 | } |
| 111 | |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 112 | /* ----------------------------------------------------------------------------- |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 113 | * V4L2 Subdevice Pad Operations |
| 114 | */ |
| 115 | |
| 116 | static int uds_enum_mbus_code(struct v4l2_subdev *subdev, |
Hans Verkuil | f723413 | 2015-03-04 01:47:54 -0800 | [diff] [blame] | 117 | struct v4l2_subdev_pad_config *cfg, |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 118 | struct v4l2_subdev_mbus_code_enum *code) |
| 119 | { |
| 120 | static const unsigned int codes[] = { |
Boris BREZILLON | 27ffaeb | 2014-11-10 14:28:31 -0300 | [diff] [blame] | 121 | MEDIA_BUS_FMT_ARGB8888_1X32, |
| 122 | MEDIA_BUS_FMT_AYUV8_1X32, |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 123 | }; |
| 124 | |
Laurent Pinchart | 6ad9ba9 | 2016-02-24 20:25:42 -0300 | [diff] [blame] | 125 | return vsp1_subdev_enum_mbus_code(subdev, cfg, code, codes, |
| 126 | ARRAY_SIZE(codes)); |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | static int uds_enum_frame_size(struct v4l2_subdev *subdev, |
Hans Verkuil | f723413 | 2015-03-04 01:47:54 -0800 | [diff] [blame] | 130 | struct v4l2_subdev_pad_config *cfg, |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 131 | struct v4l2_subdev_frame_size_enum *fse) |
| 132 | { |
Hans Verkuil | 5778e74 | 2015-03-04 01:47:58 -0800 | [diff] [blame] | 133 | struct vsp1_uds *uds = to_uds(subdev); |
Laurent Pinchart | e790c3c | 2015-11-15 19:14:22 -0200 | [diff] [blame] | 134 | struct v4l2_subdev_pad_config *config; |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 135 | struct v4l2_mbus_framefmt *format; |
Laurent Pinchart | 34e77ed | 2016-06-26 08:09:31 -0300 | [diff] [blame] | 136 | int ret = 0; |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 137 | |
Laurent Pinchart | e790c3c | 2015-11-15 19:14:22 -0200 | [diff] [blame] | 138 | config = vsp1_entity_get_pad_config(&uds->entity, cfg, fse->which); |
| 139 | if (!config) |
| 140 | return -EINVAL; |
| 141 | |
| 142 | format = vsp1_entity_get_pad_format(&uds->entity, config, |
| 143 | UDS_PAD_SINK); |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 144 | |
Laurent Pinchart | 34e77ed | 2016-06-26 08:09:31 -0300 | [diff] [blame] | 145 | mutex_lock(&uds->entity.lock); |
| 146 | |
| 147 | if (fse->index || fse->code != format->code) { |
| 148 | ret = -EINVAL; |
| 149 | goto done; |
| 150 | } |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 151 | |
| 152 | if (fse->pad == UDS_PAD_SINK) { |
| 153 | fse->min_width = UDS_MIN_SIZE; |
| 154 | fse->max_width = UDS_MAX_SIZE; |
| 155 | fse->min_height = UDS_MIN_SIZE; |
| 156 | fse->max_height = UDS_MAX_SIZE; |
| 157 | } else { |
| 158 | uds_output_limits(format->width, &fse->min_width, |
| 159 | &fse->max_width); |
| 160 | uds_output_limits(format->height, &fse->min_height, |
| 161 | &fse->max_height); |
| 162 | } |
| 163 | |
Laurent Pinchart | 34e77ed | 2016-06-26 08:09:31 -0300 | [diff] [blame] | 164 | done: |
| 165 | mutex_unlock(&uds->entity.lock); |
| 166 | return ret; |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 167 | } |
| 168 | |
Laurent Pinchart | 1bd0a1b | 2015-11-01 15:18:32 -0200 | [diff] [blame] | 169 | static void uds_try_format(struct vsp1_uds *uds, |
Laurent Pinchart | e790c3c | 2015-11-15 19:14:22 -0200 | [diff] [blame] | 170 | struct v4l2_subdev_pad_config *config, |
| 171 | unsigned int pad, struct v4l2_mbus_framefmt *fmt) |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 172 | { |
| 173 | struct v4l2_mbus_framefmt *format; |
| 174 | unsigned int minimum; |
| 175 | unsigned int maximum; |
| 176 | |
| 177 | switch (pad) { |
| 178 | case UDS_PAD_SINK: |
| 179 | /* Default to YUV if the requested format is not supported. */ |
Boris BREZILLON | 27ffaeb | 2014-11-10 14:28:31 -0300 | [diff] [blame] | 180 | if (fmt->code != MEDIA_BUS_FMT_ARGB8888_1X32 && |
| 181 | fmt->code != MEDIA_BUS_FMT_AYUV8_1X32) |
| 182 | fmt->code = MEDIA_BUS_FMT_AYUV8_1X32; |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 183 | |
| 184 | fmt->width = clamp(fmt->width, UDS_MIN_SIZE, UDS_MAX_SIZE); |
| 185 | fmt->height = clamp(fmt->height, UDS_MIN_SIZE, UDS_MAX_SIZE); |
| 186 | break; |
| 187 | |
| 188 | case UDS_PAD_SOURCE: |
| 189 | /* The UDS scales but can't perform format conversion. */ |
Laurent Pinchart | e790c3c | 2015-11-15 19:14:22 -0200 | [diff] [blame] | 190 | format = vsp1_entity_get_pad_format(&uds->entity, config, |
| 191 | UDS_PAD_SINK); |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 192 | fmt->code = format->code; |
| 193 | |
| 194 | uds_output_limits(format->width, &minimum, &maximum); |
| 195 | fmt->width = clamp(fmt->width, minimum, maximum); |
| 196 | uds_output_limits(format->height, &minimum, &maximum); |
| 197 | fmt->height = clamp(fmt->height, minimum, maximum); |
| 198 | break; |
| 199 | } |
| 200 | |
| 201 | fmt->field = V4L2_FIELD_NONE; |
| 202 | fmt->colorspace = V4L2_COLORSPACE_SRGB; |
| 203 | } |
| 204 | |
Laurent Pinchart | 1bd0a1b | 2015-11-01 15:18:32 -0200 | [diff] [blame] | 205 | static int uds_set_format(struct v4l2_subdev *subdev, |
| 206 | struct v4l2_subdev_pad_config *cfg, |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 207 | struct v4l2_subdev_format *fmt) |
| 208 | { |
| 209 | struct vsp1_uds *uds = to_uds(subdev); |
Laurent Pinchart | e790c3c | 2015-11-15 19:14:22 -0200 | [diff] [blame] | 210 | struct v4l2_subdev_pad_config *config; |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 211 | struct v4l2_mbus_framefmt *format; |
Laurent Pinchart | 34e77ed | 2016-06-26 08:09:31 -0300 | [diff] [blame] | 212 | int ret = 0; |
| 213 | |
| 214 | mutex_lock(&uds->entity.lock); |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 215 | |
Laurent Pinchart | e790c3c | 2015-11-15 19:14:22 -0200 | [diff] [blame] | 216 | config = vsp1_entity_get_pad_config(&uds->entity, cfg, fmt->which); |
Laurent Pinchart | 34e77ed | 2016-06-26 08:09:31 -0300 | [diff] [blame] | 217 | if (!config) { |
| 218 | ret = -EINVAL; |
| 219 | goto done; |
| 220 | } |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 221 | |
Laurent Pinchart | e790c3c | 2015-11-15 19:14:22 -0200 | [diff] [blame] | 222 | uds_try_format(uds, config, fmt->pad, &fmt->format); |
| 223 | |
| 224 | format = vsp1_entity_get_pad_format(&uds->entity, config, fmt->pad); |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 225 | *format = fmt->format; |
| 226 | |
| 227 | if (fmt->pad == UDS_PAD_SINK) { |
| 228 | /* Propagate the format to the source pad. */ |
Laurent Pinchart | e790c3c | 2015-11-15 19:14:22 -0200 | [diff] [blame] | 229 | format = vsp1_entity_get_pad_format(&uds->entity, config, |
| 230 | UDS_PAD_SOURCE); |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 231 | *format = fmt->format; |
| 232 | |
Laurent Pinchart | e790c3c | 2015-11-15 19:14:22 -0200 | [diff] [blame] | 233 | uds_try_format(uds, config, UDS_PAD_SOURCE, format); |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 234 | } |
| 235 | |
Laurent Pinchart | 34e77ed | 2016-06-26 08:09:31 -0300 | [diff] [blame] | 236 | done: |
| 237 | mutex_unlock(&uds->entity.lock); |
| 238 | return ret; |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | /* ----------------------------------------------------------------------------- |
| 242 | * V4L2 Subdevice Operations |
| 243 | */ |
| 244 | |
Laurent Pinchart | eb9163d | 2016-06-17 21:11:26 -0300 | [diff] [blame] | 245 | static const struct v4l2_subdev_pad_ops uds_pad_ops = { |
Laurent Pinchart | 0efdf0f | 2015-11-15 20:09:08 -0200 | [diff] [blame] | 246 | .init_cfg = vsp1_entity_init_cfg, |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 247 | .enum_mbus_code = uds_enum_mbus_code, |
| 248 | .enum_frame_size = uds_enum_frame_size, |
Laurent Pinchart | 3f55722 | 2016-02-24 21:10:13 -0300 | [diff] [blame] | 249 | .get_fmt = vsp1_subdev_get_pad_format, |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 250 | .set_fmt = uds_set_format, |
| 251 | }; |
| 252 | |
Laurent Pinchart | eb9163d | 2016-06-17 21:11:26 -0300 | [diff] [blame] | 253 | static const struct v4l2_subdev_ops uds_ops = { |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 254 | .pad = &uds_pad_ops, |
| 255 | }; |
| 256 | |
| 257 | /* ----------------------------------------------------------------------------- |
Laurent Pinchart | 7b905f0 | 2015-11-17 13:10:26 -0200 | [diff] [blame] | 258 | * VSP1 Entity Operations |
| 259 | */ |
| 260 | |
Laurent Pinchart | 83dd019 | 2016-01-14 14:17:32 -0200 | [diff] [blame] | 261 | static void uds_configure(struct vsp1_entity *entity, |
| 262 | struct vsp1_pipeline *pipe, |
Laurent Pinchart | d21fbbb | 2016-09-11 19:39:30 -0300 | [diff] [blame^] | 263 | struct vsp1_dl_list *dl, |
| 264 | enum vsp1_entity_params params) |
Laurent Pinchart | 7b905f0 | 2015-11-17 13:10:26 -0200 | [diff] [blame] | 265 | { |
| 266 | struct vsp1_uds *uds = to_uds(&entity->subdev); |
| 267 | const struct v4l2_mbus_framefmt *output; |
| 268 | const struct v4l2_mbus_framefmt *input; |
| 269 | unsigned int hscale; |
| 270 | unsigned int vscale; |
| 271 | bool multitap; |
| 272 | |
Laurent Pinchart | d21fbbb | 2016-09-11 19:39:30 -0300 | [diff] [blame^] | 273 | if (params != VSP1_ENTITY_PARAMS_INIT) |
Laurent Pinchart | fc845e5 | 2016-06-11 04:07:56 -0300 | [diff] [blame] | 274 | return; |
| 275 | |
Laurent Pinchart | 7b905f0 | 2015-11-17 13:10:26 -0200 | [diff] [blame] | 276 | input = vsp1_entity_get_pad_format(&uds->entity, uds->entity.config, |
| 277 | UDS_PAD_SINK); |
| 278 | output = vsp1_entity_get_pad_format(&uds->entity, uds->entity.config, |
| 279 | UDS_PAD_SOURCE); |
| 280 | |
| 281 | hscale = uds_compute_ratio(input->width, output->width); |
| 282 | vscale = uds_compute_ratio(input->height, output->height); |
| 283 | |
| 284 | dev_dbg(uds->entity.vsp1->dev, "hscale %u vscale %u\n", hscale, vscale); |
| 285 | |
| 286 | /* Multi-tap scaling can't be enabled along with alpha scaling when |
| 287 | * scaling down with a factor lower than or equal to 1/2 in either |
| 288 | * direction. |
| 289 | */ |
| 290 | if (uds->scale_alpha && (hscale >= 8192 || vscale >= 8192)) |
| 291 | multitap = false; |
| 292 | else |
| 293 | multitap = true; |
| 294 | |
Laurent Pinchart | 5e8dbbf | 2015-11-22 20:29:25 -0200 | [diff] [blame] | 295 | vsp1_uds_write(uds, dl, VI6_UDS_CTRL, |
Laurent Pinchart | 7b905f0 | 2015-11-17 13:10:26 -0200 | [diff] [blame] | 296 | (uds->scale_alpha ? VI6_UDS_CTRL_AON : 0) | |
| 297 | (multitap ? VI6_UDS_CTRL_BC : 0)); |
| 298 | |
Laurent Pinchart | 5e8dbbf | 2015-11-22 20:29:25 -0200 | [diff] [blame] | 299 | vsp1_uds_write(uds, dl, VI6_UDS_PASS_BWIDTH, |
Laurent Pinchart | 7b905f0 | 2015-11-17 13:10:26 -0200 | [diff] [blame] | 300 | (uds_passband_width(hscale) |
| 301 | << VI6_UDS_PASS_BWIDTH_H_SHIFT) | |
| 302 | (uds_passband_width(vscale) |
| 303 | << VI6_UDS_PASS_BWIDTH_V_SHIFT)); |
| 304 | |
| 305 | /* Set the scaling ratios and the output size. */ |
Laurent Pinchart | 5e8dbbf | 2015-11-22 20:29:25 -0200 | [diff] [blame] | 306 | vsp1_uds_write(uds, dl, VI6_UDS_SCALE, |
Laurent Pinchart | 7b905f0 | 2015-11-17 13:10:26 -0200 | [diff] [blame] | 307 | (hscale << VI6_UDS_SCALE_HFRAC_SHIFT) | |
| 308 | (vscale << VI6_UDS_SCALE_VFRAC_SHIFT)); |
Laurent Pinchart | 5e8dbbf | 2015-11-22 20:29:25 -0200 | [diff] [blame] | 309 | vsp1_uds_write(uds, dl, VI6_UDS_CLIP_SIZE, |
Laurent Pinchart | 7b905f0 | 2015-11-17 13:10:26 -0200 | [diff] [blame] | 310 | (output->width << VI6_UDS_CLIP_SIZE_HSIZE_SHIFT) | |
| 311 | (output->height << VI6_UDS_CLIP_SIZE_VSIZE_SHIFT)); |
| 312 | } |
| 313 | |
| 314 | static const struct vsp1_entity_operations uds_entity_ops = { |
| 315 | .configure = uds_configure, |
| 316 | }; |
| 317 | |
| 318 | /* ----------------------------------------------------------------------------- |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 319 | * Initialization and Cleanup |
| 320 | */ |
| 321 | |
| 322 | struct vsp1_uds *vsp1_uds_create(struct vsp1_device *vsp1, unsigned int index) |
| 323 | { |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 324 | struct vsp1_uds *uds; |
Laurent Pinchart | 823329d | 2015-11-15 19:42:01 -0200 | [diff] [blame] | 325 | char name[6]; |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 326 | int ret; |
| 327 | |
| 328 | uds = devm_kzalloc(vsp1->dev, sizeof(*uds), GFP_KERNEL); |
| 329 | if (uds == NULL) |
| 330 | return ERR_PTR(-ENOMEM); |
| 331 | |
Laurent Pinchart | 7b905f0 | 2015-11-17 13:10:26 -0200 | [diff] [blame] | 332 | uds->entity.ops = &uds_entity_ops; |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 333 | uds->entity.type = VSP1_ENTITY_UDS; |
| 334 | uds->entity.index = index; |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 335 | |
Laurent Pinchart | 823329d | 2015-11-15 19:42:01 -0200 | [diff] [blame] | 336 | sprintf(name, "uds.%u", index); |
Laurent Pinchart | 6a8e07b | 2016-02-15 22:10:26 -0200 | [diff] [blame] | 337 | ret = vsp1_entity_init(vsp1, &uds->entity, name, 2, &uds_ops, |
| 338 | MEDIA_ENT_F_PROC_VIDEO_SCALER); |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 339 | if (ret < 0) |
| 340 | return ERR_PTR(ret); |
| 341 | |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 342 | return uds; |
| 343 | } |