Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media

Pull media fixes from Mauro Carvalho Chehab:
"Most of the changes are drivers fixes (rtl28xuu, fc2580, ov7670,
davinci, gspca, s5p-fimc and s5c73m3).

There is also a compat32 fix and one infoleak fixup at the media
controller"

* 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media:
[media] V4L2: fix VIDIOC_CREATE_BUFS in 64- / 32-bit compatibility mode
[media] V4L2: ov7670: fix a wrong index, potentially Oopsing the kernel from user-space
[media] media-device: fix infoleak in ioctl media_enum_entities()
[media] fc2580: fix tuning failure on 32-bit arch
[media] Prefer gspca_sonixb over sn9c102 for all devices
[media] media: davinci: vpfe: make sure all the buffers unmapped and released
[media] staging: media: davinci: vpfe: make sure all the buffers are released
[media] media: davinci: vpbe_display: fix releasing of active buffers
[media] media: davinci: vpif_display: fix releasing of active buffers
[media] media: davinci: vpif_capture: fix releasing of active buffers
[media] s5p-fimc: Fix YUV422P depth
[media] s5c73m3: Add missing rename of v4l2_of_get_next_endpoint() function
[media] rtl28xxu: silence error log about disabled rtl2832_sdr module
[media] rtl28xxu: do not hard depend on staging SDR module

+132 -47
+1 -1
drivers/media/i2c/ov7670.c
··· 1109 1109 * windows that fall outside that. 1110 1110 */ 1111 1111 for (i = 0; i < n_win_sizes; i++) { 1112 - struct ov7670_win_size *win = &info->devtype->win_sizes[index]; 1112 + struct ov7670_win_size *win = &info->devtype->win_sizes[i]; 1113 1113 if (info->min_width && win->width < info->min_width) 1114 1114 continue; 1115 1115 if (info->min_height && win->height < info->min_height)
+1 -1
drivers/media/i2c/s5c73m3/s5c73m3-core.c
··· 1616 1616 if (ret < 0) 1617 1617 return -EINVAL; 1618 1618 1619 - node_ep = v4l2_of_get_next_endpoint(node, NULL); 1619 + node_ep = of_graph_get_next_endpoint(node, NULL); 1620 1620 if (!node_ep) { 1621 1621 dev_warn(dev, "no endpoint defined for node: %s\n", 1622 1622 node->full_name);
+1
drivers/media/media-device.c
··· 93 93 struct media_entity *ent; 94 94 struct media_entity_desc u_ent; 95 95 96 + memset(&u_ent, 0, sizeof(u_ent)); 96 97 if (copy_from_user(&u_ent.id, &uent->id, sizeof(u_ent.id))) 97 98 return -EFAULT; 98 99
+15 -1
drivers/media/platform/davinci/vpbe_display.c
··· 372 372 { 373 373 struct vpbe_fh *fh = vb2_get_drv_priv(vq); 374 374 struct vpbe_layer *layer = fh->layer; 375 + struct vpbe_display *disp = fh->disp_dev; 376 + unsigned long flags; 375 377 376 378 if (!vb2_is_streaming(vq)) 377 379 return 0; 378 380 379 381 /* release all active buffers */ 382 + spin_lock_irqsave(&disp->dma_queue_lock, flags); 383 + if (layer->cur_frm == layer->next_frm) { 384 + vb2_buffer_done(&layer->cur_frm->vb, VB2_BUF_STATE_ERROR); 385 + } else { 386 + if (layer->cur_frm != NULL) 387 + vb2_buffer_done(&layer->cur_frm->vb, 388 + VB2_BUF_STATE_ERROR); 389 + if (layer->next_frm != NULL) 390 + vb2_buffer_done(&layer->next_frm->vb, 391 + VB2_BUF_STATE_ERROR); 392 + } 393 + 380 394 while (!list_empty(&layer->dma_queue)) { 381 395 layer->next_frm = list_entry(layer->dma_queue.next, 382 396 struct vpbe_disp_buffer, list); 383 397 list_del(&layer->next_frm->list); 384 398 vb2_buffer_done(&layer->next_frm->vb, VB2_BUF_STATE_ERROR); 385 399 } 386 - 400 + spin_unlock_irqrestore(&disp->dma_queue_lock, flags); 387 401 return 0; 388 402 } 389 403
+2
drivers/media/platform/davinci/vpfe_capture.c
··· 734 734 } 735 735 vpfe_dev->io_usrs = 0; 736 736 vpfe_dev->numbuffers = config_params.numbuffers; 737 + videobuf_stop(&vpfe_dev->buffer_queue); 738 + videobuf_mmap_free(&vpfe_dev->buffer_queue); 737 739 } 738 740 739 741 /* Decrement device usrs counter */
+23 -11
drivers/media/platform/davinci/vpif_capture.c
··· 358 358 359 359 common = &ch->common[VPIF_VIDEO_INDEX]; 360 360 361 + /* Disable channel as per its device type and channel id */ 362 + if (VPIF_CHANNEL0_VIDEO == ch->channel_id) { 363 + enable_channel0(0); 364 + channel0_intr_enable(0); 365 + } 366 + if ((VPIF_CHANNEL1_VIDEO == ch->channel_id) || 367 + (2 == common->started)) { 368 + enable_channel1(0); 369 + channel1_intr_enable(0); 370 + } 371 + common->started = 0; 372 + 361 373 /* release all active buffers */ 362 374 spin_lock_irqsave(&common->irqlock, flags); 375 + if (common->cur_frm == common->next_frm) { 376 + vb2_buffer_done(&common->cur_frm->vb, VB2_BUF_STATE_ERROR); 377 + } else { 378 + if (common->cur_frm != NULL) 379 + vb2_buffer_done(&common->cur_frm->vb, 380 + VB2_BUF_STATE_ERROR); 381 + if (common->next_frm != NULL) 382 + vb2_buffer_done(&common->next_frm->vb, 383 + VB2_BUF_STATE_ERROR); 384 + } 385 + 363 386 while (!list_empty(&common->dma_queue)) { 364 387 common->next_frm = list_entry(common->dma_queue.next, 365 388 struct vpif_cap_buffer, list); ··· 956 933 if (fh->io_allowed[VPIF_VIDEO_INDEX]) { 957 934 /* Reset io_usrs member of channel object */ 958 935 common->io_usrs = 0; 959 - /* Disable channel as per its device type and channel id */ 960 - if (VPIF_CHANNEL0_VIDEO == ch->channel_id) { 961 - enable_channel0(0); 962 - channel0_intr_enable(0); 963 - } 964 - if ((VPIF_CHANNEL1_VIDEO == ch->channel_id) || 965 - (2 == common->started)) { 966 - enable_channel1(0); 967 - channel1_intr_enable(0); 968 - } 969 - common->started = 0; 970 936 /* Free buffers allocated */ 971 937 vb2_queue_release(&common->buffer_queue); 972 938 vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
+23 -12
drivers/media/platform/davinci/vpif_display.c
··· 320 320 321 321 common = &ch->common[VPIF_VIDEO_INDEX]; 322 322 323 + /* Disable channel */ 324 + if (VPIF_CHANNEL2_VIDEO == ch->channel_id) { 325 + enable_channel2(0); 326 + channel2_intr_enable(0); 327 + } 328 + if ((VPIF_CHANNEL3_VIDEO == ch->channel_id) || 329 + (2 == common->started)) { 330 + enable_channel3(0); 331 + channel3_intr_enable(0); 332 + } 333 + common->started = 0; 334 + 323 335 /* release all active buffers */ 324 336 spin_lock_irqsave(&common->irqlock, flags); 337 + if (common->cur_frm == common->next_frm) { 338 + vb2_buffer_done(&common->cur_frm->vb, VB2_BUF_STATE_ERROR); 339 + } else { 340 + if (common->cur_frm != NULL) 341 + vb2_buffer_done(&common->cur_frm->vb, 342 + VB2_BUF_STATE_ERROR); 343 + if (common->next_frm != NULL) 344 + vb2_buffer_done(&common->next_frm->vb, 345 + VB2_BUF_STATE_ERROR); 346 + } 347 + 325 348 while (!list_empty(&common->dma_queue)) { 326 349 common->next_frm = list_entry(common->dma_queue.next, 327 350 struct vpif_disp_buffer, list); ··· 796 773 if (fh->io_allowed[VPIF_VIDEO_INDEX]) { 797 774 /* Reset io_usrs member of channel object */ 798 775 common->io_usrs = 0; 799 - /* Disable channel */ 800 - if (VPIF_CHANNEL2_VIDEO == ch->channel_id) { 801 - enable_channel2(0); 802 - channel2_intr_enable(0); 803 - } 804 - if ((VPIF_CHANNEL3_VIDEO == ch->channel_id) || 805 - (2 == common->started)) { 806 - enable_channel3(0); 807 - channel3_intr_enable(0); 808 - } 809 - common->started = 0; 810 - 811 776 /* Free buffers allocated */ 812 777 vb2_queue_release(&common->buffer_queue); 813 778 vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
+1 -1
drivers/media/platform/exynos4-is/fimc-core.c
··· 122 122 }, { 123 123 .name = "YUV 4:2:2 planar, Y/Cb/Cr", 124 124 .fourcc = V4L2_PIX_FMT_YUV422P, 125 - .depth = { 12 }, 125 + .depth = { 16 }, 126 126 .color = FIMC_FMT_YCBYCR422, 127 127 .memplanes = 1, 128 128 .colplanes = 3,
+3 -3
drivers/media/tuners/fc2580.c
··· 195 195 196 196 f_ref = 2UL * priv->cfg->clock / r_val; 197 197 n_val = div_u64_rem(f_vco, f_ref, &k_val); 198 - k_val_reg = 1UL * k_val * (1 << 20) / f_ref; 198 + k_val_reg = div_u64(1ULL * k_val * (1 << 20), f_ref); 199 199 200 200 ret = fc2580_wr_reg(priv, 0x18, r18_val | ((k_val_reg >> 16) & 0xff)); 201 201 if (ret < 0) ··· 348 348 if (ret < 0) 349 349 goto err; 350 350 351 - ret = fc2580_wr_reg(priv, 0x37, 1UL * priv->cfg->clock * \ 352 - fc2580_if_filter_lut[i].mul / 1000000000); 351 + ret = fc2580_wr_reg(priv, 0x37, div_u64(1ULL * priv->cfg->clock * 352 + fc2580_if_filter_lut[i].mul, 1000000000)); 353 353 if (ret < 0) 354 354 goto err; 355 355
+1
drivers/media/tuners/fc2580_priv.h
··· 22 22 #define FC2580_PRIV_H 23 23 24 24 #include "fc2580.h" 25 + #include <linux/math64.h> 25 26 26 27 struct fc2580_reg_val { 27 28 u8 reg;
-1
drivers/media/usb/dvb-usb-v2/Makefile
··· 41 41 ccflags-y += -I$(srctree)/drivers/media/dvb-frontends 42 42 ccflags-y += -I$(srctree)/drivers/media/tuners 43 43 ccflags-y += -I$(srctree)/drivers/media/common 44 - ccflags-y += -I$(srctree)/drivers/staging/media/rtl2832u_sdr
+43 -5
drivers/media/usb/dvb-usb-v2/rtl28xxu.c
··· 24 24 25 25 #include "rtl2830.h" 26 26 #include "rtl2832.h" 27 - #include "rtl2832_sdr.h" 28 27 29 28 #include "qt1010.h" 30 29 #include "mt2060.h" ··· 34 35 #include "fc2580.h" 35 36 #include "tua9001.h" 36 37 #include "r820t.h" 38 + 39 + /* 40 + * RTL2832_SDR module is in staging. That logic is added in order to avoid any 41 + * hard dependency to drivers/staging/ directory as we want compile mainline 42 + * driver even whole staging directory is missing. 43 + */ 44 + #include <media/v4l2-subdev.h> 45 + 46 + #if IS_ENABLED(CONFIG_DVB_RTL2832_SDR) 47 + struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe, 48 + struct i2c_adapter *i2c, const struct rtl2832_config *cfg, 49 + struct v4l2_subdev *sd); 50 + #else 51 + static inline struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe, 52 + struct i2c_adapter *i2c, const struct rtl2832_config *cfg, 53 + struct v4l2_subdev *sd) 54 + { 55 + return NULL; 56 + } 57 + #endif 58 + 59 + #ifdef CONFIG_MEDIA_ATTACH 60 + #define dvb_attach_sdr(FUNCTION, ARGS...) ({ \ 61 + void *__r = NULL; \ 62 + typeof(&FUNCTION) __a = symbol_request(FUNCTION); \ 63 + if (__a) { \ 64 + __r = (void *) __a(ARGS); \ 65 + if (__r == NULL) \ 66 + symbol_put(FUNCTION); \ 67 + } \ 68 + __r; \ 69 + }) 70 + 71 + #else 72 + #define dvb_attach_sdr(FUNCTION, ARGS...) ({ \ 73 + FUNCTION(ARGS); \ 74 + }) 75 + 76 + #endif 37 77 38 78 static int rtl28xxu_disable_rc; 39 79 module_param_named(disable_rc, rtl28xxu_disable_rc, int, 0644); ··· 946 908 adap->fe[0]->ops.tuner_ops.get_rf_strength; 947 909 948 910 /* attach SDR */ 949 - dvb_attach(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap, 911 + dvb_attach_sdr(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap, 950 912 &rtl28xxu_rtl2832_fc0012_config, NULL); 951 913 break; 952 914 case TUNER_RTL2832_FC0013: ··· 958 920 adap->fe[0]->ops.tuner_ops.get_rf_strength; 959 921 960 922 /* attach SDR */ 961 - dvb_attach(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap, 923 + dvb_attach_sdr(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap, 962 924 &rtl28xxu_rtl2832_fc0013_config, NULL); 963 925 break; 964 926 case TUNER_RTL2832_E4000: { ··· 989 951 i2c_set_adapdata(i2c_adap_internal, d); 990 952 991 953 /* attach SDR */ 992 - dvb_attach(rtl2832_sdr_attach, adap->fe[0], 954 + dvb_attach_sdr(rtl2832_sdr_attach, adap->fe[0], 993 955 i2c_adap_internal, 994 956 &rtl28xxu_rtl2832_e4000_config, sd); 995 957 } ··· 1020 982 adap->fe[0]->ops.tuner_ops.get_rf_strength; 1021 983 1022 984 /* attach SDR */ 1023 - dvb_attach(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap, 985 + dvb_attach_sdr(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap, 1024 986 &rtl28xxu_rtl2832_r820t_config, NULL); 1025 987 break; 1026 988 case TUNER_RTL2832_R828D:
-2
drivers/media/usb/gspca/sonixb.c
··· 1430 1430 {USB_DEVICE(0x0c45, 0x600d), SB(PAS106, 101)}, 1431 1431 {USB_DEVICE(0x0c45, 0x6011), SB(OV6650, 101)}, 1432 1432 {USB_DEVICE(0x0c45, 0x6019), SB(OV7630, 101)}, 1433 - #if !IS_ENABLED(CONFIG_USB_SN9C102) 1434 1433 {USB_DEVICE(0x0c45, 0x6024), SB(TAS5130CXX, 102)}, 1435 1434 {USB_DEVICE(0x0c45, 0x6025), SB(TAS5130CXX, 102)}, 1436 - #endif 1437 1435 {USB_DEVICE(0x0c45, 0x6027), SB(OV7630, 101)}, /* Genius Eye 310 */ 1438 1436 {USB_DEVICE(0x0c45, 0x6028), SB(PAS202, 102)}, 1439 1437 {USB_DEVICE(0x0c45, 0x6029), SB(PAS106, 102)},
+7 -5
drivers/media/v4l2-core/v4l2-compat-ioctl32.c
··· 178 178 179 179 static int __get_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up) 180 180 { 181 + if (get_user(kp->type, &up->type)) 182 + return -EFAULT; 183 + 181 184 switch (kp->type) { 182 185 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 183 186 case V4L2_BUF_TYPE_VIDEO_OUTPUT: ··· 207 204 208 205 static int get_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up) 209 206 { 210 - if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_format32)) || 211 - get_user(kp->type, &up->type)) 212 - return -EFAULT; 207 + if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_format32))) 208 + return -EFAULT; 213 209 return __get_v4l2_format32(kp, up); 214 210 } 215 211 216 212 static int get_v4l2_create32(struct v4l2_create_buffers *kp, struct v4l2_create_buffers32 __user *up) 217 213 { 218 214 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_create_buffers32)) || 219 - copy_from_user(kp, up, offsetof(struct v4l2_create_buffers32, format.fmt))) 220 - return -EFAULT; 215 + copy_from_user(kp, up, offsetof(struct v4l2_create_buffers32, format))) 216 + return -EFAULT; 221 217 return __get_v4l2_format32(&kp->format, &up->format); 222 218 } 223 219
+11 -2
drivers/staging/media/davinci_vpfe/vpfe_video.c
··· 1247 1247 struct vpfe_fh *fh = vb2_get_drv_priv(vq); 1248 1248 struct vpfe_video_device *video = fh->video; 1249 1249 1250 - if (!vb2_is_streaming(vq)) 1251 - return 0; 1252 1250 /* release all active buffers */ 1251 + if (video->cur_frm == video->next_frm) { 1252 + vb2_buffer_done(&video->cur_frm->vb, VB2_BUF_STATE_ERROR); 1253 + } else { 1254 + if (video->cur_frm != NULL) 1255 + vb2_buffer_done(&video->cur_frm->vb, 1256 + VB2_BUF_STATE_ERROR); 1257 + if (video->next_frm != NULL) 1258 + vb2_buffer_done(&video->next_frm->vb, 1259 + VB2_BUF_STATE_ERROR); 1260 + } 1261 + 1253 1262 while (!list_empty(&video->dma_queue)) { 1254 1263 video->next_frm = list_entry(video->dma_queue.next, 1255 1264 struct vpfe_cap_buffer, list);
-2
drivers/staging/media/sn9c102/sn9c102_devtable.h
··· 48 48 { SN9C102_USB_DEVICE(0x0c45, 0x600d, BRIDGE_SN9C102), }, 49 49 /* { SN9C102_USB_DEVICE(0x0c45, 0x6011, BRIDGE_SN9C102), }, OV6650 */ 50 50 { SN9C102_USB_DEVICE(0x0c45, 0x6019, BRIDGE_SN9C102), }, 51 - #endif 52 51 { SN9C102_USB_DEVICE(0x0c45, 0x6024, BRIDGE_SN9C102), }, 53 52 { SN9C102_USB_DEVICE(0x0c45, 0x6025, BRIDGE_SN9C102), }, 54 - #if !defined CONFIG_USB_GSPCA_SONIXB && !defined CONFIG_USB_GSPCA_SONIXB_MODULE 55 53 { SN9C102_USB_DEVICE(0x0c45, 0x6028, BRIDGE_SN9C102), }, 56 54 { SN9C102_USB_DEVICE(0x0c45, 0x6029, BRIDGE_SN9C102), }, 57 55 { SN9C102_USB_DEVICE(0x0c45, 0x602a, BRIDGE_SN9C102), },