aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/common/tuners/tda18271-common.c11
-rw-r--r--drivers/media/common/tuners/tda18271-fe.c21
-rw-r--r--drivers/media/common/tuners/tda18271-maps.c12
-rw-r--r--drivers/media/dvb/b2c2/flexcop-pci.c2
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig4
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_devices.c6
-rw-r--r--drivers/media/media-entity.c8
-rw-r--r--drivers/media/video/Kconfig2
-rw-r--r--drivers/media/video/cx18/cx18-streams.c10
-rw-r--r--drivers/media/video/cx23885/Kconfig1
-rw-r--r--drivers/media/video/imx074.c2
-rw-r--r--drivers/media/video/omap3isp/isp.c34
-rw-r--r--drivers/media/video/omap3isp/isp.h12
-rw-r--r--drivers/media/video/omap3isp/ispccdc.c37
-rw-r--r--drivers/media/video/omap3isp/isppreview.c2
-rw-r--r--drivers/media/video/omap3isp/ispqueue.c6
-rw-r--r--drivers/media/video/omap3isp/ispresizer.c75
-rw-r--r--drivers/media/video/omap3isp/ispstat.h6
-rw-r--r--drivers/media/video/omap3isp/ispvideo.c108
-rw-r--r--drivers/media/video/omap3isp/ispvideo.h3
-rw-r--r--drivers/media/video/s5p-fimc/fimc-capture.c8
-rw-r--r--drivers/media/video/s5p-fimc/fimc-core.c74
-rw-r--r--drivers/media/video/sh_mobile_ceu_camera.c10
-rw-r--r--drivers/media/video/sh_mobile_csi2.c11
-rw-r--r--drivers/media/video/soc_camera.c7
-rw-r--r--drivers/media/video/v4l2-dev.c15
-rw-r--r--drivers/media/video/videobuf2-core.c17
-rw-r--r--drivers/media/video/videobuf2-dma-contig.c2
28 files changed, 361 insertions, 145 deletions
diff --git a/drivers/media/common/tuners/tda18271-common.c b/drivers/media/common/tuners/tda18271-common.c
index 5466d47db899..aae40e52af5b 100644
--- a/drivers/media/common/tuners/tda18271-common.c
+++ b/drivers/media/common/tuners/tda18271-common.c
@@ -533,16 +533,7 @@ int tda18271_calc_main_pll(struct dvb_frontend *fe, u32 freq)
533 if (tda_fail(ret)) 533 if (tda_fail(ret))
534 goto fail; 534 goto fail;
535 535
536 regs[R_MPD] = (0x77 & pd); 536 regs[R_MPD] = (0x7f & pd);
537
538 switch (priv->mode) {
539 case TDA18271_ANALOG:
540 regs[R_MPD] &= ~0x08;
541 break;
542 case TDA18271_DIGITAL:
543 regs[R_MPD] |= 0x08;
544 break;
545 }
546 537
547 div = ((d * (freq / 1000)) << 7) / 125; 538 div = ((d * (freq / 1000)) << 7) / 125;
548 539
diff --git a/drivers/media/common/tuners/tda18271-fe.c b/drivers/media/common/tuners/tda18271-fe.c
index 9ad4454a148d..d884f5eee73c 100644
--- a/drivers/media/common/tuners/tda18271-fe.c
+++ b/drivers/media/common/tuners/tda18271-fe.c
@@ -579,8 +579,8 @@ static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq)
579#define RF3 2 579#define RF3 2
580 u32 rf_default[3]; 580 u32 rf_default[3];
581 u32 rf_freq[3]; 581 u32 rf_freq[3];
582 u8 prog_cal[3]; 582 s32 prog_cal[3];
583 u8 prog_tab[3]; 583 s32 prog_tab[3];
584 584
585 i = tda18271_lookup_rf_band(fe, &freq, NULL); 585 i = tda18271_lookup_rf_band(fe, &freq, NULL);
586 586
@@ -602,32 +602,33 @@ static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq)
602 return bcal; 602 return bcal;
603 603
604 tda18271_calc_rf_cal(fe, &rf_freq[rf]); 604 tda18271_calc_rf_cal(fe, &rf_freq[rf]);
605 prog_tab[rf] = regs[R_EB14]; 605 prog_tab[rf] = (s32)regs[R_EB14];
606 606
607 if (1 == bcal) 607 if (1 == bcal)
608 prog_cal[rf] = tda18271_calibrate_rf(fe, rf_freq[rf]); 608 prog_cal[rf] =
609 (s32)tda18271_calibrate_rf(fe, rf_freq[rf]);
609 else 610 else
610 prog_cal[rf] = prog_tab[rf]; 611 prog_cal[rf] = prog_tab[rf];
611 612
612 switch (rf) { 613 switch (rf) {
613 case RF1: 614 case RF1:
614 map[i].rf_a1 = 0; 615 map[i].rf_a1 = 0;
615 map[i].rf_b1 = (s32)(prog_cal[RF1] - prog_tab[RF1]); 616 map[i].rf_b1 = (prog_cal[RF1] - prog_tab[RF1]);
616 map[i].rf1 = rf_freq[RF1] / 1000; 617 map[i].rf1 = rf_freq[RF1] / 1000;
617 break; 618 break;
618 case RF2: 619 case RF2:
619 dividend = (s32)(prog_cal[RF2] - prog_tab[RF2]) - 620 dividend = (prog_cal[RF2] - prog_tab[RF2] -
620 (s32)(prog_cal[RF1] + prog_tab[RF1]); 621 prog_cal[RF1] + prog_tab[RF1]);
621 divisor = (s32)(rf_freq[RF2] - rf_freq[RF1]) / 1000; 622 divisor = (s32)(rf_freq[RF2] - rf_freq[RF1]) / 1000;
622 map[i].rf_a1 = (dividend / divisor); 623 map[i].rf_a1 = (dividend / divisor);
623 map[i].rf2 = rf_freq[RF2] / 1000; 624 map[i].rf2 = rf_freq[RF2] / 1000;
624 break; 625 break;
625 case RF3: 626 case RF3:
626 dividend = (s32)(prog_cal[RF3] - prog_tab[RF3]) - 627 dividend = (prog_cal[RF3] - prog_tab[RF3] -
627 (s32)(prog_cal[RF2] + prog_tab[RF2]); 628 prog_cal[RF2] + prog_tab[RF2]);
628 divisor = (s32)(rf_freq[RF3] - rf_freq[RF2]) / 1000; 629 divisor = (s32)(rf_freq[RF3] - rf_freq[RF2]) / 1000;
629 map[i].rf_a2 = (dividend / divisor); 630 map[i].rf_a2 = (dividend / divisor);
630 map[i].rf_b2 = (s32)(prog_cal[RF2] - prog_tab[RF2]); 631 map[i].rf_b2 = (prog_cal[RF2] - prog_tab[RF2]);
631 map[i].rf3 = rf_freq[RF3] / 1000; 632 map[i].rf3 = rf_freq[RF3] / 1000;
632 break; 633 break;
633 default: 634 default:
diff --git a/drivers/media/common/tuners/tda18271-maps.c b/drivers/media/common/tuners/tda18271-maps.c
index e7f84c705da8..3d5b6ab7e332 100644
--- a/drivers/media/common/tuners/tda18271-maps.c
+++ b/drivers/media/common/tuners/tda18271-maps.c
@@ -229,8 +229,7 @@ static struct tda18271_map tda18271c2_km[] = {
229static struct tda18271_map tda18271_rf_band[] = { 229static struct tda18271_map tda18271_rf_band[] = {
230 { .rfmax = 47900, .val = 0x00 }, 230 { .rfmax = 47900, .val = 0x00 },
231 { .rfmax = 61100, .val = 0x01 }, 231 { .rfmax = 61100, .val = 0x01 },
232/* { .rfmax = 152600, .val = 0x02 }, */ 232 { .rfmax = 152600, .val = 0x02 },
233 { .rfmax = 121200, .val = 0x02 },
234 { .rfmax = 164700, .val = 0x03 }, 233 { .rfmax = 164700, .val = 0x03 },
235 { .rfmax = 203500, .val = 0x04 }, 234 { .rfmax = 203500, .val = 0x04 },
236 { .rfmax = 457800, .val = 0x05 }, 235 { .rfmax = 457800, .val = 0x05 },
@@ -448,7 +447,7 @@ static struct tda18271_map tda18271c2_rf_cal[] = {
448 { .rfmax = 150000, .val = 0xb0 }, 447 { .rfmax = 150000, .val = 0xb0 },
449 { .rfmax = 151000, .val = 0xb1 }, 448 { .rfmax = 151000, .val = 0xb1 },
450 { .rfmax = 152000, .val = 0xb7 }, 449 { .rfmax = 152000, .val = 0xb7 },
451 { .rfmax = 153000, .val = 0xbd }, 450 { .rfmax = 152600, .val = 0xbd },
452 { .rfmax = 154000, .val = 0x20 }, 451 { .rfmax = 154000, .val = 0x20 },
453 { .rfmax = 155000, .val = 0x22 }, 452 { .rfmax = 155000, .val = 0x22 },
454 { .rfmax = 156000, .val = 0x24 }, 453 { .rfmax = 156000, .val = 0x24 },
@@ -459,7 +458,7 @@ static struct tda18271_map tda18271c2_rf_cal[] = {
459 { .rfmax = 161000, .val = 0x2d }, 458 { .rfmax = 161000, .val = 0x2d },
460 { .rfmax = 163000, .val = 0x2e }, 459 { .rfmax = 163000, .val = 0x2e },
461 { .rfmax = 164000, .val = 0x2f }, 460 { .rfmax = 164000, .val = 0x2f },
462 { .rfmax = 165000, .val = 0x30 }, 461 { .rfmax = 164700, .val = 0x30 },
463 { .rfmax = 166000, .val = 0x11 }, 462 { .rfmax = 166000, .val = 0x11 },
464 { .rfmax = 167000, .val = 0x12 }, 463 { .rfmax = 167000, .val = 0x12 },
465 { .rfmax = 168000, .val = 0x13 }, 464 { .rfmax = 168000, .val = 0x13 },
@@ -510,7 +509,8 @@ static struct tda18271_map tda18271c2_rf_cal[] = {
510 { .rfmax = 236000, .val = 0x1b }, 509 { .rfmax = 236000, .val = 0x1b },
511 { .rfmax = 237000, .val = 0x1c }, 510 { .rfmax = 237000, .val = 0x1c },
512 { .rfmax = 240000, .val = 0x1d }, 511 { .rfmax = 240000, .val = 0x1d },
513 { .rfmax = 242000, .val = 0x1f }, 512 { .rfmax = 242000, .val = 0x1e },
513 { .rfmax = 244000, .val = 0x1f },
514 { .rfmax = 247000, .val = 0x20 }, 514 { .rfmax = 247000, .val = 0x20 },
515 { .rfmax = 249000, .val = 0x21 }, 515 { .rfmax = 249000, .val = 0x21 },
516 { .rfmax = 252000, .val = 0x22 }, 516 { .rfmax = 252000, .val = 0x22 },
@@ -624,7 +624,7 @@ static struct tda18271_map tda18271c2_rf_cal[] = {
624 { .rfmax = 453000, .val = 0x93 }, 624 { .rfmax = 453000, .val = 0x93 },
625 { .rfmax = 454000, .val = 0x94 }, 625 { .rfmax = 454000, .val = 0x94 },
626 { .rfmax = 456000, .val = 0x96 }, 626 { .rfmax = 456000, .val = 0x96 },
627 { .rfmax = 457000, .val = 0x98 }, 627 { .rfmax = 457800, .val = 0x98 },
628 { .rfmax = 461000, .val = 0x11 }, 628 { .rfmax = 461000, .val = 0x11 },
629 { .rfmax = 468000, .val = 0x12 }, 629 { .rfmax = 468000, .val = 0x12 },
630 { .rfmax = 472000, .val = 0x13 }, 630 { .rfmax = 472000, .val = 0x13 },
diff --git a/drivers/media/dvb/b2c2/flexcop-pci.c b/drivers/media/dvb/b2c2/flexcop-pci.c
index 955254090a0e..03f96d6ca894 100644
--- a/drivers/media/dvb/b2c2/flexcop-pci.c
+++ b/drivers/media/dvb/b2c2/flexcop-pci.c
@@ -38,7 +38,7 @@ MODULE_PARM_DESC(debug,
38 DEBSTATUS); 38 DEBSTATUS);
39 39
40#define DRIVER_VERSION "0.1" 40#define DRIVER_VERSION "0.1"
41#define DRIVER_NAME "Technisat/B2C2 FlexCop II/IIb/III Digital TV PCI Driver" 41#define DRIVER_NAME "flexcop-pci"
42#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@desy.de>" 42#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@desy.de>"
43 43
44struct flexcop_pci { 44struct flexcop_pci {
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index fe4f894183ff..ccbd39a38c46 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -362,7 +362,7 @@ config DVB_USB_LME2510
362config DVB_USB_TECHNISAT_USB2 362config DVB_USB_TECHNISAT_USB2
363 tristate "Technisat DVB-S/S2 USB2.0 support" 363 tristate "Technisat DVB-S/S2 USB2.0 support"
364 depends on DVB_USB 364 depends on DVB_USB
365 select DVB_STB0899 if !DVB_FE_CUSTOMISE 365 select DVB_STV090x if !DVB_FE_CUSTOMISE
366 select DVB_STB6100 if !DVB_FE_CUSTOMISE 366 select DVB_STV6110x if !DVB_FE_CUSTOMISE
367 help 367 help
368 Say Y here to support the Technisat USB2 DVB-S/S2 device 368 Say Y here to support the Technisat USB2 DVB-S/S2 device
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c
index 97af266d7f1d..65214af5cd74 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c
@@ -2162,7 +2162,7 @@ struct dibx000_agc_config dib7090_agc_config[2] = {
2162 .agc1_pt3 = 98, 2162 .agc1_pt3 = 98,
2163 .agc1_slope1 = 0, 2163 .agc1_slope1 = 0,
2164 .agc1_slope2 = 167, 2164 .agc1_slope2 = 167,
2165 .agc1_pt1 = 98, 2165 .agc2_pt1 = 98,
2166 .agc2_pt2 = 255, 2166 .agc2_pt2 = 255,
2167 .agc2_slope1 = 104, 2167 .agc2_slope1 = 104,
2168 .agc2_slope2 = 0, 2168 .agc2_slope2 = 0,
@@ -2440,11 +2440,11 @@ static int tfe7090pvr_frontend0_attach(struct dvb_usb_adapter *adap)
2440 dib0700_set_i2c_speed(adap->dev, 340); 2440 dib0700_set_i2c_speed(adap->dev, 340);
2441 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x90, &tfe7090pvr_dib7000p_config[0]); 2441 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x90, &tfe7090pvr_dib7000p_config[0]);
2442 2442
2443 dib7090_slave_reset(adap->fe);
2444
2445 if (adap->fe == NULL) 2443 if (adap->fe == NULL)
2446 return -ENODEV; 2444 return -ENODEV;
2447 2445
2446 dib7090_slave_reset(adap->fe);
2447
2448 return 0; 2448 return 0;
2449} 2449}
2450 2450
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 23640ed44d85..056138f63c7d 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -378,7 +378,6 @@ EXPORT_SYMBOL_GPL(media_entity_create_link);
378 378
379static int __media_entity_setup_link_notify(struct media_link *link, u32 flags) 379static int __media_entity_setup_link_notify(struct media_link *link, u32 flags)
380{ 380{
381 const u32 mask = MEDIA_LNK_FL_ENABLED;
382 int ret; 381 int ret;
383 382
384 /* Notify both entities. */ 383 /* Notify both entities. */
@@ -395,7 +394,7 @@ static int __media_entity_setup_link_notify(struct media_link *link, u32 flags)
395 return ret; 394 return ret;
396 } 395 }
397 396
398 link->flags = (link->flags & ~mask) | (flags & mask); 397 link->flags = flags;
399 link->reverse->flags = link->flags; 398 link->reverse->flags = link->flags;
400 399
401 return 0; 400 return 0;
@@ -417,6 +416,7 @@ static int __media_entity_setup_link_notify(struct media_link *link, u32 flags)
417 */ 416 */
418int __media_entity_setup_link(struct media_link *link, u32 flags) 417int __media_entity_setup_link(struct media_link *link, u32 flags)
419{ 418{
419 const u32 mask = MEDIA_LNK_FL_ENABLED;
420 struct media_device *mdev; 420 struct media_device *mdev;
421 struct media_entity *source, *sink; 421 struct media_entity *source, *sink;
422 int ret = -EBUSY; 422 int ret = -EBUSY;
@@ -424,6 +424,10 @@ int __media_entity_setup_link(struct media_link *link, u32 flags)
424 if (link == NULL) 424 if (link == NULL)
425 return -EINVAL; 425 return -EINVAL;
426 426
427 /* The non-modifiable link flags must not be modified. */
428 if ((link->flags & ~mask) != (flags & ~mask))
429 return -EINVAL;
430
427 if (link->flags & MEDIA_LNK_FL_IMMUTABLE) 431 if (link->flags & MEDIA_LNK_FL_IMMUTABLE)
428 return link->flags == flags ? 0 : -EINVAL; 432 return link->flags == flags ? 0 : -EINVAL;
429 433
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 4498b944dec8..00f51dd121f3 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -875,7 +875,7 @@ config MX3_VIDEO
875config VIDEO_MX3 875config VIDEO_MX3
876 tristate "i.MX3x Camera Sensor Interface driver" 876 tristate "i.MX3x Camera Sensor Interface driver"
877 depends on VIDEO_DEV && MX3_IPU && SOC_CAMERA 877 depends on VIDEO_DEV && MX3_IPU && SOC_CAMERA
878 select VIDEOBUF_DMA_CONTIG 878 select VIDEOBUF2_DMA_CONTIG
879 select MX3_VIDEO 879 select MX3_VIDEO
880 ---help--- 880 ---help---
881 This is a v4l2 driver for the i.MX3x Camera Sensor Interface 881 This is a v4l2 driver for the i.MX3x Camera Sensor Interface
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c
index c6e2ca3b1149..6fbc356113c1 100644
--- a/drivers/media/video/cx18/cx18-streams.c
+++ b/drivers/media/video/cx18/cx18-streams.c
@@ -350,9 +350,17 @@ void cx18_streams_cleanup(struct cx18 *cx, int unregister)
350 350
351 /* No struct video_device, but can have buffers allocated */ 351 /* No struct video_device, but can have buffers allocated */
352 if (type == CX18_ENC_STREAM_TYPE_IDX) { 352 if (type == CX18_ENC_STREAM_TYPE_IDX) {
353 /* If the module params didn't inhibit IDX ... */
353 if (cx->stream_buffers[type] != 0) { 354 if (cx->stream_buffers[type] != 0) {
354 cx->stream_buffers[type] = 0; 355 cx->stream_buffers[type] = 0;
355 cx18_stream_free(&cx->streams[type]); 356 /*
357 * Before calling cx18_stream_free(),
358 * check if the IDX stream was actually set up.
359 * Needed, since the cx18_probe() error path
360 * exits through here as well as normal clean up
361 */
362 if (cx->streams[type].buffers != 0)
363 cx18_stream_free(&cx->streams[type]);
356 } 364 }
357 continue; 365 continue;
358 } 366 }
diff --git a/drivers/media/video/cx23885/Kconfig b/drivers/media/video/cx23885/Kconfig
index 3b6e7f28568e..caab1bfb79e2 100644
--- a/drivers/media/video/cx23885/Kconfig
+++ b/drivers/media/video/cx23885/Kconfig
@@ -22,6 +22,7 @@ config VIDEO_CX23885
22 select DVB_CX24116 if !DVB_FE_CUSTOMISE 22 select DVB_CX24116 if !DVB_FE_CUSTOMISE
23 select DVB_STV0900 if !DVB_FE_CUSTOMISE 23 select DVB_STV0900 if !DVB_FE_CUSTOMISE
24 select DVB_DS3000 if !DVB_FE_CUSTOMISE 24 select DVB_DS3000 if !DVB_FE_CUSTOMISE
25 select DVB_STV0367 if !DVB_FE_CUSTOMISE
25 select MEDIA_TUNER_MT2131 if !MEDIA_TUNER_CUSTOMISE 26 select MEDIA_TUNER_MT2131 if !MEDIA_TUNER_CUSTOMISE
26 select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMISE 27 select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMISE
27 select MEDIA_TUNER_TDA8290 if !MEDIA_TUNER_CUSTOMISE 28 select MEDIA_TUNER_TDA8290 if !MEDIA_TUNER_CUSTOMISE
diff --git a/drivers/media/video/imx074.c b/drivers/media/video/imx074.c
index 1a1169115716..0382ea752e6f 100644
--- a/drivers/media/video/imx074.c
+++ b/drivers/media/video/imx074.c
@@ -298,7 +298,7 @@ static unsigned long imx074_query_bus_param(struct soc_camera_device *icd)
298static int imx074_set_bus_param(struct soc_camera_device *icd, 298static int imx074_set_bus_param(struct soc_camera_device *icd,
299 unsigned long flags) 299 unsigned long flags)
300{ 300{
301 return -1; 301 return -EINVAL;
302} 302}
303 303
304static struct soc_camera_ops imx074_ops = { 304static struct soc_camera_ops imx074_ops = {
diff --git a/drivers/media/video/omap3isp/isp.c b/drivers/media/video/omap3isp/isp.c
index 503bd7922bd6..472a69359e60 100644
--- a/drivers/media/video/omap3isp/isp.c
+++ b/drivers/media/video/omap3isp/isp.c
@@ -215,20 +215,21 @@ static u32 isp_set_xclk(struct isp_device *isp, u32 xclk, u8 xclksel)
215 } 215 }
216 216
217 switch (xclksel) { 217 switch (xclksel) {
218 case 0: 218 case ISP_XCLK_A:
219 isp_reg_clr_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_TCTRL_CTRL, 219 isp_reg_clr_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_TCTRL_CTRL,
220 ISPTCTRL_CTRL_DIVA_MASK, 220 ISPTCTRL_CTRL_DIVA_MASK,
221 divisor << ISPTCTRL_CTRL_DIVA_SHIFT); 221 divisor << ISPTCTRL_CTRL_DIVA_SHIFT);
222 dev_dbg(isp->dev, "isp_set_xclk(): cam_xclka set to %d Hz\n", 222 dev_dbg(isp->dev, "isp_set_xclk(): cam_xclka set to %d Hz\n",
223 currentxclk); 223 currentxclk);
224 break; 224 break;
225 case 1: 225 case ISP_XCLK_B:
226 isp_reg_clr_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_TCTRL_CTRL, 226 isp_reg_clr_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_TCTRL_CTRL,
227 ISPTCTRL_CTRL_DIVB_MASK, 227 ISPTCTRL_CTRL_DIVB_MASK,
228 divisor << ISPTCTRL_CTRL_DIVB_SHIFT); 228 divisor << ISPTCTRL_CTRL_DIVB_SHIFT);
229 dev_dbg(isp->dev, "isp_set_xclk(): cam_xclkb set to %d Hz\n", 229 dev_dbg(isp->dev, "isp_set_xclk(): cam_xclkb set to %d Hz\n",
230 currentxclk); 230 currentxclk);
231 break; 231 break;
232 case ISP_XCLK_NONE:
232 default: 233 default:
233 omap3isp_put(isp); 234 omap3isp_put(isp);
234 dev_dbg(isp->dev, "ISP_ERR: isp_set_xclk(): Invalid requested " 235 dev_dbg(isp->dev, "ISP_ERR: isp_set_xclk(): Invalid requested "
@@ -237,13 +238,13 @@ static u32 isp_set_xclk(struct isp_device *isp, u32 xclk, u8 xclksel)
237 } 238 }
238 239
239 /* Do we go from stable whatever to clock? */ 240 /* Do we go from stable whatever to clock? */
240 if (divisor >= 2 && isp->xclk_divisor[xclksel] < 2) 241 if (divisor >= 2 && isp->xclk_divisor[xclksel - 1] < 2)
241 omap3isp_get(isp); 242 omap3isp_get(isp);
242 /* Stopping the clock. */ 243 /* Stopping the clock. */
243 else if (divisor < 2 && isp->xclk_divisor[xclksel] >= 2) 244 else if (divisor < 2 && isp->xclk_divisor[xclksel - 1] >= 2)
244 omap3isp_put(isp); 245 omap3isp_put(isp);
245 246
246 isp->xclk_divisor[xclksel] = divisor; 247 isp->xclk_divisor[xclksel - 1] = divisor;
247 248
248 omap3isp_put(isp); 249 omap3isp_put(isp);
249 250
@@ -285,7 +286,8 @@ static void isp_power_settings(struct isp_device *isp, int idle)
285 */ 286 */
286void omap3isp_configure_bridge(struct isp_device *isp, 287void omap3isp_configure_bridge(struct isp_device *isp,
287 enum ccdc_input_entity input, 288 enum ccdc_input_entity input,
288 const struct isp_parallel_platform_data *pdata) 289 const struct isp_parallel_platform_data *pdata,
290 unsigned int shift)
289{ 291{
290 u32 ispctrl_val; 292 u32 ispctrl_val;
291 293
@@ -298,9 +300,9 @@ void omap3isp_configure_bridge(struct isp_device *isp,
298 switch (input) { 300 switch (input) {
299 case CCDC_INPUT_PARALLEL: 301 case CCDC_INPUT_PARALLEL:
300 ispctrl_val |= ISPCTRL_PAR_SER_CLK_SEL_PARALLEL; 302 ispctrl_val |= ISPCTRL_PAR_SER_CLK_SEL_PARALLEL;
301 ispctrl_val |= pdata->data_lane_shift << ISPCTRL_SHIFT_SHIFT;
302 ispctrl_val |= pdata->clk_pol << ISPCTRL_PAR_CLK_POL_SHIFT; 303 ispctrl_val |= pdata->clk_pol << ISPCTRL_PAR_CLK_POL_SHIFT;
303 ispctrl_val |= pdata->bridge << ISPCTRL_PAR_BRIDGE_SHIFT; 304 ispctrl_val |= pdata->bridge << ISPCTRL_PAR_BRIDGE_SHIFT;
305 shift += pdata->data_lane_shift * 2;
304 break; 306 break;
305 307
306 case CCDC_INPUT_CSI2A: 308 case CCDC_INPUT_CSI2A:
@@ -319,6 +321,8 @@ void omap3isp_configure_bridge(struct isp_device *isp,
319 return; 321 return;
320 } 322 }
321 323
324 ispctrl_val |= ((shift/2) << ISPCTRL_SHIFT_SHIFT) & ISPCTRL_SHIFT_MASK;
325
322 ispctrl_val &= ~ISPCTRL_SYNC_DETECT_MASK; 326 ispctrl_val &= ~ISPCTRL_SYNC_DETECT_MASK;
323 ispctrl_val |= ISPCTRL_SYNC_DETECT_VSRISE; 327 ispctrl_val |= ISPCTRL_SYNC_DETECT_VSRISE;
324 328
@@ -658,6 +662,8 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, int use)
658 662
659 /* Apply power change to connected non-nodes. */ 663 /* Apply power change to connected non-nodes. */
660 ret = isp_pipeline_pm_power(entity, change); 664 ret = isp_pipeline_pm_power(entity, change);
665 if (ret < 0)
666 entity->use_count -= change;
661 667
662 mutex_unlock(&entity->parent->graph_mutex); 668 mutex_unlock(&entity->parent->graph_mutex);
663 669
@@ -872,6 +878,9 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe)
872 } 878 }
873 } 879 }
874 880
881 if (failure < 0)
882 isp->needs_reset = true;
883
875 return failure; 884 return failure;
876} 885}
877 886
@@ -884,7 +893,8 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe)
884 * single-shot or continuous mode. 893 * single-shot or continuous mode.
885 * 894 *
886 * Return 0 if successful, or the return value of the failed video::s_stream 895 * Return 0 if successful, or the return value of the failed video::s_stream
887 * operation otherwise. 896 * operation otherwise. The pipeline state is not updated when the operation
897 * fails, except when stopping the pipeline.
888 */ 898 */
889int omap3isp_pipeline_set_stream(struct isp_pipeline *pipe, 899int omap3isp_pipeline_set_stream(struct isp_pipeline *pipe,
890 enum isp_pipeline_stream_state state) 900 enum isp_pipeline_stream_state state)
@@ -895,7 +905,9 @@ int omap3isp_pipeline_set_stream(struct isp_pipeline *pipe,
895 ret = isp_pipeline_disable(pipe); 905 ret = isp_pipeline_disable(pipe);
896 else 906 else
897 ret = isp_pipeline_enable(pipe, state); 907 ret = isp_pipeline_enable(pipe, state);
898 pipe->stream_state = state; 908
909 if (ret == 0 || state == ISP_PIPELINE_STREAM_STOPPED)
910 pipe->stream_state = state;
899 911
900 return ret; 912 return ret;
901} 913}
@@ -1481,6 +1493,10 @@ void omap3isp_put(struct isp_device *isp)
1481 if (--isp->ref_count == 0) { 1493 if (--isp->ref_count == 0) {
1482 isp_disable_interrupts(isp); 1494 isp_disable_interrupts(isp);
1483 isp_save_ctx(isp); 1495 isp_save_ctx(isp);
1496 if (isp->needs_reset) {
1497 isp_reset(isp);
1498 isp->needs_reset = false;
1499 }
1484 isp_disable_clocks(isp); 1500 isp_disable_clocks(isp);
1485 } 1501 }
1486 mutex_unlock(&isp->isp_mutex); 1502 mutex_unlock(&isp->isp_mutex);
diff --git a/drivers/media/video/omap3isp/isp.h b/drivers/media/video/omap3isp/isp.h
index cf5214e95a92..2620c405f5e4 100644
--- a/drivers/media/video/omap3isp/isp.h
+++ b/drivers/media/video/omap3isp/isp.h
@@ -132,7 +132,6 @@ struct isp_reg {
132 132
133/** 133/**
134 * struct isp_parallel_platform_data - Parallel interface platform data 134 * struct isp_parallel_platform_data - Parallel interface platform data
135 * @width: Parallel bus width in bits (8, 10, 11 or 12)
136 * @data_lane_shift: Data lane shifter 135 * @data_lane_shift: Data lane shifter
137 * 0 - CAMEXT[13:0] -> CAM[13:0] 136 * 0 - CAMEXT[13:0] -> CAM[13:0]
138 * 1 - CAMEXT[13:2] -> CAM[11:0] 137 * 1 - CAMEXT[13:2] -> CAM[11:0]
@@ -146,7 +145,6 @@ struct isp_reg {
146 * ISPCTRL_PAR_BRIDGE_BENDIAN - Big endian 145 * ISPCTRL_PAR_BRIDGE_BENDIAN - Big endian
147 */ 146 */
148struct isp_parallel_platform_data { 147struct isp_parallel_platform_data {
149 unsigned int width;
150 unsigned int data_lane_shift:2; 148 unsigned int data_lane_shift:2;
151 unsigned int clk_pol:1; 149 unsigned int clk_pol:1;
152 unsigned int bridge:4; 150 unsigned int bridge:4;
@@ -262,6 +260,7 @@ struct isp_device {
262 /* ISP Obj */ 260 /* ISP Obj */
263 spinlock_t stat_lock; /* common lock for statistic drivers */ 261 spinlock_t stat_lock; /* common lock for statistic drivers */
264 struct mutex isp_mutex; /* For handling ref_count field */ 262 struct mutex isp_mutex; /* For handling ref_count field */
263 bool needs_reset;
265 int has_context; 264 int has_context;
266 int ref_count; 265 int ref_count;
267 unsigned int autoidle; 266 unsigned int autoidle;
@@ -311,11 +310,12 @@ int omap3isp_pipeline_set_stream(struct isp_pipeline *pipe,
311 enum isp_pipeline_stream_state state); 310 enum isp_pipeline_stream_state state);
312void omap3isp_configure_bridge(struct isp_device *isp, 311void omap3isp_configure_bridge(struct isp_device *isp,
313 enum ccdc_input_entity input, 312 enum ccdc_input_entity input,
314 const struct isp_parallel_platform_data *pdata); 313 const struct isp_parallel_platform_data *pdata,
314 unsigned int shift);
315 315
316#define ISP_XCLK_NONE -1 316#define ISP_XCLK_NONE 0
317#define ISP_XCLK_A 0 317#define ISP_XCLK_A 1
318#define ISP_XCLK_B 1 318#define ISP_XCLK_B 2
319 319
320struct isp_device *omap3isp_get(struct isp_device *isp); 320struct isp_device *omap3isp_get(struct isp_device *isp);
321void omap3isp_put(struct isp_device *isp); 321void omap3isp_put(struct isp_device *isp);
diff --git a/drivers/media/video/omap3isp/ispccdc.c b/drivers/media/video/omap3isp/ispccdc.c
index 5ff9d14ce710..39d501bda636 100644
--- a/drivers/media/video/omap3isp/ispccdc.c
+++ b/drivers/media/video/omap3isp/ispccdc.c
@@ -43,6 +43,12 @@ __ccdc_get_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_fh *fh,
43 43
44static const unsigned int ccdc_fmts[] = { 44static const unsigned int ccdc_fmts[] = {
45 V4L2_MBUS_FMT_Y8_1X8, 45 V4L2_MBUS_FMT_Y8_1X8,
46 V4L2_MBUS_FMT_Y10_1X10,
47 V4L2_MBUS_FMT_Y12_1X12,
48 V4L2_MBUS_FMT_SGRBG8_1X8,
49 V4L2_MBUS_FMT_SRGGB8_1X8,
50 V4L2_MBUS_FMT_SBGGR8_1X8,
51 V4L2_MBUS_FMT_SGBRG8_1X8,
46 V4L2_MBUS_FMT_SGRBG10_1X10, 52 V4L2_MBUS_FMT_SGRBG10_1X10,
47 V4L2_MBUS_FMT_SRGGB10_1X10, 53 V4L2_MBUS_FMT_SRGGB10_1X10,
48 V4L2_MBUS_FMT_SBGGR10_1X10, 54 V4L2_MBUS_FMT_SBGGR10_1X10,
@@ -1110,21 +1116,38 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc)
1110 struct isp_parallel_platform_data *pdata = NULL; 1116 struct isp_parallel_platform_data *pdata = NULL;
1111 struct v4l2_subdev *sensor; 1117 struct v4l2_subdev *sensor;
1112 struct v4l2_mbus_framefmt *format; 1118 struct v4l2_mbus_framefmt *format;
1119 const struct isp_format_info *fmt_info;
1120 struct v4l2_subdev_format fmt_src;
1121 unsigned int depth_out;
1122 unsigned int depth_in = 0;
1113 struct media_pad *pad; 1123 struct media_pad *pad;
1114 unsigned long flags; 1124 unsigned long flags;
1125 unsigned int shift;
1115 u32 syn_mode; 1126 u32 syn_mode;
1116 u32 ccdc_pattern; 1127 u32 ccdc_pattern;
1117 1128
1118 if (ccdc->input == CCDC_INPUT_PARALLEL) { 1129 pad = media_entity_remote_source(&ccdc->pads[CCDC_PAD_SINK]);
1119 pad = media_entity_remote_source(&ccdc->pads[CCDC_PAD_SINK]); 1130 sensor = media_entity_to_v4l2_subdev(pad->entity);
1120 sensor = media_entity_to_v4l2_subdev(pad->entity); 1131 if (ccdc->input == CCDC_INPUT_PARALLEL)
1121 pdata = &((struct isp_v4l2_subdevs_group *)sensor->host_priv) 1132 pdata = &((struct isp_v4l2_subdevs_group *)sensor->host_priv)
1122 ->bus.parallel; 1133 ->bus.parallel;
1134
1135 /* Compute shift value for lane shifter to configure the bridge. */
1136 fmt_src.pad = pad->index;
1137 fmt_src.which = V4L2_SUBDEV_FORMAT_ACTIVE;
1138 if (!v4l2_subdev_call(sensor, pad, get_fmt, NULL, &fmt_src)) {
1139 fmt_info = omap3isp_video_format_info(fmt_src.format.code);
1140 depth_in = fmt_info->bpp;
1123 } 1141 }
1124 1142
1125 omap3isp_configure_bridge(isp, ccdc->input, pdata); 1143 fmt_info = omap3isp_video_format_info
1144 (isp->isp_ccdc.formats[CCDC_PAD_SINK].code);
1145 depth_out = fmt_info->bpp;
1146
1147 shift = depth_in - depth_out;
1148 omap3isp_configure_bridge(isp, ccdc->input, pdata, shift);
1126 1149
1127 ccdc->syncif.datsz = pdata ? pdata->width : 10; 1150 ccdc->syncif.datsz = depth_out;
1128 ccdc_config_sync_if(ccdc, &ccdc->syncif); 1151 ccdc_config_sync_if(ccdc, &ccdc->syncif);
1129 1152
1130 /* CCDC_PAD_SINK */ 1153 /* CCDC_PAD_SINK */
@@ -1338,7 +1361,7 @@ static int ccdc_sbl_wait_idle(struct isp_ccdc_device *ccdc,
1338 * @ccdc: Pointer to ISP CCDC device. 1361 * @ccdc: Pointer to ISP CCDC device.
1339 * @event: Pointing which event trigger handler 1362 * @event: Pointing which event trigger handler
1340 * 1363 *
1341 * Return 1 when the event and stopping request combination is satisfyied, 1364 * Return 1 when the event and stopping request combination is satisfied,
1342 * zero otherwise. 1365 * zero otherwise.
1343 */ 1366 */
1344static int __ccdc_handle_stopping(struct isp_ccdc_device *ccdc, u32 event) 1367static int __ccdc_handle_stopping(struct isp_ccdc_device *ccdc, u32 event)
@@ -1618,7 +1641,7 @@ static int ccdc_video_queue(struct isp_video *video, struct isp_buffer *buffer)
1618 1641
1619 ccdc_set_outaddr(ccdc, buffer->isp_addr); 1642 ccdc_set_outaddr(ccdc, buffer->isp_addr);
1620 1643
1621 /* We now have a buffer queued on the output, restart the pipeline in 1644 /* We now have a buffer queued on the output, restart the pipeline
1622 * on the next CCDC interrupt if running in continuous mode (or when 1645 * on the next CCDC interrupt if running in continuous mode (or when
1623 * starting the stream). 1646 * starting the stream).
1624 */ 1647 */
diff --git a/drivers/media/video/omap3isp/isppreview.c b/drivers/media/video/omap3isp/isppreview.c
index 2b16988a501d..aba537af87e4 100644
--- a/drivers/media/video/omap3isp/isppreview.c
+++ b/drivers/media/video/omap3isp/isppreview.c
@@ -755,7 +755,7 @@ static struct preview_update update_attrs[] = {
755 * @configs - pointer to update config structure. 755 * @configs - pointer to update config structure.
756 * @config - return pointer to appropriate structure field. 756 * @config - return pointer to appropriate structure field.
757 * @bit - for which feature to return pointers. 757 * @bit - for which feature to return pointers.
758 * Return size of coresponding prev_params member 758 * Return size of corresponding prev_params member
759 */ 759 */
760static u32 760static u32
761__preview_get_ptrs(struct prev_params *params, void **param, 761__preview_get_ptrs(struct prev_params *params, void **param,
diff --git a/drivers/media/video/omap3isp/ispqueue.c b/drivers/media/video/omap3isp/ispqueue.c
index 8fddc5806b0d..9c317148205f 100644
--- a/drivers/media/video/omap3isp/ispqueue.c
+++ b/drivers/media/video/omap3isp/ispqueue.c
@@ -339,7 +339,7 @@ static int isp_video_buffer_prepare_user(struct isp_video_buffer *buf)
339 up_read(&current->mm->mmap_sem); 339 up_read(&current->mm->mmap_sem);
340 340
341 if (ret != buf->npages) { 341 if (ret != buf->npages) {
342 buf->npages = ret; 342 buf->npages = ret < 0 ? 0 : ret;
343 isp_video_buffer_cleanup(buf); 343 isp_video_buffer_cleanup(buf);
344 return -EFAULT; 344 return -EFAULT;
345 } 345 }
@@ -408,8 +408,8 @@ done:
408 * isp_video_buffer_prepare_vm_flags - Get VMA flags for a userspace address 408 * isp_video_buffer_prepare_vm_flags - Get VMA flags for a userspace address
409 * 409 *
410 * This function locates the VMAs for the buffer's userspace address and checks 410 * This function locates the VMAs for the buffer's userspace address and checks
411 * that their flags match. The onlflag that we need to care for at the moment is 411 * that their flags match. The only flag that we need to care for at the moment
412 * VM_PFNMAP. 412 * is VM_PFNMAP.
413 * 413 *
414 * The buffer vm_flags field is set to the first VMA flags. 414 * The buffer vm_flags field is set to the first VMA flags.
415 * 415 *
diff --git a/drivers/media/video/omap3isp/ispresizer.c b/drivers/media/video/omap3isp/ispresizer.c
index 653f88ba56db..0bb0f8cd36f5 100644
--- a/drivers/media/video/omap3isp/ispresizer.c
+++ b/drivers/media/video/omap3isp/ispresizer.c
@@ -714,19 +714,50 @@ static void resizer_print_status(struct isp_res_device *res)
714 * iw and ih are the input width and height after cropping. Those equations need 714 * iw and ih are the input width and height after cropping. Those equations need
715 * to be satisfied exactly for the resizer to work correctly. 715 * to be satisfied exactly for the resizer to work correctly.
716 * 716 *
717 * Reverting the equations, we can compute the resizing ratios with 717 * The equations can't be easily reverted, as the >> 8 operation is not linear.
718 * In addition, not all input sizes can be achieved for a given output size. To
719 * get the highest input size lower than or equal to the requested input size,
720 * we need to compute the highest resizing ratio that satisfies the following
721 * inequality (taking the 4-tap mode width equation as an example)
722 *
723 * iw >= (32 * sph + (ow - 1) * hrsz + 16) >> 8 - 7
724 *
725 * (where iw is the requested input width) which can be rewritten as
726 *
727 * iw - 7 >= (32 * sph + (ow - 1) * hrsz + 16) >> 8
728 * (iw - 7) << 8 >= 32 * sph + (ow - 1) * hrsz + 16 - b
729 * ((iw - 7) << 8) + b >= 32 * sph + (ow - 1) * hrsz + 16
730 *
731 * where b is the value of the 8 least significant bits of the right hand side
732 * expression of the last inequality. The highest resizing ratio value will be
733 * achieved when b is equal to its maximum value of 255. That resizing ratio
734 * value will still satisfy the original inequality, as b will disappear when
735 * the expression will be shifted right by 8.
736 *
737 * The reverted the equations thus become
718 * 738 *
719 * - 8-phase, 4-tap mode 739 * - 8-phase, 4-tap mode
720 * hrsz = ((iw - 7) * 256 - 16 - 32 * sph) / (ow - 1) 740 * hrsz = ((iw - 7) * 256 + 255 - 16 - 32 * sph) / (ow - 1)
721 * vrsz = ((ih - 4) * 256 - 16 - 32 * spv) / (oh - 1) 741 * vrsz = ((ih - 4) * 256 + 255 - 16 - 32 * spv) / (oh - 1)
722 * - 4-phase, 7-tap mode 742 * - 4-phase, 7-tap mode
723 * hrsz = ((iw - 7) * 256 - 32 - 64 * sph) / (ow - 1) 743 * hrsz = ((iw - 7) * 256 + 255 - 32 - 64 * sph) / (ow - 1)
724 * vrsz = ((ih - 7) * 256 - 32 - 64 * spv) / (oh - 1) 744 * vrsz = ((ih - 7) * 256 + 255 - 32 - 64 * spv) / (oh - 1)
725 * 745 *
726 * The ratios are integer values, and must be rounded down to ensure that the 746 * The ratios are integer values, and are rounded down to ensure that the
727 * cropped input size is not bigger than the uncropped input size. As the ratio 747 * cropped input size is not bigger than the uncropped input size.
728 * in 7-tap mode is always smaller than the ratio in 4-tap mode, we can use the 748 *
729 * 7-tap mode equations to compute a ratio approximation. 749 * As the number of phases/taps, used to select the correct equations to compute
750 * the ratio, depends on the ratio, we start with the 4-tap mode equations to
751 * compute an approximation of the ratio, and switch to the 7-tap mode equations
752 * if the approximation is higher than the ratio threshold.
753 *
754 * As the 7-tap mode equations will return a ratio smaller than or equal to the
755 * 4-tap mode equations, the resulting ratio could become lower than or equal to
756 * the ratio threshold. This 'equations loop' isn't an issue as long as the
757 * correct equations are used to compute the final input size. Starting with the
758 * 4-tap mode equations ensure that, in case of values resulting in a 'ratio
759 * loop', the smallest of the ratio values will be used, never exceeding the
760 * requested input size.
730 * 761 *
731 * We first clamp the output size according to the hardware capabilitie to avoid 762 * We first clamp the output size according to the hardware capabilitie to avoid
732 * auto-cropping the input more than required to satisfy the TRM equations. The 763 * auto-cropping the input more than required to satisfy the TRM equations. The
@@ -775,6 +806,8 @@ static void resizer_calc_ratios(struct isp_res_device *res,
775 unsigned int max_width; 806 unsigned int max_width;
776 unsigned int max_height; 807 unsigned int max_height;
777 unsigned int width_alignment; 808 unsigned int width_alignment;
809 unsigned int width;
810 unsigned int height;
778 811
779 /* 812 /*
780 * Clamp the output height based on the hardware capabilities and 813 * Clamp the output height based on the hardware capabilities and
@@ -786,19 +819,22 @@ static void resizer_calc_ratios(struct isp_res_device *res,
786 max_height = min_t(unsigned int, max_height, MAX_OUT_HEIGHT); 819 max_height = min_t(unsigned int, max_height, MAX_OUT_HEIGHT);
787 output->height = clamp(output->height, min_height, max_height); 820 output->height = clamp(output->height, min_height, max_height);
788 821
789 ratio->vert = ((input->height - 7) * 256 - 32 - 64 * spv) 822 ratio->vert = ((input->height - 4) * 256 + 255 - 16 - 32 * spv)
790 / (output->height - 1); 823 / (output->height - 1);
824 if (ratio->vert > MID_RESIZE_VALUE)
825 ratio->vert = ((input->height - 7) * 256 + 255 - 32 - 64 * spv)
826 / (output->height - 1);
791 ratio->vert = clamp_t(unsigned int, ratio->vert, 827 ratio->vert = clamp_t(unsigned int, ratio->vert,
792 MIN_RESIZE_VALUE, MAX_RESIZE_VALUE); 828 MIN_RESIZE_VALUE, MAX_RESIZE_VALUE);
793 829
794 if (ratio->vert <= MID_RESIZE_VALUE) { 830 if (ratio->vert <= MID_RESIZE_VALUE) {
795 upscaled_height = (output->height - 1) * ratio->vert 831 upscaled_height = (output->height - 1) * ratio->vert
796 + 32 * spv + 16; 832 + 32 * spv + 16;
797 input->height = (upscaled_height >> 8) + 4; 833 height = (upscaled_height >> 8) + 4;
798 } else { 834 } else {
799 upscaled_height = (output->height - 1) * ratio->vert 835 upscaled_height = (output->height - 1) * ratio->vert
800 + 64 * spv + 32; 836 + 64 * spv + 32;
801 input->height = (upscaled_height >> 8) + 7; 837 height = (upscaled_height >> 8) + 7;
802 } 838 }
803 839
804 /* 840 /*
@@ -854,20 +890,29 @@ static void resizer_calc_ratios(struct isp_res_device *res,
854 max_width & ~(width_alignment - 1)); 890 max_width & ~(width_alignment - 1));
855 output->width = ALIGN(output->width, width_alignment); 891 output->width = ALIGN(output->width, width_alignment);
856 892
857 ratio->horz = ((input->width - 7) * 256 - 32 - 64 * sph) 893 ratio->horz = ((input->width - 7) * 256 + 255 - 16 - 32 * sph)
858 / (output->width - 1); 894 / (output->width - 1);
895 if (ratio->horz > MID_RESIZE_VALUE)
896 ratio->horz = ((input->width - 7) * 256 + 255 - 32 - 64 * sph)
897 / (output->width - 1);
859 ratio->horz = clamp_t(unsigned int, ratio->horz, 898 ratio->horz = clamp_t(unsigned int, ratio->horz,
860 MIN_RESIZE_VALUE, MAX_RESIZE_VALUE); 899 MIN_RESIZE_VALUE, MAX_RESIZE_VALUE);
861 900
862 if (ratio->horz <= MID_RESIZE_VALUE) { 901 if (ratio->horz <= MID_RESIZE_VALUE) {
863 upscaled_width = (output->width - 1) * ratio->horz 902 upscaled_width = (output->width - 1) * ratio->horz
864 + 32 * sph + 16; 903 + 32 * sph + 16;
865 input->width = (upscaled_width >> 8) + 7; 904 width = (upscaled_width >> 8) + 7;
866 } else { 905 } else {
867 upscaled_width = (output->width - 1) * ratio->horz 906 upscaled_width = (output->width - 1) * ratio->horz
868 + 64 * sph + 32; 907 + 64 * sph + 32;
869 input->width = (upscaled_width >> 8) + 7; 908 width = (upscaled_width >> 8) + 7;
870 } 909 }
910
911 /* Center the new crop rectangle. */
912 input->left += (input->width - width) / 2;
913 input->top += (input->height - height) / 2;
914 input->width = width;
915 input->height = height;
871} 916}
872 917
873/* 918/*
diff --git a/drivers/media/video/omap3isp/ispstat.h b/drivers/media/video/omap3isp/ispstat.h
index 820950c9ef46..d86da94fa50d 100644
--- a/drivers/media/video/omap3isp/ispstat.h
+++ b/drivers/media/video/omap3isp/ispstat.h
@@ -131,9 +131,9 @@ struct ispstat {
131struct ispstat_generic_config { 131struct ispstat_generic_config {
132 /* 132 /*
133 * Fields must be in the same order as in: 133 * Fields must be in the same order as in:
134 * - isph3a_aewb_config 134 * - omap3isp_h3a_aewb_config
135 * - isph3a_af_config 135 * - omap3isp_h3a_af_config
136 * - isphist_config 136 * - omap3isp_hist_config
137 */ 137 */
138 u32 buf_size; 138 u32 buf_size;
139 u16 config_counter; 139 u16 config_counter;
diff --git a/drivers/media/video/omap3isp/ispvideo.c b/drivers/media/video/omap3isp/ispvideo.c
index 208a7ec739d7..9cd8f1aa567b 100644
--- a/drivers/media/video/omap3isp/ispvideo.c
+++ b/drivers/media/video/omap3isp/ispvideo.c
@@ -47,29 +47,59 @@
47 47
48static struct isp_format_info formats[] = { 48static struct isp_format_info formats[] = {
49 { V4L2_MBUS_FMT_Y8_1X8, V4L2_MBUS_FMT_Y8_1X8, 49 { V4L2_MBUS_FMT_Y8_1X8, V4L2_MBUS_FMT_Y8_1X8,
50 V4L2_MBUS_FMT_Y8_1X8, V4L2_PIX_FMT_GREY, 8, }, 50 V4L2_MBUS_FMT_Y8_1X8, V4L2_MBUS_FMT_Y8_1X8,
51 V4L2_PIX_FMT_GREY, 8, },
52 { V4L2_MBUS_FMT_Y10_1X10, V4L2_MBUS_FMT_Y10_1X10,
53 V4L2_MBUS_FMT_Y10_1X10, V4L2_MBUS_FMT_Y8_1X8,
54 V4L2_PIX_FMT_Y10, 10, },
55 { V4L2_MBUS_FMT_Y12_1X12, V4L2_MBUS_FMT_Y10_1X10,
56 V4L2_MBUS_FMT_Y12_1X12, V4L2_MBUS_FMT_Y8_1X8,
57 V4L2_PIX_FMT_Y12, 12, },
58 { V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_MBUS_FMT_SBGGR8_1X8,
59 V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_MBUS_FMT_SBGGR8_1X8,
60 V4L2_PIX_FMT_SBGGR8, 8, },
61 { V4L2_MBUS_FMT_SGBRG8_1X8, V4L2_MBUS_FMT_SGBRG8_1X8,
62 V4L2_MBUS_FMT_SGBRG8_1X8, V4L2_MBUS_FMT_SGBRG8_1X8,
63 V4L2_PIX_FMT_SGBRG8, 8, },
64 { V4L2_MBUS_FMT_SGRBG8_1X8, V4L2_MBUS_FMT_SGRBG8_1X8,
65 V4L2_MBUS_FMT_SGRBG8_1X8, V4L2_MBUS_FMT_SGRBG8_1X8,
66 V4L2_PIX_FMT_SGRBG8, 8, },
67 { V4L2_MBUS_FMT_SRGGB8_1X8, V4L2_MBUS_FMT_SRGGB8_1X8,
68 V4L2_MBUS_FMT_SRGGB8_1X8, V4L2_MBUS_FMT_SRGGB8_1X8,
69 V4L2_PIX_FMT_SRGGB8, 8, },
51 { V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, 70 { V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8,
52 V4L2_MBUS_FMT_SGRBG10_1X10, V4L2_PIX_FMT_SGRBG10DPCM8, 8, }, 71 V4L2_MBUS_FMT_SGRBG10_1X10, 0,
72 V4L2_PIX_FMT_SGRBG10DPCM8, 8, },
53 { V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_MBUS_FMT_SBGGR10_1X10, 73 { V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_MBUS_FMT_SBGGR10_1X10,
54 V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_PIX_FMT_SBGGR10, 10, }, 74 V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_MBUS_FMT_SBGGR8_1X8,
75 V4L2_PIX_FMT_SBGGR10, 10, },
55 { V4L2_MBUS_FMT_SGBRG10_1X10, V4L2_MBUS_FMT_SGBRG10_1X10, 76 { V4L2_MBUS_FMT_SGBRG10_1X10, V4L2_MBUS_FMT_SGBRG10_1X10,
56 V4L2_MBUS_FMT_SGBRG10_1X10, V4L2_PIX_FMT_SGBRG10, 10, }, 77 V4L2_MBUS_FMT_SGBRG10_1X10, V4L2_MBUS_FMT_SGBRG8_1X8,
78 V4L2_PIX_FMT_SGBRG10, 10, },
57 { V4L2_MBUS_FMT_SGRBG10_1X10, V4L2_MBUS_FMT_SGRBG10_1X10, 79 { V4L2_MBUS_FMT_SGRBG10_1X10, V4L2_MBUS_FMT_SGRBG10_1X10,
58 V4L2_MBUS_FMT_SGRBG10_1X10, V4L2_PIX_FMT_SGRBG10, 10, }, 80 V4L2_MBUS_FMT_SGRBG10_1X10, V4L2_MBUS_FMT_SGRBG8_1X8,
81 V4L2_PIX_FMT_SGRBG10, 10, },
59 { V4L2_MBUS_FMT_SRGGB10_1X10, V4L2_MBUS_FMT_SRGGB10_1X10, 82 { V4L2_MBUS_FMT_SRGGB10_1X10, V4L2_MBUS_FMT_SRGGB10_1X10,
60 V4L2_MBUS_FMT_SRGGB10_1X10, V4L2_PIX_FMT_SRGGB10, 10, }, 83 V4L2_MBUS_FMT_SRGGB10_1X10, V4L2_MBUS_FMT_SRGGB8_1X8,
84 V4L2_PIX_FMT_SRGGB10, 10, },
61 { V4L2_MBUS_FMT_SBGGR12_1X12, V4L2_MBUS_FMT_SBGGR10_1X10, 85 { V4L2_MBUS_FMT_SBGGR12_1X12, V4L2_MBUS_FMT_SBGGR10_1X10,
62 V4L2_MBUS_FMT_SBGGR12_1X12, V4L2_PIX_FMT_SBGGR12, 12, }, 86 V4L2_MBUS_FMT_SBGGR12_1X12, V4L2_MBUS_FMT_SBGGR8_1X8,
87 V4L2_PIX_FMT_SBGGR12, 12, },
63 { V4L2_MBUS_FMT_SGBRG12_1X12, V4L2_MBUS_FMT_SGBRG10_1X10, 88 { V4L2_MBUS_FMT_SGBRG12_1X12, V4L2_MBUS_FMT_SGBRG10_1X10,
64 V4L2_MBUS_FMT_SGBRG12_1X12, V4L2_PIX_FMT_SGBRG12, 12, }, 89 V4L2_MBUS_FMT_SGBRG12_1X12, V4L2_MBUS_FMT_SGBRG8_1X8,
90 V4L2_PIX_FMT_SGBRG12, 12, },
65 { V4L2_MBUS_FMT_SGRBG12_1X12, V4L2_MBUS_FMT_SGRBG10_1X10, 91 { V4L2_MBUS_FMT_SGRBG12_1X12, V4L2_MBUS_FMT_SGRBG10_1X10,
66 V4L2_MBUS_FMT_SGRBG12_1X12, V4L2_PIX_FMT_SGRBG12, 12, }, 92 V4L2_MBUS_FMT_SGRBG12_1X12, V4L2_MBUS_FMT_SGRBG8_1X8,
93 V4L2_PIX_FMT_SGRBG12, 12, },
67 { V4L2_MBUS_FMT_SRGGB12_1X12, V4L2_MBUS_FMT_SRGGB10_1X10, 94 { V4L2_MBUS_FMT_SRGGB12_1X12, V4L2_MBUS_FMT_SRGGB10_1X10,
68 V4L2_MBUS_FMT_SRGGB12_1X12, V4L2_PIX_FMT_SRGGB12, 12, }, 95 V4L2_MBUS_FMT_SRGGB12_1X12, V4L2_MBUS_FMT_SRGGB8_1X8,
96 V4L2_PIX_FMT_SRGGB12, 12, },
69 { V4L2_MBUS_FMT_UYVY8_1X16, V4L2_MBUS_FMT_UYVY8_1X16, 97 { V4L2_MBUS_FMT_UYVY8_1X16, V4L2_MBUS_FMT_UYVY8_1X16,
70 V4L2_MBUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_UYVY, 16, }, 98 V4L2_MBUS_FMT_UYVY8_1X16, 0,
99 V4L2_PIX_FMT_UYVY, 16, },
71 { V4L2_MBUS_FMT_YUYV8_1X16, V4L2_MBUS_FMT_YUYV8_1X16, 100 { V4L2_MBUS_FMT_YUYV8_1X16, V4L2_MBUS_FMT_YUYV8_1X16,
72 V4L2_MBUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_YUYV, 16, }, 101 V4L2_MBUS_FMT_YUYV8_1X16, 0,
102 V4L2_PIX_FMT_YUYV, 16, },
73}; 103};
74 104
75const struct isp_format_info * 105const struct isp_format_info *
@@ -86,6 +116,37 @@ omap3isp_video_format_info(enum v4l2_mbus_pixelcode code)
86} 116}
87 117
88/* 118/*
119 * Decide whether desired output pixel code can be obtained with
120 * the lane shifter by shifting the input pixel code.
121 * @in: input pixelcode to shifter
122 * @out: output pixelcode from shifter
123 * @additional_shift: # of bits the sensor's LSB is offset from CAMEXT[0]
124 *
125 * return true if the combination is possible
126 * return false otherwise
127 */
128static bool isp_video_is_shiftable(enum v4l2_mbus_pixelcode in,
129 enum v4l2_mbus_pixelcode out,
130 unsigned int additional_shift)
131{
132 const struct isp_format_info *in_info, *out_info;
133
134 if (in == out)
135 return true;
136
137 in_info = omap3isp_video_format_info(in);
138 out_info = omap3isp_video_format_info(out);
139
140 if ((in_info->flavor == 0) || (out_info->flavor == 0))
141 return false;
142
143 if (in_info->flavor != out_info->flavor)
144 return false;
145
146 return in_info->bpp - out_info->bpp + additional_shift <= 6;
147}
148
149/*
89 * isp_video_mbus_to_pix - Convert v4l2_mbus_framefmt to v4l2_pix_format 150 * isp_video_mbus_to_pix - Convert v4l2_mbus_framefmt to v4l2_pix_format
90 * @video: ISP video instance 151 * @video: ISP video instance
91 * @mbus: v4l2_mbus_framefmt format (input) 152 * @mbus: v4l2_mbus_framefmt format (input)
@@ -235,6 +296,7 @@ static int isp_video_validate_pipeline(struct isp_pipeline *pipe)
235 return -EPIPE; 296 return -EPIPE;
236 297
237 while (1) { 298 while (1) {
299 unsigned int shifter_link;
238 /* Retrieve the sink format */ 300 /* Retrieve the sink format */
239 pad = &subdev->entity.pads[0]; 301 pad = &subdev->entity.pads[0];
240 if (!(pad->flags & MEDIA_PAD_FL_SINK)) 302 if (!(pad->flags & MEDIA_PAD_FL_SINK))
@@ -263,6 +325,10 @@ static int isp_video_validate_pipeline(struct isp_pipeline *pipe)
263 return -ENOSPC; 325 return -ENOSPC;
264 } 326 }
265 327
328 /* If sink pad is on CCDC, the link has the lane shifter
329 * in the middle of it. */
330 shifter_link = subdev == &isp->isp_ccdc.subdev;
331
266 /* Retrieve the source format */ 332 /* Retrieve the source format */
267 pad = media_entity_remote_source(pad); 333 pad = media_entity_remote_source(pad);
268 if (pad == NULL || 334 if (pad == NULL ||
@@ -278,10 +344,24 @@ static int isp_video_validate_pipeline(struct isp_pipeline *pipe)
278 return -EPIPE; 344 return -EPIPE;
279 345
280 /* Check if the two ends match */ 346 /* Check if the two ends match */
281 if (fmt_source.format.code != fmt_sink.format.code || 347 if (fmt_source.format.width != fmt_sink.format.width ||
282 fmt_source.format.width != fmt_sink.format.width ||
283 fmt_source.format.height != fmt_sink.format.height) 348 fmt_source.format.height != fmt_sink.format.height)
284 return -EPIPE; 349 return -EPIPE;
350
351 if (shifter_link) {
352 unsigned int parallel_shift = 0;
353 if (isp->isp_ccdc.input == CCDC_INPUT_PARALLEL) {
354 struct isp_parallel_platform_data *pdata =
355 &((struct isp_v4l2_subdevs_group *)
356 subdev->host_priv)->bus.parallel;
357 parallel_shift = pdata->data_lane_shift * 2;
358 }
359 if (!isp_video_is_shiftable(fmt_source.format.code,
360 fmt_sink.format.code,
361 parallel_shift))
362 return -EPIPE;
363 } else if (fmt_source.format.code != fmt_sink.format.code)
364 return -EPIPE;
285 } 365 }
286 366
287 return 0; 367 return 0;
diff --git a/drivers/media/video/omap3isp/ispvideo.h b/drivers/media/video/omap3isp/ispvideo.h
index 524a1acd0906..911bea64e78a 100644
--- a/drivers/media/video/omap3isp/ispvideo.h
+++ b/drivers/media/video/omap3isp/ispvideo.h
@@ -49,6 +49,8 @@ struct v4l2_pix_format;
49 * bits. Identical to @code if the format is 10 bits wide or less. 49 * bits. Identical to @code if the format is 10 bits wide or less.
50 * @uncompressed: V4L2 media bus format code for the corresponding uncompressed 50 * @uncompressed: V4L2 media bus format code for the corresponding uncompressed
51 * format. Identical to @code if the format is not DPCM compressed. 51 * format. Identical to @code if the format is not DPCM compressed.
52 * @flavor: V4L2 media bus format code for the same pixel layout but
53 * shifted to be 8 bits per pixel. =0 if format is not shiftable.
52 * @pixelformat: V4L2 pixel format FCC identifier 54 * @pixelformat: V4L2 pixel format FCC identifier
53 * @bpp: Bits per pixel 55 * @bpp: Bits per pixel
54 */ 56 */
@@ -56,6 +58,7 @@ struct isp_format_info {
56 enum v4l2_mbus_pixelcode code; 58 enum v4l2_mbus_pixelcode code;
57 enum v4l2_mbus_pixelcode truncated; 59 enum v4l2_mbus_pixelcode truncated;
58 enum v4l2_mbus_pixelcode uncompressed; 60 enum v4l2_mbus_pixelcode uncompressed;
61 enum v4l2_mbus_pixelcode flavor;
59 u32 pixelformat; 62 u32 pixelformat;
60 unsigned int bpp; 63 unsigned int bpp;
61}; 64};
diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c
index 95f8b4e11e46..d142b40ea64e 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -527,7 +527,7 @@ static int fimc_cap_s_fmt_mplane(struct file *file, void *priv,
527 if (ret) 527 if (ret)
528 return ret; 528 return ret;
529 529
530 if (vb2_is_streaming(&fimc->vid_cap.vbq) || fimc_capture_active(fimc)) 530 if (vb2_is_busy(&fimc->vid_cap.vbq) || fimc_capture_active(fimc))
531 return -EBUSY; 531 return -EBUSY;
532 532
533 frame = &ctx->d_frame; 533 frame = &ctx->d_frame;
@@ -539,8 +539,10 @@ static int fimc_cap_s_fmt_mplane(struct file *file, void *priv,
539 return -EINVAL; 539 return -EINVAL;
540 } 540 }
541 541
542 for (i = 0; i < frame->fmt->colplanes; i++) 542 for (i = 0; i < frame->fmt->colplanes; i++) {
543 frame->payload[i] = pix->plane_fmt[i].bytesperline * pix->height; 543 frame->payload[i] =
544 (pix->width * pix->height * frame->fmt->depth[i]) >> 3;
545 }
544 546
545 /* Output DMA frame pixel size and offsets. */ 547 /* Output DMA frame pixel size and offsets. */
546 frame->f_width = pix->plane_fmt[0].bytesperline * 8 548 frame->f_width = pix->plane_fmt[0].bytesperline * 8
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c b/drivers/media/video/s5p-fimc/fimc-core.c
index 6c919b38a3d8..dc91a8511af6 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.c
+++ b/drivers/media/video/s5p-fimc/fimc-core.c
@@ -361,10 +361,20 @@ static void fimc_capture_irq_handler(struct fimc_dev *fimc)
361{ 361{
362 struct fimc_vid_cap *cap = &fimc->vid_cap; 362 struct fimc_vid_cap *cap = &fimc->vid_cap;
363 struct fimc_vid_buffer *v_buf; 363 struct fimc_vid_buffer *v_buf;
364 struct timeval *tv;
365 struct timespec ts;
364 366
365 if (!list_empty(&cap->active_buf_q) && 367 if (!list_empty(&cap->active_buf_q) &&
366 test_bit(ST_CAPT_RUN, &fimc->state)) { 368 test_bit(ST_CAPT_RUN, &fimc->state)) {
369 ktime_get_real_ts(&ts);
370
367 v_buf = active_queue_pop(cap); 371 v_buf = active_queue_pop(cap);
372
373 tv = &v_buf->vb.v4l2_buf.timestamp;
374 tv->tv_sec = ts.tv_sec;
375 tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC;
376 v_buf->vb.v4l2_buf.sequence = cap->frame_count++;
377
368 vb2_buffer_done(&v_buf->vb, VB2_BUF_STATE_DONE); 378 vb2_buffer_done(&v_buf->vb, VB2_BUF_STATE_DONE);
369 } 379 }
370 380
@@ -758,7 +768,7 @@ static void fimc_unlock(struct vb2_queue *vq)
758 mutex_unlock(&ctx->fimc_dev->lock); 768 mutex_unlock(&ctx->fimc_dev->lock);
759} 769}
760 770
761struct vb2_ops fimc_qops = { 771static struct vb2_ops fimc_qops = {
762 .queue_setup = fimc_queue_setup, 772 .queue_setup = fimc_queue_setup,
763 .buf_prepare = fimc_buf_prepare, 773 .buf_prepare = fimc_buf_prepare,
764 .buf_queue = fimc_buf_queue, 774 .buf_queue = fimc_buf_queue,
@@ -927,23 +937,23 @@ int fimc_vidioc_try_fmt_mplane(struct file *file, void *priv,
927 pix->num_planes = fmt->memplanes; 937 pix->num_planes = fmt->memplanes;
928 pix->colorspace = V4L2_COLORSPACE_JPEG; 938 pix->colorspace = V4L2_COLORSPACE_JPEG;
929 939
930 for (i = 0; i < pix->num_planes; ++i) {
931 int bpl = pix->plane_fmt[i].bytesperline;
932 940
933 dbg("[%d] bpl: %d, depth: %d, w: %d, h: %d", 941 for (i = 0; i < pix->num_planes; ++i) {
934 i, bpl, fmt->depth[i], pix->width, pix->height); 942 u32 bpl = pix->plane_fmt[i].bytesperline;
943 u32 *sizeimage = &pix->plane_fmt[i].sizeimage;
935 944
936 if (!bpl || (bpl * 8 / fmt->depth[i]) > pix->width) 945 if (fmt->colplanes > 1 && (bpl == 0 || bpl < pix->width))
937 bpl = (pix->width * fmt->depth[0]) >> 3; 946 bpl = pix->width; /* Planar */
938 947
939 if (!pix->plane_fmt[i].sizeimage) 948 if (fmt->colplanes == 1 && /* Packed */
940 pix->plane_fmt[i].sizeimage = pix->height * bpl; 949 (bpl == 0 || ((bpl * 8) / fmt->depth[i]) < pix->width))
950 bpl = (pix->width * fmt->depth[0]) / 8;
941 951
942 pix->plane_fmt[i].bytesperline = bpl; 952 if (i == 0) /* Same bytesperline for each plane. */
953 mod_x = bpl;
943 954
944 dbg("[%d]: bpl: %d, sizeimage: %d", 955 pix->plane_fmt[i].bytesperline = mod_x;
945 i, pix->plane_fmt[i].bytesperline, 956 *sizeimage = (pix->width * pix->height * fmt->depth[i]) / 8;
946 pix->plane_fmt[i].sizeimage);
947 } 957 }
948 958
949 return 0; 959 return 0;
@@ -965,7 +975,7 @@ static int fimc_m2m_s_fmt_mplane(struct file *file, void *priv,
965 975
966 vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type); 976 vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
967 977
968 if (vb2_is_streaming(vq)) { 978 if (vb2_is_busy(vq)) {
969 v4l2_err(&fimc->m2m.v4l2_dev, "queue (%d) busy\n", f->type); 979 v4l2_err(&fimc->m2m.v4l2_dev, "queue (%d) busy\n", f->type);
970 return -EBUSY; 980 return -EBUSY;
971 } 981 }
@@ -985,8 +995,10 @@ static int fimc_m2m_s_fmt_mplane(struct file *file, void *priv,
985 if (!frame->fmt) 995 if (!frame->fmt)
986 return -EINVAL; 996 return -EINVAL;
987 997
988 for (i = 0; i < frame->fmt->colplanes; i++) 998 for (i = 0; i < frame->fmt->colplanes; i++) {
989 frame->payload[i] = pix->plane_fmt[i].bytesperline * pix->height; 999 frame->payload[i] =
1000 (pix->width * pix->height * frame->fmt->depth[i]) / 8;
1001 }
990 1002
991 frame->f_width = pix->plane_fmt[0].bytesperline * 8 / 1003 frame->f_width = pix->plane_fmt[0].bytesperline * 8 /
992 frame->fmt->depth[0]; 1004 frame->fmt->depth[0];
@@ -1750,7 +1762,7 @@ static int __devexit fimc_remove(struct platform_device *pdev)
1750} 1762}
1751 1763
1752/* Image pixel limits, similar across several FIMC HW revisions. */ 1764/* Image pixel limits, similar across several FIMC HW revisions. */
1753static struct fimc_pix_limit s5p_pix_limit[3] = { 1765static struct fimc_pix_limit s5p_pix_limit[4] = {
1754 [0] = { 1766 [0] = {
1755 .scaler_en_w = 3264, 1767 .scaler_en_w = 3264,
1756 .scaler_dis_w = 8192, 1768 .scaler_dis_w = 8192,
@@ -1775,6 +1787,14 @@ static struct fimc_pix_limit s5p_pix_limit[3] = {
1775 .out_rot_en_w = 1280, 1787 .out_rot_en_w = 1280,
1776 .out_rot_dis_w = 1920, 1788 .out_rot_dis_w = 1920,
1777 }, 1789 },
1790 [3] = {
1791 .scaler_en_w = 1920,
1792 .scaler_dis_w = 8192,
1793 .in_rot_en_h = 1366,
1794 .in_rot_dis_w = 8192,
1795 .out_rot_en_w = 1366,
1796 .out_rot_dis_w = 1920,
1797 },
1778}; 1798};
1779 1799
1780static struct samsung_fimc_variant fimc0_variant_s5p = { 1800static struct samsung_fimc_variant fimc0_variant_s5p = {
@@ -1827,7 +1847,7 @@ static struct samsung_fimc_variant fimc2_variant_s5pv210 = {
1827 .pix_limit = &s5p_pix_limit[2], 1847 .pix_limit = &s5p_pix_limit[2],
1828}; 1848};
1829 1849
1830static struct samsung_fimc_variant fimc0_variant_s5pv310 = { 1850static struct samsung_fimc_variant fimc0_variant_exynos4 = {
1831 .pix_hoff = 1, 1851 .pix_hoff = 1,
1832 .has_inp_rot = 1, 1852 .has_inp_rot = 1,
1833 .has_out_rot = 1, 1853 .has_out_rot = 1,
@@ -1840,7 +1860,7 @@ static struct samsung_fimc_variant fimc0_variant_s5pv310 = {
1840 .pix_limit = &s5p_pix_limit[1], 1860 .pix_limit = &s5p_pix_limit[1],
1841}; 1861};
1842 1862
1843static struct samsung_fimc_variant fimc2_variant_s5pv310 = { 1863static struct samsung_fimc_variant fimc2_variant_exynos4 = {
1844 .pix_hoff = 1, 1864 .pix_hoff = 1,
1845 .has_cistatus2 = 1, 1865 .has_cistatus2 = 1,
1846 .has_mainscaler_ext = 1, 1866 .has_mainscaler_ext = 1,
@@ -1848,7 +1868,7 @@ static struct samsung_fimc_variant fimc2_variant_s5pv310 = {
1848 .min_out_pixsize = 16, 1868 .min_out_pixsize = 16,
1849 .hor_offs_align = 1, 1869 .hor_offs_align = 1,
1850 .out_buf_count = 32, 1870 .out_buf_count = 32,
1851 .pix_limit = &s5p_pix_limit[2], 1871 .pix_limit = &s5p_pix_limit[3],
1852}; 1872};
1853 1873
1854/* S5PC100 */ 1874/* S5PC100 */
@@ -1874,12 +1894,12 @@ static struct samsung_fimc_driverdata fimc_drvdata_s5pv210 = {
1874}; 1894};
1875 1895
1876/* S5PV310, S5PC210 */ 1896/* S5PV310, S5PC210 */
1877static struct samsung_fimc_driverdata fimc_drvdata_s5pv310 = { 1897static struct samsung_fimc_driverdata fimc_drvdata_exynos4 = {
1878 .variant = { 1898 .variant = {
1879 [0] = &fimc0_variant_s5pv310, 1899 [0] = &fimc0_variant_exynos4,
1880 [1] = &fimc0_variant_s5pv310, 1900 [1] = &fimc0_variant_exynos4,
1881 [2] = &fimc0_variant_s5pv310, 1901 [2] = &fimc0_variant_exynos4,
1882 [3] = &fimc2_variant_s5pv310, 1902 [3] = &fimc2_variant_exynos4,
1883 }, 1903 },
1884 .num_entities = 4, 1904 .num_entities = 4,
1885 .lclk_frequency = 166000000UL, 1905 .lclk_frequency = 166000000UL,
@@ -1893,8 +1913,8 @@ static struct platform_device_id fimc_driver_ids[] = {
1893 .name = "s5pv210-fimc", 1913 .name = "s5pv210-fimc",
1894 .driver_data = (unsigned long)&fimc_drvdata_s5pv210, 1914 .driver_data = (unsigned long)&fimc_drvdata_s5pv210,
1895 }, { 1915 }, {
1896 .name = "s5pv310-fimc", 1916 .name = "exynos4-fimc",
1897 .driver_data = (unsigned long)&fimc_drvdata_s5pv310, 1917 .driver_data = (unsigned long)&fimc_drvdata_exynos4,
1898 }, 1918 },
1899 {}, 1919 {},
1900}; 1920};
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c
index 3fe54bf41142..134e86bf6d97 100644
--- a/drivers/media/video/sh_mobile_ceu_camera.c
+++ b/drivers/media/video/sh_mobile_ceu_camera.c
@@ -922,7 +922,7 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, unsigned int
922 /* Try 2560x1920, 1280x960, 640x480, 320x240 */ 922 /* Try 2560x1920, 1280x960, 640x480, 320x240 */
923 mf.width = 2560 >> shift; 923 mf.width = 2560 >> shift;
924 mf.height = 1920 >> shift; 924 mf.height = 1920 >> shift;
925 ret = v4l2_device_call_until_err(sd->v4l2_dev, 0, video, 925 ret = v4l2_device_call_until_err(sd->v4l2_dev, (long)icd, video,
926 s_mbus_fmt, &mf); 926 s_mbus_fmt, &mf);
927 if (ret < 0) 927 if (ret < 0)
928 return ret; 928 return ret;
@@ -1224,7 +1224,7 @@ static int client_s_fmt(struct soc_camera_device *icd,
1224 struct v4l2_cropcap cap; 1224 struct v4l2_cropcap cap;
1225 int ret; 1225 int ret;
1226 1226
1227 ret = v4l2_device_call_until_err(sd->v4l2_dev, 0, video, 1227 ret = v4l2_device_call_until_err(sd->v4l2_dev, (long)icd, video,
1228 s_mbus_fmt, mf); 1228 s_mbus_fmt, mf);
1229 if (ret < 0) 1229 if (ret < 0)
1230 return ret; 1230 return ret;
@@ -1254,7 +1254,7 @@ static int client_s_fmt(struct soc_camera_device *icd,
1254 tmp_h = min(2 * tmp_h, max_height); 1254 tmp_h = min(2 * tmp_h, max_height);
1255 mf->width = tmp_w; 1255 mf->width = tmp_w;
1256 mf->height = tmp_h; 1256 mf->height = tmp_h;
1257 ret = v4l2_device_call_until_err(sd->v4l2_dev, 0, video, 1257 ret = v4l2_device_call_until_err(sd->v4l2_dev, (long)icd, video,
1258 s_mbus_fmt, mf); 1258 s_mbus_fmt, mf);
1259 dev_geo(dev, "Camera scaled to %ux%u\n", 1259 dev_geo(dev, "Camera scaled to %ux%u\n",
1260 mf->width, mf->height); 1260 mf->width, mf->height);
@@ -1658,7 +1658,7 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd,
1658 mf.code = xlate->code; 1658 mf.code = xlate->code;
1659 mf.colorspace = pix->colorspace; 1659 mf.colorspace = pix->colorspace;
1660 1660
1661 ret = v4l2_device_call_until_err(sd->v4l2_dev, 0, video, try_mbus_fmt, &mf); 1661 ret = v4l2_device_call_until_err(sd->v4l2_dev, (long)icd, video, try_mbus_fmt, &mf);
1662 if (ret < 0) 1662 if (ret < 0)
1663 return ret; 1663 return ret;
1664 1664
@@ -1682,7 +1682,7 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd,
1682 */ 1682 */
1683 mf.width = 2560; 1683 mf.width = 2560;
1684 mf.height = 1920; 1684 mf.height = 1920;
1685 ret = v4l2_device_call_until_err(sd->v4l2_dev, 0, video, 1685 ret = v4l2_device_call_until_err(sd->v4l2_dev, (long)icd, video,
1686 try_mbus_fmt, &mf); 1686 try_mbus_fmt, &mf);
1687 if (ret < 0) { 1687 if (ret < 0) {
1688 /* Shouldn't actually happen... */ 1688 /* Shouldn't actually happen... */
diff --git a/drivers/media/video/sh_mobile_csi2.c b/drivers/media/video/sh_mobile_csi2.c
index dd1b81b1442b..98b87481fa94 100644
--- a/drivers/media/video/sh_mobile_csi2.c
+++ b/drivers/media/video/sh_mobile_csi2.c
@@ -38,6 +38,8 @@ struct sh_csi2 {
38 void __iomem *base; 38 void __iomem *base;
39 struct platform_device *pdev; 39 struct platform_device *pdev;
40 struct sh_csi2_client_config *client; 40 struct sh_csi2_client_config *client;
41 unsigned long (*query_bus_param)(struct soc_camera_device *);
42 int (*set_bus_param)(struct soc_camera_device *, unsigned long);
41}; 43};
42 44
43static int sh_csi2_try_fmt(struct v4l2_subdev *sd, 45static int sh_csi2_try_fmt(struct v4l2_subdev *sd,
@@ -208,6 +210,7 @@ static int sh_csi2_notify(struct notifier_block *nb,
208 case BUS_NOTIFY_BOUND_DRIVER: 210 case BUS_NOTIFY_BOUND_DRIVER:
209 snprintf(priv->subdev.name, V4L2_SUBDEV_NAME_SIZE, "%s%s", 211 snprintf(priv->subdev.name, V4L2_SUBDEV_NAME_SIZE, "%s%s",
210 dev_name(v4l2_dev->dev), ".mipi-csi"); 212 dev_name(v4l2_dev->dev), ".mipi-csi");
213 priv->subdev.grp_id = (long)icd;
211 ret = v4l2_device_register_subdev(v4l2_dev, &priv->subdev); 214 ret = v4l2_device_register_subdev(v4l2_dev, &priv->subdev);
212 dev_dbg(dev, "%s(%p): ret(register_subdev) = %d\n", __func__, priv, ret); 215 dev_dbg(dev, "%s(%p): ret(register_subdev) = %d\n", __func__, priv, ret);
213 if (ret < 0) 216 if (ret < 0)
@@ -215,6 +218,8 @@ static int sh_csi2_notify(struct notifier_block *nb,
215 218
216 priv->client = pdata->clients + i; 219 priv->client = pdata->clients + i;
217 220
221 priv->set_bus_param = icd->ops->set_bus_param;
222 priv->query_bus_param = icd->ops->query_bus_param;
218 icd->ops->set_bus_param = sh_csi2_set_bus_param; 223 icd->ops->set_bus_param = sh_csi2_set_bus_param;
219 icd->ops->query_bus_param = sh_csi2_query_bus_param; 224 icd->ops->query_bus_param = sh_csi2_query_bus_param;
220 225
@@ -226,8 +231,10 @@ static int sh_csi2_notify(struct notifier_block *nb,
226 priv->client = NULL; 231 priv->client = NULL;
227 232
228 /* Driver is about to be unbound */ 233 /* Driver is about to be unbound */
229 icd->ops->set_bus_param = NULL; 234 icd->ops->set_bus_param = priv->set_bus_param;
230 icd->ops->query_bus_param = NULL; 235 icd->ops->query_bus_param = priv->query_bus_param;
236 priv->set_bus_param = NULL;
237 priv->query_bus_param = NULL;
231 238
232 v4l2_device_unregister_subdev(&priv->subdev); 239 v4l2_device_unregister_subdev(&priv->subdev);
233 240
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index 46284489e4eb..3973f9a94753 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -996,10 +996,11 @@ static void soc_camera_free_i2c(struct soc_camera_device *icd)
996{ 996{
997 struct i2c_client *client = 997 struct i2c_client *client =
998 to_i2c_client(to_soc_camera_control(icd)); 998 to_i2c_client(to_soc_camera_control(icd));
999 struct i2c_adapter *adap = client->adapter;
999 dev_set_drvdata(&icd->dev, NULL); 1000 dev_set_drvdata(&icd->dev, NULL);
1000 v4l2_device_unregister_subdev(i2c_get_clientdata(client)); 1001 v4l2_device_unregister_subdev(i2c_get_clientdata(client));
1001 i2c_unregister_device(client); 1002 i2c_unregister_device(client);
1002 i2c_put_adapter(client->adapter); 1003 i2c_put_adapter(adap);
1003} 1004}
1004#else 1005#else
1005#define soc_camera_init_i2c(icd, icl) (-ENODEV) 1006#define soc_camera_init_i2c(icd, icl) (-ENODEV)
@@ -1071,6 +1072,9 @@ static int soc_camera_probe(struct device *dev)
1071 } 1072 }
1072 } 1073 }
1073 1074
1075 sd = soc_camera_to_subdev(icd);
1076 sd->grp_id = (long)icd;
1077
1074 /* At this point client .probe() should have run already */ 1078 /* At this point client .probe() should have run already */
1075 ret = soc_camera_init_user_formats(icd); 1079 ret = soc_camera_init_user_formats(icd);
1076 if (ret < 0) 1080 if (ret < 0)
@@ -1092,7 +1096,6 @@ static int soc_camera_probe(struct device *dev)
1092 goto evidstart; 1096 goto evidstart;
1093 1097
1094 /* Try to improve our guess of a reasonable window format */ 1098 /* Try to improve our guess of a reasonable window format */
1095 sd = soc_camera_to_subdev(icd);
1096 if (!v4l2_subdev_call(sd, video, g_mbus_fmt, &mf)) { 1099 if (!v4l2_subdev_call(sd, video, g_mbus_fmt, &mf)) {
1097 icd->user_width = mf.width; 1100 icd->user_width = mf.width;
1098 icd->user_height = mf.height; 1101 icd->user_height = mf.height;
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index 498e6742579e..6dc7196296b3 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -389,7 +389,8 @@ static int v4l2_open(struct inode *inode, struct file *filp)
389 video_get(vdev); 389 video_get(vdev);
390 mutex_unlock(&videodev_lock); 390 mutex_unlock(&videodev_lock);
391#if defined(CONFIG_MEDIA_CONTROLLER) 391#if defined(CONFIG_MEDIA_CONTROLLER)
392 if (vdev->v4l2_dev && vdev->v4l2_dev->mdev) { 392 if (vdev->v4l2_dev && vdev->v4l2_dev->mdev &&
393 vdev->vfl_type != VFL_TYPE_SUBDEV) {
393 entity = media_entity_get(&vdev->entity); 394 entity = media_entity_get(&vdev->entity);
394 if (!entity) { 395 if (!entity) {
395 ret = -EBUSY; 396 ret = -EBUSY;
@@ -415,7 +416,8 @@ err:
415 /* decrease the refcount in case of an error */ 416 /* decrease the refcount in case of an error */
416 if (ret) { 417 if (ret) {
417#if defined(CONFIG_MEDIA_CONTROLLER) 418#if defined(CONFIG_MEDIA_CONTROLLER)
418 if (vdev->v4l2_dev && vdev->v4l2_dev->mdev) 419 if (vdev->v4l2_dev && vdev->v4l2_dev->mdev &&
420 vdev->vfl_type != VFL_TYPE_SUBDEV)
419 media_entity_put(entity); 421 media_entity_put(entity);
420#endif 422#endif
421 video_put(vdev); 423 video_put(vdev);
@@ -437,7 +439,8 @@ static int v4l2_release(struct inode *inode, struct file *filp)
437 mutex_unlock(vdev->lock); 439 mutex_unlock(vdev->lock);
438 } 440 }
439#if defined(CONFIG_MEDIA_CONTROLLER) 441#if defined(CONFIG_MEDIA_CONTROLLER)
440 if (vdev->v4l2_dev && vdev->v4l2_dev->mdev) 442 if (vdev->v4l2_dev && vdev->v4l2_dev->mdev &&
443 vdev->vfl_type != VFL_TYPE_SUBDEV)
441 media_entity_put(&vdev->entity); 444 media_entity_put(&vdev->entity);
442#endif 445#endif
443 /* decrease the refcount unconditionally since the release() 446 /* decrease the refcount unconditionally since the release()
@@ -686,7 +689,8 @@ int __video_register_device(struct video_device *vdev, int type, int nr,
686 689
687#if defined(CONFIG_MEDIA_CONTROLLER) 690#if defined(CONFIG_MEDIA_CONTROLLER)
688 /* Part 5: Register the entity. */ 691 /* Part 5: Register the entity. */
689 if (vdev->v4l2_dev && vdev->v4l2_dev->mdev) { 692 if (vdev->v4l2_dev && vdev->v4l2_dev->mdev &&
693 vdev->vfl_type != VFL_TYPE_SUBDEV) {
690 vdev->entity.type = MEDIA_ENT_T_DEVNODE_V4L; 694 vdev->entity.type = MEDIA_ENT_T_DEVNODE_V4L;
691 vdev->entity.name = vdev->name; 695 vdev->entity.name = vdev->name;
692 vdev->entity.v4l.major = VIDEO_MAJOR; 696 vdev->entity.v4l.major = VIDEO_MAJOR;
@@ -733,7 +737,8 @@ void video_unregister_device(struct video_device *vdev)
733 return; 737 return;
734 738
735#if defined(CONFIG_MEDIA_CONTROLLER) 739#if defined(CONFIG_MEDIA_CONTROLLER)
736 if (vdev->v4l2_dev && vdev->v4l2_dev->mdev) 740 if (vdev->v4l2_dev && vdev->v4l2_dev->mdev &&
741 vdev->vfl_type != VFL_TYPE_SUBDEV)
737 media_device_unregister_entity(&vdev->entity); 742 media_device_unregister_entity(&vdev->entity);
738#endif 743#endif
739 744
diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c
index 6698c77e0f64..6ba1461d51ef 100644
--- a/drivers/media/video/videobuf2-core.c
+++ b/drivers/media/video/videobuf2-core.c
@@ -37,6 +37,9 @@ module_param(debug, int, 0644);
37#define call_qop(q, op, args...) \ 37#define call_qop(q, op, args...) \
38 (((q)->ops->op) ? ((q)->ops->op(args)) : 0) 38 (((q)->ops->op) ? ((q)->ops->op(args)) : 0)
39 39
40#define V4L2_BUFFER_STATE_FLAGS (V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_QUEUED | \
41 V4L2_BUF_FLAG_DONE | V4L2_BUF_FLAG_ERROR)
42
40/** 43/**
41 * __vb2_buf_mem_alloc() - allocate video memory for the given buffer 44 * __vb2_buf_mem_alloc() - allocate video memory for the given buffer
42 */ 45 */
@@ -51,7 +54,7 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb,
51 for (plane = 0; plane < vb->num_planes; ++plane) { 54 for (plane = 0; plane < vb->num_planes; ++plane) {
52 mem_priv = call_memop(q, plane, alloc, q->alloc_ctx[plane], 55 mem_priv = call_memop(q, plane, alloc, q->alloc_ctx[plane],
53 plane_sizes[plane]); 56 plane_sizes[plane]);
54 if (!mem_priv) 57 if (IS_ERR_OR_NULL(mem_priv))
55 goto free; 58 goto free;
56 59
57 /* Associate allocator private data with this plane */ 60 /* Associate allocator private data with this plane */
@@ -284,7 +287,7 @@ static int __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
284 struct vb2_queue *q = vb->vb2_queue; 287 struct vb2_queue *q = vb->vb2_queue;
285 int ret = 0; 288 int ret = 0;
286 289
287 /* Copy back data such as timestamp, input, etc. */ 290 /* Copy back data such as timestamp, flags, input, etc. */
288 memcpy(b, &vb->v4l2_buf, offsetof(struct v4l2_buffer, m)); 291 memcpy(b, &vb->v4l2_buf, offsetof(struct v4l2_buffer, m));
289 b->input = vb->v4l2_buf.input; 292 b->input = vb->v4l2_buf.input;
290 b->reserved = vb->v4l2_buf.reserved; 293 b->reserved = vb->v4l2_buf.reserved;
@@ -313,7 +316,10 @@ static int __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
313 b->m.userptr = vb->v4l2_planes[0].m.userptr; 316 b->m.userptr = vb->v4l2_planes[0].m.userptr;
314 } 317 }
315 318
316 b->flags = 0; 319 /*
320 * Clear any buffer state related flags.
321 */
322 b->flags &= ~V4L2_BUFFER_STATE_FLAGS;
317 323
318 switch (vb->state) { 324 switch (vb->state) {
319 case VB2_BUF_STATE_QUEUED: 325 case VB2_BUF_STATE_QUEUED:
@@ -519,6 +525,7 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
519 num_buffers = min_t(unsigned int, req->count, VIDEO_MAX_FRAME); 525 num_buffers = min_t(unsigned int, req->count, VIDEO_MAX_FRAME);
520 memset(plane_sizes, 0, sizeof(plane_sizes)); 526 memset(plane_sizes, 0, sizeof(plane_sizes));
521 memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx)); 527 memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx));
528 q->memory = req->memory;
522 529
523 /* 530 /*
524 * Ask the driver how many buffers and planes per buffer it requires. 531 * Ask the driver how many buffers and planes per buffer it requires.
@@ -560,8 +567,6 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
560 ret = num_buffers; 567 ret = num_buffers;
561 } 568 }
562 569
563 q->memory = req->memory;
564
565 /* 570 /*
566 * Return the number of successfully allocated buffers 571 * Return the number of successfully allocated buffers
567 * to the userspace. 572 * to the userspace.
@@ -715,6 +720,8 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b,
715 720
716 vb->v4l2_buf.field = b->field; 721 vb->v4l2_buf.field = b->field;
717 vb->v4l2_buf.timestamp = b->timestamp; 722 vb->v4l2_buf.timestamp = b->timestamp;
723 vb->v4l2_buf.input = b->input;
724 vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_STATE_FLAGS;
718 725
719 return 0; 726 return 0;
720} 727}
diff --git a/drivers/media/video/videobuf2-dma-contig.c b/drivers/media/video/videobuf2-dma-contig.c
index 58205d596138..a790a5f8c06f 100644
--- a/drivers/media/video/videobuf2-dma-contig.c
+++ b/drivers/media/video/videobuf2-dma-contig.c
@@ -46,7 +46,7 @@ static void *vb2_dma_contig_alloc(void *alloc_ctx, unsigned long size)
46 GFP_KERNEL); 46 GFP_KERNEL);
47 if (!buf->vaddr) { 47 if (!buf->vaddr) {
48 dev_err(conf->dev, "dma_alloc_coherent of size %ld failed\n", 48 dev_err(conf->dev, "dma_alloc_coherent of size %ld failed\n",
49 buf->size); 49 size);
50 kfree(buf); 50 kfree(buf);
51 return ERR_PTR(-ENOMEM); 51 return ERR_PTR(-ENOMEM);
52 } 52 }