aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-01-12 01:17:44 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-12 01:17:44 -0500
commit47c62e4be78303ef52ffa8134026919d0890c5a9 (patch)
treec0ece2346076651da1f9fb33261d89f43b711be9
parent2c487121e3c4f87e82cff493872675bde52e47fc (diff)
parentc3152592e70bbf023ec106ee9ea271e9060bc09a (diff)
Merge tag 'media/v4.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab: "The part of patches for Kernel 4.5. There's nothing really big here: - driver-specific headers for media devices were moved to separate directories, in order to make clear what headers belong to the core kABI and require documentation - Platform data for media drivers were moved from include/media to include/linux/platform_data/media - add a driver for cs3308 8-channel volume control, used on some high-end capture boards - lirc.h kAPI header were added at include/uapi/linux - Driver cleanups, new board additions and improvements" * tag 'media/v4.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (204 commits) [media] rc: sunxi-cir: Initialize the spinlock properly [media] rtl2832: do not filter out slave TS null packets [media] rtl2832: print reg number on error case [media] rtl28xxu: return demod reg page from driver cache [media] coda: enable MPEG-2 ES decoding [media] coda: don't start streaming without queued buffers [media] coda: hook up vidioc_prepare_buf [media] coda: relax coda_jpeg_check_buffer for trailing bytes [media] coda: make to_coda_video_device static [media] s5p-mfc: remove volatile attribute from MFC register addresses [media] s5p-mfc: merge together s5p_mfc_hw_call and s5p_mfc_hw_call_void [media] s5p-mfc: use spinlock to protect MFC context [media] s5p-mfc: remove unnecessary callbacks [media] s5p-mfc: make queue cleanup code common [media] s5p-mfc: use one implementation of s5p_mfc_get_new_ctx [media] s5p-mfc: constify s5p_mfc_codec_ops structures [media] au8522: Avoid memory leak for device config data [media] ir-lirc-codec.c: don't leak lirc->drv-rbuf [media] uvcvideo: small cleanup in uvc_video_clock_update() [media] uvcvideo: Fix reading the current exposure value of UVC ...
-rw-r--r--Documentation/DocBook/device-drivers.tmpl84
-rw-r--r--Documentation/DocBook/media/Makefile6
-rw-r--r--Documentation/DocBook/media/dvb/dvbproperty.xml2
-rw-r--r--Documentation/DocBook/media/dvb/examples.xml2
-rw-r--r--Documentation/DocBook/media/dvb/intro.xml2
-rw-r--r--Documentation/DocBook/media/v4l/capture.c.xml2
-rw-r--r--Documentation/DocBook/media/v4l/compat.xml2
-rw-r--r--Documentation/DocBook/media/v4l/io.xml10
-rw-r--r--Documentation/DocBook/media/v4l/v4l2.xml10
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-create-bufs.xml30
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-info.xml2
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml2
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-enumstd.xml2
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml28
-rw-r--r--Documentation/DocBook/media_api.tmpl6
-rw-r--r--Documentation/devicetree/bindings/media/stih407-c8sectpfe.txt20
-rw-r--r--Documentation/dvb/README.dvb-usb4
-rw-r--r--Documentation/dvb/faq.txt2
-rwxr-xr-xDocumentation/dvb/get_dvb_firmware22
-rw-r--r--Documentation/dvb/readme.txt10
-rw-r--r--Documentation/video4linux/API.html2
-rw-r--r--Documentation/video4linux/CARDLIST.em28xx4
-rw-r--r--Documentation/video4linux/fimc.txt6
-rw-r--r--Documentation/video4linux/omap4_camera.txt2
-rw-r--r--Documentation/video4linux/si4713.txt2
-rw-r--r--Documentation/video4linux/v4l2-pci-skeleton.c13
-rw-r--r--MAINTAINERS226
-rw-r--r--arch/arm/boot/dts/stihxxx-b2120.dtsi46
-rw-r--r--arch/arm/mach-davinci/board-da850-evm.c4
-rw-r--r--arch/arm/mach-davinci/board-dm355-evm.c2
-rw-r--r--arch/arm/mach-davinci/board-dm365-evm.c4
-rw-r--r--arch/arm/mach-davinci/board-dm644x-evm.c2
-rw-r--r--arch/arm/mach-davinci/board-dm646x-evm.c4
-rw-r--r--arch/arm/mach-imx/devices/devices-common.h4
-rw-r--r--arch/arm/mach-omap1/include/mach/camera.h2
-rw-r--r--arch/arm/mach-omap2/board-rx51-peripherals.c4
-rw-r--r--arch/arm/mach-pxa/devices.c2
-rw-r--r--arch/arm/mach-pxa/em-x270.c2
-rw-r--r--arch/arm/mach-pxa/ezx.c2
-rw-r--r--arch/arm/mach-pxa/mioa701.c2
-rw-r--r--arch/arm/mach-pxa/palmtreo.c2
-rw-r--r--arch/arm/mach-pxa/palmz72.c2
-rw-r--r--arch/arm/mach-pxa/pcm990-baseboard.c4
-rw-r--r--arch/arm/plat-samsung/devs.c2
-rw-r--r--arch/blackfin/mach-bf561/boards/ezkit.c2
-rw-r--r--arch/blackfin/mach-bf609/boards/ezkit.c6
-rw-r--r--arch/sh/boards/mach-ap325rxa/setup.c6
-rw-r--r--arch/sh/boards/mach-ecovec24/setup.c10
-rw-r--r--arch/sh/boards/mach-kfr2r09/setup.c4
-rw-r--r--arch/sh/boards/mach-migor/setup.c6
-rw-r--r--arch/sh/boards/mach-se/7724/setup.c6
-rw-r--r--drivers/gpu/ipu-v3/ipu-cpmem.c2
-rw-r--r--drivers/input/touchscreen/sur40.c13
-rw-r--r--drivers/media/Kconfig4
-rw-r--r--drivers/media/common/cx2341x.c2
-rw-r--r--drivers/media/common/saa7146/saa7146_core.c2
-rw-r--r--drivers/media/common/saa7146/saa7146_fops.c2
-rw-r--r--drivers/media/common/saa7146/saa7146_hlp.c2
-rw-r--r--drivers/media/common/saa7146/saa7146_i2c.c2
-rw-r--r--drivers/media/common/saa7146/saa7146_vbi.c2
-rw-r--r--drivers/media/common/saa7146/saa7146_video.c2
-rw-r--r--drivers/media/common/siano/smsir.h2
-rw-r--r--drivers/media/dvb-core/demux.h67
-rw-r--r--drivers/media/dvb-core/dvb-usb-ids.h1
-rw-r--r--drivers/media/dvb-core/dvb_frontend.c27
-rw-r--r--drivers/media/dvb-core/dvb_frontend.h221
-rw-r--r--drivers/media/dvb-frontends/Kconfig2
-rw-r--r--drivers/media/dvb-frontends/au8522_common.c10
-rw-r--r--drivers/media/dvb-frontends/au8522_decoder.c14
-rw-r--r--drivers/media/dvb-frontends/au8522_dig.c16
-rw-r--r--drivers/media/dvb-frontends/au8522_priv.h2
-rw-r--r--drivers/media/dvb-frontends/bsbe1-d01a.h2
-rw-r--r--drivers/media/dvb-frontends/bsbe1.h2
-rw-r--r--drivers/media/dvb-frontends/bsru6.h2
-rw-r--r--drivers/media/dvb-frontends/isl6405.c2
-rw-r--r--drivers/media/dvb-frontends/isl6405.h2
-rw-r--r--drivers/media/dvb-frontends/isl6421.c2
-rw-r--r--drivers/media/dvb-frontends/isl6421.h2
-rw-r--r--drivers/media/dvb-frontends/lnbp21.c2
-rw-r--r--drivers/media/dvb-frontends/lnbp21.h2
-rw-r--r--drivers/media/dvb-frontends/lnbp22.c2
-rw-r--r--drivers/media/dvb-frontends/lnbp22.h2
-rw-r--r--drivers/media/dvb-frontends/rtl2832.c21
-rw-r--r--drivers/media/dvb-frontends/rtl2832_sdr.c4
-rw-r--r--drivers/media/dvb-frontends/si2165.c351
-rw-r--r--drivers/media/dvb-frontends/stb6100.c76
-rw-r--r--drivers/media/dvb-frontends/stb6100.h1
-rw-r--r--drivers/media/dvb-frontends/stb6100_cfg.h37
-rw-r--r--drivers/media/dvb-frontends/stb6100_proc.h43
-rw-r--r--drivers/media/dvb-frontends/tda665x.c183
-rw-r--r--drivers/media/dvb-frontends/tda8261.c125
-rw-r--r--drivers/media/dvb-frontends/tda8261_cfg.h37
-rw-r--r--drivers/media/dvb-frontends/tdhd1.h2
-rw-r--r--drivers/media/i2c/Kconfig10
-rw-r--r--drivers/media/i2c/Makefile1
-rw-r--r--drivers/media/i2c/ad9389b.c2
-rw-r--r--drivers/media/i2c/adp1653.c2
-rw-r--r--drivers/media/i2c/adv7180.c2
-rw-r--r--drivers/media/i2c/adv7183.c2
-rw-r--r--drivers/media/i2c/adv7343.c2
-rw-r--r--drivers/media/i2c/adv7393.c2
-rw-r--r--drivers/media/i2c/adv7511.c4
-rw-r--r--drivers/media/i2c/adv7604.c8
-rw-r--r--drivers/media/i2c/adv7842.c8
-rw-r--r--drivers/media/i2c/ak881x.c2
-rw-r--r--drivers/media/i2c/as3645a.c2
-rw-r--r--drivers/media/i2c/bt819.c2
-rw-r--r--drivers/media/i2c/cs3308.c138
-rw-r--r--drivers/media/i2c/cx25840/cx25840-audio.c2
-rw-r--r--drivers/media/i2c/cx25840/cx25840-core.c117
-rw-r--r--drivers/media/i2c/cx25840/cx25840-core.h1
-rw-r--r--drivers/media/i2c/cx25840/cx25840-firmware.c2
-rw-r--r--drivers/media/i2c/cx25840/cx25840-ir.c2
-rw-r--r--drivers/media/i2c/cx25840/cx25840-vbi.c34
-rw-r--r--drivers/media/i2c/ir-kbd-i2c.c2
-rw-r--r--drivers/media/i2c/lm3560.c2
-rw-r--r--drivers/media/i2c/lm3646.c2
-rw-r--r--drivers/media/i2c/m52790.c2
-rw-r--r--drivers/media/i2c/m5mols/m5mols_capture.c4
-rw-r--r--drivers/media/i2c/m5mols/m5mols_core.c2
-rw-r--r--drivers/media/i2c/msp3400-driver.c4
-rw-r--r--drivers/media/i2c/msp3400-driver.h2
-rw-r--r--drivers/media/i2c/msp3400-kthreads.c2
-rw-r--r--drivers/media/i2c/mt9m032.c4
-rw-r--r--drivers/media/i2c/mt9p031.c4
-rw-r--r--drivers/media/i2c/mt9t001.c4
-rw-r--r--drivers/media/i2c/mt9v011.c4
-rw-r--r--drivers/media/i2c/mt9v032.c4
-rw-r--r--drivers/media/i2c/noon010pc30.c2
-rw-r--r--drivers/media/i2c/ov2659.c4
-rw-r--r--drivers/media/i2c/ov7670.c2
-rw-r--r--drivers/media/i2c/ov9650.c2
-rw-r--r--drivers/media/i2c/s5c73m3/s5c73m3-core.c2
-rw-r--r--drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c2
-rw-r--r--drivers/media/i2c/s5c73m3/s5c73m3-spi.c1
-rw-r--r--drivers/media/i2c/s5c73m3/s5c73m3.h2
-rw-r--r--drivers/media/i2c/s5k4ecgx.c2
-rw-r--r--drivers/media/i2c/s5k6aa.c2
-rw-r--r--drivers/media/i2c/saa6588.c2
-rw-r--r--drivers/media/i2c/saa7115.c2
-rw-r--r--drivers/media/i2c/saa7127.c2
-rw-r--r--drivers/media/i2c/smiapp/smiapp.h2
-rw-r--r--drivers/media/i2c/soc_camera/mt9m001.c2
-rw-r--r--drivers/media/i2c/soc_camera/mt9t112.c2
-rw-r--r--drivers/media/i2c/soc_camera/mt9v022.c4
-rw-r--r--drivers/media/i2c/soc_camera/ov772x.c2
-rw-r--r--drivers/media/i2c/soc_camera/rj54n1cb0c.c2
-rw-r--r--drivers/media/i2c/soc_camera/tw9910.c2
-rw-r--r--drivers/media/i2c/sr030pc30.c2
-rw-r--r--drivers/media/i2c/tc358743.c6
-rw-r--r--drivers/media/i2c/ths7303.c2
-rw-r--r--drivers/media/i2c/tvaudio.c2
-rw-r--r--drivers/media/i2c/tvp514x.c2
-rw-r--r--drivers/media/i2c/tvp5150.c2
-rw-r--r--drivers/media/i2c/tvp7002.c2
-rw-r--r--drivers/media/i2c/uda1342.c2
-rw-r--r--drivers/media/i2c/upd64031a.c2
-rw-r--r--drivers/media/i2c/upd64083.c2
-rw-r--r--drivers/media/i2c/wm8775.c2
-rw-r--r--drivers/media/pci/bt8xx/bttv-cards.c4
-rw-r--r--drivers/media/pci/bt8xx/bttv-driver.c6
-rw-r--r--drivers/media/pci/bt8xx/bttvp.h4
-rw-r--r--drivers/media/pci/cobalt/cobalt-driver.c6
-rw-r--r--drivers/media/pci/cobalt/cobalt-irq.c4
-rw-r--r--drivers/media/pci/cobalt/cobalt-v4l2.c18
-rw-r--r--drivers/media/pci/cx18/cx18-cards.c2
-rw-r--r--drivers/media/pci/cx18/cx18-controls.c2
-rw-r--r--drivers/media/pci/cx18/cx18-controls.h2
-rw-r--r--drivers/media/pci/cx18/cx18-driver.h2
-rw-r--r--drivers/media/pci/cx18/cx18-ioctl.c4
-rw-r--r--drivers/media/pci/cx18/cx23418.h2
-rw-r--r--drivers/media/pci/cx23885/Kconfig1
-rw-r--r--drivers/media/pci/cx23885/cx23885-417.c4
-rw-r--r--drivers/media/pci/cx23885/cx23885-cards.c116
-rw-r--r--drivers/media/pci/cx23885/cx23885-core.c12
-rw-r--r--drivers/media/pci/cx23885/cx23885-dvb.c8
-rw-r--r--drivers/media/pci/cx23885/cx23885-i2c.c2
-rw-r--r--drivers/media/pci/cx23885/cx23885-input.c2
-rw-r--r--drivers/media/pci/cx23885/cx23885-vbi.c5
-rw-r--r--drivers/media/pci/cx23885/cx23885-video.c49
-rw-r--r--drivers/media/pci/cx23885/cx23885.h9
-rw-r--r--drivers/media/pci/cx25821/cx25821-video.c14
-rw-r--r--drivers/media/pci/cx88/cx88-alsa.c2
-rw-r--r--drivers/media/pci/cx88/cx88-blackbird.c4
-rw-r--r--drivers/media/pci/cx88/cx88-core.c2
-rw-r--r--drivers/media/pci/cx88/cx88-dvb.c2
-rw-r--r--drivers/media/pci/cx88/cx88-vbi.c2
-rw-r--r--drivers/media/pci/cx88/cx88-video.c4
-rw-r--r--drivers/media/pci/cx88/cx88.h6
-rw-r--r--drivers/media/pci/ddbridge/ddbridge-core.c4
-rw-r--r--drivers/media/pci/dm1105/dm1105.c1
-rw-r--r--drivers/media/pci/dt3155/dt3155.c13
-rw-r--r--drivers/media/pci/ivtv/ivtv-cards.c12
-rw-r--r--drivers/media/pci/ivtv/ivtv-controls.c2
-rw-r--r--drivers/media/pci/ivtv/ivtv-controls.h2
-rw-r--r--drivers/media/pci/ivtv/ivtv-driver.c4
-rw-r--r--drivers/media/pci/ivtv/ivtv-driver.h4
-rw-r--r--drivers/media/pci/ivtv/ivtv-fileops.c2
-rw-r--r--drivers/media/pci/ivtv/ivtv-firmware.c2
-rw-r--r--drivers/media/pci/ivtv/ivtv-i2c.c2
-rw-r--r--drivers/media/pci/ivtv/ivtv-ioctl.c10
-rw-r--r--drivers/media/pci/ivtv/ivtv-routing.c8
-rw-r--r--drivers/media/pci/netup_unidvb/netup_unidvb_core.c3
-rw-r--r--drivers/media/pci/saa7134/saa7134-core.c2
-rw-r--r--drivers/media/pci/saa7134/saa7134-ts.c2
-rw-r--r--drivers/media/pci/saa7134/saa7134-vbi.c2
-rw-r--r--drivers/media/pci/saa7134/saa7134-video.c4
-rw-r--r--drivers/media/pci/saa7134/saa7134.h4
-rw-r--r--drivers/media/pci/saa7146/hexium_gemini.c2
-rw-r--r--drivers/media/pci/saa7146/hexium_orion.c2
-rw-r--r--drivers/media/pci/saa7146/mxb.c4
-rw-r--r--drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c4
-rw-r--r--drivers/media/pci/solo6x10/solo6x10-v4l2.c4
-rw-r--r--drivers/media/pci/sta2x11/sta2x11_vip.c4
-rw-r--r--drivers/media/pci/ttpci/av7110.c6
-rw-r--r--drivers/media/pci/ttpci/av7110.h2
-rw-r--r--drivers/media/pci/ttpci/av7110_av.c11
-rw-r--r--drivers/media/pci/ttpci/av7110_av.h3
-rw-r--r--drivers/media/pci/ttpci/av7110_ca.c2
-rw-r--r--drivers/media/pci/ttpci/av7110_hw.c2
-rw-r--r--drivers/media/pci/ttpci/av7110_v4l.c2
-rw-r--r--drivers/media/pci/ttpci/budget-av.c4
-rw-r--r--drivers/media/pci/ttpci/budget-ci.c2
-rw-r--r--drivers/media/pci/ttpci/budget-core.c2
-rw-r--r--drivers/media/pci/ttpci/budget-patch.c2
-rw-r--r--drivers/media/pci/ttpci/budget.c2
-rw-r--r--drivers/media/pci/ttpci/budget.h2
-rw-r--r--drivers/media/pci/tw68/tw68-video.c22
-rw-r--r--drivers/media/pci/zoran/zoran_card.c2
-rw-r--r--drivers/media/platform/Kconfig2
-rw-r--r--drivers/media/platform/am437x/am437x-vpfe.c19
-rw-r--r--drivers/media/platform/blackfin/bfin_capture.c14
-rw-r--r--drivers/media/platform/coda/coda-bit.c8
-rw-r--r--drivers/media/platform/coda/coda-common.c25
-rw-r--r--drivers/media/platform/coda/coda-jpeg.c26
-rw-r--r--drivers/media/platform/coda/coda.h4
-rw-r--r--drivers/media/platform/davinci/Kconfig6
-rw-r--r--drivers/media/platform/davinci/vpbe_display.c15
-rw-r--r--drivers/media/platform/davinci/vpif_capture.c19
-rw-r--r--drivers/media/platform/davinci/vpif_display.c19
-rw-r--r--drivers/media/platform/exynos-gsc/gsc-m2m.c5
-rw-r--r--drivers/media/platform/exynos4-is/common.c2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-capture.c33
-rw-r--r--drivers/media/platform/exynos4-is/fimc-core.h2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-isp-video.c35
-rw-r--r--drivers/media/platform/exynos4-is/fimc-isp.h2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-lite-reg.c2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-lite.c35
-rw-r--r--drivers/media/platform/exynos4-is/fimc-lite.h2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-m2m.c4
-rw-r--r--drivers/media/platform/exynos4-is/fimc-reg.c2
-rw-r--r--drivers/media/platform/exynos4-is/media-dev.c2
-rw-r--r--drivers/media/platform/exynos4-is/media-dev.h2
-rw-r--r--drivers/media/platform/exynos4-is/mipi-csis.c2
-rw-r--r--drivers/media/platform/m2m-deinterlace.c3
-rw-r--r--drivers/media/platform/marvell-ccic/mcam-core.c17
-rw-r--r--drivers/media/platform/marvell-ccic/mmp-driver.c2
-rw-r--r--drivers/media/platform/mx2_emmaprp.c3
-rw-r--r--drivers/media/platform/omap/omap_vout_vrfb.c10
-rw-r--r--drivers/media/platform/omap3isp/ispvideo.c3
-rw-r--r--drivers/media/platform/rcar_jpu.c40
-rw-r--r--drivers/media/platform/s3c-camif/camif-capture.c35
-rw-r--r--drivers/media/platform/s3c-camif/camif-core.h2
-rw-r--r--drivers/media/platform/s3c-camif/camif-regs.h2
-rw-r--r--drivers/media/platform/s5p-g2d/g2d.c4
-rw-r--r--drivers/media/platform/s5p-jpeg/jpeg-core.c5
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc.c103
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_common.h14
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c16
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_dec.c39
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_dec.h2
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_enc.c47
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_enc.h2
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_opr.h507
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c94
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c121
-rw-r--r--drivers/media/platform/s5p-tv/hdmi_drv.c4
-rw-r--r--drivers/media/platform/s5p-tv/mixer_video.c2
-rw-r--r--drivers/media/platform/s5p-tv/sii9234_drv.c2
-rw-r--r--drivers/media/platform/sh_veu.c33
-rw-r--r--drivers/media/platform/sh_vou.c15
-rw-r--r--drivers/media/platform/soc_camera/atmel-isi.c168
-rw-r--r--drivers/media/platform/soc_camera/atmel-isi.h10
-rw-r--r--drivers/media/platform/soc_camera/mx2_camera.c12
-rw-r--r--drivers/media/platform/soc_camera/mx3_camera.c44
-rw-r--r--drivers/media/platform/soc_camera/omap1_camera.c4
-rw-r--r--drivers/media/platform/soc_camera/pxa_camera.c4
-rw-r--r--drivers/media/platform/soc_camera/rcar_vin.c119
-rw-r--r--drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c45
-rw-r--r--drivers/media/platform/soc_camera/sh_mobile_csi2.c6
-rw-r--r--drivers/media/platform/soc_camera/soc_camera.c25
-rw-r--r--drivers/media/platform/soc_camera/soc_camera_platform.c2
-rw-r--r--drivers/media/platform/soc_camera/soc_mediabus.c2
-rw-r--r--drivers/media/platform/sti/bdisp/bdisp-v4l2.c14
-rw-r--r--drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c16
-rw-r--r--drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c2
-rw-r--r--drivers/media/platform/ti-vpe/vpe.c3
-rw-r--r--drivers/media/platform/timblogiw.c2
-rw-r--r--drivers/media/platform/via-camera.c2
-rw-r--r--drivers/media/platform/vim2m.c15
-rw-r--r--drivers/media/platform/vivid/vivid-core.h3
-rw-r--r--drivers/media/platform/vivid/vivid-ctrls.c35
-rw-r--r--drivers/media/platform/vivid/vivid-kthread-cap.c6
-rw-r--r--drivers/media/platform/vivid/vivid-kthread-out.c8
-rw-r--r--drivers/media/platform/vivid/vivid-sdr-cap.c6
-rw-r--r--drivers/media/platform/vivid/vivid-vbi-cap.c8
-rw-r--r--drivers/media/platform/vivid/vivid-vbi-out.c2
-rw-r--r--drivers/media/platform/vivid/vivid-vid-cap.c34
-rw-r--r--drivers/media/platform/vivid/vivid-vid-out.c30
-rw-r--r--drivers/media/platform/vsp1/vsp1_video.c53
-rw-r--r--drivers/media/platform/xilinx/xilinx-dma.c14
-rw-r--r--drivers/media/platform/xilinx/xilinx-tpg.c2
-rw-r--r--drivers/media/platform/xilinx/xilinx-vipp.c4
-rw-r--r--drivers/media/radio/radio-maxiradio.c4
-rw-r--r--drivers/media/radio/radio-sf16fmr2.c4
-rw-r--r--drivers/media/radio/radio-shark.c4
-rw-r--r--drivers/media/radio/radio-shark2.c2
-rw-r--r--drivers/media/radio/radio-si476x.c2
-rw-r--r--drivers/media/radio/radio-tea5777.h2
-rw-r--r--drivers/media/radio/radio-timb.c2
-rw-r--r--drivers/media/radio/si4713/radio-usb-si4713.c2
-rw-r--r--drivers/media/radio/si4713/si4713.h2
-rw-r--r--drivers/media/radio/tea575x.c2
-rw-r--r--drivers/media/rc/Kconfig3
-rw-r--r--drivers/media/rc/gpio-ir-recv.c24
-rw-r--r--drivers/media/rc/ir-jvc-decoder.c3
-rw-r--r--drivers/media/rc/ir-lirc-codec.c1
-rw-r--r--drivers/media/rc/ir-mce_kbd-decoder.c3
-rw-r--r--drivers/media/rc/ir-nec-decoder.c3
-rw-r--r--drivers/media/rc/ir-rc5-decoder.c3
-rw-r--r--drivers/media/rc/ir-rc6-decoder.c5
-rw-r--r--drivers/media/rc/ir-rx51.c2
-rw-r--r--drivers/media/rc/ir-sanyo-decoder.c3
-rw-r--r--drivers/media/rc/ir-sharp-decoder.c7
-rw-r--r--drivers/media/rc/ir-sony-decoder.c4
-rw-r--r--drivers/media/rc/ir-xmp-decoder.c3
-rw-r--r--drivers/media/rc/nuvoton-cir.c156
-rw-r--r--drivers/media/rc/nuvoton-cir.h28
-rw-r--r--drivers/media/rc/rc-core-priv.h71
-rw-r--r--drivers/media/rc/rc-ir-raw.c41
-rw-r--r--drivers/media/rc/rc-main.c88
-rw-r--r--drivers/media/rc/st_rc.c14
-rw-r--r--drivers/media/rc/streamzap.c19
-rw-r--r--drivers/media/rc/sunxi-cir.c2
-rw-r--r--drivers/media/tuners/max2165.c2
-rw-r--r--drivers/media/tuners/mt2063.c1
-rw-r--r--drivers/media/tuners/si2157.c1
-rw-r--r--drivers/media/usb/airspy/airspy.c4
-rw-r--r--drivers/media/usb/as102/as102_fw.c1
-rw-r--r--drivers/media/usb/au0828/au0828-vbi.c14
-rw-r--r--drivers/media/usb/au0828/au0828-video.c14
-rw-r--r--drivers/media/usb/cpia2/cpia2_usb.c3
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-417.c26
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-cards.c10
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-core.c15
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-dvb.c8
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-vbi.c2
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-video.c7
-rw-r--r--drivers/media/usb/cx231xx/cx231xx.h4
-rw-r--r--drivers/media/usb/dvb-usb-v2/Kconfig2
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf-demod.h4
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf.c6
-rw-r--r--drivers/media/usb/dvb-usb-v2/rtl28xxu.c16
-rw-r--r--drivers/media/usb/dvb-usb/Kconfig2
-rw-r--r--drivers/media/usb/em28xx/em28xx-camera.c4
-rw-r--r--drivers/media/usb/em28xx/em28xx-cards.c18
-rw-r--r--drivers/media/usb/em28xx/em28xx-dvb.c15
-rw-r--r--drivers/media/usb/em28xx/em28xx-vbi.c20
-rw-r--r--drivers/media/usb/em28xx/em28xx-video.c23
-rw-r--r--drivers/media/usb/em28xx/em28xx.h2
-rw-r--r--drivers/media/usb/go7007/go7007-driver.c2
-rw-r--r--drivers/media/usb/go7007/go7007-usb.c6
-rw-r--r--drivers/media/usb/go7007/go7007-v4l2.c3
-rw-r--r--drivers/media/usb/gspca/ov534.c9
-rw-r--r--drivers/media/usb/gspca/topro.c6
-rw-r--r--drivers/media/usb/hackrf/hackrf.c6
-rw-r--r--drivers/media/usb/hdpvr/hdpvr-video.c2
-rw-r--r--drivers/media/usb/hdpvr/hdpvr.h2
-rw-r--r--drivers/media/usb/msi2500/msi2500.c1
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-audio.c2
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-cx2584x-v4l.c2
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-hdw-internal.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c2
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-v4l2.c16
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-video-v4l.c2
-rw-r--r--drivers/media/usb/pwc/pwc-if.c5
-rw-r--r--drivers/media/usb/s2255/s2255drv.c4
-rw-r--r--drivers/media/usb/stk1160/stk1160-core.c2
-rw-r--r--drivers/media/usb/stk1160/stk1160-v4l.c4
-rw-r--r--drivers/media/usb/stk1160/stk1160-video.c2
-rw-r--r--drivers/media/usb/tm6000/tm6000-cards.c2
-rw-r--r--drivers/media/usb/ttusb-dec/ttusb_dec.c2
-rw-r--r--drivers/media/usb/usbtv/usbtv-video.c11
-rw-r--r--drivers/media/usb/usbvision/usbvision-core.c2
-rw-r--r--drivers/media/usb/usbvision/usbvision-video.c25
-rw-r--r--drivers/media/usb/uvc/uvc_ctrl.c3
-rw-r--r--drivers/media/usb/uvc/uvc_driver.c3
-rw-r--r--drivers/media/usb/uvc/uvc_queue.c14
-rw-r--r--drivers/media/usb/uvc/uvc_v4l2.c20
-rw-r--r--drivers/media/usb/uvc/uvc_video.c17
-rw-r--r--drivers/media/v4l2-core/v4l2-clk.c9
-rw-r--r--drivers/media/v4l2-core/v4l2-compat-ioctl32.c6
-rw-r--r--drivers/media/v4l2-core/v4l2-ctrls.c77
-rw-r--r--drivers/media/v4l2-core/v4l2-device.c21
-rw-r--r--drivers/media/v4l2-core/v4l2-dv-timings.c16
-rw-r--r--drivers/media/v4l2-core/v4l2-ioctl.c14
-rw-r--r--drivers/media/v4l2-core/videobuf2-core.c926
-rw-r--r--drivers/media/v4l2-core/videobuf2-internal.h161
-rw-r--r--drivers/media/v4l2-core/videobuf2-v4l2.c703
-rw-r--r--drivers/mfd/timberdale.c4
-rw-r--r--drivers/staging/media/bcm2048/radio-bcm2048.c4
-rw-r--r--drivers/staging/media/davinci_vpfe/Kconfig2
-rw-r--r--drivers/staging/media/davinci_vpfe/dm365_ipipe.c5
-rw-r--r--drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c2
-rw-r--r--drivers/staging/media/davinci_vpfe/dm365_resizer.c7
-rw-r--r--drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c2
-rw-r--r--drivers/staging/media/davinci_vpfe/vpfe_video.c4
-rw-r--r--drivers/staging/media/lirc/lirc_imon.c2
-rw-r--r--drivers/staging/media/lirc/lirc_parallel.c35
-rw-r--r--drivers/staging/media/lirc/lirc_sasem.c20
-rw-r--r--drivers/staging/media/lirc/lirc_serial.c50
-rw-r--r--drivers/staging/media/omap4iss/Kconfig2
-rw-r--r--drivers/staging/media/omap4iss/iss.c4
-rw-r--r--drivers/staging/media/omap4iss/iss.h2
-rw-r--r--drivers/staging/media/omap4iss/iss_csi2.c6
-rw-r--r--drivers/staging/media/omap4iss/iss_csiphy.h2
-rw-r--r--drivers/staging/media/omap4iss/iss_resizer.c4
-rw-r--r--drivers/staging/media/omap4iss/iss_video.c3
-rw-r--r--drivers/usb/gadget/function/uvc_queue.c4
-rw-r--r--firmware/WHENCE2
-rw-r--r--include/linux/platform_data/camera-rcar.h25
-rw-r--r--include/linux/platform_data/media/camera-mx2.h (renamed from include/linux/platform_data/camera-mx2.h)0
-rw-r--r--include/linux/platform_data/media/camera-mx3.h (renamed from include/linux/platform_data/camera-mx3.h)0
-rw-r--r--include/linux/platform_data/media/camera-pxa.h (renamed from include/linux/platform_data/camera-pxa.h)0
-rw-r--r--include/linux/platform_data/media/coda.h (renamed from include/linux/platform_data/coda.h)0
-rw-r--r--include/linux/platform_data/media/gpio-ir-recv.h (renamed from include/media/gpio-ir-recv.h)1
-rw-r--r--include/linux/platform_data/media/ir-rx51.h (renamed from include/media/ir-rx51.h)0
-rw-r--r--include/linux/platform_data/media/mmp-camera.h (renamed from include/media/mmp-camera.h)0
-rw-r--r--include/linux/platform_data/media/omap1_camera.h (renamed from include/media/omap1_camera.h)0
-rw-r--r--include/linux/platform_data/media/omap4iss.h (renamed from include/media/omap4iss.h)0
-rw-r--r--include/linux/platform_data/media/s5p_hdmi.h (renamed from include/media/s5p_hdmi.h)1
-rw-r--r--include/linux/platform_data/media/si4713.h (renamed from include/media/si4713.h)2
-rw-r--r--include/linux/platform_data/media/sii9234.h (renamed from include/media/sii9234.h)0
-rw-r--r--include/linux/platform_data/media/soc_camera_platform.h (renamed from include/media/soc_camera_platform.h)0
-rw-r--r--include/linux/platform_data/media/timb_radio.h (renamed from include/media/timb_radio.h)0
-rw-r--r--include/linux/platform_data/media/timb_video.h (renamed from include/media/timb_video.h)0
-rw-r--r--include/linux/videodev2.h2
-rw-r--r--include/media/drv-intf/cx2341x.h (renamed from include/media/cx2341x.h)0
-rw-r--r--include/media/drv-intf/cx25840.h (renamed from include/media/cx25840.h)0
-rw-r--r--include/media/drv-intf/exynos-fimc.h (renamed from include/media/exynos-fimc.h)0
-rw-r--r--include/media/drv-intf/msp3400.h (renamed from include/media/msp3400.h)1
-rw-r--r--include/media/drv-intf/s3c_camif.h (renamed from include/media/s3c_camif.h)0
-rw-r--r--include/media/drv-intf/saa7146.h (renamed from include/media/saa7146.h)0
-rw-r--r--include/media/drv-intf/saa7146_vv.h (renamed from include/media/saa7146_vv.h)2
-rw-r--r--include/media/drv-intf/sh_mobile_ceu.h (renamed from include/media/sh_mobile_ceu.h)0
-rw-r--r--include/media/drv-intf/sh_mobile_csi2.h (renamed from include/media/sh_mobile_csi2.h)0
-rw-r--r--include/media/drv-intf/sh_vou.h (renamed from include/media/sh_vou.h)0
-rw-r--r--include/media/drv-intf/si476x.h (renamed from include/media/si476x.h)2
-rw-r--r--include/media/drv-intf/soc_mediabus.h (renamed from include/media/soc_mediabus.h)0
-rw-r--r--include/media/drv-intf/tea575x.h (renamed from include/media/tea575x.h)2
-rw-r--r--include/media/i2c/ad9389b.h (renamed from include/media/ad9389b.h)0
-rw-r--r--include/media/i2c/adp1653.h (renamed from include/media/adp1653.h)2
-rw-r--r--include/media/i2c/adv7183.h (renamed from include/media/adv7183.h)0
-rw-r--r--include/media/i2c/adv7343.h (renamed from include/media/adv7343.h)0
-rw-r--r--include/media/i2c/adv7393.h (renamed from include/media/adv7393.h)0
-rw-r--r--include/media/i2c/adv7511.h (renamed from include/media/adv7511.h)0
-rw-r--r--include/media/i2c/adv7604.h (renamed from include/media/adv7604.h)0
-rw-r--r--include/media/i2c/adv7842.h (renamed from include/media/adv7842.h)0
-rw-r--r--include/media/i2c/ak881x.h (renamed from include/media/ak881x.h)0
-rw-r--r--include/media/i2c/as3645a.h (renamed from include/media/as3645a.h)2
-rw-r--r--include/media/i2c/bt819.h (renamed from include/media/bt819.h)0
-rw-r--r--include/media/i2c/cs5345.h (renamed from include/media/cs5345.h)0
-rw-r--r--include/media/i2c/cs53l32a.h (renamed from include/media/cs53l32a.h)0
-rw-r--r--include/media/i2c/ir-kbd-i2c.h (renamed from include/media/ir-kbd-i2c.h)0
-rw-r--r--include/media/i2c/lm3560.h (renamed from include/media/lm3560.h)2
-rw-r--r--include/media/i2c/lm3646.h (renamed from include/media/lm3646.h)2
-rw-r--r--include/media/i2c/m52790.h (renamed from include/media/m52790.h)0
-rw-r--r--include/media/i2c/m5mols.h (renamed from include/media/m5mols.h)0
-rw-r--r--include/media/i2c/mt9m032.h (renamed from include/media/mt9m032.h)0
-rw-r--r--include/media/i2c/mt9p031.h (renamed from include/media/mt9p031.h)0
-rw-r--r--include/media/i2c/mt9t001.h (renamed from include/media/mt9t001.h)0
-rw-r--r--include/media/i2c/mt9t112.h (renamed from include/media/mt9t112.h)0
-rw-r--r--include/media/i2c/mt9v011.h (renamed from include/media/mt9v011.h)0
-rw-r--r--include/media/i2c/mt9v022.h (renamed from include/media/mt9v022.h)0
-rw-r--r--include/media/i2c/mt9v032.h (renamed from include/media/mt9v032.h)0
-rw-r--r--include/media/i2c/noon010pc30.h (renamed from include/media/noon010pc30.h)0
-rw-r--r--include/media/i2c/ov2659.h (renamed from include/media/ov2659.h)0
-rw-r--r--include/media/i2c/ov7670.h (renamed from include/media/ov7670.h)0
-rw-r--r--include/media/i2c/ov772x.h (renamed from include/media/ov772x.h)0
-rw-r--r--include/media/i2c/ov9650.h (renamed from include/media/ov9650.h)0
-rw-r--r--include/media/i2c/rj54n1cb0c.h (renamed from include/media/rj54n1cb0c.h)0
-rw-r--r--include/media/i2c/s5c73m3.h (renamed from include/media/s5c73m3.h)0
-rw-r--r--include/media/i2c/s5k4ecgx.h (renamed from include/media/s5k4ecgx.h)0
-rw-r--r--include/media/i2c/s5k6aa.h (renamed from include/media/s5k6aa.h)0
-rw-r--r--include/media/i2c/saa6588.h (renamed from include/media/saa6588.h)0
-rw-r--r--include/media/i2c/saa7115.h (renamed from include/media/saa7115.h)1
-rw-r--r--include/media/i2c/saa7127.h (renamed from include/media/saa7127.h)1
-rw-r--r--include/media/i2c/smiapp.h (renamed from include/media/smiapp.h)2
-rw-r--r--include/media/i2c/sr030pc30.h (renamed from include/media/sr030pc30.h)0
-rw-r--r--include/media/i2c/tc358743.h (renamed from include/media/tc358743.h)0
-rw-r--r--include/media/i2c/ths7303.h (renamed from include/media/ths7303.h)0
-rw-r--r--include/media/i2c/tvaudio.h (renamed from include/media/tvaudio.h)0
-rw-r--r--include/media/i2c/tvp514x.h (renamed from include/media/tvp514x.h)0
-rw-r--r--include/media/i2c/tvp5150.h (renamed from include/media/tvp5150.h)1
-rw-r--r--include/media/i2c/tvp7002.h (renamed from include/media/tvp7002.h)0
-rw-r--r--include/media/i2c/tw9910.h (renamed from include/media/tw9910.h)0
-rw-r--r--include/media/i2c/uda1342.h (renamed from include/media/uda1342.h)0
-rw-r--r--include/media/i2c/upd64031a.h (renamed from include/media/upd64031a.h)0
-rw-r--r--include/media/i2c/upd64083.h (renamed from include/media/upd64083.h)0
-rw-r--r--include/media/i2c/wm8775.h (renamed from include/media/wm8775.h)0
-rw-r--r--include/media/lirc.h169
-rw-r--r--include/media/rc-core.h1
-rw-r--r--include/media/rc-map.h40
-rw-r--r--include/media/v4l2-clk.h5
-rw-r--r--include/media/v4l2-dv-timings.h25
-rw-r--r--include/media/videobuf2-core.h108
-rw-r--r--include/media/videobuf2-v4l2.h40
-rw-r--r--include/trace/events/v4l2.h4
-rw-r--r--include/trace/events/vb2.h7
-rw-r--r--include/uapi/drm/drm_fourcc.h2
-rw-r--r--include/uapi/linux/dvb/video.h1
-rw-r--r--include/uapi/linux/lirc.h168
-rw-r--r--include/uapi/linux/usb/video.h1
-rw-r--r--include/uapi/linux/v4l2-controls.h6
-rw-r--r--include/uapi/linux/videodev2.h14
-rw-r--r--sound/pci/es1968.c4
-rw-r--r--sound/pci/fm801.c4
528 files changed, 4540 insertions, 4096 deletions
diff --git a/Documentation/DocBook/device-drivers.tmpl b/Documentation/DocBook/device-drivers.tmpl
index 42a2d8593e39..7b3fcc5effcd 100644
--- a/Documentation/DocBook/device-drivers.tmpl
+++ b/Documentation/DocBook/device-drivers.tmpl
@@ -238,78 +238,26 @@ X!Isound/sound_firmware.c
238!Iinclude/media/videobuf2-memops.h 238!Iinclude/media/videobuf2-memops.h
239 </sect1> 239 </sect1>
240 <sect1><title>Digital TV (DVB) devices</title> 240 <sect1><title>Digital TV (DVB) devices</title>
241!Idrivers/media/dvb-core/dvb_ca_en50221.h 241 <sect1><title>Digital TV Common functions</title>
242!Idrivers/media/dvb-core/dvb_frontend.h
243!Idrivers/media/dvb-core/dvb_math.h 242!Idrivers/media/dvb-core/dvb_math.h
244!Idrivers/media/dvb-core/dvb_ringbuffer.h 243!Idrivers/media/dvb-core/dvb_ringbuffer.h
245!Idrivers/media/dvb-core/dvbdev.h 244!Idrivers/media/dvb-core/dvbdev.h
246 <sect1><title>Digital TV Demux API</title> 245 </sect1>
247 <para>The kernel demux API defines a driver-internal interface for 246 <sect1><title>Digital TV Frontend kABI</title>
248 registering low-level, hardware specific driver to a hardware 247!Pdrivers/media/dvb-core/dvb_frontend.h Digital TV Frontend
249 independent demux layer. It is only of interest for Digital TV 248!Idrivers/media/dvb-core/dvb_frontend.h
250 device driver writers. The header file for this API is named 249 </sect1>
251 <constant>demux.h</constant> and located in 250 <sect1><title>Digital TV Demux kABI</title>
252 <constant>drivers/media/dvb-core</constant>.</para> 251!Pdrivers/media/dvb-core/demux.h Digital TV Demux
253 252 <sect1><title>Demux Callback API</title>
254 <para>The demux API should be implemented for each demux in the 253!Pdrivers/media/dvb-core/demux.h Demux Callback
255 system. It is used to select the TS source of a demux and to manage 254 </sect1>
256 the demux resources. When the demux client allocates a resource via
257 the demux API, it receives a pointer to the API of that
258 resource.</para>
259 <para>Each demux receives its TS input from a DVB front-end or from
260 memory, as set via this demux API. In a system with more than one
261 front-end, the API can be used to select one of the DVB front-ends
262 as a TS source for a demux, unless this is fixed in the HW platform.
263 The demux API only controls front-ends regarding to their connections
264 with demuxes; the APIs used to set the other front-end parameters,
265 such as tuning, are not defined in this document.</para>
266 <para>The functions that implement the abstract interface demux should
267 be defined static or module private and registered to the Demux
268 core for external access. It is not necessary to implement every
269 function in the struct <constant>dmx_demux</constant>. For example,
270 a demux interface might support Section filtering, but not PES
271 filtering. The API client is expected to check the value of any
272 function pointer before calling the function: the value of NULL means
273 that the &#8220;function is not available&#8221;.</para>
274 <para>Whenever the functions of the demux API modify shared data,
275 the possibilities of lost update and race condition problems should
276 be addressed, e.g. by protecting parts of code with mutexes.</para>
277 <para>Note that functions called from a bottom half context must not
278 sleep. Even a simple memory allocation without using GFP_ATOMIC can
279 result in a kernel thread being put to sleep if swapping is needed.
280 For example, the Linux kernel calls the functions of a network device
281 interface from a bottom half context. Thus, if a demux API function
282 is called from network device code, the function must not sleep.
283 </para>
284 </sect1>
285
286 <section id="demux_callback_api">
287 <title>Demux Callback API</title>
288 <para>This kernel-space API comprises the callback functions that
289 deliver filtered data to the demux client. Unlike the other DVB
290 kABIs, these functions are provided by the client and called from
291 the demux code.</para>
292 <para>The function pointers of this abstract interface are not
293 packed into a structure as in the other demux APIs, because the
294 callback functions are registered and used independent of each
295 other. As an example, it is possible for the API client to provide
296 several callback functions for receiving TS packets and no
297 callbacks for PES packets or sections.</para>
298 <para>The functions that implement the callback API need not be
299 re-entrant: when a demux driver calls one of these functions,
300 the driver is not allowed to call the function again before
301 the original call returns. If a callback is triggered by a
302 hardware interrupt, it is recommended to use the Linux
303 &#8220;bottom half&#8221; mechanism or start a tasklet instead of
304 making the callback function call directly from a hardware
305 interrupt.</para>
306 <para>This mechanism is implemented by
307 <link linkend='API-dmx-ts-cb'>dmx_ts_cb()</link> and
308 <link linkend='API-dmx-section-cb'>dmx_section_cb()</link>.</para>
309 </section>
310
311!Idrivers/media/dvb-core/demux.h 255!Idrivers/media/dvb-core/demux.h
312 </sect1> 256 </sect1>
257 <sect1><title>Digital TV Conditional Access kABI</title>
258!Idrivers/media/dvb-core/dvb_ca_en50221.h
259 </sect1>
260 </sect1>
313 <sect1><title>Remote Controller devices</title> 261 <sect1><title>Remote Controller devices</title>
314!Iinclude/media/rc-core.h 262!Iinclude/media/rc-core.h
315!Iinclude/media/lirc_dev.h 263!Iinclude/media/lirc_dev.h
diff --git a/Documentation/DocBook/media/Makefile b/Documentation/DocBook/media/Makefile
index 08527e7ea4d0..2840ff483d5a 100644
--- a/Documentation/DocBook/media/Makefile
+++ b/Documentation/DocBook/media/Makefile
@@ -199,8 +199,10 @@ DVB_DOCUMENTED = \
199# 199#
200 200
201install_media_images = \ 201install_media_images = \
202 $(Q)-mkdir $(MEDIA_OBJ_DIR)/media_api; \ 202 $(Q)if [ "x$(findstring media_api.xml,$(DOCBOOKS))" != "x" ]; then \
203 cp $(OBJIMGFILES) $(MEDIA_SRC_DIR)/*.svg $(MEDIA_SRC_DIR)/v4l/*.svg $(MEDIA_OBJ_DIR)/media_api 203 mkdir -p $(MEDIA_OBJ_DIR)/media_api; \
204 cp $(OBJIMGFILES) $(MEDIA_SRC_DIR)/*.svg $(MEDIA_SRC_DIR)/v4l/*.svg $(MEDIA_OBJ_DIR)/media_api; \
205 fi
204 206
205$(MEDIA_OBJ_DIR)/%: $(MEDIA_SRC_DIR)/%.b64 207$(MEDIA_OBJ_DIR)/%: $(MEDIA_SRC_DIR)/%.b64
206 $(Q)base64 -d $< >$@ 208 $(Q)base64 -d $< >$@
diff --git a/Documentation/DocBook/media/dvb/dvbproperty.xml b/Documentation/DocBook/media/dvb/dvbproperty.xml
index 08227d4e9150..e579ae5088ae 100644
--- a/Documentation/DocBook/media/dvb/dvbproperty.xml
+++ b/Documentation/DocBook/media/dvb/dvbproperty.xml
@@ -76,7 +76,7 @@ int main(void)
76 76
77<para>NOTE: While it is possible to directly call the Kernel code like the 77<para>NOTE: While it is possible to directly call the Kernel code like the
78 above example, it is strongly recommended to use 78 above example, it is strongly recommended to use
79 <ulink url="http://linuxtv.org/docs/libdvbv5/index.html">libdvbv5</ulink>, 79 <ulink url="https://linuxtv.org/docs/libdvbv5/index.html">libdvbv5</ulink>,
80 as it provides abstraction to work with the supported digital TV standards 80 as it provides abstraction to work with the supported digital TV standards
81 and provides methods for usual operations like program scanning and to 81 and provides methods for usual operations like program scanning and to
82 read/write channel descriptor files.</para> 82 read/write channel descriptor files.</para>
diff --git a/Documentation/DocBook/media/dvb/examples.xml b/Documentation/DocBook/media/dvb/examples.xml
index c9f68c7183cc..837fb3b64b72 100644
--- a/Documentation/DocBook/media/dvb/examples.xml
+++ b/Documentation/DocBook/media/dvb/examples.xml
@@ -3,7 +3,7 @@
3</para> 3</para>
4<para>NOTE: This section is out of date, and the code below won't even 4<para>NOTE: This section is out of date, and the code below won't even
5 compile. Please refer to the 5 compile. Please refer to the
6 <ulink url="http://linuxtv.org/docs/libdvbv5/index.html">libdvbv5</ulink> 6 <ulink url="https://linuxtv.org/docs/libdvbv5/index.html">libdvbv5</ulink>
7 for updated/recommended examples. 7 for updated/recommended examples.
8</para> 8</para>
9 9
diff --git a/Documentation/DocBook/media/dvb/intro.xml b/Documentation/DocBook/media/dvb/intro.xml
index 51db15648099..b5b701f5d8c2 100644
--- a/Documentation/DocBook/media/dvb/intro.xml
+++ b/Documentation/DocBook/media/dvb/intro.xml
@@ -32,7 +32,7 @@ and filtering several section and PES data streams at the same time.
32new standard Linux DVB API. As a commitment to the development of 32new standard Linux DVB API. As a commitment to the development of
33terminals based on open standards, Nokia and Convergence made it 33terminals based on open standards, Nokia and Convergence made it
34available to all Linux developers and published it on 34available to all Linux developers and published it on
35<ulink url="http://www.linuxtv.org/" /> in September 2000. 35<ulink url="https://linuxtv.org" /> in September 2000.
36Convergence is the maintainer of the Linux DVB API. Together with the 36Convergence is the maintainer of the Linux DVB API. Together with the
37LinuxTV community (i.e. you, the reader of this document), the Linux DVB 37LinuxTV community (i.e. you, the reader of this document), the Linux DVB
38API will be constantly reviewed and improved. With the Linux driver for 38API will be constantly reviewed and improved. With the Linux driver for
diff --git a/Documentation/DocBook/media/v4l/capture.c.xml b/Documentation/DocBook/media/v4l/capture.c.xml
index 1c5c49a2de59..22126a991b34 100644
--- a/Documentation/DocBook/media/v4l/capture.c.xml
+++ b/Documentation/DocBook/media/v4l/capture.c.xml
@@ -5,7 +5,7 @@
5 * This program can be used and distributed without restrictions. 5 * This program can be used and distributed without restrictions.
6 * 6 *
7 * This program is provided with the V4L2 API 7 * This program is provided with the V4L2 API
8 * see http://linuxtv.org/docs.php for more information 8 * see https://linuxtv.org/docs.php for more information
9 */ 9 */
10 10
11#include &lt;stdio.h&gt; 11#include &lt;stdio.h&gt;
diff --git a/Documentation/DocBook/media/v4l/compat.xml b/Documentation/DocBook/media/v4l/compat.xml
index 5701a08ed792..5399e8904715 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2666,7 +2666,7 @@ is useful to display images captured with V4L2 devices.</para>
2666 <para>V4L2 does not support digital terrestrial, cable or 2666 <para>V4L2 does not support digital terrestrial, cable or
2667satellite broadcast. A separate project aiming at digital receivers 2667satellite broadcast. A separate project aiming at digital receivers
2668exists. You can find its homepage at <ulink 2668exists. You can find its homepage at <ulink
2669url="http://linuxtv.org">http://linuxtv.org</ulink>. The Linux DVB API 2669url="https://linuxtv.org">https://linuxtv.org</ulink>. The Linux DVB API
2670has no connection to the V4L2 API except that drivers for hybrid 2670has no connection to the V4L2 API except that drivers for hybrid
2671hardware may support both.</para> 2671hardware may support both.</para>
2672 </section> 2672 </section>
diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml
index da654031ef3f..144158b3a5ac 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -699,7 +699,7 @@ linkend="v4l2-buf-type" /></entry>
699buffer. It depends on the negotiated data format and may change with 699buffer. It depends on the negotiated data format and may change with
700each buffer for compressed variable size data like JPEG images. 700each buffer for compressed variable size data like JPEG images.
701Drivers must set this field when <structfield>type</structfield> 701Drivers must set this field when <structfield>type</structfield>
702refers to an input stream, applications when it refers to an output stream. 702refers to a capture stream, applications when it refers to an output stream.
703If the application sets this to 0 for an output stream, then 703If the application sets this to 0 for an output stream, then
704<structfield>bytesused</structfield> will be set to the size of the 704<structfield>bytesused</structfield> will be set to the size of the
705buffer (see the <structfield>length</structfield> field of this struct) by 705buffer (see the <structfield>length</structfield> field of this struct) by
@@ -720,14 +720,14 @@ linkend="buffer-flags" />.</entry>
720 <entry>Indicates the field order of the image in the 720 <entry>Indicates the field order of the image in the
721buffer, see <xref linkend="v4l2-field" />. This field is not used when 721buffer, see <xref linkend="v4l2-field" />. This field is not used when
722the buffer contains VBI data. Drivers must set it when 722the buffer contains VBI data. Drivers must set it when
723<structfield>type</structfield> refers to an input stream, 723<structfield>type</structfield> refers to a capture stream,
724applications when it refers to an output stream.</entry> 724applications when it refers to an output stream.</entry>
725 </row> 725 </row>
726 <row> 726 <row>
727 <entry>struct timeval</entry> 727 <entry>struct timeval</entry>
728 <entry><structfield>timestamp</structfield></entry> 728 <entry><structfield>timestamp</structfield></entry>
729 <entry></entry> 729 <entry></entry>
730 <entry><para>For input streams this is time when the first data 730 <entry><para>For capture streams this is time when the first data
731 byte was captured, as returned by the 731 byte was captured, as returned by the
732 <function>clock_gettime()</function> function for the relevant 732 <function>clock_gettime()</function> function for the relevant
733 clock id; see <constant>V4L2_BUF_FLAG_TIMESTAMP_*</constant> in 733 clock id; see <constant>V4L2_BUF_FLAG_TIMESTAMP_*</constant> in
@@ -866,7 +866,7 @@ must set this to 0.</entry>
866 <entry></entry> 866 <entry></entry>
867 <entry>The number of bytes occupied by data in the plane 867 <entry>The number of bytes occupied by data in the plane
868 (its payload). Drivers must set this field when <structfield>type</structfield> 868 (its payload). Drivers must set this field when <structfield>type</structfield>
869 refers to an input stream, applications when it refers to an output stream. 869 refers to a capture stream, applications when it refers to an output stream.
870 If the application sets this to 0 for an output stream, then 870 If the application sets this to 0 for an output stream, then
871 <structfield>bytesused</structfield> will be set to the size of the 871 <structfield>bytesused</structfield> will be set to the size of the
872 plane (see the <structfield>length</structfield> field of this struct) 872 plane (see the <structfield>length</structfield> field of this struct)
@@ -919,7 +919,7 @@ must set this to 0.</entry>
919 <entry></entry> 919 <entry></entry>
920 <entry>Offset in bytes to video data in the plane. 920 <entry>Offset in bytes to video data in the plane.
921 Drivers must set this field when <structfield>type</structfield> 921 Drivers must set this field when <structfield>type</structfield>
922 refers to an input stream, applications when it refers to an output stream. 922 refers to a capture stream, applications when it refers to an output stream.
923 Note that data_offset is included in <structfield>bytesused</structfield>. 923 Note that data_offset is included in <structfield>bytesused</structfield>.
924 So the size of the image in the plane is 924 So the size of the image in the plane is
925 <structfield>bytesused</structfield>-<structfield>data_offset</structfield> at 925 <structfield>bytesused</structfield>-<structfield>data_offset</structfield> at
diff --git a/Documentation/DocBook/media/v4l/v4l2.xml b/Documentation/DocBook/media/v4l/v4l2.xml
index 7e61643358de..42e626d6c936 100644
--- a/Documentation/DocBook/media/v4l/v4l2.xml
+++ b/Documentation/DocBook/media/v4l/v4l2.xml
@@ -152,6 +152,16 @@ structs, ioctls) must be noted in more detail in the history chapter
152(compat.xml), along with the possible impact on existing drivers and 152(compat.xml), along with the possible impact on existing drivers and
153applications. --> 153applications. -->
154 <revision> 154 <revision>
155 <revnumber>4.5</revnumber>
156 <date>2015-10-29</date>
157 <authorinitials>rr</authorinitials>
158 <revremark>Extend vidioc-g-ext-ctrls;. Replace ctrl_class with a new
159union with ctrl_class and which. Which is used to select the current value of
160the control or the default value.
161 </revremark>
162 </revision>
163
164 <revision>
155 <revnumber>4.4</revnumber> 165 <revnumber>4.4</revnumber>
156 <date>2015-05-26</date> 166 <date>2015-05-26</date>
157 <authorinitials>ap</authorinitials> 167 <authorinitials>ap</authorinitials>
diff --git a/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml b/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml
index 8ffe74f84af1..d81fa0d4016b 100644
--- a/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml
@@ -58,7 +58,7 @@
58 <para>This ioctl is used to create buffers for <link linkend="mmap">memory 58 <para>This ioctl is used to create buffers for <link linkend="mmap">memory
59mapped</link> or <link linkend="userp">user pointer</link> or <link 59mapped</link> or <link linkend="userp">user pointer</link> or <link
60linkend="dmabuf">DMA buffer</link> I/O. It can be used as an alternative or in 60linkend="dmabuf">DMA buffer</link> I/O. It can be used as an alternative or in
61addition to the <constant>VIDIOC_REQBUFS</constant> ioctl, when a tighter 61addition to the &VIDIOC-REQBUFS; ioctl, when a tighter
62control over buffers is required. This ioctl can be called multiple times to 62control over buffers is required. This ioctl can be called multiple times to
63create buffers of different sizes.</para> 63create buffers of different sizes.</para>
64 64
@@ -71,30 +71,28 @@ zeroed.</para>
71 71
72 <para>The <structfield>format</structfield> field specifies the image format 72 <para>The <structfield>format</structfield> field specifies the image format
73that the buffers must be able to handle. The application has to fill in this 73that the buffers must be able to handle. The application has to fill in this
74&v4l2-format;. Usually this will be done using the 74&v4l2-format;. Usually this will be done using the &VIDIOC-TRY-FMT; or &VIDIOC-G-FMT; ioctls
75<constant>VIDIOC_TRY_FMT</constant> or <constant>VIDIOC_G_FMT</constant> ioctl() 75to ensure that the requested format is supported by the driver.
76to ensure that the requested format is supported by the driver. Unsupported 76Based on the format's <structfield>type</structfield> field the requested buffer
77formats will result in an error.</para> 77size (for single-planar) or plane sizes (for multi-planar formats) will be
78used for the allocated buffers. The driver may return an error if the size(s)
79are not supported by the hardware (usually because they are too small).</para>
78 80
79 <para>The buffers created by this ioctl will have as minimum size the size 81 <para>The buffers created by this ioctl will have as minimum size the size
80defined by the <structfield>format.pix.sizeimage</structfield> field. If the 82defined by the <structfield>format.pix.sizeimage</structfield> field (or the
83corresponding fields for other format types). Usually if the
81<structfield>format.pix.sizeimage</structfield> field is less than the minimum 84<structfield>format.pix.sizeimage</structfield> field is less than the minimum
82required for the given format, then <structfield>sizeimage</structfield> will be 85required for the given format, then an error will be returned since drivers will
83increased by the driver to that minimum to allocate the buffers. If it is 86typically not allow this. If it is larger, then the value will be used as-is.
84larger, then the value will be used as-is. The same applies to the 87In other words, the driver may reject the requested size, but if it is accepted
85<structfield>sizeimage</structfield> field of the 88the driver will use it unchanged.</para>
86<structname>v4l2_plane_pix_format</structname> structure in the case of
87multiplanar formats.</para>
88 89
89 <para>When the ioctl is called with a pointer to this structure the driver 90 <para>When the ioctl is called with a pointer to this structure the driver
90will attempt to allocate up to the requested number of buffers and store the 91will attempt to allocate up to the requested number of buffers and store the
91actual number allocated and the starting index in the 92actual number allocated and the starting index in the
92<structfield>count</structfield> and the <structfield>index</structfield> fields 93<structfield>count</structfield> and the <structfield>index</structfield> fields
93respectively. On return <structfield>count</structfield> can be smaller than 94respectively. On return <structfield>count</structfield> can be smaller than
94the number requested. The driver may also increase buffer sizes if required, 95the number requested.</para>
95however, it will not update <structfield>sizeimage</structfield> field values.
96The user has to use <constant>VIDIOC_QUERYBUF</constant> to retrieve that
97information.</para>
98 96
99 <table pgwide="1" frame="none" id="v4l2-create-buffers"> 97 <table pgwide="1" frame="none" id="v4l2-create-buffers">
100 <title>struct <structname>v4l2_create_buffers</structname></title> 98 <title>struct <structname>v4l2_create_buffers</structname></title>
diff --git a/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-info.xml b/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-info.xml
index 4c4603c135fe..f14a3bb1afaa 100644
--- a/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-info.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-info.xml
@@ -99,7 +99,7 @@ if the driver supports writing registers to the device.</para>
99 <para>We recommended the <application>v4l2-dbg</application> 99 <para>We recommended the <application>v4l2-dbg</application>
100utility over calling this ioctl directly. It is available from the 100utility over calling this ioctl directly. It is available from the
101LinuxTV v4l-dvb repository; see <ulink 101LinuxTV v4l-dvb repository; see <ulink
102url="http://linuxtv.org/repo/">http://linuxtv.org/repo/</ulink> for 102url="https://linuxtv.org/repo/">https://linuxtv.org/repo/</ulink> for
103access instructions.</para> 103access instructions.</para>
104 104
105 <!-- Note for convenience vidioc-dbg-g-register.sgml 105 <!-- Note for convenience vidioc-dbg-g-register.sgml
diff --git a/Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml b/Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml
index 3d038e75d12b..5877f68a5820 100644
--- a/Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml
@@ -117,7 +117,7 @@ However when a driver supports these ioctls it must also support
117 <para>We recommended the <application>v4l2-dbg</application> 117 <para>We recommended the <application>v4l2-dbg</application>
118utility over calling these ioctls directly. It is available from the 118utility over calling these ioctls directly. It is available from the
119LinuxTV v4l-dvb repository; see <ulink 119LinuxTV v4l-dvb repository; see <ulink
120url="http://linuxtv.org/repo/">http://linuxtv.org/repo/</ulink> for 120url="https://linuxtv.org/repo/">https://linuxtv.org/repo/</ulink> for
121access instructions.</para> 121access instructions.</para>
122 122
123 <!-- Note for convenience vidioc-dbg-g-chip-info.sgml 123 <!-- Note for convenience vidioc-dbg-g-chip-info.sgml
diff --git a/Documentation/DocBook/media/v4l/vidioc-enumstd.xml b/Documentation/DocBook/media/v4l/vidioc-enumstd.xml
index 8065099401d1..f18454e91752 100644
--- a/Documentation/DocBook/media/v4l/vidioc-enumstd.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-enumstd.xml
@@ -198,7 +198,7 @@ video4linux-list@redhat.com on 17 Oct 2002
198<constant>V4L2_STD_ATSC_16_VSB</constant> are U.S. terrestrial digital 198<constant>V4L2_STD_ATSC_16_VSB</constant> are U.S. terrestrial digital
199TV standards. Presently the V4L2 API does not support digital TV. See 199TV standards. Presently the V4L2 API does not support digital TV. See
200also the Linux DVB API at <ulink 200also the Linux DVB API at <ulink
201url="http://linuxtv.org">http://linuxtv.org</ulink>.</para> 201url="https://linuxtv.org">https://linuxtv.org</ulink>.</para>
202<para><programlisting> 202<para><programlisting>
203#define V4L2_STD_PAL_BG (V4L2_STD_PAL_B |\ 203#define V4L2_STD_PAL_BG (V4L2_STD_PAL_B |\
204 V4L2_STD_PAL_B1 |\ 204 V4L2_STD_PAL_B1 |\
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml b/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml
index 842536aae8b4..eb82f7e7d06b 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml
@@ -61,7 +61,7 @@ must belong to the same control class.</para>
61 61
62 <para>Applications must always fill in the 62 <para>Applications must always fill in the
63<structfield>count</structfield>, 63<structfield>count</structfield>,
64<structfield>ctrl_class</structfield>, 64<structfield>which</structfield>,
65<structfield>controls</structfield> and 65<structfield>controls</structfield> and
66<structfield>reserved</structfield> fields of &v4l2-ext-controls;, and 66<structfield>reserved</structfield> fields of &v4l2-ext-controls;, and
67initialize the &v4l2-ext-control; array pointed to by the 67initialize the &v4l2-ext-control; array pointed to by the
@@ -109,7 +109,7 @@ the driver whether wrong values are automatically adjusted to a valid
109value or if an error is returned.</para> 109value or if an error is returned.</para>
110 110
111 <para>When the <structfield>id</structfield> or 111 <para>When the <structfield>id</structfield> or
112<structfield>ctrl_class</structfield> is invalid drivers return an 112<structfield>which</structfield> is invalid drivers return an
113&EINVAL;. When the value is out of bounds drivers can choose to take 113&EINVAL;. When the value is out of bounds drivers can choose to take
114the closest valid value or return an &ERANGE;, whatever seems more 114the closest valid value or return an &ERANGE;, whatever seems more
115appropriate. In the first case the new value is set in 115appropriate. In the first case the new value is set in
@@ -223,7 +223,12 @@ Valid if <constant>V4L2_CTRL_FLAG_HAS_PAYLOAD</constant> is set for this control
223 <tgroup cols="3"> 223 <tgroup cols="3">
224 &cs-str; 224 &cs-str;
225 <tbody valign="top"> 225 <tbody valign="top">
226 <row>
227 <entry>union</entry>
228 <entry>(anonymous)</entry>
229 </row>
226 <row> 230 <row>
231 <entry></entry>
227 <entry>__u32</entry> 232 <entry>__u32</entry>
228 <entry><structfield>ctrl_class</structfield></entry> 233 <entry><structfield>ctrl_class</structfield></entry>
229 <entry>The control class to which all controls belong, see 234 <entry>The control class to which all controls belong, see
@@ -235,6 +240,23 @@ with a <structfield>count</structfield> of 0. If that succeeds, then the driver
235supports this feature.</entry> 240supports this feature.</entry>
236 </row> 241 </row>
237 <row> 242 <row>
243 <entry></entry>
244 <entry>__u32</entry>
245 <entry><structfield>which</structfield></entry>
246 <entry><para>Which value of the control to get/set/try. <constant>V4L2_CTRL_WHICH_CUR_VAL</constant>
247will return the current value of the control and <constant>V4L2_CTRL_WHICH_DEF_VAL</constant> will
248return the default value of the control. Please note that you can only get the default value of the
249control, you cannot set or try it.</para>
250<para>For backwards compatibility you can also use a control class here (see
251<xref linkend="ctrl-class" />). In that case all controls have to belong to that
252control class. This usage is deprecated, instead just use <constant>V4L2_CTRL_WHICH_CUR_VAL</constant>.
253There are some very old drivers that do not yet support <constant>V4L2_CTRL_WHICH_CUR_VAL</constant>
254and that require a control class here. You can test for such drivers by setting ctrl_class to
255<constant>V4L2_CTRL_WHICH_CUR_VAL</constant> and calling VIDIOC_TRY_EXT_CTRLS with a count of 0.
256If that fails, then the driver does not support <constant>V4L2_CTRL_WHICH_CUR_VAL</constant>.</para>
257</entry>
258 </row>
259 <row>
238 <entry>__u32</entry> 260 <entry>__u32</entry>
239 <entry><structfield>count</structfield></entry> 261 <entry><structfield>count</structfield></entry>
240 <entry>The number of controls in the controls array. May 262 <entry>The number of controls in the controls array. May
@@ -390,7 +412,7 @@ These controls are described in <xref linkend="rf-tuner-controls" />.</entry>
390 <listitem> 412 <listitem>
391 <para>The &v4l2-ext-control; <structfield>id</structfield> 413 <para>The &v4l2-ext-control; <structfield>id</structfield>
392is invalid, the &v4l2-ext-controls; 414is invalid, the &v4l2-ext-controls;
393<structfield>ctrl_class</structfield> is invalid, or the &v4l2-ext-control; 415<structfield>which</structfield> is invalid, or the &v4l2-ext-control;
394<structfield>value</structfield> was inappropriate (e.g. the given menu 416<structfield>value</structfield> was inappropriate (e.g. the given menu
395index is not supported by the driver). This error code is 417index is not supported by the driver). This error code is
396also returned by the <constant>VIDIOC_S_EXT_CTRLS</constant> and 418also returned by the <constant>VIDIOC_S_EXT_CTRLS</constant> and
diff --git a/Documentation/DocBook/media_api.tmpl b/Documentation/DocBook/media_api.tmpl
index 92037033f5eb..7b77e0f7b87d 100644
--- a/Documentation/DocBook/media_api.tmpl
+++ b/Documentation/DocBook/media_api.tmpl
@@ -19,10 +19,10 @@
19<!ENTITY cs-def "<colspec colname='c1' colwidth='3*' /><colspec colname='c2' colwidth='1*' /><colspec colname='c3' colwidth='4*' /><spanspec spanname='hspan' namest='c1' nameend='c3' />"> 19<!ENTITY cs-def "<colspec colname='c1' colwidth='3*' /><colspec colname='c2' colwidth='1*' /><colspec colname='c3' colwidth='4*' /><spanspec spanname='hspan' namest='c1' nameend='c3' />">
20 20
21<!-- Video for Linux mailing list address. --> 21<!-- Video for Linux mailing list address. -->
22<!ENTITY v4l-ml "<ulink url='http://www.linuxtv.org/lists.php'>http://www.linuxtv.org/lists.php</ulink>"> 22<!ENTITY v4l-ml "<ulink url='https://linuxtv.org/lists.php'>https://linuxtv.org/lists.php</ulink>">
23 23
24<!-- LinuxTV v4l-dvb repository. --> 24<!-- LinuxTV v4l-dvb repository. -->
25<!ENTITY v4l-dvb "<ulink url='http://linuxtv.org/repo/'>http://linuxtv.org/repo/</ulink>"> 25<!ENTITY v4l-dvb "<ulink url='https://linuxtv.org/repo/'>https://linuxtv.org/repo/</ulink>">
26<!ENTITY dash-ent-8 "<entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry>"> 26<!ENTITY dash-ent-8 "<entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry>">
27<!ENTITY dash-ent-10 "<entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry>"> 27<!ENTITY dash-ent-10 "<entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry>">
28<!ENTITY dash-ent-12 "<entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry>"> 28<!ENTITY dash-ent-12 "<entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry><entry>-</entry>">
@@ -91,7 +91,7 @@
91 components, like mixers, PCM capture, PCM playback, etc, which 91 components, like mixers, PCM capture, PCM playback, etc, which
92 are controlled via ALSA API.</para> 92 are controlled via ALSA API.</para>
93 <para>For additional information and for the latest development code, 93 <para>For additional information and for the latest development code,
94 see: <ulink url="http://linuxtv.org">http://linuxtv.org</ulink>.</para> 94 see: <ulink url="https://linuxtv.org">https://linuxtv.org</ulink>.</para>
95 <para>For discussing improvements, reporting troubles, sending new drivers, etc, please mail to: <ulink url="http://vger.kernel.org/vger-lists.html#linux-media">Linux Media Mailing List (LMML).</ulink>.</para> 95 <para>For discussing improvements, reporting troubles, sending new drivers, etc, please mail to: <ulink url="http://vger.kernel.org/vger-lists.html#linux-media">Linux Media Mailing List (LMML).</ulink>.</para>
96</preface> 96</preface>
97 97
diff --git a/Documentation/devicetree/bindings/media/stih407-c8sectpfe.txt b/Documentation/devicetree/bindings/media/stih407-c8sectpfe.txt
index d4def767bdfe..cc51b1fd6e0c 100644
--- a/Documentation/devicetree/bindings/media/stih407-c8sectpfe.txt
+++ b/Documentation/devicetree/bindings/media/stih407-c8sectpfe.txt
@@ -35,7 +35,7 @@ Required properties (tsin (child) node):
35 35
36- tsin-num : tsin id of the InputBlock (must be between 0 to 6) 36- tsin-num : tsin id of the InputBlock (must be between 0 to 6)
37- i2c-bus : phandle to the I2C bus DT node which the demodulators & tuners on this tsin channel are connected. 37- i2c-bus : phandle to the I2C bus DT node which the demodulators & tuners on this tsin channel are connected.
38- rst-gpio : reset gpio for this tsin channel. 38- reset-gpios : reset gpio for this tsin channel.
39 39
40Optional properties (tsin (child) node): 40Optional properties (tsin (child) node):
41 41
@@ -55,27 +55,27 @@ Example:
55 status = "okay"; 55 status = "okay";
56 reg = <0x08a20000 0x10000>, <0x08a00000 0x4000>; 56 reg = <0x08a20000 0x10000>, <0x08a00000 0x4000>;
57 reg-names = "stfe", "stfe-ram"; 57 reg-names = "stfe", "stfe-ram";
58 interrupts = <0 34 0>, <0 35 0>; 58 interrupts = <GIC_SPI 34 IRQ_TYPE_NONE>, <GIC_SPI 35 IRQ_TYPE_NONE>;
59 interrupt-names = "stfe-error-irq", "stfe-idle-irq"; 59 interrupt-names = "stfe-error-irq", "stfe-idle-irq";
60
61 pinctrl-names = "tsin0-serial", "tsin0-parallel", "tsin3-serial",
62 "tsin4-serial", "tsin5-serial";
63
64 pinctrl-0 = <&pinctrl_tsin0_serial>; 60 pinctrl-0 = <&pinctrl_tsin0_serial>;
65 pinctrl-1 = <&pinctrl_tsin0_parallel>; 61 pinctrl-1 = <&pinctrl_tsin0_parallel>;
66 pinctrl-2 = <&pinctrl_tsin3_serial>; 62 pinctrl-2 = <&pinctrl_tsin3_serial>;
67 pinctrl-3 = <&pinctrl_tsin4_serial_alt3>; 63 pinctrl-3 = <&pinctrl_tsin4_serial_alt3>;
68 pinctrl-4 = <&pinctrl_tsin5_serial_alt1>; 64 pinctrl-4 = <&pinctrl_tsin5_serial_alt1>;
69 65 pinctrl-names = "tsin0-serial",
66 "tsin0-parallel",
67 "tsin3-serial",
68 "tsin4-serial",
69 "tsin5-serial";
70 clocks = <&clk_s_c0_flexgen CLK_PROC_STFE>; 70 clocks = <&clk_s_c0_flexgen CLK_PROC_STFE>;
71 clock-names = "stfe"; 71 clock-names = "c8sectpfe";
72 72
73 /* tsin0 is TSA on NIMA */ 73 /* tsin0 is TSA on NIMA */
74 tsin0: port@0 { 74 tsin0: port@0 {
75 tsin-num = <0>; 75 tsin-num = <0>;
76 serial-not-parallel; 76 serial-not-parallel;
77 i2c-bus = <&ssc2>; 77 i2c-bus = <&ssc2>;
78 rst-gpio = <&pio15 4 0>; 78 reset-gpios = <&pio15 4 GPIO_ACTIVE_HIGH>;
79 dvb-card = <STV0367_TDA18212_NIMA_1>; 79 dvb-card = <STV0367_TDA18212_NIMA_1>;
80 }; 80 };
81 81
@@ -83,7 +83,7 @@ Example:
83 tsin-num = <3>; 83 tsin-num = <3>;
84 serial-not-parallel; 84 serial-not-parallel;
85 i2c-bus = <&ssc3>; 85 i2c-bus = <&ssc3>;
86 rst-gpio = <&pio15 7 0>; 86 reset-gpios = <&pio15 7 GPIO_ACTIVE_HIGH>;
87 dvb-card = <STV0367_TDA18212_NIMB_1>; 87 dvb-card = <STV0367_TDA18212_NIMB_1>;
88 }; 88 };
89 }; 89 };
diff --git a/Documentation/dvb/README.dvb-usb b/Documentation/dvb/README.dvb-usb
index 8eb92264ee04..669dc6ce4330 100644
--- a/Documentation/dvb/README.dvb-usb
+++ b/Documentation/dvb/README.dvb-usb
@@ -45,7 +45,7 @@ Supported devices
45See the LinuxTV DVB Wiki at www.linuxtv.org for a complete list of 45See the LinuxTV DVB Wiki at www.linuxtv.org for a complete list of
46cards/drivers/firmwares: 46cards/drivers/firmwares:
47 47
48http://www.linuxtv.org/wiki/index.php/DVB_USB 48https://linuxtv.org/wiki/index.php/DVB_USB
49 49
500. History & News: 500. History & News:
51 2005-06-30 - added support for WideView WT-220U (Thanks to Steve Chang) 51 2005-06-30 - added support for WideView WT-220U (Thanks to Steve Chang)
@@ -121,7 +121,7 @@ working.
121Have a look at the Wikipage for the DVB-USB-drivers to find out, which firmware 121Have a look at the Wikipage for the DVB-USB-drivers to find out, which firmware
122you need for your device: 122you need for your device:
123 123
124http://www.linuxtv.org/wiki/index.php/DVB_USB 124https://linuxtv.org/wiki/index.php/DVB_USB
125 125
1261.2. Compiling 1261.2. Compiling
127 127
diff --git a/Documentation/dvb/faq.txt b/Documentation/dvb/faq.txt
index 97b1373f2428..a0be92012877 100644
--- a/Documentation/dvb/faq.txt
+++ b/Documentation/dvb/faq.txt
@@ -76,7 +76,7 @@ Some very frequently asked questions about linuxtv-dvb
76 the TuxBox CVS many interesting DVB applications and the dBox2 76 the TuxBox CVS many interesting DVB applications and the dBox2
77 DVB source 77 DVB source
78 78
79 http://www.linuxtv.org/downloads/ 79 https://linuxtv.org/downloads
80 DVB Swiss Army Knife library and utilities 80 DVB Swiss Army Knife library and utilities
81 81
82 http://www.nenie.org/misc/mpsys/ 82 http://www.nenie.org/misc/mpsys/
diff --git a/Documentation/dvb/get_dvb_firmware b/Documentation/dvb/get_dvb_firmware
index 91b43d2738c7..1a0a04125f71 100755
--- a/Documentation/dvb/get_dvb_firmware
+++ b/Documentation/dvb/get_dvb_firmware
@@ -152,7 +152,7 @@ sub tda10046lifeview {
152 152
153sub av7110 { 153sub av7110 {
154 my $sourcefile = "dvb-ttpci-01.fw-261d"; 154 my $sourcefile = "dvb-ttpci-01.fw-261d";
155 my $url = "http://www.linuxtv.org/downloads/firmware/$sourcefile"; 155 my $url = "https://linuxtv.org/downloads/firmware/$sourcefile";
156 my $hash = "603431b6259715a8e88f376a53b64e2f"; 156 my $hash = "603431b6259715a8e88f376a53b64e2f";
157 my $outfile = "dvb-ttpci-01.fw"; 157 my $outfile = "dvb-ttpci-01.fw";
158 158
@@ -303,7 +303,7 @@ sub vp7049 {
303} 303}
304 304
305sub dibusb { 305sub dibusb {
306 my $url = "http://www.linuxtv.org/downloads/firmware/dvb-usb-dibusb-5.0.0.11.fw"; 306 my $url = "https://linuxtv.org/downloads/firmware/dvb-usb-dibusb-5.0.0.11.fw";
307 my $outfile = "dvb-dibusb-5.0.0.11.fw"; 307 my $outfile = "dvb-dibusb-5.0.0.11.fw";
308 my $hash = "fa490295a527360ca16dcdf3224ca243"; 308 my $hash = "fa490295a527360ca16dcdf3224ca243";
309 309
@@ -351,7 +351,7 @@ sub nxt2004 {
351 351
352sub or51211 { 352sub or51211 {
353 my $fwfile = "dvb-fe-or51211.fw"; 353 my $fwfile = "dvb-fe-or51211.fw";
354 my $url = "http://linuxtv.org/downloads/firmware/$fwfile"; 354 my $url = "https://linuxtv.org/downloads/firmware/$fwfile";
355 my $hash = "d830949c771a289505bf9eafc225d491"; 355 my $hash = "d830949c771a289505bf9eafc225d491";
356 356
357 checkstandard(); 357 checkstandard();
@@ -364,7 +364,7 @@ sub or51211 {
364 364
365sub cx231xx { 365sub cx231xx {
366 my $fwfile = "v4l-cx231xx-avcore-01.fw"; 366 my $fwfile = "v4l-cx231xx-avcore-01.fw";
367 my $url = "http://linuxtv.org/downloads/firmware/$fwfile"; 367 my $url = "https://linuxtv.org/downloads/firmware/$fwfile";
368 my $hash = "7d3bb956dc9df0eafded2b56ba57cc42"; 368 my $hash = "7d3bb956dc9df0eafded2b56ba57cc42";
369 369
370 checkstandard(); 370 checkstandard();
@@ -376,7 +376,7 @@ sub cx231xx {
376} 376}
377 377
378sub cx18 { 378sub cx18 {
379 my $url = "http://linuxtv.org/downloads/firmware/"; 379 my $url = "https://linuxtv.org/downloads/firmware/";
380 380
381 my %files = ( 381 my %files = (
382 'v4l-cx23418-apu.fw' => '588f081b562f5c653a3db1ad8f65939a', 382 'v4l-cx23418-apu.fw' => '588f081b562f5c653a3db1ad8f65939a',
@@ -450,7 +450,7 @@ sub mpc718 {
450} 450}
451 451
452sub cx23885 { 452sub cx23885 {
453 my $url = "http://linuxtv.org/downloads/firmware/"; 453 my $url = "https://linuxtv.org/downloads/firmware/";
454 454
455 my %files = ( 455 my %files = (
456 'v4l-cx23885-avcore-01.fw' => 'a9f8f5d901a7fb42f552e1ee6384f3bb', 456 'v4l-cx23885-avcore-01.fw' => 'a9f8f5d901a7fb42f552e1ee6384f3bb',
@@ -472,7 +472,7 @@ sub cx23885 {
472} 472}
473 473
474sub pvrusb2 { 474sub pvrusb2 {
475 my $url = "http://linuxtv.org/downloads/firmware/"; 475 my $url = "https://linuxtv.org/downloads/firmware/";
476 476
477 my %files = ( 477 my %files = (
478 'v4l-cx25840.fw' => 'dadb79e9904fc8af96e8111d9cb59320', 478 'v4l-cx25840.fw' => 'dadb79e9904fc8af96e8111d9cb59320',
@@ -494,7 +494,7 @@ sub pvrusb2 {
494 494
495sub or51132_qam { 495sub or51132_qam {
496 my $fwfile = "dvb-fe-or51132-qam.fw"; 496 my $fwfile = "dvb-fe-or51132-qam.fw";
497 my $url = "http://linuxtv.org/downloads/firmware/$fwfile"; 497 my $url = "https://linuxtv.org/downloads/firmware/$fwfile";
498 my $hash = "7702e8938612de46ccadfe9b413cb3b5"; 498 my $hash = "7702e8938612de46ccadfe9b413cb3b5";
499 499
500 checkstandard(); 500 checkstandard();
@@ -507,7 +507,7 @@ sub or51132_qam {
507 507
508sub or51132_vsb { 508sub or51132_vsb {
509 my $fwfile = "dvb-fe-or51132-vsb.fw"; 509 my $fwfile = "dvb-fe-or51132-vsb.fw";
510 my $url = "http://linuxtv.org/downloads/firmware/$fwfile"; 510 my $url = "https://linuxtv.org/downloads/firmware/$fwfile";
511 my $hash = "c16208e02f36fc439a557ad4c613364a"; 511 my $hash = "c16208e02f36fc439a557ad4c613364a";
512 512
513 checkstandard(); 513 checkstandard();
@@ -519,7 +519,7 @@ sub or51132_vsb {
519} 519}
520 520
521sub bluebird { 521sub bluebird {
522 my $url = "http://www.linuxtv.org/download/dvb/firmware/dvb-usb-bluebird-01.fw"; 522 my $url = "https://linuxtv.org/download/dvb/firmware/dvb-usb-bluebird-01.fw";
523 my $outfile = "dvb-usb-bluebird-01.fw"; 523 my $outfile = "dvb-usb-bluebird-01.fw";
524 my $hash = "658397cb9eba9101af9031302671f49d"; 524 my $hash = "658397cb9eba9101af9031302671f49d";
525 525
@@ -677,7 +677,7 @@ sub drxk_hauppauge_hvr930c {
677} 677}
678 678
679sub drxk_terratec_h5 { 679sub drxk_terratec_h5 {
680 my $url = "http://www.linuxtv.org/downloads/firmware/"; 680 my $url = "https://linuxtv.org/downloads/firmware/";
681 my $hash = "19000dada8e2741162ccc50cc91fa7f1"; 681 my $hash = "19000dada8e2741162ccc50cc91fa7f1";
682 my $fwfile = "dvb-usb-terratec-h5-drxk.fw"; 682 my $fwfile = "dvb-usb-terratec-h5-drxk.fw";
683 683
diff --git a/Documentation/dvb/readme.txt b/Documentation/dvb/readme.txt
index 0b0380c91990..89965041a266 100644
--- a/Documentation/dvb/readme.txt
+++ b/Documentation/dvb/readme.txt
@@ -2,12 +2,12 @@ Linux Digital Video Broadcast (DVB) subsystem
2============================================= 2=============================================
3 3
4The main development site and CVS repository for these 4The main development site and CVS repository for these
5drivers is http://linuxtv.org/. 5drivers is https://linuxtv.org.
6 6
7The developer mailing list linux-dvb is also hosted there, 7The developer mailing list linux-dvb is also hosted there,
8see http://linuxtv.org/lists.php. Please check 8see https://linuxtv.org/lists.php. Please check
9the archive http://linuxtv.org/pipermail/linux-dvb/ 9the archive https://linuxtv.org/pipermail/linux-dvb/
10and the Wiki http://linuxtv.org/wiki/ 10and the Wiki https://linuxtv.org/wiki/
11before asking newbie questions on the list. 11before asking newbie questions on the list.
12 12
13API documentation, utilities and test/example programs 13API documentation, utilities and test/example programs
@@ -16,7 +16,7 @@ are available as part of the old driver package for Linux 2.4
16We plan to split this into separate packages, but it's not 16We plan to split this into separate packages, but it's not
17been done yet. 17been done yet.
18 18
19http://linuxtv.org/downloads/ 19https://linuxtv.org/downloads/
20 20
21What's inside this directory: 21What's inside this directory:
22 22
diff --git a/Documentation/video4linux/API.html b/Documentation/video4linux/API.html
index 256f8efa992c..eaf948cf1ae7 100644
--- a/Documentation/video4linux/API.html
+++ b/Documentation/video4linux/API.html
@@ -9,7 +9,7 @@
9 <table border="0"> 9 <table border="0">
10 <tr> 10 <tr>
11 <td> 11 <td>
12 <a href="http://linuxtv.org/downloads/legacy/video4linux/API/V4L1_API.html">V4L original API</a> 12 <a href="https://linuxtv.org/downloads/legacy/video4linux/API/V4L1_API.html">V4L original API</a>
13 </td> 13 </td>
14 <td> 14 <td>
15 Obsoleted by V4L2 API 15 Obsoleted by V4L2 API
diff --git a/Documentation/video4linux/CARDLIST.em28xx b/Documentation/video4linux/CARDLIST.em28xx
index 9e57ce43c4f4..67209998a439 100644
--- a/Documentation/video4linux/CARDLIST.em28xx
+++ b/Documentation/video4linux/CARDLIST.em28xx
@@ -41,8 +41,8 @@
41 40 -> Plextor ConvertX PX-TV100U (em2861) [093b:a005] 41 40 -> Plextor ConvertX PX-TV100U (em2861) [093b:a005]
42 41 -> Kworld 350 U DVB-T (em2870) [eb1a:e350] 42 41 -> Kworld 350 U DVB-T (em2870) [eb1a:e350]
43 42 -> Kworld 355 U DVB-T (em2870) [eb1a:e355,eb1a:e357,eb1a:e359] 43 42 -> Kworld 355 U DVB-T (em2870) [eb1a:e355,eb1a:e357,eb1a:e359]
44 43 -> Terratec Cinergy T XS (em2870) [0ccd:0043] 44 43 -> Terratec Cinergy T XS (em2870)
45 44 -> Terratec Cinergy T XS (MT2060) (em2870) 45 44 -> Terratec Cinergy T XS (MT2060) (em2870) [0ccd:0043]
46 45 -> Pinnacle PCTV DVB-T (em2870) 46 45 -> Pinnacle PCTV DVB-T (em2870)
47 46 -> Compro, VideoMate U3 (em2870) [185b:2870] 47 46 -> Compro, VideoMate U3 (em2870) [185b:2870]
48 47 -> KWorld DVB-T 305U (em2880) [eb1a:e305] 48 47 -> KWorld DVB-T 305U (em2880) [eb1a:e305]
diff --git a/Documentation/video4linux/fimc.txt b/Documentation/video4linux/fimc.txt
index e0c6b8bc4743..4fab231be52e 100644
--- a/Documentation/video4linux/fimc.txt
+++ b/Documentation/video4linux/fimc.txt
@@ -58,7 +58,7 @@ Not currently supported:
584.1. Media device interface 584.1. Media device interface
59 59
60The driver supports Media Controller API as defined at 60The driver supports Media Controller API as defined at
61http://linuxtv.org/downloads/v4l-dvb-apis/media_common.html 61https://linuxtv.org/downloads/v4l-dvb-apis/media_common.html
62The media device driver name is "SAMSUNG S5P FIMC". 62The media device driver name is "SAMSUNG S5P FIMC".
63 63
64The purpose of this interface is to allow changing assignment of FIMC instances 64The purpose of this interface is to allow changing assignment of FIMC instances
@@ -83,11 +83,11 @@ undefined behaviour.
834.3. Capture video node 834.3. Capture video node
84 84
85The driver supports V4L2 Video Capture Interface as defined at: 85The driver supports V4L2 Video Capture Interface as defined at:
86http://linuxtv.org/downloads/v4l-dvb-apis/devices.html 86https://linuxtv.org/downloads/v4l-dvb-apis/devices.html
87 87
88At the capture and mem-to-mem video nodes only the multi-planar API is 88At the capture and mem-to-mem video nodes only the multi-planar API is
89supported. For more details see: 89supported. For more details see:
90http://linuxtv.org/downloads/v4l-dvb-apis/planar-apis.html 90https://linuxtv.org/downloads/v4l-dvb-apis/planar-apis.html
91 91
924.4. Camera capture subdevs 924.4. Camera capture subdevs
93 93
diff --git a/Documentation/video4linux/omap4_camera.txt b/Documentation/video4linux/omap4_camera.txt
index 25d9b40a4651..a6734aa77242 100644
--- a/Documentation/video4linux/omap4_camera.txt
+++ b/Documentation/video4linux/omap4_camera.txt
@@ -47,7 +47,7 @@ Tested platforms
47File list 47File list
48--------- 48---------
49drivers/staging/media/omap4iss/ 49drivers/staging/media/omap4iss/
50include/media/omap4iss.h 50include/linux/platform_data/media/omap4iss.h
51 51
52References 52References
53---------- 53----------
diff --git a/Documentation/video4linux/si4713.txt b/Documentation/video4linux/si4713.txt
index 2e7392a4fee1..2ddc6b095a76 100644
--- a/Documentation/video4linux/si4713.txt
+++ b/Documentation/video4linux/si4713.txt
@@ -157,7 +157,7 @@ int main (int argc, char *argv[])
157} 157}
158 158
159The struct si4713_rnl and SI4713_IOC_MEASURE_RNL are defined under 159The struct si4713_rnl and SI4713_IOC_MEASURE_RNL are defined under
160include/media/si4713.h. 160include/linux/platform_data/media/si4713.h.
161 161
162Stereo/Mono and RDS subchannels 162Stereo/Mono and RDS subchannels
163=============================== 163===============================
diff --git a/Documentation/video4linux/v4l2-pci-skeleton.c b/Documentation/video4linux/v4l2-pci-skeleton.c
index 95ae82860092..79af0c041056 100644
--- a/Documentation/video4linux/v4l2-pci-skeleton.c
+++ b/Documentation/video4linux/v4l2-pci-skeleton.c
@@ -163,11 +163,10 @@ static irqreturn_t skeleton_irq(int irq, void *dev_id)
163 * minimum number: many DMA engines need a minimum of 2 buffers in the 163 * minimum number: many DMA engines need a minimum of 2 buffers in the
164 * queue and you need to have another available for userspace processing. 164 * queue and you need to have another available for userspace processing.
165 */ 165 */
166static int queue_setup(struct vb2_queue *vq, const void *parg, 166static int queue_setup(struct vb2_queue *vq,
167 unsigned int *nbuffers, unsigned int *nplanes, 167 unsigned int *nbuffers, unsigned int *nplanes,
168 unsigned int sizes[], void *alloc_ctxs[]) 168 unsigned int sizes[], void *alloc_ctxs[])
169{ 169{
170 const struct v4l2_format *fmt = parg;
171 struct skeleton *skel = vb2_get_drv_priv(vq); 170 struct skeleton *skel = vb2_get_drv_priv(vq);
172 171
173 skel->field = skel->format.field; 172 skel->field = skel->format.field;
@@ -183,12 +182,12 @@ static int queue_setup(struct vb2_queue *vq, const void *parg,
183 182
184 if (vq->num_buffers + *nbuffers < 3) 183 if (vq->num_buffers + *nbuffers < 3)
185 *nbuffers = 3 - vq->num_buffers; 184 *nbuffers = 3 - vq->num_buffers;
185 alloc_ctxs[0] = skel->alloc_ctx;
186 186
187 if (fmt && fmt->fmt.pix.sizeimage < skel->format.sizeimage) 187 if (*nplanes)
188 return -EINVAL; 188 return sizes[0] < skel->format.sizeimage ? -EINVAL : 0;
189 *nplanes = 1; 189 *nplanes = 1;
190 sizes[0] = fmt ? fmt->fmt.pix.sizeimage : skel->format.sizeimage; 190 sizes[0] = skel->format.sizeimage;
191 alloc_ctxs[0] = skel->alloc_ctx;
192 return 0; 191 return 0;
193} 192}
194 193
@@ -509,7 +508,7 @@ static int skeleton_s_dv_timings(struct file *file, void *_fh,
509 return -EINVAL; 508 return -EINVAL;
510 509
511 /* Return 0 if the new timings are the same as the current timings. */ 510 /* Return 0 if the new timings are the same as the current timings. */
512 if (v4l2_match_dv_timings(timings, &skel->timings, 0)) 511 if (v4l2_match_dv_timings(timings, &skel->timings, 0, false))
513 return 0; 512 return 0;
514 513
515 /* 514 /*
diff --git a/MAINTAINERS b/MAINTAINERS
index ab8695d6e75c..020a3be31b18 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -206,7 +206,7 @@ F: include/trace/events/9p.h
206A8293 MEDIA DRIVER 206A8293 MEDIA DRIVER
207M: Antti Palosaari <crope@iki.fi> 207M: Antti Palosaari <crope@iki.fi>
208L: linux-media@vger.kernel.org 208L: linux-media@vger.kernel.org
209W: http://linuxtv.org/ 209W: https://linuxtv.org
210W: http://palosaari.fi/linux/ 210W: http://palosaari.fi/linux/
211Q: http://patchwork.linuxtv.org/project/linux-media/list/ 211Q: http://patchwork.linuxtv.org/project/linux-media/list/
212T: git git://linuxtv.org/anttip/media_tree.git 212T: git git://linuxtv.org/anttip/media_tree.git
@@ -395,7 +395,7 @@ M: Sakari Ailus <sakari.ailus@iki.fi>
395L: linux-media@vger.kernel.org 395L: linux-media@vger.kernel.org
396S: Maintained 396S: Maintained
397F: drivers/media/i2c/adp1653.c 397F: drivers/media/i2c/adp1653.c
398F: include/media/adp1653.h 398F: include/media/i2c/adp1653.h
399 399
400ADP5520 BACKLIGHT DRIVER WITH IO EXPANDER (ADP5520/ADP5501) 400ADP5520 BACKLIGHT DRIVER WITH IO EXPANDER (ADP5520/ADP5501)
401M: Michael Hennerich <michael.hennerich@analog.com> 401M: Michael Hennerich <michael.hennerich@analog.com>
@@ -466,7 +466,7 @@ F: sound/oss/aedsp16.c
466AF9013 MEDIA DRIVER 466AF9013 MEDIA DRIVER
467M: Antti Palosaari <crope@iki.fi> 467M: Antti Palosaari <crope@iki.fi>
468L: linux-media@vger.kernel.org 468L: linux-media@vger.kernel.org
469W: http://linuxtv.org/ 469W: https://linuxtv.org
470W: http://palosaari.fi/linux/ 470W: http://palosaari.fi/linux/
471Q: http://patchwork.linuxtv.org/project/linux-media/list/ 471Q: http://patchwork.linuxtv.org/project/linux-media/list/
472T: git git://linuxtv.org/anttip/media_tree.git 472T: git git://linuxtv.org/anttip/media_tree.git
@@ -476,7 +476,7 @@ F: drivers/media/dvb-frontends/af9013*
476AF9033 MEDIA DRIVER 476AF9033 MEDIA DRIVER
477M: Antti Palosaari <crope@iki.fi> 477M: Antti Palosaari <crope@iki.fi>
478L: linux-media@vger.kernel.org 478L: linux-media@vger.kernel.org
479W: http://linuxtv.org/ 479W: https://linuxtv.org
480W: http://palosaari.fi/linux/ 480W: http://palosaari.fi/linux/
481Q: http://patchwork.linuxtv.org/project/linux-media/list/ 481Q: http://patchwork.linuxtv.org/project/linux-media/list/
482T: git git://linuxtv.org/anttip/media_tree.git 482T: git git://linuxtv.org/anttip/media_tree.git
@@ -522,7 +522,7 @@ AIMSLAB FM RADIO RECEIVER DRIVER
522M: Hans Verkuil <hverkuil@xs4all.nl> 522M: Hans Verkuil <hverkuil@xs4all.nl>
523L: linux-media@vger.kernel.org 523L: linux-media@vger.kernel.org
524T: git git://linuxtv.org/media_tree.git 524T: git git://linuxtv.org/media_tree.git
525W: http://linuxtv.org 525W: https://linuxtv.org
526S: Maintained 526S: Maintained
527F: drivers/media/radio/radio-aimslab* 527F: drivers/media/radio/radio-aimslab*
528 528
@@ -536,7 +536,7 @@ F: include/linux/*aio*.h
536AIRSPY MEDIA DRIVER 536AIRSPY MEDIA DRIVER
537M: Antti Palosaari <crope@iki.fi> 537M: Antti Palosaari <crope@iki.fi>
538L: linux-media@vger.kernel.org 538L: linux-media@vger.kernel.org
539W: http://linuxtv.org/ 539W: https://linuxtv.org
540W: http://palosaari.fi/linux/ 540W: http://palosaari.fi/linux/
541Q: http://patchwork.linuxtv.org/project/linux-media/list/ 541Q: http://patchwork.linuxtv.org/project/linux-media/list/
542T: git git://linuxtv.org/anttip/media_tree.git 542T: git git://linuxtv.org/anttip/media_tree.git
@@ -1773,7 +1773,7 @@ L: linux-media@vger.kernel.org
1773T: git git://linuxtv.org/media_tree.git 1773T: git git://linuxtv.org/media_tree.git
1774S: Maintained 1774S: Maintained
1775F: drivers/media/i2c/as3645a.c 1775F: drivers/media/i2c/as3645a.c
1776F: include/media/as3645a.h 1776F: include/media/i2c/as3645a.h
1777 1777
1778ASC7621 HARDWARE MONITOR DRIVER 1778ASC7621 HARDWARE MONITOR DRIVER
1779M: George Joseph <george.joseph@fairview5.com> 1779M: George Joseph <george.joseph@fairview5.com>
@@ -2063,7 +2063,7 @@ F: net/ax25/
2063AZ6007 DVB DRIVER 2063AZ6007 DVB DRIVER
2064M: Mauro Carvalho Chehab <mchehab@osg.samsung.com> 2064M: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2065L: linux-media@vger.kernel.org 2065L: linux-media@vger.kernel.org
2066W: http://linuxtv.org 2066W: https://linuxtv.org
2067T: git git://linuxtv.org/media_tree.git 2067T: git git://linuxtv.org/media_tree.git
2068S: Maintained 2068S: Maintained
2069F: drivers/media/usb/dvb-usb-v2/az6007.c 2069F: drivers/media/usb/dvb-usb-v2/az6007.c
@@ -2072,7 +2072,7 @@ AZTECH FM RADIO RECEIVER DRIVER
2072M: Hans Verkuil <hverkuil@xs4all.nl> 2072M: Hans Verkuil <hverkuil@xs4all.nl>
2073L: linux-media@vger.kernel.org 2073L: linux-media@vger.kernel.org
2074T: git git://linuxtv.org/media_tree.git 2074T: git git://linuxtv.org/media_tree.git
2075W: http://linuxtv.org 2075W: https://linuxtv.org
2076S: Maintained 2076S: Maintained
2077F: drivers/media/radio/radio-aztech* 2077F: drivers/media/radio/radio-aztech*
2078 2078
@@ -2125,7 +2125,7 @@ BDISP ST MEDIA DRIVER
2125M: Fabien Dessenne <fabien.dessenne@st.com> 2125M: Fabien Dessenne <fabien.dessenne@st.com>
2126L: linux-media@vger.kernel.org 2126L: linux-media@vger.kernel.org
2127T: git git://linuxtv.org/media_tree.git 2127T: git git://linuxtv.org/media_tree.git
2128W: http://linuxtv.org 2128W: https://linuxtv.org
2129S: Supported 2129S: Supported
2130F: drivers/media/platform/sti/bdisp 2130F: drivers/media/platform/sti/bdisp
2131 2131
@@ -2518,7 +2518,7 @@ F: fs/btrfs/
2518BTTV VIDEO4LINUX DRIVER 2518BTTV VIDEO4LINUX DRIVER
2519M: Mauro Carvalho Chehab <mchehab@osg.samsung.com> 2519M: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2520L: linux-media@vger.kernel.org 2520L: linux-media@vger.kernel.org
2521W: http://linuxtv.org 2521W: https://linuxtv.org
2522T: git git://linuxtv.org/media_tree.git 2522T: git git://linuxtv.org/media_tree.git
2523S: Odd fixes 2523S: Odd fixes
2524F: Documentation/video4linux/bttv/ 2524F: Documentation/video4linux/bttv/
@@ -2557,7 +2557,7 @@ CADET FM/AM RADIO RECEIVER DRIVER
2557M: Hans Verkuil <hverkuil@xs4all.nl> 2557M: Hans Verkuil <hverkuil@xs4all.nl>
2558L: linux-media@vger.kernel.org 2558L: linux-media@vger.kernel.org
2559T: git git://linuxtv.org/media_tree.git 2559T: git git://linuxtv.org/media_tree.git
2560W: http://linuxtv.org 2560W: https://linuxtv.org
2561S: Maintained 2561S: Maintained
2562F: drivers/media/radio/radio-cadet* 2562F: drivers/media/radio/radio-cadet*
2563 2563
@@ -2850,7 +2850,7 @@ COBALT MEDIA DRIVER
2850M: Hans Verkuil <hans.verkuil@cisco.com> 2850M: Hans Verkuil <hans.verkuil@cisco.com>
2851L: linux-media@vger.kernel.org 2851L: linux-media@vger.kernel.org
2852T: git git://linuxtv.org/media_tree.git 2852T: git git://linuxtv.org/media_tree.git
2853W: http://linuxtv.org 2853W: https://linuxtv.org
2854S: Supported 2854S: Supported
2855F: drivers/media/pci/cobalt/ 2855F: drivers/media/pci/cobalt/
2856 2856
@@ -3095,6 +3095,15 @@ S: Maintained
3095F: crypto/ansi_cprng.c 3095F: crypto/ansi_cprng.c
3096F: crypto/rng.c 3096F: crypto/rng.c
3097 3097
3098CS3308 MEDIA DRIVER
3099M: Hans Verkuil <hverkuil@xs4all.nl>
3100L: linux-media@vger.kernel.org
3101T: git git://linuxtv.org/media_tree.git
3102W: http://linuxtv.org
3103S: Odd Fixes
3104F: drivers/media/i2c/cs3308.c
3105F: drivers/media/i2c/cs3308.h
3106
3098CS5535 Audio ALSA driver 3107CS5535 Audio ALSA driver
3099M: Jaya Kumar <jayakumar.alsa@gmail.com> 3108M: Jaya Kumar <jayakumar.alsa@gmail.com>
3100S: Maintained 3109S: Maintained
@@ -3110,7 +3119,7 @@ M: Andy Walls <awalls@md.metrocast.net>
3110L: ivtv-devel@ivtvdriver.org (subscribers-only) 3119L: ivtv-devel@ivtvdriver.org (subscribers-only)
3111L: linux-media@vger.kernel.org 3120L: linux-media@vger.kernel.org
3112T: git git://linuxtv.org/media_tree.git 3121T: git git://linuxtv.org/media_tree.git
3113W: http://linuxtv.org 3122W: https://linuxtv.org
3114W: http://www.ivtvdriver.org/index.php/Cx18 3123W: http://www.ivtvdriver.org/index.php/Cx18
3115S: Maintained 3124S: Maintained
3116F: Documentation/video4linux/cx18.txt 3125F: Documentation/video4linux/cx18.txt
@@ -3121,7 +3130,7 @@ CX2341X MPEG ENCODER HELPER MODULE
3121M: Hans Verkuil <hverkuil@xs4all.nl> 3130M: Hans Verkuil <hverkuil@xs4all.nl>
3122L: linux-media@vger.kernel.org 3131L: linux-media@vger.kernel.org
3123T: git git://linuxtv.org/media_tree.git 3132T: git git://linuxtv.org/media_tree.git
3124W: http://linuxtv.org 3133W: https://linuxtv.org
3125S: Maintained 3134S: Maintained
3126F: drivers/media/common/cx2341x* 3135F: drivers/media/common/cx2341x*
3127F: include/media/cx2341x* 3136F: include/media/cx2341x*
@@ -3130,7 +3139,7 @@ CX24120 MEDIA DRIVER
3130M: Jemma Denson <jdenson@gmail.com> 3139M: Jemma Denson <jdenson@gmail.com>
3131M: Patrick Boettcher <patrick.boettcher@posteo.de> 3140M: Patrick Boettcher <patrick.boettcher@posteo.de>
3132L: linux-media@vger.kernel.org 3141L: linux-media@vger.kernel.org
3133W: http://linuxtv.org/ 3142W: https://linuxtv.org
3134Q: http://patchwork.linuxtv.org/project/linux-media/list/ 3143Q: http://patchwork.linuxtv.org/project/linux-media/list/
3135S: Maintained 3144S: Maintained
3136F: drivers/media/dvb-frontends/cx24120* 3145F: drivers/media/dvb-frontends/cx24120*
@@ -3138,7 +3147,7 @@ F: drivers/media/dvb-frontends/cx24120*
3138CX88 VIDEO4LINUX DRIVER 3147CX88 VIDEO4LINUX DRIVER
3139M: Mauro Carvalho Chehab <mchehab@osg.samsung.com> 3148M: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
3140L: linux-media@vger.kernel.org 3149L: linux-media@vger.kernel.org
3141W: http://linuxtv.org 3150W: https://linuxtv.org
3142T: git git://linuxtv.org/media_tree.git 3151T: git git://linuxtv.org/media_tree.git
3143S: Odd fixes 3152S: Odd fixes
3144F: Documentation/video4linux/cx88/ 3153F: Documentation/video4linux/cx88/
@@ -3147,7 +3156,7 @@ F: drivers/media/pci/cx88/
3147CXD2820R MEDIA DRIVER 3156CXD2820R MEDIA DRIVER
3148M: Antti Palosaari <crope@iki.fi> 3157M: Antti Palosaari <crope@iki.fi>
3149L: linux-media@vger.kernel.org 3158L: linux-media@vger.kernel.org
3150W: http://linuxtv.org/ 3159W: https://linuxtv.org
3151W: http://palosaari.fi/linux/ 3160W: http://palosaari.fi/linux/
3152Q: http://patchwork.linuxtv.org/project/linux-media/list/ 3161Q: http://patchwork.linuxtv.org/project/linux-media/list/
3153T: git git://linuxtv.org/anttip/media_tree.git 3162T: git git://linuxtv.org/anttip/media_tree.git
@@ -3253,7 +3262,7 @@ F: drivers/net/wan/pc300*
3253CYPRESS_FIRMWARE MEDIA DRIVER 3262CYPRESS_FIRMWARE MEDIA DRIVER
3254M: Antti Palosaari <crope@iki.fi> 3263M: Antti Palosaari <crope@iki.fi>
3255L: linux-media@vger.kernel.org 3264L: linux-media@vger.kernel.org
3256W: http://linuxtv.org/ 3265W: https://linuxtv.org
3257W: http://palosaari.fi/linux/ 3266W: http://palosaari.fi/linux/
3258Q: http://patchwork.linuxtv.org/project/linux-media/list/ 3267Q: http://patchwork.linuxtv.org/project/linux-media/list/
3259T: git git://linuxtv.org/anttip/media_tree.git 3268T: git git://linuxtv.org/anttip/media_tree.git
@@ -3760,14 +3769,14 @@ DT3155 MEDIA DRIVER
3760M: Hans Verkuil <hverkuil@xs4all.nl> 3769M: Hans Verkuil <hverkuil@xs4all.nl>
3761L: linux-media@vger.kernel.org 3770L: linux-media@vger.kernel.org
3762T: git git://linuxtv.org/media_tree.git 3771T: git git://linuxtv.org/media_tree.git
3763W: http://linuxtv.org 3772W: https://linuxtv.org
3764S: Odd Fixes 3773S: Odd Fixes
3765F: drivers/media/pci/dt3155/ 3774F: drivers/media/pci/dt3155/
3766 3775
3767DVB_USB_AF9015 MEDIA DRIVER 3776DVB_USB_AF9015 MEDIA DRIVER
3768M: Antti Palosaari <crope@iki.fi> 3777M: Antti Palosaari <crope@iki.fi>
3769L: linux-media@vger.kernel.org 3778L: linux-media@vger.kernel.org
3770W: http://linuxtv.org/ 3779W: https://linuxtv.org
3771W: http://palosaari.fi/linux/ 3780W: http://palosaari.fi/linux/
3772Q: http://patchwork.linuxtv.org/project/linux-media/list/ 3781Q: http://patchwork.linuxtv.org/project/linux-media/list/
3773T: git git://linuxtv.org/anttip/media_tree.git 3782T: git git://linuxtv.org/anttip/media_tree.git
@@ -3777,7 +3786,7 @@ F: drivers/media/usb/dvb-usb-v2/af9015*
3777DVB_USB_AF9035 MEDIA DRIVER 3786DVB_USB_AF9035 MEDIA DRIVER
3778M: Antti Palosaari <crope@iki.fi> 3787M: Antti Palosaari <crope@iki.fi>
3779L: linux-media@vger.kernel.org 3788L: linux-media@vger.kernel.org
3780W: http://linuxtv.org/ 3789W: https://linuxtv.org
3781W: http://palosaari.fi/linux/ 3790W: http://palosaari.fi/linux/
3782Q: http://patchwork.linuxtv.org/project/linux-media/list/ 3791Q: http://patchwork.linuxtv.org/project/linux-media/list/
3783T: git git://linuxtv.org/anttip/media_tree.git 3792T: git git://linuxtv.org/anttip/media_tree.git
@@ -3787,7 +3796,7 @@ F: drivers/media/usb/dvb-usb-v2/af9035*
3787DVB_USB_ANYSEE MEDIA DRIVER 3796DVB_USB_ANYSEE MEDIA DRIVER
3788M: Antti Palosaari <crope@iki.fi> 3797M: Antti Palosaari <crope@iki.fi>
3789L: linux-media@vger.kernel.org 3798L: linux-media@vger.kernel.org
3790W: http://linuxtv.org/ 3799W: https://linuxtv.org
3791W: http://palosaari.fi/linux/ 3800W: http://palosaari.fi/linux/
3792Q: http://patchwork.linuxtv.org/project/linux-media/list/ 3801Q: http://patchwork.linuxtv.org/project/linux-media/list/
3793T: git git://linuxtv.org/anttip/media_tree.git 3802T: git git://linuxtv.org/anttip/media_tree.git
@@ -3797,7 +3806,7 @@ F: drivers/media/usb/dvb-usb-v2/anysee*
3797DVB_USB_AU6610 MEDIA DRIVER 3806DVB_USB_AU6610 MEDIA DRIVER
3798M: Antti Palosaari <crope@iki.fi> 3807M: Antti Palosaari <crope@iki.fi>
3799L: linux-media@vger.kernel.org 3808L: linux-media@vger.kernel.org
3800W: http://linuxtv.org/ 3809W: https://linuxtv.org
3801W: http://palosaari.fi/linux/ 3810W: http://palosaari.fi/linux/
3802Q: http://patchwork.linuxtv.org/project/linux-media/list/ 3811Q: http://patchwork.linuxtv.org/project/linux-media/list/
3803T: git git://linuxtv.org/anttip/media_tree.git 3812T: git git://linuxtv.org/anttip/media_tree.git
@@ -3807,7 +3816,7 @@ F: drivers/media/usb/dvb-usb-v2/au6610*
3807DVB_USB_CE6230 MEDIA DRIVER 3816DVB_USB_CE6230 MEDIA DRIVER
3808M: Antti Palosaari <crope@iki.fi> 3817M: Antti Palosaari <crope@iki.fi>
3809L: linux-media@vger.kernel.org 3818L: linux-media@vger.kernel.org
3810W: http://linuxtv.org/ 3819W: https://linuxtv.org
3811W: http://palosaari.fi/linux/ 3820W: http://palosaari.fi/linux/
3812Q: http://patchwork.linuxtv.org/project/linux-media/list/ 3821Q: http://patchwork.linuxtv.org/project/linux-media/list/
3813T: git git://linuxtv.org/anttip/media_tree.git 3822T: git git://linuxtv.org/anttip/media_tree.git
@@ -3817,7 +3826,7 @@ F: drivers/media/usb/dvb-usb-v2/ce6230*
3817DVB_USB_CXUSB MEDIA DRIVER 3826DVB_USB_CXUSB MEDIA DRIVER
3818M: Michael Krufky <mkrufky@linuxtv.org> 3827M: Michael Krufky <mkrufky@linuxtv.org>
3819L: linux-media@vger.kernel.org 3828L: linux-media@vger.kernel.org
3820W: http://linuxtv.org/ 3829W: https://linuxtv.org
3821W: http://github.com/mkrufky 3830W: http://github.com/mkrufky
3822Q: http://patchwork.linuxtv.org/project/linux-media/list/ 3831Q: http://patchwork.linuxtv.org/project/linux-media/list/
3823T: git git://linuxtv.org/media_tree.git 3832T: git git://linuxtv.org/media_tree.git
@@ -3827,7 +3836,7 @@ F: drivers/media/usb/dvb-usb/cxusb*
3827DVB_USB_EC168 MEDIA DRIVER 3836DVB_USB_EC168 MEDIA DRIVER
3828M: Antti Palosaari <crope@iki.fi> 3837M: Antti Palosaari <crope@iki.fi>
3829L: linux-media@vger.kernel.org 3838L: linux-media@vger.kernel.org
3830W: http://linuxtv.org/ 3839W: https://linuxtv.org
3831W: http://palosaari.fi/linux/ 3840W: http://palosaari.fi/linux/
3832Q: http://patchwork.linuxtv.org/project/linux-media/list/ 3841Q: http://patchwork.linuxtv.org/project/linux-media/list/
3833T: git git://linuxtv.org/anttip/media_tree.git 3842T: git git://linuxtv.org/anttip/media_tree.git
@@ -3837,7 +3846,7 @@ F: drivers/media/usb/dvb-usb-v2/ec168*
3837DVB_USB_GL861 MEDIA DRIVER 3846DVB_USB_GL861 MEDIA DRIVER
3838M: Antti Palosaari <crope@iki.fi> 3847M: Antti Palosaari <crope@iki.fi>
3839L: linux-media@vger.kernel.org 3848L: linux-media@vger.kernel.org
3840W: http://linuxtv.org/ 3849W: https://linuxtv.org
3841Q: http://patchwork.linuxtv.org/project/linux-media/list/ 3850Q: http://patchwork.linuxtv.org/project/linux-media/list/
3842T: git git://linuxtv.org/anttip/media_tree.git 3851T: git git://linuxtv.org/anttip/media_tree.git
3843S: Maintained 3852S: Maintained
@@ -3846,7 +3855,7 @@ F: drivers/media/usb/dvb-usb-v2/gl861*
3846DVB_USB_MXL111SF MEDIA DRIVER 3855DVB_USB_MXL111SF MEDIA DRIVER
3847M: Michael Krufky <mkrufky@linuxtv.org> 3856M: Michael Krufky <mkrufky@linuxtv.org>
3848L: linux-media@vger.kernel.org 3857L: linux-media@vger.kernel.org
3849W: http://linuxtv.org/ 3858W: https://linuxtv.org
3850W: http://github.com/mkrufky 3859W: http://github.com/mkrufky
3851Q: http://patchwork.linuxtv.org/project/linux-media/list/ 3860Q: http://patchwork.linuxtv.org/project/linux-media/list/
3852T: git git://linuxtv.org/mkrufky/mxl111sf.git 3861T: git git://linuxtv.org/mkrufky/mxl111sf.git
@@ -3856,7 +3865,7 @@ F: drivers/media/usb/dvb-usb-v2/mxl111sf*
3856DVB_USB_RTL28XXU MEDIA DRIVER 3865DVB_USB_RTL28XXU MEDIA DRIVER
3857M: Antti Palosaari <crope@iki.fi> 3866M: Antti Palosaari <crope@iki.fi>
3858L: linux-media@vger.kernel.org 3867L: linux-media@vger.kernel.org
3859W: http://linuxtv.org/ 3868W: https://linuxtv.org
3860W: http://palosaari.fi/linux/ 3869W: http://palosaari.fi/linux/
3861Q: http://patchwork.linuxtv.org/project/linux-media/list/ 3870Q: http://patchwork.linuxtv.org/project/linux-media/list/
3862T: git git://linuxtv.org/anttip/media_tree.git 3871T: git git://linuxtv.org/anttip/media_tree.git
@@ -3866,7 +3875,7 @@ F: drivers/media/usb/dvb-usb-v2/rtl28xxu*
3866DVB_USB_V2 MEDIA DRIVER 3875DVB_USB_V2 MEDIA DRIVER
3867M: Antti Palosaari <crope@iki.fi> 3876M: Antti Palosaari <crope@iki.fi>
3868L: linux-media@vger.kernel.org 3877L: linux-media@vger.kernel.org
3869W: http://linuxtv.org/ 3878W: https://linuxtv.org
3870W: http://palosaari.fi/linux/ 3879W: http://palosaari.fi/linux/
3871Q: http://patchwork.linuxtv.org/project/linux-media/list/ 3880Q: http://patchwork.linuxtv.org/project/linux-media/list/
3872T: git git://linuxtv.org/anttip/media_tree.git 3881T: git git://linuxtv.org/anttip/media_tree.git
@@ -3896,7 +3905,7 @@ F: Documentation/devicetree/bindings/input/e3x0-button.txt
3896E4000 MEDIA DRIVER 3905E4000 MEDIA DRIVER
3897M: Antti Palosaari <crope@iki.fi> 3906M: Antti Palosaari <crope@iki.fi>
3898L: linux-media@vger.kernel.org 3907L: linux-media@vger.kernel.org
3899W: http://linuxtv.org/ 3908W: https://linuxtv.org
3900W: http://palosaari.fi/linux/ 3909W: http://palosaari.fi/linux/
3901Q: http://patchwork.linuxtv.org/project/linux-media/list/ 3910Q: http://patchwork.linuxtv.org/project/linux-media/list/
3902T: git git://linuxtv.org/anttip/media_tree.git 3911T: git git://linuxtv.org/anttip/media_tree.git
@@ -3912,7 +3921,7 @@ F: drivers/scsi/eata.c
3912EC100 MEDIA DRIVER 3921EC100 MEDIA DRIVER
3913M: Antti Palosaari <crope@iki.fi> 3922M: Antti Palosaari <crope@iki.fi>
3914L: linux-media@vger.kernel.org 3923L: linux-media@vger.kernel.org
3915W: http://linuxtv.org/ 3924W: https://linuxtv.org
3916W: http://palosaari.fi/linux/ 3925W: http://palosaari.fi/linux/
3917Q: http://patchwork.linuxtv.org/project/linux-media/list/ 3926Q: http://patchwork.linuxtv.org/project/linux-media/list/
3918T: git git://linuxtv.org/anttip/media_tree.git 3927T: git git://linuxtv.org/anttip/media_tree.git
@@ -4117,7 +4126,7 @@ F: drivers/net/ethernet/ibm/ehea/
4117EM28XX VIDEO4LINUX DRIVER 4126EM28XX VIDEO4LINUX DRIVER
4118M: Mauro Carvalho Chehab <mchehab@osg.samsung.com> 4127M: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
4119L: linux-media@vger.kernel.org 4128L: linux-media@vger.kernel.org
4120W: http://linuxtv.org 4129W: https://linuxtv.org
4121T: git git://linuxtv.org/media_tree.git 4130T: git git://linuxtv.org/media_tree.git
4122S: Maintained 4131S: Maintained
4123F: drivers/media/usb/em28xx/ 4132F: drivers/media/usb/em28xx/
@@ -4257,7 +4266,7 @@ F: drivers/media/tuners/fc0011.c
4257FC2580 MEDIA DRIVER 4266FC2580 MEDIA DRIVER
4258M: Antti Palosaari <crope@iki.fi> 4267M: Antti Palosaari <crope@iki.fi>
4259L: linux-media@vger.kernel.org 4268L: linux-media@vger.kernel.org
4260W: http://linuxtv.org/ 4269W: https://linuxtv.org
4261W: http://palosaari.fi/linux/ 4270W: http://palosaari.fi/linux/
4262Q: http://patchwork.linuxtv.org/project/linux-media/list/ 4271Q: http://patchwork.linuxtv.org/project/linux-media/list/
4263T: git git://linuxtv.org/anttip/media_tree.git 4272T: git git://linuxtv.org/anttip/media_tree.git
@@ -4580,7 +4589,7 @@ M: Heungjun Kim <riverful.kim@samsung.com>
4580L: linux-media@vger.kernel.org 4589L: linux-media@vger.kernel.org
4581S: Maintained 4590S: Maintained
4582F: drivers/media/i2c/m5mols/ 4591F: drivers/media/i2c/m5mols/
4583F: include/media/m5mols.h 4592F: include/media/i2c/m5mols.h
4584 4593
4585FUJITSU TABLET EXTRAS 4594FUJITSU TABLET EXTRAS
4586M: Robert Gerlach <khnz@gmx.de> 4595M: Robert Gerlach <khnz@gmx.de>
@@ -4626,7 +4635,7 @@ GEMTEK FM RADIO RECEIVER DRIVER
4626M: Hans Verkuil <hverkuil@xs4all.nl> 4635M: Hans Verkuil <hverkuil@xs4all.nl>
4627L: linux-media@vger.kernel.org 4636L: linux-media@vger.kernel.org
4628T: git git://linuxtv.org/media_tree.git 4637T: git git://linuxtv.org/media_tree.git
4629W: http://linuxtv.org 4638W: https://linuxtv.org
4630S: Maintained 4639S: Maintained
4631F: drivers/media/radio/radio-gemtek* 4640F: drivers/media/radio/radio-gemtek*
4632 4641
@@ -4834,7 +4843,7 @@ HDPVR USB VIDEO ENCODER DRIVER
4834M: Hans Verkuil <hverkuil@xs4all.nl> 4843M: Hans Verkuil <hverkuil@xs4all.nl>
4835L: linux-media@vger.kernel.org 4844L: linux-media@vger.kernel.org
4836T: git git://linuxtv.org/media_tree.git 4845T: git git://linuxtv.org/media_tree.git
4837W: http://linuxtv.org 4846W: https://linuxtv.org
4838S: Odd Fixes 4847S: Odd Fixes
4839F: drivers/media/usb/hdpvr/ 4848F: drivers/media/usb/hdpvr/
4840 4849
@@ -4853,7 +4862,7 @@ F: drivers/tty/hvc/
4853HACKRF MEDIA DRIVER 4862HACKRF MEDIA DRIVER
4854M: Antti Palosaari <crope@iki.fi> 4863M: Antti Palosaari <crope@iki.fi>
4855L: linux-media@vger.kernel.org 4864L: linux-media@vger.kernel.org
4856W: http://linuxtv.org/ 4865W: https://linuxtv.org
4857W: http://palosaari.fi/linux/ 4866W: http://palosaari.fi/linux/
4858Q: http://patchwork.linuxtv.org/project/linux-media/list/ 4867Q: http://patchwork.linuxtv.org/project/linux-media/list/
4859T: git git://linuxtv.org/anttip/media_tree.git 4868T: git git://linuxtv.org/anttip/media_tree.git
@@ -4896,7 +4905,7 @@ F: sound/parisc/harmony.*
4896HD29L2 MEDIA DRIVER 4905HD29L2 MEDIA DRIVER
4897M: Antti Palosaari <crope@iki.fi> 4906M: Antti Palosaari <crope@iki.fi>
4898L: linux-media@vger.kernel.org 4907L: linux-media@vger.kernel.org
4899W: http://linuxtv.org/ 4908W: https://linuxtv.org
4900W: http://palosaari.fi/linux/ 4909W: http://palosaari.fi/linux/
4901Q: http://patchwork.linuxtv.org/project/linux-media/list/ 4910Q: http://patchwork.linuxtv.org/project/linux-media/list/
4902T: git git://linuxtv.org/anttip/media_tree.git 4911T: git git://linuxtv.org/anttip/media_tree.git
@@ -5800,7 +5809,7 @@ ISA RADIO MODULE
5800M: Hans Verkuil <hverkuil@xs4all.nl> 5809M: Hans Verkuil <hverkuil@xs4all.nl>
5801L: linux-media@vger.kernel.org 5810L: linux-media@vger.kernel.org
5802T: git git://linuxtv.org/media_tree.git 5811T: git git://linuxtv.org/media_tree.git
5803W: http://linuxtv.org 5812W: https://linuxtv.org
5804S: Maintained 5813S: Maintained
5805F: drivers/media/radio/radio-isa* 5814F: drivers/media/radio/radio-isa*
5806 5815
@@ -5870,7 +5879,7 @@ F: drivers/hwmon/it87.c
5870IT913X MEDIA DRIVER 5879IT913X MEDIA DRIVER
5871M: Antti Palosaari <crope@iki.fi> 5880M: Antti Palosaari <crope@iki.fi>
5872L: linux-media@vger.kernel.org 5881L: linux-media@vger.kernel.org
5873W: http://linuxtv.org/ 5882W: https://linuxtv.org
5874W: http://palosaari.fi/linux/ 5883W: http://palosaari.fi/linux/
5875Q: http://patchwork.linuxtv.org/project/linux-media/list/ 5884Q: http://patchwork.linuxtv.org/project/linux-media/list/
5876T: git git://linuxtv.org/anttip/media_tree.git 5885T: git git://linuxtv.org/anttip/media_tree.git
@@ -5891,7 +5900,7 @@ F: include/uapi/linux/ivtv*
5891IX2505V MEDIA DRIVER 5900IX2505V MEDIA DRIVER
5892M: Malcolm Priestley <tvboxspy@gmail.com> 5901M: Malcolm Priestley <tvboxspy@gmail.com>
5893L: linux-media@vger.kernel.org 5902L: linux-media@vger.kernel.org
5894W: http://linuxtv.org/ 5903W: https://linuxtv.org
5895Q: http://patchwork.linuxtv.org/project/linux-media/list/ 5904Q: http://patchwork.linuxtv.org/project/linux-media/list/
5896S: Maintained 5905S: Maintained
5897F: drivers/media/dvb-frontends/ix2505v* 5906F: drivers/media/dvb-frontends/ix2505v*
@@ -5980,7 +5989,7 @@ KEENE FM RADIO TRANSMITTER DRIVER
5980M: Hans Verkuil <hverkuil@xs4all.nl> 5989M: Hans Verkuil <hverkuil@xs4all.nl>
5981L: linux-media@vger.kernel.org 5990L: linux-media@vger.kernel.org
5982T: git git://linuxtv.org/media_tree.git 5991T: git git://linuxtv.org/media_tree.git
5983W: http://linuxtv.org 5992W: https://linuxtv.org
5984S: Maintained 5993S: Maintained
5985F: drivers/media/radio/radio-keene* 5994F: drivers/media/radio/radio-keene*
5986 5995
@@ -6232,7 +6241,7 @@ F: drivers/usb/misc/legousbtower.c
6232LG2160 MEDIA DRIVER 6241LG2160 MEDIA DRIVER
6233M: Michael Krufky <mkrufky@linuxtv.org> 6242M: Michael Krufky <mkrufky@linuxtv.org>
6234L: linux-media@vger.kernel.org 6243L: linux-media@vger.kernel.org
6235W: http://linuxtv.org/ 6244W: https://linuxtv.org
6236W: http://github.com/mkrufky 6245W: http://github.com/mkrufky
6237Q: http://patchwork.linuxtv.org/project/linux-media/list/ 6246Q: http://patchwork.linuxtv.org/project/linux-media/list/
6238T: git git://linuxtv.org/mkrufky/tuners.git 6247T: git git://linuxtv.org/mkrufky/tuners.git
@@ -6242,7 +6251,7 @@ F: drivers/media/dvb-frontends/lg2160.*
6242LGDT3305 MEDIA DRIVER 6251LGDT3305 MEDIA DRIVER
6243M: Michael Krufky <mkrufky@linuxtv.org> 6252M: Michael Krufky <mkrufky@linuxtv.org>
6244L: linux-media@vger.kernel.org 6253L: linux-media@vger.kernel.org
6245W: http://linuxtv.org/ 6254W: https://linuxtv.org
6246W: http://github.com/mkrufky 6255W: http://github.com/mkrufky
6247Q: http://patchwork.linuxtv.org/project/linux-media/list/ 6256Q: http://patchwork.linuxtv.org/project/linux-media/list/
6248T: git git://linuxtv.org/mkrufky/tuners.git 6257T: git git://linuxtv.org/mkrufky/tuners.git
@@ -6499,7 +6508,7 @@ F: drivers/hwmon/lm95234.c
6499LME2510 MEDIA DRIVER 6508LME2510 MEDIA DRIVER
6500M: Malcolm Priestley <tvboxspy@gmail.com> 6509M: Malcolm Priestley <tvboxspy@gmail.com>
6501L: linux-media@vger.kernel.org 6510L: linux-media@vger.kernel.org
6502W: http://linuxtv.org/ 6511W: https://linuxtv.org
6503Q: http://patchwork.linuxtv.org/project/linux-media/list/ 6512Q: http://patchwork.linuxtv.org/project/linux-media/list/
6504S: Maintained 6513S: Maintained
6505F: drivers/media/usb/dvb-usb-v2/lmedm04* 6514F: drivers/media/usb/dvb-usb-v2/lmedm04*
@@ -6605,7 +6614,7 @@ F: arch/m68k/hp300/
6605M88DS3103 MEDIA DRIVER 6614M88DS3103 MEDIA DRIVER
6606M: Antti Palosaari <crope@iki.fi> 6615M: Antti Palosaari <crope@iki.fi>
6607L: linux-media@vger.kernel.org 6616L: linux-media@vger.kernel.org
6608W: http://linuxtv.org/ 6617W: https://linuxtv.org
6609W: http://palosaari.fi/linux/ 6618W: http://palosaari.fi/linux/
6610Q: http://patchwork.linuxtv.org/project/linux-media/list/ 6619Q: http://patchwork.linuxtv.org/project/linux-media/list/
6611T: git git://linuxtv.org/anttip/media_tree.git 6620T: git git://linuxtv.org/anttip/media_tree.git
@@ -6615,7 +6624,7 @@ F: drivers/media/dvb-frontends/m88ds3103*
6615M88RS2000 MEDIA DRIVER 6624M88RS2000 MEDIA DRIVER
6616M: Malcolm Priestley <tvboxspy@gmail.com> 6625M: Malcolm Priestley <tvboxspy@gmail.com>
6617L: linux-media@vger.kernel.org 6626L: linux-media@vger.kernel.org
6618W: http://linuxtv.org/ 6627W: https://linuxtv.org
6619Q: http://patchwork.linuxtv.org/project/linux-media/list/ 6628Q: http://patchwork.linuxtv.org/project/linux-media/list/
6620S: Maintained 6629S: Maintained
6621F: drivers/media/dvb-frontends/m88rs2000* 6630F: drivers/media/dvb-frontends/m88rs2000*
@@ -6794,7 +6803,7 @@ MAXIRADIO FM RADIO RECEIVER DRIVER
6794M: Hans Verkuil <hverkuil@xs4all.nl> 6803M: Hans Verkuil <hverkuil@xs4all.nl>
6795L: linux-media@vger.kernel.org 6804L: linux-media@vger.kernel.org
6796T: git git://linuxtv.org/media_tree.git 6805T: git git://linuxtv.org/media_tree.git
6797W: http://linuxtv.org 6806W: https://linuxtv.org
6798S: Maintained 6807S: Maintained
6799F: drivers/media/radio/radio-maxiradio* 6808F: drivers/media/radio/radio-maxiradio*
6800 6809
@@ -6816,7 +6825,7 @@ F: drivers/media/platform/vsp1/
6816MEDIA DRIVERS FOR ASCOT2E 6825MEDIA DRIVERS FOR ASCOT2E
6817M: Sergey Kozlov <serjk@netup.ru> 6826M: Sergey Kozlov <serjk@netup.ru>
6818L: linux-media@vger.kernel.org 6827L: linux-media@vger.kernel.org
6819W: http://linuxtv.org 6828W: https://linuxtv.org
6820W: http://netup.tv/ 6829W: http://netup.tv/
6821T: git git://linuxtv.org/media_tree.git 6830T: git git://linuxtv.org/media_tree.git
6822S: Supported 6831S: Supported
@@ -6825,7 +6834,7 @@ F: drivers/media/dvb-frontends/ascot2e*
6825MEDIA DRIVERS FOR CXD2841ER 6834MEDIA DRIVERS FOR CXD2841ER
6826M: Sergey Kozlov <serjk@netup.ru> 6835M: Sergey Kozlov <serjk@netup.ru>
6827L: linux-media@vger.kernel.org 6836L: linux-media@vger.kernel.org
6828W: http://linuxtv.org/ 6837W: https://linuxtv.org
6829W: http://netup.tv/ 6838W: http://netup.tv/
6830T: git git://linuxtv.org/media_tree.git 6839T: git git://linuxtv.org/media_tree.git
6831S: Supported 6840S: Supported
@@ -6834,7 +6843,7 @@ F: drivers/media/dvb-frontends/cxd2841er*
6834MEDIA DRIVERS FOR HORUS3A 6843MEDIA DRIVERS FOR HORUS3A
6835M: Sergey Kozlov <serjk@netup.ru> 6844M: Sergey Kozlov <serjk@netup.ru>
6836L: linux-media@vger.kernel.org 6845L: linux-media@vger.kernel.org
6837W: http://linuxtv.org/ 6846W: https://linuxtv.org
6838W: http://netup.tv/ 6847W: http://netup.tv/
6839T: git git://linuxtv.org/media_tree.git 6848T: git git://linuxtv.org/media_tree.git
6840S: Supported 6849S: Supported
@@ -6843,7 +6852,7 @@ F: drivers/media/dvb-frontends/horus3a*
6843MEDIA DRIVERS FOR LNBH25 6852MEDIA DRIVERS FOR LNBH25
6844M: Sergey Kozlov <serjk@netup.ru> 6853M: Sergey Kozlov <serjk@netup.ru>
6845L: linux-media@vger.kernel.org 6854L: linux-media@vger.kernel.org
6846W: http://linuxtv.org/ 6855W: https://linuxtv.org
6847W: http://netup.tv/ 6856W: http://netup.tv/
6848T: git git://linuxtv.org/media_tree.git 6857T: git git://linuxtv.org/media_tree.git
6849S: Supported 6858S: Supported
@@ -6852,7 +6861,7 @@ F: drivers/media/dvb-frontends/lnbh25*
6852MEDIA DRIVERS FOR NETUP PCI UNIVERSAL DVB devices 6861MEDIA DRIVERS FOR NETUP PCI UNIVERSAL DVB devices
6853M: Sergey Kozlov <serjk@netup.ru> 6862M: Sergey Kozlov <serjk@netup.ru>
6854L: linux-media@vger.kernel.org 6863L: linux-media@vger.kernel.org
6855W: http://linuxtv.org/ 6864W: https://linuxtv.org
6856W: http://netup.tv/ 6865W: http://netup.tv/
6857T: git git://linuxtv.org/media_tree.git 6866T: git git://linuxtv.org/media_tree.git
6858S: Supported 6867S: Supported
@@ -6862,7 +6871,7 @@ MEDIA INPUT INFRASTRUCTURE (V4L/DVB)
6862M: Mauro Carvalho Chehab <mchehab@osg.samsung.com> 6871M: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
6863P: LinuxTV.org Project 6872P: LinuxTV.org Project
6864L: linux-media@vger.kernel.org 6873L: linux-media@vger.kernel.org
6865W: http://linuxtv.org 6874W: https://linuxtv.org
6866Q: http://patchwork.kernel.org/project/linux-media/list/ 6875Q: http://patchwork.kernel.org/project/linux-media/list/
6867T: git git://linuxtv.org/media_tree.git 6876T: git git://linuxtv.org/media_tree.git
6868S: Maintained 6877S: Maintained
@@ -6871,6 +6880,7 @@ F: Documentation/video4linux/
6871F: Documentation/DocBook/media/ 6880F: Documentation/DocBook/media/
6872F: drivers/media/ 6881F: drivers/media/
6873F: drivers/staging/media/ 6882F: drivers/staging/media/
6883F: include/linux/platform_data/media/
6874F: include/media/ 6884F: include/media/
6875F: include/uapi/linux/dvb/ 6885F: include/uapi/linux/dvb/
6876F: include/uapi/linux/videodev2.h 6886F: include/uapi/linux/videodev2.h
@@ -7022,7 +7032,7 @@ MIROSOUND PCM20 FM RADIO RECEIVER DRIVER
7022M: Hans Verkuil <hverkuil@xs4all.nl> 7032M: Hans Verkuil <hverkuil@xs4all.nl>
7023L: linux-media@vger.kernel.org 7033L: linux-media@vger.kernel.org
7024T: git git://linuxtv.org/media_tree.git 7034T: git git://linuxtv.org/media_tree.git
7025W: http://linuxtv.org 7035W: https://linuxtv.org
7026S: Odd Fixes 7036S: Odd Fixes
7027F: drivers/media/radio/radio-miropcm20* 7037F: drivers/media/radio/radio-miropcm20*
7028 7038
@@ -7058,7 +7068,7 @@ F: drivers/iio/temperature/mlx90614.c
7058MN88472 MEDIA DRIVER 7068MN88472 MEDIA DRIVER
7059M: Antti Palosaari <crope@iki.fi> 7069M: Antti Palosaari <crope@iki.fi>
7060L: linux-media@vger.kernel.org 7070L: linux-media@vger.kernel.org
7061W: http://linuxtv.org/ 7071W: https://linuxtv.org
7062W: http://palosaari.fi/linux/ 7072W: http://palosaari.fi/linux/
7063Q: http://patchwork.linuxtv.org/project/linux-media/list/ 7073Q: http://patchwork.linuxtv.org/project/linux-media/list/
7064T: git git://linuxtv.org/anttip/media_tree.git 7074T: git git://linuxtv.org/anttip/media_tree.git
@@ -7069,7 +7079,7 @@ F: drivers/media/dvb-frontends/mn88472.h
7069MN88473 MEDIA DRIVER 7079MN88473 MEDIA DRIVER
7070M: Antti Palosaari <crope@iki.fi> 7080M: Antti Palosaari <crope@iki.fi>
7071L: linux-media@vger.kernel.org 7081L: linux-media@vger.kernel.org
7072W: http://linuxtv.org/ 7082W: https://linuxtv.org
7073W: http://palosaari.fi/linux/ 7083W: http://palosaari.fi/linux/
7074Q: http://patchwork.linuxtv.org/project/linux-media/list/ 7084Q: http://patchwork.linuxtv.org/project/linux-media/list/
7075T: git git://linuxtv.org/anttip/media_tree.git 7085T: git git://linuxtv.org/anttip/media_tree.git
@@ -7124,7 +7134,7 @@ F: drivers/platform/x86/msi-wmi.c
7124MSI001 MEDIA DRIVER 7134MSI001 MEDIA DRIVER
7125M: Antti Palosaari <crope@iki.fi> 7135M: Antti Palosaari <crope@iki.fi>
7126L: linux-media@vger.kernel.org 7136L: linux-media@vger.kernel.org
7127W: http://linuxtv.org/ 7137W: https://linuxtv.org
7128W: http://palosaari.fi/linux/ 7138W: http://palosaari.fi/linux/
7129Q: http://patchwork.linuxtv.org/project/linux-media/list/ 7139Q: http://patchwork.linuxtv.org/project/linux-media/list/
7130T: git git://linuxtv.org/anttip/media_tree.git 7140T: git git://linuxtv.org/anttip/media_tree.git
@@ -7134,7 +7144,7 @@ F: drivers/media/tuners/msi001*
7134MSI2500 MEDIA DRIVER 7144MSI2500 MEDIA DRIVER
7135M: Antti Palosaari <crope@iki.fi> 7145M: Antti Palosaari <crope@iki.fi>
7136L: linux-media@vger.kernel.org 7146L: linux-media@vger.kernel.org
7137W: http://linuxtv.org/ 7147W: https://linuxtv.org
7138W: http://palosaari.fi/linux/ 7148W: http://palosaari.fi/linux/
7139Q: http://patchwork.linuxtv.org/project/linux-media/list/ 7149Q: http://patchwork.linuxtv.org/project/linux-media/list/
7140T: git git://linuxtv.org/anttip/media_tree.git 7150T: git git://linuxtv.org/anttip/media_tree.git
@@ -7153,7 +7163,7 @@ L: linux-media@vger.kernel.org
7153T: git git://linuxtv.org/media_tree.git 7163T: git git://linuxtv.org/media_tree.git
7154S: Maintained 7164S: Maintained
7155F: drivers/media/i2c/mt9m032.c 7165F: drivers/media/i2c/mt9m032.c
7156F: include/media/mt9m032.h 7166F: include/media/i2c/mt9m032.h
7157 7167
7158MT9P031 APTINA CAMERA SENSOR 7168MT9P031 APTINA CAMERA SENSOR
7159M: Laurent Pinchart <laurent.pinchart@ideasonboard.com> 7169M: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
@@ -7161,7 +7171,7 @@ L: linux-media@vger.kernel.org
7161T: git git://linuxtv.org/media_tree.git 7171T: git git://linuxtv.org/media_tree.git
7162S: Maintained 7172S: Maintained
7163F: drivers/media/i2c/mt9p031.c 7173F: drivers/media/i2c/mt9p031.c
7164F: include/media/mt9p031.h 7174F: include/media/i2c/mt9p031.h
7165 7175
7166MT9T001 APTINA CAMERA SENSOR 7176MT9T001 APTINA CAMERA SENSOR
7167M: Laurent Pinchart <laurent.pinchart@ideasonboard.com> 7177M: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
@@ -7169,7 +7179,7 @@ L: linux-media@vger.kernel.org
7169T: git git://linuxtv.org/media_tree.git 7179T: git git://linuxtv.org/media_tree.git
7170S: Maintained 7180S: Maintained
7171F: drivers/media/i2c/mt9t001.c 7181F: drivers/media/i2c/mt9t001.c
7172F: include/media/mt9t001.h 7182F: include/media/i2c/mt9t001.h
7173 7183
7174MT9V032 APTINA CAMERA SENSOR 7184MT9V032 APTINA CAMERA SENSOR
7175M: Laurent Pinchart <laurent.pinchart@ideasonboard.com> 7185M: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
@@ -7178,7 +7188,7 @@ T: git git://linuxtv.org/media_tree.git
7178S: Maintained 7188S: Maintained
7179F: Documentation/devicetree/bindings/media/i2c/mt9v032.txt 7189F: Documentation/devicetree/bindings/media/i2c/mt9v032.txt
7180F: drivers/media/i2c/mt9v032.c 7190F: drivers/media/i2c/mt9v032.c
7181F: include/media/mt9v032.h 7191F: include/media/i2c/mt9v032.h
7182 7192
7183MULTIFUNCTION DEVICES (MFD) 7193MULTIFUNCTION DEVICES (MFD)
7184M: Lee Jones <lee.jones@linaro.org> 7194M: Lee Jones <lee.jones@linaro.org>
@@ -7222,7 +7232,7 @@ F: drivers/usb/musb/
7222MXL5007T MEDIA DRIVER 7232MXL5007T MEDIA DRIVER
7223M: Michael Krufky <mkrufky@linuxtv.org> 7233M: Michael Krufky <mkrufky@linuxtv.org>
7224L: linux-media@vger.kernel.org 7234L: linux-media@vger.kernel.org
7225W: http://linuxtv.org/ 7235W: https://linuxtv.org
7226W: http://github.com/mkrufky 7236W: http://github.com/mkrufky
7227Q: http://patchwork.linuxtv.org/project/linux-media/list/ 7237Q: http://patchwork.linuxtv.org/project/linux-media/list/
7228T: git git://linuxtv.org/mkrufky/tuners.git 7238T: git git://linuxtv.org/mkrufky/tuners.git
@@ -8725,7 +8735,7 @@ F: include/uapi/linux/qnxtypes.h
8725QT1010 MEDIA DRIVER 8735QT1010 MEDIA DRIVER
8726M: Antti Palosaari <crope@iki.fi> 8736M: Antti Palosaari <crope@iki.fi>
8727L: linux-media@vger.kernel.org 8737L: linux-media@vger.kernel.org
8728W: http://linuxtv.org/ 8738W: https://linuxtv.org
8729W: http://palosaari.fi/linux/ 8739W: http://palosaari.fi/linux/
8730Q: http://patchwork.linuxtv.org/project/linux-media/list/ 8740Q: http://patchwork.linuxtv.org/project/linux-media/list/
8731T: git git://linuxtv.org/anttip/media_tree.git 8741T: git git://linuxtv.org/anttip/media_tree.git
@@ -9018,7 +9028,7 @@ F: net/rose/
9018RTL2830 MEDIA DRIVER 9028RTL2830 MEDIA DRIVER
9019M: Antti Palosaari <crope@iki.fi> 9029M: Antti Palosaari <crope@iki.fi>
9020L: linux-media@vger.kernel.org 9030L: linux-media@vger.kernel.org
9021W: http://linuxtv.org/ 9031W: https://linuxtv.org
9022W: http://palosaari.fi/linux/ 9032W: http://palosaari.fi/linux/
9023Q: http://patchwork.linuxtv.org/project/linux-media/list/ 9033Q: http://patchwork.linuxtv.org/project/linux-media/list/
9024T: git git://linuxtv.org/anttip/media_tree.git 9034T: git git://linuxtv.org/anttip/media_tree.git
@@ -9028,7 +9038,7 @@ F: drivers/media/dvb-frontends/rtl2830*
9028RTL2832 MEDIA DRIVER 9038RTL2832 MEDIA DRIVER
9029M: Antti Palosaari <crope@iki.fi> 9039M: Antti Palosaari <crope@iki.fi>
9030L: linux-media@vger.kernel.org 9040L: linux-media@vger.kernel.org
9031W: http://linuxtv.org/ 9041W: https://linuxtv.org
9032W: http://palosaari.fi/linux/ 9042W: http://palosaari.fi/linux/
9033Q: http://patchwork.linuxtv.org/project/linux-media/list/ 9043Q: http://patchwork.linuxtv.org/project/linux-media/list/
9034T: git git://linuxtv.org/anttip/media_tree.git 9044T: git git://linuxtv.org/anttip/media_tree.git
@@ -9038,7 +9048,7 @@ F: drivers/media/dvb-frontends/rtl2832*
9038RTL2832_SDR MEDIA DRIVER 9048RTL2832_SDR MEDIA DRIVER
9039M: Antti Palosaari <crope@iki.fi> 9049M: Antti Palosaari <crope@iki.fi>
9040L: linux-media@vger.kernel.org 9050L: linux-media@vger.kernel.org
9041W: http://linuxtv.org/ 9051W: https://linuxtv.org
9042W: http://palosaari.fi/linux/ 9052W: http://palosaari.fi/linux/
9043Q: http://patchwork.linuxtv.org/project/linux-media/list/ 9053Q: http://patchwork.linuxtv.org/project/linux-media/list/
9044T: git git://linuxtv.org/anttip/media_tree.git 9054T: git git://linuxtv.org/anttip/media_tree.git
@@ -9169,14 +9179,14 @@ SAA6588 RDS RECEIVER DRIVER
9169M: Hans Verkuil <hverkuil@xs4all.nl> 9179M: Hans Verkuil <hverkuil@xs4all.nl>
9170L: linux-media@vger.kernel.org 9180L: linux-media@vger.kernel.org
9171T: git git://linuxtv.org/media_tree.git 9181T: git git://linuxtv.org/media_tree.git
9172W: http://linuxtv.org 9182W: https://linuxtv.org
9173S: Odd Fixes 9183S: Odd Fixes
9174F: drivers/media/i2c/saa6588* 9184F: drivers/media/i2c/saa6588*
9175 9185
9176SAA7134 VIDEO4LINUX DRIVER 9186SAA7134 VIDEO4LINUX DRIVER
9177M: Mauro Carvalho Chehab <mchehab@osg.samsung.com> 9187M: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
9178L: linux-media@vger.kernel.org 9188L: linux-media@vger.kernel.org
9179W: http://linuxtv.org 9189W: https://linuxtv.org
9180T: git git://linuxtv.org/media_tree.git 9190T: git git://linuxtv.org/media_tree.git
9181S: Odd fixes 9191S: Odd fixes
9182F: Documentation/video4linux/*.saa7134 9192F: Documentation/video4linux/*.saa7134
@@ -9238,7 +9248,7 @@ L: linux-media@vger.kernel.org
9238L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers) 9248L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers)
9239S: Maintained 9249S: Maintained
9240F: drivers/media/platform/s3c-camif/ 9250F: drivers/media/platform/s3c-camif/
9241F: include/media/s3c_camif.h 9251F: include/media/drv-intf/s3c_camif.h
9242 9252
9243SAMSUNG S5C73M3 CAMERA DRIVER 9253SAMSUNG S5C73M3 CAMERA DRIVER
9244M: Kyungmin Park <kyungmin.park@samsung.com> 9254M: Kyungmin Park <kyungmin.park@samsung.com>
@@ -9614,7 +9624,7 @@ F: drivers/misc/sgi-xp/
9614SI2157 MEDIA DRIVER 9624SI2157 MEDIA DRIVER
9615M: Antti Palosaari <crope@iki.fi> 9625M: Antti Palosaari <crope@iki.fi>
9616L: linux-media@vger.kernel.org 9626L: linux-media@vger.kernel.org
9617W: http://linuxtv.org/ 9627W: https://linuxtv.org
9618W: http://palosaari.fi/linux/ 9628W: http://palosaari.fi/linux/
9619Q: http://patchwork.linuxtv.org/project/linux-media/list/ 9629Q: http://patchwork.linuxtv.org/project/linux-media/list/
9620T: git git://linuxtv.org/anttip/media_tree.git 9630T: git git://linuxtv.org/anttip/media_tree.git
@@ -9624,7 +9634,7 @@ F: drivers/media/tuners/si2157*
9624SI2168 MEDIA DRIVER 9634SI2168 MEDIA DRIVER
9625M: Antti Palosaari <crope@iki.fi> 9635M: Antti Palosaari <crope@iki.fi>
9626L: linux-media@vger.kernel.org 9636L: linux-media@vger.kernel.org
9627W: http://linuxtv.org/ 9637W: https://linuxtv.org
9628W: http://palosaari.fi/linux/ 9638W: http://palosaari.fi/linux/
9629Q: http://patchwork.linuxtv.org/project/linux-media/list/ 9639Q: http://patchwork.linuxtv.org/project/linux-media/list/
9630T: git git://linuxtv.org/anttip/media_tree.git 9640T: git git://linuxtv.org/anttip/media_tree.git
@@ -9635,7 +9645,7 @@ SI470X FM RADIO RECEIVER I2C DRIVER
9635M: Hans Verkuil <hverkuil@xs4all.nl> 9645M: Hans Verkuil <hverkuil@xs4all.nl>
9636L: linux-media@vger.kernel.org 9646L: linux-media@vger.kernel.org
9637T: git git://linuxtv.org/media_tree.git 9647T: git git://linuxtv.org/media_tree.git
9638W: http://linuxtv.org 9648W: https://linuxtv.org
9639S: Odd Fixes 9649S: Odd Fixes
9640F: drivers/media/radio/si470x/radio-si470x-i2c.c 9650F: drivers/media/radio/si470x/radio-si470x-i2c.c
9641 9651
@@ -9643,7 +9653,7 @@ SI470X FM RADIO RECEIVER USB DRIVER
9643M: Hans Verkuil <hverkuil@xs4all.nl> 9653M: Hans Verkuil <hverkuil@xs4all.nl>
9644L: linux-media@vger.kernel.org 9654L: linux-media@vger.kernel.org
9645T: git git://linuxtv.org/media_tree.git 9655T: git git://linuxtv.org/media_tree.git
9646W: http://linuxtv.org 9656W: https://linuxtv.org
9647S: Maintained 9657S: Maintained
9648F: drivers/media/radio/si470x/radio-si470x-common.c 9658F: drivers/media/radio/si470x/radio-si470x-common.c
9649F: drivers/media/radio/si470x/radio-si470x.h 9659F: drivers/media/radio/si470x/radio-si470x.h
@@ -9653,7 +9663,7 @@ SI4713 FM RADIO TRANSMITTER I2C DRIVER
9653M: Eduardo Valentin <edubezval@gmail.com> 9663M: Eduardo Valentin <edubezval@gmail.com>
9654L: linux-media@vger.kernel.org 9664L: linux-media@vger.kernel.org
9655T: git git://linuxtv.org/media_tree.git 9665T: git git://linuxtv.org/media_tree.git
9656W: http://linuxtv.org 9666W: https://linuxtv.org
9657S: Odd Fixes 9667S: Odd Fixes
9658F: drivers/media/radio/si4713/si4713.? 9668F: drivers/media/radio/si4713/si4713.?
9659 9669
@@ -9661,7 +9671,7 @@ SI4713 FM RADIO TRANSMITTER PLATFORM DRIVER
9661M: Eduardo Valentin <edubezval@gmail.com> 9671M: Eduardo Valentin <edubezval@gmail.com>
9662L: linux-media@vger.kernel.org 9672L: linux-media@vger.kernel.org
9663T: git git://linuxtv.org/media_tree.git 9673T: git git://linuxtv.org/media_tree.git
9664W: http://linuxtv.org 9674W: https://linuxtv.org
9665S: Odd Fixes 9675S: Odd Fixes
9666F: drivers/media/radio/si4713/radio-platform-si4713.c 9676F: drivers/media/radio/si4713/radio-platform-si4713.c
9667 9677
@@ -9669,14 +9679,14 @@ SI4713 FM RADIO TRANSMITTER USB DRIVER
9669M: Hans Verkuil <hverkuil@xs4all.nl> 9679M: Hans Verkuil <hverkuil@xs4all.nl>
9670L: linux-media@vger.kernel.org 9680L: linux-media@vger.kernel.org
9671T: git git://linuxtv.org/media_tree.git 9681T: git git://linuxtv.org/media_tree.git
9672W: http://linuxtv.org 9682W: https://linuxtv.org
9673S: Maintained 9683S: Maintained
9674F: drivers/media/radio/si4713/radio-usb-si4713.c 9684F: drivers/media/radio/si4713/radio-usb-si4713.c
9675 9685
9676SIANO DVB DRIVER 9686SIANO DVB DRIVER
9677M: Mauro Carvalho Chehab <mchehab@osg.samsung.com> 9687M: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
9678L: linux-media@vger.kernel.org 9688L: linux-media@vger.kernel.org
9679W: http://linuxtv.org 9689W: https://linuxtv.org
9680T: git git://linuxtv.org/media_tree.git 9690T: git git://linuxtv.org/media_tree.git
9681S: Odd fixes 9691S: Odd fixes
9682F: drivers/media/common/siano/ 9692F: drivers/media/common/siano/
@@ -9701,7 +9711,7 @@ SH_VOU V4L2 OUTPUT DRIVER
9701L: linux-media@vger.kernel.org 9711L: linux-media@vger.kernel.org
9702S: Orphan 9712S: Orphan
9703F: drivers/media/platform/sh_vou.c 9713F: drivers/media/platform/sh_vou.c
9704F: include/media/sh_vou.h 9714F: include/media/drv-intf/sh_vou.h
9705 9715
9706SIMPLE FIRMWARE INTERFACE (SFI) 9716SIMPLE FIRMWARE INTERFACE (SFI)
9707M: Len Brown <lenb@kernel.org> 9717M: Len Brown <lenb@kernel.org>
@@ -9742,7 +9752,7 @@ F: drivers/i2c/busses/i2c-davinci.c
9742TI DAVINCI SERIES MEDIA DRIVER 9752TI DAVINCI SERIES MEDIA DRIVER
9743M: "Lad, Prabhakar" <prabhakar.csengg@gmail.com> 9753M: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
9744L: linux-media@vger.kernel.org 9754L: linux-media@vger.kernel.org
9745W: http://linuxtv.org/ 9755W: https://linuxtv.org
9746Q: http://patchwork.linuxtv.org/project/linux-media/list/ 9756Q: http://patchwork.linuxtv.org/project/linux-media/list/
9747T: git git://linuxtv.org/mhadli/v4l-dvb-davinci_devices.git 9757T: git git://linuxtv.org/mhadli/v4l-dvb-davinci_devices.git
9748S: Maintained 9758S: Maintained
@@ -9752,7 +9762,7 @@ F: include/media/davinci/
9752TI AM437X VPFE DRIVER 9762TI AM437X VPFE DRIVER
9753M: "Lad, Prabhakar" <prabhakar.csengg@gmail.com> 9763M: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
9754L: linux-media@vger.kernel.org 9764L: linux-media@vger.kernel.org
9755W: http://linuxtv.org/ 9765W: https://linuxtv.org
9756Q: http://patchwork.linuxtv.org/project/linux-media/list/ 9766Q: http://patchwork.linuxtv.org/project/linux-media/list/
9757T: git git://linuxtv.org/mhadli/v4l-dvb-davinci_devices.git 9767T: git git://linuxtv.org/mhadli/v4l-dvb-davinci_devices.git
9758S: Maintained 9768S: Maintained
@@ -9761,12 +9771,12 @@ F: drivers/media/platform/am437x/
9761OV2659 OMNIVISION SENSOR DRIVER 9771OV2659 OMNIVISION SENSOR DRIVER
9762M: "Lad, Prabhakar" <prabhakar.csengg@gmail.com> 9772M: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
9763L: linux-media@vger.kernel.org 9773L: linux-media@vger.kernel.org
9764W: http://linuxtv.org/ 9774W: https://linuxtv.org
9765Q: http://patchwork.linuxtv.org/project/linux-media/list/ 9775Q: http://patchwork.linuxtv.org/project/linux-media/list/
9766T: git git://linuxtv.org/mhadli/v4l-dvb-davinci_devices.git 9776T: git git://linuxtv.org/mhadli/v4l-dvb-davinci_devices.git
9767S: Maintained 9777S: Maintained
9768F: drivers/media/i2c/ov2659.c 9778F: drivers/media/i2c/ov2659.c
9769F: include/media/ov2659.h 9779F: include/media/i2c/ov2659.h
9770 9780
9771SILICON MOTION SM712 FRAME BUFFER DRIVER 9781SILICON MOTION SM712 FRAME BUFFER DRIVER
9772M: Sudip Mukherjee <sudipm.mukherjee@gmail.com> 9782M: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
@@ -9855,7 +9865,7 @@ M: Sakari Ailus <sakari.ailus@iki.fi>
9855L: linux-media@vger.kernel.org 9865L: linux-media@vger.kernel.org
9856S: Maintained 9866S: Maintained
9857F: drivers/media/i2c/smiapp/ 9867F: drivers/media/i2c/smiapp/
9858F: include/media/smiapp.h 9868F: include/media/i2c/smiapp.h
9859F: drivers/media/i2c/smiapp-pll.c 9869F: drivers/media/i2c/smiapp-pll.c
9860F: drivers/media/i2c/smiapp-pll.h 9870F: drivers/media/i2c/smiapp-pll.h
9861F: include/uapi/linux/smiapp.h 9871F: include/uapi/linux/smiapp.h
@@ -10019,7 +10029,7 @@ F: sound/soc/soc-generic-dmaengine-pcm.c
10019SP2 MEDIA DRIVER 10029SP2 MEDIA DRIVER
10020M: Olli Salonen <olli.salonen@iki.fi> 10030M: Olli Salonen <olli.salonen@iki.fi>
10021L: linux-media@vger.kernel.org 10031L: linux-media@vger.kernel.org
10022W: http://linuxtv.org/ 10032W: https://linuxtv.org
10023Q: http://patchwork.linuxtv.org/project/linux-media/list/ 10033Q: http://patchwork.linuxtv.org/project/linux-media/list/
10024S: Maintained 10034S: Maintained
10025F: drivers/media/dvb-frontends/sp2* 10035F: drivers/media/dvb-frontends/sp2*
@@ -10381,7 +10391,7 @@ F: net/ipv4/tcp_lp.c
10381TDA10071 MEDIA DRIVER 10391TDA10071 MEDIA DRIVER
10382M: Antti Palosaari <crope@iki.fi> 10392M: Antti Palosaari <crope@iki.fi>
10383L: linux-media@vger.kernel.org 10393L: linux-media@vger.kernel.org
10384W: http://linuxtv.org/ 10394W: https://linuxtv.org
10385W: http://palosaari.fi/linux/ 10395W: http://palosaari.fi/linux/
10386Q: http://patchwork.linuxtv.org/project/linux-media/list/ 10396Q: http://patchwork.linuxtv.org/project/linux-media/list/
10387T: git git://linuxtv.org/anttip/media_tree.git 10397T: git git://linuxtv.org/anttip/media_tree.git
@@ -10391,7 +10401,7 @@ F: drivers/media/dvb-frontends/tda10071*
10391TDA18212 MEDIA DRIVER 10401TDA18212 MEDIA DRIVER
10392M: Antti Palosaari <crope@iki.fi> 10402M: Antti Palosaari <crope@iki.fi>
10393L: linux-media@vger.kernel.org 10403L: linux-media@vger.kernel.org
10394W: http://linuxtv.org/ 10404W: https://linuxtv.org
10395W: http://palosaari.fi/linux/ 10405W: http://palosaari.fi/linux/
10396Q: http://patchwork.linuxtv.org/project/linux-media/list/ 10406Q: http://patchwork.linuxtv.org/project/linux-media/list/
10397T: git git://linuxtv.org/anttip/media_tree.git 10407T: git git://linuxtv.org/anttip/media_tree.git
@@ -10401,7 +10411,7 @@ F: drivers/media/tuners/tda18212*
10401TDA18218 MEDIA DRIVER 10411TDA18218 MEDIA DRIVER
10402M: Antti Palosaari <crope@iki.fi> 10412M: Antti Palosaari <crope@iki.fi>
10403L: linux-media@vger.kernel.org 10413L: linux-media@vger.kernel.org
10404W: http://linuxtv.org/ 10414W: https://linuxtv.org
10405W: http://palosaari.fi/linux/ 10415W: http://palosaari.fi/linux/
10406Q: http://patchwork.linuxtv.org/project/linux-media/list/ 10416Q: http://patchwork.linuxtv.org/project/linux-media/list/
10407T: git git://linuxtv.org/anttip/media_tree.git 10417T: git git://linuxtv.org/anttip/media_tree.git
@@ -10411,7 +10421,7 @@ F: drivers/media/tuners/tda18218*
10411TDA18271 MEDIA DRIVER 10421TDA18271 MEDIA DRIVER
10412M: Michael Krufky <mkrufky@linuxtv.org> 10422M: Michael Krufky <mkrufky@linuxtv.org>
10413L: linux-media@vger.kernel.org 10423L: linux-media@vger.kernel.org
10414W: http://linuxtv.org/ 10424W: https://linuxtv.org
10415W: http://github.com/mkrufky 10425W: http://github.com/mkrufky
10416Q: http://patchwork.linuxtv.org/project/linux-media/list/ 10426Q: http://patchwork.linuxtv.org/project/linux-media/list/
10417T: git git://linuxtv.org/mkrufky/tuners.git 10427T: git git://linuxtv.org/mkrufky/tuners.git
@@ -10421,7 +10431,7 @@ F: drivers/media/tuners/tda18271*
10421TDA827x MEDIA DRIVER 10431TDA827x MEDIA DRIVER
10422M: Michael Krufky <mkrufky@linuxtv.org> 10432M: Michael Krufky <mkrufky@linuxtv.org>
10423L: linux-media@vger.kernel.org 10433L: linux-media@vger.kernel.org
10424W: http://linuxtv.org/ 10434W: https://linuxtv.org
10425W: http://github.com/mkrufky 10435W: http://github.com/mkrufky
10426Q: http://patchwork.linuxtv.org/project/linux-media/list/ 10436Q: http://patchwork.linuxtv.org/project/linux-media/list/
10427T: git git://linuxtv.org/mkrufky/tuners.git 10437T: git git://linuxtv.org/mkrufky/tuners.git
@@ -10431,7 +10441,7 @@ F: drivers/media/tuners/tda8290.*
10431TDA8290 MEDIA DRIVER 10441TDA8290 MEDIA DRIVER
10432M: Michael Krufky <mkrufky@linuxtv.org> 10442M: Michael Krufky <mkrufky@linuxtv.org>
10433L: linux-media@vger.kernel.org 10443L: linux-media@vger.kernel.org
10434W: http://linuxtv.org/ 10444W: https://linuxtv.org
10435W: http://github.com/mkrufky 10445W: http://github.com/mkrufky
10436Q: http://patchwork.linuxtv.org/project/linux-media/list/ 10446Q: http://patchwork.linuxtv.org/project/linux-media/list/
10437T: git git://linuxtv.org/mkrufky/tuners.git 10447T: git git://linuxtv.org/mkrufky/tuners.git
@@ -10442,14 +10452,14 @@ TDA9840 MEDIA DRIVER
10442M: Hans Verkuil <hverkuil@xs4all.nl> 10452M: Hans Verkuil <hverkuil@xs4all.nl>
10443L: linux-media@vger.kernel.org 10453L: linux-media@vger.kernel.org
10444T: git git://linuxtv.org/media_tree.git 10454T: git git://linuxtv.org/media_tree.git
10445W: http://linuxtv.org 10455W: https://linuxtv.org
10446S: Maintained 10456S: Maintained
10447F: drivers/media/i2c/tda9840* 10457F: drivers/media/i2c/tda9840*
10448 10458
10449TEA5761 TUNER DRIVER 10459TEA5761 TUNER DRIVER
10450M: Mauro Carvalho Chehab <mchehab@osg.samsung.com> 10460M: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
10451L: linux-media@vger.kernel.org 10461L: linux-media@vger.kernel.org
10452W: http://linuxtv.org 10462W: https://linuxtv.org
10453T: git git://linuxtv.org/media_tree.git 10463T: git git://linuxtv.org/media_tree.git
10454S: Odd fixes 10464S: Odd fixes
10455F: drivers/media/tuners/tea5761.* 10465F: drivers/media/tuners/tea5761.*
@@ -10457,7 +10467,7 @@ F: drivers/media/tuners/tea5761.*
10457TEA5767 TUNER DRIVER 10467TEA5767 TUNER DRIVER
10458M: Mauro Carvalho Chehab <mchehab@osg.samsung.com> 10468M: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
10459L: linux-media@vger.kernel.org 10469L: linux-media@vger.kernel.org
10460W: http://linuxtv.org 10470W: https://linuxtv.org
10461T: git git://linuxtv.org/media_tree.git 10471T: git git://linuxtv.org/media_tree.git
10462S: Maintained 10472S: Maintained
10463F: drivers/media/tuners/tea5767.* 10473F: drivers/media/tuners/tea5767.*
@@ -10466,7 +10476,7 @@ TEA6415C MEDIA DRIVER
10466M: Hans Verkuil <hverkuil@xs4all.nl> 10476M: Hans Verkuil <hverkuil@xs4all.nl>
10467L: linux-media@vger.kernel.org 10477L: linux-media@vger.kernel.org
10468T: git git://linuxtv.org/media_tree.git 10478T: git git://linuxtv.org/media_tree.git
10469W: http://linuxtv.org 10479W: https://linuxtv.org
10470S: Maintained 10480S: Maintained
10471F: drivers/media/i2c/tea6415c* 10481F: drivers/media/i2c/tea6415c*
10472 10482
@@ -10474,7 +10484,7 @@ TEA6420 MEDIA DRIVER
10474M: Hans Verkuil <hverkuil@xs4all.nl> 10484M: Hans Verkuil <hverkuil@xs4all.nl>
10475L: linux-media@vger.kernel.org 10485L: linux-media@vger.kernel.org
10476T: git git://linuxtv.org/media_tree.git 10486T: git git://linuxtv.org/media_tree.git
10477W: http://linuxtv.org 10487W: https://linuxtv.org
10478S: Maintained 10488S: Maintained
10479F: drivers/media/i2c/tea6420* 10489F: drivers/media/i2c/tea6420*
10480 10490
@@ -10572,7 +10582,7 @@ THANKO'S RAREMONO AM/FM/SW RADIO RECEIVER USB DRIVER
10572M: Hans Verkuil <hverkuil@xs4all.nl> 10582M: Hans Verkuil <hverkuil@xs4all.nl>
10573L: linux-media@vger.kernel.org 10583L: linux-media@vger.kernel.org
10574T: git git://linuxtv.org/media_tree.git 10584T: git git://linuxtv.org/media_tree.git
10575W: http://linuxtv.org 10585W: https://linuxtv.org
10576S: Maintained 10586S: Maintained
10577F: drivers/media/radio/radio-raremono.c 10587F: drivers/media/radio/radio-raremono.c
10578 10588
@@ -10796,7 +10806,7 @@ M: Mats Randgaard <matrandg@cisco.com>
10796L: linux-media@vger.kernel.org 10806L: linux-media@vger.kernel.org
10797S: Maintained 10807S: Maintained
10798F: drivers/media/i2c/tc358743* 10808F: drivers/media/i2c/tc358743*
10799F: include/media/tc358743.h 10809F: include/media/i2c/tc358743.h
10800 10810
10801TMIO MMC DRIVER 10811TMIO MMC DRIVER
10802M: Ian Molton <ian@mnementh.co.uk> 10812M: Ian Molton <ian@mnementh.co.uk>
@@ -10824,7 +10834,7 @@ F: mm/shmem.c
10824TM6000 VIDEO4LINUX DRIVER 10834TM6000 VIDEO4LINUX DRIVER
10825M: Mauro Carvalho Chehab <mchehab@osg.samsung.com> 10835M: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
10826L: linux-media@vger.kernel.org 10836L: linux-media@vger.kernel.org
10827W: http://linuxtv.org 10837W: https://linuxtv.org
10828T: git git://linuxtv.org/media_tree.git 10838T: git git://linuxtv.org/media_tree.git
10829S: Odd fixes 10839S: Odd fixes
10830F: drivers/media/usb/tm6000/ 10840F: drivers/media/usb/tm6000/
@@ -10833,7 +10843,7 @@ TW68 VIDEO4LINUX DRIVER
10833M: Hans Verkuil <hverkuil@xs4all.nl> 10843M: Hans Verkuil <hverkuil@xs4all.nl>
10834L: linux-media@vger.kernel.org 10844L: linux-media@vger.kernel.org
10835T: git git://linuxtv.org/media_tree.git 10845T: git git://linuxtv.org/media_tree.git
10836W: http://linuxtv.org 10846W: https://linuxtv.org
10837S: Odd Fixes 10847S: Odd Fixes
10838F: drivers/media/pci/tw68/ 10848F: drivers/media/pci/tw68/
10839 10849
@@ -10894,7 +10904,7 @@ F: include/uapi/linux/tty.h
10894TUA9001 MEDIA DRIVER 10904TUA9001 MEDIA DRIVER
10895M: Antti Palosaari <crope@iki.fi> 10905M: Antti Palosaari <crope@iki.fi>
10896L: linux-media@vger.kernel.org 10906L: linux-media@vger.kernel.org
10897W: http://linuxtv.org/ 10907W: https://linuxtv.org
10898W: http://palosaari.fi/linux/ 10908W: http://palosaari.fi/linux/
10899Q: http://patchwork.linuxtv.org/project/linux-media/list/ 10909Q: http://patchwork.linuxtv.org/project/linux-media/list/
10900T: git git://linuxtv.org/anttip/media_tree.git 10910T: git git://linuxtv.org/anttip/media_tree.git
@@ -11241,7 +11251,7 @@ USB VISION DRIVER
11241M: Hans Verkuil <hverkuil@xs4all.nl> 11251M: Hans Verkuil <hverkuil@xs4all.nl>
11242L: linux-media@vger.kernel.org 11252L: linux-media@vger.kernel.org
11243T: git git://linuxtv.org/media_tree.git 11253T: git git://linuxtv.org/media_tree.git
11244W: http://linuxtv.org 11254W: https://linuxtv.org
11245S: Odd Fixes 11255S: Odd Fixes
11246F: drivers/media/usb/usbvision/ 11256F: drivers/media/usb/usbvision/
11247 11257
@@ -11455,7 +11465,7 @@ VIVID VIRTUAL VIDEO DRIVER
11455M: Hans Verkuil <hverkuil@xs4all.nl> 11465M: Hans Verkuil <hverkuil@xs4all.nl>
11456L: linux-media@vger.kernel.org 11466L: linux-media@vger.kernel.org
11457T: git git://linuxtv.org/media_tree.git 11467T: git git://linuxtv.org/media_tree.git
11458W: http://linuxtv.org 11468W: https://linuxtv.org
11459S: Maintained 11469S: Maintained
11460F: drivers/media/platform/vivid/* 11470F: drivers/media/platform/vivid/*
11461 11471
@@ -11744,7 +11754,7 @@ F: arch/x86/entry/vdso/
11744XC2028/3028 TUNER DRIVER 11754XC2028/3028 TUNER DRIVER
11745M: Mauro Carvalho Chehab <mchehab@osg.samsung.com> 11755M: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
11746L: linux-media@vger.kernel.org 11756L: linux-media@vger.kernel.org
11747W: http://linuxtv.org 11757W: https://linuxtv.org
11748T: git git://linuxtv.org/media_tree.git 11758T: git git://linuxtv.org/media_tree.git
11749S: Maintained 11759S: Maintained
11750F: drivers/media/tuners/tuner-xc2028.* 11760F: drivers/media/tuners/tuner-xc2028.*
@@ -11913,7 +11923,7 @@ ZR36067 VIDEO FOR LINUX DRIVER
11913L: mjpeg-users@lists.sourceforge.net 11923L: mjpeg-users@lists.sourceforge.net
11914L: linux-media@vger.kernel.org 11924L: linux-media@vger.kernel.org
11915W: http://mjpeg.sourceforge.net/driver-zoran/ 11925W: http://mjpeg.sourceforge.net/driver-zoran/
11916T: hg http://linuxtv.org/hg/v4l-dvb 11926T: hg https://linuxtv.org/hg/v4l-dvb
11917S: Odd Fixes 11927S: Odd Fixes
11918F: drivers/media/pci/zoran/ 11928F: drivers/media/pci/zoran/
11919 11929
diff --git a/arch/arm/boot/dts/stihxxx-b2120.dtsi b/arch/arm/boot/dts/stihxxx-b2120.dtsi
index ad21a4293a33..133375bc8aa5 100644
--- a/arch/arm/boot/dts/stihxxx-b2120.dtsi
+++ b/arch/arm/boot/dts/stihxxx-b2120.dtsi
@@ -6,6 +6,9 @@
6 * it under the terms of the GNU General Public License version 2 as 6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 */ 8 */
9#include <dt-bindings/clock/stih407-clks.h>
10#include <dt-bindings/gpio/gpio.h>
11#include <dt-bindings/media/c8sectpfe.h>
9/ { 12/ {
10 soc { 13 soc {
11 sbc_serial0: serial@9530000 { 14 sbc_serial0: serial@9530000 {
@@ -35,12 +38,18 @@
35 status = "okay"; 38 status = "okay";
36 }; 39 };
37 40
38 i2c@9842000 { 41 ssc2: i2c@9842000 {
39 status = "okay"; 42 status = "okay";
43 clock-frequency = <100000>;
44 st,i2c-min-scl-pulse-width-us = <0>;
45 st,i2c-min-sda-pulse-width-us = <5>;
40 }; 46 };
41 47
42 i2c@9843000 { 48 ssc3: i2c@9843000 {
43 status = "okay"; 49 status = "okay";
50 clock-frequency = <100000>;
51 st,i2c-min-scl-pulse-width-us = <0>;
52 st,i2c-min-sda-pulse-width-us = <5>;
44 }; 53 };
45 54
46 i2c@9844000 { 55 i2c@9844000 {
@@ -93,5 +102,38 @@
93 phy-mode = "rgmii"; 102 phy-mode = "rgmii";
94 fixed-link = <0 1 1000 0 0>; 103 fixed-link = <0 1 1000 0 0>;
95 }; 104 };
105
106 demux@08a20000 {
107 compatible = "st,stih407-c8sectpfe";
108 status = "okay";
109 reg = <0x08a20000 0x10000>,
110 <0x08a00000 0x4000>;
111 reg-names = "c8sectpfe", "c8sectpfe-ram";
112 interrupts = <GIC_SPI 34 IRQ_TYPE_NONE>,
113 <GIC_SPI 35 IRQ_TYPE_NONE>;
114 interrupt-names = "c8sectpfe-error-irq",
115 "c8sectpfe-idle-irq";
116 pinctrl-0 = <&pinctrl_tsin0_serial>;
117 pinctrl-1 = <&pinctrl_tsin0_parallel>;
118 pinctrl-2 = <&pinctrl_tsin3_serial>;
119 pinctrl-3 = <&pinctrl_tsin4_serial_alt3>;
120 pinctrl-4 = <&pinctrl_tsin5_serial_alt1>;
121 pinctrl-names = "tsin0-serial",
122 "tsin0-parallel",
123 "tsin3-serial",
124 "tsin4-serial",
125 "tsin5-serial";
126 clocks = <&clk_s_c0_flexgen CLK_PROC_STFE>;
127 clock-names = "c8sectpfe";
128
129 /* tsin0 is TSA on NIMA */
130 tsin0: port@0 {
131 tsin-num = <0>;
132 serial-not-parallel;
133 i2c-bus = <&ssc2>;
134 reset-gpios = <&pio15 4 GPIO_ACTIVE_HIGH>;
135 dvb-card = <STV0367_TDA18212_NIMA_1>;
136 };
137 };
96 }; 138 };
97}; 139};
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index 1ed545cc2b83..9cc7b818fbf6 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -49,8 +49,8 @@
49#include <asm/mach/arch.h> 49#include <asm/mach/arch.h>
50#include <asm/system_info.h> 50#include <asm/system_info.h>
51 51
52#include <media/tvp514x.h> 52#include <media/i2c/tvp514x.h>
53#include <media/adv7343.h> 53#include <media/i2c/adv7343.h>
54 54
55#define DA850_EVM_PHY_ID "davinci_mdio-0:00" 55#define DA850_EVM_PHY_ID "davinci_mdio-0:00"
56#define DA850_LCD_PWR_PIN GPIO_TO_PIN(2, 8) 56#define DA850_LCD_PWR_PIN GPIO_TO_PIN(2, 8)
diff --git a/arch/arm/mach-davinci/board-dm355-evm.c b/arch/arm/mach-davinci/board-dm355-evm.c
index b46b4d25f93e..c71dd9982f03 100644
--- a/arch/arm/mach-davinci/board-dm355-evm.c
+++ b/arch/arm/mach-davinci/board-dm355-evm.c
@@ -19,7 +19,7 @@
19#include <linux/gpio.h> 19#include <linux/gpio.h>
20#include <linux/clk.h> 20#include <linux/clk.h>
21#include <linux/videodev2.h> 21#include <linux/videodev2.h>
22#include <media/tvp514x.h> 22#include <media/i2c/tvp514x.h>
23#include <linux/spi/spi.h> 23#include <linux/spi/spi.h>
24#include <linux/spi/eeprom.h> 24#include <linux/spi/eeprom.h>
25#include <linux/platform_data/gpio-davinci.h> 25#include <linux/platform_data/gpio-davinci.h>
diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c
index a756003595e9..f073518f621a 100644
--- a/arch/arm/mach-davinci/board-dm365-evm.c
+++ b/arch/arm/mach-davinci/board-dm365-evm.c
@@ -40,8 +40,8 @@
40#include <linux/platform_data/mtd-davinci.h> 40#include <linux/platform_data/mtd-davinci.h>
41#include <linux/platform_data/keyscan-davinci.h> 41#include <linux/platform_data/keyscan-davinci.h>
42 42
43#include <media/ths7303.h> 43#include <media/i2c/ths7303.h>
44#include <media/tvp514x.h> 44#include <media/i2c/tvp514x.h>
45 45
46#include "davinci.h" 46#include "davinci.h"
47 47
diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
index bbdd2d614b49..7a20507a3eef 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -26,7 +26,7 @@
26#include <linux/v4l2-dv-timings.h> 26#include <linux/v4l2-dv-timings.h>
27#include <linux/export.h> 27#include <linux/export.h>
28 28
29#include <media/tvp514x.h> 29#include <media/i2c/tvp514x.h>
30 30
31#include <asm/mach-types.h> 31#include <asm/mach-types.h>
32#include <asm/mach/arch.h> 32#include <asm/mach/arch.h>
diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c
index 846a84ddc28e..ee6ab7e8d3b0 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -25,8 +25,8 @@
25#include <linux/platform_data/at24.h> 25#include <linux/platform_data/at24.h>
26#include <linux/i2c/pcf857x.h> 26#include <linux/i2c/pcf857x.h>
27 27
28#include <media/tvp514x.h> 28#include <media/i2c/tvp514x.h>
29#include <media/adv7343.h> 29#include <media/i2c/adv7343.h>
30 30
31#include <linux/mtd/mtd.h> 31#include <linux/mtd/mtd.h>
32#include <linux/mtd/nand.h> 32#include <linux/mtd/nand.h>
diff --git a/arch/arm/mach-imx/devices/devices-common.h b/arch/arm/mach-imx/devices/devices-common.h
index 67f7fb13050d..09cebd8cef2b 100644
--- a/arch/arm/mach-imx/devices/devices-common.h
+++ b/arch/arm/mach-imx/devices/devices-common.h
@@ -177,7 +177,7 @@ struct platform_device *__init imx_add_imx_uart_1irq(
177 const struct imxuart_platform_data *pdata); 177 const struct imxuart_platform_data *pdata);
178 178
179#include <linux/platform_data/video-mx3fb.h> 179#include <linux/platform_data/video-mx3fb.h>
180#include <linux/platform_data/camera-mx3.h> 180#include <linux/platform_data/media/camera-mx3.h>
181struct imx_ipu_core_data { 181struct imx_ipu_core_data {
182 resource_size_t iobase; 182 resource_size_t iobase;
183 resource_size_t synirq; 183 resource_size_t synirq;
@@ -192,7 +192,7 @@ struct platform_device *__init imx_add_mx3_sdc_fb(
192 const struct imx_ipu_core_data *data, 192 const struct imx_ipu_core_data *data,
193 struct mx3fb_platform_data *pdata); 193 struct mx3fb_platform_data *pdata);
194 194
195#include <linux/platform_data/camera-mx2.h> 195#include <linux/platform_data/media/camera-mx2.h>
196struct imx_mx2_camera_data { 196struct imx_mx2_camera_data {
197 const char *devid; 197 const char *devid;
198 resource_size_t iobasecsi; 198 resource_size_t iobasecsi;
diff --git a/arch/arm/mach-omap1/include/mach/camera.h b/arch/arm/mach-omap1/include/mach/camera.h
index 847d00f0bb0a..caa6c0d6f0ac 100644
--- a/arch/arm/mach-omap1/include/mach/camera.h
+++ b/arch/arm/mach-omap1/include/mach/camera.h
@@ -1,7 +1,7 @@
1#ifndef __ASM_ARCH_CAMERA_H_ 1#ifndef __ASM_ARCH_CAMERA_H_
2#define __ASM_ARCH_CAMERA_H_ 2#define __ASM_ARCH_CAMERA_H_
3 3
4#include <media/omap1_camera.h> 4#include <linux/platform_data/media/omap1_camera.h>
5 5
6void omap1_camera_init(void *); 6void omap1_camera_init(void *);
7 7
diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index 14edcd7a2a1d..0a0567f8e8a0 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -39,7 +39,7 @@
39 39
40#include <sound/tlv320aic3x.h> 40#include <sound/tlv320aic3x.h>
41#include <sound/tpa6130a2-plat.h> 41#include <sound/tpa6130a2-plat.h>
42#include <media/si4713.h> 42#include <linux/platform_data/media/si4713.h>
43#include <linux/platform_data/leds-lp55xx.h> 43#include <linux/platform_data/leds-lp55xx.h>
44 44
45#include <linux/platform_data/tsl2563.h> 45#include <linux/platform_data/tsl2563.h>
@@ -48,7 +48,7 @@
48#include <video/omap-panel-data.h> 48#include <video/omap-panel-data.h>
49 49
50#if defined(CONFIG_IR_RX51) || defined(CONFIG_IR_RX51_MODULE) 50#if defined(CONFIG_IR_RX51) || defined(CONFIG_IR_RX51_MODULE)
51#include <media/ir-rx51.h> 51#include <linux/platform_data/media/ir-rx51.h>
52#endif 52#endif
53 53
54#include "mux.h" 54#include "mux.h"
diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index 2a6e0ae2b920..d1211a40f400 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -14,7 +14,7 @@
14#include <mach/irqs.h> 14#include <mach/irqs.h>
15#include <linux/platform_data/usb-ohci-pxa27x.h> 15#include <linux/platform_data/usb-ohci-pxa27x.h>
16#include <linux/platform_data/keypad-pxa27x.h> 16#include <linux/platform_data/keypad-pxa27x.h>
17#include <linux/platform_data/camera-pxa.h> 17#include <linux/platform_data/media/camera-pxa.h>
18#include <mach/audio.h> 18#include <mach/audio.h>
19#include <mach/hardware.h> 19#include <mach/hardware.h>
20#include <linux/platform_data/mmp_dma.h> 20#include <linux/platform_data/mmp_dma.h>
diff --git a/arch/arm/mach-pxa/em-x270.c b/arch/arm/mach-pxa/em-x270.c
index 9d7072b04045..8b1f89e096c6 100644
--- a/arch/arm/mach-pxa/em-x270.c
+++ b/arch/arm/mach-pxa/em-x270.c
@@ -46,7 +46,7 @@
46#include <linux/platform_data/usb-ohci-pxa27x.h> 46#include <linux/platform_data/usb-ohci-pxa27x.h>
47#include <linux/platform_data/mmc-pxamci.h> 47#include <linux/platform_data/mmc-pxamci.h>
48#include <linux/platform_data/keypad-pxa27x.h> 48#include <linux/platform_data/keypad-pxa27x.h>
49#include <linux/platform_data/camera-pxa.h> 49#include <linux/platform_data/media/camera-pxa.h>
50 50
51#include "generic.h" 51#include "generic.h"
52#include "devices.h" 52#include "devices.h"
diff --git a/arch/arm/mach-pxa/ezx.c b/arch/arm/mach-pxa/ezx.c
index 7c0d5618be5e..cd6224032109 100644
--- a/arch/arm/mach-pxa/ezx.c
+++ b/arch/arm/mach-pxa/ezx.c
@@ -34,7 +34,7 @@
34#include <linux/platform_data/usb-ohci-pxa27x.h> 34#include <linux/platform_data/usb-ohci-pxa27x.h>
35#include <mach/hardware.h> 35#include <mach/hardware.h>
36#include <linux/platform_data/keypad-pxa27x.h> 36#include <linux/platform_data/keypad-pxa27x.h>
37#include <linux/platform_data/camera-pxa.h> 37#include <linux/platform_data/media/camera-pxa.h>
38 38
39#include "devices.h" 39#include "devices.h"
40#include "generic.h" 40#include "generic.h"
diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
index 3b52b1aa0659..ccfd2b63c6a4 100644
--- a/arch/arm/mach-pxa/mioa701.c
+++ b/arch/arm/mach-pxa/mioa701.c
@@ -54,7 +54,7 @@
54#include <linux/platform_data/mmc-pxamci.h> 54#include <linux/platform_data/mmc-pxamci.h>
55#include <mach/udc.h> 55#include <mach/udc.h>
56#include <mach/pxa27x-udc.h> 56#include <mach/pxa27x-udc.h>
57#include <linux/platform_data/camera-pxa.h> 57#include <linux/platform_data/media/camera-pxa.h>
58#include <mach/audio.h> 58#include <mach/audio.h>
59#include <mach/smemc.h> 59#include <mach/smemc.h>
60#include <media/soc_camera.h> 60#include <media/soc_camera.h>
diff --git a/arch/arm/mach-pxa/palmtreo.c b/arch/arm/mach-pxa/palmtreo.c
index d8b937c870de..2dc56062fb7e 100644
--- a/arch/arm/mach-pxa/palmtreo.c
+++ b/arch/arm/mach-pxa/palmtreo.c
@@ -43,7 +43,7 @@
43#include <linux/platform_data/usb-ohci-pxa27x.h> 43#include <linux/platform_data/usb-ohci-pxa27x.h>
44#include <mach/pxa2xx-regs.h> 44#include <mach/pxa2xx-regs.h>
45#include <linux/platform_data/asoc-palm27x.h> 45#include <linux/platform_data/asoc-palm27x.h>
46#include <linux/platform_data/camera-pxa.h> 46#include <linux/platform_data/media/camera-pxa.h>
47#include <mach/palm27x.h> 47#include <mach/palm27x.h>
48 48
49#include <sound/pxa2xx-lib.h> 49#include <sound/pxa2xx-lib.h>
diff --git a/arch/arm/mach-pxa/palmz72.c b/arch/arm/mach-pxa/palmz72.c
index 1a35ddf218da..e3df17a7e8d4 100644
--- a/arch/arm/mach-pxa/palmz72.c
+++ b/arch/arm/mach-pxa/palmz72.c
@@ -49,7 +49,7 @@
49#include <mach/palm27x.h> 49#include <mach/palm27x.h>
50 50
51#include <mach/pm.h> 51#include <mach/pm.h>
52#include <linux/platform_data/camera-pxa.h> 52#include <linux/platform_data/media/camera-pxa.h>
53 53
54#include <media/soc_camera.h> 54#include <media/soc_camera.h>
55 55
diff --git a/arch/arm/mach-pxa/pcm990-baseboard.c b/arch/arm/mach-pxa/pcm990-baseboard.c
index b71c96f614f9..8459239a093c 100644
--- a/arch/arm/mach-pxa/pcm990-baseboard.c
+++ b/arch/arm/mach-pxa/pcm990-baseboard.c
@@ -27,10 +27,10 @@
27#include <linux/pwm.h> 27#include <linux/pwm.h>
28#include <linux/pwm_backlight.h> 28#include <linux/pwm_backlight.h>
29 29
30#include <media/mt9v022.h> 30#include <media/i2c/mt9v022.h>
31#include <media/soc_camera.h> 31#include <media/soc_camera.h>
32 32
33#include <linux/platform_data/camera-pxa.h> 33#include <linux/platform_data/media/camera-pxa.h>
34#include <asm/mach/map.h> 34#include <asm/mach/map.h>
35#include <mach/pxa27x.h> 35#include <mach/pxa27x.h>
36#include <mach/audio.h> 36#include <mach/audio.h>
diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c
index 82074625de5c..74ef8891254e 100644
--- a/arch/arm/plat-samsung/devs.c
+++ b/arch/arm/plat-samsung/devs.c
@@ -36,7 +36,7 @@
36#include <linux/platform_data/s3c-hsotg.h> 36#include <linux/platform_data/s3c-hsotg.h>
37#include <linux/platform_data/dma-s3c24xx.h> 37#include <linux/platform_data/dma-s3c24xx.h>
38 38
39#include <media/s5p_hdmi.h> 39#include <linux/platform_data/media/s5p_hdmi.h>
40 40
41#include <asm/irq.h> 41#include <asm/irq.h>
42#include <asm/mach/arch.h> 42#include <asm/mach/arch.h>
diff --git a/arch/blackfin/mach-bf561/boards/ezkit.c b/arch/blackfin/mach-bf561/boards/ezkit.c
index 2de71e8c104b..f35525b55819 100644
--- a/arch/blackfin/mach-bf561/boards/ezkit.c
+++ b/arch/blackfin/mach-bf561/boards/ezkit.c
@@ -443,7 +443,7 @@ static const struct ppi_info ppi_info = {
443}; 443};
444 444
445#if IS_ENABLED(CONFIG_VIDEO_ADV7183) 445#if IS_ENABLED(CONFIG_VIDEO_ADV7183)
446#include <media/adv7183.h> 446#include <media/i2c/adv7183.h>
447static struct v4l2_input adv7183_inputs[] = { 447static struct v4l2_input adv7183_inputs[] = {
448 { 448 {
449 .index = 0, 449 .index = 0,
diff --git a/arch/blackfin/mach-bf609/boards/ezkit.c b/arch/blackfin/mach-bf609/boards/ezkit.c
index 2c61fc0c98f9..c7928d8ebb82 100644
--- a/arch/blackfin/mach-bf609/boards/ezkit.c
+++ b/arch/blackfin/mach-bf609/boards/ezkit.c
@@ -933,7 +933,7 @@ static struct bfin_capture_config bfin_capture_data = {
933#endif 933#endif
934 934
935#if IS_ENABLED(CONFIG_VIDEO_ADV7842) 935#if IS_ENABLED(CONFIG_VIDEO_ADV7842)
936#include <media/adv7842.h> 936#include <media/i2c/adv7842.h>
937 937
938static struct v4l2_input adv7842_inputs[] = { 938static struct v4l2_input adv7842_inputs[] = {
939 { 939 {
@@ -1084,7 +1084,7 @@ static const struct ppi_info ppi_info = {
1084}; 1084};
1085 1085
1086#if IS_ENABLED(CONFIG_VIDEO_ADV7511) 1086#if IS_ENABLED(CONFIG_VIDEO_ADV7511)
1087#include <media/adv7511.h> 1087#include <media/i2c/adv7511.h>
1088 1088
1089static struct v4l2_output adv7511_outputs[] = { 1089static struct v4l2_output adv7511_outputs[] = {
1090 { 1090 {
@@ -1125,7 +1125,7 @@ static struct bfin_display_config bfin_display_data = {
1125#endif 1125#endif
1126 1126
1127#if IS_ENABLED(CONFIG_VIDEO_ADV7343) 1127#if IS_ENABLED(CONFIG_VIDEO_ADV7343)
1128#include <media/adv7343.h> 1128#include <media/i2c/adv7343.h>
1129 1129
1130static struct v4l2_output adv7343_outputs[] = { 1130static struct v4l2_output adv7343_outputs[] = {
1131 { 1131 {
diff --git a/arch/sh/boards/mach-ap325rxa/setup.c b/arch/sh/boards/mach-ap325rxa/setup.c
index cbd2a9f02a91..62c3b81300ed 100644
--- a/arch/sh/boards/mach-ap325rxa/setup.c
+++ b/arch/sh/boards/mach-ap325rxa/setup.c
@@ -27,10 +27,10 @@
27#include <linux/gpio.h> 27#include <linux/gpio.h>
28#include <linux/videodev2.h> 28#include <linux/videodev2.h>
29#include <linux/sh_intc.h> 29#include <linux/sh_intc.h>
30#include <media/ov772x.h> 30#include <media/i2c/ov772x.h>
31#include <media/soc_camera.h> 31#include <media/soc_camera.h>
32#include <media/soc_camera_platform.h> 32#include <linux/platform_data/media/soc_camera_platform.h>
33#include <media/sh_mobile_ceu.h> 33#include <media/drv-intf/sh_mobile_ceu.h>
34#include <video/sh_mobile_lcdc.h> 34#include <video/sh_mobile_lcdc.h>
35#include <asm/io.h> 35#include <asm/io.h>
36#include <asm/clock.h> 36#include <asm/clock.h>
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index d531791f06ff..a9c0c07386fd 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -38,10 +38,10 @@
38#include <video/sh_mobile_lcdc.h> 38#include <video/sh_mobile_lcdc.h>
39#include <sound/sh_fsi.h> 39#include <sound/sh_fsi.h>
40#include <sound/simple_card.h> 40#include <sound/simple_card.h>
41#include <media/sh_mobile_ceu.h> 41#include <media/drv-intf/sh_mobile_ceu.h>
42#include <media/soc_camera.h> 42#include <media/soc_camera.h>
43#include <media/tw9910.h> 43#include <media/i2c/tw9910.h>
44#include <media/mt9t112.h> 44#include <media/i2c/mt9t112.h>
45#include <asm/heartbeat.h> 45#include <asm/heartbeat.h>
46#include <asm/clock.h> 46#include <asm/clock.h>
47#include <asm/suspend.h> 47#include <asm/suspend.h>
@@ -900,8 +900,8 @@ static struct platform_device irda_device = {
900 .resource = irda_resources, 900 .resource = irda_resources,
901}; 901};
902 902
903#include <media/ak881x.h> 903#include <media/i2c/ak881x.h>
904#include <media/sh_vou.h> 904#include <media/drv-intf/sh_vou.h>
905 905
906static struct ak881x_pdata ak881x_pdata = { 906static struct ak881x_pdata ak881x_pdata = {
907 .flags = AK881X_IF_MODE_SLAVE, 907 .flags = AK881X_IF_MODE_SLAVE,
diff --git a/arch/sh/boards/mach-kfr2r09/setup.c b/arch/sh/boards/mach-kfr2r09/setup.c
index 7d997cec09c5..6bd9230e64e3 100644
--- a/arch/sh/boards/mach-kfr2r09/setup.c
+++ b/arch/sh/boards/mach-kfr2r09/setup.c
@@ -27,9 +27,9 @@
27#include <linux/usb/r8a66597.h> 27#include <linux/usb/r8a66597.h>
28#include <linux/videodev2.h> 28#include <linux/videodev2.h>
29#include <linux/sh_intc.h> 29#include <linux/sh_intc.h>
30#include <media/rj54n1cb0c.h> 30#include <media/i2c/rj54n1cb0c.h>
31#include <media/soc_camera.h> 31#include <media/soc_camera.h>
32#include <media/sh_mobile_ceu.h> 32#include <media/drv-intf/sh_mobile_ceu.h>
33#include <video/sh_mobile_lcdc.h> 33#include <video/sh_mobile_lcdc.h>
34#include <asm/suspend.h> 34#include <asm/suspend.h>
35#include <asm/clock.h> 35#include <asm/clock.h>
diff --git a/arch/sh/boards/mach-migor/setup.c b/arch/sh/boards/mach-migor/setup.c
index 29b7c0dcfc51..8f237a5bd9aa 100644
--- a/arch/sh/boards/mach-migor/setup.c
+++ b/arch/sh/boards/mach-migor/setup.c
@@ -27,10 +27,10 @@
27#include <linux/videodev2.h> 27#include <linux/videodev2.h>
28#include <linux/sh_intc.h> 28#include <linux/sh_intc.h>
29#include <video/sh_mobile_lcdc.h> 29#include <video/sh_mobile_lcdc.h>
30#include <media/sh_mobile_ceu.h> 30#include <media/drv-intf/sh_mobile_ceu.h>
31#include <media/ov772x.h> 31#include <media/i2c/ov772x.h>
32#include <media/soc_camera.h> 32#include <media/soc_camera.h>
33#include <media/tw9910.h> 33#include <media/i2c/tw9910.h>
34#include <asm/clock.h> 34#include <asm/clock.h>
35#include <asm/machvec.h> 35#include <asm/machvec.h>
36#include <asm/io.h> 36#include <asm/io.h>
diff --git a/arch/sh/boards/mach-se/7724/setup.c b/arch/sh/boards/mach-se/7724/setup.c
index 4f6635a075f2..e0e1df136642 100644
--- a/arch/sh/boards/mach-se/7724/setup.c
+++ b/arch/sh/boards/mach-se/7724/setup.c
@@ -30,7 +30,7 @@
30#include <linux/sh_intc.h> 30#include <linux/sh_intc.h>
31#include <linux/videodev2.h> 31#include <linux/videodev2.h>
32#include <video/sh_mobile_lcdc.h> 32#include <video/sh_mobile_lcdc.h>
33#include <media/sh_mobile_ceu.h> 33#include <media/drv-intf/sh_mobile_ceu.h>
34#include <sound/sh_fsi.h> 34#include <sound/sh_fsi.h>
35#include <sound/simple_card.h> 35#include <sound/simple_card.h>
36#include <asm/io.h> 36#include <asm/io.h>
@@ -534,8 +534,8 @@ static struct platform_device irda_device = {
534 .resource = irda_resources, 534 .resource = irda_resources,
535}; 535};
536 536
537#include <media/ak881x.h> 537#include <media/i2c/ak881x.h>
538#include <media/sh_vou.h> 538#include <media/drv-intf/sh_vou.h>
539 539
540static struct ak881x_pdata ak881x_pdata = { 540static struct ak881x_pdata ak881x_pdata = {
541 .flags = AK881X_IF_MODE_SLAVE, 541 .flags = AK881X_IF_MODE_SLAVE,
diff --git a/drivers/gpu/ipu-v3/ipu-cpmem.c b/drivers/gpu/ipu-v3/ipu-cpmem.c
index 63eb16bf2cf0..883a314cd83a 100644
--- a/drivers/gpu/ipu-v3/ipu-cpmem.c
+++ b/drivers/gpu/ipu-v3/ipu-cpmem.c
@@ -161,7 +161,7 @@ static u32 ipu_ch_param_read_field(struct ipuv3_channel *ch, u32 wbs)
161 * The DRM pixel formats and IPU internal representation are ordered the other 161 * The DRM pixel formats and IPU internal representation are ordered the other
162 * way around, with the first named component ordered at the most significant 162 * way around, with the first named component ordered at the most significant
163 * bits. Further, V4L2 formats are not well defined: 163 * bits. Further, V4L2 formats are not well defined:
164 * http://linuxtv.org/downloads/v4l-dvb-apis/packed-rgb.html 164 * https://linuxtv.org/downloads/v4l-dvb-apis/packed-rgb.html
165 * We choose the interpretation which matches GStreamer behavior. 165 * We choose the interpretation which matches GStreamer behavior.
166 */ 166 */
167static int v4l2_pix_fmt_to_drm_fourcc(u32 pixelformat) 167static int v4l2_pix_fmt_to_drm_fourcc(u32 pixelformat)
diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
index d214f22ed305..b6c4d03de340 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -444,7 +444,7 @@ static void sur40_process_video(struct sur40_state *sur40)
444 goto err_poll; 444 goto err_poll;
445 445
446 /* mark as finished */ 446 /* mark as finished */
447 v4l2_get_timestamp(&new_buf->vb.timestamp); 447 new_buf->vb.vb2_buf.timestamp = ktime_get_ns();
448 new_buf->vb.sequence = sur40->sequence++; 448 new_buf->vb.sequence = sur40->sequence++;
449 new_buf->vb.field = V4L2_FIELD_NONE; 449 new_buf->vb.field = V4L2_FIELD_NONE;
450 vb2_buffer_done(&new_buf->vb.vb2_buf, VB2_BUF_STATE_DONE); 450 vb2_buffer_done(&new_buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
@@ -644,22 +644,21 @@ static void sur40_disconnect(struct usb_interface *interface)
644 * minimum number: many DMA engines need a minimum of 2 buffers in the 644 * minimum number: many DMA engines need a minimum of 2 buffers in the
645 * queue and you need to have another available for userspace processing. 645 * queue and you need to have another available for userspace processing.
646 */ 646 */
647static int sur40_queue_setup(struct vb2_queue *q, const void *parg, 647static int sur40_queue_setup(struct vb2_queue *q,
648 unsigned int *nbuffers, unsigned int *nplanes, 648 unsigned int *nbuffers, unsigned int *nplanes,
649 unsigned int sizes[], void *alloc_ctxs[]) 649 unsigned int sizes[], void *alloc_ctxs[])
650{ 650{
651 const struct v4l2_format *fmt = parg;
652 struct sur40_state *sur40 = vb2_get_drv_priv(q); 651 struct sur40_state *sur40 = vb2_get_drv_priv(q);
653 652
654 if (q->num_buffers + *nbuffers < 3) 653 if (q->num_buffers + *nbuffers < 3)
655 *nbuffers = 3 - q->num_buffers; 654 *nbuffers = 3 - q->num_buffers;
655 alloc_ctxs[0] = sur40->alloc_ctx;
656 656
657 if (fmt && fmt->fmt.pix.sizeimage < sur40_video_format.sizeimage) 657 if (*nplanes)
658 return -EINVAL; 658 return sizes[0] < sur40_video_format.sizeimage ? -EINVAL : 0;
659 659
660 *nplanes = 1; 660 *nplanes = 1;
661 sizes[0] = fmt ? fmt->fmt.pix.sizeimage : sur40_video_format.sizeimage; 661 sizes[0] = sur40_video_format.sizeimage;
662 alloc_ctxs[0] = sur40->alloc_ctx;
663 662
664 return 0; 663 return 0;
665} 664}
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index 3ef3d6c6bbf8..9264ea73b3be 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -9,7 +9,7 @@ menuconfig MEDIA_SUPPORT
9 If you want to use Webcams, Video grabber devices and/or TV devices 9 If you want to use Webcams, Video grabber devices and/or TV devices
10 enable this option and other options below. 10 enable this option and other options below.
11 Additional info and docs are available on the web at 11 Additional info and docs are available on the web at
12 <http://linuxtv.org> 12 <https://linuxtv.org>
13 13
14if MEDIA_SUPPORT 14if MEDIA_SUPPORT
15 15
@@ -51,7 +51,7 @@ config MEDIA_RADIO_SUPPORT
51 Enable AM/FM radio support. 51 Enable AM/FM radio support.
52 52
53 Additional info and docs are available on the web at 53 Additional info and docs are available on the web at
54 <http://linuxtv.org> 54 <https://linuxtv.org>
55 55
56 Say Y when you have a board with radio support. 56 Say Y when you have a board with radio support.
57 57
diff --git a/drivers/media/common/cx2341x.c b/drivers/media/common/cx2341x.c
index c07b9db51b05..5e4afa0131e6 100644
--- a/drivers/media/common/cx2341x.c
+++ b/drivers/media/common/cx2341x.c
@@ -27,7 +27,7 @@
27#include <linux/videodev2.h> 27#include <linux/videodev2.h>
28 28
29#include <media/tuner.h> 29#include <media/tuner.h>
30#include <media/cx2341x.h> 30#include <media/drv-intf/cx2341x.h>
31#include <media/v4l2-common.h> 31#include <media/v4l2-common.h>
32 32
33MODULE_DESCRIPTION("cx23415/6/8 driver"); 33MODULE_DESCRIPTION("cx23415/6/8 driver");
diff --git a/drivers/media/common/saa7146/saa7146_core.c b/drivers/media/common/saa7146/saa7146_core.c
index 1ff9f5323bc3..9f7c5b0a6b45 100644
--- a/drivers/media/common/saa7146/saa7146_core.c
+++ b/drivers/media/common/saa7146/saa7146_core.c
@@ -20,7 +20,7 @@
20 20
21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22 22
23#include <media/saa7146.h> 23#include <media/drv-intf/saa7146.h>
24#include <linux/module.h> 24#include <linux/module.h>
25 25
26static int saa7146_num; 26static int saa7146_num;
diff --git a/drivers/media/common/saa7146/saa7146_fops.c b/drivers/media/common/saa7146/saa7146_fops.c
index df1e8c975cd8..930d2c94d5d3 100644
--- a/drivers/media/common/saa7146/saa7146_fops.c
+++ b/drivers/media/common/saa7146/saa7146_fops.c
@@ -1,6 +1,6 @@
1#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 1#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
2 2
3#include <media/saa7146_vv.h> 3#include <media/drv-intf/saa7146_vv.h>
4#include <linux/module.h> 4#include <linux/module.h>
5 5
6/****************************************************************************/ 6/****************************************************************************/
diff --git a/drivers/media/common/saa7146/saa7146_hlp.c b/drivers/media/common/saa7146/saa7146_hlp.c
index 3dc6a838ca6f..6ebcbc6450f5 100644
--- a/drivers/media/common/saa7146/saa7146_hlp.c
+++ b/drivers/media/common/saa7146/saa7146_hlp.c
@@ -2,7 +2,7 @@
2 2
3#include <linux/kernel.h> 3#include <linux/kernel.h>
4#include <linux/export.h> 4#include <linux/export.h>
5#include <media/saa7146_vv.h> 5#include <media/drv-intf/saa7146_vv.h>
6 6
7static void calculate_output_format_register(struct saa7146_dev* saa, u32 palette, u32* clip_format) 7static void calculate_output_format_register(struct saa7146_dev* saa, u32 palette, u32* clip_format)
8{ 8{
diff --git a/drivers/media/common/saa7146/saa7146_i2c.c b/drivers/media/common/saa7146/saa7146_i2c.c
index 22027198129d..239a2db35068 100644
--- a/drivers/media/common/saa7146/saa7146_i2c.c
+++ b/drivers/media/common/saa7146/saa7146_i2c.c
@@ -1,6 +1,6 @@
1#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 1#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
2 2
3#include <media/saa7146_vv.h> 3#include <media/drv-intf/saa7146_vv.h>
4 4
5static u32 saa7146_i2c_func(struct i2c_adapter *adapter) 5static u32 saa7146_i2c_func(struct i2c_adapter *adapter)
6{ 6{
diff --git a/drivers/media/common/saa7146/saa7146_vbi.c b/drivers/media/common/saa7146/saa7146_vbi.c
index 2da995758778..49237518d65f 100644
--- a/drivers/media/common/saa7146/saa7146_vbi.c
+++ b/drivers/media/common/saa7146/saa7146_vbi.c
@@ -1,4 +1,4 @@
1#include <media/saa7146_vv.h> 1#include <media/drv-intf/saa7146_vv.h>
2 2
3static int vbi_pixel_to_capture = 720 * 2; 3static int vbi_pixel_to_capture = 720 * 2;
4 4
diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c
index 30779498c173..d5837be3e8cf 100644
--- a/drivers/media/common/saa7146/saa7146_video.c
+++ b/drivers/media/common/saa7146/saa7146_video.c
@@ -1,6 +1,6 @@
1#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 1#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
2 2
3#include <media/saa7146_vv.h> 3#include <media/drv-intf/saa7146_vv.h>
4#include <media/v4l2-event.h> 4#include <media/v4l2-event.h>
5#include <media/v4l2-ctrls.h> 5#include <media/v4l2-ctrls.h>
6#include <linux/module.h> 6#include <linux/module.h>
diff --git a/drivers/media/common/siano/smsir.h b/drivers/media/common/siano/smsir.h
index fc8b7925c532..d9abd96ef48b 100644
--- a/drivers/media/common/siano/smsir.h
+++ b/drivers/media/common/siano/smsir.h
@@ -30,8 +30,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
30#include <linux/input.h> 30#include <linux/input.h>
31#include <media/rc-core.h> 31#include <media/rc-core.h>
32 32
33#define IR_DEFAULT_TIMEOUT 100
34
35struct smscore_device_t; 33struct smscore_device_t;
36 34
37struct ir_t { 35struct ir_t {
diff --git a/drivers/media/dvb-core/demux.h b/drivers/media/dvb-core/demux.h
index ccc1f43cb9a9..6d3b95b8939d 100644
--- a/drivers/media/dvb-core/demux.h
+++ b/drivers/media/dvb-core/demux.h
@@ -32,6 +32,49 @@
32#include <linux/time.h> 32#include <linux/time.h>
33#include <linux/dvb/dmx.h> 33#include <linux/dvb/dmx.h>
34 34
35/**
36 * DOC: Digital TV Demux
37 *
38 * The Kernel Digital TV Demux kABI defines a driver-internal interface for
39 * registering low-level, hardware specific driver to a hardware independent
40 * demux layer. It is only of interest for Digital TV device driver writers.
41 * The header file for this kABI is named demux.h and located in
42 * drivers/media/dvb-core.
43 *
44 * The demux kABI should be implemented for each demux in the system. It is
45 * used to select the TS source of a demux and to manage the demux resources.
46 * When the demux client allocates a resource via the demux kABI, it receives
47 * a pointer to the kABI of that resource.
48 *
49 * Each demux receives its TS input from a DVB front-end or from memory, as
50 * set via this demux kABI. In a system with more than one front-end, the kABI
51 * can be used to select one of the DVB front-ends as a TS source for a demux,
52 * unless this is fixed in the HW platform.
53 *
54 * The demux kABI only controls front-ends regarding to their connections with
55 * demuxes; the kABI used to set the other front-end parameters, such as
56 * tuning, are devined via the Digital TV Frontend kABI.
57 *
58 * The functions that implement the abstract interface demux should be defined
59 * static or module private and registered to the Demux core for external
60 * access. It is not necessary to implement every function in the struct
61 * &dmx_demux. For example, a demux interface might support Section filtering,
62 * but not PES filtering. The kABI client is expected to check the value of any
63 * function pointer before calling the function: the value of NULL means
64 * that the function is not available.
65 *
66 * Whenever the functions of the demux API modify shared data, the
67 * possibilities of lost update and race condition problems should be
68 * addressed, e.g. by protecting parts of code with mutexes.
69 *
70 * Note that functions called from a bottom half context must not sleep.
71 * Even a simple memory allocation without using %GFP_ATOMIC can result in a
72 * kernel thread being put to sleep if swapping is needed. For example, the
73 * Linux Kernel calls the functions of a network device interface from a
74 * bottom half context. Thus, if a demux kABI function is called from network
75 * device code, the function must not sleep.
76 */
77
35/* 78/*
36 * Common definitions 79 * Common definitions
37 */ 80 */
@@ -187,8 +230,28 @@ struct dmx_section_feed {
187 int (*stop_filtering)(struct dmx_section_feed *feed); 230 int (*stop_filtering)(struct dmx_section_feed *feed);
188}; 231};
189 232
190/* 233/**
191 * Callback functions 234 * DOC: Demux Callback
235 *
236 * This kernel-space API comprises the callback functions that deliver filtered
237 * data to the demux client. Unlike the other DVB kABIs, these functions are
238 * provided by the client and called from the demux code.
239 *
240 * The function pointers of this abstract interface are not packed into a
241 * structure as in the other demux APIs, because the callback functions are
242 * registered and used independent of each other. As an example, it is possible
243 * for the API client to provide several callback functions for receiving TS
244 * packets and no callbacks for PES packets or sections.
245 *
246 * The functions that implement the callback API need not be re-entrant: when
247 * a demux driver calls one of these functions, the driver is not allowed to
248 * call the function again before the original call returns. If a callback is
249 * triggered by a hardware interrupt, it is recommended to use the Linux
250 * bottom half mechanism or start a tasklet instead of making the callback
251 * function call directly from a hardware interrupt.
252 *
253 * This mechanism is implemented by dmx_ts_cb() and dmx_section_cb()
254 * callbacks.
192 */ 255 */
193 256
194/** 257/**
diff --git a/drivers/media/dvb-core/dvb-usb-ids.h b/drivers/media/dvb-core/dvb-usb-ids.h
index 0a46580b5376..1c1c298d2289 100644
--- a/drivers/media/dvb-core/dvb-usb-ids.h
+++ b/drivers/media/dvb-core/dvb-usb-ids.h
@@ -389,4 +389,5 @@
389#define USB_PID_PCTV_2002E_SE 0x025d 389#define USB_PID_PCTV_2002E_SE 0x025d
390#define USB_PID_SVEON_STV27 0xd3af 390#define USB_PID_SVEON_STV27 0xd3af
391#define USB_PID_TURBOX_DTT_2000 0xd3a4 391#define USB_PID_TURBOX_DTT_2000 0xd3a4
392#define USB_PID_WINTV_SOLOHD 0x0264
392#endif 393#endif
diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index c38ef1a72b4a..b64f33776b74 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -891,21 +891,21 @@ static void dvb_frontend_stop(struct dvb_frontend *fe)
891} 891}
892 892
893/* 893/*
894 * Sleep until gettimeofday() > waketime + add_usec 894 * Sleep for the amount of time given by add_usec parameter
895 * This needs to be as precise as possible, but as the delay is 895 *
896 * usually between 2ms and 32ms, it is done using a scheduled msleep 896 * This needs to be as precise as possible, as it affects the detection of
897 * followed by usleep (normally a busy-wait loop) for the remainder 897 * the dish tone command at the satellite subsystem. The precision is improved
898 * by using a scheduled msleep followed by udelay for the remainder.
898 */ 899 */
899void dvb_frontend_sleep_until(ktime_t *waketime, u32 add_usec) 900void dvb_frontend_sleep_until(ktime_t *waketime, u32 add_usec)
900{ 901{
901 s32 delta, newdelta; 902 s32 delta;
902 903
903 ktime_add_us(*waketime, add_usec); 904 *waketime = ktime_add_us(*waketime, add_usec);
904 delta = ktime_us_delta(ktime_get_real(), *waketime); 905 delta = ktime_us_delta(ktime_get_real(), *waketime);
905 if (delta > 2500) { 906 if (delta > 2500) {
906 msleep((delta - 1500) / 1000); 907 msleep((delta - 1500) / 1000);
907 newdelta = ktime_us_delta(ktime_get_real(), *waketime); 908 delta = ktime_us_delta(ktime_get_real(), *waketime);
908 delta = (newdelta > delta) ? 0 : newdelta;
909 } 909 }
910 if (delta > 0) 910 if (delta > 0)
911 udelay(delta); 911 udelay(delta);
@@ -2313,9 +2313,9 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
2313 dev_dbg(fe->dvb->device, "%s: current delivery system on cache: %d, V3 type: %d\n", 2313 dev_dbg(fe->dvb->device, "%s: current delivery system on cache: %d, V3 type: %d\n",
2314 __func__, c->delivery_system, fe->ops.info.type); 2314 __func__, c->delivery_system, fe->ops.info.type);
2315 2315
2316 /* Force the CAN_INVERSION_AUTO bit on. If the frontend doesn't 2316 /* Set CAN_INVERSION_AUTO bit on in other than oneshot mode */
2317 * do it, it is done for it. */ 2317 if (!(fepriv->tune_mode_flags & FE_TUNE_MODE_ONESHOT))
2318 info->caps |= FE_CAN_INVERSION_AUTO; 2318 info->caps |= FE_CAN_INVERSION_AUTO;
2319 err = 0; 2319 err = 0;
2320 break; 2320 break;
2321 } 2321 }
@@ -2710,6 +2710,11 @@ int dvb_frontend_resume(struct dvb_frontend *fe)
2710 else if (fe->ops.tuner_ops.init) 2710 else if (fe->ops.tuner_ops.init)
2711 ret = fe->ops.tuner_ops.init(fe); 2711 ret = fe->ops.tuner_ops.init(fe);
2712 2712
2713 if (fe->ops.set_tone && fepriv->tone != -1)
2714 fe->ops.set_tone(fe, fepriv->tone);
2715 if (fe->ops.set_voltage && fepriv->voltage != -1)
2716 fe->ops.set_voltage(fe, fepriv->voltage);
2717
2713 fe->exit = DVB_FE_NO_EXIT; 2718 fe->exit = DVB_FE_NO_EXIT;
2714 fepriv->state = FESTATE_RETUNE; 2719 fepriv->state = FESTATE_RETUNE;
2715 dvb_frontend_wakeup(fe); 2720 dvb_frontend_wakeup(fe);
diff --git a/drivers/media/dvb-core/dvb_frontend.h b/drivers/media/dvb-core/dvb_frontend.h
index 97661b2f247a..458bcce20e38 100644
--- a/drivers/media/dvb-core/dvb_frontend.h
+++ b/drivers/media/dvb-core/dvb_frontend.h
@@ -42,6 +42,29 @@
42 42
43#include "dvbdev.h" 43#include "dvbdev.h"
44 44
45/**
46 * DOC: Digital TV Frontend
47 *
48 * The Digital TV Frontend kABI defines a driver-internal interface for
49 * registering low-level, hardware specific driver to a hardware independent
50 * frontend layer. It is only of interest for Digital TV device driver writers.
51 * The header file for this API is named dvb_frontend.h and located in
52 * drivers/media/dvb-core.
53 *
54 * Before using the Digital TV frontend core, the bridge driver should attach
55 * the frontend demod, tuner and SEC devices and call dvb_register_frontend(),
56 * in order to register the new frontend at the subsystem. At device
57 * detach/removal, the bridge driver should call dvb_unregister_frontend() to
58 * remove the frontend from the core and then dvb_frontend_detach() to free the
59 * memory allocated by the frontend drivers.
60 *
61 * The drivers should also call dvb_frontend_suspend() as part of their
62 * handler for the &device_driver.suspend(), and dvb_frontend_resume() as
63 * part of their handler for &device_driver.resume().
64 *
65 * A few other optional functions are provided to handle some special cases.
66 */
67
45/* 68/*
46 * Maximum number of Delivery systems per frontend. It 69 * Maximum number of Delivery systems per frontend. It
47 * should be smaller or equal to 32 70 * should be smaller or equal to 32
@@ -112,16 +135,6 @@ struct analog_parameters {
112 u64 std; 135 u64 std;
113}; 136};
114 137
115enum tuner_param {
116 DVBFE_TUNER_FREQUENCY = (1 << 0),
117 DVBFE_TUNER_TUNERSTEP = (1 << 1),
118 DVBFE_TUNER_IFFREQ = (1 << 2),
119 DVBFE_TUNER_BANDWIDTH = (1 << 3),
120 DVBFE_TUNER_REFCLOCK = (1 << 4),
121 DVBFE_TUNER_IQSENSE = (1 << 5),
122 DVBFE_TUNER_DUMMY = (1 << 31)
123};
124
125/** 138/**
126 * enum dvbfe_algo - defines the algorithm used to tune into a channel 139 * enum dvbfe_algo - defines the algorithm used to tune into a channel
127 * 140 *
@@ -152,15 +165,6 @@ enum dvbfe_algo {
152 DVBFE_ALGO_RECOVERY = (1 << 31) 165 DVBFE_ALGO_RECOVERY = (1 << 31)
153}; 166};
154 167
155struct tuner_state {
156 u32 frequency;
157 u32 tunerstep;
158 u32 ifreq;
159 u32 bandwidth;
160 u32 iqsense;
161 u32 refclock;
162};
163
164/** 168/**
165 * enum dvbfe_search - search callback possible return status 169 * enum dvbfe_search - search callback possible return status
166 * 170 *
@@ -209,12 +213,12 @@ enum dvbfe_search {
209 * are stored at @dvb_frontend.dtv_property_cache;. The 213 * are stored at @dvb_frontend.dtv_property_cache;. The
210 * tuner demod can change the parameters to reflect the 214 * tuner demod can change the parameters to reflect the
211 * changes needed for the channel to be tuned, and 215 * changes needed for the channel to be tuned, and
212 * update statistics. 216 * update statistics. This is the recommended way to set
217 * the tuner parameters and should be used on newer
218 * drivers.
213 * @set_analog_params: callback function used to tune into an analog TV 219 * @set_analog_params: callback function used to tune into an analog TV
214 * channel on hybrid tuners. It passes @analog_parameters; 220 * channel on hybrid tuners. It passes @analog_parameters;
215 * to the driver. 221 * to the driver.
216 * @calc_regs: callback function used to pass register data settings
217 * for simple tuners.
218 * @set_config: callback function used to send some tuner-specific 222 * @set_config: callback function used to send some tuner-specific
219 * parameters. 223 * parameters.
220 * @get_frequency: get the actual tuned frequency 224 * @get_frequency: get the actual tuned frequency
@@ -227,16 +231,10 @@ enum dvbfe_search {
227 * via DVBv5 API (@dvb_frontend.dtv_property_cache;). 231 * via DVBv5 API (@dvb_frontend.dtv_property_cache;).
228 * @get_afc: Used only by analog TV core. Reports the frequency 232 * @get_afc: Used only by analog TV core. Reports the frequency
229 * drift due to AFC. 233 * drift due to AFC.
230 * @set_frequency: Set a new frequency. Please notice that using 234 * @calc_regs: callback function used to pass register data settings
231 * set_params is preferred. 235 * for simple tuners. Shouldn't be used on newer drivers.
232 * @set_bandwidth: Set a new frequency. Please notice that using 236 * @set_frequency: Set a new frequency. Shouldn't be used on newer drivers.
233 * set_params is preferred. 237 * @set_bandwidth: Set a new frequency. Shouldn't be used on newer drivers.
234 * @set_state: callback function used on some legacy drivers that
235 * don't implement set_params in order to set properties.
236 * Shouldn't be used on new drivers.
237 * @get_state: callback function used to get properties by some
238 * legacy drivers that don't implement set_params.
239 * Shouldn't be used on new drivers.
240 * 238 *
241 * NOTE: frequencies used on get_frequency and set_frequency are in Hz for 239 * NOTE: frequencies used on get_frequency and set_frequency are in Hz for
242 * terrestrial/cable or kHz for satellite. 240 * terrestrial/cable or kHz for satellite.
@@ -252,14 +250,10 @@ struct dvb_tuner_ops {
252 int (*suspend)(struct dvb_frontend *fe); 250 int (*suspend)(struct dvb_frontend *fe);
253 int (*resume)(struct dvb_frontend *fe); 251 int (*resume)(struct dvb_frontend *fe);
254 252
255 /** This is for simple PLLs - set all parameters in one go. */ 253 /* This is the recomended way to set the tuner */
256 int (*set_params)(struct dvb_frontend *fe); 254 int (*set_params)(struct dvb_frontend *fe);
257 int (*set_analog_params)(struct dvb_frontend *fe, struct analog_parameters *p); 255 int (*set_analog_params)(struct dvb_frontend *fe, struct analog_parameters *p);
258 256
259 /** This is support for demods like the mt352 - fills out the supplied buffer with what to write. */
260 int (*calc_regs)(struct dvb_frontend *fe, u8 *buf, int buf_len);
261
262 /** This is to allow setting tuner-specific configs */
263 int (*set_config)(struct dvb_frontend *fe, void *priv_cfg); 257 int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
264 258
265 int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency); 259 int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency);
@@ -272,17 +266,23 @@ struct dvb_tuner_ops {
272 int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength); 266 int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength);
273 int (*get_afc)(struct dvb_frontend *fe, s32 *afc); 267 int (*get_afc)(struct dvb_frontend *fe, s32 *afc);
274 268
275 /** These are provided separately from set_params in order to facilitate silicon 269 /*
276 * tuners which require sophisticated tuning loops, controlling each parameter separately. */ 270 * This is support for demods like the mt352 - fills out the supplied
277 int (*set_frequency)(struct dvb_frontend *fe, u32 frequency); 271 * buffer with what to write.
278 int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth); 272 *
273 * Don't use on newer drivers.
274 */
275 int (*calc_regs)(struct dvb_frontend *fe, u8 *buf, int buf_len);
279 276
280 /* 277 /*
281 * These are provided separately from set_params in order to facilitate silicon 278 * These are provided separately from set_params in order to
282 * tuners which require sophisticated tuning loops, controlling each parameter separately. 279 * facilitate silicon tuners which require sophisticated tuning loops,
280 * controlling each parameter separately.
281 *
282 * Don't use on newer drivers.
283 */ 283 */
284 int (*set_state)(struct dvb_frontend *fe, enum tuner_param param, struct tuner_state *state); 284 int (*set_frequency)(struct dvb_frontend *fe, u32 frequency);
285 int (*get_state)(struct dvb_frontend *fe, enum tuner_param param, struct tuner_state *state); 285 int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
286}; 286};
287 287
288/** 288/**
@@ -404,6 +404,11 @@ struct dtv_frontend_properties;
404 * FE_ENABLE_HIGH_LNB_VOLTAGE ioctl (only Satellite). 404 * FE_ENABLE_HIGH_LNB_VOLTAGE ioctl (only Satellite).
405 * @dishnetwork_send_legacy_command: callback function to implement the 405 * @dishnetwork_send_legacy_command: callback function to implement the
406 * FE_DISHNETWORK_SEND_LEGACY_CMD ioctl (only Satellite). 406 * FE_DISHNETWORK_SEND_LEGACY_CMD ioctl (only Satellite).
407 * Drivers should not use this, except when the DVB
408 * core emulation fails to provide proper support (e.g.
409 * if set_voltage() takes more than 8ms to work), and
410 * when backward compatibility with this legacy API is
411 * required.
407 * @i2c_gate_ctrl: controls the I2C gate. Newer drivers should use I2C 412 * @i2c_gate_ctrl: controls the I2C gate. Newer drivers should use I2C
408 * mux support instead. 413 * mux support instead.
409 * @ts_bus_ctrl: callback function used to take control of the TS bus. 414 * @ts_bus_ctrl: callback function used to take control of the TS bus.
@@ -466,7 +471,8 @@ struct dvb_frontend_ops {
466 int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire); 471 int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire);
467 int (*set_lna)(struct dvb_frontend *); 472 int (*set_lna)(struct dvb_frontend *);
468 473
469 /* These callbacks are for devices that implement their own 474 /*
475 * These callbacks are for devices that implement their own
470 * tuning algorithms, rather than a simple swzigzag 476 * tuning algorithms, rather than a simple swzigzag
471 */ 477 */
472 enum dvbfe_search (*search)(struct dvb_frontend *fe); 478 enum dvbfe_search (*search)(struct dvb_frontend *fe);
@@ -682,17 +688,126 @@ struct dvb_frontend {
682 unsigned int exit; 688 unsigned int exit;
683}; 689};
684 690
685extern int dvb_register_frontend(struct dvb_adapter *dvb, 691/**
692 * dvb_register_frontend() - Registers a DVB frontend at the adapter
693 *
694 * @dvb: pointer to the dvb adapter
695 * @fe: pointer to the frontend struct
696 *
697 * Allocate and initialize the private data needed by the frontend core to
698 * manage the frontend and calls dvb_register_device() to register a new
699 * frontend. It also cleans the property cache that stores the frontend
700 * parameters and selects the first available delivery system.
701 */
702int dvb_register_frontend(struct dvb_adapter *dvb,
686 struct dvb_frontend *fe); 703 struct dvb_frontend *fe);
687 704
688extern int dvb_unregister_frontend(struct dvb_frontend *fe); 705/**
706 * dvb_unregister_frontend() - Unregisters a DVB frontend
707 *
708 * @fe: pointer to the frontend struct
709 *
710 * Stops the frontend kthread, calls dvb_unregister_device() and frees the
711 * private frontend data allocated by dvb_register_frontend().
712 *
713 * NOTE: This function doesn't frees the memory allocated by the demod,
714 * by the SEC driver and by the tuner. In order to free it, an explicit call to
715 * dvb_frontend_detach() is needed, after calling this function.
716 */
717int dvb_unregister_frontend(struct dvb_frontend *fe);
689 718
690extern void dvb_frontend_detach(struct dvb_frontend *fe); 719/**
720 * dvb_frontend_detach() - Detaches and frees frontend specific data
721 *
722 * @fe: pointer to the frontend struct
723 *
724 * This function should be called after dvb_unregister_frontend(). It
725 * calls the SEC, tuner and demod release functions:
726 * &dvb_frontend_ops.release_sec, &dvb_frontend_ops.tuner_ops.release,
727 * &dvb_frontend_ops.analog_ops.release and &dvb_frontend_ops.release.
728 *
729 * If the driver is compiled with CONFIG_MEDIA_ATTACH, it also decreases
730 * the module reference count, needed to allow userspace to remove the
731 * previously used DVB frontend modules.
732 */
733void dvb_frontend_detach(struct dvb_frontend *fe);
734
735/**
736 * dvb_frontend_suspend() - Suspends a Digital TV frontend
737 *
738 * @fe: pointer to the frontend struct
739 *
740 * This function prepares a Digital TV frontend to suspend.
741 *
742 * In order to prepare the tuner to suspend, if
743 * &dvb_frontend_ops.tuner_ops.suspend() is available, it calls it. Otherwise,
744 * it will call &dvb_frontend_ops.tuner_ops.sleep(), if available.
745 *
746 * It will also call &dvb_frontend_ops.sleep() to put the demod to suspend.
747 *
748 * The drivers should also call dvb_frontend_suspend() as part of their
749 * handler for the &device_driver.suspend().
750 */
751int dvb_frontend_suspend(struct dvb_frontend *fe);
752
753/**
754 * dvb_frontend_resume() - Resumes a Digital TV frontend
755 *
756 * @fe: pointer to the frontend struct
757 *
758 * This function resumes the usual operation of the tuner after resume.
759 *
760 * In order to resume the frontend, it calls the demod &dvb_frontend_ops.init().
761 *
762 * If &dvb_frontend_ops.tuner_ops.resume() is available, It, it calls it.
763 * Otherwise,t will call &dvb_frontend_ops.tuner_ops.init(), if available.
764 *
765 * Once tuner and demods are resumed, it will enforce that the SEC voltage and
766 * tone are restored to their previous values and wake up the frontend's
767 * kthread in order to retune the frontend.
768 *
769 * The drivers should also call dvb_frontend_resume() as part of their
770 * handler for the &device_driver.resume().
771 */
772int dvb_frontend_resume(struct dvb_frontend *fe);
691 773
692extern void dvb_frontend_reinitialise(struct dvb_frontend *fe); 774/**
693extern int dvb_frontend_suspend(struct dvb_frontend *fe); 775 * dvb_frontend_reinitialise() - forces a reinitialisation at the frontend
694extern int dvb_frontend_resume(struct dvb_frontend *fe); 776 *
777 * @fe: pointer to the frontend struct
778 *
779 * Calls &dvb_frontend_ops.init() and &dvb_frontend_ops.tuner_ops.init(),
780 * and resets SEC tone and voltage (for Satellite systems).
781 *
782 * NOTE: Currently, this function is used only by one driver (budget-av).
783 * It seems to be due to address some special issue with that specific
784 * frontend.
785 */
786void dvb_frontend_reinitialise(struct dvb_frontend *fe);
695 787
696extern void dvb_frontend_sleep_until(ktime_t *waketime, u32 add_usec); 788/**
789 * dvb_frontend_sleep_until() - Sleep for the amount of time given by
790 * add_usec parameter
791 *
792 * @waketime: pointer to a struct ktime_t
793 * @add_usec: time to sleep, in microseconds
794 *
795 * This function is used to measure the time required for the
796 * %FE_DISHNETWORK_SEND_LEGACY_CMD ioctl to work. It needs to be as precise
797 * as possible, as it affects the detection of the dish tone command at the
798 * satellite subsystem.
799 *
800 * Its used internally by the DVB frontend core, in order to emulate
801 * %FE_DISHNETWORK_SEND_LEGACY_CMD using the &dvb_frontend_ops.set_voltage()
802 * callback.
803 *
804 * NOTE: it should not be used at the drivers, as the emulation for the
805 * legacy callback is provided by the Kernel. The only situation where this
806 * should be at the drivers is when there are some bugs at the hardware that
807 * would prevent the core emulation to work. On such cases, the driver would
808 * be writing a &dvb_frontend_ops.dishnetwork_send_legacy_command() and
809 * calling this function directly.
810 */
811void dvb_frontend_sleep_until(ktime_t *waketime, u32 add_usec);
697 812
698#endif 813#endif
diff --git a/drivers/media/dvb-frontends/Kconfig b/drivers/media/dvb-frontends/Kconfig
index 292c9479bb75..310e4b8beae8 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -264,7 +264,7 @@ config DVB_MB86A16
264config DVB_TDA10071 264config DVB_TDA10071
265 tristate "NXP TDA10071" 265 tristate "NXP TDA10071"
266 depends on DVB_CORE && I2C 266 depends on DVB_CORE && I2C
267 select REGMAP 267 select REGMAP_I2C
268 default m if !MEDIA_SUBDRV_AUTOSELECT 268 default m if !MEDIA_SUBDRV_AUTOSELECT
269 help 269 help
270 Say Y when you want to support this frontend. 270 Say Y when you want to support this frontend.
diff --git a/drivers/media/dvb-frontends/au8522_common.c b/drivers/media/dvb-frontends/au8522_common.c
index 3559ff230045..f135126bc373 100644
--- a/drivers/media/dvb-frontends/au8522_common.c
+++ b/drivers/media/dvb-frontends/au8522_common.c
@@ -44,7 +44,7 @@ int au8522_writereg(struct au8522_state *state, u16 reg, u8 data)
44 int ret; 44 int ret;
45 u8 buf[] = { (reg >> 8) | 0x80, reg & 0xff, data }; 45 u8 buf[] = { (reg >> 8) | 0x80, reg & 0xff, data };
46 46
47 struct i2c_msg msg = { .addr = state->config->demod_address, 47 struct i2c_msg msg = { .addr = state->config.demod_address,
48 .flags = 0, .buf = buf, .len = 3 }; 48 .flags = 0, .buf = buf, .len = 3 };
49 49
50 ret = i2c_transfer(state->i2c, &msg, 1); 50 ret = i2c_transfer(state->i2c, &msg, 1);
@@ -64,9 +64,9 @@ u8 au8522_readreg(struct au8522_state *state, u16 reg)
64 u8 b1[] = { 0 }; 64 u8 b1[] = { 0 };
65 65
66 struct i2c_msg msg[] = { 66 struct i2c_msg msg[] = {
67 { .addr = state->config->demod_address, .flags = 0, 67 { .addr = state->config.demod_address, .flags = 0,
68 .buf = b0, .len = 2 }, 68 .buf = b0, .len = 2 },
69 { .addr = state->config->demod_address, .flags = I2C_M_RD, 69 { .addr = state->config.demod_address, .flags = I2C_M_RD,
70 .buf = b1, .len = 1 } }; 70 .buf = b1, .len = 1 } };
71 71
72 ret = i2c_transfer(state->i2c, msg, 2); 72 ret = i2c_transfer(state->i2c, msg, 2);
@@ -140,7 +140,7 @@ EXPORT_SYMBOL(au8522_release_state);
140 140
141static int au8522_led_gpio_enable(struct au8522_state *state, int onoff) 141static int au8522_led_gpio_enable(struct au8522_state *state, int onoff)
142{ 142{
143 struct au8522_led_config *led_config = state->config->led_cfg; 143 struct au8522_led_config *led_config = state->config.led_cfg;
144 u8 val; 144 u8 val;
145 145
146 /* bail out if we can't control an LED */ 146 /* bail out if we can't control an LED */
@@ -170,7 +170,7 @@ static int au8522_led_gpio_enable(struct au8522_state *state, int onoff)
170 */ 170 */
171int au8522_led_ctrl(struct au8522_state *state, int led) 171int au8522_led_ctrl(struct au8522_state *state, int led)
172{ 172{
173 struct au8522_led_config *led_config = state->config->led_cfg; 173 struct au8522_led_config *led_config = state->config.led_cfg;
174 int i, ret = 0; 174 int i, ret = 0;
175 175
176 /* bail out if we can't control an LED */ 176 /* bail out if we can't control an LED */
diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c
index 28d7dc2fee34..c8f13d8370e5 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -730,7 +730,6 @@ static int au8522_probe(struct i2c_client *client,
730 struct v4l2_ctrl_handler *hdl; 730 struct v4l2_ctrl_handler *hdl;
731 struct v4l2_subdev *sd; 731 struct v4l2_subdev *sd;
732 int instance; 732 int instance;
733 struct au8522_config *demod_config;
734 733
735 /* Check if the adapter supports the needed features */ 734 /* Check if the adapter supports the needed features */
736 if (!i2c_check_functionality(client->adapter, 735 if (!i2c_check_functionality(client->adapter,
@@ -754,15 +753,7 @@ static int au8522_probe(struct i2c_client *client,
754 break; 753 break;
755 } 754 }
756 755
757 demod_config = kzalloc(sizeof(struct au8522_config), GFP_KERNEL); 756 state->config.demod_address = 0x8e >> 1;
758 if (demod_config == NULL) {
759 if (instance == 1)
760 kfree(state);
761 return -ENOMEM;
762 }
763 demod_config->demod_address = 0x8e >> 1;
764
765 state->config = demod_config;
766 state->i2c = client->adapter; 757 state->i2c = client->adapter;
767 758
768 sd = &state->sd; 759 sd = &state->sd;
@@ -784,8 +775,7 @@ static int au8522_probe(struct i2c_client *client,
784 int err = hdl->error; 775 int err = hdl->error;
785 776
786 v4l2_ctrl_handler_free(hdl); 777 v4l2_ctrl_handler_free(hdl);
787 kfree(demod_config); 778 au8522_release_state(state);
788 kfree(state);
789 return err; 779 return err;
790 } 780 }
791 781
diff --git a/drivers/media/dvb-frontends/au8522_dig.c b/drivers/media/dvb-frontends/au8522_dig.c
index f956f13fb3dc..6c1e97640f3f 100644
--- a/drivers/media/dvb-frontends/au8522_dig.c
+++ b/drivers/media/dvb-frontends/au8522_dig.c
@@ -566,7 +566,7 @@ static int au8522_enable_modulation(struct dvb_frontend *fe,
566 au8522_writereg(state, 566 au8522_writereg(state,
567 VSB_mod_tab[i].reg, 567 VSB_mod_tab[i].reg,
568 VSB_mod_tab[i].data); 568 VSB_mod_tab[i].data);
569 au8522_set_if(fe, state->config->vsb_if); 569 au8522_set_if(fe, state->config.vsb_if);
570 break; 570 break;
571 case QAM_64: 571 case QAM_64:
572 dprintk("%s() QAM 64\n", __func__); 572 dprintk("%s() QAM 64\n", __func__);
@@ -574,7 +574,7 @@ static int au8522_enable_modulation(struct dvb_frontend *fe,
574 au8522_writereg(state, 574 au8522_writereg(state,
575 QAM64_mod_tab[i].reg, 575 QAM64_mod_tab[i].reg,
576 QAM64_mod_tab[i].data); 576 QAM64_mod_tab[i].data);
577 au8522_set_if(fe, state->config->qam_if); 577 au8522_set_if(fe, state->config.qam_if);
578 break; 578 break;
579 case QAM_256: 579 case QAM_256:
580 if (zv_mode) { 580 if (zv_mode) {
@@ -583,7 +583,7 @@ static int au8522_enable_modulation(struct dvb_frontend *fe,
583 au8522_writereg(state, 583 au8522_writereg(state,
584 QAM256_mod_tab_zv_mode[i].reg, 584 QAM256_mod_tab_zv_mode[i].reg,
585 QAM256_mod_tab_zv_mode[i].data); 585 QAM256_mod_tab_zv_mode[i].data);
586 au8522_set_if(fe, state->config->qam_if); 586 au8522_set_if(fe, state->config.qam_if);
587 msleep(100); 587 msleep(100);
588 au8522_writereg(state, 0x821a, 0x00); 588 au8522_writereg(state, 0x821a, 0x00);
589 } else { 589 } else {
@@ -592,7 +592,7 @@ static int au8522_enable_modulation(struct dvb_frontend *fe,
592 au8522_writereg(state, 592 au8522_writereg(state,
593 QAM256_mod_tab[i].reg, 593 QAM256_mod_tab[i].reg,
594 QAM256_mod_tab[i].data); 594 QAM256_mod_tab[i].data);
595 au8522_set_if(fe, state->config->qam_if); 595 au8522_set_if(fe, state->config.qam_if);
596 } 596 }
597 break; 597 break;
598 default: 598 default:
@@ -666,7 +666,7 @@ static int au8522_read_status(struct dvb_frontend *fe, enum fe_status *status)
666 *status |= FE_HAS_LOCK | FE_HAS_SYNC; 666 *status |= FE_HAS_LOCK | FE_HAS_SYNC;
667 } 667 }
668 668
669 switch (state->config->status_mode) { 669 switch (state->config.status_mode) {
670 case AU8522_DEMODLOCKING: 670 case AU8522_DEMODLOCKING:
671 dprintk("%s() DEMODLOCKING\n", __func__); 671 dprintk("%s() DEMODLOCKING\n", __func__);
672 if (*status & FE_HAS_VITERBI) 672 if (*status & FE_HAS_VITERBI)
@@ -704,7 +704,7 @@ static int au8522_read_status(struct dvb_frontend *fe, enum fe_status *status)
704 704
705static int au8522_led_status(struct au8522_state *state, const u16 *snr) 705static int au8522_led_status(struct au8522_state *state, const u16 *snr)
706{ 706{
707 struct au8522_led_config *led_config = state->config->led_cfg; 707 struct au8522_led_config *led_config = state->config.led_cfg;
708 int led; 708 int led;
709 u16 strong; 709 u16 strong;
710 710
@@ -758,7 +758,7 @@ static int au8522_read_snr(struct dvb_frontend *fe, u16 *snr)
758 au8522_readreg(state, 0x4311), 758 au8522_readreg(state, 0x4311),
759 snr); 759 snr);
760 760
761 if (state->config->led_cfg) 761 if (state->config.led_cfg)
762 au8522_led_status(state, snr); 762 au8522_led_status(state, snr);
763 763
764 return ret; 764 return ret;
@@ -866,7 +866,7 @@ struct dvb_frontend *au8522_attach(const struct au8522_config *config,
866 } 866 }
867 867
868 /* setup the state */ 868 /* setup the state */
869 state->config = config; 869 state->config = *config;
870 state->i2c = i2c; 870 state->i2c = i2c;
871 state->operational_mode = AU8522_DIGITAL_MODE; 871 state->operational_mode = AU8522_DIGITAL_MODE;
872 872
diff --git a/drivers/media/dvb-frontends/au8522_priv.h b/drivers/media/dvb-frontends/au8522_priv.h
index 951b3847e6f6..ee330c61aa61 100644
--- a/drivers/media/dvb-frontends/au8522_priv.h
+++ b/drivers/media/dvb-frontends/au8522_priv.h
@@ -50,7 +50,7 @@ struct au8522_state {
50 struct list_head hybrid_tuner_instance_list; 50 struct list_head hybrid_tuner_instance_list;
51 51
52 /* configuration settings */ 52 /* configuration settings */
53 const struct au8522_config *config; 53 struct au8522_config config;
54 54
55 struct dvb_frontend frontend; 55 struct dvb_frontend frontend;
56 56
diff --git a/drivers/media/dvb-frontends/bsbe1-d01a.h b/drivers/media/dvb-frontends/bsbe1-d01a.h
index 7ed3c424178c..baaf89e768cf 100644
--- a/drivers/media/dvb-frontends/bsbe1-d01a.h
+++ b/drivers/media/dvb-frontends/bsbe1-d01a.h
@@ -21,7 +21,7 @@
21 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 21 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
22 * 22 *
23 * 23 *
24 * the project's page is at http://www.linuxtv.org 24 * the project's page is at https://linuxtv.org
25 */ 25 */
26 26
27#ifndef BSBE1_D01A_H 27#ifndef BSBE1_D01A_H
diff --git a/drivers/media/dvb-frontends/bsbe1.h b/drivers/media/dvb-frontends/bsbe1.h
index 53e4d0dbb745..4ad766154741 100644
--- a/drivers/media/dvb-frontends/bsbe1.h
+++ b/drivers/media/dvb-frontends/bsbe1.h
@@ -19,7 +19,7 @@
19 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
20 * 20 *
21 * 21 *
22 * the project's page is at http://www.linuxtv.org 22 * the project's page is at https://linuxtv.org
23 */ 23 */
24 24
25#ifndef BSBE1_H 25#ifndef BSBE1_H
diff --git a/drivers/media/dvb-frontends/bsru6.h b/drivers/media/dvb-frontends/bsru6.h
index c2a578e1314d..275c1782597d 100644
--- a/drivers/media/dvb-frontends/bsru6.h
+++ b/drivers/media/dvb-frontends/bsru6.h
@@ -19,7 +19,7 @@
19 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
20 * 20 *
21 * 21 *
22 * the project's page is at http://www.linuxtv.org 22 * the project's page is at https://linuxtv.org
23 */ 23 */
24 24
25#ifndef BSRU6_H 25#ifndef BSRU6_H
diff --git a/drivers/media/dvb-frontends/isl6405.c b/drivers/media/dvb-frontends/isl6405.c
index b46450a10b80..6913cd687b4d 100644
--- a/drivers/media/dvb-frontends/isl6405.c
+++ b/drivers/media/dvb-frontends/isl6405.c
@@ -22,7 +22,7 @@
22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
23 * 23 *
24 * 24 *
25 * the project's page is at http://www.linuxtv.org 25 * the project's page is at https://linuxtv.org
26 */ 26 */
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/errno.h> 28#include <linux/errno.h>
diff --git a/drivers/media/dvb-frontends/isl6405.h b/drivers/media/dvb-frontends/isl6405.h
index 3c148b830bd1..4a23d3bdf3e6 100644
--- a/drivers/media/dvb-frontends/isl6405.h
+++ b/drivers/media/dvb-frontends/isl6405.h
@@ -22,7 +22,7 @@
22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
23 * 23 *
24 * 24 *
25 * the project's page is at http://www.linuxtv.org 25 * the project's page is at https://linuxtv.org
26 */ 26 */
27 27
28#ifndef _ISL6405_H 28#ifndef _ISL6405_H
diff --git a/drivers/media/dvb-frontends/isl6421.c b/drivers/media/dvb-frontends/isl6421.c
index 3a4d4606a426..0b6d3837d5de 100644
--- a/drivers/media/dvb-frontends/isl6421.c
+++ b/drivers/media/dvb-frontends/isl6421.c
@@ -22,7 +22,7 @@
22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
23 * 23 *
24 * 24 *
25 * the project's page is at http://www.linuxtv.org 25 * the project's page is at https://linuxtv.org
26 */ 26 */
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/errno.h> 28#include <linux/errno.h>
diff --git a/drivers/media/dvb-frontends/isl6421.h b/drivers/media/dvb-frontends/isl6421.h
index 3273597833fd..00f9874ca5a2 100644
--- a/drivers/media/dvb-frontends/isl6421.h
+++ b/drivers/media/dvb-frontends/isl6421.h
@@ -22,7 +22,7 @@
22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
23 * 23 *
24 * 24 *
25 * the project's page is at http://www.linuxtv.org 25 * the project's page is at https://linuxtv.org
26 */ 26 */
27 27
28#ifndef _ISL6421_H 28#ifndef _ISL6421_H
diff --git a/drivers/media/dvb-frontends/lnbp21.c b/drivers/media/dvb-frontends/lnbp21.c
index 4aca0fb9a8a7..6261460d93a7 100644
--- a/drivers/media/dvb-frontends/lnbp21.c
+++ b/drivers/media/dvb-frontends/lnbp21.c
@@ -22,7 +22,7 @@
22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
23 * 23 *
24 * 24 *
25 * the project's page is at http://www.linuxtv.org 25 * the project's page is at https://linuxtv.org
26 */ 26 */
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/errno.h> 28#include <linux/errno.h>
diff --git a/drivers/media/dvb-frontends/lnbp21.h b/drivers/media/dvb-frontends/lnbp21.h
index a9b530de62a6..cd9101f6e579 100644
--- a/drivers/media/dvb-frontends/lnbp21.h
+++ b/drivers/media/dvb-frontends/lnbp21.h
@@ -21,7 +21,7 @@
21 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 21 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
22 * 22 *
23 * 23 *
24 * the project's page is at http://www.linuxtv.org 24 * the project's page is at https://linuxtv.org
25 */ 25 */
26 26
27#ifndef _LNBP21_H 27#ifndef _LNBP21_H
diff --git a/drivers/media/dvb-frontends/lnbp22.c b/drivers/media/dvb-frontends/lnbp22.c
index d7ca0fdd0084..5c5fd04fd4a7 100644
--- a/drivers/media/dvb-frontends/lnbp22.c
+++ b/drivers/media/dvb-frontends/lnbp22.c
@@ -22,7 +22,7 @@
22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
23 * 23 *
24 * 24 *
25 * the project's page is at http://www.linuxtv.org 25 * the project's page is at https://linuxtv.org
26 */ 26 */
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/errno.h> 28#include <linux/errno.h>
diff --git a/drivers/media/dvb-frontends/lnbp22.h b/drivers/media/dvb-frontends/lnbp22.h
index 628148385182..5d01d92814c2 100644
--- a/drivers/media/dvb-frontends/lnbp22.h
+++ b/drivers/media/dvb-frontends/lnbp22.h
@@ -22,7 +22,7 @@
22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
23 * 23 *
24 * 24 *
25 * the project's page is at http://www.linuxtv.org 25 * the project's page is at https://linuxtv.org
26 */ 26 */
27 27
28#ifndef _LNBP22_H 28#ifndef _LNBP22_H
diff --git a/drivers/media/dvb-frontends/rtl2832.c b/drivers/media/dvb-frontends/rtl2832.c
index 78b87b260d74..10f2119935da 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -976,7 +976,8 @@ static int rtl2832_regmap_read(void *context, const void *reg_buf,
976 976
977 ret = __i2c_transfer(client->adapter, msg, 2); 977 ret = __i2c_transfer(client->adapter, msg, 2);
978 if (ret != 2) { 978 if (ret != 2) {
979 dev_warn(&client->dev, "i2c reg read failed %d\n", ret); 979 dev_warn(&client->dev, "i2c reg read failed %d reg %02x\n",
980 ret, *(u8 *)reg_buf);
980 if (ret >= 0) 981 if (ret >= 0)
981 ret = -EREMOTEIO; 982 ret = -EREMOTEIO;
982 return ret; 983 return ret;
@@ -999,7 +1000,8 @@ static int rtl2832_regmap_write(void *context, const void *data, size_t count)
999 1000
1000 ret = __i2c_transfer(client->adapter, msg, 1); 1001 ret = __i2c_transfer(client->adapter, msg, 1);
1001 if (ret != 1) { 1002 if (ret != 1) {
1002 dev_warn(&client->dev, "i2c reg write failed %d\n", ret); 1003 dev_warn(&client->dev, "i2c reg write failed %d reg %02x\n",
1004 ret, *(u8 *)data);
1003 if (ret >= 0) 1005 if (ret >= 0)
1004 ret = -EREMOTEIO; 1006 ret = -EREMOTEIO;
1005 return ret; 1007 return ret;
@@ -1028,7 +1030,8 @@ static int rtl2832_regmap_gather_write(void *context, const void *reg,
1028 1030
1029 ret = __i2c_transfer(client->adapter, msg, 1); 1031 ret = __i2c_transfer(client->adapter, msg, 1);
1030 if (ret != 1) { 1032 if (ret != 1) {
1031 dev_warn(&client->dev, "i2c reg write failed %d\n", ret); 1033 dev_warn(&client->dev, "i2c reg write failed %d reg %02x\n",
1034 ret, *(u8 const *)reg);
1032 if (ret >= 0) 1035 if (ret >= 0)
1033 ret = -EREMOTEIO; 1036 ret = -EREMOTEIO;
1034 return ret; 1037 return ret;
@@ -1097,18 +1100,6 @@ static int rtl2832_enable_slave_ts(struct i2c_client *client)
1097 if (ret) 1100 if (ret)
1098 goto err; 1101 goto err;
1099 1102
1100 ret = rtl2832_bulk_write(client, 0x022, "\x01", 1);
1101 if (ret)
1102 goto err;
1103
1104 ret = rtl2832_bulk_write(client, 0x026, "\x1f", 1);
1105 if (ret)
1106 goto err;
1107
1108 ret = rtl2832_bulk_write(client, 0x027, "\xff", 1);
1109 if (ret)
1110 goto err;
1111
1112 ret = rtl2832_bulk_write(client, 0x192, "\x7f\xf7\xff", 3); 1103 ret = rtl2832_bulk_write(client, 0x192, "\x7f\xf7\xff", 3);
1113 if (ret) 1104 if (ret)
1114 goto err; 1105 goto err;
diff --git a/drivers/media/dvb-frontends/rtl2832_sdr.c b/drivers/media/dvb-frontends/rtl2832_sdr.c
index dcd8d94c1037..b860f02a4e55 100644
--- a/drivers/media/dvb-frontends/rtl2832_sdr.c
+++ b/drivers/media/dvb-frontends/rtl2832_sdr.c
@@ -310,7 +310,7 @@ static void rtl2832_sdr_urb_complete(struct urb *urb)
310 len = rtl2832_sdr_convert_stream(dev, ptr, urb->transfer_buffer, 310 len = rtl2832_sdr_convert_stream(dev, ptr, urb->transfer_buffer,
311 urb->actual_length); 311 urb->actual_length);
312 vb2_set_plane_payload(&fbuf->vb.vb2_buf, 0, len); 312 vb2_set_plane_payload(&fbuf->vb.vb2_buf, 0, len);
313 v4l2_get_timestamp(&fbuf->vb.timestamp); 313 fbuf->vb.vb2_buf.timestamp = ktime_get_ns();
314 fbuf->vb.sequence = dev->sequence++; 314 fbuf->vb.sequence = dev->sequence++;
315 vb2_buffer_done(&fbuf->vb.vb2_buf, VB2_BUF_STATE_DONE); 315 vb2_buffer_done(&fbuf->vb.vb2_buf, VB2_BUF_STATE_DONE);
316 } 316 }
@@ -490,7 +490,7 @@ static int rtl2832_sdr_querycap(struct file *file, void *fh,
490 490
491/* Videobuf2 operations */ 491/* Videobuf2 operations */
492static int rtl2832_sdr_queue_setup(struct vb2_queue *vq, 492static int rtl2832_sdr_queue_setup(struct vb2_queue *vq,
493 const void *parg, unsigned int *nbuffers, 493 unsigned int *nbuffers,
494 unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) 494 unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[])
495{ 495{
496 struct rtl2832_sdr_dev *dev = vb2_get_drv_priv(vq); 496 struct rtl2832_sdr_dev *dev = vb2_get_drv_priv(vq);
diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index 7c2eeee69757..1cf6e52e0105 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -1,21 +1,21 @@
1/* 1/*
2 Driver for Silicon Labs Si2161 DVB-T and Si2165 DVB-C/-T Demodulator 2 * Driver for Silicon Labs Si2161 DVB-T and Si2165 DVB-C/-T Demodulator
3 3 *
4 Copyright (C) 2013-2014 Matthias Schwarzott <zzam@gentoo.org> 4 * Copyright (C) 2013-2014 Matthias Schwarzott <zzam@gentoo.org>
5 5 *
6 This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 * the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 * (at your option) any later version.
10 10 *
11 This program is distributed in the hope that it will be useful, 11 * This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 * GNU General Public License for more details.
15 15 *
16 References: 16 * References:
17 http://www.silabs.com/Support%20Documents/TechnicalDocs/Si2165-short.pdf 17 * http://www.silabs.com/Support%20Documents/TechnicalDocs/Si2165-short.pdf
18*/ 18 */
19 19
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/errno.h> 21#include <linux/errno.h>
@@ -31,16 +31,18 @@
31#include "si2165_priv.h" 31#include "si2165_priv.h"
32#include "si2165.h" 32#include "si2165.h"
33 33
34/* Hauppauge WinTV-HVR-930C-HD B130 / PCTV QuatroStick 521e 1113xx 34/*
35 * uses 16 MHz xtal */ 35 * Hauppauge WinTV-HVR-930C-HD B130 / PCTV QuatroStick 521e 1113xx
36 36 * uses 16 MHz xtal
37/* Hauppauge WinTV-HVR-930C-HD B131 / PCTV QuatroStick 522e 1114xx 37 *
38 * uses 24 MHz clock provided by tuner */ 38 * Hauppauge WinTV-HVR-930C-HD B131 / PCTV QuatroStick 522e 1114xx
39 * uses 24 MHz clock provided by tuner
40 */
39 41
40struct si2165_state { 42struct si2165_state {
41 struct i2c_adapter *i2c; 43 struct i2c_adapter *i2c;
42 44
43 struct dvb_frontend frontend; 45 struct dvb_frontend fe;
44 46
45 struct si2165_config config; 47 struct si2165_config config;
46 48
@@ -241,6 +243,27 @@ err:
241 return ret; 243 return ret;
242} 244}
243 245
246#define REG16(reg, val) { (reg), (val) & 0xff }, { (reg)+1, (val)>>8 & 0xff }
247struct si2165_reg_value_pair {
248 u16 reg;
249 u8 val;
250};
251
252static int si2165_write_reg_list(struct si2165_state *state,
253 const struct si2165_reg_value_pair *regs,
254 int count)
255{
256 int i;
257 int ret;
258
259 for (i = 0; i < count; i++) {
260 ret = si2165_writereg8(state, regs[i].reg, regs[i].val);
261 if (ret < 0)
262 return ret;
263 }
264 return 0;
265}
266
244static int si2165_get_tune_settings(struct dvb_frontend *fe, 267static int si2165_get_tune_settings(struct dvb_frontend *fe,
245 struct dvb_frontend_tune_settings *s) 268 struct dvb_frontend_tune_settings *s)
246{ 269{
@@ -258,8 +281,10 @@ static int si2165_init_pll(struct si2165_state *state)
258 u8 divl = 12; 281 u8 divl = 12;
259 u8 buf[4]; 282 u8 buf[4];
260 283
261 /* hardcoded values can be deleted if calculation is verified 284 /*
262 * or it yields the same values as the windows driver */ 285 * hardcoded values can be deleted if calculation is verified
286 * or it yields the same values as the windows driver
287 */
263 switch (ref_freq_Hz) { 288 switch (ref_freq_Hz) {
264 case 16000000u: 289 case 16000000u:
265 divn = 56; 290 divn = 56;
@@ -274,8 +299,10 @@ static int si2165_init_pll(struct si2165_state *state)
274 if (ref_freq_Hz > 16000000u) 299 if (ref_freq_Hz > 16000000u)
275 divr = 2; 300 divr = 2;
276 301
277 /* now select divn and divp such that 302 /*
278 * fvco is in 1624..1824 MHz */ 303 * now select divn and divp such that
304 * fvco is in 1624..1824 MHz
305 */
279 if (1624000000u * divr > ref_freq_Hz * 2u * 63u) 306 if (1624000000u * divr > ref_freq_Hz * 2u * 63u)
280 divp = 4; 307 divp = 4;
281 308
@@ -341,10 +368,12 @@ static int si2165_upload_firmware_block(struct si2165_state *state,
341 if (len % 4 != 0) 368 if (len % 4 != 0)
342 return -EINVAL; 369 return -EINVAL;
343 370
344 deb_fw_load("si2165_upload_firmware_block called with len=0x%x offset=0x%x blockcount=0x%x\n", 371 deb_fw_load(
372 "si2165_upload_firmware_block called with len=0x%x offset=0x%x blockcount=0x%x\n",
345 len, offset, block_count); 373 len, offset, block_count);
346 while (offset+12 <= len && cur_block < block_count) { 374 while (offset+12 <= len && cur_block < block_count) {
347 deb_fw_load("si2165_upload_firmware_block in while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n", 375 deb_fw_load(
376 "si2165_upload_firmware_block in while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n",
348 len, offset, cur_block, block_count); 377 len, offset, cur_block, block_count);
349 wordcount = data[offset]; 378 wordcount = data[offset];
350 if (wordcount < 1 || data[offset+1] || 379 if (wordcount < 1 || data[offset+1] ||
@@ -383,7 +412,8 @@ static int si2165_upload_firmware_block(struct si2165_state *state,
383 cur_block++; 412 cur_block++;
384 } 413 }
385 414
386 deb_fw_load("si2165_upload_firmware_block after while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n", 415 deb_fw_load(
416 "si2165_upload_firmware_block after while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n",
387 len, offset, cur_block, block_count); 417 len, offset, cur_block, block_count);
388 418
389 if (poffset) 419 if (poffset)
@@ -633,7 +663,7 @@ static int si2165_init(struct dvb_frontend *fe)
633 goto error; 663 goto error;
634 664
635 /* ber_pkt */ 665 /* ber_pkt */
636 ret = si2165_writereg16(state, 0x0470 , 0x7530); 666 ret = si2165_writereg16(state, 0x0470, 0x7530);
637 if (ret < 0) 667 if (ret < 0)
638 goto error; 668 goto error;
639 669
@@ -660,22 +690,19 @@ static int si2165_init(struct dvb_frontend *fe)
660 goto error; 690 goto error;
661 } 691 }
662 692
663 /* write adc values after each reset*/ 693 /* ts output config */
664 ret = si2165_writereg8(state, 0x012a, 0x46); 694 ret = si2165_writereg8(state, 0x04e4, 0x20);
665 if (ret < 0)
666 goto error;
667 ret = si2165_writereg8(state, 0x012c, 0x00);
668 if (ret < 0) 695 if (ret < 0)
669 goto error; 696 return ret;
670 ret = si2165_writereg8(state, 0x012e, 0x0a); 697 ret = si2165_writereg16(state, 0x04ef, 0x00fe);
671 if (ret < 0) 698 if (ret < 0)
672 goto error; 699 return ret;
673 ret = si2165_writereg8(state, 0x012f, 0xff); 700 ret = si2165_writereg24(state, 0x04f4, 0x555555);
674 if (ret < 0) 701 if (ret < 0)
675 goto error; 702 return ret;
676 ret = si2165_writereg8(state, 0x0123, 0x70); 703 ret = si2165_writereg8(state, 0x04e5, 0x01);
677 if (ret < 0) 704 if (ret < 0)
678 goto error; 705 return ret;
679 706
680 return 0; 707 return 0;
681error: 708error:
@@ -733,16 +760,26 @@ static int si2165_set_oversamp(struct si2165_state *state, u32 dvb_rate)
733 do_div(oversamp, dvb_rate); 760 do_div(oversamp, dvb_rate);
734 reg_value = oversamp & 0x3fffffff; 761 reg_value = oversamp & 0x3fffffff;
735 762
736 /* oversamp, usbdump contained 0x03100000; */ 763 dprintk("%s: Write oversamp=%#x\n", __func__, reg_value);
737 return si2165_writereg32(state, 0x00e4, reg_value); 764 return si2165_writereg32(state, 0x00e4, reg_value);
738} 765}
739 766
740static int si2165_set_if_freq_shift(struct si2165_state *state, u32 IF) 767static int si2165_set_if_freq_shift(struct si2165_state *state)
741{ 768{
769 struct dvb_frontend *fe = &state->fe;
742 u64 if_freq_shift; 770 u64 if_freq_shift;
743 s32 reg_value = 0; 771 s32 reg_value = 0;
744 u32 fe_clk = si2165_get_fe_clk(state); 772 u32 fe_clk = si2165_get_fe_clk(state);
773 u32 IF = 0;
745 774
775 if (!fe->ops.tuner_ops.get_if_frequency) {
776 dev_err(&state->i2c->dev,
777 "%s: Error: get_if_frequency() not defined at tuner. Can't work without it!\n",
778 KBUILD_MODNAME);
779 return -EINVAL;
780 }
781
782 fe->ops.tuner_ops.get_if_frequency(fe, &IF);
746 if_freq_shift = IF; 783 if_freq_shift = IF;
747 if_freq_shift <<= 29; 784 if_freq_shift <<= 29;
748 785
@@ -758,25 +795,39 @@ static int si2165_set_if_freq_shift(struct si2165_state *state, u32 IF)
758 return si2165_writereg32(state, 0x00e8, reg_value); 795 return si2165_writereg32(state, 0x00e8, reg_value);
759} 796}
760 797
761static int si2165_set_parameters(struct dvb_frontend *fe) 798static const struct si2165_reg_value_pair dvbt_regs[] = {
799 /* standard = DVB-T */
800 { 0x00ec, 0x01 },
801 { 0x08f8, 0x00 },
802 /* impulsive_noise_remover */
803 { 0x031c, 0x01 },
804 { 0x00cb, 0x00 },
805 /* agc2 */
806 { 0x016e, 0x41 },
807 { 0x016c, 0x0e },
808 { 0x016d, 0x10 },
809 /* agc */
810 { 0x015b, 0x03 },
811 { 0x0150, 0x78 },
812 /* agc */
813 { 0x01a0, 0x78 },
814 { 0x01c8, 0x68 },
815 /* freq_sync_range */
816 REG16(0x030c, 0x0064),
817 /* gp_reg0 */
818 { 0x0387, 0x00 }
819};
820
821static int si2165_set_frontend_dvbt(struct dvb_frontend *fe)
762{ 822{
763 int ret; 823 int ret;
764 struct dtv_frontend_properties *p = &fe->dtv_property_cache; 824 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
765 struct si2165_state *state = fe->demodulator_priv; 825 struct si2165_state *state = fe->demodulator_priv;
766 u8 val[3];
767 u32 IF;
768 u32 dvb_rate = 0; 826 u32 dvb_rate = 0;
769 u16 bw10k; 827 u16 bw10k;
770 828
771 dprintk("%s: called\n", __func__); 829 dprintk("%s: called\n", __func__);
772 830
773 if (!fe->ops.tuner_ops.get_if_frequency) {
774 dev_err(&state->i2c->dev,
775 "%s: Error: get_if_frequency() not defined at tuner. Can't work without it!\n",
776 KBUILD_MODNAME);
777 return -EINVAL;
778 }
779
780 if (!state->has_dvbt) 831 if (!state->has_dvbt)
781 return -EINVAL; 832 return -EINVAL;
782 833
@@ -788,34 +839,10 @@ static int si2165_set_parameters(struct dvb_frontend *fe)
788 bw10k = 800; 839 bw10k = 800;
789 } 840 }
790 841
791 /* standard = DVB-T */
792 ret = si2165_writereg8(state, 0x00ec, 0x01);
793 if (ret < 0)
794 return ret;
795 ret = si2165_adjust_pll_divl(state, 12); 842 ret = si2165_adjust_pll_divl(state, 12);
796 if (ret < 0) 843 if (ret < 0)
797 return ret; 844 return ret;
798 845
799 fe->ops.tuner_ops.get_if_frequency(fe, &IF);
800 ret = si2165_set_if_freq_shift(state, IF);
801 if (ret < 0)
802 return ret;
803 ret = si2165_writereg8(state, 0x08f8, 0x00);
804 if (ret < 0)
805 return ret;
806 /* ts output config */
807 ret = si2165_writereg8(state, 0x04e4, 0x20);
808 if (ret < 0)
809 return ret;
810 ret = si2165_writereg16(state, 0x04ef, 0x00fe);
811 if (ret < 0)
812 return ret;
813 ret = si2165_writereg24(state, 0x04f4, 0x555555);
814 if (ret < 0)
815 return ret;
816 ret = si2165_writereg8(state, 0x04e5, 0x01);
817 if (ret < 0)
818 return ret;
819 /* bandwidth in 10KHz steps */ 846 /* bandwidth in 10KHz steps */
820 ret = si2165_writereg16(state, 0x0308, bw10k); 847 ret = si2165_writereg16(state, 0x0308, bw10k);
821 if (ret < 0) 848 if (ret < 0)
@@ -823,48 +850,115 @@ static int si2165_set_parameters(struct dvb_frontend *fe)
823 ret = si2165_set_oversamp(state, dvb_rate); 850 ret = si2165_set_oversamp(state, dvb_rate);
824 if (ret < 0) 851 if (ret < 0)
825 return ret; 852 return ret;
826 /* impulsive_noise_remover */ 853
827 ret = si2165_writereg8(state, 0x031c, 0x01); 854 ret = si2165_write_reg_list(state, dvbt_regs, ARRAY_SIZE(dvbt_regs));
828 if (ret < 0)
829 return ret;
830 ret = si2165_writereg8(state, 0x00cb, 0x00);
831 if (ret < 0) 855 if (ret < 0)
832 return ret; 856 return ret;
857
858 return 0;
859}
860
861static const struct si2165_reg_value_pair dvbc_regs[] = {
862 /* standard = DVB-C */
863 { 0x00ec, 0x05 },
864 { 0x08f8, 0x00 },
865
833 /* agc2 */ 866 /* agc2 */
834 ret = si2165_writereg8(state, 0x016e, 0x41); 867 { 0x016e, 0x50 },
835 if (ret < 0) 868 { 0x016c, 0x0e },
836 return ret; 869 { 0x016d, 0x10 },
837 ret = si2165_writereg8(state, 0x016c, 0x0e);
838 if (ret < 0)
839 return ret;
840 ret = si2165_writereg8(state, 0x016d, 0x10);
841 if (ret < 0)
842 return ret;
843 /* agc */ 870 /* agc */
844 ret = si2165_writereg8(state, 0x015b, 0x03); 871 { 0x015b, 0x03 },
845 if (ret < 0) 872 { 0x0150, 0x68 },
846 return ret;
847 ret = si2165_writereg8(state, 0x0150, 0x78);
848 if (ret < 0)
849 return ret;
850 /* agc */ 873 /* agc */
851 ret = si2165_writereg8(state, 0x01a0, 0x78); 874 { 0x01a0, 0x68 },
875 { 0x01c8, 0x50 },
876
877 { 0x0278, 0x0d },
878
879 { 0x023a, 0x05 },
880 { 0x0261, 0x09 },
881 REG16(0x0350, 0x3e80),
882 { 0x02f4, 0x00 },
883
884 { 0x00cb, 0x01 },
885 REG16(0x024c, 0x0000),
886 REG16(0x027c, 0x0000),
887 { 0x0232, 0x03 },
888 { 0x02f4, 0x0b },
889 { 0x018b, 0x00 },
890};
891
892static int si2165_set_frontend_dvbc(struct dvb_frontend *fe)
893{
894 struct si2165_state *state = fe->demodulator_priv;
895 int ret;
896 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
897 const u32 dvb_rate = p->symbol_rate;
898 const u32 bw_hz = p->bandwidth_hz;
899
900 if (!state->has_dvbc)
901 return -EINVAL;
902
903 if (dvb_rate == 0)
904 return -EINVAL;
905
906 ret = si2165_adjust_pll_divl(state, 14);
852 if (ret < 0) 907 if (ret < 0)
853 return ret; 908 return ret;
854 ret = si2165_writereg8(state, 0x01c8, 0x68); 909
910 /* Oversampling */
911 ret = si2165_set_oversamp(state, dvb_rate);
855 if (ret < 0) 912 if (ret < 0)
856 return ret; 913 return ret;
857 /* freq_sync_range */ 914
858 ret = si2165_writereg16(state, 0x030c, 0x0064); 915 ret = si2165_writereg32(state, 0x00c4, bw_hz);
859 if (ret < 0) 916 if (ret < 0)
860 return ret; 917 return ret;
861 /* gp_reg0 */ 918
862 ret = si2165_readreg8(state, 0x0387, val); 919 ret = si2165_write_reg_list(state, dvbc_regs, ARRAY_SIZE(dvbc_regs));
863 if (ret < 0) 920 if (ret < 0)
864 return ret; 921 return ret;
865 ret = si2165_writereg8(state, 0x0387, 0x00); 922
923 return 0;
924}
925
926static const struct si2165_reg_value_pair agc_rewrite[] = {
927 { 0x012a, 0x46 },
928 { 0x012c, 0x00 },
929 { 0x012e, 0x0a },
930 { 0x012f, 0xff },
931 { 0x0123, 0x70 }
932};
933
934static int si2165_set_frontend(struct dvb_frontend *fe)
935{
936 struct si2165_state *state = fe->demodulator_priv;
937 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
938 u32 delsys = p->delivery_system;
939 int ret;
940 u8 val[3];
941
942 /* initial setting of if freq shift */
943 ret = si2165_set_if_freq_shift(state);
866 if (ret < 0) 944 if (ret < 0)
867 return ret; 945 return ret;
946
947 switch (delsys) {
948 case SYS_DVBT:
949 ret = si2165_set_frontend_dvbt(fe);
950 if (ret < 0)
951 return ret;
952 break;
953 case SYS_DVBC_ANNEX_A:
954 ret = si2165_set_frontend_dvbc(fe);
955 if (ret < 0)
956 return ret;
957 break;
958 default:
959 return -EINVAL;
960 }
961
868 /* dsp_addr_jump */ 962 /* dsp_addr_jump */
869 ret = si2165_writereg32(state, 0x0348, 0xf4000000); 963 ret = si2165_writereg32(state, 0x0348, 0xf4000000);
870 if (ret < 0) 964 if (ret < 0)
@@ -874,8 +968,7 @@ static int si2165_set_parameters(struct dvb_frontend *fe)
874 fe->ops.tuner_ops.set_params(fe); 968 fe->ops.tuner_ops.set_params(fe);
875 969
876 /* recalc if_freq_shift if IF might has changed */ 970 /* recalc if_freq_shift if IF might has changed */
877 fe->ops.tuner_ops.get_if_frequency(fe, &IF); 971 ret = si2165_set_if_freq_shift(state);
878 ret = si2165_set_if_freq_shift(state, IF);
879 if (ret < 0) 972 if (ret < 0)
880 return ret; 973 return ret;
881 974
@@ -886,6 +979,7 @@ static int si2165_set_parameters(struct dvb_frontend *fe)
886 ret = si2165_writereg8(state, 0x0341, 0x00); 979 ret = si2165_writereg8(state, 0x0341, 0x00);
887 if (ret < 0) 980 if (ret < 0)
888 return ret; 981 return ret;
982
889 /* reset all */ 983 /* reset all */
890 ret = si2165_writereg8(state, 0x00c0, 0x00); 984 ret = si2165_writereg8(state, 0x00c0, 0x00);
891 if (ret < 0) 985 if (ret < 0)
@@ -894,6 +988,13 @@ static int si2165_set_parameters(struct dvb_frontend *fe)
894 ret = si2165_writereg32(state, 0x0384, 0x00000000); 988 ret = si2165_writereg32(state, 0x0384, 0x00000000);
895 if (ret < 0) 989 if (ret < 0)
896 return ret; 990 return ret;
991
992 /* write adc values after each reset*/
993 ret = si2165_write_reg_list(state, agc_rewrite,
994 ARRAY_SIZE(agc_rewrite));
995 if (ret < 0)
996 return ret;
997
897 /* start_synchro */ 998 /* start_synchro */
898 ret = si2165_writereg8(state, 0x02e0, 0x01); 999 ret = si2165_writereg8(state, 0x02e0, 0x01);
899 if (ret < 0) 1000 if (ret < 0)
@@ -917,7 +1018,12 @@ static void si2165_release(struct dvb_frontend *fe)
917static struct dvb_frontend_ops si2165_ops = { 1018static struct dvb_frontend_ops si2165_ops = {
918 .info = { 1019 .info = {
919 .name = "Silicon Labs ", 1020 .name = "Silicon Labs ",
920 .caps = FE_CAN_FEC_1_2 | 1021 /* For DVB-C */
1022 .symbol_rate_min = 1000000,
1023 .symbol_rate_max = 7200000,
1024 /* For DVB-T */
1025 .frequency_stepsize = 166667,
1026 .caps = FE_CAN_FEC_1_2 |
921 FE_CAN_FEC_2_3 | 1027 FE_CAN_FEC_2_3 |
922 FE_CAN_FEC_3_4 | 1028 FE_CAN_FEC_3_4 |
923 FE_CAN_FEC_5_6 | 1029 FE_CAN_FEC_5_6 |
@@ -930,7 +1036,6 @@ static struct dvb_frontend_ops si2165_ops = {
930 FE_CAN_QAM_128 | 1036 FE_CAN_QAM_128 |
931 FE_CAN_QAM_256 | 1037 FE_CAN_QAM_256 |
932 FE_CAN_QAM_AUTO | 1038 FE_CAN_QAM_AUTO |
933 FE_CAN_TRANSMISSION_MODE_AUTO |
934 FE_CAN_GUARD_INTERVAL_AUTO | 1039 FE_CAN_GUARD_INTERVAL_AUTO |
935 FE_CAN_HIERARCHY_AUTO | 1040 FE_CAN_HIERARCHY_AUTO |
936 FE_CAN_MUTE_TS | 1041 FE_CAN_MUTE_TS |
@@ -943,7 +1048,7 @@ static struct dvb_frontend_ops si2165_ops = {
943 .init = si2165_init, 1048 .init = si2165_init,
944 .sleep = si2165_sleep, 1049 .sleep = si2165_sleep,
945 1050
946 .set_frontend = si2165_set_parameters, 1051 .set_frontend = si2165_set_frontend,
947 .read_status = si2165_read_status, 1052 .read_status = si2165_read_status,
948 1053
949 .release = si2165_release, 1054 .release = si2165_release,
@@ -979,9 +1084,9 @@ struct dvb_frontend *si2165_attach(const struct si2165_config *config,
979 } 1084 }
980 1085
981 /* create dvb_frontend */ 1086 /* create dvb_frontend */
982 memcpy(&state->frontend.ops, &si2165_ops, 1087 memcpy(&state->fe.ops, &si2165_ops,
983 sizeof(struct dvb_frontend_ops)); 1088 sizeof(struct dvb_frontend_ops));
984 state->frontend.demodulator_priv = state; 1089 state->fe.demodulator_priv = state;
985 1090
986 /* powerup */ 1091 /* powerup */
987 io_ret = si2165_writereg8(state, 0x0000, state->config.chip_mode); 1092 io_ret = si2165_writereg8(state, 0x0000, state->config.chip_mode);
@@ -1033,20 +1138,22 @@ struct dvb_frontend *si2165_attach(const struct si2165_config *config,
1033 KBUILD_MODNAME, chip_name, rev_char, state->chip_type, 1138 KBUILD_MODNAME, chip_name, rev_char, state->chip_type,
1034 state->chip_revcode); 1139 state->chip_revcode);
1035 1140
1036 strlcat(state->frontend.ops.info.name, chip_name, 1141 strlcat(state->fe.ops.info.name, chip_name,
1037 sizeof(state->frontend.ops.info.name)); 1142 sizeof(state->fe.ops.info.name));
1038 1143
1039 n = 0; 1144 n = 0;
1040 if (state->has_dvbt) { 1145 if (state->has_dvbt) {
1041 state->frontend.ops.delsys[n++] = SYS_DVBT; 1146 state->fe.ops.delsys[n++] = SYS_DVBT;
1042 strlcat(state->frontend.ops.info.name, " DVB-T", 1147 strlcat(state->fe.ops.info.name, " DVB-T",
1043 sizeof(state->frontend.ops.info.name)); 1148 sizeof(state->fe.ops.info.name));
1149 }
1150 if (state->has_dvbc) {
1151 state->fe.ops.delsys[n++] = SYS_DVBC_ANNEX_A;
1152 strlcat(state->fe.ops.info.name, " DVB-C",
1153 sizeof(state->fe.ops.info.name));
1044 } 1154 }
1045 if (state->has_dvbc)
1046 dev_warn(&state->i2c->dev, "%s: DVB-C is not yet supported.\n",
1047 KBUILD_MODNAME);
1048 1155
1049 return &state->frontend; 1156 return &state->fe;
1050 1157
1051error: 1158error:
1052 kfree(state); 1159 kfree(state);
diff --git a/drivers/media/dvb-frontends/stb6100.c b/drivers/media/dvb-frontends/stb6100.c
index 4ef8a5c7003e..c978c801c7aa 100644
--- a/drivers/media/dvb-frontends/stb6100.c
+++ b/drivers/media/dvb-frontends/stb6100.c
@@ -252,6 +252,7 @@ static int stb6100_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
252{ 252{
253 int rc; 253 int rc;
254 u8 f; 254 u8 f;
255 u32 bw;
255 struct stb6100_state *state = fe->tuner_priv; 256 struct stb6100_state *state = fe->tuner_priv;
256 257
257 rc = stb6100_read_reg(state, STB6100_F); 258 rc = stb6100_read_reg(state, STB6100_F);
@@ -259,9 +260,9 @@ static int stb6100_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
259 return rc; 260 return rc;
260 f = rc & STB6100_F_F; 261 f = rc & STB6100_F_F;
261 262
262 state->status.bandwidth = (f + 5) * 2000; /* x2 for ZIF */ 263 bw = (f + 5) * 2000; /* x2 for ZIF */
263 264
264 *bandwidth = state->bandwidth = state->status.bandwidth * 1000; 265 *bandwidth = state->bandwidth = bw * 1000;
265 dprintk(verbose, FE_DEBUG, 1, "bandwidth = %u Hz", state->bandwidth); 266 dprintk(verbose, FE_DEBUG, 1, "bandwidth = %u Hz", state->bandwidth);
266 return 0; 267 return 0;
267} 268}
@@ -495,68 +496,28 @@ static int stb6100_sleep(struct dvb_frontend *fe)
495static int stb6100_init(struct dvb_frontend *fe) 496static int stb6100_init(struct dvb_frontend *fe)
496{ 497{
497 struct stb6100_state *state = fe->tuner_priv; 498 struct stb6100_state *state = fe->tuner_priv;
498 struct tuner_state *status = &state->status; 499 int refclk = 27000000; /* Hz */
499 500
500 status->tunerstep = 125000; 501 /*
501 status->ifreq = 0; 502 * iqsense = 1
502 status->refclock = 27000000; /* Hz */ 503 * tunerstep = 125000
503 status->iqsense = 1; 504 */
504 status->bandwidth = 36000; /* kHz */ 505 state->bandwidth = 36000000; /* Hz */
505 state->bandwidth = status->bandwidth * 1000; /* Hz */ 506 state->reference = refclk / 1000; /* kHz */
506 state->reference = status->refclock / 1000; /* kHz */
507 507
508 /* Set default bandwidth. Modified, PN 13-May-10 */ 508 /* Set default bandwidth. Modified, PN 13-May-10 */
509 return 0; 509 return 0;
510} 510}
511 511
512static int stb6100_get_state(struct dvb_frontend *fe, 512static int stb6100_set_params(struct dvb_frontend *fe)
513 enum tuner_param param,
514 struct tuner_state *state)
515{ 513{
516 switch (param) { 514 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
517 case DVBFE_TUNER_FREQUENCY:
518 stb6100_get_frequency(fe, &state->frequency);
519 break;
520 case DVBFE_TUNER_TUNERSTEP:
521 break;
522 case DVBFE_TUNER_IFFREQ:
523 break;
524 case DVBFE_TUNER_BANDWIDTH:
525 stb6100_get_bandwidth(fe, &state->bandwidth);
526 break;
527 case DVBFE_TUNER_REFCLOCK:
528 break;
529 default:
530 break;
531 }
532 515
533 return 0; 516 if (c->frequency > 0)
534} 517 stb6100_set_frequency(fe, c->frequency);
535 518
536static int stb6100_set_state(struct dvb_frontend *fe, 519 if (c->bandwidth_hz > 0)
537 enum tuner_param param, 520 stb6100_set_bandwidth(fe, c->bandwidth_hz);
538 struct tuner_state *state)
539{
540 struct stb6100_state *tstate = fe->tuner_priv;
541
542 switch (param) {
543 case DVBFE_TUNER_FREQUENCY:
544 stb6100_set_frequency(fe, state->frequency);
545 tstate->frequency = state->frequency;
546 break;
547 case DVBFE_TUNER_TUNERSTEP:
548 break;
549 case DVBFE_TUNER_IFFREQ:
550 break;
551 case DVBFE_TUNER_BANDWIDTH:
552 stb6100_set_bandwidth(fe, state->bandwidth);
553 tstate->bandwidth = state->bandwidth;
554 break;
555 case DVBFE_TUNER_REFCLOCK:
556 break;
557 default:
558 break;
559 }
560 521
561 return 0; 522 return 0;
562} 523}
@@ -572,8 +533,9 @@ static struct dvb_tuner_ops stb6100_ops = {
572 .init = stb6100_init, 533 .init = stb6100_init,
573 .sleep = stb6100_sleep, 534 .sleep = stb6100_sleep,
574 .get_status = stb6100_get_status, 535 .get_status = stb6100_get_status,
575 .get_state = stb6100_get_state, 536 .set_params = stb6100_set_params,
576 .set_state = stb6100_set_state, 537 .get_frequency = stb6100_get_frequency,
538 .get_bandwidth = stb6100_get_bandwidth,
577 .release = stb6100_release 539 .release = stb6100_release
578}; 540};
579 541
diff --git a/drivers/media/dvb-frontends/stb6100.h b/drivers/media/dvb-frontends/stb6100.h
index 218c8188865d..f7b468b6dc26 100644
--- a/drivers/media/dvb-frontends/stb6100.h
+++ b/drivers/media/dvb-frontends/stb6100.h
@@ -86,7 +86,6 @@ struct stb6100_state {
86 const struct stb6100_config *config; 86 const struct stb6100_config *config;
87 struct dvb_tuner_ops ops; 87 struct dvb_tuner_ops ops;
88 struct dvb_frontend *frontend; 88 struct dvb_frontend *frontend;
89 struct tuner_state status;
90 89
91 u32 frequency; 90 u32 frequency;
92 u32 srate; 91 u32 srate;
diff --git a/drivers/media/dvb-frontends/stb6100_cfg.h b/drivers/media/dvb-frontends/stb6100_cfg.h
index 6edc15365847..2ef67aa768b9 100644
--- a/drivers/media/dvb-frontends/stb6100_cfg.h
+++ b/drivers/media/dvb-frontends/stb6100_cfg.h
@@ -19,20 +19,21 @@
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/ 20*/
21 21
22#include <linux/dvb/frontend.h>
23#include "dvb_frontend.h"
24
22static int stb6100_get_frequency(struct dvb_frontend *fe, u32 *frequency) 25static int stb6100_get_frequency(struct dvb_frontend *fe, u32 *frequency)
23{ 26{
24 struct dvb_frontend_ops *frontend_ops = &fe->ops; 27 struct dvb_frontend_ops *frontend_ops = &fe->ops;
25 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; 28 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
26 struct tuner_state t_state;
27 int err = 0; 29 int err = 0;
28 30
29 if (tuner_ops->get_state) { 31 if (tuner_ops->get_frequency) {
30 err = tuner_ops->get_state(fe, DVBFE_TUNER_FREQUENCY, &t_state); 32 err = tuner_ops->get_frequency(fe, frequency);
31 if (err < 0) { 33 if (err < 0) {
32 printk("%s: Invalid parameter\n", __func__); 34 printk("%s: Invalid parameter\n", __func__);
33 return err; 35 return err;
34 } 36 }
35 *frequency = t_state.frequency;
36 } 37 }
37 return 0; 38 return 0;
38} 39}
@@ -41,13 +42,16 @@ static int stb6100_set_frequency(struct dvb_frontend *fe, u32 frequency)
41{ 42{
42 struct dvb_frontend_ops *frontend_ops = &fe->ops; 43 struct dvb_frontend_ops *frontend_ops = &fe->ops;
43 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; 44 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
44 struct tuner_state t_state; 45 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
46 u32 bw = c->bandwidth_hz;
45 int err = 0; 47 int err = 0;
46 48
47 t_state.frequency = frequency; 49 c->frequency = frequency;
50 c->bandwidth_hz = 0; /* Don't adjust the bandwidth */
48 51
49 if (tuner_ops->set_state) { 52 if (tuner_ops->set_params) {
50 err = tuner_ops->set_state(fe, DVBFE_TUNER_FREQUENCY, &t_state); 53 err = tuner_ops->set_params(fe);
54 c->bandwidth_hz = bw;
51 if (err < 0) { 55 if (err < 0) {
52 printk("%s: Invalid parameter\n", __func__); 56 printk("%s: Invalid parameter\n", __func__);
53 return err; 57 return err;
@@ -60,16 +64,14 @@ static int stb6100_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
60{ 64{
61 struct dvb_frontend_ops *frontend_ops = &fe->ops; 65 struct dvb_frontend_ops *frontend_ops = &fe->ops;
62 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; 66 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
63 struct tuner_state t_state;
64 int err = 0; 67 int err = 0;
65 68
66 if (tuner_ops->get_state) { 69 if (tuner_ops->get_bandwidth) {
67 err = tuner_ops->get_state(fe, DVBFE_TUNER_BANDWIDTH, &t_state); 70 err = tuner_ops->get_bandwidth(fe, bandwidth);
68 if (err < 0) { 71 if (err < 0) {
69 printk("%s: Invalid parameter\n", __func__); 72 printk("%s: Invalid parameter\n", __func__);
70 return err; 73 return err;
71 } 74 }
72 *bandwidth = t_state.bandwidth;
73 } 75 }
74 return 0; 76 return 0;
75} 77}
@@ -78,13 +80,16 @@ static int stb6100_set_bandwidth(struct dvb_frontend *fe, u32 bandwidth)
78{ 80{
79 struct dvb_frontend_ops *frontend_ops = &fe->ops; 81 struct dvb_frontend_ops *frontend_ops = &fe->ops;
80 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; 82 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
81 struct tuner_state t_state; 83 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
84 u32 freq = c->frequency;
82 int err = 0; 85 int err = 0;
83 86
84 t_state.bandwidth = bandwidth; 87 c->bandwidth_hz = bandwidth;
88 c->frequency = 0; /* Don't adjust the frequency */
85 89
86 if (tuner_ops->set_state) { 90 if (tuner_ops->set_params) {
87 err = tuner_ops->set_state(fe, DVBFE_TUNER_BANDWIDTH, &t_state); 91 err = tuner_ops->set_params(fe);
92 c->frequency = freq;
88 if (err < 0) { 93 if (err < 0) {
89 printk("%s: Invalid parameter\n", __func__); 94 printk("%s: Invalid parameter\n", __func__);
90 return err; 95 return err;
diff --git a/drivers/media/dvb-frontends/stb6100_proc.h b/drivers/media/dvb-frontends/stb6100_proc.h
index bd8a0ec9e2cc..50ffa21e3871 100644
--- a/drivers/media/dvb-frontends/stb6100_proc.h
+++ b/drivers/media/dvb-frontends/stb6100_proc.h
@@ -17,27 +17,27 @@
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18*/ 18*/
19 19
20#include <linux/dvb/frontend.h>
21#include "dvb_frontend.h"
22
20static int stb6100_get_freq(struct dvb_frontend *fe, u32 *frequency) 23static int stb6100_get_freq(struct dvb_frontend *fe, u32 *frequency)
21{ 24{
22 struct dvb_frontend_ops *frontend_ops = &fe->ops; 25 struct dvb_frontend_ops *frontend_ops = &fe->ops;
23 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; 26 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
24 struct tuner_state state;
25 int err = 0; 27 int err = 0;
26 28
27 if (tuner_ops->get_state) { 29 if (tuner_ops->get_frequency) {
28 if (frontend_ops->i2c_gate_ctrl) 30 if (frontend_ops->i2c_gate_ctrl)
29 frontend_ops->i2c_gate_ctrl(fe, 1); 31 frontend_ops->i2c_gate_ctrl(fe, 1);
30 32
31 err = tuner_ops->get_state(fe, DVBFE_TUNER_FREQUENCY, &state); 33 err = tuner_ops->get_frequency(fe, frequency);
32 if (err < 0) { 34 if (err < 0) {
33 printk(KERN_ERR "%s: Invalid parameter\n", __func__); 35 printk("%s: Invalid parameter\n", __func__);
34 return err; 36 return err;
35 } 37 }
36 38
37 if (frontend_ops->i2c_gate_ctrl) 39 if (frontend_ops->i2c_gate_ctrl)
38 frontend_ops->i2c_gate_ctrl(fe, 0); 40 frontend_ops->i2c_gate_ctrl(fe, 0);
39
40 *frequency = state.frequency;
41 } 41 }
42 42
43 return 0; 43 return 0;
@@ -47,18 +47,21 @@ static int stb6100_set_freq(struct dvb_frontend *fe, u32 frequency)
47{ 47{
48 struct dvb_frontend_ops *frontend_ops = &fe->ops; 48 struct dvb_frontend_ops *frontend_ops = &fe->ops;
49 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; 49 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
50 struct tuner_state state; 50 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
51 u32 bw = c->bandwidth_hz;
51 int err = 0; 52 int err = 0;
52 53
53 state.frequency = frequency; 54 c->frequency = frequency;
55 c->bandwidth_hz = 0; /* Don't adjust the bandwidth */
54 56
55 if (tuner_ops->set_state) { 57 if (tuner_ops->set_params) {
56 if (frontend_ops->i2c_gate_ctrl) 58 if (frontend_ops->i2c_gate_ctrl)
57 frontend_ops->i2c_gate_ctrl(fe, 1); 59 frontend_ops->i2c_gate_ctrl(fe, 1);
58 60
59 err = tuner_ops->set_state(fe, DVBFE_TUNER_FREQUENCY, &state); 61 err = tuner_ops->set_params(fe);
62 c->bandwidth_hz = bw;
60 if (err < 0) { 63 if (err < 0) {
61 printk(KERN_ERR "%s: Invalid parameter\n", __func__); 64 printk("%s: Invalid parameter\n", __func__);
62 return err; 65 return err;
63 } 66 }
64 67
@@ -74,14 +77,13 @@ static int stb6100_get_bandw(struct dvb_frontend *fe, u32 *bandwidth)
74{ 77{
75 struct dvb_frontend_ops *frontend_ops = &fe->ops; 78 struct dvb_frontend_ops *frontend_ops = &fe->ops;
76 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; 79 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
77 struct tuner_state state;
78 int err = 0; 80 int err = 0;
79 81
80 if (tuner_ops->get_state) { 82 if (tuner_ops->get_bandwidth) {
81 if (frontend_ops->i2c_gate_ctrl) 83 if (frontend_ops->i2c_gate_ctrl)
82 frontend_ops->i2c_gate_ctrl(fe, 1); 84 frontend_ops->i2c_gate_ctrl(fe, 1);
83 85
84 err = tuner_ops->get_state(fe, DVBFE_TUNER_BANDWIDTH, &state); 86 err = tuner_ops->get_bandwidth(fe, bandwidth);
85 if (err < 0) { 87 if (err < 0) {
86 printk(KERN_ERR "%s: Invalid parameter\n", __func__); 88 printk(KERN_ERR "%s: Invalid parameter\n", __func__);
87 return err; 89 return err;
@@ -89,8 +91,6 @@ static int stb6100_get_bandw(struct dvb_frontend *fe, u32 *bandwidth)
89 91
90 if (frontend_ops->i2c_gate_ctrl) 92 if (frontend_ops->i2c_gate_ctrl)
91 frontend_ops->i2c_gate_ctrl(fe, 0); 93 frontend_ops->i2c_gate_ctrl(fe, 0);
92
93 *bandwidth = state.bandwidth;
94 } 94 }
95 95
96 return 0; 96 return 0;
@@ -100,16 +100,19 @@ static int stb6100_set_bandw(struct dvb_frontend *fe, u32 bandwidth)
100{ 100{
101 struct dvb_frontend_ops *frontend_ops = &fe->ops; 101 struct dvb_frontend_ops *frontend_ops = &fe->ops;
102 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; 102 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
103 struct tuner_state state; 103 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
104 u32 freq = c->frequency;
104 int err = 0; 105 int err = 0;
105 106
106 state.bandwidth = bandwidth; 107 c->bandwidth_hz = bandwidth;
108 c->frequency = 0; /* Don't adjust the frequency */
107 109
108 if (tuner_ops->set_state) { 110 if (tuner_ops->set_params) {
109 if (frontend_ops->i2c_gate_ctrl) 111 if (frontend_ops->i2c_gate_ctrl)
110 frontend_ops->i2c_gate_ctrl(fe, 1); 112 frontend_ops->i2c_gate_ctrl(fe, 1);
111 113
112 err = tuner_ops->set_state(fe, DVBFE_TUNER_BANDWIDTH, &state); 114 err = tuner_ops->set_params(fe);
115 c->frequency = freq;
113 if (err < 0) { 116 if (err < 0) {
114 printk(KERN_ERR "%s: Invalid parameter\n", __func__); 117 printk(KERN_ERR "%s: Invalid parameter\n", __func__);
115 return err; 118 return err;
diff --git a/drivers/media/dvb-frontends/tda665x.c b/drivers/media/dvb-frontends/tda665x.c
index 63cc12378d9a..82f8cc534f33 100644
--- a/drivers/media/dvb-frontends/tda665x.c
+++ b/drivers/media/dvb-frontends/tda665x.c
@@ -66,26 +66,13 @@ exit:
66 return err; 66 return err;
67} 67}
68 68
69static int tda665x_get_state(struct dvb_frontend *fe, 69static int tda665x_get_frequency(struct dvb_frontend *fe, u32 *frequency)
70 enum tuner_param param,
71 struct tuner_state *tstate)
72{ 70{
73 struct tda665x_state *state = fe->tuner_priv; 71 struct tda665x_state *state = fe->tuner_priv;
74 int err = 0;
75 72
76 switch (param) { 73 *frequency = state->frequency;
77 case DVBFE_TUNER_FREQUENCY:
78 tstate->frequency = state->frequency;
79 break;
80 case DVBFE_TUNER_BANDWIDTH:
81 break;
82 default:
83 printk(KERN_ERR "%s: Unknown parameter (param=%d)\n", __func__, param);
84 err = -EINVAL;
85 break;
86 }
87 74
88 return err; 75 return 0;
89} 76}
90 77
91static int tda665x_get_status(struct dvb_frontend *fe, u32 *status) 78static int tda665x_get_status(struct dvb_frontend *fe, u32 *status)
@@ -111,9 +98,8 @@ exit:
111 return err; 98 return err;
112} 99}
113 100
114static int tda665x_set_state(struct dvb_frontend *fe, 101static int tda665x_set_frequency(struct dvb_frontend *fe,
115 enum tuner_param param, 102 u32 new_frequency)
116 struct tuner_state *tstate)
117{ 103{
118 struct tda665x_state *state = fe->tuner_priv; 104 struct tda665x_state *state = fe->tuner_priv;
119 const struct tda665x_config *config = state->config; 105 const struct tda665x_config *config = state->config;
@@ -121,88 +107,96 @@ static int tda665x_set_state(struct dvb_frontend *fe,
121 u8 buf[4]; 107 u8 buf[4];
122 int err = 0; 108 int err = 0;
123 109
124 if (param & DVBFE_TUNER_FREQUENCY) { 110 if ((new_frequency < config->frequency_max)
125 111 || (new_frequency > config->frequency_min)) {
126 frequency = tstate->frequency; 112 printk(KERN_ERR "%s: Frequency beyond limits, frequency=%d\n",
127 if ((frequency < config->frequency_max) || (frequency > config->frequency_min)) { 113 __func__, new_frequency);
128 printk(KERN_ERR "%s: Frequency beyond limits, frequency=%d\n", __func__, frequency);
129 return -EINVAL;
130 }
131
132 frequency += config->frequency_offst;
133 frequency *= config->ref_multiplier;
134 frequency += config->ref_divider >> 1;
135 frequency /= config->ref_divider;
136
137 buf[0] = (u8) ((frequency & 0x7f00) >> 8);
138 buf[1] = (u8) (frequency & 0x00ff) >> 0;
139 buf[2] = 0x80 | 0x40 | 0x02;
140 buf[3] = 0x00;
141
142 /* restore frequency */
143 frequency = tstate->frequency;
144
145 if (frequency < 153000000) {
146 /* VHF-L */
147 buf[3] |= 0x01; /* fc, Low Band, 47 - 153 MHz */
148 if (frequency < 68000000)
149 buf[3] |= 0x40; /* 83uA */
150 if (frequency < 1040000000)
151 buf[3] |= 0x60; /* 122uA */
152 if (frequency < 1250000000)
153 buf[3] |= 0x80; /* 163uA */
154 else
155 buf[3] |= 0xa0; /* 254uA */
156 } else if (frequency < 438000000) {
157 /* VHF-H */
158 buf[3] |= 0x02; /* fc, Mid Band, 153 - 438 MHz */
159 if (frequency < 230000000)
160 buf[3] |= 0x40;
161 if (frequency < 300000000)
162 buf[3] |= 0x60;
163 else
164 buf[3] |= 0x80;
165 } else {
166 /* UHF */
167 buf[3] |= 0x04; /* fc, High Band, 438 - 862 MHz */
168 if (frequency < 470000000)
169 buf[3] |= 0x60;
170 if (frequency < 526000000)
171 buf[3] |= 0x80;
172 else
173 buf[3] |= 0xa0;
174 }
175
176 /* Set params */
177 err = tda665x_write(state, buf, 5);
178 if (err < 0)
179 goto exit;
180
181 /* sleep for some time */
182 printk(KERN_DEBUG "%s: Waiting to Phase LOCK\n", __func__);
183 msleep(20);
184 /* check status */
185 err = tda665x_get_status(fe, &status);
186 if (err < 0)
187 goto exit;
188
189 if (status == 1) {
190 printk(KERN_DEBUG "%s: Tuner Phase locked: status=%d\n", __func__, status);
191 state->frequency = frequency; /* cache successful state */
192 } else {
193 printk(KERN_ERR "%s: No Phase lock: status=%d\n", __func__, status);
194 }
195 } else {
196 printk(KERN_ERR "%s: Unknown parameter (param=%d)\n", __func__, param);
197 return -EINVAL; 114 return -EINVAL;
198 } 115 }
199 116
117 frequency = new_frequency;
118
119 frequency += config->frequency_offst;
120 frequency *= config->ref_multiplier;
121 frequency += config->ref_divider >> 1;
122 frequency /= config->ref_divider;
123
124 buf[0] = (u8) ((frequency & 0x7f00) >> 8);
125 buf[1] = (u8) (frequency & 0x00ff) >> 0;
126 buf[2] = 0x80 | 0x40 | 0x02;
127 buf[3] = 0x00;
128
129 /* restore frequency */
130 frequency = new_frequency;
131
132 if (frequency < 153000000) {
133 /* VHF-L */
134 buf[3] |= 0x01; /* fc, Low Band, 47 - 153 MHz */
135 if (frequency < 68000000)
136 buf[3] |= 0x40; /* 83uA */
137 if (frequency < 1040000000)
138 buf[3] |= 0x60; /* 122uA */
139 if (frequency < 1250000000)
140 buf[3] |= 0x80; /* 163uA */
141 else
142 buf[3] |= 0xa0; /* 254uA */
143 } else if (frequency < 438000000) {
144 /* VHF-H */
145 buf[3] |= 0x02; /* fc, Mid Band, 153 - 438 MHz */
146 if (frequency < 230000000)
147 buf[3] |= 0x40;
148 if (frequency < 300000000)
149 buf[3] |= 0x60;
150 else
151 buf[3] |= 0x80;
152 } else {
153 /* UHF */
154 buf[3] |= 0x04; /* fc, High Band, 438 - 862 MHz */
155 if (frequency < 470000000)
156 buf[3] |= 0x60;
157 if (frequency < 526000000)
158 buf[3] |= 0x80;
159 else
160 buf[3] |= 0xa0;
161 }
162
163 /* Set params */
164 err = tda665x_write(state, buf, 5);
165 if (err < 0)
166 goto exit;
167
168 /* sleep for some time */
169 printk(KERN_DEBUG "%s: Waiting to Phase LOCK\n", __func__);
170 msleep(20);
171 /* check status */
172 err = tda665x_get_status(fe, &status);
173 if (err < 0)
174 goto exit;
175
176 if (status == 1) {
177 printk(KERN_DEBUG "%s: Tuner Phase locked: status=%d\n",
178 __func__, status);
179 state->frequency = frequency; /* cache successful state */
180 } else {
181 printk(KERN_ERR "%s: No Phase lock: status=%d\n",
182 __func__, status);
183 }
184
200 return 0; 185 return 0;
201exit: 186exit:
202 printk(KERN_ERR "%s: I/O Error\n", __func__); 187 printk(KERN_ERR "%s: I/O Error\n", __func__);
203 return err; 188 return err;
204} 189}
205 190
191static int tda665x_set_params(struct dvb_frontend *fe)
192{
193 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
194
195 tda665x_set_frequency(fe, c->frequency);
196
197 return 0;
198}
199
206static int tda665x_release(struct dvb_frontend *fe) 200static int tda665x_release(struct dvb_frontend *fe)
207{ 201{
208 struct tda665x_state *state = fe->tuner_priv; 202 struct tda665x_state *state = fe->tuner_priv;
@@ -213,10 +207,9 @@ static int tda665x_release(struct dvb_frontend *fe)
213} 207}
214 208
215static struct dvb_tuner_ops tda665x_ops = { 209static struct dvb_tuner_ops tda665x_ops = {
216
217 .set_state = tda665x_set_state,
218 .get_state = tda665x_get_state,
219 .get_status = tda665x_get_status, 210 .get_status = tda665x_get_status,
211 .set_params = tda665x_set_params,
212 .get_frequency = tda665x_get_frequency,
220 .release = tda665x_release 213 .release = tda665x_release
221}; 214};
222 215
diff --git a/drivers/media/dvb-frontends/tda8261.c b/drivers/media/dvb-frontends/tda8261.c
index 19c488814e5c..3285b1bc4642 100644
--- a/drivers/media/dvb-frontends/tda8261.c
+++ b/drivers/media/dvb-frontends/tda8261.c
@@ -83,88 +83,71 @@ static int tda8261_get_status(struct dvb_frontend *fe, u32 *status)
83static const u32 div_tab[] = { 2000, 1000, 500, 250, 125 }; /* kHz */ 83static const u32 div_tab[] = { 2000, 1000, 500, 250, 125 }; /* kHz */
84static const u8 ref_div[] = { 0x00, 0x01, 0x02, 0x05, 0x07 }; 84static const u8 ref_div[] = { 0x00, 0x01, 0x02, 0x05, 0x07 };
85 85
86static int tda8261_get_state(struct dvb_frontend *fe, 86static int tda8261_get_frequency(struct dvb_frontend *fe, u32 *frequency)
87 enum tuner_param param,
88 struct tuner_state *tstate)
89{ 87{
90 struct tda8261_state *state = fe->tuner_priv; 88 struct tda8261_state *state = fe->tuner_priv;
91 int err = 0;
92 89
93 switch (param) { 90 *frequency = state->frequency;
94 case DVBFE_TUNER_FREQUENCY:
95 tstate->frequency = state->frequency;
96 break;
97 case DVBFE_TUNER_BANDWIDTH:
98 tstate->bandwidth = 40000000; /* FIXME! need to calculate Bandwidth */
99 break;
100 default:
101 pr_err("%s: Unknown parameter (param=%d)\n", __func__, param);
102 err = -EINVAL;
103 break;
104 }
105 91
106 return err; 92 return 0;
107} 93}
108 94
109static int tda8261_set_state(struct dvb_frontend *fe, 95static int tda8261_set_params(struct dvb_frontend *fe)
110 enum tuner_param param,
111 struct tuner_state *tstate)
112{ 96{
97 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
113 struct tda8261_state *state = fe->tuner_priv; 98 struct tda8261_state *state = fe->tuner_priv;
114 const struct tda8261_config *config = state->config; 99 const struct tda8261_config *config = state->config;
115 u32 frequency, N, status = 0; 100 u32 frequency, N, status = 0;
116 u8 buf[4]; 101 u8 buf[4];
117 int err = 0; 102 int err = 0;
118 103
119 if (param & DVBFE_TUNER_FREQUENCY) { 104 /*
120 /** 105 * N = Max VCO Frequency / Channel Spacing
121 * N = Max VCO Frequency / Channel Spacing 106 * Max VCO Frequency = VCO frequency + (channel spacing - 1)
122 * Max VCO Frequency = VCO frequency + (channel spacing - 1) 107 * (to account for half channel spacing on either side)
123 * (to account for half channel spacing on either side) 108 */
124 */ 109 frequency = c->frequency;
125 frequency = tstate->frequency; 110 if ((frequency < 950000) || (frequency > 2150000)) {
126 if ((frequency < 950000) || (frequency > 2150000)) { 111 pr_warn("%s: Frequency beyond limits, frequency=%d\n",
127 pr_warn("%s: Frequency beyond limits, frequency=%d\n", __func__, frequency); 112 __func__, frequency);
128 return -EINVAL;
129 }
130 N = (frequency + (div_tab[config->step_size] - 1)) / div_tab[config->step_size];
131 pr_debug("%s: Step size=%d, Divider=%d, PG=0x%02x (%d)\n",
132 __func__, config->step_size, div_tab[config->step_size], N, N);
133
134 buf[0] = (N >> 8) & 0xff;
135 buf[1] = N & 0xff;
136 buf[2] = (0x01 << 7) | ((ref_div[config->step_size] & 0x07) << 1);
137
138 if (frequency < 1450000)
139 buf[3] = 0x00;
140 else if (frequency < 2000000)
141 buf[3] = 0x40;
142 else if (frequency < 2150000)
143 buf[3] = 0x80;
144
145 /* Set params */
146 if ((err = tda8261_write(state, buf)) < 0) {
147 pr_err("%s: I/O Error\n", __func__);
148 return err;
149 }
150 /* sleep for some time */
151 pr_debug("%s: Waiting to Phase LOCK\n", __func__);
152 msleep(20);
153 /* check status */
154 if ((err = tda8261_get_status(fe, &status)) < 0) {
155 pr_err("%s: I/O Error\n", __func__);
156 return err;
157 }
158 if (status == 1) {
159 pr_debug("%s: Tuner Phase locked: status=%d\n", __func__, status);
160 state->frequency = frequency; /* cache successful state */
161 } else {
162 pr_debug("%s: No Phase lock: status=%d\n", __func__, status);
163 }
164 } else {
165 pr_err("%s: Unknown parameter (param=%d)\n", __func__, param);
166 return -EINVAL; 113 return -EINVAL;
167 } 114 }
115 N = (frequency + (div_tab[config->step_size] - 1)) / div_tab[config->step_size];
116 pr_debug("%s: Step size=%d, Divider=%d, PG=0x%02x (%d)\n",
117 __func__, config->step_size, div_tab[config->step_size], N, N);
118
119 buf[0] = (N >> 8) & 0xff;
120 buf[1] = N & 0xff;
121 buf[2] = (0x01 << 7) | ((ref_div[config->step_size] & 0x07) << 1);
122
123 if (frequency < 1450000)
124 buf[3] = 0x00;
125 else if (frequency < 2000000)
126 buf[3] = 0x40;
127 else if (frequency < 2150000)
128 buf[3] = 0x80;
129
130 /* Set params */
131 err = tda8261_write(state, buf);
132 if (err < 0) {
133 pr_err("%s: I/O Error\n", __func__);
134 return err;
135 }
136 /* sleep for some time */
137 pr_debug("%s: Waiting to Phase LOCK\n", __func__);
138 msleep(20);
139 /* check status */
140 if ((err = tda8261_get_status(fe, &status)) < 0) {
141 pr_err("%s: I/O Error\n", __func__);
142 return err;
143 }
144 if (status == 1) {
145 pr_debug("%s: Tuner Phase locked: status=%d\n", __func__,
146 status);
147 state->frequency = frequency; /* cache successful state */
148 } else {
149 pr_debug("%s: No Phase lock: status=%d\n", __func__, status);
150 }
168 151
169 return 0; 152 return 0;
170} 153}
@@ -182,14 +165,13 @@ static struct dvb_tuner_ops tda8261_ops = {
182 165
183 .info = { 166 .info = {
184 .name = "TDA8261", 167 .name = "TDA8261",
185// .tuner_name = NULL,
186 .frequency_min = 950000, 168 .frequency_min = 950000,
187 .frequency_max = 2150000, 169 .frequency_max = 2150000,
188 .frequency_step = 0 170 .frequency_step = 0
189 }, 171 },
190 172
191 .set_state = tda8261_set_state, 173 .set_params = tda8261_set_params,
192 .get_state = tda8261_get_state, 174 .get_frequency = tda8261_get_frequency,
193 .get_status = tda8261_get_status, 175 .get_status = tda8261_get_status,
194 .release = tda8261_release 176 .release = tda8261_release
195}; 177};
@@ -210,10 +192,7 @@ struct dvb_frontend *tda8261_attach(struct dvb_frontend *fe,
210 fe->ops.tuner_ops = tda8261_ops; 192 fe->ops.tuner_ops = tda8261_ops;
211 193
212 fe->ops.tuner_ops.info.frequency_step = div_tab[config->step_size]; 194 fe->ops.tuner_ops.info.frequency_step = div_tab[config->step_size];
213// fe->ops.tuner_ops.tuner_name = &config->buf;
214 195
215// printk("%s: Attaching %s TDA8261 8PSK/QPSK tuner\n",
216// __func__, fe->ops.tuner_ops.tuner_name);
217 pr_info("%s: Attaching TDA8261 8PSK/QPSK tuner\n", __func__); 196 pr_info("%s: Attaching TDA8261 8PSK/QPSK tuner\n", __func__);
218 197
219 return fe; 198 return fe;
diff --git a/drivers/media/dvb-frontends/tda8261_cfg.h b/drivers/media/dvb-frontends/tda8261_cfg.h
index 04a19e14ee5a..fe527ff84df4 100644
--- a/drivers/media/dvb-frontends/tda8261_cfg.h
+++ b/drivers/media/dvb-frontends/tda8261_cfg.h
@@ -21,17 +21,15 @@ static int tda8261_get_frequency(struct dvb_frontend *fe, u32 *frequency)
21{ 21{
22 struct dvb_frontend_ops *frontend_ops = &fe->ops; 22 struct dvb_frontend_ops *frontend_ops = &fe->ops;
23 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; 23 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
24 struct tuner_state t_state;
25 int err = 0; 24 int err = 0;
26 25
27 if (tuner_ops->get_state) { 26 if (tuner_ops->get_frequency) {
28 err = tuner_ops->get_state(fe, DVBFE_TUNER_FREQUENCY, &t_state); 27 err = tuner_ops->get_frequency(fe, frequency);
29 if (err < 0) { 28 if (err < 0) {
30 printk("%s: Invalid parameter\n", __func__); 29 pr_err("%s: Invalid parameter\n", __func__);
31 return err; 30 return err;
32 } 31 }
33 *frequency = t_state.frequency; 32 pr_debug("%s: Frequency=%d\n", __func__, *frequency);
34 printk("%s: Frequency=%d\n", __func__, t_state.frequency);
35 } 33 }
36 return 0; 34 return 0;
37} 35}
@@ -40,37 +38,24 @@ static int tda8261_set_frequency(struct dvb_frontend *fe, u32 frequency)
40{ 38{
41 struct dvb_frontend_ops *frontend_ops = &fe->ops; 39 struct dvb_frontend_ops *frontend_ops = &fe->ops;
42 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; 40 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
43 struct tuner_state t_state; 41 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
44 int err = 0; 42 int err = 0;
45 43
46 t_state.frequency = frequency; 44 if (tuner_ops->set_params) {
47 45 err = tuner_ops->set_params(fe);
48 if (tuner_ops->set_state) {
49 err = tuner_ops->set_state(fe, DVBFE_TUNER_FREQUENCY, &t_state);
50 if (err < 0) { 46 if (err < 0) {
51 printk("%s: Invalid parameter\n", __func__); 47 pr_err("%s: Invalid parameter\n", __func__);
52 return err; 48 return err;
53 } 49 }
54 } 50 }
55 printk("%s: Frequency=%d\n", __func__, t_state.frequency); 51 pr_debug("%s: Frequency=%d\n", __func__, c->frequency);
56 return 0; 52 return 0;
57} 53}
58 54
59static int tda8261_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) 55static int tda8261_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
60{ 56{
61 struct dvb_frontend_ops *frontend_ops = &fe->ops; 57 /* FIXME! need to calculate Bandwidth */
62 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; 58 *bandwidth = 40000000;
63 struct tuner_state t_state;
64 int err = 0;
65 59
66 if (tuner_ops->get_state) {
67 err = tuner_ops->get_state(fe, DVBFE_TUNER_BANDWIDTH, &t_state);
68 if (err < 0) {
69 printk("%s: Invalid parameter\n", __func__);
70 return err;
71 }
72 *bandwidth = t_state.bandwidth;
73 printk("%s: Bandwidth=%d\n", __func__, t_state.bandwidth);
74 }
75 return 0; 60 return 0;
76} 61}
diff --git a/drivers/media/dvb-frontends/tdhd1.h b/drivers/media/dvb-frontends/tdhd1.h
index 17750985db0c..2b9e8732c802 100644
--- a/drivers/media/dvb-frontends/tdhd1.h
+++ b/drivers/media/dvb-frontends/tdhd1.h
@@ -20,7 +20,7 @@
20 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 20 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
21 * 21 *
22 * 22 *
23 * The project's page is at http://www.linuxtv.org 23 * The project's page is at https://linuxtv.org
24 */ 24 */
25 25
26#ifndef TDHD1_H 26#ifndef TDHD1_H
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 521bbf1b29bc..993dc50c12db 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -83,6 +83,16 @@ config VIDEO_MSP3400
83 To compile this driver as a module, choose M here: the 83 To compile this driver as a module, choose M here: the
84 module will be called msp3400. 84 module will be called msp3400.
85 85
86config VIDEO_CS3308
87 tristate "Cirrus Logic CS3308 audio ADC"
88 depends on VIDEO_V4L2 && I2C
89 ---help---
90 Support for the Cirrus Logic CS3308 High Performance 8-Channel
91 Analog Volume Control
92
93 To compile this driver as a module, choose M here: the
94 module will be called cs3308.
95
86config VIDEO_CS5345 96config VIDEO_CS5345
87 tristate "Cirrus Logic CS5345 audio ADC" 97 tristate "Cirrus Logic CS5345 audio ADC"
88 depends on VIDEO_V4L2 && I2C 98 depends on VIDEO_V4L2 && I2C
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 07db257abfc1..94f2c99e890d 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -43,6 +43,7 @@ obj-$(CONFIG_VIDEO_TVP7002) += tvp7002.o
43obj-$(CONFIG_VIDEO_TW2804) += tw2804.o 43obj-$(CONFIG_VIDEO_TW2804) += tw2804.o
44obj-$(CONFIG_VIDEO_TW9903) += tw9903.o 44obj-$(CONFIG_VIDEO_TW9903) += tw9903.o
45obj-$(CONFIG_VIDEO_TW9906) += tw9906.o 45obj-$(CONFIG_VIDEO_TW9906) += tw9906.o
46obj-$(CONFIG_VIDEO_CS3308) += cs3308.o
46obj-$(CONFIG_VIDEO_CS5345) += cs5345.o 47obj-$(CONFIG_VIDEO_CS5345) += cs5345.o
47obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o 48obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o
48obj-$(CONFIG_VIDEO_M52790) += m52790.o 49obj-$(CONFIG_VIDEO_M52790) += m52790.o
diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c
index 69094ab047b1..0494a7896aa2 100644
--- a/drivers/media/i2c/ad9389b.c
+++ b/drivers/media/i2c/ad9389b.c
@@ -35,7 +35,7 @@
35#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
36#include <media/v4l2-dv-timings.h> 36#include <media/v4l2-dv-timings.h>
37#include <media/v4l2-ctrls.h> 37#include <media/v4l2-ctrls.h>
38#include <media/ad9389b.h> 38#include <media/i2c/ad9389b.h>
39 39
40static int debug; 40static int debug;
41module_param(debug, int, 0644); 41module_param(debug, int, 0644);
diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c
index 5dd39775d6ca..f00745bbe471 100644
--- a/drivers/media/i2c/adp1653.c
+++ b/drivers/media/i2c/adp1653.c
@@ -37,7 +37,7 @@
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/of.h> 38#include <linux/of.h>
39#include <linux/gpio/consumer.h> 39#include <linux/gpio/consumer.h>
40#include <media/adp1653.h> 40#include <media/i2c/adp1653.h>
41#include <media/v4l2-device.h> 41#include <media/v4l2-device.h>
42 42
43#define TIMEOUT_MAX 820000 43#define TIMEOUT_MAX 820000
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index f82c8aa164fa..3c3c4bfe3866 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -1112,7 +1112,7 @@ static int init_device(struct adv7180_state *state)
1112 mutex_lock(&state->mutex); 1112 mutex_lock(&state->mutex);
1113 1113
1114 adv7180_write(state, ADV7180_REG_PWR_MAN, ADV7180_PWR_MAN_RES); 1114 adv7180_write(state, ADV7180_REG_PWR_MAN, ADV7180_PWR_MAN_RES);
1115 usleep_range(2000, 10000); 1115 usleep_range(5000, 10000);
1116 1116
1117 ret = state->chip_info->init(state); 1117 ret = state->chip_info->init(state);
1118 if (ret) 1118 if (ret)
diff --git a/drivers/media/i2c/adv7183.c b/drivers/media/i2c/adv7183.c
index e2dd1617662f..2bec737881e9 100644
--- a/drivers/media/i2c/adv7183.c
+++ b/drivers/media/i2c/adv7183.c
@@ -27,7 +27,7 @@
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/videodev2.h> 28#include <linux/videodev2.h>
29 29
30#include <media/adv7183.h> 30#include <media/i2c/adv7183.h>
31#include <media/v4l2-ctrls.h> 31#include <media/v4l2-ctrls.h>
32#include <media/v4l2-device.h> 32#include <media/v4l2-device.h>
33 33
diff --git a/drivers/media/i2c/adv7343.c b/drivers/media/i2c/adv7343.c
index f89d0afcd964..11f9029433cf 100644
--- a/drivers/media/i2c/adv7343.c
+++ b/drivers/media/i2c/adv7343.c
@@ -28,7 +28,7 @@
28#include <linux/of.h> 28#include <linux/of.h>
29#include <linux/of_graph.h> 29#include <linux/of_graph.h>
30 30
31#include <media/adv7343.h> 31#include <media/i2c/adv7343.h>
32#include <media/v4l2-async.h> 32#include <media/v4l2-async.h>
33#include <media/v4l2-device.h> 33#include <media/v4l2-device.h>
34#include <media/v4l2-ctrls.h> 34#include <media/v4l2-ctrls.h>
diff --git a/drivers/media/i2c/adv7393.c b/drivers/media/i2c/adv7393.c
index 0215f95c2245..76d987476e35 100644
--- a/drivers/media/i2c/adv7393.c
+++ b/drivers/media/i2c/adv7393.c
@@ -31,7 +31,7 @@
31#include <linux/videodev2.h> 31#include <linux/videodev2.h>
32#include <linux/uaccess.h> 32#include <linux/uaccess.h>
33 33
34#include <media/adv7393.h> 34#include <media/i2c/adv7393.h>
35#include <media/v4l2-device.h> 35#include <media/v4l2-device.h>
36#include <media/v4l2-ctrls.h> 36#include <media/v4l2-ctrls.h>
37 37
diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index e4900df1140b..eeb2cd823c4d 100644
--- a/drivers/media/i2c/adv7511.c
+++ b/drivers/media/i2c/adv7511.c
@@ -32,7 +32,7 @@
32#include <media/v4l2-common.h> 32#include <media/v4l2-common.h>
33#include <media/v4l2-ctrls.h> 33#include <media/v4l2-ctrls.h>
34#include <media/v4l2-dv-timings.h> 34#include <media/v4l2-dv-timings.h>
35#include <media/adv7511.h> 35#include <media/i2c/adv7511.h>
36 36
37static int debug; 37static int debug;
38module_param(debug, int, 0644); 38module_param(debug, int, 0644);
@@ -1116,7 +1116,7 @@ static int adv7511_set_fmt(struct v4l2_subdev *sd,
1116 adv7511_wr_and_or(sd, 0x55, 0x9f, y << 5); 1116 adv7511_wr_and_or(sd, 0x55, 0x9f, y << 5);
1117 adv7511_wr_and_or(sd, 0x56, 0x3f, c << 6); 1117 adv7511_wr_and_or(sd, 0x56, 0x3f, c << 6);
1118 adv7511_wr_and_or(sd, 0x57, 0x83, (ec << 4) | (q << 2)); 1118 adv7511_wr_and_or(sd, 0x57, 0x83, (ec << 4) | (q << 2));
1119 adv7511_wr_and_or(sd, 0x59, 0x0f, yq << 4); 1119 adv7511_wr_and_or(sd, 0x59, 0x3f, yq << 6);
1120 adv7511_wr_and_or(sd, 0x4a, 0xff, 1); 1120 adv7511_wr_and_or(sd, 0x4a, 0xff, 1);
1121 1121
1122 return 0; 1122 return 0;
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 5631ec004eed..745286225655 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -39,7 +39,7 @@
39#include <linux/workqueue.h> 39#include <linux/workqueue.h>
40#include <linux/regmap.h> 40#include <linux/regmap.h>
41 41
42#include <media/adv7604.h> 42#include <media/i2c/adv7604.h>
43#include <media/v4l2-ctrls.h> 43#include <media/v4l2-ctrls.h>
44#include <media/v4l2-device.h> 44#include <media/v4l2-device.h>
45#include <media/v4l2-event.h> 45#include <media/v4l2-event.h>
@@ -905,7 +905,7 @@ static int find_and_set_predefined_video_timings(struct v4l2_subdev *sd,
905 905
906 for (i = 0; predef_vid_timings[i].timings.bt.width; i++) { 906 for (i = 0; predef_vid_timings[i].timings.bt.width; i++) {
907 if (!v4l2_match_dv_timings(timings, &predef_vid_timings[i].timings, 907 if (!v4l2_match_dv_timings(timings, &predef_vid_timings[i].timings,
908 is_digital_input(sd) ? 250000 : 1000000)) 908 is_digital_input(sd) ? 250000 : 1000000, false))
909 continue; 909 continue;
910 io_write(sd, 0x00, predef_vid_timings[i].vid_std); /* video std */ 910 io_write(sd, 0x00, predef_vid_timings[i].vid_std); /* video std */
911 io_write(sd, 0x01, (predef_vid_timings[i].v_freq << 4) + 911 io_write(sd, 0x01, (predef_vid_timings[i].v_freq << 4) +
@@ -1479,7 +1479,7 @@ static void adv76xx_fill_optional_dv_timings_fields(struct v4l2_subdev *sd,
1479 1479
1480 for (i = 0; adv76xx_timings[i].bt.width; i++) { 1480 for (i = 0; adv76xx_timings[i].bt.width; i++) {
1481 if (v4l2_match_dv_timings(timings, &adv76xx_timings[i], 1481 if (v4l2_match_dv_timings(timings, &adv76xx_timings[i],
1482 is_digital_input(sd) ? 250000 : 1000000)) { 1482 is_digital_input(sd) ? 250000 : 1000000, false)) {
1483 *timings = adv76xx_timings[i]; 1483 *timings = adv76xx_timings[i];
1484 break; 1484 break;
1485 } 1485 }
@@ -1644,7 +1644,7 @@ static int adv76xx_s_dv_timings(struct v4l2_subdev *sd,
1644 if (!timings) 1644 if (!timings)
1645 return -EINVAL; 1645 return -EINVAL;
1646 1646
1647 if (v4l2_match_dv_timings(&state->timings, timings, 0)) { 1647 if (v4l2_match_dv_timings(&state->timings, timings, 0, false)) {
1648 v4l2_dbg(1, debug, sd, "%s: no change\n", __func__); 1648 v4l2_dbg(1, debug, sd, "%s: no change\n", __func__);
1649 return 0; 1649 return 0;
1650 } 1650 }
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index b7269b8f040d..69378e4914b6 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -43,7 +43,7 @@
43#include <media/v4l2-event.h> 43#include <media/v4l2-event.h>
44#include <media/v4l2-ctrls.h> 44#include <media/v4l2-ctrls.h>
45#include <media/v4l2-dv-timings.h> 45#include <media/v4l2-dv-timings.h>
46#include <media/adv7842.h> 46#include <media/i2c/adv7842.h>
47 47
48static int debug; 48static int debug;
49module_param(debug, int, 0644); 49module_param(debug, int, 0644);
@@ -155,7 +155,7 @@ static bool adv7842_check_dv_timings(const struct v4l2_dv_timings *t, void *hdl)
155 int i; 155 int i;
156 156
157 for (i = 0; adv7842_timings_exceptions[i].bt.width; i++) 157 for (i = 0; adv7842_timings_exceptions[i].bt.width; i++)
158 if (v4l2_match_dv_timings(t, adv7842_timings_exceptions + i, 0)) 158 if (v4l2_match_dv_timings(t, adv7842_timings_exceptions + i, 0, false))
159 return false; 159 return false;
160 return true; 160 return true;
161} 161}
@@ -1008,7 +1008,7 @@ static int find_and_set_predefined_video_timings(struct v4l2_subdev *sd,
1008 1008
1009 for (i = 0; predef_vid_timings[i].timings.bt.width; i++) { 1009 for (i = 0; predef_vid_timings[i].timings.bt.width; i++) {
1010 if (!v4l2_match_dv_timings(timings, &predef_vid_timings[i].timings, 1010 if (!v4l2_match_dv_timings(timings, &predef_vid_timings[i].timings,
1011 is_digital_input(sd) ? 250000 : 1000000)) 1011 is_digital_input(sd) ? 250000 : 1000000, false))
1012 continue; 1012 continue;
1013 /* video std */ 1013 /* video std */
1014 io_write(sd, 0x00, predef_vid_timings[i].vid_std); 1014 io_write(sd, 0x00, predef_vid_timings[i].vid_std);
@@ -1659,7 +1659,7 @@ static int adv7842_s_dv_timings(struct v4l2_subdev *sd,
1659 if (state->mode == ADV7842_MODE_SDP) 1659 if (state->mode == ADV7842_MODE_SDP)
1660 return -ENODATA; 1660 return -ENODATA;
1661 1661
1662 if (v4l2_match_dv_timings(&state->timings, timings, 0)) { 1662 if (v4l2_match_dv_timings(&state->timings, timings, 0, false)) {
1663 v4l2_dbg(1, debug, sd, "%s: no change\n", __func__); 1663 v4l2_dbg(1, debug, sd, "%s: no change\n", __func__);
1664 return 0; 1664 return 0;
1665 } 1665 }
diff --git a/drivers/media/i2c/ak881x.c b/drivers/media/i2c/ak881x.c
index d3b965ec3bbc..d9f2b6b76d59 100644
--- a/drivers/media/i2c/ak881x.c
+++ b/drivers/media/i2c/ak881x.c
@@ -15,7 +15,7 @@
15#include <linux/videodev2.h> 15#include <linux/videodev2.h>
16#include <linux/module.h> 16#include <linux/module.h>
17 17
18#include <media/ak881x.h> 18#include <media/i2c/ak881x.h>
19#include <media/v4l2-common.h> 19#include <media/v4l2-common.h>
20#include <media/v4l2-device.h> 20#include <media/v4l2-device.h>
21 21
diff --git a/drivers/media/i2c/as3645a.c b/drivers/media/i2c/as3645a.c
index 301084b07887..29a2e7034aa6 100644
--- a/drivers/media/i2c/as3645a.c
+++ b/drivers/media/i2c/as3645a.c
@@ -31,7 +31,7 @@
31#include <linux/mutex.h> 31#include <linux/mutex.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33 33
34#include <media/as3645a.h> 34#include <media/i2c/as3645a.h>
35#include <media/v4l2-ctrls.h> 35#include <media/v4l2-ctrls.h>
36#include <media/v4l2-device.h> 36#include <media/v4l2-device.h>
37 37
diff --git a/drivers/media/i2c/bt819.c b/drivers/media/i2c/bt819.c
index e00e3104d448..7907bcfbaed3 100644
--- a/drivers/media/i2c/bt819.c
+++ b/drivers/media/i2c/bt819.c
@@ -37,7 +37,7 @@
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <media/v4l2-device.h> 38#include <media/v4l2-device.h>
39#include <media/v4l2-ctrls.h> 39#include <media/v4l2-ctrls.h>
40#include <media/bt819.h> 40#include <media/i2c/bt819.h>
41 41
42MODULE_DESCRIPTION("Brooktree-819 video decoder driver"); 42MODULE_DESCRIPTION("Brooktree-819 video decoder driver");
43MODULE_AUTHOR("Mike Bernson & Dave Perks"); 43MODULE_AUTHOR("Mike Bernson & Dave Perks");
diff --git a/drivers/media/i2c/cs3308.c b/drivers/media/i2c/cs3308.c
new file mode 100644
index 000000000000..d28b4f37fe5f
--- /dev/null
+++ b/drivers/media/i2c/cs3308.c
@@ -0,0 +1,138 @@
1/*
2 * Cirrus Logic cs3308 8-Channel Analog Volume Control
3 *
4 * Copyright (C) 2010 Devin Heitmueller <dheitmueller@kernellabs.com>
5 * Copyright (C) 2012 Steven Toth <stoth@kernellabs.com>
6 *
7 * Derived from cs5345.c Copyright (C) 2007 Hans Verkuil
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 */
19
20
21#include <linux/module.h>
22#include <linux/kernel.h>
23#include <linux/i2c.h>
24#include <linux/slab.h>
25#include <linux/videodev2.h>
26#include <media/v4l2-device.h>
27
28MODULE_DESCRIPTION("i2c device driver for cs3308 8-channel volume control");
29MODULE_AUTHOR("Devin Heitmueller");
30MODULE_LICENSE("GPL");
31
32static inline int cs3308_write(struct v4l2_subdev *sd, u8 reg, u8 value)
33{
34 struct i2c_client *client = v4l2_get_subdevdata(sd);
35
36 return i2c_smbus_write_byte_data(client, reg, value);
37}
38
39static inline int cs3308_read(struct v4l2_subdev *sd, u8 reg)
40{
41 struct i2c_client *client = v4l2_get_subdevdata(sd);
42
43 return i2c_smbus_read_byte_data(client, reg);
44}
45
46#ifdef CONFIG_VIDEO_ADV_DEBUG
47static int cs3308_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
48{
49 reg->val = cs3308_read(sd, reg->reg & 0xffff);
50 reg->size = 1;
51 return 0;
52}
53
54static int cs3308_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg)
55{
56 cs3308_write(sd, reg->reg & 0xffff, reg->val & 0xff);
57 return 0;
58}
59#endif
60
61/* ----------------------------------------------------------------------- */
62
63static const struct v4l2_subdev_core_ops cs3308_core_ops = {
64#ifdef CONFIG_VIDEO_ADV_DEBUG
65 .g_register = cs3308_g_register,
66 .s_register = cs3308_s_register,
67#endif
68};
69
70static const struct v4l2_subdev_ops cs3308_ops = {
71 .core = &cs3308_core_ops,
72};
73
74/* ----------------------------------------------------------------------- */
75
76static int cs3308_probe(struct i2c_client *client,
77 const struct i2c_device_id *id)
78{
79 struct v4l2_subdev *sd;
80 unsigned i;
81
82 /* Check if the adapter supports the needed features */
83 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
84 return -EIO;
85
86 if ((i2c_smbus_read_byte_data(client, 0x1c) & 0xf0) != 0xe0)
87 return -ENODEV;
88
89 v4l_info(client, "chip found @ 0x%x (%s)\n",
90 client->addr << 1, client->adapter->name);
91
92 sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
93 if (sd == NULL)
94 return -ENOMEM;
95
96 v4l2_i2c_subdev_init(sd, client, &cs3308_ops);
97
98 /* Set some reasonable defaults */
99 cs3308_write(sd, 0x0d, 0x00); /* Power up all channels */
100 cs3308_write(sd, 0x0e, 0x00); /* Master Power */
101 cs3308_write(sd, 0x0b, 0x00); /* Device Configuration */
102 /* Set volume for each channel */
103 for (i = 1; i <= 8; i++)
104 cs3308_write(sd, i, 0xd2);
105 cs3308_write(sd, 0x0a, 0x00); /* Unmute all channels */
106 return 0;
107}
108
109/* ----------------------------------------------------------------------- */
110
111static int cs3308_remove(struct i2c_client *client)
112{
113 struct v4l2_subdev *sd = i2c_get_clientdata(client);
114
115 v4l2_device_unregister_subdev(sd);
116 kfree(sd);
117 return 0;
118}
119
120/* ----------------------------------------------------------------------- */
121
122static const struct i2c_device_id cs3308_id[] = {
123 { "cs3308", 0 },
124 { }
125};
126MODULE_DEVICE_TABLE(i2c, cs3308_id);
127
128static struct i2c_driver cs3308_driver = {
129 .driver = {
130 .owner = THIS_MODULE,
131 .name = "cs3308",
132 },
133 .probe = cs3308_probe,
134 .remove = cs3308_remove,
135 .id_table = cs3308_id,
136};
137
138module_i2c_driver(cs3308_driver);
diff --git a/drivers/media/i2c/cx25840/cx25840-audio.c b/drivers/media/i2c/cx25840/cx25840-audio.c
index 34b96c7cfd62..baf3d9c8710e 100644
--- a/drivers/media/i2c/cx25840/cx25840-audio.c
+++ b/drivers/media/i2c/cx25840/cx25840-audio.c
@@ -19,7 +19,7 @@
19#include <linux/videodev2.h> 19#include <linux/videodev2.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <media/v4l2-common.h> 21#include <media/v4l2-common.h>
22#include <media/cx25840.h> 22#include <media/drv-intf/cx25840.h>
23 23
24#include "cx25840-core.h" 24#include "cx25840-core.h"
25 25
diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
index fe6eb78b6914..f2e2c34ddbbd 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -45,7 +45,7 @@
45#include <linux/delay.h> 45#include <linux/delay.h>
46#include <linux/math64.h> 46#include <linux/math64.h>
47#include <media/v4l2-common.h> 47#include <media/v4l2-common.h>
48#include <media/cx25840.h> 48#include <media/drv-intf/cx25840.h>
49 49
50#include "cx25840-core.h" 50#include "cx25840-core.h"
51 51
@@ -559,7 +559,10 @@ static void cx23885_initialize(struct i2c_client *client)
559 cx25840_write4(client, 0x414, 0x00107d12); 559 cx25840_write4(client, 0x414, 0x00107d12);
560 560
561 /* Chroma */ 561 /* Chroma */
562 cx25840_write4(client, 0x420, 0x3d008282); 562 if (is_cx23888(state))
563 cx25840_write4(client, 0x418, 0x1d008282);
564 else
565 cx25840_write4(client, 0x420, 0x3d008282);
563 566
564 /* 567 /*
565 * Aux PLL 568 * Aux PLL
@@ -666,14 +669,17 @@ static void cx23885_initialize(struct i2c_client *client)
666 cx25840_write4(client, 0x404, 0x0010253e); 669 cx25840_write4(client, 0x404, 0x0010253e);
667 670
668 /* CC on - Undocumented Register */ 671 /* CC on - Undocumented Register */
669 cx25840_write(client, 0x42f, 0x66); 672 cx25840_write(client, state->vbi_regs_offset + 0x42f, 0x66);
670 673
671 /* HVR-1250 / HVR1850 DIF related */ 674 /* HVR-1250 / HVR1850 DIF related */
672 /* Power everything up */ 675 /* Power everything up */
673 cx25840_write4(client, 0x130, 0x0); 676 cx25840_write4(client, 0x130, 0x0);
674 677
675 /* Undocumented */ 678 /* Undocumented */
676 cx25840_write4(client, 0x478, 0x6628021F); 679 if (is_cx23888(state))
680 cx25840_write4(client, 0x454, 0x6628021F);
681 else
682 cx25840_write4(client, 0x478, 0x6628021F);
677 683
678 /* AFE_CLK_OUT_CTRL - Select the clock output source as output */ 684 /* AFE_CLK_OUT_CTRL - Select the clock output source as output */
679 cx25840_write4(client, 0x144, 0x5); 685 cx25840_write4(client, 0x144, 0x5);
@@ -1106,31 +1112,15 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp
1106 cx25840_write4(client, 0x410, 0xffff0dbf); 1112 cx25840_write4(client, 0x410, 0xffff0dbf);
1107 cx25840_write4(client, 0x414, 0x00137d03); 1113 cx25840_write4(client, 0x414, 0x00137d03);
1108 1114
1109 /* on the 887, 0x418 is HSCALE_CTRL, on the 888 it is 1115 cx25840_write4(client, state->vbi_regs_offset + 0x42c, 0x42600000);
1110 CHROMA_CTRL */ 1116 cx25840_write4(client, state->vbi_regs_offset + 0x430, 0x0000039b);
1111 if (is_cx23888(state)) 1117 cx25840_write4(client, state->vbi_regs_offset + 0x438, 0x00000000);
1112 cx25840_write4(client, 0x418, 0x01008080);
1113 else
1114 cx25840_write4(client, 0x418, 0x01000000);
1115 1118
1116 cx25840_write4(client, 0x41c, 0x00000000); 1119 cx25840_write4(client, state->vbi_regs_offset + 0x440, 0xF8E3E824);
1117 1120 cx25840_write4(client, state->vbi_regs_offset + 0x444, 0x401040dc);
1118 /* on the 887, 0x420 is CHROMA_CTRL, on the 888 it is 1121 cx25840_write4(client, state->vbi_regs_offset + 0x448, 0xcd3f02a0);
1119 CRUSH_CTRL */ 1122 cx25840_write4(client, state->vbi_regs_offset + 0x44c, 0x161f1000);
1120 if (is_cx23888(state)) 1123 cx25840_write4(client, state->vbi_regs_offset + 0x450, 0x00000802);
1121 cx25840_write4(client, 0x420, 0x001c3e0f);
1122 else
1123 cx25840_write4(client, 0x420, 0x001c8282);
1124
1125 cx25840_write4(client, 0x42c, 0x42600000);
1126 cx25840_write4(client, 0x430, 0x0000039b);
1127 cx25840_write4(client, 0x438, 0x00000000);
1128
1129 cx25840_write4(client, 0x440, 0xF8E3E824);
1130 cx25840_write4(client, 0x444, 0x401040dc);
1131 cx25840_write4(client, 0x448, 0xcd3f02a0);
1132 cx25840_write4(client, 0x44c, 0x161f1000);
1133 cx25840_write4(client, 0x450, 0x00000802);
1134 1124
1135 cx25840_write4(client, 0x91c, 0x01000000); 1125 cx25840_write4(client, 0x91c, 0x01000000);
1136 cx25840_write4(client, 0x8e0, 0x03063870); 1126 cx25840_write4(client, 0x8e0, 0x03063870);
@@ -1400,8 +1390,14 @@ static int cx25840_set_fmt(struct v4l2_subdev *sd,
1400 1390
1401 Vlines = fmt->height + (is_50Hz ? 4 : 7); 1391 Vlines = fmt->height + (is_50Hz ? 4 : 7);
1402 1392
1393 /*
1394 * We keep 1 margin for the Vsrc < Vlines check since the
1395 * cx23888 reports a Vsrc of 486 instead of 487 for the NTSC
1396 * height. Without that margin the cx23885 fails in this
1397 * check.
1398 */
1403 if ((fmt->width * 16 < Hsrc) || (Hsrc < fmt->width) || 1399 if ((fmt->width * 16 < Hsrc) || (Hsrc < fmt->width) ||
1404 (Vlines * 8 < Vsrc) || (Vsrc < Vlines)) { 1400 (Vlines * 8 < Vsrc) || (Vsrc + 1 < Vlines)) {
1405 v4l_err(client, "%dx%d is not a valid size!\n", 1401 v4l_err(client, "%dx%d is not a valid size!\n",
1406 fmt->width, fmt->height); 1402 fmt->width, fmt->height);
1407 return -ERANGE; 1403 return -ERANGE;
@@ -1426,14 +1422,20 @@ static int cx25840_set_fmt(struct v4l2_subdev *sd,
1426 fmt->width, fmt->height, HSC, VSC); 1422 fmt->width, fmt->height, HSC, VSC);
1427 1423
1428 /* HSCALE=HSC */ 1424 /* HSCALE=HSC */
1429 cx25840_write(client, 0x418, HSC & 0xff); 1425 if (is_cx23888(state)) {
1430 cx25840_write(client, 0x419, (HSC >> 8) & 0xff); 1426 cx25840_write4(client, 0x434, HSC | (1 << 24));
1431 cx25840_write(client, 0x41a, HSC >> 16); 1427 /* VSCALE=VSC VS_INTRLACE=1 VFILT=filter */
1432 /* VSCALE=VSC */ 1428 cx25840_write4(client, 0x438, VSC | (1 << 19) | (filter << 16));
1433 cx25840_write(client, 0x41c, VSC & 0xff); 1429 } else {
1434 cx25840_write(client, 0x41d, VSC >> 8); 1430 cx25840_write(client, 0x418, HSC & 0xff);
1435 /* VS_INTRLACE=1 VFILT=filter */ 1431 cx25840_write(client, 0x419, (HSC >> 8) & 0xff);
1436 cx25840_write(client, 0x41e, 0x8 | filter); 1432 cx25840_write(client, 0x41a, HSC >> 16);
1433 /* VSCALE=VSC */
1434 cx25840_write(client, 0x41c, VSC & 0xff);
1435 cx25840_write(client, 0x41d, VSC >> 8);
1436 /* VS_INTRLACE=1 VFILT=filter */
1437 cx25840_write(client, 0x41e, 0x8 | filter);
1438 }
1437 return 0; 1439 return 0;
1438} 1440}
1439 1441
@@ -1714,26 +1716,27 @@ static int cx25840_s_stream(struct v4l2_subdev *sd, int enable)
1714 1716
1715 v4l_dbg(1, cx25840_debug, client, "%s video output\n", 1717 v4l_dbg(1, cx25840_debug, client, "%s video output\n",
1716 enable ? "enable" : "disable"); 1718 enable ? "enable" : "disable");
1719
1720 /*
1721 * It's not clear what should be done for these devices.
1722 * The original code used the same addresses as for the cx25840, but
1723 * those addresses do something else entirely on the cx2388x and
1724 * cx231xx. Since it never did anything in the first place, just do
1725 * nothing.
1726 */
1727 if (is_cx2388x(state) || is_cx231xx(state))
1728 return 0;
1729
1717 if (enable) { 1730 if (enable) {
1718 if (is_cx2388x(state) || is_cx231xx(state)) { 1731 v = cx25840_read(client, 0x115) | 0x0c;
1719 v = cx25840_read(client, 0x421) | 0x0b; 1732 cx25840_write(client, 0x115, v);
1720 cx25840_write(client, 0x421, v); 1733 v = cx25840_read(client, 0x116) | 0x04;
1721 } else { 1734 cx25840_write(client, 0x116, v);
1722 v = cx25840_read(client, 0x115) | 0x0c;
1723 cx25840_write(client, 0x115, v);
1724 v = cx25840_read(client, 0x116) | 0x04;
1725 cx25840_write(client, 0x116, v);
1726 }
1727 } else { 1735 } else {
1728 if (is_cx2388x(state) || is_cx231xx(state)) { 1736 v = cx25840_read(client, 0x115) & ~(0x0c);
1729 v = cx25840_read(client, 0x421) & ~(0x0b); 1737 cx25840_write(client, 0x115, v);
1730 cx25840_write(client, 0x421, v); 1738 v = cx25840_read(client, 0x116) & ~(0x04);
1731 } else { 1739 cx25840_write(client, 0x116, v);
1732 v = cx25840_read(client, 0x115) & ~(0x0c);
1733 cx25840_write(client, 0x115, v);
1734 v = cx25840_read(client, 0x116) & ~(0x04);
1735 cx25840_write(client, 0x116, v);
1736 }
1737 } 1740 }
1738 return 0; 1741 return 0;
1739} 1742}
@@ -4974,7 +4977,7 @@ static void cx23888_std_setup(struct i2c_client *client)
4974 cx25840_write4(client, 0x4b4, 0x20524030); 4977 cx25840_write4(client, 0x4b4, 0x20524030);
4975 cx25840_write4(client, 0x47c, 0x010a8263); 4978 cx25840_write4(client, 0x47c, 0x010a8263);
4976 4979
4977 if (std & V4L2_STD_NTSC) { 4980 if (std & V4L2_STD_525_60) {
4978 v4l_dbg(1, cx25840_debug, client, "%s() Selecting NTSC", 4981 v4l_dbg(1, cx25840_debug, client, "%s() Selecting NTSC",
4979 __func__); 4982 __func__);
4980 4983
@@ -5264,6 +5267,8 @@ static int cx25840_probe(struct i2c_client *client,
5264 state->vbi_line_offset = 8; 5267 state->vbi_line_offset = 8;
5265 state->id = id; 5268 state->id = id;
5266 state->rev = device_id; 5269 state->rev = device_id;
5270 state->vbi_regs_offset = id == CX23888_AV ? 0x500 - 0x424 : 0;
5271 state->std = V4L2_STD_NTSC_M;
5267 v4l2_ctrl_handler_init(&state->hdl, 9); 5272 v4l2_ctrl_handler_init(&state->hdl, 9);
5268 v4l2_ctrl_new_std(&state->hdl, &cx25840_ctrl_ops, 5273 v4l2_ctrl_new_std(&state->hdl, &cx25840_ctrl_ops,
5269 V4L2_CID_BRIGHTNESS, 0, 255, 1, 128); 5274 V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
diff --git a/drivers/media/i2c/cx25840/cx25840-core.h b/drivers/media/i2c/cx25840/cx25840-core.h
index fdea48ce0c03..254ef45ce41a 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.h
+++ b/drivers/media/i2c/cx25840/cx25840-core.h
@@ -69,6 +69,7 @@ struct cx25840_state {
69 enum cx25840_model id; 69 enum cx25840_model id;
70 u32 rev; 70 u32 rev;
71 int is_initialized; 71 int is_initialized;
72 unsigned vbi_regs_offset;
72 wait_queue_head_t fw_wait; /* wake up when the fw load is finished */ 73 wait_queue_head_t fw_wait; /* wake up when the fw load is finished */
73 struct work_struct fw_work; /* work entry for fw load */ 74 struct work_struct fw_work; /* work entry for fw load */
74 struct cx25840_ir_state *ir_state; 75 struct cx25840_ir_state *ir_state;
diff --git a/drivers/media/i2c/cx25840/cx25840-firmware.c b/drivers/media/i2c/cx25840/cx25840-firmware.c
index 9bbb31adc29d..37e052923a87 100644
--- a/drivers/media/i2c/cx25840/cx25840-firmware.c
+++ b/drivers/media/i2c/cx25840/cx25840-firmware.c
@@ -19,7 +19,7 @@
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/firmware.h> 20#include <linux/firmware.h>
21#include <media/v4l2-common.h> 21#include <media/v4l2-common.h>
22#include <media/cx25840.h> 22#include <media/drv-intf/cx25840.h>
23 23
24#include "cx25840-core.h" 24#include "cx25840-core.h"
25 25
diff --git a/drivers/media/i2c/cx25840/cx25840-ir.c b/drivers/media/i2c/cx25840/cx25840-ir.c
index 4cf8f18bf097..4b782012cadc 100644
--- a/drivers/media/i2c/cx25840/cx25840-ir.c
+++ b/drivers/media/i2c/cx25840/cx25840-ir.c
@@ -24,7 +24,7 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/kfifo.h> 25#include <linux/kfifo.h>
26#include <linux/module.h> 26#include <linux/module.h>
27#include <media/cx25840.h> 27#include <media/drv-intf/cx25840.h>
28#include <media/rc-core.h> 28#include <media/rc-core.h>
29 29
30#include "cx25840-core.h" 30#include "cx25840-core.h"
diff --git a/drivers/media/i2c/cx25840/cx25840-vbi.c b/drivers/media/i2c/cx25840/cx25840-vbi.c
index c39e91dc1137..0470bb6128e1 100644
--- a/drivers/media/i2c/cx25840/cx25840-vbi.c
+++ b/drivers/media/i2c/cx25840/cx25840-vbi.c
@@ -19,7 +19,7 @@
19#include <linux/videodev2.h> 19#include <linux/videodev2.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <media/v4l2-common.h> 21#include <media/v4l2-common.h>
22#include <media/cx25840.h> 22#include <media/drv-intf/cx25840.h>
23 23
24#include "cx25840-core.h" 24#include "cx25840-core.h"
25 25
@@ -104,7 +104,8 @@ int cx25840_g_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *
104 104
105 if (is_pal) { 105 if (is_pal) {
106 for (i = 7; i <= 23; i++) { 106 for (i = 7; i <= 23; i++) {
107 u8 v = cx25840_read(client, 0x424 + i - 7); 107 u8 v = cx25840_read(client,
108 state->vbi_regs_offset + 0x424 + i - 7);
108 109
109 svbi->service_lines[0][i] = lcr2vbi[v >> 4]; 110 svbi->service_lines[0][i] = lcr2vbi[v >> 4];
110 svbi->service_lines[1][i] = lcr2vbi[v & 0xf]; 111 svbi->service_lines[1][i] = lcr2vbi[v & 0xf];
@@ -113,7 +114,8 @@ int cx25840_g_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *
113 } 114 }
114 } else { 115 } else {
115 for (i = 10; i <= 21; i++) { 116 for (i = 10; i <= 21; i++) {
116 u8 v = cx25840_read(client, 0x424 + i - 10); 117 u8 v = cx25840_read(client,
118 state->vbi_regs_offset + 0x424 + i - 10);
117 119
118 svbi->service_lines[0][i] = lcr2vbi[v >> 4]; 120 svbi->service_lines[0][i] = lcr2vbi[v >> 4];
119 svbi->service_lines[1][i] = lcr2vbi[v & 0xf]; 121 svbi->service_lines[1][i] = lcr2vbi[v & 0xf];
@@ -135,7 +137,10 @@ int cx25840_s_raw_fmt(struct v4l2_subdev *sd, struct v4l2_vbi_format *fmt)
135 cx25840_std_setup(client); 137 cx25840_std_setup(client);
136 138
137 /* VBI Offset */ 139 /* VBI Offset */
138 cx25840_write(client, 0x47f, vbi_offset); 140 if (is_cx23888(state))
141 cx25840_write(client, 0x54f, vbi_offset);
142 else
143 cx25840_write(client, 0x47f, vbi_offset);
139 cx25840_write(client, 0x404, 0x2e); 144 cx25840_write(client, 0x404, 0x2e);
140 return 0; 145 return 0;
141} 146}
@@ -158,7 +163,10 @@ int cx25840_s_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *
158 /* Sliced VBI */ 163 /* Sliced VBI */
159 cx25840_write(client, 0x404, 0x32); /* Ancillary data */ 164 cx25840_write(client, 0x404, 0x32); /* Ancillary data */
160 cx25840_write(client, 0x406, 0x13); 165 cx25840_write(client, 0x406, 0x13);
161 cx25840_write(client, 0x47f, vbi_offset); 166 if (is_cx23888(state))
167 cx25840_write(client, 0x54f, vbi_offset);
168 else
169 cx25840_write(client, 0x47f, vbi_offset);
162 170
163 if (is_pal) { 171 if (is_pal) {
164 for (i = 0; i <= 6; i++) 172 for (i = 0; i <= 6; i++)
@@ -194,17 +202,23 @@ int cx25840_s_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *
194 } 202 }
195 203
196 if (is_pal) { 204 if (is_pal) {
197 for (x = 1, i = 0x424; i <= 0x434; i++, x++) 205 for (x = 1, i = state->vbi_regs_offset + 0x424;
206 i <= state->vbi_regs_offset + 0x434; i++, x++)
198 cx25840_write(client, i, lcr[6 + x]); 207 cx25840_write(client, i, lcr[6 + x]);
199 } else { 208 } else {
200 for (x = 1, i = 0x424; i <= 0x430; i++, x++) 209 for (x = 1, i = state->vbi_regs_offset + 0x424;
210 i <= state->vbi_regs_offset + 0x430; i++, x++)
201 cx25840_write(client, i, lcr[9 + x]); 211 cx25840_write(client, i, lcr[9 + x]);
202 for (i = 0x431; i <= 0x434; i++) 212 for (i = state->vbi_regs_offset + 0x431;
213 i <= state->vbi_regs_offset + 0x434; i++)
203 cx25840_write(client, i, 0); 214 cx25840_write(client, i, 0);
204 } 215 }
205 216
206 cx25840_write(client, 0x43c, 0x16); 217 cx25840_write(client, state->vbi_regs_offset + 0x43c, 0x16);
207 cx25840_write(client, 0x474, is_pal ? 0x2a : 0x22); 218 if (is_cx23888(state))
219 cx25840_write(client, 0x428, is_pal ? 0x2a : 0x22);
220 else
221 cx25840_write(client, 0x474, is_pal ? 0x2a : 0x22);
208 return 0; 222 return 0;
209} 223}
210 224
diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index 728d2cc8a3e7..830491960add 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -47,7 +47,7 @@
47#include <linux/workqueue.h> 47#include <linux/workqueue.h>
48 48
49#include <media/rc-core.h> 49#include <media/rc-core.h>
50#include <media/ir-kbd-i2c.h> 50#include <media/i2c/ir-kbd-i2c.h>
51 51
52/* ----------------------------------------------------------------------- */ 52/* ----------------------------------------------------------------------- */
53/* insmod parameters */ 53/* insmod parameters */
diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c
index d9ece4b2d047..19ecb8801064 100644
--- a/drivers/media/i2c/lm3560.c
+++ b/drivers/media/i2c/lm3560.c
@@ -24,7 +24,7 @@
24#include <linux/mutex.h> 24#include <linux/mutex.h>
25#include <linux/regmap.h> 25#include <linux/regmap.h>
26#include <linux/videodev2.h> 26#include <linux/videodev2.h>
27#include <media/lm3560.h> 27#include <media/i2c/lm3560.h>
28#include <media/v4l2-ctrls.h> 28#include <media/v4l2-ctrls.h>
29#include <media/v4l2-device.h> 29#include <media/v4l2-device.h>
30 30
diff --git a/drivers/media/i2c/lm3646.c b/drivers/media/i2c/lm3646.c
index 626fb4679c02..7fbe6ff1c4f4 100644
--- a/drivers/media/i2c/lm3646.c
+++ b/drivers/media/i2c/lm3646.c
@@ -18,7 +18,7 @@
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/regmap.h> 19#include <linux/regmap.h>
20#include <linux/videodev2.h> 20#include <linux/videodev2.h>
21#include <media/lm3646.h> 21#include <media/i2c/lm3646.h>
22#include <media/v4l2-ctrls.h> 22#include <media/v4l2-ctrls.h>
23#include <media/v4l2-device.h> 23#include <media/v4l2-device.h>
24 24
diff --git a/drivers/media/i2c/m52790.c b/drivers/media/i2c/m52790.c
index 77eb07eb667e..81171d8e1c2c 100644
--- a/drivers/media/i2c/m52790.c
+++ b/drivers/media/i2c/m52790.c
@@ -27,7 +27,7 @@
27#include <asm/uaccess.h> 27#include <asm/uaccess.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/videodev2.h> 29#include <linux/videodev2.h>
30#include <media/m52790.h> 30#include <media/i2c/m52790.h>
31#include <media/v4l2-device.h> 31#include <media/v4l2-device.h>
32 32
33MODULE_DESCRIPTION("i2c device driver for m52790 A/V switch"); 33MODULE_DESCRIPTION("i2c device driver for m52790 A/V switch");
diff --git a/drivers/media/i2c/m5mols/m5mols_capture.c b/drivers/media/i2c/m5mols/m5mols_capture.c
index 1a03d02bd4d1..a0cd6dc32eb0 100644
--- a/drivers/media/i2c/m5mols/m5mols_capture.c
+++ b/drivers/media/i2c/m5mols/m5mols_capture.c
@@ -25,8 +25,8 @@
25#include <media/v4l2-ctrls.h> 25#include <media/v4l2-ctrls.h>
26#include <media/v4l2-device.h> 26#include <media/v4l2-device.h>
27#include <media/v4l2-subdev.h> 27#include <media/v4l2-subdev.h>
28#include <media/m5mols.h> 28#include <media/i2c/m5mols.h>
29#include <media/exynos-fimc.h> 29#include <media/drv-intf/exynos-fimc.h>
30 30
31#include "m5mols.h" 31#include "m5mols.h"
32#include "m5mols_reg.h" 32#include "m5mols_reg.h"
diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c
index 6404c0d93e7a..f8993933416e 100644
--- a/drivers/media/i2c/m5mols/m5mols_core.c
+++ b/drivers/media/i2c/m5mols/m5mols_core.c
@@ -25,7 +25,7 @@
25#include <media/v4l2-ctrls.h> 25#include <media/v4l2-ctrls.h>
26#include <media/v4l2-device.h> 26#include <media/v4l2-device.h>
27#include <media/v4l2-subdev.h> 27#include <media/v4l2-subdev.h>
28#include <media/m5mols.h> 28#include <media/i2c/m5mols.h>
29 29
30#include "m5mols.h" 30#include "m5mols.h"
31#include "m5mols_reg.h" 31#include "m5mols_reg.h"
diff --git a/drivers/media/i2c/msp3400-driver.c b/drivers/media/i2c/msp3400-driver.c
index bdb94000ba5a..a84561d0d4a8 100644
--- a/drivers/media/i2c/msp3400-driver.c
+++ b/drivers/media/i2c/msp3400-driver.c
@@ -56,8 +56,8 @@
56#include <linux/videodev2.h> 56#include <linux/videodev2.h>
57#include <media/v4l2-device.h> 57#include <media/v4l2-device.h>
58#include <media/v4l2-ioctl.h> 58#include <media/v4l2-ioctl.h>
59#include <media/msp3400.h> 59#include <media/drv-intf/msp3400.h>
60#include <media/tvaudio.h> 60#include <media/i2c/tvaudio.h>
61#include "msp3400-driver.h" 61#include "msp3400-driver.h"
62 62
63/* ---------------------------------------------------------------------- */ 63/* ---------------------------------------------------------------------- */
diff --git a/drivers/media/i2c/msp3400-driver.h b/drivers/media/i2c/msp3400-driver.h
index fbe5e0715f93..6cae21366ed5 100644
--- a/drivers/media/i2c/msp3400-driver.h
+++ b/drivers/media/i2c/msp3400-driver.h
@@ -4,7 +4,7 @@
4#ifndef MSP3400_DRIVER_H 4#ifndef MSP3400_DRIVER_H
5#define MSP3400_DRIVER_H 5#define MSP3400_DRIVER_H
6 6
7#include <media/msp3400.h> 7#include <media/drv-intf/msp3400.h>
8#include <media/v4l2-device.h> 8#include <media/v4l2-device.h>
9#include <media/v4l2-ctrls.h> 9#include <media/v4l2-ctrls.h>
10 10
diff --git a/drivers/media/i2c/msp3400-kthreads.c b/drivers/media/i2c/msp3400-kthreads.c
index f8b51714f2f9..17120804fab7 100644
--- a/drivers/media/i2c/msp3400-kthreads.c
+++ b/drivers/media/i2c/msp3400-kthreads.c
@@ -26,7 +26,7 @@
26#include <linux/freezer.h> 26#include <linux/freezer.h>
27#include <linux/videodev2.h> 27#include <linux/videodev2.h>
28#include <media/v4l2-common.h> 28#include <media/v4l2-common.h>
29#include <media/msp3400.h> 29#include <media/drv-intf/msp3400.h>
30#include <linux/kthread.h> 30#include <linux/kthread.h>
31#include <linux/suspend.h> 31#include <linux/suspend.h>
32#include "msp3400-driver.h" 32#include "msp3400-driver.h"
diff --git a/drivers/media/i2c/mt9m032.c b/drivers/media/i2c/mt9m032.c
index c7747bd0cabb..101cb26f9330 100644
--- a/drivers/media/i2c/mt9m032.c
+++ b/drivers/media/i2c/mt9m032.c
@@ -31,7 +31,7 @@
31#include <linux/v4l2-mediabus.h> 31#include <linux/v4l2-mediabus.h>
32 32
33#include <media/media-entity.h> 33#include <media/media-entity.h>
34#include <media/mt9m032.h> 34#include <media/i2c/mt9m032.h>
35#include <media/v4l2-ctrls.h> 35#include <media/v4l2-ctrls.h>
36#include <media/v4l2-device.h> 36#include <media/v4l2-device.h>
37#include <media/v4l2-subdev.h> 37#include <media/v4l2-subdev.h>
@@ -671,7 +671,7 @@ static int mt9m032_set_ctrl(struct v4l2_ctrl *ctrl)
671 return 0; 671 return 0;
672} 672}
673 673
674static struct v4l2_ctrl_ops mt9m032_ctrl_ops = { 674static const struct v4l2_ctrl_ops mt9m032_ctrl_ops = {
675 .s_ctrl = mt9m032_set_ctrl, 675 .s_ctrl = mt9m032_set_ctrl,
676 .try_ctrl = mt9m032_try_ctrl, 676 .try_ctrl = mt9m032_try_ctrl,
677}; 677};
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index 0db15f528ac1..a3da0e977d0b 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -26,7 +26,7 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/videodev2.h> 27#include <linux/videodev2.h>
28 28
29#include <media/mt9p031.h> 29#include <media/i2c/mt9p031.h>
30#include <media/v4l2-async.h> 30#include <media/v4l2-async.h>
31#include <media/v4l2-ctrls.h> 31#include <media/v4l2-ctrls.h>
32#include <media/v4l2-device.h> 32#include <media/v4l2-device.h>
@@ -817,7 +817,7 @@ static int mt9p031_s_ctrl(struct v4l2_ctrl *ctrl)
817 return 0; 817 return 0;
818} 818}
819 819
820static struct v4l2_ctrl_ops mt9p031_ctrl_ops = { 820static const struct v4l2_ctrl_ops mt9p031_ctrl_ops = {
821 .s_ctrl = mt9p031_s_ctrl, 821 .s_ctrl = mt9p031_s_ctrl,
822}; 822};
823 823
diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c
index 8ae99f7f254c..b28fdff1d310 100644
--- a/drivers/media/i2c/mt9t001.c
+++ b/drivers/media/i2c/mt9t001.c
@@ -21,7 +21,7 @@
21#include <linux/videodev2.h> 21#include <linux/videodev2.h>
22#include <linux/v4l2-mediabus.h> 22#include <linux/v4l2-mediabus.h>
23 23
24#include <media/mt9t001.h> 24#include <media/i2c/mt9t001.h>
25#include <media/v4l2-ctrls.h> 25#include <media/v4l2-ctrls.h>
26#include <media/v4l2-device.h> 26#include <media/v4l2-device.h>
27#include <media/v4l2-subdev.h> 27#include <media/v4l2-subdev.h>
@@ -626,7 +626,7 @@ static int mt9t001_s_ctrl(struct v4l2_ctrl *ctrl)
626 return 0; 626 return 0;
627} 627}
628 628
629static struct v4l2_ctrl_ops mt9t001_ctrl_ops = { 629static const struct v4l2_ctrl_ops mt9t001_ctrl_ops = {
630 .s_ctrl = mt9t001_s_ctrl, 630 .s_ctrl = mt9t001_s_ctrl,
631}; 631};
632 632
diff --git a/drivers/media/i2c/mt9v011.c b/drivers/media/i2c/mt9v011.c
index a4a5c39b599b..b9fea11d6b0b 100644
--- a/drivers/media/i2c/mt9v011.c
+++ b/drivers/media/i2c/mt9v011.c
@@ -13,7 +13,7 @@
13#include <asm/div64.h> 13#include <asm/div64.h>
14#include <media/v4l2-device.h> 14#include <media/v4l2-device.h>
15#include <media/v4l2-ctrls.h> 15#include <media/v4l2-ctrls.h>
16#include <media/mt9v011.h> 16#include <media/i2c/mt9v011.h>
17 17
18MODULE_DESCRIPTION("Micron mt9v011 sensor driver"); 18MODULE_DESCRIPTION("Micron mt9v011 sensor driver");
19MODULE_AUTHOR("Mauro Carvalho Chehab"); 19MODULE_AUTHOR("Mauro Carvalho Chehab");
@@ -454,7 +454,7 @@ static int mt9v011_s_ctrl(struct v4l2_ctrl *ctrl)
454 return 0; 454 return 0;
455} 455}
456 456
457static struct v4l2_ctrl_ops mt9v011_ctrl_ops = { 457static const struct v4l2_ctrl_ops mt9v011_ctrl_ops = {
458 .s_ctrl = mt9v011_s_ctrl, 458 .s_ctrl = mt9v011_s_ctrl,
459}; 459};
460 460
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index a68ce94ee097..1dbbd23fdfb0 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -25,7 +25,7 @@
25#include <linux/v4l2-mediabus.h> 25#include <linux/v4l2-mediabus.h>
26#include <linux/module.h> 26#include <linux/module.h>
27 27
28#include <media/mt9v032.h> 28#include <media/i2c/mt9v032.h>
29#include <media/v4l2-ctrls.h> 29#include <media/v4l2-ctrls.h>
30#include <media/v4l2-device.h> 30#include <media/v4l2-device.h>
31#include <media/v4l2-of.h> 31#include <media/v4l2-of.h>
@@ -703,7 +703,7 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
703 return 0; 703 return 0;
704} 704}
705 705
706static struct v4l2_ctrl_ops mt9v032_ctrl_ops = { 706static const struct v4l2_ctrl_ops mt9v032_ctrl_ops = {
707 .s_ctrl = mt9v032_s_ctrl, 707 .s_ctrl = mt9v032_s_ctrl,
708}; 708};
709 709
diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c
index f197b6cbd407..69e4f3031d8b 100644
--- a/drivers/media/i2c/noon010pc30.c
+++ b/drivers/media/i2c/noon010pc30.c
@@ -18,7 +18,7 @@
18#include <linux/i2c.h> 18#include <linux/i2c.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/regulator/consumer.h> 20#include <linux/regulator/consumer.h>
21#include <media/noon010pc30.h> 21#include <media/i2c/noon010pc30.h>
22#include <linux/videodev2.h> 22#include <linux/videodev2.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <media/v4l2-ctrls.h> 24#include <media/v4l2-ctrls.h>
diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 49109f4f5bb4..82c7ac1cc88e 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -37,7 +37,7 @@
37#include <linux/videodev2.h> 37#include <linux/videodev2.h>
38 38
39#include <media/media-entity.h> 39#include <media/media-entity.h>
40#include <media/ov2659.h> 40#include <media/i2c/ov2659.h>
41#include <media/v4l2-common.h> 41#include <media/v4l2-common.h>
42#include <media/v4l2-ctrls.h> 42#include <media/v4l2-ctrls.h>
43#include <media/v4l2-device.h> 43#include <media/v4l2-device.h>
@@ -1249,7 +1249,7 @@ static int ov2659_s_ctrl(struct v4l2_ctrl *ctrl)
1249 return 0; 1249 return 0;
1250} 1250}
1251 1251
1252static struct v4l2_ctrl_ops ov2659_ctrl_ops = { 1252static const struct v4l2_ctrl_ops ov2659_ctrl_ops = {
1253 .s_ctrl = ov2659_s_ctrl, 1253 .s_ctrl = ov2659_s_ctrl,
1254}; 1254};
1255 1255
diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index e1b5dc84c14e..56cfb5ca9c95 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -20,7 +20,7 @@
20#include <media/v4l2-ctrls.h> 20#include <media/v4l2-ctrls.h>
21#include <media/v4l2-mediabus.h> 21#include <media/v4l2-mediabus.h>
22#include <media/v4l2-image-sizes.h> 22#include <media/v4l2-image-sizes.h>
23#include <media/ov7670.h> 23#include <media/i2c/ov7670.h>
24 24
25MODULE_AUTHOR("Jonathan Corbet <corbet@lwn.net>"); 25MODULE_AUTHOR("Jonathan Corbet <corbet@lwn.net>");
26MODULE_DESCRIPTION("A low-level driver for OmniVision ov7670 sensors"); 26MODULE_DESCRIPTION("A low-level driver for OmniVision ov7670 sensors");
diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
index 1ee6a5527c38..9fe9006474b2 100644
--- a/drivers/media/i2c/ov9650.c
+++ b/drivers/media/i2c/ov9650.c
@@ -29,7 +29,7 @@
29#include <media/v4l2-image-sizes.h> 29#include <media/v4l2-image-sizes.h>
30#include <media/v4l2-subdev.h> 30#include <media/v4l2-subdev.h>
31#include <media/v4l2-mediabus.h> 31#include <media/v4l2-mediabus.h>
32#include <media/ov9650.h> 32#include <media/i2c/ov9650.h>
33 33
34static int debug; 34static int debug;
35module_param(debug, int, 0644); 35module_param(debug, int, 0644);
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index 51b26010403c..25f5e79dc9bc 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -34,7 +34,7 @@
34#include <media/v4l2-device.h> 34#include <media/v4l2-device.h>
35#include <media/v4l2-subdev.h> 35#include <media/v4l2-subdev.h>
36#include <media/v4l2-mediabus.h> 36#include <media/v4l2-mediabus.h>
37#include <media/s5c73m3.h> 37#include <media/i2c/s5c73m3.h>
38#include <media/v4l2-of.h> 38#include <media/v4l2-of.h>
39 39
40#include "s5c73m3.h" 40#include "s5c73m3.h"
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c b/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c
index 8001cde1db1e..0a060339e516 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c
@@ -32,7 +32,7 @@
32#include <media/v4l2-device.h> 32#include <media/v4l2-device.h>
33#include <media/v4l2-subdev.h> 33#include <media/v4l2-subdev.h>
34#include <media/v4l2-mediabus.h> 34#include <media/v4l2-mediabus.h>
35#include <media/s5c73m3.h> 35#include <media/i2c/s5c73m3.h>
36 36
37#include "s5c73m3.h" 37#include "s5c73m3.h"
38 38
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-spi.c b/drivers/media/i2c/s5c73m3/s5c73m3-spi.c
index 72ef9f936e6c..7d65b36434b1 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-spi.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-spi.c
@@ -37,6 +37,7 @@ enum spi_direction {
37 SPI_DIR_RX, 37 SPI_DIR_RX,
38 SPI_DIR_TX 38 SPI_DIR_TX
39}; 39};
40MODULE_DEVICE_TABLE(of, s5c73m3_spi_ids);
40 41
41static int spi_xmit(struct spi_device *spi_dev, void *addr, const int len, 42static int spi_xmit(struct spi_device *spi_dev, void *addr, const int len,
42 enum spi_direction dir) 43 enum spi_direction dir)
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3.h b/drivers/media/i2c/s5c73m3/s5c73m3.h
index 13aed59f0f5d..653f68e7ea07 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3.h
+++ b/drivers/media/i2c/s5c73m3/s5c73m3.h
@@ -23,7 +23,7 @@
23#include <media/v4l2-common.h> 23#include <media/v4l2-common.h>
24#include <media/v4l2-ctrls.h> 24#include <media/v4l2-ctrls.h>
25#include <media/v4l2-subdev.h> 25#include <media/v4l2-subdev.h>
26#include <media/s5c73m3.h> 26#include <media/i2c/s5c73m3.h>
27 27
28#define DRIVER_NAME "S5C73M3" 28#define DRIVER_NAME "S5C73M3"
29 29
diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
index 97084237275d..6757aca2cdab 100644
--- a/drivers/media/i2c/s5k4ecgx.c
+++ b/drivers/media/i2c/s5k4ecgx.c
@@ -27,7 +27,7 @@
27#include <asm/unaligned.h> 27#include <asm/unaligned.h>
28 28
29#include <media/media-entity.h> 29#include <media/media-entity.h>
30#include <media/s5k4ecgx.h> 30#include <media/i2c/s5k4ecgx.h>
31#include <media/v4l2-ctrls.h> 31#include <media/v4l2-ctrls.h>
32#include <media/v4l2-device.h> 32#include <media/v4l2-device.h>
33#include <media/v4l2-mediabus.h> 33#include <media/v4l2-mediabus.h>
diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c
index d0ad6a25bdab..60aaff7190d2 100644
--- a/drivers/media/i2c/s5k6aa.c
+++ b/drivers/media/i2c/s5k6aa.c
@@ -28,7 +28,7 @@
28#include <media/v4l2-device.h> 28#include <media/v4l2-device.h>
29#include <media/v4l2-subdev.h> 29#include <media/v4l2-subdev.h>
30#include <media/v4l2-mediabus.h> 30#include <media/v4l2-mediabus.h>
31#include <media/s5k6aa.h> 31#include <media/i2c/s5k6aa.h>
32 32
33static int debug; 33static int debug;
34module_param(debug, int, 0644); 34module_param(debug, int, 0644);
diff --git a/drivers/media/i2c/saa6588.c b/drivers/media/i2c/saa6588.c
index 37e65f661d7a..89e458c23983 100644
--- a/drivers/media/i2c/saa6588.c
+++ b/drivers/media/i2c/saa6588.c
@@ -31,7 +31,7 @@
31#include <linux/wait.h> 31#include <linux/wait.h>
32#include <asm/uaccess.h> 32#include <asm/uaccess.h>
33 33
34#include <media/saa6588.h> 34#include <media/i2c/saa6588.h>
35#include <media/v4l2-device.h> 35#include <media/v4l2-device.h>
36 36
37 37
diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c
index 91e75222c537..24d2b76dbe97 100644
--- a/drivers/media/i2c/saa7115.c
+++ b/drivers/media/i2c/saa7115.c
@@ -46,7 +46,7 @@
46#include <linux/videodev2.h> 46#include <linux/videodev2.h>
47#include <media/v4l2-device.h> 47#include <media/v4l2-device.h>
48#include <media/v4l2-ctrls.h> 48#include <media/v4l2-ctrls.h>
49#include <media/saa7115.h> 49#include <media/i2c/saa7115.h>
50#include <asm/div64.h> 50#include <asm/div64.h>
51 51
52#define VRES_60HZ (480+16) 52#define VRES_60HZ (480+16)
diff --git a/drivers/media/i2c/saa7127.c b/drivers/media/i2c/saa7127.c
index a43d96da1017..8d94dcbf4366 100644
--- a/drivers/media/i2c/saa7127.c
+++ b/drivers/media/i2c/saa7127.c
@@ -54,7 +54,7 @@
54#include <linux/i2c.h> 54#include <linux/i2c.h>
55#include <linux/videodev2.h> 55#include <linux/videodev2.h>
56#include <media/v4l2-device.h> 56#include <media/v4l2-device.h>
57#include <media/saa7127.h> 57#include <media/i2c/saa7127.h>
58 58
59static int debug; 59static int debug;
60static int test_image; 60static int test_image;
diff --git a/drivers/media/i2c/smiapp/smiapp.h b/drivers/media/i2c/smiapp/smiapp.h
index ed010a8a49d7..f6af0cc4a256 100644
--- a/drivers/media/i2c/smiapp/smiapp.h
+++ b/drivers/media/i2c/smiapp/smiapp.h
@@ -22,7 +22,7 @@
22#include <linux/mutex.h> 22#include <linux/mutex.h>
23#include <media/v4l2-ctrls.h> 23#include <media/v4l2-ctrls.h>
24#include <media/v4l2-subdev.h> 24#include <media/v4l2-subdev.h>
25#include <media/smiapp.h> 25#include <media/i2c/smiapp.h>
26 26
27#include "smiapp-pll.h" 27#include "smiapp-pll.h"
28#include "smiapp-reg.h" 28#include "smiapp-reg.h"
diff --git a/drivers/media/i2c/soc_camera/mt9m001.c b/drivers/media/i2c/soc_camera/mt9m001.c
index 4fbdd1e9f7ee..2e14e52ba2e0 100644
--- a/drivers/media/i2c/soc_camera/mt9m001.c
+++ b/drivers/media/i2c/soc_camera/mt9m001.c
@@ -15,7 +15,7 @@
15#include <linux/module.h> 15#include <linux/module.h>
16 16
17#include <media/soc_camera.h> 17#include <media/soc_camera.h>
18#include <media/soc_mediabus.h> 18#include <media/drv-intf/soc_mediabus.h>
19#include <media/v4l2-clk.h> 19#include <media/v4l2-clk.h>
20#include <media/v4l2-subdev.h> 20#include <media/v4l2-subdev.h>
21#include <media/v4l2-ctrls.h> 21#include <media/v4l2-ctrls.h>
diff --git a/drivers/media/i2c/soc_camera/mt9t112.c b/drivers/media/i2c/soc_camera/mt9t112.c
index 2f35d31ca58e..6a1b2a9f9a09 100644
--- a/drivers/media/i2c/soc_camera/mt9t112.c
+++ b/drivers/media/i2c/soc_camera/mt9t112.c
@@ -25,7 +25,7 @@
25#include <linux/v4l2-mediabus.h> 25#include <linux/v4l2-mediabus.h>
26#include <linux/videodev2.h> 26#include <linux/videodev2.h>
27 27
28#include <media/mt9t112.h> 28#include <media/i2c/mt9t112.h>
29#include <media/soc_camera.h> 29#include <media/soc_camera.h>
30#include <media/v4l2-clk.h> 30#include <media/v4l2-clk.h>
31#include <media/v4l2-common.h> 31#include <media/v4l2-common.h>
diff --git a/drivers/media/i2c/soc_camera/mt9v022.c b/drivers/media/i2c/soc_camera/mt9v022.c
index f31377408550..c2ba1fb3694d 100644
--- a/drivers/media/i2c/soc_camera/mt9v022.c
+++ b/drivers/media/i2c/soc_camera/mt9v022.c
@@ -15,9 +15,9 @@
15#include <linux/log2.h> 15#include <linux/log2.h>
16#include <linux/module.h> 16#include <linux/module.h>
17 17
18#include <media/mt9v022.h> 18#include <media/i2c/mt9v022.h>
19#include <media/soc_camera.h> 19#include <media/soc_camera.h>
20#include <media/soc_mediabus.h> 20#include <media/drv-intf/soc_mediabus.h>
21#include <media/v4l2-subdev.h> 21#include <media/v4l2-subdev.h>
22#include <media/v4l2-clk.h> 22#include <media/v4l2-clk.h>
23#include <media/v4l2-ctrls.h> 23#include <media/v4l2-ctrls.h>
diff --git a/drivers/media/i2c/soc_camera/ov772x.c b/drivers/media/i2c/soc_camera/ov772x.c
index f150a8bd94dc..a43410c1e254 100644
--- a/drivers/media/i2c/soc_camera/ov772x.c
+++ b/drivers/media/i2c/soc_camera/ov772x.c
@@ -24,7 +24,7 @@
24#include <linux/v4l2-mediabus.h> 24#include <linux/v4l2-mediabus.h>
25#include <linux/videodev2.h> 25#include <linux/videodev2.h>
26 26
27#include <media/ov772x.h> 27#include <media/i2c/ov772x.h>
28#include <media/soc_camera.h> 28#include <media/soc_camera.h>
29#include <media/v4l2-clk.h> 29#include <media/v4l2-clk.h>
30#include <media/v4l2-ctrls.h> 30#include <media/v4l2-ctrls.h>
diff --git a/drivers/media/i2c/soc_camera/rj54n1cb0c.c b/drivers/media/i2c/soc_camera/rj54n1cb0c.c
index c769cf663f84..aa7bfbb4ad71 100644
--- a/drivers/media/i2c/soc_camera/rj54n1cb0c.c
+++ b/drivers/media/i2c/soc_camera/rj54n1cb0c.c
@@ -15,7 +15,7 @@
15#include <linux/videodev2.h> 15#include <linux/videodev2.h>
16#include <linux/module.h> 16#include <linux/module.h>
17 17
18#include <media/rj54n1cb0c.h> 18#include <media/i2c/rj54n1cb0c.h>
19#include <media/soc_camera.h> 19#include <media/soc_camera.h>
20#include <media/v4l2-clk.h> 20#include <media/v4l2-clk.h>
21#include <media/v4l2-subdev.h> 21#include <media/v4l2-subdev.h>
diff --git a/drivers/media/i2c/soc_camera/tw9910.c b/drivers/media/i2c/soc_camera/tw9910.c
index e939c24bfd3c..06aff81787a7 100644
--- a/drivers/media/i2c/soc_camera/tw9910.c
+++ b/drivers/media/i2c/soc_camera/tw9910.c
@@ -26,7 +26,7 @@
26#include <linux/videodev2.h> 26#include <linux/videodev2.h>
27 27
28#include <media/soc_camera.h> 28#include <media/soc_camera.h>
29#include <media/tw9910.h> 29#include <media/i2c/tw9910.h>
30#include <media/v4l2-clk.h> 30#include <media/v4l2-clk.h>
31#include <media/v4l2-subdev.h> 31#include <media/v4l2-subdev.h>
32 32
diff --git a/drivers/media/i2c/sr030pc30.c b/drivers/media/i2c/sr030pc30.c
index b04c09dd4bfb..0bf031b7e4fa 100644
--- a/drivers/media/i2c/sr030pc30.c
+++ b/drivers/media/i2c/sr030pc30.c
@@ -24,7 +24,7 @@
24#include <media/v4l2-subdev.h> 24#include <media/v4l2-subdev.h>
25#include <media/v4l2-mediabus.h> 25#include <media/v4l2-mediabus.h>
26#include <media/v4l2-ctrls.h> 26#include <media/v4l2-ctrls.h>
27#include <media/sr030pc30.h> 27#include <media/i2c/sr030pc30.h>
28 28
29static int debug; 29static int debug;
30module_param(debug, int, 0644); 30module_param(debug, int, 0644);
diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index 9ef5baaf8646..77b801152ea5 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -42,7 +42,7 @@
42#include <media/v4l2-ctrls.h> 42#include <media/v4l2-ctrls.h>
43#include <media/v4l2-event.h> 43#include <media/v4l2-event.h>
44#include <media/v4l2-of.h> 44#include <media/v4l2-of.h>
45#include <media/tc358743.h> 45#include <media/i2c/tc358743.h>
46 46
47#include "tc358743_regs.h" 47#include "tc358743_regs.h"
48 48
@@ -862,7 +862,7 @@ static void tc358743_format_change(struct v4l2_subdev *sd)
862 v4l2_dbg(1, debug, sd, "%s: Format changed. No signal\n", 862 v4l2_dbg(1, debug, sd, "%s: Format changed. No signal\n",
863 __func__); 863 __func__);
864 } else { 864 } else {
865 if (!v4l2_match_dv_timings(&state->timings, &timings, 0)) 865 if (!v4l2_match_dv_timings(&state->timings, &timings, 0, false))
866 enable_stream(sd, false); 866 enable_stream(sd, false);
867 867
868 v4l2_print_dv_timings(sd->name, 868 v4l2_print_dv_timings(sd->name,
@@ -1366,7 +1366,7 @@ static int tc358743_s_dv_timings(struct v4l2_subdev *sd,
1366 v4l2_print_dv_timings(sd->name, "tc358743_s_dv_timings: ", 1366 v4l2_print_dv_timings(sd->name, "tc358743_s_dv_timings: ",
1367 timings, false); 1367 timings, false);
1368 1368
1369 if (v4l2_match_dv_timings(&state->timings, timings, 0)) { 1369 if (v4l2_match_dv_timings(&state->timings, timings, 0, false)) {
1370 v4l2_dbg(1, debug, sd, "%s: no change\n", __func__); 1370 v4l2_dbg(1, debug, sd, "%s: no change\n", __func__);
1371 return 0; 1371 return 0;
1372 } 1372 }
diff --git a/drivers/media/i2c/ths7303.c b/drivers/media/i2c/ths7303.c
index bda3a6540a60..5bbfcab01c75 100644
--- a/drivers/media/i2c/ths7303.c
+++ b/drivers/media/i2c/ths7303.c
@@ -25,7 +25,7 @@
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27 27
28#include <media/ths7303.h> 28#include <media/i2c/ths7303.h>
29#include <media/v4l2-device.h> 29#include <media/v4l2-device.h>
30 30
31#define THS7303_CHANNEL_1 1 31#define THS7303_CHANNEL_1 1
diff --git a/drivers/media/i2c/tvaudio.c b/drivers/media/i2c/tvaudio.c
index 2a8114a676fd..fece2a4339a1 100644
--- a/drivers/media/i2c/tvaudio.c
+++ b/drivers/media/i2c/tvaudio.c
@@ -36,7 +36,7 @@
36#include <linux/kthread.h> 36#include <linux/kthread.h>
37#include <linux/freezer.h> 37#include <linux/freezer.h>
38 38
39#include <media/tvaudio.h> 39#include <media/i2c/tvaudio.h>
40#include <media/v4l2-device.h> 40#include <media/v4l2-device.h>
41#include <media/v4l2-ctrls.h> 41#include <media/v4l2-ctrls.h>
42 42
diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
index a93985a9b070..b5dba5b7ce3a 100644
--- a/drivers/media/i2c/tvp514x.c
+++ b/drivers/media/i2c/tvp514x.c
@@ -44,7 +44,7 @@
44#include <media/v4l2-mediabus.h> 44#include <media/v4l2-mediabus.h>
45#include <media/v4l2-of.h> 45#include <media/v4l2-of.h>
46#include <media/v4l2-ctrls.h> 46#include <media/v4l2-ctrls.h>
47#include <media/tvp514x.h> 47#include <media/i2c/tvp514x.h>
48#include <media/media-entity.h> 48#include <media/media-entity.h>
49 49
50#include "tvp514x_regs.h" 50#include "tvp514x_regs.h"
diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 3c5fb2509c47..6c3769d44b75 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -12,7 +12,7 @@
12#include <linux/module.h> 12#include <linux/module.h>
13#include <media/v4l2-async.h> 13#include <media/v4l2-async.h>
14#include <media/v4l2-device.h> 14#include <media/v4l2-device.h>
15#include <media/tvp5150.h> 15#include <media/i2c/tvp5150.h>
16#include <media/v4l2-ctrls.h> 16#include <media/v4l2-ctrls.h>
17 17
18#include "tvp5150_reg.h" 18#include "tvp5150_reg.h"
diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c
index f617d8b745ee..772a3043ae3b 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -32,7 +32,7 @@
32#include <linux/of.h> 32#include <linux/of.h>
33#include <linux/of_graph.h> 33#include <linux/of_graph.h>
34#include <linux/v4l2-dv-timings.h> 34#include <linux/v4l2-dv-timings.h>
35#include <media/tvp7002.h> 35#include <media/i2c/tvp7002.h>
36#include <media/v4l2-async.h> 36#include <media/v4l2-async.h>
37#include <media/v4l2-device.h> 37#include <media/v4l2-device.h>
38#include <media/v4l2-common.h> 38#include <media/v4l2-common.h>
diff --git a/drivers/media/i2c/uda1342.c b/drivers/media/i2c/uda1342.c
index 081786d176d0..8e17a83920d4 100644
--- a/drivers/media/i2c/uda1342.c
+++ b/drivers/media/i2c/uda1342.c
@@ -20,7 +20,7 @@
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/videodev2.h> 21#include <linux/videodev2.h>
22#include <media/v4l2-device.h> 22#include <media/v4l2-device.h>
23#include <media/uda1342.h> 23#include <media/i2c/uda1342.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25 25
26static int write_reg(struct i2c_client *client, int reg, int value) 26static int write_reg(struct i2c_client *client, int reg, int value)
diff --git a/drivers/media/i2c/upd64031a.c b/drivers/media/i2c/upd64031a.c
index 2c0f955abc72..c03567e993cd 100644
--- a/drivers/media/i2c/upd64031a.c
+++ b/drivers/media/i2c/upd64031a.c
@@ -27,7 +27,7 @@
27#include <linux/videodev2.h> 27#include <linux/videodev2.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <media/v4l2-device.h> 29#include <media/v4l2-device.h>
30#include <media/upd64031a.h> 30#include <media/i2c/upd64031a.h>
31 31
32/* --------------------- read registers functions define -------------------- */ 32/* --------------------- read registers functions define -------------------- */
33 33
diff --git a/drivers/media/i2c/upd64083.c b/drivers/media/i2c/upd64083.c
index f2057a434060..77f122f2e3c9 100644
--- a/drivers/media/i2c/upd64083.c
+++ b/drivers/media/i2c/upd64083.c
@@ -27,7 +27,7 @@
27#include <linux/videodev2.h> 27#include <linux/videodev2.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <media/v4l2-device.h> 29#include <media/v4l2-device.h>
30#include <media/upd64083.h> 30#include <media/i2c/upd64083.h>
31 31
32MODULE_DESCRIPTION("uPD64083 driver"); 32MODULE_DESCRIPTION("uPD64083 driver");
33MODULE_AUTHOR("T. Adachi, Takeru KOMORIYA, Hans Verkuil"); 33MODULE_AUTHOR("T. Adachi, Takeru KOMORIYA, Hans Verkuil");
diff --git a/drivers/media/i2c/wm8775.c b/drivers/media/i2c/wm8775.c
index d33d2cd6d034..6e00f145b948 100644
--- a/drivers/media/i2c/wm8775.c
+++ b/drivers/media/i2c/wm8775.c
@@ -34,7 +34,7 @@
34#include <linux/videodev2.h> 34#include <linux/videodev2.h>
35#include <media/v4l2-device.h> 35#include <media/v4l2-device.h>
36#include <media/v4l2-ctrls.h> 36#include <media/v4l2-ctrls.h>
37#include <media/wm8775.h> 37#include <media/i2c/wm8775.h>
38 38
39MODULE_DESCRIPTION("wm8775 driver"); 39MODULE_DESCRIPTION("wm8775 driver");
40MODULE_AUTHOR("Ulf Eklund, Hans Verkuil"); 40MODULE_AUTHOR("Ulf Eklund, Hans Verkuil");
diff --git a/drivers/media/pci/bt8xx/bttv-cards.c b/drivers/media/pci/bt8xx/bttv-cards.c
index 4654fb65ca21..8a17cc0bfa07 100644
--- a/drivers/media/pci/bt8xx/bttv-cards.c
+++ b/drivers/media/pci/bt8xx/bttv-cards.c
@@ -41,7 +41,7 @@
41 41
42#include "bttvp.h" 42#include "bttvp.h"
43#include <media/v4l2-common.h> 43#include <media/v4l2-common.h>
44#include <media/tvaudio.h> 44#include <media/i2c/tvaudio.h>
45#include "bttv-audio-hook.h" 45#include "bttv-audio-hook.h"
46 46
47/* fwd decl */ 47/* fwd decl */
@@ -3808,7 +3808,7 @@ static void bttv_tea575x_set_direction(struct snd_tea575x *tea, bool output)
3808 gpio_inout(mask, (1 << gpio.clk) | (1 << gpio.wren)); 3808 gpio_inout(mask, (1 << gpio.clk) | (1 << gpio.wren));
3809} 3809}
3810 3810
3811static struct snd_tea575x_ops bttv_tea_ops = { 3811static const struct snd_tea575x_ops bttv_tea_ops = {
3812 .set_pins = bttv_tea575x_set_pins, 3812 .set_pins = bttv_tea575x_set_pins,
3813 .get_pins = bttv_tea575x_get_pins, 3813 .get_pins = bttv_tea575x_get_pins,
3814 .set_direction = bttv_tea575x_set_direction, 3814 .set_direction = bttv_tea575x_set_direction,
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 15a4ebc2844d..9400e996087b 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -50,15 +50,15 @@
50#include <media/v4l2-common.h> 50#include <media/v4l2-common.h>
51#include <media/v4l2-ioctl.h> 51#include <media/v4l2-ioctl.h>
52#include <media/v4l2-event.h> 52#include <media/v4l2-event.h>
53#include <media/tvaudio.h> 53#include <media/i2c/tvaudio.h>
54#include <media/msp3400.h> 54#include <media/drv-intf/msp3400.h>
55 55
56#include <linux/dma-mapping.h> 56#include <linux/dma-mapping.h>
57 57
58#include <asm/io.h> 58#include <asm/io.h>
59#include <asm/byteorder.h> 59#include <asm/byteorder.h>
60 60
61#include <media/saa6588.h> 61#include <media/i2c/saa6588.h>
62 62
63#define BTTV_VERSION "0.9.19" 63#define BTTV_VERSION "0.9.19"
64 64
diff --git a/drivers/media/pci/bt8xx/bttvp.h b/drivers/media/pci/bt8xx/bttvp.h
index 31bf79d3b0d2..b1e0023f923c 100644
--- a/drivers/media/pci/bt8xx/bttvp.h
+++ b/drivers/media/pci/bt8xx/bttvp.h
@@ -41,8 +41,8 @@
41#include <media/videobuf-dma-sg.h> 41#include <media/videobuf-dma-sg.h>
42#include <media/tveeprom.h> 42#include <media/tveeprom.h>
43#include <media/rc-core.h> 43#include <media/rc-core.h>
44#include <media/ir-kbd-i2c.h> 44#include <media/i2c/ir-kbd-i2c.h>
45#include <media/tea575x.h> 45#include <media/drv-intf/tea575x.h>
46 46
47#include "bt848.h" 47#include "bt848.h"
48#include "bttv.h" 48#include "bttv.h"
diff --git a/drivers/media/pci/cobalt/cobalt-driver.c b/drivers/media/pci/cobalt/cobalt-driver.c
index 8fed61ec712e..8d6f04fc8013 100644
--- a/drivers/media/pci/cobalt/cobalt-driver.c
+++ b/drivers/media/pci/cobalt/cobalt-driver.c
@@ -21,9 +21,9 @@
21 */ 21 */
22 22
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <media/adv7604.h> 24#include <media/i2c/adv7604.h>
25#include <media/adv7842.h> 25#include <media/i2c/adv7842.h>
26#include <media/adv7511.h> 26#include <media/i2c/adv7511.h>
27#include <media/v4l2-event.h> 27#include <media/v4l2-event.h>
28#include <media/v4l2-ctrls.h> 28#include <media/v4l2-ctrls.h>
29 29
diff --git a/drivers/media/pci/cobalt/cobalt-irq.c b/drivers/media/pci/cobalt/cobalt-irq.c
index 3de26d0714b5..b190d4f81c6e 100644
--- a/drivers/media/pci/cobalt/cobalt-irq.c
+++ b/drivers/media/pci/cobalt/cobalt-irq.c
@@ -18,7 +18,7 @@
18 * SOFTWARE. 18 * SOFTWARE.
19 */ 19 */
20 20
21#include <media/adv7604.h> 21#include <media/i2c/adv7604.h>
22 22
23#include "cobalt-driver.h" 23#include "cobalt-driver.h"
24#include "cobalt-irq.h" 24#include "cobalt-irq.h"
@@ -134,7 +134,7 @@ done:
134 skip = true; 134 skip = true;
135 s->skip_first_frames--; 135 s->skip_first_frames--;
136 } 136 }
137 v4l2_get_timestamp(&cb->vb.timestamp); 137 cb->vb.vb2_buf.timestamp = ktime_get_ns();
138 /* TODO: the sequence number should be read from the FPGA so we 138 /* TODO: the sequence number should be read from the FPGA so we
139 also know about dropped frames. */ 139 also know about dropped frames. */
140 cb->vb.sequence = s->sequence++; 140 cb->vb.sequence = s->sequence++;
diff --git a/drivers/media/pci/cobalt/cobalt-v4l2.c b/drivers/media/pci/cobalt/cobalt-v4l2.c
index ff46e424262f..c0ba458f6cf3 100644
--- a/drivers/media/pci/cobalt/cobalt-v4l2.c
+++ b/drivers/media/pci/cobalt/cobalt-v4l2.c
@@ -29,8 +29,8 @@
29#include <media/v4l2-ctrls.h> 29#include <media/v4l2-ctrls.h>
30#include <media/v4l2-event.h> 30#include <media/v4l2-event.h>
31#include <media/v4l2-dv-timings.h> 31#include <media/v4l2-dv-timings.h>
32#include <media/adv7604.h> 32#include <media/i2c/adv7604.h>
33#include <media/adv7842.h> 33#include <media/i2c/adv7842.h>
34 34
35#include "cobalt-alsa.h" 35#include "cobalt-alsa.h"
36#include "cobalt-cpld.h" 36#include "cobalt-cpld.h"
@@ -43,11 +43,10 @@ static const struct v4l2_dv_timings cea1080p60 = V4L2_DV_BT_CEA_1920X1080P60;
43 43
44/* vb2 DMA streaming ops */ 44/* vb2 DMA streaming ops */
45 45
46static int cobalt_queue_setup(struct vb2_queue *q, const void *parg, 46static int cobalt_queue_setup(struct vb2_queue *q,
47 unsigned int *num_buffers, unsigned int *num_planes, 47 unsigned int *num_buffers, unsigned int *num_planes,
48 unsigned int sizes[], void *alloc_ctxs[]) 48 unsigned int sizes[], void *alloc_ctxs[])
49{ 49{
50 const struct v4l2_format *fmt = parg;
51 struct cobalt_stream *s = q->drv_priv; 50 struct cobalt_stream *s = q->drv_priv;
52 unsigned size = s->stride * s->height; 51 unsigned size = s->stride * s->height;
53 52
@@ -55,14 +54,11 @@ static int cobalt_queue_setup(struct vb2_queue *q, const void *parg,
55 *num_buffers = 3; 54 *num_buffers = 3;
56 if (*num_buffers > NR_BUFS) 55 if (*num_buffers > NR_BUFS)
57 *num_buffers = NR_BUFS; 56 *num_buffers = NR_BUFS;
57 alloc_ctxs[0] = s->cobalt->alloc_ctx;
58 if (*num_planes)
59 return sizes[0] < size ? -EINVAL : 0;
58 *num_planes = 1; 60 *num_planes = 1;
59 if (fmt) {
60 if (fmt->fmt.pix.sizeimage < size)
61 return -EINVAL;
62 size = fmt->fmt.pix.sizeimage;
63 }
64 sizes[0] = size; 61 sizes[0] = size;
65 alloc_ctxs[0] = s->cobalt->alloc_ctx;
66 return 0; 62 return 0;
67} 63}
68 64
@@ -649,7 +645,7 @@ static int cobalt_s_dv_timings(struct file *file, void *priv_fh,
649 return 0; 645 return 0;
650 } 646 }
651 647
652 if (v4l2_match_dv_timings(timings, &s->timings, 0)) 648 if (v4l2_match_dv_timings(timings, &s->timings, 0, false))
653 return 0; 649 return 0;
654 650
655 if (vb2_is_busy(&s->q)) 651 if (vb2_is_busy(&s->q))
diff --git a/drivers/media/pci/cx18/cx18-cards.c b/drivers/media/pci/cx18/cx18-cards.c
index c07c849b1aaf..5e01ea441dc4 100644
--- a/drivers/media/pci/cx18/cx18-cards.c
+++ b/drivers/media/pci/cx18/cx18-cards.c
@@ -26,7 +26,7 @@
26#include "cx18-cards.h" 26#include "cx18-cards.h"
27#include "cx18-av-core.h" 27#include "cx18-av-core.h"
28#include "cx18-i2c.h" 28#include "cx18-i2c.h"
29#include <media/cs5345.h> 29#include <media/i2c/cs5345.h>
30 30
31#define V4L2_STD_PAL_SECAM (V4L2_STD_PAL|V4L2_STD_SECAM) 31#define V4L2_STD_PAL_SECAM (V4L2_STD_PAL|V4L2_STD_SECAM)
32 32
diff --git a/drivers/media/pci/cx18/cx18-controls.c b/drivers/media/pci/cx18/cx18-controls.c
index 71227a155cba..adb5a8c72c06 100644
--- a/drivers/media/pci/cx18/cx18-controls.c
+++ b/drivers/media/pci/cx18/cx18-controls.c
@@ -126,7 +126,7 @@ static int cx18_s_audio_mode(struct cx2341x_handler *cxhdl, u32 val)
126 return 0; 126 return 0;
127} 127}
128 128
129struct cx2341x_handler_ops cx18_cxhdl_ops = { 129const struct cx2341x_handler_ops cx18_cxhdl_ops = {
130 .s_audio_mode = cx18_s_audio_mode, 130 .s_audio_mode = cx18_s_audio_mode,
131 .s_audio_sampling_freq = cx18_s_audio_sampling_freq, 131 .s_audio_sampling_freq = cx18_s_audio_sampling_freq,
132 .s_video_encoding = cx18_s_video_encoding, 132 .s_video_encoding = cx18_s_video_encoding,
diff --git a/drivers/media/pci/cx18/cx18-controls.h b/drivers/media/pci/cx18/cx18-controls.h
index cb5dfc7b2054..326794887863 100644
--- a/drivers/media/pci/cx18/cx18-controls.h
+++ b/drivers/media/pci/cx18/cx18-controls.h
@@ -21,4 +21,4 @@
21 * 02111-1307 USA 21 * 02111-1307 USA
22 */ 22 */
23 23
24extern struct cx2341x_handler_ops cx18_cxhdl_ops; 24extern const struct cx2341x_handler_ops cx18_cxhdl_ops;
diff --git a/drivers/media/pci/cx18/cx18-driver.h b/drivers/media/pci/cx18/cx18-driver.h
index b15beed2dc14..7e31f2a2e085 100644
--- a/drivers/media/pci/cx18/cx18-driver.h
+++ b/drivers/media/pci/cx18/cx18-driver.h
@@ -49,7 +49,7 @@
49#include <media/v4l2-device.h> 49#include <media/v4l2-device.h>
50#include <media/v4l2-fh.h> 50#include <media/v4l2-fh.h>
51#include <media/tuner.h> 51#include <media/tuner.h>
52#include <media/ir-kbd-i2c.h> 52#include <media/i2c/ir-kbd-i2c.h>
53#include "cx18-mailbox.h" 53#include "cx18-mailbox.h"
54#include "cx18-av-core.h" 54#include "cx18-av-core.h"
55#include "cx23418.h" 55#include "cx23418.h"
diff --git a/drivers/media/pci/cx18/cx18-ioctl.c b/drivers/media/pci/cx18/cx18-ioctl.c
index 55525af1f482..eeb741c7db1b 100644
--- a/drivers/media/pci/cx18/cx18-ioctl.c
+++ b/drivers/media/pci/cx18/cx18-ioctl.c
@@ -453,8 +453,8 @@ static int cx18_cropcap(struct file *file, void *fh,
453 453
454 if (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 454 if (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
455 return -EINVAL; 455 return -EINVAL;
456 cropcap->pixelaspect.numerator = cx->is_50hz ? 59 : 10; 456 cropcap->pixelaspect.numerator = cx->is_50hz ? 54 : 11;
457 cropcap->pixelaspect.denominator = cx->is_50hz ? 54 : 11; 457 cropcap->pixelaspect.denominator = cx->is_50hz ? 59 : 10;
458 return 0; 458 return 0;
459} 459}
460 460
diff --git a/drivers/media/pci/cx18/cx23418.h b/drivers/media/pci/cx18/cx23418.h
index 767a8d23e3f2..67ffe65b56a3 100644
--- a/drivers/media/pci/cx18/cx23418.h
+++ b/drivers/media/pci/cx18/cx23418.h
@@ -22,7 +22,7 @@
22#ifndef CX23418_H 22#ifndef CX23418_H
23#define CX23418_H 23#define CX23418_H
24 24
25#include <media/cx2341x.h> 25#include <media/drv-intf/cx2341x.h>
26 26
27#define MGR_CMD_MASK 0x40000000 27#define MGR_CMD_MASK 0x40000000
28/* The MSB of the command code indicates that this is the completion of a 28/* The MSB of the command code indicates that this is the completion of a
diff --git a/drivers/media/pci/cx23885/Kconfig b/drivers/media/pci/cx23885/Kconfig
index 2e1b88ccdbf2..3435bbaa3167 100644
--- a/drivers/media/pci/cx23885/Kconfig
+++ b/drivers/media/pci/cx23885/Kconfig
@@ -10,6 +10,7 @@ config VIDEO_CX23885
10 select VIDEOBUF2_DMA_SG 10 select VIDEOBUF2_DMA_SG
11 select VIDEO_CX25840 11 select VIDEO_CX25840
12 select VIDEO_CX2341X 12 select VIDEO_CX2341X
13 select VIDEO_CS3308
13 select DVB_DIB7000P if MEDIA_SUBDRV_AUTOSELECT 14 select DVB_DIB7000P if MEDIA_SUBDRV_AUTOSELECT
14 select DVB_DRXK if MEDIA_SUBDRV_AUTOSELECT 15 select DVB_DRXK if MEDIA_SUBDRV_AUTOSELECT
15 select DVB_S5H1409 if MEDIA_SUBDRV_AUTOSELECT 16 select DVB_S5H1409 if MEDIA_SUBDRV_AUTOSELECT
diff --git a/drivers/media/pci/cx23885/cx23885-417.c b/drivers/media/pci/cx23885/cx23885-417.c
index 88a3afb66d10..bd333875a1f7 100644
--- a/drivers/media/pci/cx23885/cx23885-417.c
+++ b/drivers/media/pci/cx23885/cx23885-417.c
@@ -30,7 +30,7 @@
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <media/v4l2-common.h> 31#include <media/v4l2-common.h>
32#include <media/v4l2-ioctl.h> 32#include <media/v4l2-ioctl.h>
33#include <media/cx2341x.h> 33#include <media/drv-intf/cx2341x.h>
34 34
35#include "cx23885.h" 35#include "cx23885.h"
36#include "cx23885-ioctl.h" 36#include "cx23885-ioctl.h"
@@ -1138,7 +1138,7 @@ static int cx23885_initialize_codec(struct cx23885_dev *dev, int startencoder)
1138 1138
1139/* ------------------------------------------------------------------ */ 1139/* ------------------------------------------------------------------ */
1140 1140
1141static int queue_setup(struct vb2_queue *q, const void *parg, 1141static int queue_setup(struct vb2_queue *q,
1142 unsigned int *num_buffers, unsigned int *num_planes, 1142 unsigned int *num_buffers, unsigned int *num_planes,
1143 unsigned int sizes[], void *alloc_ctxs[]) 1143 unsigned int sizes[], void *alloc_ctxs[])
1144{ 1144{
diff --git a/drivers/media/pci/cx23885/cx23885-cards.c b/drivers/media/pci/cx23885/cx23885-cards.c
index f384f295676e..310ee769aed4 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -19,7 +19,7 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/pci.h> 20#include <linux/pci.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <media/cx25840.h> 22#include <media/drv-intf/cx25840.h>
23#include <linux/firmware.h> 23#include <linux/firmware.h>
24#include <misc/altera.h> 24#include <misc/altera.h>
25 25
@@ -715,6 +715,56 @@ struct cx23885_board cx23885_boards[] = {
715 .portb = CX23885_MPEG_DVB, 715 .portb = CX23885_MPEG_DVB,
716 .portc = CX23885_MPEG_DVB, 716 .portc = CX23885_MPEG_DVB,
717 }, 717 },
718 [CX23885_BOARD_VIEWCAST_260E] = {
719 .name = "ViewCast 260e",
720 .porta = CX23885_ANALOG_VIDEO,
721 .force_bff = 1,
722 .input = {{
723 .type = CX23885_VMUX_COMPOSITE1,
724 .vmux = CX25840_VIN6_CH1,
725 .amux = CX25840_AUDIO7,
726 }, {
727 .type = CX23885_VMUX_SVIDEO,
728 .vmux = CX25840_VIN7_CH3 |
729 CX25840_VIN5_CH1 |
730 CX25840_SVIDEO_ON,
731 .amux = CX25840_AUDIO7,
732 }, {
733 .type = CX23885_VMUX_COMPONENT,
734 .vmux = CX25840_VIN7_CH3 |
735 CX25840_VIN6_CH2 |
736 CX25840_VIN5_CH1 |
737 CX25840_COMPONENT_ON,
738 .amux = CX25840_AUDIO7,
739 } },
740 },
741 [CX23885_BOARD_VIEWCAST_460E] = {
742 .name = "ViewCast 460e",
743 .porta = CX23885_ANALOG_VIDEO,
744 .force_bff = 1,
745 .input = {{
746 .type = CX23885_VMUX_COMPOSITE1,
747 .vmux = CX25840_VIN4_CH1,
748 .amux = CX25840_AUDIO7,
749 }, {
750 .type = CX23885_VMUX_SVIDEO,
751 .vmux = CX25840_VIN7_CH3 |
752 CX25840_VIN6_CH1 |
753 CX25840_SVIDEO_ON,
754 .amux = CX25840_AUDIO7,
755 }, {
756 .type = CX23885_VMUX_COMPONENT,
757 .vmux = CX25840_VIN7_CH3 |
758 CX25840_VIN6_CH1 |
759 CX25840_VIN5_CH2 |
760 CX25840_COMPONENT_ON,
761 .amux = CX25840_AUDIO7,
762 }, {
763 .type = CX23885_VMUX_COMPOSITE2,
764 .vmux = CX25840_VIN6_CH1,
765 .amux = CX25840_AUDIO7,
766 } },
767 },
718}; 768};
719const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards); 769const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
720 770
@@ -1002,6 +1052,14 @@ struct cx23885_subid cx23885_subids[] = {
1002 .subvendor = 0x0070, 1052 .subvendor = 0x0070,
1003 .subdevice = 0xf038, 1053 .subdevice = 0xf038,
1004 .card = CX23885_BOARD_HAUPPAUGE_HVR5525, 1054 .card = CX23885_BOARD_HAUPPAUGE_HVR5525,
1055 }, {
1056 .subvendor = 0x1576,
1057 .subdevice = 0x0260,
1058 .card = CX23885_BOARD_VIEWCAST_260E,
1059 }, {
1060 .subvendor = 0x1576,
1061 .subdevice = 0x0460,
1062 .card = CX23885_BOARD_VIEWCAST_460E,
1005 }, 1063 },
1006}; 1064};
1007const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids); 1065const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
@@ -1034,6 +1092,28 @@ void cx23885_card_list(struct cx23885_dev *dev)
1034 dev->name, i, cx23885_boards[i].name); 1092 dev->name, i, cx23885_boards[i].name);
1035} 1093}
1036 1094
1095static void viewcast_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
1096{
1097 u32 sn;
1098
1099 /* The serial number record begins with tag 0x59 */
1100 if (*(eeprom_data + 0x00) != 0x59) {
1101 pr_info("%s() eeprom records are undefined, no serial number\n",
1102 __func__);
1103 return;
1104 }
1105
1106 sn = (*(eeprom_data + 0x06) << 24) |
1107 (*(eeprom_data + 0x05) << 16) |
1108 (*(eeprom_data + 0x04) << 8) |
1109 (*(eeprom_data + 0x03));
1110
1111 pr_info("%s: card '%s' sn# MM%d\n",
1112 dev->name,
1113 cx23885_boards[dev->board].name,
1114 sn);
1115}
1116
1037static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data) 1117static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
1038{ 1118{
1039 struct tveeprom tv; 1119 struct tveeprom tv;
@@ -1671,6 +1751,12 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
1671 cx23885_gpio_set(dev, GPIO_8 | GPIO_9); 1751 cx23885_gpio_set(dev, GPIO_8 | GPIO_9);
1672 msleep(100); 1752 msleep(100);
1673 break; 1753 break;
1754 case CX23885_BOARD_VIEWCAST_260E:
1755 case CX23885_BOARD_VIEWCAST_460E:
1756 /* For documentation purposes, it's worth noting that this
1757 * card does not have any GPIO's connected to subcomponents.
1758 */
1759 break;
1674 } 1760 }
1675} 1761}
1676 1762
@@ -1917,6 +2003,14 @@ void cx23885_card_setup(struct cx23885_dev *dev)
1917 if (dev->i2c_bus[0].i2c_rc == 0) 2003 if (dev->i2c_bus[0].i2c_rc == 0)
1918 hauppauge_eeprom(dev, eeprom+0xc0); 2004 hauppauge_eeprom(dev, eeprom+0xc0);
1919 break; 2005 break;
2006 case CX23885_BOARD_VIEWCAST_260E:
2007 case CX23885_BOARD_VIEWCAST_460E:
2008 dev->i2c_bus[1].i2c_client.addr = 0xa0 >> 1;
2009 tveeprom_read(&dev->i2c_bus[1].i2c_client,
2010 eeprom, sizeof(eeprom));
2011 if (dev->i2c_bus[0].i2c_rc == 0)
2012 viewcast_eeprom(dev, eeprom);
2013 break;
1920 } 2014 }
1921 2015
1922 switch (dev->board) { 2016 switch (dev->board) {
@@ -2120,6 +2214,8 @@ void cx23885_card_setup(struct cx23885_dev *dev)
2120 case CX23885_BOARD_DVBSKY_S950: 2214 case CX23885_BOARD_DVBSKY_S950:
2121 case CX23885_BOARD_DVBSKY_S952: 2215 case CX23885_BOARD_DVBSKY_S952:
2122 case CX23885_BOARD_DVBSKY_T982: 2216 case CX23885_BOARD_DVBSKY_T982:
2217 case CX23885_BOARD_VIEWCAST_260E:
2218 case CX23885_BOARD_VIEWCAST_460E:
2123 dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev, 2219 dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
2124 &dev->i2c_bus[2].i2c_adap, 2220 &dev->i2c_bus[2].i2c_adap,
2125 "cx25840", 0x88 >> 1, NULL); 2221 "cx25840", 0x88 >> 1, NULL);
@@ -2130,6 +2226,24 @@ void cx23885_card_setup(struct cx23885_dev *dev)
2130 break; 2226 break;
2131 } 2227 }
2132 2228
2229 switch (dev->board) {
2230 case CX23885_BOARD_VIEWCAST_260E:
2231 v4l2_i2c_new_subdev(&dev->v4l2_dev,
2232 &dev->i2c_bus[0].i2c_adap,
2233 "cs3308", 0x82 >> 1, NULL);
2234 break;
2235 case CX23885_BOARD_VIEWCAST_460E:
2236 /* This cs3308 controls the audio from the breakout cable */
2237 v4l2_i2c_new_subdev(&dev->v4l2_dev,
2238 &dev->i2c_bus[0].i2c_adap,
2239 "cs3308", 0x80 >> 1, NULL);
2240 /* This cs3308 controls the audio from the onboard header */
2241 v4l2_i2c_new_subdev(&dev->v4l2_dev,
2242 &dev->i2c_bus[0].i2c_adap,
2243 "cs3308", 0x82 >> 1, NULL);
2244 break;
2245 }
2246
2133 /* AUX-PLL 27MHz CLK */ 2247 /* AUX-PLL 27MHz CLK */
2134 switch (dev->board) { 2248 switch (dev->board) {
2135 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: 2249 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
diff --git a/drivers/media/pci/cx23885/cx23885-core.c b/drivers/media/pci/cx23885/cx23885-core.c
index e8f847226a19..813c217b5e1a 100644
--- a/drivers/media/pci/cx23885/cx23885-core.c
+++ b/drivers/media/pci/cx23885/cx23885-core.c
@@ -427,7 +427,7 @@ static void cx23885_wakeup(struct cx23885_tsport *port,
427 buf = list_entry(q->active.next, 427 buf = list_entry(q->active.next,
428 struct cx23885_buffer, queue); 428 struct cx23885_buffer, queue);
429 429
430 v4l2_get_timestamp(&buf->vb.timestamp); 430 buf->vb.vb2_buf.timestamp = ktime_get_ns();
431 buf->vb.sequence = q->count++; 431 buf->vb.sequence = q->count++;
432 dprintk(1, "[%p/%d] wakeup reg=%d buf=%d\n", buf, 432 dprintk(1, "[%p/%d] wakeup reg=%d buf=%d\n", buf,
433 buf->vb.vb2_buf.index, 433 buf->vb.vb2_buf.index,
@@ -968,6 +968,16 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
968 call_all(dev, core, s_power, 0); 968 call_all(dev, core, s_power, 0);
969 cx23885_ir_init(dev); 969 cx23885_ir_init(dev);
970 970
971 if (dev->board == CX23885_BOARD_VIEWCAST_460E) {
972 /*
973 * GPIOs 9/8 are input detection bits for the breakout video
974 * (gpio 8) and audio (gpio 9) cables. When they're attached,
975 * this gpios are pulled high. Make sure these GPIOs are marked
976 * as inputs.
977 */
978 cx23885_gpio_enable(dev, 0x300, 0);
979 }
980
971 if (cx23885_boards[dev->board].porta == CX23885_ANALOG_VIDEO) { 981 if (cx23885_boards[dev->board].porta == CX23885_ANALOG_VIDEO) {
972 if (cx23885_video_register(dev) < 0) { 982 if (cx23885_video_register(dev) < 0) {
973 printk(KERN_ERR "%s() Failed to register analog " 983 printk(KERN_ERR "%s() Failed to register analog "
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
index c4307ad8594c..80319bb73d94 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -92,7 +92,7 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
92 92
93/* ------------------------------------------------------------------ */ 93/* ------------------------------------------------------------------ */
94 94
95static int queue_setup(struct vb2_queue *q, const void *parg, 95static int queue_setup(struct vb2_queue *q,
96 unsigned int *num_buffers, unsigned int *num_planes, 96 unsigned int *num_buffers, unsigned int *num_planes,
97 unsigned int sizes[], void *alloc_ctxs[]) 97 unsigned int sizes[], void *alloc_ctxs[])
98{ 98{
@@ -2168,11 +2168,12 @@ static int dvb_register(struct cx23885_tsport *port)
2168 } 2168 }
2169 port->i2c_client_tuner = client_tuner; 2169 port->i2c_client_tuner = client_tuner;
2170 break; 2170 break;
2171 case CX23885_BOARD_HAUPPAUGE_HVR5525: 2171 case CX23885_BOARD_HAUPPAUGE_HVR5525: {
2172 switch (port->nr) {
2173 struct m88rs6000t_config m88rs6000t_config; 2172 struct m88rs6000t_config m88rs6000t_config;
2174 struct a8293_platform_data a8293_pdata = {}; 2173 struct a8293_platform_data a8293_pdata = {};
2175 2174
2175 switch (port->nr) {
2176
2176 /* port b - satellite */ 2177 /* port b - satellite */
2177 case 1: 2178 case 1:
2178 /* attach frontend */ 2179 /* attach frontend */
@@ -2267,6 +2268,7 @@ static int dvb_register(struct cx23885_tsport *port)
2267 break; 2268 break;
2268 } 2269 }
2269 break; 2270 break;
2271 }
2270 default: 2272 default:
2271 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card " 2273 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card "
2272 " isn't supported yet\n", 2274 " isn't supported yet\n",
diff --git a/drivers/media/pci/cx23885/cx23885-i2c.c b/drivers/media/pci/cx23885/cx23885-i2c.c
index 1135ea3f6ce5..ae061b358591 100644
--- a/drivers/media/pci/cx23885/cx23885-i2c.c
+++ b/drivers/media/pci/cx23885/cx23885-i2c.c
@@ -279,6 +279,8 @@ static char *i2c_devs[128] = {
279 [0x10 >> 1] = "tda10048", 279 [0x10 >> 1] = "tda10048",
280 [0x12 >> 1] = "dib7000pc", 280 [0x12 >> 1] = "dib7000pc",
281 [0x1c >> 1] = "lgdt3303", 281 [0x1c >> 1] = "lgdt3303",
282 [0x80 >> 1] = "cs3308",
283 [0x82 >> 1] = "cs3308",
282 [0x86 >> 1] = "tda9887", 284 [0x86 >> 1] = "tda9887",
283 [0x32 >> 1] = "cx24227", 285 [0x32 >> 1] = "cx24227",
284 [0x88 >> 1] = "cx25837", 286 [0x88 >> 1] = "cx25837",
diff --git a/drivers/media/pci/cx23885/cx23885-input.c b/drivers/media/pci/cx23885/cx23885-input.c
index 088799c3b49b..64328d08ac2f 100644
--- a/drivers/media/pci/cx23885/cx23885-input.c
+++ b/drivers/media/pci/cx23885/cx23885-input.c
@@ -268,7 +268,7 @@ int cx23885_input_init(struct cx23885_dev *dev)
268 struct rc_dev *rc; 268 struct rc_dev *rc;
269 char *rc_map; 269 char *rc_map;
270 enum rc_driver_type driver_type; 270 enum rc_driver_type driver_type;
271 unsigned long allowed_protos; 271 u64 allowed_protos;
272 272
273 int ret; 273 int ret;
274 274
diff --git a/drivers/media/pci/cx23885/cx23885-vbi.c b/drivers/media/pci/cx23885/cx23885-vbi.c
index cf3cb1324c55..39750ebcc04c 100644
--- a/drivers/media/pci/cx23885/cx23885-vbi.c
+++ b/drivers/media/pci/cx23885/cx23885-vbi.c
@@ -83,7 +83,7 @@ int cx23885_vbi_irq(struct cx23885_dev *dev, u32 status)
83 if (status & VID_BC_MSK_VBI_RISCI1) { 83 if (status & VID_BC_MSK_VBI_RISCI1) {
84 dprintk(1, "%s() VID_BC_MSK_VBI_RISCI1\n", __func__); 84 dprintk(1, "%s() VID_BC_MSK_VBI_RISCI1\n", __func__);
85 spin_lock(&dev->slock); 85 spin_lock(&dev->slock);
86 count = cx_read(VID_A_GPCNT); 86 count = cx_read(VBI_A_GPCNT);
87 cx23885_video_wakeup(dev, &dev->vbiq, count); 87 cx23885_video_wakeup(dev, &dev->vbiq, count);
88 spin_unlock(&dev->slock); 88 spin_unlock(&dev->slock);
89 handled++; 89 handled++;
@@ -103,7 +103,6 @@ static int cx23885_start_vbi_dma(struct cx23885_dev *dev,
103 VBI_LINE_LENGTH, buf->risc.dma); 103 VBI_LINE_LENGTH, buf->risc.dma);
104 104
105 /* reset counter */ 105 /* reset counter */
106 cx_write(VID_A_GPCNT_CTL, 3);
107 cx_write(VID_A_VBI_CTRL, 3); 106 cx_write(VID_A_VBI_CTRL, 3);
108 cx_write(VBI_A_GPCNT_CTL, 3); 107 cx_write(VBI_A_GPCNT_CTL, 3);
109 q->count = 0; 108 q->count = 0;
@@ -121,7 +120,7 @@ static int cx23885_start_vbi_dma(struct cx23885_dev *dev,
121 120
122/* ------------------------------------------------------------------ */ 121/* ------------------------------------------------------------------ */
123 122
124static int queue_setup(struct vb2_queue *q, const void *parg, 123static int queue_setup(struct vb2_queue *q,
125 unsigned int *num_buffers, unsigned int *num_planes, 124 unsigned int *num_buffers, unsigned int *num_planes,
126 unsigned int sizes[], void *alloc_ctxs[]) 125 unsigned int sizes[], void *alloc_ctxs[])
127{ 126{
diff --git a/drivers/media/pci/cx23885/cx23885-video.c b/drivers/media/pci/cx23885/cx23885-video.c
index 71a80e2b842c..e1d7d0847167 100644
--- a/drivers/media/pci/cx23885/cx23885-video.c
+++ b/drivers/media/pci/cx23885/cx23885-video.c
@@ -35,7 +35,7 @@
35#include "cx23885-ioctl.h" 35#include "cx23885-ioctl.h"
36#include "tuner-xc2028.h" 36#include "tuner-xc2028.h"
37 37
38#include <media/cx25840.h> 38#include <media/drv-intf/cx25840.h>
39 39
40MODULE_DESCRIPTION("v4l2 driver module for cx23885 based TV cards"); 40MODULE_DESCRIPTION("v4l2 driver module for cx23885 based TV cards");
41MODULE_AUTHOR("Steven Toth <stoth@linuxtv.org>"); 41MODULE_AUTHOR("Steven Toth <stoth@linuxtv.org>");
@@ -105,7 +105,7 @@ void cx23885_video_wakeup(struct cx23885_dev *dev,
105 struct cx23885_buffer, queue); 105 struct cx23885_buffer, queue);
106 106
107 buf->vb.sequence = q->count++; 107 buf->vb.sequence = q->count++;
108 v4l2_get_timestamp(&buf->vb.timestamp); 108 buf->vb.vb2_buf.timestamp = ktime_get_ns();
109 dprintk(2, "[%p/%d] wakeup reg=%d buf=%d\n", buf, 109 dprintk(2, "[%p/%d] wakeup reg=%d buf=%d\n", buf,
110 buf->vb.vb2_buf.index, count, q->count); 110 buf->vb.vb2_buf.index, count, q->count);
111 list_del(&buf->queue); 111 list_del(&buf->queue);
@@ -114,11 +114,19 @@ void cx23885_video_wakeup(struct cx23885_dev *dev,
114 114
115int cx23885_set_tvnorm(struct cx23885_dev *dev, v4l2_std_id norm) 115int cx23885_set_tvnorm(struct cx23885_dev *dev, v4l2_std_id norm)
116{ 116{
117 struct v4l2_subdev_format format = {
118 .which = V4L2_SUBDEV_FORMAT_ACTIVE,
119 .format.code = MEDIA_BUS_FMT_FIXED,
120 };
121
117 dprintk(1, "%s(norm = 0x%08x) name: [%s]\n", 122 dprintk(1, "%s(norm = 0x%08x) name: [%s]\n",
118 __func__, 123 __func__,
119 (unsigned int)norm, 124 (unsigned int)norm,
120 v4l2_norm_to_name(norm)); 125 v4l2_norm_to_name(norm));
121 126
127 if (dev->tvnorm == norm)
128 return 0;
129
122 if (dev->tvnorm != norm) { 130 if (dev->tvnorm != norm) {
123 if (vb2_is_busy(&dev->vb2_vidq) || vb2_is_busy(&dev->vb2_vbiq) || 131 if (vb2_is_busy(&dev->vb2_vidq) || vb2_is_busy(&dev->vb2_vbiq) ||
124 vb2_is_busy(&dev->vb2_mpegq)) 132 vb2_is_busy(&dev->vb2_mpegq))
@@ -126,9 +134,17 @@ int cx23885_set_tvnorm(struct cx23885_dev *dev, v4l2_std_id norm)
126 } 134 }
127 135
128 dev->tvnorm = norm; 136 dev->tvnorm = norm;
137 dev->width = 720;
138 dev->height = norm_maxh(norm);
139 dev->field = V4L2_FIELD_INTERLACED;
129 140
130 call_all(dev, video, s_std, norm); 141 call_all(dev, video, s_std, norm);
131 142
143 format.format.width = dev->width;
144 format.format.height = dev->height;
145 format.format.field = dev->field;
146 call_all(dev, pad, set_fmt, NULL, &format);
147
132 return 0; 148 return 0;
133} 149}
134 150
@@ -247,7 +263,9 @@ static int cx23885_video_mux(struct cx23885_dev *dev, unsigned int input)
247 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1255_22111) || 263 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1255_22111) ||
248 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1850) || 264 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1850) ||
249 (dev->board == CX23885_BOARD_MYGICA_X8507) || 265 (dev->board == CX23885_BOARD_MYGICA_X8507) ||
250 (dev->board == CX23885_BOARD_AVERMEDIA_HC81R)) { 266 (dev->board == CX23885_BOARD_AVERMEDIA_HC81R) ||
267 (dev->board == CX23885_BOARD_VIEWCAST_260E) ||
268 (dev->board == CX23885_BOARD_VIEWCAST_460E)) {
251 /* Configure audio routing */ 269 /* Configure audio routing */
252 v4l2_subdev_call(dev->sd_cx25840, audio, s_routing, 270 v4l2_subdev_call(dev->sd_cx25840, audio, s_routing,
253 INPUT(input)->amux, 0, 0); 271 INPUT(input)->amux, 0, 0);
@@ -315,7 +333,7 @@ static int cx23885_start_video_dma(struct cx23885_dev *dev,
315 return 0; 333 return 0;
316} 334}
317 335
318static int queue_setup(struct vb2_queue *q, const void *parg, 336static int queue_setup(struct vb2_queue *q,
319 unsigned int *num_buffers, unsigned int *num_planes, 337 unsigned int *num_buffers, unsigned int *num_planes,
320 unsigned int sizes[], void *alloc_ctxs[]) 338 unsigned int sizes[], void *alloc_ctxs[])
321{ 339{
@@ -545,7 +563,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
545 return -EINVAL; 563 return -EINVAL;
546 564
547 field = f->fmt.pix.field; 565 field = f->fmt.pix.field;
548 maxw = norm_maxw(dev->tvnorm); 566 maxw = 720;
549 maxh = norm_maxh(dev->tvnorm); 567 maxh = norm_maxh(dev->tvnorm);
550 568
551 if (V4L2_FIELD_ANY == field) { 569 if (V4L2_FIELD_ANY == field) {
@@ -648,6 +666,26 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
648 return 0; 666 return 0;
649} 667}
650 668
669static int vidioc_cropcap(struct file *file, void *priv,
670 struct v4l2_cropcap *cc)
671{
672 struct cx23885_dev *dev = video_drvdata(file);
673 bool is_50hz = dev->tvnorm & V4L2_STD_625_50;
674
675 if (cc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
676 return -EINVAL;
677
678 cc->bounds.left = 0;
679 cc->bounds.top = 0;
680 cc->bounds.width = 720;
681 cc->bounds.height = norm_maxh(dev->tvnorm);
682 cc->defrect = cc->bounds;
683 cc->pixelaspect.numerator = is_50hz ? 54 : 11;
684 cc->pixelaspect.denominator = is_50hz ? 59 : 10;
685
686 return 0;
687}
688
651static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *id) 689static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *id)
652{ 690{
653 struct cx23885_dev *dev = video_drvdata(file); 691 struct cx23885_dev *dev = video_drvdata(file);
@@ -1082,6 +1120,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
1082 .vidioc_dqbuf = vb2_ioctl_dqbuf, 1120 .vidioc_dqbuf = vb2_ioctl_dqbuf,
1083 .vidioc_streamon = vb2_ioctl_streamon, 1121 .vidioc_streamon = vb2_ioctl_streamon,
1084 .vidioc_streamoff = vb2_ioctl_streamoff, 1122 .vidioc_streamoff = vb2_ioctl_streamoff,
1123 .vidioc_cropcap = vidioc_cropcap,
1085 .vidioc_s_std = vidioc_s_std, 1124 .vidioc_s_std = vidioc_s_std,
1086 .vidioc_g_std = vidioc_g_std, 1125 .vidioc_g_std = vidioc_g_std,
1087 .vidioc_enum_input = vidioc_enum_input, 1126 .vidioc_enum_input = vidioc_enum_input,
diff --git a/drivers/media/pci/cx23885/cx23885.h b/drivers/media/pci/cx23885/cx23885.h
index c5ba0833f47a..b1a5409408c7 100644
--- a/drivers/media/pci/cx23885/cx23885.h
+++ b/drivers/media/pci/cx23885/cx23885.h
@@ -30,7 +30,7 @@
30#include <media/rc-core.h> 30#include <media/rc-core.h>
31 31
32#include "cx23885-reg.h" 32#include "cx23885-reg.h"
33#include "media/cx2341x.h" 33#include "media/drv-intf/cx2341x.h"
34 34
35#include <linux/mutex.h> 35#include <linux/mutex.h>
36 36
@@ -101,6 +101,8 @@
101#define CX23885_BOARD_DVBSKY_T982 51 101#define CX23885_BOARD_DVBSKY_T982 51
102#define CX23885_BOARD_HAUPPAUGE_HVR5525 52 102#define CX23885_BOARD_HAUPPAUGE_HVR5525 52
103#define CX23885_BOARD_HAUPPAUGE_STARBURST 53 103#define CX23885_BOARD_HAUPPAUGE_STARBURST 53
104#define CX23885_BOARD_VIEWCAST_260E 54
105#define CX23885_BOARD_VIEWCAST_460E 55
104 106
105#define GPIO_0 0x00000001 107#define GPIO_0 0x00000001
106#define GPIO_1 0x00000002 108#define GPIO_1 0x00000002
@@ -627,11 +629,6 @@ extern int cx23885_risc_databuffer(struct pci_dev *pci,
627/* ----------------------------------------------------------- */ 629/* ----------------------------------------------------------- */
628/* tv norms */ 630/* tv norms */
629 631
630static inline unsigned int norm_maxw(v4l2_std_id norm)
631{
632 return (norm & V4L2_STD_525_60) ? 720 : 768;
633}
634
635static inline unsigned int norm_maxh(v4l2_std_id norm) 632static inline unsigned int norm_maxh(v4l2_std_id norm)
636{ 633{
637 return (norm & V4L2_STD_525_60) ? 480 : 576; 634 return (norm & V4L2_STD_525_60) ? 480 : 576;
diff --git a/drivers/media/pci/cx25821/cx25821-video.c b/drivers/media/pci/cx25821/cx25821-video.c
index 26e3e296d615..c48bba9daf1f 100644
--- a/drivers/media/pci/cx25821/cx25821-video.c
+++ b/drivers/media/pci/cx25821/cx25821-video.c
@@ -130,7 +130,7 @@ int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status)
130 buf = list_entry(dmaq->active.next, 130 buf = list_entry(dmaq->active.next,
131 struct cx25821_buffer, queue); 131 struct cx25821_buffer, queue);
132 132
133 v4l2_get_timestamp(&buf->vb.timestamp); 133 buf->vb.vb2_buf.timestamp = ktime_get_ns();
134 buf->vb.sequence = dmaq->count++; 134 buf->vb.sequence = dmaq->count++;
135 list_del(&buf->queue); 135 list_del(&buf->queue);
136 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); 136 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
@@ -141,20 +141,20 @@ int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status)
141 return handled; 141 return handled;
142} 142}
143 143
144static int cx25821_queue_setup(struct vb2_queue *q, const void *parg, 144static int cx25821_queue_setup(struct vb2_queue *q,
145 unsigned int *num_buffers, unsigned int *num_planes, 145 unsigned int *num_buffers, unsigned int *num_planes,
146 unsigned int sizes[], void *alloc_ctxs[]) 146 unsigned int sizes[], void *alloc_ctxs[])
147{ 147{
148 const struct v4l2_format *fmt = parg;
149 struct cx25821_channel *chan = q->drv_priv; 148 struct cx25821_channel *chan = q->drv_priv;
150 unsigned size = (chan->fmt->depth * chan->width * chan->height) >> 3; 149 unsigned size = (chan->fmt->depth * chan->width * chan->height) >> 3;
151 150
152 if (fmt && fmt->fmt.pix.sizeimage < size) 151 alloc_ctxs[0] = chan->dev->alloc_ctx;
153 return -EINVAL; 152
153 if (*num_planes)
154 return sizes[0] < size ? -EINVAL : 0;
154 155
155 *num_planes = 1; 156 *num_planes = 1;
156 sizes[0] = fmt ? fmt->fmt.pix.sizeimage : size; 157 sizes[0] = size;
157 alloc_ctxs[0] = chan->dev->alloc_ctx;
158 return 0; 158 return 0;
159} 159}
160 160
diff --git a/drivers/media/pci/cx88/cx88-alsa.c b/drivers/media/pci/cx88/cx88-alsa.c
index 1b5268f9bb24..e158a1da1d41 100644
--- a/drivers/media/pci/cx88/cx88-alsa.c
+++ b/drivers/media/pci/cx88/cx88-alsa.c
@@ -40,7 +40,7 @@
40#include <sound/control.h> 40#include <sound/control.h>
41#include <sound/initval.h> 41#include <sound/initval.h>
42#include <sound/tlv.h> 42#include <sound/tlv.h>
43#include <media/wm8775.h> 43#include <media/i2c/wm8775.h>
44 44
45#include "cx88.h" 45#include "cx88.h"
46#include "cx88-reg.h" 46#include "cx88-reg.h"
diff --git a/drivers/media/pci/cx88/cx88-blackbird.c b/drivers/media/pci/cx88/cx88-blackbird.c
index 8b889135be8a..3233d45d1e5b 100644
--- a/drivers/media/pci/cx88/cx88-blackbird.c
+++ b/drivers/media/pci/cx88/cx88-blackbird.c
@@ -36,7 +36,7 @@
36#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
37#include <media/v4l2-ioctl.h> 37#include <media/v4l2-ioctl.h>
38#include <media/v4l2-event.h> 38#include <media/v4l2-event.h>
39#include <media/cx2341x.h> 39#include <media/drv-intf/cx2341x.h>
40 40
41#include "cx88.h" 41#include "cx88.h"
42 42
@@ -637,7 +637,7 @@ static int blackbird_stop_codec(struct cx8802_dev *dev)
637 637
638/* ------------------------------------------------------------------ */ 638/* ------------------------------------------------------------------ */
639 639
640static int queue_setup(struct vb2_queue *q, const void *parg, 640static int queue_setup(struct vb2_queue *q,
641 unsigned int *num_buffers, unsigned int *num_planes, 641 unsigned int *num_buffers, unsigned int *num_planes,
642 unsigned int sizes[], void *alloc_ctxs[]) 642 unsigned int sizes[], void *alloc_ctxs[])
643{ 643{
diff --git a/drivers/media/pci/cx88/cx88-core.c b/drivers/media/pci/cx88/cx88-core.c
index 9a43c7826b60..46fe8c1eb9d4 100644
--- a/drivers/media/pci/cx88/cx88-core.c
+++ b/drivers/media/pci/cx88/cx88-core.c
@@ -518,7 +518,7 @@ void cx88_wakeup(struct cx88_core *core,
518 518
519 buf = list_entry(q->active.next, 519 buf = list_entry(q->active.next,
520 struct cx88_buffer, list); 520 struct cx88_buffer, list);
521 v4l2_get_timestamp(&buf->vb.timestamp); 521 buf->vb.vb2_buf.timestamp = ktime_get_ns();
522 buf->vb.field = core->field; 522 buf->vb.field = core->field;
523 buf->vb.sequence = q->count++; 523 buf->vb.sequence = q->count++;
524 list_del(&buf->list); 524 list_del(&buf->list);
diff --git a/drivers/media/pci/cx88/cx88-dvb.c b/drivers/media/pci/cx88/cx88-dvb.c
index f04835073844..afb20756d7a5 100644
--- a/drivers/media/pci/cx88/cx88-dvb.c
+++ b/drivers/media/pci/cx88/cx88-dvb.c
@@ -82,7 +82,7 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
82 82
83/* ------------------------------------------------------------------ */ 83/* ------------------------------------------------------------------ */
84 84
85static int queue_setup(struct vb2_queue *q, const void *parg, 85static int queue_setup(struct vb2_queue *q,
86 unsigned int *num_buffers, unsigned int *num_planes, 86 unsigned int *num_buffers, unsigned int *num_planes,
87 unsigned int sizes[], void *alloc_ctxs[]) 87 unsigned int sizes[], void *alloc_ctxs[])
88{ 88{
diff --git a/drivers/media/pci/cx88/cx88-vbi.c b/drivers/media/pci/cx88/cx88-vbi.c
index 007a5eee8e5e..ccc646d819f2 100644
--- a/drivers/media/pci/cx88/cx88-vbi.c
+++ b/drivers/media/pci/cx88/cx88-vbi.c
@@ -107,7 +107,7 @@ int cx8800_restart_vbi_queue(struct cx8800_dev *dev,
107 107
108/* ------------------------------------------------------------------ */ 108/* ------------------------------------------------------------------ */
109 109
110static int queue_setup(struct vb2_queue *q, const void *parg, 110static int queue_setup(struct vb2_queue *q,
111 unsigned int *num_buffers, unsigned int *num_planes, 111 unsigned int *num_buffers, unsigned int *num_planes,
112 unsigned int sizes[], void *alloc_ctxs[]) 112 unsigned int sizes[], void *alloc_ctxs[])
113{ 113{
diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
index aef9acf351f6..5f331df65fb9 100644
--- a/drivers/media/pci/cx88/cx88-video.c
+++ b/drivers/media/pci/cx88/cx88-video.c
@@ -41,7 +41,7 @@
41#include <media/v4l2-common.h> 41#include <media/v4l2-common.h>
42#include <media/v4l2-ioctl.h> 42#include <media/v4l2-ioctl.h>
43#include <media/v4l2-event.h> 43#include <media/v4l2-event.h>
44#include <media/wm8775.h> 44#include <media/i2c/wm8775.h>
45 45
46MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards"); 46MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards");
47MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); 47MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
@@ -429,7 +429,7 @@ static int restart_video_queue(struct cx8800_dev *dev,
429 429
430/* ------------------------------------------------------------------ */ 430/* ------------------------------------------------------------------ */
431 431
432static int queue_setup(struct vb2_queue *q, const void *parg, 432static int queue_setup(struct vb2_queue *q,
433 unsigned int *num_buffers, unsigned int *num_planes, 433 unsigned int *num_buffers, unsigned int *num_planes,
434 unsigned int sizes[], void *alloc_ctxs[]) 434 unsigned int sizes[], void *alloc_ctxs[])
435{ 435{
diff --git a/drivers/media/pci/cx88/cx88.h b/drivers/media/pci/cx88/cx88.h
index 2996eb3ea1fc..78f817ee7e41 100644
--- a/drivers/media/pci/cx88/cx88.h
+++ b/drivers/media/pci/cx88/cx88.h
@@ -30,10 +30,10 @@
30#include <media/tuner.h> 30#include <media/tuner.h>
31#include <media/tveeprom.h> 31#include <media/tveeprom.h>
32#include <media/videobuf2-dma-sg.h> 32#include <media/videobuf2-dma-sg.h>
33#include <media/cx2341x.h> 33#include <media/drv-intf/cx2341x.h>
34#include <media/videobuf2-dvb.h> 34#include <media/videobuf2-dvb.h>
35#include <media/ir-kbd-i2c.h> 35#include <media/i2c/ir-kbd-i2c.h>
36#include <media/wm8775.h> 36#include <media/i2c/wm8775.h>
37 37
38#include "cx88-reg.h" 38#include "cx88-reg.h"
39#include "tuner-xc2028.h" 39#include "tuner-xc2028.h"
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c
index 0ac2dd35fe50..fba5b40a869c 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -81,13 +81,13 @@ static int i2c_read_reg16(struct i2c_adapter *adapter, u8 adr,
81static int ddb_i2c_cmd(struct ddb_i2c *i2c, u32 adr, u32 cmd) 81static int ddb_i2c_cmd(struct ddb_i2c *i2c, u32 adr, u32 cmd)
82{ 82{
83 struct ddb *dev = i2c->dev; 83 struct ddb *dev = i2c->dev;
84 int stat; 84 long stat;
85 u32 val; 85 u32 val;
86 86
87 i2c->done = 0; 87 i2c->done = 0;
88 ddbwritel((adr << 9) | cmd, i2c->regs + I2C_COMMAND); 88 ddbwritel((adr << 9) | cmd, i2c->regs + I2C_COMMAND);
89 stat = wait_event_timeout(i2c->wq, i2c->done == 1, HZ); 89 stat = wait_event_timeout(i2c->wq, i2c->done == 1, HZ);
90 if (stat <= 0) { 90 if (stat == 0) {
91 printk(KERN_ERR "I2C timeout\n"); 91 printk(KERN_ERR "I2C timeout\n");
92 { /* MSI debugging*/ 92 { /* MSI debugging*/
93 u32 istat = ddbreadl(INTERRUPT_STATUS); 93 u32 istat = ddbreadl(INTERRUPT_STATUS);
diff --git a/drivers/media/pci/dm1105/dm1105.c b/drivers/media/pci/dm1105/dm1105.c
index 88915fb87e80..5dd504741b12 100644
--- a/drivers/media/pci/dm1105/dm1105.c
+++ b/drivers/media/pci/dm1105/dm1105.c
@@ -1206,7 +1206,6 @@ static void dm1105_remove(struct pci_dev *pdev)
1206 i2c_del_adapter(&dev->i2c_adap); 1206 i2c_del_adapter(&dev->i2c_adap);
1207 1207
1208 dm1105_hw_exit(dev); 1208 dm1105_hw_exit(dev);
1209 synchronize_irq(pdev->irq);
1210 free_irq(pdev->irq, dev); 1209 free_irq(pdev->irq, dev);
1211 pci_iounmap(pdev, dev->io_mem); 1210 pci_iounmap(pdev, dev->io_mem);
1212 pci_release_regions(pdev); 1211 pci_release_regions(pdev);
diff --git a/drivers/media/pci/dt3155/dt3155.c b/drivers/media/pci/dt3155/dt3155.c
index d84abde5ea29..568c0c8fb2dc 100644
--- a/drivers/media/pci/dt3155/dt3155.c
+++ b/drivers/media/pci/dt3155/dt3155.c
@@ -131,22 +131,21 @@ static int wait_i2c_reg(void __iomem *addr)
131} 131}
132 132
133static int 133static int
134dt3155_queue_setup(struct vb2_queue *vq, const void *parg, 134dt3155_queue_setup(struct vb2_queue *vq,
135 unsigned int *nbuffers, unsigned int *num_planes, 135 unsigned int *nbuffers, unsigned int *num_planes,
136 unsigned int sizes[], void *alloc_ctxs[]) 136 unsigned int sizes[], void *alloc_ctxs[])
137 137
138{ 138{
139 const struct v4l2_format *fmt = parg;
140 struct dt3155_priv *pd = vb2_get_drv_priv(vq); 139 struct dt3155_priv *pd = vb2_get_drv_priv(vq);
141 unsigned size = pd->width * pd->height; 140 unsigned size = pd->width * pd->height;
142 141
143 if (vq->num_buffers + *nbuffers < 2) 142 if (vq->num_buffers + *nbuffers < 2)
144 *nbuffers = 2 - vq->num_buffers; 143 *nbuffers = 2 - vq->num_buffers;
145 if (fmt && fmt->fmt.pix.sizeimage < size)
146 return -EINVAL;
147 *num_planes = 1;
148 sizes[0] = fmt ? fmt->fmt.pix.sizeimage : size;
149 alloc_ctxs[0] = pd->alloc_ctx; 144 alloc_ctxs[0] = pd->alloc_ctx;
145 if (*num_planes)
146 return sizes[0] < size ? -EINVAL : 0;
147 *num_planes = 1;
148 sizes[0] = size;
150 return 0; 149 return 0;
151} 150}
152 151
@@ -271,7 +270,7 @@ static irqreturn_t dt3155_irq_handler_even(int irq, void *dev_id)
271 270
272 spin_lock(&ipd->lock); 271 spin_lock(&ipd->lock);
273 if (ipd->curr_buf && !list_empty(&ipd->dmaq)) { 272 if (ipd->curr_buf && !list_empty(&ipd->dmaq)) {
274 v4l2_get_timestamp(&ipd->curr_buf->timestamp); 273 ipd->curr_buf->vb2_buf.timestamp = ktime_get_ns();
275 ipd->curr_buf->sequence = ipd->sequence++; 274 ipd->curr_buf->sequence = ipd->sequence++;
276 ipd->curr_buf->field = V4L2_FIELD_NONE; 275 ipd->curr_buf->field = V4L2_FIELD_NONE;
277 vb2_buffer_done(&ipd->curr_buf->vb2_buf, VB2_BUF_STATE_DONE); 276 vb2_buffer_done(&ipd->curr_buf->vb2_buf, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/pci/ivtv/ivtv-cards.c b/drivers/media/pci/ivtv/ivtv-cards.c
index 145e4749a69d..410d97bdf541 100644
--- a/drivers/media/pci/ivtv/ivtv-cards.c
+++ b/drivers/media/pci/ivtv/ivtv-cards.c
@@ -22,12 +22,12 @@
22#include "ivtv-cards.h" 22#include "ivtv-cards.h"
23#include "ivtv-i2c.h" 23#include "ivtv-i2c.h"
24 24
25#include <media/msp3400.h> 25#include <media/drv-intf/msp3400.h>
26#include <media/m52790.h> 26#include <media/i2c/m52790.h>
27#include <media/wm8775.h> 27#include <media/i2c/wm8775.h>
28#include <media/cs53l32a.h> 28#include <media/i2c/cs53l32a.h>
29#include <media/cx25840.h> 29#include <media/drv-intf/cx25840.h>
30#include <media/upd64031a.h> 30#include <media/i2c/upd64031a.h>
31 31
32#define MSP_TUNER MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1, \ 32#define MSP_TUNER MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1, \
33 MSP_DSP_IN_TUNER, MSP_DSP_IN_TUNER) 33 MSP_DSP_IN_TUNER, MSP_DSP_IN_TUNER)
diff --git a/drivers/media/pci/ivtv/ivtv-controls.c b/drivers/media/pci/ivtv/ivtv-controls.c
index 8a55ccb8f0c9..9666ca01549c 100644
--- a/drivers/media/pci/ivtv/ivtv-controls.c
+++ b/drivers/media/pci/ivtv/ivtv-controls.c
@@ -96,7 +96,7 @@ static int ivtv_s_audio_mode(struct cx2341x_handler *cxhdl, u32 val)
96 return 0; 96 return 0;
97} 97}
98 98
99struct cx2341x_handler_ops ivtv_cxhdl_ops = { 99const struct cx2341x_handler_ops ivtv_cxhdl_ops = {
100 .s_audio_mode = ivtv_s_audio_mode, 100 .s_audio_mode = ivtv_s_audio_mode,
101 .s_audio_sampling_freq = ivtv_s_audio_sampling_freq, 101 .s_audio_sampling_freq = ivtv_s_audio_sampling_freq,
102 .s_video_encoding = ivtv_s_video_encoding, 102 .s_video_encoding = ivtv_s_video_encoding,
diff --git a/drivers/media/pci/ivtv/ivtv-controls.h b/drivers/media/pci/ivtv/ivtv-controls.h
index 3999e6358312..ea397ba837e3 100644
--- a/drivers/media/pci/ivtv/ivtv-controls.h
+++ b/drivers/media/pci/ivtv/ivtv-controls.h
@@ -21,7 +21,7 @@
21#ifndef IVTV_CONTROLS_H 21#ifndef IVTV_CONTROLS_H
22#define IVTV_CONTROLS_H 22#define IVTV_CONTROLS_H
23 23
24extern struct cx2341x_handler_ops ivtv_cxhdl_ops; 24extern const struct cx2341x_handler_ops ivtv_cxhdl_ops;
25extern const struct v4l2_ctrl_ops ivtv_hdl_out_ops; 25extern const struct v4l2_ctrl_ops ivtv_hdl_out_ops;
26int ivtv_g_pts_frame(struct ivtv *itv, s64 *pts, s64 *frame); 26int ivtv_g_pts_frame(struct ivtv *itv, s64 *pts, s64 *frame);
27 27
diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
index c2e60b4f292d..374033a5bdaf 100644
--- a/drivers/media/pci/ivtv/ivtv-driver.c
+++ b/drivers/media/pci/ivtv/ivtv-driver.c
@@ -57,7 +57,7 @@
57#include "ivtv-gpio.h" 57#include "ivtv-gpio.h"
58#include <linux/dma-mapping.h> 58#include <linux/dma-mapping.h>
59#include <media/tveeprom.h> 59#include <media/tveeprom.h>
60#include <media/saa7115.h> 60#include <media/i2c/saa7115.h>
61#include "tuner-xc2028.h" 61#include "tuner-xc2028.h"
62 62
63/* If you have already X v4l cards, then set this to X. This way 63/* If you have already X v4l cards, then set this to X. This way
@@ -826,7 +826,7 @@ static void ivtv_init_struct2(struct ivtv *itv)
826 IVTV_CARD_INPUT_VID_TUNER) 826 IVTV_CARD_INPUT_VID_TUNER)
827 break; 827 break;
828 } 828 }
829 if (i == itv->nof_inputs) 829 if (i >= itv->nof_inputs)
830 i = 0; 830 i = 0;
831 itv->active_input = i; 831 itv->active_input = i;
832 itv->audio_input = itv->card->video_inputs[i].audio_index; 832 itv->audio_input = itv->card->video_inputs[i].audio_index;
diff --git a/drivers/media/pci/ivtv/ivtv-driver.h b/drivers/media/pci/ivtv/ivtv-driver.h
index ee0ef6e48c7d..6c08dae67a73 100644
--- a/drivers/media/pci/ivtv/ivtv-driver.h
+++ b/drivers/media/pci/ivtv/ivtv-driver.h
@@ -64,8 +64,8 @@
64#include <media/v4l2-device.h> 64#include <media/v4l2-device.h>
65#include <media/v4l2-fh.h> 65#include <media/v4l2-fh.h>
66#include <media/tuner.h> 66#include <media/tuner.h>
67#include <media/cx2341x.h> 67#include <media/drv-intf/cx2341x.h>
68#include <media/ir-kbd-i2c.h> 68#include <media/i2c/ir-kbd-i2c.h>
69 69
70#include <linux/ivtv.h> 70#include <linux/ivtv.h>
71 71
diff --git a/drivers/media/pci/ivtv/ivtv-fileops.c b/drivers/media/pci/ivtv/ivtv-fileops.c
index 605d280d8a5f..c9bd018e53de 100644
--- a/drivers/media/pci/ivtv/ivtv-fileops.c
+++ b/drivers/media/pci/ivtv/ivtv-fileops.c
@@ -34,7 +34,7 @@
34#include "ivtv-cards.h" 34#include "ivtv-cards.h"
35#include "ivtv-firmware.h" 35#include "ivtv-firmware.h"
36#include <media/v4l2-event.h> 36#include <media/v4l2-event.h>
37#include <media/saa7115.h> 37#include <media/i2c/saa7115.h>
38 38
39/* This function tries to claim the stream for a specific file descriptor. 39/* This function tries to claim the stream for a specific file descriptor.
40 If no one else is using this stream then the stream is claimed and 40 If no one else is using this stream then the stream is claimed and
diff --git a/drivers/media/pci/ivtv/ivtv-firmware.c b/drivers/media/pci/ivtv/ivtv-firmware.c
index 4b0e758a7bce..5b3095f65dce 100644
--- a/drivers/media/pci/ivtv/ivtv-firmware.c
+++ b/drivers/media/pci/ivtv/ivtv-firmware.c
@@ -26,7 +26,7 @@
26#include "ivtv-ioctl.h" 26#include "ivtv-ioctl.h"
27#include "ivtv-cards.h" 27#include "ivtv-cards.h"
28#include <linux/firmware.h> 28#include <linux/firmware.h>
29#include <media/saa7127.h> 29#include <media/i2c/saa7127.h>
30 30
31#define IVTV_MASK_SPU_ENABLE 0xFFFFFFFE 31#define IVTV_MASK_SPU_ENABLE 0xFFFFFFFE
32#define IVTV_MASK_VPU_ENABLE15 0xFFFFFFF6 32#define IVTV_MASK_VPU_ENABLE15 0xFFFFFFF6
diff --git a/drivers/media/pci/ivtv/ivtv-i2c.c b/drivers/media/pci/ivtv/ivtv-i2c.c
index 1a41ba5c7d30..bccbf2d18e30 100644
--- a/drivers/media/pci/ivtv/ivtv-i2c.c
+++ b/drivers/media/pci/ivtv/ivtv-i2c.c
@@ -63,7 +63,7 @@
63#include "ivtv-cards.h" 63#include "ivtv-cards.h"
64#include "ivtv-gpio.h" 64#include "ivtv-gpio.h"
65#include "ivtv-i2c.h" 65#include "ivtv-i2c.h"
66#include <media/cx25840.h> 66#include <media/drv-intf/cx25840.h>
67 67
68/* i2c implementation for cx23415/6 chip, ivtv project. 68/* i2c implementation for cx23415/6 chip, ivtv project.
69 * Author: Kevin Thayer (nufan_wfk at yahoo.com) 69 * Author: Kevin Thayer (nufan_wfk at yahoo.com)
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c b/drivers/media/pci/ivtv/ivtv-ioctl.c
index 9a21c17fc376..2dc4b20f3ac0 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -32,7 +32,7 @@
32#include "ivtv-gpio.h" 32#include "ivtv-gpio.h"
33#include "ivtv-controls.h" 33#include "ivtv-controls.h"
34#include "ivtv-cards.h" 34#include "ivtv-cards.h"
35#include <media/saa7127.h> 35#include <media/i2c/saa7127.h>
36#include <media/tveeprom.h> 36#include <media/tveeprom.h>
37#include <media/v4l2-event.h> 37#include <media/v4l2-event.h>
38#include <linux/dvb/audio.h> 38#include <linux/dvb/audio.h>
@@ -831,11 +831,11 @@ static int ivtv_cropcap(struct file *file, void *fh, struct v4l2_cropcap *cropca
831 struct ivtv *itv = id->itv; 831 struct ivtv *itv = id->itv;
832 832
833 if (cropcap->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { 833 if (cropcap->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
834 cropcap->pixelaspect.numerator = itv->is_50hz ? 59 : 10; 834 cropcap->pixelaspect.numerator = itv->is_50hz ? 54 : 11;
835 cropcap->pixelaspect.denominator = itv->is_50hz ? 54 : 11; 835 cropcap->pixelaspect.denominator = itv->is_50hz ? 59 : 10;
836 } else if (cropcap->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { 836 } else if (cropcap->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
837 cropcap->pixelaspect.numerator = itv->is_out_50hz ? 59 : 10; 837 cropcap->pixelaspect.numerator = itv->is_out_50hz ? 54 : 11;
838 cropcap->pixelaspect.denominator = itv->is_out_50hz ? 54 : 11; 838 cropcap->pixelaspect.denominator = itv->is_out_50hz ? 59 : 10;
839 } else { 839 } else {
840 return -EINVAL; 840 return -EINVAL;
841 } 841 }
diff --git a/drivers/media/pci/ivtv/ivtv-routing.c b/drivers/media/pci/ivtv/ivtv-routing.c
index 8898c569a1c9..0c168f238904 100644
--- a/drivers/media/pci/ivtv/ivtv-routing.c
+++ b/drivers/media/pci/ivtv/ivtv-routing.c
@@ -24,10 +24,10 @@
24#include "ivtv-gpio.h" 24#include "ivtv-gpio.h"
25#include "ivtv-routing.h" 25#include "ivtv-routing.h"
26 26
27#include <media/msp3400.h> 27#include <media/drv-intf/msp3400.h>
28#include <media/m52790.h> 28#include <media/i2c/m52790.h>
29#include <media/upd64031a.h> 29#include <media/i2c/upd64031a.h>
30#include <media/upd64083.h> 30#include <media/i2c/upd64083.h>
31 31
32/* Selects the audio input and output according to the current 32/* Selects the audio input and output according to the current
33 settings. */ 33 settings. */
diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
index 3fdbd81b5580..81e1a5e26efb 100644
--- a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
+++ b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
@@ -277,7 +277,6 @@ static irqreturn_t netup_unidvb_isr(int irq, void *dev_id)
277} 277}
278 278
279static int netup_unidvb_queue_setup(struct vb2_queue *vq, 279static int netup_unidvb_queue_setup(struct vb2_queue *vq,
280 const void *parg,
281 unsigned int *nbuffers, 280 unsigned int *nbuffers,
282 unsigned int *nplanes, 281 unsigned int *nplanes,
283 unsigned int sizes[], 282 unsigned int sizes[],
@@ -580,7 +579,7 @@ static void netup_unidvb_dma_worker(struct work_struct *work)
580 dev_dbg(&ndev->pci_dev->dev, 579 dev_dbg(&ndev->pci_dev->dev,
581 "%s(): buffer %p done, size %d\n", 580 "%s(): buffer %p done, size %d\n",
582 __func__, buf, buf->size); 581 __func__, buf, buf->size);
583 v4l2_get_timestamp(&buf->vb.timestamp); 582 buf->vb.vb2_buf.timestamp = ktime_get_ns();
584 vb2_set_plane_payload(&buf->vb.vb2_buf, 0, buf->size); 583 vb2_set_plane_payload(&buf->vb.vb2_buf, 0, buf->size);
585 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); 584 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
586 } 585 }
diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c
index f720cea80e28..e227b02cc122 100644
--- a/drivers/media/pci/saa7134/saa7134-core.c
+++ b/drivers/media/pci/saa7134/saa7134-core.c
@@ -309,7 +309,7 @@ void saa7134_buffer_finish(struct saa7134_dev *dev,
309 core_dbg("buffer_finish %p\n", q->curr); 309 core_dbg("buffer_finish %p\n", q->curr);
310 310
311 /* finish current buffer */ 311 /* finish current buffer */
312 v4l2_get_timestamp(&q->curr->vb2.timestamp); 312 q->curr->vb2.vb2_buf.timestamp = ktime_get_ns();
313 q->curr->vb2.sequence = q->seq_nr++; 313 q->curr->vb2.sequence = q->seq_nr++;
314 vb2_buffer_done(&q->curr->vb2.vb2_buf, state); 314 vb2_buffer_done(&q->curr->vb2.vb2_buf, state);
315 q->curr = NULL; 315 q->curr = NULL;
diff --git a/drivers/media/pci/saa7134/saa7134-ts.c b/drivers/media/pci/saa7134/saa7134-ts.c
index 7fb5ee7e20ac..0584a2adbe99 100644
--- a/drivers/media/pci/saa7134/saa7134-ts.c
+++ b/drivers/media/pci/saa7134/saa7134-ts.c
@@ -116,7 +116,7 @@ int saa7134_ts_buffer_prepare(struct vb2_buffer *vb2)
116} 116}
117EXPORT_SYMBOL_GPL(saa7134_ts_buffer_prepare); 117EXPORT_SYMBOL_GPL(saa7134_ts_buffer_prepare);
118 118
119int saa7134_ts_queue_setup(struct vb2_queue *q, const void *parg, 119int saa7134_ts_queue_setup(struct vb2_queue *q,
120 unsigned int *nbuffers, unsigned int *nplanes, 120 unsigned int *nbuffers, unsigned int *nplanes,
121 unsigned int sizes[], void *alloc_ctxs[]) 121 unsigned int sizes[], void *alloc_ctxs[])
122{ 122{
diff --git a/drivers/media/pci/saa7134/saa7134-vbi.c b/drivers/media/pci/saa7134/saa7134-vbi.c
index 6271b0eb0265..e76da37c4a8a 100644
--- a/drivers/media/pci/saa7134/saa7134-vbi.c
+++ b/drivers/media/pci/saa7134/saa7134-vbi.c
@@ -138,7 +138,7 @@ static int buffer_prepare(struct vb2_buffer *vb2)
138 saa7134_buffer_startpage(buf)); 138 saa7134_buffer_startpage(buf));
139} 139}
140 140
141static int queue_setup(struct vb2_queue *q, const void *parg, 141static int queue_setup(struct vb2_queue *q,
142 unsigned int *nbuffers, unsigned int *nplanes, 142 unsigned int *nbuffers, unsigned int *nplanes,
143 unsigned int sizes[], void *alloc_ctxs[]) 143 unsigned int sizes[], void *alloc_ctxs[])
144{ 144{
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c
index 518086c7aed5..a63c1366a64e 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -32,7 +32,7 @@
32 32
33#include <media/v4l2-common.h> 33#include <media/v4l2-common.h>
34#include <media/v4l2-event.h> 34#include <media/v4l2-event.h>
35#include <media/saa6588.h> 35#include <media/i2c/saa6588.h>
36 36
37/* ------------------------------------------------------------------ */ 37/* ------------------------------------------------------------------ */
38 38
@@ -904,7 +904,7 @@ static int buffer_prepare(struct vb2_buffer *vb2)
904 saa7134_buffer_startpage(buf)); 904 saa7134_buffer_startpage(buf));
905} 905}
906 906
907static int queue_setup(struct vb2_queue *q, const void *parg, 907static int queue_setup(struct vb2_queue *q,
908 unsigned int *nbuffers, unsigned int *nplanes, 908 unsigned int *nbuffers, unsigned int *nplanes,
909 unsigned int sizes[], void *alloc_ctxs[]) 909 unsigned int sizes[], void *alloc_ctxs[])
910{ 910{
diff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h
index 6b6d234f5cab..5938bc781999 100644
--- a/drivers/media/pci/saa7134/saa7134.h
+++ b/drivers/media/pci/saa7134/saa7134.h
@@ -42,7 +42,7 @@
42#include <media/v4l2-ctrls.h> 42#include <media/v4l2-ctrls.h>
43#include <media/tuner.h> 43#include <media/tuner.h>
44#include <media/rc-core.h> 44#include <media/rc-core.h>
45#include <media/ir-kbd-i2c.h> 45#include <media/i2c/ir-kbd-i2c.h>
46#include <media/videobuf2-dma-sg.h> 46#include <media/videobuf2-dma-sg.h>
47#include <sound/core.h> 47#include <sound/core.h>
48#include <sound/pcm.h> 48#include <sound/pcm.h>
@@ -820,7 +820,7 @@ void saa7134_video_fini(struct saa7134_dev *dev);
820 820
821int saa7134_ts_buffer_init(struct vb2_buffer *vb2); 821int saa7134_ts_buffer_init(struct vb2_buffer *vb2);
822int saa7134_ts_buffer_prepare(struct vb2_buffer *vb2); 822int saa7134_ts_buffer_prepare(struct vb2_buffer *vb2);
823int saa7134_ts_queue_setup(struct vb2_queue *q, const void *parg, 823int saa7134_ts_queue_setup(struct vb2_queue *q,
824 unsigned int *nbuffers, unsigned int *nplanes, 824 unsigned int *nbuffers, unsigned int *nplanes,
825 unsigned int sizes[], void *alloc_ctxs[]); 825 unsigned int sizes[], void *alloc_ctxs[]);
826int saa7134_ts_start_streaming(struct vb2_queue *vq, unsigned int count); 826int saa7134_ts_start_streaming(struct vb2_queue *vq, unsigned int count);
diff --git a/drivers/media/pci/saa7146/hexium_gemini.c b/drivers/media/pci/saa7146/hexium_gemini.c
index 03cbcd2095c6..c889ec9f8a5a 100644
--- a/drivers/media/pci/saa7146/hexium_gemini.c
+++ b/drivers/media/pci/saa7146/hexium_gemini.c
@@ -25,7 +25,7 @@
25 25
26#define DEBUG_VARIABLE debug 26#define DEBUG_VARIABLE debug
27 27
28#include <media/saa7146_vv.h> 28#include <media/drv-intf/saa7146_vv.h>
29#include <linux/module.h> 29#include <linux/module.h>
30 30
31static int debug; 31static int debug;
diff --git a/drivers/media/pci/saa7146/hexium_orion.c b/drivers/media/pci/saa7146/hexium_orion.c
index 15f0d66ff78a..c306a92e8909 100644
--- a/drivers/media/pci/saa7146/hexium_orion.c
+++ b/drivers/media/pci/saa7146/hexium_orion.c
@@ -25,7 +25,7 @@
25 25
26#define DEBUG_VARIABLE debug 26#define DEBUG_VARIABLE debug
27 27
28#include <media/saa7146_vv.h> 28#include <media/drv-intf/saa7146_vv.h>
29#include <linux/module.h> 29#include <linux/module.h>
30 30
31static int debug; 31static int debug;
diff --git a/drivers/media/pci/saa7146/mxb.c b/drivers/media/pci/saa7146/mxb.c
index 0ca1e07ae783..504d78807639 100644
--- a/drivers/media/pci/saa7146/mxb.c
+++ b/drivers/media/pci/saa7146/mxb.c
@@ -25,10 +25,10 @@
25 25
26#define DEBUG_VARIABLE debug 26#define DEBUG_VARIABLE debug
27 27
28#include <media/saa7146_vv.h> 28#include <media/drv-intf/saa7146_vv.h>
29#include <media/tuner.h> 29#include <media/tuner.h>
30#include <media/v4l2-common.h> 30#include <media/v4l2-common.h>
31#include <media/saa7115.h> 31#include <media/i2c/saa7115.h>
32#include <linux/module.h> 32#include <linux/module.h>
33 33
34#include "tea6415c.h" 34#include "tea6415c.h"
diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
index 4432fd69b7cb..67a14c41c227 100644
--- a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
+++ b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
@@ -531,8 +531,7 @@ static int solo_enc_fillbuf(struct solo_enc_dev *solo_enc,
531 531
532 if (!ret) { 532 if (!ret) {
533 vbuf->sequence = solo_enc->sequence++; 533 vbuf->sequence = solo_enc->sequence++;
534 vbuf->timestamp.tv_sec = vop_sec(vh); 534 vb->timestamp = ktime_get_ns();
535 vbuf->timestamp.tv_usec = vop_usec(vh);
536 535
537 /* Check for motion flags */ 536 /* Check for motion flags */
538 if (solo_is_motion_on(solo_enc) && enc_buf->motion) { 537 if (solo_is_motion_on(solo_enc) && enc_buf->motion) {
@@ -663,7 +662,6 @@ static int solo_ring_thread(void *data)
663} 662}
664 663
665static int solo_enc_queue_setup(struct vb2_queue *q, 664static int solo_enc_queue_setup(struct vb2_queue *q,
666 const void *parg,
667 unsigned int *num_buffers, 665 unsigned int *num_buffers,
668 unsigned int *num_planes, unsigned int sizes[], 666 unsigned int *num_planes, unsigned int sizes[],
669 void *alloc_ctxs[]) 667 void *alloc_ctxs[])
diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2.c b/drivers/media/pci/solo6x10/solo6x10-v4l2.c
index f7ce493b1fee..721ff5320de7 100644
--- a/drivers/media/pci/solo6x10/solo6x10-v4l2.c
+++ b/drivers/media/pci/solo6x10/solo6x10-v4l2.c
@@ -225,7 +225,7 @@ finish_buf:
225 vb2_set_plane_payload(vb, 0, 225 vb2_set_plane_payload(vb, 0,
226 solo_vlines(solo_dev) * solo_bytesperline(solo_dev)); 226 solo_vlines(solo_dev) * solo_bytesperline(solo_dev));
227 vbuf->sequence = solo_dev->sequence++; 227 vbuf->sequence = solo_dev->sequence++;
228 v4l2_get_timestamp(&vbuf->timestamp); 228 vb->timestamp = ktime_get_ns();
229 } 229 }
230 230
231 vb2_buffer_done(vb, error ? VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE); 231 vb2_buffer_done(vb, error ? VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
@@ -313,7 +313,7 @@ static void solo_stop_thread(struct solo_dev *solo_dev)
313 solo_dev->kthread = NULL; 313 solo_dev->kthread = NULL;
314} 314}
315 315
316static int solo_queue_setup(struct vb2_queue *q, const void *parg, 316static int solo_queue_setup(struct vb2_queue *q,
317 unsigned int *num_buffers, unsigned int *num_planes, 317 unsigned int *num_buffers, unsigned int *num_planes,
318 unsigned int sizes[], void *alloc_ctxs[]) 318 unsigned int sizes[], void *alloc_ctxs[])
319{ 319{
diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c b/drivers/media/pci/sta2x11/sta2x11_vip.c
index 6367b455a7e7..753411cbbc9a 100644
--- a/drivers/media/pci/sta2x11/sta2x11_vip.c
+++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
@@ -265,7 +265,7 @@ static void vip_active_buf_next(struct sta2x11_vip *vip)
265 265
266 266
267/* Videobuf2 Operations */ 267/* Videobuf2 Operations */
268static int queue_setup(struct vb2_queue *vq, const void *parg, 268static int queue_setup(struct vb2_queue *vq,
269 unsigned int *nbuffers, unsigned int *nplanes, 269 unsigned int *nbuffers, unsigned int *nplanes,
270 unsigned int sizes[], void *alloc_ctxs[]) 270 unsigned int sizes[], void *alloc_ctxs[])
271{ 271{
@@ -817,7 +817,7 @@ static irqreturn_t vip_irq(int irq, struct sta2x11_vip *vip)
817 /* Disable acquisition */ 817 /* Disable acquisition */
818 reg_write(vip, DVP_CTL, reg_read(vip, DVP_CTL) & ~DVP_CTL_ENA); 818 reg_write(vip, DVP_CTL, reg_read(vip, DVP_CTL) & ~DVP_CTL_ENA);
819 /* Remove the active buffer from the list */ 819 /* Remove the active buffer from the list */
820 v4l2_get_timestamp(&vip->active->vb.timestamp); 820 vip->active->vb.vb2_buf.timestamp = ktime_get_ns();
821 vip->active->vb.sequence = vip->sequence++; 821 vip->active->vb.sequence = vip->sequence++;
822 vb2_buffer_done(&vip->active->vb.vb2_buf, VB2_BUF_STATE_DONE); 822 vb2_buffer_done(&vip->active->vb.vb2_buf, VB2_BUF_STATE_DONE);
823 } 823 }
diff --git a/drivers/media/pci/ttpci/av7110.c b/drivers/media/pci/ttpci/av7110.c
index f89364951ebd..5e18b6796ed9 100644
--- a/drivers/media/pci/ttpci/av7110.c
+++ b/drivers/media/pci/ttpci/av7110.c
@@ -26,7 +26,7 @@
26 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 26 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
27 * 27 *
28 * 28 *
29 * the project's page is at http://www.linuxtv.org/ 29 * the project's page is at https://linuxtv.org
30 */ 30 */
31 31
32 32
@@ -1537,7 +1537,7 @@ static int get_firmware(struct av7110* av7110)
1537 printk(KERN_ERR "dvb-ttpci: usually this should be in " 1537 printk(KERN_ERR "dvb-ttpci: usually this should be in "
1538 "/usr/lib/hotplug/firmware or /lib/firmware\n"); 1538 "/usr/lib/hotplug/firmware or /lib/firmware\n");
1539 printk(KERN_ERR "dvb-ttpci: and can be downloaded from" 1539 printk(KERN_ERR "dvb-ttpci: and can be downloaded from"
1540 " http://www.linuxtv.org/download/dvb/firmware/\n"); 1540 " https://linuxtv.org/download/dvb/firmware/\n");
1541 } else 1541 } else
1542 printk(KERN_ERR "dvb-ttpci: cannot request firmware" 1542 printk(KERN_ERR "dvb-ttpci: cannot request firmware"
1543 " (error %i)\n", ret); 1543 " (error %i)\n", ret);
@@ -2314,7 +2314,7 @@ static int frontend_init(struct av7110 *av7110)
2314/* Budgetpatch note: 2314/* Budgetpatch note:
2315 * Original hardware design by Roberto Deza: 2315 * Original hardware design by Roberto Deza:
2316 * There is a DVB_Wiki at 2316 * There is a DVB_Wiki at
2317 * http://www.linuxtv.org/ 2317 * https://linuxtv.org
2318 * 2318 *
2319 * New software triggering design by Emard that works on 2319 * New software triggering design by Emard that works on
2320 * original Roberto Deza's hardware: 2320 * original Roberto Deza's hardware:
diff --git a/drivers/media/pci/ttpci/av7110.h b/drivers/media/pci/ttpci/av7110.h
index 3a55927edb95..3707ccd02732 100644
--- a/drivers/media/pci/ttpci/av7110.h
+++ b/drivers/media/pci/ttpci/av7110.h
@@ -32,7 +32,7 @@
32#include "stv0297.h" 32#include "stv0297.h"
33#include "l64781.h" 33#include "l64781.h"
34 34
35#include <media/saa7146_vv.h> 35#include <media/drv-intf/saa7146_vv.h>
36 36
37 37
38#define ANALOG_TUNER_VES1820 1 38#define ANALOG_TUNER_VES1820 1
diff --git a/drivers/media/pci/ttpci/av7110_av.c b/drivers/media/pci/ttpci/av7110_av.c
index 9ed1ec7d3551..6fc748e22017 100644
--- a/drivers/media/pci/ttpci/av7110_av.c
+++ b/drivers/media/pci/ttpci/av7110_av.c
@@ -25,7 +25,7 @@
25 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 25 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
26 * 26 *
27 * 27 *
28 * the project's page is at http://www.linuxtv.org/ 28 * the project's page is at https://linuxtv.org
29 */ 29 */
30 30
31#include <linux/types.h> 31#include <linux/types.h>
@@ -280,9 +280,11 @@ int av7110_pes_play(void *dest, struct dvb_ringbuffer *buf, int dlen)
280} 280}
281 281
282 282
283int av7110_set_volume(struct av7110 *av7110, int volleft, int volright) 283int av7110_set_volume(struct av7110 *av7110, unsigned int volleft,
284 unsigned int volright)
284{ 285{
285 int err, vol, val, balance = 0; 286 unsigned int vol, val, balance = 0;
287 int err;
286 288
287 dprintk(2, "av7110:%p, \n", av7110); 289 dprintk(2, "av7110:%p, \n", av7110);
288 290
@@ -1043,6 +1045,9 @@ static int play_iframe(struct av7110 *av7110, char __user *buf, unsigned int len
1043 1045
1044 dprintk(2, "av7110:%p, \n", av7110); 1046 dprintk(2, "av7110:%p, \n", av7110);
1045 1047
1048 if (len == 0)
1049 return 0;
1050
1046 if (!(av7110->playing & RP_VIDEO)) { 1051 if (!(av7110->playing & RP_VIDEO)) {
1047 if (av7110_av_start_play(av7110, RP_VIDEO) < 0) 1052 if (av7110_av_start_play(av7110, RP_VIDEO) < 0)
1048 return -EBUSY; 1053 return -EBUSY;
diff --git a/drivers/media/pci/ttpci/av7110_av.h b/drivers/media/pci/ttpci/av7110_av.h
index 5f02ef85e47d..f52276f47709 100644
--- a/drivers/media/pci/ttpci/av7110_av.h
+++ b/drivers/media/pci/ttpci/av7110_av.h
@@ -10,7 +10,8 @@ extern int av7110_record_cb(struct dvb_filter_pes2ts *p2t, u8 *buf, size_t len);
10extern int av7110_pes_play(void *dest, struct dvb_ringbuffer *buf, int dlen); 10extern int av7110_pes_play(void *dest, struct dvb_ringbuffer *buf, int dlen);
11extern int av7110_write_to_decoder(struct dvb_demux_feed *feed, const u8 *buf, size_t len); 11extern int av7110_write_to_decoder(struct dvb_demux_feed *feed, const u8 *buf, size_t len);
12 12
13extern int av7110_set_volume(struct av7110 *av7110, int volleft, int volright); 13extern int av7110_set_volume(struct av7110 *av7110, unsigned int volleft,
14 unsigned int volright);
14extern int av7110_av_stop(struct av7110 *av7110, int av); 15extern int av7110_av_stop(struct av7110 *av7110, int av);
15extern int av7110_av_start_record(struct av7110 *av7110, int av, 16extern int av7110_av_start_record(struct av7110 *av7110, int av,
16 struct dvb_demux_feed *dvbdmxfeed); 17 struct dvb_demux_feed *dvbdmxfeed);
diff --git a/drivers/media/pci/ttpci/av7110_ca.c b/drivers/media/pci/ttpci/av7110_ca.c
index a6079b90252a..bc4c65ffd4b9 100644
--- a/drivers/media/pci/ttpci/av7110_ca.c
+++ b/drivers/media/pci/ttpci/av7110_ca.c
@@ -25,7 +25,7 @@
25 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 25 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
26 * 26 *
27 * 27 *
28 * the project's page is at http://www.linuxtv.org/ 28 * the project's page is at https://linuxtv.org
29 */ 29 */
30 30
31#include <linux/kernel.h> 31#include <linux/kernel.h>
diff --git a/drivers/media/pci/ttpci/av7110_hw.c b/drivers/media/pci/ttpci/av7110_hw.c
index 300bd3c94738..0583d56ef5ef 100644
--- a/drivers/media/pci/ttpci/av7110_hw.c
+++ b/drivers/media/pci/ttpci/av7110_hw.c
@@ -22,7 +22,7 @@
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 23 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
24 * 24 *
25 * the project's page is at http://www.linuxtv.org/ 25 * the project's page is at https://linuxtv.org
26 */ 26 */
27 27
28/* for debugging ARM communication: */ 28/* for debugging ARM communication: */
diff --git a/drivers/media/pci/ttpci/av7110_v4l.c b/drivers/media/pci/ttpci/av7110_v4l.c
index 6c4076acb131..479aff02db81 100644
--- a/drivers/media/pci/ttpci/av7110_v4l.c
+++ b/drivers/media/pci/ttpci/av7110_v4l.c
@@ -22,7 +22,7 @@
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 23 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
24 * 24 *
25 * the project's page is at http://www.linuxtv.org/ 25 * the project's page is at https://linuxtv.org
26 */ 26 */
27 27
28#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 28#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/pci/ttpci/budget-av.c b/drivers/media/pci/ttpci/budget-av.c
index 3e469d4e0c87..6f0d0161970e 100644
--- a/drivers/media/pci/ttpci/budget-av.c
+++ b/drivers/media/pci/ttpci/budget-av.c
@@ -30,7 +30,7 @@
30 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 30 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
31 * 31 *
32 * 32 *
33 * the project's page is at http://www.linuxtv.org/ 33 * the project's page is at https://linuxtv.org
34 */ 34 */
35 35
36#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 36#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -46,7 +46,7 @@
46#include "tda1004x.h" 46#include "tda1004x.h"
47#include "tua6100.h" 47#include "tua6100.h"
48#include "dvb-pll.h" 48#include "dvb-pll.h"
49#include <media/saa7146_vv.h> 49#include <media/drv-intf/saa7146_vv.h>
50#include <linux/module.h> 50#include <linux/module.h>
51#include <linux/errno.h> 51#include <linux/errno.h>
52#include <linux/slab.h> 52#include <linux/slab.h>
diff --git a/drivers/media/pci/ttpci/budget-ci.c b/drivers/media/pci/ttpci/budget-ci.c
index 1feeeff3681b..7b27af4d9658 100644
--- a/drivers/media/pci/ttpci/budget-ci.c
+++ b/drivers/media/pci/ttpci/budget-ci.c
@@ -26,7 +26,7 @@
26 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 26 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
27 * 27 *
28 * 28 *
29 * the project's page is at http://www.linuxtv.org/ 29 * the project's page is at https://linuxtv.org
30 */ 30 */
31 31
32#include <linux/module.h> 32#include <linux/module.h>
diff --git a/drivers/media/pci/ttpci/budget-core.c b/drivers/media/pci/ttpci/budget-core.c
index e9674b40007c..6d42dcfd4825 100644
--- a/drivers/media/pci/ttpci/budget-core.c
+++ b/drivers/media/pci/ttpci/budget-core.c
@@ -31,7 +31,7 @@
31 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 31 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
32 * 32 *
33 * 33 *
34 * the project's page is at http://www.linuxtv.org/ 34 * the project's page is at https://linuxtv.org
35 */ 35 */
36 36
37 37
diff --git a/drivers/media/pci/ttpci/budget-patch.c b/drivers/media/pci/ttpci/budget-patch.c
index b5b65962ce8f..591dbdfa2a13 100644
--- a/drivers/media/pci/ttpci/budget-patch.c
+++ b/drivers/media/pci/ttpci/budget-patch.c
@@ -27,7 +27,7 @@
27 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 27 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
28 * 28 *
29 * 29 *
30 * the project's page is at http://www.linuxtv.org/ 30 * the project's page is at https://linuxtv.org
31 */ 31 */
32 32
33#include "av7110.h" 33#include "av7110.h"
diff --git a/drivers/media/pci/ttpci/budget.c b/drivers/media/pci/ttpci/budget.c
index 99972beca262..de54310a2660 100644
--- a/drivers/media/pci/ttpci/budget.c
+++ b/drivers/media/pci/ttpci/budget.c
@@ -31,7 +31,7 @@
31 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 31 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
32 * 32 *
33 * 33 *
34 * the project's page is at http://www.linuxtv.org/ 34 * the project's page is at https://linuxtv.org
35 */ 35 */
36 36
37#include "budget.h" 37#include "budget.h"
diff --git a/drivers/media/pci/ttpci/budget.h b/drivers/media/pci/ttpci/budget.h
index 1ccbe1a49a4b..655eef5236ca 100644
--- a/drivers/media/pci/ttpci/budget.h
+++ b/drivers/media/pci/ttpci/budget.h
@@ -13,7 +13,7 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/mutex.h> 14#include <linux/mutex.h>
15 15
16#include <media/saa7146.h> 16#include <media/drv-intf/saa7146.h>
17 17
18extern int budget_debug; 18extern int budget_debug;
19 19
diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c
index 46642ef9151b..07116a87a57b 100644
--- a/drivers/media/pci/tw68/tw68-video.c
+++ b/drivers/media/pci/tw68/tw68-video.c
@@ -376,28 +376,28 @@ static int tw68_buffer_count(unsigned int size, unsigned int count)
376/* ------------------------------------------------------------- */ 376/* ------------------------------------------------------------- */
377/* vb2 queue operations */ 377/* vb2 queue operations */
378 378
379static int tw68_queue_setup(struct vb2_queue *q, const void *parg, 379static int tw68_queue_setup(struct vb2_queue *q,
380 unsigned int *num_buffers, unsigned int *num_planes, 380 unsigned int *num_buffers, unsigned int *num_planes,
381 unsigned int sizes[], void *alloc_ctxs[]) 381 unsigned int sizes[], void *alloc_ctxs[])
382{ 382{
383 const struct v4l2_format *fmt = parg;
384 struct tw68_dev *dev = vb2_get_drv_priv(q); 383 struct tw68_dev *dev = vb2_get_drv_priv(q);
385 unsigned tot_bufs = q->num_buffers + *num_buffers; 384 unsigned tot_bufs = q->num_buffers + *num_buffers;
385 unsigned size = (dev->fmt->depth * dev->width * dev->height) >> 3;
386 386
387 sizes[0] = (dev->fmt->depth * dev->width * dev->height) >> 3; 387 if (tot_bufs < 2)
388 tot_bufs = 2;
389 tot_bufs = tw68_buffer_count(size, tot_bufs);
390 *num_buffers = tot_bufs - q->num_buffers;
388 alloc_ctxs[0] = dev->alloc_ctx; 391 alloc_ctxs[0] = dev->alloc_ctx;
389 /* 392 /*
390 * We allow create_bufs, but only if the sizeimage is the same as the 393 * We allow create_bufs, but only if the sizeimage is >= as the
391 * current sizeimage. The tw68_buffer_count calculation becomes quite 394 * current sizeimage. The tw68_buffer_count calculation becomes quite
392 * difficult otherwise. 395 * difficult otherwise.
393 */ 396 */
394 if (fmt && fmt->fmt.pix.sizeimage < sizes[0]) 397 if (*num_planes)
395 return -EINVAL; 398 return sizes[0] < size ? -EINVAL : 0;
396 *num_planes = 1; 399 *num_planes = 1;
397 if (tot_bufs < 2) 400 sizes[0] = size;
398 tot_bufs = 2;
399 tot_bufs = tw68_buffer_count(sizes[0], tot_bufs);
400 *num_buffers = tot_bufs - q->num_buffers;
401 401
402 return 0; 402 return 0;
403} 403}
@@ -1016,7 +1016,7 @@ void tw68_irq_video_done(struct tw68_dev *dev, unsigned long status)
1016 buf = list_entry(dev->active.next, struct tw68_buf, list); 1016 buf = list_entry(dev->active.next, struct tw68_buf, list);
1017 list_del(&buf->list); 1017 list_del(&buf->list);
1018 spin_unlock(&dev->slock); 1018 spin_unlock(&dev->slock);
1019 v4l2_get_timestamp(&buf->vb.timestamp); 1019 buf->vb.vb2_buf.timestamp = ktime_get_ns();
1020 buf->vb.field = dev->field; 1020 buf->vb.field = dev->field;
1021 buf->vb.sequence = dev->seqnr++; 1021 buf->vb.sequence = dev->seqnr++;
1022 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); 1022 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/pci/zoran/zoran_card.c b/drivers/media/pci/zoran/zoran_card.c
index 1136d92af642..9d2697f5b455 100644
--- a/drivers/media/pci/zoran/zoran_card.c
+++ b/drivers/media/pci/zoran/zoran_card.c
@@ -50,7 +50,7 @@
50#include <linux/mutex.h> 50#include <linux/mutex.h>
51#include <linux/io.h> 51#include <linux/io.h>
52#include <media/v4l2-common.h> 52#include <media/v4l2-common.h>
53#include <media/bt819.h> 53#include <media/i2c/bt819.h>
54 54
55#include "videocodec.h" 55#include "videocodec.h"
56#include "zoran.h" 56#include "zoran.h"
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index ccbc9742cb7a..0c53805dff0e 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -38,7 +38,7 @@ config VIDEO_SH_VOU
38 depends on MEDIA_CAMERA_SUPPORT 38 depends on MEDIA_CAMERA_SUPPORT
39 depends on VIDEO_DEV && I2C && HAS_DMA 39 depends on VIDEO_DEV && I2C && HAS_DMA
40 depends on ARCH_SHMOBILE || COMPILE_TEST 40 depends on ARCH_SHMOBILE || COMPILE_TEST
41 select VIDEOBUF_DMA_CONTIG 41 select VIDEOBUF2_DMA_CONTIG
42 help 42 help
43 Support for the Video Output Unit (VOU) on SuperH SoCs. 43 Support for the Video Output Unit (VOU) on SuperH SoCs.
44 44
diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c
index f0480d687f17..de32e3a3d4d1 100644
--- a/drivers/media/platform/am437x/am437x-vpfe.c
+++ b/drivers/media/platform/am437x/am437x-vpfe.c
@@ -1281,7 +1281,7 @@ static inline void vpfe_schedule_bottom_field(struct vpfe_device *vpfe)
1281 */ 1281 */
1282static inline void vpfe_process_buffer_complete(struct vpfe_device *vpfe) 1282static inline void vpfe_process_buffer_complete(struct vpfe_device *vpfe)
1283{ 1283{
1284 v4l2_get_timestamp(&vpfe->cur_frm->vb.timestamp); 1284 vpfe->cur_frm->vb.vb2_buf.timestamp = ktime_get_ns();
1285 vpfe->cur_frm->vb.field = vpfe->fmt.fmt.pix.field; 1285 vpfe->cur_frm->vb.field = vpfe->fmt.fmt.pix.field;
1286 vpfe->cur_frm->vb.sequence = vpfe->sequence++; 1286 vpfe->cur_frm->vb.sequence = vpfe->sequence++;
1287 vb2_buffer_done(&vpfe->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE); 1287 vb2_buffer_done(&vpfe->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE);
@@ -1898,7 +1898,6 @@ static void vpfe_calculate_offsets(struct vpfe_device *vpfe)
1898/* 1898/*
1899 * vpfe_queue_setup - Callback function for buffer setup. 1899 * vpfe_queue_setup - Callback function for buffer setup.
1900 * @vq: vb2_queue ptr 1900 * @vq: vb2_queue ptr
1901 * @fmt: v4l2 format
1902 * @nbuffers: ptr to number of buffers requested by application 1901 * @nbuffers: ptr to number of buffers requested by application
1903 * @nplanes:: contains number of distinct video planes needed to hold a frame 1902 * @nplanes:: contains number of distinct video planes needed to hold a frame
1904 * @sizes[]: contains the size (in bytes) of each plane. 1903 * @sizes[]: contains the size (in bytes) of each plane.
@@ -1908,22 +1907,24 @@ static void vpfe_calculate_offsets(struct vpfe_device *vpfe)
1908 * the buffer count and buffer size 1907 * the buffer count and buffer size
1909 */ 1908 */
1910static int vpfe_queue_setup(struct vb2_queue *vq, 1909static int vpfe_queue_setup(struct vb2_queue *vq,
1911 const void *parg,
1912 unsigned int *nbuffers, unsigned int *nplanes, 1910 unsigned int *nbuffers, unsigned int *nplanes,
1913 unsigned int sizes[], void *alloc_ctxs[]) 1911 unsigned int sizes[], void *alloc_ctxs[])
1914{ 1912{
1915 const struct v4l2_format *fmt = parg;
1916 struct vpfe_device *vpfe = vb2_get_drv_priv(vq); 1913 struct vpfe_device *vpfe = vb2_get_drv_priv(vq);
1917 1914 unsigned size = vpfe->fmt.fmt.pix.sizeimage;
1918 if (fmt && fmt->fmt.pix.sizeimage < vpfe->fmt.fmt.pix.sizeimage)
1919 return -EINVAL;
1920 1915
1921 if (vq->num_buffers + *nbuffers < 3) 1916 if (vq->num_buffers + *nbuffers < 3)
1922 *nbuffers = 3 - vq->num_buffers; 1917 *nbuffers = 3 - vq->num_buffers;
1918 alloc_ctxs[0] = vpfe->alloc_ctx;
1919
1920 if (*nplanes) {
1921 if (sizes[0] < size)
1922 return -EINVAL;
1923 size = sizes[0];
1924 }
1923 1925
1924 *nplanes = 1; 1926 *nplanes = 1;
1925 sizes[0] = fmt ? fmt->fmt.pix.sizeimage : vpfe->fmt.fmt.pix.sizeimage; 1927 sizes[0] = size;
1926 alloc_ctxs[0] = vpfe->alloc_ctx;
1927 1928
1928 vpfe_dbg(1, vpfe, 1929 vpfe_dbg(1, vpfe,
1929 "nbuffers=%d, size=%u\n", *nbuffers, sizes[0]); 1930 "nbuffers=%d, size=%u\n", *nbuffers, sizes[0]);
diff --git a/drivers/media/platform/blackfin/bfin_capture.c b/drivers/media/platform/blackfin/bfin_capture.c
index 7764b9c482ef..d0092dae7a57 100644
--- a/drivers/media/platform/blackfin/bfin_capture.c
+++ b/drivers/media/platform/blackfin/bfin_capture.c
@@ -202,22 +202,20 @@ static void bcap_free_sensor_formats(struct bcap_device *bcap_dev)
202} 202}
203 203
204static int bcap_queue_setup(struct vb2_queue *vq, 204static int bcap_queue_setup(struct vb2_queue *vq,
205 const void *parg,
206 unsigned int *nbuffers, unsigned int *nplanes, 205 unsigned int *nbuffers, unsigned int *nplanes,
207 unsigned int sizes[], void *alloc_ctxs[]) 206 unsigned int sizes[], void *alloc_ctxs[])
208{ 207{
209 const struct v4l2_format *fmt = parg;
210 struct bcap_device *bcap_dev = vb2_get_drv_priv(vq); 208 struct bcap_device *bcap_dev = vb2_get_drv_priv(vq);
211 209
212 if (fmt && fmt->fmt.pix.sizeimage < bcap_dev->fmt.sizeimage)
213 return -EINVAL;
214
215 if (vq->num_buffers + *nbuffers < 2) 210 if (vq->num_buffers + *nbuffers < 2)
216 *nbuffers = 2; 211 *nbuffers = 2;
212 alloc_ctxs[0] = bcap_dev->alloc_ctx;
213
214 if (*nplanes)
215 return sizes[0] < bcap_dev->fmt.sizeimage ? -EINVAL : 0;
217 216
218 *nplanes = 1; 217 *nplanes = 1;
219 sizes[0] = fmt ? fmt->fmt.pix.sizeimage : bcap_dev->fmt.sizeimage; 218 sizes[0] = bcap_dev->fmt.sizeimage;
220 alloc_ctxs[0] = bcap_dev->alloc_ctx;
221 219
222 return 0; 220 return 0;
223} 221}
@@ -406,7 +404,7 @@ static irqreturn_t bcap_isr(int irq, void *dev_id)
406 spin_lock(&bcap_dev->lock); 404 spin_lock(&bcap_dev->lock);
407 405
408 if (!list_empty(&bcap_dev->dma_queue)) { 406 if (!list_empty(&bcap_dev->dma_queue)) {
409 v4l2_get_timestamp(&vbuf->timestamp); 407 vb->timestamp = ktime_get_ns();
410 if (ppi->err) { 408 if (ppi->err) {
411 vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); 409 vb2_buffer_done(vb, VB2_BUF_STATE_ERROR);
412 ppi->err = false; 410 ppi->err = false;
diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c
index 654e964f84a2..7d28899f89ce 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -246,7 +246,7 @@ void coda_fill_bitstream(struct coda_ctx *ctx, bool streaming)
246 246
247 /* Drop frames that do not start/end with a SOI/EOI markers */ 247 /* Drop frames that do not start/end with a SOI/EOI markers */
248 if (ctx->codec->src_fourcc == V4L2_PIX_FMT_JPEG && 248 if (ctx->codec->src_fourcc == V4L2_PIX_FMT_JPEG &&
249 !coda_jpeg_check_buffer(ctx, src_buf)) { 249 !coda_jpeg_check_buffer(ctx, &src_buf->vb2_buf)) {
250 v4l2_err(&ctx->dev->v4l2_dev, 250 v4l2_err(&ctx->dev->v4l2_dev,
251 "dropping invalid JPEG frame %d\n", 251 "dropping invalid JPEG frame %d\n",
252 ctx->qsequence); 252 ctx->qsequence);
@@ -279,7 +279,7 @@ void coda_fill_bitstream(struct coda_ctx *ctx, bool streaming)
279 if (meta) { 279 if (meta) {
280 meta->sequence = src_buf->sequence; 280 meta->sequence = src_buf->sequence;
281 meta->timecode = src_buf->timecode; 281 meta->timecode = src_buf->timecode;
282 meta->timestamp = src_buf->timestamp; 282 meta->timestamp = src_buf->vb2_buf.timestamp;
283 meta->start = start; 283 meta->start = start;
284 meta->end = ctx->bitstream_fifo.kfifo.in & 284 meta->end = ctx->bitstream_fifo.kfifo.in &
285 ctx->bitstream_fifo.kfifo.mask; 285 ctx->bitstream_fifo.kfifo.mask;
@@ -1364,7 +1364,7 @@ static void coda_finish_encode(struct coda_ctx *ctx)
1364 dst_buf->flags &= ~V4L2_BUF_FLAG_KEYFRAME; 1364 dst_buf->flags &= ~V4L2_BUF_FLAG_KEYFRAME;
1365 } 1365 }
1366 1366
1367 dst_buf->timestamp = src_buf->timestamp; 1367 dst_buf->vb2_buf.timestamp = src_buf->vb2_buf.timestamp;
1368 dst_buf->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 1368 dst_buf->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
1369 dst_buf->flags |= 1369 dst_buf->flags |=
1370 src_buf->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 1370 src_buf->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
@@ -2040,7 +2040,7 @@ static void coda_finish_decode(struct coda_ctx *ctx)
2040 dst_buf->flags |= ctx->frame_types[ctx->display_idx]; 2040 dst_buf->flags |= ctx->frame_types[ctx->display_idx];
2041 meta = &ctx->frame_metas[ctx->display_idx]; 2041 meta = &ctx->frame_metas[ctx->display_idx];
2042 dst_buf->timecode = meta->timecode; 2042 dst_buf->timecode = meta->timecode;
2043 dst_buf->timestamp = meta->timestamp; 2043 dst_buf->vb2_buf.timestamp = meta->timestamp;
2044 2044
2045 trace_coda_dec_rot_done(ctx, dst_buf, meta); 2045 trace_coda_dec_rot_done(ctx, dst_buf, meta);
2046 2046
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index 15516a6e3a39..2d782ce94a67 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -28,7 +28,7 @@
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/videodev2.h> 29#include <linux/videodev2.h>
30#include <linux/of.h> 30#include <linux/of.h>
31#include <linux/platform_data/coda.h> 31#include <linux/platform_data/media/coda.h>
32#include <linux/reset.h> 32#include <linux/reset.h>
33 33
34#include <media/v4l2-ctrls.h> 34#include <media/v4l2-ctrls.h>
@@ -131,6 +131,7 @@ static const struct coda_codec coda7_codecs[] = {
131 CODA_CODEC(CODA7_MODE_ENCODE_MP4, V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_MPEG4, 1280, 720), 131 CODA_CODEC(CODA7_MODE_ENCODE_MP4, V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_MPEG4, 1280, 720),
132 CODA_CODEC(CODA7_MODE_ENCODE_MJPG, V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_JPEG, 8192, 8192), 132 CODA_CODEC(CODA7_MODE_ENCODE_MJPG, V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_JPEG, 8192, 8192),
133 CODA_CODEC(CODA7_MODE_DECODE_H264, V4L2_PIX_FMT_H264, V4L2_PIX_FMT_YUV420, 1920, 1088), 133 CODA_CODEC(CODA7_MODE_DECODE_H264, V4L2_PIX_FMT_H264, V4L2_PIX_FMT_YUV420, 1920, 1088),
134 CODA_CODEC(CODA7_MODE_DECODE_MP2, V4L2_PIX_FMT_MPEG2, V4L2_PIX_FMT_YUV420, 1920, 1088),
134 CODA_CODEC(CODA7_MODE_DECODE_MP4, V4L2_PIX_FMT_MPEG4, V4L2_PIX_FMT_YUV420, 1920, 1088), 135 CODA_CODEC(CODA7_MODE_DECODE_MP4, V4L2_PIX_FMT_MPEG4, V4L2_PIX_FMT_YUV420, 1920, 1088),
135 CODA_CODEC(CODA7_MODE_DECODE_MJPG, V4L2_PIX_FMT_JPEG, V4L2_PIX_FMT_YUV420, 8192, 8192), 136 CODA_CODEC(CODA7_MODE_DECODE_MJPG, V4L2_PIX_FMT_JPEG, V4L2_PIX_FMT_YUV420, 8192, 8192),
136}; 137};
@@ -139,6 +140,7 @@ static const struct coda_codec coda9_codecs[] = {
139 CODA_CODEC(CODA9_MODE_ENCODE_H264, V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_H264, 1920, 1088), 140 CODA_CODEC(CODA9_MODE_ENCODE_H264, V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_H264, 1920, 1088),
140 CODA_CODEC(CODA9_MODE_ENCODE_MP4, V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_MPEG4, 1920, 1088), 141 CODA_CODEC(CODA9_MODE_ENCODE_MP4, V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_MPEG4, 1920, 1088),
141 CODA_CODEC(CODA9_MODE_DECODE_H264, V4L2_PIX_FMT_H264, V4L2_PIX_FMT_YUV420, 1920, 1088), 142 CODA_CODEC(CODA9_MODE_DECODE_H264, V4L2_PIX_FMT_H264, V4L2_PIX_FMT_YUV420, 1920, 1088),
143 CODA_CODEC(CODA9_MODE_DECODE_MP2, V4L2_PIX_FMT_MPEG2, V4L2_PIX_FMT_YUV420, 1920, 1088),
142 CODA_CODEC(CODA9_MODE_DECODE_MP4, V4L2_PIX_FMT_MPEG4, V4L2_PIX_FMT_YUV420, 1920, 1088), 144 CODA_CODEC(CODA9_MODE_DECODE_MP4, V4L2_PIX_FMT_MPEG4, V4L2_PIX_FMT_YUV420, 1920, 1088),
143}; 145};
144 146
@@ -187,6 +189,7 @@ static const struct coda_video_device coda_bit_decoder = {
187 .ops = &coda_bit_decode_ops, 189 .ops = &coda_bit_decode_ops,
188 .src_formats = { 190 .src_formats = {
189 V4L2_PIX_FMT_H264, 191 V4L2_PIX_FMT_H264,
192 V4L2_PIX_FMT_MPEG2,
190 V4L2_PIX_FMT_MPEG4, 193 V4L2_PIX_FMT_MPEG4,
191 }, 194 },
192 .dst_formats = { 195 .dst_formats = {
@@ -293,7 +296,8 @@ static void coda_get_max_dimensions(struct coda_dev *dev,
293 *max_h = h; 296 *max_h = h;
294} 297}
295 298
296const struct coda_video_device *to_coda_video_device(struct video_device *vdev) 299static const struct coda_video_device *to_coda_video_device(struct video_device
300 *vdev)
297{ 301{
298 struct coda_dev *dev = video_get_drvdata(vdev); 302 struct coda_dev *dev = video_get_drvdata(vdev);
299 unsigned int i = vdev - dev->vfd; 303 unsigned int i = vdev - dev->vfd;
@@ -469,6 +473,7 @@ static int coda_try_fmt(struct coda_ctx *ctx, const struct coda_codec *codec,
469 /* fallthrough */ 473 /* fallthrough */
470 case V4L2_PIX_FMT_H264: 474 case V4L2_PIX_FMT_H264:
471 case V4L2_PIX_FMT_MPEG4: 475 case V4L2_PIX_FMT_MPEG4:
476 case V4L2_PIX_FMT_MPEG2:
472 f->fmt.pix.bytesperline = 0; 477 f->fmt.pix.bytesperline = 0;
473 f->fmt.pix.sizeimage = coda_estimate_sizeimage(ctx, 478 f->fmt.pix.sizeimage = coda_estimate_sizeimage(ctx,
474 f->fmt.pix.sizeimage, 479 f->fmt.pix.sizeimage,
@@ -920,6 +925,7 @@ static const struct v4l2_ioctl_ops coda_ioctl_ops = {
920 .vidioc_expbuf = v4l2_m2m_ioctl_expbuf, 925 .vidioc_expbuf = v4l2_m2m_ioctl_expbuf,
921 .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf, 926 .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf,
922 .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs, 927 .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
928 .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf,
923 929
924 .vidioc_streamon = v4l2_m2m_ioctl_streamon, 930 .vidioc_streamon = v4l2_m2m_ioctl_streamon,
925 .vidioc_streamoff = v4l2_m2m_ioctl_streamoff, 931 .vidioc_streamoff = v4l2_m2m_ioctl_streamoff,
@@ -1131,7 +1137,7 @@ static void set_default_params(struct coda_ctx *ctx)
1131/* 1137/*
1132 * Queue operations 1138 * Queue operations
1133 */ 1139 */
1134static int coda_queue_setup(struct vb2_queue *vq, const void *parg, 1140static int coda_queue_setup(struct vb2_queue *vq,
1135 unsigned int *nbuffers, unsigned int *nplanes, 1141 unsigned int *nbuffers, unsigned int *nplanes,
1136 unsigned int sizes[], void *alloc_ctxs[]) 1142 unsigned int sizes[], void *alloc_ctxs[])
1137{ 1143{
@@ -1250,6 +1256,9 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count)
1250 struct vb2_v4l2_buffer *buf; 1256 struct vb2_v4l2_buffer *buf;
1251 int ret = 0; 1257 int ret = 0;
1252 1258
1259 if (count < 1)
1260 return -EINVAL;
1261
1253 q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); 1262 q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
1254 if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { 1263 if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
1255 if (ctx->inst_type == CODA_INST_DECODER && ctx->use_bit) { 1264 if (ctx->inst_type == CODA_INST_DECODER && ctx->use_bit) {
@@ -1262,20 +1271,10 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count)
1262 ret = -EINVAL; 1271 ret = -EINVAL;
1263 goto err; 1272 goto err;
1264 } 1273 }
1265 } else {
1266 if (count < 1) {
1267 ret = -EINVAL;
1268 goto err;
1269 }
1270 } 1274 }
1271 1275
1272 ctx->streamon_out = 1; 1276 ctx->streamon_out = 1;
1273 } else { 1277 } else {
1274 if (count < 1) {
1275 ret = -EINVAL;
1276 goto err;
1277 }
1278
1279 ctx->streamon_cap = 1; 1278 ctx->streamon_cap = 1;
1280 } 1279 }
1281 1280
diff --git a/drivers/media/platform/coda/coda-jpeg.c b/drivers/media/platform/coda/coda-jpeg.c
index 96cd42a0baaf..9f899a6cefed 100644
--- a/drivers/media/platform/coda/coda-jpeg.c
+++ b/drivers/media/platform/coda/coda-jpeg.c
@@ -178,14 +178,28 @@ int coda_jpeg_write_tables(struct coda_ctx *ctx)
178 return 0; 178 return 0;
179} 179}
180 180
181bool coda_jpeg_check_buffer(struct coda_ctx *ctx, struct vb2_v4l2_buffer *vb) 181bool coda_jpeg_check_buffer(struct coda_ctx *ctx, struct vb2_buffer *vb)
182{ 182{
183 void *vaddr = vb2_plane_vaddr(&vb->vb2_buf, 0); 183 void *vaddr = vb2_plane_vaddr(vb, 0);
184 u16 soi = be16_to_cpup((__be16 *)vaddr); 184 u16 soi, eoi;
185 u16 eoi = be16_to_cpup((__be16 *)(vaddr + 185 int len, i;
186 vb2_get_plane_payload(&vb->vb2_buf, 0) - 2)); 186
187 soi = be16_to_cpup((__be16 *)vaddr);
188 if (soi != SOI_MARKER)
189 return false;
190
191 len = vb2_get_plane_payload(vb, 0);
192 vaddr += len - 2;
193 for (i = 0; i < 32; i++) {
194 eoi = be16_to_cpup((__be16 *)(vaddr - i));
195 if (eoi == EOI_MARKER) {
196 if (i > 0)
197 vb2_set_plane_payload(vb, 0, len - i);
198 return true;
199 }
200 }
187 201
188 return soi == SOI_MARKER && eoi == EOI_MARKER; 202 return false;
189} 203}
190 204
191/* 205/*
diff --git a/drivers/media/platform/coda/coda.h b/drivers/media/platform/coda/coda.h
index 96532b06bd9e..d08e9843e9f2 100644
--- a/drivers/media/platform/coda/coda.h
+++ b/drivers/media/platform/coda/coda.h
@@ -138,7 +138,7 @@ struct coda_buffer_meta {
138 struct list_head list; 138 struct list_head list;
139 u32 sequence; 139 u32 sequence;
140 struct v4l2_timecode timecode; 140 struct v4l2_timecode timecode;
141 struct timeval timestamp; 141 u64 timestamp;
142 u32 start; 142 u32 start;
143 u32 end; 143 u32 end;
144}; 144};
@@ -289,7 +289,7 @@ void coda_m2m_buf_done(struct coda_ctx *ctx, struct vb2_v4l2_buffer *buf,
289 289
290int coda_h264_padding(int size, char *p); 290int coda_h264_padding(int size, char *p);
291 291
292bool coda_jpeg_check_buffer(struct coda_ctx *ctx, struct vb2_v4l2_buffer *vb); 292bool coda_jpeg_check_buffer(struct coda_ctx *ctx, struct vb2_buffer *vb);
293int coda_jpeg_write_tables(struct coda_ctx *ctx); 293int coda_jpeg_write_tables(struct coda_ctx *ctx);
294void coda_set_jpeg_compression_quality(struct coda_ctx *ctx, int quality); 294void coda_set_jpeg_compression_quality(struct coda_ctx *ctx, int quality);
295 295
diff --git a/drivers/media/platform/davinci/Kconfig b/drivers/media/platform/davinci/Kconfig
index 469e9d28cec0..554e710de487 100644
--- a/drivers/media/platform/davinci/Kconfig
+++ b/drivers/media/platform/davinci/Kconfig
@@ -3,6 +3,7 @@ config VIDEO_DAVINCI_VPIF_DISPLAY
3 depends on VIDEO_V4L2 3 depends on VIDEO_V4L2
4 depends on ARCH_DAVINCI || COMPILE_TEST 4 depends on ARCH_DAVINCI || COMPILE_TEST
5 depends on HAS_DMA 5 depends on HAS_DMA
6 depends on I2C
6 select VIDEOBUF2_DMA_CONTIG 7 select VIDEOBUF2_DMA_CONTIG
7 select VIDEO_ADV7343 if MEDIA_SUBDRV_AUTOSELECT 8 select VIDEO_ADV7343 if MEDIA_SUBDRV_AUTOSELECT
8 select VIDEO_THS7303 if MEDIA_SUBDRV_AUTOSELECT 9 select VIDEO_THS7303 if MEDIA_SUBDRV_AUTOSELECT
@@ -19,6 +20,7 @@ config VIDEO_DAVINCI_VPIF_CAPTURE
19 depends on VIDEO_V4L2 20 depends on VIDEO_V4L2
20 depends on ARCH_DAVINCI || COMPILE_TEST 21 depends on ARCH_DAVINCI || COMPILE_TEST
21 depends on HAS_DMA 22 depends on HAS_DMA
23 depends on I2C
22 select VIDEOBUF2_DMA_CONTIG 24 select VIDEOBUF2_DMA_CONTIG
23 help 25 help
24 Enables Davinci VPIF module used for capture devices. 26 Enables Davinci VPIF module used for capture devices.
@@ -33,6 +35,7 @@ config VIDEO_DM6446_CCDC
33 depends on VIDEO_V4L2 35 depends on VIDEO_V4L2
34 depends on ARCH_DAVINCI || COMPILE_TEST 36 depends on ARCH_DAVINCI || COMPILE_TEST
35 depends on HAS_DMA 37 depends on HAS_DMA
38 depends on I2C
36 select VIDEOBUF_DMA_CONTIG 39 select VIDEOBUF_DMA_CONTIG
37 help 40 help
38 Enables DaVinci CCD hw module. DaVinci CCDC hw interfaces 41 Enables DaVinci CCD hw module. DaVinci CCDC hw interfaces
@@ -49,6 +52,7 @@ config VIDEO_DM355_CCDC
49 depends on VIDEO_V4L2 52 depends on VIDEO_V4L2
50 depends on ARCH_DAVINCI || COMPILE_TEST 53 depends on ARCH_DAVINCI || COMPILE_TEST
51 depends on HAS_DMA 54 depends on HAS_DMA
55 depends on I2C
52 select VIDEOBUF_DMA_CONTIG 56 select VIDEOBUF_DMA_CONTIG
53 help 57 help
54 Enables DM355 CCD hw module. DM355 CCDC hw interfaces 58 Enables DM355 CCD hw module. DM355 CCDC hw interfaces
@@ -64,6 +68,7 @@ config VIDEO_DM365_ISIF
64 tristate "TI DM365 ISIF video capture driver" 68 tristate "TI DM365 ISIF video capture driver"
65 depends on VIDEO_V4L2 && ARCH_DAVINCI 69 depends on VIDEO_V4L2 && ARCH_DAVINCI
66 depends on HAS_DMA 70 depends on HAS_DMA
71 depends on I2C
67 select VIDEOBUF_DMA_CONTIG 72 select VIDEOBUF_DMA_CONTIG
68 help 73 help
69 Enables ISIF hw module. This is the hardware module for 74 Enables ISIF hw module. This is the hardware module for
@@ -77,6 +82,7 @@ config VIDEO_DAVINCI_VPBE_DISPLAY
77 tristate "TI DaVinci VPBE V4L2-Display driver" 82 tristate "TI DaVinci VPBE V4L2-Display driver"
78 depends on VIDEO_V4L2 && ARCH_DAVINCI 83 depends on VIDEO_V4L2 && ARCH_DAVINCI
79 depends on HAS_DMA 84 depends on HAS_DMA
85 depends on I2C
80 select VIDEOBUF2_DMA_CONTIG 86 select VIDEOBUF2_DMA_CONTIG
81 help 87 help
82 Enables Davinci VPBE module used for display devices. 88 Enables Davinci VPBE module used for display devices.
diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c
index 6d91422c4e4c..0abcdfe97a6c 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -74,7 +74,7 @@ static void vpbe_isr_even_field(struct vpbe_display *disp_obj,
74 if (layer->cur_frm == layer->next_frm) 74 if (layer->cur_frm == layer->next_frm)
75 return; 75 return;
76 76
77 v4l2_get_timestamp(&layer->cur_frm->vb.timestamp); 77 layer->cur_frm->vb.vb2_buf.timestamp = ktime_get_ns();
78 vb2_buffer_done(&layer->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE); 78 vb2_buffer_done(&layer->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE);
79 /* Make cur_frm pointing to next_frm */ 79 /* Make cur_frm pointing to next_frm */
80 layer->cur_frm = layer->next_frm; 80 layer->cur_frm = layer->next_frm;
@@ -228,28 +228,27 @@ static int vpbe_buffer_prepare(struct vb2_buffer *vb)
228 * This function allocates memory for the buffers 228 * This function allocates memory for the buffers
229 */ 229 */
230static int 230static int
231vpbe_buffer_queue_setup(struct vb2_queue *vq, const void *parg, 231vpbe_buffer_queue_setup(struct vb2_queue *vq,
232 unsigned int *nbuffers, unsigned int *nplanes, 232 unsigned int *nbuffers, unsigned int *nplanes,
233 unsigned int sizes[], void *alloc_ctxs[]) 233 unsigned int sizes[], void *alloc_ctxs[])
234 234
235{ 235{
236 const struct v4l2_format *fmt = parg;
237 /* Get the file handle object and layer object */ 236 /* Get the file handle object and layer object */
238 struct vpbe_layer *layer = vb2_get_drv_priv(vq); 237 struct vpbe_layer *layer = vb2_get_drv_priv(vq);
239 struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; 238 struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
240 239
241 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_buffer_setup\n"); 240 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_buffer_setup\n");
242 241
243 if (fmt && fmt->fmt.pix.sizeimage < layer->pix_fmt.sizeimage)
244 return -EINVAL;
245
246 /* Store number of buffers allocated in numbuffer member */ 242 /* Store number of buffers allocated in numbuffer member */
247 if (vq->num_buffers + *nbuffers < VPBE_DEFAULT_NUM_BUFS) 243 if (vq->num_buffers + *nbuffers < VPBE_DEFAULT_NUM_BUFS)
248 *nbuffers = VPBE_DEFAULT_NUM_BUFS - vq->num_buffers; 244 *nbuffers = VPBE_DEFAULT_NUM_BUFS - vq->num_buffers;
245 alloc_ctxs[0] = layer->alloc_ctx;
246
247 if (*nplanes)
248 return sizes[0] < layer->pix_fmt.sizeimage ? -EINVAL : 0;
249 249
250 *nplanes = 1; 250 *nplanes = 1;
251 sizes[0] = fmt ? fmt->fmt.pix.sizeimage : layer->pix_fmt.sizeimage; 251 sizes[0] = layer->pix_fmt.sizeimage;
252 alloc_ctxs[0] = layer->alloc_ctx;
253 252
254 return 0; 253 return 0;
255} 254}
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
index c1e573b7cc6f..08f7028c7560 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -104,7 +104,6 @@ static int vpif_buffer_prepare(struct vb2_buffer *vb)
104/** 104/**
105 * vpif_buffer_queue_setup : Callback function for buffer setup. 105 * vpif_buffer_queue_setup : Callback function for buffer setup.
106 * @vq: vb2_queue ptr 106 * @vq: vb2_queue ptr
107 * @fmt: v4l2 format
108 * @nbuffers: ptr to number of buffers requested by application 107 * @nbuffers: ptr to number of buffers requested by application
109 * @nplanes:: contains number of distinct video planes needed to hold a frame 108 * @nplanes:: contains number of distinct video planes needed to hold a frame
110 * @sizes[]: contains the size (in bytes) of each plane. 109 * @sizes[]: contains the size (in bytes) of each plane.
@@ -114,26 +113,26 @@ static int vpif_buffer_prepare(struct vb2_buffer *vb)
114 * the buffer count and buffer size 113 * the buffer count and buffer size
115 */ 114 */
116static int vpif_buffer_queue_setup(struct vb2_queue *vq, 115static int vpif_buffer_queue_setup(struct vb2_queue *vq,
117 const void *parg,
118 unsigned int *nbuffers, unsigned int *nplanes, 116 unsigned int *nbuffers, unsigned int *nplanes,
119 unsigned int sizes[], void *alloc_ctxs[]) 117 unsigned int sizes[], void *alloc_ctxs[])
120{ 118{
121 const struct v4l2_format *fmt = parg;
122 struct channel_obj *ch = vb2_get_drv_priv(vq); 119 struct channel_obj *ch = vb2_get_drv_priv(vq);
123 struct common_obj *common; 120 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
124 121 unsigned size = common->fmt.fmt.pix.sizeimage;
125 common = &ch->common[VPIF_VIDEO_INDEX];
126 122
127 vpif_dbg(2, debug, "vpif_buffer_setup\n"); 123 vpif_dbg(2, debug, "vpif_buffer_setup\n");
128 124
129 if (fmt && fmt->fmt.pix.sizeimage < common->fmt.fmt.pix.sizeimage) 125 if (*nplanes) {
130 return -EINVAL; 126 if (sizes[0] < size)
127 return -EINVAL;
128 size = sizes[0];
129 }
131 130
132 if (vq->num_buffers + *nbuffers < 3) 131 if (vq->num_buffers + *nbuffers < 3)
133 *nbuffers = 3 - vq->num_buffers; 132 *nbuffers = 3 - vq->num_buffers;
134 133
135 *nplanes = 1; 134 *nplanes = 1;
136 sizes[0] = fmt ? fmt->fmt.pix.sizeimage : common->fmt.fmt.pix.sizeimage; 135 sizes[0] = size;
137 alloc_ctxs[0] = common->alloc_ctx; 136 alloc_ctxs[0] = common->alloc_ctx;
138 137
139 /* Calculate the offset for Y and C data in the buffer */ 138 /* Calculate the offset for Y and C data in the buffer */
@@ -331,7 +330,7 @@ static struct vb2_ops video_qops = {
331 */ 330 */
332static void vpif_process_buffer_complete(struct common_obj *common) 331static void vpif_process_buffer_complete(struct common_obj *common)
333{ 332{
334 v4l2_get_timestamp(&common->cur_frm->vb.timestamp); 333 common->cur_frm->vb.vb2_buf.timestamp = ktime_get_ns();
335 vb2_buffer_done(&common->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE); 334 vb2_buffer_done(&common->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE);
336 /* Make curFrm pointing to nextFrm */ 335 /* Make curFrm pointing to nextFrm */
337 common->cur_frm = common->next_frm; 336 common->cur_frm = common->next_frm;
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
index fd2780306c17..f40755cf1bf2 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -99,7 +99,6 @@ static int vpif_buffer_prepare(struct vb2_buffer *vb)
99/** 99/**
100 * vpif_buffer_queue_setup : Callback function for buffer setup. 100 * vpif_buffer_queue_setup : Callback function for buffer setup.
101 * @vq: vb2_queue ptr 101 * @vq: vb2_queue ptr
102 * @fmt: v4l2 format
103 * @nbuffers: ptr to number of buffers requested by application 102 * @nbuffers: ptr to number of buffers requested by application
104 * @nplanes:: contains number of distinct video planes needed to hold a frame 103 * @nplanes:: contains number of distinct video planes needed to hold a frame
105 * @sizes[]: contains the size (in bytes) of each plane. 104 * @sizes[]: contains the size (in bytes) of each plane.
@@ -109,22 +108,24 @@ static int vpif_buffer_prepare(struct vb2_buffer *vb)
109 * the buffer count and buffer size 108 * the buffer count and buffer size
110 */ 109 */
111static int vpif_buffer_queue_setup(struct vb2_queue *vq, 110static int vpif_buffer_queue_setup(struct vb2_queue *vq,
112 const void *parg,
113 unsigned int *nbuffers, unsigned int *nplanes, 111 unsigned int *nbuffers, unsigned int *nplanes,
114 unsigned int sizes[], void *alloc_ctxs[]) 112 unsigned int sizes[], void *alloc_ctxs[])
115{ 113{
116 const struct v4l2_format *fmt = parg;
117 struct channel_obj *ch = vb2_get_drv_priv(vq); 114 struct channel_obj *ch = vb2_get_drv_priv(vq);
118 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; 115 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
116 unsigned size = common->fmt.fmt.pix.sizeimage;
119 117
120 if (fmt && fmt->fmt.pix.sizeimage < common->fmt.fmt.pix.sizeimage) 118 if (*nplanes) {
121 return -EINVAL; 119 if (sizes[0] < size)
120 return -EINVAL;
121 size = sizes[0];
122 }
122 123
123 if (vq->num_buffers + *nbuffers < 3) 124 if (vq->num_buffers + *nbuffers < 3)
124 *nbuffers = 3 - vq->num_buffers; 125 *nbuffers = 3 - vq->num_buffers;
125 126
126 *nplanes = 1; 127 *nplanes = 1;
127 sizes[0] = fmt ? fmt->fmt.pix.sizeimage : common->fmt.fmt.pix.sizeimage; 128 sizes[0] = size;
128 alloc_ctxs[0] = common->alloc_ctx; 129 alloc_ctxs[0] = common->alloc_ctx;
129 130
130 /* Calculate the offset for Y and C data in the buffer */ 131 /* Calculate the offset for Y and C data in the buffer */
@@ -330,7 +331,7 @@ static void process_interlaced_mode(int fid, struct common_obj *common)
330 /* one frame is displayed If next frame is 331 /* one frame is displayed If next frame is
331 * available, release cur_frm and move on */ 332 * available, release cur_frm and move on */
332 /* Copy frame display time */ 333 /* Copy frame display time */
333 v4l2_get_timestamp(&common->cur_frm->vb.timestamp); 334 common->cur_frm->vb.vb2_buf.timestamp = ktime_get_ns();
334 /* Change status of the cur_frm */ 335 /* Change status of the cur_frm */
335 vb2_buffer_done(&common->cur_frm->vb.vb2_buf, 336 vb2_buffer_done(&common->cur_frm->vb.vb2_buf,
336 VB2_BUF_STATE_DONE); 337 VB2_BUF_STATE_DONE);
@@ -386,8 +387,8 @@ static irqreturn_t vpif_channel_isr(int irq, void *dev_id)
386 if (!channel_first_int[i][channel_id]) { 387 if (!channel_first_int[i][channel_id]) {
387 /* Mark status of the cur_frm to 388 /* Mark status of the cur_frm to
388 * done and unlock semaphore on it */ 389 * done and unlock semaphore on it */
389 v4l2_get_timestamp( 390 common->cur_frm->vb.vb2_buf.timestamp =
390 &common->cur_frm->vb.timestamp); 391 ktime_get_ns();
391 vb2_buffer_done(&common->cur_frm->vb.vb2_buf, 392 vb2_buffer_done(&common->cur_frm->vb.vb2_buf,
392 VB2_BUF_STATE_DONE); 393 VB2_BUF_STATE_DONE);
393 /* Make cur_frm pointing to next_frm */ 394 /* Make cur_frm pointing to next_frm */
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index d82e717acba7..93782f15b825 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -86,7 +86,7 @@ void gsc_m2m_job_finish(struct gsc_ctx *ctx, int vb_state)
86 dst_vb = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx); 86 dst_vb = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
87 87
88 if (src_vb && dst_vb) { 88 if (src_vb && dst_vb) {
89 dst_vb->timestamp = src_vb->timestamp; 89 dst_vb->vb2_buf.timestamp = src_vb->vb2_buf.timestamp;
90 dst_vb->timecode = src_vb->timecode; 90 dst_vb->timecode = src_vb->timecode;
91 dst_vb->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 91 dst_vb->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
92 dst_vb->flags |= 92 dst_vb->flags |=
@@ -125,7 +125,7 @@ static int gsc_get_bufs(struct gsc_ctx *ctx)
125 if (ret) 125 if (ret)
126 return ret; 126 return ret;
127 127
128 dst_vb->timestamp = src_vb->timestamp; 128 dst_vb->vb2_buf.timestamp = src_vb->vb2_buf.timestamp;
129 129
130 return 0; 130 return 0;
131} 131}
@@ -212,7 +212,6 @@ put_device:
212} 212}
213 213
214static int gsc_m2m_queue_setup(struct vb2_queue *vq, 214static int gsc_m2m_queue_setup(struct vb2_queue *vq,
215 const void *parg,
216 unsigned int *num_buffers, unsigned int *num_planes, 215 unsigned int *num_buffers, unsigned int *num_planes,
217 unsigned int sizes[], void *allocators[]) 216 unsigned int sizes[], void *allocators[])
218{ 217{
diff --git a/drivers/media/platform/exynos4-is/common.c b/drivers/media/platform/exynos4-is/common.c
index 0eb34ecb8ee4..b6716c57b5db 100644
--- a/drivers/media/platform/exynos4-is/common.c
+++ b/drivers/media/platform/exynos4-is/common.c
@@ -10,7 +10,7 @@
10 */ 10 */
11 11
12#include <linux/module.h> 12#include <linux/module.h>
13#include <media/exynos-fimc.h> 13#include <media/drv-intf/exynos-fimc.h>
14#include "common.h" 14#include "common.h"
15 15
16/* Called with the media graph mutex held or entity->stream_count > 0. */ 16/* Called with the media graph mutex held or entity->stream_count > 0. */
diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c
index 99e57320e6f7..0d549a6c8a13 100644
--- a/drivers/media/platform/exynos4-is/fimc-capture.c
+++ b/drivers/media/platform/exynos4-is/fimc-capture.c
@@ -193,7 +193,7 @@ void fimc_capture_irq_handler(struct fimc_dev *fimc, int deq_buf)
193 test_bit(ST_CAPT_RUN, &fimc->state) && deq_buf) { 193 test_bit(ST_CAPT_RUN, &fimc->state) && deq_buf) {
194 v_buf = fimc_active_queue_pop(cap); 194 v_buf = fimc_active_queue_pop(cap);
195 195
196 v4l2_get_timestamp(&v_buf->vb.timestamp); 196 v_buf->vb.vb2_buf.timestamp = ktime_get_ns();
197 v_buf->vb.sequence = cap->frame_count++; 197 v_buf->vb.sequence = cap->frame_count++;
198 198
199 vb2_buffer_done(&v_buf->vb.vb2_buf, VB2_BUF_STATE_DONE); 199 vb2_buffer_done(&v_buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
@@ -338,37 +338,36 @@ int fimc_capture_resume(struct fimc_dev *fimc)
338 338
339} 339}
340 340
341static int queue_setup(struct vb2_queue *vq, const void *parg, 341static int queue_setup(struct vb2_queue *vq,
342 unsigned int *num_buffers, unsigned int *num_planes, 342 unsigned int *num_buffers, unsigned int *num_planes,
343 unsigned int sizes[], void *allocators[]) 343 unsigned int sizes[], void *allocators[])
344{ 344{
345 const struct v4l2_format *pfmt = parg;
346 const struct v4l2_pix_format_mplane *pixm = NULL;
347 struct fimc_ctx *ctx = vq->drv_priv; 345 struct fimc_ctx *ctx = vq->drv_priv;
348 struct fimc_frame *frame = &ctx->d_frame; 346 struct fimc_frame *frame = &ctx->d_frame;
349 struct fimc_fmt *fmt = frame->fmt; 347 struct fimc_fmt *fmt = frame->fmt;
350 unsigned long wh; 348 unsigned long wh = frame->f_width * frame->f_height;
351 int i; 349 int i;
352 350
353 if (pfmt) {
354 pixm = &pfmt->fmt.pix_mp;
355 fmt = fimc_find_format(&pixm->pixelformat, NULL,
356 FMT_FLAGS_CAM | FMT_FLAGS_M2M, -1);
357 wh = pixm->width * pixm->height;
358 } else {
359 wh = frame->f_width * frame->f_height;
360 }
361
362 if (fmt == NULL) 351 if (fmt == NULL)
363 return -EINVAL; 352 return -EINVAL;
364 353
354 if (*num_planes) {
355 if (*num_planes != fmt->memplanes)
356 return -EINVAL;
357 for (i = 0; i < *num_planes; i++) {
358 if (sizes[i] < (wh * fmt->depth[i]) / 8)
359 return -EINVAL;
360 allocators[i] = ctx->fimc_dev->alloc_ctx;
361 }
362 return 0;
363 }
364
365 *num_planes = fmt->memplanes; 365 *num_planes = fmt->memplanes;
366 366
367 for (i = 0; i < fmt->memplanes; i++) { 367 for (i = 0; i < fmt->memplanes; i++) {
368 unsigned int size = (wh * fmt->depth[i]) / 8; 368 unsigned int size = (wh * fmt->depth[i]) / 8;
369 if (pixm) 369
370 sizes[i] = max(size, pixm->plane_fmt[i].sizeimage); 370 if (fimc_fmt_is_user_defined(fmt->color))
371 else if (fimc_fmt_is_user_defined(fmt->color))
372 sizes[i] = frame->payload[i]; 371 sizes[i] = frame->payload[i];
373 else 372 else
374 sizes[i] = max_t(u32, size, frame->payload[i]); 373 sizes[i] = max_t(u32, size, frame->payload[i]);
diff --git a/drivers/media/platform/exynos4-is/fimc-core.h b/drivers/media/platform/exynos4-is/fimc-core.h
index d336fa2916df..6b7435453d2a 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.h
+++ b/drivers/media/platform/exynos4-is/fimc-core.h
@@ -27,7 +27,7 @@
27#include <media/v4l2-device.h> 27#include <media/v4l2-device.h>
28#include <media/v4l2-mem2mem.h> 28#include <media/v4l2-mem2mem.h>
29#include <media/v4l2-mediabus.h> 29#include <media/v4l2-mediabus.h>
30#include <media/exynos-fimc.h> 30#include <media/drv-intf/exynos-fimc.h>
31 31
32#define dbg(fmt, args...) \ 32#define dbg(fmt, args...) \
33 pr_debug("%s:%d: " fmt "\n", __func__, __LINE__, ##args) 33 pr_debug("%s:%d: " fmt "\n", __func__, __LINE__, ##args)
diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c b/drivers/media/platform/exynos4-is/fimc-isp-video.c
index 6e6648446f00..0dd22ec66694 100644
--- a/drivers/media/platform/exynos4-is/fimc-isp-video.c
+++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c
@@ -30,7 +30,7 @@
30#include <media/v4l2-ioctl.h> 30#include <media/v4l2-ioctl.h>
31#include <media/videobuf2-v4l2.h> 31#include <media/videobuf2-v4l2.h>
32#include <media/videobuf2-dma-contig.h> 32#include <media/videobuf2-dma-contig.h>
33#include <media/exynos-fimc.h> 33#include <media/drv-intf/exynos-fimc.h>
34 34
35#include "common.h" 35#include "common.h"
36#include "media-dev.h" 36#include "media-dev.h"
@@ -39,39 +39,36 @@
39#include "fimc-is-param.h" 39#include "fimc-is-param.h"
40 40
41static int isp_video_capture_queue_setup(struct vb2_queue *vq, 41static int isp_video_capture_queue_setup(struct vb2_queue *vq,
42 const void *parg,
43 unsigned int *num_buffers, unsigned int *num_planes, 42 unsigned int *num_buffers, unsigned int *num_planes,
44 unsigned int sizes[], void *allocators[]) 43 unsigned int sizes[], void *allocators[])
45{ 44{
46 const struct v4l2_format *pfmt = parg;
47 struct fimc_isp *isp = vb2_get_drv_priv(vq); 45 struct fimc_isp *isp = vb2_get_drv_priv(vq);
48 struct v4l2_pix_format_mplane *vid_fmt = &isp->video_capture.pixfmt; 46 struct v4l2_pix_format_mplane *vid_fmt = &isp->video_capture.pixfmt;
49 const struct v4l2_pix_format_mplane *pixm = NULL; 47 const struct fimc_fmt *fmt = isp->video_capture.format;
50 const struct fimc_fmt *fmt;
51 unsigned int wh, i; 48 unsigned int wh, i;
52 49
53 if (pfmt) { 50 wh = vid_fmt->width * vid_fmt->height;
54 pixm = &pfmt->fmt.pix_mp;
55 fmt = fimc_isp_find_format(&pixm->pixelformat, NULL, -1);
56 wh = pixm->width * pixm->height;
57 } else {
58 fmt = isp->video_capture.format;
59 wh = vid_fmt->width * vid_fmt->height;
60 }
61 51
62 if (fmt == NULL) 52 if (fmt == NULL)
63 return -EINVAL; 53 return -EINVAL;
64 54
65 *num_buffers = clamp_t(u32, *num_buffers, FIMC_ISP_REQ_BUFS_MIN, 55 *num_buffers = clamp_t(u32, *num_buffers, FIMC_ISP_REQ_BUFS_MIN,
66 FIMC_ISP_REQ_BUFS_MAX); 56 FIMC_ISP_REQ_BUFS_MAX);
57 if (*num_planes) {
58 if (*num_planes != fmt->memplanes)
59 return -EINVAL;
60 for (i = 0; i < *num_planes; i++) {
61 if (sizes[i] < (wh * fmt->depth[i]) / 8)
62 return -EINVAL;
63 allocators[i] = isp->alloc_ctx;
64 }
65 return 0;
66 }
67
67 *num_planes = fmt->memplanes; 68 *num_planes = fmt->memplanes;
68 69
69 for (i = 0; i < fmt->memplanes; i++) { 70 for (i = 0; i < fmt->memplanes; i++) {
70 unsigned int size = (wh * fmt->depth[i]) / 8; 71 sizes[i] = (wh * fmt->depth[i]) / 8;
71 if (pixm)
72 sizes[i] = max(size, pixm->plane_fmt[i].sizeimage);
73 else
74 sizes[i] = size;
75 allocators[i] = isp->alloc_ctx; 72 allocators[i] = isp->alloc_ctx;
76 } 73 }
77 74
@@ -254,7 +251,7 @@ void fimc_isp_video_irq_handler(struct fimc_is *is)
254 buf_index = (is->i2h_cmd.args[1] - 1) % video->buf_count; 251 buf_index = (is->i2h_cmd.args[1] - 1) % video->buf_count;
255 vbuf = &video->buffers[buf_index]->vb; 252 vbuf = &video->buffers[buf_index]->vb;
256 253
257 v4l2_get_timestamp(&vbuf->timestamp); 254 vbuf->vb2_buf.timestamp = ktime_get_ns();
258 vb2_buffer_done(&vbuf->vb2_buf, VB2_BUF_STATE_DONE); 255 vb2_buffer_done(&vbuf->vb2_buf, VB2_BUF_STATE_DONE);
259 256
260 video->buf_mask &= ~BIT(buf_index); 257 video->buf_mask &= ~BIT(buf_index);
diff --git a/drivers/media/platform/exynos4-is/fimc-isp.h b/drivers/media/platform/exynos4-is/fimc-isp.h
index c2d25df85db9..e0686b5f1bf8 100644
--- a/drivers/media/platform/exynos4-is/fimc-isp.h
+++ b/drivers/media/platform/exynos4-is/fimc-isp.h
@@ -24,7 +24,7 @@
24#include <media/videobuf2-v4l2.h> 24#include <media/videobuf2-v4l2.h>
25#include <media/v4l2-device.h> 25#include <media/v4l2-device.h>
26#include <media/v4l2-mediabus.h> 26#include <media/v4l2-mediabus.h>
27#include <media/exynos-fimc.h> 27#include <media/drv-intf/exynos-fimc.h>
28 28
29extern int fimc_isp_debug; 29extern int fimc_isp_debug;
30 30
diff --git a/drivers/media/platform/exynos4-is/fimc-lite-reg.c b/drivers/media/platform/exynos4-is/fimc-lite-reg.c
index 0477716a20db..f0acc550d065 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite-reg.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite-reg.c
@@ -12,7 +12,7 @@
12#include <linux/bitops.h> 12#include <linux/bitops.h>
13#include <linux/delay.h> 13#include <linux/delay.h>
14#include <linux/io.h> 14#include <linux/io.h>
15#include <media/exynos-fimc.h> 15#include <media/drv-intf/exynos-fimc.h>
16 16
17#include "fimc-lite-reg.h" 17#include "fimc-lite-reg.h"
18#include "fimc-lite.h" 18#include "fimc-lite.h"
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c
index 60660c3a5de0..639ee710499e 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -30,7 +30,7 @@
30#include <media/v4l2-mem2mem.h> 30#include <media/v4l2-mem2mem.h>
31#include <media/videobuf2-v4l2.h> 31#include <media/videobuf2-v4l2.h>
32#include <media/videobuf2-dma-contig.h> 32#include <media/videobuf2-dma-contig.h>
33#include <media/exynos-fimc.h> 33#include <media/drv-intf/exynos-fimc.h>
34 34
35#include "common.h" 35#include "common.h"
36#include "fimc-core.h" 36#include "fimc-core.h"
@@ -292,7 +292,7 @@ static irqreturn_t flite_irq_handler(int irq, void *priv)
292 test_bit(ST_FLITE_RUN, &fimc->state) && 292 test_bit(ST_FLITE_RUN, &fimc->state) &&
293 !list_empty(&fimc->active_buf_q)) { 293 !list_empty(&fimc->active_buf_q)) {
294 vbuf = fimc_lite_active_queue_pop(fimc); 294 vbuf = fimc_lite_active_queue_pop(fimc);
295 v4l2_get_timestamp(&vbuf->vb.timestamp); 295 vbuf->vb.vb2_buf.timestamp = ktime_get_ns();
296 vbuf->vb.sequence = fimc->frame_count++; 296 vbuf->vb.sequence = fimc->frame_count++;
297 flite_hw_mask_dma_buffer(fimc, vbuf->index); 297 flite_hw_mask_dma_buffer(fimc, vbuf->index);
298 vb2_buffer_done(&vbuf->vb.vb2_buf, VB2_BUF_STATE_DONE); 298 vb2_buffer_done(&vbuf->vb.vb2_buf, VB2_BUF_STATE_DONE);
@@ -355,37 +355,34 @@ static void stop_streaming(struct vb2_queue *q)
355 fimc_lite_stop_capture(fimc, false); 355 fimc_lite_stop_capture(fimc, false);
356} 356}
357 357
358static int queue_setup(struct vb2_queue *vq, const void *parg, 358static int queue_setup(struct vb2_queue *vq,
359 unsigned int *num_buffers, unsigned int *num_planes, 359 unsigned int *num_buffers, unsigned int *num_planes,
360 unsigned int sizes[], void *allocators[]) 360 unsigned int sizes[], void *allocators[])
361{ 361{
362 const struct v4l2_format *pfmt = parg;
363 const struct v4l2_pix_format_mplane *pixm = NULL;
364 struct fimc_lite *fimc = vq->drv_priv; 362 struct fimc_lite *fimc = vq->drv_priv;
365 struct flite_frame *frame = &fimc->out_frame; 363 struct flite_frame *frame = &fimc->out_frame;
366 const struct fimc_fmt *fmt = frame->fmt; 364 const struct fimc_fmt *fmt = frame->fmt;
367 unsigned long wh; 365 unsigned long wh = frame->f_width * frame->f_height;
368 int i; 366 int i;
369 367
370 if (pfmt) {
371 pixm = &pfmt->fmt.pix_mp;
372 fmt = fimc_lite_find_format(&pixm->pixelformat, NULL, 0, -1);
373 wh = pixm->width * pixm->height;
374 } else {
375 wh = frame->f_width * frame->f_height;
376 }
377
378 if (fmt == NULL) 368 if (fmt == NULL)
379 return -EINVAL; 369 return -EINVAL;
380 370
371 if (*num_planes) {
372 if (*num_planes != fmt->memplanes)
373 return -EINVAL;
374 for (i = 0; i < *num_planes; i++) {
375 if (sizes[i] < (wh * fmt->depth[i]) / 8)
376 return -EINVAL;
377 allocators[i] = fimc->alloc_ctx;
378 }
379 return 0;
380 }
381
381 *num_planes = fmt->memplanes; 382 *num_planes = fmt->memplanes;
382 383
383 for (i = 0; i < fmt->memplanes; i++) { 384 for (i = 0; i < fmt->memplanes; i++) {
384 unsigned int size = (wh * fmt->depth[i]) / 8; 385 sizes[i] = (wh * fmt->depth[i]) / 8;
385 if (pixm)
386 sizes[i] = max(size, pixm->plane_fmt[i].sizeimage);
387 else
388 sizes[i] = size;
389 allocators[i] = fimc->alloc_ctx; 386 allocators[i] = fimc->alloc_ctx;
390 } 387 }
391 388
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.h b/drivers/media/platform/exynos4-is/fimc-lite.h
index b302305dedbe..11690d563e06 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.h
+++ b/drivers/media/platform/exynos4-is/fimc-lite.h
@@ -23,7 +23,7 @@
23#include <media/v4l2-ctrls.h> 23#include <media/v4l2-ctrls.h>
24#include <media/v4l2-device.h> 24#include <media/v4l2-device.h>
25#include <media/v4l2-mediabus.h> 25#include <media/v4l2-mediabus.h>
26#include <media/exynos-fimc.h> 26#include <media/drv-intf/exynos-fimc.h>
27 27
28#define FIMC_LITE_DRV_NAME "exynos-fimc-lite" 28#define FIMC_LITE_DRV_NAME "exynos-fimc-lite"
29#define FLITE_CLK_NAME "flite" 29#define FLITE_CLK_NAME "flite"
diff --git a/drivers/media/platform/exynos4-is/fimc-m2m.c b/drivers/media/platform/exynos4-is/fimc-m2m.c
index 4d1d64a46b21..5aa857c7b631 100644
--- a/drivers/media/platform/exynos4-is/fimc-m2m.c
+++ b/drivers/media/platform/exynos4-is/fimc-m2m.c
@@ -132,7 +132,7 @@ static void fimc_device_run(void *priv)
132 if (ret) 132 if (ret)
133 goto dma_unlock; 133 goto dma_unlock;
134 134
135 dst_vb->timestamp = src_vb->timestamp; 135 dst_vb->vb2_buf.timestamp = src_vb->vb2_buf.timestamp;
136 dst_vb->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 136 dst_vb->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
137 dst_vb->flags |= 137 dst_vb->flags |=
138 src_vb->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 138 src_vb->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
@@ -176,7 +176,7 @@ static void fimc_job_abort(void *priv)
176 fimc_m2m_shutdown(priv); 176 fimc_m2m_shutdown(priv);
177} 177}
178 178
179static int fimc_queue_setup(struct vb2_queue *vq, const void *parg, 179static int fimc_queue_setup(struct vb2_queue *vq,
180 unsigned int *num_buffers, unsigned int *num_planes, 180 unsigned int *num_buffers, unsigned int *num_planes,
181 unsigned int sizes[], void *allocators[]) 181 unsigned int sizes[], void *allocators[])
182{ 182{
diff --git a/drivers/media/platform/exynos4-is/fimc-reg.c b/drivers/media/platform/exynos4-is/fimc-reg.c
index df0cbcb69b6b..0806724553a2 100644
--- a/drivers/media/platform/exynos4-is/fimc-reg.c
+++ b/drivers/media/platform/exynos4-is/fimc-reg.c
@@ -13,7 +13,7 @@
13#include <linux/io.h> 13#include <linux/io.h>
14#include <linux/regmap.h> 14#include <linux/regmap.h>
15 15
16#include <media/exynos-fimc.h> 16#include <media/drv-intf/exynos-fimc.h>
17#include "media-dev.h" 17#include "media-dev.h"
18 18
19#include "fimc-reg.h" 19#include "fimc-reg.h"
diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index 4f5586a4cbff..9481ce3201a2 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -31,7 +31,7 @@
31#include <media/v4l2-ctrls.h> 31#include <media/v4l2-ctrls.h>
32#include <media/v4l2-of.h> 32#include <media/v4l2-of.h>
33#include <media/media-device.h> 33#include <media/media-device.h>
34#include <media/exynos-fimc.h> 34#include <media/drv-intf/exynos-fimc.h>
35 35
36#include "media-dev.h" 36#include "media-dev.h"
37#include "fimc-core.h" 37#include "fimc-core.h"
diff --git a/drivers/media/platform/exynos4-is/media-dev.h b/drivers/media/platform/exynos4-is/media-dev.h
index 03214541f149..93a96126929b 100644
--- a/drivers/media/platform/exynos4-is/media-dev.h
+++ b/drivers/media/platform/exynos4-is/media-dev.h
@@ -19,7 +19,7 @@
19#include <media/media-entity.h> 19#include <media/media-entity.h>
20#include <media/v4l2-device.h> 20#include <media/v4l2-device.h>
21#include <media/v4l2-subdev.h> 21#include <media/v4l2-subdev.h>
22#include <media/exynos-fimc.h> 22#include <media/drv-intf/exynos-fimc.h>
23 23
24#include "fimc-core.h" 24#include "fimc-core.h"
25#include "fimc-lite.h" 25#include "fimc-lite.h"
diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c
index 4b85105dc159..ff5dabf24694 100644
--- a/drivers/media/platform/exynos4-is/mipi-csis.c
+++ b/drivers/media/platform/exynos4-is/mipi-csis.c
@@ -29,7 +29,7 @@
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/spinlock.h> 30#include <linux/spinlock.h>
31#include <linux/videodev2.h> 31#include <linux/videodev2.h>
32#include <media/exynos-fimc.h> 32#include <media/drv-intf/exynos-fimc.h>
33#include <media/v4l2-of.h> 33#include <media/v4l2-of.h>
34#include <media/v4l2-subdev.h> 34#include <media/v4l2-subdev.h>
35 35
diff --git a/drivers/media/platform/m2m-deinterlace.c b/drivers/media/platform/m2m-deinterlace.c
index 29973f9bf8db..7383818c2be6 100644
--- a/drivers/media/platform/m2m-deinterlace.c
+++ b/drivers/media/platform/m2m-deinterlace.c
@@ -207,7 +207,7 @@ static void dma_callback(void *data)
207 src_vb = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx); 207 src_vb = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx);
208 dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx); 208 dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx);
209 209
210 dst_vb->timestamp = src_vb->timestamp; 210 dst_vb->vb2_buf.timestamp = src_vb->vb2_buf.timestamp;
211 dst_vb->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 211 dst_vb->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
212 dst_vb->flags |= 212 dst_vb->flags |=
213 src_vb->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 213 src_vb->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
@@ -798,7 +798,6 @@ struct vb2_dc_conf {
798}; 798};
799 799
800static int deinterlace_queue_setup(struct vb2_queue *vq, 800static int deinterlace_queue_setup(struct vb2_queue *vq,
801 const void *parg,
802 unsigned int *nbuffers, unsigned int *nplanes, 801 unsigned int *nbuffers, unsigned int *nplanes,
803 unsigned int sizes[], void *alloc_ctxs[]) 802 unsigned int sizes[], void *alloc_ctxs[])
804{ 803{
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index aa2b44041d3f..9b878deb1437 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -25,7 +25,7 @@
25#include <media/v4l2-ioctl.h> 25#include <media/v4l2-ioctl.h>
26#include <media/v4l2-ctrls.h> 26#include <media/v4l2-ctrls.h>
27#include <media/v4l2-event.h> 27#include <media/v4l2-event.h>
28#include <media/ov7670.h> 28#include <media/i2c/ov7670.h>
29#include <media/videobuf2-vmalloc.h> 29#include <media/videobuf2-vmalloc.h>
30#include <media/videobuf2-dma-contig.h> 30#include <media/videobuf2-dma-contig.h>
31#include <media/videobuf2-dma-sg.h> 31#include <media/videobuf2-dma-sg.h>
@@ -226,7 +226,7 @@ static void mcam_buffer_done(struct mcam_camera *cam, int frame,
226 vbuf->vb2_buf.planes[0].bytesused = cam->pix_format.sizeimage; 226 vbuf->vb2_buf.planes[0].bytesused = cam->pix_format.sizeimage;
227 vbuf->sequence = cam->buf_seq[frame]; 227 vbuf->sequence = cam->buf_seq[frame];
228 vbuf->field = V4L2_FIELD_NONE; 228 vbuf->field = V4L2_FIELD_NONE;
229 v4l2_get_timestamp(&vbuf->timestamp); 229 vbuf->vb2_buf.timestamp = ktime_get_ns();
230 vb2_set_plane_payload(&vbuf->vb2_buf, 0, cam->pix_format.sizeimage); 230 vb2_set_plane_payload(&vbuf->vb2_buf, 0, cam->pix_format.sizeimage);
231 vb2_buffer_done(&vbuf->vb2_buf, VB2_BUF_STATE_DONE); 231 vb2_buffer_done(&vbuf->vb2_buf, VB2_BUF_STATE_DONE);
232} 232}
@@ -1049,24 +1049,25 @@ static int mcam_read_setup(struct mcam_camera *cam)
1049 */ 1049 */
1050 1050
1051static int mcam_vb_queue_setup(struct vb2_queue *vq, 1051static int mcam_vb_queue_setup(struct vb2_queue *vq,
1052 const void *parg, unsigned int *nbufs, 1052 unsigned int *nbufs,
1053 unsigned int *num_planes, unsigned int sizes[], 1053 unsigned int *num_planes, unsigned int sizes[],
1054 void *alloc_ctxs[]) 1054 void *alloc_ctxs[])
1055{ 1055{
1056 const struct v4l2_format *fmt = parg;
1057 struct mcam_camera *cam = vb2_get_drv_priv(vq); 1056 struct mcam_camera *cam = vb2_get_drv_priv(vq);
1058 int minbufs = (cam->buffer_mode == B_DMA_contig) ? 3 : 2; 1057 int minbufs = (cam->buffer_mode == B_DMA_contig) ? 3 : 2;
1058 unsigned size = cam->pix_format.sizeimage;
1059 1059
1060 if (fmt && fmt->fmt.pix.sizeimage < cam->pix_format.sizeimage)
1061 return -EINVAL;
1062 sizes[0] = fmt ? fmt->fmt.pix.sizeimage : cam->pix_format.sizeimage;
1063 *num_planes = 1; /* Someday we have to support planar formats... */
1064 if (*nbufs < minbufs) 1060 if (*nbufs < minbufs)
1065 *nbufs = minbufs; 1061 *nbufs = minbufs;
1066 if (cam->buffer_mode == B_DMA_contig) 1062 if (cam->buffer_mode == B_DMA_contig)
1067 alloc_ctxs[0] = cam->vb_alloc_ctx; 1063 alloc_ctxs[0] = cam->vb_alloc_ctx;
1068 else if (cam->buffer_mode == B_DMA_sg) 1064 else if (cam->buffer_mode == B_DMA_sg)
1069 alloc_ctxs[0] = cam->vb_alloc_ctx_sg; 1065 alloc_ctxs[0] = cam->vb_alloc_ctx_sg;
1066
1067 if (*num_planes)
1068 return sizes[0] < size ? -EINVAL : 0;
1069 sizes[0] = size;
1070 *num_planes = 1; /* Someday we have to support planar formats... */
1070 return 0; 1071 return 0;
1071} 1072}
1072 1073
diff --git a/drivers/media/platform/marvell-ccic/mmp-driver.c b/drivers/media/platform/marvell-ccic/mmp-driver.c
index b5f165a68566..816f4b6a7b8e 100644
--- a/drivers/media/platform/marvell-ccic/mmp-driver.c
+++ b/drivers/media/platform/marvell-ccic/mmp-driver.c
@@ -18,7 +18,7 @@
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/videodev2.h> 19#include <linux/videodev2.h>
20#include <media/v4l2-device.h> 20#include <media/v4l2-device.h>
21#include <media/mmp-camera.h> 21#include <linux/platform_data/media/mmp-camera.h>
22#include <linux/device.h> 22#include <linux/device.h>
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/gpio.h> 24#include <linux/gpio.h>
diff --git a/drivers/media/platform/mx2_emmaprp.c b/drivers/media/platform/mx2_emmaprp.c
index 03a1b606655d..3c4012d42d69 100644
--- a/drivers/media/platform/mx2_emmaprp.c
+++ b/drivers/media/platform/mx2_emmaprp.c
@@ -375,7 +375,7 @@ static irqreturn_t emmaprp_irq(int irq_emma, void *data)
375 src_vb = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx); 375 src_vb = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx);
376 dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx); 376 dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx);
377 377
378 dst_vb->timestamp = src_vb->timestamp; 378 dst_vb->vb2_buf.timestamp = src_vb->vb2_buf.timestamp;
379 dst_vb->flags &= 379 dst_vb->flags &=
380 ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 380 ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
381 dst_vb->flags |= 381 dst_vb->flags |=
@@ -689,7 +689,6 @@ static const struct v4l2_ioctl_ops emmaprp_ioctl_ops = {
689 * Queue operations 689 * Queue operations
690 */ 690 */
691static int emmaprp_queue_setup(struct vb2_queue *vq, 691static int emmaprp_queue_setup(struct vb2_queue *vq,
692 const void *parg,
693 unsigned int *nbuffers, unsigned int *nplanes, 692 unsigned int *nbuffers, unsigned int *nplanes,
694 unsigned int sizes[], void *alloc_ctxs[]) 693 unsigned int sizes[], void *alloc_ctxs[])
695{ 694{
diff --git a/drivers/media/platform/omap/omap_vout_vrfb.c b/drivers/media/platform/omap/omap_vout_vrfb.c
index c6e252760c62..b8638e4e1627 100644
--- a/drivers/media/platform/omap/omap_vout_vrfb.c
+++ b/drivers/media/platform/omap/omap_vout_vrfb.c
@@ -79,10 +79,12 @@ void omap_vout_free_vrfb_buffers(struct omap_vout_device *vout)
79 int j; 79 int j;
80 80
81 for (j = 0; j < VRFB_NUM_BUFS; j++) { 81 for (j = 0; j < VRFB_NUM_BUFS; j++) {
82 omap_vout_free_buffer(vout->smsshado_virt_addr[j], 82 if (vout->smsshado_virt_addr[j]) {
83 vout->smsshado_size); 83 omap_vout_free_buffer(vout->smsshado_virt_addr[j],
84 vout->smsshado_virt_addr[j] = 0; 84 vout->smsshado_size);
85 vout->smsshado_phy_addr[j] = 0; 85 vout->smsshado_virt_addr[j] = 0;
86 vout->smsshado_phy_addr[j] = 0;
87 }
86 } 88 }
87} 89}
88 90
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c
index f4f591652432..ecadca3e945b 100644
--- a/drivers/media/platform/omap3isp/ispvideo.c
+++ b/drivers/media/platform/omap3isp/ispvideo.c
@@ -320,7 +320,6 @@ isp_video_check_format(struct isp_video *video, struct isp_video_fh *vfh)
320 */ 320 */
321 321
322static int isp_video_queue_setup(struct vb2_queue *queue, 322static int isp_video_queue_setup(struct vb2_queue *queue,
323 const void *parg,
324 unsigned int *count, unsigned int *num_planes, 323 unsigned int *count, unsigned int *num_planes,
325 unsigned int sizes[], void *alloc_ctxs[]) 324 unsigned int sizes[], void *alloc_ctxs[])
326{ 325{
@@ -467,7 +466,7 @@ struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video)
467 list_del(&buf->irqlist); 466 list_del(&buf->irqlist);
468 spin_unlock_irqrestore(&video->irqlock, flags); 467 spin_unlock_irqrestore(&video->irqlock, flags);
469 468
470 v4l2_get_timestamp(&buf->vb.timestamp); 469 buf->vb.vb2_buf.timestamp = ktime_get_ns();
471 470
472 /* Do frame number propagation only if this is the output video node. 471 /* Do frame number propagation only if this is the output video node.
473 * Frame number either comes from the CSI receivers or it gets 472 * Frame number either comes from the CSI receivers or it gets
diff --git a/drivers/media/platform/rcar_jpu.c b/drivers/media/platform/rcar_jpu.c
index f8e3e83c52a2..485f5259acb0 100644
--- a/drivers/media/platform/rcar_jpu.c
+++ b/drivers/media/platform/rcar_jpu.c
@@ -1015,28 +1015,33 @@ error_free:
1015 * ============================================================================ 1015 * ============================================================================
1016 */ 1016 */
1017static int jpu_queue_setup(struct vb2_queue *vq, 1017static int jpu_queue_setup(struct vb2_queue *vq,
1018 const void *parg,
1019 unsigned int *nbuffers, unsigned int *nplanes, 1018 unsigned int *nbuffers, unsigned int *nplanes,
1020 unsigned int sizes[], void *alloc_ctxs[]) 1019 unsigned int sizes[], void *alloc_ctxs[])
1021{ 1020{
1022 const struct v4l2_format *fmt = parg;
1023 struct jpu_ctx *ctx = vb2_get_drv_priv(vq); 1021 struct jpu_ctx *ctx = vb2_get_drv_priv(vq);
1024 struct jpu_q_data *q_data; 1022 struct jpu_q_data *q_data;
1025 unsigned int i; 1023 unsigned int i;
1026 1024
1027 q_data = jpu_get_q_data(ctx, vq->type); 1025 q_data = jpu_get_q_data(ctx, vq->type);
1028 1026
1029 *nplanes = q_data->format.num_planes; 1027 if (*nplanes) {
1028 if (*nplanes != q_data->format.num_planes)
1029 return -EINVAL;
1030 1030
1031 for (i = 0; i < *nplanes; i++) { 1031 for (i = 0; i < *nplanes; i++) {
1032 unsigned int q_size = q_data->format.plane_fmt[i].sizeimage; 1032 unsigned int q_size = q_data->format.plane_fmt[i].sizeimage;
1033 unsigned int f_size = fmt ?
1034 fmt->fmt.pix_mp.plane_fmt[i].sizeimage : 0;
1035 1033
1036 if (fmt && f_size < q_size) 1034 if (sizes[i] < q_size)
1037 return -EINVAL; 1035 return -EINVAL;
1036 alloc_ctxs[i] = ctx->jpu->alloc_ctx;
1037 }
1038 return 0;
1039 }
1038 1040
1039 sizes[i] = fmt ? f_size : q_size; 1041 *nplanes = q_data->format.num_planes;
1042
1043 for (i = 0; i < *nplanes; i++) {
1044 sizes[i] = q_data->format.plane_fmt[i].sizeimage;
1040 alloc_ctxs[i] = ctx->jpu->alloc_ctx; 1045 alloc_ctxs[i] = ctx->jpu->alloc_ctx;
1041 } 1046 }
1042 1047
@@ -1300,17 +1305,17 @@ static int jpu_release(struct file *file)
1300 struct jpu *jpu = video_drvdata(file); 1305 struct jpu *jpu = video_drvdata(file);
1301 struct jpu_ctx *ctx = fh_to_ctx(file->private_data); 1306 struct jpu_ctx *ctx = fh_to_ctx(file->private_data);
1302 1307
1303 mutex_lock(&jpu->mutex);
1304 if (--jpu->ref_count == 0)
1305 clk_disable_unprepare(jpu->clk);
1306 mutex_unlock(&jpu->mutex);
1307
1308 v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); 1308 v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
1309 v4l2_ctrl_handler_free(&ctx->ctrl_handler); 1309 v4l2_ctrl_handler_free(&ctx->ctrl_handler);
1310 v4l2_fh_del(&ctx->fh); 1310 v4l2_fh_del(&ctx->fh);
1311 v4l2_fh_exit(&ctx->fh); 1311 v4l2_fh_exit(&ctx->fh);
1312 kfree(ctx); 1312 kfree(ctx);
1313 1313
1314 mutex_lock(&jpu->mutex);
1315 if (--jpu->ref_count == 0)
1316 clk_disable_unprepare(jpu->clk);
1317 mutex_unlock(&jpu->mutex);
1318
1314 return 0; 1319 return 0;
1315} 1320}
1316 1321
@@ -1560,12 +1565,9 @@ static irqreturn_t jpu_irq_handler(int irq, void *dev_id)
1560 } 1565 }
1561 1566
1562 dst_buf->field = src_buf->field; 1567 dst_buf->field = src_buf->field;
1563 dst_buf->timestamp = src_buf->timestamp; 1568 dst_buf->vb2_buf.timestamp = src_buf->vb2_buf.timestamp;
1564 if (src_buf->flags & V4L2_BUF_FLAG_TIMECODE) 1569 if (src_buf->flags & V4L2_BUF_FLAG_TIMECODE)
1565 dst_buf->timecode = src_buf->timecode; 1570 dst_buf->timecode = src_buf->timecode;
1566 dst_buf->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
1567 dst_buf->flags |= src_buf->flags &
1568 V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
1569 dst_buf->flags = src_buf->flags & 1571 dst_buf->flags = src_buf->flags &
1570 (V4L2_BUF_FLAG_TIMECODE | V4L2_BUF_FLAG_KEYFRAME | 1572 (V4L2_BUF_FLAG_TIMECODE | V4L2_BUF_FLAG_KEYFRAME |
1571 V4L2_BUF_FLAG_PFRAME | V4L2_BUF_FLAG_BFRAME | 1573 V4L2_BUF_FLAG_PFRAME | V4L2_BUF_FLAG_BFRAME |
diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c
index 537b858cb94a..ec3abbed87d9 100644
--- a/drivers/media/platform/s3c-camif/camif-capture.c
+++ b/drivers/media/platform/s3c-camif/camif-capture.c
@@ -338,7 +338,7 @@ irqreturn_t s3c_camif_irq_handler(int irq, void *priv)
338 338
339 if (!WARN_ON(vbuf == NULL)) { 339 if (!WARN_ON(vbuf == NULL)) {
340 /* Dequeue a filled buffer */ 340 /* Dequeue a filled buffer */
341 v4l2_get_timestamp(&vbuf->vb.timestamp); 341 vbuf->vb.vb2_buf.timestamp = ktime_get_ns();
342 vbuf->vb.sequence = vp->frame_sequence++; 342 vbuf->vb.sequence = vp->frame_sequence++;
343 vb2_buffer_done(&vbuf->vb.vb2_buf, VB2_BUF_STATE_DONE); 343 vb2_buffer_done(&vbuf->vb.vb2_buf, VB2_BUF_STATE_DONE);
344 344
@@ -435,39 +435,28 @@ static void stop_streaming(struct vb2_queue *vq)
435 camif_stop_capture(vp); 435 camif_stop_capture(vp);
436} 436}
437 437
438static int queue_setup(struct vb2_queue *vq, const void *parg, 438static int queue_setup(struct vb2_queue *vq,
439 unsigned int *num_buffers, unsigned int *num_planes, 439 unsigned int *num_buffers, unsigned int *num_planes,
440 unsigned int sizes[], void *allocators[]) 440 unsigned int sizes[], void *allocators[])
441{ 441{
442 const struct v4l2_format *pfmt = parg;
443 const struct v4l2_pix_format *pix = NULL;
444 struct camif_vp *vp = vb2_get_drv_priv(vq); 442 struct camif_vp *vp = vb2_get_drv_priv(vq);
445 struct camif_dev *camif = vp->camif; 443 struct camif_dev *camif = vp->camif;
446 struct camif_frame *frame = &vp->out_frame; 444 struct camif_frame *frame = &vp->out_frame;
447 const struct camif_fmt *fmt; 445 const struct camif_fmt *fmt = vp->out_fmt;
448 unsigned int size; 446 unsigned int size;
449 447
450 if (pfmt) { 448 if (fmt == NULL)
451 pix = &pfmt->fmt.pix; 449 return -EINVAL;
452 fmt = s3c_camif_find_format(vp, &pix->pixelformat, -1);
453 if (fmt == NULL)
454 return -EINVAL;
455 size = (pix->width * pix->height * fmt->depth) / 8;
456 } else {
457 fmt = vp->out_fmt;
458 if (fmt == NULL)
459 return -EINVAL;
460 size = (frame->f_width * frame->f_height * fmt->depth) / 8;
461 }
462
463 *num_planes = 1;
464 450
465 if (pix) 451 size = (frame->f_width * frame->f_height * fmt->depth) / 8;
466 sizes[0] = max(size, pix->sizeimage);
467 else
468 sizes[0] = size;
469 allocators[0] = camif->alloc_ctx; 452 allocators[0] = camif->alloc_ctx;
470 453
454 if (*num_planes)
455 return sizes[0] < size ? -EINVAL : 0;
456
457 *num_planes = 1;
458 sizes[0] = size;
459
471 pr_debug("size: %u\n", sizes[0]); 460 pr_debug("size: %u\n", sizes[0]);
472 return 0; 461 return 0;
473} 462}
diff --git a/drivers/media/platform/s3c-camif/camif-core.h b/drivers/media/platform/s3c-camif/camif-core.h
index adaf1969ef63..57cbc3d9725d 100644
--- a/drivers/media/platform/s3c-camif/camif-core.h
+++ b/drivers/media/platform/s3c-camif/camif-core.h
@@ -26,7 +26,7 @@
26#include <media/v4l2-device.h> 26#include <media/v4l2-device.h>
27#include <media/v4l2-mediabus.h> 27#include <media/v4l2-mediabus.h>
28#include <media/videobuf2-v4l2.h> 28#include <media/videobuf2-v4l2.h>
29#include <media/s3c_camif.h> 29#include <media/drv-intf/s3c_camif.h>
30 30
31#define S3C_CAMIF_DRIVER_NAME "s3c-camif" 31#define S3C_CAMIF_DRIVER_NAME "s3c-camif"
32#define CAMIF_REQ_BUFS_MIN 3 32#define CAMIF_REQ_BUFS_MIN 3
diff --git a/drivers/media/platform/s3c-camif/camif-regs.h b/drivers/media/platform/s3c-camif/camif-regs.h
index af2d472ea1dd..5ad36c1c2a5d 100644
--- a/drivers/media/platform/s3c-camif/camif-regs.h
+++ b/drivers/media/platform/s3c-camif/camif-regs.h
@@ -13,7 +13,7 @@
13#define CAMIF_REGS_H_ 13#define CAMIF_REGS_H_
14 14
15#include "camif-core.h" 15#include "camif-core.h"
16#include <media/s3c_camif.h> 16#include <media/drv-intf/s3c_camif.h>
17 17
18/* 18/*
19 * The id argument indicates the processing path: 19 * The id argument indicates the processing path:
diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c
index e1936d9d27da..74bd46ca7942 100644
--- a/drivers/media/platform/s5p-g2d/g2d.c
+++ b/drivers/media/platform/s5p-g2d/g2d.c
@@ -101,7 +101,7 @@ static struct g2d_frame *get_frame(struct g2d_ctx *ctx,
101 } 101 }
102} 102}
103 103
104static int g2d_queue_setup(struct vb2_queue *vq, const void *parg, 104static int g2d_queue_setup(struct vb2_queue *vq,
105 unsigned int *nbuffers, unsigned int *nplanes, 105 unsigned int *nbuffers, unsigned int *nplanes,
106 unsigned int sizes[], void *alloc_ctxs[]) 106 unsigned int sizes[], void *alloc_ctxs[])
107{ 107{
@@ -552,7 +552,7 @@ static irqreturn_t g2d_isr(int irq, void *prv)
552 BUG_ON(dst == NULL); 552 BUG_ON(dst == NULL);
553 553
554 dst->timecode = src->timecode; 554 dst->timecode = src->timecode;
555 dst->timestamp = src->timestamp; 555 dst->vb2_buf.timestamp = src->vb2_buf.timestamp;
556 dst->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 556 dst->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
557 dst->flags |= 557 dst->flags |=
558 src->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 558 src->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index 4a608cbe0fdb..c3b13a630edf 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -2430,7 +2430,6 @@ static struct v4l2_m2m_ops exynos4_jpeg_m2m_ops = {
2430 */ 2430 */
2431 2431
2432static int s5p_jpeg_queue_setup(struct vb2_queue *vq, 2432static int s5p_jpeg_queue_setup(struct vb2_queue *vq,
2433 const void *parg,
2434 unsigned int *nbuffers, unsigned int *nplanes, 2433 unsigned int *nbuffers, unsigned int *nplanes,
2435 unsigned int sizes[], void *alloc_ctxs[]) 2434 unsigned int sizes[], void *alloc_ctxs[])
2436{ 2435{
@@ -2621,7 +2620,7 @@ static irqreturn_t s5p_jpeg_irq(int irq, void *dev_id)
2621 } 2620 }
2622 2621
2623 dst_buf->timecode = src_buf->timecode; 2622 dst_buf->timecode = src_buf->timecode;
2624 dst_buf->timestamp = src_buf->timestamp; 2623 dst_buf->vb2_buf.timestamp = src_buf->vb2_buf.timestamp;
2625 dst_buf->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 2624 dst_buf->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
2626 dst_buf->flags |= 2625 dst_buf->flags |=
2627 src_buf->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 2626 src_buf->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
@@ -2752,7 +2751,7 @@ static irqreturn_t exynos3250_jpeg_irq(int irq, void *dev_id)
2752 dst_buf = v4l2_m2m_dst_buf_remove(curr_ctx->fh.m2m_ctx); 2751 dst_buf = v4l2_m2m_dst_buf_remove(curr_ctx->fh.m2m_ctx);
2753 2752
2754 dst_buf->timecode = src_buf->timecode; 2753 dst_buf->timecode = src_buf->timecode;
2755 dst_buf->timestamp = src_buf->timestamp; 2754 dst_buf->vb2_buf.timestamp = src_buf->vb2_buf.timestamp;
2756 2755
2757 v4l2_m2m_buf_done(src_buf, state); 2756 v4l2_m2m_buf_done(src_buf, state);
2758 if (curr_ctx->mode == S5P_JPEG_ENCODE) 2757 if (curr_ctx->mode == S5P_JPEG_ENCODE)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 3ffe2ecfd5ef..927ab4928779 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -85,6 +85,26 @@ void set_work_bit_irqsave(struct s5p_mfc_ctx *ctx)
85 spin_unlock_irqrestore(&dev->condlock, flags); 85 spin_unlock_irqrestore(&dev->condlock, flags);
86} 86}
87 87
88int s5p_mfc_get_new_ctx(struct s5p_mfc_dev *dev)
89{
90 unsigned long flags;
91 int ctx;
92
93 spin_lock_irqsave(&dev->condlock, flags);
94 ctx = dev->curr_ctx;
95 do {
96 ctx = (ctx + 1) % MFC_NUM_CONTEXTS;
97 if (ctx == dev->curr_ctx) {
98 if (!test_bit(ctx, &dev->ctx_work_bits))
99 ctx = -EAGAIN;
100 break;
101 }
102 } while (!test_bit(ctx, &dev->ctx_work_bits));
103 spin_unlock_irqrestore(&dev->condlock, flags);
104
105 return ctx;
106}
107
88/* Wake up context wait_queue */ 108/* Wake up context wait_queue */
89static void wake_up_ctx(struct s5p_mfc_ctx *ctx, unsigned int reason, 109static void wake_up_ctx(struct s5p_mfc_ctx *ctx, unsigned int reason,
90 unsigned int err) 110 unsigned int err)
@@ -105,6 +125,20 @@ static void wake_up_dev(struct s5p_mfc_dev *dev, unsigned int reason,
105 wake_up(&dev->queue); 125 wake_up(&dev->queue);
106} 126}
107 127
128void s5p_mfc_cleanup_queue(struct list_head *lh, struct vb2_queue *vq)
129{
130 struct s5p_mfc_buf *b;
131 int i;
132
133 while (!list_empty(lh)) {
134 b = list_entry(lh->next, struct s5p_mfc_buf, list);
135 for (i = 0; i < b->b->vb2_buf.num_planes; i++)
136 vb2_set_plane_payload(&b->b->vb2_buf, i, 0);
137 vb2_buffer_done(&b->b->vb2_buf, VB2_BUF_STATE_ERROR);
138 list_del(&b->list);
139 }
140}
141
108static void s5p_mfc_watchdog(unsigned long arg) 142static void s5p_mfc_watchdog(unsigned long arg)
109{ 143{
110 struct s5p_mfc_dev *dev = (struct s5p_mfc_dev *)arg; 144 struct s5p_mfc_dev *dev = (struct s5p_mfc_dev *)arg;
@@ -150,10 +184,8 @@ static void s5p_mfc_watchdog_worker(struct work_struct *work)
150 if (!ctx) 184 if (!ctx)
151 continue; 185 continue;
152 ctx->state = MFCINST_ERROR; 186 ctx->state = MFCINST_ERROR;
153 s5p_mfc_hw_call_void(dev->mfc_ops, cleanup_queue, 187 s5p_mfc_cleanup_queue(&ctx->dst_queue, &ctx->vq_dst);
154 &ctx->dst_queue, &ctx->vq_dst); 188 s5p_mfc_cleanup_queue(&ctx->src_queue, &ctx->vq_src);
155 s5p_mfc_hw_call_void(dev->mfc_ops, cleanup_queue,
156 &ctx->src_queue, &ctx->vq_src);
157 clear_work_bit(ctx); 189 clear_work_bit(ctx);
158 wake_up_ctx(ctx, S5P_MFC_R2H_CMD_ERR_RET, 0); 190 wake_up_ctx(ctx, S5P_MFC_R2H_CMD_ERR_RET, 0);
159 } 191 }
@@ -233,8 +265,8 @@ static void s5p_mfc_handle_frame_copy_time(struct s5p_mfc_ctx *ctx)
233 == dec_y_addr) { 265 == dec_y_addr) {
234 dst_buf->b->timecode = 266 dst_buf->b->timecode =
235 src_buf->b->timecode; 267 src_buf->b->timecode;
236 dst_buf->b->timestamp = 268 dst_buf->b->vb2_buf.timestamp =
237 src_buf->b->timestamp; 269 src_buf->b->vb2_buf.timestamp;
238 dst_buf->b->flags &= 270 dst_buf->b->flags &=
239 ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 271 ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
240 dst_buf->b->flags |= 272 dst_buf->b->flags |=
@@ -327,7 +359,6 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx,
327 unsigned int dst_frame_status; 359 unsigned int dst_frame_status;
328 unsigned int dec_frame_status; 360 unsigned int dec_frame_status;
329 struct s5p_mfc_buf *src_buf; 361 struct s5p_mfc_buf *src_buf;
330 unsigned long flags;
331 unsigned int res_change; 362 unsigned int res_change;
332 363
333 dst_frame_status = s5p_mfc_hw_call(dev->mfc_ops, get_dspl_status, dev) 364 dst_frame_status = s5p_mfc_hw_call(dev->mfc_ops, get_dspl_status, dev)
@@ -343,17 +374,16 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx,
343 if (res_change == S5P_FIMV_RES_INCREASE || 374 if (res_change == S5P_FIMV_RES_INCREASE ||
344 res_change == S5P_FIMV_RES_DECREASE) { 375 res_change == S5P_FIMV_RES_DECREASE) {
345 ctx->state = MFCINST_RES_CHANGE_INIT; 376 ctx->state = MFCINST_RES_CHANGE_INIT;
346 s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); 377 s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
347 wake_up_ctx(ctx, reason, err); 378 wake_up_ctx(ctx, reason, err);
348 WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0); 379 WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
349 s5p_mfc_clock_off(); 380 s5p_mfc_clock_off();
350 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); 381 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
351 return; 382 return;
352 } 383 }
353 if (ctx->dpb_flush_flag) 384 if (ctx->dpb_flush_flag)
354 ctx->dpb_flush_flag = 0; 385 ctx->dpb_flush_flag = 0;
355 386
356 spin_lock_irqsave(&dev->irqlock, flags);
357 /* All frames remaining in the buffer have been extracted */ 387 /* All frames remaining in the buffer have been extracted */
358 if (dst_frame_status == S5P_FIMV_DEC_STATUS_DECODING_EMPTY) { 388 if (dst_frame_status == S5P_FIMV_DEC_STATUS_DECODING_EMPTY) {
359 if (ctx->state == MFCINST_RES_CHANGE_FLUSH) { 389 if (ctx->state == MFCINST_RES_CHANGE_FLUSH) {
@@ -413,11 +443,10 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx,
413 } 443 }
414 } 444 }
415leave_handle_frame: 445leave_handle_frame:
416 spin_unlock_irqrestore(&dev->irqlock, flags);
417 if ((ctx->src_queue_cnt == 0 && ctx->state != MFCINST_FINISHING) 446 if ((ctx->src_queue_cnt == 0 && ctx->state != MFCINST_FINISHING)
418 || ctx->dst_queue_cnt < ctx->pb_count) 447 || ctx->dst_queue_cnt < ctx->pb_count)
419 clear_work_bit(ctx); 448 clear_work_bit(ctx);
420 s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); 449 s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
421 wake_up_ctx(ctx, reason, err); 450 wake_up_ctx(ctx, reason, err);
422 WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0); 451 WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
423 s5p_mfc_clock_off(); 452 s5p_mfc_clock_off();
@@ -425,15 +454,13 @@ leave_handle_frame:
425 if (test_bit(0, &dev->enter_suspend)) 454 if (test_bit(0, &dev->enter_suspend))
426 wake_up_dev(dev, reason, err); 455 wake_up_dev(dev, reason, err);
427 else 456 else
428 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); 457 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
429} 458}
430 459
431/* Error handling for interrupt */ 460/* Error handling for interrupt */
432static void s5p_mfc_handle_error(struct s5p_mfc_dev *dev, 461static void s5p_mfc_handle_error(struct s5p_mfc_dev *dev,
433 struct s5p_mfc_ctx *ctx, unsigned int reason, unsigned int err) 462 struct s5p_mfc_ctx *ctx, unsigned int reason, unsigned int err)
434{ 463{
435 unsigned long flags;
436
437 mfc_err("Interrupt Error: %08x\n", err); 464 mfc_err("Interrupt Error: %08x\n", err);
438 465
439 if (ctx != NULL) { 466 if (ctx != NULL) {
@@ -450,13 +477,9 @@ static void s5p_mfc_handle_error(struct s5p_mfc_dev *dev,
450 clear_work_bit(ctx); 477 clear_work_bit(ctx);
451 ctx->state = MFCINST_ERROR; 478 ctx->state = MFCINST_ERROR;
452 /* Mark all dst buffers as having an error */ 479 /* Mark all dst buffers as having an error */
453 spin_lock_irqsave(&dev->irqlock, flags); 480 s5p_mfc_cleanup_queue(&ctx->dst_queue, &ctx->vq_dst);
454 s5p_mfc_hw_call_void(dev->mfc_ops, cleanup_queue,
455 &ctx->dst_queue, &ctx->vq_dst);
456 /* Mark all src buffers as having an error */ 481 /* Mark all src buffers as having an error */
457 s5p_mfc_hw_call_void(dev->mfc_ops, cleanup_queue, 482 s5p_mfc_cleanup_queue(&ctx->src_queue, &ctx->vq_src);
458 &ctx->src_queue, &ctx->vq_src);
459 spin_unlock_irqrestore(&dev->irqlock, flags);
460 wake_up_ctx(ctx, reason, err); 483 wake_up_ctx(ctx, reason, err);
461 break; 484 break;
462 default: 485 default:
@@ -467,7 +490,7 @@ static void s5p_mfc_handle_error(struct s5p_mfc_dev *dev,
467 } 490 }
468 } 491 }
469 WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0); 492 WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
470 s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); 493 s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
471 s5p_mfc_clock_off(); 494 s5p_mfc_clock_off();
472 wake_up_dev(dev, reason, err); 495 wake_up_dev(dev, reason, err);
473 return; 496 return;
@@ -491,7 +514,7 @@ static void s5p_mfc_handle_seq_done(struct s5p_mfc_ctx *ctx,
491 ctx->img_height = s5p_mfc_hw_call(dev->mfc_ops, get_img_height, 514 ctx->img_height = s5p_mfc_hw_call(dev->mfc_ops, get_img_height,
492 dev); 515 dev);
493 516
494 s5p_mfc_hw_call_void(dev->mfc_ops, dec_calc_dpb_size, ctx); 517 s5p_mfc_hw_call(dev->mfc_ops, dec_calc_dpb_size, ctx);
495 518
496 ctx->pb_count = s5p_mfc_hw_call(dev->mfc_ops, get_dpb_count, 519 ctx->pb_count = s5p_mfc_hw_call(dev->mfc_ops, get_dpb_count,
497 dev); 520 dev);
@@ -518,11 +541,11 @@ static void s5p_mfc_handle_seq_done(struct s5p_mfc_ctx *ctx,
518 ctx->head_processed = 1; 541 ctx->head_processed = 1;
519 } 542 }
520 } 543 }
521 s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); 544 s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
522 clear_work_bit(ctx); 545 clear_work_bit(ctx);
523 WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0); 546 WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
524 s5p_mfc_clock_off(); 547 s5p_mfc_clock_off();
525 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); 548 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
526 wake_up_ctx(ctx, reason, err); 549 wake_up_ctx(ctx, reason, err);
527} 550}
528 551
@@ -532,12 +555,11 @@ static void s5p_mfc_handle_init_buffers(struct s5p_mfc_ctx *ctx,
532{ 555{
533 struct s5p_mfc_buf *src_buf; 556 struct s5p_mfc_buf *src_buf;
534 struct s5p_mfc_dev *dev; 557 struct s5p_mfc_dev *dev;
535 unsigned long flags;
536 558
537 if (ctx == NULL) 559 if (ctx == NULL)
538 return; 560 return;
539 dev = ctx->dev; 561 dev = ctx->dev;
540 s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); 562 s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
541 ctx->int_type = reason; 563 ctx->int_type = reason;
542 ctx->int_err = err; 564 ctx->int_err = err;
543 ctx->int_cond = 1; 565 ctx->int_cond = 1;
@@ -545,7 +567,6 @@ static void s5p_mfc_handle_init_buffers(struct s5p_mfc_ctx *ctx,
545 if (err == 0) { 567 if (err == 0) {
546 ctx->state = MFCINST_RUNNING; 568 ctx->state = MFCINST_RUNNING;
547 if (!ctx->dpb_flush_flag && ctx->head_processed) { 569 if (!ctx->dpb_flush_flag && ctx->head_processed) {
548 spin_lock_irqsave(&dev->irqlock, flags);
549 if (!list_empty(&ctx->src_queue)) { 570 if (!list_empty(&ctx->src_queue)) {
550 src_buf = list_entry(ctx->src_queue.next, 571 src_buf = list_entry(ctx->src_queue.next,
551 struct s5p_mfc_buf, list); 572 struct s5p_mfc_buf, list);
@@ -554,7 +575,6 @@ static void s5p_mfc_handle_init_buffers(struct s5p_mfc_ctx *ctx,
554 vb2_buffer_done(&src_buf->b->vb2_buf, 575 vb2_buffer_done(&src_buf->b->vb2_buf,
555 VB2_BUF_STATE_DONE); 576 VB2_BUF_STATE_DONE);
556 } 577 }
557 spin_unlock_irqrestore(&dev->irqlock, flags);
558 } else { 578 } else {
559 ctx->dpb_flush_flag = 0; 579 ctx->dpb_flush_flag = 0;
560 } 580 }
@@ -563,7 +583,7 @@ static void s5p_mfc_handle_init_buffers(struct s5p_mfc_ctx *ctx,
563 s5p_mfc_clock_off(); 583 s5p_mfc_clock_off();
564 584
565 wake_up(&ctx->queue); 585 wake_up(&ctx->queue);
566 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); 586 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
567 } else { 587 } else {
568 WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0); 588 WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
569 589
@@ -582,7 +602,6 @@ static void s5p_mfc_handle_stream_complete(struct s5p_mfc_ctx *ctx)
582 602
583 ctx->state = MFCINST_FINISHED; 603 ctx->state = MFCINST_FINISHED;
584 604
585 spin_lock(&dev->irqlock);
586 if (!list_empty(&ctx->dst_queue)) { 605 if (!list_empty(&ctx->dst_queue)) {
587 mb_entry = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, 606 mb_entry = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf,
588 list); 607 list);
@@ -591,7 +610,6 @@ static void s5p_mfc_handle_stream_complete(struct s5p_mfc_ctx *ctx)
591 vb2_set_plane_payload(&mb_entry->b->vb2_buf, 0, 0); 610 vb2_set_plane_payload(&mb_entry->b->vb2_buf, 0, 0);
592 vb2_buffer_done(&mb_entry->b->vb2_buf, VB2_BUF_STATE_DONE); 611 vb2_buffer_done(&mb_entry->b->vb2_buf, VB2_BUF_STATE_DONE);
593 } 612 }
594 spin_unlock(&dev->irqlock);
595 613
596 clear_work_bit(ctx); 614 clear_work_bit(ctx);
597 615
@@ -599,7 +617,7 @@ static void s5p_mfc_handle_stream_complete(struct s5p_mfc_ctx *ctx)
599 617
600 s5p_mfc_clock_off(); 618 s5p_mfc_clock_off();
601 wake_up(&ctx->queue); 619 wake_up(&ctx->queue);
602 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); 620 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
603} 621}
604 622
605/* Interrupt processing */ 623/* Interrupt processing */
@@ -613,6 +631,7 @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv)
613 mfc_debug_enter(); 631 mfc_debug_enter();
614 /* Reset the timeout watchdog */ 632 /* Reset the timeout watchdog */
615 atomic_set(&dev->watchdog_cnt, 0); 633 atomic_set(&dev->watchdog_cnt, 0);
634 spin_lock(&dev->irqlock);
616 ctx = dev->ctx[dev->curr_ctx]; 635 ctx = dev->ctx[dev->curr_ctx];
617 /* Get the reason of interrupt and the error code */ 636 /* Get the reason of interrupt and the error code */
618 reason = s5p_mfc_hw_call(dev->mfc_ops, get_int_reason, dev); 637 reason = s5p_mfc_hw_call(dev->mfc_ops, get_int_reason, dev);
@@ -639,15 +658,15 @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv)
639 658
640 if (ctx->state == MFCINST_FINISHING && 659 if (ctx->state == MFCINST_FINISHING &&
641 list_empty(&ctx->ref_queue)) { 660 list_empty(&ctx->ref_queue)) {
642 s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); 661 s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
643 s5p_mfc_handle_stream_complete(ctx); 662 s5p_mfc_handle_stream_complete(ctx);
644 break; 663 break;
645 } 664 }
646 s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); 665 s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
647 wake_up_ctx(ctx, reason, err); 666 wake_up_ctx(ctx, reason, err);
648 WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0); 667 WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
649 s5p_mfc_clock_off(); 668 s5p_mfc_clock_off();
650 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); 669 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
651 } else { 670 } else {
652 s5p_mfc_handle_frame(ctx, reason, err); 671 s5p_mfc_handle_frame(ctx, reason, err);
653 } 672 }
@@ -677,7 +696,7 @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv)
677 case S5P_MFC_R2H_CMD_WAKEUP_RET: 696 case S5P_MFC_R2H_CMD_WAKEUP_RET:
678 if (ctx) 697 if (ctx)
679 clear_work_bit(ctx); 698 clear_work_bit(ctx);
680 s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); 699 s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
681 wake_up_dev(dev, reason, err); 700 wake_up_dev(dev, reason, err);
682 clear_bit(0, &dev->hw_lock); 701 clear_bit(0, &dev->hw_lock);
683 clear_bit(0, &dev->enter_suspend); 702 clear_bit(0, &dev->enter_suspend);
@@ -688,7 +707,7 @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv)
688 break; 707 break;
689 708
690 case S5P_MFC_R2H_CMD_COMPLETE_SEQ_RET: 709 case S5P_MFC_R2H_CMD_COMPLETE_SEQ_RET:
691 s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); 710 s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
692 ctx->int_type = reason; 711 ctx->int_type = reason;
693 ctx->int_err = err; 712 ctx->int_err = err;
694 s5p_mfc_handle_stream_complete(ctx); 713 s5p_mfc_handle_stream_complete(ctx);
@@ -702,12 +721,13 @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv)
702 721
703 default: 722 default:
704 mfc_debug(2, "Unknown int reason\n"); 723 mfc_debug(2, "Unknown int reason\n");
705 s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); 724 s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
706 } 725 }
726 spin_unlock(&dev->irqlock);
707 mfc_debug_leave(); 727 mfc_debug_leave();
708 return IRQ_HANDLED; 728 return IRQ_HANDLED;
709irq_cleanup_hw: 729irq_cleanup_hw:
710 s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); 730 s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
711 ctx->int_type = reason; 731 ctx->int_type = reason;
712 ctx->int_err = err; 732 ctx->int_err = err;
713 ctx->int_cond = 1; 733 ctx->int_cond = 1;
@@ -716,7 +736,8 @@ irq_cleanup_hw:
716 736
717 s5p_mfc_clock_off(); 737 s5p_mfc_clock_off();
718 738
719 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); 739 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
740 spin_unlock(&dev->irqlock);
720 mfc_debug(2, "Exit via irq_cleanup_hw\n"); 741 mfc_debug(2, "Exit via irq_cleanup_hw\n");
721 return IRQ_HANDLED; 742 return IRQ_HANDLED;
722} 743}
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index d1a3f9b1bc44..9eb2481ec292 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -308,7 +308,7 @@ struct s5p_mfc_dev {
308 struct s5p_mfc_pm pm; 308 struct s5p_mfc_pm pm;
309 struct s5p_mfc_variant *variant; 309 struct s5p_mfc_variant *variant;
310 int num_inst; 310 int num_inst;
311 spinlock_t irqlock; /* lock when operating on videobuf2 queues */ 311 spinlock_t irqlock; /* lock when operating on context */
312 spinlock_t condlock; /* lock when changing/checking if a context is 312 spinlock_t condlock; /* lock when changing/checking if a context is
313 ready to be processed */ 313 ready to be processed */
314 struct mutex mfc_mutex; /* video_device lock */ 314 struct mutex mfc_mutex; /* video_device lock */
@@ -653,7 +653,7 @@ struct s5p_mfc_ctx {
653 unsigned int bits; 653 unsigned int bits;
654 } slice_size; 654 } slice_size;
655 655
656 struct s5p_mfc_codec_ops *c_ops; 656 const struct s5p_mfc_codec_ops *c_ops;
657 657
658 struct v4l2_ctrl *ctrls[MFC_MAX_CTRLS]; 658 struct v4l2_ctrl *ctrls[MFC_MAX_CTRLS];
659 struct v4l2_ctrl_handler ctrl_handler; 659 struct v4l2_ctrl_handler ctrl_handler;
@@ -694,13 +694,7 @@ struct mfc_control {
694 694
695/* Macro for making hardware specific calls */ 695/* Macro for making hardware specific calls */
696#define s5p_mfc_hw_call(f, op, args...) \ 696#define s5p_mfc_hw_call(f, op, args...) \
697 ((f && f->op) ? f->op(args) : -ENODEV) 697 ((f && f->op) ? f->op(args) : (typeof(f->op(args)))(-ENODEV))
698
699#define s5p_mfc_hw_call_void(f, op, args...) \
700do { \
701 if (f && f->op) \
702 f->op(args); \
703} while (0)
704 698
705#define fh_to_ctx(__fh) container_of(__fh, struct s5p_mfc_ctx, fh) 699#define fh_to_ctx(__fh) container_of(__fh, struct s5p_mfc_ctx, fh)
706#define ctrl_to_ctx(__ctrl) \ 700#define ctrl_to_ctx(__ctrl) \
@@ -710,6 +704,8 @@ void clear_work_bit(struct s5p_mfc_ctx *ctx);
710void set_work_bit(struct s5p_mfc_ctx *ctx); 704void set_work_bit(struct s5p_mfc_ctx *ctx);
711void clear_work_bit_irqsave(struct s5p_mfc_ctx *ctx); 705void clear_work_bit_irqsave(struct s5p_mfc_ctx *ctx);
712void set_work_bit_irqsave(struct s5p_mfc_ctx *ctx); 706void set_work_bit_irqsave(struct s5p_mfc_ctx *ctx);
707int s5p_mfc_get_new_ctx(struct s5p_mfc_dev *dev);
708void s5p_mfc_cleanup_queue(struct list_head *lh, struct vb2_queue *vq);
713 709
714#define HAS_PORTNUM(dev) (dev ? (dev->variant ? \ 710#define HAS_PORTNUM(dev) (dev ? (dev->variant ? \
715 (dev->variant->port_num ? 1 : 0) : 0) : 0) 711 (dev->variant->port_num ? 1 : 0) : 0) : 0)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index 40d8a03a141d..cc888713b3b6 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -319,7 +319,7 @@ void s5p_mfc_deinit_hw(struct s5p_mfc_dev *dev)
319 s5p_mfc_clock_on(); 319 s5p_mfc_clock_on();
320 320
321 s5p_mfc_reset(dev); 321 s5p_mfc_reset(dev);
322 s5p_mfc_hw_call_void(dev->mfc_ops, release_dev_context_buffer, dev); 322 s5p_mfc_hw_call(dev->mfc_ops, release_dev_context_buffer, dev);
323 323
324 s5p_mfc_clock_off(); 324 s5p_mfc_clock_off();
325} 325}
@@ -468,7 +468,7 @@ int s5p_mfc_open_mfc_inst(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx)
468 } 468 }
469 469
470 set_work_bit_irqsave(ctx); 470 set_work_bit_irqsave(ctx);
471 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); 471 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
472 if (s5p_mfc_wait_for_done_ctx(ctx, 472 if (s5p_mfc_wait_for_done_ctx(ctx,
473 S5P_MFC_R2H_CMD_OPEN_INSTANCE_RET, 0)) { 473 S5P_MFC_R2H_CMD_OPEN_INSTANCE_RET, 0)) {
474 /* Error or timeout */ 474 /* Error or timeout */
@@ -482,9 +482,9 @@ int s5p_mfc_open_mfc_inst(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx)
482 482
483err_free_desc_buf: 483err_free_desc_buf:
484 if (ctx->type == MFCINST_DECODER) 484 if (ctx->type == MFCINST_DECODER)
485 s5p_mfc_hw_call_void(dev->mfc_ops, release_dec_desc_buffer, ctx); 485 s5p_mfc_hw_call(dev->mfc_ops, release_dec_desc_buffer, ctx);
486err_free_inst_buf: 486err_free_inst_buf:
487 s5p_mfc_hw_call_void(dev->mfc_ops, release_instance_buffer, ctx); 487 s5p_mfc_hw_call(dev->mfc_ops, release_instance_buffer, ctx);
488err: 488err:
489 return ret; 489 return ret;
490} 490}
@@ -493,17 +493,17 @@ void s5p_mfc_close_mfc_inst(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx)
493{ 493{
494 ctx->state = MFCINST_RETURN_INST; 494 ctx->state = MFCINST_RETURN_INST;
495 set_work_bit_irqsave(ctx); 495 set_work_bit_irqsave(ctx);
496 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); 496 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
497 /* Wait until instance is returned or timeout occurred */ 497 /* Wait until instance is returned or timeout occurred */
498 if (s5p_mfc_wait_for_done_ctx(ctx, 498 if (s5p_mfc_wait_for_done_ctx(ctx,
499 S5P_MFC_R2H_CMD_CLOSE_INSTANCE_RET, 0)) 499 S5P_MFC_R2H_CMD_CLOSE_INSTANCE_RET, 0))
500 mfc_err("Err returning instance\n"); 500 mfc_err("Err returning instance\n");
501 501
502 /* Free resources */ 502 /* Free resources */
503 s5p_mfc_hw_call_void(dev->mfc_ops, release_codec_buffers, ctx); 503 s5p_mfc_hw_call(dev->mfc_ops, release_codec_buffers, ctx);
504 s5p_mfc_hw_call_void(dev->mfc_ops, release_instance_buffer, ctx); 504 s5p_mfc_hw_call(dev->mfc_ops, release_instance_buffer, ctx);
505 if (ctx->type == MFCINST_DECODER) 505 if (ctx->type == MFCINST_DECODER)
506 s5p_mfc_hw_call_void(dev->mfc_ops, release_dec_desc_buffer, ctx); 506 s5p_mfc_hw_call(dev->mfc_ops, release_dec_desc_buffer, ctx);
507 507
508 ctx->inst_no = MFC_NO_INSTANCE_SET; 508 ctx->inst_no = MFC_NO_INSTANCE_SET;
509 ctx->state = MFCINST_FREE; 509 ctx->state = MFCINST_FREE;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index 8c5060a7534f..f2d6376ce618 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -252,7 +252,7 @@ static int s5p_mfc_ctx_ready(struct s5p_mfc_ctx *ctx)
252 return 0; 252 return 0;
253} 253}
254 254
255static struct s5p_mfc_codec_ops decoder_codec_ops = { 255static const struct s5p_mfc_codec_ops decoder_codec_ops = {
256 .pre_seq_start = NULL, 256 .pre_seq_start = NULL,
257 .post_seq_start = NULL, 257 .post_seq_start = NULL,
258 .pre_frame_start = NULL, 258 .pre_frame_start = NULL,
@@ -523,7 +523,7 @@ static int reqbufs_capture(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx,
523 ret = vb2_reqbufs(&ctx->vq_dst, reqbufs); 523 ret = vb2_reqbufs(&ctx->vq_dst, reqbufs);
524 if (ret) 524 if (ret)
525 goto out; 525 goto out;
526 s5p_mfc_hw_call_void(dev->mfc_ops, release_codec_buffers, ctx); 526 s5p_mfc_hw_call(dev->mfc_ops, release_codec_buffers, ctx);
527 ctx->dst_bufs_cnt = 0; 527 ctx->dst_bufs_cnt = 0;
528 } else if (ctx->capture_state == QUEUE_FREE) { 528 } else if (ctx->capture_state == QUEUE_FREE) {
529 WARN_ON(ctx->dst_bufs_cnt != 0); 529 WARN_ON(ctx->dst_bufs_cnt != 0);
@@ -551,7 +551,7 @@ static int reqbufs_capture(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx,
551 551
552 if (s5p_mfc_ctx_ready(ctx)) 552 if (s5p_mfc_ctx_ready(ctx))
553 set_work_bit_irqsave(ctx); 553 set_work_bit_irqsave(ctx);
554 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); 554 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
555 s5p_mfc_wait_for_done_ctx(ctx, S5P_MFC_R2H_CMD_INIT_BUFFERS_RET, 555 s5p_mfc_wait_for_done_ctx(ctx, S5P_MFC_R2H_CMD_INIT_BUFFERS_RET,
556 0); 556 0);
557 } else { 557 } else {
@@ -831,7 +831,7 @@ static int vidioc_decoder_cmd(struct file *file, void *priv,
831 if (s5p_mfc_ctx_ready(ctx)) 831 if (s5p_mfc_ctx_ready(ctx))
832 set_work_bit_irqsave(ctx); 832 set_work_bit_irqsave(ctx);
833 spin_unlock_irqrestore(&dev->irqlock, flags); 833 spin_unlock_irqrestore(&dev->irqlock, flags);
834 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); 834 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
835 } else { 835 } else {
836 mfc_err("EOS: marking last buffer of stream"); 836 mfc_err("EOS: marking last buffer of stream");
837 buf = list_entry(ctx->src_queue.prev, 837 buf = list_entry(ctx->src_queue.prev,
@@ -888,7 +888,7 @@ static const struct v4l2_ioctl_ops s5p_mfc_dec_ioctl_ops = {
888}; 888};
889 889
890static int s5p_mfc_queue_setup(struct vb2_queue *vq, 890static int s5p_mfc_queue_setup(struct vb2_queue *vq,
891 const void *parg, unsigned int *buf_count, 891 unsigned int *buf_count,
892 unsigned int *plane_count, unsigned int psize[], 892 unsigned int *plane_count, unsigned int psize[],
893 void *allocators[]) 893 void *allocators[])
894{ 894{
@@ -1012,7 +1012,7 @@ static int s5p_mfc_start_streaming(struct vb2_queue *q, unsigned int count)
1012 /* If context is ready then dev = work->data;schedule it to run */ 1012 /* If context is ready then dev = work->data;schedule it to run */
1013 if (s5p_mfc_ctx_ready(ctx)) 1013 if (s5p_mfc_ctx_ready(ctx))
1014 set_work_bit_irqsave(ctx); 1014 set_work_bit_irqsave(ctx);
1015 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); 1015 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
1016 return 0; 1016 return 0;
1017} 1017}
1018 1018
@@ -1023,42 +1023,41 @@ static void s5p_mfc_stop_streaming(struct vb2_queue *q)
1023 struct s5p_mfc_dev *dev = ctx->dev; 1023 struct s5p_mfc_dev *dev = ctx->dev;
1024 int aborted = 0; 1024 int aborted = 0;
1025 1025
1026 spin_lock_irqsave(&dev->irqlock, flags);
1026 if ((ctx->state == MFCINST_FINISHING || 1027 if ((ctx->state == MFCINST_FINISHING ||
1027 ctx->state == MFCINST_RUNNING) && 1028 ctx->state == MFCINST_RUNNING) &&
1028 dev->curr_ctx == ctx->num && dev->hw_lock) { 1029 dev->curr_ctx == ctx->num && dev->hw_lock) {
1029 ctx->state = MFCINST_ABORT; 1030 ctx->state = MFCINST_ABORT;
1031 spin_unlock_irqrestore(&dev->irqlock, flags);
1030 s5p_mfc_wait_for_done_ctx(ctx, 1032 s5p_mfc_wait_for_done_ctx(ctx,
1031 S5P_MFC_R2H_CMD_FRAME_DONE_RET, 0); 1033 S5P_MFC_R2H_CMD_FRAME_DONE_RET, 0);
1032 aborted = 1; 1034 aborted = 1;
1035 spin_lock_irqsave(&dev->irqlock, flags);
1033 } 1036 }
1034 if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { 1037 if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
1035 spin_lock_irqsave(&dev->irqlock, flags); 1038 s5p_mfc_cleanup_queue(&ctx->dst_queue, &ctx->vq_dst);
1036 s5p_mfc_hw_call_void(dev->mfc_ops, cleanup_queue,
1037 &ctx->dst_queue, &ctx->vq_dst);
1038 INIT_LIST_HEAD(&ctx->dst_queue); 1039 INIT_LIST_HEAD(&ctx->dst_queue);
1039 ctx->dst_queue_cnt = 0; 1040 ctx->dst_queue_cnt = 0;
1040 ctx->dpb_flush_flag = 1; 1041 ctx->dpb_flush_flag = 1;
1041 ctx->dec_dst_flag = 0; 1042 ctx->dec_dst_flag = 0;
1042 spin_unlock_irqrestore(&dev->irqlock, flags);
1043 if (IS_MFCV6_PLUS(dev) && (ctx->state == MFCINST_RUNNING)) { 1043 if (IS_MFCV6_PLUS(dev) && (ctx->state == MFCINST_RUNNING)) {
1044 ctx->state = MFCINST_FLUSH; 1044 ctx->state = MFCINST_FLUSH;
1045 set_work_bit_irqsave(ctx); 1045 set_work_bit_irqsave(ctx);
1046 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); 1046 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
1047 spin_unlock_irqrestore(&dev->irqlock, flags);
1047 if (s5p_mfc_wait_for_done_ctx(ctx, 1048 if (s5p_mfc_wait_for_done_ctx(ctx,
1048 S5P_MFC_R2H_CMD_DPB_FLUSH_RET, 0)) 1049 S5P_MFC_R2H_CMD_DPB_FLUSH_RET, 0))
1049 mfc_err("Err flushing buffers\n"); 1050 mfc_err("Err flushing buffers\n");
1051 spin_lock_irqsave(&dev->irqlock, flags);
1050 } 1052 }
1051 } 1053 } else if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
1052 if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { 1054 s5p_mfc_cleanup_queue(&ctx->src_queue, &ctx->vq_src);
1053 spin_lock_irqsave(&dev->irqlock, flags);
1054 s5p_mfc_hw_call_void(dev->mfc_ops, cleanup_queue,
1055 &ctx->src_queue, &ctx->vq_src);
1056 INIT_LIST_HEAD(&ctx->src_queue); 1055 INIT_LIST_HEAD(&ctx->src_queue);
1057 ctx->src_queue_cnt = 0; 1056 ctx->src_queue_cnt = 0;
1058 spin_unlock_irqrestore(&dev->irqlock, flags);
1059 } 1057 }
1060 if (aborted) 1058 if (aborted)
1061 ctx->state = MFCINST_RUNNING; 1059 ctx->state = MFCINST_RUNNING;
1060 spin_unlock_irqrestore(&dev->irqlock, flags);
1062} 1061}
1063 1062
1064 1063
@@ -1091,7 +1090,7 @@ static void s5p_mfc_buf_queue(struct vb2_buffer *vb)
1091 } 1090 }
1092 if (s5p_mfc_ctx_ready(ctx)) 1091 if (s5p_mfc_ctx_ready(ctx))
1093 set_work_bit_irqsave(ctx); 1092 set_work_bit_irqsave(ctx);
1094 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); 1093 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
1095} 1094}
1096 1095
1097static struct vb2_ops s5p_mfc_dec_qops = { 1096static struct vb2_ops s5p_mfc_dec_qops = {
@@ -1104,7 +1103,7 @@ static struct vb2_ops s5p_mfc_dec_qops = {
1104 .buf_queue = s5p_mfc_buf_queue, 1103 .buf_queue = s5p_mfc_buf_queue,
1105}; 1104};
1106 1105
1107struct s5p_mfc_codec_ops *get_dec_codec_ops(void) 1106const struct s5p_mfc_codec_ops *get_dec_codec_ops(void)
1108{ 1107{
1109 return &decoder_codec_ops; 1108 return &decoder_codec_ops;
1110} 1109}
@@ -1119,7 +1118,7 @@ const struct v4l2_ioctl_ops *get_dec_v4l2_ioctl_ops(void)
1119 return &s5p_mfc_dec_ioctl_ops; 1118 return &s5p_mfc_dec_ioctl_ops;
1120} 1119}
1121 1120
1122#define IS_MFC51_PRIV(x) ((V4L2_CTRL_ID2CLASS(x) == V4L2_CTRL_CLASS_MPEG) \ 1121#define IS_MFC51_PRIV(x) ((V4L2_CTRL_ID2WHICH(x) == V4L2_CTRL_CLASS_MPEG) \
1123 && V4L2_CTRL_DRIVER_PRIV(x)) 1122 && V4L2_CTRL_DRIVER_PRIV(x))
1124 1123
1125int s5p_mfc_dec_ctrls_setup(struct s5p_mfc_ctx *ctx) 1124int s5p_mfc_dec_ctrls_setup(struct s5p_mfc_ctx *ctx)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.h b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.h
index d06a7cab5eb1..886628b153f0 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.h
@@ -13,7 +13,7 @@
13#ifndef S5P_MFC_DEC_H_ 13#ifndef S5P_MFC_DEC_H_
14#define S5P_MFC_DEC_H_ 14#define S5P_MFC_DEC_H_
15 15
16struct s5p_mfc_codec_ops *get_dec_codec_ops(void); 16const struct s5p_mfc_codec_ops *get_dec_codec_ops(void);
17struct vb2_ops *get_dec_queue_ops(void); 17struct vb2_ops *get_dec_queue_ops(void);
18const struct v4l2_ioctl_ops *get_dec_v4l2_ioctl_ops(void); 18const struct v4l2_ioctl_ops *get_dec_v4l2_ioctl_ops(void);
19struct s5p_mfc_fmt *get_dec_def_fmt(bool src); 19struct s5p_mfc_fmt *get_dec_def_fmt(bool src);
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 5c678ec9c9f2..0434f02a7175 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -769,15 +769,12 @@ static int enc_pre_seq_start(struct s5p_mfc_ctx *ctx)
769 struct s5p_mfc_buf *dst_mb; 769 struct s5p_mfc_buf *dst_mb;
770 unsigned long dst_addr; 770 unsigned long dst_addr;
771 unsigned int dst_size; 771 unsigned int dst_size;
772 unsigned long flags;
773 772
774 spin_lock_irqsave(&dev->irqlock, flags);
775 dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list); 773 dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list);
776 dst_addr = vb2_dma_contig_plane_dma_addr(&dst_mb->b->vb2_buf, 0); 774 dst_addr = vb2_dma_contig_plane_dma_addr(&dst_mb->b->vb2_buf, 0);
777 dst_size = vb2_plane_size(&dst_mb->b->vb2_buf, 0); 775 dst_size = vb2_plane_size(&dst_mb->b->vb2_buf, 0);
778 s5p_mfc_hw_call_void(dev->mfc_ops, set_enc_stream_buffer, ctx, dst_addr, 776 s5p_mfc_hw_call(dev->mfc_ops, set_enc_stream_buffer, ctx, dst_addr,
779 dst_size); 777 dst_size);
780 spin_unlock_irqrestore(&dev->irqlock, flags);
781 return 0; 778 return 0;
782} 779}
783 780
@@ -786,11 +783,9 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx)
786 struct s5p_mfc_dev *dev = ctx->dev; 783 struct s5p_mfc_dev *dev = ctx->dev;
787 struct s5p_mfc_enc_params *p = &ctx->enc_params; 784 struct s5p_mfc_enc_params *p = &ctx->enc_params;
788 struct s5p_mfc_buf *dst_mb; 785 struct s5p_mfc_buf *dst_mb;
789 unsigned long flags;
790 unsigned int enc_pb_count; 786 unsigned int enc_pb_count;
791 787
792 if (p->seq_hdr_mode == V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE) { 788 if (p->seq_hdr_mode == V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE) {
793 spin_lock_irqsave(&dev->irqlock, flags);
794 if (!list_empty(&ctx->dst_queue)) { 789 if (!list_empty(&ctx->dst_queue)) {
795 dst_mb = list_entry(ctx->dst_queue.next, 790 dst_mb = list_entry(ctx->dst_queue.next,
796 struct s5p_mfc_buf, list); 791 struct s5p_mfc_buf, list);
@@ -802,14 +797,13 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx)
802 vb2_buffer_done(&dst_mb->b->vb2_buf, 797 vb2_buffer_done(&dst_mb->b->vb2_buf,
803 VB2_BUF_STATE_DONE); 798 VB2_BUF_STATE_DONE);
804 } 799 }
805 spin_unlock_irqrestore(&dev->irqlock, flags);
806 } 800 }
807 801
808 if (!IS_MFCV6_PLUS(dev)) { 802 if (!IS_MFCV6_PLUS(dev)) {
809 ctx->state = MFCINST_RUNNING; 803 ctx->state = MFCINST_RUNNING;
810 if (s5p_mfc_ctx_ready(ctx)) 804 if (s5p_mfc_ctx_ready(ctx))
811 set_work_bit_irqsave(ctx); 805 set_work_bit_irqsave(ctx);
812 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); 806 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
813 } else { 807 } else {
814 enc_pb_count = s5p_mfc_hw_call(dev->mfc_ops, 808 enc_pb_count = s5p_mfc_hw_call(dev->mfc_ops,
815 get_enc_dpb_count, dev); 809 get_enc_dpb_count, dev);
@@ -826,25 +820,20 @@ static int enc_pre_frame_start(struct s5p_mfc_ctx *ctx)
826 struct s5p_mfc_dev *dev = ctx->dev; 820 struct s5p_mfc_dev *dev = ctx->dev;
827 struct s5p_mfc_buf *dst_mb; 821 struct s5p_mfc_buf *dst_mb;
828 struct s5p_mfc_buf *src_mb; 822 struct s5p_mfc_buf *src_mb;
829 unsigned long flags;
830 unsigned long src_y_addr, src_c_addr, dst_addr; 823 unsigned long src_y_addr, src_c_addr, dst_addr;
831 unsigned int dst_size; 824 unsigned int dst_size;
832 825
833 spin_lock_irqsave(&dev->irqlock, flags);
834 src_mb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); 826 src_mb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
835 src_y_addr = vb2_dma_contig_plane_dma_addr(&src_mb->b->vb2_buf, 0); 827 src_y_addr = vb2_dma_contig_plane_dma_addr(&src_mb->b->vb2_buf, 0);
836 src_c_addr = vb2_dma_contig_plane_dma_addr(&src_mb->b->vb2_buf, 1); 828 src_c_addr = vb2_dma_contig_plane_dma_addr(&src_mb->b->vb2_buf, 1);
837 s5p_mfc_hw_call_void(dev->mfc_ops, set_enc_frame_buffer, ctx, 829 s5p_mfc_hw_call(dev->mfc_ops, set_enc_frame_buffer, ctx,
838 src_y_addr, src_c_addr); 830 src_y_addr, src_c_addr);
839 spin_unlock_irqrestore(&dev->irqlock, flags);
840 831
841 spin_lock_irqsave(&dev->irqlock, flags);
842 dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list); 832 dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list);
843 dst_addr = vb2_dma_contig_plane_dma_addr(&dst_mb->b->vb2_buf, 0); 833 dst_addr = vb2_dma_contig_plane_dma_addr(&dst_mb->b->vb2_buf, 0);
844 dst_size = vb2_plane_size(&dst_mb->b->vb2_buf, 0); 834 dst_size = vb2_plane_size(&dst_mb->b->vb2_buf, 0);
845 s5p_mfc_hw_call_void(dev->mfc_ops, set_enc_stream_buffer, ctx, dst_addr, 835 s5p_mfc_hw_call(dev->mfc_ops, set_enc_stream_buffer, ctx, dst_addr,
846 dst_size); 836 dst_size);
847 spin_unlock_irqrestore(&dev->irqlock, flags);
848 837
849 return 0; 838 return 0;
850} 839}
@@ -857,7 +846,6 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx)
857 unsigned long mb_y_addr, mb_c_addr; 846 unsigned long mb_y_addr, mb_c_addr;
858 int slice_type; 847 int slice_type;
859 unsigned int strm_size; 848 unsigned int strm_size;
860 unsigned long flags;
861 849
862 slice_type = s5p_mfc_hw_call(dev->mfc_ops, get_enc_slice_type, dev); 850 slice_type = s5p_mfc_hw_call(dev->mfc_ops, get_enc_slice_type, dev);
863 strm_size = s5p_mfc_hw_call(dev->mfc_ops, get_enc_strm_size, dev); 851 strm_size = s5p_mfc_hw_call(dev->mfc_ops, get_enc_strm_size, dev);
@@ -865,9 +853,8 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx)
865 mfc_debug(2, "Encoded stream size: %d\n", strm_size); 853 mfc_debug(2, "Encoded stream size: %d\n", strm_size);
866 mfc_debug(2, "Display order: %d\n", 854 mfc_debug(2, "Display order: %d\n",
867 mfc_read(dev, S5P_FIMV_ENC_SI_PIC_CNT)); 855 mfc_read(dev, S5P_FIMV_ENC_SI_PIC_CNT));
868 spin_lock_irqsave(&dev->irqlock, flags);
869 if (slice_type >= 0) { 856 if (slice_type >= 0) {
870 s5p_mfc_hw_call_void(dev->mfc_ops, get_enc_frame_buffer, ctx, 857 s5p_mfc_hw_call(dev->mfc_ops, get_enc_frame_buffer, ctx,
871 &enc_y_addr, &enc_c_addr); 858 &enc_y_addr, &enc_c_addr);
872 list_for_each_entry(mb_entry, &ctx->src_queue, list) { 859 list_for_each_entry(mb_entry, &ctx->src_queue, list) {
873 mb_y_addr = vb2_dma_contig_plane_dma_addr( 860 mb_y_addr = vb2_dma_contig_plane_dma_addr(
@@ -929,14 +916,13 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx)
929 vb2_set_plane_payload(&mb_entry->b->vb2_buf, 0, strm_size); 916 vb2_set_plane_payload(&mb_entry->b->vb2_buf, 0, strm_size);
930 vb2_buffer_done(&mb_entry->b->vb2_buf, VB2_BUF_STATE_DONE); 917 vb2_buffer_done(&mb_entry->b->vb2_buf, VB2_BUF_STATE_DONE);
931 } 918 }
932 spin_unlock_irqrestore(&dev->irqlock, flags);
933 if ((ctx->src_queue_cnt == 0) || (ctx->dst_queue_cnt == 0)) 919 if ((ctx->src_queue_cnt == 0) || (ctx->dst_queue_cnt == 0))
934 clear_work_bit(ctx); 920 clear_work_bit(ctx);
935 921
936 return 0; 922 return 0;
937} 923}
938 924
939static struct s5p_mfc_codec_ops encoder_codec_ops = { 925static const struct s5p_mfc_codec_ops encoder_codec_ops = {
940 .pre_seq_start = enc_pre_seq_start, 926 .pre_seq_start = enc_pre_seq_start,
941 .post_seq_start = enc_post_seq_start, 927 .post_seq_start = enc_post_seq_start,
942 .pre_frame_start = enc_pre_frame_start, 928 .pre_frame_start = enc_pre_frame_start,
@@ -1120,7 +1106,7 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
1120 pix_fmt_mp->width, pix_fmt_mp->height, 1106 pix_fmt_mp->width, pix_fmt_mp->height,
1121 ctx->img_width, ctx->img_height); 1107 ctx->img_width, ctx->img_height);
1122 1108
1123 s5p_mfc_hw_call_void(dev->mfc_ops, enc_calc_src_size, ctx); 1109 s5p_mfc_hw_call(dev->mfc_ops, enc_calc_src_size, ctx);
1124 pix_fmt_mp->plane_fmt[0].sizeimage = ctx->luma_size; 1110 pix_fmt_mp->plane_fmt[0].sizeimage = ctx->luma_size;
1125 pix_fmt_mp->plane_fmt[0].bytesperline = ctx->buf_width; 1111 pix_fmt_mp->plane_fmt[0].bytesperline = ctx->buf_width;
1126 pix_fmt_mp->plane_fmt[1].sizeimage = ctx->chroma_size; 1112 pix_fmt_mp->plane_fmt[1].sizeimage = ctx->chroma_size;
@@ -1178,7 +1164,7 @@ static int vidioc_reqbufs(struct file *file, void *priv,
1178 if (reqbufs->count == 0) { 1164 if (reqbufs->count == 0) {
1179 mfc_debug(2, "Freeing buffers\n"); 1165 mfc_debug(2, "Freeing buffers\n");
1180 ret = vb2_reqbufs(&ctx->vq_src, reqbufs); 1166 ret = vb2_reqbufs(&ctx->vq_src, reqbufs);
1181 s5p_mfc_hw_call_void(dev->mfc_ops, release_codec_buffers, 1167 s5p_mfc_hw_call(dev->mfc_ops, release_codec_buffers,
1182 ctx); 1168 ctx);
1183 ctx->output_state = QUEUE_FREE; 1169 ctx->output_state = QUEUE_FREE;
1184 return ret; 1170 return ret;
@@ -1741,7 +1727,7 @@ static int vidioc_encoder_cmd(struct file *file, void *priv,
1741 if (s5p_mfc_ctx_ready(ctx)) 1727 if (s5p_mfc_ctx_ready(ctx))
1742 set_work_bit_irqsave(ctx); 1728 set_work_bit_irqsave(ctx);
1743 spin_unlock_irqrestore(&dev->irqlock, flags); 1729 spin_unlock_irqrestore(&dev->irqlock, flags);
1744 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); 1730 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
1745 } else { 1731 } else {
1746 mfc_debug(2, "EOS: marking last buffer of stream\n"); 1732 mfc_debug(2, "EOS: marking last buffer of stream\n");
1747 buf = list_entry(ctx->src_queue.prev, 1733 buf = list_entry(ctx->src_queue.prev,
@@ -1818,7 +1804,6 @@ static int check_vb_with_fmt(struct s5p_mfc_fmt *fmt, struct vb2_buffer *vb)
1818} 1804}
1819 1805
1820static int s5p_mfc_queue_setup(struct vb2_queue *vq, 1806static int s5p_mfc_queue_setup(struct vb2_queue *vq,
1821 const void *parg,
1822 unsigned int *buf_count, unsigned int *plane_count, 1807 unsigned int *buf_count, unsigned int *plane_count,
1823 unsigned int psize[], void *allocators[]) 1808 unsigned int psize[], void *allocators[])
1824{ 1809{
@@ -1969,7 +1954,7 @@ static int s5p_mfc_start_streaming(struct vb2_queue *q, unsigned int count)
1969 /* If context is ready then dev = work->data;schedule it to run */ 1954 /* If context is ready then dev = work->data;schedule it to run */
1970 if (s5p_mfc_ctx_ready(ctx)) 1955 if (s5p_mfc_ctx_ready(ctx))
1971 set_work_bit_irqsave(ctx); 1956 set_work_bit_irqsave(ctx);
1972 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); 1957 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
1973 1958
1974 return 0; 1959 return 0;
1975} 1960}
@@ -1990,15 +1975,13 @@ static void s5p_mfc_stop_streaming(struct vb2_queue *q)
1990 ctx->state = MFCINST_FINISHED; 1975 ctx->state = MFCINST_FINISHED;
1991 spin_lock_irqsave(&dev->irqlock, flags); 1976 spin_lock_irqsave(&dev->irqlock, flags);
1992 if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { 1977 if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
1993 s5p_mfc_hw_call_void(dev->mfc_ops, cleanup_queue, 1978 s5p_mfc_cleanup_queue(&ctx->dst_queue, &ctx->vq_dst);
1994 &ctx->dst_queue, &ctx->vq_dst);
1995 INIT_LIST_HEAD(&ctx->dst_queue); 1979 INIT_LIST_HEAD(&ctx->dst_queue);
1996 ctx->dst_queue_cnt = 0; 1980 ctx->dst_queue_cnt = 0;
1997 } 1981 }
1998 if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { 1982 if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
1999 cleanup_ref_queue(ctx); 1983 cleanup_ref_queue(ctx);
2000 s5p_mfc_hw_call_void(dev->mfc_ops, cleanup_queue, &ctx->src_queue, 1984 s5p_mfc_cleanup_queue(&ctx->src_queue, &ctx->vq_src);
2001 &ctx->vq_src);
2002 INIT_LIST_HEAD(&ctx->src_queue); 1985 INIT_LIST_HEAD(&ctx->src_queue);
2003 ctx->src_queue_cnt = 0; 1986 ctx->src_queue_cnt = 0;
2004 } 1987 }
@@ -2038,7 +2021,7 @@ static void s5p_mfc_buf_queue(struct vb2_buffer *vb)
2038 } 2021 }
2039 if (s5p_mfc_ctx_ready(ctx)) 2022 if (s5p_mfc_ctx_ready(ctx))
2040 set_work_bit_irqsave(ctx); 2023 set_work_bit_irqsave(ctx);
2041 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); 2024 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
2042} 2025}
2043 2026
2044static struct vb2_ops s5p_mfc_enc_qops = { 2027static struct vb2_ops s5p_mfc_enc_qops = {
@@ -2052,7 +2035,7 @@ static struct vb2_ops s5p_mfc_enc_qops = {
2052 .buf_queue = s5p_mfc_buf_queue, 2035 .buf_queue = s5p_mfc_buf_queue,
2053}; 2036};
2054 2037
2055struct s5p_mfc_codec_ops *get_enc_codec_ops(void) 2038const struct s5p_mfc_codec_ops *get_enc_codec_ops(void)
2056{ 2039{
2057 return &encoder_codec_ops; 2040 return &encoder_codec_ops;
2058} 2041}
@@ -2067,7 +2050,7 @@ const struct v4l2_ioctl_ops *get_enc_v4l2_ioctl_ops(void)
2067 return &s5p_mfc_enc_ioctl_ops; 2050 return &s5p_mfc_enc_ioctl_ops;
2068} 2051}
2069 2052
2070#define IS_MFC51_PRIV(x) ((V4L2_CTRL_ID2CLASS(x) == V4L2_CTRL_CLASS_MPEG) \ 2053#define IS_MFC51_PRIV(x) ((V4L2_CTRL_ID2WHICH(x) == V4L2_CTRL_CLASS_MPEG) \
2071 && V4L2_CTRL_DRIVER_PRIV(x)) 2054 && V4L2_CTRL_DRIVER_PRIV(x))
2072 2055
2073int s5p_mfc_enc_ctrls_setup(struct s5p_mfc_ctx *ctx) 2056int s5p_mfc_enc_ctrls_setup(struct s5p_mfc_ctx *ctx)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.h b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.h
index 5118d46b3a9e..d0d42f818832 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.h
@@ -13,7 +13,7 @@
13#ifndef S5P_MFC_ENC_H_ 13#ifndef S5P_MFC_ENC_H_
14#define S5P_MFC_ENC_H_ 14#define S5P_MFC_ENC_H_
15 15
16struct s5p_mfc_codec_ops *get_enc_codec_ops(void); 16const struct s5p_mfc_codec_ops *get_enc_codec_ops(void);
17struct vb2_ops *get_enc_queue_ops(void); 17struct vb2_ops *get_enc_queue_ops(void);
18const struct v4l2_ioctl_ops *get_enc_v4l2_ioctl_ops(void); 18const struct v4l2_ioctl_ops *get_enc_v4l2_ioctl_ops(void);
19struct s5p_mfc_fmt *get_enc_def_fmt(bool src); 19struct s5p_mfc_fmt *get_enc_def_fmt(bool src);
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr.h b/drivers/media/platform/s5p-mfc/s5p_mfc_opr.h
index 77a08b19b46d..b6ac417ab63e 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr.h
@@ -20,254 +20,254 @@
20struct s5p_mfc_regs { 20struct s5p_mfc_regs {
21 21
22 /* codec common registers */ 22 /* codec common registers */
23 volatile void __iomem *risc_on; 23 void __iomem *risc_on;
24 volatile void __iomem *risc2host_int; 24 void __iomem *risc2host_int;
25 volatile void __iomem *host2risc_int; 25 void __iomem *host2risc_int;
26 volatile void __iomem *risc_base_address; 26 void __iomem *risc_base_address;
27 volatile void __iomem *mfc_reset; 27 void __iomem *mfc_reset;
28 volatile void __iomem *host2risc_command; 28 void __iomem *host2risc_command;
29 volatile void __iomem *risc2host_command; 29 void __iomem *risc2host_command;
30 volatile void __iomem *mfc_bus_reset_ctrl; 30 void __iomem *mfc_bus_reset_ctrl;
31 volatile void __iomem *firmware_version; 31 void __iomem *firmware_version;
32 volatile void __iomem *instance_id; 32 void __iomem *instance_id;
33 volatile void __iomem *codec_type; 33 void __iomem *codec_type;
34 volatile void __iomem *context_mem_addr; 34 void __iomem *context_mem_addr;
35 volatile void __iomem *context_mem_size; 35 void __iomem *context_mem_size;
36 volatile void __iomem *pixel_format; 36 void __iomem *pixel_format;
37 volatile void __iomem *metadata_enable; 37 void __iomem *metadata_enable;
38 volatile void __iomem *mfc_version; 38 void __iomem *mfc_version;
39 volatile void __iomem *dbg_info_enable; 39 void __iomem *dbg_info_enable;
40 volatile void __iomem *dbg_buffer_addr; 40 void __iomem *dbg_buffer_addr;
41 volatile void __iomem *dbg_buffer_size; 41 void __iomem *dbg_buffer_size;
42 volatile void __iomem *hed_control; 42 void __iomem *hed_control;
43 volatile void __iomem *mfc_timeout_value; 43 void __iomem *mfc_timeout_value;
44 volatile void __iomem *hed_shared_mem_addr; 44 void __iomem *hed_shared_mem_addr;
45 volatile void __iomem *dis_shared_mem_addr;/* only v7 */ 45 void __iomem *dis_shared_mem_addr;/* only v7 */
46 volatile void __iomem *ret_instance_id; 46 void __iomem *ret_instance_id;
47 volatile void __iomem *error_code; 47 void __iomem *error_code;
48 volatile void __iomem *dbg_buffer_output_size; 48 void __iomem *dbg_buffer_output_size;
49 volatile void __iomem *metadata_status; 49 void __iomem *metadata_status;
50 volatile void __iomem *metadata_addr_mb_info; 50 void __iomem *metadata_addr_mb_info;
51 volatile void __iomem *metadata_size_mb_info; 51 void __iomem *metadata_size_mb_info;
52 volatile void __iomem *dbg_info_stage_counter; 52 void __iomem *dbg_info_stage_counter;
53 53
54 /* decoder registers */ 54 /* decoder registers */
55 volatile void __iomem *d_crc_ctrl; 55 void __iomem *d_crc_ctrl;
56 volatile void __iomem *d_dec_options; 56 void __iomem *d_dec_options;
57 volatile void __iomem *d_display_delay; 57 void __iomem *d_display_delay;
58 volatile void __iomem *d_set_frame_width; 58 void __iomem *d_set_frame_width;
59 volatile void __iomem *d_set_frame_height; 59 void __iomem *d_set_frame_height;
60 volatile void __iomem *d_sei_enable; 60 void __iomem *d_sei_enable;
61 volatile void __iomem *d_min_num_dpb; 61 void __iomem *d_min_num_dpb;
62 volatile void __iomem *d_min_first_plane_dpb_size; 62 void __iomem *d_min_first_plane_dpb_size;
63 volatile void __iomem *d_min_second_plane_dpb_size; 63 void __iomem *d_min_second_plane_dpb_size;
64 volatile void __iomem *d_min_third_plane_dpb_size;/* only v8 */ 64 void __iomem *d_min_third_plane_dpb_size;/* only v8 */
65 volatile void __iomem *d_min_num_mv; 65 void __iomem *d_min_num_mv;
66 volatile void __iomem *d_mvc_num_views; 66 void __iomem *d_mvc_num_views;
67 volatile void __iomem *d_min_num_dis;/* only v7 */ 67 void __iomem *d_min_num_dis;/* only v7 */
68 volatile void __iomem *d_min_first_dis_size;/* only v7 */ 68 void __iomem *d_min_first_dis_size;/* only v7 */
69 volatile void __iomem *d_min_second_dis_size;/* only v7 */ 69 void __iomem *d_min_second_dis_size;/* only v7 */
70 volatile void __iomem *d_min_third_dis_size;/* only v7 */ 70 void __iomem *d_min_third_dis_size;/* only v7 */
71 volatile void __iomem *d_post_filter_luma_dpb0;/* v7 and v8 */ 71 void __iomem *d_post_filter_luma_dpb0;/* v7 and v8 */
72 volatile void __iomem *d_post_filter_luma_dpb1;/* v7 and v8 */ 72 void __iomem *d_post_filter_luma_dpb1;/* v7 and v8 */
73 volatile void __iomem *d_post_filter_luma_dpb2;/* only v7 */ 73 void __iomem *d_post_filter_luma_dpb2;/* only v7 */
74 volatile void __iomem *d_post_filter_chroma_dpb0;/* v7 and v8 */ 74 void __iomem *d_post_filter_chroma_dpb0;/* v7 and v8 */
75 volatile void __iomem *d_post_filter_chroma_dpb1;/* v7 and v8 */ 75 void __iomem *d_post_filter_chroma_dpb1;/* v7 and v8 */
76 volatile void __iomem *d_post_filter_chroma_dpb2;/* only v7 */ 76 void __iomem *d_post_filter_chroma_dpb2;/* only v7 */
77 volatile void __iomem *d_num_dpb; 77 void __iomem *d_num_dpb;
78 volatile void __iomem *d_num_mv; 78 void __iomem *d_num_mv;
79 volatile void __iomem *d_init_buffer_options; 79 void __iomem *d_init_buffer_options;
80 volatile void __iomem *d_first_plane_dpb_stride_size;/* only v8 */ 80 void __iomem *d_first_plane_dpb_stride_size;/* only v8 */
81 volatile void __iomem *d_second_plane_dpb_stride_size;/* only v8 */ 81 void __iomem *d_second_plane_dpb_stride_size;/* only v8 */
82 volatile void __iomem *d_third_plane_dpb_stride_size;/* only v8 */ 82 void __iomem *d_third_plane_dpb_stride_size;/* only v8 */
83 volatile void __iomem *d_first_plane_dpb_size; 83 void __iomem *d_first_plane_dpb_size;
84 volatile void __iomem *d_second_plane_dpb_size; 84 void __iomem *d_second_plane_dpb_size;
85 volatile void __iomem *d_third_plane_dpb_size;/* only v8 */ 85 void __iomem *d_third_plane_dpb_size;/* only v8 */
86 volatile void __iomem *d_mv_buffer_size; 86 void __iomem *d_mv_buffer_size;
87 volatile void __iomem *d_first_plane_dpb; 87 void __iomem *d_first_plane_dpb;
88 volatile void __iomem *d_second_plane_dpb; 88 void __iomem *d_second_plane_dpb;
89 volatile void __iomem *d_third_plane_dpb; 89 void __iomem *d_third_plane_dpb;
90 volatile void __iomem *d_mv_buffer; 90 void __iomem *d_mv_buffer;
91 volatile void __iomem *d_scratch_buffer_addr; 91 void __iomem *d_scratch_buffer_addr;
92 volatile void __iomem *d_scratch_buffer_size; 92 void __iomem *d_scratch_buffer_size;
93 volatile void __iomem *d_metadata_buffer_addr; 93 void __iomem *d_metadata_buffer_addr;
94 volatile void __iomem *d_metadata_buffer_size; 94 void __iomem *d_metadata_buffer_size;
95 volatile void __iomem *d_nal_start_options;/* v7 and v8 */ 95 void __iomem *d_nal_start_options;/* v7 and v8 */
96 volatile void __iomem *d_cpb_buffer_addr; 96 void __iomem *d_cpb_buffer_addr;
97 volatile void __iomem *d_cpb_buffer_size; 97 void __iomem *d_cpb_buffer_size;
98 volatile void __iomem *d_available_dpb_flag_upper; 98 void __iomem *d_available_dpb_flag_upper;
99 volatile void __iomem *d_available_dpb_flag_lower; 99 void __iomem *d_available_dpb_flag_lower;
100 volatile void __iomem *d_cpb_buffer_offset; 100 void __iomem *d_cpb_buffer_offset;
101 volatile void __iomem *d_slice_if_enable; 101 void __iomem *d_slice_if_enable;
102 volatile void __iomem *d_picture_tag; 102 void __iomem *d_picture_tag;
103 volatile void __iomem *d_stream_data_size; 103 void __iomem *d_stream_data_size;
104 volatile void __iomem *d_dynamic_dpb_flag_upper;/* v7 and v8 */ 104 void __iomem *d_dynamic_dpb_flag_upper;/* v7 and v8 */
105 volatile void __iomem *d_dynamic_dpb_flag_lower;/* v7 and v8 */ 105 void __iomem *d_dynamic_dpb_flag_lower;/* v7 and v8 */
106 volatile void __iomem *d_display_frame_width; 106 void __iomem *d_display_frame_width;
107 volatile void __iomem *d_display_frame_height; 107 void __iomem *d_display_frame_height;
108 volatile void __iomem *d_display_status; 108 void __iomem *d_display_status;
109 volatile void __iomem *d_display_first_plane_addr; 109 void __iomem *d_display_first_plane_addr;
110 volatile void __iomem *d_display_second_plane_addr; 110 void __iomem *d_display_second_plane_addr;
111 volatile void __iomem *d_display_third_plane_addr;/* only v8 */ 111 void __iomem *d_display_third_plane_addr;/* only v8 */
112 volatile void __iomem *d_display_frame_type; 112 void __iomem *d_display_frame_type;
113 volatile void __iomem *d_display_crop_info1; 113 void __iomem *d_display_crop_info1;
114 volatile void __iomem *d_display_crop_info2; 114 void __iomem *d_display_crop_info2;
115 volatile void __iomem *d_display_picture_profile; 115 void __iomem *d_display_picture_profile;
116 volatile void __iomem *d_display_luma_crc;/* v7 and v8 */ 116 void __iomem *d_display_luma_crc;/* v7 and v8 */
117 volatile void __iomem *d_display_chroma0_crc;/* v7 and v8 */ 117 void __iomem *d_display_chroma0_crc;/* v7 and v8 */
118 volatile void __iomem *d_display_chroma1_crc;/* only v8 */ 118 void __iomem *d_display_chroma1_crc;/* only v8 */
119 volatile void __iomem *d_display_luma_crc_top;/* only v6 */ 119 void __iomem *d_display_luma_crc_top;/* only v6 */
120 volatile void __iomem *d_display_chroma_crc_top;/* only v6 */ 120 void __iomem *d_display_chroma_crc_top;/* only v6 */
121 volatile void __iomem *d_display_luma_crc_bot;/* only v6 */ 121 void __iomem *d_display_luma_crc_bot;/* only v6 */
122 volatile void __iomem *d_display_chroma_crc_bot;/* only v6 */ 122 void __iomem *d_display_chroma_crc_bot;/* only v6 */
123 volatile void __iomem *d_display_aspect_ratio; 123 void __iomem *d_display_aspect_ratio;
124 volatile void __iomem *d_display_extended_ar; 124 void __iomem *d_display_extended_ar;
125 volatile void __iomem *d_decoded_frame_width; 125 void __iomem *d_decoded_frame_width;
126 volatile void __iomem *d_decoded_frame_height; 126 void __iomem *d_decoded_frame_height;
127 volatile void __iomem *d_decoded_status; 127 void __iomem *d_decoded_status;
128 volatile void __iomem *d_decoded_first_plane_addr; 128 void __iomem *d_decoded_first_plane_addr;
129 volatile void __iomem *d_decoded_second_plane_addr; 129 void __iomem *d_decoded_second_plane_addr;
130 volatile void __iomem *d_decoded_third_plane_addr;/* only v8 */ 130 void __iomem *d_decoded_third_plane_addr;/* only v8 */
131 volatile void __iomem *d_decoded_frame_type; 131 void __iomem *d_decoded_frame_type;
132 volatile void __iomem *d_decoded_crop_info1; 132 void __iomem *d_decoded_crop_info1;
133 volatile void __iomem *d_decoded_crop_info2; 133 void __iomem *d_decoded_crop_info2;
134 volatile void __iomem *d_decoded_picture_profile; 134 void __iomem *d_decoded_picture_profile;
135 volatile void __iomem *d_decoded_nal_size; 135 void __iomem *d_decoded_nal_size;
136 volatile void __iomem *d_decoded_luma_crc; 136 void __iomem *d_decoded_luma_crc;
137 volatile void __iomem *d_decoded_chroma0_crc; 137 void __iomem *d_decoded_chroma0_crc;
138 volatile void __iomem *d_decoded_chroma1_crc;/* only v8 */ 138 void __iomem *d_decoded_chroma1_crc;/* only v8 */
139 volatile void __iomem *d_ret_picture_tag_top; 139 void __iomem *d_ret_picture_tag_top;
140 volatile void __iomem *d_ret_picture_tag_bot; 140 void __iomem *d_ret_picture_tag_bot;
141 volatile void __iomem *d_ret_picture_time_top; 141 void __iomem *d_ret_picture_time_top;
142 volatile void __iomem *d_ret_picture_time_bot; 142 void __iomem *d_ret_picture_time_bot;
143 volatile void __iomem *d_chroma_format; 143 void __iomem *d_chroma_format;
144 volatile void __iomem *d_vc1_info;/* v7 and v8 */ 144 void __iomem *d_vc1_info;/* v7 and v8 */
145 volatile void __iomem *d_mpeg4_info; 145 void __iomem *d_mpeg4_info;
146 volatile void __iomem *d_h264_info; 146 void __iomem *d_h264_info;
147 volatile void __iomem *d_metadata_addr_concealed_mb; 147 void __iomem *d_metadata_addr_concealed_mb;
148 volatile void __iomem *d_metadata_size_concealed_mb; 148 void __iomem *d_metadata_size_concealed_mb;
149 volatile void __iomem *d_metadata_addr_vc1_param; 149 void __iomem *d_metadata_addr_vc1_param;
150 volatile void __iomem *d_metadata_size_vc1_param; 150 void __iomem *d_metadata_size_vc1_param;
151 volatile void __iomem *d_metadata_addr_sei_nal; 151 void __iomem *d_metadata_addr_sei_nal;
152 volatile void __iomem *d_metadata_size_sei_nal; 152 void __iomem *d_metadata_size_sei_nal;
153 volatile void __iomem *d_metadata_addr_vui; 153 void __iomem *d_metadata_addr_vui;
154 volatile void __iomem *d_metadata_size_vui; 154 void __iomem *d_metadata_size_vui;
155 volatile void __iomem *d_metadata_addr_mvcvui;/* v7 and v8 */ 155 void __iomem *d_metadata_addr_mvcvui;/* v7 and v8 */
156 volatile void __iomem *d_metadata_size_mvcvui;/* v7 and v8 */ 156 void __iomem *d_metadata_size_mvcvui;/* v7 and v8 */
157 volatile void __iomem *d_mvc_view_id; 157 void __iomem *d_mvc_view_id;
158 volatile void __iomem *d_frame_pack_sei_avail; 158 void __iomem *d_frame_pack_sei_avail;
159 volatile void __iomem *d_frame_pack_arrgment_id; 159 void __iomem *d_frame_pack_arrgment_id;
160 volatile void __iomem *d_frame_pack_sei_info; 160 void __iomem *d_frame_pack_sei_info;
161 volatile void __iomem *d_frame_pack_grid_pos; 161 void __iomem *d_frame_pack_grid_pos;
162 volatile void __iomem *d_display_recovery_sei_info;/* v7 and v8 */ 162 void __iomem *d_display_recovery_sei_info;/* v7 and v8 */
163 volatile void __iomem *d_decoded_recovery_sei_info;/* v7 and v8 */ 163 void __iomem *d_decoded_recovery_sei_info;/* v7 and v8 */
164 volatile void __iomem *d_display_first_addr;/* only v7 */ 164 void __iomem *d_display_first_addr;/* only v7 */
165 volatile void __iomem *d_display_second_addr;/* only v7 */ 165 void __iomem *d_display_second_addr;/* only v7 */
166 volatile void __iomem *d_display_third_addr;/* only v7 */ 166 void __iomem *d_display_third_addr;/* only v7 */
167 volatile void __iomem *d_decoded_first_addr;/* only v7 */ 167 void __iomem *d_decoded_first_addr;/* only v7 */
168 volatile void __iomem *d_decoded_second_addr;/* only v7 */ 168 void __iomem *d_decoded_second_addr;/* only v7 */
169 volatile void __iomem *d_decoded_third_addr;/* only v7 */ 169 void __iomem *d_decoded_third_addr;/* only v7 */
170 volatile void __iomem *d_used_dpb_flag_upper;/* v7 and v8 */ 170 void __iomem *d_used_dpb_flag_upper;/* v7 and v8 */
171 volatile void __iomem *d_used_dpb_flag_lower;/* v7 and v8 */ 171 void __iomem *d_used_dpb_flag_lower;/* v7 and v8 */
172 172
173 /* encoder registers */ 173 /* encoder registers */
174 volatile void __iomem *e_frame_width; 174 void __iomem *e_frame_width;
175 volatile void __iomem *e_frame_height; 175 void __iomem *e_frame_height;
176 volatile void __iomem *e_cropped_frame_width; 176 void __iomem *e_cropped_frame_width;
177 volatile void __iomem *e_cropped_frame_height; 177 void __iomem *e_cropped_frame_height;
178 volatile void __iomem *e_frame_crop_offset; 178 void __iomem *e_frame_crop_offset;
179 volatile void __iomem *e_enc_options; 179 void __iomem *e_enc_options;
180 volatile void __iomem *e_picture_profile; 180 void __iomem *e_picture_profile;
181 volatile void __iomem *e_vbv_buffer_size; 181 void __iomem *e_vbv_buffer_size;
182 volatile void __iomem *e_vbv_init_delay; 182 void __iomem *e_vbv_init_delay;
183 volatile void __iomem *e_fixed_picture_qp; 183 void __iomem *e_fixed_picture_qp;
184 volatile void __iomem *e_rc_config; 184 void __iomem *e_rc_config;
185 volatile void __iomem *e_rc_qp_bound; 185 void __iomem *e_rc_qp_bound;
186 volatile void __iomem *e_rc_qp_bound_pb;/* v7 and v8 */ 186 void __iomem *e_rc_qp_bound_pb;/* v7 and v8 */
187 volatile void __iomem *e_rc_mode; 187 void __iomem *e_rc_mode;
188 volatile void __iomem *e_mb_rc_config; 188 void __iomem *e_mb_rc_config;
189 volatile void __iomem *e_padding_ctrl; 189 void __iomem *e_padding_ctrl;
190 volatile void __iomem *e_air_threshold; 190 void __iomem *e_air_threshold;
191 volatile void __iomem *e_mv_hor_range; 191 void __iomem *e_mv_hor_range;
192 volatile void __iomem *e_mv_ver_range; 192 void __iomem *e_mv_ver_range;
193 volatile void __iomem *e_num_dpb; 193 void __iomem *e_num_dpb;
194 volatile void __iomem *e_luma_dpb; 194 void __iomem *e_luma_dpb;
195 volatile void __iomem *e_chroma_dpb; 195 void __iomem *e_chroma_dpb;
196 volatile void __iomem *e_me_buffer; 196 void __iomem *e_me_buffer;
197 volatile void __iomem *e_scratch_buffer_addr; 197 void __iomem *e_scratch_buffer_addr;
198 volatile void __iomem *e_scratch_buffer_size; 198 void __iomem *e_scratch_buffer_size;
199 volatile void __iomem *e_tmv_buffer0; 199 void __iomem *e_tmv_buffer0;
200 volatile void __iomem *e_tmv_buffer1; 200 void __iomem *e_tmv_buffer1;
201 volatile void __iomem *e_ir_buffer_addr;/* v7 and v8 */ 201 void __iomem *e_ir_buffer_addr;/* v7 and v8 */
202 volatile void __iomem *e_source_first_plane_addr; 202 void __iomem *e_source_first_plane_addr;
203 volatile void __iomem *e_source_second_plane_addr; 203 void __iomem *e_source_second_plane_addr;
204 volatile void __iomem *e_source_third_plane_addr;/* v7 and v8 */ 204 void __iomem *e_source_third_plane_addr;/* v7 and v8 */
205 volatile void __iomem *e_source_first_plane_stride;/* v7 and v8 */ 205 void __iomem *e_source_first_plane_stride;/* v7 and v8 */
206 volatile void __iomem *e_source_second_plane_stride;/* v7 and v8 */ 206 void __iomem *e_source_second_plane_stride;/* v7 and v8 */
207 volatile void __iomem *e_source_third_plane_stride;/* v7 and v8 */ 207 void __iomem *e_source_third_plane_stride;/* v7 and v8 */
208 volatile void __iomem *e_stream_buffer_addr; 208 void __iomem *e_stream_buffer_addr;
209 volatile void __iomem *e_stream_buffer_size; 209 void __iomem *e_stream_buffer_size;
210 volatile void __iomem *e_roi_buffer_addr; 210 void __iomem *e_roi_buffer_addr;
211 volatile void __iomem *e_param_change; 211 void __iomem *e_param_change;
212 volatile void __iomem *e_ir_size; 212 void __iomem *e_ir_size;
213 volatile void __iomem *e_gop_config; 213 void __iomem *e_gop_config;
214 volatile void __iomem *e_mslice_mode; 214 void __iomem *e_mslice_mode;
215 volatile void __iomem *e_mslice_size_mb; 215 void __iomem *e_mslice_size_mb;
216 volatile void __iomem *e_mslice_size_bits; 216 void __iomem *e_mslice_size_bits;
217 volatile void __iomem *e_frame_insertion; 217 void __iomem *e_frame_insertion;
218 volatile void __iomem *e_rc_frame_rate; 218 void __iomem *e_rc_frame_rate;
219 volatile void __iomem *e_rc_bit_rate; 219 void __iomem *e_rc_bit_rate;
220 volatile void __iomem *e_rc_roi_ctrl; 220 void __iomem *e_rc_roi_ctrl;
221 volatile void __iomem *e_picture_tag; 221 void __iomem *e_picture_tag;
222 volatile void __iomem *e_bit_count_enable; 222 void __iomem *e_bit_count_enable;
223 volatile void __iomem *e_max_bit_count; 223 void __iomem *e_max_bit_count;
224 volatile void __iomem *e_min_bit_count; 224 void __iomem *e_min_bit_count;
225 volatile void __iomem *e_metadata_buffer_addr; 225 void __iomem *e_metadata_buffer_addr;
226 volatile void __iomem *e_metadata_buffer_size; 226 void __iomem *e_metadata_buffer_size;
227 volatile void __iomem *e_encoded_source_first_plane_addr; 227 void __iomem *e_encoded_source_first_plane_addr;
228 volatile void __iomem *e_encoded_source_second_plane_addr; 228 void __iomem *e_encoded_source_second_plane_addr;
229 volatile void __iomem *e_encoded_source_third_plane_addr;/* v7 and v8 */ 229 void __iomem *e_encoded_source_third_plane_addr;/* v7 and v8 */
230 volatile void __iomem *e_stream_size; 230 void __iomem *e_stream_size;
231 volatile void __iomem *e_slice_type; 231 void __iomem *e_slice_type;
232 volatile void __iomem *e_picture_count; 232 void __iomem *e_picture_count;
233 volatile void __iomem *e_ret_picture_tag; 233 void __iomem *e_ret_picture_tag;
234 volatile void __iomem *e_stream_buffer_write_pointer; /* only v6 */ 234 void __iomem *e_stream_buffer_write_pointer; /* only v6 */
235 volatile void __iomem *e_recon_luma_dpb_addr; 235 void __iomem *e_recon_luma_dpb_addr;
236 volatile void __iomem *e_recon_chroma_dpb_addr; 236 void __iomem *e_recon_chroma_dpb_addr;
237 volatile void __iomem *e_metadata_addr_enc_slice; 237 void __iomem *e_metadata_addr_enc_slice;
238 volatile void __iomem *e_metadata_size_enc_slice; 238 void __iomem *e_metadata_size_enc_slice;
239 volatile void __iomem *e_mpeg4_options; 239 void __iomem *e_mpeg4_options;
240 volatile void __iomem *e_mpeg4_hec_period; 240 void __iomem *e_mpeg4_hec_period;
241 volatile void __iomem *e_aspect_ratio; 241 void __iomem *e_aspect_ratio;
242 volatile void __iomem *e_extended_sar; 242 void __iomem *e_extended_sar;
243 volatile void __iomem *e_h264_options; 243 void __iomem *e_h264_options;
244 volatile void __iomem *e_h264_options_2;/* v7 and v8 */ 244 void __iomem *e_h264_options_2;/* v7 and v8 */
245 volatile void __iomem *e_h264_lf_alpha_offset; 245 void __iomem *e_h264_lf_alpha_offset;
246 volatile void __iomem *e_h264_lf_beta_offset; 246 void __iomem *e_h264_lf_beta_offset;
247 volatile void __iomem *e_h264_i_period; 247 void __iomem *e_h264_i_period;
248 volatile void __iomem *e_h264_fmo_slice_grp_map_type; 248 void __iomem *e_h264_fmo_slice_grp_map_type;
249 volatile void __iomem *e_h264_fmo_num_slice_grp_minus1; 249 void __iomem *e_h264_fmo_num_slice_grp_minus1;
250 volatile void __iomem *e_h264_fmo_slice_grp_change_dir; 250 void __iomem *e_h264_fmo_slice_grp_change_dir;
251 volatile void __iomem *e_h264_fmo_slice_grp_change_rate_minus1; 251 void __iomem *e_h264_fmo_slice_grp_change_rate_minus1;
252 volatile void __iomem *e_h264_fmo_run_length_minus1_0; 252 void __iomem *e_h264_fmo_run_length_minus1_0;
253 volatile void __iomem *e_h264_aso_slice_order_0; 253 void __iomem *e_h264_aso_slice_order_0;
254 volatile void __iomem *e_h264_chroma_qp_offset; 254 void __iomem *e_h264_chroma_qp_offset;
255 volatile void __iomem *e_h264_num_t_layer; 255 void __iomem *e_h264_num_t_layer;
256 volatile void __iomem *e_h264_hierarchical_qp_layer0; 256 void __iomem *e_h264_hierarchical_qp_layer0;
257 volatile void __iomem *e_h264_frame_packing_sei_info; 257 void __iomem *e_h264_frame_packing_sei_info;
258 volatile void __iomem *e_h264_nal_control;/* v7 and v8 */ 258 void __iomem *e_h264_nal_control;/* v7 and v8 */
259 volatile void __iomem *e_mvc_frame_qp_view1; 259 void __iomem *e_mvc_frame_qp_view1;
260 volatile void __iomem *e_mvc_rc_bit_rate_view1; 260 void __iomem *e_mvc_rc_bit_rate_view1;
261 volatile void __iomem *e_mvc_rc_qbound_view1; 261 void __iomem *e_mvc_rc_qbound_view1;
262 volatile void __iomem *e_mvc_rc_mode_view1; 262 void __iomem *e_mvc_rc_mode_view1;
263 volatile void __iomem *e_mvc_inter_view_prediction_on; 263 void __iomem *e_mvc_inter_view_prediction_on;
264 volatile void __iomem *e_vp8_options;/* v7 and v8 */ 264 void __iomem *e_vp8_options;/* v7 and v8 */
265 volatile void __iomem *e_vp8_filter_options;/* v7 and v8 */ 265 void __iomem *e_vp8_filter_options;/* v7 and v8 */
266 volatile void __iomem *e_vp8_golden_frame_option;/* v7 and v8 */ 266 void __iomem *e_vp8_golden_frame_option;/* v7 and v8 */
267 volatile void __iomem *e_vp8_num_t_layer;/* v7 and v8 */ 267 void __iomem *e_vp8_num_t_layer;/* v7 and v8 */
268 volatile void __iomem *e_vp8_hierarchical_qp_layer0;/* v7 and v8 */ 268 void __iomem *e_vp8_hierarchical_qp_layer0;/* v7 and v8 */
269 volatile void __iomem *e_vp8_hierarchical_qp_layer1;/* v7 and v8 */ 269 void __iomem *e_vp8_hierarchical_qp_layer1;/* v7 and v8 */
270 volatile void __iomem *e_vp8_hierarchical_qp_layer2;/* v7 and v8 */ 270 void __iomem *e_vp8_hierarchical_qp_layer2;/* v7 and v8 */
271}; 271};
272 272
273struct s5p_mfc_hw_ops { 273struct s5p_mfc_hw_ops {
@@ -281,28 +281,14 @@ struct s5p_mfc_hw_ops {
281 void (*release_dev_context_buffer)(struct s5p_mfc_dev *dev); 281 void (*release_dev_context_buffer)(struct s5p_mfc_dev *dev);
282 void (*dec_calc_dpb_size)(struct s5p_mfc_ctx *ctx); 282 void (*dec_calc_dpb_size)(struct s5p_mfc_ctx *ctx);
283 void (*enc_calc_src_size)(struct s5p_mfc_ctx *ctx); 283 void (*enc_calc_src_size)(struct s5p_mfc_ctx *ctx);
284 int (*set_dec_stream_buffer)(struct s5p_mfc_ctx *ctx,
285 int buf_addr, unsigned int start_num_byte,
286 unsigned int buf_size);
287 int (*set_dec_frame_buffer)(struct s5p_mfc_ctx *ctx);
288 int (*set_enc_stream_buffer)(struct s5p_mfc_ctx *ctx, 284 int (*set_enc_stream_buffer)(struct s5p_mfc_ctx *ctx,
289 unsigned long addr, unsigned int size); 285 unsigned long addr, unsigned int size);
290 void (*set_enc_frame_buffer)(struct s5p_mfc_ctx *ctx, 286 void (*set_enc_frame_buffer)(struct s5p_mfc_ctx *ctx,
291 unsigned long y_addr, unsigned long c_addr); 287 unsigned long y_addr, unsigned long c_addr);
292 void (*get_enc_frame_buffer)(struct s5p_mfc_ctx *ctx, 288 void (*get_enc_frame_buffer)(struct s5p_mfc_ctx *ctx,
293 unsigned long *y_addr, unsigned long *c_addr); 289 unsigned long *y_addr, unsigned long *c_addr);
294 int (*set_enc_ref_buffer)(struct s5p_mfc_ctx *ctx);
295 int (*init_decode)(struct s5p_mfc_ctx *ctx);
296 int (*init_encode)(struct s5p_mfc_ctx *ctx);
297 int (*encode_one_frame)(struct s5p_mfc_ctx *ctx);
298 void (*try_run)(struct s5p_mfc_dev *dev); 290 void (*try_run)(struct s5p_mfc_dev *dev);
299 void (*cleanup_queue)(struct list_head *lh,
300 struct vb2_queue *vq);
301 void (*clear_int_flags)(struct s5p_mfc_dev *dev); 291 void (*clear_int_flags)(struct s5p_mfc_dev *dev);
302 void (*write_info)(struct s5p_mfc_ctx *ctx, unsigned int data,
303 unsigned int ofs);
304 unsigned int (*read_info)(struct s5p_mfc_ctx *ctx,
305 unsigned long ofs);
306 int (*get_dspl_y_adr)(struct s5p_mfc_dev *dev); 292 int (*get_dspl_y_adr)(struct s5p_mfc_dev *dev);
307 int (*get_dec_y_adr)(struct s5p_mfc_dev *dev); 293 int (*get_dec_y_adr)(struct s5p_mfc_dev *dev);
308 int (*get_dspl_status)(struct s5p_mfc_dev *dev); 294 int (*get_dspl_status)(struct s5p_mfc_dev *dev);
@@ -313,7 +299,6 @@ struct s5p_mfc_hw_ops {
313 int (*get_int_reason)(struct s5p_mfc_dev *dev); 299 int (*get_int_reason)(struct s5p_mfc_dev *dev);
314 int (*get_int_err)(struct s5p_mfc_dev *dev); 300 int (*get_int_err)(struct s5p_mfc_dev *dev);
315 int (*err_dec)(unsigned int err); 301 int (*err_dec)(unsigned int err);
316 int (*err_dspl)(unsigned int err);
317 int (*get_img_width)(struct s5p_mfc_dev *dev); 302 int (*get_img_width)(struct s5p_mfc_dev *dev);
318 int (*get_img_height)(struct s5p_mfc_dev *dev); 303 int (*get_img_height)(struct s5p_mfc_dev *dev);
319 int (*get_dpb_count)(struct s5p_mfc_dev *dev); 304 int (*get_dpb_count)(struct s5p_mfc_dev *dev);
@@ -322,10 +307,6 @@ struct s5p_mfc_hw_ops {
322 int (*get_enc_strm_size)(struct s5p_mfc_dev *dev); 307 int (*get_enc_strm_size)(struct s5p_mfc_dev *dev);
323 int (*get_enc_slice_type)(struct s5p_mfc_dev *dev); 308 int (*get_enc_slice_type)(struct s5p_mfc_dev *dev);
324 int (*get_enc_dpb_count)(struct s5p_mfc_dev *dev); 309 int (*get_enc_dpb_count)(struct s5p_mfc_dev *dev);
325 int (*get_enc_pic_count)(struct s5p_mfc_dev *dev);
326 int (*get_sei_avail_status)(struct s5p_mfc_ctx *ctx);
327 int (*get_mvc_num_views)(struct s5p_mfc_dev *dev);
328 int (*get_mvc_view_id)(struct s5p_mfc_dev *dev);
329 unsigned int (*get_pic_type_top)(struct s5p_mfc_ctx *ctx); 310 unsigned int (*get_pic_type_top)(struct s5p_mfc_ctx *ctx);
330 unsigned int (*get_pic_type_bot)(struct s5p_mfc_ctx *ctx); 311 unsigned int (*get_pic_type_bot)(struct s5p_mfc_ctx *ctx);
331 unsigned int (*get_crop_info_h)(struct s5p_mfc_ctx *ctx); 312 unsigned int (*get_crop_info_h)(struct s5p_mfc_ctx *ctx);
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
index 873c933bc7d4..81e1e4ce6c24 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
@@ -1153,27 +1153,6 @@ static int s5p_mfc_encode_one_frame_v5(struct s5p_mfc_ctx *ctx)
1153 return 0; 1153 return 0;
1154} 1154}
1155 1155
1156static int s5p_mfc_get_new_ctx(struct s5p_mfc_dev *dev)
1157{
1158 unsigned long flags;
1159 int new_ctx;
1160 int cnt;
1161
1162 spin_lock_irqsave(&dev->condlock, flags);
1163 new_ctx = (dev->curr_ctx + 1) % MFC_NUM_CONTEXTS;
1164 cnt = 0;
1165 while (!test_bit(new_ctx, &dev->ctx_work_bits)) {
1166 new_ctx = (new_ctx + 1) % MFC_NUM_CONTEXTS;
1167 if (++cnt > MFC_NUM_CONTEXTS) {
1168 /* No contexts to run */
1169 spin_unlock_irqrestore(&dev->condlock, flags);
1170 return -EAGAIN;
1171 }
1172 }
1173 spin_unlock_irqrestore(&dev->condlock, flags);
1174 return new_ctx;
1175}
1176
1177static void s5p_mfc_run_res_change(struct s5p_mfc_ctx *ctx) 1156static void s5p_mfc_run_res_change(struct s5p_mfc_ctx *ctx)
1178{ 1157{
1179 struct s5p_mfc_dev *dev = ctx->dev; 1158 struct s5p_mfc_dev *dev = ctx->dev;
@@ -1187,7 +1166,6 @@ static int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx, int last_frame)
1187{ 1166{
1188 struct s5p_mfc_dev *dev = ctx->dev; 1167 struct s5p_mfc_dev *dev = ctx->dev;
1189 struct s5p_mfc_buf *temp_vb; 1168 struct s5p_mfc_buf *temp_vb;
1190 unsigned long flags;
1191 1169
1192 if (ctx->state == MFCINST_FINISHING) { 1170 if (ctx->state == MFCINST_FINISHING) {
1193 last_frame = MFC_DEC_LAST_FRAME; 1171 last_frame = MFC_DEC_LAST_FRAME;
@@ -1197,11 +1175,9 @@ static int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx, int last_frame)
1197 return 0; 1175 return 0;
1198 } 1176 }
1199 1177
1200 spin_lock_irqsave(&dev->irqlock, flags);
1201 /* Frames are being decoded */ 1178 /* Frames are being decoded */
1202 if (list_empty(&ctx->src_queue)) { 1179 if (list_empty(&ctx->src_queue)) {
1203 mfc_debug(2, "No src buffers\n"); 1180 mfc_debug(2, "No src buffers\n");
1204 spin_unlock_irqrestore(&dev->irqlock, flags);
1205 return -EAGAIN; 1181 return -EAGAIN;
1206 } 1182 }
1207 /* Get the next source buffer */ 1183 /* Get the next source buffer */
@@ -1210,7 +1186,6 @@ static int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx, int last_frame)
1210 s5p_mfc_set_dec_stream_buffer_v5(ctx, 1186 s5p_mfc_set_dec_stream_buffer_v5(ctx,
1211 vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf, 0), 1187 vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf, 0),
1212 ctx->consumed_stream, temp_vb->b->vb2_buf.planes[0].bytesused); 1188 ctx->consumed_stream, temp_vb->b->vb2_buf.planes[0].bytesused);
1213 spin_unlock_irqrestore(&dev->irqlock, flags);
1214 dev->curr_ctx = ctx->num; 1189 dev->curr_ctx = ctx->num;
1215 if (temp_vb->b->vb2_buf.planes[0].bytesused == 0) { 1190 if (temp_vb->b->vb2_buf.planes[0].bytesused == 0) {
1216 last_frame = MFC_DEC_LAST_FRAME; 1191 last_frame = MFC_DEC_LAST_FRAME;
@@ -1224,21 +1199,17 @@ static int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx, int last_frame)
1224static int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx) 1199static int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx)
1225{ 1200{
1226 struct s5p_mfc_dev *dev = ctx->dev; 1201 struct s5p_mfc_dev *dev = ctx->dev;
1227 unsigned long flags;
1228 struct s5p_mfc_buf *dst_mb; 1202 struct s5p_mfc_buf *dst_mb;
1229 struct s5p_mfc_buf *src_mb; 1203 struct s5p_mfc_buf *src_mb;
1230 unsigned long src_y_addr, src_c_addr, dst_addr; 1204 unsigned long src_y_addr, src_c_addr, dst_addr;
1231 unsigned int dst_size; 1205 unsigned int dst_size;
1232 1206
1233 spin_lock_irqsave(&dev->irqlock, flags);
1234 if (list_empty(&ctx->src_queue) && ctx->state != MFCINST_FINISHING) { 1207 if (list_empty(&ctx->src_queue) && ctx->state != MFCINST_FINISHING) {
1235 mfc_debug(2, "no src buffers\n"); 1208 mfc_debug(2, "no src buffers\n");
1236 spin_unlock_irqrestore(&dev->irqlock, flags);
1237 return -EAGAIN; 1209 return -EAGAIN;
1238 } 1210 }
1239 if (list_empty(&ctx->dst_queue)) { 1211 if (list_empty(&ctx->dst_queue)) {
1240 mfc_debug(2, "no dst buffers\n"); 1212 mfc_debug(2, "no dst buffers\n");
1241 spin_unlock_irqrestore(&dev->irqlock, flags);
1242 return -EAGAIN; 1213 return -EAGAIN;
1243 } 1214 }
1244 if (list_empty(&ctx->src_queue)) { 1215 if (list_empty(&ctx->src_queue)) {
@@ -1270,7 +1241,6 @@ static int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx)
1270 dst_addr = vb2_dma_contig_plane_dma_addr(&dst_mb->b->vb2_buf, 0); 1241 dst_addr = vb2_dma_contig_plane_dma_addr(&dst_mb->b->vb2_buf, 0);
1271 dst_size = vb2_plane_size(&dst_mb->b->vb2_buf, 0); 1242 dst_size = vb2_plane_size(&dst_mb->b->vb2_buf, 0);
1272 s5p_mfc_set_enc_stream_buffer_v5(ctx, dst_addr, dst_size); 1243 s5p_mfc_set_enc_stream_buffer_v5(ctx, dst_addr, dst_size);
1273 spin_unlock_irqrestore(&dev->irqlock, flags);
1274 dev->curr_ctx = ctx->num; 1244 dev->curr_ctx = ctx->num;
1275 mfc_debug(2, "encoding buffer with index=%d state=%d\n", 1245 mfc_debug(2, "encoding buffer with index=%d state=%d\n",
1276 src_mb ? src_mb->b->vb2_buf.index : -1, ctx->state); 1246 src_mb ? src_mb->b->vb2_buf.index : -1, ctx->state);
@@ -1281,11 +1251,9 @@ static int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx)
1281static void s5p_mfc_run_init_dec(struct s5p_mfc_ctx *ctx) 1251static void s5p_mfc_run_init_dec(struct s5p_mfc_ctx *ctx)
1282{ 1252{
1283 struct s5p_mfc_dev *dev = ctx->dev; 1253 struct s5p_mfc_dev *dev = ctx->dev;
1284 unsigned long flags;
1285 struct s5p_mfc_buf *temp_vb; 1254 struct s5p_mfc_buf *temp_vb;
1286 1255
1287 /* Initializing decoding - parsing header */ 1256 /* Initializing decoding - parsing header */
1288 spin_lock_irqsave(&dev->irqlock, flags);
1289 mfc_debug(2, "Preparing to init decoding\n"); 1257 mfc_debug(2, "Preparing to init decoding\n");
1290 temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); 1258 temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
1291 s5p_mfc_set_dec_desc_buffer(ctx); 1259 s5p_mfc_set_dec_desc_buffer(ctx);
@@ -1294,7 +1262,6 @@ static void s5p_mfc_run_init_dec(struct s5p_mfc_ctx *ctx)
1294 s5p_mfc_set_dec_stream_buffer_v5(ctx, 1262 s5p_mfc_set_dec_stream_buffer_v5(ctx,
1295 vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf, 0), 1263 vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf, 0),
1296 0, temp_vb->b->vb2_buf.planes[0].bytesused); 1264 0, temp_vb->b->vb2_buf.planes[0].bytesused);
1297 spin_unlock_irqrestore(&dev->irqlock, flags);
1298 dev->curr_ctx = ctx->num; 1265 dev->curr_ctx = ctx->num;
1299 s5p_mfc_init_decode_v5(ctx); 1266 s5p_mfc_init_decode_v5(ctx);
1300} 1267}
@@ -1302,18 +1269,15 @@ static void s5p_mfc_run_init_dec(struct s5p_mfc_ctx *ctx)
1302static void s5p_mfc_run_init_enc(struct s5p_mfc_ctx *ctx) 1269static void s5p_mfc_run_init_enc(struct s5p_mfc_ctx *ctx)
1303{ 1270{
1304 struct s5p_mfc_dev *dev = ctx->dev; 1271 struct s5p_mfc_dev *dev = ctx->dev;
1305 unsigned long flags;
1306 struct s5p_mfc_buf *dst_mb; 1272 struct s5p_mfc_buf *dst_mb;
1307 unsigned long dst_addr; 1273 unsigned long dst_addr;
1308 unsigned int dst_size; 1274 unsigned int dst_size;
1309 1275
1310 s5p_mfc_set_enc_ref_buffer_v5(ctx); 1276 s5p_mfc_set_enc_ref_buffer_v5(ctx);
1311 spin_lock_irqsave(&dev->irqlock, flags);
1312 dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list); 1277 dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list);
1313 dst_addr = vb2_dma_contig_plane_dma_addr(&dst_mb->b->vb2_buf, 0); 1278 dst_addr = vb2_dma_contig_plane_dma_addr(&dst_mb->b->vb2_buf, 0);
1314 dst_size = vb2_plane_size(&dst_mb->b->vb2_buf, 0); 1279 dst_size = vb2_plane_size(&dst_mb->b->vb2_buf, 0);
1315 s5p_mfc_set_enc_stream_buffer_v5(ctx, dst_addr, dst_size); 1280 s5p_mfc_set_enc_stream_buffer_v5(ctx, dst_addr, dst_size);
1316 spin_unlock_irqrestore(&dev->irqlock, flags);
1317 dev->curr_ctx = ctx->num; 1281 dev->curr_ctx = ctx->num;
1318 s5p_mfc_init_encode_v5(ctx); 1282 s5p_mfc_init_encode_v5(ctx);
1319} 1283}
@@ -1321,7 +1285,6 @@ static void s5p_mfc_run_init_enc(struct s5p_mfc_ctx *ctx)
1321static int s5p_mfc_run_init_dec_buffers(struct s5p_mfc_ctx *ctx) 1285static int s5p_mfc_run_init_dec_buffers(struct s5p_mfc_ctx *ctx)
1322{ 1286{
1323 struct s5p_mfc_dev *dev = ctx->dev; 1287 struct s5p_mfc_dev *dev = ctx->dev;
1324 unsigned long flags;
1325 struct s5p_mfc_buf *temp_vb; 1288 struct s5p_mfc_buf *temp_vb;
1326 int ret; 1289 int ret;
1327 1290
@@ -1335,11 +1298,9 @@ static int s5p_mfc_run_init_dec_buffers(struct s5p_mfc_ctx *ctx)
1335 "before starting processing\n"); 1298 "before starting processing\n");
1336 return -EAGAIN; 1299 return -EAGAIN;
1337 } 1300 }
1338 spin_lock_irqsave(&dev->irqlock, flags);
1339 if (list_empty(&ctx->src_queue)) { 1301 if (list_empty(&ctx->src_queue)) {
1340 mfc_err("Header has been deallocated in the middle of" 1302 mfc_err("Header has been deallocated in the middle of"
1341 " initialization\n"); 1303 " initialization\n");
1342 spin_unlock_irqrestore(&dev->irqlock, flags);
1343 return -EIO; 1304 return -EIO;
1344 } 1305 }
1345 temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); 1306 temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
@@ -1348,7 +1309,6 @@ static int s5p_mfc_run_init_dec_buffers(struct s5p_mfc_ctx *ctx)
1348 s5p_mfc_set_dec_stream_buffer_v5(ctx, 1309 s5p_mfc_set_dec_stream_buffer_v5(ctx,
1349 vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf, 0), 1310 vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf, 0),
1350 0, temp_vb->b->vb2_buf.planes[0].bytesused); 1311 0, temp_vb->b->vb2_buf.planes[0].bytesused);
1351 spin_unlock_irqrestore(&dev->irqlock, flags);
1352 dev->curr_ctx = ctx->num; 1312 dev->curr_ctx = ctx->num;
1353 ret = s5p_mfc_set_dec_frame_buffer_v5(ctx); 1313 ret = s5p_mfc_set_dec_frame_buffer_v5(ctx);
1354 if (ret) { 1314 if (ret) {
@@ -1472,21 +1432,6 @@ static void s5p_mfc_try_run_v5(struct s5p_mfc_dev *dev)
1472 } 1432 }
1473} 1433}
1474 1434
1475
1476static void s5p_mfc_cleanup_queue_v5(struct list_head *lh, struct vb2_queue *vq)
1477{
1478 struct s5p_mfc_buf *b;
1479 int i;
1480
1481 while (!list_empty(lh)) {
1482 b = list_entry(lh->next, struct s5p_mfc_buf, list);
1483 for (i = 0; i < b->b->vb2_buf.num_planes; i++)
1484 vb2_set_plane_payload(&b->b->vb2_buf, i, 0);
1485 vb2_buffer_done(&b->b->vb2_buf, VB2_BUF_STATE_ERROR);
1486 list_del(&b->list);
1487 }
1488}
1489
1490static void s5p_mfc_clear_int_flags_v5(struct s5p_mfc_dev *dev) 1435static void s5p_mfc_clear_int_flags_v5(struct s5p_mfc_dev *dev)
1491{ 1436{
1492 mfc_write(dev, 0, S5P_FIMV_RISC_HOST_INT); 1437 mfc_write(dev, 0, S5P_FIMV_RISC_HOST_INT);
@@ -1590,11 +1535,6 @@ static int s5p_mfc_err_dec_v5(unsigned int err)
1590 return (err & S5P_FIMV_ERR_DEC_MASK) >> S5P_FIMV_ERR_DEC_SHIFT; 1535 return (err & S5P_FIMV_ERR_DEC_MASK) >> S5P_FIMV_ERR_DEC_SHIFT;
1591} 1536}
1592 1537
1593static int s5p_mfc_err_dspl_v5(unsigned int err)
1594{
1595 return (err & S5P_FIMV_ERR_DSPL_MASK) >> S5P_FIMV_ERR_DSPL_SHIFT;
1596}
1597
1598static int s5p_mfc_get_img_width_v5(struct s5p_mfc_dev *dev) 1538static int s5p_mfc_get_img_width_v5(struct s5p_mfc_dev *dev)
1599{ 1539{
1600 return mfc_read(dev, S5P_FIMV_SI_HRESOL); 1540 return mfc_read(dev, S5P_FIMV_SI_HRESOL);
@@ -1636,26 +1576,6 @@ static int s5p_mfc_get_enc_dpb_count_v5(struct s5p_mfc_dev *dev)
1636 return -1; 1576 return -1;
1637} 1577}
1638 1578
1639static int s5p_mfc_get_enc_pic_count_v5(struct s5p_mfc_dev *dev)
1640{
1641 return mfc_read(dev, S5P_FIMV_ENC_SI_PIC_CNT);
1642}
1643
1644static int s5p_mfc_get_sei_avail_status_v5(struct s5p_mfc_ctx *ctx)
1645{
1646 return s5p_mfc_read_info_v5(ctx, FRAME_PACK_SEI_AVAIL);
1647}
1648
1649static int s5p_mfc_get_mvc_num_views_v5(struct s5p_mfc_dev *dev)
1650{
1651 return -1;
1652}
1653
1654static int s5p_mfc_get_mvc_view_id_v5(struct s5p_mfc_dev *dev)
1655{
1656 return -1;
1657}
1658
1659static unsigned int s5p_mfc_get_pic_type_top_v5(struct s5p_mfc_ctx *ctx) 1579static unsigned int s5p_mfc_get_pic_type_top_v5(struct s5p_mfc_ctx *ctx)
1660{ 1580{
1661 return s5p_mfc_read_info_v5(ctx, PIC_TIME_TOP); 1581 return s5p_mfc_read_info_v5(ctx, PIC_TIME_TOP);
@@ -1688,20 +1608,11 @@ static struct s5p_mfc_hw_ops s5p_mfc_ops_v5 = {
1688 .release_dev_context_buffer = s5p_mfc_release_dev_context_buffer_v5, 1608 .release_dev_context_buffer = s5p_mfc_release_dev_context_buffer_v5,
1689 .dec_calc_dpb_size = s5p_mfc_dec_calc_dpb_size_v5, 1609 .dec_calc_dpb_size = s5p_mfc_dec_calc_dpb_size_v5,
1690 .enc_calc_src_size = s5p_mfc_enc_calc_src_size_v5, 1610 .enc_calc_src_size = s5p_mfc_enc_calc_src_size_v5,
1691 .set_dec_stream_buffer = s5p_mfc_set_dec_stream_buffer_v5,
1692 .set_dec_frame_buffer = s5p_mfc_set_dec_frame_buffer_v5,
1693 .set_enc_stream_buffer = s5p_mfc_set_enc_stream_buffer_v5, 1611 .set_enc_stream_buffer = s5p_mfc_set_enc_stream_buffer_v5,
1694 .set_enc_frame_buffer = s5p_mfc_set_enc_frame_buffer_v5, 1612 .set_enc_frame_buffer = s5p_mfc_set_enc_frame_buffer_v5,
1695 .get_enc_frame_buffer = s5p_mfc_get_enc_frame_buffer_v5, 1613 .get_enc_frame_buffer = s5p_mfc_get_enc_frame_buffer_v5,
1696 .set_enc_ref_buffer = s5p_mfc_set_enc_ref_buffer_v5,
1697 .init_decode = s5p_mfc_init_decode_v5,
1698 .init_encode = s5p_mfc_init_encode_v5,
1699 .encode_one_frame = s5p_mfc_encode_one_frame_v5,
1700 .try_run = s5p_mfc_try_run_v5, 1614 .try_run = s5p_mfc_try_run_v5,
1701 .cleanup_queue = s5p_mfc_cleanup_queue_v5,
1702 .clear_int_flags = s5p_mfc_clear_int_flags_v5, 1615 .clear_int_flags = s5p_mfc_clear_int_flags_v5,
1703 .write_info = s5p_mfc_write_info_v5,
1704 .read_info = s5p_mfc_read_info_v5,
1705 .get_dspl_y_adr = s5p_mfc_get_dspl_y_adr_v5, 1616 .get_dspl_y_adr = s5p_mfc_get_dspl_y_adr_v5,
1706 .get_dec_y_adr = s5p_mfc_get_dec_y_adr_v5, 1617 .get_dec_y_adr = s5p_mfc_get_dec_y_adr_v5,
1707 .get_dspl_status = s5p_mfc_get_dspl_status_v5, 1618 .get_dspl_status = s5p_mfc_get_dspl_status_v5,
@@ -1712,7 +1623,6 @@ static struct s5p_mfc_hw_ops s5p_mfc_ops_v5 = {
1712 .get_int_reason = s5p_mfc_get_int_reason_v5, 1623 .get_int_reason = s5p_mfc_get_int_reason_v5,
1713 .get_int_err = s5p_mfc_get_int_err_v5, 1624 .get_int_err = s5p_mfc_get_int_err_v5,
1714 .err_dec = s5p_mfc_err_dec_v5, 1625 .err_dec = s5p_mfc_err_dec_v5,
1715 .err_dspl = s5p_mfc_err_dspl_v5,
1716 .get_img_width = s5p_mfc_get_img_width_v5, 1626 .get_img_width = s5p_mfc_get_img_width_v5,
1717 .get_img_height = s5p_mfc_get_img_height_v5, 1627 .get_img_height = s5p_mfc_get_img_height_v5,
1718 .get_dpb_count = s5p_mfc_get_dpb_count_v5, 1628 .get_dpb_count = s5p_mfc_get_dpb_count_v5,
@@ -1721,10 +1631,6 @@ static struct s5p_mfc_hw_ops s5p_mfc_ops_v5 = {
1721 .get_enc_strm_size = s5p_mfc_get_enc_strm_size_v5, 1631 .get_enc_strm_size = s5p_mfc_get_enc_strm_size_v5,
1722 .get_enc_slice_type = s5p_mfc_get_enc_slice_type_v5, 1632 .get_enc_slice_type = s5p_mfc_get_enc_slice_type_v5,
1723 .get_enc_dpb_count = s5p_mfc_get_enc_dpb_count_v5, 1633 .get_enc_dpb_count = s5p_mfc_get_enc_dpb_count_v5,
1724 .get_enc_pic_count = s5p_mfc_get_enc_pic_count_v5,
1725 .get_sei_avail_status = s5p_mfc_get_sei_avail_status_v5,
1726 .get_mvc_num_views = s5p_mfc_get_mvc_num_views_v5,
1727 .get_mvc_view_id = s5p_mfc_get_mvc_view_id_v5,
1728 .get_pic_type_top = s5p_mfc_get_pic_type_top_v5, 1634 .get_pic_type_top = s5p_mfc_get_pic_type_top_v5,
1729 .get_pic_type_bot = s5p_mfc_get_pic_type_bot_v5, 1635 .get_pic_type_bot = s5p_mfc_get_pic_type_bot_v5,
1730 .get_crop_info_h = s5p_mfc_get_crop_info_h_v5, 1636 .get_crop_info_h = s5p_mfc_get_crop_info_h_v5,
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
index b95845347348..d6f207e859ab 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
@@ -505,7 +505,7 @@ static int s5p_mfc_set_dec_frame_buffer_v6(struct s5p_mfc_ctx *ctx)
505 } 505 }
506 506
507 writel(ctx->inst_no, mfc_regs->instance_id); 507 writel(ctx->inst_no, mfc_regs->instance_id);
508 s5p_mfc_hw_call_void(dev->mfc_cmds, cmd_host2risc, dev, 508 s5p_mfc_hw_call(dev->mfc_cmds, cmd_host2risc, dev,
509 S5P_FIMV_CH_INIT_BUFS_V6, NULL); 509 S5P_FIMV_CH_INIT_BUFS_V6, NULL);
510 510
511 mfc_debug(2, "After setting buffers.\n"); 511 mfc_debug(2, "After setting buffers.\n");
@@ -603,7 +603,7 @@ static int s5p_mfc_set_enc_ref_buffer_v6(struct s5p_mfc_ctx *ctx)
603 } 603 }
604 604
605 writel(ctx->inst_no, mfc_regs->instance_id); 605 writel(ctx->inst_no, mfc_regs->instance_id);
606 s5p_mfc_hw_call_void(dev->mfc_cmds, cmd_host2risc, dev, 606 s5p_mfc_hw_call(dev->mfc_cmds, cmd_host2risc, dev,
607 S5P_FIMV_CH_INIT_BUFS_V6, NULL); 607 S5P_FIMV_CH_INIT_BUFS_V6, NULL);
608 608
609 mfc_debug_leave(); 609 mfc_debug_leave();
@@ -1378,7 +1378,7 @@ static int s5p_mfc_init_decode_v6(struct s5p_mfc_ctx *ctx)
1378 writel(ctx->sei_fp_parse & 0x1, mfc_regs->d_sei_enable); 1378 writel(ctx->sei_fp_parse & 0x1, mfc_regs->d_sei_enable);
1379 1379
1380 writel(ctx->inst_no, mfc_regs->instance_id); 1380 writel(ctx->inst_no, mfc_regs->instance_id);
1381 s5p_mfc_hw_call_void(dev->mfc_cmds, cmd_host2risc, dev, 1381 s5p_mfc_hw_call(dev->mfc_cmds, cmd_host2risc, dev,
1382 S5P_FIMV_CH_SEQ_HEADER_V6, NULL); 1382 S5P_FIMV_CH_SEQ_HEADER_V6, NULL);
1383 1383
1384 mfc_debug_leave(); 1384 mfc_debug_leave();
@@ -1393,7 +1393,7 @@ static inline void s5p_mfc_set_flush(struct s5p_mfc_ctx *ctx, int flush)
1393 if (flush) { 1393 if (flush) {
1394 dev->curr_ctx = ctx->num; 1394 dev->curr_ctx = ctx->num;
1395 writel(ctx->inst_no, mfc_regs->instance_id); 1395 writel(ctx->inst_no, mfc_regs->instance_id);
1396 s5p_mfc_hw_call_void(dev->mfc_cmds, cmd_host2risc, dev, 1396 s5p_mfc_hw_call(dev->mfc_cmds, cmd_host2risc, dev,
1397 S5P_FIMV_H2R_CMD_FLUSH_V6, NULL); 1397 S5P_FIMV_H2R_CMD_FLUSH_V6, NULL);
1398 } 1398 }
1399} 1399}
@@ -1413,11 +1413,11 @@ static int s5p_mfc_decode_one_frame_v6(struct s5p_mfc_ctx *ctx,
1413 * is the last frame or not. */ 1413 * is the last frame or not. */
1414 switch (last_frame) { 1414 switch (last_frame) {
1415 case 0: 1415 case 0:
1416 s5p_mfc_hw_call_void(dev->mfc_cmds, cmd_host2risc, dev, 1416 s5p_mfc_hw_call(dev->mfc_cmds, cmd_host2risc, dev,
1417 S5P_FIMV_CH_FRAME_START_V6, NULL); 1417 S5P_FIMV_CH_FRAME_START_V6, NULL);
1418 break; 1418 break;
1419 case 1: 1419 case 1:
1420 s5p_mfc_hw_call_void(dev->mfc_cmds, cmd_host2risc, dev, 1420 s5p_mfc_hw_call(dev->mfc_cmds, cmd_host2risc, dev,
1421 S5P_FIMV_CH_LAST_FRAME_V6, NULL); 1421 S5P_FIMV_CH_LAST_FRAME_V6, NULL);
1422 break; 1422 break;
1423 default: 1423 default:
@@ -1455,7 +1455,7 @@ static int s5p_mfc_init_encode_v6(struct s5p_mfc_ctx *ctx)
1455 } 1455 }
1456 1456
1457 writel(ctx->inst_no, mfc_regs->instance_id); 1457 writel(ctx->inst_no, mfc_regs->instance_id);
1458 s5p_mfc_hw_call_void(dev->mfc_cmds, cmd_host2risc, dev, 1458 s5p_mfc_hw_call(dev->mfc_cmds, cmd_host2risc, dev,
1459 S5P_FIMV_CH_SEQ_HEADER_V6, NULL); 1459 S5P_FIMV_CH_SEQ_HEADER_V6, NULL);
1460 1460
1461 return 0; 1461 return 0;
@@ -1500,37 +1500,13 @@ static int s5p_mfc_encode_one_frame_v6(struct s5p_mfc_ctx *ctx)
1500 cmd = S5P_FIMV_CH_LAST_FRAME_V6; 1500 cmd = S5P_FIMV_CH_LAST_FRAME_V6;
1501 1501
1502 writel(ctx->inst_no, mfc_regs->instance_id); 1502 writel(ctx->inst_no, mfc_regs->instance_id);
1503 s5p_mfc_hw_call_void(dev->mfc_cmds, cmd_host2risc, dev, cmd, NULL); 1503 s5p_mfc_hw_call(dev->mfc_cmds, cmd_host2risc, dev, cmd, NULL);
1504 1504
1505 mfc_debug(2, "--\n"); 1505 mfc_debug(2, "--\n");
1506 1506
1507 return 0; 1507 return 0;
1508} 1508}
1509 1509
1510static inline int s5p_mfc_get_new_ctx(struct s5p_mfc_dev *dev)
1511{
1512 unsigned long flags;
1513 int new_ctx;
1514 int cnt;
1515
1516 spin_lock_irqsave(&dev->condlock, flags);
1517 mfc_debug(2, "Previous context: %d (bits %08lx)\n", dev->curr_ctx,
1518 dev->ctx_work_bits);
1519 new_ctx = (dev->curr_ctx + 1) % MFC_NUM_CONTEXTS;
1520 cnt = 0;
1521 while (!test_bit(new_ctx, &dev->ctx_work_bits)) {
1522 new_ctx = (new_ctx + 1) % MFC_NUM_CONTEXTS;
1523 cnt++;
1524 if (cnt > MFC_NUM_CONTEXTS) {
1525 /* No contexts to run */
1526 spin_unlock_irqrestore(&dev->condlock, flags);
1527 return -EAGAIN;
1528 }
1529 }
1530 spin_unlock_irqrestore(&dev->condlock, flags);
1531 return new_ctx;
1532}
1533
1534static inline void s5p_mfc_run_dec_last_frames(struct s5p_mfc_ctx *ctx) 1510static inline void s5p_mfc_run_dec_last_frames(struct s5p_mfc_ctx *ctx)
1535{ 1511{
1536 struct s5p_mfc_dev *dev = ctx->dev; 1512 struct s5p_mfc_dev *dev = ctx->dev;
@@ -1544,7 +1520,6 @@ static inline int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx)
1544{ 1520{
1545 struct s5p_mfc_dev *dev = ctx->dev; 1521 struct s5p_mfc_dev *dev = ctx->dev;
1546 struct s5p_mfc_buf *temp_vb; 1522 struct s5p_mfc_buf *temp_vb;
1547 unsigned long flags;
1548 int last_frame = 0; 1523 int last_frame = 0;
1549 1524
1550 if (ctx->state == MFCINST_FINISHING) { 1525 if (ctx->state == MFCINST_FINISHING) {
@@ -1556,11 +1531,9 @@ static inline int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx)
1556 return 0; 1531 return 0;
1557 } 1532 }
1558 1533
1559 spin_lock_irqsave(&dev->irqlock, flags);
1560 /* Frames are being decoded */ 1534 /* Frames are being decoded */
1561 if (list_empty(&ctx->src_queue)) { 1535 if (list_empty(&ctx->src_queue)) {
1562 mfc_debug(2, "No src buffers.\n"); 1536 mfc_debug(2, "No src buffers.\n");
1563 spin_unlock_irqrestore(&dev->irqlock, flags);
1564 return -EAGAIN; 1537 return -EAGAIN;
1565 } 1538 }
1566 /* Get the next source buffer */ 1539 /* Get the next source buffer */
@@ -1570,7 +1543,6 @@ static inline int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx)
1570 vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf, 0), 1543 vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf, 0),
1571 ctx->consumed_stream, 1544 ctx->consumed_stream,
1572 temp_vb->b->vb2_buf.planes[0].bytesused); 1545 temp_vb->b->vb2_buf.planes[0].bytesused);
1573 spin_unlock_irqrestore(&dev->irqlock, flags);
1574 1546
1575 dev->curr_ctx = ctx->num; 1547 dev->curr_ctx = ctx->num;
1576 if (temp_vb->b->vb2_buf.planes[0].bytesused == 0) { 1548 if (temp_vb->b->vb2_buf.planes[0].bytesused == 0) {
@@ -1586,7 +1558,6 @@ static inline int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx)
1586static inline int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx) 1558static inline int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx)
1587{ 1559{
1588 struct s5p_mfc_dev *dev = ctx->dev; 1560 struct s5p_mfc_dev *dev = ctx->dev;
1589 unsigned long flags;
1590 struct s5p_mfc_buf *dst_mb; 1561 struct s5p_mfc_buf *dst_mb;
1591 struct s5p_mfc_buf *src_mb; 1562 struct s5p_mfc_buf *src_mb;
1592 unsigned long src_y_addr, src_c_addr, dst_addr; 1563 unsigned long src_y_addr, src_c_addr, dst_addr;
@@ -1595,17 +1566,13 @@ static inline int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx)
1595 */ 1566 */
1596 unsigned int dst_size; 1567 unsigned int dst_size;
1597 1568
1598 spin_lock_irqsave(&dev->irqlock, flags);
1599
1600 if (list_empty(&ctx->src_queue) && ctx->state != MFCINST_FINISHING) { 1569 if (list_empty(&ctx->src_queue) && ctx->state != MFCINST_FINISHING) {
1601 mfc_debug(2, "no src buffers.\n"); 1570 mfc_debug(2, "no src buffers.\n");
1602 spin_unlock_irqrestore(&dev->irqlock, flags);
1603 return -EAGAIN; 1571 return -EAGAIN;
1604 } 1572 }
1605 1573
1606 if (list_empty(&ctx->dst_queue)) { 1574 if (list_empty(&ctx->dst_queue)) {
1607 mfc_debug(2, "no dst buffers.\n"); 1575 mfc_debug(2, "no dst buffers.\n");
1608 spin_unlock_irqrestore(&dev->irqlock, flags);
1609 return -EAGAIN; 1576 return -EAGAIN;
1610 } 1577 }
1611 1578
@@ -1639,8 +1606,6 @@ static inline int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx)
1639 1606
1640 s5p_mfc_set_enc_stream_buffer_v6(ctx, dst_addr, dst_size); 1607 s5p_mfc_set_enc_stream_buffer_v6(ctx, dst_addr, dst_size);
1641 1608
1642 spin_unlock_irqrestore(&dev->irqlock, flags);
1643
1644 dev->curr_ctx = ctx->num; 1609 dev->curr_ctx = ctx->num;
1645 s5p_mfc_encode_one_frame_v6(ctx); 1610 s5p_mfc_encode_one_frame_v6(ctx);
1646 1611
@@ -1650,18 +1615,15 @@ static inline int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx)
1650static inline void s5p_mfc_run_init_dec(struct s5p_mfc_ctx *ctx) 1615static inline void s5p_mfc_run_init_dec(struct s5p_mfc_ctx *ctx)
1651{ 1616{
1652 struct s5p_mfc_dev *dev = ctx->dev; 1617 struct s5p_mfc_dev *dev = ctx->dev;
1653 unsigned long flags;
1654 struct s5p_mfc_buf *temp_vb; 1618 struct s5p_mfc_buf *temp_vb;
1655 1619
1656 /* Initializing decoding - parsing header */ 1620 /* Initializing decoding - parsing header */
1657 spin_lock_irqsave(&dev->irqlock, flags);
1658 mfc_debug(2, "Preparing to init decoding.\n"); 1621 mfc_debug(2, "Preparing to init decoding.\n");
1659 temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); 1622 temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
1660 mfc_debug(2, "Header size: %d\n", temp_vb->b->vb2_buf.planes[0].bytesused); 1623 mfc_debug(2, "Header size: %d\n", temp_vb->b->vb2_buf.planes[0].bytesused);
1661 s5p_mfc_set_dec_stream_buffer_v6(ctx, 1624 s5p_mfc_set_dec_stream_buffer_v6(ctx,
1662 vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf, 0), 0, 1625 vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf, 0), 0,
1663 temp_vb->b->vb2_buf.planes[0].bytesused); 1626 temp_vb->b->vb2_buf.planes[0].bytesused);
1664 spin_unlock_irqrestore(&dev->irqlock, flags);
1665 dev->curr_ctx = ctx->num; 1627 dev->curr_ctx = ctx->num;
1666 s5p_mfc_init_decode_v6(ctx); 1628 s5p_mfc_init_decode_v6(ctx);
1667} 1629}
@@ -1669,18 +1631,14 @@ static inline void s5p_mfc_run_init_dec(struct s5p_mfc_ctx *ctx)
1669static inline void s5p_mfc_run_init_enc(struct s5p_mfc_ctx *ctx) 1631static inline void s5p_mfc_run_init_enc(struct s5p_mfc_ctx *ctx)
1670{ 1632{
1671 struct s5p_mfc_dev *dev = ctx->dev; 1633 struct s5p_mfc_dev *dev = ctx->dev;
1672 unsigned long flags;
1673 struct s5p_mfc_buf *dst_mb; 1634 struct s5p_mfc_buf *dst_mb;
1674 unsigned long dst_addr; 1635 unsigned long dst_addr;
1675 unsigned int dst_size; 1636 unsigned int dst_size;
1676 1637
1677 spin_lock_irqsave(&dev->irqlock, flags);
1678
1679 dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list); 1638 dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list);
1680 dst_addr = vb2_dma_contig_plane_dma_addr(&dst_mb->b->vb2_buf, 0); 1639 dst_addr = vb2_dma_contig_plane_dma_addr(&dst_mb->b->vb2_buf, 0);
1681 dst_size = vb2_plane_size(&dst_mb->b->vb2_buf, 0); 1640 dst_size = vb2_plane_size(&dst_mb->b->vb2_buf, 0);
1682 s5p_mfc_set_enc_stream_buffer_v6(ctx, dst_addr, dst_size); 1641 s5p_mfc_set_enc_stream_buffer_v6(ctx, dst_addr, dst_size);
1683 spin_unlock_irqrestore(&dev->irqlock, flags);
1684 dev->curr_ctx = ctx->num; 1642 dev->curr_ctx = ctx->num;
1685 s5p_mfc_init_encode_v6(ctx); 1643 s5p_mfc_init_encode_v6(ctx);
1686} 1644}
@@ -1846,21 +1804,6 @@ static void s5p_mfc_try_run_v6(struct s5p_mfc_dev *dev)
1846 } 1804 }
1847} 1805}
1848 1806
1849
1850static void s5p_mfc_cleanup_queue_v6(struct list_head *lh, struct vb2_queue *vq)
1851{
1852 struct s5p_mfc_buf *b;
1853 int i;
1854
1855 while (!list_empty(lh)) {
1856 b = list_entry(lh->next, struct s5p_mfc_buf, list);
1857 for (i = 0; i < b->b->vb2_buf.num_planes; i++)
1858 vb2_set_plane_payload(&b->b->vb2_buf, i, 0);
1859 vb2_buffer_done(&b->b->vb2_buf, VB2_BUF_STATE_ERROR);
1860 list_del(&b->list);
1861 }
1862}
1863
1864static void s5p_mfc_clear_int_flags_v6(struct s5p_mfc_dev *dev) 1807static void s5p_mfc_clear_int_flags_v6(struct s5p_mfc_dev *dev)
1865{ 1808{
1866 const struct s5p_mfc_regs *mfc_regs = dev->mfc_regs; 1809 const struct s5p_mfc_regs *mfc_regs = dev->mfc_regs;
@@ -1868,14 +1811,6 @@ static void s5p_mfc_clear_int_flags_v6(struct s5p_mfc_dev *dev)
1868 writel(0, mfc_regs->risc2host_int); 1811 writel(0, mfc_regs->risc2host_int);
1869} 1812}
1870 1813
1871static void s5p_mfc_write_info_v6(struct s5p_mfc_ctx *ctx, unsigned int data,
1872 unsigned int ofs)
1873{
1874 s5p_mfc_clock_on();
1875 writel(data, (void __iomem *)((unsigned long)ofs));
1876 s5p_mfc_clock_off();
1877}
1878
1879static unsigned int 1814static unsigned int
1880s5p_mfc_read_info_v6(struct s5p_mfc_ctx *ctx, unsigned long ofs) 1815s5p_mfc_read_info_v6(struct s5p_mfc_ctx *ctx, unsigned long ofs)
1881{ 1816{
@@ -1942,11 +1877,6 @@ static int s5p_mfc_err_dec_v6(unsigned int err)
1942 return (err & S5P_FIMV_ERR_DEC_MASK_V6) >> S5P_FIMV_ERR_DEC_SHIFT_V6; 1877 return (err & S5P_FIMV_ERR_DEC_MASK_V6) >> S5P_FIMV_ERR_DEC_SHIFT_V6;
1943} 1878}
1944 1879
1945static int s5p_mfc_err_dspl_v6(unsigned int err)
1946{
1947 return (err & S5P_FIMV_ERR_DSPL_MASK_V6) >> S5P_FIMV_ERR_DSPL_SHIFT_V6;
1948}
1949
1950static int s5p_mfc_get_img_width_v6(struct s5p_mfc_dev *dev) 1880static int s5p_mfc_get_img_width_v6(struct s5p_mfc_dev *dev)
1951{ 1881{
1952 return readl(dev->mfc_regs->d_display_frame_width); 1882 return readl(dev->mfc_regs->d_display_frame_width);
@@ -1987,27 +1917,6 @@ static int s5p_mfc_get_enc_slice_type_v6(struct s5p_mfc_dev *dev)
1987 return readl(dev->mfc_regs->e_slice_type); 1917 return readl(dev->mfc_regs->e_slice_type);
1988} 1918}
1989 1919
1990static int s5p_mfc_get_enc_pic_count_v6(struct s5p_mfc_dev *dev)
1991{
1992 return readl(dev->mfc_regs->e_picture_count);
1993}
1994
1995static int s5p_mfc_get_sei_avail_status_v6(struct s5p_mfc_ctx *ctx)
1996{
1997 struct s5p_mfc_dev *dev = ctx->dev;
1998 return readl(dev->mfc_regs->d_frame_pack_sei_avail);
1999}
2000
2001static int s5p_mfc_get_mvc_num_views_v6(struct s5p_mfc_dev *dev)
2002{
2003 return readl(dev->mfc_regs->d_mvc_num_views);
2004}
2005
2006static int s5p_mfc_get_mvc_view_id_v6(struct s5p_mfc_dev *dev)
2007{
2008 return readl(dev->mfc_regs->d_mvc_view_id);
2009}
2010
2011static unsigned int s5p_mfc_get_pic_type_top_v6(struct s5p_mfc_ctx *ctx) 1920static unsigned int s5p_mfc_get_pic_type_top_v6(struct s5p_mfc_ctx *ctx)
2012{ 1921{
2013 return s5p_mfc_read_info_v6(ctx, 1922 return s5p_mfc_read_info_v6(ctx,
@@ -2282,20 +2191,11 @@ static struct s5p_mfc_hw_ops s5p_mfc_ops_v6 = {
2282 s5p_mfc_release_dev_context_buffer_v6, 2191 s5p_mfc_release_dev_context_buffer_v6,
2283 .dec_calc_dpb_size = s5p_mfc_dec_calc_dpb_size_v6, 2192 .dec_calc_dpb_size = s5p_mfc_dec_calc_dpb_size_v6,
2284 .enc_calc_src_size = s5p_mfc_enc_calc_src_size_v6, 2193 .enc_calc_src_size = s5p_mfc_enc_calc_src_size_v6,
2285 .set_dec_stream_buffer = s5p_mfc_set_dec_stream_buffer_v6,
2286 .set_dec_frame_buffer = s5p_mfc_set_dec_frame_buffer_v6,
2287 .set_enc_stream_buffer = s5p_mfc_set_enc_stream_buffer_v6, 2194 .set_enc_stream_buffer = s5p_mfc_set_enc_stream_buffer_v6,
2288 .set_enc_frame_buffer = s5p_mfc_set_enc_frame_buffer_v6, 2195 .set_enc_frame_buffer = s5p_mfc_set_enc_frame_buffer_v6,
2289 .get_enc_frame_buffer = s5p_mfc_get_enc_frame_buffer_v6, 2196 .get_enc_frame_buffer = s5p_mfc_get_enc_frame_buffer_v6,
2290 .set_enc_ref_buffer = s5p_mfc_set_enc_ref_buffer_v6,
2291 .init_decode = s5p_mfc_init_decode_v6,
2292 .init_encode = s5p_mfc_init_encode_v6,
2293 .encode_one_frame = s5p_mfc_encode_one_frame_v6,
2294 .try_run = s5p_mfc_try_run_v6, 2197 .try_run = s5p_mfc_try_run_v6,
2295 .cleanup_queue = s5p_mfc_cleanup_queue_v6,
2296 .clear_int_flags = s5p_mfc_clear_int_flags_v6, 2198 .clear_int_flags = s5p_mfc_clear_int_flags_v6,
2297 .write_info = s5p_mfc_write_info_v6,
2298 .read_info = s5p_mfc_read_info_v6,
2299 .get_dspl_y_adr = s5p_mfc_get_dspl_y_adr_v6, 2199 .get_dspl_y_adr = s5p_mfc_get_dspl_y_adr_v6,
2300 .get_dec_y_adr = s5p_mfc_get_dec_y_adr_v6, 2200 .get_dec_y_adr = s5p_mfc_get_dec_y_adr_v6,
2301 .get_dspl_status = s5p_mfc_get_dspl_status_v6, 2201 .get_dspl_status = s5p_mfc_get_dspl_status_v6,
@@ -2306,7 +2206,6 @@ static struct s5p_mfc_hw_ops s5p_mfc_ops_v6 = {
2306 .get_int_reason = s5p_mfc_get_int_reason_v6, 2206 .get_int_reason = s5p_mfc_get_int_reason_v6,
2307 .get_int_err = s5p_mfc_get_int_err_v6, 2207 .get_int_err = s5p_mfc_get_int_err_v6,
2308 .err_dec = s5p_mfc_err_dec_v6, 2208 .err_dec = s5p_mfc_err_dec_v6,
2309 .err_dspl = s5p_mfc_err_dspl_v6,
2310 .get_img_width = s5p_mfc_get_img_width_v6, 2209 .get_img_width = s5p_mfc_get_img_width_v6,
2311 .get_img_height = s5p_mfc_get_img_height_v6, 2210 .get_img_height = s5p_mfc_get_img_height_v6,
2312 .get_dpb_count = s5p_mfc_get_dpb_count_v6, 2211 .get_dpb_count = s5p_mfc_get_dpb_count_v6,
@@ -2315,10 +2214,6 @@ static struct s5p_mfc_hw_ops s5p_mfc_ops_v6 = {
2315 .get_enc_strm_size = s5p_mfc_get_enc_strm_size_v6, 2214 .get_enc_strm_size = s5p_mfc_get_enc_strm_size_v6,
2316 .get_enc_slice_type = s5p_mfc_get_enc_slice_type_v6, 2215 .get_enc_slice_type = s5p_mfc_get_enc_slice_type_v6,
2317 .get_enc_dpb_count = s5p_mfc_get_enc_dpb_count_v6, 2216 .get_enc_dpb_count = s5p_mfc_get_enc_dpb_count_v6,
2318 .get_enc_pic_count = s5p_mfc_get_enc_pic_count_v6,
2319 .get_sei_avail_status = s5p_mfc_get_sei_avail_status_v6,
2320 .get_mvc_num_views = s5p_mfc_get_mvc_num_views_v6,
2321 .get_mvc_view_id = s5p_mfc_get_mvc_view_id_v6,
2322 .get_pic_type_top = s5p_mfc_get_pic_type_top_v6, 2217 .get_pic_type_top = s5p_mfc_get_pic_type_top_v6,
2323 .get_pic_type_bot = s5p_mfc_get_pic_type_bot_v6, 2218 .get_pic_type_bot = s5p_mfc_get_pic_type_bot_v6,
2324 .get_crop_info_h = s5p_mfc_get_crop_info_h_v6, 2219 .get_crop_info_h = s5p_mfc_get_crop_info_h_v6,
diff --git a/drivers/media/platform/s5p-tv/hdmi_drv.c b/drivers/media/platform/s5p-tv/hdmi_drv.c
index 79940757b34f..e71b13e40f59 100644
--- a/drivers/media/platform/s5p-tv/hdmi_drv.c
+++ b/drivers/media/platform/s5p-tv/hdmi_drv.c
@@ -33,7 +33,7 @@
33#include <linux/regulator/consumer.h> 33#include <linux/regulator/consumer.h>
34#include <linux/v4l2-dv-timings.h> 34#include <linux/v4l2-dv-timings.h>
35 35
36#include <media/s5p_hdmi.h> 36#include <linux/platform_data/media/s5p_hdmi.h>
37#include <media/v4l2-common.h> 37#include <media/v4l2-common.h>
38#include <media/v4l2-dev.h> 38#include <media/v4l2-dev.h>
39#include <media/v4l2-device.h> 39#include <media/v4l2-device.h>
@@ -627,7 +627,7 @@ static int hdmi_s_dv_timings(struct v4l2_subdev *sd,
627 627
628 for (i = 0; i < ARRAY_SIZE(hdmi_timings); i++) 628 for (i = 0; i < ARRAY_SIZE(hdmi_timings); i++)
629 if (v4l2_match_dv_timings(&hdmi_timings[i].dv_timings, 629 if (v4l2_match_dv_timings(&hdmi_timings[i].dv_timings,
630 timings, 0)) 630 timings, 0, false))
631 break; 631 break;
632 if (i == ARRAY_SIZE(hdmi_timings)) { 632 if (i == ARRAY_SIZE(hdmi_timings)) {
633 dev_err(dev, "timings not supported\n"); 633 dev_err(dev, "timings not supported\n");
diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
index dc1c679e136c..d9e7f030294c 100644
--- a/drivers/media/platform/s5p-tv/mixer_video.c
+++ b/drivers/media/platform/s5p-tv/mixer_video.c
@@ -881,7 +881,7 @@ static const struct v4l2_file_operations mxr_fops = {
881 .unlocked_ioctl = video_ioctl2, 881 .unlocked_ioctl = video_ioctl2,
882}; 882};
883 883
884static int queue_setup(struct vb2_queue *vq, const void *parg, 884static int queue_setup(struct vb2_queue *vq,
885 unsigned int *nbuffers, unsigned int *nplanes, unsigned int sizes[], 885 unsigned int *nbuffers, unsigned int *nplanes, unsigned int sizes[],
886 void *alloc_ctxs[]) 886 void *alloc_ctxs[])
887{ 887{
diff --git a/drivers/media/platform/s5p-tv/sii9234_drv.c b/drivers/media/platform/s5p-tv/sii9234_drv.c
index 8d171310af8f..0a97f9ab4f76 100644
--- a/drivers/media/platform/s5p-tv/sii9234_drv.c
+++ b/drivers/media/platform/s5p-tv/sii9234_drv.c
@@ -23,7 +23,7 @@
23#include <linux/regulator/machine.h> 23#include <linux/regulator/machine.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25 25
26#include <media/sii9234.h> 26#include <linux/platform_data/media/sii9234.h>
27#include <media/v4l2-subdev.h> 27#include <media/v4l2-subdev.h>
28 28
29MODULE_AUTHOR("Tomasz Stanislawski <t.stanislaws@samsung.com>"); 29MODULE_AUTHOR("Tomasz Stanislawski <t.stanislaws@samsung.com>");
diff --git a/drivers/media/platform/sh_veu.c b/drivers/media/platform/sh_veu.c
index d6ab33e7060a..82b5d69b87fa 100644
--- a/drivers/media/platform/sh_veu.c
+++ b/drivers/media/platform/sh_veu.c
@@ -865,32 +865,14 @@ static const struct v4l2_ioctl_ops sh_veu_ioctl_ops = {
865 /* ========== Queue operations ========== */ 865 /* ========== Queue operations ========== */
866 866
867static int sh_veu_queue_setup(struct vb2_queue *vq, 867static int sh_veu_queue_setup(struct vb2_queue *vq,
868 const void *parg,
869 unsigned int *nbuffers, unsigned int *nplanes, 868 unsigned int *nbuffers, unsigned int *nplanes,
870 unsigned int sizes[], void *alloc_ctxs[]) 869 unsigned int sizes[], void *alloc_ctxs[])
871{ 870{
872 const struct v4l2_format *f = parg;
873 struct sh_veu_dev *veu = vb2_get_drv_priv(vq); 871 struct sh_veu_dev *veu = vb2_get_drv_priv(vq);
874 struct sh_veu_vfmt *vfmt; 872 struct sh_veu_vfmt *vfmt = sh_veu_get_vfmt(veu, vq->type);
875 unsigned int size, count = *nbuffers; 873 unsigned int count = *nbuffers;
876 874 unsigned int size = vfmt->bytesperline * vfmt->frame.height *
877 if (f) { 875 vfmt->fmt->depth / vfmt->fmt->ydepth;
878 const struct v4l2_pix_format *pix = &f->fmt.pix;
879 const struct sh_veu_format *fmt = sh_veu_find_fmt(f);
880 struct v4l2_format ftmp = *f;
881
882 if (fmt->fourcc != pix->pixelformat)
883 return -EINVAL;
884 sh_veu_try_fmt(&ftmp, fmt);
885 if (ftmp.fmt.pix.width != pix->width ||
886 ftmp.fmt.pix.height != pix->height)
887 return -EINVAL;
888 size = pix->bytesperline ? pix->bytesperline * pix->height * fmt->depth / fmt->ydepth :
889 pix->width * pix->height * fmt->depth / fmt->ydepth;
890 } else {
891 vfmt = sh_veu_get_vfmt(veu, vq->type);
892 size = vfmt->bytesperline * vfmt->frame.height * vfmt->fmt->depth / vfmt->fmt->ydepth;
893 }
894 876
895 if (count < 2) 877 if (count < 2)
896 *nbuffers = count = 2; 878 *nbuffers = count = 2;
@@ -900,6 +882,11 @@ static int sh_veu_queue_setup(struct vb2_queue *vq,
900 *nbuffers = count; 882 *nbuffers = count;
901 } 883 }
902 884
885 if (*nplanes) {
886 alloc_ctxs[0] = veu->alloc_ctx;
887 return sizes[0] < size ? -EINVAL : 0;
888 }
889
903 *nplanes = 1; 890 *nplanes = 1;
904 sizes[0] = size; 891 sizes[0] = size;
905 alloc_ctxs[0] = veu->alloc_ctx; 892 alloc_ctxs[0] = veu->alloc_ctx;
@@ -1107,7 +1094,7 @@ static irqreturn_t sh_veu_isr(int irq, void *dev_id)
1107 if (!src || !dst) 1094 if (!src || !dst)
1108 return IRQ_NONE; 1095 return IRQ_NONE;
1109 1096
1110 dst->timestamp = src->timestamp; 1097 dst->vb2_buf.timestamp = src->vb2_buf.timestamp;
1111 dst->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 1098 dst->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
1112 dst->flags |= 1099 dst->flags |=
1113 src->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 1100 src->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c
index 2231f8922df3..115740498274 100644
--- a/drivers/media/platform/sh_vou.c
+++ b/drivers/media/platform/sh_vou.c
@@ -22,7 +22,7 @@
22#include <linux/videodev2.h> 22#include <linux/videodev2.h>
23#include <linux/module.h> 23#include <linux/module.h>
24 24
25#include <media/sh_vou.h> 25#include <media/drv-intf/sh_vou.h>
26#include <media/v4l2-common.h> 26#include <media/v4l2-common.h>
27#include <media/v4l2-device.h> 27#include <media/v4l2-device.h>
28#include <media/v4l2-ioctl.h> 28#include <media/v4l2-ioctl.h>
@@ -243,22 +243,21 @@ static void sh_vou_stream_config(struct sh_vou_device *vou_dev)
243} 243}
244 244
245/* Locking: caller holds fop_lock mutex */ 245/* Locking: caller holds fop_lock mutex */
246static int sh_vou_queue_setup(struct vb2_queue *vq, const void *parg, 246static int sh_vou_queue_setup(struct vb2_queue *vq,
247 unsigned int *nbuffers, unsigned int *nplanes, 247 unsigned int *nbuffers, unsigned int *nplanes,
248 unsigned int sizes[], void *alloc_ctxs[]) 248 unsigned int sizes[], void *alloc_ctxs[])
249{ 249{
250 const struct v4l2_format *fmt = parg;
251 struct sh_vou_device *vou_dev = vb2_get_drv_priv(vq); 250 struct sh_vou_device *vou_dev = vb2_get_drv_priv(vq);
252 struct v4l2_pix_format *pix = &vou_dev->pix; 251 struct v4l2_pix_format *pix = &vou_dev->pix;
253 int bytes_per_line = vou_fmt[vou_dev->pix_idx].bpp * pix->width / 8; 252 int bytes_per_line = vou_fmt[vou_dev->pix_idx].bpp * pix->width / 8;
254 253
255 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); 254 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__);
256 255
257 if (fmt && fmt->fmt.pix.sizeimage < pix->height * bytes_per_line)
258 return -EINVAL;
259 *nplanes = 1;
260 sizes[0] = fmt ? fmt->fmt.pix.sizeimage : pix->height * bytes_per_line;
261 alloc_ctxs[0] = vou_dev->alloc_ctx; 256 alloc_ctxs[0] = vou_dev->alloc_ctx;
257 if (*nplanes)
258 return sizes[0] < pix->height * bytes_per_line ? -EINVAL : 0;
259 *nplanes = 1;
260 sizes[0] = pix->height * bytes_per_line;
262 return 0; 261 return 0;
263} 262}
264 263
@@ -1071,7 +1070,7 @@ static irqreturn_t sh_vou_isr(int irq, void *dev_id)
1071 1070
1072 list_del(&vb->list); 1071 list_del(&vb->list);
1073 1072
1074 v4l2_get_timestamp(&vb->vb.timestamp); 1073 vb->vb.vb2_buf.timestamp = ktime_get_ns();
1075 vb->vb.sequence = vou_dev->sequence++; 1074 vb->vb.sequence = vou_dev->sequence++;
1076 vb->vb.field = V4L2_FIELD_INTERLACED; 1075 vb->vb.field = V4L2_FIELD_INTERLACED;
1077 vb2_buffer_done(&vb->vb.vb2_buf, VB2_BUF_STATE_DONE); 1076 vb2_buffer_done(&vb->vb.vb2_buf, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/platform/soc_camera/atmel-isi.c b/drivers/media/platform/soc_camera/atmel-isi.c
index 454f68f0cdad..c398b285180c 100644
--- a/drivers/media/platform/soc_camera/atmel-isi.c
+++ b/drivers/media/platform/soc_camera/atmel-isi.c
@@ -24,7 +24,7 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25 25
26#include <media/soc_camera.h> 26#include <media/soc_camera.h>
27#include <media/soc_mediabus.h> 27#include <media/drv-intf/soc_mediabus.h>
28#include <media/v4l2-of.h> 28#include <media/v4l2-of.h>
29#include <media/videobuf2-dma-contig.h> 29#include <media/videobuf2-dma-contig.h>
30 30
@@ -79,6 +79,7 @@ struct atmel_isi {
79 dma_addr_t fb_descriptors_phys; 79 dma_addr_t fb_descriptors_phys;
80 struct list_head dma_desc_head; 80 struct list_head dma_desc_head;
81 struct isi_dma_desc dma_desc[MAX_BUFFER_NUM]; 81 struct isi_dma_desc dma_desc[MAX_BUFFER_NUM];
82 bool enable_preview_path;
82 83
83 struct completion complete; 84 struct completion complete;
84 /* ISI peripherial clock */ 85 /* ISI peripherial clock */
@@ -103,13 +104,55 @@ static u32 isi_readl(struct atmel_isi *isi, u32 reg)
103 return readl(isi->regs + reg); 104 return readl(isi->regs + reg);
104} 105}
105 106
107static u32 setup_cfg2_yuv_swap(struct atmel_isi *isi,
108 const struct soc_camera_format_xlate *xlate)
109{
110 if (xlate->host_fmt->fourcc == V4L2_PIX_FMT_YUYV) {
111 /* all convert to YUYV */
112 switch (xlate->code) {
113 case MEDIA_BUS_FMT_VYUY8_2X8:
114 return ISI_CFG2_YCC_SWAP_MODE_3;
115 case MEDIA_BUS_FMT_UYVY8_2X8:
116 return ISI_CFG2_YCC_SWAP_MODE_2;
117 case MEDIA_BUS_FMT_YVYU8_2X8:
118 return ISI_CFG2_YCC_SWAP_MODE_1;
119 }
120 } else if (xlate->host_fmt->fourcc == V4L2_PIX_FMT_RGB565) {
121 /*
122 * Preview path is enabled, it will convert UYVY to RGB format.
123 * But if sensor output format is not UYVY, we need to set
124 * YCC_SWAP_MODE to convert it as UYVY.
125 */
126 switch (xlate->code) {
127 case MEDIA_BUS_FMT_VYUY8_2X8:
128 return ISI_CFG2_YCC_SWAP_MODE_1;
129 case MEDIA_BUS_FMT_YUYV8_2X8:
130 return ISI_CFG2_YCC_SWAP_MODE_2;
131 case MEDIA_BUS_FMT_YVYU8_2X8:
132 return ISI_CFG2_YCC_SWAP_MODE_3;
133 }
134 }
135
136 /*
137 * By default, no swap for the codec path of Atmel ISI. So codec
138 * output is same as sensor's output.
139 * For instance, if sensor's output is YUYV, then codec outputs YUYV.
140 * And if sensor's output is UYVY, then codec outputs UYVY.
141 */
142 return ISI_CFG2_YCC_SWAP_DEFAULT;
143}
144
106static void configure_geometry(struct atmel_isi *isi, u32 width, 145static void configure_geometry(struct atmel_isi *isi, u32 width,
107 u32 height, u32 code) 146 u32 height, const struct soc_camera_format_xlate *xlate)
108{ 147{
109 u32 cfg2; 148 u32 cfg2, psize;
149 u32 fourcc = xlate->host_fmt->fourcc;
150
151 isi->enable_preview_path = fourcc == V4L2_PIX_FMT_RGB565 ||
152 fourcc == V4L2_PIX_FMT_RGB32;
110 153
111 /* According to sensor's output format to set cfg2 */ 154 /* According to sensor's output format to set cfg2 */
112 switch (code) { 155 switch (xlate->code) {
113 default: 156 default:
114 /* Grey */ 157 /* Grey */
115 case MEDIA_BUS_FMT_Y8_1X8: 158 case MEDIA_BUS_FMT_Y8_1X8:
@@ -117,16 +160,11 @@ static void configure_geometry(struct atmel_isi *isi, u32 width,
117 break; 160 break;
118 /* YUV */ 161 /* YUV */
119 case MEDIA_BUS_FMT_VYUY8_2X8: 162 case MEDIA_BUS_FMT_VYUY8_2X8:
120 cfg2 = ISI_CFG2_YCC_SWAP_MODE_3 | ISI_CFG2_COL_SPACE_YCbCr;
121 break;
122 case MEDIA_BUS_FMT_UYVY8_2X8: 163 case MEDIA_BUS_FMT_UYVY8_2X8:
123 cfg2 = ISI_CFG2_YCC_SWAP_MODE_2 | ISI_CFG2_COL_SPACE_YCbCr;
124 break;
125 case MEDIA_BUS_FMT_YVYU8_2X8: 164 case MEDIA_BUS_FMT_YVYU8_2X8:
126 cfg2 = ISI_CFG2_YCC_SWAP_MODE_1 | ISI_CFG2_COL_SPACE_YCbCr;
127 break;
128 case MEDIA_BUS_FMT_YUYV8_2X8: 165 case MEDIA_BUS_FMT_YUYV8_2X8:
129 cfg2 = ISI_CFG2_YCC_SWAP_DEFAULT | ISI_CFG2_COL_SPACE_YCbCr; 166 cfg2 = ISI_CFG2_COL_SPACE_YCbCr |
167 setup_cfg2_yuv_swap(isi, xlate);
130 break; 168 break;
131 /* RGB, TODO */ 169 /* RGB, TODO */
132 } 170 }
@@ -139,6 +177,16 @@ static void configure_geometry(struct atmel_isi *isi, u32 width,
139 cfg2 |= ((height - 1) << ISI_CFG2_IM_VSIZE_OFFSET) 177 cfg2 |= ((height - 1) << ISI_CFG2_IM_VSIZE_OFFSET)
140 & ISI_CFG2_IM_VSIZE_MASK; 178 & ISI_CFG2_IM_VSIZE_MASK;
141 isi_writel(isi, ISI_CFG2, cfg2); 179 isi_writel(isi, ISI_CFG2, cfg2);
180
181 /* No down sampling, preview size equal to sensor output size */
182 psize = ((width - 1) << ISI_PSIZE_PREV_HSIZE_OFFSET) &
183 ISI_PSIZE_PREV_HSIZE_MASK;
184 psize |= ((height - 1) << ISI_PSIZE_PREV_VSIZE_OFFSET) &
185 ISI_PSIZE_PREV_VSIZE_MASK;
186 isi_writel(isi, ISI_PSIZE, psize);
187 isi_writel(isi, ISI_PDECF, ISI_PDECF_NO_SAMPLING);
188
189 return;
142} 190}
143 191
144static bool is_supported(struct soc_camera_device *icd, 192static bool is_supported(struct soc_camera_device *icd,
@@ -151,8 +199,9 @@ static bool is_supported(struct soc_camera_device *icd,
151 case V4L2_PIX_FMT_UYVY: 199 case V4L2_PIX_FMT_UYVY:
152 case V4L2_PIX_FMT_YVYU: 200 case V4L2_PIX_FMT_YVYU:
153 case V4L2_PIX_FMT_VYUY: 201 case V4L2_PIX_FMT_VYUY:
202 /* RGB */
203 case V4L2_PIX_FMT_RGB565:
154 return true; 204 return true;
155 /* RGB, TODO */
156 default: 205 default:
157 return false; 206 return false;
158 } 207 }
@@ -165,7 +214,7 @@ static irqreturn_t atmel_isi_handle_streaming(struct atmel_isi *isi)
165 struct frame_buffer *buf = isi->active; 214 struct frame_buffer *buf = isi->active;
166 215
167 list_del_init(&buf->list); 216 list_del_init(&buf->list);
168 v4l2_get_timestamp(&vbuf->timestamp); 217 vbuf->vb2_buf.timestamp = ktime_get_ns();
169 vbuf->sequence = isi->sequence++; 218 vbuf->sequence = isi->sequence++;
170 vb2_buffer_done(&vbuf->vb2_buf, VB2_BUF_STATE_DONE); 219 vb2_buffer_done(&vbuf->vb2_buf, VB2_BUF_STATE_DONE);
171 } 220 }
@@ -176,11 +225,19 @@ static irqreturn_t atmel_isi_handle_streaming(struct atmel_isi *isi)
176 /* start next dma frame. */ 225 /* start next dma frame. */
177 isi->active = list_entry(isi->video_buffer_list.next, 226 isi->active = list_entry(isi->video_buffer_list.next,
178 struct frame_buffer, list); 227 struct frame_buffer, list);
179 isi_writel(isi, ISI_DMA_C_DSCR, 228 if (!isi->enable_preview_path) {
180 (u32)isi->active->p_dma_desc->fbd_phys); 229 isi_writel(isi, ISI_DMA_C_DSCR,
181 isi_writel(isi, ISI_DMA_C_CTRL, 230 (u32)isi->active->p_dma_desc->fbd_phys);
182 ISI_DMA_CTRL_FETCH | ISI_DMA_CTRL_DONE); 231 isi_writel(isi, ISI_DMA_C_CTRL,
183 isi_writel(isi, ISI_DMA_CHER, ISI_DMA_CHSR_C_CH); 232 ISI_DMA_CTRL_FETCH | ISI_DMA_CTRL_DONE);
233 isi_writel(isi, ISI_DMA_CHER, ISI_DMA_CHSR_C_CH);
234 } else {
235 isi_writel(isi, ISI_DMA_P_DSCR,
236 (u32)isi->active->p_dma_desc->fbd_phys);
237 isi_writel(isi, ISI_DMA_P_CTRL,
238 ISI_DMA_CTRL_FETCH | ISI_DMA_CTRL_DONE);
239 isi_writel(isi, ISI_DMA_CHER, ISI_DMA_CHSR_P_CH);
240 }
184 } 241 }
185 return IRQ_HANDLED; 242 return IRQ_HANDLED;
186} 243}
@@ -207,7 +264,8 @@ static irqreturn_t isi_interrupt(int irq, void *dev_id)
207 isi_writel(isi, ISI_INTDIS, ISI_CTRL_DIS); 264 isi_writel(isi, ISI_INTDIS, ISI_CTRL_DIS);
208 ret = IRQ_HANDLED; 265 ret = IRQ_HANDLED;
209 } else { 266 } else {
210 if (likely(pending & ISI_SR_CXFR_DONE)) 267 if (likely(pending & ISI_SR_CXFR_DONE) ||
268 likely(pending & ISI_SR_PXFR_DONE))
211 ret = atmel_isi_handle_streaming(isi); 269 ret = atmel_isi_handle_streaming(isi);
212 } 270 }
213 271
@@ -245,7 +303,7 @@ static int atmel_isi_wait_status(struct atmel_isi *isi, int wait_reset)
245/* ------------------------------------------------------------------ 303/* ------------------------------------------------------------------
246 Videobuf operations 304 Videobuf operations
247 ------------------------------------------------------------------*/ 305 ------------------------------------------------------------------*/
248static int queue_setup(struct vb2_queue *vq, const void *parg, 306static int queue_setup(struct vb2_queue *vq,
249 unsigned int *nbuffers, unsigned int *nplanes, 307 unsigned int *nbuffers, unsigned int *nplanes,
250 unsigned int sizes[], void *alloc_ctxs[]) 308 unsigned int sizes[], void *alloc_ctxs[])
251{ 309{
@@ -352,21 +410,35 @@ static void start_dma(struct atmel_isi *isi, struct frame_buffer *buffer)
352 ISI_SR_CXFR_DONE | ISI_SR_PXFR_DONE); 410 ISI_SR_CXFR_DONE | ISI_SR_PXFR_DONE);
353 411
354 /* Check if already in a frame */ 412 /* Check if already in a frame */
355 if (isi_readl(isi, ISI_STATUS) & ISI_CTRL_CDC) { 413 if (!isi->enable_preview_path) {
356 dev_err(isi->soc_host.icd->parent, "Already in frame handling.\n"); 414 if (isi_readl(isi, ISI_STATUS) & ISI_CTRL_CDC) {
357 return; 415 dev_err(isi->soc_host.icd->parent, "Already in frame handling.\n");
358 } 416 return;
417 }
359 418
360 isi_writel(isi, ISI_DMA_C_DSCR, (u32)buffer->p_dma_desc->fbd_phys); 419 isi_writel(isi, ISI_DMA_C_DSCR,
361 isi_writel(isi, ISI_DMA_C_CTRL, ISI_DMA_CTRL_FETCH | ISI_DMA_CTRL_DONE); 420 (u32)buffer->p_dma_desc->fbd_phys);
362 isi_writel(isi, ISI_DMA_CHER, ISI_DMA_CHSR_C_CH); 421 isi_writel(isi, ISI_DMA_C_CTRL,
422 ISI_DMA_CTRL_FETCH | ISI_DMA_CTRL_DONE);
423 isi_writel(isi, ISI_DMA_CHER, ISI_DMA_CHSR_C_CH);
424 } else {
425 isi_writel(isi, ISI_DMA_P_DSCR,
426 (u32)buffer->p_dma_desc->fbd_phys);
427 isi_writel(isi, ISI_DMA_P_CTRL,
428 ISI_DMA_CTRL_FETCH | ISI_DMA_CTRL_DONE);
429 isi_writel(isi, ISI_DMA_CHER, ISI_DMA_CHSR_P_CH);
430 }
363 431
364 cfg1 &= ~ISI_CFG1_FRATE_DIV_MASK; 432 cfg1 &= ~ISI_CFG1_FRATE_DIV_MASK;
365 /* Enable linked list */ 433 /* Enable linked list */
366 cfg1 |= isi->pdata.frate | ISI_CFG1_DISCR; 434 cfg1 |= isi->pdata.frate | ISI_CFG1_DISCR;
367 435
368 /* Enable codec path and ISI */ 436 /* Enable ISI */
369 ctrl = ISI_CTRL_CDC | ISI_CTRL_EN; 437 ctrl = ISI_CTRL_EN;
438
439 if (!isi->enable_preview_path)
440 ctrl |= ISI_CTRL_CDC;
441
370 isi_writel(isi, ISI_CTRL, ctrl); 442 isi_writel(isi, ISI_CTRL, ctrl);
371 isi_writel(isi, ISI_CFG1, cfg1); 443 isi_writel(isi, ISI_CFG1, cfg1);
372} 444}
@@ -411,7 +483,7 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
411 isi_writel(isi, ISI_INTDIS, (u32)~0UL); 483 isi_writel(isi, ISI_INTDIS, (u32)~0UL);
412 484
413 configure_geometry(isi, icd->user_width, icd->user_height, 485 configure_geometry(isi, icd->user_width, icd->user_height,
414 icd->current_fmt->code); 486 icd->current_fmt);
415 487
416 spin_lock_irq(&isi->lock); 488 spin_lock_irq(&isi->lock);
417 /* Clear any pending interrupt */ 489 /* Clear any pending interrupt */
@@ -443,15 +515,17 @@ static void stop_streaming(struct vb2_queue *vq)
443 } 515 }
444 spin_unlock_irq(&isi->lock); 516 spin_unlock_irq(&isi->lock);
445 517
446 timeout = jiffies + FRAME_INTERVAL_MILLI_SEC * HZ; 518 if (!isi->enable_preview_path) {
447 /* Wait until the end of the current frame. */ 519 timeout = jiffies + FRAME_INTERVAL_MILLI_SEC * HZ;
448 while ((isi_readl(isi, ISI_STATUS) & ISI_CTRL_CDC) && 520 /* Wait until the end of the current frame. */
449 time_before(jiffies, timeout)) 521 while ((isi_readl(isi, ISI_STATUS) & ISI_CTRL_CDC) &&
450 msleep(1); 522 time_before(jiffies, timeout))
523 msleep(1);
451 524
452 if (time_after(jiffies, timeout)) 525 if (time_after(jiffies, timeout))
453 dev_err(icd->parent, 526 dev_err(icd->parent,
454 "Timeout waiting for finishing codec request\n"); 527 "Timeout waiting for finishing codec request\n");
528 }
455 529
456 /* Disable interrupts */ 530 /* Disable interrupts */
457 isi_writel(isi, ISI_INTDIS, 531 isi_writel(isi, ISI_INTDIS,
@@ -617,6 +691,14 @@ static const struct soc_mbus_pixelfmt isi_camera_formats[] = {
617 .order = SOC_MBUS_ORDER_LE, 691 .order = SOC_MBUS_ORDER_LE,
618 .layout = SOC_MBUS_LAYOUT_PACKED, 692 .layout = SOC_MBUS_LAYOUT_PACKED,
619 }, 693 },
694 {
695 .fourcc = V4L2_PIX_FMT_RGB565,
696 .name = "RGB565",
697 .bits_per_sample = 8,
698 .packing = SOC_MBUS_PACKING_2X8_PADHI,
699 .order = SOC_MBUS_ORDER_LE,
700 .layout = SOC_MBUS_LAYOUT_PACKED,
701 },
620}; 702};
621 703
622/* This will be corrected as we get more formats */ 704/* This will be corrected as we get more formats */
@@ -673,7 +755,7 @@ static int isi_camera_get_formats(struct soc_camera_device *icd,
673 struct soc_camera_format_xlate *xlate) 755 struct soc_camera_format_xlate *xlate)
674{ 756{
675 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); 757 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
676 int formats = 0, ret; 758 int formats = 0, ret, i, n;
677 /* sensor format */ 759 /* sensor format */
678 struct v4l2_subdev_mbus_code_enum code = { 760 struct v4l2_subdev_mbus_code_enum code = {
679 .which = V4L2_SUBDEV_FORMAT_ACTIVE, 761 .which = V4L2_SUBDEV_FORMAT_ACTIVE,
@@ -707,11 +789,11 @@ static int isi_camera_get_formats(struct soc_camera_device *icd,
707 case MEDIA_BUS_FMT_VYUY8_2X8: 789 case MEDIA_BUS_FMT_VYUY8_2X8:
708 case MEDIA_BUS_FMT_YUYV8_2X8: 790 case MEDIA_BUS_FMT_YUYV8_2X8:
709 case MEDIA_BUS_FMT_YVYU8_2X8: 791 case MEDIA_BUS_FMT_YVYU8_2X8:
710 formats++; 792 n = ARRAY_SIZE(isi_camera_formats);
711 if (xlate) { 793 formats += n;
712 xlate->host_fmt = &isi_camera_formats[0]; 794 for (i = 0; xlate && i < n; i++, xlate++) {
795 xlate->host_fmt = &isi_camera_formats[i];
713 xlate->code = code.code; 796 xlate->code = code.code;
714 xlate++;
715 dev_dbg(icd->parent, "Providing format %s using code %d\n", 797 dev_dbg(icd->parent, "Providing format %s using code %d\n",
716 isi_camera_formats[0].name, code.code); 798 isi_camera_formats[0].name, code.code);
717 } 799 }
diff --git a/drivers/media/platform/soc_camera/atmel-isi.h b/drivers/media/platform/soc_camera/atmel-isi.h
index 5acc771d2edc..0acb32a2b65c 100644
--- a/drivers/media/platform/soc_camera/atmel-isi.h
+++ b/drivers/media/platform/soc_camera/atmel-isi.h
@@ -79,6 +79,16 @@
79#define ISI_CFG2_IM_VSIZE_MASK (0x7FF << ISI_CFG2_IM_VSIZE_OFFSET) 79#define ISI_CFG2_IM_VSIZE_MASK (0x7FF << ISI_CFG2_IM_VSIZE_OFFSET)
80#define ISI_CFG2_IM_HSIZE_MASK (0x7FF << ISI_CFG2_IM_HSIZE_OFFSET) 80#define ISI_CFG2_IM_HSIZE_MASK (0x7FF << ISI_CFG2_IM_HSIZE_OFFSET)
81 81
82/* Bitfields in PSIZE */
83#define ISI_PSIZE_PREV_VSIZE_OFFSET 0
84#define ISI_PSIZE_PREV_HSIZE_OFFSET 16
85#define ISI_PSIZE_PREV_VSIZE_MASK (0x3FF << ISI_PSIZE_PREV_VSIZE_OFFSET)
86#define ISI_PSIZE_PREV_HSIZE_MASK (0x3FF << ISI_PSIZE_PREV_HSIZE_OFFSET)
87
88/* Bitfields in PDECF */
89#define ISI_PDECF_DEC_FACTOR_MASK (0xFF << 0)
90#define ISI_PDECF_NO_SAMPLING (16)
91
82/* Bitfields in CTRL */ 92/* Bitfields in CTRL */
83/* Also using in SR(ISI_V2) */ 93/* Also using in SR(ISI_V2) */
84#define ISI_CTRL_EN (1 << 0) 94#define ISI_CTRL_EN (1 << 0)
diff --git a/drivers/media/platform/soc_camera/mx2_camera.c b/drivers/media/platform/soc_camera/mx2_camera.c
index 1f28d21a3c9a..48dd5b7851b5 100644
--- a/drivers/media/platform/soc_camera/mx2_camera.c
+++ b/drivers/media/platform/soc_camera/mx2_camera.c
@@ -35,11 +35,11 @@
35#include <media/videobuf2-v4l2.h> 35#include <media/videobuf2-v4l2.h>
36#include <media/videobuf2-dma-contig.h> 36#include <media/videobuf2-dma-contig.h>
37#include <media/soc_camera.h> 37#include <media/soc_camera.h>
38#include <media/soc_mediabus.h> 38#include <media/drv-intf/soc_mediabus.h>
39 39
40#include <linux/videodev2.h> 40#include <linux/videodev2.h>
41 41
42#include <linux/platform_data/camera-mx2.h> 42#include <linux/platform_data/media/camera-mx2.h>
43 43
44#include <asm/dma.h> 44#include <asm/dma.h>
45 45
@@ -469,21 +469,15 @@ static void mx2_camera_clock_stop(struct soc_camera_host *ici)
469 * Videobuf operations 469 * Videobuf operations
470 */ 470 */
471static int mx2_videobuf_setup(struct vb2_queue *vq, 471static int mx2_videobuf_setup(struct vb2_queue *vq,
472 const void *parg,
473 unsigned int *count, unsigned int *num_planes, 472 unsigned int *count, unsigned int *num_planes,
474 unsigned int sizes[], void *alloc_ctxs[]) 473 unsigned int sizes[], void *alloc_ctxs[])
475{ 474{
476 const struct v4l2_format *fmt = parg;
477 struct soc_camera_device *icd = soc_camera_from_vb2q(vq); 475 struct soc_camera_device *icd = soc_camera_from_vb2q(vq);
478 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); 476 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
479 struct mx2_camera_dev *pcdev = ici->priv; 477 struct mx2_camera_dev *pcdev = ici->priv;
480 478
481 dev_dbg(icd->parent, "count=%d, size=%d\n", *count, sizes[0]); 479 dev_dbg(icd->parent, "count=%d, size=%d\n", *count, sizes[0]);
482 480
483 /* TODO: support for VIDIOC_CREATE_BUFS not ready */
484 if (fmt != NULL)
485 return -ENOTTY;
486
487 alloc_ctxs[0] = pcdev->alloc_ctx; 481 alloc_ctxs[0] = pcdev->alloc_ctx;
488 482
489 sizes[0] = icd->sizeimage; 483 sizes[0] = icd->sizeimage;
@@ -1351,7 +1345,7 @@ static void mx27_camera_frame_done_emma(struct mx2_camera_dev *pcdev,
1351 vb2_get_plane_payload(vb, 0)); 1345 vb2_get_plane_payload(vb, 0));
1352 1346
1353 list_del_init(&buf->internal.queue); 1347 list_del_init(&buf->internal.queue);
1354 v4l2_get_timestamp(&vbuf->timestamp); 1348 vb->timestamp = ktime_get_ns();
1355 vbuf->sequence = pcdev->frame_count; 1349 vbuf->sequence = pcdev->frame_count;
1356 if (err) 1350 if (err)
1357 vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); 1351 vb2_buffer_done(vb, VB2_BUF_STATE_ERROR);
diff --git a/drivers/media/platform/soc_camera/mx3_camera.c b/drivers/media/platform/soc_camera/mx3_camera.c
index 49c3a257a916..169ed1150226 100644
--- a/drivers/media/platform/soc_camera/mx3_camera.c
+++ b/drivers/media/platform/soc_camera/mx3_camera.c
@@ -23,9 +23,9 @@
23#include <media/v4l2-dev.h> 23#include <media/v4l2-dev.h>
24#include <media/videobuf2-dma-contig.h> 24#include <media/videobuf2-dma-contig.h>
25#include <media/soc_camera.h> 25#include <media/soc_camera.h>
26#include <media/soc_mediabus.h> 26#include <media/drv-intf/soc_mediabus.h>
27 27
28#include <linux/platform_data/camera-mx3.h> 28#include <linux/platform_data/media/camera-mx3.h>
29#include <linux/platform_data/dma-imx.h> 29#include <linux/platform_data/dma-imx.h>
30 30
31#define MX3_CAM_DRV_NAME "mx3-camera" 31#define MX3_CAM_DRV_NAME "mx3-camera"
@@ -155,7 +155,7 @@ static void mx3_cam_dma_done(void *arg)
155 struct mx3_camera_buffer *buf = to_mx3_vb(vb); 155 struct mx3_camera_buffer *buf = to_mx3_vb(vb);
156 156
157 list_del_init(&buf->queue); 157 list_del_init(&buf->queue);
158 v4l2_get_timestamp(&vb->timestamp); 158 vb->vb2_buf.timestamp = ktime_get_ns();
159 vb->field = mx3_cam->field; 159 vb->field = mx3_cam->field;
160 vb->sequence = mx3_cam->sequence++; 160 vb->sequence = mx3_cam->sequence++;
161 vb2_buffer_done(&vb->vb2_buf, VB2_BUF_STATE_DONE); 161 vb2_buffer_done(&vb->vb2_buf, VB2_BUF_STATE_DONE);
@@ -185,11 +185,9 @@ static void mx3_cam_dma_done(void *arg)
185 * Calculate the __buffer__ (not data) size and number of buffers. 185 * Calculate the __buffer__ (not data) size and number of buffers.
186 */ 186 */
187static int mx3_videobuf_setup(struct vb2_queue *vq, 187static int mx3_videobuf_setup(struct vb2_queue *vq,
188 const void *parg,
189 unsigned int *count, unsigned int *num_planes, 188 unsigned int *count, unsigned int *num_planes,
190 unsigned int sizes[], void *alloc_ctxs[]) 189 unsigned int sizes[], void *alloc_ctxs[])
191{ 190{
192 const struct v4l2_format *fmt = parg;
193 struct soc_camera_device *icd = soc_camera_from_vb2q(vq); 191 struct soc_camera_device *icd = soc_camera_from_vb2q(vq);
194 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); 192 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
195 struct mx3_camera_dev *mx3_cam = ici->priv; 193 struct mx3_camera_dev *mx3_cam = ici->priv;
@@ -197,33 +195,6 @@ static int mx3_videobuf_setup(struct vb2_queue *vq,
197 if (!mx3_cam->idmac_channel[0]) 195 if (!mx3_cam->idmac_channel[0])
198 return -EINVAL; 196 return -EINVAL;
199 197
200 if (fmt) {
201 const struct soc_camera_format_xlate *xlate = soc_camera_xlate_by_fourcc(icd,
202 fmt->fmt.pix.pixelformat);
203 unsigned int bytes_per_line;
204 int ret;
205
206 if (!xlate)
207 return -EINVAL;
208
209 ret = soc_mbus_bytes_per_line(fmt->fmt.pix.width,
210 xlate->host_fmt);
211 if (ret < 0)
212 return ret;
213
214 bytes_per_line = max_t(u32, fmt->fmt.pix.bytesperline, ret);
215
216 ret = soc_mbus_image_size(xlate->host_fmt, bytes_per_line,
217 fmt->fmt.pix.height);
218 if (ret < 0)
219 return ret;
220
221 sizes[0] = max_t(u32, fmt->fmt.pix.sizeimage, ret);
222 } else {
223 /* Called from VIDIOC_REQBUFS or in compatibility mode */
224 sizes[0] = icd->sizeimage;
225 }
226
227 alloc_ctxs[0] = mx3_cam->alloc_ctx; 198 alloc_ctxs[0] = mx3_cam->alloc_ctx;
228 199
229 if (!vq->num_buffers) 200 if (!vq->num_buffers)
@@ -232,9 +203,14 @@ static int mx3_videobuf_setup(struct vb2_queue *vq,
232 if (!*count) 203 if (!*count)
233 *count = 2; 204 *count = 2;
234 205
206 /* Called from VIDIOC_REQBUFS or in compatibility mode */
207 if (!*num_planes)
208 sizes[0] = icd->sizeimage;
209 else if (sizes[0] < icd->sizeimage)
210 return -EINVAL;
211
235 /* If *num_planes != 0, we have already verified *count. */ 212 /* If *num_planes != 0, we have already verified *count. */
236 if (!*num_planes && 213 if (sizes[0] * *count + mx3_cam->buf_total > MAX_VIDEO_MEM * 1024 * 1024)
237 sizes[0] * *count + mx3_cam->buf_total > MAX_VIDEO_MEM * 1024 * 1024)
238 *count = (MAX_VIDEO_MEM * 1024 * 1024 - mx3_cam->buf_total) / 214 *count = (MAX_VIDEO_MEM * 1024 * 1024 - mx3_cam->buf_total) /
239 sizes[0]; 215 sizes[0];
240 216
diff --git a/drivers/media/platform/soc_camera/omap1_camera.c b/drivers/media/platform/soc_camera/omap1_camera.c
index ba8dcd11ae0e..bd721e35474a 100644
--- a/drivers/media/platform/soc_camera/omap1_camera.c
+++ b/drivers/media/platform/soc_camera/omap1_camera.c
@@ -28,9 +28,9 @@
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30 30
31#include <media/omap1_camera.h> 31#include <linux/platform_data/media/omap1_camera.h>
32#include <media/soc_camera.h> 32#include <media/soc_camera.h>
33#include <media/soc_mediabus.h> 33#include <media/drv-intf/soc_mediabus.h>
34#include <media/videobuf-dma-contig.h> 34#include <media/videobuf-dma-contig.h>
35#include <media/videobuf-dma-sg.h> 35#include <media/videobuf-dma-sg.h>
36 36
diff --git a/drivers/media/platform/soc_camera/pxa_camera.c b/drivers/media/platform/soc_camera/pxa_camera.c
index fcb942de0c7f..415f3bda60bf 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -33,13 +33,13 @@
33#include <media/v4l2-dev.h> 33#include <media/v4l2-dev.h>
34#include <media/videobuf-dma-sg.h> 34#include <media/videobuf-dma-sg.h>
35#include <media/soc_camera.h> 35#include <media/soc_camera.h>
36#include <media/soc_mediabus.h> 36#include <media/drv-intf/soc_mediabus.h>
37#include <media/v4l2-of.h> 37#include <media/v4l2-of.h>
38 38
39#include <linux/videodev2.h> 39#include <linux/videodev2.h>
40 40
41#include <mach/dma.h> 41#include <mach/dma.h>
42#include <linux/platform_data/camera-pxa.h> 42#include <linux/platform_data/media/camera-pxa.h>
43 43
44#define PXA_CAM_VERSION "0.0.6" 44#define PXA_CAM_VERSION "0.0.6"
45#define PXA_CAM_DRV_NAME "pxa27x-camera" 45#define PXA_CAM_DRV_NAME "pxa27x-camera"
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index efe57b23fac1..b7fd695b9ed5 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -21,14 +21,13 @@
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/of.h> 22#include <linux/of.h>
23#include <linux/of_device.h> 23#include <linux/of_device.h>
24#include <linux/platform_data/camera-rcar.h>
25#include <linux/platform_device.h> 24#include <linux/platform_device.h>
26#include <linux/pm_runtime.h> 25#include <linux/pm_runtime.h>
27#include <linux/slab.h> 26#include <linux/slab.h>
28#include <linux/videodev2.h> 27#include <linux/videodev2.h>
29 28
30#include <media/soc_camera.h> 29#include <media/soc_camera.h>
31#include <media/soc_mediabus.h> 30#include <media/drv-intf/soc_mediabus.h>
32#include <media/v4l2-common.h> 31#include <media/v4l2-common.h>
33#include <media/v4l2-dev.h> 32#include <media/v4l2-dev.h>
34#include <media/v4l2-device.h> 33#include <media/v4l2-device.h>
@@ -138,6 +137,11 @@
138 137
139#define TIMEOUT_MS 100 138#define TIMEOUT_MS 100
140 139
140#define RCAR_VIN_HSYNC_ACTIVE_LOW (1 << 0)
141#define RCAR_VIN_VSYNC_ACTIVE_LOW (1 << 1)
142#define RCAR_VIN_BT601 (1 << 2)
143#define RCAR_VIN_BT656 (1 << 3)
144
141enum chip_id { 145enum chip_id {
142 RCAR_GEN2, 146 RCAR_GEN2,
143 RCAR_H1, 147 RCAR_H1,
@@ -527,46 +531,14 @@ struct rcar_vin_cam {
527 * required 531 * required
528 */ 532 */
529static int rcar_vin_videobuf_setup(struct vb2_queue *vq, 533static int rcar_vin_videobuf_setup(struct vb2_queue *vq,
530 const void *parg,
531 unsigned int *count, 534 unsigned int *count,
532 unsigned int *num_planes, 535 unsigned int *num_planes,
533 unsigned int sizes[], void *alloc_ctxs[]) 536 unsigned int sizes[], void *alloc_ctxs[])
534{ 537{
535 const struct v4l2_format *fmt = parg;
536 struct soc_camera_device *icd = soc_camera_from_vb2q(vq); 538 struct soc_camera_device *icd = soc_camera_from_vb2q(vq);
537 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); 539 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
538 struct rcar_vin_priv *priv = ici->priv; 540 struct rcar_vin_priv *priv = ici->priv;
539 541
540 if (fmt) {
541 const struct soc_camera_format_xlate *xlate;
542 unsigned int bytes_per_line;
543 int ret;
544
545 if (fmt->fmt.pix.sizeimage < icd->sizeimage)
546 return -EINVAL;
547
548 xlate = soc_camera_xlate_by_fourcc(icd,
549 fmt->fmt.pix.pixelformat);
550 if (!xlate)
551 return -EINVAL;
552 ret = soc_mbus_bytes_per_line(fmt->fmt.pix.width,
553 xlate->host_fmt);
554 if (ret < 0)
555 return ret;
556
557 bytes_per_line = max_t(u32, fmt->fmt.pix.bytesperline, ret);
558
559 ret = soc_mbus_image_size(xlate->host_fmt, bytes_per_line,
560 fmt->fmt.pix.height);
561 if (ret < 0)
562 return ret;
563
564 sizes[0] = max_t(u32, fmt->fmt.pix.sizeimage, ret);
565 } else {
566 /* Called from VIDIOC_REQBUFS or in compatibility mode */
567 sizes[0] = icd->sizeimage;
568 }
569
570 alloc_ctxs[0] = priv->alloc_ctx; 542 alloc_ctxs[0] = priv->alloc_ctx;
571 543
572 if (!vq->num_buffers) 544 if (!vq->num_buffers)
@@ -576,14 +548,18 @@ static int rcar_vin_videobuf_setup(struct vb2_queue *vq,
576 *count = 2; 548 *count = 2;
577 priv->vb_count = *count; 549 priv->vb_count = *count;
578 550
579 *num_planes = 1;
580
581 /* Number of hardware slots */ 551 /* Number of hardware slots */
582 if (is_continuous_transfer(priv)) 552 if (is_continuous_transfer(priv))
583 priv->nr_hw_slots = MAX_BUFFER_NUM; 553 priv->nr_hw_slots = MAX_BUFFER_NUM;
584 else 554 else
585 priv->nr_hw_slots = 1; 555 priv->nr_hw_slots = 1;
586 556
557 if (*num_planes)
558 return sizes[0] < icd->sizeimage ? -EINVAL : 0;
559
560 sizes[0] = icd->sizeimage;
561 *num_planes = 1;
562
587 dev_dbg(icd->parent, "count=%d, size=%u\n", *count, sizes[0]); 563 dev_dbg(icd->parent, "count=%d, size=%u\n", *count, sizes[0]);
588 564
589 return 0; 565 return 0;
@@ -912,7 +888,7 @@ static irqreturn_t rcar_vin_irq(int irq, void *data)
912 888
913 priv->queue_buf[slot]->field = priv->field; 889 priv->queue_buf[slot]->field = priv->field;
914 priv->queue_buf[slot]->sequence = priv->sequence++; 890 priv->queue_buf[slot]->sequence = priv->sequence++;
915 v4l2_get_timestamp(&priv->queue_buf[slot]->timestamp); 891 priv->queue_buf[slot]->vb2_buf.timestamp = ktime_get_ns();
916 vb2_buffer_done(&priv->queue_buf[slot]->vb2_buf, 892 vb2_buffer_done(&priv->queue_buf[slot]->vb2_buf,
917 VB2_BUF_STATE_DONE); 893 VB2_BUF_STATE_DONE);
918 priv->queue_buf[slot] = NULL; 894 priv->queue_buf[slot] = NULL;
@@ -1853,63 +1829,43 @@ static const struct of_device_id rcar_vin_of_table[] = {
1853MODULE_DEVICE_TABLE(of, rcar_vin_of_table); 1829MODULE_DEVICE_TABLE(of, rcar_vin_of_table);
1854#endif 1830#endif
1855 1831
1856static struct platform_device_id rcar_vin_id_table[] = {
1857 { "r8a7779-vin", RCAR_H1 },
1858 { "r8a7778-vin", RCAR_M1 },
1859 { "uPD35004-vin", RCAR_E1 },
1860 {},
1861};
1862MODULE_DEVICE_TABLE(platform, rcar_vin_id_table);
1863
1864static int rcar_vin_probe(struct platform_device *pdev) 1832static int rcar_vin_probe(struct platform_device *pdev)
1865{ 1833{
1866 const struct of_device_id *match = NULL; 1834 const struct of_device_id *match = NULL;
1867 struct rcar_vin_priv *priv; 1835 struct rcar_vin_priv *priv;
1836 struct v4l2_of_endpoint ep;
1837 struct device_node *np;
1868 struct resource *mem; 1838 struct resource *mem;
1869 struct rcar_vin_platform_data *pdata;
1870 unsigned int pdata_flags; 1839 unsigned int pdata_flags;
1871 int irq, ret; 1840 int irq, ret;
1872 1841
1873 if (pdev->dev.of_node) { 1842 match = of_match_device(of_match_ptr(rcar_vin_of_table), &pdev->dev);
1874 struct v4l2_of_endpoint ep;
1875 struct device_node *np;
1876 1843
1877 match = of_match_device(of_match_ptr(rcar_vin_of_table), 1844 np = of_graph_get_next_endpoint(pdev->dev.of_node, NULL);
1878 &pdev->dev); 1845 if (!np) {
1879 1846 dev_err(&pdev->dev, "could not find endpoint\n");
1880 np = of_graph_get_next_endpoint(pdev->dev.of_node, NULL); 1847 return -EINVAL;
1881 if (!np) { 1848 }
1882 dev_err(&pdev->dev, "could not find endpoint\n");
1883 return -EINVAL;
1884 }
1885 1849
1886 ret = v4l2_of_parse_endpoint(np, &ep); 1850 ret = v4l2_of_parse_endpoint(np, &ep);
1887 if (ret) { 1851 if (ret) {
1888 dev_err(&pdev->dev, "could not parse endpoint\n"); 1852 dev_err(&pdev->dev, "could not parse endpoint\n");
1889 return ret; 1853 return ret;
1890 } 1854 }
1891 1855
1892 if (ep.bus_type == V4L2_MBUS_BT656) 1856 if (ep.bus_type == V4L2_MBUS_BT656)
1893 pdata_flags = RCAR_VIN_BT656; 1857 pdata_flags = RCAR_VIN_BT656;
1894 else { 1858 else {
1895 pdata_flags = 0; 1859 pdata_flags = 0;
1896 if (ep.bus.parallel.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW) 1860 if (ep.bus.parallel.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
1897 pdata_flags |= RCAR_VIN_HSYNC_ACTIVE_LOW; 1861 pdata_flags |= RCAR_VIN_HSYNC_ACTIVE_LOW;
1898 if (ep.bus.parallel.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW) 1862 if (ep.bus.parallel.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
1899 pdata_flags |= RCAR_VIN_VSYNC_ACTIVE_LOW; 1863 pdata_flags |= RCAR_VIN_VSYNC_ACTIVE_LOW;
1900 } 1864 }
1901 1865
1902 of_node_put(np); 1866 of_node_put(np);
1903 1867
1904 dev_dbg(&pdev->dev, "pdata_flags = %08x\n", pdata_flags); 1868 dev_dbg(&pdev->dev, "pdata_flags = %08x\n", pdata_flags);
1905 } else {
1906 pdata = pdev->dev.platform_data;
1907 if (!pdata || !pdata->flags) {
1908 dev_err(&pdev->dev, "platform data not set\n");
1909 return -EINVAL;
1910 }
1911 pdata_flags = pdata->flags;
1912 }
1913 1869
1914 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1870 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1915 if (mem == NULL) 1871 if (mem == NULL)
@@ -1992,7 +1948,6 @@ static struct platform_driver rcar_vin_driver = {
1992 .name = DRV_NAME, 1948 .name = DRV_NAME,
1993 .of_match_table = of_match_ptr(rcar_vin_of_table), 1949 .of_match_table = of_match_ptr(rcar_vin_of_table),
1994 }, 1950 },
1995 .id_table = rcar_vin_id_table,
1996}; 1951};
1997 1952
1998module_platform_driver(rcar_vin_driver); 1953module_platform_driver(rcar_vin_driver);
diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
index 67a669d826b8..90c87f2b4ec0 100644
--- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
+++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
@@ -40,11 +40,11 @@
40#include <media/v4l2-common.h> 40#include <media/v4l2-common.h>
41#include <media/v4l2-dev.h> 41#include <media/v4l2-dev.h>
42#include <media/soc_camera.h> 42#include <media/soc_camera.h>
43#include <media/sh_mobile_ceu.h> 43#include <media/drv-intf/sh_mobile_ceu.h>
44#include <media/sh_mobile_csi2.h> 44#include <media/drv-intf/sh_mobile_csi2.h>
45#include <media/videobuf2-dma-contig.h> 45#include <media/videobuf2-dma-contig.h>
46#include <media/v4l2-mediabus.h> 46#include <media/v4l2-mediabus.h>
47#include <media/soc_mediabus.h> 47#include <media/drv-intf/soc_mediabus.h>
48 48
49#include "soc_scale_crop.h" 49#include "soc_scale_crop.h"
50 50
@@ -210,43 +210,14 @@ static int sh_mobile_ceu_soft_reset(struct sh_mobile_ceu_dev *pcdev)
210 * for the current frame format if required 210 * for the current frame format if required
211 */ 211 */
212static int sh_mobile_ceu_videobuf_setup(struct vb2_queue *vq, 212static int sh_mobile_ceu_videobuf_setup(struct vb2_queue *vq,
213 const void *parg,
214 unsigned int *count, unsigned int *num_planes, 213 unsigned int *count, unsigned int *num_planes,
215 unsigned int sizes[], void *alloc_ctxs[]) 214 unsigned int sizes[], void *alloc_ctxs[])
216{ 215{
217 const struct v4l2_format *fmt = parg;
218 struct soc_camera_device *icd = container_of(vq, 216 struct soc_camera_device *icd = container_of(vq,
219 struct soc_camera_device, vb2_vidq); 217 struct soc_camera_device, vb2_vidq);
220 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); 218 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
221 struct sh_mobile_ceu_dev *pcdev = ici->priv; 219 struct sh_mobile_ceu_dev *pcdev = ici->priv;
222 220
223 if (fmt) {
224 const struct soc_camera_format_xlate *xlate = soc_camera_xlate_by_fourcc(icd,
225 fmt->fmt.pix.pixelformat);
226 unsigned int bytes_per_line;
227 int ret;
228
229 if (!xlate)
230 return -EINVAL;
231
232 ret = soc_mbus_bytes_per_line(fmt->fmt.pix.width,
233 xlate->host_fmt);
234 if (ret < 0)
235 return ret;
236
237 bytes_per_line = max_t(u32, fmt->fmt.pix.bytesperline, ret);
238
239 ret = soc_mbus_image_size(xlate->host_fmt, bytes_per_line,
240 fmt->fmt.pix.height);
241 if (ret < 0)
242 return ret;
243
244 sizes[0] = max_t(u32, fmt->fmt.pix.sizeimage, ret);
245 } else {
246 /* Called from VIDIOC_REQBUFS or in compatibility mode */
247 sizes[0] = icd->sizeimage;
248 }
249
250 alloc_ctxs[0] = pcdev->alloc_ctx; 221 alloc_ctxs[0] = pcdev->alloc_ctx;
251 222
252 if (!vq->num_buffers) 223 if (!vq->num_buffers)
@@ -255,8 +226,14 @@ static int sh_mobile_ceu_videobuf_setup(struct vb2_queue *vq,
255 if (!*count) 226 if (!*count)
256 *count = 2; 227 *count = 2;
257 228
229 /* Called from VIDIOC_REQBUFS or in compatibility mode */
230 if (!*num_planes)
231 sizes[0] = icd->sizeimage;
232 else if (sizes[0] < icd->sizeimage)
233 return -EINVAL;
234
258 /* If *num_planes != 0, we have already verified *count. */ 235 /* If *num_planes != 0, we have already verified *count. */
259 if (pcdev->video_limit && !*num_planes) { 236 if (pcdev->video_limit) {
260 size_t size = PAGE_ALIGN(sizes[0]) * *count; 237 size_t size = PAGE_ALIGN(sizes[0]) * *count;
261 238
262 if (size + pcdev->buf_total > pcdev->video_limit) 239 if (size + pcdev->buf_total > pcdev->video_limit)
@@ -533,7 +510,7 @@ static irqreturn_t sh_mobile_ceu_irq(int irq, void *data)
533 pcdev->active = NULL; 510 pcdev->active = NULL;
534 511
535 ret = sh_mobile_ceu_capture(pcdev); 512 ret = sh_mobile_ceu_capture(pcdev);
536 v4l2_get_timestamp(&vbuf->timestamp); 513 vbuf->vb2_buf.timestamp = ktime_get_ns();
537 if (!ret) { 514 if (!ret) {
538 vbuf->field = pcdev->field; 515 vbuf->field = pcdev->field;
539 vbuf->sequence = pcdev->sequence++; 516 vbuf->sequence = pcdev->sequence++;
diff --git a/drivers/media/platform/soc_camera/sh_mobile_csi2.c b/drivers/media/platform/soc_camera/sh_mobile_csi2.c
index 12d3626ecf22..09b18365a4b1 100644
--- a/drivers/media/platform/soc_camera/sh_mobile_csi2.c
+++ b/drivers/media/platform/soc_camera/sh_mobile_csi2.c
@@ -18,10 +18,10 @@
18#include <linux/videodev2.h> 18#include <linux/videodev2.h>
19#include <linux/module.h> 19#include <linux/module.h>
20 20
21#include <media/sh_mobile_ceu.h> 21#include <media/drv-intf/sh_mobile_ceu.h>
22#include <media/sh_mobile_csi2.h> 22#include <media/drv-intf/sh_mobile_csi2.h>
23#include <media/soc_camera.h> 23#include <media/soc_camera.h>
24#include <media/soc_mediabus.h> 24#include <media/drv-intf/soc_mediabus.h>
25#include <media/v4l2-common.h> 25#include <media/v4l2-common.h>
26#include <media/v4l2-dev.h> 26#include <media/v4l2-dev.h>
27#include <media/v4l2-device.h> 27#include <media/v4l2-device.h>
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index dc98122e78dc..cc84c6d6a701 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -30,7 +30,7 @@
30#include <linux/vmalloc.h> 30#include <linux/vmalloc.h>
31 31
32#include <media/soc_camera.h> 32#include <media/soc_camera.h>
33#include <media/soc_mediabus.h> 33#include <media/drv-intf/soc_mediabus.h>
34#include <media/v4l2-async.h> 34#include <media/v4l2-async.h>
35#include <media/v4l2-clk.h> 35#include <media/v4l2-clk.h>
36#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
@@ -1360,7 +1360,7 @@ static int soc_camera_i2c_init(struct soc_camera_device *icd,
1360 struct soc_camera_host_desc *shd = &sdesc->host_desc; 1360 struct soc_camera_host_desc *shd = &sdesc->host_desc;
1361 struct i2c_adapter *adap; 1361 struct i2c_adapter *adap;
1362 struct v4l2_subdev *subdev; 1362 struct v4l2_subdev *subdev;
1363 char clk_name[V4L2_SUBDEV_NAME_SIZE]; 1363 char clk_name[V4L2_CLK_NAME_SIZE];
1364 int ret; 1364 int ret;
1365 1365
1366 /* First find out how we link the main client */ 1366 /* First find out how we link the main client */
@@ -1391,8 +1391,8 @@ static int soc_camera_i2c_init(struct soc_camera_device *icd,
1391 ssdd->sd_pdata.regulators = NULL; 1391 ssdd->sd_pdata.regulators = NULL;
1392 shd->board_info->platform_data = ssdd; 1392 shd->board_info->platform_data = ssdd;
1393 1393
1394 snprintf(clk_name, sizeof(clk_name), "%d-%04x", 1394 v4l2_clk_name_i2c(clk_name, sizeof(clk_name),
1395 shd->i2c_adapter_id, shd->board_info->addr); 1395 shd->i2c_adapter_id, shd->board_info->addr);
1396 1396
1397 icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd); 1397 icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd);
1398 if (IS_ERR(icd->clk)) { 1398 if (IS_ERR(icd->clk)) {
@@ -1526,7 +1526,7 @@ static int scan_async_group(struct soc_camera_host *ici,
1526 struct soc_camera_async_client *sasc; 1526 struct soc_camera_async_client *sasc;
1527 struct soc_camera_device *icd; 1527 struct soc_camera_device *icd;
1528 struct soc_camera_desc sdesc = {.host_desc.bus_id = ici->nr,}; 1528 struct soc_camera_desc sdesc = {.host_desc.bus_id = ici->nr,};
1529 char clk_name[V4L2_SUBDEV_NAME_SIZE]; 1529 char clk_name[V4L2_CLK_NAME_SIZE];
1530 unsigned int i; 1530 unsigned int i;
1531 int ret; 1531 int ret;
1532 1532
@@ -1572,8 +1572,9 @@ static int scan_async_group(struct soc_camera_host *ici,
1572 icd->sasc = sasc; 1572 icd->sasc = sasc;
1573 icd->parent = ici->v4l2_dev.dev; 1573 icd->parent = ici->v4l2_dev.dev;
1574 1574
1575 snprintf(clk_name, sizeof(clk_name), "%d-%04x", 1575 v4l2_clk_name_i2c(clk_name, sizeof(clk_name),
1576 sasd->asd.match.i2c.adapter_id, sasd->asd.match.i2c.address); 1576 sasd->asd.match.i2c.adapter_id,
1577 sasd->asd.match.i2c.address);
1577 1578
1578 icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd); 1579 icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd);
1579 if (IS_ERR(icd->clk)) { 1580 if (IS_ERR(icd->clk)) {
@@ -1631,7 +1632,7 @@ static int soc_of_bind(struct soc_camera_host *ici,
1631 struct soc_camera_async_client *sasc; 1632 struct soc_camera_async_client *sasc;
1632 struct soc_of_info *info; 1633 struct soc_of_info *info;
1633 struct i2c_client *client; 1634 struct i2c_client *client;
1634 char clk_name[V4L2_SUBDEV_NAME_SIZE + 32]; 1635 char clk_name[V4L2_CLK_NAME_SIZE];
1635 int ret; 1636 int ret;
1636 1637
1637 /* allocate a new subdev and add match info to it */ 1638 /* allocate a new subdev and add match info to it */
@@ -1674,11 +1675,11 @@ static int soc_of_bind(struct soc_camera_host *ici,
1674 client = of_find_i2c_device_by_node(remote); 1675 client = of_find_i2c_device_by_node(remote);
1675 1676
1676 if (client) 1677 if (client)
1677 snprintf(clk_name, sizeof(clk_name), "%d-%04x", 1678 v4l2_clk_name_i2c(clk_name, sizeof(clk_name),
1678 client->adapter->nr, client->addr); 1679 client->adapter->nr, client->addr);
1679 else 1680 else
1680 snprintf(clk_name, sizeof(clk_name), "of-%s", 1681 v4l2_clk_name_of(clk_name, sizeof(clk_name),
1681 of_node_full_name(remote)); 1682 of_node_full_name(remote));
1682 1683
1683 icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd); 1684 icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd);
1684 if (IS_ERR(icd->clk)) { 1685 if (IS_ERR(icd->clk)) {
diff --git a/drivers/media/platform/soc_camera/soc_camera_platform.c b/drivers/media/platform/soc_camera/soc_camera_platform.c
index cc8eb0758219..a51d2a42998c 100644
--- a/drivers/media/platform/soc_camera/soc_camera_platform.c
+++ b/drivers/media/platform/soc_camera/soc_camera_platform.c
@@ -18,7 +18,7 @@
18#include <linux/videodev2.h> 18#include <linux/videodev2.h>
19#include <media/v4l2-subdev.h> 19#include <media/v4l2-subdev.h>
20#include <media/soc_camera.h> 20#include <media/soc_camera.h>
21#include <media/soc_camera_platform.h> 21#include <linux/platform_data/media/soc_camera_platform.h>
22 22
23struct soc_camera_platform_priv { 23struct soc_camera_platform_priv {
24 struct v4l2_subdev subdev; 24 struct v4l2_subdev subdev;
diff --git a/drivers/media/platform/soc_camera/soc_mediabus.c b/drivers/media/platform/soc_camera/soc_mediabus.c
index 1dbcd426683c..e3e665e1c503 100644
--- a/drivers/media/platform/soc_camera/soc_mediabus.c
+++ b/drivers/media/platform/soc_camera/soc_mediabus.c
@@ -13,7 +13,7 @@
13 13
14#include <media/v4l2-device.h> 14#include <media/v4l2-device.h>
15#include <media/v4l2-mediabus.h> 15#include <media/v4l2-mediabus.h>
16#include <media/soc_mediabus.h> 16#include <media/drv-intf/soc_mediabus.h>
17 17
18static const struct soc_mbus_lookup mbus_fmt[] = { 18static const struct soc_mbus_lookup mbus_fmt[] = {
19{ 19{
diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
index a0d267e017f6..d12a419c044a 100644
--- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
+++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
@@ -191,7 +191,7 @@ static void bdisp_job_finish(struct bdisp_ctx *ctx, int vb_state)
191 dst_vb = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); 191 dst_vb = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
192 192
193 if (src_vb && dst_vb) { 193 if (src_vb && dst_vb) {
194 dst_vb->timestamp = src_vb->timestamp; 194 dst_vb->vb2_buf.timestamp = src_vb->vb2_buf.timestamp;
195 dst_vb->timecode = src_vb->timecode; 195 dst_vb->timecode = src_vb->timecode;
196 dst_vb->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 196 dst_vb->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
197 dst_vb->flags |= src_vb->flags & 197 dst_vb->flags |= src_vb->flags &
@@ -297,7 +297,7 @@ static int bdisp_get_bufs(struct bdisp_ctx *ctx)
297 if (ret) 297 if (ret)
298 return ret; 298 return ret;
299 299
300 dst_vb->timestamp = src_vb->timestamp; 300 dst_vb->vb2_buf.timestamp = src_vb->vb2_buf.timestamp;
301 301
302 return 0; 302 return 0;
303} 303}
@@ -438,11 +438,9 @@ static void bdisp_ctrls_delete(struct bdisp_ctx *ctx)
438} 438}
439 439
440static int bdisp_queue_setup(struct vb2_queue *vq, 440static int bdisp_queue_setup(struct vb2_queue *vq,
441 const void *parg,
442 unsigned int *nb_buf, unsigned int *nb_planes, 441 unsigned int *nb_buf, unsigned int *nb_planes,
443 unsigned int sizes[], void *allocators[]) 442 unsigned int sizes[], void *allocators[])
444{ 443{
445 const struct v4l2_format *fmt = parg;
446 struct bdisp_ctx *ctx = vb2_get_drv_priv(vq); 444 struct bdisp_ctx *ctx = vb2_get_drv_priv(vq);
447 struct bdisp_frame *frame = ctx_get_frame(ctx, vq->type); 445 struct bdisp_frame *frame = ctx_get_frame(ctx, vq->type);
448 446
@@ -455,13 +453,13 @@ static int bdisp_queue_setup(struct vb2_queue *vq,
455 dev_err(ctx->bdisp_dev->dev, "Invalid format\n"); 453 dev_err(ctx->bdisp_dev->dev, "Invalid format\n");
456 return -EINVAL; 454 return -EINVAL;
457 } 455 }
456 allocators[0] = ctx->bdisp_dev->alloc_ctx;
458 457
459 if (fmt && fmt->fmt.pix.sizeimage < frame->sizeimage) 458 if (*nb_planes)
460 return -EINVAL; 459 return sizes[0] < frame->sizeimage ? -EINVAL : 0;
461 460
462 *nb_planes = 1; 461 *nb_planes = 1;
463 sizes[0] = fmt ? fmt->fmt.pix.sizeimage : frame->sizeimage; 462 sizes[0] = frame->sizeimage;
464 allocators[0] = ctx->bdisp_dev->alloc_ctx;
465 463
466 return 0; 464 return 0;
467} 465}
diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
index 95223ab71e19..2dfbe8ab5214 100644
--- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
+++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
@@ -209,18 +209,18 @@ void c8sectpfe_tuner_unregister_frontend(struct c8sectpfe *c8sectpfe,
209 209
210 tsin = fei->channel_data[n]; 210 tsin = fei->channel_data[n];
211 211
212 if (tsin && tsin->frontend) { 212 if (tsin) {
213 dvb_unregister_frontend(tsin->frontend); 213 if (tsin->frontend) {
214 dvb_frontend_detach(tsin->frontend); 214 dvb_unregister_frontend(tsin->frontend);
215 } 215 dvb_frontend_detach(tsin->frontend);
216 }
216 217
217 if (tsin && tsin->i2c_adapter)
218 i2c_put_adapter(tsin->i2c_adapter); 218 i2c_put_adapter(tsin->i2c_adapter);
219 219
220 if (tsin && tsin->i2c_client) { 220 if (tsin->i2c_client) {
221 if (tsin->i2c_client->dev.driver->owner)
222 module_put(tsin->i2c_client->dev.driver->owner); 221 module_put(tsin->i2c_client->dev.driver->owner);
223 i2c_unregister_device(tsin->i2c_client); 222 i2c_unregister_device(tsin->i2c_client);
223 }
224 } 224 }
225 } 225 }
226 226
diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
index 8490a65ae1c6..78e3cb9a628f 100644
--- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
+++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
@@ -823,7 +823,7 @@ static int c8sectpfe_probe(struct platform_device *pdev)
823 } 823 }
824 of_node_put(i2c_bus); 824 of_node_put(i2c_bus);
825 825
826 tsin->rst_gpio = of_get_named_gpio(child, "rst-gpio", 0); 826 tsin->rst_gpio = of_get_named_gpio(child, "reset-gpios", 0);
827 827
828 ret = gpio_is_valid(tsin->rst_gpio); 828 ret = gpio_is_valid(tsin->rst_gpio);
829 if (!ret) { 829 if (!ret) {
diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c
index de24effd984f..1fa00c2cf3d7 100644
--- a/drivers/media/platform/ti-vpe/vpe.c
+++ b/drivers/media/platform/ti-vpe/vpe.c
@@ -1288,7 +1288,7 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
1288 d_vb = ctx->dst_vb; 1288 d_vb = ctx->dst_vb;
1289 1289
1290 d_vb->flags = s_vb->flags; 1290 d_vb->flags = s_vb->flags;
1291 d_vb->timestamp = s_vb->timestamp; 1291 d_vb->vb2_buf.timestamp = s_vb->vb2_buf.timestamp;
1292 1292
1293 if (s_vb->flags & V4L2_BUF_FLAG_TIMECODE) 1293 if (s_vb->flags & V4L2_BUF_FLAG_TIMECODE)
1294 d_vb->timecode = s_vb->timecode; 1294 d_vb->timecode = s_vb->timecode;
@@ -1796,7 +1796,6 @@ static const struct v4l2_ioctl_ops vpe_ioctl_ops = {
1796 * Queue operations 1796 * Queue operations
1797 */ 1797 */
1798static int vpe_queue_setup(struct vb2_queue *vq, 1798static int vpe_queue_setup(struct vb2_queue *vq,
1799 const void *parg,
1800 unsigned int *nbuffers, unsigned int *nplanes, 1799 unsigned int *nbuffers, unsigned int *nplanes,
1801 unsigned int sizes[], void *alloc_ctxs[]) 1800 unsigned int sizes[], void *alloc_ctxs[])
1802{ 1801{
diff --git a/drivers/media/platform/timblogiw.c b/drivers/media/platform/timblogiw.c
index 5820e45b3a9f..113c9f3c0b3e 100644
--- a/drivers/media/platform/timblogiw.c
+++ b/drivers/media/platform/timblogiw.c
@@ -31,7 +31,7 @@
31#include <media/v4l2-ioctl.h> 31#include <media/v4l2-ioctl.h>
32#include <media/v4l2-device.h> 32#include <media/v4l2-device.h>
33#include <media/videobuf-dma-contig.h> 33#include <media/videobuf-dma-contig.h>
34#include <media/timb_video.h> 34#include <linux/platform_data/media/timb_video.h>
35 35
36#define DRIVER_NAME "timb-video" 36#define DRIVER_NAME "timb-video"
37 37
diff --git a/drivers/media/platform/via-camera.c b/drivers/media/platform/via-camera.c
index 32e4ff46daf3..1254f7e4d732 100644
--- a/drivers/media/platform/via-camera.c
+++ b/drivers/media/platform/via-camera.c
@@ -19,7 +19,7 @@
19#include <media/v4l2-ioctl.h> 19#include <media/v4l2-ioctl.h>
20#include <media/v4l2-ctrls.h> 20#include <media/v4l2-ctrls.h>
21#include <media/v4l2-image-sizes.h> 21#include <media/v4l2-image-sizes.h>
22#include <media/ov7670.h> 22#include <media/i2c/ov7670.h>
23#include <media/videobuf-dma-sg.h> 23#include <media/videobuf-dma-sg.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/dma-mapping.h> 25#include <linux/dma-mapping.h>
diff --git a/drivers/media/platform/vim2m.c b/drivers/media/platform/vim2m.c
index e18fb9f9ed2f..418113c99801 100644
--- a/drivers/media/platform/vim2m.c
+++ b/drivers/media/platform/vim2m.c
@@ -235,7 +235,7 @@ static int device_process(struct vim2m_ctx *ctx,
235 out_vb->sequence = 235 out_vb->sequence =
236 get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE)->sequence++; 236 get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE)->sequence++;
237 in_vb->sequence = q_data->sequence++; 237 in_vb->sequence = q_data->sequence++;
238 out_vb->timestamp = in_vb->timestamp; 238 out_vb->vb2_buf.timestamp = in_vb->vb2_buf.timestamp;
239 239
240 if (in_vb->flags & V4L2_BUF_FLAG_TIMECODE) 240 if (in_vb->flags & V4L2_BUF_FLAG_TIMECODE)
241 out_vb->timecode = in_vb->timecode; 241 out_vb->timecode = in_vb->timecode;
@@ -710,11 +710,9 @@ static const struct v4l2_ioctl_ops vim2m_ioctl_ops = {
710 */ 710 */
711 711
712static int vim2m_queue_setup(struct vb2_queue *vq, 712static int vim2m_queue_setup(struct vb2_queue *vq,
713 const void *parg,
714 unsigned int *nbuffers, unsigned int *nplanes, 713 unsigned int *nbuffers, unsigned int *nplanes,
715 unsigned int sizes[], void *alloc_ctxs[]) 714 unsigned int sizes[], void *alloc_ctxs[])
716{ 715{
717 const struct v4l2_format *fmt = parg;
718 struct vim2m_ctx *ctx = vb2_get_drv_priv(vq); 716 struct vim2m_ctx *ctx = vb2_get_drv_priv(vq);
719 struct vim2m_q_data *q_data; 717 struct vim2m_q_data *q_data;
720 unsigned int size, count = *nbuffers; 718 unsigned int size, count = *nbuffers;
@@ -723,17 +721,14 @@ static int vim2m_queue_setup(struct vb2_queue *vq,
723 721
724 size = q_data->width * q_data->height * q_data->fmt->depth >> 3; 722 size = q_data->width * q_data->height * q_data->fmt->depth >> 3;
725 723
726 if (fmt) {
727 if (fmt->fmt.pix.sizeimage < size)
728 return -EINVAL;
729 size = fmt->fmt.pix.sizeimage;
730 }
731
732 while (size * count > MEM2MEM_VID_MEM_LIMIT) 724 while (size * count > MEM2MEM_VID_MEM_LIMIT)
733 (count)--; 725 (count)--;
726 *nbuffers = count;
727
728 if (*nplanes)
729 return sizes[0] < size ? -EINVAL : 0;
734 730
735 *nplanes = 1; 731 *nplanes = 1;
736 *nbuffers = count;
737 sizes[0] = size; 732 sizes[0] = size;
738 733
739 /* 734 /*
diff --git a/drivers/media/platform/vivid/vivid-core.h b/drivers/media/platform/vivid/vivid-core.h
index 55b304a705d5..751c1ba391e9 100644
--- a/drivers/media/platform/vivid/vivid-core.h
+++ b/drivers/media/platform/vivid/vivid-core.h
@@ -264,6 +264,7 @@ struct vivid_dev {
264 bool vflip; 264 bool vflip;
265 bool vbi_cap_interlaced; 265 bool vbi_cap_interlaced;
266 bool loop_video; 266 bool loop_video;
267 bool reduced_fps;
267 268
268 /* Framebuffer */ 269 /* Framebuffer */
269 unsigned long video_pbase; 270 unsigned long video_pbase;
@@ -285,7 +286,7 @@ struct vivid_dev {
285 bool dqbuf_error; 286 bool dqbuf_error;
286 bool seq_wrap; 287 bool seq_wrap;
287 bool time_wrap; 288 bool time_wrap;
288 __kernel_time_t time_wrap_offset; 289 u64 time_wrap_offset;
289 unsigned perc_dropped_buffers; 290 unsigned perc_dropped_buffers;
290 enum vivid_signal_mode std_signal_mode; 291 enum vivid_signal_mode std_signal_mode;
291 unsigned query_std_last; 292 unsigned query_std_last;
diff --git a/drivers/media/platform/vivid/vivid-ctrls.c b/drivers/media/platform/vivid/vivid-ctrls.c
index f41ac0b01fec..b98089c95ef5 100644
--- a/drivers/media/platform/vivid/vivid-ctrls.c
+++ b/drivers/media/platform/vivid/vivid-ctrls.c
@@ -78,6 +78,7 @@
78#define VIVID_CID_TIME_WRAP (VIVID_CID_VIVID_BASE + 39) 78#define VIVID_CID_TIME_WRAP (VIVID_CID_VIVID_BASE + 39)
79#define VIVID_CID_MAX_EDID_BLOCKS (VIVID_CID_VIVID_BASE + 40) 79#define VIVID_CID_MAX_EDID_BLOCKS (VIVID_CID_VIVID_BASE + 40)
80#define VIVID_CID_PERCENTAGE_FILL (VIVID_CID_VIVID_BASE + 41) 80#define VIVID_CID_PERCENTAGE_FILL (VIVID_CID_VIVID_BASE + 41)
81#define VIVID_CID_REDUCED_FPS (VIVID_CID_VIVID_BASE + 42)
81 82
82#define VIVID_CID_STD_SIGNAL_MODE (VIVID_CID_VIVID_BASE + 60) 83#define VIVID_CID_STD_SIGNAL_MODE (VIVID_CID_VIVID_BASE + 60)
83#define VIVID_CID_STANDARD (VIVID_CID_VIVID_BASE + 61) 84#define VIVID_CID_STANDARD (VIVID_CID_VIVID_BASE + 61)
@@ -424,6 +425,10 @@ static int vivid_vid_cap_s_ctrl(struct v4l2_ctrl *ctrl)
424 dev->sensor_vflip = ctrl->val; 425 dev->sensor_vflip = ctrl->val;
425 tpg_s_vflip(&dev->tpg, dev->sensor_vflip ^ dev->vflip); 426 tpg_s_vflip(&dev->tpg, dev->sensor_vflip ^ dev->vflip);
426 break; 427 break;
428 case VIVID_CID_REDUCED_FPS:
429 dev->reduced_fps = ctrl->val;
430 vivid_update_format_cap(dev, true);
431 break;
427 case VIVID_CID_HAS_CROP_CAP: 432 case VIVID_CID_HAS_CROP_CAP:
428 dev->has_crop_cap = ctrl->val; 433 dev->has_crop_cap = ctrl->val;
429 vivid_update_format_cap(dev, true); 434 vivid_update_format_cap(dev, true);
@@ -601,6 +606,15 @@ static const struct v4l2_ctrl_config vivid_ctrl_vflip = {
601 .step = 1, 606 .step = 1,
602}; 607};
603 608
609static const struct v4l2_ctrl_config vivid_ctrl_reduced_fps = {
610 .ops = &vivid_vid_cap_ctrl_ops,
611 .id = VIVID_CID_REDUCED_FPS,
612 .name = "Reduced Framerate",
613 .type = V4L2_CTRL_TYPE_BOOLEAN,
614 .max = 1,
615 .step = 1,
616};
617
604static const struct v4l2_ctrl_config vivid_ctrl_has_crop_cap = { 618static const struct v4l2_ctrl_config vivid_ctrl_has_crop_cap = {
605 .ops = &vivid_vid_cap_ctrl_ops, 619 .ops = &vivid_vid_cap_ctrl_ops,
606 .id = VIVID_CID_HAS_CROP_CAP, 620 .id = VIVID_CID_HAS_CROP_CAP,
@@ -940,7 +954,7 @@ static const struct v4l2_ctrl_config vivid_ctrl_has_scaler_out = {
940static int vivid_streaming_s_ctrl(struct v4l2_ctrl *ctrl) 954static int vivid_streaming_s_ctrl(struct v4l2_ctrl *ctrl)
941{ 955{
942 struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_streaming); 956 struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_streaming);
943 struct timeval tv; 957 u64 rem;
944 958
945 switch (ctrl->id) { 959 switch (ctrl->id) {
946 case VIVID_CID_DQBUF_ERROR: 960 case VIVID_CID_DQBUF_ERROR:
@@ -979,8 +993,16 @@ static int vivid_streaming_s_ctrl(struct v4l2_ctrl *ctrl)
979 dev->time_wrap_offset = 0; 993 dev->time_wrap_offset = 0;
980 break; 994 break;
981 } 995 }
982 v4l2_get_timestamp(&tv); 996 /*
983 dev->time_wrap_offset = -tv.tv_sec - 16; 997 * We want to set the time 16 seconds before the 32 bit tv_sec
998 * value of struct timeval would wrap around. So first we
999 * calculate ktime_get_ns() % ((1 << 32) * NSEC_PER_SEC), and
1000 * then we set the offset to ((1 << 32) - 16) * NSEC_PER_SEC).
1001 */
1002 div64_u64_rem(ktime_get_ns(),
1003 0x100000000ULL * NSEC_PER_SEC, &rem);
1004 dev->time_wrap_offset =
1005 (0x100000000ULL - 16) * NSEC_PER_SEC - rem;
984 break; 1006 break;
985 } 1007 }
986 return 0; 1008 return 0;
@@ -1340,11 +1362,13 @@ int vivid_create_controls(struct vivid_dev *dev, bool show_ccs_cap,
1340 v4l2_ctrl_handler_init(hdl_vid_cap, 55); 1362 v4l2_ctrl_handler_init(hdl_vid_cap, 55);
1341 v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_class, NULL); 1363 v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_class, NULL);
1342 v4l2_ctrl_handler_init(hdl_vid_out, 26); 1364 v4l2_ctrl_handler_init(hdl_vid_out, 26);
1343 v4l2_ctrl_new_custom(hdl_vid_out, &vivid_ctrl_class, NULL); 1365 if (!no_error_inj)
1366 v4l2_ctrl_new_custom(hdl_vid_out, &vivid_ctrl_class, NULL);
1344 v4l2_ctrl_handler_init(hdl_vbi_cap, 21); 1367 v4l2_ctrl_handler_init(hdl_vbi_cap, 21);
1345 v4l2_ctrl_new_custom(hdl_vbi_cap, &vivid_ctrl_class, NULL); 1368 v4l2_ctrl_new_custom(hdl_vbi_cap, &vivid_ctrl_class, NULL);
1346 v4l2_ctrl_handler_init(hdl_vbi_out, 19); 1369 v4l2_ctrl_handler_init(hdl_vbi_out, 19);
1347 v4l2_ctrl_new_custom(hdl_vbi_out, &vivid_ctrl_class, NULL); 1370 if (!no_error_inj)
1371 v4l2_ctrl_new_custom(hdl_vbi_out, &vivid_ctrl_class, NULL);
1348 v4l2_ctrl_handler_init(hdl_radio_rx, 17); 1372 v4l2_ctrl_handler_init(hdl_radio_rx, 17);
1349 v4l2_ctrl_new_custom(hdl_radio_rx, &vivid_ctrl_class, NULL); 1373 v4l2_ctrl_new_custom(hdl_radio_rx, &vivid_ctrl_class, NULL);
1350 v4l2_ctrl_handler_init(hdl_radio_tx, 17); 1374 v4l2_ctrl_handler_init(hdl_radio_tx, 17);
@@ -1414,6 +1438,7 @@ int vivid_create_controls(struct vivid_dev *dev, bool show_ccs_cap,
1414 v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_vflip, NULL); 1438 v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_vflip, NULL);
1415 v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_insert_sav, NULL); 1439 v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_insert_sav, NULL);
1416 v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_insert_eav, NULL); 1440 v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_insert_eav, NULL);
1441 v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_reduced_fps, NULL);
1417 if (show_ccs_cap) { 1442 if (show_ccs_cap) {
1418 dev->ctrl_has_crop_cap = v4l2_ctrl_new_custom(hdl_vid_cap, 1443 dev->ctrl_has_crop_cap = v4l2_ctrl_new_custom(hdl_vid_cap,
1419 &vivid_ctrl_has_crop_cap, NULL); 1444 &vivid_ctrl_has_crop_cap, NULL);
diff --git a/drivers/media/platform/vivid/vivid-kthread-cap.c b/drivers/media/platform/vivid/vivid-kthread-cap.c
index 83cc6d3b4784..9034281944a4 100644
--- a/drivers/media/platform/vivid/vivid-kthread-cap.c
+++ b/drivers/media/platform/vivid/vivid-kthread-cap.c
@@ -441,7 +441,7 @@ static void vivid_fillbuff(struct vivid_dev *dev, struct vivid_buffer *buf)
441 * "Start of Exposure". 441 * "Start of Exposure".
442 */ 442 */
443 if (dev->tstamp_src_is_soe) 443 if (dev->tstamp_src_is_soe)
444 v4l2_get_timestamp(&buf->vb.timestamp); 444 buf->vb.vb2_buf.timestamp = ktime_get_ns();
445 if (dev->field_cap == V4L2_FIELD_ALTERNATE) { 445 if (dev->field_cap == V4L2_FIELD_ALTERNATE) {
446 /* 446 /*
447 * 60 Hz standards start with the bottom field, 50 Hz standards 447 * 60 Hz standards start with the bottom field, 50 Hz standards
@@ -558,8 +558,8 @@ static void vivid_fillbuff(struct vivid_dev *dev, struct vivid_buffer *buf)
558 * the timestamp now. 558 * the timestamp now.
559 */ 559 */
560 if (!dev->tstamp_src_is_soe) 560 if (!dev->tstamp_src_is_soe)
561 v4l2_get_timestamp(&buf->vb.timestamp); 561 buf->vb.vb2_buf.timestamp = ktime_get_ns();
562 buf->vb.timestamp.tv_sec += dev->time_wrap_offset; 562 buf->vb.vb2_buf.timestamp += dev->time_wrap_offset;
563} 563}
564 564
565/* 565/*
diff --git a/drivers/media/platform/vivid/vivid-kthread-out.c b/drivers/media/platform/vivid/vivid-kthread-out.c
index c2c46dcdbe95..98eed5889bc1 100644
--- a/drivers/media/platform/vivid/vivid-kthread-out.c
+++ b/drivers/media/platform/vivid/vivid-kthread-out.c
@@ -95,8 +95,8 @@ static void vivid_thread_vid_out_tick(struct vivid_dev *dev)
95 */ 95 */
96 vid_out_buf->vb.sequence /= 2; 96 vid_out_buf->vb.sequence /= 2;
97 } 97 }
98 v4l2_get_timestamp(&vid_out_buf->vb.timestamp); 98 vid_out_buf->vb.vb2_buf.timestamp =
99 vid_out_buf->vb.timestamp.tv_sec += dev->time_wrap_offset; 99 ktime_get_ns() + dev->time_wrap_offset;
100 vb2_buffer_done(&vid_out_buf->vb.vb2_buf, dev->dqbuf_error ? 100 vb2_buffer_done(&vid_out_buf->vb.vb2_buf, dev->dqbuf_error ?
101 VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE); 101 VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
102 dprintk(dev, 2, "vid_out buffer %d done\n", 102 dprintk(dev, 2, "vid_out buffer %d done\n",
@@ -108,8 +108,8 @@ static void vivid_thread_vid_out_tick(struct vivid_dev *dev)
108 vivid_sliced_vbi_out_process(dev, vbi_out_buf); 108 vivid_sliced_vbi_out_process(dev, vbi_out_buf);
109 109
110 vbi_out_buf->vb.sequence = dev->vbi_out_seq_count; 110 vbi_out_buf->vb.sequence = dev->vbi_out_seq_count;
111 v4l2_get_timestamp(&vbi_out_buf->vb.timestamp); 111 vbi_out_buf->vb.vb2_buf.timestamp =
112 vbi_out_buf->vb.timestamp.tv_sec += dev->time_wrap_offset; 112 ktime_get_ns() + dev->time_wrap_offset;
113 vb2_buffer_done(&vbi_out_buf->vb.vb2_buf, dev->dqbuf_error ? 113 vb2_buffer_done(&vbi_out_buf->vb.vb2_buf, dev->dqbuf_error ?
114 VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE); 114 VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
115 dprintk(dev, 2, "vbi_out buffer %d done\n", 115 dprintk(dev, 2, "vbi_out buffer %d done\n",
diff --git a/drivers/media/platform/vivid/vivid-sdr-cap.c b/drivers/media/platform/vivid/vivid-sdr-cap.c
index 082c401764ce..3d1604cb982f 100644
--- a/drivers/media/platform/vivid/vivid-sdr-cap.c
+++ b/drivers/media/platform/vivid/vivid-sdr-cap.c
@@ -117,8 +117,8 @@ static void vivid_thread_sdr_cap_tick(struct vivid_dev *dev)
117 if (sdr_cap_buf) { 117 if (sdr_cap_buf) {
118 sdr_cap_buf->vb.sequence = dev->sdr_cap_seq_count; 118 sdr_cap_buf->vb.sequence = dev->sdr_cap_seq_count;
119 vivid_sdr_cap_process(dev, sdr_cap_buf); 119 vivid_sdr_cap_process(dev, sdr_cap_buf);
120 v4l2_get_timestamp(&sdr_cap_buf->vb.timestamp); 120 sdr_cap_buf->vb.vb2_buf.timestamp =
121 sdr_cap_buf->vb.timestamp.tv_sec += dev->time_wrap_offset; 121 ktime_get_ns() + dev->time_wrap_offset;
122 vb2_buffer_done(&sdr_cap_buf->vb.vb2_buf, dev->dqbuf_error ? 122 vb2_buffer_done(&sdr_cap_buf->vb.vb2_buf, dev->dqbuf_error ?
123 VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE); 123 VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
124 dev->dqbuf_error = false; 124 dev->dqbuf_error = false;
@@ -213,7 +213,7 @@ static int vivid_thread_sdr_cap(void *data)
213 return 0; 213 return 0;
214} 214}
215 215
216static int sdr_cap_queue_setup(struct vb2_queue *vq, const void *parg, 216static int sdr_cap_queue_setup(struct vb2_queue *vq,
217 unsigned *nbuffers, unsigned *nplanes, 217 unsigned *nbuffers, unsigned *nplanes,
218 unsigned sizes[], void *alloc_ctxs[]) 218 unsigned sizes[], void *alloc_ctxs[])
219{ 219{
diff --git a/drivers/media/platform/vivid/vivid-vbi-cap.c b/drivers/media/platform/vivid/vivid-vbi-cap.c
index e903d023e9df..cda45a582bfe 100644
--- a/drivers/media/platform/vivid/vivid-vbi-cap.c
+++ b/drivers/media/platform/vivid/vivid-vbi-cap.c
@@ -108,8 +108,7 @@ void vivid_raw_vbi_cap_process(struct vivid_dev *dev, struct vivid_buffer *buf)
108 if (!VIVID_INVALID_SIGNAL(dev->std_signal_mode)) 108 if (!VIVID_INVALID_SIGNAL(dev->std_signal_mode))
109 vivid_vbi_gen_raw(&dev->vbi_gen, &vbi, vbuf); 109 vivid_vbi_gen_raw(&dev->vbi_gen, &vbi, vbuf);
110 110
111 v4l2_get_timestamp(&buf->vb.timestamp); 111 buf->vb.vb2_buf.timestamp = ktime_get_ns() + dev->time_wrap_offset;
112 buf->vb.timestamp.tv_sec += dev->time_wrap_offset;
113} 112}
114 113
115 114
@@ -133,11 +132,10 @@ void vivid_sliced_vbi_cap_process(struct vivid_dev *dev,
133 vbuf[i] = dev->vbi_gen.data[i]; 132 vbuf[i] = dev->vbi_gen.data[i];
134 } 133 }
135 134
136 v4l2_get_timestamp(&buf->vb.timestamp); 135 buf->vb.vb2_buf.timestamp = ktime_get_ns() + dev->time_wrap_offset;
137 buf->vb.timestamp.tv_sec += dev->time_wrap_offset;
138} 136}
139 137
140static int vbi_cap_queue_setup(struct vb2_queue *vq, const void *parg, 138static int vbi_cap_queue_setup(struct vb2_queue *vq,
141 unsigned *nbuffers, unsigned *nplanes, 139 unsigned *nbuffers, unsigned *nplanes,
142 unsigned sizes[], void *alloc_ctxs[]) 140 unsigned sizes[], void *alloc_ctxs[])
143{ 141{
diff --git a/drivers/media/platform/vivid/vivid-vbi-out.c b/drivers/media/platform/vivid/vivid-vbi-out.c
index 75c5709f938e..3c5a469e6f49 100644
--- a/drivers/media/platform/vivid/vivid-vbi-out.c
+++ b/drivers/media/platform/vivid/vivid-vbi-out.c
@@ -27,7 +27,7 @@
27#include "vivid-vbi-out.h" 27#include "vivid-vbi-out.h"
28#include "vivid-vbi-cap.h" 28#include "vivid-vbi-cap.h"
29 29
30static int vbi_out_queue_setup(struct vb2_queue *vq, const void *parg, 30static int vbi_out_queue_setup(struct vb2_queue *vq,
31 unsigned *nbuffers, unsigned *nplanes, 31 unsigned *nbuffers, unsigned *nplanes,
32 unsigned sizes[], void *alloc_ctxs[]) 32 unsigned sizes[], void *alloc_ctxs[])
33{ 33{
diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c b/drivers/media/platform/vivid/vivid-vid-cap.c
index ef5412311b2f..b84f081c1b92 100644
--- a/drivers/media/platform/vivid/vivid-vid-cap.c
+++ b/drivers/media/platform/vivid/vivid-vid-cap.c
@@ -95,11 +95,10 @@ static const struct v4l2_discrete_probe webcam_probe = {
95 VIVID_WEBCAM_SIZES 95 VIVID_WEBCAM_SIZES
96}; 96};
97 97
98static int vid_cap_queue_setup(struct vb2_queue *vq, const void *parg, 98static int vid_cap_queue_setup(struct vb2_queue *vq,
99 unsigned *nbuffers, unsigned *nplanes, 99 unsigned *nbuffers, unsigned *nplanes,
100 unsigned sizes[], void *alloc_ctxs[]) 100 unsigned sizes[], void *alloc_ctxs[])
101{ 101{
102 const struct v4l2_format *fmt = parg;
103 struct vivid_dev *dev = vb2_get_drv_priv(vq); 102 struct vivid_dev *dev = vb2_get_drv_priv(vq);
104 unsigned buffers = tpg_g_buffers(&dev->tpg); 103 unsigned buffers = tpg_g_buffers(&dev->tpg);
105 unsigned h = dev->fmt_cap_rect.height; 104 unsigned h = dev->fmt_cap_rect.height;
@@ -122,27 +121,16 @@ static int vid_cap_queue_setup(struct vb2_queue *vq, const void *parg,
122 dev->queue_setup_error = false; 121 dev->queue_setup_error = false;
123 return -EINVAL; 122 return -EINVAL;
124 } 123 }
125 if (fmt) { 124 if (*nplanes) {
126 const struct v4l2_pix_format_mplane *mp;
127 struct v4l2_format mp_fmt;
128 const struct vivid_fmt *vfmt;
129
130 if (!V4L2_TYPE_IS_MULTIPLANAR(fmt->type)) {
131 fmt_sp2mp(fmt, &mp_fmt);
132 fmt = &mp_fmt;
133 }
134 mp = &fmt->fmt.pix_mp;
135 /* 125 /*
136 * Check if the number of planes in the specified format match 126 * Check if the number of requested planes match
137 * the number of buffers in the current format. You can't mix that. 127 * the number of buffers in the current format. You can't mix that.
138 */ 128 */
139 if (mp->num_planes != buffers) 129 if (*nplanes != buffers)
140 return -EINVAL; 130 return -EINVAL;
141 vfmt = vivid_get_format(dev, mp->pixelformat);
142 for (p = 0; p < buffers; p++) { 131 for (p = 0; p < buffers; p++) {
143 sizes[p] = mp->plane_fmt[p].sizeimage;
144 if (sizes[p] < tpg_g_line_width(&dev->tpg, p) * h + 132 if (sizes[p] < tpg_g_line_width(&dev->tpg, p) * h +
145 vfmt->data_offset[p]) 133 dev->fmt_cap->data_offset[p])
146 return -EINVAL; 134 return -EINVAL;
147 } 135 }
148 } else { 136 } else {
@@ -405,6 +393,7 @@ void vivid_update_format_cap(struct vivid_dev *dev, bool keep_controls)
405{ 393{
406 struct v4l2_bt_timings *bt = &dev->dv_timings_cap.bt; 394 struct v4l2_bt_timings *bt = &dev->dv_timings_cap.bt;
407 unsigned size; 395 unsigned size;
396 u64 pixelclock;
408 397
409 switch (dev->input_type[dev->input]) { 398 switch (dev->input_type[dev->input]) {
410 case WEBCAM: 399 case WEBCAM:
@@ -434,8 +423,15 @@ void vivid_update_format_cap(struct vivid_dev *dev, bool keep_controls)
434 dev->src_rect.width = bt->width; 423 dev->src_rect.width = bt->width;
435 dev->src_rect.height = bt->height; 424 dev->src_rect.height = bt->height;
436 size = V4L2_DV_BT_FRAME_WIDTH(bt) * V4L2_DV_BT_FRAME_HEIGHT(bt); 425 size = V4L2_DV_BT_FRAME_WIDTH(bt) * V4L2_DV_BT_FRAME_HEIGHT(bt);
426 if (dev->reduced_fps && can_reduce_fps(bt)) {
427 pixelclock = div_u64(bt->pixelclock * 1000, 1001);
428 bt->flags |= V4L2_DV_FL_REDUCED_FPS;
429 } else {
430 pixelclock = bt->pixelclock;
431 bt->flags &= ~V4L2_DV_FL_REDUCED_FPS;
432 }
437 dev->timeperframe_vid_cap = (struct v4l2_fract) { 433 dev->timeperframe_vid_cap = (struct v4l2_fract) {
438 size / 100, (u32)bt->pixelclock / 100 434 size / 100, (u32)pixelclock / 100
439 }; 435 };
440 if (bt->interlaced) 436 if (bt->interlaced)
441 dev->field_cap = V4L2_FIELD_ALTERNATE; 437 dev->field_cap = V4L2_FIELD_ALTERNATE;
@@ -1662,7 +1658,7 @@ int vivid_vid_cap_s_dv_timings(struct file *file, void *_fh,
1662 !valid_cvt_gtf_timings(timings)) 1658 !valid_cvt_gtf_timings(timings))
1663 return -EINVAL; 1659 return -EINVAL;
1664 1660
1665 if (v4l2_match_dv_timings(timings, &dev->dv_timings_cap, 0)) 1661 if (v4l2_match_dv_timings(timings, &dev->dv_timings_cap, 0, false))
1666 return 0; 1662 return 0;
1667 if (vb2_is_busy(&dev->vb_vid_cap_q)) 1663 if (vb2_is_busy(&dev->vb_vid_cap_q))
1668 return -EBUSY; 1664 return -EBUSY;
diff --git a/drivers/media/platform/vivid/vivid-vid-out.c b/drivers/media/platform/vivid/vivid-vid-out.c
index b77acb6a7013..64e4d66482c1 100644
--- a/drivers/media/platform/vivid/vivid-vid-out.c
+++ b/drivers/media/platform/vivid/vivid-vid-out.c
@@ -31,11 +31,10 @@
31#include "vivid-kthread-out.h" 31#include "vivid-kthread-out.h"
32#include "vivid-vid-out.h" 32#include "vivid-vid-out.h"
33 33
34static int vid_out_queue_setup(struct vb2_queue *vq, const void *parg, 34static int vid_out_queue_setup(struct vb2_queue *vq,
35 unsigned *nbuffers, unsigned *nplanes, 35 unsigned *nbuffers, unsigned *nplanes,
36 unsigned sizes[], void *alloc_ctxs[]) 36 unsigned sizes[], void *alloc_ctxs[])
37{ 37{
38 const struct v4l2_format *fmt = parg;
39 struct vivid_dev *dev = vb2_get_drv_priv(vq); 38 struct vivid_dev *dev = vb2_get_drv_priv(vq);
40 const struct vivid_fmt *vfmt = dev->fmt_out; 39 const struct vivid_fmt *vfmt = dev->fmt_out;
41 unsigned planes = vfmt->buffers; 40 unsigned planes = vfmt->buffers;
@@ -64,26 +63,16 @@ static int vid_out_queue_setup(struct vb2_queue *vq, const void *parg,
64 return -EINVAL; 63 return -EINVAL;
65 } 64 }
66 65
67 if (fmt) { 66 if (*nplanes) {
68 const struct v4l2_pix_format_mplane *mp;
69 struct v4l2_format mp_fmt;
70
71 if (!V4L2_TYPE_IS_MULTIPLANAR(fmt->type)) {
72 fmt_sp2mp(fmt, &mp_fmt);
73 fmt = &mp_fmt;
74 }
75 mp = &fmt->fmt.pix_mp;
76 /* 67 /*
77 * Check if the number of planes in the specified format match 68 * Check if the number of requested planes match
78 * the number of planes in the current format. You can't mix that. 69 * the number of planes in the current format. You can't mix that.
79 */ 70 */
80 if (mp->num_planes != planes) 71 if (*nplanes != planes)
81 return -EINVAL; 72 return -EINVAL;
82 sizes[0] = mp->plane_fmt[0].sizeimage;
83 if (sizes[0] < size) 73 if (sizes[0] < size)
84 return -EINVAL; 74 return -EINVAL;
85 for (p = 1; p < planes; p++) { 75 for (p = 1; p < planes; p++) {
86 sizes[p] = mp->plane_fmt[p].sizeimage;
87 if (sizes[p] < dev->bytesperline_out[p] * h) 76 if (sizes[p] < dev->bytesperline_out[p] * h)
88 return -EINVAL; 77 return -EINVAL;
89 } 78 }
@@ -224,6 +213,7 @@ void vivid_update_format_out(struct vivid_dev *dev)
224{ 213{
225 struct v4l2_bt_timings *bt = &dev->dv_timings_out.bt; 214 struct v4l2_bt_timings *bt = &dev->dv_timings_out.bt;
226 unsigned size, p; 215 unsigned size, p;
216 u64 pixelclock;
227 217
228 switch (dev->output_type[dev->output]) { 218 switch (dev->output_type[dev->output]) {
229 case SVID: 219 case SVID:
@@ -245,8 +235,14 @@ void vivid_update_format_out(struct vivid_dev *dev)
245 dev->sink_rect.width = bt->width; 235 dev->sink_rect.width = bt->width;
246 dev->sink_rect.height = bt->height; 236 dev->sink_rect.height = bt->height;
247 size = V4L2_DV_BT_FRAME_WIDTH(bt) * V4L2_DV_BT_FRAME_HEIGHT(bt); 237 size = V4L2_DV_BT_FRAME_WIDTH(bt) * V4L2_DV_BT_FRAME_HEIGHT(bt);
238
239 if (can_reduce_fps(bt) && (bt->flags & V4L2_DV_FL_REDUCED_FPS))
240 pixelclock = div_u64(bt->pixelclock * 1000, 1001);
241 else
242 pixelclock = bt->pixelclock;
243
248 dev->timeperframe_vid_out = (struct v4l2_fract) { 244 dev->timeperframe_vid_out = (struct v4l2_fract) {
249 size / 100, (u32)bt->pixelclock / 100 245 size / 100, (u32)pixelclock / 100
250 }; 246 };
251 if (bt->interlaced) 247 if (bt->interlaced)
252 dev->field_out = V4L2_FIELD_ALTERNATE; 248 dev->field_out = V4L2_FIELD_ALTERNATE;
@@ -1149,7 +1145,7 @@ int vivid_vid_out_s_dv_timings(struct file *file, void *_fh,
1149 0, NULL, NULL) && 1145 0, NULL, NULL) &&
1150 !valid_cvt_gtf_timings(timings)) 1146 !valid_cvt_gtf_timings(timings))
1151 return -EINVAL; 1147 return -EINVAL;
1152 if (v4l2_match_dv_timings(timings, &dev->dv_timings_out, 0)) 1148 if (v4l2_match_dv_timings(timings, &dev->dv_timings_out, 0, true))
1153 return 0; 1149 return 0;
1154 if (vb2_is_busy(&dev->vb_vid_out_q)) 1150 if (vb2_is_busy(&dev->vb_vid_out_q))
1155 return -EBUSY; 1151 return -EBUSY;
diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c
index 5ce88e1f5d71..45eb65fa23db 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -274,35 +274,6 @@ static int __vsp1_video_try_format(struct vsp1_video *video,
274 return 0; 274 return 0;
275} 275}
276 276
277static bool
278vsp1_video_format_adjust(struct vsp1_video *video,
279 const struct v4l2_pix_format_mplane *format,
280 struct v4l2_pix_format_mplane *adjust)
281{
282 unsigned int i;
283
284 *adjust = *format;
285 __vsp1_video_try_format(video, adjust, NULL);
286
287 if (format->width != adjust->width ||
288 format->height != adjust->height ||
289 format->pixelformat != adjust->pixelformat ||
290 format->num_planes != adjust->num_planes)
291 return false;
292
293 for (i = 0; i < format->num_planes; ++i) {
294 if (format->plane_fmt[i].bytesperline !=
295 adjust->plane_fmt[i].bytesperline)
296 return false;
297
298 adjust->plane_fmt[i].sizeimage =
299 max(adjust->plane_fmt[i].sizeimage,
300 format->plane_fmt[i].sizeimage);
301 }
302
303 return true;
304}
305
306/* ----------------------------------------------------------------------------- 277/* -----------------------------------------------------------------------------
307 * Pipeline Management 278 * Pipeline Management
308 */ 279 */
@@ -611,7 +582,7 @@ vsp1_video_complete_buffer(struct vsp1_video *video)
611 spin_unlock_irqrestore(&video->irqlock, flags); 582 spin_unlock_irqrestore(&video->irqlock, flags);
612 583
613 done->buf.sequence = video->sequence++; 584 done->buf.sequence = video->sequence++;
614 v4l2_get_timestamp(&done->buf.timestamp); 585 done->buf.vb2_buf.timestamp = ktime_get_ns();
615 for (i = 0; i < done->buf.vb2_buf.num_planes; ++i) 586 for (i = 0; i < done->buf.vb2_buf.num_planes; ++i)
616 vb2_set_plane_payload(&done->buf.vb2_buf, i, done->length[i]); 587 vb2_set_plane_payload(&done->buf.vb2_buf, i, done->length[i]);
617 vb2_buffer_done(&done->buf.vb2_buf, VB2_BUF_STATE_DONE); 588 vb2_buffer_done(&done->buf.vb2_buf, VB2_BUF_STATE_DONE);
@@ -787,26 +758,24 @@ void vsp1_pipelines_resume(struct vsp1_device *vsp1)
787 */ 758 */
788 759
789static int 760static int
790vsp1_video_queue_setup(struct vb2_queue *vq, const void *parg, 761vsp1_video_queue_setup(struct vb2_queue *vq,
791 unsigned int *nbuffers, unsigned int *nplanes, 762 unsigned int *nbuffers, unsigned int *nplanes,
792 unsigned int sizes[], void *alloc_ctxs[]) 763 unsigned int sizes[], void *alloc_ctxs[])
793{ 764{
794 const struct v4l2_format *fmt = parg;
795 struct vsp1_video *video = vb2_get_drv_priv(vq); 765 struct vsp1_video *video = vb2_get_drv_priv(vq);
796 const struct v4l2_pix_format_mplane *format; 766 const struct v4l2_pix_format_mplane *format = &video->format;
797 struct v4l2_pix_format_mplane pix_mp;
798 unsigned int i; 767 unsigned int i;
799 768
800 if (fmt) { 769 if (*nplanes) {
801 /* Make sure the format is valid and adjust the sizeimage field 770 if (*nplanes != format->num_planes)
802 * if needed.
803 */
804 if (!vsp1_video_format_adjust(video, &fmt->fmt.pix_mp, &pix_mp))
805 return -EINVAL; 771 return -EINVAL;
806 772
807 format = &pix_mp; 773 for (i = 0; i < *nplanes; i++) {
808 } else { 774 if (sizes[i] < format->plane_fmt[i].sizeimage)
809 format = &video->format; 775 return -EINVAL;
776 alloc_ctxs[i] = video->alloc_ctx;
777 }
778 return 0;
810 } 779 }
811 780
812 *nplanes = format->num_planes; 781 *nplanes = format->num_planes;
diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c
index d11cc7072cd5..722758f33924 100644
--- a/drivers/media/platform/xilinx/xilinx-dma.c
+++ b/drivers/media/platform/xilinx/xilinx-dma.c
@@ -303,27 +303,25 @@ static void xvip_dma_complete(void *param)
303 303
304 buf->buf.field = V4L2_FIELD_NONE; 304 buf->buf.field = V4L2_FIELD_NONE;
305 buf->buf.sequence = dma->sequence++; 305 buf->buf.sequence = dma->sequence++;
306 v4l2_get_timestamp(&buf->buf.timestamp); 306 buf->buf.vb2_buf.timestamp = ktime_get_ns();
307 vb2_set_plane_payload(&buf->buf.vb2_buf, 0, dma->format.sizeimage); 307 vb2_set_plane_payload(&buf->buf.vb2_buf, 0, dma->format.sizeimage);
308 vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE); 308 vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE);
309} 309}
310 310
311static int 311static int
312xvip_dma_queue_setup(struct vb2_queue *vq, const void *parg, 312xvip_dma_queue_setup(struct vb2_queue *vq,
313 unsigned int *nbuffers, unsigned int *nplanes, 313 unsigned int *nbuffers, unsigned int *nplanes,
314 unsigned int sizes[], void *alloc_ctxs[]) 314 unsigned int sizes[], void *alloc_ctxs[])
315{ 315{
316 const struct v4l2_format *fmt = parg;
317 struct xvip_dma *dma = vb2_get_drv_priv(vq); 316 struct xvip_dma *dma = vb2_get_drv_priv(vq);
318 317
318 alloc_ctxs[0] = dma->alloc_ctx;
319 /* Make sure the image size is large enough. */ 319 /* Make sure the image size is large enough. */
320 if (fmt && fmt->fmt.pix.sizeimage < dma->format.sizeimage) 320 if (*nplanes)
321 return -EINVAL; 321 return sizes[0] < dma->format.sizeimage ? -EINVAL : 0;
322 322
323 *nplanes = 1; 323 *nplanes = 1;
324 324 sizes[0] = dma->format.sizeimage;
325 sizes[0] = fmt ? fmt->fmt.pix.sizeimage : dma->format.sizeimage;
326 alloc_ctxs[0] = dma->alloc_ctx;
327 325
328 return 0; 326 return 0;
329} 327}
diff --git a/drivers/media/platform/xilinx/xilinx-tpg.c b/drivers/media/platform/xilinx/xilinx-tpg.c
index b5f7d5ecb7f6..8bd7e3736019 100644
--- a/drivers/media/platform/xilinx/xilinx-tpg.c
+++ b/drivers/media/platform/xilinx/xilinx-tpg.c
@@ -731,6 +731,7 @@ static int xtpg_parse_of(struct xtpg_device *xtpg)
731 format = xvip_of_get_format(port); 731 format = xvip_of_get_format(port);
732 if (IS_ERR(format)) { 732 if (IS_ERR(format)) {
733 dev_err(dev, "invalid format in DT"); 733 dev_err(dev, "invalid format in DT");
734 of_node_put(port);
734 return PTR_ERR(format); 735 return PTR_ERR(format);
735 } 736 }
736 737
@@ -739,6 +740,7 @@ static int xtpg_parse_of(struct xtpg_device *xtpg)
739 xtpg->vip_format = format; 740 xtpg->vip_format = format;
740 } else if (xtpg->vip_format != format) { 741 } else if (xtpg->vip_format != format) {
741 dev_err(dev, "in/out format mismatch in DT"); 742 dev_err(dev, "in/out format mismatch in DT");
743 of_node_put(port);
742 return -EINVAL; 744 return -EINVAL;
743 } 745 }
744 746
diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c
index 7b7cb9c28d2c..b9bf24fefa5a 100644
--- a/drivers/media/platform/xilinx/xilinx-vipp.c
+++ b/drivers/media/platform/xilinx/xilinx-vipp.c
@@ -476,8 +476,10 @@ static int xvip_graph_dma_init(struct xvip_composite_device *xdev)
476 476
477 for_each_child_of_node(ports, port) { 477 for_each_child_of_node(ports, port) {
478 ret = xvip_graph_dma_init_one(xdev, port); 478 ret = xvip_graph_dma_init_one(xdev, port);
479 if (ret < 0) 479 if (ret < 0) {
480 of_node_put(port);
480 return ret; 481 return ret;
482 }
481 } 483 }
482 484
483 return 0; 485 return 0;
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
index 5236035f0f2a..70fd8e80198a 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -42,7 +42,7 @@
42#include <linux/videodev2.h> 42#include <linux/videodev2.h>
43#include <linux/io.h> 43#include <linux/io.h>
44#include <linux/slab.h> 44#include <linux/slab.h>
45#include <media/tea575x.h> 45#include <media/drv-intf/tea575x.h>
46#include <media/v4l2-device.h> 46#include <media/v4l2-device.h>
47#include <media/v4l2-ioctl.h> 47#include <media/v4l2-ioctl.h>
48#include <media/v4l2-fh.h> 48#include <media/v4l2-fh.h>
@@ -108,7 +108,7 @@ static void maxiradio_tea575x_set_direction(struct snd_tea575x *tea, bool output
108{ 108{
109} 109}
110 110
111static struct snd_tea575x_ops maxiradio_tea_ops = { 111static const struct snd_tea575x_ops maxiradio_tea_ops = {
112 .set_pins = maxiradio_tea575x_set_pins, 112 .set_pins = maxiradio_tea575x_set_pins,
113 .get_pins = maxiradio_tea575x_get_pins, 113 .get_pins = maxiradio_tea575x_get_pins,
114 .set_direction = maxiradio_tea575x_set_direction, 114 .set_direction = maxiradio_tea575x_set_direction,
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c
index b8d61cbc18cb..dc81d422b394 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -14,7 +14,7 @@
14#include <linux/io.h> /* outb, outb_p */ 14#include <linux/io.h> /* outb, outb_p */
15#include <linux/isa.h> 15#include <linux/isa.h>
16#include <linux/pnp.h> 16#include <linux/pnp.h>
17#include <media/tea575x.h> 17#include <media/drv-intf/tea575x.h>
18 18
19MODULE_AUTHOR("Ondrej Zary"); 19MODULE_AUTHOR("Ondrej Zary");
20MODULE_DESCRIPTION("MediaForte SF16-FMR2 and SF16-FMD2 FM radio card driver"); 20MODULE_DESCRIPTION("MediaForte SF16-FMR2 and SF16-FMD2 FM radio card driver");
@@ -82,7 +82,7 @@ static void fmr2_tea575x_set_direction(struct snd_tea575x *tea, bool output)
82{ 82{
83} 83}
84 84
85static struct snd_tea575x_ops fmr2_tea_ops = { 85static const struct snd_tea575x_ops fmr2_tea_ops = {
86 .set_pins = fmr2_tea575x_set_pins, 86 .set_pins = fmr2_tea575x_set_pins,
87 .get_pins = fmr2_tea575x_get_pins, 87 .get_pins = fmr2_tea575x_get_pins,
88 .set_direction = fmr2_tea575x_set_direction, 88 .set_direction = fmr2_tea575x_set_direction,
diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
index 050b3bb96fec..85667a95f003 100644
--- a/drivers/media/radio/radio-shark.c
+++ b/drivers/media/radio/radio-shark.c
@@ -33,7 +33,7 @@
33#include <linux/usb.h> 33#include <linux/usb.h>
34#include <linux/workqueue.h> 34#include <linux/workqueue.h>
35#include <media/v4l2-device.h> 35#include <media/v4l2-device.h>
36#include <media/tea575x.h> 36#include <media/drv-intf/tea575x.h>
37 37
38#if defined(CONFIG_LEDS_CLASS) || \ 38#if defined(CONFIG_LEDS_CLASS) || \
39 (defined(CONFIG_LEDS_CLASS_MODULE) && defined(CONFIG_RADIO_SHARK_MODULE)) 39 (defined(CONFIG_LEDS_CLASS_MODULE) && defined(CONFIG_RADIO_SHARK_MODULE))
@@ -150,7 +150,7 @@ static u32 shark_read_val(struct snd_tea575x *tea)
150 return val; 150 return val;
151} 151}
152 152
153static struct snd_tea575x_ops shark_tea_ops = { 153static const struct snd_tea575x_ops shark_tea_ops = {
154 .write_val = shark_write_val, 154 .write_val = shark_write_val,
155 .read_val = shark_read_val, 155 .read_val = shark_read_val,
156}; 156};
diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
index 8654e0dc5c95..0e65a85d52c6 100644
--- a/drivers/media/radio/radio-shark2.c
+++ b/drivers/media/radio/radio-shark2.c
@@ -137,7 +137,7 @@ static int shark_read_reg(struct radio_tea5777 *tea, u32 *reg_ret)
137 return 0; 137 return 0;
138} 138}
139 139
140static struct radio_tea5777_ops shark_tea_ops = { 140static const struct radio_tea5777_ops shark_tea_ops = {
141 .write_reg = shark_write_reg, 141 .write_reg = shark_write_reg,
142 .read_reg = shark_read_reg, 142 .read_reg = shark_read_reg,
143}; 143};
diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
index 9cbb8cdf0ac0..859f0c08ee05 100644
--- a/drivers/media/radio/radio-si476x.c
+++ b/drivers/media/radio/radio-si476x.c
@@ -31,7 +31,7 @@
31#include <media/v4l2-event.h> 31#include <media/v4l2-event.h>
32#include <media/v4l2-device.h> 32#include <media/v4l2-device.h>
33 33
34#include <media/si476x.h> 34#include <media/drv-intf/si476x.h>
35#include <linux/mfd/si476x-core.h> 35#include <linux/mfd/si476x-core.h>
36 36
37#define FM_FREQ_RANGE_LOW 64000000 37#define FM_FREQ_RANGE_LOW 64000000
diff --git a/drivers/media/radio/radio-tea5777.h b/drivers/media/radio/radio-tea5777.h
index 4ea43a90a151..4bd942526a1b 100644
--- a/drivers/media/radio/radio-tea5777.h
+++ b/drivers/media/radio/radio-tea5777.h
@@ -76,7 +76,7 @@ struct radio_tea5777 {
76 u32 read_reg; 76 u32 read_reg;
77 u64 write_reg; 77 u64 write_reg;
78 struct mutex mutex; 78 struct mutex mutex;
79 struct radio_tea5777_ops *ops; 79 const struct radio_tea5777_ops *ops;
80 void *private_data; 80 void *private_data;
81 u8 card[32]; 81 u8 card[32];
82 u8 bus_info[32]; 82 u8 bus_info[32];
diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c
index 04baafe5e901..a82eb9678d6c 100644
--- a/drivers/media/radio/radio-timb.c
+++ b/drivers/media/radio/radio-timb.c
@@ -26,7 +26,7 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <media/timb_radio.h> 29#include <linux/platform_data/media/timb_radio.h>
30 30
31#define DRIVER_NAME "timb-radio" 31#define DRIVER_NAME "timb-radio"
32 32
diff --git a/drivers/media/radio/si4713/radio-usb-si4713.c b/drivers/media/radio/si4713/radio-usb-si4713.c
index a77319dcba05..5146be2a1a50 100644
--- a/drivers/media/radio/si4713/radio-usb-si4713.c
+++ b/drivers/media/radio/si4713/radio-usb-si4713.c
@@ -31,7 +31,7 @@
31#include <media/v4l2-device.h> 31#include <media/v4l2-device.h>
32#include <media/v4l2-ioctl.h> 32#include <media/v4l2-ioctl.h>
33#include <media/v4l2-event.h> 33#include <media/v4l2-event.h>
34#include <media/si4713.h> 34#include <linux/platform_data/media/si4713.h>
35 35
36#include "si4713.h" 36#include "si4713.h"
37 37
diff --git a/drivers/media/radio/si4713/si4713.h b/drivers/media/radio/si4713/si4713.h
index 8a376e142188..29d0e1f104d2 100644
--- a/drivers/media/radio/si4713/si4713.h
+++ b/drivers/media/radio/si4713/si4713.h
@@ -20,7 +20,7 @@
20#include <linux/gpio/consumer.h> 20#include <linux/gpio/consumer.h>
21#include <media/v4l2-subdev.h> 21#include <media/v4l2-subdev.h>
22#include <media/v4l2-ctrls.h> 22#include <media/v4l2-ctrls.h>
23#include <media/si4713.h> 23#include <linux/platform_data/media/si4713.h>
24 24
25#define SI4713_PRODUCT_NUMBER 0x0D 25#define SI4713_PRODUCT_NUMBER 0x0D
26 26
diff --git a/drivers/media/radio/tea575x.c b/drivers/media/radio/tea575x.c
index 43d1ea53cb66..3e08475af579 100644
--- a/drivers/media/radio/tea575x.c
+++ b/drivers/media/radio/tea575x.c
@@ -31,7 +31,7 @@
31#include <media/v4l2-fh.h> 31#include <media/v4l2-fh.h>
32#include <media/v4l2-ioctl.h> 32#include <media/v4l2-ioctl.h>
33#include <media/v4l2-event.h> 33#include <media/v4l2-event.h>
34#include <media/tea575x.h> 34#include <media/drv-intf/tea575x.h>
35 35
36MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); 36MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
37MODULE_DESCRIPTION("Routines for control of TEA5757/5759 Philips AM/FM radio tuner chips"); 37MODULE_DESCRIPTION("Routines for control of TEA5757/5759 Philips AM/FM radio tuner chips");
diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
index b6e13116c6f5..bd4d68500085 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -101,7 +101,8 @@ config IR_SHARP_DECODER
101 101
102 ---help--- 102 ---help---
103 Enable this option if you have an infrared remote control which 103 Enable this option if you have an infrared remote control which
104 uses the Sharp protocol, and you need software decoding support. 104 uses the Sharp protocol (Sharp, Denon), and you need software
105 decoding support.
105 106
106config IR_MCE_KBD_DECODER 107config IR_MCE_KBD_DECODER
107 tristate "Enable IR raw decoder for the MCE keyboard/mouse protocol" 108 tristate "Enable IR raw decoder for the MCE keyboard/mouse protocol"
diff --git a/drivers/media/rc/gpio-ir-recv.c b/drivers/media/rc/gpio-ir-recv.c
index 7dbc9ca6d885..5b63b1f15cb1 100644
--- a/drivers/media/rc/gpio-ir-recv.c
+++ b/drivers/media/rc/gpio-ir-recv.c
@@ -21,7 +21,7 @@
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/irq.h> 22#include <linux/irq.h>
23#include <media/rc-core.h> 23#include <media/rc-core.h>
24#include <media/gpio-ir-recv.h> 24#include <linux/platform_data/media/gpio-ir-recv.h>
25 25
26#define GPIO_IR_DRIVER_NAME "gpio-rc-recv" 26#define GPIO_IR_DRIVER_NAME "gpio-rc-recv"
27#define GPIO_IR_DEVICE_NAME "gpio_ir_recv" 27#define GPIO_IR_DEVICE_NAME "gpio_ir_recv"
@@ -30,6 +30,7 @@ struct gpio_rc_dev {
30 struct rc_dev *rcdev; 30 struct rc_dev *rcdev;
31 int gpio_nr; 31 int gpio_nr;
32 bool active_low; 32 bool active_low;
33 struct timer_list flush_timer;
33}; 34};
34 35
35#ifdef CONFIG_OF 36#ifdef CONFIG_OF
@@ -93,12 +94,26 @@ static irqreturn_t gpio_ir_recv_irq(int irq, void *dev_id)
93 if (rc < 0) 94 if (rc < 0)
94 goto err_get_value; 95 goto err_get_value;
95 96
97 mod_timer(&gpio_dev->flush_timer,
98 jiffies + nsecs_to_jiffies(gpio_dev->rcdev->timeout));
99
96 ir_raw_event_handle(gpio_dev->rcdev); 100 ir_raw_event_handle(gpio_dev->rcdev);
97 101
98err_get_value: 102err_get_value:
99 return IRQ_HANDLED; 103 return IRQ_HANDLED;
100} 104}
101 105
106static void flush_timer(unsigned long arg)
107{
108 struct gpio_rc_dev *gpio_dev = (struct gpio_rc_dev *)arg;
109 DEFINE_IR_RAW_EVENT(ev);
110
111 ev.timeout = true;
112 ev.duration = gpio_dev->rcdev->timeout;
113 ir_raw_event_store(gpio_dev->rcdev, &ev);
114 ir_raw_event_handle(gpio_dev->rcdev);
115}
116
102static int gpio_ir_recv_probe(struct platform_device *pdev) 117static int gpio_ir_recv_probe(struct platform_device *pdev)
103{ 118{
104 struct gpio_rc_dev *gpio_dev; 119 struct gpio_rc_dev *gpio_dev;
@@ -144,6 +159,9 @@ static int gpio_ir_recv_probe(struct platform_device *pdev)
144 rcdev->input_id.version = 0x0100; 159 rcdev->input_id.version = 0x0100;
145 rcdev->dev.parent = &pdev->dev; 160 rcdev->dev.parent = &pdev->dev;
146 rcdev->driver_name = GPIO_IR_DRIVER_NAME; 161 rcdev->driver_name = GPIO_IR_DRIVER_NAME;
162 rcdev->min_timeout = 0;
163 rcdev->timeout = IR_DEFAULT_TIMEOUT;
164 rcdev->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
147 if (pdata->allowed_protos) 165 if (pdata->allowed_protos)
148 rcdev->allowed_protocols = pdata->allowed_protos; 166 rcdev->allowed_protocols = pdata->allowed_protos;
149 else 167 else
@@ -154,6 +172,9 @@ static int gpio_ir_recv_probe(struct platform_device *pdev)
154 gpio_dev->gpio_nr = pdata->gpio_nr; 172 gpio_dev->gpio_nr = pdata->gpio_nr;
155 gpio_dev->active_low = pdata->active_low; 173 gpio_dev->active_low = pdata->active_low;
156 174
175 setup_timer(&gpio_dev->flush_timer, flush_timer,
176 (unsigned long)gpio_dev);
177
157 rc = gpio_request(pdata->gpio_nr, "gpio-ir-recv"); 178 rc = gpio_request(pdata->gpio_nr, "gpio-ir-recv");
158 if (rc < 0) 179 if (rc < 0)
159 goto err_gpio_request; 180 goto err_gpio_request;
@@ -196,6 +217,7 @@ static int gpio_ir_recv_remove(struct platform_device *pdev)
196 struct gpio_rc_dev *gpio_dev = platform_get_drvdata(pdev); 217 struct gpio_rc_dev *gpio_dev = platform_get_drvdata(pdev);
197 218
198 free_irq(gpio_to_irq(gpio_dev->gpio_nr), gpio_dev); 219 free_irq(gpio_to_irq(gpio_dev->gpio_nr), gpio_dev);
220 del_timer_sync(&gpio_dev->flush_timer);
199 rc_unregister_device(gpio_dev->rcdev); 221 rc_unregister_device(gpio_dev->rcdev);
200 gpio_free(gpio_dev->gpio_nr); 222 gpio_free(gpio_dev->gpio_nr);
201 kfree(gpio_dev); 223 kfree(gpio_dev);
diff --git a/drivers/media/rc/ir-jvc-decoder.c b/drivers/media/rc/ir-jvc-decoder.c
index 30bcf188d377..182402f7b4d1 100644
--- a/drivers/media/rc/ir-jvc-decoder.c
+++ b/drivers/media/rc/ir-jvc-decoder.c
@@ -47,9 +47,6 @@ static int ir_jvc_decode(struct rc_dev *dev, struct ir_raw_event ev)
47{ 47{
48 struct jvc_dec *data = &dev->raw->jvc; 48 struct jvc_dec *data = &dev->raw->jvc;
49 49
50 if (!(dev->enabled_protocols & RC_BIT_JVC))
51 return 0;
52
53 if (!is_timing_event(ev)) { 50 if (!is_timing_event(ev)) {
54 if (ev.reset) 51 if (ev.reset)
55 data->state = STATE_INACTIVE; 52 data->state = STATE_INACTIVE;
diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c
index a32659fcd266..5effc65d2947 100644
--- a/drivers/media/rc/ir-lirc-codec.c
+++ b/drivers/media/rc/ir-lirc-codec.c
@@ -415,6 +415,7 @@ static int ir_lirc_unregister(struct rc_dev *dev)
415 415
416 lirc_unregister_driver(lirc->drv->minor); 416 lirc_unregister_driver(lirc->drv->minor);
417 lirc_buffer_free(lirc->drv->rbuf); 417 lirc_buffer_free(lirc->drv->rbuf);
418 kfree(lirc->drv->rbuf);
418 kfree(lirc->drv); 419 kfree(lirc->drv);
419 420
420 return 0; 421 return 0;
diff --git a/drivers/media/rc/ir-mce_kbd-decoder.c b/drivers/media/rc/ir-mce_kbd-decoder.c
index 9f3c9b59f30c..d80986251ee0 100644
--- a/drivers/media/rc/ir-mce_kbd-decoder.c
+++ b/drivers/media/rc/ir-mce_kbd-decoder.c
@@ -216,9 +216,6 @@ static int ir_mce_kbd_decode(struct rc_dev *dev, struct ir_raw_event ev)
216 u32 scancode; 216 u32 scancode;
217 unsigned long delay; 217 unsigned long delay;
218 218
219 if (!(dev->enabled_protocols & RC_BIT_MCE_KBD))
220 return 0;
221
222 if (!is_timing_event(ev)) { 219 if (!is_timing_event(ev)) {
223 if (ev.reset) 220 if (ev.reset)
224 data->state = STATE_INACTIVE; 221 data->state = STATE_INACTIVE;
diff --git a/drivers/media/rc/ir-nec-decoder.c b/drivers/media/rc/ir-nec-decoder.c
index 7b81fec0820f..bea0d1eedee0 100644
--- a/drivers/media/rc/ir-nec-decoder.c
+++ b/drivers/media/rc/ir-nec-decoder.c
@@ -52,9 +52,6 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
52 u8 address, not_address, command, not_command; 52 u8 address, not_address, command, not_command;
53 bool send_32bits = false; 53 bool send_32bits = false;
54 54
55 if (!(dev->enabled_protocols & RC_BIT_NEC))
56 return 0;
57
58 if (!is_timing_event(ev)) { 55 if (!is_timing_event(ev)) {
59 if (ev.reset) 56 if (ev.reset)
60 data->state = STATE_INACTIVE; 57 data->state = STATE_INACTIVE;
diff --git a/drivers/media/rc/ir-rc5-decoder.c b/drivers/media/rc/ir-rc5-decoder.c
index 84fa6e9b59a1..6ffe776abf6b 100644
--- a/drivers/media/rc/ir-rc5-decoder.c
+++ b/drivers/media/rc/ir-rc5-decoder.c
@@ -53,9 +53,6 @@ static int ir_rc5_decode(struct rc_dev *dev, struct ir_raw_event ev)
53 u32 scancode; 53 u32 scancode;
54 enum rc_type protocol; 54 enum rc_type protocol;
55 55
56 if (!(dev->enabled_protocols & (RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ)))
57 return 0;
58
59 if (!is_timing_event(ev)) { 56 if (!is_timing_event(ev)) {
60 if (ev.reset) 57 if (ev.reset)
61 data->state = STATE_INACTIVE; 58 data->state = STATE_INACTIVE;
diff --git a/drivers/media/rc/ir-rc6-decoder.c b/drivers/media/rc/ir-rc6-decoder.c
index d16bc67af732..e0e2edefa651 100644
--- a/drivers/media/rc/ir-rc6-decoder.c
+++ b/drivers/media/rc/ir-rc6-decoder.c
@@ -90,11 +90,6 @@ static int ir_rc6_decode(struct rc_dev *dev, struct ir_raw_event ev)
90 u8 toggle; 90 u8 toggle;
91 enum rc_type protocol; 91 enum rc_type protocol;
92 92
93 if (!(dev->enabled_protocols &
94 (RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 |
95 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE)))
96 return 0;
97
98 if (!is_timing_event(ev)) { 93 if (!is_timing_event(ev)) {
99 if (ev.reset) 94 if (ev.reset)
100 data->state = STATE_INACTIVE; 95 data->state = STATE_INACTIVE;
diff --git a/drivers/media/rc/ir-rx51.c b/drivers/media/rc/ir-rx51.c
index b1e19a26208d..4e1711a40466 100644
--- a/drivers/media/rc/ir-rx51.c
+++ b/drivers/media/rc/ir-rx51.c
@@ -31,7 +31,7 @@
31 31
32#include <media/lirc.h> 32#include <media/lirc.h>
33#include <media/lirc_dev.h> 33#include <media/lirc_dev.h>
34#include <media/ir-rx51.h> 34#include <linux/platform_data/media/ir-rx51.h>
35 35
36#define LIRC_RX51_DRIVER_FEATURES (LIRC_CAN_SET_SEND_DUTY_CYCLE | \ 36#define LIRC_RX51_DRIVER_FEATURES (LIRC_CAN_SET_SEND_DUTY_CYCLE | \
37 LIRC_CAN_SET_SEND_CARRIER | \ 37 LIRC_CAN_SET_SEND_CARRIER | \
diff --git a/drivers/media/rc/ir-sanyo-decoder.c b/drivers/media/rc/ir-sanyo-decoder.c
index ad1dc6ae21fc..7331e5e7c497 100644
--- a/drivers/media/rc/ir-sanyo-decoder.c
+++ b/drivers/media/rc/ir-sanyo-decoder.c
@@ -58,9 +58,6 @@ static int ir_sanyo_decode(struct rc_dev *dev, struct ir_raw_event ev)
58 u32 scancode; 58 u32 scancode;
59 u8 address, command, not_command; 59 u8 address, command, not_command;
60 60
61 if (!(dev->enabled_protocols & RC_BIT_SANYO))
62 return 0;
63
64 if (!is_timing_event(ev)) { 61 if (!is_timing_event(ev)) {
65 if (ev.reset) { 62 if (ev.reset) {
66 IR_dprintk(1, "SANYO event reset received. reset to state 0\n"); 63 IR_dprintk(1, "SANYO event reset received. reset to state 0\n");
diff --git a/drivers/media/rc/ir-sharp-decoder.c b/drivers/media/rc/ir-sharp-decoder.c
index b7acdbae8159..317677f06f2c 100644
--- a/drivers/media/rc/ir-sharp-decoder.c
+++ b/drivers/media/rc/ir-sharp-decoder.c
@@ -48,9 +48,6 @@ static int ir_sharp_decode(struct rc_dev *dev, struct ir_raw_event ev)
48 struct sharp_dec *data = &dev->raw->sharp; 48 struct sharp_dec *data = &dev->raw->sharp;
49 u32 msg, echo, address, command, scancode; 49 u32 msg, echo, address, command, scancode;
50 50
51 if (!(dev->enabled_protocols & RC_BIT_SHARP))
52 return 0;
53
54 if (!is_timing_event(ev)) { 51 if (!is_timing_event(ev)) {
55 if (ev.reset) 52 if (ev.reset)
56 data->state = STATE_INACTIVE; 53 data->state = STATE_INACTIVE;
@@ -118,7 +115,9 @@ static int ir_sharp_decode(struct rc_dev *dev, struct ir_raw_event ev)
118 115
119 if (data->count == SHARP_NBITS) { 116 if (data->count == SHARP_NBITS) {
120 /* exp,chk bits should be 1,0 */ 117 /* exp,chk bits should be 1,0 */
121 if ((data->bits & 0x3) != 0x2) 118 if ((data->bits & 0x3) != 0x2 &&
119 /* DENON variant, both chk bits 0 */
120 (data->bits & 0x3) != 0x0)
122 break; 121 break;
123 data->state = STATE_ECHO_SPACE; 122 data->state = STATE_ECHO_SPACE;
124 } else { 123 } else {
diff --git a/drivers/media/rc/ir-sony-decoder.c b/drivers/media/rc/ir-sony-decoder.c
index 58ef06f35175..baa972c76e0e 100644
--- a/drivers/media/rc/ir-sony-decoder.c
+++ b/drivers/media/rc/ir-sony-decoder.c
@@ -46,10 +46,6 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
46 u32 scancode; 46 u32 scancode;
47 u8 device, subdevice, function; 47 u8 device, subdevice, function;
48 48
49 if (!(dev->enabled_protocols &
50 (RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20)))
51 return 0;
52
53 if (!is_timing_event(ev)) { 49 if (!is_timing_event(ev)) {
54 if (ev.reset) 50 if (ev.reset)
55 data->state = STATE_INACTIVE; 51 data->state = STATE_INACTIVE;
diff --git a/drivers/media/rc/ir-xmp-decoder.c b/drivers/media/rc/ir-xmp-decoder.c
index 1017d4816e8d..18596190bbb8 100644
--- a/drivers/media/rc/ir-xmp-decoder.c
+++ b/drivers/media/rc/ir-xmp-decoder.c
@@ -43,9 +43,6 @@ static int ir_xmp_decode(struct rc_dev *dev, struct ir_raw_event ev)
43{ 43{
44 struct xmp_dec *data = &dev->raw->xmp; 44 struct xmp_dec *data = &dev->raw->xmp;
45 45
46 if (!(dev->enabled_protocols & RC_BIT_XMP))
47 return 0;
48
49 if (!is_timing_event(ev)) { 46 if (!is_timing_event(ev)) {
50 if (ev.reset) 47 if (ev.reset)
51 data->state = STATE_INACTIVE; 48 data->state = STATE_INACTIVE;
diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
index 85af7a869167..18adf580f502 100644
--- a/drivers/media/rc/nuvoton-cir.c
+++ b/drivers/media/rc/nuvoton-cir.c
@@ -39,6 +39,18 @@
39 39
40#include "nuvoton-cir.h" 40#include "nuvoton-cir.h"
41 41
42static const struct nvt_chip nvt_chips[] = {
43 { "w83667hg", NVT_W83667HG },
44 { "NCT6775F", NVT_6775F },
45 { "NCT6776F", NVT_6776F },
46 { "NCT6779D", NVT_6779D },
47};
48
49static inline bool is_w83667hg(struct nvt_dev *nvt)
50{
51 return nvt->chip_ver == NVT_W83667HG;
52}
53
42/* write val to config reg */ 54/* write val to config reg */
43static inline void nvt_cr_write(struct nvt_dev *nvt, u8 val, u8 reg) 55static inline void nvt_cr_write(struct nvt_dev *nvt, u8 val, u8 reg)
44{ 56{
@@ -224,74 +236,60 @@ static void cir_wake_dump_regs(struct nvt_dev *nvt)
224 pr_cont("\n"); 236 pr_cont("\n");
225} 237}
226 238
239static inline const char *nvt_find_chip(struct nvt_dev *nvt, int id)
240{
241 int i;
242
243 for (i = 0; i < ARRAY_SIZE(nvt_chips); i++)
244 if ((id & SIO_ID_MASK) == nvt_chips[i].chip_ver) {
245 nvt->chip_ver = nvt_chips[i].chip_ver;
246 return nvt_chips[i].name;
247 }
248
249 return NULL;
250}
251
252
227/* detect hardware features */ 253/* detect hardware features */
228static int nvt_hw_detect(struct nvt_dev *nvt) 254static void nvt_hw_detect(struct nvt_dev *nvt)
229{ 255{
230 unsigned long flags; 256 const char *chip_name;
231 u8 chip_major, chip_minor; 257 int chip_id;
232 char chip_id[12];
233 bool chip_unknown = false;
234 258
235 nvt_efm_enable(nvt); 259 nvt_efm_enable(nvt);
236 260
237 /* Check if we're wired for the alternate EFER setup */ 261 /* Check if we're wired for the alternate EFER setup */
238 chip_major = nvt_cr_read(nvt, CR_CHIP_ID_HI); 262 nvt->chip_major = nvt_cr_read(nvt, CR_CHIP_ID_HI);
239 if (chip_major == 0xff) { 263 if (nvt->chip_major == 0xff) {
240 nvt->cr_efir = CR_EFIR2; 264 nvt->cr_efir = CR_EFIR2;
241 nvt->cr_efdr = CR_EFDR2; 265 nvt->cr_efdr = CR_EFDR2;
242 nvt_efm_enable(nvt); 266 nvt_efm_enable(nvt);
243 chip_major = nvt_cr_read(nvt, CR_CHIP_ID_HI); 267 nvt->chip_major = nvt_cr_read(nvt, CR_CHIP_ID_HI);
244 } 268 }
245 269
246 chip_minor = nvt_cr_read(nvt, CR_CHIP_ID_LO); 270 nvt->chip_minor = nvt_cr_read(nvt, CR_CHIP_ID_LO);
247 271
248 /* these are the known working chip revisions... */ 272 chip_id = nvt->chip_major << 8 | nvt->chip_minor;
249 switch (chip_major) { 273 chip_name = nvt_find_chip(nvt, chip_id);
250 case CHIP_ID_HIGH_667:
251 strcpy(chip_id, "w83667hg\0");
252 if (chip_minor != CHIP_ID_LOW_667)
253 chip_unknown = true;
254 break;
255 case CHIP_ID_HIGH_677B:
256 strcpy(chip_id, "w83677hg\0");
257 if (chip_minor != CHIP_ID_LOW_677B2 &&
258 chip_minor != CHIP_ID_LOW_677B3)
259 chip_unknown = true;
260 break;
261 case CHIP_ID_HIGH_677C:
262 strcpy(chip_id, "w83677hg-c\0");
263 if (chip_minor != CHIP_ID_LOW_677C)
264 chip_unknown = true;
265 break;
266 default:
267 strcpy(chip_id, "w836x7hg\0");
268 chip_unknown = true;
269 break;
270 }
271 274
272 /* warn, but still let the driver load, if we don't know this chip */ 275 /* warn, but still let the driver load, if we don't know this chip */
273 if (chip_unknown) 276 if (!chip_name)
274 nvt_pr(KERN_WARNING, "%s: unknown chip, id: 0x%02x 0x%02x, " 277 dev_warn(&nvt->pdev->dev,
275 "it may not work...", chip_id, chip_major, chip_minor); 278 "unknown chip, id: 0x%02x 0x%02x, it may not work...",
279 nvt->chip_major, nvt->chip_minor);
276 else 280 else
277 nvt_dbg("%s: chip id: 0x%02x 0x%02x", 281 dev_info(&nvt->pdev->dev,
278 chip_id, chip_major, chip_minor); 282 "found %s or compatible: chip id: 0x%02x 0x%02x",
283 chip_name, nvt->chip_major, nvt->chip_minor);
279 284
280 nvt_efm_disable(nvt); 285 nvt_efm_disable(nvt);
281
282 spin_lock_irqsave(&nvt->nvt_lock, flags);
283 nvt->chip_major = chip_major;
284 nvt->chip_minor = chip_minor;
285 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
286
287 return 0;
288} 286}
289 287
290static void nvt_cir_ldev_init(struct nvt_dev *nvt) 288static void nvt_cir_ldev_init(struct nvt_dev *nvt)
291{ 289{
292 u8 val, psreg, psmask, psval; 290 u8 val, psreg, psmask, psval;
293 291
294 if (nvt->chip_major == CHIP_ID_HIGH_667) { 292 if (is_w83667hg(nvt)) {
295 psreg = CR_MULTIFUNC_PIN_SEL; 293 psreg = CR_MULTIFUNC_PIN_SEL;
296 psmask = MULTIFUNC_PIN_SEL_MASK; 294 psmask = MULTIFUNC_PIN_SEL_MASK;
297 psval = MULTIFUNC_ENABLE_CIR | MULTIFUNC_ENABLE_CIRWB; 295 psval = MULTIFUNC_ENABLE_CIR | MULTIFUNC_ENABLE_CIRWB;
@@ -485,8 +483,9 @@ static u32 nvt_rx_carrier_detect(struct nvt_dev *nvt)
485 duration *= SAMPLE_PERIOD; 483 duration *= SAMPLE_PERIOD;
486 484
487 if (!count || !duration) { 485 if (!count || !duration) {
488 nvt_pr(KERN_NOTICE, "Unable to determine carrier! (c:%u, d:%u)", 486 dev_notice(&nvt->pdev->dev,
489 count, duration); 487 "Unable to determine carrier! (c:%u, d:%u)",
488 count, duration);
490 return 0; 489 return 0;
491 } 490 }
492 491
@@ -661,7 +660,7 @@ static void nvt_process_rx_ir_data(struct nvt_dev *nvt)
661 660
662static void nvt_handle_rx_fifo_overrun(struct nvt_dev *nvt) 661static void nvt_handle_rx_fifo_overrun(struct nvt_dev *nvt)
663{ 662{
664 nvt_pr(KERN_WARNING, "RX FIFO overrun detected, flushing data!"); 663 dev_warn(&nvt->pdev->dev, "RX FIFO overrun detected, flushing data!");
665 664
666 nvt->pkts = 0; 665 nvt->pkts = 0;
667 nvt_clear_cir_fifo(nvt); 666 nvt_clear_cir_fifo(nvt);
@@ -719,7 +718,7 @@ static void nvt_get_rx_ir_data(struct nvt_dev *nvt)
719 718
720static void nvt_cir_log_irqs(u8 status, u8 iren) 719static void nvt_cir_log_irqs(u8 status, u8 iren)
721{ 720{
722 nvt_pr(KERN_INFO, "IRQ 0x%02x (IREN 0x%02x) :%s%s%s%s%s%s%s%s%s", 721 nvt_dbg("IRQ 0x%02x (IREN 0x%02x) :%s%s%s%s%s%s%s%s%s",
723 status, iren, 722 status, iren,
724 status & CIR_IRSTS_RDR ? " RDR" : "", 723 status & CIR_IRSTS_RDR ? " RDR" : "",
725 status & CIR_IRSTS_RTR ? " RTR" : "", 724 status & CIR_IRSTS_RTR ? " RTR" : "",
@@ -779,7 +778,7 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
779 if (!status) { 778 if (!status) {
780 nvt_dbg_verbose("%s exiting, IRSTS 0x0", __func__); 779 nvt_dbg_verbose("%s exiting, IRSTS 0x0", __func__);
781 nvt_cir_reg_write(nvt, 0xff, CIR_IRSTS); 780 nvt_cir_reg_write(nvt, 0xff, CIR_IRSTS);
782 return IRQ_RETVAL(IRQ_NONE); 781 return IRQ_NONE;
783 } 782 }
784 783
785 /* ack/clear all irq flags we've got */ 784 /* ack/clear all irq flags we've got */
@@ -790,11 +789,10 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
790 iren = nvt_cir_reg_read(nvt, CIR_IREN); 789 iren = nvt_cir_reg_read(nvt, CIR_IREN);
791 if (!iren) { 790 if (!iren) {
792 nvt_dbg_verbose("%s exiting, CIR not enabled", __func__); 791 nvt_dbg_verbose("%s exiting, CIR not enabled", __func__);
793 return IRQ_RETVAL(IRQ_NONE); 792 return IRQ_NONE;
794 } 793 }
795 794
796 if (debug) 795 nvt_cir_log_irqs(status, iren);
797 nvt_cir_log_irqs(status, iren);
798 796
799 if (status & CIR_IRSTS_RTR) { 797 if (status & CIR_IRSTS_RTR) {
800 /* FIXME: add code for study/learn mode */ 798 /* FIXME: add code for study/learn mode */
@@ -853,7 +851,7 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
853 } 851 }
854 852
855 nvt_dbg_verbose("%s done", __func__); 853 nvt_dbg_verbose("%s done", __func__);
856 return IRQ_RETVAL(IRQ_HANDLED); 854 return IRQ_HANDLED;
857} 855}
858 856
859/* Interrupt service routine for CIR Wake */ 857/* Interrupt service routine for CIR Wake */
@@ -867,7 +865,7 @@ static irqreturn_t nvt_cir_wake_isr(int irq, void *data)
867 865
868 status = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRSTS); 866 status = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRSTS);
869 if (!status) 867 if (!status)
870 return IRQ_RETVAL(IRQ_NONE); 868 return IRQ_NONE;
871 869
872 if (status & CIR_WAKE_IRSTS_IR_PENDING) 870 if (status & CIR_WAKE_IRSTS_IR_PENDING)
873 nvt_clear_cir_wake_fifo(nvt); 871 nvt_clear_cir_wake_fifo(nvt);
@@ -879,7 +877,7 @@ static irqreturn_t nvt_cir_wake_isr(int irq, void *data)
879 iren = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IREN); 877 iren = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IREN);
880 if (!iren) { 878 if (!iren) {
881 nvt_dbg_wake("%s exiting, wake not enabled", __func__); 879 nvt_dbg_wake("%s exiting, wake not enabled", __func__);
882 return IRQ_RETVAL(IRQ_HANDLED); 880 return IRQ_HANDLED;
883 } 881 }
884 882
885 if ((status & CIR_WAKE_IRSTS_PE) && 883 if ((status & CIR_WAKE_IRSTS_PE) &&
@@ -896,7 +894,7 @@ static irqreturn_t nvt_cir_wake_isr(int irq, void *data)
896 } 894 }
897 895
898 nvt_dbg_wake("%s done", __func__); 896 nvt_dbg_wake("%s done", __func__);
899 return IRQ_RETVAL(IRQ_HANDLED); 897 return IRQ_HANDLED;
900} 898}
901 899
902static void nvt_enable_cir(struct nvt_dev *nvt) 900static void nvt_enable_cir(struct nvt_dev *nvt)
@@ -974,7 +972,7 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
974 struct rc_dev *rdev; 972 struct rc_dev *rdev;
975 int ret = -ENOMEM; 973 int ret = -ENOMEM;
976 974
977 nvt = kzalloc(sizeof(struct nvt_dev), GFP_KERNEL); 975 nvt = devm_kzalloc(&pdev->dev, sizeof(struct nvt_dev), GFP_KERNEL);
978 if (!nvt) 976 if (!nvt)
979 return ret; 977 return ret;
980 978
@@ -1026,9 +1024,7 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1026 1024
1027 init_waitqueue_head(&nvt->tx.queue); 1025 init_waitqueue_head(&nvt->tx.queue);
1028 1026
1029 ret = nvt_hw_detect(nvt); 1027 nvt_hw_detect(nvt);
1030 if (ret)
1031 goto exit_free_dev_rdev;
1032 1028
1033 /* Initialize CIR & CIR Wake Logical Devices */ 1029 /* Initialize CIR & CIR Wake Logical Devices */
1034 nvt_efm_enable(nvt); 1030 nvt_efm_enable(nvt);
@@ -1074,25 +1070,26 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1074 1070
1075 ret = -EBUSY; 1071 ret = -EBUSY;
1076 /* now claim resources */ 1072 /* now claim resources */
1077 if (!request_region(nvt->cir_addr, 1073 if (!devm_request_region(&pdev->dev, nvt->cir_addr,
1078 CIR_IOREG_LENGTH, NVT_DRIVER_NAME)) 1074 CIR_IOREG_LENGTH, NVT_DRIVER_NAME))
1079 goto exit_unregister_device; 1075 goto exit_unregister_device;
1080 1076
1081 if (request_irq(nvt->cir_irq, nvt_cir_isr, IRQF_SHARED, 1077 if (devm_request_irq(&pdev->dev, nvt->cir_irq, nvt_cir_isr,
1082 NVT_DRIVER_NAME, (void *)nvt)) 1078 IRQF_SHARED, NVT_DRIVER_NAME, (void *)nvt))
1083 goto exit_release_cir_addr; 1079 goto exit_unregister_device;
1084 1080
1085 if (!request_region(nvt->cir_wake_addr, 1081 if (!devm_request_region(&pdev->dev, nvt->cir_wake_addr,
1086 CIR_IOREG_LENGTH, NVT_DRIVER_NAME)) 1082 CIR_IOREG_LENGTH, NVT_DRIVER_NAME))
1087 goto exit_free_irq; 1083 goto exit_unregister_device;
1088 1084
1089 if (request_irq(nvt->cir_wake_irq, nvt_cir_wake_isr, IRQF_SHARED, 1085 if (devm_request_irq(&pdev->dev, nvt->cir_wake_irq,
1090 NVT_DRIVER_NAME, (void *)nvt)) 1086 nvt_cir_wake_isr, IRQF_SHARED,
1091 goto exit_release_cir_wake_addr; 1087 NVT_DRIVER_NAME, (void *)nvt))
1088 goto exit_unregister_device;
1092 1089
1093 device_init_wakeup(&pdev->dev, true); 1090 device_init_wakeup(&pdev->dev, true);
1094 1091
1095 nvt_pr(KERN_NOTICE, "driver has been successfully loaded\n"); 1092 dev_notice(&pdev->dev, "driver has been successfully loaded\n");
1096 if (debug) { 1093 if (debug) {
1097 cir_dump_regs(nvt); 1094 cir_dump_regs(nvt);
1098 cir_wake_dump_regs(nvt); 1095 cir_wake_dump_regs(nvt);
@@ -1100,18 +1097,11 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1100 1097
1101 return 0; 1098 return 0;
1102 1099
1103exit_release_cir_wake_addr:
1104 release_region(nvt->cir_wake_addr, CIR_IOREG_LENGTH);
1105exit_free_irq:
1106 free_irq(nvt->cir_irq, nvt);
1107exit_release_cir_addr:
1108 release_region(nvt->cir_addr, CIR_IOREG_LENGTH);
1109exit_unregister_device: 1100exit_unregister_device:
1110 rc_unregister_device(rdev); 1101 rc_unregister_device(rdev);
1111 rdev = NULL; 1102 rdev = NULL;
1112exit_free_dev_rdev: 1103exit_free_dev_rdev:
1113 rc_free_device(rdev); 1104 rc_free_device(rdev);
1114 kfree(nvt);
1115 1105
1116 return ret; 1106 return ret;
1117} 1107}
@@ -1129,15 +1119,7 @@ static void nvt_remove(struct pnp_dev *pdev)
1129 nvt_enable_wake(nvt); 1119 nvt_enable_wake(nvt);
1130 spin_unlock_irqrestore(&nvt->nvt_lock, flags); 1120 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
1131 1121
1132 /* free resources */
1133 free_irq(nvt->cir_irq, nvt);
1134 free_irq(nvt->cir_wake_irq, nvt);
1135 release_region(nvt->cir_addr, CIR_IOREG_LENGTH);
1136 release_region(nvt->cir_wake_addr, CIR_IOREG_LENGTH);
1137
1138 rc_unregister_device(nvt->rdev); 1122 rc_unregister_device(nvt->rdev);
1139
1140 kfree(nvt);
1141} 1123}
1142 1124
1143static int nvt_suspend(struct pnp_dev *pdev, pm_message_t state) 1125static int nvt_suspend(struct pnp_dev *pdev, pm_message_t state)
diff --git a/drivers/media/rc/nuvoton-cir.h b/drivers/media/rc/nuvoton-cir.h
index e1cf23c3875b..0ad15d34e9c9 100644
--- a/drivers/media/rc/nuvoton-cir.h
+++ b/drivers/media/rc/nuvoton-cir.h
@@ -35,9 +35,6 @@
35static int debug; 35static int debug;
36 36
37 37
38#define nvt_pr(level, text, ...) \
39 printk(level KBUILD_MODNAME ": " text, ## __VA_ARGS__)
40
41#define nvt_dbg(text, ...) \ 38#define nvt_dbg(text, ...) \
42 if (debug) \ 39 if (debug) \
43 printk(KERN_DEBUG \ 40 printk(KERN_DEBUG \
@@ -64,6 +61,21 @@ static int debug;
64#define TX_BUF_LEN 256 61#define TX_BUF_LEN 256
65#define RX_BUF_LEN 32 62#define RX_BUF_LEN 32
66 63
64#define SIO_ID_MASK 0xfff0
65
66enum nvt_chip_ver {
67 NVT_UNKNOWN = 0,
68 NVT_W83667HG = 0xa510,
69 NVT_6775F = 0xb470,
70 NVT_6776F = 0xc330,
71 NVT_6779D = 0xc560
72};
73
74struct nvt_chip {
75 const char *name;
76 enum nvt_chip_ver chip_ver;
77};
78
67struct nvt_dev { 79struct nvt_dev {
68 struct pnp_dev *pdev; 80 struct pnp_dev *pdev;
69 struct rc_dev *rdev; 81 struct rc_dev *rdev;
@@ -93,6 +105,7 @@ struct nvt_dev {
93 int cir_irq; 105 int cir_irq;
94 int cir_wake_irq; 106 int cir_wake_irq;
95 107
108 enum nvt_chip_ver chip_ver;
96 /* hardware id */ 109 /* hardware id */
97 u8 chip_major; 110 u8 chip_major;
98 u8 chip_minor; 111 u8 chip_minor;
@@ -326,15 +339,6 @@ struct nvt_dev {
326#define EFER_EFM_ENABLE 0x87 339#define EFER_EFM_ENABLE 0x87
327#define EFER_EFM_DISABLE 0xaa 340#define EFER_EFM_DISABLE 0xaa
328 341
329/* Chip IDs found in CR_CHIP_ID_{HI,LO} */
330#define CHIP_ID_HIGH_667 0xa5
331#define CHIP_ID_HIGH_677B 0xb4
332#define CHIP_ID_HIGH_677C 0xc3
333#define CHIP_ID_LOW_667 0x13
334#define CHIP_ID_LOW_677B2 0x72
335#define CHIP_ID_LOW_677B3 0x73
336#define CHIP_ID_LOW_677C 0x33
337
338/* Config regs we need to care about */ 342/* Config regs we need to care about */
339#define CR_SOFTWARE_RESET 0x02 343#define CR_SOFTWARE_RESET 0x02
340#define CR_LOGICAL_DEV_SEL 0x07 344#define CR_LOGICAL_DEV_SEL 0x07
diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h
index b68d4f762734..7359f3d03b64 100644
--- a/drivers/media/rc/rc-core-priv.h
+++ b/drivers/media/rc/rc-core-priv.h
@@ -167,75 +167,4 @@ void ir_raw_init(void);
167 * loads the compiled decoders for their usage with IR raw events 167 * loads the compiled decoders for their usage with IR raw events
168 */ 168 */
169 169
170/* from ir-nec-decoder.c */
171#ifdef CONFIG_IR_NEC_DECODER_MODULE
172#define load_nec_decode() request_module_nowait("ir-nec-decoder")
173#else
174static inline void load_nec_decode(void) { }
175#endif
176
177/* from ir-rc5-decoder.c */
178#ifdef CONFIG_IR_RC5_DECODER_MODULE
179#define load_rc5_decode() request_module_nowait("ir-rc5-decoder")
180#else
181static inline void load_rc5_decode(void) { }
182#endif
183
184/* from ir-rc6-decoder.c */
185#ifdef CONFIG_IR_RC6_DECODER_MODULE
186#define load_rc6_decode() request_module_nowait("ir-rc6-decoder")
187#else
188static inline void load_rc6_decode(void) { }
189#endif
190
191/* from ir-jvc-decoder.c */
192#ifdef CONFIG_IR_JVC_DECODER_MODULE
193#define load_jvc_decode() request_module_nowait("ir-jvc-decoder")
194#else
195static inline void load_jvc_decode(void) { }
196#endif
197
198/* from ir-sony-decoder.c */
199#ifdef CONFIG_IR_SONY_DECODER_MODULE
200#define load_sony_decode() request_module_nowait("ir-sony-decoder")
201#else
202static inline void load_sony_decode(void) { }
203#endif
204
205/* from ir-sanyo-decoder.c */
206#ifdef CONFIG_IR_SANYO_DECODER_MODULE
207#define load_sanyo_decode() request_module_nowait("ir-sanyo-decoder")
208#else
209static inline void load_sanyo_decode(void) { }
210#endif
211
212/* from ir-sharp-decoder.c */
213#ifdef CONFIG_IR_SHARP_DECODER_MODULE
214#define load_sharp_decode() request_module_nowait("ir-sharp-decoder")
215#else
216static inline void load_sharp_decode(void) { }
217#endif
218
219/* from ir-mce_kbd-decoder.c */
220#ifdef CONFIG_IR_MCE_KBD_DECODER_MODULE
221#define load_mce_kbd_decode() request_module_nowait("ir-mce_kbd-decoder")
222#else
223static inline void load_mce_kbd_decode(void) { }
224#endif
225
226/* from ir-lirc-codec.c */
227#ifdef CONFIG_IR_LIRC_CODEC_MODULE
228#define load_lirc_codec() request_module_nowait("ir-lirc-codec")
229#else
230static inline void load_lirc_codec(void) { }
231#endif
232
233/* from ir-xmp-decoder.c */
234#ifdef CONFIG_IR_XMP_DECODER_MODULE
235#define load_xmp_decode() request_module_nowait("ir-xmp-decoder")
236#else
237static inline void load_xmp_decode(void) { }
238#endif
239
240
241#endif /* _RC_CORE_PRIV */ 170#endif /* _RC_CORE_PRIV */
diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c
index ad260520a9d4..c69807fe2fef 100644
--- a/drivers/media/rc/rc-ir-raw.c
+++ b/drivers/media/rc/rc-ir-raw.c
@@ -59,7 +59,9 @@ static int ir_raw_event_thread(void *data)
59 59
60 mutex_lock(&ir_raw_handler_lock); 60 mutex_lock(&ir_raw_handler_lock);
61 list_for_each_entry(handler, &ir_raw_handler_list, list) 61 list_for_each_entry(handler, &ir_raw_handler_list, list)
62 handler->decode(raw->dev, ev); 62 if (raw->dev->enabled_protocols & handler->protocols ||
63 !handler->protocols)
64 handler->decode(raw->dev, ev);
63 raw->prev_ev = ev; 65 raw->prev_ev = ev;
64 mutex_unlock(&ir_raw_handler_lock); 66 mutex_unlock(&ir_raw_handler_lock);
65 } 67 }
@@ -246,6 +248,14 @@ static int change_protocol(struct rc_dev *dev, u64 *rc_type)
246 return 0; 248 return 0;
247} 249}
248 250
251static void ir_raw_disable_protocols(struct rc_dev *dev, u64 protocols)
252{
253 mutex_lock(&dev->lock);
254 dev->enabled_protocols &= ~protocols;
255 dev->enabled_wakeup_protocols &= ~protocols;
256 mutex_unlock(&dev->lock);
257}
258
249/* 259/*
250 * Used to (un)register raw event clients 260 * Used to (un)register raw event clients
251 */ 261 */
@@ -337,33 +347,16 @@ EXPORT_SYMBOL(ir_raw_handler_register);
337void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler) 347void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler)
338{ 348{
339 struct ir_raw_event_ctrl *raw; 349 struct ir_raw_event_ctrl *raw;
350 u64 protocols = ir_raw_handler->protocols;
340 351
341 mutex_lock(&ir_raw_handler_lock); 352 mutex_lock(&ir_raw_handler_lock);
342 list_del(&ir_raw_handler->list); 353 list_del(&ir_raw_handler->list);
343 if (ir_raw_handler->raw_unregister) 354 list_for_each_entry(raw, &ir_raw_client_list, list) {
344 list_for_each_entry(raw, &ir_raw_client_list, list) 355 ir_raw_disable_protocols(raw->dev, protocols);
356 if (ir_raw_handler->raw_unregister)
345 ir_raw_handler->raw_unregister(raw->dev); 357 ir_raw_handler->raw_unregister(raw->dev);
346 available_protocols &= ~ir_raw_handler->protocols; 358 }
359 available_protocols &= ~protocols;
347 mutex_unlock(&ir_raw_handler_lock); 360 mutex_unlock(&ir_raw_handler_lock);
348} 361}
349EXPORT_SYMBOL(ir_raw_handler_unregister); 362EXPORT_SYMBOL(ir_raw_handler_unregister);
350
351void ir_raw_init(void)
352{
353 /* Load the decoder modules */
354
355 load_nec_decode();
356 load_rc5_decode();
357 load_rc6_decode();
358 load_jvc_decode();
359 load_sony_decode();
360 load_sanyo_decode();
361 load_sharp_decode();
362 load_mce_kbd_decode();
363 load_lirc_codec();
364 load_xmp_decode();
365
366 /* If needed, we may later add some init code. In this case,
367 it is needed to change the CONFIG_MODULE test at rc-core.h
368 */
369}
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 3f0f71adabb4..1042fa331a07 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -61,7 +61,7 @@ struct rc_map *rc_map_get(const char *name)
61 struct rc_map_list *map; 61 struct rc_map_list *map;
62 62
63 map = seek_rc_map(name); 63 map = seek_rc_map(name);
64#ifdef MODULE 64#ifdef CONFIG_MODULES
65 if (!map) { 65 if (!map) {
66 int rc = request_module("%s", name); 66 int rc = request_module("%s", name);
67 if (rc < 0) { 67 if (rc < 0) {
@@ -777,30 +777,31 @@ static struct class rc_class = {
777 * used by the sysfs protocols file. Note that the order 777 * used by the sysfs protocols file. Note that the order
778 * of the entries is relevant. 778 * of the entries is relevant.
779 */ 779 */
780static struct { 780static const struct {
781 u64 type; 781 u64 type;
782 char *name; 782 const char *name;
783 const char *module_name;
783} proto_names[] = { 784} proto_names[] = {
784 { RC_BIT_NONE, "none" }, 785 { RC_BIT_NONE, "none", NULL },
785 { RC_BIT_OTHER, "other" }, 786 { RC_BIT_OTHER, "other", NULL },
786 { RC_BIT_UNKNOWN, "unknown" }, 787 { RC_BIT_UNKNOWN, "unknown", NULL },
787 { RC_BIT_RC5 | 788 { RC_BIT_RC5 |
788 RC_BIT_RC5X, "rc-5" }, 789 RC_BIT_RC5X, "rc-5", "ir-rc5-decoder" },
789 { RC_BIT_NEC, "nec" }, 790 { RC_BIT_NEC, "nec", "ir-nec-decoder" },
790 { RC_BIT_RC6_0 | 791 { RC_BIT_RC6_0 |
791 RC_BIT_RC6_6A_20 | 792 RC_BIT_RC6_6A_20 |
792 RC_BIT_RC6_6A_24 | 793 RC_BIT_RC6_6A_24 |
793 RC_BIT_RC6_6A_32 | 794 RC_BIT_RC6_6A_32 |
794 RC_BIT_RC6_MCE, "rc-6" }, 795 RC_BIT_RC6_MCE, "rc-6", "ir-rc6-decoder" },
795 { RC_BIT_JVC, "jvc" }, 796 { RC_BIT_JVC, "jvc", "ir-jvc-decoder" },
796 { RC_BIT_SONY12 | 797 { RC_BIT_SONY12 |
797 RC_BIT_SONY15 | 798 RC_BIT_SONY15 |
798 RC_BIT_SONY20, "sony" }, 799 RC_BIT_SONY20, "sony", "ir-sony-decoder" },
799 { RC_BIT_RC5_SZ, "rc-5-sz" }, 800 { RC_BIT_RC5_SZ, "rc-5-sz", "ir-rc5-decoder" },
800 { RC_BIT_SANYO, "sanyo" }, 801 { RC_BIT_SANYO, "sanyo", "ir-sanyo-decoder" },
801 { RC_BIT_SHARP, "sharp" }, 802 { RC_BIT_SHARP, "sharp", "ir-sharp-decoder" },
802 { RC_BIT_MCE_KBD, "mce_kbd" }, 803 { RC_BIT_MCE_KBD, "mce_kbd", "ir-mce_kbd-decoder" },
803 { RC_BIT_XMP, "xmp" }, 804 { RC_BIT_XMP, "xmp", "ir-xmp-decoder" },
804}; 805};
805 806
806/** 807/**
@@ -979,6 +980,48 @@ static int parse_protocol_change(u64 *protocols, const char *buf)
979 return count; 980 return count;
980} 981}
981 982
983static void ir_raw_load_modules(u64 *protocols)
984
985{
986 u64 available;
987 int i, ret;
988
989 for (i = 0; i < ARRAY_SIZE(proto_names); i++) {
990 if (proto_names[i].type == RC_BIT_NONE ||
991 proto_names[i].type & (RC_BIT_OTHER | RC_BIT_UNKNOWN))
992 continue;
993
994 available = ir_raw_get_allowed_protocols();
995 if (!(*protocols & proto_names[i].type & ~available))
996 continue;
997
998 if (!proto_names[i].module_name) {
999 pr_err("Can't enable IR protocol %s\n",
1000 proto_names[i].name);
1001 *protocols &= ~proto_names[i].type;
1002 continue;
1003 }
1004
1005 ret = request_module("%s", proto_names[i].module_name);
1006 if (ret < 0) {
1007 pr_err("Couldn't load IR protocol module %s\n",
1008 proto_names[i].module_name);
1009 *protocols &= ~proto_names[i].type;
1010 continue;
1011 }
1012 msleep(20);
1013 available = ir_raw_get_allowed_protocols();
1014 if (!(*protocols & proto_names[i].type & ~available))
1015 continue;
1016
1017 pr_err("Loaded IR protocol module %s, \
1018 but protocol %s still not available\n",
1019 proto_names[i].module_name,
1020 proto_names[i].name);
1021 *protocols &= ~proto_names[i].type;
1022 }
1023}
1024
982/** 1025/**
983 * store_protocols() - changes the current/wakeup IR protocol(s) 1026 * store_protocols() - changes the current/wakeup IR protocol(s)
984 * @device: the device descriptor 1027 * @device: the device descriptor
@@ -1045,6 +1088,9 @@ static ssize_t store_protocols(struct device *device,
1045 goto out; 1088 goto out;
1046 } 1089 }
1047 1090
1091 if (dev->driver_type == RC_DRIVER_IR_RAW)
1092 ir_raw_load_modules(&new_protocols);
1093
1048 if (new_protocols != old_protocols) { 1094 if (new_protocols != old_protocols) {
1049 *current_protocols = new_protocols; 1095 *current_protocols = new_protocols;
1050 IR_dprintk(1, "Protocols changed to 0x%llx\n", 1096 IR_dprintk(1, "Protocols changed to 0x%llx\n",
@@ -1420,17 +1466,13 @@ int rc_register_device(struct rc_dev *dev)
1420 dev->input_dev->rep[REP_PERIOD] = 125; 1466 dev->input_dev->rep[REP_PERIOD] = 125;
1421 1467
1422 path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL); 1468 path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL);
1423 printk(KERN_INFO "%s: %s as %s\n", 1469 dev_info(&dev->dev, "%s as %s\n",
1424 dev_name(&dev->dev), 1470 dev->input_name ?: "Unspecified device", path ?: "N/A");
1425 dev->input_name ? dev->input_name : "Unspecified device",
1426 path ? path : "N/A");
1427 kfree(path); 1471 kfree(path);
1428 1472
1429 if (dev->driver_type == RC_DRIVER_IR_RAW) { 1473 if (dev->driver_type == RC_DRIVER_IR_RAW) {
1430 /* Load raw decoders, if they aren't already */
1431 if (!raw_init) { 1474 if (!raw_init) {
1432 IR_dprintk(1, "Loading raw decoders\n"); 1475 request_module_nowait("ir-lirc-codec");
1433 ir_raw_init();
1434 raw_init = true; 1476 raw_init = true;
1435 } 1477 }
1436 /* calls ir_register_device so unlock mutex here*/ 1478 /* calls ir_register_device so unlock mutex here*/
diff --git a/drivers/media/rc/st_rc.c b/drivers/media/rc/st_rc.c
index 37d040158dff..1fa0c9d1c508 100644
--- a/drivers/media/rc/st_rc.c
+++ b/drivers/media/rc/st_rc.c
@@ -16,6 +16,7 @@
16#include <linux/reset.h> 16#include <linux/reset.h>
17#include <media/rc-core.h> 17#include <media/rc-core.h>
18#include <linux/pinctrl/consumer.h> 18#include <linux/pinctrl/consumer.h>
19#include <linux/pm_wakeirq.h>
19 20
20struct st_rc_device { 21struct st_rc_device {
21 struct device *dev; 22 struct device *dev;
@@ -190,6 +191,9 @@ static void st_rc_hardware_init(struct st_rc_device *dev)
190static int st_rc_remove(struct platform_device *pdev) 191static int st_rc_remove(struct platform_device *pdev)
191{ 192{
192 struct st_rc_device *rc_dev = platform_get_drvdata(pdev); 193 struct st_rc_device *rc_dev = platform_get_drvdata(pdev);
194
195 dev_pm_clear_wake_irq(&pdev->dev);
196 device_init_wakeup(&pdev->dev, false);
193 clk_disable_unprepare(rc_dev->sys_clock); 197 clk_disable_unprepare(rc_dev->sys_clock);
194 rc_unregister_device(rc_dev->rdev); 198 rc_unregister_device(rc_dev->rdev);
195 return 0; 199 return 0;
@@ -298,22 +302,22 @@ static int st_rc_probe(struct platform_device *pdev)
298 rdev->map_name = RC_MAP_LIRC; 302 rdev->map_name = RC_MAP_LIRC;
299 rdev->input_name = "ST Remote Control Receiver"; 303 rdev->input_name = "ST Remote Control Receiver";
300 304
301 /* enable wake via this device */
302 device_set_wakeup_capable(dev, true);
303 device_set_wakeup_enable(dev, true);
304
305 ret = rc_register_device(rdev); 305 ret = rc_register_device(rdev);
306 if (ret < 0) 306 if (ret < 0)
307 goto clkerr; 307 goto clkerr;
308 308
309 rc_dev->rdev = rdev; 309 rc_dev->rdev = rdev;
310 if (devm_request_irq(dev, rc_dev->irq, st_rc_rx_interrupt, 310 if (devm_request_irq(dev, rc_dev->irq, st_rc_rx_interrupt,
311 IRQF_NO_SUSPEND, IR_ST_NAME, rc_dev) < 0) { 311 0, IR_ST_NAME, rc_dev) < 0) {
312 dev_err(dev, "IRQ %d register failed\n", rc_dev->irq); 312 dev_err(dev, "IRQ %d register failed\n", rc_dev->irq);
313 ret = -EINVAL; 313 ret = -EINVAL;
314 goto rcerr; 314 goto rcerr;
315 } 315 }
316 316
317 /* enable wake via this device */
318 device_init_wakeup(dev, true);
319 dev_pm_set_wake_irq(dev, rc_dev->irq);
320
317 /** 321 /**
318 * for LIRC_MODE_MODE2 or LIRC_MODE_PULSE or LIRC_MODE_RAW 322 * for LIRC_MODE_MODE2 or LIRC_MODE_PULSE or LIRC_MODE_RAW
319 * lircd expects a long space first before a signal train to sync. 323 * lircd expects a long space first before a signal train to sync.
diff --git a/drivers/media/rc/streamzap.c b/drivers/media/rc/streamzap.c
index 5a17cb88ff27..815243c65bc3 100644
--- a/drivers/media/rc/streamzap.c
+++ b/drivers/media/rc/streamzap.c
@@ -34,6 +34,7 @@
34#include <linux/device.h> 34#include <linux/device.h>
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/ktime.h>
37#include <linux/usb.h> 38#include <linux/usb.h>
38#include <linux/usb/input.h> 39#include <linux/usb/input.h>
39#include <media/rc-core.h> 40#include <media/rc-core.h>
@@ -96,8 +97,8 @@ struct streamzap_ir {
96 /* sum of signal lengths received since signal start */ 97 /* sum of signal lengths received since signal start */
97 unsigned long sum; 98 unsigned long sum;
98 /* start time of signal; necessary for gap tracking */ 99 /* start time of signal; necessary for gap tracking */
99 struct timeval signal_last; 100 ktime_t signal_last;
100 struct timeval signal_start; 101 ktime_t signal_start;
101 bool timeout_enabled; 102 bool timeout_enabled;
102 103
103 char name[128]; 104 char name[128];
@@ -136,20 +137,18 @@ static void sz_push_full_pulse(struct streamzap_ir *sz,
136 DEFINE_IR_RAW_EVENT(rawir); 137 DEFINE_IR_RAW_EVENT(rawir);
137 138
138 if (sz->idle) { 139 if (sz->idle) {
139 long deltv; 140 int delta;
140 141
141 sz->signal_last = sz->signal_start; 142 sz->signal_last = sz->signal_start;
142 do_gettimeofday(&sz->signal_start); 143 sz->signal_start = ktime_get_real();
143 144
144 deltv = sz->signal_start.tv_sec - sz->signal_last.tv_sec; 145 delta = ktime_us_delta(sz->signal_start, sz->signal_last);
145 rawir.pulse = false; 146 rawir.pulse = false;
146 if (deltv > 15) { 147 if (delta > (15 * USEC_PER_SEC)) {
147 /* really long time */ 148 /* really long time */
148 rawir.duration = IR_MAX_DURATION; 149 rawir.duration = IR_MAX_DURATION;
149 } else { 150 } else {
150 rawir.duration = (int)(deltv * 1000000 + 151 rawir.duration = delta;
151 sz->signal_start.tv_usec -
152 sz->signal_last.tv_usec);
153 rawir.duration -= sz->sum; 152 rawir.duration -= sz->sum;
154 rawir.duration = US_TO_NS(rawir.duration); 153 rawir.duration = US_TO_NS(rawir.duration);
155 rawir.duration = (rawir.duration > IR_MAX_DURATION) ? 154 rawir.duration = (rawir.duration > IR_MAX_DURATION) ?
@@ -428,7 +427,7 @@ static int streamzap_probe(struct usb_interface *intf,
428 sz->max_timeout = US_TO_NS(SZ_TIMEOUT * SZ_RESOLUTION); 427 sz->max_timeout = US_TO_NS(SZ_TIMEOUT * SZ_RESOLUTION);
429 #endif 428 #endif
430 429
431 do_gettimeofday(&sz->signal_start); 430 sz->signal_start = ktime_get_real();
432 431
433 /* Complete final initialisations */ 432 /* Complete final initialisations */
434 usb_fill_int_urb(sz->urb_in, usbdev, pipe, sz->buf_in, 433 usb_fill_int_urb(sz->urb_in, usbdev, pipe, sz->buf_in,
diff --git a/drivers/media/rc/sunxi-cir.c b/drivers/media/rc/sunxi-cir.c
index 7830aef3db45..40f77685cc4a 100644
--- a/drivers/media/rc/sunxi-cir.c
+++ b/drivers/media/rc/sunxi-cir.c
@@ -153,6 +153,8 @@ static int sunxi_ir_probe(struct platform_device *pdev)
153 if (!ir) 153 if (!ir)
154 return -ENOMEM; 154 return -ENOMEM;
155 155
156 spin_lock_init(&ir->ir_lock);
157
156 if (of_device_is_compatible(dn, "allwinner,sun5i-a13-ir")) 158 if (of_device_is_compatible(dn, "allwinner,sun5i-a13-ir"))
157 ir->fifo_size = 64; 159 ir->fifo_size = 64;
158 else 160 else
diff --git a/drivers/media/tuners/max2165.c b/drivers/media/tuners/max2165.c
index 95ed46f2cd26..353b178becf6 100644
--- a/drivers/media/tuners/max2165.c
+++ b/drivers/media/tuners/max2165.c
@@ -385,7 +385,7 @@ static const struct dvb_tuner_ops max2165_tuner_ops = {
385 .info = { 385 .info = {
386 .name = "Maxim MAX2165", 386 .name = "Maxim MAX2165",
387 .frequency_min = 470000000, 387 .frequency_min = 470000000,
388 .frequency_max = 780000000, 388 .frequency_max = 862000000,
389 .frequency_step = 50000, 389 .frequency_step = 50000,
390 }, 390 },
391 391
diff --git a/drivers/media/tuners/mt2063.c b/drivers/media/tuners/mt2063.c
index 9e9c5eb4cb66..6457ac91ef09 100644
--- a/drivers/media/tuners/mt2063.c
+++ b/drivers/media/tuners/mt2063.c
@@ -225,7 +225,6 @@ struct mt2063_state {
225 const struct mt2063_config *config; 225 const struct mt2063_config *config;
226 struct dvb_tuner_ops ops; 226 struct dvb_tuner_ops ops;
227 struct dvb_frontend *frontend; 227 struct dvb_frontend *frontend;
228 struct tuner_state status;
229 228
230 u32 frequency; 229 u32 frequency;
231 u32 srate; 230 u32 srate;
diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index ce157edd45fa..0e1ca2b00e61 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -168,6 +168,7 @@ static int si2157_init(struct dvb_frontend *fe)
168 len = fw->data[fw->size - remaining]; 168 len = fw->data[fw->size - remaining];
169 if (len > SI2157_ARGLEN) { 169 if (len > SI2157_ARGLEN) {
170 dev_err(&client->dev, "Bad firmware length\n"); 170 dev_err(&client->dev, "Bad firmware length\n");
171 ret = -EINVAL;
171 goto err_release_firmware; 172 goto err_release_firmware;
172 } 173 }
173 memcpy(cmd.args, &fw->data[(fw->size - remaining) + 1], len); 174 memcpy(cmd.args, &fw->data[(fw->size - remaining) + 1], len);
diff --git a/drivers/media/usb/airspy/airspy.c b/drivers/media/usb/airspy/airspy.c
index 565a59310747..0d4ac5947f3a 100644
--- a/drivers/media/usb/airspy/airspy.c
+++ b/drivers/media/usb/airspy/airspy.c
@@ -316,7 +316,7 @@ static void airspy_urb_complete(struct urb *urb)
316 len = airspy_convert_stream(s, ptr, urb->transfer_buffer, 316 len = airspy_convert_stream(s, ptr, urb->transfer_buffer,
317 urb->actual_length); 317 urb->actual_length);
318 vb2_set_plane_payload(&fbuf->vb.vb2_buf, 0, len); 318 vb2_set_plane_payload(&fbuf->vb.vb2_buf, 0, len);
319 v4l2_get_timestamp(&fbuf->vb.timestamp); 319 fbuf->vb.vb2_buf.timestamp = ktime_get_ns();
320 fbuf->vb.sequence = s->sequence++; 320 fbuf->vb.sequence = s->sequence++;
321 vb2_buffer_done(&fbuf->vb.vb2_buf, VB2_BUF_STATE_DONE); 321 vb2_buffer_done(&fbuf->vb.vb2_buf, VB2_BUF_STATE_DONE);
322 } 322 }
@@ -488,7 +488,7 @@ static void airspy_disconnect(struct usb_interface *intf)
488 488
489/* Videobuf2 operations */ 489/* Videobuf2 operations */
490static int airspy_queue_setup(struct vb2_queue *vq, 490static int airspy_queue_setup(struct vb2_queue *vq,
491 const void *parg, unsigned int *nbuffers, 491 unsigned int *nbuffers,
492 unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) 492 unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[])
493{ 493{
494 struct airspy *s = vb2_get_drv_priv(vq); 494 struct airspy *s = vb2_get_drv_priv(vq);
diff --git a/drivers/media/usb/as102/as102_fw.c b/drivers/media/usb/as102/as102_fw.c
index 07d08c49f4d4..5a28ce3a1d49 100644
--- a/drivers/media/usb/as102/as102_fw.c
+++ b/drivers/media/usb/as102/as102_fw.c
@@ -198,6 +198,7 @@ int as102_fw_upload(struct as10x_bus_adapter_t *bus_adap)
198 pr_info("%s: firmware: %s loaded with success\n", 198 pr_info("%s: firmware: %s loaded with success\n",
199 DRIVER_NAME, fw1); 199 DRIVER_NAME, fw1);
200 release_firmware(firmware); 200 release_firmware(firmware);
201 firmware = NULL;
201 202
202 /* wait for boot to complete */ 203 /* wait for boot to complete */
203 mdelay(100); 204 mdelay(100);
diff --git a/drivers/media/usb/au0828/au0828-vbi.c b/drivers/media/usb/au0828/au0828-vbi.c
index 130c8b49bf7f..b4efc103ae57 100644
--- a/drivers/media/usb/au0828/au0828-vbi.c
+++ b/drivers/media/usb/au0828/au0828-vbi.c
@@ -30,23 +30,17 @@
30 30
31/* ------------------------------------------------------------------ */ 31/* ------------------------------------------------------------------ */
32 32
33static int vbi_queue_setup(struct vb2_queue *vq, const void *parg, 33static int vbi_queue_setup(struct vb2_queue *vq,
34 unsigned int *nbuffers, unsigned int *nplanes, 34 unsigned int *nbuffers, unsigned int *nplanes,
35 unsigned int sizes[], void *alloc_ctxs[]) 35 unsigned int sizes[], void *alloc_ctxs[])
36{ 36{
37 const struct v4l2_format *fmt = parg;
38 struct au0828_dev *dev = vb2_get_drv_priv(vq); 37 struct au0828_dev *dev = vb2_get_drv_priv(vq);
39 unsigned long img_size = dev->vbi_width * dev->vbi_height * 2; 38 unsigned long size = dev->vbi_width * dev->vbi_height * 2;
40 unsigned long size;
41
42 size = fmt ? (fmt->fmt.vbi.samples_per_line *
43 (fmt->fmt.vbi.count[0] + fmt->fmt.vbi.count[1])) : img_size;
44 if (size < img_size)
45 return -EINVAL;
46 39
40 if (*nplanes)
41 return sizes[0] < size ? -EINVAL : 0;
47 *nplanes = 1; 42 *nplanes = 1;
48 sizes[0] = size; 43 sizes[0] = size;
49
50 return 0; 44 return 0;
51} 45}
52 46
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 45c622e234f7..0a725a161dd6 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -314,7 +314,7 @@ static inline void buffer_filled(struct au0828_dev *dev,
314 vb->sequence = dev->vbi_frame_count++; 314 vb->sequence = dev->vbi_frame_count++;
315 315
316 vb->field = V4L2_FIELD_INTERLACED; 316 vb->field = V4L2_FIELD_INTERLACED;
317 v4l2_get_timestamp(&vb->timestamp); 317 vb->vb2_buf.timestamp = ktime_get_ns();
318 vb2_buffer_done(&vb->vb2_buf, VB2_BUF_STATE_DONE); 318 vb2_buffer_done(&vb->vb2_buf, VB2_BUF_STATE_DONE);
319} 319}
320 320
@@ -638,19 +638,15 @@ static inline int au0828_isoc_copy(struct au0828_dev *dev, struct urb *urb)
638 return rc; 638 return rc;
639} 639}
640 640
641static int queue_setup(struct vb2_queue *vq, const void *parg, 641static int queue_setup(struct vb2_queue *vq,
642 unsigned int *nbuffers, unsigned int *nplanes, 642 unsigned int *nbuffers, unsigned int *nplanes,
643 unsigned int sizes[], void *alloc_ctxs[]) 643 unsigned int sizes[], void *alloc_ctxs[])
644{ 644{
645 const struct v4l2_format *fmt = parg;
646 struct au0828_dev *dev = vb2_get_drv_priv(vq); 645 struct au0828_dev *dev = vb2_get_drv_priv(vq);
647 unsigned long img_size = dev->height * dev->bytesperline; 646 unsigned long size = dev->height * dev->bytesperline;
648 unsigned long size;
649
650 size = fmt ? fmt->fmt.pix.sizeimage : img_size;
651 if (size < img_size)
652 return -EINVAL;
653 647
648 if (*nplanes)
649 return sizes[0] < size ? -EINVAL : 0;
654 *nplanes = 1; 650 *nplanes = 1;
655 sizes[0] = size; 651 sizes[0] = size;
656 652
diff --git a/drivers/media/usb/cpia2/cpia2_usb.c b/drivers/media/usb/cpia2/cpia2_usb.c
index 351a78a84c3d..c1aa1ab2ece9 100644
--- a/drivers/media/usb/cpia2/cpia2_usb.c
+++ b/drivers/media/usb/cpia2/cpia2_usb.c
@@ -890,8 +890,7 @@ static void cpia2_usb_disconnect(struct usb_interface *intf)
890 DBG("Wakeup waiting processes\n"); 890 DBG("Wakeup waiting processes\n");
891 cam->curbuff->status = FRAME_READY; 891 cam->curbuff->status = FRAME_READY;
892 cam->curbuff->length = 0; 892 cam->curbuff->length = 0;
893 if (waitqueue_active(&cam->wq_stream)) 893 wake_up_interruptible(&cam->wq_stream);
894 wake_up_interruptible(&cam->wq_stream);
895 } 894 }
896 895
897 DBG("Releasing interface\n"); 896 DBG("Releasing interface\n");
diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c
index 47a98a2014a5..48643b94e694 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -37,7 +37,7 @@
37#include <media/v4l2-common.h> 37#include <media/v4l2-common.h>
38#include <media/v4l2-ioctl.h> 38#include <media/v4l2-ioctl.h>
39#include <media/v4l2-event.h> 39#include <media/v4l2-event.h>
40#include <media/cx2341x.h> 40#include <media/drv-intf/cx2341x.h>
41#include <media/tuner.h> 41#include <media/tuner.h>
42 42
43#define CX231xx_FIRM_IMAGE_SIZE 376836 43#define CX231xx_FIRM_IMAGE_SIZE 376836
@@ -1492,6 +1492,27 @@ static struct videobuf_queue_ops cx231xx_qops = {
1492 1492
1493/* ------------------------------------------------------------------ */ 1493/* ------------------------------------------------------------------ */
1494 1494
1495static int vidioc_cropcap(struct file *file, void *priv,
1496 struct v4l2_cropcap *cc)
1497{
1498 struct cx231xx_fh *fh = priv;
1499 struct cx231xx *dev = fh->dev;
1500 bool is_50hz = dev->encodernorm.id & V4L2_STD_625_50;
1501
1502 if (cc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1503 return -EINVAL;
1504
1505 cc->bounds.left = 0;
1506 cc->bounds.top = 0;
1507 cc->bounds.width = dev->ts1.width;
1508 cc->bounds.height = dev->ts1.height;
1509 cc->defrect = cc->bounds;
1510 cc->pixelaspect.numerator = is_50hz ? 54 : 11;
1511 cc->pixelaspect.denominator = is_50hz ? 59 : 10;
1512
1513 return 0;
1514}
1515
1495static int vidioc_g_std(struct file *file, void *fh0, v4l2_std_id *norm) 1516static int vidioc_g_std(struct file *file, void *fh0, v4l2_std_id *norm)
1496{ 1517{
1497 struct cx231xx_fh *fh = file->private_data; 1518 struct cx231xx_fh *fh = file->private_data;
@@ -1834,6 +1855,7 @@ static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {
1834 .vidioc_g_input = cx231xx_g_input, 1855 .vidioc_g_input = cx231xx_g_input,
1835 .vidioc_s_input = cx231xx_s_input, 1856 .vidioc_s_input = cx231xx_s_input,
1836 .vidioc_s_ctrl = vidioc_s_ctrl, 1857 .vidioc_s_ctrl = vidioc_s_ctrl,
1858 .vidioc_cropcap = vidioc_cropcap,
1837 .vidioc_querycap = cx231xx_querycap, 1859 .vidioc_querycap = cx231xx_querycap,
1838 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, 1860 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
1839 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, 1861 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap,
@@ -1901,7 +1923,7 @@ static int cx231xx_s_audio_sampling_freq(struct cx2341x_handler *cxhdl, u32 idx)
1901 return 0; 1923 return 0;
1902} 1924}
1903 1925
1904static struct cx2341x_handler_ops cx231xx_ops = { 1926static const struct cx2341x_handler_ops cx231xx_ops = {
1905 /* needed for the video clock freq */ 1927 /* needed for the video clock freq */
1906 .s_audio_sampling_freq = cx231xx_s_audio_sampling_freq, 1928 .s_audio_sampling_freq = cx231xx_s_audio_sampling_freq,
1907 /* needed for setting up the video resolution */ 1929 /* needed for setting up the video resolution */
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 4a117a58c39a..89dc695c696e 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -30,7 +30,7 @@
30#include <media/tveeprom.h> 30#include <media/tveeprom.h>
31#include <media/v4l2-common.h> 31#include <media/v4l2-common.h>
32 32
33#include <media/cx25840.h> 33#include <media/drv-intf/cx25840.h>
34#include "dvb-usb-ids.h" 34#include "dvb-usb-ids.h"
35#include "xc5000.h" 35#include "xc5000.h"
36#include "tda18271.h" 36#include "tda18271.h"
@@ -352,7 +352,7 @@ struct cx231xx_board cx231xx_boards[] = {
352 .agc_analog_digital_select_gpio = 0x0c, 352 .agc_analog_digital_select_gpio = 0x0c,
353 .gpio_pin_status_mask = 0x4001000, 353 .gpio_pin_status_mask = 0x4001000,
354 .tuner_i2c_master = I2C_1_MUX_1, 354 .tuner_i2c_master = I2C_1_MUX_1,
355 .demod_i2c_master = I2C_2, 355 .demod_i2c_master = I2C_1_MUX_1,
356 .has_dvb = 1, 356 .has_dvb = 1,
357 .demod_addr = 0x0e, 357 .demod_addr = 0x0e,
358 .norm = V4L2_STD_NTSC, 358 .norm = V4L2_STD_NTSC,
@@ -713,7 +713,7 @@ struct cx231xx_board cx231xx_boards[] = {
713 .agc_analog_digital_select_gpio = 0x0c, 713 .agc_analog_digital_select_gpio = 0x0c,
714 .gpio_pin_status_mask = 0x4001000, 714 .gpio_pin_status_mask = 0x4001000,
715 .tuner_i2c_master = I2C_1_MUX_3, 715 .tuner_i2c_master = I2C_1_MUX_3,
716 .demod_i2c_master = I2C_2, 716 .demod_i2c_master = I2C_1_MUX_3,
717 .has_dvb = 1, 717 .has_dvb = 1,
718 .demod_addr = 0x0e, 718 .demod_addr = 0x0e,
719 .norm = V4L2_STD_PAL, 719 .norm = V4L2_STD_PAL,
@@ -752,7 +752,7 @@ struct cx231xx_board cx231xx_boards[] = {
752 .agc_analog_digital_select_gpio = 0x0c, 752 .agc_analog_digital_select_gpio = 0x0c,
753 .gpio_pin_status_mask = 0x4001000, 753 .gpio_pin_status_mask = 0x4001000,
754 .tuner_i2c_master = I2C_1_MUX_3, 754 .tuner_i2c_master = I2C_1_MUX_3,
755 .demod_i2c_master = I2C_2, 755 .demod_i2c_master = I2C_1_MUX_3,
756 .has_dvb = 1, 756 .has_dvb = 1,
757 .demod_addr = 0x0e, 757 .demod_addr = 0x0e,
758 .norm = V4L2_STD_PAL, 758 .norm = V4L2_STD_PAL,
@@ -791,7 +791,7 @@ struct cx231xx_board cx231xx_boards[] = {
791 .agc_analog_digital_select_gpio = 0x0c, 791 .agc_analog_digital_select_gpio = 0x0c,
792 .gpio_pin_status_mask = 0x4001000, 792 .gpio_pin_status_mask = 0x4001000,
793 .tuner_i2c_master = I2C_1_MUX_3, 793 .tuner_i2c_master = I2C_1_MUX_3,
794 .demod_i2c_master = I2C_2, 794 .demod_i2c_master = I2C_1_MUX_3,
795 .has_dvb = 1, 795 .has_dvb = 1,
796 .demod_addr = 0x0e, 796 .demod_addr = 0x0e,
797 .norm = V4L2_STD_NTSC, 797 .norm = V4L2_STD_NTSC,
diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c b/drivers/media/usb/cx231xx/cx231xx-core.c
index a2fd49b6be83..f497888d94bf 100644
--- a/drivers/media/usb/cx231xx/cx231xx-core.c
+++ b/drivers/media/usb/cx231xx/cx231xx-core.c
@@ -914,6 +914,7 @@ EXPORT_SYMBOL_GPL(cx231xx_uninit_isoc);
914 */ 914 */
915void cx231xx_uninit_bulk(struct cx231xx *dev) 915void cx231xx_uninit_bulk(struct cx231xx *dev)
916{ 916{
917 struct cx231xx_dmaqueue *dma_q = &dev->video_mode.vidq;
917 struct urb *urb; 918 struct urb *urb;
918 int i; 919 int i;
919 920
@@ -931,7 +932,7 @@ void cx231xx_uninit_bulk(struct cx231xx *dev)
931 if (dev->video_mode.bulk_ctl.transfer_buffer[i]) { 932 if (dev->video_mode.bulk_ctl.transfer_buffer[i]) {
932 usb_free_coherent(dev->udev, 933 usb_free_coherent(dev->udev,
933 urb->transfer_buffer_length, 934 urb->transfer_buffer_length,
934 dev->video_mode.isoc_ctl. 935 dev->video_mode.bulk_ctl.
935 transfer_buffer[i], 936 transfer_buffer[i],
936 urb->transfer_dma); 937 urb->transfer_dma);
937 } 938 }
@@ -943,10 +944,12 @@ void cx231xx_uninit_bulk(struct cx231xx *dev)
943 944
944 kfree(dev->video_mode.bulk_ctl.urb); 945 kfree(dev->video_mode.bulk_ctl.urb);
945 kfree(dev->video_mode.bulk_ctl.transfer_buffer); 946 kfree(dev->video_mode.bulk_ctl.transfer_buffer);
947 kfree(dma_q->p_left_data);
946 948
947 dev->video_mode.bulk_ctl.urb = NULL; 949 dev->video_mode.bulk_ctl.urb = NULL;
948 dev->video_mode.bulk_ctl.transfer_buffer = NULL; 950 dev->video_mode.bulk_ctl.transfer_buffer = NULL;
949 dev->video_mode.bulk_ctl.num_bufs = 0; 951 dev->video_mode.bulk_ctl.num_bufs = 0;
952 dma_q->p_left_data = NULL;
950 953
951 if (dev->mode_tv == 0) 954 if (dev->mode_tv == 0)
952 cx231xx_capture_start(dev, 0, Raw_Video); 955 cx231xx_capture_start(dev, 0, Raw_Video);
@@ -1196,6 +1199,16 @@ int cx231xx_init_bulk(struct cx231xx *dev, int max_packets,
1196 sb_size, cx231xx_bulk_irq_callback, dma_q); 1199 sb_size, cx231xx_bulk_irq_callback, dma_q);
1197 } 1200 }
1198 1201
1202 /* clear halt */
1203 rc = usb_clear_halt(dev->udev, dev->video_mode.bulk_ctl.urb[0]->pipe);
1204 if (rc < 0) {
1205 dev_err(dev->dev,
1206 "failed to clear USB bulk endpoint stall/halt condition (error=%i)\n",
1207 rc);
1208 cx231xx_uninit_bulk(dev);
1209 return rc;
1210 }
1211
1199 init_waitqueue_head(&dma_q->wq); 1212 init_waitqueue_head(&dma_q->wq);
1200 1213
1201 /* submit urbs and enables IRQ */ 1214 /* submit urbs and enables IRQ */
diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
index 66ee161fc7ba..e3594b9fab4a 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
@@ -725,7 +725,7 @@ static int dvb_init(struct cx231xx *dev)
725 725
726 dev->dvb->frontend = dvb_attach(lgdt3305_attach, 726 dev->dvb->frontend = dvb_attach(lgdt3305_attach,
727 &hcw_lgdt3305_config, 727 &hcw_lgdt3305_config,
728 tuner_i2c); 728 demod_i2c);
729 729
730 if (dev->dvb->frontend == NULL) { 730 if (dev->dvb->frontend == NULL) {
731 dev_err(dev->dev, 731 dev_err(dev->dev,
@@ -746,7 +746,7 @@ static int dvb_init(struct cx231xx *dev)
746 746
747 dev->dvb->frontend = dvb_attach(si2165_attach, 747 dev->dvb->frontend = dvb_attach(si2165_attach,
748 &hauppauge_930C_HD_1113xx_si2165_config, 748 &hauppauge_930C_HD_1113xx_si2165_config,
749 tuner_i2c 749 demod_i2c
750 ); 750 );
751 751
752 if (dev->dvb->frontend == NULL) { 752 if (dev->dvb->frontend == NULL) {
@@ -779,7 +779,7 @@ static int dvb_init(struct cx231xx *dev)
779 779
780 dev->dvb->frontend = dvb_attach(si2165_attach, 780 dev->dvb->frontend = dvb_attach(si2165_attach,
781 &pctv_quatro_stick_1114xx_si2165_config, 781 &pctv_quatro_stick_1114xx_si2165_config,
782 tuner_i2c 782 demod_i2c
783 ); 783 );
784 784
785 if (dev->dvb->frontend == NULL) { 785 if (dev->dvb->frontend == NULL) {
@@ -835,7 +835,7 @@ static int dvb_init(struct cx231xx *dev)
835 835
836 dev->dvb->frontend = dvb_attach(lgdt3306a_attach, 836 dev->dvb->frontend = dvb_attach(lgdt3306a_attach,
837 &hauppauge_955q_lgdt3306a_config, 837 &hauppauge_955q_lgdt3306a_config,
838 tuner_i2c 838 demod_i2c
839 ); 839 );
840 840
841 if (dev->dvb->frontend == NULL) { 841 if (dev->dvb->frontend == NULL) {
diff --git a/drivers/media/usb/cx231xx/cx231xx-vbi.c b/drivers/media/usb/cx231xx/cx231xx-vbi.c
index a08014d20a5c..15bb573b78ac 100644
--- a/drivers/media/usb/cx231xx/cx231xx-vbi.c
+++ b/drivers/media/usb/cx231xx/cx231xx-vbi.c
@@ -32,7 +32,7 @@
32 32
33#include <media/v4l2-common.h> 33#include <media/v4l2-common.h>
34#include <media/v4l2-ioctl.h> 34#include <media/v4l2-ioctl.h>
35#include <media/msp3400.h> 35#include <media/drv-intf/msp3400.h>
36#include <media/tuner.h> 36#include <media/tuner.h>
37 37
38#include "cx231xx-vbi.h" 38#include "cx231xx-vbi.h"
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
index d0d8f08e37c8..a70850fe6235 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -36,7 +36,7 @@
36#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
37#include <media/v4l2-ioctl.h> 37#include <media/v4l2-ioctl.h>
38#include <media/v4l2-event.h> 38#include <media/v4l2-event.h>
39#include <media/msp3400.h> 39#include <media/drv-intf/msp3400.h>
40#include <media/tuner.h> 40#include <media/tuner.h>
41 41
42#include "dvb_frontend.h" 42#include "dvb_frontend.h"
@@ -1444,6 +1444,7 @@ static int vidioc_cropcap(struct file *file, void *priv,
1444{ 1444{
1445 struct cx231xx_fh *fh = priv; 1445 struct cx231xx_fh *fh = priv;
1446 struct cx231xx *dev = fh->dev; 1446 struct cx231xx *dev = fh->dev;
1447 bool is_50hz = dev->norm & V4L2_STD_625_50;
1447 1448
1448 if (cc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1449 if (cc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1449 return -EINVAL; 1450 return -EINVAL;
@@ -1453,8 +1454,8 @@ static int vidioc_cropcap(struct file *file, void *priv,
1453 cc->bounds.width = dev->width; 1454 cc->bounds.width = dev->width;
1454 cc->bounds.height = dev->height; 1455 cc->bounds.height = dev->height;
1455 cc->defrect = cc->bounds; 1456 cc->defrect = cc->bounds;
1456 cc->pixelaspect.numerator = 54; /* 4:3 FIXME: remove magic numbers */ 1457 cc->pixelaspect.numerator = is_50hz ? 54 : 11;
1457 cc->pixelaspect.denominator = 59; 1458 cc->pixelaspect.denominator = is_50hz ? 59 : 10;
1458 1459
1459 return 0; 1460 return 0;
1460} 1461}
diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
index 54790fbe8fdc..ec6d3f5bc36d 100644
--- a/drivers/media/usb/cx231xx/cx231xx.h
+++ b/drivers/media/usb/cx231xx/cx231xx.h
@@ -30,14 +30,14 @@
30#include <linux/mutex.h> 30#include <linux/mutex.h>
31#include <linux/usb.h> 31#include <linux/usb.h>
32 32
33#include <media/cx2341x.h> 33#include <media/drv-intf/cx2341x.h>
34 34
35#include <media/videobuf-vmalloc.h> 35#include <media/videobuf-vmalloc.h>
36#include <media/v4l2-device.h> 36#include <media/v4l2-device.h>
37#include <media/v4l2-ctrls.h> 37#include <media/v4l2-ctrls.h>
38#include <media/v4l2-fh.h> 38#include <media/v4l2-fh.h>
39#include <media/rc-core.h> 39#include <media/rc-core.h>
40#include <media/ir-kbd-i2c.h> 40#include <media/i2c/ir-kbd-i2c.h>
41#include <media/videobuf-dvb.h> 41#include <media/videobuf-dvb.h>
42 42
43#include "cx231xx-reg.h" 43#include "cx231xx-reg.h"
diff --git a/drivers/media/usb/dvb-usb-v2/Kconfig b/drivers/media/usb/dvb-usb-v2/Kconfig
index 9facc92c8dea..3dc8ef004f8b 100644
--- a/drivers/media/usb/dvb-usb-v2/Kconfig
+++ b/drivers/media/usb/dvb-usb-v2/Kconfig
@@ -9,7 +9,7 @@ config DVB_USB_V2
9 <file:Documentation/dvb/README.dvb-usb>. 9 <file:Documentation/dvb/README.dvb-usb>.
10 10
11 For a complete list of supported USB devices see the LinuxTV DVB Wiki: 11 For a complete list of supported USB devices see the LinuxTV DVB Wiki:
12 <http://www.linuxtv.org/wiki/index.php/DVB_USB> 12 <https://linuxtv.org/wiki/index.php/DVB_USB>
13 13
14 Say Y if you own a USB DVB device. 14 Say Y if you own a USB DVB device.
15 15
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c b/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c
index ea3753653368..84f6de6fa07d 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c
@@ -35,7 +35,7 @@ MODULE_PARM_DESC(debug, "set debugging level (1=info (or-able)).");
35struct mxl111sf_demod_state { 35struct mxl111sf_demod_state {
36 struct mxl111sf_state *mxl_state; 36 struct mxl111sf_state *mxl_state;
37 37
38 struct mxl111sf_demod_config *cfg; 38 const struct mxl111sf_demod_config *cfg;
39 39
40 struct dvb_frontend fe; 40 struct dvb_frontend fe;
41}; 41};
@@ -579,7 +579,7 @@ static struct dvb_frontend_ops mxl111sf_demod_ops = {
579}; 579};
580 580
581struct dvb_frontend *mxl111sf_demod_attach(struct mxl111sf_state *mxl_state, 581struct dvb_frontend *mxl111sf_demod_attach(struct mxl111sf_state *mxl_state,
582 struct mxl111sf_demod_config *cfg) 582 const struct mxl111sf_demod_config *cfg)
583{ 583{
584 struct mxl111sf_demod_state *state = NULL; 584 struct mxl111sf_demod_state *state = NULL;
585 585
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.h b/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.h
index 0bd83e52669c..7065aca81252 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.h
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.h
@@ -35,11 +35,11 @@ struct mxl111sf_demod_config {
35#if IS_ENABLED(CONFIG_DVB_USB_MXL111SF) 35#if IS_ENABLED(CONFIG_DVB_USB_MXL111SF)
36extern 36extern
37struct dvb_frontend *mxl111sf_demod_attach(struct mxl111sf_state *mxl_state, 37struct dvb_frontend *mxl111sf_demod_attach(struct mxl111sf_state *mxl_state,
38 struct mxl111sf_demod_config *cfg); 38 const struct mxl111sf_demod_config *cfg);
39#else 39#else
40static inline 40static inline
41struct dvb_frontend *mxl111sf_demod_attach(struct mxl111sf_state *mxl_state, 41struct dvb_frontend *mxl111sf_demod_attach(struct mxl111sf_state *mxl_state,
42 struct mxl111sf_demod_config *cfg) 42 const struct mxl111sf_demod_config *cfg)
43{ 43{
44 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 44 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
45 return NULL; 45 return NULL;
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf.c b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
index bec12b0e076b..1710f9038d75 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
@@ -288,9 +288,9 @@ static int mxl111sf_adap_fe_init(struct dvb_frontend *fe)
288 err = mxl1x1sf_set_device_mode(state, adap_state->device_mode); 288 err = mxl1x1sf_set_device_mode(state, adap_state->device_mode);
289 289
290 mxl_fail(err); 290 mxl_fail(err);
291 mxl111sf_enable_usb_output(state); 291 err = mxl111sf_enable_usb_output(state);
292 mxl_fail(err); 292 mxl_fail(err);
293 mxl1x1sf_top_master_ctrl(state, 1); 293 err = mxl1x1sf_top_master_ctrl(state, 1);
294 mxl_fail(err); 294 mxl_fail(err);
295 295
296 if ((MXL111SF_GPIO_MOD_DVBT != adap_state->gpio_mode) && 296 if ((MXL111SF_GPIO_MOD_DVBT != adap_state->gpio_mode) &&
@@ -731,7 +731,7 @@ fail:
731 return ret; 731 return ret;
732} 732}
733 733
734static struct mxl111sf_demod_config mxl_demod_config = { 734static const struct mxl111sf_demod_config mxl_demod_config = {
735 .read_reg = mxl111sf_read_reg, 735 .read_reg = mxl111sf_read_reg,
736 .write_reg = mxl111sf_write_reg, 736 .write_reg = mxl111sf_write_reg,
737 .program_regs = mxl111sf_ctrl_program_regs, 737 .program_regs = mxl111sf_ctrl_program_regs,
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index 5a503a6bb8c5..eb5787a3191e 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -181,11 +181,17 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
181 goto err_mutex_unlock; 181 goto err_mutex_unlock;
182 } else if (msg[0].addr == 0x10) { 182 } else if (msg[0].addr == 0x10) {
183 /* method 1 - integrated demod */ 183 /* method 1 - integrated demod */
184 req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1); 184 if (msg[0].buf[0] == 0x00) {
185 req.index = CMD_DEMOD_RD | dev->page; 185 /* return demod page from driver cache */
186 req.size = msg[1].len; 186 msg[1].buf[0] = dev->page;
187 req.data = &msg[1].buf[0]; 187 ret = 0;
188 ret = rtl28xxu_ctrl_msg(d, &req); 188 } else {
189 req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1);
190 req.index = CMD_DEMOD_RD | dev->page;
191 req.size = msg[1].len;
192 req.data = &msg[1].buf[0];
193 ret = rtl28xxu_ctrl_msg(d, &req);
194 }
189 } else if (msg[0].len < 2) { 195 } else if (msg[0].len < 2) {
190 /* method 2 - old I2C */ 196 /* method 2 - old I2C */
191 req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1); 197 req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1);
diff --git a/drivers/media/usb/dvb-usb/Kconfig b/drivers/media/usb/dvb-usb/Kconfig
index 128eee61570d..f03b0b70c901 100644
--- a/drivers/media/usb/dvb-usb/Kconfig
+++ b/drivers/media/usb/dvb-usb/Kconfig
@@ -9,7 +9,7 @@ config DVB_USB
9 <file:Documentation/dvb/README.dvb-usb>. 9 <file:Documentation/dvb/README.dvb-usb>.
10 10
11 For a complete list of supported USB devices see the LinuxTV DVB Wiki: 11 For a complete list of supported USB devices see the LinuxTV DVB Wiki:
12 <http://www.linuxtv.org/wiki/index.php/DVB_USB> 12 <https://linuxtv.org/wiki/index.php/DVB_USB>
13 13
14 Say Y if you own a USB DVB device. 14 Say Y if you own a USB DVB device.
15 15
diff --git a/drivers/media/usb/em28xx/em28xx-camera.c b/drivers/media/usb/em28xx/em28xx-camera.c
index ed0b3a87983e..b58acd3fcd99 100644
--- a/drivers/media/usb/em28xx/em28xx-camera.c
+++ b/drivers/media/usb/em28xx/em28xx-camera.c
@@ -21,7 +21,7 @@
21 21
22#include <linux/i2c.h> 22#include <linux/i2c.h>
23#include <media/soc_camera.h> 23#include <media/soc_camera.h>
24#include <media/mt9v011.h> 24#include <media/i2c/mt9v011.h>
25#include <media/v4l2-clk.h> 25#include <media/v4l2-clk.h>
26#include <media/v4l2-common.h> 26#include <media/v4l2-common.h>
27 27
@@ -322,7 +322,7 @@ int em28xx_detect_sensor(struct em28xx *dev)
322 322
323int em28xx_init_camera(struct em28xx *dev) 323int em28xx_init_camera(struct em28xx *dev)
324{ 324{
325 char clk_name[V4L2_SUBDEV_NAME_SIZE]; 325 char clk_name[V4L2_CLK_NAME_SIZE];
326 struct i2c_client *client = &dev->i2c_client[dev->def_i2c_bus]; 326 struct i2c_client *client = &dev->i2c_client[dev->def_i2c_bus];
327 struct i2c_adapter *adap = &dev->i2c_adap[dev->def_i2c_bus]; 327 struct i2c_adapter *adap = &dev->i2c_adap[dev->def_i2c_bus];
328 struct em28xx_v4l2 *v4l2 = dev->v4l2; 328 struct em28xx_v4l2 *v4l2 = dev->v4l2;
diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c
index 394004607059..a1b6ef5894a6 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -30,10 +30,10 @@
30#include <linux/i2c.h> 30#include <linux/i2c.h>
31#include <linux/usb.h> 31#include <linux/usb.h>
32#include <media/tuner.h> 32#include <media/tuner.h>
33#include <media/msp3400.h> 33#include <media/drv-intf/msp3400.h>
34#include <media/saa7115.h> 34#include <media/i2c/saa7115.h>
35#include <media/tvp5150.h> 35#include <media/i2c/tvp5150.h>
36#include <media/tvaudio.h> 36#include <media/i2c/tvaudio.h>
37#include <media/i2c-addr.h> 37#include <media/i2c-addr.h>
38#include <media/tveeprom.h> 38#include <media/tveeprom.h>
39#include <media/v4l2-common.h> 39#include <media/v4l2-common.h>
@@ -1051,8 +1051,12 @@ struct em28xx_board em28xx_boards[] = {
1051 }, 1051 },
1052 [EM2870_BOARD_TERRATEC_XS_MT2060] = { 1052 [EM2870_BOARD_TERRATEC_XS_MT2060] = {
1053 .name = "Terratec Cinergy T XS (MT2060)", 1053 .name = "Terratec Cinergy T XS (MT2060)",
1054 .valid = EM28XX_BOARD_NOT_VALIDATED, 1054 .xclk = EM28XX_XCLK_IR_RC5_MODE |
1055 EM28XX_XCLK_FREQUENCY_12MHZ,
1056 .i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE,
1055 .tuner_type = TUNER_ABSENT, /* MT2060 */ 1057 .tuner_type = TUNER_ABSENT, /* MT2060 */
1058 .has_dvb = 1,
1059 .tuner_gpio = default_tuner_gpio,
1056 }, 1060 },
1057 [EM2870_BOARD_KWORLD_350U] = { 1061 [EM2870_BOARD_KWORLD_350U] = {
1058 .name = "Kworld 350 U DVB-T", 1062 .name = "Kworld 350 U DVB-T",
@@ -2368,7 +2372,7 @@ struct usb_device_id em28xx_id_table[] = {
2368 { USB_DEVICE(0x0ccd, 0x0042), 2372 { USB_DEVICE(0x0ccd, 0x0042),
2369 .driver_info = EM2882_BOARD_TERRATEC_HYBRID_XS }, 2373 .driver_info = EM2882_BOARD_TERRATEC_HYBRID_XS },
2370 { USB_DEVICE(0x0ccd, 0x0043), 2374 { USB_DEVICE(0x0ccd, 0x0043),
2371 .driver_info = EM2870_BOARD_TERRATEC_XS }, 2375 .driver_info = EM2870_BOARD_TERRATEC_XS_MT2060 },
2372 { USB_DEVICE(0x0ccd, 0x008e), /* Cinergy HTC USB XS Rev. 1 */ 2376 { USB_DEVICE(0x0ccd, 0x008e), /* Cinergy HTC USB XS Rev. 1 */
2373 .driver_info = EM2884_BOARD_TERRATEC_HTC_USB_XS }, 2377 .driver_info = EM2884_BOARD_TERRATEC_HTC_USB_XS },
2374 { USB_DEVICE(0x0ccd, 0x00ac), /* Cinergy HTC USB XS Rev. 2 */ 2378 { USB_DEVICE(0x0ccd, 0x00ac), /* Cinergy HTC USB XS Rev. 2 */
@@ -2471,6 +2475,8 @@ struct usb_device_id em28xx_id_table[] = {
2471 .driver_info = EM28178_BOARD_PCTV_461E }, 2475 .driver_info = EM28178_BOARD_PCTV_461E },
2472 { USB_DEVICE(0x2013, 0x025f), 2476 { USB_DEVICE(0x2013, 0x025f),
2473 .driver_info = EM28178_BOARD_PCTV_292E }, 2477 .driver_info = EM28178_BOARD_PCTV_292E },
2478 { USB_DEVICE(0x2040, 0x0264), /* Hauppauge WinTV-soloHD */
2479 .driver_info = EM28178_BOARD_PCTV_292E },
2474 { USB_DEVICE(0x0413, 0x6f07), 2480 { USB_DEVICE(0x0413, 0x6f07),
2475 .driver_info = EM2861_BOARD_LEADTEK_VC100 }, 2481 .driver_info = EM2861_BOARD_LEADTEK_VC100 },
2476 { USB_DEVICE(0xeb1a, 0x8179), 2482 { USB_DEVICE(0xeb1a, 0x8179),
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
index 357be76c7a55..bf5c24467c65 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -38,6 +38,7 @@
38#include "lgdt3305.h" 38#include "lgdt3305.h"
39#include "zl10353.h" 39#include "zl10353.h"
40#include "s5h1409.h" 40#include "s5h1409.h"
41#include "mt2060.h"
41#include "mt352.h" 42#include "mt352.h"
42#include "mt352_priv.h" /* FIXME */ 43#include "mt352_priv.h" /* FIXME */
43#include "tda1002x.h" 44#include "tda1002x.h"
@@ -815,6 +816,10 @@ static struct zl10353_config em28xx_zl10353_no_i2c_gate_dev = {
815 .parallel_ts = 1, 816 .parallel_ts = 1,
816}; 817};
817 818
819static struct mt2060_config em28xx_mt2060_config = {
820 .i2c_address = 0x60,
821};
822
818static struct qt1010_config em28xx_qt1010_config = { 823static struct qt1010_config em28xx_qt1010_config = {
819 .i2c_address = 0x62 824 .i2c_address = 0x62
820}; 825};
@@ -1142,6 +1147,16 @@ static int em28xx_dvb_init(struct em28xx *dev)
1142 goto out_free; 1147 goto out_free;
1143 } 1148 }
1144 break; 1149 break;
1150 case EM2870_BOARD_TERRATEC_XS_MT2060:
1151 dvb->fe[0] = dvb_attach(zl10353_attach,
1152 &em28xx_zl10353_no_i2c_gate_dev,
1153 &dev->i2c_adap[dev->def_i2c_bus]);
1154 if (dvb->fe[0] != NULL) {
1155 dvb_attach(mt2060_attach, dvb->fe[0],
1156 &dev->i2c_adap[dev->def_i2c_bus],
1157 &em28xx_mt2060_config, 1220);
1158 }
1159 break;
1145 case EM2870_BOARD_KWORLD_355U: 1160 case EM2870_BOARD_KWORLD_355U:
1146 dvb->fe[0] = dvb_attach(zl10353_attach, 1161 dvb->fe[0] = dvb_attach(zl10353_attach,
1147 &em28xx_zl10353_no_i2c_gate_dev, 1162 &em28xx_zl10353_no_i2c_gate_dev,
diff --git a/drivers/media/usb/em28xx/em28xx-vbi.c b/drivers/media/usb/em28xx/em28xx-vbi.c
index e23c285b3108..fe94c9225dd7 100644
--- a/drivers/media/usb/em28xx/em28xx-vbi.c
+++ b/drivers/media/usb/em28xx/em28xx-vbi.c
@@ -31,26 +31,22 @@
31 31
32/* ------------------------------------------------------------------ */ 32/* ------------------------------------------------------------------ */
33 33
34static int vbi_queue_setup(struct vb2_queue *vq, const void *parg, 34static int vbi_queue_setup(struct vb2_queue *vq,
35 unsigned int *nbuffers, unsigned int *nplanes, 35 unsigned int *nbuffers, unsigned int *nplanes,
36 unsigned int sizes[], void *alloc_ctxs[]) 36 unsigned int sizes[], void *alloc_ctxs[])
37{ 37{
38 const struct v4l2_format *fmt = parg;
39 struct em28xx *dev = vb2_get_drv_priv(vq); 38 struct em28xx *dev = vb2_get_drv_priv(vq);
40 struct em28xx_v4l2 *v4l2 = dev->v4l2; 39 struct em28xx_v4l2 *v4l2 = dev->v4l2;
41 unsigned long size; 40 unsigned long size = v4l2->vbi_width * v4l2->vbi_height * 2;
42 41
43 if (fmt)
44 size = fmt->fmt.pix.sizeimage;
45 else
46 size = v4l2->vbi_width * v4l2->vbi_height * 2;
47
48 if (0 == *nbuffers)
49 *nbuffers = 32;
50 if (*nbuffers < 2) 42 if (*nbuffers < 2)
51 *nbuffers = 2; 43 *nbuffers = 2;
52 if (*nbuffers > 32) 44
53 *nbuffers = 32; 45 if (*nplanes) {
46 if (sizes[0] < size)
47 return -EINVAL;
48 size = sizes[0];
49 }
54 50
55 *nplanes = 1; 51 *nplanes = 1;
56 sizes[0] = size; 52 sizes[0] = size;
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index 6a3cf342e087..0e86ff423c49 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -43,7 +43,7 @@
43#include <media/v4l2-ioctl.h> 43#include <media/v4l2-ioctl.h>
44#include <media/v4l2-event.h> 44#include <media/v4l2-event.h>
45#include <media/v4l2-clk.h> 45#include <media/v4l2-clk.h>
46#include <media/msp3400.h> 46#include <media/drv-intf/msp3400.h>
47#include <media/tuner.h> 47#include <media/tuner.h>
48 48
49#define DRIVER_AUTHOR "Ludovico Cavedon <cavedon@sssup.it>, " \ 49#define DRIVER_AUTHOR "Ludovico Cavedon <cavedon@sssup.it>, " \
@@ -438,7 +438,7 @@ static inline void finish_buffer(struct em28xx *dev,
438 buf->vb.field = V4L2_FIELD_NONE; 438 buf->vb.field = V4L2_FIELD_NONE;
439 else 439 else
440 buf->vb.field = V4L2_FIELD_INTERLACED; 440 buf->vb.field = V4L2_FIELD_INTERLACED;
441 v4l2_get_timestamp(&buf->vb.timestamp); 441 buf->vb.vb2_buf.timestamp = ktime_get_ns();
442 442
443 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); 443 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
444} 444}
@@ -871,30 +871,19 @@ static void res_free(struct em28xx *dev, enum v4l2_buf_type f_type)
871 Videobuf2 operations 871 Videobuf2 operations
872 ------------------------------------------------------------------*/ 872 ------------------------------------------------------------------*/
873 873
874static int queue_setup(struct vb2_queue *vq, const void *parg, 874static int queue_setup(struct vb2_queue *vq,
875 unsigned int *nbuffers, unsigned int *nplanes, 875 unsigned int *nbuffers, unsigned int *nplanes,
876 unsigned int sizes[], void *alloc_ctxs[]) 876 unsigned int sizes[], void *alloc_ctxs[])
877{ 877{
878 const struct v4l2_format *fmt = parg;
879 struct em28xx *dev = vb2_get_drv_priv(vq); 878 struct em28xx *dev = vb2_get_drv_priv(vq);
880 struct em28xx_v4l2 *v4l2 = dev->v4l2; 879 struct em28xx_v4l2 *v4l2 = dev->v4l2;
881 unsigned long size; 880 unsigned long size =
882
883 if (fmt)
884 size = fmt->fmt.pix.sizeimage;
885 else
886 size =
887 (v4l2->width * v4l2->height * v4l2->format->depth + 7) >> 3; 881 (v4l2->width * v4l2->height * v4l2->format->depth + 7) >> 3;
888 882
889 if (size == 0) 883 if (*nplanes)
890 return -EINVAL; 884 return sizes[0] < size ? -EINVAL : 0;
891
892 if (0 == *nbuffers)
893 *nbuffers = 32;
894
895 *nplanes = 1; 885 *nplanes = 1;
896 sizes[0] = size; 886 sizes[0] = size;
897
898 return 0; 887 return 0;
899} 888}
900 889
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h
index 76bf8ba372b3..8ff066c977d9 100644
--- a/drivers/media/usb/em28xx/em28xx.h
+++ b/drivers/media/usb/em28xx/em28xx.h
@@ -40,7 +40,7 @@
40#include <media/v4l2-device.h> 40#include <media/v4l2-device.h>
41#include <media/v4l2-ctrls.h> 41#include <media/v4l2-ctrls.h>
42#include <media/v4l2-fh.h> 42#include <media/v4l2-fh.h>
43#include <media/ir-kbd-i2c.h> 43#include <media/i2c/ir-kbd-i2c.h>
44#include <media/rc-core.h> 44#include <media/rc-core.h>
45#include "tuner-xc2028.h" 45#include "tuner-xc2028.h"
46#include "xc5000.h" 46#include "xc5000.h"
diff --git a/drivers/media/usb/go7007/go7007-driver.c b/drivers/media/usb/go7007/go7007-driver.c
index ae1cfa792c58..05b1126f263e 100644
--- a/drivers/media/usb/go7007/go7007-driver.c
+++ b/drivers/media/usb/go7007/go7007-driver.c
@@ -466,7 +466,7 @@ static struct go7007_buffer *frame_boundary(struct go7007 *go, struct go7007_buf
466 else 466 else
467 go7007_set_motion_regions(go, vb, 0); 467 go7007_set_motion_regions(go, vb, 0);
468 468
469 v4l2_get_timestamp(&vb->vb.timestamp); 469 vb->vb.vb2_buf.timestamp = ktime_get_ns();
470 vb_tmp = vb; 470 vb_tmp = vb;
471 spin_lock(&go->spinlock); 471 spin_lock(&go->spinlock);
472 list_del(&vb->list); 472 list_del(&vb->list);
diff --git a/drivers/media/usb/go7007/go7007-usb.c b/drivers/media/usb/go7007/go7007-usb.c
index 4857c467e76c..3dbf14c85c5c 100644
--- a/drivers/media/usb/go7007/go7007-usb.c
+++ b/drivers/media/usb/go7007/go7007-usb.c
@@ -23,9 +23,9 @@
23#include <linux/usb.h> 23#include <linux/usb.h>
24#include <linux/i2c.h> 24#include <linux/i2c.h>
25#include <asm/byteorder.h> 25#include <asm/byteorder.h>
26#include <media/saa7115.h> 26#include <media/i2c/saa7115.h>
27#include <media/tuner.h> 27#include <media/tuner.h>
28#include <media/uda1342.h> 28#include <media/i2c/uda1342.h>
29 29
30#include "go7007-priv.h" 30#include "go7007-priv.h"
31 31
@@ -1289,7 +1289,7 @@ static int go7007_usb_probe(struct usb_interface *intf,
1289 1289
1290 /* Allocate the URBs and buffers for receiving the audio stream */ 1290 /* Allocate the URBs and buffers for receiving the audio stream */
1291 if ((board->flags & GO7007_USB_EZUSB) && 1291 if ((board->flags & GO7007_USB_EZUSB) &&
1292 (board->flags & GO7007_BOARD_HAS_AUDIO)) { 1292 (board->main_info.flags & GO7007_BOARD_HAS_AUDIO)) {
1293 for (i = 0; i < 8; ++i) { 1293 for (i = 0; i < 8; ++i) {
1294 usb->audio_urbs[i] = usb_alloc_urb(0, GFP_KERNEL); 1294 usb->audio_urbs[i] = usb_alloc_urb(0, GFP_KERNEL);
1295 if (usb->audio_urbs[i] == NULL) 1295 if (usb->audio_urbs[i] == NULL)
diff --git a/drivers/media/usb/go7007/go7007-v4l2.c b/drivers/media/usb/go7007/go7007-v4l2.c
index f3d187db9368..358c1c186d03 100644
--- a/drivers/media/usb/go7007/go7007-v4l2.c
+++ b/drivers/media/usb/go7007/go7007-v4l2.c
@@ -30,7 +30,7 @@
30#include <media/v4l2-subdev.h> 30#include <media/v4l2-subdev.h>
31#include <media/v4l2-event.h> 31#include <media/v4l2-event.h>
32#include <media/videobuf2-vmalloc.h> 32#include <media/videobuf2-vmalloc.h>
33#include <media/saa7115.h> 33#include <media/i2c/saa7115.h>
34 34
35#include "go7007-priv.h" 35#include "go7007-priv.h"
36 36
@@ -369,7 +369,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
369} 369}
370 370
371static int go7007_queue_setup(struct vb2_queue *q, 371static int go7007_queue_setup(struct vb2_queue *q,
372 const void *parg,
373 unsigned int *num_buffers, unsigned int *num_planes, 372 unsigned int *num_buffers, unsigned int *num_planes,
374 unsigned int sizes[], void *alloc_ctxs[]) 373 unsigned int sizes[], void *alloc_ctxs[])
375{ 374{
diff --git a/drivers/media/usb/gspca/ov534.c b/drivers/media/usb/gspca/ov534.c
index 146071b8e116..bfff1d1c70ab 100644
--- a/drivers/media/usb/gspca/ov534.c
+++ b/drivers/media/usb/gspca/ov534.c
@@ -1491,8 +1491,13 @@ static void sd_set_streamparm(struct gspca_dev *gspca_dev,
1491 struct v4l2_fract *tpf = &cp->timeperframe; 1491 struct v4l2_fract *tpf = &cp->timeperframe;
1492 struct sd *sd = (struct sd *) gspca_dev; 1492 struct sd *sd = (struct sd *) gspca_dev;
1493 1493
1494 /* Set requested framerate */ 1494 if (tpf->numerator == 0 || tpf->denominator == 0)
1495 sd->frame_rate = tpf->denominator / tpf->numerator; 1495 /* Set default framerate */
1496 sd->frame_rate = 30;
1497 else
1498 /* Set requested framerate */
1499 sd->frame_rate = tpf->denominator / tpf->numerator;
1500
1496 if (gspca_dev->streaming) 1501 if (gspca_dev->streaming)
1497 set_frame_rate(gspca_dev); 1502 set_frame_rate(gspca_dev);
1498 1503
diff --git a/drivers/media/usb/gspca/topro.c b/drivers/media/usb/gspca/topro.c
index c70ff406b07a..c028a5c2438e 100644
--- a/drivers/media/usb/gspca/topro.c
+++ b/drivers/media/usb/gspca/topro.c
@@ -4802,7 +4802,11 @@ static void sd_set_streamparm(struct gspca_dev *gspca_dev,
4802 struct v4l2_fract *tpf = &cp->timeperframe; 4802 struct v4l2_fract *tpf = &cp->timeperframe;
4803 int fr, i; 4803 int fr, i;
4804 4804
4805 sd->framerate = tpf->denominator / tpf->numerator; 4805 if (tpf->numerator == 0 || tpf->denominator == 0)
4806 sd->framerate = 30;
4807 else
4808 sd->framerate = tpf->denominator / tpf->numerator;
4809
4806 if (gspca_dev->streaming) 4810 if (gspca_dev->streaming)
4807 setframerate(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure)); 4811 setframerate(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure));
4808 4812
diff --git a/drivers/media/usb/hackrf/hackrf.c b/drivers/media/usb/hackrf/hackrf.c
index 0fe5cb2c260c..9e700caf0d66 100644
--- a/drivers/media/usb/hackrf/hackrf.c
+++ b/drivers/media/usb/hackrf/hackrf.c
@@ -526,7 +526,7 @@ static void hackrf_urb_complete_in(struct urb *urb)
526 urb->transfer_buffer, len); 526 urb->transfer_buffer, len);
527 vb2_set_plane_payload(&buffer->vb.vb2_buf, 0, len); 527 vb2_set_plane_payload(&buffer->vb.vb2_buf, 0, len);
528 buffer->vb.sequence = dev->sequence++; 528 buffer->vb.sequence = dev->sequence++;
529 v4l2_get_timestamp(&buffer->vb.timestamp); 529 buffer->vb.vb2_buf.timestamp = ktime_get_ns();
530 vb2_buffer_done(&buffer->vb.vb2_buf, VB2_BUF_STATE_DONE); 530 vb2_buffer_done(&buffer->vb.vb2_buf, VB2_BUF_STATE_DONE);
531exit_usb_submit_urb: 531exit_usb_submit_urb:
532 usb_submit_urb(urb, GFP_ATOMIC); 532 usb_submit_urb(urb, GFP_ATOMIC);
@@ -571,7 +571,7 @@ static void hackrf_urb_complete_out(struct urb *urb)
571 vb2_plane_vaddr(&buffer->vb.vb2_buf, 0), len); 571 vb2_plane_vaddr(&buffer->vb.vb2_buf, 0), len);
572 urb->actual_length = len; 572 urb->actual_length = len;
573 buffer->vb.sequence = dev->sequence++; 573 buffer->vb.sequence = dev->sequence++;
574 v4l2_get_timestamp(&buffer->vb.timestamp); 574 buffer->vb.vb2_buf.timestamp = ktime_get_ns();
575 vb2_buffer_done(&buffer->vb.vb2_buf, VB2_BUF_STATE_DONE); 575 vb2_buffer_done(&buffer->vb.vb2_buf, VB2_BUF_STATE_DONE);
576exit_usb_submit_urb: 576exit_usb_submit_urb:
577 usb_submit_urb(urb, GFP_ATOMIC); 577 usb_submit_urb(urb, GFP_ATOMIC);
@@ -759,7 +759,7 @@ static void hackrf_return_all_buffers(struct vb2_queue *vq,
759} 759}
760 760
761static int hackrf_queue_setup(struct vb2_queue *vq, 761static int hackrf_queue_setup(struct vb2_queue *vq,
762 const void *parg, unsigned int *nbuffers, 762 unsigned int *nbuffers,
763 unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) 763 unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[])
764{ 764{
765 struct hackrf_dev *dev = vb2_get_drv_priv(vq); 765 struct hackrf_dev *dev = vb2_get_drv_priv(vq);
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
index d8d8c0f519fc..7dee22deebf3 100644
--- a/drivers/media/usb/hdpvr/hdpvr-video.c
+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
@@ -642,7 +642,7 @@ static int vidioc_s_dv_timings(struct file *file, void *_fh,
642 if (dev->status != STATUS_IDLE) 642 if (dev->status != STATUS_IDLE)
643 return -EBUSY; 643 return -EBUSY;
644 for (i = 0; i < ARRAY_SIZE(hdpvr_dv_timings); i++) 644 for (i = 0; i < ARRAY_SIZE(hdpvr_dv_timings); i++)
645 if (v4l2_match_dv_timings(timings, hdpvr_dv_timings + i, 0)) 645 if (v4l2_match_dv_timings(timings, hdpvr_dv_timings + i, 0, false))
646 break; 646 break;
647 if (i == ARRAY_SIZE(hdpvr_dv_timings)) 647 if (i == ARRAY_SIZE(hdpvr_dv_timings))
648 return -EINVAL; 648 return -EINVAL;
diff --git a/drivers/media/usb/hdpvr/hdpvr.h b/drivers/media/usb/hdpvr/hdpvr.h
index a3194304182d..78e815441f95 100644
--- a/drivers/media/usb/hdpvr/hdpvr.h
+++ b/drivers/media/usb/hdpvr/hdpvr.h
@@ -17,7 +17,7 @@
17 17
18#include <media/v4l2-device.h> 18#include <media/v4l2-device.h>
19#include <media/v4l2-ctrls.h> 19#include <media/v4l2-ctrls.h>
20#include <media/ir-kbd-i2c.h> 20#include <media/i2c/ir-kbd-i2c.h>
21 21
22#define HDPVR_MAX 8 22#define HDPVR_MAX 8
23#define HDPVR_I2C_MAX_SIZE 128 23#define HDPVR_I2C_MAX_SIZE 128
diff --git a/drivers/media/usb/msi2500/msi2500.c b/drivers/media/usb/msi2500/msi2500.c
index e06a21a4fbd9..c104315fdc17 100644
--- a/drivers/media/usb/msi2500/msi2500.c
+++ b/drivers/media/usb/msi2500/msi2500.c
@@ -616,7 +616,6 @@ static int msi2500_querycap(struct file *file, void *fh,
616 616
617/* Videobuf2 operations */ 617/* Videobuf2 operations */
618static int msi2500_queue_setup(struct vb2_queue *vq, 618static int msi2500_queue_setup(struct vb2_queue *vq,
619 const void *parg,
620 unsigned int *nbuffers, 619 unsigned int *nbuffers,
621 unsigned int *nplanes, unsigned int sizes[], 620 unsigned int *nplanes, unsigned int sizes[],
622 void *alloc_ctxs[]) 621 void *alloc_ctxs[])
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-audio.c b/drivers/media/usb/pvrusb2/pvrusb2-audio.c
index 45276c628482..5f953d837bf1 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-audio.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-audio.c
@@ -23,7 +23,7 @@
23#include "pvrusb2-hdw-internal.h" 23#include "pvrusb2-hdw-internal.h"
24#include "pvrusb2-debug.h" 24#include "pvrusb2-debug.h"
25#include <linux/videodev2.h> 25#include <linux/videodev2.h>
26#include <media/msp3400.h> 26#include <media/drv-intf/msp3400.h>
27#include <media/v4l2-common.h> 27#include <media/v4l2-common.h>
28 28
29 29
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-cx2584x-v4l.c b/drivers/media/usb/pvrusb2/pvrusb2-cx2584x-v4l.c
index 1a81aa70509b..7d675fae1846 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-cx2584x-v4l.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-cx2584x-v4l.c
@@ -32,7 +32,7 @@
32 32
33#include "pvrusb2-hdw-internal.h" 33#include "pvrusb2-hdw-internal.h"
34#include "pvrusb2-debug.h" 34#include "pvrusb2-debug.h"
35#include <media/cx25840.h> 35#include <media/drv-intf/cx25840.h>
36#include <linux/videodev2.h> 36#include <linux/videodev2.h>
37#include <media/v4l2-common.h> 37#include <media/v4l2-common.h>
38#include <linux/errno.h> 38#include <linux/errno.h>
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/usb/pvrusb2/pvrusb2-hdw-internal.h
index 1f9c02801cee..60141b16d731 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw-internal.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw-internal.h
@@ -39,8 +39,8 @@
39#include "pvrusb2-hdw.h" 39#include "pvrusb2-hdw.h"
40#include "pvrusb2-io.h" 40#include "pvrusb2-io.h"
41#include <media/v4l2-device.h> 41#include <media/v4l2-device.h>
42#include <media/cx2341x.h> 42#include <media/drv-intf/cx2341x.h>
43#include <media/ir-kbd-i2c.h> 43#include <media/i2c/ir-kbd-i2c.h>
44#include "pvrusb2-devattr.h" 44#include "pvrusb2-devattr.h"
45 45
46/* Legal values for PVR2_CID_HSM */ 46/* Legal values for PVR2_CID_HSM */
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
index 4baa9d632a4e..14321d0a1833 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
@@ -20,7 +20,7 @@
20 20
21#include <linux/i2c.h> 21#include <linux/i2c.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <media/ir-kbd-i2c.h> 23#include <media/i2c/ir-kbd-i2c.h>
24#include "pvrusb2-i2c-core.h" 24#include "pvrusb2-i2c-core.h"
25#include "pvrusb2-hdw-internal.h" 25#include "pvrusb2-hdw-internal.h"
26#include "pvrusb2-debug.h" 26#include "pvrusb2-debug.h"
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
index 1c5f85bf7ed4..81f788b7b242 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
@@ -628,6 +628,7 @@ static int pvr2_g_ext_ctrls(struct file *file, void *priv,
628 struct pvr2_v4l2_fh *fh = file->private_data; 628 struct pvr2_v4l2_fh *fh = file->private_data;
629 struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; 629 struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
630 struct v4l2_ext_control *ctrl; 630 struct v4l2_ext_control *ctrl;
631 struct pvr2_ctrl *cptr;
631 unsigned int idx; 632 unsigned int idx;
632 int val; 633 int val;
633 int ret; 634 int ret;
@@ -635,8 +636,15 @@ static int pvr2_g_ext_ctrls(struct file *file, void *priv,
635 ret = 0; 636 ret = 0;
636 for (idx = 0; idx < ctls->count; idx++) { 637 for (idx = 0; idx < ctls->count; idx++) {
637 ctrl = ctls->controls + idx; 638 ctrl = ctls->controls + idx;
638 ret = pvr2_ctrl_get_value( 639 cptr = pvr2_hdw_get_ctrl_v4l(hdw, ctrl->id);
639 pvr2_hdw_get_ctrl_v4l(hdw, ctrl->id), &val); 640 if (cptr) {
641 if (ctls->which == V4L2_CTRL_WHICH_DEF_VAL)
642 pvr2_ctrl_get_def(cptr, &val);
643 else
644 ret = pvr2_ctrl_get_value(cptr, &val);
645 } else
646 ret = -EINVAL;
647
640 if (ret) { 648 if (ret) {
641 ctls->error_idx = idx; 649 ctls->error_idx = idx;
642 return ret; 650 return ret;
@@ -658,6 +666,10 @@ static int pvr2_s_ext_ctrls(struct file *file, void *priv,
658 unsigned int idx; 666 unsigned int idx;
659 int ret; 667 int ret;
660 668
669 /* Default value cannot be changed */
670 if (ctls->which == V4L2_CTRL_WHICH_DEF_VAL)
671 return -EINVAL;
672
661 ret = 0; 673 ret = 0;
662 for (idx = 0; idx < ctls->count; idx++) { 674 for (idx = 0; idx < ctls->count; idx++) {
663 ctrl = ctls->controls + idx; 675 ctrl = ctls->controls + idx;
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-video-v4l.c b/drivers/media/usb/pvrusb2/pvrusb2-video-v4l.c
index 139b39740534..105123ab36aa 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-video-v4l.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-video-v4l.c
@@ -35,7 +35,7 @@
35#include "pvrusb2-debug.h" 35#include "pvrusb2-debug.h"
36#include <linux/videodev2.h> 36#include <linux/videodev2.h>
37#include <media/v4l2-common.h> 37#include <media/v4l2-common.h>
38#include <media/saa7115.h> 38#include <media/i2c/saa7115.h>
39#include <linux/errno.h> 39#include <linux/errno.h>
40 40
41struct routing_scheme { 41struct routing_scheme {
diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c
index b79c36fd8cd2..086cf1c7bd7d 100644
--- a/drivers/media/usb/pwc/pwc-if.c
+++ b/drivers/media/usb/pwc/pwc-if.c
@@ -316,8 +316,7 @@ static void pwc_isoc_handler(struct urb *urb)
316 struct pwc_frame_buf *fbuf = pdev->fill_buf; 316 struct pwc_frame_buf *fbuf = pdev->fill_buf;
317 317
318 if (pdev->vsync == 1) { 318 if (pdev->vsync == 1) {
319 v4l2_get_timestamp( 319 fbuf->vb.vb2_buf.timestamp = ktime_get_ns();
320 &fbuf->vb.timestamp);
321 pdev->vsync = 2; 320 pdev->vsync = 2;
322 } 321 }
323 322
@@ -571,7 +570,7 @@ static void pwc_video_release(struct v4l2_device *v)
571/***************************************************************************/ 570/***************************************************************************/
572/* Videobuf2 operations */ 571/* Videobuf2 operations */
573 572
574static int queue_setup(struct vb2_queue *vq, const void *parg, 573static int queue_setup(struct vb2_queue *vq,
575 unsigned int *nbuffers, unsigned int *nplanes, 574 unsigned int *nbuffers, unsigned int *nplanes,
576 unsigned int sizes[], void *alloc_ctxs[]) 575 unsigned int sizes[], void *alloc_ctxs[])
577{ 576{
diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
index e7acb12ad21d..9acdaa3716fb 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -574,7 +574,7 @@ static void s2255_got_frame(struct s2255_vc *vc, int jpgsize)
574 buf = list_entry(vc->buf_list.next, 574 buf = list_entry(vc->buf_list.next,
575 struct s2255_buffer, list); 575 struct s2255_buffer, list);
576 list_del(&buf->list); 576 list_del(&buf->list);
577 v4l2_get_timestamp(&buf->vb.timestamp); 577 buf->vb.vb2_buf.timestamp = ktime_get_ns();
578 buf->vb.field = vc->field; 578 buf->vb.field = vc->field;
579 buf->vb.sequence = vc->frame_count; 579 buf->vb.sequence = vc->frame_count;
580 spin_unlock_irqrestore(&vc->qlock, flags); 580 spin_unlock_irqrestore(&vc->qlock, flags);
@@ -660,7 +660,7 @@ static void s2255_fillbuff(struct s2255_vc *vc,
660 Videobuf operations 660 Videobuf operations
661 ------------------------------------------------------------------*/ 661 ------------------------------------------------------------------*/
662 662
663static int queue_setup(struct vb2_queue *vq, const void *parg, 663static int queue_setup(struct vb2_queue *vq,
664 unsigned int *nbuffers, unsigned int *nplanes, 664 unsigned int *nbuffers, unsigned int *nplanes,
665 unsigned int sizes[], void *alloc_ctxs[]) 665 unsigned int sizes[], void *alloc_ctxs[])
666{ 666{
diff --git a/drivers/media/usb/stk1160/stk1160-core.c b/drivers/media/usb/stk1160/stk1160-core.c
index 1b6836f15370..bc029478065a 100644
--- a/drivers/media/usb/stk1160/stk1160-core.c
+++ b/drivers/media/usb/stk1160/stk1160-core.c
@@ -34,7 +34,7 @@
34#include <linux/usb.h> 34#include <linux/usb.h>
35#include <linux/mm.h> 35#include <linux/mm.h>
36#include <linux/vmalloc.h> 36#include <linux/vmalloc.h>
37#include <media/saa7115.h> 37#include <media/i2c/saa7115.h>
38 38
39#include "stk1160.h" 39#include "stk1160.h"
40#include "stk1160-reg.h" 40#include "stk1160-reg.h"
diff --git a/drivers/media/usb/stk1160/stk1160-v4l.c b/drivers/media/usb/stk1160/stk1160-v4l.c
index 0bd34f1e7fa9..77131fd614a5 100644
--- a/drivers/media/usb/stk1160/stk1160-v4l.c
+++ b/drivers/media/usb/stk1160/stk1160-v4l.c
@@ -33,7 +33,7 @@
33#include <media/v4l2-event.h> 33#include <media/v4l2-event.h>
34#include <media/videobuf2-vmalloc.h> 34#include <media/videobuf2-vmalloc.h>
35 35
36#include <media/saa7115.h> 36#include <media/i2c/saa7115.h>
37 37
38#include "stk1160.h" 38#include "stk1160.h"
39#include "stk1160-reg.h" 39#include "stk1160-reg.h"
@@ -664,7 +664,7 @@ static const struct v4l2_ioctl_ops stk1160_ioctl_ops = {
664/* 664/*
665 * Videobuf2 operations 665 * Videobuf2 operations
666 */ 666 */
667static int queue_setup(struct vb2_queue *vq, const void *parg, 667static int queue_setup(struct vb2_queue *vq,
668 unsigned int *nbuffers, unsigned int *nplanes, 668 unsigned int *nbuffers, unsigned int *nplanes,
669 unsigned int sizes[], void *alloc_ctxs[]) 669 unsigned int sizes[], void *alloc_ctxs[])
670{ 670{
diff --git a/drivers/media/usb/stk1160/stk1160-video.c b/drivers/media/usb/stk1160/stk1160-video.c
index 75654e676e80..46191d5262eb 100644
--- a/drivers/media/usb/stk1160/stk1160-video.c
+++ b/drivers/media/usb/stk1160/stk1160-video.c
@@ -99,7 +99,7 @@ void stk1160_buffer_done(struct stk1160 *dev)
99 buf->vb.sequence = dev->sequence++; 99 buf->vb.sequence = dev->sequence++;
100 buf->vb.field = V4L2_FIELD_INTERLACED; 100 buf->vb.field = V4L2_FIELD_INTERLACED;
101 buf->vb.vb2_buf.planes[0].bytesused = buf->bytesused; 101 buf->vb.vb2_buf.planes[0].bytesused = buf->bytesused;
102 v4l2_get_timestamp(&buf->vb.timestamp); 102 buf->vb.vb2_buf.timestamp = ktime_get_ns();
103 103
104 vb2_set_plane_payload(&buf->vb.vb2_buf, 0, buf->bytesused); 104 vb2_set_plane_payload(&buf->vb.vb2_buf, 0, buf->bytesused);
105 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); 105 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/usb/tm6000/tm6000-cards.c b/drivers/media/usb/tm6000/tm6000-cards.c
index 2e8c3afe4ec4..8902ee36bc94 100644
--- a/drivers/media/usb/tm6000/tm6000-cards.c
+++ b/drivers/media/usb/tm6000/tm6000-cards.c
@@ -26,7 +26,7 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <media/v4l2-common.h> 27#include <media/v4l2-common.h>
28#include <media/tuner.h> 28#include <media/tuner.h>
29#include <media/tvaudio.h> 29#include <media/i2c/tvaudio.h>
30#include <media/i2c-addr.h> 30#include <media/i2c-addr.h>
31#include <media/rc-map.h> 31#include <media/rc-map.h>
32 32
diff --git a/drivers/media/usb/ttusb-dec/ttusb_dec.c b/drivers/media/usb/ttusb-dec/ttusb_dec.c
index a5de46f04247..4e36e24cb3a6 100644
--- a/drivers/media/usb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/usb/ttusb-dec/ttusb_dec.c
@@ -1606,7 +1606,7 @@ static int fe_send_command(struct dvb_frontend* fe, const u8 command,
1606 return ttusb_dec_send_command(dec, command, param_length, params, result_length, cmd_result); 1606 return ttusb_dec_send_command(dec, command, param_length, params, result_length, cmd_result);
1607} 1607}
1608 1608
1609static struct ttusbdecfe_config fe_config = { 1609static const struct ttusbdecfe_config fe_config = {
1610 .send_command = fe_send_command 1610 .send_command = fe_send_command
1611}; 1611};
1612 1612
diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c
index e645c9df2d94..4ebb33943f9a 100644
--- a/drivers/media/usb/usbtv/usbtv-video.c
+++ b/drivers/media/usb/usbtv/usbtv-video.c
@@ -322,7 +322,7 @@ static void usbtv_image_chunk(struct usbtv *usbtv, __be32 *chunk)
322 322
323 buf->vb.field = V4L2_FIELD_INTERLACED; 323 buf->vb.field = V4L2_FIELD_INTERLACED;
324 buf->vb.sequence = usbtv->sequence++; 324 buf->vb.sequence = usbtv->sequence++;
325 v4l2_get_timestamp(&buf->vb.timestamp); 325 buf->vb.vb2_buf.timestamp = ktime_get_ns();
326 vb2_set_plane_payload(&buf->vb.vb2_buf, 0, size); 326 vb2_set_plane_payload(&buf->vb.vb2_buf, 0, size);
327 vb2_buffer_done(&buf->vb.vb2_buf, state); 327 vb2_buffer_done(&buf->vb.vb2_buf, state);
328 list_del(&buf->list); 328 list_del(&buf->list);
@@ -599,19 +599,18 @@ static struct v4l2_file_operations usbtv_fops = {
599}; 599};
600 600
601static int usbtv_queue_setup(struct vb2_queue *vq, 601static int usbtv_queue_setup(struct vb2_queue *vq,
602 const void *parg, unsigned int *nbuffers, 602 unsigned int *nbuffers,
603 unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) 603 unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[])
604{ 604{
605 const struct v4l2_format *fmt = parg;
606 struct usbtv *usbtv = vb2_get_drv_priv(vq); 605 struct usbtv *usbtv = vb2_get_drv_priv(vq);
607 unsigned size = USBTV_CHUNK * usbtv->n_chunks * 2 * sizeof(u32); 606 unsigned size = USBTV_CHUNK * usbtv->n_chunks * 2 * sizeof(u32);
608 607
609 if (vq->num_buffers + *nbuffers < 2) 608 if (vq->num_buffers + *nbuffers < 2)
610 *nbuffers = 2 - vq->num_buffers; 609 *nbuffers = 2 - vq->num_buffers;
610 if (*nplanes)
611 return sizes[0] < size ? -EINVAL : 0;
611 *nplanes = 1; 612 *nplanes = 1;
612 if (fmt && fmt->fmt.pix.sizeimage < size) 613 sizes[0] = size;
613 return -EINVAL;
614 sizes[0] = fmt ? fmt->fmt.pix.sizeimage : size;
615 614
616 return 0; 615 return 0;
617} 616}
diff --git a/drivers/media/usb/usbvision/usbvision-core.c b/drivers/media/usb/usbvision/usbvision-core.c
index dc3b4d5155c5..1ea04e75fb36 100644
--- a/drivers/media/usb/usbvision/usbvision-core.c
+++ b/drivers/media/usb/usbvision/usbvision-core.c
@@ -37,7 +37,7 @@
37#include <linux/videodev2.h> 37#include <linux/videodev2.h>
38#include <linux/i2c.h> 38#include <linux/i2c.h>
39 39
40#include <media/saa7115.h> 40#include <media/i2c/saa7115.h>
41#include <media/v4l2-common.h> 41#include <media/v4l2-common.h>
42#include <media/tuner.h> 42#include <media/tuner.h>
43 43
diff --git a/drivers/media/usb/usbvision/usbvision-video.c b/drivers/media/usb/usbvision/usbvision-video.c
index b693206f66dd..de9ff3bb8edd 100644
--- a/drivers/media/usb/usbvision/usbvision-video.c
+++ b/drivers/media/usb/usbvision/usbvision-video.c
@@ -59,7 +59,7 @@
59#include <linux/videodev2.h> 59#include <linux/videodev2.h>
60#include <linux/i2c.h> 60#include <linux/i2c.h>
61 61
62#include <media/saa7115.h> 62#include <media/i2c/saa7115.h>
63#include <media/v4l2-common.h> 63#include <media/v4l2-common.h>
64#include <media/v4l2-ioctl.h> 64#include <media/v4l2-ioctl.h>
65#include <media/v4l2-event.h> 65#include <media/v4l2-event.h>
@@ -1461,11 +1461,32 @@ static int usbvision_probe(struct usb_interface *intf,
1461 printk(KERN_INFO "%s: %s found\n", __func__, 1461 printk(KERN_INFO "%s: %s found\n", __func__,
1462 usbvision_device_data[model].model_string); 1462 usbvision_device_data[model].model_string);
1463 1463
1464 /*
1465 * this is a security check.
1466 * an exploit using an incorrect bInterfaceNumber is known
1467 */
1468 if (ifnum >= USB_MAXINTERFACES || !dev->actconfig->interface[ifnum])
1469 return -ENODEV;
1470
1464 if (usbvision_device_data[model].interface >= 0) 1471 if (usbvision_device_data[model].interface >= 0)
1465 interface = &dev->actconfig->interface[usbvision_device_data[model].interface]->altsetting[0]; 1472 interface = &dev->actconfig->interface[usbvision_device_data[model].interface]->altsetting[0];
1466 else 1473 else if (ifnum < dev->actconfig->desc.bNumInterfaces)
1467 interface = &dev->actconfig->interface[ifnum]->altsetting[0]; 1474 interface = &dev->actconfig->interface[ifnum]->altsetting[0];
1475 else {
1476 dev_err(&intf->dev, "interface %d is invalid, max is %d\n",
1477 ifnum, dev->actconfig->desc.bNumInterfaces - 1);
1478 ret = -ENODEV;
1479 goto err_usb;
1480 }
1481
1482 if (interface->desc.bNumEndpoints < 2) {
1483 dev_err(&intf->dev, "interface %d has %d endpoints, but must"
1484 " have minimum 2\n", ifnum, interface->desc.bNumEndpoints);
1485 ret = -ENODEV;
1486 goto err_usb;
1487 }
1468 endpoint = &interface->endpoint[1].desc; 1488 endpoint = &interface->endpoint[1].desc;
1489
1469 if (!usb_endpoint_xfer_isoc(endpoint)) { 1490 if (!usb_endpoint_xfer_isoc(endpoint)) {
1470 dev_err(&intf->dev, "%s: interface %d. has non-ISO endpoint!\n", 1491 dev_err(&intf->dev, "%s: interface %d. has non-ISO endpoint!\n",
1471 __func__, ifnum); 1492 __func__, ifnum);
diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index 3e59b288b8a8..c2ee6e39fd0c 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -227,7 +227,8 @@ static struct uvc_control_info uvc_ctrls[] = {
227 .size = 4, 227 .size = 4,
228 .flags = UVC_CTRL_FLAG_SET_CUR 228 .flags = UVC_CTRL_FLAG_SET_CUR
229 | UVC_CTRL_FLAG_GET_RANGE 229 | UVC_CTRL_FLAG_GET_RANGE
230 | UVC_CTRL_FLAG_RESTORE, 230 | UVC_CTRL_FLAG_RESTORE
231 | UVC_CTRL_FLAG_AUTO_UPDATE,
231 }, 232 },
232 { 233 {
233 .entity = UVC_GUID_UVC_CAMERA, 234 .entity = UVC_GUID_UVC_CAMERA,
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index d11fd6ac2df0..39abbafad796 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -2540,7 +2540,8 @@ static struct usb_device_id uvc_ids[] = {
2540 .bInterfaceProtocol = 0, 2540 .bInterfaceProtocol = 0,
2541 .driver_info = UVC_QUIRK_FORCE_Y8 }, 2541 .driver_info = UVC_QUIRK_FORCE_Y8 },
2542 /* Generic USB Video Class */ 2542 /* Generic USB Video Class */
2543 { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, 0) }, 2543 { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, UVC_PC_PROTOCOL_UNDEFINED) },
2544 { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, UVC_PC_PROTOCOL_15) },
2544 {} 2545 {}
2545}; 2546};
2546 2547
diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c
index cfb868a48b5f..54394722756f 100644
--- a/drivers/media/usb/uvc/uvc_queue.c
+++ b/drivers/media/usb/uvc/uvc_queue.c
@@ -69,23 +69,19 @@ static void uvc_queue_return_buffers(struct uvc_video_queue *queue,
69 * videobuf2 queue operations 69 * videobuf2 queue operations
70 */ 70 */
71 71
72static int uvc_queue_setup(struct vb2_queue *vq, const void *parg, 72static int uvc_queue_setup(struct vb2_queue *vq,
73 unsigned int *nbuffers, unsigned int *nplanes, 73 unsigned int *nbuffers, unsigned int *nplanes,
74 unsigned int sizes[], void *alloc_ctxs[]) 74 unsigned int sizes[], void *alloc_ctxs[])
75{ 75{
76 const struct v4l2_format *fmt = parg;
77 struct uvc_video_queue *queue = vb2_get_drv_priv(vq); 76 struct uvc_video_queue *queue = vb2_get_drv_priv(vq);
78 struct uvc_streaming *stream = uvc_queue_to_stream(queue); 77 struct uvc_streaming *stream = uvc_queue_to_stream(queue);
78 unsigned size = stream->ctrl.dwMaxVideoFrameSize;
79 79
80 /* Make sure the image size is large enough. */ 80 /* Make sure the image size is large enough. */
81 if (fmt && fmt->fmt.pix.sizeimage < stream->ctrl.dwMaxVideoFrameSize) 81 if (*nplanes)
82 return -EINVAL; 82 return sizes[0] < size ? -EINVAL : 0;
83
84 *nplanes = 1; 83 *nplanes = 1;
85 84 sizes[0] = size;
86 sizes[0] = fmt ? fmt->fmt.pix.sizeimage
87 : stream->ctrl.dwMaxVideoFrameSize;
88
89 return 0; 85 return 0;
90} 86}
91 87
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 2764f43607c1..d7723ce772b3 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -983,6 +983,22 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh,
983 unsigned int i; 983 unsigned int i;
984 int ret; 984 int ret;
985 985
986 if (ctrls->which == V4L2_CTRL_WHICH_DEF_VAL) {
987 for (i = 0; i < ctrls->count; ++ctrl, ++i) {
988 struct v4l2_queryctrl qc = { .id = ctrl->id };
989
990 ret = uvc_query_v4l2_ctrl(chain, &qc);
991 if (ret < 0) {
992 ctrls->error_idx = i;
993 return ret;
994 }
995
996 ctrl->value = qc.default_value;
997 }
998
999 return 0;
1000 }
1001
986 ret = uvc_ctrl_begin(chain); 1002 ret = uvc_ctrl_begin(chain);
987 if (ret < 0) 1003 if (ret < 0)
988 return ret; 1004 return ret;
@@ -1010,6 +1026,10 @@ static int uvc_ioctl_s_try_ext_ctrls(struct uvc_fh *handle,
1010 unsigned int i; 1026 unsigned int i;
1011 int ret; 1027 int ret;
1012 1028
1029 /* Default value cannot be changed */
1030 if (ctrls->which == V4L2_CTRL_WHICH_DEF_VAL)
1031 return -EINVAL;
1032
1013 ret = uvc_ctrl_begin(chain); 1033 ret = uvc_ctrl_begin(chain);
1014 if (ret < 0) 1034 if (ret < 0)
1015 return ret; 1035 return ret;
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 2b276ab7764f..075a0fe77485 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -694,22 +694,19 @@ void uvc_video_clock_update(struct uvc_streaming *stream,
694 ts.tv_nsec -= NSEC_PER_SEC; 694 ts.tv_nsec -= NSEC_PER_SEC;
695 } 695 }
696 696
697 uvc_trace(UVC_TRACE_CLOCK, "%s: SOF %u.%06llu y %llu ts %lu.%06lu " 697 uvc_trace(UVC_TRACE_CLOCK, "%s: SOF %u.%06llu y %llu ts %llu "
698 "buf ts %lu.%06lu (x1 %u/%u/%u x2 %u/%u/%u y1 %u y2 %u)\n", 698 "buf ts %llu (x1 %u/%u/%u x2 %u/%u/%u y1 %u y2 %u)\n",
699 stream->dev->name, 699 stream->dev->name,
700 sof >> 16, div_u64(((u64)sof & 0xffff) * 1000000LLU, 65536), 700 sof >> 16, div_u64(((u64)sof & 0xffff) * 1000000LLU, 65536),
701 y, ts.tv_sec, ts.tv_nsec / NSEC_PER_USEC, 701 y, timespec_to_ns(&ts), vbuf->vb2_buf.timestamp,
702 vbuf->timestamp.tv_sec,
703 (unsigned long)vbuf->timestamp.tv_usec,
704 x1, first->host_sof, first->dev_sof, 702 x1, first->host_sof, first->dev_sof,
705 x2, last->host_sof, last->dev_sof, y1, y2); 703 x2, last->host_sof, last->dev_sof, y1, y2);
706 704
707 /* Update the V4L2 buffer. */ 705 /* Update the V4L2 buffer. */
708 vbuf->timestamp.tv_sec = ts.tv_sec; 706 vbuf->vb2_buf.timestamp = timespec_to_ns(&ts);
709 vbuf->timestamp.tv_usec = ts.tv_nsec / NSEC_PER_USEC;
710 707
711done: 708done:
712 spin_unlock_irqrestore(&stream->clock.lock, flags); 709 spin_unlock_irqrestore(&clock->lock, flags);
713} 710}
714 711
715/* ------------------------------------------------------------------------ 712/* ------------------------------------------------------------------------
@@ -1034,9 +1031,7 @@ static int uvc_video_decode_start(struct uvc_streaming *stream,
1034 1031
1035 buf->buf.field = V4L2_FIELD_NONE; 1032 buf->buf.field = V4L2_FIELD_NONE;
1036 buf->buf.sequence = stream->sequence; 1033 buf->buf.sequence = stream->sequence;
1037 buf->buf.timestamp.tv_sec = ts.tv_sec; 1034 buf->buf.vb2_buf.timestamp = timespec_to_ns(&ts);
1038 buf->buf.timestamp.tv_usec =
1039 ts.tv_nsec / NSEC_PER_USEC;
1040 1035
1041 /* TODO: Handle PTS and SCR. */ 1036 /* TODO: Handle PTS and SCR. */
1042 buf->state = UVC_BUF_STATE_ACTIVE; 1037 buf->state = UVC_BUF_STATE_ACTIVE;
diff --git a/drivers/media/v4l2-core/v4l2-clk.c b/drivers/media/v4l2-core/v4l2-clk.c
index 34e416a554f6..297e10e69898 100644
--- a/drivers/media/v4l2-core/v4l2-clk.c
+++ b/drivers/media/v4l2-core/v4l2-clk.c
@@ -15,6 +15,7 @@
15#include <linux/list.h> 15#include <linux/list.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/mutex.h> 17#include <linux/mutex.h>
18#include <linux/of.h>
18#include <linux/slab.h> 19#include <linux/slab.h>
19#include <linux/string.h> 20#include <linux/string.h>
20 21
@@ -39,6 +40,7 @@ struct v4l2_clk *v4l2_clk_get(struct device *dev, const char *id)
39{ 40{
40 struct v4l2_clk *clk; 41 struct v4l2_clk *clk;
41 struct clk *ccf_clk = clk_get(dev, id); 42 struct clk *ccf_clk = clk_get(dev, id);
43 char clk_name[V4L2_CLK_NAME_SIZE];
42 44
43 if (PTR_ERR(ccf_clk) == -EPROBE_DEFER) 45 if (PTR_ERR(ccf_clk) == -EPROBE_DEFER)
44 return ERR_PTR(-EPROBE_DEFER); 46 return ERR_PTR(-EPROBE_DEFER);
@@ -57,6 +59,13 @@ struct v4l2_clk *v4l2_clk_get(struct device *dev, const char *id)
57 mutex_lock(&clk_lock); 59 mutex_lock(&clk_lock);
58 clk = v4l2_clk_find(dev_name(dev)); 60 clk = v4l2_clk_find(dev_name(dev));
59 61
62 /* if dev_name is not found, try use the OF name to find again */
63 if (PTR_ERR(clk) == -ENODEV && dev->of_node) {
64 v4l2_clk_name_of(clk_name, sizeof(clk_name),
65 of_node_full_name(dev->of_node));
66 clk = v4l2_clk_find(clk_name);
67 }
68
60 if (!IS_ERR(clk)) 69 if (!IS_ERR(clk))
61 atomic_inc(&clk->use_count); 70 atomic_inc(&clk->use_count);
62 mutex_unlock(&clk_lock); 71 mutex_unlock(&clk_lock);
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
index 327e83ac2469..8fd84a67478a 100644
--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
@@ -630,7 +630,7 @@ static inline int put_v4l2_input32(struct v4l2_input *kp, struct v4l2_input32 __
630} 630}
631 631
632struct v4l2_ext_controls32 { 632struct v4l2_ext_controls32 {
633 __u32 ctrl_class; 633 __u32 which;
634 __u32 count; 634 __u32 count;
635 __u32 error_idx; 635 __u32 error_idx;
636 __u32 reserved[2]; 636 __u32 reserved[2];
@@ -673,7 +673,7 @@ static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext
673 compat_caddr_t p; 673 compat_caddr_t p;
674 674
675 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_ext_controls32)) || 675 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_ext_controls32)) ||
676 get_user(kp->ctrl_class, &up->ctrl_class) || 676 get_user(kp->which, &up->which) ||
677 get_user(kp->count, &up->count) || 677 get_user(kp->count, &up->count) ||
678 get_user(kp->error_idx, &up->error_idx) || 678 get_user(kp->error_idx, &up->error_idx) ||
679 copy_from_user(kp->reserved, up->reserved, 679 copy_from_user(kp->reserved, up->reserved,
@@ -723,7 +723,7 @@ static int put_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext
723 compat_caddr_t p; 723 compat_caddr_t p;
724 724
725 if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_ext_controls32)) || 725 if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_ext_controls32)) ||
726 put_user(kp->ctrl_class, &up->ctrl_class) || 726 put_user(kp->which, &up->which) ||
727 put_user(kp->count, &up->count) || 727 put_user(kp->count, &up->count) ||
728 put_user(kp->error_idx, &up->error_idx) || 728 put_user(kp->error_idx, &up->error_idx) ||
729 copy_to_user(up->reserved, kp->reserved, sizeof(up->reserved))) 729 copy_to_user(up->reserved, kp->reserved, sizeof(up->reserved)))
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index 4a1d9fdd14bb..c9d5537b6af7 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1491,6 +1491,17 @@ static int new_to_user(struct v4l2_ext_control *c,
1491 return ptr_to_user(c, ctrl, ctrl->p_new); 1491 return ptr_to_user(c, ctrl, ctrl->p_new);
1492} 1492}
1493 1493
1494/* Helper function: copy the initial control value back to the caller */
1495static int def_to_user(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl)
1496{
1497 int idx;
1498
1499 for (idx = 0; idx < ctrl->elems; idx++)
1500 ctrl->type_ops->init(ctrl, idx, ctrl->p_new);
1501
1502 return ptr_to_user(c, ctrl, ctrl->p_new);
1503}
1504
1494/* Helper function: copy the caller-provider value to the given control value */ 1505/* Helper function: copy the caller-provider value to the given control value */
1495static int user_to_ptr(struct v4l2_ext_control *c, 1506static int user_to_ptr(struct v4l2_ext_control *c,
1496 struct v4l2_ctrl *ctrl, 1507 struct v4l2_ctrl *ctrl,
@@ -1762,7 +1773,7 @@ static struct v4l2_ctrl_ref *find_private_ref(
1762 list_for_each_entry(ref, &hdl->ctrl_refs, node) { 1773 list_for_each_entry(ref, &hdl->ctrl_refs, node) {
1763 /* Search for private user controls that are compatible with 1774 /* Search for private user controls that are compatible with
1764 VIDIOC_G/S_CTRL. */ 1775 VIDIOC_G/S_CTRL. */
1765 if (V4L2_CTRL_ID2CLASS(ref->ctrl->id) == V4L2_CTRL_CLASS_USER && 1776 if (V4L2_CTRL_ID2WHICH(ref->ctrl->id) == V4L2_CTRL_CLASS_USER &&
1766 V4L2_CTRL_DRIVER_PRIV(ref->ctrl->id)) { 1777 V4L2_CTRL_DRIVER_PRIV(ref->ctrl->id)) {
1767 if (!ref->ctrl->is_int) 1778 if (!ref->ctrl->is_int)
1768 continue; 1779 continue;
@@ -1831,7 +1842,7 @@ static int handler_new_ref(struct v4l2_ctrl_handler *hdl,
1831 struct v4l2_ctrl_ref *ref; 1842 struct v4l2_ctrl_ref *ref;
1832 struct v4l2_ctrl_ref *new_ref; 1843 struct v4l2_ctrl_ref *new_ref;
1833 u32 id = ctrl->id; 1844 u32 id = ctrl->id;
1834 u32 class_ctrl = V4L2_CTRL_ID2CLASS(id) | 1; 1845 u32 class_ctrl = V4L2_CTRL_ID2WHICH(id) | 1;
1835 int bucket = id % hdl->nr_of_buckets; /* which bucket to use */ 1846 int bucket = id % hdl->nr_of_buckets; /* which bucket to use */
1836 1847
1837 /* 1848 /*
@@ -2253,9 +2264,9 @@ EXPORT_SYMBOL(v4l2_ctrl_add_handler);
2253 2264
2254bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl) 2265bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl)
2255{ 2266{
2256 if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_FM_TX) 2267 if (V4L2_CTRL_ID2WHICH(ctrl->id) == V4L2_CTRL_CLASS_FM_TX)
2257 return true; 2268 return true;
2258 if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_FM_RX) 2269 if (V4L2_CTRL_ID2WHICH(ctrl->id) == V4L2_CTRL_CLASS_FM_RX)
2259 return true; 2270 return true;
2260 switch (ctrl->id) { 2271 switch (ctrl->id) {
2261 case V4L2_CID_AUDIO_MUTE: 2272 case V4L2_CID_AUDIO_MUTE:
@@ -2710,7 +2721,9 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl,
2710 2721
2711 cs->error_idx = i; 2722 cs->error_idx = i;
2712 2723
2713 if (cs->ctrl_class && V4L2_CTRL_ID2CLASS(id) != cs->ctrl_class) 2724 if (cs->which &&
2725 cs->which != V4L2_CTRL_WHICH_DEF_VAL &&
2726 V4L2_CTRL_ID2WHICH(id) != cs->which)
2714 return -EINVAL; 2727 return -EINVAL;
2715 2728
2716 /* Old-style private controls are not allowed for 2729 /* Old-style private controls are not allowed for
@@ -2787,11 +2800,11 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl,
2787/* Handles the corner case where cs->count == 0. It checks whether the 2800/* Handles the corner case where cs->count == 0. It checks whether the
2788 specified control class exists. If that class ID is 0, then it checks 2801 specified control class exists. If that class ID is 0, then it checks
2789 whether there are any controls at all. */ 2802 whether there are any controls at all. */
2790static int class_check(struct v4l2_ctrl_handler *hdl, u32 ctrl_class) 2803static int class_check(struct v4l2_ctrl_handler *hdl, u32 which)
2791{ 2804{
2792 if (ctrl_class == 0) 2805 if (which == 0 || which == V4L2_CTRL_WHICH_DEF_VAL)
2793 return list_empty(&hdl->ctrl_refs) ? -EINVAL : 0; 2806 return list_empty(&hdl->ctrl_refs) ? -EINVAL : 0;
2794 return find_ref_lock(hdl, ctrl_class | 1) ? 0 : -EINVAL; 2807 return find_ref_lock(hdl, which | 1) ? 0 : -EINVAL;
2795} 2808}
2796 2809
2797 2810
@@ -2803,15 +2816,18 @@ int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *cs
2803 struct v4l2_ctrl_helper *helpers = helper; 2816 struct v4l2_ctrl_helper *helpers = helper;
2804 int ret; 2817 int ret;
2805 int i, j; 2818 int i, j;
2819 bool def_value;
2820
2821 def_value = (cs->which == V4L2_CTRL_WHICH_DEF_VAL);
2806 2822
2807 cs->error_idx = cs->count; 2823 cs->error_idx = cs->count;
2808 cs->ctrl_class = V4L2_CTRL_ID2CLASS(cs->ctrl_class); 2824 cs->which = V4L2_CTRL_ID2WHICH(cs->which);
2809 2825
2810 if (hdl == NULL) 2826 if (hdl == NULL)
2811 return -EINVAL; 2827 return -EINVAL;
2812 2828
2813 if (cs->count == 0) 2829 if (cs->count == 0)
2814 return class_check(hdl, cs->ctrl_class); 2830 return class_check(hdl, cs->which);
2815 2831
2816 if (cs->count > ARRAY_SIZE(helper)) { 2832 if (cs->count > ARRAY_SIZE(helper)) {
2817 helpers = kmalloc_array(cs->count, sizeof(helper[0]), 2833 helpers = kmalloc_array(cs->count, sizeof(helper[0]),
@@ -2829,9 +2845,11 @@ int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *cs
2829 2845
2830 for (i = 0; !ret && i < cs->count; i++) { 2846 for (i = 0; !ret && i < cs->count; i++) {
2831 int (*ctrl_to_user)(struct v4l2_ext_control *c, 2847 int (*ctrl_to_user)(struct v4l2_ext_control *c,
2832 struct v4l2_ctrl *ctrl) = cur_to_user; 2848 struct v4l2_ctrl *ctrl);
2833 struct v4l2_ctrl *master; 2849 struct v4l2_ctrl *master;
2834 2850
2851 ctrl_to_user = def_value ? def_to_user : cur_to_user;
2852
2835 if (helpers[i].mref == NULL) 2853 if (helpers[i].mref == NULL)
2836 continue; 2854 continue;
2837 2855
@@ -2841,8 +2859,9 @@ int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *cs
2841 v4l2_ctrl_lock(master); 2859 v4l2_ctrl_lock(master);
2842 2860
2843 /* g_volatile_ctrl will update the new control values */ 2861 /* g_volatile_ctrl will update the new control values */
2844 if ((master->flags & V4L2_CTRL_FLAG_VOLATILE) || 2862 if (!def_value &&
2845 (master->has_volatiles && !is_cur_manual(master))) { 2863 ((master->flags & V4L2_CTRL_FLAG_VOLATILE) ||
2864 (master->has_volatiles && !is_cur_manual(master)))) {
2846 for (j = 0; j < master->ncontrols; j++) 2865 for (j = 0; j < master->ncontrols; j++)
2847 cur_to_new(master->cluster[j]); 2866 cur_to_new(master->cluster[j]);
2848 ret = call_op(master, g_volatile_ctrl); 2867 ret = call_op(master, g_volatile_ctrl);
@@ -3064,13 +3083,18 @@ static int try_set_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
3064 int ret; 3083 int ret;
3065 3084
3066 cs->error_idx = cs->count; 3085 cs->error_idx = cs->count;
3067 cs->ctrl_class = V4L2_CTRL_ID2CLASS(cs->ctrl_class); 3086
3087 /* Default value cannot be changed */
3088 if (cs->which == V4L2_CTRL_WHICH_DEF_VAL)
3089 return -EINVAL;
3090
3091 cs->which = V4L2_CTRL_ID2WHICH(cs->which);
3068 3092
3069 if (hdl == NULL) 3093 if (hdl == NULL)
3070 return -EINVAL; 3094 return -EINVAL;
3071 3095
3072 if (cs->count == 0) 3096 if (cs->count == 0)
3073 return class_check(hdl, cs->ctrl_class); 3097 return class_check(hdl, cs->which);
3074 3098
3075 if (cs->count > ARRAY_SIZE(helper)) { 3099 if (cs->count > ARRAY_SIZE(helper)) {
3076 helpers = kmalloc_array(cs->count, sizeof(helper[0]), 3100 helpers = kmalloc_array(cs->count, sizeof(helper[0]),
@@ -3300,7 +3324,8 @@ EXPORT_SYMBOL(v4l2_ctrl_notify);
3300int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, 3324int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
3301 s64 min, s64 max, u64 step, s64 def) 3325 s64 min, s64 max, u64 step, s64 def)
3302{ 3326{
3303 bool changed; 3327 bool value_changed;
3328 bool range_changed = false;
3304 int ret; 3329 int ret;
3305 3330
3306 lockdep_assert_held(ctrl->handler->lock); 3331 lockdep_assert_held(ctrl->handler->lock);
@@ -3324,10 +3349,14 @@ int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
3324 default: 3349 default:
3325 return -EINVAL; 3350 return -EINVAL;
3326 } 3351 }
3327 ctrl->minimum = min; 3352 if ((ctrl->minimum != min) || (ctrl->maximum != max) ||
3328 ctrl->maximum = max; 3353 (ctrl->step != step) || ctrl->default_value != def) {
3329 ctrl->step = step; 3354 range_changed = true;
3330 ctrl->default_value = def; 3355 ctrl->minimum = min;
3356 ctrl->maximum = max;
3357 ctrl->step = step;
3358 ctrl->default_value = def;
3359 }
3331 cur_to_new(ctrl); 3360 cur_to_new(ctrl);
3332 if (validate_new(ctrl, ctrl->p_new)) { 3361 if (validate_new(ctrl, ctrl->p_new)) {
3333 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) 3362 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64)
@@ -3337,12 +3366,12 @@ int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
3337 } 3366 }
3338 3367
3339 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) 3368 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64)
3340 changed = *ctrl->p_new.p_s64 != *ctrl->p_cur.p_s64; 3369 value_changed = *ctrl->p_new.p_s64 != *ctrl->p_cur.p_s64;
3341 else 3370 else
3342 changed = *ctrl->p_new.p_s32 != *ctrl->p_cur.p_s32; 3371 value_changed = *ctrl->p_new.p_s32 != *ctrl->p_cur.p_s32;
3343 if (changed) 3372 if (value_changed)
3344 ret = set_ctrl(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE); 3373 ret = set_ctrl(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE);
3345 else 3374 else if (range_changed)
3346 send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE); 3375 send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE);
3347 return ret; 3376 return ret;
3348} 3377}
diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
index 5b0a30b9252b..7129e438f29e 100644
--- a/drivers/media/v4l2-core/v4l2-device.c
+++ b/drivers/media/v4l2-core/v4l2-device.c
@@ -118,11 +118,20 @@ void v4l2_device_unregister(struct v4l2_device *v4l2_dev)
118 if (sd->flags & V4L2_SUBDEV_FL_IS_I2C) { 118 if (sd->flags & V4L2_SUBDEV_FL_IS_I2C) {
119 struct i2c_client *client = v4l2_get_subdevdata(sd); 119 struct i2c_client *client = v4l2_get_subdevdata(sd);
120 120
121 /* We need to unregister the i2c client explicitly. 121 /*
122 We cannot rely on i2c_del_adapter to always 122 * We need to unregister the i2c client
123 unregister clients for us, since if the i2c bus 123 * explicitly. We cannot rely on
124 is a platform bus, then it is never deleted. */ 124 * i2c_del_adapter to always unregister
125 if (client) 125 * clients for us, since if the i2c bus is a
126 * platform bus, then it is never deleted.
127 *
128 * Device tree or ACPI based devices must not
129 * be unregistered as they have not been
130 * registered by us, and would not be
131 * re-created by just probing the V4L2 driver.
132 */
133 if (client &&
134 !client->dev.of_node && !client->dev.fwnode)
126 i2c_unregister_device(client); 135 i2c_unregister_device(client);
127 continue; 136 continue;
128 } 137 }
@@ -131,7 +140,7 @@ void v4l2_device_unregister(struct v4l2_device *v4l2_dev)
131 if (sd->flags & V4L2_SUBDEV_FL_IS_SPI) { 140 if (sd->flags & V4L2_SUBDEV_FL_IS_SPI) {
132 struct spi_device *spi = v4l2_get_subdevdata(sd); 141 struct spi_device *spi = v4l2_get_subdevdata(sd);
133 142
134 if (spi) 143 if (spi && !spi->dev.of_node && !spi->dev.fwnode)
135 spi_unregister_device(spi); 144 spi_unregister_device(spi);
136 continue; 145 continue;
137 } 146 }
diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c b/drivers/media/v4l2-core/v4l2-dv-timings.c
index 6a83d6191684..ec258b73001a 100644
--- a/drivers/media/v4l2-core/v4l2-dv-timings.c
+++ b/drivers/media/v4l2-core/v4l2-dv-timings.c
@@ -209,8 +209,13 @@ bool v4l2_find_dv_timings_cap(struct v4l2_dv_timings *t,
209 if (v4l2_valid_dv_timings(v4l2_dv_timings_presets + i, cap, 209 if (v4l2_valid_dv_timings(v4l2_dv_timings_presets + i, cap,
210 fnc, fnc_handle) && 210 fnc, fnc_handle) &&
211 v4l2_match_dv_timings(t, v4l2_dv_timings_presets + i, 211 v4l2_match_dv_timings(t, v4l2_dv_timings_presets + i,
212 pclock_delta)) { 212 pclock_delta, false)) {
213 u32 flags = t->bt.flags & V4L2_DV_FL_REDUCED_FPS;
214
213 *t = v4l2_dv_timings_presets[i]; 215 *t = v4l2_dv_timings_presets[i];
216 if (can_reduce_fps(&t->bt))
217 t->bt.flags |= flags;
218
214 return true; 219 return true;
215 } 220 }
216 } 221 }
@@ -223,12 +228,14 @@ EXPORT_SYMBOL_GPL(v4l2_find_dv_timings_cap);
223 * @t1 - compare this v4l2_dv_timings struct... 228 * @t1 - compare this v4l2_dv_timings struct...
224 * @t2 - with this struct. 229 * @t2 - with this struct.
225 * @pclock_delta - the allowed pixelclock deviation. 230 * @pclock_delta - the allowed pixelclock deviation.
231 * @match_reduced_fps - if true, then fail if V4L2_DV_FL_REDUCED_FPS does not
232 * match.
226 * 233 *
227 * Compare t1 with t2 with a given margin of error for the pixelclock. 234 * Compare t1 with t2 with a given margin of error for the pixelclock.
228 */ 235 */
229bool v4l2_match_dv_timings(const struct v4l2_dv_timings *t1, 236bool v4l2_match_dv_timings(const struct v4l2_dv_timings *t1,
230 const struct v4l2_dv_timings *t2, 237 const struct v4l2_dv_timings *t2,
231 unsigned pclock_delta) 238 unsigned pclock_delta, bool match_reduced_fps)
232{ 239{
233 if (t1->type != t2->type || t1->type != V4L2_DV_BT_656_1120) 240 if (t1->type != t2->type || t1->type != V4L2_DV_BT_656_1120)
234 return false; 241 return false;
@@ -239,9 +246,14 @@ bool v4l2_match_dv_timings(const struct v4l2_dv_timings *t1,
239 t1->bt.pixelclock >= t2->bt.pixelclock - pclock_delta && 246 t1->bt.pixelclock >= t2->bt.pixelclock - pclock_delta &&
240 t1->bt.pixelclock <= t2->bt.pixelclock + pclock_delta && 247 t1->bt.pixelclock <= t2->bt.pixelclock + pclock_delta &&
241 t1->bt.hfrontporch == t2->bt.hfrontporch && 248 t1->bt.hfrontporch == t2->bt.hfrontporch &&
249 t1->bt.hsync == t2->bt.hsync &&
250 t1->bt.hbackporch == t2->bt.hbackporch &&
242 t1->bt.vfrontporch == t2->bt.vfrontporch && 251 t1->bt.vfrontporch == t2->bt.vfrontporch &&
243 t1->bt.vsync == t2->bt.vsync && 252 t1->bt.vsync == t2->bt.vsync &&
244 t1->bt.vbackporch == t2->bt.vbackporch && 253 t1->bt.vbackporch == t2->bt.vbackporch &&
254 (!match_reduced_fps ||
255 (t1->bt.flags & V4L2_DV_FL_REDUCED_FPS) ==
256 (t2->bt.flags & V4L2_DV_FL_REDUCED_FPS)) &&
245 (!t1->bt.interlaced || 257 (!t1->bt.interlaced ||
246 (t1->bt.il_vfrontporch == t2->bt.il_vfrontporch && 258 (t1->bt.il_vfrontporch == t2->bt.il_vfrontporch &&
247 t1->bt.il_vsync == t2->bt.il_vsync && 259 t1->bt.il_vsync == t2->bt.il_vsync &&
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 7486af2c8ae4..8a018c6dd16a 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -565,8 +565,8 @@ static void v4l_print_ext_controls(const void *arg, bool write_only)
565 const struct v4l2_ext_controls *p = arg; 565 const struct v4l2_ext_controls *p = arg;
566 int i; 566 int i;
567 567
568 pr_cont("class=0x%x, count=%d, error_idx=%d", 568 pr_cont("which=0x%x, count=%d, error_idx=%d",
569 p->ctrl_class, p->count, p->error_idx); 569 p->which, p->count, p->error_idx);
570 for (i = 0; i < p->count; i++) { 570 for (i = 0; i < p->count; i++) {
571 if (!p->controls[i].size) 571 if (!p->controls[i].size)
572 pr_cont(", id/val=0x%x/0x%x", 572 pr_cont(", id/val=0x%x/0x%x",
@@ -902,13 +902,13 @@ static int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv)
902 Only when passed in through VIDIOC_G_CTRL and VIDIOC_S_CTRL 902 Only when passed in through VIDIOC_G_CTRL and VIDIOC_S_CTRL
903 is it allowed for backwards compatibility. 903 is it allowed for backwards compatibility.
904 */ 904 */
905 if (!allow_priv && c->ctrl_class == V4L2_CID_PRIVATE_BASE) 905 if (!allow_priv && c->which == V4L2_CID_PRIVATE_BASE)
906 return 0; 906 return 0;
907 if (c->ctrl_class == 0) 907 if (!c->which)
908 return 1; 908 return 1;
909 /* Check that all controls are from the same control class. */ 909 /* Check that all controls are from the same control class. */
910 for (i = 0; i < c->count; i++) { 910 for (i = 0; i < c->count; i++) {
911 if (V4L2_CTRL_ID2CLASS(c->controls[i].id) != c->ctrl_class) { 911 if (V4L2_CTRL_ID2WHICH(c->controls[i].id) != c->which) {
912 c->error_idx = i; 912 c->error_idx = i;
913 return 0; 913 return 0;
914 } 914 }
@@ -1969,7 +1969,7 @@ static int v4l_g_ctrl(const struct v4l2_ioctl_ops *ops,
1969 if (ops->vidioc_g_ext_ctrls == NULL) 1969 if (ops->vidioc_g_ext_ctrls == NULL)
1970 return -ENOTTY; 1970 return -ENOTTY;
1971 1971
1972 ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id); 1972 ctrls.which = V4L2_CTRL_ID2WHICH(p->id);
1973 ctrls.count = 1; 1973 ctrls.count = 1;
1974 ctrls.controls = &ctrl; 1974 ctrls.controls = &ctrl;
1975 ctrl.id = p->id; 1975 ctrl.id = p->id;
@@ -2003,7 +2003,7 @@ static int v4l_s_ctrl(const struct v4l2_ioctl_ops *ops,
2003 if (ops->vidioc_s_ext_ctrls == NULL) 2003 if (ops->vidioc_s_ext_ctrls == NULL)
2004 return -ENOTTY; 2004 return -ENOTTY;
2005 2005
2006 ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id); 2006 ctrls.which = V4L2_CTRL_ID2WHICH(p->id);
2007 ctrls.count = 1; 2007 ctrls.count = 1;
2008 ctrls.controls = &ctrl; 2008 ctrls.controls = &ctrl;
2009 ctrl.id = p->id; 2009 ctrl.id = p->id;
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 33bdd81065e8..c5d49d7a0d76 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -28,11 +28,161 @@
28 28
29#include <trace/events/vb2.h> 29#include <trace/events/vb2.h>
30 30
31#include "videobuf2-internal.h" 31static int debug;
32module_param(debug, int, 0644);
32 33
33int vb2_debug; 34#define dprintk(level, fmt, arg...) \
34EXPORT_SYMBOL_GPL(vb2_debug); 35 do { \
35module_param_named(debug, vb2_debug, int, 0644); 36 if (debug >= level) \
37 pr_info("vb2-core: %s: " fmt, __func__, ## arg); \
38 } while (0)
39
40#ifdef CONFIG_VIDEO_ADV_DEBUG
41
42/*
43 * If advanced debugging is on, then count how often each op is called
44 * successfully, which can either be per-buffer or per-queue.
45 *
46 * This makes it easy to check that the 'init' and 'cleanup'
47 * (and variations thereof) stay balanced.
48 */
49
50#define log_memop(vb, op) \
51 dprintk(2, "call_memop(%p, %d, %s)%s\n", \
52 (vb)->vb2_queue, (vb)->index, #op, \
53 (vb)->vb2_queue->mem_ops->op ? "" : " (nop)")
54
55#define call_memop(vb, op, args...) \
56({ \
57 struct vb2_queue *_q = (vb)->vb2_queue; \
58 int err; \
59 \
60 log_memop(vb, op); \
61 err = _q->mem_ops->op ? _q->mem_ops->op(args) : 0; \
62 if (!err) \
63 (vb)->cnt_mem_ ## op++; \
64 err; \
65})
66
67#define call_ptr_memop(vb, op, args...) \
68({ \
69 struct vb2_queue *_q = (vb)->vb2_queue; \
70 void *ptr; \
71 \
72 log_memop(vb, op); \
73 ptr = _q->mem_ops->op ? _q->mem_ops->op(args) : NULL; \
74 if (!IS_ERR_OR_NULL(ptr)) \
75 (vb)->cnt_mem_ ## op++; \
76 ptr; \
77})
78
79#define call_void_memop(vb, op, args...) \
80({ \
81 struct vb2_queue *_q = (vb)->vb2_queue; \
82 \
83 log_memop(vb, op); \
84 if (_q->mem_ops->op) \
85 _q->mem_ops->op(args); \
86 (vb)->cnt_mem_ ## op++; \
87})
88
89#define log_qop(q, op) \
90 dprintk(2, "call_qop(%p, %s)%s\n", q, #op, \
91 (q)->ops->op ? "" : " (nop)")
92
93#define call_qop(q, op, args...) \
94({ \
95 int err; \
96 \
97 log_qop(q, op); \
98 err = (q)->ops->op ? (q)->ops->op(args) : 0; \
99 if (!err) \
100 (q)->cnt_ ## op++; \
101 err; \
102})
103
104#define call_void_qop(q, op, args...) \
105({ \
106 log_qop(q, op); \
107 if ((q)->ops->op) \
108 (q)->ops->op(args); \
109 (q)->cnt_ ## op++; \
110})
111
112#define log_vb_qop(vb, op, args...) \
113 dprintk(2, "call_vb_qop(%p, %d, %s)%s\n", \
114 (vb)->vb2_queue, (vb)->index, #op, \
115 (vb)->vb2_queue->ops->op ? "" : " (nop)")
116
117#define call_vb_qop(vb, op, args...) \
118({ \
119 int err; \
120 \
121 log_vb_qop(vb, op); \
122 err = (vb)->vb2_queue->ops->op ? \
123 (vb)->vb2_queue->ops->op(args) : 0; \
124 if (!err) \
125 (vb)->cnt_ ## op++; \
126 err; \
127})
128
129#define call_void_vb_qop(vb, op, args...) \
130({ \
131 log_vb_qop(vb, op); \
132 if ((vb)->vb2_queue->ops->op) \
133 (vb)->vb2_queue->ops->op(args); \
134 (vb)->cnt_ ## op++; \
135})
136
137#else
138
139#define call_memop(vb, op, args...) \
140 ((vb)->vb2_queue->mem_ops->op ? \
141 (vb)->vb2_queue->mem_ops->op(args) : 0)
142
143#define call_ptr_memop(vb, op, args...) \
144 ((vb)->vb2_queue->mem_ops->op ? \
145 (vb)->vb2_queue->mem_ops->op(args) : NULL)
146
147#define call_void_memop(vb, op, args...) \
148 do { \
149 if ((vb)->vb2_queue->mem_ops->op) \
150 (vb)->vb2_queue->mem_ops->op(args); \
151 } while (0)
152
153#define call_qop(q, op, args...) \
154 ((q)->ops->op ? (q)->ops->op(args) : 0)
155
156#define call_void_qop(q, op, args...) \
157 do { \
158 if ((q)->ops->op) \
159 (q)->ops->op(args); \
160 } while (0)
161
162#define call_vb_qop(vb, op, args...) \
163 ((vb)->vb2_queue->ops->op ? (vb)->vb2_queue->ops->op(args) : 0)
164
165#define call_void_vb_qop(vb, op, args...) \
166 do { \
167 if ((vb)->vb2_queue->ops->op) \
168 (vb)->vb2_queue->ops->op(args); \
169 } while (0)
170
171#endif
172
173#define call_bufop(q, op, args...) \
174({ \
175 int ret = 0; \
176 if (q && q->buf_ops && q->buf_ops->op) \
177 ret = q->buf_ops->op(args); \
178 ret; \
179})
180
181#define call_void_bufop(q, op, args...) \
182({ \
183 if (q && q->buf_ops && q->buf_ops->op) \
184 q->buf_ops->op(args); \
185})
36 186
37static void __vb2_queue_cancel(struct vb2_queue *q); 187static void __vb2_queue_cancel(struct vb2_queue *q);
38static void __enqueue_in_driver(struct vb2_buffer *vb); 188static void __enqueue_in_driver(struct vb2_buffer *vb);
@@ -53,7 +203,7 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
53 * NOTE: mmapped areas should be page aligned 203 * NOTE: mmapped areas should be page aligned
54 */ 204 */
55 for (plane = 0; plane < vb->num_planes; ++plane) { 205 for (plane = 0; plane < vb->num_planes; ++plane) {
56 unsigned long size = PAGE_ALIGN(q->plane_sizes[plane]); 206 unsigned long size = PAGE_ALIGN(vb->planes[plane].length);
57 207
58 mem_priv = call_ptr_memop(vb, alloc, q->alloc_ctx[plane], 208 mem_priv = call_ptr_memop(vb, alloc, q->alloc_ctx[plane],
59 size, dma_dir, q->gfp_flags); 209 size, dma_dir, q->gfp_flags);
@@ -62,7 +212,6 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
62 212
63 /* Associate allocator private data with this plane */ 213 /* Associate allocator private data with this plane */
64 vb->planes[plane].mem_priv = mem_priv; 214 vb->planes[plane].mem_priv = mem_priv;
65 vb->planes[plane].length = q->plane_sizes[plane];
66 } 215 }
67 216
68 return 0; 217 return 0;
@@ -137,57 +286,30 @@ static void __vb2_buf_dmabuf_put(struct vb2_buffer *vb)
137} 286}
138 287
139/** 288/**
140 * __setup_lengths() - setup initial lengths for every plane in
141 * every buffer on the queue
142 */
143static void __setup_lengths(struct vb2_queue *q, unsigned int n)
144{
145 unsigned int buffer, plane;
146 struct vb2_buffer *vb;
147
148 for (buffer = q->num_buffers; buffer < q->num_buffers + n; ++buffer) {
149 vb = q->bufs[buffer];
150 if (!vb)
151 continue;
152
153 for (plane = 0; plane < vb->num_planes; ++plane)
154 vb->planes[plane].length = q->plane_sizes[plane];
155 }
156}
157
158/**
159 * __setup_offsets() - setup unique offsets ("cookies") for every plane in 289 * __setup_offsets() - setup unique offsets ("cookies") for every plane in
160 * every buffer on the queue 290 * the buffer.
161 */ 291 */
162static void __setup_offsets(struct vb2_queue *q, unsigned int n) 292static void __setup_offsets(struct vb2_buffer *vb)
163{ 293{
164 unsigned int buffer, plane; 294 struct vb2_queue *q = vb->vb2_queue;
165 struct vb2_buffer *vb; 295 unsigned int plane;
166 unsigned long off; 296 unsigned long off = 0;
297
298 if (vb->index) {
299 struct vb2_buffer *prev = q->bufs[vb->index - 1];
300 struct vb2_plane *p = &prev->planes[prev->num_planes - 1];
167 301
168 if (q->num_buffers) {
169 struct vb2_plane *p;
170 vb = q->bufs[q->num_buffers - 1];
171 p = &vb->planes[vb->num_planes - 1];
172 off = PAGE_ALIGN(p->m.offset + p->length); 302 off = PAGE_ALIGN(p->m.offset + p->length);
173 } else {
174 off = 0;
175 } 303 }
176 304
177 for (buffer = q->num_buffers; buffer < q->num_buffers + n; ++buffer) { 305 for (plane = 0; plane < vb->num_planes; ++plane) {
178 vb = q->bufs[buffer]; 306 vb->planes[plane].m.offset = off;
179 if (!vb)
180 continue;
181
182 for (plane = 0; plane < vb->num_planes; ++plane) {
183 vb->planes[plane].m.offset = off;
184 307
185 dprintk(3, "buffer %d, plane %d offset 0x%08lx\n", 308 dprintk(3, "buffer %d, plane %d offset 0x%08lx\n",
186 buffer, plane, off); 309 vb->index, plane, off);
187 310
188 off += vb->planes[plane].length; 311 off += vb->planes[plane].length;
189 off = PAGE_ALIGN(off); 312 off = PAGE_ALIGN(off);
190 }
191 } 313 }
192} 314}
193 315
@@ -199,9 +321,10 @@ static void __setup_offsets(struct vb2_queue *q, unsigned int n)
199 * Returns the number of buffers successfully allocated. 321 * Returns the number of buffers successfully allocated.
200 */ 322 */
201static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory, 323static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
202 unsigned int num_buffers, unsigned int num_planes) 324 unsigned int num_buffers, unsigned int num_planes,
325 const unsigned plane_sizes[VB2_MAX_PLANES])
203{ 326{
204 unsigned int buffer; 327 unsigned int buffer, plane;
205 struct vb2_buffer *vb; 328 struct vb2_buffer *vb;
206 int ret; 329 int ret;
207 330
@@ -219,6 +342,11 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
219 vb->index = q->num_buffers + buffer; 342 vb->index = q->num_buffers + buffer;
220 vb->type = q->type; 343 vb->type = q->type;
221 vb->memory = memory; 344 vb->memory = memory;
345 for (plane = 0; plane < num_planes; ++plane) {
346 vb->planes[plane].length = plane_sizes[plane];
347 vb->planes[plane].min_length = plane_sizes[plane];
348 }
349 q->bufs[vb->index] = vb;
222 350
223 /* Allocate video buffer memory for the MMAP type */ 351 /* Allocate video buffer memory for the MMAP type */
224 if (memory == VB2_MEMORY_MMAP) { 352 if (memory == VB2_MEMORY_MMAP) {
@@ -226,9 +354,11 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
226 if (ret) { 354 if (ret) {
227 dprintk(1, "failed allocating memory for " 355 dprintk(1, "failed allocating memory for "
228 "buffer %d\n", buffer); 356 "buffer %d\n", buffer);
357 q->bufs[vb->index] = NULL;
229 kfree(vb); 358 kfree(vb);
230 break; 359 break;
231 } 360 }
361 __setup_offsets(vb);
232 /* 362 /*
233 * Call the driver-provided buffer initialization 363 * Call the driver-provided buffer initialization
234 * callback, if given. An error in initialization 364 * callback, if given. An error in initialization
@@ -239,18 +369,13 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
239 dprintk(1, "buffer %d %p initialization" 369 dprintk(1, "buffer %d %p initialization"
240 " failed\n", buffer, vb); 370 " failed\n", buffer, vb);
241 __vb2_buf_mem_free(vb); 371 __vb2_buf_mem_free(vb);
372 q->bufs[vb->index] = NULL;
242 kfree(vb); 373 kfree(vb);
243 break; 374 break;
244 } 375 }
245 } 376 }
246
247 q->bufs[q->num_buffers + buffer] = vb;
248 } 377 }
249 378
250 __setup_lengths(q, buffer);
251 if (memory == VB2_MEMORY_MMAP)
252 __setup_offsets(q, buffer);
253
254 dprintk(1, "allocated %d buffers, %d plane(s) each\n", 379 dprintk(1, "allocated %d buffers, %d plane(s) each\n",
255 buffer, num_planes); 380 buffer, num_planes);
256 381
@@ -330,7 +455,7 @@ static int __vb2_queue_free(struct vb2_queue *q, unsigned int buffers)
330 bool unbalanced = q->cnt_start_streaming != q->cnt_stop_streaming || 455 bool unbalanced = q->cnt_start_streaming != q->cnt_stop_streaming ||
331 q->cnt_wait_prepare != q->cnt_wait_finish; 456 q->cnt_wait_prepare != q->cnt_wait_finish;
332 457
333 if (unbalanced || vb2_debug) { 458 if (unbalanced || debug) {
334 pr_info("vb2: counters for queue %p:%s\n", q, 459 pr_info("vb2: counters for queue %p:%s\n", q,
335 unbalanced ? " UNBALANCED!" : ""); 460 unbalanced ? " UNBALANCED!" : "");
336 pr_info("vb2: setup: %u start_streaming: %u stop_streaming: %u\n", 461 pr_info("vb2: setup: %u start_streaming: %u stop_streaming: %u\n",
@@ -356,7 +481,7 @@ static int __vb2_queue_free(struct vb2_queue *q, unsigned int buffers)
356 vb->cnt_buf_prepare != vb->cnt_buf_finish || 481 vb->cnt_buf_prepare != vb->cnt_buf_finish ||
357 vb->cnt_buf_init != vb->cnt_buf_cleanup; 482 vb->cnt_buf_init != vb->cnt_buf_cleanup;
358 483
359 if (unbalanced || vb2_debug) { 484 if (unbalanced || debug) {
360 pr_info("vb2: counters for queue %p, buffer %d:%s\n", 485 pr_info("vb2: counters for queue %p, buffer %d:%s\n",
361 q, buffer, unbalanced ? " UNBALANCED!" : ""); 486 q, buffer, unbalanced ? " UNBALANCED!" : "");
362 pr_info("vb2: buf_init: %u buf_cleanup: %u buf_prepare: %u buf_finish: %u\n", 487 pr_info("vb2: buf_init: %u buf_cleanup: %u buf_prepare: %u buf_finish: %u\n",
@@ -442,13 +567,10 @@ static bool __buffers_in_use(struct vb2_queue *q)
442 * Should be called from vidioc_querybuf ioctl handler in driver. 567 * Should be called from vidioc_querybuf ioctl handler in driver.
443 * The passed buffer should have been verified. 568 * The passed buffer should have been verified.
444 * This function fills the relevant information for the userspace. 569 * This function fills the relevant information for the userspace.
445 *
446 * The return values from this function are intended to be directly returned
447 * from vidioc_querybuf handler in driver.
448 */ 570 */
449int vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb) 571void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb)
450{ 572{
451 return call_bufop(q, fill_user_buffer, q->bufs[index], pb); 573 call_void_bufop(q, fill_user_buffer, q->bufs[index], pb);
452} 574}
453EXPORT_SYMBOL_GPL(vb2_core_querybuf); 575EXPORT_SYMBOL_GPL(vb2_core_querybuf);
454 576
@@ -570,6 +692,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
570 unsigned int *count) 692 unsigned int *count)
571{ 693{
572 unsigned int num_buffers, allocated_buffers, num_planes = 0; 694 unsigned int num_buffers, allocated_buffers, num_planes = 0;
695 unsigned plane_sizes[VB2_MAX_PLANES] = { };
573 int ret; 696 int ret;
574 697
575 if (q->streaming) { 698 if (q->streaming) {
@@ -613,7 +736,6 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
613 */ 736 */
614 num_buffers = min_t(unsigned int, *count, VB2_MAX_FRAME); 737 num_buffers = min_t(unsigned int, *count, VB2_MAX_FRAME);
615 num_buffers = max_t(unsigned int, num_buffers, q->min_buffers_needed); 738 num_buffers = max_t(unsigned int, num_buffers, q->min_buffers_needed);
616 memset(q->plane_sizes, 0, sizeof(q->plane_sizes));
617 memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx)); 739 memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx));
618 q->memory = memory; 740 q->memory = memory;
619 741
@@ -621,14 +743,14 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
621 * Ask the driver how many buffers and planes per buffer it requires. 743 * Ask the driver how many buffers and planes per buffer it requires.
622 * Driver also sets the size and allocator context for each plane. 744 * Driver also sets the size and allocator context for each plane.
623 */ 745 */
624 ret = call_qop(q, queue_setup, q, NULL, &num_buffers, &num_planes, 746 ret = call_qop(q, queue_setup, q, &num_buffers, &num_planes,
625 q->plane_sizes, q->alloc_ctx); 747 plane_sizes, q->alloc_ctx);
626 if (ret) 748 if (ret)
627 return ret; 749 return ret;
628 750
629 /* Finally, allocate buffers and video memory */ 751 /* Finally, allocate buffers and video memory */
630 allocated_buffers = 752 allocated_buffers =
631 __vb2_queue_alloc(q, memory, num_buffers, num_planes); 753 __vb2_queue_alloc(q, memory, num_buffers, num_planes, plane_sizes);
632 if (allocated_buffers == 0) { 754 if (allocated_buffers == 0) {
633 dprintk(1, "memory allocation failed\n"); 755 dprintk(1, "memory allocation failed\n");
634 return -ENOMEM; 756 return -ENOMEM;
@@ -646,9 +768,16 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
646 */ 768 */
647 if (!ret && allocated_buffers < num_buffers) { 769 if (!ret && allocated_buffers < num_buffers) {
648 num_buffers = allocated_buffers; 770 num_buffers = allocated_buffers;
771 /*
772 * num_planes is set by the previous queue_setup(), but since it
773 * signals to queue_setup() whether it is called from create_bufs()
774 * vs reqbufs() we zero it here to signal that queue_setup() is
775 * called for the reqbufs() case.
776 */
777 num_planes = 0;
649 778
650 ret = call_qop(q, queue_setup, q, NULL, &num_buffers, 779 ret = call_qop(q, queue_setup, q, &num_buffers,
651 &num_planes, q->plane_sizes, q->alloc_ctx); 780 &num_planes, plane_sizes, q->alloc_ctx);
652 781
653 if (!ret && allocated_buffers < num_buffers) 782 if (!ret && allocated_buffers < num_buffers)
654 ret = -ENOMEM; 783 ret = -ENOMEM;
@@ -701,9 +830,11 @@ EXPORT_SYMBOL_GPL(vb2_core_reqbufs);
701 * from vidioc_create_bufs handler in driver. 830 * from vidioc_create_bufs handler in driver.
702 */ 831 */
703int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, 832int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
704 unsigned int *count, const void *parg) 833 unsigned int *count, unsigned requested_planes,
834 const unsigned requested_sizes[])
705{ 835{
706 unsigned int num_planes = 0, num_buffers, allocated_buffers; 836 unsigned int num_planes = 0, num_buffers, allocated_buffers;
837 unsigned plane_sizes[VB2_MAX_PLANES] = { };
707 int ret; 838 int ret;
708 839
709 if (q->num_buffers == VB2_MAX_FRAME) { 840 if (q->num_buffers == VB2_MAX_FRAME) {
@@ -712,7 +843,6 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
712 } 843 }
713 844
714 if (!q->num_buffers) { 845 if (!q->num_buffers) {
715 memset(q->plane_sizes, 0, sizeof(q->plane_sizes));
716 memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx)); 846 memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx));
717 q->memory = memory; 847 q->memory = memory;
718 q->waiting_for_buffers = !q->is_output; 848 q->waiting_for_buffers = !q->is_output;
@@ -720,18 +850,23 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
720 850
721 num_buffers = min(*count, VB2_MAX_FRAME - q->num_buffers); 851 num_buffers = min(*count, VB2_MAX_FRAME - q->num_buffers);
722 852
853 if (requested_planes && requested_sizes) {
854 num_planes = requested_planes;
855 memcpy(plane_sizes, requested_sizes, sizeof(plane_sizes));
856 }
857
723 /* 858 /*
724 * Ask the driver, whether the requested number of buffers, planes per 859 * Ask the driver, whether the requested number of buffers, planes per
725 * buffer and their sizes are acceptable 860 * buffer and their sizes are acceptable
726 */ 861 */
727 ret = call_qop(q, queue_setup, q, parg, &num_buffers, 862 ret = call_qop(q, queue_setup, q, &num_buffers,
728 &num_planes, q->plane_sizes, q->alloc_ctx); 863 &num_planes, plane_sizes, q->alloc_ctx);
729 if (ret) 864 if (ret)
730 return ret; 865 return ret;
731 866
732 /* Finally, allocate buffers and video memory */ 867 /* Finally, allocate buffers and video memory */
733 allocated_buffers = __vb2_queue_alloc(q, memory, num_buffers, 868 allocated_buffers = __vb2_queue_alloc(q, memory, num_buffers,
734 num_planes); 869 num_planes, plane_sizes);
735 if (allocated_buffers == 0) { 870 if (allocated_buffers == 0) {
736 dprintk(1, "memory allocation failed\n"); 871 dprintk(1, "memory allocation failed\n");
737 return -ENOMEM; 872 return -ENOMEM;
@@ -747,8 +882,8 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
747 * q->num_buffers contains the total number of buffers, that the 882 * q->num_buffers contains the total number of buffers, that the
748 * queue driver has set up 883 * queue driver has set up
749 */ 884 */
750 ret = call_qop(q, queue_setup, q, parg, &num_buffers, 885 ret = call_qop(q, queue_setup, q, &num_buffers,
751 &num_planes, q->plane_sizes, q->alloc_ctx); 886 &num_planes, plane_sizes, q->alloc_ctx);
752 887
753 if (!ret && allocated_buffers < num_buffers) 888 if (!ret && allocated_buffers < num_buffers)
754 ret = -ENOMEM; 889 ret = -ENOMEM;
@@ -964,11 +1099,12 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const void *pb)
964 "reacquiring memory\n", plane); 1099 "reacquiring memory\n", plane);
965 1100
966 /* Check if the provided plane buffer is large enough */ 1101 /* Check if the provided plane buffer is large enough */
967 if (planes[plane].length < q->plane_sizes[plane]) { 1102 if (planes[plane].length < vb->planes[plane].min_length) {
968 dprintk(1, "provided buffer size %u is less than " 1103 dprintk(1, "provided buffer size %u is less than "
969 "setup size %u for plane %d\n", 1104 "setup size %u for plane %d\n",
970 planes[plane].length, 1105 planes[plane].length,
971 q->plane_sizes[plane], plane); 1106 vb->planes[plane].min_length,
1107 plane);
972 ret = -EINVAL; 1108 ret = -EINVAL;
973 goto err; 1109 goto err;
974 } 1110 }
@@ -1081,7 +1217,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const void *pb)
1081 if (planes[plane].length == 0) 1217 if (planes[plane].length == 0)
1082 planes[plane].length = dbuf->size; 1218 planes[plane].length = dbuf->size;
1083 1219
1084 if (planes[plane].length < q->plane_sizes[plane]) { 1220 if (planes[plane].length < vb->planes[plane].min_length) {
1085 dprintk(1, "invalid dmabuf length for plane %d\n", 1221 dprintk(1, "invalid dmabuf length for plane %d\n",
1086 plane); 1222 plane);
1087 ret = -EINVAL; 1223 ret = -EINVAL;
@@ -1263,9 +1399,7 @@ int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb)
1263 return ret; 1399 return ret;
1264 1400
1265 /* Fill buffer information for the userspace */ 1401 /* Fill buffer information for the userspace */
1266 ret = call_bufop(q, fill_user_buffer, vb, pb); 1402 call_void_bufop(q, fill_user_buffer, vb, pb);
1267 if (ret)
1268 return ret;
1269 1403
1270 dprintk(1, "prepare of buffer %d succeeded\n", vb->index); 1404 dprintk(1, "prepare of buffer %d succeeded\n", vb->index);
1271 1405
@@ -1386,7 +1520,7 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb)
1386 q->waiting_for_buffers = false; 1520 q->waiting_for_buffers = false;
1387 vb->state = VB2_BUF_STATE_QUEUED; 1521 vb->state = VB2_BUF_STATE_QUEUED;
1388 1522
1389 call_bufop(q, set_timestamp, vb, pb); 1523 call_void_bufop(q, copy_timestamp, vb, pb);
1390 1524
1391 trace_vb2_qbuf(q, vb); 1525 trace_vb2_qbuf(q, vb);
1392 1526
@@ -1398,9 +1532,7 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb)
1398 __enqueue_in_driver(vb); 1532 __enqueue_in_driver(vb);
1399 1533
1400 /* Fill buffer information for the userspace */ 1534 /* Fill buffer information for the userspace */
1401 ret = call_bufop(q, fill_user_buffer, vb, pb); 1535 call_void_bufop(q, fill_user_buffer, vb, pb);
1402 if (ret)
1403 return ret;
1404 1536
1405 /* 1537 /*
1406 * If streamon has been called, and we haven't yet called 1538 * If streamon has been called, and we haven't yet called
@@ -1623,9 +1755,7 @@ int vb2_core_dqbuf(struct vb2_queue *q, void *pb, bool nonblocking)
1623 call_void_vb_qop(vb, buf_finish, vb); 1755 call_void_vb_qop(vb, buf_finish, vb);
1624 1756
1625 /* Fill buffer information for the userspace */ 1757 /* Fill buffer information for the userspace */
1626 ret = call_bufop(q, fill_user_buffer, vb, pb); 1758 call_void_bufop(q, fill_user_buffer, vb, pb);
1627 if (ret)
1628 return ret;
1629 1759
1630 /* Remove from videobuf queue */ 1760 /* Remove from videobuf queue */
1631 list_del(&vb->queued_entry); 1761 list_del(&vb->queued_entry);
@@ -2073,6 +2203,8 @@ int vb2_core_queue_init(struct vb2_queue *q)
2073} 2203}
2074EXPORT_SYMBOL_GPL(vb2_core_queue_init); 2204EXPORT_SYMBOL_GPL(vb2_core_queue_init);
2075 2205
2206static int __vb2_init_fileio(struct vb2_queue *q, int read);
2207static int __vb2_cleanup_fileio(struct vb2_queue *q);
2076/** 2208/**
2077 * vb2_core_queue_release() - stop streaming, release the queue and free memory 2209 * vb2_core_queue_release() - stop streaming, release the queue and free memory
2078 * @q: videobuf2 queue 2210 * @q: videobuf2 queue
@@ -2083,6 +2215,7 @@ EXPORT_SYMBOL_GPL(vb2_core_queue_init);
2083 */ 2215 */
2084void vb2_core_queue_release(struct vb2_queue *q) 2216void vb2_core_queue_release(struct vb2_queue *q)
2085{ 2217{
2218 __vb2_cleanup_fileio(q);
2086 __vb2_queue_cancel(q); 2219 __vb2_queue_cancel(q);
2087 mutex_lock(&q->mmap_lock); 2220 mutex_lock(&q->mmap_lock);
2088 __vb2_queue_free(q, q->num_buffers); 2221 __vb2_queue_free(q, q->num_buffers);
@@ -2090,6 +2223,619 @@ void vb2_core_queue_release(struct vb2_queue *q)
2090} 2223}
2091EXPORT_SYMBOL_GPL(vb2_core_queue_release); 2224EXPORT_SYMBOL_GPL(vb2_core_queue_release);
2092 2225
2093MODULE_DESCRIPTION("Driver helper framework for Video for Linux 2"); 2226/**
2227 * vb2_core_poll() - implements poll userspace operation
2228 * @q: videobuf2 queue
2229 * @file: file argument passed to the poll file operation handler
2230 * @wait: wait argument passed to the poll file operation handler
2231 *
2232 * This function implements poll file operation handler for a driver.
2233 * For CAPTURE queues, if a buffer is ready to be dequeued, the userspace will
2234 * be informed that the file descriptor of a video device is available for
2235 * reading.
2236 * For OUTPUT queues, if a buffer is ready to be dequeued, the file descriptor
2237 * will be reported as available for writing.
2238 *
2239 * The return values from this function are intended to be directly returned
2240 * from poll handler in driver.
2241 */
2242unsigned int vb2_core_poll(struct vb2_queue *q, struct file *file,
2243 poll_table *wait)
2244{
2245 unsigned long req_events = poll_requested_events(wait);
2246 struct vb2_buffer *vb = NULL;
2247 unsigned long flags;
2248
2249 if (!q->is_output && !(req_events & (POLLIN | POLLRDNORM)))
2250 return 0;
2251 if (q->is_output && !(req_events & (POLLOUT | POLLWRNORM)))
2252 return 0;
2253
2254 /*
2255 * Start file I/O emulator only if streaming API has not been used yet.
2256 */
2257 if (q->num_buffers == 0 && !vb2_fileio_is_active(q)) {
2258 if (!q->is_output && (q->io_modes & VB2_READ) &&
2259 (req_events & (POLLIN | POLLRDNORM))) {
2260 if (__vb2_init_fileio(q, 1))
2261 return POLLERR;
2262 }
2263 if (q->is_output && (q->io_modes & VB2_WRITE) &&
2264 (req_events & (POLLOUT | POLLWRNORM))) {
2265 if (__vb2_init_fileio(q, 0))
2266 return POLLERR;
2267 /*
2268 * Write to OUTPUT queue can be done immediately.
2269 */
2270 return POLLOUT | POLLWRNORM;
2271 }
2272 }
2273
2274 /*
2275 * There is nothing to wait for if the queue isn't streaming, or if the
2276 * error flag is set.
2277 */
2278 if (!vb2_is_streaming(q) || q->error)
2279 return POLLERR;
2280
2281 /*
2282 * For output streams you can call write() as long as there are fewer
2283 * buffers queued than there are buffers available.
2284 */
2285 if (q->is_output && q->fileio && q->queued_count < q->num_buffers)
2286 return POLLOUT | POLLWRNORM;
2287
2288 if (list_empty(&q->done_list)) {
2289 /*
2290 * If the last buffer was dequeued from a capture queue,
2291 * return immediately. DQBUF will return -EPIPE.
2292 */
2293 if (q->last_buffer_dequeued)
2294 return POLLIN | POLLRDNORM;
2295
2296 poll_wait(file, &q->done_wq, wait);
2297 }
2298
2299 /*
2300 * Take first buffer available for dequeuing.
2301 */
2302 spin_lock_irqsave(&q->done_lock, flags);
2303 if (!list_empty(&q->done_list))
2304 vb = list_first_entry(&q->done_list, struct vb2_buffer,
2305 done_entry);
2306 spin_unlock_irqrestore(&q->done_lock, flags);
2307
2308 if (vb && (vb->state == VB2_BUF_STATE_DONE
2309 || vb->state == VB2_BUF_STATE_ERROR)) {
2310 return (q->is_output) ?
2311 POLLOUT | POLLWRNORM :
2312 POLLIN | POLLRDNORM;
2313 }
2314 return 0;
2315}
2316EXPORT_SYMBOL_GPL(vb2_core_poll);
2317
2318/**
2319 * struct vb2_fileio_buf - buffer context used by file io emulator
2320 *
2321 * vb2 provides a compatibility layer and emulator of file io (read and
2322 * write) calls on top of streaming API. This structure is used for
2323 * tracking context related to the buffers.
2324 */
2325struct vb2_fileio_buf {
2326 void *vaddr;
2327 unsigned int size;
2328 unsigned int pos;
2329 unsigned int queued:1;
2330};
2331
2332/**
2333 * struct vb2_fileio_data - queue context used by file io emulator
2334 *
2335 * @cur_index: the index of the buffer currently being read from or
2336 * written to. If equal to q->num_buffers then a new buffer
2337 * must be dequeued.
2338 * @initial_index: in the read() case all buffers are queued up immediately
2339 * in __vb2_init_fileio() and __vb2_perform_fileio() just cycles
2340 * buffers. However, in the write() case no buffers are initially
2341 * queued, instead whenever a buffer is full it is queued up by
2342 * __vb2_perform_fileio(). Only once all available buffers have
2343 * been queued up will __vb2_perform_fileio() start to dequeue
2344 * buffers. This means that initially __vb2_perform_fileio()
2345 * needs to know what buffer index to use when it is queuing up
2346 * the buffers for the first time. That initial index is stored
2347 * in this field. Once it is equal to q->num_buffers all
2348 * available buffers have been queued and __vb2_perform_fileio()
2349 * should start the normal dequeue/queue cycle.
2350 *
2351 * vb2 provides a compatibility layer and emulator of file io (read and
2352 * write) calls on top of streaming API. For proper operation it required
2353 * this structure to save the driver state between each call of the read
2354 * or write function.
2355 */
2356struct vb2_fileio_data {
2357 unsigned int count;
2358 unsigned int type;
2359 unsigned int memory;
2360 struct vb2_buffer *b;
2361 struct vb2_fileio_buf bufs[VB2_MAX_FRAME];
2362 unsigned int cur_index;
2363 unsigned int initial_index;
2364 unsigned int q_count;
2365 unsigned int dq_count;
2366 unsigned read_once:1;
2367 unsigned write_immediately:1;
2368};
2369
2370/**
2371 * __vb2_init_fileio() - initialize file io emulator
2372 * @q: videobuf2 queue
2373 * @read: mode selector (1 means read, 0 means write)
2374 */
2375static int __vb2_init_fileio(struct vb2_queue *q, int read)
2376{
2377 struct vb2_fileio_data *fileio;
2378 int i, ret;
2379 unsigned int count = 0;
2380
2381 /*
2382 * Sanity check
2383 */
2384 if (WARN_ON((read && !(q->io_modes & VB2_READ)) ||
2385 (!read && !(q->io_modes & VB2_WRITE))))
2386 return -EINVAL;
2387
2388 /*
2389 * Check if device supports mapping buffers to kernel virtual space.
2390 */
2391 if (!q->mem_ops->vaddr)
2392 return -EBUSY;
2393
2394 /*
2395 * Check if streaming api has not been already activated.
2396 */
2397 if (q->streaming || q->num_buffers > 0)
2398 return -EBUSY;
2399
2400 /*
2401 * Start with count 1, driver can increase it in queue_setup()
2402 */
2403 count = 1;
2404
2405 dprintk(3, "setting up file io: mode %s, count %d, read_once %d, write_immediately %d\n",
2406 (read) ? "read" : "write", count, q->fileio_read_once,
2407 q->fileio_write_immediately);
2408
2409 fileio = kzalloc(sizeof(*fileio), GFP_KERNEL);
2410 if (fileio == NULL)
2411 return -ENOMEM;
2412
2413 fileio->b = kzalloc(q->buf_struct_size, GFP_KERNEL);
2414 if (fileio->b == NULL) {
2415 kfree(fileio);
2416 return -ENOMEM;
2417 }
2418
2419 fileio->read_once = q->fileio_read_once;
2420 fileio->write_immediately = q->fileio_write_immediately;
2421
2422 /*
2423 * Request buffers and use MMAP type to force driver
2424 * to allocate buffers by itself.
2425 */
2426 fileio->count = count;
2427 fileio->memory = VB2_MEMORY_MMAP;
2428 fileio->type = q->type;
2429 q->fileio = fileio;
2430 ret = vb2_core_reqbufs(q, fileio->memory, &fileio->count);
2431 if (ret)
2432 goto err_kfree;
2433
2434 /*
2435 * Check if plane_count is correct
2436 * (multiplane buffers are not supported).
2437 */
2438 if (q->bufs[0]->num_planes != 1) {
2439 ret = -EBUSY;
2440 goto err_reqbufs;
2441 }
2442
2443 /*
2444 * Get kernel address of each buffer.
2445 */
2446 for (i = 0; i < q->num_buffers; i++) {
2447 fileio->bufs[i].vaddr = vb2_plane_vaddr(q->bufs[i], 0);
2448 if (fileio->bufs[i].vaddr == NULL) {
2449 ret = -EINVAL;
2450 goto err_reqbufs;
2451 }
2452 fileio->bufs[i].size = vb2_plane_size(q->bufs[i], 0);
2453 }
2454
2455 /*
2456 * Read mode requires pre queuing of all buffers.
2457 */
2458 if (read) {
2459 /*
2460 * Queue all buffers.
2461 */
2462 for (i = 0; i < q->num_buffers; i++) {
2463 struct vb2_buffer *b = fileio->b;
2464
2465 memset(b, 0, q->buf_struct_size);
2466 b->type = q->type;
2467 b->memory = q->memory;
2468 b->index = i;
2469 ret = vb2_core_qbuf(q, i, b);
2470 if (ret)
2471 goto err_reqbufs;
2472 fileio->bufs[i].queued = 1;
2473 }
2474 /*
2475 * All buffers have been queued, so mark that by setting
2476 * initial_index to q->num_buffers
2477 */
2478 fileio->initial_index = q->num_buffers;
2479 fileio->cur_index = q->num_buffers;
2480 }
2481
2482 /*
2483 * Start streaming.
2484 */
2485 ret = vb2_core_streamon(q, q->type);
2486 if (ret)
2487 goto err_reqbufs;
2488
2489 return ret;
2490
2491err_reqbufs:
2492 fileio->count = 0;
2493 vb2_core_reqbufs(q, fileio->memory, &fileio->count);
2494
2495err_kfree:
2496 q->fileio = NULL;
2497 kfree(fileio);
2498 return ret;
2499}
2500
2501/**
2502 * __vb2_cleanup_fileio() - free resourced used by file io emulator
2503 * @q: videobuf2 queue
2504 */
2505static int __vb2_cleanup_fileio(struct vb2_queue *q)
2506{
2507 struct vb2_fileio_data *fileio = q->fileio;
2508
2509 if (fileio) {
2510 vb2_core_streamoff(q, q->type);
2511 q->fileio = NULL;
2512 fileio->count = 0;
2513 vb2_core_reqbufs(q, fileio->memory, &fileio->count);
2514 kfree(fileio->b);
2515 kfree(fileio);
2516 dprintk(3, "file io emulator closed\n");
2517 }
2518 return 0;
2519}
2520
2521/**
2522 * __vb2_perform_fileio() - perform a single file io (read or write) operation
2523 * @q: videobuf2 queue
2524 * @data: pointed to target userspace buffer
2525 * @count: number of bytes to read or write
2526 * @ppos: file handle position tracking pointer
2527 * @nonblock: mode selector (1 means blocking calls, 0 means nonblocking)
2528 * @read: access mode selector (1 means read, 0 means write)
2529 */
2530static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_t count,
2531 loff_t *ppos, int nonblock, int read)
2532{
2533 struct vb2_fileio_data *fileio;
2534 struct vb2_fileio_buf *buf;
2535 bool is_multiplanar = q->is_multiplanar;
2536 /*
2537 * When using write() to write data to an output video node the vb2 core
2538 * should copy timestamps if V4L2_BUF_FLAG_TIMESTAMP_COPY is set. Nobody
2539 * else is able to provide this information with the write() operation.
2540 */
2541 bool copy_timestamp = !read && q->copy_timestamp;
2542 int ret, index;
2543
2544 dprintk(3, "mode %s, offset %ld, count %zd, %sblocking\n",
2545 read ? "read" : "write", (long)*ppos, count,
2546 nonblock ? "non" : "");
2547
2548 if (!data)
2549 return -EINVAL;
2550
2551 /*
2552 * Initialize emulator on first call.
2553 */
2554 if (!vb2_fileio_is_active(q)) {
2555 ret = __vb2_init_fileio(q, read);
2556 dprintk(3, "vb2_init_fileio result: %d\n", ret);
2557 if (ret)
2558 return ret;
2559 }
2560 fileio = q->fileio;
2561
2562 /*
2563 * Check if we need to dequeue the buffer.
2564 */
2565 index = fileio->cur_index;
2566 if (index >= q->num_buffers) {
2567 struct vb2_buffer *b = fileio->b;
2568
2569 /*
2570 * Call vb2_dqbuf to get buffer back.
2571 */
2572 memset(b, 0, q->buf_struct_size);
2573 b->type = q->type;
2574 b->memory = q->memory;
2575 ret = vb2_core_dqbuf(q, b, nonblock);
2576 dprintk(5, "vb2_dqbuf result: %d\n", ret);
2577 if (ret)
2578 return ret;
2579 fileio->dq_count += 1;
2580
2581 fileio->cur_index = index = b->index;
2582 buf = &fileio->bufs[index];
2583
2584 /*
2585 * Get number of bytes filled by the driver
2586 */
2587 buf->pos = 0;
2588 buf->queued = 0;
2589 buf->size = read ? vb2_get_plane_payload(q->bufs[index], 0)
2590 : vb2_plane_size(q->bufs[index], 0);
2591 /* Compensate for data_offset on read in the multiplanar case. */
2592 if (is_multiplanar && read &&
2593 b->planes[0].data_offset < buf->size) {
2594 buf->pos = b->planes[0].data_offset;
2595 buf->size -= buf->pos;
2596 }
2597 } else {
2598 buf = &fileio->bufs[index];
2599 }
2600
2601 /*
2602 * Limit count on last few bytes of the buffer.
2603 */
2604 if (buf->pos + count > buf->size) {
2605 count = buf->size - buf->pos;
2606 dprintk(5, "reducing read count: %zd\n", count);
2607 }
2608
2609 /*
2610 * Transfer data to userspace.
2611 */
2612 dprintk(3, "copying %zd bytes - buffer %d, offset %u\n",
2613 count, index, buf->pos);
2614 if (read)
2615 ret = copy_to_user(data, buf->vaddr + buf->pos, count);
2616 else
2617 ret = copy_from_user(buf->vaddr + buf->pos, data, count);
2618 if (ret) {
2619 dprintk(3, "error copying data\n");
2620 return -EFAULT;
2621 }
2622
2623 /*
2624 * Update counters.
2625 */
2626 buf->pos += count;
2627 *ppos += count;
2628
2629 /*
2630 * Queue next buffer if required.
2631 */
2632 if (buf->pos == buf->size || (!read && fileio->write_immediately)) {
2633 struct vb2_buffer *b = fileio->b;
2634
2635 /*
2636 * Check if this is the last buffer to read.
2637 */
2638 if (read && fileio->read_once && fileio->dq_count == 1) {
2639 dprintk(3, "read limit reached\n");
2640 return __vb2_cleanup_fileio(q);
2641 }
2642
2643 /*
2644 * Call vb2_qbuf and give buffer to the driver.
2645 */
2646 memset(b, 0, q->buf_struct_size);
2647 b->type = q->type;
2648 b->memory = q->memory;
2649 b->index = index;
2650 b->planes[0].bytesused = buf->pos;
2651
2652 if (copy_timestamp)
2653 b->timestamp = ktime_get_ns();
2654 ret = vb2_core_qbuf(q, index, b);
2655 dprintk(5, "vb2_dbuf result: %d\n", ret);
2656 if (ret)
2657 return ret;
2658
2659 /*
2660 * Buffer has been queued, update the status
2661 */
2662 buf->pos = 0;
2663 buf->queued = 1;
2664 buf->size = vb2_plane_size(q->bufs[index], 0);
2665 fileio->q_count += 1;
2666 /*
2667 * If we are queuing up buffers for the first time, then
2668 * increase initial_index by one.
2669 */
2670 if (fileio->initial_index < q->num_buffers)
2671 fileio->initial_index++;
2672 /*
2673 * The next buffer to use is either a buffer that's going to be
2674 * queued for the first time (initial_index < q->num_buffers)
2675 * or it is equal to q->num_buffers, meaning that the next
2676 * time we need to dequeue a buffer since we've now queued up
2677 * all the 'first time' buffers.
2678 */
2679 fileio->cur_index = fileio->initial_index;
2680 }
2681
2682 /*
2683 * Return proper number of bytes processed.
2684 */
2685 if (ret == 0)
2686 ret = count;
2687 return ret;
2688}
2689
2690size_t vb2_read(struct vb2_queue *q, char __user *data, size_t count,
2691 loff_t *ppos, int nonblocking)
2692{
2693 return __vb2_perform_fileio(q, data, count, ppos, nonblocking, 1);
2694}
2695EXPORT_SYMBOL_GPL(vb2_read);
2696
2697size_t vb2_write(struct vb2_queue *q, const char __user *data, size_t count,
2698 loff_t *ppos, int nonblocking)
2699{
2700 return __vb2_perform_fileio(q, (char __user *) data, count,
2701 ppos, nonblocking, 0);
2702}
2703EXPORT_SYMBOL_GPL(vb2_write);
2704
2705struct vb2_threadio_data {
2706 struct task_struct *thread;
2707 vb2_thread_fnc fnc;
2708 void *priv;
2709 bool stop;
2710};
2711
2712static int vb2_thread(void *data)
2713{
2714 struct vb2_queue *q = data;
2715 struct vb2_threadio_data *threadio = q->threadio;
2716 struct vb2_fileio_data *fileio = q->fileio;
2717 bool copy_timestamp = false;
2718 int prequeue = 0;
2719 int index = 0;
2720 int ret = 0;
2721
2722 if (q->is_output) {
2723 prequeue = q->num_buffers;
2724 copy_timestamp = q->copy_timestamp;
2725 }
2726
2727 set_freezable();
2728
2729 for (;;) {
2730 struct vb2_buffer *vb;
2731 struct vb2_buffer *b = fileio->b;
2732
2733 /*
2734 * Call vb2_dqbuf to get buffer back.
2735 */
2736 memset(b, 0, q->buf_struct_size);
2737 b->type = q->type;
2738 b->memory = q->memory;
2739 if (prequeue) {
2740 b->index = index++;
2741 prequeue--;
2742 } else {
2743 call_void_qop(q, wait_finish, q);
2744 if (!threadio->stop)
2745 ret = vb2_core_dqbuf(q, b, 0);
2746 call_void_qop(q, wait_prepare, q);
2747 dprintk(5, "file io: vb2_dqbuf result: %d\n", ret);
2748 }
2749 if (ret || threadio->stop)
2750 break;
2751 try_to_freeze();
2752
2753 vb = q->bufs[b->index];
2754 if (b->state == VB2_BUF_STATE_DONE)
2755 if (threadio->fnc(vb, threadio->priv))
2756 break;
2757 call_void_qop(q, wait_finish, q);
2758 if (copy_timestamp)
2759 b->timestamp = ktime_get_ns();;
2760 if (!threadio->stop)
2761 ret = vb2_core_qbuf(q, b->index, b);
2762 call_void_qop(q, wait_prepare, q);
2763 if (ret || threadio->stop)
2764 break;
2765 }
2766
2767 /* Hmm, linux becomes *very* unhappy without this ... */
2768 while (!kthread_should_stop()) {
2769 set_current_state(TASK_INTERRUPTIBLE);
2770 schedule();
2771 }
2772 return 0;
2773}
2774
2775/*
2776 * This function should not be used for anything else but the videobuf2-dvb
2777 * support. If you think you have another good use-case for this, then please
2778 * contact the linux-media mailinglist first.
2779 */
2780int vb2_thread_start(struct vb2_queue *q, vb2_thread_fnc fnc, void *priv,
2781 const char *thread_name)
2782{
2783 struct vb2_threadio_data *threadio;
2784 int ret = 0;
2785
2786 if (q->threadio)
2787 return -EBUSY;
2788 if (vb2_is_busy(q))
2789 return -EBUSY;
2790 if (WARN_ON(q->fileio))
2791 return -EBUSY;
2792
2793 threadio = kzalloc(sizeof(*threadio), GFP_KERNEL);
2794 if (threadio == NULL)
2795 return -ENOMEM;
2796 threadio->fnc = fnc;
2797 threadio->priv = priv;
2798
2799 ret = __vb2_init_fileio(q, !q->is_output);
2800 dprintk(3, "file io: vb2_init_fileio result: %d\n", ret);
2801 if (ret)
2802 goto nomem;
2803 q->threadio = threadio;
2804 threadio->thread = kthread_run(vb2_thread, q, "vb2-%s", thread_name);
2805 if (IS_ERR(threadio->thread)) {
2806 ret = PTR_ERR(threadio->thread);
2807 threadio->thread = NULL;
2808 goto nothread;
2809 }
2810 return 0;
2811
2812nothread:
2813 __vb2_cleanup_fileio(q);
2814nomem:
2815 kfree(threadio);
2816 return ret;
2817}
2818EXPORT_SYMBOL_GPL(vb2_thread_start);
2819
2820int vb2_thread_stop(struct vb2_queue *q)
2821{
2822 struct vb2_threadio_data *threadio = q->threadio;
2823 int err;
2824
2825 if (threadio == NULL)
2826 return 0;
2827 threadio->stop = true;
2828 /* Wake up all pending sleeps in the thread */
2829 vb2_queue_error(q);
2830 err = kthread_stop(threadio->thread);
2831 __vb2_cleanup_fileio(q);
2832 threadio->thread = NULL;
2833 kfree(threadio);
2834 q->threadio = NULL;
2835 return err;
2836}
2837EXPORT_SYMBOL_GPL(vb2_thread_stop);
2838
2839MODULE_DESCRIPTION("Media buffer core framework");
2094MODULE_AUTHOR("Pawel Osciak <pawel@osciak.com>, Marek Szyprowski"); 2840MODULE_AUTHOR("Pawel Osciak <pawel@osciak.com>, Marek Szyprowski");
2095MODULE_LICENSE("GPL"); 2841MODULE_LICENSE("GPL");
diff --git a/drivers/media/v4l2-core/videobuf2-internal.h b/drivers/media/v4l2-core/videobuf2-internal.h
deleted file mode 100644
index 79018c749282..000000000000
--- a/drivers/media/v4l2-core/videobuf2-internal.h
+++ /dev/null
@@ -1,161 +0,0 @@
1#ifndef _MEDIA_VIDEOBUF2_INTERNAL_H
2#define _MEDIA_VIDEOBUF2_INTERNAL_H
3
4#include <linux/err.h>
5#include <linux/kernel.h>
6#include <linux/module.h>
7#include <media/videobuf2-core.h>
8
9extern int vb2_debug;
10
11#define dprintk(level, fmt, arg...) \
12 do { \
13 if (vb2_debug >= level) \
14 pr_info("vb2: %s: " fmt, __func__, ## arg); \
15 } while (0)
16
17#ifdef CONFIG_VIDEO_ADV_DEBUG
18
19/*
20 * If advanced debugging is on, then count how often each op is called
21 * successfully, which can either be per-buffer or per-queue.
22 *
23 * This makes it easy to check that the 'init' and 'cleanup'
24 * (and variations thereof) stay balanced.
25 */
26
27#define log_memop(vb, op) \
28 dprintk(2, "call_memop(%p, %d, %s)%s\n", \
29 (vb)->vb2_queue, (vb)->index, #op, \
30 (vb)->vb2_queue->mem_ops->op ? "" : " (nop)")
31
32#define call_memop(vb, op, args...) \
33({ \
34 struct vb2_queue *_q = (vb)->vb2_queue; \
35 int err; \
36 \
37 log_memop(vb, op); \
38 err = _q->mem_ops->op ? _q->mem_ops->op(args) : 0; \
39 if (!err) \
40 (vb)->cnt_mem_ ## op++; \
41 err; \
42})
43
44#define call_ptr_memop(vb, op, args...) \
45({ \
46 struct vb2_queue *_q = (vb)->vb2_queue; \
47 void *ptr; \
48 \
49 log_memop(vb, op); \
50 ptr = _q->mem_ops->op ? _q->mem_ops->op(args) : NULL; \
51 if (!IS_ERR_OR_NULL(ptr)) \
52 (vb)->cnt_mem_ ## op++; \
53 ptr; \
54})
55
56#define call_void_memop(vb, op, args...) \
57({ \
58 struct vb2_queue *_q = (vb)->vb2_queue; \
59 \
60 log_memop(vb, op); \
61 if (_q->mem_ops->op) \
62 _q->mem_ops->op(args); \
63 (vb)->cnt_mem_ ## op++; \
64})
65
66#define log_qop(q, op) \
67 dprintk(2, "call_qop(%p, %s)%s\n", q, #op, \
68 (q)->ops->op ? "" : " (nop)")
69
70#define call_qop(q, op, args...) \
71({ \
72 int err; \
73 \
74 log_qop(q, op); \
75 err = (q)->ops->op ? (q)->ops->op(args) : 0; \
76 if (!err) \
77 (q)->cnt_ ## op++; \
78 err; \
79})
80
81#define call_void_qop(q, op, args...) \
82({ \
83 log_qop(q, op); \
84 if ((q)->ops->op) \
85 (q)->ops->op(args); \
86 (q)->cnt_ ## op++; \
87})
88
89#define log_vb_qop(vb, op, args...) \
90 dprintk(2, "call_vb_qop(%p, %d, %s)%s\n", \
91 (vb)->vb2_queue, (vb)->index, #op, \
92 (vb)->vb2_queue->ops->op ? "" : " (nop)")
93
94#define call_vb_qop(vb, op, args...) \
95({ \
96 int err; \
97 \
98 log_vb_qop(vb, op); \
99 err = (vb)->vb2_queue->ops->op ? \
100 (vb)->vb2_queue->ops->op(args) : 0; \
101 if (!err) \
102 (vb)->cnt_ ## op++; \
103 err; \
104})
105
106#define call_void_vb_qop(vb, op, args...) \
107({ \
108 log_vb_qop(vb, op); \
109 if ((vb)->vb2_queue->ops->op) \
110 (vb)->vb2_queue->ops->op(args); \
111 (vb)->cnt_ ## op++; \
112})
113
114#else
115
116#define call_memop(vb, op, args...) \
117 ((vb)->vb2_queue->mem_ops->op ? \
118 (vb)->vb2_queue->mem_ops->op(args) : 0)
119
120#define call_ptr_memop(vb, op, args...) \
121 ((vb)->vb2_queue->mem_ops->op ? \
122 (vb)->vb2_queue->mem_ops->op(args) : NULL)
123
124#define call_void_memop(vb, op, args...) \
125 do { \
126 if ((vb)->vb2_queue->mem_ops->op) \
127 (vb)->vb2_queue->mem_ops->op(args); \
128 } while (0)
129
130#define call_qop(q, op, args...) \
131 ((q)->ops->op ? (q)->ops->op(args) : 0)
132
133#define call_void_qop(q, op, args...) \
134 do { \
135 if ((q)->ops->op) \
136 (q)->ops->op(args); \
137 } while (0)
138
139#define call_vb_qop(vb, op, args...) \
140 ((vb)->vb2_queue->ops->op ? (vb)->vb2_queue->ops->op(args) : 0)
141
142#define call_void_vb_qop(vb, op, args...) \
143 do { \
144 if ((vb)->vb2_queue->ops->op) \
145 (vb)->vb2_queue->ops->op(args); \
146 } while (0)
147
148#endif
149
150#define call_bufop(q, op, args...) \
151({ \
152 int ret = 0; \
153 if (q && q->buf_ops && q->buf_ops->op) \
154 ret = q->buf_ops->op(args); \
155 ret; \
156})
157
158bool vb2_buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb);
159int vb2_verify_memory_type(struct vb2_queue *q,
160 enum vb2_memory memory, unsigned int type);
161#endif /* _MEDIA_VIDEOBUF2_INTERNAL_H */
diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c b/drivers/media/v4l2-core/videobuf2-v4l2.c
index 27b4b9e7c0c2..c9a28605511a 100644
--- a/drivers/media/v4l2-core/videobuf2-v4l2.c
+++ b/drivers/media/v4l2-core/videobuf2-v4l2.c
@@ -31,7 +31,14 @@
31 31
32#include <media/videobuf2-v4l2.h> 32#include <media/videobuf2-v4l2.h>
33 33
34#include "videobuf2-internal.h" 34static int debug;
35module_param(debug, int, 0644);
36
37#define dprintk(level, fmt, arg...) \
38 do { \
39 if (debug >= level) \
40 pr_info("vb2-v4l2: %s: " fmt, __func__, ## arg); \
41 } while (0)
35 42
36/* Flags that are set by the vb2 core */ 43/* Flags that are set by the vb2 core */
37#define V4L2_BUFFER_MASK_FLAGS (V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_QUEUED | \ 44#define V4L2_BUFFER_MASK_FLAGS (V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_QUEUED | \
@@ -52,7 +59,7 @@ static int __verify_planes_array(struct vb2_buffer *vb, const struct v4l2_buffer
52 return 0; 59 return 0;
53 60
54 /* Is memory for copying plane information present? */ 61 /* Is memory for copying plane information present? */
55 if (NULL == b->m.planes) { 62 if (b->m.planes == NULL) {
56 dprintk(1, "multi-planar buffer passed but " 63 dprintk(1, "multi-planar buffer passed but "
57 "planes array not provided\n"); 64 "planes array not provided\n");
58 return -EINVAL; 65 return -EINVAL;
@@ -107,7 +114,7 @@ static int __verify_length(struct vb2_buffer *vb, const struct v4l2_buffer *b)
107 return 0; 114 return 0;
108} 115}
109 116
110static int __set_timestamp(struct vb2_buffer *vb, const void *pb) 117static void __copy_timestamp(struct vb2_buffer *vb, const void *pb)
111{ 118{
112 const struct v4l2_buffer *b = pb; 119 const struct v4l2_buffer *b = pb;
113 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); 120 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
@@ -118,14 +125,12 @@ static int __set_timestamp(struct vb2_buffer *vb, const void *pb)
118 * For output buffers copy the timestamp if needed, 125 * For output buffers copy the timestamp if needed,
119 * and the timecode field and flag if needed. 126 * and the timecode field and flag if needed.
120 */ 127 */
121 if ((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) == 128 if (q->copy_timestamp)
122 V4L2_BUF_FLAG_TIMESTAMP_COPY) 129 vb->timestamp = timeval_to_ns(&b->timestamp);
123 vbuf->timestamp = b->timestamp;
124 vbuf->flags |= b->flags & V4L2_BUF_FLAG_TIMECODE; 130 vbuf->flags |= b->flags & V4L2_BUF_FLAG_TIMECODE;
125 if (b->flags & V4L2_BUF_FLAG_TIMECODE) 131 if (b->flags & V4L2_BUF_FLAG_TIMECODE)
126 vbuf->timecode = b->timecode; 132 vbuf->timecode = b->timecode;
127 } 133 }
128 return 0;
129}; 134};
130 135
131static void vb2_warn_zero_bytesused(struct vb2_buffer *vb) 136static void vb2_warn_zero_bytesused(struct vb2_buffer *vb)
@@ -176,7 +181,7 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b,
176 * __fill_v4l2_buffer() - fill in a struct v4l2_buffer with information to be 181 * __fill_v4l2_buffer() - fill in a struct v4l2_buffer with information to be
177 * returned to userspace 182 * returned to userspace
178 */ 183 */
179static int __fill_v4l2_buffer(struct vb2_buffer *vb, void *pb) 184static void __fill_v4l2_buffer(struct vb2_buffer *vb, void *pb)
180{ 185{
181 struct v4l2_buffer *b = pb; 186 struct v4l2_buffer *b = pb;
182 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); 187 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
@@ -191,7 +196,7 @@ static int __fill_v4l2_buffer(struct vb2_buffer *vb, void *pb)
191 196
192 b->flags = vbuf->flags; 197 b->flags = vbuf->flags;
193 b->field = vbuf->field; 198 b->field = vbuf->field;
194 b->timestamp = vbuf->timestamp; 199 b->timestamp = ns_to_timeval(vb->timestamp);
195 b->timecode = vbuf->timecode; 200 b->timecode = vbuf->timecode;
196 b->sequence = vbuf->sequence; 201 b->sequence = vbuf->sequence;
197 b->reserved2 = 0; 202 b->reserved2 = 0;
@@ -238,8 +243,7 @@ static int __fill_v4l2_buffer(struct vb2_buffer *vb, void *pb)
238 */ 243 */
239 b->flags &= ~V4L2_BUFFER_MASK_FLAGS; 244 b->flags &= ~V4L2_BUFFER_MASK_FLAGS;
240 b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK; 245 b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK;
241 if ((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) != 246 if (!q->copy_timestamp) {
242 V4L2_BUF_FLAG_TIMESTAMP_COPY) {
243 /* 247 /*
244 * For non-COPY timestamps, drop timestamp source bits 248 * For non-COPY timestamps, drop timestamp source bits
245 * and obtain the timestamp source from the queue. 249 * and obtain the timestamp source from the queue.
@@ -272,7 +276,10 @@ static int __fill_v4l2_buffer(struct vb2_buffer *vb, void *pb)
272 if (vb2_buffer_in_use(q, vb)) 276 if (vb2_buffer_in_use(q, vb))
273 b->flags |= V4L2_BUF_FLAG_MAPPED; 277 b->flags |= V4L2_BUF_FLAG_MAPPED;
274 278
275 return 0; 279 if (!q->is_output &&
280 b->flags & V4L2_BUF_FLAG_DONE &&
281 b->flags & V4L2_BUF_FLAG_LAST)
282 q->last_buffer_dequeued = true;
276} 283}
277 284
278/** 285/**
@@ -308,8 +315,7 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb,
308 "for an output buffer\n"); 315 "for an output buffer\n");
309 return -EINVAL; 316 return -EINVAL;
310 } 317 }
311 vbuf->timestamp.tv_sec = 0; 318 vb->timestamp = 0;
312 vbuf->timestamp.tv_usec = 0;
313 vbuf->sequence = 0; 319 vbuf->sequence = 0;
314 320
315 if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) { 321 if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) {
@@ -404,8 +410,7 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb,
404 410
405 /* Zero flags that the vb2 core handles */ 411 /* Zero flags that the vb2 core handles */
406 vbuf->flags = b->flags & ~V4L2_BUFFER_MASK_FLAGS; 412 vbuf->flags = b->flags & ~V4L2_BUFFER_MASK_FLAGS;
407 if ((vb->vb2_queue->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) != 413 if (!vb->vb2_queue->copy_timestamp || !V4L2_TYPE_IS_OUTPUT(b->type)) {
408 V4L2_BUF_FLAG_TIMESTAMP_COPY || !V4L2_TYPE_IS_OUTPUT(b->type)) {
409 /* 414 /*
410 * Non-COPY timestamps and non-OUTPUT queues will get 415 * Non-COPY timestamps and non-OUTPUT queues will get
411 * their timestamp and timestamp source flags from the 416 * their timestamp and timestamp source flags from the
@@ -434,7 +439,7 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb,
434static const struct vb2_buf_ops v4l2_buf_ops = { 439static const struct vb2_buf_ops v4l2_buf_ops = {
435 .fill_user_buffer = __fill_v4l2_buffer, 440 .fill_user_buffer = __fill_v4l2_buffer,
436 .fill_vb2_buffer = __fill_vb2_buffer, 441 .fill_vb2_buffer = __fill_vb2_buffer,
437 .set_timestamp = __set_timestamp, 442 .copy_timestamp = __copy_timestamp,
438}; 443};
439 444
440/** 445/**
@@ -466,8 +471,9 @@ int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b)
466 } 471 }
467 vb = q->bufs[b->index]; 472 vb = q->bufs[b->index];
468 ret = __verify_planes_array(vb, b); 473 ret = __verify_planes_array(vb, b);
469 474 if (!ret)
470 return ret ? ret : vb2_core_querybuf(q, b->index, b); 475 vb2_core_querybuf(q, b->index, b);
476 return ret;
471} 477}
472EXPORT_SYMBOL(vb2_querybuf); 478EXPORT_SYMBOL(vb2_querybuf);
473 479
@@ -525,14 +531,52 @@ EXPORT_SYMBOL_GPL(vb2_prepare_buf);
525 */ 531 */
526int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) 532int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create)
527{ 533{
528 int ret = vb2_verify_memory_type(q, create->memory, 534 unsigned requested_planes = 1;
529 create->format.type); 535 unsigned requested_sizes[VIDEO_MAX_PLANES];
536 struct v4l2_format *f = &create->format;
537 int ret = vb2_verify_memory_type(q, create->memory, f->type);
538 unsigned i;
530 539
531 create->index = q->num_buffers; 540 create->index = q->num_buffers;
532 if (create->count == 0) 541 if (create->count == 0)
533 return ret != -EBUSY ? ret : 0; 542 return ret != -EBUSY ? ret : 0;
543
544 switch (f->type) {
545 case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
546 case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
547 requested_planes = f->fmt.pix_mp.num_planes;
548 if (requested_planes == 0 ||
549 requested_planes > VIDEO_MAX_PLANES)
550 return -EINVAL;
551 for (i = 0; i < requested_planes; i++)
552 requested_sizes[i] =
553 f->fmt.pix_mp.plane_fmt[i].sizeimage;
554 break;
555 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
556 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
557 requested_sizes[0] = f->fmt.pix.sizeimage;
558 break;
559 case V4L2_BUF_TYPE_VBI_CAPTURE:
560 case V4L2_BUF_TYPE_VBI_OUTPUT:
561 requested_sizes[0] = f->fmt.vbi.samples_per_line *
562 (f->fmt.vbi.count[0] + f->fmt.vbi.count[1]);
563 break;
564 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
565 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
566 requested_sizes[0] = f->fmt.sliced.io_size;
567 break;
568 case V4L2_BUF_TYPE_SDR_CAPTURE:
569 case V4L2_BUF_TYPE_SDR_OUTPUT:
570 requested_sizes[0] = f->fmt.sdr.buffersize;
571 break;
572 default:
573 return -EINVAL;
574 }
575 for (i = 0; i < requested_planes; i++)
576 if (requested_sizes[i] == 0)
577 return -EINVAL;
534 return ret ? ret : vb2_core_create_bufs(q, create->memory, 578 return ret ? ret : vb2_core_create_bufs(q, create->memory,
535 &create->count, &create->format); 579 &create->count, requested_planes, requested_sizes);
536} 580}
537EXPORT_SYMBOL_GPL(vb2_create_bufs); 581EXPORT_SYMBOL_GPL(vb2_create_bufs);
538 582
@@ -583,10 +627,6 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b,
583 627
584 ret = vb2_core_dqbuf(q, b, nonblocking); 628 ret = vb2_core_dqbuf(q, b, nonblocking);
585 629
586 if (!ret && !q->is_output &&
587 b->flags & V4L2_BUF_FLAG_LAST)
588 q->last_buffer_dequeued = true;
589
590 return ret; 630 return ret;
591} 631}
592 632
@@ -723,14 +763,13 @@ int vb2_queue_init(struct vb2_queue *q)
723 q->buf_ops = &v4l2_buf_ops; 763 q->buf_ops = &v4l2_buf_ops;
724 q->is_multiplanar = V4L2_TYPE_IS_MULTIPLANAR(q->type); 764 q->is_multiplanar = V4L2_TYPE_IS_MULTIPLANAR(q->type);
725 q->is_output = V4L2_TYPE_IS_OUTPUT(q->type); 765 q->is_output = V4L2_TYPE_IS_OUTPUT(q->type);
766 q->copy_timestamp = (q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK)
767 == V4L2_BUF_FLAG_TIMESTAMP_COPY;
726 768
727 return vb2_core_queue_init(q); 769 return vb2_core_queue_init(q);
728} 770}
729EXPORT_SYMBOL_GPL(vb2_queue_init); 771EXPORT_SYMBOL_GPL(vb2_queue_init);
730 772
731static int __vb2_init_fileio(struct vb2_queue *q, int read);
732static int __vb2_cleanup_fileio(struct vb2_queue *q);
733
734/** 773/**
735 * vb2_queue_release() - stop streaming, release the queue and free memory 774 * vb2_queue_release() - stop streaming, release the queue and free memory
736 * @q: videobuf2 queue 775 * @q: videobuf2 queue
@@ -741,7 +780,6 @@ static int __vb2_cleanup_fileio(struct vb2_queue *q);
741 */ 780 */
742void vb2_queue_release(struct vb2_queue *q) 781void vb2_queue_release(struct vb2_queue *q)
743{ 782{
744 __vb2_cleanup_fileio(q);
745 vb2_core_queue_release(q); 783 vb2_core_queue_release(q);
746} 784}
747EXPORT_SYMBOL_GPL(vb2_queue_release); 785EXPORT_SYMBOL_GPL(vb2_queue_release);
@@ -769,9 +807,7 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
769{ 807{
770 struct video_device *vfd = video_devdata(file); 808 struct video_device *vfd = video_devdata(file);
771 unsigned long req_events = poll_requested_events(wait); 809 unsigned long req_events = poll_requested_events(wait);
772 struct vb2_buffer *vb = NULL;
773 unsigned int res = 0; 810 unsigned int res = 0;
774 unsigned long flags;
775 811
776 if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) { 812 if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) {
777 struct v4l2_fh *fh = file->private_data; 813 struct v4l2_fh *fh = file->private_data;
@@ -782,611 +818,18 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
782 poll_wait(file, &fh->wait, wait); 818 poll_wait(file, &fh->wait, wait);
783 } 819 }
784 820
785 if (!q->is_output && !(req_events & (POLLIN | POLLRDNORM)))
786 return res;
787 if (q->is_output && !(req_events & (POLLOUT | POLLWRNORM)))
788 return res;
789
790 /*
791 * Start file I/O emulator only if streaming API has not been used yet.
792 */
793 if (q->num_buffers == 0 && !vb2_fileio_is_active(q)) {
794 if (!q->is_output && (q->io_modes & VB2_READ) &&
795 (req_events & (POLLIN | POLLRDNORM))) {
796 if (__vb2_init_fileio(q, 1))
797 return res | POLLERR;
798 }
799 if (q->is_output && (q->io_modes & VB2_WRITE) &&
800 (req_events & (POLLOUT | POLLWRNORM))) {
801 if (__vb2_init_fileio(q, 0))
802 return res | POLLERR;
803 /*
804 * Write to OUTPUT queue can be done immediately.
805 */
806 return res | POLLOUT | POLLWRNORM;
807 }
808 }
809
810 /*
811 * There is nothing to wait for if the queue isn't streaming, or if the
812 * error flag is set.
813 */
814 if (!vb2_is_streaming(q) || q->error)
815 return res | POLLERR;
816 /* 821 /*
817 * For compatibility with vb1: if QBUF hasn't been called yet, then 822 * For compatibility with vb1: if QBUF hasn't been called yet, then
818 * return POLLERR as well. This only affects capture queues, output 823 * return POLLERR as well. This only affects capture queues, output
819 * queues will always initialize waiting_for_buffers to false. 824 * queues will always initialize waiting_for_buffers to false.
820 */ 825 */
821 if (q->waiting_for_buffers) 826 if (q->waiting_for_buffers && (req_events & (POLLIN | POLLRDNORM)))
822 return res | POLLERR; 827 return POLLERR;
823
824 /*
825 * For output streams you can write as long as there are fewer buffers
826 * queued than there are buffers available.
827 */
828 if (q->is_output && q->queued_count < q->num_buffers)
829 return res | POLLOUT | POLLWRNORM;
830
831 if (list_empty(&q->done_list)) {
832 /*
833 * If the last buffer was dequeued from a capture queue,
834 * return immediately. DQBUF will return -EPIPE.
835 */
836 if (q->last_buffer_dequeued)
837 return res | POLLIN | POLLRDNORM;
838
839 poll_wait(file, &q->done_wq, wait);
840 }
841 828
842 /* 829 return res | vb2_core_poll(q, file, wait);
843 * Take first buffer available for dequeuing.
844 */
845 spin_lock_irqsave(&q->done_lock, flags);
846 if (!list_empty(&q->done_list))
847 vb = list_first_entry(&q->done_list, struct vb2_buffer,
848 done_entry);
849 spin_unlock_irqrestore(&q->done_lock, flags);
850
851 if (vb && (vb->state == VB2_BUF_STATE_DONE
852 || vb->state == VB2_BUF_STATE_ERROR)) {
853 return (q->is_output) ?
854 res | POLLOUT | POLLWRNORM :
855 res | POLLIN | POLLRDNORM;
856 }
857 return res;
858} 830}
859EXPORT_SYMBOL_GPL(vb2_poll); 831EXPORT_SYMBOL_GPL(vb2_poll);
860 832
861/**
862 * struct vb2_fileio_buf - buffer context used by file io emulator
863 *
864 * vb2 provides a compatibility layer and emulator of file io (read and
865 * write) calls on top of streaming API. This structure is used for
866 * tracking context related to the buffers.
867 */
868struct vb2_fileio_buf {
869 void *vaddr;
870 unsigned int size;
871 unsigned int pos;
872 unsigned int queued:1;
873};
874
875/**
876 * struct vb2_fileio_data - queue context used by file io emulator
877 *
878 * @cur_index: the index of the buffer currently being read from or
879 * written to. If equal to q->num_buffers then a new buffer
880 * must be dequeued.
881 * @initial_index: in the read() case all buffers are queued up immediately
882 * in __vb2_init_fileio() and __vb2_perform_fileio() just cycles
883 * buffers. However, in the write() case no buffers are initially
884 * queued, instead whenever a buffer is full it is queued up by
885 * __vb2_perform_fileio(). Only once all available buffers have
886 * been queued up will __vb2_perform_fileio() start to dequeue
887 * buffers. This means that initially __vb2_perform_fileio()
888 * needs to know what buffer index to use when it is queuing up
889 * the buffers for the first time. That initial index is stored
890 * in this field. Once it is equal to q->num_buffers all
891 * available buffers have been queued and __vb2_perform_fileio()
892 * should start the normal dequeue/queue cycle.
893 *
894 * vb2 provides a compatibility layer and emulator of file io (read and
895 * write) calls on top of streaming API. For proper operation it required
896 * this structure to save the driver state between each call of the read
897 * or write function.
898 */
899struct vb2_fileio_data {
900 struct v4l2_requestbuffers req;
901 struct v4l2_plane p;
902 struct v4l2_buffer b;
903 struct vb2_fileio_buf bufs[VB2_MAX_FRAME];
904 unsigned int cur_index;
905 unsigned int initial_index;
906 unsigned int q_count;
907 unsigned int dq_count;
908 unsigned read_once:1;
909 unsigned write_immediately:1;
910};
911
912/**
913 * __vb2_init_fileio() - initialize file io emulator
914 * @q: videobuf2 queue
915 * @read: mode selector (1 means read, 0 means write)
916 */
917static int __vb2_init_fileio(struct vb2_queue *q, int read)
918{
919 struct vb2_fileio_data *fileio;
920 int i, ret;
921 unsigned int count = 0;
922
923 /*
924 * Sanity check
925 */
926 if (WARN_ON((read && !(q->io_modes & VB2_READ)) ||
927 (!read && !(q->io_modes & VB2_WRITE))))
928 return -EINVAL;
929
930 /*
931 * Check if device supports mapping buffers to kernel virtual space.
932 */
933 if (!q->mem_ops->vaddr)
934 return -EBUSY;
935
936 /*
937 * Check if streaming api has not been already activated.
938 */
939 if (q->streaming || q->num_buffers > 0)
940 return -EBUSY;
941
942 /*
943 * Start with count 1, driver can increase it in queue_setup()
944 */
945 count = 1;
946
947 dprintk(3, "setting up file io: mode %s, count %d, read_once %d, write_immediately %d\n",
948 (read) ? "read" : "write", count, q->fileio_read_once,
949 q->fileio_write_immediately);
950
951 fileio = kzalloc(sizeof(struct vb2_fileio_data), GFP_KERNEL);
952 if (fileio == NULL)
953 return -ENOMEM;
954
955 fileio->read_once = q->fileio_read_once;
956 fileio->write_immediately = q->fileio_write_immediately;
957
958 /*
959 * Request buffers and use MMAP type to force driver
960 * to allocate buffers by itself.
961 */
962 fileio->req.count = count;
963 fileio->req.memory = VB2_MEMORY_MMAP;
964 fileio->req.type = q->type;
965 q->fileio = fileio;
966 ret = vb2_core_reqbufs(q, fileio->req.memory, &fileio->req.count);
967 if (ret)
968 goto err_kfree;
969
970 /*
971 * Check if plane_count is correct
972 * (multiplane buffers are not supported).
973 */
974 if (q->bufs[0]->num_planes != 1) {
975 ret = -EBUSY;
976 goto err_reqbufs;
977 }
978
979 /*
980 * Get kernel address of each buffer.
981 */
982 for (i = 0; i < q->num_buffers; i++) {
983 fileio->bufs[i].vaddr = vb2_plane_vaddr(q->bufs[i], 0);
984 if (fileio->bufs[i].vaddr == NULL) {
985 ret = -EINVAL;
986 goto err_reqbufs;
987 }
988 fileio->bufs[i].size = vb2_plane_size(q->bufs[i], 0);
989 }
990
991 /*
992 * Read mode requires pre queuing of all buffers.
993 */
994 if (read) {
995 bool is_multiplanar = q->is_multiplanar;
996
997 /*
998 * Queue all buffers.
999 */
1000 for (i = 0; i < q->num_buffers; i++) {
1001 struct v4l2_buffer *b = &fileio->b;
1002
1003 memset(b, 0, sizeof(*b));
1004 b->type = q->type;
1005 if (is_multiplanar) {
1006 memset(&fileio->p, 0, sizeof(fileio->p));
1007 b->m.planes = &fileio->p;
1008 b->length = 1;
1009 }
1010 b->memory = q->memory;
1011 b->index = i;
1012 ret = vb2_internal_qbuf(q, b);
1013 if (ret)
1014 goto err_reqbufs;
1015 fileio->bufs[i].queued = 1;
1016 }
1017 /*
1018 * All buffers have been queued, so mark that by setting
1019 * initial_index to q->num_buffers
1020 */
1021 fileio->initial_index = q->num_buffers;
1022 fileio->cur_index = q->num_buffers;
1023 }
1024
1025 /*
1026 * Start streaming.
1027 */
1028 ret = vb2_core_streamon(q, q->type);
1029 if (ret)
1030 goto err_reqbufs;
1031
1032 return ret;
1033
1034err_reqbufs:
1035 fileio->req.count = 0;
1036 vb2_core_reqbufs(q, fileio->req.memory, &fileio->req.count);
1037
1038err_kfree:
1039 q->fileio = NULL;
1040 kfree(fileio);
1041 return ret;
1042}
1043
1044/**
1045 * __vb2_cleanup_fileio() - free resourced used by file io emulator
1046 * @q: videobuf2 queue
1047 */
1048static int __vb2_cleanup_fileio(struct vb2_queue *q)
1049{
1050 struct vb2_fileio_data *fileio = q->fileio;
1051
1052 if (fileio) {
1053 vb2_core_streamoff(q, q->type);
1054 q->fileio = NULL;
1055 fileio->req.count = 0;
1056 vb2_reqbufs(q, &fileio->req);
1057 kfree(fileio);
1058 dprintk(3, "file io emulator closed\n");
1059 }
1060 return 0;
1061}
1062
1063/**
1064 * __vb2_perform_fileio() - perform a single file io (read or write) operation
1065 * @q: videobuf2 queue
1066 * @data: pointed to target userspace buffer
1067 * @count: number of bytes to read or write
1068 * @ppos: file handle position tracking pointer
1069 * @nonblock: mode selector (1 means blocking calls, 0 means nonblocking)
1070 * @read: access mode selector (1 means read, 0 means write)
1071 */
1072static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_t count,
1073 loff_t *ppos, int nonblock, int read)
1074{
1075 struct vb2_fileio_data *fileio;
1076 struct vb2_fileio_buf *buf;
1077 bool is_multiplanar = q->is_multiplanar;
1078 /*
1079 * When using write() to write data to an output video node the vb2 core
1080 * should set timestamps if V4L2_BUF_FLAG_TIMESTAMP_COPY is set. Nobody
1081 * else is able to provide this information with the write() operation.
1082 */
1083 bool set_timestamp = !read &&
1084 (q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
1085 V4L2_BUF_FLAG_TIMESTAMP_COPY;
1086 int ret, index;
1087
1088 dprintk(3, "mode %s, offset %ld, count %zd, %sblocking\n",
1089 read ? "read" : "write", (long)*ppos, count,
1090 nonblock ? "non" : "");
1091
1092 if (!data)
1093 return -EINVAL;
1094
1095 /*
1096 * Initialize emulator on first call.
1097 */
1098 if (!vb2_fileio_is_active(q)) {
1099 ret = __vb2_init_fileio(q, read);
1100 dprintk(3, "vb2_init_fileio result: %d\n", ret);
1101 if (ret)
1102 return ret;
1103 }
1104 fileio = q->fileio;
1105
1106 /*
1107 * Check if we need to dequeue the buffer.
1108 */
1109 index = fileio->cur_index;
1110 if (index >= q->num_buffers) {
1111 /*
1112 * Call vb2_dqbuf to get buffer back.
1113 */
1114 memset(&fileio->b, 0, sizeof(fileio->b));
1115 fileio->b.type = q->type;
1116 fileio->b.memory = q->memory;
1117 if (is_multiplanar) {
1118 memset(&fileio->p, 0, sizeof(fileio->p));
1119 fileio->b.m.planes = &fileio->p;
1120 fileio->b.length = 1;
1121 }
1122 ret = vb2_internal_dqbuf(q, &fileio->b, nonblock);
1123 dprintk(5, "vb2_dqbuf result: %d\n", ret);
1124 if (ret)
1125 return ret;
1126 fileio->dq_count += 1;
1127
1128 fileio->cur_index = index = fileio->b.index;
1129 buf = &fileio->bufs[index];
1130
1131 /*
1132 * Get number of bytes filled by the driver
1133 */
1134 buf->pos = 0;
1135 buf->queued = 0;
1136 buf->size = read ? vb2_get_plane_payload(q->bufs[index], 0)
1137 : vb2_plane_size(q->bufs[index], 0);
1138 /* Compensate for data_offset on read in the multiplanar case. */
1139 if (is_multiplanar && read &&
1140 fileio->b.m.planes[0].data_offset < buf->size) {
1141 buf->pos = fileio->b.m.planes[0].data_offset;
1142 buf->size -= buf->pos;
1143 }
1144 } else {
1145 buf = &fileio->bufs[index];
1146 }
1147
1148 /*
1149 * Limit count on last few bytes of the buffer.
1150 */
1151 if (buf->pos + count > buf->size) {
1152 count = buf->size - buf->pos;
1153 dprintk(5, "reducing read count: %zd\n", count);
1154 }
1155
1156 /*
1157 * Transfer data to userspace.
1158 */
1159 dprintk(3, "copying %zd bytes - buffer %d, offset %u\n",
1160 count, index, buf->pos);
1161 if (read)
1162 ret = copy_to_user(data, buf->vaddr + buf->pos, count);
1163 else
1164 ret = copy_from_user(buf->vaddr + buf->pos, data, count);
1165 if (ret) {
1166 dprintk(3, "error copying data\n");
1167 return -EFAULT;
1168 }
1169
1170 /*
1171 * Update counters.
1172 */
1173 buf->pos += count;
1174 *ppos += count;
1175
1176 /*
1177 * Queue next buffer if required.
1178 */
1179 if (buf->pos == buf->size || (!read && fileio->write_immediately)) {
1180 /*
1181 * Check if this is the last buffer to read.
1182 */
1183 if (read && fileio->read_once && fileio->dq_count == 1) {
1184 dprintk(3, "read limit reached\n");
1185 return __vb2_cleanup_fileio(q);
1186 }
1187
1188 /*
1189 * Call vb2_qbuf and give buffer to the driver.
1190 */
1191 memset(&fileio->b, 0, sizeof(fileio->b));
1192 fileio->b.type = q->type;
1193 fileio->b.memory = q->memory;
1194 fileio->b.index = index;
1195 fileio->b.bytesused = buf->pos;
1196 if (is_multiplanar) {
1197 memset(&fileio->p, 0, sizeof(fileio->p));
1198 fileio->p.bytesused = buf->pos;
1199 fileio->b.m.planes = &fileio->p;
1200 fileio->b.length = 1;
1201 }
1202 if (set_timestamp)
1203 v4l2_get_timestamp(&fileio->b.timestamp);
1204 ret = vb2_internal_qbuf(q, &fileio->b);
1205 dprintk(5, "vb2_dbuf result: %d\n", ret);
1206 if (ret)
1207 return ret;
1208
1209 /*
1210 * Buffer has been queued, update the status
1211 */
1212 buf->pos = 0;
1213 buf->queued = 1;
1214 buf->size = vb2_plane_size(q->bufs[index], 0);
1215 fileio->q_count += 1;
1216 /*
1217 * If we are queuing up buffers for the first time, then
1218 * increase initial_index by one.
1219 */
1220 if (fileio->initial_index < q->num_buffers)
1221 fileio->initial_index++;
1222 /*
1223 * The next buffer to use is either a buffer that's going to be
1224 * queued for the first time (initial_index < q->num_buffers)
1225 * or it is equal to q->num_buffers, meaning that the next
1226 * time we need to dequeue a buffer since we've now queued up
1227 * all the 'first time' buffers.
1228 */
1229 fileio->cur_index = fileio->initial_index;
1230 }
1231
1232 /*
1233 * Return proper number of bytes processed.
1234 */
1235 if (ret == 0)
1236 ret = count;
1237 return ret;
1238}
1239
1240size_t vb2_read(struct vb2_queue *q, char __user *data, size_t count,
1241 loff_t *ppos, int nonblocking)
1242{
1243 return __vb2_perform_fileio(q, data, count, ppos, nonblocking, 1);
1244}
1245EXPORT_SYMBOL_GPL(vb2_read);
1246
1247size_t vb2_write(struct vb2_queue *q, const char __user *data, size_t count,
1248 loff_t *ppos, int nonblocking)
1249{
1250 return __vb2_perform_fileio(q, (char __user *) data, count,
1251 ppos, nonblocking, 0);
1252}
1253EXPORT_SYMBOL_GPL(vb2_write);
1254
1255struct vb2_threadio_data {
1256 struct task_struct *thread;
1257 vb2_thread_fnc fnc;
1258 void *priv;
1259 bool stop;
1260};
1261
1262static int vb2_thread(void *data)
1263{
1264 struct vb2_queue *q = data;
1265 struct vb2_threadio_data *threadio = q->threadio;
1266 struct vb2_fileio_data *fileio = q->fileio;
1267 bool set_timestamp = false;
1268 int prequeue = 0;
1269 int index = 0;
1270 int ret = 0;
1271
1272 if (q->is_output) {
1273 prequeue = q->num_buffers;
1274 set_timestamp =
1275 (q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
1276 V4L2_BUF_FLAG_TIMESTAMP_COPY;
1277 }
1278
1279 set_freezable();
1280
1281 for (;;) {
1282 struct vb2_buffer *vb;
1283
1284 /*
1285 * Call vb2_dqbuf to get buffer back.
1286 */
1287 memset(&fileio->b, 0, sizeof(fileio->b));
1288 fileio->b.type = q->type;
1289 fileio->b.memory = q->memory;
1290 if (prequeue) {
1291 fileio->b.index = index++;
1292 prequeue--;
1293 } else {
1294 call_void_qop(q, wait_finish, q);
1295 if (!threadio->stop)
1296 ret = vb2_internal_dqbuf(q, &fileio->b, 0);
1297 call_void_qop(q, wait_prepare, q);
1298 dprintk(5, "file io: vb2_dqbuf result: %d\n", ret);
1299 }
1300 if (ret || threadio->stop)
1301 break;
1302 try_to_freeze();
1303
1304 vb = q->bufs[fileio->b.index];
1305 if (!(fileio->b.flags & V4L2_BUF_FLAG_ERROR))
1306 if (threadio->fnc(vb, threadio->priv))
1307 break;
1308 call_void_qop(q, wait_finish, q);
1309 if (set_timestamp)
1310 v4l2_get_timestamp(&fileio->b.timestamp);
1311 if (!threadio->stop)
1312 ret = vb2_internal_qbuf(q, &fileio->b);
1313 call_void_qop(q, wait_prepare, q);
1314 if (ret || threadio->stop)
1315 break;
1316 }
1317
1318 /* Hmm, linux becomes *very* unhappy without this ... */
1319 while (!kthread_should_stop()) {
1320 set_current_state(TASK_INTERRUPTIBLE);
1321 schedule();
1322 }
1323 return 0;
1324}
1325
1326/*
1327 * This function should not be used for anything else but the videobuf2-dvb
1328 * support. If you think you have another good use-case for this, then please
1329 * contact the linux-media mailinglist first.
1330 */
1331int vb2_thread_start(struct vb2_queue *q, vb2_thread_fnc fnc, void *priv,
1332 const char *thread_name)
1333{
1334 struct vb2_threadio_data *threadio;
1335 int ret = 0;
1336
1337 if (q->threadio)
1338 return -EBUSY;
1339 if (vb2_is_busy(q))
1340 return -EBUSY;
1341 if (WARN_ON(q->fileio))
1342 return -EBUSY;
1343
1344 threadio = kzalloc(sizeof(*threadio), GFP_KERNEL);
1345 if (threadio == NULL)
1346 return -ENOMEM;
1347 threadio->fnc = fnc;
1348 threadio->priv = priv;
1349
1350 ret = __vb2_init_fileio(q, !q->is_output);
1351 dprintk(3, "file io: vb2_init_fileio result: %d\n", ret);
1352 if (ret)
1353 goto nomem;
1354 q->threadio = threadio;
1355 threadio->thread = kthread_run(vb2_thread, q, "vb2-%s", thread_name);
1356 if (IS_ERR(threadio->thread)) {
1357 ret = PTR_ERR(threadio->thread);
1358 threadio->thread = NULL;
1359 goto nothread;
1360 }
1361 return 0;
1362
1363nothread:
1364 __vb2_cleanup_fileio(q);
1365nomem:
1366 kfree(threadio);
1367 return ret;
1368}
1369EXPORT_SYMBOL_GPL(vb2_thread_start);
1370
1371int vb2_thread_stop(struct vb2_queue *q)
1372{
1373 struct vb2_threadio_data *threadio = q->threadio;
1374 int err;
1375
1376 if (threadio == NULL)
1377 return 0;
1378 threadio->stop = true;
1379 /* Wake up all pending sleeps in the thread */
1380 vb2_queue_error(q);
1381 err = kthread_stop(threadio->thread);
1382 __vb2_cleanup_fileio(q);
1383 threadio->thread = NULL;
1384 kfree(threadio);
1385 q->threadio = NULL;
1386 return err;
1387}
1388EXPORT_SYMBOL_GPL(vb2_thread_stop);
1389
1390/* 833/*
1391 * The following functions are not part of the vb2 core API, but are helper 834 * The following functions are not part of the vb2 core API, but are helper
1392 * functions that plug into struct v4l2_ioctl_ops, struct v4l2_file_operations 835 * functions that plug into struct v4l2_ioctl_ops, struct v4l2_file_operations
@@ -1440,8 +883,8 @@ int vb2_ioctl_create_bufs(struct file *file, void *priv,
1440 return res; 883 return res;
1441 if (vb2_queue_is_busy(vdev, file)) 884 if (vb2_queue_is_busy(vdev, file))
1442 return -EBUSY; 885 return -EBUSY;
1443 res = vb2_core_create_bufs(vdev->queue, p->memory, &p->count, 886
1444 &p->format); 887 res = vb2_create_bufs(vdev->queue, p);
1445 if (res == 0) 888 if (res == 0)
1446 vdev->queue->owner = file->private_data; 889 vdev->queue->owner = file->private_data;
1447 return res; 890 return res;
diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c
index 6ce36d6970a4..c9339f85359b 100644
--- a/drivers/mfd/timberdale.c
+++ b/drivers/mfd/timberdale.c
@@ -39,8 +39,8 @@
39#include <linux/spi/max7301.h> 39#include <linux/spi/max7301.h>
40#include <linux/spi/mc33880.h> 40#include <linux/spi/mc33880.h>
41 41
42#include <media/timb_radio.h> 42#include <linux/platform_data/media/timb_radio.h>
43#include <media/timb_video.h> 43#include <linux/platform_data/media/timb_video.h>
44 44
45#include <linux/timb_dma.h> 45#include <linux/timb_dma.h>
46 46
diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c
index b10d6016b993..93bffbac8fc7 100644
--- a/drivers/staging/media/bcm2048/radio-bcm2048.c
+++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
@@ -1000,8 +1000,8 @@ static int bcm2048_set_fm_search_tune_mode(struct bcm2048_device *bdev,
1000 timeout = BCM2048_AUTO_SEARCH_TIMEOUT; 1000 timeout = BCM2048_AUTO_SEARCH_TIMEOUT;
1001 1001
1002 if (!wait_for_completion_timeout(&bdev->compl, 1002 if (!wait_for_completion_timeout(&bdev->compl,
1003 msecs_to_jiffies(timeout))) 1003 msecs_to_jiffies(timeout)))
1004 dev_err(&bdev->client->dev, "IRQ timeout.\n"); 1004 dev_err(&bdev->client->dev, "IRQ timeout.\n");
1005 1005
1006 if (value) 1006 if (value)
1007 if (!bdev->scan_state) 1007 if (!bdev->scan_state)
diff --git a/drivers/staging/media/davinci_vpfe/Kconfig b/drivers/staging/media/davinci_vpfe/Kconfig
index 4de2f082491d..f40a06954a92 100644
--- a/drivers/staging/media/davinci_vpfe/Kconfig
+++ b/drivers/staging/media/davinci_vpfe/Kconfig
@@ -2,6 +2,8 @@ config VIDEO_DM365_VPFE
2 tristate "DM365 VPFE Media Controller Capture Driver" 2 tristate "DM365 VPFE Media Controller Capture Driver"
3 depends on VIDEO_V4L2 && ARCH_DAVINCI_DM365 && !VIDEO_DM365_ISIF 3 depends on VIDEO_V4L2 && ARCH_DAVINCI_DM365 && !VIDEO_DM365_ISIF
4 depends on HAS_DMA 4 depends on HAS_DMA
5 depends on VIDEO_V4L2_SUBDEV_API
6 depends on VIDEO_DAVINCI_VPBE_DISPLAY
5 select VIDEOBUF2_DMA_CONTIG 7 select VIDEOBUF2_DMA_CONTIG
6 help 8 help
7 Support for DM365 VPFE based Media Controller Capture driver. 9 Support for DM365 VPFE based Media Controller Capture driver.
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
index b1dfa2ccc4ef..c492914768ea 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
@@ -1536,8 +1536,9 @@ ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1536 * @fse: pointer to v4l2_subdev_frame_size_enum structure. 1536 * @fse: pointer to v4l2_subdev_frame_size_enum structure.
1537 */ 1537 */
1538static int 1538static int
1539ipipe_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, 1539ipipe_enum_frame_size(struct v4l2_subdev *sd,
1540 struct v4l2_subdev_frame_size_enum *fse) 1540 struct v4l2_subdev_pad_config *cfg,
1541 struct v4l2_subdev_frame_size_enum *fse)
1541{ 1542{
1542 struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd); 1543 struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd);
1543 struct v4l2_mbus_framefmt format; 1544 struct v4l2_mbus_framefmt format;
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
index 2a3a56b88de1..b1d5e23ae6e0 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
@@ -254,7 +254,7 @@ int config_ipipe_hw(struct vpfe_ipipe_device *ipipe)
254 void __iomem *ipipe_base = ipipe->base_addr; 254 void __iomem *ipipe_base = ipipe->base_addr;
255 struct v4l2_mbus_framefmt *outformat; 255 struct v4l2_mbus_framefmt *outformat;
256 u32 color_pat; 256 u32 color_pat;
257 u32 ipipe_mode; 257 int ipipe_mode;
258 u32 data_path; 258 u32 data_path;
259 259
260 /* enable clock to IPIPE */ 260 /* enable clock to IPIPE */
diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c b/drivers/staging/media/davinci_vpfe/dm365_resizer.c
index acb293ed9c91..d892fee3f52f 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c
@@ -63,16 +63,11 @@ resizer_calculate_line_length(u32 pix, int width, int height,
63 if (pix == MEDIA_BUS_FMT_UYVY8_2X8 || 63 if (pix == MEDIA_BUS_FMT_UYVY8_2X8 ||
64 pix == MEDIA_BUS_FMT_SGRBG12_1X12) { 64 pix == MEDIA_BUS_FMT_SGRBG12_1X12) {
65 *line_len = width << 1; 65 *line_len = width << 1;
66 } else if (pix == MEDIA_BUS_FMT_Y8_1X8 ||
67 pix == MEDIA_BUS_FMT_UV8_1X8) {
68 *line_len = width;
69 *line_len_c = width;
70 } else { 66 } else {
71 /* YUV 420 */
72 /* round width to upper 32 byte boundary */
73 *line_len = width; 67 *line_len = width;
74 *line_len_c = width; 68 *line_len_c = width;
75 } 69 }
70
76 /* adjust the line len to be a multiple of 32 */ 71 /* adjust the line len to be a multiple of 32 */
77 *line_len += 31; 72 *line_len += 31;
78 *line_len &= ~0x1f; 73 *line_len &= ~0x1f;
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
index 01df0683e950..69b678ca40c0 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
@@ -227,7 +227,7 @@ static int vpfe_enable_clock(struct vpfe_device *vpfe_dev)
227 return 0; 227 return 0;
228 228
229 vpfe_dev->clks = kcalloc(vpfe_cfg->num_clocks, 229 vpfe_dev->clks = kcalloc(vpfe_cfg->num_clocks,
230 sizeof(struct clock *), GFP_KERNEL); 230 sizeof(*vpfe_dev->clks), GFP_KERNEL);
231 if (vpfe_dev->clks == NULL) 231 if (vpfe_dev->clks == NULL)
232 return -ENOMEM; 232 return -ENOMEM;
233 233
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c
index 0fdff91624fd..adb2bc8811ab 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c
@@ -470,7 +470,7 @@ void vpfe_video_process_buffer_complete(struct vpfe_video_device *video)
470{ 470{
471 struct vpfe_pipeline *pipe = &video->pipe; 471 struct vpfe_pipeline *pipe = &video->pipe;
472 472
473 v4l2_get_timestamp(&video->cur_frm->vb.timestamp); 473 video->cur_frm->vb.vb2_buf.timestamp = ktime_get_ns();
474 vb2_buffer_done(&video->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE); 474 vb2_buffer_done(&video->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE);
475 if (pipe->state == VPFE_PIPELINE_STREAM_CONTINUOUS) 475 if (pipe->state == VPFE_PIPELINE_STREAM_CONTINUOUS)
476 video->cur_frm = video->next_frm; 476 video->cur_frm = video->next_frm;
@@ -1078,7 +1078,7 @@ vpfe_g_dv_timings(struct file *file, void *fh,
1078 * the buffer nbuffers and buffer size 1078 * the buffer nbuffers and buffer size
1079 */ 1079 */
1080static int 1080static int
1081vpfe_buffer_queue_setup(struct vb2_queue *vq, const void *parg, 1081vpfe_buffer_queue_setup(struct vb2_queue *vq,
1082 unsigned int *nbuffers, unsigned int *nplanes, 1082 unsigned int *nbuffers, unsigned int *nplanes,
1083 unsigned int sizes[], void *alloc_ctxs[]) 1083 unsigned int sizes[], void *alloc_ctxs[])
1084{ 1084{
diff --git a/drivers/staging/media/lirc/lirc_imon.c b/drivers/staging/media/lirc/lirc_imon.c
index 534b8103ae80..ff1926ca1f96 100644
--- a/drivers/staging/media/lirc/lirc_imon.c
+++ b/drivers/staging/media/lirc/lirc_imon.c
@@ -885,12 +885,14 @@ static int imon_probe(struct usb_interface *interface,
885 vendor, product, ifnum, usbdev->bus->busnum, usbdev->devnum); 885 vendor, product, ifnum, usbdev->bus->busnum, usbdev->devnum);
886 886
887 /* Everything went fine. Just unlock and return retval (with is 0) */ 887 /* Everything went fine. Just unlock and return retval (with is 0) */
888 mutex_unlock(&context->ctx_lock);
888 goto driver_unlock; 889 goto driver_unlock;
889 890
890unregister_lirc: 891unregister_lirc:
891 lirc_unregister_driver(driver->minor); 892 lirc_unregister_driver(driver->minor);
892 893
893free_tx_urb: 894free_tx_urb:
895 mutex_unlock(&context->ctx_lock);
894 usb_free_urb(tx_urb); 896 usb_free_urb(tx_urb);
895 897
896free_rx_urb: 898free_rx_urb:
diff --git a/drivers/staging/media/lirc/lirc_parallel.c b/drivers/staging/media/lirc/lirc_parallel.c
index c1408342b1d0..d009bcb439f0 100644
--- a/drivers/staging/media/lirc/lirc_parallel.c
+++ b/drivers/staging/media/lirc/lirc_parallel.c
@@ -33,7 +33,7 @@
33#include <linux/fs.h> 33#include <linux/fs.h>
34#include <linux/kernel.h> 34#include <linux/kernel.h>
35#include <linux/ioport.h> 35#include <linux/ioport.h>
36#include <linux/time.h> 36#include <linux/ktime.h>
37#include <linux/mm.h> 37#include <linux/mm.h>
38#include <linux/delay.h> 38#include <linux/delay.h>
39 39
@@ -144,25 +144,22 @@ static void lirc_off(void)
144 144
145static unsigned int init_lirc_timer(void) 145static unsigned int init_lirc_timer(void)
146{ 146{
147 struct timeval tv, now; 147 ktime_t kt, now, timeout;
148 unsigned int level, newlevel, timeelapsed, newtimer; 148 unsigned int level, newlevel, timeelapsed, newtimer;
149 int count = 0; 149 int count = 0;
150 150
151 do_gettimeofday(&tv); 151 kt = ktime_get();
152 tv.tv_sec++; /* wait max. 1 sec. */ 152 /* wait max. 1 sec. */
153 timeout = ktime_add_ns(kt, NSEC_PER_SEC);
153 level = lirc_get_timer(); 154 level = lirc_get_timer();
154 do { 155 do {
155 newlevel = lirc_get_timer(); 156 newlevel = lirc_get_timer();
156 if (level == 0 && newlevel != 0) 157 if (level == 0 && newlevel != 0)
157 count++; 158 count++;
158 level = newlevel; 159 level = newlevel;
159 do_gettimeofday(&now); 160 now = ktime_get();
160 } while (count < 1000 && (now.tv_sec < tv.tv_sec 161 } while (count < 1000 && (ktime_before(now, timeout)));
161 || (now.tv_sec == tv.tv_sec 162 timeelapsed = ktime_us_delta(now, kt);
162 && now.tv_usec < tv.tv_usec)));
163
164 timeelapsed = (now.tv_sec + 1 - tv.tv_sec)*1000000
165 + (now.tv_usec - tv.tv_usec);
166 if (count >= 1000 && timeelapsed > 0) { 163 if (count >= 1000 && timeelapsed > 0) {
167 if (default_timer == 0) { 164 if (default_timer == 0) {
168 /* autodetect timer */ 165 /* autodetect timer */
@@ -220,8 +217,8 @@ static void rbuf_write(int signal)
220 217
221static void lirc_lirc_irq_handler(void *blah) 218static void lirc_lirc_irq_handler(void *blah)
222{ 219{
223 struct timeval tv; 220 ktime_t kt, delkt;
224 static struct timeval lasttv; 221 static ktime_t lastkt;
225 static int init; 222 static int init;
226 long signal; 223 long signal;
227 int data; 224 int data;
@@ -244,16 +241,14 @@ static void lirc_lirc_irq_handler(void *blah)
244 241
245#ifdef LIRC_TIMER 242#ifdef LIRC_TIMER
246 if (init) { 243 if (init) {
247 do_gettimeofday(&tv); 244 kt = ktime_get();
248 245
249 signal = tv.tv_sec - lasttv.tv_sec; 246 delkt = ktime_sub(kt, lastkt);
250 if (signal > 15) 247 if (ktime_compare(delkt, ktime_set(15, 0)) > 0)
251 /* really long time */ 248 /* really long time */
252 data = PULSE_MASK; 249 data = PULSE_MASK;
253 else 250 else
254 data = (int) (signal*1000000 + 251 data = (int)(ktime_to_us(delkt) + LIRC_SFH506_DELAY);
255 tv.tv_usec - lasttv.tv_usec +
256 LIRC_SFH506_DELAY);
257 252
258 rbuf_write(data); /* space */ 253 rbuf_write(data); /* space */
259 } else { 254 } else {
@@ -301,7 +296,7 @@ static void lirc_lirc_irq_handler(void *blah)
301 data = 1; 296 data = 1;
302 rbuf_write(PULSE_BIT|data); /* pulse */ 297 rbuf_write(PULSE_BIT|data); /* pulse */
303 } 298 }
304 do_gettimeofday(&lasttv); 299 lastkt = ktime_get();
305#else 300#else
306 /* add your code here */ 301 /* add your code here */
307#endif 302#endif
diff --git a/drivers/staging/media/lirc/lirc_sasem.c b/drivers/staging/media/lirc/lirc_sasem.c
index f2dca69c2bc0..2218d0042030 100644
--- a/drivers/staging/media/lirc/lirc_sasem.c
+++ b/drivers/staging/media/lirc/lirc_sasem.c
@@ -42,6 +42,7 @@
42#include <linux/slab.h> 42#include <linux/slab.h>
43#include <linux/uaccess.h> 43#include <linux/uaccess.h>
44#include <linux/usb.h> 44#include <linux/usb.h>
45#include <linux/ktime.h>
45 46
46#include <media/lirc.h> 47#include <media/lirc.h>
47#include <media/lirc_dev.h> 48#include <media/lirc_dev.h>
@@ -111,7 +112,7 @@ struct sasem_context {
111 } tx; 112 } tx;
112 113
113 /* for dealing with repeat codes (wish there was a toggle bit!) */ 114 /* for dealing with repeat codes (wish there was a toggle bit!) */
114 struct timeval presstime; 115 ktime_t presstime;
115 char lastcode[8]; 116 char lastcode[8];
116 int codesaved; 117 int codesaved;
117}; 118};
@@ -566,8 +567,8 @@ static void incoming_packet(struct sasem_context *context,
566{ 567{
567 int len = urb->actual_length; 568 int len = urb->actual_length;
568 unsigned char *buf = urb->transfer_buffer; 569 unsigned char *buf = urb->transfer_buffer;
569 long ms; 570 u64 ns;
570 struct timeval tv; 571 ktime_t kt;
571 572
572 if (len != 8) { 573 if (len != 8) {
573 dev_warn(&context->dev->dev, 574 dev_warn(&context->dev->dev,
@@ -584,9 +585,8 @@ static void incoming_packet(struct sasem_context *context,
584 */ 585 */
585 586
586 /* get the time since the last button press */ 587 /* get the time since the last button press */
587 do_gettimeofday(&tv); 588 kt = ktime_get();
588 ms = (tv.tv_sec - context->presstime.tv_sec) * 1000 + 589 ns = ktime_to_ns(ktime_sub(kt, context->presstime));
589 (tv.tv_usec - context->presstime.tv_usec) / 1000;
590 590
591 if (memcmp(buf, "\x08\0\0\0\0\0\0\0", 8) == 0) { 591 if (memcmp(buf, "\x08\0\0\0\0\0\0\0", 8) == 0) {
592 /* 592 /*
@@ -600,10 +600,9 @@ static void incoming_packet(struct sasem_context *context,
600 * in that time and then get a false repeat of the previous 600 * in that time and then get a false repeat of the previous
601 * press but it is long enough for a genuine repeat 601 * press but it is long enough for a genuine repeat
602 */ 602 */
603 if ((ms < 250) && (context->codesaved != 0)) { 603 if ((ns < 250 * NSEC_PER_MSEC) && (context->codesaved != 0)) {
604 memcpy(buf, &context->lastcode, 8); 604 memcpy(buf, &context->lastcode, 8);
605 context->presstime.tv_sec = tv.tv_sec; 605 context->presstime = kt;
606 context->presstime.tv_usec = tv.tv_usec;
607 } 606 }
608 } else { 607 } else {
609 /* save the current valid code for repeats */ 608 /* save the current valid code for repeats */
@@ -613,8 +612,7 @@ static void incoming_packet(struct sasem_context *context,
613 * just for safety reasons 612 * just for safety reasons
614 */ 613 */
615 context->codesaved = 1; 614 context->codesaved = 1;
616 context->presstime.tv_sec = tv.tv_sec; 615 context->presstime = kt;
617 context->presstime.tv_usec = tv.tv_usec;
618 } 616 }
619 617
620 lirc_buffer_write(context->driver->rbuf, buf); 618 lirc_buffer_write(context->driver->rbuf, buf);
diff --git a/drivers/staging/media/lirc/lirc_serial.c b/drivers/staging/media/lirc/lirc_serial.c
index 64a7b2fc5289..b798b311d32c 100644
--- a/drivers/staging/media/lirc/lirc_serial.c
+++ b/drivers/staging/media/lirc/lirc_serial.c
@@ -59,7 +59,7 @@
59#include <linux/ioport.h> 59#include <linux/ioport.h>
60#include <linux/kernel.h> 60#include <linux/kernel.h>
61#include <linux/serial_reg.h> 61#include <linux/serial_reg.h>
62#include <linux/time.h> 62#include <linux/ktime.h>
63#include <linux/string.h> 63#include <linux/string.h>
64#include <linux/types.h> 64#include <linux/types.h>
65#include <linux/wait.h> 65#include <linux/wait.h>
@@ -204,7 +204,7 @@ static struct lirc_serial hardware[] = {
204 204
205#define RBUF_LEN 256 205#define RBUF_LEN 256
206 206
207static struct timeval lasttv = {0, 0}; 207static ktime_t lastkt;
208 208
209static struct lirc_buffer rbuf; 209static struct lirc_buffer rbuf;
210 210
@@ -542,10 +542,10 @@ static void frbwrite(int l)
542 542
543static irqreturn_t lirc_irq_handler(int i, void *blah) 543static irqreturn_t lirc_irq_handler(int i, void *blah)
544{ 544{
545 struct timeval tv; 545 ktime_t kt;
546 int counter, dcd; 546 int counter, dcd;
547 u8 status; 547 u8 status;
548 long deltv; 548 ktime_t delkt;
549 int data; 549 int data;
550 static int last_dcd = -1; 550 static int last_dcd = -1;
551 551
@@ -565,7 +565,7 @@ static irqreturn_t lirc_irq_handler(int i, void *blah)
565 if ((status & hardware[type].signal_pin_change) 565 if ((status & hardware[type].signal_pin_change)
566 && sense != -1) { 566 && sense != -1) {
567 /* get current time */ 567 /* get current time */
568 do_gettimeofday(&tv); 568 kt = ktime_get();
569 569
570 /* New mode, written by Trent Piepho 570 /* New mode, written by Trent Piepho
571 <xyzzy@u.washington.edu>. */ 571 <xyzzy@u.washington.edu>. */
@@ -594,34 +594,20 @@ static irqreturn_t lirc_irq_handler(int i, void *blah)
594 dcd = (status & hardware[type].signal_pin) ? 1 : 0; 594 dcd = (status & hardware[type].signal_pin) ? 1 : 0;
595 595
596 if (dcd == last_dcd) { 596 if (dcd == last_dcd) {
597 pr_warn("ignoring spike: %d %d %lx %lx %lx %lx\n", 597 pr_warn("ignoring spike: %d %d %llx %llx\n",
598 dcd, sense, 598 dcd, sense, ktime_to_us(kt),
599 tv.tv_sec, lasttv.tv_sec, 599 ktime_to_us(lastkt));
600 (unsigned long)tv.tv_usec,
601 (unsigned long)lasttv.tv_usec);
602 continue; 600 continue;
603 } 601 }
604 602
605 deltv = tv.tv_sec-lasttv.tv_sec; 603 delkt = ktime_sub(kt, lastkt);
606 if (tv.tv_sec < lasttv.tv_sec || 604 if (ktime_compare(delkt, ktime_set(15, 0)) > 0) {
607 (tv.tv_sec == lasttv.tv_sec &&
608 tv.tv_usec < lasttv.tv_usec)) {
609 pr_warn("AIEEEE: your clock just jumped backwards\n");
610 pr_warn("%d %d %lx %lx %lx %lx\n",
611 dcd, sense,
612 tv.tv_sec, lasttv.tv_sec,
613 (unsigned long)tv.tv_usec,
614 (unsigned long)lasttv.tv_usec);
615 data = PULSE_MASK;
616 } else if (deltv > 15) {
617 data = PULSE_MASK; /* really long time */ 605 data = PULSE_MASK; /* really long time */
618 if (!(dcd^sense)) { 606 if (!(dcd^sense)) {
619 /* sanity check */ 607 /* sanity check */
620 pr_warn("AIEEEE: %d %d %lx %lx %lx %lx\n", 608 pr_warn("AIEEEE: %d %d %llx %llx\n",
621 dcd, sense, 609 dcd, sense, ktime_to_us(kt),
622 tv.tv_sec, lasttv.tv_sec, 610 ktime_to_us(lastkt));
623 (unsigned long)tv.tv_usec,
624 (unsigned long)lasttv.tv_usec);
625 /* 611 /*
626 * detecting pulse while this 612 * detecting pulse while this
627 * MUST be a space! 613 * MUST be a space!
@@ -629,11 +615,9 @@ static irqreturn_t lirc_irq_handler(int i, void *blah)
629 sense = sense ? 0 : 1; 615 sense = sense ? 0 : 1;
630 } 616 }
631 } else 617 } else
632 data = (int) (deltv*1000000 + 618 data = (int) ktime_to_us(delkt);
633 tv.tv_usec -
634 lasttv.tv_usec);
635 frbwrite(dcd^sense ? data : (data|PULSE_BIT)); 619 frbwrite(dcd^sense ? data : (data|PULSE_BIT));
636 lasttv = tv; 620 lastkt = kt;
637 last_dcd = dcd; 621 last_dcd = dcd;
638 wake_up_interruptible(&rbuf.wait_poll); 622 wake_up_interruptible(&rbuf.wait_poll);
639 } 623 }
@@ -790,7 +774,7 @@ static int set_use_inc(void *data)
790 unsigned long flags; 774 unsigned long flags;
791 775
792 /* initialize timestamp */ 776 /* initialize timestamp */
793 do_gettimeofday(&lasttv); 777 lastkt = ktime_get();
794 778
795 spin_lock_irqsave(&hardware[type].lock, flags); 779 spin_lock_irqsave(&hardware[type].lock, flags);
796 780
@@ -979,7 +963,7 @@ static int lirc_serial_resume(struct platform_device *dev)
979 963
980 spin_lock_irqsave(&hardware[type].lock, flags); 964 spin_lock_irqsave(&hardware[type].lock, flags);
981 /* Enable Interrupt */ 965 /* Enable Interrupt */
982 do_gettimeofday(&lasttv); 966 lastkt = ktime_get();
983 soutp(UART_IER, sinp(UART_IER)|UART_IER_MSI); 967 soutp(UART_IER, sinp(UART_IER)|UART_IER_MSI);
984 off(); 968 off();
985 969
diff --git a/drivers/staging/media/omap4iss/Kconfig b/drivers/staging/media/omap4iss/Kconfig
index 8d4e3bd1bfe1..46183464ee79 100644
--- a/drivers/staging/media/omap4iss/Kconfig
+++ b/drivers/staging/media/omap4iss/Kconfig
@@ -1,6 +1,6 @@
1config VIDEO_OMAP4 1config VIDEO_OMAP4
2 tristate "OMAP 4 Camera support" 2 tristate "OMAP 4 Camera support"
3 depends on VIDEO_V4L2=y && VIDEO_V4L2_SUBDEV_API && I2C=y && ARCH_OMAP4 3 depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && I2C && ARCH_OMAP4
4 depends on HAS_DMA 4 depends on HAS_DMA
5 select MFD_SYSCON 5 select MFD_SYSCON
6 select VIDEOBUF2_DMA_CONTIG 6 select VIDEOBUF2_DMA_CONTIG
diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c
index aa76ccda5b42..e27a988540a6 100644
--- a/drivers/staging/media/omap4iss/iss.c
+++ b/drivers/staging/media/omap4iss/iss.c
@@ -601,8 +601,8 @@ static int iss_pipeline_disable(struct iss_pipeline *pipe,
601 subdev = media_entity_to_v4l2_subdev(entity); 601 subdev = media_entity_to_v4l2_subdev(entity);
602 ret = v4l2_subdev_call(subdev, video, s_stream, 0); 602 ret = v4l2_subdev_call(subdev, video, s_stream, 0);
603 if (ret < 0) { 603 if (ret < 0) {
604 dev_dbg(iss->dev, "%s: module stop timeout.\n", 604 dev_warn(iss->dev, "%s: module stop timeout.\n",
605 subdev->name); 605 subdev->name);
606 /* If the entity failed to stopped, assume it has 606 /* If the entity failed to stopped, assume it has
607 * crashed. Mark it as such, the ISS will be reset when 607 * crashed. Mark it as such, the ISS will be reset when
608 * applications will release it. 608 * applications will release it.
diff --git a/drivers/staging/media/omap4iss/iss.h b/drivers/staging/media/omap4iss/iss.h
index 35df8b4709e6..5929357fe687 100644
--- a/drivers/staging/media/omap4iss/iss.h
+++ b/drivers/staging/media/omap4iss/iss.h
@@ -20,7 +20,7 @@
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/wait.h> 21#include <linux/wait.h>
22 22
23#include <media/omap4iss.h> 23#include <linux/platform_data/media/omap4iss.h>
24 24
25#include "iss_regs.h" 25#include "iss_regs.h"
26#include "iss_csiphy.h" 26#include "iss_csiphy.h"
diff --git a/drivers/staging/media/omap4iss/iss_csi2.c b/drivers/staging/media/omap4iss/iss_csi2.c
index c6e6d47ac57f..b941035139ae 100644
--- a/drivers/staging/media/omap4iss/iss_csi2.c
+++ b/drivers/staging/media/omap4iss/iss_csi2.c
@@ -674,6 +674,9 @@ static void csi2_isr_ctx(struct iss_csi2_device *csi2,
674 status = iss_reg_read(csi2->iss, csi2->regs1, CSI2_CTX_IRQSTATUS(n)); 674 status = iss_reg_read(csi2->iss, csi2->regs1, CSI2_CTX_IRQSTATUS(n));
675 iss_reg_write(csi2->iss, csi2->regs1, CSI2_CTX_IRQSTATUS(n), status); 675 iss_reg_write(csi2->iss, csi2->regs1, CSI2_CTX_IRQSTATUS(n), status);
676 676
677 if (omap4iss_module_sync_is_stopping(&csi2->wait, &csi2->stopping))
678 return;
679
677 /* Propagate frame number */ 680 /* Propagate frame number */
678 if (status & CSI2_CTX_IRQ_FS) { 681 if (status & CSI2_CTX_IRQ_FS) {
679 struct iss_pipeline *pipe = 682 struct iss_pipeline *pipe =
@@ -776,9 +779,6 @@ void omap4iss_csi2_isr(struct iss_csi2_device *csi2)
776 pipe->error = true; 779 pipe->error = true;
777 } 780 }
778 781
779 if (omap4iss_module_sync_is_stopping(&csi2->wait, &csi2->stopping))
780 return;
781
782 /* Successful cases */ 782 /* Successful cases */
783 if (csi2_irqstatus & CSI2_IRQ_CONTEXT0) 783 if (csi2_irqstatus & CSI2_IRQ_CONTEXT0)
784 csi2_isr_ctx(csi2, &csi2->contexts[0]); 784 csi2_isr_ctx(csi2, &csi2->contexts[0]);
diff --git a/drivers/staging/media/omap4iss/iss_csiphy.h b/drivers/staging/media/omap4iss/iss_csiphy.h
index e9ca43955654..a0f2d974daeb 100644
--- a/drivers/staging/media/omap4iss/iss_csiphy.h
+++ b/drivers/staging/media/omap4iss/iss_csiphy.h
@@ -14,7 +14,7 @@
14#ifndef OMAP4_ISS_CSI_PHY_H 14#ifndef OMAP4_ISS_CSI_PHY_H
15#define OMAP4_ISS_CSI_PHY_H 15#define OMAP4_ISS_CSI_PHY_H
16 16
17#include <media/omap4iss.h> 17#include <linux/platform_data/media/omap4iss.h>
18 18
19struct iss_csi2_device; 19struct iss_csi2_device;
20 20
diff --git a/drivers/staging/media/omap4iss/iss_resizer.c b/drivers/staging/media/omap4iss/iss_resizer.c
index 9c8180bba77e..108961e05f53 100644
--- a/drivers/staging/media/omap4iss/iss_resizer.c
+++ b/drivers/staging/media/omap4iss/iss_resizer.c
@@ -158,8 +158,8 @@ static void resizer_set_outaddr(struct iss_resizer_device *resizer, u32 addr)
158 /* Program UV buffer address... Hardcoded to be contiguous! */ 158 /* Program UV buffer address... Hardcoded to be contiguous! */
159 if ((informat->code == MEDIA_BUS_FMT_UYVY8_1X16) && 159 if ((informat->code == MEDIA_BUS_FMT_UYVY8_1X16) &&
160 (outformat->code == MEDIA_BUS_FMT_YUYV8_1_5X8)) { 160 (outformat->code == MEDIA_BUS_FMT_YUYV8_1_5X8)) {
161 u32 c_addr = addr + (resizer->video_out.bpl_value * 161 u32 c_addr = addr + resizer->video_out.bpl_value
162 (outformat->height - 1)); 162 * outformat->height;
163 163
164 /* Ensure Y_BAD_L[6:0] = C_BAD_L[6:0]*/ 164 /* Ensure Y_BAD_L[6:0] = C_BAD_L[6:0]*/
165 if ((c_addr ^ addr) & 0x7f) { 165 if ((c_addr ^ addr) & 0x7f) {
diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c
index 2a0158bb4974..e9aeca08986f 100644
--- a/drivers/staging/media/omap4iss/iss_video.c
+++ b/drivers/staging/media/omap4iss/iss_video.c
@@ -287,7 +287,6 @@ iss_video_check_format(struct iss_video *video, struct iss_video_fh *vfh)
287 */ 287 */
288 288
289static int iss_video_queue_setup(struct vb2_queue *vq, 289static int iss_video_queue_setup(struct vb2_queue *vq,
290 const void *parg,
291 unsigned int *count, unsigned int *num_planes, 290 unsigned int *count, unsigned int *num_planes,
292 unsigned int sizes[], void *alloc_ctxs[]) 291 unsigned int sizes[], void *alloc_ctxs[])
293{ 292{
@@ -434,7 +433,7 @@ struct iss_buffer *omap4iss_video_buffer_next(struct iss_video *video)
434 list_del(&buf->list); 433 list_del(&buf->list);
435 spin_unlock_irqrestore(&video->qlock, flags); 434 spin_unlock_irqrestore(&video->qlock, flags);
436 435
437 v4l2_get_timestamp(&buf->vb.timestamp); 436 buf->vb.vb2_buf.timestamp = ktime_get_ns();
438 437
439 /* Do frame number propagation only if this is the output video node. 438 /* Do frame number propagation only if this is the output video node.
440 * Frame number either comes from the CSI receivers or it gets 439 * Frame number either comes from the CSI receivers or it gets
diff --git a/drivers/usb/gadget/function/uvc_queue.c b/drivers/usb/gadget/function/uvc_queue.c
index 51d4a1703af2..912694f3d54e 100644
--- a/drivers/usb/gadget/function/uvc_queue.c
+++ b/drivers/usb/gadget/function/uvc_queue.c
@@ -41,7 +41,7 @@
41 * videobuf2 queue operations 41 * videobuf2 queue operations
42 */ 42 */
43 43
44static int uvc_queue_setup(struct vb2_queue *vq, const void *parg, 44static int uvc_queue_setup(struct vb2_queue *vq,
45 unsigned int *nbuffers, unsigned int *nplanes, 45 unsigned int *nbuffers, unsigned int *nplanes,
46 unsigned int sizes[], void *alloc_ctxs[]) 46 unsigned int sizes[], void *alloc_ctxs[])
47{ 47{
@@ -329,7 +329,7 @@ struct uvc_buffer *uvcg_queue_next_buffer(struct uvc_video_queue *queue,
329 329
330 buf->buf.field = V4L2_FIELD_NONE; 330 buf->buf.field = V4L2_FIELD_NONE;
331 buf->buf.sequence = queue->sequence++; 331 buf->buf.sequence = queue->sequence++;
332 v4l2_get_timestamp(&buf->buf.timestamp); 332 buf->buf.vb2_buf.timestamp = ktime_get_ns();
333 333
334 vb2_set_plane_payload(&buf->buf.vb2_buf, 0, buf->bytesused); 334 vb2_set_plane_payload(&buf->buf.vb2_buf, 0, buf->bytesused);
335 vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE); 335 vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE);
diff --git a/firmware/WHENCE b/firmware/WHENCE
index 0c4d96dee9b6..de6f22e008f1 100644
--- a/firmware/WHENCE
+++ b/firmware/WHENCE
@@ -677,7 +677,7 @@ File: av7110/bootcode.bin
677 677
678Licence: GPLv2 or later 678Licence: GPLv2 or later
679 679
680ARM assembly source code available at http://www.linuxtv.org/downloads/firmware/Boot.S 680ARM assembly source code available at https://linuxtv.org/downloads/firmware/Boot.S
681 681
682-------------------------------------------------------------------------- 682--------------------------------------------------------------------------
683 683
diff --git a/include/linux/platform_data/camera-rcar.h b/include/linux/platform_data/camera-rcar.h
deleted file mode 100644
index dfc83c581593..000000000000
--- a/include/linux/platform_data/camera-rcar.h
+++ /dev/null
@@ -1,25 +0,0 @@
1/*
2 * Platform data for Renesas R-Car VIN soc-camera driver
3 *
4 * Copyright (C) 2011-2013 Renesas Solutions Corp.
5 * Copyright (C) 2013 Cogent Embedded, Inc., <source@cogentembedded.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#ifndef __CAMERA_RCAR_H_
14#define __CAMERA_RCAR_H_
15
16#define RCAR_VIN_HSYNC_ACTIVE_LOW (1 << 0)
17#define RCAR_VIN_VSYNC_ACTIVE_LOW (1 << 1)
18#define RCAR_VIN_BT601 (1 << 2)
19#define RCAR_VIN_BT656 (1 << 3)
20
21struct rcar_vin_platform_data {
22 unsigned int flags;
23};
24
25#endif /* __CAMERA_RCAR_H_ */
diff --git a/include/linux/platform_data/camera-mx2.h b/include/linux/platform_data/media/camera-mx2.h
index 7ded6f1f74bc..7ded6f1f74bc 100644
--- a/include/linux/platform_data/camera-mx2.h
+++ b/include/linux/platform_data/media/camera-mx2.h
diff --git a/include/linux/platform_data/camera-mx3.h b/include/linux/platform_data/media/camera-mx3.h
index a910dadc8258..a910dadc8258 100644
--- a/include/linux/platform_data/camera-mx3.h
+++ b/include/linux/platform_data/media/camera-mx3.h
diff --git a/include/linux/platform_data/camera-pxa.h b/include/linux/platform_data/media/camera-pxa.h
index 6709b1cd7c77..6709b1cd7c77 100644
--- a/include/linux/platform_data/camera-pxa.h
+++ b/include/linux/platform_data/media/camera-pxa.h
diff --git a/include/linux/platform_data/coda.h b/include/linux/platform_data/media/coda.h
index 6ad4410d9e20..6ad4410d9e20 100644
--- a/include/linux/platform_data/coda.h
+++ b/include/linux/platform_data/media/coda.h
diff --git a/include/media/gpio-ir-recv.h b/include/linux/platform_data/media/gpio-ir-recv.h
index 0142736a59db..0c298f569d5a 100644
--- a/include/media/gpio-ir-recv.h
+++ b/include/linux/platform_data/media/gpio-ir-recv.h
@@ -21,4 +21,3 @@ struct gpio_ir_recv_platform_data {
21}; 21};
22 22
23#endif /* __GPIO_IR_RECV_H__ */ 23#endif /* __GPIO_IR_RECV_H__ */
24
diff --git a/include/media/ir-rx51.h b/include/linux/platform_data/media/ir-rx51.h
index 104aa892f31b..104aa892f31b 100644
--- a/include/media/ir-rx51.h
+++ b/include/linux/platform_data/media/ir-rx51.h
diff --git a/include/media/mmp-camera.h b/include/linux/platform_data/media/mmp-camera.h
index 7611963a257f..7611963a257f 100644
--- a/include/media/mmp-camera.h
+++ b/include/linux/platform_data/media/mmp-camera.h
diff --git a/include/media/omap1_camera.h b/include/linux/platform_data/media/omap1_camera.h
index 819767cf04d4..819767cf04d4 100644
--- a/include/media/omap1_camera.h
+++ b/include/linux/platform_data/media/omap1_camera.h
diff --git a/include/media/omap4iss.h b/include/linux/platform_data/media/omap4iss.h
index 0d7620db5e32..0d7620db5e32 100644
--- a/include/media/omap4iss.h
+++ b/include/linux/platform_data/media/omap4iss.h
diff --git a/include/media/s5p_hdmi.h b/include/linux/platform_data/media/s5p_hdmi.h
index 181642b8d0a5..bb9cacb0cbb0 100644
--- a/include/media/s5p_hdmi.h
+++ b/include/linux/platform_data/media/s5p_hdmi.h
@@ -34,4 +34,3 @@ struct s5p_hdmi_platform_data {
34}; 34};
35 35
36#endif /* S5P_HDMI_H */ 36#endif /* S5P_HDMI_H */
37
diff --git a/include/media/si4713.h b/include/linux/platform_data/media/si4713.h
index be4f58e2440b..932668ad54f7 100644
--- a/include/media/si4713.h
+++ b/include/linux/platform_data/media/si4713.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * include/media/si4713.h 2 * include/linux/platform_data/media/si4713.h
3 * 3 *
4 * Board related data definitions for Si4713 i2c device driver. 4 * Board related data definitions for Si4713 i2c device driver.
5 * 5 *
diff --git a/include/media/sii9234.h b/include/linux/platform_data/media/sii9234.h
index 6a4a809fe9a3..6a4a809fe9a3 100644
--- a/include/media/sii9234.h
+++ b/include/linux/platform_data/media/sii9234.h
diff --git a/include/media/soc_camera_platform.h b/include/linux/platform_data/media/soc_camera_platform.h
index 1e5065dab430..1e5065dab430 100644
--- a/include/media/soc_camera_platform.h
+++ b/include/linux/platform_data/media/soc_camera_platform.h
diff --git a/include/media/timb_radio.h b/include/linux/platform_data/media/timb_radio.h
index a40a6a348d21..a40a6a348d21 100644
--- a/include/media/timb_radio.h
+++ b/include/linux/platform_data/media/timb_radio.h
diff --git a/include/media/timb_video.h b/include/linux/platform_data/media/timb_video.h
index 70ae43970a49..70ae43970a49 100644
--- a/include/media/timb_video.h
+++ b/include/linux/platform_data/media/timb_video.h
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 73ea2fb04731..16c0ed6c50a7 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -46,7 +46,7 @@
46 * All kernel-specific stuff were moved to media/v4l2-dev.h, so 46 * All kernel-specific stuff were moved to media/v4l2-dev.h, so
47 * no #if __KERNEL tests are allowed here 47 * no #if __KERNEL tests are allowed here
48 * 48 *
49 * See http://linuxtv.org for more info 49 * See https://linuxtv.org for more info
50 * 50 *
51 * Author: Bill Dirks <bill@thedirks.org> 51 * Author: Bill Dirks <bill@thedirks.org>
52 * Justin Schoeman 52 * Justin Schoeman
diff --git a/include/media/cx2341x.h b/include/media/drv-intf/cx2341x.h
index 9635eebaab09..9635eebaab09 100644
--- a/include/media/cx2341x.h
+++ b/include/media/drv-intf/cx2341x.h
diff --git a/include/media/cx25840.h b/include/media/drv-intf/cx25840.h
index 783c5bdd63eb..783c5bdd63eb 100644
--- a/include/media/cx25840.h
+++ b/include/media/drv-intf/cx25840.h
diff --git a/include/media/exynos-fimc.h b/include/media/drv-intf/exynos-fimc.h
index 69bcd2a07d5c..69bcd2a07d5c 100644
--- a/include/media/exynos-fimc.h
+++ b/include/media/drv-intf/exynos-fimc.h
diff --git a/include/media/msp3400.h b/include/media/drv-intf/msp3400.h
index 90cf22ada8b4..1e6e80213a77 100644
--- a/include/media/msp3400.h
+++ b/include/media/drv-intf/msp3400.h
@@ -223,4 +223,3 @@
223 */ 223 */
224 224
225#endif /* MSP3400_H */ 225#endif /* MSP3400_H */
226
diff --git a/include/media/s3c_camif.h b/include/media/drv-intf/s3c_camif.h
index df96c2c789b4..df96c2c789b4 100644
--- a/include/media/s3c_camif.h
+++ b/include/media/drv-intf/s3c_camif.h
diff --git a/include/media/saa7146.h b/include/media/drv-intf/saa7146.h
index 96058a5a4acc..96058a5a4acc 100644
--- a/include/media/saa7146.h
+++ b/include/media/drv-intf/saa7146.h
diff --git a/include/media/saa7146_vv.h b/include/media/drv-intf/saa7146_vv.h
index 92766f77a5de..0da6ccc0615b 100644
--- a/include/media/saa7146_vv.h
+++ b/include/media/drv-intf/saa7146_vv.h
@@ -4,7 +4,7 @@
4#include <media/v4l2-common.h> 4#include <media/v4l2-common.h>
5#include <media/v4l2-ioctl.h> 5#include <media/v4l2-ioctl.h>
6#include <media/v4l2-fh.h> 6#include <media/v4l2-fh.h>
7#include <media/saa7146.h> 7#include <media/drv-intf/saa7146.h>
8#include <media/videobuf-dma-sg.h> 8#include <media/videobuf-dma-sg.h>
9 9
10#define MAX_SAA7146_CAPTURE_BUFFERS 32 /* arbitrary */ 10#define MAX_SAA7146_CAPTURE_BUFFERS 32 /* arbitrary */
diff --git a/include/media/sh_mobile_ceu.h b/include/media/drv-intf/sh_mobile_ceu.h
index 7f57056c22ba..7f57056c22ba 100644
--- a/include/media/sh_mobile_ceu.h
+++ b/include/media/drv-intf/sh_mobile_ceu.h
diff --git a/include/media/sh_mobile_csi2.h b/include/media/drv-intf/sh_mobile_csi2.h
index 14030db51f13..14030db51f13 100644
--- a/include/media/sh_mobile_csi2.h
+++ b/include/media/drv-intf/sh_mobile_csi2.h
diff --git a/include/media/sh_vou.h b/include/media/drv-intf/sh_vou.h
index ec3ba9a597a2..ec3ba9a597a2 100644
--- a/include/media/sh_vou.h
+++ b/include/media/drv-intf/sh_vou.h
diff --git a/include/media/si476x.h b/include/media/drv-intf/si476x.h
index e02e241e2d22..ad87fa8483b2 100644
--- a/include/media/si476x.h
+++ b/include/media/drv-intf/si476x.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * include/media/si476x.h -- Common definitions for si476x driver 2 * include/media/drv-intf/si476x.h -- Common definitions for si476x driver
3 * 3 *
4 * Copyright (C) 2012 Innovative Converged Devices(ICD) 4 * Copyright (C) 2012 Innovative Converged Devices(ICD)
5 * Copyright (C) 2013 Andrey Smirnov 5 * Copyright (C) 2013 Andrey Smirnov
diff --git a/include/media/soc_mediabus.h b/include/media/drv-intf/soc_mediabus.h
index 2ff773785fb6..2ff773785fb6 100644
--- a/include/media/soc_mediabus.h
+++ b/include/media/drv-intf/soc_mediabus.h
diff --git a/include/media/tea575x.h b/include/media/drv-intf/tea575x.h
index 5d096578b736..fb272d48ba33 100644
--- a/include/media/tea575x.h
+++ b/include/media/drv-intf/tea575x.h
@@ -63,7 +63,7 @@ struct snd_tea575x {
63 u32 band; /* 0: FM, 1: FM-Japan, 2: AM */ 63 u32 band; /* 0: FM, 1: FM-Japan, 2: AM */
64 u32 freq; /* frequency */ 64 u32 freq; /* frequency */
65 struct mutex mutex; 65 struct mutex mutex;
66 struct snd_tea575x_ops *ops; 66 const struct snd_tea575x_ops *ops;
67 void *private_data; 67 void *private_data;
68 u8 card[32]; 68 u8 card[32];
69 u8 bus_info[32]; 69 u8 bus_info[32];
diff --git a/include/media/ad9389b.h b/include/media/i2c/ad9389b.h
index 5ba9af869b8b..5ba9af869b8b 100644
--- a/include/media/ad9389b.h
+++ b/include/media/i2c/ad9389b.h
diff --git a/include/media/adp1653.h b/include/media/i2c/adp1653.h
index 9779c8549eb4..0b6709335dff 100644
--- a/include/media/adp1653.h
+++ b/include/media/i2c/adp1653.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * include/media/adp1653.h 2 * include/media/i2c/adp1653.h
3 * 3 *
4 * Copyright (C) 2008--2011 Nokia Corporation 4 * Copyright (C) 2008--2011 Nokia Corporation
5 * 5 *
diff --git a/include/media/adv7183.h b/include/media/i2c/adv7183.h
index c5c2d377c0a6..c5c2d377c0a6 100644
--- a/include/media/adv7183.h
+++ b/include/media/i2c/adv7183.h
diff --git a/include/media/adv7343.h b/include/media/i2c/adv7343.h
index e4142b1ef8cd..e4142b1ef8cd 100644
--- a/include/media/adv7343.h
+++ b/include/media/i2c/adv7343.h
diff --git a/include/media/adv7393.h b/include/media/i2c/adv7393.h
index b28edf351842..b28edf351842 100644
--- a/include/media/adv7393.h
+++ b/include/media/i2c/adv7393.h
diff --git a/include/media/adv7511.h b/include/media/i2c/adv7511.h
index d83b91d80764..d83b91d80764 100644
--- a/include/media/adv7511.h
+++ b/include/media/i2c/adv7511.h
diff --git a/include/media/adv7604.h b/include/media/i2c/adv7604.h
index a913859bfd30..a913859bfd30 100644
--- a/include/media/adv7604.h
+++ b/include/media/i2c/adv7604.h
diff --git a/include/media/adv7842.h b/include/media/i2c/adv7842.h
index bc249709bf35..bc249709bf35 100644
--- a/include/media/adv7842.h
+++ b/include/media/i2c/adv7842.h
diff --git a/include/media/ak881x.h b/include/media/i2c/ak881x.h
index b7f2add5ce7b..b7f2add5ce7b 100644
--- a/include/media/ak881x.h
+++ b/include/media/i2c/ak881x.h
diff --git a/include/media/as3645a.h b/include/media/i2c/as3645a.h
index 5075496d2c9e..0e07484ddc33 100644
--- a/include/media/as3645a.h
+++ b/include/media/i2c/as3645a.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * include/media/as3645a.h 2 * include/media/i2c/as3645a.h
3 * 3 *
4 * Copyright (C) 2008-2011 Nokia Corporation 4 * Copyright (C) 2008-2011 Nokia Corporation
5 * 5 *
diff --git a/include/media/bt819.h b/include/media/i2c/bt819.h
index 8025f4bc2bb6..8025f4bc2bb6 100644
--- a/include/media/bt819.h
+++ b/include/media/i2c/bt819.h
diff --git a/include/media/cs5345.h b/include/media/i2c/cs5345.h
index 6ccae24e65ed..6ccae24e65ed 100644
--- a/include/media/cs5345.h
+++ b/include/media/i2c/cs5345.h
diff --git a/include/media/cs53l32a.h b/include/media/i2c/cs53l32a.h
index bf76197d3790..bf76197d3790 100644
--- a/include/media/cs53l32a.h
+++ b/include/media/i2c/cs53l32a.h
diff --git a/include/media/ir-kbd-i2c.h b/include/media/i2c/ir-kbd-i2c.h
index d8564354debb..d8564354debb 100644
--- a/include/media/ir-kbd-i2c.h
+++ b/include/media/i2c/ir-kbd-i2c.h
diff --git a/include/media/lm3560.h b/include/media/i2c/lm3560.h
index 46670706d6f8..5ed942a8ac32 100644
--- a/include/media/lm3560.h
+++ b/include/media/i2c/lm3560.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * include/media/lm3560.h 2 * include/media/i2c/lm3560.h
3 * 3 *
4 * Copyright (C) 2013 Texas Instruments 4 * Copyright (C) 2013 Texas Instruments
5 * 5 *
diff --git a/include/media/lm3646.h b/include/media/i2c/lm3646.h
index c6acf5a1d640..724c10003a28 100644
--- a/include/media/lm3646.h
+++ b/include/media/i2c/lm3646.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * include/media/lm3646.h 2 * include/media/i2c/lm3646.h
3 * 3 *
4 * Copyright (C) 2014 Texas Instruments 4 * Copyright (C) 2014 Texas Instruments
5 * 5 *
diff --git a/include/media/m52790.h b/include/media/i2c/m52790.h
index 7ddffae31a67..7ddffae31a67 100644
--- a/include/media/m52790.h
+++ b/include/media/i2c/m52790.h
diff --git a/include/media/m5mols.h b/include/media/i2c/m5mols.h
index 4a825ae5c6c8..4a825ae5c6c8 100644
--- a/include/media/m5mols.h
+++ b/include/media/i2c/m5mols.h
diff --git a/include/media/mt9m032.h b/include/media/i2c/mt9m032.h
index c3a78114d7a6..c3a78114d7a6 100644
--- a/include/media/mt9m032.h
+++ b/include/media/i2c/mt9m032.h
diff --git a/include/media/mt9p031.h b/include/media/i2c/mt9p031.h
index 1ba361205af1..1ba361205af1 100644
--- a/include/media/mt9p031.h
+++ b/include/media/i2c/mt9p031.h
diff --git a/include/media/mt9t001.h b/include/media/i2c/mt9t001.h
index 03fd63edd133..03fd63edd133 100644
--- a/include/media/mt9t001.h
+++ b/include/media/i2c/mt9t001.h
diff --git a/include/media/mt9t112.h b/include/media/i2c/mt9t112.h
index a43c74ab05ec..a43c74ab05ec 100644
--- a/include/media/mt9t112.h
+++ b/include/media/i2c/mt9t112.h
diff --git a/include/media/mt9v011.h b/include/media/i2c/mt9v011.h
index ea29fc74cd06..ea29fc74cd06 100644
--- a/include/media/mt9v011.h
+++ b/include/media/i2c/mt9v011.h
diff --git a/include/media/mt9v022.h b/include/media/i2c/mt9v022.h
index 40561801321a..40561801321a 100644
--- a/include/media/mt9v022.h
+++ b/include/media/i2c/mt9v022.h
diff --git a/include/media/mt9v032.h b/include/media/i2c/mt9v032.h
index 12175a63c5b2..12175a63c5b2 100644
--- a/include/media/mt9v032.h
+++ b/include/media/i2c/mt9v032.h
diff --git a/include/media/noon010pc30.h b/include/media/i2c/noon010pc30.h
index 58eafee36b30..58eafee36b30 100644
--- a/include/media/noon010pc30.h
+++ b/include/media/i2c/noon010pc30.h
diff --git a/include/media/ov2659.h b/include/media/i2c/ov2659.h
index 4216adc1ede2..4216adc1ede2 100644
--- a/include/media/ov2659.h
+++ b/include/media/i2c/ov2659.h
diff --git a/include/media/ov7670.h b/include/media/i2c/ov7670.h
index 1913d5123072..1913d5123072 100644
--- a/include/media/ov7670.h
+++ b/include/media/i2c/ov7670.h
diff --git a/include/media/ov772x.h b/include/media/i2c/ov772x.h
index 00dbb7c4feae..00dbb7c4feae 100644
--- a/include/media/ov772x.h
+++ b/include/media/i2c/ov772x.h
diff --git a/include/media/ov9650.h b/include/media/i2c/ov9650.h
index d630cf9e028d..d630cf9e028d 100644
--- a/include/media/ov9650.h
+++ b/include/media/i2c/ov9650.h
diff --git a/include/media/rj54n1cb0c.h b/include/media/i2c/rj54n1cb0c.h
index 8ae3288ae925..8ae3288ae925 100644
--- a/include/media/rj54n1cb0c.h
+++ b/include/media/i2c/rj54n1cb0c.h
diff --git a/include/media/s5c73m3.h b/include/media/i2c/s5c73m3.h
index ccb9e5448762..ccb9e5448762 100644
--- a/include/media/s5c73m3.h
+++ b/include/media/i2c/s5c73m3.h
diff --git a/include/media/s5k4ecgx.h b/include/media/i2c/s5k4ecgx.h
index 90c1be792ffe..90c1be792ffe 100644
--- a/include/media/s5k4ecgx.h
+++ b/include/media/i2c/s5k4ecgx.h
diff --git a/include/media/s5k6aa.h b/include/media/i2c/s5k6aa.h
index ba34f7055e55..ba34f7055e55 100644
--- a/include/media/s5k6aa.h
+++ b/include/media/i2c/s5k6aa.h
diff --git a/include/media/saa6588.h b/include/media/i2c/saa6588.h
index b5ec1aa60ed5..b5ec1aa60ed5 100644
--- a/include/media/saa6588.h
+++ b/include/media/i2c/saa6588.h
diff --git a/include/media/saa7115.h b/include/media/i2c/saa7115.h
index 76911e71de17..53954c90e7f6 100644
--- a/include/media/saa7115.h
+++ b/include/media/i2c/saa7115.h
@@ -138,4 +138,3 @@ struct saa7115_platform_data {
138}; 138};
139 139
140#endif 140#endif
141
diff --git a/include/media/saa7127.h b/include/media/i2c/saa7127.h
index bbcf862141af..7005ba7daa9e 100644
--- a/include/media/saa7127.h
+++ b/include/media/i2c/saa7127.h
@@ -38,4 +38,3 @@ enum saa7127_output_type {
38}; 38};
39 39
40#endif 40#endif
41
diff --git a/include/media/smiapp.h b/include/media/i2c/smiapp.h
index 268a3cdbf6cb..029142ddb95c 100644
--- a/include/media/smiapp.h
+++ b/include/media/i2c/smiapp.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * include/media/smiapp.h 2 * include/media/i2c/smiapp.h
3 * 3 *
4 * Generic driver for SMIA/SMIA++ compliant camera modules 4 * Generic driver for SMIA/SMIA++ compliant camera modules
5 * 5 *
diff --git a/include/media/sr030pc30.h b/include/media/i2c/sr030pc30.h
index 6f901a653ba2..6f901a653ba2 100644
--- a/include/media/sr030pc30.h
+++ b/include/media/i2c/sr030pc30.h
diff --git a/include/media/tc358743.h b/include/media/i2c/tc358743.h
index 4513f2f9cfbc..4513f2f9cfbc 100644
--- a/include/media/tc358743.h
+++ b/include/media/i2c/tc358743.h
diff --git a/include/media/ths7303.h b/include/media/i2c/ths7303.h
index a7b49297da82..a7b49297da82 100644
--- a/include/media/ths7303.h
+++ b/include/media/i2c/ths7303.h
diff --git a/include/media/tvaudio.h b/include/media/i2c/tvaudio.h
index 1ac8184693f8..1ac8184693f8 100644
--- a/include/media/tvaudio.h
+++ b/include/media/i2c/tvaudio.h
diff --git a/include/media/tvp514x.h b/include/media/i2c/tvp514x.h
index 86ed7e806830..86ed7e806830 100644
--- a/include/media/tvp514x.h
+++ b/include/media/i2c/tvp514x.h
diff --git a/include/media/tvp5150.h b/include/media/i2c/tvp5150.h
index 72bd2a2b8bfd..649908a25605 100644
--- a/include/media/tvp5150.h
+++ b/include/media/i2c/tvp5150.h
@@ -31,4 +31,3 @@
31#define TVP5150_BLACK_SCREEN 1 31#define TVP5150_BLACK_SCREEN 1
32 32
33#endif 33#endif
34
diff --git a/include/media/tvp7002.h b/include/media/i2c/tvp7002.h
index fadb6afe9ef0..fadb6afe9ef0 100644
--- a/include/media/tvp7002.h
+++ b/include/media/i2c/tvp7002.h
diff --git a/include/media/tw9910.h b/include/media/i2c/tw9910.h
index 90bcf1fa5421..90bcf1fa5421 100644
--- a/include/media/tw9910.h
+++ b/include/media/i2c/tw9910.h
diff --git a/include/media/uda1342.h b/include/media/i2c/uda1342.h
index cd156403a368..cd156403a368 100644
--- a/include/media/uda1342.h
+++ b/include/media/i2c/uda1342.h
diff --git a/include/media/upd64031a.h b/include/media/i2c/upd64031a.h
index 3ad6a32e1bce..3ad6a32e1bce 100644
--- a/include/media/upd64031a.h
+++ b/include/media/i2c/upd64031a.h
diff --git a/include/media/upd64083.h b/include/media/i2c/upd64083.h
index 59b6f32ba300..59b6f32ba300 100644
--- a/include/media/upd64083.h
+++ b/include/media/i2c/upd64083.h
diff --git a/include/media/wm8775.h b/include/media/i2c/wm8775.h
index d0e801a9935c..d0e801a9935c 100644
--- a/include/media/wm8775.h
+++ b/include/media/i2c/wm8775.h
diff --git a/include/media/lirc.h b/include/media/lirc.h
index 4b3ab2966b5a..554988c860c1 100644
--- a/include/media/lirc.h
+++ b/include/media/lirc.h
@@ -1,168 +1 @@
1/* #include <uapi/linux/lirc.h>
2 * lirc.h - linux infrared remote control header file
3 * last modified 2010/07/13 by Jarod Wilson
4 */
5
6#ifndef _LINUX_LIRC_H
7#define _LINUX_LIRC_H
8
9#include <linux/types.h>
10#include <linux/ioctl.h>
11
12#define PULSE_BIT 0x01000000
13#define PULSE_MASK 0x00FFFFFF
14
15#define LIRC_MODE2_SPACE 0x00000000
16#define LIRC_MODE2_PULSE 0x01000000
17#define LIRC_MODE2_FREQUENCY 0x02000000
18#define LIRC_MODE2_TIMEOUT 0x03000000
19
20#define LIRC_VALUE_MASK 0x00FFFFFF
21#define LIRC_MODE2_MASK 0xFF000000
22
23#define LIRC_SPACE(val) (((val)&LIRC_VALUE_MASK) | LIRC_MODE2_SPACE)
24#define LIRC_PULSE(val) (((val)&LIRC_VALUE_MASK) | LIRC_MODE2_PULSE)
25#define LIRC_FREQUENCY(val) (((val)&LIRC_VALUE_MASK) | LIRC_MODE2_FREQUENCY)
26#define LIRC_TIMEOUT(val) (((val)&LIRC_VALUE_MASK) | LIRC_MODE2_TIMEOUT)
27
28#define LIRC_VALUE(val) ((val)&LIRC_VALUE_MASK)
29#define LIRC_MODE2(val) ((val)&LIRC_MODE2_MASK)
30
31#define LIRC_IS_SPACE(val) (LIRC_MODE2(val) == LIRC_MODE2_SPACE)
32#define LIRC_IS_PULSE(val) (LIRC_MODE2(val) == LIRC_MODE2_PULSE)
33#define LIRC_IS_FREQUENCY(val) (LIRC_MODE2(val) == LIRC_MODE2_FREQUENCY)
34#define LIRC_IS_TIMEOUT(val) (LIRC_MODE2(val) == LIRC_MODE2_TIMEOUT)
35
36/* used heavily by lirc userspace */
37#define lirc_t int
38
39/*** lirc compatible hardware features ***/
40
41#define LIRC_MODE2SEND(x) (x)
42#define LIRC_SEND2MODE(x) (x)
43#define LIRC_MODE2REC(x) ((x) << 16)
44#define LIRC_REC2MODE(x) ((x) >> 16)
45
46#define LIRC_MODE_RAW 0x00000001
47#define LIRC_MODE_PULSE 0x00000002
48#define LIRC_MODE_MODE2 0x00000004
49#define LIRC_MODE_LIRCCODE 0x00000010
50
51
52#define LIRC_CAN_SEND_RAW LIRC_MODE2SEND(LIRC_MODE_RAW)
53#define LIRC_CAN_SEND_PULSE LIRC_MODE2SEND(LIRC_MODE_PULSE)
54#define LIRC_CAN_SEND_MODE2 LIRC_MODE2SEND(LIRC_MODE_MODE2)
55#define LIRC_CAN_SEND_LIRCCODE LIRC_MODE2SEND(LIRC_MODE_LIRCCODE)
56
57#define LIRC_CAN_SEND_MASK 0x0000003f
58
59#define LIRC_CAN_SET_SEND_CARRIER 0x00000100
60#define LIRC_CAN_SET_SEND_DUTY_CYCLE 0x00000200
61#define LIRC_CAN_SET_TRANSMITTER_MASK 0x00000400
62
63#define LIRC_CAN_REC_RAW LIRC_MODE2REC(LIRC_MODE_RAW)
64#define LIRC_CAN_REC_PULSE LIRC_MODE2REC(LIRC_MODE_PULSE)
65#define LIRC_CAN_REC_MODE2 LIRC_MODE2REC(LIRC_MODE_MODE2)
66#define LIRC_CAN_REC_LIRCCODE LIRC_MODE2REC(LIRC_MODE_LIRCCODE)
67
68#define LIRC_CAN_REC_MASK LIRC_MODE2REC(LIRC_CAN_SEND_MASK)
69
70#define LIRC_CAN_SET_REC_CARRIER (LIRC_CAN_SET_SEND_CARRIER << 16)
71#define LIRC_CAN_SET_REC_DUTY_CYCLE (LIRC_CAN_SET_SEND_DUTY_CYCLE << 16)
72
73#define LIRC_CAN_SET_REC_DUTY_CYCLE_RANGE 0x40000000
74#define LIRC_CAN_SET_REC_CARRIER_RANGE 0x80000000
75#define LIRC_CAN_GET_REC_RESOLUTION 0x20000000
76#define LIRC_CAN_SET_REC_TIMEOUT 0x10000000
77#define LIRC_CAN_SET_REC_FILTER 0x08000000
78
79#define LIRC_CAN_MEASURE_CARRIER 0x02000000
80#define LIRC_CAN_USE_WIDEBAND_RECEIVER 0x04000000
81
82#define LIRC_CAN_SEND(x) ((x)&LIRC_CAN_SEND_MASK)
83#define LIRC_CAN_REC(x) ((x)&LIRC_CAN_REC_MASK)
84
85#define LIRC_CAN_NOTIFY_DECODE 0x01000000
86
87/*** IOCTL commands for lirc driver ***/
88
89#define LIRC_GET_FEATURES _IOR('i', 0x00000000, __u32)
90
91#define LIRC_GET_SEND_MODE _IOR('i', 0x00000001, __u32)
92#define LIRC_GET_REC_MODE _IOR('i', 0x00000002, __u32)
93#define LIRC_GET_SEND_CARRIER _IOR('i', 0x00000003, __u32)
94#define LIRC_GET_REC_CARRIER _IOR('i', 0x00000004, __u32)
95#define LIRC_GET_SEND_DUTY_CYCLE _IOR('i', 0x00000005, __u32)
96#define LIRC_GET_REC_DUTY_CYCLE _IOR('i', 0x00000006, __u32)
97#define LIRC_GET_REC_RESOLUTION _IOR('i', 0x00000007, __u32)
98
99#define LIRC_GET_MIN_TIMEOUT _IOR('i', 0x00000008, __u32)
100#define LIRC_GET_MAX_TIMEOUT _IOR('i', 0x00000009, __u32)
101
102#define LIRC_GET_MIN_FILTER_PULSE _IOR('i', 0x0000000a, __u32)
103#define LIRC_GET_MAX_FILTER_PULSE _IOR('i', 0x0000000b, __u32)
104#define LIRC_GET_MIN_FILTER_SPACE _IOR('i', 0x0000000c, __u32)
105#define LIRC_GET_MAX_FILTER_SPACE _IOR('i', 0x0000000d, __u32)
106
107/* code length in bits, currently only for LIRC_MODE_LIRCCODE */
108#define LIRC_GET_LENGTH _IOR('i', 0x0000000f, __u32)
109
110#define LIRC_SET_SEND_MODE _IOW('i', 0x00000011, __u32)
111#define LIRC_SET_REC_MODE _IOW('i', 0x00000012, __u32)
112/* Note: these can reset the according pulse_width */
113#define LIRC_SET_SEND_CARRIER _IOW('i', 0x00000013, __u32)
114#define LIRC_SET_REC_CARRIER _IOW('i', 0x00000014, __u32)
115#define LIRC_SET_SEND_DUTY_CYCLE _IOW('i', 0x00000015, __u32)
116#define LIRC_SET_REC_DUTY_CYCLE _IOW('i', 0x00000016, __u32)
117#define LIRC_SET_TRANSMITTER_MASK _IOW('i', 0x00000017, __u32)
118
119/*
120 * when a timeout != 0 is set the driver will send a
121 * LIRC_MODE2_TIMEOUT data packet, otherwise LIRC_MODE2_TIMEOUT is
122 * never sent, timeout is disabled by default
123 */
124#define LIRC_SET_REC_TIMEOUT _IOW('i', 0x00000018, __u32)
125
126/* 1 enables, 0 disables timeout reports in MODE2 */
127#define LIRC_SET_REC_TIMEOUT_REPORTS _IOW('i', 0x00000019, __u32)
128
129/*
130 * pulses shorter than this are filtered out by hardware (software
131 * emulation in lirc_dev?)
132 */
133#define LIRC_SET_REC_FILTER_PULSE _IOW('i', 0x0000001a, __u32)
134/*
135 * spaces shorter than this are filtered out by hardware (software
136 * emulation in lirc_dev?)
137 */
138#define LIRC_SET_REC_FILTER_SPACE _IOW('i', 0x0000001b, __u32)
139/*
140 * if filter cannot be set independently for pulse/space, this should
141 * be used
142 */
143#define LIRC_SET_REC_FILTER _IOW('i', 0x0000001c, __u32)
144
145/*
146 * if enabled from the next key press on the driver will send
147 * LIRC_MODE2_FREQUENCY packets
148 */
149#define LIRC_SET_MEASURE_CARRIER_MODE _IOW('i', 0x0000001d, __u32)
150
151/*
152 * to set a range use
153 * LIRC_SET_REC_DUTY_CYCLE_RANGE/LIRC_SET_REC_CARRIER_RANGE with the
154 * lower bound first and later
155 * LIRC_SET_REC_DUTY_CYCLE/LIRC_SET_REC_CARRIER with the upper bound
156 */
157
158#define LIRC_SET_REC_DUTY_CYCLE_RANGE _IOW('i', 0x0000001e, __u32)
159#define LIRC_SET_REC_CARRIER_RANGE _IOW('i', 0x0000001f, __u32)
160
161#define LIRC_NOTIFY_DECODE _IO('i', 0x00000020)
162
163#define LIRC_SETUP_START _IO('i', 0x00000021)
164#define LIRC_SETUP_END _IO('i', 0x00000022)
165
166#define LIRC_SET_WIDEBAND_RECEIVER _IOW('i', 0x00000023, __u32)
167
168#endif
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index ec921f6538c7..f6494709e230 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -239,6 +239,7 @@ static inline void init_ir_raw_event(struct ir_raw_event *ev)
239 memset(ev, 0, sizeof(*ev)); 239 memset(ev, 0, sizeof(*ev));
240} 240}
241 241
242#define IR_DEFAULT_TIMEOUT MS_TO_NS(125)
242#define IR_MAX_DURATION 500000000 /* 500 ms */ 243#define IR_MAX_DURATION 500000000 /* 500 ms */
243#define US_TO_NS(usec) ((usec) * 1000) 244#define US_TO_NS(usec) ((usec) * 1000)
244#define MS_TO_US(msec) ((msec) * 1000) 245#define MS_TO_US(msec) ((msec) * 1000)
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index 7c4bbc4dfab4..7844e9879497 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -33,26 +33,26 @@ enum rc_type {
33 RC_TYPE_XMP = 18, /* XMP protocol */ 33 RC_TYPE_XMP = 18, /* XMP protocol */
34}; 34};
35 35
36#define RC_BIT_NONE 0 36#define RC_BIT_NONE 0ULL
37#define RC_BIT_UNKNOWN (1 << RC_TYPE_UNKNOWN) 37#define RC_BIT_UNKNOWN (1ULL << RC_TYPE_UNKNOWN)
38#define RC_BIT_OTHER (1 << RC_TYPE_OTHER) 38#define RC_BIT_OTHER (1ULL << RC_TYPE_OTHER)
39#define RC_BIT_RC5 (1 << RC_TYPE_RC5) 39#define RC_BIT_RC5 (1ULL << RC_TYPE_RC5)
40#define RC_BIT_RC5X (1 << RC_TYPE_RC5X) 40#define RC_BIT_RC5X (1ULL << RC_TYPE_RC5X)
41#define RC_BIT_RC5_SZ (1 << RC_TYPE_RC5_SZ) 41#define RC_BIT_RC5_SZ (1ULL << RC_TYPE_RC5_SZ)
42#define RC_BIT_JVC (1 << RC_TYPE_JVC) 42#define RC_BIT_JVC (1ULL << RC_TYPE_JVC)
43#define RC_BIT_SONY12 (1 << RC_TYPE_SONY12) 43#define RC_BIT_SONY12 (1ULL << RC_TYPE_SONY12)
44#define RC_BIT_SONY15 (1 << RC_TYPE_SONY15) 44#define RC_BIT_SONY15 (1ULL << RC_TYPE_SONY15)
45#define RC_BIT_SONY20 (1 << RC_TYPE_SONY20) 45#define RC_BIT_SONY20 (1ULL << RC_TYPE_SONY20)
46#define RC_BIT_NEC (1 << RC_TYPE_NEC) 46#define RC_BIT_NEC (1ULL << RC_TYPE_NEC)
47#define RC_BIT_SANYO (1 << RC_TYPE_SANYO) 47#define RC_BIT_SANYO (1ULL << RC_TYPE_SANYO)
48#define RC_BIT_MCE_KBD (1 << RC_TYPE_MCE_KBD) 48#define RC_BIT_MCE_KBD (1ULL << RC_TYPE_MCE_KBD)
49#define RC_BIT_RC6_0 (1 << RC_TYPE_RC6_0) 49#define RC_BIT_RC6_0 (1ULL << RC_TYPE_RC6_0)
50#define RC_BIT_RC6_6A_20 (1 << RC_TYPE_RC6_6A_20) 50#define RC_BIT_RC6_6A_20 (1ULL << RC_TYPE_RC6_6A_20)
51#define RC_BIT_RC6_6A_24 (1 << RC_TYPE_RC6_6A_24) 51#define RC_BIT_RC6_6A_24 (1ULL << RC_TYPE_RC6_6A_24)
52#define RC_BIT_RC6_6A_32 (1 << RC_TYPE_RC6_6A_32) 52#define RC_BIT_RC6_6A_32 (1ULL << RC_TYPE_RC6_6A_32)
53#define RC_BIT_RC6_MCE (1 << RC_TYPE_RC6_MCE) 53#define RC_BIT_RC6_MCE (1ULL << RC_TYPE_RC6_MCE)
54#define RC_BIT_SHARP (1 << RC_TYPE_SHARP) 54#define RC_BIT_SHARP (1ULL << RC_TYPE_SHARP)
55#define RC_BIT_XMP (1 << RC_TYPE_XMP) 55#define RC_BIT_XMP (1ULL << RC_TYPE_XMP)
56 56
57#define RC_BIT_ALL (RC_BIT_UNKNOWN | RC_BIT_OTHER | \ 57#define RC_BIT_ALL (RC_BIT_UNKNOWN | RC_BIT_OTHER | \
58 RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ | \ 58 RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ | \
diff --git a/include/media/v4l2-clk.h b/include/media/v4l2-clk.h
index 3ef6e3d5ed6c..2b94662d005c 100644
--- a/include/media/v4l2-clk.h
+++ b/include/media/v4l2-clk.h
@@ -65,7 +65,12 @@ static inline struct v4l2_clk *v4l2_clk_register_fixed(const char *dev_id,
65 return __v4l2_clk_register_fixed(dev_id, rate, THIS_MODULE); 65 return __v4l2_clk_register_fixed(dev_id, rate, THIS_MODULE);
66} 66}
67 67
68#define V4L2_CLK_NAME_SIZE 64
69
68#define v4l2_clk_name_i2c(name, size, adap, client) snprintf(name, size, \ 70#define v4l2_clk_name_i2c(name, size, adap, client) snprintf(name, size, \
69 "%d-%04x", adap, client) 71 "%d-%04x", adap, client)
70 72
73#define v4l2_clk_name_of(name, size, of_full_name) snprintf(name, size, \
74 "of-%s", of_full_name)
75
71#endif 76#endif
diff --git a/include/media/v4l2-dv-timings.h b/include/media/v4l2-dv-timings.h
index a209526b6014..1113c8874c26 100644
--- a/include/media/v4l2-dv-timings.h
+++ b/include/media/v4l2-dv-timings.h
@@ -107,12 +107,14 @@ bool v4l2_find_dv_timings_cap(struct v4l2_dv_timings *t,
107 * @standard: the timings according to the standard. 107 * @standard: the timings according to the standard.
108 * @pclock_delta: maximum delta in Hz between standard->pixelclock and 108 * @pclock_delta: maximum delta in Hz between standard->pixelclock and
109 * the measured timings. 109 * the measured timings.
110 * @match_reduced_fps: if true, then fail if V4L2_DV_FL_REDUCED_FPS does not
111 * match.
110 * 112 *
111 * Returns true if the two timings match, returns false otherwise. 113 * Returns true if the two timings match, returns false otherwise.
112 */ 114 */
113bool v4l2_match_dv_timings(const struct v4l2_dv_timings *measured, 115bool v4l2_match_dv_timings(const struct v4l2_dv_timings *measured,
114 const struct v4l2_dv_timings *standard, 116 const struct v4l2_dv_timings *standard,
115 unsigned pclock_delta); 117 unsigned pclock_delta, bool match_reduced_fps);
116 118
117/** 119/**
118 * v4l2_print_dv_timings() - log the contents of a dv_timings struct 120 * v4l2_print_dv_timings() - log the contents of a dv_timings struct
@@ -183,4 +185,25 @@ bool v4l2_detect_gtf(unsigned frame_height, unsigned hfreq, unsigned vsync,
183 */ 185 */
184struct v4l2_fract v4l2_calc_aspect_ratio(u8 hor_landscape, u8 vert_portrait); 186struct v4l2_fract v4l2_calc_aspect_ratio(u8 hor_landscape, u8 vert_portrait);
185 187
188/*
189 * reduce_fps - check if conditions for reduced fps are true.
190 * bt - v4l2 timing structure
191 * For different timings reduced fps is allowed if following conditions
192 * are met -
193 * For CVT timings: if reduced blanking v2 (vsync == 8) is true.
194 * For CEA861 timings: if V4L2_DV_FL_CAN_REDUCE_FPS flag is true.
195 */
196static inline bool can_reduce_fps(struct v4l2_bt_timings *bt)
197{
198 if ((bt->standards & V4L2_DV_BT_STD_CVT) && (bt->vsync == 8))
199 return true;
200
201 if ((bt->standards & V4L2_DV_BT_STD_CEA861) &&
202 (bt->flags & V4L2_DV_FL_CAN_REDUCE_FPS))
203 return true;
204
205 return false;
206}
207
208
186#endif 209#endif
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index 647ebfe5174f..ef03ae56b1c1 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -129,6 +129,8 @@ struct vb2_mem_ops {
129 * @dbuf_mapped: flag to show whether dbuf is mapped or not 129 * @dbuf_mapped: flag to show whether dbuf is mapped or not
130 * @bytesused: number of bytes occupied by data in the plane (payload) 130 * @bytesused: number of bytes occupied by data in the plane (payload)
131 * @length: size of this plane (NOT the payload) in bytes 131 * @length: size of this plane (NOT the payload) in bytes
132 * @min_length: minimum required size of this plane (NOT the payload) in bytes.
133 * @length is always greater or equal to @min_length.
132 * @offset: when memory in the associated struct vb2_buffer is 134 * @offset: when memory in the associated struct vb2_buffer is
133 * VB2_MEMORY_MMAP, equals the offset from the start of 135 * VB2_MEMORY_MMAP, equals the offset from the start of
134 * the device memory for this plane (or is a "cookie" that 136 * the device memory for this plane (or is a "cookie" that
@@ -150,6 +152,7 @@ struct vb2_plane {
150 unsigned int dbuf_mapped; 152 unsigned int dbuf_mapped;
151 unsigned int bytesused; 153 unsigned int bytesused;
152 unsigned int length; 154 unsigned int length;
155 unsigned int min_length;
153 union { 156 union {
154 unsigned int offset; 157 unsigned int offset;
155 unsigned long userptr; 158 unsigned long userptr;
@@ -211,6 +214,7 @@ struct vb2_queue;
211 * @num_planes: number of planes in the buffer 214 * @num_planes: number of planes in the buffer
212 * on an internal driver queue 215 * on an internal driver queue
213 * @planes: private per-plane information; do not change 216 * @planes: private per-plane information; do not change
217 * @timestamp: frame timestamp in ns
214 */ 218 */
215struct vb2_buffer { 219struct vb2_buffer {
216 struct vb2_queue *vb2_queue; 220 struct vb2_queue *vb2_queue;
@@ -219,6 +223,7 @@ struct vb2_buffer {
219 unsigned int memory; 223 unsigned int memory;
220 unsigned int num_planes; 224 unsigned int num_planes;
221 struct vb2_plane planes[VB2_MAX_PLANES]; 225 struct vb2_plane planes[VB2_MAX_PLANES];
226 u64 timestamp;
222 227
223 /* private: internal use only 228 /* private: internal use only
224 * 229 *
@@ -268,21 +273,26 @@ struct vb2_buffer {
268 * struct vb2_ops - driver-specific callbacks 273 * struct vb2_ops - driver-specific callbacks
269 * 274 *
270 * @queue_setup: called from VIDIOC_REQBUFS and VIDIOC_CREATE_BUFS 275 * @queue_setup: called from VIDIOC_REQBUFS and VIDIOC_CREATE_BUFS
271 * handlers before memory allocation, or, if 276 * handlers before memory allocation. It can be called
272 * *num_planes != 0, after the allocation to verify a 277 * twice: if the original number of requested buffers
273 * smaller number of buffers. Driver should return 278 * could not be allocated, then it will be called a
274 * the required number of buffers in *num_buffers, the 279 * second time with the actually allocated number of
275 * required number of planes per buffer in *num_planes; the 280 * buffers to verify if that is OK.
276 * size of each plane should be set in the sizes[] array 281 * The driver should return the required number of buffers
277 * and optional per-plane allocator specific context in the 282 * in *num_buffers, the required number of planes per
278 * alloc_ctxs[] array. When called from VIDIOC_REQBUFS, 283 * buffer in *num_planes, the size of each plane should be
279 * fmt == NULL, the driver has to use the currently 284 * set in the sizes[] array and optional per-plane
280 * configured format and *num_buffers is the total number 285 * allocator specific context in the alloc_ctxs[] array.
281 * of buffers, that are being allocated. When called from 286 * When called from VIDIOC_REQBUFS, *num_planes == 0, the
282 * VIDIOC_CREATE_BUFS, fmt != NULL and it describes the 287 * driver has to use the currently configured format to
283 * target frame format (if the format isn't valid the 288 * determine the plane sizes and *num_buffers is the total
284 * callback must return -EINVAL). In this case *num_buffers 289 * number of buffers that are being allocated. When called
285 * are being allocated additionally to q->num_buffers. 290 * from VIDIOC_CREATE_BUFS, *num_planes != 0 and it
291 * describes the requested number of planes and sizes[]
292 * contains the requested plane sizes. If either
293 * *num_planes or the requested sizes are invalid callback
294 * must return -EINVAL. In this case *num_buffers are
295 * being allocated additionally to q->num_buffers.
286 * @wait_prepare: release any locks taken while calling vb2 functions; 296 * @wait_prepare: release any locks taken while calling vb2 functions;
287 * it is called before an ioctl needs to wait for a new 297 * it is called before an ioctl needs to wait for a new
288 * buffer to arrive; required to avoid a deadlock in 298 * buffer to arrive; required to avoid a deadlock in
@@ -344,7 +354,7 @@ struct vb2_buffer {
344 * pre-queued buffers before calling STREAMON. 354 * pre-queued buffers before calling STREAMON.
345 */ 355 */
346struct vb2_ops { 356struct vb2_ops {
347 int (*queue_setup)(struct vb2_queue *q, const void *parg, 357 int (*queue_setup)(struct vb2_queue *q,
348 unsigned int *num_buffers, unsigned int *num_planes, 358 unsigned int *num_buffers, unsigned int *num_planes,
349 unsigned int sizes[], void *alloc_ctxs[]); 359 unsigned int sizes[], void *alloc_ctxs[]);
350 360
@@ -362,11 +372,22 @@ struct vb2_ops {
362 void (*buf_queue)(struct vb2_buffer *vb); 372 void (*buf_queue)(struct vb2_buffer *vb);
363}; 373};
364 374
375/**
376 * struct vb2_ops - driver-specific callbacks
377 *
378 * @fill_user_buffer: given a vb2_buffer fill in the userspace structure.
379 * For V4L2 this is a struct v4l2_buffer.
380 * @fill_vb2_buffer: given a userspace structure, fill in the vb2_buffer.
381 * If the userspace structure is invalid, then this op
382 * will return an error.
383 * @copy_timestamp: copy the timestamp from a userspace structure to
384 * the vb2_buffer struct.
385 */
365struct vb2_buf_ops { 386struct vb2_buf_ops {
366 int (*fill_user_buffer)(struct vb2_buffer *vb, void *pb); 387 void (*fill_user_buffer)(struct vb2_buffer *vb, void *pb);
367 int (*fill_vb2_buffer)(struct vb2_buffer *vb, const void *pb, 388 int (*fill_vb2_buffer)(struct vb2_buffer *vb, const void *pb,
368 struct vb2_plane *planes); 389 struct vb2_plane *planes);
369 int (*set_timestamp)(struct vb2_buffer *vb, const void *pb); 390 void (*copy_timestamp)(struct vb2_buffer *vb, const void *pb);
370}; 391};
371 392
372/** 393/**
@@ -429,6 +450,7 @@ struct vb2_buf_ops {
429 * called since poll() needs to return POLLERR in that situation. 450 * called since poll() needs to return POLLERR in that situation.
430 * @is_multiplanar: set if buffer type is multiplanar 451 * @is_multiplanar: set if buffer type is multiplanar
431 * @is_output: set if buffer type is output 452 * @is_output: set if buffer type is output
453 * @copy_timestamp: set if vb2-core should set timestamps
432 * @last_buffer_dequeued: used in poll() and DQBUF to immediately return if the 454 * @last_buffer_dequeued: used in poll() and DQBUF to immediately return if the
433 * last decoded buffer was already dequeued. Set for capture queues 455 * last decoded buffer was already dequeued. Set for capture queues
434 * when a buffer with the V4L2_BUF_FLAG_LAST is dequeued. 456 * when a buffer with the V4L2_BUF_FLAG_LAST is dequeued.
@@ -470,7 +492,6 @@ struct vb2_queue {
470 wait_queue_head_t done_wq; 492 wait_queue_head_t done_wq;
471 493
472 void *alloc_ctx[VB2_MAX_PLANES]; 494 void *alloc_ctx[VB2_MAX_PLANES];
473 unsigned int plane_sizes[VB2_MAX_PLANES];
474 495
475 unsigned int streaming:1; 496 unsigned int streaming:1;
476 unsigned int start_streaming_called:1; 497 unsigned int start_streaming_called:1;
@@ -478,6 +499,7 @@ struct vb2_queue {
478 unsigned int waiting_for_buffers:1; 499 unsigned int waiting_for_buffers:1;
479 unsigned int is_multiplanar:1; 500 unsigned int is_multiplanar:1;
480 unsigned int is_output:1; 501 unsigned int is_output:1;
502 unsigned int copy_timestamp:1;
481 unsigned int last_buffer_dequeued:1; 503 unsigned int last_buffer_dequeued:1;
482 504
483 struct vb2_fileio_data *fileio; 505 struct vb2_fileio_data *fileio;
@@ -503,11 +525,12 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state);
503void vb2_discard_done(struct vb2_queue *q); 525void vb2_discard_done(struct vb2_queue *q);
504int vb2_wait_for_all_buffers(struct vb2_queue *q); 526int vb2_wait_for_all_buffers(struct vb2_queue *q);
505 527
506int vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb); 528void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb);
507int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, 529int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
508 unsigned int *count); 530 unsigned int *count);
509int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, 531int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
510 unsigned int *count, const void *parg); 532 unsigned int *count, unsigned requested_planes,
533 const unsigned int requested_sizes[]);
511int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb); 534int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb);
512int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb); 535int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb);
513int vb2_core_dqbuf(struct vb2_queue *q, void *pb, bool nonblocking); 536int vb2_core_dqbuf(struct vb2_queue *q, void *pb, bool nonblocking);
@@ -531,6 +554,42 @@ unsigned long vb2_get_unmapped_area(struct vb2_queue *q,
531 unsigned long pgoff, 554 unsigned long pgoff,
532 unsigned long flags); 555 unsigned long flags);
533#endif 556#endif
557unsigned int vb2_core_poll(struct vb2_queue *q, struct file *file,
558 poll_table *wait);
559size_t vb2_read(struct vb2_queue *q, char __user *data, size_t count,
560 loff_t *ppos, int nonblock);
561size_t vb2_write(struct vb2_queue *q, const char __user *data, size_t count,
562 loff_t *ppos, int nonblock);
563
564/*
565 * vb2_thread_fnc - callback function for use with vb2_thread
566 *
567 * This is called whenever a buffer is dequeued in the thread.
568 */
569typedef int (*vb2_thread_fnc)(struct vb2_buffer *vb, void *priv);
570
571/**
572 * vb2_thread_start() - start a thread for the given queue.
573 * @q: videobuf queue
574 * @fnc: callback function
575 * @priv: priv pointer passed to the callback function
576 * @thread_name:the name of the thread. This will be prefixed with "vb2-".
577 *
578 * This starts a thread that will queue and dequeue until an error occurs
579 * or @vb2_thread_stop is called.
580 *
581 * This function should not be used for anything else but the videobuf2-dvb
582 * support. If you think you have another good use-case for this, then please
583 * contact the linux-media mailinglist first.
584 */
585int vb2_thread_start(struct vb2_queue *q, vb2_thread_fnc fnc, void *priv,
586 const char *thread_name);
587
588/**
589 * vb2_thread_stop() - stop the thread for the given queue.
590 * @q: videobuf queue
591 */
592int vb2_thread_stop(struct vb2_queue *q);
534 593
535/** 594/**
536 * vb2_is_streaming() - return streaming status of the queue 595 * vb2_is_streaming() - return streaming status of the queue
@@ -635,4 +694,11 @@ static inline void vb2_clear_last_buffer_dequeued(struct vb2_queue *q)
635 q->last_buffer_dequeued = false; 694 q->last_buffer_dequeued = false;
636} 695}
637 696
697/*
698 * The following functions are not part of the vb2 core API, but are useful
699 * functions for videobuf2-*.
700 */
701bool vb2_buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb);
702int vb2_verify_memory_type(struct vb2_queue *q,
703 enum vb2_memory memory, unsigned int type);
638#endif /* _MEDIA_VIDEOBUF2_CORE_H */ 704#endif /* _MEDIA_VIDEOBUF2_CORE_H */
diff --git a/include/media/videobuf2-v4l2.h b/include/media/videobuf2-v4l2.h
index 5abab1e7c7e8..3cc836f76675 100644
--- a/include/media/videobuf2-v4l2.h
+++ b/include/media/videobuf2-v4l2.h
@@ -28,7 +28,6 @@
28 * @vb2_buf: video buffer 2 28 * @vb2_buf: video buffer 2
29 * @flags: buffer informational flags 29 * @flags: buffer informational flags
30 * @field: enum v4l2_field; field order of the image in the buffer 30 * @field: enum v4l2_field; field order of the image in the buffer
31 * @timestamp: frame timestamp
32 * @timecode: frame timecode 31 * @timecode: frame timecode
33 * @sequence: sequence count of this frame 32 * @sequence: sequence count of this frame
34 * Should contain enough information to be able to cover all the fields 33 * Should contain enough information to be able to cover all the fields
@@ -39,7 +38,6 @@ struct vb2_v4l2_buffer {
39 38
40 __u32 flags; 39 __u32 flags;
41 __u32 field; 40 __u32 field;
42 struct timeval timestamp;
43 struct v4l2_timecode timecode; 41 struct v4l2_timecode timecode;
44 __u32 sequence; 42 __u32 sequence;
45}; 43};
@@ -65,42 +63,8 @@ int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type);
65 63
66int __must_check vb2_queue_init(struct vb2_queue *q); 64int __must_check vb2_queue_init(struct vb2_queue *q);
67void vb2_queue_release(struct vb2_queue *q); 65void vb2_queue_release(struct vb2_queue *q);
68 66unsigned int vb2_poll(struct vb2_queue *q, struct file *file,
69unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait); 67 poll_table *wait);
70size_t vb2_read(struct vb2_queue *q, char __user *data, size_t count,
71 loff_t *ppos, int nonblock);
72size_t vb2_write(struct vb2_queue *q, const char __user *data, size_t count,
73 loff_t *ppos, int nonblock);
74
75/*
76 * vb2_thread_fnc - callback function for use with vb2_thread
77 *
78 * This is called whenever a buffer is dequeued in the thread.
79 */
80typedef int (*vb2_thread_fnc)(struct vb2_buffer *vb, void *priv);
81
82/**
83 * vb2_thread_start() - start a thread for the given queue.
84 * @q: videobuf queue
85 * @fnc: callback function
86 * @priv: priv pointer passed to the callback function
87 * @thread_name:the name of the thread. This will be prefixed with "vb2-".
88 *
89 * This starts a thread that will queue and dequeue until an error occurs
90 * or @vb2_thread_stop is called.
91 *
92 * This function should not be used for anything else but the videobuf2-dvb
93 * support. If you think you have another good use-case for this, then please
94 * contact the linux-media mailinglist first.
95 */
96int vb2_thread_start(struct vb2_queue *q, vb2_thread_fnc fnc, void *priv,
97 const char *thread_name);
98
99/**
100 * vb2_thread_stop() - stop the thread for the given queue.
101 * @q: videobuf queue
102 */
103int vb2_thread_stop(struct vb2_queue *q);
104 68
105/* 69/*
106 * The following functions are not part of the vb2 core API, but are simple 70 * The following functions are not part of the vb2 core API, but are simple
diff --git a/include/trace/events/v4l2.h b/include/trace/events/v4l2.h
index 22afa26e34b2..ee7754c6e4a1 100644
--- a/include/trace/events/v4l2.h
+++ b/include/trace/events/v4l2.h
@@ -184,7 +184,7 @@ DECLARE_EVENT_CLASS(vb2_v4l2_event_class,
184 __field(int, minor) 184 __field(int, minor)
185 __field(u32, flags) 185 __field(u32, flags)
186 __field(u32, field) 186 __field(u32, field)
187 __field(s64, timestamp) 187 __field(u64, timestamp)
188 __field(u32, timecode_type) 188 __field(u32, timecode_type)
189 __field(u32, timecode_flags) 189 __field(u32, timecode_flags)
190 __field(u8, timecode_frames) 190 __field(u8, timecode_frames)
@@ -205,7 +205,7 @@ DECLARE_EVENT_CLASS(vb2_v4l2_event_class,
205 __entry->minor = owner ? owner->vdev->minor : -1; 205 __entry->minor = owner ? owner->vdev->minor : -1;
206 __entry->flags = vbuf->flags; 206 __entry->flags = vbuf->flags;
207 __entry->field = vbuf->field; 207 __entry->field = vbuf->field;
208 __entry->timestamp = timeval_to_ns(&vbuf->timestamp); 208 __entry->timestamp = vb->timestamp;
209 __entry->timecode_type = vbuf->timecode.type; 209 __entry->timecode_type = vbuf->timecode.type;
210 __entry->timecode_flags = vbuf->timecode.flags; 210 __entry->timecode_flags = vbuf->timecode.flags;
211 __entry->timecode_frames = vbuf->timecode.frames; 211 __entry->timecode_frames = vbuf->timecode.frames;
diff --git a/include/trace/events/vb2.h b/include/trace/events/vb2.h
index bfeceeba3744..c1a22416ed05 100644
--- a/include/trace/events/vb2.h
+++ b/include/trace/events/vb2.h
@@ -18,6 +18,7 @@ DECLARE_EVENT_CLASS(vb2_event_class,
18 __field(u32, index) 18 __field(u32, index)
19 __field(u32, type) 19 __field(u32, type)
20 __field(u32, bytesused) 20 __field(u32, bytesused)
21 __field(u64, timestamp)
21 ), 22 ),
22 23
23 TP_fast_assign( 24 TP_fast_assign(
@@ -28,14 +29,16 @@ DECLARE_EVENT_CLASS(vb2_event_class,
28 __entry->index = vb->index; 29 __entry->index = vb->index;
29 __entry->type = vb->type; 30 __entry->type = vb->type;
30 __entry->bytesused = vb->planes[0].bytesused; 31 __entry->bytesused = vb->planes[0].bytesused;
32 __entry->timestamp = vb->timestamp;
31 ), 33 ),
32 34
33 TP_printk("owner = %p, queued = %u, owned_by_drv = %d, index = %u, " 35 TP_printk("owner = %p, queued = %u, owned_by_drv = %d, index = %u, "
34 "type = %u, bytesused = %u", __entry->owner, 36 "type = %u, bytesused = %u, timestamp = %llu", __entry->owner,
35 __entry->queued_count, 37 __entry->queued_count,
36 __entry->owned_by_drv_count, 38 __entry->owned_by_drv_count,
37 __entry->index, __entry->type, 39 __entry->index, __entry->type,
38 __entry->bytesused 40 __entry->bytesused,
41 __entry->timestamp
39 ) 42 )
40) 43)
41 44
diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
index 0b69a7753558..ee2d542c65f5 100644
--- a/include/uapi/drm/drm_fourcc.h
+++ b/include/uapi/drm/drm_fourcc.h
@@ -225,7 +225,7 @@
225 * - multiple of 128 pixels for the width 225 * - multiple of 128 pixels for the width
226 * - multiple of 32 pixels for the height 226 * - multiple of 32 pixels for the height
227 * 227 *
228 * For more information: see http://linuxtv.org/downloads/v4l-dvb-apis/re32.html 228 * For more information: see https://linuxtv.org/downloads/v4l-dvb-apis/re32.html
229 */ 229 */
230#define DRM_FORMAT_MOD_SAMSUNG_64_32_TILE fourcc_mod_code(SAMSUNG, 1) 230#define DRM_FORMAT_MOD_SAMSUNG_64_32_TILE fourcc_mod_code(SAMSUNG, 1)
231 231
diff --git a/include/uapi/linux/dvb/video.h b/include/uapi/linux/dvb/video.h
index d3d14a59d2d5..49392564f9d6 100644
--- a/include/uapi/linux/dvb/video.h
+++ b/include/uapi/linux/dvb/video.h
@@ -26,7 +26,6 @@
26 26
27#include <linux/types.h> 27#include <linux/types.h>
28#ifndef __KERNEL__ 28#ifndef __KERNEL__
29#include <stdint.h>
30#include <time.h> 29#include <time.h>
31#endif 30#endif
32 31
diff --git a/include/uapi/linux/lirc.h b/include/uapi/linux/lirc.h
new file mode 100644
index 000000000000..4b3ab2966b5a
--- /dev/null
+++ b/include/uapi/linux/lirc.h
@@ -0,0 +1,168 @@
1/*
2 * lirc.h - linux infrared remote control header file
3 * last modified 2010/07/13 by Jarod Wilson
4 */
5
6#ifndef _LINUX_LIRC_H
7#define _LINUX_LIRC_H
8
9#include <linux/types.h>
10#include <linux/ioctl.h>
11
12#define PULSE_BIT 0x01000000
13#define PULSE_MASK 0x00FFFFFF
14
15#define LIRC_MODE2_SPACE 0x00000000
16#define LIRC_MODE2_PULSE 0x01000000
17#define LIRC_MODE2_FREQUENCY 0x02000000
18#define LIRC_MODE2_TIMEOUT 0x03000000
19
20#define LIRC_VALUE_MASK 0x00FFFFFF
21#define LIRC_MODE2_MASK 0xFF000000
22
23#define LIRC_SPACE(val) (((val)&LIRC_VALUE_MASK) | LIRC_MODE2_SPACE)
24#define LIRC_PULSE(val) (((val)&LIRC_VALUE_MASK) | LIRC_MODE2_PULSE)
25#define LIRC_FREQUENCY(val) (((val)&LIRC_VALUE_MASK) | LIRC_MODE2_FREQUENCY)
26#define LIRC_TIMEOUT(val) (((val)&LIRC_VALUE_MASK) | LIRC_MODE2_TIMEOUT)
27
28#define LIRC_VALUE(val) ((val)&LIRC_VALUE_MASK)
29#define LIRC_MODE2(val) ((val)&LIRC_MODE2_MASK)
30
31#define LIRC_IS_SPACE(val) (LIRC_MODE2(val) == LIRC_MODE2_SPACE)
32#define LIRC_IS_PULSE(val) (LIRC_MODE2(val) == LIRC_MODE2_PULSE)
33#define LIRC_IS_FREQUENCY(val) (LIRC_MODE2(val) == LIRC_MODE2_FREQUENCY)
34#define LIRC_IS_TIMEOUT(val) (LIRC_MODE2(val) == LIRC_MODE2_TIMEOUT)
35
36/* used heavily by lirc userspace */
37#define lirc_t int
38
39/*** lirc compatible hardware features ***/
40
41#define LIRC_MODE2SEND(x) (x)
42#define LIRC_SEND2MODE(x) (x)
43#define LIRC_MODE2REC(x) ((x) << 16)
44#define LIRC_REC2MODE(x) ((x) >> 16)
45
46#define LIRC_MODE_RAW 0x00000001
47#define LIRC_MODE_PULSE 0x00000002
48#define LIRC_MODE_MODE2 0x00000004
49#define LIRC_MODE_LIRCCODE 0x00000010
50
51
52#define LIRC_CAN_SEND_RAW LIRC_MODE2SEND(LIRC_MODE_RAW)
53#define LIRC_CAN_SEND_PULSE LIRC_MODE2SEND(LIRC_MODE_PULSE)
54#define LIRC_CAN_SEND_MODE2 LIRC_MODE2SEND(LIRC_MODE_MODE2)
55#define LIRC_CAN_SEND_LIRCCODE LIRC_MODE2SEND(LIRC_MODE_LIRCCODE)
56
57#define LIRC_CAN_SEND_MASK 0x0000003f
58
59#define LIRC_CAN_SET_SEND_CARRIER 0x00000100
60#define LIRC_CAN_SET_SEND_DUTY_CYCLE 0x00000200
61#define LIRC_CAN_SET_TRANSMITTER_MASK 0x00000400
62
63#define LIRC_CAN_REC_RAW LIRC_MODE2REC(LIRC_MODE_RAW)
64#define LIRC_CAN_REC_PULSE LIRC_MODE2REC(LIRC_MODE_PULSE)
65#define LIRC_CAN_REC_MODE2 LIRC_MODE2REC(LIRC_MODE_MODE2)
66#define LIRC_CAN_REC_LIRCCODE LIRC_MODE2REC(LIRC_MODE_LIRCCODE)
67
68#define LIRC_CAN_REC_MASK LIRC_MODE2REC(LIRC_CAN_SEND_MASK)
69
70#define LIRC_CAN_SET_REC_CARRIER (LIRC_CAN_SET_SEND_CARRIER << 16)
71#define LIRC_CAN_SET_REC_DUTY_CYCLE (LIRC_CAN_SET_SEND_DUTY_CYCLE << 16)
72
73#define LIRC_CAN_SET_REC_DUTY_CYCLE_RANGE 0x40000000
74#define LIRC_CAN_SET_REC_CARRIER_RANGE 0x80000000
75#define LIRC_CAN_GET_REC_RESOLUTION 0x20000000
76#define LIRC_CAN_SET_REC_TIMEOUT 0x10000000
77#define LIRC_CAN_SET_REC_FILTER 0x08000000
78
79#define LIRC_CAN_MEASURE_CARRIER 0x02000000
80#define LIRC_CAN_USE_WIDEBAND_RECEIVER 0x04000000
81
82#define LIRC_CAN_SEND(x) ((x)&LIRC_CAN_SEND_MASK)
83#define LIRC_CAN_REC(x) ((x)&LIRC_CAN_REC_MASK)
84
85#define LIRC_CAN_NOTIFY_DECODE 0x01000000
86
87/*** IOCTL commands for lirc driver ***/
88
89#define LIRC_GET_FEATURES _IOR('i', 0x00000000, __u32)
90
91#define LIRC_GET_SEND_MODE _IOR('i', 0x00000001, __u32)
92#define LIRC_GET_REC_MODE _IOR('i', 0x00000002, __u32)
93#define LIRC_GET_SEND_CARRIER _IOR('i', 0x00000003, __u32)
94#define LIRC_GET_REC_CARRIER _IOR('i', 0x00000004, __u32)
95#define LIRC_GET_SEND_DUTY_CYCLE _IOR('i', 0x00000005, __u32)
96#define LIRC_GET_REC_DUTY_CYCLE _IOR('i', 0x00000006, __u32)
97#define LIRC_GET_REC_RESOLUTION _IOR('i', 0x00000007, __u32)
98
99#define LIRC_GET_MIN_TIMEOUT _IOR('i', 0x00000008, __u32)
100#define LIRC_GET_MAX_TIMEOUT _IOR('i', 0x00000009, __u32)
101
102#define LIRC_GET_MIN_FILTER_PULSE _IOR('i', 0x0000000a, __u32)
103#define LIRC_GET_MAX_FILTER_PULSE _IOR('i', 0x0000000b, __u32)
104#define LIRC_GET_MIN_FILTER_SPACE _IOR('i', 0x0000000c, __u32)
105#define LIRC_GET_MAX_FILTER_SPACE _IOR('i', 0x0000000d, __u32)
106
107/* code length in bits, currently only for LIRC_MODE_LIRCCODE */
108#define LIRC_GET_LENGTH _IOR('i', 0x0000000f, __u32)
109
110#define LIRC_SET_SEND_MODE _IOW('i', 0x00000011, __u32)
111#define LIRC_SET_REC_MODE _IOW('i', 0x00000012, __u32)
112/* Note: these can reset the according pulse_width */
113#define LIRC_SET_SEND_CARRIER _IOW('i', 0x00000013, __u32)
114#define LIRC_SET_REC_CARRIER _IOW('i', 0x00000014, __u32)
115#define LIRC_SET_SEND_DUTY_CYCLE _IOW('i', 0x00000015, __u32)
116#define LIRC_SET_REC_DUTY_CYCLE _IOW('i', 0x00000016, __u32)
117#define LIRC_SET_TRANSMITTER_MASK _IOW('i', 0x00000017, __u32)
118
119/*
120 * when a timeout != 0 is set the driver will send a
121 * LIRC_MODE2_TIMEOUT data packet, otherwise LIRC_MODE2_TIMEOUT is
122 * never sent, timeout is disabled by default
123 */
124#define LIRC_SET_REC_TIMEOUT _IOW('i', 0x00000018, __u32)
125
126/* 1 enables, 0 disables timeout reports in MODE2 */
127#define LIRC_SET_REC_TIMEOUT_REPORTS _IOW('i', 0x00000019, __u32)
128
129/*
130 * pulses shorter than this are filtered out by hardware (software
131 * emulation in lirc_dev?)
132 */
133#define LIRC_SET_REC_FILTER_PULSE _IOW('i', 0x0000001a, __u32)
134/*
135 * spaces shorter than this are filtered out by hardware (software
136 * emulation in lirc_dev?)
137 */
138#define LIRC_SET_REC_FILTER_SPACE _IOW('i', 0x0000001b, __u32)
139/*
140 * if filter cannot be set independently for pulse/space, this should
141 * be used
142 */
143#define LIRC_SET_REC_FILTER _IOW('i', 0x0000001c, __u32)
144
145/*
146 * if enabled from the next key press on the driver will send
147 * LIRC_MODE2_FREQUENCY packets
148 */
149#define LIRC_SET_MEASURE_CARRIER_MODE _IOW('i', 0x0000001d, __u32)
150
151/*
152 * to set a range use
153 * LIRC_SET_REC_DUTY_CYCLE_RANGE/LIRC_SET_REC_CARRIER_RANGE with the
154 * lower bound first and later
155 * LIRC_SET_REC_DUTY_CYCLE/LIRC_SET_REC_CARRIER with the upper bound
156 */
157
158#define LIRC_SET_REC_DUTY_CYCLE_RANGE _IOW('i', 0x0000001e, __u32)
159#define LIRC_SET_REC_CARRIER_RANGE _IOW('i', 0x0000001f, __u32)
160
161#define LIRC_NOTIFY_DECODE _IO('i', 0x00000020)
162
163#define LIRC_SETUP_START _IO('i', 0x00000021)
164#define LIRC_SETUP_END _IO('i', 0x00000022)
165
166#define LIRC_SET_WIDEBAND_RECEIVER _IOW('i', 0x00000023, __u32)
167
168#endif
diff --git a/include/uapi/linux/usb/video.h b/include/uapi/linux/usb/video.h
index 3b3b95e01f71..69ab695fad2e 100644
--- a/include/uapi/linux/usb/video.h
+++ b/include/uapi/linux/usb/video.h
@@ -28,6 +28,7 @@
28 28
29/* A.3. Video Interface Protocol Codes */ 29/* A.3. Video Interface Protocol Codes */
30#define UVC_PC_PROTOCOL_UNDEFINED 0x00 30#define UVC_PC_PROTOCOL_UNDEFINED 0x00
31#define UVC_PC_PROTOCOL_15 0x01
31 32
32/* A.5. Video Class-Specific VC Interface Descriptor Subtypes */ 33/* A.5. Video Class-Specific VC Interface Descriptor Subtypes */
33#define UVC_VC_DESCRIPTOR_UNDEFINED 0x00 34#define UVC_VC_DESCRIPTOR_UNDEFINED 0x00
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index 1bdce501ad6b..2d225bcdb831 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -158,8 +158,10 @@ enum v4l2_colorfx {
158 * We reserve 16 controls for this driver. */ 158 * We reserve 16 controls for this driver. */
159#define V4L2_CID_USER_S2255_BASE (V4L2_CID_USER_BASE + 0x1030) 159#define V4L2_CID_USER_S2255_BASE (V4L2_CID_USER_BASE + 0x1030)
160 160
161/* The base for the si476x driver controls. See include/media/si476x.h for the list 161/*
162 * of controls. Total of 16 controls is reserved for this driver */ 162 * The base for the si476x driver controls. See include/media/drv-intf/si476x.h
163 * for the list of controls. Total of 16 controls is reserved for this driver
164 */
163#define V4L2_CID_USER_SI476X_BASE (V4L2_CID_USER_BASE + 0x1040) 165#define V4L2_CID_USER_SI476X_BASE (V4L2_CID_USER_BASE + 0x1040)
164 166
165/* The base for the TI VPE driver controls. Total of 16 controls is reserved for 167/* The base for the TI VPE driver controls. Total of 16 controls is reserved for
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index a0e87d16b726..14cd5ebfee6d 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -46,7 +46,7 @@
46 * All kernel-specific stuff were moved to media/v4l2-dev.h, so 46 * All kernel-specific stuff were moved to media/v4l2-dev.h, so
47 * no #if __KERNEL tests are allowed here 47 * no #if __KERNEL tests are allowed here
48 * 48 *
49 * See http://linuxtv.org for more info 49 * See https://linuxtv.org for more info
50 * 50 *
51 * Author: Bill Dirks <bill@thedirks.org> 51 * Author: Bill Dirks <bill@thedirks.org>
52 * Justin Schoeman 52 * Justin Schoeman
@@ -1476,7 +1476,12 @@ struct v4l2_ext_control {
1476} __attribute__ ((packed)); 1476} __attribute__ ((packed));
1477 1477
1478struct v4l2_ext_controls { 1478struct v4l2_ext_controls {
1479 __u32 ctrl_class; 1479 union {
1480#ifndef __KERNEL__
1481 __u32 ctrl_class;
1482#endif
1483 __u32 which;
1484 };
1480 __u32 count; 1485 __u32 count;
1481 __u32 error_idx; 1486 __u32 error_idx;
1482 __u32 reserved[2]; 1487 __u32 reserved[2];
@@ -1484,9 +1489,14 @@ struct v4l2_ext_controls {
1484}; 1489};
1485 1490
1486#define V4L2_CTRL_ID_MASK (0x0fffffff) 1491#define V4L2_CTRL_ID_MASK (0x0fffffff)
1492#ifndef __KERNEL__
1487#define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL) 1493#define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL)
1494#endif
1495#define V4L2_CTRL_ID2WHICH(id) ((id) & 0x0fff0000UL)
1488#define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000) 1496#define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000)
1489#define V4L2_CTRL_MAX_DIMS (4) 1497#define V4L2_CTRL_MAX_DIMS (4)
1498#define V4L2_CTRL_WHICH_CUR_VAL 0
1499#define V4L2_CTRL_WHICH_DEF_VAL 0x0f000000
1490 1500
1491enum v4l2_ctrl_type { 1501enum v4l2_ctrl_type {
1492 V4L2_CTRL_TYPE_INTEGER = 1, 1502 V4L2_CTRL_TYPE_INTEGER = 1,
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index e0d9363dc7fd..514f2604086e 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -113,7 +113,7 @@
113#include <sound/initval.h> 113#include <sound/initval.h>
114 114
115#ifdef CONFIG_SND_ES1968_RADIO 115#ifdef CONFIG_SND_ES1968_RADIO
116#include <media/tea575x.h> 116#include <media/drv-intf/tea575x.h>
117#endif 117#endif
118 118
119#define CARD_NAME "ESS Maestro1/2" 119#define CARD_NAME "ESS Maestro1/2"
@@ -2605,7 +2605,7 @@ static void snd_es1968_tea575x_set_direction(struct snd_tea575x *tea, bool outpu
2605 } 2605 }
2606} 2606}
2607 2607
2608static struct snd_tea575x_ops snd_es1968_tea_ops = { 2608static const struct snd_tea575x_ops snd_es1968_tea_ops = {
2609 .set_pins = snd_es1968_tea575x_set_pins, 2609 .set_pins = snd_es1968_tea575x_set_pins,
2610 .get_pins = snd_es1968_tea575x_get_pins, 2610 .get_pins = snd_es1968_tea575x_get_pins,
2611 .set_direction = snd_es1968_tea575x_set_direction, 2611 .set_direction = snd_es1968_tea575x_set_direction,
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index 1fdd92b6f18f..759295aa8366 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -30,7 +30,7 @@
30#include <sound/initval.h> 30#include <sound/initval.h>
31 31
32#ifdef CONFIG_SND_FM801_TEA575X_BOOL 32#ifdef CONFIG_SND_FM801_TEA575X_BOOL
33#include <media/tea575x.h> 33#include <media/drv-intf/tea575x.h>
34#endif 34#endif
35 35
36MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); 36MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
@@ -815,7 +815,7 @@ static void snd_fm801_tea575x_set_direction(struct snd_tea575x *tea, bool output
815 fm801_writew(chip, GPIO_CTRL, reg); 815 fm801_writew(chip, GPIO_CTRL, reg);
816} 816}
817 817
818static struct snd_tea575x_ops snd_fm801_tea_ops = { 818static const struct snd_tea575x_ops snd_fm801_tea_ops = {
819 .set_pins = snd_fm801_tea575x_set_pins, 819 .set_pins = snd_fm801_tea575x_set_pins,
820 .get_pins = snd_fm801_tea575x_get_pins, 820 .get_pins = snd_fm801_tea575x_get_pins,
821 .set_direction = snd_fm801_tea575x_set_direction, 821 .set_direction = snd_fm801_tea575x_set_direction,