aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-13 22:22:22 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-13 22:22:22 -0500
commitd8c532c40721f7507896d202b8cae3b3642d2b0d (patch)
tree42b1ce76671eb85324281ed93491432f4523f983
parente777d192ffb9f2929d547a2f8a5f65b7db7a9552 (diff)
parent77c53d0b56264a8fc5844e087ad15fffe20c299d (diff)
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab: - Missing MAINTAINERS entries were added for several drivers - Adds V4L2 support for DMABUF handling, allowing zero-copy buffer sharing between V4L2 devices and GPU - Got rid of all warnings when compiling with W=1 on x86 - Add a new driver for Exynos hardware (s3c-camif) - Several bug fixes, cleanups and driver improvements * 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (243 commits) [media] omap3isp: Replace cpu_is_omap3630() with ISP revision check [media] omap3isp: Prepare/unprepare clocks before/after enable/disable [media] omap3isp: preview: Add support for 8-bit formats at the sink pad [media] omap3isp: Replace printk with dev_* [media] omap3isp: Find source pad from external entity [media] omap3isp: Configure CSI-2 phy based on platform data [media] omap3isp: Add PHY routing configuration [media] omap3isp: Add CSI configuration registers from control block to ISP resources [media] omap3isp: Remove unneeded module memory address definitions [media] omap3isp: Use monotonic timestamps for statistics buffers [media] uvcvideo: Fix control value clamping for unsigned integer controls [media] uvcvideo: Mark first output terminal as default video node [media] uvcvideo: Add VIDIOC_[GS]_PRIORITY support [media] uvcvideo: Return -ENOTTY for unsupported ioctls [media] uvcvideo: Set device_caps in VIDIOC_QUERYCAP [media] uvcvideo: Don't fail when an unsupported format is requested [media] uvcvideo: Return -EACCES when trying to access a read/write-only control [media] uvcvideo: Set error_idx properly for extended controls API failures [media] rtl28xxu: add NOXON DAB/DAB+ USB dongle rev 2 [media] fc2580: write some registers conditionally ...
-rw-r--r--Documentation/DocBook/media/v4l/compat.xml7
-rw-r--r--Documentation/DocBook/media/v4l/io.xml188
-rw-r--r--Documentation/DocBook/media/v4l/v4l2.xml1
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-create-bufs.xml16
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-expbuf.xml212
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-qbuf.xml17
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-reqbufs.xml47
-rw-r--r--MAINTAINERS250
-rw-r--r--arch/arm/mach-omap2/devices.c10
-rw-r--r--arch/arm/mach-pxa/pcm990-baseboard.c6
-rw-r--r--drivers/base/dma-mapping.c4
-rw-r--r--drivers/hid/hid-picolcd_cir.c2
-rw-r--r--drivers/media/common/Kconfig7
-rw-r--r--drivers/media/common/b2c2/Kconfig5
-rw-r--r--drivers/media/common/siano/Kconfig18
-rw-r--r--drivers/media/common/siano/Makefile6
-rw-r--r--drivers/media/common/siano/smscoreapi.c2
-rw-r--r--drivers/media/common/siano/smsir.c2
-rw-r--r--drivers/media/common/siano/smsir.h9
-rw-r--r--drivers/media/dvb-core/dmxdev.c2
-rw-r--r--drivers/media/dvb-core/dmxdev.h1
-rw-r--r--drivers/media/dvb-core/dvb-usb-ids.h1
-rw-r--r--drivers/media/dvb-core/dvb_frontend.c10
-rw-r--r--drivers/media/dvb-frontends/cx22700.c4
-rw-r--r--drivers/media/dvb-frontends/cx24123.c2
-rw-r--r--drivers/media/dvb-frontends/dib9000.h2
-rw-r--r--drivers/media/dvb-frontends/drxd_hard.c8
-rw-r--r--drivers/media/dvb-frontends/drxk_hard.c24
-rw-r--r--drivers/media/dvb-frontends/drxk_hard.h6
-rw-r--r--drivers/media/dvb-frontends/ds3000.c15
-rw-r--r--drivers/media/dvb-frontends/l64781.c4
-rw-r--r--drivers/media/dvb-frontends/mt312.c4
-rw-r--r--drivers/media/dvb-frontends/rtl2830.c6
-rw-r--r--drivers/media/dvb-frontends/rtl2832.c6
-rw-r--r--drivers/media/dvb-frontends/stb0899_drv.c2
-rw-r--r--drivers/media/dvb-frontends/stv0367.c19
-rw-r--r--drivers/media/dvb-frontends/tda10071.c6
-rw-r--r--drivers/media/dvb-frontends/tda18271c2dd.c1
-rw-r--r--drivers/media/firewire/firedtv.h1
-rw-r--r--drivers/media/i2c/adp1653.c4
-rw-r--r--drivers/media/i2c/adv7183.c13
-rw-r--r--drivers/media/i2c/adv7604.c16
-rw-r--r--drivers/media/i2c/cx25840/cx25840-core.c2
-rw-r--r--drivers/media/i2c/ir-kbd-i2c.c14
-rw-r--r--drivers/media/i2c/s5k4ecgx.c2
-rw-r--r--drivers/media/i2c/smiapp-pll.c219
-rw-r--r--drivers/media/i2c/smiapp-pll.h61
-rw-r--r--drivers/media/i2c/smiapp/smiapp-core.c74
-rw-r--r--drivers/media/i2c/smiapp/smiapp-limits.c2
-rw-r--r--drivers/media/i2c/smiapp/smiapp-limits.h2
-rw-r--r--drivers/media/i2c/smiapp/smiapp-quirk.c2
-rw-r--r--drivers/media/i2c/smiapp/smiapp-quirk.h2
-rw-r--r--drivers/media/i2c/smiapp/smiapp-reg-defs.h2
-rw-r--r--drivers/media/i2c/smiapp/smiapp-reg.h2
-rw-r--r--drivers/media/i2c/smiapp/smiapp-regs.c2
-rw-r--r--drivers/media/i2c/smiapp/smiapp-regs.h2
-rw-r--r--drivers/media/i2c/smiapp/smiapp.h2
-rw-r--r--drivers/media/i2c/soc_camera/mt9v022.c88
-rw-r--r--drivers/media/i2c/soc_camera/ov2640.c55
-rw-r--r--drivers/media/i2c/vs6624.c13
-rw-r--r--drivers/media/mmc/siano/Kconfig3
-rw-r--r--drivers/media/pci/bt8xx/bttv-driver.c7
-rw-r--r--drivers/media/pci/cx18/cx18-alsa-main.c2
-rw-r--r--drivers/media/pci/cx18/cx18-alsa-pcm.c1
-rw-r--r--drivers/media/pci/cx18/cx18-i2c.c2
-rw-r--r--drivers/media/pci/cx18/cx18-streams.c2
-rw-r--r--drivers/media/pci/cx23885/altera-ci.c45
-rw-r--r--drivers/media/pci/cx23885/cimax2.c17
-rw-r--r--drivers/media/pci/cx23885/cx23885-alsa.c6
-rw-r--r--drivers/media/pci/cx23885/cx23885-av.c1
-rw-r--r--drivers/media/pci/cx23885/cx23885-cards.c2
-rw-r--r--drivers/media/pci/cx23885/cx23885-core.c8
-rw-r--r--drivers/media/pci/cx23885/cx23885-dvb.c2
-rw-r--r--drivers/media/pci/cx23885/cx23885-f300.c1
-rw-r--r--drivers/media/pci/cx23885/cx23885-input.c7
-rw-r--r--drivers/media/pci/cx23885/cx23885-input.h2
-rw-r--r--drivers/media/pci/cx23885/cx23885-ioctl.c2
-rw-r--r--drivers/media/pci/cx23885/cx23885-ir.c1
-rw-r--r--drivers/media/pci/cx23885/cx23888-ir.c1
-rw-r--r--drivers/media/pci/cx23885/netup-init.c1
-rw-r--r--drivers/media/pci/cx25821/cx25821-audio-upstream.c44
-rw-r--r--drivers/media/pci/cx25821/cx25821-biffuncs.h6
-rw-r--r--drivers/media/pci/cx25821/cx25821-i2c.c4
-rw-r--r--drivers/media/pci/cx25821/cx25821-video-upstream-ch2.c54
-rw-r--r--drivers/media/pci/cx25821/cx25821-video-upstream.c47
-rw-r--r--drivers/media/pci/cx25821/cx25821-video.c8
-rw-r--r--drivers/media/pci/cx88/cx88-alsa.c14
-rw-r--r--drivers/media/pci/cx88/cx88-blackbird.c7
-rw-r--r--drivers/media/pci/cx88/cx88-core.c12
-rw-r--r--drivers/media/pci/cx88/cx88-input.c8
-rw-r--r--drivers/media/pci/cx88/cx88-mpeg.c18
-rw-r--r--drivers/media/pci/cx88/cx88.h4
-rw-r--r--drivers/media/pci/dm1105/dm1105.c8
-rw-r--r--drivers/media/pci/ivtv/ivtv-alsa-main.c2
-rw-r--r--drivers/media/pci/ivtv/ivtv-alsa-pcm.c6
-rw-r--r--drivers/media/pci/ivtv/ivtv-alsa-pcm.h4
-rw-r--r--drivers/media/pci/ivtv/ivtv-firmware.c2
-rw-r--r--drivers/media/pci/ivtv/ivtv-i2c.c8
-rw-r--r--drivers/media/pci/ivtv/ivtv-ioctl.c4
-rw-r--r--drivers/media/pci/mantis/mantis_input.c5
-rw-r--r--drivers/media/pci/mantis/mantis_uart.c2
-rw-r--r--drivers/media/pci/mantis/mantis_vp1033.c6
-rw-r--r--drivers/media/pci/meye/meye.c2
-rw-r--r--drivers/media/pci/ngene/ngene-cards.c4
-rw-r--r--drivers/media/pci/ngene/ngene-core.c7
-rw-r--r--drivers/media/pci/saa7134/saa7134-core.c3
-rw-r--r--drivers/media/pci/saa7134/saa7134-input.c2
-rw-r--r--drivers/media/pci/saa7134/saa7134-video.c2
-rw-r--r--drivers/media/pci/saa7164/saa7164-api.c26
-rw-r--r--drivers/media/pci/saa7164/saa7164-bus.c6
-rw-r--r--drivers/media/pci/saa7164/saa7164-cmd.c16
-rw-r--r--drivers/media/pci/saa7164/saa7164-core.c4
-rw-r--r--drivers/media/pci/saa7164/saa7164-encoder.c15
-rw-r--r--drivers/media/pci/saa7164/saa7164-fw.c8
-rw-r--r--drivers/media/pci/saa7164/saa7164-vbi.c6
-rw-r--r--drivers/media/pci/ttpci/av7110.h1
-rw-r--r--drivers/media/pci/ttpci/budget-av.c4
-rw-r--r--drivers/media/platform/Kconfig12
-rw-r--r--drivers/media/platform/Makefile1
-rw-r--r--drivers/media/platform/blackfin/bfin_capture.c14
-rw-r--r--drivers/media/platform/coda.c4
-rw-r--r--drivers/media/platform/davinci/Kconfig2
-rw-r--r--drivers/media/platform/davinci/dm355_ccdc.c8
-rw-r--r--drivers/media/platform/davinci/dm644x_ccdc.c16
-rw-r--r--drivers/media/platform/davinci/isif.c5
-rw-r--r--drivers/media/platform/davinci/vpbe.c10
-rw-r--r--drivers/media/platform/davinci/vpbe_display.c303
-rw-r--r--drivers/media/platform/davinci/vpbe_osd.c9
-rw-r--r--drivers/media/platform/davinci/vpif.c8
-rw-r--r--drivers/media/platform/davinci/vpif_capture.c34
-rw-r--r--drivers/media/platform/davinci/vpif_display.c28
-rw-r--r--drivers/media/platform/exynos-gsc/gsc-core.c2
-rw-r--r--drivers/media/platform/exynos-gsc/gsc-m2m.c2
-rw-r--r--drivers/media/platform/fsl-viu.c6
-rw-r--r--drivers/media/platform/m2m-deinterlace.c24
-rw-r--r--drivers/media/platform/mem2mem_testdev.c4
-rw-r--r--drivers/media/platform/mx2_emmaprp.c14
-rw-r--r--drivers/media/platform/omap/omap_vout.c36
-rw-r--r--drivers/media/platform/omap3isp/isp.c83
-rw-r--r--drivers/media/platform/omap3isp/isp.h5
-rw-r--r--drivers/media/platform/omap3isp/ispcsi2.c6
-rw-r--r--drivers/media/platform/omap3isp/ispcsiphy.c227
-rw-r--r--drivers/media/platform/omap3isp/ispcsiphy.h10
-rw-r--r--drivers/media/platform/omap3isp/isphist.c8
-rw-r--r--drivers/media/platform/omap3isp/isppreview.c41
-rw-r--r--drivers/media/platform/omap3isp/ispreg.h99
-rw-r--r--drivers/media/platform/omap3isp/ispstat.c5
-rw-r--r--drivers/media/platform/omap3isp/ispstat.h2
-rw-r--r--drivers/media/platform/omap3isp/ispvideo.c3
-rw-r--r--drivers/media/platform/s3c-camif/Makefile5
-rw-r--r--drivers/media/platform/s3c-camif/camif-capture.c1672
-rw-r--r--drivers/media/platform/s3c-camif/camif-core.c662
-rw-r--r--drivers/media/platform/s3c-camif/camif-core.h393
-rw-r--r--drivers/media/platform/s3c-camif/camif-regs.c606
-rw-r--r--drivers/media/platform/s3c-camif/camif-regs.h269
-rw-r--r--drivers/media/platform/s5p-fimc/fimc-capture.c11
-rw-r--r--drivers/media/platform/s5p-fimc/fimc-m2m.c16
-rw-r--r--drivers/media/platform/s5p-fimc/fimc-mdevice.c4
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_dec.c14
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_enc.c16
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_pm.c2
-rw-r--r--drivers/media/platform/s5p-tv/mixer_video.c13
-rw-r--r--drivers/media/platform/soc_camera/Kconfig1
-rw-r--r--drivers/media/platform/soc_camera/soc_camera.c14
-rw-r--r--drivers/media/platform/vivi.c8
-rw-r--r--drivers/media/radio/radio-aimslab.c2
-rw-r--r--drivers/media/radio/radio-cadet.c3
-rw-r--r--drivers/media/radio/radio-isa.c10
-rw-r--r--drivers/media/radio/radio-sf16fmi.c2
-rw-r--r--drivers/media/radio/radio-tea5764.c4
-rw-r--r--drivers/media/radio/si4713-i2c.c2
-rw-r--r--drivers/media/radio/wl128x/fmdrv.h2
-rw-r--r--drivers/media/radio/wl128x/fmdrv_common.c2
-rw-r--r--drivers/media/radio/wl128x/fmdrv_rx.c2
-rw-r--r--drivers/media/rc/ati_remote.c2
-rw-r--r--drivers/media/rc/ene_ir.c33
-rw-r--r--drivers/media/rc/fintek-cir.c6
-rw-r--r--drivers/media/rc/gpio-ir-recv.c2
-rw-r--r--drivers/media/rc/iguanair.c2
-rw-r--r--drivers/media/rc/imon.c40
-rw-r--r--drivers/media/rc/ir-jvc-decoder.c4
-rw-r--r--drivers/media/rc/ir-lirc-codec.c4
-rw-r--r--drivers/media/rc/ir-mce_kbd-decoder.c4
-rw-r--r--drivers/media/rc/ir-nec-decoder.c4
-rw-r--r--drivers/media/rc/ir-rc5-decoder.c14
-rw-r--r--drivers/media/rc/ir-rc5-sz-decoder.c6
-rw-r--r--drivers/media/rc/ir-rc6-decoder.c8
-rw-r--r--drivers/media/rc/ir-rx51.c13
-rw-r--r--drivers/media/rc/ir-sanyo-decoder.c4
-rw-r--r--drivers/media/rc/ir-sony-decoder.c17
-rw-r--r--drivers/media/rc/ite-cir.c6
-rw-r--r--drivers/media/rc/keymaps/rc-imon-mce.c2
-rw-r--r--drivers/media/rc/keymaps/rc-rc6-mce.c2
-rw-r--r--drivers/media/rc/mceusb.c2
-rw-r--r--drivers/media/rc/nuvoton-cir.c13
-rw-r--r--drivers/media/rc/nuvoton-cir.h1
-rw-r--r--drivers/media/rc/rc-loopback.c2
-rw-r--r--drivers/media/rc/rc-main.c73
-rw-r--r--drivers/media/rc/redrat3.c2
-rw-r--r--drivers/media/rc/streamzap.c2
-rw-r--r--drivers/media/rc/ttusbir.c2
-rw-r--r--drivers/media/rc/winbond-cir.c113
-rw-r--r--drivers/media/tuners/fc2580.c61
-rw-r--r--drivers/media/tuners/max2165.c2
-rw-r--r--drivers/media/tuners/tua9001.c2
-rw-r--r--drivers/media/tuners/xc4000.c2
-rw-r--r--drivers/media/usb/au0828/au0828-cards.c2
-rw-r--r--drivers/media/usb/au0828/au0828-dvb.c5
-rw-r--r--drivers/media/usb/au0828/au0828-video.c16
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-avcore.c9
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-cards.c8
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-i2c.c4
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-input.c2
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9015.c2
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9035.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/anysee.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/az6007.c2
-rw-r--r--drivers/media/usb/dvb-usb-v2/dvb_usb.h2
-rw-r--r--drivers/media/usb/dvb-usb-v2/dvb_usb_core.c14
-rw-r--r--drivers/media/usb/dvb-usb-v2/it913x.c12
-rw-r--r--drivers/media/usb/dvb-usb-v2/lmedm04.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/rtl28xxu.c6
-rw-r--r--drivers/media/usb/dvb-usb-v2/usb_urb.c8
-rw-r--r--drivers/media/usb/dvb-usb/az6027.c11
-rw-r--r--drivers/media/usb/dvb-usb/dib0700.h2
-rw-r--r--drivers/media/usb/dvb-usb/dib0700_core.c16
-rw-r--r--drivers/media/usb/dvb-usb/dib0700_devices.c146
-rw-r--r--drivers/media/usb/dvb-usb/dvb-usb.h2
-rw-r--r--drivers/media/usb/dvb-usb/pctv452e.c4
-rw-r--r--drivers/media/usb/dvb-usb/technisat-usb2.c2
-rw-r--r--drivers/media/usb/dvb-usb/ttusb2.c2
-rw-r--r--drivers/media/usb/dvb-usb/vp702x.c8
-rw-r--r--drivers/media/usb/em28xx/em28xx-cards.c15
-rw-r--r--drivers/media/usb/em28xx/em28xx-dvb.c84
-rw-r--r--drivers/media/usb/em28xx/em28xx-input.c16
-rw-r--r--drivers/media/usb/em28xx/em28xx.h1
-rw-r--r--drivers/media/usb/gspca/gspca.c3
-rw-r--r--drivers/media/usb/gspca/gspca.h2
-rw-r--r--drivers/media/usb/gspca/jeilinj.c6
-rw-r--r--drivers/media/usb/gspca/m5602/m5602_s5k4aa.c6
-rw-r--r--drivers/media/usb/gspca/pac7302.c62
-rw-r--r--drivers/media/usb/gspca/sonixb.c1
-rw-r--r--drivers/media/usb/hdpvr/hdpvr-core.c2
-rw-r--r--drivers/media/usb/hdpvr/hdpvr-i2c.c2
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-hdw.c6
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-v4l2.c4
-rw-r--r--drivers/media/usb/pwc/pwc-ctrl.c2
-rw-r--r--drivers/media/usb/pwc/pwc-if.c8
-rw-r--r--drivers/media/usb/s2255/s2255drv.c2
-rw-r--r--drivers/media/usb/siano/Kconfig3
-rw-r--r--drivers/media/usb/sn9c102/sn9c102_core.c2
-rw-r--r--drivers/media/usb/stk1160/stk1160-i2c.c2
-rw-r--r--drivers/media/usb/stk1160/stk1160-video.c23
-rw-r--r--drivers/media/usb/stk1160/stk1160.h5
-rw-r--r--drivers/media/usb/stkwebcam/stk-webcam.c5
-rw-r--r--drivers/media/usb/tlg2300/pd-dvb.c1
-rw-r--r--drivers/media/usb/tlg2300/pd-video.c4
-rw-r--r--drivers/media/usb/tm6000/tm6000-input.c20
-rw-r--r--drivers/media/usb/tm6000/tm6000-video.c1
-rw-r--r--drivers/media/usb/usbvision/usbvision.h2
-rw-r--r--drivers/media/usb/uvc/uvc_ctrl.c29
-rw-r--r--drivers/media/usb/uvc/uvc_driver.c10
-rw-r--r--drivers/media/usb/uvc/uvc_entity.c2
-rw-r--r--drivers/media/usb/uvc/uvc_queue.c2
-rw-r--r--drivers/media/usb/uvc/uvc_v4l2.c89
-rw-r--r--drivers/media/usb/uvc/uvc_video.c1
-rw-r--r--drivers/media/usb/uvc/uvcvideo.h8
-rw-r--r--drivers/media/usb/zr364xx/zr364xx.c3
-rw-r--r--drivers/media/v4l2-core/Kconfig3
-rw-r--r--drivers/media/v4l2-core/v4l2-common.c3
-rw-r--r--drivers/media/v4l2-core/v4l2-compat-ioctl32.c19
-rw-r--r--drivers/media/v4l2-core/v4l2-dev.c1
-rw-r--r--drivers/media/v4l2-core/v4l2-event.c2
-rw-r--r--drivers/media/v4l2-core/v4l2-fh.c2
-rw-r--r--drivers/media/v4l2-core/v4l2-ioctl.c11
-rw-r--r--drivers/media/v4l2-core/v4l2-mem2mem.c19
-rw-r--r--drivers/media/v4l2-core/v4l2-subdev.c22
-rw-r--r--drivers/media/v4l2-core/videobuf-core.c4
-rw-r--r--drivers/media/v4l2-core/videobuf2-core.c300
-rw-r--r--drivers/media/v4l2-core/videobuf2-dma-contig.c700
-rw-r--r--drivers/media/v4l2-core/videobuf2-memops.c40
-rw-r--r--drivers/media/v4l2-core/videobuf2-vmalloc.c56
-rw-r--r--drivers/staging/media/dt3155v4l/dt3155v4l.c4
-rw-r--r--drivers/staging/media/go7007/go7007-fw.c42
-rw-r--r--drivers/staging/media/go7007/go7007-v4l2.c2
-rw-r--r--drivers/staging/media/go7007/s2250-board.c13
-rw-r--r--drivers/staging/media/go7007/wis-ov7640.c20
-rw-r--r--drivers/staging/media/go7007/wis-saa7113.c20
-rw-r--r--drivers/staging/media/go7007/wis-saa7115.c20
-rw-r--r--drivers/staging/media/go7007/wis-sony-tuner.c13
-rw-r--r--drivers/staging/media/go7007/wis-tw2804.c13
-rw-r--r--drivers/staging/media/go7007/wis-tw9903.c13
-rw-r--r--drivers/staging/media/go7007/wis-uda1342.c13
-rw-r--r--drivers/staging/media/lirc/lirc_serial.c6
-rw-r--r--include/linux/dvb/Kbuild0
-rw-r--r--include/linux/dvb/dmx.h29
-rw-r--r--include/linux/dvb/video.h29
-rw-r--r--include/media/adp1653.h4
-rw-r--r--include/media/davinci/vpbe_display.h15
-rw-r--r--include/media/davinci/vpbe_osd.h2
-rw-r--r--include/media/ir-kbd-i2c.h2
-rw-r--r--include/media/mt9v022.h16
-rw-r--r--include/media/rc-core.h4
-rw-r--r--include/media/rc-map.h64
-rw-r--r--include/media/s3c_camif.h45
-rw-r--r--include/media/smiapp.h2
-rw-r--r--include/media/v4l2-event.h2
-rw-r--r--include/media/v4l2-fh.h2
-rw-r--r--include/media/v4l2-ioctl.h2
-rw-r--r--include/media/v4l2-mem2mem.h3
-rw-r--r--include/media/videobuf2-core.h38
-rw-r--r--include/media/videobuf2-memops.h5
-rw-r--r--include/uapi/linux/videodev2.h37
314 files changed, 7754 insertions, 1863 deletions
diff --git a/Documentation/DocBook/media/v4l/compat.xml b/Documentation/DocBook/media/v4l/compat.xml
index 4fdf6b562d1c..3dd9e78815d1 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2586,6 +2586,13 @@ ioctls.</para>
2586 <para>Vendor and device specific media bus pixel formats. 2586 <para>Vendor and device specific media bus pixel formats.
2587 <xref linkend="v4l2-mbus-vendor-spec-fmts" />.</para> 2587 <xref linkend="v4l2-mbus-vendor-spec-fmts" />.</para>
2588 </listitem> 2588 </listitem>
2589 <listitem>
2590 <para>Importing DMABUF file descriptors as a new IO method described
2591 in <xref linkend="dmabuf" />.</para>
2592 </listitem>
2593 <listitem>
2594 <para>Exporting DMABUF files using &VIDIOC-EXPBUF; ioctl.</para>
2595 </listitem>
2589 </itemizedlist> 2596 </itemizedlist>
2590 </section> 2597 </section>
2591 2598
diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml
index b5d1cbdc558b..388a34032653 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -331,7 +331,7 @@ application until one or more buffers can be dequeued. By default
331outgoing queue. When the <constant>O_NONBLOCK</constant> flag was 331outgoing queue. When the <constant>O_NONBLOCK</constant> flag was
332given to the &func-open; function, <constant>VIDIOC_DQBUF</constant> 332given to the &func-open; function, <constant>VIDIOC_DQBUF</constant>
333returns immediately with an &EAGAIN; when no buffer is available. The 333returns immediately with an &EAGAIN; when no buffer is available. The
334&func-select; or &func-poll; function are always available.</para> 334&func-select; or &func-poll; functions are always available.</para>
335 335
336 <para>To start and stop capturing or output applications call the 336 <para>To start and stop capturing or output applications call the
337&VIDIOC-STREAMON; and &VIDIOC-STREAMOFF; ioctl. Note 337&VIDIOC-STREAMON; and &VIDIOC-STREAMOFF; ioctl. Note
@@ -472,6 +472,165 @@ rest should be evident.</para>
472 </footnote></para> 472 </footnote></para>
473 </section> 473 </section>
474 474
475 <section id="dmabuf">
476 <title>Streaming I/O (DMA buffer importing)</title>
477
478 <note>
479 <title>Experimental</title>
480 <para>This is an <link linkend="experimental"> experimental </link>
481 interface and may change in the future.</para>
482 </note>
483
484<para>The DMABUF framework provides a generic method for sharing buffers
485between multiple devices. Device drivers that support DMABUF can export a DMA
486buffer to userspace as a file descriptor (known as the exporter role), import a
487DMA buffer from userspace using a file descriptor previously exported for a
488different or the same device (known as the importer role), or both. This
489section describes the DMABUF importer role API in V4L2.</para>
490
491 <para>Refer to <link linked="vidioc-expbuf"> DMABUF exporting </link> for
492details about exporting V4L2 buffers as DMABUF file descriptors.</para>
493
494<para>Input and output devices support the streaming I/O method when the
495<constant>V4L2_CAP_STREAMING</constant> flag in the
496<structfield>capabilities</structfield> field of &v4l2-capability; returned by
497the &VIDIOC-QUERYCAP; ioctl is set. Whether importing DMA buffers through
498DMABUF file descriptors is supported is determined by calling the
499&VIDIOC-REQBUFS; ioctl with the memory type set to
500<constant>V4L2_MEMORY_DMABUF</constant>.</para>
501
502 <para>This I/O method is dedicated to sharing DMA buffers between different
503devices, which may be V4L devices or other video-related devices (e.g. DRM).
504Buffers (planes) are allocated by a driver on behalf of an application. Next,
505these buffers are exported to the application as file descriptors using an API
506which is specific for an allocator driver. Only such file descriptor are
507exchanged. The descriptors and meta-information are passed in &v4l2-buffer; (or
508in &v4l2-plane; in the multi-planar API case). The driver must be switched
509into DMABUF I/O mode by calling the &VIDIOC-REQBUFS; with the desired buffer
510type.</para>
511
512 <example>
513 <title>Initiating streaming I/O with DMABUF file descriptors</title>
514
515 <programlisting>
516&v4l2-requestbuffers; reqbuf;
517
518memset(&amp;reqbuf, 0, sizeof (reqbuf));
519reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
520reqbuf.memory = V4L2_MEMORY_DMABUF;
521reqbuf.count = 1;
522
523if (ioctl(fd, &VIDIOC-REQBUFS;, &amp;reqbuf) == -1) {
524 if (errno == EINVAL)
525 printf("Video capturing or DMABUF streaming is not supported\n");
526 else
527 perror("VIDIOC_REQBUFS");
528
529 exit(EXIT_FAILURE);
530}
531 </programlisting>
532 </example>
533
534 <para>The buffer (plane) file descriptor is passed on the fly with the
535&VIDIOC-QBUF; ioctl. In case of multiplanar buffers, every plane can be
536associated with a different DMABUF descriptor. Although buffers are commonly
537cycled, applications can pass a different DMABUF descriptor at each
538<constant>VIDIOC_QBUF</constant> call.</para>
539
540 <example>
541 <title>Queueing DMABUF using single plane API</title>
542
543 <programlisting>
544int buffer_queue(int v4lfd, int index, int dmafd)
545{
546 &v4l2-buffer; buf;
547
548 memset(&amp;buf, 0, sizeof buf);
549 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
550 buf.memory = V4L2_MEMORY_DMABUF;
551 buf.index = index;
552 buf.m.fd = dmafd;
553
554 if (ioctl(v4lfd, &VIDIOC-QBUF;, &amp;buf) == -1) {
555 perror("VIDIOC_QBUF");
556 return -1;
557 }
558
559 return 0;
560}
561 </programlisting>
562 </example>
563
564 <example>
565 <title>Queueing DMABUF using multi plane API</title>
566
567 <programlisting>
568int buffer_queue_mp(int v4lfd, int index, int dmafd[], int n_planes)
569{
570 &v4l2-buffer; buf;
571 &v4l2-plane; planes[VIDEO_MAX_PLANES];
572 int i;
573
574 memset(&amp;buf, 0, sizeof buf);
575 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
576 buf.memory = V4L2_MEMORY_DMABUF;
577 buf.index = index;
578 buf.m.planes = planes;
579 buf.length = n_planes;
580
581 memset(&amp;planes, 0, sizeof planes);
582
583 for (i = 0; i &lt; n_planes; ++i)
584 buf.m.planes[i].m.fd = dmafd[i];
585
586 if (ioctl(v4lfd, &VIDIOC-QBUF;, &amp;buf) == -1) {
587 perror("VIDIOC_QBUF");
588 return -1;
589 }
590
591 return 0;
592}
593 </programlisting>
594 </example>
595
596 <para>Captured or displayed buffers are dequeued with the
597&VIDIOC-DQBUF; ioctl. The driver can unlock the buffer at any
598time between the completion of the DMA and this ioctl. The memory is
599also unlocked when &VIDIOC-STREAMOFF; is called, &VIDIOC-REQBUFS;, or
600when the device is closed.</para>
601
602 <para>For capturing applications it is customary to enqueue a
603number of empty buffers, to start capturing and enter the read loop.
604Here the application waits until a filled buffer can be dequeued, and
605re-enqueues the buffer when the data is no longer needed. Output
606applications fill and enqueue buffers, when enough buffers are stacked
607up output is started. In the write loop, when the application
608runs out of free buffers it must wait until an empty buffer can be
609dequeued and reused. Two methods exist to suspend execution of the
610application until one or more buffers can be dequeued. By default
611<constant>VIDIOC_DQBUF</constant> blocks when no buffer is in the
612outgoing queue. When the <constant>O_NONBLOCK</constant> flag was
613given to the &func-open; function, <constant>VIDIOC_DQBUF</constant>
614returns immediately with an &EAGAIN; when no buffer is available. The
615&func-select; and &func-poll; functions are always available.</para>
616
617 <para>To start and stop capturing or displaying applications call the
618&VIDIOC-STREAMON; and &VIDIOC-STREAMOFF; ioctls. Note that
619<constant>VIDIOC_STREAMOFF</constant> removes all buffers from both queues and
620unlocks all buffers as a side effect. Since there is no notion of doing
621anything "now" on a multitasking system, if an application needs to synchronize
622with another event it should examine the &v4l2-buffer;
623<structfield>timestamp</structfield> of captured buffers, or set the field
624before enqueuing buffers for output.</para>
625
626 <para>Drivers implementing DMABUF importing I/O must support the
627<constant>VIDIOC_REQBUFS</constant>, <constant>VIDIOC_QBUF</constant>,
628<constant>VIDIOC_DQBUF</constant>, <constant>VIDIOC_STREAMON</constant> and
629<constant>VIDIOC_STREAMOFF</constant> ioctls, and the
630<function>select()</function> and <function>poll()</function> functions.</para>
631
632 </section>
633
475 <section id="async"> 634 <section id="async">
476 <title>Asynchronous I/O</title> 635 <title>Asynchronous I/O</title>
477 636
@@ -673,6 +832,14 @@ memory, set by the application. See <xref linkend="userp" /> for details.
673 <structname>v4l2_buffer</structname> structure.</entry> 832 <structname>v4l2_buffer</structname> structure.</entry>
674 </row> 833 </row>
675 <row> 834 <row>
835 <entry></entry>
836 <entry>int</entry>
837 <entry><structfield>fd</structfield></entry>
838 <entry>For the single-plane API and when
839<structfield>memory</structfield> is <constant>V4L2_MEMORY_DMABUF</constant> this
840is the file descriptor associated with a DMABUF buffer.</entry>
841 </row>
842 <row>
676 <entry>__u32</entry> 843 <entry>__u32</entry>
677 <entry><structfield>length</structfield></entry> 844 <entry><structfield>length</structfield></entry>
678 <entry></entry> 845 <entry></entry>
@@ -744,6 +911,15 @@ should set this to 0.</entry>
744 </entry> 911 </entry>
745 </row> 912 </row>
746 <row> 913 <row>
914 <entry></entry>
915 <entry>int</entry>
916 <entry><structfield>fd</structfield></entry>
917 <entry>When the memory type in the containing &v4l2-buffer; is
918 <constant>V4L2_MEMORY_DMABUF</constant>, this is a file
919 descriptor associated with a DMABUF buffer, similar to the
920 <structfield>fd</structfield> field in &v4l2-buffer;.</entry>
921 </row>
922 <row>
747 <entry>__u32</entry> 923 <entry>__u32</entry>
748 <entry><structfield>data_offset</structfield></entry> 924 <entry><structfield>data_offset</structfield></entry>
749 <entry></entry> 925 <entry></entry>
@@ -923,7 +1099,7 @@ application. Drivers set or clear this flag when the
923 </row> 1099 </row>
924 <row> 1100 <row>
925 <entry><constant>V4L2_BUF_FLAG_NO_CACHE_INVALIDATE</constant></entry> 1101 <entry><constant>V4L2_BUF_FLAG_NO_CACHE_INVALIDATE</constant></entry>
926 <entry>0x0400</entry> 1102 <entry>0x0800</entry>
927 <entry>Caches do not have to be invalidated for this buffer. 1103 <entry>Caches do not have to be invalidated for this buffer.
928Typically applications shall use this flag if the data captured in the buffer 1104Typically applications shall use this flag if the data captured in the buffer
929is not going to be touched by the CPU, instead the buffer will, probably, be 1105is not going to be touched by the CPU, instead the buffer will, probably, be
@@ -932,7 +1108,7 @@ passed on to a DMA-capable hardware unit for further processing or output.
932 </row> 1108 </row>
933 <row> 1109 <row>
934 <entry><constant>V4L2_BUF_FLAG_NO_CACHE_CLEAN</constant></entry> 1110 <entry><constant>V4L2_BUF_FLAG_NO_CACHE_CLEAN</constant></entry>
935 <entry>0x0800</entry> 1111 <entry>0x1000</entry>
936 <entry>Caches do not have to be cleaned for this buffer. 1112 <entry>Caches do not have to be cleaned for this buffer.
937Typically applications shall use this flag for output buffers if the data 1113Typically applications shall use this flag for output buffers if the data
938in this buffer has not been created by the CPU but by some DMA-capable unit, 1114in this buffer has not been created by the CPU but by some DMA-capable unit,
@@ -964,6 +1140,12 @@ pointer</link> I/O.</entry>
964 <entry>3</entry> 1140 <entry>3</entry>
965 <entry>[to do]</entry> 1141 <entry>[to do]</entry>
966 </row> 1142 </row>
1143 <row>
1144 <entry><constant>V4L2_MEMORY_DMABUF</constant></entry>
1145 <entry>4</entry>
1146 <entry>The buffer is used for <link linkend="dmabuf">DMA shared
1147buffer</link> I/O.</entry>
1148 </row>
967 </tbody> 1149 </tbody>
968 </tgroup> 1150 </tgroup>
969 </table> 1151 </table>
diff --git a/Documentation/DocBook/media/v4l/v4l2.xml b/Documentation/DocBook/media/v4l/v4l2.xml
index 10ccde9d16d0..4d110b1ad3e9 100644
--- a/Documentation/DocBook/media/v4l/v4l2.xml
+++ b/Documentation/DocBook/media/v4l/v4l2.xml
@@ -543,6 +543,7 @@ and discussions on the V4L mailing list.</revremark>
543 &sub-enuminput; 543 &sub-enuminput;
544 &sub-enumoutput; 544 &sub-enumoutput;
545 &sub-enumstd; 545 &sub-enumstd;
546 &sub-expbuf;
546 &sub-g-audio; 547 &sub-g-audio;
547 &sub-g-audioout; 548 &sub-g-audioout;
548 &sub-g-crop; 549 &sub-g-crop;
diff --git a/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml b/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml
index a8cda1acacd9..cd9943672434 100644
--- a/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml
@@ -6,7 +6,8 @@
6 6
7 <refnamediv> 7 <refnamediv>
8 <refname>VIDIOC_CREATE_BUFS</refname> 8 <refname>VIDIOC_CREATE_BUFS</refname>
9 <refpurpose>Create buffers for Memory Mapped or User Pointer I/O</refpurpose> 9 <refpurpose>Create buffers for Memory Mapped or User Pointer or DMA Buffer
10 I/O</refpurpose>
10 </refnamediv> 11 </refnamediv>
11 12
12 <refsynopsisdiv> 13 <refsynopsisdiv>
@@ -55,11 +56,11 @@
55 </note> 56 </note>
56 57
57 <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
58mapped</link> or <link linkend="userp">user pointer</link> 59mapped</link> or <link linkend="userp">user pointer</link> or <link
59I/O. It can be used as an alternative or in addition to the 60linkend="dmabuf">DMA buffer</link> I/O. It can be used as an alternative or in
60<constant>VIDIOC_REQBUFS</constant> ioctl, when a tighter control over buffers 61addition to the <constant>VIDIOC_REQBUFS</constant> ioctl, when a tighter
61is required. This ioctl can be called multiple times to create buffers of 62control over buffers is required. This ioctl can be called multiple times to
62different sizes.</para> 63create buffers of different sizes.</para>
63 64
64 <para>To allocate device buffers applications initialize relevant fields of 65 <para>To allocate device buffers applications initialize relevant fields of
65the <structname>v4l2_create_buffers</structname> structure. They set the 66the <structname>v4l2_create_buffers</structname> structure. They set the
@@ -109,7 +110,8 @@ information.</para>
109 <entry>__u32</entry> 110 <entry>__u32</entry>
110 <entry><structfield>memory</structfield></entry> 111 <entry><structfield>memory</structfield></entry>
111 <entry>Applications set this field to 112 <entry>Applications set this field to
112<constant>V4L2_MEMORY_MMAP</constant> or 113<constant>V4L2_MEMORY_MMAP</constant>,
114<constant>V4L2_MEMORY_DMABUF</constant> or
113<constant>V4L2_MEMORY_USERPTR</constant>. See <xref linkend="v4l2-memory" 115<constant>V4L2_MEMORY_USERPTR</constant>. See <xref linkend="v4l2-memory"
114/></entry> 116/></entry>
115 </row> 117 </row>
diff --git a/Documentation/DocBook/media/v4l/vidioc-expbuf.xml b/Documentation/DocBook/media/v4l/vidioc-expbuf.xml
new file mode 100644
index 000000000000..72dfbd20a802
--- /dev/null
+++ b/Documentation/DocBook/media/v4l/vidioc-expbuf.xml
@@ -0,0 +1,212 @@
1<refentry id="vidioc-expbuf">
2
3 <refmeta>
4 <refentrytitle>ioctl VIDIOC_EXPBUF</refentrytitle>
5 &manvol;
6 </refmeta>
7
8 <refnamediv>
9 <refname>VIDIOC_EXPBUF</refname>
10 <refpurpose>Export a buffer as a DMABUF file descriptor.</refpurpose>
11 </refnamediv>
12
13 <refsynopsisdiv>
14 <funcsynopsis>
15 <funcprototype>
16 <funcdef>int <function>ioctl</function></funcdef>
17 <paramdef>int <parameter>fd</parameter></paramdef>
18 <paramdef>int <parameter>request</parameter></paramdef>
19 <paramdef>struct v4l2_exportbuffer *<parameter>argp</parameter></paramdef>
20 </funcprototype>
21 </funcsynopsis>
22 </refsynopsisdiv>
23
24 <refsect1>
25 <title>Arguments</title>
26
27 <variablelist>
28 <varlistentry>
29 <term><parameter>fd</parameter></term>
30 <listitem>
31 <para>&fd;</para>
32 </listitem>
33 </varlistentry>
34 <varlistentry>
35 <term><parameter>request</parameter></term>
36 <listitem>
37 <para>VIDIOC_EXPBUF</para>
38 </listitem>
39 </varlistentry>
40 <varlistentry>
41 <term><parameter>argp</parameter></term>
42 <listitem>
43 <para></para>
44 </listitem>
45 </varlistentry>
46 </variablelist>
47 </refsect1>
48
49 <refsect1>
50 <title>Description</title>
51
52 <note>
53 <title>Experimental</title>
54 <para>This is an <link linkend="experimental"> experimental </link>
55 interface and may change in the future.</para>
56 </note>
57
58<para>This ioctl is an extension to the <link linkend="mmap">memory
59mapping</link> I/O method, therefore it is available only for
60<constant>V4L2_MEMORY_MMAP</constant> buffers. It can be used to export a
61buffer as a DMABUF file at any time after buffers have been allocated with the
62&VIDIOC-REQBUFS; ioctl.</para>
63
64<para> To export a buffer, applications fill &v4l2-exportbuffer;. The
65<structfield> type </structfield> field is set to the same buffer type as was
66previously used with &v4l2-requestbuffers;<structfield> type </structfield>.
67Applications must also set the <structfield> index </structfield> field. Valid
68index numbers range from zero to the number of buffers allocated with
69&VIDIOC-REQBUFS; (&v4l2-requestbuffers;<structfield> count </structfield>)
70minus one. For the multi-planar API, applications set the <structfield> plane
71</structfield> field to the index of the plane to be exported. Valid planes
72range from zero to the maximal number of valid planes for the currently active
73format. For the single-planar API, applications must set <structfield> plane
74</structfield> to zero. Additional flags may be posted in the <structfield>
75flags </structfield> field. Refer to a manual for open() for details.
76Currently only O_CLOEXEC is supported. All other fields must be set to zero.
77In the case of multi-planar API, every plane is exported separately using
78multiple <constant> VIDIOC_EXPBUF </constant> calls. </para>
79
80<para> After calling <constant>VIDIOC_EXPBUF</constant> the <structfield> fd
81</structfield> field will be set by a driver. This is a DMABUF file
82descriptor. The application may pass it to other DMABUF-aware devices. Refer to
83<link linkend="dmabuf">DMABUF importing</link> for details about importing
84DMABUF files into V4L2 nodes. It is recommended to close a DMABUF file when it
85is no longer used to allow the associated memory to be reclaimed. </para>
86
87 </refsect1>
88 <refsect1>
89 <section>
90 <title>Examples</title>
91
92 <example>
93 <title>Exporting a buffer.</title>
94 <programlisting>
95int buffer_export(int v4lfd, &v4l2-buf-type; bt, int index, int *dmafd)
96{
97 &v4l2-exportbuffer; expbuf;
98
99 memset(&amp;expbuf, 0, sizeof(expbuf));
100 expbuf.type = bt;
101 expbuf.index = index;
102 if (ioctl(v4lfd, &VIDIOC-EXPBUF;, &amp;expbuf) == -1) {
103 perror("VIDIOC_EXPBUF");
104 return -1;
105 }
106
107 *dmafd = expbuf.fd;
108
109 return 0;
110}
111 </programlisting>
112 </example>
113
114 <example>
115 <title>Exporting a buffer using the multi-planar API.</title>
116 <programlisting>
117int buffer_export_mp(int v4lfd, &v4l2-buf-type; bt, int index,
118 int dmafd[], int n_planes)
119{
120 int i;
121
122 for (i = 0; i &lt; n_planes; ++i) {
123 &v4l2-exportbuffer; expbuf;
124
125 memset(&amp;expbuf, 0, sizeof(expbuf));
126 expbuf.type = bt;
127 expbuf.index = index;
128 expbuf.plane = i;
129 if (ioctl(v4lfd, &VIDIOC-EXPBUF;, &amp;expbuf) == -1) {
130 perror("VIDIOC_EXPBUF");
131 while (i)
132 close(dmafd[--i]);
133 return -1;
134 }
135 dmafd[i] = expbuf.fd;
136 }
137
138 return 0;
139}
140 </programlisting>
141 </example>
142 </section>
143 </refsect1>
144
145 <refsect1>
146 <table pgwide="1" frame="none" id="v4l2-exportbuffer">
147 <title>struct <structname>v4l2_exportbuffer</structname></title>
148 <tgroup cols="3">
149 &cs-str;
150 <tbody valign="top">
151 <row>
152 <entry>__u32</entry>
153 <entry><structfield>type</structfield></entry>
154 <entry>Type of the buffer, same as &v4l2-format;
155<structfield>type</structfield> or &v4l2-requestbuffers;
156<structfield>type</structfield>, set by the application. See <xref
157linkend="v4l2-buf-type" /></entry>
158 </row>
159 <row>
160 <entry>__u32</entry>
161 <entry><structfield>index</structfield></entry>
162 <entry>Number of the buffer, set by the application. This field is
163only used for <link linkend="mmap">memory mapping</link> I/O and can range from
164zero to the number of buffers allocated with the &VIDIOC-REQBUFS; and/or
165&VIDIOC-CREATE-BUFS; ioctls. </entry>
166 </row>
167 <row>
168 <entry>__u32</entry>
169 <entry><structfield>plane</structfield></entry>
170 <entry>Index of the plane to be exported when using the
171multi-planar API. Otherwise this value must be set to zero. </entry>
172 </row>
173 <row>
174 <entry>__u32</entry>
175 <entry><structfield>flags</structfield></entry>
176 <entry>Flags for the newly created file, currently only <constant>
177O_CLOEXEC </constant> is supported, refer to the manual of open() for more
178details.</entry>
179 </row>
180 <row>
181 <entry>__s32</entry>
182 <entry><structfield>fd</structfield></entry>
183 <entry>The DMABUF file descriptor associated with a buffer. Set by
184 the driver.</entry>
185 </row>
186 <row>
187 <entry>__u32</entry>
188 <entry><structfield>reserved[11]</structfield></entry>
189 <entry>Reserved field for future use. Must be set to zero.</entry>
190 </row>
191 </tbody>
192 </tgroup>
193 </table>
194
195 </refsect1>
196
197 <refsect1>
198 &return-value;
199 <variablelist>
200 <varlistentry>
201 <term><errorcode>EINVAL</errorcode></term>
202 <listitem>
203 <para>A queue is not in MMAP mode or DMABUF exporting is not
204supported or <structfield> flags </structfield> or <structfield> type
205</structfield> or <structfield> index </structfield> or <structfield> plane
206</structfield> fields are invalid.</para>
207 </listitem>
208 </varlistentry>
209 </variablelist>
210 </refsect1>
211
212</refentry>
diff --git a/Documentation/DocBook/media/v4l/vidioc-qbuf.xml b/Documentation/DocBook/media/v4l/vidioc-qbuf.xml
index 2d37abefce13..3504a7f2f382 100644
--- a/Documentation/DocBook/media/v4l/vidioc-qbuf.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-qbuf.xml
@@ -109,6 +109,23 @@ they cannot be swapped out to disk. Buffers remain locked until
109dequeued, until the &VIDIOC-STREAMOFF; or &VIDIOC-REQBUFS; ioctl is 109dequeued, until the &VIDIOC-STREAMOFF; or &VIDIOC-REQBUFS; ioctl is
110called, or until the device is closed.</para> 110called, or until the device is closed.</para>
111 111
112 <para>To enqueue a <link linkend="dmabuf">DMABUF</link> buffer applications
113set the <structfield>memory</structfield> field to
114<constant>V4L2_MEMORY_DMABUF</constant> and the <structfield>m.fd</structfield>
115field to a file descriptor associated with a DMABUF buffer. When the
116multi-planar API is used the <structfield>m.fd</structfield> fields of the
117passed array of &v4l2-plane; have to be used instead. When
118<constant>VIDIOC_QBUF</constant> is called with a pointer to this structure the
119driver sets the <constant>V4L2_BUF_FLAG_QUEUED</constant> flag and clears the
120<constant>V4L2_BUF_FLAG_MAPPED</constant> and
121<constant>V4L2_BUF_FLAG_DONE</constant> flags in the
122<structfield>flags</structfield> field, or it returns an error code. This
123ioctl locks the buffer. Locking a buffer means passing it to a driver for a
124hardware access (usually DMA). If an application accesses (reads/writes) a
125locked buffer then the result is undefined. Buffers remain locked until
126dequeued, until the &VIDIOC-STREAMOFF; or &VIDIOC-REQBUFS; ioctl is called, or
127until the device is closed.</para>
128
112 <para>Applications call the <constant>VIDIOC_DQBUF</constant> 129 <para>Applications call the <constant>VIDIOC_DQBUF</constant>
113ioctl to dequeue a filled (capturing) or displayed (output) buffer 130ioctl to dequeue a filled (capturing) or displayed (output) buffer
114from the driver's outgoing queue. They just set the 131from the driver's outgoing queue. They just set the
diff --git a/Documentation/DocBook/media/v4l/vidioc-reqbufs.xml b/Documentation/DocBook/media/v4l/vidioc-reqbufs.xml
index 2b50ef2007f3..78a06a9a5ece 100644
--- a/Documentation/DocBook/media/v4l/vidioc-reqbufs.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-reqbufs.xml
@@ -48,28 +48,30 @@
48 <refsect1> 48 <refsect1>
49 <title>Description</title> 49 <title>Description</title>
50 50
51 <para>This ioctl is used to initiate <link linkend="mmap">memory 51<para>This ioctl is used to initiate <link linkend="mmap">memory mapped</link>,
52mapped</link> or <link linkend="userp">user pointer</link> 52<link linkend="userp">user pointer</link> or <link
53I/O. Memory mapped buffers are located in device memory and must be 53linkend="dmabuf">DMABUF</link> based I/O. Memory mapped buffers are located in
54allocated with this ioctl before they can be mapped into the 54device memory and must be allocated with this ioctl before they can be mapped
55application's address space. User buffers are allocated by 55into the application's address space. User buffers are allocated by
56applications themselves, and this ioctl is merely used to switch the 56applications themselves, and this ioctl is merely used to switch the driver
57driver into user pointer I/O mode and to setup some internal structures.</para> 57into user pointer I/O mode and to setup some internal structures.
58Similarly, DMABUF buffers are allocated by applications through a device
59driver, and this ioctl only configures the driver into DMABUF I/O mode without
60performing any direct allocation.</para>
58 61
59 <para>To allocate device buffers applications initialize all 62 <para>To allocate device buffers applications initialize all fields of the
60fields of the <structname>v4l2_requestbuffers</structname> structure. 63<structname>v4l2_requestbuffers</structname> structure. They set the
61They set the <structfield>type</structfield> field to the respective 64<structfield>type</structfield> field to the respective stream or buffer type,
62stream or buffer type, the <structfield>count</structfield> field to 65the <structfield>count</structfield> field to the desired number of buffers,
63the desired number of buffers, <structfield>memory</structfield> 66<structfield>memory</structfield> must be set to the requested I/O method and
64must be set to the requested I/O method and the <structfield>reserved</structfield> array 67the <structfield>reserved</structfield> array must be zeroed. When the ioctl is
65must be zeroed. When the ioctl 68called with a pointer to this structure the driver will attempt to allocate the
66is called with a pointer to this structure the driver will attempt to allocate 69requested number of buffers and it stores the actual number allocated in the
67the requested number of buffers and it stores the actual number 70<structfield>count</structfield> field. It can be smaller than the number
68allocated in the <structfield>count</structfield> field. It can be 71requested, even zero, when the driver runs out of free memory. A larger number
69smaller than the number requested, even zero, when the driver runs out 72is also possible when the driver requires more buffers to function correctly.
70of free memory. A larger number is also possible when the driver requires 73For example video output requires at least two buffers, one displayed and one
71more buffers to function correctly. For example video output requires at least two buffers, 74filled by the application.</para>
72one displayed and one filled by the application.</para>
73 <para>When the I/O method is not supported the ioctl 75 <para>When the I/O method is not supported the ioctl
74returns an &EINVAL;.</para> 76returns an &EINVAL;.</para>
75 77
@@ -102,7 +104,8 @@ as the &v4l2-format; <structfield>type</structfield> field. See <xref
102 <entry>__u32</entry> 104 <entry>__u32</entry>
103 <entry><structfield>memory</structfield></entry> 105 <entry><structfield>memory</structfield></entry>
104 <entry>Applications set this field to 106 <entry>Applications set this field to
105<constant>V4L2_MEMORY_MMAP</constant> or 107<constant>V4L2_MEMORY_MMAP</constant>,
108<constant>V4L2_MEMORY_DMABUF</constant> or
106<constant>V4L2_MEMORY_USERPTR</constant>. See <xref linkend="v4l2-memory" 109<constant>V4L2_MEMORY_USERPTR</constant>. See <xref linkend="v4l2-memory"
107/>.</entry> 110/>.</entry>
108 </row> 111 </row>
diff --git a/MAINTAINERS b/MAINTAINERS
index 63b140583e29..a6be3e864b53 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -337,6 +337,13 @@ W: http://wireless.kernel.org/
337S: Orphan 337S: Orphan
338F: drivers/net/wireless/adm8211.* 338F: drivers/net/wireless/adm8211.*
339 339
340ADP1653 FLASH CONTROLLER DRIVER
341M: Sakari Ailus <sakari.ailus@iki.fi>
342L: linux-media@vger.kernel.org
343S: Maintained
344F: drivers/media/i2c/adp1653.c
345F: include/media/adp1653.h
346
340ADP5520 BACKLIGHT DRIVER WITH IO EXPANDER (ADP5520/ADP5501) 347ADP5520 BACKLIGHT DRIVER WITH IO EXPANDER (ADP5520/ADP5501)
341M: Michael Hennerich <michael.hennerich@analog.com> 348M: Michael Hennerich <michael.hennerich@analog.com>
342L: device-drivers-devel@blackfin.uclinux.org 349L: device-drivers-devel@blackfin.uclinux.org
@@ -1494,6 +1501,14 @@ F: include/linux/ax25.h
1494F: include/net/ax25.h 1501F: include/net/ax25.h
1495F: net/ax25/ 1502F: net/ax25/
1496 1503
1504AZ6007 DVB DRIVER
1505M: Mauro Carvalho Chehab <mchehab@redhat.com>
1506L: linux-media@vger.kernel.org
1507W: http://linuxtv.org
1508T: git git://linuxtv.org/media_tree.git
1509S: Maintained
1510F: drivers/media/usb/dvb-usb-v2/az6007.c
1511
1497B43 WIRELESS DRIVER 1512B43 WIRELESS DRIVER
1498M: Stefano Brivio <stefano.brivio@polimi.it> 1513M: Stefano Brivio <stefano.brivio@polimi.it>
1499L: linux-wireless@vger.kernel.org 1514L: linux-wireless@vger.kernel.org
@@ -1745,11 +1760,11 @@ F: Documentation/filesystems/btrfs.txt
1745F: fs/btrfs/ 1760F: fs/btrfs/
1746 1761
1747BTTV VIDEO4LINUX DRIVER 1762BTTV VIDEO4LINUX DRIVER
1748M: Mauro Carvalho Chehab <mchehab@infradead.org> 1763M: Mauro Carvalho Chehab <mchehab@redhat.com>
1749L: linux-media@vger.kernel.org 1764L: linux-media@vger.kernel.org
1750W: http://linuxtv.org 1765W: http://linuxtv.org
1751T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git 1766T: git git://linuxtv.org/media_tree.git
1752S: Maintained 1767S: Odd fixes
1753F: Documentation/video4linux/bttv/ 1768F: Documentation/video4linux/bttv/
1754F: drivers/media/pci/bt8xx/bttv* 1769F: drivers/media/pci/bt8xx/bttv*
1755 1770
@@ -1778,7 +1793,7 @@ F: fs/cachefiles/
1778CAFE CMOS INTEGRATED CAMERA CONTROLLER DRIVER 1793CAFE CMOS INTEGRATED CAMERA CONTROLLER DRIVER
1779M: Jonathan Corbet <corbet@lwn.net> 1794M: Jonathan Corbet <corbet@lwn.net>
1780L: linux-media@vger.kernel.org 1795L: linux-media@vger.kernel.org
1781T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git 1796T: git git://linuxtv.org/media_tree.git
1782S: Maintained 1797S: Maintained
1783F: Documentation/video4linux/cafe_ccic 1798F: Documentation/video4linux/cafe_ccic
1784F: drivers/media/platform/marvell-ccic/ 1799F: drivers/media/platform/marvell-ccic/
@@ -2164,12 +2179,22 @@ CX18 VIDEO4LINUX DRIVER
2164M: Andy Walls <awalls@md.metrocast.net> 2179M: Andy Walls <awalls@md.metrocast.net>
2165L: ivtv-devel@ivtvdriver.org (moderated for non-subscribers) 2180L: ivtv-devel@ivtvdriver.org (moderated for non-subscribers)
2166L: linux-media@vger.kernel.org 2181L: linux-media@vger.kernel.org
2167T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git 2182T: git git://linuxtv.org/media_tree.git
2168W: http://linuxtv.org 2183W: http://linuxtv.org
2169W: http://www.ivtvdriver.org/index.php/Cx18 2184W: http://www.ivtvdriver.org/index.php/Cx18
2170S: Maintained 2185S: Maintained
2171F: Documentation/video4linux/cx18.txt 2186F: Documentation/video4linux/cx18.txt
2172F: drivers/media/pci/cx18/ 2187F: drivers/media/pci/cx18/
2188F: include/uapi/linux/ivtv*
2189
2190CX88 VIDEO4LINUX DRIVER
2191M: Mauro Carvalho Chehab <mchehab@redhat.com>
2192L: linux-media@vger.kernel.org
2193W: http://linuxtv.org
2194T: git git://linuxtv.org/media_tree.git
2195S: Odd fixes
2196F: Documentation/video4linux/cx88/
2197F: drivers/media/pci/cx88/
2173 2198
2174CXD2820R MEDIA DRIVER 2199CXD2820R MEDIA DRIVER
2175M: Antti Palosaari <crope@iki.fi> 2200M: Antti Palosaari <crope@iki.fi>
@@ -2856,6 +2881,14 @@ L: netdev@vger.kernel.org
2856S: Maintained 2881S: Maintained
2857F: drivers/net/ethernet/ibm/ehea/ 2882F: drivers/net/ethernet/ibm/ehea/
2858 2883
2884EM28XX VIDEO4LINUX DRIVER
2885M: Mauro Carvalho Chehab <mchehab@redhat.com>
2886L: linux-media@vger.kernel.org
2887W: http://linuxtv.org
2888T: git git://linuxtv.org/media_tree.git
2889S: Maintained
2890F: drivers/media/usb/em28xx/
2891
2859EMBEDDED LINUX 2892EMBEDDED LINUX
2860M: Paul Gortmaker <paul.gortmaker@windriver.com> 2893M: Paul Gortmaker <paul.gortmaker@windriver.com>
2861M: Matt Mackall <mpm@selenic.com> 2894M: Matt Mackall <mpm@selenic.com>
@@ -3054,6 +3087,14 @@ T: git git://git.alsa-project.org/alsa-kernel.git
3054S: Maintained 3087S: Maintained
3055F: sound/firewire/ 3088F: sound/firewire/
3056 3089
3090FIREWIRE MEDIA DRIVERS (firedtv)
3091M: Stefan Richter <stefanr@s5r6.in-berlin.de>
3092L: linux-media@vger.kernel.org
3093L: linux1394-devel@lists.sourceforge.net
3094T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git
3095S: Maintained
3096F: drivers/media/firewire/
3097
3057FIREWIRE SBP-2 TARGET 3098FIREWIRE SBP-2 TARGET
3058M: Chris Boot <bootc@bootc.net> 3099M: Chris Boot <bootc@bootc.net>
3059L: linux-scsi@vger.kernel.org 3100L: linux-scsi@vger.kernel.org
@@ -3340,56 +3381,56 @@ F: drivers/net/ethernet/aeroflex/
3340GSPCA FINEPIX SUBDRIVER 3381GSPCA FINEPIX SUBDRIVER
3341M: Frank Zago <frank@zago.net> 3382M: Frank Zago <frank@zago.net>
3342L: linux-media@vger.kernel.org 3383L: linux-media@vger.kernel.org
3343T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git 3384T: git git://linuxtv.org/media_tree.git
3344S: Maintained 3385S: Maintained
3345F: drivers/media/usb/gspca/finepix.c 3386F: drivers/media/usb/gspca/finepix.c
3346 3387
3347GSPCA GL860 SUBDRIVER 3388GSPCA GL860 SUBDRIVER
3348M: Olivier Lorin <o.lorin@laposte.net> 3389M: Olivier Lorin <o.lorin@laposte.net>
3349L: linux-media@vger.kernel.org 3390L: linux-media@vger.kernel.org
3350T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git 3391T: git git://linuxtv.org/media_tree.git
3351S: Maintained 3392S: Maintained
3352F: drivers/media/usb/gspca/gl860/ 3393F: drivers/media/usb/gspca/gl860/
3353 3394
3354GSPCA M5602 SUBDRIVER 3395GSPCA M5602 SUBDRIVER
3355M: Erik Andren <erik.andren@gmail.com> 3396M: Erik Andren <erik.andren@gmail.com>
3356L: linux-media@vger.kernel.org 3397L: linux-media@vger.kernel.org
3357T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git 3398T: git git://linuxtv.org/media_tree.git
3358S: Maintained 3399S: Maintained
3359F: drivers/media/usb/gspca/m5602/ 3400F: drivers/media/usb/gspca/m5602/
3360 3401
3361GSPCA PAC207 SONIXB SUBDRIVER 3402GSPCA PAC207 SONIXB SUBDRIVER
3362M: Hans de Goede <hdegoede@redhat.com> 3403M: Hans de Goede <hdegoede@redhat.com>
3363L: linux-media@vger.kernel.org 3404L: linux-media@vger.kernel.org
3364T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git 3405T: git git://linuxtv.org/media_tree.git
3365S: Maintained 3406S: Maintained
3366F: drivers/media/usb/gspca/pac207.c 3407F: drivers/media/usb/gspca/pac207.c
3367 3408
3368GSPCA SN9C20X SUBDRIVER 3409GSPCA SN9C20X SUBDRIVER
3369M: Brian Johnson <brijohn@gmail.com> 3410M: Brian Johnson <brijohn@gmail.com>
3370L: linux-media@vger.kernel.org 3411L: linux-media@vger.kernel.org
3371T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git 3412T: git git://linuxtv.org/media_tree.git
3372S: Maintained 3413S: Maintained
3373F: drivers/media/usb/gspca/sn9c20x.c 3414F: drivers/media/usb/gspca/sn9c20x.c
3374 3415
3375GSPCA T613 SUBDRIVER 3416GSPCA T613 SUBDRIVER
3376M: Leandro Costantino <lcostantino@gmail.com> 3417M: Leandro Costantino <lcostantino@gmail.com>
3377L: linux-media@vger.kernel.org 3418L: linux-media@vger.kernel.org
3378T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git 3419T: git git://linuxtv.org/media_tree.git
3379S: Maintained 3420S: Maintained
3380F: drivers/media/usb/gspca/t613.c 3421F: drivers/media/usb/gspca/t613.c
3381 3422
3382GSPCA USB WEBCAM DRIVER 3423GSPCA USB WEBCAM DRIVER
3383M: Hans de Goede <hdegoede@redhat.com> 3424M: Hans de Goede <hdegoede@redhat.com>
3384L: linux-media@vger.kernel.org 3425L: linux-media@vger.kernel.org
3385T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git 3426T: git git://linuxtv.org/media_tree.git
3386S: Maintained 3427S: Maintained
3387F: drivers/media/usb/gspca/ 3428F: drivers/media/usb/gspca/
3388 3429
3389STK1160 USB VIDEO CAPTURE DRIVER 3430STK1160 USB VIDEO CAPTURE DRIVER
3390M: Ezequiel Garcia <elezegarcia@gmail.com> 3431M: Ezequiel Garcia <elezegarcia@gmail.com>
3391L: linux-media@vger.kernel.org 3432L: linux-media@vger.kernel.org
3392T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git 3433T: git git://linuxtv.org/media_tree.git
3393S: Maintained 3434S: Maintained
3394F: drivers/media/usb/stk1160/ 3435F: drivers/media/usb/stk1160/
3395 3436
@@ -3787,6 +3828,12 @@ F: net/ieee802154/
3787F: net/mac802154/ 3828F: net/mac802154/
3788F: drivers/ieee802154/ 3829F: drivers/ieee802154/
3789 3830
3831IGUANAWORKS USB IR TRANSCEIVER
3832M: Sean Young <sean@mess.org>
3833L: linux-media@vger.kernel.org
3834S: Maintained
3835F: drivers/media/rc/iguanair.c
3836
3790IIO SUBSYSTEM AND DRIVERS 3837IIO SUBSYSTEM AND DRIVERS
3791M: Jonathan Cameron <jic23@cam.ac.uk> 3838M: Jonathan Cameron <jic23@cam.ac.uk>
3792L: linux-iio@vger.kernel.org 3839L: linux-iio@vger.kernel.org
@@ -4172,17 +4219,41 @@ S: Maintained
4172F: Documentation/hwmon/it87 4219F: Documentation/hwmon/it87
4173F: drivers/hwmon/it87.c 4220F: drivers/hwmon/it87.c
4174 4221
4222IT913X MEDIA DRIVER
4223M: Malcolm Priestley <tvboxspy@gmail.com>
4224L: linux-media@vger.kernel.org
4225W: http://linuxtv.org/
4226Q: http://patchwork.linuxtv.org/project/linux-media/list/
4227S: Maintained
4228F: drivers/media/usb/dvb-usb-v2/it913x*
4229
4230IT913X FE MEDIA DRIVER
4231M: Malcolm Priestley <tvboxspy@gmail.com>
4232L: linux-media@vger.kernel.org
4233W: http://linuxtv.org/
4234Q: http://patchwork.linuxtv.org/project/linux-media/list/
4235S: Maintained
4236F: drivers/media/dvb-frontends/it913x-fe*
4237
4175IVTV VIDEO4LINUX DRIVER 4238IVTV VIDEO4LINUX DRIVER
4176M: Andy Walls <awalls@md.metrocast.net> 4239M: Andy Walls <awalls@md.metrocast.net>
4177L: ivtv-devel@ivtvdriver.org (moderated for non-subscribers) 4240L: ivtv-devel@ivtvdriver.org (moderated for non-subscribers)
4178L: linux-media@vger.kernel.org 4241L: linux-media@vger.kernel.org
4179T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git 4242T: git git://linuxtv.org/media_tree.git
4180W: http://www.ivtvdriver.org 4243W: http://www.ivtvdriver.org
4181S: Maintained 4244S: Maintained
4182F: Documentation/video4linux/*.ivtv 4245F: Documentation/video4linux/*.ivtv
4183F: drivers/media/pci/ivtv/ 4246F: drivers/media/pci/ivtv/
4184F: include/linux/ivtv* 4247F: include/linux/ivtv*
4185 4248
4249IX2505V MEDIA DRIVER
4250M: Malcolm Priestley <tvboxspy@gmail.com>
4251L: linux-media@vger.kernel.org
4252W: http://linuxtv.org/
4253Q: http://patchwork.linuxtv.org/project/linux-media/list/
4254S: Maintained
4255F: drivers/media/dvb-frontends/ix2505v*
4256
4186JC42.4 TEMPERATURE SENSOR DRIVER 4257JC42.4 TEMPERATURE SENSOR DRIVER
4187M: Guenter Roeck <linux@roeck-us.net> 4258M: Guenter Roeck <linux@roeck-us.net>
4188L: lm-sensors@lm-sensors.org 4259L: lm-sensors@lm-sensors.org
@@ -4628,6 +4699,14 @@ S: Maintained
4628F: Documentation/hwmon/lm90 4699F: Documentation/hwmon/lm90
4629F: drivers/hwmon/lm90.c 4700F: drivers/hwmon/lm90.c
4630 4701
4702LME2510 MEDIA DRIVER
4703M: Malcolm Priestley <tvboxspy@gmail.com>
4704L: linux-media@vger.kernel.org
4705W: http://linuxtv.org/
4706Q: http://patchwork.linuxtv.org/project/linux-media/list/
4707S: Maintained
4708F: drivers/media/usb/dvb-usb-v2/lmedm04*
4709
4631LOCKDEP AND LOCKSTAT 4710LOCKDEP AND LOCKSTAT
4632M: Peter Zijlstra <peterz@infradead.org> 4711M: Peter Zijlstra <peterz@infradead.org>
4633M: Ingo Molnar <mingo@redhat.com> 4712M: Ingo Molnar <mingo@redhat.com>
@@ -4721,6 +4800,14 @@ W: http://www.tazenda.demon.co.uk/phil/linux-hp
4721S: Maintained 4800S: Maintained
4722F: arch/m68k/hp300/ 4801F: arch/m68k/hp300/
4723 4802
4803M88RS2000 MEDIA DRIVER
4804M: Malcolm Priestley <tvboxspy@gmail.com>
4805L: linux-media@vger.kernel.org
4806W: http://linuxtv.org/
4807Q: http://patchwork.linuxtv.org/project/linux-media/list/
4808S: Maintained
4809F: drivers/media/dvb-frontends/m88rs2000*
4810
4724MAC80211 4811MAC80211
4725M: Johannes Berg <johannes@sipsolutions.net> 4812M: Johannes Berg <johannes@sipsolutions.net>
4726L: linux-wireless@vger.kernel.org 4813L: linux-wireless@vger.kernel.org
@@ -4813,12 +4900,12 @@ F: Documentation/hwmon/max6650
4813F: drivers/hwmon/max6650.c 4900F: drivers/hwmon/max6650.c
4814 4901
4815MEDIA INPUT INFRASTRUCTURE (V4L/DVB) 4902MEDIA INPUT INFRASTRUCTURE (V4L/DVB)
4816M: Mauro Carvalho Chehab <mchehab@infradead.org> 4903M: Mauro Carvalho Chehab <mchehab@redhat.com>
4817P: LinuxTV.org Project 4904P: LinuxTV.org Project
4818L: linux-media@vger.kernel.org 4905L: linux-media@vger.kernel.org
4819W: http://linuxtv.org 4906W: http://linuxtv.org
4820Q: http://patchwork.kernel.org/project/linux-media/list/ 4907Q: http://patchwork.kernel.org/project/linux-media/list/
4821T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git 4908T: git git://linuxtv.org/media_tree.git
4822S: Maintained 4909S: Maintained
4823F: Documentation/dvb/ 4910F: Documentation/dvb/
4824F: Documentation/video4linux/ 4911F: Documentation/video4linux/
@@ -4826,8 +4913,13 @@ F: Documentation/DocBook/media/
4826F: drivers/media/ 4913F: drivers/media/
4827F: drivers/staging/media/ 4914F: drivers/staging/media/
4828F: include/media/ 4915F: include/media/
4829F: include/linux/dvb/ 4916F: include/uapi/linux/dvb/
4830F: include/linux/videodev*.h 4917F: include/uapi/linux/videodev2.h
4918F: include/uapi/linux/media.h
4919F: include/uapi/linux/v4l2-*
4920F: include/uapi/linux/meye.h
4921F: include/uapi/linux/ivtv*
4922F: include/uapi/linux/uvcvideo.h
4831 4923
4832MEGARAID SCSI DRIVERS 4924MEGARAID SCSI DRIVERS
4833M: Neela Syam Kolli <megaraidlinux@lsi.com> 4925M: Neela Syam Kolli <megaraidlinux@lsi.com>
@@ -4909,7 +5001,7 @@ W: http://popies.net/meye/
4909S: Orphan 5001S: Orphan
4910F: Documentation/video4linux/meye.txt 5002F: Documentation/video4linux/meye.txt
4911F: drivers/media/pci/meye/ 5003F: drivers/media/pci/meye/
4912F: include/linux/meye.h 5004F: include/uapi/linux/meye.h
4913 5005
4914MOTOROLA IMX MMC/SD HOST CONTROLLER INTERFACE DRIVER 5006MOTOROLA IMX MMC/SD HOST CONTROLLER INTERFACE DRIVER
4915M: Pavel Pisa <ppisa@pikron.com> 5007M: Pavel Pisa <ppisa@pikron.com>
@@ -4923,6 +5015,13 @@ S: Maintained
4923F: Documentation/serial/moxa-smartio 5015F: Documentation/serial/moxa-smartio
4924F: drivers/tty/mxser.* 5016F: drivers/tty/mxser.*
4925 5017
5018MR800 AVERMEDIA USB FM RADIO DRIVER
5019M: Alexey Klimov <klimov.linux@gmail.com>
5020L: linux-media@vger.kernel.org
5021T: git git://linuxtv.org/media_tree.git
5022S: Maintained
5023F: drivers/media/radio/radio-mr800.c
5024
4926MSI LAPTOP SUPPORT 5025MSI LAPTOP SUPPORT
4927M: "Lee, Chun-Yi" <jlee@novell.com> 5026M: "Lee, Chun-Yi" <jlee@novell.com>
4928L: platform-driver-x86@vger.kernel.org 5027L: platform-driver-x86@vger.kernel.org
@@ -5385,7 +5484,7 @@ F: drivers/char/pcmcia/cm4040_cs.*
5385OMNIVISION OV7670 SENSOR DRIVER 5484OMNIVISION OV7670 SENSOR DRIVER
5386M: Jonathan Corbet <corbet@lwn.net> 5485M: Jonathan Corbet <corbet@lwn.net>
5387L: linux-media@vger.kernel.org 5486L: linux-media@vger.kernel.org
5388T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git 5487T: git git://linuxtv.org/media_tree.git
5389S: Maintained 5488S: Maintained
5390F: drivers/media/i2c/ov7670.c 5489F: drivers/media/i2c/ov7670.c
5391 5490
@@ -5934,11 +6033,18 @@ M: Mike Isely <isely@pobox.com>
5934L: pvrusb2@isely.net (subscribers-only) 6033L: pvrusb2@isely.net (subscribers-only)
5935L: linux-media@vger.kernel.org 6034L: linux-media@vger.kernel.org
5936W: http://www.isely.net/pvrusb2/ 6035W: http://www.isely.net/pvrusb2/
5937T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git 6036T: git git://linuxtv.org/media_tree.git
5938S: Maintained 6037S: Maintained
5939F: Documentation/video4linux/README.pvrusb2 6038F: Documentation/video4linux/README.pvrusb2
5940F: drivers/media/usb/pvrusb2/ 6039F: drivers/media/usb/pvrusb2/
5941 6040
6041PWC WEBCAM DRIVER
6042M: Hans de Goede <hdegoede@redhat.com>
6043L: linux-media@vger.kernel.org
6044T: git git://linuxtv.org/media_tree.git
6045S: Maintained
6046F: drivers/media/usb/pwc/*
6047
5942PWM SUBSYSTEM 6048PWM SUBSYSTEM
5943M: Thierry Reding <thierry.reding@avionic-design.de> 6049M: Thierry Reding <thierry.reding@avionic-design.de>
5944L: linux-kernel@vger.kernel.org 6050L: linux-kernel@vger.kernel.org
@@ -6081,6 +6187,21 @@ S: Maintained
6081F: drivers/video/aty/radeon* 6187F: drivers/video/aty/radeon*
6082F: include/linux/radeonfb.h 6188F: include/linux/radeonfb.h
6083 6189
6190RADIOSHARK RADIO DRIVER
6191M: Hans de Goede <hdegoede@redhat.com>
6192L: linux-media@vger.kernel.org
6193T: git git://linuxtv.org/media_tree.git
6194S: Maintained
6195F: drivers/media/radio/radio-shark.c
6196
6197RADIOSHARK2 RADIO DRIVER
6198M: Hans de Goede <hdegoede@redhat.com>
6199L: linux-media@vger.kernel.org
6200T: git git://linuxtv.org/media_tree.git
6201S: Maintained
6202F: drivers/media/radio/radio-shark2.c
6203F: drivers/media/radio/radio-tea5777.c
6204
6084RAGE128 FRAMEBUFFER DISPLAY DRIVER 6205RAGE128 FRAMEBUFFER DISPLAY DRIVER
6085M: Paul Mackerras <paulus@samba.org> 6206M: Paul Mackerras <paulus@samba.org>
6086L: linux-fbdev@vger.kernel.org 6207L: linux-fbdev@vger.kernel.org
@@ -6321,10 +6442,19 @@ L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
6321S: Supported 6442S: Supported
6322F: drivers/mmc/host/s3cmci.* 6443F: drivers/mmc/host/s3cmci.*
6323 6444
6445SAA7134 VIDEO4LINUX DRIVER
6446M: Mauro Carvalho Chehab <mchehab@redhat.com>
6447L: linux-media@vger.kernel.org
6448W: http://linuxtv.org
6449T: git git://linuxtv.org/media_tree.git
6450S: Odd fixes
6451F: Documentation/video4linux/saa7134/
6452F: drivers/media/pci/saa7134/
6453
6324SAA7146 VIDEO4LINUX-2 DRIVER 6454SAA7146 VIDEO4LINUX-2 DRIVER
6325M: Michael Hunold <michael@mihu.de> 6455M: Michael Hunold <michael@mihu.de>
6326L: linux-media@vger.kernel.org 6456L: linux-media@vger.kernel.org
6327T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git 6457T: git git://linuxtv.org/media_tree.git
6328W: http://www.mihu.de/linux/saa7146 6458W: http://www.mihu.de/linux/saa7146
6329S: Maintained 6459S: Maintained
6330F: drivers/media/common/saa7146/ 6460F: drivers/media/common/saa7146/
@@ -6359,6 +6489,14 @@ F: drivers/regulator/s5m*.c
6359F: drivers/rtc/rtc-sec.c 6489F: drivers/rtc/rtc-sec.c
6360F: include/linux/mfd/samsung/ 6490F: include/linux/mfd/samsung/
6361 6491
6492SAMSUNG S3C24XX/S3C64XX SOC SERIES CAMIF DRIVER
6493M: Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
6494L: linux-media@vger.kernel.org
6495L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers)
6496S: Maintained
6497F: drivers/media/platform/s3c-camif/
6498F: include/media/s3c_camif.h
6499
6362SERIAL DRIVERS 6500SERIAL DRIVERS
6363M: Alan Cox <alan@linux.intel.com> 6501M: Alan Cox <alan@linux.intel.com>
6364L: linux-serial@vger.kernel.org 6502L: linux-serial@vger.kernel.org
@@ -6653,6 +6791,18 @@ S: Supported
6653F: arch/arm/mach-davinci 6791F: arch/arm/mach-davinci
6654F: drivers/i2c/busses/i2c-davinci.c 6792F: drivers/i2c/busses/i2c-davinci.c
6655 6793
6794TI DAVINCI SERIES MEDIA DRIVER
6795M: Manjunath Hadli <manjunath.hadli@ti.com>
6796M: Prabhakar Lad <prabhakar.lad@ti.com>
6797L: linux-media@vger.kernel.org
6798L: davinci-linux-open-source@linux.davincidsp.com (moderated for non-subscribers)
6799W: http://linuxtv.org/
6800Q: http://patchwork.linuxtv.org/project/linux-media/list/
6801T: git git://linuxtv.org/mhadli/v4l-dvb-davinci_devices.git
6802S: Supported
6803F: drivers/media/platform/davinci/
6804F: include/media/davinci/
6805
6656SIS 190 ETHERNET DRIVER 6806SIS 190 ETHERNET DRIVER
6657M: Francois Romieu <romieu@fr.zoreil.com> 6807M: Francois Romieu <romieu@fr.zoreil.com>
6658L: netdev@vger.kernel.org 6808L: netdev@vger.kernel.org
@@ -6719,6 +6869,15 @@ M: Nicolas Pitre <nico@fluxnic.net>
6719S: Odd Fixes 6869S: Odd Fixes
6720F: drivers/net/ethernet/smsc/smc91x.* 6870F: drivers/net/ethernet/smsc/smc91x.*
6721 6871
6872SMIA AND SMIA++ IMAGE SENSOR DRIVER
6873M: Sakari Ailus <sakari.ailus@iki.fi>
6874L: linux-media@vger.kernel.org
6875S: Maintained
6876F: drivers/media/i2c/smiapp
6877F: include/media/smiapp.h
6878F: drivers/media/i2c/smiapp-pll.c
6879F: drivers/media/i2c/smiapp-pll.h
6880
6722SMM665 HARDWARE MONITOR DRIVER 6881SMM665 HARDWARE MONITOR DRIVER
6723M: Guenter Roeck <linux@roeck-us.net> 6882M: Guenter Roeck <linux@roeck-us.net>
6724L: lm-sensors@lm-sensors.org 6883L: lm-sensors@lm-sensors.org
@@ -6777,7 +6936,7 @@ F: arch/ia64/sn/
6777SOC-CAMERA V4L2 SUBSYSTEM 6936SOC-CAMERA V4L2 SUBSYSTEM
6778M: Guennadi Liakhovetski <g.liakhovetski@gmx.de> 6937M: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
6779L: linux-media@vger.kernel.org 6938L: linux-media@vger.kernel.org
6780T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git 6939T: git git://linuxtv.org/media_tree.git
6781S: Maintained 6940S: Maintained
6782F: include/media/soc* 6941F: include/media/soc*
6783F: drivers/media/i2c/soc_camera/ 6942F: drivers/media/i2c/soc_camera/
@@ -7267,6 +7426,22 @@ T: git git://linuxtv.org/mkrufky/tuners.git
7267S: Maintained 7426S: Maintained
7268F: drivers/media/tuners/tda8290.* 7427F: drivers/media/tuners/tda8290.*
7269 7428
7429TEA5761 TUNER DRIVER
7430M: Mauro Carvalho Chehab <mchehab@redhat.com>
7431L: linux-media@vger.kernel.org
7432W: http://linuxtv.org
7433T: git git://linuxtv.org/media_tree.git
7434S: Odd fixes
7435F: drivers/media/tuners/tea5761.*
7436
7437TEA5767 TUNER DRIVER
7438M: Mauro Carvalho Chehab <mchehab@redhat.com>
7439L: linux-media@vger.kernel.org
7440W: http://linuxtv.org
7441T: git git://linuxtv.org/media_tree.git
7442S: Maintained
7443F: drivers/media/tuners/tea5767.*
7444
7270TEAM DRIVER 7445TEAM DRIVER
7271M: Jiri Pirko <jpirko@redhat.com> 7446M: Jiri Pirko <jpirko@redhat.com>
7272L: netdev@vger.kernel.org 7447L: netdev@vger.kernel.org
@@ -7274,6 +7449,12 @@ S: Supported
7274F: drivers/net/team/ 7449F: drivers/net/team/
7275F: include/linux/if_team.h 7450F: include/linux/if_team.h
7276 7451
7452TECHNOTREND USB IR RECEIVER
7453M: Sean Young <sean@mess.org>
7454L: linux-media@vger.kernel.org
7455S: Maintained
7456F: drivers/media/rc/ttusbir.c
7457
7277TEGRA SUPPORT 7458TEGRA SUPPORT
7278M: Stephen Warren <swarren@wwwdotorg.org> 7459M: Stephen Warren <swarren@wwwdotorg.org>
7279L: linux-tegra@vger.kernel.org 7460L: linux-tegra@vger.kernel.org
@@ -7426,6 +7607,14 @@ S: Maintained
7426F: include/linux/shmem_fs.h 7607F: include/linux/shmem_fs.h
7427F: mm/shmem.c 7608F: mm/shmem.c
7428 7609
7610TM6000 VIDEO4LINUX DRIVER
7611M: Mauro Carvalho Chehab <mchehab@redhat.com>
7612L: linux-media@vger.kernel.org
7613W: http://linuxtv.org
7614T: git git://linuxtv.org/media_tree.git
7615S: Odd fixes
7616F: drivers/media/usb/tm6000/
7617
7429TPM DEVICE DRIVER 7618TPM DEVICE DRIVER
7430M: Kent Yoder <key@linux.vnet.ibm.com> 7619M: Kent Yoder <key@linux.vnet.ibm.com>
7431M: Rajiv Andrade <mail@srajiv.net> 7620M: Rajiv Andrade <mail@srajiv.net>
@@ -7820,7 +8009,7 @@ USB SN9C1xx DRIVER
7820M: Luca Risolia <luca.risolia@studio.unibo.it> 8009M: Luca Risolia <luca.risolia@studio.unibo.it>
7821L: linux-usb@vger.kernel.org 8010L: linux-usb@vger.kernel.org
7822L: linux-media@vger.kernel.org 8011L: linux-media@vger.kernel.org
7823T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git 8012T: git git://linuxtv.org/media_tree.git
7824W: http://www.linux-projects.org 8013W: http://www.linux-projects.org
7825S: Maintained 8014S: Maintained
7826F: Documentation/video4linux/sn9c102.txt 8015F: Documentation/video4linux/sn9c102.txt
@@ -7856,10 +8045,11 @@ USB VIDEO CLASS
7856M: Laurent Pinchart <laurent.pinchart@ideasonboard.com> 8045M: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
7857L: linux-uvc-devel@lists.sourceforge.net (subscribers-only) 8046L: linux-uvc-devel@lists.sourceforge.net (subscribers-only)
7858L: linux-media@vger.kernel.org 8047L: linux-media@vger.kernel.org
7859T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git 8048T: git git://linuxtv.org/media_tree.git
7860W: http://www.ideasonboard.org/uvc/ 8049W: http://www.ideasonboard.org/uvc/
7861S: Maintained 8050S: Maintained
7862F: drivers/media/usb/uvc/ 8051F: drivers/media/usb/uvc/
8052F: include/uapi/linux/uvcvideo.h
7863 8053
7864USB WEBCAM GADGET 8054USB WEBCAM GADGET
7865M: Laurent Pinchart <laurent.pinchart@ideasonboard.com> 8055M: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
@@ -7891,7 +8081,7 @@ USB ZR364XX DRIVER
7891M: Antoine Jacquet <royale@zerezo.com> 8081M: Antoine Jacquet <royale@zerezo.com>
7892L: linux-usb@vger.kernel.org 8082L: linux-usb@vger.kernel.org
7893L: linux-media@vger.kernel.org 8083L: linux-media@vger.kernel.org
7894T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git 8084T: git git://linuxtv.org/media_tree.git
7895W: http://royale.zerezo.com/zr364xx/ 8085W: http://royale.zerezo.com/zr364xx/
7896S: Maintained 8086S: Maintained
7897F: Documentation/video4linux/zr364xx.txt 8087F: Documentation/video4linux/zr364xx.txt
@@ -8246,6 +8436,14 @@ L: linux-edac@vger.kernel.org
8246S: Maintained 8436S: Maintained
8247F: arch/x86/kernel/cpu/mcheck/* 8437F: arch/x86/kernel/cpu/mcheck/*
8248 8438
8439XC2028/3028 TUNER DRIVER
8440M: Mauro Carvalho Chehab <mchehab@redhat.com>
8441L: linux-media@vger.kernel.org
8442W: http://linuxtv.org
8443T: git git://linuxtv.org/media_tree.git
8444S: Maintained
8445F: drivers/media/tuners/tuner-xc2028.*
8446
8249XEN HYPERVISOR INTERFACE 8447XEN HYPERVISOR INTERFACE
8250M: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> 8448M: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
8251M: Jeremy Fitzhardinge <jeremy@goop.org> 8449M: Jeremy Fitzhardinge <jeremy@goop.org>
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index c67a731cfbb7..4abb8b5e9bc0 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -203,6 +203,16 @@ static struct resource omap3isp_resources[] = {
203 .flags = IORESOURCE_MEM, 203 .flags = IORESOURCE_MEM,
204 }, 204 },
205 { 205 {
206 .start = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE,
207 .end = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE + 3,
208 .flags = IORESOURCE_MEM,
209 },
210 {
211 .start = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL,
212 .end = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL + 3,
213 .flags = IORESOURCE_MEM,
214 },
215 {
206 .start = 24 + OMAP_INTC_START, 216 .start = 24 + OMAP_INTC_START,
207 .flags = IORESOURCE_IRQ, 217 .flags = IORESOURCE_IRQ,
208 } 218 }
diff --git a/arch/arm/mach-pxa/pcm990-baseboard.c b/arch/arm/mach-pxa/pcm990-baseboard.c
index 113c57a03565..fb7f1d1627dc 100644
--- a/arch/arm/mach-pxa/pcm990-baseboard.c
+++ b/arch/arm/mach-pxa/pcm990-baseboard.c
@@ -26,6 +26,7 @@
26#include <linux/i2c/pxa-i2c.h> 26#include <linux/i2c/pxa-i2c.h>
27#include <linux/pwm_backlight.h> 27#include <linux/pwm_backlight.h>
28 28
29#include <media/mt9v022.h>
29#include <media/soc_camera.h> 30#include <media/soc_camera.h>
30 31
31#include <linux/platform_data/camera-pxa.h> 32#include <linux/platform_data/camera-pxa.h>
@@ -468,6 +469,10 @@ static struct i2c_board_info __initdata pcm990_i2c_devices[] = {
468 }, 469 },
469}; 470};
470 471
472static struct mt9v022_platform_data mt9v022_pdata = {
473 .y_skip_top = 1,
474};
475
471static struct i2c_board_info pcm990_camera_i2c[] = { 476static struct i2c_board_info pcm990_camera_i2c[] = {
472 { 477 {
473 I2C_BOARD_INFO("mt9v022", 0x48), 478 I2C_BOARD_INFO("mt9v022", 0x48),
@@ -480,6 +485,7 @@ static struct soc_camera_link iclink[] = {
480 { 485 {
481 .bus_id = 0, /* Must match with the camera ID */ 486 .bus_id = 0, /* Must match with the camera ID */
482 .board_info = &pcm990_camera_i2c[0], 487 .board_info = &pcm990_camera_i2c[0],
488 .priv = &mt9v022_pdata,
483 .i2c_adapter_id = 0, 489 .i2c_adapter_id = 0,
484 .query_bus_param = pcm990_camera_query_bus_param, 490 .query_bus_param = pcm990_camera_query_bus_param,
485 .set_bus_param = pcm990_camera_set_bus_param, 491 .set_bus_param = pcm990_camera_set_bus_param,
diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
index 3fbedc75e7c5..0ce39a33b3c2 100644
--- a/drivers/base/dma-mapping.c
+++ b/drivers/base/dma-mapping.c
@@ -218,6 +218,8 @@ void dmam_release_declared_memory(struct device *dev)
218} 218}
219EXPORT_SYMBOL(dmam_release_declared_memory); 219EXPORT_SYMBOL(dmam_release_declared_memory);
220 220
221#endif
222
221/* 223/*
222 * Create scatter-list for the already allocated DMA buffer. 224 * Create scatter-list for the already allocated DMA buffer.
223 */ 225 */
@@ -236,8 +238,6 @@ int dma_common_get_sgtable(struct device *dev, struct sg_table *sgt,
236} 238}
237EXPORT_SYMBOL(dma_common_get_sgtable); 239EXPORT_SYMBOL(dma_common_get_sgtable);
238 240
239#endif
240
241/* 241/*
242 * Create userspace mapping for the DMA-coherent memory. 242 * Create userspace mapping for the DMA-coherent memory.
243 */ 243 */
diff --git a/drivers/hid/hid-picolcd_cir.c b/drivers/hid/hid-picolcd_cir.c
index 13ca9191b630..a79e95bb9fb6 100644
--- a/drivers/hid/hid-picolcd_cir.c
+++ b/drivers/hid/hid-picolcd_cir.c
@@ -116,7 +116,7 @@ int picolcd_init_cir(struct picolcd_data *data, struct hid_report *report)
116 116
117 rdev->priv = data; 117 rdev->priv = data;
118 rdev->driver_type = RC_DRIVER_IR_RAW; 118 rdev->driver_type = RC_DRIVER_IR_RAW;
119 rdev->allowed_protos = RC_TYPE_ALL; 119 rdev->allowed_protos = RC_BIT_ALL;
120 rdev->open = picolcd_cir_open; 120 rdev->open = picolcd_cir_open;
121 rdev->close = picolcd_cir_close; 121 rdev->close = picolcd_cir_close;
122 rdev->input_name = data->hdev->name; 122 rdev->input_name = data->hdev->name;
diff --git a/drivers/media/common/Kconfig b/drivers/media/common/Kconfig
index 121b0110af3c..d2a436ce77f8 100644
--- a/drivers/media/common/Kconfig
+++ b/drivers/media/common/Kconfig
@@ -1,3 +1,10 @@
1# Used by common drivers, when they need to ask questions
2config MEDIA_COMMON_OPTIONS
3 bool
4
5comment "common driver options"
6 depends on MEDIA_COMMON_OPTIONS
7
1source "drivers/media/common/b2c2/Kconfig" 8source "drivers/media/common/b2c2/Kconfig"
2source "drivers/media/common/saa7146/Kconfig" 9source "drivers/media/common/saa7146/Kconfig"
3source "drivers/media/common/siano/Kconfig" 10source "drivers/media/common/siano/Kconfig"
diff --git a/drivers/media/common/b2c2/Kconfig b/drivers/media/common/b2c2/Kconfig
index 1df9e578daa5..a8c6cdfaa2f5 100644
--- a/drivers/media/common/b2c2/Kconfig
+++ b/drivers/media/common/b2c2/Kconfig
@@ -17,11 +17,6 @@ config DVB_B2C2_FLEXCOP
17 select DVB_CX24123 if MEDIA_SUBDRV_AUTOSELECT 17 select DVB_CX24123 if MEDIA_SUBDRV_AUTOSELECT
18 select MEDIA_TUNER_SIMPLE if MEDIA_SUBDRV_AUTOSELECT 18 select MEDIA_TUNER_SIMPLE if MEDIA_SUBDRV_AUTOSELECT
19 select DVB_TUNER_CX24113 if MEDIA_SUBDRV_AUTOSELECT 19 select DVB_TUNER_CX24113 if MEDIA_SUBDRV_AUTOSELECT
20 help
21 Support for the digital TV receiver chip made by B2C2 Inc. included in
22 Technisats PCI cards and USB boxes.
23
24 Say Y if you own such a device and want to use it.
25 20
26# Selected via the PCI or USB flexcop drivers 21# Selected via the PCI or USB flexcop drivers
27config DVB_B2C2_FLEXCOP_DEBUG 22config DVB_B2C2_FLEXCOP_DEBUG
diff --git a/drivers/media/common/siano/Kconfig b/drivers/media/common/siano/Kconfig
index 425aeadfb49d..68f0f604678e 100644
--- a/drivers/media/common/siano/Kconfig
+++ b/drivers/media/common/siano/Kconfig
@@ -4,14 +4,16 @@
4 4
5config SMS_SIANO_MDTV 5config SMS_SIANO_MDTV
6 tristate 6 tristate
7 depends on DVB_CORE && RC_CORE && HAS_DMA 7 depends on DVB_CORE && HAS_DMA
8 depends on !RC_CORE || RC_CORE
8 depends on SMS_USB_DRV || SMS_SDIO_DRV 9 depends on SMS_USB_DRV || SMS_SDIO_DRV
9 default y 10 default y
10 ---help---
11 Choose Y or M here if you have MDTV receiver with a Siano chipset.
12
13 To compile this driver as a module, choose M here
14 (The module will be called smsmdtv).
15 11
16 Further documentation on this driver can be found on the WWW 12config SMS_SIANO_RC
17 at http://www.siano-ms.com/ 13 bool "Enable Remote Controller support for Siano devices"
14 depends on SMS_SIANO_MDTV && RC_CORE
15 depends on SMS_USB_DRV || SMS_SDIO_DRV
16 depends on MEDIA_COMMON_OPTIONS
17 default y
18 ---help---
19 Choose Y to select Remote Controller support for Siano driver.
diff --git a/drivers/media/common/siano/Makefile b/drivers/media/common/siano/Makefile
index 2a09279e0648..81b1e985bea5 100644
--- a/drivers/media/common/siano/Makefile
+++ b/drivers/media/common/siano/Makefile
@@ -1,7 +1,11 @@
1smsmdtv-objs := smscoreapi.o sms-cards.o smsendian.o smsir.o 1smsmdtv-objs := smscoreapi.o sms-cards.o smsendian.o
2 2
3obj-$(CONFIG_SMS_SIANO_MDTV) += smsmdtv.o smsdvb.o 3obj-$(CONFIG_SMS_SIANO_MDTV) += smsmdtv.o smsdvb.o
4 4
5ifeq ($(CONFIG_SMS_SIANO_RC),y)
6 smsmdtv-objs += smsir.o
7endif
8
5ccflags-y += -Idrivers/media/dvb-core 9ccflags-y += -Idrivers/media/dvb-core
6ccflags-y += $(extra-cflags-y) $(extra-cflags-m) 10ccflags-y += $(extra-cflags-y) $(extra-cflags-m)
7 11
diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c
index 9cc55546cc30..1842e64e6338 100644
--- a/drivers/media/common/siano/smscoreapi.c
+++ b/drivers/media/common/siano/smscoreapi.c
@@ -1092,7 +1092,7 @@ EXPORT_SYMBOL_GPL(smscore_onresponse);
1092 * @return pointer to descriptor on success, NULL on error. 1092 * @return pointer to descriptor on success, NULL on error.
1093 */ 1093 */
1094 1094
1095struct smscore_buffer_t *get_entry(struct smscore_device_t *coredev) 1095static struct smscore_buffer_t *get_entry(struct smscore_device_t *coredev)
1096{ 1096{
1097 struct smscore_buffer_t *cb = NULL; 1097 struct smscore_buffer_t *cb = NULL;
1098 unsigned long flags; 1098 unsigned long flags;
diff --git a/drivers/media/common/siano/smsir.c b/drivers/media/common/siano/smsir.c
index 37bc5c4b8ad8..b8c5cad78537 100644
--- a/drivers/media/common/siano/smsir.c
+++ b/drivers/media/common/siano/smsir.c
@@ -88,7 +88,7 @@ int sms_ir_init(struct smscore_device_t *coredev)
88 88
89 dev->priv = coredev; 89 dev->priv = coredev;
90 dev->driver_type = RC_DRIVER_IR_RAW; 90 dev->driver_type = RC_DRIVER_IR_RAW;
91 dev->allowed_protos = RC_TYPE_ALL; 91 dev->allowed_protos = RC_BIT_ALL;
92 dev->map_name = sms_get_board(board_id)->rc_codes; 92 dev->map_name = sms_get_board(board_id)->rc_codes;
93 dev->driver_name = MODULE_NAME; 93 dev->driver_name = MODULE_NAME;
94 94
diff --git a/drivers/media/common/siano/smsir.h b/drivers/media/common/siano/smsir.h
index ae92b3a8587e..69b59b9eee28 100644
--- a/drivers/media/common/siano/smsir.h
+++ b/drivers/media/common/siano/smsir.h
@@ -46,10 +46,19 @@ struct ir_t {
46 u32 controller; 46 u32 controller;
47}; 47};
48 48
49#ifdef CONFIG_SMS_SIANO_RC
49int sms_ir_init(struct smscore_device_t *coredev); 50int sms_ir_init(struct smscore_device_t *coredev);
50void sms_ir_exit(struct smscore_device_t *coredev); 51void sms_ir_exit(struct smscore_device_t *coredev);
51void sms_ir_event(struct smscore_device_t *coredev, 52void sms_ir_event(struct smscore_device_t *coredev,
52 const char *buf, int len); 53 const char *buf, int len);
54#else
55inline static int sms_ir_init(struct smscore_device_t *coredev) {
56 return 0;
57}
58inline static void sms_ir_exit(struct smscore_device_t *coredev) {};
59inline static void sms_ir_event(struct smscore_device_t *coredev,
60 const char *buf, int len) {};
61#endif
53 62
54#endif /* __SMS_IR_H__ */ 63#endif /* __SMS_IR_H__ */
55 64
diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c
index 889c9c16c6df..d81dbb22aa81 100644
--- a/drivers/media/dvb-core/dmxdev.c
+++ b/drivers/media/dvb-core/dmxdev.c
@@ -877,7 +877,7 @@ static int dvb_dmxdev_pes_filter_set(struct dmxdev *dmxdev,
877 dvb_dmxdev_filter_stop(dmxdevfilter); 877 dvb_dmxdev_filter_stop(dmxdevfilter);
878 dvb_dmxdev_filter_reset(dmxdevfilter); 878 dvb_dmxdev_filter_reset(dmxdevfilter);
879 879
880 if (params->pes_type > DMX_PES_OTHER || params->pes_type < 0) 880 if ((unsigned)params->pes_type > DMX_PES_OTHER)
881 return -EINVAL; 881 return -EINVAL;
882 882
883 dmxdevfilter->type = DMXDEV_TYPE_PES; 883 dmxdevfilter->type = DMXDEV_TYPE_PES;
diff --git a/drivers/media/dvb-core/dmxdev.h b/drivers/media/dvb-core/dmxdev.h
index 02ebe28f830d..48c6cf92ab99 100644
--- a/drivers/media/dvb-core/dmxdev.h
+++ b/drivers/media/dvb-core/dmxdev.h
@@ -26,6 +26,7 @@
26#include <linux/types.h> 26#include <linux/types.h>
27#include <linux/spinlock.h> 27#include <linux/spinlock.h>
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/time.h>
29#include <linux/timer.h> 30#include <linux/timer.h>
30#include <linux/wait.h> 31#include <linux/wait.h>
31#include <linux/fs.h> 32#include <linux/fs.h>
diff --git a/drivers/media/dvb-core/dvb-usb-ids.h b/drivers/media/dvb-core/dvb-usb-ids.h
index 58e0220447c0..388c2eb4d747 100644
--- a/drivers/media/dvb-core/dvb-usb-ids.h
+++ b/drivers/media/dvb-core/dvb-usb-ids.h
@@ -250,6 +250,7 @@
250#define USB_PID_TERRATEC_T3 0x10a0 250#define USB_PID_TERRATEC_T3 0x10a0
251#define USB_PID_TERRATEC_T5 0x10a1 251#define USB_PID_TERRATEC_T5 0x10a1
252#define USB_PID_NOXON_DAB_STICK 0x00b3 252#define USB_PID_NOXON_DAB_STICK 0x00b3
253#define USB_PID_NOXON_DAB_STICK_REV2 0x00e0
253#define USB_PID_PINNACLE_EXPRESSCARD_320CX 0x022e 254#define USB_PID_PINNACLE_EXPRESSCARD_320CX 0x022e
254#define USB_PID_PINNACLE_PCTV2000E 0x022c 255#define USB_PID_PINNACLE_PCTV2000E 0x022c
255#define USB_PID_PINNACLE_PCTV_DVB_T_FLASH 0x0228 256#define USB_PID_PINNACLE_PCTV_DVB_T_FLASH 0x0228
diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index 7e92793260f0..49d95040096a 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -1029,12 +1029,6 @@ static struct dtv_cmds_h dtv_cmds[DTV_MAX_COMMAND + 1] = {
1029 /* Get */ 1029 /* Get */
1030 _DTV_CMD(DTV_DISEQC_SLAVE_REPLY, 0, 1), 1030 _DTV_CMD(DTV_DISEQC_SLAVE_REPLY, 0, 1),
1031 _DTV_CMD(DTV_API_VERSION, 0, 0), 1031 _DTV_CMD(DTV_API_VERSION, 0, 0),
1032 _DTV_CMD(DTV_CODE_RATE_HP, 0, 0),
1033 _DTV_CMD(DTV_CODE_RATE_LP, 0, 0),
1034 _DTV_CMD(DTV_GUARD_INTERVAL, 0, 0),
1035 _DTV_CMD(DTV_TRANSMISSION_MODE, 0, 0),
1036 _DTV_CMD(DTV_HIERARCHY, 0, 0),
1037 _DTV_CMD(DTV_INTERLEAVING, 0, 0),
1038 1032
1039 _DTV_CMD(DTV_ENUM_DELSYS, 0, 0), 1033 _DTV_CMD(DTV_ENUM_DELSYS, 0, 0),
1040 1034
@@ -1042,13 +1036,11 @@ static struct dtv_cmds_h dtv_cmds[DTV_MAX_COMMAND + 1] = {
1042 _DTV_CMD(DTV_ATSCMH_RS_FRAME_ENSEMBLE, 1, 0), 1036 _DTV_CMD(DTV_ATSCMH_RS_FRAME_ENSEMBLE, 1, 0),
1043 1037
1044 _DTV_CMD(DTV_ATSCMH_FIC_VER, 0, 0), 1038 _DTV_CMD(DTV_ATSCMH_FIC_VER, 0, 0),
1045 _DTV_CMD(DTV_ATSCMH_PARADE_ID, 0, 0),
1046 _DTV_CMD(DTV_ATSCMH_NOG, 0, 0), 1039 _DTV_CMD(DTV_ATSCMH_NOG, 0, 0),
1047 _DTV_CMD(DTV_ATSCMH_TNOG, 0, 0), 1040 _DTV_CMD(DTV_ATSCMH_TNOG, 0, 0),
1048 _DTV_CMD(DTV_ATSCMH_SGN, 0, 0), 1041 _DTV_CMD(DTV_ATSCMH_SGN, 0, 0),
1049 _DTV_CMD(DTV_ATSCMH_PRC, 0, 0), 1042 _DTV_CMD(DTV_ATSCMH_PRC, 0, 0),
1050 _DTV_CMD(DTV_ATSCMH_RS_FRAME_MODE, 0, 0), 1043 _DTV_CMD(DTV_ATSCMH_RS_FRAME_MODE, 0, 0),
1051 _DTV_CMD(DTV_ATSCMH_RS_FRAME_ENSEMBLE, 0, 0),
1052 _DTV_CMD(DTV_ATSCMH_RS_CODE_MODE_PRI, 0, 0), 1044 _DTV_CMD(DTV_ATSCMH_RS_CODE_MODE_PRI, 0, 0),
1053 _DTV_CMD(DTV_ATSCMH_RS_CODE_MODE_SEC, 0, 0), 1045 _DTV_CMD(DTV_ATSCMH_RS_CODE_MODE_SEC, 0, 0),
1054 _DTV_CMD(DTV_ATSCMH_SCCC_BLOCK_MODE, 0, 0), 1046 _DTV_CMD(DTV_ATSCMH_SCCC_BLOCK_MODE, 0, 0),
@@ -1056,8 +1048,6 @@ static struct dtv_cmds_h dtv_cmds[DTV_MAX_COMMAND + 1] = {
1056 _DTV_CMD(DTV_ATSCMH_SCCC_CODE_MODE_B, 0, 0), 1048 _DTV_CMD(DTV_ATSCMH_SCCC_CODE_MODE_B, 0, 0),
1057 _DTV_CMD(DTV_ATSCMH_SCCC_CODE_MODE_C, 0, 0), 1049 _DTV_CMD(DTV_ATSCMH_SCCC_CODE_MODE_C, 0, 0),
1058 _DTV_CMD(DTV_ATSCMH_SCCC_CODE_MODE_D, 0, 0), 1050 _DTV_CMD(DTV_ATSCMH_SCCC_CODE_MODE_D, 0, 0),
1059
1060 _DTV_CMD(DTV_LNA, 0, 0),
1061}; 1051};
1062 1052
1063static void dtv_property_dump(struct dvb_frontend *fe, struct dtv_property *tvp) 1053static void dtv_property_dump(struct dvb_frontend *fe, struct dtv_property *tvp)
diff --git a/drivers/media/dvb-frontends/cx22700.c b/drivers/media/dvb-frontends/cx22700.c
index f2a90f990ce3..3d399d9a6343 100644
--- a/drivers/media/dvb-frontends/cx22700.c
+++ b/drivers/media/dvb-frontends/cx22700.c
@@ -139,7 +139,7 @@ static int cx22700_set_tps(struct cx22700_state *state,
139 if (p->code_rate_HP == FEC_4_5 || p->code_rate_LP == FEC_4_5) 139 if (p->code_rate_HP == FEC_4_5 || p->code_rate_LP == FEC_4_5)
140 return -EINVAL; 140 return -EINVAL;
141 141
142 if (p->guard_interval < GUARD_INTERVAL_1_32 || 142 if ((int)p->guard_interval < GUARD_INTERVAL_1_32 ||
143 p->guard_interval > GUARD_INTERVAL_1_4) 143 p->guard_interval > GUARD_INTERVAL_1_4)
144 return -EINVAL; 144 return -EINVAL;
145 145
@@ -152,7 +152,7 @@ static int cx22700_set_tps(struct cx22700_state *state,
152 p->modulation != QAM_64) 152 p->modulation != QAM_64)
153 return -EINVAL; 153 return -EINVAL;
154 154
155 if (p->hierarchy < HIERARCHY_NONE || 155 if ((int)p->hierarchy < HIERARCHY_NONE ||
156 p->hierarchy > HIERARCHY_4) 156 p->hierarchy > HIERARCHY_4)
157 return -EINVAL; 157 return -EINVAL;
158 158
diff --git a/drivers/media/dvb-frontends/cx24123.c b/drivers/media/dvb-frontends/cx24123.c
index 7e28b4ee7d4f..68c88ab58e71 100644
--- a/drivers/media/dvb-frontends/cx24123.c
+++ b/drivers/media/dvb-frontends/cx24123.c
@@ -338,7 +338,7 @@ static int cx24123_set_fec(struct cx24123_state *state, fe_code_rate_t fec)
338{ 338{
339 u8 nom_reg = cx24123_readreg(state, 0x0e) & ~0x07; 339 u8 nom_reg = cx24123_readreg(state, 0x0e) & ~0x07;
340 340
341 if ((fec < FEC_NONE) || (fec > FEC_AUTO)) 341 if (((int)fec < FEC_NONE) || (fec > FEC_AUTO))
342 fec = FEC_AUTO; 342 fec = FEC_AUTO;
343 343
344 /* Set the soft decision threshold */ 344 /* Set the soft decision threshold */
diff --git a/drivers/media/dvb-frontends/dib9000.h b/drivers/media/dvb-frontends/dib9000.h
index b5781a48034c..de1cc91fd833 100644
--- a/drivers/media/dvb-frontends/dib9000.h
+++ b/drivers/media/dvb-frontends/dib9000.h
@@ -97,7 +97,7 @@ static inline int dib9000_set_slave_frontend(struct dvb_frontend *fe, struct dvb
97 return -ENODEV; 97 return -ENODEV;
98} 98}
99 99
100int dib9000_remove_slave_frontend(struct dvb_frontend *fe) 100static inline int dib9000_remove_slave_frontend(struct dvb_frontend *fe)
101{ 101{
102 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 102 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
103 return -ENODEV; 103 return -ENODEV;
diff --git a/drivers/media/dvb-frontends/drxd_hard.c b/drivers/media/dvb-frontends/drxd_hard.c
index 6d9853750d2b..e71cc60851e7 100644
--- a/drivers/media/dvb-frontends/drxd_hard.c
+++ b/drivers/media/dvb-frontends/drxd_hard.c
@@ -1748,7 +1748,8 @@ static int DRX_Stop(struct drxd_state *state)
1748 return status; 1748 return status;
1749} 1749}
1750 1750
1751int SetOperationMode(struct drxd_state *state, int oMode) 1751#if 0 /* Currently unused */
1752static int SetOperationMode(struct drxd_state *state, int oMode)
1752{ 1753{
1753 int status; 1754 int status;
1754 1755
@@ -1788,6 +1789,7 @@ int SetOperationMode(struct drxd_state *state, int oMode)
1788 state->operation_mode = oMode; 1789 state->operation_mode = oMode;
1789 return status; 1790 return status;
1790} 1791}
1792#endif
1791 1793
1792static int StartDiversity(struct drxd_state *state) 1794static int StartDiversity(struct drxd_state *state)
1793{ 1795{
@@ -2612,7 +2614,7 @@ static int CDRXD(struct drxd_state *state, u32 IntermediateFrequency)
2612 return 0; 2614 return 0;
2613} 2615}
2614 2616
2615int DRXD_init(struct drxd_state *state, const u8 * fw, u32 fw_size) 2617static int DRXD_init(struct drxd_state *state, const u8 *fw, u32 fw_size)
2616{ 2618{
2617 int status = 0; 2619 int status = 0;
2618 u32 driverVersion; 2620 u32 driverVersion;
@@ -2774,7 +2776,7 @@ int DRXD_init(struct drxd_state *state, const u8 * fw, u32 fw_size)
2774 return status; 2776 return status;
2775} 2777}
2776 2778
2777int DRXD_status(struct drxd_state *state, u32 * pLockStatus) 2779static int DRXD_status(struct drxd_state *state, u32 *pLockStatus)
2778{ 2780{
2779 DRX_GetLockStatus(state, pLockStatus); 2781 DRX_GetLockStatus(state, pLockStatus);
2780 2782
diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c
index df9abe83f877..c2fc7da0d6bf 100644
--- a/drivers/media/dvb-frontends/drxk_hard.c
+++ b/drivers/media/dvb-frontends/drxk_hard.c
@@ -65,16 +65,6 @@ static bool IsQAM(struct drxk_state *state)
65 state->m_OperationMode == OM_QAM_ITU_C; 65 state->m_OperationMode == OM_QAM_ITU_C;
66} 66}
67 67
68bool IsA1WithPatchCode(struct drxk_state *state)
69{
70 return state->m_DRXK_A1_PATCH_CODE;
71}
72
73bool IsA1WithRomCode(struct drxk_state *state)
74{
75 return state->m_DRXK_A1_ROM_CODE;
76}
77
78#define NOA1ROM 0 68#define NOA1ROM 0
79 69
80#define DRXDAP_FASI_SHORT_FORMAT(addr) (((addr) & 0xFC30FF80) == 0) 70#define DRXDAP_FASI_SHORT_FORMAT(addr) (((addr) & 0xFC30FF80) == 0)
@@ -189,7 +179,7 @@ static inline u32 MulDiv32(u32 a, u32 b, u32 c)
189 return (u32) tmp64; 179 return (u32) tmp64;
190} 180}
191 181
192inline u32 Frac28a(u32 a, u32 c) 182static inline u32 Frac28a(u32 a, u32 c)
193{ 183{
194 int i = 0; 184 int i = 0;
195 u32 Q1 = 0; 185 u32 Q1 = 0;
@@ -587,7 +577,7 @@ static int write_block(struct drxk_state *state, u32 Address,
587#define DRXK_MAX_RETRIES_POWERUP 20 577#define DRXK_MAX_RETRIES_POWERUP 20
588#endif 578#endif
589 579
590int PowerUpDevice(struct drxk_state *state) 580static int PowerUpDevice(struct drxk_state *state)
591{ 581{
592 int status; 582 int status;
593 u8 data = 0; 583 u8 data = 0;
@@ -720,11 +710,6 @@ static int init_state(struct drxk_state *state)
720 710
721 state->m_bPowerDown = (ulPowerDown != 0); 711 state->m_bPowerDown = (ulPowerDown != 0);
722 712
723 state->m_DRXK_A1_PATCH_CODE = false;
724 state->m_DRXK_A1_ROM_CODE = false;
725 state->m_DRXK_A2_ROM_CODE = false;
726 state->m_DRXK_A3_ROM_CODE = false;
727 state->m_DRXK_A2_PATCH_CODE = false;
728 state->m_DRXK_A3_PATCH_CODE = false; 713 state->m_DRXK_A3_PATCH_CODE = false;
729 714
730 /* Init AGC and PGA parameters */ 715 /* Init AGC and PGA parameters */
@@ -921,7 +906,7 @@ static int GetDeviceCapabilities(struct drxk_state *state)
921 status = write16(state, SCU_RAM_GPIO__A, SCU_RAM_GPIO_HW_LOCK_IND_DISABLE); 906 status = write16(state, SCU_RAM_GPIO__A, SCU_RAM_GPIO_HW_LOCK_IND_DISABLE);
922 if (status < 0) 907 if (status < 0)
923 goto error; 908 goto error;
924 status = write16(state, SIO_TOP_COMM_KEY__A, 0xFABA); 909 status = write16(state, SIO_TOP_COMM_KEY__A, SIO_TOP_COMM_KEY_KEY);
925 if (status < 0) 910 if (status < 0)
926 goto error; 911 goto error;
927 status = read16(state, SIO_PDR_OHW_CFG__A, &sioPdrOhwCfg); 912 status = read16(state, SIO_PDR_OHW_CFG__A, &sioPdrOhwCfg);
@@ -1217,7 +1202,7 @@ static int MPEGTSConfigurePins(struct drxk_state *state, bool mpegEnable)
1217 goto error; 1202 goto error;
1218 1203
1219 /* MPEG TS pad configuration */ 1204 /* MPEG TS pad configuration */
1220 status = write16(state, SIO_TOP_COMM_KEY__A, 0xFABA); 1205 status = write16(state, SIO_TOP_COMM_KEY__A, SIO_TOP_COMM_KEY_KEY);
1221 if (status < 0) 1206 if (status < 0)
1222 goto error; 1207 goto error;
1223 1208
@@ -5461,6 +5446,7 @@ static int QAMDemodulatorCommand(struct drxk_state *state,
5461 } else { 5446 } else {
5462 printk(KERN_WARNING "drxk: Unknown QAM demodulator parameter " 5447 printk(KERN_WARNING "drxk: Unknown QAM demodulator parameter "
5463 "count %d\n", numberOfParameters); 5448 "count %d\n", numberOfParameters);
5449 status = -EINVAL;
5464 } 5450 }
5465 5451
5466error: 5452error:
diff --git a/drivers/media/dvb-frontends/drxk_hard.h b/drivers/media/dvb-frontends/drxk_hard.h
index 6bb9fc4a7b96..d18a896a9835 100644
--- a/drivers/media/dvb-frontends/drxk_hard.h
+++ b/drivers/media/dvb-frontends/drxk_hard.h
@@ -320,11 +320,7 @@ struct drxk_state {
320 320
321 u8 *m_microcode; 321 u8 *m_microcode;
322 int m_microcode_length; 322 int m_microcode_length;
323 bool m_DRXK_A1_PATCH_CODE; 323 bool m_DRXK_A3_ROM_CODE;
324 bool m_DRXK_A1_ROM_CODE;
325 bool m_DRXK_A2_ROM_CODE;
326 bool m_DRXK_A3_ROM_CODE;
327 bool m_DRXK_A2_PATCH_CODE;
328 bool m_DRXK_A3_PATCH_CODE; 324 bool m_DRXK_A3_PATCH_CODE;
329 325
330 bool m_rfmirror; 326 bool m_rfmirror;
diff --git a/drivers/media/dvb-frontends/ds3000.c b/drivers/media/dvb-frontends/ds3000.c
index 5b639087ce45..60a529e3833f 100644
--- a/drivers/media/dvb-frontends/ds3000.c
+++ b/drivers/media/dvb-frontends/ds3000.c
@@ -30,7 +30,6 @@
30#include "ds3000.h" 30#include "ds3000.h"
31 31
32static int debug; 32static int debug;
33static int force_fw_upload;
34 33
35#define dprintk(args...) \ 34#define dprintk(args...) \
36 do { \ 35 do { \
@@ -234,7 +233,6 @@ struct ds3000_state {
234 struct i2c_adapter *i2c; 233 struct i2c_adapter *i2c;
235 const struct ds3000_config *config; 234 const struct ds3000_config *config;
236 struct dvb_frontend frontend; 235 struct dvb_frontend frontend;
237 u8 skip_fw_load;
238 /* previous uncorrected block counter for DVB-S2 */ 236 /* previous uncorrected block counter for DVB-S2 */
239 u16 prevUCBS2; 237 u16 prevUCBS2;
240}; 238};
@@ -397,9 +395,6 @@ static int ds3000_firmware_ondemand(struct dvb_frontend *fe)
397 if (ret < 0) 395 if (ret < 0)
398 return ret; 396 return ret;
399 397
400 if (state->skip_fw_load || !force_fw_upload)
401 return 0; /* Firmware already uploaded, skipping */
402
403 /* Load firmware */ 398 /* Load firmware */
404 /* request the firmware, this will block until someone uploads it */ 399 /* request the firmware, this will block until someone uploads it */
405 printk(KERN_INFO "%s: Waiting for firmware upload (%s)...\n", __func__, 400 printk(KERN_INFO "%s: Waiting for firmware upload (%s)...\n", __func__,
@@ -413,9 +408,6 @@ static int ds3000_firmware_ondemand(struct dvb_frontend *fe)
413 return ret; 408 return ret;
414 } 409 }
415 410
416 /* Make sure we don't recurse back through here during loading */
417 state->skip_fw_load = 1;
418
419 ret = ds3000_load_firmware(fe, fw); 411 ret = ds3000_load_firmware(fe, fw);
420 if (ret) 412 if (ret)
421 printk("%s: Writing firmware to device failed\n", __func__); 413 printk("%s: Writing firmware to device failed\n", __func__);
@@ -425,9 +417,6 @@ static int ds3000_firmware_ondemand(struct dvb_frontend *fe)
425 dprintk("%s: Firmware upload %s\n", __func__, 417 dprintk("%s: Firmware upload %s\n", __func__,
426 ret == 0 ? "complete" : "failed"); 418 ret == 0 ? "complete" : "failed");
427 419
428 /* Ensure firmware is always loaded if required */
429 state->skip_fw_load = 0;
430
431 return ret; 420 return ret;
432} 421}
433 422
@@ -1309,10 +1298,8 @@ static struct dvb_frontend_ops ds3000_ops = {
1309module_param(debug, int, 0644); 1298module_param(debug, int, 0644);
1310MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); 1299MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)");
1311 1300
1312module_param(force_fw_upload, int, 0644);
1313MODULE_PARM_DESC(force_fw_upload, "Force firmware upload (default:0)");
1314
1315MODULE_DESCRIPTION("DVB Frontend module for Montage Technology " 1301MODULE_DESCRIPTION("DVB Frontend module for Montage Technology "
1316 "DS3000/TS2020 hardware"); 1302 "DS3000/TS2020 hardware");
1317MODULE_AUTHOR("Konstantin Dimitrov"); 1303MODULE_AUTHOR("Konstantin Dimitrov");
1318MODULE_LICENSE("GPL"); 1304MODULE_LICENSE("GPL");
1305MODULE_FIRMWARE(DS3000_DEFAULT_FIRMWARE);
diff --git a/drivers/media/dvb-frontends/l64781.c b/drivers/media/dvb-frontends/l64781.c
index 36fcf559e361..ddf866c46f8b 100644
--- a/drivers/media/dvb-frontends/l64781.c
+++ b/drivers/media/dvb-frontends/l64781.c
@@ -180,11 +180,11 @@ static int apply_frontend_param(struct dvb_frontend *fe)
180 p->transmission_mode != TRANSMISSION_MODE_8K) 180 p->transmission_mode != TRANSMISSION_MODE_8K)
181 return -EINVAL; 181 return -EINVAL;
182 182
183 if (p->guard_interval < GUARD_INTERVAL_1_32 || 183 if ((int)p->guard_interval < GUARD_INTERVAL_1_32 ||
184 p->guard_interval > GUARD_INTERVAL_1_4) 184 p->guard_interval > GUARD_INTERVAL_1_4)
185 return -EINVAL; 185 return -EINVAL;
186 186
187 if (p->hierarchy < HIERARCHY_NONE || 187 if ((int)p->hierarchy < HIERARCHY_NONE ||
188 p->hierarchy > HIERARCHY_4) 188 p->hierarchy > HIERARCHY_4)
189 return -EINVAL; 189 return -EINVAL;
190 190
diff --git a/drivers/media/dvb-frontends/mt312.c b/drivers/media/dvb-frontends/mt312.c
index e20bf13aa860..ec388c1d6913 100644
--- a/drivers/media/dvb-frontends/mt312.c
+++ b/drivers/media/dvb-frontends/mt312.c
@@ -549,7 +549,7 @@ static int mt312_set_frontend(struct dvb_frontend *fe)
549 || (p->frequency > fe->ops.info.frequency_max)) 549 || (p->frequency > fe->ops.info.frequency_max))
550 return -EINVAL; 550 return -EINVAL;
551 551
552 if ((p->inversion < INVERSION_OFF) 552 if (((int)p->inversion < INVERSION_OFF)
553 || (p->inversion > INVERSION_ON)) 553 || (p->inversion > INVERSION_ON))
554 return -EINVAL; 554 return -EINVAL;
555 555
@@ -557,7 +557,7 @@ static int mt312_set_frontend(struct dvb_frontend *fe)
557 || (p->symbol_rate > fe->ops.info.symbol_rate_max)) 557 || (p->symbol_rate > fe->ops.info.symbol_rate_max))
558 return -EINVAL; 558 return -EINVAL;
559 559
560 if ((p->fec_inner < FEC_NONE) 560 if (((int)p->fec_inner < FEC_NONE)
561 || (p->fec_inner > FEC_AUTO)) 561 || (p->fec_inner > FEC_AUTO))
562 return -EINVAL; 562 return -EINVAL;
563 563
diff --git a/drivers/media/dvb-frontends/rtl2830.c b/drivers/media/dvb-frontends/rtl2830.c
index b0f6ec03d1eb..362d26d11e82 100644
--- a/drivers/media/dvb-frontends/rtl2830.c
+++ b/drivers/media/dvb-frontends/rtl2830.c
@@ -130,7 +130,7 @@ static int rtl2830_rd_reg(struct rtl2830_priv *priv, u16 reg, u8 *val)
130} 130}
131 131
132/* write single register with mask */ 132/* write single register with mask */
133int rtl2830_wr_reg_mask(struct rtl2830_priv *priv, u16 reg, u8 val, u8 mask) 133static int rtl2830_wr_reg_mask(struct rtl2830_priv *priv, u16 reg, u8 val, u8 mask)
134{ 134{
135 int ret; 135 int ret;
136 u8 tmp; 136 u8 tmp;
@@ -150,7 +150,7 @@ int rtl2830_wr_reg_mask(struct rtl2830_priv *priv, u16 reg, u8 val, u8 mask)
150} 150}
151 151
152/* read single register with mask */ 152/* read single register with mask */
153int rtl2830_rd_reg_mask(struct rtl2830_priv *priv, u16 reg, u8 *val, u8 mask) 153static int rtl2830_rd_reg_mask(struct rtl2830_priv *priv, u16 reg, u8 *val, u8 mask)
154{ 154{
155 int ret, i; 155 int ret, i;
156 u8 tmp; 156 u8 tmp;
@@ -256,7 +256,7 @@ static int rtl2830_sleep(struct dvb_frontend *fe)
256 return 0; 256 return 0;
257} 257}
258 258
259int rtl2830_get_tune_settings(struct dvb_frontend *fe, 259static int rtl2830_get_tune_settings(struct dvb_frontend *fe,
260 struct dvb_frontend_tune_settings *s) 260 struct dvb_frontend_tune_settings *s)
261{ 261{
262 s->min_delay_ms = 500; 262 s->min_delay_ms = 500;
diff --git a/drivers/media/dvb-frontends/rtl2832.c b/drivers/media/dvb-frontends/rtl2832.c
index 80c8e5f1182f..73887690b046 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -265,7 +265,7 @@ static int rtl2832_rd_reg(struct rtl2832_priv *priv, u8 reg, u8 page, u8 *val)
265 return rtl2832_rd_regs(priv, reg, page, val, 1); 265 return rtl2832_rd_regs(priv, reg, page, val, 1);
266} 266}
267 267
268int rtl2832_rd_demod_reg(struct rtl2832_priv *priv, int reg, u32 *val) 268static int rtl2832_rd_demod_reg(struct rtl2832_priv *priv, int reg, u32 *val)
269{ 269{
270 int ret; 270 int ret;
271 271
@@ -305,7 +305,7 @@ err:
305 305
306} 306}
307 307
308int rtl2832_wr_demod_reg(struct rtl2832_priv *priv, int reg, u32 val) 308static int rtl2832_wr_demod_reg(struct rtl2832_priv *priv, int reg, u32 val)
309{ 309{
310 int ret, i; 310 int ret, i;
311 u8 len; 311 u8 len;
@@ -510,7 +510,7 @@ static int rtl2832_sleep(struct dvb_frontend *fe)
510 return 0; 510 return 0;
511} 511}
512 512
513int rtl2832_get_tune_settings(struct dvb_frontend *fe, 513static int rtl2832_get_tune_settings(struct dvb_frontend *fe,
514 struct dvb_frontend_tune_settings *s) 514 struct dvb_frontend_tune_settings *s)
515{ 515{
516 struct rtl2832_priv *priv = fe->demodulator_priv; 516 struct rtl2832_priv *priv = fe->demodulator_priv;
diff --git a/drivers/media/dvb-frontends/stb0899_drv.c b/drivers/media/dvb-frontends/stb0899_drv.c
index 79e29de87fb7..cc278b3d6d5a 100644
--- a/drivers/media/dvb-frontends/stb0899_drv.c
+++ b/drivers/media/dvb-frontends/stb0899_drv.c
@@ -1260,7 +1260,7 @@ static inline void CONVERT32(u32 x, char *str)
1260 *str = '\0'; 1260 *str = '\0';
1261} 1261}
1262 1262
1263int stb0899_get_dev_id(struct stb0899_state *state) 1263static int stb0899_get_dev_id(struct stb0899_state *state)
1264{ 1264{
1265 u8 chip_id, release; 1265 u8 chip_id, release;
1266 u16 id; 1266 u16 id;
diff --git a/drivers/media/dvb-frontends/stv0367.c b/drivers/media/dvb-frontends/stv0367.c
index 2a8aaeb1112d..0c8e45949b11 100644
--- a/drivers/media/dvb-frontends/stv0367.c
+++ b/drivers/media/dvb-frontends/stv0367.c
@@ -879,7 +879,8 @@ static u8 stv0367_readbits(struct stv0367_state *state, u32 label)
879 return val; 879 return val;
880} 880}
881 881
882u8 stv0367_getbits(u8 reg, u32 label) 882#if 0 /* Currently, unused */
883static u8 stv0367_getbits(u8 reg, u32 label)
883{ 884{
884 u8 mask, pos; 885 u8 mask, pos;
885 886
@@ -887,7 +888,7 @@ u8 stv0367_getbits(u8 reg, u32 label)
887 888
888 return (reg & mask) >> pos; 889 return (reg & mask) >> pos;
889} 890}
890 891#endif
891static int stv0367ter_gate_ctrl(struct dvb_frontend *fe, int enable) 892static int stv0367ter_gate_ctrl(struct dvb_frontend *fe, int enable)
892{ 893{
893 struct stv0367_state *state = fe->demodulator_priv; 894 struct stv0367_state *state = fe->demodulator_priv;
@@ -1263,8 +1264,8 @@ stv0367_ter_signal_type stv0367ter_check_cpamp(struct stv0367_state *state,
1263 return CPAMPStatus; 1264 return CPAMPStatus;
1264} 1265}
1265 1266
1266enum 1267static enum stv0367_ter_signal_type
1267stv0367_ter_signal_type stv0367ter_lock_algo(struct stv0367_state *state) 1268stv0367ter_lock_algo(struct stv0367_state *state)
1268{ 1269{
1269 enum stv0367_ter_signal_type ret_flag; 1270 enum stv0367_ter_signal_type ret_flag;
1270 short int wd, tempo; 1271 short int wd, tempo;
@@ -1528,7 +1529,7 @@ static int stv0367ter_sleep(struct dvb_frontend *fe)
1528 return stv0367ter_standby(fe, 1); 1529 return stv0367ter_standby(fe, 1);
1529} 1530}
1530 1531
1531int stv0367ter_init(struct dvb_frontend *fe) 1532static int stv0367ter_init(struct dvb_frontend *fe)
1532{ 1533{
1533 struct stv0367_state *state = fe->demodulator_priv; 1534 struct stv0367_state *state = fe->demodulator_priv;
1534 struct stv0367ter_state *ter_state = state->ter_state; 1535 struct stv0367ter_state *ter_state = state->ter_state;
@@ -2378,9 +2379,9 @@ static u32 stv0367cab_get_adc_freq(struct dvb_frontend *fe, u32 ExtClk_Hz)
2378 return ADCClk_Hz; 2379 return ADCClk_Hz;
2379} 2380}
2380 2381
2381enum stv0367cab_mod stv0367cab_SetQamSize(struct stv0367_state *state, 2382static enum stv0367cab_mod stv0367cab_SetQamSize(struct stv0367_state *state,
2382 u32 SymbolRate, 2383 u32 SymbolRate,
2383 enum stv0367cab_mod QAMSize) 2384 enum stv0367cab_mod QAMSize)
2384{ 2385{
2385 /* Set QAM size */ 2386 /* Set QAM size */
2386 stv0367_writebits(state, F367CAB_QAM_MODE, QAMSize); 2387 stv0367_writebits(state, F367CAB_QAM_MODE, QAMSize);
@@ -2762,7 +2763,7 @@ static int stv0367cab_sleep(struct dvb_frontend *fe)
2762 return stv0367cab_standby(fe, 1); 2763 return stv0367cab_standby(fe, 1);
2763} 2764}
2764 2765
2765int stv0367cab_init(struct dvb_frontend *fe) 2766static int stv0367cab_init(struct dvb_frontend *fe)
2766{ 2767{
2767 struct stv0367_state *state = fe->demodulator_priv; 2768 struct stv0367_state *state = fe->demodulator_priv;
2768 struct stv0367cab_state *cab_state = state->cab_state; 2769 struct stv0367cab_state *cab_state = state->cab_state;
diff --git a/drivers/media/dvb-frontends/tda10071.c b/drivers/media/dvb-frontends/tda10071.c
index a83bf6802345..16a4bc54dbe7 100644
--- a/drivers/media/dvb-frontends/tda10071.c
+++ b/drivers/media/dvb-frontends/tda10071.c
@@ -96,7 +96,8 @@ static int tda10071_rd_reg(struct tda10071_priv *priv, u8 reg, u8 *val)
96} 96}
97 97
98/* write single register with mask */ 98/* write single register with mask */
99int tda10071_wr_reg_mask(struct tda10071_priv *priv, u8 reg, u8 val, u8 mask) 99static int tda10071_wr_reg_mask(struct tda10071_priv *priv,
100 u8 reg, u8 val, u8 mask)
100{ 101{
101 int ret; 102 int ret;
102 u8 tmp; 103 u8 tmp;
@@ -116,7 +117,8 @@ int tda10071_wr_reg_mask(struct tda10071_priv *priv, u8 reg, u8 val, u8 mask)
116} 117}
117 118
118/* read single register with mask */ 119/* read single register with mask */
119int tda10071_rd_reg_mask(struct tda10071_priv *priv, u8 reg, u8 *val, u8 mask) 120static int tda10071_rd_reg_mask(struct tda10071_priv *priv,
121 u8 reg, u8 *val, u8 mask)
120{ 122{
121 int ret, i; 123 int ret, i;
122 u8 tmp; 124 u8 tmp;
diff --git a/drivers/media/dvb-frontends/tda18271c2dd.c b/drivers/media/dvb-frontends/tda18271c2dd.c
index ad7c72e8f517..d281f77d5c28 100644
--- a/drivers/media/dvb-frontends/tda18271c2dd.c
+++ b/drivers/media/dvb-frontends/tda18271c2dd.c
@@ -32,6 +32,7 @@
32#include <asm/div64.h> 32#include <asm/div64.h>
33 33
34#include "dvb_frontend.h" 34#include "dvb_frontend.h"
35#include "tda18271c2dd.h"
35 36
36struct SStandardParam { 37struct SStandardParam {
37 s32 m_IFFrequency; 38 s32 m_IFFrequency;
diff --git a/drivers/media/firewire/firedtv.h b/drivers/media/firewire/firedtv.h
index 4fdcd8cb7530..c2ba085e0d20 100644
--- a/drivers/media/firewire/firedtv.h
+++ b/drivers/media/firewire/firedtv.h
@@ -13,6 +13,7 @@
13#ifndef _FIREDTV_H 13#ifndef _FIREDTV_H
14#define _FIREDTV_H 14#define _FIREDTV_H
15 15
16#include <linux/time.h>
16#include <linux/dvb/dmx.h> 17#include <linux/dvb/dmx.h>
17#include <linux/dvb/frontend.h> 18#include <linux/dvb/frontend.h>
18#include <linux/list.h> 19#include <linux/list.h>
diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c
index 18a38b38fcb8..df163800c8e1 100644
--- a/drivers/media/i2c/adp1653.c
+++ b/drivers/media/i2c/adp1653.c
@@ -3,10 +3,10 @@
3 * 3 *
4 * Copyright (C) 2008--2011 Nokia Corporation 4 * Copyright (C) 2008--2011 Nokia Corporation
5 * 5 *
6 * Contact: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 6 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 9 * Sakari Ailus <sakari.ailus@iki.fi>
10 * Tuukka Toivonen <tuukkat76@gmail.com> 10 * Tuukka Toivonen <tuukkat76@gmail.com>
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
diff --git a/drivers/media/i2c/adv7183.c b/drivers/media/i2c/adv7183.c
index e1d4c89d7140..10c3c1db4cdd 100644
--- a/drivers/media/i2c/adv7183.c
+++ b/drivers/media/i2c/adv7183.c
@@ -681,18 +681,7 @@ static struct i2c_driver adv7183_driver = {
681 .id_table = adv7183_id, 681 .id_table = adv7183_id,
682}; 682};
683 683
684static __init int adv7183_init(void) 684module_i2c_driver(adv7183_driver);
685{
686 return i2c_add_driver(&adv7183_driver);
687}
688
689static __exit void adv7183_exit(void)
690{
691 i2c_del_driver(&adv7183_driver);
692}
693
694module_init(adv7183_init);
695module_exit(adv7183_exit);
696 685
697MODULE_DESCRIPTION("Analog Devices ADV7183 video decoder driver"); 686MODULE_DESCRIPTION("Analog Devices ADV7183 video decoder driver");
698MODULE_AUTHOR("Scott Jiang <Scott.Jiang.Linux@gmail.com>"); 687MODULE_AUTHOR("Scott Jiang <Scott.Jiang.Linux@gmail.com>");
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 05f8950f6f91..f47555b1000a 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -486,9 +486,19 @@ static inline int edid_read_block(struct v4l2_subdev *sd, unsigned len, u8 *val)
486 struct i2c_client *client = state->i2c_edid; 486 struct i2c_client *client = state->i2c_edid;
487 u8 msgbuf0[1] = { 0 }; 487 u8 msgbuf0[1] = { 0 };
488 u8 msgbuf1[256]; 488 u8 msgbuf1[256];
489 struct i2c_msg msg[2] = { { client->addr, 0, 1, msgbuf0 }, 489 struct i2c_msg msg[2] = {
490 { client->addr, 0 | I2C_M_RD, len, msgbuf1 } 490 {
491 }; 491 .addr = client->addr,
492 .len = 1,
493 .buf = msgbuf0
494 },
495 {
496 .addr = client->addr,
497 .flags = I2C_M_RD,
498 .len = len,
499 .buf = msgbuf1
500 },
501 };
492 502
493 if (i2c_transfer(client->adapter, msg, 2) < 0) 503 if (i2c_transfer(client->adapter, msg, 2) < 0)
494 return -EIO; 504 return -EIO;
diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
index 2cee69e34184..f4149eb4d7b4 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -2065,7 +2065,7 @@ static int cx25840_irq_handler(struct v4l2_subdev *sd, u32 status,
2065#define DIF_BPF_COEFF3435 (0x38c) 2065#define DIF_BPF_COEFF3435 (0x38c)
2066#define DIF_BPF_COEFF36 (0x390) 2066#define DIF_BPF_COEFF36 (0x390)
2067 2067
2068void cx23885_dif_setup(struct i2c_client *client, u32 ifHz) 2068static void cx23885_dif_setup(struct i2c_client *client, u32 ifHz)
2069{ 2069{
2070 u64 pll_freq; 2070 u64 pll_freq;
2071 u32 pll_freq_word; 2071 u32 pll_freq_word;
diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index 04f192a0398a..08ae067b2b6f 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -284,7 +284,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
284{ 284{
285 char *ir_codes = NULL; 285 char *ir_codes = NULL;
286 const char *name = NULL; 286 const char *name = NULL;
287 u64 rc_type = RC_TYPE_UNKNOWN; 287 u64 rc_type = RC_BIT_UNKNOWN;
288 struct IR_i2c *ir; 288 struct IR_i2c *ir;
289 struct rc_dev *rc = NULL; 289 struct rc_dev *rc = NULL;
290 struct i2c_adapter *adap = client->adapter; 290 struct i2c_adapter *adap = client->adapter;
@@ -303,7 +303,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
303 case 0x64: 303 case 0x64:
304 name = "Pixelview"; 304 name = "Pixelview";
305 ir->get_key = get_key_pixelview; 305 ir->get_key = get_key_pixelview;
306 rc_type = RC_TYPE_OTHER; 306 rc_type = RC_BIT_OTHER;
307 ir_codes = RC_MAP_EMPTY; 307 ir_codes = RC_MAP_EMPTY;
308 break; 308 break;
309 case 0x18: 309 case 0x18:
@@ -311,31 +311,31 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
311 case 0x1a: 311 case 0x1a:
312 name = "Hauppauge"; 312 name = "Hauppauge";
313 ir->get_key = get_key_haup; 313 ir->get_key = get_key_haup;
314 rc_type = RC_TYPE_RC5; 314 rc_type = RC_BIT_RC5;
315 ir_codes = RC_MAP_HAUPPAUGE; 315 ir_codes = RC_MAP_HAUPPAUGE;
316 break; 316 break;
317 case 0x30: 317 case 0x30:
318 name = "KNC One"; 318 name = "KNC One";
319 ir->get_key = get_key_knc1; 319 ir->get_key = get_key_knc1;
320 rc_type = RC_TYPE_OTHER; 320 rc_type = RC_BIT_OTHER;
321 ir_codes = RC_MAP_EMPTY; 321 ir_codes = RC_MAP_EMPTY;
322 break; 322 break;
323 case 0x6b: 323 case 0x6b:
324 name = "FusionHDTV"; 324 name = "FusionHDTV";
325 ir->get_key = get_key_fusionhdtv; 325 ir->get_key = get_key_fusionhdtv;
326 rc_type = RC_TYPE_RC5; 326 rc_type = RC_BIT_RC5;
327 ir_codes = RC_MAP_FUSIONHDTV_MCE; 327 ir_codes = RC_MAP_FUSIONHDTV_MCE;
328 break; 328 break;
329 case 0x40: 329 case 0x40:
330 name = "AVerMedia Cardbus remote"; 330 name = "AVerMedia Cardbus remote";
331 ir->get_key = get_key_avermedia_cardbus; 331 ir->get_key = get_key_avermedia_cardbus;
332 rc_type = RC_TYPE_OTHER; 332 rc_type = RC_BIT_OTHER;
333 ir_codes = RC_MAP_AVERMEDIA_CARDBUS; 333 ir_codes = RC_MAP_AVERMEDIA_CARDBUS;
334 break; 334 break;
335 case 0x71: 335 case 0x71:
336 name = "Hauppauge/Zilog Z8"; 336 name = "Hauppauge/Zilog Z8";
337 ir->get_key = get_key_haup_xvr; 337 ir->get_key = get_key_haup_xvr;
338 rc_type = RC_TYPE_RC5; 338 rc_type = RC_BIT_RC5;
339 ir_codes = RC_MAP_HAUPPAUGE; 339 ir_codes = RC_MAP_HAUPPAUGE;
340 break; 340 break;
341 } 341 }
diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
index 49c1b3abb425..2750de634270 100644
--- a/drivers/media/i2c/s5k4ecgx.c
+++ b/drivers/media/i2c/s5k4ecgx.c
@@ -343,7 +343,7 @@ static int s5k4ecgx_load_firmware(struct v4l2_subdev *sd)
343 } 343 }
344 regs_num = le32_to_cpu(get_unaligned_le32(fw->data)); 344 regs_num = le32_to_cpu(get_unaligned_le32(fw->data));
345 345
346 v4l2_dbg(3, debug, sd, "FW: %s size %d register sets %d\n", 346 v4l2_dbg(3, debug, sd, "FW: %s size %zu register sets %d\n",
347 S5K4ECGX_FIRMWARE, fw->size, regs_num); 347 S5K4ECGX_FIRMWARE, fw->size, regs_num);
348 348
349 regs_num++; /* Add header */ 349 regs_num++; /* Add header */
diff --git a/drivers/media/i2c/smiapp-pll.c b/drivers/media/i2c/smiapp-pll.c
index a577614bd84f..d8d5da7c52db 100644
--- a/drivers/media/i2c/smiapp-pll.c
+++ b/drivers/media/i2c/smiapp-pll.c
@@ -4,7 +4,7 @@
4 * Generic driver for SMIA/SMIA++ compliant camera modules 4 * Generic driver for SMIA/SMIA++ compliant camera modules
5 * 5 *
6 * Copyright (C) 2011--2012 Nokia Corporation 6 * Copyright (C) 2011--2012 Nokia Corporation
7 * Contact: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 7 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
@@ -58,7 +58,7 @@ static int bounds_check(struct device *dev, uint32_t val,
58 if (val >= min && val <= max) 58 if (val >= min && val <= max)
59 return 0; 59 return 0;
60 60
61 dev_warn(dev, "%s out of bounds: %d (%d--%d)\n", str, val, min, max); 61 dev_dbg(dev, "%s out of bounds: %d (%d--%d)\n", str, val, min, max);
62 62
63 return -EINVAL; 63 return -EINVAL;
64} 64}
@@ -87,14 +87,14 @@ static void print_pll(struct device *dev, struct smiapp_pll *pll)
87 dev_dbg(dev, "vt_pix_clk_freq_hz \t%d\n", pll->vt_pix_clk_freq_hz); 87 dev_dbg(dev, "vt_pix_clk_freq_hz \t%d\n", pll->vt_pix_clk_freq_hz);
88} 88}
89 89
90int smiapp_pll_calculate(struct device *dev, struct smiapp_pll_limits *limits, 90static int __smiapp_pll_calculate(struct device *dev,
91 struct smiapp_pll *pll) 91 const struct smiapp_pll_limits *limits,
92 struct smiapp_pll *pll, uint32_t mul,
93 uint32_t div, uint32_t lane_op_clock_ratio)
92{ 94{
93 uint32_t sys_div; 95 uint32_t sys_div;
94 uint32_t best_pix_div = INT_MAX >> 1; 96 uint32_t best_pix_div = INT_MAX >> 1;
95 uint32_t vt_op_binning_div; 97 uint32_t vt_op_binning_div;
96 uint32_t lane_op_clock_ratio;
97 uint32_t mul, div;
98 uint32_t more_mul_min, more_mul_max; 98 uint32_t more_mul_min, more_mul_max;
99 uint32_t more_mul_factor; 99 uint32_t more_mul_factor;
100 uint32_t min_vt_div, max_vt_div, vt_div; 100 uint32_t min_vt_div, max_vt_div, vt_div;
@@ -102,54 +102,6 @@ int smiapp_pll_calculate(struct device *dev, struct smiapp_pll_limits *limits,
102 unsigned int i; 102 unsigned int i;
103 int rval; 103 int rval;
104 104
105 if (pll->flags & SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE)
106 lane_op_clock_ratio = pll->lanes;
107 else
108 lane_op_clock_ratio = 1;
109 dev_dbg(dev, "lane_op_clock_ratio: %d\n", lane_op_clock_ratio);
110
111 dev_dbg(dev, "binning: %dx%d\n", pll->binning_horizontal,
112 pll->binning_vertical);
113
114 /* CSI transfers 2 bits per clock per lane; thus times 2 */
115 pll->pll_op_clk_freq_hz = pll->link_freq * 2
116 * (pll->lanes / lane_op_clock_ratio);
117
118 /* Figure out limits for pre-pll divider based on extclk */
119 dev_dbg(dev, "min / max pre_pll_clk_div: %d / %d\n",
120 limits->min_pre_pll_clk_div, limits->max_pre_pll_clk_div);
121 limits->max_pre_pll_clk_div =
122 min_t(uint16_t, limits->max_pre_pll_clk_div,
123 clk_div_even(pll->ext_clk_freq_hz /
124 limits->min_pll_ip_freq_hz));
125 limits->min_pre_pll_clk_div =
126 max_t(uint16_t, limits->min_pre_pll_clk_div,
127 clk_div_even_up(
128 DIV_ROUND_UP(pll->ext_clk_freq_hz,
129 limits->max_pll_ip_freq_hz)));
130 dev_dbg(dev, "pre-pll check: min / max pre_pll_clk_div: %d / %d\n",
131 limits->min_pre_pll_clk_div, limits->max_pre_pll_clk_div);
132
133 i = gcd(pll->pll_op_clk_freq_hz, pll->ext_clk_freq_hz);
134 mul = div_u64(pll->pll_op_clk_freq_hz, i);
135 div = pll->ext_clk_freq_hz / i;
136 dev_dbg(dev, "mul %d / div %d\n", mul, div);
137
138 limits->min_pre_pll_clk_div =
139 max_t(uint16_t, limits->min_pre_pll_clk_div,
140 clk_div_even_up(
141 DIV_ROUND_UP(mul * pll->ext_clk_freq_hz,
142 limits->max_pll_op_freq_hz)));
143 dev_dbg(dev, "pll_op check: min / max pre_pll_clk_div: %d / %d\n",
144 limits->min_pre_pll_clk_div, limits->max_pre_pll_clk_div);
145
146 if (limits->min_pre_pll_clk_div > limits->max_pre_pll_clk_div) {
147 dev_err(dev, "unable to compute pre_pll divisor\n");
148 return -EINVAL;
149 }
150
151 pll->pre_pll_clk_div = limits->min_pre_pll_clk_div;
152
153 /* 105 /*
154 * Get pre_pll_clk_div so that our pll_op_clk_freq_hz won't be 106 * Get pre_pll_clk_div so that our pll_op_clk_freq_hz won't be
155 * too high. 107 * too high.
@@ -162,7 +114,7 @@ int smiapp_pll_calculate(struct device *dev, struct smiapp_pll_limits *limits,
162 more_mul_max); 114 more_mul_max);
163 /* Don't go above max pll op frequency. */ 115 /* Don't go above max pll op frequency. */
164 more_mul_max = 116 more_mul_max =
165 min_t(int, 117 min_t(uint32_t,
166 more_mul_max, 118 more_mul_max,
167 limits->max_pll_op_freq_hz 119 limits->max_pll_op_freq_hz
168 / (pll->ext_clk_freq_hz / pll->pre_pll_clk_div * mul)); 120 / (pll->ext_clk_freq_hz / pll->pre_pll_clk_div * mul));
@@ -170,7 +122,7 @@ int smiapp_pll_calculate(struct device *dev, struct smiapp_pll_limits *limits,
170 more_mul_max); 122 more_mul_max);
171 /* Don't go above the division capability of op sys clock divider. */ 123 /* Don't go above the division capability of op sys clock divider. */
172 more_mul_max = min(more_mul_max, 124 more_mul_max = min(more_mul_max,
173 limits->max_op_sys_clk_div * pll->pre_pll_clk_div 125 limits->op.max_sys_clk_div * pll->pre_pll_clk_div
174 / div); 126 / div);
175 dev_dbg(dev, "more_mul_max: max_op_sys_clk_div check: %d\n", 127 dev_dbg(dev, "more_mul_max: max_op_sys_clk_div check: %d\n",
176 more_mul_max); 128 more_mul_max);
@@ -193,14 +145,14 @@ int smiapp_pll_calculate(struct device *dev, struct smiapp_pll_limits *limits,
193 more_mul_min); 145 more_mul_min);
194 146
195 if (more_mul_min > more_mul_max) { 147 if (more_mul_min > more_mul_max) {
196 dev_warn(dev, 148 dev_dbg(dev,
197 "unable to compute more_mul_min and more_mul_max"); 149 "unable to compute more_mul_min and more_mul_max\n");
198 return -EINVAL; 150 return -EINVAL;
199 } 151 }
200 152
201 more_mul_factor = lcm(div, pll->pre_pll_clk_div) / div; 153 more_mul_factor = lcm(div, pll->pre_pll_clk_div) / div;
202 dev_dbg(dev, "more_mul_factor: %d\n", more_mul_factor); 154 dev_dbg(dev, "more_mul_factor: %d\n", more_mul_factor);
203 more_mul_factor = lcm(more_mul_factor, limits->min_op_sys_clk_div); 155 more_mul_factor = lcm(more_mul_factor, limits->op.min_sys_clk_div);
204 dev_dbg(dev, "more_mul_factor: min_op_sys_clk_div: %d\n", 156 dev_dbg(dev, "more_mul_factor: min_op_sys_clk_div: %d\n",
205 more_mul_factor); 157 more_mul_factor);
206 i = roundup(more_mul_min, more_mul_factor); 158 i = roundup(more_mul_min, more_mul_factor);
@@ -209,7 +161,7 @@ int smiapp_pll_calculate(struct device *dev, struct smiapp_pll_limits *limits,
209 161
210 dev_dbg(dev, "final more_mul: %d\n", i); 162 dev_dbg(dev, "final more_mul: %d\n", i);
211 if (i > more_mul_max) { 163 if (i > more_mul_max) {
212 dev_warn(dev, "final more_mul is bad, max %d", more_mul_max); 164 dev_dbg(dev, "final more_mul is bad, max %d\n", more_mul_max);
213 return -EINVAL; 165 return -EINVAL;
214 } 166 }
215 167
@@ -268,19 +220,19 @@ int smiapp_pll_calculate(struct device *dev, struct smiapp_pll_limits *limits,
268 dev_dbg(dev, "min_vt_div: %d\n", min_vt_div); 220 dev_dbg(dev, "min_vt_div: %d\n", min_vt_div);
269 min_vt_div = max(min_vt_div, 221 min_vt_div = max(min_vt_div,
270 DIV_ROUND_UP(pll->pll_op_clk_freq_hz, 222 DIV_ROUND_UP(pll->pll_op_clk_freq_hz,
271 limits->max_vt_pix_clk_freq_hz)); 223 limits->vt.max_pix_clk_freq_hz));
272 dev_dbg(dev, "min_vt_div: max_vt_pix_clk_freq_hz: %d\n", 224 dev_dbg(dev, "min_vt_div: max_vt_pix_clk_freq_hz: %d\n",
273 min_vt_div); 225 min_vt_div);
274 min_vt_div = max_t(uint32_t, min_vt_div, 226 min_vt_div = max_t(uint32_t, min_vt_div,
275 limits->min_vt_pix_clk_div 227 limits->vt.min_pix_clk_div
276 * limits->min_vt_sys_clk_div); 228 * limits->vt.min_sys_clk_div);
277 dev_dbg(dev, "min_vt_div: min_vt_clk_div: %d\n", min_vt_div); 229 dev_dbg(dev, "min_vt_div: min_vt_clk_div: %d\n", min_vt_div);
278 230
279 max_vt_div = limits->max_vt_sys_clk_div * limits->max_vt_pix_clk_div; 231 max_vt_div = limits->vt.max_sys_clk_div * limits->vt.max_pix_clk_div;
280 dev_dbg(dev, "max_vt_div: %d\n", max_vt_div); 232 dev_dbg(dev, "max_vt_div: %d\n", max_vt_div);
281 max_vt_div = min(max_vt_div, 233 max_vt_div = min(max_vt_div,
282 DIV_ROUND_UP(pll->pll_op_clk_freq_hz, 234 DIV_ROUND_UP(pll->pll_op_clk_freq_hz,
283 limits->min_vt_pix_clk_freq_hz)); 235 limits->vt.min_pix_clk_freq_hz));
284 dev_dbg(dev, "max_vt_div: min_vt_pix_clk_freq_hz: %d\n", 236 dev_dbg(dev, "max_vt_div: min_vt_pix_clk_freq_hz: %d\n",
285 max_vt_div); 237 max_vt_div);
286 238
@@ -288,28 +240,28 @@ int smiapp_pll_calculate(struct device *dev, struct smiapp_pll_limits *limits,
288 * Find limitsits for sys_clk_div. Not all values are possible 240 * Find limitsits for sys_clk_div. Not all values are possible
289 * with all values of pix_clk_div. 241 * with all values of pix_clk_div.
290 */ 242 */
291 min_sys_div = limits->min_vt_sys_clk_div; 243 min_sys_div = limits->vt.min_sys_clk_div;
292 dev_dbg(dev, "min_sys_div: %d\n", min_sys_div); 244 dev_dbg(dev, "min_sys_div: %d\n", min_sys_div);
293 min_sys_div = max(min_sys_div, 245 min_sys_div = max(min_sys_div,
294 DIV_ROUND_UP(min_vt_div, 246 DIV_ROUND_UP(min_vt_div,
295 limits->max_vt_pix_clk_div)); 247 limits->vt.max_pix_clk_div));
296 dev_dbg(dev, "min_sys_div: max_vt_pix_clk_div: %d\n", min_sys_div); 248 dev_dbg(dev, "min_sys_div: max_vt_pix_clk_div: %d\n", min_sys_div);
297 min_sys_div = max(min_sys_div, 249 min_sys_div = max(min_sys_div,
298 pll->pll_op_clk_freq_hz 250 pll->pll_op_clk_freq_hz
299 / limits->max_vt_sys_clk_freq_hz); 251 / limits->vt.max_sys_clk_freq_hz);
300 dev_dbg(dev, "min_sys_div: max_pll_op_clk_freq_hz: %d\n", min_sys_div); 252 dev_dbg(dev, "min_sys_div: max_pll_op_clk_freq_hz: %d\n", min_sys_div);
301 min_sys_div = clk_div_even_up(min_sys_div); 253 min_sys_div = clk_div_even_up(min_sys_div);
302 dev_dbg(dev, "min_sys_div: one or even: %d\n", min_sys_div); 254 dev_dbg(dev, "min_sys_div: one or even: %d\n", min_sys_div);
303 255
304 max_sys_div = limits->max_vt_sys_clk_div; 256 max_sys_div = limits->vt.max_sys_clk_div;
305 dev_dbg(dev, "max_sys_div: %d\n", max_sys_div); 257 dev_dbg(dev, "max_sys_div: %d\n", max_sys_div);
306 max_sys_div = min(max_sys_div, 258 max_sys_div = min(max_sys_div,
307 DIV_ROUND_UP(max_vt_div, 259 DIV_ROUND_UP(max_vt_div,
308 limits->min_vt_pix_clk_div)); 260 limits->vt.min_pix_clk_div));
309 dev_dbg(dev, "max_sys_div: min_vt_pix_clk_div: %d\n", max_sys_div); 261 dev_dbg(dev, "max_sys_div: min_vt_pix_clk_div: %d\n", max_sys_div);
310 max_sys_div = min(max_sys_div, 262 max_sys_div = min(max_sys_div,
311 DIV_ROUND_UP(pll->pll_op_clk_freq_hz, 263 DIV_ROUND_UP(pll->pll_op_clk_freq_hz,
312 limits->min_vt_pix_clk_freq_hz)); 264 limits->vt.min_pix_clk_freq_hz));
313 dev_dbg(dev, "max_sys_div: min_vt_pix_clk_freq_hz: %d\n", max_sys_div); 265 dev_dbg(dev, "max_sys_div: min_vt_pix_clk_freq_hz: %d\n", max_sys_div);
314 266
315 /* 267 /*
@@ -322,15 +274,15 @@ int smiapp_pll_calculate(struct device *dev, struct smiapp_pll_limits *limits,
322 for (sys_div = min_sys_div; 274 for (sys_div = min_sys_div;
323 sys_div <= max_sys_div; 275 sys_div <= max_sys_div;
324 sys_div += 2 - (sys_div & 1)) { 276 sys_div += 2 - (sys_div & 1)) {
325 int pix_div = DIV_ROUND_UP(vt_div, sys_div); 277 uint16_t pix_div = DIV_ROUND_UP(vt_div, sys_div);
326 278
327 if (pix_div < limits->min_vt_pix_clk_div 279 if (pix_div < limits->vt.min_pix_clk_div
328 || pix_div > limits->max_vt_pix_clk_div) { 280 || pix_div > limits->vt.max_pix_clk_div) {
329 dev_dbg(dev, 281 dev_dbg(dev,
330 "pix_div %d too small or too big (%d--%d)\n", 282 "pix_div %d too small or too big (%d--%d)\n",
331 pix_div, 283 pix_div,
332 limits->min_vt_pix_clk_div, 284 limits->vt.min_pix_clk_div,
333 limits->max_vt_pix_clk_div); 285 limits->vt.max_pix_clk_div);
334 continue; 286 continue;
335 } 287 }
336 288
@@ -354,16 +306,10 @@ int smiapp_pll_calculate(struct device *dev, struct smiapp_pll_limits *limits,
354 pll->pixel_rate_csi = 306 pll->pixel_rate_csi =
355 pll->op_pix_clk_freq_hz * lane_op_clock_ratio; 307 pll->op_pix_clk_freq_hz * lane_op_clock_ratio;
356 308
357 print_pll(dev, pll); 309 rval = bounds_check(dev, pll->pll_ip_clk_freq_hz,
358 310 limits->min_pll_ip_freq_hz,
359 rval = bounds_check(dev, pll->pre_pll_clk_div, 311 limits->max_pll_ip_freq_hz,
360 limits->min_pre_pll_clk_div, 312 "pll_ip_clk_freq_hz");
361 limits->max_pre_pll_clk_div, "pre_pll_clk_div");
362 if (!rval)
363 rval = bounds_check(
364 dev, pll->pll_ip_clk_freq_hz,
365 limits->min_pll_ip_freq_hz, limits->max_pll_ip_freq_hz,
366 "pll_ip_clk_freq_hz");
367 if (!rval) 313 if (!rval)
368 rval = bounds_check( 314 rval = bounds_check(
369 dev, pll->pll_multiplier, 315 dev, pll->pll_multiplier,
@@ -377,42 +323,121 @@ int smiapp_pll_calculate(struct device *dev, struct smiapp_pll_limits *limits,
377 if (!rval) 323 if (!rval)
378 rval = bounds_check( 324 rval = bounds_check(
379 dev, pll->op_sys_clk_div, 325 dev, pll->op_sys_clk_div,
380 limits->min_op_sys_clk_div, limits->max_op_sys_clk_div, 326 limits->op.min_sys_clk_div, limits->op.max_sys_clk_div,
381 "op_sys_clk_div"); 327 "op_sys_clk_div");
382 if (!rval) 328 if (!rval)
383 rval = bounds_check( 329 rval = bounds_check(
384 dev, pll->op_pix_clk_div, 330 dev, pll->op_pix_clk_div,
385 limits->min_op_pix_clk_div, limits->max_op_pix_clk_div, 331 limits->op.min_pix_clk_div, limits->op.max_pix_clk_div,
386 "op_pix_clk_div"); 332 "op_pix_clk_div");
387 if (!rval) 333 if (!rval)
388 rval = bounds_check( 334 rval = bounds_check(
389 dev, pll->op_sys_clk_freq_hz, 335 dev, pll->op_sys_clk_freq_hz,
390 limits->min_op_sys_clk_freq_hz, 336 limits->op.min_sys_clk_freq_hz,
391 limits->max_op_sys_clk_freq_hz, 337 limits->op.max_sys_clk_freq_hz,
392 "op_sys_clk_freq_hz"); 338 "op_sys_clk_freq_hz");
393 if (!rval) 339 if (!rval)
394 rval = bounds_check( 340 rval = bounds_check(
395 dev, pll->op_pix_clk_freq_hz, 341 dev, pll->op_pix_clk_freq_hz,
396 limits->min_op_pix_clk_freq_hz, 342 limits->op.min_pix_clk_freq_hz,
397 limits->max_op_pix_clk_freq_hz, 343 limits->op.max_pix_clk_freq_hz,
398 "op_pix_clk_freq_hz"); 344 "op_pix_clk_freq_hz");
399 if (!rval) 345 if (!rval)
400 rval = bounds_check( 346 rval = bounds_check(
401 dev, pll->vt_sys_clk_freq_hz, 347 dev, pll->vt_sys_clk_freq_hz,
402 limits->min_vt_sys_clk_freq_hz, 348 limits->vt.min_sys_clk_freq_hz,
403 limits->max_vt_sys_clk_freq_hz, 349 limits->vt.max_sys_clk_freq_hz,
404 "vt_sys_clk_freq_hz"); 350 "vt_sys_clk_freq_hz");
405 if (!rval) 351 if (!rval)
406 rval = bounds_check( 352 rval = bounds_check(
407 dev, pll->vt_pix_clk_freq_hz, 353 dev, pll->vt_pix_clk_freq_hz,
408 limits->min_vt_pix_clk_freq_hz, 354 limits->vt.min_pix_clk_freq_hz,
409 limits->max_vt_pix_clk_freq_hz, 355 limits->vt.max_pix_clk_freq_hz,
410 "vt_pix_clk_freq_hz"); 356 "vt_pix_clk_freq_hz");
411 357
412 return rval; 358 return rval;
413} 359}
360
361int smiapp_pll_calculate(struct device *dev,
362 const struct smiapp_pll_limits *limits,
363 struct smiapp_pll *pll)
364{
365 uint16_t min_pre_pll_clk_div;
366 uint16_t max_pre_pll_clk_div;
367 uint32_t lane_op_clock_ratio;
368 uint32_t mul, div;
369 unsigned int i;
370 int rval = -EINVAL;
371
372 if (pll->flags & SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE)
373 lane_op_clock_ratio = pll->csi2.lanes;
374 else
375 lane_op_clock_ratio = 1;
376 dev_dbg(dev, "lane_op_clock_ratio: %d\n", lane_op_clock_ratio);
377
378 dev_dbg(dev, "binning: %dx%d\n", pll->binning_horizontal,
379 pll->binning_vertical);
380
381 switch (pll->bus_type) {
382 case SMIAPP_PLL_BUS_TYPE_CSI2:
383 /* CSI transfers 2 bits per clock per lane; thus times 2 */
384 pll->pll_op_clk_freq_hz = pll->link_freq * 2
385 * (pll->csi2.lanes / lane_op_clock_ratio);
386 break;
387 case SMIAPP_PLL_BUS_TYPE_PARALLEL:
388 pll->pll_op_clk_freq_hz = pll->link_freq * pll->bits_per_pixel
389 / DIV_ROUND_UP(pll->bits_per_pixel,
390 pll->parallel.bus_width);
391 break;
392 default:
393 return -EINVAL;
394 }
395
396 /* Figure out limits for pre-pll divider based on extclk */
397 dev_dbg(dev, "min / max pre_pll_clk_div: %d / %d\n",
398 limits->min_pre_pll_clk_div, limits->max_pre_pll_clk_div);
399 max_pre_pll_clk_div =
400 min_t(uint16_t, limits->max_pre_pll_clk_div,
401 clk_div_even(pll->ext_clk_freq_hz /
402 limits->min_pll_ip_freq_hz));
403 min_pre_pll_clk_div =
404 max_t(uint16_t, limits->min_pre_pll_clk_div,
405 clk_div_even_up(
406 DIV_ROUND_UP(pll->ext_clk_freq_hz,
407 limits->max_pll_ip_freq_hz)));
408 dev_dbg(dev, "pre-pll check: min / max pre_pll_clk_div: %d / %d\n",
409 min_pre_pll_clk_div, max_pre_pll_clk_div);
410
411 i = gcd(pll->pll_op_clk_freq_hz, pll->ext_clk_freq_hz);
412 mul = div_u64(pll->pll_op_clk_freq_hz, i);
413 div = pll->ext_clk_freq_hz / i;
414 dev_dbg(dev, "mul %d / div %d\n", mul, div);
415
416 min_pre_pll_clk_div =
417 max_t(uint16_t, min_pre_pll_clk_div,
418 clk_div_even_up(
419 DIV_ROUND_UP(mul * pll->ext_clk_freq_hz,
420 limits->max_pll_op_freq_hz)));
421 dev_dbg(dev, "pll_op check: min / max pre_pll_clk_div: %d / %d\n",
422 min_pre_pll_clk_div, max_pre_pll_clk_div);
423
424 for (pll->pre_pll_clk_div = min_pre_pll_clk_div;
425 pll->pre_pll_clk_div <= max_pre_pll_clk_div;
426 pll->pre_pll_clk_div += 2 - (pll->pre_pll_clk_div & 1)) {
427 rval = __smiapp_pll_calculate(dev, limits, pll, mul, div,
428 lane_op_clock_ratio);
429 if (rval)
430 continue;
431
432 print_pll(dev, pll);
433 return 0;
434 }
435
436 dev_info(dev, "unable to compute pre_pll divisor\n");
437 return rval;
438}
414EXPORT_SYMBOL_GPL(smiapp_pll_calculate); 439EXPORT_SYMBOL_GPL(smiapp_pll_calculate);
415 440
416MODULE_AUTHOR("Sakari Ailus <sakari.ailus@maxwell.research.nokia.com>"); 441MODULE_AUTHOR("Sakari Ailus <sakari.ailus@iki.fi>");
417MODULE_DESCRIPTION("Generic SMIA/SMIA++ PLL calculator"); 442MODULE_DESCRIPTION("Generic SMIA/SMIA++ PLL calculator");
418MODULE_LICENSE("GPL"); 443MODULE_LICENSE("GPL");
diff --git a/drivers/media/i2c/smiapp-pll.h b/drivers/media/i2c/smiapp-pll.h
index cb2d2db5d02d..a4a649834a18 100644
--- a/drivers/media/i2c/smiapp-pll.h
+++ b/drivers/media/i2c/smiapp-pll.h
@@ -4,7 +4,7 @@
4 * Generic driver for SMIA/SMIA++ compliant camera modules 4 * Generic driver for SMIA/SMIA++ compliant camera modules
5 * 5 *
6 * Copyright (C) 2012 Nokia Corporation 6 * Copyright (C) 2012 Nokia Corporation
7 * Contact: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 7 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
@@ -27,16 +27,34 @@
27 27
28#include <linux/device.h> 28#include <linux/device.h>
29 29
30/* CSI-2 or CCP-2 */
31#define SMIAPP_PLL_BUS_TYPE_CSI2 0x00
32#define SMIAPP_PLL_BUS_TYPE_PARALLEL 0x01
33
34/* op pix clock is for all lanes in total normally */
35#define SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE (1 << 0)
36#define SMIAPP_PLL_FLAG_NO_OP_CLOCKS (1 << 1)
37
30struct smiapp_pll { 38struct smiapp_pll {
31 uint8_t lanes; 39 /* input values */
40 uint8_t bus_type;
41 union {
42 struct {
43 uint8_t lanes;
44 } csi2;
45 struct {
46 uint8_t bus_width;
47 } parallel;
48 };
49 uint8_t flags;
32 uint8_t binning_horizontal; 50 uint8_t binning_horizontal;
33 uint8_t binning_vertical; 51 uint8_t binning_vertical;
34 uint8_t scale_m; 52 uint8_t scale_m;
35 uint8_t scale_n; 53 uint8_t scale_n;
36 uint8_t bits_per_pixel; 54 uint8_t bits_per_pixel;
37 uint16_t flags;
38 uint32_t link_freq; 55 uint32_t link_freq;
39 56
57 /* output values */
40 uint16_t pre_pll_clk_div; 58 uint16_t pre_pll_clk_div;
41 uint16_t pll_multiplier; 59 uint16_t pll_multiplier;
42 uint16_t op_sys_clk_div; 60 uint16_t op_sys_clk_div;
@@ -55,6 +73,17 @@ struct smiapp_pll {
55 uint32_t pixel_rate_csi; 73 uint32_t pixel_rate_csi;
56}; 74};
57 75
76struct smiapp_pll_branch_limits {
77 uint16_t min_sys_clk_div;
78 uint16_t max_sys_clk_div;
79 uint32_t min_sys_clk_freq_hz;
80 uint32_t max_sys_clk_freq_hz;
81 uint16_t min_pix_clk_div;
82 uint16_t max_pix_clk_div;
83 uint32_t min_pix_clk_freq_hz;
84 uint32_t max_pix_clk_freq_hz;
85};
86
58struct smiapp_pll_limits { 87struct smiapp_pll_limits {
59 /* Strict PLL limits */ 88 /* Strict PLL limits */
60 uint32_t min_ext_clk_freq_hz; 89 uint32_t min_ext_clk_freq_hz;
@@ -68,36 +97,18 @@ struct smiapp_pll_limits {
68 uint32_t min_pll_op_freq_hz; 97 uint32_t min_pll_op_freq_hz;
69 uint32_t max_pll_op_freq_hz; 98 uint32_t max_pll_op_freq_hz;
70 99
71 uint16_t min_vt_sys_clk_div; 100 struct smiapp_pll_branch_limits vt;
72 uint16_t max_vt_sys_clk_div; 101 struct smiapp_pll_branch_limits op;
73 uint32_t min_vt_sys_clk_freq_hz;
74 uint32_t max_vt_sys_clk_freq_hz;
75 uint16_t min_vt_pix_clk_div;
76 uint16_t max_vt_pix_clk_div;
77 uint32_t min_vt_pix_clk_freq_hz;
78 uint32_t max_vt_pix_clk_freq_hz;
79
80 uint16_t min_op_sys_clk_div;
81 uint16_t max_op_sys_clk_div;
82 uint32_t min_op_sys_clk_freq_hz;
83 uint32_t max_op_sys_clk_freq_hz;
84 uint16_t min_op_pix_clk_div;
85 uint16_t max_op_pix_clk_div;
86 uint32_t min_op_pix_clk_freq_hz;
87 uint32_t max_op_pix_clk_freq_hz;
88 102
89 /* Other relevant limits */ 103 /* Other relevant limits */
90 uint32_t min_line_length_pck_bin; 104 uint32_t min_line_length_pck_bin;
91 uint32_t min_line_length_pck; 105 uint32_t min_line_length_pck;
92}; 106};
93 107
94/* op pix clock is for all lanes in total normally */
95#define SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE (1 << 0)
96#define SMIAPP_PLL_FLAG_NO_OP_CLOCKS (1 << 1)
97
98struct device; 108struct device;
99 109
100int smiapp_pll_calculate(struct device *dev, struct smiapp_pll_limits *limits, 110int smiapp_pll_calculate(struct device *dev,
111 const struct smiapp_pll_limits *limits,
101 struct smiapp_pll *pll); 112 struct smiapp_pll *pll);
102 113
103#endif /* SMIAPP_PLL_H */ 114#endif /* SMIAPP_PLL_H */
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index e08e588ad24b..83c7ed7ffcc2 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -4,7 +4,7 @@
4 * Generic driver for SMIA/SMIA++ compliant camera modules 4 * Generic driver for SMIA/SMIA++ compliant camera modules
5 * 5 *
6 * Copyright (C) 2010--2012 Nokia Corporation 6 * Copyright (C) 2010--2012 Nokia Corporation
7 * Contact: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 7 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
8 * 8 *
9 * Based on smiapp driver by Vimarsh Zutshi 9 * Based on smiapp driver by Vimarsh Zutshi
10 * Based on jt8ev1.c by Vimarsh Zutshi 10 * Based on jt8ev1.c by Vimarsh Zutshi
@@ -252,23 +252,23 @@ static int smiapp_pll_update(struct smiapp_sensor *sensor)
252 .min_pll_op_freq_hz = sensor->limits[SMIAPP_LIMIT_MIN_PLL_OP_FREQ_HZ], 252 .min_pll_op_freq_hz = sensor->limits[SMIAPP_LIMIT_MIN_PLL_OP_FREQ_HZ],
253 .max_pll_op_freq_hz = sensor->limits[SMIAPP_LIMIT_MAX_PLL_OP_FREQ_HZ], 253 .max_pll_op_freq_hz = sensor->limits[SMIAPP_LIMIT_MAX_PLL_OP_FREQ_HZ],
254 254
255 .min_op_sys_clk_div = sensor->limits[SMIAPP_LIMIT_MIN_OP_SYS_CLK_DIV], 255 .op.min_sys_clk_div = sensor->limits[SMIAPP_LIMIT_MIN_OP_SYS_CLK_DIV],
256 .max_op_sys_clk_div = sensor->limits[SMIAPP_LIMIT_MAX_OP_SYS_CLK_DIV], 256 .op.max_sys_clk_div = sensor->limits[SMIAPP_LIMIT_MAX_OP_SYS_CLK_DIV],
257 .min_op_pix_clk_div = sensor->limits[SMIAPP_LIMIT_MIN_OP_PIX_CLK_DIV], 257 .op.min_pix_clk_div = sensor->limits[SMIAPP_LIMIT_MIN_OP_PIX_CLK_DIV],
258 .max_op_pix_clk_div = sensor->limits[SMIAPP_LIMIT_MAX_OP_PIX_CLK_DIV], 258 .op.max_pix_clk_div = sensor->limits[SMIAPP_LIMIT_MAX_OP_PIX_CLK_DIV],
259 .min_op_sys_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MIN_OP_SYS_CLK_FREQ_HZ], 259 .op.min_sys_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MIN_OP_SYS_CLK_FREQ_HZ],
260 .max_op_sys_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MAX_OP_SYS_CLK_FREQ_HZ], 260 .op.max_sys_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MAX_OP_SYS_CLK_FREQ_HZ],
261 .min_op_pix_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MIN_OP_PIX_CLK_FREQ_HZ], 261 .op.min_pix_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MIN_OP_PIX_CLK_FREQ_HZ],
262 .max_op_pix_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MAX_OP_PIX_CLK_FREQ_HZ], 262 .op.max_pix_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MAX_OP_PIX_CLK_FREQ_HZ],
263 263
264 .min_vt_sys_clk_div = sensor->limits[SMIAPP_LIMIT_MIN_VT_SYS_CLK_DIV], 264 .vt.min_sys_clk_div = sensor->limits[SMIAPP_LIMIT_MIN_VT_SYS_CLK_DIV],
265 .max_vt_sys_clk_div = sensor->limits[SMIAPP_LIMIT_MAX_VT_SYS_CLK_DIV], 265 .vt.max_sys_clk_div = sensor->limits[SMIAPP_LIMIT_MAX_VT_SYS_CLK_DIV],
266 .min_vt_pix_clk_div = sensor->limits[SMIAPP_LIMIT_MIN_VT_PIX_CLK_DIV], 266 .vt.min_pix_clk_div = sensor->limits[SMIAPP_LIMIT_MIN_VT_PIX_CLK_DIV],
267 .max_vt_pix_clk_div = sensor->limits[SMIAPP_LIMIT_MAX_VT_PIX_CLK_DIV], 267 .vt.max_pix_clk_div = sensor->limits[SMIAPP_LIMIT_MAX_VT_PIX_CLK_DIV],
268 .min_vt_sys_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MIN_VT_SYS_CLK_FREQ_HZ], 268 .vt.min_sys_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MIN_VT_SYS_CLK_FREQ_HZ],
269 .max_vt_sys_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MAX_VT_SYS_CLK_FREQ_HZ], 269 .vt.max_sys_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MAX_VT_SYS_CLK_FREQ_HZ],
270 .min_vt_pix_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MIN_VT_PIX_CLK_FREQ_HZ], 270 .vt.min_pix_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MIN_VT_PIX_CLK_FREQ_HZ],
271 .max_vt_pix_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MAX_VT_PIX_CLK_FREQ_HZ], 271 .vt.max_pix_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MAX_VT_PIX_CLK_FREQ_HZ],
272 272
273 .min_line_length_pck_bin = sensor->limits[SMIAPP_LIMIT_MIN_LINE_LENGTH_PCK_BIN], 273 .min_line_length_pck_bin = sensor->limits[SMIAPP_LIMIT_MIN_LINE_LENGTH_PCK_BIN],
274 .min_line_length_pck = sensor->limits[SMIAPP_LIMIT_MIN_LINE_LENGTH_PCK], 274 .min_line_length_pck = sensor->limits[SMIAPP_LIMIT_MIN_LINE_LENGTH_PCK],
@@ -276,11 +276,6 @@ static int smiapp_pll_update(struct smiapp_sensor *sensor)
276 struct smiapp_pll *pll = &sensor->pll; 276 struct smiapp_pll *pll = &sensor->pll;
277 int rval; 277 int rval;
278 278
279 memset(&sensor->pll, 0, sizeof(sensor->pll));
280
281 pll->lanes = sensor->platform_data->lanes;
282 pll->ext_clk_freq_hz = sensor->platform_data->ext_clk;
283
284 if (sensor->minfo.smiapp_profile == SMIAPP_PROFILE_0) { 279 if (sensor->minfo.smiapp_profile == SMIAPP_PROFILE_0) {
285 /* 280 /*
286 * Fill in operational clock divisors limits from the 281 * Fill in operational clock divisors limits from the
@@ -288,28 +283,14 @@ static int smiapp_pll_update(struct smiapp_sensor *sensor)
288 * requirements regarding them are essentially the 283 * requirements regarding them are essentially the
289 * same as on VT ones. 284 * same as on VT ones.
290 */ 285 */
291 lim.min_op_sys_clk_div = lim.min_vt_sys_clk_div; 286 lim.op = lim.vt;
292 lim.max_op_sys_clk_div = lim.max_vt_sys_clk_div;
293 lim.min_op_pix_clk_div = lim.min_vt_pix_clk_div;
294 lim.max_op_pix_clk_div = lim.max_vt_pix_clk_div;
295 lim.min_op_sys_clk_freq_hz = lim.min_vt_sys_clk_freq_hz;
296 lim.max_op_sys_clk_freq_hz = lim.max_vt_sys_clk_freq_hz;
297 lim.min_op_pix_clk_freq_hz = lim.min_vt_pix_clk_freq_hz;
298 lim.max_op_pix_clk_freq_hz = lim.max_vt_pix_clk_freq_hz;
299 /* Profile 0 sensors have no separate OP clock branch. */
300 pll->flags |= SMIAPP_PLL_FLAG_NO_OP_CLOCKS;
301 } 287 }
302 288
303 if (smiapp_needs_quirk(sensor,
304 SMIAPP_QUIRK_FLAG_OP_PIX_CLOCK_PER_LANE))
305 pll->flags |= SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE;
306
307 pll->binning_horizontal = sensor->binning_horizontal; 289 pll->binning_horizontal = sensor->binning_horizontal;
308 pll->binning_vertical = sensor->binning_vertical; 290 pll->binning_vertical = sensor->binning_vertical;
309 pll->link_freq = 291 pll->link_freq =
310 sensor->link_freq->qmenu_int[sensor->link_freq->val]; 292 sensor->link_freq->qmenu_int[sensor->link_freq->val];
311 pll->scale_m = sensor->scale_m; 293 pll->scale_m = sensor->scale_m;
312 pll->scale_n = sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN];
313 pll->bits_per_pixel = sensor->csi_format->compressed; 294 pll->bits_per_pixel = sensor->csi_format->compressed;
314 295
315 rval = smiapp_pll_calculate(&client->dev, &lim, pll); 296 rval = smiapp_pll_calculate(&client->dev, &lim, pll);
@@ -1010,7 +991,7 @@ static int smiapp_setup_flash_strobe(struct smiapp_sensor *sensor)
1010 * do not change, or if you do at least know what you're 991 * do not change, or if you do at least know what you're
1011 * doing. :-) 992 * doing. :-)
1012 * 993 *
1013 * Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 2010-10-25 994 * Sakari Ailus <sakari.ailus@iki.fi> 2010-10-25
1014 * 995 *
1015 * flash_strobe_length [us] / 10^6 = (tFlash_strobe_width_ctrl 996 * flash_strobe_length [us] / 10^6 = (tFlash_strobe_width_ctrl
1016 * / EXTCLK freq [Hz]) * flash_strobe_adjustment 997 * / EXTCLK freq [Hz]) * flash_strobe_adjustment
@@ -2369,6 +2350,7 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
2369{ 2350{
2370 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev); 2351 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
2371 struct i2c_client *client = v4l2_get_subdevdata(subdev); 2352 struct i2c_client *client = v4l2_get_subdevdata(subdev);
2353 struct smiapp_pll *pll = &sensor->pll;
2372 struct smiapp_subdev *last = NULL; 2354 struct smiapp_subdev *last = NULL;
2373 u32 tmp; 2355 u32 tmp;
2374 unsigned int i; 2356 unsigned int i;
@@ -2635,6 +2617,18 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
2635 if (rval < 0) 2617 if (rval < 0)
2636 goto out_nvm_release; 2618 goto out_nvm_release;
2637 2619
2620 /* prepare PLL configuration input values */
2621 pll->bus_type = SMIAPP_PLL_BUS_TYPE_CSI2;
2622 pll->csi2.lanes = sensor->platform_data->lanes;
2623 pll->ext_clk_freq_hz = sensor->platform_data->ext_clk;
2624 /* Profile 0 sensors have no separate OP clock branch. */
2625 if (sensor->minfo.smiapp_profile == SMIAPP_PROFILE_0)
2626 pll->flags |= SMIAPP_PLL_FLAG_NO_OP_CLOCKS;
2627 if (smiapp_needs_quirk(sensor,
2628 SMIAPP_QUIRK_FLAG_OP_PIX_CLOCK_PER_LANE))
2629 pll->flags |= SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE;
2630 pll->scale_n = sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN];
2631
2638 rval = smiapp_update_mode(sensor); 2632 rval = smiapp_update_mode(sensor);
2639 if (rval) { 2633 if (rval) {
2640 dev_err(&client->dev, "update mode failed\n"); 2634 dev_err(&client->dev, "update mode failed\n");
@@ -2893,6 +2887,6 @@ static struct i2c_driver smiapp_i2c_driver = {
2893 2887
2894module_i2c_driver(smiapp_i2c_driver); 2888module_i2c_driver(smiapp_i2c_driver);
2895 2889
2896MODULE_AUTHOR("Sakari Ailus <sakari.ailus@maxwell.research.nokia.com>"); 2890MODULE_AUTHOR("Sakari Ailus <sakari.ailus@iki.fi>");
2897MODULE_DESCRIPTION("Generic SMIA/SMIA++ camera module driver"); 2891MODULE_DESCRIPTION("Generic SMIA/SMIA++ camera module driver");
2898MODULE_LICENSE("GPL"); 2892MODULE_LICENSE("GPL");
diff --git a/drivers/media/i2c/smiapp/smiapp-limits.c b/drivers/media/i2c/smiapp/smiapp-limits.c
index fb2f81ad8c3b..847cb235e198 100644
--- a/drivers/media/i2c/smiapp/smiapp-limits.c
+++ b/drivers/media/i2c/smiapp/smiapp-limits.c
@@ -4,7 +4,7 @@
4 * Generic driver for SMIA/SMIA++ compliant camera modules 4 * Generic driver for SMIA/SMIA++ compliant camera modules
5 * 5 *
6 * Copyright (C) 2011--2012 Nokia Corporation 6 * Copyright (C) 2011--2012 Nokia Corporation
7 * Contact: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 7 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
diff --git a/drivers/media/i2c/smiapp/smiapp-limits.h b/drivers/media/i2c/smiapp/smiapp-limits.h
index 9ae765e23ea5..343e9c3827fc 100644
--- a/drivers/media/i2c/smiapp/smiapp-limits.h
+++ b/drivers/media/i2c/smiapp/smiapp-limits.h
@@ -4,7 +4,7 @@
4 * Generic driver for SMIA/SMIA++ compliant camera modules 4 * Generic driver for SMIA/SMIA++ compliant camera modules
5 * 5 *
6 * Copyright (C) 2011--2012 Nokia Corporation 6 * Copyright (C) 2011--2012 Nokia Corporation
7 * Contact: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 7 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
diff --git a/drivers/media/i2c/smiapp/smiapp-quirk.c b/drivers/media/i2c/smiapp/smiapp-quirk.c
index 725cf62836c6..bb8c506e0e3d 100644
--- a/drivers/media/i2c/smiapp/smiapp-quirk.c
+++ b/drivers/media/i2c/smiapp/smiapp-quirk.c
@@ -4,7 +4,7 @@
4 * Generic driver for SMIA/SMIA++ compliant camera modules 4 * Generic driver for SMIA/SMIA++ compliant camera modules
5 * 5 *
6 * Copyright (C) 2011--2012 Nokia Corporation 6 * Copyright (C) 2011--2012 Nokia Corporation
7 * Contact: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 7 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
diff --git a/drivers/media/i2c/smiapp/smiapp-quirk.h b/drivers/media/i2c/smiapp/smiapp-quirk.h
index 86fd3e8bfb0f..504a6d80ced5 100644
--- a/drivers/media/i2c/smiapp/smiapp-quirk.h
+++ b/drivers/media/i2c/smiapp/smiapp-quirk.h
@@ -4,7 +4,7 @@
4 * Generic driver for SMIA/SMIA++ compliant camera modules 4 * Generic driver for SMIA/SMIA++ compliant camera modules
5 * 5 *
6 * Copyright (C) 2011--2012 Nokia Corporation 6 * Copyright (C) 2011--2012 Nokia Corporation
7 * Contact: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 7 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
diff --git a/drivers/media/i2c/smiapp/smiapp-reg-defs.h b/drivers/media/i2c/smiapp/smiapp-reg-defs.h
index defa7c5adebf..3aa0ca948d87 100644
--- a/drivers/media/i2c/smiapp/smiapp-reg-defs.h
+++ b/drivers/media/i2c/smiapp/smiapp-reg-defs.h
@@ -4,7 +4,7 @@
4 * Generic driver for SMIA/SMIA++ compliant camera modules 4 * Generic driver for SMIA/SMIA++ compliant camera modules
5 * 5 *
6 * Copyright (C) 2011--2012 Nokia Corporation 6 * Copyright (C) 2011--2012 Nokia Corporation
7 * Contact: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 7 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
diff --git a/drivers/media/i2c/smiapp/smiapp-reg.h b/drivers/media/i2c/smiapp/smiapp-reg.h
index 54568ca2fe6d..b0dcbb8fa5e2 100644
--- a/drivers/media/i2c/smiapp/smiapp-reg.h
+++ b/drivers/media/i2c/smiapp/smiapp-reg.h
@@ -4,7 +4,7 @@
4 * Generic driver for SMIA/SMIA++ compliant camera modules 4 * Generic driver for SMIA/SMIA++ compliant camera modules
5 * 5 *
6 * Copyright (C) 2011--2012 Nokia Corporation 6 * Copyright (C) 2011--2012 Nokia Corporation
7 * Contact: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 7 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
diff --git a/drivers/media/i2c/smiapp/smiapp-regs.c b/drivers/media/i2c/smiapp/smiapp-regs.c
index 70e0d8db0130..4fac32cfcb3f 100644
--- a/drivers/media/i2c/smiapp/smiapp-regs.c
+++ b/drivers/media/i2c/smiapp/smiapp-regs.c
@@ -4,7 +4,7 @@
4 * Generic driver for SMIA/SMIA++ compliant camera modules 4 * Generic driver for SMIA/SMIA++ compliant camera modules
5 * 5 *
6 * Copyright (C) 2011--2012 Nokia Corporation 6 * Copyright (C) 2011--2012 Nokia Corporation
7 * Contact: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 7 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
diff --git a/drivers/media/i2c/smiapp/smiapp-regs.h b/drivers/media/i2c/smiapp/smiapp-regs.h
index 7f9013b47971..eefc6c84d5fe 100644
--- a/drivers/media/i2c/smiapp/smiapp-regs.h
+++ b/drivers/media/i2c/smiapp/smiapp-regs.h
@@ -4,7 +4,7 @@
4 * Generic driver for SMIA/SMIA++ compliant camera modules 4 * Generic driver for SMIA/SMIA++ compliant camera modules
5 * 5 *
6 * Copyright (C) 2011--2012 Nokia Corporation 6 * Copyright (C) 2011--2012 Nokia Corporation
7 * Contact: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 7 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
diff --git a/drivers/media/i2c/smiapp/smiapp.h b/drivers/media/i2c/smiapp/smiapp.h
index 4182a695ab53..7cc5aae662fd 100644
--- a/drivers/media/i2c/smiapp/smiapp.h
+++ b/drivers/media/i2c/smiapp/smiapp.h
@@ -4,7 +4,7 @@
4 * Generic driver for SMIA/SMIA++ compliant camera modules 4 * Generic driver for SMIA/SMIA++ compliant camera modules
5 * 5 *
6 * Copyright (C) 2010--2012 Nokia Corporation 6 * Copyright (C) 2010--2012 Nokia Corporation
7 * Contact: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 7 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
diff --git a/drivers/media/i2c/soc_camera/mt9v022.c b/drivers/media/i2c/soc_camera/mt9v022.c
index 333ef178d6fb..d40a8858be01 100644
--- a/drivers/media/i2c/soc_camera/mt9v022.c
+++ b/drivers/media/i2c/soc_camera/mt9v022.c
@@ -15,6 +15,7 @@
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/soc_camera.h> 19#include <media/soc_camera.h>
19#include <media/soc_mediabus.h> 20#include <media/soc_mediabus.h>
20#include <media/v4l2-subdev.h> 21#include <media/v4l2-subdev.h>
@@ -50,6 +51,7 @@ MODULE_PARM_DESC(sensor_type, "Sensor type: \"colour\" or \"monochrome\"");
50#define MT9V022_PIXEL_OPERATION_MODE 0x0f 51#define MT9V022_PIXEL_OPERATION_MODE 0x0f
51#define MT9V022_LED_OUT_CONTROL 0x1b 52#define MT9V022_LED_OUT_CONTROL 0x1b
52#define MT9V022_ADC_MODE_CONTROL 0x1c 53#define MT9V022_ADC_MODE_CONTROL 0x1c
54#define MT9V022_REG32 0x20
53#define MT9V022_ANALOG_GAIN 0x35 55#define MT9V022_ANALOG_GAIN 0x35
54#define MT9V022_BLACK_LEVEL_CALIB_CTRL 0x47 56#define MT9V022_BLACK_LEVEL_CALIB_CTRL 0x47
55#define MT9V022_PIXCLK_FV_LV 0x74 57#define MT9V022_PIXCLK_FV_LV 0x74
@@ -71,7 +73,15 @@ MODULE_PARM_DESC(sensor_type, "Sensor type: \"colour\" or \"monochrome\"");
71#define MT9V022_COLUMN_SKIP 1 73#define MT9V022_COLUMN_SKIP 1
72#define MT9V022_ROW_SKIP 4 74#define MT9V022_ROW_SKIP 4
73 75
74#define is_mt9v024(id) (id == 0x1324) 76#define MT9V022_HORIZONTAL_BLANKING_MIN 43
77#define MT9V022_HORIZONTAL_BLANKING_MAX 1023
78#define MT9V022_HORIZONTAL_BLANKING_DEF 94
79#define MT9V022_VERTICAL_BLANKING_MIN 2
80#define MT9V022_VERTICAL_BLANKING_MAX 3000
81#define MT9V022_VERTICAL_BLANKING_DEF 45
82
83#define is_mt9v022_rev3(id) (id == 0x1313)
84#define is_mt9v024(id) (id == 0x1324)
75 85
76/* MT9V022 has only one fixed colorspace per pixelcode */ 86/* MT9V022 has only one fixed colorspace per pixelcode */
77struct mt9v022_datafmt { 87struct mt9v022_datafmt {
@@ -136,6 +146,8 @@ struct mt9v022 {
136 struct v4l2_ctrl *autogain; 146 struct v4l2_ctrl *autogain;
137 struct v4l2_ctrl *gain; 147 struct v4l2_ctrl *gain;
138 }; 148 };
149 struct v4l2_ctrl *hblank;
150 struct v4l2_ctrl *vblank;
139 struct v4l2_rect rect; /* Sensor window */ 151 struct v4l2_rect rect; /* Sensor window */
140 const struct mt9v022_datafmt *fmt; 152 const struct mt9v022_datafmt *fmt;
141 const struct mt9v022_datafmt *fmts; 153 const struct mt9v022_datafmt *fmts;
@@ -143,6 +155,7 @@ struct mt9v022 {
143 int num_fmts; 155 int num_fmts;
144 int model; /* V4L2_IDENT_MT9V022* codes from v4l2-chip-ident.h */ 156 int model; /* V4L2_IDENT_MT9V022* codes from v4l2-chip-ident.h */
145 u16 chip_control; 157 u16 chip_control;
158 u16 chip_version;
146 unsigned short y_skip_top; /* Lines to skip at the top */ 159 unsigned short y_skip_top; /* Lines to skip at the top */
147}; 160};
148 161
@@ -225,12 +238,32 @@ static int mt9v022_s_stream(struct v4l2_subdev *sd, int enable)
225 struct i2c_client *client = v4l2_get_subdevdata(sd); 238 struct i2c_client *client = v4l2_get_subdevdata(sd);
226 struct mt9v022 *mt9v022 = to_mt9v022(client); 239 struct mt9v022 *mt9v022 = to_mt9v022(client);
227 240
228 if (enable) 241 if (enable) {
229 /* Switch to master "normal" mode */ 242 /* Switch to master "normal" mode */
230 mt9v022->chip_control &= ~0x10; 243 mt9v022->chip_control &= ~0x10;
231 else 244 if (is_mt9v022_rev3(mt9v022->chip_version) ||
245 is_mt9v024(mt9v022->chip_version)) {
246 /*
247 * Unset snapshot mode specific settings: clear bit 9
248 * and bit 2 in reg. 0x20 when in normal mode.
249 */
250 if (reg_clear(client, MT9V022_REG32, 0x204))
251 return -EIO;
252 }
253 } else {
232 /* Switch to snapshot mode */ 254 /* Switch to snapshot mode */
233 mt9v022->chip_control |= 0x10; 255 mt9v022->chip_control |= 0x10;
256 if (is_mt9v022_rev3(mt9v022->chip_version) ||
257 is_mt9v024(mt9v022->chip_version)) {
258 /*
259 * Required settings for snapshot mode: set bit 9
260 * (RST enable) and bit 2 (CR enable) in reg. 0x20
261 * See TechNote TN0960 or TN-09-225.
262 */
263 if (reg_set(client, MT9V022_REG32, 0x204))
264 return -EIO;
265 }
266 }
234 267
235 if (reg_write(client, MT9V022_CHIP_CONTROL, mt9v022->chip_control) < 0) 268 if (reg_write(client, MT9V022_CHIP_CONTROL, mt9v022->chip_control) < 0)
236 return -EIO; 269 return -EIO;
@@ -282,11 +315,10 @@ static int mt9v022_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
282 * Default 94, Phytec driver says: 315 * Default 94, Phytec driver says:
283 * "width + horizontal blank >= 660" 316 * "width + horizontal blank >= 660"
284 */ 317 */
285 ret = reg_write(client, MT9V022_HORIZONTAL_BLANKING, 318 ret = v4l2_ctrl_s_ctrl(mt9v022->hblank,
286 rect.width > 660 - 43 ? 43 : 319 rect.width > 660 - 43 ? 43 : 660 - rect.width);
287 660 - rect.width);
288 if (!ret) 320 if (!ret)
289 ret = reg_write(client, MT9V022_VERTICAL_BLANKING, 45); 321 ret = v4l2_ctrl_s_ctrl(mt9v022->vblank, 45);
290 if (!ret) 322 if (!ret)
291 ret = reg_write(client, MT9V022_WINDOW_WIDTH, rect.width); 323 ret = reg_write(client, MT9V022_WINDOW_WIDTH, rect.width);
292 if (!ret) 324 if (!ret)
@@ -509,6 +541,18 @@ static int mt9v022_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
509 range = exp->maximum - exp->minimum; 541 range = exp->maximum - exp->minimum;
510 exp->val = ((data - 1) * range + 239) / 479 + exp->minimum; 542 exp->val = ((data - 1) * range + 239) / 479 + exp->minimum;
511 return 0; 543 return 0;
544 case V4L2_CID_HBLANK:
545 data = reg_read(client, MT9V022_HORIZONTAL_BLANKING);
546 if (data < 0)
547 return -EIO;
548 ctrl->val = data;
549 return 0;
550 case V4L2_CID_VBLANK:
551 data = reg_read(client, MT9V022_VERTICAL_BLANKING);
552 if (data < 0)
553 return -EIO;
554 ctrl->val = data;
555 return 0;
512 } 556 }
513 return -EINVAL; 557 return -EINVAL;
514} 558}
@@ -590,6 +634,16 @@ static int mt9v022_s_ctrl(struct v4l2_ctrl *ctrl)
590 return -EIO; 634 return -EIO;
591 } 635 }
592 return 0; 636 return 0;
637 case V4L2_CID_HBLANK:
638 if (reg_write(client, MT9V022_HORIZONTAL_BLANKING,
639 ctrl->val) < 0)
640 return -EIO;
641 return 0;
642 case V4L2_CID_VBLANK:
643 if (reg_write(client, MT9V022_VERTICAL_BLANKING,
644 ctrl->val) < 0)
645 return -EIO;
646 return 0;
593 } 647 }
594 return -EINVAL; 648 return -EINVAL;
595} 649}
@@ -621,6 +675,8 @@ static int mt9v022_video_probe(struct i2c_client *client)
621 goto ei2c; 675 goto ei2c;
622 } 676 }
623 677
678 mt9v022->chip_version = data;
679
624 mt9v022->reg = is_mt9v024(data) ? &mt9v024_register : 680 mt9v022->reg = is_mt9v024(data) ? &mt9v024_register :
625 &mt9v022_register; 681 &mt9v022_register;
626 682
@@ -819,6 +875,7 @@ static int mt9v022_probe(struct i2c_client *client,
819 struct mt9v022 *mt9v022; 875 struct mt9v022 *mt9v022;
820 struct soc_camera_link *icl = soc_camera_i2c_to_link(client); 876 struct soc_camera_link *icl = soc_camera_i2c_to_link(client);
821 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); 877 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
878 struct mt9v022_platform_data *pdata = icl->priv;
822 int ret; 879 int ret;
823 880
824 if (!icl) { 881 if (!icl) {
@@ -857,10 +914,21 @@ static int mt9v022_probe(struct i2c_client *client,
857 mt9v022->exposure = v4l2_ctrl_new_std(&mt9v022->hdl, &mt9v022_ctrl_ops, 914 mt9v022->exposure = v4l2_ctrl_new_std(&mt9v022->hdl, &mt9v022_ctrl_ops,
858 V4L2_CID_EXPOSURE, 1, 255, 1, 255); 915 V4L2_CID_EXPOSURE, 1, 255, 1, 255);
859 916
917 mt9v022->hblank = v4l2_ctrl_new_std(&mt9v022->hdl, &mt9v022_ctrl_ops,
918 V4L2_CID_HBLANK, MT9V022_HORIZONTAL_BLANKING_MIN,
919 MT9V022_HORIZONTAL_BLANKING_MAX, 1,
920 MT9V022_HORIZONTAL_BLANKING_DEF);
921
922 mt9v022->vblank = v4l2_ctrl_new_std(&mt9v022->hdl, &mt9v022_ctrl_ops,
923 V4L2_CID_VBLANK, MT9V022_VERTICAL_BLANKING_MIN,
924 MT9V022_VERTICAL_BLANKING_MAX, 1,
925 MT9V022_VERTICAL_BLANKING_DEF);
926
860 mt9v022->subdev.ctrl_handler = &mt9v022->hdl; 927 mt9v022->subdev.ctrl_handler = &mt9v022->hdl;
861 if (mt9v022->hdl.error) { 928 if (mt9v022->hdl.error) {
862 int err = mt9v022->hdl.error; 929 int err = mt9v022->hdl.error;
863 930
931 dev_err(&client->dev, "control initialisation err %d\n", err);
864 kfree(mt9v022); 932 kfree(mt9v022);
865 return err; 933 return err;
866 } 934 }
@@ -871,10 +939,10 @@ static int mt9v022_probe(struct i2c_client *client,
871 mt9v022->chip_control = MT9V022_CHIP_CONTROL_DEFAULT; 939 mt9v022->chip_control = MT9V022_CHIP_CONTROL_DEFAULT;
872 940
873 /* 941 /*
874 * MT9V022 _really_ corrupts the first read out line. 942 * On some platforms the first read out line is corrupted.
875 * TODO: verify on i.MX31 943 * Workaround it by skipping if indicated by platform data.
876 */ 944 */
877 mt9v022->y_skip_top = 1; 945 mt9v022->y_skip_top = pdata ? pdata->y_skip_top : 0;
878 mt9v022->rect.left = MT9V022_COLUMN_SKIP; 946 mt9v022->rect.left = MT9V022_COLUMN_SKIP;
879 mt9v022->rect.top = MT9V022_ROW_SKIP; 947 mt9v022->rect.top = MT9V022_ROW_SKIP;
880 mt9v022->rect.width = MT9V022_MAX_WIDTH; 948 mt9v022->rect.width = MT9V022_MAX_WIDTH;
diff --git a/drivers/media/i2c/soc_camera/ov2640.c b/drivers/media/i2c/soc_camera/ov2640.c
index d2d298b6354e..66698a83bda2 100644
--- a/drivers/media/i2c/soc_camera/ov2640.c
+++ b/drivers/media/i2c/soc_camera/ov2640.c
@@ -586,9 +586,20 @@ static const struct regval_list ov2640_format_change_preamble_regs[] = {
586 ENDMARKER, 586 ENDMARKER,
587}; 587};
588 588
589static const struct regval_list ov2640_yuv422_regs[] = { 589static const struct regval_list ov2640_yuyv_regs[] = {
590 { IMAGE_MODE, IMAGE_MODE_YUV422 },
591 { 0xd7, 0x03 },
592 { 0x33, 0xa0 },
593 { 0xe5, 0x1f },
594 { 0xe1, 0x67 },
595 { RESET, 0x00 },
596 { R_BYPASS, R_BYPASS_USE_DSP },
597 ENDMARKER,
598};
599
600static const struct regval_list ov2640_uyvy_regs[] = {
590 { IMAGE_MODE, IMAGE_MODE_LBYTE_FIRST | IMAGE_MODE_YUV422 }, 601 { IMAGE_MODE, IMAGE_MODE_LBYTE_FIRST | IMAGE_MODE_YUV422 },
591 { 0xD7, 0x01 }, 602 { 0xd7, 0x01 },
592 { 0x33, 0xa0 }, 603 { 0x33, 0xa0 },
593 { 0xe1, 0x67 }, 604 { 0xe1, 0x67 },
594 { RESET, 0x00 }, 605 { RESET, 0x00 },
@@ -596,7 +607,15 @@ static const struct regval_list ov2640_yuv422_regs[] = {
596 ENDMARKER, 607 ENDMARKER,
597}; 608};
598 609
599static const struct regval_list ov2640_rgb565_regs[] = { 610static const struct regval_list ov2640_rgb565_be_regs[] = {
611 { IMAGE_MODE, IMAGE_MODE_RGB565 },
612 { 0xd7, 0x03 },
613 { RESET, 0x00 },
614 { R_BYPASS, R_BYPASS_USE_DSP },
615 ENDMARKER,
616};
617
618static const struct regval_list ov2640_rgb565_le_regs[] = {
600 { IMAGE_MODE, IMAGE_MODE_LBYTE_FIRST | IMAGE_MODE_RGB565 }, 619 { IMAGE_MODE, IMAGE_MODE_LBYTE_FIRST | IMAGE_MODE_RGB565 },
601 { 0xd7, 0x03 }, 620 { 0xd7, 0x03 },
602 { RESET, 0x00 }, 621 { RESET, 0x00 },
@@ -605,7 +624,9 @@ static const struct regval_list ov2640_rgb565_regs[] = {
605}; 624};
606 625
607static enum v4l2_mbus_pixelcode ov2640_codes[] = { 626static enum v4l2_mbus_pixelcode ov2640_codes[] = {
627 V4L2_MBUS_FMT_YUYV8_2X8,
608 V4L2_MBUS_FMT_UYVY8_2X8, 628 V4L2_MBUS_FMT_UYVY8_2X8,
629 V4L2_MBUS_FMT_RGB565_2X8_BE,
609 V4L2_MBUS_FMT_RGB565_2X8_LE, 630 V4L2_MBUS_FMT_RGB565_2X8_LE,
610}; 631};
611 632
@@ -787,14 +808,22 @@ static int ov2640_set_params(struct i2c_client *client, u32 *width, u32 *height,
787 /* select format */ 808 /* select format */
788 priv->cfmt_code = 0; 809 priv->cfmt_code = 0;
789 switch (code) { 810 switch (code) {
811 case V4L2_MBUS_FMT_RGB565_2X8_BE:
812 dev_dbg(&client->dev, "%s: Selected cfmt RGB565 BE", __func__);
813 selected_cfmt_regs = ov2640_rgb565_be_regs;
814 break;
790 case V4L2_MBUS_FMT_RGB565_2X8_LE: 815 case V4L2_MBUS_FMT_RGB565_2X8_LE:
791 dev_dbg(&client->dev, "%s: Selected cfmt RGB565", __func__); 816 dev_dbg(&client->dev, "%s: Selected cfmt RGB565 LE", __func__);
792 selected_cfmt_regs = ov2640_rgb565_regs; 817 selected_cfmt_regs = ov2640_rgb565_le_regs;
818 break;
819 case V4L2_MBUS_FMT_YUYV8_2X8:
820 dev_dbg(&client->dev, "%s: Selected cfmt YUYV (YUV422)", __func__);
821 selected_cfmt_regs = ov2640_yuyv_regs;
793 break; 822 break;
794 default: 823 default:
795 case V4L2_MBUS_FMT_UYVY8_2X8: 824 case V4L2_MBUS_FMT_UYVY8_2X8:
796 dev_dbg(&client->dev, "%s: Selected cfmt YUV422", __func__); 825 dev_dbg(&client->dev, "%s: Selected cfmt UYVY", __func__);
797 selected_cfmt_regs = ov2640_yuv422_regs; 826 selected_cfmt_regs = ov2640_uyvy_regs;
798 } 827 }
799 828
800 /* reset hardware */ 829 /* reset hardware */
@@ -859,10 +888,12 @@ static int ov2640_g_fmt(struct v4l2_subdev *sd,
859 mf->code = priv->cfmt_code; 888 mf->code = priv->cfmt_code;
860 889
861 switch (mf->code) { 890 switch (mf->code) {
891 case V4L2_MBUS_FMT_RGB565_2X8_BE:
862 case V4L2_MBUS_FMT_RGB565_2X8_LE: 892 case V4L2_MBUS_FMT_RGB565_2X8_LE:
863 mf->colorspace = V4L2_COLORSPACE_SRGB; 893 mf->colorspace = V4L2_COLORSPACE_SRGB;
864 break; 894 break;
865 default: 895 default:
896 case V4L2_MBUS_FMT_YUYV8_2X8:
866 case V4L2_MBUS_FMT_UYVY8_2X8: 897 case V4L2_MBUS_FMT_UYVY8_2X8:
867 mf->colorspace = V4L2_COLORSPACE_JPEG; 898 mf->colorspace = V4L2_COLORSPACE_JPEG;
868 } 899 }
@@ -879,11 +910,13 @@ static int ov2640_s_fmt(struct v4l2_subdev *sd,
879 910
880 911
881 switch (mf->code) { 912 switch (mf->code) {
913 case V4L2_MBUS_FMT_RGB565_2X8_BE:
882 case V4L2_MBUS_FMT_RGB565_2X8_LE: 914 case V4L2_MBUS_FMT_RGB565_2X8_LE:
883 mf->colorspace = V4L2_COLORSPACE_SRGB; 915 mf->colorspace = V4L2_COLORSPACE_SRGB;
884 break; 916 break;
885 default: 917 default:
886 mf->code = V4L2_MBUS_FMT_UYVY8_2X8; 918 mf->code = V4L2_MBUS_FMT_UYVY8_2X8;
919 case V4L2_MBUS_FMT_YUYV8_2X8:
887 case V4L2_MBUS_FMT_UYVY8_2X8: 920 case V4L2_MBUS_FMT_UYVY8_2X8:
888 mf->colorspace = V4L2_COLORSPACE_JPEG; 921 mf->colorspace = V4L2_COLORSPACE_JPEG;
889 } 922 }
@@ -896,21 +929,21 @@ static int ov2640_s_fmt(struct v4l2_subdev *sd,
896static int ov2640_try_fmt(struct v4l2_subdev *sd, 929static int ov2640_try_fmt(struct v4l2_subdev *sd,
897 struct v4l2_mbus_framefmt *mf) 930 struct v4l2_mbus_framefmt *mf)
898{ 931{
899 const struct ov2640_win_size *win;
900
901 /* 932 /*
902 * select suitable win 933 * select suitable win, but don't store it
903 */ 934 */
904 win = ov2640_select_win(&mf->width, &mf->height); 935 ov2640_select_win(&mf->width, &mf->height);
905 936
906 mf->field = V4L2_FIELD_NONE; 937 mf->field = V4L2_FIELD_NONE;
907 938
908 switch (mf->code) { 939 switch (mf->code) {
940 case V4L2_MBUS_FMT_RGB565_2X8_BE:
909 case V4L2_MBUS_FMT_RGB565_2X8_LE: 941 case V4L2_MBUS_FMT_RGB565_2X8_LE:
910 mf->colorspace = V4L2_COLORSPACE_SRGB; 942 mf->colorspace = V4L2_COLORSPACE_SRGB;
911 break; 943 break;
912 default: 944 default:
913 mf->code = V4L2_MBUS_FMT_UYVY8_2X8; 945 mf->code = V4L2_MBUS_FMT_UYVY8_2X8;
946 case V4L2_MBUS_FMT_YUYV8_2X8:
914 case V4L2_MBUS_FMT_UYVY8_2X8: 947 case V4L2_MBUS_FMT_UYVY8_2X8:
915 mf->colorspace = V4L2_COLORSPACE_JPEG; 948 mf->colorspace = V4L2_COLORSPACE_JPEG;
916 } 949 }
diff --git a/drivers/media/i2c/vs6624.c b/drivers/media/i2c/vs6624.c
index 42ae9dc9c574..f434a19b9bcb 100644
--- a/drivers/media/i2c/vs6624.c
+++ b/drivers/media/i2c/vs6624.c
@@ -910,18 +910,7 @@ static struct i2c_driver vs6624_driver = {
910 .id_table = vs6624_id, 910 .id_table = vs6624_id,
911}; 911};
912 912
913static __init int vs6624_init(void) 913module_i2c_driver(vs6624_driver);
914{
915 return i2c_add_driver(&vs6624_driver);
916}
917
918static __exit void vs6624_exit(void)
919{
920 i2c_del_driver(&vs6624_driver);
921}
922
923module_init(vs6624_init);
924module_exit(vs6624_exit);
925 914
926MODULE_DESCRIPTION("VS6624 sensor driver"); 915MODULE_DESCRIPTION("VS6624 sensor driver");
927MODULE_AUTHOR("Scott Jiang <Scott.Jiang.Linux@gmail.com>"); 916MODULE_AUTHOR("Scott Jiang <Scott.Jiang.Linux@gmail.com>");
diff --git a/drivers/media/mmc/siano/Kconfig b/drivers/media/mmc/siano/Kconfig
index fa62475be3bf..aa05ad3c1ccb 100644
--- a/drivers/media/mmc/siano/Kconfig
+++ b/drivers/media/mmc/siano/Kconfig
@@ -4,7 +4,8 @@
4 4
5config SMS_SDIO_DRV 5config SMS_SDIO_DRV
6 tristate "Siano SMS1xxx based MDTV via SDIO interface" 6 tristate "Siano SMS1xxx based MDTV via SDIO interface"
7 depends on DVB_CORE && RC_CORE && HAS_DMA 7 depends on DVB_CORE && HAS_DMA
8 depends on MMC 8 depends on MMC
9 select MEDIA_COMMON_OPTIONS
9 ---help--- 10 ---help---
10 Choose if you would like to have Siano's support for SDIO interface 11 Choose if you would like to have Siano's support for SDIO interface
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 56c6c77793d7..de6f41f19187 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -200,7 +200,7 @@ static void flush_request_modules(struct bttv *dev)
200} 200}
201#else 201#else
202#define request_modules(dev) 202#define request_modules(dev)
203#define flush_request_modules(dev) 203#define flush_request_modules(dev) do {} while(0)
204#endif /* CONFIG_MODULES */ 204#endif /* CONFIG_MODULES */
205 205
206 206
@@ -301,11 +301,10 @@ const struct bttv_tvnorm bttv_tvnorms[] = {
301 /* totalwidth */ 1135, 301 /* totalwidth */ 1135,
302 /* sqwidth */ 944, 302 /* sqwidth */ 944,
303 /* vdelay */ 0x20, 303 /* vdelay */ 0x20,
304 /* sheight */ 576,
305 /* videostart0 */ 23)
306 /* bt878 (and bt848?) can capture another 304 /* bt878 (and bt848?) can capture another
307 line below active video. */ 305 line below active video. */
308 .cropcap.bounds.height = (576 + 2) + 0x20 - 2, 306 /* sheight */ (576 + 2) + 0x20 - 2,
307 /* videostart0 */ 23)
309 },{ 308 },{
310 .v4l2_id = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR, 309 .v4l2_id = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR,
311 .name = "NTSC", 310 .name = "NTSC",
diff --git a/drivers/media/pci/cx18/cx18-alsa-main.c b/drivers/media/pci/cx18/cx18-alsa-main.c
index 6d2a98246b6d..8e971ff60588 100644
--- a/drivers/media/pci/cx18/cx18-alsa-main.c
+++ b/drivers/media/pci/cx18/cx18-alsa-main.c
@@ -197,7 +197,7 @@ err_exit:
197 return ret; 197 return ret;
198} 198}
199 199
200int cx18_alsa_load(struct cx18 *cx) 200static int __init cx18_alsa_load(struct cx18 *cx)
201{ 201{
202 struct v4l2_device *v4l2_dev = &cx->v4l2_dev; 202 struct v4l2_device *v4l2_dev = &cx->v4l2_dev;
203 struct cx18_stream *s; 203 struct cx18_stream *s;
diff --git a/drivers/media/pci/cx18/cx18-alsa-pcm.c b/drivers/media/pci/cx18/cx18-alsa-pcm.c
index 7a5b84a86bb3..180077c49123 100644
--- a/drivers/media/pci/cx18/cx18-alsa-pcm.c
+++ b/drivers/media/pci/cx18/cx18-alsa-pcm.c
@@ -37,6 +37,7 @@
37#include "cx18-streams.h" 37#include "cx18-streams.h"
38#include "cx18-fileops.h" 38#include "cx18-fileops.h"
39#include "cx18-alsa.h" 39#include "cx18-alsa.h"
40#include "cx18-alsa-pcm.h"
40 41
41static unsigned int pcm_debug; 42static unsigned int pcm_debug;
42module_param(pcm_debug, int, 0644); 43module_param(pcm_debug, int, 0644);
diff --git a/drivers/media/pci/cx18/cx18-i2c.c b/drivers/media/pci/cx18/cx18-i2c.c
index 51609d5c88ce..4908eb7bcf6c 100644
--- a/drivers/media/pci/cx18/cx18-i2c.c
+++ b/drivers/media/pci/cx18/cx18-i2c.c
@@ -98,7 +98,7 @@ static int cx18_i2c_new_ir(struct cx18 *cx, struct i2c_adapter *adap, u32 hw,
98 case CX18_HW_Z8F0811_IR_RX_HAUP: 98 case CX18_HW_Z8F0811_IR_RX_HAUP:
99 init_data->ir_codes = RC_MAP_HAUPPAUGE; 99 init_data->ir_codes = RC_MAP_HAUPPAUGE;
100 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; 100 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
101 init_data->type = RC_TYPE_RC5; 101 init_data->type = RC_BIT_RC5;
102 init_data->name = cx->card_name; 102 init_data->name = cx->card_name;
103 info.platform_data = init_data; 103 info.platform_data = init_data;
104 break; 104 break;
diff --git a/drivers/media/pci/cx18/cx18-streams.c b/drivers/media/pci/cx18/cx18-streams.c
index 72af9b5c2d7d..843c62b2f482 100644
--- a/drivers/media/pci/cx18/cx18-streams.c
+++ b/drivers/media/pci/cx18/cx18-streams.c
@@ -97,7 +97,7 @@ static struct {
97}; 97};
98 98
99 99
100void cx18_dma_free(struct videobuf_queue *q, 100static void cx18_dma_free(struct videobuf_queue *q,
101 struct cx18_stream *s, struct cx18_videobuf_buffer *buf) 101 struct cx18_stream *s, struct cx18_videobuf_buffer *buf)
102{ 102{
103 videobuf_waiton(q, &buf->vb, 0, 0); 103 videobuf_waiton(q, &buf->vb, 0, 0);
diff --git a/drivers/media/pci/cx23885/altera-ci.c b/drivers/media/pci/cx23885/altera-ci.c
index 495781ee4711..2926f7fadccd 100644
--- a/drivers/media/pci/cx23885/altera-ci.c
+++ b/drivers/media/pci/cx23885/altera-ci.c
@@ -263,7 +263,7 @@ static int netup_fpga_op_rw(struct fpga_internal *inter, int addr,
263} 263}
264 264
265/* flag - mem/io, read - read/write */ 265/* flag - mem/io, read - read/write */
266int altera_ci_op_cam(struct dvb_ca_en50221 *en50221, int slot, 266static int altera_ci_op_cam(struct dvb_ca_en50221 *en50221, int slot,
267 u8 flag, u8 read, int addr, u8 val) 267 u8 flag, u8 read, int addr, u8 val)
268{ 268{
269 269
@@ -298,31 +298,32 @@ int altera_ci_op_cam(struct dvb_ca_en50221 *en50221, int slot,
298 return mem; 298 return mem;
299} 299}
300 300
301int altera_ci_read_attribute_mem(struct dvb_ca_en50221 *en50221, 301static int altera_ci_read_attribute_mem(struct dvb_ca_en50221 *en50221,
302 int slot, int addr) 302 int slot, int addr)
303{ 303{
304 return altera_ci_op_cam(en50221, slot, 0, NETUP_CI_FLG_RD, addr, 0); 304 return altera_ci_op_cam(en50221, slot, 0, NETUP_CI_FLG_RD, addr, 0);
305} 305}
306 306
307int altera_ci_write_attribute_mem(struct dvb_ca_en50221 *en50221, 307static int altera_ci_write_attribute_mem(struct dvb_ca_en50221 *en50221,
308 int slot, int addr, u8 data) 308 int slot, int addr, u8 data)
309{ 309{
310 return altera_ci_op_cam(en50221, slot, 0, 0, addr, data); 310 return altera_ci_op_cam(en50221, slot, 0, 0, addr, data);
311} 311}
312 312
313int altera_ci_read_cam_ctl(struct dvb_ca_en50221 *en50221, int slot, u8 addr) 313static int altera_ci_read_cam_ctl(struct dvb_ca_en50221 *en50221,
314 int slot, u8 addr)
314{ 315{
315 return altera_ci_op_cam(en50221, slot, NETUP_CI_FLG_CTL, 316 return altera_ci_op_cam(en50221, slot, NETUP_CI_FLG_CTL,
316 NETUP_CI_FLG_RD, addr, 0); 317 NETUP_CI_FLG_RD, addr, 0);
317} 318}
318 319
319int altera_ci_write_cam_ctl(struct dvb_ca_en50221 *en50221, int slot, 320static int altera_ci_write_cam_ctl(struct dvb_ca_en50221 *en50221, int slot,
320 u8 addr, u8 data) 321 u8 addr, u8 data)
321{ 322{
322 return altera_ci_op_cam(en50221, slot, NETUP_CI_FLG_CTL, 0, addr, data); 323 return altera_ci_op_cam(en50221, slot, NETUP_CI_FLG_CTL, 0, addr, data);
323} 324}
324 325
325int altera_ci_slot_reset(struct dvb_ca_en50221 *en50221, int slot) 326static int altera_ci_slot_reset(struct dvb_ca_en50221 *en50221, int slot)
326{ 327{
327 struct altera_ci_state *state = en50221->data; 328 struct altera_ci_state *state = en50221->data;
328 struct fpga_internal *inter = state->internal; 329 struct fpga_internal *inter = state->internal;
@@ -365,13 +366,13 @@ int altera_ci_slot_reset(struct dvb_ca_en50221 *en50221, int slot)
365 return 0; 366 return 0;
366} 367}
367 368
368int altera_ci_slot_shutdown(struct dvb_ca_en50221 *en50221, int slot) 369static int altera_ci_slot_shutdown(struct dvb_ca_en50221 *en50221, int slot)
369{ 370{
370 /* not implemented */ 371 /* not implemented */
371 return 0; 372 return 0;
372} 373}
373 374
374int altera_ci_slot_ts_ctl(struct dvb_ca_en50221 *en50221, int slot) 375static int altera_ci_slot_ts_ctl(struct dvb_ca_en50221 *en50221, int slot)
375{ 376{
376 struct altera_ci_state *state = en50221->data; 377 struct altera_ci_state *state = en50221->data;
377 struct fpga_internal *inter = state->internal; 378 struct fpga_internal *inter = state->internal;
@@ -448,8 +449,8 @@ int altera_ci_irq(void *dev)
448} 449}
449EXPORT_SYMBOL(altera_ci_irq); 450EXPORT_SYMBOL(altera_ci_irq);
450 451
451int altera_poll_ci_slot_status(struct dvb_ca_en50221 *en50221, int slot, 452static int altera_poll_ci_slot_status(struct dvb_ca_en50221 *en50221,
452 int open) 453 int slot, int open)
453{ 454{
454 struct altera_ci_state *state = en50221->data; 455 struct altera_ci_state *state = en50221->data;
455 456
@@ -459,7 +460,7 @@ int altera_poll_ci_slot_status(struct dvb_ca_en50221 *en50221, int slot,
459 return state->status; 460 return state->status;
460} 461}
461 462
462void altera_hw_filt_release(void *main_dev, int filt_nr) 463static void altera_hw_filt_release(void *main_dev, int filt_nr)
463{ 464{
464 struct fpga_inode *temp_int = find_inode(main_dev); 465 struct fpga_inode *temp_int = find_inode(main_dev);
465 struct netup_hw_pid_filter *pid_filt = NULL; 466 struct netup_hw_pid_filter *pid_filt = NULL;
@@ -581,7 +582,7 @@ static void altera_toggle_fullts_streaming(struct netup_hw_pid_filter *pid_filt,
581 mutex_unlock(&inter->fpga_mutex); 582 mutex_unlock(&inter->fpga_mutex);
582} 583}
583 584
584int altera_pid_feed_control(void *demux_dev, int filt_nr, 585static int altera_pid_feed_control(void *demux_dev, int filt_nr,
585 struct dvb_demux_feed *feed, int onoff) 586 struct dvb_demux_feed *feed, int onoff)
586{ 587{
587 struct fpga_inode *temp_int = find_dinode(demux_dev); 588 struct fpga_inode *temp_int = find_dinode(demux_dev);
@@ -603,41 +604,41 @@ int altera_pid_feed_control(void *demux_dev, int filt_nr,
603} 604}
604EXPORT_SYMBOL(altera_pid_feed_control); 605EXPORT_SYMBOL(altera_pid_feed_control);
605 606
606int altera_ci_start_feed(struct dvb_demux_feed *feed, int num) 607static int altera_ci_start_feed(struct dvb_demux_feed *feed, int num)
607{ 608{
608 altera_pid_feed_control(feed->demux, num, feed, 1); 609 altera_pid_feed_control(feed->demux, num, feed, 1);
609 610
610 return 0; 611 return 0;
611} 612}
612 613
613int altera_ci_stop_feed(struct dvb_demux_feed *feed, int num) 614static int altera_ci_stop_feed(struct dvb_demux_feed *feed, int num)
614{ 615{
615 altera_pid_feed_control(feed->demux, num, feed, 0); 616 altera_pid_feed_control(feed->demux, num, feed, 0);
616 617
617 return 0; 618 return 0;
618} 619}
619 620
620int altera_ci_start_feed_1(struct dvb_demux_feed *feed) 621static int altera_ci_start_feed_1(struct dvb_demux_feed *feed)
621{ 622{
622 return altera_ci_start_feed(feed, 1); 623 return altera_ci_start_feed(feed, 1);
623} 624}
624 625
625int altera_ci_stop_feed_1(struct dvb_demux_feed *feed) 626static int altera_ci_stop_feed_1(struct dvb_demux_feed *feed)
626{ 627{
627 return altera_ci_stop_feed(feed, 1); 628 return altera_ci_stop_feed(feed, 1);
628} 629}
629 630
630int altera_ci_start_feed_2(struct dvb_demux_feed *feed) 631static int altera_ci_start_feed_2(struct dvb_demux_feed *feed)
631{ 632{
632 return altera_ci_start_feed(feed, 2); 633 return altera_ci_start_feed(feed, 2);
633} 634}
634 635
635int altera_ci_stop_feed_2(struct dvb_demux_feed *feed) 636static int altera_ci_stop_feed_2(struct dvb_demux_feed *feed)
636{ 637{
637 return altera_ci_stop_feed(feed, 2); 638 return altera_ci_stop_feed(feed, 2);
638} 639}
639 640
640int altera_hw_filt_init(struct altera_ci_config *config, int hw_filt_nr) 641static int altera_hw_filt_init(struct altera_ci_config *config, int hw_filt_nr)
641{ 642{
642 struct netup_hw_pid_filter *pid_filt = NULL; 643 struct netup_hw_pid_filter *pid_filt = NULL;
643 struct fpga_inode *temp_int = find_inode(config->dev); 644 struct fpga_inode *temp_int = find_inode(config->dev);
diff --git a/drivers/media/pci/cx23885/cimax2.c b/drivers/media/pci/cx23885/cimax2.c
index 6617774a326a..7344849183a7 100644
--- a/drivers/media/pci/cx23885/cimax2.c
+++ b/drivers/media/pci/cx23885/cimax2.c
@@ -24,6 +24,7 @@
24 */ 24 */
25 25
26#include "cx23885.h" 26#include "cx23885.h"
27#include "cimax2.h"
27#include "dvb_ca_en50221.h" 28#include "dvb_ca_en50221.h"
28/**** Bit definitions for MC417_RWD and MC417_OEN registers *** 29/**** Bit definitions for MC417_RWD and MC417_OEN registers ***
29 bits 31-16 30 bits 31-16
@@ -87,7 +88,7 @@ struct netup_ci_state {
87}; 88};
88 89
89 90
90int netup_read_i2c(struct i2c_adapter *i2c_adap, u8 addr, u8 reg, 91static int netup_read_i2c(struct i2c_adapter *i2c_adap, u8 addr, u8 reg,
91 u8 *buf, int len) 92 u8 *buf, int len)
92{ 93{
93 int ret; 94 int ret;
@@ -120,7 +121,7 @@ int netup_read_i2c(struct i2c_adapter *i2c_adap, u8 addr, u8 reg,
120 return 0; 121 return 0;
121} 122}
122 123
123int netup_write_i2c(struct i2c_adapter *i2c_adap, u8 addr, u8 reg, 124static int netup_write_i2c(struct i2c_adapter *i2c_adap, u8 addr, u8 reg,
124 u8 *buf, int len) 125 u8 *buf, int len)
125{ 126{
126 int ret; 127 int ret;
@@ -147,7 +148,7 @@ int netup_write_i2c(struct i2c_adapter *i2c_adap, u8 addr, u8 reg,
147 return 0; 148 return 0;
148} 149}
149 150
150int netup_ci_get_mem(struct cx23885_dev *dev) 151static int netup_ci_get_mem(struct cx23885_dev *dev)
151{ 152{
152 int mem; 153 int mem;
153 unsigned long timeout = jiffies + msecs_to_jiffies(1); 154 unsigned long timeout = jiffies + msecs_to_jiffies(1);
@@ -166,7 +167,7 @@ int netup_ci_get_mem(struct cx23885_dev *dev)
166 return mem & 0xff; 167 return mem & 0xff;
167} 168}
168 169
169int netup_ci_op_cam(struct dvb_ca_en50221 *en50221, int slot, 170static int netup_ci_op_cam(struct dvb_ca_en50221 *en50221, int slot,
170 u8 flag, u8 read, int addr, u8 data) 171 u8 flag, u8 read, int addr, u8 data)
171{ 172{
172 struct netup_ci_state *state = en50221->data; 173 struct netup_ci_state *state = en50221->data;
@@ -248,7 +249,8 @@ int netup_ci_write_attribute_mem(struct dvb_ca_en50221 *en50221,
248 return netup_ci_op_cam(en50221, slot, 0, 0, addr, data); 249 return netup_ci_op_cam(en50221, slot, 0, 0, addr, data);
249} 250}
250 251
251int netup_ci_read_cam_ctl(struct dvb_ca_en50221 *en50221, int slot, u8 addr) 252int netup_ci_read_cam_ctl(struct dvb_ca_en50221 *en50221, int slot,
253 u8 addr)
252{ 254{
253 return netup_ci_op_cam(en50221, slot, NETUP_CI_CTL, 255 return netup_ci_op_cam(en50221, slot, NETUP_CI_CTL,
254 NETUP_CI_RD, addr, 0); 256 NETUP_CI_RD, addr, 0);
@@ -295,7 +297,7 @@ int netup_ci_slot_shutdown(struct dvb_ca_en50221 *en50221, int slot)
295 return 0; 297 return 0;
296} 298}
297 299
298int netup_ci_set_irq(struct dvb_ca_en50221 *en50221, u8 irq_mode) 300static int netup_ci_set_irq(struct dvb_ca_en50221 *en50221, u8 irq_mode)
299{ 301{
300 struct netup_ci_state *state = en50221->data; 302 struct netup_ci_state *state = en50221->data;
301 int ret; 303 int ret;
@@ -399,7 +401,8 @@ int netup_ci_slot_status(struct cx23885_dev *dev, u32 pci_status)
399 return 1; 401 return 1;
400} 402}
401 403
402int netup_poll_ci_slot_status(struct dvb_ca_en50221 *en50221, int slot, int open) 404int netup_poll_ci_slot_status(struct dvb_ca_en50221 *en50221,
405 int slot, int open)
403{ 406{
404 struct netup_ci_state *state = en50221->data; 407 struct netup_ci_state *state = en50221->data;
405 408
diff --git a/drivers/media/pci/cx23885/cx23885-alsa.c b/drivers/media/pci/cx23885/cx23885-alsa.c
index 795169237e70..c6c9bd58f8be 100644
--- a/drivers/media/pci/cx23885/cx23885-alsa.c
+++ b/drivers/media/pci/cx23885/cx23885-alsa.c
@@ -45,8 +45,10 @@
45 45
46#define AUDIO_SRAM_CHANNEL SRAM_CH07 46#define AUDIO_SRAM_CHANNEL SRAM_CH07
47 47
48#define dprintk(level, fmt, arg...) if (audio_debug >= level) \ 48#define dprintk(level, fmt, arg...) do { \
49 printk(KERN_INFO "%s: " fmt, chip->dev->name , ## arg) 49 if (audio_debug + 1 > level) \
50 printk(KERN_INFO "%s: " fmt, chip->dev->name , ## arg); \
51} while(0)
50 52
51#define dprintk_core(level, fmt, arg...) if (audio_debug >= level) \ 53#define dprintk_core(level, fmt, arg...) if (audio_debug >= level) \
52 printk(KERN_DEBUG "%s: " fmt, chip->dev->name , ## arg) 54 printk(KERN_DEBUG "%s: " fmt, chip->dev->name , ## arg)
diff --git a/drivers/media/pci/cx23885/cx23885-av.c b/drivers/media/pci/cx23885/cx23885-av.c
index 134ebddd860f..e958a01fd554 100644
--- a/drivers/media/pci/cx23885/cx23885-av.c
+++ b/drivers/media/pci/cx23885/cx23885-av.c
@@ -22,6 +22,7 @@
22 */ 22 */
23 23
24#include "cx23885.h" 24#include "cx23885.h"
25#include "cx23885-av.h"
25 26
26void cx23885_av_work_handler(struct work_struct *work) 27void cx23885_av_work_handler(struct work_struct *work)
27{ 28{
diff --git a/drivers/media/pci/cx23885/cx23885-cards.c b/drivers/media/pci/cx23885/cx23885-cards.c
index 5acdf954ff6b..6277e145f0b8 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -1427,7 +1427,7 @@ void cx23885_ir_fini(struct cx23885_dev *dev)
1427 } 1427 }
1428} 1428}
1429 1429
1430int netup_jtag_io(void *device, int tms, int tdi, int read_tdo) 1430static int netup_jtag_io(void *device, int tms, int tdi, int read_tdo)
1431{ 1431{
1432 int data; 1432 int data;
1433 int tdo = 0; 1433 int tdo = 0;
diff --git a/drivers/media/pci/cx23885/cx23885-core.c b/drivers/media/pci/cx23885/cx23885-core.c
index 697728f09430..065ecd54bda3 100644
--- a/drivers/media/pci/cx23885/cx23885-core.c
+++ b/drivers/media/pci/cx23885/cx23885-core.c
@@ -303,7 +303,7 @@ static struct sram_channel cx23887_sram_channels[] = {
303 }, 303 },
304}; 304};
305 305
306void cx23885_irq_add(struct cx23885_dev *dev, u32 mask) 306static void cx23885_irq_add(struct cx23885_dev *dev, u32 mask)
307{ 307{
308 unsigned long flags; 308 unsigned long flags;
309 spin_lock_irqsave(&dev->pci_irqmask_lock, flags); 309 spin_lock_irqsave(&dev->pci_irqmask_lock, flags);
@@ -1516,8 +1516,7 @@ int cx23885_restart_queue(struct cx23885_tsport *port,
1516 buf = list_entry(q->queued.next, struct cx23885_buffer, 1516 buf = list_entry(q->queued.next, struct cx23885_buffer,
1517 vb.queue); 1517 vb.queue);
1518 if (NULL == prev) { 1518 if (NULL == prev) {
1519 list_del(&buf->vb.queue); 1519 list_move_tail(&buf->vb.queue, &q->active);
1520 list_add_tail(&buf->vb.queue, &q->active);
1521 cx23885_start_dma(port, q, buf); 1520 cx23885_start_dma(port, q, buf);
1522 buf->vb.state = VIDEOBUF_ACTIVE; 1521 buf->vb.state = VIDEOBUF_ACTIVE;
1523 buf->count = q->count++; 1522 buf->count = q->count++;
@@ -1528,8 +1527,7 @@ int cx23885_restart_queue(struct cx23885_tsport *port,
1528 } else if (prev->vb.width == buf->vb.width && 1527 } else if (prev->vb.width == buf->vb.width &&
1529 prev->vb.height == buf->vb.height && 1528 prev->vb.height == buf->vb.height &&
1530 prev->fmt == buf->fmt) { 1529 prev->fmt == buf->fmt) {
1531 list_del(&buf->vb.queue); 1530 list_move_tail(&buf->vb.queue, &q->active);
1532 list_add_tail(&buf->vb.queue, &q->active);
1533 buf->vb.state = VIDEOBUF_ACTIVE; 1531 buf->vb.state = VIDEOBUF_ACTIVE;
1534 buf->count = q->count++; 1532 buf->count = q->count++;
1535 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); 1533 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
index 4379d8a6dad5..2f5b902e63ae 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -659,7 +659,7 @@ static struct mt2063_config terratec_mt2063_config[] = {
659 }, 659 },
660}; 660};
661 661
662int netup_altera_fpga_rw(void *device, int flag, int data, int read) 662static int netup_altera_fpga_rw(void *device, int flag, int data, int read)
663{ 663{
664 struct cx23885_dev *dev = (struct cx23885_dev *)device; 664 struct cx23885_dev *dev = (struct cx23885_dev *)device;
665 unsigned long timeout = jiffies + msecs_to_jiffies(1); 665 unsigned long timeout = jiffies + msecs_to_jiffies(1);
diff --git a/drivers/media/pci/cx23885/cx23885-f300.c b/drivers/media/pci/cx23885/cx23885-f300.c
index 93998f220986..5444cc526008 100644
--- a/drivers/media/pci/cx23885/cx23885-f300.c
+++ b/drivers/media/pci/cx23885/cx23885-f300.c
@@ -29,6 +29,7 @@
29 */ 29 */
30 30
31#include "cx23885.h" 31#include "cx23885.h"
32#include "cx23885-f300.h"
32 33
33#define F300_DATA GPIO_0 34#define F300_DATA GPIO_0
34#define F300_RESET GPIO_1 35#define F300_RESET GPIO_1
diff --git a/drivers/media/pci/cx23885/cx23885-input.c b/drivers/media/pci/cx23885/cx23885-input.c
index 2c925f77cf2a..4f1055a194b5 100644
--- a/drivers/media/pci/cx23885/cx23885-input.c
+++ b/drivers/media/pci/cx23885/cx23885-input.c
@@ -40,6 +40,7 @@
40#include <media/v4l2-subdev.h> 40#include <media/v4l2-subdev.h>
41 41
42#include "cx23885.h" 42#include "cx23885.h"
43#include "cx23885-input.h"
43 44
44#define MODULE_NAME "cx23885" 45#define MODULE_NAME "cx23885"
45 46
@@ -270,21 +271,21 @@ int cx23885_input_init(struct cx23885_dev *dev)
270 case CX23885_BOARD_HAUPPAUGE_HVR1250: 271 case CX23885_BOARD_HAUPPAUGE_HVR1250:
271 /* Integrated CX2388[58] IR controller */ 272 /* Integrated CX2388[58] IR controller */
272 driver_type = RC_DRIVER_IR_RAW; 273 driver_type = RC_DRIVER_IR_RAW;
273 allowed_protos = RC_TYPE_ALL; 274 allowed_protos = RC_BIT_ALL;
274 /* The grey Hauppauge RC-5 remote */ 275 /* The grey Hauppauge RC-5 remote */
275 rc_map = RC_MAP_HAUPPAUGE; 276 rc_map = RC_MAP_HAUPPAUGE;
276 break; 277 break;
277 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL: 278 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
278 /* Integrated CX23885 IR controller */ 279 /* Integrated CX23885 IR controller */
279 driver_type = RC_DRIVER_IR_RAW; 280 driver_type = RC_DRIVER_IR_RAW;
280 allowed_protos = RC_TYPE_NEC; 281 allowed_protos = RC_BIT_NEC;
281 /* The grey Terratec remote with orange buttons */ 282 /* The grey Terratec remote with orange buttons */
282 rc_map = RC_MAP_NEC_TERRATEC_CINERGY_XS; 283 rc_map = RC_MAP_NEC_TERRATEC_CINERGY_XS;
283 break; 284 break;
284 case CX23885_BOARD_TEVII_S470: 285 case CX23885_BOARD_TEVII_S470:
285 /* Integrated CX23885 IR controller */ 286 /* Integrated CX23885 IR controller */
286 driver_type = RC_DRIVER_IR_RAW; 287 driver_type = RC_DRIVER_IR_RAW;
287 allowed_protos = RC_TYPE_ALL; 288 allowed_protos = RC_BIT_ALL;
288 /* A guess at the remote */ 289 /* A guess at the remote */
289 rc_map = RC_MAP_TEVII_NEC; 290 rc_map = RC_MAP_TEVII_NEC;
290 break; 291 break;
diff --git a/drivers/media/pci/cx23885/cx23885-input.h b/drivers/media/pci/cx23885/cx23885-input.h
index 75ef15d3f523..87dc44e69977 100644
--- a/drivers/media/pci/cx23885/cx23885-input.h
+++ b/drivers/media/pci/cx23885/cx23885-input.h
@@ -23,7 +23,7 @@
23 23
24#ifndef _CX23885_INPUT_H_ 24#ifndef _CX23885_INPUT_H_
25#define _CX23885_INPUT_H_ 25#define _CX23885_INPUT_H_
26int cx23885_input_rx_work_handler(struct cx23885_dev *dev, u32 events); 26void cx23885_input_rx_work_handler(struct cx23885_dev *dev, u32 events);
27 27
28int cx23885_input_init(struct cx23885_dev *dev); 28int cx23885_input_init(struct cx23885_dev *dev);
29void cx23885_input_fini(struct cx23885_dev *dev); 29void cx23885_input_fini(struct cx23885_dev *dev);
diff --git a/drivers/media/pci/cx23885/cx23885-ioctl.c b/drivers/media/pci/cx23885/cx23885-ioctl.c
index 44812ca78899..ea9a614f3bbf 100644
--- a/drivers/media/pci/cx23885/cx23885-ioctl.c
+++ b/drivers/media/pci/cx23885/cx23885-ioctl.c
@@ -22,6 +22,8 @@
22 */ 22 */
23 23
24#include "cx23885.h" 24#include "cx23885.h"
25#include "cx23885-ioctl.h"
26
25#include <media/v4l2-chip-ident.h> 27#include <media/v4l2-chip-ident.h>
26 28
27int cx23885_g_chip_ident(struct file *file, void *fh, 29int cx23885_g_chip_ident(struct file *file, void *fh,
diff --git a/drivers/media/pci/cx23885/cx23885-ir.c b/drivers/media/pci/cx23885/cx23885-ir.c
index 7125247dd255..bfef19359291 100644
--- a/drivers/media/pci/cx23885/cx23885-ir.c
+++ b/drivers/media/pci/cx23885/cx23885-ir.c
@@ -24,6 +24,7 @@
24#include <media/v4l2-device.h> 24#include <media/v4l2-device.h>
25 25
26#include "cx23885.h" 26#include "cx23885.h"
27#include "cx23885-ir.h"
27#include "cx23885-input.h" 28#include "cx23885-input.h"
28 29
29#define CX23885_IR_RX_FIFO_SERVICE_REQ 0 30#define CX23885_IR_RX_FIFO_SERVICE_REQ 0
diff --git a/drivers/media/pci/cx23885/cx23888-ir.c b/drivers/media/pci/cx23885/cx23888-ir.c
index c2bc39c58f82..c4bd1e95d33f 100644
--- a/drivers/media/pci/cx23885/cx23888-ir.c
+++ b/drivers/media/pci/cx23885/cx23888-ir.c
@@ -29,6 +29,7 @@
29#include <media/rc-core.h> 29#include <media/rc-core.h>
30 30
31#include "cx23885.h" 31#include "cx23885.h"
32#include "cx23888-ir.h"
32 33
33static unsigned int ir_888_debug; 34static unsigned int ir_888_debug;
34module_param(ir_888_debug, int, 0644); 35module_param(ir_888_debug, int, 0644);
diff --git a/drivers/media/pci/cx23885/netup-init.c b/drivers/media/pci/cx23885/netup-init.c
index f4893e69cd89..0044fef7ca24 100644
--- a/drivers/media/pci/cx23885/netup-init.c
+++ b/drivers/media/pci/cx23885/netup-init.c
@@ -24,6 +24,7 @@
24 */ 24 */
25 25
26#include "cx23885.h" 26#include "cx23885.h"
27#include "netup-init.h"
27 28
28static void i2c_av_write(struct i2c_adapter *i2c, u16 reg, u8 val) 29static void i2c_av_write(struct i2c_adapter *i2c, u16 reg, u8 val)
29{ 30{
diff --git a/drivers/media/pci/cx25821/cx25821-audio-upstream.c b/drivers/media/pci/cx25821/cx25821-audio-upstream.c
index 8b2a99975c23..87491ca05ee5 100644
--- a/drivers/media/pci/cx25821/cx25821-audio-upstream.c
+++ b/drivers/media/pci/cx25821/cx25821-audio-upstream.c
@@ -44,7 +44,7 @@ MODULE_LICENSE("GPL");
44static int _intr_msk = FLD_AUD_SRC_RISCI1 | FLD_AUD_SRC_OF | 44static int _intr_msk = FLD_AUD_SRC_RISCI1 | FLD_AUD_SRC_OF |
45 FLD_AUD_SRC_SYNC | FLD_AUD_SRC_OPC_ERR; 45 FLD_AUD_SRC_SYNC | FLD_AUD_SRC_OPC_ERR;
46 46
47int cx25821_sram_channel_setup_upstream_audio(struct cx25821_dev *dev, 47static int cx25821_sram_channel_setup_upstream_audio(struct cx25821_dev *dev,
48 struct sram_channel *ch, 48 struct sram_channel *ch,
49 unsigned int bpl, u32 risc) 49 unsigned int bpl, u32 risc)
50{ 50{
@@ -133,7 +133,7 @@ static __le32 *cx25821_risc_field_upstream_audio(struct cx25821_dev *dev,
133 return rp; 133 return rp;
134} 134}
135 135
136int cx25821_risc_buffer_upstream_audio(struct cx25821_dev *dev, 136static int cx25821_risc_buffer_upstream_audio(struct cx25821_dev *dev,
137 struct pci_dev *pci, 137 struct pci_dev *pci,
138 unsigned int bpl, unsigned int lines) 138 unsigned int bpl, unsigned int lines)
139{ 139{
@@ -197,7 +197,7 @@ int cx25821_risc_buffer_upstream_audio(struct cx25821_dev *dev,
197 return 0; 197 return 0;
198} 198}
199 199
200void cx25821_free_memory_audio(struct cx25821_dev *dev) 200static void cx25821_free_memory_audio(struct cx25821_dev *dev)
201{ 201{
202 if (dev->_risc_virt_addr) { 202 if (dev->_risc_virt_addr) {
203 pci_free_consistent(dev->pci, dev->_audiorisc_size, 203 pci_free_consistent(dev->pci, dev->_audiorisc_size,
@@ -256,7 +256,7 @@ void cx25821_free_mem_upstream_audio(struct cx25821_dev *dev)
256 cx25821_free_memory_audio(dev); 256 cx25821_free_memory_audio(dev);
257} 257}
258 258
259int cx25821_get_audio_data(struct cx25821_dev *dev, 259static int cx25821_get_audio_data(struct cx25821_dev *dev,
260 struct sram_channel *sram_ch) 260 struct sram_channel *sram_ch)
261{ 261{
262 struct file *myfile; 262 struct file *myfile;
@@ -351,7 +351,7 @@ static void cx25821_audioups_handler(struct work_struct *work)
351 sram_channels); 351 sram_channels);
352} 352}
353 353
354int cx25821_openfile_audio(struct cx25821_dev *dev, 354static int cx25821_openfile_audio(struct cx25821_dev *dev,
355 struct sram_channel *sram_ch) 355 struct sram_channel *sram_ch)
356{ 356{
357 struct file *myfile; 357 struct file *myfile;
@@ -490,7 +490,7 @@ error:
490 return ret; 490 return ret;
491} 491}
492 492
493int cx25821_audio_upstream_irq(struct cx25821_dev *dev, int chan_num, 493static int cx25821_audio_upstream_irq(struct cx25821_dev *dev, int chan_num,
494 u32 status) 494 u32 status)
495{ 495{
496 int i = 0; 496 int i = 0;
@@ -634,8 +634,8 @@ static void cx25821_wait_fifo_enable(struct cx25821_dev *dev,
634 634
635} 635}
636 636
637int cx25821_start_audio_dma_upstream(struct cx25821_dev *dev, 637static int cx25821_start_audio_dma_upstream(struct cx25821_dev *dev,
638 struct sram_channel *sram_ch) 638 struct sram_channel *sram_ch)
639{ 639{
640 u32 tmp = 0; 640 u32 tmp = 0;
641 int err = 0; 641 int err = 0;
@@ -700,9 +700,7 @@ fail_irq:
700int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select) 700int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select)
701{ 701{
702 struct sram_channel *sram_ch; 702 struct sram_channel *sram_ch;
703 int retval = 0;
704 int err = 0; 703 int err = 0;
705 int str_length = 0;
706 704
707 if (dev->_audio_is_running) { 705 if (dev->_audio_is_running) {
708 pr_warn("Audio Channel is still running so return!\n"); 706 pr_warn("Audio Channel is still running so return!\n");
@@ -731,27 +729,29 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select)
731 _line_size = AUDIO_LINE_SIZE; 729 _line_size = AUDIO_LINE_SIZE;
732 730
733 if (dev->input_audiofilename) { 731 if (dev->input_audiofilename) {
734 str_length = strlen(dev->input_audiofilename); 732 dev->_audiofilename = kstrdup(dev->input_audiofilename,
735 dev->_audiofilename = kmemdup(dev->input_audiofilename, 733 GFP_KERNEL);
736 str_length + 1, GFP_KERNEL);
737 734
738 if (!dev->_audiofilename) 735 if (!dev->_audiofilename) {
736 err = -ENOMEM;
739 goto error; 737 goto error;
738 }
740 739
741 /* Default if filename is empty string */ 740 /* Default if filename is empty string */
742 if (strcmp(dev->input_audiofilename, "") == 0) 741 if (strcmp(dev->input_audiofilename, "") == 0)
743 dev->_audiofilename = "/root/audioGOOD.wav"; 742 dev->_audiofilename = "/root/audioGOOD.wav";
744 } else { 743 } else {
745 str_length = strlen(_defaultAudioName); 744 dev->_audiofilename = kstrdup(_defaultAudioName,
746 dev->_audiofilename = kmemdup(_defaultAudioName, 745 GFP_KERNEL);
747 str_length + 1, GFP_KERNEL);
748 746
749 if (!dev->_audiofilename) 747 if (!dev->_audiofilename) {
748 err = -ENOMEM;
750 goto error; 749 goto error;
750 }
751 } 751 }
752 752
753 retval = cx25821_sram_channel_setup_upstream_audio(dev, sram_ch, 753 cx25821_sram_channel_setup_upstream_audio(dev, sram_ch,
754 _line_size, 0); 754 _line_size, 0);
755 755
756 dev->audio_upstream_riscbuf_size = 756 dev->audio_upstream_riscbuf_size =
757 AUDIO_RISC_DMA_BUF_SIZE * NUM_AUDIO_PROGS + 757 AUDIO_RISC_DMA_BUF_SIZE * NUM_AUDIO_PROGS +
@@ -759,9 +759,9 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select)
759 dev->audio_upstream_databuf_size = AUDIO_DATA_BUF_SZ * NUM_AUDIO_PROGS; 759 dev->audio_upstream_databuf_size = AUDIO_DATA_BUF_SZ * NUM_AUDIO_PROGS;
760 760
761 /* Allocating buffers and prepare RISC program */ 761 /* Allocating buffers and prepare RISC program */
762 retval = cx25821_audio_upstream_buffer_prepare(dev, sram_ch, 762 err = cx25821_audio_upstream_buffer_prepare(dev, sram_ch,
763 _line_size); 763 _line_size);
764 if (retval < 0) { 764 if (err < 0) {
765 pr_err("%s: Failed to set up Audio upstream buffers!\n", 765 pr_err("%s: Failed to set up Audio upstream buffers!\n",
766 dev->name); 766 dev->name);
767 goto error; 767 goto error;
diff --git a/drivers/media/pci/cx25821/cx25821-biffuncs.h b/drivers/media/pci/cx25821/cx25821-biffuncs.h
index 9326a7c729ec..937f5a70fb7a 100644
--- a/drivers/media/pci/cx25821/cx25821-biffuncs.h
+++ b/drivers/media/pci/cx25821/cx25821-biffuncs.h
@@ -25,17 +25,17 @@
25 25
26#define SetBit(Bit) (1 << Bit) 26#define SetBit(Bit) (1 << Bit)
27 27
28inline u8 getBit(u32 sample, u8 index) 28static inline u8 getBit(u32 sample, u8 index)
29{ 29{
30 return (u8) ((sample >> index) & 1); 30 return (u8) ((sample >> index) & 1);
31} 31}
32 32
33inline u32 clearBitAtPos(u32 value, u8 bit) 33static inline u32 clearBitAtPos(u32 value, u8 bit)
34{ 34{
35 return value & ~(1 << bit); 35 return value & ~(1 << bit);
36} 36}
37 37
38inline u32 setBitAtPos(u32 sample, u8 bit) 38static inline u32 setBitAtPos(u32 sample, u8 bit)
39{ 39{
40 sample |= (1 << bit); 40 sample |= (1 << bit);
41 return sample; 41 return sample;
diff --git a/drivers/media/pci/cx25821/cx25821-i2c.c b/drivers/media/pci/cx25821/cx25821-i2c.c
index 9844549764c9..a8dc945bbe17 100644
--- a/drivers/media/pci/cx25821/cx25821-i2c.c
+++ b/drivers/media/pci/cx25821/cx25821-i2c.c
@@ -329,7 +329,8 @@ int cx25821_i2c_unregister(struct cx25821_i2c *bus)
329 return 0; 329 return 0;
330} 330}
331 331
332void cx25821_av_clk(struct cx25821_dev *dev, int enable) 332#if 0 /* Currently unused */
333static void cx25821_av_clk(struct cx25821_dev *dev, int enable)
333{ 334{
334 /* write 0 to bus 2 addr 0x144 via i2x_xfer() */ 335 /* write 0 to bus 2 addr 0x144 via i2x_xfer() */
335 char buffer[3]; 336 char buffer[3];
@@ -351,6 +352,7 @@ void cx25821_av_clk(struct cx25821_dev *dev, int enable)
351 352
352 i2c_xfer(&dev->i2c_bus[0].i2c_adap, &msg, 1); 353 i2c_xfer(&dev->i2c_bus[0].i2c_adap, &msg, 1);
353} 354}
355#endif
354 356
355int cx25821_i2c_read(struct cx25821_i2c *bus, u16 reg_addr, int *value) 357int cx25821_i2c_read(struct cx25821_i2c *bus, u16 reg_addr, int *value)
356{ 358{
diff --git a/drivers/media/pci/cx25821/cx25821-video-upstream-ch2.c b/drivers/media/pci/cx25821/cx25821-video-upstream-ch2.c
index d33fc1a23030..cf2723c7197f 100644
--- a/drivers/media/pci/cx25821/cx25821-video-upstream-ch2.c
+++ b/drivers/media/pci/cx25821/cx25821-video-upstream-ch2.c
@@ -123,10 +123,11 @@ static __le32 *cx25821_risc_field_upstream_ch2(struct cx25821_dev *dev,
123 return rp; 123 return rp;
124} 124}
125 125
126int cx25821_risc_buffer_upstream_ch2(struct cx25821_dev *dev, 126static int cx25821_risc_buffer_upstream_ch2(struct cx25821_dev *dev,
127 struct pci_dev *pci, 127 struct pci_dev *pci,
128 unsigned int top_offset, unsigned int bpl, 128 unsigned int top_offset,
129 unsigned int lines) 129 unsigned int bpl,
130 unsigned int lines)
130{ 131{
131 __le32 *rp; 132 __le32 *rp;
132 int fifo_enable = 0; 133 int fifo_enable = 0;
@@ -255,7 +256,8 @@ void cx25821_free_mem_upstream_ch2(struct cx25821_dev *dev)
255 } 256 }
256} 257}
257 258
258int cx25821_get_frame_ch2(struct cx25821_dev *dev, struct sram_channel *sram_ch) 259static int cx25821_get_frame_ch2(struct cx25821_dev *dev,
260 struct sram_channel *sram_ch)
259{ 261{
260 struct file *myfile; 262 struct file *myfile;
261 int frame_index_temp = dev->_frame_index_ch2; 263 int frame_index_temp = dev->_frame_index_ch2;
@@ -360,7 +362,8 @@ static void cx25821_vidups_handler_ch2(struct work_struct *work)
360 _channel2_upstream_select].sram_channels); 362 _channel2_upstream_select].sram_channels);
361} 363}
362 364
363int cx25821_openfile_ch2(struct cx25821_dev *dev, struct sram_channel *sram_ch) 365static int cx25821_openfile_ch2(struct cx25821_dev *dev,
366 struct sram_channel *sram_ch)
364{ 367{
365 struct file *myfile; 368 struct file *myfile;
366 int i = 0, j = 0; 369 int i = 0, j = 0;
@@ -507,8 +510,9 @@ error:
507 return ret; 510 return ret;
508} 511}
509 512
510int cx25821_video_upstream_irq_ch2(struct cx25821_dev *dev, int chan_num, 513static int cx25821_video_upstream_irq_ch2(struct cx25821_dev *dev,
511 u32 status) 514 int chan_num,
515 u32 status)
512{ 516{
513 u32 int_msk_tmp; 517 u32 int_msk_tmp;
514 struct sram_channel *channel = dev->channels[chan_num].sram_channels; 518 struct sram_channel *channel = dev->channels[chan_num].sram_channels;
@@ -647,8 +651,8 @@ static void cx25821_set_pixelengine_ch2(struct cx25821_dev *dev,
647 cx_write(ch->vid_cdt_size, VID_CDT_SIZE >> 3); 651 cx_write(ch->vid_cdt_size, VID_CDT_SIZE >> 3);
648} 652}
649 653
650int cx25821_start_video_dma_upstream_ch2(struct cx25821_dev *dev, 654static int cx25821_start_video_dma_upstream_ch2(struct cx25821_dev *dev,
651 struct sram_channel *sram_ch) 655 struct sram_channel *sram_ch)
652{ 656{
653 u32 tmp = 0; 657 u32 tmp = 0;
654 int err = 0; 658 int err = 0;
@@ -704,11 +708,9 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select,
704{ 708{
705 struct sram_channel *sram_ch; 709 struct sram_channel *sram_ch;
706 u32 tmp; 710 u32 tmp;
707 int retval = 0;
708 int err = 0; 711 int err = 0;
709 int data_frame_size = 0; 712 int data_frame_size = 0;
710 int risc_buffer_size = 0; 713 int risc_buffer_size = 0;
711 int str_length = 0;
712 714
713 if (dev->_is_running_ch2) { 715 if (dev->_is_running_ch2) {
714 pr_info("Video Channel is still running so return!\n"); 716 pr_info("Video Channel is still running so return!\n");
@@ -744,20 +746,16 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select,
744 risc_buffer_size = dev->_isNTSC_ch2 ? 746 risc_buffer_size = dev->_isNTSC_ch2 ?
745 NTSC_RISC_BUF_SIZE : PAL_RISC_BUF_SIZE; 747 NTSC_RISC_BUF_SIZE : PAL_RISC_BUF_SIZE;
746 748
747 if (dev->input_filename_ch2) { 749 if (dev->input_filename_ch2)
748 str_length = strlen(dev->input_filename_ch2); 750 dev->_filename_ch2 = kstrdup(dev->input_filename_ch2,
749 dev->_filename_ch2 = kmemdup(dev->input_filename_ch2, 751 GFP_KERNEL);
750 str_length + 1, GFP_KERNEL); 752 else
751 753 dev->_filename_ch2 = kstrdup(dev->_defaultname_ch2,
752 if (!dev->_filename_ch2) 754 GFP_KERNEL);
753 goto error;
754 } else {
755 str_length = strlen(dev->_defaultname_ch2);
756 dev->_filename_ch2 = kmemdup(dev->_defaultname_ch2,
757 str_length + 1, GFP_KERNEL);
758 755
759 if (!dev->_filename_ch2) 756 if (!dev->_filename_ch2) {
760 goto error; 757 err = -ENOENT;
758 goto error;
761 } 759 }
762 760
763 /* Default if filename is empty string */ 761 /* Default if filename is empty string */
@@ -773,7 +771,7 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select,
773 } 771 }
774 } 772 }
775 773
776 retval = cx25821_sram_channel_setup_upstream(dev, sram_ch, 774 err = cx25821_sram_channel_setup_upstream(dev, sram_ch,
777 dev->_line_size_ch2, 0); 775 dev->_line_size_ch2, 0);
778 776
779 /* setup fifo + format */ 777 /* setup fifo + format */
@@ -783,9 +781,9 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select,
783 dev->upstream_databuf_size_ch2 = data_frame_size * 2; 781 dev->upstream_databuf_size_ch2 = data_frame_size * 2;
784 782
785 /* Allocating buffers and prepare RISC program */ 783 /* Allocating buffers and prepare RISC program */
786 retval = cx25821_upstream_buffer_prepare_ch2(dev, sram_ch, 784 err = cx25821_upstream_buffer_prepare_ch2(dev, sram_ch,
787 dev->_line_size_ch2); 785 dev->_line_size_ch2);
788 if (retval < 0) { 786 if (err < 0) {
789 pr_err("%s: Failed to set up Video upstream buffers!\n", 787 pr_err("%s: Failed to set up Video upstream buffers!\n",
790 dev->name); 788 dev->name);
791 goto error; 789 goto error;
diff --git a/drivers/media/pci/cx25821/cx25821-video-upstream.c b/drivers/media/pci/cx25821/cx25821-video-upstream.c
index 6759fff8eb64..7fc97110d973 100644
--- a/drivers/media/pci/cx25821/cx25821-video-upstream.c
+++ b/drivers/media/pci/cx25821/cx25821-video-upstream.c
@@ -173,10 +173,10 @@ static __le32 *cx25821_risc_field_upstream(struct cx25821_dev *dev, __le32 * rp,
173 return rp; 173 return rp;
174} 174}
175 175
176int cx25821_risc_buffer_upstream(struct cx25821_dev *dev, 176static int cx25821_risc_buffer_upstream(struct cx25821_dev *dev,
177 struct pci_dev *pci, 177 struct pci_dev *pci,
178 unsigned int top_offset, 178 unsigned int top_offset,
179 unsigned int bpl, unsigned int lines) 179 unsigned int bpl, unsigned int lines)
180{ 180{
181 __le32 *rp; 181 __le32 *rp;
182 int fifo_enable = 0; 182 int fifo_enable = 0;
@@ -300,7 +300,8 @@ void cx25821_free_mem_upstream_ch1(struct cx25821_dev *dev)
300 } 300 }
301} 301}
302 302
303int cx25821_get_frame(struct cx25821_dev *dev, struct sram_channel *sram_ch) 303static int cx25821_get_frame(struct cx25821_dev *dev,
304 struct sram_channel *sram_ch)
304{ 305{
305 struct file *myfile; 306 struct file *myfile;
306 int frame_index_temp = dev->_frame_index; 307 int frame_index_temp = dev->_frame_index;
@@ -405,7 +406,8 @@ static void cx25821_vidups_handler(struct work_struct *work)
405 sram_channels); 406 sram_channels);
406} 407}
407 408
408int cx25821_openfile(struct cx25821_dev *dev, struct sram_channel *sram_ch) 409static int cx25821_openfile(struct cx25821_dev *dev,
410 struct sram_channel *sram_ch)
409{ 411{
410 struct file *myfile; 412 struct file *myfile;
411 int i = 0, j = 0; 413 int i = 0, j = 0;
@@ -486,8 +488,9 @@ int cx25821_openfile(struct cx25821_dev *dev, struct sram_channel *sram_ch)
486 return 0; 488 return 0;
487} 489}
488 490
489int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev, 491static int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev,
490 struct sram_channel *sram_ch, int bpl) 492 struct sram_channel *sram_ch,
493 int bpl)
491{ 494{
492 int ret = 0; 495 int ret = 0;
493 dma_addr_t dma_addr; 496 dma_addr_t dma_addr;
@@ -548,8 +551,8 @@ error:
548 return ret; 551 return ret;
549} 552}
550 553
551int cx25821_video_upstream_irq(struct cx25821_dev *dev, int chan_num, 554static int cx25821_video_upstream_irq(struct cx25821_dev *dev, int chan_num,
552 u32 status) 555 u32 status)
553{ 556{
554 u32 int_msk_tmp; 557 u32 int_msk_tmp;
555 struct sram_channel *channel = dev->channels[chan_num].sram_channels; 558 struct sram_channel *channel = dev->channels[chan_num].sram_channels;
@@ -664,8 +667,9 @@ static irqreturn_t cx25821_upstream_irq(int irq, void *dev_id)
664 return IRQ_RETVAL(handled); 667 return IRQ_RETVAL(handled);
665} 668}
666 669
667void cx25821_set_pixelengine(struct cx25821_dev *dev, struct sram_channel *ch, 670static void cx25821_set_pixelengine(struct cx25821_dev *dev,
668 int pix_format) 671 struct sram_channel *ch,
672 int pix_format)
669{ 673{
670 int width = WIDTH_D1; 674 int width = WIDTH_D1;
671 int height = dev->_lines_count; 675 int height = dev->_lines_count;
@@ -696,8 +700,8 @@ void cx25821_set_pixelengine(struct cx25821_dev *dev, struct sram_channel *ch,
696 cx_write(ch->vid_cdt_size, VID_CDT_SIZE >> 3); 700 cx_write(ch->vid_cdt_size, VID_CDT_SIZE >> 3);
697} 701}
698 702
699int cx25821_start_video_dma_upstream(struct cx25821_dev *dev, 703static int cx25821_start_video_dma_upstream(struct cx25821_dev *dev,
700 struct sram_channel *sram_ch) 704 struct sram_channel *sram_ch)
701{ 705{
702 u32 tmp = 0; 706 u32 tmp = 0;
703 int err = 0; 707 int err = 0;
@@ -753,7 +757,6 @@ int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select,
753{ 757{
754 struct sram_channel *sram_ch; 758 struct sram_channel *sram_ch;
755 u32 tmp; 759 u32 tmp;
756 int retval = 0;
757 int err = 0; 760 int err = 0;
758 int data_frame_size = 0; 761 int data_frame_size = 0;
759 int risc_buffer_size = 0; 762 int risc_buffer_size = 0;
@@ -796,15 +799,19 @@ int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select,
796 dev->_filename = kmemdup(dev->input_filename, str_length + 1, 799 dev->_filename = kmemdup(dev->input_filename, str_length + 1,
797 GFP_KERNEL); 800 GFP_KERNEL);
798 801
799 if (!dev->_filename) 802 if (!dev->_filename) {
803 err = -ENOENT;
800 goto error; 804 goto error;
805 }
801 } else { 806 } else {
802 str_length = strlen(dev->_defaultname); 807 str_length = strlen(dev->_defaultname);
803 dev->_filename = kmemdup(dev->_defaultname, str_length + 1, 808 dev->_filename = kmemdup(dev->_defaultname, str_length + 1,
804 GFP_KERNEL); 809 GFP_KERNEL);
805 810
806 if (!dev->_filename) 811 if (!dev->_filename) {
812 err = -ENOENT;
807 goto error; 813 goto error;
814 }
808 } 815 }
809 816
810 /* Default if filename is empty string */ 817 /* Default if filename is empty string */
@@ -828,7 +835,7 @@ int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select,
828 dev->_line_size = (dev->_pixel_format == PIXEL_FRMT_422) ? 835 dev->_line_size = (dev->_pixel_format == PIXEL_FRMT_422) ?
829 (WIDTH_D1 * 2) : (WIDTH_D1 * 3) / 2; 836 (WIDTH_D1 * 2) : (WIDTH_D1 * 3) / 2;
830 837
831 retval = cx25821_sram_channel_setup_upstream(dev, sram_ch, 838 err = cx25821_sram_channel_setup_upstream(dev, sram_ch,
832 dev->_line_size, 0); 839 dev->_line_size, 0);
833 840
834 /* setup fifo + format */ 841 /* setup fifo + format */
@@ -838,8 +845,8 @@ int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select,
838 dev->upstream_databuf_size = data_frame_size * 2; 845 dev->upstream_databuf_size = data_frame_size * 2;
839 846
840 /* Allocating buffers and prepare RISC program */ 847 /* Allocating buffers and prepare RISC program */
841 retval = cx25821_upstream_buffer_prepare(dev, sram_ch, dev->_line_size); 848 err = cx25821_upstream_buffer_prepare(dev, sram_ch, dev->_line_size);
842 if (retval < 0) { 849 if (err < 0) {
843 pr_err("%s: Failed to set up Video upstream buffers!\n", 850 pr_err("%s: Failed to set up Video upstream buffers!\n",
844 dev->name); 851 dev->name);
845 goto error; 852 goto error;
diff --git a/drivers/media/pci/cx25821/cx25821-video.c b/drivers/media/pci/cx25821/cx25821-video.c
index 0a80245165d0..53b16dd70320 100644
--- a/drivers/media/pci/cx25821/cx25821-video.c
+++ b/drivers/media/pci/cx25821/cx25821-video.c
@@ -291,9 +291,9 @@ int cx25821_start_video_dma(struct cx25821_dev *dev,
291 return 0; 291 return 0;
292} 292}
293 293
294int cx25821_restart_video_queue(struct cx25821_dev *dev, 294static int cx25821_restart_video_queue(struct cx25821_dev *dev,
295 struct cx25821_dmaqueue *q, 295 struct cx25821_dmaqueue *q,
296 struct sram_channel *channel) 296 struct sram_channel *channel)
297{ 297{
298 struct cx25821_buffer *buf, *prev; 298 struct cx25821_buffer *buf, *prev;
299 struct list_head *item; 299 struct list_head *item;
@@ -342,7 +342,7 @@ int cx25821_restart_video_queue(struct cx25821_dev *dev,
342 } 342 }
343} 343}
344 344
345void cx25821_vid_timeout(unsigned long data) 345static void cx25821_vid_timeout(unsigned long data)
346{ 346{
347 struct cx25821_data *timeout_data = (struct cx25821_data *)data; 347 struct cx25821_data *timeout_data = (struct cx25821_data *)data;
348 struct cx25821_dev *dev = timeout_data->dev; 348 struct cx25821_dev *dev = timeout_data->dev;
diff --git a/drivers/media/pci/cx88/cx88-alsa.c b/drivers/media/pci/cx88/cx88-alsa.c
index 3aa6856ead3b..d2de1a913e19 100644
--- a/drivers/media/pci/cx88/cx88-alsa.c
+++ b/drivers/media/pci/cx88/cx88-alsa.c
@@ -45,11 +45,15 @@
45#include "cx88.h" 45#include "cx88.h"
46#include "cx88-reg.h" 46#include "cx88-reg.h"
47 47
48#define dprintk(level,fmt, arg...) if (debug >= level) \ 48#define dprintk(level, fmt, arg...) do { \
49 printk(KERN_INFO "%s/1: " fmt, chip->core->name , ## arg) 49 if (debug + 1 > level) \
50 50 printk(KERN_INFO "%s/1: " fmt, chip->core->name , ## arg);\
51#define dprintk_core(level,fmt, arg...) if (debug >= level) \ 51} while(0)
52 printk(KERN_DEBUG "%s/1: " fmt, chip->core->name , ## arg) 52
53#define dprintk_core(level, fmt, arg...) do { \
54 if (debug + 1 > level) \
55 printk(KERN_DEBUG "%s/1: " fmt, chip->core->name , ## arg);\
56} while(0)
53 57
54/**************************************************************************** 58/****************************************************************************
55 Data type declarations - Can be moded to a header file later 59 Data type declarations - Can be moded to a header file later
diff --git a/drivers/media/pci/cx88/cx88-blackbird.c b/drivers/media/pci/cx88/cx88-blackbird.c
index 62184eb919e5..a6ff8a6f4fc0 100644
--- a/drivers/media/pci/cx88/cx88-blackbird.c
+++ b/drivers/media/pci/cx88/cx88-blackbird.c
@@ -53,9 +53,10 @@ static unsigned int debug;
53module_param(debug,int,0644); 53module_param(debug,int,0644);
54MODULE_PARM_DESC(debug,"enable debug messages [blackbird]"); 54MODULE_PARM_DESC(debug,"enable debug messages [blackbird]");
55 55
56#define dprintk(level,fmt, arg...) if (debug >= level) \ 56#define dprintk(level, fmt, arg...) do { \
57 printk(KERN_DEBUG "%s/2-bb: " fmt, dev->core->name , ## arg) 57 if (debug + 1 > level) \
58 58 printk(KERN_DEBUG "%s/2-bb: " fmt, dev->core->name , ## arg); \
59} while(0)
59 60
60/* ------------------------------------------------------------------ */ 61/* ------------------------------------------------------------------ */
61 62
diff --git a/drivers/media/pci/cx88/cx88-core.c b/drivers/media/pci/cx88/cx88-core.c
index c97b174be3ab..19a58754c6e1 100644
--- a/drivers/media/pci/cx88/cx88-core.c
+++ b/drivers/media/pci/cx88/cx88-core.c
@@ -646,22 +646,22 @@ int cx88_reset(struct cx88_core *core)
646 646
647/* ------------------------------------------------------------------ */ 647/* ------------------------------------------------------------------ */
648 648
649static unsigned int inline norm_swidth(v4l2_std_id norm) 649static inline unsigned int norm_swidth(v4l2_std_id norm)
650{ 650{
651 return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 754 : 922; 651 return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 754 : 922;
652} 652}
653 653
654static unsigned int inline norm_hdelay(v4l2_std_id norm) 654static inline unsigned int norm_hdelay(v4l2_std_id norm)
655{ 655{
656 return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 135 : 186; 656 return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 135 : 186;
657} 657}
658 658
659static unsigned int inline norm_vdelay(v4l2_std_id norm) 659static inline unsigned int norm_vdelay(v4l2_std_id norm)
660{ 660{
661 return (norm & V4L2_STD_625_50) ? 0x24 : 0x18; 661 return (norm & V4L2_STD_625_50) ? 0x24 : 0x18;
662} 662}
663 663
664static unsigned int inline norm_fsc8(v4l2_std_id norm) 664static inline unsigned int norm_fsc8(v4l2_std_id norm)
665{ 665{
666 if (norm & V4L2_STD_PAL_M) 666 if (norm & V4L2_STD_PAL_M)
667 return 28604892; // 3.575611 MHz 667 return 28604892; // 3.575611 MHz
@@ -681,7 +681,7 @@ static unsigned int inline norm_fsc8(v4l2_std_id norm)
681 return 35468950; // 4.43361875 MHz +/- 5 Hz 681 return 35468950; // 4.43361875 MHz +/- 5 Hz
682} 682}
683 683
684static unsigned int inline norm_htotal(v4l2_std_id norm) 684static inline unsigned int norm_htotal(v4l2_std_id norm)
685{ 685{
686 686
687 unsigned int fsc4=norm_fsc8(norm)/2; 687 unsigned int fsc4=norm_fsc8(norm)/2;
@@ -692,7 +692,7 @@ static unsigned int inline norm_htotal(v4l2_std_id norm)
692 ((fsc4+262)/525*1001+15000)/30000; 692 ((fsc4+262)/525*1001+15000)/30000;
693} 693}
694 694
695static unsigned int inline norm_vbipack(v4l2_std_id norm) 695static inline unsigned int norm_vbipack(v4l2_std_id norm)
696{ 696{
697 return (norm & V4L2_STD_625_50) ? 511 : 400; 697 return (norm & V4L2_STD_625_50) ? 511 : 400;
698} 698}
diff --git a/drivers/media/pci/cx88/cx88-input.c b/drivers/media/pci/cx88/cx88-input.c
index ebf448c48ca3..f29e18c72f44 100644
--- a/drivers/media/pci/cx88/cx88-input.c
+++ b/drivers/media/pci/cx88/cx88-input.c
@@ -248,7 +248,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
248 struct cx88_IR *ir; 248 struct cx88_IR *ir;
249 struct rc_dev *dev; 249 struct rc_dev *dev;
250 char *ir_codes = NULL; 250 char *ir_codes = NULL;
251 u64 rc_type = RC_TYPE_OTHER; 251 u64 rc_type = RC_BIT_OTHER;
252 int err = -ENOMEM; 252 int err = -ENOMEM;
253 u32 hardware_mask = 0; /* For devices with a hardware mask, when 253 u32 hardware_mask = 0; /* For devices with a hardware mask, when
254 * used with a full-code IR table 254 * used with a full-code IR table
@@ -416,7 +416,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
416 break; 416 break;
417 case CX88_BOARD_TWINHAN_VP1027_DVBS: 417 case CX88_BOARD_TWINHAN_VP1027_DVBS:
418 ir_codes = RC_MAP_TWINHAN_VP1027_DVBS; 418 ir_codes = RC_MAP_TWINHAN_VP1027_DVBS;
419 rc_type = RC_TYPE_NEC; 419 rc_type = RC_BIT_NEC;
420 ir->sampling = 0xff00; /* address */ 420 ir->sampling = 0xff00; /* address */
421 break; 421 break;
422 } 422 }
@@ -592,7 +592,7 @@ void cx88_i2c_init_ir(struct cx88_core *core)
592 case CX88_BOARD_LEADTEK_PVR2000: 592 case CX88_BOARD_LEADTEK_PVR2000:
593 addr_list = pvr2000_addr_list; 593 addr_list = pvr2000_addr_list;
594 core->init_data.name = "cx88 Leadtek PVR 2000 remote"; 594 core->init_data.name = "cx88 Leadtek PVR 2000 remote";
595 core->init_data.type = RC_TYPE_UNKNOWN; 595 core->init_data.type = RC_BIT_UNKNOWN;
596 core->init_data.get_key = get_key_pvr2000; 596 core->init_data.get_key = get_key_pvr2000;
597 core->init_data.ir_codes = RC_MAP_EMPTY; 597 core->init_data.ir_codes = RC_MAP_EMPTY;
598 break; 598 break;
@@ -613,7 +613,7 @@ void cx88_i2c_init_ir(struct cx88_core *core)
613 /* Hauppauge XVR */ 613 /* Hauppauge XVR */
614 core->init_data.name = "cx88 Hauppauge XVR remote"; 614 core->init_data.name = "cx88 Hauppauge XVR remote";
615 core->init_data.ir_codes = RC_MAP_HAUPPAUGE; 615 core->init_data.ir_codes = RC_MAP_HAUPPAUGE;
616 core->init_data.type = RC_TYPE_RC5; 616 core->init_data.type = RC_BIT_RC5;
617 core->init_data.internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; 617 core->init_data.internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
618 618
619 info.platform_data = &core->init_data; 619 info.platform_data = &core->init_data;
diff --git a/drivers/media/pci/cx88/cx88-mpeg.c b/drivers/media/pci/cx88/cx88-mpeg.c
index d154bc197356..d46b008a46b8 100644
--- a/drivers/media/pci/cx88/cx88-mpeg.c
+++ b/drivers/media/pci/cx88/cx88-mpeg.c
@@ -45,11 +45,15 @@ static unsigned int debug;
45module_param(debug,int,0644); 45module_param(debug,int,0644);
46MODULE_PARM_DESC(debug,"enable debug messages [mpeg]"); 46MODULE_PARM_DESC(debug,"enable debug messages [mpeg]");
47 47
48#define dprintk(level,fmt, arg...) if (debug >= level) \ 48#define dprintk(level, fmt, arg...) do { \
49 printk(KERN_DEBUG "%s/2-mpeg: " fmt, dev->core->name, ## arg) 49 if (debug + 1 > level) \
50 printk(KERN_DEBUG "%s/2-mpeg: " fmt, dev->core->name, ## arg); \
51} while(0)
50 52
51#define mpeg_dbg(level,fmt, arg...) if (debug >= level) \ 53#define mpeg_dbg(level, fmt, arg...) do { \
52 printk(KERN_DEBUG "%s/2-mpeg: " fmt, core->name, ## arg) 54 if (debug + 1 > level) \
55 printk(KERN_DEBUG "%s/2-mpeg: " fmt, core->name, ## arg); \
56} while(0)
53 57
54#if defined(CONFIG_MODULES) && defined(MODULE) 58#if defined(CONFIG_MODULES) && defined(MODULE)
55static void request_module_async(struct work_struct *work) 59static void request_module_async(struct work_struct *work)
@@ -217,8 +221,7 @@ static int cx8802_restart_queue(struct cx8802_dev *dev,
217 return 0; 221 return 0;
218 buf = list_entry(q->queued.next, struct cx88_buffer, vb.queue); 222 buf = list_entry(q->queued.next, struct cx88_buffer, vb.queue);
219 if (NULL == prev) { 223 if (NULL == prev) {
220 list_del(&buf->vb.queue); 224 list_move_tail(&buf->vb.queue, &q->active);
221 list_add_tail(&buf->vb.queue,&q->active);
222 cx8802_start_dma(dev, q, buf); 225 cx8802_start_dma(dev, q, buf);
223 buf->vb.state = VIDEOBUF_ACTIVE; 226 buf->vb.state = VIDEOBUF_ACTIVE;
224 buf->count = q->count++; 227 buf->count = q->count++;
@@ -229,8 +232,7 @@ static int cx8802_restart_queue(struct cx8802_dev *dev,
229 } else if (prev->vb.width == buf->vb.width && 232 } else if (prev->vb.width == buf->vb.width &&
230 prev->vb.height == buf->vb.height && 233 prev->vb.height == buf->vb.height &&
231 prev->fmt == buf->fmt) { 234 prev->fmt == buf->fmt) {
232 list_del(&buf->vb.queue); 235 list_move_tail(&buf->vb.queue, &q->active);
233 list_add_tail(&buf->vb.queue,&q->active);
234 buf->vb.state = VIDEOBUF_ACTIVE; 236 buf->vb.state = VIDEOBUF_ACTIVE;
235 buf->count = q->count++; 237 buf->count = q->count++;
236 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); 238 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
diff --git a/drivers/media/pci/cx88/cx88.h b/drivers/media/pci/cx88/cx88.h
index 44ffc8b3d45f..ba0dba4a4d22 100644
--- a/drivers/media/pci/cx88/cx88.h
+++ b/drivers/media/pci/cx88/cx88.h
@@ -94,13 +94,13 @@ enum cx8802_board_access {
94/* ----------------------------------------------------------- */ 94/* ----------------------------------------------------------- */
95/* tv norms */ 95/* tv norms */
96 96
97static unsigned int inline norm_maxw(v4l2_std_id norm) 97static inline unsigned int norm_maxw(v4l2_std_id norm)
98{ 98{
99 return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 720 : 768; 99 return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 720 : 768;
100} 100}
101 101
102 102
103static unsigned int inline norm_maxh(v4l2_std_id norm) 103static inline unsigned int norm_maxh(v4l2_std_id norm)
104{ 104{
105 return (norm & V4L2_STD_625_50) ? 576 : 480; 105 return (norm & V4L2_STD_625_50) ? 576 : 480;
106} 106}
diff --git a/drivers/media/pci/dm1105/dm1105.c b/drivers/media/pci/dm1105/dm1105.c
index a609b3a9b146..f288ffcc4b6b 100644
--- a/drivers/media/pci/dm1105/dm1105.c
+++ b/drivers/media/pci/dm1105/dm1105.c
@@ -736,7 +736,7 @@ static irqreturn_t dm1105_irq(int irq, void *dev_id)
736 return IRQ_HANDLED; 736 return IRQ_HANDLED;
737} 737}
738 738
739int __devinit dm1105_ir_init(struct dm1105_dev *dm1105) 739static int __devinit dm1105_ir_init(struct dm1105_dev *dm1105)
740{ 740{
741 struct rc_dev *dev; 741 struct rc_dev *dev;
742 int err = -ENOMEM; 742 int err = -ENOMEM;
@@ -776,7 +776,7 @@ int __devinit dm1105_ir_init(struct dm1105_dev *dm1105)
776 return 0; 776 return 0;
777} 777}
778 778
779void __devexit dm1105_ir_exit(struct dm1105_dev *dm1105) 779static void __devexit dm1105_ir_exit(struct dm1105_dev *dm1105)
780{ 780{
781 rc_unregister_device(dm1105->ir.dev); 781 rc_unregister_device(dm1105->ir.dev);
782} 782}
@@ -1128,8 +1128,10 @@ static int __devinit dm1105_probe(struct pci_dev *pdev,
1128 INIT_WORK(&dev->work, dm1105_dmx_buffer); 1128 INIT_WORK(&dev->work, dm1105_dmx_buffer);
1129 sprintf(dev->wqn, "%s/%d", dvb_adapter->name, dvb_adapter->num); 1129 sprintf(dev->wqn, "%s/%d", dvb_adapter->name, dvb_adapter->num);
1130 dev->wq = create_singlethread_workqueue(dev->wqn); 1130 dev->wq = create_singlethread_workqueue(dev->wqn);
1131 if (!dev->wq) 1131 if (!dev->wq) {
1132 ret = -ENOMEM;
1132 goto err_dvb_net; 1133 goto err_dvb_net;
1134 }
1133 1135
1134 ret = request_irq(pdev->irq, dm1105_irq, IRQF_SHARED, 1136 ret = request_irq(pdev->irq, dm1105_irq, IRQF_SHARED,
1135 DRIVER_NAME, dev); 1137 DRIVER_NAME, dev);
diff --git a/drivers/media/pci/ivtv/ivtv-alsa-main.c b/drivers/media/pci/ivtv/ivtv-alsa-main.c
index 8deab1629b3b..4a221c693995 100644
--- a/drivers/media/pci/ivtv/ivtv-alsa-main.c
+++ b/drivers/media/pci/ivtv/ivtv-alsa-main.c
@@ -205,7 +205,7 @@ err_exit:
205 return ret; 205 return ret;
206} 206}
207 207
208int ivtv_alsa_load(struct ivtv *itv) 208static int __init ivtv_alsa_load(struct ivtv *itv)
209{ 209{
210 struct v4l2_device *v4l2_dev = &itv->v4l2_dev; 210 struct v4l2_device *v4l2_dev = &itv->v4l2_dev;
211 struct ivtv_stream *s; 211 struct ivtv_stream *s;
diff --git a/drivers/media/pci/ivtv/ivtv-alsa-pcm.c b/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
index f7022bd58ffd..e1863dbf4edc 100644
--- a/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
+++ b/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
@@ -37,6 +37,7 @@
37#include "ivtv-streams.h" 37#include "ivtv-streams.h"
38#include "ivtv-fileops.h" 38#include "ivtv-fileops.h"
39#include "ivtv-alsa.h" 39#include "ivtv-alsa.h"
40#include "ivtv-alsa-pcm.h"
40 41
41static unsigned int pcm_debug; 42static unsigned int pcm_debug;
42module_param(pcm_debug, int, 0644); 43module_param(pcm_debug, int, 0644);
@@ -69,8 +70,9 @@ static struct snd_pcm_hardware snd_ivtv_hw_capture = {
69 .periods_max = 98, /* 12544, */ 70 .periods_max = 98, /* 12544, */
70}; 71};
71 72
72void ivtv_alsa_announce_pcm_data(struct snd_ivtv_card *itvsc, u8 *pcm_data, 73static void ivtv_alsa_announce_pcm_data(struct snd_ivtv_card *itvsc,
73 size_t num_bytes) 74 u8 *pcm_data,
75 size_t num_bytes)
74{ 76{
75 struct snd_pcm_substream *substream; 77 struct snd_pcm_substream *substream;
76 struct snd_pcm_runtime *runtime; 78 struct snd_pcm_runtime *runtime;
diff --git a/drivers/media/pci/ivtv/ivtv-alsa-pcm.h b/drivers/media/pci/ivtv/ivtv-alsa-pcm.h
index 5ab18319ea4d..23dfe0d12400 100644
--- a/drivers/media/pci/ivtv/ivtv-alsa-pcm.h
+++ b/drivers/media/pci/ivtv/ivtv-alsa-pcm.h
@@ -21,7 +21,3 @@
21 */ 21 */
22 22
23int __init snd_ivtv_pcm_create(struct snd_ivtv_card *itvsc); 23int __init snd_ivtv_pcm_create(struct snd_ivtv_card *itvsc);
24
25/* Used by ivtv driver to announce the PCM data to the module */
26void ivtv_alsa_announce_pcm_data(struct snd_ivtv_card *card, u8 *pcm_data,
27 size_t num_bytes);
diff --git a/drivers/media/pci/ivtv/ivtv-firmware.c b/drivers/media/pci/ivtv/ivtv-firmware.c
index 6ec7705af555..68387d4369d6 100644
--- a/drivers/media/pci/ivtv/ivtv-firmware.c
+++ b/drivers/media/pci/ivtv/ivtv-firmware.c
@@ -276,7 +276,7 @@ void ivtv_init_mpeg_decoder(struct ivtv *itv)
276} 276}
277 277
278/* Try to restart the card & restore previous settings */ 278/* Try to restart the card & restore previous settings */
279int ivtv_firmware_restart(struct ivtv *itv) 279static int ivtv_firmware_restart(struct ivtv *itv)
280{ 280{
281 int rc = 0; 281 int rc = 0;
282 v4l2_std_id std; 282 v4l2_std_id std;
diff --git a/drivers/media/pci/ivtv/ivtv-i2c.c b/drivers/media/pci/ivtv/ivtv-i2c.c
index d47f41a0ef66..46e262becb67 100644
--- a/drivers/media/pci/ivtv/ivtv-i2c.c
+++ b/drivers/media/pci/ivtv/ivtv-i2c.c
@@ -200,21 +200,21 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
200 init_data->ir_codes = RC_MAP_AVERMEDIA_CARDBUS; 200 init_data->ir_codes = RC_MAP_AVERMEDIA_CARDBUS;
201 init_data->internal_get_key_func = 201 init_data->internal_get_key_func =
202 IR_KBD_GET_KEY_AVERMEDIA_CARDBUS; 202 IR_KBD_GET_KEY_AVERMEDIA_CARDBUS;
203 init_data->type = RC_TYPE_OTHER; 203 init_data->type = RC_BIT_OTHER;
204 init_data->name = "AVerMedia AVerTV card"; 204 init_data->name = "AVerMedia AVerTV card";
205 break; 205 break;
206 case IVTV_HW_I2C_IR_RX_HAUP_EXT: 206 case IVTV_HW_I2C_IR_RX_HAUP_EXT:
207 case IVTV_HW_I2C_IR_RX_HAUP_INT: 207 case IVTV_HW_I2C_IR_RX_HAUP_INT:
208 init_data->ir_codes = RC_MAP_HAUPPAUGE; 208 init_data->ir_codes = RC_MAP_HAUPPAUGE;
209 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP; 209 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP;
210 init_data->type = RC_TYPE_RC5; 210 init_data->type = RC_BIT_RC5;
211 init_data->name = itv->card_name; 211 init_data->name = itv->card_name;
212 break; 212 break;
213 case IVTV_HW_Z8F0811_IR_RX_HAUP: 213 case IVTV_HW_Z8F0811_IR_RX_HAUP:
214 /* Default to grey remote */ 214 /* Default to grey remote */
215 init_data->ir_codes = RC_MAP_HAUPPAUGE; 215 init_data->ir_codes = RC_MAP_HAUPPAUGE;
216 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; 216 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
217 init_data->type = RC_TYPE_RC5; 217 init_data->type = RC_BIT_RC5;
218 init_data->name = itv->card_name; 218 init_data->name = itv->card_name;
219 break; 219 break;
220 case IVTV_HW_I2C_IR_RX_ADAPTEC: 220 case IVTV_HW_I2C_IR_RX_ADAPTEC:
@@ -222,7 +222,7 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
222 init_data->name = itv->card_name; 222 init_data->name = itv->card_name;
223 /* FIXME: The protocol and RC_MAP needs to be corrected */ 223 /* FIXME: The protocol and RC_MAP needs to be corrected */
224 init_data->ir_codes = RC_MAP_EMPTY; 224 init_data->ir_codes = RC_MAP_EMPTY;
225 init_data->type = RC_TYPE_UNKNOWN; 225 init_data->type = RC_BIT_UNKNOWN;
226 break; 226 break;
227 } 227 }
228 228
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c b/drivers/media/pci/ivtv/ivtv-ioctl.c
index 949ae230e119..7a8b0d0b6127 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -993,7 +993,7 @@ int ivtv_s_input(struct file *file, void *fh, unsigned int inp)
993 v4l2_std_id std; 993 v4l2_std_id std;
994 int i; 994 int i;
995 995
996 if (inp < 0 || inp >= itv->nof_inputs) 996 if (inp >= itv->nof_inputs)
997 return -EINVAL; 997 return -EINVAL;
998 998
999 if (inp == itv->active_input) { 999 if (inp == itv->active_input) {
@@ -1168,7 +1168,7 @@ void ivtv_s_std_dec(struct ivtv *itv, v4l2_std_id *std)
1168 } 1168 }
1169} 1169}
1170 1170
1171int ivtv_s_std(struct file *file, void *fh, v4l2_std_id *std) 1171static int ivtv_s_std(struct file *file, void *fh, v4l2_std_id *std)
1172{ 1172{
1173 struct ivtv *itv = fh2id(fh)->itv; 1173 struct ivtv *itv = fh2id(fh)->itv;
1174 1174
diff --git a/drivers/media/pci/mantis/mantis_input.c b/drivers/media/pci/mantis/mantis_input.c
index db6d54d3fec0..0e5252e5c0ef 100644
--- a/drivers/media/pci/mantis/mantis_input.c
+++ b/drivers/media/pci/mantis/mantis_input.c
@@ -18,6 +18,8 @@
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/ 19*/
20 20
21#if 0 /* Currently unused */
22
21#include <media/rc-core.h> 23#include <media/rc-core.h>
22#include <linux/pci.h> 24#include <linux/pci.h>
23 25
@@ -150,10 +152,11 @@ out:
150 return err; 152 return err;
151} 153}
152 154
153int mantis_exit(struct mantis_pci *mantis) 155int mantis_init_exit(struct mantis_pci *mantis)
154{ 156{
155 rc_unregister_device(mantis->rc); 157 rc_unregister_device(mantis->rc);
156 rc_map_unregister(&ir_mantis_map); 158 rc_map_unregister(&ir_mantis_map);
157 return 0; 159 return 0;
158} 160}
159 161
162#endif
diff --git a/drivers/media/pci/mantis/mantis_uart.c b/drivers/media/pci/mantis/mantis_uart.c
index 85e977861b4a..a70719218631 100644
--- a/drivers/media/pci/mantis/mantis_uart.c
+++ b/drivers/media/pci/mantis/mantis_uart.c
@@ -61,7 +61,7 @@ static struct {
61 61
62#define UART_MAX_BUF 16 62#define UART_MAX_BUF 16
63 63
64int mantis_uart_read(struct mantis_pci *mantis, u8 *data) 64static int mantis_uart_read(struct mantis_pci *mantis, u8 *data)
65{ 65{
66 struct mantis_hwconfig *config = mantis->hwconfig; 66 struct mantis_hwconfig *config = mantis->hwconfig;
67 u32 stat = 0, i; 67 u32 stat = 0, i;
diff --git a/drivers/media/pci/mantis/mantis_vp1033.c b/drivers/media/pci/mantis/mantis_vp1033.c
index ad013e93ed11..115003e8d19d 100644
--- a/drivers/media/pci/mantis/mantis_vp1033.c
+++ b/drivers/media/pci/mantis/mantis_vp1033.c
@@ -83,7 +83,7 @@ u8 lgtdqcs001f_inittab[] = {
83#define MANTIS_MODEL_NAME "VP-1033" 83#define MANTIS_MODEL_NAME "VP-1033"
84#define MANTIS_DEV_TYPE "DVB-S/DSS" 84#define MANTIS_DEV_TYPE "DVB-S/DSS"
85 85
86int lgtdqcs001f_tuner_set(struct dvb_frontend *fe) 86static int lgtdqcs001f_tuner_set(struct dvb_frontend *fe)
87{ 87{
88 struct dtv_frontend_properties *p = &fe->dtv_property_cache; 88 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
89 struct mantis_pci *mantis = fe->dvb->priv; 89 struct mantis_pci *mantis = fe->dvb->priv;
@@ -115,8 +115,8 @@ int lgtdqcs001f_tuner_set(struct dvb_frontend *fe)
115 return 0; 115 return 0;
116} 116}
117 117
118int lgtdqcs001f_set_symbol_rate(struct dvb_frontend *fe, 118static int lgtdqcs001f_set_symbol_rate(struct dvb_frontend *fe,
119 u32 srate, u32 ratio) 119 u32 srate, u32 ratio)
120{ 120{
121 u8 aclk = 0; 121 u8 aclk = 0;
122 u8 bclk = 0; 122 u8 bclk = 0;
diff --git a/drivers/media/pci/meye/meye.c b/drivers/media/pci/meye/meye.c
index e5a76da86081..ae7d32027bf7 100644
--- a/drivers/media/pci/meye/meye.c
+++ b/drivers/media/pci/meye/meye.c
@@ -1945,7 +1945,7 @@ static struct pci_driver meye_driver = {
1945static int __init meye_init(void) 1945static int __init meye_init(void)
1946{ 1946{
1947 gbuffers = max(2, min((int)gbuffers, MEYE_MAX_BUFNBRS)); 1947 gbuffers = max(2, min((int)gbuffers, MEYE_MAX_BUFNBRS));
1948 if (gbufsize < 0 || gbufsize > MEYE_MAX_BUFSIZE) 1948 if (gbufsize > MEYE_MAX_BUFSIZE)
1949 gbufsize = MEYE_MAX_BUFSIZE; 1949 gbufsize = MEYE_MAX_BUFSIZE;
1950 gbufsize = PAGE_ALIGN(gbufsize); 1950 gbufsize = PAGE_ALIGN(gbufsize);
1951 printk(KERN_INFO "meye: using %d buffers with %dk (%dk total) " 1951 printk(KERN_INFO "meye: using %d buffers with %dk (%dk total) "
diff --git a/drivers/media/pci/ngene/ngene-cards.c b/drivers/media/pci/ngene/ngene-cards.c
index 96a13ed197d0..b38bce529566 100644
--- a/drivers/media/pci/ngene/ngene-cards.c
+++ b/drivers/media/pci/ngene/ngene-cards.c
@@ -425,8 +425,10 @@ static int ReadEEProm(struct i2c_adapter *adapter,
425 status = i2c_read_eeprom(adapter, 0x50, Addr, data, Length); 425 status = i2c_read_eeprom(adapter, 0x50, Addr, data, Length);
426 if (!status) { 426 if (!status) {
427 *pLength = EETag[2]; 427 *pLength = EETag[2];
428#if 0
428 if (Length < EETag[2]) 429 if (Length < EETag[2])
429 ; /*status=STATUS_BUFFER_OVERFLOW; */ 430 status = STATUS_BUFFER_OVERFLOW;
431#endif
430 } 432 }
431 } 433 }
432 return status; 434 return status;
diff --git a/drivers/media/pci/ngene/ngene-core.c b/drivers/media/pci/ngene/ngene-core.c
index c8e0d5b99d4c..8eeec4f50ccb 100644
--- a/drivers/media/pci/ngene/ngene-core.c
+++ b/drivers/media/pci/ngene/ngene-core.c
@@ -752,8 +752,8 @@ void set_transfer(struct ngene_channel *chan, int state)
752 if (chan->mode & NGENE_IO_TSIN) 752 if (chan->mode & NGENE_IO_TSIN)
753 chan->pBufferExchange = tsin_exchange; 753 chan->pBufferExchange = tsin_exchange;
754 spin_unlock_irq(&chan->state_lock); 754 spin_unlock_irq(&chan->state_lock);
755 } else 755 }
756 ;/* printk(KERN_INFO DEVICE_NAME ": lock=%08x\n", 756 /* else printk(KERN_INFO DEVICE_NAME ": lock=%08x\n",
757 ngreadl(0x9310)); */ 757 ngreadl(0x9310)); */
758 758
759 ret = ngene_command_stream_control(dev, chan->number, 759 ret = ngene_command_stream_control(dev, chan->number,
@@ -1691,7 +1691,8 @@ int __devinit ngene_probe(struct pci_dev *pci_dev,
1691 dev->i2c_current_bus = -1; 1691 dev->i2c_current_bus = -1;
1692 1692
1693 /* Register DVB adapters and devices for both channels */ 1693 /* Register DVB adapters and devices for both channels */
1694 if (init_channels(dev) < 0) 1694 stat = init_channels(dev);
1695 if (stat < 0)
1695 goto fail2; 1696 goto fail2;
1696 1697
1697 return 0; 1698 return 0;
diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c
index f2b37e05b964..8976d0e65813 100644
--- a/drivers/media/pci/saa7134/saa7134-core.c
+++ b/drivers/media/pci/saa7134/saa7134-core.c
@@ -944,8 +944,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
944 944
945 /* board config */ 945 /* board config */
946 dev->board = pci_id->driver_data; 946 dev->board = pci_id->driver_data;
947 if (card[dev->nr] >= 0 && 947 if ((unsigned)card[dev->nr] < saa7134_bcount)
948 card[dev->nr] < saa7134_bcount)
949 dev->board = card[dev->nr]; 948 dev->board = card[dev->nr];
950 if (SAA7134_BOARD_UNKNOWN == dev->board) 949 if (SAA7134_BOARD_UNKNOWN == dev->board)
951 must_configure_manually(0); 950 must_configure_manually(0);
diff --git a/drivers/media/pci/saa7134/saa7134-input.c b/drivers/media/pci/saa7134/saa7134-input.c
index 0f78f5e537e2..e761262f7475 100644
--- a/drivers/media/pci/saa7134/saa7134-input.c
+++ b/drivers/media/pci/saa7134/saa7134-input.c
@@ -990,7 +990,7 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev)
990 dev->init_data.name = "BeholdTV"; 990 dev->init_data.name = "BeholdTV";
991 dev->init_data.get_key = get_key_beholdm6xx; 991 dev->init_data.get_key = get_key_beholdm6xx;
992 dev->init_data.ir_codes = RC_MAP_BEHOLD; 992 dev->init_data.ir_codes = RC_MAP_BEHOLD;
993 dev->init_data.type = RC_TYPE_NEC; 993 dev->init_data.type = RC_BIT_NEC;
994 info.addr = 0x2d; 994 info.addr = 0x2d;
995 break; 995 break;
996 case SAA7134_BOARD_AVERMEDIA_CARDBUS_501: 996 case SAA7134_BOARD_AVERMEDIA_CARDBUS_501:
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c
index 4a77124ee70e..3abf52711e13 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -2511,7 +2511,7 @@ int saa7134_video_init1(struct saa7134_dev *dev)
2511 /* sanitycheck insmod options */ 2511 /* sanitycheck insmod options */
2512 if (gbuffers < 2 || gbuffers > VIDEO_MAX_FRAME) 2512 if (gbuffers < 2 || gbuffers > VIDEO_MAX_FRAME)
2513 gbuffers = 2; 2513 gbuffers = 2;
2514 if (gbufsize < 0 || gbufsize > gbufsize_max) 2514 if (gbufsize > gbufsize_max)
2515 gbufsize = gbufsize_max; 2515 gbufsize = gbufsize_max;
2516 gbufsize = (gbufsize + PAGE_SIZE - 1) & PAGE_MASK; 2516 gbufsize = (gbufsize + PAGE_SIZE - 1) & PAGE_MASK;
2517 2517
diff --git a/drivers/media/pci/saa7164/saa7164-api.c b/drivers/media/pci/saa7164/saa7164-api.c
index eff7135cf0e8..e042963d377d 100644
--- a/drivers/media/pci/saa7164/saa7164-api.c
+++ b/drivers/media/pci/saa7164/saa7164-api.c
@@ -165,7 +165,7 @@ int saa7164_api_set_vbi_format(struct saa7164_port *port)
165 return ret; 165 return ret;
166} 166}
167 167
168int saa7164_api_set_gop_size(struct saa7164_port *port) 168static int saa7164_api_set_gop_size(struct saa7164_port *port)
169{ 169{
170 struct saa7164_dev *dev = port->dev; 170 struct saa7164_dev *dev = port->dev;
171 struct tmComResEncVideoGopStructure gs; 171 struct tmComResEncVideoGopStructure gs;
@@ -619,7 +619,7 @@ int saa7164_api_get_videomux(struct saa7164_port *port)
619 return ret; 619 return ret;
620} 620}
621 621
622int saa7164_api_set_dif(struct saa7164_port *port, u8 reg, u8 val) 622static int saa7164_api_set_dif(struct saa7164_port *port, u8 reg, u8 val)
623{ 623{
624 struct saa7164_dev *dev = port->dev; 624 struct saa7164_dev *dev = port->dev;
625 625
@@ -822,8 +822,8 @@ int saa7164_api_read_eeprom(struct saa7164_dev *dev, u8 *buf, int buflen)
822 &reg[0], 128, buf); 822 &reg[0], 128, buf);
823} 823}
824 824
825int saa7164_api_configure_port_vbi(struct saa7164_dev *dev, 825static int saa7164_api_configure_port_vbi(struct saa7164_dev *dev,
826 struct saa7164_port *port) 826 struct saa7164_port *port)
827{ 827{
828 struct tmComResVBIFormatDescrHeader *fmt = &port->vbi_fmt_ntsc; 828 struct tmComResVBIFormatDescrHeader *fmt = &port->vbi_fmt_ntsc;
829 829
@@ -858,9 +858,10 @@ int saa7164_api_configure_port_vbi(struct saa7164_dev *dev,
858 return 0; 858 return 0;
859} 859}
860 860
861int saa7164_api_configure_port_mpeg2ts(struct saa7164_dev *dev, 861static int
862 struct saa7164_port *port, 862saa7164_api_configure_port_mpeg2ts(struct saa7164_dev *dev,
863 struct tmComResTSFormatDescrHeader *tsfmt) 863 struct saa7164_port *port,
864 struct tmComResTSFormatDescrHeader *tsfmt)
864{ 865{
865 dprintk(DBGLVL_API, " bFormatIndex = 0x%x\n", tsfmt->bFormatIndex); 866 dprintk(DBGLVL_API, " bFormatIndex = 0x%x\n", tsfmt->bFormatIndex);
866 dprintk(DBGLVL_API, " bDataOffset = 0x%x\n", tsfmt->bDataOffset); 867 dprintk(DBGLVL_API, " bDataOffset = 0x%x\n", tsfmt->bDataOffset);
@@ -892,9 +893,10 @@ int saa7164_api_configure_port_mpeg2ts(struct saa7164_dev *dev,
892 return 0; 893 return 0;
893} 894}
894 895
895int saa7164_api_configure_port_mpeg2ps(struct saa7164_dev *dev, 896static int
896 struct saa7164_port *port, 897saa7164_api_configure_port_mpeg2ps(struct saa7164_dev *dev,
897 struct tmComResPSFormatDescrHeader *fmt) 898 struct saa7164_port *port,
899 struct tmComResPSFormatDescrHeader *fmt)
898{ 900{
899 dprintk(DBGLVL_API, " bFormatIndex = 0x%x\n", fmt->bFormatIndex); 901 dprintk(DBGLVL_API, " bFormatIndex = 0x%x\n", fmt->bFormatIndex);
900 dprintk(DBGLVL_API, " wPacketLength= 0x%x\n", fmt->wPacketLength); 902 dprintk(DBGLVL_API, " wPacketLength= 0x%x\n", fmt->wPacketLength);
@@ -925,7 +927,7 @@ int saa7164_api_configure_port_mpeg2ps(struct saa7164_dev *dev,
925 return 0; 927 return 0;
926} 928}
927 929
928int saa7164_api_dump_subdevs(struct saa7164_dev *dev, u8 *buf, int len) 930static int saa7164_api_dump_subdevs(struct saa7164_dev *dev, u8 *buf, int len)
929{ 931{
930 struct saa7164_port *tsport = NULL; 932 struct saa7164_port *tsport = NULL;
931 struct saa7164_port *encport = NULL; 933 struct saa7164_port *encport = NULL;
@@ -1486,7 +1488,7 @@ int saa7164_api_i2c_write(struct saa7164_i2c *bus, u8 addr, u32 datalen,
1486 return ret == SAA_OK ? 0 : -EIO; 1488 return ret == SAA_OK ? 0 : -EIO;
1487} 1489}
1488 1490
1489int saa7164_api_modify_gpio(struct saa7164_dev *dev, u8 unitid, 1491static int saa7164_api_modify_gpio(struct saa7164_dev *dev, u8 unitid,
1490 u8 pin, u8 state) 1492 u8 pin, u8 state)
1491{ 1493{
1492 int ret; 1494 int ret;
diff --git a/drivers/media/pci/saa7164/saa7164-bus.c b/drivers/media/pci/saa7164/saa7164-bus.c
index a7f58a998752..5f6f3094c44e 100644
--- a/drivers/media/pci/saa7164/saa7164-bus.c
+++ b/drivers/media/pci/saa7164/saa7164-bus.c
@@ -81,7 +81,7 @@ void saa7164_bus_dump(struct saa7164_dev *dev)
81} 81}
82 82
83/* Intensionally throw a BUG() if the state of the message bus looks corrupt */ 83/* Intensionally throw a BUG() if the state of the message bus looks corrupt */
84void saa7164_bus_verify(struct saa7164_dev *dev) 84static void saa7164_bus_verify(struct saa7164_dev *dev)
85{ 85{
86 struct tmComResBusInfo *b = &dev->bus; 86 struct tmComResBusInfo *b = &dev->bus;
87 int bug = 0; 87 int bug = 0;
@@ -106,8 +106,8 @@ void saa7164_bus_verify(struct saa7164_dev *dev)
106 } 106 }
107} 107}
108 108
109void saa7164_bus_dumpmsg(struct saa7164_dev *dev, struct tmComResInfo* m, 109static void saa7164_bus_dumpmsg(struct saa7164_dev *dev, struct tmComResInfo *m,
110 void *buf) 110 void *buf)
111{ 111{
112 dprintk(DBGLVL_BUS, "Dumping msg structure:\n"); 112 dprintk(DBGLVL_BUS, "Dumping msg structure:\n");
113 dprintk(DBGLVL_BUS, " .id = %d\n", m->id); 113 dprintk(DBGLVL_BUS, " .id = %d\n", m->id);
diff --git a/drivers/media/pci/saa7164/saa7164-cmd.c b/drivers/media/pci/saa7164/saa7164-cmd.c
index 62fac7f9d04e..cfabcbacc33d 100644
--- a/drivers/media/pci/saa7164/saa7164-cmd.c
+++ b/drivers/media/pci/saa7164/saa7164-cmd.c
@@ -23,7 +23,7 @@
23 23
24#include "saa7164.h" 24#include "saa7164.h"
25 25
26int saa7164_cmd_alloc_seqno(struct saa7164_dev *dev) 26static int saa7164_cmd_alloc_seqno(struct saa7164_dev *dev)
27{ 27{
28 int i, ret = -1; 28 int i, ret = -1;
29 29
@@ -42,7 +42,7 @@ int saa7164_cmd_alloc_seqno(struct saa7164_dev *dev)
42 return ret; 42 return ret;
43} 43}
44 44
45void saa7164_cmd_free_seqno(struct saa7164_dev *dev, u8 seqno) 45static void saa7164_cmd_free_seqno(struct saa7164_dev *dev, u8 seqno)
46{ 46{
47 mutex_lock(&dev->lock); 47 mutex_lock(&dev->lock);
48 if ((dev->cmds[seqno].inuse == 1) && 48 if ((dev->cmds[seqno].inuse == 1) &&
@@ -54,7 +54,7 @@ void saa7164_cmd_free_seqno(struct saa7164_dev *dev, u8 seqno)
54 mutex_unlock(&dev->lock); 54 mutex_unlock(&dev->lock);
55} 55}
56 56
57void saa7164_cmd_timeout_seqno(struct saa7164_dev *dev, u8 seqno) 57static void saa7164_cmd_timeout_seqno(struct saa7164_dev *dev, u8 seqno)
58{ 58{
59 mutex_lock(&dev->lock); 59 mutex_lock(&dev->lock);
60 if ((dev->cmds[seqno].inuse == 1) && 60 if ((dev->cmds[seqno].inuse == 1) &&
@@ -64,7 +64,7 @@ void saa7164_cmd_timeout_seqno(struct saa7164_dev *dev, u8 seqno)
64 mutex_unlock(&dev->lock); 64 mutex_unlock(&dev->lock);
65} 65}
66 66
67u32 saa7164_cmd_timeout_get(struct saa7164_dev *dev, u8 seqno) 67static u32 saa7164_cmd_timeout_get(struct saa7164_dev *dev, u8 seqno)
68{ 68{
69 int ret = 0; 69 int ret = 0;
70 70
@@ -132,7 +132,7 @@ int saa7164_irq_dequeue(struct saa7164_dev *dev)
132 132
133/* Commands to the f/w get marshelled to/from this code then onto the PCI 133/* Commands to the f/w get marshelled to/from this code then onto the PCI
134 * -bus/c running buffer. */ 134 * -bus/c running buffer. */
135int saa7164_cmd_dequeue(struct saa7164_dev *dev) 135static int saa7164_cmd_dequeue(struct saa7164_dev *dev)
136{ 136{
137 int loop = 1; 137 int loop = 1;
138 int ret; 138 int ret;
@@ -186,8 +186,8 @@ int saa7164_cmd_dequeue(struct saa7164_dev *dev)
186 return SAA_OK; 186 return SAA_OK;
187} 187}
188 188
189int saa7164_cmd_set(struct saa7164_dev *dev, struct tmComResInfo *msg, 189static int saa7164_cmd_set(struct saa7164_dev *dev, struct tmComResInfo *msg,
190 void *buf) 190 void *buf)
191{ 191{
192 struct tmComResBusInfo *bus = &dev->bus; 192 struct tmComResBusInfo *bus = &dev->bus;
193 u8 cmd_sent; 193 u8 cmd_sent;
@@ -259,7 +259,7 @@ out:
259/* Wait for a signal event, without holding a mutex. Either return TIMEOUT if 259/* Wait for a signal event, without holding a mutex. Either return TIMEOUT if
260 * the event never occurred, or SAA_OK if it was signaled during the wait. 260 * the event never occurred, or SAA_OK if it was signaled during the wait.
261 */ 261 */
262int saa7164_cmd_wait(struct saa7164_dev *dev, u8 seqno) 262static int saa7164_cmd_wait(struct saa7164_dev *dev, u8 seqno)
263{ 263{
264 wait_queue_head_t *q = NULL; 264 wait_queue_head_t *q = NULL;
265 int ret = SAA_BUS_TIMEOUT; 265 int ret = SAA_BUS_TIMEOUT;
diff --git a/drivers/media/pci/saa7164/saa7164-core.c b/drivers/media/pci/saa7164/saa7164-core.c
index 2c9ad878bef3..063047f56766 100644
--- a/drivers/media/pci/saa7164/saa7164-core.c
+++ b/drivers/media/pci/saa7164/saa7164-core.c
@@ -410,7 +410,7 @@ static void saa7164_work_enchandler(struct work_struct *w)
410 } else 410 } else
411 rp = (port->last_svc_rp + 1) % 8; 411 rp = (port->last_svc_rp + 1) % 8;
412 412
413 if ((rp < 0) || (rp > (port->hwcfg.buffercount - 1))) { 413 if (rp > (port->hwcfg.buffercount - 1)) {
414 printk(KERN_ERR "%s() illegal rp count %d\n", __func__, rp); 414 printk(KERN_ERR "%s() illegal rp count %d\n", __func__, rp);
415 break; 415 break;
416 } 416 }
@@ -486,7 +486,7 @@ static void saa7164_work_vbihandler(struct work_struct *w)
486 } else 486 } else
487 rp = (port->last_svc_rp + 1) % 8; 487 rp = (port->last_svc_rp + 1) % 8;
488 488
489 if ((rp < 0) || (rp > (port->hwcfg.buffercount - 1))) { 489 if (rp > (port->hwcfg.buffercount - 1)) {
490 printk(KERN_ERR "%s() illegal rp count %d\n", __func__, rp); 490 printk(KERN_ERR "%s() illegal rp count %d\n", __func__, rp);
491 break; 491 break;
492 } 492 }
diff --git a/drivers/media/pci/saa7164/saa7164-encoder.c b/drivers/media/pci/saa7164/saa7164-encoder.c
index a9ed686ad08a..994018e2d0d6 100644
--- a/drivers/media/pci/saa7164/saa7164-encoder.c
+++ b/drivers/media/pci/saa7164/saa7164-encoder.c
@@ -1101,7 +1101,8 @@ static int fops_release(struct file *file)
1101 return 0; 1101 return 0;
1102} 1102}
1103 1103
1104struct saa7164_user_buffer *saa7164_enc_next_buf(struct saa7164_port *port) 1104static struct
1105saa7164_user_buffer *saa7164_enc_next_buf(struct saa7164_port *port)
1105{ 1106{
1106 struct saa7164_user_buffer *ubuf = NULL; 1107 struct saa7164_user_buffer *ubuf = NULL;
1107 struct saa7164_dev *dev = port->dev; 1108 struct saa7164_dev *dev = port->dev;
@@ -1287,8 +1288,8 @@ static const struct v4l2_file_operations mpeg_fops = {
1287 .unlocked_ioctl = video_ioctl2, 1288 .unlocked_ioctl = video_ioctl2,
1288}; 1289};
1289 1290
1290int saa7164_g_chip_ident(struct file *file, void *fh, 1291static int saa7164_g_chip_ident(struct file *file, void *fh,
1291 struct v4l2_dbg_chip_ident *chip) 1292 struct v4l2_dbg_chip_ident *chip)
1292{ 1293{
1293 struct saa7164_port *port = ((struct saa7164_encoder_fh *)fh)->port; 1294 struct saa7164_port *port = ((struct saa7164_encoder_fh *)fh)->port;
1294 struct saa7164_dev *dev = port->dev; 1295 struct saa7164_dev *dev = port->dev;
@@ -1297,8 +1298,8 @@ int saa7164_g_chip_ident(struct file *file, void *fh,
1297 return 0; 1298 return 0;
1298} 1299}
1299 1300
1300int saa7164_g_register(struct file *file, void *fh, 1301static int saa7164_g_register(struct file *file, void *fh,
1301 struct v4l2_dbg_register *reg) 1302 struct v4l2_dbg_register *reg)
1302{ 1303{
1303 struct saa7164_port *port = ((struct saa7164_encoder_fh *)fh)->port; 1304 struct saa7164_port *port = ((struct saa7164_encoder_fh *)fh)->port;
1304 struct saa7164_dev *dev = port->dev; 1305 struct saa7164_dev *dev = port->dev;
@@ -1310,8 +1311,8 @@ int saa7164_g_register(struct file *file, void *fh,
1310 return 0; 1311 return 0;
1311} 1312}
1312 1313
1313int saa7164_s_register(struct file *file, void *fh, 1314static int saa7164_s_register(struct file *file, void *fh,
1314 struct v4l2_dbg_register *reg) 1315 struct v4l2_dbg_register *reg)
1315{ 1316{
1316 struct saa7164_port *port = ((struct saa7164_encoder_fh *)fh)->port; 1317 struct saa7164_port *port = ((struct saa7164_encoder_fh *)fh)->port;
1317 struct saa7164_dev *dev = port->dev; 1318 struct saa7164_dev *dev = port->dev;
diff --git a/drivers/media/pci/saa7164/saa7164-fw.c b/drivers/media/pci/saa7164/saa7164-fw.c
index a266bf0169e6..86763203d61d 100644
--- a/drivers/media/pci/saa7164/saa7164-fw.c
+++ b/drivers/media/pci/saa7164/saa7164-fw.c
@@ -37,7 +37,7 @@ struct fw_header {
37 u32 version; 37 u32 version;
38}; 38};
39 39
40int saa7164_dl_wait_ack(struct saa7164_dev *dev, u32 reg) 40static int saa7164_dl_wait_ack(struct saa7164_dev *dev, u32 reg)
41{ 41{
42 u32 timeout = SAA_DEVICE_TIMEOUT; 42 u32 timeout = SAA_DEVICE_TIMEOUT;
43 while ((saa7164_readl(reg) & 0x01) == 0) { 43 while ((saa7164_readl(reg) & 0x01) == 0) {
@@ -53,7 +53,7 @@ int saa7164_dl_wait_ack(struct saa7164_dev *dev, u32 reg)
53 return 0; 53 return 0;
54} 54}
55 55
56int saa7164_dl_wait_clr(struct saa7164_dev *dev, u32 reg) 56static int saa7164_dl_wait_clr(struct saa7164_dev *dev, u32 reg)
57{ 57{
58 u32 timeout = SAA_DEVICE_TIMEOUT; 58 u32 timeout = SAA_DEVICE_TIMEOUT;
59 while (saa7164_readl(reg) & 0x01) { 59 while (saa7164_readl(reg) & 0x01) {
@@ -71,8 +71,8 @@ int saa7164_dl_wait_clr(struct saa7164_dev *dev, u32 reg)
71 71
72/* TODO: move dlflags into dev-> and change to write/readl/b */ 72/* TODO: move dlflags into dev-> and change to write/readl/b */
73/* TODO: Excessive levels of debug */ 73/* TODO: Excessive levels of debug */
74int saa7164_downloadimage(struct saa7164_dev *dev, u8 *src, u32 srcsize, 74static int saa7164_downloadimage(struct saa7164_dev *dev, u8 *src, u32 srcsize,
75 u32 dlflags, u8 *dst, u32 dstsize) 75 u32 dlflags, u8 *dst, u32 dstsize)
76{ 76{
77 u32 reg, timeout, offset; 77 u32 reg, timeout, offset;
78 u8 *srcbuf = NULL; 78 u8 *srcbuf = NULL;
diff --git a/drivers/media/pci/saa7164/saa7164-vbi.c b/drivers/media/pci/saa7164/saa7164-vbi.c
index d8e6c8f14079..b4532299c0ed 100644
--- a/drivers/media/pci/saa7164/saa7164-vbi.c
+++ b/drivers/media/pci/saa7164/saa7164-vbi.c
@@ -984,7 +984,8 @@ out:
984 return ret; 984 return ret;
985} 985}
986 986
987int saa7164_vbi_fmt(struct file *file, void *priv, struct v4l2_format *f) 987static int saa7164_vbi_fmt(struct file *file, void *priv,
988 struct v4l2_format *f)
988{ 989{
989 /* ntsc */ 990 /* ntsc */
990 f->fmt.vbi.samples_per_line = 1600; 991 f->fmt.vbi.samples_per_line = 1600;
@@ -1047,7 +1048,8 @@ static int fops_release(struct file *file)
1047 return 0; 1048 return 0;
1048} 1049}
1049 1050
1050struct saa7164_user_buffer *saa7164_vbi_next_buf(struct saa7164_port *port) 1051static struct
1052saa7164_user_buffer *saa7164_vbi_next_buf(struct saa7164_port *port)
1051{ 1053{
1052 struct saa7164_user_buffer *ubuf = NULL; 1054 struct saa7164_user_buffer *ubuf = NULL;
1053 struct saa7164_dev *dev = port->dev; 1055 struct saa7164_dev *dev = port->dev;
diff --git a/drivers/media/pci/ttpci/av7110.h b/drivers/media/pci/ttpci/av7110.h
index 88b3b2d6cc0e..a378662b1dcf 100644
--- a/drivers/media/pci/ttpci/av7110.h
+++ b/drivers/media/pci/ttpci/av7110.h
@@ -6,6 +6,7 @@
6#include <linux/netdevice.h> 6#include <linux/netdevice.h>
7#include <linux/i2c.h> 7#include <linux/i2c.h>
8#include <linux/input.h> 8#include <linux/input.h>
9#include <linux/time.h>
9 10
10#include <linux/dvb/video.h> 11#include <linux/dvb/video.h>
11#include <linux/dvb/audio.h> 12#include <linux/dvb/audio.h>
diff --git a/drivers/media/pci/ttpci/budget-av.c b/drivers/media/pci/ttpci/budget-av.c
index 12ddb53c58dc..1f8b1bb0bf9f 100644
--- a/drivers/media/pci/ttpci/budget-av.c
+++ b/drivers/media/pci/ttpci/budget-av.c
@@ -1477,8 +1477,8 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
1477 1477
1478 if (saa7113_init(budget_av) == 0) { 1478 if (saa7113_init(budget_av) == 0) {
1479 budget_av->has_saa7113 = 1; 1479 budget_av->has_saa7113 = 1;
1480 1480 err = saa7146_vv_init(dev, &vv_data);
1481 if (0 != saa7146_vv_init(dev, &vv_data)) { 1481 if (err != 0) {
1482 /* fixme: proper cleanup here */ 1482 /* fixme: proper cleanup here */
1483 ERR("cannot init vv subsystem\n"); 1483 ERR("cannot init vv subsystem\n");
1484 return err; 1484 return err;
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 181c7686e412..3dcfea612c42 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -109,6 +109,18 @@ config VIDEO_OMAP3_DEBUG
109 ---help--- 109 ---help---
110 Enable debug messages on OMAP 3 camera controller driver. 110 Enable debug messages on OMAP 3 camera controller driver.
111 111
112config VIDEO_S3C_CAMIF
113 tristate "Samsung S3C24XX/S3C64XX SoC Camera Interface driver"
114 depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
115 depends on (PLAT_S3C64XX || PLAT_S3C24XX) && PM_RUNTIME
116 select VIDEOBUF2_DMA_CONTIG
117 ---help---
118 This is a v4l2 driver for s3c24xx and s3c64xx SoC series camera
119 host interface (CAMIF).
120
121 To compile this driver as a module, choose M here: the module
122 will be called s3c-camif.
123
112source "drivers/media/platform/soc_camera/Kconfig" 124source "drivers/media/platform/soc_camera/Kconfig"
113source "drivers/media/platform/s5p-fimc/Kconfig" 125source "drivers/media/platform/s5p-fimc/Kconfig"
114source "drivers/media/platform/s5p-tv/Kconfig" 126source "drivers/media/platform/s5p-tv/Kconfig"
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index baaa55026c8e..4817d2802171 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_VIDEO_CODA) += coda.o
27 27
28obj-$(CONFIG_VIDEO_MEM2MEM_DEINTERLACE) += m2m-deinterlace.o 28obj-$(CONFIG_VIDEO_MEM2MEM_DEINTERLACE) += m2m-deinterlace.o
29 29
30obj-$(CONFIG_VIDEO_S3C_CAMIF) += s3c-camif/
30obj-$(CONFIG_VIDEO_SAMSUNG_S5P_FIMC) += s5p-fimc/ 31obj-$(CONFIG_VIDEO_SAMSUNG_S5P_FIMC) += s5p-fimc/
31obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) += s5p-jpeg/ 32obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) += s5p-jpeg/
32obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC) += s5p-mfc/ 33obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC) += s5p-mfc/
diff --git a/drivers/media/platform/blackfin/bfin_capture.c b/drivers/media/platform/blackfin/bfin_capture.c
index cb2eb26850b1..ec476ef5b709 100644
--- a/drivers/media/platform/blackfin/bfin_capture.c
+++ b/drivers/media/platform/blackfin/bfin_capture.c
@@ -1050,19 +1050,7 @@ static struct platform_driver bcap_driver = {
1050 .probe = bcap_probe, 1050 .probe = bcap_probe,
1051 .remove = __devexit_p(bcap_remove), 1051 .remove = __devexit_p(bcap_remove),
1052}; 1052};
1053 1053module_platform_driver(bcap_driver);
1054static __init int bcap_init(void)
1055{
1056 return platform_driver_register(&bcap_driver);
1057}
1058
1059static __exit void bcap_exit(void)
1060{
1061 platform_driver_unregister(&bcap_driver);
1062}
1063
1064module_init(bcap_init);
1065module_exit(bcap_exit);
1066 1054
1067MODULE_DESCRIPTION("Analog Devices blackfin video capture driver"); 1055MODULE_DESCRIPTION("Analog Devices blackfin video capture driver");
1068MODULE_AUTHOR("Scott Jiang <Scott.Jiang.Linux@gmail.com>"); 1056MODULE_AUTHOR("Scott Jiang <Scott.Jiang.Linux@gmail.com>");
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index cd04ae252c30..7b8b547f2d51 100644
--- a/drivers/media/platform/coda.c
+++ b/drivers/media/platform/coda.c
@@ -1540,7 +1540,7 @@ static irqreturn_t coda_irq_handler(int irq, void *data)
1540 u32 wr_ptr, start_ptr; 1540 u32 wr_ptr, start_ptr;
1541 struct coda_ctx *ctx; 1541 struct coda_ctx *ctx;
1542 1542
1543 __cancel_delayed_work(&dev->timeout); 1543 cancel_delayed_work(&dev->timeout);
1544 1544
1545 /* read status register to attend the IRQ */ 1545 /* read status register to attend the IRQ */
1546 coda_read(dev, CODA_REG_BIT_INT_STATUS); 1546 coda_read(dev, CODA_REG_BIT_INT_STATUS);
@@ -1877,7 +1877,7 @@ static const struct coda_devtype coda_devdata[] = {
1877 1877
1878static struct platform_device_id coda_platform_ids[] = { 1878static struct platform_device_id coda_platform_ids[] = {
1879 { .name = "coda-imx27", .driver_data = CODA_IMX27 }, 1879 { .name = "coda-imx27", .driver_data = CODA_IMX27 },
1880 { .name = "coda-imx53", .driver_data = CODA_7541 }, 1880 { .name = "coda-imx53", .driver_data = CODA_IMX53 },
1881 { /* sentinel */ } 1881 { /* sentinel */ }
1882}; 1882};
1883MODULE_DEVICE_TABLE(platform, coda_platform_ids); 1883MODULE_DEVICE_TABLE(platform, coda_platform_ids);
diff --git a/drivers/media/platform/davinci/Kconfig b/drivers/media/platform/davinci/Kconfig
index 78e26d24f637..3c56037c82fc 100644
--- a/drivers/media/platform/davinci/Kconfig
+++ b/drivers/media/platform/davinci/Kconfig
@@ -101,7 +101,7 @@ config VIDEO_DM644X_VPBE
101 tristate "DM644X VPBE HW module" 101 tristate "DM644X VPBE HW module"
102 depends on ARCH_DAVINCI_DM644x 102 depends on ARCH_DAVINCI_DM644x
103 select VIDEO_VPSS_SYSTEM 103 select VIDEO_VPSS_SYSTEM
104 select VIDEOBUF_DMA_CONTIG 104 select VIDEOBUF2_DMA_CONTIG
105 help 105 help
106 Enables VPBE modules used for display on a DM644x 106 Enables VPBE modules used for display on a DM644x
107 SoC. 107 SoC.
diff --git a/drivers/media/platform/davinci/dm355_ccdc.c b/drivers/media/platform/davinci/dm355_ccdc.c
index ce0e4131c067..030950dcfb16 100644
--- a/drivers/media/platform/davinci/dm355_ccdc.c
+++ b/drivers/media/platform/davinci/dm355_ccdc.c
@@ -1003,7 +1003,7 @@ static int __devinit dm355_ccdc_probe(struct platform_device *pdev)
1003 status = PTR_ERR(ccdc_cfg.mclk); 1003 status = PTR_ERR(ccdc_cfg.mclk);
1004 goto fail_nomap; 1004 goto fail_nomap;
1005 } 1005 }
1006 if (clk_enable(ccdc_cfg.mclk)) { 1006 if (clk_prepare_enable(ccdc_cfg.mclk)) {
1007 status = -ENODEV; 1007 status = -ENODEV;
1008 goto fail_mclk; 1008 goto fail_mclk;
1009 } 1009 }
@@ -1014,7 +1014,7 @@ static int __devinit dm355_ccdc_probe(struct platform_device *pdev)
1014 status = PTR_ERR(ccdc_cfg.sclk); 1014 status = PTR_ERR(ccdc_cfg.sclk);
1015 goto fail_mclk; 1015 goto fail_mclk;
1016 } 1016 }
1017 if (clk_enable(ccdc_cfg.sclk)) { 1017 if (clk_prepare_enable(ccdc_cfg.sclk)) {
1018 status = -ENODEV; 1018 status = -ENODEV;
1019 goto fail_sclk; 1019 goto fail_sclk;
1020 } 1020 }
@@ -1034,8 +1034,10 @@ static int __devinit dm355_ccdc_probe(struct platform_device *pdev)
1034 printk(KERN_NOTICE "%s is registered with vpfe.\n", ccdc_hw_dev.name); 1034 printk(KERN_NOTICE "%s is registered with vpfe.\n", ccdc_hw_dev.name);
1035 return 0; 1035 return 0;
1036fail_sclk: 1036fail_sclk:
1037 clk_disable_unprepare(ccdc_cfg.sclk);
1037 clk_put(ccdc_cfg.sclk); 1038 clk_put(ccdc_cfg.sclk);
1038fail_mclk: 1039fail_mclk:
1040 clk_disable_unprepare(ccdc_cfg.mclk);
1039 clk_put(ccdc_cfg.mclk); 1041 clk_put(ccdc_cfg.mclk);
1040fail_nomap: 1042fail_nomap:
1041 iounmap(ccdc_cfg.base_addr); 1043 iounmap(ccdc_cfg.base_addr);
@@ -1050,6 +1052,8 @@ static int dm355_ccdc_remove(struct platform_device *pdev)
1050{ 1052{
1051 struct resource *res; 1053 struct resource *res;
1052 1054
1055 clk_disable_unprepare(ccdc_cfg.sclk);
1056 clk_disable_unprepare(ccdc_cfg.mclk);
1053 clk_put(ccdc_cfg.mclk); 1057 clk_put(ccdc_cfg.mclk);
1054 clk_put(ccdc_cfg.sclk); 1058 clk_put(ccdc_cfg.sclk);
1055 iounmap(ccdc_cfg.base_addr); 1059 iounmap(ccdc_cfg.base_addr);
diff --git a/drivers/media/platform/davinci/dm644x_ccdc.c b/drivers/media/platform/davinci/dm644x_ccdc.c
index ee7942b1996e..0215ab6ebc90 100644
--- a/drivers/media/platform/davinci/dm644x_ccdc.c
+++ b/drivers/media/platform/davinci/dm644x_ccdc.c
@@ -994,7 +994,7 @@ static int __devinit dm644x_ccdc_probe(struct platform_device *pdev)
994 status = PTR_ERR(ccdc_cfg.mclk); 994 status = PTR_ERR(ccdc_cfg.mclk);
995 goto fail_nomap; 995 goto fail_nomap;
996 } 996 }
997 if (clk_enable(ccdc_cfg.mclk)) { 997 if (clk_prepare_enable(ccdc_cfg.mclk)) {
998 status = -ENODEV; 998 status = -ENODEV;
999 goto fail_mclk; 999 goto fail_mclk;
1000 } 1000 }
@@ -1005,7 +1005,7 @@ static int __devinit dm644x_ccdc_probe(struct platform_device *pdev)
1005 status = PTR_ERR(ccdc_cfg.sclk); 1005 status = PTR_ERR(ccdc_cfg.sclk);
1006 goto fail_mclk; 1006 goto fail_mclk;
1007 } 1007 }
1008 if (clk_enable(ccdc_cfg.sclk)) { 1008 if (clk_prepare_enable(ccdc_cfg.sclk)) {
1009 status = -ENODEV; 1009 status = -ENODEV;
1010 goto fail_sclk; 1010 goto fail_sclk;
1011 } 1011 }
@@ -1013,8 +1013,10 @@ static int __devinit dm644x_ccdc_probe(struct platform_device *pdev)
1013 printk(KERN_NOTICE "%s is registered with vpfe.\n", ccdc_hw_dev.name); 1013 printk(KERN_NOTICE "%s is registered with vpfe.\n", ccdc_hw_dev.name);
1014 return 0; 1014 return 0;
1015fail_sclk: 1015fail_sclk:
1016 clk_disable_unprepare(ccdc_cfg.sclk);
1016 clk_put(ccdc_cfg.sclk); 1017 clk_put(ccdc_cfg.sclk);
1017fail_mclk: 1018fail_mclk:
1019 clk_disable_unprepare(ccdc_cfg.mclk);
1018 clk_put(ccdc_cfg.mclk); 1020 clk_put(ccdc_cfg.mclk);
1019fail_nomap: 1021fail_nomap:
1020 iounmap(ccdc_cfg.base_addr); 1022 iounmap(ccdc_cfg.base_addr);
@@ -1029,6 +1031,8 @@ static int dm644x_ccdc_remove(struct platform_device *pdev)
1029{ 1031{
1030 struct resource *res; 1032 struct resource *res;
1031 1033
1034 clk_disable_unprepare(ccdc_cfg.mclk);
1035 clk_disable_unprepare(ccdc_cfg.sclk);
1032 clk_put(ccdc_cfg.mclk); 1036 clk_put(ccdc_cfg.mclk);
1033 clk_put(ccdc_cfg.sclk); 1037 clk_put(ccdc_cfg.sclk);
1034 iounmap(ccdc_cfg.base_addr); 1038 iounmap(ccdc_cfg.base_addr);
@@ -1046,8 +1050,8 @@ static int dm644x_ccdc_suspend(struct device *dev)
1046 /* Disable CCDC */ 1050 /* Disable CCDC */
1047 ccdc_enable(0); 1051 ccdc_enable(0);
1048 /* Disable both master and slave clock */ 1052 /* Disable both master and slave clock */
1049 clk_disable(ccdc_cfg.mclk); 1053 clk_disable_unprepare(ccdc_cfg.mclk);
1050 clk_disable(ccdc_cfg.sclk); 1054 clk_disable_unprepare(ccdc_cfg.sclk);
1051 1055
1052 return 0; 1056 return 0;
1053} 1057}
@@ -1055,8 +1059,8 @@ static int dm644x_ccdc_suspend(struct device *dev)
1055static int dm644x_ccdc_resume(struct device *dev) 1059static int dm644x_ccdc_resume(struct device *dev)
1056{ 1060{
1057 /* Enable both master and slave clock */ 1061 /* Enable both master and slave clock */
1058 clk_enable(ccdc_cfg.mclk); 1062 clk_prepare_enable(ccdc_cfg.mclk);
1059 clk_enable(ccdc_cfg.sclk); 1063 clk_prepare_enable(ccdc_cfg.sclk);
1060 /* Restore CCDC context */ 1064 /* Restore CCDC context */
1061 ccdc_restore_context(); 1065 ccdc_restore_context();
1062 1066
diff --git a/drivers/media/platform/davinci/isif.c b/drivers/media/platform/davinci/isif.c
index b99d5423e3a8..2c26c3e1837e 100644
--- a/drivers/media/platform/davinci/isif.c
+++ b/drivers/media/platform/davinci/isif.c
@@ -1053,7 +1053,7 @@ static int __devinit isif_probe(struct platform_device *pdev)
1053 status = PTR_ERR(isif_cfg.mclk); 1053 status = PTR_ERR(isif_cfg.mclk);
1054 goto fail_mclk; 1054 goto fail_mclk;
1055 } 1055 }
1056 if (clk_enable(isif_cfg.mclk)) { 1056 if (clk_prepare_enable(isif_cfg.mclk)) {
1057 status = -ENODEV; 1057 status = -ENODEV;
1058 goto fail_mclk; 1058 goto fail_mclk;
1059 } 1059 }
@@ -1125,6 +1125,7 @@ fail_nobase_res:
1125 i--; 1125 i--;
1126 } 1126 }
1127fail_mclk: 1127fail_mclk:
1128 clk_disable_unprepare(isif_cfg.mclk);
1128 clk_put(isif_cfg.mclk); 1129 clk_put(isif_cfg.mclk);
1129 vpfe_unregister_ccdc_device(&isif_hw_dev); 1130 vpfe_unregister_ccdc_device(&isif_hw_dev);
1130 return status; 1131 return status;
@@ -1145,6 +1146,8 @@ static int isif_remove(struct platform_device *pdev)
1145 i++; 1146 i++;
1146 } 1147 }
1147 vpfe_unregister_ccdc_device(&isif_hw_dev); 1148 vpfe_unregister_ccdc_device(&isif_hw_dev);
1149 clk_disable_unprepare(isif_cfg.mclk);
1150 clk_put(isif_cfg.mclk);
1148 return 0; 1151 return 0;
1149} 1152}
1150 1153
diff --git a/drivers/media/platform/davinci/vpbe.c b/drivers/media/platform/davinci/vpbe.c
index 69d7a58c92c3..7f5cf9b347b2 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -612,7 +612,7 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
612 ret = PTR_ERR(vpbe_dev->dac_clk); 612 ret = PTR_ERR(vpbe_dev->dac_clk);
613 goto fail_mutex_unlock; 613 goto fail_mutex_unlock;
614 } 614 }
615 if (clk_enable(vpbe_dev->dac_clk)) { 615 if (clk_prepare_enable(vpbe_dev->dac_clk)) {
616 ret = -ENODEV; 616 ret = -ENODEV;
617 goto fail_mutex_unlock; 617 goto fail_mutex_unlock;
618 } 618 }
@@ -759,8 +759,10 @@ fail_kfree_encoders:
759fail_dev_unregister: 759fail_dev_unregister:
760 v4l2_device_unregister(&vpbe_dev->v4l2_dev); 760 v4l2_device_unregister(&vpbe_dev->v4l2_dev);
761fail_clk_put: 761fail_clk_put:
762 if (strcmp(vpbe_dev->cfg->module_name, "dm644x-vpbe-display") != 0) 762 if (strcmp(vpbe_dev->cfg->module_name, "dm644x-vpbe-display") != 0) {
763 clk_disable_unprepare(vpbe_dev->dac_clk);
763 clk_put(vpbe_dev->dac_clk); 764 clk_put(vpbe_dev->dac_clk);
765 }
764fail_mutex_unlock: 766fail_mutex_unlock:
765 mutex_unlock(&vpbe_dev->lock); 767 mutex_unlock(&vpbe_dev->lock);
766 return ret; 768 return ret;
@@ -777,8 +779,10 @@ fail_mutex_unlock:
777static void vpbe_deinitialize(struct device *dev, struct vpbe_device *vpbe_dev) 779static void vpbe_deinitialize(struct device *dev, struct vpbe_device *vpbe_dev)
778{ 780{
779 v4l2_device_unregister(&vpbe_dev->v4l2_dev); 781 v4l2_device_unregister(&vpbe_dev->v4l2_dev);
780 if (strcmp(vpbe_dev->cfg->module_name, "dm644x-vpbe-display") != 0) 782 if (strcmp(vpbe_dev->cfg->module_name, "dm644x-vpbe-display") != 0) {
783 clk_disable_unprepare(vpbe_dev->dac_clk);
781 clk_put(vpbe_dev->dac_clk); 784 clk_put(vpbe_dev->dac_clk);
785 }
782 786
783 kfree(vpbe_dev->amp); 787 kfree(vpbe_dev->amp);
784 kfree(vpbe_dev->encoders); 788 kfree(vpbe_dev->encoders);
diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c
index 161c77650e2f..2bfde7958fef 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -47,6 +47,9 @@ static int debug;
47 47
48module_param(debug, int, 0644); 48module_param(debug, int, 0644);
49 49
50static int vpbe_set_osd_display_params(struct vpbe_display *disp_dev,
51 struct vpbe_layer *layer);
52
50static int venc_is_second_field(struct vpbe_display *disp_dev) 53static int venc_is_second_field(struct vpbe_display *disp_dev)
51{ 54{
52 struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev; 55 struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev;
@@ -73,10 +76,11 @@ static void vpbe_isr_even_field(struct vpbe_display *disp_obj,
73 if (layer->cur_frm == layer->next_frm) 76 if (layer->cur_frm == layer->next_frm)
74 return; 77 return;
75 ktime_get_ts(&timevalue); 78 ktime_get_ts(&timevalue);
76 layer->cur_frm->ts.tv_sec = timevalue.tv_sec; 79 layer->cur_frm->vb.v4l2_buf.timestamp.tv_sec =
77 layer->cur_frm->ts.tv_usec = timevalue.tv_nsec / NSEC_PER_USEC; 80 timevalue.tv_sec;
78 layer->cur_frm->state = VIDEOBUF_DONE; 81 layer->cur_frm->vb.v4l2_buf.timestamp.tv_usec =
79 wake_up_interruptible(&layer->cur_frm->done); 82 timevalue.tv_nsec / NSEC_PER_USEC;
83 vb2_buffer_done(&layer->cur_frm->vb, VB2_BUF_STATE_DONE);
80 /* Make cur_frm pointing to next_frm */ 84 /* Make cur_frm pointing to next_frm */
81 layer->cur_frm = layer->next_frm; 85 layer->cur_frm = layer->next_frm;
82} 86}
@@ -99,16 +103,14 @@ static void vpbe_isr_odd_field(struct vpbe_display *disp_obj,
99 * otherwise hold on current frame 103 * otherwise hold on current frame
100 * Get next from the buffer queue 104 * Get next from the buffer queue
101 */ 105 */
102 layer->next_frm = list_entry( 106 layer->next_frm = list_entry(layer->dma_queue.next,
103 layer->dma_queue.next, 107 struct vpbe_disp_buffer, list);
104 struct videobuf_buffer,
105 queue);
106 /* Remove that from the buffer queue */ 108 /* Remove that from the buffer queue */
107 list_del(&layer->next_frm->queue); 109 list_del(&layer->next_frm->list);
108 spin_unlock(&disp_obj->dma_queue_lock); 110 spin_unlock(&disp_obj->dma_queue_lock);
109 /* Mark state of the frame to active */ 111 /* Mark state of the frame to active */
110 layer->next_frm->state = VIDEOBUF_ACTIVE; 112 layer->next_frm->vb.state = VB2_BUF_STATE_ACTIVE;
111 addr = videobuf_to_dma_contig(layer->next_frm); 113 addr = vb2_dma_contig_plane_dma_addr(&layer->next_frm->vb, 0);
112 osd_device->ops.start_layer(osd_device, 114 osd_device->ops.start_layer(osd_device,
113 layer->layer_info.id, 115 layer->layer_info.id,
114 addr, 116 addr,
@@ -199,39 +201,29 @@ static irqreturn_t venc_isr(int irq, void *arg)
199 201
200/* 202/*
201 * vpbe_buffer_prepare() 203 * vpbe_buffer_prepare()
202 * This is the callback function called from videobuf_qbuf() function 204 * This is the callback function called from vb2_qbuf() function
203 * the buffer is prepared and user space virtual address is converted into 205 * the buffer is prepared and user space virtual address is converted into
204 * physical address 206 * physical address
205 */ 207 */
206static int vpbe_buffer_prepare(struct videobuf_queue *q, 208static int vpbe_buffer_prepare(struct vb2_buffer *vb)
207 struct videobuf_buffer *vb,
208 enum v4l2_field field)
209{ 209{
210 struct vpbe_fh *fh = q->priv_data; 210 struct vpbe_fh *fh = vb2_get_drv_priv(vb->vb2_queue);
211 struct vb2_queue *q = vb->vb2_queue;
211 struct vpbe_layer *layer = fh->layer; 212 struct vpbe_layer *layer = fh->layer;
212 struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; 213 struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev;
213 unsigned long addr; 214 unsigned long addr;
214 int ret;
215 215
216 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, 216 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev,
217 "vpbe_buffer_prepare\n"); 217 "vpbe_buffer_prepare\n");
218 218
219 /* If buffer is not initialized, initialize it */ 219 if (vb->state != VB2_BUF_STATE_ACTIVE &&
220 if (VIDEOBUF_NEEDS_INIT == vb->state) { 220 vb->state != VB2_BUF_STATE_PREPARED) {
221 vb->width = layer->pix_fmt.width; 221 vb2_set_plane_payload(vb, 0, layer->pix_fmt.sizeimage);
222 vb->height = layer->pix_fmt.height; 222 if (vb2_plane_vaddr(vb, 0) &&
223 vb->size = layer->pix_fmt.sizeimage; 223 vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0))
224 vb->field = field;
225
226 ret = videobuf_iolock(q, vb, NULL);
227 if (ret < 0) {
228 v4l2_err(&vpbe_dev->v4l2_dev, "Failed to map \
229 user address\n");
230 return -EINVAL; 224 return -EINVAL;
231 }
232
233 addr = videobuf_to_dma_contig(vb);
234 225
226 addr = vb2_dma_contig_plane_dma_addr(vb, 0);
235 if (q->streaming) { 227 if (q->streaming) {
236 if (!IS_ALIGNED(addr, 8)) { 228 if (!IS_ALIGNED(addr, 8)) {
237 v4l2_err(&vpbe_dev->v4l2_dev, 229 v4l2_err(&vpbe_dev->v4l2_dev,
@@ -240,7 +232,6 @@ static int vpbe_buffer_prepare(struct videobuf_queue *q,
240 return -EINVAL; 232 return -EINVAL;
241 } 233 }
242 } 234 }
243 vb->state = VIDEOBUF_PREPARED;
244 } 235 }
245 return 0; 236 return 0;
246} 237}
@@ -249,22 +240,26 @@ static int vpbe_buffer_prepare(struct videobuf_queue *q,
249 * vpbe_buffer_setup() 240 * vpbe_buffer_setup()
250 * This function allocates memory for the buffers 241 * This function allocates memory for the buffers
251 */ 242 */
252static int vpbe_buffer_setup(struct videobuf_queue *q, 243static int
253 unsigned int *count, 244vpbe_buffer_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,
254 unsigned int *size) 245 unsigned int *nbuffers, unsigned int *nplanes,
246 unsigned int sizes[], void *alloc_ctxs[])
247
255{ 248{
256 /* Get the file handle object and layer object */ 249 /* Get the file handle object and layer object */
257 struct vpbe_fh *fh = q->priv_data; 250 struct vpbe_fh *fh = vb2_get_drv_priv(vq);
258 struct vpbe_layer *layer = fh->layer; 251 struct vpbe_layer *layer = fh->layer;
259 struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; 252 struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev;
260 253
261 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_buffer_setup\n"); 254 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_buffer_setup\n");
262 255
263 *size = layer->pix_fmt.sizeimage;
264
265 /* Store number of buffers allocated in numbuffer member */ 256 /* Store number of buffers allocated in numbuffer member */
266 if (*count < VPBE_DEFAULT_NUM_BUFS) 257 if (*nbuffers < VPBE_DEFAULT_NUM_BUFS)
267 *count = layer->numbuffers = VPBE_DEFAULT_NUM_BUFS; 258 *nbuffers = layer->numbuffers = VPBE_DEFAULT_NUM_BUFS;
259
260 *nplanes = 1;
261 sizes[0] = layer->pix_fmt.sizeimage;
262 alloc_ctxs[0] = layer->alloc_ctx;
268 263
269 return 0; 264 return 0;
270} 265}
@@ -273,11 +268,12 @@ static int vpbe_buffer_setup(struct videobuf_queue *q,
273 * vpbe_buffer_queue() 268 * vpbe_buffer_queue()
274 * This function adds the buffer to DMA queue 269 * This function adds the buffer to DMA queue
275 */ 270 */
276static void vpbe_buffer_queue(struct videobuf_queue *q, 271static void vpbe_buffer_queue(struct vb2_buffer *vb)
277 struct videobuf_buffer *vb)
278{ 272{
279 /* Get the file handle object and layer object */ 273 /* Get the file handle object and layer object */
280 struct vpbe_fh *fh = q->priv_data; 274 struct vpbe_fh *fh = vb2_get_drv_priv(vb->vb2_queue);
275 struct vpbe_disp_buffer *buf = container_of(vb,
276 struct vpbe_disp_buffer, vb);
281 struct vpbe_layer *layer = fh->layer; 277 struct vpbe_layer *layer = fh->layer;
282 struct vpbe_display *disp = fh->disp_dev; 278 struct vpbe_display *disp = fh->disp_dev;
283 struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; 279 struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev;
@@ -288,39 +284,125 @@ static void vpbe_buffer_queue(struct videobuf_queue *q,
288 284
289 /* add the buffer to the DMA queue */ 285 /* add the buffer to the DMA queue */
290 spin_lock_irqsave(&disp->dma_queue_lock, flags); 286 spin_lock_irqsave(&disp->dma_queue_lock, flags);
291 list_add_tail(&vb->queue, &layer->dma_queue); 287 list_add_tail(&buf->list, &layer->dma_queue);
292 spin_unlock_irqrestore(&disp->dma_queue_lock, flags); 288 spin_unlock_irqrestore(&disp->dma_queue_lock, flags);
293 /* Change state of the buffer */
294 vb->state = VIDEOBUF_QUEUED;
295} 289}
296 290
297/* 291/*
298 * vpbe_buffer_release() 292 * vpbe_buf_cleanup()
299 * This function is called from the videobuf layer to free memory allocated to 293 * This function is called from the vb2 layer to free memory allocated to
300 * the buffers 294 * the buffers
301 */ 295 */
302static void vpbe_buffer_release(struct videobuf_queue *q, 296static void vpbe_buf_cleanup(struct vb2_buffer *vb)
303 struct videobuf_buffer *vb)
304{ 297{
305 /* Get the file handle object and layer object */ 298 /* Get the file handle object and layer object */
306 struct vpbe_fh *fh = q->priv_data; 299 struct vpbe_fh *fh = vb2_get_drv_priv(vb->vb2_queue);
307 struct vpbe_layer *layer = fh->layer; 300 struct vpbe_layer *layer = fh->layer;
308 struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; 301 struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev;
302 struct vpbe_disp_buffer *buf = container_of(vb,
303 struct vpbe_disp_buffer, vb);
304 unsigned long flags;
309 305
310 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, 306 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev,
311 "vpbe_buffer_release\n"); 307 "vpbe_buf_cleanup\n");
308
309 spin_lock_irqsave(&layer->irqlock, flags);
310 if (vb->state == VB2_BUF_STATE_ACTIVE)
311 list_del_init(&buf->list);
312 spin_unlock_irqrestore(&layer->irqlock, flags);
313}
314
315static void vpbe_wait_prepare(struct vb2_queue *vq)
316{
317 struct vpbe_fh *fh = vb2_get_drv_priv(vq);
318 struct vpbe_layer *layer = fh->layer;
319
320 mutex_unlock(&layer->opslock);
321}
322
323static void vpbe_wait_finish(struct vb2_queue *vq)
324{
325 struct vpbe_fh *fh = vb2_get_drv_priv(vq);
326 struct vpbe_layer *layer = fh->layer;
327
328 mutex_lock(&layer->opslock);
329}
330
331static int vpbe_buffer_init(struct vb2_buffer *vb)
332{
333 struct vpbe_disp_buffer *buf = container_of(vb,
334 struct vpbe_disp_buffer, vb);
335
336 INIT_LIST_HEAD(&buf->list);
337 return 0;
338}
339
340static int vpbe_start_streaming(struct vb2_queue *vq, unsigned int count)
341{
342 struct vpbe_fh *fh = vb2_get_drv_priv(vq);
343 struct vpbe_layer *layer = fh->layer;
344 struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev;
345 int ret;
346
347 /* If buffer queue is empty, return error */
348 if (list_empty(&layer->dma_queue)) {
349 v4l2_err(&vpbe_dev->v4l2_dev, "buffer queue is empty\n");
350 return -EINVAL;
351 }
352 /* Get the next frame from the buffer queue */
353 layer->next_frm = layer->cur_frm = list_entry(layer->dma_queue.next,
354 struct vpbe_disp_buffer, list);
355 /* Remove buffer from the buffer queue */
356 list_del(&layer->cur_frm->list);
357 /* Mark state of the current frame to active */
358 layer->cur_frm->vb.state = VB2_BUF_STATE_ACTIVE;
359 /* Initialize field_id and started member */
360 layer->field_id = 0;
361
362 /* Set parameters in OSD and VENC */
363 ret = vpbe_set_osd_display_params(fh->disp_dev, layer);
364 if (ret < 0)
365 return ret;
312 366
313 if (V4L2_MEMORY_USERPTR != layer->memory) 367 /*
314 videobuf_dma_contig_free(q, vb); 368 * if request format is yuv420 semiplanar, need to
369 * enable both video windows
370 */
371 layer->started = 1;
372 layer->layer_first_int = 1;
373
374 return ret;
375}
376
377static int vpbe_stop_streaming(struct vb2_queue *vq)
378{
379 struct vpbe_fh *fh = vb2_get_drv_priv(vq);
380 struct vpbe_layer *layer = fh->layer;
381
382 if (!vb2_is_streaming(vq))
383 return 0;
384
385 /* release all active buffers */
386 while (!list_empty(&layer->dma_queue)) {
387 layer->next_frm = list_entry(layer->dma_queue.next,
388 struct vpbe_disp_buffer, list);
389 list_del(&layer->next_frm->list);
390 vb2_buffer_done(&layer->next_frm->vb, VB2_BUF_STATE_ERROR);
391 }
315 392
316 vb->state = VIDEOBUF_NEEDS_INIT; 393 return 0;
317} 394}
318 395
319static struct videobuf_queue_ops video_qops = { 396static struct vb2_ops video_qops = {
320 .buf_setup = vpbe_buffer_setup, 397 .queue_setup = vpbe_buffer_queue_setup,
398 .wait_prepare = vpbe_wait_prepare,
399 .wait_finish = vpbe_wait_finish,
400 .buf_init = vpbe_buffer_init,
321 .buf_prepare = vpbe_buffer_prepare, 401 .buf_prepare = vpbe_buffer_prepare,
402 .start_streaming = vpbe_start_streaming,
403 .stop_streaming = vpbe_stop_streaming,
404 .buf_cleanup = vpbe_buf_cleanup,
322 .buf_queue = vpbe_buffer_queue, 405 .buf_queue = vpbe_buffer_queue,
323 .buf_release = vpbe_buffer_release,
324}; 406};
325 407
326static 408static
@@ -345,7 +427,7 @@ static int vpbe_set_osd_display_params(struct vpbe_display *disp_dev,
345 unsigned long addr; 427 unsigned long addr;
346 int ret; 428 int ret;
347 429
348 addr = videobuf_to_dma_contig(layer->cur_frm); 430 addr = vb2_dma_contig_plane_dma_addr(&layer->cur_frm->vb, 0);
349 /* Set address in the display registers */ 431 /* Set address in the display registers */
350 osd_device->ops.start_layer(osd_device, 432 osd_device->ops.start_layer(osd_device,
351 layer->layer_info.id, 433 layer->layer_info.id,
@@ -620,9 +702,12 @@ static int vpbe_display_querycap(struct file *file, void *priv,
620 struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; 702 struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev;
621 703
622 cap->version = VPBE_DISPLAY_VERSION_CODE; 704 cap->version = VPBE_DISPLAY_VERSION_CODE;
623 cap->capabilities = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING; 705 cap->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
624 strlcpy(cap->driver, VPBE_DISPLAY_DRIVER, sizeof(cap->driver)); 706 cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
625 strlcpy(cap->bus_info, "platform", sizeof(cap->bus_info)); 707 snprintf(cap->driver, sizeof(cap->driver), "%s",
708 dev_name(vpbe_dev->pdev));
709 snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
710 dev_name(vpbe_dev->pdev));
626 strlcpy(cap->card, vpbe_dev->cfg->module_name, sizeof(cap->card)); 711 strlcpy(cap->card, vpbe_dev->cfg->module_name, sizeof(cap->card));
627 712
628 return 0; 713 return 0;
@@ -1161,7 +1246,7 @@ static int vpbe_display_streamoff(struct file *file, void *priv,
1161 osd_device->ops.disable_layer(osd_device, 1246 osd_device->ops.disable_layer(osd_device,
1162 layer->layer_info.id); 1247 layer->layer_info.id);
1163 layer->started = 0; 1248 layer->started = 0;
1164 ret = videobuf_streamoff(&layer->buffer_queue); 1249 ret = vb2_streamoff(&layer->buffer_queue, buf_type);
1165 1250
1166 return ret; 1251 return ret;
1167} 1252}
@@ -1199,46 +1284,15 @@ static int vpbe_display_streamon(struct file *file, void *priv,
1199 } 1284 }
1200 1285
1201 /* 1286 /*
1202 * Call videobuf_streamon to start streaming 1287 * Call vb2_streamon to start streaming
1203 * in videobuf 1288 * in videobuf
1204 */ 1289 */
1205 ret = videobuf_streamon(&layer->buffer_queue); 1290 ret = vb2_streamon(&layer->buffer_queue, buf_type);
1206 if (ret) { 1291 if (ret) {
1207 v4l2_err(&vpbe_dev->v4l2_dev, 1292 v4l2_err(&vpbe_dev->v4l2_dev,
1208 "error in videobuf_streamon\n"); 1293 "error in vb2_streamon\n");
1209 return ret; 1294 return ret;
1210 } 1295 }
1211 /* If buffer queue is empty, return error */
1212 if (list_empty(&layer->dma_queue)) {
1213 v4l2_err(&vpbe_dev->v4l2_dev, "buffer queue is empty\n");
1214 goto streamoff;
1215 }
1216 /* Get the next frame from the buffer queue */
1217 layer->next_frm = layer->cur_frm = list_entry(layer->dma_queue.next,
1218 struct videobuf_buffer, queue);
1219 /* Remove buffer from the buffer queue */
1220 list_del(&layer->cur_frm->queue);
1221 /* Mark state of the current frame to active */
1222 layer->cur_frm->state = VIDEOBUF_ACTIVE;
1223 /* Initialize field_id and started member */
1224 layer->field_id = 0;
1225
1226 /* Set parameters in OSD and VENC */
1227 ret = vpbe_set_osd_display_params(disp_dev, layer);
1228 if (ret < 0)
1229 goto streamoff;
1230
1231 /*
1232 * if request format is yuv420 semiplanar, need to
1233 * enable both video windows
1234 */
1235 layer->started = 1;
1236
1237 layer->layer_first_int = 1;
1238
1239 return ret;
1240streamoff:
1241 ret = videobuf_streamoff(&layer->buffer_queue);
1242 return ret; 1296 return ret;
1243} 1297}
1244 1298
@@ -1265,10 +1319,10 @@ static int vpbe_display_dqbuf(struct file *file, void *priv,
1265 } 1319 }
1266 if (file->f_flags & O_NONBLOCK) 1320 if (file->f_flags & O_NONBLOCK)
1267 /* Call videobuf_dqbuf for non blocking mode */ 1321 /* Call videobuf_dqbuf for non blocking mode */
1268 ret = videobuf_dqbuf(&layer->buffer_queue, buf, 1); 1322 ret = vb2_dqbuf(&layer->buffer_queue, buf, 1);
1269 else 1323 else
1270 /* Call videobuf_dqbuf for blocking mode */ 1324 /* Call videobuf_dqbuf for blocking mode */
1271 ret = videobuf_dqbuf(&layer->buffer_queue, buf, 0); 1325 ret = vb2_dqbuf(&layer->buffer_queue, buf, 0);
1272 1326
1273 return ret; 1327 return ret;
1274} 1328}
@@ -1295,7 +1349,7 @@ static int vpbe_display_qbuf(struct file *file, void *priv,
1295 return -EACCES; 1349 return -EACCES;
1296 } 1350 }
1297 1351
1298 return videobuf_qbuf(&layer->buffer_queue, p); 1352 return vb2_qbuf(&layer->buffer_queue, p);
1299} 1353}
1300 1354
1301static int vpbe_display_querybuf(struct file *file, void *priv, 1355static int vpbe_display_querybuf(struct file *file, void *priv,
@@ -1304,7 +1358,6 @@ static int vpbe_display_querybuf(struct file *file, void *priv,
1304 struct vpbe_fh *fh = file->private_data; 1358 struct vpbe_fh *fh = file->private_data;
1305 struct vpbe_layer *layer = fh->layer; 1359 struct vpbe_layer *layer = fh->layer;
1306 struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; 1360 struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev;
1307 int ret;
1308 1361
1309 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, 1362 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev,
1310 "VIDIOC_QUERYBUF, layer id = %d\n", 1363 "VIDIOC_QUERYBUF, layer id = %d\n",
@@ -1314,11 +1367,8 @@ static int vpbe_display_querybuf(struct file *file, void *priv,
1314 v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n"); 1367 v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n");
1315 return -EINVAL; 1368 return -EINVAL;
1316 } 1369 }
1317 1370 /* Call vb2_querybuf to get information */
1318 /* Call videobuf_querybuf to get information */ 1371 return vb2_querybuf(&layer->buffer_queue, buf);
1319 ret = videobuf_querybuf(&layer->buffer_queue, buf);
1320
1321 return ret;
1322} 1372}
1323 1373
1324static int vpbe_display_reqbufs(struct file *file, void *priv, 1374static int vpbe_display_reqbufs(struct file *file, void *priv,
@@ -1327,8 +1377,8 @@ static int vpbe_display_reqbufs(struct file *file, void *priv,
1327 struct vpbe_fh *fh = file->private_data; 1377 struct vpbe_fh *fh = file->private_data;
1328 struct vpbe_layer *layer = fh->layer; 1378 struct vpbe_layer *layer = fh->layer;
1329 struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; 1379 struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev;
1380 struct vb2_queue *q;
1330 int ret; 1381 int ret;
1331
1332 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_reqbufs\n"); 1382 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_reqbufs\n");
1333 1383
1334 if (V4L2_BUF_TYPE_VIDEO_OUTPUT != req_buf->type) { 1384 if (V4L2_BUF_TYPE_VIDEO_OUTPUT != req_buf->type) {
@@ -1342,15 +1392,26 @@ static int vpbe_display_reqbufs(struct file *file, void *priv,
1342 return -EBUSY; 1392 return -EBUSY;
1343 } 1393 }
1344 /* Initialize videobuf queue as per the buffer type */ 1394 /* Initialize videobuf queue as per the buffer type */
1345 videobuf_queue_dma_contig_init(&layer->buffer_queue, 1395 layer->alloc_ctx = vb2_dma_contig_init_ctx(vpbe_dev->pdev);
1346 &video_qops, 1396 if (!layer->alloc_ctx) {
1347 vpbe_dev->pdev, 1397 v4l2_err(&vpbe_dev->v4l2_dev, "Failed to get the context\n");
1348 &layer->irqlock, 1398 return -EINVAL;
1349 V4L2_BUF_TYPE_VIDEO_OUTPUT, 1399 }
1350 layer->pix_fmt.field, 1400 q = &layer->buffer_queue;
1351 sizeof(struct videobuf_buffer), 1401 memset(q, 0, sizeof(*q));
1352 fh, NULL); 1402 q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
1403 q->io_modes = VB2_MMAP | VB2_USERPTR;
1404 q->drv_priv = fh;
1405 q->ops = &video_qops;
1406 q->mem_ops = &vb2_dma_contig_memops;
1407 q->buf_struct_size = sizeof(struct vpbe_disp_buffer);
1353 1408
1409 ret = vb2_queue_init(q);
1410 if (ret) {
1411 v4l2_err(&vpbe_dev->v4l2_dev, "vb2_queue_init() failed\n");
1412 vb2_dma_contig_cleanup_ctx(layer->alloc_ctx);
1413 return ret;
1414 }
1354 /* Set io allowed member of file handle to TRUE */ 1415 /* Set io allowed member of file handle to TRUE */
1355 fh->io_allowed = 1; 1416 fh->io_allowed = 1;
1356 /* Increment io usrs member of layer object to 1 */ 1417 /* Increment io usrs member of layer object to 1 */
@@ -1360,9 +1421,7 @@ static int vpbe_display_reqbufs(struct file *file, void *priv,
1360 /* Initialize buffer queue */ 1421 /* Initialize buffer queue */
1361 INIT_LIST_HEAD(&layer->dma_queue); 1422 INIT_LIST_HEAD(&layer->dma_queue);
1362 /* Allocate buffers */ 1423 /* Allocate buffers */
1363 ret = videobuf_reqbufs(&layer->buffer_queue, req_buf); 1424 return vb2_reqbufs(q, req_buf);
1364
1365 return ret;
1366} 1425}
1367 1426
1368/* 1427/*
@@ -1381,7 +1440,7 @@ static int vpbe_display_mmap(struct file *filep, struct vm_area_struct *vma)
1381 1440
1382 if (mutex_lock_interruptible(&layer->opslock)) 1441 if (mutex_lock_interruptible(&layer->opslock))
1383 return -ERESTARTSYS; 1442 return -ERESTARTSYS;
1384 ret = videobuf_mmap_mapper(&layer->buffer_queue, vma); 1443 ret = vb2_mmap(&layer->buffer_queue, vma);
1385 mutex_unlock(&layer->opslock); 1444 mutex_unlock(&layer->opslock);
1386 return ret; 1445 return ret;
1387} 1446}
@@ -1398,7 +1457,7 @@ static unsigned int vpbe_display_poll(struct file *filep, poll_table *wait)
1398 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_poll\n"); 1457 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_poll\n");
1399 if (layer->started) { 1458 if (layer->started) {
1400 mutex_lock(&layer->opslock); 1459 mutex_lock(&layer->opslock);
1401 err = videobuf_poll_stream(filep, &layer->buffer_queue, wait); 1460 err = vb2_poll(&layer->buffer_queue, filep, wait);
1402 mutex_unlock(&layer->opslock); 1461 mutex_unlock(&layer->opslock);
1403 } 1462 }
1404 return err; 1463 return err;
@@ -1488,8 +1547,8 @@ static int vpbe_display_release(struct file *file)
1488 layer->layer_info.id); 1547 layer->layer_info.id);
1489 layer->started = 0; 1548 layer->started = 0;
1490 /* Free buffers allocated */ 1549 /* Free buffers allocated */
1491 videobuf_queue_cancel(&layer->buffer_queue); 1550 vb2_queue_release(&layer->buffer_queue);
1492 videobuf_mmap_free(&layer->buffer_queue); 1551 vb2_dma_contig_cleanup_ctx(&layer->buffer_queue);
1493 } 1552 }
1494 1553
1495 /* Decrement layer usrs counter */ 1554 /* Decrement layer usrs counter */
diff --git a/drivers/media/platform/davinci/vpbe_osd.c b/drivers/media/platform/davinci/vpbe_osd.c
index bba299dbf396..707f243f810d 100644
--- a/drivers/media/platform/davinci/vpbe_osd.c
+++ b/drivers/media/platform/davinci/vpbe_osd.c
@@ -62,7 +62,7 @@ static inline u32 osd_set(struct osd_state *sd, u32 mask, u32 offset)
62{ 62{
63 struct osd_state *osd = sd; 63 struct osd_state *osd = sd;
64 64
65 u32 addr = osd->osd_base + offset; 65 void __iomem *addr = osd->osd_base + offset;
66 u32 val = readl(addr) | mask; 66 u32 val = readl(addr) | mask;
67 67
68 writel(val, addr); 68 writel(val, addr);
@@ -74,7 +74,7 @@ static inline u32 osd_clear(struct osd_state *sd, u32 mask, u32 offset)
74{ 74{
75 struct osd_state *osd = sd; 75 struct osd_state *osd = sd;
76 76
77 u32 addr = osd->osd_base + offset; 77 void __iomem *addr = osd->osd_base + offset;
78 u32 val = readl(addr) & ~mask; 78 u32 val = readl(addr) & ~mask;
79 79
80 writel(val, addr); 80 writel(val, addr);
@@ -87,7 +87,7 @@ static inline u32 osd_modify(struct osd_state *sd, u32 mask, u32 val,
87{ 87{
88 struct osd_state *osd = sd; 88 struct osd_state *osd = sd;
89 89
90 u32 addr = osd->osd_base + offset; 90 void __iomem *addr = osd->osd_base + offset;
91 u32 new_val = (readl(addr) & ~mask) | (val & mask); 91 u32 new_val = (readl(addr) & ~mask) | (val & mask);
92 92
93 writel(new_val, addr); 93 writel(new_val, addr);
@@ -1559,8 +1559,7 @@ static int osd_probe(struct platform_device *pdev)
1559 ret = -ENODEV; 1559 ret = -ENODEV;
1560 goto free_mem; 1560 goto free_mem;
1561 } 1561 }
1562 osd->osd_base = (unsigned long)ioremap_nocache(res->start, 1562 osd->osd_base = ioremap_nocache(res->start, osd->osd_size);
1563 osd->osd_size);
1564 if (!osd->osd_base) { 1563 if (!osd->osd_base) {
1565 dev_err(osd->dev, "Unable to map the OSD region\n"); 1564 dev_err(osd->dev, "Unable to map the OSD region\n");
1566 ret = -ENODEV; 1565 ret = -ENODEV;
diff --git a/drivers/media/platform/davinci/vpif.c b/drivers/media/platform/davinci/vpif.c
index cff3c0ab501f..0d6cc8e4deb2 100644
--- a/drivers/media/platform/davinci/vpif.c
+++ b/drivers/media/platform/davinci/vpif.c
@@ -444,7 +444,7 @@ static int __devinit vpif_probe(struct platform_device *pdev)
444 status = PTR_ERR(vpif_clk); 444 status = PTR_ERR(vpif_clk);
445 goto clk_fail; 445 goto clk_fail;
446 } 446 }
447 clk_enable(vpif_clk); 447 clk_prepare_enable(vpif_clk);
448 448
449 spin_lock_init(&vpif_lock); 449 spin_lock_init(&vpif_lock);
450 dev_info(&pdev->dev, "vpif probe success\n"); 450 dev_info(&pdev->dev, "vpif probe success\n");
@@ -460,7 +460,7 @@ fail:
460static int __devexit vpif_remove(struct platform_device *pdev) 460static int __devexit vpif_remove(struct platform_device *pdev)
461{ 461{
462 if (vpif_clk) { 462 if (vpif_clk) {
463 clk_disable(vpif_clk); 463 clk_disable_unprepare(vpif_clk);
464 clk_put(vpif_clk); 464 clk_put(vpif_clk);
465 } 465 }
466 466
@@ -472,13 +472,13 @@ static int __devexit vpif_remove(struct platform_device *pdev)
472#ifdef CONFIG_PM 472#ifdef CONFIG_PM
473static int vpif_suspend(struct device *dev) 473static int vpif_suspend(struct device *dev)
474{ 474{
475 clk_disable(vpif_clk); 475 clk_disable_unprepare(vpif_clk);
476 return 0; 476 return 0;
477} 477}
478 478
479static int vpif_resume(struct device *dev) 479static int vpif_resume(struct device *dev)
480{ 480{
481 clk_enable(vpif_clk); 481 clk_prepare_enable(vpif_clk);
482 return 0; 482 return 0;
483} 483}
484 484
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
index fcabc023885d..a409ccefb380 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -201,13 +201,16 @@ static void vpif_buffer_queue(struct vb2_buffer *vb)
201 struct vpif_cap_buffer *buf = container_of(vb, 201 struct vpif_cap_buffer *buf = container_of(vb,
202 struct vpif_cap_buffer, vb); 202 struct vpif_cap_buffer, vb);
203 struct common_obj *common; 203 struct common_obj *common;
204 unsigned long flags;
204 205
205 common = &ch->common[VPIF_VIDEO_INDEX]; 206 common = &ch->common[VPIF_VIDEO_INDEX];
206 207
207 vpif_dbg(2, debug, "vpif_buffer_queue\n"); 208 vpif_dbg(2, debug, "vpif_buffer_queue\n");
208 209
210 spin_lock_irqsave(&common->irqlock, flags);
209 /* add the buffer to the DMA queue */ 211 /* add the buffer to the DMA queue */
210 list_add_tail(&buf->list, &common->dma_queue); 212 list_add_tail(&buf->list, &common->dma_queue);
213 spin_unlock_irqrestore(&common->irqlock, flags);
211} 214}
212 215
213/** 216/**
@@ -278,10 +281,13 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count)
278 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; 281 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
279 struct vpif_params *vpif = &ch->vpifparams; 282 struct vpif_params *vpif = &ch->vpifparams;
280 unsigned long addr = 0; 283 unsigned long addr = 0;
284 unsigned long flags;
281 int ret; 285 int ret;
282 286
283 /* If buffer queue is empty, return error */ 287 /* If buffer queue is empty, return error */
288 spin_lock_irqsave(&common->irqlock, flags);
284 if (list_empty(&common->dma_queue)) { 289 if (list_empty(&common->dma_queue)) {
290 spin_unlock_irqrestore(&common->irqlock, flags);
285 vpif_dbg(1, debug, "buffer queue is empty\n"); 291 vpif_dbg(1, debug, "buffer queue is empty\n");
286 return -EIO; 292 return -EIO;
287 } 293 }
@@ -291,6 +297,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count)
291 struct vpif_cap_buffer, list); 297 struct vpif_cap_buffer, list);
292 /* Remove buffer from the buffer queue */ 298 /* Remove buffer from the buffer queue */
293 list_del(&common->cur_frm->list); 299 list_del(&common->cur_frm->list);
300 spin_unlock_irqrestore(&common->irqlock, flags);
294 /* Mark state of the current frame to active */ 301 /* Mark state of the current frame to active */
295 common->cur_frm->vb.state = VB2_BUF_STATE_ACTIVE; 302 common->cur_frm->vb.state = VB2_BUF_STATE_ACTIVE;
296 /* Initialize field_id and started member */ 303 /* Initialize field_id and started member */
@@ -362,6 +369,7 @@ static int vpif_stop_streaming(struct vb2_queue *vq)
362 struct vpif_fh *fh = vb2_get_drv_priv(vq); 369 struct vpif_fh *fh = vb2_get_drv_priv(vq);
363 struct channel_obj *ch = fh->channel; 370 struct channel_obj *ch = fh->channel;
364 struct common_obj *common; 371 struct common_obj *common;
372 unsigned long flags;
365 373
366 if (!vb2_is_streaming(vq)) 374 if (!vb2_is_streaming(vq))
367 return 0; 375 return 0;
@@ -369,12 +377,14 @@ static int vpif_stop_streaming(struct vb2_queue *vq)
369 common = &ch->common[VPIF_VIDEO_INDEX]; 377 common = &ch->common[VPIF_VIDEO_INDEX];
370 378
371 /* release all active buffers */ 379 /* release all active buffers */
380 spin_lock_irqsave(&common->irqlock, flags);
372 while (!list_empty(&common->dma_queue)) { 381 while (!list_empty(&common->dma_queue)) {
373 common->next_frm = list_entry(common->dma_queue.next, 382 common->next_frm = list_entry(common->dma_queue.next,
374 struct vpif_cap_buffer, list); 383 struct vpif_cap_buffer, list);
375 list_del(&common->next_frm->list); 384 list_del(&common->next_frm->list);
376 vb2_buffer_done(&common->next_frm->vb, VB2_BUF_STATE_ERROR); 385 vb2_buffer_done(&common->next_frm->vb, VB2_BUF_STATE_ERROR);
377 } 386 }
387 spin_unlock_irqrestore(&common->irqlock, flags);
378 388
379 return 0; 389 return 0;
380} 390}
@@ -420,10 +430,12 @@ static void vpif_schedule_next_buffer(struct common_obj *common)
420{ 430{
421 unsigned long addr = 0; 431 unsigned long addr = 0;
422 432
433 spin_lock(&common->irqlock);
423 common->next_frm = list_entry(common->dma_queue.next, 434 common->next_frm = list_entry(common->dma_queue.next,
424 struct vpif_cap_buffer, list); 435 struct vpif_cap_buffer, list);
425 /* Remove that buffer from the buffer queue */ 436 /* Remove that buffer from the buffer queue */
426 list_del(&common->next_frm->list); 437 list_del(&common->next_frm->list);
438 spin_unlock(&common->irqlock);
427 common->next_frm->vb.state = VB2_BUF_STATE_ACTIVE; 439 common->next_frm->vb.state = VB2_BUF_STATE_ACTIVE;
428 addr = vb2_dma_contig_plane_dma_addr(&common->next_frm->vb, 0); 440 addr = vb2_dma_contig_plane_dma_addr(&common->next_frm->vb, 0);
429 441
@@ -468,8 +480,12 @@ static irqreturn_t vpif_channel_isr(int irq, void *dev_id)
468 /* Check the field format */ 480 /* Check the field format */
469 if (1 == ch->vpifparams.std_info.frm_fmt) { 481 if (1 == ch->vpifparams.std_info.frm_fmt) {
470 /* Progressive mode */ 482 /* Progressive mode */
471 if (list_empty(&common->dma_queue)) 483 spin_lock(&common->irqlock);
484 if (list_empty(&common->dma_queue)) {
485 spin_unlock(&common->irqlock);
472 continue; 486 continue;
487 }
488 spin_unlock(&common->irqlock);
473 489
474 if (!channel_first_int[i][channel_id]) 490 if (!channel_first_int[i][channel_id])
475 vpif_process_buffer_complete(common); 491 vpif_process_buffer_complete(common);
@@ -513,9 +529,13 @@ static irqreturn_t vpif_channel_isr(int irq, void *dev_id)
513 vpif_process_buffer_complete(common); 529 vpif_process_buffer_complete(common);
514 } else if (1 == fid) { 530 } else if (1 == fid) {
515 /* odd field */ 531 /* odd field */
532 spin_lock(&common->irqlock);
516 if (list_empty(&common->dma_queue) || 533 if (list_empty(&common->dma_queue) ||
517 (common->cur_frm != common->next_frm)) 534 (common->cur_frm != common->next_frm)) {
535 spin_unlock(&common->irqlock);
518 continue; 536 continue;
537 }
538 spin_unlock(&common->irqlock);
519 539
520 vpif_schedule_next_buffer(common); 540 vpif_schedule_next_buffer(common);
521 } 541 }
@@ -1004,9 +1024,9 @@ static int vpif_reqbufs(struct file *file, void *priv,
1004 1024
1005 /* Initialize videobuf2 queue as per the buffer type */ 1025 /* Initialize videobuf2 queue as per the buffer type */
1006 common->alloc_ctx = vb2_dma_contig_init_ctx(vpif_dev); 1026 common->alloc_ctx = vb2_dma_contig_init_ctx(vpif_dev);
1007 if (!common->alloc_ctx) { 1027 if (IS_ERR(common->alloc_ctx)) {
1008 vpif_err("Failed to get the context\n"); 1028 vpif_err("Failed to get the context\n");
1009 return -EINVAL; 1029 return PTR_ERR(common->alloc_ctx);
1010 } 1030 }
1011 q = &common->buffer_queue; 1031 q = &common->buffer_queue;
1012 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1032 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -1715,7 +1735,7 @@ vpif_enum_dv_timings(struct file *file, void *priv,
1715 int ret; 1735 int ret;
1716 1736
1717 ret = v4l2_subdev_call(ch->sd, video, enum_dv_timings, timings); 1737 ret = v4l2_subdev_call(ch->sd, video, enum_dv_timings, timings);
1718 if (ret == -ENOIOCTLCMD && ret == -ENODEV) 1738 if (ret == -ENOIOCTLCMD || ret == -ENODEV)
1719 return -EINVAL; 1739 return -EINVAL;
1720 return ret; 1740 return ret;
1721} 1741}
@@ -1735,7 +1755,7 @@ vpif_query_dv_timings(struct file *file, void *priv,
1735 int ret; 1755 int ret;
1736 1756
1737 ret = v4l2_subdev_call(ch->sd, video, query_dv_timings, timings); 1757 ret = v4l2_subdev_call(ch->sd, video, query_dv_timings, timings);
1738 if (ret == -ENOIOCTLCMD && ret == -ENODEV) 1758 if (ret == -ENOIOCTLCMD || ret == -ENODEV)
1739 return -ENODATA; 1759 return -ENODATA;
1740 return ret; 1760 return ret;
1741} 1761}
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
index b716fbd4241f..9f2b603be9c9 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -177,11 +177,14 @@ static void vpif_buffer_queue(struct vb2_buffer *vb)
177 struct vpif_disp_buffer, vb); 177 struct vpif_disp_buffer, vb);
178 struct channel_obj *ch = fh->channel; 178 struct channel_obj *ch = fh->channel;
179 struct common_obj *common; 179 struct common_obj *common;
180 unsigned long flags;
180 181
181 common = &ch->common[VPIF_VIDEO_INDEX]; 182 common = &ch->common[VPIF_VIDEO_INDEX];
182 183
183 /* add the buffer to the DMA queue */ 184 /* add the buffer to the DMA queue */
185 spin_lock_irqsave(&common->irqlock, flags);
184 list_add_tail(&buf->list, &common->dma_queue); 186 list_add_tail(&buf->list, &common->dma_queue);
187 spin_unlock_irqrestore(&common->irqlock, flags);
185} 188}
186 189
187/* 190/*
@@ -246,10 +249,13 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count)
246 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; 249 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
247 struct vpif_params *vpif = &ch->vpifparams; 250 struct vpif_params *vpif = &ch->vpifparams;
248 unsigned long addr = 0; 251 unsigned long addr = 0;
252 unsigned long flags;
249 int ret; 253 int ret;
250 254
251 /* If buffer queue is empty, return error */ 255 /* If buffer queue is empty, return error */
256 spin_lock_irqsave(&common->irqlock, flags);
252 if (list_empty(&common->dma_queue)) { 257 if (list_empty(&common->dma_queue)) {
258 spin_unlock_irqrestore(&common->irqlock, flags);
253 vpif_err("buffer queue is empty\n"); 259 vpif_err("buffer queue is empty\n");
254 return -EIO; 260 return -EIO;
255 } 261 }
@@ -260,6 +266,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count)
260 struct vpif_disp_buffer, list); 266 struct vpif_disp_buffer, list);
261 267
262 list_del(&common->cur_frm->list); 268 list_del(&common->cur_frm->list);
269 spin_unlock_irqrestore(&common->irqlock, flags);
263 /* Mark state of the current frame to active */ 270 /* Mark state of the current frame to active */
264 common->cur_frm->vb.state = VB2_BUF_STATE_ACTIVE; 271 common->cur_frm->vb.state = VB2_BUF_STATE_ACTIVE;
265 272
@@ -330,6 +337,7 @@ static int vpif_stop_streaming(struct vb2_queue *vq)
330 struct vpif_fh *fh = vb2_get_drv_priv(vq); 337 struct vpif_fh *fh = vb2_get_drv_priv(vq);
331 struct channel_obj *ch = fh->channel; 338 struct channel_obj *ch = fh->channel;
332 struct common_obj *common; 339 struct common_obj *common;
340 unsigned long flags;
333 341
334 if (!vb2_is_streaming(vq)) 342 if (!vb2_is_streaming(vq))
335 return 0; 343 return 0;
@@ -337,12 +345,14 @@ static int vpif_stop_streaming(struct vb2_queue *vq)
337 common = &ch->common[VPIF_VIDEO_INDEX]; 345 common = &ch->common[VPIF_VIDEO_INDEX];
338 346
339 /* release all active buffers */ 347 /* release all active buffers */
348 spin_lock_irqsave(&common->irqlock, flags);
340 while (!list_empty(&common->dma_queue)) { 349 while (!list_empty(&common->dma_queue)) {
341 common->next_frm = list_entry(common->dma_queue.next, 350 common->next_frm = list_entry(common->dma_queue.next,
342 struct vpif_disp_buffer, list); 351 struct vpif_disp_buffer, list);
343 list_del(&common->next_frm->list); 352 list_del(&common->next_frm->list);
344 vb2_buffer_done(&common->next_frm->vb, VB2_BUF_STATE_ERROR); 353 vb2_buffer_done(&common->next_frm->vb, VB2_BUF_STATE_ERROR);
345 } 354 }
355 spin_unlock_irqrestore(&common->irqlock, flags);
346 356
347 return 0; 357 return 0;
348} 358}
@@ -363,11 +373,13 @@ static void process_progressive_mode(struct common_obj *common)
363{ 373{
364 unsigned long addr = 0; 374 unsigned long addr = 0;
365 375
376 spin_lock(&common->irqlock);
366 /* Get the next buffer from buffer queue */ 377 /* Get the next buffer from buffer queue */
367 common->next_frm = list_entry(common->dma_queue.next, 378 common->next_frm = list_entry(common->dma_queue.next,
368 struct vpif_disp_buffer, list); 379 struct vpif_disp_buffer, list);
369 /* Remove that buffer from the buffer queue */ 380 /* Remove that buffer from the buffer queue */
370 list_del(&common->next_frm->list); 381 list_del(&common->next_frm->list);
382 spin_unlock(&common->irqlock);
371 /* Mark status of the buffer as active */ 383 /* Mark status of the buffer as active */
372 common->next_frm->vb.state = VB2_BUF_STATE_ACTIVE; 384 common->next_frm->vb.state = VB2_BUF_STATE_ACTIVE;
373 385
@@ -398,16 +410,18 @@ static void process_interlaced_mode(int fid, struct common_obj *common)
398 common->cur_frm = common->next_frm; 410 common->cur_frm = common->next_frm;
399 411
400 } else if (1 == fid) { /* odd field */ 412 } else if (1 == fid) { /* odd field */
413 spin_lock(&common->irqlock);
401 if (list_empty(&common->dma_queue) 414 if (list_empty(&common->dma_queue)
402 || (common->cur_frm != common->next_frm)) { 415 || (common->cur_frm != common->next_frm)) {
416 spin_unlock(&common->irqlock);
403 return; 417 return;
404 } 418 }
419 spin_unlock(&common->irqlock);
405 /* one field is displayed configure the next 420 /* one field is displayed configure the next
406 * frame if it is available else hold on current 421 * frame if it is available else hold on current
407 * frame */ 422 * frame */
408 /* Get next from the buffer queue */ 423 /* Get next from the buffer queue */
409 process_progressive_mode(common); 424 process_progressive_mode(common);
410
411 } 425 }
412} 426}
413 427
@@ -437,8 +451,12 @@ static irqreturn_t vpif_channel_isr(int irq, void *dev_id)
437 continue; 451 continue;
438 452
439 if (1 == ch->vpifparams.std_info.frm_fmt) { 453 if (1 == ch->vpifparams.std_info.frm_fmt) {
440 if (list_empty(&common->dma_queue)) 454 spin_lock(&common->irqlock);
455 if (list_empty(&common->dma_queue)) {
456 spin_unlock(&common->irqlock);
441 continue; 457 continue;
458 }
459 spin_unlock(&common->irqlock);
442 460
443 /* Progressive mode */ 461 /* Progressive mode */
444 if (!channel_first_int[i][channel_id]) { 462 if (!channel_first_int[i][channel_id]) {
@@ -972,9 +990,9 @@ static int vpif_reqbufs(struct file *file, void *priv,
972 } 990 }
973 /* Initialize videobuf2 queue as per the buffer type */ 991 /* Initialize videobuf2 queue as per the buffer type */
974 common->alloc_ctx = vb2_dma_contig_init_ctx(vpif_dev); 992 common->alloc_ctx = vb2_dma_contig_init_ctx(vpif_dev);
975 if (!common->alloc_ctx) { 993 if (IS_ERR(common->alloc_ctx)) {
976 vpif_err("Failed to get the context\n"); 994 vpif_err("Failed to get the context\n");
977 return -EINVAL; 995 return PTR_ERR(common->alloc_ctx);
978 } 996 }
979 q = &common->buffer_queue; 997 q = &common->buffer_queue;
980 q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; 998 q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
@@ -1380,7 +1398,7 @@ vpif_enum_dv_timings(struct file *file, void *priv,
1380 int ret; 1398 int ret;
1381 1399
1382 ret = v4l2_subdev_call(ch->sd, video, enum_dv_timings, timings); 1400 ret = v4l2_subdev_call(ch->sd, video, enum_dv_timings, timings);
1383 if (ret == -ENOIOCTLCMD && ret == -ENODEV) 1401 if (ret == -ENOIOCTLCMD || ret == -ENODEV)
1384 return -EINVAL; 1402 return -EINVAL;
1385 return ret; 1403 return ret;
1386} 1404}
diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c b/drivers/media/platform/exynos-gsc/gsc-core.c
index 19cbb12a12a2..cc7b218d047c 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.c
+++ b/drivers/media/platform/exynos-gsc/gsc-core.c
@@ -982,7 +982,7 @@ static void *gsc_get_drv_data(struct platform_device *pdev)
982 match = of_match_node(of_match_ptr(exynos_gsc_match), 982 match = of_match_node(of_match_ptr(exynos_gsc_match),
983 pdev->dev.of_node); 983 pdev->dev.of_node);
984 if (match) 984 if (match)
985 driver_data = match->data; 985 driver_data = (struct gsc_driverdata *)match->data;
986 } else { 986 } else {
987 driver_data = (struct gsc_driverdata *) 987 driver_data = (struct gsc_driverdata *)
988 platform_get_device_id(pdev)->driver_data; 988 platform_get_device_id(pdev)->driver_data;
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index c065d040ed94..c267c57c76fd 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -122,7 +122,7 @@ static void gsc_m2m_device_run(void *priv)
122 struct gsc_ctx *ctx = priv; 122 struct gsc_ctx *ctx = priv;
123 struct gsc_dev *gsc; 123 struct gsc_dev *gsc;
124 unsigned long flags; 124 unsigned long flags;
125 u32 ret; 125 int ret;
126 bool is_set = false; 126 bool is_set = false;
127 127
128 if (WARN(!ctx, "null hardware context\n")) 128 if (WARN(!ctx, "null hardware context\n"))
diff --git a/drivers/media/platform/fsl-viu.c b/drivers/media/platform/fsl-viu.c
index 31ac4dc69247..a8ddb0cacab8 100644
--- a/drivers/media/platform/fsl-viu.c
+++ b/drivers/media/platform/fsl-viu.c
@@ -352,8 +352,7 @@ static int restart_video_queue(struct viu_dmaqueue *vidq)
352 return 0; 352 return 0;
353 buf = list_entry(vidq->queued.next, struct viu_buf, vb.queue); 353 buf = list_entry(vidq->queued.next, struct viu_buf, vb.queue);
354 if (prev == NULL) { 354 if (prev == NULL) {
355 list_del(&buf->vb.queue); 355 list_move_tail(&buf->vb.queue, &vidq->active);
356 list_add_tail(&buf->vb.queue, &vidq->active);
357 356
358 dprintk(1, "Restarting video dma\n"); 357 dprintk(1, "Restarting video dma\n");
359 viu_stop_dma(vidq->dev); 358 viu_stop_dma(vidq->dev);
@@ -367,8 +366,7 @@ static int restart_video_queue(struct viu_dmaqueue *vidq)
367 } else if (prev->vb.width == buf->vb.width && 366 } else if (prev->vb.width == buf->vb.width &&
368 prev->vb.height == buf->vb.height && 367 prev->vb.height == buf->vb.height &&
369 prev->fmt == buf->fmt) { 368 prev->fmt == buf->fmt) {
370 list_del(&buf->vb.queue); 369 list_move_tail(&buf->vb.queue, &vidq->active);
371 list_add_tail(&buf->vb.queue, &vidq->active);
372 buf->vb.state = VIDEOBUF_ACTIVE; 370 buf->vb.state = VIDEOBUF_ACTIVE;
373 dprintk(2, "[%p/%d] restart_queue - move to active\n", 371 dprintk(2, "[%p/%d] restart_queue - move to active\n",
374 buf, buf->vb.i); 372 buf, buf->vb.i);
diff --git a/drivers/media/platform/m2m-deinterlace.c b/drivers/media/platform/m2m-deinterlace.c
index 45164c4f8452..05c560f2ef06 100644
--- a/drivers/media/platform/m2m-deinterlace.c
+++ b/drivers/media/platform/m2m-deinterlace.c
@@ -218,15 +218,14 @@ static void dma_callback(void *data)
218static void deinterlace_issue_dma(struct deinterlace_ctx *ctx, int op, 218static void deinterlace_issue_dma(struct deinterlace_ctx *ctx, int op,
219 int do_callback) 219 int do_callback)
220{ 220{
221 struct deinterlace_q_data *s_q_data, *d_q_data; 221 struct deinterlace_q_data *s_q_data;
222 struct vb2_buffer *src_buf, *dst_buf; 222 struct vb2_buffer *src_buf, *dst_buf;
223 struct deinterlace_dev *pcdev = ctx->dev; 223 struct deinterlace_dev *pcdev = ctx->dev;
224 struct dma_chan *chan = pcdev->dma_chan; 224 struct dma_chan *chan = pcdev->dma_chan;
225 struct dma_device *dmadev = chan->device; 225 struct dma_device *dmadev = chan->device;
226 struct dma_async_tx_descriptor *tx; 226 struct dma_async_tx_descriptor *tx;
227 unsigned int s_width, s_height; 227 unsigned int s_width, s_height;
228 unsigned int d_width, d_height; 228 unsigned int s_size;
229 unsigned int d_size, s_size;
230 dma_addr_t p_in, p_out; 229 dma_addr_t p_in, p_out;
231 enum dma_ctrl_flags flags; 230 enum dma_ctrl_flags flags;
232 231
@@ -238,11 +237,6 @@ static void deinterlace_issue_dma(struct deinterlace_ctx *ctx, int op,
238 s_height = s_q_data->height; 237 s_height = s_q_data->height;
239 s_size = s_width * s_height; 238 s_size = s_width * s_height;
240 239
241 d_q_data = get_q_data(V4L2_BUF_TYPE_VIDEO_CAPTURE);
242 d_width = d_q_data->width;
243 d_height = d_q_data->height;
244 d_size = d_width * d_height;
245
246 p_in = (dma_addr_t)vb2_dma_contig_plane_dma_addr(src_buf, 0); 240 p_in = (dma_addr_t)vb2_dma_contig_plane_dma_addr(src_buf, 0);
247 p_out = (dma_addr_t)vb2_dma_contig_plane_dma_addr(dst_buf, 0); 241 p_out = (dma_addr_t)vb2_dma_contig_plane_dma_addr(dst_buf, 0);
248 if (!p_in || !p_out) { 242 if (!p_in || !p_out) {
@@ -1108,17 +1102,5 @@ static struct platform_driver deinterlace_pdrv = {
1108 .owner = THIS_MODULE, 1102 .owner = THIS_MODULE,
1109 }, 1103 },
1110}; 1104};
1111 1105module_platform_driver(deinterlace_pdrv);
1112static void __exit deinterlace_exit(void)
1113{
1114 platform_driver_unregister(&deinterlace_pdrv);
1115}
1116
1117static int __init deinterlace_init(void)
1118{
1119 return platform_driver_register(&deinterlace_pdrv);
1120}
1121
1122module_init(deinterlace_init);
1123module_exit(deinterlace_exit);
1124 1106
diff --git a/drivers/media/platform/mem2mem_testdev.c b/drivers/media/platform/mem2mem_testdev.c
index 2e2121e98133..7487d7208dea 100644
--- a/drivers/media/platform/mem2mem_testdev.c
+++ b/drivers/media/platform/mem2mem_testdev.c
@@ -839,7 +839,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *ds
839 int ret; 839 int ret;
840 840
841 src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; 841 src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
842 src_vq->io_modes = VB2_MMAP; 842 src_vq->io_modes = VB2_MMAP | VB2_DMABUF;
843 src_vq->drv_priv = ctx; 843 src_vq->drv_priv = ctx;
844 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 844 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
845 src_vq->ops = &m2mtest_qops; 845 src_vq->ops = &m2mtest_qops;
@@ -850,7 +850,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *ds
850 return ret; 850 return ret;
851 851
852 dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 852 dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
853 dst_vq->io_modes = VB2_MMAP; 853 dst_vq->io_modes = VB2_MMAP | VB2_DMABUF;
854 dst_vq->drv_priv = ctx; 854 dst_vq->drv_priv = ctx;
855 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 855 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
856 dst_vq->ops = &m2mtest_qops; 856 dst_vq->ops = &m2mtest_qops;
diff --git a/drivers/media/platform/mx2_emmaprp.c b/drivers/media/platform/mx2_emmaprp.c
index bfa65079fc38..6b155d7be8e0 100644
--- a/drivers/media/platform/mx2_emmaprp.c
+++ b/drivers/media/platform/mx2_emmaprp.c
@@ -1013,16 +1013,4 @@ static struct platform_driver emmaprp_pdrv = {
1013 .owner = THIS_MODULE, 1013 .owner = THIS_MODULE,
1014 }, 1014 },
1015}; 1015};
1016 1016module_platform_driver(emmaprp_pdrv);
1017static void __exit emmaprp_exit(void)
1018{
1019 platform_driver_unregister(&emmaprp_pdrv);
1020}
1021
1022static int __init emmaprp_init(void)
1023{
1024 return platform_driver_register(&emmaprp_pdrv);
1025}
1026
1027module_init(emmaprp_init);
1028module_exit(emmaprp_exit);
diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
index 993504015963..202d1b4b9bee 100644
--- a/drivers/media/platform/omap/omap_vout.c
+++ b/drivers/media/platform/omap/omap_vout.c
@@ -1174,13 +1174,6 @@ static int vidioc_s_fmt_vid_out(struct file *file, void *fh,
1174 /* set default crop and win */ 1174 /* set default crop and win */
1175 omap_vout_new_format(&vout->pix, &vout->fbuf, &vout->crop, &vout->win); 1175 omap_vout_new_format(&vout->pix, &vout->fbuf, &vout->crop, &vout->win);
1176 1176
1177 /* Save the changes in the overlay strcuture */
1178 ret = omapvid_init(vout, 0);
1179 if (ret) {
1180 v4l2_err(&vout->vid_dev->v4l2_dev, "failed to change mode\n");
1181 goto s_fmt_vid_out_exit;
1182 }
1183
1184 ret = 0; 1177 ret = 0;
1185 1178
1186s_fmt_vid_out_exit: 1179s_fmt_vid_out_exit:
@@ -1684,20 +1677,6 @@ static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i)
1684 1677
1685 omap_dispc_register_isr(omap_vout_isr, vout, mask); 1678 omap_dispc_register_isr(omap_vout_isr, vout, mask);
1686 1679
1687 for (j = 0; j < ovid->num_overlays; j++) {
1688 struct omap_overlay *ovl = ovid->overlays[j];
1689
1690 if (ovl->get_device(ovl)) {
1691 struct omap_overlay_info info;
1692 ovl->get_overlay_info(ovl, &info);
1693 info.paddr = addr;
1694 if (ovl->set_overlay_info(ovl, &info)) {
1695 ret = -EINVAL;
1696 goto streamon_err1;
1697 }
1698 }
1699 }
1700
1701 /* First save the configuration in ovelray structure */ 1680 /* First save the configuration in ovelray structure */
1702 ret = omapvid_init(vout, addr); 1681 ret = omapvid_init(vout, addr);
1703 if (ret) 1682 if (ret)
@@ -2094,11 +2073,12 @@ static int __init omap_vout_create_video_devices(struct platform_device *pdev)
2094 } 2073 }
2095 video_set_drvdata(vfd, vout); 2074 video_set_drvdata(vfd, vout);
2096 2075
2097 /* Configure the overlay structure */ 2076 dev_info(&pdev->dev, ": registered and initialized"
2098 ret = omapvid_init(vid_dev->vouts[k], 0); 2077 " video device %d\n", vfd->minor);
2099 if (!ret) 2078 if (k == (pdev->num_resources - 1))
2100 goto success; 2079 return 0;
2101 2080
2081 continue;
2102error2: 2082error2:
2103 if (vout->vid_info.rotation_type == VOUT_ROT_VRFB) 2083 if (vout->vid_info.rotation_type == VOUT_ROT_VRFB)
2104 omap_vout_release_vrfb(vout); 2084 omap_vout_release_vrfb(vout);
@@ -2108,12 +2088,6 @@ error1:
2108error: 2088error:
2109 kfree(vout); 2089 kfree(vout);
2110 return ret; 2090 return ret;
2111
2112success:
2113 dev_info(&pdev->dev, ": registered and initialized"
2114 " video device %d\n", vfd->minor);
2115 if (k == (pdev->num_resources - 1))
2116 return 0;
2117 } 2091 }
2118 2092
2119 return -ENODEV; 2093 return -ENODEV;
diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
index 7f182f0ff3da..a9f6de5b69d8 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -103,7 +103,8 @@ static const struct isp_res_mapping isp_res_maps[] = {
103 1 << OMAP3_ISP_IOMEM_RESZ | 103 1 << OMAP3_ISP_IOMEM_RESZ |
104 1 << OMAP3_ISP_IOMEM_SBL | 104 1 << OMAP3_ISP_IOMEM_SBL |
105 1 << OMAP3_ISP_IOMEM_CSI2A_REGS1 | 105 1 << OMAP3_ISP_IOMEM_CSI2A_REGS1 |
106 1 << OMAP3_ISP_IOMEM_CSIPHY2, 106 1 << OMAP3_ISP_IOMEM_CSIPHY2 |
107 1 << OMAP3_ISP_IOMEM_343X_CONTROL_CSIRXFE,
107 }, 108 },
108 { 109 {
109 .isp_rev = ISP_REVISION_15_0, 110 .isp_rev = ISP_REVISION_15_0,
@@ -120,7 +121,8 @@ static const struct isp_res_mapping isp_res_maps[] = {
120 1 << OMAP3_ISP_IOMEM_CSI2A_REGS2 | 121 1 << OMAP3_ISP_IOMEM_CSI2A_REGS2 |
121 1 << OMAP3_ISP_IOMEM_CSI2C_REGS1 | 122 1 << OMAP3_ISP_IOMEM_CSI2C_REGS1 |
122 1 << OMAP3_ISP_IOMEM_CSIPHY1 | 123 1 << OMAP3_ISP_IOMEM_CSIPHY1 |
123 1 << OMAP3_ISP_IOMEM_CSI2C_REGS2, 124 1 << OMAP3_ISP_IOMEM_CSI2C_REGS2 |
125 1 << OMAP3_ISP_IOMEM_3630_CONTROL_CAMERA_PHY_CTRL,
124 }, 126 },
125}; 127};
126 128
@@ -1331,7 +1333,8 @@ void omap3isp_subclk_disable(struct isp_device *isp,
1331 * isp_enable_clocks - Enable ISP clocks 1333 * isp_enable_clocks - Enable ISP clocks
1332 * @isp: OMAP3 ISP device 1334 * @isp: OMAP3 ISP device
1333 * 1335 *
1334 * Return 0 if successful, or clk_enable return value if any of tthem fails. 1336 * Return 0 if successful, or clk_prepare_enable return value if any of them
1337 * fails.
1335 */ 1338 */
1336static int isp_enable_clocks(struct isp_device *isp) 1339static int isp_enable_clocks(struct isp_device *isp)
1337{ 1340{
@@ -1348,14 +1351,11 @@ static int isp_enable_clocks(struct isp_device *isp)
1348 * has to be twice of what is set on OMAP3430 to get 1351 * has to be twice of what is set on OMAP3430 to get
1349 * the required value for cam_mclk 1352 * the required value for cam_mclk
1350 */ 1353 */
1351 if (cpu_is_omap3630()) 1354 divisor = isp->revision == ISP_REVISION_15_0 ? 1 : 2;
1352 divisor = 1;
1353 else
1354 divisor = 2;
1355 1355
1356 r = clk_enable(isp->clock[ISP_CLK_CAM_ICK]); 1356 r = clk_prepare_enable(isp->clock[ISP_CLK_CAM_ICK]);
1357 if (r) { 1357 if (r) {
1358 dev_err(isp->dev, "clk_enable cam_ick failed\n"); 1358 dev_err(isp->dev, "failed to enable cam_ick clock\n");
1359 goto out_clk_enable_ick; 1359 goto out_clk_enable_ick;
1360 } 1360 }
1361 r = clk_set_rate(isp->clock[ISP_CLK_DPLL4_M5_CK], 1361 r = clk_set_rate(isp->clock[ISP_CLK_DPLL4_M5_CK],
@@ -1364,9 +1364,9 @@ static int isp_enable_clocks(struct isp_device *isp)
1364 dev_err(isp->dev, "clk_set_rate for dpll4_m5_ck failed\n"); 1364 dev_err(isp->dev, "clk_set_rate for dpll4_m5_ck failed\n");
1365 goto out_clk_enable_mclk; 1365 goto out_clk_enable_mclk;
1366 } 1366 }
1367 r = clk_enable(isp->clock[ISP_CLK_CAM_MCLK]); 1367 r = clk_prepare_enable(isp->clock[ISP_CLK_CAM_MCLK]);
1368 if (r) { 1368 if (r) {
1369 dev_err(isp->dev, "clk_enable cam_mclk failed\n"); 1369 dev_err(isp->dev, "failed to enable cam_mclk clock\n");
1370 goto out_clk_enable_mclk; 1370 goto out_clk_enable_mclk;
1371 } 1371 }
1372 rate = clk_get_rate(isp->clock[ISP_CLK_CAM_MCLK]); 1372 rate = clk_get_rate(isp->clock[ISP_CLK_CAM_MCLK]);
@@ -1374,17 +1374,17 @@ static int isp_enable_clocks(struct isp_device *isp)
1374 dev_warn(isp->dev, "unexpected cam_mclk rate:\n" 1374 dev_warn(isp->dev, "unexpected cam_mclk rate:\n"
1375 " expected : %d\n" 1375 " expected : %d\n"
1376 " actual : %ld\n", CM_CAM_MCLK_HZ, rate); 1376 " actual : %ld\n", CM_CAM_MCLK_HZ, rate);
1377 r = clk_enable(isp->clock[ISP_CLK_CSI2_FCK]); 1377 r = clk_prepare_enable(isp->clock[ISP_CLK_CSI2_FCK]);
1378 if (r) { 1378 if (r) {
1379 dev_err(isp->dev, "clk_enable csi2_fck failed\n"); 1379 dev_err(isp->dev, "failed to enable csi2_fck clock\n");
1380 goto out_clk_enable_csi2_fclk; 1380 goto out_clk_enable_csi2_fclk;
1381 } 1381 }
1382 return 0; 1382 return 0;
1383 1383
1384out_clk_enable_csi2_fclk: 1384out_clk_enable_csi2_fclk:
1385 clk_disable(isp->clock[ISP_CLK_CAM_MCLK]); 1385 clk_disable_unprepare(isp->clock[ISP_CLK_CAM_MCLK]);
1386out_clk_enable_mclk: 1386out_clk_enable_mclk:
1387 clk_disable(isp->clock[ISP_CLK_CAM_ICK]); 1387 clk_disable_unprepare(isp->clock[ISP_CLK_CAM_ICK]);
1388out_clk_enable_ick: 1388out_clk_enable_ick:
1389 return r; 1389 return r;
1390} 1390}
@@ -1395,9 +1395,9 @@ out_clk_enable_ick:
1395 */ 1395 */
1396static void isp_disable_clocks(struct isp_device *isp) 1396static void isp_disable_clocks(struct isp_device *isp)
1397{ 1397{
1398 clk_disable(isp->clock[ISP_CLK_CAM_ICK]); 1398 clk_disable_unprepare(isp->clock[ISP_CLK_CAM_ICK]);
1399 clk_disable(isp->clock[ISP_CLK_CAM_MCLK]); 1399 clk_disable_unprepare(isp->clock[ISP_CLK_CAM_MCLK]);
1400 clk_disable(isp->clock[ISP_CLK_CSI2_FCK]); 1400 clk_disable_unprepare(isp->clock[ISP_CLK_CSI2_FCK]);
1401} 1401}
1402 1402
1403static const char *isp_clocks[] = { 1403static const char *isp_clocks[] = {
@@ -1678,7 +1678,7 @@ isp_register_subdev_group(struct isp_device *isp,
1678 1678
1679 adapter = i2c_get_adapter(board_info->i2c_adapter_id); 1679 adapter = i2c_get_adapter(board_info->i2c_adapter_id);
1680 if (adapter == NULL) { 1680 if (adapter == NULL) {
1681 printk(KERN_ERR "%s: Unable to get I2C adapter %d for " 1681 dev_err(isp->dev, "%s: Unable to get I2C adapter %d for "
1682 "device %s\n", __func__, 1682 "device %s\n", __func__,
1683 board_info->i2c_adapter_id, 1683 board_info->i2c_adapter_id,
1684 board_info->board_info->type); 1684 board_info->board_info->type);
@@ -1688,7 +1688,7 @@ isp_register_subdev_group(struct isp_device *isp,
1688 subdev = v4l2_i2c_new_subdev_board(&isp->v4l2_dev, adapter, 1688 subdev = v4l2_i2c_new_subdev_board(&isp->v4l2_dev, adapter,
1689 board_info->board_info, NULL); 1689 board_info->board_info, NULL);
1690 if (subdev == NULL) { 1690 if (subdev == NULL) {
1691 printk(KERN_ERR "%s: Unable to register subdev %s\n", 1691 dev_err(isp->dev, "%s: Unable to register subdev %s\n",
1692 __func__, board_info->board_info->type); 1692 __func__, board_info->board_info->type);
1693 continue; 1693 continue;
1694 } 1694 }
@@ -1713,7 +1713,7 @@ static int isp_register_entities(struct isp_device *isp)
1713 isp->media_dev.link_notify = isp_pipeline_link_notify; 1713 isp->media_dev.link_notify = isp_pipeline_link_notify;
1714 ret = media_device_register(&isp->media_dev); 1714 ret = media_device_register(&isp->media_dev);
1715 if (ret < 0) { 1715 if (ret < 0) {
1716 printk(KERN_ERR "%s: Media device registration failed (%d)\n", 1716 dev_err(isp->dev, "%s: Media device registration failed (%d)\n",
1717 __func__, ret); 1717 __func__, ret);
1718 return ret; 1718 return ret;
1719 } 1719 }
@@ -1721,7 +1721,7 @@ static int isp_register_entities(struct isp_device *isp)
1721 isp->v4l2_dev.mdev = &isp->media_dev; 1721 isp->v4l2_dev.mdev = &isp->media_dev;
1722 ret = v4l2_device_register(isp->dev, &isp->v4l2_dev); 1722 ret = v4l2_device_register(isp->dev, &isp->v4l2_dev);
1723 if (ret < 0) { 1723 if (ret < 0) {
1724 printk(KERN_ERR "%s: V4L2 device registration failed (%d)\n", 1724 dev_err(isp->dev, "%s: V4L2 device registration failed (%d)\n",
1725 __func__, ret); 1725 __func__, ret);
1726 goto done; 1726 goto done;
1727 } 1727 }
@@ -1766,6 +1766,7 @@ static int isp_register_entities(struct isp_device *isp)
1766 struct media_entity *input; 1766 struct media_entity *input;
1767 unsigned int flags; 1767 unsigned int flags;
1768 unsigned int pad; 1768 unsigned int pad;
1769 unsigned int i;
1769 1770
1770 sensor = isp_register_subdev_group(isp, subdevs->subdevs); 1771 sensor = isp_register_subdev_group(isp, subdevs->subdevs);
1771 if (sensor == NULL) 1772 if (sensor == NULL)
@@ -1807,13 +1808,25 @@ static int isp_register_entities(struct isp_device *isp)
1807 break; 1808 break;
1808 1809
1809 default: 1810 default:
1810 printk(KERN_ERR "%s: invalid interface type %u\n", 1811 dev_err(isp->dev, "%s: invalid interface type %u\n",
1811 __func__, subdevs->interface); 1812 __func__, subdevs->interface);
1813 ret = -EINVAL;
1814 goto done;
1815 }
1816
1817 for (i = 0; i < sensor->entity.num_pads; i++) {
1818 if (sensor->entity.pads[i].flags & MEDIA_PAD_FL_SOURCE)
1819 break;
1820 }
1821 if (i == sensor->entity.num_pads) {
1822 dev_err(isp->dev,
1823 "%s: no source pad in external entity\n",
1824 __func__);
1812 ret = -EINVAL; 1825 ret = -EINVAL;
1813 goto done; 1826 goto done;
1814 } 1827 }
1815 1828
1816 ret = media_entity_create_link(&sensor->entity, 0, input, pad, 1829 ret = media_entity_create_link(&sensor->entity, i, input, pad,
1817 flags); 1830 flags);
1818 if (ret < 0) 1831 if (ret < 0)
1819 goto done; 1832 goto done;
@@ -2096,7 +2109,11 @@ static int __devinit isp_probe(struct platform_device *pdev)
2096 isp->isp_csiphy1.vdd = regulator_get(&pdev->dev, "VDD_CSIPHY1"); 2109 isp->isp_csiphy1.vdd = regulator_get(&pdev->dev, "VDD_CSIPHY1");
2097 isp->isp_csiphy2.vdd = regulator_get(&pdev->dev, "VDD_CSIPHY2"); 2110 isp->isp_csiphy2.vdd = regulator_get(&pdev->dev, "VDD_CSIPHY2");
2098 2111
2099 /* Clocks */ 2112 /* Clocks
2113 *
2114 * The ISP clock tree is revision-dependent. We thus need to enable ICLK
2115 * manually to read the revision before calling __omap3isp_get().
2116 */
2100 ret = isp_map_mem_resource(pdev, isp, OMAP3_ISP_IOMEM_MAIN); 2117 ret = isp_map_mem_resource(pdev, isp, OMAP3_ISP_IOMEM_MAIN);
2101 if (ret < 0) 2118 if (ret < 0)
2102 goto error; 2119 goto error;
@@ -2105,6 +2122,16 @@ static int __devinit isp_probe(struct platform_device *pdev)
2105 if (ret < 0) 2122 if (ret < 0)
2106 goto error; 2123 goto error;
2107 2124
2125 ret = clk_enable(isp->clock[ISP_CLK_CAM_ICK]);
2126 if (ret < 0)
2127 goto error;
2128
2129 isp->revision = isp_reg_readl(isp, OMAP3_ISP_IOMEM_MAIN, ISP_REVISION);
2130 dev_info(isp->dev, "Revision %d.%d found\n",
2131 (isp->revision & 0xf0) >> 4, isp->revision & 0x0f);
2132
2133 clk_disable(isp->clock[ISP_CLK_CAM_ICK]);
2134
2108 if (__omap3isp_get(isp, false) == NULL) { 2135 if (__omap3isp_get(isp, false) == NULL) {
2109 ret = -ENODEV; 2136 ret = -ENODEV;
2110 goto error; 2137 goto error;
@@ -2115,10 +2142,6 @@ static int __devinit isp_probe(struct platform_device *pdev)
2115 goto error_isp; 2142 goto error_isp;
2116 2143
2117 /* Memory resources */ 2144 /* Memory resources */
2118 isp->revision = isp_reg_readl(isp, OMAP3_ISP_IOMEM_MAIN, ISP_REVISION);
2119 dev_info(isp->dev, "Revision %d.%d found\n",
2120 (isp->revision & 0xf0) >> 4, isp->revision & 0x0f);
2121
2122 for (m = 0; m < ARRAY_SIZE(isp_res_maps); m++) 2145 for (m = 0; m < ARRAY_SIZE(isp_res_maps); m++)
2123 if (isp->revision == isp_res_maps[m].isp_rev) 2146 if (isp->revision == isp_res_maps[m].isp_rev)
2124 break; 2147 break;
diff --git a/drivers/media/platform/omap3isp/isp.h b/drivers/media/platform/omap3isp/isp.h
index 8d6866942b85..517d348ce32b 100644
--- a/drivers/media/platform/omap3isp/isp.h
+++ b/drivers/media/platform/omap3isp/isp.h
@@ -70,6 +70,8 @@ enum isp_mem_resources {
70 OMAP3_ISP_IOMEM_CSI2C_REGS1, 70 OMAP3_ISP_IOMEM_CSI2C_REGS1,
71 OMAP3_ISP_IOMEM_CSIPHY1, 71 OMAP3_ISP_IOMEM_CSIPHY1,
72 OMAP3_ISP_IOMEM_CSI2C_REGS2, 72 OMAP3_ISP_IOMEM_CSI2C_REGS2,
73 OMAP3_ISP_IOMEM_343X_CONTROL_CSIRXFE,
74 OMAP3_ISP_IOMEM_3630_CONTROL_CAMERA_PHY_CTRL,
73 OMAP3_ISP_IOMEM_LAST 75 OMAP3_ISP_IOMEM_LAST
74}; 76};
75 77
@@ -125,9 +127,6 @@ struct isp_reg {
125 127
126struct isp_platform_callback { 128struct isp_platform_callback {
127 u32 (*set_xclk)(struct isp_device *isp, u32 xclk, u8 xclksel); 129 u32 (*set_xclk)(struct isp_device *isp, u32 xclk, u8 xclksel);
128 int (*csiphy_config)(struct isp_csiphy *phy,
129 struct isp_csiphy_dphy_cfg *dphy,
130 struct isp_csiphy_lanes_cfg *lanes);
131}; 130};
132 131
133/* 132/*
diff --git a/drivers/media/platform/omap3isp/ispcsi2.c b/drivers/media/platform/omap3isp/ispcsi2.c
index 6a3ff792af7d..783f4b05b153 100644
--- a/drivers/media/platform/omap3isp/ispcsi2.c
+++ b/drivers/media/platform/omap3isp/ispcsi2.c
@@ -517,7 +517,7 @@ int omap3isp_csi2_reset(struct isp_csi2_device *csi2)
517 } while (soft_reset_retries < 5); 517 } while (soft_reset_retries < 5);
518 518
519 if (soft_reset_retries == 5) { 519 if (soft_reset_retries == 5) {
520 printk(KERN_ERR "CSI2: Soft reset try count exceeded!\n"); 520 dev_err(isp->dev, "CSI2: Soft reset try count exceeded!\n");
521 return -EBUSY; 521 return -EBUSY;
522 } 522 }
523 523
@@ -535,8 +535,8 @@ int omap3isp_csi2_reset(struct isp_csi2_device *csi2)
535 } while (--i > 0); 535 } while (--i > 0);
536 536
537 if (i == 0) { 537 if (i == 0) {
538 printk(KERN_ERR 538 dev_err(isp->dev,
539 "CSI2: Reset for CSI2_96M_FCLK domain Failed!\n"); 539 "CSI2: Reset for CSI2_96M_FCLK domain Failed!\n");
540 return -EBUSY; 540 return -EBUSY;
541 } 541 }
542 542
diff --git a/drivers/media/platform/omap3isp/ispcsiphy.c b/drivers/media/platform/omap3isp/ispcsiphy.c
index 348f67ebbbc9..3d56b33f85e8 100644
--- a/drivers/media/platform/omap3isp/ispcsiphy.c
+++ b/drivers/media/platform/omap3isp/ispcsiphy.c
@@ -32,34 +32,92 @@
32#include "ispreg.h" 32#include "ispreg.h"
33#include "ispcsiphy.h" 33#include "ispcsiphy.h"
34 34
35/* 35static void csiphy_routing_cfg_3630(struct isp_csiphy *phy, u32 iface,
36 * csiphy_lanes_config - Configuration of CSIPHY lanes. 36 bool ccp2_strobe)
37 *
38 * Updates HW configuration.
39 * Called with phy->mutex taken.
40 */
41static void csiphy_lanes_config(struct isp_csiphy *phy)
42{ 37{
43 unsigned int i; 38 u32 reg = isp_reg_readl(
44 u32 reg; 39 phy->isp, OMAP3_ISP_IOMEM_3630_CONTROL_CAMERA_PHY_CTRL, 0);
40 u32 shift, mode;
41
42 switch (iface) {
43 case ISP_INTERFACE_CCP2B_PHY1:
44 reg &= ~OMAP3630_CONTROL_CAMERA_PHY_CTRL_CSI1_RX_SEL_PHY2;
45 shift = OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_PHY1_SHIFT;
46 break;
47 case ISP_INTERFACE_CSI2C_PHY1:
48 shift = OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_PHY1_SHIFT;
49 mode = OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_DPHY;
50 break;
51 case ISP_INTERFACE_CCP2B_PHY2:
52 reg |= OMAP3630_CONTROL_CAMERA_PHY_CTRL_CSI1_RX_SEL_PHY2;
53 shift = OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_PHY2_SHIFT;
54 break;
55 case ISP_INTERFACE_CSI2A_PHY2:
56 shift = OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_PHY2_SHIFT;
57 mode = OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_DPHY;
58 break;
59 }
45 60
46 reg = isp_reg_readl(phy->isp, phy->cfg_regs, ISPCSI2_PHY_CFG); 61 /* Select data/clock or data/strobe mode for CCP2 */
62 switch (iface) {
63 case ISP_INTERFACE_CCP2B_PHY1:
64 case ISP_INTERFACE_CCP2B_PHY2:
65 if (ccp2_strobe)
66 mode = OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_CCP2_DATA_STROBE;
67 else
68 mode = OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_CCP2_DATA_CLOCK;
69 }
47 70
48 for (i = 0; i < phy->num_data_lanes; i++) { 71 reg &= ~(OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_MASK << shift);
49 reg &= ~(ISPCSI2_PHY_CFG_DATA_POL_MASK(i + 1) | 72 reg |= mode << shift;
50 ISPCSI2_PHY_CFG_DATA_POSITION_MASK(i + 1)); 73
51 reg |= (phy->lanes.data[i].pol << 74 isp_reg_writel(phy->isp, reg,
52 ISPCSI2_PHY_CFG_DATA_POL_SHIFT(i + 1)); 75 OMAP3_ISP_IOMEM_3630_CONTROL_CAMERA_PHY_CTRL, 0);
53 reg |= (phy->lanes.data[i].pos << 76}
54 ISPCSI2_PHY_CFG_DATA_POSITION_SHIFT(i + 1)); 77
78static void csiphy_routing_cfg_3430(struct isp_csiphy *phy, u32 iface, bool on,
79 bool ccp2_strobe)
80{
81 u32 csirxfe = OMAP343X_CONTROL_CSIRXFE_PWRDNZ
82 | OMAP343X_CONTROL_CSIRXFE_RESET;
83
84 /* Only the CCP2B on PHY1 is configurable. */
85 if (iface != ISP_INTERFACE_CCP2B_PHY1)
86 return;
87
88 if (!on) {
89 isp_reg_writel(phy->isp, 0,
90 OMAP3_ISP_IOMEM_343X_CONTROL_CSIRXFE, 0);
91 return;
55 } 92 }
56 93
57 reg &= ~(ISPCSI2_PHY_CFG_CLOCK_POL_MASK | 94 if (ccp2_strobe)
58 ISPCSI2_PHY_CFG_CLOCK_POSITION_MASK); 95 csirxfe |= OMAP343X_CONTROL_CSIRXFE_SELFORM;
59 reg |= phy->lanes.clk.pol << ISPCSI2_PHY_CFG_CLOCK_POL_SHIFT;
60 reg |= phy->lanes.clk.pos << ISPCSI2_PHY_CFG_CLOCK_POSITION_SHIFT;
61 96
62 isp_reg_writel(phy->isp, reg, phy->cfg_regs, ISPCSI2_PHY_CFG); 97 isp_reg_writel(phy->isp, csirxfe,
98 OMAP3_ISP_IOMEM_343X_CONTROL_CSIRXFE, 0);
99}
100
101/*
102 * Configure OMAP 3 CSI PHY routing.
103 * @phy: relevant phy device
104 * @iface: ISP_INTERFACE_*
105 * @on: power on or off
106 * @ccp2_strobe: false: data/clock, true: data/strobe
107 *
108 * Note that the underlying routing configuration registers are part of the
109 * control (SCM) register space and part of the CORE power domain on both 3430
110 * and 3630, so they will not hold their contents in off-mode. This isn't an
111 * issue since the MPU power domain is forced on whilst the ISP is in use.
112 */
113static void csiphy_routing_cfg(struct isp_csiphy *phy, u32 iface, bool on,
114 bool ccp2_strobe)
115{
116 if (phy->isp->mmio_base[OMAP3_ISP_IOMEM_3630_CONTROL_CAMERA_PHY_CTRL]
117 && on)
118 return csiphy_routing_cfg_3630(phy, iface, ccp2_strobe);
119 if (phy->isp->mmio_base[OMAP3_ISP_IOMEM_343X_CONTROL_CSIRXFE])
120 return csiphy_routing_cfg_3430(phy, iface, on, ccp2_strobe);
63} 121}
64 122
65/* 123/*
@@ -99,7 +157,7 @@ static int csiphy_set_power(struct isp_csiphy *phy, u32 power)
99 } while ((reg != power >> 2) && (retry_count < 100)); 157 } while ((reg != power >> 2) && (retry_count < 100));
100 158
101 if (retry_count == 100) { 159 if (retry_count == 100) {
102 printk(KERN_ERR "CSI2 CIO set power failed!\n"); 160 dev_err(phy->isp->dev, "CSI2 CIO set power failed!\n");
103 return -EBUSY; 161 return -EBUSY;
104 } 162 }
105 163
@@ -107,43 +165,28 @@ static int csiphy_set_power(struct isp_csiphy *phy, u32 power)
107} 165}
108 166
109/* 167/*
110 * csiphy_dphy_config - Configure CSI2 D-PHY parameters. 168 * TCLK values are OK at their reset values
111 *
112 * Called with phy->mutex taken.
113 */ 169 */
114static void csiphy_dphy_config(struct isp_csiphy *phy) 170#define TCLK_TERM 0
115{ 171#define TCLK_MISS 1
116 u32 reg; 172#define TCLK_SETTLE 14
117
118 /* Set up ISPCSIPHY_REG0 */
119 reg = isp_reg_readl(phy->isp, phy->phy_regs, ISPCSIPHY_REG0);
120
121 reg &= ~(ISPCSIPHY_REG0_THS_TERM_MASK |
122 ISPCSIPHY_REG0_THS_SETTLE_MASK);
123 reg |= phy->dphy.ths_term << ISPCSIPHY_REG0_THS_TERM_SHIFT;
124 reg |= phy->dphy.ths_settle << ISPCSIPHY_REG0_THS_SETTLE_SHIFT;
125
126 isp_reg_writel(phy->isp, reg, phy->phy_regs, ISPCSIPHY_REG0);
127
128 /* Set up ISPCSIPHY_REG1 */
129 reg = isp_reg_readl(phy->isp, phy->phy_regs, ISPCSIPHY_REG1);
130
131 reg &= ~(ISPCSIPHY_REG1_TCLK_TERM_MASK |
132 ISPCSIPHY_REG1_TCLK_MISS_MASK |
133 ISPCSIPHY_REG1_TCLK_SETTLE_MASK);
134 reg |= phy->dphy.tclk_term << ISPCSIPHY_REG1_TCLK_TERM_SHIFT;
135 reg |= phy->dphy.tclk_miss << ISPCSIPHY_REG1_TCLK_MISS_SHIFT;
136 reg |= phy->dphy.tclk_settle << ISPCSIPHY_REG1_TCLK_SETTLE_SHIFT;
137
138 isp_reg_writel(phy->isp, reg, phy->phy_regs, ISPCSIPHY_REG1);
139}
140 173
141static int csiphy_config(struct isp_csiphy *phy, 174static int omap3isp_csiphy_config(struct isp_csiphy *phy)
142 struct isp_csiphy_dphy_cfg *dphy,
143 struct isp_csiphy_lanes_cfg *lanes)
144{ 175{
176 struct isp_csi2_device *csi2 = phy->csi2;
177 struct isp_pipeline *pipe = to_isp_pipeline(&csi2->subdev.entity);
178 struct isp_v4l2_subdevs_group *subdevs = pipe->external->host_priv;
179 struct isp_csiphy_lanes_cfg *lanes;
180 int csi2_ddrclk_khz;
145 unsigned int used_lanes = 0; 181 unsigned int used_lanes = 0;
146 unsigned int i; 182 unsigned int i;
183 u32 reg;
184
185 if (subdevs->interface == ISP_INTERFACE_CCP2B_PHY1
186 || subdevs->interface == ISP_INTERFACE_CCP2B_PHY2)
187 lanes = &subdevs->bus.ccp2.lanecfg;
188 else
189 lanes = &subdevs->bus.csi2.lanecfg;
147 190
148 /* Clock and data lanes verification */ 191 /* Clock and data lanes verification */
149 for (i = 0; i < phy->num_data_lanes; i++) { 192 for (i = 0; i < phy->num_data_lanes; i++) {
@@ -162,10 +205,61 @@ static int csiphy_config(struct isp_csiphy *phy,
162 if (lanes->clk.pos == 0 || used_lanes & (1 << lanes->clk.pos)) 205 if (lanes->clk.pos == 0 || used_lanes & (1 << lanes->clk.pos))
163 return -EINVAL; 206 return -EINVAL;
164 207
165 mutex_lock(&phy->mutex); 208 /*
166 phy->dphy = *dphy; 209 * The PHY configuration is lost in off mode, that's not an
167 phy->lanes = *lanes; 210 * issue since the MPU power domain is forced on whilst the
168 mutex_unlock(&phy->mutex); 211 * ISP is in use.
212 */
213 csiphy_routing_cfg(phy, subdevs->interface, true,
214 subdevs->bus.ccp2.phy_layer);
215
216 /* DPHY timing configuration */
217 /* CSI-2 is DDR and we only count used lanes. */
218 csi2_ddrclk_khz = pipe->external_rate / 1000
219 / (2 * hweight32(used_lanes)) * pipe->external_width;
220
221 reg = isp_reg_readl(csi2->isp, phy->phy_regs, ISPCSIPHY_REG0);
222
223 reg &= ~(ISPCSIPHY_REG0_THS_TERM_MASK |
224 ISPCSIPHY_REG0_THS_SETTLE_MASK);
225 /* THS_TERM: Programmed value = ceil(12.5 ns/DDRClk period) - 1. */
226 reg |= (DIV_ROUND_UP(25 * csi2_ddrclk_khz, 2000000) - 1)
227 << ISPCSIPHY_REG0_THS_TERM_SHIFT;
228 /* THS_SETTLE: Programmed value = ceil(90 ns/DDRClk period) + 3. */
229 reg |= (DIV_ROUND_UP(90 * csi2_ddrclk_khz, 1000000) + 3)
230 << ISPCSIPHY_REG0_THS_SETTLE_SHIFT;
231
232 isp_reg_writel(csi2->isp, reg, phy->phy_regs, ISPCSIPHY_REG0);
233
234 reg = isp_reg_readl(csi2->isp, phy->phy_regs, ISPCSIPHY_REG1);
235
236 reg &= ~(ISPCSIPHY_REG1_TCLK_TERM_MASK |
237 ISPCSIPHY_REG1_TCLK_MISS_MASK |
238 ISPCSIPHY_REG1_TCLK_SETTLE_MASK);
239 reg |= TCLK_TERM << ISPCSIPHY_REG1_TCLK_TERM_SHIFT;
240 reg |= TCLK_MISS << ISPCSIPHY_REG1_TCLK_MISS_SHIFT;
241 reg |= TCLK_SETTLE << ISPCSIPHY_REG1_TCLK_SETTLE_SHIFT;
242
243 isp_reg_writel(csi2->isp, reg, phy->phy_regs, ISPCSIPHY_REG1);
244
245 /* DPHY lane configuration */
246 reg = isp_reg_readl(csi2->isp, phy->cfg_regs, ISPCSI2_PHY_CFG);
247
248 for (i = 0; i < phy->num_data_lanes; i++) {
249 reg &= ~(ISPCSI2_PHY_CFG_DATA_POL_MASK(i + 1) |
250 ISPCSI2_PHY_CFG_DATA_POSITION_MASK(i + 1));
251 reg |= (lanes->data[i].pol <<
252 ISPCSI2_PHY_CFG_DATA_POL_SHIFT(i + 1));
253 reg |= (lanes->data[i].pos <<
254 ISPCSI2_PHY_CFG_DATA_POSITION_SHIFT(i + 1));
255 }
256
257 reg &= ~(ISPCSI2_PHY_CFG_CLOCK_POL_MASK |
258 ISPCSI2_PHY_CFG_CLOCK_POSITION_MASK);
259 reg |= lanes->clk.pol << ISPCSI2_PHY_CFG_CLOCK_POL_SHIFT;
260 reg |= lanes->clk.pos << ISPCSI2_PHY_CFG_CLOCK_POSITION_SHIFT;
261
262 isp_reg_writel(csi2->isp, reg, phy->cfg_regs, ISPCSI2_PHY_CFG);
169 263
170 return 0; 264 return 0;
171} 265}
@@ -190,8 +284,9 @@ int omap3isp_csiphy_acquire(struct isp_csiphy *phy)
190 if (rval < 0) 284 if (rval < 0)
191 goto done; 285 goto done;
192 286
193 csiphy_dphy_config(phy); 287 rval = omap3isp_csiphy_config(phy);
194 csiphy_lanes_config(phy); 288 if (rval < 0)
289 goto done;
195 290
196 rval = csiphy_set_power(phy, ISPCSI2_PHY_CFG_PWR_CMD_ON); 291 rval = csiphy_set_power(phy, ISPCSI2_PHY_CFG_PWR_CMD_ON);
197 if (rval) { 292 if (rval) {
@@ -211,6 +306,14 @@ void omap3isp_csiphy_release(struct isp_csiphy *phy)
211{ 306{
212 mutex_lock(&phy->mutex); 307 mutex_lock(&phy->mutex);
213 if (phy->phy_in_use) { 308 if (phy->phy_in_use) {
309 struct isp_csi2_device *csi2 = phy->csi2;
310 struct isp_pipeline *pipe =
311 to_isp_pipeline(&csi2->subdev.entity);
312 struct isp_v4l2_subdevs_group *subdevs =
313 pipe->external->host_priv;
314
315 csiphy_routing_cfg(phy, subdevs->interface, false,
316 subdevs->bus.ccp2.phy_layer);
214 csiphy_power_autoswitch_enable(phy, false); 317 csiphy_power_autoswitch_enable(phy, false);
215 csiphy_set_power(phy, ISPCSI2_PHY_CFG_PWR_CMD_OFF); 318 csiphy_set_power(phy, ISPCSI2_PHY_CFG_PWR_CMD_OFF);
216 regulator_disable(phy->vdd); 319 regulator_disable(phy->vdd);
@@ -227,8 +330,6 @@ int omap3isp_csiphy_init(struct isp_device *isp)
227 struct isp_csiphy *phy1 = &isp->isp_csiphy1; 330 struct isp_csiphy *phy1 = &isp->isp_csiphy1;
228 struct isp_csiphy *phy2 = &isp->isp_csiphy2; 331 struct isp_csiphy *phy2 = &isp->isp_csiphy2;
229 332
230 isp->platform_cb.csiphy_config = csiphy_config;
231
232 phy2->isp = isp; 333 phy2->isp = isp;
233 phy2->csi2 = &isp->isp_csi2a; 334 phy2->csi2 = &isp->isp_csi2a;
234 phy2->num_data_lanes = ISP_CSIPHY2_NUM_DATA_LANES; 335 phy2->num_data_lanes = ISP_CSIPHY2_NUM_DATA_LANES;
diff --git a/drivers/media/platform/omap3isp/ispcsiphy.h b/drivers/media/platform/omap3isp/ispcsiphy.h
index e93a661e65d9..14551fd77697 100644
--- a/drivers/media/platform/omap3isp/ispcsiphy.h
+++ b/drivers/media/platform/omap3isp/ispcsiphy.h
@@ -32,14 +32,6 @@
32struct isp_csi2_device; 32struct isp_csi2_device;
33struct regulator; 33struct regulator;
34 34
35struct isp_csiphy_dphy_cfg {
36 u8 ths_term;
37 u8 ths_settle;
38 u8 tclk_term;
39 unsigned tclk_miss:1;
40 u8 tclk_settle;
41};
42
43struct isp_csiphy { 35struct isp_csiphy {
44 struct isp_device *isp; 36 struct isp_device *isp;
45 struct mutex mutex; /* serialize csiphy configuration */ 37 struct mutex mutex; /* serialize csiphy configuration */
@@ -52,8 +44,6 @@ struct isp_csiphy {
52 unsigned int phy_regs; 44 unsigned int phy_regs;
53 45
54 u8 num_data_lanes; /* number of CSI2 Data Lanes supported */ 46 u8 num_data_lanes; /* number of CSI2 Data Lanes supported */
55 struct isp_csiphy_lanes_cfg lanes;
56 struct isp_csiphy_dphy_cfg dphy;
57}; 47};
58 48
59int omap3isp_csiphy_acquire(struct isp_csiphy *phy); 49int omap3isp_csiphy_acquire(struct isp_csiphy *phy);
diff --git a/drivers/media/platform/omap3isp/isphist.c b/drivers/media/platform/omap3isp/isphist.c
index e7f9c4292cc6..2d759c56f37c 100644
--- a/drivers/media/platform/omap3isp/isphist.c
+++ b/drivers/media/platform/omap3isp/isphist.c
@@ -74,11 +74,14 @@ static void hist_reset_mem(struct ispstat *hist)
74 74
75static void hist_dma_config(struct ispstat *hist) 75static void hist_dma_config(struct ispstat *hist)
76{ 76{
77 struct isp_device *isp = hist->isp;
78
77 hist->dma_config.data_type = OMAP_DMA_DATA_TYPE_S32; 79 hist->dma_config.data_type = OMAP_DMA_DATA_TYPE_S32;
78 hist->dma_config.sync_mode = OMAP_DMA_SYNC_ELEMENT; 80 hist->dma_config.sync_mode = OMAP_DMA_SYNC_ELEMENT;
79 hist->dma_config.frame_count = 1; 81 hist->dma_config.frame_count = 1;
80 hist->dma_config.src_amode = OMAP_DMA_AMODE_CONSTANT; 82 hist->dma_config.src_amode = OMAP_DMA_AMODE_CONSTANT;
81 hist->dma_config.src_start = OMAP3ISP_HIST_REG_BASE + ISPHIST_DATA; 83 hist->dma_config.src_start = isp->mmio_base_phys[OMAP3_ISP_IOMEM_HIST]
84 + ISPHIST_DATA;
82 hist->dma_config.dst_amode = OMAP_DMA_AMODE_POST_INC; 85 hist->dma_config.dst_amode = OMAP_DMA_AMODE_POST_INC;
83 hist->dma_config.src_or_dst_synch = OMAP_DMA_SRC_SYNC; 86 hist->dma_config.src_or_dst_synch = OMAP_DMA_SRC_SYNC;
84} 87}
@@ -479,6 +482,8 @@ int omap3isp_hist_init(struct isp_device *isp)
479 return -ENOMEM; 482 return -ENOMEM;
480 483
481 memset(hist, 0, sizeof(*hist)); 484 memset(hist, 0, sizeof(*hist));
485 hist->isp = isp;
486
482 if (HIST_CONFIG_DMA) 487 if (HIST_CONFIG_DMA)
483 ret = omap_request_dma(OMAP24XX_DMA_NO_DEVICE, "DMA_ISP_HIST", 488 ret = omap_request_dma(OMAP24XX_DMA_NO_DEVICE, "DMA_ISP_HIST",
484 hist_dma_cb, hist, &hist->dma_ch); 489 hist_dma_cb, hist, &hist->dma_ch);
@@ -496,7 +501,6 @@ int omap3isp_hist_init(struct isp_device *isp)
496 hist->ops = &hist_ops; 501 hist->ops = &hist_ops;
497 hist->priv = hist_cfg; 502 hist->priv = hist_cfg;
498 hist->event_type = V4L2_EVENT_OMAP3ISP_HIST; 503 hist->event_type = V4L2_EVENT_OMAP3ISP_HIST;
499 hist->isp = isp;
500 504
501 ret = omap3isp_stat_init(hist, "histogram", &hist_subdev_ops); 505 ret = omap3isp_stat_init(hist, "histogram", &hist_subdev_ops);
502 if (ret) { 506 if (ret) {
diff --git a/drivers/media/platform/omap3isp/isppreview.c b/drivers/media/platform/omap3isp/isppreview.c
index 1ae1c0909ed1..691b92a3c3e7 100644
--- a/drivers/media/platform/omap3isp/isppreview.c
+++ b/drivers/media/platform/omap3isp/isppreview.c
@@ -200,10 +200,10 @@ static void preview_enable_invalaw(struct isp_prev_device *prev, bool enable)
200 200
201 if (enable) 201 if (enable)
202 isp_reg_set(isp, OMAP3_ISP_IOMEM_PREV, ISPPRV_PCR, 202 isp_reg_set(isp, OMAP3_ISP_IOMEM_PREV, ISPPRV_PCR,
203 ISPPRV_PCR_WIDTH | ISPPRV_PCR_INVALAW); 203 ISPPRV_PCR_INVALAW);
204 else 204 else
205 isp_reg_clr(isp, OMAP3_ISP_IOMEM_PREV, ISPPRV_PCR, 205 isp_reg_clr(isp, OMAP3_ISP_IOMEM_PREV, ISPPRV_PCR,
206 ISPPRV_PCR_WIDTH | ISPPRV_PCR_INVALAW); 206 ISPPRV_PCR_INVALAW);
207} 207}
208 208
209/* 209/*
@@ -1014,7 +1014,7 @@ static void preview_config_averager(struct isp_prev_device *prev, u8 average)
1014/* 1014/*
1015 * preview_config_input_format - Configure the input format 1015 * preview_config_input_format - Configure the input format
1016 * @prev: The preview engine 1016 * @prev: The preview engine
1017 * @format: Format on the preview engine sink pad 1017 * @info: Sink pad format information
1018 * 1018 *
1019 * Enable and configure CFA interpolation for Bayer formats and disable it for 1019 * Enable and configure CFA interpolation for Bayer formats and disable it for
1020 * greyscale formats. 1020 * greyscale formats.
@@ -1025,22 +1025,29 @@ static void preview_config_averager(struct isp_prev_device *prev, u8 average)
1025 * reordered to support non-GRBG Bayer patterns. 1025 * reordered to support non-GRBG Bayer patterns.
1026 */ 1026 */
1027static void preview_config_input_format(struct isp_prev_device *prev, 1027static void preview_config_input_format(struct isp_prev_device *prev,
1028 const struct v4l2_mbus_framefmt *format) 1028 const struct isp_format_info *info)
1029{ 1029{
1030 struct isp_device *isp = to_isp_device(prev); 1030 struct isp_device *isp = to_isp_device(prev);
1031 struct prev_params *params; 1031 struct prev_params *params;
1032 1032
1033 switch (format->code) { 1033 if (info->width == 8)
1034 case V4L2_MBUS_FMT_SGRBG10_1X10: 1034 isp_reg_set(isp, OMAP3_ISP_IOMEM_PREV, ISPPRV_PCR,
1035 ISPPRV_PCR_WIDTH);
1036 else
1037 isp_reg_clr(isp, OMAP3_ISP_IOMEM_PREV, ISPPRV_PCR,
1038 ISPPRV_PCR_WIDTH);
1039
1040 switch (info->flavor) {
1041 case V4L2_MBUS_FMT_SGRBG8_1X8:
1035 prev->params.cfa_order = 0; 1042 prev->params.cfa_order = 0;
1036 break; 1043 break;
1037 case V4L2_MBUS_FMT_SRGGB10_1X10: 1044 case V4L2_MBUS_FMT_SRGGB8_1X8:
1038 prev->params.cfa_order = 1; 1045 prev->params.cfa_order = 1;
1039 break; 1046 break;
1040 case V4L2_MBUS_FMT_SBGGR10_1X10: 1047 case V4L2_MBUS_FMT_SBGGR8_1X8:
1041 prev->params.cfa_order = 2; 1048 prev->params.cfa_order = 2;
1042 break; 1049 break;
1043 case V4L2_MBUS_FMT_SGBRG10_1X10: 1050 case V4L2_MBUS_FMT_SGBRG8_1X8:
1044 prev->params.cfa_order = 3; 1051 prev->params.cfa_order = 3;
1045 break; 1052 break;
1046 default: 1053 default:
@@ -1081,7 +1088,8 @@ static void preview_config_input_size(struct isp_prev_device *prev, u32 active)
1081 unsigned int elv = prev->crop.top + prev->crop.height - 1; 1088 unsigned int elv = prev->crop.top + prev->crop.height - 1;
1082 u32 features; 1089 u32 features;
1083 1090
1084 if (format->code != V4L2_MBUS_FMT_Y10_1X10) { 1091 if (format->code != V4L2_MBUS_FMT_Y8_1X8 &&
1092 format->code != V4L2_MBUS_FMT_Y10_1X10) {
1085 sph -= 2; 1093 sph -= 2;
1086 eph += 2; 1094 eph += 2;
1087 slv -= 2; 1095 slv -= 2;
@@ -1389,6 +1397,7 @@ static unsigned int preview_max_out_width(struct isp_prev_device *prev)
1389static void preview_configure(struct isp_prev_device *prev) 1397static void preview_configure(struct isp_prev_device *prev)
1390{ 1398{
1391 struct isp_device *isp = to_isp_device(prev); 1399 struct isp_device *isp = to_isp_device(prev);
1400 const struct isp_format_info *info;
1392 struct v4l2_mbus_framefmt *format; 1401 struct v4l2_mbus_framefmt *format;
1393 unsigned long flags; 1402 unsigned long flags;
1394 u32 update; 1403 u32 update;
@@ -1402,17 +1411,18 @@ static void preview_configure(struct isp_prev_device *prev)
1402 1411
1403 /* PREV_PAD_SINK */ 1412 /* PREV_PAD_SINK */
1404 format = &prev->formats[PREV_PAD_SINK]; 1413 format = &prev->formats[PREV_PAD_SINK];
1414 info = omap3isp_video_format_info(format->code);
1405 1415
1406 preview_adjust_bandwidth(prev); 1416 preview_adjust_bandwidth(prev);
1407 1417
1408 preview_config_input_format(prev, format); 1418 preview_config_input_format(prev, info);
1409 preview_config_input_size(prev, active); 1419 preview_config_input_size(prev, active);
1410 1420
1411 if (prev->input == PREVIEW_INPUT_CCDC) 1421 if (prev->input == PREVIEW_INPUT_CCDC)
1412 preview_config_inlineoffset(prev, 0); 1422 preview_config_inlineoffset(prev, 0);
1413 else 1423 else
1414 preview_config_inlineoffset(prev, 1424 preview_config_inlineoffset(prev, ALIGN(format->width, 0x20) *
1415 ALIGN(format->width, 0x20) * 2); 1425 info->bpp);
1416 1426
1417 preview_setup_hw(prev, update, active); 1427 preview_setup_hw(prev, update, active);
1418 1428
@@ -1709,6 +1719,11 @@ __preview_get_crop(struct isp_prev_device *prev, struct v4l2_subdev_fh *fh,
1709 1719
1710/* previewer format descriptions */ 1720/* previewer format descriptions */
1711static const unsigned int preview_input_fmts[] = { 1721static const unsigned int preview_input_fmts[] = {
1722 V4L2_MBUS_FMT_Y8_1X8,
1723 V4L2_MBUS_FMT_SGRBG8_1X8,
1724 V4L2_MBUS_FMT_SRGGB8_1X8,
1725 V4L2_MBUS_FMT_SBGGR8_1X8,
1726 V4L2_MBUS_FMT_SGBRG8_1X8,
1712 V4L2_MBUS_FMT_Y10_1X10, 1727 V4L2_MBUS_FMT_Y10_1X10,
1713 V4L2_MBUS_FMT_SGRBG10_1X10, 1728 V4L2_MBUS_FMT_SGRBG10_1X10,
1714 V4L2_MBUS_FMT_SRGGB10_1X10, 1729 V4L2_MBUS_FMT_SRGGB10_1X10,
diff --git a/drivers/media/platform/omap3isp/ispreg.h b/drivers/media/platform/omap3isp/ispreg.h
index e2c57f334c5d..b7d90e6fb01d 100644
--- a/drivers/media/platform/omap3isp/ispreg.h
+++ b/drivers/media/platform/omap3isp/ispreg.h
@@ -29,83 +29,6 @@
29 29
30#define CM_CAM_MCLK_HZ 172800000 /* Hz */ 30#define CM_CAM_MCLK_HZ 172800000 /* Hz */
31 31
32/* ISP Submodules offset */
33
34#define L4_34XX_BASE 0x48000000
35#define OMAP3430_ISP_BASE (L4_34XX_BASE + 0xBC000)
36
37#define OMAP3ISP_REG_BASE OMAP3430_ISP_BASE
38#define OMAP3ISP_REG(offset) (OMAP3ISP_REG_BASE + (offset))
39
40#define OMAP3ISP_CCP2_REG_OFFSET 0x0400
41#define OMAP3ISP_CCP2_REG_BASE (OMAP3ISP_REG_BASE + \
42 OMAP3ISP_CCP2_REG_OFFSET)
43#define OMAP3ISP_CCP2_REG(offset) (OMAP3ISP_CCP2_REG_BASE + (offset))
44
45#define OMAP3ISP_CCDC_REG_OFFSET 0x0600
46#define OMAP3ISP_CCDC_REG_BASE (OMAP3ISP_REG_BASE + \
47 OMAP3ISP_CCDC_REG_OFFSET)
48#define OMAP3ISP_CCDC_REG(offset) (OMAP3ISP_CCDC_REG_BASE + (offset))
49
50#define OMAP3ISP_HIST_REG_OFFSET 0x0A00
51#define OMAP3ISP_HIST_REG_BASE (OMAP3ISP_REG_BASE + \
52 OMAP3ISP_HIST_REG_OFFSET)
53#define OMAP3ISP_HIST_REG(offset) (OMAP3ISP_HIST_REG_BASE + (offset))
54
55#define OMAP3ISP_H3A_REG_OFFSET 0x0C00
56#define OMAP3ISP_H3A_REG_BASE (OMAP3ISP_REG_BASE + \
57 OMAP3ISP_H3A_REG_OFFSET)
58#define OMAP3ISP_H3A_REG(offset) (OMAP3ISP_H3A_REG_BASE + (offset))
59
60#define OMAP3ISP_PREV_REG_OFFSET 0x0E00
61#define OMAP3ISP_PREV_REG_BASE (OMAP3ISP_REG_BASE + \
62 OMAP3ISP_PREV_REG_OFFSET)
63#define OMAP3ISP_PREV_REG(offset) (OMAP3ISP_PREV_REG_BASE + (offset))
64
65#define OMAP3ISP_RESZ_REG_OFFSET 0x1000
66#define OMAP3ISP_RESZ_REG_BASE (OMAP3ISP_REG_BASE + \
67 OMAP3ISP_RESZ_REG_OFFSET)
68#define OMAP3ISP_RESZ_REG(offset) (OMAP3ISP_RESZ_REG_BASE + (offset))
69
70#define OMAP3ISP_SBL_REG_OFFSET 0x1200
71#define OMAP3ISP_SBL_REG_BASE (OMAP3ISP_REG_BASE + \
72 OMAP3ISP_SBL_REG_OFFSET)
73#define OMAP3ISP_SBL_REG(offset) (OMAP3ISP_SBL_REG_BASE + (offset))
74
75#define OMAP3ISP_CSI2A_REGS1_REG_OFFSET 0x1800
76#define OMAP3ISP_CSI2A_REGS1_REG_BASE (OMAP3ISP_REG_BASE + \
77 OMAP3ISP_CSI2A_REGS1_REG_OFFSET)
78#define OMAP3ISP_CSI2A_REGS1_REG(offset) \
79 (OMAP3ISP_CSI2A_REGS1_REG_BASE + (offset))
80
81#define OMAP3ISP_CSIPHY2_REG_OFFSET 0x1970
82#define OMAP3ISP_CSIPHY2_REG_BASE (OMAP3ISP_REG_BASE + \
83 OMAP3ISP_CSIPHY2_REG_OFFSET)
84#define OMAP3ISP_CSIPHY2_REG(offset) (OMAP3ISP_CSIPHY2_REG_BASE + (offset))
85
86#define OMAP3ISP_CSI2A_REGS2_REG_OFFSET 0x19C0
87#define OMAP3ISP_CSI2A_REGS2_REG_BASE (OMAP3ISP_REG_BASE + \
88 OMAP3ISP_CSI2A_REGS2_REG_OFFSET)
89#define OMAP3ISP_CSI2A_REGS2_REG(offset) \
90 (OMAP3ISP_CSI2A_REGS2_REG_BASE + (offset))
91
92#define OMAP3ISP_CSI2C_REGS1_REG_OFFSET 0x1C00
93#define OMAP3ISP_CSI2C_REGS1_REG_BASE (OMAP3ISP_REG_BASE + \
94 OMAP3ISP_CSI2C_REGS1_REG_OFFSET)
95#define OMAP3ISP_CSI2C_REGS1_REG(offset) \
96 (OMAP3ISP_CSI2C_REGS1_REG_BASE + (offset))
97
98#define OMAP3ISP_CSIPHY1_REG_OFFSET 0x1D70
99#define OMAP3ISP_CSIPHY1_REG_BASE (OMAP3ISP_REG_BASE + \
100 OMAP3ISP_CSIPHY1_REG_OFFSET)
101#define OMAP3ISP_CSIPHY1_REG(offset) (OMAP3ISP_CSIPHY1_REG_BASE + (offset))
102
103#define OMAP3ISP_CSI2C_REGS2_REG_OFFSET 0x1DC0
104#define OMAP3ISP_CSI2C_REGS2_REG_BASE (OMAP3ISP_REG_BASE + \
105 OMAP3ISP_CSI2C_REGS2_REG_OFFSET)
106#define OMAP3ISP_CSI2C_REGS2_REG(offset) \
107 (OMAP3ISP_CSI2C_REGS2_REG_BASE + (offset))
108
109/* ISP module register offset */ 32/* ISP module register offset */
110 33
111#define ISP_REVISION (0x000) 34#define ISP_REVISION (0x000)
@@ -1583,4 +1506,26 @@
1583#define ISPCSIPHY_REG2_CCP2_SYNC_PATTERN_MASK \ 1506#define ISPCSIPHY_REG2_CCP2_SYNC_PATTERN_MASK \
1584 (0x7fffff << ISPCSIPHY_REG2_CCP2_SYNC_PATTERN_SHIFT) 1507 (0x7fffff << ISPCSIPHY_REG2_CCP2_SYNC_PATTERN_SHIFT)
1585 1508
1509/* -----------------------------------------------------------------------------
1510 * CONTROL registers for CSI-2 phy routing
1511 */
1512
1513/* OMAP343X_CONTROL_CSIRXFE */
1514#define OMAP343X_CONTROL_CSIRXFE_CSIB_INV (1 << 7)
1515#define OMAP343X_CONTROL_CSIRXFE_RESENABLE (1 << 8)
1516#define OMAP343X_CONTROL_CSIRXFE_SELFORM (1 << 10)
1517#define OMAP343X_CONTROL_CSIRXFE_PWRDNZ (1 << 12)
1518#define OMAP343X_CONTROL_CSIRXFE_RESET (1 << 13)
1519
1520/* OMAP3630_CONTROL_CAMERA_PHY_CTRL */
1521#define OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_PHY1_SHIFT 2
1522#define OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_PHY2_SHIFT 0
1523#define OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_DPHY 0x0
1524#define OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_CCP2_DATA_STROBE 0x1
1525#define OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_CCP2_DATA_CLOCK 0x2
1526#define OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_GPI 0x3
1527#define OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_MASK 0x3
1528/* CCP2B: set to receive data from PHY2 instead of PHY1 */
1529#define OMAP3630_CONTROL_CAMERA_PHY_CTRL_CSI1_RX_SEL_PHY2 (1 << 4)
1530
1586#endif /* OMAP3_ISP_REG_H */ 1531#endif /* OMAP3_ISP_REG_H */
diff --git a/drivers/media/platform/omap3isp/ispstat.c b/drivers/media/platform/omap3isp/ispstat.c
index e7939869bda7..61e17f9bd8b9 100644
--- a/drivers/media/platform/omap3isp/ispstat.c
+++ b/drivers/media/platform/omap3isp/ispstat.c
@@ -257,7 +257,7 @@ static int isp_stat_buf_queue(struct ispstat *stat)
257 if (!stat->active_buf) 257 if (!stat->active_buf)
258 return STAT_NO_BUF; 258 return STAT_NO_BUF;
259 259
260 do_gettimeofday(&stat->active_buf->ts); 260 ktime_get_ts(&stat->active_buf->ts);
261 261
262 stat->active_buf->buf_size = stat->buf_size; 262 stat->active_buf->buf_size = stat->buf_size;
263 if (isp_stat_buf_check_magic(stat, stat->active_buf)) { 263 if (isp_stat_buf_check_magic(stat, stat->active_buf)) {
@@ -537,7 +537,8 @@ int omap3isp_stat_request_statistics(struct ispstat *stat,
537 return PTR_ERR(buf); 537 return PTR_ERR(buf);
538 } 538 }
539 539
540 data->ts = buf->ts; 540 data->ts.tv_sec = buf->ts.tv_sec;
541 data->ts.tv_usec = buf->ts.tv_nsec / NSEC_PER_USEC;
541 data->config_counter = buf->config_counter; 542 data->config_counter = buf->config_counter;
542 data->frame_number = buf->frame_number; 543 data->frame_number = buf->frame_number;
543 data->buf_size = buf->buf_size; 544 data->buf_size = buf->buf_size;
diff --git a/drivers/media/platform/omap3isp/ispstat.h b/drivers/media/platform/omap3isp/ispstat.h
index fd15094de34a..9a047c929b9f 100644
--- a/drivers/media/platform/omap3isp/ispstat.h
+++ b/drivers/media/platform/omap3isp/ispstat.h
@@ -50,7 +50,7 @@ struct ispstat_buffer {
50 struct iovm_struct *iovm; 50 struct iovm_struct *iovm;
51 void *virt_addr; 51 void *virt_addr;
52 dma_addr_t dma_addr; 52 dma_addr_t dma_addr;
53 struct timeval ts; 53 struct timespec ts;
54 u32 buf_size; 54 u32 buf_size;
55 u32 frame_number; 55 u32 frame_number;
56 u16 config_counter; 56 u16 config_counter;
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c
index 3311d6bb3456..e0d73a642186 100644
--- a/drivers/media/platform/omap3isp/ispvideo.c
+++ b/drivers/media/platform/omap3isp/ispvideo.c
@@ -1392,7 +1392,8 @@ int omap3isp_video_register(struct isp_video *video, struct v4l2_device *vdev)
1392 1392
1393 ret = video_register_device(&video->video, VFL_TYPE_GRABBER, -1); 1393 ret = video_register_device(&video->video, VFL_TYPE_GRABBER, -1);
1394 if (ret < 0) 1394 if (ret < 0)
1395 printk(KERN_ERR "%s: could not register video device (%d)\n", 1395 dev_err(video->isp->dev,
1396 "%s: could not register video device (%d)\n",
1396 __func__, ret); 1397 __func__, ret);
1397 1398
1398 return ret; 1399 return ret;
diff --git a/drivers/media/platform/s3c-camif/Makefile b/drivers/media/platform/s3c-camif/Makefile
new file mode 100644
index 000000000000..50bf8c59b99c
--- /dev/null
+++ b/drivers/media/platform/s3c-camif/Makefile
@@ -0,0 +1,5 @@
1# Makefile for s3c244x/s3c64xx CAMIF driver
2
3s3c-camif-objs := camif-core.o camif-capture.o camif-regs.o
4
5obj-$(CONFIG_VIDEO_S3C_CAMIF) += s3c-camif.o
diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c
new file mode 100644
index 000000000000..a55793c3d811
--- /dev/null
+++ b/drivers/media/platform/s3c-camif/camif-capture.c
@@ -0,0 +1,1672 @@
1/*
2 * s3c24xx/s3c64xx SoC series Camera Interface (CAMIF) driver
3 *
4 * Copyright (C) 2012 Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
5 * Copyright (C) 2012 Tomasz Figa <tomasz.figa@gmail.com>
6 *
7 * Based on drivers/media/platform/s5p-fimc,
8 * Copyright (C) 2010 - 2012 Samsung Electronics Co., Ltd.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13*/
14#define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
15
16#include <linux/bug.h>
17#include <linux/clk.h>
18#include <linux/device.h>
19#include <linux/errno.h>
20#include <linux/i2c.h>
21#include <linux/interrupt.h>
22#include <linux/io.h>
23#include <linux/kernel.h>
24#include <linux/list.h>
25#include <linux/module.h>
26#include <linux/platform_device.h>
27#include <linux/pm_runtime.h>
28#include <linux/ratelimit.h>
29#include <linux/slab.h>
30#include <linux/types.h>
31#include <linux/videodev2.h>
32
33#include <media/media-device.h>
34#include <media/v4l2-ctrls.h>
35#include <media/v4l2-event.h>
36#include <media/v4l2-ioctl.h>
37#include <media/videobuf2-core.h>
38#include <media/videobuf2-dma-contig.h>
39
40#include "camif-core.h"
41#include "camif-regs.h"
42
43static int debug;
44module_param(debug, int, 0644);
45
46/* Locking: called with vp->camif->slock spinlock held */
47static void camif_cfg_video_path(struct camif_vp *vp)
48{
49 WARN_ON(s3c_camif_get_scaler_config(vp, &vp->scaler));
50 camif_hw_set_scaler(vp);
51 camif_hw_set_flip(vp);
52 camif_hw_set_target_format(vp);
53 camif_hw_set_output_dma(vp);
54}
55
56static void camif_prepare_dma_offset(struct camif_vp *vp)
57{
58 struct camif_frame *f = &vp->out_frame;
59
60 f->dma_offset.initial = f->rect.top * f->f_width + f->rect.left;
61 f->dma_offset.line = f->f_width - (f->rect.left + f->rect.width);
62
63 pr_debug("dma_offset: initial: %d, line: %d\n",
64 f->dma_offset.initial, f->dma_offset.line);
65}
66
67/* Locking: called with camif->slock spinlock held */
68static int s3c_camif_hw_init(struct camif_dev *camif, struct camif_vp *vp)
69{
70 const struct s3c_camif_variant *variant = camif->variant;
71
72 if (camif->sensor.sd == NULL || vp->out_fmt == NULL)
73 return -EINVAL;
74
75 if (variant->ip_revision == S3C244X_CAMIF_IP_REV)
76 camif_hw_clear_fifo_overflow(vp);
77 camif_hw_set_camera_bus(camif);
78 camif_hw_set_source_format(camif);
79 camif_hw_set_camera_crop(camif);
80 camif_hw_set_test_pattern(camif, camif->test_pattern);
81 if (variant->has_img_effect)
82 camif_hw_set_effect(camif, camif->colorfx,
83 camif->colorfx_cb, camif->colorfx_cr);
84 if (variant->ip_revision == S3C6410_CAMIF_IP_REV)
85 camif_hw_set_input_path(vp);
86 camif_cfg_video_path(vp);
87 vp->state &= ~ST_VP_CONFIG;
88
89 return 0;
90}
91
92/*
93 * Initialize the video path, only up from the scaler stage. The camera
94 * input interface set up is skipped. This is useful to enable one of the
95 * video paths when the other is already running.
96 * Locking: called with camif->slock spinlock held.
97 */
98static int s3c_camif_hw_vp_init(struct camif_dev *camif, struct camif_vp *vp)
99{
100 unsigned int ip_rev = camif->variant->ip_revision;
101
102 if (vp->out_fmt == NULL)
103 return -EINVAL;
104
105 camif_prepare_dma_offset(vp);
106 if (ip_rev == S3C244X_CAMIF_IP_REV)
107 camif_hw_clear_fifo_overflow(vp);
108 camif_cfg_video_path(vp);
109 vp->state &= ~ST_VP_CONFIG;
110 return 0;
111}
112
113static int sensor_set_power(struct camif_dev *camif, int on)
114{
115 struct cam_sensor *sensor = &camif->sensor;
116 int err = 0;
117
118 if (!on == camif->sensor.power_count)
119 err = v4l2_subdev_call(sensor->sd, core, s_power, on);
120 if (!err)
121 sensor->power_count += on ? 1 : -1;
122
123 pr_debug("on: %d, power_count: %d, err: %d\n",
124 on, sensor->power_count, err);
125
126 return err;
127}
128
129static int sensor_set_streaming(struct camif_dev *camif, int on)
130{
131 struct cam_sensor *sensor = &camif->sensor;
132 int err = 0;
133
134 if (!on == camif->sensor.stream_count)
135 err = v4l2_subdev_call(sensor->sd, video, s_stream, on);
136 if (!err)
137 sensor->stream_count += on ? 1 : -1;
138
139 pr_debug("on: %d, stream_count: %d, err: %d\n",
140 on, sensor->stream_count, err);
141
142 return err;
143}
144
145/*
146 * Reinitialize the driver so it is ready to start streaming again.
147 * Return any buffers to vb2, perform CAMIF software reset and
148 * turn off streaming at the data pipeline (sensor) if required.
149 */
150static int camif_reinitialize(struct camif_vp *vp)
151{
152 struct camif_dev *camif = vp->camif;
153 struct camif_buffer *buf;
154 unsigned long flags;
155 bool streaming;
156
157 spin_lock_irqsave(&camif->slock, flags);
158 streaming = vp->state & ST_VP_SENSOR_STREAMING;
159
160 vp->state &= ~(ST_VP_PENDING | ST_VP_RUNNING | ST_VP_OFF |
161 ST_VP_ABORTING | ST_VP_STREAMING |
162 ST_VP_SENSOR_STREAMING | ST_VP_LASTIRQ);
163
164 /* Release unused buffers */
165 while (!list_empty(&vp->pending_buf_q)) {
166 buf = camif_pending_queue_pop(vp);
167 vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR);
168 }
169
170 while (!list_empty(&vp->active_buf_q)) {
171 buf = camif_active_queue_pop(vp);
172 vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR);
173 }
174
175 spin_unlock_irqrestore(&camif->slock, flags);
176
177 if (!streaming)
178 return 0;
179
180 return sensor_set_streaming(camif, 0);
181}
182
183static bool s3c_vp_active(struct camif_vp *vp)
184{
185 struct camif_dev *camif = vp->camif;
186 unsigned long flags;
187 bool ret;
188
189 spin_lock_irqsave(&camif->slock, flags);
190 ret = (vp->state & ST_VP_RUNNING) || (vp->state & ST_VP_PENDING);
191 spin_unlock_irqrestore(&camif->slock, flags);
192
193 return ret;
194}
195
196static bool camif_is_streaming(struct camif_dev *camif)
197{
198 unsigned long flags;
199 bool status;
200
201 spin_lock_irqsave(&camif->slock, flags);
202 status = camif->stream_count > 0;
203 spin_unlock_irqrestore(&camif->slock, flags);
204
205 return status;
206}
207
208static int camif_stop_capture(struct camif_vp *vp)
209{
210 struct camif_dev *camif = vp->camif;
211 unsigned long flags;
212 int ret;
213
214 if (!s3c_vp_active(vp))
215 return 0;
216
217 spin_lock_irqsave(&camif->slock, flags);
218 vp->state &= ~(ST_VP_OFF | ST_VP_LASTIRQ);
219 vp->state |= ST_VP_ABORTING;
220 spin_unlock_irqrestore(&camif->slock, flags);
221
222 ret = wait_event_timeout(vp->irq_queue,
223 !(vp->state & ST_VP_ABORTING),
224 msecs_to_jiffies(CAMIF_STOP_TIMEOUT));
225
226 spin_lock_irqsave(&camif->slock, flags);
227
228 if (ret == 0 && !(vp->state & ST_VP_OFF)) {
229 /* Timed out, forcibly stop capture */
230 vp->state &= ~(ST_VP_OFF | ST_VP_ABORTING |
231 ST_VP_LASTIRQ);
232
233 camif_hw_disable_capture(vp);
234 camif_hw_enable_scaler(vp, false);
235 }
236
237 spin_unlock_irqrestore(&camif->slock, flags);
238
239 return camif_reinitialize(vp);
240}
241
242static int camif_prepare_addr(struct camif_vp *vp, struct vb2_buffer *vb,
243 struct camif_addr *paddr)
244{
245 struct camif_frame *frame = &vp->out_frame;
246 u32 pix_size;
247
248 if (vb == NULL || frame == NULL)
249 return -EINVAL;
250
251 pix_size = frame->rect.width * frame->rect.height;
252
253 pr_debug("colplanes: %d, pix_size: %u\n",
254 vp->out_fmt->colplanes, pix_size);
255
256 paddr->y = vb2_dma_contig_plane_dma_addr(vb, 0);
257
258 switch (vp->out_fmt->colplanes) {
259 case 1:
260 paddr->cb = 0;
261 paddr->cr = 0;
262 break;
263 case 2:
264 /* decompose Y into Y/Cb */
265 paddr->cb = (u32)(paddr->y + pix_size);
266 paddr->cr = 0;
267 break;
268 case 3:
269 paddr->cb = (u32)(paddr->y + pix_size);
270 /* decompose Y into Y/Cb/Cr */
271 if (vp->out_fmt->color == IMG_FMT_YCBCR422P)
272 paddr->cr = (u32)(paddr->cb + (pix_size >> 1));
273 else /* 420 */
274 paddr->cr = (u32)(paddr->cb + (pix_size >> 2));
275
276 if (vp->out_fmt->color == IMG_FMT_YCRCB420)
277 swap(paddr->cb, paddr->cr);
278 break;
279 default:
280 return -EINVAL;
281 }
282
283 pr_debug("DMA address: y: %#x cb: %#x cr: %#x\n",
284 paddr->y, paddr->cb, paddr->cr);
285
286 return 0;
287}
288
289irqreturn_t s3c_camif_irq_handler(int irq, void *priv)
290{
291 struct camif_vp *vp = priv;
292 struct camif_dev *camif = vp->camif;
293 unsigned int ip_rev = camif->variant->ip_revision;
294 unsigned int status;
295
296 spin_lock(&camif->slock);
297
298 if (ip_rev == S3C6410_CAMIF_IP_REV)
299 camif_hw_clear_pending_irq(vp);
300
301 status = camif_hw_get_status(vp);
302
303 if (ip_rev == S3C244X_CAMIF_IP_REV && (status & CISTATUS_OVF_MASK)) {
304 camif_hw_clear_fifo_overflow(vp);
305 goto unlock;
306 }
307
308 if (vp->state & ST_VP_ABORTING) {
309 if (vp->state & ST_VP_OFF) {
310 /* Last IRQ */
311 vp->state &= ~(ST_VP_OFF | ST_VP_ABORTING |
312 ST_VP_LASTIRQ);
313 wake_up(&vp->irq_queue);
314 goto unlock;
315 } else if (vp->state & ST_VP_LASTIRQ) {
316 camif_hw_disable_capture(vp);
317 camif_hw_enable_scaler(vp, false);
318 camif_hw_set_lastirq(vp, false);
319 vp->state |= ST_VP_OFF;
320 } else {
321 /* Disable capture, enable last IRQ */
322 camif_hw_set_lastirq(vp, true);
323 vp->state |= ST_VP_LASTIRQ;
324 }
325 }
326
327 if (!list_empty(&vp->pending_buf_q) && (vp->state & ST_VP_RUNNING) &&
328 !list_empty(&vp->active_buf_q)) {
329 unsigned int index;
330 struct camif_buffer *vbuf;
331 struct timeval *tv;
332 struct timespec ts;
333 /*
334 * Get previous DMA write buffer index:
335 * 0 => DMA buffer 0, 2;
336 * 1 => DMA buffer 1, 3.
337 */
338 index = (CISTATUS_FRAMECNT(status) + 2) & 1;
339
340 ktime_get_ts(&ts);
341 vbuf = camif_active_queue_peek(vp, index);
342
343 if (!WARN_ON(vbuf == NULL)) {
344 /* Dequeue a filled buffer */
345 tv = &vbuf->vb.v4l2_buf.timestamp;
346 tv->tv_sec = ts.tv_sec;
347 tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC;
348 vbuf->vb.v4l2_buf.sequence = vp->frame_sequence++;
349 vb2_buffer_done(&vbuf->vb, VB2_BUF_STATE_DONE);
350
351 /* Set up an empty buffer at the DMA engine */
352 vbuf = camif_pending_queue_pop(vp);
353 vbuf->index = index;
354 camif_hw_set_output_addr(vp, &vbuf->paddr, index);
355 camif_hw_set_output_addr(vp, &vbuf->paddr, index + 2);
356
357 /* Scheduled in H/W, add to the queue */
358 camif_active_queue_add(vp, vbuf);
359 }
360 } else if (!(vp->state & ST_VP_ABORTING) &&
361 (vp->state & ST_VP_PENDING)) {
362 vp->state |= ST_VP_RUNNING;
363 }
364
365 if (vp->state & ST_VP_CONFIG) {
366 camif_prepare_dma_offset(vp);
367 camif_hw_set_camera_crop(camif);
368 camif_hw_set_scaler(vp);
369 camif_hw_set_flip(vp);
370 camif_hw_set_test_pattern(camif, camif->test_pattern);
371 if (camif->variant->has_img_effect)
372 camif_hw_set_effect(camif, camif->colorfx,
373 camif->colorfx_cb, camif->colorfx_cr);
374 vp->state &= ~ST_VP_CONFIG;
375 }
376unlock:
377 spin_unlock(&camif->slock);
378 return IRQ_HANDLED;
379}
380
381static int start_streaming(struct vb2_queue *vq, unsigned int count)
382{
383 struct camif_vp *vp = vb2_get_drv_priv(vq);
384 struct camif_dev *camif = vp->camif;
385 unsigned long flags;
386 int ret;
387
388 /*
389 * We assume the codec capture path is always activated
390 * first, before the preview path starts streaming.
391 * This is required to avoid internal FIFO overflow and
392 * a need for CAMIF software reset.
393 */
394 spin_lock_irqsave(&camif->slock, flags);
395
396 if (camif->stream_count == 0) {
397 camif_hw_reset(camif);
398 ret = s3c_camif_hw_init(camif, vp);
399 } else {
400 ret = s3c_camif_hw_vp_init(camif, vp);
401 }
402 spin_unlock_irqrestore(&camif->slock, flags);
403
404 if (ret < 0) {
405 camif_reinitialize(vp);
406 return ret;
407 }
408
409 spin_lock_irqsave(&camif->slock, flags);
410 vp->frame_sequence = 0;
411 vp->state |= ST_VP_PENDING;
412
413 if (!list_empty(&vp->pending_buf_q) &&
414 (!(vp->state & ST_VP_STREAMING) ||
415 !(vp->state & ST_VP_SENSOR_STREAMING))) {
416
417 camif_hw_enable_scaler(vp, vp->scaler.enable);
418 camif_hw_enable_capture(vp);
419 vp->state |= ST_VP_STREAMING;
420
421 if (!(vp->state & ST_VP_SENSOR_STREAMING)) {
422 vp->state |= ST_VP_SENSOR_STREAMING;
423 spin_unlock_irqrestore(&camif->slock, flags);
424 ret = sensor_set_streaming(camif, 1);
425 if (ret)
426 v4l2_err(&vp->vdev, "Sensor s_stream failed\n");
427 if (debug)
428 camif_hw_dump_regs(camif, __func__);
429
430 return ret;
431 }
432 }
433
434 spin_unlock_irqrestore(&camif->slock, flags);
435 return 0;
436}
437
438static int stop_streaming(struct vb2_queue *vq)
439{
440 struct camif_vp *vp = vb2_get_drv_priv(vq);
441 return camif_stop_capture(vp);
442}
443
444static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *pfmt,
445 unsigned int *num_buffers, unsigned int *num_planes,
446 unsigned int sizes[], void *allocators[])
447{
448 const struct v4l2_pix_format *pix = NULL;
449 struct camif_vp *vp = vb2_get_drv_priv(vq);
450 struct camif_dev *camif = vp->camif;
451 struct camif_frame *frame = &vp->out_frame;
452 const struct camif_fmt *fmt = vp->out_fmt;
453 unsigned int size;
454
455 if (pfmt) {
456 pix = &pfmt->fmt.pix;
457 fmt = s3c_camif_find_format(vp, &pix->pixelformat, -1);
458 size = (pix->width * pix->height * fmt->depth) / 8;
459 } else {
460 size = (frame->f_width * frame->f_height * fmt->depth) / 8;
461 }
462
463 if (fmt == NULL)
464 return -EINVAL;
465 *num_planes = 1;
466
467 if (pix)
468 sizes[0] = max(size, pix->sizeimage);
469 else
470 sizes[0] = size;
471 allocators[0] = camif->alloc_ctx;
472
473 pr_debug("size: %u\n", sizes[0]);
474 return 0;
475}
476
477static int buffer_prepare(struct vb2_buffer *vb)
478{
479 struct camif_vp *vp = vb2_get_drv_priv(vb->vb2_queue);
480
481 if (vp->out_fmt == NULL)
482 return -EINVAL;
483
484 if (vb2_plane_size(vb, 0) < vp->payload) {
485 v4l2_err(&vp->vdev, "buffer too small: %lu, required: %u\n",
486 vb2_plane_size(vb, 0), vp->payload);
487 return -EINVAL;
488 }
489 vb2_set_plane_payload(vb, 0, vp->payload);
490
491 return 0;
492}
493
494static void buffer_queue(struct vb2_buffer *vb)
495{
496 struct camif_buffer *buf = container_of(vb, struct camif_buffer, vb);
497 struct camif_vp *vp = vb2_get_drv_priv(vb->vb2_queue);
498 struct camif_dev *camif = vp->camif;
499 unsigned long flags;
500
501 spin_lock_irqsave(&camif->slock, flags);
502 WARN_ON(camif_prepare_addr(vp, &buf->vb, &buf->paddr));
503
504 if (!(vp->state & ST_VP_STREAMING) && vp->active_buffers < 2) {
505 /* Schedule an empty buffer in H/W */
506 buf->index = vp->buf_index;
507
508 camif_hw_set_output_addr(vp, &buf->paddr, buf->index);
509 camif_hw_set_output_addr(vp, &buf->paddr, buf->index + 2);
510
511 camif_active_queue_add(vp, buf);
512 vp->buf_index = !vp->buf_index;
513 } else {
514 camif_pending_queue_add(vp, buf);
515 }
516
517 if (vb2_is_streaming(&vp->vb_queue) && !list_empty(&vp->pending_buf_q)
518 && !(vp->state & ST_VP_STREAMING)) {
519
520 vp->state |= ST_VP_STREAMING;
521 camif_hw_enable_scaler(vp, vp->scaler.enable);
522 camif_hw_enable_capture(vp);
523 spin_unlock_irqrestore(&camif->slock, flags);
524
525 if (!(vp->state & ST_VP_SENSOR_STREAMING)) {
526 if (sensor_set_streaming(camif, 1) == 0)
527 vp->state |= ST_VP_SENSOR_STREAMING;
528 else
529 v4l2_err(&vp->vdev, "Sensor s_stream failed\n");
530
531 if (debug)
532 camif_hw_dump_regs(camif, __func__);
533 }
534 return;
535 }
536 spin_unlock_irqrestore(&camif->slock, flags);
537}
538
539static void camif_lock(struct vb2_queue *vq)
540{
541 struct camif_vp *vp = vb2_get_drv_priv(vq);
542 mutex_lock(&vp->camif->lock);
543}
544
545static void camif_unlock(struct vb2_queue *vq)
546{
547 struct camif_vp *vp = vb2_get_drv_priv(vq);
548 mutex_unlock(&vp->camif->lock);
549}
550
551static const struct vb2_ops s3c_camif_qops = {
552 .queue_setup = queue_setup,
553 .buf_prepare = buffer_prepare,
554 .buf_queue = buffer_queue,
555 .wait_prepare = camif_unlock,
556 .wait_finish = camif_lock,
557 .start_streaming = start_streaming,
558 .stop_streaming = stop_streaming,
559};
560
561static int s3c_camif_open(struct file *file)
562{
563 struct camif_vp *vp = video_drvdata(file);
564 struct camif_dev *camif = vp->camif;
565 int ret;
566
567 pr_debug("[vp%d] state: %#x, owner: %p, pid: %d\n", vp->id,
568 vp->state, vp->owner, task_pid_nr(current));
569
570 if (mutex_lock_interruptible(&camif->lock))
571 return -ERESTARTSYS;
572
573 ret = v4l2_fh_open(file);
574 if (ret < 0)
575 goto unlock;
576
577 ret = pm_runtime_get_sync(camif->dev);
578 if (ret < 0)
579 goto err_pm;
580
581 ret = sensor_set_power(camif, 1);
582 if (!ret)
583 goto unlock;
584
585 pm_runtime_put(camif->dev);
586err_pm:
587 v4l2_fh_release(file);
588unlock:
589 mutex_unlock(&camif->lock);
590 return ret;
591}
592
593static int s3c_camif_close(struct file *file)
594{
595 struct camif_vp *vp = video_drvdata(file);
596 struct camif_dev *camif = vp->camif;
597 int ret;
598
599 pr_debug("[vp%d] state: %#x, owner: %p, pid: %d\n", vp->id,
600 vp->state, vp->owner, task_pid_nr(current));
601
602 mutex_lock(&camif->lock);
603
604 if (vp->owner == file->private_data) {
605 camif_stop_capture(vp);
606 vb2_queue_release(&vp->vb_queue);
607 vp->owner = NULL;
608 }
609
610 sensor_set_power(camif, 0);
611
612 pm_runtime_put(camif->dev);
613 ret = v4l2_fh_release(file);
614
615 mutex_unlock(&camif->lock);
616 return ret;
617}
618
619static unsigned int s3c_camif_poll(struct file *file,
620 struct poll_table_struct *wait)
621{
622 struct camif_vp *vp = video_drvdata(file);
623 struct camif_dev *camif = vp->camif;
624 int ret;
625
626 mutex_lock(&camif->lock);
627 if (vp->owner && vp->owner != file->private_data)
628 ret = -EBUSY;
629 else
630 ret = vb2_poll(&vp->vb_queue, file, wait);
631
632 mutex_unlock(&camif->lock);
633 return ret;
634}
635
636static int s3c_camif_mmap(struct file *file, struct vm_area_struct *vma)
637{
638 struct camif_vp *vp = video_drvdata(file);
639 int ret;
640
641 if (vp->owner && vp->owner != file->private_data)
642 ret = -EBUSY;
643 else
644 ret = vb2_mmap(&vp->vb_queue, vma);
645
646 return ret;
647}
648
649static const struct v4l2_file_operations s3c_camif_fops = {
650 .owner = THIS_MODULE,
651 .open = s3c_camif_open,
652 .release = s3c_camif_close,
653 .poll = s3c_camif_poll,
654 .unlocked_ioctl = video_ioctl2,
655 .mmap = s3c_camif_mmap,
656};
657
658/*
659 * Video node IOCTLs
660 */
661
662static int s3c_camif_vidioc_querycap(struct file *file, void *priv,
663 struct v4l2_capability *cap)
664{
665 struct camif_vp *vp = video_drvdata(file);
666
667 strlcpy(cap->driver, S3C_CAMIF_DRIVER_NAME, sizeof(cap->driver));
668 strlcpy(cap->card, S3C_CAMIF_DRIVER_NAME, sizeof(cap->card));
669 snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s.%d",
670 dev_name(vp->camif->dev), vp->id);
671
672 cap->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_CAPTURE;
673 cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
674
675 return 0;
676}
677
678static int s3c_camif_vidioc_enum_input(struct file *file, void *priv,
679 struct v4l2_input *input)
680{
681 struct camif_vp *vp = video_drvdata(file);
682 struct v4l2_subdev *sensor = vp->camif->sensor.sd;
683
684 if (input->index || sensor == NULL)
685 return -EINVAL;
686
687 input->type = V4L2_INPUT_TYPE_CAMERA;
688 strlcpy(input->name, sensor->name, sizeof(input->name));
689 return 0;
690}
691
692static int s3c_camif_vidioc_s_input(struct file *file, void *priv,
693 unsigned int i)
694{
695 return i == 0 ? 0 : -EINVAL;
696}
697
698static int s3c_camif_vidioc_g_input(struct file *file, void *priv,
699 unsigned int *i)
700{
701 *i = 0;
702 return 0;
703}
704
705static int s3c_camif_vidioc_enum_fmt(struct file *file, void *priv,
706 struct v4l2_fmtdesc *f)
707{
708 struct camif_vp *vp = video_drvdata(file);
709 const struct camif_fmt *fmt;
710
711 fmt = s3c_camif_find_format(vp, NULL, f->index);
712 if (!fmt)
713 return -EINVAL;
714
715 strlcpy(f->description, fmt->name, sizeof(f->description));
716 f->pixelformat = fmt->fourcc;
717
718 pr_debug("fmt(%d): %s\n", f->index, f->description);
719 return 0;
720}
721
722static int s3c_camif_vidioc_g_fmt(struct file *file, void *priv,
723 struct v4l2_format *f)
724{
725 struct camif_vp *vp = video_drvdata(file);
726 struct v4l2_pix_format *pix = &f->fmt.pix;
727 struct camif_frame *frame = &vp->out_frame;
728 const struct camif_fmt *fmt = vp->out_fmt;
729
730 pix->bytesperline = frame->f_width * fmt->ybpp;
731 pix->sizeimage = vp->payload;
732
733 pix->pixelformat = fmt->fourcc;
734 pix->width = frame->f_width;
735 pix->height = frame->f_height;
736 pix->field = V4L2_FIELD_NONE;
737 pix->colorspace = V4L2_COLORSPACE_JPEG;
738
739 return 0;
740}
741
742static int __camif_video_try_format(struct camif_vp *vp,
743 struct v4l2_pix_format *pix,
744 const struct camif_fmt **ffmt)
745{
746 struct camif_dev *camif = vp->camif;
747 struct v4l2_rect *crop = &camif->camif_crop;
748 unsigned int wmin, hmin, sc_hrmax, sc_vrmax;
749 const struct vp_pix_limits *pix_lim;
750 const struct camif_fmt *fmt;
751
752 fmt = s3c_camif_find_format(vp, &pix->pixelformat, 0);
753
754 if (WARN_ON(fmt == NULL))
755 return -EINVAL;
756
757 if (ffmt)
758 *ffmt = fmt;
759
760 pix_lim = &camif->variant->vp_pix_limits[vp->id];
761
762 pr_debug("fmt: %ux%u, crop: %ux%u, bytesperline: %u\n",
763 pix->width, pix->height, crop->width, crop->height,
764 pix->bytesperline);
765 /*
766 * Calculate minimum width and height according to the configured
767 * camera input interface crop rectangle and the resizer's capabilities.
768 */
769 sc_hrmax = min(SCALER_MAX_RATIO, 1 << (ffs(crop->width) - 3));
770 sc_vrmax = min(SCALER_MAX_RATIO, 1 << (ffs(crop->height) - 1));
771
772 wmin = max_t(u32, pix_lim->min_out_width, crop->width / sc_hrmax);
773 wmin = round_up(wmin, pix_lim->out_width_align);
774 hmin = max_t(u32, 8, crop->height / sc_vrmax);
775 hmin = round_up(hmin, 8);
776
777 v4l_bound_align_image(&pix->width, wmin, pix_lim->max_sc_out_width,
778 ffs(pix_lim->out_width_align) - 1,
779 &pix->height, hmin, pix_lim->max_height, 0, 0);
780
781 pix->bytesperline = pix->width * fmt->ybpp;
782 pix->sizeimage = (pix->width * pix->height * fmt->depth) / 8;
783 pix->pixelformat = fmt->fourcc;
784 pix->colorspace = V4L2_COLORSPACE_JPEG;
785 pix->field = V4L2_FIELD_NONE;
786
787 pr_debug("%ux%u, wmin: %d, hmin: %d, sc_hrmax: %d, sc_vrmax: %d\n",
788 pix->width, pix->height, wmin, hmin, sc_hrmax, sc_vrmax);
789
790 return 0;
791}
792
793static int s3c_camif_vidioc_try_fmt(struct file *file, void *priv,
794 struct v4l2_format *f)
795{
796 struct camif_vp *vp = video_drvdata(file);
797 return __camif_video_try_format(vp, &f->fmt.pix, NULL);
798}
799
800static int s3c_camif_vidioc_s_fmt(struct file *file, void *priv,
801 struct v4l2_format *f)
802{
803 struct v4l2_pix_format *pix = &f->fmt.pix;
804 struct camif_vp *vp = video_drvdata(file);
805 struct camif_frame *out_frame = &vp->out_frame;
806 const struct camif_fmt *fmt = NULL;
807 int ret;
808
809 pr_debug("[vp%d]\n", vp->id);
810
811 if (vb2_is_busy(&vp->vb_queue))
812 return -EBUSY;
813
814 ret = __camif_video_try_format(vp, &f->fmt.pix, &fmt);
815 if (ret < 0)
816 return ret;
817
818 vp->out_fmt = fmt;
819 vp->payload = pix->sizeimage;
820 out_frame->f_width = pix->width;
821 out_frame->f_height = pix->height;
822
823 /* Reset composition rectangle */
824 out_frame->rect.width = pix->width;
825 out_frame->rect.height = pix->height;
826 out_frame->rect.left = 0;
827 out_frame->rect.top = 0;
828
829 if (vp->owner == NULL)
830 vp->owner = priv;
831
832 pr_debug("%ux%u. payload: %u. fmt: %s. %d %d. sizeimage: %d. bpl: %d\n",
833 out_frame->f_width, out_frame->f_height, vp->payload, fmt->name,
834 pix->width * pix->height * fmt->depth, fmt->depth,
835 pix->sizeimage, pix->bytesperline);
836
837 return 0;
838}
839
840/* Only check pixel formats at the sensor and the camif subdev pads */
841static int camif_pipeline_validate(struct camif_dev *camif)
842{
843 struct v4l2_subdev_format src_fmt;
844 struct media_pad *pad;
845 int ret;
846
847 /* Retrieve format at the sensor subdev source pad */
848 pad = media_entity_remote_source(&camif->pads[0]);
849 if (!pad || media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
850 return -EPIPE;
851
852 src_fmt.pad = pad->index;
853 src_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
854 ret = v4l2_subdev_call(camif->sensor.sd, pad, get_fmt, NULL, &src_fmt);
855 if (ret < 0 && ret != -ENOIOCTLCMD)
856 return -EPIPE;
857
858 if (src_fmt.format.width != camif->mbus_fmt.width ||
859 src_fmt.format.height != camif->mbus_fmt.height ||
860 src_fmt.format.code != camif->mbus_fmt.code)
861 return -EPIPE;
862
863 return 0;
864}
865
866static int s3c_camif_streamon(struct file *file, void *priv,
867 enum v4l2_buf_type type)
868{
869 struct camif_vp *vp = video_drvdata(file);
870 struct camif_dev *camif = vp->camif;
871 struct media_entity *sensor = &camif->sensor.sd->entity;
872 int ret;
873
874 pr_debug("[vp%d]\n", vp->id);
875
876 if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
877 return -EINVAL;
878
879 if (vp->owner && vp->owner != priv)
880 return -EBUSY;
881
882 if (s3c_vp_active(vp))
883 return 0;
884
885 ret = media_entity_pipeline_start(sensor, camif->m_pipeline);
886 if (ret < 0)
887 return ret;
888
889 ret = camif_pipeline_validate(camif);
890 if (ret < 0) {
891 media_entity_pipeline_stop(sensor);
892 return ret;
893 }
894
895 return vb2_streamon(&vp->vb_queue, type);
896}
897
898static int s3c_camif_streamoff(struct file *file, void *priv,
899 enum v4l2_buf_type type)
900{
901 struct camif_vp *vp = video_drvdata(file);
902 struct camif_dev *camif = vp->camif;
903 int ret;
904
905 pr_debug("[vp%d]\n", vp->id);
906
907 if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
908 return -EINVAL;
909
910 if (vp->owner && vp->owner != priv)
911 return -EBUSY;
912
913 ret = vb2_streamoff(&vp->vb_queue, type);
914 if (ret == 0)
915 media_entity_pipeline_stop(&camif->sensor.sd->entity);
916 return ret;
917}
918
919static int s3c_camif_reqbufs(struct file *file, void *priv,
920 struct v4l2_requestbuffers *rb)
921{
922 struct camif_vp *vp = video_drvdata(file);
923 int ret;
924
925 pr_debug("[vp%d] rb count: %d, owner: %p, priv: %p\n",
926 vp->id, rb->count, vp->owner, priv);
927
928 if (vp->owner && vp->owner != priv)
929 return -EBUSY;
930
931 if (rb->count)
932 rb->count = max_t(u32, CAMIF_REQ_BUFS_MIN, rb->count);
933 else
934 vp->owner = NULL;
935
936 ret = vb2_reqbufs(&vp->vb_queue, rb);
937 if (!ret) {
938 vp->reqbufs_count = rb->count;
939 if (vp->owner == NULL && rb->count > 0)
940 vp->owner = priv;
941 }
942
943 return ret;
944}
945
946static int s3c_camif_querybuf(struct file *file, void *priv,
947 struct v4l2_buffer *buf)
948{
949 struct camif_vp *vp = video_drvdata(file);
950 return vb2_querybuf(&vp->vb_queue, buf);
951}
952
953static int s3c_camif_qbuf(struct file *file, void *priv,
954 struct v4l2_buffer *buf)
955{
956 struct camif_vp *vp = video_drvdata(file);
957
958 pr_debug("[vp%d]\n", vp->id);
959
960 if (vp->owner && vp->owner != priv)
961 return -EBUSY;
962
963 return vb2_qbuf(&vp->vb_queue, buf);
964}
965
966static int s3c_camif_dqbuf(struct file *file, void *priv,
967 struct v4l2_buffer *buf)
968{
969 struct camif_vp *vp = video_drvdata(file);
970
971 pr_debug("[vp%d] sequence: %d\n", vp->id, vp->frame_sequence);
972
973 if (vp->owner && vp->owner != priv)
974 return -EBUSY;
975
976 return vb2_dqbuf(&vp->vb_queue, buf, file->f_flags & O_NONBLOCK);
977}
978
979static int s3c_camif_create_bufs(struct file *file, void *priv,
980 struct v4l2_create_buffers *create)
981{
982 struct camif_vp *vp = video_drvdata(file);
983 int ret;
984
985 if (vp->owner && vp->owner != priv)
986 return -EBUSY;
987
988 create->count = max_t(u32, 1, create->count);
989 ret = vb2_create_bufs(&vp->vb_queue, create);
990
991 if (!ret && vp->owner == NULL)
992 vp->owner = priv;
993
994 return ret;
995}
996
997static int s3c_camif_prepare_buf(struct file *file, void *priv,
998 struct v4l2_buffer *b)
999{
1000 struct camif_vp *vp = video_drvdata(file);
1001 return vb2_prepare_buf(&vp->vb_queue, b);
1002}
1003
1004static int s3c_camif_g_selection(struct file *file, void *priv,
1005 struct v4l2_selection *sel)
1006{
1007 struct camif_vp *vp = video_drvdata(file);
1008
1009 if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1010 return -EINVAL;
1011
1012 switch (sel->target) {
1013 case V4L2_SEL_TGT_COMPOSE_BOUNDS:
1014 case V4L2_SEL_TGT_COMPOSE_DEFAULT:
1015 sel->r.left = 0;
1016 sel->r.top = 0;
1017 sel->r.width = vp->out_frame.f_width;
1018 sel->r.height = vp->out_frame.f_height;
1019 return 0;
1020
1021 case V4L2_SEL_TGT_COMPOSE:
1022 sel->r = vp->out_frame.rect;
1023 return 0;
1024 }
1025
1026 return -EINVAL;
1027}
1028
1029static void __camif_try_compose(struct camif_dev *camif, struct camif_vp *vp,
1030 struct v4l2_rect *r)
1031{
1032 /* s3c244x doesn't support composition */
1033 if (camif->variant->ip_revision == S3C244X_CAMIF_IP_REV) {
1034 *r = vp->out_frame.rect;
1035 return;
1036 }
1037
1038 /* TODO: s3c64xx */
1039}
1040
1041static int s3c_camif_s_selection(struct file *file, void *priv,
1042 struct v4l2_selection *sel)
1043{
1044 struct camif_vp *vp = video_drvdata(file);
1045 struct camif_dev *camif = vp->camif;
1046 struct v4l2_rect rect = sel->r;
1047 unsigned long flags;
1048
1049 if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
1050 sel->target != V4L2_SEL_TGT_COMPOSE)
1051 return -EINVAL;
1052
1053 __camif_try_compose(camif, vp, &rect);
1054
1055 sel->r = rect;
1056 spin_lock_irqsave(&camif->slock, flags);
1057 vp->out_frame.rect = rect;
1058 vp->state |= ST_VP_CONFIG;
1059 spin_unlock_irqrestore(&camif->slock, flags);
1060
1061 pr_debug("type: %#x, target: %#x, flags: %#x, (%d,%d)/%dx%d\n",
1062 sel->type, sel->target, sel->flags,
1063 sel->r.left, sel->r.top, sel->r.width, sel->r.height);
1064
1065 return 0;
1066}
1067
1068static const struct v4l2_ioctl_ops s3c_camif_ioctl_ops = {
1069 .vidioc_querycap = s3c_camif_vidioc_querycap,
1070 .vidioc_enum_input = s3c_camif_vidioc_enum_input,
1071 .vidioc_g_input = s3c_camif_vidioc_g_input,
1072 .vidioc_s_input = s3c_camif_vidioc_s_input,
1073 .vidioc_enum_fmt_vid_cap = s3c_camif_vidioc_enum_fmt,
1074 .vidioc_try_fmt_vid_cap = s3c_camif_vidioc_try_fmt,
1075 .vidioc_s_fmt_vid_cap = s3c_camif_vidioc_s_fmt,
1076 .vidioc_g_fmt_vid_cap = s3c_camif_vidioc_g_fmt,
1077 .vidioc_g_selection = s3c_camif_g_selection,
1078 .vidioc_s_selection = s3c_camif_s_selection,
1079 .vidioc_reqbufs = s3c_camif_reqbufs,
1080 .vidioc_querybuf = s3c_camif_querybuf,
1081 .vidioc_prepare_buf = s3c_camif_prepare_buf,
1082 .vidioc_create_bufs = s3c_camif_create_bufs,
1083 .vidioc_qbuf = s3c_camif_qbuf,
1084 .vidioc_dqbuf = s3c_camif_dqbuf,
1085 .vidioc_streamon = s3c_camif_streamon,
1086 .vidioc_streamoff = s3c_camif_streamoff,
1087 .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
1088 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
1089 .vidioc_log_status = v4l2_ctrl_log_status,
1090};
1091
1092/*
1093 * Video node controls
1094 */
1095static int s3c_camif_video_s_ctrl(struct v4l2_ctrl *ctrl)
1096{
1097 struct camif_vp *vp = ctrl->priv;
1098 struct camif_dev *camif = vp->camif;
1099 unsigned long flags;
1100
1101 pr_debug("[vp%d] ctrl: %s, value: %d\n", vp->id,
1102 ctrl->name, ctrl->val);
1103
1104 spin_lock_irqsave(&camif->slock, flags);
1105
1106 switch (ctrl->id) {
1107 case V4L2_CID_HFLIP:
1108 vp->hflip = ctrl->val;
1109 break;
1110
1111 case V4L2_CID_VFLIP:
1112 vp->vflip = ctrl->val;
1113 break;
1114 }
1115
1116 vp->state |= ST_VP_CONFIG;
1117 spin_unlock_irqrestore(&camif->slock, flags);
1118 return 0;
1119}
1120
1121/* Codec and preview video node control ops */
1122static const struct v4l2_ctrl_ops s3c_camif_video_ctrl_ops = {
1123 .s_ctrl = s3c_camif_video_s_ctrl,
1124};
1125
1126int s3c_camif_register_video_node(struct camif_dev *camif, int idx)
1127{
1128 struct camif_vp *vp = &camif->vp[idx];
1129 struct vb2_queue *q = &vp->vb_queue;
1130 struct video_device *vfd = &vp->vdev;
1131 struct v4l2_ctrl *ctrl;
1132 int ret;
1133
1134 memset(vfd, 0, sizeof(*vfd));
1135 snprintf(vfd->name, sizeof(vfd->name), "camif-%s",
1136 vp->id == 0 ? "codec" : "preview");
1137
1138 vfd->fops = &s3c_camif_fops;
1139 vfd->ioctl_ops = &s3c_camif_ioctl_ops;
1140 vfd->v4l2_dev = &camif->v4l2_dev;
1141 vfd->minor = -1;
1142 vfd->release = video_device_release_empty;
1143 vfd->lock = &camif->lock;
1144 vp->reqbufs_count = 0;
1145
1146 INIT_LIST_HEAD(&vp->pending_buf_q);
1147 INIT_LIST_HEAD(&vp->active_buf_q);
1148
1149 memset(q, 0, sizeof(*q));
1150 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1151 q->io_modes = VB2_MMAP | VB2_USERPTR;
1152 q->ops = &s3c_camif_qops;
1153 q->mem_ops = &vb2_dma_contig_memops;
1154 q->buf_struct_size = sizeof(struct camif_buffer);
1155 q->drv_priv = vp;
1156
1157 ret = vb2_queue_init(q);
1158 if (ret)
1159 goto err_vd_rel;
1160
1161 vp->pad.flags = MEDIA_PAD_FL_SINK;
1162 ret = media_entity_init(&vfd->entity, 1, &vp->pad, 0);
1163 if (ret)
1164 goto err_vd_rel;
1165
1166 video_set_drvdata(vfd, vp);
1167 set_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags);
1168
1169 v4l2_ctrl_handler_init(&vp->ctrl_handler, 1);
1170 ctrl = v4l2_ctrl_new_std(&vp->ctrl_handler, &s3c_camif_video_ctrl_ops,
1171 V4L2_CID_HFLIP, 0, 1, 1, 0);
1172 if (ctrl)
1173 ctrl->priv = vp;
1174 ctrl = v4l2_ctrl_new_std(&vp->ctrl_handler, &s3c_camif_video_ctrl_ops,
1175 V4L2_CID_VFLIP, 0, 1, 1, 0);
1176 if (ctrl)
1177 ctrl->priv = vp;
1178
1179 ret = vp->ctrl_handler.error;
1180 if (ret < 0)
1181 goto err_me_cleanup;
1182
1183 vfd->ctrl_handler = &vp->ctrl_handler;
1184
1185 ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1);
1186 if (ret)
1187 goto err_ctrlh_free;
1188
1189 v4l2_info(&camif->v4l2_dev, "registered %s as /dev/%s\n",
1190 vfd->name, video_device_node_name(vfd));
1191 return 0;
1192
1193err_ctrlh_free:
1194 v4l2_ctrl_handler_free(&vp->ctrl_handler);
1195err_me_cleanup:
1196 media_entity_cleanup(&vfd->entity);
1197err_vd_rel:
1198 video_device_release(vfd);
1199 return ret;
1200}
1201
1202void s3c_camif_unregister_video_node(struct camif_dev *camif, int idx)
1203{
1204 struct video_device *vfd = &camif->vp[idx].vdev;
1205
1206 if (video_is_registered(vfd)) {
1207 video_unregister_device(vfd);
1208 media_entity_cleanup(&vfd->entity);
1209 v4l2_ctrl_handler_free(vfd->ctrl_handler);
1210 }
1211}
1212
1213/* Media bus pixel formats supported at the camif input */
1214static const enum v4l2_mbus_pixelcode camif_mbus_formats[] = {
1215 V4L2_MBUS_FMT_YUYV8_2X8,
1216 V4L2_MBUS_FMT_YVYU8_2X8,
1217 V4L2_MBUS_FMT_UYVY8_2X8,
1218 V4L2_MBUS_FMT_VYUY8_2X8,
1219};
1220
1221/*
1222 * Camera input interface subdev operations
1223 */
1224
1225static int s3c_camif_subdev_enum_mbus_code(struct v4l2_subdev *sd,
1226 struct v4l2_subdev_fh *fh,
1227 struct v4l2_subdev_mbus_code_enum *code)
1228{
1229 if (code->index >= ARRAY_SIZE(camif_mbus_formats))
1230 return -EINVAL;
1231
1232 code->code = camif_mbus_formats[code->index];
1233 return 0;
1234}
1235
1236static int s3c_camif_subdev_get_fmt(struct v4l2_subdev *sd,
1237 struct v4l2_subdev_fh *fh,
1238 struct v4l2_subdev_format *fmt)
1239{
1240 struct camif_dev *camif = v4l2_get_subdevdata(sd);
1241 struct v4l2_mbus_framefmt *mf = &fmt->format;
1242
1243 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1244 mf = v4l2_subdev_get_try_format(fh, fmt->pad);
1245 fmt->format = *mf;
1246 return 0;
1247 }
1248
1249 mutex_lock(&camif->lock);
1250
1251 switch (fmt->pad) {
1252 case CAMIF_SD_PAD_SINK:
1253 /* full camera input pixel size */
1254 *mf = camif->mbus_fmt;
1255 break;
1256
1257 case CAMIF_SD_PAD_SOURCE_C...CAMIF_SD_PAD_SOURCE_P:
1258 /* crop rectangle at camera interface input */
1259 mf->width = camif->camif_crop.width;
1260 mf->height = camif->camif_crop.height;
1261 mf->code = camif->mbus_fmt.code;
1262 break;
1263 }
1264
1265 mutex_unlock(&camif->lock);
1266 mf->colorspace = V4L2_COLORSPACE_JPEG;
1267 return 0;
1268}
1269
1270static void __camif_subdev_try_format(struct camif_dev *camif,
1271 struct v4l2_mbus_framefmt *mf, int pad)
1272{
1273 const struct s3c_camif_variant *variant = camif->variant;
1274 const struct vp_pix_limits *pix_lim;
1275 int i = ARRAY_SIZE(camif_mbus_formats);
1276
1277 /* FIXME: constraints against codec or preview path ? */
1278 pix_lim = &variant->vp_pix_limits[VP_CODEC];
1279
1280 while (i-- >= 0)
1281 if (camif_mbus_formats[i] == mf->code)
1282 break;
1283
1284 mf->code = camif_mbus_formats[i];
1285
1286 if (pad == CAMIF_SD_PAD_SINK) {
1287 v4l_bound_align_image(&mf->width, 8, CAMIF_MAX_PIX_WIDTH,
1288 ffs(pix_lim->out_width_align) - 1,
1289 &mf->height, 8, CAMIF_MAX_PIX_HEIGHT, 0,
1290 0);
1291 } else {
1292 struct v4l2_rect *crop = &camif->camif_crop;
1293 v4l_bound_align_image(&mf->width, 8, crop->width,
1294 ffs(pix_lim->out_width_align) - 1,
1295 &mf->height, 8, crop->height,
1296 0, 0);
1297 }
1298
1299 v4l2_dbg(1, debug, &camif->subdev, "%ux%u\n", mf->width, mf->height);
1300}
1301
1302static int s3c_camif_subdev_set_fmt(struct v4l2_subdev *sd,
1303 struct v4l2_subdev_fh *fh,
1304 struct v4l2_subdev_format *fmt)
1305{
1306 struct camif_dev *camif = v4l2_get_subdevdata(sd);
1307 struct v4l2_mbus_framefmt *mf = &fmt->format;
1308 struct v4l2_rect *crop = &camif->camif_crop;
1309 int i;
1310
1311 v4l2_dbg(1, debug, sd, "pad%d: code: 0x%x, %ux%u\n",
1312 fmt->pad, mf->code, mf->width, mf->height);
1313
1314 mf->colorspace = V4L2_COLORSPACE_JPEG;
1315 mutex_lock(&camif->lock);
1316
1317 /*
1318 * No pixel format change at the camera input is allowed
1319 * while streaming.
1320 */
1321 if (vb2_is_busy(&camif->vp[VP_CODEC].vb_queue) ||
1322 vb2_is_busy(&camif->vp[VP_PREVIEW].vb_queue)) {
1323 mutex_unlock(&camif->lock);
1324 return -EBUSY;
1325 }
1326
1327 __camif_subdev_try_format(camif, mf, fmt->pad);
1328
1329 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1330 mf = v4l2_subdev_get_try_format(fh, fmt->pad);
1331 *mf = fmt->format;
1332 mutex_unlock(&camif->lock);
1333 return 0;
1334 }
1335
1336 switch (fmt->pad) {
1337 case CAMIF_SD_PAD_SINK:
1338 camif->mbus_fmt = *mf;
1339 /* Reset sink crop rectangle. */
1340 crop->width = mf->width;
1341 crop->height = mf->height;
1342 crop->left = 0;
1343 crop->top = 0;
1344 /*
1345 * Reset source format (the camif's crop rectangle)
1346 * and the video output resolution.
1347 */
1348 for (i = 0; i < CAMIF_VP_NUM; i++) {
1349 struct camif_frame *frame = &camif->vp[i].out_frame;
1350 frame->rect = *crop;
1351 frame->f_width = mf->width;
1352 frame->f_height = mf->height;
1353 }
1354 break;
1355
1356 case CAMIF_SD_PAD_SOURCE_C...CAMIF_SD_PAD_SOURCE_P:
1357 /* Pixel format can be only changed on the sink pad. */
1358 mf->code = camif->mbus_fmt.code;
1359 mf->width = crop->width;
1360 mf->height = crop->height;
1361 break;
1362 }
1363
1364 mutex_unlock(&camif->lock);
1365 return 0;
1366}
1367
1368static int s3c_camif_subdev_get_selection(struct v4l2_subdev *sd,
1369 struct v4l2_subdev_fh *fh,
1370 struct v4l2_subdev_selection *sel)
1371{
1372 struct camif_dev *camif = v4l2_get_subdevdata(sd);
1373 struct v4l2_rect *crop = &camif->camif_crop;
1374 struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt;
1375
1376 if ((sel->target != V4L2_SEL_TGT_CROP &&
1377 sel->target != V4L2_SEL_TGT_CROP_BOUNDS) ||
1378 sel->pad != CAMIF_SD_PAD_SINK)
1379 return -EINVAL;
1380
1381 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
1382 sel->r = *v4l2_subdev_get_try_crop(fh, sel->pad);
1383 return 0;
1384 }
1385
1386 mutex_lock(&camif->lock);
1387
1388 if (sel->target == V4L2_SEL_TGT_CROP) {
1389 sel->r = *crop;
1390 } else { /* crop bounds */
1391 sel->r.width = mf->width;
1392 sel->r.height = mf->height;
1393 sel->r.left = 0;
1394 sel->r.top = 0;
1395 }
1396
1397 mutex_unlock(&camif->lock);
1398
1399 v4l2_dbg(1, debug, sd, "%s: crop: (%d,%d) %dx%d, size: %ux%u\n",
1400 __func__, crop->left, crop->top, crop->width,
1401 crop->height, mf->width, mf->height);
1402
1403 return 0;
1404}
1405
1406static void __camif_try_crop(struct camif_dev *camif, struct v4l2_rect *r)
1407{
1408 struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt;
1409 const struct camif_pix_limits *pix_lim = &camif->variant->pix_limits;
1410 unsigned int left = 2 * r->left;
1411 unsigned int top = 2 * r->top;
1412
1413 /*
1414 * Following constraints must be met:
1415 * - r->width + 2 * r->left = mf->width;
1416 * - r->height + 2 * r->top = mf->height;
1417 * - crop rectangle size and position must be aligned
1418 * to 8 or 2 pixels, depending on SoC version.
1419 */
1420 v4l_bound_align_image(&r->width, 0, mf->width,
1421 ffs(pix_lim->win_hor_offset_align) - 1,
1422 &r->height, 0, mf->height, 1, 0);
1423
1424 v4l_bound_align_image(&left, 0, mf->width - r->width,
1425 ffs(pix_lim->win_hor_offset_align),
1426 &top, 0, mf->height - r->height, 2, 0);
1427
1428 r->left = left / 2;
1429 r->top = top / 2;
1430 r->width = mf->width - left;
1431 r->height = mf->height - top;
1432 /*
1433 * Make sure we either downscale or upscale both the pixel
1434 * width and height. Just return current crop rectangle if
1435 * this scaler constraint is not met.
1436 */
1437 if (camif->variant->ip_revision == S3C244X_CAMIF_IP_REV &&
1438 camif_is_streaming(camif)) {
1439 unsigned int i;
1440
1441 for (i = 0; i < CAMIF_VP_NUM; i++) {
1442 struct v4l2_rect *or = &camif->vp[i].out_frame.rect;
1443 if ((or->width > r->width) == (or->height > r->height))
1444 continue;
1445 *r = camif->camif_crop;
1446 pr_debug("Width/height scaling direction limitation\n");
1447 break;
1448 }
1449 }
1450
1451 v4l2_dbg(1, debug, &camif->v4l2_dev, "crop: (%d,%d)/%dx%d, fmt: %ux%u\n",
1452 r->left, r->top, r->width, r->height, mf->width, mf->height);
1453}
1454
1455static int s3c_camif_subdev_set_selection(struct v4l2_subdev *sd,
1456 struct v4l2_subdev_fh *fh,
1457 struct v4l2_subdev_selection *sel)
1458{
1459 struct camif_dev *camif = v4l2_get_subdevdata(sd);
1460 struct v4l2_rect *crop = &camif->camif_crop;
1461 struct camif_scaler scaler;
1462
1463 if (sel->target != V4L2_SEL_TGT_CROP || sel->pad != CAMIF_SD_PAD_SINK)
1464 return -EINVAL;
1465
1466 mutex_lock(&camif->lock);
1467 __camif_try_crop(camif, &sel->r);
1468
1469 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
1470 *v4l2_subdev_get_try_crop(fh, sel->pad) = sel->r;
1471 } else {
1472 unsigned long flags;
1473 unsigned int i;
1474
1475 spin_lock_irqsave(&camif->slock, flags);
1476 *crop = sel->r;
1477
1478 for (i = 0; i < CAMIF_VP_NUM; i++) {
1479 struct camif_vp *vp = &camif->vp[i];
1480 scaler = vp->scaler;
1481 if (s3c_camif_get_scaler_config(vp, &scaler))
1482 continue;
1483 vp->scaler = scaler;
1484 vp->state |= ST_VP_CONFIG;
1485 }
1486
1487 spin_unlock_irqrestore(&camif->slock, flags);
1488 }
1489 mutex_unlock(&camif->lock);
1490
1491 v4l2_dbg(1, debug, sd, "%s: (%d,%d) %dx%d, f_w: %u, f_h: %u\n",
1492 __func__, crop->left, crop->top, crop->width, crop->height,
1493 camif->mbus_fmt.width, camif->mbus_fmt.height);
1494
1495 return 0;
1496}
1497
1498static const struct v4l2_subdev_pad_ops s3c_camif_subdev_pad_ops = {
1499 .enum_mbus_code = s3c_camif_subdev_enum_mbus_code,
1500 .get_selection = s3c_camif_subdev_get_selection,
1501 .set_selection = s3c_camif_subdev_set_selection,
1502 .get_fmt = s3c_camif_subdev_get_fmt,
1503 .set_fmt = s3c_camif_subdev_set_fmt,
1504};
1505
1506static struct v4l2_subdev_ops s3c_camif_subdev_ops = {
1507 .pad = &s3c_camif_subdev_pad_ops,
1508};
1509
1510static int s3c_camif_subdev_s_ctrl(struct v4l2_ctrl *ctrl)
1511{
1512 struct camif_dev *camif = container_of(ctrl->handler, struct camif_dev,
1513 ctrl_handler);
1514 unsigned long flags;
1515
1516 spin_lock_irqsave(&camif->slock, flags);
1517
1518 switch (ctrl->id) {
1519 case V4L2_CID_COLORFX:
1520 camif->colorfx = camif->ctrl_colorfx->val;
1521 /* Set Cb, Cr */
1522 switch (ctrl->val) {
1523 case V4L2_COLORFX_SEPIA:
1524 camif->colorfx_cb = 115;
1525 camif->colorfx_cr = 145;
1526 break;
1527 case V4L2_COLORFX_SET_CBCR:
1528 camif->colorfx_cb = camif->ctrl_colorfx_cbcr->val >> 8;
1529 camif->colorfx_cr = camif->ctrl_colorfx_cbcr->val & 0xff;
1530 break;
1531 default:
1532 /* for V4L2_COLORFX_BW and others */
1533 camif->colorfx_cb = 128;
1534 camif->colorfx_cr = 128;
1535 }
1536 break;
1537 case V4L2_CID_TEST_PATTERN:
1538 camif->test_pattern = camif->ctrl_test_pattern->val;
1539 break;
1540 default:
1541 WARN_ON(1);
1542 }
1543
1544 camif->vp[VP_CODEC].state |= ST_VP_CONFIG;
1545 camif->vp[VP_PREVIEW].state |= ST_VP_CONFIG;
1546 spin_unlock_irqrestore(&camif->slock, flags);
1547
1548 return 0;
1549}
1550
1551static const struct v4l2_ctrl_ops s3c_camif_subdev_ctrl_ops = {
1552 .s_ctrl = s3c_camif_subdev_s_ctrl,
1553};
1554
1555static const char * const s3c_camif_test_pattern_menu[] = {
1556 "Disabled",
1557 "Color bars",
1558 "Horizontal increment",
1559 "Vertical increment",
1560};
1561
1562int s3c_camif_create_subdev(struct camif_dev *camif)
1563{
1564 struct v4l2_ctrl_handler *handler = &camif->ctrl_handler;
1565 struct v4l2_subdev *sd = &camif->subdev;
1566 int ret;
1567
1568 v4l2_subdev_init(sd, &s3c_camif_subdev_ops);
1569 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
1570 strlcpy(sd->name, "S3C-CAMIF", sizeof(sd->name));
1571
1572 camif->pads[CAMIF_SD_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
1573 camif->pads[CAMIF_SD_PAD_SOURCE_C].flags = MEDIA_PAD_FL_SOURCE;
1574 camif->pads[CAMIF_SD_PAD_SOURCE_P].flags = MEDIA_PAD_FL_SOURCE;
1575
1576 ret = media_entity_init(&sd->entity, CAMIF_SD_PADS_NUM,
1577 camif->pads, 0);
1578 if (ret)
1579 return ret;
1580
1581 v4l2_ctrl_handler_init(handler, 3);
1582 camif->ctrl_test_pattern = v4l2_ctrl_new_std_menu_items(handler,
1583 &s3c_camif_subdev_ctrl_ops, V4L2_CID_TEST_PATTERN,
1584 ARRAY_SIZE(s3c_camif_test_pattern_menu) - 1, 0, 0,
1585 s3c_camif_test_pattern_menu);
1586
1587 camif->ctrl_colorfx = v4l2_ctrl_new_std_menu(handler,
1588 &s3c_camif_subdev_ctrl_ops,
1589 V4L2_CID_COLORFX, V4L2_COLORFX_SET_CBCR,
1590 ~0x981f, V4L2_COLORFX_NONE);
1591
1592 camif->ctrl_colorfx_cbcr = v4l2_ctrl_new_std(handler,
1593 &s3c_camif_subdev_ctrl_ops,
1594 V4L2_CID_COLORFX_CBCR, 0, 0xffff, 1, 0);
1595 if (handler->error) {
1596 v4l2_ctrl_handler_free(handler);
1597 media_entity_cleanup(&sd->entity);
1598 return handler->error;
1599 }
1600
1601 v4l2_ctrl_auto_cluster(2, &camif->ctrl_colorfx,
1602 V4L2_COLORFX_SET_CBCR, false);
1603 if (!camif->variant->has_img_effect) {
1604 camif->ctrl_colorfx->flags |= V4L2_CTRL_FLAG_DISABLED;
1605 camif->ctrl_colorfx_cbcr->flags |= V4L2_CTRL_FLAG_DISABLED;
1606 }
1607 sd->ctrl_handler = handler;
1608 v4l2_set_subdevdata(sd, camif);
1609
1610 return 0;
1611}
1612
1613void s3c_camif_unregister_subdev(struct camif_dev *camif)
1614{
1615 struct v4l2_subdev *sd = &camif->subdev;
1616
1617 /* Return if not registered */
1618 if (v4l2_get_subdevdata(sd) == NULL)
1619 return;
1620
1621 v4l2_device_unregister_subdev(sd);
1622 media_entity_cleanup(&sd->entity);
1623 v4l2_ctrl_handler_free(&camif->ctrl_handler);
1624 v4l2_set_subdevdata(sd, NULL);
1625}
1626
1627int s3c_camif_set_defaults(struct camif_dev *camif)
1628{
1629 unsigned int ip_rev = camif->variant->ip_revision;
1630 int i;
1631
1632 for (i = 0; i < CAMIF_VP_NUM; i++) {
1633 struct camif_vp *vp = &camif->vp[i];
1634 struct camif_frame *f = &vp->out_frame;
1635
1636 vp->camif = camif;
1637 vp->id = i;
1638 vp->offset = camif->variant->vp_offset;
1639
1640 if (ip_rev == S3C244X_CAMIF_IP_REV)
1641 vp->fmt_flags = i ? FMT_FL_S3C24XX_PREVIEW :
1642 FMT_FL_S3C24XX_CODEC;
1643 else
1644 vp->fmt_flags = FMT_FL_S3C64XX;
1645
1646 vp->out_fmt = s3c_camif_find_format(vp, NULL, 0);
1647 BUG_ON(vp->out_fmt == NULL);
1648
1649 memset(f, 0, sizeof(*f));
1650 f->f_width = CAMIF_DEF_WIDTH;
1651 f->f_height = CAMIF_DEF_HEIGHT;
1652 f->rect.width = CAMIF_DEF_WIDTH;
1653 f->rect.height = CAMIF_DEF_HEIGHT;
1654
1655 /* Scaler is always enabled */
1656 vp->scaler.enable = 1;
1657
1658 vp->payload = (f->f_width * f->f_height *
1659 vp->out_fmt->depth) / 8;
1660 }
1661
1662 memset(&camif->mbus_fmt, 0, sizeof(camif->mbus_fmt));
1663 camif->mbus_fmt.width = CAMIF_DEF_WIDTH;
1664 camif->mbus_fmt.height = CAMIF_DEF_HEIGHT;
1665 camif->mbus_fmt.code = camif_mbus_formats[0];
1666
1667 memset(&camif->camif_crop, 0, sizeof(camif->camif_crop));
1668 camif->camif_crop.width = CAMIF_DEF_WIDTH;
1669 camif->camif_crop.height = CAMIF_DEF_HEIGHT;
1670
1671 return 0;
1672}
diff --git a/drivers/media/platform/s3c-camif/camif-core.c b/drivers/media/platform/s3c-camif/camif-core.c
new file mode 100644
index 000000000000..0dd65376c067
--- /dev/null
+++ b/drivers/media/platform/s3c-camif/camif-core.c
@@ -0,0 +1,662 @@
1/*
2 * s3c24xx/s3c64xx SoC series Camera Interface (CAMIF) driver
3 *
4 * Copyright (C) 2012 Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
5 * Copyright (C) 2012 Tomasz Figa <tomasz.figa@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation, either version 2 of the License,
10 * or (at your option) any later version.
11 */
12#define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
13
14#include <linux/bug.h>
15#include <linux/clk.h>
16#include <linux/delay.h>
17#include <linux/device.h>
18#include <linux/errno.h>
19#include <linux/gpio.h>
20#include <linux/i2c.h>
21#include <linux/interrupt.h>
22#include <linux/io.h>
23#include <linux/kernel.h>
24#include <linux/list.h>
25#include <linux/module.h>
26#include <linux/platform_device.h>
27#include <linux/pm_runtime.h>
28#include <linux/slab.h>
29#include <linux/types.h>
30
31#include <media/media-device.h>
32#include <media/v4l2-ctrls.h>
33#include <media/v4l2-ioctl.h>
34#include <media/videobuf2-core.h>
35#include <media/videobuf2-dma-contig.h>
36
37#include "camif-core.h"
38
39static char *camif_clocks[CLK_MAX_NUM] = {
40 /* HCLK CAMIF clock */
41 [CLK_GATE] = "camif",
42 /* CAMIF / external camera sensor master clock */
43 [CLK_CAM] = "camera",
44};
45
46static const struct camif_fmt camif_formats[] = {
47 {
48 .name = "YUV 4:2:2 planar, Y/Cb/Cr",
49 .fourcc = V4L2_PIX_FMT_YUV422P,
50 .depth = 16,
51 .ybpp = 1,
52 .color = IMG_FMT_YCBCR422P,
53 .colplanes = 3,
54 .flags = FMT_FL_S3C24XX_CODEC |
55 FMT_FL_S3C64XX,
56 }, {
57 .name = "YUV 4:2:0 planar, Y/Cb/Cr",
58 .fourcc = V4L2_PIX_FMT_YUV420,
59 .depth = 12,
60 .ybpp = 1,
61 .color = IMG_FMT_YCBCR420,
62 .colplanes = 3,
63 .flags = FMT_FL_S3C24XX_CODEC |
64 FMT_FL_S3C64XX,
65 }, {
66 .name = "YVU 4:2:0 planar, Y/Cr/Cb",
67 .fourcc = V4L2_PIX_FMT_YVU420,
68 .depth = 12,
69 .ybpp = 1,
70 .color = IMG_FMT_YCRCB420,
71 .colplanes = 3,
72 .flags = FMT_FL_S3C24XX_CODEC |
73 FMT_FL_S3C64XX,
74 }, {
75 .name = "RGB565, 16 bpp",
76 .fourcc = V4L2_PIX_FMT_RGB565X,
77 .depth = 16,
78 .ybpp = 2,
79 .color = IMG_FMT_RGB565,
80 .colplanes = 1,
81 .flags = FMT_FL_S3C24XX_PREVIEW |
82 FMT_FL_S3C64XX,
83 }, {
84 .name = "XRGB8888, 32 bpp",
85 .fourcc = V4L2_PIX_FMT_RGB32,
86 .depth = 32,
87 .ybpp = 4,
88 .color = IMG_FMT_XRGB8888,
89 .colplanes = 1,
90 .flags = FMT_FL_S3C24XX_PREVIEW |
91 FMT_FL_S3C64XX,
92 }, {
93 .name = "BGR666",
94 .fourcc = V4L2_PIX_FMT_BGR666,
95 .depth = 32,
96 .ybpp = 4,
97 .color = IMG_FMT_RGB666,
98 .colplanes = 1,
99 .flags = FMT_FL_S3C64XX,
100 }
101};
102
103/**
104 * s3c_camif_find_format() - lookup camif color format by fourcc or an index
105 * @pixelformat: fourcc to match, ignored if null
106 * @index: index to the camif_formats array, ignored if negative
107 */
108const struct camif_fmt *s3c_camif_find_format(struct camif_vp *vp,
109 const u32 *pixelformat,
110 int index)
111{
112 const struct camif_fmt *fmt, *def_fmt = NULL;
113 unsigned int i;
114 int id = 0;
115
116 if (index >= (int)ARRAY_SIZE(camif_formats))
117 return NULL;
118
119 for (i = 0; i < ARRAY_SIZE(camif_formats); ++i) {
120 fmt = &camif_formats[i];
121 if (vp && !(vp->fmt_flags & fmt->flags))
122 continue;
123 if (pixelformat && fmt->fourcc == *pixelformat)
124 return fmt;
125 if (index == id)
126 def_fmt = fmt;
127 id++;
128 }
129 return def_fmt;
130}
131
132static int camif_get_scaler_factor(u32 src, u32 tar, u32 *ratio, u32 *shift)
133{
134 unsigned int sh = 6;
135
136 if (src >= 64 * tar)
137 return -EINVAL;
138
139 while (sh--) {
140 unsigned int tmp = 1 << sh;
141 if (src >= tar * tmp) {
142 *shift = sh, *ratio = tmp;
143 return 0;
144 }
145 }
146 *shift = 0, *ratio = 1;
147 return 0;
148}
149
150int s3c_camif_get_scaler_config(struct camif_vp *vp,
151 struct camif_scaler *scaler)
152{
153 struct v4l2_rect *camif_crop = &vp->camif->camif_crop;
154 int source_x = camif_crop->width;
155 int source_y = camif_crop->height;
156 int target_x = vp->out_frame.rect.width;
157 int target_y = vp->out_frame.rect.height;
158 int ret;
159
160 if (vp->rotation == 90 || vp->rotation == 270)
161 swap(target_x, target_y);
162
163 ret = camif_get_scaler_factor(source_x, target_x, &scaler->pre_h_ratio,
164 &scaler->h_shift);
165 if (ret < 0)
166 return ret;
167
168 ret = camif_get_scaler_factor(source_y, target_y, &scaler->pre_v_ratio,
169 &scaler->v_shift);
170 if (ret < 0)
171 return ret;
172
173 scaler->pre_dst_width = source_x / scaler->pre_h_ratio;
174 scaler->pre_dst_height = source_y / scaler->pre_v_ratio;
175
176 scaler->main_h_ratio = (source_x << 8) / (target_x << scaler->h_shift);
177 scaler->main_v_ratio = (source_y << 8) / (target_y << scaler->v_shift);
178
179 scaler->scaleup_h = (target_x >= source_x);
180 scaler->scaleup_v = (target_y >= source_y);
181
182 scaler->copy = 0;
183
184 pr_debug("H: ratio: %u, shift: %u. V: ratio: %u, shift: %u.\n",
185 scaler->pre_h_ratio, scaler->h_shift,
186 scaler->pre_v_ratio, scaler->v_shift);
187
188 pr_debug("Source: %dx%d, Target: %dx%d, scaleup_h/v: %d/%d\n",
189 source_x, source_y, target_x, target_y,
190 scaler->scaleup_h, scaler->scaleup_v);
191
192 return 0;
193}
194
195static int camif_register_sensor(struct camif_dev *camif)
196{
197 struct s3c_camif_sensor_info *sensor = &camif->pdata.sensor;
198 struct v4l2_device *v4l2_dev = &camif->v4l2_dev;
199 struct i2c_adapter *adapter;
200 struct v4l2_subdev_format format;
201 struct v4l2_subdev *sd;
202 int ret;
203
204 camif->sensor.sd = NULL;
205
206 if (sensor->i2c_board_info.addr == 0)
207 return -EINVAL;
208
209 adapter = i2c_get_adapter(sensor->i2c_bus_num);
210 if (adapter == NULL) {
211 v4l2_warn(v4l2_dev, "failed to get I2C adapter %d\n",
212 sensor->i2c_bus_num);
213 return -EPROBE_DEFER;
214 }
215
216 sd = v4l2_i2c_new_subdev_board(v4l2_dev, adapter,
217 &sensor->i2c_board_info, NULL);
218 if (sd == NULL) {
219 i2c_put_adapter(adapter);
220 v4l2_warn(v4l2_dev, "failed to acquire subdev %s\n",
221 sensor->i2c_board_info.type);
222 return -EPROBE_DEFER;
223 }
224 camif->sensor.sd = sd;
225
226 v4l2_info(v4l2_dev, "registered sensor subdevice %s\n", sd->name);
227
228 /* Get initial pixel format and set it at the camif sink pad */
229 format.pad = 0;
230 format.which = V4L2_SUBDEV_FORMAT_ACTIVE;
231 ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &format);
232
233 if (ret < 0)
234 return 0;
235
236 format.pad = CAMIF_SD_PAD_SINK;
237 v4l2_subdev_call(&camif->subdev, pad, set_fmt, NULL, &format);
238
239 v4l2_info(sd, "Initial format from sensor: %dx%d, %#x\n",
240 format.format.width, format.format.height,
241 format.format.code);
242 return 0;
243}
244
245static void camif_unregister_sensor(struct camif_dev *camif)
246{
247 struct v4l2_subdev *sd = camif->sensor.sd;
248 struct i2c_client *client = sd ? v4l2_get_subdevdata(sd) : NULL;
249 struct i2c_adapter *adapter;
250
251 if (client == NULL)
252 return;
253
254 adapter = client->adapter;
255 v4l2_device_unregister_subdev(sd);
256 camif->sensor.sd = NULL;
257 i2c_unregister_device(client);
258 if (adapter)
259 i2c_put_adapter(adapter);
260}
261
262static int camif_create_media_links(struct camif_dev *camif)
263{
264 int i, ret;
265
266 ret = media_entity_create_link(&camif->sensor.sd->entity, 0,
267 &camif->subdev.entity, CAMIF_SD_PAD_SINK,
268 MEDIA_LNK_FL_IMMUTABLE |
269 MEDIA_LNK_FL_ENABLED);
270 if (ret)
271 return ret;
272
273 for (i = 1; i < CAMIF_SD_PADS_NUM && !ret; i++) {
274 ret = media_entity_create_link(&camif->subdev.entity, i,
275 &camif->vp[i - 1].vdev.entity, 0,
276 MEDIA_LNK_FL_IMMUTABLE |
277 MEDIA_LNK_FL_ENABLED);
278 }
279
280 return ret;
281}
282
283static int camif_register_video_nodes(struct camif_dev *camif)
284{
285 int ret = s3c_camif_register_video_node(camif, VP_CODEC);
286 if (ret < 0)
287 return ret;
288
289 return s3c_camif_register_video_node(camif, VP_PREVIEW);
290}
291
292static void camif_unregister_video_nodes(struct camif_dev *camif)
293{
294 s3c_camif_unregister_video_node(camif, VP_CODEC);
295 s3c_camif_unregister_video_node(camif, VP_PREVIEW);
296}
297
298static void camif_unregister_media_entities(struct camif_dev *camif)
299{
300 camif_unregister_video_nodes(camif);
301 camif_unregister_sensor(camif);
302 s3c_camif_unregister_subdev(camif);
303}
304
305/*
306 * Media device
307 */
308static int camif_media_dev_register(struct camif_dev *camif)
309{
310 struct media_device *md = &camif->media_dev;
311 struct v4l2_device *v4l2_dev = &camif->v4l2_dev;
312 unsigned int ip_rev = camif->variant->ip_revision;
313 int ret;
314
315 memset(md, 0, sizeof(*md));
316 snprintf(md->model, sizeof(md->model), "SAMSUNG S3C%s CAMIF",
317 ip_rev == S3C6410_CAMIF_IP_REV ? "6410" : "244X");
318 strlcpy(md->bus_info, "platform", sizeof(md->bus_info));
319 md->hw_revision = ip_rev;
320 md->driver_version = KERNEL_VERSION(1, 0, 0);
321
322 md->dev = camif->dev;
323
324 strlcpy(v4l2_dev->name, "s3c-camif", sizeof(v4l2_dev->name));
325 v4l2_dev->mdev = md;
326
327 ret = v4l2_device_register(camif->dev, v4l2_dev);
328 if (ret < 0)
329 return ret;
330
331 ret = media_device_register(md);
332 if (ret < 0)
333 v4l2_device_unregister(v4l2_dev);
334
335 return ret;
336}
337
338static void camif_clk_put(struct camif_dev *camif)
339{
340 int i;
341
342 for (i = 0; i < CLK_MAX_NUM; i++) {
343 if (IS_ERR_OR_NULL(camif->clock[i]))
344 continue;
345 clk_unprepare(camif->clock[i]);
346 clk_put(camif->clock[i]);
347 }
348}
349
350static int camif_clk_get(struct camif_dev *camif)
351{
352 int ret, i;
353
354 for (i = 0; i < CLK_MAX_NUM; i++) {
355 camif->clock[i] = clk_get(camif->dev, camif_clocks[i]);
356 if (IS_ERR(camif->clock[i])) {
357 ret = PTR_ERR(camif->clock[i]);
358 goto err;
359 }
360 ret = clk_prepare(camif->clock[i]);
361 if (ret < 0) {
362 clk_put(camif->clock[i]);
363 camif->clock[i] = NULL;
364 goto err;
365 }
366 }
367 return 0;
368err:
369 camif_clk_put(camif);
370 dev_err(camif->dev, "failed to get clock: %s\n",
371 camif_clocks[i]);
372 return ret;
373}
374
375/*
376 * The CAMIF device has two relatively independent data processing paths
377 * that can source data from memory or the common camera input frontend.
378 * Register interrupts for each data processing path (camif_vp).
379 */
380static int camif_request_irqs(struct platform_device *pdev,
381 struct camif_dev *camif)
382{
383 int irq, ret, i;
384
385 for (i = 0; i < CAMIF_VP_NUM; i++) {
386 struct camif_vp *vp = &camif->vp[i];
387
388 init_waitqueue_head(&vp->irq_queue);
389
390 irq = platform_get_irq(pdev, i);
391 if (irq <= 0) {
392 dev_err(&pdev->dev, "failed to get IRQ %d\n", i);
393 return -ENXIO;
394 }
395
396 ret = devm_request_irq(&pdev->dev, irq, s3c_camif_irq_handler,
397 0, dev_name(&pdev->dev), vp);
398 if (ret < 0) {
399 dev_err(&pdev->dev, "failed to install IRQ: %d\n", ret);
400 break;
401 }
402 }
403
404 return ret;
405}
406
407static int s3c_camif_probe(struct platform_device *pdev)
408{
409 struct device *dev = &pdev->dev;
410 struct s3c_camif_plat_data *pdata = dev->platform_data;
411 struct s3c_camif_drvdata *drvdata;
412 struct camif_dev *camif;
413 struct resource *mres;
414 int ret = 0;
415
416 camif = devm_kzalloc(dev, sizeof(*camif), GFP_KERNEL);
417 if (!camif)
418 return -ENOMEM;
419
420 spin_lock_init(&camif->slock);
421 mutex_init(&camif->lock);
422
423 camif->dev = dev;
424
425 if (!pdata || !pdata->gpio_get || !pdata->gpio_put) {
426 dev_err(dev, "wrong platform data\n");
427 return -EINVAL;
428 }
429
430 camif->pdata = *pdata;
431 drvdata = (void *)platform_get_device_id(pdev)->driver_data;
432 camif->variant = drvdata->variant;
433
434 mres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
435
436 camif->io_base = devm_request_and_ioremap(dev, mres);
437 if (!camif->io_base) {
438 dev_err(dev, "failed to obtain I/O memory\n");
439 return -ENOENT;
440 }
441
442 ret = camif_request_irqs(pdev, camif);
443 if (ret < 0)
444 return ret;
445
446 ret = pdata->gpio_get();
447 if (ret < 0)
448 return ret;
449
450 ret = s3c_camif_create_subdev(camif);
451 if (ret < 0)
452 goto err_sd;
453
454 ret = camif_clk_get(camif);
455 if (ret < 0)
456 goto err_clk;
457
458 platform_set_drvdata(pdev, camif);
459 clk_set_rate(camif->clock[CLK_CAM],
460 camif->pdata.sensor.clock_frequency);
461
462 dev_info(dev, "sensor clock frequency: %lu\n",
463 clk_get_rate(camif->clock[CLK_CAM]));
464 /*
465 * Set initial pixel format, resolution and crop rectangle.
466 * Must be done before a sensor subdev is registered as some
467 * settings are overrode with values from sensor subdev.
468 */
469 s3c_camif_set_defaults(camif);
470
471 pm_runtime_enable(dev);
472
473 ret = pm_runtime_get_sync(dev);
474 if (ret < 0)
475 goto err_pm;
476
477 /* Initialize contiguous memory allocator */
478 camif->alloc_ctx = vb2_dma_contig_init_ctx(dev);
479 if (IS_ERR(camif->alloc_ctx)) {
480 ret = PTR_ERR(camif->alloc_ctx);
481 goto err_alloc;
482 }
483
484 ret = camif_media_dev_register(camif);
485 if (ret < 0)
486 goto err_mdev;
487
488 ret = camif_register_sensor(camif);
489 if (ret < 0)
490 goto err_sens;
491
492 ret = v4l2_device_register_subdev(&camif->v4l2_dev, &camif->subdev);
493 if (ret < 0)
494 goto err_sens;
495
496 mutex_lock(&camif->media_dev.graph_mutex);
497
498 ret = v4l2_device_register_subdev_nodes(&camif->v4l2_dev);
499 if (ret < 0)
500 goto err_unlock;
501
502 ret = camif_register_video_nodes(camif);
503 if (ret < 0)
504 goto err_unlock;
505
506 ret = camif_create_media_links(camif);
507 if (ret < 0)
508 goto err_unlock;
509
510 mutex_unlock(&camif->media_dev.graph_mutex);
511 pm_runtime_put(dev);
512 return 0;
513
514err_unlock:
515 mutex_unlock(&camif->media_dev.graph_mutex);
516err_sens:
517 v4l2_device_unregister(&camif->v4l2_dev);
518 media_device_unregister(&camif->media_dev);
519 camif_unregister_media_entities(camif);
520err_mdev:
521 vb2_dma_contig_cleanup_ctx(camif->alloc_ctx);
522err_alloc:
523 pm_runtime_put(dev);
524 pm_runtime_disable(dev);
525err_pm:
526 camif_clk_put(camif);
527err_clk:
528 s3c_camif_unregister_subdev(camif);
529err_sd:
530 pdata->gpio_put();
531 return ret;
532}
533
534static int __devexit s3c_camif_remove(struct platform_device *pdev)
535{
536 struct camif_dev *camif = platform_get_drvdata(pdev);
537 struct s3c_camif_plat_data *pdata = &camif->pdata;
538
539 media_device_unregister(&camif->media_dev);
540 camif_unregister_media_entities(camif);
541 v4l2_device_unregister(&camif->v4l2_dev);
542
543 pm_runtime_disable(&pdev->dev);
544 camif_clk_put(camif);
545 pdata->gpio_put();
546
547 return 0;
548}
549
550static int s3c_camif_runtime_resume(struct device *dev)
551{
552 struct camif_dev *camif = dev_get_drvdata(dev);
553
554 clk_enable(camif->clock[CLK_GATE]);
555 /* null op on s3c244x */
556 clk_enable(camif->clock[CLK_CAM]);
557 return 0;
558}
559
560static int s3c_camif_runtime_suspend(struct device *dev)
561{
562 struct camif_dev *camif = dev_get_drvdata(dev);
563
564 /* null op on s3c244x */
565 clk_disable(camif->clock[CLK_CAM]);
566
567 clk_disable(camif->clock[CLK_GATE]);
568 return 0;
569}
570
571static const struct s3c_camif_variant s3c244x_camif_variant = {
572 .vp_pix_limits = {
573 [VP_CODEC] = {
574 .max_out_width = 4096,
575 .max_sc_out_width = 2048,
576 .out_width_align = 16,
577 .min_out_width = 16,
578 .max_height = 4096,
579 },
580 [VP_PREVIEW] = {
581 .max_out_width = 640,
582 .max_sc_out_width = 640,
583 .out_width_align = 16,
584 .min_out_width = 16,
585 .max_height = 480,
586 }
587 },
588 .pix_limits = {
589 .win_hor_offset_align = 8,
590 },
591 .ip_revision = S3C244X_CAMIF_IP_REV,
592};
593
594static struct s3c_camif_drvdata s3c244x_camif_drvdata = {
595 .variant = &s3c244x_camif_variant,
596 .bus_clk_freq = 24000000UL,
597};
598
599static const struct s3c_camif_variant s3c6410_camif_variant = {
600 .vp_pix_limits = {
601 [VP_CODEC] = {
602 .max_out_width = 4096,
603 .max_sc_out_width = 2048,
604 .out_width_align = 16,
605 .min_out_width = 16,
606 .max_height = 4096,
607 },
608 [VP_PREVIEW] = {
609 .max_out_width = 4096,
610 .max_sc_out_width = 720,
611 .out_width_align = 16,
612 .min_out_width = 16,
613 .max_height = 4096,
614 }
615 },
616 .pix_limits = {
617 .win_hor_offset_align = 8,
618 },
619 .ip_revision = S3C6410_CAMIF_IP_REV,
620 .has_img_effect = 1,
621 .vp_offset = 0x20,
622};
623
624static struct s3c_camif_drvdata s3c6410_camif_drvdata = {
625 .variant = &s3c6410_camif_variant,
626 .bus_clk_freq = 133000000UL,
627};
628
629static struct platform_device_id s3c_camif_driver_ids[] = {
630 {
631 .name = "s3c2440-camif",
632 .driver_data = (unsigned long)&s3c244x_camif_drvdata,
633 }, {
634 .name = "s3c6410-camif",
635 .driver_data = (unsigned long)&s3c6410_camif_drvdata,
636 },
637 { /* sentinel */ },
638};
639MODULE_DEVICE_TABLE(platform, s3c_camif_driver_ids);
640
641static const struct dev_pm_ops s3c_camif_pm_ops = {
642 .runtime_suspend = s3c_camif_runtime_suspend,
643 .runtime_resume = s3c_camif_runtime_resume,
644};
645
646static struct platform_driver s3c_camif_driver = {
647 .probe = s3c_camif_probe,
648 .remove = __devexit_p(s3c_camif_remove),
649 .id_table = s3c_camif_driver_ids,
650 .driver = {
651 .name = S3C_CAMIF_DRIVER_NAME,
652 .owner = THIS_MODULE,
653 .pm = &s3c_camif_pm_ops,
654 }
655};
656
657module_platform_driver(s3c_camif_driver);
658
659MODULE_AUTHOR("Sylwester Nawrocki <sylvester.nawrocki@gmail.com>");
660MODULE_AUTHOR("Tomasz Figa <tomasz.figa@gmail.com>");
661MODULE_DESCRIPTION("S3C24XX/S3C64XX SoC camera interface driver");
662MODULE_LICENSE("GPL");
diff --git a/drivers/media/platform/s3c-camif/camif-core.h b/drivers/media/platform/s3c-camif/camif-core.h
new file mode 100644
index 000000000000..261134baa655
--- /dev/null
+++ b/drivers/media/platform/s3c-camif/camif-core.h
@@ -0,0 +1,393 @@
1/*
2 * s3c24xx/s3c64xx SoC series Camera Interface (CAMIF) driver
3 *
4 * Copyright (C) 2012 Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
5 * Copyright (C) 2012 Tomasz Figa <tomasz.figa@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10*/
11
12#ifndef CAMIF_CORE_H_
13#define CAMIF_CORE_H_
14
15#include <linux/io.h>
16#include <linux/irq.h>
17#include <linux/platform_device.h>
18#include <linux/sched.h>
19#include <linux/spinlock.h>
20#include <linux/types.h>
21#include <linux/videodev2.h>
22
23#include <media/media-entity.h>
24#include <media/v4l2-ctrls.h>
25#include <media/v4l2-dev.h>
26#include <media/v4l2-device.h>
27#include <media/v4l2-mediabus.h>
28#include <media/videobuf2-core.h>
29#include <media/s3c_camif.h>
30
31#define S3C_CAMIF_DRIVER_NAME "s3c-camif"
32#define CAMIF_REQ_BUFS_MIN 3
33#define CAMIF_MAX_OUT_BUFS 4
34#define CAMIF_MAX_PIX_WIDTH 4096
35#define CAMIF_MAX_PIX_HEIGHT 4096
36#define SCALER_MAX_RATIO 64
37#define CAMIF_DEF_WIDTH 640
38#define CAMIF_DEF_HEIGHT 480
39#define CAMIF_STOP_TIMEOUT 1500 /* ms */
40
41#define S3C244X_CAMIF_IP_REV 0x20 /* 2.0 */
42#define S3C2450_CAMIF_IP_REV 0x30 /* 3.0 - not implemented, not tested */
43#define S3C6400_CAMIF_IP_REV 0x31 /* 3.1 - not implemented, not tested */
44#define S3C6410_CAMIF_IP_REV 0x32 /* 3.2 */
45
46/* struct camif_vp::state */
47
48#define ST_VP_PENDING (1 << 0)
49#define ST_VP_RUNNING (1 << 1)
50#define ST_VP_STREAMING (1 << 2)
51#define ST_VP_SENSOR_STREAMING (1 << 3)
52
53#define ST_VP_ABORTING (1 << 4)
54#define ST_VP_OFF (1 << 5)
55#define ST_VP_LASTIRQ (1 << 6)
56
57#define ST_VP_CONFIG (1 << 8)
58
59#define CAMIF_SD_PAD_SINK 0
60#define CAMIF_SD_PAD_SOURCE_C 1
61#define CAMIF_SD_PAD_SOURCE_P 2
62#define CAMIF_SD_PADS_NUM 3
63
64enum img_fmt {
65 IMG_FMT_RGB565 = 0x0010,
66 IMG_FMT_RGB666,
67 IMG_FMT_XRGB8888,
68 IMG_FMT_YCBCR420 = 0x0020,
69 IMG_FMT_YCRCB420,
70 IMG_FMT_YCBCR422P,
71 IMG_FMT_YCBYCR422 = 0x0040,
72 IMG_FMT_YCRYCB422,
73 IMG_FMT_CBYCRY422,
74 IMG_FMT_CRYCBY422,
75};
76
77#define img_fmt_is_rgb(x) ((x) & 0x10)
78#define img_fmt_is_ycbcr(x) ((x) & 0x60)
79
80/* Possible values for struct camif_fmt::flags */
81#define FMT_FL_S3C24XX_CODEC (1 << 0)
82#define FMT_FL_S3C24XX_PREVIEW (1 << 1)
83#define FMT_FL_S3C64XX (1 << 2)
84
85/**
86 * struct camif_fmt - pixel format description
87 * @fourcc: fourcc code for this format, 0 if not applicable
88 * @color: a corresponding enum img_fmt
89 * @colplanes: number of physically contiguous data planes
90 * @flags: indicate for which SoCs revisions this format is valid
91 * @depth: bits per pixel (total)
92 * @ybpp: number of luminance bytes per pixel
93 */
94struct camif_fmt {
95 char *name;
96 u32 fourcc;
97 u32 color;
98 u16 colplanes;
99 u16 flags;
100 u8 depth;
101 u8 ybpp;
102};
103
104/**
105 * struct camif_dma_offset - pixel offset information for DMA
106 * @initial: offset (in pixels) to first pixel
107 * @line: offset (in pixels) from end of line to start of next line
108 */
109struct camif_dma_offset {
110 int initial;
111 int line;
112};
113
114/**
115 * struct camif_frame - source/target frame properties
116 * @f_width: full pixel width
117 * @f_height: full pixel height
118 * @rect: crop/composition rectangle
119 * @dma_offset: DMA offset configuration
120 */
121struct camif_frame {
122 u16 f_width;
123 u16 f_height;
124 struct v4l2_rect rect;
125 struct camif_dma_offset dma_offset;
126};
127
128/* CAMIF clocks enumeration */
129enum {
130 CLK_GATE,
131 CLK_CAM,
132 CLK_MAX_NUM,
133};
134
135struct vp_pix_limits {
136 u16 max_out_width;
137 u16 max_sc_out_width;
138 u16 out_width_align;
139 u16 max_height;
140 u8 min_out_width;
141 u16 out_hor_offset_align;
142};
143
144struct camif_pix_limits {
145 u16 win_hor_offset_align;
146};
147
148/**
149 * struct s3c_camif_variant - CAMIF variant structure
150 * @vp_pix_limits: pixel limits for the codec and preview paths
151 * @camif_pix_limits: pixel limits for the camera input interface
152 * @ip_revision: the CAMIF IP revision: 0x20 for s3c244x, 0x32 for s3c6410
153 */
154struct s3c_camif_variant {
155 struct vp_pix_limits vp_pix_limits[2];
156 struct camif_pix_limits pix_limits;
157 u8 ip_revision;
158 u8 has_img_effect;
159 unsigned int vp_offset;
160};
161
162struct s3c_camif_drvdata {
163 const struct s3c_camif_variant *variant;
164 unsigned long bus_clk_freq;
165};
166
167struct camif_scaler {
168 u8 scaleup_h;
169 u8 scaleup_v;
170 u8 copy;
171 u8 enable;
172 u32 h_shift;
173 u32 v_shift;
174 u32 pre_h_ratio;
175 u32 pre_v_ratio;
176 u32 pre_dst_width;
177 u32 pre_dst_height;
178 u32 main_h_ratio;
179 u32 main_v_ratio;
180};
181
182struct camif_dev;
183
184/**
185 * struct camif_vp - CAMIF data processing path structure (codec/preview)
186 * @irq_queue: interrupt handling waitqueue
187 * @irq: interrupt number for this data path
188 * @camif: pointer to the camif structure
189 * @pad: media pad for the video node
190 * @vdev video device
191 * @ctrl_handler: video node controls handler
192 * @owner: file handle that own the streaming
193 * @pending_buf_q: pending (empty) buffers queue head
194 * @active_buf_q: active (being written) buffers queue head
195 * @active_buffers: counter of buffer set up at the DMA engine
196 * @buf_index: identifier of a last empty buffer set up in H/W
197 * @frame_sequence: image frame sequence counter
198 * @reqbufs_count: the number of buffers requested
199 * @scaler: the scaler structure
200 * @out_fmt: pixel format at this video path output
201 * @payload: the output data frame payload size
202 * @out_frame: the output pixel resolution
203 * @state: the video path's state
204 * @fmt_flags: flags determining supported pixel formats
205 * @id: CAMIF id, 0 - codec, 1 - preview
206 * @rotation: current image rotation value
207 * @hflip: apply horizontal flip if set
208 * @vflip: apply vertical flip if set
209 */
210struct camif_vp {
211 wait_queue_head_t irq_queue;
212 int irq;
213 struct camif_dev *camif;
214 struct media_pad pad;
215 struct video_device vdev;
216 struct v4l2_ctrl_handler ctrl_handler;
217 struct v4l2_fh *owner;
218 struct vb2_queue vb_queue;
219 struct list_head pending_buf_q;
220 struct list_head active_buf_q;
221 unsigned int active_buffers;
222 unsigned int buf_index;
223 unsigned int frame_sequence;
224 unsigned int reqbufs_count;
225 struct camif_scaler scaler;
226 const struct camif_fmt *out_fmt;
227 unsigned int payload;
228 struct camif_frame out_frame;
229 unsigned int state;
230 u16 fmt_flags;
231 u8 id;
232 u8 rotation;
233 u8 hflip;
234 u8 vflip;
235 unsigned int offset;
236};
237
238/* Video processing path enumeration */
239#define VP_CODEC 0
240#define VP_PREVIEW 1
241#define CAMIF_VP_NUM 2
242
243/**
244 * struct camif_dev - the CAMIF driver private data structure
245 * @media_dev: top-level media device structure
246 * @v4l2_dev: root v4l2_device
247 * @subdev: camera interface ("catchcam") subdev
248 * @mbus_fmt: camera input media bus format
249 * @camif_crop: camera input interface crop rectangle
250 * @pads: the camif subdev's media pads
251 * @stream_count: the camera interface streaming reference counter
252 * @sensor: image sensor data structure
253 * @m_pipeline: video entity pipeline description
254 * @ctrl_handler: v4l2 control handler (owned by @subdev)
255 * @test_pattern: test pattern controls
256 * @vp: video path (DMA) description (codec/preview)
257 * @alloc_ctx: memory buffer allocator context
258 * @variant: variant information for this device
259 * @dev: pointer to the CAMIF device struct
260 * @pdata: a copy of the driver's platform data
261 * @clock: clocks required for the CAMIF operation
262 * @lock: mutex protecting this data structure
263 * @slock: spinlock protecting CAMIF registers
264 * @io_base: start address of the mmaped CAMIF registers
265 */
266struct camif_dev {
267 struct media_device media_dev;
268 struct v4l2_device v4l2_dev;
269 struct v4l2_subdev subdev;
270 struct v4l2_mbus_framefmt mbus_fmt;
271 struct v4l2_rect camif_crop;
272 struct media_pad pads[CAMIF_SD_PADS_NUM];
273 int stream_count;
274
275 struct cam_sensor {
276 struct v4l2_subdev *sd;
277 short power_count;
278 short stream_count;
279 } sensor;
280 struct media_pipeline *m_pipeline;
281
282 struct v4l2_ctrl_handler ctrl_handler;
283 struct v4l2_ctrl *ctrl_test_pattern;
284 struct {
285 struct v4l2_ctrl *ctrl_colorfx;
286 struct v4l2_ctrl *ctrl_colorfx_cbcr;
287 };
288 u8 test_pattern;
289 u8 colorfx;
290 u8 colorfx_cb;
291 u8 colorfx_cr;
292
293 struct camif_vp vp[CAMIF_VP_NUM];
294 struct vb2_alloc_ctx *alloc_ctx;
295
296 const struct s3c_camif_variant *variant;
297 struct device *dev;
298 struct s3c_camif_plat_data pdata;
299 struct clk *clock[CLK_MAX_NUM];
300 struct mutex lock;
301 spinlock_t slock;
302 void __iomem *io_base;
303};
304
305/**
306 * struct camif_addr - Y/Cb/Cr DMA start address structure
307 * @y: luminance plane dma address
308 * @cb: Cb plane dma address
309 * @cr: Cr plane dma address
310 */
311struct camif_addr {
312 dma_addr_t y;
313 dma_addr_t cb;
314 dma_addr_t cr;
315};
316
317/**
318 * struct camif_buffer - the camif video buffer structure
319 * @vb: vb2 buffer
320 * @list: list head for the buffers queue
321 * @paddr: DMA start addresses
322 * @index: an identifier of this buffer at the DMA engine
323 */
324struct camif_buffer {
325 struct vb2_buffer vb;
326 struct list_head list;
327 struct camif_addr paddr;
328 unsigned int index;
329};
330
331const struct camif_fmt *s3c_camif_find_format(struct camif_vp *vp,
332 const u32 *pixelformat, int index);
333int s3c_camif_register_video_node(struct camif_dev *camif, int idx);
334void s3c_camif_unregister_video_node(struct camif_dev *camif, int idx);
335irqreturn_t s3c_camif_irq_handler(int irq, void *priv);
336int s3c_camif_create_subdev(struct camif_dev *camif);
337void s3c_camif_unregister_subdev(struct camif_dev *camif);
338int s3c_camif_set_defaults(struct camif_dev *camif);
339int s3c_camif_get_scaler_config(struct camif_vp *vp,
340 struct camif_scaler *scaler);
341
342static inline void camif_active_queue_add(struct camif_vp *vp,
343 struct camif_buffer *buf)
344{
345 list_add_tail(&buf->list, &vp->active_buf_q);
346 vp->active_buffers++;
347}
348
349static inline struct camif_buffer *camif_active_queue_pop(
350 struct camif_vp *vp)
351{
352 struct camif_buffer *buf = list_first_entry(&vp->active_buf_q,
353 struct camif_buffer, list);
354 list_del(&buf->list);
355 vp->active_buffers--;
356 return buf;
357}
358
359static inline struct camif_buffer *camif_active_queue_peek(
360 struct camif_vp *vp, int index)
361{
362 struct camif_buffer *tmp, *buf;
363
364 if (WARN_ON(list_empty(&vp->active_buf_q)))
365 return NULL;
366
367 list_for_each_entry_safe(buf, tmp, &vp->active_buf_q, list) {
368 if (buf->index == index) {
369 list_del(&buf->list);
370 vp->active_buffers--;
371 return buf;
372 }
373 }
374
375 return NULL;
376}
377
378static inline void camif_pending_queue_add(struct camif_vp *vp,
379 struct camif_buffer *buf)
380{
381 list_add_tail(&buf->list, &vp->pending_buf_q);
382}
383
384static inline struct camif_buffer *camif_pending_queue_pop(
385 struct camif_vp *vp)
386{
387 struct camif_buffer *buf = list_first_entry(&vp->pending_buf_q,
388 struct camif_buffer, list);
389 list_del(&buf->list);
390 return buf;
391}
392
393#endif /* CAMIF_CORE_H_ */
diff --git a/drivers/media/platform/s3c-camif/camif-regs.c b/drivers/media/platform/s3c-camif/camif-regs.c
new file mode 100644
index 000000000000..1a3b4fc05ec6
--- /dev/null
+++ b/drivers/media/platform/s3c-camif/camif-regs.c
@@ -0,0 +1,606 @@
1/*
2 * Samsung s3c24xx/s3c64xx SoC CAMIF driver
3 *
4 * Copyright (C) 2012 Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
5 * Copyright (C) 2012 Tomasz Figa <tomasz.figa@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10*/
11#define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
12
13#include <linux/delay.h>
14#include "camif-regs.h"
15
16#define camif_write(_camif, _off, _val) writel(_val, (_camif)->io_base + (_off))
17#define camif_read(_camif, _off) readl((_camif)->io_base + (_off))
18
19void camif_hw_reset(struct camif_dev *camif)
20{
21 u32 cfg;
22
23 cfg = camif_read(camif, S3C_CAMIF_REG_CISRCFMT);
24 cfg |= CISRCFMT_ITU601_8BIT;
25 camif_write(camif, S3C_CAMIF_REG_CISRCFMT, cfg);
26
27 /* S/W reset */
28 cfg = camif_read(camif, S3C_CAMIF_REG_CIGCTRL);
29 cfg |= CIGCTRL_SWRST;
30 if (camif->variant->ip_revision == S3C6410_CAMIF_IP_REV)
31 cfg |= CIGCTRL_IRQ_LEVEL;
32 camif_write(camif, S3C_CAMIF_REG_CIGCTRL, cfg);
33 udelay(10);
34
35 cfg = camif_read(camif, S3C_CAMIF_REG_CIGCTRL);
36 cfg &= ~CIGCTRL_SWRST;
37 camif_write(camif, S3C_CAMIF_REG_CIGCTRL, cfg);
38 udelay(10);
39}
40
41void camif_hw_clear_pending_irq(struct camif_vp *vp)
42{
43 u32 cfg = camif_read(vp->camif, S3C_CAMIF_REG_CIGCTRL);
44 cfg |= CIGCTRL_IRQ_CLR(vp->id);
45 camif_write(vp->camif, S3C_CAMIF_REG_CIGCTRL, cfg);
46}
47
48/*
49 * Sets video test pattern (off, color bar, horizontal or vertical gradient).
50 * External sensor pixel clock must be active for the test pattern to work.
51 */
52void camif_hw_set_test_pattern(struct camif_dev *camif, unsigned int pattern)
53{
54 u32 cfg = camif_read(camif, S3C_CAMIF_REG_CIGCTRL);
55 cfg &= ~CIGCTRL_TESTPATTERN_MASK;
56 cfg |= (pattern << 27);
57 camif_write(camif, S3C_CAMIF_REG_CIGCTRL, cfg);
58}
59
60void camif_hw_set_effect(struct camif_dev *camif, unsigned int effect,
61 unsigned int cr, unsigned int cb)
62{
63 static const struct v4l2_control colorfx[] = {
64 { V4L2_COLORFX_NONE, CIIMGEFF_FIN_BYPASS },
65 { V4L2_COLORFX_BW, CIIMGEFF_FIN_ARBITRARY },
66 { V4L2_COLORFX_SEPIA, CIIMGEFF_FIN_ARBITRARY },
67 { V4L2_COLORFX_NEGATIVE, CIIMGEFF_FIN_NEGATIVE },
68 { V4L2_COLORFX_ART_FREEZE, CIIMGEFF_FIN_ARTFREEZE },
69 { V4L2_COLORFX_EMBOSS, CIIMGEFF_FIN_EMBOSSING },
70 { V4L2_COLORFX_SILHOUETTE, CIIMGEFF_FIN_SILHOUETTE },
71 { V4L2_COLORFX_SET_CBCR, CIIMGEFF_FIN_ARBITRARY },
72 };
73 unsigned int i, cfg;
74
75 for (i = 0; i < ARRAY_SIZE(colorfx); i++)
76 if (colorfx[i].id == effect)
77 break;
78
79 if (i == ARRAY_SIZE(colorfx))
80 return;
81
82 cfg = camif_read(camif, S3C_CAMIF_REG_CIIMGEFF(camif->vp->offset));
83 /* Set effect */
84 cfg &= ~CIIMGEFF_FIN_MASK;
85 cfg |= colorfx[i].value;
86 /* Set both paths */
87 if (camif->variant->ip_revision >= S3C6400_CAMIF_IP_REV) {
88 if (effect == V4L2_COLORFX_NONE)
89 cfg &= ~CIIMGEFF_IE_ENABLE_MASK;
90 else
91 cfg |= CIIMGEFF_IE_ENABLE_MASK;
92 }
93 cfg &= ~CIIMGEFF_PAT_CBCR_MASK;
94 cfg |= cr | (cb << 13);
95 camif_write(camif, S3C_CAMIF_REG_CIIMGEFF(camif->vp->offset), cfg);
96}
97
98static const u32 src_pixfmt_map[8][2] = {
99 { V4L2_MBUS_FMT_YUYV8_2X8, CISRCFMT_ORDER422_YCBYCR },
100 { V4L2_MBUS_FMT_YVYU8_2X8, CISRCFMT_ORDER422_YCRYCB },
101 { V4L2_MBUS_FMT_UYVY8_2X8, CISRCFMT_ORDER422_CBYCRY },
102 { V4L2_MBUS_FMT_VYUY8_2X8, CISRCFMT_ORDER422_CRYCBY },
103};
104
105/* Set camera input pixel format and resolution */
106void camif_hw_set_source_format(struct camif_dev *camif)
107{
108 struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt;
109 unsigned int i = ARRAY_SIZE(src_pixfmt_map);
110 u32 cfg;
111
112 while (i-- >= 0) {
113 if (src_pixfmt_map[i][0] == mf->code)
114 break;
115 }
116
117 if (i == 0 && src_pixfmt_map[i][0] != mf->code) {
118 dev_err(camif->dev,
119 "Unsupported pixel code, falling back to %#08x\n",
120 src_pixfmt_map[i][0]);
121 }
122
123 cfg = camif_read(camif, S3C_CAMIF_REG_CISRCFMT);
124 cfg &= ~(CISRCFMT_ORDER422_MASK | CISRCFMT_SIZE_CAM_MASK);
125 cfg |= (mf->width << 16) | mf->height;
126 cfg |= src_pixfmt_map[i][1];
127 camif_write(camif, S3C_CAMIF_REG_CISRCFMT, cfg);
128}
129
130/* Set the camera host input window offsets (cropping) */
131void camif_hw_set_camera_crop(struct camif_dev *camif)
132{
133 struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt;
134 struct v4l2_rect *crop = &camif->camif_crop;
135 u32 hoff2, voff2;
136 u32 cfg;
137
138 /* Note: s3c244x requirement: left = f_width - rect.width / 2 */
139 cfg = camif_read(camif, S3C_CAMIF_REG_CIWDOFST);
140 cfg &= ~(CIWDOFST_OFST_MASK | CIWDOFST_WINOFSEN);
141 cfg |= (crop->left << 16) | crop->top;
142 if (crop->left != 0 || crop->top != 0)
143 cfg |= CIWDOFST_WINOFSEN;
144 camif_write(camif, S3C_CAMIF_REG_CIWDOFST, cfg);
145
146 if (camif->variant->ip_revision == S3C6410_CAMIF_IP_REV) {
147 hoff2 = mf->width - crop->width - crop->left;
148 voff2 = mf->height - crop->height - crop->top;
149 cfg = (hoff2 << 16) | voff2;
150 camif_write(camif, S3C_CAMIF_REG_CIWDOFST2, cfg);
151 }
152}
153
154void camif_hw_clear_fifo_overflow(struct camif_vp *vp)
155{
156 struct camif_dev *camif = vp->camif;
157 u32 cfg;
158
159 cfg = camif_read(camif, S3C_CAMIF_REG_CIWDOFST);
160 if (vp->id == 0)
161 cfg |= (CIWDOFST_CLROVCOFIY | CIWDOFST_CLROVCOFICB |
162 CIWDOFST_CLROVCOFICR);
163 else
164 cfg |= (/* CIWDOFST_CLROVPRFIY | */ CIWDOFST_CLROVPRFICB |
165 CIWDOFST_CLROVPRFICR);
166 camif_write(camif, S3C_CAMIF_REG_CIWDOFST, cfg);
167}
168
169/* Set video bus signals polarity */
170void camif_hw_set_camera_bus(struct camif_dev *camif)
171{
172 unsigned int flags = camif->pdata.sensor.flags;
173
174 u32 cfg = camif_read(camif, S3C_CAMIF_REG_CIGCTRL);
175
176 cfg &= ~(CIGCTRL_INVPOLPCLK | CIGCTRL_INVPOLVSYNC |
177 CIGCTRL_INVPOLHREF | CIGCTRL_INVPOLFIELD);
178
179 if (flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)
180 cfg |= CIGCTRL_INVPOLPCLK;
181
182 if (flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
183 cfg |= CIGCTRL_INVPOLVSYNC;
184 /*
185 * HREF is normally high during frame active data
186 * transmission and low during horizontal synchronization
187 * period. Thus HREF active high means HSYNC active low.
188 */
189 if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
190 cfg |= CIGCTRL_INVPOLHREF; /* HREF active low */
191
192 if (camif->variant->ip_revision == S3C6410_CAMIF_IP_REV) {
193 if (flags & V4L2_MBUS_FIELD_EVEN_LOW)
194 cfg |= CIGCTRL_INVPOLFIELD;
195 cfg |= CIGCTRL_FIELDMODE;
196 }
197
198 pr_debug("Setting CIGCTRL to: %#x\n", cfg);
199
200 camif_write(camif, S3C_CAMIF_REG_CIGCTRL, cfg);
201}
202
203void camif_hw_set_output_addr(struct camif_vp *vp,
204 struct camif_addr *paddr, int i)
205{
206 struct camif_dev *camif = vp->camif;
207
208 camif_write(camif, S3C_CAMIF_REG_CIYSA(vp->id, i), paddr->y);
209 if (camif->variant->ip_revision == S3C6410_CAMIF_IP_REV
210 || vp->id == VP_CODEC) {
211 camif_write(camif, S3C_CAMIF_REG_CICBSA(vp->id, i),
212 paddr->cb);
213 camif_write(camif, S3C_CAMIF_REG_CICRSA(vp->id, i),
214 paddr->cr);
215 }
216
217 pr_debug("dst_buf[%d]: %#X, cb: %#X, cr: %#X\n",
218 i, paddr->y, paddr->cb, paddr->cr);
219}
220
221static void camif_hw_set_out_dma_size(struct camif_vp *vp)
222{
223 struct camif_frame *frame = &vp->out_frame;
224 u32 cfg;
225
226 cfg = camif_read(vp->camif, S3C_CAMIF_REG_CITRGFMT(vp->id, vp->offset));
227 cfg &= ~CITRGFMT_TARGETSIZE_MASK;
228 cfg |= (frame->f_width << 16) | frame->f_height;
229 camif_write(vp->camif, S3C_CAMIF_REG_CITRGFMT(vp->id, vp->offset), cfg);
230}
231
232static void camif_get_dma_burst(u32 width, u32 ybpp, u32 *mburst, u32 *rburst)
233{
234 unsigned int nwords = width * ybpp / 4;
235 unsigned int div, rem;
236
237 if (WARN_ON(width < 8 || (width * ybpp) & 7))
238 return;
239
240 for (div = 16; div >= 2; div /= 2) {
241 if (nwords < div)
242 continue;
243
244 rem = nwords & (div - 1);
245 if (rem == 0) {
246 *mburst = div;
247 *rburst = div;
248 break;
249 }
250 if (rem == div / 2 || rem == div / 4) {
251 *mburst = div;
252 *rburst = rem;
253 break;
254 }
255 }
256}
257
258void camif_hw_set_output_dma(struct camif_vp *vp)
259{
260 struct camif_dev *camif = vp->camif;
261 struct camif_frame *frame = &vp->out_frame;
262 const struct camif_fmt *fmt = vp->out_fmt;
263 unsigned int ymburst = 0, yrburst = 0;
264 u32 cfg;
265
266 camif_hw_set_out_dma_size(vp);
267
268 if (camif->variant->ip_revision == S3C6410_CAMIF_IP_REV) {
269 struct camif_dma_offset *offset = &frame->dma_offset;
270 /* Set the input dma offsets. */
271 cfg = S3C_CISS_OFFS_INITIAL(offset->initial);
272 cfg |= S3C_CISS_OFFS_LINE(offset->line);
273 camif_write(camif, S3C_CAMIF_REG_CISSY(vp->id), cfg);
274 camif_write(camif, S3C_CAMIF_REG_CISSCB(vp->id), cfg);
275 camif_write(camif, S3C_CAMIF_REG_CISSCR(vp->id), cfg);
276 }
277
278 /* Configure DMA burst values */
279 camif_get_dma_burst(frame->rect.width, fmt->ybpp, &ymburst, &yrburst);
280
281 cfg = camif_read(camif, S3C_CAMIF_REG_CICTRL(vp->id, vp->offset));
282 cfg &= ~CICTRL_BURST_MASK;
283
284 cfg |= CICTRL_YBURST1(ymburst) | CICTRL_YBURST2(yrburst);
285 cfg |= CICTRL_CBURST1(ymburst / 2) | CICTRL_CBURST2(yrburst / 2);
286
287 camif_write(camif, S3C_CAMIF_REG_CICTRL(vp->id, vp->offset), cfg);
288
289 pr_debug("ymburst: %u, yrburst: %u\n", ymburst, yrburst);
290}
291
292void camif_hw_set_input_path(struct camif_vp *vp)
293{
294 u32 cfg = camif_read(vp->camif, S3C_CAMIF_REG_MSCTRL(vp->id));
295 cfg &= ~MSCTRL_SEL_DMA_CAM;
296 camif_write(vp->camif, S3C_CAMIF_REG_MSCTRL(vp->id), cfg);
297}
298
299void camif_hw_set_target_format(struct camif_vp *vp)
300{
301 struct camif_dev *camif = vp->camif;
302 struct camif_frame *frame = &vp->out_frame;
303 u32 cfg;
304
305 pr_debug("fw: %d, fh: %d color: %d\n", frame->f_width,
306 frame->f_height, vp->out_fmt->color);
307
308 cfg = camif_read(camif, S3C_CAMIF_REG_CITRGFMT(vp->id, vp->offset));
309 cfg &= ~CITRGFMT_TARGETSIZE_MASK;
310
311 if (camif->variant->ip_revision == S3C244X_CAMIF_IP_REV) {
312 /* We currently support only YCbCr 4:2:2 at the camera input */
313 cfg |= CITRGFMT_IN422;
314 cfg &= ~CITRGFMT_OUT422;
315 if (vp->out_fmt->color == IMG_FMT_YCBCR422P)
316 cfg |= CITRGFMT_OUT422;
317 } else {
318 cfg &= ~CITRGFMT_OUTFORMAT_MASK;
319 switch (vp->out_fmt->color) {
320 case IMG_FMT_RGB565...IMG_FMT_XRGB8888:
321 cfg |= CITRGFMT_OUTFORMAT_RGB;
322 break;
323 case IMG_FMT_YCBCR420...IMG_FMT_YCRCB420:
324 cfg |= CITRGFMT_OUTFORMAT_YCBCR420;
325 break;
326 case IMG_FMT_YCBCR422P:
327 cfg |= CITRGFMT_OUTFORMAT_YCBCR422;
328 break;
329 case IMG_FMT_YCBYCR422...IMG_FMT_CRYCBY422:
330 cfg |= CITRGFMT_OUTFORMAT_YCBCR422I;
331 break;
332 }
333 }
334
335 /* Rotation is only supported by s3c64xx */
336 if (vp->rotation == 90 || vp->rotation == 270)
337 cfg |= (frame->f_height << 16) | frame->f_width;
338 else
339 cfg |= (frame->f_width << 16) | frame->f_height;
340 camif_write(camif, S3C_CAMIF_REG_CITRGFMT(vp->id, vp->offset), cfg);
341
342 /* Target area, output pixel width * height */
343 cfg = camif_read(camif, S3C_CAMIF_REG_CITAREA(vp->id, vp->offset));
344 cfg &= ~CITAREA_MASK;
345 cfg |= (frame->f_width * frame->f_height);
346 camif_write(camif, S3C_CAMIF_REG_CITAREA(vp->id, vp->offset), cfg);
347}
348
349void camif_hw_set_flip(struct camif_vp *vp)
350{
351 u32 cfg = camif_read(vp->camif,
352 S3C_CAMIF_REG_CITRGFMT(vp->id, vp->offset));
353
354 cfg &= ~CITRGFMT_FLIP_MASK;
355
356 if (vp->hflip)
357 cfg |= CITRGFMT_FLIP_Y_MIRROR;
358 if (vp->vflip)
359 cfg |= CITRGFMT_FLIP_X_MIRROR;
360
361 camif_write(vp->camif, S3C_CAMIF_REG_CITRGFMT(vp->id, vp->offset), cfg);
362}
363
364static void camif_hw_set_prescaler(struct camif_vp *vp)
365{
366 struct camif_dev *camif = vp->camif;
367 struct camif_scaler *sc = &vp->scaler;
368 u32 cfg, shfactor, addr;
369
370 addr = S3C_CAMIF_REG_CISCPRERATIO(vp->id, vp->offset);
371
372 shfactor = 10 - (sc->h_shift + sc->v_shift);
373 cfg = shfactor << 28;
374
375 cfg |= (sc->pre_h_ratio << 16) | sc->pre_v_ratio;
376 camif_write(camif, addr, cfg);
377
378 cfg = (sc->pre_dst_width << 16) | sc->pre_dst_height;
379 camif_write(camif, S3C_CAMIF_REG_CISCPREDST(vp->id, vp->offset), cfg);
380}
381
382void camif_s3c244x_hw_set_scaler(struct camif_vp *vp)
383{
384 struct camif_dev *camif = vp->camif;
385 struct camif_scaler *scaler = &vp->scaler;
386 unsigned int color = vp->out_fmt->color;
387 u32 cfg;
388
389 camif_hw_set_prescaler(vp);
390
391 cfg = camif_read(camif, S3C_CAMIF_REG_CISCCTRL(vp->id, vp->offset));
392
393 cfg &= ~(CISCCTRL_SCALEUP_MASK | CISCCTRL_SCALERBYPASS |
394 CISCCTRL_MAIN_RATIO_MASK | CIPRSCCTRL_RGB_FORMAT_24BIT);
395
396 if (scaler->enable) {
397 if (scaler->scaleup_h) {
398 if (vp->id == VP_CODEC)
399 cfg |= CISCCTRL_SCALEUP_H;
400 else
401 cfg |= CIPRSCCTRL_SCALEUP_H;
402 }
403 if (scaler->scaleup_v) {
404 if (vp->id == VP_CODEC)
405 cfg |= CISCCTRL_SCALEUP_V;
406 else
407 cfg |= CIPRSCCTRL_SCALEUP_V;
408 }
409 } else {
410 if (vp->id == VP_CODEC)
411 cfg |= CISCCTRL_SCALERBYPASS;
412 }
413
414 cfg |= ((scaler->main_h_ratio & 0x1ff) << 16);
415 cfg |= scaler->main_v_ratio & 0x1ff;
416
417 if (vp->id == VP_PREVIEW) {
418 if (color == IMG_FMT_XRGB8888)
419 cfg |= CIPRSCCTRL_RGB_FORMAT_24BIT;
420 cfg |= CIPRSCCTRL_SAMPLE;
421 }
422
423 camif_write(camif, S3C_CAMIF_REG_CISCCTRL(vp->id, vp->offset), cfg);
424
425 pr_debug("main: h_ratio: %#x, v_ratio: %#x",
426 scaler->main_h_ratio, scaler->main_v_ratio);
427}
428
429void camif_s3c64xx_hw_set_scaler(struct camif_vp *vp)
430{
431 struct camif_dev *camif = vp->camif;
432 struct camif_scaler *scaler = &vp->scaler;
433 unsigned int color = vp->out_fmt->color;
434 u32 cfg;
435
436 camif_hw_set_prescaler(vp);
437
438 cfg = camif_read(camif, S3C_CAMIF_REG_CISCCTRL(vp->id, vp->offset));
439
440 cfg &= ~(CISCCTRL_CSCR2Y_WIDE | CISCCTRL_CSCY2R_WIDE
441 | CISCCTRL_SCALEUP_H | CISCCTRL_SCALEUP_V
442 | CISCCTRL_SCALERBYPASS | CISCCTRL_ONE2ONE
443 | CISCCTRL_INRGB_FMT_MASK | CISCCTRL_OUTRGB_FMT_MASK
444 | CISCCTRL_INTERLACE | CISCCTRL_EXTRGB_EXTENSION
445 | CISCCTRL_MAIN_RATIO_MASK);
446
447 cfg |= (CISCCTRL_CSCR2Y_WIDE | CISCCTRL_CSCY2R_WIDE);
448
449 if (!scaler->enable) {
450 cfg |= CISCCTRL_SCALERBYPASS;
451 } else {
452 if (scaler->scaleup_h)
453 cfg |= CISCCTRL_SCALEUP_H;
454 if (scaler->scaleup_v)
455 cfg |= CISCCTRL_SCALEUP_V;
456 if (scaler->copy)
457 cfg |= CISCCTRL_ONE2ONE;
458 }
459
460 switch (color) {
461 case IMG_FMT_RGB666:
462 cfg |= CISCCTRL_OUTRGB_FMT_RGB666;
463 break;
464 case IMG_FMT_XRGB8888:
465 cfg |= CISCCTRL_OUTRGB_FMT_RGB888;
466 break;
467 }
468
469 cfg |= (scaler->main_h_ratio & 0x1ff) << 16;
470 cfg |= scaler->main_v_ratio & 0x1ff;
471
472 camif_write(camif, S3C_CAMIF_REG_CISCCTRL(vp->id, vp->offset), cfg);
473
474 pr_debug("main: h_ratio: %#x, v_ratio: %#x",
475 scaler->main_h_ratio, scaler->main_v_ratio);
476}
477
478void camif_hw_set_scaler(struct camif_vp *vp)
479{
480 unsigned int ip_rev = vp->camif->variant->ip_revision;
481
482 if (ip_rev == S3C244X_CAMIF_IP_REV)
483 camif_s3c244x_hw_set_scaler(vp);
484 else
485 camif_s3c64xx_hw_set_scaler(vp);
486}
487
488void camif_hw_enable_scaler(struct camif_vp *vp, bool on)
489{
490 u32 addr = S3C_CAMIF_REG_CISCCTRL(vp->id, vp->offset);
491 u32 cfg;
492
493 cfg = camif_read(vp->camif, addr);
494 if (on)
495 cfg |= CISCCTRL_SCALERSTART;
496 else
497 cfg &= ~CISCCTRL_SCALERSTART;
498 camif_write(vp->camif, addr, cfg);
499}
500
501void camif_hw_set_lastirq(struct camif_vp *vp, int enable)
502{
503 u32 addr = S3C_CAMIF_REG_CICTRL(vp->id, vp->offset);
504 u32 cfg;
505
506 cfg = camif_read(vp->camif, addr);
507 if (enable)
508 cfg |= CICTRL_LASTIRQ_ENABLE;
509 else
510 cfg &= ~CICTRL_LASTIRQ_ENABLE;
511 camif_write(vp->camif, addr, cfg);
512}
513
514void camif_hw_enable_capture(struct camif_vp *vp)
515{
516 struct camif_dev *camif = vp->camif;
517 u32 cfg;
518
519 cfg = camif_read(camif, S3C_CAMIF_REG_CIIMGCPT(vp->offset));
520 camif->stream_count++;
521
522 if (camif->variant->ip_revision == S3C6410_CAMIF_IP_REV)
523 cfg |= CIIMGCPT_CPT_FREN_ENABLE(vp->id);
524
525 if (vp->scaler.enable)
526 cfg |= CIIMGCPT_IMGCPTEN_SC(vp->id);
527
528 if (camif->stream_count == 1)
529 cfg |= CIIMGCPT_IMGCPTEN;
530
531 camif_write(camif, S3C_CAMIF_REG_CIIMGCPT(vp->offset), cfg);
532
533 pr_debug("CIIMGCPT: %#x, camif->stream_count: %d\n",
534 cfg, camif->stream_count);
535}
536
537void camif_hw_disable_capture(struct camif_vp *vp)
538{
539 struct camif_dev *camif = vp->camif;
540 u32 cfg;
541
542 cfg = camif_read(camif, S3C_CAMIF_REG_CIIMGCPT(vp->offset));
543 cfg &= ~CIIMGCPT_IMGCPTEN_SC(vp->id);
544
545 if (WARN_ON(--(camif->stream_count) < 0))
546 camif->stream_count = 0;
547
548 if (camif->stream_count == 0)
549 cfg &= ~CIIMGCPT_IMGCPTEN;
550
551 pr_debug("CIIMGCPT: %#x, camif->stream_count: %d\n",
552 cfg, camif->stream_count);
553
554 camif_write(camif, S3C_CAMIF_REG_CIIMGCPT(vp->offset), cfg);
555}
556
557void camif_hw_dump_regs(struct camif_dev *camif, const char *label)
558{
559 struct {
560 u32 offset;
561 const char * const name;
562 } registers[] = {
563 { S3C_CAMIF_REG_CISRCFMT, "CISRCFMT" },
564 { S3C_CAMIF_REG_CIWDOFST, "CIWDOFST" },
565 { S3C_CAMIF_REG_CIGCTRL, "CIGCTRL" },
566 { S3C_CAMIF_REG_CIWDOFST2, "CIWDOFST2" },
567 { S3C_CAMIF_REG_CIYSA(0, 0), "CICOYSA0" },
568 { S3C_CAMIF_REG_CICBSA(0, 0), "CICOCBSA0" },
569 { S3C_CAMIF_REG_CICRSA(0, 0), "CICOCRSA0" },
570 { S3C_CAMIF_REG_CIYSA(0, 1), "CICOYSA1" },
571 { S3C_CAMIF_REG_CICBSA(0, 1), "CICOCBSA1" },
572 { S3C_CAMIF_REG_CICRSA(0, 1), "CICOCRSA1" },
573 { S3C_CAMIF_REG_CIYSA(0, 2), "CICOYSA2" },
574 { S3C_CAMIF_REG_CICBSA(0, 2), "CICOCBSA2" },
575 { S3C_CAMIF_REG_CICRSA(0, 2), "CICOCRSA2" },
576 { S3C_CAMIF_REG_CIYSA(0, 3), "CICOYSA3" },
577 { S3C_CAMIF_REG_CICBSA(0, 3), "CICOCBSA3" },
578 { S3C_CAMIF_REG_CICRSA(0, 3), "CICOCRSA3" },
579 { S3C_CAMIF_REG_CIYSA(1, 0), "CIPRYSA0" },
580 { S3C_CAMIF_REG_CIYSA(1, 1), "CIPRYSA1" },
581 { S3C_CAMIF_REG_CIYSA(1, 2), "CIPRYSA2" },
582 { S3C_CAMIF_REG_CIYSA(1, 3), "CIPRYSA3" },
583 { S3C_CAMIF_REG_CITRGFMT(0, 0), "CICOTRGFMT" },
584 { S3C_CAMIF_REG_CITRGFMT(1, 0), "CIPRTRGFMT" },
585 { S3C_CAMIF_REG_CICTRL(0, 0), "CICOCTRL" },
586 { S3C_CAMIF_REG_CICTRL(1, 0), "CIPRCTRL" },
587 { S3C_CAMIF_REG_CISCPREDST(0, 0), "CICOSCPREDST" },
588 { S3C_CAMIF_REG_CISCPREDST(1, 0), "CIPRSCPREDST" },
589 { S3C_CAMIF_REG_CISCPRERATIO(0, 0), "CICOSCPRERATIO" },
590 { S3C_CAMIF_REG_CISCPRERATIO(1, 0), "CIPRSCPRERATIO" },
591 { S3C_CAMIF_REG_CISCCTRL(0, 0), "CICOSCCTRL" },
592 { S3C_CAMIF_REG_CISCCTRL(1, 0), "CIPRSCCTRL" },
593 { S3C_CAMIF_REG_CITAREA(0, 0), "CICOTAREA" },
594 { S3C_CAMIF_REG_CITAREA(1, 0), "CIPRTAREA" },
595 { S3C_CAMIF_REG_CISTATUS(0, 0), "CICOSTATUS" },
596 { S3C_CAMIF_REG_CISTATUS(1, 0), "CIPRSTATUS" },
597 { S3C_CAMIF_REG_CIIMGCPT(0), "CIIMGCPT" },
598 };
599 u32 i;
600
601 pr_info("--- %s ---\n", label);
602 for (i = 0; i < ARRAY_SIZE(registers); i++) {
603 u32 cfg = readl(camif->io_base + registers[i].offset);
604 printk(KERN_INFO "%s:\t0x%08x\n", registers[i].name, cfg);
605 }
606}
diff --git a/drivers/media/platform/s3c-camif/camif-regs.h b/drivers/media/platform/s3c-camif/camif-regs.h
new file mode 100644
index 000000000000..af2d472ea1dd
--- /dev/null
+++ b/drivers/media/platform/s3c-camif/camif-regs.h
@@ -0,0 +1,269 @@
1/*
2 * Register definition file for s3c24xx/s3c64xx SoC CAMIF driver
3 *
4 * Copyright (C) 2012 Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
5 * Copyright (C) 2012 Tomasz Figa <tomasz.figa@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10*/
11
12#ifndef CAMIF_REGS_H_
13#define CAMIF_REGS_H_
14
15#include "camif-core.h"
16#include <media/s3c_camif.h>
17
18/*
19 * The id argument indicates the processing path:
20 * id = 0 - codec (FIMC C), 1 - preview (FIMC P).
21 */
22
23/* Camera input format */
24#define S3C_CAMIF_REG_CISRCFMT 0x00
25#define CISRCFMT_ITU601_8BIT (1 << 31)
26#define CISRCFMT_ITU656_8BIT (0 << 31)
27#define CISRCFMT_ORDER422_YCBYCR (0 << 14)
28#define CISRCFMT_ORDER422_YCRYCB (1 << 14)
29#define CISRCFMT_ORDER422_CBYCRY (2 << 14)
30#define CISRCFMT_ORDER422_CRYCBY (3 << 14)
31#define CISRCFMT_ORDER422_MASK (3 << 14)
32#define CISRCFMT_SIZE_CAM_MASK (0x1fff << 16 | 0x1fff)
33
34/* Window offset */
35#define S3C_CAMIF_REG_CIWDOFST 0x04
36#define CIWDOFST_WINOFSEN (1 << 31)
37#define CIWDOFST_CLROVCOFIY (1 << 30)
38#define CIWDOFST_CLROVRLB_PR (1 << 28)
39/* #define CIWDOFST_CLROVPRFIY (1 << 27) */
40#define CIWDOFST_CLROVCOFICB (1 << 15)
41#define CIWDOFST_CLROVCOFICR (1 << 14)
42#define CIWDOFST_CLROVPRFICB (1 << 13)
43#define CIWDOFST_CLROVPRFICR (1 << 12)
44#define CIWDOFST_OFST_MASK (0x7ff << 16 | 0x7ff)
45
46/* Window offset 2 */
47#define S3C_CAMIF_REG_CIWDOFST2 0x14
48#define CIWDOFST2_OFST2_MASK (0xfff << 16 | 0xfff)
49
50/* Global control */
51#define S3C_CAMIF_REG_CIGCTRL 0x08
52#define CIGCTRL_SWRST (1 << 31)
53#define CIGCTRL_CAMRST (1 << 30)
54#define CIGCTRL_TESTPATTERN_NORMAL (0 << 27)
55#define CIGCTRL_TESTPATTERN_COLOR_BAR (1 << 27)
56#define CIGCTRL_TESTPATTERN_HOR_INC (2 << 27)
57#define CIGCTRL_TESTPATTERN_VER_INC (3 << 27)
58#define CIGCTRL_TESTPATTERN_MASK (3 << 27)
59#define CIGCTRL_INVPOLPCLK (1 << 26)
60#define CIGCTRL_INVPOLVSYNC (1 << 25)
61#define CIGCTRL_INVPOLHREF (1 << 24)
62#define CIGCTRL_IRQ_OVFEN (1 << 22)
63#define CIGCTRL_HREF_MASK (1 << 21)
64#define CIGCTRL_IRQ_LEVEL (1 << 20)
65/* IRQ_CLR_C, IRQ_CLR_P */
66#define CIGCTRL_IRQ_CLR(id) (1 << (19 - (id)))
67#define CIGCTRL_FIELDMODE (1 << 2)
68#define CIGCTRL_INVPOLFIELD (1 << 1)
69#define CIGCTRL_CAM_INTERLACE (1 << 0)
70
71/* Y DMA output frame start address. n = 0..3. */
72#define S3C_CAMIF_REG_CIYSA(id, n) (0x18 + (id) * 0x54 + (n) * 4)
73/* Cb plane output DMA start address. n = 0..3. Only codec path. */
74#define S3C_CAMIF_REG_CICBSA(id, n) (0x28 + (id) * 0x54 + (n) * 4)
75/* Cr plane output DMA start address. n = 0..3. Only codec path. */
76#define S3C_CAMIF_REG_CICRSA(id, n) (0x38 + (id) * 0x54 + (n) * 4)
77
78/* CICOTRGFMT, CIPRTRGFMT - Target format */
79#define S3C_CAMIF_REG_CITRGFMT(id, _offs) (0x48 + (id) * (0x34 + (_offs)))
80#define CITRGFMT_IN422 (1 << 31) /* only for s3c24xx */
81#define CITRGFMT_OUT422 (1 << 30) /* only for s3c24xx */
82#define CITRGFMT_OUTFORMAT_YCBCR420 (0 << 29) /* only for s3c6410 */
83#define CITRGFMT_OUTFORMAT_YCBCR422 (1 << 29) /* only for s3c6410 */
84#define CITRGFMT_OUTFORMAT_YCBCR422I (2 << 29) /* only for s3c6410 */
85#define CITRGFMT_OUTFORMAT_RGB (3 << 29) /* only for s3c6410 */
86#define CITRGFMT_OUTFORMAT_MASK (3 << 29) /* only for s3c6410 */
87#define CITRGFMT_TARGETHSIZE(x) ((x) << 16)
88#define CITRGFMT_FLIP_NORMAL (0 << 14)
89#define CITRGFMT_FLIP_X_MIRROR (1 << 14)
90#define CITRGFMT_FLIP_Y_MIRROR (2 << 14)
91#define CITRGFMT_FLIP_180 (3 << 14)
92#define CITRGFMT_FLIP_MASK (3 << 14)
93/* Preview path only */
94#define CITRGFMT_ROT90_PR (1 << 13)
95#define CITRGFMT_TARGETVSIZE(x) ((x) << 0)
96#define CITRGFMT_TARGETSIZE_MASK ((0x1fff << 16) | 0x1fff)
97
98/* CICOCTRL, CIPRCTRL. Output DMA control. */
99#define S3C_CAMIF_REG_CICTRL(id, _offs) (0x4c + (id) * (0x34 + (_offs)))
100#define CICTRL_BURST_MASK (0xfffff << 4)
101/* xBURSTn - 5-bits width */
102#define CICTRL_YBURST1(x) ((x) << 19)
103#define CICTRL_YBURST2(x) ((x) << 14)
104#define CICTRL_RGBBURST1(x) ((x) << 19)
105#define CICTRL_RGBBURST2(x) ((x) << 14)
106#define CICTRL_CBURST1(x) ((x) << 9)
107#define CICTRL_CBURST2(x) ((x) << 4)
108#define CICTRL_LASTIRQ_ENABLE (1 << 2)
109#define CICTRL_ORDER422_MASK (3 << 0)
110
111/* CICOSCPRERATIO, CIPRSCPRERATIO. Pre-scaler control 1. */
112#define S3C_CAMIF_REG_CISCPRERATIO(id, _offs) (0x50 + (id) * (0x34 + (_offs)))
113
114/* CICOSCPREDST, CIPRSCPREDST. Pre-scaler control 2. */
115#define S3C_CAMIF_REG_CISCPREDST(id, _offs) (0x54 + (id) * (0x34 + (_offs)))
116
117/* CICOSCCTRL, CIPRSCCTRL. Main scaler control. */
118#define S3C_CAMIF_REG_CISCCTRL(id, _offs) (0x58 + (id) * (0x34 + (_offs)))
119#define CISCCTRL_SCALERBYPASS (1 << 31)
120/* s3c244x preview path only, s3c64xx both */
121#define CIPRSCCTRL_SAMPLE (1 << 31)
122/* 0 - 16-bit RGB, 1 - 24-bit RGB */
123#define CIPRSCCTRL_RGB_FORMAT_24BIT (1 << 30) /* only for s3c244x */
124#define CIPRSCCTRL_SCALEUP_H (1 << 29) /* only for s3c244x */
125#define CIPRSCCTRL_SCALEUP_V (1 << 28) /* only for s3c244x */
126/* s3c64xx */
127#define CISCCTRL_SCALEUP_H (1 << 30)
128#define CISCCTRL_SCALEUP_V (1 << 29)
129#define CISCCTRL_SCALEUP_MASK (0x3 << 29)
130#define CISCCTRL_CSCR2Y_WIDE (1 << 28)
131#define CISCCTRL_CSCY2R_WIDE (1 << 27)
132#define CISCCTRL_LCDPATHEN_FIFO (1 << 26)
133#define CISCCTRL_INTERLACE (1 << 25)
134#define CISCCTRL_SCALERSTART (1 << 15)
135#define CISCCTRL_INRGB_FMT_RGB565 (0 << 13)
136#define CISCCTRL_INRGB_FMT_RGB666 (1 << 13)
137#define CISCCTRL_INRGB_FMT_RGB888 (2 << 13)
138#define CISCCTRL_INRGB_FMT_MASK (3 << 13)
139#define CISCCTRL_OUTRGB_FMT_RGB565 (0 << 11)
140#define CISCCTRL_OUTRGB_FMT_RGB666 (1 << 11)
141#define CISCCTRL_OUTRGB_FMT_RGB888 (2 << 11)
142#define CISCCTRL_OUTRGB_FMT_MASK (3 << 11)
143#define CISCCTRL_EXTRGB_EXTENSION (1 << 10)
144#define CISCCTRL_ONE2ONE (1 << 9)
145#define CISCCTRL_MAIN_RATIO_MASK (0x1ff << 16 | 0x1ff)
146
147/* CICOTAREA, CIPRTAREA. Target area for DMA (Hsize x Vsize). */
148#define S3C_CAMIF_REG_CITAREA(id, _offs) (0x5c + (id) * (0x34 + (_offs)))
149#define CITAREA_MASK 0xfffffff
150
151/* Codec (id = 0) or preview (id = 1) path status. */
152#define S3C_CAMIF_REG_CISTATUS(id, _offs) (0x64 + (id) * (0x34 + (_offs)))
153#define CISTATUS_OVFIY_STATUS (1 << 31)
154#define CISTATUS_OVFICB_STATUS (1 << 30)
155#define CISTATUS_OVFICR_STATUS (1 << 29)
156#define CISTATUS_OVF_MASK (0x7 << 29)
157#define CIPRSTATUS_OVF_MASK (0x3 << 30)
158#define CISTATUS_VSYNC_STATUS (1 << 28)
159#define CISTATUS_FRAMECNT_MASK (3 << 26)
160#define CISTATUS_FRAMECNT(__reg) (((__reg) >> 26) & 0x3)
161#define CISTATUS_WINOFSTEN_STATUS (1 << 25)
162#define CISTATUS_IMGCPTEN_STATUS (1 << 22)
163#define CISTATUS_IMGCPTENSC_STATUS (1 << 21)
164#define CISTATUS_VSYNC_A_STATUS (1 << 20)
165#define CISTATUS_FRAMEEND_STATUS (1 << 19) /* 17 on s3c64xx */
166
167/* Image capture enable */
168#define S3C_CAMIF_REG_CIIMGCPT(_offs) (0xa0 + (_offs))
169#define CIIMGCPT_IMGCPTEN (1 << 31)
170#define CIIMGCPT_IMGCPTEN_SC(id) (1 << (30 - (id)))
171/* Frame control: 1 - one-shot, 0 - free run */
172#define CIIMGCPT_CPT_FREN_ENABLE(id) (1 << (25 - (id)))
173#define CIIMGCPT_CPT_FRMOD_ENABLE (0 << 18)
174#define CIIMGCPT_CPT_FRMOD_CNT (1 << 18)
175
176/* Capture sequence */
177#define S3C_CAMIF_REG_CICPTSEQ 0xc4
178
179/* Image effects */
180#define S3C_CAMIF_REG_CIIMGEFF(_offs) (0xb0 + (_offs))
181#define CIIMGEFF_IE_ENABLE(id) (1 << (30 + (id)))
182#define CIIMGEFF_IE_ENABLE_MASK (3 << 30)
183/* Image effect: 1 - after scaler, 0 - before scaler */
184#define CIIMGEFF_IE_AFTER_SC (1 << 29)
185#define CIIMGEFF_FIN_MASK (7 << 26)
186#define CIIMGEFF_FIN_BYPASS (0 << 26)
187#define CIIMGEFF_FIN_ARBITRARY (1 << 26)
188#define CIIMGEFF_FIN_NEGATIVE (2 << 26)
189#define CIIMGEFF_FIN_ARTFREEZE (3 << 26)
190#define CIIMGEFF_FIN_EMBOSSING (4 << 26)
191#define CIIMGEFF_FIN_SILHOUETTE (5 << 26)
192#define CIIMGEFF_PAT_CBCR_MASK ((0xff << 13) | 0xff)
193#define CIIMGEFF_PAT_CB(x) ((x) << 13)
194#define CIIMGEFF_PAT_CR(x) (x)
195
196/* MSCOY0SA, MSPRY0SA. Y/Cb/Cr frame start address for input DMA. */
197#define S3C_CAMIF_REG_MSY0SA(id) (0xd4 + ((id) * 0x2c))
198#define S3C_CAMIF_REG_MSCB0SA(id) (0xd8 + ((id) * 0x2c))
199#define S3C_CAMIF_REG_MSCR0SA(id) (0xdc + ((id) * 0x2c))
200
201/* MSCOY0END, MSCOY0END. Y/Cb/Cr frame end address for input DMA. */
202#define S3C_CAMIF_REG_MSY0END(id) (0xe0 + ((id) * 0x2c))
203#define S3C_CAMIF_REG_MSCB0END(id) (0xe4 + ((id) * 0x2c))
204#define S3C_CAMIF_REG_MSCR0END(id) (0xe8 + ((id) * 0x2c))
205
206/* MSPRYOFF, MSPRYOFF. Y/Cb/Cr offset. n: 0 - codec, 1 - preview. */
207#define S3C_CAMIF_REG_MSYOFF(id) (0x118 + ((id) * 0x2c))
208#define S3C_CAMIF_REG_MSCBOFF(id) (0x11c + ((id) * 0x2c))
209#define S3C_CAMIF_REG_MSCROFF(id) (0x120 + ((id) * 0x2c))
210
211/* Real input DMA data size. n = 0 - codec, 1 - preview. */
212#define S3C_CAMIF_REG_MSWIDTH(id) (0xf8 + (id) * 0x2c)
213#define AUTOLOAD_ENABLE (1 << 31)
214#define ADDR_CH_DIS (1 << 30)
215#define MSHEIGHT(x) (((x) & 0x3ff) << 16)
216#define MSWIDTH(x) ((x) & 0x3ff)
217
218/* Input DMA control. n = 0 - codec, 1 - preview */
219#define S3C_CAMIF_REG_MSCTRL(id) (0xfc + (id) * 0x2c)
220#define MSCTRL_ORDER422_M_YCBYCR (0 << 4)
221#define MSCTRL_ORDER422_M_YCRYCB (1 << 4)
222#define MSCTRL_ORDER422_M_CBYCRY (2 << 4)
223#define MSCTRL_ORDER422_M_CRYCBY (3 << 4)
224/* 0 - camera, 1 - DMA */
225#define MSCTRL_SEL_DMA_CAM (1 << 3)
226#define MSCTRL_INFORMAT_M_YCBCR420 (0 << 1)
227#define MSCTRL_INFORMAT_M_YCBCR422 (1 << 1)
228#define MSCTRL_INFORMAT_M_YCBCR422I (2 << 1)
229#define MSCTRL_INFORMAT_M_RGB (3 << 1)
230#define MSCTRL_ENVID_M (1 << 0)
231
232/* CICOSCOSY, CIPRSCOSY. Scan line Y/Cb/Cr offset. */
233#define S3C_CAMIF_REG_CISSY(id) (0x12c + (id) * 0x0c)
234#define S3C_CAMIF_REG_CISSCB(id) (0x130 + (id) * 0x0c)
235#define S3C_CAMIF_REG_CISSCR(id) (0x134 + (id) * 0x0c)
236#define S3C_CISS_OFFS_INITIAL(x) ((x) << 16)
237#define S3C_CISS_OFFS_LINE(x) ((x) << 0)
238
239/* ------------------------------------------------------------------ */
240
241void camif_hw_reset(struct camif_dev *camif);
242void camif_hw_clear_pending_irq(struct camif_vp *vp);
243void camif_hw_clear_fifo_overflow(struct camif_vp *vp);
244void camif_hw_set_lastirq(struct camif_vp *vp, int enable);
245void camif_hw_set_input_path(struct camif_vp *vp);
246void camif_hw_enable_scaler(struct camif_vp *vp, bool on);
247void camif_hw_enable_capture(struct camif_vp *vp);
248void camif_hw_disable_capture(struct camif_vp *vp);
249void camif_hw_set_camera_bus(struct camif_dev *camif);
250void camif_hw_set_source_format(struct camif_dev *camif);
251void camif_hw_set_camera_crop(struct camif_dev *camif);
252void camif_hw_set_scaler(struct camif_vp *vp);
253void camif_hw_set_flip(struct camif_vp *vp);
254void camif_hw_set_output_dma(struct camif_vp *vp);
255void camif_hw_set_target_format(struct camif_vp *vp);
256void camif_hw_set_test_pattern(struct camif_dev *camif, unsigned int pattern);
257void camif_hw_set_effect(struct camif_dev *camif, unsigned int effect,
258 unsigned int cr, unsigned int cb);
259void camif_hw_set_output_addr(struct camif_vp *vp, struct camif_addr *paddr,
260 int index);
261void camif_hw_dump_regs(struct camif_dev *camif, const char *label);
262
263static inline u32 camif_hw_get_status(struct camif_vp *vp)
264{
265 return readl(vp->camif->io_base + S3C_CAMIF_REG_CISTATUS(vp->id,
266 vp->offset));
267}
268
269#endif /* CAMIF_REGS_H_ */
diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c b/drivers/media/platform/s5p-fimc/fimc-capture.c
index 891ee873c62b..fdb6740248a7 100644
--- a/drivers/media/platform/s5p-fimc/fimc-capture.c
+++ b/drivers/media/platform/s5p-fimc/fimc-capture.c
@@ -1230,6 +1230,14 @@ static int fimc_cap_qbuf(struct file *file, void *priv,
1230 return vb2_qbuf(&fimc->vid_cap.vbq, buf); 1230 return vb2_qbuf(&fimc->vid_cap.vbq, buf);
1231} 1231}
1232 1232
1233static int fimc_cap_expbuf(struct file *file, void *priv,
1234 struct v4l2_exportbuffer *eb)
1235{
1236 struct fimc_dev *fimc = video_drvdata(file);
1237
1238 return vb2_expbuf(&fimc->vid_cap.vbq, eb);
1239}
1240
1233static int fimc_cap_dqbuf(struct file *file, void *priv, 1241static int fimc_cap_dqbuf(struct file *file, void *priv,
1234 struct v4l2_buffer *buf) 1242 struct v4l2_buffer *buf)
1235{ 1243{
@@ -1354,6 +1362,7 @@ static const struct v4l2_ioctl_ops fimc_capture_ioctl_ops = {
1354 1362
1355 .vidioc_qbuf = fimc_cap_qbuf, 1363 .vidioc_qbuf = fimc_cap_qbuf,
1356 .vidioc_dqbuf = fimc_cap_dqbuf, 1364 .vidioc_dqbuf = fimc_cap_dqbuf,
1365 .vidioc_expbuf = fimc_cap_expbuf,
1357 1366
1358 .vidioc_prepare_buf = fimc_cap_prepare_buf, 1367 .vidioc_prepare_buf = fimc_cap_prepare_buf,
1359 .vidioc_create_bufs = fimc_cap_create_bufs, 1368 .vidioc_create_bufs = fimc_cap_create_bufs,
@@ -1729,7 +1738,7 @@ static int fimc_register_capture_device(struct fimc_dev *fimc,
1729 q = &fimc->vid_cap.vbq; 1738 q = &fimc->vid_cap.vbq;
1730 memset(q, 0, sizeof(*q)); 1739 memset(q, 0, sizeof(*q));
1731 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; 1740 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
1732 q->io_modes = VB2_MMAP | VB2_USERPTR; 1741 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
1733 q->drv_priv = fimc->vid_cap.ctx; 1742 q->drv_priv = fimc->vid_cap.ctx;
1734 q->ops = &fimc_capture_qops; 1743 q->ops = &fimc_capture_qops;
1735 q->mem_ops = &vb2_dma_contig_memops; 1744 q->mem_ops = &vb2_dma_contig_memops;
diff --git a/drivers/media/platform/s5p-fimc/fimc-m2m.c b/drivers/media/platform/s5p-fimc/fimc-m2m.c
index 62afed3162ea..1d21da4bd24b 100644
--- a/drivers/media/platform/s5p-fimc/fimc-m2m.c
+++ b/drivers/media/platform/s5p-fimc/fimc-m2m.c
@@ -105,7 +105,7 @@ static void fimc_device_run(void *priv)
105 struct fimc_frame *sf, *df; 105 struct fimc_frame *sf, *df;
106 struct fimc_dev *fimc; 106 struct fimc_dev *fimc;
107 unsigned long flags; 107 unsigned long flags;
108 u32 ret; 108 int ret;
109 109
110 if (WARN(!ctx, "Null context\n")) 110 if (WARN(!ctx, "Null context\n"))
111 return; 111 return;
@@ -439,6 +439,15 @@ static int fimc_m2m_dqbuf(struct file *file, void *fh,
439 return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf); 439 return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
440} 440}
441 441
442static int fimc_m2m_expbuf(struct file *file, void *fh,
443 struct v4l2_exportbuffer *eb)
444{
445 struct fimc_ctx *ctx = fh_to_ctx(fh);
446
447 return v4l2_m2m_expbuf(file, ctx->m2m_ctx, eb);
448}
449
450
442static int fimc_m2m_streamon(struct file *file, void *fh, 451static int fimc_m2m_streamon(struct file *file, void *fh,
443 enum v4l2_buf_type type) 452 enum v4l2_buf_type type)
444{ 453{
@@ -607,6 +616,7 @@ static const struct v4l2_ioctl_ops fimc_m2m_ioctl_ops = {
607 .vidioc_querybuf = fimc_m2m_querybuf, 616 .vidioc_querybuf = fimc_m2m_querybuf,
608 .vidioc_qbuf = fimc_m2m_qbuf, 617 .vidioc_qbuf = fimc_m2m_qbuf,
609 .vidioc_dqbuf = fimc_m2m_dqbuf, 618 .vidioc_dqbuf = fimc_m2m_dqbuf,
619 .vidioc_expbuf = fimc_m2m_expbuf,
610 .vidioc_streamon = fimc_m2m_streamon, 620 .vidioc_streamon = fimc_m2m_streamon,
611 .vidioc_streamoff = fimc_m2m_streamoff, 621 .vidioc_streamoff = fimc_m2m_streamoff,
612 .vidioc_g_crop = fimc_m2m_g_crop, 622 .vidioc_g_crop = fimc_m2m_g_crop,
@@ -622,7 +632,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
622 int ret; 632 int ret;
623 633
624 src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; 634 src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
625 src_vq->io_modes = VB2_MMAP | VB2_USERPTR; 635 src_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
626 src_vq->drv_priv = ctx; 636 src_vq->drv_priv = ctx;
627 src_vq->ops = &fimc_qops; 637 src_vq->ops = &fimc_qops;
628 src_vq->mem_ops = &vb2_dma_contig_memops; 638 src_vq->mem_ops = &vb2_dma_contig_memops;
@@ -633,7 +643,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
633 return ret; 643 return ret;
634 644
635 dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; 645 dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
636 dst_vq->io_modes = VB2_MMAP | VB2_USERPTR; 646 dst_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
637 dst_vq->drv_priv = ctx; 647 dst_vq->drv_priv = ctx;
638 dst_vq->ops = &fimc_qops; 648 dst_vq->ops = &fimc_qops;
639 dst_vq->mem_ops = &vb2_dma_contig_memops; 649 dst_vq->mem_ops = &vb2_dma_contig_memops;
diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index 0531ab70a94c..1bd5678cfeb9 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -213,7 +213,7 @@ static int fimc_pipeline_close(struct fimc_pipeline *p)
213 * @pipeline: video pipeline structure 213 * @pipeline: video pipeline structure
214 * @on: passed as the s_stream call argument 214 * @on: passed as the s_stream call argument
215 */ 215 */
216int fimc_pipeline_s_stream(struct fimc_pipeline *p, bool on) 216static int fimc_pipeline_s_stream(struct fimc_pipeline *p, bool on)
217{ 217{
218 int i, ret; 218 int i, ret;
219 219
@@ -547,7 +547,7 @@ static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd,
547 if (ret) 547 if (ret)
548 break; 548 break;
549 549
550 v4l2_info(&fmd->v4l2_dev, "created link [%s] %c> [%s]", 550 v4l2_info(&fmd->v4l2_dev, "created link [%s] %c> [%s]\n",
551 source->name, flags ? '=' : '-', sink->name); 551 source->name, flags ? '=' : '-', sink->name);
552 552
553 if (flags == 0 || sensor == NULL) 553 if (flags == 0 || sensor == NULL)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index eb6a70b0f821..6dad9a74f61c 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -636,6 +636,19 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
636 return -EINVAL; 636 return -EINVAL;
637} 637}
638 638
639/* Export DMA buffer */
640static int vidioc_expbuf(struct file *file, void *priv,
641 struct v4l2_exportbuffer *eb)
642{
643 struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
644
645 if (eb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
646 return vb2_expbuf(&ctx->vq_src, eb);
647 if (eb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
648 return vb2_expbuf(&ctx->vq_dst, eb);
649 return -EINVAL;
650}
651
639/* Stream on */ 652/* Stream on */
640static int vidioc_streamon(struct file *file, void *priv, 653static int vidioc_streamon(struct file *file, void *priv,
641 enum v4l2_buf_type type) 654 enum v4l2_buf_type type)
@@ -813,6 +826,7 @@ static const struct v4l2_ioctl_ops s5p_mfc_dec_ioctl_ops = {
813 .vidioc_querybuf = vidioc_querybuf, 826 .vidioc_querybuf = vidioc_querybuf,
814 .vidioc_qbuf = vidioc_qbuf, 827 .vidioc_qbuf = vidioc_qbuf,
815 .vidioc_dqbuf = vidioc_dqbuf, 828 .vidioc_dqbuf = vidioc_dqbuf,
829 .vidioc_expbuf = vidioc_expbuf,
816 .vidioc_streamon = vidioc_streamon, 830 .vidioc_streamon = vidioc_streamon,
817 .vidioc_streamoff = vidioc_streamoff, 831 .vidioc_streamoff = vidioc_streamoff,
818 .vidioc_g_crop = vidioc_g_crop, 832 .vidioc_g_crop = vidioc_g_crop,
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 2af6d522f4ac..f92f6ddd739f 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -1165,6 +1165,19 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
1165 return ret; 1165 return ret;
1166} 1166}
1167 1167
1168/* Export DMA buffer */
1169static int vidioc_expbuf(struct file *file, void *priv,
1170 struct v4l2_exportbuffer *eb)
1171{
1172 struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
1173
1174 if (eb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
1175 return vb2_expbuf(&ctx->vq_src, eb);
1176 if (eb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
1177 return vb2_expbuf(&ctx->vq_dst, eb);
1178 return -EINVAL;
1179}
1180
1168/* Stream on */ 1181/* Stream on */
1169static int vidioc_streamon(struct file *file, void *priv, 1182static int vidioc_streamon(struct file *file, void *priv,
1170 enum v4l2_buf_type type) 1183 enum v4l2_buf_type type)
@@ -1542,7 +1555,7 @@ int vidioc_encoder_cmd(struct file *file, void *priv,
1542} 1555}
1543 1556
1544static int vidioc_subscribe_event(struct v4l2_fh *fh, 1557static int vidioc_subscribe_event(struct v4l2_fh *fh,
1545 struct v4l2_event_subscription *sub) 1558 const struct v4l2_event_subscription *sub)
1546{ 1559{
1547 switch (sub->type) { 1560 switch (sub->type) {
1548 case V4L2_EVENT_EOS: 1561 case V4L2_EVENT_EOS:
@@ -1568,6 +1581,7 @@ static const struct v4l2_ioctl_ops s5p_mfc_enc_ioctl_ops = {
1568 .vidioc_querybuf = vidioc_querybuf, 1581 .vidioc_querybuf = vidioc_querybuf,
1569 .vidioc_qbuf = vidioc_qbuf, 1582 .vidioc_qbuf = vidioc_qbuf,
1570 .vidioc_dqbuf = vidioc_dqbuf, 1583 .vidioc_dqbuf = vidioc_dqbuf,
1584 .vidioc_expbuf = vidioc_expbuf,
1571 .vidioc_streamon = vidioc_streamon, 1585 .vidioc_streamon = vidioc_streamon,
1572 .vidioc_streamoff = vidioc_streamoff, 1586 .vidioc_streamoff = vidioc_streamoff,
1573 .vidioc_s_parm = vidioc_s_parm, 1587 .vidioc_s_parm = vidioc_s_parm,
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
index 367db7552289..2895333866fc 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
@@ -28,7 +28,7 @@ static struct s5p_mfc_pm *pm;
28static struct s5p_mfc_dev *p_dev; 28static struct s5p_mfc_dev *p_dev;
29 29
30#ifdef CLK_DEBUG 30#ifdef CLK_DEBUG
31atomic_t clk_ref; 31static atomic_t clk_ref;
32#endif 32#endif
33 33
34int s5p_mfc_init_pm(struct s5p_mfc_dev *dev) 34int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
index 0c1cd895ff66..7379e77bf4e1 100644
--- a/drivers/media/platform/s5p-tv/mixer_video.c
+++ b/drivers/media/platform/s5p-tv/mixer_video.c
@@ -19,7 +19,6 @@
19#include <linux/videodev2.h> 19#include <linux/videodev2.h>
20#include <linux/mm.h> 20#include <linux/mm.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/version.h>
23#include <linux/timer.h> 22#include <linux/timer.h>
24#include <media/videobuf2-dma-contig.h> 23#include <media/videobuf2-dma-contig.h>
25 24
@@ -698,6 +697,15 @@ static int mxr_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p)
698 return vb2_dqbuf(&layer->vb_queue, p, file->f_flags & O_NONBLOCK); 697 return vb2_dqbuf(&layer->vb_queue, p, file->f_flags & O_NONBLOCK);
699} 698}
700 699
700static int mxr_expbuf(struct file *file, void *priv,
701 struct v4l2_exportbuffer *eb)
702{
703 struct mxr_layer *layer = video_drvdata(file);
704
705 mxr_dbg(layer->mdev, "%s:%d\n", __func__, __LINE__);
706 return vb2_expbuf(&layer->vb_queue, eb);
707}
708
701static int mxr_streamon(struct file *file, void *priv, enum v4l2_buf_type i) 709static int mxr_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
702{ 710{
703 struct mxr_layer *layer = video_drvdata(file); 711 struct mxr_layer *layer = video_drvdata(file);
@@ -725,6 +733,7 @@ static const struct v4l2_ioctl_ops mxr_ioctl_ops = {
725 .vidioc_querybuf = mxr_querybuf, 733 .vidioc_querybuf = mxr_querybuf,
726 .vidioc_qbuf = mxr_qbuf, 734 .vidioc_qbuf = mxr_qbuf,
727 .vidioc_dqbuf = mxr_dqbuf, 735 .vidioc_dqbuf = mxr_dqbuf,
736 .vidioc_expbuf = mxr_expbuf,
728 /* Streaming control */ 737 /* Streaming control */
729 .vidioc_streamon = mxr_streamon, 738 .vidioc_streamon = mxr_streamon,
730 .vidioc_streamoff = mxr_streamoff, 739 .vidioc_streamoff = mxr_streamoff,
@@ -1093,7 +1102,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
1093 1102
1094 layer->vb_queue = (struct vb2_queue) { 1103 layer->vb_queue = (struct vb2_queue) {
1095 .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, 1104 .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
1096 .io_modes = VB2_MMAP | VB2_USERPTR, 1105 .io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF,
1097 .drv_priv = layer, 1106 .drv_priv = layer,
1098 .buf_struct_size = sizeof(struct mxr_buffer), 1107 .buf_struct_size = sizeof(struct mxr_buffer),
1099 .ops = &mxr_video_qops, 1108 .ops = &mxr_video_qops,
diff --git a/drivers/media/platform/soc_camera/Kconfig b/drivers/media/platform/soc_camera/Kconfig
index 9afe1e7bde74..cb6791e62bd4 100644
--- a/drivers/media/platform/soc_camera/Kconfig
+++ b/drivers/media/platform/soc_camera/Kconfig
@@ -19,6 +19,7 @@ config MX1_VIDEO
19 19
20config VIDEO_MX1 20config VIDEO_MX1
21 tristate "i.MX1/i.MXL CMOS Sensor Interface driver" 21 tristate "i.MX1/i.MXL CMOS Sensor Interface driver"
22 depends on BROKEN
22 depends on VIDEO_DEV && ARCH_MX1 && SOC_CAMERA 23 depends on VIDEO_DEV && ARCH_MX1 && SOC_CAMERA
23 select FIQ 24 select FIQ
24 select VIDEOBUF_DMA_CONTIG 25 select VIDEOBUF_DMA_CONTIG
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index d3f0b84e2d70..4e3735679f17 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -645,11 +645,17 @@ static ssize_t soc_camera_read(struct file *file, char __user *buf,
645 size_t count, loff_t *ppos) 645 size_t count, loff_t *ppos)
646{ 646{
647 struct soc_camera_device *icd = file->private_data; 647 struct soc_camera_device *icd = file->private_data;
648 int err = -EINVAL; 648 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
649
650 dev_dbg(icd->pdev, "read called, buf %p\n", buf);
651
652 if (ici->ops->init_videobuf2 && icd->vb2_vidq.io_modes & VB2_READ)
653 return vb2_read(&icd->vb2_vidq, buf, count, ppos,
654 file->f_flags & O_NONBLOCK);
649 655
650 dev_err(icd->pdev, "camera device read not implemented\n"); 656 dev_err(icd->pdev, "camera device read not implemented\n");
651 657
652 return err; 658 return -EINVAL;
653} 659}
654 660
655static int soc_camera_mmap(struct file *file, struct vm_area_struct *vma) 661static int soc_camera_mmap(struct file *file, struct vm_area_struct *vma)
@@ -1048,10 +1054,8 @@ static void scan_add_host(struct soc_camera_host *ici)
1048 1054
1049 list_for_each_entry(icd, &devices, list) { 1055 list_for_each_entry(icd, &devices, list) {
1050 if (icd->iface == ici->nr) { 1056 if (icd->iface == ici->nr) {
1051 int ret;
1052
1053 icd->parent = ici->v4l2_dev.dev; 1057 icd->parent = ici->v4l2_dev.dev;
1054 ret = soc_camera_probe(icd); 1058 soc_camera_probe(icd);
1055 } 1059 }
1056 } 1060 }
1057 1061
diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
index b366b050a3dd..0d59b9db83cb 100644
--- a/drivers/media/platform/vivi.c
+++ b/drivers/media/platform/vivi.c
@@ -39,7 +39,6 @@
39/* Wake up at about 30 fps */ 39/* Wake up at about 30 fps */
40#define WAKE_NUMERATOR 30 40#define WAKE_NUMERATOR 30
41#define WAKE_DENOMINATOR 1001 41#define WAKE_DENOMINATOR 1001
42#define BUFFER_TIMEOUT msecs_to_jiffies(500) /* 0.5 seconds */
43 42
44#define MAX_WIDTH 1920 43#define MAX_WIDTH 1920
45#define MAX_HEIGHT 1200 44#define MAX_HEIGHT 1200
@@ -352,11 +351,6 @@ static void precalculate_bars(struct vivi_dev *dev)
352 } 351 }
353} 352}
354 353
355#define TSTAMP_MIN_Y 24
356#define TSTAMP_MAX_Y (TSTAMP_MIN_Y + 15)
357#define TSTAMP_INPUT_X 10
358#define TSTAMP_MIN_X (54 + TSTAMP_INPUT_X)
359
360/* 'odd' is true for pixels 1, 3, 5, etc. and false for pixels 0, 2, 4, etc. */ 354/* 'odd' is true for pixels 1, 3, 5, etc. and false for pixels 0, 2, 4, etc. */
361static void gen_twopix(struct vivi_dev *dev, u8 *buf, int colorpos, bool odd) 355static void gen_twopix(struct vivi_dev *dev, u8 *buf, int colorpos, bool odd)
362{ 356{
@@ -1308,7 +1302,7 @@ static int __init vivi_create_instance(int inst)
1308 /* initialize queue */ 1302 /* initialize queue */
1309 q = &dev->vb_vidq; 1303 q = &dev->vb_vidq;
1310 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1304 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1311 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ; 1305 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ;
1312 q->drv_priv = dev; 1306 q->drv_priv = dev;
1313 q->buf_struct_size = sizeof(struct vivi_buffer); 1307 q->buf_struct_size = sizeof(struct vivi_buffer);
1314 q->ops = &vivi_video_qops; 1308 q->ops = &vivi_video_qops;
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c
index 12c70e876f58..a739ad492e7b 100644
--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -82,7 +82,7 @@ static struct radio_isa_card *rtrack_alloc(void)
82#define AIMS_BIT_VOL_UP (1 << 6) /* active low */ 82#define AIMS_BIT_VOL_UP (1 << 6) /* active low */
83#define AIMS_BIT_VOL_DN (1 << 7) /* active low */ 83#define AIMS_BIT_VOL_DN (1 << 7) /* active low */
84 84
85void rtrack_set_pins(void *handle, u8 pins) 85static void rtrack_set_pins(void *handle, u8 pins)
86{ 86{
87 struct radio_isa_card *isa = handle; 87 struct radio_isa_card *isa = handle;
88 struct rtrack *rt = container_of(isa, struct rtrack, isa); 88 struct rtrack *rt = container_of(isa, struct rtrack, isa);
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
index 697a421c9940..643d80ac28fb 100644
--- a/drivers/media/radio/radio-cadet.c
+++ b/drivers/media/radio/radio-cadet.c
@@ -645,7 +645,8 @@ static int __init cadet_init(void)
645 set_bit(V4L2_FL_USE_FH_PRIO, &dev->vdev.flags); 645 set_bit(V4L2_FL_USE_FH_PRIO, &dev->vdev.flags);
646 video_set_drvdata(&dev->vdev, dev); 646 video_set_drvdata(&dev->vdev, dev);
647 647
648 if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0) 648 res = video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr);
649 if (res < 0)
649 goto err_hdl; 650 goto err_hdl;
650 v4l2_info(v4l2_dev, "ADS Cadet Radio Card at 0x%x\n", dev->io); 651 v4l2_info(v4l2_dev, "ADS Cadet Radio Card at 0x%x\n", dev->io);
651 return 0; 652 return 0;
diff --git a/drivers/media/radio/radio-isa.c b/drivers/media/radio/radio-isa.c
index 3c0067de4324..84b7b9f4385e 100644
--- a/drivers/media/radio/radio-isa.c
+++ b/drivers/media/radio/radio-isa.c
@@ -191,7 +191,7 @@ static bool radio_isa_valid_io(const struct radio_isa_driver *drv, int io)
191 return false; 191 return false;
192} 192}
193 193
194struct radio_isa_card *radio_isa_alloc(struct radio_isa_driver *drv, 194static struct radio_isa_card *radio_isa_alloc(struct radio_isa_driver *drv,
195 struct device *pdev) 195 struct device *pdev)
196{ 196{
197 struct v4l2_device *v4l2_dev; 197 struct v4l2_device *v4l2_dev;
@@ -207,8 +207,9 @@ struct radio_isa_card *radio_isa_alloc(struct radio_isa_driver *drv,
207 return isa; 207 return isa;
208} 208}
209 209
210int radio_isa_common_probe(struct radio_isa_card *isa, struct device *pdev, 210static int radio_isa_common_probe(struct radio_isa_card *isa,
211 int radio_nr, unsigned region_size) 211 struct device *pdev,
212 int radio_nr, unsigned region_size)
212{ 213{
213 const struct radio_isa_driver *drv = isa->drv; 214 const struct radio_isa_driver *drv = isa->drv;
214 const struct radio_isa_ops *ops = drv->ops; 215 const struct radio_isa_ops *ops = drv->ops;
@@ -287,7 +288,8 @@ err_dev_reg:
287 return res; 288 return res;
288} 289}
289 290
290int radio_isa_common_remove(struct radio_isa_card *isa, unsigned region_size) 291static int radio_isa_common_remove(struct radio_isa_card *isa,
292 unsigned region_size)
291{ 293{
292 const struct radio_isa_ops *ops = isa->drv->ops; 294 const struct radio_isa_ops *ops = isa->drv->ops;
293 295
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c
index 227dcdb54df3..c260a2a354b1 100644
--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -64,7 +64,7 @@ bool pnp_attached;
64#define FMI_BIT_VOL_SW (1 << 3) 64#define FMI_BIT_VOL_SW (1 << 3)
65#define FMI_BIT_TUN_STRQ (1 << 4) 65#define FMI_BIT_TUN_STRQ (1 << 4)
66 66
67void fmi_set_pins(void *handle, u8 pins) 67static void fmi_set_pins(void *handle, u8 pins)
68{ 68{
69 struct fmi *fmi = handle; 69 struct fmi *fmi = handle;
70 u8 bits = FMI_BIT_TUN_STRQ; 70 u8 bits = FMI_BIT_TUN_STRQ;
diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c
index d0c905310071..36aec575e0ec 100644
--- a/drivers/media/radio/radio-tea5764.c
+++ b/drivers/media/radio/radio-tea5764.c
@@ -145,7 +145,7 @@ struct tea5764_device {
145}; 145};
146 146
147/* I2C code related */ 147/* I2C code related */
148int tea5764_i2c_read(struct tea5764_device *radio) 148static int tea5764_i2c_read(struct tea5764_device *radio)
149{ 149{
150 int i; 150 int i;
151 u16 *p = (u16 *) &radio->regs; 151 u16 *p = (u16 *) &radio->regs;
@@ -165,7 +165,7 @@ int tea5764_i2c_read(struct tea5764_device *radio)
165 return 0; 165 return 0;
166} 166}
167 167
168int tea5764_i2c_write(struct tea5764_device *radio) 168static int tea5764_i2c_write(struct tea5764_device *radio)
169{ 169{
170 struct tea5764_write_regs wr; 170 struct tea5764_write_regs wr;
171 struct tea5764_regs *r = &radio->regs; 171 struct tea5764_regs *r = &radio->regs;
diff --git a/drivers/media/radio/si4713-i2c.c b/drivers/media/radio/si4713-i2c.c
index e3079c142c5f..bd61b3bd0ca3 100644
--- a/drivers/media/radio/si4713-i2c.c
+++ b/drivers/media/radio/si4713-i2c.c
@@ -1769,7 +1769,7 @@ exit:
1769} 1769}
1770 1770
1771/* si4713_ioctl - deal with private ioctls (only rnl for now) */ 1771/* si4713_ioctl - deal with private ioctls (only rnl for now) */
1772long si4713_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) 1772static long si4713_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
1773{ 1773{
1774 struct si4713_device *sdev = to_si4713_device(sd); 1774 struct si4713_device *sdev = to_si4713_device(sd);
1775 struct si4713_rnl *rnl = arg; 1775 struct si4713_rnl *rnl = arg;
diff --git a/drivers/media/radio/wl128x/fmdrv.h b/drivers/media/radio/wl128x/fmdrv.h
index d84ad9dad323..aac0f025f767 100644
--- a/drivers/media/radio/wl128x/fmdrv.h
+++ b/drivers/media/radio/wl128x/fmdrv.h
@@ -60,7 +60,7 @@
60#define fmdbg(format, ...) \ 60#define fmdbg(format, ...) \
61 printk(KERN_DEBUG "fmdrv: " format, ## __VA_ARGS__) 61 printk(KERN_DEBUG "fmdrv: " format, ## __VA_ARGS__)
62#else /* DEBUG */ 62#else /* DEBUG */
63#define fmdbg(format, ...) 63#define fmdbg(format, ...) do {} while(0)
64#endif 64#endif
65enum { 65enum {
66 FM_MODE_OFF, 66 FM_MODE_OFF,
diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
index bf867a6b5ea0..602ef7ac8c24 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -742,7 +742,7 @@ static void fm_irq_handle_rdsdata_getcmd_resp(struct fmdev *fmdev)
742 if ((meta_data & FM_RDS_STATUS_ERR_MASK) != 0) 742 if ((meta_data & FM_RDS_STATUS_ERR_MASK) != 0)
743 break; 743 break;
744 744
745 if (blk_idx < FM_RDS_BLK_IDX_A || blk_idx > FM_RDS_BLK_IDX_D) { 745 if (blk_idx > FM_RDS_BLK_IDX_D) {
746 fmdbg("Block sequence mismatch\n"); 746 fmdbg("Block sequence mismatch\n");
747 rds->last_blk_idx = -1; 747 rds->last_blk_idx = -1;
748 break; 748 break;
diff --git a/drivers/media/radio/wl128x/fmdrv_rx.c b/drivers/media/radio/wl128x/fmdrv_rx.c
index 3dd9fc097c47..ebf09a3927de 100644
--- a/drivers/media/radio/wl128x/fmdrv_rx.c
+++ b/drivers/media/radio/wl128x/fmdrv_rx.c
@@ -305,7 +305,7 @@ int fm_rx_set_volume(struct fmdev *fmdev, u16 vol_to_set)
305 if (fmdev->curr_fmmode != FM_MODE_RX) 305 if (fmdev->curr_fmmode != FM_MODE_RX)
306 return -EPERM; 306 return -EPERM;
307 307
308 if (vol_to_set < FM_RX_VOLUME_MIN || vol_to_set > FM_RX_VOLUME_MAX) { 308 if (vol_to_set > FM_RX_VOLUME_MAX) {
309 fmerr("Volume is not within(%d-%d) range\n", 309 fmerr("Volume is not within(%d-%d) range\n",
310 FM_RX_VOLUME_MIN, FM_RX_VOLUME_MAX); 310 FM_RX_VOLUME_MIN, FM_RX_VOLUME_MAX);
311 return -EINVAL; 311 return -EINVAL;
diff --git a/drivers/media/rc/ati_remote.c b/drivers/media/rc/ati_remote.c
index 49bb356ed14c..2d6fb26a0170 100644
--- a/drivers/media/rc/ati_remote.c
+++ b/drivers/media/rc/ati_remote.c
@@ -784,7 +784,7 @@ static void ati_remote_rc_init(struct ati_remote *ati_remote)
784 784
785 rdev->priv = ati_remote; 785 rdev->priv = ati_remote;
786 rdev->driver_type = RC_DRIVER_SCANCODE; 786 rdev->driver_type = RC_DRIVER_SCANCODE;
787 rdev->allowed_protos = RC_TYPE_OTHER; 787 rdev->allowed_protos = RC_BIT_OTHER;
788 rdev->driver_name = "ati_remote"; 788 rdev->driver_name = "ati_remote";
789 789
790 rdev->open = ati_remote_rc_open; 790 rdev->open = ati_remote_rc_open;
diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c
index d05ac15b5de4..22231dd4f62b 100644
--- a/drivers/media/rc/ene_ir.c
+++ b/drivers/media/rc/ene_ir.c
@@ -329,7 +329,7 @@ static int ene_rx_get_sample_reg(struct ene_device *dev)
329} 329}
330 330
331/* Sense current received carrier */ 331/* Sense current received carrier */
332void ene_rx_sense_carrier(struct ene_device *dev) 332static void ene_rx_sense_carrier(struct ene_device *dev)
333{ 333{
334 DEFINE_IR_RAW_EVENT(ev); 334 DEFINE_IR_RAW_EVENT(ev);
335 335
@@ -1003,7 +1003,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1003 dev = kzalloc(sizeof(struct ene_device), GFP_KERNEL); 1003 dev = kzalloc(sizeof(struct ene_device), GFP_KERNEL);
1004 rdev = rc_allocate_device(); 1004 rdev = rc_allocate_device();
1005 if (!dev || !rdev) 1005 if (!dev || !rdev)
1006 goto error1; 1006 goto failure;
1007 1007
1008 /* validate resources */ 1008 /* validate resources */
1009 error = -ENODEV; 1009 error = -ENODEV;
@@ -1014,10 +1014,10 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1014 1014
1015 if (!pnp_port_valid(pnp_dev, 0) || 1015 if (!pnp_port_valid(pnp_dev, 0) ||
1016 pnp_port_len(pnp_dev, 0) < ENE_IO_SIZE) 1016 pnp_port_len(pnp_dev, 0) < ENE_IO_SIZE)
1017 goto error; 1017 goto failure;
1018 1018
1019 if (!pnp_irq_valid(pnp_dev, 0)) 1019 if (!pnp_irq_valid(pnp_dev, 0))
1020 goto error; 1020 goto failure;
1021 1021
1022 spin_lock_init(&dev->hw_lock); 1022 spin_lock_init(&dev->hw_lock);
1023 1023
@@ -1033,7 +1033,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1033 /* detect hardware version and features */ 1033 /* detect hardware version and features */
1034 error = ene_hw_detect(dev); 1034 error = ene_hw_detect(dev);
1035 if (error) 1035 if (error)
1036 goto error; 1036 goto failure;
1037 1037
1038 if (!dev->hw_learning_and_tx_capable && txsim) { 1038 if (!dev->hw_learning_and_tx_capable && txsim) {
1039 dev->hw_learning_and_tx_capable = true; 1039 dev->hw_learning_and_tx_capable = true;
@@ -1046,7 +1046,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1046 learning_mode_force = false; 1046 learning_mode_force = false;
1047 1047
1048 rdev->driver_type = RC_DRIVER_IR_RAW; 1048 rdev->driver_type = RC_DRIVER_IR_RAW;
1049 rdev->allowed_protos = RC_TYPE_ALL; 1049 rdev->allowed_protos = RC_BIT_ALL;
1050 rdev->priv = dev; 1050 rdev->priv = dev;
1051 rdev->open = ene_open; 1051 rdev->open = ene_open;
1052 rdev->close = ene_close; 1052 rdev->close = ene_close;
@@ -1078,30 +1078,27 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1078 /* claim the resources */ 1078 /* claim the resources */
1079 error = -EBUSY; 1079 error = -EBUSY;
1080 if (!request_region(dev->hw_io, ENE_IO_SIZE, ENE_DRIVER_NAME)) { 1080 if (!request_region(dev->hw_io, ENE_IO_SIZE, ENE_DRIVER_NAME)) {
1081 dev->hw_io = -1; 1081 goto failure;
1082 dev->irq = -1;
1083 goto error;
1084 } 1082 }
1085 1083
1086 dev->irq = pnp_irq(pnp_dev, 0); 1084 dev->irq = pnp_irq(pnp_dev, 0);
1087 if (request_irq(dev->irq, ene_isr, 1085 if (request_irq(dev->irq, ene_isr,
1088 IRQF_SHARED, ENE_DRIVER_NAME, (void *)dev)) { 1086 IRQF_SHARED, ENE_DRIVER_NAME, (void *)dev)) {
1089 dev->irq = -1; 1087 goto failure2;
1090 goto error;
1091 } 1088 }
1092 1089
1093 error = rc_register_device(rdev); 1090 error = rc_register_device(rdev);
1094 if (error < 0) 1091 if (error < 0)
1095 goto error; 1092 goto failure3;
1096 1093
1097 pr_notice("driver has been successfully loaded\n"); 1094 pr_notice("driver has been successfully loaded\n");
1098 return 0; 1095 return 0;
1099error: 1096
1100 if (dev && dev->irq >= 0) 1097failure3:
1101 free_irq(dev->irq, dev); 1098 free_irq(dev->irq, dev);
1102 if (dev && dev->hw_io >= 0) 1099failure2:
1103 release_region(dev->hw_io, ENE_IO_SIZE); 1100 release_region(dev->hw_io, ENE_IO_SIZE);
1104error1: 1101failure:
1105 rc_free_device(rdev); 1102 rc_free_device(rdev);
1106 kfree(dev); 1103 kfree(dev);
1107 return error; 1104 return error;
diff --git a/drivers/media/rc/fintek-cir.c b/drivers/media/rc/fintek-cir.c
index 52fd7696b1ba..936c3f79b62c 100644
--- a/drivers/media/rc/fintek-cir.c
+++ b/drivers/media/rc/fintek-cir.c
@@ -541,7 +541,7 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id
541 /* Set up the rc device */ 541 /* Set up the rc device */
542 rdev->priv = fintek; 542 rdev->priv = fintek;
543 rdev->driver_type = RC_DRIVER_IR_RAW; 543 rdev->driver_type = RC_DRIVER_IR_RAW;
544 rdev->allowed_protos = RC_TYPE_ALL; 544 rdev->allowed_protos = RC_BIT_ALL;
545 rdev->open = fintek_open; 545 rdev->open = fintek_open;
546 rdev->close = fintek_close; 546 rdev->close = fintek_close;
547 rdev->input_name = FINTEK_DESCRIPTION; 547 rdev->input_name = FINTEK_DESCRIPTION;
@@ -684,12 +684,12 @@ static struct pnp_driver fintek_driver = {
684 .shutdown = fintek_shutdown, 684 .shutdown = fintek_shutdown,
685}; 685};
686 686
687int fintek_init(void) 687static int fintek_init(void)
688{ 688{
689 return pnp_register_driver(&fintek_driver); 689 return pnp_register_driver(&fintek_driver);
690} 690}
691 691
692void fintek_exit(void) 692static void fintek_exit(void)
693{ 693{
694 pnp_unregister_driver(&fintek_driver); 694 pnp_unregister_driver(&fintek_driver);
695} 695}
diff --git a/drivers/media/rc/gpio-ir-recv.c b/drivers/media/rc/gpio-ir-recv.c
index 04cb272db16a..ba1a1eb356cf 100644
--- a/drivers/media/rc/gpio-ir-recv.c
+++ b/drivers/media/rc/gpio-ir-recv.c
@@ -95,7 +95,7 @@ static int __devinit gpio_ir_recv_probe(struct platform_device *pdev)
95 if (pdata->allowed_protos) 95 if (pdata->allowed_protos)
96 rcdev->allowed_protos = pdata->allowed_protos; 96 rcdev->allowed_protos = pdata->allowed_protos;
97 else 97 else
98 rcdev->allowed_protos = RC_TYPE_ALL; 98 rcdev->allowed_protos = RC_BIT_ALL;
99 rcdev->map_name = pdata->map_name ?: RC_MAP_EMPTY; 99 rcdev->map_name = pdata->map_name ?: RC_MAP_EMPTY;
100 100
101 gpio_dev->rcdev = rcdev; 101 gpio_dev->rcdev = rcdev;
diff --git a/drivers/media/rc/iguanair.c b/drivers/media/rc/iguanair.c
index 51d7057aca04..5a9163da63c3 100644
--- a/drivers/media/rc/iguanair.c
+++ b/drivers/media/rc/iguanair.c
@@ -499,7 +499,7 @@ static int __devinit iguanair_probe(struct usb_interface *intf,
499 usb_to_input_id(ir->udev, &rc->input_id); 499 usb_to_input_id(ir->udev, &rc->input_id);
500 rc->dev.parent = &intf->dev; 500 rc->dev.parent = &intf->dev;
501 rc->driver_type = RC_DRIVER_IR_RAW; 501 rc->driver_type = RC_DRIVER_IR_RAW;
502 rc->allowed_protos = RC_TYPE_ALL; 502 rc->allowed_protos = RC_BIT_ALL;
503 rc->priv = ir; 503 rc->priv = ir;
504 rc->open = iguanair_open; 504 rc->open = iguanair_open;
505 rc->close = iguanair_close; 505 rc->close = iguanair_close;
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 5dd0386604f0..8f6a28921ed4 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -1001,7 +1001,7 @@ static void imon_touch_display_timeout(unsigned long data)
1001 * it is not, so we must acquire it prior to calling send_packet, which 1001 * it is not, so we must acquire it prior to calling send_packet, which
1002 * requires that the lock is held. 1002 * requires that the lock is held.
1003 */ 1003 */
1004static int imon_ir_change_protocol(struct rc_dev *rc, u64 rc_type) 1004static int imon_ir_change_protocol(struct rc_dev *rc, u64 *rc_type)
1005{ 1005{
1006 int retval; 1006 int retval;
1007 struct imon_context *ictx = rc->priv; 1007 struct imon_context *ictx = rc->priv;
@@ -1010,31 +1010,27 @@ static int imon_ir_change_protocol(struct rc_dev *rc, u64 rc_type)
1010 unsigned char ir_proto_packet[] = { 1010 unsigned char ir_proto_packet[] = {
1011 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 }; 1011 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 };
1012 1012
1013 if (rc_type && !(rc_type & rc->allowed_protos)) 1013 if (*rc_type && !(*rc_type & rc->allowed_protos))
1014 dev_warn(dev, "Looks like you're trying to use an IR protocol " 1014 dev_warn(dev, "Looks like you're trying to use an IR protocol "
1015 "this device does not support\n"); 1015 "this device does not support\n");
1016 1016
1017 switch (rc_type) { 1017 if (*rc_type & RC_BIT_RC6_MCE) {
1018 case RC_TYPE_RC6:
1019 dev_dbg(dev, "Configuring IR receiver for MCE protocol\n"); 1018 dev_dbg(dev, "Configuring IR receiver for MCE protocol\n");
1020 ir_proto_packet[0] = 0x01; 1019 ir_proto_packet[0] = 0x01;
1021 break; 1020 *rc_type = RC_BIT_RC6_MCE;
1022 case RC_TYPE_UNKNOWN: 1021 } else if (*rc_type & RC_BIT_OTHER) {
1023 case RC_TYPE_OTHER:
1024 dev_dbg(dev, "Configuring IR receiver for iMON protocol\n"); 1022 dev_dbg(dev, "Configuring IR receiver for iMON protocol\n");
1025 if (!pad_stabilize) 1023 if (!pad_stabilize)
1026 dev_dbg(dev, "PAD stabilize functionality disabled\n"); 1024 dev_dbg(dev, "PAD stabilize functionality disabled\n");
1027 /* ir_proto_packet[0] = 0x00; // already the default */ 1025 /* ir_proto_packet[0] = 0x00; // already the default */
1028 rc_type = RC_TYPE_OTHER; 1026 *rc_type = RC_BIT_OTHER;
1029 break; 1027 } else {
1030 default:
1031 dev_warn(dev, "Unsupported IR protocol specified, overriding " 1028 dev_warn(dev, "Unsupported IR protocol specified, overriding "
1032 "to iMON IR protocol\n"); 1029 "to iMON IR protocol\n");
1033 if (!pad_stabilize) 1030 if (!pad_stabilize)
1034 dev_dbg(dev, "PAD stabilize functionality disabled\n"); 1031 dev_dbg(dev, "PAD stabilize functionality disabled\n");
1035 /* ir_proto_packet[0] = 0x00; // already the default */ 1032 /* ir_proto_packet[0] = 0x00; // already the default */
1036 rc_type = RC_TYPE_OTHER; 1033 *rc_type = RC_BIT_OTHER;
1037 break;
1038 } 1034 }
1039 1035
1040 memcpy(ictx->usb_tx_buf, &ir_proto_packet, sizeof(ir_proto_packet)); 1036 memcpy(ictx->usb_tx_buf, &ir_proto_packet, sizeof(ir_proto_packet));
@@ -1048,7 +1044,7 @@ static int imon_ir_change_protocol(struct rc_dev *rc, u64 rc_type)
1048 if (retval) 1044 if (retval)
1049 goto out; 1045 goto out;
1050 1046
1051 ictx->rc_type = rc_type; 1047 ictx->rc_type = *rc_type;
1052 ictx->pad_mouse = false; 1048 ictx->pad_mouse = false;
1053 1049
1054out: 1050out:
@@ -1323,7 +1319,7 @@ static void imon_pad_to_keys(struct imon_context *ictx, unsigned char *buf)
1323 rel_x = buf[2]; 1319 rel_x = buf[2];
1324 rel_y = buf[3]; 1320 rel_y = buf[3];
1325 1321
1326 if (ictx->rc_type == RC_TYPE_OTHER && pad_stabilize) { 1322 if (ictx->rc_type == RC_BIT_OTHER && pad_stabilize) {
1327 if ((buf[1] == 0) && ((rel_x != 0) || (rel_y != 0))) { 1323 if ((buf[1] == 0) && ((rel_x != 0) || (rel_y != 0))) {
1328 dir = stabilize((int)rel_x, (int)rel_y, 1324 dir = stabilize((int)rel_x, (int)rel_y,
1329 timeout, threshold); 1325 timeout, threshold);
@@ -1390,7 +1386,7 @@ static void imon_pad_to_keys(struct imon_context *ictx, unsigned char *buf)
1390 buf[0] = 0x01; 1386 buf[0] = 0x01;
1391 buf[1] = buf[4] = buf[5] = buf[6] = buf[7] = 0; 1387 buf[1] = buf[4] = buf[5] = buf[6] = buf[7] = 0;
1392 1388
1393 if (ictx->rc_type == RC_TYPE_OTHER && pad_stabilize) { 1389 if (ictx->rc_type == RC_BIT_OTHER && pad_stabilize) {
1394 dir = stabilize((int)rel_x, (int)rel_y, 1390 dir = stabilize((int)rel_x, (int)rel_y,
1395 timeout, threshold); 1391 timeout, threshold);
1396 if (!dir) { 1392 if (!dir) {
@@ -1511,7 +1507,7 @@ static void imon_incoming_packet(struct imon_context *ictx,
1511 kc = imon_panel_key_lookup(scancode); 1507 kc = imon_panel_key_lookup(scancode);
1512 } else { 1508 } else {
1513 scancode = be32_to_cpu(*((u32 *)buf)); 1509 scancode = be32_to_cpu(*((u32 *)buf));
1514 if (ictx->rc_type == RC_TYPE_RC6) { 1510 if (ictx->rc_type == RC_BIT_RC6_MCE) {
1515 ktype = IMON_KEY_IMON; 1511 ktype = IMON_KEY_IMON;
1516 if (buf[0] == 0x80) 1512 if (buf[0] == 0x80)
1517 ktype = IMON_KEY_MCE; 1513 ktype = IMON_KEY_MCE;
@@ -1744,7 +1740,7 @@ static void imon_get_ffdc_type(struct imon_context *ictx)
1744{ 1740{
1745 u8 ffdc_cfg_byte = ictx->usb_rx_buf[6]; 1741 u8 ffdc_cfg_byte = ictx->usb_rx_buf[6];
1746 u8 detected_display_type = IMON_DISPLAY_TYPE_NONE; 1742 u8 detected_display_type = IMON_DISPLAY_TYPE_NONE;
1747 u64 allowed_protos = RC_TYPE_OTHER; 1743 u64 allowed_protos = RC_BIT_OTHER;
1748 1744
1749 switch (ffdc_cfg_byte) { 1745 switch (ffdc_cfg_byte) {
1750 /* iMON Knob, no display, iMON IR + vol knob */ 1746 /* iMON Knob, no display, iMON IR + vol knob */
@@ -1775,13 +1771,13 @@ static void imon_get_ffdc_type(struct imon_context *ictx)
1775 case 0x9e: 1771 case 0x9e:
1776 dev_info(ictx->dev, "0xffdc iMON VFD, MCE IR"); 1772 dev_info(ictx->dev, "0xffdc iMON VFD, MCE IR");
1777 detected_display_type = IMON_DISPLAY_TYPE_VFD; 1773 detected_display_type = IMON_DISPLAY_TYPE_VFD;
1778 allowed_protos = RC_TYPE_RC6; 1774 allowed_protos = RC_BIT_RC6_MCE;
1779 break; 1775 break;
1780 /* iMON LCD, MCE IR */ 1776 /* iMON LCD, MCE IR */
1781 case 0x9f: 1777 case 0x9f:
1782 dev_info(ictx->dev, "0xffdc iMON LCD, MCE IR"); 1778 dev_info(ictx->dev, "0xffdc iMON LCD, MCE IR");
1783 detected_display_type = IMON_DISPLAY_TYPE_LCD; 1779 detected_display_type = IMON_DISPLAY_TYPE_LCD;
1784 allowed_protos = RC_TYPE_RC6; 1780 allowed_protos = RC_BIT_RC6_MCE;
1785 break; 1781 break;
1786 default: 1782 default:
1787 dev_info(ictx->dev, "Unknown 0xffdc device, " 1783 dev_info(ictx->dev, "Unknown 0xffdc device, "
@@ -1789,7 +1785,7 @@ static void imon_get_ffdc_type(struct imon_context *ictx)
1789 detected_display_type = IMON_DISPLAY_TYPE_VFD; 1785 detected_display_type = IMON_DISPLAY_TYPE_VFD;
1790 /* We don't know which one it is, allow user to set the 1786 /* We don't know which one it is, allow user to set the
1791 * RC6 one from userspace if OTHER wasn't correct. */ 1787 * RC6 one from userspace if OTHER wasn't correct. */
1792 allowed_protos |= RC_TYPE_RC6; 1788 allowed_protos |= RC_BIT_RC6_MCE;
1793 break; 1789 break;
1794 } 1790 }
1795 1791
@@ -1875,7 +1871,7 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
1875 1871
1876 rdev->priv = ictx; 1872 rdev->priv = ictx;
1877 rdev->driver_type = RC_DRIVER_SCANCODE; 1873 rdev->driver_type = RC_DRIVER_SCANCODE;
1878 rdev->allowed_protos = RC_TYPE_OTHER | RC_TYPE_RC6; /* iMON PAD or MCE */ 1874 rdev->allowed_protos = RC_BIT_OTHER | RC_BIT_RC6_MCE; /* iMON PAD or MCE */
1879 rdev->change_protocol = imon_ir_change_protocol; 1875 rdev->change_protocol = imon_ir_change_protocol;
1880 rdev->driver_name = MOD_NAME; 1876 rdev->driver_name = MOD_NAME;
1881 1877
@@ -1893,7 +1889,7 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
1893 1889
1894 imon_set_display_type(ictx); 1890 imon_set_display_type(ictx);
1895 1891
1896 if (ictx->rc_type == RC_TYPE_RC6) 1892 if (ictx->rc_type == RC_BIT_RC6_MCE)
1897 rdev->map_name = RC_MAP_IMON_MCE; 1893 rdev->map_name = RC_MAP_IMON_MCE;
1898 else 1894 else
1899 rdev->map_name = RC_MAP_IMON_PAD; 1895 rdev->map_name = RC_MAP_IMON_PAD;
diff --git a/drivers/media/rc/ir-jvc-decoder.c b/drivers/media/rc/ir-jvc-decoder.c
index 035668e27f6b..69edffb9fe9a 100644
--- a/drivers/media/rc/ir-jvc-decoder.c
+++ b/drivers/media/rc/ir-jvc-decoder.c
@@ -47,7 +47,7 @@ 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->raw->enabled_protocols & RC_TYPE_JVC)) 50 if (!(dev->raw->enabled_protocols & RC_BIT_JVC))
51 return 0; 51 return 0;
52 52
53 if (!is_timing_event(ev)) { 53 if (!is_timing_event(ev)) {
@@ -174,7 +174,7 @@ out:
174} 174}
175 175
176static struct ir_raw_handler jvc_handler = { 176static struct ir_raw_handler jvc_handler = {
177 .protocols = RC_TYPE_JVC, 177 .protocols = RC_BIT_JVC,
178 .decode = ir_jvc_decode, 178 .decode = ir_jvc_decode,
179}; 179};
180 180
diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c
index 870c93052fd0..9945e5e7f61a 100644
--- a/drivers/media/rc/ir-lirc-codec.c
+++ b/drivers/media/rc/ir-lirc-codec.c
@@ -35,7 +35,7 @@ static int ir_lirc_decode(struct rc_dev *dev, struct ir_raw_event ev)
35 struct lirc_codec *lirc = &dev->raw->lirc; 35 struct lirc_codec *lirc = &dev->raw->lirc;
36 int sample; 36 int sample;
37 37
38 if (!(dev->raw->enabled_protocols & RC_TYPE_LIRC)) 38 if (!(dev->raw->enabled_protocols & RC_BIT_LIRC))
39 return 0; 39 return 0;
40 40
41 if (!dev->raw->lirc.drv || !dev->raw->lirc.drv->rbuf) 41 if (!dev->raw->lirc.drv || !dev->raw->lirc.drv->rbuf)
@@ -408,7 +408,7 @@ static int ir_lirc_unregister(struct rc_dev *dev)
408} 408}
409 409
410static struct ir_raw_handler lirc_handler = { 410static struct ir_raw_handler lirc_handler = {
411 .protocols = RC_TYPE_LIRC, 411 .protocols = RC_BIT_LIRC,
412 .decode = ir_lirc_decode, 412 .decode = ir_lirc_decode,
413 .raw_register = ir_lirc_register, 413 .raw_register = ir_lirc_register,
414 .raw_unregister = ir_lirc_unregister, 414 .raw_unregister = ir_lirc_unregister,
diff --git a/drivers/media/rc/ir-mce_kbd-decoder.c b/drivers/media/rc/ir-mce_kbd-decoder.c
index 3784ebf80ec7..33fafa4cf7cb 100644
--- a/drivers/media/rc/ir-mce_kbd-decoder.c
+++ b/drivers/media/rc/ir-mce_kbd-decoder.c
@@ -216,7 +216,7 @@ 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->raw->enabled_protocols & RC_TYPE_MCE_KBD)) 219 if (!(dev->raw->enabled_protocols & RC_BIT_MCE_KBD))
220 return 0; 220 return 0;
221 221
222 if (!is_timing_event(ev)) { 222 if (!is_timing_event(ev)) {
@@ -422,7 +422,7 @@ static int ir_mce_kbd_unregister(struct rc_dev *dev)
422} 422}
423 423
424static struct ir_raw_handler mce_kbd_handler = { 424static struct ir_raw_handler mce_kbd_handler = {
425 .protocols = RC_TYPE_MCE_KBD, 425 .protocols = RC_BIT_MCE_KBD,
426 .decode = ir_mce_kbd_decode, 426 .decode = ir_mce_kbd_decode,
427 .raw_register = ir_mce_kbd_register, 427 .raw_register = ir_mce_kbd_register,
428 .raw_unregister = ir_mce_kbd_unregister, 428 .raw_unregister = ir_mce_kbd_unregister,
diff --git a/drivers/media/rc/ir-nec-decoder.c b/drivers/media/rc/ir-nec-decoder.c
index 2ca509e6e16b..a47ee3634969 100644
--- a/drivers/media/rc/ir-nec-decoder.c
+++ b/drivers/media/rc/ir-nec-decoder.c
@@ -52,7 +52,7 @@ 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->raw->enabled_protocols & RC_TYPE_NEC)) 55 if (!(dev->raw->enabled_protocols & RC_BIT_NEC))
56 return 0; 56 return 0;
57 57
58 if (!is_timing_event(ev)) { 58 if (!is_timing_event(ev)) {
@@ -201,7 +201,7 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
201} 201}
202 202
203static struct ir_raw_handler nec_handler = { 203static struct ir_raw_handler nec_handler = {
204 .protocols = RC_TYPE_NEC, 204 .protocols = RC_BIT_NEC,
205 .decode = ir_nec_decode, 205 .decode = ir_nec_decode,
206}; 206};
207 207
diff --git a/drivers/media/rc/ir-rc5-decoder.c b/drivers/media/rc/ir-rc5-decoder.c
index 9ab663a507a4..5b4d1ddeac4e 100644
--- a/drivers/media/rc/ir-rc5-decoder.c
+++ b/drivers/media/rc/ir-rc5-decoder.c
@@ -52,8 +52,8 @@ static int ir_rc5_decode(struct rc_dev *dev, struct ir_raw_event ev)
52 u8 toggle; 52 u8 toggle;
53 u32 scancode; 53 u32 scancode;
54 54
55 if (!(dev->raw->enabled_protocols & RC_TYPE_RC5)) 55 if (!(dev->raw->enabled_protocols & (RC_BIT_RC5 | RC_BIT_RC5X)))
56 return 0; 56 return 0;
57 57
58 if (!is_timing_event(ev)) { 58 if (!is_timing_event(ev)) {
59 if (ev.reset) 59 if (ev.reset)
@@ -128,6 +128,10 @@ again:
128 if (data->wanted_bits == RC5X_NBITS) { 128 if (data->wanted_bits == RC5X_NBITS) {
129 /* RC5X */ 129 /* RC5X */
130 u8 xdata, command, system; 130 u8 xdata, command, system;
131 if (!(dev->raw->enabled_protocols & RC_BIT_RC5X)) {
132 data->state = STATE_INACTIVE;
133 return 0;
134 }
131 xdata = (data->bits & 0x0003F) >> 0; 135 xdata = (data->bits & 0x0003F) >> 0;
132 command = (data->bits & 0x00FC0) >> 6; 136 command = (data->bits & 0x00FC0) >> 6;
133 system = (data->bits & 0x1F000) >> 12; 137 system = (data->bits & 0x1F000) >> 12;
@@ -141,6 +145,10 @@ again:
141 } else { 145 } else {
142 /* RC5 */ 146 /* RC5 */
143 u8 command, system; 147 u8 command, system;
148 if (!(dev->raw->enabled_protocols & RC_BIT_RC5)) {
149 data->state = STATE_INACTIVE;
150 return 0;
151 }
144 command = (data->bits & 0x0003F) >> 0; 152 command = (data->bits & 0x0003F) >> 0;
145 system = (data->bits & 0x007C0) >> 6; 153 system = (data->bits & 0x007C0) >> 6;
146 toggle = (data->bits & 0x00800) ? 1 : 0; 154 toggle = (data->bits & 0x00800) ? 1 : 0;
@@ -164,7 +172,7 @@ out:
164} 172}
165 173
166static struct ir_raw_handler rc5_handler = { 174static struct ir_raw_handler rc5_handler = {
167 .protocols = RC_TYPE_RC5, 175 .protocols = RC_BIT_RC5 | RC_BIT_RC5X,
168 .decode = ir_rc5_decode, 176 .decode = ir_rc5_decode,
169}; 177};
170 178
diff --git a/drivers/media/rc/ir-rc5-sz-decoder.c b/drivers/media/rc/ir-rc5-sz-decoder.c
index ec8d4a2e2c5a..fd807a8308d8 100644
--- a/drivers/media/rc/ir-rc5-sz-decoder.c
+++ b/drivers/media/rc/ir-rc5-sz-decoder.c
@@ -48,8 +48,8 @@ static int ir_rc5_sz_decode(struct rc_dev *dev, struct ir_raw_event ev)
48 u8 toggle, command, system; 48 u8 toggle, command, system;
49 u32 scancode; 49 u32 scancode;
50 50
51 if (!(dev->raw->enabled_protocols & RC_TYPE_RC5_SZ)) 51 if (!(dev->raw->enabled_protocols & RC_BIT_RC5_SZ))
52 return 0; 52 return 0;
53 53
54 if (!is_timing_event(ev)) { 54 if (!is_timing_event(ev)) {
55 if (ev.reset) 55 if (ev.reset)
@@ -128,7 +128,7 @@ out:
128} 128}
129 129
130static struct ir_raw_handler rc5_sz_handler = { 130static struct ir_raw_handler rc5_sz_handler = {
131 .protocols = RC_TYPE_RC5_SZ, 131 .protocols = RC_BIT_RC5_SZ,
132 .decode = ir_rc5_sz_decode, 132 .decode = ir_rc5_sz_decode,
133}; 133};
134 134
diff --git a/drivers/media/rc/ir-rc6-decoder.c b/drivers/media/rc/ir-rc6-decoder.c
index 4cfdd7fa4bbd..e19072ffb36c 100644
--- a/drivers/media/rc/ir-rc6-decoder.c
+++ b/drivers/media/rc/ir-rc6-decoder.c
@@ -89,7 +89,9 @@ static int ir_rc6_decode(struct rc_dev *dev, struct ir_raw_event ev)
89 u32 scancode; 89 u32 scancode;
90 u8 toggle; 90 u8 toggle;
91 91
92 if (!(dev->raw->enabled_protocols & RC_TYPE_RC6)) 92 if (!(dev->raw->enabled_protocols &
93 (RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 |
94 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE)))
93 return 0; 95 return 0;
94 96
95 if (!is_timing_event(ev)) { 97 if (!is_timing_event(ev)) {
@@ -271,7 +273,9 @@ out:
271} 273}
272 274
273static struct ir_raw_handler rc6_handler = { 275static struct ir_raw_handler rc6_handler = {
274 .protocols = RC_TYPE_RC6, 276 .protocols = RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 |
277 RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 |
278 RC_BIT_RC6_MCE,
275 .decode = ir_rc6_decode, 279 .decode = ir_rc6_decode,
276}; 280};
277 281
diff --git a/drivers/media/rc/ir-rx51.c b/drivers/media/rc/ir-rx51.c
index 82e6c1e282d5..9e76c7b40af2 100644
--- a/drivers/media/rc/ir-rx51.c
+++ b/drivers/media/rc/ir-rx51.c
@@ -479,18 +479,7 @@ struct platform_driver lirc_rx51_platform_driver = {
479 .owner = THIS_MODULE, 479 .owner = THIS_MODULE,
480 }, 480 },
481}; 481};
482 482module_platform_driver(lirc_rx51_platform_driver);
483static int __init lirc_rx51_init(void)
484{
485 return platform_driver_register(&lirc_rx51_platform_driver);
486}
487module_init(lirc_rx51_init);
488
489static void __exit lirc_rx51_exit(void)
490{
491 platform_driver_unregister(&lirc_rx51_platform_driver);
492}
493module_exit(lirc_rx51_exit);
494 483
495MODULE_DESCRIPTION("LIRC TX driver for Nokia RX51"); 484MODULE_DESCRIPTION("LIRC TX driver for Nokia RX51");
496MODULE_AUTHOR("Nokia Corporation"); 485MODULE_AUTHOR("Nokia Corporation");
diff --git a/drivers/media/rc/ir-sanyo-decoder.c b/drivers/media/rc/ir-sanyo-decoder.c
index 7e54ec57bcf9..7e69a3b65370 100644
--- a/drivers/media/rc/ir-sanyo-decoder.c
+++ b/drivers/media/rc/ir-sanyo-decoder.c
@@ -58,7 +58,7 @@ 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->raw->enabled_protocols & RC_TYPE_SANYO)) 61 if (!(dev->raw->enabled_protocols & RC_BIT_SANYO))
62 return 0; 62 return 0;
63 63
64 if (!is_timing_event(ev)) { 64 if (!is_timing_event(ev)) {
@@ -179,7 +179,7 @@ static int ir_sanyo_decode(struct rc_dev *dev, struct ir_raw_event ev)
179} 179}
180 180
181static struct ir_raw_handler sanyo_handler = { 181static struct ir_raw_handler sanyo_handler = {
182 .protocols = RC_TYPE_SANYO, 182 .protocols = RC_BIT_SANYO,
183 .decode = ir_sanyo_decode, 183 .decode = ir_sanyo_decode,
184}; 184};
185 185
diff --git a/drivers/media/rc/ir-sony-decoder.c b/drivers/media/rc/ir-sony-decoder.c
index dab98b37621a..fb914342cf4d 100644
--- a/drivers/media/rc/ir-sony-decoder.c
+++ b/drivers/media/rc/ir-sony-decoder.c
@@ -45,7 +45,8 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
45 u32 scancode; 45 u32 scancode;
46 u8 device, subdevice, function; 46 u8 device, subdevice, function;
47 47
48 if (!(dev->raw->enabled_protocols & RC_TYPE_SONY)) 48 if (!(dev->raw->enabled_protocols &
49 (RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20)))
49 return 0; 50 return 0;
50 51
51 if (!is_timing_event(ev)) { 52 if (!is_timing_event(ev)) {
@@ -123,16 +124,28 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
123 124
124 switch (data->count) { 125 switch (data->count) {
125 case 12: 126 case 12:
127 if (!(dev->raw->enabled_protocols & RC_BIT_SONY12)) {
128 data->state = STATE_INACTIVE;
129 return 0;
130 }
126 device = bitrev8((data->bits << 3) & 0xF8); 131 device = bitrev8((data->bits << 3) & 0xF8);
127 subdevice = 0; 132 subdevice = 0;
128 function = bitrev8((data->bits >> 4) & 0xFE); 133 function = bitrev8((data->bits >> 4) & 0xFE);
129 break; 134 break;
130 case 15: 135 case 15:
136 if (!(dev->raw->enabled_protocols & RC_BIT_SONY15)) {
137 data->state = STATE_INACTIVE;
138 return 0;
139 }
131 device = bitrev8((data->bits >> 0) & 0xFF); 140 device = bitrev8((data->bits >> 0) & 0xFF);
132 subdevice = 0; 141 subdevice = 0;
133 function = bitrev8((data->bits >> 7) & 0xFE); 142 function = bitrev8((data->bits >> 7) & 0xFE);
134 break; 143 break;
135 case 20: 144 case 20:
145 if (!(dev->raw->enabled_protocols & RC_BIT_SONY20)) {
146 data->state = STATE_INACTIVE;
147 return 0;
148 }
136 device = bitrev8((data->bits >> 5) & 0xF8); 149 device = bitrev8((data->bits >> 5) & 0xF8);
137 subdevice = bitrev8((data->bits >> 0) & 0xFF); 150 subdevice = bitrev8((data->bits >> 0) & 0xFF);
138 function = bitrev8((data->bits >> 12) & 0xFE); 151 function = bitrev8((data->bits >> 12) & 0xFE);
@@ -157,7 +170,7 @@ out:
157} 170}
158 171
159static struct ir_raw_handler sony_handler = { 172static struct ir_raw_handler sony_handler = {
160 .protocols = RC_TYPE_SONY, 173 .protocols = RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20,
161 .decode = ir_sony_decode, 174 .decode = ir_sony_decode,
162}; 175};
163 176
diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c
index 24c77a42fc36..5e5a7f2b8184 100644
--- a/drivers/media/rc/ite-cir.c
+++ b/drivers/media/rc/ite-cir.c
@@ -1563,7 +1563,7 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
1563 /* set up ir-core props */ 1563 /* set up ir-core props */
1564 rdev->priv = itdev; 1564 rdev->priv = itdev;
1565 rdev->driver_type = RC_DRIVER_IR_RAW; 1565 rdev->driver_type = RC_DRIVER_IR_RAW;
1566 rdev->allowed_protos = RC_TYPE_ALL; 1566 rdev->allowed_protos = RC_BIT_ALL;
1567 rdev->open = ite_open; 1567 rdev->open = ite_open;
1568 rdev->close = ite_close; 1568 rdev->close = ite_close;
1569 rdev->s_idle = ite_s_idle; 1569 rdev->s_idle = ite_s_idle;
@@ -1708,12 +1708,12 @@ static struct pnp_driver ite_driver = {
1708 .shutdown = ite_shutdown, 1708 .shutdown = ite_shutdown,
1709}; 1709};
1710 1710
1711int ite_init(void) 1711static int ite_init(void)
1712{ 1712{
1713 return pnp_register_driver(&ite_driver); 1713 return pnp_register_driver(&ite_driver);
1714} 1714}
1715 1715
1716void ite_exit(void) 1716static void ite_exit(void)
1717{ 1717{
1718 pnp_unregister_driver(&ite_driver); 1718 pnp_unregister_driver(&ite_driver);
1719} 1719}
diff --git a/drivers/media/rc/keymaps/rc-imon-mce.c b/drivers/media/rc/keymaps/rc-imon-mce.c
index 124c7228ba8c..f0da960560b0 100644
--- a/drivers/media/rc/keymaps/rc-imon-mce.c
+++ b/drivers/media/rc/keymaps/rc-imon-mce.c
@@ -121,7 +121,7 @@ static struct rc_map_list imon_mce_map = {
121 .scan = imon_mce, 121 .scan = imon_mce,
122 .size = ARRAY_SIZE(imon_mce), 122 .size = ARRAY_SIZE(imon_mce),
123 /* its RC6, but w/a hardware decoder */ 123 /* its RC6, but w/a hardware decoder */
124 .rc_type = RC_TYPE_RC6, 124 .rc_type = RC_TYPE_RC6_MCE,
125 .name = RC_MAP_IMON_MCE, 125 .name = RC_MAP_IMON_MCE,
126 } 126 }
127}; 127};
diff --git a/drivers/media/rc/keymaps/rc-rc6-mce.c b/drivers/media/rc/keymaps/rc-rc6-mce.c
index 753e43ec787b..ef4006fe4de0 100644
--- a/drivers/media/rc/keymaps/rc-rc6-mce.c
+++ b/drivers/media/rc/keymaps/rc-rc6-mce.c
@@ -97,7 +97,7 @@ static struct rc_map_list rc6_mce_map = {
97 .map = { 97 .map = {
98 .scan = rc6_mce, 98 .scan = rc6_mce,
99 .size = ARRAY_SIZE(rc6_mce), 99 .size = ARRAY_SIZE(rc6_mce),
100 .rc_type = RC_TYPE_RC6, 100 .rc_type = RC_TYPE_RC6_MCE,
101 .name = RC_MAP_RC6_MCE, 101 .name = RC_MAP_RC6_MCE,
102 } 102 }
103}; 103};
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index 850547fe711c..b2146cd99fd8 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -1205,7 +1205,7 @@ static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir)
1205 rc->dev.parent = dev; 1205 rc->dev.parent = dev;
1206 rc->priv = ir; 1206 rc->priv = ir;
1207 rc->driver_type = RC_DRIVER_IR_RAW; 1207 rc->driver_type = RC_DRIVER_IR_RAW;
1208 rc->allowed_protos = RC_TYPE_ALL; 1208 rc->allowed_protos = RC_BIT_ALL;
1209 rc->timeout = MS_TO_NS(100); 1209 rc->timeout = MS_TO_NS(100);
1210 if (!ir->flags.no_tx) { 1210 if (!ir->flags.no_tx) {
1211 rc->s_tx_mask = mceusb_set_tx_mask; 1211 rc->s_tx_mask = mceusb_set_tx_mask;
diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
index 2ea913a44ae8..e4ea89a11eed 100644
--- a/drivers/media/rc/nuvoton-cir.c
+++ b/drivers/media/rc/nuvoton-cir.c
@@ -472,6 +472,7 @@ static void nvt_enable_wake(struct nvt_dev *nvt)
472 nvt_cir_wake_reg_write(nvt, 0, CIR_WAKE_IREN); 472 nvt_cir_wake_reg_write(nvt, 0, CIR_WAKE_IREN);
473} 473}
474 474
475#if 0 /* Currently unused */
475/* rx carrier detect only works in learning mode, must be called w/nvt_lock */ 476/* rx carrier detect only works in learning mode, must be called w/nvt_lock */
476static u32 nvt_rx_carrier_detect(struct nvt_dev *nvt) 477static u32 nvt_rx_carrier_detect(struct nvt_dev *nvt)
477{ 478{
@@ -504,7 +505,7 @@ static u32 nvt_rx_carrier_detect(struct nvt_dev *nvt)
504 505
505 return carrier; 506 return carrier;
506} 507}
507 508#endif
508/* 509/*
509 * set carrier frequency 510 * set carrier frequency
510 * 511 *
@@ -620,7 +621,6 @@ static void nvt_dump_rx_buf(struct nvt_dev *nvt)
620static void nvt_process_rx_ir_data(struct nvt_dev *nvt) 621static void nvt_process_rx_ir_data(struct nvt_dev *nvt)
621{ 622{
622 DEFINE_IR_RAW_EVENT(rawir); 623 DEFINE_IR_RAW_EVENT(rawir);
623 u32 carrier;
624 u8 sample; 624 u8 sample;
625 int i; 625 int i;
626 626
@@ -629,9 +629,6 @@ static void nvt_process_rx_ir_data(struct nvt_dev *nvt)
629 if (debug) 629 if (debug)
630 nvt_dump_rx_buf(nvt); 630 nvt_dump_rx_buf(nvt);
631 631
632 if (nvt->carrier_detect_enabled)
633 carrier = nvt_rx_carrier_detect(nvt);
634
635 nvt_dbg_verbose("Processing buffer of len %d", nvt->pkts); 632 nvt_dbg_verbose("Processing buffer of len %d", nvt->pkts);
636 633
637 init_ir_raw_event(&rawir); 634 init_ir_raw_event(&rawir);
@@ -1045,7 +1042,7 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1045 /* Set up the rc device */ 1042 /* Set up the rc device */
1046 rdev->priv = nvt; 1043 rdev->priv = nvt;
1047 rdev->driver_type = RC_DRIVER_IR_RAW; 1044 rdev->driver_type = RC_DRIVER_IR_RAW;
1048 rdev->allowed_protos = RC_TYPE_ALL; 1045 rdev->allowed_protos = RC_BIT_ALL;
1049 rdev->open = nvt_open; 1046 rdev->open = nvt_open;
1050 rdev->close = nvt_close; 1047 rdev->close = nvt_close;
1051 rdev->tx_ir = nvt_tx_ir; 1048 rdev->tx_ir = nvt_tx_ir;
@@ -1220,12 +1217,12 @@ static struct pnp_driver nvt_driver = {
1220 .shutdown = nvt_shutdown, 1217 .shutdown = nvt_shutdown,
1221}; 1218};
1222 1219
1223int nvt_init(void) 1220static int nvt_init(void)
1224{ 1221{
1225 return pnp_register_driver(&nvt_driver); 1222 return pnp_register_driver(&nvt_driver);
1226} 1223}
1227 1224
1228void nvt_exit(void) 1225static void nvt_exit(void)
1229{ 1226{
1230 pnp_unregister_driver(&nvt_driver); 1227 pnp_unregister_driver(&nvt_driver);
1231} 1228}
diff --git a/drivers/media/rc/nuvoton-cir.h b/drivers/media/rc/nuvoton-cir.h
index 0d5e0872a2ea..7c3674ff5ea2 100644
--- a/drivers/media/rc/nuvoton-cir.h
+++ b/drivers/media/rc/nuvoton-cir.h
@@ -103,7 +103,6 @@ struct nvt_dev {
103 103
104 /* rx settings */ 104 /* rx settings */
105 bool learning_enabled; 105 bool learning_enabled;
106 bool carrier_detect_enabled;
107 106
108 /* track cir wake state */ 107 /* track cir wake state */
109 u8 wake_state; 108 u8 wake_state;
diff --git a/drivers/media/rc/rc-loopback.c b/drivers/media/rc/rc-loopback.c
index f9be68132c67..53d02827a472 100644
--- a/drivers/media/rc/rc-loopback.c
+++ b/drivers/media/rc/rc-loopback.c
@@ -195,7 +195,7 @@ static int __init loop_init(void)
195 rc->map_name = RC_MAP_EMPTY; 195 rc->map_name = RC_MAP_EMPTY;
196 rc->priv = &loopdev; 196 rc->priv = &loopdev;
197 rc->driver_type = RC_DRIVER_IR_RAW; 197 rc->driver_type = RC_DRIVER_IR_RAW;
198 rc->allowed_protos = RC_TYPE_ALL; 198 rc->allowed_protos = RC_BIT_ALL;
199 rc->timeout = 100 * 1000 * 1000; /* 100 ms */ 199 rc->timeout = 100 * 1000 * 1000; /* 100 ms */
200 rc->min_timeout = 1; 200 rc->min_timeout = 1;
201 rc->max_timeout = UINT_MAX; 201 rc->max_timeout = UINT_MAX;
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index cabc19c10515..601d1ac1c688 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -725,25 +725,36 @@ static struct class ir_input_class = {
725 .devnode = ir_devnode, 725 .devnode = ir_devnode,
726}; 726};
727 727
728/*
729 * These are the protocol textual descriptions that are
730 * used by the sysfs protocols file. Note that the order
731 * of the entries is relevant.
732 */
728static struct { 733static struct {
729 u64 type; 734 u64 type;
730 char *name; 735 char *name;
731} proto_names[] = { 736} proto_names[] = {
732 { RC_TYPE_UNKNOWN, "unknown" }, 737 { RC_BIT_NONE, "none" },
733 { RC_TYPE_RC5, "rc-5" }, 738 { RC_BIT_OTHER, "other" },
734 { RC_TYPE_NEC, "nec" }, 739 { RC_BIT_UNKNOWN, "unknown" },
735 { RC_TYPE_RC6, "rc-6" }, 740 { RC_BIT_RC5 |
736 { RC_TYPE_JVC, "jvc" }, 741 RC_BIT_RC5X, "rc-5" },
737 { RC_TYPE_SONY, "sony" }, 742 { RC_BIT_NEC, "nec" },
738 { RC_TYPE_RC5_SZ, "rc-5-sz" }, 743 { RC_BIT_RC6_0 |
739 { RC_TYPE_SANYO, "sanyo" }, 744 RC_BIT_RC6_6A_20 |
740 { RC_TYPE_MCE_KBD, "mce_kbd" }, 745 RC_BIT_RC6_6A_24 |
741 { RC_TYPE_LIRC, "lirc" }, 746 RC_BIT_RC6_6A_32 |
742 { RC_TYPE_OTHER, "other" }, 747 RC_BIT_RC6_MCE, "rc-6" },
748 { RC_BIT_JVC, "jvc" },
749 { RC_BIT_SONY12 |
750 RC_BIT_SONY15 |
751 RC_BIT_SONY20, "sony" },
752 { RC_BIT_RC5_SZ, "rc-5-sz" },
753 { RC_BIT_SANYO, "sanyo" },
754 { RC_BIT_MCE_KBD, "mce_kbd" },
755 { RC_BIT_LIRC, "lirc" },
743}; 756};
744 757
745#define PROTO_NONE "none"
746
747/** 758/**
748 * show_protocols() - shows the current IR protocol(s) 759 * show_protocols() - shows the current IR protocol(s)
749 * @device: the device descriptor 760 * @device: the device descriptor
@@ -790,6 +801,9 @@ static ssize_t show_protocols(struct device *device,
790 tmp += sprintf(tmp, "[%s] ", proto_names[i].name); 801 tmp += sprintf(tmp, "[%s] ", proto_names[i].name);
791 else if (allowed & proto_names[i].type) 802 else if (allowed & proto_names[i].type)
792 tmp += sprintf(tmp, "%s ", proto_names[i].name); 803 tmp += sprintf(tmp, "%s ", proto_names[i].name);
804
805 if (allowed & proto_names[i].type)
806 allowed &= ~proto_names[i].type;
793 } 807 }
794 808
795 if (tmp != buf) 809 if (tmp != buf)
@@ -867,26 +881,20 @@ static ssize_t store_protocols(struct device *device,
867 disable = false; 881 disable = false;
868 } 882 }
869 883
870 if (!enable && !disable && !strncasecmp(tmp, PROTO_NONE, sizeof(PROTO_NONE))) { 884 for (i = 0; i < ARRAY_SIZE(proto_names); i++) {
871 tmp += sizeof(PROTO_NONE); 885 if (!strcasecmp(tmp, proto_names[i].name)) {
872 mask = 0; 886 mask = proto_names[i].type;
873 count++; 887 break;
874 } else {
875 for (i = 0; i < ARRAY_SIZE(proto_names); i++) {
876 if (!strcasecmp(tmp, proto_names[i].name)) {
877 tmp += strlen(proto_names[i].name);
878 mask = proto_names[i].type;
879 break;
880 }
881 }
882 if (i == ARRAY_SIZE(proto_names)) {
883 IR_dprintk(1, "Unknown protocol: '%s'\n", tmp);
884 ret = -EINVAL;
885 goto out;
886 } 888 }
887 count++;
888 } 889 }
889 890
891 if (i == ARRAY_SIZE(proto_names)) {
892 IR_dprintk(1, "Unknown protocol: '%s'\n", tmp);
893 return -EINVAL;
894 }
895
896 count++;
897
890 if (enable) 898 if (enable)
891 type |= mask; 899 type |= mask;
892 else if (disable) 900 else if (disable)
@@ -902,7 +910,7 @@ static ssize_t store_protocols(struct device *device,
902 } 910 }
903 911
904 if (dev->change_protocol) { 912 if (dev->change_protocol) {
905 rc = dev->change_protocol(dev, type); 913 rc = dev->change_protocol(dev, &type);
906 if (rc < 0) { 914 if (rc < 0) {
907 IR_dprintk(1, "Error setting protocols to 0x%llx\n", 915 IR_dprintk(1, "Error setting protocols to 0x%llx\n",
908 (long long)type); 916 (long long)type);
@@ -1117,7 +1125,8 @@ int rc_register_device(struct rc_dev *dev)
1117 } 1125 }
1118 1126
1119 if (dev->change_protocol) { 1127 if (dev->change_protocol) {
1120 rc = dev->change_protocol(dev, rc_map->rc_type); 1128 u64 rc_type = (1 << rc_map->rc_type);
1129 rc = dev->change_protocol(dev, &rc_type);
1121 if (rc < 0) 1130 if (rc < 0)
1122 goto out_raw; 1131 goto out_raw;
1123 } 1132 }
diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index 9f5a17bb5ef5..a8887aba9faf 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -1082,7 +1082,7 @@ static struct rc_dev *redrat3_init_rc_dev(struct redrat3_dev *rr3)
1082 rc->dev.parent = dev; 1082 rc->dev.parent = dev;
1083 rc->priv = rr3; 1083 rc->priv = rr3;
1084 rc->driver_type = RC_DRIVER_IR_RAW; 1084 rc->driver_type = RC_DRIVER_IR_RAW;
1085 rc->allowed_protos = RC_TYPE_ALL; 1085 rc->allowed_protos = RC_BIT_ALL;
1086 rc->timeout = US_TO_NS(2750); 1086 rc->timeout = US_TO_NS(2750);
1087 rc->tx_ir = redrat3_transmit_ir; 1087 rc->tx_ir = redrat3_transmit_ir;
1088 rc->s_tx_carrier = redrat3_set_tx_carrier; 1088 rc->s_tx_carrier = redrat3_set_tx_carrier;
diff --git a/drivers/media/rc/streamzap.c b/drivers/media/rc/streamzap.c
index d6f4bfe09391..c720f12f661e 100644
--- a/drivers/media/rc/streamzap.c
+++ b/drivers/media/rc/streamzap.c
@@ -322,7 +322,7 @@ static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz)
322 rdev->dev.parent = dev; 322 rdev->dev.parent = dev;
323 rdev->priv = sz; 323 rdev->priv = sz;
324 rdev->driver_type = RC_DRIVER_IR_RAW; 324 rdev->driver_type = RC_DRIVER_IR_RAW;
325 rdev->allowed_protos = RC_TYPE_ALL; 325 rdev->allowed_protos = RC_BIT_ALL;
326 rdev->driver_name = DRIVER_NAME; 326 rdev->driver_name = DRIVER_NAME;
327 rdev->map_name = RC_MAP_STREAMZAP; 327 rdev->map_name = RC_MAP_STREAMZAP;
328 328
diff --git a/drivers/media/rc/ttusbir.c b/drivers/media/rc/ttusbir.c
index fef05235234a..f0921b5483eb 100644
--- a/drivers/media/rc/ttusbir.c
+++ b/drivers/media/rc/ttusbir.c
@@ -316,7 +316,7 @@ static int __devinit ttusbir_probe(struct usb_interface *intf,
316 usb_to_input_id(tt->udev, &rc->input_id); 316 usb_to_input_id(tt->udev, &rc->input_id);
317 rc->dev.parent = &intf->dev; 317 rc->dev.parent = &intf->dev;
318 rc->driver_type = RC_DRIVER_IR_RAW; 318 rc->driver_type = RC_DRIVER_IR_RAW;
319 rc->allowed_protos = RC_TYPE_ALL; 319 rc->allowed_protos = RC_BIT_ALL;
320 rc->priv = tt; 320 rc->priv = tt;
321 rc->driver_name = DRIVER_NAME; 321 rc->driver_name = DRIVER_NAME;
322 rc->map_name = RC_MAP_TT_1500; 322 rc->map_name = RC_MAP_TT_1500;
diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c
index 7c9b5f33113b..7f3c476dde05 100644
--- a/drivers/media/rc/winbond-cir.c
+++ b/drivers/media/rc/winbond-cir.c
@@ -7,6 +7,7 @@
7 * with minor modifications. 7 * with minor modifications.
8 * 8 *
9 * Original Author: David Härdeman <david@hardeman.nu> 9 * Original Author: David Härdeman <david@hardeman.nu>
10 * Copyright (C) 2012 Sean Young <sean@mess.org>
10 * Copyright (C) 2009 - 2011 David Härdeman <david@hardeman.nu> 11 * Copyright (C) 2009 - 2011 David Härdeman <david@hardeman.nu>
11 * 12 *
12 * Dedicated to my daughter Matilda, without whose loving attention this 13 * Dedicated to my daughter Matilda, without whose loving attention this
@@ -22,9 +23,7 @@
22 * o IR Receive 23 * o IR Receive
23 * o IR Transmit 24 * o IR Transmit
24 * o Wake-On-CIR functionality 25 * o Wake-On-CIR functionality
25 * 26 * o Carrier detection
26 * To do:
27 * o Learning
28 * 27 *
29 * This program is free software; you can redistribute it and/or modify 28 * This program is free software; you can redistribute it and/or modify
30 * it under the terms of the GNU General Public License as published by 29 * it under the terms of the GNU General Public License as published by
@@ -149,6 +148,12 @@
149#define WBCIR_REGSEL_MASK 0x20 148#define WBCIR_REGSEL_MASK 0x20
150/* Starting address of selected register in WBCIR_REG_WCEIR_INDEX */ 149/* Starting address of selected register in WBCIR_REG_WCEIR_INDEX */
151#define WBCIR_REG_ADDR0 0x00 150#define WBCIR_REG_ADDR0 0x00
151/* Enable carrier counter */
152#define WBCIR_CNTR_EN 0x01
153/* Reset carrier counter */
154#define WBCIR_CNTR_R 0x02
155/* Invert TX */
156#define WBCIR_IRTX_INV 0x04
152 157
153/* Valid banks for the SP3 UART */ 158/* Valid banks for the SP3 UART */
154enum wbcir_bank { 159enum wbcir_bank {
@@ -184,7 +189,7 @@ enum wbcir_txstate {
184}; 189};
185 190
186/* Misc */ 191/* Misc */
187#define WBCIR_NAME "winbond-cir" 192#define WBCIR_NAME "Winbond CIR"
188#define WBCIR_ID_FAMILY 0xF1 /* Family ID for the WPCD376I */ 193#define WBCIR_ID_FAMILY 0xF1 /* Family ID for the WPCD376I */
189#define WBCIR_ID_CHIP 0x04 /* Chip ID for the WPCD376I */ 194#define WBCIR_ID_CHIP 0x04 /* Chip ID for the WPCD376I */
190#define INVALID_SCANCODE 0x7FFFFFFF /* Invalid with all protos */ 195#define INVALID_SCANCODE 0x7FFFFFFF /* Invalid with all protos */
@@ -207,7 +212,8 @@ struct wbcir_data {
207 /* RX state */ 212 /* RX state */
208 enum wbcir_rxstate rxstate; 213 enum wbcir_rxstate rxstate;
209 struct led_trigger *rxtrigger; 214 struct led_trigger *rxtrigger;
210 struct ir_raw_event rxev; 215 int carrier_report_enabled;
216 u32 pulse_duration;
211 217
212 /* TX state */ 218 /* TX state */
213 enum wbcir_txstate txstate; 219 enum wbcir_txstate txstate;
@@ -330,6 +336,30 @@ wbcir_to_rc6cells(u8 val)
330 *****************************************************************************/ 336 *****************************************************************************/
331 337
332static void 338static void
339wbcir_carrier_report(struct wbcir_data *data)
340{
341 unsigned counter = inb(data->ebase + WBCIR_REG_ECEIR_CNT_LO) |
342 inb(data->ebase + WBCIR_REG_ECEIR_CNT_HI) << 8;
343
344 if (counter > 0 && counter < 0xffff) {
345 DEFINE_IR_RAW_EVENT(ev);
346
347 ev.carrier_report = 1;
348 ev.carrier = DIV_ROUND_CLOSEST(counter * 1000000u,
349 data->pulse_duration);
350
351 ir_raw_event_store(data->dev, &ev);
352 }
353
354 /* reset and restart the counter */
355 data->pulse_duration = 0;
356 wbcir_set_bits(data->ebase + WBCIR_REG_ECEIR_CCTL, WBCIR_CNTR_R,
357 WBCIR_CNTR_EN | WBCIR_CNTR_R);
358 wbcir_set_bits(data->ebase + WBCIR_REG_ECEIR_CCTL, WBCIR_CNTR_EN,
359 WBCIR_CNTR_EN | WBCIR_CNTR_R);
360}
361
362static void
333wbcir_idle_rx(struct rc_dev *dev, bool idle) 363wbcir_idle_rx(struct rc_dev *dev, bool idle)
334{ 364{
335 struct wbcir_data *data = dev->priv; 365 struct wbcir_data *data = dev->priv;
@@ -339,9 +369,16 @@ wbcir_idle_rx(struct rc_dev *dev, bool idle)
339 led_trigger_event(data->rxtrigger, LED_FULL); 369 led_trigger_event(data->rxtrigger, LED_FULL);
340 } 370 }
341 371
342 if (idle && data->rxstate != WBCIR_RXSTATE_INACTIVE) 372 if (idle && data->rxstate != WBCIR_RXSTATE_INACTIVE) {
373 data->rxstate = WBCIR_RXSTATE_INACTIVE;
374 led_trigger_event(data->rxtrigger, LED_OFF);
375
376 if (data->carrier_report_enabled)
377 wbcir_carrier_report(data);
378
343 /* Tell hardware to go idle by setting RXINACTIVE */ 379 /* Tell hardware to go idle by setting RXINACTIVE */
344 outb(WBCIR_RX_DISABLE, data->sbase + WBCIR_REG_SP3_ASCR); 380 outb(WBCIR_RX_DISABLE, data->sbase + WBCIR_REG_SP3_ASCR);
381 }
345} 382}
346 383
347static void 384static void
@@ -349,21 +386,22 @@ wbcir_irq_rx(struct wbcir_data *data, struct pnp_dev *device)
349{ 386{
350 u8 irdata; 387 u8 irdata;
351 DEFINE_IR_RAW_EVENT(rawir); 388 DEFINE_IR_RAW_EVENT(rawir);
389 unsigned duration;
352 390
353 /* Since RXHDLEV is set, at least 8 bytes are in the FIFO */ 391 /* Since RXHDLEV is set, at least 8 bytes are in the FIFO */
354 while (inb(data->sbase + WBCIR_REG_SP3_LSR) & WBCIR_RX_AVAIL) { 392 while (inb(data->sbase + WBCIR_REG_SP3_LSR) & WBCIR_RX_AVAIL) {
355 irdata = inb(data->sbase + WBCIR_REG_SP3_RXDATA); 393 irdata = inb(data->sbase + WBCIR_REG_SP3_RXDATA);
356 if (data->rxstate == WBCIR_RXSTATE_ERROR) 394 if (data->rxstate == WBCIR_RXSTATE_ERROR)
357 continue; 395 continue;
396
397 duration = ((irdata & 0x7F) + 1) * 2;
358 rawir.pulse = irdata & 0x80 ? false : true; 398 rawir.pulse = irdata & 0x80 ? false : true;
359 rawir.duration = US_TO_NS(((irdata & 0x7F) + 1) * 10); 399 rawir.duration = US_TO_NS(duration);
360 ir_raw_event_store_with_filter(data->dev, &rawir);
361 }
362 400
363 /* Check if we should go idle */ 401 if (rawir.pulse)
364 if (data->dev->idle) { 402 data->pulse_duration += duration;
365 led_trigger_event(data->rxtrigger, LED_OFF); 403
366 data->rxstate = WBCIR_RXSTATE_INACTIVE; 404 ir_raw_event_store_with_filter(data->dev, &rawir);
367 } 405 }
368 406
369 ir_raw_event_handle(data->dev); 407 ir_raw_event_handle(data->dev);
@@ -492,6 +530,33 @@ wbcir_irq_handler(int irqno, void *cookie)
492 *****************************************************************************/ 530 *****************************************************************************/
493 531
494static int 532static int
533wbcir_set_carrier_report(struct rc_dev *dev, int enable)
534{
535 struct wbcir_data *data = dev->priv;
536 unsigned long flags;
537
538 spin_lock_irqsave(&data->spinlock, flags);
539
540 if (data->carrier_report_enabled == enable) {
541 spin_unlock_irqrestore(&data->spinlock, flags);
542 return 0;
543 }
544
545 data->pulse_duration = 0;
546 wbcir_set_bits(data->ebase + WBCIR_REG_ECEIR_CCTL, WBCIR_CNTR_R,
547 WBCIR_CNTR_EN | WBCIR_CNTR_R);
548
549 if (enable && data->dev->idle)
550 wbcir_set_bits(data->ebase + WBCIR_REG_ECEIR_CCTL,
551 WBCIR_CNTR_EN, WBCIR_CNTR_EN | WBCIR_CNTR_R);
552
553 data->carrier_report_enabled = enable;
554 spin_unlock_irqrestore(&data->spinlock, flags);
555
556 return 0;
557}
558
559static int
495wbcir_txcarrier(struct rc_dev *dev, u32 carrier) 560wbcir_txcarrier(struct rc_dev *dev, u32 carrier)
496{ 561{
497 struct wbcir_data *data = dev->priv; 562 struct wbcir_data *data = dev->priv;
@@ -837,7 +902,7 @@ wbcir_init_hw(struct wbcir_data *data)
837 902
838 /* Set IRTX_INV */ 903 /* Set IRTX_INV */
839 if (invert) 904 if (invert)
840 outb(0x04, data->ebase + WBCIR_REG_ECEIR_CCTL); 905 outb(WBCIR_IRTX_INV, data->ebase + WBCIR_REG_ECEIR_CCTL);
841 else 906 else
842 outb(0x00, data->ebase + WBCIR_REG_ECEIR_CCTL); 907 outb(0x00, data->ebase + WBCIR_REG_ECEIR_CCTL);
843 908
@@ -866,8 +931,8 @@ wbcir_init_hw(struct wbcir_data *data)
866 /* prescaler 1.0, tx/rx fifo lvl 16 */ 931 /* prescaler 1.0, tx/rx fifo lvl 16 */
867 outb(0x30, data->sbase + WBCIR_REG_SP3_EXCR2); 932 outb(0x30, data->sbase + WBCIR_REG_SP3_EXCR2);
868 933
869 /* Set baud divisor to sample every 10 us */ 934 /* Set baud divisor to sample every 2 ns */
870 outb(0x0F, data->sbase + WBCIR_REG_SP3_BGDL); 935 outb(0x03, data->sbase + WBCIR_REG_SP3_BGDL);
871 outb(0x00, data->sbase + WBCIR_REG_SP3_BGDH); 936 outb(0x00, data->sbase + WBCIR_REG_SP3_BGDH);
872 937
873 /* Set CEIR mode */ 938 /* Set CEIR mode */
@@ -876,9 +941,12 @@ wbcir_init_hw(struct wbcir_data *data)
876 inb(data->sbase + WBCIR_REG_SP3_LSR); /* Clear LSR */ 941 inb(data->sbase + WBCIR_REG_SP3_LSR); /* Clear LSR */
877 inb(data->sbase + WBCIR_REG_SP3_MSR); /* Clear MSR */ 942 inb(data->sbase + WBCIR_REG_SP3_MSR); /* Clear MSR */
878 943
879 /* Disable RX demod, enable run-length enc/dec, set freq span */ 944 /*
945 * Disable RX demod, enable run-length enc/dec, set freq span and
946 * enable over-sampling
947 */
880 wbcir_select_bank(data, WBCIR_BANK_7); 948 wbcir_select_bank(data, WBCIR_BANK_7);
881 outb(0x90, data->sbase + WBCIR_REG_SP3_RCCFG); 949 outb(0xd0, data->sbase + WBCIR_REG_SP3_RCCFG);
882 950
883 /* Disable timer */ 951 /* Disable timer */
884 wbcir_select_bank(data, WBCIR_BANK_4); 952 wbcir_select_bank(data, WBCIR_BANK_4);
@@ -915,9 +983,8 @@ wbcir_init_hw(struct wbcir_data *data)
915 983
916 /* Clear RX state */ 984 /* Clear RX state */
917 data->rxstate = WBCIR_RXSTATE_INACTIVE; 985 data->rxstate = WBCIR_RXSTATE_INACTIVE;
918 data->rxev.duration = 0;
919 ir_raw_event_reset(data->dev); 986 ir_raw_event_reset(data->dev);
920 ir_raw_event_handle(data->dev); 987 ir_raw_event_set_idle(data->dev, true);
921 988
922 /* Clear TX state */ 989 /* Clear TX state */
923 if (data->txstate == WBCIR_TXSTATE_ACTIVE) { 990 if (data->txstate == WBCIR_TXSTATE_ACTIVE) {
@@ -1007,7 +1074,7 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
1007 } 1074 }
1008 1075
1009 data->dev->driver_type = RC_DRIVER_IR_RAW; 1076 data->dev->driver_type = RC_DRIVER_IR_RAW;
1010 data->dev->driver_name = WBCIR_NAME; 1077 data->dev->driver_name = DRVNAME;
1011 data->dev->input_name = WBCIR_NAME; 1078 data->dev->input_name = WBCIR_NAME;
1012 data->dev->input_phys = "wbcir/cir0"; 1079 data->dev->input_phys = "wbcir/cir0";
1013 data->dev->input_id.bustype = BUS_HOST; 1080 data->dev->input_id.bustype = BUS_HOST;
@@ -1016,13 +1083,15 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
1016 data->dev->input_id.version = WBCIR_ID_CHIP; 1083 data->dev->input_id.version = WBCIR_ID_CHIP;
1017 data->dev->map_name = RC_MAP_RC6_MCE; 1084 data->dev->map_name = RC_MAP_RC6_MCE;
1018 data->dev->s_idle = wbcir_idle_rx; 1085 data->dev->s_idle = wbcir_idle_rx;
1086 data->dev->s_carrier_report = wbcir_set_carrier_report;
1019 data->dev->s_tx_mask = wbcir_txmask; 1087 data->dev->s_tx_mask = wbcir_txmask;
1020 data->dev->s_tx_carrier = wbcir_txcarrier; 1088 data->dev->s_tx_carrier = wbcir_txcarrier;
1021 data->dev->tx_ir = wbcir_tx; 1089 data->dev->tx_ir = wbcir_tx;
1022 data->dev->priv = data; 1090 data->dev->priv = data;
1023 data->dev->dev.parent = &device->dev; 1091 data->dev->dev.parent = &device->dev;
1024 data->dev->timeout = MS_TO_NS(100); 1092 data->dev->timeout = MS_TO_NS(100);
1025 data->dev->allowed_protos = RC_TYPE_ALL; 1093 data->dev->rx_resolution = US_TO_NS(2);
1094 data->dev->allowed_protos = RC_BIT_ALL;
1026 1095
1027 if (!request_region(data->wbase, WAKEUP_IOMEM_LEN, DRVNAME)) { 1096 if (!request_region(data->wbase, WAKEUP_IOMEM_LEN, DRVNAME)) {
1028 dev_err(dev, "Region 0x%lx-0x%lx already in use!\n", 1097 dev_err(dev, "Region 0x%lx-0x%lx already in use!\n",
diff --git a/drivers/media/tuners/fc2580.c b/drivers/media/tuners/fc2580.c
index aff39ae457a0..81f38aae9c66 100644
--- a/drivers/media/tuners/fc2580.c
+++ b/drivers/media/tuners/fc2580.c
@@ -35,8 +35,6 @@
35 * Currently it blind writes bunch of static registers from the 35 * Currently it blind writes bunch of static registers from the
36 * fc2580_freq_regs_lut[] when fc2580_set_params() is called. Add some 36 * fc2580_freq_regs_lut[] when fc2580_set_params() is called. Add some
37 * logic to reduce unneeded register writes. 37 * logic to reduce unneeded register writes.
38 * There is also don't-care registers, initialized with value 0xff, and those
39 * are also written to the chip currently (yes, not wise).
40 */ 38 */
41 39
42/* write multiple registers */ 40/* write multiple registers */
@@ -111,6 +109,17 @@ static int fc2580_rd_reg(struct fc2580_priv *priv, u8 reg, u8 *val)
111 return fc2580_rd_regs(priv, reg, val, 1); 109 return fc2580_rd_regs(priv, reg, val, 1);
112} 110}
113 111
112/* write single register conditionally only when value differs from 0xff
113 * XXX: This is special routine meant only for writing fc2580_freq_regs_lut[]
114 * values. Do not use for the other purposes. */
115static int fc2580_wr_reg_ff(struct fc2580_priv *priv, u8 reg, u8 val)
116{
117 if (val == 0xff)
118 return 0;
119 else
120 return fc2580_wr_regs(priv, reg, &val, 1);
121}
122
114static int fc2580_set_params(struct dvb_frontend *fe) 123static int fc2580_set_params(struct dvb_frontend *fe)
115{ 124{
116 struct fc2580_priv *priv = fe->tuner_priv; 125 struct fc2580_priv *priv = fe->tuner_priv;
@@ -213,99 +222,99 @@ static int fc2580_set_params(struct dvb_frontend *fe)
213 if (i == ARRAY_SIZE(fc2580_freq_regs_lut)) 222 if (i == ARRAY_SIZE(fc2580_freq_regs_lut))
214 goto err; 223 goto err;
215 224
216 ret = fc2580_wr_reg(priv, 0x25, fc2580_freq_regs_lut[i].r25_val); 225 ret = fc2580_wr_reg_ff(priv, 0x25, fc2580_freq_regs_lut[i].r25_val);
217 if (ret < 0) 226 if (ret < 0)
218 goto err; 227 goto err;
219 228
220 ret = fc2580_wr_reg(priv, 0x27, fc2580_freq_regs_lut[i].r27_val); 229 ret = fc2580_wr_reg_ff(priv, 0x27, fc2580_freq_regs_lut[i].r27_val);
221 if (ret < 0) 230 if (ret < 0)
222 goto err; 231 goto err;
223 232
224 ret = fc2580_wr_reg(priv, 0x28, fc2580_freq_regs_lut[i].r28_val); 233 ret = fc2580_wr_reg_ff(priv, 0x28, fc2580_freq_regs_lut[i].r28_val);
225 if (ret < 0) 234 if (ret < 0)
226 goto err; 235 goto err;
227 236
228 ret = fc2580_wr_reg(priv, 0x29, fc2580_freq_regs_lut[i].r29_val); 237 ret = fc2580_wr_reg_ff(priv, 0x29, fc2580_freq_regs_lut[i].r29_val);
229 if (ret < 0) 238 if (ret < 0)
230 goto err; 239 goto err;
231 240
232 ret = fc2580_wr_reg(priv, 0x2b, fc2580_freq_regs_lut[i].r2b_val); 241 ret = fc2580_wr_reg_ff(priv, 0x2b, fc2580_freq_regs_lut[i].r2b_val);
233 if (ret < 0) 242 if (ret < 0)
234 goto err; 243 goto err;
235 244
236 ret = fc2580_wr_reg(priv, 0x2c, fc2580_freq_regs_lut[i].r2c_val); 245 ret = fc2580_wr_reg_ff(priv, 0x2c, fc2580_freq_regs_lut[i].r2c_val);
237 if (ret < 0) 246 if (ret < 0)
238 goto err; 247 goto err;
239 248
240 ret = fc2580_wr_reg(priv, 0x2d, fc2580_freq_regs_lut[i].r2d_val); 249 ret = fc2580_wr_reg_ff(priv, 0x2d, fc2580_freq_regs_lut[i].r2d_val);
241 if (ret < 0) 250 if (ret < 0)
242 goto err; 251 goto err;
243 252
244 ret = fc2580_wr_reg(priv, 0x30, fc2580_freq_regs_lut[i].r30_val); 253 ret = fc2580_wr_reg_ff(priv, 0x30, fc2580_freq_regs_lut[i].r30_val);
245 if (ret < 0) 254 if (ret < 0)
246 goto err; 255 goto err;
247 256
248 ret = fc2580_wr_reg(priv, 0x44, fc2580_freq_regs_lut[i].r44_val); 257 ret = fc2580_wr_reg_ff(priv, 0x44, fc2580_freq_regs_lut[i].r44_val);
249 if (ret < 0) 258 if (ret < 0)
250 goto err; 259 goto err;
251 260
252 ret = fc2580_wr_reg(priv, 0x50, fc2580_freq_regs_lut[i].r50_val); 261 ret = fc2580_wr_reg_ff(priv, 0x50, fc2580_freq_regs_lut[i].r50_val);
253 if (ret < 0) 262 if (ret < 0)
254 goto err; 263 goto err;
255 264
256 ret = fc2580_wr_reg(priv, 0x53, fc2580_freq_regs_lut[i].r53_val); 265 ret = fc2580_wr_reg_ff(priv, 0x53, fc2580_freq_regs_lut[i].r53_val);
257 if (ret < 0) 266 if (ret < 0)
258 goto err; 267 goto err;
259 268
260 ret = fc2580_wr_reg(priv, 0x5f, fc2580_freq_regs_lut[i].r5f_val); 269 ret = fc2580_wr_reg_ff(priv, 0x5f, fc2580_freq_regs_lut[i].r5f_val);
261 if (ret < 0) 270 if (ret < 0)
262 goto err; 271 goto err;
263 272
264 ret = fc2580_wr_reg(priv, 0x61, fc2580_freq_regs_lut[i].r61_val); 273 ret = fc2580_wr_reg_ff(priv, 0x61, fc2580_freq_regs_lut[i].r61_val);
265 if (ret < 0) 274 if (ret < 0)
266 goto err; 275 goto err;
267 276
268 ret = fc2580_wr_reg(priv, 0x62, fc2580_freq_regs_lut[i].r62_val); 277 ret = fc2580_wr_reg_ff(priv, 0x62, fc2580_freq_regs_lut[i].r62_val);
269 if (ret < 0) 278 if (ret < 0)
270 goto err; 279 goto err;
271 280
272 ret = fc2580_wr_reg(priv, 0x63, fc2580_freq_regs_lut[i].r63_val); 281 ret = fc2580_wr_reg_ff(priv, 0x63, fc2580_freq_regs_lut[i].r63_val);
273 if (ret < 0) 282 if (ret < 0)
274 goto err; 283 goto err;
275 284
276 ret = fc2580_wr_reg(priv, 0x67, fc2580_freq_regs_lut[i].r67_val); 285 ret = fc2580_wr_reg_ff(priv, 0x67, fc2580_freq_regs_lut[i].r67_val);
277 if (ret < 0) 286 if (ret < 0)
278 goto err; 287 goto err;
279 288
280 ret = fc2580_wr_reg(priv, 0x68, fc2580_freq_regs_lut[i].r68_val); 289 ret = fc2580_wr_reg_ff(priv, 0x68, fc2580_freq_regs_lut[i].r68_val);
281 if (ret < 0) 290 if (ret < 0)
282 goto err; 291 goto err;
283 292
284 ret = fc2580_wr_reg(priv, 0x69, fc2580_freq_regs_lut[i].r69_val); 293 ret = fc2580_wr_reg_ff(priv, 0x69, fc2580_freq_regs_lut[i].r69_val);
285 if (ret < 0) 294 if (ret < 0)
286 goto err; 295 goto err;
287 296
288 ret = fc2580_wr_reg(priv, 0x6a, fc2580_freq_regs_lut[i].r6a_val); 297 ret = fc2580_wr_reg_ff(priv, 0x6a, fc2580_freq_regs_lut[i].r6a_val);
289 if (ret < 0) 298 if (ret < 0)
290 goto err; 299 goto err;
291 300
292 ret = fc2580_wr_reg(priv, 0x6b, fc2580_freq_regs_lut[i].r6b_val); 301 ret = fc2580_wr_reg_ff(priv, 0x6b, fc2580_freq_regs_lut[i].r6b_val);
293 if (ret < 0) 302 if (ret < 0)
294 goto err; 303 goto err;
295 304
296 ret = fc2580_wr_reg(priv, 0x6c, fc2580_freq_regs_lut[i].r6c_val); 305 ret = fc2580_wr_reg_ff(priv, 0x6c, fc2580_freq_regs_lut[i].r6c_val);
297 if (ret < 0) 306 if (ret < 0)
298 goto err; 307 goto err;
299 308
300 ret = fc2580_wr_reg(priv, 0x6d, fc2580_freq_regs_lut[i].r6d_val); 309 ret = fc2580_wr_reg_ff(priv, 0x6d, fc2580_freq_regs_lut[i].r6d_val);
301 if (ret < 0) 310 if (ret < 0)
302 goto err; 311 goto err;
303 312
304 ret = fc2580_wr_reg(priv, 0x6e, fc2580_freq_regs_lut[i].r6e_val); 313 ret = fc2580_wr_reg_ff(priv, 0x6e, fc2580_freq_regs_lut[i].r6e_val);
305 if (ret < 0) 314 if (ret < 0)
306 goto err; 315 goto err;
307 316
308 ret = fc2580_wr_reg(priv, 0x6f, fc2580_freq_regs_lut[i].r6f_val); 317 ret = fc2580_wr_reg_ff(priv, 0x6f, fc2580_freq_regs_lut[i].r6f_val);
309 if (ret < 0) 318 if (ret < 0)
310 goto err; 319 goto err;
311 320
diff --git a/drivers/media/tuners/max2165.c b/drivers/media/tuners/max2165.c
index ba84936aafd6..95ed46f2cd26 100644
--- a/drivers/media/tuners/max2165.c
+++ b/drivers/media/tuners/max2165.c
@@ -161,7 +161,7 @@ static int max2165_set_bandwidth(struct max2165_priv *priv, u32 bw)
161 return 0; 161 return 0;
162} 162}
163 163
164int fixpt_div32(u32 dividend, u32 divisor, u32 *quotient, u32 *fraction) 164static int fixpt_div32(u32 dividend, u32 divisor, u32 *quotient, u32 *fraction)
165{ 165{
166 u32 remainder; 166 u32 remainder;
167 u32 q, f = 0; 167 u32 q, f = 0;
diff --git a/drivers/media/tuners/tua9001.c b/drivers/media/tuners/tua9001.c
index 389668474070..83a6240f64d3 100644
--- a/drivers/media/tuners/tua9001.c
+++ b/drivers/media/tuners/tua9001.c
@@ -136,7 +136,7 @@ static int tua9001_set_params(struct dvb_frontend *fe)
136{ 136{
137 struct tua9001_priv *priv = fe->tuner_priv; 137 struct tua9001_priv *priv = fe->tuner_priv;
138 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 138 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
139 int ret, i; 139 int ret = 0, i;
140 u16 val; 140 u16 val;
141 u32 frequency; 141 u32 frequency;
142 struct reg_val data[2]; 142 struct reg_val data[2];
diff --git a/drivers/media/tuners/xc4000.c b/drivers/media/tuners/xc4000.c
index 4937712278f6..5c0fd787cc8f 100644
--- a/drivers/media/tuners/xc4000.c
+++ b/drivers/media/tuners/xc4000.c
@@ -934,7 +934,7 @@ static int check_firmware(struct dvb_frontend *fe, unsigned int type,
934 int rc = 0, is_retry = 0; 934 int rc = 0, is_retry = 0;
935 u16 hwmodel; 935 u16 hwmodel;
936 v4l2_std_id std0; 936 v4l2_std_id std0;
937 u8 hw_major, hw_minor, fw_major, fw_minor; 937 u8 hw_major = 0, hw_minor = 0, fw_major = 0, fw_minor = 0;
938 938
939 dprintk(1, "%s called\n", __func__); 939 dprintk(1, "%s called\n", __func__);
940 940
diff --git a/drivers/media/usb/au0828/au0828-cards.c b/drivers/media/usb/au0828/au0828-cards.c
index 448361c6a13e..0cb7c28dcb17 100644
--- a/drivers/media/usb/au0828/au0828-cards.c
+++ b/drivers/media/usb/au0828/au0828-cards.c
@@ -25,7 +25,7 @@
25#include "media/tuner.h" 25#include "media/tuner.h"
26#include "media/v4l2-common.h" 26#include "media/v4l2-common.h"
27 27
28void hvr950q_cs5340_audio(void *priv, int enable) 28static void hvr950q_cs5340_audio(void *priv, int enable)
29{ 29{
30 /* Because the HVR-950q shares an i2s bus between the cs5340 and the 30 /* Because the HVR-950q shares an i2s bus between the cs5340 and the
31 au8522, we need to hold cs5340 in reset when using the au8522 */ 31 au8522, we need to hold cs5340 in reset when using the au8522 */
diff --git a/drivers/media/usb/au0828/au0828-dvb.c b/drivers/media/usb/au0828/au0828-dvb.c
index b328f6550d0b..9a6f15613a38 100644
--- a/drivers/media/usb/au0828/au0828-dvb.c
+++ b/drivers/media/usb/au0828/au0828-dvb.c
@@ -272,7 +272,6 @@ static void au0828_restart_dvb_streaming(struct work_struct *work)
272 struct au0828_dev *dev = container_of(work, struct au0828_dev, 272 struct au0828_dev *dev = container_of(work, struct au0828_dev,
273 restart_streaming); 273 restart_streaming);
274 struct au0828_dvb *dvb = &dev->dvb; 274 struct au0828_dvb *dvb = &dev->dvb;
275 int ret;
276 275
277 if (dev->urb_streaming == 0) 276 if (dev->urb_streaming == 0)
278 return; 277 return;
@@ -282,7 +281,7 @@ static void au0828_restart_dvb_streaming(struct work_struct *work)
282 mutex_lock(&dvb->lock); 281 mutex_lock(&dvb->lock);
283 282
284 /* Stop transport */ 283 /* Stop transport */
285 ret = stop_urb_transfer(dev); 284 stop_urb_transfer(dev);
286 au0828_write(dev, 0x608, 0x00); 285 au0828_write(dev, 0x608, 0x00);
287 au0828_write(dev, 0x609, 0x00); 286 au0828_write(dev, 0x609, 0x00);
288 au0828_write(dev, 0x60a, 0x00); 287 au0828_write(dev, 0x60a, 0x00);
@@ -293,7 +292,7 @@ static void au0828_restart_dvb_streaming(struct work_struct *work)
293 au0828_write(dev, 0x609, 0x72); 292 au0828_write(dev, 0x609, 0x72);
294 au0828_write(dev, 0x60a, 0x71); 293 au0828_write(dev, 0x60a, 0x71);
295 au0828_write(dev, 0x60b, 0x01); 294 au0828_write(dev, 0x60b, 0x01);
296 ret = start_urb_transfer(dev); 295 start_urb_transfer(dev);
297 296
298 mutex_unlock(&dvb->lock); 297 mutex_unlock(&dvb->lock);
299} 298}
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 870585570571..45387aab10c7 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -158,7 +158,7 @@ static void au0828_irq_callback(struct urb *urb)
158/* 158/*
159 * Stop and Deallocate URBs 159 * Stop and Deallocate URBs
160 */ 160 */
161void au0828_uninit_isoc(struct au0828_dev *dev) 161static void au0828_uninit_isoc(struct au0828_dev *dev)
162{ 162{
163 struct urb *urb; 163 struct urb *urb;
164 int i; 164 int i;
@@ -197,9 +197,9 @@ void au0828_uninit_isoc(struct au0828_dev *dev)
197/* 197/*
198 * Allocate URBs and start IRQ 198 * Allocate URBs and start IRQ
199 */ 199 */
200int au0828_init_isoc(struct au0828_dev *dev, int max_packets, 200static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
201 int num_bufs, int max_pkt_size, 201 int num_bufs, int max_pkt_size,
202 int (*isoc_copy) (struct au0828_dev *dev, struct urb *urb)) 202 int (*isoc_copy) (struct au0828_dev *dev, struct urb *urb))
203{ 203{
204 struct au0828_dmaqueue *dma_q = &dev->vidq; 204 struct au0828_dmaqueue *dma_q = &dev->vidq;
205 int i; 205 int i;
@@ -783,7 +783,7 @@ static int au0828_i2s_init(struct au0828_dev *dev)
783 * Auvitek au0828 analog stream enable 783 * Auvitek au0828 analog stream enable
784 * Please set interface0 to AS5 before enable the stream 784 * Please set interface0 to AS5 before enable the stream
785 */ 785 */
786int au0828_analog_stream_enable(struct au0828_dev *d) 786static int au0828_analog_stream_enable(struct au0828_dev *d)
787{ 787{
788 dprintk(1, "au0828_analog_stream_enable called\n"); 788 dprintk(1, "au0828_analog_stream_enable called\n");
789 au0828_writereg(d, AU0828_SENSORCTRL_VBI_103, 0x00); 789 au0828_writereg(d, AU0828_SENSORCTRL_VBI_103, 0x00);
@@ -810,7 +810,7 @@ int au0828_analog_stream_disable(struct au0828_dev *d)
810 return 0; 810 return 0;
811} 811}
812 812
813void au0828_analog_stream_reset(struct au0828_dev *dev) 813static void au0828_analog_stream_reset(struct au0828_dev *dev)
814{ 814{
815 dprintk(1, "au0828_analog_stream_reset called\n"); 815 dprintk(1, "au0828_analog_stream_reset called\n");
816 au0828_writereg(dev, AU0828_SENSORCTRL_100, 0x0); 816 au0828_writereg(dev, AU0828_SENSORCTRL_100, 0x0);
@@ -913,7 +913,7 @@ static int get_ressource(struct au0828_fh *fh)
913/* This function ensures that video frames continue to be delivered even if 913/* This function ensures that video frames continue to be delivered even if
914 the ITU-656 input isn't receiving any data (thereby preventing applications 914 the ITU-656 input isn't receiving any data (thereby preventing applications
915 such as tvtime from hanging) */ 915 such as tvtime from hanging) */
916void au0828_vid_buffer_timeout(unsigned long data) 916static void au0828_vid_buffer_timeout(unsigned long data)
917{ 917{
918 struct au0828_dev *dev = (struct au0828_dev *) data; 918 struct au0828_dev *dev = (struct au0828_dev *) data;
919 struct au0828_dmaqueue *dma_q = &dev->vidq; 919 struct au0828_dmaqueue *dma_q = &dev->vidq;
@@ -937,7 +937,7 @@ void au0828_vid_buffer_timeout(unsigned long data)
937 spin_unlock_irqrestore(&dev->slock, flags); 937 spin_unlock_irqrestore(&dev->slock, flags);
938} 938}
939 939
940void au0828_vbi_buffer_timeout(unsigned long data) 940static void au0828_vbi_buffer_timeout(unsigned long data)
941{ 941{
942 struct au0828_dev *dev = (struct au0828_dev *) data; 942 struct au0828_dev *dev = (struct au0828_dev *) data;
943 struct au0828_dmaqueue *dma_q = &dev->vbiq; 943 struct au0828_dmaqueue *dma_q = &dev->vbiq;
diff --git a/drivers/media/usb/cx231xx/cx231xx-avcore.c b/drivers/media/usb/cx231xx/cx231xx-avcore.c
index 447148eff958..722207913740 100644
--- a/drivers/media/usb/cx231xx/cx231xx-avcore.c
+++ b/drivers/media/usb/cx231xx/cx231xx-avcore.c
@@ -1068,12 +1068,12 @@ int cx231xx_unmute_audio(struct cx231xx *dev)
1068} 1068}
1069EXPORT_SYMBOL_GPL(cx231xx_unmute_audio); 1069EXPORT_SYMBOL_GPL(cx231xx_unmute_audio);
1070 1070
1071int stopAudioFirmware(struct cx231xx *dev) 1071static int stopAudioFirmware(struct cx231xx *dev)
1072{ 1072{
1073 return vid_blk_write_byte(dev, DL_CTL_CONTROL, 0x03); 1073 return vid_blk_write_byte(dev, DL_CTL_CONTROL, 0x03);
1074} 1074}
1075 1075
1076int restartAudioFirmware(struct cx231xx *dev) 1076static int restartAudioFirmware(struct cx231xx *dev)
1077{ 1077{
1078 return vid_blk_write_byte(dev, DL_CTL_CONTROL, 0x13); 1078 return vid_blk_write_byte(dev, DL_CTL_CONTROL, 0x13);
1079} 1079}
@@ -2631,11 +2631,6 @@ int cx231xx_capture_start(struct cx231xx *dev, int start, u8 media_type)
2631 rc = cx231xx_stop_stream(dev, ep_mask); 2631 rc = cx231xx_stop_stream(dev, ep_mask);
2632 } 2632 }
2633 2633
2634 if (dev->mode == CX231XX_ANALOG_MODE)
2635 ;/* do any in Analog mode */
2636 else
2637 ;/* do any in digital mode */
2638
2639 return rc; 2634 return rc;
2640} 2635}
2641EXPORT_SYMBOL_GPL(cx231xx_capture_start); 2636EXPORT_SYMBOL_GPL(cx231xx_capture_start);
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index b84ebc54d91b..bbed1e40eeda 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -686,7 +686,7 @@ int cx231xx_tuner_callback(void *ptr, int component, int command, int arg)
686} 686}
687EXPORT_SYMBOL_GPL(cx231xx_tuner_callback); 687EXPORT_SYMBOL_GPL(cx231xx_tuner_callback);
688 688
689void cx231xx_reset_out(struct cx231xx *dev) 689static void cx231xx_reset_out(struct cx231xx *dev)
690{ 690{
691 cx231xx_set_gpio_value(dev, CX23417_RESET, 1); 691 cx231xx_set_gpio_value(dev, CX23417_RESET, 1);
692 msleep(200); 692 msleep(200);
@@ -694,11 +694,13 @@ void cx231xx_reset_out(struct cx231xx *dev)
694 msleep(200); 694 msleep(200);
695 cx231xx_set_gpio_value(dev, CX23417_RESET, 1); 695 cx231xx_set_gpio_value(dev, CX23417_RESET, 1);
696} 696}
697void cx231xx_enable_OSC(struct cx231xx *dev) 697
698static void cx231xx_enable_OSC(struct cx231xx *dev)
698{ 699{
699 cx231xx_set_gpio_value(dev, CX23417_OSC_EN, 1); 700 cx231xx_set_gpio_value(dev, CX23417_OSC_EN, 1);
700} 701}
701void cx231xx_sleep_s5h1432(struct cx231xx *dev) 702
703static void cx231xx_sleep_s5h1432(struct cx231xx *dev)
702{ 704{
703 cx231xx_set_gpio_value(dev, SLEEP_S5H1432, 0); 705 cx231xx_set_gpio_value(dev, SLEEP_S5H1432, 0);
704} 706}
diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c
index 781feed406f7..96a5a0965399 100644
--- a/drivers/media/usb/cx231xx/cx231xx-i2c.c
+++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c
@@ -72,8 +72,8 @@ static inline bool is_tuner(struct cx231xx *dev, struct cx231xx_i2c *bus,
72/* 72/*
73 * cx231xx_i2c_send_bytes() 73 * cx231xx_i2c_send_bytes()
74 */ 74 */
75int cx231xx_i2c_send_bytes(struct i2c_adapter *i2c_adap, 75static int cx231xx_i2c_send_bytes(struct i2c_adapter *i2c_adap,
76 const struct i2c_msg *msg) 76 const struct i2c_msg *msg)
77{ 77{
78 struct cx231xx_i2c *bus = i2c_adap->algo_data; 78 struct cx231xx_i2c *bus = i2c_adap->algo_data;
79 struct cx231xx *dev = bus->dev; 79 struct cx231xx *dev = bus->dev;
diff --git a/drivers/media/usb/cx231xx/cx231xx-input.c b/drivers/media/usb/cx231xx/cx231xx-input.c
index 96176e9db5a2..0f7b42446826 100644
--- a/drivers/media/usb/cx231xx/cx231xx-input.c
+++ b/drivers/media/usb/cx231xx/cx231xx-input.c
@@ -99,7 +99,7 @@ int cx231xx_ir_init(struct cx231xx *dev)
99 /* The i2c micro-controller only outputs the cmd part of NEC protocol */ 99 /* The i2c micro-controller only outputs the cmd part of NEC protocol */
100 dev->init_data.rc_dev->scanmask = 0xff; 100 dev->init_data.rc_dev->scanmask = 0xff;
101 dev->init_data.rc_dev->driver_name = "cx231xx"; 101 dev->init_data.rc_dev->driver_name = "cx231xx";
102 dev->init_data.type = RC_TYPE_NEC; 102 dev->init_data.type = RC_BIT_NEC;
103 info.addr = 0x30; 103 info.addr = 0x30;
104 104
105 /* Load and bind ir-kbd-i2c */ 105 /* Load and bind ir-kbd-i2c */
diff --git a/drivers/media/usb/dvb-usb-v2/af9015.c b/drivers/media/usb/dvb-usb-v2/af9015.c
index 3d7526e28d42..943d93423705 100644
--- a/drivers/media/usb/dvb-usb-v2/af9015.c
+++ b/drivers/media/usb/dvb-usb-v2/af9015.c
@@ -1306,7 +1306,7 @@ static int af9015_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc)
1306 if (!rc->map_name) 1306 if (!rc->map_name)
1307 rc->map_name = RC_MAP_EMPTY; 1307 rc->map_name = RC_MAP_EMPTY;
1308 1308
1309 rc->allowed_protos = RC_TYPE_NEC; 1309 rc->allowed_protos = RC_BIT_NEC;
1310 rc->query = af9015_rc_query; 1310 rc->query = af9015_rc_query;
1311 rc->interval = 500; 1311 rc->interval = 500;
1312 1312
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
index ea27eaff4e34..61ae7f9d0b27 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -1023,10 +1023,10 @@ static int af9035_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc)
1023 switch (tmp) { 1023 switch (tmp) {
1024 case 0: /* NEC */ 1024 case 0: /* NEC */
1025 default: 1025 default:
1026 rc->allowed_protos = RC_TYPE_NEC; 1026 rc->allowed_protos = RC_BIT_NEC;
1027 break; 1027 break;
1028 case 1: /* RC6 */ 1028 case 1: /* RC6 */
1029 rc->allowed_protos = RC_TYPE_RC6; 1029 rc->allowed_protos = RC_BIT_RC6_MCE;
1030 break; 1030 break;
1031 } 1031 }
1032 1032
diff --git a/drivers/media/usb/dvb-usb-v2/anysee.c b/drivers/media/usb/dvb-usb-v2/anysee.c
index ec540140c810..d05c5b563dac 100644
--- a/drivers/media/usb/dvb-usb-v2/anysee.c
+++ b/drivers/media/usb/dvb-usb-v2/anysee.c
@@ -1048,7 +1048,7 @@ static int anysee_rc_query(struct dvb_usb_device *d)
1048 1048
1049static int anysee_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc) 1049static int anysee_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc)
1050{ 1050{
1051 rc->allowed_protos = RC_TYPE_NEC; 1051 rc->allowed_protos = RC_BIT_NEC;
1052 rc->query = anysee_rc_query; 1052 rc->query = anysee_rc_query;
1053 rc->interval = 250; /* windows driver uses 500ms */ 1053 rc->interval = 250; /* windows driver uses 500ms */
1054 1054
@@ -1170,7 +1170,7 @@ static int anysee_ci_poll_slot_status(struct dvb_ca_en50221 *ci, int slot,
1170 struct dvb_usb_device *d = ci->data; 1170 struct dvb_usb_device *d = ci->data;
1171 struct anysee_state *state = d_to_priv(d); 1171 struct anysee_state *state = d_to_priv(d);
1172 int ret; 1172 int ret;
1173 u8 tmp; 1173 u8 tmp = 0;
1174 1174
1175 ret = anysee_rd_reg_mask(d, REG_IOC, &tmp, 0x40); 1175 ret = anysee_rd_reg_mask(d, REG_IOC, &tmp, 0x40);
1176 if (ret) 1176 if (ret)
diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c
index 54f1221d930d..d75dbf27e99e 100644
--- a/drivers/media/usb/dvb-usb-v2/az6007.c
+++ b/drivers/media/usb/dvb-usb-v2/az6007.c
@@ -826,7 +826,7 @@ static int az6007_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc)
826{ 826{
827 pr_debug("Getting az6007 Remote Control properties\n"); 827 pr_debug("Getting az6007 Remote Control properties\n");
828 828
829 rc->allowed_protos = RC_TYPE_NEC; 829 rc->allowed_protos = RC_BIT_NEC;
830 rc->query = az6007_rc_query; 830 rc->query = az6007_rc_query;
831 rc->interval = 400; 831 rc->interval = 400;
832 832
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb.h b/drivers/media/usb/dvb-usb-v2/dvb_usb.h
index bae16a1189d6..059291b892b8 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb.h
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb.h
@@ -137,7 +137,7 @@ struct dvb_usb_driver_info {
137struct dvb_usb_rc { 137struct dvb_usb_rc {
138 const char *map_name; 138 const char *map_name;
139 u64 allowed_protos; 139 u64 allowed_protos;
140 int (*change_protocol)(struct rc_dev *dev, u64 rc_type); 140 int (*change_protocol)(struct rc_dev *dev, u64 *rc_type);
141 int (*query) (struct dvb_usb_device *d); 141 int (*query) (struct dvb_usb_device *d);
142 unsigned int interval; 142 unsigned int interval;
143 const enum rc_driver_type driver_type; 143 const enum rc_driver_type driver_type;
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
index ba51f65204de..671b4fa232b4 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
@@ -224,7 +224,7 @@ static void dvb_usb_data_complete_raw(struct usb_data_stream *stream, u8 *buf,
224 dvb_dmx_swfilter_raw(&adap->demux, buf, len); 224 dvb_dmx_swfilter_raw(&adap->demux, buf, len);
225} 225}
226 226
227int dvb_usbv2_adapter_stream_init(struct dvb_usb_adapter *adap) 227static int dvb_usbv2_adapter_stream_init(struct dvb_usb_adapter *adap)
228{ 228{
229 dev_dbg(&adap_to_d(adap)->udev->dev, "%s: adap=%d\n", __func__, 229 dev_dbg(&adap_to_d(adap)->udev->dev, "%s: adap=%d\n", __func__,
230 adap->id); 230 adap->id);
@@ -236,7 +236,7 @@ int dvb_usbv2_adapter_stream_init(struct dvb_usb_adapter *adap)
236 return usb_urb_initv2(&adap->stream, &adap->props->stream); 236 return usb_urb_initv2(&adap->stream, &adap->props->stream);
237} 237}
238 238
239int dvb_usbv2_adapter_stream_exit(struct dvb_usb_adapter *adap) 239static int dvb_usbv2_adapter_stream_exit(struct dvb_usb_adapter *adap)
240{ 240{
241 dev_dbg(&adap_to_d(adap)->udev->dev, "%s: adap=%d\n", __func__, 241 dev_dbg(&adap_to_d(adap)->udev->dev, "%s: adap=%d\n", __func__,
242 adap->id); 242 adap->id);
@@ -368,7 +368,7 @@ static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
368 return dvb_usb_ctrl_feed(dvbdmxfeed, -1); 368 return dvb_usb_ctrl_feed(dvbdmxfeed, -1);
369} 369}
370 370
371int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap) 371static int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap)
372{ 372{
373 int ret; 373 int ret;
374 struct dvb_usb_device *d = adap_to_d(adap); 374 struct dvb_usb_device *d = adap_to_d(adap);
@@ -440,7 +440,7 @@ err_dvb_register_adapter:
440 return ret; 440 return ret;
441} 441}
442 442
443int dvb_usbv2_adapter_dvb_exit(struct dvb_usb_adapter *adap) 443static int dvb_usbv2_adapter_dvb_exit(struct dvb_usb_adapter *adap)
444{ 444{
445 dev_dbg(&adap_to_d(adap)->udev->dev, "%s: adap=%d\n", __func__, 445 dev_dbg(&adap_to_d(adap)->udev->dev, "%s: adap=%d\n", __func__,
446 adap->id); 446 adap->id);
@@ -456,7 +456,7 @@ int dvb_usbv2_adapter_dvb_exit(struct dvb_usb_adapter *adap)
456 return 0; 456 return 0;
457} 457}
458 458
459int dvb_usbv2_device_power_ctrl(struct dvb_usb_device *d, int onoff) 459static int dvb_usbv2_device_power_ctrl(struct dvb_usb_device *d, int onoff)
460{ 460{
461 int ret; 461 int ret;
462 462
@@ -553,7 +553,7 @@ err:
553 return ret; 553 return ret;
554} 554}
555 555
556int dvb_usbv2_adapter_frontend_init(struct dvb_usb_adapter *adap) 556static int dvb_usbv2_adapter_frontend_init(struct dvb_usb_adapter *adap)
557{ 557{
558 int ret, i, count_registered = 0; 558 int ret, i, count_registered = 0;
559 struct dvb_usb_device *d = adap_to_d(adap); 559 struct dvb_usb_device *d = adap_to_d(adap);
@@ -622,7 +622,7 @@ err:
622 return ret; 622 return ret;
623} 623}
624 624
625int dvb_usbv2_adapter_frontend_exit(struct dvb_usb_adapter *adap) 625static int dvb_usbv2_adapter_frontend_exit(struct dvb_usb_adapter *adap)
626{ 626{
627 int i; 627 int i;
628 dev_dbg(&adap_to_d(adap)->udev->dev, "%s: adap=%d\n", __func__, 628 dev_dbg(&adap_to_d(adap)->udev->dev, "%s: adap=%d\n", __func__,
diff --git a/drivers/media/usb/dvb-usb-v2/it913x.c b/drivers/media/usb/dvb-usb-v2/it913x.c
index 695f9106bc54..47204280b8b3 100644
--- a/drivers/media/usb/dvb-usb-v2/it913x.c
+++ b/drivers/media/usb/dvb-usb-v2/it913x.c
@@ -659,13 +659,19 @@ static int it913x_frontend_attach(struct dvb_usb_adapter *adap)
659 it913x_wr_reg(d, DEV_0_DMOD, MP2IF2_SW_RST, 0x1); 659 it913x_wr_reg(d, DEV_0_DMOD, MP2IF2_SW_RST, 0x1);
660 it913x_wr_reg(d, DEV_0, EP0_TX_EN, 0x0f); 660 it913x_wr_reg(d, DEV_0, EP0_TX_EN, 0x0f);
661 it913x_wr_reg(d, DEV_0, EP0_TX_NAK, 0x1b); 661 it913x_wr_reg(d, DEV_0, EP0_TX_NAK, 0x1b);
662 it913x_wr_reg(d, DEV_0, EP0_TX_EN, 0x2f); 662 if (st->proprietary_ir == false) /* Enable endpoint 3 */
663 it913x_wr_reg(d, DEV_0, EP0_TX_EN, 0x3f);
664 else
665 it913x_wr_reg(d, DEV_0, EP0_TX_EN, 0x2f);
663 it913x_wr_reg(d, DEV_0, EP4_TX_LEN_LSB, 666 it913x_wr_reg(d, DEV_0, EP4_TX_LEN_LSB,
664 ep_size & 0xff); 667 ep_size & 0xff);
665 it913x_wr_reg(d, DEV_0, EP4_TX_LEN_MSB, ep_size >> 8); 668 it913x_wr_reg(d, DEV_0, EP4_TX_LEN_MSB, ep_size >> 8);
666 ret = it913x_wr_reg(d, DEV_0, EP4_MAX_PKT, pkt_size); 669 ret = it913x_wr_reg(d, DEV_0, EP4_MAX_PKT, pkt_size);
667 } else if (adap->id == 1 && adap->fe[0]) { 670 } else if (adap->id == 1 && adap->fe[0]) {
668 it913x_wr_reg(d, DEV_0, EP0_TX_EN, 0x6f); 671 if (st->proprietary_ir == false)
672 it913x_wr_reg(d, DEV_0, EP0_TX_EN, 0x7f);
673 else
674 it913x_wr_reg(d, DEV_0, EP0_TX_EN, 0x6f);
669 it913x_wr_reg(d, DEV_0, EP5_TX_LEN_LSB, 675 it913x_wr_reg(d, DEV_0, EP5_TX_LEN_LSB,
670 ep_size & 0xff); 676 ep_size & 0xff);
671 it913x_wr_reg(d, DEV_0, EP5_TX_LEN_MSB, ep_size >> 8); 677 it913x_wr_reg(d, DEV_0, EP5_TX_LEN_MSB, ep_size >> 8);
@@ -698,7 +704,7 @@ static int it913x_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc)
698 return 0; 704 return 0;
699 } 705 }
700 706
701 rc->allowed_protos = RC_TYPE_NEC; 707 rc->allowed_protos = RC_BIT_NEC;
702 rc->query = it913x_rc_query; 708 rc->query = it913x_rc_query;
703 rc->interval = 250; 709 rc->interval = 250;
704 710
diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c
index c41d9d9ec7b5..6427ac359f21 100644
--- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
+++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
@@ -799,7 +799,7 @@ static const char fw_c_rs2000[] = LME2510_C_RS2000;
799static const char fw_lg[] = LME2510_LG; 799static const char fw_lg[] = LME2510_LG;
800static const char fw_s0194[] = LME2510_S0194; 800static const char fw_s0194[] = LME2510_S0194;
801 801
802const char *lme_firmware_switch(struct dvb_usb_device *d, int cold) 802static const char *lme_firmware_switch(struct dvb_usb_device *d, int cold)
803{ 803{
804 struct lme2510_state *st = d->priv; 804 struct lme2510_state *st = d->priv;
805 struct usb_device *udev = d->udev; 805 struct usb_device *udev = d->udev;
@@ -1253,7 +1253,7 @@ static int lme2510_get_stream_config(struct dvb_frontend *fe, u8 *ts_type,
1253static int lme2510_get_rc_config(struct dvb_usb_device *d, 1253static int lme2510_get_rc_config(struct dvb_usb_device *d,
1254 struct dvb_usb_rc *rc) 1254 struct dvb_usb_rc *rc)
1255{ 1255{
1256 rc->allowed_protos = RC_TYPE_NEC; 1256 rc->allowed_protos = RC_BIT_NEC;
1257 return 0; 1257 return 0;
1258} 1258}
1259 1259
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index 093f1acce403..a4c302d0aa37 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -1197,7 +1197,7 @@ static int rtl2831u_get_rc_config(struct dvb_usb_device *d,
1197 struct dvb_usb_rc *rc) 1197 struct dvb_usb_rc *rc)
1198{ 1198{
1199 rc->map_name = RC_MAP_EMPTY; 1199 rc->map_name = RC_MAP_EMPTY;
1200 rc->allowed_protos = RC_TYPE_NEC; 1200 rc->allowed_protos = RC_BIT_NEC;
1201 rc->query = rtl2831u_rc_query; 1201 rc->query = rtl2831u_rc_query;
1202 rc->interval = 400; 1202 rc->interval = 400;
1203 1203
@@ -1269,7 +1269,7 @@ static int rtl2832u_get_rc_config(struct dvb_usb_device *d,
1269 struct dvb_usb_rc *rc) 1269 struct dvb_usb_rc *rc)
1270{ 1270{
1271 rc->map_name = RC_MAP_EMPTY; 1271 rc->map_name = RC_MAP_EMPTY;
1272 rc->allowed_protos = RC_TYPE_NEC; 1272 rc->allowed_protos = RC_BIT_NEC;
1273 rc->query = rtl2832u_rc_query; 1273 rc->query = rtl2832u_rc_query;
1274 rc->interval = 400; 1274 rc->interval = 400;
1275 1275
@@ -1338,6 +1338,8 @@ static const struct usb_device_id rtl28xxu_id_table[] = {
1338 &rtl2832u_props, "G-Tek Electronics Group Lifeview LV5TDLX DVB-T", NULL) }, 1338 &rtl2832u_props, "G-Tek Electronics Group Lifeview LV5TDLX DVB-T", NULL) },
1339 { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK, 1339 { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK,
1340 &rtl2832u_props, "NOXON DAB/DAB+ USB dongle", NULL) }, 1340 &rtl2832u_props, "NOXON DAB/DAB+ USB dongle", NULL) },
1341 { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK_REV2,
1342 &rtl2832u_props, "NOXON DAB/DAB+ USB dongle (rev 2)", NULL) },
1341 { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_TREKSTOR_TERRES_2_0, 1343 { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_TREKSTOR_TERRES_2_0,
1342 &rtl2832u_props, "Trekstor DVB-T Stick Terres 2.0", NULL) }, 1344 &rtl2832u_props, "Trekstor DVB-T Stick Terres 2.0", NULL) },
1343 { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1101, 1345 { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1101,
diff --git a/drivers/media/usb/dvb-usb-v2/usb_urb.c b/drivers/media/usb/dvb-usb-v2/usb_urb.c
index 5989b6590377..7346f85f3f2f 100644
--- a/drivers/media/usb/dvb-usb-v2/usb_urb.c
+++ b/drivers/media/usb/dvb-usb-v2/usb_urb.c
@@ -112,7 +112,7 @@ int usb_urb_submitv2(struct usb_data_stream *stream,
112 return 0; 112 return 0;
113} 113}
114 114
115int usb_urb_free_urbs(struct usb_data_stream *stream) 115static int usb_urb_free_urbs(struct usb_data_stream *stream)
116{ 116{
117 int i; 117 int i;
118 118
@@ -205,7 +205,7 @@ static int usb_urb_alloc_isoc_urbs(struct usb_data_stream *stream)
205 return 0; 205 return 0;
206} 206}
207 207
208int usb_free_stream_buffers(struct usb_data_stream *stream) 208static int usb_free_stream_buffers(struct usb_data_stream *stream)
209{ 209{
210 if (stream->state & USB_STATE_URB_BUF) { 210 if (stream->state & USB_STATE_URB_BUF) {
211 while (stream->buf_num) { 211 while (stream->buf_num) {
@@ -223,8 +223,8 @@ int usb_free_stream_buffers(struct usb_data_stream *stream)
223 return 0; 223 return 0;
224} 224}
225 225
226int usb_alloc_stream_buffers(struct usb_data_stream *stream, int num, 226static int usb_alloc_stream_buffers(struct usb_data_stream *stream, int num,
227 unsigned long size) 227 unsigned long size)
228{ 228{
229 stream->buf_num = 0; 229 stream->buf_num = 0;
230 stream->buf_size = size; 230 stream->buf_size = size;
diff --git a/drivers/media/usb/dvb-usb/az6027.c b/drivers/media/usb/dvb-usb/az6027.c
index 5e45ae605427..91e0119e8a87 100644
--- a/drivers/media/usb/dvb-usb/az6027.c
+++ b/drivers/media/usb/dvb-usb/az6027.c
@@ -298,7 +298,8 @@ struct stb6100_config az6027_stb6100_config = {
298 298
299 299
300/* check for mutex FIXME */ 300/* check for mutex FIXME */
301int az6027_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) 301static int az6027_usb_in_op(struct dvb_usb_device *d, u8 req,
302 u16 value, u16 index, u8 *b, int blen)
302{ 303{
303 int ret = -1; 304 int ret = -1;
304 if (mutex_lock_interruptible(&d->usb_mutex)) 305 if (mutex_lock_interruptible(&d->usb_mutex))
@@ -1051,10 +1052,10 @@ static struct i2c_algorithm az6027_i2c_algo = {
1051 .functionality = az6027_i2c_func, 1052 .functionality = az6027_i2c_func,
1052}; 1053};
1053 1054
1054int az6027_identify_state(struct usb_device *udev, 1055static int az6027_identify_state(struct usb_device *udev,
1055 struct dvb_usb_device_properties *props, 1056 struct dvb_usb_device_properties *props,
1056 struct dvb_usb_device_description **desc, 1057 struct dvb_usb_device_description **desc,
1057 int *cold) 1058 int *cold)
1058{ 1059{
1059 u8 *b; 1060 u8 *b;
1060 s16 ret; 1061 s16 ret;
diff --git a/drivers/media/usb/dvb-usb/dib0700.h b/drivers/media/usb/dvb-usb/dib0700.h
index 7de125c0b36f..637b6123f391 100644
--- a/drivers/media/usb/dvb-usb/dib0700.h
+++ b/drivers/media/usb/dvb-usb/dib0700.h
@@ -64,7 +64,7 @@ extern int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff);
64extern struct i2c_algorithm dib0700_i2c_algo; 64extern struct i2c_algorithm dib0700_i2c_algo;
65extern int dib0700_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props, 65extern int dib0700_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props,
66 struct dvb_usb_device_description **desc, int *cold); 66 struct dvb_usb_device_description **desc, int *cold);
67extern int dib0700_change_protocol(struct rc_dev *dev, u64 rc_type); 67extern int dib0700_change_protocol(struct rc_dev *dev, u64 *rc_type);
68extern int dib0700_set_i2c_speed(struct dvb_usb_device *d, u16 scl_kHz); 68extern int dib0700_set_i2c_speed(struct dvb_usb_device *d, u16 scl_kHz);
69 69
70extern int dib0700_device_count; 70extern int dib0700_device_count;
diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c b/drivers/media/usb/dvb-usb/dib0700_core.c
index ef87229de6af..19b5ed2825d7 100644
--- a/drivers/media/usb/dvb-usb/dib0700_core.c
+++ b/drivers/media/usb/dvb-usb/dib0700_core.c
@@ -605,7 +605,7 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
605 return ret; 605 return ret;
606} 606}
607 607
608int dib0700_change_protocol(struct rc_dev *rc, u64 rc_type) 608int dib0700_change_protocol(struct rc_dev *rc, u64 *rc_type)
609{ 609{
610 struct dvb_usb_device *d = rc->priv; 610 struct dvb_usb_device *d = rc->priv;
611 struct dib0700_state *st = d->priv; 611 struct dib0700_state *st = d->priv;
@@ -621,17 +621,19 @@ int dib0700_change_protocol(struct rc_dev *rc, u64 rc_type)
621 st->buf[2] = 0; 621 st->buf[2] = 0;
622 622
623 /* Set the IR mode */ 623 /* Set the IR mode */
624 if (rc_type == RC_TYPE_RC5) 624 if (*rc_type & RC_BIT_RC5) {
625 new_proto = 1; 625 new_proto = 1;
626 else if (rc_type == RC_TYPE_NEC) 626 *rc_type = RC_BIT_RC5;
627 } else if (*rc_type & RC_BIT_NEC) {
627 new_proto = 0; 628 new_proto = 0;
628 else if (rc_type == RC_TYPE_RC6) { 629 *rc_type = RC_BIT_NEC;
630 } else if (*rc_type & RC_BIT_RC6_MCE) {
629 if (st->fw_version < 0x10200) { 631 if (st->fw_version < 0x10200) {
630 ret = -EINVAL; 632 ret = -EINVAL;
631 goto out; 633 goto out;
632 } 634 }
633
634 new_proto = 2; 635 new_proto = 2;
636 *rc_type = RC_BIT_RC6_MCE;
635 } else { 637 } else {
636 ret = -EINVAL; 638 ret = -EINVAL;
637 goto out; 639 goto out;
@@ -645,7 +647,7 @@ int dib0700_change_protocol(struct rc_dev *rc, u64 rc_type)
645 goto out; 647 goto out;
646 } 648 }
647 649
648 d->props.rc.core.protocol = rc_type; 650 d->props.rc.core.protocol = *rc_type;
649 651
650out: 652out:
651 mutex_unlock(&d->usb_mutex); 653 mutex_unlock(&d->usb_mutex);
@@ -707,7 +709,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
707 purb->actual_length); 709 purb->actual_length);
708 710
709 switch (d->props.rc.core.protocol) { 711 switch (d->props.rc.core.protocol) {
710 case RC_TYPE_NEC: 712 case RC_BIT_NEC:
711 toggle = 0; 713 toggle = 0;
712 714
713 /* NEC protocol sends repeat code as 0 0 0 FF */ 715 /* NEC protocol sends repeat code as 0 0 0 FF */
diff --git a/drivers/media/usb/dvb-usb/dib0700_devices.c b/drivers/media/usb/dvb-usb/dib0700_devices.c
index 510001da6e83..11798426fa88 100644
--- a/drivers/media/usb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/usb/dvb-usb/dib0700_devices.c
@@ -518,7 +518,7 @@ static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
518 518
519 d->last_event = 0; 519 d->last_event = 0;
520 switch (d->props.rc.core.protocol) { 520 switch (d->props.rc.core.protocol) {
521 case RC_TYPE_NEC: 521 case RC_BIT_NEC:
522 /* NEC protocol sends repeat code as 0 0 0 FF */ 522 /* NEC protocol sends repeat code as 0 0 0 FF */
523 if ((key[3-2] == 0x00) && (key[3-3] == 0x00) && 523 if ((key[3-2] == 0x00) && (key[3-3] == 0x00) &&
524 (key[3] == 0xff)) 524 (key[3] == 0xff))
@@ -3658,9 +3658,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
3658 .rc_interval = DEFAULT_RC_INTERVAL, 3658 .rc_interval = DEFAULT_RC_INTERVAL,
3659 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 3659 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
3660 .rc_query = dib0700_rc_query_old_firmware, 3660 .rc_query = dib0700_rc_query_old_firmware,
3661 .allowed_protos = RC_TYPE_RC5 | 3661 .allowed_protos = RC_BIT_RC5 |
3662 RC_TYPE_RC6 | 3662 RC_BIT_RC6_MCE |
3663 RC_TYPE_NEC, 3663 RC_BIT_NEC,
3664 .change_protocol = dib0700_change_protocol, 3664 .change_protocol = dib0700_change_protocol,
3665 }, 3665 },
3666 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 3666 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -3698,9 +3698,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
3698 .rc_interval = DEFAULT_RC_INTERVAL, 3698 .rc_interval = DEFAULT_RC_INTERVAL,
3699 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 3699 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
3700 .rc_query = dib0700_rc_query_old_firmware, 3700 .rc_query = dib0700_rc_query_old_firmware,
3701 .allowed_protos = RC_TYPE_RC5 | 3701 .allowed_protos = RC_BIT_RC5 |
3702 RC_TYPE_RC6 | 3702 RC_BIT_RC6_MCE |
3703 RC_TYPE_NEC, 3703 RC_BIT_NEC,
3704 .change_protocol = dib0700_change_protocol, 3704 .change_protocol = dib0700_change_protocol,
3705 }, 3705 },
3706 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 3706 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -3763,9 +3763,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
3763 .rc_interval = DEFAULT_RC_INTERVAL, 3763 .rc_interval = DEFAULT_RC_INTERVAL,
3764 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 3764 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
3765 .rc_query = dib0700_rc_query_old_firmware, 3765 .rc_query = dib0700_rc_query_old_firmware,
3766 .allowed_protos = RC_TYPE_RC5 | 3766 .allowed_protos = RC_BIT_RC5 |
3767 RC_TYPE_RC6 | 3767 RC_BIT_RC6_MCE |
3768 RC_TYPE_NEC, 3768 RC_BIT_NEC,
3769 .change_protocol = dib0700_change_protocol, 3769 .change_protocol = dib0700_change_protocol,
3770 }, 3770 },
3771 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 3771 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -3808,9 +3808,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
3808 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 3808 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
3809 .module_name = "dib0700", 3809 .module_name = "dib0700",
3810 .rc_query = dib0700_rc_query_old_firmware, 3810 .rc_query = dib0700_rc_query_old_firmware,
3811 .allowed_protos = RC_TYPE_RC5 | 3811 .allowed_protos = RC_BIT_RC5 |
3812 RC_TYPE_RC6 | 3812 RC_BIT_RC6_MCE |
3813 RC_TYPE_NEC, 3813 RC_BIT_NEC,
3814 .change_protocol = dib0700_change_protocol, 3814 .change_protocol = dib0700_change_protocol,
3815 }, 3815 },
3816 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 3816 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -3890,9 +3890,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
3890 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 3890 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
3891 .module_name = "dib0700", 3891 .module_name = "dib0700",
3892 .rc_query = dib0700_rc_query_old_firmware, 3892 .rc_query = dib0700_rc_query_old_firmware,
3893 .allowed_protos = RC_TYPE_RC5 | 3893 .allowed_protos = RC_BIT_RC5 |
3894 RC_TYPE_RC6 | 3894 RC_BIT_RC6_MCE |
3895 RC_TYPE_NEC, 3895 RC_BIT_NEC,
3896 .change_protocol = dib0700_change_protocol, 3896 .change_protocol = dib0700_change_protocol,
3897 }, 3897 },
3898 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 3898 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -3936,9 +3936,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
3936 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 3936 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
3937 .module_name = "dib0700", 3937 .module_name = "dib0700",
3938 .rc_query = dib0700_rc_query_old_firmware, 3938 .rc_query = dib0700_rc_query_old_firmware,
3939 .allowed_protos = RC_TYPE_RC5 | 3939 .allowed_protos = RC_BIT_RC5 |
3940 RC_TYPE_RC6 | 3940 RC_BIT_RC6_MCE |
3941 RC_TYPE_NEC, 3941 RC_BIT_NEC,
3942 .change_protocol = dib0700_change_protocol, 3942 .change_protocol = dib0700_change_protocol,
3943 }, 3943 },
3944 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 3944 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -3987,9 +3987,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
3987 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 3987 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
3988 .module_name = "dib0700", 3988 .module_name = "dib0700",
3989 .rc_query = dib0700_rc_query_old_firmware, 3989 .rc_query = dib0700_rc_query_old_firmware,
3990 .allowed_protos = RC_TYPE_RC5 | 3990 .allowed_protos = RC_BIT_RC5 |
3991 RC_TYPE_RC6 | 3991 RC_BIT_RC6_MCE |
3992 RC_TYPE_NEC, 3992 RC_BIT_NEC,
3993 .change_protocol = dib0700_change_protocol, 3993 .change_protocol = dib0700_change_protocol,
3994 }, 3994 },
3995 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 3995 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4055,9 +4055,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4055 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4055 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4056 .module_name = "dib0700", 4056 .module_name = "dib0700",
4057 .rc_query = dib0700_rc_query_old_firmware, 4057 .rc_query = dib0700_rc_query_old_firmware,
4058 .allowed_protos = RC_TYPE_RC5 | 4058 .allowed_protos = RC_BIT_RC5 |
4059 RC_TYPE_RC6 | 4059 RC_BIT_RC6_MCE |
4060 RC_TYPE_NEC, 4060 RC_BIT_NEC,
4061 .change_protocol = dib0700_change_protocol, 4061 .change_protocol = dib0700_change_protocol,
4062 }, 4062 },
4063 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4063 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4106,9 +4106,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4106 .rc_codes = RC_MAP_DIB0700_NEC_TABLE, 4106 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
4107 .module_name = "dib0700", 4107 .module_name = "dib0700",
4108 .rc_query = dib0700_rc_query_old_firmware, 4108 .rc_query = dib0700_rc_query_old_firmware,
4109 .allowed_protos = RC_TYPE_RC5 | 4109 .allowed_protos = RC_BIT_RC5 |
4110 RC_TYPE_RC6 | 4110 RC_BIT_RC6_MCE |
4111 RC_TYPE_NEC, 4111 RC_BIT_NEC,
4112 .change_protocol = dib0700_change_protocol, 4112 .change_protocol = dib0700_change_protocol,
4113 }, 4113 },
4114 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4114 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4177,9 +4177,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4177 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4177 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4178 .module_name = "dib0700", 4178 .module_name = "dib0700",
4179 .rc_query = dib0700_rc_query_old_firmware, 4179 .rc_query = dib0700_rc_query_old_firmware,
4180 .allowed_protos = RC_TYPE_RC5 | 4180 .allowed_protos = RC_BIT_RC5 |
4181 RC_TYPE_RC6 | 4181 RC_BIT_RC6_MCE |
4182 RC_TYPE_NEC, 4182 RC_BIT_NEC,
4183 .change_protocol = dib0700_change_protocol, 4183 .change_protocol = dib0700_change_protocol,
4184 }, 4184 },
4185 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4185 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4215,9 +4215,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4215 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4215 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4216 .module_name = "dib0700", 4216 .module_name = "dib0700",
4217 .rc_query = dib0700_rc_query_old_firmware, 4217 .rc_query = dib0700_rc_query_old_firmware,
4218 .allowed_protos = RC_TYPE_RC5 | 4218 .allowed_protos = RC_BIT_RC5 |
4219 RC_TYPE_RC6 | 4219 RC_BIT_RC6_MCE |
4220 RC_TYPE_NEC, 4220 RC_BIT_NEC,
4221 .change_protocol = dib0700_change_protocol, 4221 .change_protocol = dib0700_change_protocol,
4222 }, 4222 },
4223 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4223 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4295,9 +4295,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4295 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4295 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4296 .module_name = "dib0700", 4296 .module_name = "dib0700",
4297 .rc_query = dib0700_rc_query_old_firmware, 4297 .rc_query = dib0700_rc_query_old_firmware,
4298 .allowed_protos = RC_TYPE_RC5 | 4298 .allowed_protos = RC_BIT_RC5 |
4299 RC_TYPE_RC6 | 4299 RC_BIT_RC6_MCE |
4300 RC_TYPE_NEC, 4300 RC_BIT_NEC,
4301 .change_protocol = dib0700_change_protocol, 4301 .change_protocol = dib0700_change_protocol,
4302 }, 4302 },
4303 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4303 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4341,9 +4341,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4341 .rc_codes = RC_MAP_DIB0700_NEC_TABLE, 4341 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
4342 .module_name = "dib0700", 4342 .module_name = "dib0700",
4343 .rc_query = dib0700_rc_query_old_firmware, 4343 .rc_query = dib0700_rc_query_old_firmware,
4344 .allowed_protos = RC_TYPE_RC5 | 4344 .allowed_protos = RC_BIT_RC5 |
4345 RC_TYPE_RC6 | 4345 RC_BIT_RC6_MCE |
4346 RC_TYPE_NEC, 4346 RC_BIT_NEC,
4347 .change_protocol = dib0700_change_protocol, 4347 .change_protocol = dib0700_change_protocol,
4348 }, 4348 },
4349 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4349 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4394,9 +4394,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4394 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4394 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4395 .module_name = "dib0700", 4395 .module_name = "dib0700",
4396 .rc_query = dib0700_rc_query_old_firmware, 4396 .rc_query = dib0700_rc_query_old_firmware,
4397 .allowed_protos = RC_TYPE_RC5 | 4397 .allowed_protos = RC_BIT_RC5 |
4398 RC_TYPE_RC6 | 4398 RC_BIT_RC6_MCE |
4399 RC_TYPE_NEC, 4399 RC_BIT_NEC,
4400 .change_protocol = dib0700_change_protocol, 4400 .change_protocol = dib0700_change_protocol,
4401 }, 4401 },
4402 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4402 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4433,9 +4433,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4433 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4433 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4434 .module_name = "dib0700", 4434 .module_name = "dib0700",
4435 .rc_query = dib0700_rc_query_old_firmware, 4435 .rc_query = dib0700_rc_query_old_firmware,
4436 .allowed_protos = RC_TYPE_RC5 | 4436 .allowed_protos = RC_BIT_RC5 |
4437 RC_TYPE_RC6 | 4437 RC_BIT_RC6_MCE |
4438 RC_TYPE_NEC, 4438 RC_BIT_NEC,
4439 .change_protocol = dib0700_change_protocol, 4439 .change_protocol = dib0700_change_protocol,
4440 }, 4440 },
4441 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4441 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4472,9 +4472,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4472 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4472 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4473 .module_name = "dib0700", 4473 .module_name = "dib0700",
4474 .rc_query = dib0700_rc_query_old_firmware, 4474 .rc_query = dib0700_rc_query_old_firmware,
4475 .allowed_protos = RC_TYPE_RC5 | 4475 .allowed_protos = RC_BIT_RC5 |
4476 RC_TYPE_RC6 | 4476 RC_BIT_RC6_MCE |
4477 RC_TYPE_NEC, 4477 RC_BIT_NEC,
4478 .change_protocol = dib0700_change_protocol, 4478 .change_protocol = dib0700_change_protocol,
4479 }, 4479 },
4480 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4480 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4511,9 +4511,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4511 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4511 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4512 .module_name = "dib0700", 4512 .module_name = "dib0700",
4513 .rc_query = dib0700_rc_query_old_firmware, 4513 .rc_query = dib0700_rc_query_old_firmware,
4514 .allowed_protos = RC_TYPE_RC5 | 4514 .allowed_protos = RC_BIT_RC5 |
4515 RC_TYPE_RC6 | 4515 RC_BIT_RC6_MCE |
4516 RC_TYPE_NEC, 4516 RC_BIT_NEC,
4517 .change_protocol = dib0700_change_protocol, 4517 .change_protocol = dib0700_change_protocol,
4518 }, 4518 },
4519 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4519 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4550,9 +4550,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4550 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4550 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4551 .module_name = "dib0700", 4551 .module_name = "dib0700",
4552 .rc_query = dib0700_rc_query_old_firmware, 4552 .rc_query = dib0700_rc_query_old_firmware,
4553 .allowed_protos = RC_TYPE_RC5 | 4553 .allowed_protos = RC_BIT_RC5 |
4554 RC_TYPE_RC6 | 4554 RC_BIT_RC6_MCE |
4555 RC_TYPE_NEC, 4555 RC_BIT_NEC,
4556 .change_protocol = dib0700_change_protocol, 4556 .change_protocol = dib0700_change_protocol,
4557 }, 4557 },
4558 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4558 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4589,9 +4589,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4589 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4589 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4590 .module_name = "dib0700", 4590 .module_name = "dib0700",
4591 .rc_query = dib0700_rc_query_old_firmware, 4591 .rc_query = dib0700_rc_query_old_firmware,
4592 .allowed_protos = RC_TYPE_RC5 | 4592 .allowed_protos = RC_BIT_RC5 |
4593 RC_TYPE_RC6 | 4593 RC_BIT_RC6_MCE |
4594 RC_TYPE_NEC, 4594 RC_BIT_NEC,
4595 .change_protocol = dib0700_change_protocol, 4595 .change_protocol = dib0700_change_protocol,
4596 }, 4596 },
4597 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4597 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4644,9 +4644,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4644 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4644 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4645 .module_name = "dib0700", 4645 .module_name = "dib0700",
4646 .rc_query = dib0700_rc_query_old_firmware, 4646 .rc_query = dib0700_rc_query_old_firmware,
4647 .allowed_protos = RC_TYPE_RC5 | 4647 .allowed_protos = RC_BIT_RC5 |
4648 RC_TYPE_RC6 | 4648 RC_BIT_RC6_MCE |
4649 RC_TYPE_NEC, 4649 RC_BIT_NEC,
4650 .change_protocol = dib0700_change_protocol, 4650 .change_protocol = dib0700_change_protocol,
4651 }, 4651 },
4652 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4652 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4681,9 +4681,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4681 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4681 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4682 .module_name = "dib0700", 4682 .module_name = "dib0700",
4683 .rc_query = dib0700_rc_query_old_firmware, 4683 .rc_query = dib0700_rc_query_old_firmware,
4684 .allowed_protos = RC_TYPE_RC5 | 4684 .allowed_protos = RC_BIT_RC5 |
4685 RC_TYPE_RC6 | 4685 RC_BIT_RC6_MCE |
4686 RC_TYPE_NEC, 4686 RC_BIT_NEC,
4687 .change_protocol = dib0700_change_protocol, 4687 .change_protocol = dib0700_change_protocol,
4688 }, 4688 },
4689 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4689 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4721,9 +4721,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4721 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4721 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4722 .module_name = "dib0700", 4722 .module_name = "dib0700",
4723 .rc_query = dib0700_rc_query_old_firmware, 4723 .rc_query = dib0700_rc_query_old_firmware,
4724 .allowed_protos = RC_TYPE_RC5 | 4724 .allowed_protos = RC_BIT_RC5 |
4725 RC_TYPE_RC6 | 4725 RC_BIT_RC6_MCE |
4726 RC_TYPE_NEC, 4726 RC_BIT_NEC,
4727 .change_protocol = dib0700_change_protocol, 4727 .change_protocol = dib0700_change_protocol,
4728 }, 4728 },
4729 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4729 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4761,9 +4761,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4761 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4761 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4762 .module_name = "dib0700", 4762 .module_name = "dib0700",
4763 .rc_query = dib0700_rc_query_old_firmware, 4763 .rc_query = dib0700_rc_query_old_firmware,
4764 .allowed_protos = RC_TYPE_RC5 | 4764 .allowed_protos = RC_BIT_RC5 |
4765 RC_TYPE_RC6 | 4765 RC_BIT_RC6_MCE |
4766 RC_TYPE_NEC, 4766 RC_BIT_NEC,
4767 .change_protocol = dib0700_change_protocol, 4767 .change_protocol = dib0700_change_protocol,
4768 }, 4768 },
4769 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4769 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4802,9 +4802,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4802 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4802 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4803 .module_name = "dib0700", 4803 .module_name = "dib0700",
4804 .rc_query = dib0700_rc_query_old_firmware, 4804 .rc_query = dib0700_rc_query_old_firmware,
4805 .allowed_protos = RC_TYPE_RC5 | 4805 .allowed_protos = RC_BIT_RC5 |
4806 RC_TYPE_RC6 | 4806 RC_BIT_RC6_MCE |
4807 RC_TYPE_NEC, 4807 RC_BIT_NEC,
4808 .change_protocol = dib0700_change_protocol, 4808 .change_protocol = dib0700_change_protocol,
4809 }, 4809 },
4810 }, 4810 },
diff --git a/drivers/media/usb/dvb-usb/dvb-usb.h b/drivers/media/usb/dvb-usb/dvb-usb.h
index aab0f99bc892..ce4c4e3b58bb 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb.h
+++ b/drivers/media/usb/dvb-usb/dvb-usb.h
@@ -202,7 +202,7 @@ struct dvb_rc {
202 u64 protocol; 202 u64 protocol;
203 u64 allowed_protos; 203 u64 allowed_protos;
204 enum rc_driver_type driver_type; 204 enum rc_driver_type driver_type;
205 int (*change_protocol)(struct rc_dev *dev, u64 rc_type); 205 int (*change_protocol)(struct rc_dev *dev, u64 *rc_type);
206 char *module_name; 206 char *module_name;
207 int (*rc_query) (struct dvb_usb_device *d); 207 int (*rc_query) (struct dvb_usb_device *d);
208 int rc_interval; 208 int rc_interval;
diff --git a/drivers/media/usb/dvb-usb/pctv452e.c b/drivers/media/usb/dvb-usb/pctv452e.c
index 02e878577c3d..d1ddfa13de86 100644
--- a/drivers/media/usb/dvb-usb/pctv452e.c
+++ b/drivers/media/usb/dvb-usb/pctv452e.c
@@ -927,7 +927,7 @@ static struct dvb_usb_device_properties pctv452e_properties = {
927 927
928 .rc.core = { 928 .rc.core = {
929 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 929 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
930 .allowed_protos = RC_TYPE_UNKNOWN, 930 .allowed_protos = RC_BIT_UNKNOWN,
931 .rc_query = pctv452e_rc_query, 931 .rc_query = pctv452e_rc_query,
932 .rc_interval = 100, 932 .rc_interval = 100,
933 }, 933 },
@@ -980,7 +980,7 @@ static struct dvb_usb_device_properties tt_connect_s2_3600_properties = {
980 980
981 .rc.core = { 981 .rc.core = {
982 .rc_codes = RC_MAP_TT_1500, 982 .rc_codes = RC_MAP_TT_1500,
983 .allowed_protos = RC_TYPE_UNKNOWN, 983 .allowed_protos = RC_BIT_UNKNOWN,
984 .rc_query = pctv452e_rc_query, 984 .rc_query = pctv452e_rc_query,
985 .rc_interval = 100, 985 .rc_interval = 100,
986 }, 986 },
diff --git a/drivers/media/usb/dvb-usb/technisat-usb2.c b/drivers/media/usb/dvb-usb/technisat-usb2.c
index 7a8c8c18590f..40832a1aef6c 100644
--- a/drivers/media/usb/dvb-usb/technisat-usb2.c
+++ b/drivers/media/usb/dvb-usb/technisat-usb2.c
@@ -732,7 +732,7 @@ static struct dvb_usb_device_properties technisat_usb2_devices = {
732 .rc_codes = RC_MAP_TECHNISAT_USB2, 732 .rc_codes = RC_MAP_TECHNISAT_USB2,
733 .module_name = "technisat-usb2", 733 .module_name = "technisat-usb2",
734 .rc_query = technisat_usb2_rc_query, 734 .rc_query = technisat_usb2_rc_query,
735 .allowed_protos = RC_TYPE_ALL, 735 .allowed_protos = RC_BIT_ALL,
736 .driver_type = RC_DRIVER_IR_RAW, 736 .driver_type = RC_DRIVER_IR_RAW,
737 } 737 }
738}; 738};
diff --git a/drivers/media/usb/dvb-usb/ttusb2.c b/drivers/media/usb/dvb-usb/ttusb2.c
index 6a50cdea3bce..bcdac225ebe1 100644
--- a/drivers/media/usb/dvb-usb/ttusb2.c
+++ b/drivers/media/usb/dvb-usb/ttusb2.c
@@ -741,7 +741,7 @@ static struct dvb_usb_device_properties ttusb2_properties_ct3650 = {
741 .rc_interval = 150, /* Less than IR_KEYPRESS_TIMEOUT */ 741 .rc_interval = 150, /* Less than IR_KEYPRESS_TIMEOUT */
742 .rc_codes = RC_MAP_TT_1500, 742 .rc_codes = RC_MAP_TT_1500,
743 .rc_query = tt3650_rc_query, 743 .rc_query = tt3650_rc_query,
744 .allowed_protos = RC_TYPE_UNKNOWN, 744 .allowed_protos = RC_BIT_UNKNOWN,
745 }, 745 },
746 746
747 .num_adapters = 1, 747 .num_adapters = 1,
diff --git a/drivers/media/usb/dvb-usb/vp702x.c b/drivers/media/usb/dvb-usb/vp702x.c
index 07c673a6e764..22cf9f96cb9e 100644
--- a/drivers/media/usb/dvb-usb/vp702x.c
+++ b/drivers/media/usb/dvb-usb/vp702x.c
@@ -56,7 +56,7 @@ static int vp702x_usb_in_op_unlocked(struct dvb_usb_device *d, u8 req,
56} 56}
57 57
58int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, 58int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value,
59 u16 index, u8 *b, int blen) 59 u16 index, u8 *b, int blen)
60{ 60{
61 int ret; 61 int ret;
62 62
@@ -67,8 +67,8 @@ int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value,
67 return ret; 67 return ret;
68} 68}
69 69
70int vp702x_usb_out_op_unlocked(struct dvb_usb_device *d, u8 req, u16 value, 70static int vp702x_usb_out_op_unlocked(struct dvb_usb_device *d, u8 req,
71 u16 index, u8 *b, int blen) 71 u16 value, u16 index, u8 *b, int blen)
72{ 72{
73 int ret; 73 int ret;
74 deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: ",req,value,index); 74 deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: ",req,value,index);
@@ -86,7 +86,7 @@ int vp702x_usb_out_op_unlocked(struct dvb_usb_device *d, u8 req, u16 value,
86 return 0; 86 return 0;
87} 87}
88 88
89int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, 89static int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
90 u16 index, u8 *b, int blen) 90 u16 index, u8 *b, int blen)
91{ 91{
92 int ret; 92 int ret;
diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c
index 16a84f9f46d8..619bffbab3bc 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -1979,6 +1979,15 @@ struct em28xx_board em28xx_boards[] = {
1979 EM28XX_I2C_CLK_WAIT_ENABLE | 1979 EM28XX_I2C_CLK_WAIT_ENABLE |
1980 EM28XX_I2C_FREQ_400_KHZ, 1980 EM28XX_I2C_FREQ_400_KHZ,
1981 }, 1981 },
1982 [EM2884_BOARD_TERRATEC_HTC_USB_XS] = {
1983 .name = "Terratec Cinergy HTC USB XS",
1984 .has_dvb = 1,
1985 .ir_codes = RC_MAP_NEC_TERRATEC_CINERGY_XS,
1986 .tuner_type = TUNER_ABSENT,
1987 .i2c_speed = EM2874_I2C_SECONDARY_BUS_SELECT |
1988 EM28XX_I2C_CLK_WAIT_ENABLE |
1989 EM28XX_I2C_FREQ_400_KHZ,
1990 },
1982}; 1991};
1983const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards); 1992const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
1984 1993
@@ -2057,9 +2066,9 @@ struct usb_device_id em28xx_id_table[] = {
2057 { USB_DEVICE(0x0ccd, 0x0043), 2066 { USB_DEVICE(0x0ccd, 0x0043),
2058 .driver_info = EM2870_BOARD_TERRATEC_XS }, 2067 .driver_info = EM2870_BOARD_TERRATEC_XS },
2059 { USB_DEVICE(0x0ccd, 0x008e), /* Cinergy HTC USB XS Rev. 1 */ 2068 { USB_DEVICE(0x0ccd, 0x008e), /* Cinergy HTC USB XS Rev. 1 */
2060 .driver_info = EM2884_BOARD_TERRATEC_H5 }, 2069 .driver_info = EM2884_BOARD_TERRATEC_HTC_USB_XS },
2061 { USB_DEVICE(0x0ccd, 0x00ac), /* Cinergy HTC USB XS Rev. 2 */ 2070 { USB_DEVICE(0x0ccd, 0x00ac), /* Cinergy HTC USB XS Rev. 2 */
2062 .driver_info = EM2884_BOARD_TERRATEC_H5 }, 2071 .driver_info = EM2884_BOARD_TERRATEC_HTC_USB_XS },
2063 { USB_DEVICE(0x0ccd, 0x10a2), /* H5 Rev. 1 */ 2072 { USB_DEVICE(0x0ccd, 0x10a2), /* H5 Rev. 1 */
2064 .driver_info = EM2884_BOARD_TERRATEC_H5 }, 2073 .driver_info = EM2884_BOARD_TERRATEC_H5 },
2065 { USB_DEVICE(0x0ccd, 0x10ad), /* H5 Rev. 2 */ 2074 { USB_DEVICE(0x0ccd, 0x10ad), /* H5 Rev. 2 */
@@ -3297,7 +3306,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3297 3306
3298 dev->num_alt = interface->num_altsetting; 3307 dev->num_alt = interface->num_altsetting;
3299 3308
3300 if ((card[nr] >= 0) && (card[nr] < em28xx_bcount)) 3309 if ((unsigned)card[nr] < em28xx_bcount)
3301 dev->model = card[nr]; 3310 dev->model = card[nr];
3302 3311
3303 /* save our data pointer in this interface device */ 3312 /* save our data pointer in this interface device */
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
index 13ae821949e9..63f2e7070c00 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -331,7 +331,7 @@ static struct drxk_config hauppauge_930c_drxk = {
331 .load_firmware_sync = true, 331 .load_firmware_sync = true,
332}; 332};
333 333
334struct drxk_config terratec_htc_stick_drxk = { 334static struct drxk_config terratec_htc_stick_drxk = {
335 .adr = 0x29, 335 .adr = 0x29,
336 .single_master = 1, 336 .single_master = 1,
337 .no_i2c_bridge = 1, 337 .no_i2c_bridge = 1,
@@ -520,7 +520,10 @@ static void terratec_htc_stick_init(struct em28xx *dev)
520 { -1, -1, -1, -1}, 520 { -1, -1, -1, -1},
521 }; 521 };
522 522
523 /* Init the analog decoder? */ 523 /*
524 * Init the analog decoder (not yet supported), but
525 * it's probably still a good idea.
526 */
524 struct { 527 struct {
525 unsigned char r[4]; 528 unsigned char r[4];
526 int len; 529 int len;
@@ -547,6 +550,64 @@ static void terratec_htc_stick_init(struct em28xx *dev)
547 em28xx_gpio_set(dev, terratec_htc_stick_end); 550 em28xx_gpio_set(dev, terratec_htc_stick_end);
548}; 551};
549 552
553static void terratec_htc_usb_xs_init(struct em28xx *dev)
554{
555 int i;
556
557 struct em28xx_reg_seq terratec_htc_usb_xs_init[] = {
558 {EM28XX_R08_GPIO, 0xff, 0xff, 10},
559 {EM2874_R80_GPIO, 0xb2, 0xff, 100},
560 {EM2874_R80_GPIO, 0xb2, 0xff, 50},
561 {EM2874_R80_GPIO, 0xb6, 0xff, 100},
562 { -1, -1, -1, -1},
563 };
564 struct em28xx_reg_seq terratec_htc_usb_xs_end[] = {
565 {EM2874_R80_GPIO, 0xa6, 0xff, 100},
566 {EM2874_R80_GPIO, 0xa6, 0xff, 50},
567 {EM2874_R80_GPIO, 0xe6, 0xff, 100},
568 { -1, -1, -1, -1},
569 };
570
571 /*
572 * Init the analog decoder (not yet supported), but
573 * it's probably still a good idea.
574 */
575 struct {
576 unsigned char r[4];
577 int len;
578 } regs[] = {
579 {{ 0x06, 0x02, 0x00, 0x31 }, 4},
580 {{ 0x01, 0x02 }, 2},
581 {{ 0x01, 0x02, 0x00, 0xc6 }, 4},
582 {{ 0x01, 0x00 }, 2},
583 {{ 0x01, 0x00, 0xff, 0xaf }, 4},
584 {{ 0x01, 0x00, 0x03, 0xa0 }, 4},
585 {{ 0x01, 0x00 }, 2},
586 {{ 0x01, 0x00, 0x73, 0xaf }, 4},
587 {{ 0x04, 0x00 }, 2},
588 {{ 0x00, 0x04 }, 2},
589 {{ 0x00, 0x04, 0x00, 0x0a }, 4},
590 {{ 0x04, 0x14 }, 2},
591 {{ 0x04, 0x14, 0x00, 0x00 }, 4},
592 };
593
594 em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40);
595
596 em28xx_gpio_set(dev, terratec_htc_usb_xs_init);
597
598 em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40);
599 msleep(10);
600 em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x44);
601 msleep(10);
602
603 dev->i2c_client.addr = 0x82 >> 1;
604
605 for (i = 0; i < ARRAY_SIZE(regs); i++)
606 i2c_master_send(&dev->i2c_client, regs[i].r, regs[i].len);
607
608 em28xx_gpio_set(dev, terratec_htc_usb_xs_end);
609};
610
550static void pctv_520e_init(struct em28xx *dev) 611static void pctv_520e_init(struct em28xx *dev)
551{ 612{
552 /* 613 /*
@@ -1155,6 +1216,25 @@ static int em28xx_dvb_init(struct em28xx *dev)
1155 goto out_free; 1216 goto out_free;
1156 } 1217 }
1157 break; 1218 break;
1219 case EM2884_BOARD_TERRATEC_HTC_USB_XS:
1220 terratec_htc_usb_xs_init(dev);
1221
1222 /* attach demodulator */
1223 dvb->fe[0] = dvb_attach(drxk_attach, &terratec_htc_stick_drxk,
1224 &dev->i2c_adap);
1225 if (!dvb->fe[0]) {
1226 result = -EINVAL;
1227 goto out_free;
1228 }
1229
1230 /* Attach the demodulator. */
1231 if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60,
1232 &dev->i2c_adap,
1233 &em28xx_cxd2820r_tda18271_config)) {
1234 result = -EINVAL;
1235 goto out_free;
1236 }
1237 break;
1158 default: 1238 default:
1159 em28xx_errdev("/2: The frontend of your DVB/ATSC card" 1239 em28xx_errdev("/2: The frontend of your DVB/ATSC card"
1160 " isn't supported yet\n"); 1240 " isn't supported yet\n");
diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c
index 97d36b4f19db..660bf803c9e4 100644
--- a/drivers/media/usb/em28xx/em28xx-input.c
+++ b/drivers/media/usb/em28xx/em28xx-input.c
@@ -345,7 +345,7 @@ static void em28xx_ir_stop(struct rc_dev *rc)
345 cancel_delayed_work_sync(&ir->work); 345 cancel_delayed_work_sync(&ir->work);
346} 346}
347 347
348static int em28xx_ir_change_protocol(struct rc_dev *rc_dev, u64 rc_type) 348static int em28xx_ir_change_protocol(struct rc_dev *rc_dev, u64 *rc_type)
349{ 349{
350 int rc = 0; 350 int rc = 0;
351 struct em28xx_IR *ir = rc_dev->priv; 351 struct em28xx_IR *ir = rc_dev->priv;
@@ -354,14 +354,16 @@ static int em28xx_ir_change_protocol(struct rc_dev *rc_dev, u64 rc_type)
354 354
355 /* Adjust xclk based o IR table for RC5/NEC tables */ 355 /* Adjust xclk based o IR table for RC5/NEC tables */
356 356
357 if (rc_type == RC_TYPE_RC5) { 357 if (*rc_type & RC_BIT_RC5) {
358 dev->board.xclk |= EM28XX_XCLK_IR_RC5_MODE; 358 dev->board.xclk |= EM28XX_XCLK_IR_RC5_MODE;
359 ir->full_code = 1; 359 ir->full_code = 1;
360 } else if (rc_type == RC_TYPE_NEC) { 360 *rc_type = RC_BIT_RC5;
361 } else if (*rc_type & RC_BIT_NEC) {
361 dev->board.xclk &= ~EM28XX_XCLK_IR_RC5_MODE; 362 dev->board.xclk &= ~EM28XX_XCLK_IR_RC5_MODE;
362 ir_config = EM2874_IR_NEC; 363 ir_config = EM2874_IR_NEC;
363 ir->full_code = 1; 364 ir->full_code = 1;
364 } else if (rc_type != RC_TYPE_UNKNOWN) 365 *rc_type = RC_BIT_NEC;
366 } else if (*rc_type != RC_BIT_UNKNOWN)
365 rc = -EINVAL; 367 rc = -EINVAL;
366 368
367 em28xx_write_reg_bits(dev, EM28XX_R0F_XCLK, dev->board.xclk, 369 em28xx_write_reg_bits(dev, EM28XX_R0F_XCLK, dev->board.xclk,
@@ -524,6 +526,7 @@ static int em28xx_ir_init(struct em28xx *dev)
524 struct em28xx_IR *ir; 526 struct em28xx_IR *ir;
525 struct rc_dev *rc; 527 struct rc_dev *rc;
526 int err = -ENOMEM; 528 int err = -ENOMEM;
529 u64 rc_type;
527 530
528 if (dev->board.ir_codes == NULL) { 531 if (dev->board.ir_codes == NULL) {
529 /* No remote control support */ 532 /* No remote control support */
@@ -546,14 +549,15 @@ static int em28xx_ir_init(struct em28xx *dev)
546 * em2874 supports more protocols. For now, let's just announce 549 * em2874 supports more protocols. For now, let's just announce
547 * the two protocols that were already tested 550 * the two protocols that were already tested
548 */ 551 */
549 rc->allowed_protos = RC_TYPE_RC5 | RC_TYPE_NEC; 552 rc->allowed_protos = RC_BIT_RC5 | RC_BIT_NEC;
550 rc->priv = ir; 553 rc->priv = ir;
551 rc->change_protocol = em28xx_ir_change_protocol; 554 rc->change_protocol = em28xx_ir_change_protocol;
552 rc->open = em28xx_ir_start; 555 rc->open = em28xx_ir_start;
553 rc->close = em28xx_ir_stop; 556 rc->close = em28xx_ir_stop;
554 557
555 /* By default, keep protocol field untouched */ 558 /* By default, keep protocol field untouched */
556 err = em28xx_ir_change_protocol(rc, RC_TYPE_UNKNOWN); 559 rc_type = RC_BIT_UNKNOWN;
560 err = em28xx_ir_change_protocol(rc, &rc_type);
557 if (err) 561 if (err)
558 goto err_out_free; 562 goto err_out_free;
559 563
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h
index 8757523e6863..86e90d86da6d 100644
--- a/drivers/media/usb/em28xx/em28xx.h
+++ b/drivers/media/usb/em28xx/em28xx.h
@@ -128,6 +128,7 @@
128#define EM2874_BOARD_MAXMEDIA_UB425_TC 84 128#define EM2874_BOARD_MAXMEDIA_UB425_TC 84
129#define EM2884_BOARD_PCTV_510E 85 129#define EM2884_BOARD_PCTV_510E 85
130#define EM2884_BOARD_PCTV_520E 86 130#define EM2884_BOARD_PCTV_520E 86
131#define EM2884_BOARD_TERRATEC_HTC_USB_XS 87
131 132
132/* Limits minimum and default number of buffers */ 133/* Limits minimum and default number of buffers */
133#define EM28XX_MIN_BUF 4 134#define EM28XX_MIN_BUF 4
diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index a2b934146ebf..e0a431bb0d42 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -1586,8 +1586,7 @@ static int vidioc_querybuf(struct file *file, void *priv,
1586 struct gspca_dev *gspca_dev = video_drvdata(file); 1586 struct gspca_dev *gspca_dev = video_drvdata(file);
1587 struct gspca_frame *frame; 1587 struct gspca_frame *frame;
1588 1588
1589 if (v4l2_buf->index < 0 1589 if (v4l2_buf->index >= gspca_dev->nframes)
1590 || v4l2_buf->index >= gspca_dev->nframes)
1591 return -EINVAL; 1590 return -EINVAL;
1592 1591
1593 frame = &gspca_dev->frame[v4l2_buf->index]; 1592 frame = &gspca_dev->frame[v4l2_buf->index];
diff --git a/drivers/media/usb/gspca/gspca.h b/drivers/media/usb/gspca/gspca.h
index e3eab82cd4e5..352317d7acdb 100644
--- a/drivers/media/usb/gspca/gspca.h
+++ b/drivers/media/usb/gspca/gspca.h
@@ -32,7 +32,7 @@ do { \
32#define D_USBO 0x00 32#define D_USBO 0x00
33#define D_V4L2 0x0100 33#define D_V4L2 0x0100
34#else 34#else
35#define PDEBUG(level, fmt, ...) 35#define PDEBUG(level, fmt, ...) do {} while(0)
36#endif 36#endif
37 37
38#define GSPCA_MAX_FRAMES 16 /* maximum number of video frame buffers */ 38#define GSPCA_MAX_FRAMES 16 /* maximum number of video frame buffers */
diff --git a/drivers/media/usb/gspca/jeilinj.c b/drivers/media/usb/gspca/jeilinj.c
index b897aa86f315..1ba29fe7fada 100644
--- a/drivers/media/usb/gspca/jeilinj.c
+++ b/drivers/media/usb/gspca/jeilinj.c
@@ -114,7 +114,7 @@ static void jlj_write2(struct gspca_dev *gspca_dev, unsigned char *command)
114} 114}
115 115
116/* Responses are one byte only */ 116/* Responses are one byte only */
117static void jlj_read1(struct gspca_dev *gspca_dev, unsigned char response) 117static void jlj_read1(struct gspca_dev *gspca_dev, unsigned char *response)
118{ 118{
119 int retval; 119 int retval;
120 120
@@ -123,7 +123,7 @@ static void jlj_read1(struct gspca_dev *gspca_dev, unsigned char response)
123 retval = usb_bulk_msg(gspca_dev->dev, 123 retval = usb_bulk_msg(gspca_dev->dev,
124 usb_rcvbulkpipe(gspca_dev->dev, 0x84), 124 usb_rcvbulkpipe(gspca_dev->dev, 0x84),
125 gspca_dev->usb_buf, 1, NULL, 500); 125 gspca_dev->usb_buf, 1, NULL, 500);
126 response = gspca_dev->usb_buf[0]; 126 *response = gspca_dev->usb_buf[0];
127 if (retval < 0) { 127 if (retval < 0) {
128 pr_err("read command [%02x] error %d\n", 128 pr_err("read command [%02x] error %d\n",
129 gspca_dev->usb_buf[0], retval); 129 gspca_dev->usb_buf[0], retval);
@@ -260,7 +260,7 @@ static int jlj_start(struct gspca_dev *gspca_dev)
260 if (start_commands[i].delay) 260 if (start_commands[i].delay)
261 msleep(start_commands[i].delay); 261 msleep(start_commands[i].delay);
262 if (start_commands[i].ack_wanted) 262 if (start_commands[i].ack_wanted)
263 jlj_read1(gspca_dev, response); 263 jlj_read1(gspca_dev, &response);
264 } 264 }
265 setcamquality(gspca_dev, v4l2_ctrl_g_ctrl(sd->jpegqual)); 265 setcamquality(gspca_dev, v4l2_ctrl_g_ctrl(sd->jpegqual));
266 msleep(2); 266 msleep(2);
diff --git a/drivers/media/usb/gspca/m5602/m5602_s5k4aa.c b/drivers/media/usb/gspca/m5602/m5602_s5k4aa.c
index cc8ec3f7e8dc..c8e1572eb502 100644
--- a/drivers/media/usb/gspca/m5602/m5602_s5k4aa.c
+++ b/drivers/media/usb/gspca/m5602/m5602_s5k4aa.c
@@ -74,6 +74,12 @@ static
74 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pa 2548") 74 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pa 2548")
75 } 75 }
76 }, { 76 }, {
77 .ident = "Fujitsu-Siemens Amilo Pi 2530",
78 .matches = {
79 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
80 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pi 2530")
81 }
82 }, {
77 .ident = "MSI GX700", 83 .ident = "MSI GX700",
78 .matches = { 84 .matches = {
79 DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star International"), 85 DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star International"),
diff --git a/drivers/media/usb/gspca/pac7302.c b/drivers/media/usb/gspca/pac7302.c
index 2d5c6d8343a0..4f5869a98082 100644
--- a/drivers/media/usb/gspca/pac7302.c
+++ b/drivers/media/usb/gspca/pac7302.c
@@ -29,14 +29,13 @@
29 * Register page 0: 29 * Register page 0:
30 * 30 *
31 * Address Description 31 * Address Description
32 * 0x02 Red balance control 32 * 0x01 Red balance control
33 * 0x03 Green balance control 33 * 0x02 Green balance control
34 * 0x04 Blue balance control 34 * 0x03 Blue balance control
35 * Valus are inverted (0=max, 255=min).
36 * The Windows driver uses a quadratic approach to map 35 * The Windows driver uses a quadratic approach to map
37 * the settable values (0-200) on register values: 36 * the settable values (0-200) on register values:
38 * min=0x80, default=0x40, max=0x20 37 * min=0x20, default=0x40, max=0x80
39 * 0x0f-0x20 Colors, saturation and exposure control 38 * 0x0f-0x20 Color and saturation control
40 * 0xa2-0xab Brightness, contrast and gamma control 39 * 0xa2-0xab Brightness, contrast and gamma control
41 * 0xb6 Sharpness control (bits 0-4) 40 * 0xb6 Sharpness control (bits 0-4)
42 * 41 *
@@ -78,12 +77,12 @@
78 * 77 *
79 * Page | Register | Function 78 * Page | Register | Function
80 * -----+------------+--------------------------------------------------- 79 * -----+------------+---------------------------------------------------
80 * 0 | 0x01 | setredbalance()
81 * 0 | 0x03 | setbluebalance()
81 * 0 | 0x0f..0x20 | setcolors() 82 * 0 | 0x0f..0x20 | setcolors()
82 * 0 | 0xa2..0xab | setbrightcont() 83 * 0 | 0xa2..0xab | setbrightcont()
83 * 0 | 0xb6 | setsharpness() 84 * 0 | 0xb6 | setsharpness()
84 * 0 | 0xc5 | setredbalance()
85 * 0 | 0xc6 | setwhitebalance() 85 * 0 | 0xc6 | setwhitebalance()
86 * 0 | 0xc7 | setbluebalance()
87 * 0 | 0xdc | setbrightcont(), setcolors() 86 * 0 | 0xdc | setbrightcont(), setcolors()
88 * 3 | 0x02 | setexposure() 87 * 3 | 0x02 | setexposure()
89 * 3 | 0x10, 0x12 | setgain() 88 * 3 | 0x10, 0x12 | setgain()
@@ -99,10 +98,13 @@
99/* Include pac common sof detection functions */ 98/* Include pac common sof detection functions */
100#include "pac_common.h" 99#include "pac_common.h"
101 100
102#define PAC7302_GAIN_DEFAULT 15 101#define PAC7302_RGB_BALANCE_MIN 0
103#define PAC7302_GAIN_KNEE 42 102#define PAC7302_RGB_BALANCE_MAX 200
104#define PAC7302_EXPOSURE_DEFAULT 66 /* 33 ms / 30 fps */ 103#define PAC7302_RGB_BALANCE_DEFAULT 100
105#define PAC7302_EXPOSURE_KNEE 133 /* 66 ms / 15 fps */ 104#define PAC7302_GAIN_DEFAULT 15
105#define PAC7302_GAIN_KNEE 42
106#define PAC7302_EXPOSURE_DEFAULT 66 /* 33 ms / 30 fps */
107#define PAC7302_EXPOSURE_KNEE 133 /* 66 ms / 15 fps */
106 108
107MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>, " 109MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>, "
108 "Thomas Kaiser thomas@kaiser-linux.li"); 110 "Thomas Kaiser thomas@kaiser-linux.li");
@@ -439,12 +441,31 @@ static void setwhitebalance(struct gspca_dev *gspca_dev)
439 reg_w(gspca_dev, 0xdc, 0x01); 441 reg_w(gspca_dev, 0xdc, 0x01);
440} 442}
441 443
444static u8 rgbbalance_ctrl_to_reg_value(s32 rgb_ctrl_val)
445{
446 const unsigned int k = 1000; /* precision factor */
447 unsigned int norm;
448
449 /* Normed value [0...k] */
450 norm = k * (rgb_ctrl_val - PAC7302_RGB_BALANCE_MIN)
451 / (PAC7302_RGB_BALANCE_MAX - PAC7302_RGB_BALANCE_MIN);
452 /* Qudratic apporach improves control at small (register) values: */
453 return 64 * norm * norm / (k*k) + 32 * norm / k + 32;
454 /* Y = 64*X*X + 32*X + 32
455 * => register values 0x20-0x80; Windows driver uses these limits */
456
457 /* NOTE: for full value range (0x00-0xff) use
458 * Y = 254*X*X + X
459 * => 254 * norm * norm / (k*k) + 1 * norm / k */
460}
461
442static void setredbalance(struct gspca_dev *gspca_dev) 462static void setredbalance(struct gspca_dev *gspca_dev)
443{ 463{
444 struct sd *sd = (struct sd *) gspca_dev; 464 struct sd *sd = (struct sd *) gspca_dev;
445 465
446 reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ 466 reg_w(gspca_dev, 0xff, 0x00); /* page 0 */
447 reg_w(gspca_dev, 0xc5, sd->red_balance->val); 467 reg_w(gspca_dev, 0x01,
468 rgbbalance_ctrl_to_reg_value(sd->red_balance->val));
448 469
449 reg_w(gspca_dev, 0xdc, 0x01); 470 reg_w(gspca_dev, 0xdc, 0x01);
450} 471}
@@ -454,7 +475,8 @@ static void setbluebalance(struct gspca_dev *gspca_dev)
454 struct sd *sd = (struct sd *) gspca_dev; 475 struct sd *sd = (struct sd *) gspca_dev;
455 476
456 reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ 477 reg_w(gspca_dev, 0xff, 0x00); /* page 0 */
457 reg_w(gspca_dev, 0xc7, sd->blue_balance->val); 478 reg_w(gspca_dev, 0x03,
479 rgbbalance_ctrl_to_reg_value(sd->blue_balance->val));
458 480
459 reg_w(gspca_dev, 0xdc, 0x01); 481 reg_w(gspca_dev, 0xdc, 0x01);
460} 482}
@@ -643,9 +665,15 @@ static int sd_init_controls(struct gspca_dev *gspca_dev)
643 V4L2_CID_WHITE_BALANCE_TEMPERATURE, 665 V4L2_CID_WHITE_BALANCE_TEMPERATURE,
644 0, 255, 1, 55); 666 0, 255, 1, 55);
645 sd->red_balance = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 667 sd->red_balance = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
646 V4L2_CID_RED_BALANCE, 0, 3, 1, 1); 668 V4L2_CID_RED_BALANCE,
669 PAC7302_RGB_BALANCE_MIN,
670 PAC7302_RGB_BALANCE_MAX,
671 1, PAC7302_RGB_BALANCE_DEFAULT);
647 sd->blue_balance = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 672 sd->blue_balance = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
648 V4L2_CID_BLUE_BALANCE, 0, 3, 1, 1); 673 V4L2_CID_BLUE_BALANCE,
674 PAC7302_RGB_BALANCE_MIN,
675 PAC7302_RGB_BALANCE_MAX,
676 1, PAC7302_RGB_BALANCE_DEFAULT);
649 677
650 gspca_dev->autogain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 678 gspca_dev->autogain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
651 V4L2_CID_AUTOGAIN, 0, 1, 1, 1); 679 V4L2_CID_AUTOGAIN, 0, 1, 1, 1);
diff --git a/drivers/media/usb/gspca/sonixb.c b/drivers/media/usb/gspca/sonixb.c
index fd1f8d2d3b0b..70511d5f9538 100644
--- a/drivers/media/usb/gspca/sonixb.c
+++ b/drivers/media/usb/gspca/sonixb.c
@@ -1449,6 +1449,7 @@ static const struct usb_device_id device_table[] = {
1449 {USB_DEVICE(0x0c45, 0x6024), SB(TAS5130CXX, 102)}, 1449 {USB_DEVICE(0x0c45, 0x6024), SB(TAS5130CXX, 102)},
1450 {USB_DEVICE(0x0c45, 0x6025), SB(TAS5130CXX, 102)}, 1450 {USB_DEVICE(0x0c45, 0x6025), SB(TAS5130CXX, 102)},
1451#endif 1451#endif
1452 {USB_DEVICE(0x0c45, 0x6027), SB(OV7630, 101)}, /* Genius Eye 310 */
1452 {USB_DEVICE(0x0c45, 0x6028), SB(PAS202, 102)}, 1453 {USB_DEVICE(0x0c45, 0x6028), SB(PAS202, 102)},
1453 {USB_DEVICE(0x0c45, 0x6029), SB(PAS106, 102)}, 1454 {USB_DEVICE(0x0c45, 0x6029), SB(PAS106, 102)},
1454 {USB_DEVICE(0x0c45, 0x602a), SB(HV7131D, 102)}, 1455 {USB_DEVICE(0x0c45, 0x602a), SB(HV7131D, 102)},
diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c b/drivers/media/usb/hdpvr/hdpvr-core.c
index 304f43ef59eb..84dc26fe80ee 100644
--- a/drivers/media/usb/hdpvr/hdpvr-core.c
+++ b/drivers/media/usb/hdpvr/hdpvr-core.c
@@ -401,12 +401,14 @@ static int hdpvr_probe(struct usb_interface *interface,
401 client = hdpvr_register_ir_rx_i2c(dev); 401 client = hdpvr_register_ir_rx_i2c(dev);
402 if (!client) { 402 if (!client) {
403 v4l2_err(&dev->v4l2_dev, "i2c IR RX device register failed\n"); 403 v4l2_err(&dev->v4l2_dev, "i2c IR RX device register failed\n");
404 retval = -ENODEV;
404 goto reg_fail; 405 goto reg_fail;
405 } 406 }
406 407
407 client = hdpvr_register_ir_tx_i2c(dev); 408 client = hdpvr_register_ir_tx_i2c(dev);
408 if (!client) { 409 if (!client) {
409 v4l2_err(&dev->v4l2_dev, "i2c IR TX device register failed\n"); 410 v4l2_err(&dev->v4l2_dev, "i2c IR TX device register failed\n");
411 retval = -ENODEV;
410 goto reg_fail; 412 goto reg_fail;
411 } 413 }
412#endif 414#endif
diff --git a/drivers/media/usb/hdpvr/hdpvr-i2c.c b/drivers/media/usb/hdpvr/hdpvr-i2c.c
index 82e819fa91c0..031cf024304c 100644
--- a/drivers/media/usb/hdpvr/hdpvr-i2c.c
+++ b/drivers/media/usb/hdpvr/hdpvr-i2c.c
@@ -55,7 +55,7 @@ struct i2c_client *hdpvr_register_ir_rx_i2c(struct hdpvr_device *dev)
55 /* Our default information for ir-kbd-i2c.c to use */ 55 /* Our default information for ir-kbd-i2c.c to use */
56 init_data->ir_codes = RC_MAP_HAUPPAUGE; 56 init_data->ir_codes = RC_MAP_HAUPPAUGE;
57 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; 57 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
58 init_data->type = RC_TYPE_RC5; 58 init_data->type = RC_BIT_RC5;
59 init_data->name = "HD-PVR"; 59 init_data->name = "HD-PVR";
60 init_data->polling_interval = 405; /* ms, duplicated from Windows */ 60 init_data->polling_interval = 405; /* ms, duplicated from Windows */
61 hdpvr_ir_rx_i2c_board_info.platform_data = init_data; 61 hdpvr_ir_rx_i2c_board_info.platform_data = init_data;
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
index fb828ba1dbbe..299751a8b06b 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
@@ -3563,9 +3563,9 @@ void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *hdw,
3563 enum pvr2_v4l_type index,int v) 3563 enum pvr2_v4l_type index,int v)
3564{ 3564{
3565 switch (index) { 3565 switch (index) {
3566 case pvr2_v4l_type_video: hdw->v4l_minor_number_video = v; 3566 case pvr2_v4l_type_video: hdw->v4l_minor_number_video = v;break;
3567 case pvr2_v4l_type_vbi: hdw->v4l_minor_number_vbi = v; 3567 case pvr2_v4l_type_vbi: hdw->v4l_minor_number_vbi = v;break;
3568 case pvr2_v4l_type_radio: hdw->v4l_minor_number_radio = v; 3568 case pvr2_v4l_type_radio: hdw->v4l_minor_number_radio = v;break;
3569 default: break; 3569 default: break;
3570 } 3570 }
3571} 3571}
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
index 885ce11f222d..9ab596c78a4e 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
@@ -581,7 +581,7 @@ static void pvr2_i2c_register_ir(struct pvr2_hdw *hdw)
581 case PVR2_IR_SCHEME_29XXX: /* Original 29xxx device */ 581 case PVR2_IR_SCHEME_29XXX: /* Original 29xxx device */
582 init_data->ir_codes = RC_MAP_HAUPPAUGE; 582 init_data->ir_codes = RC_MAP_HAUPPAUGE;
583 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP; 583 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP;
584 init_data->type = RC_TYPE_RC5; 584 init_data->type = RC_BIT_RC5;
585 init_data->name = hdw->hdw_desc->description; 585 init_data->name = hdw->hdw_desc->description;
586 init_data->polling_interval = 100; /* ms From ir-kbd-i2c */ 586 init_data->polling_interval = 100; /* ms From ir-kbd-i2c */
587 /* IR Receiver */ 587 /* IR Receiver */
@@ -596,7 +596,7 @@ static void pvr2_i2c_register_ir(struct pvr2_hdw *hdw)
596 case PVR2_IR_SCHEME_24XXX_MCE: /* 24xxx MCE device */ 596 case PVR2_IR_SCHEME_24XXX_MCE: /* 24xxx MCE device */
597 init_data->ir_codes = RC_MAP_HAUPPAUGE; 597 init_data->ir_codes = RC_MAP_HAUPPAUGE;
598 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; 598 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
599 init_data->type = RC_TYPE_RC5; 599 init_data->type = RC_BIT_RC5;
600 init_data->name = hdw->hdw_desc->description; 600 init_data->name = hdw->hdw_desc->description;
601 /* IR Receiver */ 601 /* IR Receiver */
602 info.addr = 0x71; 602 info.addr = 0x71;
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
index db249cad3cd9..6930676051e7 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
@@ -196,7 +196,7 @@ static int pvr2_g_std(struct file *file, void *priv, v4l2_std_id *std)
196 return ret; 196 return ret;
197} 197}
198 198
199int pvr2_s_std(struct file *file, void *priv, v4l2_std_id *std) 199static int pvr2_s_std(struct file *file, void *priv, v4l2_std_id *std)
200{ 200{
201 struct pvr2_v4l2_fh *fh = file->private_data; 201 struct pvr2_v4l2_fh *fh = file->private_data;
202 struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; 202 struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
@@ -365,7 +365,7 @@ static int pvr2_s_tuner(struct file *file, void *priv, struct v4l2_tuner *vt)
365 vt->audmode); 365 vt->audmode);
366} 366}
367 367
368int pvr2_s_frequency(struct file *file, void *priv, struct v4l2_frequency *vf) 368static int pvr2_s_frequency(struct file *file, void *priv, struct v4l2_frequency *vf)
369{ 369{
370 struct pvr2_v4l2_fh *fh = file->private_data; 370 struct pvr2_v4l2_fh *fh = file->private_data;
371 struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; 371 struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
diff --git a/drivers/media/usb/pwc/pwc-ctrl.c b/drivers/media/usb/pwc/pwc-ctrl.c
index 1f506fde97d0..3a1618580ed6 100644
--- a/drivers/media/usb/pwc/pwc-ctrl.c
+++ b/drivers/media/usb/pwc/pwc-ctrl.c
@@ -179,6 +179,8 @@ static int set_video_mode_Nala(struct pwc_device *pdev, int size, int pixfmt,
179 return -EINVAL; 179 return -EINVAL;
180 if (frames < 4) 180 if (frames < 4)
181 frames = 4; 181 frames = 4;
182 else if (size > PSZ_QCIF && frames > 15)
183 frames = 15;
182 else if (frames > 25) 184 else if (frames > 25)
183 frames = 25; 185 frames = 25;
184 frames = frames2frames[frames]; 186 frames = frames2frames[frames];
diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c
index 42e36bac4d72..5210239cbaee 100644
--- a/drivers/media/usb/pwc/pwc-if.c
+++ b/drivers/media/usb/pwc/pwc-if.c
@@ -155,7 +155,7 @@ static struct video_device pwc_template = {
155/***************************************************************************/ 155/***************************************************************************/
156/* Private functions */ 156/* Private functions */
157 157
158struct pwc_frame_buf *pwc_get_next_fill_buf(struct pwc_device *pdev) 158static struct pwc_frame_buf *pwc_get_next_fill_buf(struct pwc_device *pdev)
159{ 159{
160 unsigned long flags = 0; 160 unsigned long flags = 0;
161 struct pwc_frame_buf *buf = NULL; 161 struct pwc_frame_buf *buf = NULL;
@@ -1000,7 +1000,11 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1000 pdev->vb_queue.buf_struct_size = sizeof(struct pwc_frame_buf); 1000 pdev->vb_queue.buf_struct_size = sizeof(struct pwc_frame_buf);
1001 pdev->vb_queue.ops = &pwc_vb_queue_ops; 1001 pdev->vb_queue.ops = &pwc_vb_queue_ops;
1002 pdev->vb_queue.mem_ops = &vb2_vmalloc_memops; 1002 pdev->vb_queue.mem_ops = &vb2_vmalloc_memops;
1003 vb2_queue_init(&pdev->vb_queue); 1003 rc = vb2_queue_init(&pdev->vb_queue);
1004 if (rc < 0) {
1005 PWC_ERROR("Oops, could not initialize vb2 queue.\n");
1006 goto err_free_mem;
1007 }
1004 1008
1005 /* Init video_device structure */ 1009 /* Init video_device structure */
1006 memcpy(&pdev->vdev, &pwc_template, sizeof(pwc_template)); 1010 memcpy(&pdev->vdev, &pwc_template, sizeof(pwc_template));
diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
index 2191f6ddf9e7..8ebec0d7bf59 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -1651,7 +1651,7 @@ static int vidioc_enum_frameintervals(struct file *file, void *priv,
1651 int is_ntsc = 0; 1651 int is_ntsc = 0;
1652#define NUM_FRAME_ENUMS 4 1652#define NUM_FRAME_ENUMS 4
1653 int frm_dec[NUM_FRAME_ENUMS] = {1, 2, 3, 5}; 1653 int frm_dec[NUM_FRAME_ENUMS] = {1, 2, 3, 5};
1654 if (fe->index < 0 || fe->index >= NUM_FRAME_ENUMS) 1654 if (fe->index >= NUM_FRAME_ENUMS)
1655 return -EINVAL; 1655 return -EINVAL;
1656 switch (fe->width) { 1656 switch (fe->width) {
1657 case 640: 1657 case 640:
diff --git a/drivers/media/usb/siano/Kconfig b/drivers/media/usb/siano/Kconfig
index 3c76e62d820d..5afbd9a4b55c 100644
--- a/drivers/media/usb/siano/Kconfig
+++ b/drivers/media/usb/siano/Kconfig
@@ -4,7 +4,8 @@
4 4
5config SMS_USB_DRV 5config SMS_USB_DRV
6 tristate "Siano SMS1xxx based MDTV receiver" 6 tristate "Siano SMS1xxx based MDTV receiver"
7 depends on DVB_CORE && RC_CORE && HAS_DMA 7 depends on DVB_CORE && HAS_DMA
8 select MEDIA_COMMON_OPTIONS
8 ---help--- 9 ---help---
9 Choose if you would like to have Siano's support for USB interface 10 Choose if you would like to have Siano's support for USB interface
10 11
diff --git a/drivers/media/usb/sn9c102/sn9c102_core.c b/drivers/media/usb/sn9c102/sn9c102_core.c
index 5bfc8e2f018f..73605864fffa 100644
--- a/drivers/media/usb/sn9c102/sn9c102_core.c
+++ b/drivers/media/usb/sn9c102/sn9c102_core.c
@@ -2481,11 +2481,13 @@ sn9c102_vidioc_enum_framesizes(struct sn9c102_device* cam, void __user * arg)
2481 if (frmsize.pixel_format != V4L2_PIX_FMT_SN9C10X && 2481 if (frmsize.pixel_format != V4L2_PIX_FMT_SN9C10X &&
2482 frmsize.pixel_format != V4L2_PIX_FMT_SBGGR8) 2482 frmsize.pixel_format != V4L2_PIX_FMT_SBGGR8)
2483 return -EINVAL; 2483 return -EINVAL;
2484 break;
2484 case BRIDGE_SN9C105: 2485 case BRIDGE_SN9C105:
2485 case BRIDGE_SN9C120: 2486 case BRIDGE_SN9C120:
2486 if (frmsize.pixel_format != V4L2_PIX_FMT_JPEG && 2487 if (frmsize.pixel_format != V4L2_PIX_FMT_JPEG &&
2487 frmsize.pixel_format != V4L2_PIX_FMT_SBGGR8) 2488 frmsize.pixel_format != V4L2_PIX_FMT_SBGGR8)
2488 return -EINVAL; 2489 return -EINVAL;
2490 break;
2489 } 2491 }
2490 2492
2491 frmsize.type = V4L2_FRMSIZE_TYPE_STEPWISE; 2493 frmsize.type = V4L2_FRMSIZE_TYPE_STEPWISE;
diff --git a/drivers/media/usb/stk1160/stk1160-i2c.c b/drivers/media/usb/stk1160/stk1160-i2c.c
index 176ac937306b..850cf285ada8 100644
--- a/drivers/media/usb/stk1160/stk1160-i2c.c
+++ b/drivers/media/usb/stk1160/stk1160-i2c.c
@@ -116,7 +116,7 @@ static int stk1160_i2c_read_reg(struct stk1160 *dev, u8 addr,
116 if (rc < 0) 116 if (rc < 0)
117 return rc; 117 return rc;
118 118
119 stk1160_read_reg(dev, STK1160_SBUSR_RD, value); 119 rc = stk1160_read_reg(dev, STK1160_SBUSR_RD, value);
120 if (rc < 0) 120 if (rc < 0)
121 return rc; 121 return rc;
122 122
diff --git a/drivers/media/usb/stk1160/stk1160-video.c b/drivers/media/usb/stk1160/stk1160-video.c
index 8bdfb0275313..fa3671de02aa 100644
--- a/drivers/media/usb/stk1160/stk1160-video.c
+++ b/drivers/media/usb/stk1160/stk1160-video.c
@@ -475,7 +475,11 @@ int stk1160_alloc_isoc(struct stk1160 *dev)
475 if (!dev->isoc_ctl.transfer_buffer[i]) { 475 if (!dev->isoc_ctl.transfer_buffer[i]) {
476 stk1160_err("cannot alloc %d bytes for tx[%d] buffer\n", 476 stk1160_err("cannot alloc %d bytes for tx[%d] buffer\n",
477 sb_size, i); 477 sb_size, i);
478 goto free_i_bufs; 478
479 /* Not enough transfer buffers, so just give up */
480 if (i < STK1160_MIN_BUFS)
481 goto free_i_bufs;
482 goto nomore_tx_bufs;
479 } 483 }
480 memset(dev->isoc_ctl.transfer_buffer[i], 0, sb_size); 484 memset(dev->isoc_ctl.transfer_buffer[i], 0, sb_size);
481 485
@@ -506,13 +510,28 @@ int stk1160_alloc_isoc(struct stk1160 *dev)
506 } 510 }
507 } 511 }
508 512
509 stk1160_dbg("urbs allocated\n"); 513 stk1160_dbg("%d urbs allocated\n", num_bufs);
510 514
511 /* At last we can say we have some buffers */ 515 /* At last we can say we have some buffers */
512 dev->isoc_ctl.num_bufs = num_bufs; 516 dev->isoc_ctl.num_bufs = num_bufs;
513 517
514 return 0; 518 return 0;
515 519
520nomore_tx_bufs:
521 /*
522 * Failed to allocate desired buffer count. However, we may have
523 * enough to work fine, so we just free the extra urb,
524 * store the allocated count and keep going, fingers crossed!
525 */
526 usb_free_urb(dev->isoc_ctl.urb[i]);
527 dev->isoc_ctl.urb[i] = NULL;
528
529 stk1160_warn("%d urbs allocated. Trying to continue...\n", i - 1);
530
531 dev->isoc_ctl.num_bufs = i - 1;
532
533 return 0;
534
516free_i_bufs: 535free_i_bufs:
517 /* Save the allocated buffers so far, so we can properly free them */ 536 /* Save the allocated buffers so far, so we can properly free them */
518 dev->isoc_ctl.num_bufs = i+1; 537 dev->isoc_ctl.num_bufs = i+1;
diff --git a/drivers/media/usb/stk1160/stk1160.h b/drivers/media/usb/stk1160/stk1160.h
index 68c8707d36ab..05b05b160e1e 100644
--- a/drivers/media/usb/stk1160/stk1160.h
+++ b/drivers/media/usb/stk1160/stk1160.h
@@ -30,11 +30,12 @@
30#define STK1160_VERSION "0.9.5" 30#define STK1160_VERSION "0.9.5"
31#define STK1160_VERSION_NUM 0x000905 31#define STK1160_VERSION_NUM 0x000905
32 32
33/* TODO: Decide on number of packets for each buffer */ 33/* Decide on number of packets for each buffer */
34#define STK1160_NUM_PACKETS 64 34#define STK1160_NUM_PACKETS 64
35 35
36/* Number of buffers for isoc transfers */ 36/* Number of buffers for isoc transfers */
37#define STK1160_NUM_BUFS 16 /* TODO */ 37#define STK1160_NUM_BUFS 16
38#define STK1160_MIN_BUFS 1
38 39
39/* TODO: This endpoint address should be retrieved */ 40/* TODO: This endpoint address should be retrieved */
40#define STK1160_EP_VIDEO 0x82 41#define STK1160_EP_VIDEO 0x82
diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c
index 86a0fc56c330..5d3c032d733c 100644
--- a/drivers/media/usb/stkwebcam/stk-webcam.c
+++ b/drivers/media/usb/stkwebcam/stk-webcam.c
@@ -54,10 +54,6 @@ MODULE_LICENSE("GPL");
54MODULE_AUTHOR("Jaime Velasco Juan <jsagarribay@gmail.com> and Nicolas VIVIEN"); 54MODULE_AUTHOR("Jaime Velasco Juan <jsagarribay@gmail.com> and Nicolas VIVIEN");
55MODULE_DESCRIPTION("Syntek DC1125 webcam driver"); 55MODULE_DESCRIPTION("Syntek DC1125 webcam driver");
56 56
57
58/* bool for webcam LED management */
59int first_init = 1;
60
61/* Some cameras have audio interfaces, we aren't interested in those */ 57/* Some cameras have audio interfaces, we aren't interested in those */
62static struct usb_device_id stkwebcam_table[] = { 58static struct usb_device_id stkwebcam_table[] = {
63 { USB_DEVICE_AND_INTERFACE_INFO(0x174f, 0xa311, 0xff, 0xff, 0xff) }, 59 { USB_DEVICE_AND_INTERFACE_INFO(0x174f, 0xa311, 0xff, 0xff, 0xff) },
@@ -554,6 +550,7 @@ static void stk_free_buffers(struct stk_camera *dev)
554 550
555static int v4l_stk_open(struct file *fp) 551static int v4l_stk_open(struct file *fp)
556{ 552{
553 static int first_init = 1; /* webcam LED management */
557 struct stk_camera *dev; 554 struct stk_camera *dev;
558 struct video_device *vdev; 555 struct video_device *vdev;
559 556
diff --git a/drivers/media/usb/tlg2300/pd-dvb.c b/drivers/media/usb/tlg2300/pd-dvb.c
index 30fcb117e898..ca4994a5190c 100644
--- a/drivers/media/usb/tlg2300/pd-dvb.c
+++ b/drivers/media/usb/tlg2300/pd-dvb.c
@@ -1,6 +1,7 @@
1#include "pd-common.h" 1#include "pd-common.h"
2#include <linux/kernel.h> 2#include <linux/kernel.h>
3#include <linux/usb.h> 3#include <linux/usb.h>
4#include <linux/time.h>
4#include <linux/dvb/dmx.h> 5#include <linux/dvb/dmx.h>
5#include <linux/delay.h> 6#include <linux/delay.h>
6#include <linux/gfp.h> 7#include <linux/gfp.h>
diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c
index 1f448ac7a496..3082bfa9b2c5 100644
--- a/drivers/media/usb/tlg2300/pd-video.c
+++ b/drivers/media/usb/tlg2300/pd-video.c
@@ -888,7 +888,7 @@ static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *in)
888{ 888{
889 struct front_face *front = fh; 889 struct front_face *front = fh;
890 890
891 if (in->index < 0 || in->index >= POSEIDON_INPUTS) 891 if (in->index >= POSEIDON_INPUTS)
892 return -EINVAL; 892 return -EINVAL;
893 strcpy(in->name, pd_inputs[in->index].name); 893 strcpy(in->name, pd_inputs[in->index].name);
894 in->type = V4L2_INPUT_TYPE_TUNER; 894 in->type = V4L2_INPUT_TYPE_TUNER;
@@ -923,7 +923,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int i)
923 struct poseidon *pd = front->pd; 923 struct poseidon *pd = front->pd;
924 s32 ret, cmd_status; 924 s32 ret, cmd_status;
925 925
926 if (i < 0 || i >= POSEIDON_INPUTS) 926 if (i >= POSEIDON_INPUTS)
927 return -EINVAL; 927 return -EINVAL;
928 ret = send_set_req(pd, SGNL_SRC_SEL, 928 ret = send_set_req(pd, SGNL_SRC_SEL,
929 pd_inputs[i].tlg_src, &cmd_status); 929 pd_inputs[i].tlg_src, &cmd_status);
diff --git a/drivers/media/usb/tm6000/tm6000-input.c b/drivers/media/usb/tm6000/tm6000-input.c
index dffbd4bd47b1..8a6bbf1d80e1 100644
--- a/drivers/media/usb/tm6000/tm6000-input.c
+++ b/drivers/media/usb/tm6000/tm6000-input.c
@@ -109,12 +109,12 @@ static int tm6000_ir_config(struct tm6000_IR *ir)
109 */ 109 */
110 110
111 switch (ir->rc_type) { 111 switch (ir->rc_type) {
112 case RC_TYPE_NEC: 112 case RC_BIT_NEC:
113 leader = 900; /* ms */ 113 leader = 900; /* ms */
114 pulse = 700; /* ms - the actual value would be 562 */ 114 pulse = 700; /* ms - the actual value would be 562 */
115 break; 115 break;
116 default: 116 default:
117 case RC_TYPE_RC5: 117 case RC_BIT_RC5:
118 leader = 900; /* ms - from the NEC decoding */ 118 leader = 900; /* ms - from the NEC decoding */
119 pulse = 1780; /* ms - The actual value would be 1776 */ 119 pulse = 1780; /* ms - The actual value would be 1776 */
120 break; 120 break;
@@ -122,12 +122,12 @@ static int tm6000_ir_config(struct tm6000_IR *ir)
122 122
123 pulse = ir_clock_mhz * pulse; 123 pulse = ir_clock_mhz * pulse;
124 leader = ir_clock_mhz * leader; 124 leader = ir_clock_mhz * leader;
125 if (ir->rc_type == RC_TYPE_NEC) 125 if (ir->rc_type == RC_BIT_NEC)
126 leader = leader | 0x8000; 126 leader = leader | 0x8000;
127 127
128 dprintk(2, "%s: %s, %d MHz, leader = 0x%04x, pulse = 0x%06x \n", 128 dprintk(2, "%s: %s, %d MHz, leader = 0x%04x, pulse = 0x%06x \n",
129 __func__, 129 __func__,
130 (ir->rc_type == RC_TYPE_NEC) ? "NEC" : "RC-5", 130 (ir->rc_type == RC_BIT_NEC) ? "NEC" : "RC-5",
131 ir_clock_mhz, leader, pulse); 131 ir_clock_mhz, leader, pulse);
132 132
133 /* Remote WAKEUP = enable, normal mode, from IR decoder output */ 133 /* Remote WAKEUP = enable, normal mode, from IR decoder output */
@@ -297,7 +297,7 @@ static void tm6000_ir_stop(struct rc_dev *rc)
297 cancel_delayed_work_sync(&ir->work); 297 cancel_delayed_work_sync(&ir->work);
298} 298}
299 299
300static int tm6000_ir_change_protocol(struct rc_dev *rc, u64 rc_type) 300static int tm6000_ir_change_protocol(struct rc_dev *rc, u64 *rc_type)
301{ 301{
302 struct tm6000_IR *ir = rc->priv; 302 struct tm6000_IR *ir = rc->priv;
303 303
@@ -306,10 +306,10 @@ static int tm6000_ir_change_protocol(struct rc_dev *rc, u64 rc_type)
306 306
307 dprintk(2, "%s\n",__func__); 307 dprintk(2, "%s\n",__func__);
308 308
309 if ((rc->rc_map.scan) && (rc_type == RC_TYPE_NEC)) 309 if ((rc->rc_map.scan) && (*rc_type == RC_BIT_NEC))
310 ir->key_addr = ((rc->rc_map.scan[0].scancode >> 8) & 0xffff); 310 ir->key_addr = ((rc->rc_map.scan[0].scancode >> 8) & 0xffff);
311 311
312 ir->rc_type = rc_type; 312 ir->rc_type = *rc_type;
313 313
314 tm6000_ir_config(ir); 314 tm6000_ir_config(ir);
315 /* TODO */ 315 /* TODO */
@@ -398,6 +398,7 @@ int tm6000_ir_init(struct tm6000_core *dev)
398 struct tm6000_IR *ir; 398 struct tm6000_IR *ir;
399 struct rc_dev *rc; 399 struct rc_dev *rc;
400 int err = -ENOMEM; 400 int err = -ENOMEM;
401 u64 rc_type;
401 402
402 if (!enable_ir) 403 if (!enable_ir)
403 return -ENODEV; 404 return -ENODEV;
@@ -421,7 +422,7 @@ int tm6000_ir_init(struct tm6000_core *dev)
421 ir->rc = rc; 422 ir->rc = rc;
422 423
423 /* input setup */ 424 /* input setup */
424 rc->allowed_protos = RC_TYPE_RC5 | RC_TYPE_NEC; 425 rc->allowed_protos = RC_BIT_RC5 | RC_BIT_NEC;
425 /* Neded, in order to support NEC remotes with 24 or 32 bits */ 426 /* Neded, in order to support NEC remotes with 24 or 32 bits */
426 rc->scanmask = 0xffff; 427 rc->scanmask = 0xffff;
427 rc->priv = ir; 428 rc->priv = ir;
@@ -444,7 +445,8 @@ int tm6000_ir_init(struct tm6000_core *dev)
444 usb_make_path(dev->udev, ir->phys, sizeof(ir->phys)); 445 usb_make_path(dev->udev, ir->phys, sizeof(ir->phys));
445 strlcat(ir->phys, "/input0", sizeof(ir->phys)); 446 strlcat(ir->phys, "/input0", sizeof(ir->phys));
446 447
447 tm6000_ir_change_protocol(rc, RC_TYPE_UNKNOWN); 448 rc_type = RC_BIT_UNKNOWN;
449 tm6000_ir_change_protocol(rc, &rc_type);
448 450
449 rc->input_name = ir->name; 451 rc->input_name = ir->name;
450 rc->input_phys = ir->phys; 452 rc->input_phys = ir->phys;
diff --git a/drivers/media/usb/tm6000/tm6000-video.c b/drivers/media/usb/tm6000/tm6000-video.c
index 4342cd4f5c8a..f656fd7a39a2 100644
--- a/drivers/media/usb/tm6000/tm6000-video.c
+++ b/drivers/media/usb/tm6000/tm6000-video.c
@@ -1802,6 +1802,7 @@ int tm6000_v4l2_register(struct tm6000_core *dev)
1802 if (!dev->radio_dev) { 1802 if (!dev->radio_dev) {
1803 printk(KERN_INFO "%s: can't register radio device\n", 1803 printk(KERN_INFO "%s: can't register radio device\n",
1804 dev->name); 1804 dev->name);
1805 ret = -ENXIO;
1805 return ret; /* FIXME release resource */ 1806 return ret; /* FIXME release resource */
1806 } 1807 }
1807 1808
diff --git a/drivers/media/usb/usbvision/usbvision.h b/drivers/media/usb/usbvision/usbvision.h
index 43cf61fe4943..8a25876d72c6 100644
--- a/drivers/media/usb/usbvision/usbvision.h
+++ b/drivers/media/usb/usbvision/usbvision.h
@@ -167,7 +167,7 @@ enum {
167 167
168/* This macro restricts an int variable to an inclusive range */ 168/* This macro restricts an int variable to an inclusive range */
169#define RESTRICT_TO_RANGE(v, mi, ma) \ 169#define RESTRICT_TO_RANGE(v, mi, ma) \
170 { if ((v) < (mi)) (v) = (mi); else if ((v) > (ma)) (v) = (ma); } 170 { if (((int)v) < (mi)) (v) = (mi); else if ((v) > (ma)) (v) = (ma); }
171 171
172/* 172/*
173 * We use macros to do YUV -> RGB conversion because this is 173 * We use macros to do YUV -> RGB conversion because this is
diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index f7061a5ef1d2..516a5b188ea5 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -927,7 +927,7 @@ static int __uvc_ctrl_get(struct uvc_video_chain *chain,
927 int ret; 927 int ret;
928 928
929 if ((ctrl->info.flags & UVC_CTRL_FLAG_GET_CUR) == 0) 929 if ((ctrl->info.flags & UVC_CTRL_FLAG_GET_CUR) == 0)
930 return -EINVAL; 930 return -EACCES;
931 931
932 if (!ctrl->loaded) { 932 if (!ctrl->loaded) {
933 ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR, ctrl->entity->id, 933 ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR, ctrl->entity->id,
@@ -1061,7 +1061,7 @@ int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
1061 1061
1062 ctrl = uvc_find_control(chain, v4l2_ctrl->id, &mapping); 1062 ctrl = uvc_find_control(chain, v4l2_ctrl->id, &mapping);
1063 if (ctrl == NULL) { 1063 if (ctrl == NULL) {
1064 ret = -EINVAL; 1064 ret = -ENOENT;
1065 goto done; 1065 goto done;
1066 } 1066 }
1067 1067
@@ -1099,12 +1099,13 @@ int uvc_query_v4l2_menu(struct uvc_video_chain *chain,
1099 return -ERESTARTSYS; 1099 return -ERESTARTSYS;
1100 1100
1101 ctrl = uvc_find_control(chain, query_menu->id, &mapping); 1101 ctrl = uvc_find_control(chain, query_menu->id, &mapping);
1102 if (ctrl == NULL || mapping->v4l2_type != V4L2_CTRL_TYPE_MENU) { 1102 if (ctrl == NULL) {
1103 ret = -EINVAL; 1103 ret = -ENOENT;
1104 goto done; 1104 goto done;
1105 } 1105 }
1106 1106
1107 if (query_menu->index >= mapping->menu_count) { 1107 if (mapping->v4l2_type != V4L2_CTRL_TYPE_MENU ||
1108 query_menu->index >= mapping->menu_count) {
1108 ret = -EINVAL; 1109 ret = -EINVAL;
1109 goto done; 1110 goto done;
1110 } 1111 }
@@ -1263,7 +1264,7 @@ static int uvc_ctrl_add_event(struct v4l2_subscribed_event *sev, unsigned elems)
1263 1264
1264 ctrl = uvc_find_control(handle->chain, sev->id, &mapping); 1265 ctrl = uvc_find_control(handle->chain, sev->id, &mapping);
1265 if (ctrl == NULL) { 1266 if (ctrl == NULL) {
1266 ret = -EINVAL; 1267 ret = -ENOENT;
1267 goto done; 1268 goto done;
1268 } 1269 }
1269 1270
@@ -1414,7 +1415,7 @@ int uvc_ctrl_get(struct uvc_video_chain *chain,
1414 1415
1415 ctrl = uvc_find_control(chain, xctrl->id, &mapping); 1416 ctrl = uvc_find_control(chain, xctrl->id, &mapping);
1416 if (ctrl == NULL) 1417 if (ctrl == NULL)
1417 return -EINVAL; 1418 return -ENOENT;
1418 1419
1419 return __uvc_ctrl_get(chain, ctrl, mapping, &xctrl->value); 1420 return __uvc_ctrl_get(chain, ctrl, mapping, &xctrl->value);
1420} 1421}
@@ -1431,8 +1432,10 @@ int uvc_ctrl_set(struct uvc_video_chain *chain,
1431 int ret; 1432 int ret;
1432 1433
1433 ctrl = uvc_find_control(chain, xctrl->id, &mapping); 1434 ctrl = uvc_find_control(chain, xctrl->id, &mapping);
1434 if (ctrl == NULL || (ctrl->info.flags & UVC_CTRL_FLAG_SET_CUR) == 0) 1435 if (ctrl == NULL)
1435 return -EINVAL; 1436 return -ENOENT;
1437 if (!(ctrl->info.flags & UVC_CTRL_FLAG_SET_CUR))
1438 return -EACCES;
1436 1439
1437 /* Clamp out of range values. */ 1440 /* Clamp out of range values. */
1438 switch (mapping->v4l2_type) { 1441 switch (mapping->v4l2_type) {
@@ -1452,8 +1455,12 @@ int uvc_ctrl_set(struct uvc_video_chain *chain,
1452 if (step == 0) 1455 if (step == 0)
1453 step = 1; 1456 step = 1;
1454 1457
1455 xctrl->value = min + (xctrl->value - min + step/2) / step * step; 1458 xctrl->value = min + ((u32)(xctrl->value - min) + step / 2)
1456 xctrl->value = clamp(xctrl->value, min, max); 1459 / step * step;
1460 if (mapping->data_type == UVC_CTRL_DATA_TYPE_SIGNED)
1461 xctrl->value = clamp(xctrl->value, min, max);
1462 else
1463 xctrl->value = clamp_t(u32, xctrl->value, min, max);
1457 value = xctrl->value; 1464 value = xctrl->value;
1458 break; 1465 break;
1459 1466
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index 5967081747ce..5dbefa68b1d2 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -1562,6 +1562,9 @@ static int uvc_scan_device(struct uvc_device *dev)
1562 INIT_LIST_HEAD(&chain->entities); 1562 INIT_LIST_HEAD(&chain->entities);
1563 mutex_init(&chain->ctrl_mutex); 1563 mutex_init(&chain->ctrl_mutex);
1564 chain->dev = dev; 1564 chain->dev = dev;
1565 v4l2_prio_init(&chain->prio);
1566
1567 term->flags |= UVC_ENTITY_FLAG_DEFAULT;
1565 1568
1566 if (uvc_scan_chain(chain, term) < 0) { 1569 if (uvc_scan_chain(chain, term) < 0) {
1567 kfree(chain); 1570 kfree(chain);
@@ -1722,6 +1725,8 @@ static int uvc_register_video(struct uvc_device *dev,
1722 vdev->v4l2_dev = &dev->vdev; 1725 vdev->v4l2_dev = &dev->vdev;
1723 vdev->fops = &uvc_fops; 1726 vdev->fops = &uvc_fops;
1724 vdev->release = uvc_release; 1727 vdev->release = uvc_release;
1728 vdev->prio = &stream->chain->prio;
1729 set_bit(V4L2_FL_USE_FH_PRIO, &vdev->flags);
1725 if (stream->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) 1730 if (stream->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
1726 vdev->vfl_dir = VFL_DIR_TX; 1731 vdev->vfl_dir = VFL_DIR_TX;
1727 strlcpy(vdev->name, dev->name, sizeof vdev->name); 1732 strlcpy(vdev->name, dev->name, sizeof vdev->name);
@@ -1741,6 +1746,11 @@ static int uvc_register_video(struct uvc_device *dev,
1741 return ret; 1746 return ret;
1742 } 1747 }
1743 1748
1749 if (stream->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
1750 stream->chain->caps |= V4L2_CAP_VIDEO_CAPTURE;
1751 else
1752 stream->chain->caps |= V4L2_CAP_VIDEO_OUTPUT;
1753
1744 atomic_inc(&dev->nstreams); 1754 atomic_inc(&dev->nstreams);
1745 return 0; 1755 return 0;
1746} 1756}
diff --git a/drivers/media/usb/uvc/uvc_entity.c b/drivers/media/usb/uvc/uvc_entity.c
index 29e239911d0e..dc56a59ecadc 100644
--- a/drivers/media/usb/uvc/uvc_entity.c
+++ b/drivers/media/usb/uvc/uvc_entity.c
@@ -93,6 +93,8 @@ static int uvc_mc_init_entity(struct uvc_entity *entity)
93 } else if (entity->vdev != NULL) { 93 } else if (entity->vdev != NULL) {
94 ret = media_entity_init(&entity->vdev->entity, 94 ret = media_entity_init(&entity->vdev->entity,
95 entity->num_pads, entity->pads, 0); 95 entity->num_pads, entity->pads, 0);
96 if (entity->flags & UVC_ENTITY_FLAG_DEFAULT)
97 entity->vdev->entity.flags |= MEDIA_ENT_FL_DEFAULT;
96 } else 98 } else
97 ret = 0; 99 ret = 0;
98 100
diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c
index 18a91fae6bc1..778addc5caff 100644
--- a/drivers/media/usb/uvc/uvc_queue.c
+++ b/drivers/media/usb/uvc/uvc_queue.c
@@ -128,7 +128,7 @@ int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
128 int ret; 128 int ret;
129 129
130 queue->queue.type = type; 130 queue->queue.type = type;
131 queue->queue.io_modes = VB2_MMAP | VB2_USERPTR; 131 queue->queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
132 queue->queue.drv_priv = queue; 132 queue->queue.drv_priv = queue;
133 queue->queue.buf_struct_size = sizeof(struct uvc_buffer); 133 queue->queue.buf_struct_size = sizeof(struct uvc_buffer);
134 queue->queue.ops = &uvc_queue_qops; 134 queue->queue.ops = &uvc_queue_qops;
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index f00db3060e0e..8e056046bc20 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -165,17 +165,18 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream,
165 fcc[0], fcc[1], fcc[2], fcc[3], 165 fcc[0], fcc[1], fcc[2], fcc[3],
166 fmt->fmt.pix.width, fmt->fmt.pix.height); 166 fmt->fmt.pix.width, fmt->fmt.pix.height);
167 167
168 /* Check if the hardware supports the requested format. */ 168 /* Check if the hardware supports the requested format, use the default
169 * format otherwise.
170 */
169 for (i = 0; i < stream->nformats; ++i) { 171 for (i = 0; i < stream->nformats; ++i) {
170 format = &stream->format[i]; 172 format = &stream->format[i];
171 if (format->fcc == fmt->fmt.pix.pixelformat) 173 if (format->fcc == fmt->fmt.pix.pixelformat)
172 break; 174 break;
173 } 175 }
174 176
175 if (format == NULL || format->fcc != fmt->fmt.pix.pixelformat) { 177 if (i == stream->nformats) {
176 uvc_trace(UVC_TRACE_FORMAT, "Unsupported format 0x%08x.\n", 178 format = stream->def_format;
177 fmt->fmt.pix.pixelformat); 179 fmt->fmt.pix.pixelformat = format->fcc;
178 return -EINVAL;
179 } 180 }
180 181
181 /* Find the closest image size. The distance between image sizes is 182 /* Find the closest image size. The distance between image sizes is
@@ -564,15 +565,30 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
564 usb_make_path(stream->dev->udev, 565 usb_make_path(stream->dev->udev,
565 cap->bus_info, sizeof(cap->bus_info)); 566 cap->bus_info, sizeof(cap->bus_info));
566 cap->version = LINUX_VERSION_CODE; 567 cap->version = LINUX_VERSION_CODE;
568 cap->capabilities = V4L2_CAP_DEVICE_CAPS | V4L2_CAP_STREAMING
569 | chain->caps;
567 if (stream->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) 570 if (stream->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
568 cap->capabilities = V4L2_CAP_VIDEO_CAPTURE 571 cap->device_caps = V4L2_CAP_VIDEO_CAPTURE
569 | V4L2_CAP_STREAMING; 572 | V4L2_CAP_STREAMING;
570 else 573 else
571 cap->capabilities = V4L2_CAP_VIDEO_OUTPUT 574 cap->device_caps = V4L2_CAP_VIDEO_OUTPUT
572 | V4L2_CAP_STREAMING; 575 | V4L2_CAP_STREAMING;
573 break; 576 break;
574 } 577 }
575 578
579 /* Priority */
580 case VIDIOC_G_PRIORITY:
581 *(u32 *)arg = v4l2_prio_max(vdev->prio);
582 break;
583
584 case VIDIOC_S_PRIORITY:
585 ret = v4l2_prio_check(vdev->prio, handle->vfh.prio);
586 if (ret < 0)
587 return ret;
588
589 return v4l2_prio_change(vdev->prio, &handle->vfh.prio,
590 *(u32 *)arg);
591
576 /* Get, Set & Query control */ 592 /* Get, Set & Query control */
577 case VIDIOC_QUERYCTRL: 593 case VIDIOC_QUERYCTRL:
578 return uvc_query_v4l2_ctrl(chain, arg); 594 return uvc_query_v4l2_ctrl(chain, arg);
@@ -591,8 +607,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
591 607
592 ret = uvc_ctrl_get(chain, &xctrl); 608 ret = uvc_ctrl_get(chain, &xctrl);
593 uvc_ctrl_rollback(handle); 609 uvc_ctrl_rollback(handle);
594 if (ret >= 0) 610 if (ret < 0)
595 ctrl->value = xctrl.value; 611 return ret == -ENOENT ? -EINVAL : ret;
612
613 ctrl->value = xctrl.value;
596 break; 614 break;
597 } 615 }
598 616
@@ -601,6 +619,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
601 struct v4l2_control *ctrl = arg; 619 struct v4l2_control *ctrl = arg;
602 struct v4l2_ext_control xctrl; 620 struct v4l2_ext_control xctrl;
603 621
622 ret = v4l2_prio_check(vdev->prio, handle->vfh.prio);
623 if (ret < 0)
624 return ret;
625
604 memset(&xctrl, 0, sizeof xctrl); 626 memset(&xctrl, 0, sizeof xctrl);
605 xctrl.id = ctrl->id; 627 xctrl.id = ctrl->id;
606 xctrl.value = ctrl->value; 628 xctrl.value = ctrl->value;
@@ -612,7 +634,7 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
612 ret = uvc_ctrl_set(chain, &xctrl); 634 ret = uvc_ctrl_set(chain, &xctrl);
613 if (ret < 0) { 635 if (ret < 0) {
614 uvc_ctrl_rollback(handle); 636 uvc_ctrl_rollback(handle);
615 return ret; 637 return ret == -ENOENT ? -EINVAL : ret;
616 } 638 }
617 ret = uvc_ctrl_commit(handle, &xctrl, 1); 639 ret = uvc_ctrl_commit(handle, &xctrl, 1);
618 if (ret == 0) 640 if (ret == 0)
@@ -637,8 +659,9 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
637 ret = uvc_ctrl_get(chain, ctrl); 659 ret = uvc_ctrl_get(chain, ctrl);
638 if (ret < 0) { 660 if (ret < 0) {
639 uvc_ctrl_rollback(handle); 661 uvc_ctrl_rollback(handle);
640 ctrls->error_idx = i; 662 ctrls->error_idx = ret == -ENOENT
641 return ret; 663 ? ctrls->count : i;
664 return ret == -ENOENT ? -EINVAL : ret;
642 } 665 }
643 } 666 }
644 ctrls->error_idx = 0; 667 ctrls->error_idx = 0;
@@ -647,6 +670,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
647 } 670 }
648 671
649 case VIDIOC_S_EXT_CTRLS: 672 case VIDIOC_S_EXT_CTRLS:
673 ret = v4l2_prio_check(vdev->prio, handle->vfh.prio);
674 if (ret < 0)
675 return ret;
676 /* Fall through */
650 case VIDIOC_TRY_EXT_CTRLS: 677 case VIDIOC_TRY_EXT_CTRLS:
651 { 678 {
652 struct v4l2_ext_controls *ctrls = arg; 679 struct v4l2_ext_controls *ctrls = arg;
@@ -661,8 +688,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
661 ret = uvc_ctrl_set(chain, ctrl); 688 ret = uvc_ctrl_set(chain, ctrl);
662 if (ret < 0) { 689 if (ret < 0) {
663 uvc_ctrl_rollback(handle); 690 uvc_ctrl_rollback(handle);
664 ctrls->error_idx = i; 691 ctrls->error_idx = (ret == -ENOENT &&
665 return ret; 692 cmd == VIDIOC_S_EXT_CTRLS)
693 ? ctrls->count : i;
694 return ret == -ENOENT ? -EINVAL : ret;
666 } 695 }
667 } 696 }
668 697
@@ -739,6 +768,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
739 { 768 {
740 u32 input = *(u32 *)arg + 1; 769 u32 input = *(u32 *)arg + 1;
741 770
771 ret = v4l2_prio_check(vdev->prio, handle->vfh.prio);
772 if (ret < 0)
773 return ret;
774
742 if ((ret = uvc_acquire_privileges(handle)) < 0) 775 if ((ret = uvc_acquire_privileges(handle)) < 0)
743 return ret; 776 return ret;
744 777
@@ -792,6 +825,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
792 } 825 }
793 826
794 case VIDIOC_S_FMT: 827 case VIDIOC_S_FMT:
828 ret = v4l2_prio_check(vdev->prio, handle->vfh.prio);
829 if (ret < 0)
830 return ret;
831
795 if ((ret = uvc_acquire_privileges(handle)) < 0) 832 if ((ret = uvc_acquire_privileges(handle)) < 0)
796 return ret; 833 return ret;
797 834
@@ -894,6 +931,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
894 return uvc_v4l2_get_streamparm(stream, arg); 931 return uvc_v4l2_get_streamparm(stream, arg);
895 932
896 case VIDIOC_S_PARM: 933 case VIDIOC_S_PARM:
934 ret = v4l2_prio_check(vdev->prio, handle->vfh.prio);
935 if (ret < 0)
936 return ret;
937
897 if ((ret = uvc_acquire_privileges(handle)) < 0) 938 if ((ret = uvc_acquire_privileges(handle)) < 0)
898 return ret; 939 return ret;
899 940
@@ -924,10 +965,14 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
924 965
925 case VIDIOC_G_CROP: 966 case VIDIOC_G_CROP:
926 case VIDIOC_S_CROP: 967 case VIDIOC_S_CROP:
927 return -EINVAL; 968 return -ENOTTY;
928 969
929 /* Buffers & streaming */ 970 /* Buffers & streaming */
930 case VIDIOC_REQBUFS: 971 case VIDIOC_REQBUFS:
972 ret = v4l2_prio_check(vdev->prio, handle->vfh.prio);
973 if (ret < 0)
974 return ret;
975
931 if ((ret = uvc_acquire_privileges(handle)) < 0) 976 if ((ret = uvc_acquire_privileges(handle)) < 0)
932 return ret; 977 return ret;
933 978
@@ -973,6 +1018,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
973 if (*type != stream->type) 1018 if (*type != stream->type)
974 return -EINVAL; 1019 return -EINVAL;
975 1020
1021 ret = v4l2_prio_check(vdev->prio, handle->vfh.prio);
1022 if (ret < 0)
1023 return ret;
1024
976 if (!uvc_has_privileges(handle)) 1025 if (!uvc_has_privileges(handle))
977 return -EBUSY; 1026 return -EBUSY;
978 1027
@@ -991,6 +1040,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
991 if (*type != stream->type) 1040 if (*type != stream->type)
992 return -EINVAL; 1041 return -EINVAL;
993 1042
1043 ret = v4l2_prio_check(vdev->prio, handle->vfh.prio);
1044 if (ret < 0)
1045 return ret;
1046
994 if (!uvc_has_privileges(handle)) 1047 if (!uvc_has_privileges(handle))
995 return -EBUSY; 1048 return -EBUSY;
996 1049
@@ -1030,7 +1083,7 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
1030 1083
1031 case VIDIOC_ENUMOUTPUT: 1084 case VIDIOC_ENUMOUTPUT:
1032 uvc_trace(UVC_TRACE_IOCTL, "Unsupported ioctl 0x%08x\n", cmd); 1085 uvc_trace(UVC_TRACE_IOCTL, "Unsupported ioctl 0x%08x\n", cmd);
1033 return -EINVAL; 1086 return -ENOTTY;
1034 1087
1035 case UVCIOC_CTRL_MAP: 1088 case UVCIOC_CTRL_MAP:
1036 return uvc_ioctl_ctrl_map(chain, arg); 1089 return uvc_ioctl_ctrl_map(chain, arg);
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 57c3076a4625..3394c3432011 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -1812,6 +1812,7 @@ int uvc_video_init(struct uvc_streaming *stream)
1812 probe->bFormatIndex = format->index; 1812 probe->bFormatIndex = format->index;
1813 probe->bFrameIndex = frame->bFrameIndex; 1813 probe->bFrameIndex = frame->bFrameIndex;
1814 1814
1815 stream->def_format = format;
1815 stream->cur_format = format; 1816 stream->cur_format = format;
1816 stream->cur_frame = frame; 1817 stream->cur_frame = frame;
1817 1818
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index af216ec45e39..af505fdd9b3f 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -225,10 +225,14 @@ struct uvc_format_desc {
225 * always be accessed with the UVC_ENTITY_* macros and never directly. 225 * always be accessed with the UVC_ENTITY_* macros and never directly.
226 */ 226 */
227 227
228#define UVC_ENTITY_FLAG_DEFAULT (1 << 0)
229
228struct uvc_entity { 230struct uvc_entity {
229 struct list_head list; /* Entity as part of a UVC device. */ 231 struct list_head list; /* Entity as part of a UVC device. */
230 struct list_head chain; /* Entity as part of a video device 232 struct list_head chain; /* Entity as part of a video device
231 * chain. */ 233 * chain. */
234 unsigned int flags;
235
232 __u8 id; 236 __u8 id;
233 __u16 type; 237 __u16 type;
234 char name[64]; 238 char name[64];
@@ -371,6 +375,9 @@ struct uvc_video_chain {
371 struct uvc_entity *selector; /* Selector unit */ 375 struct uvc_entity *selector; /* Selector unit */
372 376
373 struct mutex ctrl_mutex; /* Protects ctrl.info */ 377 struct mutex ctrl_mutex; /* Protects ctrl.info */
378
379 struct v4l2_prio_state prio; /* V4L2 priority state */
380 u32 caps; /* V4L2 chain-wide caps */
374}; 381};
375 382
376struct uvc_stats_frame { 383struct uvc_stats_frame {
@@ -436,6 +443,7 @@ struct uvc_streaming {
436 struct uvc_format *format; 443 struct uvc_format *format;
437 444
438 struct uvc_streaming_control ctrl; 445 struct uvc_streaming_control ctrl;
446 struct uvc_format *def_format;
439 struct uvc_format *cur_format; 447 struct uvc_format *cur_format;
440 struct uvc_frame *cur_frame; 448 struct uvc_frame *cur_frame;
441 /* Protect access to ctrl, cur_format, cur_frame and hardware video 449 /* Protect access to ctrl, cur_format, cur_frame and hardware video
diff --git a/drivers/media/usb/zr364xx/zr364xx.c b/drivers/media/usb/zr364xx/zr364xx.c
index 9afab35878b4..39edd4442932 100644
--- a/drivers/media/usb/zr364xx/zr364xx.c
+++ b/drivers/media/usb/zr364xx/zr364xx.c
@@ -1007,8 +1007,7 @@ static void read_pipe_completion(struct urb *purb)
1007 return; 1007 return;
1008 } 1008 }
1009 1009
1010 if (purb->actual_length < 0 || 1010 if (purb->actual_length > pipe_info->transfer_size) {
1011 purb->actual_length > pipe_info->transfer_size) {
1012 dev_err(&cam->udev->dev, "wrong number of bytes\n"); 1011 dev_err(&cam->udev->dev, "wrong number of bytes\n");
1013 return; 1012 return;
1014 } 1013 }
diff --git a/drivers/media/v4l2-core/Kconfig b/drivers/media/v4l2-core/Kconfig
index 0c54e19d9944..65875c3aba1b 100644
--- a/drivers/media/v4l2-core/Kconfig
+++ b/drivers/media/v4l2-core/Kconfig
@@ -59,6 +59,7 @@ config VIDEOBUF_DVB
59 59
60# Used by drivers that need Videobuf2 modules 60# Used by drivers that need Videobuf2 modules
61config VIDEOBUF2_CORE 61config VIDEOBUF2_CORE
62 select DMA_SHARED_BUFFER
62 tristate 63 tristate
63 64
64config VIDEOBUF2_MEMOPS 65config VIDEOBUF2_MEMOPS
@@ -68,11 +69,13 @@ config VIDEOBUF2_DMA_CONTIG
68 tristate 69 tristate
69 select VIDEOBUF2_CORE 70 select VIDEOBUF2_CORE
70 select VIDEOBUF2_MEMOPS 71 select VIDEOBUF2_MEMOPS
72 select DMA_SHARED_BUFFER
71 73
72config VIDEOBUF2_VMALLOC 74config VIDEOBUF2_VMALLOC
73 tristate 75 tristate
74 select VIDEOBUF2_CORE 76 select VIDEOBUF2_CORE
75 select VIDEOBUF2_MEMOPS 77 select VIDEOBUF2_MEMOPS
78 select DMA_SHARED_BUFFER
76 79
77config VIDEOBUF2_DMA_SG 80config VIDEOBUF2_DMA_SG
78 tristate 81 tristate
diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
index f995dd31151d..380ddd89fa4c 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -837,7 +837,7 @@ bool v4l2_detect_gtf(unsigned frame_height,
837 struct v4l2_dv_timings *fmt) 837 struct v4l2_dv_timings *fmt)
838{ 838{
839 int pix_clk; 839 int pix_clk;
840 int v_fp, v_bp, h_fp, h_bp, hsync; 840 int v_fp, v_bp, h_fp, hsync;
841 int frame_width, image_height, image_width; 841 int frame_width, image_height, image_width;
842 bool default_gtf; 842 bool default_gtf;
843 int h_blank; 843 int h_blank;
@@ -885,7 +885,6 @@ bool v4l2_detect_gtf(unsigned frame_height,
885 hsync = hsync - hsync % GTF_CELL_GRAN; 885 hsync = hsync - hsync % GTF_CELL_GRAN;
886 886
887 h_fp = h_blank / 2 - hsync; 887 h_fp = h_blank / 2 - hsync;
888 h_bp = h_blank / 2;
889 888
890 fmt->bt.polarities = polarities; 889 fmt->bt.polarities = polarities;
891 fmt->bt.width = image_width; 890 fmt->bt.width = image_width;
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
index 83ffb6436baf..7157af301b14 100644
--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
@@ -297,6 +297,7 @@ struct v4l2_plane32 {
297 union { 297 union {
298 __u32 mem_offset; 298 __u32 mem_offset;
299 compat_long_t userptr; 299 compat_long_t userptr;
300 __s32 fd;
300 } m; 301 } m;
301 __u32 data_offset; 302 __u32 data_offset;
302 __u32 reserved[11]; 303 __u32 reserved[11];
@@ -318,6 +319,7 @@ struct v4l2_buffer32 {
318 __u32 offset; 319 __u32 offset;
319 compat_long_t userptr; 320 compat_long_t userptr;
320 compat_caddr_t planes; 321 compat_caddr_t planes;
322 __s32 fd;
321 } m; 323 } m;
322 __u32 length; 324 __u32 length;
323 __u32 reserved2; 325 __u32 reserved2;
@@ -341,6 +343,9 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
341 up_pln = compat_ptr(p); 343 up_pln = compat_ptr(p);
342 if (put_user((unsigned long)up_pln, &up->m.userptr)) 344 if (put_user((unsigned long)up_pln, &up->m.userptr))
343 return -EFAULT; 345 return -EFAULT;
346 } else if (memory == V4L2_MEMORY_DMABUF) {
347 if (copy_in_user(&up->m.fd, &up32->m.fd, sizeof(int)))
348 return -EFAULT;
344 } else { 349 } else {
345 if (copy_in_user(&up->m.mem_offset, &up32->m.mem_offset, 350 if (copy_in_user(&up->m.mem_offset, &up32->m.mem_offset,
346 sizeof(__u32))) 351 sizeof(__u32)))
@@ -364,6 +369,11 @@ static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
364 if (copy_in_user(&up32->m.mem_offset, &up->m.mem_offset, 369 if (copy_in_user(&up32->m.mem_offset, &up->m.mem_offset,
365 sizeof(__u32))) 370 sizeof(__u32)))
366 return -EFAULT; 371 return -EFAULT;
372 /* For DMABUF, driver might've set up the fd, so copy it back. */
373 if (memory == V4L2_MEMORY_DMABUF)
374 if (copy_in_user(&up32->m.fd, &up->m.fd,
375 sizeof(int)))
376 return -EFAULT;
367 377
368 return 0; 378 return 0;
369} 379}
@@ -446,6 +456,10 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
446 if (get_user(kp->m.offset, &up->m.offset)) 456 if (get_user(kp->m.offset, &up->m.offset))
447 return -EFAULT; 457 return -EFAULT;
448 break; 458 break;
459 case V4L2_MEMORY_DMABUF:
460 if (get_user(kp->m.fd, &up->m.fd))
461 return -EFAULT;
462 break;
449 } 463 }
450 } 464 }
451 465
@@ -510,6 +524,10 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
510 if (put_user(kp->m.offset, &up->m.offset)) 524 if (put_user(kp->m.offset, &up->m.offset))
511 return -EFAULT; 525 return -EFAULT;
512 break; 526 break;
527 case V4L2_MEMORY_DMABUF:
528 if (put_user(kp->m.fd, &up->m.fd))
529 return -EFAULT;
530 break;
513 } 531 }
514 } 532 }
515 533
@@ -1000,6 +1018,7 @@ long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
1000 case VIDIOC_S_FBUF32: 1018 case VIDIOC_S_FBUF32:
1001 case VIDIOC_OVERLAY32: 1019 case VIDIOC_OVERLAY32:
1002 case VIDIOC_QBUF32: 1020 case VIDIOC_QBUF32:
1021 case VIDIOC_EXPBUF:
1003 case VIDIOC_DQBUF32: 1022 case VIDIOC_DQBUF32:
1004 case VIDIOC_STREAMON32: 1023 case VIDIOC_STREAMON32:
1005 case VIDIOC_STREAMOFF32: 1024 case VIDIOC_STREAMOFF32:
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index a2df842e5100..98dcad9c8a3b 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -571,6 +571,7 @@ static void determine_valid_ioctls(struct video_device *vdev)
571 SET_VALID_IOCTL(ops, VIDIOC_REQBUFS, vidioc_reqbufs); 571 SET_VALID_IOCTL(ops, VIDIOC_REQBUFS, vidioc_reqbufs);
572 SET_VALID_IOCTL(ops, VIDIOC_QUERYBUF, vidioc_querybuf); 572 SET_VALID_IOCTL(ops, VIDIOC_QUERYBUF, vidioc_querybuf);
573 SET_VALID_IOCTL(ops, VIDIOC_QBUF, vidioc_qbuf); 573 SET_VALID_IOCTL(ops, VIDIOC_QBUF, vidioc_qbuf);
574 SET_VALID_IOCTL(ops, VIDIOC_EXPBUF, vidioc_expbuf);
574 SET_VALID_IOCTL(ops, VIDIOC_DQBUF, vidioc_dqbuf); 575 SET_VALID_IOCTL(ops, VIDIOC_DQBUF, vidioc_dqbuf);
575 SET_VALID_IOCTL(ops, VIDIOC_STREAMON, vidioc_streamon); 576 SET_VALID_IOCTL(ops, VIDIOC_STREAMON, vidioc_streamon);
576 SET_VALID_IOCTL(ops, VIDIOC_STREAMOFF, vidioc_streamoff); 577 SET_VALID_IOCTL(ops, VIDIOC_STREAMOFF, vidioc_streamoff);
diff --git a/drivers/media/v4l2-core/v4l2-event.c b/drivers/media/v4l2-core/v4l2-event.c
index 18a040b935a3..c72009218152 100644
--- a/drivers/media/v4l2-core/v4l2-event.c
+++ b/drivers/media/v4l2-core/v4l2-event.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * Copyright (C) 2009--2010 Nokia Corporation. 6 * Copyright (C) 2009--2010 Nokia Corporation.
7 * 7 *
8 * Contact: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 8 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
9 * 9 *
10 * This program is free software; you can redistribute it and/or 10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License 11 * modify it under the terms of the GNU General Public License
diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c
index 9e3fc040ea20..e57c002b4150 100644
--- a/drivers/media/v4l2-core/v4l2-fh.c
+++ b/drivers/media/v4l2-core/v4l2-fh.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * Copyright (C) 2009--2010 Nokia Corporation. 6 * Copyright (C) 2009--2010 Nokia Corporation.
7 * 7 *
8 * Contact: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 8 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
9 * 9 *
10 * This program is free software; you can redistribute it and/or 10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License 11 * modify it under the terms of the GNU General Public License
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 8f388ff31ebb..aa6e7c788db2 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -155,6 +155,7 @@ static const char *v4l2_memory_names[] = {
155 [V4L2_MEMORY_MMAP] = "mmap", 155 [V4L2_MEMORY_MMAP] = "mmap",
156 [V4L2_MEMORY_USERPTR] = "userptr", 156 [V4L2_MEMORY_USERPTR] = "userptr",
157 [V4L2_MEMORY_OVERLAY] = "overlay", 157 [V4L2_MEMORY_OVERLAY] = "overlay",
158 [V4L2_MEMORY_DMABUF] = "dmabuf",
158}; 159};
159 160
160#define prt_names(a, arr) (((unsigned)(a)) < ARRAY_SIZE(arr) ? arr[a] : "unknown") 161#define prt_names(a, arr) (((unsigned)(a)) < ARRAY_SIZE(arr) ? arr[a] : "unknown")
@@ -453,6 +454,15 @@ static void v4l_print_buffer(const void *arg, bool write_only)
453 tc->type, tc->flags, tc->frames, *(__u32 *)tc->userbits); 454 tc->type, tc->flags, tc->frames, *(__u32 *)tc->userbits);
454} 455}
455 456
457static void v4l_print_exportbuffer(const void *arg, bool write_only)
458{
459 const struct v4l2_exportbuffer *p = arg;
460
461 pr_cont("fd=%d, type=%s, index=%u, plane=%u, flags=0x%08x\n",
462 p->fd, prt_names(p->type, v4l2_type_names),
463 p->index, p->plane, p->flags);
464}
465
456static void v4l_print_create_buffers(const void *arg, bool write_only) 466static void v4l_print_create_buffers(const void *arg, bool write_only)
457{ 467{
458 const struct v4l2_create_buffers *p = arg; 468 const struct v4l2_create_buffers *p = arg;
@@ -1960,6 +1970,7 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = {
1960 IOCTL_INFO_STD(VIDIOC_S_FBUF, vidioc_s_fbuf, v4l_print_framebuffer, INFO_FL_PRIO), 1970 IOCTL_INFO_STD(VIDIOC_S_FBUF, vidioc_s_fbuf, v4l_print_framebuffer, INFO_FL_PRIO),
1961 IOCTL_INFO_FNC(VIDIOC_OVERLAY, v4l_overlay, v4l_print_u32, INFO_FL_PRIO), 1971 IOCTL_INFO_FNC(VIDIOC_OVERLAY, v4l_overlay, v4l_print_u32, INFO_FL_PRIO),
1962 IOCTL_INFO_FNC(VIDIOC_QBUF, v4l_qbuf, v4l_print_buffer, INFO_FL_QUEUE), 1972 IOCTL_INFO_FNC(VIDIOC_QBUF, v4l_qbuf, v4l_print_buffer, INFO_FL_QUEUE),
1973 IOCTL_INFO_STD(VIDIOC_EXPBUF, vidioc_expbuf, v4l_print_exportbuffer, INFO_FL_QUEUE | INFO_FL_CLEAR(v4l2_exportbuffer, flags)),
1963 IOCTL_INFO_FNC(VIDIOC_DQBUF, v4l_dqbuf, v4l_print_buffer, INFO_FL_QUEUE), 1974 IOCTL_INFO_FNC(VIDIOC_DQBUF, v4l_dqbuf, v4l_print_buffer, INFO_FL_QUEUE),
1964 IOCTL_INFO_FNC(VIDIOC_STREAMON, v4l_streamon, v4l_print_buftype, INFO_FL_PRIO | INFO_FL_QUEUE), 1975 IOCTL_INFO_FNC(VIDIOC_STREAMON, v4l_streamon, v4l_print_buftype, INFO_FL_PRIO | INFO_FL_QUEUE),
1965 IOCTL_INFO_FNC(VIDIOC_STREAMOFF, v4l_streamoff, v4l_print_buftype, INFO_FL_PRIO | INFO_FL_QUEUE), 1976 IOCTL_INFO_FNC(VIDIOC_STREAMOFF, v4l_streamoff, v4l_print_buftype, INFO_FL_PRIO | INFO_FL_QUEUE),
diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c
index 3ac83583ad7a..438ea45d1074 100644
--- a/drivers/media/v4l2-core/v4l2-mem2mem.c
+++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
@@ -369,6 +369,19 @@ int v4l2_m2m_dqbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
369EXPORT_SYMBOL_GPL(v4l2_m2m_dqbuf); 369EXPORT_SYMBOL_GPL(v4l2_m2m_dqbuf);
370 370
371/** 371/**
372 * v4l2_m2m_expbuf() - export a source or destination buffer, depending on
373 * the type
374 */
375int v4l2_m2m_expbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
376 struct v4l2_exportbuffer *eb)
377{
378 struct vb2_queue *vq;
379
380 vq = v4l2_m2m_get_vq(m2m_ctx, eb->type);
381 return vb2_expbuf(vq, eb);
382}
383EXPORT_SYMBOL_GPL(v4l2_m2m_expbuf);
384/**
372 * v4l2_m2m_streamon() - turn on streaming for a video queue 385 * v4l2_m2m_streamon() - turn on streaming for a video queue
373 */ 386 */
374int v4l2_m2m_streamon(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, 387int v4l2_m2m_streamon(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
@@ -510,12 +523,10 @@ struct v4l2_m2m_dev *v4l2_m2m_init(struct v4l2_m2m_ops *m2m_ops)
510{ 523{
511 struct v4l2_m2m_dev *m2m_dev; 524 struct v4l2_m2m_dev *m2m_dev;
512 525
513 if (!m2m_ops) 526 if (!m2m_ops || WARN_ON(!m2m_ops->device_run) ||
527 WARN_ON(!m2m_ops->job_abort))
514 return ERR_PTR(-EINVAL); 528 return ERR_PTR(-EINVAL);
515 529
516 BUG_ON(!m2m_ops->device_run);
517 BUG_ON(!m2m_ops->job_abort);
518
519 m2m_dev = kzalloc(sizeof *m2m_dev, GFP_KERNEL); 530 m2m_dev = kzalloc(sizeof *m2m_dev, GFP_KERNEL);
520 if (!m2m_dev) 531 if (!m2m_dev)
521 return ERR_PTR(-ENOMEM); 532 return ERR_PTR(-ENOMEM);
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index dced41c1d993..996c248dea42 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -412,20 +412,20 @@ static int
412v4l2_subdev_link_validate_get_format(struct media_pad *pad, 412v4l2_subdev_link_validate_get_format(struct media_pad *pad,
413 struct v4l2_subdev_format *fmt) 413 struct v4l2_subdev_format *fmt)
414{ 414{
415 switch (media_entity_type(pad->entity)) { 415 if (media_entity_type(pad->entity) == MEDIA_ENT_T_V4L2_SUBDEV) {
416 case MEDIA_ENT_T_V4L2_SUBDEV: 416 struct v4l2_subdev *sd =
417 media_entity_to_v4l2_subdev(pad->entity);
418
417 fmt->which = V4L2_SUBDEV_FORMAT_ACTIVE; 419 fmt->which = V4L2_SUBDEV_FORMAT_ACTIVE;
418 fmt->pad = pad->index; 420 fmt->pad = pad->index;
419 return v4l2_subdev_call(media_entity_to_v4l2_subdev( 421 return v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt);
420 pad->entity),
421 pad, get_fmt, NULL, fmt);
422 default:
423 WARN(1, "Driver bug! Wrong media entity type %d, entity %s\n",
424 media_entity_type(pad->entity), pad->entity->name);
425 /* Fall through */
426 case MEDIA_ENT_T_DEVNODE_V4L:
427 return -EINVAL;
428 } 422 }
423
424 WARN(pad->entity->type != MEDIA_ENT_T_DEVNODE_V4L,
425 "Driver bug! Wrong media entity type 0x%08x, entity %s\n",
426 pad->entity->type, pad->entity->name);
427
428 return -EINVAL;
429} 429}
430 430
431int v4l2_subdev_link_validate(struct media_link *link) 431int v4l2_subdev_link_validate(struct media_link *link)
diff --git a/drivers/media/v4l2-core/videobuf-core.c b/drivers/media/v4l2-core/videobuf-core.c
index bf7a326b1cdc..5449e8aa984a 100644
--- a/drivers/media/v4l2-core/videobuf-core.c
+++ b/drivers/media/v4l2-core/videobuf-core.c
@@ -335,6 +335,9 @@ static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b,
335 case V4L2_MEMORY_OVERLAY: 335 case V4L2_MEMORY_OVERLAY:
336 b->m.offset = vb->boff; 336 b->m.offset = vb->boff;
337 break; 337 break;
338 case V4L2_MEMORY_DMABUF:
339 /* DMABUF is not handled in videobuf framework */
340 break;
338 } 341 }
339 342
340 b->flags = 0; 343 b->flags = 0;
@@ -405,6 +408,7 @@ int __videobuf_mmap_setup(struct videobuf_queue *q,
405 break; 408 break;
406 case V4L2_MEMORY_USERPTR: 409 case V4L2_MEMORY_USERPTR:
407 case V4L2_MEMORY_OVERLAY: 410 case V4L2_MEMORY_OVERLAY:
411 case V4L2_MEMORY_DMABUF:
408 /* nothing */ 412 /* nothing */
409 break; 413 break;
410 } 414 }
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 432df119af27..9f81be23a81f 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -109,6 +109,36 @@ static void __vb2_buf_userptr_put(struct vb2_buffer *vb)
109} 109}
110 110
111/** 111/**
112 * __vb2_plane_dmabuf_put() - release memory associated with
113 * a DMABUF shared plane
114 */
115static void __vb2_plane_dmabuf_put(struct vb2_queue *q, struct vb2_plane *p)
116{
117 if (!p->mem_priv)
118 return;
119
120 if (p->dbuf_mapped)
121 call_memop(q, unmap_dmabuf, p->mem_priv);
122
123 call_memop(q, detach_dmabuf, p->mem_priv);
124 dma_buf_put(p->dbuf);
125 memset(p, 0, sizeof(*p));
126}
127
128/**
129 * __vb2_buf_dmabuf_put() - release memory associated with
130 * a DMABUF shared buffer
131 */
132static void __vb2_buf_dmabuf_put(struct vb2_buffer *vb)
133{
134 struct vb2_queue *q = vb->vb2_queue;
135 unsigned int plane;
136
137 for (plane = 0; plane < vb->num_planes; ++plane)
138 __vb2_plane_dmabuf_put(q, &vb->planes[plane]);
139}
140
141/**
112 * __setup_offsets() - setup unique offsets ("cookies") for every plane in 142 * __setup_offsets() - setup unique offsets ("cookies") for every plane in
113 * every buffer on the queue 143 * every buffer on the queue
114 */ 144 */
@@ -230,6 +260,8 @@ static void __vb2_free_mem(struct vb2_queue *q, unsigned int buffers)
230 /* Free MMAP buffers or release USERPTR buffers */ 260 /* Free MMAP buffers or release USERPTR buffers */
231 if (q->memory == V4L2_MEMORY_MMAP) 261 if (q->memory == V4L2_MEMORY_MMAP)
232 __vb2_buf_mem_free(vb); 262 __vb2_buf_mem_free(vb);
263 else if (q->memory == V4L2_MEMORY_DMABUF)
264 __vb2_buf_dmabuf_put(vb);
233 else 265 else
234 __vb2_buf_userptr_put(vb); 266 __vb2_buf_userptr_put(vb);
235 } 267 }
@@ -362,6 +394,8 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
362 b->m.offset = vb->v4l2_planes[0].m.mem_offset; 394 b->m.offset = vb->v4l2_planes[0].m.mem_offset;
363 else if (q->memory == V4L2_MEMORY_USERPTR) 395 else if (q->memory == V4L2_MEMORY_USERPTR)
364 b->m.userptr = vb->v4l2_planes[0].m.userptr; 396 b->m.userptr = vb->v4l2_planes[0].m.userptr;
397 else if (q->memory == V4L2_MEMORY_DMABUF)
398 b->m.fd = vb->v4l2_planes[0].m.fd;
365 } 399 }
366 400
367 /* 401 /*
@@ -454,13 +488,28 @@ static int __verify_mmap_ops(struct vb2_queue *q)
454} 488}
455 489
456/** 490/**
491 * __verify_dmabuf_ops() - verify that all memory operations required for
492 * DMABUF queue type have been provided
493 */
494static int __verify_dmabuf_ops(struct vb2_queue *q)
495{
496 if (!(q->io_modes & VB2_DMABUF) || !q->mem_ops->attach_dmabuf ||
497 !q->mem_ops->detach_dmabuf || !q->mem_ops->map_dmabuf ||
498 !q->mem_ops->unmap_dmabuf)
499 return -EINVAL;
500
501 return 0;
502}
503
504/**
457 * __verify_memory_type() - Check whether the memory type and buffer type 505 * __verify_memory_type() - Check whether the memory type and buffer type
458 * passed to a buffer operation are compatible with the queue. 506 * passed to a buffer operation are compatible with the queue.
459 */ 507 */
460static int __verify_memory_type(struct vb2_queue *q, 508static int __verify_memory_type(struct vb2_queue *q,
461 enum v4l2_memory memory, enum v4l2_buf_type type) 509 enum v4l2_memory memory, enum v4l2_buf_type type)
462{ 510{
463 if (memory != V4L2_MEMORY_MMAP && memory != V4L2_MEMORY_USERPTR) { 511 if (memory != V4L2_MEMORY_MMAP && memory != V4L2_MEMORY_USERPTR &&
512 memory != V4L2_MEMORY_DMABUF) {
464 dprintk(1, "reqbufs: unsupported memory type\n"); 513 dprintk(1, "reqbufs: unsupported memory type\n");
465 return -EINVAL; 514 return -EINVAL;
466 } 515 }
@@ -484,6 +533,11 @@ static int __verify_memory_type(struct vb2_queue *q,
484 return -EINVAL; 533 return -EINVAL;
485 } 534 }
486 535
536 if (memory == V4L2_MEMORY_DMABUF && __verify_dmabuf_ops(q)) {
537 dprintk(1, "reqbufs: DMABUF for current setup unsupported\n");
538 return -EINVAL;
539 }
540
487 /* 541 /*
488 * Place the busy tests at the end: -EBUSY can be ignored when 542 * Place the busy tests at the end: -EBUSY can be ignored when
489 * create_bufs is called with count == 0, but count == 0 should still 543 * create_bufs is called with count == 0, but count == 0 should still
@@ -790,6 +844,7 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
790{ 844{
791 struct vb2_queue *q = vb->vb2_queue; 845 struct vb2_queue *q = vb->vb2_queue;
792 unsigned long flags; 846 unsigned long flags;
847 unsigned int plane;
793 848
794 if (vb->state != VB2_BUF_STATE_ACTIVE) 849 if (vb->state != VB2_BUF_STATE_ACTIVE)
795 return; 850 return;
@@ -800,6 +855,10 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
800 dprintk(4, "Done processing on buffer %d, state: %d\n", 855 dprintk(4, "Done processing on buffer %d, state: %d\n",
801 vb->v4l2_buf.index, vb->state); 856 vb->v4l2_buf.index, vb->state);
802 857
858 /* sync buffers */
859 for (plane = 0; plane < vb->num_planes; ++plane)
860 call_memop(q, finish, vb->planes[plane].mem_priv);
861
803 /* Add the buffer to the done buffers list */ 862 /* Add the buffer to the done buffers list */
804 spin_lock_irqsave(&q->done_lock, flags); 863 spin_lock_irqsave(&q->done_lock, flags);
805 vb->state = state; 864 vb->state = state;
@@ -845,6 +904,16 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b
845 b->m.planes[plane].length; 904 b->m.planes[plane].length;
846 } 905 }
847 } 906 }
907 if (b->memory == V4L2_MEMORY_DMABUF) {
908 for (plane = 0; plane < vb->num_planes; ++plane) {
909 v4l2_planes[plane].m.fd =
910 b->m.planes[plane].m.fd;
911 v4l2_planes[plane].length =
912 b->m.planes[plane].length;
913 v4l2_planes[plane].data_offset =
914 b->m.planes[plane].data_offset;
915 }
916 }
848 } else { 917 } else {
849 /* 918 /*
850 * Single-planar buffers do not use planes array, 919 * Single-planar buffers do not use planes array,
@@ -859,6 +928,13 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b
859 v4l2_planes[0].m.userptr = b->m.userptr; 928 v4l2_planes[0].m.userptr = b->m.userptr;
860 v4l2_planes[0].length = b->length; 929 v4l2_planes[0].length = b->length;
861 } 930 }
931
932 if (b->memory == V4L2_MEMORY_DMABUF) {
933 v4l2_planes[0].m.fd = b->m.fd;
934 v4l2_planes[0].length = b->length;
935 v4l2_planes[0].data_offset = 0;
936 }
937
862 } 938 }
863 939
864 vb->v4l2_buf.field = b->field; 940 vb->v4l2_buf.field = b->field;
@@ -959,14 +1035,121 @@ static int __qbuf_mmap(struct vb2_buffer *vb, const struct v4l2_buffer *b)
959} 1035}
960 1036
961/** 1037/**
1038 * __qbuf_dmabuf() - handle qbuf of a DMABUF buffer
1039 */
1040static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b)
1041{
1042 struct v4l2_plane planes[VIDEO_MAX_PLANES];
1043 struct vb2_queue *q = vb->vb2_queue;
1044 void *mem_priv;
1045 unsigned int plane;
1046 int ret;
1047 int write = !V4L2_TYPE_IS_OUTPUT(q->type);
1048
1049 /* Verify and copy relevant information provided by the userspace */
1050 __fill_vb2_buffer(vb, b, planes);
1051
1052 for (plane = 0; plane < vb->num_planes; ++plane) {
1053 struct dma_buf *dbuf = dma_buf_get(planes[plane].m.fd);
1054
1055 if (IS_ERR_OR_NULL(dbuf)) {
1056 dprintk(1, "qbuf: invalid dmabuf fd for plane %d\n",
1057 plane);
1058 ret = -EINVAL;
1059 goto err;
1060 }
1061
1062 /* use DMABUF size if length is not provided */
1063 if (planes[plane].length == 0)
1064 planes[plane].length = dbuf->size;
1065
1066 if (planes[plane].length < planes[plane].data_offset +
1067 q->plane_sizes[plane]) {
1068 ret = -EINVAL;
1069 goto err;
1070 }
1071
1072 /* Skip the plane if already verified */
1073 if (dbuf == vb->planes[plane].dbuf &&
1074 vb->v4l2_planes[plane].length == planes[plane].length) {
1075 dma_buf_put(dbuf);
1076 continue;
1077 }
1078
1079 dprintk(1, "qbuf: buffer for plane %d changed\n", plane);
1080
1081 /* Release previously acquired memory if present */
1082 __vb2_plane_dmabuf_put(q, &vb->planes[plane]);
1083 memset(&vb->v4l2_planes[plane], 0, sizeof(struct v4l2_plane));
1084
1085 /* Acquire each plane's memory */
1086 mem_priv = call_memop(q, attach_dmabuf, q->alloc_ctx[plane],
1087 dbuf, planes[plane].length, write);
1088 if (IS_ERR(mem_priv)) {
1089 dprintk(1, "qbuf: failed to attach dmabuf\n");
1090 ret = PTR_ERR(mem_priv);
1091 dma_buf_put(dbuf);
1092 goto err;
1093 }
1094
1095 vb->planes[plane].dbuf = dbuf;
1096 vb->planes[plane].mem_priv = mem_priv;
1097 }
1098
1099 /* TODO: This pins the buffer(s) with dma_buf_map_attachment()).. but
1100 * really we want to do this just before the DMA, not while queueing
1101 * the buffer(s)..
1102 */
1103 for (plane = 0; plane < vb->num_planes; ++plane) {
1104 ret = call_memop(q, map_dmabuf, vb->planes[plane].mem_priv);
1105 if (ret) {
1106 dprintk(1, "qbuf: failed to map dmabuf for plane %d\n",
1107 plane);
1108 goto err;
1109 }
1110 vb->planes[plane].dbuf_mapped = 1;
1111 }
1112
1113 /*
1114 * Call driver-specific initialization on the newly acquired buffer,
1115 * if provided.
1116 */
1117 ret = call_qop(q, buf_init, vb);
1118 if (ret) {
1119 dprintk(1, "qbuf: buffer initialization failed\n");
1120 goto err;
1121 }
1122
1123 /*
1124 * Now that everything is in order, copy relevant information
1125 * provided by userspace.
1126 */
1127 for (plane = 0; plane < vb->num_planes; ++plane)
1128 vb->v4l2_planes[plane] = planes[plane];
1129
1130 return 0;
1131err:
1132 /* In case of errors, release planes that were already acquired */
1133 __vb2_buf_dmabuf_put(vb);
1134
1135 return ret;
1136}
1137
1138/**
962 * __enqueue_in_driver() - enqueue a vb2_buffer in driver for processing 1139 * __enqueue_in_driver() - enqueue a vb2_buffer in driver for processing
963 */ 1140 */
964static void __enqueue_in_driver(struct vb2_buffer *vb) 1141static void __enqueue_in_driver(struct vb2_buffer *vb)
965{ 1142{
966 struct vb2_queue *q = vb->vb2_queue; 1143 struct vb2_queue *q = vb->vb2_queue;
1144 unsigned int plane;
967 1145
968 vb->state = VB2_BUF_STATE_ACTIVE; 1146 vb->state = VB2_BUF_STATE_ACTIVE;
969 atomic_inc(&q->queued_count); 1147 atomic_inc(&q->queued_count);
1148
1149 /* sync buffers */
1150 for (plane = 0; plane < vb->num_planes; ++plane)
1151 call_memop(q, prepare, vb->planes[plane].mem_priv);
1152
970 q->ops->buf_queue(vb); 1153 q->ops->buf_queue(vb);
971} 1154}
972 1155
@@ -982,6 +1165,9 @@ static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b)
982 case V4L2_MEMORY_USERPTR: 1165 case V4L2_MEMORY_USERPTR:
983 ret = __qbuf_userptr(vb, b); 1166 ret = __qbuf_userptr(vb, b);
984 break; 1167 break;
1168 case V4L2_MEMORY_DMABUF:
1169 ret = __qbuf_dmabuf(vb, b);
1170 break;
985 default: 1171 default:
986 WARN(1, "Invalid queue type\n"); 1172 WARN(1, "Invalid queue type\n");
987 ret = -EINVAL; 1173 ret = -EINVAL;
@@ -1303,6 +1489,30 @@ int vb2_wait_for_all_buffers(struct vb2_queue *q)
1303EXPORT_SYMBOL_GPL(vb2_wait_for_all_buffers); 1489EXPORT_SYMBOL_GPL(vb2_wait_for_all_buffers);
1304 1490
1305/** 1491/**
1492 * __vb2_dqbuf() - bring back the buffer to the DEQUEUED state
1493 */
1494static void __vb2_dqbuf(struct vb2_buffer *vb)
1495{
1496 struct vb2_queue *q = vb->vb2_queue;
1497 unsigned int i;
1498
1499 /* nothing to do if the buffer is already dequeued */
1500 if (vb->state == VB2_BUF_STATE_DEQUEUED)
1501 return;
1502
1503 vb->state = VB2_BUF_STATE_DEQUEUED;
1504
1505 /* unmap DMABUF buffer */
1506 if (q->memory == V4L2_MEMORY_DMABUF)
1507 for (i = 0; i < vb->num_planes; ++i) {
1508 if (!vb->planes[i].dbuf_mapped)
1509 continue;
1510 call_memop(q, unmap_dmabuf, vb->planes[i].mem_priv);
1511 vb->planes[i].dbuf_mapped = 0;
1512 }
1513}
1514
1515/**
1306 * vb2_dqbuf() - Dequeue a buffer to the userspace 1516 * vb2_dqbuf() - Dequeue a buffer to the userspace
1307 * @q: videobuf2 queue 1517 * @q: videobuf2 queue
1308 * @b: buffer structure passed from userspace to vidioc_dqbuf handler 1518 * @b: buffer structure passed from userspace to vidioc_dqbuf handler
@@ -1363,11 +1573,12 @@ int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking)
1363 __fill_v4l2_buffer(vb, b); 1573 __fill_v4l2_buffer(vb, b);
1364 /* Remove from videobuf queue */ 1574 /* Remove from videobuf queue */
1365 list_del(&vb->queued_entry); 1575 list_del(&vb->queued_entry);
1576 /* go back to dequeued state */
1577 __vb2_dqbuf(vb);
1366 1578
1367 dprintk(1, "dqbuf of buffer %d, with state %d\n", 1579 dprintk(1, "dqbuf of buffer %d, with state %d\n",
1368 vb->v4l2_buf.index, vb->state); 1580 vb->v4l2_buf.index, vb->state);
1369 1581
1370 vb->state = VB2_BUF_STATE_DEQUEUED;
1371 return 0; 1582 return 0;
1372} 1583}
1373EXPORT_SYMBOL_GPL(vb2_dqbuf); 1584EXPORT_SYMBOL_GPL(vb2_dqbuf);
@@ -1406,7 +1617,7 @@ static void __vb2_queue_cancel(struct vb2_queue *q)
1406 * Reinitialize all buffers for next use. 1617 * Reinitialize all buffers for next use.
1407 */ 1618 */
1408 for (i = 0; i < q->num_buffers; ++i) 1619 for (i = 0; i < q->num_buffers; ++i)
1409 q->bufs[i]->state = VB2_BUF_STATE_DEQUEUED; 1620 __vb2_dqbuf(q->bufs[i]);
1410} 1621}
1411 1622
1412/** 1623/**
@@ -1540,6 +1751,79 @@ static int __find_plane_by_offset(struct vb2_queue *q, unsigned long off,
1540} 1751}
1541 1752
1542/** 1753/**
1754 * vb2_expbuf() - Export a buffer as a file descriptor
1755 * @q: videobuf2 queue
1756 * @eb: export buffer structure passed from userspace to vidioc_expbuf
1757 * handler in driver
1758 *
1759 * The return values from this function are intended to be directly returned
1760 * from vidioc_expbuf handler in driver.
1761 */
1762int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb)
1763{
1764 struct vb2_buffer *vb = NULL;
1765 struct vb2_plane *vb_plane;
1766 int ret;
1767 struct dma_buf *dbuf;
1768
1769 if (q->memory != V4L2_MEMORY_MMAP) {
1770 dprintk(1, "Queue is not currently set up for mmap\n");
1771 return -EINVAL;
1772 }
1773
1774 if (!q->mem_ops->get_dmabuf) {
1775 dprintk(1, "Queue does not support DMA buffer exporting\n");
1776 return -EINVAL;
1777 }
1778
1779 if (eb->flags & ~O_CLOEXEC) {
1780 dprintk(1, "Queue does support only O_CLOEXEC flag\n");
1781 return -EINVAL;
1782 }
1783
1784 if (eb->type != q->type) {
1785 dprintk(1, "qbuf: invalid buffer type\n");
1786 return -EINVAL;
1787 }
1788
1789 if (eb->index >= q->num_buffers) {
1790 dprintk(1, "buffer index out of range\n");
1791 return -EINVAL;
1792 }
1793
1794 vb = q->bufs[eb->index];
1795
1796 if (eb->plane >= vb->num_planes) {
1797 dprintk(1, "buffer plane out of range\n");
1798 return -EINVAL;
1799 }
1800
1801 vb_plane = &vb->planes[eb->plane];
1802
1803 dbuf = call_memop(q, get_dmabuf, vb_plane->mem_priv);
1804 if (IS_ERR_OR_NULL(dbuf)) {
1805 dprintk(1, "Failed to export buffer %d, plane %d\n",
1806 eb->index, eb->plane);
1807 return -EINVAL;
1808 }
1809
1810 ret = dma_buf_fd(dbuf, eb->flags);
1811 if (ret < 0) {
1812 dprintk(3, "buffer %d, plane %d failed to export (%d)\n",
1813 eb->index, eb->plane, ret);
1814 dma_buf_put(dbuf);
1815 return ret;
1816 }
1817
1818 dprintk(3, "buffer %d, plane %d exported as %d descriptor\n",
1819 eb->index, eb->plane, ret);
1820 eb->fd = ret;
1821
1822 return 0;
1823}
1824EXPORT_SYMBOL_GPL(vb2_expbuf);
1825
1826/**
1543 * vb2_mmap() - map video buffers into application address space 1827 * vb2_mmap() - map video buffers into application address space
1544 * @q: videobuf2 queue 1828 * @q: videobuf2 queue
1545 * @vma: vma passed to the mmap file operation handler in the driver 1829 * @vma: vma passed to the mmap file operation handler in the driver
@@ -2245,6 +2529,16 @@ int vb2_ioctl_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
2245} 2529}
2246EXPORT_SYMBOL_GPL(vb2_ioctl_streamoff); 2530EXPORT_SYMBOL_GPL(vb2_ioctl_streamoff);
2247 2531
2532int vb2_ioctl_expbuf(struct file *file, void *priv, struct v4l2_exportbuffer *p)
2533{
2534 struct video_device *vdev = video_devdata(file);
2535
2536 if (vb2_queue_is_busy(vdev, file))
2537 return -EBUSY;
2538 return vb2_expbuf(vdev->queue, p);
2539}
2540EXPORT_SYMBOL_GPL(vb2_ioctl_expbuf);
2541
2248/* v4l2_file_operations helpers */ 2542/* v4l2_file_operations helpers */
2249 2543
2250int vb2_fop_mmap(struct file *file, struct vm_area_struct *vma) 2544int vb2_fop_mmap(struct file *file, struct vm_area_struct *vma)
diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c
index 4b7132660a93..10beaee7f0ae 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
@@ -10,7 +10,10 @@
10 * the Free Software Foundation. 10 * the Free Software Foundation.
11 */ 11 */
12 12
13#include <linux/dma-buf.h>
13#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/scatterlist.h>
16#include <linux/sched.h>
14#include <linux/slab.h> 17#include <linux/slab.h>
15#include <linux/dma-mapping.h> 18#include <linux/dma-mapping.h>
16 19
@@ -23,40 +26,158 @@ struct vb2_dc_conf {
23}; 26};
24 27
25struct vb2_dc_buf { 28struct vb2_dc_buf {
26 struct vb2_dc_conf *conf; 29 struct device *dev;
27 void *vaddr; 30 void *vaddr;
28 dma_addr_t dma_addr;
29 unsigned long size; 31 unsigned long size;
30 struct vm_area_struct *vma; 32 dma_addr_t dma_addr;
31 atomic_t refcount; 33 enum dma_data_direction dma_dir;
34 struct sg_table *dma_sgt;
35
36 /* MMAP related */
32 struct vb2_vmarea_handler handler; 37 struct vb2_vmarea_handler handler;
38 atomic_t refcount;
39 struct sg_table *sgt_base;
40
41 /* USERPTR related */
42 struct vm_area_struct *vma;
43
44 /* DMABUF related */
45 struct dma_buf_attachment *db_attach;
33}; 46};
34 47
35static void vb2_dma_contig_put(void *buf_priv); 48/*********************************************/
49/* scatterlist table functions */
50/*********************************************/
51
52
53static void vb2_dc_sgt_foreach_page(struct sg_table *sgt,
54 void (*cb)(struct page *pg))
55{
56 struct scatterlist *s;
57 unsigned int i;
58
59 for_each_sg(sgt->sgl, s, sgt->orig_nents, i) {
60 struct page *page = sg_page(s);
61 unsigned int n_pages = PAGE_ALIGN(s->offset + s->length)
62 >> PAGE_SHIFT;
63 unsigned int j;
64
65 for (j = 0; j < n_pages; ++j, ++page)
66 cb(page);
67 }
68}
69
70static unsigned long vb2_dc_get_contiguous_size(struct sg_table *sgt)
71{
72 struct scatterlist *s;
73 dma_addr_t expected = sg_dma_address(sgt->sgl);
74 unsigned int i;
75 unsigned long size = 0;
76
77 for_each_sg(sgt->sgl, s, sgt->nents, i) {
78 if (sg_dma_address(s) != expected)
79 break;
80 expected = sg_dma_address(s) + sg_dma_len(s);
81 size += sg_dma_len(s);
82 }
83 return size;
84}
85
86/*********************************************/
87/* callbacks for all buffers */
88/*********************************************/
89
90static void *vb2_dc_cookie(void *buf_priv)
91{
92 struct vb2_dc_buf *buf = buf_priv;
93
94 return &buf->dma_addr;
95}
96
97static void *vb2_dc_vaddr(void *buf_priv)
98{
99 struct vb2_dc_buf *buf = buf_priv;
100
101 return buf->vaddr;
102}
103
104static unsigned int vb2_dc_num_users(void *buf_priv)
105{
106 struct vb2_dc_buf *buf = buf_priv;
107
108 return atomic_read(&buf->refcount);
109}
110
111static void vb2_dc_prepare(void *buf_priv)
112{
113 struct vb2_dc_buf *buf = buf_priv;
114 struct sg_table *sgt = buf->dma_sgt;
115
116 /* DMABUF exporter will flush the cache for us */
117 if (!sgt || buf->db_attach)
118 return;
119
120 dma_sync_sg_for_device(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir);
121}
122
123static void vb2_dc_finish(void *buf_priv)
124{
125 struct vb2_dc_buf *buf = buf_priv;
126 struct sg_table *sgt = buf->dma_sgt;
127
128 /* DMABUF exporter will flush the cache for us */
129 if (!sgt || buf->db_attach)
130 return;
131
132 dma_sync_sg_for_cpu(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir);
133}
134
135/*********************************************/
136/* callbacks for MMAP buffers */
137/*********************************************/
138
139static void vb2_dc_put(void *buf_priv)
140{
141 struct vb2_dc_buf *buf = buf_priv;
142
143 if (!atomic_dec_and_test(&buf->refcount))
144 return;
145
146 if (buf->sgt_base) {
147 sg_free_table(buf->sgt_base);
148 kfree(buf->sgt_base);
149 }
150 dma_free_coherent(buf->dev, buf->size, buf->vaddr, buf->dma_addr);
151 put_device(buf->dev);
152 kfree(buf);
153}
36 154
37static void *vb2_dma_contig_alloc(void *alloc_ctx, unsigned long size) 155static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size)
38{ 156{
39 struct vb2_dc_conf *conf = alloc_ctx; 157 struct vb2_dc_conf *conf = alloc_ctx;
158 struct device *dev = conf->dev;
40 struct vb2_dc_buf *buf; 159 struct vb2_dc_buf *buf;
41 160
42 buf = kzalloc(sizeof *buf, GFP_KERNEL); 161 buf = kzalloc(sizeof *buf, GFP_KERNEL);
43 if (!buf) 162 if (!buf)
44 return ERR_PTR(-ENOMEM); 163 return ERR_PTR(-ENOMEM);
45 164
46 buf->vaddr = dma_alloc_coherent(conf->dev, size, &buf->dma_addr, 165 /* align image size to PAGE_SIZE */
47 GFP_KERNEL); 166 size = PAGE_ALIGN(size);
167
168 buf->vaddr = dma_alloc_coherent(dev, size, &buf->dma_addr, GFP_KERNEL);
48 if (!buf->vaddr) { 169 if (!buf->vaddr) {
49 dev_err(conf->dev, "dma_alloc_coherent of size %ld failed\n", 170 dev_err(dev, "dma_alloc_coherent of size %ld failed\n", size);
50 size);
51 kfree(buf); 171 kfree(buf);
52 return ERR_PTR(-ENOMEM); 172 return ERR_PTR(-ENOMEM);
53 } 173 }
54 174
55 buf->conf = conf; 175 /* Prevent the device from being released while the buffer is used */
176 buf->dev = get_device(dev);
56 buf->size = size; 177 buf->size = size;
57 178
58 buf->handler.refcount = &buf->refcount; 179 buf->handler.refcount = &buf->refcount;
59 buf->handler.put = vb2_dma_contig_put; 180 buf->handler.put = vb2_dc_put;
60 buf->handler.arg = buf; 181 buf->handler.arg = buf;
61 182
62 atomic_inc(&buf->refcount); 183 atomic_inc(&buf->refcount);
@@ -64,100 +185,569 @@ static void *vb2_dma_contig_alloc(void *alloc_ctx, unsigned long size)
64 return buf; 185 return buf;
65} 186}
66 187
67static void vb2_dma_contig_put(void *buf_priv) 188static int vb2_dc_mmap(void *buf_priv, struct vm_area_struct *vma)
68{ 189{
69 struct vb2_dc_buf *buf = buf_priv; 190 struct vb2_dc_buf *buf = buf_priv;
191 int ret;
70 192
71 if (atomic_dec_and_test(&buf->refcount)) { 193 if (!buf) {
72 dma_free_coherent(buf->conf->dev, buf->size, buf->vaddr, 194 printk(KERN_ERR "No buffer to map\n");
73 buf->dma_addr); 195 return -EINVAL;
74 kfree(buf); 196 }
197
198 /*
199 * dma_mmap_* uses vm_pgoff as in-buffer offset, but we want to
200 * map whole buffer
201 */
202 vma->vm_pgoff = 0;
203
204 ret = dma_mmap_coherent(buf->dev, vma, buf->vaddr,
205 buf->dma_addr, buf->size);
206
207 if (ret) {
208 pr_err("Remapping memory failed, error: %d\n", ret);
209 return ret;
75 } 210 }
211
212 vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
213 vma->vm_private_data = &buf->handler;
214 vma->vm_ops = &vb2_common_vm_ops;
215
216 vma->vm_ops->open(vma);
217
218 pr_debug("%s: mapped dma addr 0x%08lx at 0x%08lx, size %ld\n",
219 __func__, (unsigned long)buf->dma_addr, vma->vm_start,
220 buf->size);
221
222 return 0;
76} 223}
77 224
78static void *vb2_dma_contig_cookie(void *buf_priv) 225/*********************************************/
226/* DMABUF ops for exporters */
227/*********************************************/
228
229struct vb2_dc_attachment {
230 struct sg_table sgt;
231 enum dma_data_direction dir;
232};
233
234static int vb2_dc_dmabuf_ops_attach(struct dma_buf *dbuf, struct device *dev,
235 struct dma_buf_attachment *dbuf_attach)
79{ 236{
80 struct vb2_dc_buf *buf = buf_priv; 237 struct vb2_dc_attachment *attach;
238 unsigned int i;
239 struct scatterlist *rd, *wr;
240 struct sg_table *sgt;
241 struct vb2_dc_buf *buf = dbuf->priv;
242 int ret;
81 243
82 return &buf->dma_addr; 244 attach = kzalloc(sizeof(*attach), GFP_KERNEL);
245 if (!attach)
246 return -ENOMEM;
247
248 sgt = &attach->sgt;
249 /* Copy the buf->base_sgt scatter list to the attachment, as we can't
250 * map the same scatter list to multiple attachments at the same time.
251 */
252 ret = sg_alloc_table(sgt, buf->sgt_base->orig_nents, GFP_KERNEL);
253 if (ret) {
254 kfree(attach);
255 return -ENOMEM;
256 }
257
258 rd = buf->sgt_base->sgl;
259 wr = sgt->sgl;
260 for (i = 0; i < sgt->orig_nents; ++i) {
261 sg_set_page(wr, sg_page(rd), rd->length, rd->offset);
262 rd = sg_next(rd);
263 wr = sg_next(wr);
264 }
265
266 attach->dir = DMA_NONE;
267 dbuf_attach->priv = attach;
268
269 return 0;
83} 270}
84 271
85static void *vb2_dma_contig_vaddr(void *buf_priv) 272static void vb2_dc_dmabuf_ops_detach(struct dma_buf *dbuf,
273 struct dma_buf_attachment *db_attach)
86{ 274{
87 struct vb2_dc_buf *buf = buf_priv; 275 struct vb2_dc_attachment *attach = db_attach->priv;
88 if (!buf) 276 struct sg_table *sgt;
89 return NULL; 277
278 if (!attach)
279 return;
280
281 sgt = &attach->sgt;
282
283 /* release the scatterlist cache */
284 if (attach->dir != DMA_NONE)
285 dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents,
286 attach->dir);
287 sg_free_table(sgt);
288 kfree(attach);
289 db_attach->priv = NULL;
290}
291
292static struct sg_table *vb2_dc_dmabuf_ops_map(
293 struct dma_buf_attachment *db_attach, enum dma_data_direction dir)
294{
295 struct vb2_dc_attachment *attach = db_attach->priv;
296 /* stealing dmabuf mutex to serialize map/unmap operations */
297 struct mutex *lock = &db_attach->dmabuf->lock;
298 struct sg_table *sgt;
299 int ret;
300
301 mutex_lock(lock);
302
303 sgt = &attach->sgt;
304 /* return previously mapped sg table */
305 if (attach->dir == dir) {
306 mutex_unlock(lock);
307 return sgt;
308 }
309
310 /* release any previous cache */
311 if (attach->dir != DMA_NONE) {
312 dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents,
313 attach->dir);
314 attach->dir = DMA_NONE;
315 }
316
317 /* mapping to the client with new direction */
318 ret = dma_map_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, dir);
319 if (ret <= 0) {
320 pr_err("failed to map scatterlist\n");
321 mutex_unlock(lock);
322 return ERR_PTR(-EIO);
323 }
324
325 attach->dir = dir;
326
327 mutex_unlock(lock);
328
329 return sgt;
330}
331
332static void vb2_dc_dmabuf_ops_unmap(struct dma_buf_attachment *db_attach,
333 struct sg_table *sgt, enum dma_data_direction dir)
334{
335 /* nothing to be done here */
336}
337
338static void vb2_dc_dmabuf_ops_release(struct dma_buf *dbuf)
339{
340 /* drop reference obtained in vb2_dc_get_dmabuf */
341 vb2_dc_put(dbuf->priv);
342}
343
344static void *vb2_dc_dmabuf_ops_kmap(struct dma_buf *dbuf, unsigned long pgnum)
345{
346 struct vb2_dc_buf *buf = dbuf->priv;
347
348 return buf->vaddr + pgnum * PAGE_SIZE;
349}
350
351static void *vb2_dc_dmabuf_ops_vmap(struct dma_buf *dbuf)
352{
353 struct vb2_dc_buf *buf = dbuf->priv;
90 354
91 return buf->vaddr; 355 return buf->vaddr;
92} 356}
93 357
94static unsigned int vb2_dma_contig_num_users(void *buf_priv) 358static int vb2_dc_dmabuf_ops_mmap(struct dma_buf *dbuf,
359 struct vm_area_struct *vma)
95{ 360{
96 struct vb2_dc_buf *buf = buf_priv; 361 return vb2_dc_mmap(dbuf->priv, vma);
362}
97 363
98 return atomic_read(&buf->refcount); 364static struct dma_buf_ops vb2_dc_dmabuf_ops = {
365 .attach = vb2_dc_dmabuf_ops_attach,
366 .detach = vb2_dc_dmabuf_ops_detach,
367 .map_dma_buf = vb2_dc_dmabuf_ops_map,
368 .unmap_dma_buf = vb2_dc_dmabuf_ops_unmap,
369 .kmap = vb2_dc_dmabuf_ops_kmap,
370 .kmap_atomic = vb2_dc_dmabuf_ops_kmap,
371 .vmap = vb2_dc_dmabuf_ops_vmap,
372 .mmap = vb2_dc_dmabuf_ops_mmap,
373 .release = vb2_dc_dmabuf_ops_release,
374};
375
376static struct sg_table *vb2_dc_get_base_sgt(struct vb2_dc_buf *buf)
377{
378 int ret;
379 struct sg_table *sgt;
380
381 sgt = kmalloc(sizeof(*sgt), GFP_KERNEL);
382 if (!sgt) {
383 dev_err(buf->dev, "failed to alloc sg table\n");
384 return NULL;
385 }
386
387 ret = dma_get_sgtable(buf->dev, sgt, buf->vaddr, buf->dma_addr,
388 buf->size);
389 if (ret < 0) {
390 dev_err(buf->dev, "failed to get scatterlist from DMA API\n");
391 kfree(sgt);
392 return NULL;
393 }
394
395 return sgt;
99} 396}
100 397
101static int vb2_dma_contig_mmap(void *buf_priv, struct vm_area_struct *vma) 398static struct dma_buf *vb2_dc_get_dmabuf(void *buf_priv)
102{ 399{
103 struct vb2_dc_buf *buf = buf_priv; 400 struct vb2_dc_buf *buf = buf_priv;
401 struct dma_buf *dbuf;
104 402
105 if (!buf) { 403 if (!buf->sgt_base)
106 printk(KERN_ERR "No buffer to map\n"); 404 buf->sgt_base = vb2_dc_get_base_sgt(buf);
107 return -EINVAL; 405
406 if (WARN_ON(!buf->sgt_base))
407 return NULL;
408
409 dbuf = dma_buf_export(buf, &vb2_dc_dmabuf_ops, buf->size, 0);
410 if (IS_ERR(dbuf))
411 return NULL;
412
413 /* dmabuf keeps reference to vb2 buffer */
414 atomic_inc(&buf->refcount);
415
416 return dbuf;
417}
418
419/*********************************************/
420/* callbacks for USERPTR buffers */
421/*********************************************/
422
423static inline int vma_is_io(struct vm_area_struct *vma)
424{
425 return !!(vma->vm_flags & (VM_IO | VM_PFNMAP));
426}
427
428static int vb2_dc_get_user_pages(unsigned long start, struct page **pages,
429 int n_pages, struct vm_area_struct *vma, int write)
430{
431 if (vma_is_io(vma)) {
432 unsigned int i;
433
434 for (i = 0; i < n_pages; ++i, start += PAGE_SIZE) {
435 unsigned long pfn;
436 int ret = follow_pfn(vma, start, &pfn);
437
438 if (ret) {
439 pr_err("no page for address %lu\n", start);
440 return ret;
441 }
442 pages[i] = pfn_to_page(pfn);
443 }
444 } else {
445 int n;
446
447 n = get_user_pages(current, current->mm, start & PAGE_MASK,
448 n_pages, write, 1, pages, NULL);
449 /* negative error means that no page was pinned */
450 n = max(n, 0);
451 if (n != n_pages) {
452 pr_err("got only %d of %d user pages\n", n, n_pages);
453 while (n)
454 put_page(pages[--n]);
455 return -EFAULT;
456 }
108 } 457 }
109 458
110 return vb2_mmap_pfn_range(vma, buf->dma_addr, buf->size, 459 return 0;
111 &vb2_common_vm_ops, &buf->handler);
112} 460}
113 461
114static void *vb2_dma_contig_get_userptr(void *alloc_ctx, unsigned long vaddr, 462static void vb2_dc_put_dirty_page(struct page *page)
115 unsigned long size, int write)
116{ 463{
464 set_page_dirty_lock(page);
465 put_page(page);
466}
467
468static void vb2_dc_put_userptr(void *buf_priv)
469{
470 struct vb2_dc_buf *buf = buf_priv;
471 struct sg_table *sgt = buf->dma_sgt;
472
473 dma_unmap_sg(buf->dev, sgt->sgl, sgt->orig_nents, buf->dma_dir);
474 if (!vma_is_io(buf->vma))
475 vb2_dc_sgt_foreach_page(sgt, vb2_dc_put_dirty_page);
476
477 sg_free_table(sgt);
478 kfree(sgt);
479 vb2_put_vma(buf->vma);
480 kfree(buf);
481}
482
483static void *vb2_dc_get_userptr(void *alloc_ctx, unsigned long vaddr,
484 unsigned long size, int write)
485{
486 struct vb2_dc_conf *conf = alloc_ctx;
117 struct vb2_dc_buf *buf; 487 struct vb2_dc_buf *buf;
488 unsigned long start;
489 unsigned long end;
490 unsigned long offset;
491 struct page **pages;
492 int n_pages;
493 int ret = 0;
118 struct vm_area_struct *vma; 494 struct vm_area_struct *vma;
119 dma_addr_t dma_addr = 0; 495 struct sg_table *sgt;
120 int ret; 496 unsigned long contig_size;
497 unsigned long dma_align = dma_get_cache_alignment();
498
499 /* Only cache aligned DMA transfers are reliable */
500 if (!IS_ALIGNED(vaddr | size, dma_align)) {
501 pr_debug("user data must be aligned to %lu bytes\n", dma_align);
502 return ERR_PTR(-EINVAL);
503 }
504
505 if (!size) {
506 pr_debug("size is zero\n");
507 return ERR_PTR(-EINVAL);
508 }
121 509
122 buf = kzalloc(sizeof *buf, GFP_KERNEL); 510 buf = kzalloc(sizeof *buf, GFP_KERNEL);
123 if (!buf) 511 if (!buf)
124 return ERR_PTR(-ENOMEM); 512 return ERR_PTR(-ENOMEM);
125 513
126 ret = vb2_get_contig_userptr(vaddr, size, &vma, &dma_addr); 514 buf->dev = conf->dev;
515 buf->dma_dir = write ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
516
517 start = vaddr & PAGE_MASK;
518 offset = vaddr & ~PAGE_MASK;
519 end = PAGE_ALIGN(vaddr + size);
520 n_pages = (end - start) >> PAGE_SHIFT;
521
522 pages = kmalloc(n_pages * sizeof(pages[0]), GFP_KERNEL);
523 if (!pages) {
524 ret = -ENOMEM;
525 pr_err("failed to allocate pages table\n");
526 goto fail_buf;
527 }
528
529 /* current->mm->mmap_sem is taken by videobuf2 core */
530 vma = find_vma(current->mm, vaddr);
531 if (!vma) {
532 pr_err("no vma for address %lu\n", vaddr);
533 ret = -EFAULT;
534 goto fail_pages;
535 }
536
537 if (vma->vm_end < vaddr + size) {
538 pr_err("vma at %lu is too small for %lu bytes\n", vaddr, size);
539 ret = -EFAULT;
540 goto fail_pages;
541 }
542
543 buf->vma = vb2_get_vma(vma);
544 if (!buf->vma) {
545 pr_err("failed to copy vma\n");
546 ret = -ENOMEM;
547 goto fail_pages;
548 }
549
550 /* extract page list from userspace mapping */
551 ret = vb2_dc_get_user_pages(start, pages, n_pages, vma, write);
127 if (ret) { 552 if (ret) {
128 printk(KERN_ERR "Failed acquiring VMA for vaddr 0x%08lx\n", 553 pr_err("failed to get user pages\n");
129 vaddr); 554 goto fail_vma;
130 kfree(buf); 555 }
131 return ERR_PTR(ret); 556
557 sgt = kzalloc(sizeof(*sgt), GFP_KERNEL);
558 if (!sgt) {
559 pr_err("failed to allocate sg table\n");
560 ret = -ENOMEM;
561 goto fail_get_user_pages;
562 }
563
564 ret = sg_alloc_table_from_pages(sgt, pages, n_pages,
565 offset, size, GFP_KERNEL);
566 if (ret) {
567 pr_err("failed to initialize sg table\n");
568 goto fail_sgt;
132 } 569 }
133 570
571 /* pages are no longer needed */
572 kfree(pages);
573 pages = NULL;
574
575 sgt->nents = dma_map_sg(buf->dev, sgt->sgl, sgt->orig_nents,
576 buf->dma_dir);
577 if (sgt->nents <= 0) {
578 pr_err("failed to map scatterlist\n");
579 ret = -EIO;
580 goto fail_sgt_init;
581 }
582
583 contig_size = vb2_dc_get_contiguous_size(sgt);
584 if (contig_size < size) {
585 pr_err("contiguous mapping is too small %lu/%lu\n",
586 contig_size, size);
587 ret = -EFAULT;
588 goto fail_map_sg;
589 }
590
591 buf->dma_addr = sg_dma_address(sgt->sgl);
134 buf->size = size; 592 buf->size = size;
135 buf->dma_addr = dma_addr; 593 buf->dma_sgt = sgt;
136 buf->vma = vma;
137 594
138 return buf; 595 return buf;
596
597fail_map_sg:
598 dma_unmap_sg(buf->dev, sgt->sgl, sgt->orig_nents, buf->dma_dir);
599
600fail_sgt_init:
601 if (!vma_is_io(buf->vma))
602 vb2_dc_sgt_foreach_page(sgt, put_page);
603 sg_free_table(sgt);
604
605fail_sgt:
606 kfree(sgt);
607
608fail_get_user_pages:
609 if (pages && !vma_is_io(buf->vma))
610 while (n_pages)
611 put_page(pages[--n_pages]);
612
613fail_vma:
614 vb2_put_vma(buf->vma);
615
616fail_pages:
617 kfree(pages); /* kfree is NULL-proof */
618
619fail_buf:
620 kfree(buf);
621
622 return ERR_PTR(ret);
139} 623}
140 624
141static void vb2_dma_contig_put_userptr(void *mem_priv) 625/*********************************************/
626/* callbacks for DMABUF buffers */
627/*********************************************/
628
629static int vb2_dc_map_dmabuf(void *mem_priv)
142{ 630{
143 struct vb2_dc_buf *buf = mem_priv; 631 struct vb2_dc_buf *buf = mem_priv;
632 struct sg_table *sgt;
633 unsigned long contig_size;
144 634
145 if (!buf) 635 if (WARN_ON(!buf->db_attach)) {
636 pr_err("trying to pin a non attached buffer\n");
637 return -EINVAL;
638 }
639
640 if (WARN_ON(buf->dma_sgt)) {
641 pr_err("dmabuf buffer is already pinned\n");
642 return 0;
643 }
644
645 /* get the associated scatterlist for this buffer */
646 sgt = dma_buf_map_attachment(buf->db_attach, buf->dma_dir);
647 if (IS_ERR_OR_NULL(sgt)) {
648 pr_err("Error getting dmabuf scatterlist\n");
649 return -EINVAL;
650 }
651
652 /* checking if dmabuf is big enough to store contiguous chunk */
653 contig_size = vb2_dc_get_contiguous_size(sgt);
654 if (contig_size < buf->size) {
655 pr_err("contiguous chunk is too small %lu/%lu b\n",
656 contig_size, buf->size);
657 dma_buf_unmap_attachment(buf->db_attach, sgt, buf->dma_dir);
658 return -EFAULT;
659 }
660
661 buf->dma_addr = sg_dma_address(sgt->sgl);
662 buf->dma_sgt = sgt;
663
664 return 0;
665}
666
667static void vb2_dc_unmap_dmabuf(void *mem_priv)
668{
669 struct vb2_dc_buf *buf = mem_priv;
670 struct sg_table *sgt = buf->dma_sgt;
671
672 if (WARN_ON(!buf->db_attach)) {
673 pr_err("trying to unpin a not attached buffer\n");
146 return; 674 return;
675 }
147 676
148 vb2_put_vma(buf->vma); 677 if (WARN_ON(!sgt)) {
678 pr_err("dmabuf buffer is already unpinned\n");
679 return;
680 }
681
682 dma_buf_unmap_attachment(buf->db_attach, sgt, buf->dma_dir);
683
684 buf->dma_addr = 0;
685 buf->dma_sgt = NULL;
686}
687
688static void vb2_dc_detach_dmabuf(void *mem_priv)
689{
690 struct vb2_dc_buf *buf = mem_priv;
691
692 /* if vb2 works correctly you should never detach mapped buffer */
693 if (WARN_ON(buf->dma_addr))
694 vb2_dc_unmap_dmabuf(buf);
695
696 /* detach this attachment */
697 dma_buf_detach(buf->db_attach->dmabuf, buf->db_attach);
149 kfree(buf); 698 kfree(buf);
150} 699}
151 700
701static void *vb2_dc_attach_dmabuf(void *alloc_ctx, struct dma_buf *dbuf,
702 unsigned long size, int write)
703{
704 struct vb2_dc_conf *conf = alloc_ctx;
705 struct vb2_dc_buf *buf;
706 struct dma_buf_attachment *dba;
707
708 if (dbuf->size < size)
709 return ERR_PTR(-EFAULT);
710
711 buf = kzalloc(sizeof(*buf), GFP_KERNEL);
712 if (!buf)
713 return ERR_PTR(-ENOMEM);
714
715 buf->dev = conf->dev;
716 /* create attachment for the dmabuf with the user device */
717 dba = dma_buf_attach(dbuf, buf->dev);
718 if (IS_ERR(dba)) {
719 pr_err("failed to attach dmabuf\n");
720 kfree(buf);
721 return dba;
722 }
723
724 buf->dma_dir = write ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
725 buf->size = size;
726 buf->db_attach = dba;
727
728 return buf;
729}
730
731/*********************************************/
732/* DMA CONTIG exported functions */
733/*********************************************/
734
152const struct vb2_mem_ops vb2_dma_contig_memops = { 735const struct vb2_mem_ops vb2_dma_contig_memops = {
153 .alloc = vb2_dma_contig_alloc, 736 .alloc = vb2_dc_alloc,
154 .put = vb2_dma_contig_put, 737 .put = vb2_dc_put,
155 .cookie = vb2_dma_contig_cookie, 738 .get_dmabuf = vb2_dc_get_dmabuf,
156 .vaddr = vb2_dma_contig_vaddr, 739 .cookie = vb2_dc_cookie,
157 .mmap = vb2_dma_contig_mmap, 740 .vaddr = vb2_dc_vaddr,
158 .get_userptr = vb2_dma_contig_get_userptr, 741 .mmap = vb2_dc_mmap,
159 .put_userptr = vb2_dma_contig_put_userptr, 742 .get_userptr = vb2_dc_get_userptr,
160 .num_users = vb2_dma_contig_num_users, 743 .put_userptr = vb2_dc_put_userptr,
744 .prepare = vb2_dc_prepare,
745 .finish = vb2_dc_finish,
746 .map_dmabuf = vb2_dc_map_dmabuf,
747 .unmap_dmabuf = vb2_dc_unmap_dmabuf,
748 .attach_dmabuf = vb2_dc_attach_dmabuf,
749 .detach_dmabuf = vb2_dc_detach_dmabuf,
750 .num_users = vb2_dc_num_users,
161}; 751};
162EXPORT_SYMBOL_GPL(vb2_dma_contig_memops); 752EXPORT_SYMBOL_GPL(vb2_dma_contig_memops);
163 753
diff --git a/drivers/media/v4l2-core/videobuf2-memops.c b/drivers/media/v4l2-core/videobuf2-memops.c
index 051ea3571b20..81c1ad8b2cf1 100644
--- a/drivers/media/v4l2-core/videobuf2-memops.c
+++ b/drivers/media/v4l2-core/videobuf2-memops.c
@@ -137,46 +137,6 @@ int vb2_get_contig_userptr(unsigned long vaddr, unsigned long size,
137EXPORT_SYMBOL_GPL(vb2_get_contig_userptr); 137EXPORT_SYMBOL_GPL(vb2_get_contig_userptr);
138 138
139/** 139/**
140 * vb2_mmap_pfn_range() - map physical pages to userspace
141 * @vma: virtual memory region for the mapping
142 * @paddr: starting physical address of the memory to be mapped
143 * @size: size of the memory to be mapped
144 * @vm_ops: vm operations to be assigned to the created area
145 * @priv: private data to be associated with the area
146 *
147 * Returns 0 on success.
148 */
149int vb2_mmap_pfn_range(struct vm_area_struct *vma, unsigned long paddr,
150 unsigned long size,
151 const struct vm_operations_struct *vm_ops,
152 void *priv)
153{
154 int ret;
155
156 size = min_t(unsigned long, vma->vm_end - vma->vm_start, size);
157
158 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
159 ret = remap_pfn_range(vma, vma->vm_start, paddr >> PAGE_SHIFT,
160 size, vma->vm_page_prot);
161 if (ret) {
162 printk(KERN_ERR "Remapping memory failed, error: %d\n", ret);
163 return ret;
164 }
165
166 vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
167 vma->vm_private_data = priv;
168 vma->vm_ops = vm_ops;
169
170 vma->vm_ops->open(vma);
171
172 pr_debug("%s: mapped paddr 0x%08lx at 0x%08lx, size %ld\n",
173 __func__, paddr, vma->vm_start, size);
174
175 return 0;
176}
177EXPORT_SYMBOL_GPL(vb2_mmap_pfn_range);
178
179/**
180 * vb2_common_vm_open() - increase refcount of the vma 140 * vb2_common_vm_open() - increase refcount of the vma
181 * @vma: virtual memory region for the mapping 141 * @vma: virtual memory region for the mapping
182 * 142 *
diff --git a/drivers/media/v4l2-core/videobuf2-vmalloc.c b/drivers/media/v4l2-core/videobuf2-vmalloc.c
index 94efa04d8d55..a47fd4f589a1 100644
--- a/drivers/media/v4l2-core/videobuf2-vmalloc.c
+++ b/drivers/media/v4l2-core/videobuf2-vmalloc.c
@@ -30,6 +30,7 @@ struct vb2_vmalloc_buf {
30 unsigned int n_pages; 30 unsigned int n_pages;
31 atomic_t refcount; 31 atomic_t refcount;
32 struct vb2_vmarea_handler handler; 32 struct vb2_vmarea_handler handler;
33 struct dma_buf *dbuf;
33}; 34};
34 35
35static void vb2_vmalloc_put(void *buf_priv); 36static void vb2_vmalloc_put(void *buf_priv);
@@ -207,11 +208,66 @@ static int vb2_vmalloc_mmap(void *buf_priv, struct vm_area_struct *vma)
207 return 0; 208 return 0;
208} 209}
209 210
211/*********************************************/
212/* callbacks for DMABUF buffers */
213/*********************************************/
214
215static int vb2_vmalloc_map_dmabuf(void *mem_priv)
216{
217 struct vb2_vmalloc_buf *buf = mem_priv;
218
219 buf->vaddr = dma_buf_vmap(buf->dbuf);
220
221 return buf->vaddr ? 0 : -EFAULT;
222}
223
224static void vb2_vmalloc_unmap_dmabuf(void *mem_priv)
225{
226 struct vb2_vmalloc_buf *buf = mem_priv;
227
228 dma_buf_vunmap(buf->dbuf, buf->vaddr);
229 buf->vaddr = NULL;
230}
231
232static void vb2_vmalloc_detach_dmabuf(void *mem_priv)
233{
234 struct vb2_vmalloc_buf *buf = mem_priv;
235
236 if (buf->vaddr)
237 dma_buf_vunmap(buf->dbuf, buf->vaddr);
238
239 kfree(buf);
240}
241
242static void *vb2_vmalloc_attach_dmabuf(void *alloc_ctx, struct dma_buf *dbuf,
243 unsigned long size, int write)
244{
245 struct vb2_vmalloc_buf *buf;
246
247 if (dbuf->size < size)
248 return ERR_PTR(-EFAULT);
249
250 buf = kzalloc(sizeof(*buf), GFP_KERNEL);
251 if (!buf)
252 return ERR_PTR(-ENOMEM);
253
254 buf->dbuf = dbuf;
255 buf->write = write;
256 buf->size = size;
257
258 return buf;
259}
260
261
210const struct vb2_mem_ops vb2_vmalloc_memops = { 262const struct vb2_mem_ops vb2_vmalloc_memops = {
211 .alloc = vb2_vmalloc_alloc, 263 .alloc = vb2_vmalloc_alloc,
212 .put = vb2_vmalloc_put, 264 .put = vb2_vmalloc_put,
213 .get_userptr = vb2_vmalloc_get_userptr, 265 .get_userptr = vb2_vmalloc_get_userptr,
214 .put_userptr = vb2_vmalloc_put_userptr, 266 .put_userptr = vb2_vmalloc_put_userptr,
267 .map_dmabuf = vb2_vmalloc_map_dmabuf,
268 .unmap_dmabuf = vb2_vmalloc_unmap_dmabuf,
269 .attach_dmabuf = vb2_vmalloc_attach_dmabuf,
270 .detach_dmabuf = vb2_vmalloc_detach_dmabuf,
215 .vaddr = vb2_vmalloc_vaddr, 271 .vaddr = vb2_vmalloc_vaddr,
216 .mmap = vb2_vmalloc_mmap, 272 .mmap = vb2_vmalloc_mmap,
217 .num_users = vb2_vmalloc_num_users, 273 .num_users = vb2_vmalloc_num_users,
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c
index 238910373f5c..479c643da2f6 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.c
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c
@@ -396,7 +396,9 @@ dt3155_open(struct file *filp)
396 pd->q->drv_priv = pd; 396 pd->q->drv_priv = pd;
397 pd->curr_buf = NULL; 397 pd->curr_buf = NULL;
398 pd->field_count = 0; 398 pd->field_count = 0;
399 vb2_queue_init(pd->q); /* cannot fail */ 399 ret = vb2_queue_init(pd->q);
400 if (ret < 0)
401 return ret;
400 INIT_LIST_HEAD(&pd->dmaq); 402 INIT_LIST_HEAD(&pd->dmaq);
401 spin_lock_init(&pd->lock); 403 spin_lock_init(&pd->lock);
402 /* disable all irqs, clear all irq flags */ 404 /* disable all irqs, clear all irq flags */
diff --git a/drivers/staging/media/go7007/go7007-fw.c b/drivers/staging/media/go7007/go7007-fw.c
index c9a6409edfe3..f99c05b454b0 100644
--- a/drivers/staging/media/go7007/go7007-fw.c
+++ b/drivers/staging/media/go7007/go7007-fw.c
@@ -382,8 +382,8 @@ static int gen_mjpeghdr_to_package(struct go7007 *go, __le16 *code, int space)
382 382
383 buf = kzalloc(4096, GFP_KERNEL); 383 buf = kzalloc(4096, GFP_KERNEL);
384 if (buf == NULL) { 384 if (buf == NULL) {
385 printk(KERN_ERR "go7007: unable to allocate 4096 bytes for " 385 dev_err(go->dev,
386 "firmware construction\n"); 386 "unable to allocate 4096 bytes for firmware construction\n");
387 return -1; 387 return -1;
388 } 388 }
389 389
@@ -652,8 +652,8 @@ static int gen_mpeg1hdr_to_package(struct go7007 *go,
652 652
653 buf = kzalloc(5120, GFP_KERNEL); 653 buf = kzalloc(5120, GFP_KERNEL);
654 if (buf == NULL) { 654 if (buf == NULL) {
655 printk(KERN_ERR "go7007: unable to allocate 5120 bytes for " 655 dev_err(go->dev,
656 "firmware construction\n"); 656 "unable to allocate 5120 bytes for firmware construction\n");
657 return -1; 657 return -1;
658 } 658 }
659 framelen[0] = mpeg1_frame_header(go, buf, 0, 1, PFRAME); 659 framelen[0] = mpeg1_frame_header(go, buf, 0, 1, PFRAME);
@@ -839,8 +839,8 @@ static int gen_mpeg4hdr_to_package(struct go7007 *go,
839 839
840 buf = kzalloc(5120, GFP_KERNEL); 840 buf = kzalloc(5120, GFP_KERNEL);
841 if (buf == NULL) { 841 if (buf == NULL) {
842 printk(KERN_ERR "go7007: unable to allocate 5120 bytes for " 842 dev_err(go->dev,
843 "firmware construction\n"); 843 "unable to allocate 5120 bytes for firmware construction\n");
844 return -1; 844 return -1;
845 } 845 }
846 framelen[0] = mpeg4_frame_header(go, buf, 0, PFRAME); 846 framelen[0] = mpeg4_frame_header(go, buf, 0, PFRAME);
@@ -1545,9 +1545,8 @@ static int do_special(struct go7007 *go, u16 type, __le16 *code, int space,
1545 case SPECIAL_MODET: 1545 case SPECIAL_MODET:
1546 return modet_to_package(go, code, space); 1546 return modet_to_package(go, code, space);
1547 } 1547 }
1548 printk(KERN_ERR 1548 dev_err(go->dev,
1549 "go7007: firmware file contains unsupported feature %04x\n", 1549 "firmware file contains unsupported feature %04x\n", type);
1550 type);
1551 return -1; 1550 return -1;
1552} 1551}
1553 1552
@@ -1577,15 +1576,16 @@ int go7007_construct_fw_image(struct go7007 *go, u8 **fw, int *fwlen)
1577 return -1; 1576 return -1;
1578 } 1577 }
1579 if (request_firmware(&fw_entry, go->board_info->firmware, go->dev)) { 1578 if (request_firmware(&fw_entry, go->board_info->firmware, go->dev)) {
1580 printk(KERN_ERR 1579 dev_err(go->dev,
1581 "go7007: unable to load firmware from file \"%s\"\n", 1580 "unable to load firmware from file \"%s\"\n",
1582 go->board_info->firmware); 1581 go->board_info->firmware);
1583 return -1; 1582 return -1;
1584 } 1583 }
1585 code = kzalloc(codespace * 2, GFP_KERNEL); 1584 code = kzalloc(codespace * 2, GFP_KERNEL);
1586 if (code == NULL) { 1585 if (code == NULL) {
1587 printk(KERN_ERR "go7007: unable to allocate %d bytes for " 1586 dev_err(go->dev,
1588 "firmware construction\n", codespace * 2); 1587 "unable to allocate %d bytes for firmware construction\n",
1588 codespace * 2);
1589 goto fw_failed; 1589 goto fw_failed;
1590 } 1590 }
1591 src = (__le16 *)fw_entry->data; 1591 src = (__le16 *)fw_entry->data;
@@ -1594,9 +1594,9 @@ int go7007_construct_fw_image(struct go7007 *go, u8 **fw, int *fwlen)
1594 chunk_flags = __le16_to_cpu(src[0]); 1594 chunk_flags = __le16_to_cpu(src[0]);
1595 chunk_len = __le16_to_cpu(src[1]); 1595 chunk_len = __le16_to_cpu(src[1]);
1596 if (chunk_len + 2 > srclen) { 1596 if (chunk_len + 2 > srclen) {
1597 printk(KERN_ERR "go7007: firmware file \"%s\" " 1597 dev_err(go->dev,
1598 "appears to be corrupted\n", 1598 "firmware file \"%s\" appears to be corrupted\n",
1599 go->board_info->firmware); 1599 go->board_info->firmware);
1600 goto fw_failed; 1600 goto fw_failed;
1601 } 1601 }
1602 if (chunk_flags & mode_flag) { 1602 if (chunk_flags & mode_flag) {
@@ -1604,17 +1604,15 @@ int go7007_construct_fw_image(struct go7007 *go, u8 **fw, int *fwlen)
1604 ret = do_special(go, __le16_to_cpu(src[2]), 1604 ret = do_special(go, __le16_to_cpu(src[2]),
1605 &code[i], codespace - i, framelen); 1605 &code[i], codespace - i, framelen);
1606 if (ret < 0) { 1606 if (ret < 0) {
1607 printk(KERN_ERR "go7007: insufficient " 1607 dev_err(go->dev,
1608 "memory for firmware " 1608 "insufficient memory for firmware construction\n");
1609 "construction\n");
1610 goto fw_failed; 1609 goto fw_failed;
1611 } 1610 }
1612 i += ret; 1611 i += ret;
1613 } else { 1612 } else {
1614 if (codespace - i < chunk_len) { 1613 if (codespace - i < chunk_len) {
1615 printk(KERN_ERR "go7007: insufficient " 1614 dev_err(go->dev,
1616 "memory for firmware " 1615 "insufficient memory for firmware construction\n");
1617 "construction\n");
1618 goto fw_failed; 1616 goto fw_failed;
1619 } 1617 }
1620 memcpy(&code[i], &src[2], chunk_len * 2); 1618 memcpy(&code[i], &src[2], chunk_len * 2);
diff --git a/drivers/staging/media/go7007/go7007-v4l2.c b/drivers/staging/media/go7007/go7007-v4l2.c
index 980371b02749..a78133b67de2 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -812,7 +812,7 @@ static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
812 return retval; 812 return retval;
813 813
814 mutex_lock(&gofh->lock); 814 mutex_lock(&gofh->lock);
815 if (buf->index < 0 || buf->index >= gofh->buf_count) 815 if (buf->index >= gofh->buf_count)
816 goto unlock_and_return; 816 goto unlock_and_return;
817 817
818 gobuf = &gofh->bufs[buf->index]; 818 gobuf = &gofh->bufs[buf->index];
diff --git a/drivers/staging/media/go7007/s2250-board.c b/drivers/staging/media/go7007/s2250-board.c
index 014d38410c99..b3974100c6cd 100644
--- a/drivers/staging/media/go7007/s2250-board.c
+++ b/drivers/staging/media/go7007/s2250-board.c
@@ -688,15 +688,4 @@ static struct i2c_driver s2250_driver = {
688 .id_table = s2250_id, 688 .id_table = s2250_id,
689}; 689};
690 690
691static __init int init_s2250(void) 691module_i2c_driver(s2250_driver);
692{
693 return i2c_add_driver(&s2250_driver);
694}
695
696static __exit void exit_s2250(void)
697{
698 i2c_del_driver(&s2250_driver);
699}
700
701module_init(init_s2250);
702module_exit(exit_s2250);
diff --git a/drivers/staging/media/go7007/wis-ov7640.c b/drivers/staging/media/go7007/wis-ov7640.c
index 6bc9470fecb6..9f01657f884a 100644
--- a/drivers/staging/media/go7007/wis-ov7640.c
+++ b/drivers/staging/media/go7007/wis-ov7640.c
@@ -29,8 +29,7 @@ struct wis_ov7640 {
29 int hue; 29 int hue;
30}; 30};
31 31
32static u8 initial_registers[] = 32static u8 initial_registers[] = {
33{
34 0x12, 0x80, 33 0x12, 0x80,
35 0x12, 0x54, 34 0x12, 0x54,
36 0x14, 0x24, 35 0x14, 0x24,
@@ -60,12 +59,12 @@ static int wis_ov7640_probe(struct i2c_client *client,
60 59
61 client->flags = I2C_CLIENT_SCCB; 60 client->flags = I2C_CLIENT_SCCB;
62 61
63 printk(KERN_DEBUG 62 dev_dbg(&client->dev,
64 "wis-ov7640: initializing OV7640 at address %d on %s\n", 63 "wis-ov7640: initializing OV7640 at address %d on %s\n",
65 client->addr, adapter->name); 64 client->addr, adapter->name);
66 65
67 if (write_regs(client, initial_registers) < 0) { 66 if (write_regs(client, initial_registers) < 0) {
68 printk(KERN_ERR "wis-ov7640: error initializing OV7640\n"); 67 dev_err(&client->dev, "wis-ov7640: error initializing OV7640\n");
69 return -ENODEV; 68 return -ENODEV;
70 } 69 }
71 70
@@ -92,17 +91,6 @@ static struct i2c_driver wis_ov7640_driver = {
92 .id_table = wis_ov7640_id, 91 .id_table = wis_ov7640_id,
93}; 92};
94 93
95static int __init wis_ov7640_init(void) 94module_i2c_driver(wis_ov7640_driver);
96{
97 return i2c_add_driver(&wis_ov7640_driver);
98}
99
100static void __exit wis_ov7640_cleanup(void)
101{
102 i2c_del_driver(&wis_ov7640_driver);
103}
104
105module_init(wis_ov7640_init);
106module_exit(wis_ov7640_cleanup);
107 95
108MODULE_LICENSE("GPL v2"); 96MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/media/go7007/wis-saa7113.c b/drivers/staging/media/go7007/wis-saa7113.c
index 05e0e1083864..8810c1e6e1ed 100644
--- a/drivers/staging/media/go7007/wis-saa7113.c
+++ b/drivers/staging/media/go7007/wis-saa7113.c
@@ -32,8 +32,7 @@ struct wis_saa7113 {
32 int hue; 32 int hue;
33}; 33};
34 34
35static u8 initial_registers[] = 35static u8 initial_registers[] = {
36{
37 0x01, 0x08, 36 0x01, 0x08,
38 0x02, 0xc0, 37 0x02, 0xc0,
39 0x03, 0x33, 38 0x03, 0x33,
@@ -282,12 +281,12 @@ static int wis_saa7113_probe(struct i2c_client *client,
282 dec->hue = 0; 281 dec->hue = 0;
283 i2c_set_clientdata(client, dec); 282 i2c_set_clientdata(client, dec);
284 283
285 printk(KERN_DEBUG 284 dev_dbg(&client->dev,
286 "wis-saa7113: initializing SAA7113 at address %d on %s\n", 285 "wis-saa7113: initializing SAA7113 at address %d on %s\n",
287 client->addr, adapter->name); 286 client->addr, adapter->name);
288 287
289 if (write_regs(client, initial_registers) < 0) { 288 if (write_regs(client, initial_registers) < 0) {
290 printk(KERN_ERR 289 dev_err(&client->dev,
291 "wis-saa7113: error initializing SAA7113\n"); 290 "wis-saa7113: error initializing SAA7113\n");
292 kfree(dec); 291 kfree(dec);
293 return -ENODEV; 292 return -ENODEV;
@@ -320,17 +319,6 @@ static struct i2c_driver wis_saa7113_driver = {
320 .id_table = wis_saa7113_id, 319 .id_table = wis_saa7113_id,
321}; 320};
322 321
323static int __init wis_saa7113_init(void) 322module_i2c_driver(wis_saa7113_driver);
324{
325 return i2c_add_driver(&wis_saa7113_driver);
326}
327
328static void __exit wis_saa7113_cleanup(void)
329{
330 i2c_del_driver(&wis_saa7113_driver);
331}
332
333module_init(wis_saa7113_init);
334module_exit(wis_saa7113_cleanup);
335 323
336MODULE_LICENSE("GPL v2"); 324MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/media/go7007/wis-saa7115.c b/drivers/staging/media/go7007/wis-saa7115.c
index 46cff59e28b7..fa86acd3fdf0 100644
--- a/drivers/staging/media/go7007/wis-saa7115.c
+++ b/drivers/staging/media/go7007/wis-saa7115.c
@@ -32,8 +32,7 @@ struct wis_saa7115 {
32 int hue; 32 int hue;
33}; 33};
34 34
35static u8 initial_registers[] = 35static u8 initial_registers[] = {
36{
37 0x01, 0x08, 36 0x01, 0x08,
38 0x02, 0xc0, 37 0x02, 0xc0,
39 0x03, 0x20, 38 0x03, 0x20,
@@ -415,12 +414,12 @@ static int wis_saa7115_probe(struct i2c_client *client,
415 dec->hue = 0; 414 dec->hue = 0;
416 i2c_set_clientdata(client, dec); 415 i2c_set_clientdata(client, dec);
417 416
418 printk(KERN_DEBUG 417 dev_dbg(&client->dev,
419 "wis-saa7115: initializing SAA7115 at address %d on %s\n", 418 "wis-saa7115: initializing SAA7115 at address %d on %s\n",
420 client->addr, adapter->name); 419 client->addr, adapter->name);
421 420
422 if (write_regs(client, initial_registers) < 0) { 421 if (write_regs(client, initial_registers) < 0) {
423 printk(KERN_ERR 422 dev_err(&client->dev,
424 "wis-saa7115: error initializing SAA7115\n"); 423 "wis-saa7115: error initializing SAA7115\n");
425 kfree(dec); 424 kfree(dec);
426 return -ENODEV; 425 return -ENODEV;
@@ -453,17 +452,6 @@ static struct i2c_driver wis_saa7115_driver = {
453 .id_table = wis_saa7115_id, 452 .id_table = wis_saa7115_id,
454}; 453};
455 454
456static int __init wis_saa7115_init(void) 455module_i2c_driver(wis_saa7115_driver);
457{
458 return i2c_add_driver(&wis_saa7115_driver);
459}
460
461static void __exit wis_saa7115_cleanup(void)
462{
463 i2c_del_driver(&wis_saa7115_driver);
464}
465
466module_init(wis_saa7115_init);
467module_exit(wis_saa7115_cleanup);
468 456
469MODULE_LICENSE("GPL v2"); 457MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/media/go7007/wis-sony-tuner.c b/drivers/staging/media/go7007/wis-sony-tuner.c
index 8f1b7d4f6a2e..1291ab79d2af 100644
--- a/drivers/staging/media/go7007/wis-sony-tuner.c
+++ b/drivers/staging/media/go7007/wis-sony-tuner.c
@@ -704,17 +704,6 @@ static struct i2c_driver wis_sony_tuner_driver = {
704 .id_table = wis_sony_tuner_id, 704 .id_table = wis_sony_tuner_id,
705}; 705};
706 706
707static int __init wis_sony_tuner_init(void) 707module_i2c_driver(wis_sony_tuner_driver);
708{
709 return i2c_add_driver(&wis_sony_tuner_driver);
710}
711
712static void __exit wis_sony_tuner_cleanup(void)
713{
714 i2c_del_driver(&wis_sony_tuner_driver);
715}
716
717module_init(wis_sony_tuner_init);
718module_exit(wis_sony_tuner_cleanup);
719 708
720MODULE_LICENSE("GPL v2"); 709MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/media/go7007/wis-tw2804.c b/drivers/staging/media/go7007/wis-tw2804.c
index 9134f03e3cf0..d6410ee01be8 100644
--- a/drivers/staging/media/go7007/wis-tw2804.c
+++ b/drivers/staging/media/go7007/wis-tw2804.c
@@ -341,17 +341,6 @@ static struct i2c_driver wis_tw2804_driver = {
341 .id_table = wis_tw2804_id, 341 .id_table = wis_tw2804_id,
342}; 342};
343 343
344static int __init wis_tw2804_init(void) 344module_i2c_driver(wis_tw2804_driver);
345{
346 return i2c_add_driver(&wis_tw2804_driver);
347}
348
349static void __exit wis_tw2804_cleanup(void)
350{
351 i2c_del_driver(&wis_tw2804_driver);
352}
353
354module_init(wis_tw2804_init);
355module_exit(wis_tw2804_cleanup);
356 345
357MODULE_LICENSE("GPL v2"); 346MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/media/go7007/wis-tw9903.c b/drivers/staging/media/go7007/wis-tw9903.c
index 9230f4a80529..94071def3bb4 100644
--- a/drivers/staging/media/go7007/wis-tw9903.c
+++ b/drivers/staging/media/go7007/wis-tw9903.c
@@ -325,17 +325,6 @@ static struct i2c_driver wis_tw9903_driver = {
325 .id_table = wis_tw9903_id, 325 .id_table = wis_tw9903_id,
326}; 326};
327 327
328static int __init wis_tw9903_init(void) 328module_i2c_driver(wis_tw9903_driver);
329{
330 return i2c_add_driver(&wis_tw9903_driver);
331}
332
333static void __exit wis_tw9903_cleanup(void)
334{
335 i2c_del_driver(&wis_tw9903_driver);
336}
337
338module_init(wis_tw9903_init);
339module_exit(wis_tw9903_cleanup);
340 329
341MODULE_LICENSE("GPL v2"); 330MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/media/go7007/wis-uda1342.c b/drivers/staging/media/go7007/wis-uda1342.c
index 0127be2f3be0..05ac798f35f7 100644
--- a/drivers/staging/media/go7007/wis-uda1342.c
+++ b/drivers/staging/media/go7007/wis-uda1342.c
@@ -98,17 +98,6 @@ static struct i2c_driver wis_uda1342_driver = {
98 .id_table = wis_uda1342_id, 98 .id_table = wis_uda1342_id,
99}; 99};
100 100
101static int __init wis_uda1342_init(void) 101module_i2c_driver(wis_uda1342_driver);
102{
103 return i2c_add_driver(&wis_uda1342_driver);
104}
105
106static void __exit wis_uda1342_cleanup(void)
107{
108 i2c_del_driver(&wis_uda1342_driver);
109}
110
111module_init(wis_uda1342_init);
112module_exit(wis_uda1342_cleanup);
113 102
114MODULE_LICENSE("GPL v2"); 103MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/media/lirc/lirc_serial.c b/drivers/staging/media/lirc/lirc_serial.c
index 71e3bf2937f9..b5d0088f3102 100644
--- a/drivers/staging/media/lirc/lirc_serial.c
+++ b/drivers/staging/media/lirc/lirc_serial.c
@@ -1239,6 +1239,10 @@ static int __init lirc_serial_init_module(void)
1239 } 1239 }
1240 } 1240 }
1241 1241
1242 /* make sure sense is either -1, 0, or 1 */
1243 if (sense != -1)
1244 sense = !!sense;
1245
1242 result = lirc_serial_init(); 1246 result = lirc_serial_init();
1243 if (result) 1247 if (result)
1244 return result; 1248 return result;
@@ -1298,7 +1302,7 @@ MODULE_PARM_DESC(irq, "Interrupt (4 or 3)");
1298module_param(share_irq, bool, S_IRUGO); 1302module_param(share_irq, bool, S_IRUGO);
1299MODULE_PARM_DESC(share_irq, "Share interrupts (0 = off, 1 = on)"); 1303MODULE_PARM_DESC(share_irq, "Share interrupts (0 = off, 1 = on)");
1300 1304
1301module_param(sense, bool, S_IRUGO); 1305module_param(sense, int, S_IRUGO);
1302MODULE_PARM_DESC(sense, "Override autodetection of IR receiver circuit" 1306MODULE_PARM_DESC(sense, "Override autodetection of IR receiver circuit"
1303 " (0 = active high, 1 = active low )"); 1307 " (0 = active high, 1 = active low )");
1304 1308
diff --git a/include/linux/dvb/Kbuild b/include/linux/dvb/Kbuild
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/include/linux/dvb/Kbuild
+++ /dev/null
diff --git a/include/linux/dvb/dmx.h b/include/linux/dvb/dmx.h
deleted file mode 100644
index 0be6d8f2b52b..000000000000
--- a/include/linux/dvb/dmx.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * dmx.h
3 *
4 * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>
5 * & Ralph Metzler <ralph@convergence.de>
6 * for convergence integrated media GmbH
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 *
22 */
23#ifndef _DVBDMX_H_
24#define _DVBDMX_H_
25
26#include <linux/time.h>
27#include <uapi/linux/dvb/dmx.h>
28
29#endif /*_DVBDMX_H_*/
diff --git a/include/linux/dvb/video.h b/include/linux/dvb/video.h
deleted file mode 100644
index 85c20d925696..000000000000
--- a/include/linux/dvb/video.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * video.h
3 *
4 * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>
5 * & Ralph Metzler <ralph@convergence.de>
6 * for convergence integrated media GmbH
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 *
22 */
23#ifndef _DVBVIDEO_H_
24#define _DVBVIDEO_H_
25
26#include <linux/compiler.h>
27#include <uapi/linux/dvb/video.h>
28
29#endif /*_DVBVIDEO_H_*/
diff --git a/include/media/adp1653.h b/include/media/adp1653.h
index 50a1af88aed0..1d9b48a3bd80 100644
--- a/include/media/adp1653.h
+++ b/include/media/adp1653.h
@@ -3,10 +3,10 @@
3 * 3 *
4 * Copyright (C) 2008--2011 Nokia Corporation 4 * Copyright (C) 2008--2011 Nokia Corporation
5 * 5 *
6 * Contact: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 6 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 9 * Sakari Ailus <sakari.ailus@iki.fi>
10 * Tuukka Toivonen <tuukkat76@gmail.com> 10 * Tuukka Toivonen <tuukkat76@gmail.com>
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
diff --git a/include/media/davinci/vpbe_display.h b/include/media/davinci/vpbe_display.h
index dbf6b37682cd..8dffffedbb59 100644
--- a/include/media/davinci/vpbe_display.h
+++ b/include/media/davinci/vpbe_display.h
@@ -16,7 +16,7 @@
16/* Header files */ 16/* Header files */
17#include <linux/videodev2.h> 17#include <linux/videodev2.h>
18#include <media/v4l2-common.h> 18#include <media/v4l2-common.h>
19#include <media/videobuf-dma-contig.h> 19#include <media/videobuf2-dma-contig.h>
20#include <media/davinci/vpbe_types.h> 20#include <media/davinci/vpbe_types.h>
21#include <media/davinci/vpbe_osd.h> 21#include <media/davinci/vpbe_osd.h>
22#include <media/davinci/vpbe.h> 22#include <media/davinci/vpbe.h>
@@ -62,6 +62,11 @@ struct display_layer_info {
62 enum osd_v_exp_ratio v_exp; 62 enum osd_v_exp_ratio v_exp;
63}; 63};
64 64
65struct vpbe_disp_buffer {
66 struct vb2_buffer vb;
67 struct list_head list;
68};
69
65/* vpbe display object structure */ 70/* vpbe display object structure */
66struct vpbe_layer { 71struct vpbe_layer {
67 /* number of buffers in fbuffers */ 72 /* number of buffers in fbuffers */
@@ -69,13 +74,15 @@ struct vpbe_layer {
69 /* Pointer to the vpbe_display */ 74 /* Pointer to the vpbe_display */
70 struct vpbe_display *disp_dev; 75 struct vpbe_display *disp_dev;
71 /* Pointer pointing to current v4l2_buffer */ 76 /* Pointer pointing to current v4l2_buffer */
72 struct videobuf_buffer *cur_frm; 77 struct vpbe_disp_buffer *cur_frm;
73 /* Pointer pointing to next v4l2_buffer */ 78 /* Pointer pointing to next v4l2_buffer */
74 struct videobuf_buffer *next_frm; 79 struct vpbe_disp_buffer *next_frm;
75 /* videobuf specific parameters 80 /* videobuf specific parameters
76 * Buffer queue used in video-buf 81 * Buffer queue used in video-buf
77 */ 82 */
78 struct videobuf_queue buffer_queue; 83 struct vb2_queue buffer_queue;
84 /* allocator-specific contexts for each plane */
85 struct vb2_alloc_ctx *alloc_ctx;
79 /* Queue of filled frames */ 86 /* Queue of filled frames */
80 struct list_head dma_queue; 87 struct list_head dma_queue;
81 /* Used in video-buf */ 88 /* Used in video-buf */
diff --git a/include/media/davinci/vpbe_osd.h b/include/media/davinci/vpbe_osd.h
index d7e397a444e6..5ab0d8d41f68 100644
--- a/include/media/davinci/vpbe_osd.h
+++ b/include/media/davinci/vpbe_osd.h
@@ -357,7 +357,7 @@ struct osd_state {
357 spinlock_t lock; 357 spinlock_t lock;
358 struct device *dev; 358 struct device *dev;
359 dma_addr_t osd_base_phys; 359 dma_addr_t osd_base_phys;
360 unsigned long osd_base; 360 void __iomem *osd_base;
361 unsigned long osd_size; 361 unsigned long osd_size;
362 /* 1-->the isr will toggle the VID0 ping-pong buffer */ 362 /* 1-->the isr will toggle the VID0 ping-pong buffer */
363 int pingpong; 363 int pingpong;
diff --git a/include/media/ir-kbd-i2c.h b/include/media/ir-kbd-i2c.h
index 768aa77925cd..e221bc74020b 100644
--- a/include/media/ir-kbd-i2c.h
+++ b/include/media/ir-kbd-i2c.h
@@ -37,7 +37,7 @@ enum ir_kbd_get_key_fn {
37struct IR_i2c_init_data { 37struct IR_i2c_init_data {
38 char *ir_codes; 38 char *ir_codes;
39 const char *name; 39 const char *name;
40 u64 type; /* RC_TYPE_RC5, etc */ 40 u64 type; /* RC_BIT_RC5, etc */
41 u32 polling_interval; /* 0 means DEFAULT_POLLING_INTERVAL */ 41 u32 polling_interval; /* 0 means DEFAULT_POLLING_INTERVAL */
42 42
43 /* 43 /*
diff --git a/include/media/mt9v022.h b/include/media/mt9v022.h
new file mode 100644
index 000000000000..40561801321a
--- /dev/null
+++ b/include/media/mt9v022.h
@@ -0,0 +1,16 @@
1/*
2 * mt9v022 sensor
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#ifndef __MT9V022_H__
10#define __MT9V022_H__
11
12struct mt9v022_platform_data {
13 unsigned short y_skip_top; /* Lines to skip at the top */
14};
15
16#endif
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index b0c494a69079..f03445f3c767 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -50,7 +50,7 @@ enum rc_driver_type {
50 * @input_dev: the input child device used to communicate events to userspace 50 * @input_dev: the input child device used to communicate events to userspace
51 * @driver_type: specifies if protocol decoding is done in hardware or software 51 * @driver_type: specifies if protocol decoding is done in hardware or software
52 * @idle: used to keep track of RX state 52 * @idle: used to keep track of RX state
53 * @allowed_protos: bitmask with the supported RC_TYPE_* protocols 53 * @allowed_protos: bitmask with the supported RC_BIT_* protocols
54 * @scanmask: some hardware decoders are not capable of providing the full 54 * @scanmask: some hardware decoders are not capable of providing the full
55 * scancode to the application. As this is a hardware limit, we can't do 55 * scancode to the application. As this is a hardware limit, we can't do
56 * anything with it. Yet, as the same keycode table can be used with other 56 * anything with it. Yet, as the same keycode table can be used with other
@@ -113,7 +113,7 @@ struct rc_dev {
113 u32 max_timeout; 113 u32 max_timeout;
114 u32 rx_resolution; 114 u32 rx_resolution;
115 u32 tx_resolution; 115 u32 tx_resolution;
116 int (*change_protocol)(struct rc_dev *dev, u64 rc_type); 116 int (*change_protocol)(struct rc_dev *dev, u64 *rc_type);
117 int (*open)(struct rc_dev *dev); 117 int (*open)(struct rc_dev *dev);
118 void (*close)(struct rc_dev *dev); 118 void (*close)(struct rc_dev *dev);
119 int (*s_tx_mask)(struct rc_dev *dev, u32 mask); 119 int (*s_tx_mask)(struct rc_dev *dev, u32 mask);
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index cfd5163ff7f3..74f55a3f14eb 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -11,22 +11,54 @@
11 11
12#include <linux/input.h> 12#include <linux/input.h>
13 13
14#define RC_TYPE_UNKNOWN 0 14enum rc_type {
15#define RC_TYPE_RC5 (1 << 0) /* Philips RC5 protocol */ 15 RC_TYPE_UNKNOWN = 0, /* Protocol not known */
16#define RC_TYPE_NEC (1 << 1) 16 RC_TYPE_OTHER = 1, /* Protocol known but proprietary */
17#define RC_TYPE_RC6 (1 << 2) /* Philips RC6 protocol */ 17 RC_TYPE_LIRC = 2, /* Pass raw IR to lirc userspace */
18#define RC_TYPE_JVC (1 << 3) /* JVC protocol */ 18 RC_TYPE_RC5 = 3, /* Philips RC5 protocol */
19#define RC_TYPE_SONY (1 << 4) /* Sony12/15/20 protocol */ 19 RC_TYPE_RC5X = 4, /* Philips RC5x protocol */
20#define RC_TYPE_RC5_SZ (1 << 5) /* RC5 variant used by Streamzap */ 20 RC_TYPE_RC5_SZ = 5, /* StreamZap variant of RC5 */
21#define RC_TYPE_SANYO (1 << 6) /* Sanyo protocol */ 21 RC_TYPE_JVC = 6, /* JVC protocol */
22#define RC_TYPE_MCE_KBD (1 << 29) /* RC6-ish MCE keyboard/mouse */ 22 RC_TYPE_SONY12 = 7, /* Sony 12 bit protocol */
23#define RC_TYPE_LIRC (1 << 30) /* Pass raw IR to lirc userspace */ 23 RC_TYPE_SONY15 = 8, /* Sony 15 bit protocol */
24#define RC_TYPE_OTHER (1u << 31) 24 RC_TYPE_SONY20 = 9, /* Sony 20 bit protocol */
25 RC_TYPE_NEC = 10, /* NEC protocol */
26 RC_TYPE_SANYO = 11, /* Sanyo protocol */
27 RC_TYPE_MCE_KBD = 12, /* RC6-ish MCE keyboard/mouse */
28 RC_TYPE_RC6_0 = 13, /* Philips RC6-0-16 protocol */
29 RC_TYPE_RC6_6A_20 = 14, /* Philips RC6-6A-20 protocol */
30 RC_TYPE_RC6_6A_24 = 15, /* Philips RC6-6A-24 protocol */
31 RC_TYPE_RC6_6A_32 = 16, /* Philips RC6-6A-32 protocol */
32 RC_TYPE_RC6_MCE = 17, /* MCE (Philips RC6-6A-32 subtype) protocol */
33};
34
35#define RC_BIT_NONE 0
36#define RC_BIT_UNKNOWN (1 << RC_TYPE_UNKNOWN)
37#define RC_BIT_OTHER (1 << RC_TYPE_OTHER)
38#define RC_BIT_LIRC (1 << RC_TYPE_LIRC)
39#define RC_BIT_RC5 (1 << RC_TYPE_RC5)
40#define RC_BIT_RC5X (1 << RC_TYPE_RC5X)
41#define RC_BIT_RC5_SZ (1 << RC_TYPE_RC5_SZ)
42#define RC_BIT_JVC (1 << RC_TYPE_JVC)
43#define RC_BIT_SONY12 (1 << RC_TYPE_SONY12)
44#define RC_BIT_SONY15 (1 << RC_TYPE_SONY15)
45#define RC_BIT_SONY20 (1 << RC_TYPE_SONY20)
46#define RC_BIT_NEC (1 << RC_TYPE_NEC)
47#define RC_BIT_SANYO (1 << RC_TYPE_SANYO)
48#define RC_BIT_MCE_KBD (1 << RC_TYPE_MCE_KBD)
49#define RC_BIT_RC6_0 (1 << RC_TYPE_RC6_0)
50#define RC_BIT_RC6_6A_20 (1 << RC_TYPE_RC6_6A_20)
51#define RC_BIT_RC6_6A_24 (1 << RC_TYPE_RC6_6A_24)
52#define RC_BIT_RC6_6A_32 (1 << RC_TYPE_RC6_6A_32)
53#define RC_BIT_RC6_MCE (1 << RC_TYPE_RC6_MCE)
25 54
26#define RC_TYPE_ALL (RC_TYPE_RC5 | RC_TYPE_NEC | RC_TYPE_RC6 | \ 55#define RC_BIT_ALL (RC_BIT_UNKNOWN | RC_BIT_OTHER | RC_BIT_LIRC | \
27 RC_TYPE_JVC | RC_TYPE_SONY | RC_TYPE_LIRC | \ 56 RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ | \
28 RC_TYPE_RC5_SZ | RC_TYPE_SANYO | RC_TYPE_MCE_KBD | \ 57 RC_BIT_JVC | \
29 RC_TYPE_OTHER) 58 RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20 | \
59 RC_BIT_NEC | RC_BIT_SANYO | RC_BIT_MCE_KBD | \
60 RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | \
61 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE)
30 62
31struct rc_map_table { 63struct rc_map_table {
32 u32 scancode; 64 u32 scancode;
@@ -38,7 +70,7 @@ struct rc_map {
38 unsigned int size; /* Max number of entries */ 70 unsigned int size; /* Max number of entries */
39 unsigned int len; /* Used number of entries */ 71 unsigned int len; /* Used number of entries */
40 unsigned int alloc; /* Size of *scan in bytes */ 72 unsigned int alloc; /* Size of *scan in bytes */
41 u64 rc_type; 73 enum rc_type rc_type;
42 const char *name; 74 const char *name;
43 spinlock_t lock; 75 spinlock_t lock;
44}; 76};
diff --git a/include/media/s3c_camif.h b/include/media/s3c_camif.h
new file mode 100644
index 000000000000..df96c2c789b4
--- /dev/null
+++ b/include/media/s3c_camif.h
@@ -0,0 +1,45 @@
1/*
2 * s3c24xx/s3c64xx SoC series Camera Interface (CAMIF) driver
3 *
4 * Copyright (C) 2012 Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9*/
10
11#ifndef MEDIA_S3C_CAMIF_
12#define MEDIA_S3C_CAMIF_
13
14#include <linux/i2c.h>
15#include <media/v4l2-mediabus.h>
16
17/**
18 * struct s3c_camif_sensor_info - an image sensor description
19 * @i2c_board_info: pointer to an I2C sensor subdevice board info
20 * @clock_frequency: frequency of the clock the host provides to a sensor
21 * @mbus_type: media bus type
22 * @i2c_bus_num: i2c control bus id the sensor is attached to
23 * @flags: the parallel bus flags defining signals polarity (V4L2_MBUS_*)
24 * @use_field: 1 if parallel bus FIELD signal is used (only s3c64xx)
25 */
26struct s3c_camif_sensor_info {
27 struct i2c_board_info i2c_board_info;
28 unsigned long clock_frequency;
29 enum v4l2_mbus_type mbus_type;
30 u16 i2c_bus_num;
31 u16 flags;
32 u8 use_field;
33};
34
35struct s3c_camif_plat_data {
36 struct s3c_camif_sensor_info sensor;
37 int (*gpio_get)(void);
38 int (*gpio_put)(void);
39};
40
41/* Platform default helper functions */
42int s3c_camif_gpio_get(void);
43int s3c_camif_gpio_put(void);
44
45#endif /* MEDIA_S3C_CAMIF_ */
diff --git a/include/media/smiapp.h b/include/media/smiapp.h
index 9ab07fd45d5c..07f96a89e189 100644
--- a/include/media/smiapp.h
+++ b/include/media/smiapp.h
@@ -4,7 +4,7 @@
4 * Generic driver for SMIA/SMIA++ compliant camera modules 4 * Generic driver for SMIA/SMIA++ compliant camera modules
5 * 5 *
6 * Copyright (C) 2011--2012 Nokia Corporation 6 * Copyright (C) 2011--2012 Nokia Corporation
7 * Contact: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 7 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
diff --git a/include/media/v4l2-event.h b/include/media/v4l2-event.h
index e7c5d170a9cd..eff85f934b24 100644
--- a/include/media/v4l2-event.h
+++ b/include/media/v4l2-event.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * Copyright (C) 2009--2010 Nokia Corporation. 6 * Copyright (C) 2009--2010 Nokia Corporation.
7 * 7 *
8 * Contact: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 8 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
9 * 9 *
10 * This program is free software; you can redistribute it and/or 10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License 11 * modify it under the terms of the GNU General Public License
diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
index 52513c225c18..a62ee18cb7b7 100644
--- a/include/media/v4l2-fh.h
+++ b/include/media/v4l2-fh.h
@@ -6,7 +6,7 @@
6 * 6 *
7 * Copyright (C) 2009--2010 Nokia Corporation. 7 * Copyright (C) 2009--2010 Nokia Corporation.
8 * 8 *
9 * Contact: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> 9 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
10 * 10 *
11 * This program is free software; you can redistribute it and/or 11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License 12 * modify it under the terms of the GNU General Public License
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index e48b571ca37d..4118ad1324c9 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -111,6 +111,8 @@ struct v4l2_ioctl_ops {
111 int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b); 111 int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b);
112 int (*vidioc_querybuf)(struct file *file, void *fh, struct v4l2_buffer *b); 112 int (*vidioc_querybuf)(struct file *file, void *fh, struct v4l2_buffer *b);
113 int (*vidioc_qbuf) (struct file *file, void *fh, struct v4l2_buffer *b); 113 int (*vidioc_qbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
114 int (*vidioc_expbuf) (struct file *file, void *fh,
115 struct v4l2_exportbuffer *e);
114 int (*vidioc_dqbuf) (struct file *file, void *fh, struct v4l2_buffer *b); 116 int (*vidioc_dqbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
115 117
116 int (*vidioc_create_bufs)(struct file *file, void *fh, struct v4l2_create_buffers *b); 118 int (*vidioc_create_bufs)(struct file *file, void *fh, struct v4l2_create_buffers *b);
diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h
index 131cc4a53675..7e82d2b193d5 100644
--- a/include/media/v4l2-mem2mem.h
+++ b/include/media/v4l2-mem2mem.h
@@ -111,6 +111,9 @@ int v4l2_m2m_qbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
111int v4l2_m2m_dqbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, 111int v4l2_m2m_dqbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
112 struct v4l2_buffer *buf); 112 struct v4l2_buffer *buf);
113 113
114int v4l2_m2m_expbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
115 struct v4l2_exportbuffer *eb);
116
114int v4l2_m2m_streamon(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, 117int v4l2_m2m_streamon(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
115 enum v4l2_buf_type type); 118 enum v4l2_buf_type type);
116int v4l2_m2m_streamoff(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, 119int v4l2_m2m_streamoff(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index e04252a9fea6..9cfd4ee9e56f 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -16,6 +16,7 @@
16#include <linux/mutex.h> 16#include <linux/mutex.h>
17#include <linux/poll.h> 17#include <linux/poll.h>
18#include <linux/videodev2.h> 18#include <linux/videodev2.h>
19#include <linux/dma-buf.h>
19 20
20struct vb2_alloc_ctx; 21struct vb2_alloc_ctx;
21struct vb2_fileio_data; 22struct vb2_fileio_data;
@@ -41,6 +42,24 @@ struct vb2_fileio_data;
41 * argument to other ops in this structure 42 * argument to other ops in this structure
42 * @put_userptr: inform the allocator that a USERPTR buffer will no longer 43 * @put_userptr: inform the allocator that a USERPTR buffer will no longer
43 * be used 44 * be used
45 * @attach_dmabuf: attach a shared struct dma_buf for a hardware operation;
46 * used for DMABUF memory types; alloc_ctx is the alloc context
47 * dbuf is the shared dma_buf; returns NULL on failure;
48 * allocator private per-buffer structure on success;
49 * this needs to be used for further accesses to the buffer
50 * @detach_dmabuf: inform the exporter of the buffer that the current DMABUF
51 * buffer is no longer used; the buf_priv argument is the
52 * allocator private per-buffer structure previously returned
53 * from the attach_dmabuf callback
54 * @map_dmabuf: request for access to the dmabuf from allocator; the allocator
55 * of dmabuf is informed that this driver is going to use the
56 * dmabuf
57 * @unmap_dmabuf: releases access control to the dmabuf - allocator is notified
58 * that this driver is done using the dmabuf for now
59 * @prepare: called every time the buffer is passed from userspace to the
60 * driver, useful for cache synchronisation, optional
61 * @finish: called every time the buffer is passed back from the driver
62 * to the userspace, also optional
44 * @vaddr: return a kernel virtual address to a given memory buffer 63 * @vaddr: return a kernel virtual address to a given memory buffer
45 * associated with the passed private structure or NULL if no 64 * associated with the passed private structure or NULL if no
46 * such mapping exists 65 * such mapping exists
@@ -56,15 +75,27 @@ struct vb2_fileio_data;
56 * Required ops for USERPTR types: get_userptr, put_userptr. 75 * Required ops for USERPTR types: get_userptr, put_userptr.
57 * Required ops for MMAP types: alloc, put, num_users, mmap. 76 * Required ops for MMAP types: alloc, put, num_users, mmap.
58 * Required ops for read/write access types: alloc, put, num_users, vaddr 77 * Required ops for read/write access types: alloc, put, num_users, vaddr
78 * Required ops for DMABUF types: attach_dmabuf, detach_dmabuf, map_dmabuf,
79 * unmap_dmabuf.
59 */ 80 */
60struct vb2_mem_ops { 81struct vb2_mem_ops {
61 void *(*alloc)(void *alloc_ctx, unsigned long size); 82 void *(*alloc)(void *alloc_ctx, unsigned long size);
62 void (*put)(void *buf_priv); 83 void (*put)(void *buf_priv);
84 struct dma_buf *(*get_dmabuf)(void *buf_priv);
63 85
64 void *(*get_userptr)(void *alloc_ctx, unsigned long vaddr, 86 void *(*get_userptr)(void *alloc_ctx, unsigned long vaddr,
65 unsigned long size, int write); 87 unsigned long size, int write);
66 void (*put_userptr)(void *buf_priv); 88 void (*put_userptr)(void *buf_priv);
67 89
90 void (*prepare)(void *buf_priv);
91 void (*finish)(void *buf_priv);
92
93 void *(*attach_dmabuf)(void *alloc_ctx, struct dma_buf *dbuf,
94 unsigned long size, int write);
95 void (*detach_dmabuf)(void *buf_priv);
96 int (*map_dmabuf)(void *buf_priv);
97 void (*unmap_dmabuf)(void *buf_priv);
98
68 void *(*vaddr)(void *buf_priv); 99 void *(*vaddr)(void *buf_priv);
69 void *(*cookie)(void *buf_priv); 100 void *(*cookie)(void *buf_priv);
70 101
@@ -75,6 +106,8 @@ struct vb2_mem_ops {
75 106
76struct vb2_plane { 107struct vb2_plane {
77 void *mem_priv; 108 void *mem_priv;
109 struct dma_buf *dbuf;
110 unsigned int dbuf_mapped;
78}; 111};
79 112
80/** 113/**
@@ -83,12 +116,14 @@ struct vb2_plane {
83 * @VB2_USERPTR: driver supports USERPTR with streaming API 116 * @VB2_USERPTR: driver supports USERPTR with streaming API
84 * @VB2_READ: driver supports read() style access 117 * @VB2_READ: driver supports read() style access
85 * @VB2_WRITE: driver supports write() style access 118 * @VB2_WRITE: driver supports write() style access
119 * @VB2_DMABUF: driver supports DMABUF with streaming API
86 */ 120 */
87enum vb2_io_modes { 121enum vb2_io_modes {
88 VB2_MMAP = (1 << 0), 122 VB2_MMAP = (1 << 0),
89 VB2_USERPTR = (1 << 1), 123 VB2_USERPTR = (1 << 1),
90 VB2_READ = (1 << 2), 124 VB2_READ = (1 << 2),
91 VB2_WRITE = (1 << 3), 125 VB2_WRITE = (1 << 3),
126 VB2_DMABUF = (1 << 4),
92}; 127};
93 128
94/** 129/**
@@ -329,6 +364,7 @@ int __must_check vb2_queue_init(struct vb2_queue *q);
329void vb2_queue_release(struct vb2_queue *q); 364void vb2_queue_release(struct vb2_queue *q);
330 365
331int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b); 366int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b);
367int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb);
332int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking); 368int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking);
333 369
334int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type); 370int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type);
@@ -438,6 +474,8 @@ int vb2_ioctl_qbuf(struct file *file, void *priv, struct v4l2_buffer *p);
438int vb2_ioctl_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p); 474int vb2_ioctl_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p);
439int vb2_ioctl_streamon(struct file *file, void *priv, enum v4l2_buf_type i); 475int vb2_ioctl_streamon(struct file *file, void *priv, enum v4l2_buf_type i);
440int vb2_ioctl_streamoff(struct file *file, void *priv, enum v4l2_buf_type i); 476int vb2_ioctl_streamoff(struct file *file, void *priv, enum v4l2_buf_type i);
477int vb2_ioctl_expbuf(struct file *file, void *priv,
478 struct v4l2_exportbuffer *p);
441 479
442/* struct v4l2_file_operations helpers */ 480/* struct v4l2_file_operations helpers */
443 481
diff --git a/include/media/videobuf2-memops.h b/include/media/videobuf2-memops.h
index 84e1f6c031c5..f05444ca8c0c 100644
--- a/include/media/videobuf2-memops.h
+++ b/include/media/videobuf2-memops.h
@@ -33,11 +33,6 @@ extern const struct vm_operations_struct vb2_common_vm_ops;
33int vb2_get_contig_userptr(unsigned long vaddr, unsigned long size, 33int vb2_get_contig_userptr(unsigned long vaddr, unsigned long size,
34 struct vm_area_struct **res_vma, dma_addr_t *res_pa); 34 struct vm_area_struct **res_vma, dma_addr_t *res_pa);
35 35
36int vb2_mmap_pfn_range(struct vm_area_struct *vma, unsigned long paddr,
37 unsigned long size,
38 const struct vm_operations_struct *vm_ops,
39 void *priv);
40
41struct vm_area_struct *vb2_get_vma(struct vm_area_struct *vma); 36struct vm_area_struct *vb2_get_vma(struct vm_area_struct *vma);
42void vb2_put_vma(struct vm_area_struct *vma); 37void vb2_put_vma(struct vm_area_struct *vma);
43 38
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 57bfa59cda74..3cf3e946e331 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -186,6 +186,7 @@ enum v4l2_memory {
186 V4L2_MEMORY_MMAP = 1, 186 V4L2_MEMORY_MMAP = 1,
187 V4L2_MEMORY_USERPTR = 2, 187 V4L2_MEMORY_USERPTR = 2,
188 V4L2_MEMORY_OVERLAY = 3, 188 V4L2_MEMORY_OVERLAY = 3,
189 V4L2_MEMORY_DMABUF = 4,
189}; 190};
190 191
191/* see also http://vektor.theorem.ca/graphics/ycbcr/ */ 192/* see also http://vektor.theorem.ca/graphics/ycbcr/ */
@@ -602,6 +603,8 @@ struct v4l2_requestbuffers {
602 * should be passed to mmap() called on the video node) 603 * should be passed to mmap() called on the video node)
603 * @userptr: when memory is V4L2_MEMORY_USERPTR, a userspace pointer 604 * @userptr: when memory is V4L2_MEMORY_USERPTR, a userspace pointer
604 * pointing to this plane 605 * pointing to this plane
606 * @fd: when memory is V4L2_MEMORY_DMABUF, a userspace file
607 * descriptor associated with this plane
605 * @data_offset: offset in the plane to the start of data; usually 0, 608 * @data_offset: offset in the plane to the start of data; usually 0,
606 * unless there is a header in front of the data 609 * unless there is a header in front of the data
607 * 610 *
@@ -616,6 +619,7 @@ struct v4l2_plane {
616 union { 619 union {
617 __u32 mem_offset; 620 __u32 mem_offset;
618 unsigned long userptr; 621 unsigned long userptr;
622 __s32 fd;
619 } m; 623 } m;
620 __u32 data_offset; 624 __u32 data_offset;
621 __u32 reserved[11]; 625 __u32 reserved[11];
@@ -640,6 +644,8 @@ struct v4l2_plane {
640 * (or a "cookie" that should be passed to mmap() as offset) 644 * (or a "cookie" that should be passed to mmap() as offset)
641 * @userptr: for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR; 645 * @userptr: for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
642 * a userspace pointer pointing to this buffer 646 * a userspace pointer pointing to this buffer
647 * @fd: for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;
648 * a userspace file descriptor associated with this buffer
643 * @planes: for multiplanar buffers; userspace pointer to the array of plane 649 * @planes: for multiplanar buffers; userspace pointer to the array of plane
644 * info structs for this buffer 650 * info structs for this buffer
645 * @length: size in bytes of the buffer (NOT its payload) for single-plane 651 * @length: size in bytes of the buffer (NOT its payload) for single-plane
@@ -666,6 +672,7 @@ struct v4l2_buffer {
666 __u32 offset; 672 __u32 offset;
667 unsigned long userptr; 673 unsigned long userptr;
668 struct v4l2_plane *planes; 674 struct v4l2_plane *planes;
675 __s32 fd;
669 } m; 676 } m;
670 __u32 length; 677 __u32 length;
671 __u32 reserved2; 678 __u32 reserved2;
@@ -687,6 +694,33 @@ struct v4l2_buffer {
687#define V4L2_BUF_FLAG_NO_CACHE_INVALIDATE 0x0800 694#define V4L2_BUF_FLAG_NO_CACHE_INVALIDATE 0x0800
688#define V4L2_BUF_FLAG_NO_CACHE_CLEAN 0x1000 695#define V4L2_BUF_FLAG_NO_CACHE_CLEAN 0x1000
689 696
697/**
698 * struct v4l2_exportbuffer - export of video buffer as DMABUF file descriptor
699 *
700 * @index: id number of the buffer
701 * @type: enum v4l2_buf_type; buffer type (type == *_MPLANE for
702 * multiplanar buffers);
703 * @plane: index of the plane to be exported, 0 for single plane queues
704 * @flags: flags for newly created file, currently only O_CLOEXEC is
705 * supported, refer to manual of open syscall for more details
706 * @fd: file descriptor associated with DMABUF (set by driver)
707 *
708 * Contains data used for exporting a video buffer as DMABUF file descriptor.
709 * The buffer is identified by a 'cookie' returned by VIDIOC_QUERYBUF
710 * (identical to the cookie used to mmap() the buffer to userspace). All
711 * reserved fields must be set to zero. The field reserved0 is expected to
712 * become a structure 'type' allowing an alternative layout of the structure
713 * content. Therefore this field should not be used for any other extensions.
714 */
715struct v4l2_exportbuffer {
716 __u32 type; /* enum v4l2_buf_type */
717 __u32 index;
718 __u32 plane;
719 __u32 flags;
720 __s32 fd;
721 __u32 reserved[11];
722};
723
690/* 724/*
691 * O V E R L A Y P R E V I E W 725 * O V E R L A Y P R E V I E W
692 */ 726 */
@@ -737,7 +771,7 @@ struct v4l2_window {
737struct v4l2_captureparm { 771struct v4l2_captureparm {
738 __u32 capability; /* Supported modes */ 772 __u32 capability; /* Supported modes */
739 __u32 capturemode; /* Current mode */ 773 __u32 capturemode; /* Current mode */
740 struct v4l2_fract timeperframe; /* Time per frame in .1us units */ 774 struct v4l2_fract timeperframe; /* Time per frame in seconds */
741 __u32 extendedmode; /* Driver-specific extensions */ 775 __u32 extendedmode; /* Driver-specific extensions */
742 __u32 readbuffers; /* # of buffers for read */ 776 __u32 readbuffers; /* # of buffers for read */
743 __u32 reserved[4]; 777 __u32 reserved[4];
@@ -1888,6 +1922,7 @@ struct v4l2_create_buffers {
1888#define VIDIOC_S_FBUF _IOW('V', 11, struct v4l2_framebuffer) 1922#define VIDIOC_S_FBUF _IOW('V', 11, struct v4l2_framebuffer)
1889#define VIDIOC_OVERLAY _IOW('V', 14, int) 1923#define VIDIOC_OVERLAY _IOW('V', 14, int)
1890#define VIDIOC_QBUF _IOWR('V', 15, struct v4l2_buffer) 1924#define VIDIOC_QBUF _IOWR('V', 15, struct v4l2_buffer)
1925#define VIDIOC_EXPBUF _IOWR('V', 16, struct v4l2_exportbuffer)
1891#define VIDIOC_DQBUF _IOWR('V', 17, struct v4l2_buffer) 1926#define VIDIOC_DQBUF _IOWR('V', 17, struct v4l2_buffer)
1892#define VIDIOC_STREAMON _IOW('V', 18, int) 1927#define VIDIOC_STREAMON _IOW('V', 18, int)
1893#define VIDIOC_STREAMOFF _IOW('V', 19, int) 1928#define VIDIOC_STREAMOFF _IOW('V', 19, int)