Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: staging: max96712: Store format in subdev active state

Create and store the subdevice format in the subdevices active state.
This change do not have a huge effect on the driver as it do not yet
support changing the format.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

authored by

Niklas Söderlund and committed by
Hans Verkuil
ce44dc1f 7d30b8ef

+28 -9
+28 -9
drivers/staging/media/max96712/max96712.c
··· 242 242 .s_stream = max96712_s_stream, 243 243 }; 244 244 245 - static int max96712_get_pad_format(struct v4l2_subdev *sd, 246 - struct v4l2_subdev_state *sd_state, 247 - struct v4l2_subdev_format *format) 245 + static int max96712_init_state(struct v4l2_subdev *sd, 246 + struct v4l2_subdev_state *state) 248 247 { 249 - format->format.width = 1920; 250 - format->format.height = 1080; 251 - format->format.code = MEDIA_BUS_FMT_RGB888_1X24; 252 - format->format.field = V4L2_FIELD_NONE; 248 + static const struct v4l2_mbus_framefmt default_fmt = { 249 + .width = 1920, 250 + .height = 1080, 251 + .code = MEDIA_BUS_FMT_RGB888_1X24, 252 + .colorspace = V4L2_COLORSPACE_SRGB, 253 + .field = V4L2_FIELD_NONE, 254 + .ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT, 255 + .quantization = V4L2_QUANTIZATION_DEFAULT, 256 + .xfer_func = V4L2_XFER_FUNC_DEFAULT, 257 + }; 258 + struct v4l2_mbus_framefmt *fmt; 259 + 260 + fmt = v4l2_subdev_state_get_format(state, 0); 261 + *fmt = default_fmt; 253 262 254 263 return 0; 255 264 } 256 265 266 + static const struct v4l2_subdev_internal_ops max96712_internal_ops = { 267 + .init_state = max96712_init_state, 268 + }; 269 + 257 270 static const struct v4l2_subdev_pad_ops max96712_pad_ops = { 258 - .get_fmt = max96712_get_pad_format, 259 - .set_fmt = max96712_get_pad_format, 271 + .get_fmt = v4l2_subdev_get_fmt, 272 + .set_fmt = v4l2_subdev_get_fmt, 260 273 }; 261 274 262 275 static const struct v4l2_subdev_ops max96712_subdev_ops = { ··· 306 293 long pixel_rate; 307 294 int ret; 308 295 296 + priv->sd.internal_ops = &max96712_internal_ops; 309 297 v4l2_i2c_subdev_init(&priv->sd, priv->client, &max96712_subdev_ops); 310 298 priv->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; 311 299 priv->sd.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; ··· 337 323 goto error; 338 324 339 325 v4l2_set_subdevdata(&priv->sd, priv); 326 + 327 + priv->sd.state_lock = priv->ctrl_handler.lock; 328 + ret = v4l2_subdev_init_finalize(&priv->sd); 329 + if (ret) 330 + goto error; 340 331 341 332 ret = v4l2_async_register_subdev(&priv->sd); 342 333 if (ret < 0) {