aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/v4l2-core/v4l2-subdev.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-04-03 20:16:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-03 20:16:59 -0400
commitef1c4a6fa91bbbe9b09f770d28eba31a9edf770c (patch)
tree52f5d175031c553160d14890e876ffc5432d2467 /drivers/media/v4l2-core/v4l2-subdev.c
parent147a89bc71e7db40f011454a40add7ff2d10f8d8 (diff)
parentf8a695c4b43d02c89b8bba9ba6058fd5db1bc71d (diff)
Merge tag 'media/v4.17-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab: - new CEC pin injection code for testing purposes - DVB frontend cxd2099 promoted from staging - new platform driver for Sony cxd2880 DVB devices - new sensor drivers: mt9t112, ov2685, ov5695, ov772x, tda1997x, tw9910.c - removal of unused cx18 and ivtv alsa mixers - the reneseas-ceu driver doesn't depend on soc_camera anymore and moved from staging - removed the mantis_vp3028 driver, unused since 2009 - s5p-mfc: add support for version 10 of the MSP - added a decoder for imon protocol - atomisp: lots of cleanups - imx074 and mt9t031: don't depend on soc_camera anymore, being promoted from staging - added helper functions to better support DVB I2C binding - lots of driver improvements and cleanups * tag 'media/v4.17-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (438 commits) media: v4l2-ioctl: rename a temp var that stores _IOC_SIZE(cmd) media: fimc-capture: get rid of two warnings media: dvb-usb-v2: fix a missing dependency of I2C_MUX media: uvc: to the right check at uvc_ioctl_enum_framesizes() media: cec-core: fix a bug at cec_error_inj_write() media: tda9840: cleanup a warning media: tm6000: avoid casting just to print pointer address media: em28xx-input: improve error handling code media: zr364xx: avoid casting just to print pointer address media: vivid-radio-rx: add a cast to avoid a warning media: saa7134-alsa: don't use casts to print a buffer address media: solo6x10: get rid of an address space warning media: zoran: don't cast pointers to print them media: ir-kbd-i2c: change the if logic to avoid a warning media: ir-kbd-i2c: improve error handling code media: saa7134-input: improve error handling media: s2255drv: fix a casting warning media: ivtvfb: Cleanup some warnings media: videobuf-dma-sg: Fix a weird cast soc_camera: fix a weird cast on printk ...
Diffstat (limited to 'drivers/media/v4l2-core/v4l2-subdev.c')
-rw-r--r--drivers/media/v4l2-core/v4l2-subdev.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index c5639817db34..f9eed938d348 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -187,27 +187,51 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
187 187
188 switch (cmd) { 188 switch (cmd) {
189 case VIDIOC_QUERYCTRL: 189 case VIDIOC_QUERYCTRL:
190 /*
191 * TODO: this really should be folded into v4l2_queryctrl (this
192 * currently returns -EINVAL for NULL control handlers).
193 * However, v4l2_queryctrl() is still called directly by
194 * drivers as well and until that has been addressed I believe
195 * it is safer to do the check here. The same is true for the
196 * other control ioctls below.
197 */
198 if (!vfh->ctrl_handler)
199 return -ENOTTY;
190 return v4l2_queryctrl(vfh->ctrl_handler, arg); 200 return v4l2_queryctrl(vfh->ctrl_handler, arg);
191 201
192 case VIDIOC_QUERY_EXT_CTRL: 202 case VIDIOC_QUERY_EXT_CTRL:
203 if (!vfh->ctrl_handler)
204 return -ENOTTY;
193 return v4l2_query_ext_ctrl(vfh->ctrl_handler, arg); 205 return v4l2_query_ext_ctrl(vfh->ctrl_handler, arg);
194 206
195 case VIDIOC_QUERYMENU: 207 case VIDIOC_QUERYMENU:
208 if (!vfh->ctrl_handler)
209 return -ENOTTY;
196 return v4l2_querymenu(vfh->ctrl_handler, arg); 210 return v4l2_querymenu(vfh->ctrl_handler, arg);
197 211
198 case VIDIOC_G_CTRL: 212 case VIDIOC_G_CTRL:
213 if (!vfh->ctrl_handler)
214 return -ENOTTY;
199 return v4l2_g_ctrl(vfh->ctrl_handler, arg); 215 return v4l2_g_ctrl(vfh->ctrl_handler, arg);
200 216
201 case VIDIOC_S_CTRL: 217 case VIDIOC_S_CTRL:
218 if (!vfh->ctrl_handler)
219 return -ENOTTY;
202 return v4l2_s_ctrl(vfh, vfh->ctrl_handler, arg); 220 return v4l2_s_ctrl(vfh, vfh->ctrl_handler, arg);
203 221
204 case VIDIOC_G_EXT_CTRLS: 222 case VIDIOC_G_EXT_CTRLS:
223 if (!vfh->ctrl_handler)
224 return -ENOTTY;
205 return v4l2_g_ext_ctrls(vfh->ctrl_handler, arg); 225 return v4l2_g_ext_ctrls(vfh->ctrl_handler, arg);
206 226
207 case VIDIOC_S_EXT_CTRLS: 227 case VIDIOC_S_EXT_CTRLS:
228 if (!vfh->ctrl_handler)
229 return -ENOTTY;
208 return v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler, arg); 230 return v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler, arg);
209 231
210 case VIDIOC_TRY_EXT_CTRLS: 232 case VIDIOC_TRY_EXT_CTRLS:
233 if (!vfh->ctrl_handler)
234 return -ENOTTY;
211 return v4l2_try_ext_ctrls(vfh->ctrl_handler, arg); 235 return v4l2_try_ext_ctrls(vfh->ctrl_handler, arg);
212 236
213 case VIDIOC_DQEVENT: 237 case VIDIOC_DQEVENT:
@@ -239,6 +263,19 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
239 return -EPERM; 263 return -EPERM;
240 return v4l2_subdev_call(sd, core, s_register, p); 264 return v4l2_subdev_call(sd, core, s_register, p);
241 } 265 }
266 case VIDIOC_DBG_G_CHIP_INFO:
267 {
268 struct v4l2_dbg_chip_info *p = arg;
269
270 if (p->match.type != V4L2_CHIP_MATCH_SUBDEV || p->match.addr)
271 return -EINVAL;
272 if (sd->ops->core && sd->ops->core->s_register)
273 p->flags |= V4L2_CHIP_FL_WRITABLE;
274 if (sd->ops->core && sd->ops->core->g_register)
275 p->flags |= V4L2_CHIP_FL_READABLE;
276 strlcpy(p->name, sd->name, sizeof(p->name));
277 return 0;
278 }
242#endif 279#endif
243 280
244 case VIDIOC_LOG_STATUS: { 281 case VIDIOC_LOG_STATUS: {
@@ -260,6 +297,8 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
260 if (rval) 297 if (rval)
261 return rval; 298 return rval;
262 299
300 memset(format->reserved, 0, sizeof(format->reserved));
301 memset(format->format.reserved, 0, sizeof(format->format.reserved));
263 return v4l2_subdev_call(sd, pad, get_fmt, subdev_fh->pad, format); 302 return v4l2_subdev_call(sd, pad, get_fmt, subdev_fh->pad, format);
264 } 303 }
265 304
@@ -270,6 +309,8 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
270 if (rval) 309 if (rval)
271 return rval; 310 return rval;
272 311
312 memset(format->reserved, 0, sizeof(format->reserved));
313 memset(format->format.reserved, 0, sizeof(format->format.reserved));
273 return v4l2_subdev_call(sd, pad, set_fmt, subdev_fh->pad, format); 314 return v4l2_subdev_call(sd, pad, set_fmt, subdev_fh->pad, format);
274 } 315 }
275 316
@@ -281,6 +322,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
281 if (rval) 322 if (rval)
282 return rval; 323 return rval;
283 324
325 memset(crop->reserved, 0, sizeof(crop->reserved));
284 memset(&sel, 0, sizeof(sel)); 326 memset(&sel, 0, sizeof(sel));
285 sel.which = crop->which; 327 sel.which = crop->which;
286 sel.pad = crop->pad; 328 sel.pad = crop->pad;
@@ -298,6 +340,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
298 struct v4l2_subdev_crop *crop = arg; 340 struct v4l2_subdev_crop *crop = arg;
299 struct v4l2_subdev_selection sel; 341 struct v4l2_subdev_selection sel;
300 342
343 memset(crop->reserved, 0, sizeof(crop->reserved));
301 rval = check_crop(sd, crop); 344 rval = check_crop(sd, crop);
302 if (rval) 345 if (rval)
303 return rval; 346 return rval;
@@ -326,6 +369,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
326 if (code->pad >= sd->entity.num_pads) 369 if (code->pad >= sd->entity.num_pads)
327 return -EINVAL; 370 return -EINVAL;
328 371
372 memset(code->reserved, 0, sizeof(code->reserved));
329 return v4l2_subdev_call(sd, pad, enum_mbus_code, subdev_fh->pad, 373 return v4l2_subdev_call(sd, pad, enum_mbus_code, subdev_fh->pad,
330 code); 374 code);
331 } 375 }
@@ -340,6 +384,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
340 if (fse->pad >= sd->entity.num_pads) 384 if (fse->pad >= sd->entity.num_pads)
341 return -EINVAL; 385 return -EINVAL;
342 386
387 memset(fse->reserved, 0, sizeof(fse->reserved));
343 return v4l2_subdev_call(sd, pad, enum_frame_size, subdev_fh->pad, 388 return v4l2_subdev_call(sd, pad, enum_frame_size, subdev_fh->pad,
344 fse); 389 fse);
345 } 390 }
@@ -350,6 +395,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
350 if (fi->pad >= sd->entity.num_pads) 395 if (fi->pad >= sd->entity.num_pads)
351 return -EINVAL; 396 return -EINVAL;
352 397
398 memset(fi->reserved, 0, sizeof(fi->reserved));
353 return v4l2_subdev_call(sd, video, g_frame_interval, arg); 399 return v4l2_subdev_call(sd, video, g_frame_interval, arg);
354 } 400 }
355 401
@@ -359,6 +405,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
359 if (fi->pad >= sd->entity.num_pads) 405 if (fi->pad >= sd->entity.num_pads)
360 return -EINVAL; 406 return -EINVAL;
361 407
408 memset(fi->reserved, 0, sizeof(fi->reserved));
362 return v4l2_subdev_call(sd, video, s_frame_interval, arg); 409 return v4l2_subdev_call(sd, video, s_frame_interval, arg);
363 } 410 }
364 411
@@ -372,6 +419,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
372 if (fie->pad >= sd->entity.num_pads) 419 if (fie->pad >= sd->entity.num_pads)
373 return -EINVAL; 420 return -EINVAL;
374 421
422 memset(fie->reserved, 0, sizeof(fie->reserved));
375 return v4l2_subdev_call(sd, pad, enum_frame_interval, subdev_fh->pad, 423 return v4l2_subdev_call(sd, pad, enum_frame_interval, subdev_fh->pad,
376 fie); 424 fie);
377 } 425 }
@@ -383,6 +431,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
383 if (rval) 431 if (rval)
384 return rval; 432 return rval;
385 433
434 memset(sel->reserved, 0, sizeof(sel->reserved));
386 return v4l2_subdev_call( 435 return v4l2_subdev_call(
387 sd, pad, get_selection, subdev_fh->pad, sel); 436 sd, pad, get_selection, subdev_fh->pad, sel);
388 } 437 }
@@ -394,6 +443,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
394 if (rval) 443 if (rval)
395 return rval; 444 return rval;
396 445
446 memset(sel->reserved, 0, sizeof(sel->reserved));
397 return v4l2_subdev_call( 447 return v4l2_subdev_call(
398 sd, pad, set_selection, subdev_fh->pad, sel); 448 sd, pad, set_selection, subdev_fh->pad, sel);
399 } 449 }