aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-02-21 19:58:32 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-02-21 19:58:32 -0500
commitff58d005cd10fcd372787cceac547e11cf706ff6 (patch)
tree7e7af56aa1a38731af1ec5f3cf09f13050bb0ff4
parent5ab356626f3cf97f00280f17a52e4b5b4a13e038 (diff)
parent9eeb0ed0f30938f31a3d9135a88b9502192c18dd (diff)
Merge tag 'media/v4.11-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab: - new drivers: - i.MX6 Video Data Order Adapter's (VDOA) - Toshiba et8ek8 5MP sensor - STM DELTA multi-format video decoder V4L2 driver - SPI connected IR LED - Mediatek IR remote receiver - ZyDAS ZD1301 DVB USB interface driver - new RC keymaps - some very old LIRC drivers got removed from staging - RC core gained support encoding IR scan codes - DVB si2168 gained support for DVBv5 statistics - lirc_sir driver ported to rc-core and promoted from staging - other bug fixes, board additions and driver improvements * tag 'media/v4.11-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (230 commits) [media] mtk-vcodec: fix build warnings without DEBUG [media] zd1301: fix building interface driver without demodulator [media] usbtv: add sharpness control [media] cxusb: Use a dma capable buffer also for reading [media] ttpci: address stringop overflow warning [media] dvb-usb-v2: avoid use-after-free [media] add Hama Hybrid DVB-T Stick support [media] et8ek8: Fix compiler / Coccinelle warnings [media] media: fix semicolon.cocci warnings [media] media: exynos4-is: add flags to dummy Exynos IS i2c adapter [media] v4l: of: check for unique lanes in data-lanes and clock-lanes [media] coda/imx-vdoa: constify structs [media] st-delta: debug: trace stream/frame information & summary [media] st-delta: add mjpeg support [media] st-delta: EOS (End Of Stream) support [media] st-delta: rpmsg ipc support [media] st-delta: add memory allocator helper functions [media] st-delta: STiH4xx multi-format video decoder v4l2 driver [media] MAINTAINERS: add st-delta driver [media] ARM: multi_v7_defconfig: enable STMicroelectronics DELTA Support ...
-rw-r--r--Documentation/ABI/testing/sysfs-class-rc14
-rw-r--r--Documentation/devicetree/bindings/leds/irled/spi-ir-led.txt29
-rw-r--r--Documentation/devicetree/bindings/media/fsl-vdoa.txt21
-rw-r--r--Documentation/devicetree/bindings/media/gpio-ir-receiver.txt3
-rw-r--r--Documentation/devicetree/bindings/media/hix5hd2-ir.txt2
-rw-r--r--Documentation/devicetree/bindings/media/i2c/toshiba,et8ek8.txt48
-rw-r--r--Documentation/devicetree/bindings/media/meson-ir.txt3
-rw-r--r--Documentation/devicetree/bindings/media/mtk-cir.txt24
-rw-r--r--Documentation/devicetree/bindings/media/rc.txt117
-rw-r--r--Documentation/devicetree/bindings/media/st,st-delta.txt17
-rw-r--r--Documentation/devicetree/bindings/media/sunxi-ir.txt2
-rw-r--r--Documentation/devicetree/bindings/media/ti,da850-vpif.txt83
-rw-r--r--Documentation/media/kapi/mc-core.rst18
-rw-r--r--Documentation/media/uapi/gen-errors.rst10
-rw-r--r--Documentation/media/uapi/rc/rc-sysfs-nodes.rst13
-rw-r--r--MAINTAINERS52
-rw-r--r--arch/arm/boot/dts/imx6qdl.dtsi2
-rw-r--r--arch/arm/boot/dts/stih407-family.dtsi10
-rw-r--r--arch/arm/configs/multi_v7_defconfig1
-rw-r--r--arch/arm/mach-omap2/pdata-quirks.c10
-rw-r--r--drivers/hid/hid-picolcd_cir.c5
-rw-r--r--drivers/media/cec/cec-core.c3
-rw-r--r--drivers/media/common/b2c2/flexcop-fe-tuner.c3
-rw-r--r--drivers/media/common/b2c2/flexcop.c4
-rw-r--r--drivers/media/common/cx2341x.c4
-rw-r--r--drivers/media/common/siano/sms-cards.c4
-rw-r--r--drivers/media/common/siano/sms-cards.h4
-rw-r--r--drivers/media/common/siano/smscoreapi.c4
-rw-r--r--drivers/media/common/siano/smsir.c5
-rw-r--r--drivers/media/common/tveeprom.c4
-rw-r--r--drivers/media/dvb-core/demux.h4
-rw-r--r--drivers/media/dvb-core/dmxdev.c16
-rw-r--r--drivers/media/dvb-core/dmxdev.h4
-rw-r--r--drivers/media/dvb-core/dvb-usb-ids.h5
-rw-r--r--drivers/media/dvb-core/dvb_ca_en50221.c7
-rw-r--r--drivers/media/dvb-core/dvb_demux.c4
-rw-r--r--drivers/media/dvb-core/dvb_demux.h4
-rw-r--r--drivers/media/dvb-core/dvb_frontend.c31
-rw-r--r--drivers/media/dvb-core/dvb_math.c4
-rw-r--r--drivers/media/dvb-core/dvb_math.h4
-rw-r--r--drivers/media/dvb-core/dvb_net.c7
-rw-r--r--drivers/media/dvb-core/dvb_net.h4
-rw-r--r--drivers/media/dvb-core/dvb_ringbuffer.c4
-rw-r--r--drivers/media/dvb-core/dvbdev.c4
-rw-r--r--drivers/media/dvb-core/dvbdev.h4
-rw-r--r--drivers/media/dvb-frontends/Kconfig17
-rw-r--r--drivers/media/dvb-frontends/Makefile2
-rw-r--r--drivers/media/dvb-frontends/af9013.c4
-rw-r--r--drivers/media/dvb-frontends/af9013.h4
-rw-r--r--drivers/media/dvb-frontends/af9013_priv.h4
-rw-r--r--drivers/media/dvb-frontends/af9033.c837
-rw-r--r--drivers/media/dvb-frontends/af9033.h13
-rw-r--r--drivers/media/dvb-frontends/af9033_priv.h185
-rw-r--r--drivers/media/dvb-frontends/atbm8830.c4
-rw-r--r--drivers/media/dvb-frontends/atbm8830.h4
-rw-r--r--drivers/media/dvb-frontends/atbm8830_priv.h4
-rw-r--r--drivers/media/dvb-frontends/au8522_decoder.c5
-rw-r--r--drivers/media/dvb-frontends/bcm3510.h4
-rw-r--r--drivers/media/dvb-frontends/bcm3510_priv.h4
-rw-r--r--drivers/media/dvb-frontends/bsbe1-d01a.h7
-rw-r--r--drivers/media/dvb-frontends/bsbe1.h7
-rw-r--r--drivers/media/dvb-frontends/bsru6.h7
-rw-r--r--drivers/media/dvb-frontends/cx24113.c4
-rw-r--r--drivers/media/dvb-frontends/cx24113.h4
-rw-r--r--drivers/media/dvb-frontends/cx24123.c6
-rw-r--r--drivers/media/dvb-frontends/cxd2820r_core.c2
-rw-r--r--drivers/media/dvb-frontends/dib0070.c4
-rw-r--r--drivers/media/dvb-frontends/dib0090.c4
-rw-r--r--drivers/media/dvb-frontends/dib7000p.c15
-rw-r--r--drivers/media/dvb-frontends/drx39xyj/drx39xxj.h4
-rw-r--r--drivers/media/dvb-frontends/drxd.h8
-rw-r--r--drivers/media/dvb-frontends/drxd_firm.c8
-rw-r--r--drivers/media/dvb-frontends/drxd_firm.h8
-rw-r--r--drivers/media/dvb-frontends/drxd_hard.c8
-rw-r--r--drivers/media/dvb-frontends/drxd_map_firm.h8
-rw-r--r--drivers/media/dvb-frontends/drxk_hard.c8
-rw-r--r--drivers/media/dvb-frontends/dvb-pll.c4
-rw-r--r--drivers/media/dvb-frontends/dvb_dummy_fe.c4
-rw-r--r--drivers/media/dvb-frontends/dvb_dummy_fe.h4
-rw-r--r--drivers/media/dvb-frontends/ec100.c4
-rw-r--r--drivers/media/dvb-frontends/ec100.h4
-rw-r--r--drivers/media/dvb-frontends/hd29l2.c870
-rw-r--r--drivers/media/dvb-frontends/hd29l2.h65
-rw-r--r--drivers/media/dvb-frontends/hd29l2_priv.h301
-rw-r--r--drivers/media/dvb-frontends/isl6405.c7
-rw-r--r--drivers/media/dvb-frontends/isl6405.h7
-rw-r--r--drivers/media/dvb-frontends/isl6421.c7
-rw-r--r--drivers/media/dvb-frontends/isl6421.h7
-rw-r--r--drivers/media/dvb-frontends/itd1000.c4
-rw-r--r--drivers/media/dvb-frontends/itd1000.h4
-rw-r--r--drivers/media/dvb-frontends/itd1000_priv.h4
-rw-r--r--drivers/media/dvb-frontends/ix2505v.c4
-rw-r--r--drivers/media/dvb-frontends/ix2505v.h4
-rw-r--r--drivers/media/dvb-frontends/lg2160.c4
-rw-r--r--drivers/media/dvb-frontends/lg2160.h4
-rw-r--r--drivers/media/dvb-frontends/lgdt3305.c4
-rw-r--r--drivers/media/dvb-frontends/lgdt3305.h4
-rw-r--r--drivers/media/dvb-frontends/lgdt3306a.c108
-rw-r--r--drivers/media/dvb-frontends/lgdt3306a.h4
-rw-r--r--drivers/media/dvb-frontends/lgdt330x.c4
-rw-r--r--drivers/media/dvb-frontends/lgdt330x.h4
-rw-r--r--drivers/media/dvb-frontends/lgdt330x_priv.h4
-rw-r--r--drivers/media/dvb-frontends/lgs8gxx.c4
-rw-r--r--drivers/media/dvb-frontends/lgs8gxx.h4
-rw-r--r--drivers/media/dvb-frontends/lgs8gxx_priv.h4
-rw-r--r--drivers/media/dvb-frontends/lnbh24.h4
-rw-r--r--drivers/media/dvb-frontends/lnbp21.c7
-rw-r--r--drivers/media/dvb-frontends/lnbp21.h7
-rw-r--r--drivers/media/dvb-frontends/lnbp22.c7
-rw-r--r--drivers/media/dvb-frontends/lnbp22.h7
-rw-r--r--drivers/media/dvb-frontends/mn88473.c10
-rw-r--r--drivers/media/dvb-frontends/mt352.c4
-rw-r--r--drivers/media/dvb-frontends/mt352.h4
-rw-r--r--drivers/media/dvb-frontends/mt352_priv.h4
-rw-r--r--drivers/media/dvb-frontends/nxt200x.c4
-rw-r--r--drivers/media/dvb-frontends/nxt200x.h4
-rw-r--r--drivers/media/dvb-frontends/or51132.c4
-rw-r--r--drivers/media/dvb-frontends/or51132.h4
-rw-r--r--drivers/media/dvb-frontends/or51211.c4
-rw-r--r--drivers/media/dvb-frontends/or51211.h4
-rw-r--r--drivers/media/dvb-frontends/rtl2832_sdr.c2
-rw-r--r--drivers/media/dvb-frontends/s5h1420.c4
-rw-r--r--drivers/media/dvb-frontends/s5h1420.h4
-rw-r--r--drivers/media/dvb-frontends/s5h1432.c4
-rw-r--r--drivers/media/dvb-frontends/s5h1432.h4
-rw-r--r--drivers/media/dvb-frontends/si2168.c70
-rw-r--r--drivers/media/dvb-frontends/si2168_priv.h1
-rw-r--r--drivers/media/dvb-frontends/stv0367.c4
-rw-r--r--drivers/media/dvb-frontends/stv0367.h4
-rw-r--r--drivers/media/dvb-frontends/stv0367_priv.h4
-rw-r--r--drivers/media/dvb-frontends/stv0367_regs.h4
-rw-r--r--drivers/media/dvb-frontends/stv0900.h4
-rw-r--r--drivers/media/dvb-frontends/stv0900_core.c4
-rw-r--r--drivers/media/dvb-frontends/stv0900_init.h4
-rw-r--r--drivers/media/dvb-frontends/stv0900_priv.h4
-rw-r--r--drivers/media/dvb-frontends/stv0900_reg.h4
-rw-r--r--drivers/media/dvb-frontends/stv0900_sw.c4
-rw-r--r--drivers/media/dvb-frontends/stv6110.c4
-rw-r--r--drivers/media/dvb-frontends/stv6110.h4
-rw-r--r--drivers/media/dvb-frontends/tda18271c2dd.c8
-rw-r--r--drivers/media/dvb-frontends/tdhd1.h7
-rw-r--r--drivers/media/dvb-frontends/tua6100.c4
-rw-r--r--drivers/media/dvb-frontends/tua6100.h4
-rw-r--r--drivers/media/dvb-frontends/zd1301_demod.c551
-rw-r--r--drivers/media/dvb-frontends/zd1301_demod.h73
-rw-r--r--drivers/media/dvb-frontends/zl10036.c4
-rw-r--r--drivers/media/dvb-frontends/zl10036.h4
-rw-r--r--drivers/media/dvb-frontends/zl10039.c4
-rw-r--r--drivers/media/dvb-frontends/zl10353.c4
-rw-r--r--drivers/media/dvb-frontends/zl10353.h4
-rw-r--r--drivers/media/dvb-frontends/zl10353_priv.h4
-rw-r--r--drivers/media/i2c/Kconfig1
-rw-r--r--drivers/media/i2c/Makefile1
-rw-r--r--drivers/media/i2c/adp1653.c5
-rw-r--r--drivers/media/i2c/adv7170.c9
-rw-r--r--drivers/media/i2c/adv7175.c4
-rw-r--r--drivers/media/i2c/adv7180.c4
-rw-r--r--drivers/media/i2c/adv7183.c4
-rw-r--r--drivers/media/i2c/adv7183_regs.h4
-rw-r--r--drivers/media/i2c/adv7604.c3
-rw-r--r--drivers/media/i2c/ak881x.c6
-rw-r--r--drivers/media/i2c/aptina-pll.c5
-rw-r--r--drivers/media/i2c/aptina-pll.h5
-rw-r--r--drivers/media/i2c/as3645a.c5
-rw-r--r--drivers/media/i2c/bt819.c4
-rw-r--r--drivers/media/i2c/bt856.c4
-rw-r--r--drivers/media/i2c/cs5345.c4
-rw-r--r--drivers/media/i2c/cs53l32a.c4
-rw-r--r--drivers/media/i2c/cx25840/cx25840-audio.c4
-rw-r--r--drivers/media/i2c/cx25840/cx25840-core.c4
-rw-r--r--drivers/media/i2c/cx25840/cx25840-core.h4
-rw-r--r--drivers/media/i2c/cx25840/cx25840-firmware.c4
-rw-r--r--drivers/media/i2c/cx25840/cx25840-ir.c5
-rw-r--r--drivers/media/i2c/cx25840/cx25840-vbi.c4
-rw-r--r--drivers/media/i2c/et8ek8/Kconfig6
-rw-r--r--drivers/media/i2c/et8ek8/Makefile2
-rw-r--r--drivers/media/i2c/et8ek8/et8ek8_driver.c1514
-rw-r--r--drivers/media/i2c/et8ek8/et8ek8_mode.c587
-rw-r--r--drivers/media/i2c/et8ek8/et8ek8_reg.h96
-rw-r--r--drivers/media/i2c/ir-kbd-i2c.c6
-rw-r--r--drivers/media/i2c/ks0127.c4
-rw-r--r--drivers/media/i2c/ks0127.h4
-rw-r--r--drivers/media/i2c/m52790.c4
-rw-r--r--drivers/media/i2c/m5mols/m5mols_core.c7
-rw-r--r--drivers/media/i2c/ml86v7667.c6
-rw-r--r--drivers/media/i2c/msp3400-driver.c5
-rw-r--r--drivers/media/i2c/msp3400-kthreads.c5
-rw-r--r--drivers/media/i2c/mt9m032.c5
-rw-r--r--drivers/media/i2c/mt9p031.c8
-rw-r--r--drivers/media/i2c/mt9v032.c11
-rw-r--r--drivers/media/i2c/noon010pc30.c4
-rw-r--r--drivers/media/i2c/ov2659.c1
-rw-r--r--drivers/media/i2c/ov7640.c4
-rw-r--r--drivers/media/i2c/ov9650.c4
-rw-r--r--drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c2
-rw-r--r--drivers/media/i2c/s5k6a3.c6
-rw-r--r--drivers/media/i2c/saa7110.c4
-rw-r--r--drivers/media/i2c/saa7115.c4
-rw-r--r--drivers/media/i2c/saa7127.c4
-rw-r--r--drivers/media/i2c/saa717x.c4
-rw-r--r--drivers/media/i2c/saa7185.c4
-rw-r--r--drivers/media/i2c/soc_camera/ov9640.c2
-rw-r--r--drivers/media/i2c/sony-btf-mpx.c4
-rw-r--r--drivers/media/i2c/tc358743.c47
-rw-r--r--drivers/media/i2c/tc358743_regs.h1
-rw-r--r--drivers/media/i2c/tlv320aic23b.c4
-rw-r--r--drivers/media/i2c/tvp514x.c4
-rw-r--r--drivers/media/i2c/tvp514x_regs.h4
-rw-r--r--drivers/media/i2c/tvp7002.c4
-rw-r--r--drivers/media/i2c/tvp7002_reg.h4
-rw-r--r--drivers/media/i2c/tw2804.c4
-rw-r--r--drivers/media/i2c/tw9903.c4
-rw-r--r--drivers/media/i2c/tw9906.c4
-rw-r--r--drivers/media/i2c/uda1342.c4
-rw-r--r--drivers/media/i2c/upd64031a.c4
-rw-r--r--drivers/media/i2c/upd64083.c5
-rw-r--r--drivers/media/i2c/vp27smpx.c4
-rw-r--r--drivers/media/i2c/vpx3220.c4
-rw-r--r--drivers/media/i2c/vs6624.c4
-rw-r--r--drivers/media/i2c/vs6624_regs.h4
-rw-r--r--drivers/media/i2c/wm8739.c4
-rw-r--r--drivers/media/i2c/wm8775.c4
-rw-r--r--drivers/media/media-device.c14
-rw-r--r--drivers/media/media-devnode.c4
-rw-r--r--drivers/media/media-entity.c166
-rw-r--r--drivers/media/pci/b2c2/flexcop-pci.c2
-rw-r--r--drivers/media/pci/bt8xx/bttv-input.c6
-rw-r--r--drivers/media/pci/bt8xx/dst_ca.c11
-rw-r--r--drivers/media/pci/bt8xx/dvb-bt8xx.c5
-rw-r--r--drivers/media/pci/bt8xx/dvb-bt8xx.h4
-rw-r--r--drivers/media/pci/cobalt/cobalt-cpld.c4
-rw-r--r--drivers/media/pci/cx18/cx18-alsa-main.c5
-rw-r--r--drivers/media/pci/cx18/cx18-alsa-mixer.c5
-rw-r--r--drivers/media/pci/cx18/cx18-alsa-mixer.h5
-rw-r--r--drivers/media/pci/cx18/cx18-alsa-pcm.c5
-rw-r--r--drivers/media/pci/cx18/cx18-alsa-pcm.h5
-rw-r--r--drivers/media/pci/cx18/cx18-alsa.h5
-rw-r--r--drivers/media/pci/cx18/cx18-audio.c5
-rw-r--r--drivers/media/pci/cx18/cx18-audio.h5
-rw-r--r--drivers/media/pci/cx18/cx18-av-audio.c5
-rw-r--r--drivers/media/pci/cx18/cx18-av-core.c5
-rw-r--r--drivers/media/pci/cx18/cx18-av-core.h5
-rw-r--r--drivers/media/pci/cx18/cx18-av-firmware.c5
-rw-r--r--drivers/media/pci/cx18/cx18-av-vbi.c5
-rw-r--r--drivers/media/pci/cx18/cx18-cards.c5
-rw-r--r--drivers/media/pci/cx18/cx18-cards.h4
-rw-r--r--drivers/media/pci/cx18/cx18-controls.c5
-rw-r--r--drivers/media/pci/cx18/cx18-driver.c5
-rw-r--r--drivers/media/pci/cx18/cx18-driver.h5
-rw-r--r--drivers/media/pci/cx18/cx18-dvb.c4
-rw-r--r--drivers/media/pci/cx18/cx18-dvb.h4
-rw-r--r--drivers/media/pci/cx18/cx18-fileops.c5
-rw-r--r--drivers/media/pci/cx18/cx18-fileops.h5
-rw-r--r--drivers/media/pci/cx18/cx18-firmware.c5
-rw-r--r--drivers/media/pci/cx18/cx18-firmware.h5
-rw-r--r--drivers/media/pci/cx18/cx18-gpio.c5
-rw-r--r--drivers/media/pci/cx18/cx18-gpio.h4
-rw-r--r--drivers/media/pci/cx18/cx18-i2c.c5
-rw-r--r--drivers/media/pci/cx18/cx18-i2c.h5
-rw-r--r--drivers/media/pci/cx18/cx18-io.c5
-rw-r--r--drivers/media/pci/cx18/cx18-io.h5
-rw-r--r--drivers/media/pci/cx18/cx18-ioctl.c5
-rw-r--r--drivers/media/pci/cx18/cx18-ioctl.h5
-rw-r--r--drivers/media/pci/cx18/cx18-irq.c5
-rw-r--r--drivers/media/pci/cx18/cx18-irq.h5
-rw-r--r--drivers/media/pci/cx18/cx18-mailbox.c5
-rw-r--r--drivers/media/pci/cx18/cx18-mailbox.h5
-rw-r--r--drivers/media/pci/cx18/cx18-queue.c5
-rw-r--r--drivers/media/pci/cx18/cx18-queue.h5
-rw-r--r--drivers/media/pci/cx18/cx18-scb.c5
-rw-r--r--drivers/media/pci/cx18/cx18-scb.h5
-rw-r--r--drivers/media/pci/cx18/cx18-streams.c5
-rw-r--r--drivers/media/pci/cx18/cx18-streams.h5
-rw-r--r--drivers/media/pci/cx18/cx18-vbi.c5
-rw-r--r--drivers/media/pci/cx18/cx18-vbi.h5
-rw-r--r--drivers/media/pci/cx18/cx18-version.h5
-rw-r--r--drivers/media/pci/cx18/cx18-video.c5
-rw-r--r--drivers/media/pci/cx18/cx18-video.h5
-rw-r--r--drivers/media/pci/cx18/cx23418.h5
-rw-r--r--drivers/media/pci/cx23885/cx23885-dvb.c54
-rw-r--r--drivers/media/pci/cx23885/cx23885-input.c25
-rw-r--r--drivers/media/pci/cx25821/cx25821-alsa.c4
-rw-r--r--drivers/media/pci/cx25821/cx25821-audio-upstream.c4
-rw-r--r--drivers/media/pci/cx25821/cx25821-audio-upstream.h4
-rw-r--r--drivers/media/pci/cx25821/cx25821-audio.h4
-rw-r--r--drivers/media/pci/cx25821/cx25821-biffuncs.h4
-rw-r--r--drivers/media/pci/cx25821/cx25821-cards.c4
-rw-r--r--drivers/media/pci/cx25821/cx25821-core.c4
-rw-r--r--drivers/media/pci/cx25821/cx25821-gpio.c4
-rw-r--r--drivers/media/pci/cx25821/cx25821-i2c.c4
-rw-r--r--drivers/media/pci/cx25821/cx25821-medusa-defines.h4
-rw-r--r--drivers/media/pci/cx25821/cx25821-medusa-reg.h4
-rw-r--r--drivers/media/pci/cx25821/cx25821-medusa-video.c4
-rw-r--r--drivers/media/pci/cx25821/cx25821-medusa-video.h4
-rw-r--r--drivers/media/pci/cx25821/cx25821-reg.h4
-rw-r--r--drivers/media/pci/cx25821/cx25821-sram.h4
-rw-r--r--drivers/media/pci/cx25821/cx25821-video-upstream.c4
-rw-r--r--drivers/media/pci/cx25821/cx25821-video-upstream.h4
-rw-r--r--drivers/media/pci/cx25821/cx25821-video.c4
-rw-r--r--drivers/media/pci/cx25821/cx25821-video.h4
-rw-r--r--drivers/media/pci/cx25821/cx25821.h4
-rw-r--r--drivers/media/pci/cx88/cx88-input.c3
-rw-r--r--drivers/media/pci/ddbridge/ddbridge-core.c8
-rw-r--r--drivers/media/pci/ddbridge/ddbridge-regs.h8
-rw-r--r--drivers/media/pci/ddbridge/ddbridge.h8
-rw-r--r--drivers/media/pci/dm1105/Kconfig2
-rw-r--r--drivers/media/pci/dm1105/dm1105.c7
-rw-r--r--drivers/media/pci/ivtv/Kconfig13
-rw-r--r--drivers/media/pci/ivtv/ivtv-alsa-main.c31
-rw-r--r--drivers/media/pci/ivtv/ivtv-alsa-mixer.c18
-rw-r--r--drivers/media/pci/ivtv/ivtv-alsa-mixer.h5
-rw-r--r--drivers/media/pci/ivtv/ivtv-alsa-pcm.c21
-rw-r--r--drivers/media/pci/ivtv/ivtv-alsa-pcm.h5
-rw-r--r--drivers/media/pci/ivtv/ivtv-alsa.h5
-rw-r--r--drivers/media/pci/ivtv/ivtv-driver.c12
-rw-r--r--drivers/media/pci/ivtv/ivtv-driver.h37
-rw-r--r--drivers/media/pci/ivtv/ivtv-ioctl.c49
-rw-r--r--drivers/media/pci/ivtv/ivtv-mailbox.c4
-rw-r--r--drivers/media/pci/ivtv/ivtvfb.c23
-rw-r--r--drivers/media/pci/mantis/mantis_dvb.c5
-rw-r--r--drivers/media/pci/mantis/mantis_input.c2
-rw-r--r--drivers/media/pci/meye/meye.c5
-rw-r--r--drivers/media/pci/meye/meye.h4
-rw-r--r--drivers/media/pci/ngene/ngene-cards.c15
-rw-r--r--drivers/media/pci/ngene/ngene-core.c8
-rw-r--r--drivers/media/pci/ngene/ngene-dvb.c8
-rw-r--r--drivers/media/pci/ngene/ngene-i2c.c8
-rw-r--r--drivers/media/pci/ngene/ngene.h8
-rw-r--r--drivers/media/pci/pluto2/pluto2.c4
-rw-r--r--drivers/media/pci/pt1/pt1.c4
-rw-r--r--drivers/media/pci/pt1/va1j5jf8007s.c4
-rw-r--r--drivers/media/pci/pt1/va1j5jf8007s.h4
-rw-r--r--drivers/media/pci/pt1/va1j5jf8007t.c4
-rw-r--r--drivers/media/pci/pt1/va1j5jf8007t.h4
-rw-r--r--drivers/media/pci/saa7134/saa7134-alsa.c4
-rw-r--r--drivers/media/pci/saa7134/saa7134-cards.c4
-rw-r--r--drivers/media/pci/saa7134/saa7134-core.c4
-rw-r--r--drivers/media/pci/saa7134/saa7134-dvb.c4
-rw-r--r--drivers/media/pci/saa7134/saa7134-empress.c4
-rw-r--r--drivers/media/pci/saa7134/saa7134-i2c.c4
-rw-r--r--drivers/media/pci/saa7134/saa7134-input.c6
-rw-r--r--drivers/media/pci/saa7134/saa7134-ts.c4
-rw-r--r--drivers/media/pci/saa7134/saa7134-tvaudio.c4
-rw-r--r--drivers/media/pci/saa7134/saa7134-vbi.c4
-rw-r--r--drivers/media/pci/saa7134/saa7134-video.c4
-rw-r--r--drivers/media/pci/saa7134/saa7134.h4
-rw-r--r--drivers/media/pci/saa7164/saa7164-api.c4
-rw-r--r--drivers/media/pci/saa7164/saa7164-buffer.c4
-rw-r--r--drivers/media/pci/saa7164/saa7164-bus.c4
-rw-r--r--drivers/media/pci/saa7164/saa7164-cards.c4
-rw-r--r--drivers/media/pci/saa7164/saa7164-cmd.c4
-rw-r--r--drivers/media/pci/saa7164/saa7164-core.c4
-rw-r--r--drivers/media/pci/saa7164/saa7164-dvb.c4
-rw-r--r--drivers/media/pci/saa7164/saa7164-encoder.c4
-rw-r--r--drivers/media/pci/saa7164/saa7164-fw.c6
-rw-r--r--drivers/media/pci/saa7164/saa7164-i2c.c4
-rw-r--r--drivers/media/pci/saa7164/saa7164-reg.h4
-rw-r--r--drivers/media/pci/saa7164/saa7164-types.h4
-rw-r--r--drivers/media/pci/saa7164/saa7164-vbi.c4
-rw-r--r--drivers/media/pci/saa7164/saa7164.h4
-rw-r--r--drivers/media/pci/smipcie/smipcie-ir.c3
-rw-r--r--drivers/media/pci/solo6x10/solo6x10-g723.c2
-rw-r--r--drivers/media/pci/sta2x11/sta2x11_vip.c2
-rw-r--r--drivers/media/pci/sta2x11/sta2x11_vip.h4
-rw-r--r--drivers/media/pci/ttpci/av7110.c7
-rw-r--r--drivers/media/pci/ttpci/av7110_av.c7
-rw-r--r--drivers/media/pci/ttpci/av7110_ca.c7
-rw-r--r--drivers/media/pci/ttpci/av7110_hw.c15
-rw-r--r--drivers/media/pci/ttpci/av7110_hw.h12
-rw-r--r--drivers/media/pci/ttpci/av7110_ir.c7
-rw-r--r--drivers/media/pci/ttpci/av7110_v4l.c7
-rw-r--r--drivers/media/pci/ttpci/budget-av.c7
-rw-r--r--drivers/media/pci/ttpci/budget-ci.c9
-rw-r--r--drivers/media/pci/ttpci/budget-core.c7
-rw-r--r--drivers/media/pci/ttpci/budget-patch.c7
-rw-r--r--drivers/media/pci/ttpci/budget.c7
-rw-r--r--drivers/media/pci/ttpci/dvb_filter.h4
-rw-r--r--drivers/media/pci/tw686x/tw686x-core.c2
-rw-r--r--drivers/media/pci/zoran/videocodec.c4
-rw-r--r--drivers/media/pci/zoran/videocodec.h4
-rw-r--r--drivers/media/pci/zoran/zoran.h4
-rw-r--r--drivers/media/pci/zoran/zoran_card.c4
-rw-r--r--drivers/media/pci/zoran/zoran_card.h4
-rw-r--r--drivers/media/pci/zoran/zoran_device.c4
-rw-r--r--drivers/media/pci/zoran/zoran_device.h4
-rw-r--r--drivers/media/pci/zoran/zoran_driver.c5
-rw-r--r--drivers/media/pci/zoran/zoran_procfs.c4
-rw-r--r--drivers/media/pci/zoran/zoran_procfs.h4
-rw-r--r--drivers/media/pci/zoran/zr36016.c4
-rw-r--r--drivers/media/pci/zoran/zr36016.h4
-rw-r--r--drivers/media/pci/zoran/zr36050.c4
-rw-r--r--drivers/media/pci/zoran/zr36050.h4
-rw-r--r--drivers/media/pci/zoran/zr36057.h4
-rw-r--r--drivers/media/pci/zoran/zr36060.c4
-rw-r--r--drivers/media/pci/zoran/zr36060.h4
-rw-r--r--drivers/media/platform/Kconfig53
-rw-r--r--drivers/media/platform/Makefile2
-rw-r--r--drivers/media/platform/am437x/am437x-vpfe.c2
-rw-r--r--drivers/media/platform/blackfin/bfin_capture.c4
-rw-r--r--drivers/media/platform/blackfin/ppi.c4
-rw-r--r--drivers/media/platform/coda/Makefile1
-rw-r--r--drivers/media/platform/coda/coda-bit.c93
-rw-r--r--drivers/media/platform/coda/coda-common.c181
-rw-r--r--drivers/media/platform/coda/coda.h5
-rw-r--r--drivers/media/platform/coda/imx-vdoa.c338
-rw-r--r--drivers/media/platform/coda/imx-vdoa.h58
-rw-r--r--drivers/media/platform/davinci/ccdc_hw_device.h4
-rw-r--r--drivers/media/platform/davinci/dm355_ccdc.c4
-rw-r--r--drivers/media/platform/davinci/dm355_ccdc_regs.h4
-rw-r--r--drivers/media/platform/davinci/dm644x_ccdc.c4
-rw-r--r--drivers/media/platform/davinci/dm644x_ccdc_regs.h4
-rw-r--r--drivers/media/platform/davinci/isif.c4
-rw-r--r--drivers/media/platform/davinci/isif_regs.h4
-rw-r--r--drivers/media/platform/davinci/vpbe.c4
-rw-r--r--drivers/media/platform/davinci/vpbe_osd.c4
-rw-r--r--drivers/media/platform/davinci/vpbe_osd_regs.h4
-rw-r--r--drivers/media/platform/davinci/vpbe_venc.c4
-rw-r--r--drivers/media/platform/davinci/vpbe_venc_regs.h4
-rw-r--r--drivers/media/platform/davinci/vpfe_capture.c6
-rw-r--r--drivers/media/platform/davinci/vpif.c14
-rw-r--r--drivers/media/platform/davinci/vpif_capture.c28
-rw-r--r--drivers/media/platform/davinci/vpif_capture.h6
-rw-r--r--drivers/media/platform/davinci/vpif_display.c6
-rw-r--r--drivers/media/platform/davinci/vpss.c4
-rw-r--r--drivers/media/platform/exynos-gsc/gsc-core.c3
-rw-r--r--drivers/media/platform/exynos-gsc/gsc-m2m.c2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-capture.c12
-rw-r--r--drivers/media/platform/exynos4-is/fimc-is-i2c.c9
-rw-r--r--drivers/media/platform/exynos4-is/fimc-is.c8
-rw-r--r--drivers/media/platform/exynos4-is/fimc-isp-video.c8
-rw-r--r--drivers/media/platform/exynos4-is/fimc-lite.c8
-rw-r--r--drivers/media/platform/exynos4-is/fimc-m2m.c2
-rw-r--r--drivers/media/platform/exynos4-is/media-dev.c20
-rw-r--r--drivers/media/platform/exynos4-is/media-dev.h2
-rw-r--r--drivers/media/platform/exynos4-is/mipi-csis.c8
-rw-r--r--drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c160
-rw-r--r--drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c14
-rw-r--r--drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h2
-rw-r--r--drivers/media/platform/mtk-vcodec/vdec_vpu_if.c5
-rw-r--r--drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c8
-rw-r--r--drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c8
-rw-r--r--drivers/media/platform/mtk-vcodec/venc_vpu_if.c4
-rw-r--r--drivers/media/platform/omap3isp/ispvideo.c18
-rw-r--r--drivers/media/platform/rcar_fdp1.c4
-rw-r--r--drivers/media/platform/s3c-camif/camif-capture.c8
-rw-r--r--drivers/media/platform/soc_camera/soc_camera_platform.c6
-rw-r--r--drivers/media/platform/sti/bdisp/bdisp-debug.c2
-rw-r--r--drivers/media/platform/sti/delta/Makefile6
-rw-r--r--drivers/media/platform/sti/delta/delta-cfg.h64
-rw-r--r--drivers/media/platform/sti/delta/delta-debug.c72
-rw-r--r--drivers/media/platform/sti/delta/delta-debug.h18
-rw-r--r--drivers/media/platform/sti/delta/delta-ipc.c594
-rw-r--r--drivers/media/platform/sti/delta/delta-ipc.h76
-rw-r--r--drivers/media/platform/sti/delta/delta-mem.c51
-rw-r--r--drivers/media/platform/sti/delta/delta-mem.h14
-rw-r--r--drivers/media/platform/sti/delta/delta-mjpeg-dec.c455
-rw-r--r--drivers/media/platform/sti/delta/delta-mjpeg-fw.h225
-rw-r--r--drivers/media/platform/sti/delta/delta-mjpeg-hdr.c149
-rw-r--r--drivers/media/platform/sti/delta/delta-mjpeg.h35
-rw-r--r--drivers/media/platform/sti/delta/delta-v4l2.c1993
-rw-r--r--drivers/media/platform/sti/delta/delta.h566
-rw-r--r--drivers/media/platform/sti/hva/Makefile1
-rw-r--r--drivers/media/platform/sti/hva/hva-debugfs.c422
-rw-r--r--drivers/media/platform/sti/hva/hva-h264.c6
-rw-r--r--drivers/media/platform/sti/hva/hva-hw.c48
-rw-r--r--drivers/media/platform/sti/hva/hva-hw.h3
-rw-r--r--drivers/media/platform/sti/hva/hva-mem.c5
-rw-r--r--drivers/media/platform/sti/hva/hva-v4l2.c78
-rw-r--r--drivers/media/platform/sti/hva/hva.h96
-rw-r--r--drivers/media/platform/ti-vpe/vpdma.c2
-rw-r--r--drivers/media/platform/vim2m.c2
-rw-r--r--drivers/media/platform/vivid/vivid-vid-cap.c5
-rw-r--r--drivers/media/platform/vsp1/vsp1_drm.c4
-rw-r--r--drivers/media/platform/vsp1/vsp1_video.c17
-rw-r--r--drivers/media/platform/xilinx/xilinx-dma.c16
-rw-r--r--drivers/media/platform/xilinx/xilinx-tpg.c8
-rw-r--r--drivers/media/radio/dsbr100.c4
-rw-r--r--drivers/media/radio/radio-cadet.c8
-rw-r--r--drivers/media/radio/radio-isa.c5
-rw-r--r--drivers/media/radio/radio-isa.h5
-rw-r--r--drivers/media/radio/radio-keene.c4
-rw-r--r--drivers/media/radio/radio-ma901.c4
-rw-r--r--drivers/media/radio/radio-mr800.c4
-rw-r--r--drivers/media/radio/radio-shark.c4
-rw-r--r--drivers/media/radio/radio-shark2.c4
-rw-r--r--drivers/media/radio/radio-tea5764.c4
-rw-r--r--drivers/media/radio/radio-tea5777.c4
-rw-r--r--drivers/media/radio/radio-tea5777.h4
-rw-r--r--drivers/media/radio/radio-timb.c4
-rw-r--r--drivers/media/radio/radio-wl1273.c4
-rw-r--r--drivers/media/radio/saa7706h.c4
-rw-r--r--drivers/media/radio/si470x/radio-si470x-common.c4
-rw-r--r--drivers/media/radio/si470x/radio-si470x-i2c.c4
-rw-r--r--drivers/media/radio/si470x/radio-si470x-usb.c4
-rw-r--r--drivers/media/radio/si470x/radio-si470x.h4
-rw-r--r--drivers/media/radio/si4713/radio-platform-si4713.c4
-rw-r--r--drivers/media/radio/si4713/si4713.c4
-rw-r--r--drivers/media/radio/tef6862.c4
-rw-r--r--drivers/media/radio/wl128x/fmdrv.h4
-rw-r--r--drivers/media/radio/wl128x/fmdrv_common.c4
-rw-r--r--drivers/media/radio/wl128x/fmdrv_common.h4
-rw-r--r--drivers/media/radio/wl128x/fmdrv_rx.c4
-rw-r--r--drivers/media/radio/wl128x/fmdrv_rx.h4
-rw-r--r--drivers/media/radio/wl128x/fmdrv_tx.c4
-rw-r--r--drivers/media/radio/wl128x/fmdrv_tx.h4
-rw-r--r--drivers/media/radio/wl128x/fmdrv_v4l2.c4
-rw-r--r--drivers/media/radio/wl128x/fmdrv_v4l2.h4
-rw-r--r--drivers/media/rc/Kconfig22
-rw-r--r--drivers/media/rc/Makefile2
-rw-r--r--drivers/media/rc/ati_remote.c7
-rw-r--r--drivers/media/rc/ene_ir.c10
-rw-r--r--drivers/media/rc/ene_ir.h5
-rw-r--r--drivers/media/rc/fintek-cir.c10
-rw-r--r--drivers/media/rc/fintek-cir.h5
-rw-r--r--drivers/media/rc/gpio-ir-recv.c5
-rw-r--r--drivers/media/rc/igorplugusb.c7
-rw-r--r--drivers/media/rc/iguanair.c13
-rw-r--r--drivers/media/rc/img-ir/img-ir-hw.c15
-rw-r--r--drivers/media/rc/img-ir/img-ir-nec.c21
-rw-r--r--drivers/media/rc/img-ir/img-ir-raw.c3
-rw-r--r--drivers/media/rc/img-ir/img-ir-sony.c26
-rw-r--r--drivers/media/rc/imon.c138
-rw-r--r--drivers/media/rc/ir-hix5hd2.c5
-rw-r--r--drivers/media/rc/ir-jvc-decoder.c39
-rw-r--r--drivers/media/rc/ir-lirc-codec.c17
-rw-r--r--drivers/media/rc/ir-mce_kbd-decoder.c2
-rw-r--r--drivers/media/rc/ir-nec-decoder.c86
-rw-r--r--drivers/media/rc/ir-rc5-decoder.c105
-rw-r--r--drivers/media/rc/ir-rc6-decoder.c117
-rw-r--r--drivers/media/rc/ir-rx51.c332
-rw-r--r--drivers/media/rc/ir-sanyo-decoder.c43
-rw-r--r--drivers/media/rc/ir-sharp-decoder.c50
-rw-r--r--drivers/media/rc/ir-sony-decoder.c48
-rw-r--r--drivers/media/rc/ir-spi.c199
-rw-r--r--drivers/media/rc/ite-cir.c10
-rw-r--r--drivers/media/rc/ite-cir.h5
-rw-r--r--drivers/media/rc/keymaps/Makefile4
-rw-r--r--drivers/media/rc/keymaps/rc-d680-dmb.c75
-rw-r--r--drivers/media/rc/keymaps/rc-dvico-mce.c85
-rw-r--r--drivers/media/rc/keymaps/rc-dvico-portable.c76
-rw-r--r--drivers/media/rc/keymaps/rc-geekbox.c55
-rw-r--r--drivers/media/rc/keymaps/rc-rc6-mce.c1
-rw-r--r--drivers/media/rc/keymaps/rc-technisat-usb2.c4
-rw-r--r--drivers/media/rc/keymaps/rc-tivo.c86
-rw-r--r--drivers/media/rc/lirc_dev.c13
-rw-r--r--drivers/media/rc/mceusb.c13
-rw-r--r--drivers/media/rc/meson-ir.c5
-rw-r--r--drivers/media/rc/mtk-cir.c335
-rw-r--r--drivers/media/rc/nuvoton-cir.c130
-rw-r--r--drivers/media/rc/nuvoton-cir.h5
-rw-r--r--drivers/media/rc/rc-core-priv.h109
-rw-r--r--drivers/media/rc/rc-ir-raw.c308
-rw-r--r--drivers/media/rc/rc-loopback.c48
-rw-r--r--drivers/media/rc/rc-main.c527
-rw-r--r--drivers/media/rc/redrat3.c9
-rw-r--r--drivers/media/rc/serial_ir.c29
-rw-r--r--drivers/media/rc/st_rc.c5
-rw-r--r--drivers/media/rc/streamzap.c9
-rw-r--r--drivers/media/rc/sunxi-cir.c5
-rw-r--r--drivers/media/rc/ttusbir.c14
-rw-r--r--drivers/media/rc/winbond-cir.c266
-rw-r--r--drivers/media/tuners/fc0011.c4
-rw-r--r--drivers/media/tuners/fc0012-priv.h4
-rw-r--r--drivers/media/tuners/fc0012.c4
-rw-r--r--drivers/media/tuners/fc0012.h4
-rw-r--r--drivers/media/tuners/fc0013-priv.h4
-rw-r--r--drivers/media/tuners/fc0013.c4
-rw-r--r--drivers/media/tuners/fc0013.h4
-rw-r--r--drivers/media/tuners/fc001x-common.h4
-rw-r--r--drivers/media/tuners/it913x.c96
-rw-r--r--drivers/media/tuners/it913x.h30
-rw-r--r--drivers/media/tuners/max2165.c4
-rw-r--r--drivers/media/tuners/max2165.h4
-rw-r--r--drivers/media/tuners/max2165_priv.h4
-rw-r--r--drivers/media/tuners/mc44s803.c4
-rw-r--r--drivers/media/tuners/mc44s803.h4
-rw-r--r--drivers/media/tuners/mc44s803_priv.h4
-rw-r--r--drivers/media/tuners/mt2060.c129
-rw-r--r--drivers/media/tuners/mt2060.h27
-rw-r--r--drivers/media/tuners/mt2060_priv.h15
-rw-r--r--drivers/media/tuners/mt2131.c4
-rw-r--r--drivers/media/tuners/mt2131.h4
-rw-r--r--drivers/media/tuners/mt2131_priv.h4
-rw-r--r--drivers/media/tuners/mxl5007t.c4
-rw-r--r--drivers/media/tuners/mxl5007t.h4
-rw-r--r--drivers/media/tuners/qt1010.c4
-rw-r--r--drivers/media/tuners/qt1010.h4
-rw-r--r--drivers/media/tuners/qt1010_priv.h4
-rw-r--r--drivers/media/tuners/tda18218.c4
-rw-r--r--drivers/media/tuners/tda18218.h4
-rw-r--r--drivers/media/tuners/tda18218_priv.h4
-rw-r--r--drivers/media/tuners/tda827x.c4
-rw-r--r--drivers/media/tuners/xc4000.c4
-rw-r--r--drivers/media/tuners/xc4000.h4
-rw-r--r--drivers/media/tuners/xc5000.c4
-rw-r--r--drivers/media/tuners/xc5000.h4
-rw-r--r--drivers/media/usb/au0828/au0828-cards.c4
-rw-r--r--drivers/media/usb/au0828/au0828-cards.h4
-rw-r--r--drivers/media/usb/au0828/au0828-core.c29
-rw-r--r--drivers/media/usb/au0828/au0828-dvb.c4
-rw-r--r--drivers/media/usb/au0828/au0828-i2c.c4
-rw-r--r--drivers/media/usb/au0828/au0828-input.c3
-rw-r--r--drivers/media/usb/au0828/au0828-reg.h4
-rw-r--r--drivers/media/usb/au0828/au0828-video.c5
-rw-r--r--drivers/media/usb/au0828/au0828.h4
-rw-r--r--drivers/media/usb/cpia2/cpia2.h4
-rw-r--r--drivers/media/usb/cpia2/cpia2_core.c4
-rw-r--r--drivers/media/usb/cpia2/cpia2_registers.h4
-rw-r--r--drivers/media/usb/cpia2/cpia2_usb.c8
-rw-r--r--drivers/media/usb/cpia2/cpia2_v4l.c4
-rw-r--r--drivers/media/usb/cx231xx/Kconfig1
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-417.c4
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-audio.c4
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-cards.c29
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-core.c7
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-dif.h4
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-dvb.c70
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-input.c2
-rw-r--r--drivers/media/usb/cx231xx/cx231xx.h1
-rw-r--r--drivers/media/usb/dvb-usb-v2/Kconfig8
-rw-r--r--drivers/media/usb/dvb-usb-v2/Makefile3
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9015.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9015.h4
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9035.c267
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9035.h7
-rw-r--r--drivers/media/usb/dvb-usb-v2/anysee.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/anysee.h4
-rw-r--r--drivers/media/usb/dvb-usb-v2/au6610.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/au6610.h4
-rw-r--r--drivers/media/usb/dvb-usb-v2/ce6230.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/ce6230.h4
-rw-r--r--drivers/media/usb/dvb-usb-v2/dvb_usb_core.c12
-rw-r--r--drivers/media/usb/dvb-usb-v2/dvbsky.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/ec168.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/ec168.h4
-rw-r--r--drivers/media/usb/dvb-usb-v2/lmedm04.c22
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf-demod.h4
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf-gpio.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf-gpio.h4
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.h4
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf-phy.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf-phy.h4
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf-reg.h4
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.h4
-rw-r--r--drivers/media/usb/dvb-usb-v2/rtl28xxu.c2
-rw-r--r--drivers/media/usb/dvb-usb-v2/zd1301.c298
-rw-r--r--drivers/media/usb/dvb-usb/af9005-fe.c4
-rw-r--r--drivers/media/usb/dvb-usb/af9005-remote.c4
-rw-r--r--drivers/media/usb/dvb-usb/af9005.c4
-rw-r--r--drivers/media/usb/dvb-usb/af9005.h4
-rw-r--r--drivers/media/usb/dvb-usb/cinergyT2-core.c4
-rw-r--r--drivers/media/usb/dvb-usb/cinergyT2-fe.c4
-rw-r--r--drivers/media/usb/dvb-usb/cinergyT2.h4
-rw-r--r--drivers/media/usb/dvb-usb/cxusb.c327
-rw-r--r--drivers/media/usb/dvb-usb/dib0700_devices.c7
-rw-r--r--drivers/media/usb/dvb-usb/dtv5100.c4
-rw-r--r--drivers/media/usb/dvb-usb/dtv5100.h4
-rw-r--r--drivers/media/usb/dvb-usb/dvb-usb-firmware.c19
-rw-r--r--drivers/media/usb/dvb-usb/dvb-usb-remote.c3
-rw-r--r--drivers/media/usb/dvb-usb/gp8psk.c4
-rw-r--r--drivers/media/usb/dvb-usb/technisat-usb2.c6
-rw-r--r--drivers/media/usb/em28xx/em28xx-audio.c4
-rw-r--r--drivers/media/usb/em28xx/em28xx-cards.c19
-rw-r--r--drivers/media/usb/em28xx/em28xx-dvb.c74
-rw-r--r--drivers/media/usb/em28xx/em28xx-input.c15
-rw-r--r--drivers/media/usb/em28xx/em28xx.h1
-rw-r--r--drivers/media/usb/gspca/autogain_functions.c4
-rw-r--r--drivers/media/usb/gspca/benq.c4
-rw-r--r--drivers/media/usb/gspca/conex.c4
-rw-r--r--drivers/media/usb/gspca/cpia1.c4
-rw-r--r--drivers/media/usb/gspca/etoms.c4
-rw-r--r--drivers/media/usb/gspca/finepix.c4
-rw-r--r--drivers/media/usb/gspca/gspca.c4
-rw-r--r--drivers/media/usb/gspca/jeilinj.c4
-rw-r--r--drivers/media/usb/gspca/jl2005bcd.c4
-rw-r--r--drivers/media/usb/gspca/jpeg.h4
-rw-r--r--drivers/media/usb/gspca/kinect.c4
-rw-r--r--drivers/media/usb/gspca/konica.c4
-rw-r--r--drivers/media/usb/gspca/mars.c4
-rw-r--r--drivers/media/usb/gspca/mr97310a.c4
-rw-r--r--drivers/media/usb/gspca/nw80x.c4
-rw-r--r--drivers/media/usb/gspca/ov519.c4
-rw-r--r--drivers/media/usb/gspca/ov534.c4
-rw-r--r--drivers/media/usb/gspca/ov534_9.c4
-rw-r--r--drivers/media/usb/gspca/pac207.c4
-rw-r--r--drivers/media/usb/gspca/pac7302.c4
-rw-r--r--drivers/media/usb/gspca/pac7311.c4
-rw-r--r--drivers/media/usb/gspca/pac_common.h4
-rw-r--r--drivers/media/usb/gspca/se401.c4
-rw-r--r--drivers/media/usb/gspca/se401.h4
-rw-r--r--drivers/media/usb/gspca/sn9c2028.c4
-rw-r--r--drivers/media/usb/gspca/sn9c2028.h4
-rw-r--r--drivers/media/usb/gspca/sn9c20x.c4
-rw-r--r--drivers/media/usb/gspca/sonixb.c4
-rw-r--r--drivers/media/usb/gspca/sonixj.c4
-rw-r--r--drivers/media/usb/gspca/spca1528.c4
-rw-r--r--drivers/media/usb/gspca/spca500.c4
-rw-r--r--drivers/media/usb/gspca/spca501.c4
-rw-r--r--drivers/media/usb/gspca/spca505.c4
-rw-r--r--drivers/media/usb/gspca/spca506.c4
-rw-r--r--drivers/media/usb/gspca/spca508.c4
-rw-r--r--drivers/media/usb/gspca/spca561.c4
-rw-r--r--drivers/media/usb/gspca/sq905.c4
-rw-r--r--drivers/media/usb/gspca/sq905c.c4
-rw-r--r--drivers/media/usb/gspca/sq930x.c4
-rw-r--r--drivers/media/usb/gspca/stk014.c4
-rw-r--r--drivers/media/usb/gspca/stk1135.c4
-rw-r--r--drivers/media/usb/gspca/stk1135.h4
-rw-r--r--drivers/media/usb/gspca/stv0680.c4
-rw-r--r--drivers/media/usb/gspca/stv06xx/stv06xx.c4
-rw-r--r--drivers/media/usb/gspca/stv06xx/stv06xx.h4
-rw-r--r--drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.c4
-rw-r--r--drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.h4
-rw-r--r--drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c4
-rw-r--r--drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.h4
-rw-r--r--drivers/media/usb/gspca/stv06xx/stv06xx_sensor.h4
-rw-r--r--drivers/media/usb/gspca/stv06xx/stv06xx_st6422.c4
-rw-r--r--drivers/media/usb/gspca/stv06xx/stv06xx_st6422.h4
-rw-r--r--drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c7
-rw-r--r--drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.h4
-rw-r--r--drivers/media/usb/gspca/sunplus.c4
-rw-r--r--drivers/media/usb/gspca/t613.c4
-rw-r--r--drivers/media/usb/gspca/tv8532.c4
-rw-r--r--drivers/media/usb/gspca/vc032x.c4
-rw-r--r--drivers/media/usb/gspca/vicam.c4
-rw-r--r--drivers/media/usb/gspca/w996Xcf.c4
-rw-r--r--drivers/media/usb/gspca/xirlink_cit.c4
-rw-r--r--drivers/media/usb/gspca/zc3xx.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-audio.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-audio.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-context.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-context.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-cs53l32a.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-cs53l32a.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-ctrl.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-ctrl.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-cx2584x-v4l.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-cx2584x-v4l.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-debug.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-debugifc.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-debugifc.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-devattr.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-devattr.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-dvb.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-eeprom.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-eeprom.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-encoder.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-encoder.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-fx2-cmd.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-hdw-internal.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-hdw.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-hdw.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-i2c-core.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-io.c127
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-io.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-ioread.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-ioread.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-main.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-std.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-std.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-sysfs.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-sysfs.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-util.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-v4l2.c7
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-v4l2.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-video-v4l.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-video-v4l.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-wm8775.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-wm8775.h4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2.h4
-rw-r--r--drivers/media/usb/s2255/s2255drv.c4
-rw-r--r--drivers/media/usb/stk1160/Kconfig10
-rw-r--r--drivers/media/usb/stk1160/Makefile4
-rw-r--r--drivers/media/usb/stk1160/stk1160-ac97.c183
-rw-r--r--drivers/media/usb/stk1160/stk1160-core.c8
-rw-r--r--drivers/media/usb/stk1160/stk1160-reg.h10
-rw-r--r--drivers/media/usb/stk1160/stk1160.h11
-rw-r--r--drivers/media/usb/stkwebcam/stk-sensor.c4
-rw-r--r--drivers/media/usb/stkwebcam/stk-webcam.c4
-rw-r--r--drivers/media/usb/stkwebcam/stk-webcam.h4
-rw-r--r--drivers/media/usb/tm6000/tm6000-cards.c4
-rw-r--r--drivers/media/usb/tm6000/tm6000-core.c4
-rw-r--r--drivers/media/usb/tm6000/tm6000-dvb.c4
-rw-r--r--drivers/media/usb/tm6000/tm6000-i2c.c4
-rw-r--r--drivers/media/usb/tm6000/tm6000-input.c9
-rw-r--r--drivers/media/usb/tm6000/tm6000-regs.h4
-rw-r--r--drivers/media/usb/tm6000/tm6000-stds.c4
-rw-r--r--drivers/media/usb/tm6000/tm6000-usb-isoc.h4
-rw-r--r--drivers/media/usb/tm6000/tm6000-video.c9
-rw-r--r--drivers/media/usb/tm6000/tm6000.h4
-rw-r--r--drivers/media/usb/ttusb-dec/ttusb_dec.c4
-rw-r--r--drivers/media/usb/ttusb-dec/ttusbdecfe.c4
-rw-r--r--drivers/media/usb/ttusb-dec/ttusbdecfe.h4
-rw-r--r--drivers/media/usb/usbtv/usbtv-video.c8
-rw-r--r--drivers/media/usb/usbvision/usbvision-cards.c4
-rw-r--r--drivers/media/usb/usbvision/usbvision-core.c6
-rw-r--r--drivers/media/usb/usbvision/usbvision-i2c.c4
-rw-r--r--drivers/media/usb/usbvision/usbvision-video.c5
-rw-r--r--drivers/media/usb/usbvision/usbvision.h5
-rw-r--r--drivers/media/usb/uvc/uvc_debugfs.c15
-rw-r--r--drivers/media/usb/uvc/uvc_queue.c13
-rw-r--r--drivers/media/usb/uvc/uvc_video.c3
-rw-r--r--drivers/media/usb/uvc/uvcvideo.h4
-rw-r--r--drivers/media/usb/zr364xx/zr364xx.c4
-rw-r--r--drivers/media/v4l2-core/v4l2-async.c26
-rw-r--r--drivers/media/v4l2-core/v4l2-ctrls.c3
-rw-r--r--drivers/media/v4l2-core/v4l2-device.c2
-rw-r--r--drivers/media/v4l2-core/v4l2-event.c5
-rw-r--r--drivers/media/v4l2-core/v4l2-fh.c5
-rw-r--r--drivers/media/v4l2-core/v4l2-mc.c44
-rw-r--r--drivers/media/v4l2-core/v4l2-of.c13
-rw-r--r--drivers/media/v4l2-core/v4l2-subdev.c4
-rw-r--r--drivers/staging/media/davinci_vpfe/vpfe_video.c25
-rw-r--r--drivers/staging/media/davinci_vpfe/vpfe_video.h2
-rw-r--r--drivers/staging/media/lirc/Kconfig22
-rw-r--r--drivers/staging/media/lirc/Makefile3
-rw-r--r--drivers/staging/media/lirc/lirc_bt829.c401
-rw-r--r--drivers/staging/media/lirc/lirc_imon.c979
-rw-r--r--drivers/staging/media/lirc/lirc_parallel.c741
-rw-r--r--drivers/staging/media/lirc/lirc_parallel.h26
-rw-r--r--drivers/staging/media/lirc/lirc_sir.c296
-rw-r--r--drivers/staging/media/omap4iss/iss_video.c34
-rw-r--r--drivers/staging/media/s5p-cec/Kconfig2
-rw-r--r--drivers/staging/media/s5p-cec/exynos_hdmi_cec.h1
-rw-r--r--drivers/staging/media/s5p-cec/exynos_hdmi_cecctrl.c5
-rw-r--r--include/linux/platform_data/media/ir-rx51.h6
-rw-r--r--include/media/blackfin/ppi.h4
-rw-r--r--include/media/davinci/ccdc_types.h4
-rw-r--r--include/media/davinci/dm355_ccdc.h4
-rw-r--r--include/media/davinci/dm644x_ccdc.h4
-rw-r--r--include/media/davinci/isif.h4
-rw-r--r--include/media/davinci/vpbe.h4
-rw-r--r--include/media/davinci/vpbe_osd.h4
-rw-r--r--include/media/davinci/vpbe_types.h4
-rw-r--r--include/media/davinci/vpbe_venc.h4
-rw-r--r--include/media/davinci/vpfe_capture.h4
-rw-r--r--include/media/davinci/vpfe_types.h4
-rw-r--r--include/media/davinci/vpif_types.h5
-rw-r--r--include/media/davinci/vpss.h4
-rw-r--r--include/media/drv-intf/tea575x.h4
-rw-r--r--include/media/i2c/adp1653.h5
-rw-r--r--include/media/i2c/adv7183.h4
-rw-r--r--include/media/i2c/as3645a.h5
-rw-r--r--include/media/i2c/lm3560.h5
-rw-r--r--include/media/i2c/mt9m032.h5
-rw-r--r--include/media/i2c/smiapp.h5
-rw-r--r--include/media/i2c/ths7303.h4
-rw-r--r--include/media/i2c/tvp514x.h4
-rw-r--r--include/media/i2c/tvp7002.h4
-rw-r--r--include/media/i2c/upd64031a.h4
-rw-r--r--include/media/i2c/upd64083.h4
-rw-r--r--include/media/media-device.h8
-rw-r--r--include/media/media-devnode.h4
-rw-r--r--include/media/media-entity.h69
-rw-r--r--include/media/rc-core.h32
-rw-r--r--include/media/rc-map.h31
-rw-r--r--include/media/v4l2-event.h5
-rw-r--r--include/media/v4l2-fh.h5
-rw-r--r--include/media/v4l2-subdev.h6
863 files changed, 14505 insertions, 9025 deletions
diff --git a/Documentation/ABI/testing/sysfs-class-rc b/Documentation/ABI/testing/sysfs-class-rc
index b65674da43bb..8be1fd3760e0 100644
--- a/Documentation/ABI/testing/sysfs-class-rc
+++ b/Documentation/ABI/testing/sysfs-class-rc
@@ -62,18 +62,18 @@ Description:
62 This value may be reset to 0 if the current protocol is altered. 62 This value may be reset to 0 if the current protocol is altered.
63 63
64What: /sys/class/rc/rcN/wakeup_protocols 64What: /sys/class/rc/rcN/wakeup_protocols
65Date: Feb 2014 65Date: Feb 2017
66KernelVersion: 3.15 66KernelVersion: 4.11
67Contact: Mauro Carvalho Chehab <m.chehab@samsung.com> 67Contact: Mauro Carvalho Chehab <m.chehab@samsung.com>
68Description: 68Description:
69 Reading this file returns a list of available protocols to use 69 Reading this file returns a list of available protocols to use
70 for the wakeup filter, something like: 70 for the wakeup filter, something like:
71 "rc5 rc6 nec jvc [sony]" 71 "rc-5 nec nec-x rc-6-0 rc-6-6a-24 [rc-6-6a-32] rc-6-mce"
72 Note that protocol variants are listed, so "nec", "sony",
73 "rc-5", "rc-6" have their different bit length encodings
74 listed if available.
72 The enabled wakeup protocol is shown in [] brackets. 75 The enabled wakeup protocol is shown in [] brackets.
73 Writing "+proto" will add a protocol to the list of enabled 76 Only one protocol can be selected at a time.
74 wakeup protocols.
75 Writing "-proto" will remove a protocol from the list of enabled
76 wakeup protocols.
77 Writing "proto" will use "proto" for wakeup events. 77 Writing "proto" will use "proto" for wakeup events.
78 Writing "none" will disable wakeup. 78 Writing "none" will disable wakeup.
79 Write fails with EINVAL if an invalid protocol combination or 79 Write fails with EINVAL if an invalid protocol combination or
diff --git a/Documentation/devicetree/bindings/leds/irled/spi-ir-led.txt b/Documentation/devicetree/bindings/leds/irled/spi-ir-led.txt
new file mode 100644
index 000000000000..896b6997cf30
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/irled/spi-ir-led.txt
@@ -0,0 +1,29 @@
1Device tree bindings for IR LED connected through SPI bus which is used as
2remote controller.
3
4The IR LED switch is connected to the MOSI line of the SPI device and the data
5are delivered thourgh that.
6
7Required properties:
8 - compatible: should be "ir-spi-led".
9
10Optional properties:
11 - duty-cycle: 8 bit balue that represents the percentage of one period
12 in which the signal is active. It can be 50, 60, 70, 75, 80 or 90.
13 - led-active-low: boolean value that specifies whether the output is
14 negated with a NOT gate.
15 - power-supply: specifies the power source. It can either be a regulator
16 or a gpio which enables a regulator, i.e. a regulator-fixed as
17 described in
18 Documentation/devicetree/bindings/regulator/fixed-regulator.txt
19
20Example:
21
22 irled@0 {
23 compatible = "ir-spi-led";
24 reg = <0x0>;
25 spi-max-frequency = <5000000>;
26 power-supply = <&vdd_led>;
27 led-active-low;
28 duty-cycle = /bits/ 8 <60>;
29 };
diff --git a/Documentation/devicetree/bindings/media/fsl-vdoa.txt b/Documentation/devicetree/bindings/media/fsl-vdoa.txt
new file mode 100644
index 000000000000..6c5628530bb7
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/fsl-vdoa.txt
@@ -0,0 +1,21 @@
1Freescale Video Data Order Adapter
2==================================
3
4The Video Data Order Adapter (VDOA) is present on the i.MX6q. Its sole purpose
5is to reorder video data from the macroblock tiled order produced by the CODA
6960 VPU to the conventional raster-scan order for scanout.
7
8Required properties:
9- compatible: must be "fsl,imx6q-vdoa"
10- reg: the register base and size for the device registers
11- interrupts: the VDOA interrupt
12- clocks: the vdoa clock
13
14Example:
15
16vdoa@21e4000 {
17 compatible = "fsl,imx6q-vdoa";
18 reg = <0x021e4000 0x4000>;
19 interrupts = <0 18 IRQ_TYPE_LEVEL_HIGH>;
20 clocks = <&clks IMX6QDL_CLK_VDOA>;
21};
diff --git a/Documentation/devicetree/bindings/media/gpio-ir-receiver.txt b/Documentation/devicetree/bindings/media/gpio-ir-receiver.txt
index 56e726ef4bf2..58261fb7b408 100644
--- a/Documentation/devicetree/bindings/media/gpio-ir-receiver.txt
+++ b/Documentation/devicetree/bindings/media/gpio-ir-receiver.txt
@@ -5,7 +5,8 @@ Required properties:
5 - gpios: specifies GPIO used for IR signal reception. 5 - gpios: specifies GPIO used for IR signal reception.
6 6
7Optional properties: 7Optional properties:
8 - linux,rc-map-name: Linux specific remote control map name. 8 - linux,rc-map-name: see rc.txt file in the same
9 directory.
9 10
10Example node: 11Example node:
11 12
diff --git a/Documentation/devicetree/bindings/media/hix5hd2-ir.txt b/Documentation/devicetree/bindings/media/hix5hd2-ir.txt
index 54e1bede6244..13ebc0fac9ea 100644
--- a/Documentation/devicetree/bindings/media/hix5hd2-ir.txt
+++ b/Documentation/devicetree/bindings/media/hix5hd2-ir.txt
@@ -10,7 +10,7 @@ Required properties:
10 - clocks: clock phandle and specifier pair. 10 - clocks: clock phandle and specifier pair.
11 11
12Optional properties: 12Optional properties:
13 - linux,rc-map-name : Remote control map name. 13 - linux,rc-map-name: see rc.txt file in the same directory.
14 - hisilicon,power-syscon: DEPRECATED. Don't use this in new dts files. 14 - hisilicon,power-syscon: DEPRECATED. Don't use this in new dts files.
15 Provide correct clocks instead. 15 Provide correct clocks instead.
16 16
diff --git a/Documentation/devicetree/bindings/media/i2c/toshiba,et8ek8.txt b/Documentation/devicetree/bindings/media/i2c/toshiba,et8ek8.txt
new file mode 100644
index 000000000000..0b7b6a4d84ff
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/toshiba,et8ek8.txt
@@ -0,0 +1,48 @@
1Toshiba et8ek8 5MP sensor
2
3Toshiba et8ek8 5MP sensor is an image sensor found in Nokia N900 device
4
5More detailed documentation can be found in
6Documentation/devicetree/bindings/media/video-interfaces.txt .
7
8
9Mandatory properties
10--------------------
11
12- compatible: "toshiba,et8ek8"
13- reg: I2C address (0x3e, or an alternative address)
14- vana-supply: Analogue voltage supply (VANA), 2.8 volts
15- clocks: External clock to the sensor
16- clock-frequency: Frequency of the external clock to the sensor. Camera
17 driver will set this frequency on the external clock. The clock frequency is
18 a pre-determined frequency known to be suitable to the board.
19- reset-gpios: XSHUTDOWN GPIO. The XSHUTDOWN signal is active low. The sensor
20 is in hardware standby mode when the signal is in the low state.
21
22
23Endpoint node mandatory properties
24----------------------------------
25
26- remote-endpoint: A phandle to the bus receiver's endpoint node.
27
28
29Example
30-------
31
32&i2c3 {
33 clock-frequency = <400000>;
34
35 cam1: camera@3e {
36 compatible = "toshiba,et8ek8";
37 reg = <0x3e>;
38 vana-supply = <&vaux4>;
39 clocks = <&isp 0>;
40 clock-frequency = <9600000>;
41 reset-gpio = <&gpio4 6 GPIO_ACTIVE_HIGH>; /* 102 */
42 port {
43 csi_cam1: endpoint {
44 remote-endpoint = <&csi_out1>;
45 };
46 };
47 };
48};
diff --git a/Documentation/devicetree/bindings/media/meson-ir.txt b/Documentation/devicetree/bindings/media/meson-ir.txt
index e7e3f3c4fc8f..efd9d29a8f10 100644
--- a/Documentation/devicetree/bindings/media/meson-ir.txt
+++ b/Documentation/devicetree/bindings/media/meson-ir.txt
@@ -8,6 +8,9 @@ Required properties:
8 - reg : physical base address and length of the device registers 8 - reg : physical base address and length of the device registers
9 - interrupts : a single specifier for the interrupt from the device 9 - interrupts : a single specifier for the interrupt from the device
10 10
11Optional properties:
12 - linux,rc-map-name: see rc.txt file in the same directory.
13
11Example: 14Example:
12 15
13 ir-receiver@c8100480 { 16 ir-receiver@c8100480 {
diff --git a/Documentation/devicetree/bindings/media/mtk-cir.txt b/Documentation/devicetree/bindings/media/mtk-cir.txt
new file mode 100644
index 000000000000..2be2005577d6
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/mtk-cir.txt
@@ -0,0 +1,24 @@
1Device-Tree bindings for Mediatek consumer IR controller
2found in Mediatek SoC family
3
4Required properties:
5- compatible : "mediatek,mt7623-cir"
6- clocks : list of clock specifiers, corresponding to
7 entries in clock-names property;
8- clock-names : should contain "clk" entries;
9- interrupts : should contain IR IRQ number;
10- reg : should contain IO map address for IR.
11
12Optional properties:
13- linux,rc-map-name : see rc.txt file in the same directory.
14
15Example:
16
17cir: cir@10013000 {
18 compatible = "mediatek,mt7623-cir";
19 reg = <0 0x10013000 0 0x1000>;
20 interrupts = <GIC_SPI 87 IRQ_TYPE_LEVEL_LOW>;
21 clocks = <&infracfg CLK_INFRA_IRRX>;
22 clock-names = "clk";
23 linux,rc-map-name = "rc-rc6-mce";
24};
diff --git a/Documentation/devicetree/bindings/media/rc.txt b/Documentation/devicetree/bindings/media/rc.txt
new file mode 100644
index 000000000000..d3e7a012bfda
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/rc.txt
@@ -0,0 +1,117 @@
1The following properties are common to the infrared remote controllers:
2
3- linux,rc-map-name: string, specifies the scancode/key mapping table
4 defined in-kernel for the remote controller. Support values are:
5 * "rc-adstech-dvb-t-pci"
6 * "rc-alink-dtu-m"
7 * "rc-anysee"
8 * "rc-apac-viewcomp"
9 * "rc-asus-pc39"
10 * "rc-asus-ps3-100"
11 * "rc-ati-tv-wonder-hd-600"
12 * "rc-ati-x10"
13 * "rc-avermedia-a16d"
14 * "rc-avermedia-cardbus"
15 * "rc-avermedia-dvbt"
16 * "rc-avermedia-m135a"
17 * "rc-avermedia-m733a-rm-k6"
18 * "rc-avermedia-rm-ks"
19 * "rc-avermedia"
20 * "rc-avertv-303"
21 * "rc-azurewave-ad-tu700"
22 * "rc-behold-columbus"
23 * "rc-behold"
24 * "rc-budget-ci-old"
25 * "rc-cec"
26 * "rc-cinergy-1400"
27 * "rc-cinergy"
28 * "rc-delock-61959"
29 * "rc-dib0700-nec"
30 * "rc-dib0700-rc5"
31 * "rc-digitalnow-tinytwin"
32 * "rc-digittrade"
33 * "rc-dm1105-nec"
34 * "rc-dntv-live-dvbt-pro"
35 * "rc-dntv-live-dvb-t"
36 * "rc-dtt200u"
37 * "rc-dvbsky"
38 * "rc-empty"
39 * "rc-em-terratec"
40 * "rc-encore-enltv2"
41 * "rc-encore-enltv-fm53"
42 * "rc-encore-enltv"
43 * "rc-evga-indtube"
44 * "rc-eztv"
45 * "rc-flydvb"
46 * "rc-flyvideo"
47 * "rc-fusionhdtv-mce"
48 * "rc-gadmei-rm008z"
49 * "rc-geekbox"
50 * "rc-genius-tvgo-a11mce"
51 * "rc-gotview7135"
52 * "rc-hauppauge"
53 * "rc-imon-mce"
54 * "rc-imon-pad"
55 * "rc-iodata-bctv7e"
56 * "rc-it913x-v1"
57 * "rc-it913x-v2"
58 * "rc-kaiomy"
59 * "rc-kworld-315u"
60 * "rc-kworld-pc150u"
61 * "rc-kworld-plus-tv-analog"
62 * "rc-leadtek-y04g0051"
63 * "rc-lirc"
64 * "rc-lme2510"
65 * "rc-manli"
66 * "rc-medion-x10"
67 * "rc-medion-x10-digitainer"
68 * "rc-medion-x10-or2x"
69 * "rc-msi-digivox-ii"
70 * "rc-msi-digivox-iii"
71 * "rc-msi-tvanywhere-plus"
72 * "rc-msi-tvanywhere"
73 * "rc-nebula"
74 * "rc-nec-terratec-cinergy-xs"
75 * "rc-norwood"
76 * "rc-npgtech"
77 * "rc-pctv-sedna"
78 * "rc-pinnacle-color"
79 * "rc-pinnacle-grey"
80 * "rc-pinnacle-pctv-hd"
81 * "rc-pixelview-new"
82 * "rc-pixelview"
83 * "rc-pixelview-002t"
84 * "rc-pixelview-mk12"
85 * "rc-powercolor-real-angel"
86 * "rc-proteus-2309"
87 * "rc-purpletv"
88 * "rc-pv951"
89 * "rc-hauppauge"
90 * "rc-rc5-tv"
91 * "rc-rc6-mce"
92 * "rc-real-audio-220-32-keys"
93 * "rc-reddo"
94 * "rc-snapstream-firefly"
95 * "rc-streamzap"
96 * "rc-tbs-nec"
97 * "rc-technisat-ts35"
98 * "rc-technisat-usb2"
99 * "rc-terratec-cinergy-c-pci"
100 * "rc-terratec-cinergy-s2-hd"
101 * "rc-terratec-cinergy-xs"
102 * "rc-terratec-slim"
103 * "rc-terratec-slim-2"
104 * "rc-tevii-nec"
105 * "rc-tivo"
106 * "rc-total-media-in-hand"
107 * "rc-total-media-in-hand-02"
108 * "rc-trekstor"
109 * "rc-tt-1500"
110 * "rc-twinhan-dtv-cab-ci"
111 * "rc-twinhan1027"
112 * "rc-videomate-k100"
113 * "rc-videomate-s350"
114 * "rc-videomate-tv-pvr"
115 * "rc-winfast"
116 * "rc-winfast-usbii-deluxe"
117 * "rc-su3000"
diff --git a/Documentation/devicetree/bindings/media/st,st-delta.txt b/Documentation/devicetree/bindings/media/st,st-delta.txt
new file mode 100644
index 000000000000..a538ab30a617
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/st,st-delta.txt
@@ -0,0 +1,17 @@
1* STMicroelectronics DELTA multi-format video decoder
2
3Required properties:
4- compatible: should be "st,st-delta".
5- clocks: from common clock binding: handle hardware IP needed clocks, the
6 number of clocks may depend on the SoC type.
7 See ../clock/clock-bindings.txt for details.
8- clock-names: names of the clocks listed in clocks property in the same order.
9
10Example:
11 delta0 {
12 compatible = "st,st-delta";
13 clock-names = "delta", "delta-st231", "delta-flash-promip";
14 clocks = <&clk_s_c0_flexgen CLK_VID_DMU>,
15 <&clk_s_c0_flexgen CLK_ST231_DMU>,
16 <&clk_s_c0_flexgen CLK_FLASH_PROMIP>;
17 };
diff --git a/Documentation/devicetree/bindings/media/sunxi-ir.txt b/Documentation/devicetree/bindings/media/sunxi-ir.txt
index 1811a067c72c..302a0b183cb8 100644
--- a/Documentation/devicetree/bindings/media/sunxi-ir.txt
+++ b/Documentation/devicetree/bindings/media/sunxi-ir.txt
@@ -9,7 +9,7 @@ Required properties:
9- reg : should contain IO map address for IR. 9- reg : should contain IO map address for IR.
10 10
11Optional properties: 11Optional properties:
12- linux,rc-map-name : Remote control map name. 12- linux,rc-map-name: see rc.txt file in the same directory.
13- resets : phandle + reset specifier pair 13- resets : phandle + reset specifier pair
14 14
15Example: 15Example:
diff --git a/Documentation/devicetree/bindings/media/ti,da850-vpif.txt b/Documentation/devicetree/bindings/media/ti,da850-vpif.txt
new file mode 100644
index 000000000000..6d25d7f23d26
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/ti,da850-vpif.txt
@@ -0,0 +1,83 @@
1Texas Instruments VPIF
2----------------------
3
4The TI Video Port InterFace (VPIF) is the primary component for video
5capture and display on the DA850/AM18x family of TI DaVinci/Sitara
6SoCs.
7
8TI Document reference: SPRUH82C, Chapter 35
9http://www.ti.com/lit/pdf/spruh82
10
11Required properties:
12- compatible: must be "ti,da850-vpif"
13- reg: physical base address and length of the registers set for the device;
14- interrupts: should contain IRQ line for the VPIF
15
16Video Capture:
17
18VPIF has a 16-bit parallel bus input, supporting 2 8-bit channels or a
19single 16-bit channel. It should contain at least one port child node
20with child 'endpoint' node. Please refer to the bindings defined in
21Documentation/devicetree/bindings/media/video-interfaces.txt.
22
23Example using 2 8-bit input channels, one of which is connected to an
24I2C-connected TVP5147 decoder:
25
26 vpif: vpif@217000 {
27 compatible = "ti,da850-vpif";
28 reg = <0x217000 0x1000>;
29 interrupts = <92>;
30
31 port {
32 vpif_ch0: endpoint@0 {
33 reg = <0>;
34 bus-width = <8>;
35 remote-endpoint = <&composite>;
36 };
37
38 vpif_ch1: endpoint@1 {
39 reg = <1>;
40 bus-width = <8>;
41 data-shift = <8>;
42 };
43 };
44 };
45
46[ ... ]
47
48&i2c0 {
49
50 tvp5147@5d {
51 compatible = "ti,tvp5147";
52 reg = <0x5d>;
53 status = "okay";
54
55 port {
56 composite: endpoint {
57 hsync-active = <1>;
58 vsync-active = <1>;
59 pclk-sample = <0>;
60
61 /* VPIF channel 0 (lower 8-bits) */
62 remote-endpoint = <&vpif_ch0>;
63 bus-width = <8>;
64 };
65 };
66 };
67};
68
69
70Alternatively, an example when the bus is configured as a single
7116-bit input (e.g. for raw-capture mode):
72
73 vpif: vpif@217000 {
74 compatible = "ti,da850-vpif";
75 reg = <0x217000 0x1000>;
76 interrupts = <92>;
77
78 port {
79 vpif_ch0: endpoint {
80 bus-width = <16>;
81 };
82 };
83 };
diff --git a/Documentation/media/kapi/mc-core.rst b/Documentation/media/kapi/mc-core.rst
index 1a738e5f6056..0c05503eaf1f 100644
--- a/Documentation/media/kapi/mc-core.rst
+++ b/Documentation/media/kapi/mc-core.rst
@@ -162,13 +162,13 @@ framework provides a depth-first graph traversal API for that purpose.
162 currently defined as 16. 162 currently defined as 16.
163 163
164Drivers initiate a graph traversal by calling 164Drivers initiate a graph traversal by calling
165:c:func:`media_entity_graph_walk_start()` 165:c:func:`media_graph_walk_start()`
166 166
167The graph structure, provided by the caller, is initialized to start graph 167The graph structure, provided by the caller, is initialized to start graph
168traversal at the given entity. 168traversal at the given entity.
169 169
170Drivers can then retrieve the next entity by calling 170Drivers can then retrieve the next entity by calling
171:c:func:`media_entity_graph_walk_next()` 171:c:func:`media_graph_walk_next()`
172 172
173When the graph traversal is complete the function will return ``NULL``. 173When the graph traversal is complete the function will return ``NULL``.
174 174
@@ -206,7 +206,7 @@ Pipelines and media streams
206 206
207When starting streaming, drivers must notify all entities in the pipeline to 207When starting streaming, drivers must notify all entities in the pipeline to
208prevent link states from being modified during streaming by calling 208prevent link states from being modified during streaming by calling
209:c:func:`media_entity_pipeline_start()`. 209:c:func:`media_pipeline_start()`.
210 210
211The function will mark all entities connected to the given entity through 211The function will mark all entities connected to the given entity through
212enabled links, either directly or indirectly, as streaming. 212enabled links, either directly or indirectly, as streaming.
@@ -218,17 +218,17 @@ in higher-level pipeline structures and can then access the
218pipeline through the struct :c:type:`media_entity` 218pipeline through the struct :c:type:`media_entity`
219pipe field. 219pipe field.
220 220
221Calls to :c:func:`media_entity_pipeline_start()` can be nested. 221Calls to :c:func:`media_pipeline_start()` can be nested.
222The pipeline pointer must be identical for all nested calls to the function. 222The pipeline pointer must be identical for all nested calls to the function.
223 223
224:c:func:`media_entity_pipeline_start()` may return an error. In that case, 224:c:func:`media_pipeline_start()` may return an error. In that case,
225it will clean up any of the changes it did by itself. 225it will clean up any of the changes it did by itself.
226 226
227When stopping the stream, drivers must notify the entities with 227When stopping the stream, drivers must notify the entities with
228:c:func:`media_entity_pipeline_stop()`. 228:c:func:`media_pipeline_stop()`.
229 229
230If multiple calls to :c:func:`media_entity_pipeline_start()` have been 230If multiple calls to :c:func:`media_pipeline_start()` have been
231made the same number of :c:func:`media_entity_pipeline_stop()` calls 231made the same number of :c:func:`media_pipeline_stop()` calls
232are required to stop streaming. 232are required to stop streaming.
233The :c:type:`media_entity`.\ ``pipe`` field is reset to ``NULL`` on the last 233The :c:type:`media_entity`.\ ``pipe`` field is reset to ``NULL`` on the last
234nested stop call. 234nested stop call.
@@ -245,7 +245,7 @@ operation must be done with the media_device graph_mutex held.
245Link validation 245Link validation
246^^^^^^^^^^^^^^^ 246^^^^^^^^^^^^^^^
247 247
248Link validation is performed by :c:func:`media_entity_pipeline_start()` 248Link validation is performed by :c:func:`media_pipeline_start()`
249for any entity which has sink pads in the pipeline. The 249for any entity which has sink pads in the pipeline. The
250:c:type:`media_entity`.\ ``link_validate()`` callback is used for that 250:c:type:`media_entity`.\ ``link_validate()`` callback is used for that
251purpose. In ``link_validate()`` callback, entity driver should check 251purpose. In ``link_validate()`` callback, entity driver should check
diff --git a/Documentation/media/uapi/gen-errors.rst b/Documentation/media/uapi/gen-errors.rst
index 6e983b9880fc..d39e34d1b19d 100644
--- a/Documentation/media/uapi/gen-errors.rst
+++ b/Documentation/media/uapi/gen-errors.rst
@@ -94,9 +94,17 @@ Generic Error Codes
94 - Permission denied. Can be returned if the device needs write 94 - Permission denied. Can be returned if the device needs write
95 permission, or some special capabilities is needed (e. g. root) 95 permission, or some special capabilities is needed (e. g. root)
96 96
97 - .. row 11
98
99 - ``EIO``
100
101 - I/O error. Typically used when there are problems communicating with
102 a hardware device. This could indicate broken or flaky hardware.
103 It's a 'Something is wrong, I give up!' type of error.
104
97.. note:: 105.. note::
98 106
99 #. This list is not exaustive; ioctls may return other error codes. 107 #. This list is not exhaustive; ioctls may return other error codes.
100 Since errors may have side effects such as a driver reset, 108 Since errors may have side effects such as a driver reset,
101 applications should abort on unexpected errors, or otherwise 109 applications should abort on unexpected errors, or otherwise
102 assume that the device is in a bad state. 110 assume that the device is in a bad state.
diff --git a/Documentation/media/uapi/rc/rc-sysfs-nodes.rst b/Documentation/media/uapi/rc/rc-sysfs-nodes.rst
index 6fb944fe21fd..3476ae29708f 100644
--- a/Documentation/media/uapi/rc/rc-sysfs-nodes.rst
+++ b/Documentation/media/uapi/rc/rc-sysfs-nodes.rst
@@ -92,15 +92,16 @@ This value may be reset to 0 if the current protocol is altered.
92Reading this file returns a list of available protocols to use for the 92Reading this file returns a list of available protocols to use for the
93wakeup filter, something like: 93wakeup filter, something like:
94 94
95``rc5 rc6 nec jvc [sony]`` 95``rc-5 nec nec-x rc-6-0 rc-6-6a-24 [rc-6-6a-32] rc-6-mce``
96 96
97The enabled wakeup protocol is shown in [] brackets. 97Note that protocol variants are listed, so "nec", "sony", "rc-5", "rc-6"
98have their different bit length encodings listed if available.
98 99
99Writing "+proto" will add a protocol to the list of enabled wakeup 100Note that all protocol variants are listed.
100protocols.
101 101
102Writing "-proto" will remove a protocol from the list of enabled wakeup 102The enabled wakeup protocol is shown in [] brackets.
103protocols. 103
104Only one protocol can be selected at a time.
104 105
105Writing "proto" will use "proto" for wakeup events. 106Writing "proto" will use "proto" for wakeup events.
106 107
diff --git a/MAINTAINERS b/MAINTAINERS
index 0e542ed67e0a..2f9f345a15b7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2423,6 +2423,14 @@ W: https://linuxtv.org
2423S: Supported 2423S: Supported
2424F: drivers/media/platform/sti/bdisp 2424F: drivers/media/platform/sti/bdisp
2425 2425
2426DELTA ST MEDIA DRIVER
2427M: Hugues Fruchet <hugues.fruchet@st.com>
2428L: linux-media@vger.kernel.org
2429T: git git://linuxtv.org/media_tree.git
2430W: https://linuxtv.org
2431S: Supported
2432F: drivers/media/platform/sti/delta
2433
2426BEFS FILE SYSTEM 2434BEFS FILE SYSTEM
2427M: Luis de Bethencourt <luisbg@osg.samsung.com> 2435M: Luis de Bethencourt <luisbg@osg.samsung.com>
2428M: Salah Triki <salah.triki@gmail.com> 2436M: Salah Triki <salah.triki@gmail.com>
@@ -5738,16 +5746,6 @@ L: linux-parisc@vger.kernel.org
5738S: Maintained 5746S: Maintained
5739F: sound/parisc/harmony.* 5747F: sound/parisc/harmony.*
5740 5748
5741HD29L2 MEDIA DRIVER
5742M: Antti Palosaari <crope@iki.fi>
5743L: linux-media@vger.kernel.org
5744W: https://linuxtv.org
5745W: http://palosaari.fi/linux/
5746Q: http://patchwork.linuxtv.org/project/linux-media/list/
5747T: git git://linuxtv.org/anttip/media_tree.git
5748S: Maintained
5749F: drivers/media/dvb-frontends/hd29l2*
5750
5751HEWLETT PACKARD ENTERPRISE ILO NMI WATCHDOG DRIVER 5749HEWLETT PACKARD ENTERPRISE ILO NMI WATCHDOG DRIVER
5752M: Jimmy Vance <jimmy.vance@hpe.com> 5750M: Jimmy Vance <jimmy.vance@hpe.com>
5753S: Supported 5751S: Supported
@@ -8825,6 +8823,22 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/lftan/nios2.git
8825S: Maintained 8823S: Maintained
8826F: arch/nios2/ 8824F: arch/nios2/
8827 8825
8826NOKIA N900 CAMERA SUPPORT (ET8EK8 SENSOR, AD5820 FOCUS)
8827M: Pavel Machek <pavel@ucw.cz>
8828M: Sakari Ailus <sakari.ailus@iki.fi>
8829L: linux-media@vger.kernel.org
8830S: Maintained
8831F: drivers/media/i2c/et8ek8
8832F: drivers/media/i2c/ad5820.c
8833
8834NOKIA N900 CAMERA SUPPORT (ET8EK8 SENSOR, AD5820 FOCUS)
8835M: Pavel Machek <pavel@ucw.cz>
8836M: Sakari Ailus <sakari.ailus@iki.fi>
8837L: linux-media@vger.kernel.org
8838S: Maintained
8839F: drivers/media/i2c/et8ek8
8840F: drivers/media/i2c/ad5820.c
8841
8828NOKIA N900 POWER SUPPLY DRIVERS 8842NOKIA N900 POWER SUPPLY DRIVERS
8829R: Pali Rohár <pali.rohar@gmail.com> 8843R: Pali Rohár <pali.rohar@gmail.com>
8830F: include/linux/power/bq2415x_charger.h 8844F: include/linux/power/bq2415x_charger.h
@@ -13660,6 +13674,24 @@ L: zd1211-devs@lists.sourceforge.net (subscribers-only)
13660S: Maintained 13674S: Maintained
13661F: drivers/net/wireless/zydas/zd1211rw/ 13675F: drivers/net/wireless/zydas/zd1211rw/
13662 13676
13677ZD1301_DEMOD MEDIA DRIVER
13678M: Antti Palosaari <crope@iki.fi>
13679L: linux-media@vger.kernel.org
13680W: https://linuxtv.org/
13681W: http://palosaari.fi/linux/
13682Q: https://patchwork.linuxtv.org/project/linux-media/list/
13683S: Maintained
13684F: drivers/media/dvb-frontends/zd1301_demod*
13685
13686ZD1301 MEDIA DRIVER
13687M: Antti Palosaari <crope@iki.fi>
13688L: linux-media@vger.kernel.org
13689W: https://linuxtv.org/
13690W: http://palosaari.fi/linux/
13691Q: https://patchwork.linuxtv.org/project/linux-media/list/
13692S: Maintained
13693F: drivers/media/usb/dvb-usb-v2/zd1301*
13694
13663ZPOOL COMPRESSED PAGE STORAGE API 13695ZPOOL COMPRESSED PAGE STORAGE API
13664M: Dan Streetman <ddstreet@ieee.org> 13696M: Dan Streetman <ddstreet@ieee.org>
13665L: linux-mm@kvack.org 13697L: linux-mm@kvack.org
diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi
index e7d30f45b161..6d37d9af5f1d 100644
--- a/arch/arm/boot/dts/imx6qdl.dtsi
+++ b/arch/arm/boot/dts/imx6qdl.dtsi
@@ -1166,8 +1166,10 @@
1166 }; 1166 };
1167 1167
1168 vdoa@021e4000 { 1168 vdoa@021e4000 {
1169 compatible = "fsl,imx6q-vdoa";
1169 reg = <0x021e4000 0x4000>; 1170 reg = <0x021e4000 0x4000>;
1170 interrupts = <0 18 IRQ_TYPE_LEVEL_HIGH>; 1171 interrupts = <0 18 IRQ_TYPE_LEVEL_HIGH>;
1172 clocks = <&clks IMX6QDL_CLK_VDOA>;
1171 }; 1173 };
1172 1174
1173 uart2: serial@021e8000 { 1175 uart2: serial@021e8000 {
diff --git a/arch/arm/boot/dts/stih407-family.dtsi b/arch/arm/boot/dts/stih407-family.dtsi
index ace97e8576db..4c72dae2aefa 100644
--- a/arch/arm/boot/dts/stih407-family.dtsi
+++ b/arch/arm/boot/dts/stih407-family.dtsi
@@ -1003,5 +1003,15 @@
1003 1003
1004 status = "disabled"; 1004 status = "disabled";
1005 }; 1005 };
1006
1007 delta0 {
1008 compatible = "st,st-delta";
1009 clock-names = "delta",
1010 "delta-st231",
1011 "delta-flash-promip";
1012 clocks = <&clk_s_c0_flexgen CLK_VID_DMU>,
1013 <&clk_s_c0_flexgen CLK_ST231_DMU>,
1014 <&clk_s_c0_flexgen CLK_FLASH_PROMIP>;
1015 };
1006 }; 1016 };
1007}; 1017};
diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index 2e7a63f35bd3..affffa7c415b 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -569,6 +569,7 @@ CONFIG_VIDEO_SAMSUNG_S5P_MFC=m
569CONFIG_VIDEO_SAMSUNG_EXYNOS_GSC=m 569CONFIG_VIDEO_SAMSUNG_EXYNOS_GSC=m
570CONFIG_VIDEO_STI_BDISP=m 570CONFIG_VIDEO_STI_BDISP=m
571CONFIG_VIDEO_STI_HVA=m 571CONFIG_VIDEO_STI_HVA=m
572CONFIG_VIDEO_STI_DELTA=m
572CONFIG_VIDEO_RENESAS_JPU=m 573CONFIG_VIDEO_RENESAS_JPU=m
573CONFIG_VIDEO_RENESAS_VSP1=m 574CONFIG_VIDEO_RENESAS_VSP1=m
574CONFIG_V4L_TEST_DRIVERS=y 575CONFIG_V4L_TEST_DRIVERS=y
diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c
index 70c004794880..67498aad2654 100644
--- a/arch/arm/mach-omap2/pdata-quirks.c
+++ b/arch/arm/mach-omap2/pdata-quirks.c
@@ -484,15 +484,15 @@ static struct pwm_omap_dmtimer_pdata pwm_dmtimer_pdata = {
484}; 484};
485#endif 485#endif
486 486
487static struct lirc_rx51_platform_data __maybe_unused rx51_lirc_data = { 487static struct ir_rx51_platform_data __maybe_unused rx51_ir_data = {
488 .set_max_mpu_wakeup_lat = omap_pm_set_max_mpu_wakeup_lat, 488 .set_max_mpu_wakeup_lat = omap_pm_set_max_mpu_wakeup_lat,
489}; 489};
490 490
491static struct platform_device __maybe_unused rx51_lirc_device = { 491static struct platform_device __maybe_unused rx51_ir_device = {
492 .name = "lirc_rx51", 492 .name = "ir_rx51",
493 .id = -1, 493 .id = -1,
494 .dev = { 494 .dev = {
495 .platform_data = &rx51_lirc_data, 495 .platform_data = &rx51_ir_data,
496 }, 496 },
497}; 497};
498 498
@@ -533,7 +533,7 @@ static struct of_dev_auxdata omap_auxdata_lookup[] __initdata = {
533 &omap3_iommu_pdata), 533 &omap3_iommu_pdata),
534 OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x4809c000, "4809c000.mmc", &mmc_pdata[0]), 534 OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x4809c000, "4809c000.mmc", &mmc_pdata[0]),
535 OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x480b4000, "480b4000.mmc", &mmc_pdata[1]), 535 OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x480b4000, "480b4000.mmc", &mmc_pdata[1]),
536 OF_DEV_AUXDATA("nokia,n900-ir", 0, "n900-ir", &rx51_lirc_data), 536 OF_DEV_AUXDATA("nokia,n900-ir", 0, "n900-ir", &rx51_ir_data),
537 /* Only on am3517 */ 537 /* Only on am3517 */
538 OF_DEV_AUXDATA("ti,davinci_mdio", 0x5c030000, "davinci_mdio.0", NULL), 538 OF_DEV_AUXDATA("ti,davinci_mdio", 0x5c030000, "davinci_mdio.0", NULL),
539 OF_DEV_AUXDATA("ti,am3517-emac", 0x5c000000, "davinci_emac.0", 539 OF_DEV_AUXDATA("ti,am3517-emac", 0x5c000000, "davinci_emac.0",
diff --git a/drivers/hid/hid-picolcd_cir.c b/drivers/hid/hid-picolcd_cir.c
index 96286510f42e..8ffbb6f65a65 100644
--- a/drivers/hid/hid-picolcd_cir.c
+++ b/drivers/hid/hid-picolcd_cir.c
@@ -108,13 +108,12 @@ int picolcd_init_cir(struct picolcd_data *data, struct hid_report *report)
108 struct rc_dev *rdev; 108 struct rc_dev *rdev;
109 int ret = 0; 109 int ret = 0;
110 110
111 rdev = rc_allocate_device(); 111 rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
112 if (!rdev) 112 if (!rdev)
113 return -ENOMEM; 113 return -ENOMEM;
114 114
115 rdev->priv = data; 115 rdev->priv = data;
116 rdev->driver_type = RC_DRIVER_IR_RAW; 116 rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
117 rdev->allowed_protocols = RC_BIT_ALL;
118 rdev->open = picolcd_cir_open; 117 rdev->open = picolcd_cir_open;
119 rdev->close = picolcd_cir_close; 118 rdev->close = picolcd_cir_close;
120 rdev->input_name = data->hdev->name; 119 rdev->input_name = data->hdev->name;
diff --git a/drivers/media/cec/cec-core.c b/drivers/media/cec/cec-core.c
index aca3ab83a8a1..37217e205040 100644
--- a/drivers/media/cec/cec-core.c
+++ b/drivers/media/cec/cec-core.c
@@ -239,7 +239,7 @@ struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops,
239 239
240#if IS_REACHABLE(CONFIG_RC_CORE) 240#if IS_REACHABLE(CONFIG_RC_CORE)
241 /* Prepare the RC input device */ 241 /* Prepare the RC input device */
242 adap->rc = rc_allocate_device(); 242 adap->rc = rc_allocate_device(RC_DRIVER_SCANCODE);
243 if (!adap->rc) { 243 if (!adap->rc) {
244 pr_err("cec-%s: failed to allocate memory for rc_dev\n", 244 pr_err("cec-%s: failed to allocate memory for rc_dev\n",
245 name); 245 name);
@@ -259,7 +259,6 @@ struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops,
259 adap->rc->input_id.vendor = 0; 259 adap->rc->input_id.vendor = 0;
260 adap->rc->input_id.product = 0; 260 adap->rc->input_id.product = 0;
261 adap->rc->input_id.version = 1; 261 adap->rc->input_id.version = 1;
262 adap->rc->driver_type = RC_DRIVER_SCANCODE;
263 adap->rc->driver_name = CEC_NAME; 262 adap->rc->driver_name = CEC_NAME;
264 adap->rc->allowed_protocols = RC_BIT_CEC; 263 adap->rc->allowed_protocols = RC_BIT_CEC;
265 adap->rc->priv = adap; 264 adap->rc->priv = adap;
diff --git a/drivers/media/common/b2c2/flexcop-fe-tuner.c b/drivers/media/common/b2c2/flexcop-fe-tuner.c
index f5956402fc69..5f10151ecec9 100644
--- a/drivers/media/common/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/common/b2c2/flexcop-fe-tuner.c
@@ -24,8 +24,7 @@
24 24
25/* Can we use the specified front-end? Remember that if we are compiled 25/* Can we use the specified front-end? Remember that if we are compiled
26 * into the kernel we can't call code that's in modules. */ 26 * into the kernel we can't call code that's in modules. */
27#define FE_SUPPORTED(fe) (defined(CONFIG_DVB_##fe) || \ 27#define FE_SUPPORTED(fe) IS_REACHABLE(CONFIG_DVB_ ## fe)
28 (defined(CONFIG_DVB_##fe##_MODULE) && defined(MODULE)))
29 28
30#if FE_SUPPORTED(BCM3510) || (FE_SUPPORTED(CX24120) && FE_SUPPORTED(ISL6421)) 29#if FE_SUPPORTED(BCM3510) || (FE_SUPPORTED(CX24120) && FE_SUPPORTED(ISL6421))
31static int flexcop_fe_request_firmware(struct dvb_frontend *fe, 30static int flexcop_fe_request_firmware(struct dvb_frontend *fe,
diff --git a/drivers/media/common/b2c2/flexcop.c b/drivers/media/common/b2c2/flexcop.c
index 4338ab0043b4..2e0ab55cd67e 100644
--- a/drivers/media/common/b2c2/flexcop.c
+++ b/drivers/media/common/b2c2/flexcop.c
@@ -25,10 +25,6 @@
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of 25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details. 27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU Lesser General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 */ 28 */
33 29
34#include "flexcop.h" 30#include "flexcop.h"
diff --git a/drivers/media/common/cx2341x.c b/drivers/media/common/cx2341x.c
index 2725702eda7b..81dce9a81bd3 100644
--- a/drivers/media/common/cx2341x.c
+++ b/drivers/media/common/cx2341x.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21 17
diff --git a/drivers/media/common/siano/sms-cards.c b/drivers/media/common/siano/sms-cards.c
index ca2f80c7740c..af6b2268db61 100644
--- a/drivers/media/common/siano/sms-cards.c
+++ b/drivers/media/common/siano/sms-cards.c
@@ -11,10 +11,6 @@
11 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 11 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
12 * 12 *
13 * See the GNU General Public License for more details. 13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 14 */
19 15
20#include "sms-cards.h" 16#include "sms-cards.h"
diff --git a/drivers/media/common/siano/sms-cards.h b/drivers/media/common/siano/sms-cards.h
index bb3d733f092b..e6264b4797b4 100644
--- a/drivers/media/common/siano/sms-cards.h
+++ b/drivers/media/common/siano/sms-cards.h
@@ -11,10 +11,6 @@
11 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 11 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
12 * 12 *
13 * See the GNU General Public License for more details. 13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 14 */
19 15
20#ifndef __SMS_CARDS_H__ 16#ifndef __SMS_CARDS_H__
diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c
index f3a42834d7d6..e7a0d7798d5b 100644
--- a/drivers/media/common/siano/smscoreapi.c
+++ b/drivers/media/common/siano/smscoreapi.c
@@ -15,10 +15,6 @@
15 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 15 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
16 * 16 *
17 * See the GNU General Public License for more details. 17 * See the GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 18 */
23 19
24#include "smscoreapi.h" 20#include "smscoreapi.h"
diff --git a/drivers/media/common/siano/smsir.c b/drivers/media/common/siano/smsir.c
index 41f2a3939979..7c898b06d85c 100644
--- a/drivers/media/common/siano/smsir.c
+++ b/drivers/media/common/siano/smsir.c
@@ -58,7 +58,7 @@ int sms_ir_init(struct smscore_device_t *coredev)
58 struct rc_dev *dev; 58 struct rc_dev *dev;
59 59
60 pr_debug("Allocating rc device\n"); 60 pr_debug("Allocating rc device\n");
61 dev = rc_allocate_device(); 61 dev = rc_allocate_device(RC_DRIVER_IR_RAW);
62 if (!dev) 62 if (!dev)
63 return -ENOMEM; 63 return -ENOMEM;
64 64
@@ -86,8 +86,7 @@ int sms_ir_init(struct smscore_device_t *coredev)
86#endif 86#endif
87 87
88 dev->priv = coredev; 88 dev->priv = coredev;
89 dev->driver_type = RC_DRIVER_IR_RAW; 89 dev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
90 dev->allowed_protocols = RC_BIT_ALL;
91 dev->map_name = sms_get_board(board_id)->rc_codes; 90 dev->map_name = sms_get_board(board_id)->rc_codes;
92 dev->driver_name = MODULE_NAME; 91 dev->driver_name = MODULE_NAME;
93 92
diff --git a/drivers/media/common/tveeprom.c b/drivers/media/common/tveeprom.c
index 11976031aff8..6e1020227f9f 100644
--- a/drivers/media/common/tveeprom.c
+++ b/drivers/media/common/tveeprom.c
@@ -22,10 +22,6 @@
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details. 24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 */ 25 */
30 26
31#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 27#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/dvb-core/demux.h b/drivers/media/dvb-core/demux.h
index f8adf4506a45..f854309ba8a5 100644
--- a/drivers/media/dvb-core/demux.h
+++ b/drivers/media/dvb-core/demux.h
@@ -21,10 +21,6 @@
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details. 22 * GNU General Public License for more details.
23 * 23 *
24 * You should have received a copy of the GNU Lesser General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 *
28 */ 24 */
29 25
30#ifndef __DEMUX_H 26#ifndef __DEMUX_H
diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c
index 0c16bb213101..45e91add73ba 100644
--- a/drivers/media/dvb-core/dmxdev.c
+++ b/drivers/media/dvb-core/dmxdev.c
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 *
21 */ 17 */
22 18
23#define pr_fmt(fmt) "dmxdev: " fmt 19#define pr_fmt(fmt) "dmxdev: " fmt
@@ -151,6 +147,7 @@ static int dvb_dvr_open(struct inode *inode, struct file *file)
151 147
152 if ((file->f_flags & O_ACCMODE) == O_RDONLY) { 148 if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
153 void *mem; 149 void *mem;
150
154 if (!dvbdev->readers) { 151 if (!dvbdev->readers) {
155 mutex_unlock(&dmxdev->mutex); 152 mutex_unlock(&dmxdev->mutex);
156 return -EBUSY; 153 return -EBUSY;
@@ -202,6 +199,7 @@ static int dvb_dvr_release(struct inode *inode, struct file *file)
202 dvbdev->readers++; 199 dvbdev->readers++;
203 if (dmxdev->dvr_buffer.data) { 200 if (dmxdev->dvr_buffer.data) {
204 void *mem = dmxdev->dvr_buffer.data; 201 void *mem = dmxdev->dvr_buffer.data;
202 /*memory barrier*/
205 mb(); 203 mb();
206 spin_lock_irq(&dmxdev->lock); 204 spin_lock_irq(&dmxdev->lock);
207 dmxdev->dvr_buffer.data = NULL; 205 dmxdev->dvr_buffer.data = NULL;
@@ -876,7 +874,7 @@ static int dvb_dmxdev_pes_filter_set(struct dmxdev *dmxdev,
876 dvb_dmxdev_filter_stop(dmxdevfilter); 874 dvb_dmxdev_filter_stop(dmxdevfilter);
877 dvb_dmxdev_filter_reset(dmxdevfilter); 875 dvb_dmxdev_filter_reset(dmxdevfilter);
878 876
879 if ((unsigned)params->pes_type > DMX_PES_OTHER) 877 if ((unsigned int)params->pes_type > DMX_PES_OTHER)
880 return -EINVAL; 878 return -EINVAL;
881 879
882 dmxdevfilter->type = DMXDEV_TYPE_PES; 880 dmxdevfilter->type = DMXDEV_TYPE_PES;
@@ -1125,7 +1123,7 @@ static int dvb_demux_release(struct inode *inode, struct file *file)
1125 1123
1126 mutex_lock(&dmxdev->mutex); 1124 mutex_lock(&dmxdev->mutex);
1127 dmxdev->dvbdev->users--; 1125 dmxdev->dvbdev->users--;
1128 if(dmxdev->dvbdev->users==1 && dmxdev->exit==1) { 1126 if (dmxdev->dvbdev->users == 1 && dmxdev->exit == 1) {
1129 mutex_unlock(&dmxdev->mutex); 1127 mutex_unlock(&dmxdev->mutex);
1130 wake_up(&dmxdev->dvbdev->wait_queue); 1128 wake_up(&dmxdev->dvbdev->wait_queue);
1131 } else 1129 } else
@@ -1263,14 +1261,14 @@ EXPORT_SYMBOL(dvb_dmxdev_init);
1263 1261
1264void dvb_dmxdev_release(struct dmxdev *dmxdev) 1262void dvb_dmxdev_release(struct dmxdev *dmxdev)
1265{ 1263{
1266 dmxdev->exit=1; 1264 dmxdev->exit = 1;
1267 if (dmxdev->dvbdev->users > 1) { 1265 if (dmxdev->dvbdev->users > 1) {
1268 wait_event(dmxdev->dvbdev->wait_queue, 1266 wait_event(dmxdev->dvbdev->wait_queue,
1269 dmxdev->dvbdev->users==1); 1267 dmxdev->dvbdev->users == 1);
1270 } 1268 }
1271 if (dmxdev->dvr_dvbdev->users > 1) { 1269 if (dmxdev->dvr_dvbdev->users > 1) {
1272 wait_event(dmxdev->dvr_dvbdev->wait_queue, 1270 wait_event(dmxdev->dvr_dvbdev->wait_queue,
1273 dmxdev->dvr_dvbdev->users==1); 1271 dmxdev->dvr_dvbdev->users == 1);
1274 } 1272 }
1275 1273
1276 dvb_unregister_device(dmxdev->dvbdev); 1274 dvb_unregister_device(dmxdev->dvbdev);
diff --git a/drivers/media/dvb-core/dmxdev.h b/drivers/media/dvb-core/dmxdev.h
index 48c6cf92ab99..054fd4eb6192 100644
--- a/drivers/media/dvb-core/dmxdev.h
+++ b/drivers/media/dvb-core/dmxdev.h
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 *
21 */ 17 */
22 18
23#ifndef _DMXDEV_H_ 19#ifndef _DMXDEV_H_
diff --git a/drivers/media/dvb-core/dvb-usb-ids.h b/drivers/media/dvb-core/dvb-usb-ids.h
index 779f4224b63e..e200aa6f2d2f 100644
--- a/drivers/media/dvb-core/dvb-usb-ids.h
+++ b/drivers/media/dvb-core/dvb-usb-ids.h
@@ -73,11 +73,13 @@
73#define USB_VID_GIGABYTE 0x1044 73#define USB_VID_GIGABYTE 0x1044
74#define USB_VID_YUAN 0x1164 74#define USB_VID_YUAN 0x1164
75#define USB_VID_XTENSIONS 0x1ae7 75#define USB_VID_XTENSIONS 0x1ae7
76#define USB_VID_ZYDAS 0x0ace
76#define USB_VID_HUMAX_COEX 0x10b9 77#define USB_VID_HUMAX_COEX 0x10b9
77#define USB_VID_774 0x7a69 78#define USB_VID_774 0x7a69
78#define USB_VID_EVOLUTEPC 0x1e59 79#define USB_VID_EVOLUTEPC 0x1e59
79#define USB_VID_AZUREWAVE 0x13d3 80#define USB_VID_AZUREWAVE 0x13d3
80#define USB_VID_TECHNISAT 0x14f7 81#define USB_VID_TECHNISAT 0x14f7
82#define USB_VID_HAMA 0x147f
81 83
82/* Product IDs */ 84/* Product IDs */
83#define USB_PID_ADSTECH_USB2_COLD 0xa333 85#define USB_PID_ADSTECH_USB2_COLD 0xa333
@@ -412,5 +414,6 @@
412#define USB_PID_SVEON_STV27 0xd3af 414#define USB_PID_SVEON_STV27 0xd3af
413#define USB_PID_TURBOX_DTT_2000 0xd3a4 415#define USB_PID_TURBOX_DTT_2000 0xd3a4
414#define USB_PID_WINTV_SOLOHD 0x0264 416#define USB_PID_WINTV_SOLOHD 0x0264
415#define USB_PID_EVOLVEO_XTRATV_STICK 0xa115 417#define USB_PID_EVOLVEO_XTRATV_STICK 0xa115
418#define USB_PID_HAMA_DVBT_HYBRID 0x2758
416#endif 419#endif
diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index fd893141211c..000d737ad827 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -21,11 +21,8 @@
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details. 23 * GNU General Public License for more details.
24 * 24 * To obtain the license, point your browser to
25 * You should have received a copy of the GNU General Public License 25 * http://www.gnu.org/copyleft/gpl.html
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
29 */ 26 */
30 27
31#define pr_fmt(fmt) "dvb_ca_en50221: " fmt 28#define pr_fmt(fmt) "dvb_ca_en50221: " fmt
diff --git a/drivers/media/dvb-core/dvb_demux.c b/drivers/media/dvb-core/dvb_demux.c
index bbbff72bbb2a..4eac71e50c5f 100644
--- a/drivers/media/dvb-core/dvb_demux.c
+++ b/drivers/media/dvb-core/dvb_demux.c
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 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 */ 18 */
23 19
24#define pr_fmt(fmt) "dvb_demux: " fmt 20#define pr_fmt(fmt) "dvb_demux: " fmt
diff --git a/drivers/media/dvb-core/dvb_demux.h b/drivers/media/dvb-core/dvb_demux.h
index 9235b008ea0a..6f572ca8d339 100644
--- a/drivers/media/dvb-core/dvb_demux.h
+++ b/drivers/media/dvb-core/dvb_demux.h
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 *
21 */ 17 */
22 18
23#ifndef _DVB_DEMUX_H_ 19#ifndef _DVB_DEMUX_H_
diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index db74cb74d271..85ae3669aa66 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -18,11 +18,8 @@
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 * 21 * To obtain the license, point your browser to
22 * You should have received a copy of the GNU General Public License 22 * http://www.gnu.org/copyleft/gpl.html
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
26 */ 23 */
27 24
28/* Enables DVBv3 compatibility bits at the headers */ 25/* Enables DVBv3 compatibility bits at the headers */
@@ -2536,9 +2533,13 @@ static int dvb_frontend_open(struct inode *inode, struct file *file)
2536 fepriv->voltage = -1; 2533 fepriv->voltage = -1;
2537 2534
2538#ifdef CONFIG_MEDIA_CONTROLLER_DVB 2535#ifdef CONFIG_MEDIA_CONTROLLER_DVB
2539 if (fe->dvb->mdev && fe->dvb->mdev->enable_source) { 2536 if (fe->dvb->mdev) {
2540 ret = fe->dvb->mdev->enable_source(dvbdev->entity, 2537 mutex_lock(&fe->dvb->mdev->graph_mutex);
2538 if (fe->dvb->mdev->enable_source)
2539 ret = fe->dvb->mdev->enable_source(
2540 dvbdev->entity,
2541 &fepriv->pipe); 2541 &fepriv->pipe);
2542 mutex_unlock(&fe->dvb->mdev->graph_mutex);
2542 if (ret) { 2543 if (ret) {
2543 dev_err(fe->dvb->device, 2544 dev_err(fe->dvb->device,
2544 "Tuner is busy. Error %d\n", ret); 2545 "Tuner is busy. Error %d\n", ret);
@@ -2562,8 +2563,12 @@ static int dvb_frontend_open(struct inode *inode, struct file *file)
2562 2563
2563err3: 2564err3:
2564#ifdef CONFIG_MEDIA_CONTROLLER_DVB 2565#ifdef CONFIG_MEDIA_CONTROLLER_DVB
2565 if (fe->dvb->mdev && fe->dvb->mdev->disable_source) 2566 if (fe->dvb->mdev) {
2566 fe->dvb->mdev->disable_source(dvbdev->entity); 2567 mutex_lock(&fe->dvb->mdev->graph_mutex);
2568 if (fe->dvb->mdev->disable_source)
2569 fe->dvb->mdev->disable_source(dvbdev->entity);
2570 mutex_unlock(&fe->dvb->mdev->graph_mutex);
2571 }
2567err2: 2572err2:
2568#endif 2573#endif
2569 dvb_generic_release(inode, file); 2574 dvb_generic_release(inode, file);
@@ -2595,8 +2600,12 @@ static int dvb_frontend_release(struct inode *inode, struct file *file)
2595 if (dvbdev->users == -1) { 2600 if (dvbdev->users == -1) {
2596 wake_up(&fepriv->wait_queue); 2601 wake_up(&fepriv->wait_queue);
2597#ifdef CONFIG_MEDIA_CONTROLLER_DVB 2602#ifdef CONFIG_MEDIA_CONTROLLER_DVB
2598 if (fe->dvb->mdev && fe->dvb->mdev->disable_source) 2603 if (fe->dvb->mdev) {
2599 fe->dvb->mdev->disable_source(dvbdev->entity); 2604 mutex_lock(&fe->dvb->mdev->graph_mutex);
2605 if (fe->dvb->mdev->disable_source)
2606 fe->dvb->mdev->disable_source(dvbdev->entity);
2607 mutex_unlock(&fe->dvb->mdev->graph_mutex);
2608 }
2600#endif 2609#endif
2601 if (fe->exit != DVB_FE_NO_EXIT) 2610 if (fe->exit != DVB_FE_NO_EXIT)
2602 wake_up(&dvbdev->wait_queue); 2611 wake_up(&dvbdev->wait_queue);
diff --git a/drivers/media/dvb-core/dvb_math.c b/drivers/media/dvb-core/dvb_math.c
index beb7c93aa6cb..a2e1810dd83a 100644
--- a/drivers/media/dvb-core/dvb_math.c
+++ b/drivers/media/dvb-core/dvb_math.c
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details. 15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 16 */
21 17
22#include <linux/bitops.h> 18#include <linux/bitops.h>
diff --git a/drivers/media/dvb-core/dvb_math.h b/drivers/media/dvb-core/dvb_math.h
index 4d11d3529c14..8690ec42954d 100644
--- a/drivers/media/dvb-core/dvb_math.h
+++ b/drivers/media/dvb-core/dvb_math.h
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details. 15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 16 */
21 17
22#ifndef __DVB_MATH_H 18#ifndef __DVB_MATH_H
diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c
index 8f11d7e45993..9947b342633e 100644
--- a/drivers/media/dvb-core/dvb_net.c
+++ b/drivers/media/dvb-core/dvb_net.c
@@ -23,11 +23,8 @@
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details. 25 * GNU General Public License for more details.
26 * 26 * To obtain the license, point your browser to
27 * You should have received a copy of the GNU General Public License 27 * http://www.gnu.org/copyleft/gpl.html
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
31 */ 28 */
32 29
33/* 30/*
diff --git a/drivers/media/dvb-core/dvb_net.h b/drivers/media/dvb-core/dvb_net.h
index ede78e8c8aa8..e9b18aa03e02 100644
--- a/drivers/media/dvb-core/dvb_net.h
+++ b/drivers/media/dvb-core/dvb_net.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 *
20 */ 16 */
21 17
22#ifndef _DVB_NET_H_ 18#ifndef _DVB_NET_H_
diff --git a/drivers/media/dvb-core/dvb_ringbuffer.c b/drivers/media/dvb-core/dvb_ringbuffer.c
index 5c4b5a1f604f..2322af1b8742 100644
--- a/drivers/media/dvb-core/dvb_ringbuffer.c
+++ b/drivers/media/dvb-core/dvb_ringbuffer.c
@@ -18,10 +18,6 @@
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details. 20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 */ 21 */
26 22
27 23
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 38c844667789..41aad0f99d73 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 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 */ 18 */
23 19
24#define pr_fmt(fmt) "dvbdev: " fmt 20#define pr_fmt(fmt) "dvbdev: " fmt
diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h
index 8c0a7b51555e..49189392cf3b 100644
--- a/drivers/media/dvb-core/dvbdev.h
+++ b/drivers/media/dvb-core/dvbdev.h
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 *
21 */ 17 */
22 18
23#ifndef _DVBDEV_H_ 19#ifndef _DVBDEV_H_
diff --git a/drivers/media/dvb-frontends/Kconfig b/drivers/media/dvb-frontends/Kconfig
index c841fa1770be..e8c6554a47aa 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -447,13 +447,6 @@ config DVB_EC100
447 help 447 help
448 Say Y when you want to support this frontend. 448 Say Y when you want to support this frontend.
449 449
450config DVB_HD29L2
451 tristate "HDIC HD29L2"
452 depends on DVB_CORE && I2C
453 default m if !MEDIA_SUBDRV_AUTOSELECT
454 help
455 Say Y when you want to support this frontend.
456
457config DVB_STV0367 450config DVB_STV0367
458 tristate "ST STV0367 based" 451 tristate "ST STV0367 based"
459 depends on DVB_CORE && I2C 452 depends on DVB_CORE && I2C
@@ -513,6 +506,13 @@ config DVB_AS102_FE
513 depends on DVB_CORE 506 depends on DVB_CORE
514 default DVB_AS102 507 default DVB_AS102
515 508
509config DVB_ZD1301_DEMOD
510 tristate "ZyDAS ZD1301"
511 depends on DVB_CORE && I2C
512 default m if !MEDIA_SUBDRV_AUTOSELECT
513 help
514 Say Y when you want to support this frontend.
515
516config DVB_GP8PSK_FE 516config DVB_GP8PSK_FE
517 tristate 517 tristate
518 depends on DVB_CORE 518 depends on DVB_CORE
@@ -619,7 +619,7 @@ config DVB_LGDT3305
619 619
620config DVB_LGDT3306A 620config DVB_LGDT3306A
621 tristate "LG Electronics LGDT3306A based" 621 tristate "LG Electronics LGDT3306A based"
622 depends on DVB_CORE && I2C 622 depends on DVB_CORE && I2C && I2C_MUX
623 default m if !MEDIA_SUBDRV_AUTOSELECT 623 default m if !MEDIA_SUBDRV_AUTOSELECT
624 help 624 help
625 An ATSC 8VSB and QAM-B 64/256 demodulator module. Say Y when you want 625 An ATSC 8VSB and QAM-B 64/256 demodulator module. Say Y when you want
@@ -852,6 +852,7 @@ config DVB_M88RS2000
852config DVB_AF9033 852config DVB_AF9033
853 tristate "Afatech AF9033 DVB-T demodulator" 853 tristate "Afatech AF9033 DVB-T demodulator"
854 depends on DVB_CORE && I2C 854 depends on DVB_CORE && I2C
855 select REGMAP_I2C
855 default m if !MEDIA_SUBDRV_AUTOSELECT 856 default m if !MEDIA_SUBDRV_AUTOSELECT
856 857
857config DVB_HORUS3A 858config DVB_HORUS3A
diff --git a/drivers/media/dvb-frontends/Makefile b/drivers/media/dvb-frontends/Makefile
index 93921a4eaa27..3fccaf34ef52 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -99,7 +99,6 @@ obj-$(CONFIG_DVB_MN88472) += mn88472.o
99obj-$(CONFIG_DVB_MN88473) += mn88473.o 99obj-$(CONFIG_DVB_MN88473) += mn88473.o
100obj-$(CONFIG_DVB_ISL6423) += isl6423.o 100obj-$(CONFIG_DVB_ISL6423) += isl6423.o
101obj-$(CONFIG_DVB_EC100) += ec100.o 101obj-$(CONFIG_DVB_EC100) += ec100.o
102obj-$(CONFIG_DVB_HD29L2) += hd29l2.o
103obj-$(CONFIG_DVB_DS3000) += ds3000.o 102obj-$(CONFIG_DVB_DS3000) += ds3000.o
104obj-$(CONFIG_DVB_TS2020) += ts2020.o 103obj-$(CONFIG_DVB_TS2020) += ts2020.o
105obj-$(CONFIG_DVB_MB86A16) += mb86a16.o 104obj-$(CONFIG_DVB_MB86A16) += mb86a16.o
@@ -126,3 +125,4 @@ obj-$(CONFIG_DVB_TC90522) += tc90522.o
126obj-$(CONFIG_DVB_HORUS3A) += horus3a.o 125obj-$(CONFIG_DVB_HORUS3A) += horus3a.o
127obj-$(CONFIG_DVB_ASCOT2E) += ascot2e.o 126obj-$(CONFIG_DVB_ASCOT2E) += ascot2e.o
128obj-$(CONFIG_DVB_HELENE) += helene.o 127obj-$(CONFIG_DVB_HELENE) += helene.o
128obj-$(CONFIG_DVB_ZD1301_DEMOD) += zd1301_demod.o
diff --git a/drivers/media/dvb-frontends/af9013.c b/drivers/media/dvb-frontends/af9013.c
index c6cb3bbc912a..b978002af4d8 100644
--- a/drivers/media/dvb-frontends/af9013.c
+++ b/drivers/media/dvb-frontends/af9013.c
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 */ 19 */
24 20
25#include "af9013_priv.h" 21#include "af9013_priv.h"
diff --git a/drivers/media/dvb-frontends/af9013.h b/drivers/media/dvb-frontends/af9013.h
index dcdd163ace85..277112863719 100644
--- a/drivers/media/dvb-frontends/af9013.h
+++ b/drivers/media/dvb-frontends/af9013.h
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 */ 19 */
24 20
25#ifndef AF9013_H 21#ifndef AF9013_H
diff --git a/drivers/media/dvb-frontends/af9013_priv.h b/drivers/media/dvb-frontends/af9013_priv.h
index 8b9392cfc00d..31d6538abfae 100644
--- a/drivers/media/dvb-frontends/af9013_priv.h
+++ b/drivers/media/dvb-frontends/af9013_priv.h
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 */ 19 */
24 20
25#ifndef AF9013_PRIV_H 21#ifndef AF9013_PRIV_H
diff --git a/drivers/media/dvb-frontends/af9033.c b/drivers/media/dvb-frontends/af9033.c
index f8818028752e..aaed7cfe5f66 100644
--- a/drivers/media/dvb-frontends/af9033.c
+++ b/drivers/media/dvb-frontends/af9033.c
@@ -13,19 +13,13 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */ 16 */
21 17
22#include "af9033_priv.h" 18#include "af9033_priv.h"
23 19
24/* Max transfer size done by I2C transfer functions */
25#define MAX_XFER_SIZE 64
26
27struct af9033_dev { 20struct af9033_dev {
28 struct i2c_client *client; 21 struct i2c_client *client;
22 struct regmap *regmap;
29 struct dvb_frontend fe; 23 struct dvb_frontend fe;
30 struct af9033_config cfg; 24 struct af9033_config cfg;
31 bool is_af9035; 25 bool is_af9035;
@@ -43,146 +37,19 @@ struct af9033_dev {
43 u64 total_block_count; 37 u64 total_block_count;
44}; 38};
45 39
46/* write multiple registers */ 40/* Write reg val table using reg addr auto increment */
47static int af9033_wr_regs(struct af9033_dev *dev, u32 reg, const u8 *val,
48 int len)
49{
50 int ret;
51 u8 buf[MAX_XFER_SIZE];
52 struct i2c_msg msg[1] = {
53 {
54 .addr = dev->client->addr,
55 .flags = 0,
56 .len = 3 + len,
57 .buf = buf,
58 }
59 };
60
61 if (3 + len > sizeof(buf)) {
62 dev_warn(&dev->client->dev,
63 "i2c wr reg=%04x: len=%d is too big!\n",
64 reg, len);
65 return -EINVAL;
66 }
67
68 buf[0] = (reg >> 16) & 0xff;
69 buf[1] = (reg >> 8) & 0xff;
70 buf[2] = (reg >> 0) & 0xff;
71 memcpy(&buf[3], val, len);
72
73 ret = i2c_transfer(dev->client->adapter, msg, 1);
74 if (ret == 1) {
75 ret = 0;
76 } else {
77 dev_warn(&dev->client->dev, "i2c wr failed=%d reg=%06x len=%d\n",
78 ret, reg, len);
79 ret = -EREMOTEIO;
80 }
81
82 return ret;
83}
84
85/* read multiple registers */
86static int af9033_rd_regs(struct af9033_dev *dev, u32 reg, u8 *val, int len)
87{
88 int ret;
89 u8 buf[3] = { (reg >> 16) & 0xff, (reg >> 8) & 0xff,
90 (reg >> 0) & 0xff };
91 struct i2c_msg msg[2] = {
92 {
93 .addr = dev->client->addr,
94 .flags = 0,
95 .len = sizeof(buf),
96 .buf = buf
97 }, {
98 .addr = dev->client->addr,
99 .flags = I2C_M_RD,
100 .len = len,
101 .buf = val
102 }
103 };
104
105 ret = i2c_transfer(dev->client->adapter, msg, 2);
106 if (ret == 2) {
107 ret = 0;
108 } else {
109 dev_warn(&dev->client->dev, "i2c rd failed=%d reg=%06x len=%d\n",
110 ret, reg, len);
111 ret = -EREMOTEIO;
112 }
113
114 return ret;
115}
116
117
118/* write single register */
119static int af9033_wr_reg(struct af9033_dev *dev, u32 reg, u8 val)
120{
121 return af9033_wr_regs(dev, reg, &val, 1);
122}
123
124/* read single register */
125static int af9033_rd_reg(struct af9033_dev *dev, u32 reg, u8 *val)
126{
127 return af9033_rd_regs(dev, reg, val, 1);
128}
129
130/* write single register with mask */
131static int af9033_wr_reg_mask(struct af9033_dev *dev, u32 reg, u8 val,
132 u8 mask)
133{
134 int ret;
135 u8 tmp;
136
137 /* no need for read if whole reg is written */
138 if (mask != 0xff) {
139 ret = af9033_rd_regs(dev, reg, &tmp, 1);
140 if (ret)
141 return ret;
142
143 val &= mask;
144 tmp &= ~mask;
145 val |= tmp;
146 }
147
148 return af9033_wr_regs(dev, reg, &val, 1);
149}
150
151/* read single register with mask */
152static int af9033_rd_reg_mask(struct af9033_dev *dev, u32 reg, u8 *val,
153 u8 mask)
154{
155 int ret, i;
156 u8 tmp;
157
158 ret = af9033_rd_regs(dev, reg, &tmp, 1);
159 if (ret)
160 return ret;
161
162 tmp &= mask;
163
164 /* find position of the first bit */
165 for (i = 0; i < 8; i++) {
166 if ((mask >> i) & 0x01)
167 break;
168 }
169 *val = tmp >> i;
170
171 return 0;
172}
173
174/* write reg val table using reg addr auto increment */
175static int af9033_wr_reg_val_tab(struct af9033_dev *dev, 41static int af9033_wr_reg_val_tab(struct af9033_dev *dev,
176 const struct reg_val *tab, int tab_len) 42 const struct reg_val *tab, int tab_len)
177{ 43{
44 struct i2c_client *client = dev->client;
178#define MAX_TAB_LEN 212 45#define MAX_TAB_LEN 212
179 int ret, i, j; 46 int ret, i, j;
180 u8 buf[1 + MAX_TAB_LEN]; 47 u8 buf[1 + MAX_TAB_LEN];
181 48
182 dev_dbg(&dev->client->dev, "tab_len=%d\n", tab_len); 49 dev_dbg(&client->dev, "tab_len=%d\n", tab_len);
183 50
184 if (tab_len > sizeof(buf)) { 51 if (tab_len > sizeof(buf)) {
185 dev_warn(&dev->client->dev, "tab len %d is too big\n", tab_len); 52 dev_warn(&client->dev, "tab len %d is too big\n", tab_len);
186 return -EINVAL; 53 return -EINVAL;
187 } 54 }
188 55
@@ -190,8 +57,9 @@ static int af9033_wr_reg_val_tab(struct af9033_dev *dev,
190 buf[j] = tab[i].val; 57 buf[j] = tab[i].val;
191 58
192 if (i == tab_len - 1 || tab[i].reg != tab[i + 1].reg - 1) { 59 if (i == tab_len - 1 || tab[i].reg != tab[i + 1].reg - 1) {
193 ret = af9033_wr_regs(dev, tab[i].reg - j, buf, j + 1); 60 ret = regmap_bulk_write(dev->regmap, tab[i].reg - j,
194 if (ret < 0) 61 buf, j + 1);
62 if (ret)
195 goto err; 63 goto err;
196 64
197 j = 0; 65 j = 0;
@@ -201,47 +69,20 @@ static int af9033_wr_reg_val_tab(struct af9033_dev *dev,
201 } 69 }
202 70
203 return 0; 71 return 0;
204
205err: 72err:
206 dev_dbg(&dev->client->dev, "failed=%d\n", ret); 73 dev_dbg(&client->dev, "failed=%d\n", ret);
207
208 return ret; 74 return ret;
209} 75}
210 76
211static u32 af9033_div(struct af9033_dev *dev, u32 a, u32 b, u32 x)
212{
213 u32 r = 0, c = 0, i;
214
215 dev_dbg(&dev->client->dev, "a=%d b=%d x=%d\n", a, b, x);
216
217 if (a > b) {
218 c = a / b;
219 a = a - c * b;
220 }
221
222 for (i = 0; i < x; i++) {
223 if (a >= b) {
224 r += 1;
225 a -= b;
226 }
227 a <<= 1;
228 r <<= 1;
229 }
230 r = (c << (u32)x) + r;
231
232 dev_dbg(&dev->client->dev, "a=%d b=%d x=%d r=%d r=%x\n", a, b, x, r, r);
233
234 return r;
235}
236
237static int af9033_init(struct dvb_frontend *fe) 77static int af9033_init(struct dvb_frontend *fe)
238{ 78{
239 struct af9033_dev *dev = fe->demodulator_priv; 79 struct af9033_dev *dev = fe->demodulator_priv;
80 struct i2c_client *client = dev->client;
240 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 81 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
241 int ret, i, len; 82 int ret, i, len;
83 unsigned int utmp;
242 const struct reg_val *init; 84 const struct reg_val *init;
243 u8 buf[4]; 85 u8 buf[4];
244 u32 adc_cw, clock_cw;
245 struct reg_val_mask tab[] = { 86 struct reg_val_mask tab[] = {
246 { 0x80fb24, 0x00, 0x08 }, 87 { 0x80fb24, 0x00, 0x08 },
247 { 0x80004c, 0x00, 0xff }, 88 { 0x80004c, 0x00, 0xff },
@@ -271,80 +112,76 @@ static int af9033_init(struct dvb_frontend *fe)
271 { 0x800045, dev->cfg.adc_multiplier, 0xff }, 112 { 0x800045, dev->cfg.adc_multiplier, 0xff },
272 }; 113 };
273 114
274 /* program clock control */ 115 dev_dbg(&client->dev, "\n");
275 clock_cw = af9033_div(dev, dev->cfg.clock, 1000000ul, 19ul);
276 buf[0] = (clock_cw >> 0) & 0xff;
277 buf[1] = (clock_cw >> 8) & 0xff;
278 buf[2] = (clock_cw >> 16) & 0xff;
279 buf[3] = (clock_cw >> 24) & 0xff;
280
281 dev_dbg(&dev->client->dev, "clock=%d clock_cw=%08x\n",
282 dev->cfg.clock, clock_cw);
283 116
284 ret = af9033_wr_regs(dev, 0x800025, buf, 4); 117 /* Main clk control */
285 if (ret < 0) 118 utmp = div_u64((u64)dev->cfg.clock * 0x80000, 1000000);
119 buf[0] = (utmp >> 0) & 0xff;
120 buf[1] = (utmp >> 8) & 0xff;
121 buf[2] = (utmp >> 16) & 0xff;
122 buf[3] = (utmp >> 24) & 0xff;
123 ret = regmap_bulk_write(dev->regmap, 0x800025, buf, 4);
124 if (ret)
286 goto err; 125 goto err;
287 126
288 /* program ADC control */ 127 dev_dbg(&client->dev, "clk=%u clk_cw=%08x\n", dev->cfg.clock, utmp);
128
129 /* ADC clk control */
289 for (i = 0; i < ARRAY_SIZE(clock_adc_lut); i++) { 130 for (i = 0; i < ARRAY_SIZE(clock_adc_lut); i++) {
290 if (clock_adc_lut[i].clock == dev->cfg.clock) 131 if (clock_adc_lut[i].clock == dev->cfg.clock)
291 break; 132 break;
292 } 133 }
293 if (i == ARRAY_SIZE(clock_adc_lut)) { 134 if (i == ARRAY_SIZE(clock_adc_lut)) {
294 dev_err(&dev->client->dev, 135 dev_err(&client->dev, "Couldn't find ADC config for clock %d\n",
295 "Couldn't find ADC config for clock=%d\n",
296 dev->cfg.clock); 136 dev->cfg.clock);
297 goto err; 137 goto err;
298 } 138 }
299 139
300 adc_cw = af9033_div(dev, clock_adc_lut[i].adc, 1000000ul, 19ul); 140 utmp = div_u64((u64)clock_adc_lut[i].adc * 0x80000, 1000000);
301 buf[0] = (adc_cw >> 0) & 0xff; 141 buf[0] = (utmp >> 0) & 0xff;
302 buf[1] = (adc_cw >> 8) & 0xff; 142 buf[1] = (utmp >> 8) & 0xff;
303 buf[2] = (adc_cw >> 16) & 0xff; 143 buf[2] = (utmp >> 16) & 0xff;
304 144 ret = regmap_bulk_write(dev->regmap, 0x80f1cd, buf, 3);
305 dev_dbg(&dev->client->dev, "adc=%d adc_cw=%06x\n", 145 if (ret)
306 clock_adc_lut[i].adc, adc_cw);
307
308 ret = af9033_wr_regs(dev, 0x80f1cd, buf, 3);
309 if (ret < 0)
310 goto err; 146 goto err;
311 147
312 /* program register table */ 148 dev_dbg(&client->dev, "adc=%u adc_cw=%06x\n",
149 clock_adc_lut[i].adc, utmp);
150
151 /* Config register table */
313 for (i = 0; i < ARRAY_SIZE(tab); i++) { 152 for (i = 0; i < ARRAY_SIZE(tab); i++) {
314 ret = af9033_wr_reg_mask(dev, tab[i].reg, tab[i].val, 153 ret = regmap_update_bits(dev->regmap, tab[i].reg, tab[i].mask,
315 tab[i].mask); 154 tab[i].val);
316 if (ret < 0) 155 if (ret)
317 goto err; 156 goto err;
318 } 157 }
319 158
320 /* clock output */ 159 /* Demod clk output */
321 if (dev->cfg.dyn0_clk) { 160 if (dev->cfg.dyn0_clk) {
322 ret = af9033_wr_reg(dev, 0x80fba8, 0x00); 161 ret = regmap_write(dev->regmap, 0x80fba8, 0x00);
323 if (ret < 0) 162 if (ret)
324 goto err; 163 goto err;
325 } 164 }
326 165
327 /* settings for TS interface */ 166 /* TS interface */
328 if (dev->cfg.ts_mode == AF9033_TS_MODE_USB) { 167 if (dev->cfg.ts_mode == AF9033_TS_MODE_USB) {
329 ret = af9033_wr_reg_mask(dev, 0x80f9a5, 0x00, 0x01); 168 ret = regmap_update_bits(dev->regmap, 0x80f9a5, 0x01, 0x00);
330 if (ret < 0) 169 if (ret)
331 goto err; 170 goto err;
332 171 ret = regmap_update_bits(dev->regmap, 0x80f9b5, 0x01, 0x01);
333 ret = af9033_wr_reg_mask(dev, 0x80f9b5, 0x01, 0x01); 172 if (ret)
334 if (ret < 0)
335 goto err; 173 goto err;
336 } else { 174 } else {
337 ret = af9033_wr_reg_mask(dev, 0x80f990, 0x00, 0x01); 175 ret = regmap_update_bits(dev->regmap, 0x80f990, 0x01, 0x00);
338 if (ret < 0) 176 if (ret)
339 goto err; 177 goto err;
340 178 ret = regmap_update_bits(dev->regmap, 0x80f9b5, 0x01, 0x00);
341 ret = af9033_wr_reg_mask(dev, 0x80f9b5, 0x00, 0x01); 179 if (ret)
342 if (ret < 0)
343 goto err; 180 goto err;
344 } 181 }
345 182
346 /* load OFSM settings */ 183 /* Demod core settings */
347 dev_dbg(&dev->client->dev, "load ofsm settings\n"); 184 dev_dbg(&client->dev, "load ofsm settings\n");
348 switch (dev->cfg.tuner) { 185 switch (dev->cfg.tuner) {
349 case AF9033_TUNER_IT9135_38: 186 case AF9033_TUNER_IT9135_38:
350 case AF9033_TUNER_IT9135_51: 187 case AF9033_TUNER_IT9135_51:
@@ -365,11 +202,11 @@ static int af9033_init(struct dvb_frontend *fe)
365 } 202 }
366 203
367 ret = af9033_wr_reg_val_tab(dev, init, len); 204 ret = af9033_wr_reg_val_tab(dev, init, len);
368 if (ret < 0) 205 if (ret)
369 goto err; 206 goto err;
370 207
371 /* load tuner specific settings */ 208 /* Demod tuner specific settings */
372 dev_dbg(&dev->client->dev, "load tuner specific settings\n"); 209 dev_dbg(&client->dev, "load tuner specific settings\n");
373 switch (dev->cfg.tuner) { 210 switch (dev->cfg.tuner) {
374 case AF9033_TUNER_TUA9001: 211 case AF9033_TUNER_TUA9001:
375 len = ARRAY_SIZE(tuner_init_tua9001); 212 len = ARRAY_SIZE(tuner_init_tua9001);
@@ -420,27 +257,25 @@ static int af9033_init(struct dvb_frontend *fe)
420 init = tuner_init_it9135_62; 257 init = tuner_init_it9135_62;
421 break; 258 break;
422 default: 259 default:
423 dev_dbg(&dev->client->dev, "unsupported tuner ID=%d\n", 260 dev_dbg(&client->dev, "unsupported tuner ID=%d\n",
424 dev->cfg.tuner); 261 dev->cfg.tuner);
425 ret = -ENODEV; 262 ret = -ENODEV;
426 goto err; 263 goto err;
427 } 264 }
428 265
429 ret = af9033_wr_reg_val_tab(dev, init, len); 266 ret = af9033_wr_reg_val_tab(dev, init, len);
430 if (ret < 0) 267 if (ret)
431 goto err; 268 goto err;
432 269
433 if (dev->cfg.ts_mode == AF9033_TS_MODE_SERIAL) { 270 if (dev->cfg.ts_mode == AF9033_TS_MODE_SERIAL) {
434 ret = af9033_wr_reg_mask(dev, 0x00d91c, 0x01, 0x01); 271 ret = regmap_update_bits(dev->regmap, 0x00d91c, 0x01, 0x01);
435 if (ret < 0) 272 if (ret)
436 goto err; 273 goto err;
437 274 ret = regmap_update_bits(dev->regmap, 0x00d917, 0x01, 0x00);
438 ret = af9033_wr_reg_mask(dev, 0x00d917, 0x00, 0x01); 275 if (ret)
439 if (ret < 0)
440 goto err; 276 goto err;
441 277 ret = regmap_update_bits(dev->regmap, 0x00d916, 0x01, 0x00);
442 ret = af9033_wr_reg_mask(dev, 0x00d916, 0x00, 0x01); 278 if (ret)
443 if (ret < 0)
444 goto err; 279 goto err;
445 } 280 }
446 281
@@ -448,13 +283,13 @@ static int af9033_init(struct dvb_frontend *fe)
448 case AF9033_TUNER_IT9135_60: 283 case AF9033_TUNER_IT9135_60:
449 case AF9033_TUNER_IT9135_61: 284 case AF9033_TUNER_IT9135_61:
450 case AF9033_TUNER_IT9135_62: 285 case AF9033_TUNER_IT9135_62:
451 ret = af9033_wr_reg(dev, 0x800000, 0x01); 286 ret = regmap_write(dev->regmap, 0x800000, 0x01);
452 if (ret < 0) 287 if (ret)
453 goto err; 288 goto err;
454 } 289 }
455 290
456 dev->bandwidth_hz = 0; /* force to program all parameters */ 291 dev->bandwidth_hz = 0; /* Force to program all parameters */
457 /* init stats here in order signal app which stats are supported */ 292 /* Init stats here in order signal app which stats are supported */
458 c->strength.len = 1; 293 c->strength.len = 1;
459 c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE; 294 c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
460 c->cnr.len = 1; 295 c->cnr.len = 1;
@@ -469,68 +304,53 @@ static int af9033_init(struct dvb_frontend *fe)
469 c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; 304 c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
470 305
471 return 0; 306 return 0;
472
473err: 307err:
474 dev_dbg(&dev->client->dev, "failed=%d\n", ret); 308 dev_dbg(&client->dev, "failed=%d\n", ret);
475
476 return ret; 309 return ret;
477} 310}
478 311
479static int af9033_sleep(struct dvb_frontend *fe) 312static int af9033_sleep(struct dvb_frontend *fe)
480{ 313{
481 struct af9033_dev *dev = fe->demodulator_priv; 314 struct af9033_dev *dev = fe->demodulator_priv;
482 int ret, i; 315 struct i2c_client *client = dev->client;
483 u8 tmp; 316 int ret;
317 unsigned int utmp;
484 318
485 ret = af9033_wr_reg(dev, 0x80004c, 1); 319 dev_dbg(&client->dev, "\n");
486 if (ret < 0)
487 goto err;
488 320
489 ret = af9033_wr_reg(dev, 0x800000, 0); 321 ret = regmap_write(dev->regmap, 0x80004c, 0x01);
490 if (ret < 0) 322 if (ret)
491 goto err; 323 goto err;
492 324 ret = regmap_write(dev->regmap, 0x800000, 0x00);
493 for (i = 100, tmp = 1; i && tmp; i--) { 325 if (ret)
494 ret = af9033_rd_reg(dev, 0x80004c, &tmp);
495 if (ret < 0)
496 goto err;
497
498 usleep_range(200, 10000);
499 }
500
501 dev_dbg(&dev->client->dev, "loop=%d\n", i);
502
503 if (i == 0) {
504 ret = -ETIMEDOUT;
505 goto err; 326 goto err;
506 } 327 ret = regmap_read_poll_timeout(dev->regmap, 0x80004c, utmp, utmp == 0,
507 328 5000, 1000000);
508 ret = af9033_wr_reg_mask(dev, 0x80fb24, 0x08, 0x08); 329 if (ret)
509 if (ret < 0) 330 goto err;
331 ret = regmap_update_bits(dev->regmap, 0x80fb24, 0x08, 0x08);
332 if (ret)
510 goto err; 333 goto err;
511 334
512 /* prevent current leak (?) */ 335 /* Prevent current leak by setting TS interface to parallel mode */
513 if (dev->cfg.ts_mode == AF9033_TS_MODE_SERIAL) { 336 if (dev->cfg.ts_mode == AF9033_TS_MODE_SERIAL) {
514 /* enable parallel TS */ 337 /* Enable parallel TS */
515 ret = af9033_wr_reg_mask(dev, 0x00d917, 0x00, 0x01); 338 ret = regmap_update_bits(dev->regmap, 0x00d917, 0x01, 0x00);
516 if (ret < 0) 339 if (ret)
517 goto err; 340 goto err;
518 341 ret = regmap_update_bits(dev->regmap, 0x00d916, 0x01, 0x01);
519 ret = af9033_wr_reg_mask(dev, 0x00d916, 0x01, 0x01); 342 if (ret)
520 if (ret < 0)
521 goto err; 343 goto err;
522 } 344 }
523 345
524 return 0; 346 return 0;
525
526err: 347err:
527 dev_dbg(&dev->client->dev, "failed=%d\n", ret); 348 dev_dbg(&client->dev, "failed=%d\n", ret);
528
529 return ret; 349 return ret;
530} 350}
531 351
532static int af9033_get_tune_settings(struct dvb_frontend *fe, 352static int af9033_get_tune_settings(struct dvb_frontend *fe,
533 struct dvb_frontend_tune_settings *fesettings) 353 struct dvb_frontend_tune_settings *fesettings)
534{ 354{
535 /* 800 => 2000 because IT9135 v2 is slow to gain lock */ 355 /* 800 => 2000 because IT9135 v2 is slow to gain lock */
536 fesettings->min_delay_ms = 2000; 356 fesettings->min_delay_ms = 2000;
@@ -543,15 +363,17 @@ static int af9033_get_tune_settings(struct dvb_frontend *fe,
543static int af9033_set_frontend(struct dvb_frontend *fe) 363static int af9033_set_frontend(struct dvb_frontend *fe)
544{ 364{
545 struct af9033_dev *dev = fe->demodulator_priv; 365 struct af9033_dev *dev = fe->demodulator_priv;
366 struct i2c_client *client = dev->client;
546 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 367 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
547 int ret, i, spec_inv, sampling_freq; 368 int ret, i;
369 unsigned int utmp, adc_freq;
548 u8 tmp, buf[3], bandwidth_reg_val; 370 u8 tmp, buf[3], bandwidth_reg_val;
549 u32 if_frequency, freq_cw, adc_freq; 371 u32 if_frequency;
550 372
551 dev_dbg(&dev->client->dev, "frequency=%d bandwidth_hz=%d\n", 373 dev_dbg(&client->dev, "frequency=%u bandwidth_hz=%u\n",
552 c->frequency, c->bandwidth_hz); 374 c->frequency, c->bandwidth_hz);
553 375
554 /* check bandwidth */ 376 /* Check bandwidth */
555 switch (c->bandwidth_hz) { 377 switch (c->bandwidth_hz) {
556 case 6000000: 378 case 6000000:
557 bandwidth_reg_val = 0x00; 379 bandwidth_reg_val = 0x00;
@@ -563,105 +385,91 @@ static int af9033_set_frontend(struct dvb_frontend *fe)
563 bandwidth_reg_val = 0x02; 385 bandwidth_reg_val = 0x02;
564 break; 386 break;
565 default: 387 default:
566 dev_dbg(&dev->client->dev, "invalid bandwidth_hz\n"); 388 dev_dbg(&client->dev, "invalid bandwidth_hz\n");
567 ret = -EINVAL; 389 ret = -EINVAL;
568 goto err; 390 goto err;
569 } 391 }
570 392
571 /* program tuner */ 393 /* Program tuner */
572 if (fe->ops.tuner_ops.set_params) 394 if (fe->ops.tuner_ops.set_params)
573 fe->ops.tuner_ops.set_params(fe); 395 fe->ops.tuner_ops.set_params(fe);
574 396
575 /* program CFOE coefficients */ 397 /* Coefficients */
576 if (c->bandwidth_hz != dev->bandwidth_hz) { 398 if (c->bandwidth_hz != dev->bandwidth_hz) {
577 for (i = 0; i < ARRAY_SIZE(coeff_lut); i++) { 399 for (i = 0; i < ARRAY_SIZE(coeff_lut); i++) {
578 if (coeff_lut[i].clock == dev->cfg.clock && 400 if (coeff_lut[i].clock == dev->cfg.clock &&
579 coeff_lut[i].bandwidth_hz == c->bandwidth_hz) { 401 coeff_lut[i].bandwidth_hz == c->bandwidth_hz) {
580 break; 402 break;
581 } 403 }
582 } 404 }
583 if (i == ARRAY_SIZE(coeff_lut)) { 405 if (i == ARRAY_SIZE(coeff_lut)) {
584 dev_err(&dev->client->dev, 406 dev_err(&client->dev,
585 "Couldn't find LUT config for clock=%d\n", 407 "Couldn't find config for clock %u\n",
586 dev->cfg.clock); 408 dev->cfg.clock);
587 ret = -EINVAL; 409 ret = -EINVAL;
588 goto err; 410 goto err;
589 } 411 }
590 412
591 ret = af9033_wr_regs(dev, 0x800001, 413 ret = regmap_bulk_write(dev->regmap, 0x800001, coeff_lut[i].val,
592 coeff_lut[i].val, sizeof(coeff_lut[i].val)); 414 sizeof(coeff_lut[i].val));
415 if (ret)
416 goto err;
593 } 417 }
594 418
595 /* program frequency control */ 419 /* IF frequency control */
596 if (c->bandwidth_hz != dev->bandwidth_hz) { 420 if (c->bandwidth_hz != dev->bandwidth_hz) {
597 spec_inv = dev->cfg.spec_inv ? -1 : 1;
598
599 for (i = 0; i < ARRAY_SIZE(clock_adc_lut); i++) { 421 for (i = 0; i < ARRAY_SIZE(clock_adc_lut); i++) {
600 if (clock_adc_lut[i].clock == dev->cfg.clock) 422 if (clock_adc_lut[i].clock == dev->cfg.clock)
601 break; 423 break;
602 } 424 }
603 if (i == ARRAY_SIZE(clock_adc_lut)) { 425 if (i == ARRAY_SIZE(clock_adc_lut)) {
604 dev_err(&dev->client->dev, 426 dev_err(&client->dev,
605 "Couldn't find ADC clock for clock=%d\n", 427 "Couldn't find ADC clock for clock %u\n",
606 dev->cfg.clock); 428 dev->cfg.clock);
607 ret = -EINVAL; 429 ret = -EINVAL;
608 goto err; 430 goto err;
609 } 431 }
610 adc_freq = clock_adc_lut[i].adc; 432 adc_freq = clock_adc_lut[i].adc;
611 433
612 /* get used IF frequency */ 434 if (dev->cfg.adc_multiplier == AF9033_ADC_MULTIPLIER_2X)
435 adc_freq = 2 * adc_freq;
436
437 /* Get used IF frequency */
613 if (fe->ops.tuner_ops.get_if_frequency) 438 if (fe->ops.tuner_ops.get_if_frequency)
614 fe->ops.tuner_ops.get_if_frequency(fe, &if_frequency); 439 fe->ops.tuner_ops.get_if_frequency(fe, &if_frequency);
615 else 440 else
616 if_frequency = 0; 441 if_frequency = 0;
617 442
618 sampling_freq = if_frequency; 443 utmp = DIV_ROUND_CLOSEST_ULL((u64)if_frequency * 0x800000,
619 444 adc_freq);
620 while (sampling_freq > (adc_freq / 2))
621 sampling_freq -= adc_freq;
622
623 if (sampling_freq >= 0)
624 spec_inv *= -1;
625 else
626 sampling_freq *= -1;
627
628 freq_cw = af9033_div(dev, sampling_freq, adc_freq, 23ul);
629 445
630 if (spec_inv == -1) 446 if (!dev->cfg.spec_inv && if_frequency)
631 freq_cw = 0x800000 - freq_cw; 447 utmp = 0x800000 - utmp;
632 448
633 if (dev->cfg.adc_multiplier == AF9033_ADC_MULTIPLIER_2X) 449 buf[0] = (utmp >> 0) & 0xff;
634 freq_cw /= 2; 450 buf[1] = (utmp >> 8) & 0xff;
635 451 buf[2] = (utmp >> 16) & 0xff;
636 buf[0] = (freq_cw >> 0) & 0xff; 452 ret = regmap_bulk_write(dev->regmap, 0x800029, buf, 3);
637 buf[1] = (freq_cw >> 8) & 0xff; 453 if (ret)
638 buf[2] = (freq_cw >> 16) & 0x7f;
639
640 /* FIXME: there seems to be calculation error here... */
641 if (if_frequency == 0)
642 buf[2] = 0;
643
644 ret = af9033_wr_regs(dev, 0x800029, buf, 3);
645 if (ret < 0)
646 goto err; 454 goto err;
647 455
456 dev_dbg(&client->dev, "if_frequency_cw=%06x\n", utmp);
457
648 dev->bandwidth_hz = c->bandwidth_hz; 458 dev->bandwidth_hz = c->bandwidth_hz;
649 } 459 }
650 460
651 ret = af9033_wr_reg_mask(dev, 0x80f904, bandwidth_reg_val, 0x03); 461 ret = regmap_update_bits(dev->regmap, 0x80f904, 0x03,
652 if (ret < 0) 462 bandwidth_reg_val);
463 if (ret)
653 goto err; 464 goto err;
654 465 ret = regmap_write(dev->regmap, 0x800040, 0x00);
655 ret = af9033_wr_reg(dev, 0x800040, 0x00); 466 if (ret)
656 if (ret < 0)
657 goto err; 467 goto err;
658 468 ret = regmap_write(dev->regmap, 0x800047, 0x00);
659 ret = af9033_wr_reg(dev, 0x800047, 0x00); 469 if (ret)
660 if (ret < 0)
661 goto err; 470 goto err;
662 471 ret = regmap_update_bits(dev->regmap, 0x80f999, 0x01, 0x00);
663 ret = af9033_wr_reg_mask(dev, 0x80f999, 0x00, 0x01); 472 if (ret)
664 if (ret < 0)
665 goto err; 473 goto err;
666 474
667 if (c->frequency <= 230000000) 475 if (c->frequency <= 230000000)
@@ -669,19 +477,17 @@ static int af9033_set_frontend(struct dvb_frontend *fe)
669 else 477 else
670 tmp = 0x01; /* UHF */ 478 tmp = 0x01; /* UHF */
671 479
672 ret = af9033_wr_reg(dev, 0x80004b, tmp); 480 ret = regmap_write(dev->regmap, 0x80004b, tmp);
673 if (ret < 0) 481 if (ret)
674 goto err; 482 goto err;
675 483 /* Reset FSM */
676 ret = af9033_wr_reg(dev, 0x800000, 0x00); 484 ret = regmap_write(dev->regmap, 0x800000, 0x00);
677 if (ret < 0) 485 if (ret)
678 goto err; 486 goto err;
679 487
680 return 0; 488 return 0;
681
682err: 489err:
683 dev_dbg(&dev->client->dev, "failed=%d\n", ret); 490 dev_dbg(&client->dev, "failed=%d\n", ret);
684
685 return ret; 491 return ret;
686} 492}
687 493
@@ -689,14 +495,15 @@ static int af9033_get_frontend(struct dvb_frontend *fe,
689 struct dtv_frontend_properties *c) 495 struct dtv_frontend_properties *c)
690{ 496{
691 struct af9033_dev *dev = fe->demodulator_priv; 497 struct af9033_dev *dev = fe->demodulator_priv;
498 struct i2c_client *client = dev->client;
692 int ret; 499 int ret;
693 u8 buf[8]; 500 u8 buf[8];
694 501
695 dev_dbg(&dev->client->dev, "\n"); 502 dev_dbg(&client->dev, "\n");
696 503
697 /* read all needed registers */ 504 /* Read all needed TPS registers */
698 ret = af9033_rd_regs(dev, 0x80f900, buf, sizeof(buf)); 505 ret = regmap_bulk_read(dev->regmap, 0x80f900, buf, 8);
699 if (ret < 0) 506 if (ret)
700 goto err; 507 goto err;
701 508
702 switch ((buf[0] >> 0) & 3) { 509 switch ((buf[0] >> 0) & 3) {
@@ -805,49 +612,49 @@ static int af9033_get_frontend(struct dvb_frontend *fe,
805 } 612 }
806 613
807 return 0; 614 return 0;
808
809err: 615err:
810 dev_dbg(&dev->client->dev, "failed=%d\n", ret); 616 dev_dbg(&client->dev, "failed=%d\n", ret);
811
812 return ret; 617 return ret;
813} 618}
814 619
815static int af9033_read_status(struct dvb_frontend *fe, enum fe_status *status) 620static int af9033_read_status(struct dvb_frontend *fe, enum fe_status *status)
816{ 621{
817 struct af9033_dev *dev = fe->demodulator_priv; 622 struct af9033_dev *dev = fe->demodulator_priv;
623 struct i2c_client *client = dev->client;
818 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 624 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
819 int ret, i, tmp = 0; 625 int ret, tmp = 0;
820 u8 u8tmp, buf[7]; 626 u8 buf[7];
627 unsigned int utmp, utmp1;
821 628
822 dev_dbg(&dev->client->dev, "\n"); 629 dev_dbg(&client->dev, "\n");
823 630
824 *status = 0; 631 *status = 0;
825 632
826 /* radio channel status, 0=no result, 1=has signal, 2=no signal */ 633 /* Radio channel status: 0=no result, 1=has signal, 2=no signal */
827 ret = af9033_rd_reg(dev, 0x800047, &u8tmp); 634 ret = regmap_read(dev->regmap, 0x800047, &utmp);
828 if (ret < 0) 635 if (ret)
829 goto err; 636 goto err;
830 637
831 /* has signal */ 638 /* Has signal */
832 if (u8tmp == 0x01) 639 if (utmp == 0x01)
833 *status |= FE_HAS_SIGNAL; 640 *status |= FE_HAS_SIGNAL;
834 641
835 if (u8tmp != 0x02) { 642 if (utmp != 0x02) {
836 /* TPS lock */ 643 /* TPS lock */
837 ret = af9033_rd_reg_mask(dev, 0x80f5a9, &u8tmp, 0x01); 644 ret = regmap_read(dev->regmap, 0x80f5a9, &utmp);
838 if (ret < 0) 645 if (ret)
839 goto err; 646 goto err;
840 647
841 if (u8tmp) 648 if ((utmp >> 0) & 0x01)
842 *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER | 649 *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER |
843 FE_HAS_VITERBI; 650 FE_HAS_VITERBI;
844 651
845 /* full lock */ 652 /* Full lock */
846 ret = af9033_rd_reg_mask(dev, 0x80f999, &u8tmp, 0x01); 653 ret = regmap_read(dev->regmap, 0x80f999, &utmp);
847 if (ret < 0) 654 if (ret)
848 goto err; 655 goto err;
849 656
850 if (u8tmp) 657 if ((utmp >> 0) & 0x01)
851 *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER | 658 *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER |
852 FE_HAS_VITERBI | FE_HAS_SYNC | 659 FE_HAS_VITERBI | FE_HAS_SYNC |
853 FE_HAS_LOCK; 660 FE_HAS_LOCK;
@@ -855,18 +662,18 @@ static int af9033_read_status(struct dvb_frontend *fe, enum fe_status *status)
855 662
856 dev->fe_status = *status; 663 dev->fe_status = *status;
857 664
858 /* signal strength */ 665 /* Signal strength */
859 if (dev->fe_status & FE_HAS_SIGNAL) { 666 if (dev->fe_status & FE_HAS_SIGNAL) {
860 if (dev->is_af9035) { 667 if (dev->is_af9035) {
861 ret = af9033_rd_reg(dev, 0x80004a, &u8tmp); 668 ret = regmap_read(dev->regmap, 0x80004a, &utmp);
862 if (ret) 669 if (ret)
863 goto err; 670 goto err;
864 tmp = -u8tmp * 1000; 671 tmp = -utmp * 1000;
865 } else { 672 } else {
866 ret = af9033_rd_reg(dev, 0x8000f7, &u8tmp); 673 ret = regmap_read(dev->regmap, 0x8000f7, &utmp);
867 if (ret) 674 if (ret)
868 goto err; 675 goto err;
869 tmp = (u8tmp - 100) * 1000; 676 tmp = (utmp - 100) * 1000;
870 } 677 }
871 678
872 c->strength.len = 1; 679 c->strength.len = 1;
@@ -879,87 +686,101 @@ static int af9033_read_status(struct dvb_frontend *fe, enum fe_status *status)
879 686
880 /* CNR */ 687 /* CNR */
881 if (dev->fe_status & FE_HAS_VITERBI) { 688 if (dev->fe_status & FE_HAS_VITERBI) {
882 u32 snr_val, snr_lut_size; 689 /* Read raw SNR value */
883 const struct val_snr *snr_lut = NULL; 690 ret = regmap_bulk_read(dev->regmap, 0x80002c, buf, 3);
884
885 /* read value */
886 ret = af9033_rd_regs(dev, 0x80002c, buf, 3);
887 if (ret) 691 if (ret)
888 goto err; 692 goto err;
889 693
890 snr_val = (buf[2] << 16) | (buf[1] << 8) | (buf[0] << 0); 694 utmp1 = buf[2] << 16 | buf[1] << 8 | buf[0] << 0;
891 695
892 /* read superframe number */ 696 /* Read superframe number */
893 ret = af9033_rd_reg(dev, 0x80f78b, &u8tmp); 697 ret = regmap_read(dev->regmap, 0x80f78b, &utmp);
894 if (ret) 698 if (ret)
895 goto err; 699 goto err;
896 700
897 if (u8tmp) 701 if (utmp)
898 snr_val /= u8tmp; 702 utmp1 /= utmp;
899 703
900 /* read current transmission mode */ 704 /* Read current transmission mode */
901 ret = af9033_rd_reg(dev, 0x80f900, &u8tmp); 705 ret = regmap_read(dev->regmap, 0x80f900, &utmp);
902 if (ret) 706 if (ret)
903 goto err; 707 goto err;
904 708
905 switch ((u8tmp >> 0) & 3) { 709 switch ((utmp >> 0) & 3) {
906 case 0: 710 case 0:
907 snr_val *= 4; 711 /* 2k */
712 utmp1 *= 4;
908 break; 713 break;
909 case 1: 714 case 1:
910 snr_val *= 1; 715 /* 8k */
716 utmp1 *= 1;
911 break; 717 break;
912 case 2: 718 case 2:
913 snr_val *= 2; 719 /* 4k */
720 utmp1 *= 2;
914 break; 721 break;
915 default: 722 default:
916 snr_val *= 0; 723 utmp1 *= 0;
917 break; 724 break;
918 } 725 }
919 726
920 /* read current modulation */ 727 /* Read current modulation */
921 ret = af9033_rd_reg(dev, 0x80f903, &u8tmp); 728 ret = regmap_read(dev->regmap, 0x80f903, &utmp);
922 if (ret) 729 if (ret)
923 goto err; 730 goto err;
924 731
925 switch ((u8tmp >> 0) & 3) { 732 switch ((utmp >> 0) & 3) {
926 case 0: 733 case 0:
927 snr_lut_size = ARRAY_SIZE(qpsk_snr_lut); 734 /*
928 snr_lut = qpsk_snr_lut; 735 * QPSK
736 * CNR[dB] 13 * -log10((1690000 - value) / value) + 2.6
737 * value [653799, 1689999], 2.6 / 13 = 3355443
738 */
739 utmp1 = clamp(utmp1, 653799U, 1689999U);
740 utmp1 = ((u64)(intlog10(utmp1)
741 - intlog10(1690000 - utmp1)
742 + 3355443) * 13 * 1000) >> 24;
929 break; 743 break;
930 case 1: 744 case 1:
931 snr_lut_size = ARRAY_SIZE(qam16_snr_lut); 745 /*
932 snr_lut = qam16_snr_lut; 746 * QAM-16
747 * CNR[dB] 6 * log10((value - 370000) / (828000 - value)) + 15.7
748 * value [371105, 827999], 15.7 / 6 = 43900382
749 */
750 utmp1 = clamp(utmp1, 371105U, 827999U);
751 utmp1 = ((u64)(intlog10(utmp1 - 370000)
752 - intlog10(828000 - utmp1)
753 + 43900382) * 6 * 1000) >> 24;
933 break; 754 break;
934 case 2: 755 case 2:
935 snr_lut_size = ARRAY_SIZE(qam64_snr_lut); 756 /*
936 snr_lut = qam64_snr_lut; 757 * QAM-64
758 * CNR[dB] 8 * log10((value - 193000) / (425000 - value)) + 23.8
759 * value [193246, 424999], 23.8 / 8 = 49912218
760 */
761 utmp1 = clamp(utmp1, 193246U, 424999U);
762 utmp1 = ((u64)(intlog10(utmp1 - 193000)
763 - intlog10(425000 - utmp1)
764 + 49912218) * 8 * 1000) >> 24;
937 break; 765 break;
938 default: 766 default:
939 snr_lut_size = 0; 767 utmp1 = 0;
940 tmp = 0;
941 break; 768 break;
942 } 769 }
943 770
944 for (i = 0; i < snr_lut_size; i++) { 771 dev_dbg(&client->dev, "cnr=%u\n", utmp1);
945 tmp = snr_lut[i].snr * 1000;
946 if (snr_val < snr_lut[i].val)
947 break;
948 }
949 772
950 c->cnr.len = 1;
951 c->cnr.stat[0].scale = FE_SCALE_DECIBEL; 773 c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
952 c->cnr.stat[0].svalue = tmp; 774 c->cnr.stat[0].svalue = utmp1;
953 } else { 775 } else {
954 c->cnr.len = 1;
955 c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; 776 c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
956 } 777 }
957 778
958 /* UCB/PER/BER */ 779 /* UCB/PER/BER */
959 if (dev->fe_status & FE_HAS_LOCK) { 780 if (dev->fe_status & FE_HAS_LOCK) {
960 /* outer FEC, 204 byte packets */ 781 /* Outer FEC, 204 byte packets */
961 u16 abort_packet_count, rsd_packet_count; 782 u16 abort_packet_count, rsd_packet_count;
962 /* inner FEC, bits */ 783 /* Inner FEC, bits */
963 u32 rsd_bit_err_count; 784 u32 rsd_bit_err_count;
964 785
965 /* 786 /*
@@ -967,7 +788,7 @@ static int af9033_read_status(struct dvb_frontend *fe, enum fe_status *status)
967 * (rsd_packet_count). Maybe it should be increased? 788 * (rsd_packet_count). Maybe it should be increased?
968 */ 789 */
969 790
970 ret = af9033_rd_regs(dev, 0x800032, buf, 7); 791 ret = regmap_bulk_read(dev->regmap, 0x800032, buf, 7);
971 if (ret) 792 if (ret)
972 goto err; 793 goto err;
973 794
@@ -998,21 +819,22 @@ static int af9033_read_status(struct dvb_frontend *fe, enum fe_status *status)
998 } 819 }
999 820
1000 return 0; 821 return 0;
1001
1002err: 822err:
1003 dev_dbg(&dev->client->dev, "failed=%d\n", ret); 823 dev_dbg(&client->dev, "failed=%d\n", ret);
1004
1005 return ret; 824 return ret;
1006} 825}
1007 826
1008static int af9033_read_snr(struct dvb_frontend *fe, u16 *snr) 827static int af9033_read_snr(struct dvb_frontend *fe, u16 *snr)
1009{ 828{
1010 struct af9033_dev *dev = fe->demodulator_priv; 829 struct af9033_dev *dev = fe->demodulator_priv;
830 struct i2c_client *client = dev->client;
1011 struct dtv_frontend_properties *c = &dev->fe.dtv_property_cache; 831 struct dtv_frontend_properties *c = &dev->fe.dtv_property_cache;
1012 int ret; 832 int ret;
1013 u8 u8tmp; 833 unsigned int utmp;
834
835 dev_dbg(&client->dev, "\n");
1014 836
1015 /* use DVBv5 CNR */ 837 /* Use DVBv5 CNR */
1016 if (c->cnr.stat[0].scale == FE_SCALE_DECIBEL) { 838 if (c->cnr.stat[0].scale == FE_SCALE_DECIBEL) {
1017 /* Return 0.1 dB for AF9030 and 0-0xffff for IT9130. */ 839 /* Return 0.1 dB for AF9030 and 0-0xffff for IT9130. */
1018 if (dev->is_af9035) { 840 if (dev->is_af9035) {
@@ -1022,13 +844,13 @@ static int af9033_read_snr(struct dvb_frontend *fe, u16 *snr)
1022 /* 1000x => 1x (1 dB) */ 844 /* 1000x => 1x (1 dB) */
1023 *snr = div_s64(c->cnr.stat[0].svalue, 1000); 845 *snr = div_s64(c->cnr.stat[0].svalue, 1000);
1024 846
1025 /* read current modulation */ 847 /* Read current modulation */
1026 ret = af9033_rd_reg(dev, 0x80f903, &u8tmp); 848 ret = regmap_read(dev->regmap, 0x80f903, &utmp);
1027 if (ret) 849 if (ret)
1028 goto err; 850 goto err;
1029 851
1030 /* scale value to 0x0000-0xffff */ 852 /* scale value to 0x0000-0xffff */
1031 switch ((u8tmp >> 0) & 3) { 853 switch ((utmp >> 0) & 3) {
1032 case 0: 854 case 0:
1033 *snr = *snr * 0xffff / 23; 855 *snr = *snr * 0xffff / 23;
1034 break; 856 break;
@@ -1047,35 +869,37 @@ static int af9033_read_snr(struct dvb_frontend *fe, u16 *snr)
1047 } 869 }
1048 870
1049 return 0; 871 return 0;
1050
1051err: 872err:
1052 dev_dbg(&dev->client->dev, "failed=%d\n", ret); 873 dev_dbg(&client->dev, "failed=%d\n", ret);
1053
1054 return ret; 874 return ret;
1055} 875}
1056 876
1057static int af9033_read_signal_strength(struct dvb_frontend *fe, u16 *strength) 877static int af9033_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
1058{ 878{
1059 struct af9033_dev *dev = fe->demodulator_priv; 879 struct af9033_dev *dev = fe->demodulator_priv;
880 struct i2c_client *client = dev->client;
1060 struct dtv_frontend_properties *c = &dev->fe.dtv_property_cache; 881 struct dtv_frontend_properties *c = &dev->fe.dtv_property_cache;
1061 int ret, tmp, power_real; 882 int ret, tmp, power_real;
1062 u8 u8tmp, gain_offset, buf[7]; 883 unsigned int utmp;
884 u8 gain_offset, buf[7];
885
886 dev_dbg(&client->dev, "\n");
1063 887
1064 if (dev->is_af9035) { 888 if (dev->is_af9035) {
1065 /* read signal strength of 0-100 scale */ 889 /* Read signal strength of 0-100 scale */
1066 ret = af9033_rd_reg(dev, 0x800048, &u8tmp); 890 ret = regmap_read(dev->regmap, 0x800048, &utmp);
1067 if (ret < 0) 891 if (ret)
1068 goto err; 892 goto err;
1069 893
1070 /* scale value to 0x0000-0xffff */ 894 /* Scale value to 0x0000-0xffff */
1071 *strength = u8tmp * 0xffff / 100; 895 *strength = utmp * 0xffff / 100;
1072 } else { 896 } else {
1073 ret = af9033_rd_reg(dev, 0x8000f7, &u8tmp); 897 ret = regmap_read(dev->regmap, 0x8000f7, &utmp);
1074 if (ret < 0) 898 if (ret)
1075 goto err; 899 goto err;
1076 900
1077 ret = af9033_rd_regs(dev, 0x80f900, buf, 7); 901 ret = regmap_bulk_read(dev->regmap, 0x80f900, buf, 7);
1078 if (ret < 0) 902 if (ret)
1079 goto err; 903 goto err;
1080 904
1081 if (c->frequency <= 300000000) 905 if (c->frequency <= 300000000)
@@ -1083,7 +907,7 @@ static int af9033_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
1083 else 907 else
1084 gain_offset = 4; /* UHF */ 908 gain_offset = 4; /* UHF */
1085 909
1086 power_real = (u8tmp - 100 - gain_offset) - 910 power_real = (utmp - 100 - gain_offset) -
1087 power_reference[((buf[3] >> 0) & 3)][((buf[6] >> 0) & 7)]; 911 power_reference[((buf[3] >> 0) & 3)][((buf[6] >> 0) & 7)];
1088 912
1089 if (power_real < -15) 913 if (power_real < -15)
@@ -1097,15 +921,13 @@ static int af9033_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
1097 else 921 else
1098 tmp = 100; 922 tmp = 100;
1099 923
1100 /* scale value to 0x0000-0xffff */ 924 /* Scale value to 0x0000-0xffff */
1101 *strength = tmp * 0xffff / 100; 925 *strength = tmp * 0xffff / 100;
1102 } 926 }
1103 927
1104 return 0; 928 return 0;
1105
1106err: 929err:
1107 dev_dbg(&dev->client->dev, "failed=%d\n", ret); 930 dev_dbg(&client->dev, "failed=%d\n", ret);
1108
1109 return ret; 931 return ret;
1110} 932}
1111 933
@@ -1124,82 +946,78 @@ static int af9033_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
1124 struct af9033_dev *dev = fe->demodulator_priv; 946 struct af9033_dev *dev = fe->demodulator_priv;
1125 947
1126 *ucblocks = dev->error_block_count; 948 *ucblocks = dev->error_block_count;
949
1127 return 0; 950 return 0;
1128} 951}
1129 952
1130static int af9033_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) 953static int af9033_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
1131{ 954{
1132 struct af9033_dev *dev = fe->demodulator_priv; 955 struct af9033_dev *dev = fe->demodulator_priv;
956 struct i2c_client *client = dev->client;
1133 int ret; 957 int ret;
1134 958
1135 dev_dbg(&dev->client->dev, "enable=%d\n", enable); 959 dev_dbg(&client->dev, "enable=%d\n", enable);
1136 960
1137 ret = af9033_wr_reg_mask(dev, 0x00fa04, enable, 0x01); 961 ret = regmap_update_bits(dev->regmap, 0x00fa04, 0x01, enable);
1138 if (ret < 0) 962 if (ret)
1139 goto err; 963 goto err;
1140 964
1141 return 0; 965 return 0;
1142
1143err: 966err:
1144 dev_dbg(&dev->client->dev, "failed=%d\n", ret); 967 dev_dbg(&client->dev, "failed=%d\n", ret);
1145
1146 return ret; 968 return ret;
1147} 969}
1148 970
1149static int af9033_pid_filter_ctrl(struct dvb_frontend *fe, int onoff) 971static int af9033_pid_filter_ctrl(struct dvb_frontend *fe, int onoff)
1150{ 972{
1151 struct af9033_dev *dev = fe->demodulator_priv; 973 struct af9033_dev *dev = fe->demodulator_priv;
974 struct i2c_client *client = dev->client;
1152 int ret; 975 int ret;
1153 976
1154 dev_dbg(&dev->client->dev, "onoff=%d\n", onoff); 977 dev_dbg(&client->dev, "onoff=%d\n", onoff);
1155 978
1156 ret = af9033_wr_reg_mask(dev, 0x80f993, onoff, 0x01); 979 ret = regmap_update_bits(dev->regmap, 0x80f993, 0x01, onoff);
1157 if (ret < 0) 980 if (ret)
1158 goto err; 981 goto err;
1159 982
1160 return 0; 983 return 0;
1161
1162err: 984err:
1163 dev_dbg(&dev->client->dev, "failed=%d\n", ret); 985 dev_dbg(&client->dev, "failed=%d\n", ret);
1164
1165 return ret; 986 return ret;
1166} 987}
1167 988
1168static int af9033_pid_filter(struct dvb_frontend *fe, int index, u16 pid, 989static int af9033_pid_filter(struct dvb_frontend *fe, int index, u16 pid,
1169 int onoff) 990 int onoff)
1170{ 991{
1171 struct af9033_dev *dev = fe->demodulator_priv; 992 struct af9033_dev *dev = fe->demodulator_priv;
993 struct i2c_client *client = dev->client;
1172 int ret; 994 int ret;
1173 u8 wbuf[2] = {(pid >> 0) & 0xff, (pid >> 8) & 0xff}; 995 u8 wbuf[2] = {(pid >> 0) & 0xff, (pid >> 8) & 0xff};
1174 996
1175 dev_dbg(&dev->client->dev, "index=%d pid=%04x onoff=%d\n", 997 dev_dbg(&client->dev, "index=%d pid=%04x onoff=%d\n",
1176 index, pid, onoff); 998 index, pid, onoff);
1177 999
1178 if (pid > 0x1fff) 1000 if (pid > 0x1fff)
1179 return 0; 1001 return 0;
1180 1002
1181 ret = af9033_wr_regs(dev, 0x80f996, wbuf, 2); 1003 ret = regmap_bulk_write(dev->regmap, 0x80f996, wbuf, 2);
1182 if (ret < 0) 1004 if (ret)
1183 goto err; 1005 goto err;
1184 1006 ret = regmap_write(dev->regmap, 0x80f994, onoff);
1185 ret = af9033_wr_reg(dev, 0x80f994, onoff); 1007 if (ret)
1186 if (ret < 0)
1187 goto err; 1008 goto err;
1188 1009 ret = regmap_write(dev->regmap, 0x80f995, index);
1189 ret = af9033_wr_reg(dev, 0x80f995, index); 1010 if (ret)
1190 if (ret < 0)
1191 goto err; 1011 goto err;
1192 1012
1193 return 0; 1013 return 0;
1194
1195err: 1014err:
1196 dev_dbg(&dev->client->dev, "failed=%d\n", ret); 1015 dev_dbg(&client->dev, "failed=%d\n", ret);
1197
1198 return ret; 1016 return ret;
1199} 1017}
1200 1018
1201static const struct dvb_frontend_ops af9033_ops = { 1019static const struct dvb_frontend_ops af9033_ops = {
1202 .delsys = { SYS_DVBT }, 1020 .delsys = {SYS_DVBT},
1203 .info = { 1021 .info = {
1204 .name = "Afatech AF9033 (DVB-T)", 1022 .name = "Afatech AF9033 (DVB-T)",
1205 .frequency_min = 174000000, 1023 .frequency_min = 174000000,
@@ -1240,35 +1058,57 @@ static const struct dvb_frontend_ops af9033_ops = {
1240}; 1058};
1241 1059
1242static int af9033_probe(struct i2c_client *client, 1060static int af9033_probe(struct i2c_client *client,
1243 const struct i2c_device_id *id) 1061 const struct i2c_device_id *id)
1244{ 1062{
1245 struct af9033_config *cfg = client->dev.platform_data; 1063 struct af9033_config *cfg = client->dev.platform_data;
1246 struct af9033_dev *dev; 1064 struct af9033_dev *dev;
1247 int ret; 1065 int ret;
1248 u8 buf[8]; 1066 u8 buf[8];
1249 u32 reg; 1067 u32 reg;
1068 static const struct regmap_config regmap_config = {
1069 .reg_bits = 24,
1070 .val_bits = 8,
1071 };
1250 1072
1251 /* allocate memory for the internal state */ 1073 /* Allocate memory for the internal state */
1252 dev = kzalloc(sizeof(struct af9033_dev), GFP_KERNEL); 1074 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1253 if (dev == NULL) { 1075 if (!dev) {
1254 ret = -ENOMEM; 1076 ret = -ENOMEM;
1255 dev_err(&client->dev, "Could not allocate memory for state\n");
1256 goto err; 1077 goto err;
1257 } 1078 }
1258 1079
1259 /* setup the state */ 1080 /* Setup the state */
1260 dev->client = client; 1081 dev->client = client;
1261 memcpy(&dev->cfg, cfg, sizeof(struct af9033_config)); 1082 memcpy(&dev->cfg, cfg, sizeof(dev->cfg));
1083 switch (dev->cfg.ts_mode) {
1084 case AF9033_TS_MODE_PARALLEL:
1085 dev->ts_mode_parallel = true;
1086 break;
1087 case AF9033_TS_MODE_SERIAL:
1088 dev->ts_mode_serial = true;
1089 break;
1090 case AF9033_TS_MODE_USB:
1091 /* USB mode for AF9035 */
1092 default:
1093 break;
1094 }
1262 1095
1263 if (dev->cfg.clock != 12000000) { 1096 if (dev->cfg.clock != 12000000) {
1264 ret = -ENODEV; 1097 ret = -ENODEV;
1265 dev_err(&dev->client->dev, 1098 dev_err(&client->dev,
1266 "unsupported clock %d Hz, only 12000000 Hz is supported currently\n", 1099 "Unsupported clock %u Hz. Only 12000000 Hz is supported currently\n",
1267 dev->cfg.clock); 1100 dev->cfg.clock);
1101 goto err_kfree;
1102 }
1103
1104 /* Create regmap */
1105 dev->regmap = regmap_init_i2c(client, &regmap_config);
1106 if (IS_ERR(dev->regmap)) {
1107 ret = PTR_ERR(dev->regmap);
1268 goto err_kfree; 1108 goto err_kfree;
1269 } 1109 }
1270 1110
1271 /* firmware version */ 1111 /* Firmware version */
1272 switch (dev->cfg.tuner) { 1112 switch (dev->cfg.tuner) {
1273 case AF9033_TUNER_IT9135_38: 1113 case AF9033_TUNER_IT9135_38:
1274 case AF9033_TUNER_IT9135_51: 1114 case AF9033_TUNER_IT9135_51:
@@ -1285,20 +1125,19 @@ static int af9033_probe(struct i2c_client *client,
1285 break; 1125 break;
1286 } 1126 }
1287 1127
1288 ret = af9033_rd_regs(dev, reg, &buf[0], 4); 1128 ret = regmap_bulk_read(dev->regmap, reg, &buf[0], 4);
1289 if (ret < 0) 1129 if (ret)
1290 goto err_kfree; 1130 goto err_regmap_exit;
1291 1131 ret = regmap_bulk_read(dev->regmap, 0x804191, &buf[4], 4);
1292 ret = af9033_rd_regs(dev, 0x804191, &buf[4], 4); 1132 if (ret)
1293 if (ret < 0) 1133 goto err_regmap_exit;
1294 goto err_kfree;
1295 1134
1296 dev_info(&dev->client->dev, 1135 dev_info(&client->dev,
1297 "firmware version: LINK %d.%d.%d.%d - OFDM %d.%d.%d.%d\n", 1136 "firmware version: LINK %d.%d.%d.%d - OFDM %d.%d.%d.%d\n",
1298 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], 1137 buf[0], buf[1], buf[2], buf[3],
1299 buf[7]); 1138 buf[4], buf[5], buf[6], buf[7]);
1300 1139
1301 /* sleep */ 1140 /* Sleep as chip seems to be partly active by default */
1302 switch (dev->cfg.tuner) { 1141 switch (dev->cfg.tuner) {
1303 case AF9033_TUNER_IT9135_38: 1142 case AF9033_TUNER_IT9135_38:
1304 case AF9033_TUNER_IT9135_51: 1143 case AF9033_TUNER_IT9135_51:
@@ -1309,41 +1148,30 @@ static int af9033_probe(struct i2c_client *client,
1309 /* IT9135 did not like to sleep at that early */ 1148 /* IT9135 did not like to sleep at that early */
1310 break; 1149 break;
1311 default: 1150 default:
1312 ret = af9033_wr_reg(dev, 0x80004c, 1); 1151 ret = regmap_write(dev->regmap, 0x80004c, 0x01);
1313 if (ret < 0) 1152 if (ret)
1314 goto err_kfree; 1153 goto err_regmap_exit;
1315 1154 ret = regmap_write(dev->regmap, 0x800000, 0x00);
1316 ret = af9033_wr_reg(dev, 0x800000, 0); 1155 if (ret)
1317 if (ret < 0) 1156 goto err_regmap_exit;
1318 goto err_kfree;
1319 }
1320
1321 /* configure internal TS mode */
1322 switch (dev->cfg.ts_mode) {
1323 case AF9033_TS_MODE_PARALLEL:
1324 dev->ts_mode_parallel = true;
1325 break;
1326 case AF9033_TS_MODE_SERIAL:
1327 dev->ts_mode_serial = true;
1328 break;
1329 case AF9033_TS_MODE_USB:
1330 /* usb mode for AF9035 */
1331 default:
1332 break;
1333 } 1157 }
1334 1158
1335 /* create dvb_frontend */ 1159 /* Create dvb frontend */
1336 memcpy(&dev->fe.ops, &af9033_ops, sizeof(struct dvb_frontend_ops)); 1160 memcpy(&dev->fe.ops, &af9033_ops, sizeof(dev->fe.ops));
1337 dev->fe.demodulator_priv = dev; 1161 dev->fe.demodulator_priv = dev;
1338 *cfg->fe = &dev->fe; 1162 *cfg->fe = &dev->fe;
1339 if (cfg->ops) { 1163 if (cfg->ops) {
1340 cfg->ops->pid_filter = af9033_pid_filter; 1164 cfg->ops->pid_filter = af9033_pid_filter;
1341 cfg->ops->pid_filter_ctrl = af9033_pid_filter_ctrl; 1165 cfg->ops->pid_filter_ctrl = af9033_pid_filter_ctrl;
1342 } 1166 }
1167 cfg->regmap = dev->regmap;
1343 i2c_set_clientdata(client, dev); 1168 i2c_set_clientdata(client, dev);
1344 1169
1345 dev_info(&dev->client->dev, "Afatech AF9033 successfully attached\n"); 1170 dev_info(&client->dev, "Afatech AF9033 successfully attached\n");
1171
1346 return 0; 1172 return 0;
1173err_regmap_exit:
1174 regmap_exit(dev->regmap);
1347err_kfree: 1175err_kfree:
1348 kfree(dev); 1176 kfree(dev);
1349err: 1177err:
@@ -1355,10 +1183,9 @@ static int af9033_remove(struct i2c_client *client)
1355{ 1183{
1356 struct af9033_dev *dev = i2c_get_clientdata(client); 1184 struct af9033_dev *dev = i2c_get_clientdata(client);
1357 1185
1358 dev_dbg(&dev->client->dev, "\n"); 1186 dev_dbg(&client->dev, "\n");
1359 1187
1360 dev->fe.ops.release = NULL; 1188 regmap_exit(dev->regmap);
1361 dev->fe.demodulator_priv = NULL;
1362 kfree(dev); 1189 kfree(dev);
1363 1190
1364 return 0; 1191 return 0;
diff --git a/drivers/media/dvb-frontends/af9033.h b/drivers/media/dvb-frontends/af9033.h
index 5b83e4f96297..8193f9805c4f 100644
--- a/drivers/media/dvb-frontends/af9033.h
+++ b/drivers/media/dvb-frontends/af9033.h
@@ -13,18 +13,13 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */ 16 */
21 17
22#ifndef AF9033_H 18#ifndef AF9033_H
23#define AF9033_H 19#define AF9033_H
24 20
25/* 21/*
26 * I2C address (TODO: are these in 8-bit format?) 22 * I2C address: 0x1c, 0x1d, 0x1e, 0x1f
27 * 0x38, 0x3a, 0x3c, 0x3e
28 */ 23 */
29struct af9033_config { 24struct af9033_config {
30 /* 25 /*
@@ -88,6 +83,12 @@ struct af9033_config {
88 * returned by that driver 83 * returned by that driver
89 */ 84 */
90 struct dvb_frontend **fe; 85 struct dvb_frontend **fe;
86
87 /*
88 * regmap for IT913x integrated tuner driver
89 * returned by that driver
90 */
91 struct regmap *regmap;
91}; 92};
92 93
93struct af9033_ops { 94struct af9033_ops {
diff --git a/drivers/media/dvb-frontends/af9033_priv.h b/drivers/media/dvb-frontends/af9033_priv.h
index 8e23275148ed..8799cda1ae14 100644
--- a/drivers/media/dvb-frontends/af9033_priv.h
+++ b/drivers/media/dvb-frontends/af9033_priv.h
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */ 16 */
21 17
22#ifndef AF9033_PRIV_H 18#ifndef AF9033_PRIV_H
@@ -25,6 +21,9 @@
25#include "dvb_frontend.h" 21#include "dvb_frontend.h"
26#include "af9033.h" 22#include "af9033.h"
27#include <linux/math64.h> 23#include <linux/math64.h>
24#include <linux/regmap.h>
25#include <linux/kernel.h>
26#include "dvb_math.h"
28 27
29struct reg_val { 28struct reg_val {
30 u32 reg; 29 u32 reg;
@@ -68,7 +67,7 @@ static const struct clock_adc clock_adc_lut[] = {
68 { 12000000, 20250000 }, 67 { 12000000, 20250000 },
69}; 68};
70 69
71/* pre-calculated coeff lookup table */ 70/* Pre-calculated coeff lookup table */
72static const struct coeff coeff_lut[] = { 71static const struct coeff coeff_lut[] = {
73 /* 12.000 MHz */ 72 /* 12.000 MHz */
74 { 12000000, 8000000, { 73 { 12000000, 8000000, {
@@ -91,102 +90,9 @@ static const struct coeff coeff_lut[] = {
91 }, 90 },
92}; 91};
93 92
94/* QPSK SNR lookup table */ 93/*
95static const struct val_snr qpsk_snr_lut[] = { 94 * Afatech AF9033 demod init
96 { 0x0b4771, 0 }, 95 */
97 { 0x0c1aed, 1 },
98 { 0x0d0d27, 2 },
99 { 0x0e4d19, 3 },
100 { 0x0e5da8, 4 },
101 { 0x107097, 5 },
102 { 0x116975, 6 },
103 { 0x1252d9, 7 },
104 { 0x131fa4, 8 },
105 { 0x13d5e1, 9 },
106 { 0x148e53, 10 },
107 { 0x15358b, 11 },
108 { 0x15dd29, 12 },
109 { 0x168112, 13 },
110 { 0x170b61, 14 },
111 { 0x17a532, 15 },
112 { 0x180f94, 16 },
113 { 0x186ed2, 17 },
114 { 0x18b271, 18 },
115 { 0x18e118, 19 },
116 { 0x18ff4b, 20 },
117 { 0x190af1, 21 },
118 { 0x191451, 22 },
119 { 0xffffff, 23 },
120};
121
122/* QAM16 SNR lookup table */
123static const struct val_snr qam16_snr_lut[] = {
124 { 0x04f0d5, 0 },
125 { 0x05387a, 1 },
126 { 0x0573a4, 2 },
127 { 0x05a99e, 3 },
128 { 0x05cc80, 4 },
129 { 0x05eb62, 5 },
130 { 0x05fecf, 6 },
131 { 0x060b80, 7 },
132 { 0x062501, 8 },
133 { 0x064865, 9 },
134 { 0x069604, 10 },
135 { 0x06f356, 11 },
136 { 0x07706a, 12 },
137 { 0x0804d3, 13 },
138 { 0x089d1a, 14 },
139 { 0x093e3d, 15 },
140 { 0x09e35d, 16 },
141 { 0x0a7c3c, 17 },
142 { 0x0afaf8, 18 },
143 { 0x0b719d, 19 },
144 { 0x0bda6a, 20 },
145 { 0x0c0c75, 21 },
146 { 0x0c3f7d, 22 },
147 { 0x0c5e62, 23 },
148 { 0x0c6c31, 24 },
149 { 0x0c7925, 25 },
150 { 0xffffff, 26 },
151};
152
153/* QAM64 SNR lookup table */
154static const struct val_snr qam64_snr_lut[] = {
155 { 0x0256d0, 0 },
156 { 0x027a65, 1 },
157 { 0x029873, 2 },
158 { 0x02b7fe, 3 },
159 { 0x02cf1e, 4 },
160 { 0x02e234, 5 },
161 { 0x02f409, 6 },
162 { 0x030046, 7 },
163 { 0x030844, 8 },
164 { 0x030a02, 9 },
165 { 0x030cde, 10 },
166 { 0x031031, 11 },
167 { 0x03144c, 12 },
168 { 0x0315dd, 13 },
169 { 0x031920, 14 },
170 { 0x0322d0, 15 },
171 { 0x0339fc, 16 },
172 { 0x0364a1, 17 },
173 { 0x038bcc, 18 },
174 { 0x03c7d3, 19 },
175 { 0x0408cc, 20 },
176 { 0x043bed, 21 },
177 { 0x048061, 22 },
178 { 0x04be95, 23 },
179 { 0x04fa7d, 24 },
180 { 0x052405, 25 },
181 { 0x05570d, 26 },
182 { 0x059feb, 27 },
183 { 0x05bf38, 28 },
184 { 0x05f78f, 29 },
185 { 0x0612c3, 30 },
186 { 0x0626be, 31 },
187 { 0xffffff, 32 },
188};
189
190static const struct reg_val ofsm_init[] = { 96static const struct reg_val ofsm_init[] = {
191 { 0x800051, 0x01 }, 97 { 0x800051, 0x01 },
192 { 0x800070, 0x0a }, 98 { 0x800070, 0x0a },
@@ -298,8 +204,10 @@ static const struct reg_val ofsm_init[] = {
298 { 0x80fd8b, 0x00 }, 204 { 0x80fd8b, 0x00 },
299}; 205};
300 206
301/* Infineon TUA 9001 tuner init 207/*
302 AF9033_TUNER_TUA9001 = 0x27 */ 208 * Infineon TUA 9001 tuner init
209 * AF9033_TUNER_TUA9001 = 0x27
210 */
303static const struct reg_val tuner_init_tua9001[] = { 211static const struct reg_val tuner_init_tua9001[] = {
304 { 0x800046, 0x27 }, 212 { 0x800046, 0x27 },
305 { 0x800057, 0x00 }, 213 { 0x800057, 0x00 },
@@ -340,8 +248,10 @@ static const struct reg_val tuner_init_tua9001[] = {
340 { 0x80f1e6, 0x00 }, 248 { 0x80f1e6, 0x00 },
341}; 249};
342 250
343/* Fitipower fc0011 tuner init 251/*
344 AF9033_TUNER_FC0011 = 0x28 */ 252 * Fitipower FC0011 tuner init
253 * AF9033_TUNER_FC0011 = 0x28
254 */
345static const struct reg_val tuner_init_fc0011[] = { 255static const struct reg_val tuner_init_fc0011[] = {
346 { 0x800046, 0x28 }, 256 { 0x800046, 0x28 },
347 { 0x800057, 0x00 }, 257 { 0x800057, 0x00 },
@@ -401,8 +311,10 @@ static const struct reg_val tuner_init_fc0011[] = {
401 { 0x80f1e6, 0x00 }, 311 { 0x80f1e6, 0x00 },
402}; 312};
403 313
404/* Fitipower FC0012 tuner init 314/*
405 AF9033_TUNER_FC0012 = 0x2e */ 315 * Fitipower FC0012 tuner init
316 * AF9033_TUNER_FC0012 = 0x2e
317 */
406static const struct reg_val tuner_init_fc0012[] = { 318static const struct reg_val tuner_init_fc0012[] = {
407 { 0x800046, 0x2e }, 319 { 0x800046, 0x2e },
408 { 0x800057, 0x00 }, 320 { 0x800057, 0x00 },
@@ -444,8 +356,10 @@ static const struct reg_val tuner_init_fc0012[] = {
444 { 0x80f1e6, 0x00 }, 356 { 0x80f1e6, 0x00 },
445}; 357};
446 358
447/* MaxLinear MxL5007T tuner init 359/*
448 AF9033_TUNER_MXL5007T = 0xa0 */ 360 * MaxLinear MxL5007T tuner init
361 * AF9033_TUNER_MXL5007T = 0xa0
362 */
449static const struct reg_val tuner_init_mxl5007t[] = { 363static const struct reg_val tuner_init_mxl5007t[] = {
450 { 0x800046, 0x1b }, 364 { 0x800046, 0x1b },
451 { 0x800057, 0x01 }, 365 { 0x800057, 0x01 },
@@ -479,8 +393,10 @@ static const struct reg_val tuner_init_mxl5007t[] = {
479 { 0x80f1e6, 0x00 }, 393 { 0x80f1e6, 0x00 },
480}; 394};
481 395
482/* NXP TDA 18218HN tuner init 396/*
483 AF9033_TUNER_TDA18218 = 0xa1 */ 397 * NXP TDA18218HN tuner init
398 * AF9033_TUNER_TDA18218 = 0xa1
399 */
484static const struct reg_val tuner_init_tda18218[] = { 400static const struct reg_val tuner_init_tda18218[] = {
485 {0x800046, 0xa1}, 401 {0x800046, 0xa1},
486 {0x800057, 0x01}, 402 {0x800057, 0x01},
@@ -513,7 +429,10 @@ static const struct reg_val tuner_init_tda18218[] = {
513 {0x80f1e6, 0x00}, 429 {0x80f1e6, 0x00},
514}; 430};
515 431
516/* FCI FC2580 tuner init */ 432/*
433 * FCI FC2580 tuner init
434 * AF9033_TUNER_FC2580 = 0x32
435 */
517static const struct reg_val tuner_init_fc2580[] = { 436static const struct reg_val tuner_init_fc2580[] = {
518 { 0x800046, 0x32 }, 437 { 0x800046, 0x32 },
519 { 0x800057, 0x01 }, 438 { 0x800057, 0x01 },
@@ -551,6 +470,9 @@ static const struct reg_val tuner_init_fc2580[] = {
551 { 0x80f1e6, 0x01 }, 470 { 0x80f1e6, 0x01 },
552}; 471};
553 472
473/*
474 * IT9133 AX demod init
475 */
554static const struct reg_val ofsm_init_it9135_v1[] = { 476static const struct reg_val ofsm_init_it9135_v1[] = {
555 { 0x800051, 0x01 }, 477 { 0x800051, 0x01 },
556 { 0x800070, 0x0a }, 478 { 0x800070, 0x0a },
@@ -662,8 +584,10 @@ static const struct reg_val ofsm_init_it9135_v1[] = {
662 { 0x80fd8b, 0x00 }, 584 { 0x80fd8b, 0x00 },
663}; 585};
664 586
665/* ITE Tech IT9135 Omega tuner init 587/*
666 AF9033_TUNER_IT9135_38 = 0x38 */ 588 * ITE Tech IT9133 AX Omega tuner init
589 * AF9033_TUNER_IT9135_38 = 0x38
590 */
667static const struct reg_val tuner_init_it9135_38[] = { 591static const struct reg_val tuner_init_it9135_38[] = {
668 { 0x800043, 0x00 }, 592 { 0x800043, 0x00 },
669 { 0x800046, 0x38 }, 593 { 0x800046, 0x38 },
@@ -879,8 +803,10 @@ static const struct reg_val tuner_init_it9135_38[] = {
879 { 0x80fd8b, 0x00 }, 803 { 0x80fd8b, 0x00 },
880}; 804};
881 805
882/* ITE Tech IT9135 Omega LNA config 1 tuner init 806/*
883 AF9033_TUNER_IT9135_51 = 0x51 */ 807 * ITE Tech IT9133 AX Omega LNA config 1 tuner init
808 * AF9033_TUNER_IT9135_51 = 0x51
809 */
884static const struct reg_val tuner_init_it9135_51[] = { 810static const struct reg_val tuner_init_it9135_51[] = {
885 { 0x800043, 0x00 }, 811 { 0x800043, 0x00 },
886 { 0x800046, 0x51 }, 812 { 0x800046, 0x51 },
@@ -1096,8 +1022,10 @@ static const struct reg_val tuner_init_it9135_51[] = {
1096 { 0x80fd8b, 0x00 }, 1022 { 0x80fd8b, 0x00 },
1097}; 1023};
1098 1024
1099/* ITE Tech IT9135 Omega LNA config 2 tuner init 1025/*
1100 AF9033_TUNER_IT9135_52 = 0x52 */ 1026 * ITE Tech IT9133 AX Omega LNA config 2 tuner init
1027 * AF9033_TUNER_IT9135_52 = 0x52
1028 */
1101static const struct reg_val tuner_init_it9135_52[] = { 1029static const struct reg_val tuner_init_it9135_52[] = {
1102 { 0x800043, 0x00 }, 1030 { 0x800043, 0x00 },
1103 { 0x800046, 0x52 }, 1031 { 0x800046, 0x52 },
@@ -1313,6 +1241,9 @@ static const struct reg_val tuner_init_it9135_52[] = {
1313 { 0x80fd8b, 0x00 }, 1241 { 0x80fd8b, 0x00 },
1314}; 1242};
1315 1243
1244/*
1245 * ITE Tech IT9133 BX demod init
1246 */
1316static const struct reg_val ofsm_init_it9135_v2[] = { 1247static const struct reg_val ofsm_init_it9135_v2[] = {
1317 { 0x800051, 0x01 }, 1248 { 0x800051, 0x01 },
1318 { 0x800070, 0x0a }, 1249 { 0x800070, 0x0a },
@@ -1411,8 +1342,10 @@ static const struct reg_val ofsm_init_it9135_v2[] = {
1411 { 0x80fd8b, 0x00 }, 1342 { 0x80fd8b, 0x00 },
1412}; 1343};
1413 1344
1414/* ITE Tech IT9135 Omega v2 tuner init 1345/*
1415 AF9033_TUNER_IT9135_60 = 0x60 */ 1346 * ITE Tech IT9133 BX Omega tuner init
1347 * AF9033_TUNER_IT9135_60 = 0x60
1348 */
1416static const struct reg_val tuner_init_it9135_60[] = { 1349static const struct reg_val tuner_init_it9135_60[] = {
1417 { 0x800043, 0x00 }, 1350 { 0x800043, 0x00 },
1418 { 0x800046, 0x60 }, 1351 { 0x800046, 0x60 },
@@ -1625,8 +1558,10 @@ static const struct reg_val tuner_init_it9135_60[] = {
1625 { 0x80fd8b, 0x00 }, 1558 { 0x80fd8b, 0x00 },
1626}; 1559};
1627 1560
1628/* ITE Tech IT9135 Omega v2 LNA config 1 tuner init 1561/*
1629 AF9033_TUNER_IT9135_61 = 0x61 */ 1562 * ITE Tech IT9133 BX Omega LNA config 1 tuner init
1563 * AF9033_TUNER_IT9135_61 = 0x61
1564 */
1630static const struct reg_val tuner_init_it9135_61[] = { 1565static const struct reg_val tuner_init_it9135_61[] = {
1631 { 0x800043, 0x00 }, 1566 { 0x800043, 0x00 },
1632 { 0x800046, 0x61 }, 1567 { 0x800046, 0x61 },
@@ -1839,8 +1774,10 @@ static const struct reg_val tuner_init_it9135_61[] = {
1839 { 0x80fd8b, 0x00 }, 1774 { 0x80fd8b, 0x00 },
1840}; 1775};
1841 1776
1842/* ITE Tech IT9135 Omega v2 LNA config 2 tuner init 1777/*
1843 AF9033_TUNER_IT9135_62 = 0x62 */ 1778 * ITE Tech IT9133 BX Omega LNA config 2 tuner init
1779 * AF9033_TUNER_IT9135_62 = 0x62
1780 */
1844static const struct reg_val tuner_init_it9135_62[] = { 1781static const struct reg_val tuner_init_it9135_62[] = {
1845 { 0x800043, 0x00 }, 1782 { 0x800043, 0x00 },
1846 { 0x800046, 0x62 }, 1783 { 0x800046, 0x62 },
diff --git a/drivers/media/dvb-frontends/atbm8830.c b/drivers/media/dvb-frontends/atbm8830.c
index 07ce05578278..05850b32d6c6 100644
--- a/drivers/media/dvb-frontends/atbm8830.c
+++ b/drivers/media/dvb-frontends/atbm8830.c
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include <asm/div64.h> 18#include <asm/div64.h>
diff --git a/drivers/media/dvb-frontends/atbm8830.h b/drivers/media/dvb-frontends/atbm8830.h
index bb862387080f..e146d394f4ed 100644
--- a/drivers/media/dvb-frontends/atbm8830.h
+++ b/drivers/media/dvb-frontends/atbm8830.h
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#ifndef __ATBM8830_H__ 18#ifndef __ATBM8830_H__
diff --git a/drivers/media/dvb-frontends/atbm8830_priv.h b/drivers/media/dvb-frontends/atbm8830_priv.h
index d460058d497e..f1399451d1b0 100644
--- a/drivers/media/dvb-frontends/atbm8830_priv.h
+++ b/drivers/media/dvb-frontends/atbm8830_priv.h
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#ifndef __ATBM8830_PRIV_H 18#ifndef __ATBM8830_PRIV_H
diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c
index add246382806..a2e771305008 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -13,11 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 */ 16 */
22 17
23/* Developer notes: 18/* Developer notes:
diff --git a/drivers/media/dvb-frontends/bcm3510.h b/drivers/media/dvb-frontends/bcm3510.h
index 961c2eb87c68..b6a2d62de379 100644
--- a/drivers/media/dvb-frontends/bcm3510.h
+++ b/drivers/media/dvb-frontends/bcm3510.h
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22#ifndef BCM3510_H 18#ifndef BCM3510_H
23#define BCM3510_H 19#define BCM3510_H
diff --git a/drivers/media/dvb-frontends/bcm3510_priv.h b/drivers/media/dvb-frontends/bcm3510_priv.h
index 67f24686c31b..475e8381bf13 100644
--- a/drivers/media/dvb-frontends/bcm3510_priv.h
+++ b/drivers/media/dvb-frontends/bcm3510_priv.h
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22#ifndef __BCM3510_PRIV_H__ 18#ifndef __BCM3510_PRIV_H__
23#define __BCM3510_PRIV_H__ 19#define __BCM3510_PRIV_H__
diff --git a/drivers/media/dvb-frontends/bsbe1-d01a.h b/drivers/media/dvb-frontends/bsbe1-d01a.h
index baaf89e768cf..1d6e8d33cd92 100644
--- a/drivers/media/dvb-frontends/bsbe1-d01a.h
+++ b/drivers/media/dvb-frontends/bsbe1-d01a.h
@@ -14,11 +14,8 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * 17 * To obtain the license, point your browser to
18 * You should have received a copy of the GNU General Public License 18 * http://www.gnu.org/copyleft/gpl.html
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 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
22 * 19 *
23 * 20 *
24 * the project's page is at https://linuxtv.org 21 * the project's page is at https://linuxtv.org
diff --git a/drivers/media/dvb-frontends/bsbe1.h b/drivers/media/dvb-frontends/bsbe1.h
index 4ad766154741..cb7cb2c5b977 100644
--- a/drivers/media/dvb-frontends/bsbe1.h
+++ b/drivers/media/dvb-frontends/bsbe1.h
@@ -12,11 +12,8 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * 15 * To obtain the license, point your browser to
16 * You should have received a copy of the GNU General Public License 16 * http://www.gnu.org/copyleft/gpl.html
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
20 * 17 *
21 * 18 *
22 * the project's page is at https://linuxtv.org 19 * the project's page is at https://linuxtv.org
diff --git a/drivers/media/dvb-frontends/bsru6.h b/drivers/media/dvb-frontends/bsru6.h
index 275c1782597d..1c203eb27491 100644
--- a/drivers/media/dvb-frontends/bsru6.h
+++ b/drivers/media/dvb-frontends/bsru6.h
@@ -12,11 +12,8 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * 15 * To obtain the license, point your browser to
16 * You should have received a copy of the GNU General Public License 16 * http://www.gnu.org/copyleft/gpl.html
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
20 * 17 *
21 * 18 *
22 * the project's page is at https://linuxtv.org 19 * the project's page is at https://linuxtv.org
diff --git a/drivers/media/dvb-frontends/cx24113.c b/drivers/media/dvb-frontends/cx24113.c
index db44ebb7c561..0118c2658cf7 100644
--- a/drivers/media/dvb-frontends/cx24113.c
+++ b/drivers/media/dvb-frontends/cx24113.c
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * 16 *
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 18 */
23 19
24#include <linux/slab.h> 20#include <linux/slab.h>
diff --git a/drivers/media/dvb-frontends/cx24113.h b/drivers/media/dvb-frontends/cx24113.h
index 194c703611b4..f013aca3a691 100644
--- a/drivers/media/dvb-frontends/cx24113.h
+++ b/drivers/media/dvb-frontends/cx24113.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#ifndef CX24113_H 18#ifndef CX24113_H
diff --git a/drivers/media/dvb-frontends/cx24123.c b/drivers/media/dvb-frontends/cx24123.c
index 8aed8cc9f93d..4ae3d922a8e8 100644
--- a/drivers/media/dvb-frontends/cx24123.c
+++ b/drivers/media/dvb-frontends/cx24123.c
@@ -16,10 +16,6 @@
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details. 18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */ 19 */
24 20
25#include <linux/slab.h> 21#include <linux/slab.h>
@@ -653,7 +649,7 @@ static int cx24123_pll_tune(struct dvb_frontend *fe)
653 dprintk("frequency=%i\n", p->frequency); 649 dprintk("frequency=%i\n", p->frequency);
654 650
655 if (cx24123_pll_calculate(fe) != 0) { 651 if (cx24123_pll_calculate(fe) != 0) {
656 err("%s: cx24123_pll_calcutate failed\n", __func__); 652 err("%s: cx24123_pll_calculate failed\n", __func__);
657 return -EINVAL; 653 return -EINVAL;
658 } 654 }
659 655
diff --git a/drivers/media/dvb-frontends/cxd2820r_core.c b/drivers/media/dvb-frontends/cxd2820r_core.c
index 95267c6edb3a..f6ebbb47b9b2 100644
--- a/drivers/media/dvb-frontends/cxd2820r_core.c
+++ b/drivers/media/dvb-frontends/cxd2820r_core.c
@@ -615,6 +615,7 @@ static int cxd2820r_probe(struct i2c_client *client,
615 } 615 }
616 616
617 priv->client[0] = client; 617 priv->client[0] = client;
618 priv->fe.demodulator_priv = priv;
618 priv->i2c = client->adapter; 619 priv->i2c = client->adapter;
619 priv->ts_mode = pdata->ts_mode; 620 priv->ts_mode = pdata->ts_mode;
620 priv->ts_clk_inv = pdata->ts_clk_inv; 621 priv->ts_clk_inv = pdata->ts_clk_inv;
@@ -697,7 +698,6 @@ static int cxd2820r_probe(struct i2c_client *client,
697 memcpy(&priv->fe.ops, &cxd2820r_ops, sizeof(priv->fe.ops)); 698 memcpy(&priv->fe.ops, &cxd2820r_ops, sizeof(priv->fe.ops));
698 if (!pdata->attach_in_use) 699 if (!pdata->attach_in_use)
699 priv->fe.ops.release = NULL; 700 priv->fe.ops.release = NULL;
700 priv->fe.demodulator_priv = priv;
701 i2c_set_clientdata(client, priv); 701 i2c_set_clientdata(client, priv);
702 702
703 /* Setup callbacks */ 703 /* Setup callbacks */
diff --git a/drivers/media/dvb-frontends/dib0070.c b/drivers/media/dvb-frontends/dib0070.c
index befc8172159d..d7614b8b8782 100644
--- a/drivers/media/dvb-frontends/dib0070.c
+++ b/drivers/media/dvb-frontends/dib0070.c
@@ -14,10 +14,6 @@
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 * 17 *
22 * This code is more or less generated from another driver, please 18 * This code is more or less generated from another driver, please
23 * excuse some codingstyle oddities. 19 * excuse some codingstyle oddities.
diff --git a/drivers/media/dvb-frontends/dib0090.c b/drivers/media/dvb-frontends/dib0090.c
index fd3b33296b15..33af14df27bd 100644
--- a/drivers/media/dvb-frontends/dib0090.c
+++ b/drivers/media/dvb-frontends/dib0090.c
@@ -14,10 +14,6 @@
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 * 17 *
22 * This code is more or less generated from another driver, please 18 * This code is more or less generated from another driver, please
23 * excuse some codingstyle oddities. 19 * excuse some codingstyle oddities.
diff --git a/drivers/media/dvb-frontends/dib7000p.c b/drivers/media/dvb-frontends/dib7000p.c
index a27c0001f2d6..3815ea515364 100644
--- a/drivers/media/dvb-frontends/dib7000p.c
+++ b/drivers/media/dvb-frontends/dib7000p.c
@@ -805,13 +805,19 @@ static int dib7000p_set_agc_config(struct dib7000p_state *state, u8 band)
805 return 0; 805 return 0;
806} 806}
807 807
808static void dib7000p_set_dds(struct dib7000p_state *state, s32 offset_khz) 808static int dib7000p_set_dds(struct dib7000p_state *state, s32 offset_khz)
809{ 809{
810 u32 internal = dib7000p_get_internal_freq(state); 810 u32 internal = dib7000p_get_internal_freq(state);
811 s32 unit_khz_dds_val = 67108864 / (internal); /* 2**26 / Fsampling is the unit 1KHz offset */ 811 s32 unit_khz_dds_val;
812 u32 abs_offset_khz = ABS(offset_khz); 812 u32 abs_offset_khz = ABS(offset_khz);
813 u32 dds = state->cfg.bw->ifreq & 0x1ffffff; 813 u32 dds = state->cfg.bw->ifreq & 0x1ffffff;
814 u8 invert = !!(state->cfg.bw->ifreq & (1 << 25)); 814 u8 invert = !!(state->cfg.bw->ifreq & (1 << 25));
815 if (internal == 0) {
816 pr_warn("DIB7000P: dib7000p_get_internal_freq returned 0\n");
817 return -1;
818 }
819 /* 2**26 / Fsampling is the unit 1KHz offset */
820 unit_khz_dds_val = 67108864 / (internal);
815 821
816 dprintk("setting a frequency offset of %dkHz internal freq = %d invert = %d\n", offset_khz, internal, invert); 822 dprintk("setting a frequency offset of %dkHz internal freq = %d invert = %d\n", offset_khz, internal, invert);
817 823
@@ -828,6 +834,7 @@ static void dib7000p_set_dds(struct dib7000p_state *state, s32 offset_khz)
828 dib7000p_write_word(state, 21, (u16) (((dds >> 16) & 0x1ff) | (0 << 10) | (invert << 9))); 834 dib7000p_write_word(state, 21, (u16) (((dds >> 16) & 0x1ff) | (0 << 10) | (invert << 9)));
829 dib7000p_write_word(state, 22, (u16) (dds & 0xffff)); 835 dib7000p_write_word(state, 22, (u16) (dds & 0xffff));
830 } 836 }
837 return 0;
831} 838}
832 839
833static int dib7000p_agc_startup(struct dvb_frontend *demod) 840static int dib7000p_agc_startup(struct dvb_frontend *demod)
@@ -867,7 +874,9 @@ static int dib7000p_agc_startup(struct dvb_frontend *demod)
867 frequency_offset = (s32)frequency_tuner / 1000 - ch->frequency / 1000; 874 frequency_offset = (s32)frequency_tuner / 1000 - ch->frequency / 1000;
868 } 875 }
869 876
870 dib7000p_set_dds(state, frequency_offset); 877 if (dib7000p_set_dds(state, frequency_offset) < 0)
878 return -1;
879
871 ret = 7; 880 ret = 7;
872 (*agc_state)++; 881 (*agc_state)++;
873 break; 882 break;
diff --git a/drivers/media/dvb-frontends/drx39xyj/drx39xxj.h b/drivers/media/dvb-frontends/drx39xyj/drx39xxj.h
index 8188062953af..11e1ddeeef0a 100644
--- a/drivers/media/dvb-frontends/drx39xyj/drx39xxj.h
+++ b/drivers/media/dvb-frontends/drx39xyj/drx39xxj.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */ 16 */
21 17
22#ifndef DRX39XXJ_H 18#ifndef DRX39XXJ_H
diff --git a/drivers/media/dvb-frontends/drxd.h b/drivers/media/dvb-frontends/drxd.h
index f0507cdbb503..1d4b89488ac4 100644
--- a/drivers/media/dvb-frontends/drxd.h
+++ b/drivers/media/dvb-frontends/drxd.h
@@ -13,12 +13,8 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * 16 * To obtain the license, point your browser to
17 * You should have received a copy of the GNU General Public License 17 * http://www.gnu.org/copyleft/gpl.html
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA
21 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
22 */ 18 */
23 19
24#ifndef _DRXD_H_ 20#ifndef _DRXD_H_
diff --git a/drivers/media/dvb-frontends/drxd_firm.c b/drivers/media/dvb-frontends/drxd_firm.c
index 5418b0b1dadc..4e1d8905e06a 100644
--- a/drivers/media/dvb-frontends/drxd_firm.c
+++ b/drivers/media/dvb-frontends/drxd_firm.c
@@ -13,12 +13,8 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * 16 * To obtain the license, point your browser to
17 * You should have received a copy of the GNU General Public License 17 * http://www.gnu.org/copyleft/gpl.html
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA
21 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
22 */ 18 */
23 19
24/* TODO: generate this file with a script from a settings file */ 20/* TODO: generate this file with a script from a settings file */
diff --git a/drivers/media/dvb-frontends/drxd_firm.h b/drivers/media/dvb-frontends/drxd_firm.h
index 41597e89941c..7d9f9fa7ab3c 100644
--- a/drivers/media/dvb-frontends/drxd_firm.h
+++ b/drivers/media/dvb-frontends/drxd_firm.h
@@ -13,12 +13,8 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * 16 * To obtain the license, point your browser to
17 * You should have received a copy of the GNU General Public License 17 * http://www.gnu.org/copyleft/gpl.html
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA
21 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
22 */ 18 */
23 19
24#ifndef _DRXD_FIRM_H_ 20#ifndef _DRXD_FIRM_H_
diff --git a/drivers/media/dvb-frontends/drxd_hard.c b/drivers/media/dvb-frontends/drxd_hard.c
index 4143f0326684..71910561005f 100644
--- a/drivers/media/dvb-frontends/drxd_hard.c
+++ b/drivers/media/dvb-frontends/drxd_hard.c
@@ -13,12 +13,8 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * 16 * To obtain the license, point your browser to
17 * You should have received a copy of the GNU General Public License 17 * http://www.gnu.org/copyleft/gpl.html
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA
21 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
22 */ 18 */
23 19
24#include <linux/kernel.h> 20#include <linux/kernel.h>
diff --git a/drivers/media/dvb-frontends/drxd_map_firm.h b/drivers/media/dvb-frontends/drxd_map_firm.h
index 6bc553abf215..8e5bd2e8de40 100644
--- a/drivers/media/dvb-frontends/drxd_map_firm.h
+++ b/drivers/media/dvb-frontends/drxd_map_firm.h
@@ -13,12 +13,8 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * 16 * To obtain the license, point your browser to
17 * You should have received a copy of the GNU General Public License 17 * http://www.gnu.org/copyleft/gpl.html
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA
21 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
22 */ 18 */
23 19
24#ifndef __DRX3973D_MAP__H__ 20#ifndef __DRX3973D_MAP__H__
diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c
index 146edf344dd8..15d2cac588b1 100644
--- a/drivers/media/dvb-frontends/drxk_hard.c
+++ b/drivers/media/dvb-frontends/drxk_hard.c
@@ -13,12 +13,8 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * 16 * To obtain the license, point your browser to
17 * You should have received a copy of the GNU General Public License 17 * http://www.gnu.org/copyleft/gpl.html
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA
21 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
22 */ 18 */
23 19
24#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 20#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/dvb-frontends/dvb-pll.c b/drivers/media/dvb-frontends/dvb-pll.c
index ef976eb23344..7bec3e028bee 100644
--- a/drivers/media/dvb-frontends/dvb-pll.c
+++ b/drivers/media/dvb-frontends/dvb-pll.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/dvb-frontends/dvb_dummy_fe.c b/drivers/media/dvb-frontends/dvb_dummy_fe.c
index efc3c31a7635..50b2b666ef6c 100644
--- a/drivers/media/dvb-frontends/dvb_dummy_fe.c
+++ b/drivers/media/dvb-frontends/dvb_dummy_fe.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */ 16 */
21 17
22#include <linux/module.h> 18#include <linux/module.h>
diff --git a/drivers/media/dvb-frontends/dvb_dummy_fe.h b/drivers/media/dvb-frontends/dvb_dummy_fe.h
index 50f1af512b62..86dd7b9d1e57 100644
--- a/drivers/media/dvb-frontends/dvb_dummy_fe.h
+++ b/drivers/media/dvb-frontends/dvb_dummy_fe.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */ 16 */
21 17
22#ifndef DVB_DUMMY_FE_H 18#ifndef DVB_DUMMY_FE_H
diff --git a/drivers/media/dvb-frontends/ec100.c b/drivers/media/dvb-frontends/ec100.c
index d97ce21e26e1..fa2a96d5f94e 100644
--- a/drivers/media/dvb-frontends/ec100.c
+++ b/drivers/media/dvb-frontends/ec100.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */ 16 */
21 17
22#include "dvb_frontend.h" 18#include "dvb_frontend.h"
diff --git a/drivers/media/dvb-frontends/ec100.h b/drivers/media/dvb-frontends/ec100.h
index e894bdcf35a3..e43fe26654b2 100644
--- a/drivers/media/dvb-frontends/ec100.h
+++ b/drivers/media/dvb-frontends/ec100.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */ 16 */
21 17
22#ifndef EC100_H 18#ifndef EC100_H
diff --git a/drivers/media/dvb-frontends/hd29l2.c b/drivers/media/dvb-frontends/hd29l2.c
deleted file mode 100644
index 8b53633cf325..000000000000
--- a/drivers/media/dvb-frontends/hd29l2.c
+++ /dev/null
@@ -1,870 +0,0 @@
1/*
2 * HDIC HD29L2 DMB-TH demodulator driver
3 *
4 * Copyright (C) 2011 Metropolia University of Applied Sciences, Electria R&D
5 *
6 * Author: Antti Palosaari <crope@iki.fi>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (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 General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include "hd29l2_priv.h"
24
25#define HD29L2_MAX_LEN (3)
26
27/* write multiple registers */
28static int hd29l2_wr_regs(struct hd29l2_priv *priv, u8 reg, u8 *val, int len)
29{
30 int ret;
31 u8 buf[2 + HD29L2_MAX_LEN];
32 struct i2c_msg msg[1] = {
33 {
34 .addr = priv->cfg.i2c_addr,
35 .flags = 0,
36 .len = 2 + len,
37 .buf = buf,
38 }
39 };
40
41 if (len > HD29L2_MAX_LEN)
42 return -EINVAL;
43 buf[0] = 0x00;
44 buf[1] = reg;
45 memcpy(&buf[2], val, len);
46
47 ret = i2c_transfer(priv->i2c, msg, 1);
48 if (ret == 1) {
49 ret = 0;
50 } else {
51 dev_warn(&priv->i2c->dev,
52 "%s: i2c wr failed=%d reg=%02x len=%d\n",
53 KBUILD_MODNAME, ret, reg, len);
54 ret = -EREMOTEIO;
55 }
56
57 return ret;
58}
59
60/* read multiple registers */
61static int hd29l2_rd_regs(struct hd29l2_priv *priv, u8 reg, u8 *val, int len)
62{
63 int ret;
64 u8 buf[2] = { 0x00, reg };
65 struct i2c_msg msg[2] = {
66 {
67 .addr = priv->cfg.i2c_addr,
68 .flags = 0,
69 .len = 2,
70 .buf = buf,
71 }, {
72 .addr = priv->cfg.i2c_addr,
73 .flags = I2C_M_RD,
74 .len = len,
75 .buf = val,
76 }
77 };
78
79 ret = i2c_transfer(priv->i2c, msg, 2);
80 if (ret == 2) {
81 ret = 0;
82 } else {
83 dev_warn(&priv->i2c->dev,
84 "%s: i2c rd failed=%d reg=%02x len=%d\n",
85 KBUILD_MODNAME, ret, reg, len);
86 ret = -EREMOTEIO;
87 }
88
89 return ret;
90}
91
92/* write single register */
93static int hd29l2_wr_reg(struct hd29l2_priv *priv, u8 reg, u8 val)
94{
95 return hd29l2_wr_regs(priv, reg, &val, 1);
96}
97
98/* read single register */
99static int hd29l2_rd_reg(struct hd29l2_priv *priv, u8 reg, u8 *val)
100{
101 return hd29l2_rd_regs(priv, reg, val, 1);
102}
103
104/* write single register with mask */
105static int hd29l2_wr_reg_mask(struct hd29l2_priv *priv, u8 reg, u8 val, u8 mask)
106{
107 int ret;
108 u8 tmp;
109
110 /* no need for read if whole reg is written */
111 if (mask != 0xff) {
112 ret = hd29l2_rd_regs(priv, reg, &tmp, 1);
113 if (ret)
114 return ret;
115
116 val &= mask;
117 tmp &= ~mask;
118 val |= tmp;
119 }
120
121 return hd29l2_wr_regs(priv, reg, &val, 1);
122}
123
124/* read single register with mask */
125static int hd29l2_rd_reg_mask(struct hd29l2_priv *priv, u8 reg, u8 *val, u8 mask)
126{
127 int ret, i;
128 u8 tmp;
129
130 ret = hd29l2_rd_regs(priv, reg, &tmp, 1);
131 if (ret)
132 return ret;
133
134 tmp &= mask;
135
136 /* find position of the first bit */
137 for (i = 0; i < 8; i++) {
138 if ((mask >> i) & 0x01)
139 break;
140 }
141 *val = tmp >> i;
142
143 return 0;
144}
145
146static int hd29l2_soft_reset(struct hd29l2_priv *priv)
147{
148 int ret;
149 u8 tmp;
150
151 ret = hd29l2_rd_reg(priv, 0x26, &tmp);
152 if (ret)
153 goto err;
154
155 ret = hd29l2_wr_reg(priv, 0x26, 0x0d);
156 if (ret)
157 goto err;
158
159 usleep_range(10000, 20000);
160
161 ret = hd29l2_wr_reg(priv, 0x26, tmp);
162 if (ret)
163 goto err;
164
165 return 0;
166err:
167 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
168 return ret;
169}
170
171static int hd29l2_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
172{
173 int ret, i;
174 struct hd29l2_priv *priv = fe->demodulator_priv;
175 u8 tmp;
176
177 dev_dbg(&priv->i2c->dev, "%s: enable=%d\n", __func__, enable);
178
179 /* set tuner address for demod */
180 if (!priv->tuner_i2c_addr_programmed && enable) {
181 /* no need to set tuner address every time, once is enough */
182 ret = hd29l2_wr_reg(priv, 0x9d, priv->cfg.tuner_i2c_addr << 1);
183 if (ret)
184 goto err;
185
186 priv->tuner_i2c_addr_programmed = true;
187 }
188
189 /* open / close gate */
190 ret = hd29l2_wr_reg(priv, 0x9f, enable);
191 if (ret)
192 goto err;
193
194 /* wait demod ready */
195 for (i = 10; i; i--) {
196 ret = hd29l2_rd_reg(priv, 0x9e, &tmp);
197 if (ret)
198 goto err;
199
200 if (tmp == enable)
201 break;
202
203 usleep_range(5000, 10000);
204 }
205
206 dev_dbg(&priv->i2c->dev, "%s: loop=%d\n", __func__, i);
207
208 return ret;
209err:
210 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
211 return ret;
212}
213
214static int hd29l2_read_status(struct dvb_frontend *fe, enum fe_status *status)
215{
216 int ret;
217 struct hd29l2_priv *priv = fe->demodulator_priv;
218 u8 buf[2];
219
220 *status = 0;
221
222 ret = hd29l2_rd_reg(priv, 0x05, &buf[0]);
223 if (ret)
224 goto err;
225
226 if (buf[0] & 0x01) {
227 /* full lock */
228 *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
229 FE_HAS_SYNC | FE_HAS_LOCK;
230 } else {
231 ret = hd29l2_rd_reg(priv, 0x0d, &buf[1]);
232 if (ret)
233 goto err;
234
235 if ((buf[1] & 0xfe) == 0x78)
236 /* partial lock */
237 *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER |
238 FE_HAS_VITERBI | FE_HAS_SYNC;
239 }
240
241 priv->fe_status = *status;
242
243 return 0;
244err:
245 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
246 return ret;
247}
248
249static int hd29l2_read_snr(struct dvb_frontend *fe, u16 *snr)
250{
251 int ret;
252 struct hd29l2_priv *priv = fe->demodulator_priv;
253 u8 buf[2];
254 u16 tmp;
255
256 if (!(priv->fe_status & FE_HAS_LOCK)) {
257 *snr = 0;
258 ret = 0;
259 goto err;
260 }
261
262 ret = hd29l2_rd_regs(priv, 0x0b, buf, 2);
263 if (ret)
264 goto err;
265
266 tmp = (buf[0] << 8) | buf[1];
267
268 /* report SNR in dB * 10 */
269 #define LOG10_20736_24 72422627 /* log10(20736) << 24 */
270 if (tmp)
271 *snr = (LOG10_20736_24 - intlog10(tmp)) / ((1 << 24) / 100);
272 else
273 *snr = 0;
274
275 return 0;
276err:
277 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
278 return ret;
279}
280
281static int hd29l2_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
282{
283 int ret;
284 struct hd29l2_priv *priv = fe->demodulator_priv;
285 u8 buf[2];
286 u16 tmp;
287
288 *strength = 0;
289
290 ret = hd29l2_rd_regs(priv, 0xd5, buf, 2);
291 if (ret)
292 goto err;
293
294 tmp = buf[0] << 8 | buf[1];
295 tmp = ~tmp & 0x0fff;
296
297 /* scale value to 0x0000-0xffff from 0x0000-0x0fff */
298 *strength = tmp * 0xffff / 0x0fff;
299
300 return 0;
301err:
302 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
303 return ret;
304}
305
306static int hd29l2_read_ber(struct dvb_frontend *fe, u32 *ber)
307{
308 int ret;
309 struct hd29l2_priv *priv = fe->demodulator_priv;
310 u8 buf[2];
311
312 if (!(priv->fe_status & FE_HAS_SYNC)) {
313 *ber = 0;
314 ret = 0;
315 goto err;
316 }
317
318 ret = hd29l2_rd_regs(priv, 0xd9, buf, 2);
319 if (ret) {
320 *ber = 0;
321 goto err;
322 }
323
324 /* LDPC BER */
325 *ber = ((buf[0] & 0x0f) << 8) | buf[1];
326
327 return 0;
328err:
329 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
330 return ret;
331}
332
333static int hd29l2_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
334{
335 /* no way to read? */
336 *ucblocks = 0;
337 return 0;
338}
339
340static enum dvbfe_search hd29l2_search(struct dvb_frontend *fe)
341{
342 int ret, i;
343 struct hd29l2_priv *priv = fe->demodulator_priv;
344 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
345 u8 tmp, buf[3];
346 u8 modulation, carrier, guard_interval, interleave, code_rate;
347 u64 num64;
348 u32 if_freq, if_ctl;
349 bool auto_mode;
350
351 dev_dbg(&priv->i2c->dev, "%s: delivery_system=%d frequency=%d " \
352 "bandwidth_hz=%d modulation=%d inversion=%d " \
353 "fec_inner=%d guard_interval=%d\n", __func__,
354 c->delivery_system, c->frequency, c->bandwidth_hz,
355 c->modulation, c->inversion, c->fec_inner,
356 c->guard_interval);
357
358 /* as for now we detect always params automatically */
359 auto_mode = true;
360
361 /* program tuner */
362 if (fe->ops.tuner_ops.set_params)
363 fe->ops.tuner_ops.set_params(fe);
364
365 /* get and program IF */
366 if (fe->ops.tuner_ops.get_if_frequency)
367 fe->ops.tuner_ops.get_if_frequency(fe, &if_freq);
368 else
369 if_freq = 0;
370
371 if (if_freq) {
372 /* normal IF */
373
374 /* calc IF control value */
375 num64 = if_freq;
376 num64 *= 0x800000;
377 num64 = div_u64(num64, HD29L2_XTAL);
378 num64 -= 0x800000;
379 if_ctl = num64;
380
381 tmp = 0xfc; /* tuner type normal */
382 } else {
383 /* zero IF */
384 if_ctl = 0;
385 tmp = 0xfe; /* tuner type Zero-IF */
386 }
387
388 buf[0] = ((if_ctl >> 0) & 0xff);
389 buf[1] = ((if_ctl >> 8) & 0xff);
390 buf[2] = ((if_ctl >> 16) & 0xff);
391
392 /* program IF control */
393 ret = hd29l2_wr_regs(priv, 0x14, buf, 3);
394 if (ret)
395 goto err;
396
397 /* program tuner type */
398 ret = hd29l2_wr_reg(priv, 0xab, tmp);
399 if (ret)
400 goto err;
401
402 dev_dbg(&priv->i2c->dev, "%s: if_freq=%d if_ctl=%x\n",
403 __func__, if_freq, if_ctl);
404
405 if (auto_mode) {
406 /*
407 * use auto mode
408 */
409
410 /* disable quick mode */
411 ret = hd29l2_wr_reg_mask(priv, 0xac, 0 << 7, 0x80);
412 if (ret)
413 goto err;
414
415 ret = hd29l2_wr_reg_mask(priv, 0x82, 1 << 1, 0x02);
416 if (ret)
417 goto err;
418
419 /* enable auto mode */
420 ret = hd29l2_wr_reg_mask(priv, 0x7d, 1 << 6, 0x40);
421 if (ret)
422 goto err;
423
424 ret = hd29l2_wr_reg_mask(priv, 0x81, 1 << 3, 0x08);
425 if (ret)
426 goto err;
427
428 /* soft reset */
429 ret = hd29l2_soft_reset(priv);
430 if (ret)
431 goto err;
432
433 /* detect modulation */
434 for (i = 30; i; i--) {
435 msleep(100);
436
437 ret = hd29l2_rd_reg(priv, 0x0d, &tmp);
438 if (ret)
439 goto err;
440
441 if ((((tmp & 0xf0) >= 0x10) &&
442 ((tmp & 0x0f) == 0x08)) || (tmp >= 0x2c))
443 break;
444 }
445
446 dev_dbg(&priv->i2c->dev, "%s: loop=%d\n", __func__, i);
447
448 if (i == 0)
449 /* detection failed */
450 return DVBFE_ALGO_SEARCH_FAILED;
451
452 /* read modulation */
453 ret = hd29l2_rd_reg_mask(priv, 0x7d, &modulation, 0x07);
454 if (ret)
455 goto err;
456 } else {
457 /*
458 * use manual mode
459 */
460
461 modulation = HD29L2_QAM64;
462 carrier = HD29L2_CARRIER_MULTI;
463 guard_interval = HD29L2_PN945;
464 interleave = HD29L2_INTERLEAVER_420;
465 code_rate = HD29L2_CODE_RATE_08;
466
467 tmp = (code_rate << 3) | modulation;
468 ret = hd29l2_wr_reg_mask(priv, 0x7d, tmp, 0x5f);
469 if (ret)
470 goto err;
471
472 tmp = (carrier << 2) | guard_interval;
473 ret = hd29l2_wr_reg_mask(priv, 0x81, tmp, 0x0f);
474 if (ret)
475 goto err;
476
477 tmp = interleave;
478 ret = hd29l2_wr_reg_mask(priv, 0x82, tmp, 0x03);
479 if (ret)
480 goto err;
481 }
482
483 /* ensure modulation validy */
484 /* 0=QAM4_NR, 1=QAM4, 2=QAM16, 3=QAM32, 4=QAM64 */
485 if (modulation > (ARRAY_SIZE(reg_mod_vals_tab[0].val) - 1)) {
486 dev_dbg(&priv->i2c->dev, "%s: modulation=%d not valid\n",
487 __func__, modulation);
488 goto err;
489 }
490
491 /* program registers according to modulation */
492 for (i = 0; i < ARRAY_SIZE(reg_mod_vals_tab); i++) {
493 ret = hd29l2_wr_reg(priv, reg_mod_vals_tab[i].reg,
494 reg_mod_vals_tab[i].val[modulation]);
495 if (ret)
496 goto err;
497 }
498
499 /* read guard interval */
500 ret = hd29l2_rd_reg_mask(priv, 0x81, &guard_interval, 0x03);
501 if (ret)
502 goto err;
503
504 /* read carrier mode */
505 ret = hd29l2_rd_reg_mask(priv, 0x81, &carrier, 0x04);
506 if (ret)
507 goto err;
508
509 dev_dbg(&priv->i2c->dev,
510 "%s: modulation=%d guard_interval=%d carrier=%d\n",
511 __func__, modulation, guard_interval, carrier);
512
513 if ((carrier == HD29L2_CARRIER_MULTI) && (modulation == HD29L2_QAM64) &&
514 (guard_interval == HD29L2_PN945)) {
515 dev_dbg(&priv->i2c->dev, "%s: C=3780 && QAM64 && PN945\n",
516 __func__);
517
518 ret = hd29l2_wr_reg(priv, 0x42, 0x33);
519 if (ret)
520 goto err;
521
522 ret = hd29l2_wr_reg(priv, 0xdd, 0x01);
523 if (ret)
524 goto err;
525 }
526
527 usleep_range(10000, 20000);
528
529 /* soft reset */
530 ret = hd29l2_soft_reset(priv);
531 if (ret)
532 goto err;
533
534 /* wait demod lock */
535 for (i = 30; i; i--) {
536 msleep(100);
537
538 /* read lock bit */
539 ret = hd29l2_rd_reg_mask(priv, 0x05, &tmp, 0x01);
540 if (ret)
541 goto err;
542
543 if (tmp)
544 break;
545 }
546
547 dev_dbg(&priv->i2c->dev, "%s: loop=%d\n", __func__, i);
548
549 if (i == 0)
550 return DVBFE_ALGO_SEARCH_AGAIN;
551
552 return DVBFE_ALGO_SEARCH_SUCCESS;
553err:
554 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
555 return DVBFE_ALGO_SEARCH_ERROR;
556}
557
558static int hd29l2_get_frontend_algo(struct dvb_frontend *fe)
559{
560 return DVBFE_ALGO_CUSTOM;
561}
562
563static int hd29l2_get_frontend(struct dvb_frontend *fe,
564 struct dtv_frontend_properties *c)
565{
566 int ret;
567 struct hd29l2_priv *priv = fe->demodulator_priv;
568 u8 buf[3];
569 u32 if_ctl;
570 char *str_constellation, *str_code_rate, *str_constellation_code_rate,
571 *str_guard_interval, *str_carrier, *str_guard_interval_carrier,
572 *str_interleave, *str_interleave_;
573
574 ret = hd29l2_rd_reg(priv, 0x7d, &buf[0]);
575 if (ret)
576 goto err;
577
578 ret = hd29l2_rd_regs(priv, 0x81, &buf[1], 2);
579 if (ret)
580 goto err;
581
582 /* constellation, 0x7d[2:0] */
583 switch ((buf[0] >> 0) & 0x07) {
584 case 0: /* QAM4NR */
585 str_constellation = "QAM4NR";
586 c->modulation = QAM_AUTO; /* FIXME */
587 break;
588 case 1: /* QAM4 */
589 str_constellation = "QAM4";
590 c->modulation = QPSK; /* FIXME */
591 break;
592 case 2:
593 str_constellation = "QAM16";
594 c->modulation = QAM_16;
595 break;
596 case 3:
597 str_constellation = "QAM32";
598 c->modulation = QAM_32;
599 break;
600 case 4:
601 str_constellation = "QAM64";
602 c->modulation = QAM_64;
603 break;
604 default:
605 str_constellation = "?";
606 }
607
608 /* LDPC code rate, 0x7d[4:3] */
609 switch ((buf[0] >> 3) & 0x03) {
610 case 0: /* 0.4 */
611 str_code_rate = "0.4";
612 c->fec_inner = FEC_AUTO; /* FIXME */
613 break;
614 case 1: /* 0.6 */
615 str_code_rate = "0.6";
616 c->fec_inner = FEC_3_5;
617 break;
618 case 2: /* 0.8 */
619 str_code_rate = "0.8";
620 c->fec_inner = FEC_4_5;
621 break;
622 default:
623 str_code_rate = "?";
624 }
625
626 /* constellation & code rate set, 0x7d[6] */
627 switch ((buf[0] >> 6) & 0x01) {
628 case 0:
629 str_constellation_code_rate = "manual";
630 break;
631 case 1:
632 str_constellation_code_rate = "auto";
633 break;
634 default:
635 str_constellation_code_rate = "?";
636 }
637
638 /* frame header, 0x81[1:0] */
639 switch ((buf[1] >> 0) & 0x03) {
640 case 0: /* PN945 */
641 str_guard_interval = "PN945";
642 c->guard_interval = GUARD_INTERVAL_AUTO; /* FIXME */
643 break;
644 case 1: /* PN595 */
645 str_guard_interval = "PN595";
646 c->guard_interval = GUARD_INTERVAL_AUTO; /* FIXME */
647 break;
648 case 2: /* PN420 */
649 str_guard_interval = "PN420";
650 c->guard_interval = GUARD_INTERVAL_AUTO; /* FIXME */
651 break;
652 default:
653 str_guard_interval = "?";
654 }
655
656 /* carrier, 0x81[2] */
657 switch ((buf[1] >> 2) & 0x01) {
658 case 0:
659 str_carrier = "C=1";
660 break;
661 case 1:
662 str_carrier = "C=3780";
663 break;
664 default:
665 str_carrier = "?";
666 }
667
668 /* frame header & carrier set, 0x81[3] */
669 switch ((buf[1] >> 3) & 0x01) {
670 case 0:
671 str_guard_interval_carrier = "manual";
672 break;
673 case 1:
674 str_guard_interval_carrier = "auto";
675 break;
676 default:
677 str_guard_interval_carrier = "?";
678 }
679
680 /* interleave, 0x82[0] */
681 switch ((buf[2] >> 0) & 0x01) {
682 case 0:
683 str_interleave = "M=720";
684 break;
685 case 1:
686 str_interleave = "M=240";
687 break;
688 default:
689 str_interleave = "?";
690 }
691
692 /* interleave set, 0x82[1] */
693 switch ((buf[2] >> 1) & 0x01) {
694 case 0:
695 str_interleave_ = "manual";
696 break;
697 case 1:
698 str_interleave_ = "auto";
699 break;
700 default:
701 str_interleave_ = "?";
702 }
703
704 /*
705 * We can read out current detected NCO and use that value next
706 * time instead of calculating new value from targed IF.
707 * I think it will not effect receiver sensitivity but gaining lock
708 * after tune could be easier...
709 */
710 ret = hd29l2_rd_regs(priv, 0xb1, &buf[0], 3);
711 if (ret)
712 goto err;
713
714 if_ctl = (buf[0] << 16) | ((buf[1] - 7) << 8) | buf[2];
715
716 dev_dbg(&priv->i2c->dev, "%s: %s %s %s | %s %s %s | %s %s | NCO=%06x\n",
717 __func__, str_constellation, str_code_rate,
718 str_constellation_code_rate, str_guard_interval,
719 str_carrier, str_guard_interval_carrier, str_interleave,
720 str_interleave_, if_ctl);
721 return 0;
722err:
723 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
724 return ret;
725}
726
727static int hd29l2_init(struct dvb_frontend *fe)
728{
729 int ret, i;
730 struct hd29l2_priv *priv = fe->demodulator_priv;
731 u8 tmp;
732 static const struct reg_val tab[] = {
733 { 0x3a, 0x06 },
734 { 0x3b, 0x03 },
735 { 0x3c, 0x04 },
736 { 0xaf, 0x06 },
737 { 0xb0, 0x1b },
738 { 0x80, 0x64 },
739 { 0x10, 0x38 },
740 };
741
742 dev_dbg(&priv->i2c->dev, "%s:\n", __func__);
743
744 /* reset demod */
745 /* it is recommended to HW reset chip using RST_N pin */
746 if (fe->callback) {
747 ret = fe->callback(fe, DVB_FRONTEND_COMPONENT_DEMOD, 0, 0);
748 if (ret)
749 goto err;
750
751 /* reprogramming needed because HW reset clears registers */
752 priv->tuner_i2c_addr_programmed = false;
753 }
754
755 /* init */
756 for (i = 0; i < ARRAY_SIZE(tab); i++) {
757 ret = hd29l2_wr_reg(priv, tab[i].reg, tab[i].val);
758 if (ret)
759 goto err;
760 }
761
762 /* TS params */
763 ret = hd29l2_rd_reg(priv, 0x36, &tmp);
764 if (ret)
765 goto err;
766
767 tmp &= 0x1b;
768 tmp |= priv->cfg.ts_mode;
769 ret = hd29l2_wr_reg(priv, 0x36, tmp);
770 if (ret)
771 goto err;
772
773 ret = hd29l2_rd_reg(priv, 0x31, &tmp);
774 tmp &= 0xef;
775
776 if (!(priv->cfg.ts_mode >> 7))
777 /* set b4 for serial TS */
778 tmp |= 0x10;
779
780 ret = hd29l2_wr_reg(priv, 0x31, tmp);
781 if (ret)
782 goto err;
783
784 return ret;
785err:
786 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
787 return ret;
788}
789
790static void hd29l2_release(struct dvb_frontend *fe)
791{
792 struct hd29l2_priv *priv = fe->demodulator_priv;
793 kfree(priv);
794}
795
796static const struct dvb_frontend_ops hd29l2_ops;
797
798struct dvb_frontend *hd29l2_attach(const struct hd29l2_config *config,
799 struct i2c_adapter *i2c)
800{
801 int ret;
802 struct hd29l2_priv *priv = NULL;
803 u8 tmp;
804
805 /* allocate memory for the internal state */
806 priv = kzalloc(sizeof(struct hd29l2_priv), GFP_KERNEL);
807 if (priv == NULL)
808 goto err;
809
810 /* setup the state */
811 priv->i2c = i2c;
812 memcpy(&priv->cfg, config, sizeof(struct hd29l2_config));
813
814
815 /* check if the demod is there */
816 ret = hd29l2_rd_reg(priv, 0x00, &tmp);
817 if (ret)
818 goto err;
819
820 /* create dvb_frontend */
821 memcpy(&priv->fe.ops, &hd29l2_ops, sizeof(struct dvb_frontend_ops));
822 priv->fe.demodulator_priv = priv;
823
824 return &priv->fe;
825err:
826 kfree(priv);
827 return NULL;
828}
829EXPORT_SYMBOL(hd29l2_attach);
830
831static const struct dvb_frontend_ops hd29l2_ops = {
832 .delsys = { SYS_DVBT },
833 .info = {
834 .name = "HDIC HD29L2 DMB-TH",
835 .frequency_min = 474000000,
836 .frequency_max = 858000000,
837 .frequency_stepsize = 10000,
838 .caps = FE_CAN_FEC_AUTO |
839 FE_CAN_QPSK |
840 FE_CAN_QAM_16 |
841 FE_CAN_QAM_32 |
842 FE_CAN_QAM_64 |
843 FE_CAN_QAM_AUTO |
844 FE_CAN_TRANSMISSION_MODE_AUTO |
845 FE_CAN_BANDWIDTH_AUTO |
846 FE_CAN_GUARD_INTERVAL_AUTO |
847 FE_CAN_HIERARCHY_AUTO |
848 FE_CAN_RECOVER
849 },
850
851 .release = hd29l2_release,
852
853 .init = hd29l2_init,
854
855 .get_frontend_algo = hd29l2_get_frontend_algo,
856 .search = hd29l2_search,
857 .get_frontend = hd29l2_get_frontend,
858
859 .read_status = hd29l2_read_status,
860 .read_snr = hd29l2_read_snr,
861 .read_signal_strength = hd29l2_read_signal_strength,
862 .read_ber = hd29l2_read_ber,
863 .read_ucblocks = hd29l2_read_ucblocks,
864
865 .i2c_gate_ctrl = hd29l2_i2c_gate_ctrl,
866};
867
868MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
869MODULE_DESCRIPTION("HDIC HD29L2 DMB-TH demodulator driver");
870MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/hd29l2.h b/drivers/media/dvb-frontends/hd29l2.h
deleted file mode 100644
index a14d6f36dbf6..000000000000
--- a/drivers/media/dvb-frontends/hd29l2.h
+++ /dev/null
@@ -1,65 +0,0 @@
1/*
2 * HDIC HD29L2 DMB-TH demodulator driver
3 *
4 * Copyright (C) 2011 Metropolia University of Applied Sciences, Electria R&D
5 *
6 * Author: Antti Palosaari <crope@iki.fi>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (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 General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#ifndef HD29L2_H
24#define HD29L2_H
25
26#include <linux/dvb/frontend.h>
27
28struct hd29l2_config {
29 /*
30 * demodulator I2C address
31 */
32 u8 i2c_addr;
33
34 /*
35 * tuner I2C address
36 * only needed when tuner is behind demod I2C-gate
37 */
38 u8 tuner_i2c_addr;
39
40 /*
41 * TS settings
42 */
43#define HD29L2_TS_SERIAL 0x00
44#define HD29L2_TS_PARALLEL 0x80
45#define HD29L2_TS_CLK_NORMAL 0x40
46#define HD29L2_TS_CLK_INVERTED 0x00
47#define HD29L2_TS_CLK_GATED 0x20
48#define HD29L2_TS_CLK_FREE 0x00
49 u8 ts_mode;
50};
51
52
53#if IS_REACHABLE(CONFIG_DVB_HD29L2)
54extern struct dvb_frontend *hd29l2_attach(const struct hd29l2_config *config,
55 struct i2c_adapter *i2c);
56#else
57static inline struct dvb_frontend *hd29l2_attach(
58const struct hd29l2_config *config, struct i2c_adapter *i2c)
59{
60 pr_warn("%s: driver disabled by Kconfig\n", __func__);
61 return NULL;
62}
63#endif
64
65#endif /* HD29L2_H */
diff --git a/drivers/media/dvb-frontends/hd29l2_priv.h b/drivers/media/dvb-frontends/hd29l2_priv.h
deleted file mode 100644
index 6dc225c4bc91..000000000000
--- a/drivers/media/dvb-frontends/hd29l2_priv.h
+++ /dev/null
@@ -1,301 +0,0 @@
1/*
2 * HDIC HD29L2 DMB-TH demodulator driver
3 *
4 * Copyright (C) 2011 Metropolia University of Applied Sciences, Electria R&D
5 *
6 * Author: Antti Palosaari <crope@iki.fi>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (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 General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#ifndef HD29L2_PRIV
24#define HD29L2_PRIV
25
26#include <linux/dvb/version.h>
27#include "dvb_frontend.h"
28#include "dvb_math.h"
29#include "hd29l2.h"
30
31#define HD29L2_XTAL 30400000 /* Hz */
32
33
34#define HD29L2_QAM4NR 0x00
35#define HD29L2_QAM4 0x01
36#define HD29L2_QAM16 0x02
37#define HD29L2_QAM32 0x03
38#define HD29L2_QAM64 0x04
39
40#define HD29L2_CODE_RATE_04 0x00
41#define HD29L2_CODE_RATE_06 0x08
42#define HD29L2_CODE_RATE_08 0x10
43
44#define HD29L2_PN945 0x00
45#define HD29L2_PN595 0x01
46#define HD29L2_PN420 0x02
47
48#define HD29L2_CARRIER_SINGLE 0x00
49#define HD29L2_CARRIER_MULTI 0x01
50
51#define HD29L2_INTERLEAVER_720 0x00
52#define HD29L2_INTERLEAVER_420 0x01
53
54struct reg_val {
55 u8 reg;
56 u8 val;
57};
58
59struct reg_mod_vals {
60 u8 reg;
61 u8 val[5];
62};
63
64struct hd29l2_priv {
65 struct i2c_adapter *i2c;
66 struct dvb_frontend fe;
67 struct hd29l2_config cfg;
68 u8 tuner_i2c_addr_programmed:1;
69
70 enum fe_status fe_status;
71};
72
73static const struct reg_mod_vals reg_mod_vals_tab[] = {
74 /* REG, QAM4NR, QAM4,QAM16,QAM32,QAM64 */
75 { 0x01, { 0x10, 0x10, 0x10, 0x10, 0x10 } },
76 { 0x02, { 0x07, 0x07, 0x07, 0x07, 0x07 } },
77 { 0x03, { 0x10, 0x10, 0x10, 0x10, 0x10 } },
78 { 0x04, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
79 { 0x05, { 0x61, 0x60, 0x60, 0x61, 0x60 } },
80 { 0x06, { 0xff, 0xff, 0xff, 0xff, 0xff } },
81 { 0x07, { 0xff, 0xff, 0xff, 0xff, 0xff } },
82 { 0x08, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
83 { 0x09, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
84 { 0x0a, { 0x15, 0x15, 0x03, 0x03, 0x03 } },
85 { 0x0d, { 0x78, 0x78, 0x88, 0x78, 0x78 } },
86 { 0x0e, { 0xa0, 0x90, 0xa0, 0xa0, 0xa0 } },
87 { 0x0f, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
88 { 0x10, { 0xa0, 0xa0, 0x58, 0x38, 0x38 } },
89 { 0x11, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
90 { 0x12, { 0x5a, 0x5a, 0x5a, 0x5a, 0x5a } },
91 { 0x13, { 0xa2, 0xa2, 0xa2, 0xa2, 0xa2 } },
92 { 0x17, { 0x40, 0x40, 0x40, 0x40, 0x40 } },
93 { 0x18, { 0x21, 0x21, 0x42, 0x52, 0x42 } },
94 { 0x19, { 0x21, 0x21, 0x62, 0x72, 0x62 } },
95 { 0x1a, { 0x32, 0x43, 0xa9, 0xb9, 0xa9 } },
96 { 0x1b, { 0x32, 0x43, 0xb9, 0xd8, 0xb9 } },
97 { 0x1c, { 0x02, 0x02, 0x03, 0x02, 0x03 } },
98 { 0x1d, { 0x0c, 0x0c, 0x01, 0x02, 0x02 } },
99 { 0x1e, { 0x02, 0x02, 0x02, 0x01, 0x02 } },
100 { 0x1f, { 0x02, 0x02, 0x01, 0x02, 0x04 } },
101 { 0x20, { 0x01, 0x02, 0x01, 0x01, 0x01 } },
102 { 0x21, { 0x08, 0x08, 0x0a, 0x0a, 0x0a } },
103 { 0x22, { 0x06, 0x06, 0x04, 0x05, 0x05 } },
104 { 0x23, { 0x06, 0x06, 0x05, 0x03, 0x05 } },
105 { 0x24, { 0x08, 0x08, 0x05, 0x07, 0x07 } },
106 { 0x25, { 0x16, 0x10, 0x10, 0x0a, 0x10 } },
107 { 0x26, { 0x14, 0x14, 0x04, 0x04, 0x04 } },
108 { 0x27, { 0x58, 0x58, 0x58, 0x5c, 0x58 } },
109 { 0x28, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
110 { 0x29, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
111 { 0x2a, { 0x08, 0x0a, 0x08, 0x08, 0x08 } },
112 { 0x2b, { 0x08, 0x08, 0x08, 0x08, 0x08 } },
113 { 0x2c, { 0x06, 0x06, 0x06, 0x06, 0x06 } },
114 { 0x2d, { 0x05, 0x06, 0x06, 0x06, 0x06 } },
115 { 0x2e, { 0x21, 0x21, 0x21, 0x21, 0x21 } },
116 { 0x2f, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
117 { 0x30, { 0x14, 0x14, 0x14, 0x14, 0x14 } },
118 { 0x33, { 0xb7, 0xb7, 0xb7, 0xb7, 0xb7 } },
119 { 0x34, { 0x81, 0x81, 0x81, 0x81, 0x81 } },
120 { 0x35, { 0x80, 0x80, 0x80, 0x80, 0x80 } },
121 { 0x37, { 0x70, 0x70, 0x70, 0x70, 0x70 } },
122 { 0x38, { 0x04, 0x04, 0x02, 0x02, 0x02 } },
123 { 0x39, { 0x07, 0x07, 0x05, 0x05, 0x05 } },
124 { 0x3a, { 0x06, 0x06, 0x06, 0x06, 0x06 } },
125 { 0x3b, { 0x03, 0x03, 0x03, 0x03, 0x03 } },
126 { 0x3c, { 0x07, 0x06, 0x04, 0x04, 0x04 } },
127 { 0x3d, { 0xf0, 0xf0, 0xf0, 0xf0, 0x80 } },
128 { 0x3e, { 0x60, 0x60, 0x60, 0x60, 0xff } },
129 { 0x3f, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
130 { 0x40, { 0x5b, 0x5b, 0x5b, 0x57, 0x50 } },
131 { 0x41, { 0x30, 0x30, 0x30, 0x30, 0x18 } },
132 { 0x42, { 0x20, 0x20, 0x20, 0x00, 0x30 } },
133 { 0x43, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
134 { 0x44, { 0x3f, 0x3f, 0x3f, 0x3f, 0x3f } },
135 { 0x45, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
136 { 0x46, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
137 { 0x47, { 0x00, 0x00, 0x95, 0x00, 0x95 } },
138 { 0x48, { 0xc0, 0xc0, 0xc0, 0xc0, 0xc0 } },
139 { 0x49, { 0xc0, 0xc0, 0xc0, 0xc0, 0xc0 } },
140 { 0x4a, { 0x40, 0x40, 0x33, 0x11, 0x11 } },
141 { 0x4b, { 0x40, 0x40, 0x00, 0x00, 0x00 } },
142 { 0x4c, { 0x40, 0x40, 0x99, 0x11, 0x11 } },
143 { 0x4d, { 0x40, 0x40, 0x00, 0x00, 0x00 } },
144 { 0x4e, { 0x40, 0x40, 0x66, 0x77, 0x77 } },
145 { 0x4f, { 0x40, 0x40, 0x00, 0x00, 0x00 } },
146 { 0x50, { 0x40, 0x40, 0x88, 0x33, 0x11 } },
147 { 0x51, { 0x40, 0x40, 0x00, 0x00, 0x00 } },
148 { 0x52, { 0x40, 0x40, 0x88, 0x02, 0x02 } },
149 { 0x53, { 0x40, 0x40, 0x00, 0x02, 0x02 } },
150 { 0x54, { 0x00, 0x00, 0x88, 0x33, 0x33 } },
151 { 0x55, { 0x40, 0x40, 0x00, 0x00, 0x00 } },
152 { 0x56, { 0x00, 0x00, 0x00, 0x0b, 0x00 } },
153 { 0x57, { 0x40, 0x40, 0x0a, 0x0b, 0x0a } },
154 { 0x58, { 0xaa, 0x00, 0x00, 0x00, 0x00 } },
155 { 0x59, { 0x7a, 0x40, 0x02, 0x02, 0x02 } },
156 { 0x5a, { 0x18, 0x18, 0x01, 0x01, 0x01 } },
157 { 0x5b, { 0x18, 0x18, 0x01, 0x01, 0x01 } },
158 { 0x5c, { 0x18, 0x18, 0x01, 0x01, 0x01 } },
159 { 0x5d, { 0x18, 0x18, 0x01, 0x01, 0x01 } },
160 { 0x5e, { 0xc0, 0xc0, 0xc0, 0xff, 0xc0 } },
161 { 0x5f, { 0xc0, 0xc0, 0xc0, 0xff, 0xc0 } },
162 { 0x60, { 0x40, 0x40, 0x00, 0x30, 0x30 } },
163 { 0x61, { 0x40, 0x40, 0x10, 0x30, 0x30 } },
164 { 0x62, { 0x40, 0x40, 0x00, 0x30, 0x30 } },
165 { 0x63, { 0x40, 0x40, 0x05, 0x30, 0x30 } },
166 { 0x64, { 0x40, 0x40, 0x06, 0x00, 0x30 } },
167 { 0x65, { 0x40, 0x40, 0x06, 0x08, 0x30 } },
168 { 0x66, { 0x40, 0x40, 0x00, 0x00, 0x20 } },
169 { 0x67, { 0x40, 0x40, 0x01, 0x04, 0x20 } },
170 { 0x68, { 0x00, 0x00, 0x30, 0x00, 0x20 } },
171 { 0x69, { 0xa0, 0xa0, 0x00, 0x08, 0x20 } },
172 { 0x6a, { 0x00, 0x00, 0x30, 0x00, 0x25 } },
173 { 0x6b, { 0xa0, 0xa0, 0x00, 0x06, 0x25 } },
174 { 0x6c, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
175 { 0x6d, { 0xa0, 0x60, 0x0c, 0x03, 0x0c } },
176 { 0x6e, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
177 { 0x6f, { 0xa0, 0x60, 0x04, 0x01, 0x04 } },
178 { 0x70, { 0x58, 0x58, 0xaa, 0xaa, 0xaa } },
179 { 0x71, { 0x58, 0x58, 0xaa, 0xaa, 0xaa } },
180 { 0x72, { 0x58, 0x58, 0xff, 0xff, 0xff } },
181 { 0x73, { 0x58, 0x58, 0xff, 0xff, 0xff } },
182 { 0x74, { 0x06, 0x06, 0x09, 0x05, 0x05 } },
183 { 0x75, { 0x06, 0x06, 0x0a, 0x10, 0x10 } },
184 { 0x76, { 0x10, 0x10, 0x06, 0x0a, 0x0a } },
185 { 0x77, { 0x12, 0x18, 0x28, 0x10, 0x28 } },
186 { 0x78, { 0xf8, 0xf8, 0xf8, 0xf8, 0xf8 } },
187 { 0x79, { 0x15, 0x15, 0x03, 0x03, 0x03 } },
188 { 0x7a, { 0x02, 0x02, 0x01, 0x04, 0x03 } },
189 { 0x7b, { 0x01, 0x02, 0x03, 0x03, 0x03 } },
190 { 0x7c, { 0x28, 0x28, 0x28, 0x28, 0x28 } },
191 { 0x7f, { 0x25, 0x92, 0x5f, 0x17, 0x2d } },
192 { 0x80, { 0x64, 0x64, 0x64, 0x74, 0x64 } },
193 { 0x83, { 0x06, 0x03, 0x04, 0x04, 0x04 } },
194 { 0x84, { 0xff, 0xff, 0xff, 0xff, 0xff } },
195 { 0x85, { 0x05, 0x05, 0x05, 0x05, 0x05 } },
196 { 0x86, { 0x00, 0x00, 0x11, 0x11, 0x11 } },
197 { 0x87, { 0x03, 0x03, 0x03, 0x03, 0x03 } },
198 { 0x88, { 0x09, 0x09, 0x09, 0x09, 0x09 } },
199 { 0x89, { 0x20, 0x20, 0x30, 0x20, 0x20 } },
200 { 0x8a, { 0x03, 0x03, 0x02, 0x03, 0x02 } },
201 { 0x8b, { 0x00, 0x07, 0x09, 0x00, 0x09 } },
202 { 0x8c, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
203 { 0x8d, { 0x4f, 0x4f, 0x4f, 0x3f, 0x4f } },
204 { 0x8e, { 0xf0, 0xf0, 0x60, 0xf0, 0xa0 } },
205 { 0x8f, { 0xe8, 0xe8, 0xe8, 0xe8, 0xe8 } },
206 { 0x90, { 0x10, 0x10, 0x10, 0x10, 0x10 } },
207 { 0x91, { 0x40, 0x40, 0x70, 0x70, 0x10 } },
208 { 0x92, { 0x00, 0x00, 0x00, 0x00, 0x04 } },
209 { 0x93, { 0x60, 0x60, 0x60, 0x60, 0x60 } },
210 { 0x94, { 0x00, 0x00, 0x00, 0x00, 0x03 } },
211 { 0x95, { 0x09, 0x09, 0x47, 0x47, 0x47 } },
212 { 0x96, { 0x80, 0xa0, 0xa0, 0x40, 0xa0 } },
213 { 0x97, { 0x60, 0x60, 0x60, 0x60, 0x60 } },
214 { 0x98, { 0x50, 0x50, 0x50, 0x30, 0x50 } },
215 { 0x99, { 0x10, 0x10, 0x10, 0x10, 0x10 } },
216 { 0x9a, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
217 { 0x9b, { 0x40, 0x40, 0x40, 0x30, 0x40 } },
218 { 0x9c, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
219 { 0xa0, { 0xf0, 0xf0, 0xf0, 0xf0, 0xf0 } },
220 { 0xa1, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
221 { 0xa2, { 0x30, 0x30, 0x00, 0x30, 0x00 } },
222 { 0xa3, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
223 { 0xa4, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
224 { 0xa5, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
225 { 0xa6, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
226 { 0xa7, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
227 { 0xa8, { 0x77, 0x77, 0x77, 0x77, 0x77 } },
228 { 0xa9, { 0x02, 0x02, 0x02, 0x02, 0x02 } },
229 { 0xaa, { 0x40, 0x40, 0x40, 0x40, 0x40 } },
230 { 0xac, { 0x1f, 0x1f, 0x1f, 0x1f, 0x1f } },
231 { 0xad, { 0x14, 0x14, 0x14, 0x14, 0x14 } },
232 { 0xae, { 0x78, 0x78, 0x78, 0x78, 0x78 } },
233 { 0xaf, { 0x06, 0x06, 0x06, 0x06, 0x07 } },
234 { 0xb0, { 0x1b, 0x1b, 0x1b, 0x19, 0x1b } },
235 { 0xb1, { 0x18, 0x17, 0x17, 0x18, 0x17 } },
236 { 0xb2, { 0x35, 0x82, 0x82, 0x38, 0x82 } },
237 { 0xb3, { 0xb6, 0xce, 0xc7, 0x5c, 0xb0 } },
238 { 0xb4, { 0x3f, 0x3e, 0x3e, 0x3f, 0x3e } },
239 { 0xb5, { 0x70, 0x58, 0x50, 0x68, 0x50 } },
240 { 0xb6, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
241 { 0xb7, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
242 { 0xb8, { 0x03, 0x03, 0x01, 0x01, 0x01 } },
243 { 0xb9, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
244 { 0xba, { 0x06, 0x06, 0x0a, 0x05, 0x0a } },
245 { 0xbb, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
246 { 0xbc, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
247 { 0xbd, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
248 { 0xbe, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
249 { 0xbf, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
250 { 0xc0, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
251 { 0xc1, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
252 { 0xc2, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
253 { 0xc3, { 0x00, 0x00, 0x88, 0x66, 0x88 } },
254 { 0xc4, { 0x10, 0x10, 0x00, 0x00, 0x00 } },
255 { 0xc5, { 0x00, 0x00, 0x44, 0x60, 0x44 } },
256 { 0xc6, { 0x10, 0x0a, 0x00, 0x00, 0x00 } },
257 { 0xc7, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
258 { 0xc8, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
259 { 0xc9, { 0x90, 0x04, 0x00, 0x00, 0x00 } },
260 { 0xca, { 0x90, 0x08, 0x01, 0x01, 0x01 } },
261 { 0xcb, { 0xa0, 0x04, 0x00, 0x44, 0x00 } },
262 { 0xcc, { 0xa0, 0x10, 0x03, 0x00, 0x03 } },
263 { 0xcd, { 0x06, 0x06, 0x06, 0x05, 0x06 } },
264 { 0xce, { 0x05, 0x05, 0x01, 0x01, 0x01 } },
265 { 0xcf, { 0x40, 0x20, 0x18, 0x18, 0x18 } },
266 { 0xd0, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
267 { 0xd1, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
268 { 0xd2, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
269 { 0xd3, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
270 { 0xd4, { 0x05, 0x05, 0x05, 0x05, 0x05 } },
271 { 0xd5, { 0x05, 0x05, 0x05, 0x03, 0x05 } },
272 { 0xd6, { 0xac, 0x22, 0xca, 0x8f, 0xca } },
273 { 0xd7, { 0x20, 0x20, 0x20, 0x20, 0x20 } },
274 { 0xd8, { 0x01, 0x01, 0x01, 0x01, 0x01 } },
275 { 0xd9, { 0x00, 0x00, 0x0f, 0x00, 0x0f } },
276 { 0xda, { 0x00, 0xff, 0xff, 0x0e, 0xff } },
277 { 0xdb, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
278 { 0xdc, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
279 { 0xdd, { 0x05, 0x05, 0x05, 0x05, 0x05 } },
280 { 0xde, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
281 { 0xdf, { 0x42, 0x42, 0x44, 0x44, 0x04 } },
282 { 0xe0, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
283 { 0xe1, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
284 { 0xe2, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
285 { 0xe3, { 0x00, 0x00, 0x26, 0x06, 0x26 } },
286 { 0xe4, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
287 { 0xe5, { 0x01, 0x0a, 0x01, 0x01, 0x01 } },
288 { 0xe6, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
289 { 0xe7, { 0x08, 0x08, 0x08, 0x08, 0x08 } },
290 { 0xe8, { 0x63, 0x63, 0x63, 0x63, 0x63 } },
291 { 0xe9, { 0x59, 0x59, 0x59, 0x59, 0x59 } },
292 { 0xea, { 0x80, 0x80, 0x20, 0x80, 0x80 } },
293 { 0xeb, { 0x37, 0x37, 0x78, 0x37, 0x77 } },
294 { 0xec, { 0x1f, 0x1f, 0x25, 0x25, 0x25 } },
295 { 0xed, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
296 { 0xee, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
297 { 0xef, { 0x70, 0x70, 0x58, 0x38, 0x58 } },
298 { 0xf0, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
299};
300
301#endif /* HD29L2_PRIV */
diff --git a/drivers/media/dvb-frontends/isl6405.c b/drivers/media/dvb-frontends/isl6405.c
index 6913cd687b4d..2fc8d3c72c11 100644
--- a/drivers/media/dvb-frontends/isl6405.c
+++ b/drivers/media/dvb-frontends/isl6405.c
@@ -15,11 +15,8 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * 18 * To obtain the license, point your browser to
19 * You should have received a copy of the GNU General Public License 19 * http://www.gnu.org/copyleft/gpl.html
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
23 * 20 *
24 * 21 *
25 * the project's page is at https://linuxtv.org 22 * the project's page is at https://linuxtv.org
diff --git a/drivers/media/dvb-frontends/isl6405.h b/drivers/media/dvb-frontends/isl6405.h
index 4a23d3bdf3e6..18fe714f9999 100644
--- a/drivers/media/dvb-frontends/isl6405.h
+++ b/drivers/media/dvb-frontends/isl6405.h
@@ -15,11 +15,8 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * 18 * To obtain the license, point your browser to
19 * You should have received a copy of the GNU General Public License 19 * http://www.gnu.org/copyleft/gpl.html
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
23 * 20 *
24 * 21 *
25 * the project's page is at https://linuxtv.org 22 * the project's page is at https://linuxtv.org
diff --git a/drivers/media/dvb-frontends/isl6421.c b/drivers/media/dvb-frontends/isl6421.c
index 0b6d3837d5de..838b42771a05 100644
--- a/drivers/media/dvb-frontends/isl6421.c
+++ b/drivers/media/dvb-frontends/isl6421.c
@@ -15,11 +15,8 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * 18 * To obtain the license, point your browser to
19 * You should have received a copy of the GNU General Public License 19 * http://www.gnu.org/copyleft/gpl.html
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
23 * 20 *
24 * 21 *
25 * the project's page is at https://linuxtv.org 22 * the project's page is at https://linuxtv.org
diff --git a/drivers/media/dvb-frontends/isl6421.h b/drivers/media/dvb-frontends/isl6421.h
index 00f9874ca5a2..4deeddec5140 100644
--- a/drivers/media/dvb-frontends/isl6421.h
+++ b/drivers/media/dvb-frontends/isl6421.h
@@ -15,11 +15,8 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * 18 * To obtain the license, point your browser to
19 * You should have received a copy of the GNU General Public License 19 * http://www.gnu.org/copyleft/gpl.html
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
23 * 20 *
24 * 21 *
25 * the project's page is at https://linuxtv.org 22 * the project's page is at https://linuxtv.org
diff --git a/drivers/media/dvb-frontends/itd1000.c b/drivers/media/dvb-frontends/itd1000.c
index 475525134327..5bb1e73a10b4 100644
--- a/drivers/media/dvb-frontends/itd1000.c
+++ b/drivers/media/dvb-frontends/itd1000.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */ 16 */
21 17
22#include <linux/module.h> 18#include <linux/module.h>
diff --git a/drivers/media/dvb-frontends/itd1000.h b/drivers/media/dvb-frontends/itd1000.h
index a691bb6f26de..f8a2256a0b36 100644
--- a/drivers/media/dvb-frontends/itd1000.h
+++ b/drivers/media/dvb-frontends/itd1000.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */ 16 */
21 17
22#ifndef ITD1000_H 18#ifndef ITD1000_H
diff --git a/drivers/media/dvb-frontends/itd1000_priv.h b/drivers/media/dvb-frontends/itd1000_priv.h
index 08ca851223c9..6c99d95d1056 100644
--- a/drivers/media/dvb-frontends/itd1000_priv.h
+++ b/drivers/media/dvb-frontends/itd1000_priv.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */ 16 */
21 17
22#ifndef ITD1000_PRIV_H 18#ifndef ITD1000_PRIV_H
diff --git a/drivers/media/dvb-frontends/ix2505v.c b/drivers/media/dvb-frontends/ix2505v.c
index ca371680a69f..534b24fa2b95 100644
--- a/drivers/media/dvb-frontends/ix2505v.c
+++ b/drivers/media/dvb-frontends/ix2505v.c
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 *
19 */ 15 */
20 16
21#include <linux/module.h> 17#include <linux/module.h>
diff --git a/drivers/media/dvb-frontends/ix2505v.h b/drivers/media/dvb-frontends/ix2505v.h
index 5eab39744b23..0b0a431c74f6 100644
--- a/drivers/media/dvb-frontends/ix2505v.h
+++ b/drivers/media/dvb-frontends/ix2505v.h
@@ -11,10 +11,6 @@
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 14 */
19 15
20#ifndef DVB_IX2505V_H 16#ifndef DVB_IX2505V_H
diff --git a/drivers/media/dvb-frontends/lg2160.c b/drivers/media/dvb-frontends/lg2160.c
index 3b31e5f20f46..5798079add10 100644
--- a/drivers/media/dvb-frontends/lg2160.c
+++ b/drivers/media/dvb-frontends/lg2160.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */ 16 */
21 17
22#include <linux/jiffies.h> 18#include <linux/jiffies.h>
diff --git a/drivers/media/dvb-frontends/lg2160.h b/drivers/media/dvb-frontends/lg2160.h
index 8c74ddc6b88a..ba99125deac0 100644
--- a/drivers/media/dvb-frontends/lg2160.h
+++ b/drivers/media/dvb-frontends/lg2160.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */ 16 */
21 17
22#ifndef _LG2160_H_ 18#ifndef _LG2160_H_
diff --git a/drivers/media/dvb-frontends/lgdt3305.c b/drivers/media/dvb-frontends/lgdt3305.c
index 9f5d9380bf5f..0af4d9104761 100644
--- a/drivers/media/dvb-frontends/lgdt3305.c
+++ b/drivers/media/dvb-frontends/lgdt3305.c
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 */ 18 */
23 19
24#include <asm/div64.h> 20#include <asm/div64.h>
diff --git a/drivers/media/dvb-frontends/lgdt3305.h b/drivers/media/dvb-frontends/lgdt3305.h
index e7dceb60e572..2fb60d91f7b4 100644
--- a/drivers/media/dvb-frontends/lgdt3305.h
+++ b/drivers/media/dvb-frontends/lgdt3305.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */ 16 */
21 17
22#ifndef _LGDT3305_H_ 18#ifndef _LGDT3305_H_
diff --git a/drivers/media/dvb-frontends/lgdt3306a.c b/drivers/media/dvb-frontends/lgdt3306a.c
index 19dca46b1171..c9b1eb38444e 100644
--- a/drivers/media/dvb-frontends/lgdt3306a.c
+++ b/drivers/media/dvb-frontends/lgdt3306a.c
@@ -22,6 +22,7 @@
22#include <linux/dvb/frontend.h> 22#include <linux/dvb/frontend.h>
23#include "dvb_math.h" 23#include "dvb_math.h"
24#include "lgdt3306a.h" 24#include "lgdt3306a.h"
25#include <linux/i2c-mux.h>
25 26
26 27
27static int debug; 28static int debug;
@@ -65,6 +66,8 @@ struct lgdt3306a_state {
65 enum fe_modulation current_modulation; 66 enum fe_modulation current_modulation;
66 u32 current_frequency; 67 u32 current_frequency;
67 u32 snr; 68 u32 snr;
69
70 struct i2c_mux_core *muxc;
68}; 71};
69 72
70/* 73/*
@@ -2131,6 +2134,111 @@ static const struct dvb_frontend_ops lgdt3306a_ops = {
2131 .search = lgdt3306a_search, 2134 .search = lgdt3306a_search,
2132}; 2135};
2133 2136
2137static int lgdt3306a_select(struct i2c_mux_core *muxc, u32 chan)
2138{
2139 struct i2c_client *client = i2c_mux_priv(muxc);
2140 struct lgdt3306a_state *state = i2c_get_clientdata(client);
2141
2142 return lgdt3306a_i2c_gate_ctrl(&state->frontend, 1);
2143}
2144
2145static int lgdt3306a_deselect(struct i2c_mux_core *muxc, u32 chan)
2146{
2147 struct i2c_client *client = i2c_mux_priv(muxc);
2148 struct lgdt3306a_state *state = i2c_get_clientdata(client);
2149
2150 return lgdt3306a_i2c_gate_ctrl(&state->frontend, 0);
2151}
2152
2153static int lgdt3306a_probe(struct i2c_client *client,
2154 const struct i2c_device_id *id)
2155{
2156 struct lgdt3306a_config *config;
2157 struct lgdt3306a_state *state;
2158 struct dvb_frontend *fe;
2159 int ret;
2160
2161 config = kzalloc(sizeof(struct lgdt3306a_config), GFP_KERNEL);
2162 if (config == NULL) {
2163 ret = -ENOMEM;
2164 goto fail;
2165 }
2166
2167 memcpy(config, client->dev.platform_data,
2168 sizeof(struct lgdt3306a_config));
2169
2170 config->i2c_addr = client->addr;
2171 fe = lgdt3306a_attach(config, client->adapter);
2172 if (fe == NULL) {
2173 ret = -ENODEV;
2174 goto err_fe;
2175 }
2176
2177 i2c_set_clientdata(client, fe->demodulator_priv);
2178 state = fe->demodulator_priv;
2179
2180 /* create mux i2c adapter for tuner */
2181 state->muxc = i2c_mux_alloc(client->adapter, &client->dev,
2182 1, 0, I2C_MUX_LOCKED,
2183 lgdt3306a_select, lgdt3306a_deselect);
2184 if (!state->muxc) {
2185 ret = -ENOMEM;
2186 goto err_kfree;
2187 }
2188 state->muxc->priv = client;
2189 ret = i2c_mux_add_adapter(state->muxc, 0, 0, 0);
2190 if (ret)
2191 goto err_kfree;
2192
2193 /* create dvb_frontend */
2194 fe->ops.i2c_gate_ctrl = NULL;
2195 *config->i2c_adapter = state->muxc->adapter[0];
2196 *config->fe = fe;
2197
2198 return 0;
2199
2200err_kfree:
2201 kfree(state);
2202err_fe:
2203 kfree(config);
2204fail:
2205 dev_dbg(&client->dev, "failed=%d\n", ret);
2206 return ret;
2207}
2208
2209static int lgdt3306a_remove(struct i2c_client *client)
2210{
2211 struct lgdt3306a_state *state = i2c_get_clientdata(client);
2212
2213 i2c_mux_del_adapters(state->muxc);
2214
2215 state->frontend.ops.release = NULL;
2216 state->frontend.demodulator_priv = NULL;
2217
2218 kfree(state->cfg);
2219 kfree(state);
2220
2221 return 0;
2222}
2223
2224static const struct i2c_device_id lgdt3306a_id_table[] = {
2225 {"lgdt3306a", 0},
2226 {}
2227};
2228MODULE_DEVICE_TABLE(i2c, lgdt3306a_id_table);
2229
2230static struct i2c_driver lgdt3306a_driver = {
2231 .driver = {
2232 .name = "lgdt3306a",
2233 .suppress_bind_attrs = true,
2234 },
2235 .probe = lgdt3306a_probe,
2236 .remove = lgdt3306a_remove,
2237 .id_table = lgdt3306a_id_table,
2238};
2239
2240module_i2c_driver(lgdt3306a_driver);
2241
2134MODULE_DESCRIPTION("LG Electronics LGDT3306A ATSC/QAM-B Demodulator Driver"); 2242MODULE_DESCRIPTION("LG Electronics LGDT3306A ATSC/QAM-B Demodulator Driver");
2135MODULE_AUTHOR("Fred Richter <frichter@hauppauge.com>"); 2243MODULE_AUTHOR("Fred Richter <frichter@hauppauge.com>");
2136MODULE_LICENSE("GPL"); 2244MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/lgdt3306a.h b/drivers/media/dvb-frontends/lgdt3306a.h
index 9dbb2dced1fe..6ce337ec5272 100644
--- a/drivers/media/dvb-frontends/lgdt3306a.h
+++ b/drivers/media/dvb-frontends/lgdt3306a.h
@@ -56,6 +56,10 @@ struct lgdt3306a_config {
56 56
57 /* demod clock freq in MHz; 24 or 25 supported */ 57 /* demod clock freq in MHz; 24 or 25 supported */
58 int xtalMHz; 58 int xtalMHz;
59
60 /* returned by driver if using i2c bus multiplexing */
61 struct dvb_frontend **fe;
62 struct i2c_adapter **i2c_adapter;
59}; 63};
60 64
61#if IS_REACHABLE(CONFIG_DVB_LGDT3306A) 65#if IS_REACHABLE(CONFIG_DVB_LGDT3306A)
diff --git a/drivers/media/dvb-frontends/lgdt330x.c b/drivers/media/dvb-frontends/lgdt330x.c
index 2f4a0316f89c..06f47dc8cd3d 100644
--- a/drivers/media/dvb-frontends/lgdt330x.c
+++ b/drivers/media/dvb-frontends/lgdt330x.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */ 16 */
21 17
22/* 18/*
diff --git a/drivers/media/dvb-frontends/lgdt330x.h b/drivers/media/dvb-frontends/lgdt330x.h
index c73eeb45e330..61434cbecd2c 100644
--- a/drivers/media/dvb-frontends/lgdt330x.h
+++ b/drivers/media/dvb-frontends/lgdt330x.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */ 16 */
21 17
22#ifndef LGDT330X_H 18#ifndef LGDT330X_H
diff --git a/drivers/media/dvb-frontends/lgdt330x_priv.h b/drivers/media/dvb-frontends/lgdt330x_priv.h
index 1922f09a02d0..dcb9a317eddc 100644
--- a/drivers/media/dvb-frontends/lgdt330x_priv.h
+++ b/drivers/media/dvb-frontends/lgdt330x_priv.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */ 16 */
21 17
22#ifndef _LGDT330X_PRIV_ 18#ifndef _LGDT330X_PRIV_
diff --git a/drivers/media/dvb-frontends/lgs8gxx.c b/drivers/media/dvb-frontends/lgs8gxx.c
index 6d2e62469d58..e6bf60e1138c 100644
--- a/drivers/media/dvb-frontends/lgs8gxx.c
+++ b/drivers/media/dvb-frontends/lgs8gxx.c
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 */ 20 */
25 21
26#include <asm/div64.h> 22#include <asm/div64.h>
diff --git a/drivers/media/dvb-frontends/lgs8gxx.h b/drivers/media/dvb-frontends/lgs8gxx.h
index 7519c0210399..aa83ea46807b 100644
--- a/drivers/media/dvb-frontends/lgs8gxx.h
+++ b/drivers/media/dvb-frontends/lgs8gxx.h
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 */ 20 */
25 21
26#ifndef __LGS8GXX_H__ 22#ifndef __LGS8GXX_H__
diff --git a/drivers/media/dvb-frontends/lgs8gxx_priv.h b/drivers/media/dvb-frontends/lgs8gxx_priv.h
index 8ef376f1414d..42ecbbd14c90 100644
--- a/drivers/media/dvb-frontends/lgs8gxx_priv.h
+++ b/drivers/media/dvb-frontends/lgs8gxx_priv.h
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 */ 20 */
25 21
26#ifndef LGS8913_PRIV_H 22#ifndef LGS8913_PRIV_H
diff --git a/drivers/media/dvb-frontends/lnbh24.h b/drivers/media/dvb-frontends/lnbh24.h
index 24431dfdce1f..332d639025ba 100644
--- a/drivers/media/dvb-frontends/lnbh24.h
+++ b/drivers/media/dvb-frontends/lnbh24.h
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * 15 *
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#ifndef _LNBH24_H 19#ifndef _LNBH24_H
diff --git a/drivers/media/dvb-frontends/lnbp21.c b/drivers/media/dvb-frontends/lnbp21.c
index 6261460d93a7..392d7be93774 100644
--- a/drivers/media/dvb-frontends/lnbp21.c
+++ b/drivers/media/dvb-frontends/lnbp21.c
@@ -15,11 +15,8 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * 18 * To obtain the license, point your browser to
19 * You should have received a copy of the GNU General Public License 19 * http://www.gnu.org/copyleft/gpl.html
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
23 * 20 *
24 * 21 *
25 * the project's page is at https://linuxtv.org 22 * the project's page is at https://linuxtv.org
diff --git a/drivers/media/dvb-frontends/lnbp21.h b/drivers/media/dvb-frontends/lnbp21.h
index 4bb6439068ec..ee9d050ddc04 100644
--- a/drivers/media/dvb-frontends/lnbp21.h
+++ b/drivers/media/dvb-frontends/lnbp21.h
@@ -14,11 +14,8 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * 17 * To obtain the license, point your browser to
18 * You should have received a copy of the GNU General Public License 18 * http://www.gnu.org/copyleft/gpl.html
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 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
22 * 19 *
23 * 20 *
24 * the project's page is at https://linuxtv.org 21 * the project's page is at https://linuxtv.org
diff --git a/drivers/media/dvb-frontends/lnbp22.c b/drivers/media/dvb-frontends/lnbp22.c
index 5c5fd04fd4a7..39326a2ebab2 100644
--- a/drivers/media/dvb-frontends/lnbp22.c
+++ b/drivers/media/dvb-frontends/lnbp22.c
@@ -15,11 +15,8 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * 18 * To obtain the license, point your browser to
19 * You should have received a copy of the GNU General Public License 19 * http://www.gnu.org/copyleft/gpl.html
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
23 * 20 *
24 * 21 *
25 * the project's page is at https://linuxtv.org 22 * the project's page is at https://linuxtv.org
diff --git a/drivers/media/dvb-frontends/lnbp22.h b/drivers/media/dvb-frontends/lnbp22.h
index 0cb72126c498..f4c59ff7b7ca 100644
--- a/drivers/media/dvb-frontends/lnbp22.h
+++ b/drivers/media/dvb-frontends/lnbp22.h
@@ -15,11 +15,8 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * 18 * To obtain the license, point your browser to
19 * You should have received a copy of the GNU General Public License 19 * http://www.gnu.org/copyleft/gpl.html
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
23 * 20 *
24 * 21 *
25 * the project's page is at https://linuxtv.org 22 * the project's page is at https://linuxtv.org
diff --git a/drivers/media/dvb-frontends/mn88473.c b/drivers/media/dvb-frontends/mn88473.c
index c221c7d2ac3e..15874244fd8b 100644
--- a/drivers/media/dvb-frontends/mn88473.c
+++ b/drivers/media/dvb-frontends/mn88473.c
@@ -223,6 +223,13 @@ static int mn88473_set_frontend(struct dvb_frontend *fe)
223 if (ret) 223 if (ret)
224 goto err; 224 goto err;
225 225
226 /* PLP */
227 if (c->delivery_system == SYS_DVBT2) {
228 ret = regmap_write(dev->regmap[2], 0x36, c->stream_id);
229 if (ret)
230 goto err;
231 }
232
226 /* Reset FSM */ 233 /* Reset FSM */
227 ret = regmap_write(dev->regmap[2], 0xf8, 0x9f); 234 ret = regmap_write(dev->regmap[2], 0xf8, 0x9f);
228 if (ret) 235 if (ret)
@@ -592,7 +599,8 @@ static const struct dvb_frontend_ops mn88473_ops = {
592 FE_CAN_GUARD_INTERVAL_AUTO | 599 FE_CAN_GUARD_INTERVAL_AUTO |
593 FE_CAN_HIERARCHY_AUTO | 600 FE_CAN_HIERARCHY_AUTO |
594 FE_CAN_MUTE_TS | 601 FE_CAN_MUTE_TS |
595 FE_CAN_2G_MODULATION 602 FE_CAN_2G_MODULATION |
603 FE_CAN_MULTISTREAM
596 }, 604 },
597 605
598 .get_tune_settings = mn88473_get_tune_settings, 606 .get_tune_settings = mn88473_get_tune_settings,
diff --git a/drivers/media/dvb-frontends/mt352.c b/drivers/media/dvb-frontends/mt352.c
index 48ea0408f02a..e127090f2d22 100644
--- a/drivers/media/dvb-frontends/mt352.c
+++ b/drivers/media/dvb-frontends/mt352.c
@@ -24,10 +24,6 @@
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * 25 *
26 * GNU General Public License for more details. 26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
31 */ 27 */
32 28
33#include <linux/kernel.h> 29#include <linux/kernel.h>
diff --git a/drivers/media/dvb-frontends/mt352.h b/drivers/media/dvb-frontends/mt352.h
index 5873263bd1af..b4c03b7405fb 100644
--- a/drivers/media/dvb-frontends/mt352.h
+++ b/drivers/media/dvb-frontends/mt352.h
@@ -24,10 +24,6 @@
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * 25 *
26 * GNU General Public License for more details. 26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
31 */ 27 */
32 28
33#ifndef MT352_H 29#ifndef MT352_H
diff --git a/drivers/media/dvb-frontends/mt352_priv.h b/drivers/media/dvb-frontends/mt352_priv.h
index 44ad0d4c8f12..79bbb894b287 100644
--- a/drivers/media/dvb-frontends/mt352_priv.h
+++ b/drivers/media/dvb-frontends/mt352_priv.h
@@ -24,10 +24,6 @@
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * 25 *
26 * GNU General Public License for more details. 26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
31 */ 27 */
32 28
33#ifndef _MT352_PRIV_ 29#ifndef _MT352_PRIV_
diff --git a/drivers/media/dvb-frontends/nxt200x.c b/drivers/media/dvb-frontends/nxt200x.c
index 2fe40372ca07..bf6e5cd572c5 100644
--- a/drivers/media/dvb-frontends/nxt200x.c
+++ b/drivers/media/dvb-frontends/nxt200x.c
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23*/ 19*/
24 20
25/* 21/*
diff --git a/drivers/media/dvb-frontends/nxt200x.h b/drivers/media/dvb-frontends/nxt200x.h
index 825b928ef542..360320645913 100644
--- a/drivers/media/dvb-frontends/nxt200x.h
+++ b/drivers/media/dvb-frontends/nxt200x.h
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22*/ 18*/
23 19
24#ifndef NXT200X_H 20#ifndef NXT200X_H
diff --git a/drivers/media/dvb-frontends/or51132.c b/drivers/media/dvb-frontends/or51132.c
index 17bdadd7d0e1..4b67d7e0116d 100644
--- a/drivers/media/dvb-frontends/or51132.c
+++ b/drivers/media/dvb-frontends/or51132.c
@@ -19,10 +19,6 @@
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *
26*/ 22*/
27 23
28/* 24/*
diff --git a/drivers/media/dvb-frontends/or51132.h b/drivers/media/dvb-frontends/or51132.h
index 9acf8dc87413..96b70e78e30a 100644
--- a/drivers/media/dvb-frontends/or51132.h
+++ b/drivers/media/dvb-frontends/or51132.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20*/ 16*/
21 17
22#ifndef OR51132_H 18#ifndef OR51132_H
diff --git a/drivers/media/dvb-frontends/or51211.c b/drivers/media/dvb-frontends/or51211.c
index 27eb73aa4f62..d14fa9736ae5 100644
--- a/drivers/media/dvb-frontends/or51211.c
+++ b/drivers/media/dvb-frontends/or51211.c
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23*/ 19*/
24 20
25#define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__ 21#define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
diff --git a/drivers/media/dvb-frontends/or51211.h b/drivers/media/dvb-frontends/or51211.h
index cc6adab63249..03b476982ad0 100644
--- a/drivers/media/dvb-frontends/or51211.h
+++ b/drivers/media/dvb-frontends/or51211.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20*/ 16*/
21 17
22#ifndef OR51211_H 18#ifndef OR51211_H
diff --git a/drivers/media/dvb-frontends/rtl2832_sdr.c b/drivers/media/dvb-frontends/rtl2832_sdr.c
index e038e886731b..c6e78d870ccd 100644
--- a/drivers/media/dvb-frontends/rtl2832_sdr.c
+++ b/drivers/media/dvb-frontends/rtl2832_sdr.c
@@ -956,7 +956,7 @@ static void rtl2832_sdr_stop_streaming(struct vb2_queue *vq)
956 mutex_unlock(&dev->v4l2_lock); 956 mutex_unlock(&dev->v4l2_lock);
957} 957}
958 958
959static struct vb2_ops rtl2832_sdr_vb2_ops = { 959static const struct vb2_ops rtl2832_sdr_vb2_ops = {
960 .queue_setup = rtl2832_sdr_queue_setup, 960 .queue_setup = rtl2832_sdr_queue_setup,
961 .buf_prepare = rtl2832_sdr_buf_prepare, 961 .buf_prepare = rtl2832_sdr_buf_prepare,
962 .buf_queue = rtl2832_sdr_buf_queue, 962 .buf_queue = rtl2832_sdr_buf_queue,
diff --git a/drivers/media/dvb-frontends/s5h1420.c b/drivers/media/dvb-frontends/s5h1420.c
index f9a18fe94d88..cba9bff05b12 100644
--- a/drivers/media/dvb-frontends/s5h1420.c
+++ b/drivers/media/dvb-frontends/s5h1420.c
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * 17 *
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */ 19 */
24 20
25#include <linux/kernel.h> 21#include <linux/kernel.h>
diff --git a/drivers/media/dvb-frontends/s5h1420.h b/drivers/media/dvb-frontends/s5h1420.h
index 142d93e7d02b..43d0de6f3a55 100644
--- a/drivers/media/dvb-frontends/s5h1420.h
+++ b/drivers/media/dvb-frontends/s5h1420.h
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * 17 *
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */ 19 */
24#ifndef S5H1420_H 20#ifndef S5H1420_H
25#define S5H1420_H 21#define S5H1420_H
diff --git a/drivers/media/dvb-frontends/s5h1432.c b/drivers/media/dvb-frontends/s5h1432.c
index a32fd9bc51a9..4de50fe0c638 100644
--- a/drivers/media/dvb-frontends/s5h1432.c
+++ b/drivers/media/dvb-frontends/s5h1432.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#include <linux/kernel.h> 17#include <linux/kernel.h>
diff --git a/drivers/media/dvb-frontends/s5h1432.h b/drivers/media/dvb-frontends/s5h1432.h
index b81c9bd4e422..af3a157b5e77 100644
--- a/drivers/media/dvb-frontends/s5h1432.h
+++ b/drivers/media/dvb-frontends/s5h1432.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */ 16 */
21 17
22#ifndef __S5H1432_H__ 18#ifndef __S5H1432_H__
diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c
index 20b4a659e2e4..680ba06c29fb 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -85,7 +85,8 @@ static int si2168_read_status(struct dvb_frontend *fe, enum fe_status *status)
85 struct i2c_client *client = fe->demodulator_priv; 85 struct i2c_client *client = fe->demodulator_priv;
86 struct si2168_dev *dev = i2c_get_clientdata(client); 86 struct si2168_dev *dev = i2c_get_clientdata(client);
87 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 87 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
88 int ret; 88 int ret, i;
89 unsigned int utmp, utmp1, utmp2;
89 struct si2168_cmd cmd; 90 struct si2168_cmd cmd;
90 91
91 *status = 0; 92 *status = 0;
@@ -144,6 +145,61 @@ static int si2168_read_status(struct dvb_frontend *fe, enum fe_status *status)
144 dev_dbg(&client->dev, "status=%02x args=%*ph\n", 145 dev_dbg(&client->dev, "status=%02x args=%*ph\n",
145 *status, cmd.rlen, cmd.args); 146 *status, cmd.rlen, cmd.args);
146 147
148 /* BER */
149 if (*status & FE_HAS_VITERBI) {
150 memcpy(cmd.args, "\x82\x00", 2);
151 cmd.wlen = 2;
152 cmd.rlen = 3;
153 ret = si2168_cmd_execute(client, &cmd);
154 if (ret)
155 goto err;
156
157 /*
158 * Firmware returns [0, 255] mantissa and [0, 8] exponent.
159 * Convert to DVB API: mantissa * 10^(8 - exponent) / 10^8
160 */
161 utmp = clamp(8 - cmd.args[1], 0, 8);
162 for (i = 0, utmp1 = 1; i < utmp; i++)
163 utmp1 = utmp1 * 10;
164
165 utmp1 = cmd.args[2] * utmp1;
166 utmp2 = 100000000; /* 10^8 */
167
168 dev_dbg(&client->dev,
169 "post_bit_error=%u post_bit_count=%u ber=%u*10^-%u\n",
170 utmp1, utmp2, cmd.args[2], cmd.args[1]);
171
172 c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER;
173 c->post_bit_error.stat[0].uvalue += utmp1;
174 c->post_bit_count.stat[0].scale = FE_SCALE_COUNTER;
175 c->post_bit_count.stat[0].uvalue += utmp2;
176 } else {
177 c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
178 c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
179 }
180
181 /* UCB */
182 if (*status & FE_HAS_SYNC) {
183 memcpy(cmd.args, "\x84\x01", 2);
184 cmd.wlen = 2;
185 cmd.rlen = 3;
186 ret = si2168_cmd_execute(client, &cmd);
187 if (ret)
188 goto err;
189
190 utmp1 = cmd.args[2] << 8 | cmd.args[1] << 0;
191 dev_dbg(&client->dev, "block_error=%u\n", utmp1);
192
193 /* Sometimes firmware returns bogus value */
194 if (utmp1 == 0xffff)
195 utmp1 = 0;
196
197 c->block_error.stat[0].scale = FE_SCALE_COUNTER;
198 c->block_error.stat[0].uvalue += utmp1;
199 } else {
200 c->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
201 }
202
147 return 0; 203 return 0;
148err: 204err:
149 dev_dbg(&client->dev, "failed=%d\n", ret); 205 dev_dbg(&client->dev, "failed=%d\n", ret);
@@ -355,6 +411,7 @@ static int si2168_init(struct dvb_frontend *fe)
355{ 411{
356 struct i2c_client *client = fe->demodulator_priv; 412 struct i2c_client *client = fe->demodulator_priv;
357 struct si2168_dev *dev = i2c_get_clientdata(client); 413 struct si2168_dev *dev = i2c_get_clientdata(client);
414 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
358 int ret, len, remaining; 415 int ret, len, remaining;
359 const struct firmware *fw; 416 const struct firmware *fw;
360 struct si2168_cmd cmd; 417 struct si2168_cmd cmd;
@@ -493,10 +550,19 @@ static int si2168_init(struct dvb_frontend *fe)
493 550
494 dev->warm = true; 551 dev->warm = true;
495warm: 552warm:
553 /* Init stats here to indicate which stats are supported */
554 c->cnr.len = 1;
555 c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
556 c->post_bit_error.len = 1;
557 c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
558 c->post_bit_count.len = 1;
559 c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
560 c->block_error.len = 1;
561 c->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
562
496 dev->active = true; 563 dev->active = true;
497 564
498 return 0; 565 return 0;
499
500err_release_firmware: 566err_release_firmware:
501 release_firmware(fw); 567 release_firmware(fw);
502err: 568err:
diff --git a/drivers/media/dvb-frontends/si2168_priv.h b/drivers/media/dvb-frontends/si2168_priv.h
index 7843ccb448a0..2fecac6231ff 100644
--- a/drivers/media/dvb-frontends/si2168_priv.h
+++ b/drivers/media/dvb-frontends/si2168_priv.h
@@ -21,6 +21,7 @@
21#include "dvb_frontend.h" 21#include "dvb_frontend.h"
22#include <linux/firmware.h> 22#include <linux/firmware.h>
23#include <linux/i2c-mux.h> 23#include <linux/i2c-mux.h>
24#include <linux/kernel.h>
24 25
25#define SI2168_A20_FIRMWARE "dvb-demod-si2168-a20-01.fw" 26#define SI2168_A20_FIRMWARE "dvb-demod-si2168-a20-01.fw"
26#define SI2168_A30_FIRMWARE "dvb-demod-si2168-a30-01.fw" 27#define SI2168_A30_FIRMWARE "dvb-demod-si2168-a30-01.fw"
diff --git a/drivers/media/dvb-frontends/stv0367.c b/drivers/media/dvb-frontends/stv0367.c
index 4ac1ce2831ba..fd49c436a36d 100644
--- a/drivers/media/dvb-frontends/stv0367.c
+++ b/drivers/media/dvb-frontends/stv0367.c
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * 18 *
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 20 */
25 21
26#include <linux/kernel.h> 22#include <linux/kernel.h>
diff --git a/drivers/media/dvb-frontends/stv0367.h b/drivers/media/dvb-frontends/stv0367.h
index b88166a9716f..26c38a0503c8 100644
--- a/drivers/media/dvb-frontends/stv0367.h
+++ b/drivers/media/dvb-frontends/stv0367.h
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * 18 *
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 20 */
25 21
26#ifndef STV0367_H 22#ifndef STV0367_H
diff --git a/drivers/media/dvb-frontends/stv0367_priv.h b/drivers/media/dvb-frontends/stv0367_priv.h
index 89bf6f64b078..8abc451dd524 100644
--- a/drivers/media/dvb-frontends/stv0367_priv.h
+++ b/drivers/media/dvb-frontends/stv0367_priv.h
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * 18 *
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 20 */
25/* Common driver error constants */ 21/* Common driver error constants */
26 22
diff --git a/drivers/media/dvb-frontends/stv0367_regs.h b/drivers/media/dvb-frontends/stv0367_regs.h
index a96fbdc7e25e..1d1586221239 100644
--- a/drivers/media/dvb-frontends/stv0367_regs.h
+++ b/drivers/media/dvb-frontends/stv0367_regs.h
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * 18 *
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 20 */
25 21
26#ifndef STV0367_REGS_H 22#ifndef STV0367_REGS_H
diff --git a/drivers/media/dvb-frontends/stv0900.h b/drivers/media/dvb-frontends/stv0900.h
index 9ca2da90c7d7..1571a465e05c 100644
--- a/drivers/media/dvb-frontends/stv0900.h
+++ b/drivers/media/dvb-frontends/stv0900.h
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * 18 *
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 20 */
25 21
26#ifndef STV0900_H 22#ifndef STV0900_H
diff --git a/drivers/media/dvb-frontends/stv0900_core.c b/drivers/media/dvb-frontends/stv0900_core.c
index 43a0f69b4b14..0b739725e3c0 100644
--- a/drivers/media/dvb-frontends/stv0900_core.c
+++ b/drivers/media/dvb-frontends/stv0900_core.c
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * 18 *
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 20 */
25 21
26#include <linux/kernel.h> 22#include <linux/kernel.h>
diff --git a/drivers/media/dvb-frontends/stv0900_init.h b/drivers/media/dvb-frontends/stv0900_init.h
index b684df9995d8..411941442086 100644
--- a/drivers/media/dvb-frontends/stv0900_init.h
+++ b/drivers/media/dvb-frontends/stv0900_init.h
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * 18 *
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 20 */
25 21
26#ifndef STV0900_INIT_H 22#ifndef STV0900_INIT_H
diff --git a/drivers/media/dvb-frontends/stv0900_priv.h b/drivers/media/dvb-frontends/stv0900_priv.h
index e0ea74c8e093..7a95f955627b 100644
--- a/drivers/media/dvb-frontends/stv0900_priv.h
+++ b/drivers/media/dvb-frontends/stv0900_priv.h
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * 18 *
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 20 */
25 21
26#ifndef STV0900_PRIV_H 22#ifndef STV0900_PRIV_H
diff --git a/drivers/media/dvb-frontends/stv0900_reg.h b/drivers/media/dvb-frontends/stv0900_reg.h
index 511ed2a2d987..59f264c2f8f5 100644
--- a/drivers/media/dvb-frontends/stv0900_reg.h
+++ b/drivers/media/dvb-frontends/stv0900_reg.h
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * 18 *
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 20 */
25 21
26#ifndef STV0900_REG_H 22#ifndef STV0900_REG_H
diff --git a/drivers/media/dvb-frontends/stv0900_sw.c b/drivers/media/dvb-frontends/stv0900_sw.c
index bded82774f4b..c97a39120ea5 100644
--- a/drivers/media/dvb-frontends/stv0900_sw.c
+++ b/drivers/media/dvb-frontends/stv0900_sw.c
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * 18 *
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 20 */
25 21
26#include "stv0900.h" 22#include "stv0900.h"
diff --git a/drivers/media/dvb-frontends/stv6110.c b/drivers/media/dvb-frontends/stv6110.c
index 6a72d0be2ec5..e4fd9c1b0560 100644
--- a/drivers/media/dvb-frontends/stv6110.c
+++ b/drivers/media/dvb-frontends/stv6110.c
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * 17 *
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */ 19 */
24 20
25#include <linux/slab.h> 21#include <linux/slab.h>
diff --git a/drivers/media/dvb-frontends/stv6110.h b/drivers/media/dvb-frontends/stv6110.h
index 4604f793d954..ab73124c0dec 100644
--- a/drivers/media/dvb-frontends/stv6110.h
+++ b/drivers/media/dvb-frontends/stv6110.h
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * 17 *
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */ 19 */
24 20
25#ifndef __DVB_STV6110_H__ 21#ifndef __DVB_STV6110_H__
diff --git a/drivers/media/dvb-frontends/tda18271c2dd.c b/drivers/media/dvb-frontends/tda18271c2dd.c
index 6859fa5d5a85..2d2778be2d2f 100644
--- a/drivers/media/dvb-frontends/tda18271c2dd.c
+++ b/drivers/media/dvb-frontends/tda18271c2dd.c
@@ -14,12 +14,8 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * 17 * To obtain the license, point your browser to
18 * You should have received a copy of the GNU General Public License 18 * http://www.gnu.org/copyleft/gpl.html
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301, USA
22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
23 */ 19 */
24 20
25#include <linux/kernel.h> 21#include <linux/kernel.h>
diff --git a/drivers/media/dvb-frontends/tdhd1.h b/drivers/media/dvb-frontends/tdhd1.h
index 2b9e8732c802..68358c0d869f 100644
--- a/drivers/media/dvb-frontends/tdhd1.h
+++ b/drivers/media/dvb-frontends/tdhd1.h
@@ -13,11 +13,8 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 * To obtain the license, point your browser to
17 * You should have received a copy of the GNU General Public License 17 * http://www.gnu.org/copyleft/gpl.html
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
21 * 18 *
22 * 19 *
23 * The project's page is at https://linuxtv.org 20 * The project's page is at https://linuxtv.org
diff --git a/drivers/media/dvb-frontends/tua6100.c b/drivers/media/dvb-frontends/tua6100.c
index 05ee16d29851..18e6d4c5be21 100644
--- a/drivers/media/dvb-frontends/tua6100.c
+++ b/drivers/media/dvb-frontends/tua6100.c
@@ -22,10 +22,6 @@
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details. 24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 */ 25 */
30 26
31#include <linux/slab.h> 27#include <linux/slab.h>
diff --git a/drivers/media/dvb-frontends/tua6100.h b/drivers/media/dvb-frontends/tua6100.h
index 52919e04e258..9f15cbdfdeca 100644
--- a/drivers/media/dvb-frontends/tua6100.h
+++ b/drivers/media/dvb-frontends/tua6100.h
@@ -22,10 +22,6 @@
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details. 24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 */ 25 */
30 26
31#ifndef __DVB_TUA6100_H__ 27#ifndef __DVB_TUA6100_H__
diff --git a/drivers/media/dvb-frontends/zd1301_demod.c b/drivers/media/dvb-frontends/zd1301_demod.c
new file mode 100644
index 000000000000..fcf5f69de0c5
--- /dev/null
+++ b/drivers/media/dvb-frontends/zd1301_demod.c
@@ -0,0 +1,551 @@
1/*
2 * ZyDAS ZD1301 driver (demodulator)
3 *
4 * Copyright (C) 2015 Antti Palosaari <crope@iki.fi>
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 as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include "zd1301_demod.h"
18
19static u8 zd1301_demod_gain = 0x38;
20module_param_named(gain, zd1301_demod_gain, byte, 0644);
21MODULE_PARM_DESC(gain, "gain (value: 0x00 - 0x70, default: 0x38)");
22
23struct zd1301_demod_dev {
24 struct platform_device *pdev;
25 struct dvb_frontend frontend;
26 struct i2c_adapter adapter;
27 u8 gain;
28};
29
30static int zd1301_demod_wreg(struct zd1301_demod_dev *dev, u16 reg, u8 val)
31{
32 struct platform_device *pdev = dev->pdev;
33 struct zd1301_demod_platform_data *pdata = pdev->dev.platform_data;
34
35 return pdata->reg_write(pdata->reg_priv, reg, val);
36}
37
38static int zd1301_demod_rreg(struct zd1301_demod_dev *dev, u16 reg, u8 *val)
39{
40 struct platform_device *pdev = dev->pdev;
41 struct zd1301_demod_platform_data *pdata = pdev->dev.platform_data;
42
43 return pdata->reg_read(pdata->reg_priv, reg, val);
44}
45
46static int zd1301_demod_set_frontend(struct dvb_frontend *fe)
47{
48 struct zd1301_demod_dev *dev = fe->demodulator_priv;
49 struct platform_device *pdev = dev->pdev;
50 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
51 int ret;
52 u32 if_frequency;
53 u8 r6a50_val;
54
55 dev_dbg(&pdev->dev, "frequency=%u bandwidth_hz=%u\n",
56 c->frequency, c->bandwidth_hz);
57
58 /* Program tuner */
59 if (fe->ops.tuner_ops.set_params &&
60 fe->ops.tuner_ops.get_if_frequency) {
61 ret = fe->ops.tuner_ops.set_params(fe);
62 if (ret)
63 goto err;
64 ret = fe->ops.tuner_ops.get_if_frequency(fe, &if_frequency);
65 if (ret)
66 goto err;
67 } else {
68 ret = -EINVAL;
69 goto err;
70 }
71
72 dev_dbg(&pdev->dev, "if_frequency=%u\n", if_frequency);
73 if (if_frequency != 36150000) {
74 ret = -EINVAL;
75 goto err;
76 }
77
78 switch (c->bandwidth_hz) {
79 case 6000000:
80 r6a50_val = 0x78;
81 break;
82 case 7000000:
83 r6a50_val = 0x68;
84 break;
85 case 8000000:
86 r6a50_val = 0x58;
87 break;
88 default:
89 ret = -EINVAL;
90 goto err;
91 }
92
93 ret = zd1301_demod_wreg(dev, 0x6a60, 0x11);
94 if (ret)
95 goto err;
96 ret = zd1301_demod_wreg(dev, 0x6a47, 0x46);
97 if (ret)
98 goto err;
99 ret = zd1301_demod_wreg(dev, 0x6a48, 0x46);
100 if (ret)
101 goto err;
102 ret = zd1301_demod_wreg(dev, 0x6a4a, 0x15);
103 if (ret)
104 goto err;
105 ret = zd1301_demod_wreg(dev, 0x6a4b, 0x63);
106 if (ret)
107 goto err;
108 ret = zd1301_demod_wreg(dev, 0x6a5b, 0x99);
109 if (ret)
110 goto err;
111 ret = zd1301_demod_wreg(dev, 0x6a3b, 0x10);
112 if (ret)
113 goto err;
114 ret = zd1301_demod_wreg(dev, 0x6806, 0x01);
115 if (ret)
116 goto err;
117 ret = zd1301_demod_wreg(dev, 0x6a41, 0x08);
118 if (ret)
119 goto err;
120 ret = zd1301_demod_wreg(dev, 0x6a42, 0x46);
121 if (ret)
122 goto err;
123 ret = zd1301_demod_wreg(dev, 0x6a44, 0x14);
124 if (ret)
125 goto err;
126 ret = zd1301_demod_wreg(dev, 0x6a45, 0x67);
127 if (ret)
128 goto err;
129 ret = zd1301_demod_wreg(dev, 0x6a38, 0x00);
130 if (ret)
131 goto err;
132 ret = zd1301_demod_wreg(dev, 0x6a4c, 0x52);
133 if (ret)
134 goto err;
135 ret = zd1301_demod_wreg(dev, 0x6a49, 0x2a);
136 if (ret)
137 goto err;
138 ret = zd1301_demod_wreg(dev, 0x6840, 0x2e);
139 if (ret)
140 goto err;
141 ret = zd1301_demod_wreg(dev, 0x6a50, r6a50_val);
142 if (ret)
143 goto err;
144 ret = zd1301_demod_wreg(dev, 0x6a38, 0x07);
145 if (ret)
146 goto err;
147
148 return 0;
149err:
150 dev_dbg(&pdev->dev, "failed=%d\n", ret);
151 return ret;
152}
153
154static int zd1301_demod_sleep(struct dvb_frontend *fe)
155{
156 struct zd1301_demod_dev *dev = fe->demodulator_priv;
157 struct platform_device *pdev = dev->pdev;
158 int ret;
159
160 dev_dbg(&pdev->dev, "\n");
161
162 ret = zd1301_demod_wreg(dev, 0x6a43, 0x70);
163 if (ret)
164 goto err;
165 ret = zd1301_demod_wreg(dev, 0x684e, 0x00);
166 if (ret)
167 goto err;
168 ret = zd1301_demod_wreg(dev, 0x6849, 0x00);
169 if (ret)
170 goto err;
171 ret = zd1301_demod_wreg(dev, 0x68e2, 0xd7);
172 if (ret)
173 goto err;
174 ret = zd1301_demod_wreg(dev, 0x68e0, 0x39);
175 if (ret)
176 goto err;
177 ret = zd1301_demod_wreg(dev, 0x6840, 0x21);
178 if (ret)
179 goto err;
180
181 return 0;
182err:
183 dev_dbg(&pdev->dev, "failed=%d\n", ret);
184 return ret;
185}
186
187static int zd1301_demod_init(struct dvb_frontend *fe)
188{
189 struct zd1301_demod_dev *dev = fe->demodulator_priv;
190 struct platform_device *pdev = dev->pdev;
191 int ret;
192
193 dev_dbg(&pdev->dev, "\n");
194
195 ret = zd1301_demod_wreg(dev, 0x6840, 0x26);
196 if (ret)
197 goto err;
198 ret = zd1301_demod_wreg(dev, 0x68e0, 0xff);
199 if (ret)
200 goto err;
201 ret = zd1301_demod_wreg(dev, 0x68e2, 0xd8);
202 if (ret)
203 goto err;
204 ret = zd1301_demod_wreg(dev, 0x6849, 0x4e);
205 if (ret)
206 goto err;
207 ret = zd1301_demod_wreg(dev, 0x684e, 0x01);
208 if (ret)
209 goto err;
210 ret = zd1301_demod_wreg(dev, 0x6a43, zd1301_demod_gain);
211 if (ret)
212 goto err;
213
214 return 0;
215err:
216 dev_dbg(&pdev->dev, "failed=%d\n", ret);
217 return ret;
218}
219
220static int zd1301_demod_get_tune_settings(struct dvb_frontend *fe,
221 struct dvb_frontend_tune_settings *settings)
222{
223 struct zd1301_demod_dev *dev = fe->demodulator_priv;
224 struct platform_device *pdev = dev->pdev;
225
226 dev_dbg(&pdev->dev, "\n");
227
228 /* ~180ms seems to be enough */
229 settings->min_delay_ms = 400;
230
231 return 0;
232}
233
234static int zd1301_demod_read_status(struct dvb_frontend *fe,
235 enum fe_status *status)
236{
237 struct zd1301_demod_dev *dev = fe->demodulator_priv;
238 struct platform_device *pdev = dev->pdev;
239 int ret;
240 u8 u8tmp;
241
242 ret = zd1301_demod_rreg(dev, 0x6a24, &u8tmp);
243 if (ret)
244 goto err;
245 if (u8tmp > 0x00 && u8tmp < 0x20)
246 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
247 FE_HAS_SYNC | FE_HAS_LOCK;
248 else
249 *status = 0;
250
251 dev_dbg(&pdev->dev, "lock byte=%02x\n", u8tmp);
252
253 /*
254 * Interesting registers here are:
255 * 0x6a05: get some gain value
256 * 0x6a06: get about same gain value than set to 0x6a43
257 * 0x6a07: get some gain value
258 * 0x6a43: set gain value by driver
259 * 0x6a24: get demod lock bits (FSM stage?)
260 *
261 * Driver should implement some kind of algorithm to calculate suitable
262 * value for register 0x6a43, based likely values from register 0x6a05
263 * and 0x6a07. Looks like gain register 0x6a43 value could be from
264 * range 0x00 - 0x70.
265 */
266
267 if (dev->gain != zd1301_demod_gain) {
268 dev->gain = zd1301_demod_gain;
269
270 ret = zd1301_demod_wreg(dev, 0x6a43, dev->gain);
271 if (ret)
272 goto err;
273 }
274
275 return 0;
276err:
277 dev_dbg(&pdev->dev, "failed=%d\n", ret);
278 return ret;
279}
280
281static const struct dvb_frontend_ops zd1301_demod_ops = {
282 .delsys = {SYS_DVBT},
283 .info = {
284 .name = "ZyDAS ZD1301",
285 .caps = FE_CAN_FEC_1_2 |
286 FE_CAN_FEC_2_3 |
287 FE_CAN_FEC_3_4 |
288 FE_CAN_FEC_5_6 |
289 FE_CAN_FEC_7_8 |
290 FE_CAN_FEC_AUTO |
291 FE_CAN_QPSK |
292 FE_CAN_QAM_16 |
293 FE_CAN_QAM_64 |
294 FE_CAN_QAM_AUTO |
295 FE_CAN_TRANSMISSION_MODE_AUTO |
296 FE_CAN_GUARD_INTERVAL_AUTO |
297 FE_CAN_HIERARCHY_AUTO |
298 FE_CAN_MUTE_TS
299 },
300
301 .sleep = zd1301_demod_sleep,
302 .init = zd1301_demod_init,
303 .set_frontend = zd1301_demod_set_frontend,
304 .get_tune_settings = zd1301_demod_get_tune_settings,
305 .read_status = zd1301_demod_read_status,
306};
307
308struct dvb_frontend *zd1301_demod_get_dvb_frontend(struct platform_device *pdev)
309{
310 struct zd1301_demod_dev *dev = platform_get_drvdata(pdev);
311
312 dev_dbg(&pdev->dev, "\n");
313
314 return &dev->frontend;
315}
316EXPORT_SYMBOL(zd1301_demod_get_dvb_frontend);
317
318static int zd1301_demod_i2c_master_xfer(struct i2c_adapter *adapter,
319 struct i2c_msg msg[], int num)
320{
321 struct zd1301_demod_dev *dev = i2c_get_adapdata(adapter);
322 struct platform_device *pdev = dev->pdev;
323 int ret, i;
324 unsigned long timeout;
325 u8 u8tmp;
326
327 #define I2C_XFER_TIMEOUT 5
328 #define ZD1301_IS_I2C_XFER_WRITE_READ(_msg, _num) \
329 (_num == 2 && !(_msg[0].flags & I2C_M_RD) && (_msg[1].flags & I2C_M_RD))
330 #define ZD1301_IS_I2C_XFER_WRITE(_msg, _num) \
331 (_num == 1 && !(_msg[0].flags & I2C_M_RD))
332 #define ZD1301_IS_I2C_XFER_READ(_msg, _num) \
333 (_num == 1 && (_msg[0].flags & I2C_M_RD))
334 if (ZD1301_IS_I2C_XFER_WRITE_READ(msg, num)) {
335 dev_dbg(&pdev->dev, "write&read msg[0].len=%u msg[1].len=%u\n",
336 msg[0].len, msg[1].len);
337 if (msg[0].len > 1 || msg[1].len > 8) {
338 ret = -EOPNOTSUPP;
339 goto err;
340 }
341
342 ret = zd1301_demod_wreg(dev, 0x6811, 0x80);
343 if (ret)
344 goto err;
345 ret = zd1301_demod_wreg(dev, 0x6812, 0x05);
346 if (ret)
347 goto err;
348 ret = zd1301_demod_wreg(dev, 0x6813, msg[1].addr << 1);
349 if (ret)
350 goto err;
351 ret = zd1301_demod_wreg(dev, 0x6801, msg[0].buf[0]);
352 if (ret)
353 goto err;
354 ret = zd1301_demod_wreg(dev, 0x6802, 0x00);
355 if (ret)
356 goto err;
357 ret = zd1301_demod_wreg(dev, 0x6803, 0x06);
358 if (ret)
359 goto err;
360 ret = zd1301_demod_wreg(dev, 0x6805, 0x00);
361 if (ret)
362 goto err;
363 ret = zd1301_demod_wreg(dev, 0x6804, msg[1].len);
364 if (ret)
365 goto err;
366
367 /* Poll xfer ready */
368 timeout = jiffies + msecs_to_jiffies(I2C_XFER_TIMEOUT);
369 for (u8tmp = 1; !time_after(jiffies, timeout) && u8tmp;) {
370 usleep_range(500, 800);
371
372 ret = zd1301_demod_rreg(dev, 0x6804, &u8tmp);
373 if (ret)
374 goto err;
375 }
376
377 for (i = 0; i < msg[1].len; i++) {
378 ret = zd1301_demod_rreg(dev, 0x0600 + i, &msg[1].buf[i]);
379 if (ret)
380 goto err;
381 }
382 } else if (ZD1301_IS_I2C_XFER_WRITE(msg, num)) {
383 dev_dbg(&pdev->dev, "write msg[0].len=%u\n", msg[0].len);
384 if (msg[0].len > 1 + 8) {
385 ret = -EOPNOTSUPP;
386 goto err;
387 }
388
389 ret = zd1301_demod_wreg(dev, 0x6811, 0x80);
390 if (ret)
391 goto err;
392 ret = zd1301_demod_wreg(dev, 0x6812, 0x01);
393 if (ret)
394 goto err;
395 ret = zd1301_demod_wreg(dev, 0x6813, msg[0].addr << 1);
396 if (ret)
397 goto err;
398 ret = zd1301_demod_wreg(dev, 0x6800, msg[0].buf[0]);
399 if (ret)
400 goto err;
401 ret = zd1301_demod_wreg(dev, 0x6802, 0x00);
402 if (ret)
403 goto err;
404 ret = zd1301_demod_wreg(dev, 0x6803, 0x06);
405 if (ret)
406 goto err;
407
408 for (i = 0; i < msg[0].len - 1; i++) {
409 ret = zd1301_demod_wreg(dev, 0x0600 + i, msg[0].buf[1 + i]);
410 if (ret)
411 goto err;
412 }
413
414 ret = zd1301_demod_wreg(dev, 0x6805, 0x80);
415 if (ret)
416 goto err;
417 ret = zd1301_demod_wreg(dev, 0x6804, msg[0].len - 1);
418 if (ret)
419 goto err;
420
421 /* Poll xfer ready */
422 timeout = jiffies + msecs_to_jiffies(I2C_XFER_TIMEOUT);
423 for (u8tmp = 1; !time_after(jiffies, timeout) && u8tmp;) {
424 usleep_range(500, 800);
425
426 ret = zd1301_demod_rreg(dev, 0x6804, &u8tmp);
427 if (ret)
428 goto err;
429 }
430 } else {
431 dev_dbg(&pdev->dev, "unknown msg[0].len=%u\n", msg[0].len);
432 ret = -EOPNOTSUPP;
433 if (ret)
434 goto err;
435 }
436
437 return num;
438err:
439 dev_dbg(&pdev->dev, "failed=%d\n", ret);
440 return ret;
441}
442
443static u32 zd1301_demod_i2c_functionality(struct i2c_adapter *adapter)
444{
445 return I2C_FUNC_I2C;
446}
447
448static struct i2c_algorithm zd1301_demod_i2c_algorithm = {
449 .master_xfer = zd1301_demod_i2c_master_xfer,
450 .functionality = zd1301_demod_i2c_functionality,
451};
452
453struct i2c_adapter *zd1301_demod_get_i2c_adapter(struct platform_device *pdev)
454{
455 struct zd1301_demod_dev *dev = platform_get_drvdata(pdev);
456
457 dev_dbg(&pdev->dev, "\n");
458
459 return &dev->adapter;
460}
461EXPORT_SYMBOL(zd1301_demod_get_i2c_adapter);
462
463/* Platform driver interface */
464static int zd1301_demod_probe(struct platform_device *pdev)
465{
466 struct zd1301_demod_dev *dev;
467 struct zd1301_demod_platform_data *pdata = pdev->dev.platform_data;
468 int ret;
469
470 dev_dbg(&pdev->dev, "\n");
471
472 if (!pdata) {
473 ret = -EINVAL;
474 dev_err(&pdev->dev, "cannot proceed without platform data\n");
475 goto err;
476 }
477 if (!pdev->dev.parent->driver) {
478 ret = -EINVAL;
479 dev_dbg(&pdev->dev, "no parent device\n");
480 goto err;
481 }
482
483 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
484 if (!dev) {
485 ret = -ENOMEM;
486 goto err;
487 }
488
489 /* Setup the state */
490 dev->pdev = pdev;
491 dev->gain = zd1301_demod_gain;
492
493 /* Sleep */
494 ret = zd1301_demod_wreg(dev, 0x6840, 0x21);
495 if (ret)
496 goto err_kfree;
497 ret = zd1301_demod_wreg(dev, 0x6a38, 0x07);
498 if (ret)
499 goto err_kfree;
500
501 /* Create I2C adapter */
502 strlcpy(dev->adapter.name, "ZyDAS ZD1301 demod", sizeof(dev->adapter.name));
503 dev->adapter.algo = &zd1301_demod_i2c_algorithm;
504 dev->adapter.algo_data = NULL;
505 dev->adapter.dev.parent = pdev->dev.parent;
506 i2c_set_adapdata(&dev->adapter, dev);
507 ret = i2c_add_adapter(&dev->adapter);
508 if (ret) {
509 dev_err(&pdev->dev, "I2C adapter add failed %d\n", ret);
510 goto err_kfree;
511 }
512
513 /* Create dvb frontend */
514 memcpy(&dev->frontend.ops, &zd1301_demod_ops, sizeof(dev->frontend.ops));
515 dev->frontend.demodulator_priv = dev;
516 platform_set_drvdata(pdev, dev);
517 dev_info(&pdev->dev, "ZyDAS ZD1301 demod attached\n");
518
519 return 0;
520err_kfree:
521 kfree(dev);
522err:
523 dev_dbg(&pdev->dev, "failed=%d\n", ret);
524 return ret;
525}
526
527static int zd1301_demod_remove(struct platform_device *pdev)
528{
529 struct zd1301_demod_dev *dev = platform_get_drvdata(pdev);
530
531 dev_dbg(&pdev->dev, "\n");
532
533 i2c_del_adapter(&dev->adapter);
534 kfree(dev);
535
536 return 0;
537}
538
539static struct platform_driver zd1301_demod_driver = {
540 .driver = {
541 .name = "zd1301_demod",
542 .suppress_bind_attrs = true,
543 },
544 .probe = zd1301_demod_probe,
545 .remove = zd1301_demod_remove,
546};
547module_platform_driver(zd1301_demod_driver);
548
549MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
550MODULE_DESCRIPTION("ZyDAS ZD1301 demodulator driver");
551MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/zd1301_demod.h b/drivers/media/dvb-frontends/zd1301_demod.h
new file mode 100644
index 000000000000..ceb2e05e873c
--- /dev/null
+++ b/drivers/media/dvb-frontends/zd1301_demod.h
@@ -0,0 +1,73 @@
1/*
2 * ZyDAS ZD1301 driver (demodulator)
3 *
4 * Copyright (C) 2015 Antti Palosaari <crope@iki.fi>
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 as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#ifndef ZD1301_DEMOD_H
18#define ZD1301_DEMOD_H
19
20#include <linux/platform_device.h>
21#include <linux/dvb/frontend.h>
22#include "dvb_frontend.h"
23
24/**
25 * struct zd1301_demod_platform_data - Platform data for the zd1301_demod driver
26 * @reg_priv: First argument of reg_read and reg_write callbacks.
27 * @reg_read: Register read callback.
28 * @reg_write: Register write callback.
29 */
30
31struct zd1301_demod_platform_data {
32 void *reg_priv;
33 int (*reg_read)(void *, u16, u8 *);
34 int (*reg_write)(void *, u16, u8);
35};
36
37#if IS_REACHABLE(CONFIG_DVB_ZD1301_DEMOD)
38/**
39 * zd1301_demod_get_dvb_frontend() - Get pointer to DVB frontend
40 * @pdev: Pointer to platform device
41 *
42 * Return: Pointer to DVB frontend which given platform device owns.
43 */
44
45struct dvb_frontend *zd1301_demod_get_dvb_frontend(struct platform_device *);
46
47/**
48 * zd1301_demod_get_i2c_adapter() - Get pointer to I2C adapter
49 * @pdev: Pointer to platform device
50 *
51 * Return: Pointer to I2C adapter which given platform device owns.
52 */
53
54struct i2c_adapter *zd1301_demod_get_i2c_adapter(struct platform_device *);
55
56#else
57
58static inline struct dvb_frontend *zd1301_demod_get_dvb_frontend(struct platform_device *dev)
59{
60 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
61
62 return NULL;
63}
64static inline struct i2c_adapter *zd1301_demod_get_i2c_adapter(struct platform_device *dev)
65{
66 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
67
68 return NULL;
69}
70
71#endif
72
73#endif /* ZD1301_DEMOD_H */
diff --git a/drivers/media/dvb-frontends/zl10036.c b/drivers/media/dvb-frontends/zl10036.c
index a6d020fe9b8b..062282739ce5 100644
--- a/drivers/media/dvb-frontends/zl10036.c
+++ b/drivers/media/dvb-frontends/zl10036.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 ** 16 **
21 * The data sheet for this tuner can be found at: 17 * The data sheet for this tuner can be found at:
22 * http://www.mcmilk.de/projects/dvb-card/datasheets/ZL10036.pdf 18 * http://www.mcmilk.de/projects/dvb-card/datasheets/ZL10036.pdf
diff --git a/drivers/media/dvb-frontends/zl10036.h b/drivers/media/dvb-frontends/zl10036.h
index c568d8d59de3..88751adfecf7 100644
--- a/drivers/media/dvb-frontends/zl10036.h
+++ b/drivers/media/dvb-frontends/zl10036.h
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#ifndef DVB_ZL10036_H 17#ifndef DVB_ZL10036_H
diff --git a/drivers/media/dvb-frontends/zl10039.c b/drivers/media/dvb-frontends/zl10039.c
index 60a2954f8ff8..623355fc2666 100644
--- a/drivers/media/dvb-frontends/zl10039.c
+++ b/drivers/media/dvb-frontends/zl10039.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include <linux/module.h> 18#include <linux/module.h>
diff --git a/drivers/media/dvb-frontends/zl10353.c b/drivers/media/dvb-frontends/zl10353.c
index 4f3ff3e853ac..47c0549eb7b2 100644
--- a/drivers/media/dvb-frontends/zl10353.c
+++ b/drivers/media/dvb-frontends/zl10353.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include <linux/kernel.h> 18#include <linux/kernel.h>
diff --git a/drivers/media/dvb-frontends/zl10353.h b/drivers/media/dvb-frontends/zl10353.h
index 37aa6e8f454a..cb6248c00089 100644
--- a/drivers/media/dvb-frontends/zl10353.h
+++ b/drivers/media/dvb-frontends/zl10353.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */ 16 */
21 17
22#ifndef ZL10353_H 18#ifndef ZL10353_H
diff --git a/drivers/media/dvb-frontends/zl10353_priv.h b/drivers/media/dvb-frontends/zl10353_priv.h
index e0dd1d3e09dd..a1d902b2d47a 100644
--- a/drivers/media/dvb-frontends/zl10353_priv.h
+++ b/drivers/media/dvb-frontends/zl10353_priv.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#ifndef _ZL10353_PRIV_ 18#ifndef _ZL10353_PRIV_
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index b979ea148251..cee1dae6e014 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -668,6 +668,7 @@ config VIDEO_S5K5BAF
668 camera sensor with an embedded SoC image signal processor. 668 camera sensor with an embedded SoC image signal processor.
669 669
670source "drivers/media/i2c/smiapp/Kconfig" 670source "drivers/media/i2c/smiapp/Kconfig"
671source "drivers/media/i2c/et8ek8/Kconfig"
671 672
672config VIDEO_S5C73M3 673config VIDEO_S5C73M3
673 tristate "Samsung S5C73M3 sensor support" 674 tristate "Samsung S5C73M3 sensor support"
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 92773b2e6225..5bc7bbeb5499 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -2,6 +2,7 @@ msp3400-objs := msp3400-driver.o msp3400-kthreads.o
2obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o 2obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
3 3
4obj-$(CONFIG_VIDEO_SMIAPP) += smiapp/ 4obj-$(CONFIG_VIDEO_SMIAPP) += smiapp/
5obj-$(CONFIG_VIDEO_ET8EK8) += et8ek8/
5obj-$(CONFIG_VIDEO_CX25840) += cx25840/ 6obj-$(CONFIG_VIDEO_CX25840) += cx25840/
6obj-$(CONFIG_VIDEO_M5MOLS) += m5mols/ 7obj-$(CONFIG_VIDEO_M5MOLS) += m5mols/
7obj-y += soc_camera/ 8obj-y += soc_camera/
diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c
index e191e295c951..ba1ec4ab9eba 100644
--- a/drivers/media/i2c/adp1653.c
+++ b/drivers/media/i2c/adp1653.c
@@ -19,11 +19,6 @@
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details. 20 * General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 * 02110-1301 USA
26 *
27 * TODO: 22 * TODO:
28 * - fault interrupt handling 23 * - fault interrupt handling
29 * - hardware strobe 24 * - hardware strobe
diff --git a/drivers/media/i2c/adv7170.c b/drivers/media/i2c/adv7170.c
index fc9ec0f3679c..739331473429 100644
--- a/drivers/media/i2c/adv7170.c
+++ b/drivers/media/i2c/adv7170.c
@@ -22,10 +22,6 @@
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details. 24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 */ 25 */
30 26
31#include <linux/module.h> 27#include <linux/module.h>
@@ -302,7 +298,6 @@ static int adv7170_set_fmt(struct v4l2_subdev *sd,
302{ 298{
303 struct v4l2_mbus_framefmt *mf = &format->format; 299 struct v4l2_mbus_framefmt *mf = &format->format;
304 u8 val = adv7170_read(sd, 0x7); 300 u8 val = adv7170_read(sd, 0x7);
305 int ret = 0;
306 301
307 if (format->pad) 302 if (format->pad)
308 return -EINVAL; 303 return -EINVAL;
@@ -323,9 +318,9 @@ static int adv7170_set_fmt(struct v4l2_subdev *sd,
323 } 318 }
324 319
325 if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) 320 if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
326 ret = adv7170_write(sd, 0x7, val); 321 return adv7170_write(sd, 0x7, val);
327 322
328 return ret; 323 return 0;
329} 324}
330 325
331/* ----------------------------------------------------------------------- */ 326/* ----------------------------------------------------------------------- */
diff --git a/drivers/media/i2c/adv7175.c b/drivers/media/i2c/adv7175.c
index 72139bdae1ca..e31e8d909bb9 100644
--- a/drivers/media/i2c/adv7175.c
+++ b/drivers/media/i2c/adv7175.c
@@ -18,10 +18,6 @@
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 21 */
26 22
27#include <linux/module.h> 23#include <linux/module.h>
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index cbed2bc29325..bdbbf8cf27e4 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#include <linux/module.h> 17#include <linux/module.h>
diff --git a/drivers/media/i2c/adv7183.c b/drivers/media/i2c/adv7183.c
index 04eecda74d66..8b00dc854cf8 100644
--- a/drivers/media/i2c/adv7183.c
+++ b/drivers/media/i2c/adv7183.c
@@ -11,10 +11,6 @@
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 14 */
19 15
20#include <linux/delay.h> 16#include <linux/delay.h>
diff --git a/drivers/media/i2c/adv7183_regs.h b/drivers/media/i2c/adv7183_regs.h
index b253d400e817..843d4998435e 100644
--- a/drivers/media/i2c/adv7183_regs.h
+++ b/drivers/media/i2c/adv7183_regs.h
@@ -11,10 +11,6 @@
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 14 */
19 15
20#ifndef _ADV7183_REGS_H_ 16#ifndef _ADV7183_REGS_H_
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index d0375cac6a05..d8bf435db86d 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -3133,6 +3133,9 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
3133 state->pdata.blank_data = 1; 3133 state->pdata.blank_data = 1;
3134 state->pdata.op_format_mode_sel = ADV7604_OP_FORMAT_MODE0; 3134 state->pdata.op_format_mode_sel = ADV7604_OP_FORMAT_MODE0;
3135 state->pdata.bus_order = ADV7604_BUS_ORDER_RGB; 3135 state->pdata.bus_order = ADV7604_BUS_ORDER_RGB;
3136 state->pdata.dr_str_data = ADV76XX_DR_STR_MEDIUM_HIGH;
3137 state->pdata.dr_str_clk = ADV76XX_DR_STR_MEDIUM_HIGH;
3138 state->pdata.dr_str_sync = ADV76XX_DR_STR_MEDIUM_HIGH;
3136 3139
3137 return 0; 3140 return 0;
3138} 3141}
diff --git a/drivers/media/i2c/ak881x.c b/drivers/media/i2c/ak881x.c
index 3a795dcb7d8e..16682c8477d1 100644
--- a/drivers/media/i2c/ak881x.c
+++ b/drivers/media/i2c/ak881x.c
@@ -205,14 +205,14 @@ static int ak881x_s_stream(struct v4l2_subdev *sd, int enable)
205 return 0; 205 return 0;
206} 206}
207 207
208static struct v4l2_subdev_core_ops ak881x_subdev_core_ops = { 208static const struct v4l2_subdev_core_ops ak881x_subdev_core_ops = {
209#ifdef CONFIG_VIDEO_ADV_DEBUG 209#ifdef CONFIG_VIDEO_ADV_DEBUG
210 .g_register = ak881x_g_register, 210 .g_register = ak881x_g_register,
211 .s_register = ak881x_s_register, 211 .s_register = ak881x_s_register,
212#endif 212#endif
213}; 213};
214 214
215static struct v4l2_subdev_video_ops ak881x_subdev_video_ops = { 215static const struct v4l2_subdev_video_ops ak881x_subdev_video_ops = {
216 .s_std_output = ak881x_s_std_output, 216 .s_std_output = ak881x_s_std_output,
217 .s_stream = ak881x_s_stream, 217 .s_stream = ak881x_s_stream,
218}; 218};
@@ -224,7 +224,7 @@ static const struct v4l2_subdev_pad_ops ak881x_subdev_pad_ops = {
224 .get_fmt = ak881x_fill_fmt, 224 .get_fmt = ak881x_fill_fmt,
225}; 225};
226 226
227static struct v4l2_subdev_ops ak881x_subdev_ops = { 227static const struct v4l2_subdev_ops ak881x_subdev_ops = {
228 .core = &ak881x_subdev_core_ops, 228 .core = &ak881x_subdev_core_ops,
229 .video = &ak881x_subdev_video_ops, 229 .video = &ak881x_subdev_video_ops,
230 .pad = &ak881x_subdev_pad_ops, 230 .pad = &ak881x_subdev_pad_ops,
diff --git a/drivers/media/i2c/aptina-pll.c b/drivers/media/i2c/aptina-pll.c
index 8153a449846b..224ae4e4cf8b 100644
--- a/drivers/media/i2c/aptina-pll.c
+++ b/drivers/media/i2c/aptina-pll.c
@@ -11,11 +11,6 @@
11 * WITHOUT ANY WARRANTY; without even the implied warranty of 11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details. 13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 * 02110-1301 USA
19 */ 14 */
20 15
21#include <linux/device.h> 16#include <linux/device.h>
diff --git a/drivers/media/i2c/aptina-pll.h b/drivers/media/i2c/aptina-pll.h
index b370e341e75d..1632f864c44f 100644
--- a/drivers/media/i2c/aptina-pll.h
+++ b/drivers/media/i2c/aptina-pll.h
@@ -11,11 +11,6 @@
11 * WITHOUT ANY WARRANTY; without even the implied warranty of 11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details. 13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 * 02110-1301 USA
19 */ 14 */
20 15
21#ifndef __APTINA_PLL_H 16#ifndef __APTINA_PLL_H
diff --git a/drivers/media/i2c/as3645a.c b/drivers/media/i2c/as3645a.c
index 2e90e4094b79..b6aeceea9850 100644
--- a/drivers/media/i2c/as3645a.c
+++ b/drivers/media/i2c/as3645a.c
@@ -15,11 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details. 16 * General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 * TODO: 18 * TODO:
24 * - Check hardware FSTROBE control when sensor driver add support for this 19 * - Check hardware FSTROBE control when sensor driver add support for this
25 * 20 *
diff --git a/drivers/media/i2c/bt819.c b/drivers/media/i2c/bt819.c
index 7907bcfbaed3..472e37637c8d 100644
--- a/drivers/media/i2c/bt819.c
+++ b/drivers/media/i2c/bt819.c
@@ -22,10 +22,6 @@
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details. 24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 */ 25 */
30 26
31#include <linux/module.h> 27#include <linux/module.h>
diff --git a/drivers/media/i2c/bt856.c b/drivers/media/i2c/bt856.c
index 54c627859c8e..2c039ae7d0b2 100644
--- a/drivers/media/i2c/bt856.c
+++ b/drivers/media/i2c/bt856.c
@@ -22,10 +22,6 @@
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details. 24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 */ 25 */
30 26
31#include <linux/module.h> 27#include <linux/module.h>
diff --git a/drivers/media/i2c/cs5345.c b/drivers/media/i2c/cs5345.c
index c7de9790d4f3..03e80278dc10 100644
--- a/drivers/media/i2c/cs5345.c
+++ b/drivers/media/i2c/cs5345.c
@@ -11,10 +11,6 @@
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 14 */
19 15
20 16
diff --git a/drivers/media/i2c/cs53l32a.c b/drivers/media/i2c/cs53l32a.c
index 59c1a98c5a90..fd70fe2130a1 100644
--- a/drivers/media/i2c/cs53l32a.c
+++ b/drivers/media/i2c/cs53l32a.c
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22 18
diff --git a/drivers/media/i2c/cx25840/cx25840-audio.c b/drivers/media/i2c/cx25840/cx25840-audio.c
index baf3d9c8710e..dfe94b84f1fb 100644
--- a/drivers/media/i2c/cx25840/cx25840-audio.c
+++ b/drivers/media/i2c/cx25840/cx25840-audio.c
@@ -9,10 +9,6 @@
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 */ 12 */
17 13
18 14
diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
index 0dcf450052ac..b8d3c070bfc1 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -30,10 +30,6 @@
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of 30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details. 32 * GNU General Public License for more details.
33 *
34 * You should have received a copy of the GNU General Public License
35 * along with this program; if not, write to the Free Software
36 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 */ 33 */
38 34
39 35
diff --git a/drivers/media/i2c/cx25840/cx25840-core.h b/drivers/media/i2c/cx25840/cx25840-core.h
index 254ef45ce41a..55432ed42714 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.h
+++ b/drivers/media/i2c/cx25840/cx25840-core.h
@@ -11,10 +11,6 @@
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */ 14 */
19 15
20#ifndef _CX25840_CORE_H_ 16#ifndef _CX25840_CORE_H_
diff --git a/drivers/media/i2c/cx25840/cx25840-firmware.c b/drivers/media/i2c/cx25840/cx25840-firmware.c
index 37e052923a87..a7819c463674 100644
--- a/drivers/media/i2c/cx25840/cx25840-firmware.c
+++ b/drivers/media/i2c/cx25840/cx25840-firmware.c
@@ -9,10 +9,6 @@
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 */ 12 */
17 13
18#include <linux/module.h> 14#include <linux/module.h>
diff --git a/drivers/media/i2c/cx25840/cx25840-ir.c b/drivers/media/i2c/cx25840/cx25840-ir.c
index 15fbd9607cee..9b65c7d2fa84 100644
--- a/drivers/media/i2c/cx25840/cx25840-ir.c
+++ b/drivers/media/i2c/cx25840/cx25840-ir.c
@@ -14,11 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 */ 17 */
23 18
24#include <linux/slab.h> 19#include <linux/slab.h>
diff --git a/drivers/media/i2c/cx25840/cx25840-vbi.c b/drivers/media/i2c/cx25840/cx25840-vbi.c
index 0470bb6128e1..8c99a79fb726 100644
--- a/drivers/media/i2c/cx25840/cx25840-vbi.c
+++ b/drivers/media/i2c/cx25840/cx25840-vbi.c
@@ -9,10 +9,6 @@
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 */ 12 */
17 13
18 14
diff --git a/drivers/media/i2c/et8ek8/Kconfig b/drivers/media/i2c/et8ek8/Kconfig
new file mode 100644
index 000000000000..14399365ad7f
--- /dev/null
+++ b/drivers/media/i2c/et8ek8/Kconfig
@@ -0,0 +1,6 @@
1config VIDEO_ET8EK8
2 tristate "ET8EK8 camera sensor support"
3 depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
4 ---help---
5 This is a driver for the Toshiba ET8EK8 5 MP camera sensor.
6 It is used for example in Nokia N900 (RX-51).
diff --git a/drivers/media/i2c/et8ek8/Makefile b/drivers/media/i2c/et8ek8/Makefile
new file mode 100644
index 000000000000..66d1b7d44946
--- /dev/null
+++ b/drivers/media/i2c/et8ek8/Makefile
@@ -0,0 +1,2 @@
1et8ek8-objs += et8ek8_mode.o et8ek8_driver.o
2obj-$(CONFIG_VIDEO_ET8EK8) += et8ek8.o
diff --git a/drivers/media/i2c/et8ek8/et8ek8_driver.c b/drivers/media/i2c/et8ek8/et8ek8_driver.c
new file mode 100644
index 000000000000..bec4a563a09c
--- /dev/null
+++ b/drivers/media/i2c/et8ek8/et8ek8_driver.c
@@ -0,0 +1,1514 @@
1/*
2 * et8ek8_driver.c
3 *
4 * Copyright (C) 2008 Nokia Corporation
5 *
6 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
7 * Tuukka Toivonen <tuukkat76@gmail.com>
8 * Pavel Machek <pavel@ucw.cz>
9 *
10 * Based on code from Toni Leinonen <toni.leinonen@offcode.fi>.
11 *
12 * This driver is based on the Micron MT9T012 camera imager driver
13 * (C) Texas Instruments.
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * version 2 as published by the Free Software Foundation.
18 *
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.
23 */
24
25#include <linux/clk.h>
26#include <linux/delay.h>
27#include <linux/gpio/consumer.h>
28#include <linux/i2c.h>
29#include <linux/kernel.h>
30#include <linux/module.h>
31#include <linux/mutex.h>
32#include <linux/regulator/consumer.h>
33#include <linux/slab.h>
34#include <linux/sort.h>
35#include <linux/v4l2-mediabus.h>
36
37#include <media/media-entity.h>
38#include <media/v4l2-ctrls.h>
39#include <media/v4l2-device.h>
40#include <media/v4l2-subdev.h>
41
42#include "et8ek8_reg.h"
43
44#define ET8EK8_NAME "et8ek8"
45#define ET8EK8_PRIV_MEM_SIZE 128
46#define ET8EK8_MAX_MSG 48
47
48struct et8ek8_sensor {
49 struct v4l2_subdev subdev;
50 struct media_pad pad;
51 struct v4l2_mbus_framefmt format;
52 struct gpio_desc *reset;
53 struct regulator *vana;
54 struct clk *ext_clk;
55 u32 xclk_freq;
56
57 u16 version;
58
59 struct v4l2_ctrl_handler ctrl_handler;
60 struct v4l2_ctrl *exposure;
61 struct v4l2_ctrl *pixel_rate;
62 struct et8ek8_reglist *current_reglist;
63
64 u8 priv_mem[ET8EK8_PRIV_MEM_SIZE];
65
66 struct mutex power_lock;
67 int power_count;
68};
69
70#define to_et8ek8_sensor(sd) container_of(sd, struct et8ek8_sensor, subdev)
71
72enum et8ek8_versions {
73 ET8EK8_REV_1 = 0x0001,
74 ET8EK8_REV_2,
75};
76
77/*
78 * This table describes what should be written to the sensor register
79 * for each gain value. The gain(index in the table) is in terms of
80 * 0.1EV, i.e. 10 indexes in the table give 2 time more gain [0] in
81 * the *analog gain, [1] in the digital gain
82 *
83 * Analog gain [dB] = 20*log10(regvalue/32); 0x20..0x100
84 */
85static struct et8ek8_gain {
86 u16 analog;
87 u16 digital;
88} const et8ek8_gain_table[] = {
89 { 32, 0}, /* x1 */
90 { 34, 0},
91 { 37, 0},
92 { 39, 0},
93 { 42, 0},
94 { 45, 0},
95 { 49, 0},
96 { 52, 0},
97 { 56, 0},
98 { 60, 0},
99 { 64, 0}, /* x2 */
100 { 69, 0},
101 { 74, 0},
102 { 79, 0},
103 { 84, 0},
104 { 91, 0},
105 { 97, 0},
106 {104, 0},
107 {111, 0},
108 {119, 0},
109 {128, 0}, /* x4 */
110 {137, 0},
111 {147, 0},
112 {158, 0},
113 {169, 0},
114 {181, 0},
115 {194, 0},
116 {208, 0},
117 {223, 0},
118 {239, 0},
119 {256, 0}, /* x8 */
120 {256, 73},
121 {256, 152},
122 {256, 236},
123 {256, 327},
124 {256, 424},
125 {256, 528},
126 {256, 639},
127 {256, 758},
128 {256, 886},
129 {256, 1023}, /* x16 */
130};
131
132/* Register definitions */
133#define REG_REVISION_NUMBER_L 0x1200
134#define REG_REVISION_NUMBER_H 0x1201
135
136#define PRIV_MEM_START_REG 0x0008
137#define PRIV_MEM_WIN_SIZE 8
138
139#define ET8EK8_I2C_DELAY 3 /* msec delay b/w accesses */
140
141#define USE_CRC 1
142
143/*
144 * Register access helpers
145 *
146 * Read a 8/16/32-bit i2c register. The value is returned in 'val'.
147 * Returns zero if successful, or non-zero otherwise.
148 */
149static int et8ek8_i2c_read_reg(struct i2c_client *client, u16 data_length,
150 u16 reg, u32 *val)
151{
152 int r;
153 struct i2c_msg msg;
154 unsigned char data[4];
155
156 if (!client->adapter)
157 return -ENODEV;
158 if (data_length != ET8EK8_REG_8BIT && data_length != ET8EK8_REG_16BIT)
159 return -EINVAL;
160
161 msg.addr = client->addr;
162 msg.flags = 0;
163 msg.len = 2;
164 msg.buf = data;
165
166 /* high byte goes out first */
167 data[0] = (u8) (reg >> 8);
168 data[1] = (u8) (reg & 0xff);
169 r = i2c_transfer(client->adapter, &msg, 1);
170 if (r < 0)
171 goto err;
172
173 msg.len = data_length;
174 msg.flags = I2C_M_RD;
175 r = i2c_transfer(client->adapter, &msg, 1);
176 if (r < 0)
177 goto err;
178
179 *val = 0;
180 /* high byte comes first */
181 if (data_length == ET8EK8_REG_8BIT)
182 *val = data[0];
183 else
184 *val = (data[1] << 8) + data[0];
185
186 return 0;
187
188err:
189 dev_err(&client->dev, "read from offset 0x%x error %d\n", reg, r);
190
191 return r;
192}
193
194static void et8ek8_i2c_create_msg(struct i2c_client *client, u16 len, u16 reg,
195 u32 val, struct i2c_msg *msg,
196 unsigned char *buf)
197{
198 msg->addr = client->addr;
199 msg->flags = 0; /* Write */
200 msg->len = 2 + len;
201 msg->buf = buf;
202
203 /* high byte goes out first */
204 buf[0] = (u8) (reg >> 8);
205 buf[1] = (u8) (reg & 0xff);
206
207 switch (len) {
208 case ET8EK8_REG_8BIT:
209 buf[2] = (u8) (val) & 0xff;
210 break;
211 case ET8EK8_REG_16BIT:
212 buf[2] = (u8) (val) & 0xff;
213 buf[3] = (u8) (val >> 8) & 0xff;
214 break;
215 default:
216 WARN_ONCE(1, ET8EK8_NAME ": %s: invalid message length.\n",
217 __func__);
218 }
219}
220
221/*
222 * A buffered write method that puts the wanted register write
223 * commands in a message list and passes the list to the i2c framework
224 */
225static int et8ek8_i2c_buffered_write_regs(struct i2c_client *client,
226 const struct et8ek8_reg *wnext,
227 int cnt)
228{
229 struct i2c_msg msg[ET8EK8_MAX_MSG];
230 unsigned char data[ET8EK8_MAX_MSG][6];
231 int wcnt = 0;
232 u16 reg, data_length;
233 u32 val;
234
235 if (WARN_ONCE(cnt > ET8EK8_MAX_MSG,
236 ET8EK8_NAME ": %s: too many messages.\n", __func__)) {
237 return -EINVAL;
238 }
239
240 /* Create new write messages for all writes */
241 while (wcnt < cnt) {
242 data_length = wnext->type;
243 reg = wnext->reg;
244 val = wnext->val;
245 wnext++;
246
247 et8ek8_i2c_create_msg(client, data_length, reg,
248 val, &msg[wcnt], &data[wcnt][0]);
249
250 /* Update write count */
251 wcnt++;
252 }
253
254 /* Now we send everything ... */
255 return i2c_transfer(client->adapter, msg, wcnt);
256}
257
258/*
259 * Write a list of registers to i2c device.
260 *
261 * The list of registers is terminated by ET8EK8_REG_TERM.
262 * Returns zero if successful, or non-zero otherwise.
263 */
264static int et8ek8_i2c_write_regs(struct i2c_client *client,
265 const struct et8ek8_reg *regs)
266{
267 int r, cnt = 0;
268 const struct et8ek8_reg *next;
269
270 if (!client->adapter)
271 return -ENODEV;
272
273 if (!regs)
274 return -EINVAL;
275
276 /* Initialize list pointers to the start of the list */
277 next = regs;
278
279 do {
280 /*
281 * We have to go through the list to figure out how
282 * many regular writes we have in a row
283 */
284 while (next->type != ET8EK8_REG_TERM &&
285 next->type != ET8EK8_REG_DELAY) {
286 /*
287 * Here we check that the actual length fields
288 * are valid
289 */
290 if (WARN(next->type != ET8EK8_REG_8BIT &&
291 next->type != ET8EK8_REG_16BIT,
292 "Invalid type = %d", next->type)) {
293 return -EINVAL;
294 }
295 /*
296 * Increment count of successive writes and
297 * read pointer
298 */
299 cnt++;
300 next++;
301 }
302
303 /* Now we start writing ... */
304 r = et8ek8_i2c_buffered_write_regs(client, regs, cnt);
305
306 /* ... and then check that everything was OK */
307 if (r < 0) {
308 dev_err(&client->dev, "i2c transfer error!\n");
309 return r;
310 }
311
312 /*
313 * If we ran into a sleep statement when going through
314 * the list, this is where we snooze for the required time
315 */
316 if (next->type == ET8EK8_REG_DELAY) {
317 msleep(next->val);
318 /*
319 * ZZZ ...
320 * Update list pointers and cnt and start over ...
321 */
322 next++;
323 regs = next;
324 cnt = 0;
325 }
326 } while (next->type != ET8EK8_REG_TERM);
327
328 return 0;
329}
330
331/*
332 * Write to a 8/16-bit register.
333 * Returns zero if successful, or non-zero otherwise.
334 */
335static int et8ek8_i2c_write_reg(struct i2c_client *client, u16 data_length,
336 u16 reg, u32 val)
337{
338 int r;
339 struct i2c_msg msg;
340 unsigned char data[6];
341
342 if (!client->adapter)
343 return -ENODEV;
344 if (data_length != ET8EK8_REG_8BIT && data_length != ET8EK8_REG_16BIT)
345 return -EINVAL;
346
347 et8ek8_i2c_create_msg(client, data_length, reg, val, &msg, data);
348
349 r = i2c_transfer(client->adapter, &msg, 1);
350 if (r < 0) {
351 dev_err(&client->dev,
352 "wrote 0x%x to offset 0x%x error %d\n", val, reg, r);
353 return r;
354 }
355
356 return 0;
357}
358
359static struct et8ek8_reglist *et8ek8_reglist_find_type(
360 struct et8ek8_meta_reglist *meta,
361 u16 type)
362{
363 struct et8ek8_reglist **next = &meta->reglist[0].ptr;
364
365 while (*next) {
366 if ((*next)->type == type)
367 return *next;
368
369 next++;
370 }
371
372 return NULL;
373}
374
375static int et8ek8_i2c_reglist_find_write(struct i2c_client *client,
376 struct et8ek8_meta_reglist *meta,
377 u16 type)
378{
379 struct et8ek8_reglist *reglist;
380
381 reglist = et8ek8_reglist_find_type(meta, type);
382 if (!reglist)
383 return -EINVAL;
384
385 return et8ek8_i2c_write_regs(client, reglist->regs);
386}
387
388static struct et8ek8_reglist **et8ek8_reglist_first(
389 struct et8ek8_meta_reglist *meta)
390{
391 return &meta->reglist[0].ptr;
392}
393
394static void et8ek8_reglist_to_mbus(const struct et8ek8_reglist *reglist,
395 struct v4l2_mbus_framefmt *fmt)
396{
397 fmt->width = reglist->mode.window_width;
398 fmt->height = reglist->mode.window_height;
399 fmt->code = reglist->mode.bus_format;
400}
401
402static struct et8ek8_reglist *et8ek8_reglist_find_mode_fmt(
403 struct et8ek8_meta_reglist *meta,
404 struct v4l2_mbus_framefmt *fmt)
405{
406 struct et8ek8_reglist **list = et8ek8_reglist_first(meta);
407 struct et8ek8_reglist *best_match = NULL;
408 struct et8ek8_reglist *best_other = NULL;
409 struct v4l2_mbus_framefmt format;
410 unsigned int max_dist_match = (unsigned int)-1;
411 unsigned int max_dist_other = (unsigned int)-1;
412
413 /*
414 * Find the mode with the closest image size. The distance between
415 * image sizes is the size in pixels of the non-overlapping regions
416 * between the requested size and the frame-specified size.
417 *
418 * Store both the closest mode that matches the requested format, and
419 * the closest mode for all other formats. The best match is returned
420 * if found, otherwise the best mode with a non-matching format is
421 * returned.
422 */
423 for (; *list; list++) {
424 unsigned int dist;
425
426 if ((*list)->type != ET8EK8_REGLIST_MODE)
427 continue;
428
429 et8ek8_reglist_to_mbus(*list, &format);
430
431 dist = min(fmt->width, format.width)
432 * min(fmt->height, format.height);
433 dist = format.width * format.height
434 + fmt->width * fmt->height - 2 * dist;
435
436
437 if (fmt->code == format.code) {
438 if (dist < max_dist_match || !best_match) {
439 best_match = *list;
440 max_dist_match = dist;
441 }
442 } else {
443 if (dist < max_dist_other || !best_other) {
444 best_other = *list;
445 max_dist_other = dist;
446 }
447 }
448 }
449
450 return best_match ? best_match : best_other;
451}
452
453#define TIMEPERFRAME_AVG_FPS(t) \
454 (((t).denominator + ((t).numerator >> 1)) / (t).numerator)
455
456static struct et8ek8_reglist *et8ek8_reglist_find_mode_ival(
457 struct et8ek8_meta_reglist *meta,
458 struct et8ek8_reglist *current_reglist,
459 struct v4l2_fract *timeperframe)
460{
461 int fps = TIMEPERFRAME_AVG_FPS(*timeperframe);
462 struct et8ek8_reglist **list = et8ek8_reglist_first(meta);
463 struct et8ek8_mode *current_mode = &current_reglist->mode;
464
465 for (; *list; list++) {
466 struct et8ek8_mode *mode = &(*list)->mode;
467
468 if ((*list)->type != ET8EK8_REGLIST_MODE)
469 continue;
470
471 if (mode->window_width != current_mode->window_width ||
472 mode->window_height != current_mode->window_height)
473 continue;
474
475 if (TIMEPERFRAME_AVG_FPS(mode->timeperframe) == fps)
476 return *list;
477 }
478
479 return NULL;
480}
481
482static int et8ek8_reglist_cmp(const void *a, const void *b)
483{
484 const struct et8ek8_reglist **list1 = (const struct et8ek8_reglist **)a,
485 **list2 = (const struct et8ek8_reglist **)b;
486
487 /* Put real modes in the beginning. */
488 if ((*list1)->type == ET8EK8_REGLIST_MODE &&
489 (*list2)->type != ET8EK8_REGLIST_MODE)
490 return -1;
491 if ((*list1)->type != ET8EK8_REGLIST_MODE &&
492 (*list2)->type == ET8EK8_REGLIST_MODE)
493 return 1;
494
495 /* Descending width. */
496 if ((*list1)->mode.window_width > (*list2)->mode.window_width)
497 return -1;
498 if ((*list1)->mode.window_width < (*list2)->mode.window_width)
499 return 1;
500
501 if ((*list1)->mode.window_height > (*list2)->mode.window_height)
502 return -1;
503 if ((*list1)->mode.window_height < (*list2)->mode.window_height)
504 return 1;
505
506 return 0;
507}
508
509static int et8ek8_reglist_import(struct i2c_client *client,
510 struct et8ek8_meta_reglist *meta)
511{
512 int nlists = 0, i;
513
514 dev_info(&client->dev, "meta_reglist version %s\n", meta->version);
515
516 while (meta->reglist[nlists].ptr)
517 nlists++;
518
519 if (!nlists)
520 return -EINVAL;
521
522 sort(&meta->reglist[0].ptr, nlists, sizeof(meta->reglist[0].ptr),
523 et8ek8_reglist_cmp, NULL);
524
525 i = nlists;
526 nlists = 0;
527
528 while (i--) {
529 struct et8ek8_reglist *list;
530
531 list = meta->reglist[nlists].ptr;
532
533 dev_dbg(&client->dev,
534 "%s: type %d\tw %d\th %d\tfmt %x\tival %d/%d\tptr %p\n",
535 __func__,
536 list->type,
537 list->mode.window_width, list->mode.window_height,
538 list->mode.bus_format,
539 list->mode.timeperframe.numerator,
540 list->mode.timeperframe.denominator,
541 (void *)meta->reglist[nlists].ptr);
542
543 nlists++;
544 }
545
546 return 0;
547}
548
549/* Called to change the V4L2 gain control value. This function
550 * rounds and clamps the given value and updates the V4L2 control value.
551 * If power is on, also updates the sensor analog and digital gains.
552 * gain is in 0.1 EV (exposure value) units.
553 */
554static int et8ek8_set_gain(struct et8ek8_sensor *sensor, s32 gain)
555{
556 struct i2c_client *client = v4l2_get_subdevdata(&sensor->subdev);
557 struct et8ek8_gain new;
558 int r;
559
560 new = et8ek8_gain_table[gain];
561
562 /* FIXME: optimise I2C writes! */
563 r = et8ek8_i2c_write_reg(client, ET8EK8_REG_8BIT,
564 0x124a, new.analog >> 8);
565 if (r)
566 return r;
567 r = et8ek8_i2c_write_reg(client, ET8EK8_REG_8BIT,
568 0x1249, new.analog & 0xff);
569 if (r)
570 return r;
571
572 r = et8ek8_i2c_write_reg(client, ET8EK8_REG_8BIT,
573 0x124d, new.digital >> 8);
574 if (r)
575 return r;
576 r = et8ek8_i2c_write_reg(client, ET8EK8_REG_8BIT,
577 0x124c, new.digital & 0xff);
578
579 return r;
580}
581
582static int et8ek8_set_test_pattern(struct et8ek8_sensor *sensor, s32 mode)
583{
584 struct i2c_client *client = v4l2_get_subdevdata(&sensor->subdev);
585 int cbh_mode, cbv_mode, tp_mode, din_sw, r1420, rval;
586
587 /* Values for normal mode */
588 cbh_mode = 0;
589 cbv_mode = 0;
590 tp_mode = 0;
591 din_sw = 0x00;
592 r1420 = 0xF0;
593
594 if (mode) {
595 /* Test pattern mode */
596 if (mode < 5) {
597 cbh_mode = 1;
598 cbv_mode = 1;
599 tp_mode = mode + 3;
600 } else {
601 cbh_mode = 0;
602 cbv_mode = 0;
603 tp_mode = mode - 4 + 3;
604 }
605
606 din_sw = 0x01;
607 r1420 = 0xE0;
608 }
609
610 rval = et8ek8_i2c_write_reg(client, ET8EK8_REG_8BIT, 0x111B,
611 tp_mode << 4);
612 if (rval)
613 return rval;
614
615 rval = et8ek8_i2c_write_reg(client, ET8EK8_REG_8BIT, 0x1121,
616 cbh_mode << 7);
617 if (rval)
618 return rval;
619
620 rval = et8ek8_i2c_write_reg(client, ET8EK8_REG_8BIT, 0x1124,
621 cbv_mode << 7);
622 if (rval)
623 return rval;
624
625 rval = et8ek8_i2c_write_reg(client, ET8EK8_REG_8BIT, 0x112C, din_sw);
626 if (rval)
627 return rval;
628
629 return et8ek8_i2c_write_reg(client, ET8EK8_REG_8BIT, 0x1420, r1420);
630}
631
632/* -----------------------------------------------------------------------------
633 * V4L2 controls
634 */
635
636static int et8ek8_set_ctrl(struct v4l2_ctrl *ctrl)
637{
638 struct et8ek8_sensor *sensor =
639 container_of(ctrl->handler, struct et8ek8_sensor, ctrl_handler);
640
641 switch (ctrl->id) {
642 case V4L2_CID_GAIN:
643 return et8ek8_set_gain(sensor, ctrl->val);
644
645 case V4L2_CID_EXPOSURE:
646 {
647 struct i2c_client *client =
648 v4l2_get_subdevdata(&sensor->subdev);
649
650 return et8ek8_i2c_write_reg(client, ET8EK8_REG_16BIT, 0x1243,
651 ctrl->val);
652 }
653
654 case V4L2_CID_TEST_PATTERN:
655 return et8ek8_set_test_pattern(sensor, ctrl->val);
656
657 case V4L2_CID_PIXEL_RATE:
658 return 0;
659
660 default:
661 return -EINVAL;
662 }
663}
664
665static const struct v4l2_ctrl_ops et8ek8_ctrl_ops = {
666 .s_ctrl = et8ek8_set_ctrl,
667};
668
669static const char * const et8ek8_test_pattern_menu[] = {
670 "Normal",
671 "Vertical colorbar",
672 "Horizontal colorbar",
673 "Scale",
674 "Ramp",
675 "Small vertical colorbar",
676 "Small horizontal colorbar",
677 "Small scale",
678 "Small ramp",
679};
680
681static int et8ek8_init_controls(struct et8ek8_sensor *sensor)
682{
683 s32 max_rows;
684
685 v4l2_ctrl_handler_init(&sensor->ctrl_handler, 4);
686
687 /* V4L2_CID_GAIN */
688 v4l2_ctrl_new_std(&sensor->ctrl_handler, &et8ek8_ctrl_ops,
689 V4L2_CID_GAIN, 0, ARRAY_SIZE(et8ek8_gain_table) - 1,
690 1, 0);
691
692 max_rows = sensor->current_reglist->mode.max_exp;
693 {
694 u32 min = 1, max = max_rows;
695
696 sensor->exposure =
697 v4l2_ctrl_new_std(&sensor->ctrl_handler,
698 &et8ek8_ctrl_ops, V4L2_CID_EXPOSURE,
699 min, max, min, max);
700 }
701
702 /* V4L2_CID_PIXEL_RATE */
703 sensor->pixel_rate =
704 v4l2_ctrl_new_std(&sensor->ctrl_handler, &et8ek8_ctrl_ops,
705 V4L2_CID_PIXEL_RATE, 1, INT_MAX, 1, 1);
706
707 /* V4L2_CID_TEST_PATTERN */
708 v4l2_ctrl_new_std_menu_items(&sensor->ctrl_handler,
709 &et8ek8_ctrl_ops, V4L2_CID_TEST_PATTERN,
710 ARRAY_SIZE(et8ek8_test_pattern_menu) - 1,
711 0, 0, et8ek8_test_pattern_menu);
712
713 if (sensor->ctrl_handler.error)
714 return sensor->ctrl_handler.error;
715
716 sensor->subdev.ctrl_handler = &sensor->ctrl_handler;
717
718 return 0;
719}
720
721static void et8ek8_update_controls(struct et8ek8_sensor *sensor)
722{
723 struct v4l2_ctrl *ctrl;
724 struct et8ek8_mode *mode = &sensor->current_reglist->mode;
725
726 u32 min, max, pixel_rate;
727 static const int S = 8;
728
729 ctrl = sensor->exposure;
730
731 min = 1;
732 max = mode->max_exp;
733
734 /*
735 * Calculate average pixel clock per line. Assume buffers can spread
736 * the data over horizontal blanking time. Rounding upwards.
737 * Formula taken from stock Nokia N900 kernel.
738 */
739 pixel_rate = ((mode->pixel_clock + (1 << S) - 1) >> S) + mode->width;
740 pixel_rate = mode->window_width * (pixel_rate - 1) / mode->width;
741
742 __v4l2_ctrl_modify_range(ctrl, min, max, min, max);
743 __v4l2_ctrl_s_ctrl_int64(sensor->pixel_rate, pixel_rate << S);
744}
745
746static int et8ek8_configure(struct et8ek8_sensor *sensor)
747{
748 struct v4l2_subdev *subdev = &sensor->subdev;
749 struct i2c_client *client = v4l2_get_subdevdata(subdev);
750 int rval;
751
752 rval = et8ek8_i2c_write_regs(client, sensor->current_reglist->regs);
753 if (rval)
754 goto fail;
755
756 /* Controls set while the power to the sensor is turned off are saved
757 * but not applied to the hardware. Now that we're about to start
758 * streaming apply all the current values to the hardware.
759 */
760 rval = v4l2_ctrl_handler_setup(&sensor->ctrl_handler);
761 if (rval)
762 goto fail;
763
764 return 0;
765
766fail:
767 dev_err(&client->dev, "sensor configuration failed\n");
768
769 return rval;
770}
771
772static int et8ek8_stream_on(struct et8ek8_sensor *sensor)
773{
774 struct i2c_client *client = v4l2_get_subdevdata(&sensor->subdev);
775
776 return et8ek8_i2c_write_reg(client, ET8EK8_REG_8BIT, 0x1252, 0xb0);
777}
778
779static int et8ek8_stream_off(struct et8ek8_sensor *sensor)
780{
781 struct i2c_client *client = v4l2_get_subdevdata(&sensor->subdev);
782
783 return et8ek8_i2c_write_reg(client, ET8EK8_REG_8BIT, 0x1252, 0x30);
784}
785
786static int et8ek8_s_stream(struct v4l2_subdev *subdev, int streaming)
787{
788 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev);
789 int ret;
790
791 if (!streaming)
792 return et8ek8_stream_off(sensor);
793
794 ret = et8ek8_configure(sensor);
795 if (ret < 0)
796 return ret;
797
798 return et8ek8_stream_on(sensor);
799}
800
801/* --------------------------------------------------------------------------
802 * V4L2 subdev operations
803 */
804
805static int et8ek8_power_off(struct et8ek8_sensor *sensor)
806{
807 gpiod_set_value(sensor->reset, 0);
808 udelay(1);
809
810 clk_disable_unprepare(sensor->ext_clk);
811
812 return regulator_disable(sensor->vana);
813}
814
815static int et8ek8_power_on(struct et8ek8_sensor *sensor)
816{
817 struct v4l2_subdev *subdev = &sensor->subdev;
818 struct i2c_client *client = v4l2_get_subdevdata(subdev);
819 unsigned int xclk_freq;
820 int val, rval;
821
822 rval = regulator_enable(sensor->vana);
823 if (rval) {
824 dev_err(&client->dev, "failed to enable vana regulator\n");
825 return rval;
826 }
827
828 if (sensor->current_reglist)
829 xclk_freq = sensor->current_reglist->mode.ext_clock;
830 else
831 xclk_freq = sensor->xclk_freq;
832
833 rval = clk_set_rate(sensor->ext_clk, xclk_freq);
834 if (rval < 0) {
835 dev_err(&client->dev, "unable to set extclk clock freq to %u\n",
836 xclk_freq);
837 goto out;
838 }
839 rval = clk_prepare_enable(sensor->ext_clk);
840 if (rval < 0) {
841 dev_err(&client->dev, "failed to enable extclk\n");
842 goto out;
843 }
844
845 if (rval)
846 goto out;
847
848 udelay(10); /* I wish this is a good value */
849
850 gpiod_set_value(sensor->reset, 1);
851
852 msleep(5000 * 1000 / xclk_freq + 1); /* Wait 5000 cycles */
853
854 rval = et8ek8_i2c_reglist_find_write(client, &meta_reglist,
855 ET8EK8_REGLIST_POWERON);
856 if (rval)
857 goto out;
858
859#ifdef USE_CRC
860 rval = et8ek8_i2c_read_reg(client, ET8EK8_REG_8BIT, 0x1263, &val);
861 if (rval)
862 goto out;
863#if USE_CRC /* TODO get crc setting from DT */
864 val |= BIT(4);
865#else
866 val &= ~BIT(4);
867#endif
868 rval = et8ek8_i2c_write_reg(client, ET8EK8_REG_8BIT, 0x1263, val);
869 if (rval)
870 goto out;
871#endif
872
873out:
874 if (rval)
875 et8ek8_power_off(sensor);
876
877 return rval;
878}
879
880/* --------------------------------------------------------------------------
881 * V4L2 subdev video operations
882 */
883#define MAX_FMTS 4
884static int et8ek8_enum_mbus_code(struct v4l2_subdev *subdev,
885 struct v4l2_subdev_pad_config *cfg,
886 struct v4l2_subdev_mbus_code_enum *code)
887{
888 struct et8ek8_reglist **list =
889 et8ek8_reglist_first(&meta_reglist);
890 u32 pixelformat[MAX_FMTS];
891 int npixelformat = 0;
892
893 if (code->index >= MAX_FMTS)
894 return -EINVAL;
895
896 for (; *list; list++) {
897 struct et8ek8_mode *mode = &(*list)->mode;
898 int i;
899
900 if ((*list)->type != ET8EK8_REGLIST_MODE)
901 continue;
902
903 for (i = 0; i < npixelformat; i++) {
904 if (pixelformat[i] == mode->bus_format)
905 break;
906 }
907 if (i != npixelformat)
908 continue;
909
910 if (code->index == npixelformat) {
911 code->code = mode->bus_format;
912 return 0;
913 }
914
915 pixelformat[npixelformat] = mode->bus_format;
916 npixelformat++;
917 }
918
919 return -EINVAL;
920}
921
922static int et8ek8_enum_frame_size(struct v4l2_subdev *subdev,
923 struct v4l2_subdev_pad_config *cfg,
924 struct v4l2_subdev_frame_size_enum *fse)
925{
926 struct et8ek8_reglist **list =
927 et8ek8_reglist_first(&meta_reglist);
928 struct v4l2_mbus_framefmt format;
929 int cmp_width = INT_MAX;
930 int cmp_height = INT_MAX;
931 int index = fse->index;
932
933 for (; *list; list++) {
934 if ((*list)->type != ET8EK8_REGLIST_MODE)
935 continue;
936
937 et8ek8_reglist_to_mbus(*list, &format);
938 if (fse->code != format.code)
939 continue;
940
941 /* Assume that the modes are grouped by frame size. */
942 if (format.width == cmp_width && format.height == cmp_height)
943 continue;
944
945 cmp_width = format.width;
946 cmp_height = format.height;
947
948 if (index-- == 0) {
949 fse->min_width = format.width;
950 fse->min_height = format.height;
951 fse->max_width = format.width;
952 fse->max_height = format.height;
953 return 0;
954 }
955 }
956
957 return -EINVAL;
958}
959
960static int et8ek8_enum_frame_ival(struct v4l2_subdev *subdev,
961 struct v4l2_subdev_pad_config *cfg,
962 struct v4l2_subdev_frame_interval_enum *fie)
963{
964 struct et8ek8_reglist **list =
965 et8ek8_reglist_first(&meta_reglist);
966 struct v4l2_mbus_framefmt format;
967 int index = fie->index;
968
969 for (; *list; list++) {
970 struct et8ek8_mode *mode = &(*list)->mode;
971
972 if ((*list)->type != ET8EK8_REGLIST_MODE)
973 continue;
974
975 et8ek8_reglist_to_mbus(*list, &format);
976 if (fie->code != format.code)
977 continue;
978
979 if (fie->width != format.width || fie->height != format.height)
980 continue;
981
982 if (index-- == 0) {
983 fie->interval = mode->timeperframe;
984 return 0;
985 }
986 }
987
988 return -EINVAL;
989}
990
991static struct v4l2_mbus_framefmt *
992__et8ek8_get_pad_format(struct et8ek8_sensor *sensor,
993 struct v4l2_subdev_pad_config *cfg,
994 unsigned int pad, enum v4l2_subdev_format_whence which)
995{
996 switch (which) {
997 case V4L2_SUBDEV_FORMAT_TRY:
998 return v4l2_subdev_get_try_format(&sensor->subdev, cfg, pad);
999 case V4L2_SUBDEV_FORMAT_ACTIVE:
1000 return &sensor->format;
1001 default:
1002 return NULL;
1003 }
1004}
1005
1006static int et8ek8_get_pad_format(struct v4l2_subdev *subdev,
1007 struct v4l2_subdev_pad_config *cfg,
1008 struct v4l2_subdev_format *fmt)
1009{
1010 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev);
1011 struct v4l2_mbus_framefmt *format;
1012
1013 format = __et8ek8_get_pad_format(sensor, cfg, fmt->pad, fmt->which);
1014 if (!format)
1015 return -EINVAL;
1016
1017 fmt->format = *format;
1018
1019 return 0;
1020}
1021
1022static int et8ek8_set_pad_format(struct v4l2_subdev *subdev,
1023 struct v4l2_subdev_pad_config *cfg,
1024 struct v4l2_subdev_format *fmt)
1025{
1026 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev);
1027 struct v4l2_mbus_framefmt *format;
1028 struct et8ek8_reglist *reglist;
1029
1030 format = __et8ek8_get_pad_format(sensor, cfg, fmt->pad, fmt->which);
1031 if (!format)
1032 return -EINVAL;
1033
1034 reglist = et8ek8_reglist_find_mode_fmt(&meta_reglist, &fmt->format);
1035 et8ek8_reglist_to_mbus(reglist, &fmt->format);
1036 *format = fmt->format;
1037
1038 if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
1039 sensor->current_reglist = reglist;
1040 et8ek8_update_controls(sensor);
1041 }
1042
1043 return 0;
1044}
1045
1046static int et8ek8_get_frame_interval(struct v4l2_subdev *subdev,
1047 struct v4l2_subdev_frame_interval *fi)
1048{
1049 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev);
1050
1051 memset(fi, 0, sizeof(*fi));
1052 fi->interval = sensor->current_reglist->mode.timeperframe;
1053
1054 return 0;
1055}
1056
1057static int et8ek8_set_frame_interval(struct v4l2_subdev *subdev,
1058 struct v4l2_subdev_frame_interval *fi)
1059{
1060 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev);
1061 struct et8ek8_reglist *reglist;
1062
1063 reglist = et8ek8_reglist_find_mode_ival(&meta_reglist,
1064 sensor->current_reglist,
1065 &fi->interval);
1066
1067 if (!reglist)
1068 return -EINVAL;
1069
1070 if (sensor->current_reglist->mode.ext_clock != reglist->mode.ext_clock)
1071 return -EINVAL;
1072
1073 sensor->current_reglist = reglist;
1074 et8ek8_update_controls(sensor);
1075
1076 return 0;
1077}
1078
1079static int et8ek8_g_priv_mem(struct v4l2_subdev *subdev)
1080{
1081 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev);
1082 struct i2c_client *client = v4l2_get_subdevdata(subdev);
1083 unsigned int length = ET8EK8_PRIV_MEM_SIZE;
1084 unsigned int offset = 0;
1085 u8 *ptr = sensor->priv_mem;
1086 int rval = 0;
1087
1088 /* Read the EEPROM window-by-window, each window 8 bytes */
1089 do {
1090 u8 buffer[PRIV_MEM_WIN_SIZE];
1091 struct i2c_msg msg;
1092 int bytes, i;
1093 int ofs;
1094
1095 /* Set the current window */
1096 rval = et8ek8_i2c_write_reg(client, ET8EK8_REG_8BIT, 0x0001,
1097 0xe0 | (offset >> 3));
1098 if (rval < 0)
1099 return rval;
1100
1101 /* Wait for status bit */
1102 for (i = 0; i < 1000; ++i) {
1103 u32 status;
1104
1105 rval = et8ek8_i2c_read_reg(client, ET8EK8_REG_8BIT,
1106 0x0003, &status);
1107 if (rval < 0)
1108 return rval;
1109 if (!(status & 0x08))
1110 break;
1111 usleep_range(1000, 2000);
1112 }
1113
1114 if (i == 1000)
1115 return -EIO;
1116
1117 /* Read window, 8 bytes at once, and copy to user space */
1118 ofs = offset & 0x07; /* Offset within this window */
1119 bytes = length + ofs > 8 ? 8-ofs : length;
1120 msg.addr = client->addr;
1121 msg.flags = 0;
1122 msg.len = 2;
1123 msg.buf = buffer;
1124 ofs += PRIV_MEM_START_REG;
1125 buffer[0] = (u8)(ofs >> 8);
1126 buffer[1] = (u8)(ofs & 0xFF);
1127
1128 rval = i2c_transfer(client->adapter, &msg, 1);
1129 if (rval < 0)
1130 return rval;
1131
1132 mdelay(ET8EK8_I2C_DELAY);
1133 msg.addr = client->addr;
1134 msg.len = bytes;
1135 msg.flags = I2C_M_RD;
1136 msg.buf = buffer;
1137 memset(buffer, 0, sizeof(buffer));
1138
1139 rval = i2c_transfer(client->adapter, &msg, 1);
1140 if (rval < 0)
1141 return rval;
1142
1143 rval = 0;
1144 memcpy(ptr, buffer, bytes);
1145
1146 length -= bytes;
1147 offset += bytes;
1148 ptr += bytes;
1149 } while (length > 0);
1150
1151 return rval;
1152}
1153
1154static int et8ek8_dev_init(struct v4l2_subdev *subdev)
1155{
1156 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev);
1157 struct i2c_client *client = v4l2_get_subdevdata(subdev);
1158 int rval, rev_l, rev_h;
1159
1160 rval = et8ek8_power_on(sensor);
1161 if (rval) {
1162 dev_err(&client->dev, "could not power on\n");
1163 return rval;
1164 }
1165
1166 rval = et8ek8_i2c_read_reg(client, ET8EK8_REG_8BIT,
1167 REG_REVISION_NUMBER_L, &rev_l);
1168 if (!rval)
1169 rval = et8ek8_i2c_read_reg(client, ET8EK8_REG_8BIT,
1170 REG_REVISION_NUMBER_H, &rev_h);
1171 if (rval) {
1172 dev_err(&client->dev, "no et8ek8 sensor detected\n");
1173 goto out_poweroff;
1174 }
1175
1176 sensor->version = (rev_h << 8) + rev_l;
1177 if (sensor->version != ET8EK8_REV_1 && sensor->version != ET8EK8_REV_2)
1178 dev_info(&client->dev,
1179 "unknown version 0x%x detected, continuing anyway\n",
1180 sensor->version);
1181
1182 rval = et8ek8_reglist_import(client, &meta_reglist);
1183 if (rval) {
1184 dev_err(&client->dev,
1185 "invalid register list %s, import failed\n",
1186 ET8EK8_NAME);
1187 goto out_poweroff;
1188 }
1189
1190 sensor->current_reglist = et8ek8_reglist_find_type(&meta_reglist,
1191 ET8EK8_REGLIST_MODE);
1192 if (!sensor->current_reglist) {
1193 dev_err(&client->dev,
1194 "invalid register list %s, no mode found\n",
1195 ET8EK8_NAME);
1196 rval = -ENODEV;
1197 goto out_poweroff;
1198 }
1199
1200 et8ek8_reglist_to_mbus(sensor->current_reglist, &sensor->format);
1201
1202 rval = et8ek8_i2c_reglist_find_write(client, &meta_reglist,
1203 ET8EK8_REGLIST_POWERON);
1204 if (rval) {
1205 dev_err(&client->dev,
1206 "invalid register list %s, no POWERON mode found\n",
1207 ET8EK8_NAME);
1208 goto out_poweroff;
1209 }
1210 rval = et8ek8_stream_on(sensor); /* Needed to be able to read EEPROM */
1211 if (rval)
1212 goto out_poweroff;
1213 rval = et8ek8_g_priv_mem(subdev);
1214 if (rval)
1215 dev_warn(&client->dev,
1216 "can not read OTP (EEPROM) memory from sensor\n");
1217 rval = et8ek8_stream_off(sensor);
1218 if (rval)
1219 goto out_poweroff;
1220
1221 rval = et8ek8_power_off(sensor);
1222 if (rval)
1223 goto out_poweroff;
1224
1225 return 0;
1226
1227out_poweroff:
1228 et8ek8_power_off(sensor);
1229
1230 return rval;
1231}
1232
1233/* --------------------------------------------------------------------------
1234 * sysfs attributes
1235 */
1236static ssize_t
1237et8ek8_priv_mem_read(struct device *dev, struct device_attribute *attr,
1238 char *buf)
1239{
1240 struct v4l2_subdev *subdev = i2c_get_clientdata(to_i2c_client(dev));
1241 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev);
1242
1243#if PAGE_SIZE < ET8EK8_PRIV_MEM_SIZE
1244#error PAGE_SIZE too small!
1245#endif
1246
1247 memcpy(buf, sensor->priv_mem, ET8EK8_PRIV_MEM_SIZE);
1248
1249 return ET8EK8_PRIV_MEM_SIZE;
1250}
1251static DEVICE_ATTR(priv_mem, 0444, et8ek8_priv_mem_read, NULL);
1252
1253/* --------------------------------------------------------------------------
1254 * V4L2 subdev core operations
1255 */
1256
1257static int
1258et8ek8_registered(struct v4l2_subdev *subdev)
1259{
1260 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev);
1261 struct i2c_client *client = v4l2_get_subdevdata(subdev);
1262 int rval;
1263
1264 dev_dbg(&client->dev, "registered!");
1265
1266 rval = device_create_file(&client->dev, &dev_attr_priv_mem);
1267 if (rval) {
1268 dev_err(&client->dev, "could not register sysfs entry\n");
1269 return rval;
1270 }
1271
1272 rval = et8ek8_dev_init(subdev);
1273 if (rval)
1274 goto err_file;
1275
1276 rval = et8ek8_init_controls(sensor);
1277 if (rval) {
1278 dev_err(&client->dev, "controls initialization failed\n");
1279 goto err_file;
1280 }
1281
1282 __et8ek8_get_pad_format(sensor, NULL, 0, V4L2_SUBDEV_FORMAT_ACTIVE);
1283
1284 return 0;
1285
1286err_file:
1287 device_remove_file(&client->dev, &dev_attr_priv_mem);
1288
1289 return rval;
1290}
1291
1292static int __et8ek8_set_power(struct et8ek8_sensor *sensor, bool on)
1293{
1294 return on ? et8ek8_power_on(sensor) : et8ek8_power_off(sensor);
1295}
1296
1297static int et8ek8_set_power(struct v4l2_subdev *subdev, int on)
1298{
1299 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev);
1300 int ret = 0;
1301
1302 mutex_lock(&sensor->power_lock);
1303
1304 /* If the power count is modified from 0 to != 0 or from != 0 to 0,
1305 * update the power state.
1306 */
1307 if (sensor->power_count == !on) {
1308 ret = __et8ek8_set_power(sensor, !!on);
1309 if (ret < 0)
1310 goto done;
1311 }
1312
1313 /* Update the power count. */
1314 sensor->power_count += on ? 1 : -1;
1315 WARN_ON(sensor->power_count < 0);
1316
1317done:
1318 mutex_unlock(&sensor->power_lock);
1319
1320 return ret;
1321}
1322
1323static int et8ek8_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
1324{
1325 struct et8ek8_sensor *sensor = to_et8ek8_sensor(sd);
1326 struct v4l2_mbus_framefmt *format;
1327 struct et8ek8_reglist *reglist;
1328
1329 reglist = et8ek8_reglist_find_type(&meta_reglist, ET8EK8_REGLIST_MODE);
1330 format = __et8ek8_get_pad_format(sensor, fh->pad, 0,
1331 V4L2_SUBDEV_FORMAT_TRY);
1332 et8ek8_reglist_to_mbus(reglist, format);
1333
1334 return et8ek8_set_power(sd, true);
1335}
1336
1337static int et8ek8_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
1338{
1339 return et8ek8_set_power(sd, false);
1340}
1341
1342static const struct v4l2_subdev_video_ops et8ek8_video_ops = {
1343 .s_stream = et8ek8_s_stream,
1344 .g_frame_interval = et8ek8_get_frame_interval,
1345 .s_frame_interval = et8ek8_set_frame_interval,
1346};
1347
1348static const struct v4l2_subdev_core_ops et8ek8_core_ops = {
1349 .s_power = et8ek8_set_power,
1350};
1351
1352static const struct v4l2_subdev_pad_ops et8ek8_pad_ops = {
1353 .enum_mbus_code = et8ek8_enum_mbus_code,
1354 .enum_frame_size = et8ek8_enum_frame_size,
1355 .enum_frame_interval = et8ek8_enum_frame_ival,
1356 .get_fmt = et8ek8_get_pad_format,
1357 .set_fmt = et8ek8_set_pad_format,
1358};
1359
1360static const struct v4l2_subdev_ops et8ek8_ops = {
1361 .core = &et8ek8_core_ops,
1362 .video = &et8ek8_video_ops,
1363 .pad = &et8ek8_pad_ops,
1364};
1365
1366static const struct v4l2_subdev_internal_ops et8ek8_internal_ops = {
1367 .registered = et8ek8_registered,
1368 .open = et8ek8_open,
1369 .close = et8ek8_close,
1370};
1371
1372/* --------------------------------------------------------------------------
1373 * I2C driver
1374 */
1375static int __maybe_unused et8ek8_suspend(struct device *dev)
1376{
1377 struct i2c_client *client = to_i2c_client(dev);
1378 struct v4l2_subdev *subdev = i2c_get_clientdata(client);
1379 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev);
1380
1381 if (!sensor->power_count)
1382 return 0;
1383
1384 return __et8ek8_set_power(sensor, false);
1385}
1386
1387static int __maybe_unused et8ek8_resume(struct device *dev)
1388{
1389 struct i2c_client *client = to_i2c_client(dev);
1390 struct v4l2_subdev *subdev = i2c_get_clientdata(client);
1391 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev);
1392
1393 if (!sensor->power_count)
1394 return 0;
1395
1396 return __et8ek8_set_power(sensor, true);
1397}
1398
1399static int et8ek8_probe(struct i2c_client *client,
1400 const struct i2c_device_id *devid)
1401{
1402 struct et8ek8_sensor *sensor;
1403 struct device *dev = &client->dev;
1404 int ret;
1405
1406 sensor = devm_kzalloc(&client->dev, sizeof(*sensor), GFP_KERNEL);
1407 if (!sensor)
1408 return -ENOMEM;
1409
1410 sensor->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
1411 if (IS_ERR(sensor->reset)) {
1412 dev_dbg(&client->dev, "could not request reset gpio\n");
1413 return PTR_ERR(sensor->reset);
1414 }
1415
1416 sensor->vana = devm_regulator_get(dev, "vana");
1417 if (IS_ERR(sensor->vana)) {
1418 dev_err(&client->dev, "could not get regulator for vana\n");
1419 return PTR_ERR(sensor->vana);
1420 }
1421
1422 sensor->ext_clk = devm_clk_get(dev, NULL);
1423 if (IS_ERR(sensor->ext_clk)) {
1424 dev_err(&client->dev, "could not get clock\n");
1425 return PTR_ERR(sensor->ext_clk);
1426 }
1427
1428 ret = of_property_read_u32(dev->of_node, "clock-frequency",
1429 &sensor->xclk_freq);
1430 if (ret) {
1431 dev_warn(dev, "can't get clock-frequency\n");
1432 return ret;
1433 }
1434
1435 mutex_init(&sensor->power_lock);
1436
1437 v4l2_i2c_subdev_init(&sensor->subdev, client, &et8ek8_ops);
1438 sensor->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
1439 sensor->subdev.internal_ops = &et8ek8_internal_ops;
1440
1441 sensor->pad.flags = MEDIA_PAD_FL_SOURCE;
1442 ret = media_entity_pads_init(&sensor->subdev.entity, 1, &sensor->pad);
1443 if (ret < 0) {
1444 dev_err(&client->dev, "media entity init failed!\n");
1445 goto err_mutex;
1446 }
1447
1448 ret = v4l2_async_register_subdev(&sensor->subdev);
1449 if (ret < 0)
1450 goto err_entity;
1451
1452 dev_dbg(dev, "initialized!\n");
1453
1454 return 0;
1455
1456err_entity:
1457 media_entity_cleanup(&sensor->subdev.entity);
1458err_mutex:
1459 mutex_destroy(&sensor->power_lock);
1460 return ret;
1461}
1462
1463static int __exit et8ek8_remove(struct i2c_client *client)
1464{
1465 struct v4l2_subdev *subdev = i2c_get_clientdata(client);
1466 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev);
1467
1468 if (sensor->power_count) {
1469 WARN_ON(1);
1470 et8ek8_power_off(sensor);
1471 sensor->power_count = 0;
1472 }
1473
1474 v4l2_device_unregister_subdev(&sensor->subdev);
1475 device_remove_file(&client->dev, &dev_attr_priv_mem);
1476 v4l2_ctrl_handler_free(&sensor->ctrl_handler);
1477 v4l2_async_unregister_subdev(&sensor->subdev);
1478 media_entity_cleanup(&sensor->subdev.entity);
1479 mutex_destroy(&sensor->power_lock);
1480
1481 return 0;
1482}
1483
1484static const struct of_device_id et8ek8_of_table[] = {
1485 { .compatible = "toshiba,et8ek8" },
1486 { },
1487};
1488
1489static const struct i2c_device_id et8ek8_id_table[] = {
1490 { ET8EK8_NAME, 0 },
1491 { }
1492};
1493MODULE_DEVICE_TABLE(i2c, et8ek8_id_table);
1494
1495static const struct dev_pm_ops et8ek8_pm_ops = {
1496 SET_SYSTEM_SLEEP_PM_OPS(et8ek8_suspend, et8ek8_resume)
1497};
1498
1499static struct i2c_driver et8ek8_i2c_driver = {
1500 .driver = {
1501 .name = ET8EK8_NAME,
1502 .pm = &et8ek8_pm_ops,
1503 .of_match_table = et8ek8_of_table,
1504 },
1505 .probe = et8ek8_probe,
1506 .remove = __exit_p(et8ek8_remove),
1507 .id_table = et8ek8_id_table,
1508};
1509
1510module_i2c_driver(et8ek8_i2c_driver);
1511
1512MODULE_AUTHOR("Sakari Ailus <sakari.ailus@iki.fi>, Pavel Machek <pavel@ucw.cz");
1513MODULE_DESCRIPTION("Toshiba ET8EK8 camera sensor driver");
1514MODULE_LICENSE("GPL");
diff --git a/drivers/media/i2c/et8ek8/et8ek8_mode.c b/drivers/media/i2c/et8ek8/et8ek8_mode.c
new file mode 100644
index 000000000000..a79882a83885
--- /dev/null
+++ b/drivers/media/i2c/et8ek8/et8ek8_mode.c
@@ -0,0 +1,587 @@
1/*
2 * et8ek8_mode.c
3 *
4 * Copyright (C) 2008 Nokia Corporation
5 *
6 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
7 * Tuukka Toivonen <tuukkat76@gmail.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 */
18
19#include "et8ek8_reg.h"
20
21/*
22 * Stingray sensor mode settings for Scooby
23 */
24
25/* Mode1_poweron_Mode2_16VGA_2592x1968_12.07fps */
26static struct et8ek8_reglist mode1_poweron_mode2_16vga_2592x1968_12_07fps = {
27/* (without the +1)
28 * SPCK = 80 MHz
29 * CCP2 = 640 MHz
30 * VCO = 640 MHz
31 * VCOUNT = 84 (2016)
32 * HCOUNT = 137 (3288)
33 * CKREF_DIV = 2
34 * CKVAR_DIV = 200
35 * VCO_DIV = 0
36 * SPCK_DIV = 7
37 * MRCK_DIV = 7
38 * LVDSCK_DIV = 0
39 */
40 .type = ET8EK8_REGLIST_POWERON,
41 .mode = {
42 .sensor_width = 2592,
43 .sensor_height = 1968,
44 .sensor_window_origin_x = 0,
45 .sensor_window_origin_y = 0,
46 .sensor_window_width = 2592,
47 .sensor_window_height = 1968,
48 .width = 3288,
49 .height = 2016,
50 .window_origin_x = 0,
51 .window_origin_y = 0,
52 .window_width = 2592,
53 .window_height = 1968,
54 .pixel_clock = 80000000,
55 .ext_clock = 9600000,
56 .timeperframe = {
57 .numerator = 100,
58 .denominator = 1207
59 },
60 .max_exp = 2012,
61 /* .max_gain = 0, */
62 .bus_format = MEDIA_BUS_FMT_SGRBG10_1X10,
63 .sensitivity = 65536
64 },
65 .regs = {
66 /* Need to set firstly */
67 { ET8EK8_REG_8BIT, 0x126C, 0xCC },
68 /* Strobe and Data of CCP2 delay are minimized. */
69 { ET8EK8_REG_8BIT, 0x1269, 0x00 },
70 /* Refined value of Min H_COUNT */
71 { ET8EK8_REG_8BIT, 0x1220, 0x89 },
72 /* Frequency of SPCK setting (SPCK=MRCK) */
73 { ET8EK8_REG_8BIT, 0x123A, 0x07 },
74 { ET8EK8_REG_8BIT, 0x1241, 0x94 },
75 { ET8EK8_REG_8BIT, 0x1242, 0x02 },
76 { ET8EK8_REG_8BIT, 0x124B, 0x00 },
77 { ET8EK8_REG_8BIT, 0x1255, 0xFF },
78 { ET8EK8_REG_8BIT, 0x1256, 0x9F },
79 { ET8EK8_REG_8BIT, 0x1258, 0x00 },
80 /* From parallel out to serial out */
81 { ET8EK8_REG_8BIT, 0x125D, 0x88 },
82 /* From w/ embeded data to w/o embeded data */
83 { ET8EK8_REG_8BIT, 0x125E, 0xC0 },
84 /* CCP2 out is from STOP to ACTIVE */
85 { ET8EK8_REG_8BIT, 0x1263, 0x98 },
86 { ET8EK8_REG_8BIT, 0x1268, 0xC6 },
87 { ET8EK8_REG_8BIT, 0x1434, 0x00 },
88 { ET8EK8_REG_8BIT, 0x1163, 0x44 },
89 { ET8EK8_REG_8BIT, 0x1166, 0x29 },
90 { ET8EK8_REG_8BIT, 0x1140, 0x02 },
91 { ET8EK8_REG_8BIT, 0x1011, 0x24 },
92 { ET8EK8_REG_8BIT, 0x1151, 0x80 },
93 { ET8EK8_REG_8BIT, 0x1152, 0x23 },
94 /* Initial setting for improvement2 of lower frequency noise */
95 { ET8EK8_REG_8BIT, 0x1014, 0x05 },
96 { ET8EK8_REG_8BIT, 0x1033, 0x06 },
97 { ET8EK8_REG_8BIT, 0x1034, 0x79 },
98 { ET8EK8_REG_8BIT, 0x1423, 0x3F },
99 { ET8EK8_REG_8BIT, 0x1424, 0x3F },
100 { ET8EK8_REG_8BIT, 0x1426, 0x00 },
101 /* Switch of Preset-White-balance (0d:disable / 1d:enable) */
102 { ET8EK8_REG_8BIT, 0x1439, 0x00 },
103 /* Switch of blemish correction (0d:disable / 1d:enable) */
104 { ET8EK8_REG_8BIT, 0x161F, 0x60 },
105 /* Switch of auto noise correction (0d:disable / 1d:enable) */
106 { ET8EK8_REG_8BIT, 0x1634, 0x00 },
107 { ET8EK8_REG_8BIT, 0x1646, 0x00 },
108 { ET8EK8_REG_8BIT, 0x1648, 0x00 },
109 { ET8EK8_REG_8BIT, 0x113E, 0x01 },
110 { ET8EK8_REG_8BIT, 0x113F, 0x22 },
111 { ET8EK8_REG_8BIT, 0x1239, 0x64 },
112 { ET8EK8_REG_8BIT, 0x1238, 0x02 },
113 { ET8EK8_REG_8BIT, 0x123B, 0x70 },
114 { ET8EK8_REG_8BIT, 0x123A, 0x07 },
115 { ET8EK8_REG_8BIT, 0x121B, 0x64 },
116 { ET8EK8_REG_8BIT, 0x121D, 0x64 },
117 { ET8EK8_REG_8BIT, 0x1221, 0x00 },
118 { ET8EK8_REG_8BIT, 0x1220, 0x89 },
119 { ET8EK8_REG_8BIT, 0x1223, 0x00 },
120 { ET8EK8_REG_8BIT, 0x1222, 0x54 },
121 { ET8EK8_REG_8BIT, 0x125D, 0x88 }, /* CCP_LVDS_MODE/ */
122 { ET8EK8_REG_TERM, 0, 0}
123 }
124};
125
126/* Mode1_16VGA_2592x1968_13.12fps_DPCM10-8 */
127static struct et8ek8_reglist mode1_16vga_2592x1968_13_12fps_dpcm10_8 = {
128/* (without the +1)
129 * SPCK = 80 MHz
130 * CCP2 = 560 MHz
131 * VCO = 560 MHz
132 * VCOUNT = 84 (2016)
133 * HCOUNT = 128 (3072)
134 * CKREF_DIV = 2
135 * CKVAR_DIV = 175
136 * VCO_DIV = 0
137 * SPCK_DIV = 6
138 * MRCK_DIV = 7
139 * LVDSCK_DIV = 0
140 */
141 .type = ET8EK8_REGLIST_MODE,
142 .mode = {
143 .sensor_width = 2592,
144 .sensor_height = 1968,
145 .sensor_window_origin_x = 0,
146 .sensor_window_origin_y = 0,
147 .sensor_window_width = 2592,
148 .sensor_window_height = 1968,
149 .width = 3072,
150 .height = 2016,
151 .window_origin_x = 0,
152 .window_origin_y = 0,
153 .window_width = 2592,
154 .window_height = 1968,
155 .pixel_clock = 80000000,
156 .ext_clock = 9600000,
157 .timeperframe = {
158 .numerator = 100,
159 .denominator = 1292
160 },
161 .max_exp = 2012,
162 /* .max_gain = 0, */
163 .bus_format = MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8,
164 .sensitivity = 65536
165 },
166 .regs = {
167 { ET8EK8_REG_8BIT, 0x1239, 0x57 },
168 { ET8EK8_REG_8BIT, 0x1238, 0x82 },
169 { ET8EK8_REG_8BIT, 0x123B, 0x70 },
170 { ET8EK8_REG_8BIT, 0x123A, 0x06 },
171 { ET8EK8_REG_8BIT, 0x121B, 0x64 },
172 { ET8EK8_REG_8BIT, 0x121D, 0x64 },
173 { ET8EK8_REG_8BIT, 0x1221, 0x00 },
174 { ET8EK8_REG_8BIT, 0x1220, 0x80 }, /* <-changed to v14 7E->80 */
175 { ET8EK8_REG_8BIT, 0x1223, 0x00 },
176 { ET8EK8_REG_8BIT, 0x1222, 0x54 },
177 { ET8EK8_REG_8BIT, 0x125D, 0x83 }, /* CCP_LVDS_MODE/ */
178 { ET8EK8_REG_TERM, 0, 0}
179 }
180};
181
182/* Mode3_4VGA_1296x984_29.99fps_DPCM10-8 */
183static struct et8ek8_reglist mode3_4vga_1296x984_29_99fps_dpcm10_8 = {
184/* (without the +1)
185 * SPCK = 96.5333333333333 MHz
186 * CCP2 = 579.2 MHz
187 * VCO = 579.2 MHz
188 * VCOUNT = 84 (2016)
189 * HCOUNT = 133 (3192)
190 * CKREF_DIV = 2
191 * CKVAR_DIV = 181
192 * VCO_DIV = 0
193 * SPCK_DIV = 5
194 * MRCK_DIV = 7
195 * LVDSCK_DIV = 0
196 */
197 .type = ET8EK8_REGLIST_MODE,
198 .mode = {
199 .sensor_width = 2592,
200 .sensor_height = 1968,
201 .sensor_window_origin_x = 0,
202 .sensor_window_origin_y = 0,
203 .sensor_window_width = 2592,
204 .sensor_window_height = 1968,
205 .width = 3192,
206 .height = 1008,
207 .window_origin_x = 0,
208 .window_origin_y = 0,
209 .window_width = 1296,
210 .window_height = 984,
211 .pixel_clock = 96533333,
212 .ext_clock = 9600000,
213 .timeperframe = {
214 .numerator = 100,
215 .denominator = 3000
216 },
217 .max_exp = 1004,
218 /* .max_gain = 0, */
219 .bus_format = MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8,
220 .sensitivity = 65536
221 },
222 .regs = {
223 { ET8EK8_REG_8BIT, 0x1239, 0x5A },
224 { ET8EK8_REG_8BIT, 0x1238, 0x82 },
225 { ET8EK8_REG_8BIT, 0x123B, 0x70 },
226 { ET8EK8_REG_8BIT, 0x123A, 0x05 },
227 { ET8EK8_REG_8BIT, 0x121B, 0x63 },
228 { ET8EK8_REG_8BIT, 0x1220, 0x85 },
229 { ET8EK8_REG_8BIT, 0x1221, 0x00 },
230 { ET8EK8_REG_8BIT, 0x1222, 0x54 },
231 { ET8EK8_REG_8BIT, 0x1223, 0x00 },
232 { ET8EK8_REG_8BIT, 0x121D, 0x63 },
233 { ET8EK8_REG_8BIT, 0x125D, 0x83 }, /* CCP_LVDS_MODE/ */
234 { ET8EK8_REG_TERM, 0, 0}
235 }
236};
237
238/* Mode4_SVGA_864x656_29.88fps */
239static struct et8ek8_reglist mode4_svga_864x656_29_88fps = {
240/* (without the +1)
241 * SPCK = 80 MHz
242 * CCP2 = 320 MHz
243 * VCO = 640 MHz
244 * VCOUNT = 84 (2016)
245 * HCOUNT = 166 (3984)
246 * CKREF_DIV = 2
247 * CKVAR_DIV = 200
248 * VCO_DIV = 0
249 * SPCK_DIV = 7
250 * MRCK_DIV = 7
251 * LVDSCK_DIV = 1
252 */
253 .type = ET8EK8_REGLIST_MODE,
254 .mode = {
255 .sensor_width = 2592,
256 .sensor_height = 1968,
257 .sensor_window_origin_x = 0,
258 .sensor_window_origin_y = 0,
259 .sensor_window_width = 2592,
260 .sensor_window_height = 1968,
261 .width = 3984,
262 .height = 672,
263 .window_origin_x = 0,
264 .window_origin_y = 0,
265 .window_width = 864,
266 .window_height = 656,
267 .pixel_clock = 80000000,
268 .ext_clock = 9600000,
269 .timeperframe = {
270 .numerator = 100,
271 .denominator = 2988
272 },
273 .max_exp = 668,
274 /* .max_gain = 0, */
275 .bus_format = MEDIA_BUS_FMT_SGRBG10_1X10,
276 .sensitivity = 65536
277 },
278 .regs = {
279 { ET8EK8_REG_8BIT, 0x1239, 0x64 },
280 { ET8EK8_REG_8BIT, 0x1238, 0x02 },
281 { ET8EK8_REG_8BIT, 0x123B, 0x71 },
282 { ET8EK8_REG_8BIT, 0x123A, 0x07 },
283 { ET8EK8_REG_8BIT, 0x121B, 0x62 },
284 { ET8EK8_REG_8BIT, 0x121D, 0x62 },
285 { ET8EK8_REG_8BIT, 0x1221, 0x00 },
286 { ET8EK8_REG_8BIT, 0x1220, 0xA6 },
287 { ET8EK8_REG_8BIT, 0x1223, 0x00 },
288 { ET8EK8_REG_8BIT, 0x1222, 0x54 },
289 { ET8EK8_REG_8BIT, 0x125D, 0x88 }, /* CCP_LVDS_MODE/ */
290 { ET8EK8_REG_TERM, 0, 0}
291 }
292};
293
294/* Mode5_VGA_648x492_29.93fps */
295static struct et8ek8_reglist mode5_vga_648x492_29_93fps = {
296/* (without the +1)
297 * SPCK = 80 MHz
298 * CCP2 = 320 MHz
299 * VCO = 640 MHz
300 * VCOUNT = 84 (2016)
301 * HCOUNT = 221 (5304)
302 * CKREF_DIV = 2
303 * CKVAR_DIV = 200
304 * VCO_DIV = 0
305 * SPCK_DIV = 7
306 * MRCK_DIV = 7
307 * LVDSCK_DIV = 1
308 */
309 .type = ET8EK8_REGLIST_MODE,
310 .mode = {
311 .sensor_width = 2592,
312 .sensor_height = 1968,
313 .sensor_window_origin_x = 0,
314 .sensor_window_origin_y = 0,
315 .sensor_window_width = 2592,
316 .sensor_window_height = 1968,
317 .width = 5304,
318 .height = 504,
319 .window_origin_x = 0,
320 .window_origin_y = 0,
321 .window_width = 648,
322 .window_height = 492,
323 .pixel_clock = 80000000,
324 .ext_clock = 9600000,
325 .timeperframe = {
326 .numerator = 100,
327 .denominator = 2993
328 },
329 .max_exp = 500,
330 /* .max_gain = 0, */
331 .bus_format = MEDIA_BUS_FMT_SGRBG10_1X10,
332 .sensitivity = 65536
333 },
334 .regs = {
335 { ET8EK8_REG_8BIT, 0x1239, 0x64 },
336 { ET8EK8_REG_8BIT, 0x1238, 0x02 },
337 { ET8EK8_REG_8BIT, 0x123B, 0x71 },
338 { ET8EK8_REG_8BIT, 0x123A, 0x07 },
339 { ET8EK8_REG_8BIT, 0x121B, 0x61 },
340 { ET8EK8_REG_8BIT, 0x121D, 0x61 },
341 { ET8EK8_REG_8BIT, 0x1221, 0x00 },
342 { ET8EK8_REG_8BIT, 0x1220, 0xDD },
343 { ET8EK8_REG_8BIT, 0x1223, 0x00 },
344 { ET8EK8_REG_8BIT, 0x1222, 0x54 },
345 { ET8EK8_REG_8BIT, 0x125D, 0x88 }, /* CCP_LVDS_MODE/ */
346 { ET8EK8_REG_TERM, 0, 0}
347 }
348};
349
350/* Mode2_16VGA_2592x1968_3.99fps */
351static struct et8ek8_reglist mode2_16vga_2592x1968_3_99fps = {
352/* (without the +1)
353 * SPCK = 80 MHz
354 * CCP2 = 640 MHz
355 * VCO = 640 MHz
356 * VCOUNT = 254 (6096)
357 * HCOUNT = 137 (3288)
358 * CKREF_DIV = 2
359 * CKVAR_DIV = 200
360 * VCO_DIV = 0
361 * SPCK_DIV = 7
362 * MRCK_DIV = 7
363 * LVDSCK_DIV = 0
364 */
365 .type = ET8EK8_REGLIST_MODE,
366 .mode = {
367 .sensor_width = 2592,
368 .sensor_height = 1968,
369 .sensor_window_origin_x = 0,
370 .sensor_window_origin_y = 0,
371 .sensor_window_width = 2592,
372 .sensor_window_height = 1968,
373 .width = 3288,
374 .height = 6096,
375 .window_origin_x = 0,
376 .window_origin_y = 0,
377 .window_width = 2592,
378 .window_height = 1968,
379 .pixel_clock = 80000000,
380 .ext_clock = 9600000,
381 .timeperframe = {
382 .numerator = 100,
383 .denominator = 399
384 },
385 .max_exp = 6092,
386 /* .max_gain = 0, */
387 .bus_format = MEDIA_BUS_FMT_SGRBG10_1X10,
388 .sensitivity = 65536
389 },
390 .regs = {
391 { ET8EK8_REG_8BIT, 0x1239, 0x64 },
392 { ET8EK8_REG_8BIT, 0x1238, 0x02 },
393 { ET8EK8_REG_8BIT, 0x123B, 0x70 },
394 { ET8EK8_REG_8BIT, 0x123A, 0x07 },
395 { ET8EK8_REG_8BIT, 0x121B, 0x64 },
396 { ET8EK8_REG_8BIT, 0x121D, 0x64 },
397 { ET8EK8_REG_8BIT, 0x1221, 0x00 },
398 { ET8EK8_REG_8BIT, 0x1220, 0x89 },
399 { ET8EK8_REG_8BIT, 0x1223, 0x00 },
400 { ET8EK8_REG_8BIT, 0x1222, 0xFE },
401 { ET8EK8_REG_TERM, 0, 0}
402 }
403};
404
405/* Mode_648x492_5fps */
406static struct et8ek8_reglist mode_648x492_5fps = {
407/* (without the +1)
408 * SPCK = 13.3333333333333 MHz
409 * CCP2 = 53.3333333333333 MHz
410 * VCO = 640 MHz
411 * VCOUNT = 84 (2016)
412 * HCOUNT = 221 (5304)
413 * CKREF_DIV = 2
414 * CKVAR_DIV = 200
415 * VCO_DIV = 5
416 * SPCK_DIV = 7
417 * MRCK_DIV = 7
418 * LVDSCK_DIV = 1
419 */
420 .type = ET8EK8_REGLIST_MODE,
421 .mode = {
422 .sensor_width = 2592,
423 .sensor_height = 1968,
424 .sensor_window_origin_x = 0,
425 .sensor_window_origin_y = 0,
426 .sensor_window_width = 2592,
427 .sensor_window_height = 1968,
428 .width = 5304,
429 .height = 504,
430 .window_origin_x = 0,
431 .window_origin_y = 0,
432 .window_width = 648,
433 .window_height = 492,
434 .pixel_clock = 13333333,
435 .ext_clock = 9600000,
436 .timeperframe = {
437 .numerator = 100,
438 .denominator = 499
439 },
440 .max_exp = 500,
441 /* .max_gain = 0, */
442 .bus_format = MEDIA_BUS_FMT_SGRBG10_1X10,
443 .sensitivity = 65536
444 },
445 .regs = {
446 { ET8EK8_REG_8BIT, 0x1239, 0x64 },
447 { ET8EK8_REG_8BIT, 0x1238, 0x02 },
448 { ET8EK8_REG_8BIT, 0x123B, 0x71 },
449 { ET8EK8_REG_8BIT, 0x123A, 0x57 },
450 { ET8EK8_REG_8BIT, 0x121B, 0x61 },
451 { ET8EK8_REG_8BIT, 0x121D, 0x61 },
452 { ET8EK8_REG_8BIT, 0x1221, 0x00 },
453 { ET8EK8_REG_8BIT, 0x1220, 0xDD },
454 { ET8EK8_REG_8BIT, 0x1223, 0x00 },
455 { ET8EK8_REG_8BIT, 0x1222, 0x54 },
456 { ET8EK8_REG_8BIT, 0x125D, 0x88 }, /* CCP_LVDS_MODE/ */
457 { ET8EK8_REG_TERM, 0, 0}
458 }
459};
460
461/* Mode3_4VGA_1296x984_5fps */
462static struct et8ek8_reglist mode3_4vga_1296x984_5fps = {
463/* (without the +1)
464 * SPCK = 49.4 MHz
465 * CCP2 = 395.2 MHz
466 * VCO = 790.4 MHz
467 * VCOUNT = 250 (6000)
468 * HCOUNT = 137 (3288)
469 * CKREF_DIV = 2
470 * CKVAR_DIV = 247
471 * VCO_DIV = 1
472 * SPCK_DIV = 7
473 * MRCK_DIV = 7
474 * LVDSCK_DIV = 0
475 */
476 .type = ET8EK8_REGLIST_MODE,
477 .mode = {
478 .sensor_width = 2592,
479 .sensor_height = 1968,
480 .sensor_window_origin_x = 0,
481 .sensor_window_origin_y = 0,
482 .sensor_window_width = 2592,
483 .sensor_window_height = 1968,
484 .width = 3288,
485 .height = 3000,
486 .window_origin_x = 0,
487 .window_origin_y = 0,
488 .window_width = 1296,
489 .window_height = 984,
490 .pixel_clock = 49400000,
491 .ext_clock = 9600000,
492 .timeperframe = {
493 .numerator = 100,
494 .denominator = 501
495 },
496 .max_exp = 2996,
497 /* .max_gain = 0, */
498 .bus_format = MEDIA_BUS_FMT_SGRBG10_1X10,
499 .sensitivity = 65536
500 },
501 .regs = {
502 { ET8EK8_REG_8BIT, 0x1239, 0x7B },
503 { ET8EK8_REG_8BIT, 0x1238, 0x82 },
504 { ET8EK8_REG_8BIT, 0x123B, 0x70 },
505 { ET8EK8_REG_8BIT, 0x123A, 0x17 },
506 { ET8EK8_REG_8BIT, 0x121B, 0x63 },
507 { ET8EK8_REG_8BIT, 0x121D, 0x63 },
508 { ET8EK8_REG_8BIT, 0x1221, 0x00 },
509 { ET8EK8_REG_8BIT, 0x1220, 0x89 },
510 { ET8EK8_REG_8BIT, 0x1223, 0x00 },
511 { ET8EK8_REG_8BIT, 0x1222, 0xFA },
512 { ET8EK8_REG_8BIT, 0x125D, 0x88 }, /* CCP_LVDS_MODE/ */
513 { ET8EK8_REG_TERM, 0, 0}
514 }
515};
516
517/* Mode_4VGA_1296x984_25fps_DPCM10-8 */
518static struct et8ek8_reglist mode_4vga_1296x984_25fps_dpcm10_8 = {
519/* (without the +1)
520 * SPCK = 84.2666666666667 MHz
521 * CCP2 = 505.6 MHz
522 * VCO = 505.6 MHz
523 * VCOUNT = 88 (2112)
524 * HCOUNT = 133 (3192)
525 * CKREF_DIV = 2
526 * CKVAR_DIV = 158
527 * VCO_DIV = 0
528 * SPCK_DIV = 5
529 * MRCK_DIV = 7
530 * LVDSCK_DIV = 0
531 */
532 .type = ET8EK8_REGLIST_MODE,
533 .mode = {
534 .sensor_width = 2592,
535 .sensor_height = 1968,
536 .sensor_window_origin_x = 0,
537 .sensor_window_origin_y = 0,
538 .sensor_window_width = 2592,
539 .sensor_window_height = 1968,
540 .width = 3192,
541 .height = 1056,
542 .window_origin_x = 0,
543 .window_origin_y = 0,
544 .window_width = 1296,
545 .window_height = 984,
546 .pixel_clock = 84266667,
547 .ext_clock = 9600000,
548 .timeperframe = {
549 .numerator = 100,
550 .denominator = 2500
551 },
552 .max_exp = 1052,
553 /* .max_gain = 0, */
554 .bus_format = MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8,
555 .sensitivity = 65536
556 },
557 .regs = {
558 { ET8EK8_REG_8BIT, 0x1239, 0x4F },
559 { ET8EK8_REG_8BIT, 0x1238, 0x02 },
560 { ET8EK8_REG_8BIT, 0x123B, 0x70 },
561 { ET8EK8_REG_8BIT, 0x123A, 0x05 },
562 { ET8EK8_REG_8BIT, 0x121B, 0x63 },
563 { ET8EK8_REG_8BIT, 0x1220, 0x85 },
564 { ET8EK8_REG_8BIT, 0x1221, 0x00 },
565 { ET8EK8_REG_8BIT, 0x1222, 0x58 },
566 { ET8EK8_REG_8BIT, 0x1223, 0x00 },
567 { ET8EK8_REG_8BIT, 0x121D, 0x63 },
568 { ET8EK8_REG_8BIT, 0x125D, 0x83 },
569 { ET8EK8_REG_TERM, 0, 0}
570 }
571};
572
573struct et8ek8_meta_reglist meta_reglist = {
574 .version = "V14 03-June-2008",
575 .reglist = {
576 { .ptr = &mode1_poweron_mode2_16vga_2592x1968_12_07fps },
577 { .ptr = &mode1_16vga_2592x1968_13_12fps_dpcm10_8 },
578 { .ptr = &mode3_4vga_1296x984_29_99fps_dpcm10_8 },
579 { .ptr = &mode4_svga_864x656_29_88fps },
580 { .ptr = &mode5_vga_648x492_29_93fps },
581 { .ptr = &mode2_16vga_2592x1968_3_99fps },
582 { .ptr = &mode_648x492_5fps },
583 { .ptr = &mode3_4vga_1296x984_5fps },
584 { .ptr = &mode_4vga_1296x984_25fps_dpcm10_8 },
585 { .ptr = NULL }
586 }
587};
diff --git a/drivers/media/i2c/et8ek8/et8ek8_reg.h b/drivers/media/i2c/et8ek8/et8ek8_reg.h
new file mode 100644
index 000000000000..07f1873a9c3d
--- /dev/null
+++ b/drivers/media/i2c/et8ek8/et8ek8_reg.h
@@ -0,0 +1,96 @@
1/*
2 * et8ek8_reg.h
3 *
4 * Copyright (C) 2008 Nokia Corporation
5 *
6 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
7 * Tuukka Toivonen <tuukkat76@gmail.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 */
18
19#ifndef ET8EK8REGS_H
20#define ET8EK8REGS_H
21
22#include <linux/i2c.h>
23#include <linux/types.h>
24#include <linux/videodev2.h>
25#include <linux/v4l2-subdev.h>
26
27struct v4l2_mbus_framefmt;
28struct v4l2_subdev_pad_mbus_code_enum;
29
30struct et8ek8_mode {
31 /* Physical sensor resolution and current image window */
32 u16 sensor_width;
33 u16 sensor_height;
34 u16 sensor_window_origin_x;
35 u16 sensor_window_origin_y;
36 u16 sensor_window_width;
37 u16 sensor_window_height;
38
39 /* Image data coming from sensor (after scaling) */
40 u16 width;
41 u16 height;
42 u16 window_origin_x;
43 u16 window_origin_y;
44 u16 window_width;
45 u16 window_height;
46
47 u32 pixel_clock; /* in Hz */
48 u32 ext_clock; /* in Hz */
49 struct v4l2_fract timeperframe;
50 u32 max_exp; /* Maximum exposure value */
51 u32 bus_format; /* MEDIA_BUS_FMT_ */
52 u32 sensitivity; /* 16.16 fixed point */
53};
54
55#define ET8EK8_REG_8BIT 1
56#define ET8EK8_REG_16BIT 2
57#define ET8EK8_REG_DELAY 100
58#define ET8EK8_REG_TERM 0xff
59struct et8ek8_reg {
60 u16 type;
61 u16 reg; /* 16-bit offset */
62 u32 val; /* 8/16/32-bit value */
63};
64
65/* Possible struct smia_reglist types. */
66#define ET8EK8_REGLIST_STANDBY 0
67#define ET8EK8_REGLIST_POWERON 1
68#define ET8EK8_REGLIST_RESUME 2
69#define ET8EK8_REGLIST_STREAMON 3
70#define ET8EK8_REGLIST_STREAMOFF 4
71#define ET8EK8_REGLIST_DISABLED 5
72
73#define ET8EK8_REGLIST_MODE 10
74
75#define ET8EK8_REGLIST_LSC_ENABLE 100
76#define ET8EK8_REGLIST_LSC_DISABLE 101
77#define ET8EK8_REGLIST_ANR_ENABLE 102
78#define ET8EK8_REGLIST_ANR_DISABLE 103
79
80struct et8ek8_reglist {
81 u32 type;
82 struct et8ek8_mode mode;
83 struct et8ek8_reg regs[];
84};
85
86#define ET8EK8_MAX_LEN 32
87struct et8ek8_meta_reglist {
88 char version[ET8EK8_MAX_LEN];
89 union {
90 struct et8ek8_reglist *ptr;
91 } reglist[];
92};
93
94extern struct et8ek8_meta_reglist meta_reglist;
95
96#endif /* ET8EK8REGS */
diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index cede3975d04b..cee7fd9cf08b 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -29,10 +29,6 @@
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details. 30 * GNU General Public License for more details.
31 * 31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 *
36 */ 32 */
37 33
38#include <asm/unaligned.h> 34#include <asm/unaligned.h>
@@ -428,7 +424,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
428 * If platform_data doesn't specify rc_dev, initialize it 424 * If platform_data doesn't specify rc_dev, initialize it
429 * internally 425 * internally
430 */ 426 */
431 rc = rc_allocate_device(); 427 rc = rc_allocate_device(RC_DRIVER_SCANCODE);
432 if (!rc) 428 if (!rc)
433 return -ENOMEM; 429 return -ENOMEM;
434 } 430 }
diff --git a/drivers/media/i2c/ks0127.c b/drivers/media/i2c/ks0127.c
index 77551baab068..ab536c4a7115 100644
--- a/drivers/media/i2c/ks0127.c
+++ b/drivers/media/i2c/ks0127.c
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 *
23 ***************************************************************************** 19 *****************************************************************************
24 * 20 *
25 * Modified and extended by 21 * Modified and extended by
diff --git a/drivers/media/i2c/ks0127.h b/drivers/media/i2c/ks0127.h
index cb8abd5403b3..636b70a984f7 100644
--- a/drivers/media/i2c/ks0127.h
+++ b/drivers/media/i2c/ks0127.h
@@ -15,10 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */ 18 */
23 19
24#ifndef KS0127_H 20#ifndef KS0127_H
diff --git a/drivers/media/i2c/m52790.c b/drivers/media/i2c/m52790.c
index 89c28c36c5bf..a7a8f9a4e45c 100644
--- a/drivers/media/i2c/m52790.c
+++ b/drivers/media/i2c/m52790.c
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22 18
diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c
index acb804bceccb..9ccb5ee55fa9 100644
--- a/drivers/media/i2c/m5mols/m5mols_core.c
+++ b/drivers/media/i2c/m5mols/m5mols_core.c
@@ -168,7 +168,7 @@ static int m5mols_read(struct v4l2_subdev *sd, u32 size, u32 reg, u32 *val)
168 msg[1].buf = rbuf; 168 msg[1].buf = rbuf;
169 169
170 /* minimum stabilization time */ 170 /* minimum stabilization time */
171 usleep_range(200, 200); 171 usleep_range(200, 300);
172 172
173 ret = i2c_transfer(client->adapter, msg, 2); 173 ret = i2c_transfer(client->adapter, msg, 2);
174 174
@@ -268,7 +268,8 @@ int m5mols_write(struct v4l2_subdev *sd, u32 reg, u32 val)
268 268
269 *buf = m5mols_swap_byte((u8 *)&val, size); 269 *buf = m5mols_swap_byte((u8 *)&val, size);
270 270
271 usleep_range(200, 200); 271 /* minimum stabilization time */
272 usleep_range(200, 300);
272 273
273 ret = i2c_transfer(client->adapter, msg, 1); 274 ret = i2c_transfer(client->adapter, msg, 1);
274 if (ret == 1) 275 if (ret == 1)
@@ -651,7 +652,7 @@ static int m5mols_enum_mbus_code(struct v4l2_subdev *sd,
651 return 0; 652 return 0;
652} 653}
653 654
654static struct v4l2_subdev_pad_ops m5mols_pad_ops = { 655static const struct v4l2_subdev_pad_ops m5mols_pad_ops = {
655 .enum_mbus_code = m5mols_enum_mbus_code, 656 .enum_mbus_code = m5mols_enum_mbus_code,
656 .get_fmt = m5mols_get_fmt, 657 .get_fmt = m5mols_get_fmt,
657 .set_fmt = m5mols_set_fmt, 658 .set_fmt = m5mols_set_fmt,
diff --git a/drivers/media/i2c/ml86v7667.c b/drivers/media/i2c/ml86v7667.c
index 38a20fe181ee..57ef901edb06 100644
--- a/drivers/media/i2c/ml86v7667.c
+++ b/drivers/media/i2c/ml86v7667.c
@@ -290,7 +290,7 @@ static const struct v4l2_ctrl_ops ml86v7667_ctrl_ops = {
290 .s_ctrl = ml86v7667_s_ctrl, 290 .s_ctrl = ml86v7667_s_ctrl,
291}; 291};
292 292
293static struct v4l2_subdev_video_ops ml86v7667_subdev_video_ops = { 293static const struct v4l2_subdev_video_ops ml86v7667_subdev_video_ops = {
294 .g_std = ml86v7667_g_std, 294 .g_std = ml86v7667_g_std,
295 .s_std = ml86v7667_s_std, 295 .s_std = ml86v7667_s_std,
296 .querystd = ml86v7667_querystd, 296 .querystd = ml86v7667_querystd,
@@ -304,14 +304,14 @@ static const struct v4l2_subdev_pad_ops ml86v7667_subdev_pad_ops = {
304 .set_fmt = ml86v7667_fill_fmt, 304 .set_fmt = ml86v7667_fill_fmt,
305}; 305};
306 306
307static struct v4l2_subdev_core_ops ml86v7667_subdev_core_ops = { 307static const struct v4l2_subdev_core_ops ml86v7667_subdev_core_ops = {
308#ifdef CONFIG_VIDEO_ADV_DEBUG 308#ifdef CONFIG_VIDEO_ADV_DEBUG
309 .g_register = ml86v7667_g_register, 309 .g_register = ml86v7667_g_register,
310 .s_register = ml86v7667_s_register, 310 .s_register = ml86v7667_s_register,
311#endif 311#endif
312}; 312};
313 313
314static struct v4l2_subdev_ops ml86v7667_subdev_ops = { 314static const struct v4l2_subdev_ops ml86v7667_subdev_ops = {
315 .core = &ml86v7667_subdev_core_ops, 315 .core = &ml86v7667_subdev_core_ops,
316 .video = &ml86v7667_subdev_video_ops, 316 .video = &ml86v7667_subdev_video_ops,
317 .pad = &ml86v7667_subdev_pad_ops, 317 .pad = &ml86v7667_subdev_pad_ops,
diff --git a/drivers/media/i2c/msp3400-driver.c b/drivers/media/i2c/msp3400-driver.c
index 201a9800ea52..3db966db83eb 100644
--- a/drivers/media/i2c/msp3400-driver.c
+++ b/drivers/media/i2c/msp3400-driver.c
@@ -39,11 +39,6 @@
39 * but WITHOUT ANY WARRANTY; without even the implied warranty of 39 * but WITHOUT ANY WARRANTY; without even the implied warranty of
40 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 40 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41 * GNU General Public License for more details. 41 * GNU General Public License for more details.
42 *
43 * You should have received a copy of the GNU General Public License
44 * along with this program; if not, write to the Free Software
45 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
46 * 02110-1301, USA.
47 */ 42 */
48 43
49 44
diff --git a/drivers/media/i2c/msp3400-kthreads.c b/drivers/media/i2c/msp3400-kthreads.c
index eec7aa4c6f98..11fc593ed908 100644
--- a/drivers/media/i2c/msp3400-kthreads.c
+++ b/drivers/media/i2c/msp3400-kthreads.c
@@ -12,11 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 */ 15 */
21 16
22 17
diff --git a/drivers/media/i2c/mt9m032.c b/drivers/media/i2c/mt9m032.c
index da076796999e..6a9e068462fd 100644
--- a/drivers/media/i2c/mt9m032.c
+++ b/drivers/media/i2c/mt9m032.c
@@ -13,11 +13,6 @@
13 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details. 15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 */ 16 */
22 17
23#include <linux/delay.h> 18#include <linux/delay.h>
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index 237737fec09c..91d822fc4443 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -972,15 +972,15 @@ static int mt9p031_close(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh)
972 return mt9p031_set_power(subdev, 0); 972 return mt9p031_set_power(subdev, 0);
973} 973}
974 974
975static struct v4l2_subdev_core_ops mt9p031_subdev_core_ops = { 975static const struct v4l2_subdev_core_ops mt9p031_subdev_core_ops = {
976 .s_power = mt9p031_set_power, 976 .s_power = mt9p031_set_power,
977}; 977};
978 978
979static struct v4l2_subdev_video_ops mt9p031_subdev_video_ops = { 979static const struct v4l2_subdev_video_ops mt9p031_subdev_video_ops = {
980 .s_stream = mt9p031_s_stream, 980 .s_stream = mt9p031_s_stream,
981}; 981};
982 982
983static struct v4l2_subdev_pad_ops mt9p031_subdev_pad_ops = { 983static const struct v4l2_subdev_pad_ops mt9p031_subdev_pad_ops = {
984 .enum_mbus_code = mt9p031_enum_mbus_code, 984 .enum_mbus_code = mt9p031_enum_mbus_code,
985 .enum_frame_size = mt9p031_enum_frame_size, 985 .enum_frame_size = mt9p031_enum_frame_size,
986 .get_fmt = mt9p031_get_format, 986 .get_fmt = mt9p031_get_format,
@@ -989,7 +989,7 @@ static struct v4l2_subdev_pad_ops mt9p031_subdev_pad_ops = {
989 .set_selection = mt9p031_set_selection, 989 .set_selection = mt9p031_set_selection,
990}; 990};
991 991
992static struct v4l2_subdev_ops mt9p031_subdev_ops = { 992static const struct v4l2_subdev_ops mt9p031_subdev_ops = {
993 .core = &mt9p031_subdev_core_ops, 993 .core = &mt9p031_subdev_core_ops,
994 .video = &mt9p031_subdev_video_ops, 994 .video = &mt9p031_subdev_video_ops,
995 .pad = &mt9p031_subdev_pad_ops, 995 .pad = &mt9p031_subdev_pad_ops,
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 58eb62f1ba21..2e7a6e62a358 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -266,8 +266,7 @@ static int mt9v032_power_on(struct mt9v032 *mt9v032)
266 struct regmap *map = mt9v032->regmap; 266 struct regmap *map = mt9v032->regmap;
267 int ret; 267 int ret;
268 268
269 if (mt9v032->reset_gpio) 269 gpiod_set_value_cansleep(mt9v032->reset_gpio, 1);
270 gpiod_set_value_cansleep(mt9v032->reset_gpio, 1);
271 270
272 ret = clk_set_rate(mt9v032->clk, mt9v032->sysclk); 271 ret = clk_set_rate(mt9v032->clk, mt9v032->sysclk);
273 if (ret < 0) 272 if (ret < 0)
@@ -936,15 +935,15 @@ static int mt9v032_close(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh)
936 return mt9v032_set_power(subdev, 0); 935 return mt9v032_set_power(subdev, 0);
937} 936}
938 937
939static struct v4l2_subdev_core_ops mt9v032_subdev_core_ops = { 938static const struct v4l2_subdev_core_ops mt9v032_subdev_core_ops = {
940 .s_power = mt9v032_set_power, 939 .s_power = mt9v032_set_power,
941}; 940};
942 941
943static struct v4l2_subdev_video_ops mt9v032_subdev_video_ops = { 942static const struct v4l2_subdev_video_ops mt9v032_subdev_video_ops = {
944 .s_stream = mt9v032_s_stream, 943 .s_stream = mt9v032_s_stream,
945}; 944};
946 945
947static struct v4l2_subdev_pad_ops mt9v032_subdev_pad_ops = { 946static const struct v4l2_subdev_pad_ops mt9v032_subdev_pad_ops = {
948 .enum_mbus_code = mt9v032_enum_mbus_code, 947 .enum_mbus_code = mt9v032_enum_mbus_code,
949 .enum_frame_size = mt9v032_enum_frame_size, 948 .enum_frame_size = mt9v032_enum_frame_size,
950 .get_fmt = mt9v032_get_format, 949 .get_fmt = mt9v032_get_format,
@@ -953,7 +952,7 @@ static struct v4l2_subdev_pad_ops mt9v032_subdev_pad_ops = {
953 .set_selection = mt9v032_set_selection, 952 .set_selection = mt9v032_set_selection,
954}; 953};
955 954
956static struct v4l2_subdev_ops mt9v032_subdev_ops = { 955static const struct v4l2_subdev_ops mt9v032_subdev_ops = {
957 .core = &mt9v032_subdev_core_ops, 956 .core = &mt9v032_subdev_core_ops,
958 .video = &mt9v032_subdev_video_ops, 957 .video = &mt9v032_subdev_video_ops,
959 .pad = &mt9v032_subdev_pad_ops, 958 .pad = &mt9v032_subdev_pad_ops,
diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c
index 30cb90b88d75..88c498ad45df 100644
--- a/drivers/media/i2c/noon010pc30.c
+++ b/drivers/media/i2c/noon010pc30.c
@@ -664,13 +664,13 @@ static const struct v4l2_subdev_core_ops noon010_core_ops = {
664 .log_status = noon010_log_status, 664 .log_status = noon010_log_status,
665}; 665};
666 666
667static struct v4l2_subdev_pad_ops noon010_pad_ops = { 667static const struct v4l2_subdev_pad_ops noon010_pad_ops = {
668 .enum_mbus_code = noon010_enum_mbus_code, 668 .enum_mbus_code = noon010_enum_mbus_code,
669 .get_fmt = noon010_get_fmt, 669 .get_fmt = noon010_get_fmt,
670 .set_fmt = noon010_set_fmt, 670 .set_fmt = noon010_set_fmt,
671}; 671};
672 672
673static struct v4l2_subdev_video_ops noon010_video_ops = { 673static const struct v4l2_subdev_video_ops noon010_video_ops = {
674 .s_stream = noon010_s_stream, 674 .s_stream = noon010_s_stream,
675}; 675};
676 676
diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 1f999e9c0118..6e6367214d40 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1121,7 +1121,6 @@ static int ov2659_set_fmt(struct v4l2_subdev *sd,
1121 return -EINVAL; 1121 return -EINVAL;
1122 1122
1123 mf->colorspace = V4L2_COLORSPACE_SRGB; 1123 mf->colorspace = V4L2_COLORSPACE_SRGB;
1124 mf->code = ov2659_formats[index].code;
1125 mf->field = V4L2_FIELD_NONE; 1124 mf->field = V4L2_FIELD_NONE;
1126 1125
1127 mutex_lock(&ov2659->lock); 1126 mutex_lock(&ov2659->lock);
diff --git a/drivers/media/i2c/ov7640.c b/drivers/media/i2c/ov7640.c
index b8961df5af33..a03b41a3639e 100644
--- a/drivers/media/i2c/ov7640.c
+++ b/drivers/media/i2c/ov7640.c
@@ -9,10 +9,6 @@
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
16 */ 12 */
17 13
18#include <linux/init.h> 14#include <linux/init.h>
diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
index 502c72238a4a..2de2fbb13b85 100644
--- a/drivers/media/i2c/ov9650.c
+++ b/drivers/media/i2c/ov9650.c
@@ -522,7 +522,7 @@ static void __ov965x_set_power(struct ov965x *ov965x, int on)
522 if (on) { 522 if (on) {
523 ov965x_gpio_set(ov965x->gpios[GPIO_PWDN], 0); 523 ov965x_gpio_set(ov965x->gpios[GPIO_PWDN], 0);
524 ov965x_gpio_set(ov965x->gpios[GPIO_RST], 0); 524 ov965x_gpio_set(ov965x->gpios[GPIO_RST], 0);
525 usleep_range(25000, 26000); 525 msleep(25);
526 } else { 526 } else {
527 ov965x_gpio_set(ov965x->gpios[GPIO_RST], 1); 527 ov965x_gpio_set(ov965x->gpios[GPIO_RST], 1);
528 ov965x_gpio_set(ov965x->gpios[GPIO_PWDN], 1); 528 ov965x_gpio_set(ov965x->gpios[GPIO_PWDN], 1);
@@ -1438,7 +1438,7 @@ static int ov965x_detect_sensor(struct v4l2_subdev *sd)
1438 1438
1439 mutex_lock(&ov965x->lock); 1439 mutex_lock(&ov965x->lock);
1440 __ov965x_set_power(ov965x, 1); 1440 __ov965x_set_power(ov965x, 1);
1441 usleep_range(25000, 26000); 1441 msleep(25);
1442 1442
1443 /* Check sensor revision */ 1443 /* Check sensor revision */
1444 ret = ov965x_read(client, REG_PID, &pid); 1444 ret = ov965x_read(client, REG_PID, &pid);
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c b/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c
index 0a060339e516..2e7185030741 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c
@@ -211,7 +211,7 @@ static int s5c73m3_3a_lock(struct s5c73m3 *state, struct v4l2_ctrl *ctrl)
211 } 211 }
212 212
213 if ((ctrl->val ^ ctrl->cur.val) & V4L2_LOCK_FOCUS) 213 if ((ctrl->val ^ ctrl->cur.val) & V4L2_LOCK_FOCUS)
214 ret = s5c73m3_af_run(state, ~af_lock); 214 ret = s5c73m3_af_run(state, !af_lock);
215 215
216 return ret; 216 return ret;
217} 217}
diff --git a/drivers/media/i2c/s5k6a3.c b/drivers/media/i2c/s5k6a3.c
index 769964057881..67dcca76f981 100644
--- a/drivers/media/i2c/s5k6a3.c
+++ b/drivers/media/i2c/s5k6a3.c
@@ -165,7 +165,7 @@ static int s5k6a3_get_fmt(struct v4l2_subdev *sd,
165 return 0; 165 return 0;
166} 166}
167 167
168static struct v4l2_subdev_pad_ops s5k6a3_pad_ops = { 168static const struct v4l2_subdev_pad_ops s5k6a3_pad_ops = {
169 .enum_mbus_code = s5k6a3_enum_mbus_code, 169 .enum_mbus_code = s5k6a3_enum_mbus_code,
170 .get_fmt = s5k6a3_get_fmt, 170 .get_fmt = s5k6a3_get_fmt,
171 .set_fmt = s5k6a3_set_fmt, 171 .set_fmt = s5k6a3_set_fmt,
@@ -266,11 +266,11 @@ static int s5k6a3_s_power(struct v4l2_subdev *sd, int on)
266 return ret; 266 return ret;
267} 267}
268 268
269static struct v4l2_subdev_core_ops s5k6a3_core_ops = { 269static const struct v4l2_subdev_core_ops s5k6a3_core_ops = {
270 .s_power = s5k6a3_s_power, 270 .s_power = s5k6a3_s_power,
271}; 271};
272 272
273static struct v4l2_subdev_ops s5k6a3_subdev_ops = { 273static const struct v4l2_subdev_ops s5k6a3_subdev_ops = {
274 .core = &s5k6a3_core_ops, 274 .core = &s5k6a3_core_ops,
275 .pad = &s5k6a3_pad_ops, 275 .pad = &s5k6a3_pad_ops,
276}; 276};
diff --git a/drivers/media/i2c/saa7110.c b/drivers/media/i2c/saa7110.c
index ad456ce051f9..63fe521752a1 100644
--- a/drivers/media/i2c/saa7110.c
+++ b/drivers/media/i2c/saa7110.c
@@ -19,10 +19,6 @@
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 */ 22 */
27 23
28#include <linux/module.h> 24#include <linux/module.h>
diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c
index 58062b41c923..d863b04aa2a8 100644
--- a/drivers/media/i2c/saa7115.c
+++ b/drivers/media/i2c/saa7115.c
@@ -31,10 +31,6 @@
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of 31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details. 33 * GNU General Public License for more details.
34 *
35 * You should have received a copy of the GNU General Public License
36 * along with this program; if not, write to the Free Software
37 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
38 */ 34 */
39 35
40#include "saa711x_regs.h" 36#include "saa711x_regs.h"
diff --git a/drivers/media/i2c/saa7127.c b/drivers/media/i2c/saa7127.c
index 8d94dcbf4366..99c303002e90 100644
--- a/drivers/media/i2c/saa7127.c
+++ b/drivers/media/i2c/saa7127.c
@@ -41,10 +41,6 @@
41 * but WITHOUT ANY WARRANTY; without even the implied warranty of 41 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 42 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43 * GNU General Public License for more details. 43 * GNU General Public License for more details.
44 *
45 * You should have received a copy of the GNU General Public License
46 * along with this program; if not, write to the Free Software
47 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
48 */ 44 */
49 45
50 46
diff --git a/drivers/media/i2c/saa717x.c b/drivers/media/i2c/saa717x.c
index 1baca37f3eb6..e1f6bc219c64 100644
--- a/drivers/media/i2c/saa717x.c
+++ b/drivers/media/i2c/saa717x.c
@@ -24,10 +24,6 @@
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of 24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details. 26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 */ 27 */
32 28
33#include <linux/module.h> 29#include <linux/module.h>
diff --git a/drivers/media/i2c/saa7185.c b/drivers/media/i2c/saa7185.c
index 119050e1197a..0e27fafaef2d 100644
--- a/drivers/media/i2c/saa7185.c
+++ b/drivers/media/i2c/saa7185.c
@@ -18,10 +18,6 @@
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 21 */
26 22
27#include <linux/module.h> 23#include <linux/module.h>
diff --git a/drivers/media/i2c/soc_camera/ov9640.c b/drivers/media/i2c/soc_camera/ov9640.c
index 8c93c57af71c..65085a235128 100644
--- a/drivers/media/i2c/soc_camera/ov9640.c
+++ b/drivers/media/i2c/soc_camera/ov9640.c
@@ -233,7 +233,7 @@ static int ov9640_reg_rmw(struct i2c_client *client, u8 reg, u8 set, u8 unset)
233 if (ret) { 233 if (ret) {
234 dev_err(&client->dev, 234 dev_err(&client->dev,
235 "[Read]-Modify-Write of register %02x failed!\n", reg); 235 "[Read]-Modify-Write of register %02x failed!\n", reg);
236 return val; 236 return ret;
237 } 237 }
238 238
239 val |= set; 239 val |= set;
diff --git a/drivers/media/i2c/sony-btf-mpx.c b/drivers/media/i2c/sony-btf-mpx.c
index 6b1a04ffad32..a9c067bcc0ac 100644
--- a/drivers/media/i2c/sony-btf-mpx.c
+++ b/drivers/media/i2c/sony-btf-mpx.c
@@ -9,10 +9,6 @@
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
16 */ 12 */
17 13
18#include <linux/module.h> 14#include <linux/module.h>
diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index 1e3a0dd2238c..f569a05fe105 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -96,6 +96,7 @@ struct tc358743_state {
96 96
97 struct v4l2_dv_timings timings; 97 struct v4l2_dv_timings timings;
98 u32 mbus_fmt_code; 98 u32 mbus_fmt_code;
99 u8 csi_lanes_in_use;
99 100
100 struct gpio_desc *reset_gpio; 101 struct gpio_desc *reset_gpio;
101}; 102};
@@ -287,11 +288,6 @@ static int get_audio_sampling_rate(struct v4l2_subdev *sd)
287 return code_to_rate[i2c_rd8(sd, FS_SET) & MASK_FS]; 288 return code_to_rate[i2c_rd8(sd, FS_SET) & MASK_FS];
288} 289}
289 290
290static unsigned tc358743_num_csi_lanes_in_use(struct v4l2_subdev *sd)
291{
292 return ((i2c_rd32(sd, CSI_CONTROL) & MASK_NOL) >> 1) + 1;
293}
294
295/* --------------- TIMINGS --------------- */ 291/* --------------- TIMINGS --------------- */
296 292
297static inline unsigned fps(const struct v4l2_bt_timings *t) 293static inline unsigned fps(const struct v4l2_bt_timings *t)
@@ -372,29 +368,21 @@ static void tc358743_set_hdmi_hdcp(struct v4l2_subdev *sd, bool enable)
372 v4l2_dbg(2, debug, sd, "%s: %s\n", __func__, enable ? 368 v4l2_dbg(2, debug, sd, "%s: %s\n", __func__, enable ?
373 "enable" : "disable"); 369 "enable" : "disable");
374 370
375 i2c_wr8_and_or(sd, HDCP_REG1, 371 if (enable) {
376 ~(MASK_AUTH_UNAUTH_SEL | MASK_AUTH_UNAUTH), 372 i2c_wr8_and_or(sd, HDCP_REG3, ~KEY_RD_CMD, KEY_RD_CMD);
377 MASK_AUTH_UNAUTH_SEL_16_FRAMES | MASK_AUTH_UNAUTH_AUTO);
378 373
379 i2c_wr8_and_or(sd, HDCP_REG2, ~MASK_AUTO_P3_RESET, 374 i2c_wr8_and_or(sd, HDCP_MODE, ~MASK_MANUAL_AUTHENTICATION, 0);
380 SET_AUTO_P3_RESET_FRAMES(0x0f));
381 375
382 /* HDCP is disabled by configuring the receiver as HDCP repeater. The 376 i2c_wr8_and_or(sd, HDCP_REG1, 0xff,
383 * repeater mode require software support to work, so HDCP 377 MASK_AUTH_UNAUTH_SEL_16_FRAMES |
384 * authentication will fail. 378 MASK_AUTH_UNAUTH_AUTO);
385 */
386 i2c_wr8_and_or(sd, HDCP_REG3, ~KEY_RD_CMD, enable ? KEY_RD_CMD : 0);
387 i2c_wr8_and_or(sd, HDCP_MODE, ~(MASK_AUTO_CLR | MASK_MODE_RST_TN),
388 enable ? (MASK_AUTO_CLR | MASK_MODE_RST_TN) : 0);
389 379
390 /* Apple MacBook Pro gen.8 has a bug that makes it freeze every fifth 380 i2c_wr8_and_or(sd, HDCP_REG2, ~MASK_AUTO_P3_RESET,
391 * second when HDCP is disabled, but the MAX_EXCED bit is handled 381 SET_AUTO_P3_RESET_FRAMES(0x0f));
392 * correctly and HDCP is disabled on the HDMI output. 382 } else {
393 */ 383 i2c_wr8_and_or(sd, HDCP_MODE, ~MASK_MANUAL_AUTHENTICATION,
394 i2c_wr8_and_or(sd, BSTATUS1, ~MASK_MAX_EXCED, 384 MASK_MANUAL_AUTHENTICATION);
395 enable ? 0 : MASK_MAX_EXCED); 385 }
396 i2c_wr8_and_or(sd, BCAPS, ~(MASK_REPEATER | MASK_READY),
397 enable ? 0 : MASK_REPEATER | MASK_READY);
398} 386}
399 387
400static void tc358743_disable_edid(struct v4l2_subdev *sd) 388static void tc358743_disable_edid(struct v4l2_subdev *sd)
@@ -416,6 +404,7 @@ static void tc358743_enable_edid(struct v4l2_subdev *sd)
416 404
417 if (state->edid_blocks_written == 0) { 405 if (state->edid_blocks_written == 0) {
418 v4l2_dbg(2, debug, sd, "%s: no EDID -> no hotplug\n", __func__); 406 v4l2_dbg(2, debug, sd, "%s: no EDID -> no hotplug\n", __func__);
407 tc358743_s_ctrl_detect_tx_5v(sd);
419 return; 408 return;
420 } 409 }
421 410
@@ -683,6 +672,8 @@ static void tc358743_set_csi(struct v4l2_subdev *sd)
683 672
684 v4l2_dbg(3, debug, sd, "%s:\n", __func__); 673 v4l2_dbg(3, debug, sd, "%s:\n", __func__);
685 674
675 state->csi_lanes_in_use = lanes;
676
686 tc358743_reset(sd, MASK_CTXRST); 677 tc358743_reset(sd, MASK_CTXRST);
687 678
688 if (lanes < 1) 679 if (lanes < 1)
@@ -1155,7 +1146,7 @@ static int tc358743_log_status(struct v4l2_subdev *sd)
1155 v4l2_info(sd, "Lanes needed: %d\n", 1146 v4l2_info(sd, "Lanes needed: %d\n",
1156 tc358743_num_csi_lanes_needed(sd)); 1147 tc358743_num_csi_lanes_needed(sd));
1157 v4l2_info(sd, "Lanes in use: %d\n", 1148 v4l2_info(sd, "Lanes in use: %d\n",
1158 tc358743_num_csi_lanes_in_use(sd)); 1149 state->csi_lanes_in_use);
1159 v4l2_info(sd, "Waiting for particular sync signal: %s\n", 1150 v4l2_info(sd, "Waiting for particular sync signal: %s\n",
1160 (i2c_rd16(sd, CSI_STATUS) & MASK_S_WSYNC) ? 1151 (i2c_rd16(sd, CSI_STATUS) & MASK_S_WSYNC) ?
1161 "yes" : "no"); 1152 "yes" : "no");
@@ -1438,12 +1429,14 @@ static int tc358743_dv_timings_cap(struct v4l2_subdev *sd,
1438static int tc358743_g_mbus_config(struct v4l2_subdev *sd, 1429static int tc358743_g_mbus_config(struct v4l2_subdev *sd,
1439 struct v4l2_mbus_config *cfg) 1430 struct v4l2_mbus_config *cfg)
1440{ 1431{
1432 struct tc358743_state *state = to_state(sd);
1433
1441 cfg->type = V4L2_MBUS_CSI2; 1434 cfg->type = V4L2_MBUS_CSI2;
1442 1435
1443 /* Support for non-continuous CSI-2 clock is missing in the driver */ 1436 /* Support for non-continuous CSI-2 clock is missing in the driver */
1444 cfg->flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK; 1437 cfg->flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
1445 1438
1446 switch (tc358743_num_csi_lanes_in_use(sd)) { 1439 switch (state->csi_lanes_in_use) {
1447 case 1: 1440 case 1:
1448 cfg->flags |= V4L2_MBUS_CSI2_1_LANE; 1441 cfg->flags |= V4L2_MBUS_CSI2_1_LANE;
1449 break; 1442 break;
diff --git a/drivers/media/i2c/tc358743_regs.h b/drivers/media/i2c/tc358743_regs.h
index 81f1db558e7c..657ef50f215f 100644
--- a/drivers/media/i2c/tc358743_regs.h
+++ b/drivers/media/i2c/tc358743_regs.h
@@ -420,6 +420,7 @@
420#define MASK_MODE_RST_TN 0x20 420#define MASK_MODE_RST_TN 0x20
421#define MASK_LINE_REKEY 0x10 421#define MASK_LINE_REKEY 0x10
422#define MASK_AUTO_CLR 0x04 422#define MASK_AUTO_CLR 0x04
423#define MASK_MANUAL_AUTHENTICATION 0x02 /* Not in REF_01 */
423 424
424#define HDCP_REG1 0x8563 /* Not in REF_01 */ 425#define HDCP_REG1 0x8563 /* Not in REF_01 */
425#define MASK_AUTH_UNAUTH_SEL 0x70 426#define MASK_AUTH_UNAUTH_SEL 0x70
diff --git a/drivers/media/i2c/tlv320aic23b.c b/drivers/media/i2c/tlv320aic23b.c
index cc6104da34ef..6ac26986f6a2 100644
--- a/drivers/media/i2c/tlv320aic23b.c
+++ b/drivers/media/i2c/tlv320aic23b.c
@@ -17,10 +17,6 @@
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 20 */
25 21
26#include <linux/module.h> 22#include <linux/module.h>
diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
index 0c62899c3667..07853d2252aa 100644
--- a/drivers/media/i2c/tvp514x.c
+++ b/drivers/media/i2c/tvp514x.c
@@ -23,10 +23,6 @@
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details. 24 * GNU General Public License for more details.
25 * 25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 *
30 */ 26 */
31 27
32#include <linux/i2c.h> 28#include <linux/i2c.h>
diff --git a/drivers/media/i2c/tvp514x_regs.h b/drivers/media/i2c/tvp514x_regs.h
index d23aa2fbb9b1..1e6c0857590e 100644
--- a/drivers/media/i2c/tvp514x_regs.h
+++ b/drivers/media/i2c/tvp514x_regs.h
@@ -20,10 +20,6 @@
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 21 * GNU General Public License for more details.
22 * 22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 */ 23 */
28 24
29#ifndef _TVP514X_REGS_H 25#ifndef _TVP514X_REGS_H
diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c
index 3dc3341c4896..4c1190127c85 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -19,10 +19,6 @@
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 */ 22 */
27#include <linux/delay.h> 23#include <linux/delay.h>
28#include <linux/i2c.h> 24#include <linux/i2c.h>
diff --git a/drivers/media/i2c/tvp7002_reg.h b/drivers/media/i2c/tvp7002_reg.h
index 0e34ca9bccf3..933673561fa2 100644
--- a/drivers/media/i2c/tvp7002_reg.h
+++ b/drivers/media/i2c/tvp7002_reg.h
@@ -18,10 +18,6 @@
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 21 */
26 22
27/* Naming conventions 23/* Naming conventions
diff --git a/drivers/media/i2c/tw2804.c b/drivers/media/i2c/tw2804.c
index 7347480c0b0c..bc8a3ecebffb 100644
--- a/drivers/media/i2c/tw2804.c
+++ b/drivers/media/i2c/tw2804.c
@@ -9,10 +9,6 @@
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
16 */ 12 */
17 13
18#include <linux/module.h> 14#include <linux/module.h>
diff --git a/drivers/media/i2c/tw9903.c b/drivers/media/i2c/tw9903.c
index bef79cf74364..af32db3d7408 100644
--- a/drivers/media/i2c/tw9903.c
+++ b/drivers/media/i2c/tw9903.c
@@ -9,10 +9,6 @@
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
16 */ 12 */
17 13
18#include <linux/module.h> 14#include <linux/module.h>
diff --git a/drivers/media/i2c/tw9906.c b/drivers/media/i2c/tw9906.c
index 316a3113ef27..5081307b2cdb 100644
--- a/drivers/media/i2c/tw9906.c
+++ b/drivers/media/i2c/tw9906.c
@@ -9,10 +9,6 @@
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
16 */ 12 */
17 13
18#include <linux/module.h> 14#include <linux/module.h>
diff --git a/drivers/media/i2c/uda1342.c b/drivers/media/i2c/uda1342.c
index 8e17a83920d4..eb0084ebe35e 100644
--- a/drivers/media/i2c/uda1342.c
+++ b/drivers/media/i2c/uda1342.c
@@ -9,10 +9,6 @@
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
16 */ 12 */
17 13
18#include <linux/module.h> 14#include <linux/module.h>
diff --git a/drivers/media/i2c/upd64031a.c b/drivers/media/i2c/upd64031a.c
index c03567e993cd..7ad5d51dfbc3 100644
--- a/drivers/media/i2c/upd64031a.c
+++ b/drivers/media/i2c/upd64031a.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23 19
diff --git a/drivers/media/i2c/upd64083.c b/drivers/media/i2c/upd64083.c
index 77f122f2e3c9..c7fdd7c163cb 100644
--- a/drivers/media/i2c/upd64083.c
+++ b/drivers/media/i2c/upd64083.c
@@ -14,11 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 */ 17 */
23 18
24#include <linux/module.h> 19#include <linux/module.h>
diff --git a/drivers/media/i2c/vp27smpx.c b/drivers/media/i2c/vp27smpx.c
index ef0d8b8e3df7..c6611a3f2b3d 100644
--- a/drivers/media/i2c/vp27smpx.c
+++ b/drivers/media/i2c/vp27smpx.c
@@ -15,10 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 18 */
23 19
24#include <linux/module.h> 20#include <linux/module.h>
diff --git a/drivers/media/i2c/vpx3220.c b/drivers/media/i2c/vpx3220.c
index ce9f09370e22..67de79b2d550 100644
--- a/drivers/media/i2c/vpx3220.c
+++ b/drivers/media/i2c/vpx3220.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#include <linux/module.h> 17#include <linux/module.h>
diff --git a/drivers/media/i2c/vs6624.c b/drivers/media/i2c/vs6624.c
index be4cb7a8bdeb..f0741ab338df 100644
--- a/drivers/media/i2c/vs6624.c
+++ b/drivers/media/i2c/vs6624.c
@@ -11,10 +11,6 @@
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 14 */
19 15
20#include <linux/delay.h> 16#include <linux/delay.h>
diff --git a/drivers/media/i2c/vs6624_regs.h b/drivers/media/i2c/vs6624_regs.h
index 6ba2ee25827e..f78e7d1087a4 100644
--- a/drivers/media/i2c/vs6624_regs.h
+++ b/drivers/media/i2c/vs6624_regs.h
@@ -11,10 +11,6 @@
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 14 */
19 15
20#ifndef _VS6624_REGS_H_ 16#ifndef _VS6624_REGS_H_
diff --git a/drivers/media/i2c/wm8739.c b/drivers/media/i2c/wm8739.c
index c885def54b15..23464d0641fe 100644
--- a/drivers/media/i2c/wm8739.c
+++ b/drivers/media/i2c/wm8739.c
@@ -15,10 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 18 */
23 19
24#include <linux/module.h> 20#include <linux/module.h>
diff --git a/drivers/media/i2c/wm8775.c b/drivers/media/i2c/wm8775.c
index 45039d756753..704bccf0d4b2 100644
--- a/drivers/media/i2c/wm8775.c
+++ b/drivers/media/i2c/wm8775.c
@@ -19,10 +19,6 @@
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 */ 22 */
27 23
28#include <linux/module.h> 24#include <linux/module.h>
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 8756275e9fc4..760e3e424e23 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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 */ 17 */
22 18
23/* We need to access legacy defines from linux/media.h */ 19/* We need to access legacy defines from linux/media.h */
@@ -130,7 +126,7 @@ static long media_device_enum_entities(struct media_device *mdev,
130 * old range. 126 * old range.
131 */ 127 */
132 if (ent->function < MEDIA_ENT_F_OLD_BASE || 128 if (ent->function < MEDIA_ENT_F_OLD_BASE ||
133 ent->function > MEDIA_ENT_T_DEVNODE_UNKNOWN) { 129 ent->function > MEDIA_ENT_F_TUNER) {
134 if (is_media_entity_v4l2_subdev(ent)) 130 if (is_media_entity_v4l2_subdev(ent))
135 entd->type = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN; 131 entd->type = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
136 else if (ent->function != MEDIA_ENT_F_IO_V4L) 132 else if (ent->function != MEDIA_ENT_F_IO_V4L)
@@ -601,19 +597,19 @@ int __must_check media_device_register_entity(struct media_device *mdev,
601 597
602 if (mdev->entity_internal_idx_max 598 if (mdev->entity_internal_idx_max
603 >= mdev->pm_count_walk.ent_enum.idx_max) { 599 >= mdev->pm_count_walk.ent_enum.idx_max) {
604 struct media_entity_graph new = { .top = 0 }; 600 struct media_graph new = { .top = 0 };
605 601
606 /* 602 /*
607 * Initialise the new graph walk before cleaning up 603 * Initialise the new graph walk before cleaning up
608 * the old one in order not to spoil the graph walk 604 * the old one in order not to spoil the graph walk
609 * object of the media device if graph walk init fails. 605 * object of the media device if graph walk init fails.
610 */ 606 */
611 ret = media_entity_graph_walk_init(&new, mdev); 607 ret = media_graph_walk_init(&new, mdev);
612 if (ret) { 608 if (ret) {
613 mutex_unlock(&mdev->graph_mutex); 609 mutex_unlock(&mdev->graph_mutex);
614 return ret; 610 return ret;
615 } 611 }
616 media_entity_graph_walk_cleanup(&mdev->pm_count_walk); 612 media_graph_walk_cleanup(&mdev->pm_count_walk);
617 mdev->pm_count_walk = new; 613 mdev->pm_count_walk = new;
618 } 614 }
619 mutex_unlock(&mdev->graph_mutex); 615 mutex_unlock(&mdev->graph_mutex);
@@ -695,7 +691,7 @@ void media_device_cleanup(struct media_device *mdev)
695{ 691{
696 ida_destroy(&mdev->entity_internal_idx); 692 ida_destroy(&mdev->entity_internal_idx);
697 mdev->entity_internal_idx_max = 0; 693 mdev->entity_internal_idx_max = 0;
698 media_entity_graph_walk_cleanup(&mdev->pm_count_walk); 694 media_graph_walk_cleanup(&mdev->pm_count_walk);
699 mutex_destroy(&mdev->graph_mutex); 695 mutex_destroy(&mdev->graph_mutex);
700} 696}
701EXPORT_SYMBOL_GPL(media_device_cleanup); 697EXPORT_SYMBOL_GPL(media_device_cleanup);
diff --git a/drivers/media/media-devnode.c b/drivers/media/media-devnode.c
index f2772ba6f611..ae46753c90cb 100644
--- a/drivers/media/media-devnode.c
+++ b/drivers/media/media-devnode.c
@@ -19,10 +19,6 @@
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * -- 22 * --
27 * 23 *
28 * Generic media device node infrastructure to register and unregister 24 * Generic media device node infrastructure to register and unregister
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index f9f723f5e4f0..5640ca29da8c 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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 */ 17 */
22 18
23#include <linux/bitmap.h> 19#include <linux/bitmap.h>
@@ -258,7 +254,7 @@ media_entity_other(struct media_entity *entity, struct media_link *link)
258} 254}
259 255
260/* push an entity to traversal stack */ 256/* push an entity to traversal stack */
261static void stack_push(struct media_entity_graph *graph, 257static void stack_push(struct media_graph *graph,
262 struct media_entity *entity) 258 struct media_entity *entity)
263{ 259{
264 if (graph->top == MEDIA_ENTITY_ENUM_MAX_DEPTH - 1) { 260 if (graph->top == MEDIA_ENTITY_ENUM_MAX_DEPTH - 1) {
@@ -270,7 +266,7 @@ static void stack_push(struct media_entity_graph *graph,
270 graph->stack[graph->top].entity = entity; 266 graph->stack[graph->top].entity = entity;
271} 267}
272 268
273static struct media_entity *stack_pop(struct media_entity_graph *graph) 269static struct media_entity *stack_pop(struct media_graph *graph)
274{ 270{
275 struct media_entity *entity; 271 struct media_entity *entity;
276 272
@@ -289,35 +285,35 @@ static struct media_entity *stack_pop(struct media_entity_graph *graph)
289#define MEDIA_ENTITY_MAX_PADS 512 285#define MEDIA_ENTITY_MAX_PADS 512
290 286
291/** 287/**
292 * media_entity_graph_walk_init - Allocate resources for graph walk 288 * media_graph_walk_init - Allocate resources for graph walk
293 * @graph: Media graph structure that will be used to walk the graph 289 * @graph: Media graph structure that will be used to walk the graph
294 * @mdev: Media device 290 * @mdev: Media device
295 * 291 *
296 * Reserve resources for graph walk in media device's current 292 * Reserve resources for graph walk in media device's current
297 * state. The memory must be released using 293 * state. The memory must be released using
298 * media_entity_graph_walk_free(). 294 * media_graph_walk_free().
299 * 295 *
300 * Returns error on failure, zero on success. 296 * Returns error on failure, zero on success.
301 */ 297 */
302__must_check int media_entity_graph_walk_init( 298__must_check int media_graph_walk_init(
303 struct media_entity_graph *graph, struct media_device *mdev) 299 struct media_graph *graph, struct media_device *mdev)
304{ 300{
305 return media_entity_enum_init(&graph->ent_enum, mdev); 301 return media_entity_enum_init(&graph->ent_enum, mdev);
306} 302}
307EXPORT_SYMBOL_GPL(media_entity_graph_walk_init); 303EXPORT_SYMBOL_GPL(media_graph_walk_init);
308 304
309/** 305/**
310 * media_entity_graph_walk_cleanup - Release resources related to graph walking 306 * media_graph_walk_cleanup - Release resources related to graph walking
311 * @graph: Media graph structure that was used to walk the graph 307 * @graph: Media graph structure that was used to walk the graph
312 */ 308 */
313void media_entity_graph_walk_cleanup(struct media_entity_graph *graph) 309void media_graph_walk_cleanup(struct media_graph *graph)
314{ 310{
315 media_entity_enum_cleanup(&graph->ent_enum); 311 media_entity_enum_cleanup(&graph->ent_enum);
316} 312}
317EXPORT_SYMBOL_GPL(media_entity_graph_walk_cleanup); 313EXPORT_SYMBOL_GPL(media_graph_walk_cleanup);
318 314
319void media_entity_graph_walk_start(struct media_entity_graph *graph, 315void media_graph_walk_start(struct media_graph *graph,
320 struct media_entity *entity) 316 struct media_entity *entity)
321{ 317{
322 media_entity_enum_zero(&graph->ent_enum); 318 media_entity_enum_zero(&graph->ent_enum);
323 media_entity_enum_set(&graph->ent_enum, entity); 319 media_entity_enum_set(&graph->ent_enum, entity);
@@ -325,12 +321,52 @@ void media_entity_graph_walk_start(struct media_entity_graph *graph,
325 graph->top = 0; 321 graph->top = 0;
326 graph->stack[graph->top].entity = NULL; 322 graph->stack[graph->top].entity = NULL;
327 stack_push(graph, entity); 323 stack_push(graph, entity);
324 dev_dbg(entity->graph_obj.mdev->dev,
325 "begin graph walk at '%s'\n", entity->name);
328} 326}
329EXPORT_SYMBOL_GPL(media_entity_graph_walk_start); 327EXPORT_SYMBOL_GPL(media_graph_walk_start);
330 328
331struct media_entity * 329static void media_graph_walk_iter(struct media_graph *graph)
332media_entity_graph_walk_next(struct media_entity_graph *graph)
333{ 330{
331 struct media_entity *entity = stack_top(graph);
332 struct media_link *link;
333 struct media_entity *next;
334
335 link = list_entry(link_top(graph), typeof(*link), list);
336
337 /* The link is not enabled so we do not follow. */
338 if (!(link->flags & MEDIA_LNK_FL_ENABLED)) {
339 link_top(graph) = link_top(graph)->next;
340 dev_dbg(entity->graph_obj.mdev->dev,
341 "walk: skipping disabled link '%s':%u -> '%s':%u\n",
342 link->source->entity->name, link->source->index,
343 link->sink->entity->name, link->sink->index);
344 return;
345 }
346
347 /* Get the entity in the other end of the link . */
348 next = media_entity_other(entity, link);
349
350 /* Has the entity already been visited? */
351 if (media_entity_enum_test_and_set(&graph->ent_enum, next)) {
352 link_top(graph) = link_top(graph)->next;
353 dev_dbg(entity->graph_obj.mdev->dev,
354 "walk: skipping entity '%s' (already seen)\n",
355 next->name);
356 return;
357 }
358
359 /* Push the new entity to stack and start over. */
360 link_top(graph) = link_top(graph)->next;
361 stack_push(graph, next);
362 dev_dbg(entity->graph_obj.mdev->dev, "walk: pushing '%s' on stack\n",
363 next->name);
364}
365
366struct media_entity *media_graph_walk_next(struct media_graph *graph)
367{
368 struct media_entity *entity;
369
334 if (stack_top(graph) == NULL) 370 if (stack_top(graph) == NULL)
335 return NULL; 371 return NULL;
336 372
@@ -339,59 +375,39 @@ media_entity_graph_walk_next(struct media_entity_graph *graph)
339 * top of the stack until no more entities on the level can be 375 * top of the stack until no more entities on the level can be
340 * found. 376 * found.
341 */ 377 */
342 while (link_top(graph) != &stack_top(graph)->links) { 378 while (link_top(graph) != &stack_top(graph)->links)
343 struct media_entity *entity = stack_top(graph); 379 media_graph_walk_iter(graph);
344 struct media_link *link;
345 struct media_entity *next;
346
347 link = list_entry(link_top(graph), typeof(*link), list);
348
349 /* The link is not enabled so we do not follow. */
350 if (!(link->flags & MEDIA_LNK_FL_ENABLED)) {
351 link_top(graph) = link_top(graph)->next;
352 continue;
353 }
354 380
355 /* Get the entity in the other end of the link . */ 381 entity = stack_pop(graph);
356 next = media_entity_other(entity, link); 382 dev_dbg(entity->graph_obj.mdev->dev,
383 "walk: returning entity '%s'\n", entity->name);
357 384
358 /* Has the entity already been visited? */ 385 return entity;
359 if (media_entity_enum_test_and_set(&graph->ent_enum, next)) {
360 link_top(graph) = link_top(graph)->next;
361 continue;
362 }
363
364 /* Push the new entity to stack and start over. */
365 link_top(graph) = link_top(graph)->next;
366 stack_push(graph, next);
367 }
368
369 return stack_pop(graph);
370} 386}
371EXPORT_SYMBOL_GPL(media_entity_graph_walk_next); 387EXPORT_SYMBOL_GPL(media_graph_walk_next);
372 388
373/* ----------------------------------------------------------------------------- 389/* -----------------------------------------------------------------------------
374 * Pipeline management 390 * Pipeline management
375 */ 391 */
376 392
377__must_check int __media_entity_pipeline_start(struct media_entity *entity, 393__must_check int __media_pipeline_start(struct media_entity *entity,
378 struct media_pipeline *pipe) 394 struct media_pipeline *pipe)
379{ 395{
380 struct media_device *mdev = entity->graph_obj.mdev; 396 struct media_device *mdev = entity->graph_obj.mdev;
381 struct media_entity_graph *graph = &pipe->graph; 397 struct media_graph *graph = &pipe->graph;
382 struct media_entity *entity_err = entity; 398 struct media_entity *entity_err = entity;
383 struct media_link *link; 399 struct media_link *link;
384 int ret; 400 int ret;
385 401
386 if (!pipe->streaming_count++) { 402 if (!pipe->streaming_count++) {
387 ret = media_entity_graph_walk_init(&pipe->graph, mdev); 403 ret = media_graph_walk_init(&pipe->graph, mdev);
388 if (ret) 404 if (ret)
389 goto error_graph_walk_start; 405 goto error_graph_walk_start;
390 } 406 }
391 407
392 media_entity_graph_walk_start(&pipe->graph, entity); 408 media_graph_walk_start(&pipe->graph, entity);
393 409
394 while ((entity = media_entity_graph_walk_next(graph))) { 410 while ((entity = media_graph_walk_next(graph))) {
395 DECLARE_BITMAP(active, MEDIA_ENTITY_MAX_PADS); 411 DECLARE_BITMAP(active, MEDIA_ENTITY_MAX_PADS);
396 DECLARE_BITMAP(has_no_links, MEDIA_ENTITY_MAX_PADS); 412 DECLARE_BITMAP(has_no_links, MEDIA_ENTITY_MAX_PADS);
397 413
@@ -441,7 +457,7 @@ __must_check int __media_entity_pipeline_start(struct media_entity *entity,
441 ret = entity->ops->link_validate(link); 457 ret = entity->ops->link_validate(link);
442 if (ret < 0 && ret != -ENOIOCTLCMD) { 458 if (ret < 0 && ret != -ENOIOCTLCMD) {
443 dev_dbg(entity->graph_obj.mdev->dev, 459 dev_dbg(entity->graph_obj.mdev->dev,
444 "link validation failed for \"%s\":%u -> \"%s\":%u, error %d\n", 460 "link validation failed for '%s':%u -> '%s':%u, error %d\n",
445 link->source->entity->name, 461 link->source->entity->name,
446 link->source->index, 462 link->source->index,
447 entity->name, link->sink->index, ret); 463 entity->name, link->sink->index, ret);
@@ -455,7 +471,7 @@ __must_check int __media_entity_pipeline_start(struct media_entity *entity,
455 if (!bitmap_full(active, entity->num_pads)) { 471 if (!bitmap_full(active, entity->num_pads)) {
456 ret = -ENOLINK; 472 ret = -ENOLINK;
457 dev_dbg(entity->graph_obj.mdev->dev, 473 dev_dbg(entity->graph_obj.mdev->dev,
458 "\"%s\":%u must be connected by an enabled link\n", 474 "'%s':%u must be connected by an enabled link\n",
459 entity->name, 475 entity->name,
460 (unsigned)find_first_zero_bit( 476 (unsigned)find_first_zero_bit(
461 active, entity->num_pads)); 477 active, entity->num_pads));
@@ -470,11 +486,11 @@ error:
470 * Link validation on graph failed. We revert what we did and 486 * Link validation on graph failed. We revert what we did and
471 * return the error. 487 * return the error.
472 */ 488 */
473 media_entity_graph_walk_start(graph, entity_err); 489 media_graph_walk_start(graph, entity_err);
474 490
475 while ((entity_err = media_entity_graph_walk_next(graph))) { 491 while ((entity_err = media_graph_walk_next(graph))) {
476 /* don't let the stream_count go negative */ 492 /* Sanity check for negative stream_count */
477 if (entity->stream_count > 0) { 493 if (!WARN_ON_ONCE(entity_err->stream_count <= 0)) {
478 entity_err->stream_count--; 494 entity_err->stream_count--;
479 if (entity_err->stream_count == 0) 495 if (entity_err->stream_count == 0)
480 entity_err->pipe = NULL; 496 entity_err->pipe = NULL;
@@ -490,37 +506,37 @@ error:
490 506
491error_graph_walk_start: 507error_graph_walk_start:
492 if (!--pipe->streaming_count) 508 if (!--pipe->streaming_count)
493 media_entity_graph_walk_cleanup(graph); 509 media_graph_walk_cleanup(graph);
494 510
495 return ret; 511 return ret;
496} 512}
497EXPORT_SYMBOL_GPL(__media_entity_pipeline_start); 513EXPORT_SYMBOL_GPL(__media_pipeline_start);
498 514
499__must_check int media_entity_pipeline_start(struct media_entity *entity, 515__must_check int media_pipeline_start(struct media_entity *entity,
500 struct media_pipeline *pipe) 516 struct media_pipeline *pipe)
501{ 517{
502 struct media_device *mdev = entity->graph_obj.mdev; 518 struct media_device *mdev = entity->graph_obj.mdev;
503 int ret; 519 int ret;
504 520
505 mutex_lock(&mdev->graph_mutex); 521 mutex_lock(&mdev->graph_mutex);
506 ret = __media_entity_pipeline_start(entity, pipe); 522 ret = __media_pipeline_start(entity, pipe);
507 mutex_unlock(&mdev->graph_mutex); 523 mutex_unlock(&mdev->graph_mutex);
508 return ret; 524 return ret;
509} 525}
510EXPORT_SYMBOL_GPL(media_entity_pipeline_start); 526EXPORT_SYMBOL_GPL(media_pipeline_start);
511 527
512void __media_entity_pipeline_stop(struct media_entity *entity) 528void __media_pipeline_stop(struct media_entity *entity)
513{ 529{
514 struct media_entity_graph *graph = &entity->pipe->graph; 530 struct media_graph *graph = &entity->pipe->graph;
515 struct media_pipeline *pipe = entity->pipe; 531 struct media_pipeline *pipe = entity->pipe;
516 532
517 533
518 WARN_ON(!pipe->streaming_count); 534 WARN_ON(!pipe->streaming_count);
519 media_entity_graph_walk_start(graph, entity); 535 media_graph_walk_start(graph, entity);
520 536
521 while ((entity = media_entity_graph_walk_next(graph))) { 537 while ((entity = media_graph_walk_next(graph))) {
522 /* don't let the stream_count go negative */ 538 /* Sanity check for negative stream_count */
523 if (entity->stream_count > 0) { 539 if (!WARN_ON_ONCE(entity->stream_count <= 0)) {
524 entity->stream_count--; 540 entity->stream_count--;
525 if (entity->stream_count == 0) 541 if (entity->stream_count == 0)
526 entity->pipe = NULL; 542 entity->pipe = NULL;
@@ -528,20 +544,20 @@ void __media_entity_pipeline_stop(struct media_entity *entity)
528 } 544 }
529 545
530 if (!--pipe->streaming_count) 546 if (!--pipe->streaming_count)
531 media_entity_graph_walk_cleanup(graph); 547 media_graph_walk_cleanup(graph);
532 548
533} 549}
534EXPORT_SYMBOL_GPL(__media_entity_pipeline_stop); 550EXPORT_SYMBOL_GPL(__media_pipeline_stop);
535 551
536void media_entity_pipeline_stop(struct media_entity *entity) 552void media_pipeline_stop(struct media_entity *entity)
537{ 553{
538 struct media_device *mdev = entity->graph_obj.mdev; 554 struct media_device *mdev = entity->graph_obj.mdev;
539 555
540 mutex_lock(&mdev->graph_mutex); 556 mutex_lock(&mdev->graph_mutex);
541 __media_entity_pipeline_stop(entity); 557 __media_pipeline_stop(entity);
542 mutex_unlock(&mdev->graph_mutex); 558 mutex_unlock(&mdev->graph_mutex);
543} 559}
544EXPORT_SYMBOL_GPL(media_entity_pipeline_stop); 560EXPORT_SYMBOL_GPL(media_pipeline_stop);
545 561
546/* ----------------------------------------------------------------------------- 562/* -----------------------------------------------------------------------------
547 * Module use count 563 * Module use count
diff --git a/drivers/media/pci/b2c2/flexcop-pci.c b/drivers/media/pci/b2c2/flexcop-pci.c
index 99ce28442a75..6e60decb2198 100644
--- a/drivers/media/pci/b2c2/flexcop-pci.c
+++ b/drivers/media/pci/b2c2/flexcop-pci.c
@@ -157,7 +157,7 @@ static irqreturn_t flexcop_pci_isr(int irq, void *dev_id)
157 if (v.irq_20c.Data_receiver_error) 157 if (v.irq_20c.Data_receiver_error)
158 deb_chk("data receiver error\n"); 158 deb_chk("data receiver error\n");
159 if (v.irq_20c.Continuity_error_flag) 159 if (v.irq_20c.Continuity_error_flag)
160 deb_chk("Contunuity error flag is set\n"); 160 deb_chk("Continuity error flag is set\n");
161 if (v.irq_20c.LLC_SNAP_FLAG_set) 161 if (v.irq_20c.LLC_SNAP_FLAG_set)
162 deb_chk("LLC_SNAP_FLAG_set is set\n"); 162 deb_chk("LLC_SNAP_FLAG_set is set\n");
163 if (v.irq_20c.Transport_Error) 163 if (v.irq_20c.Transport_Error)
diff --git a/drivers/media/pci/bt8xx/bttv-input.c b/drivers/media/pci/bt8xx/bttv-input.c
index 4da720e4867e..2fd07a8afcd2 100644
--- a/drivers/media/pci/bt8xx/bttv-input.c
+++ b/drivers/media/pci/bt8xx/bttv-input.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 15 */
20 16
21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -424,7 +420,7 @@ int bttv_input_init(struct bttv *btv)
424 return -ENODEV; 420 return -ENODEV;
425 421
426 ir = kzalloc(sizeof(*ir),GFP_KERNEL); 422 ir = kzalloc(sizeof(*ir),GFP_KERNEL);
427 rc = rc_allocate_device(); 423 rc = rc_allocate_device(RC_DRIVER_SCANCODE);
428 if (!ir || !rc) 424 if (!ir || !rc)
429 goto err_out_free; 425 goto err_out_free;
430 426
diff --git a/drivers/media/pci/bt8xx/dst_ca.c b/drivers/media/pci/bt8xx/dst_ca.c
index 8681b9143a35..04d06c564602 100644
--- a/drivers/media/pci/bt8xx/dst_ca.c
+++ b/drivers/media/pci/bt8xx/dst_ca.c
@@ -475,16 +475,14 @@ static int dst_check_ca_pmt(struct dst_state *state, struct ca_msg *p_ca_message
475 475
476static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message, void __user *arg) 476static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message, void __user *arg)
477{ 477{
478 int i = 0; 478 int i;
479 479 u32 command;
480 u32 command = 0;
481 struct ca_msg *hw_buffer; 480 struct ca_msg *hw_buffer;
482 int result = 0; 481 int result = 0;
483 482
484 if ((hw_buffer = kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) { 483 hw_buffer = kmalloc(sizeof(*hw_buffer), GFP_KERNEL);
485 dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); 484 if (!hw_buffer)
486 return -ENOMEM; 485 return -ENOMEM;
487 }
488 dprintk(verbose, DST_CA_DEBUG, 1, " "); 486 dprintk(verbose, DST_CA_DEBUG, 1, " ");
489 487
490 if (copy_from_user(p_ca_message, arg, sizeof (struct ca_msg))) { 488 if (copy_from_user(p_ca_message, arg, sizeof (struct ca_msg))) {
@@ -567,7 +565,6 @@ static long dst_ca_ioctl(struct file *file, unsigned int cmd, unsigned long ioct
567 p_ca_slot_info = kmalloc(sizeof (struct ca_slot_info), GFP_KERNEL); 565 p_ca_slot_info = kmalloc(sizeof (struct ca_slot_info), GFP_KERNEL);
568 p_ca_caps = kmalloc(sizeof (struct ca_caps), GFP_KERNEL); 566 p_ca_caps = kmalloc(sizeof (struct ca_caps), GFP_KERNEL);
569 if (!p_ca_message || !p_ca_slot_info || !p_ca_caps) { 567 if (!p_ca_message || !p_ca_slot_info || !p_ca_caps) {
570 dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure");
571 result = -ENOMEM; 568 result = -ENOMEM;
572 goto free_mem_and_exit; 569 goto free_mem_and_exit;
573 } 570 }
diff --git a/drivers/media/pci/bt8xx/dvb-bt8xx.c b/drivers/media/pci/bt8xx/dvb-bt8xx.c
index 6100fa71ece8..ad617871ce9b 100644
--- a/drivers/media/pci/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/pci/bt8xx/dvb-bt8xx.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */ 16 */
21 17
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -683,6 +679,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
683 /* DST is not a frontend, attaching the ASIC */ 679 /* DST is not a frontend, attaching the ASIC */
684 if (dvb_attach(dst_attach, state, &card->dvb_adapter) == NULL) { 680 if (dvb_attach(dst_attach, state, &card->dvb_adapter) == NULL) {
685 pr_err("%s: Could not find a Twinhan DST\n", __func__); 681 pr_err("%s: Could not find a Twinhan DST\n", __func__);
682 kfree(state);
686 break; 683 break;
687 } 684 }
688 /* Attach other DST peripherals if any */ 685 /* Attach other DST peripherals if any */
diff --git a/drivers/media/pci/bt8xx/dvb-bt8xx.h b/drivers/media/pci/bt8xx/dvb-bt8xx.h
index 4499ed2ac0ed..0ec538e23b4e 100644
--- a/drivers/media/pci/bt8xx/dvb-bt8xx.h
+++ b/drivers/media/pci/bt8xx/dvb-bt8xx.h
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 */ 19 */
24 20
25#ifndef DVB_BT8XX_H 21#ifndef DVB_BT8XX_H
diff --git a/drivers/media/pci/cobalt/cobalt-cpld.c b/drivers/media/pci/cobalt/cobalt-cpld.c
index 23c875fc173e..bfcecef659e3 100644
--- a/drivers/media/pci/cobalt/cobalt-cpld.c
+++ b/drivers/media/pci/cobalt/cobalt-cpld.c
@@ -71,9 +71,9 @@ static void cpld_info_ver3(struct cobalt *cobalt)
71 cobalt_info("\t\tMAXII program revision: 0x%04x\n", 71 cobalt_info("\t\tMAXII program revision: 0x%04x\n",
72 cpld_read(cobalt, 0x30)); 72 cpld_read(cobalt, 0x30));
73 cobalt_info("CPLD temp and voltage ADT7411 registers (read only)\n"); 73 cobalt_info("CPLD temp and voltage ADT7411 registers (read only)\n");
74 cobalt_info("\t\tBoard temperature: %u Celcius\n", 74 cobalt_info("\t\tBoard temperature: %u Celsius\n",
75 cpld_read(cobalt, 0x34) / 4); 75 cpld_read(cobalt, 0x34) / 4);
76 cobalt_info("\t\tFPGA temperature: %u Celcius\n", 76 cobalt_info("\t\tFPGA temperature: %u Celsius\n",
77 cpld_read(cobalt, 0x38) / 4); 77 cpld_read(cobalt, 0x38) / 4);
78 rd = cpld_read(cobalt, 0x3c); 78 rd = cpld_read(cobalt, 0x3c);
79 tmp = (rd * 33 * 1000) / (483 * 10); 79 tmp = (rd * 33 * 1000) / (483 * 10);
diff --git a/drivers/media/pci/cx18/cx18-alsa-main.c b/drivers/media/pci/cx18/cx18-alsa-main.c
index 9fb7f5978c8b..2531e4b81b60 100644
--- a/drivers/media/pci/cx18/cx18-alsa-main.c
+++ b/drivers/media/pci/cx18/cx18-alsa-main.c
@@ -15,11 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 * 02111-1307 USA
23 */ 18 */
24 19
25#include <linux/init.h> 20#include <linux/init.h>
diff --git a/drivers/media/pci/cx18/cx18-alsa-mixer.c b/drivers/media/pci/cx18/cx18-alsa-mixer.c
index 284275270f1b..06b066bc9301 100644
--- a/drivers/media/pci/cx18/cx18-alsa-mixer.c
+++ b/drivers/media/pci/cx18/cx18-alsa-mixer.c
@@ -13,11 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 * 02111-1307 USA
21 */ 16 */
22 17
23#include <linux/init.h> 18#include <linux/init.h>
diff --git a/drivers/media/pci/cx18/cx18-alsa-mixer.h b/drivers/media/pci/cx18/cx18-alsa-mixer.h
index ec9238793f6f..3aed123955dd 100644
--- a/drivers/media/pci/cx18/cx18-alsa-mixer.h
+++ b/drivers/media/pci/cx18/cx18-alsa-mixer.h
@@ -13,11 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 * 02111-1307 USA
21 */ 16 */
22 17
23int __init snd_cx18_mixer_create(struct snd_cx18_card *cxsc); 18int __init snd_cx18_mixer_create(struct snd_cx18_card *cxsc);
diff --git a/drivers/media/pci/cx18/cx18-alsa-pcm.c b/drivers/media/pci/cx18/cx18-alsa-pcm.c
index 5344510fbea3..205a98da877c 100644
--- a/drivers/media/pci/cx18/cx18-alsa-pcm.c
+++ b/drivers/media/pci/cx18/cx18-alsa-pcm.c
@@ -16,11 +16,6 @@
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 * 02111-1307 USA
24 */ 19 */
25 20
26#include <linux/init.h> 21#include <linux/init.h>
diff --git a/drivers/media/pci/cx18/cx18-alsa-pcm.h b/drivers/media/pci/cx18/cx18-alsa-pcm.h
index e2b2c5b01215..b9e3afe14ee0 100644
--- a/drivers/media/pci/cx18/cx18-alsa-pcm.h
+++ b/drivers/media/pci/cx18/cx18-alsa-pcm.h
@@ -13,11 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 * 02111-1307 USA
21 */ 16 */
22 17
23int snd_cx18_pcm_create(struct snd_cx18_card *cxsc); 18int snd_cx18_pcm_create(struct snd_cx18_card *cxsc);
diff --git a/drivers/media/pci/cx18/cx18-alsa.h b/drivers/media/pci/cx18/cx18-alsa.h
index 2718be28bf5f..d88e3bd7944e 100644
--- a/drivers/media/pci/cx18/cx18-alsa.h
+++ b/drivers/media/pci/cx18/cx18-alsa.h
@@ -12,11 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 * 02111-1307 USA
20 */ 15 */
21 16
22struct snd_card; 17struct snd_card;
diff --git a/drivers/media/pci/cx18/cx18-audio.c b/drivers/media/pci/cx18/cx18-audio.c
index 35268923911c..61fc485d3d80 100644
--- a/drivers/media/pci/cx18/cx18-audio.c
+++ b/drivers/media/pci/cx18/cx18-audio.c
@@ -14,11 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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
21 * 02111-1307 USA
22 */ 17 */
23 18
24#include "cx18-driver.h" 19#include "cx18-driver.h"
diff --git a/drivers/media/pci/cx18/cx18-audio.h b/drivers/media/pci/cx18/cx18-audio.h
index 2731d29b0ab9..f65d71a04c19 100644
--- a/drivers/media/pci/cx18/cx18-audio.h
+++ b/drivers/media/pci/cx18/cx18-audio.h
@@ -14,11 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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
21 * 02111-1307 USA
22 */ 17 */
23 18
24int cx18_audio_set_io(struct cx18 *cx); 19int cx18_audio_set_io(struct cx18 *cx);
diff --git a/drivers/media/pci/cx18/cx18-av-audio.c b/drivers/media/pci/cx18/cx18-av-audio.c
index 4a24ffb17a7d..8b95e9aae576 100644
--- a/drivers/media/pci/cx18/cx18-av-audio.c
+++ b/drivers/media/pci/cx18/cx18-av-audio.c
@@ -15,11 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
23 */ 18 */
24 19
25#include "cx18-driver.h" 20#include "cx18-driver.h"
diff --git a/drivers/media/pci/cx18/cx18-av-core.c b/drivers/media/pci/cx18/cx18-av-core.c
index 7f7306fd9a7f..cf8817e9c8b9 100644
--- a/drivers/media/pci/cx18/cx18-av-core.c
+++ b/drivers/media/pci/cx18/cx18-av-core.c
@@ -15,11 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
23 */ 18 */
24 19
25#include "cx18-driver.h" 20#include "cx18-driver.h"
diff --git a/drivers/media/pci/cx18/cx18-av-core.h b/drivers/media/pci/cx18/cx18-av-core.h
index 4c559e86e340..c976ce6e7a78 100644
--- a/drivers/media/pci/cx18/cx18-av-core.h
+++ b/drivers/media/pci/cx18/cx18-av-core.h
@@ -15,11 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
23 */ 18 */
24 19
25#ifndef _CX18_AV_CORE_H_ 20#ifndef _CX18_AV_CORE_H_
diff --git a/drivers/media/pci/cx18/cx18-av-firmware.c b/drivers/media/pci/cx18/cx18-av-firmware.c
index 160e2e53383f..543ace7a481a 100644
--- a/drivers/media/pci/cx18/cx18-av-firmware.c
+++ b/drivers/media/pci/cx18/cx18-av-firmware.c
@@ -13,11 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 */ 16 */
22 17
23#include "cx18-driver.h" 18#include "cx18-driver.h"
diff --git a/drivers/media/pci/cx18/cx18-av-vbi.c b/drivers/media/pci/cx18/cx18-av-vbi.c
index 246982841fec..a002537a387d 100644
--- a/drivers/media/pci/cx18/cx18-av-vbi.c
+++ b/drivers/media/pci/cx18/cx18-av-vbi.c
@@ -14,11 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 */ 17 */
23 18
24 19
diff --git a/drivers/media/pci/cx18/cx18-cards.c b/drivers/media/pci/cx18/cx18-cards.c
index 5e01ea441dc4..11e898e66ce9 100644
--- a/drivers/media/pci/cx18/cx18-cards.c
+++ b/drivers/media/pci/cx18/cx18-cards.c
@@ -15,11 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 * 02111-1307 USA
23 */ 18 */
24 19
25#include "cx18-driver.h" 20#include "cx18-driver.h"
diff --git a/drivers/media/pci/cx18/cx18-cards.h b/drivers/media/pci/cx18/cx18-cards.h
index f6b921f3b0ac..667e2d7b1d03 100644
--- a/drivers/media/pci/cx18/cx18-cards.h
+++ b/drivers/media/pci/cx18/cx18-cards.h
@@ -15,10 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 18 */
23 19
24/* hardware flags */ 20/* hardware flags */
diff --git a/drivers/media/pci/cx18/cx18-controls.c b/drivers/media/pci/cx18/cx18-controls.c
index 812a2507945a..f02df985def0 100644
--- a/drivers/media/pci/cx18/cx18-controls.c
+++ b/drivers/media/pci/cx18/cx18-controls.c
@@ -14,11 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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
21 * 02111-1307 USA
22 */ 17 */
23#include <linux/kernel.h> 18#include <linux/kernel.h>
24#include <linux/slab.h> 19#include <linux/slab.h>
diff --git a/drivers/media/pci/cx18/cx18-driver.c b/drivers/media/pci/cx18/cx18-driver.c
index b8eedbe51c8f..206db81ef78e 100644
--- a/drivers/media/pci/cx18/cx18-driver.c
+++ b/drivers/media/pci/cx18/cx18-driver.c
@@ -15,11 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 * 02111-1307 USA
23 */ 18 */
24 19
25#include "cx18-driver.h" 20#include "cx18-driver.h"
diff --git a/drivers/media/pci/cx18/cx18-driver.h b/drivers/media/pci/cx18/cx18-driver.h
index ef308a10e870..fef3c736fcba 100644
--- a/drivers/media/pci/cx18/cx18-driver.h
+++ b/drivers/media/pci/cx18/cx18-driver.h
@@ -15,11 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 * 02111-1307 USA
23 */ 18 */
24 19
25#ifndef CX18_DRIVER_H 20#ifndef CX18_DRIVER_H
diff --git a/drivers/media/pci/cx18/cx18-dvb.c b/drivers/media/pci/cx18/cx18-dvb.c
index 03d0478170a7..d130d65828b0 100644
--- a/drivers/media/pci/cx18/cx18-dvb.c
+++ b/drivers/media/pci/cx18/cx18-dvb.c
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * 15 *
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#include "cx18-version.h" 19#include "cx18-version.h"
diff --git a/drivers/media/pci/cx18/cx18-dvb.h b/drivers/media/pci/cx18/cx18-dvb.h
index bf8d8f6f5455..33dfc53e3b4f 100644
--- a/drivers/media/pci/cx18/cx18-dvb.h
+++ b/drivers/media/pci/cx18/cx18-dvb.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include "cx18-driver.h" 18#include "cx18-driver.h"
diff --git a/drivers/media/pci/cx18/cx18-fileops.c b/drivers/media/pci/cx18/cx18-fileops.c
index 78b399b8613e..98467b2089fa 100644
--- a/drivers/media/pci/cx18/cx18-fileops.c
+++ b/drivers/media/pci/cx18/cx18-fileops.c
@@ -15,11 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 * 02111-1307 USA
23 */ 18 */
24 19
25#include "cx18-driver.h" 20#include "cx18-driver.h"
diff --git a/drivers/media/pci/cx18/cx18-fileops.h b/drivers/media/pci/cx18/cx18-fileops.h
index b9e5110ad043..58b00b433708 100644
--- a/drivers/media/pci/cx18/cx18-fileops.h
+++ b/drivers/media/pci/cx18/cx18-fileops.h
@@ -14,11 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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
21 * 02111-1307 USA
22 */ 17 */
23 18
24/* Testing/Debugging */ 19/* Testing/Debugging */
diff --git a/drivers/media/pci/cx18/cx18-firmware.c b/drivers/media/pci/cx18/cx18-firmware.c
index c6c83445f8bf..1b34ea1c3730 100644
--- a/drivers/media/pci/cx18/cx18-firmware.c
+++ b/drivers/media/pci/cx18/cx18-firmware.c
@@ -13,11 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 * 02111-1307 USA
21 */ 16 */
22 17
23#include "cx18-driver.h" 18#include "cx18-driver.h"
diff --git a/drivers/media/pci/cx18/cx18-firmware.h b/drivers/media/pci/cx18/cx18-firmware.h
index 38d4c05e8499..bdc4b11f74f7 100644
--- a/drivers/media/pci/cx18/cx18-firmware.h
+++ b/drivers/media/pci/cx18/cx18-firmware.h
@@ -12,11 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 * 02111-1307 USA
20 */ 15 */
21 16
22int cx18_firmware_init(struct cx18 *cx); 17int cx18_firmware_init(struct cx18 *cx);
diff --git a/drivers/media/pci/cx18/cx18-gpio.c b/drivers/media/pci/cx18/cx18-gpio.c
index 38dc6b8f8254..012859e6dc7b 100644
--- a/drivers/media/pci/cx18/cx18-gpio.c
+++ b/drivers/media/pci/cx18/cx18-gpio.c
@@ -15,11 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 * 02111-1307 USA
23 */ 18 */
24 19
25#include "cx18-driver.h" 20#include "cx18-driver.h"
diff --git a/drivers/media/pci/cx18/cx18-gpio.h b/drivers/media/pci/cx18/cx18-gpio.h
index 4aea2ef88e8d..0274a17a8837 100644
--- a/drivers/media/pci/cx18/cx18-gpio.h
+++ b/drivers/media/pci/cx18/cx18-gpio.h
@@ -15,10 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 18 */
23 19
24void cx18_gpio_init(struct cx18 *cx); 20void cx18_gpio_init(struct cx18 *cx);
diff --git a/drivers/media/pci/cx18/cx18-i2c.c b/drivers/media/pci/cx18/cx18-i2c.c
index c9329371a3f8..eabdd4c5520a 100644
--- a/drivers/media/pci/cx18/cx18-i2c.c
+++ b/drivers/media/pci/cx18/cx18-i2c.c
@@ -15,11 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 * 02111-1307 USA
23 */ 18 */
24 19
25#include "cx18-driver.h" 20#include "cx18-driver.h"
diff --git a/drivers/media/pci/cx18/cx18-i2c.h b/drivers/media/pci/cx18/cx18-i2c.h
index 1180fdc8d983..bf315ecbe5dd 100644
--- a/drivers/media/pci/cx18/cx18-i2c.h
+++ b/drivers/media/pci/cx18/cx18-i2c.h
@@ -14,11 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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
21 * 02111-1307 USA
22 */ 17 */
23 18
24int cx18_i2c_register(struct cx18 *cx, unsigned idx); 19int cx18_i2c_register(struct cx18 *cx, unsigned idx);
diff --git a/drivers/media/pci/cx18/cx18-io.c b/drivers/media/pci/cx18/cx18-io.c
index 49b9dbd06248..7090fdbce28f 100644
--- a/drivers/media/pci/cx18/cx18-io.c
+++ b/drivers/media/pci/cx18/cx18-io.c
@@ -13,11 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 * 02111-1307 USA
21 */ 16 */
22 17
23#include "cx18-driver.h" 18#include "cx18-driver.h"
diff --git a/drivers/media/pci/cx18/cx18-io.h b/drivers/media/pci/cx18/cx18-io.h
index 18974d886cf7..a3c96fb5d28d 100644
--- a/drivers/media/pci/cx18/cx18-io.h
+++ b/drivers/media/pci/cx18/cx18-io.h
@@ -13,11 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 * 02111-1307 USA
21 */ 16 */
22 17
23#ifndef CX18_IO_H 18#ifndef CX18_IO_H
diff --git a/drivers/media/pci/cx18/cx18-ioctl.c b/drivers/media/pci/cx18/cx18-ioctl.c
index 0faeb979ceb9..80b902b12a78 100644
--- a/drivers/media/pci/cx18/cx18-ioctl.c
+++ b/drivers/media/pci/cx18/cx18-ioctl.c
@@ -15,11 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 * 02111-1307 USA
23 */ 18 */
24 19
25#include "cx18-driver.h" 20#include "cx18-driver.h"
diff --git a/drivers/media/pci/cx18/cx18-ioctl.h b/drivers/media/pci/cx18/cx18-ioctl.h
index 43433969d633..413129004a89 100644
--- a/drivers/media/pci/cx18/cx18-ioctl.h
+++ b/drivers/media/pci/cx18/cx18-ioctl.h
@@ -15,11 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 * 02111-1307 USA
23 */ 18 */
24 19
25u16 cx18_service2vbi(int type); 20u16 cx18_service2vbi(int type);
diff --git a/drivers/media/pci/cx18/cx18-irq.c b/drivers/media/pci/cx18/cx18-irq.c
index 361426485e98..ff33ffda0126 100644
--- a/drivers/media/pci/cx18/cx18-irq.c
+++ b/drivers/media/pci/cx18/cx18-irq.c
@@ -13,11 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 * 02111-1307 USA
21 */ 16 */
22 17
23#include "cx18-driver.h" 18#include "cx18-driver.h"
diff --git a/drivers/media/pci/cx18/cx18-irq.h b/drivers/media/pci/cx18/cx18-irq.h
index 30e7eaf8cb55..64496746ea46 100644
--- a/drivers/media/pci/cx18/cx18-irq.h
+++ b/drivers/media/pci/cx18/cx18-irq.h
@@ -13,11 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 * 02111-1307 USA
21 */ 16 */
22 17
23#define HW2_I2C1_INT (1 << 22) 18#define HW2_I2C1_INT (1 << 22)
diff --git a/drivers/media/pci/cx18/cx18-mailbox.c b/drivers/media/pci/cx18/cx18-mailbox.c
index d3cf3588879f..763f960fc918 100644
--- a/drivers/media/pci/cx18/cx18-mailbox.c
+++ b/drivers/media/pci/cx18/cx18-mailbox.c
@@ -13,11 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 * 02111-1307 USA
21 */ 16 */
22 17
23#include <stdarg.h> 18#include <stdarg.h>
diff --git a/drivers/media/pci/cx18/cx18-mailbox.h b/drivers/media/pci/cx18/cx18-mailbox.h
index b63fdfaac49e..54b11322bd23 100644
--- a/drivers/media/pci/cx18/cx18-mailbox.h
+++ b/drivers/media/pci/cx18/cx18-mailbox.h
@@ -13,11 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 * 02111-1307 USA
21 */ 16 */
22 17
23#ifndef _CX18_MAILBOX_H_ 18#ifndef _CX18_MAILBOX_H_
diff --git a/drivers/media/pci/cx18/cx18-queue.c b/drivers/media/pci/cx18/cx18-queue.c
index 13e96d6055eb..d212f79fd3aa 100644
--- a/drivers/media/pci/cx18/cx18-queue.c
+++ b/drivers/media/pci/cx18/cx18-queue.c
@@ -15,11 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 * 02111-1307 USA
23 */ 18 */
24 19
25#include "cx18-driver.h" 20#include "cx18-driver.h"
diff --git a/drivers/media/pci/cx18/cx18-queue.h b/drivers/media/pci/cx18/cx18-queue.h
index 4201ddc16091..093b04e0189c 100644
--- a/drivers/media/pci/cx18/cx18-queue.h
+++ b/drivers/media/pci/cx18/cx18-queue.h
@@ -15,11 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 * 02111-1307 USA
23 */ 18 */
24 19
25#define CX18_DMA_UNMAPPED ((u32) -1) 20#define CX18_DMA_UNMAPPED ((u32) -1)
diff --git a/drivers/media/pci/cx18/cx18-scb.c b/drivers/media/pci/cx18/cx18-scb.c
index 85cc59637e54..83a92629519d 100644
--- a/drivers/media/pci/cx18/cx18-scb.c
+++ b/drivers/media/pci/cx18/cx18-scb.c
@@ -13,11 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 * 02111-1307 USA
21 */ 16 */
22 17
23#include "cx18-driver.h" 18#include "cx18-driver.h"
diff --git a/drivers/media/pci/cx18/cx18-scb.h b/drivers/media/pci/cx18/cx18-scb.h
index 08877652e321..7c3eaea3021f 100644
--- a/drivers/media/pci/cx18/cx18-scb.h
+++ b/drivers/media/pci/cx18/cx18-scb.h
@@ -13,11 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 * 02111-1307 USA
21 */ 16 */
22 17
23#ifndef CX18_SCB_H 18#ifndef CX18_SCB_H
diff --git a/drivers/media/pci/cx18/cx18-streams.c b/drivers/media/pci/cx18/cx18-streams.c
index 7f699f0ee76c..7c9381448966 100644
--- a/drivers/media/pci/cx18/cx18-streams.c
+++ b/drivers/media/pci/cx18/cx18-streams.c
@@ -15,11 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 * 02111-1307 USA
23 */ 18 */
24 19
25#include "cx18-driver.h" 20#include "cx18-driver.h"
diff --git a/drivers/media/pci/cx18/cx18-streams.h b/drivers/media/pci/cx18/cx18-streams.h
index 27f8af9b11cd..75c86f1b2e26 100644
--- a/drivers/media/pci/cx18/cx18-streams.h
+++ b/drivers/media/pci/cx18/cx18-streams.h
@@ -15,11 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 * 02111-1307 USA
23 */ 18 */
24 19
25u32 cx18_find_handle(struct cx18 *cx); 20u32 cx18_find_handle(struct cx18 *cx);
diff --git a/drivers/media/pci/cx18/cx18-vbi.c b/drivers/media/pci/cx18/cx18-vbi.c
index 43360cbcf24b..72c74d60c6fb 100644
--- a/drivers/media/pci/cx18/cx18-vbi.c
+++ b/drivers/media/pci/cx18/cx18-vbi.c
@@ -14,11 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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
21 * 02111-1307 USA
22 */ 17 */
23 18
24#include "cx18-driver.h" 19#include "cx18-driver.h"
diff --git a/drivers/media/pci/cx18/cx18-vbi.h b/drivers/media/pci/cx18/cx18-vbi.h
index b365cf4b4668..8c514ea2d2ba 100644
--- a/drivers/media/pci/cx18/cx18-vbi.h
+++ b/drivers/media/pci/cx18/cx18-vbi.h
@@ -14,11 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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
21 * 02111-1307 USA
22 */ 17 */
23 18
24void cx18_process_vbi_data(struct cx18 *cx, struct cx18_mdl *mdl, 19void cx18_process_vbi_data(struct cx18 *cx, struct cx18_mdl *mdl,
diff --git a/drivers/media/pci/cx18/cx18-version.h b/drivers/media/pci/cx18/cx18-version.h
index fed48b6bb67b..50728c68b835 100644
--- a/drivers/media/pci/cx18/cx18-version.h
+++ b/drivers/media/pci/cx18/cx18-version.h
@@ -12,11 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 * 02111-1307 USA
20 */ 15 */
21 16
22#ifndef CX18_VERSION_H 17#ifndef CX18_VERSION_H
diff --git a/drivers/media/pci/cx18/cx18-video.c b/drivers/media/pci/cx18/cx18-video.c
index 6dc84aac8f44..697d01168b63 100644
--- a/drivers/media/pci/cx18/cx18-video.c
+++ b/drivers/media/pci/cx18/cx18-video.c
@@ -12,11 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 * 02111-1307 USA
20 */ 15 */
21 16
22#include "cx18-driver.h" 17#include "cx18-driver.h"
diff --git a/drivers/media/pci/cx18/cx18-video.h b/drivers/media/pci/cx18/cx18-video.h
index 529006a06e5c..f6eca36e7271 100644
--- a/drivers/media/pci/cx18/cx18-video.h
+++ b/drivers/media/pci/cx18/cx18-video.h
@@ -12,11 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 * 02111-1307 USA
20 */ 15 */
21 16
22void cx18_video_set_io(struct cx18 *cx); 17void cx18_video_set_io(struct cx18 *cx);
diff --git a/drivers/media/pci/cx18/cx23418.h b/drivers/media/pci/cx18/cx23418.h
index 67ffe65b56a3..901ed7fac10f 100644
--- a/drivers/media/pci/cx18/cx23418.h
+++ b/drivers/media/pci/cx18/cx23418.h
@@ -12,11 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 * 02111-1307 USA
20 */ 15 */
21 16
22#ifndef CX23418_H 17#ifndef CX23418_H
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
index 589a168d1df4..979b66627f60 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -920,19 +920,6 @@ static const struct m88ds3103_config dvbsky_s950c_m88ds3103_config = {
920 .agc = 0x99, 920 .agc = 0x99,
921}; 921};
922 922
923static const struct m88ds3103_config dvbsky_s952_portc_m88ds3103_config = {
924 .i2c_addr = 0x68,
925 .clock = 27000000,
926 .i2c_wr_max = 33,
927 .clock_out = 0,
928 .ts_mode = M88DS3103_TS_SERIAL,
929 .ts_clk = 96000,
930 .ts_clk_pol = 0,
931 .lnb_en_pol = 1,
932 .lnb_hv_pol = 0,
933 .agc = 0x99,
934};
935
936static const struct m88ds3103_config hauppauge_hvr5525_m88ds3103_config = { 923static const struct m88ds3103_config hauppauge_hvr5525_m88ds3103_config = {
937 .i2c_addr = 0x69, 924 .i2c_addr = 0x69,
938 .clock = 27000000, 925 .clock = 27000000,
@@ -1206,11 +1193,11 @@ static int dvb_register(struct cx23885_tsport *port)
1206 struct si2165_platform_data si2165_pdata; 1193 struct si2165_platform_data si2165_pdata;
1207 struct si2157_config si2157_config; 1194 struct si2157_config si2157_config;
1208 struct ts2020_config ts2020_config; 1195 struct ts2020_config ts2020_config;
1196 struct m88ds3103_platform_data m88ds3103_pdata;
1209 struct i2c_board_info info; 1197 struct i2c_board_info info;
1210 struct i2c_adapter *adapter; 1198 struct i2c_adapter *adapter;
1211 struct i2c_client *client_demod = NULL, *client_tuner = NULL; 1199 struct i2c_client *client_demod = NULL, *client_tuner = NULL;
1212 struct i2c_client *client_sec = NULL; 1200 struct i2c_client *client_sec = NULL;
1213 const struct m88ds3103_config *p_m88ds3103_config = NULL;
1214 int (*p_set_voltage)(struct dvb_frontend *fe, 1201 int (*p_set_voltage)(struct dvb_frontend *fe,
1215 enum fe_sec_voltage voltage) = NULL; 1202 enum fe_sec_voltage voltage) = NULL;
1216 int mfe_shared = 0; /* bus not shared by default */ 1203 int mfe_shared = 0; /* bus not shared by default */
@@ -2103,27 +2090,50 @@ static int dvb_register(struct cx23885_tsport *port)
2103 port->i2c_client_tuner = client_tuner; 2090 port->i2c_client_tuner = client_tuner;
2104 break; 2091 break;
2105 case CX23885_BOARD_DVBSKY_S952: 2092 case CX23885_BOARD_DVBSKY_S952:
2093 /* attach frontend */
2094 memset(&m88ds3103_pdata, 0, sizeof(m88ds3103_pdata));
2095 m88ds3103_pdata.clk = 27000000;
2096 m88ds3103_pdata.i2c_wr_max = 33;
2097 m88ds3103_pdata.agc = 0x99;
2098 m88ds3103_pdata.clk_out = M88DS3103_CLOCK_OUT_DISABLED;
2099 m88ds3103_pdata.lnb_en_pol = 1;
2100
2106 switch (port->nr) { 2101 switch (port->nr) {
2107 /* port b */ 2102 /* port b */
2108 case 1: 2103 case 1:
2109 i2c_bus = &dev->i2c_bus[1]; 2104 i2c_bus = &dev->i2c_bus[1];
2110 p_m88ds3103_config = &dvbsky_t9580_m88ds3103_config; 2105 m88ds3103_pdata.ts_mode = M88DS3103_TS_PARALLEL;
2106 m88ds3103_pdata.ts_clk = 16000;
2107 m88ds3103_pdata.ts_clk_pol = 1;
2111 p_set_voltage = dvbsky_t9580_set_voltage; 2108 p_set_voltage = dvbsky_t9580_set_voltage;
2112 break; 2109 break;
2113 /* port c */ 2110 /* port c */
2114 case 2: 2111 case 2:
2115 i2c_bus = &dev->i2c_bus[0]; 2112 i2c_bus = &dev->i2c_bus[0];
2116 p_m88ds3103_config = &dvbsky_s952_portc_m88ds3103_config; 2113 m88ds3103_pdata.ts_mode = M88DS3103_TS_SERIAL;
2114 m88ds3103_pdata.ts_clk = 96000;
2115 m88ds3103_pdata.ts_clk_pol = 0;
2117 p_set_voltage = dvbsky_s952_portc_set_voltage; 2116 p_set_voltage = dvbsky_s952_portc_set_voltage;
2118 break; 2117 break;
2118 default:
2119 return 0;
2119 } 2120 }
2120 2121
2121 /* attach frontend */ 2122 memset(&info, 0, sizeof(info));
2122 fe0->dvb.frontend = dvb_attach(m88ds3103_attach, 2123 strlcpy(info.type, "m88ds3103", I2C_NAME_SIZE);
2123 p_m88ds3103_config, 2124 info.addr = 0x68;
2124 &i2c_bus->i2c_adap, &adapter); 2125 info.platform_data = &m88ds3103_pdata;
2125 if (fe0->dvb.frontend == NULL) 2126 request_module(info.type);
2126 break; 2127 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
2128 if (client_demod == NULL || client_demod->dev.driver == NULL)
2129 goto frontend_detach;
2130 if (!try_module_get(client_demod->dev.driver->owner)) {
2131 i2c_unregister_device(client_demod);
2132 goto frontend_detach;
2133 }
2134 port->i2c_client_demod = client_demod;
2135 adapter = m88ds3103_pdata.get_i2c_adapter(client_demod);
2136 fe0->dvb.frontend = m88ds3103_pdata.get_dvb_frontend(client_demod);
2127 2137
2128 /* attach tuner */ 2138 /* attach tuner */
2129 memset(&ts2020_config, 0, sizeof(ts2020_config)); 2139 memset(&ts2020_config, 0, sizeof(ts2020_config));
diff --git a/drivers/media/pci/cx23885/cx23885-input.c b/drivers/media/pci/cx23885/cx23885-input.c
index 1f092febdbd1..4367cb3162b6 100644
--- a/drivers/media/pci/cx23885/cx23885-input.c
+++ b/drivers/media/pci/cx23885/cx23885-input.c
@@ -267,7 +267,6 @@ int cx23885_input_init(struct cx23885_dev *dev)
267 struct cx23885_kernel_ir *kernel_ir; 267 struct cx23885_kernel_ir *kernel_ir;
268 struct rc_dev *rc; 268 struct rc_dev *rc;
269 char *rc_map; 269 char *rc_map;
270 enum rc_driver_type driver_type;
271 u64 allowed_protos; 270 u64 allowed_protos;
272 271
273 int ret; 272 int ret;
@@ -285,37 +284,32 @@ int cx23885_input_init(struct cx23885_dev *dev)
285 case CX23885_BOARD_HAUPPAUGE_HVR1290: 284 case CX23885_BOARD_HAUPPAUGE_HVR1290:
286 case CX23885_BOARD_HAUPPAUGE_HVR1250: 285 case CX23885_BOARD_HAUPPAUGE_HVR1250:
287 /* Integrated CX2388[58] IR controller */ 286 /* Integrated CX2388[58] IR controller */
288 driver_type = RC_DRIVER_IR_RAW; 287 allowed_protos = RC_BIT_ALL_IR_DECODER;
289 allowed_protos = RC_BIT_ALL;
290 /* The grey Hauppauge RC-5 remote */ 288 /* The grey Hauppauge RC-5 remote */
291 rc_map = RC_MAP_HAUPPAUGE; 289 rc_map = RC_MAP_HAUPPAUGE;
292 break; 290 break;
293 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL: 291 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
294 /* Integrated CX23885 IR controller */ 292 /* Integrated CX23885 IR controller */
295 driver_type = RC_DRIVER_IR_RAW; 293 allowed_protos = RC_BIT_ALL_IR_DECODER;
296 allowed_protos = RC_BIT_ALL;
297 /* The grey Terratec remote with orange buttons */ 294 /* The grey Terratec remote with orange buttons */
298 rc_map = RC_MAP_NEC_TERRATEC_CINERGY_XS; 295 rc_map = RC_MAP_NEC_TERRATEC_CINERGY_XS;
299 break; 296 break;
300 case CX23885_BOARD_TEVII_S470: 297 case CX23885_BOARD_TEVII_S470:
301 /* Integrated CX23885 IR controller */ 298 /* Integrated CX23885 IR controller */
302 driver_type = RC_DRIVER_IR_RAW; 299 allowed_protos = RC_BIT_ALL_IR_DECODER;
303 allowed_protos = RC_BIT_ALL;
304 /* A guess at the remote */ 300 /* A guess at the remote */
305 rc_map = RC_MAP_TEVII_NEC; 301 rc_map = RC_MAP_TEVII_NEC;
306 break; 302 break;
307 case CX23885_BOARD_MYGICA_X8507: 303 case CX23885_BOARD_MYGICA_X8507:
308 /* Integrated CX23885 IR controller */ 304 /* Integrated CX23885 IR controller */
309 driver_type = RC_DRIVER_IR_RAW; 305 allowed_protos = RC_BIT_ALL_IR_DECODER;
310 allowed_protos = RC_BIT_ALL;
311 /* A guess at the remote */ 306 /* A guess at the remote */
312 rc_map = RC_MAP_TOTAL_MEDIA_IN_HAND_02; 307 rc_map = RC_MAP_TOTAL_MEDIA_IN_HAND_02;
313 break; 308 break;
314 case CX23885_BOARD_TBS_6980: 309 case CX23885_BOARD_TBS_6980:
315 case CX23885_BOARD_TBS_6981: 310 case CX23885_BOARD_TBS_6981:
316 /* Integrated CX23885 IR controller */ 311 /* Integrated CX23885 IR controller */
317 driver_type = RC_DRIVER_IR_RAW; 312 allowed_protos = RC_BIT_ALL_IR_DECODER;
318 allowed_protos = RC_BIT_ALL;
319 /* A guess at the remote */ 313 /* A guess at the remote */
320 rc_map = RC_MAP_TBS_NEC; 314 rc_map = RC_MAP_TBS_NEC;
321 break; 315 break;
@@ -326,14 +320,12 @@ int cx23885_input_init(struct cx23885_dev *dev)
326 case CX23885_BOARD_DVBSKY_S952: 320 case CX23885_BOARD_DVBSKY_S952:
327 case CX23885_BOARD_DVBSKY_T982: 321 case CX23885_BOARD_DVBSKY_T982:
328 /* Integrated CX23885 IR controller */ 322 /* Integrated CX23885 IR controller */
329 driver_type = RC_DRIVER_IR_RAW; 323 allowed_protos = RC_BIT_ALL_IR_DECODER;
330 allowed_protos = RC_BIT_ALL;
331 rc_map = RC_MAP_DVBSKY; 324 rc_map = RC_MAP_DVBSKY;
332 break; 325 break;
333 case CX23885_BOARD_TT_CT2_4500_CI: 326 case CX23885_BOARD_TT_CT2_4500_CI:
334 /* Integrated CX23885 IR controller */ 327 /* Integrated CX23885 IR controller */
335 driver_type = RC_DRIVER_IR_RAW; 328 allowed_protos = RC_BIT_ALL_IR_DECODER;
336 allowed_protos = RC_BIT_ALL;
337 rc_map = RC_MAP_TT_1500; 329 rc_map = RC_MAP_TT_1500;
338 break; 330 break;
339 default: 331 default:
@@ -352,7 +344,7 @@ int cx23885_input_init(struct cx23885_dev *dev)
352 pci_name(dev->pci)); 344 pci_name(dev->pci));
353 345
354 /* input device */ 346 /* input device */
355 rc = rc_allocate_device(); 347 rc = rc_allocate_device(RC_DRIVER_IR_RAW);
356 if (!rc) { 348 if (!rc) {
357 ret = -ENOMEM; 349 ret = -ENOMEM;
358 goto err_out_free; 350 goto err_out_free;
@@ -371,7 +363,6 @@ int cx23885_input_init(struct cx23885_dev *dev)
371 rc->input_id.product = dev->pci->device; 363 rc->input_id.product = dev->pci->device;
372 } 364 }
373 rc->dev.parent = &dev->pci->dev; 365 rc->dev.parent = &dev->pci->dev;
374 rc->driver_type = driver_type;
375 rc->allowed_protocols = allowed_protos; 366 rc->allowed_protocols = allowed_protos;
376 rc->priv = kernel_ir; 367 rc->priv = kernel_ir;
377 rc->open = cx23885_input_ir_open; 368 rc->open = cx23885_input_ir_open;
diff --git a/drivers/media/pci/cx25821/cx25821-alsa.c b/drivers/media/pci/cx25821/cx25821-alsa.c
index 4711583de8fe..519b81c0c837 100644
--- a/drivers/media/pci/cx25821/cx25821-alsa.c
+++ b/drivers/media/pci/cx25821/cx25821-alsa.c
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */ 17 */
22 18
23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/pci/cx25821/cx25821-audio-upstream.c b/drivers/media/pci/cx25821/cx25821-audio-upstream.c
index 7c8edb6181ec..b94eb1c0023d 100644
--- a/drivers/media/pci/cx25821/cx25821-audio-upstream.c
+++ b/drivers/media/pci/cx25821/cx25821-audio-upstream.c
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * 15 *
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/pci/cx25821/cx25821-audio-upstream.h b/drivers/media/pci/cx25821/cx25821-audio-upstream.h
index af2ae7c5815a..2bc875d1ec9f 100644
--- a/drivers/media/pci/cx25821/cx25821-audio-upstream.h
+++ b/drivers/media/pci/cx25821/cx25821-audio-upstream.h
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * 15 *
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#include <linux/mutex.h> 19#include <linux/mutex.h>
diff --git a/drivers/media/pci/cx25821/cx25821-audio.h b/drivers/media/pci/cx25821/cx25821-audio.h
index 1fc2d24f5110..55df64091539 100644
--- a/drivers/media/pci/cx25821/cx25821-audio.h
+++ b/drivers/media/pci/cx25821/cx25821-audio.h
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * 15 *
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#ifndef __CX25821_AUDIO_H__ 19#ifndef __CX25821_AUDIO_H__
diff --git a/drivers/media/pci/cx25821/cx25821-biffuncs.h b/drivers/media/pci/cx25821/cx25821-biffuncs.h
index 937f5a70fb7a..7c0ada3e382d 100644
--- a/drivers/media/pci/cx25821/cx25821-biffuncs.h
+++ b/drivers/media/pci/cx25821/cx25821-biffuncs.h
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * 15 *
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#ifndef _BITFUNCS_H 19#ifndef _BITFUNCS_H
diff --git a/drivers/media/pci/cx25821/cx25821-cards.c b/drivers/media/pci/cx25821/cx25821-cards.c
index f2ebc989b303..f3b4d89d90c8 100644
--- a/drivers/media/pci/cx25821/cx25821-cards.c
+++ b/drivers/media/pci/cx25821/cx25821-cards.c
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * 16 *
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 18 */
23 19
24#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 20#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/pci/cx25821/cx25821-core.c b/drivers/media/pci/cx25821/cx25821-core.c
index 9a5f912ca859..fbc0229183bd 100644
--- a/drivers/media/pci/cx25821/cx25821-core.c
+++ b/drivers/media/pci/cx25821/cx25821-core.c
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * 16 *
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 18 */
23 19
24#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 20#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/pci/cx25821/cx25821-gpio.c b/drivers/media/pci/cx25821/cx25821-gpio.c
index 95e8ddf62947..76b8f619e55a 100644
--- a/drivers/media/pci/cx25821/cx25821-gpio.c
+++ b/drivers/media/pci/cx25821/cx25821-gpio.c
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * 15 *
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#include <linux/module.h> 19#include <linux/module.h>
diff --git a/drivers/media/pci/cx25821/cx25821-i2c.c b/drivers/media/pci/cx25821/cx25821-i2c.c
index 63ba25b82692..263a1cf36ef1 100644
--- a/drivers/media/pci/cx25821/cx25821-i2c.c
+++ b/drivers/media/pci/cx25821/cx25821-i2c.c
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * 16 *
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 18 */
23 19
24#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 20#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/pci/cx25821/cx25821-medusa-defines.h b/drivers/media/pci/cx25821/cx25821-medusa-defines.h
index 7a9e6470ba22..36977090ec4c 100644
--- a/drivers/media/pci/cx25821/cx25821-medusa-defines.h
+++ b/drivers/media/pci/cx25821/cx25821-medusa-defines.h
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * 15 *
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#ifndef _MEDUSA_DEF_H_ 19#ifndef _MEDUSA_DEF_H_
diff --git a/drivers/media/pci/cx25821/cx25821-medusa-reg.h b/drivers/media/pci/cx25821/cx25821-medusa-reg.h
index 2e10643a86b7..6ef63b867879 100644
--- a/drivers/media/pci/cx25821/cx25821-medusa-reg.h
+++ b/drivers/media/pci/cx25821/cx25821-medusa-reg.h
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * 15 *
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#ifndef __MEDUSA_REGISTERS__ 19#ifndef __MEDUSA_REGISTERS__
diff --git a/drivers/media/pci/cx25821/cx25821-medusa-video.c b/drivers/media/pci/cx25821/cx25821-medusa-video.c
index 43bdfa4dfba1..0a9db050b175 100644
--- a/drivers/media/pci/cx25821/cx25821-medusa-video.c
+++ b/drivers/media/pci/cx25821/cx25821-medusa-video.c
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * 15 *
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/pci/cx25821/cx25821-medusa-video.h b/drivers/media/pci/cx25821/cx25821-medusa-video.h
index 8bf602ff27b1..176b35333f2b 100644
--- a/drivers/media/pci/cx25821/cx25821-medusa-video.h
+++ b/drivers/media/pci/cx25821/cx25821-medusa-video.h
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * 15 *
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#ifndef _MEDUSA_VIDEO_H 19#ifndef _MEDUSA_VIDEO_H
diff --git a/drivers/media/pci/cx25821/cx25821-reg.h b/drivers/media/pci/cx25821/cx25821-reg.h
index a3fc25a4dc0b..061cdeb9b45b 100644
--- a/drivers/media/pci/cx25821/cx25821-reg.h
+++ b/drivers/media/pci/cx25821/cx25821-reg.h
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * 15 *
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#ifndef __CX25821_REGISTERS__ 19#ifndef __CX25821_REGISTERS__
diff --git a/drivers/media/pci/cx25821/cx25821-sram.h b/drivers/media/pci/cx25821/cx25821-sram.h
index 5f05d153bc4d..b94e0d4df664 100644
--- a/drivers/media/pci/cx25821/cx25821-sram.h
+++ b/drivers/media/pci/cx25821/cx25821-sram.h
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * 15 *
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#ifndef __ATHENA_SRAM_H__ 19#ifndef __ATHENA_SRAM_H__
diff --git a/drivers/media/pci/cx25821/cx25821-video-upstream.c b/drivers/media/pci/cx25821/cx25821-video-upstream.c
index a664997e1958..6c838c8a7924 100644
--- a/drivers/media/pci/cx25821/cx25821-video-upstream.c
+++ b/drivers/media/pci/cx25821/cx25821-video-upstream.c
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * 15 *
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/pci/cx25821/cx25821-video-upstream.h b/drivers/media/pci/cx25821/cx25821-video-upstream.h
index 268ec8aa6a61..b6cf95f2d11b 100644
--- a/drivers/media/pci/cx25821/cx25821-video-upstream.h
+++ b/drivers/media/pci/cx25821/cx25821-video-upstream.h
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * 15 *
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#include <linux/mutex.h> 19#include <linux/mutex.h>
diff --git a/drivers/media/pci/cx25821/cx25821-video.c b/drivers/media/pci/cx25821/cx25821-video.c
index 7ce352a0f2d3..dbaf42ec26cd 100644
--- a/drivers/media/pci/cx25821/cx25821-video.c
+++ b/drivers/media/pci/cx25821/cx25821-video.c
@@ -18,10 +18,6 @@
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * 19 *
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 21 */
26 22
27#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/pci/cx25821/cx25821-video.h b/drivers/media/pci/cx25821/cx25821-video.h
index ab63b3858acf..246011c1ba08 100644
--- a/drivers/media/pci/cx25821/cx25821-video.h
+++ b/drivers/media/pci/cx25821/cx25821-video.h
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * 16 *
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 18 */
23 19
24#ifndef CX25821_VIDEO_H_ 20#ifndef CX25821_VIDEO_H_
diff --git a/drivers/media/pci/cx25821/cx25821.h b/drivers/media/pci/cx25821/cx25821.h
index ef61dea982e8..0f20e89b0cde 100644
--- a/drivers/media/pci/cx25821/cx25821.h
+++ b/drivers/media/pci/cx25821/cx25821.h
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * 16 *
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 18 */
23 19
24#ifndef CX25821_H_ 20#ifndef CX25821_H_
diff --git a/drivers/media/pci/cx88/cx88-input.c b/drivers/media/pci/cx88/cx88-input.c
index c7b3cb406499..01f2e472a2a0 100644
--- a/drivers/media/pci/cx88/cx88-input.c
+++ b/drivers/media/pci/cx88/cx88-input.c
@@ -274,7 +274,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
274 */ 274 */
275 275
276 ir = kzalloc(sizeof(*ir), GFP_KERNEL); 276 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
277 dev = rc_allocate_device(); 277 dev = rc_allocate_device(RC_DRIVER_IR_RAW);
278 if (!ir || !dev) 278 if (!ir || !dev)
279 goto err_out_free; 279 goto err_out_free;
280 280
@@ -484,7 +484,6 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
484 dev->scancode_mask = hardware_mask; 484 dev->scancode_mask = hardware_mask;
485 485
486 if (ir->sampling) { 486 if (ir->sampling) {
487 dev->driver_type = RC_DRIVER_IR_RAW;
488 dev->timeout = 10 * 1000 * 1000; /* 10 ms */ 487 dev->timeout = 10 * 1000 * 1000; /* 10 ms */
489 } else { 488 } else {
490 dev->driver_type = RC_DRIVER_SCANCODE; 489 dev->driver_type = RC_DRIVER_SCANCODE;
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c
index a6c9fe235974..340cff02dee2 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -13,12 +13,8 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * 16 * To obtain the license, point your browser to
17 * You should have received a copy of the GNU General Public License 17 * http://www.gnu.org/copyleft/gpl.html
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA
21 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
22 */ 18 */
23 19
24#include <linux/module.h> 20#include <linux/module.h>
diff --git a/drivers/media/pci/ddbridge/ddbridge-regs.h b/drivers/media/pci/ddbridge/ddbridge-regs.h
index a3ccb318b500..6ae810324b4e 100644
--- a/drivers/media/pci/ddbridge/ddbridge-regs.h
+++ b/drivers/media/pci/ddbridge/ddbridge-regs.h
@@ -13,12 +13,8 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * 16 * To obtain the license, point your browser to
17 * You should have received a copy of the GNU General Public License 17 * http://www.gnu.org/copyleft/gpl.html
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA
21 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
22 */ 18 */
23 19
24/* DD-DVBBridgeV1.h 273 2010-09-17 05:03:16Z manfred */ 20/* DD-DVBBridgeV1.h 273 2010-09-17 05:03:16Z manfred */
diff --git a/drivers/media/pci/ddbridge/ddbridge.h b/drivers/media/pci/ddbridge/ddbridge.h
index be87fbd90456..185b423818d3 100644
--- a/drivers/media/pci/ddbridge/ddbridge.h
+++ b/drivers/media/pci/ddbridge/ddbridge.h
@@ -13,12 +13,8 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * 16 * To obtain the license, point your browser to
17 * You should have received a copy of the GNU General Public License 17 * http://www.gnu.org/copyleft/gpl.html
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA
21 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
22 */ 18 */
23 19
24#ifndef _DDBRIDGE_H_ 20#ifndef _DDBRIDGE_H_
diff --git a/drivers/media/pci/dm1105/Kconfig b/drivers/media/pci/dm1105/Kconfig
index 173daf0c0847..14fa7e40f2a6 100644
--- a/drivers/media/pci/dm1105/Kconfig
+++ b/drivers/media/pci/dm1105/Kconfig
@@ -1,6 +1,6 @@
1config DVB_DM1105 1config DVB_DM1105
2 tristate "SDMC DM1105 based PCI cards" 2 tristate "SDMC DM1105 based PCI cards"
3 depends on DVB_CORE && PCI && I2C 3 depends on DVB_CORE && PCI && I2C && I2C_ALGOBIT
4 select DVB_PLL if MEDIA_SUBDRV_AUTOSELECT 4 select DVB_PLL if MEDIA_SUBDRV_AUTOSELECT
5 select DVB_STV0299 if MEDIA_SUBDRV_AUTOSELECT 5 select DVB_STV0299 if MEDIA_SUBDRV_AUTOSELECT
6 select DVB_STV0288 if MEDIA_SUBDRV_AUTOSELECT 6 select DVB_STV0288 if MEDIA_SUBDRV_AUTOSELECT
diff --git a/drivers/media/pci/dm1105/dm1105.c b/drivers/media/pci/dm1105/dm1105.c
index a589aa78d1d9..a7724b78fbb4 100644
--- a/drivers/media/pci/dm1105/dm1105.c
+++ b/drivers/media/pci/dm1105/dm1105.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */ 16 */
21 17
22#include <linux/i2c.h> 18#include <linux/i2c.h>
@@ -743,7 +739,7 @@ static int dm1105_ir_init(struct dm1105_dev *dm1105)
743 struct rc_dev *dev; 739 struct rc_dev *dev;
744 int err = -ENOMEM; 740 int err = -ENOMEM;
745 741
746 dev = rc_allocate_device(); 742 dev = rc_allocate_device(RC_DRIVER_SCANCODE);
747 if (!dev) 743 if (!dev)
748 return -ENOMEM; 744 return -ENOMEM;
749 745
@@ -752,7 +748,6 @@ static int dm1105_ir_init(struct dm1105_dev *dm1105)
752 748
753 dev->driver_name = MODULE_NAME; 749 dev->driver_name = MODULE_NAME;
754 dev->map_name = RC_MAP_DM1105_NEC; 750 dev->map_name = RC_MAP_DM1105_NEC;
755 dev->driver_type = RC_DRIVER_SCANCODE;
756 dev->input_name = "DVB on-card IR receiver"; 751 dev->input_name = "DVB on-card IR receiver";
757 dev->input_phys = dm1105->ir.input_phys; 752 dev->input_phys = dm1105->ir.input_phys;
758 dev->input_id.bustype = BUS_PCI; 753 dev->input_id.bustype = BUS_PCI;
diff --git a/drivers/media/pci/ivtv/Kconfig b/drivers/media/pci/ivtv/Kconfig
index 6e5867c57305..c72cbbd2d40c 100644
--- a/drivers/media/pci/ivtv/Kconfig
+++ b/drivers/media/pci/ivtv/Kconfig
@@ -28,6 +28,19 @@ config VIDEO_IVTV
28 To compile this driver as a module, choose M here: the 28 To compile this driver as a module, choose M here: the
29 module will be called ivtv. 29 module will be called ivtv.
30 30
31config VIDEO_IVTV_DEPRECATED_IOCTLS
32 bool "enable the DVB ioctls abuse on ivtv driver"
33 depends on VIDEO_IVTV
34 default n
35 ---help---
36 Enable the usage of the a DVB set of ioctls that were abused by
37 IVTV driver for a while.
38
39 Those ioctls were not needed for a long time, as IVTV implements
40 the proper V4L2 ioctls since kernel 3.3.
41
42 If unsure, say N.
43
31config VIDEO_IVTV_ALSA 44config VIDEO_IVTV_ALSA
32 tristate "Conexant cx23415/cx23416 ALSA interface for PCM audio capture" 45 tristate "Conexant cx23415/cx23416 ALSA interface for PCM audio capture"
33 depends on VIDEO_IVTV && SND 46 depends on VIDEO_IVTV && SND
diff --git a/drivers/media/pci/ivtv/ivtv-alsa-main.c b/drivers/media/pci/ivtv/ivtv-alsa-main.c
index 374f45f81ab3..029f52733f70 100644
--- a/drivers/media/pci/ivtv/ivtv-alsa-main.c
+++ b/drivers/media/pci/ivtv/ivtv-alsa-main.c
@@ -15,38 +15,25 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 * 02111-1307 USA
23 */ 18 */
24 19
25#include <linux/init.h>
26#include <linux/slab.h>
27#include <linux/module.h>
28#include <linux/kernel.h>
29#include <linux/device.h>
30#include <linux/spinlock.h>
31
32#include <media/v4l2-device.h>
33
34#include <sound/core.h>
35#include <sound/initval.h>
36
37#include "ivtv-driver.h" 20#include "ivtv-driver.h"
38#include "ivtv-version.h" 21#include "ivtv-version.h"
39#include "ivtv-alsa.h" 22#include "ivtv-alsa.h"
40#include "ivtv-alsa-mixer.h" 23#include "ivtv-alsa-mixer.h"
41#include "ivtv-alsa-pcm.h" 24#include "ivtv-alsa-pcm.h"
42 25
26#include <sound/core.h>
27#include <sound/initval.h>
28
43int ivtv_alsa_debug; 29int ivtv_alsa_debug;
44static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 30static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
45 31
46#define IVTV_DEBUG_ALSA_INFO(fmt, arg...) \ 32#define IVTV_DEBUG_ALSA_INFO(__fmt, __arg...) \
47 do { \ 33 do { \
48 if (ivtv_alsa_debug & 2) \ 34 if (ivtv_alsa_debug & 2) \
49 pr_info("%s: " fmt, "ivtv-alsa", ## arg); \ 35 printk(KERN_INFO pr_fmt("%s: alsa:" __fmt), \
36 __func__, ##__arg); \
50 } while (0) 37 } while (0)
51 38
52module_param_named(debug, ivtv_alsa_debug, int, 0644); 39module_param_named(debug, ivtv_alsa_debug, int, 0644);
@@ -235,8 +222,7 @@ static int ivtv_alsa_load(struct ivtv *itv)
235 222
236 s = &itv->streams[IVTV_ENC_STREAM_TYPE_PCM]; 223 s = &itv->streams[IVTV_ENC_STREAM_TYPE_PCM];
237 if (s->vdev.v4l2_dev == NULL) { 224 if (s->vdev.v4l2_dev == NULL) {
238 IVTV_DEBUG_ALSA_INFO("%s: PCM stream for card is disabled - skipping\n", 225 IVTV_DEBUG_ALSA_INFO("PCM stream for card is disabled - skipping\n");
239 __func__);
240 return 0; 226 return 0;
241 } 227 }
242 228
@@ -250,8 +236,7 @@ static int ivtv_alsa_load(struct ivtv *itv)
250 IVTV_ALSA_ERR("%s: failed to create struct snd_ivtv_card\n", 236 IVTV_ALSA_ERR("%s: failed to create struct snd_ivtv_card\n",
251 __func__); 237 __func__);
252 } else { 238 } else {
253 IVTV_DEBUG_ALSA_INFO("%s: created ivtv ALSA interface instance \n", 239 IVTV_DEBUG_ALSA_INFO("created ivtv ALSA interface instance\n");
254 __func__);
255 } 240 }
256 return 0; 241 return 0;
257} 242}
diff --git a/drivers/media/pci/ivtv/ivtv-alsa-mixer.c b/drivers/media/pci/ivtv/ivtv-alsa-mixer.c
index 79b24bde4a39..ba372a23eb5c 100644
--- a/drivers/media/pci/ivtv/ivtv-alsa-mixer.c
+++ b/drivers/media/pci/ivtv/ivtv-alsa-mixer.c
@@ -13,28 +13,18 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 * 02111-1307 USA
21 */ 16 */
22 17
23#include <linux/init.h> 18#include "ivtv-alsa.h"
24#include <linux/kernel.h> 19#include "ivtv-alsa-mixer.h"
25#include <linux/device.h> 20#include "ivtv-driver.h"
26#include <linux/spinlock.h>
27#include <linux/videodev2.h>
28 21
29#include <media/v4l2-device.h> 22#include <linux/videodev2.h>
30 23
31#include <sound/core.h> 24#include <sound/core.h>
32#include <sound/control.h> 25#include <sound/control.h>
33#include <sound/tlv.h> 26#include <sound/tlv.h>
34 27
35#include "ivtv-alsa.h"
36#include "ivtv-driver.h"
37
38/* 28/*
39 * Note the cx25840-core volume scale is funny, due to the alignment of the 29 * Note the cx25840-core volume scale is funny, due to the alignment of the
40 * scale with another chip's range: 30 * scale with another chip's range:
diff --git a/drivers/media/pci/ivtv/ivtv-alsa-mixer.h b/drivers/media/pci/ivtv/ivtv-alsa-mixer.h
index cdde36704d53..382bc36bc529 100644
--- a/drivers/media/pci/ivtv/ivtv-alsa-mixer.h
+++ b/drivers/media/pci/ivtv/ivtv-alsa-mixer.h
@@ -13,11 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 * 02111-1307 USA
21 */ 16 */
22 17
23int __init snd_ivtv_mixer_create(struct snd_ivtv_card *itvsc); 18int __init snd_ivtv_mixer_create(struct snd_ivtv_card *itvsc);
diff --git a/drivers/media/pci/ivtv/ivtv-alsa-pcm.c b/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
index a26f9800eca3..807ead20d212 100644
--- a/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
+++ b/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
@@ -16,22 +16,8 @@
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 * 02111-1307 USA
24 */ 19 */
25 20
26#include <linux/init.h>
27#include <linux/kernel.h>
28#include <linux/vmalloc.h>
29
30#include <media/v4l2-device.h>
31
32#include <sound/core.h>
33#include <sound/pcm.h>
34
35#include "ivtv-driver.h" 21#include "ivtv-driver.h"
36#include "ivtv-queue.h" 22#include "ivtv-queue.h"
37#include "ivtv-streams.h" 23#include "ivtv-streams.h"
@@ -39,6 +25,12 @@
39#include "ivtv-alsa.h" 25#include "ivtv-alsa.h"
40#include "ivtv-alsa-pcm.h" 26#include "ivtv-alsa-pcm.h"
41 27
28#include <linux/vmalloc.h>
29
30#include <sound/core.h>
31#include <sound/pcm.h>
32
33
42static unsigned int pcm_debug; 34static unsigned int pcm_debug;
43module_param(pcm_debug, int, 0644); 35module_param(pcm_debug, int, 0644);
44MODULE_PARM_DESC(pcm_debug, "enable debug messages for pcm"); 36MODULE_PARM_DESC(pcm_debug, "enable debug messages for pcm");
@@ -174,6 +166,7 @@ static int snd_ivtv_pcm_capture_open(struct snd_pcm_substream *substream)
174 /* See if the stream is available */ 166 /* See if the stream is available */
175 if (ivtv_claim_stream(&item, item.type)) { 167 if (ivtv_claim_stream(&item, item.type)) {
176 /* No, it's already in use */ 168 /* No, it's already in use */
169 v4l2_fh_exit(&item.fh);
177 snd_ivtv_unlock(itvsc); 170 snd_ivtv_unlock(itvsc);
178 return -EBUSY; 171 return -EBUSY;
179 } 172 }
diff --git a/drivers/media/pci/ivtv/ivtv-alsa-pcm.h b/drivers/media/pci/ivtv/ivtv-alsa-pcm.h
index 186814e0b2d4..147586a886fc 100644
--- a/drivers/media/pci/ivtv/ivtv-alsa-pcm.h
+++ b/drivers/media/pci/ivtv/ivtv-alsa-pcm.h
@@ -13,11 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 * 02111-1307 USA
21 */ 16 */
22 17
23int snd_ivtv_pcm_create(struct snd_ivtv_card *itvsc); 18int snd_ivtv_pcm_create(struct snd_ivtv_card *itvsc);
diff --git a/drivers/media/pci/ivtv/ivtv-alsa.h b/drivers/media/pci/ivtv/ivtv-alsa.h
index 4a0d8f2c254d..eae646223367 100644
--- a/drivers/media/pci/ivtv/ivtv-alsa.h
+++ b/drivers/media/pci/ivtv/ivtv-alsa.h
@@ -13,11 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 * 02111-1307 USA
21 */ 16 */
22 17
23struct snd_card; 18struct snd_card;
diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
index 0a3b80a4bd69..ab2ae53618e8 100644
--- a/drivers/media/pci/ivtv/ivtv-driver.c
+++ b/drivers/media/pci/ivtv/ivtv-driver.c
@@ -1452,7 +1452,7 @@ static void ivtv_remove(struct pci_dev *pdev)
1452 for (i = 0; i < IVTV_VBI_FRAMES; i++) 1452 for (i = 0; i < IVTV_VBI_FRAMES; i++)
1453 kfree(itv->vbi.sliced_mpeg_data[i]); 1453 kfree(itv->vbi.sliced_mpeg_data[i]);
1454 1454
1455 printk(KERN_INFO "ivtv: Removed %s\n", itv->card_name); 1455 pr_info("Removed %s\n", itv->card_name);
1456 1456
1457 v4l2_device_unregister(&itv->v4l2_dev); 1457 v4l2_device_unregister(&itv->v4l2_dev);
1458 kfree(itv); 1458 kfree(itv);
@@ -1468,25 +1468,25 @@ static struct pci_driver ivtv_pci_driver = {
1468 1468
1469static int __init module_start(void) 1469static int __init module_start(void)
1470{ 1470{
1471 printk(KERN_INFO "ivtv: Start initialization, version %s\n", IVTV_VERSION); 1471 pr_info("Start initialization, version %s\n", IVTV_VERSION);
1472 1472
1473 /* Validate parameters */ 1473 /* Validate parameters */
1474 if (ivtv_first_minor < 0 || ivtv_first_minor >= IVTV_MAX_CARDS) { 1474 if (ivtv_first_minor < 0 || ivtv_first_minor >= IVTV_MAX_CARDS) {
1475 printk(KERN_ERR "ivtv: Exiting, ivtv_first_minor must be between 0 and %d\n", 1475 pr_err("Exiting, ivtv_first_minor must be between 0 and %d\n",
1476 IVTV_MAX_CARDS - 1); 1476 IVTV_MAX_CARDS - 1);
1477 return -1; 1477 return -1;
1478 } 1478 }
1479 1479
1480 if (ivtv_debug < 0 || ivtv_debug > 2047) { 1480 if (ivtv_debug < 0 || ivtv_debug > 2047) {
1481 ivtv_debug = 0; 1481 ivtv_debug = 0;
1482 printk(KERN_INFO "ivtv: Debug value must be >= 0 and <= 2047\n"); 1482 pr_info("Debug value must be >= 0 and <= 2047\n");
1483 } 1483 }
1484 1484
1485 if (pci_register_driver(&ivtv_pci_driver)) { 1485 if (pci_register_driver(&ivtv_pci_driver)) {
1486 printk(KERN_ERR "ivtv: Error detecting PCI card\n"); 1486 pr_err("Error detecting PCI card\n");
1487 return -ENODEV; 1487 return -ENODEV;
1488 } 1488 }
1489 printk(KERN_INFO "ivtv: End initialization\n"); 1489 pr_info("End initialization\n");
1490 return 0; 1490 return 0;
1491} 1491}
1492 1492
diff --git a/drivers/media/pci/ivtv/ivtv-driver.h b/drivers/media/pci/ivtv/ivtv-driver.h
index 6b09a9514d64..cde452e30746 100644
--- a/drivers/media/pci/ivtv/ivtv-driver.h
+++ b/drivers/media/pci/ivtv/ivtv-driver.h
@@ -22,6 +22,8 @@
22#ifndef IVTV_DRIVER_H 22#ifndef IVTV_DRIVER_H
23#define IVTV_DRIVER_H 23#define IVTV_DRIVER_H
24 24
25#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
26
25/* Internal header for ivtv project: 27/* Internal header for ivtv project:
26 * Driver for the cx23415/6 chip. 28 * Driver for the cx23415/6 chip.
27 * Author: Kevin Thayer (nufan_wfk at yahoo.com) 29 * Author: Kevin Thayer (nufan_wfk at yahoo.com)
@@ -36,38 +38,37 @@
36 * using information provided by Jiun-Kuei Jung @ AVerMedia. 38 * using information provided by Jiun-Kuei Jung @ AVerMedia.
37 */ 39 */
38 40
39#include <linux/module.h> 41#include <asm/byteorder.h>
40#include <linux/init.h>
41#include <linux/delay.h> 42#include <linux/delay.h>
42#include <linux/sched.h> 43#include <linux/device.h>
43#include <linux/fs.h> 44#include <linux/fs.h>
44#include <linux/pci.h>
45#include <linux/interrupt.h>
46#include <linux/spinlock.h>
47#include <linux/i2c.h> 45#include <linux/i2c.h>
48#include <linux/i2c-algo-bit.h> 46#include <linux/i2c-algo-bit.h>
47#include <linux/init.h>
48#include <linux/interrupt.h>
49#include <linux/ivtv.h>
50#include <linux/kernel.h>
51#include <linux/kthread.h>
49#include <linux/list.h> 52#include <linux/list.h>
50#include <linux/unistd.h> 53#include <linux/module.h>
54#include <linux/mutex.h>
51#include <linux/pagemap.h> 55#include <linux/pagemap.h>
56#include <linux/pci.h>
52#include <linux/scatterlist.h> 57#include <linux/scatterlist.h>
53#include <linux/kthread.h> 58#include <linux/sched.h>
54#include <linux/mutex.h>
55#include <linux/slab.h> 59#include <linux/slab.h>
60#include <linux/spinlock.h>
56#include <linux/uaccess.h> 61#include <linux/uaccess.h>
57#include <asm/byteorder.h> 62#include <linux/unistd.h>
58 63
59#include <linux/dvb/video.h> 64#include <media/drv-intf/cx2341x.h>
60#include <linux/dvb/audio.h> 65#include <media/i2c/ir-kbd-i2c.h>
66#include <media/tuner.h>
61#include <media/v4l2-common.h> 67#include <media/v4l2-common.h>
62#include <media/v4l2-ioctl.h>
63#include <media/v4l2-ctrls.h> 68#include <media/v4l2-ctrls.h>
64#include <media/v4l2-device.h> 69#include <media/v4l2-device.h>
65#include <media/v4l2-fh.h> 70#include <media/v4l2-fh.h>
66#include <media/tuner.h> 71#include <media/v4l2-ioctl.h>
67#include <media/drv-intf/cx2341x.h>
68#include <media/i2c/ir-kbd-i2c.h>
69
70#include <linux/ivtv.h>
71 72
72/* Memory layout */ 73/* Memory layout */
73#define IVTV_ENCODER_OFFSET 0x00000000 74#define IVTV_ENCODER_OFFSET 0x00000000
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c b/drivers/media/pci/ivtv/ivtv-ioctl.c
index 2dc4b20f3ac0..f956188f7f19 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -35,7 +35,10 @@
35#include <media/i2c/saa7127.h> 35#include <media/i2c/saa7127.h>
36#include <media/tveeprom.h> 36#include <media/tveeprom.h>
37#include <media/v4l2-event.h> 37#include <media/v4l2-event.h>
38#ifdef CONFIG_VIDEO_IVTV_DEPRECATED_IOCTLS
38#include <linux/dvb/audio.h> 39#include <linux/dvb/audio.h>
40#include <linux/dvb/video.h>
41#endif
39 42
40u16 ivtv_service2vbi(int type) 43u16 ivtv_service2vbi(int type)
41{ 44{
@@ -1620,13 +1623,23 @@ static int ivtv_try_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder
1620 return ivtv_video_command(itv, id, dec, true); 1623 return ivtv_video_command(itv, id, dec, true);
1621} 1624}
1622 1625
1626#ifdef CONFIG_VIDEO_IVTV_DEPRECATED_IOCTLS
1627static __inline__ void warn_deprecated_ioctl(const char *name)
1628{
1629 pr_warn_once("warning: the %s ioctl is deprecated. Don't use it, as it will be removed soon\n",
1630 name);
1631}
1632#endif
1633
1623static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg) 1634static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
1624{ 1635{
1625 struct ivtv_open_id *id = fh2id(filp->private_data); 1636 struct ivtv_open_id *id = fh2id(filp->private_data);
1626 struct ivtv *itv = id->itv; 1637 struct ivtv *itv = id->itv;
1627 int nonblocking = filp->f_flags & O_NONBLOCK;
1628 struct ivtv_stream *s = &itv->streams[id->type]; 1638 struct ivtv_stream *s = &itv->streams[id->type];
1639#ifdef CONFIG_VIDEO_IVTV_DEPRECATED_IOCTLS
1640 int nonblocking = filp->f_flags & O_NONBLOCK;
1629 unsigned long iarg = (unsigned long)arg; 1641 unsigned long iarg = (unsigned long)arg;
1642#endif
1630 1643
1631 switch (cmd) { 1644 switch (cmd) {
1632 case IVTV_IOC_DMA_FRAME: { 1645 case IVTV_IOC_DMA_FRAME: {
@@ -1658,12 +1671,12 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
1658 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) 1671 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
1659 return -EINVAL; 1672 return -EINVAL;
1660 return ivtv_passthrough_mode(itv, *(int *)arg != 0); 1673 return ivtv_passthrough_mode(itv, *(int *)arg != 0);
1661 1674#ifdef CONFIG_VIDEO_IVTV_DEPRECATED_IOCTLS
1662 case VIDEO_GET_PTS: { 1675 case VIDEO_GET_PTS: {
1663 s64 *pts = arg; 1676 s64 *pts = arg;
1664 s64 frame; 1677 s64 frame;
1665 1678
1666 IVTV_DEBUG_IOCTL("VIDEO_GET_PTS\n"); 1679 warn_deprecated_ioctl("VIDEO_GET_PTS");
1667 if (s->type < IVTV_DEC_STREAM_TYPE_MPG) { 1680 if (s->type < IVTV_DEC_STREAM_TYPE_MPG) {
1668 *pts = s->dma_pts; 1681 *pts = s->dma_pts;
1669 break; 1682 break;
@@ -1677,7 +1690,7 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
1677 s64 *frame = arg; 1690 s64 *frame = arg;
1678 s64 pts; 1691 s64 pts;
1679 1692
1680 IVTV_DEBUG_IOCTL("VIDEO_GET_FRAME_COUNT\n"); 1693 warn_deprecated_ioctl("VIDEO_GET_FRAME_COUNT");
1681 if (s->type < IVTV_DEC_STREAM_TYPE_MPG) { 1694 if (s->type < IVTV_DEC_STREAM_TYPE_MPG) {
1682 *frame = 0; 1695 *frame = 0;
1683 break; 1696 break;
@@ -1690,7 +1703,7 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
1690 case VIDEO_PLAY: { 1703 case VIDEO_PLAY: {
1691 struct v4l2_decoder_cmd dc; 1704 struct v4l2_decoder_cmd dc;
1692 1705
1693 IVTV_DEBUG_IOCTL("VIDEO_PLAY\n"); 1706 warn_deprecated_ioctl("VIDEO_PLAY");
1694 memset(&dc, 0, sizeof(dc)); 1707 memset(&dc, 0, sizeof(dc));
1695 dc.cmd = V4L2_DEC_CMD_START; 1708 dc.cmd = V4L2_DEC_CMD_START;
1696 return ivtv_video_command(itv, id, &dc, 0); 1709 return ivtv_video_command(itv, id, &dc, 0);
@@ -1699,7 +1712,7 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
1699 case VIDEO_STOP: { 1712 case VIDEO_STOP: {
1700 struct v4l2_decoder_cmd dc; 1713 struct v4l2_decoder_cmd dc;
1701 1714
1702 IVTV_DEBUG_IOCTL("VIDEO_STOP\n"); 1715 warn_deprecated_ioctl("VIDEO_STOP");
1703 memset(&dc, 0, sizeof(dc)); 1716 memset(&dc, 0, sizeof(dc));
1704 dc.cmd = V4L2_DEC_CMD_STOP; 1717 dc.cmd = V4L2_DEC_CMD_STOP;
1705 dc.flags = V4L2_DEC_CMD_STOP_TO_BLACK | V4L2_DEC_CMD_STOP_IMMEDIATELY; 1718 dc.flags = V4L2_DEC_CMD_STOP_TO_BLACK | V4L2_DEC_CMD_STOP_IMMEDIATELY;
@@ -1709,7 +1722,7 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
1709 case VIDEO_FREEZE: { 1722 case VIDEO_FREEZE: {
1710 struct v4l2_decoder_cmd dc; 1723 struct v4l2_decoder_cmd dc;
1711 1724
1712 IVTV_DEBUG_IOCTL("VIDEO_FREEZE\n"); 1725 warn_deprecated_ioctl("VIDEO_FREEZE");
1713 memset(&dc, 0, sizeof(dc)); 1726 memset(&dc, 0, sizeof(dc));
1714 dc.cmd = V4L2_DEC_CMD_PAUSE; 1727 dc.cmd = V4L2_DEC_CMD_PAUSE;
1715 return ivtv_video_command(itv, id, &dc, 0); 1728 return ivtv_video_command(itv, id, &dc, 0);
@@ -1718,7 +1731,7 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
1718 case VIDEO_CONTINUE: { 1731 case VIDEO_CONTINUE: {
1719 struct v4l2_decoder_cmd dc; 1732 struct v4l2_decoder_cmd dc;
1720 1733
1721 IVTV_DEBUG_IOCTL("VIDEO_CONTINUE\n"); 1734 warn_deprecated_ioctl("VIDEO_CONTINUE");
1722 memset(&dc, 0, sizeof(dc)); 1735 memset(&dc, 0, sizeof(dc));
1723 dc.cmd = V4L2_DEC_CMD_RESUME; 1736 dc.cmd = V4L2_DEC_CMD_RESUME;
1724 return ivtv_video_command(itv, id, &dc, 0); 1737 return ivtv_video_command(itv, id, &dc, 0);
@@ -1732,9 +1745,9 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
1732 int try = (cmd == VIDEO_TRY_COMMAND); 1745 int try = (cmd == VIDEO_TRY_COMMAND);
1733 1746
1734 if (try) 1747 if (try)
1735 IVTV_DEBUG_IOCTL("VIDEO_TRY_COMMAND %d\n", dc->cmd); 1748 warn_deprecated_ioctl("VIDEO_TRY_COMMAND");
1736 else 1749 else
1737 IVTV_DEBUG_IOCTL("VIDEO_COMMAND %d\n", dc->cmd); 1750 warn_deprecated_ioctl("VIDEO_COMMAND");
1738 return ivtv_video_command(itv, id, dc, try); 1751 return ivtv_video_command(itv, id, dc, try);
1739 } 1752 }
1740 1753
@@ -1742,7 +1755,7 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
1742 struct video_event *ev = arg; 1755 struct video_event *ev = arg;
1743 DEFINE_WAIT(wait); 1756 DEFINE_WAIT(wait);
1744 1757
1745 IVTV_DEBUG_IOCTL("VIDEO_GET_EVENT\n"); 1758 warn_deprecated_ioctl("VIDEO_GET_EVENT");
1746 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) 1759 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
1747 return -EINVAL; 1760 return -EINVAL;
1748 memset(ev, 0, sizeof(*ev)); 1761 memset(ev, 0, sizeof(*ev));
@@ -1785,28 +1798,28 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
1785 } 1798 }
1786 1799
1787 case VIDEO_SELECT_SOURCE: 1800 case VIDEO_SELECT_SOURCE:
1788 IVTV_DEBUG_IOCTL("VIDEO_SELECT_SOURCE\n"); 1801 warn_deprecated_ioctl("VIDEO_SELECT_SOURCE");
1789 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) 1802 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
1790 return -EINVAL; 1803 return -EINVAL;
1791 return ivtv_passthrough_mode(itv, iarg == VIDEO_SOURCE_DEMUX); 1804 return ivtv_passthrough_mode(itv, iarg == VIDEO_SOURCE_DEMUX);
1792 1805
1793 case AUDIO_SET_MUTE: 1806 case AUDIO_SET_MUTE:
1794 IVTV_DEBUG_IOCTL("AUDIO_SET_MUTE\n"); 1807 warn_deprecated_ioctl("AUDIO_SET_MUTE");
1795 itv->speed_mute_audio = iarg; 1808 itv->speed_mute_audio = iarg;
1796 return 0; 1809 return 0;
1797 1810
1798 case AUDIO_CHANNEL_SELECT: 1811 case AUDIO_CHANNEL_SELECT:
1799 IVTV_DEBUG_IOCTL("AUDIO_CHANNEL_SELECT\n"); 1812 warn_deprecated_ioctl("AUDIO_CHANNEL_SELECT");
1800 if (iarg > AUDIO_STEREO_SWAPPED) 1813 if (iarg > AUDIO_STEREO_SWAPPED)
1801 return -EINVAL; 1814 return -EINVAL;
1802 return v4l2_ctrl_s_ctrl(itv->ctrl_audio_playback, iarg + 1); 1815 return v4l2_ctrl_s_ctrl(itv->ctrl_audio_playback, iarg + 1);
1803 1816
1804 case AUDIO_BILINGUAL_CHANNEL_SELECT: 1817 case AUDIO_BILINGUAL_CHANNEL_SELECT:
1805 IVTV_DEBUG_IOCTL("AUDIO_BILINGUAL_CHANNEL_SELECT\n"); 1818 warn_deprecated_ioctl("AUDIO_BILINGUAL_CHANNEL_SELECT");
1806 if (iarg > AUDIO_STEREO_SWAPPED) 1819 if (iarg > AUDIO_STEREO_SWAPPED)
1807 return -EINVAL; 1820 return -EINVAL;
1808 return v4l2_ctrl_s_ctrl(itv->ctrl_audio_multilingual_playback, iarg + 1); 1821 return v4l2_ctrl_s_ctrl(itv->ctrl_audio_multilingual_playback, iarg + 1);
1809 1822#endif
1810 default: 1823 default:
1811 return -EINVAL; 1824 return -EINVAL;
1812 } 1825 }
@@ -1821,6 +1834,7 @@ static long ivtv_default(struct file *file, void *fh, bool valid_prio,
1821 if (!valid_prio) { 1834 if (!valid_prio) {
1822 switch (cmd) { 1835 switch (cmd) {
1823 case IVTV_IOC_PASSTHROUGH_MODE: 1836 case IVTV_IOC_PASSTHROUGH_MODE:
1837#ifdef CONFIG_VIDEO_IVTV_DEPRECATED_IOCTLS
1824 case VIDEO_PLAY: 1838 case VIDEO_PLAY:
1825 case VIDEO_STOP: 1839 case VIDEO_STOP:
1826 case VIDEO_FREEZE: 1840 case VIDEO_FREEZE:
@@ -1830,6 +1844,7 @@ static long ivtv_default(struct file *file, void *fh, bool valid_prio,
1830 case AUDIO_SET_MUTE: 1844 case AUDIO_SET_MUTE:
1831 case AUDIO_CHANNEL_SELECT: 1845 case AUDIO_CHANNEL_SELECT:
1832 case AUDIO_BILINGUAL_CHANNEL_SELECT: 1846 case AUDIO_BILINGUAL_CHANNEL_SELECT:
1847#endif
1833 return -EBUSY; 1848 return -EBUSY;
1834 } 1849 }
1835 } 1850 }
@@ -1847,6 +1862,7 @@ static long ivtv_default(struct file *file, void *fh, bool valid_prio,
1847 1862
1848 case IVTV_IOC_DMA_FRAME: 1863 case IVTV_IOC_DMA_FRAME:
1849 case IVTV_IOC_PASSTHROUGH_MODE: 1864 case IVTV_IOC_PASSTHROUGH_MODE:
1865#ifdef CONFIG_VIDEO_IVTV_DEPRECATED_IOCTLS
1850 case VIDEO_GET_PTS: 1866 case VIDEO_GET_PTS:
1851 case VIDEO_GET_FRAME_COUNT: 1867 case VIDEO_GET_FRAME_COUNT:
1852 case VIDEO_GET_EVENT: 1868 case VIDEO_GET_EVENT:
@@ -1860,6 +1876,7 @@ static long ivtv_default(struct file *file, void *fh, bool valid_prio,
1860 case AUDIO_SET_MUTE: 1876 case AUDIO_SET_MUTE:
1861 case AUDIO_CHANNEL_SELECT: 1877 case AUDIO_CHANNEL_SELECT:
1862 case AUDIO_BILINGUAL_CHANNEL_SELECT: 1878 case AUDIO_BILINGUAL_CHANNEL_SELECT:
1879#endif
1863 return ivtv_decoder_ioctls(file, cmd, (void *)arg); 1880 return ivtv_decoder_ioctls(file, cmd, (void *)arg);
1864 1881
1865 default: 1882 default:
diff --git a/drivers/media/pci/ivtv/ivtv-mailbox.c b/drivers/media/pci/ivtv/ivtv-mailbox.c
index e3ce96763785..9a2506a5edbe 100644
--- a/drivers/media/pci/ivtv/ivtv-mailbox.c
+++ b/drivers/media/pci/ivtv/ivtv-mailbox.c
@@ -19,11 +19,11 @@
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21 21
22#include <stdarg.h>
23
24#include "ivtv-driver.h" 22#include "ivtv-driver.h"
25#include "ivtv-mailbox.h" 23#include "ivtv-mailbox.h"
26 24
25#include <stdarg.h>
26
27/* Firmware mailbox flags*/ 27/* Firmware mailbox flags*/
28#define IVTV_MBOX_FIRMWARE_DONE 0x00000004 28#define IVTV_MBOX_FIRMWARE_DONE 0x00000004
29#define IVTV_MBOX_DRIVER_DONE 0x00000002 29#define IVTV_MBOX_DRIVER_DONE 0x00000002
diff --git a/drivers/media/pci/ivtv/ivtvfb.c b/drivers/media/pci/ivtv/ivtvfb.c
index 612a8402cf4d..621b2f613d81 100644
--- a/drivers/media/pci/ivtv/ivtvfb.c
+++ b/drivers/media/pci/ivtv/ivtvfb.c
@@ -38,25 +38,20 @@
38 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 38 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
39 */ 39 */
40 40
41#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 41#include "ivtv-driver.h"
42#include "ivtv-cards.h"
43#include "ivtv-i2c.h"
44#include "ivtv-udma.h"
45#include "ivtv-mailbox.h"
46#include "ivtv-firmware.h"
42 47
43#include <linux/module.h>
44#include <linux/kernel.h>
45#include <linux/fb.h> 48#include <linux/fb.h>
46#include <linux/ivtvfb.h> 49#include <linux/ivtvfb.h>
47#include <linux/slab.h>
48 50
49#ifdef CONFIG_X86_64 51#ifdef CONFIG_X86_64
50#include <asm/pat.h> 52#include <asm/pat.h>
51#endif 53#endif
52 54
53#include "ivtv-driver.h"
54#include "ivtv-cards.h"
55#include "ivtv-i2c.h"
56#include "ivtv-udma.h"
57#include "ivtv-mailbox.h"
58#include "ivtv-firmware.h"
59
60/* card parameters */ 55/* card parameters */
61static int ivtvfb_card_id = -1; 56static int ivtvfb_card_id = -1;
62static int ivtvfb_debug = 0; 57static int ivtvfb_debug = 0;
@@ -1275,7 +1270,7 @@ static int __init ivtvfb_init(void)
1275 1270
1276 1271
1277 if (ivtvfb_card_id < -1 || ivtvfb_card_id >= IVTV_MAX_CARDS) { 1272 if (ivtvfb_card_id < -1 || ivtvfb_card_id >= IVTV_MAX_CARDS) {
1278 printk(KERN_ERR "ivtvfb: ivtvfb_card_id parameter is out of range (valid range: -1 - %d)\n", 1273 pr_err("ivtvfb_card_id parameter is out of range (valid range: -1 - %d)\n",
1279 IVTV_MAX_CARDS - 1); 1274 IVTV_MAX_CARDS - 1);
1280 return -EINVAL; 1275 return -EINVAL;
1281 } 1276 }
@@ -1284,7 +1279,7 @@ static int __init ivtvfb_init(void)
1284 err = driver_for_each_device(drv, NULL, &registered, ivtvfb_callback_init); 1279 err = driver_for_each_device(drv, NULL, &registered, ivtvfb_callback_init);
1285 (void)err; /* suppress compiler warning */ 1280 (void)err; /* suppress compiler warning */
1286 if (!registered) { 1281 if (!registered) {
1287 printk(KERN_ERR "ivtvfb: no cards found\n"); 1282 pr_err("no cards found\n");
1288 return -ENODEV; 1283 return -ENODEV;
1289 } 1284 }
1290 return 0; 1285 return 0;
@@ -1295,7 +1290,7 @@ static void ivtvfb_cleanup(void)
1295 struct device_driver *drv; 1290 struct device_driver *drv;
1296 int err; 1291 int err;
1297 1292
1298 printk(KERN_INFO "ivtvfb: Unloading framebuffer module\n"); 1293 pr_info("Unloading framebuffer module\n");
1299 1294
1300 drv = driver_find("ivtv", &pci_bus_type); 1295 drv = driver_find("ivtv", &pci_bus_type);
1301 err = driver_for_each_device(drv, NULL, NULL, ivtvfb_callback_cleanup); 1296 err = driver_for_each_device(drv, NULL, NULL, ivtvfb_callback_cleanup);
diff --git a/drivers/media/pci/mantis/mantis_dvb.c b/drivers/media/pci/mantis/mantis_dvb.c
index 5a71e1791cf5..0db4de3a2285 100644
--- a/drivers/media/pci/mantis/mantis_dvb.c
+++ b/drivers/media/pci/mantis/mantis_dvb.c
@@ -226,11 +226,12 @@ int mantis_dvb_init(struct mantis_pci *mantis)
226 goto err5; 226 goto err5;
227 } else { 227 } else {
228 if (mantis->fe == NULL) { 228 if (mantis->fe == NULL) {
229 result = -ENOMEM;
229 dprintk(MANTIS_ERROR, 1, "FE <NULL>"); 230 dprintk(MANTIS_ERROR, 1, "FE <NULL>");
230 goto err5; 231 goto err5;
231 } 232 }
232 233 result = dvb_register_frontend(&mantis->dvb_adapter, mantis->fe);
233 if (dvb_register_frontend(&mantis->dvb_adapter, mantis->fe)) { 234 if (result) {
234 dprintk(MANTIS_ERROR, 1, "ERROR: Frontend registration failed"); 235 dprintk(MANTIS_ERROR, 1, "ERROR: Frontend registration failed");
235 236
236 if (mantis->fe->ops.release) 237 if (mantis->fe->ops.release)
diff --git a/drivers/media/pci/mantis/mantis_input.c b/drivers/media/pci/mantis/mantis_input.c
index 7f7f1d4d7bb1..50d10cb7d49d 100644
--- a/drivers/media/pci/mantis/mantis_input.c
+++ b/drivers/media/pci/mantis/mantis_input.c
@@ -39,7 +39,7 @@ int mantis_input_init(struct mantis_pci *mantis)
39 struct rc_dev *dev; 39 struct rc_dev *dev;
40 int err; 40 int err;
41 41
42 dev = rc_allocate_device(); 42 dev = rc_allocate_device(RC_DRIVER_SCANCODE);
43 if (!dev) { 43 if (!dev) {
44 dprintk(MANTIS_ERROR, 1, "Remote device allocation failed"); 44 dprintk(MANTIS_ERROR, 1, "Remote device allocation failed");
45 err = -ENOMEM; 45 err = -ENOMEM;
diff --git a/drivers/media/pci/meye/meye.c b/drivers/media/pci/meye/meye.c
index 24fba633c217..9c4a024745de 100644
--- a/drivers/media/pci/meye/meye.c
+++ b/drivers/media/pci/meye/meye.c
@@ -21,10 +21,6 @@
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details. 23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 */ 24 */
29#include <linux/module.h> 25#include <linux/module.h>
30#include <linux/pci.h> 26#include <linux/pci.h>
@@ -1663,6 +1659,7 @@ static int meye_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
1663 goto outenabledev; 1659 goto outenabledev;
1664 } 1660 }
1665 1661
1662 ret = -EIO;
1666 mchip_adr = pci_resource_start(meye.mchip_dev,0); 1663 mchip_adr = pci_resource_start(meye.mchip_dev,0);
1667 if (!mchip_adr) { 1664 if (!mchip_adr) {
1668 v4l2_err(v4l2_dev, "meye: mchip has no device base address\n"); 1665 v4l2_err(v4l2_dev, "meye: mchip has no device base address\n");
diff --git a/drivers/media/pci/meye/meye.h b/drivers/media/pci/meye/meye.h
index 751be5e533c7..c4a8a5fe040c 100644
--- a/drivers/media/pci/meye/meye.h
+++ b/drivers/media/pci/meye/meye.h
@@ -21,10 +21,6 @@
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details. 23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 */ 24 */
29 25
30#ifndef _MEYE_PRIV_H_ 26#ifndef _MEYE_PRIV_H_
diff --git a/drivers/media/pci/ngene/ngene-cards.c b/drivers/media/pci/ngene/ngene-cards.c
index 423e8c889310..bb49620540c5 100644
--- a/drivers/media/pci/ngene/ngene-cards.c
+++ b/drivers/media/pci/ngene/ngene-cards.c
@@ -19,12 +19,8 @@
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 * 21 *
22 * 22 * To obtain the license, point your browser to
23 * You should have received a copy of the GNU General Public License 23 * http://www.gnu.org/copyleft/gpl.html
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 * 02110-1301, USA
27 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
28 */ 24 */
29 25
30#include <linux/module.h> 26#include <linux/module.h>
@@ -781,12 +777,6 @@ static pci_ers_result_t ngene_error_detected(struct pci_dev *dev,
781 return PCI_ERS_RESULT_CAN_RECOVER; 777 return PCI_ERS_RESULT_CAN_RECOVER;
782} 778}
783 779
784static pci_ers_result_t ngene_link_reset(struct pci_dev *dev)
785{
786 printk(KERN_INFO DEVICE_NAME ": link reset\n");
787 return 0;
788}
789
790static pci_ers_result_t ngene_slot_reset(struct pci_dev *dev) 780static pci_ers_result_t ngene_slot_reset(struct pci_dev *dev)
791{ 781{
792 printk(KERN_INFO DEVICE_NAME ": slot reset\n"); 782 printk(KERN_INFO DEVICE_NAME ": slot reset\n");
@@ -800,7 +790,6 @@ static void ngene_resume(struct pci_dev *dev)
800 790
801static const struct pci_error_handlers ngene_errors = { 791static const struct pci_error_handlers ngene_errors = {
802 .error_detected = ngene_error_detected, 792 .error_detected = ngene_error_detected,
803 .link_reset = ngene_link_reset,
804 .slot_reset = ngene_slot_reset, 793 .slot_reset = ngene_slot_reset,
805 .resume = ngene_resume, 794 .resume = ngene_resume,
806}; 795};
diff --git a/drivers/media/pci/ngene/ngene-core.c b/drivers/media/pci/ngene/ngene-core.c
index 4e924e2d1638..ce69e648b663 100644
--- a/drivers/media/pci/ngene/ngene-core.c
+++ b/drivers/media/pci/ngene/ngene-core.c
@@ -19,12 +19,8 @@
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 * 21 *
22 * 22 * To obtain the license, point your browser to
23 * You should have received a copy of the GNU General Public License 23 * http://www.gnu.org/copyleft/gpl.html
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 * 02110-1301, USA
27 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
28 */ 24 */
29 25
30#include <linux/module.h> 26#include <linux/module.h>
diff --git a/drivers/media/pci/ngene/ngene-dvb.c b/drivers/media/pci/ngene/ngene-dvb.c
index 59bb2858c8d0..03fc218a45e9 100644
--- a/drivers/media/pci/ngene/ngene-dvb.c
+++ b/drivers/media/pci/ngene/ngene-dvb.c
@@ -19,12 +19,8 @@
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 * 21 *
22 * 22 * To obtain the license, point your browser to
23 * You should have received a copy of the GNU General Public License 23 * http://www.gnu.org/copyleft/gpl.html
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 * 02110-1301, USA
27 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
28 */ 24 */
29 25
30#include <linux/module.h> 26#include <linux/module.h>
diff --git a/drivers/media/pci/ngene/ngene-i2c.c b/drivers/media/pci/ngene/ngene-i2c.c
index d28554f8ce99..cf39fcf54adf 100644
--- a/drivers/media/pci/ngene/ngene-i2c.c
+++ b/drivers/media/pci/ngene/ngene-i2c.c
@@ -19,12 +19,8 @@
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 * 21 *
22 * 22 * To obtain the license, point your browser to
23 * You should have received a copy of the GNU General Public License 23 * http://www.gnu.org/copyleft/gpl.html
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 * 02110-1301, USA
27 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
28 */ 24 */
29 25
30/* FIXME - some of these can probably be removed */ 26/* FIXME - some of these can probably be removed */
diff --git a/drivers/media/pci/ngene/ngene.h b/drivers/media/pci/ngene/ngene.h
index fa30930d7047..10d8f74c4f0a 100644
--- a/drivers/media/pci/ngene/ngene.h
+++ b/drivers/media/pci/ngene/ngene.h
@@ -13,12 +13,8 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * 16 * To obtain the license, point your browser to
17 * You should have received a copy of the GNU General Public License 17 * http://www.gnu.org/copyleft/gpl.html
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA
21 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
22 */ 18 */
23 19
24#ifndef _NGENE_H_ 20#ifndef _NGENE_H_
diff --git a/drivers/media/pci/pluto2/pluto2.c b/drivers/media/pci/pluto2/pluto2.c
index 65afb71ff79f..74838109afe5 100644
--- a/drivers/media/pci/pluto2/pluto2.c
+++ b/drivers/media/pci/pluto2/pluto2.c
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 */ 20 */
25 21
26#include <linux/i2c.h> 22#include <linux/i2c.h>
diff --git a/drivers/media/pci/pt1/pt1.c b/drivers/media/pci/pt1/pt1.c
index d5ee82aee9e8..da1eebd2016f 100644
--- a/drivers/media/pci/pt1/pt1.c
+++ b/drivers/media/pci/pt1/pt1.c
@@ -15,10 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 18 */
23 19
24#include <linux/kernel.h> 20#include <linux/kernel.h>
diff --git a/drivers/media/pci/pt1/va1j5jf8007s.c b/drivers/media/pci/pt1/va1j5jf8007s.c
index 249273b2e0f2..f75f69556be7 100644
--- a/drivers/media/pci/pt1/va1j5jf8007s.c
+++ b/drivers/media/pci/pt1/va1j5jf8007s.c
@@ -15,10 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 18 */
23 19
24#include <linux/kernel.h> 20#include <linux/kernel.h>
diff --git a/drivers/media/pci/pt1/va1j5jf8007s.h b/drivers/media/pci/pt1/va1j5jf8007s.h
index b7d6f05a0e02..efbe6ccae8b4 100644
--- a/drivers/media/pci/pt1/va1j5jf8007s.h
+++ b/drivers/media/pci/pt1/va1j5jf8007s.h
@@ -15,10 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 18 */
23 19
24#ifndef VA1J5JF8007S_H 20#ifndef VA1J5JF8007S_H
diff --git a/drivers/media/pci/pt1/va1j5jf8007t.c b/drivers/media/pci/pt1/va1j5jf8007t.c
index e0766e69a370..63fda79a75c0 100644
--- a/drivers/media/pci/pt1/va1j5jf8007t.c
+++ b/drivers/media/pci/pt1/va1j5jf8007t.c
@@ -15,10 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 18 */
23 19
24#include <linux/kernel.h> 20#include <linux/kernel.h>
diff --git a/drivers/media/pci/pt1/va1j5jf8007t.h b/drivers/media/pci/pt1/va1j5jf8007t.h
index 2903be519ef5..6fb119c6e73a 100644
--- a/drivers/media/pci/pt1/va1j5jf8007t.h
+++ b/drivers/media/pci/pt1/va1j5jf8007t.h
@@ -15,10 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 18 */
23 19
24#ifndef VA1J5JF8007T_H 20#ifndef VA1J5JF8007T_H
diff --git a/drivers/media/pci/saa7134/saa7134-alsa.c b/drivers/media/pci/saa7134/saa7134-alsa.c
index 8a35ecfb75e3..bf358ec7aca5 100644
--- a/drivers/media/pci/saa7134/saa7134-alsa.c
+++ b/drivers/media/pci/saa7134/saa7134-alsa.c
@@ -10,10 +10,6 @@
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 * 12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 */ 13 */
18 14
19#include "saa7134.h" 15#include "saa7134.h"
diff --git a/drivers/media/pci/saa7134/saa7134-cards.c b/drivers/media/pci/saa7134/saa7134-cards.c
index 2b60af493de4..321253827997 100644
--- a/drivers/media/pci/saa7134/saa7134-cards.c
+++ b/drivers/media/pci/saa7134/saa7134-cards.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#include "saa7134.h" 19#include "saa7134.h"
diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c
index 7d6bb5c9343f..7976c5a12ca8 100644
--- a/drivers/media/pci/saa7134/saa7134-core.c
+++ b/drivers/media/pci/saa7134/saa7134-core.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#include "saa7134.h" 19#include "saa7134.h"
diff --git a/drivers/media/pci/saa7134/saa7134-dvb.c b/drivers/media/pci/saa7134/saa7134-dvb.c
index 598b8bbfe726..efdece5ab11c 100644
--- a/drivers/media/pci/saa7134/saa7134-dvb.c
+++ b/drivers/media/pci/saa7134/saa7134-dvb.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#include "saa7134.h" 19#include "saa7134.h"
diff --git a/drivers/media/pci/saa7134/saa7134-empress.c b/drivers/media/pci/saa7134/saa7134-empress.c
index f0fe2524259f..b1d3648dcba1 100644
--- a/drivers/media/pci/saa7134/saa7134-empress.c
+++ b/drivers/media/pci/saa7134/saa7134-empress.c
@@ -11,10 +11,6 @@
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 14 */
19 15
20#include "saa7134.h" 16#include "saa7134.h"
diff --git a/drivers/media/pci/saa7134/saa7134-i2c.c b/drivers/media/pci/saa7134/saa7134-i2c.c
index dca0592c5f47..9d0e69eae036 100644
--- a/drivers/media/pci/saa7134/saa7134-i2c.c
+++ b/drivers/media/pci/saa7134/saa7134-i2c.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#include "saa7134.h" 19#include "saa7134.h"
diff --git a/drivers/media/pci/saa7134/saa7134-input.c b/drivers/media/pci/saa7134/saa7134-input.c
index 823b75ed47e1..78849c19f68a 100644
--- a/drivers/media/pci/saa7134/saa7134-input.c
+++ b/drivers/media/pci/saa7134/saa7134-input.c
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20 16
21#include "saa7134.h" 17#include "saa7134.h"
@@ -846,7 +842,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
846 } 842 }
847 843
848 ir = kzalloc(sizeof(*ir), GFP_KERNEL); 844 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
849 rc = rc_allocate_device(); 845 rc = rc_allocate_device(RC_DRIVER_SCANCODE);
850 if (!ir || !rc) { 846 if (!ir || !rc) {
851 err = -ENOMEM; 847 err = -ENOMEM;
852 goto err_out_free; 848 goto err_out_free;
diff --git a/drivers/media/pci/saa7134/saa7134-ts.c b/drivers/media/pci/saa7134/saa7134-ts.c
index 7eaf36a41db9..578e03f8c041 100644
--- a/drivers/media/pci/saa7134/saa7134-ts.c
+++ b/drivers/media/pci/saa7134/saa7134-ts.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#include "saa7134.h" 19#include "saa7134.h"
diff --git a/drivers/media/pci/saa7134/saa7134-tvaudio.c b/drivers/media/pci/saa7134/saa7134-tvaudio.c
index 38f94b742e28..68d400e1e240 100644
--- a/drivers/media/pci/saa7134/saa7134-tvaudio.c
+++ b/drivers/media/pci/saa7134/saa7134-tvaudio.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#include "saa7134.h" 19#include "saa7134.h"
diff --git a/drivers/media/pci/saa7134/saa7134-vbi.c b/drivers/media/pci/saa7134/saa7134-vbi.c
index cf9a31e0a390..46193370e41a 100644
--- a/drivers/media/pci/saa7134/saa7134-vbi.c
+++ b/drivers/media/pci/saa7134/saa7134-vbi.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#include "saa7134.h" 19#include "saa7134.h"
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c
index cbb173d99085..4b1c4327f112 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#include "saa7134.h" 19#include "saa7134.h"
diff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h
index 3849083526a7..816b5282d671 100644
--- a/drivers/media/pci/saa7134/saa7134.h
+++ b/drivers/media/pci/saa7134/saa7134.h
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#define SAA7134_VERSION "0, 2, 17" 18#define SAA7134_VERSION "0, 2, 17"
diff --git a/drivers/media/pci/saa7164/saa7164-api.c b/drivers/media/pci/saa7164/saa7164-api.c
index e7e586c1ba53..e318ccf81277 100644
--- a/drivers/media/pci/saa7164/saa7164-api.c
+++ b/drivers/media/pci/saa7164/saa7164-api.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include <linux/wait.h> 18#include <linux/wait.h>
diff --git a/drivers/media/pci/saa7164/saa7164-buffer.c b/drivers/media/pci/saa7164/saa7164-buffer.c
index 62c34504199d..a0d2129c6ca9 100644
--- a/drivers/media/pci/saa7164/saa7164-buffer.c
+++ b/drivers/media/pci/saa7164/saa7164-buffer.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include <linux/slab.h> 18#include <linux/slab.h>
diff --git a/drivers/media/pci/saa7164/saa7164-bus.c b/drivers/media/pci/saa7164/saa7164-bus.c
index e305c02f9dc9..b2ff82fa7116 100644
--- a/drivers/media/pci/saa7164/saa7164-bus.c
+++ b/drivers/media/pci/saa7164/saa7164-bus.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include "saa7164.h" 18#include "saa7164.h"
diff --git a/drivers/media/pci/saa7164/saa7164-cards.c b/drivers/media/pci/saa7164/saa7164-cards.c
index 15a98c638c55..0e1cd7e153ca 100644
--- a/drivers/media/pci/saa7164/saa7164-cards.c
+++ b/drivers/media/pci/saa7164/saa7164-cards.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include <linux/init.h> 18#include <linux/init.h>
diff --git a/drivers/media/pci/saa7164/saa7164-cmd.c b/drivers/media/pci/saa7164/saa7164-cmd.c
index 45951b3cc251..f55c177fd1e4 100644
--- a/drivers/media/pci/saa7164/saa7164-cmd.c
+++ b/drivers/media/pci/saa7164/saa7164-cmd.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include <linux/wait.h> 18#include <linux/wait.h>
diff --git a/drivers/media/pci/saa7164/saa7164-core.c b/drivers/media/pci/saa7164/saa7164-core.c
index 03a1511a92be..75eed4cc4823 100644
--- a/drivers/media/pci/saa7164/saa7164-core.c
+++ b/drivers/media/pci/saa7164/saa7164-core.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include <linux/init.h> 18#include <linux/init.h>
diff --git a/drivers/media/pci/saa7164/saa7164-dvb.c b/drivers/media/pci/saa7164/saa7164-dvb.c
index cd3eeda5250b..e76d3bafe2ce 100644
--- a/drivers/media/pci/saa7164/saa7164-dvb.c
+++ b/drivers/media/pci/saa7164/saa7164-dvb.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include "saa7164.h" 18#include "saa7164.h"
diff --git a/drivers/media/pci/saa7164/saa7164-encoder.c b/drivers/media/pci/saa7164/saa7164-encoder.c
index 68124ce7ebc3..f21c245a54f7 100644
--- a/drivers/media/pci/saa7164/saa7164-encoder.c
+++ b/drivers/media/pci/saa7164/saa7164-encoder.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include "saa7164.h" 18#include "saa7164.h"
diff --git a/drivers/media/pci/saa7164/saa7164-fw.c b/drivers/media/pci/saa7164/saa7164-fw.c
index 8568adfd7ece..4ba5eade7ce2 100644
--- a/drivers/media/pci/saa7164/saa7164-fw.c
+++ b/drivers/media/pci/saa7164/saa7164-fw.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include <linux/firmware.h> 18#include <linux/firmware.h>
@@ -309,7 +305,7 @@ int saa7164_downloadfirmware(struct saa7164_dev *dev)
309 break; 305 break;
310 } 306 }
311 if (err_flags & SAA_DEVICE_NO_IMAGE) { 307 if (err_flags & SAA_DEVICE_NO_IMAGE) {
312 printk(KERN_ERR "%s() no first image\n", 308 printk(KERN_ERR "%s() no second image\n",
313 __func__); 309 __func__);
314 break; 310 break;
315 } 311 }
diff --git a/drivers/media/pci/saa7164/saa7164-i2c.c b/drivers/media/pci/saa7164/saa7164-i2c.c
index 024f4e29e840..430f6789f222 100644
--- a/drivers/media/pci/saa7164/saa7164-i2c.c
+++ b/drivers/media/pci/saa7164/saa7164-i2c.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include <linux/module.h> 18#include <linux/module.h>
diff --git a/drivers/media/pci/saa7164/saa7164-reg.h b/drivers/media/pci/saa7164/saa7164-reg.h
index 37521a2ee504..5cf842112e43 100644
--- a/drivers/media/pci/saa7164/saa7164-reg.h
+++ b/drivers/media/pci/saa7164/saa7164-reg.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22/* TODO: Retest the driver with errors expressed as negatives */ 18/* TODO: Retest the driver with errors expressed as negatives */
diff --git a/drivers/media/pci/saa7164/saa7164-types.h b/drivers/media/pci/saa7164/saa7164-types.h
index 1efba6c64ebf..ae241103b261 100644
--- a/drivers/media/pci/saa7164/saa7164-types.h
+++ b/drivers/media/pci/saa7164/saa7164-types.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22/* TODO: Cleanup and shorten the namespace */ 18/* TODO: Cleanup and shorten the namespace */
diff --git a/drivers/media/pci/saa7164/saa7164-vbi.c b/drivers/media/pci/saa7164/saa7164-vbi.c
index e5dcb81029d3..9255d7d23947 100644
--- a/drivers/media/pci/saa7164/saa7164-vbi.c
+++ b/drivers/media/pci/saa7164/saa7164-vbi.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include "saa7164.h" 18#include "saa7164.h"
diff --git a/drivers/media/pci/saa7164/saa7164.h b/drivers/media/pci/saa7164/saa7164.h
index 97411b0384c1..81b3f0e19993 100644
--- a/drivers/media/pci/saa7164/saa7164.h
+++ b/drivers/media/pci/saa7164/saa7164.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22/* 18/*
diff --git a/drivers/media/pci/smipcie/smipcie-ir.c b/drivers/media/pci/smipcie/smipcie-ir.c
index 826c7c75e64d..d2730c3fdbae 100644
--- a/drivers/media/pci/smipcie/smipcie-ir.c
+++ b/drivers/media/pci/smipcie/smipcie-ir.c
@@ -183,7 +183,7 @@ int smi_ir_init(struct smi_dev *dev)
183 struct rc_dev *rc_dev; 183 struct rc_dev *rc_dev;
184 struct smi_rc *ir = &dev->ir; 184 struct smi_rc *ir = &dev->ir;
185 185
186 rc_dev = rc_allocate_device(); 186 rc_dev = rc_allocate_device(RC_DRIVER_SCANCODE);
187 if (!rc_dev) 187 if (!rc_dev)
188 return -ENOMEM; 188 return -ENOMEM;
189 189
@@ -202,7 +202,6 @@ int smi_ir_init(struct smi_dev *dev)
202 rc_dev->input_id.product = dev->pci_dev->subsystem_device; 202 rc_dev->input_id.product = dev->pci_dev->subsystem_device;
203 rc_dev->dev.parent = &dev->pci_dev->dev; 203 rc_dev->dev.parent = &dev->pci_dev->dev;
204 204
205 rc_dev->driver_type = RC_DRIVER_SCANCODE;
206 rc_dev->map_name = dev->info->rc_map; 205 rc_dev->map_name = dev->info->rc_map;
207 206
208 ir->rc_dev = rc_dev; 207 ir->rc_dev = rc_dev;
diff --git a/drivers/media/pci/solo6x10/solo6x10-g723.c b/drivers/media/pci/solo6x10/solo6x10-g723.c
index 6a35107aca25..36e93540bb49 100644
--- a/drivers/media/pci/solo6x10/solo6x10-g723.c
+++ b/drivers/media/pci/solo6x10/solo6x10-g723.c
@@ -350,7 +350,7 @@ static int solo_snd_pcm_init(struct solo_dev *solo_dev)
350 350
351int solo_g723_init(struct solo_dev *solo_dev) 351int solo_g723_init(struct solo_dev *solo_dev)
352{ 352{
353 static struct snd_device_ops ops = { NULL }; 353 static struct snd_device_ops ops = { };
354 struct snd_card *card; 354 struct snd_card *card;
355 struct snd_kcontrol_new kctl; 355 struct snd_kcontrol_new kctl;
356 char name[32]; 356 char name[32];
diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c b/drivers/media/pci/sta2x11/sta2x11_vip.c
index aeb2b4e2db35..6343d24eb1d5 100644
--- a/drivers/media/pci/sta2x11/sta2x11_vip.c
+++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
@@ -377,7 +377,7 @@ static void stop_streaming(struct vb2_queue *vq)
377 spin_unlock(&vip->lock); 377 spin_unlock(&vip->lock);
378} 378}
379 379
380static struct vb2_ops vip_video_qops = { 380static const struct vb2_ops vip_video_qops = {
381 .queue_setup = queue_setup, 381 .queue_setup = queue_setup,
382 .buf_init = buffer_init, 382 .buf_init = buffer_init,
383 .buf_prepare = buffer_prepare, 383 .buf_prepare = buffer_prepare,
diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.h b/drivers/media/pci/sta2x11/sta2x11_vip.h
index 4f81a13666eb..61e5c4822b52 100644
--- a/drivers/media/pci/sta2x11/sta2x11_vip.h
+++ b/drivers/media/pci/sta2x11/sta2x11_vip.h
@@ -10,10 +10,6 @@
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 * See the GNU General Public License for more details. 11 * See the GNU General Public License for more details.
12 * 12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Anders Wallin <anders.wallin@windriver.com> 13 * Author: Anders Wallin <anders.wallin@windriver.com>
18 * 14 *
19 */ 15 */
diff --git a/drivers/media/pci/ttpci/av7110.c b/drivers/media/pci/ttpci/av7110.c
index 6e63949d6ad0..df9395c87178 100644
--- a/drivers/media/pci/ttpci/av7110.c
+++ b/drivers/media/pci/ttpci/av7110.c
@@ -19,11 +19,8 @@
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 * 21 *
22 * 22 * To obtain the license, point your browser to
23 * You should have received a copy of the GNU General Public License 23 * http://www.gnu.org/copyleft/gpl.html
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
27 * 24 *
28 * 25 *
29 * the project's page is at https://linuxtv.org 26 * the project's page is at https://linuxtv.org
diff --git a/drivers/media/pci/ttpci/av7110_av.c b/drivers/media/pci/ttpci/av7110_av.c
index 26c5696c193b..2aa4ba675194 100644
--- a/drivers/media/pci/ttpci/av7110_av.c
+++ b/drivers/media/pci/ttpci/av7110_av.c
@@ -18,11 +18,8 @@
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 * 20 *
21 * 21 * To obtain the license, point your browser to
22 * You should have received a copy of the GNU General Public License 22 * http://www.gnu.org/copyleft/gpl.html
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
26 * 23 *
27 * 24 *
28 * the project's page is at https://linuxtv.org 25 * the project's page is at https://linuxtv.org
diff --git a/drivers/media/pci/ttpci/av7110_ca.c b/drivers/media/pci/ttpci/av7110_ca.c
index 96a130fb4595..f64723aea56b 100644
--- a/drivers/media/pci/ttpci/av7110_ca.c
+++ b/drivers/media/pci/ttpci/av7110_ca.c
@@ -18,11 +18,8 @@
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 * 20 *
21 * 21 * To obtain the license, point your browser to
22 * You should have received a copy of the GNU General Public License 22 * http://www.gnu.org/copyleft/gpl.html
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
26 * 23 *
27 * 24 *
28 * the project's page is at https://linuxtv.org 25 * the project's page is at https://linuxtv.org
diff --git a/drivers/media/pci/ttpci/av7110_hw.c b/drivers/media/pci/ttpci/av7110_hw.c
index 520414cbe087..b2b79bb73917 100644
--- a/drivers/media/pci/ttpci/av7110_hw.c
+++ b/drivers/media/pci/ttpci/av7110_hw.c
@@ -16,11 +16,8 @@
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 * To obtain the license, point your browser to
20 * You should have received a copy of the GNU General Public License 20 * http://www.gnu.org/copyleft/gpl.html
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
24 * 21 *
25 * the project's page is at https://linuxtv.org 22 * the project's page is at https://linuxtv.org
26 */ 23 */
@@ -56,11 +53,11 @@
56 by Nathan Laredo <laredo@gnu.org> */ 53 by Nathan Laredo <laredo@gnu.org> */
57 54
58int av7110_debiwrite(struct av7110 *av7110, u32 config, 55int av7110_debiwrite(struct av7110 *av7110, u32 config,
59 int addr, u32 val, int count) 56 int addr, u32 val, unsigned int count)
60{ 57{
61 struct saa7146_dev *dev = av7110->dev; 58 struct saa7146_dev *dev = av7110->dev;
62 59
63 if (count <= 0 || count > 32764) { 60 if (count > 32764) {
64 printk("%s: invalid count %d\n", __func__, count); 61 printk("%s: invalid count %d\n", __func__, count);
65 return -1; 62 return -1;
66 } 63 }
@@ -78,12 +75,12 @@ int av7110_debiwrite(struct av7110 *av7110, u32 config,
78 return 0; 75 return 0;
79} 76}
80 77
81u32 av7110_debiread(struct av7110 *av7110, u32 config, int addr, int count) 78u32 av7110_debiread(struct av7110 *av7110, u32 config, int addr, unsigned int count)
82{ 79{
83 struct saa7146_dev *dev = av7110->dev; 80 struct saa7146_dev *dev = av7110->dev;
84 u32 result = 0; 81 u32 result = 0;
85 82
86 if (count > 32764 || count <= 0) { 83 if (count > 32764) {
87 printk("%s: invalid count %d\n", __func__, count); 84 printk("%s: invalid count %d\n", __func__, count);
88 return 0; 85 return 0;
89 } 86 }
diff --git a/drivers/media/pci/ttpci/av7110_hw.h b/drivers/media/pci/ttpci/av7110_hw.h
index 1634aba5cb84..ccb148059406 100644
--- a/drivers/media/pci/ttpci/av7110_hw.h
+++ b/drivers/media/pci/ttpci/av7110_hw.h
@@ -377,14 +377,14 @@ extern int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
377 377
378/* DEBI (saa7146 data extension bus interface) access */ 378/* DEBI (saa7146 data extension bus interface) access */
379extern int av7110_debiwrite(struct av7110 *av7110, u32 config, 379extern int av7110_debiwrite(struct av7110 *av7110, u32 config,
380 int addr, u32 val, int count); 380 int addr, u32 val, unsigned int count);
381extern u32 av7110_debiread(struct av7110 *av7110, u32 config, 381extern u32 av7110_debiread(struct av7110 *av7110, u32 config,
382 int addr, int count); 382 int addr, unsigned int count);
383 383
384 384
385/* DEBI during interrupt */ 385/* DEBI during interrupt */
386/* single word writes */ 386/* single word writes */
387static inline void iwdebi(struct av7110 *av7110, u32 config, int addr, u32 val, int count) 387static inline void iwdebi(struct av7110 *av7110, u32 config, int addr, u32 val, unsigned int count)
388{ 388{
389 av7110_debiwrite(av7110, config, addr, val, count); 389 av7110_debiwrite(av7110, config, addr, val, count);
390} 390}
@@ -397,7 +397,7 @@ static inline void mwdebi(struct av7110 *av7110, u32 config, int addr,
397 av7110_debiwrite(av7110, config, addr, 0, count); 397 av7110_debiwrite(av7110, config, addr, 0, count);
398} 398}
399 399
400static inline u32 irdebi(struct av7110 *av7110, u32 config, int addr, u32 val, int count) 400static inline u32 irdebi(struct av7110 *av7110, u32 config, int addr, u32 val, unsigned int count)
401{ 401{
402 u32 res; 402 u32 res;
403 403
@@ -408,7 +408,7 @@ static inline u32 irdebi(struct av7110 *av7110, u32 config, int addr, u32 val, i
408} 408}
409 409
410/* DEBI outside interrupts, only for count <= 4! */ 410/* DEBI outside interrupts, only for count <= 4! */
411static inline void wdebi(struct av7110 *av7110, u32 config, int addr, u32 val, int count) 411static inline void wdebi(struct av7110 *av7110, u32 config, int addr, u32 val, unsigned int count)
412{ 412{
413 unsigned long flags; 413 unsigned long flags;
414 414
@@ -417,7 +417,7 @@ static inline void wdebi(struct av7110 *av7110, u32 config, int addr, u32 val, i
417 spin_unlock_irqrestore(&av7110->debilock, flags); 417 spin_unlock_irqrestore(&av7110->debilock, flags);
418} 418}
419 419
420static inline u32 rdebi(struct av7110 *av7110, u32 config, int addr, u32 val, int count) 420static inline u32 rdebi(struct av7110 *av7110, u32 config, int addr, u32 val, unsigned int count)
421{ 421{
422 unsigned long flags; 422 unsigned long flags;
423 u32 res; 423 u32 res;
diff --git a/drivers/media/pci/ttpci/av7110_ir.c b/drivers/media/pci/ttpci/av7110_ir.c
index 0e763a784e2b..10e28f067b45 100644
--- a/drivers/media/pci/ttpci/av7110_ir.c
+++ b/drivers/media/pci/ttpci/av7110_ir.c
@@ -13,11 +13,8 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 * To obtain the license, point your browser to
17 * You should have received a copy of the GNU General Public License 17 * http://www.gnu.org/copyleft/gpl.html
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
21 * 18 *
22 */ 19 */
23 20
diff --git a/drivers/media/pci/ttpci/av7110_v4l.c b/drivers/media/pci/ttpci/av7110_v4l.c
index 479aff02db81..397fe146dedd 100644
--- a/drivers/media/pci/ttpci/av7110_v4l.c
+++ b/drivers/media/pci/ttpci/av7110_v4l.c
@@ -16,11 +16,8 @@
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 * To obtain the license, point your browser to
20 * You should have received a copy of the GNU General Public License 20 * http://www.gnu.org/copyleft/gpl.html
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
24 * 21 *
25 * the project's page is at https://linuxtv.org 22 * the project's page is at https://linuxtv.org
26 */ 23 */
diff --git a/drivers/media/pci/ttpci/budget-av.c b/drivers/media/pci/ttpci/budget-av.c
index 896c66d4b3ae..19f07d4aba6a 100644
--- a/drivers/media/pci/ttpci/budget-av.c
+++ b/drivers/media/pci/ttpci/budget-av.c
@@ -23,11 +23,8 @@
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details. 24 * GNU General Public License for more details.
25 * 25 *
26 * 26 * To obtain the license, point your browser to
27 * You should have received a copy of the GNU General Public License 27 * http://www.gnu.org/copyleft/gpl.html
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
31 * 28 *
32 * 29 *
33 * the project's page is at https://linuxtv.org 30 * the project's page is at https://linuxtv.org
diff --git a/drivers/media/pci/ttpci/budget-ci.c b/drivers/media/pci/ttpci/budget-ci.c
index 20ad93bf0f54..68355484ba7d 100644
--- a/drivers/media/pci/ttpci/budget-ci.c
+++ b/drivers/media/pci/ttpci/budget-ci.c
@@ -19,11 +19,8 @@
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 * 21 *
22 * 22 * To obtain the license, point your browser to
23 * You should have received a copy of the GNU General Public License 23 * http://www.gnu.org/copyleft/gpl.html
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
27 * 24 *
28 * 25 *
29 * the project's page is at https://linuxtv.org 26 * the project's page is at https://linuxtv.org
@@ -177,7 +174,7 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
177 struct rc_dev *dev; 174 struct rc_dev *dev;
178 int error; 175 int error;
179 176
180 dev = rc_allocate_device(); 177 dev = rc_allocate_device(RC_DRIVER_SCANCODE);
181 if (!dev) { 178 if (!dev) {
182 printk(KERN_ERR "budget_ci: IR interface initialisation failed\n"); 179 printk(KERN_ERR "budget_ci: IR interface initialisation failed\n");
183 return -ENOMEM; 180 return -ENOMEM;
diff --git a/drivers/media/pci/ttpci/budget-core.c b/drivers/media/pci/ttpci/budget-core.c
index 6d42dcfd4825..97499b2af714 100644
--- a/drivers/media/pci/ttpci/budget-core.c
+++ b/drivers/media/pci/ttpci/budget-core.c
@@ -24,11 +24,8 @@
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details. 25 * GNU General Public License for more details.
26 * 26 *
27 * 27 * To obtain the license, point your browser to
28 * You should have received a copy of the GNU General Public License 28 * http://www.gnu.org/copyleft/gpl.html
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
32 * 29 *
33 * 30 *
34 * the project's page is at https://linuxtv.org 31 * the project's page is at https://linuxtv.org
diff --git a/drivers/media/pci/ttpci/budget-patch.c b/drivers/media/pci/ttpci/budget-patch.c
index f152eda0123a..442992372008 100644
--- a/drivers/media/pci/ttpci/budget-patch.c
+++ b/drivers/media/pci/ttpci/budget-patch.c
@@ -20,11 +20,8 @@
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 21 * GNU General Public License for more details.
22 * 22 *
23 * 23 * To obtain the license, point your browser to
24 * You should have received a copy of the GNU General Public License 24 * http://www.gnu.org/copyleft/gpl.html
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
28 * 25 *
29 * 26 *
30 * the project's page is at https://linuxtv.org 27 * the project's page is at https://linuxtv.org
diff --git a/drivers/media/pci/ttpci/budget.c b/drivers/media/pci/ttpci/budget.c
index 3091b480ce22..5f17e1c9a207 100644
--- a/drivers/media/pci/ttpci/budget.c
+++ b/drivers/media/pci/ttpci/budget.c
@@ -24,11 +24,8 @@
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details. 25 * GNU General Public License for more details.
26 * 26 *
27 * 27 * To obtain the license, point your browser to
28 * You should have received a copy of the GNU General Public License 28 * http://www.gnu.org/copyleft/gpl.html
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
32 * 29 *
33 * 30 *
34 * the project's page is at https://linuxtv.org 31 * the project's page is at https://linuxtv.org
diff --git a/drivers/media/pci/ttpci/dvb_filter.h b/drivers/media/pci/ttpci/dvb_filter.h
index 375e3be184b1..3d410d02a987 100644
--- a/drivers/media/pci/ttpci/dvb_filter.h
+++ b/drivers/media/pci/ttpci/dvb_filter.h
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */ 15 */
20 16
21#ifndef _DVB_FILTER_H_ 17#ifndef _DVB_FILTER_H_
diff --git a/drivers/media/pci/tw686x/tw686x-core.c b/drivers/media/pci/tw686x/tw686x-core.c
index 71a0453b1af1..336e2f9bc1b6 100644
--- a/drivers/media/pci/tw686x/tw686x-core.c
+++ b/drivers/media/pci/tw686x/tw686x-core.c
@@ -74,7 +74,7 @@ static const char *dma_mode_name(unsigned int mode)
74 74
75static int tw686x_dma_mode_get(char *buffer, struct kernel_param *kp) 75static int tw686x_dma_mode_get(char *buffer, struct kernel_param *kp)
76{ 76{
77 return sprintf(buffer, dma_mode_name(dma_mode)); 77 return sprintf(buffer, "%s", dma_mode_name(dma_mode));
78} 78}
79 79
80static int tw686x_dma_mode_set(const char *val, struct kernel_param *kp) 80static int tw686x_dma_mode_set(const char *val, struct kernel_param *kp)
diff --git a/drivers/media/pci/zoran/videocodec.c b/drivers/media/pci/zoran/videocodec.c
index 3c3cbce0f9cc..303289a7fd3f 100644
--- a/drivers/media/pci/zoran/videocodec.c
+++ b/drivers/media/pci/zoran/videocodec.c
@@ -20,10 +20,6 @@
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 21 * GNU General Public License for more details.
22 * 22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 * ------------------------------------------------------------------------ 23 * ------------------------------------------------------------------------
28 */ 24 */
29 25
diff --git a/drivers/media/pci/zoran/videocodec.h b/drivers/media/pci/zoran/videocodec.h
index def55585ad23..8ed5a0f7ac01 100644
--- a/drivers/media/pci/zoran/videocodec.h
+++ b/drivers/media/pci/zoran/videocodec.h
@@ -20,10 +20,6 @@
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 21 * GNU General Public License for more details.
22 * 22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 * ------------------------------------------------------------------------ 23 * ------------------------------------------------------------------------
28 */ 24 */
29 25
diff --git a/drivers/media/pci/zoran/zoran.h b/drivers/media/pci/zoran/zoran.h
index 4e7db8939c2b..9bb3c21aa275 100644
--- a/drivers/media/pci/zoran/zoran.h
+++ b/drivers/media/pci/zoran/zoran.h
@@ -22,10 +22,6 @@
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details. 24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 */ 25 */
30 26
31#ifndef _BUZ_H_ 27#ifndef _BUZ_H_
diff --git a/drivers/media/pci/zoran/zoran_card.c b/drivers/media/pci/zoran/zoran_card.c
index 9d2697f5b455..5266755add63 100644
--- a/drivers/media/pci/zoran/zoran_card.c
+++ b/drivers/media/pci/zoran/zoran_card.c
@@ -21,10 +21,6 @@
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details. 23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 */ 24 */
29 25
30#include <linux/delay.h> 26#include <linux/delay.h>
diff --git a/drivers/media/pci/zoran/zoran_card.h b/drivers/media/pci/zoran/zoran_card.h
index 4936fead73e8..81cba177cd90 100644
--- a/drivers/media/pci/zoran/zoran_card.h
+++ b/drivers/media/pci/zoran/zoran_card.h
@@ -21,10 +21,6 @@
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details. 23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 */ 24 */
29 25
30#ifndef __ZORAN_CARD_H__ 26#ifndef __ZORAN_CARD_H__
diff --git a/drivers/media/pci/zoran/zoran_device.c b/drivers/media/pci/zoran/zoran_device.c
index 35b552c178da..671907a6e6b6 100644
--- a/drivers/media/pci/zoran/zoran_device.c
+++ b/drivers/media/pci/zoran/zoran_device.c
@@ -21,10 +21,6 @@
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details. 23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 */ 24 */
29 25
30#include <linux/types.h> 26#include <linux/types.h>
diff --git a/drivers/media/pci/zoran/zoran_device.h b/drivers/media/pci/zoran/zoran_device.h
index 07f2c23ff740..a507aaad4ebb 100644
--- a/drivers/media/pci/zoran/zoran_device.h
+++ b/drivers/media/pci/zoran/zoran_device.h
@@ -21,10 +21,6 @@
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details. 23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 */ 24 */
29 25
30#ifndef __ZORAN_DEVICE_H__ 26#ifndef __ZORAN_DEVICE_H__
diff --git a/drivers/media/pci/zoran/zoran_driver.c b/drivers/media/pci/zoran/zoran_driver.c
index 94b9b616df98..180f3d7af3e1 100644
--- a/drivers/media/pci/zoran/zoran_driver.c
+++ b/drivers/media/pci/zoran/zoran_driver.c
@@ -38,10 +38,6 @@
38 * but WITHOUT ANY WARRANTY; without even the implied warranty of 38 * but WITHOUT ANY WARRANTY; without even the implied warranty of
39 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 39 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40 * GNU General Public License for more details. 40 * GNU General Public License for more details.
41 *
42 * You should have received a copy of the GNU General Public License
43 * along with this program; if not, write to the Free Software
44 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
45 */ 41 */
46 42
47#include <linux/init.h> 43#include <linux/init.h>
@@ -975,6 +971,7 @@ static int zoran_open(struct file *file)
975 return 0; 971 return 0;
976 972
977fail_fh: 973fail_fh:
974 v4l2_fh_exit(&fh->fh);
978 kfree(fh); 975 kfree(fh);
979fail_unlock: 976fail_unlock:
980 mutex_unlock(&zr->lock); 977 mutex_unlock(&zr->lock);
diff --git a/drivers/media/pci/zoran/zoran_procfs.c b/drivers/media/pci/zoran/zoran_procfs.c
index 437652761093..78ac8f853748 100644
--- a/drivers/media/pci/zoran/zoran_procfs.c
+++ b/drivers/media/pci/zoran/zoran_procfs.c
@@ -21,10 +21,6 @@
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details. 23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 */ 24 */
29 25
30#include <linux/types.h> 26#include <linux/types.h>
diff --git a/drivers/media/pci/zoran/zoran_procfs.h b/drivers/media/pci/zoran/zoran_procfs.h
index f2d5b1ba448f..0ac7cb0011f2 100644
--- a/drivers/media/pci/zoran/zoran_procfs.h
+++ b/drivers/media/pci/zoran/zoran_procfs.h
@@ -21,10 +21,6 @@
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details. 23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 */ 24 */
29 25
30#ifndef __ZORAN_PROCFS_H__ 26#ifndef __ZORAN_PROCFS_H__
diff --git a/drivers/media/pci/zoran/zr36016.c b/drivers/media/pci/zoran/zr36016.c
index c12ca9f96bac..8736b9d8d97e 100644
--- a/drivers/media/pci/zoran/zr36016.c
+++ b/drivers/media/pci/zoran/zr36016.c
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 * ------------------------------------------------------------------------ 20 * ------------------------------------------------------------------------
25 */ 21 */
26 22
diff --git a/drivers/media/pci/zoran/zr36016.h b/drivers/media/pci/zoran/zr36016.h
index 8c79229f69d1..784bcf5727b8 100644
--- a/drivers/media/pci/zoran/zr36016.h
+++ b/drivers/media/pci/zoran/zr36016.h
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 * ------------------------------------------------------------------------ 20 * ------------------------------------------------------------------------
25 */ 21 */
26 22
diff --git a/drivers/media/pci/zoran/zr36050.c b/drivers/media/pci/zoran/zr36050.c
index e1985609af4b..5ebfc16672f3 100644
--- a/drivers/media/pci/zoran/zr36050.c
+++ b/drivers/media/pci/zoran/zr36050.c
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 * ------------------------------------------------------------------------ 20 * ------------------------------------------------------------------------
25 */ 21 */
26 22
diff --git a/drivers/media/pci/zoran/zr36050.h b/drivers/media/pci/zoran/zr36050.h
index ea083adda045..9236486d3c2b 100644
--- a/drivers/media/pci/zoran/zr36050.h
+++ b/drivers/media/pci/zoran/zr36050.h
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 * ------------------------------------------------------------------------ 20 * ------------------------------------------------------------------------
25 */ 21 */
26 22
diff --git a/drivers/media/pci/zoran/zr36057.h b/drivers/media/pci/zoran/zr36057.h
index 54c9362aa980..c9ffef15532d 100644
--- a/drivers/media/pci/zoran/zr36057.h
+++ b/drivers/media/pci/zoran/zr36057.h
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#ifndef _ZR36057_H_ 17#ifndef _ZR36057_H_
diff --git a/drivers/media/pci/zoran/zr36060.c b/drivers/media/pci/zoran/zr36060.c
index f08546fe2234..2c2e8130fc96 100644
--- a/drivers/media/pci/zoran/zr36060.c
+++ b/drivers/media/pci/zoran/zr36060.c
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 * ------------------------------------------------------------------------ 20 * ------------------------------------------------------------------------
25 */ 21 */
26 22
diff --git a/drivers/media/pci/zoran/zr36060.h b/drivers/media/pci/zoran/zr36060.h
index 914ffa4ad8d3..82911757ba78 100644
--- a/drivers/media/pci/zoran/zr36060.h
+++ b/drivers/media/pci/zoran/zr36060.h
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 * ------------------------------------------------------------------------ 20 * ------------------------------------------------------------------------
25 */ 21 */
26 22
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index d944421e392d..c9106e105bab 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -162,6 +162,9 @@ config VIDEO_CODA
162 Coda is a range of video codec IPs that supports 162 Coda is a range of video codec IPs that supports
163 H.264, MPEG-4, and other video formats. 163 H.264, MPEG-4, and other video formats.
164 164
165config VIDEO_IMX_VDOA
166 def_tristate VIDEO_CODA if SOC_IMX6Q || COMPILE_TEST
167
165config VIDEO_MEDIATEK_VPU 168config VIDEO_MEDIATEK_VPU
166 tristate "Mediatek Video Processor Unit" 169 tristate "Mediatek Video Processor Unit"
167 depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA 170 depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
@@ -298,6 +301,56 @@ config VIDEO_STI_HVA
298 To compile this driver as a module, choose M here: 301 To compile this driver as a module, choose M here:
299 the module will be called st-hva. 302 the module will be called st-hva.
300 303
304config VIDEO_STI_HVA_DEBUGFS
305 bool "Export STMicroelectronics HVA internals in debugfs"
306 depends on VIDEO_STI_HVA
307 depends on DEBUG_FS
308 help
309 Select this to see information about the internal state and the last
310 operation of STMicroelectronics HVA multi-format video encoder in
311 debugfs.
312
313 Choose N unless you know you need this.
314
315config VIDEO_STI_DELTA
316 tristate "STMicroelectronics DELTA multi-format video decoder V4L2 driver"
317 depends on VIDEO_DEV && VIDEO_V4L2
318 depends on ARCH_STI || COMPILE_TEST
319 depends on HAS_DMA
320 help
321 This V4L2 driver enables DELTA multi-format video decoder
322 of STMicroelectronics STiH4xx SoC series allowing hardware
323 decoding of various compressed video bitstream format in
324 raw uncompressed format.
325
326 Use this option to see the decoders available for such
327 hardware.
328
329 Please notice that the driver will only be built if
330 at least one of the DELTA decoder below is selected.
331
332if VIDEO_STI_DELTA
333
334config VIDEO_STI_DELTA_MJPEG
335 bool "STMicroelectronics DELTA MJPEG support"
336 default y
337 help
338 Enables DELTA MJPEG hardware support.
339
340 To compile this driver as a module, choose M here:
341 the module will be called st-delta.
342
343config VIDEO_STI_DELTA_DRIVER
344 tristate
345 depends on VIDEO_STI_DELTA
346 depends on VIDEO_STI_DELTA_MJPEG
347 default VIDEO_STI_DELTA_MJPEG
348 select VIDEOBUF2_DMA_CONTIG
349 select V4L2_MEM2MEM_DEV
350 select RPMSG
351
352endif # VIDEO_STI_DELTA
353
301config VIDEO_SH_VEU 354config VIDEO_SH_VEU
302 tristate "SuperH VEU mem2mem video processing driver" 355 tristate "SuperH VEU mem2mem video processing driver"
303 depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA 356 depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 5b3cb271d2b8..349ddf6a69da 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -39,6 +39,8 @@ obj-$(CONFIG_VIDEO_STI_BDISP) += sti/bdisp/
39obj-$(CONFIG_VIDEO_STI_HVA) += sti/hva/ 39obj-$(CONFIG_VIDEO_STI_HVA) += sti/hva/
40obj-$(CONFIG_DVB_C8SECTPFE) += sti/c8sectpfe/ 40obj-$(CONFIG_DVB_C8SECTPFE) += sti/c8sectpfe/
41 41
42obj-$(CONFIG_VIDEO_STI_DELTA) += sti/delta/
43
42obj-$(CONFIG_BLACKFIN) += blackfin/ 44obj-$(CONFIG_BLACKFIN) += blackfin/
43 45
44obj-$(CONFIG_ARCH_DAVINCI) += davinci/ 46obj-$(CONFIG_ARCH_DAVINCI) += davinci/
diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c
index b33b9e35e60e..05489a401c5c 100644
--- a/drivers/media/platform/am437x/am437x-vpfe.c
+++ b/drivers/media/platform/am437x/am437x-vpfe.c
@@ -1576,7 +1576,7 @@ static int vpfe_s_fmt(struct file *file, void *priv,
1576 return -EBUSY; 1576 return -EBUSY;
1577 } 1577 }
1578 1578
1579 ret = vpfe_try_fmt(file, priv, &format); 1579 ret = __vpfe_get_format(vpfe, &format, &bpp);
1580 if (ret) 1580 if (ret)
1581 return ret; 1581 return ret;
1582 1582
diff --git a/drivers/media/platform/blackfin/bfin_capture.c b/drivers/media/platform/blackfin/bfin_capture.c
index 2e6edc09b58f..1c5166df46f5 100644
--- a/drivers/media/platform/blackfin/bfin_capture.c
+++ b/drivers/media/platform/blackfin/bfin_capture.c
@@ -11,10 +11,6 @@
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 14 */
19 15
20#include <linux/completion.h> 16#include <linux/completion.h>
diff --git a/drivers/media/platform/blackfin/ppi.c b/drivers/media/platform/blackfin/ppi.c
index b8f3d9fa66e9..37169054b828 100644
--- a/drivers/media/platform/blackfin/ppi.c
+++ b/drivers/media/platform/blackfin/ppi.c
@@ -11,10 +11,6 @@
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 14 */
19 15
20#include <linux/module.h> 16#include <linux/module.h>
diff --git a/drivers/media/platform/coda/Makefile b/drivers/media/platform/coda/Makefile
index 9342ac57b230..858284328af9 100644
--- a/drivers/media/platform/coda/Makefile
+++ b/drivers/media/platform/coda/Makefile
@@ -3,3 +3,4 @@ ccflags-y += -I$(src)
3coda-objs := coda-common.o coda-bit.o coda-gdi.o coda-h264.o coda-jpeg.o 3coda-objs := coda-common.o coda-bit.o coda-gdi.o coda-h264.o coda-jpeg.o
4 4
5obj-$(CONFIG_VIDEO_CODA) += coda.o 5obj-$(CONFIG_VIDEO_CODA) += coda.o
6obj-$(CONFIG_VIDEO_IMX_VDOA) += imx-vdoa.o
diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c
index b6625047250d..466a44e4549e 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -30,6 +30,7 @@
30#include <media/videobuf2-vmalloc.h> 30#include <media/videobuf2-vmalloc.h>
31 31
32#include "coda.h" 32#include "coda.h"
33#include "imx-vdoa.h"
33#define CREATE_TRACE_POINTS 34#define CREATE_TRACE_POINTS
34#include "trace.h" 35#include "trace.h"
35 36
@@ -758,7 +759,7 @@ static void coda9_set_frame_cache(struct coda_ctx *ctx, u32 fourcc)
758 cache_config = 1 << CODA9_CACHE_PAGEMERGE_OFFSET; 759 cache_config = 1 << CODA9_CACHE_PAGEMERGE_OFFSET;
759 } 760 }
760 coda_write(ctx->dev, cache_size, CODA9_CMD_SET_FRAME_CACHE_SIZE); 761 coda_write(ctx->dev, cache_size, CODA9_CMD_SET_FRAME_CACHE_SIZE);
761 if (fourcc == V4L2_PIX_FMT_NV12) { 762 if (fourcc == V4L2_PIX_FMT_NV12 || fourcc == V4L2_PIX_FMT_YUYV) {
762 cache_config |= 32 << CODA9_CACHE_LUMA_BUFFER_SIZE_OFFSET | 763 cache_config |= 32 << CODA9_CACHE_LUMA_BUFFER_SIZE_OFFSET |
763 16 << CODA9_CACHE_CR_BUFFER_SIZE_OFFSET | 764 16 << CODA9_CACHE_CR_BUFFER_SIZE_OFFSET |
764 0 << CODA9_CACHE_CB_BUFFER_SIZE_OFFSET; 765 0 << CODA9_CACHE_CB_BUFFER_SIZE_OFFSET;
@@ -1517,6 +1518,10 @@ static int __coda_start_decoding(struct coda_ctx *ctx)
1517 u32 val; 1518 u32 val;
1518 int ret; 1519 int ret;
1519 1520
1521 v4l2_dbg(1, coda_debug, &dev->v4l2_dev,
1522 "Video Data Order Adapter: %s\n",
1523 ctx->use_vdoa ? "Enabled" : "Disabled");
1524
1520 /* Start decoding */ 1525 /* Start decoding */
1521 q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); 1526 q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
1522 q_data_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); 1527 q_data_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
@@ -1532,10 +1537,11 @@ static int __coda_start_decoding(struct coda_ctx *ctx)
1532 1537
1533 ctx->frame_mem_ctrl &= ~(CODA_FRAME_CHROMA_INTERLEAVE | (0x3 << 9) | 1538 ctx->frame_mem_ctrl &= ~(CODA_FRAME_CHROMA_INTERLEAVE | (0x3 << 9) |
1534 CODA9_FRAME_TILED2LINEAR); 1539 CODA9_FRAME_TILED2LINEAR);
1535 if (dst_fourcc == V4L2_PIX_FMT_NV12) 1540 if (dst_fourcc == V4L2_PIX_FMT_NV12 || dst_fourcc == V4L2_PIX_FMT_YUYV)
1536 ctx->frame_mem_ctrl |= CODA_FRAME_CHROMA_INTERLEAVE; 1541 ctx->frame_mem_ctrl |= CODA_FRAME_CHROMA_INTERLEAVE;
1537 if (ctx->tiled_map_type == GDI_TILED_FRAME_MB_RASTER_MAP) 1542 if (ctx->tiled_map_type == GDI_TILED_FRAME_MB_RASTER_MAP)
1538 ctx->frame_mem_ctrl |= (0x3 << 9) | CODA9_FRAME_TILED2LINEAR; 1543 ctx->frame_mem_ctrl |= (0x3 << 9) |
1544 ((ctx->use_vdoa) ? 0 : CODA9_FRAME_TILED2LINEAR);
1539 coda_write(dev, ctx->frame_mem_ctrl, CODA_REG_BIT_FRAME_MEM_CTRL); 1545 coda_write(dev, ctx->frame_mem_ctrl, CODA_REG_BIT_FRAME_MEM_CTRL);
1540 1546
1541 ctx->display_idx = -1; 1547 ctx->display_idx = -1;
@@ -1618,6 +1624,15 @@ static int __coda_start_decoding(struct coda_ctx *ctx)
1618 __func__, ctx->idx, width, height); 1624 __func__, ctx->idx, width, height);
1619 1625
1620 ctx->num_internal_frames = coda_read(dev, CODA_RET_DEC_SEQ_FRAME_NEED); 1626 ctx->num_internal_frames = coda_read(dev, CODA_RET_DEC_SEQ_FRAME_NEED);
1627 /*
1628 * If the VDOA is used, the decoder needs one additional frame,
1629 * because the frames are freed when the next frame is decoded.
1630 * Otherwise there are visible errors in the decoded frames (green
1631 * regions in displayed frames) and a broken order of frames (earlier
1632 * frames are sporadically displayed after later frames).
1633 */
1634 if (ctx->use_vdoa)
1635 ctx->num_internal_frames += 1;
1621 if (ctx->num_internal_frames > CODA_MAX_FRAMEBUFFERS) { 1636 if (ctx->num_internal_frames > CODA_MAX_FRAMEBUFFERS) {
1622 v4l2_err(&dev->v4l2_dev, 1637 v4l2_err(&dev->v4l2_dev,
1623 "not enough framebuffers to decode (%d < %d)\n", 1638 "not enough framebuffers to decode (%d < %d)\n",
@@ -1724,6 +1739,7 @@ static int coda_prepare_decode(struct coda_ctx *ctx)
1724 struct coda_q_data *q_data_dst; 1739 struct coda_q_data *q_data_dst;
1725 struct coda_buffer_meta *meta; 1740 struct coda_buffer_meta *meta;
1726 unsigned long flags; 1741 unsigned long flags;
1742 u32 rot_mode = 0;
1727 u32 reg_addr, reg_stride; 1743 u32 reg_addr, reg_stride;
1728 1744
1729 dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); 1745 dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
@@ -1759,27 +1775,40 @@ static int coda_prepare_decode(struct coda_ctx *ctx)
1759 if (dev->devtype->product == CODA_960) 1775 if (dev->devtype->product == CODA_960)
1760 coda_set_gdi_regs(ctx); 1776 coda_set_gdi_regs(ctx);
1761 1777
1762 if (dev->devtype->product == CODA_960) { 1778 if (ctx->use_vdoa &&
1763 /* 1779 ctx->display_idx >= 0 &&
1764 * The CODA960 seems to have an internal list of buffers with 1780 ctx->display_idx < ctx->num_internal_frames) {
1765 * 64 entries that includes the registered frame buffers as 1781 vdoa_device_run(ctx->vdoa,
1766 * well as the rotator buffer output. 1782 vb2_dma_contig_plane_dma_addr(&dst_buf->vb2_buf, 0),
1767 * ROT_INDEX needs to be < 0x40, but > ctx->num_internal_frames. 1783 ctx->internal_frames[ctx->display_idx].paddr);
1768 */
1769 coda_write(dev, CODA_MAX_FRAMEBUFFERS + dst_buf->vb2_buf.index,
1770 CODA9_CMD_DEC_PIC_ROT_INDEX);
1771
1772 reg_addr = CODA9_CMD_DEC_PIC_ROT_ADDR_Y;
1773 reg_stride = CODA9_CMD_DEC_PIC_ROT_STRIDE;
1774 } else { 1784 } else {
1775 reg_addr = CODA_CMD_DEC_PIC_ROT_ADDR_Y; 1785 if (dev->devtype->product == CODA_960) {
1776 reg_stride = CODA_CMD_DEC_PIC_ROT_STRIDE; 1786 /*
1787 * The CODA960 seems to have an internal list of
1788 * buffers with 64 entries that includes the
1789 * registered frame buffers as well as the rotator
1790 * buffer output.
1791 *
1792 * ROT_INDEX needs to be < 0x40, but >
1793 * ctx->num_internal_frames.
1794 */
1795 coda_write(dev,
1796 CODA_MAX_FRAMEBUFFERS + dst_buf->vb2_buf.index,
1797 CODA9_CMD_DEC_PIC_ROT_INDEX);
1798
1799 reg_addr = CODA9_CMD_DEC_PIC_ROT_ADDR_Y;
1800 reg_stride = CODA9_CMD_DEC_PIC_ROT_STRIDE;
1801 } else {
1802 reg_addr = CODA_CMD_DEC_PIC_ROT_ADDR_Y;
1803 reg_stride = CODA_CMD_DEC_PIC_ROT_STRIDE;
1804 }
1805 coda_write_base(ctx, q_data_dst, dst_buf, reg_addr);
1806 coda_write(dev, q_data_dst->bytesperline, reg_stride);
1807
1808 rot_mode = CODA_ROT_MIR_ENABLE | ctx->params.rot_mode;
1777 } 1809 }
1778 coda_write_base(ctx, q_data_dst, dst_buf, reg_addr);
1779 coda_write(dev, q_data_dst->bytesperline, reg_stride);
1780 1810
1781 coda_write(dev, CODA_ROT_MIR_ENABLE | ctx->params.rot_mode, 1811 coda_write(dev, rot_mode, CODA_CMD_DEC_PIC_ROT_MODE);
1782 CODA_CMD_DEC_PIC_ROT_MODE);
1783 1812
1784 switch (dev->devtype->product) { 1813 switch (dev->devtype->product) {
1785 case CODA_DX6: 1814 case CODA_DX6:
@@ -1851,6 +1880,7 @@ static void coda_finish_decode(struct coda_ctx *ctx)
1851 u32 src_fourcc; 1880 u32 src_fourcc;
1852 int success; 1881 int success;
1853 u32 err_mb; 1882 u32 err_mb;
1883 int err_vdoa = 0;
1854 u32 val; 1884 u32 val;
1855 1885
1856 /* Update kfifo out pointer from coda bitstream read pointer */ 1886 /* Update kfifo out pointer from coda bitstream read pointer */
@@ -1934,13 +1964,17 @@ static void coda_finish_decode(struct coda_ctx *ctx)
1934 } 1964 }
1935 } 1965 }
1936 1966
1967 /* Wait until the VDOA finished writing the previous display frame */
1968 if (ctx->use_vdoa &&
1969 ctx->display_idx >= 0 &&
1970 ctx->display_idx < ctx->num_internal_frames) {
1971 err_vdoa = vdoa_wait_for_completion(ctx->vdoa);
1972 }
1973
1937 ctx->frm_dis_flg = coda_read(dev, 1974 ctx->frm_dis_flg = coda_read(dev,
1938 CODA_REG_BIT_FRM_DIS_FLG(ctx->reg_idx)); 1975 CODA_REG_BIT_FRM_DIS_FLG(ctx->reg_idx));
1939 1976
1940 /* 1977 /* The previous display frame was copied out and can be overwritten */
1941 * The previous display frame was copied out by the rotator,
1942 * now it can be overwritten again
1943 */
1944 if (ctx->display_idx >= 0 && 1978 if (ctx->display_idx >= 0 &&
1945 ctx->display_idx < ctx->num_internal_frames) { 1979 ctx->display_idx < ctx->num_internal_frames) {
1946 ctx->frm_dis_flg &= ~(1 << ctx->display_idx); 1980 ctx->frm_dis_flg &= ~(1 << ctx->display_idx);
@@ -2045,6 +2079,9 @@ static void coda_finish_decode(struct coda_ctx *ctx)
2045 trace_coda_dec_rot_done(ctx, dst_buf, meta); 2079 trace_coda_dec_rot_done(ctx, dst_buf, meta);
2046 2080
2047 switch (q_data_dst->fourcc) { 2081 switch (q_data_dst->fourcc) {
2082 case V4L2_PIX_FMT_YUYV:
2083 payload = width * height * 2;
2084 break;
2048 case V4L2_PIX_FMT_YUV420: 2085 case V4L2_PIX_FMT_YUV420:
2049 case V4L2_PIX_FMT_YVU420: 2086 case V4L2_PIX_FMT_YVU420:
2050 case V4L2_PIX_FMT_NV12: 2087 case V4L2_PIX_FMT_NV12:
@@ -2057,8 +2094,10 @@ static void coda_finish_decode(struct coda_ctx *ctx)
2057 } 2094 }
2058 vb2_set_plane_payload(&dst_buf->vb2_buf, 0, payload); 2095 vb2_set_plane_payload(&dst_buf->vb2_buf, 0, payload);
2059 2096
2060 coda_m2m_buf_done(ctx, dst_buf, ctx->frame_errors[display_idx] ? 2097 if (ctx->frame_errors[ctx->display_idx] || err_vdoa)
2061 VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE); 2098 coda_m2m_buf_done(ctx, dst_buf, VB2_BUF_STATE_ERROR);
2099 else
2100 coda_m2m_buf_done(ctx, dst_buf, VB2_BUF_STATE_DONE);
2062 2101
2063 v4l2_dbg(1, coda_debug, &dev->v4l2_dev, 2102 v4l2_dbg(1, coda_debug, &dev->v4l2_dev,
2064 "job finished: decoding frame (%d) (%s)\n", 2103 "job finished: decoding frame (%d) (%s)\n",
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index 9e6bdafa16f5..eb6548f46cba 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -41,6 +41,7 @@
41#include <media/videobuf2-vmalloc.h> 41#include <media/videobuf2-vmalloc.h>
42 42
43#include "coda.h" 43#include "coda.h"
44#include "imx-vdoa.h"
44 45
45#define CODA_NAME "coda" 46#define CODA_NAME "coda"
46 47
@@ -66,6 +67,10 @@ static int disable_tiling;
66module_param(disable_tiling, int, 0644); 67module_param(disable_tiling, int, 0644);
67MODULE_PARM_DESC(disable_tiling, "Disable tiled frame buffers"); 68MODULE_PARM_DESC(disable_tiling, "Disable tiled frame buffers");
68 69
70static int disable_vdoa;
71module_param(disable_vdoa, int, 0644);
72MODULE_PARM_DESC(disable_vdoa, "Disable Video Data Order Adapter tiled to raster-scan conversion");
73
69void coda_write(struct coda_dev *dev, u32 data, u32 reg) 74void coda_write(struct coda_dev *dev, u32 data, u32 reg)
70{ 75{
71 v4l2_dbg(2, coda_debug, &dev->v4l2_dev, 76 v4l2_dbg(2, coda_debug, &dev->v4l2_dev,
@@ -90,6 +95,8 @@ void coda_write_base(struct coda_ctx *ctx, struct coda_q_data *q_data,
90 u32 base_cb, base_cr; 95 u32 base_cb, base_cr;
91 96
92 switch (q_data->fourcc) { 97 switch (q_data->fourcc) {
98 case V4L2_PIX_FMT_YUYV:
99 /* Fallthrough: IN -H264-> CODA -NV12 MB-> VDOA -YUYV-> OUT */
93 case V4L2_PIX_FMT_NV12: 100 case V4L2_PIX_FMT_NV12:
94 case V4L2_PIX_FMT_YUV420: 101 case V4L2_PIX_FMT_YUV420:
95 default: 102 default:
@@ -196,6 +203,11 @@ static const struct coda_video_device coda_bit_decoder = {
196 V4L2_PIX_FMT_NV12, 203 V4L2_PIX_FMT_NV12,
197 V4L2_PIX_FMT_YUV420, 204 V4L2_PIX_FMT_YUV420,
198 V4L2_PIX_FMT_YVU420, 205 V4L2_PIX_FMT_YVU420,
206 /*
207 * If V4L2_PIX_FMT_YUYV should be default,
208 * set_default_params() must be adjusted.
209 */
210 V4L2_PIX_FMT_YUYV,
199 }, 211 },
200}; 212};
201 213
@@ -241,6 +253,7 @@ static u32 coda_format_normalize_yuv(u32 fourcc)
241 case V4L2_PIX_FMT_YUV420: 253 case V4L2_PIX_FMT_YUV420:
242 case V4L2_PIX_FMT_YVU420: 254 case V4L2_PIX_FMT_YVU420:
243 case V4L2_PIX_FMT_YUV422P: 255 case V4L2_PIX_FMT_YUV422P:
256 case V4L2_PIX_FMT_YUYV:
244 return V4L2_PIX_FMT_YUV420; 257 return V4L2_PIX_FMT_YUV420;
245 default: 258 default:
246 return fourcc; 259 return fourcc;
@@ -325,6 +338,31 @@ const char *coda_product_name(int product)
325 } 338 }
326} 339}
327 340
341static struct vdoa_data *coda_get_vdoa_data(void)
342{
343 struct device_node *vdoa_node;
344 struct platform_device *vdoa_pdev;
345 struct vdoa_data *vdoa_data = NULL;
346
347 vdoa_node = of_find_compatible_node(NULL, NULL, "fsl,imx6q-vdoa");
348 if (!vdoa_node)
349 return NULL;
350
351 vdoa_pdev = of_find_device_by_node(vdoa_node);
352 if (!vdoa_pdev)
353 goto out;
354
355 vdoa_data = platform_get_drvdata(vdoa_pdev);
356 if (!vdoa_data)
357 vdoa_data = ERR_PTR(-EPROBE_DEFER);
358
359out:
360 if (vdoa_node)
361 of_node_put(vdoa_node);
362
363 return vdoa_data;
364}
365
328/* 366/*
329 * V4L2 ioctl() operations. 367 * V4L2 ioctl() operations.
330 */ 368 */
@@ -404,6 +442,11 @@ static int coda_try_pixelformat(struct coda_ctx *ctx, struct v4l2_format *f)
404 return -EINVAL; 442 return -EINVAL;
405 443
406 for (i = 0; i < CODA_MAX_FORMATS; i++) { 444 for (i = 0; i < CODA_MAX_FORMATS; i++) {
445 /* Skip YUYV if the vdoa is not available */
446 if (!ctx->vdoa && f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE &&
447 formats[i] == V4L2_PIX_FMT_YUYV)
448 continue;
449
407 if (formats[i] == f->fmt.pix.pixelformat) { 450 if (formats[i] == f->fmt.pix.pixelformat) {
408 f->fmt.pix.pixelformat = formats[i]; 451 f->fmt.pix.pixelformat = formats[i];
409 return 0; 452 return 0;
@@ -417,6 +460,33 @@ static int coda_try_pixelformat(struct coda_ctx *ctx, struct v4l2_format *f)
417 return 0; 460 return 0;
418} 461}
419 462
463static int coda_try_fmt_vdoa(struct coda_ctx *ctx, struct v4l2_format *f,
464 bool *use_vdoa)
465{
466 int err;
467
468 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
469 return -EINVAL;
470
471 if (!use_vdoa)
472 return -EINVAL;
473
474 if (!ctx->vdoa) {
475 *use_vdoa = false;
476 return 0;
477 }
478
479 err = vdoa_context_configure(NULL, f->fmt.pix.width, f->fmt.pix.height,
480 f->fmt.pix.pixelformat);
481 if (err) {
482 *use_vdoa = false;
483 return 0;
484 }
485
486 *use_vdoa = true;
487 return 0;
488}
489
420static unsigned int coda_estimate_sizeimage(struct coda_ctx *ctx, u32 sizeimage, 490static unsigned int coda_estimate_sizeimage(struct coda_ctx *ctx, u32 sizeimage,
421 u32 width, u32 height) 491 u32 width, u32 height)
422{ 492{
@@ -463,6 +533,11 @@ static int coda_try_fmt(struct coda_ctx *ctx, const struct coda_codec *codec,
463 f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * 533 f->fmt.pix.sizeimage = f->fmt.pix.bytesperline *
464 f->fmt.pix.height * 3 / 2; 534 f->fmt.pix.height * 3 / 2;
465 break; 535 break;
536 case V4L2_PIX_FMT_YUYV:
537 f->fmt.pix.bytesperline = round_up(f->fmt.pix.width, 16) * 2;
538 f->fmt.pix.sizeimage = f->fmt.pix.bytesperline *
539 f->fmt.pix.height;
540 break;
466 case V4L2_PIX_FMT_YUV422P: 541 case V4L2_PIX_FMT_YUV422P:
467 f->fmt.pix.bytesperline = round_up(f->fmt.pix.width, 16); 542 f->fmt.pix.bytesperline = round_up(f->fmt.pix.width, 16);
468 f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * 543 f->fmt.pix.sizeimage = f->fmt.pix.bytesperline *
@@ -495,6 +570,7 @@ static int coda_try_fmt_vid_cap(struct file *file, void *priv,
495 const struct coda_codec *codec; 570 const struct coda_codec *codec;
496 struct vb2_queue *src_vq; 571 struct vb2_queue *src_vq;
497 int ret; 572 int ret;
573 bool use_vdoa;
498 574
499 ret = coda_try_pixelformat(ctx, f); 575 ret = coda_try_pixelformat(ctx, f);
500 if (ret < 0) 576 if (ret < 0)
@@ -531,6 +607,19 @@ static int coda_try_fmt_vid_cap(struct file *file, void *priv,
531 f->fmt.pix.bytesperline = round_up(f->fmt.pix.width, 16); 607 f->fmt.pix.bytesperline = round_up(f->fmt.pix.width, 16);
532 f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * 608 f->fmt.pix.sizeimage = f->fmt.pix.bytesperline *
533 f->fmt.pix.height * 3 / 2; 609 f->fmt.pix.height * 3 / 2;
610
611 ret = coda_try_fmt_vdoa(ctx, f, &use_vdoa);
612 if (ret < 0)
613 return ret;
614
615 if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) {
616 if (!use_vdoa)
617 return -EINVAL;
618
619 f->fmt.pix.bytesperline = round_up(f->fmt.pix.width, 16) * 2;
620 f->fmt.pix.sizeimage = f->fmt.pix.bytesperline *
621 f->fmt.pix.height;
622 }
534 } 623 }
535 624
536 return 0; 625 return 0;
@@ -566,7 +655,8 @@ static int coda_try_fmt_vid_out(struct file *file, void *priv,
566 return coda_try_fmt(ctx, codec, f); 655 return coda_try_fmt(ctx, codec, f);
567} 656}
568 657
569static int coda_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f) 658static int coda_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f,
659 struct v4l2_rect *r)
570{ 660{
571 struct coda_q_data *q_data; 661 struct coda_q_data *q_data;
572 struct vb2_queue *vq; 662 struct vb2_queue *vq;
@@ -589,18 +679,23 @@ static int coda_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f)
589 q_data->height = f->fmt.pix.height; 679 q_data->height = f->fmt.pix.height;
590 q_data->bytesperline = f->fmt.pix.bytesperline; 680 q_data->bytesperline = f->fmt.pix.bytesperline;
591 q_data->sizeimage = f->fmt.pix.sizeimage; 681 q_data->sizeimage = f->fmt.pix.sizeimage;
592 q_data->rect.left = 0; 682 if (r) {
593 q_data->rect.top = 0; 683 q_data->rect = *r;
594 q_data->rect.width = f->fmt.pix.width; 684 } else {
595 q_data->rect.height = f->fmt.pix.height; 685 q_data->rect.left = 0;
686 q_data->rect.top = 0;
687 q_data->rect.width = f->fmt.pix.width;
688 q_data->rect.height = f->fmt.pix.height;
689 }
596 690
597 switch (f->fmt.pix.pixelformat) { 691 switch (f->fmt.pix.pixelformat) {
692 case V4L2_PIX_FMT_YUYV:
693 ctx->tiled_map_type = GDI_TILED_FRAME_MB_RASTER_MAP;
694 break;
598 case V4L2_PIX_FMT_NV12: 695 case V4L2_PIX_FMT_NV12:
599 if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { 696 ctx->tiled_map_type = GDI_TILED_FRAME_MB_RASTER_MAP;
600 ctx->tiled_map_type = GDI_TILED_FRAME_MB_RASTER_MAP; 697 if (!disable_tiling)
601 if (!disable_tiling) 698 break;
602 break;
603 }
604 /* else fall through */ 699 /* else fall through */
605 case V4L2_PIX_FMT_YUV420: 700 case V4L2_PIX_FMT_YUV420:
606 case V4L2_PIX_FMT_YVU420: 701 case V4L2_PIX_FMT_YVU420:
@@ -610,9 +705,20 @@ static int coda_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f)
610 break; 705 break;
611 } 706 }
612 707
708 if (ctx->tiled_map_type == GDI_TILED_FRAME_MB_RASTER_MAP &&
709 !coda_try_fmt_vdoa(ctx, f, &ctx->use_vdoa) &&
710 ctx->use_vdoa)
711 vdoa_context_configure(ctx->vdoa, f->fmt.pix.width,
712 f->fmt.pix.height,
713 f->fmt.pix.pixelformat);
714 else
715 ctx->use_vdoa = false;
716
613 v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, 717 v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev,
614 "Setting format for type %d, wxh: %dx%d, fmt: %d\n", 718 "Setting format for type %d, wxh: %dx%d, fmt: %4.4s %c\n",
615 f->type, q_data->width, q_data->height, q_data->fourcc); 719 f->type, q_data->width, q_data->height,
720 (char *)&q_data->fourcc,
721 (ctx->tiled_map_type == GDI_LINEAR_FRAME_MAP) ? 'L' : 'T');
616 722
617 return 0; 723 return 0;
618} 724}
@@ -621,27 +727,37 @@ static int coda_s_fmt_vid_cap(struct file *file, void *priv,
621 struct v4l2_format *f) 727 struct v4l2_format *f)
622{ 728{
623 struct coda_ctx *ctx = fh_to_ctx(priv); 729 struct coda_ctx *ctx = fh_to_ctx(priv);
730 struct coda_q_data *q_data_src;
731 struct v4l2_rect r;
624 int ret; 732 int ret;
625 733
626 ret = coda_try_fmt_vid_cap(file, priv, f); 734 ret = coda_try_fmt_vid_cap(file, priv, f);
627 if (ret) 735 if (ret)
628 return ret; 736 return ret;
629 737
630 return coda_s_fmt(ctx, f); 738 q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
739 r.left = 0;
740 r.top = 0;
741 r.width = q_data_src->width;
742 r.height = q_data_src->height;
743
744 return coda_s_fmt(ctx, f, &r);
631} 745}
632 746
633static int coda_s_fmt_vid_out(struct file *file, void *priv, 747static int coda_s_fmt_vid_out(struct file *file, void *priv,
634 struct v4l2_format *f) 748 struct v4l2_format *f)
635{ 749{
636 struct coda_ctx *ctx = fh_to_ctx(priv); 750 struct coda_ctx *ctx = fh_to_ctx(priv);
751 struct coda_q_data *q_data_src;
637 struct v4l2_format f_cap; 752 struct v4l2_format f_cap;
753 struct v4l2_rect r;
638 int ret; 754 int ret;
639 755
640 ret = coda_try_fmt_vid_out(file, priv, f); 756 ret = coda_try_fmt_vid_out(file, priv, f);
641 if (ret) 757 if (ret)
642 return ret; 758 return ret;
643 759
644 ret = coda_s_fmt(ctx, f); 760 ret = coda_s_fmt(ctx, f, NULL);
645 if (ret) 761 if (ret)
646 return ret; 762 return ret;
647 763
@@ -657,7 +773,13 @@ static int coda_s_fmt_vid_out(struct file *file, void *priv,
657 if (ret) 773 if (ret)
658 return ret; 774 return ret;
659 775
660 return coda_s_fmt(ctx, &f_cap); 776 q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
777 r.left = 0;
778 r.top = 0;
779 r.width = q_data_src->width;
780 r.height = q_data_src->height;
781
782 return coda_s_fmt(ctx, &f_cap, &r);
661} 783}
662 784
663static int coda_reqbufs(struct file *file, void *priv, 785static int coda_reqbufs(struct file *file, void *priv,
@@ -1018,6 +1140,16 @@ static int coda_job_ready(void *m2m_priv)
1018 bool stream_end = ctx->bit_stream_param & 1140 bool stream_end = ctx->bit_stream_param &
1019 CODA_BIT_STREAM_END_FLAG; 1141 CODA_BIT_STREAM_END_FLAG;
1020 int num_metas = ctx->num_metas; 1142 int num_metas = ctx->num_metas;
1143 unsigned int count;
1144
1145 count = hweight32(ctx->frm_dis_flg);
1146 if (ctx->use_vdoa && count >= (ctx->num_internal_frames - 1)) {
1147 v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev,
1148 "%d: not ready: all internal buffers in use: %d/%d (0x%x)",
1149 ctx->idx, count, ctx->num_internal_frames,
1150 ctx->frm_dis_flg);
1151 return 0;
1152 }
1021 1153
1022 if (ctx->hold && !src_bufs) { 1154 if (ctx->hold && !src_bufs) {
1023 v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, 1155 v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev,
@@ -1708,6 +1840,13 @@ static int coda_open(struct file *file)
1708 default: 1840 default:
1709 ctx->reg_idx = idx; 1841 ctx->reg_idx = idx;
1710 } 1842 }
1843 if (ctx->dev->vdoa && !disable_vdoa) {
1844 ctx->vdoa = vdoa_context_create(dev->vdoa);
1845 if (!ctx->vdoa)
1846 v4l2_warn(&dev->v4l2_dev,
1847 "Failed to create vdoa context: not using vdoa");
1848 }
1849 ctx->use_vdoa = false;
1711 1850
1712 /* Power up and upload firmware if necessary */ 1851 /* Power up and upload firmware if necessary */
1713 ret = pm_runtime_get_sync(&dev->plat_dev->dev); 1852 ret = pm_runtime_get_sync(&dev->plat_dev->dev);
@@ -1789,6 +1928,9 @@ static int coda_release(struct file *file)
1789 /* If this instance is running, call .job_abort and wait for it to end */ 1928 /* If this instance is running, call .job_abort and wait for it to end */
1790 v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); 1929 v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
1791 1930
1931 if (ctx->vdoa)
1932 vdoa_context_destroy(ctx->vdoa);
1933
1792 /* In case the instance was not running, we still need to call SEQ_END */ 1934 /* In case the instance was not running, we still need to call SEQ_END */
1793 if (ctx->ops->seq_end_work) { 1935 if (ctx->ops->seq_end_work) {
1794 queue_work(dev->workqueue, &ctx->seq_end_work); 1936 queue_work(dev->workqueue, &ctx->seq_end_work);
@@ -2079,6 +2221,7 @@ static const struct coda_devtype coda_devdata[] = {
2079 [CODA_IMX27] = { 2221 [CODA_IMX27] = {
2080 .firmware = { 2222 .firmware = {
2081 "vpu_fw_imx27_TO2.bin", 2223 "vpu_fw_imx27_TO2.bin",
2224 "vpu/vpu_fw_imx27_TO2.bin",
2082 "v4l-codadx6-imx27.bin" 2225 "v4l-codadx6-imx27.bin"
2083 }, 2226 },
2084 .product = CODA_DX6, 2227 .product = CODA_DX6,
@@ -2092,6 +2235,7 @@ static const struct coda_devtype coda_devdata[] = {
2092 [CODA_IMX53] = { 2235 [CODA_IMX53] = {
2093 .firmware = { 2236 .firmware = {
2094 "vpu_fw_imx53.bin", 2237 "vpu_fw_imx53.bin",
2238 "vpu/vpu_fw_imx53.bin",
2095 "v4l-coda7541-imx53.bin" 2239 "v4l-coda7541-imx53.bin"
2096 }, 2240 },
2097 .product = CODA_7541, 2241 .product = CODA_7541,
@@ -2106,6 +2250,7 @@ static const struct coda_devtype coda_devdata[] = {
2106 [CODA_IMX6Q] = { 2250 [CODA_IMX6Q] = {
2107 .firmware = { 2251 .firmware = {
2108 "vpu_fw_imx6q.bin", 2252 "vpu_fw_imx6q.bin",
2253 "vpu/vpu_fw_imx6q.bin",
2109 "v4l-coda960-imx6q.bin" 2254 "v4l-coda960-imx6q.bin"
2110 }, 2255 },
2111 .product = CODA_960, 2256 .product = CODA_960,
@@ -2120,6 +2265,7 @@ static const struct coda_devtype coda_devdata[] = {
2120 [CODA_IMX6DL] = { 2265 [CODA_IMX6DL] = {
2121 .firmware = { 2266 .firmware = {
2122 "vpu_fw_imx6d.bin", 2267 "vpu_fw_imx6d.bin",
2268 "vpu/vpu_fw_imx6d.bin",
2123 "v4l-coda960-imx6dl.bin" 2269 "v4l-coda960-imx6dl.bin"
2124 }, 2270 },
2125 .product = CODA_960, 2271 .product = CODA_960,
@@ -2235,6 +2381,11 @@ static int coda_probe(struct platform_device *pdev)
2235 } 2381 }
2236 dev->iram_pool = pool; 2382 dev->iram_pool = pool;
2237 2383
2384 /* Get vdoa_data if supported by the platform */
2385 dev->vdoa = coda_get_vdoa_data();
2386 if (PTR_ERR(dev->vdoa) == -EPROBE_DEFER)
2387 return -EPROBE_DEFER;
2388
2238 ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); 2389 ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev);
2239 if (ret) 2390 if (ret)
2240 return ret; 2391 return ret;
diff --git a/drivers/media/platform/coda/coda.h b/drivers/media/platform/coda/coda.h
index 53f96661683c..4b831c91ae4a 100644
--- a/drivers/media/platform/coda/coda.h
+++ b/drivers/media/platform/coda/coda.h
@@ -50,7 +50,7 @@ enum coda_product {
50struct coda_video_device; 50struct coda_video_device;
51 51
52struct coda_devtype { 52struct coda_devtype {
53 char *firmware[2]; 53 char *firmware[3];
54 enum coda_product product; 54 enum coda_product product;
55 const struct coda_codec *codecs; 55 const struct coda_codec *codecs;
56 unsigned int num_codecs; 56 unsigned int num_codecs;
@@ -75,6 +75,7 @@ struct coda_dev {
75 struct platform_device *plat_dev; 75 struct platform_device *plat_dev;
76 const struct coda_devtype *devtype; 76 const struct coda_devtype *devtype;
77 int firmware; 77 int firmware;
78 struct vdoa_data *vdoa;
78 79
79 void __iomem *regs_base; 80 void __iomem *regs_base;
80 struct clk *clk_per; 81 struct clk *clk_per;
@@ -236,6 +237,8 @@ struct coda_ctx {
236 int display_idx; 237 int display_idx;
237 struct dentry *debugfs_entry; 238 struct dentry *debugfs_entry;
238 bool use_bit; 239 bool use_bit;
240 bool use_vdoa;
241 struct vdoa_ctx *vdoa;
239}; 242};
240 243
241extern int coda_debug; 244extern int coda_debug;
diff --git a/drivers/media/platform/coda/imx-vdoa.c b/drivers/media/platform/coda/imx-vdoa.c
new file mode 100644
index 000000000000..67fd8ffa60a4
--- /dev/null
+++ b/drivers/media/platform/coda/imx-vdoa.c
@@ -0,0 +1,338 @@
1/*
2 * i.MX6 Video Data Order Adapter (VDOA)
3 *
4 * Copyright (C) 2014 Philipp Zabel
5 * Copyright (C) 2016 Pengutronix, Michael Tretter <kernel@pengutronix.de>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2, as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <linux/clk.h>
18#include <linux/device.h>
19#include <linux/interrupt.h>
20#include <linux/module.h>
21#include <linux/dma-mapping.h>
22#include <linux/platform_device.h>
23#include <linux/videodev2.h>
24#include <linux/slab.h>
25
26#include "imx-vdoa.h"
27
28#define VDOA_NAME "imx-vdoa"
29
30#define VDOAC 0x00
31#define VDOASRR 0x04
32#define VDOAIE 0x08
33#define VDOAIST 0x0c
34#define VDOAFP 0x10
35#define VDOAIEBA00 0x14
36#define VDOAIEBA01 0x18
37#define VDOAIEBA02 0x1c
38#define VDOAIEBA10 0x20
39#define VDOAIEBA11 0x24
40#define VDOAIEBA12 0x28
41#define VDOASL 0x2c
42#define VDOAIUBO 0x30
43#define VDOAVEBA0 0x34
44#define VDOAVEBA1 0x38
45#define VDOAVEBA2 0x3c
46#define VDOAVUBO 0x40
47#define VDOASR 0x44
48
49#define VDOAC_ISEL BIT(6)
50#define VDOAC_PFS BIT(5)
51#define VDOAC_SO BIT(4)
52#define VDOAC_SYNC BIT(3)
53#define VDOAC_NF BIT(2)
54#define VDOAC_BNDM_MASK 0x3
55#define VDOAC_BAND_HEIGHT_8 0x0
56#define VDOAC_BAND_HEIGHT_16 0x1
57#define VDOAC_BAND_HEIGHT_32 0x2
58
59#define VDOASRR_START BIT(1)
60#define VDOASRR_SWRST BIT(0)
61
62#define VDOAIE_EITERR BIT(1)
63#define VDOAIE_EIEOT BIT(0)
64
65#define VDOAIST_TERR BIT(1)
66#define VDOAIST_EOT BIT(0)
67
68#define VDOAFP_FH_MASK (0x1fff << 16)
69#define VDOAFP_FW_MASK (0x3fff)
70
71#define VDOASL_VSLY_MASK (0x3fff << 16)
72#define VDOASL_ISLY_MASK (0x7fff)
73
74#define VDOASR_ERRW BIT(4)
75#define VDOASR_EOB BIT(3)
76#define VDOASR_CURRENT_FRAME (0x3 << 1)
77#define VDOASR_CURRENT_BUFFER BIT(1)
78
79enum {
80 V4L2_M2M_SRC = 0,
81 V4L2_M2M_DST = 1,
82};
83
84struct vdoa_data {
85 struct vdoa_ctx *curr_ctx;
86 struct device *dev;
87 struct clk *vdoa_clk;
88 void __iomem *regs;
89 int irq;
90};
91
92struct vdoa_q_data {
93 unsigned int width;
94 unsigned int height;
95 unsigned int bytesperline;
96 unsigned int sizeimage;
97 u32 pixelformat;
98};
99
100struct vdoa_ctx {
101 struct vdoa_data *vdoa;
102 struct completion completion;
103 struct vdoa_q_data q_data[2];
104};
105
106static irqreturn_t vdoa_irq_handler(int irq, void *data)
107{
108 struct vdoa_data *vdoa = data;
109 struct vdoa_ctx *curr_ctx;
110 u32 val;
111
112 /* Disable interrupts */
113 writel(0, vdoa->regs + VDOAIE);
114
115 curr_ctx = vdoa->curr_ctx;
116 if (!curr_ctx) {
117 dev_dbg(vdoa->dev,
118 "Instance released before the end of transaction\n");
119 return IRQ_HANDLED;
120 }
121
122 val = readl(vdoa->regs + VDOAIST);
123 writel(val, vdoa->regs + VDOAIST);
124 if (val & VDOAIST_TERR) {
125 val = readl(vdoa->regs + VDOASR) & VDOASR_ERRW;
126 dev_err(vdoa->dev, "AXI %s error\n", val ? "write" : "read");
127 } else if (!(val & VDOAIST_EOT)) {
128 dev_warn(vdoa->dev, "Spurious interrupt\n");
129 }
130 complete(&curr_ctx->completion);
131
132 return IRQ_HANDLED;
133}
134
135void vdoa_device_run(struct vdoa_ctx *ctx, dma_addr_t dst, dma_addr_t src)
136{
137 struct vdoa_q_data *src_q_data, *dst_q_data;
138 struct vdoa_data *vdoa = ctx->vdoa;
139 u32 val;
140
141 vdoa->curr_ctx = ctx;
142
143 src_q_data = &ctx->q_data[V4L2_M2M_SRC];
144 dst_q_data = &ctx->q_data[V4L2_M2M_DST];
145
146 /* Progressive, no sync, 1 frame per run */
147 if (dst_q_data->pixelformat == V4L2_PIX_FMT_YUYV)
148 val = VDOAC_PFS;
149 else
150 val = 0;
151 writel(val, vdoa->regs + VDOAC);
152
153 writel(dst_q_data->height << 16 | dst_q_data->width,
154 vdoa->regs + VDOAFP);
155
156 val = dst;
157 writel(val, vdoa->regs + VDOAIEBA00);
158
159 writel(src_q_data->bytesperline << 16 | dst_q_data->bytesperline,
160 vdoa->regs + VDOASL);
161
162 if (dst_q_data->pixelformat == V4L2_PIX_FMT_NV12 ||
163 dst_q_data->pixelformat == V4L2_PIX_FMT_NV21)
164 val = dst_q_data->bytesperline * dst_q_data->height;
165 else
166 val = 0;
167 writel(val, vdoa->regs + VDOAIUBO);
168
169 val = src;
170 writel(val, vdoa->regs + VDOAVEBA0);
171 val = round_up(src_q_data->bytesperline * src_q_data->height, 4096);
172 writel(val, vdoa->regs + VDOAVUBO);
173
174 /* Enable interrupts and start transfer */
175 writel(VDOAIE_EITERR | VDOAIE_EIEOT, vdoa->regs + VDOAIE);
176 writel(VDOASRR_START, vdoa->regs + VDOASRR);
177}
178EXPORT_SYMBOL(vdoa_device_run);
179
180int vdoa_wait_for_completion(struct vdoa_ctx *ctx)
181{
182 struct vdoa_data *vdoa = ctx->vdoa;
183
184 if (!wait_for_completion_timeout(&ctx->completion,
185 msecs_to_jiffies(300))) {
186 dev_err(vdoa->dev,
187 "Timeout waiting for transfer result\n");
188 return -ETIMEDOUT;
189 }
190
191 return 0;
192}
193EXPORT_SYMBOL(vdoa_wait_for_completion);
194
195struct vdoa_ctx *vdoa_context_create(struct vdoa_data *vdoa)
196{
197 struct vdoa_ctx *ctx;
198 int err;
199
200 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
201 if (!ctx)
202 return NULL;
203
204 err = clk_prepare_enable(vdoa->vdoa_clk);
205 if (err) {
206 kfree(ctx);
207 return NULL;
208 }
209
210 init_completion(&ctx->completion);
211 ctx->vdoa = vdoa;
212
213 return ctx;
214}
215EXPORT_SYMBOL(vdoa_context_create);
216
217void vdoa_context_destroy(struct vdoa_ctx *ctx)
218{
219 struct vdoa_data *vdoa = ctx->vdoa;
220
221 clk_disable_unprepare(vdoa->vdoa_clk);
222 kfree(ctx);
223}
224EXPORT_SYMBOL(vdoa_context_destroy);
225
226int vdoa_context_configure(struct vdoa_ctx *ctx,
227 unsigned int width, unsigned int height,
228 u32 pixelformat)
229{
230 struct vdoa_q_data *src_q_data;
231 struct vdoa_q_data *dst_q_data;
232
233 if (width < 16 || width > 8192 || width % 16 != 0 ||
234 height < 16 || height > 4096 || height % 16 != 0)
235 return -EINVAL;
236
237 if (pixelformat != V4L2_PIX_FMT_YUYV &&
238 pixelformat != V4L2_PIX_FMT_NV12)
239 return -EINVAL;
240
241 /* If no context is passed, only check if the format is valid */
242 if (!ctx)
243 return 0;
244
245 src_q_data = &ctx->q_data[V4L2_M2M_SRC];
246 dst_q_data = &ctx->q_data[V4L2_M2M_DST];
247
248 src_q_data->width = width;
249 src_q_data->height = height;
250 src_q_data->bytesperline = width;
251 src_q_data->sizeimage =
252 round_up(src_q_data->bytesperline * height, 4096) +
253 src_q_data->bytesperline * height / 2;
254
255 dst_q_data->width = width;
256 dst_q_data->height = height;
257 dst_q_data->pixelformat = pixelformat;
258 switch (pixelformat) {
259 case V4L2_PIX_FMT_YUYV:
260 dst_q_data->bytesperline = width * 2;
261 dst_q_data->sizeimage = dst_q_data->bytesperline * height;
262 break;
263 case V4L2_PIX_FMT_NV12:
264 default:
265 dst_q_data->bytesperline = width;
266 dst_q_data->sizeimage =
267 dst_q_data->bytesperline * height * 3 / 2;
268 break;
269 }
270
271 return 0;
272}
273EXPORT_SYMBOL(vdoa_context_configure);
274
275static int vdoa_probe(struct platform_device *pdev)
276{
277 struct vdoa_data *vdoa;
278 struct resource *res;
279
280 dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
281
282 vdoa = devm_kzalloc(&pdev->dev, sizeof(*vdoa), GFP_KERNEL);
283 if (!vdoa)
284 return -ENOMEM;
285
286 vdoa->dev = &pdev->dev;
287
288 vdoa->vdoa_clk = devm_clk_get(vdoa->dev, NULL);
289 if (IS_ERR(vdoa->vdoa_clk)) {
290 dev_err(vdoa->dev, "Failed to get clock\n");
291 return PTR_ERR(vdoa->vdoa_clk);
292 }
293
294 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
295 vdoa->regs = devm_ioremap_resource(vdoa->dev, res);
296 if (IS_ERR(vdoa->regs))
297 return PTR_ERR(vdoa->regs);
298
299 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
300 vdoa->irq = devm_request_threaded_irq(&pdev->dev, res->start, NULL,
301 vdoa_irq_handler, IRQF_ONESHOT,
302 "vdoa", vdoa);
303 if (vdoa->irq < 0) {
304 dev_err(vdoa->dev, "Failed to get irq\n");
305 return vdoa->irq;
306 }
307
308 platform_set_drvdata(pdev, vdoa);
309
310 return 0;
311}
312
313static int vdoa_remove(struct platform_device *pdev)
314{
315 return 0;
316}
317
318static const struct of_device_id vdoa_dt_ids[] = {
319 { .compatible = "fsl,imx6q-vdoa" },
320 {}
321};
322MODULE_DEVICE_TABLE(of, vdoa_dt_ids);
323
324static const struct platform_driver vdoa_driver = {
325 .probe = vdoa_probe,
326 .remove = vdoa_remove,
327 .driver = {
328 .name = VDOA_NAME,
329 .of_match_table = vdoa_dt_ids,
330 },
331};
332
333module_platform_driver(vdoa_driver);
334
335MODULE_DESCRIPTION("Video Data Order Adapter");
336MODULE_AUTHOR("Philipp Zabel <philipp.zabel@gmail.com>");
337MODULE_ALIAS("platform:imx-vdoa");
338MODULE_LICENSE("GPL");
diff --git a/drivers/media/platform/coda/imx-vdoa.h b/drivers/media/platform/coda/imx-vdoa.h
new file mode 100644
index 000000000000..967576b2a06a
--- /dev/null
+++ b/drivers/media/platform/coda/imx-vdoa.h
@@ -0,0 +1,58 @@
1/*
2 * Copyright (C) 2016 Pengutronix
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#ifndef IMX_VDOA_H
15#define IMX_VDOA_H
16
17struct vdoa_data;
18struct vdoa_ctx;
19
20#if (defined CONFIG_VIDEO_IMX_VDOA || defined CONFIG_VIDEO_IMX_VDOA_MODULE)
21
22struct vdoa_ctx *vdoa_context_create(struct vdoa_data *vdoa);
23int vdoa_context_configure(struct vdoa_ctx *ctx,
24 unsigned int width, unsigned int height,
25 u32 pixelformat);
26void vdoa_context_destroy(struct vdoa_ctx *ctx);
27
28void vdoa_device_run(struct vdoa_ctx *ctx, dma_addr_t dst, dma_addr_t src);
29int vdoa_wait_for_completion(struct vdoa_ctx *ctx);
30
31#else
32
33static inline struct vdoa_ctx *vdoa_context_create(struct vdoa_data *vdoa)
34{
35 return NULL;
36}
37
38static inline int vdoa_context_configure(struct vdoa_ctx *ctx,
39 unsigned int width,
40 unsigned int height,
41 u32 pixelformat)
42{
43 return 0;
44}
45
46static inline void vdoa_context_destroy(struct vdoa_ctx *ctx) { };
47
48static inline void vdoa_device_run(struct vdoa_ctx *ctx,
49 dma_addr_t dst, dma_addr_t src) { };
50
51static inline int vdoa_wait_for_completion(struct vdoa_ctx *ctx)
52{
53 return 0;
54};
55
56#endif
57
58#endif /* IMX_VDOA_H */
diff --git a/drivers/media/platform/davinci/ccdc_hw_device.h b/drivers/media/platform/davinci/ccdc_hw_device.h
index ae5605de7679..8f6688a7a111 100644
--- a/drivers/media/platform/davinci/ccdc_hw_device.h
+++ b/drivers/media/platform/davinci/ccdc_hw_device.h
@@ -11,10 +11,6 @@
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * ccdc device API 14 * ccdc device API
19 */ 15 */
20#ifndef _CCDC_HW_DEVICE_H 16#ifndef _CCDC_HW_DEVICE_H
diff --git a/drivers/media/platform/davinci/dm355_ccdc.c b/drivers/media/platform/davinci/dm355_ccdc.c
index 65c2973167c6..73db166dc338 100644
--- a/drivers/media/platform/davinci/dm355_ccdc.c
+++ b/drivers/media/platform/davinci/dm355_ccdc.c
@@ -11,10 +11,6 @@
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * CCDC hardware module for DM355 14 * CCDC hardware module for DM355
19 * ------------------------------ 15 * ------------------------------
20 * 16 *
diff --git a/drivers/media/platform/davinci/dm355_ccdc_regs.h b/drivers/media/platform/davinci/dm355_ccdc_regs.h
index 2e1946e0b99f..a753ce262583 100644
--- a/drivers/media/platform/davinci/dm355_ccdc_regs.h
+++ b/drivers/media/platform/davinci/dm355_ccdc_regs.h
@@ -10,10 +10,6 @@
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */ 13 */
18#ifndef _DM355_CCDC_REGS_H 14#ifndef _DM355_CCDC_REGS_H
19#define _DM355_CCDC_REGS_H 15#define _DM355_CCDC_REGS_H
diff --git a/drivers/media/platform/davinci/dm644x_ccdc.c b/drivers/media/platform/davinci/dm644x_ccdc.c
index c7523a7e0594..740fbc7a8c14 100644
--- a/drivers/media/platform/davinci/dm644x_ccdc.c
+++ b/drivers/media/platform/davinci/dm644x_ccdc.c
@@ -11,10 +11,6 @@
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * CCDC hardware module for DM6446 14 * CCDC hardware module for DM6446
19 * ------------------------------ 15 * ------------------------------
20 * 16 *
diff --git a/drivers/media/platform/davinci/dm644x_ccdc_regs.h b/drivers/media/platform/davinci/dm644x_ccdc_regs.h
index 2b0aca5383f0..bece0bd9c9de 100644
--- a/drivers/media/platform/davinci/dm644x_ccdc_regs.h
+++ b/drivers/media/platform/davinci/dm644x_ccdc_regs.h
@@ -10,10 +10,6 @@
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */ 13 */
18#ifndef _DM644X_CCDC_REGS_H 14#ifndef _DM644X_CCDC_REGS_H
19#define _DM644X_CCDC_REGS_H 15#define _DM644X_CCDC_REGS_H
diff --git a/drivers/media/platform/davinci/isif.c b/drivers/media/platform/davinci/isif.c
index 99faea2e84c6..5813b49391ed 100644
--- a/drivers/media/platform/davinci/isif.c
+++ b/drivers/media/platform/davinci/isif.c
@@ -11,10 +11,6 @@
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Image Sensor Interface (ISIF) driver 14 * Image Sensor Interface (ISIF) driver
19 * 15 *
20 * This driver is for configuring the ISIF IP available on DM365 or any other 16 * This driver is for configuring the ISIF IP available on DM365 or any other
diff --git a/drivers/media/platform/davinci/isif_regs.h b/drivers/media/platform/davinci/isif_regs.h
index 3993aece821b..a3564abe08ae 100644
--- a/drivers/media/platform/davinci/isif_regs.h
+++ b/drivers/media/platform/davinci/isif_regs.h
@@ -10,10 +10,6 @@
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */ 13 */
18#ifndef _ISIF_REGS_H 14#ifndef _ISIF_REGS_H
19#define _ISIF_REGS_H 15#define _ISIF_REGS_H
diff --git a/drivers/media/platform/davinci/vpbe.c b/drivers/media/platform/davinci/vpbe.c
index 8c8cbeb7d90f..3679b1e7b39e 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -9,10 +9,6 @@
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */ 12 */
17#include <linux/kernel.h> 13#include <linux/kernel.h>
18#include <linux/init.h> 14#include <linux/init.h>
diff --git a/drivers/media/platform/davinci/vpbe_osd.c b/drivers/media/platform/davinci/vpbe_osd.c
index 7d96a4b13b32..df042e84a678 100644
--- a/drivers/media/platform/davinci/vpbe_osd.c
+++ b/drivers/media/platform/davinci/vpbe_osd.c
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */ 19 */
24#include <linux/module.h> 20#include <linux/module.h>
25#include <linux/kernel.h> 21#include <linux/kernel.h>
diff --git a/drivers/media/platform/davinci/vpbe_osd_regs.h b/drivers/media/platform/davinci/vpbe_osd_regs.h
index 584520f3af60..3db265f87c65 100644
--- a/drivers/media/platform/davinci/vpbe_osd_regs.h
+++ b/drivers/media/platform/davinci/vpbe_osd_regs.h
@@ -9,10 +9,6 @@
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */ 12 */
17#ifndef _VPBE_OSD_REGS_H 13#ifndef _VPBE_OSD_REGS_H
18#define _VPBE_OSD_REGS_H 14#define _VPBE_OSD_REGS_H
diff --git a/drivers/media/platform/davinci/vpbe_venc.c b/drivers/media/platform/davinci/vpbe_venc.c
index 36ed1466b290..8bfe90a24681 100644
--- a/drivers/media/platform/davinci/vpbe_venc.c
+++ b/drivers/media/platform/davinci/vpbe_venc.c
@@ -9,10 +9,6 @@
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */ 12 */
17#include <linux/module.h> 13#include <linux/module.h>
18#include <linux/kernel.h> 14#include <linux/kernel.h>
diff --git a/drivers/media/platform/davinci/vpbe_venc_regs.h b/drivers/media/platform/davinci/vpbe_venc_regs.h
index 947cb1510776..6ad38f7ab0fe 100644
--- a/drivers/media/platform/davinci/vpbe_venc_regs.h
+++ b/drivers/media/platform/davinci/vpbe_venc_regs.h
@@ -9,10 +9,6 @@
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */ 12 */
17#ifndef _VPBE_VENC_REGS_H 13#ifndef _VPBE_VENC_REGS_H
18#define _VPBE_VENC_REGS_H 14#define _VPBE_VENC_REGS_H
diff --git a/drivers/media/platform/davinci/vpfe_capture.c b/drivers/media/platform/davinci/vpfe_capture.c
index ee1cd79739c8..e3fe3e0635aa 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -11,10 +11,6 @@
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Driver name : VPFE Capture driver 14 * Driver name : VPFE Capture driver
19 * VPFE Capture driver allows applications to capture and stream video 15 * VPFE Capture driver allows applications to capture and stream video
20 * frames on DaVinci SoCs (DM6446, DM355 etc) from a YUV source such as 16 * frames on DaVinci SoCs (DM6446, DM355 etc) from a YUV source such as
@@ -523,6 +519,8 @@ static int vpfe_open(struct file *file)
523 if (!vpfe_dev->initialized) { 519 if (!vpfe_dev->initialized) {
524 if (vpfe_initialize_device(vpfe_dev)) { 520 if (vpfe_initialize_device(vpfe_dev)) {
525 mutex_unlock(&vpfe_dev->lock); 521 mutex_unlock(&vpfe_dev->lock);
522 v4l2_fh_exit(&fh->fh);
523 kfree(fh);
526 return -ENODEV; 524 return -ENODEV;
527 } 525 }
528 } 526 }
diff --git a/drivers/media/platform/davinci/vpif.c b/drivers/media/platform/davinci/vpif.c
index 0380cf2e5775..1b02a6363f77 100644
--- a/drivers/media/platform/davinci/vpif.c
+++ b/drivers/media/platform/davinci/vpif.c
@@ -32,6 +32,9 @@
32MODULE_DESCRIPTION("TI DaVinci Video Port Interface driver"); 32MODULE_DESCRIPTION("TI DaVinci Video Port Interface driver");
33MODULE_LICENSE("GPL"); 33MODULE_LICENSE("GPL");
34 34
35#define VPIF_DRIVER_NAME "vpif"
36MODULE_ALIAS("platform:" VPIF_DRIVER_NAME);
37
35#define VPIF_CH0_MAX_MODES 22 38#define VPIF_CH0_MAX_MODES 22
36#define VPIF_CH1_MAX_MODES 2 39#define VPIF_CH1_MAX_MODES 2
37#define VPIF_CH2_MAX_MODES 15 40#define VPIF_CH2_MAX_MODES 15
@@ -464,9 +467,18 @@ static const struct dev_pm_ops vpif_pm = {
464#define vpif_pm_ops NULL 467#define vpif_pm_ops NULL
465#endif 468#endif
466 469
470#if IS_ENABLED(CONFIG_OF)
471static const struct of_device_id vpif_of_match[] = {
472 { .compatible = "ti,da850-vpif", },
473 { /* sentinel */ },
474};
475MODULE_DEVICE_TABLE(of, vpif_of_match);
476#endif
477
467static struct platform_driver vpif_driver = { 478static struct platform_driver vpif_driver = {
468 .driver = { 479 .driver = {
469 .name = "vpif", 480 .of_match_table = of_match_ptr(vpif_of_match),
481 .name = VPIF_DRIVER_NAME,
470 .pm = vpif_pm_ops, 482 .pm = vpif_pm_ops,
471 }, 483 },
472 .remove = vpif_remove, 484 .remove = vpif_remove,
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
index f791f5c402bf..44f702752d3a 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * TODO : add support for VBI & HBI data service 15 * TODO : add support for VBI & HBI data service
20 * add static buffer allocation 16 * add static buffer allocation
21 */ 17 */
@@ -45,6 +41,7 @@ module_param(debug, int, 0644);
45MODULE_PARM_DESC(debug, "Debug level 0-1"); 41MODULE_PARM_DESC(debug, "Debug level 0-1");
46 42
47#define VPIF_DRIVER_NAME "vpif_capture" 43#define VPIF_DRIVER_NAME "vpif_capture"
44MODULE_ALIAS("platform:" VPIF_DRIVER_NAME);
48 45
49/* global variables */ 46/* global variables */
50static struct vpif_device vpif_obj = { {NULL} }; 47static struct vpif_device vpif_obj = { {NULL} };
@@ -178,8 +175,6 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count)
178 unsigned long addr, flags; 175 unsigned long addr, flags;
179 int ret; 176 int ret;
180 177
181 spin_lock_irqsave(&common->irqlock, flags);
182
183 /* Initialize field_id */ 178 /* Initialize field_id */
184 ch->field_id = 0; 179 ch->field_id = 0;
185 180
@@ -210,6 +205,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count)
210 vpif_config_addr(ch, ret); 205 vpif_config_addr(ch, ret);
211 206
212 /* Get the next frame from the buffer queue */ 207 /* Get the next frame from the buffer queue */
208 spin_lock_irqsave(&common->irqlock, flags);
213 common->cur_frm = common->next_frm = list_entry(common->dma_queue.next, 209 common->cur_frm = common->next_frm = list_entry(common->dma_queue.next,
214 struct vpif_cap_buffer, list); 210 struct vpif_cap_buffer, list);
215 /* Remove buffer from the buffer queue */ 211 /* Remove buffer from the buffer queue */
@@ -243,6 +239,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count)
243 return 0; 239 return 0;
244 240
245err: 241err:
242 spin_lock_irqsave(&common->irqlock, flags);
246 list_for_each_entry_safe(buf, tmp, &common->dma_queue, list) { 243 list_for_each_entry_safe(buf, tmp, &common->dma_queue, list) {
247 list_del(&buf->list); 244 list_del(&buf->list);
248 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_QUEUED); 245 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_QUEUED);
@@ -286,7 +283,6 @@ static void vpif_stop_streaming(struct vb2_queue *vq)
286 vpif_dbg(1, debug, "stream off failed in subdev\n"); 283 vpif_dbg(1, debug, "stream off failed in subdev\n");
287 284
288 /* release all active buffers */ 285 /* release all active buffers */
289 spin_lock_irqsave(&common->irqlock, flags);
290 if (common->cur_frm == common->next_frm) { 286 if (common->cur_frm == common->next_frm) {
291 vb2_buffer_done(&common->cur_frm->vb.vb2_buf, 287 vb2_buffer_done(&common->cur_frm->vb.vb2_buf,
292 VB2_BUF_STATE_ERROR); 288 VB2_BUF_STATE_ERROR);
@@ -299,6 +295,7 @@ static void vpif_stop_streaming(struct vb2_queue *vq)
299 VB2_BUF_STATE_ERROR); 295 VB2_BUF_STATE_ERROR);
300 } 296 }
301 297
298 spin_lock_irqsave(&common->irqlock, flags);
302 while (!list_empty(&common->dma_queue)) { 299 while (!list_empty(&common->dma_queue)) {
303 common->next_frm = list_entry(common->dma_queue.next, 300 common->next_frm = list_entry(common->dma_queue.next,
304 struct vpif_cap_buffer, list); 301 struct vpif_cap_buffer, list);
@@ -647,6 +644,10 @@ static int vpif_input_to_subdev(
647 644
648 vpif_dbg(2, debug, "vpif_input_to_subdev\n"); 645 vpif_dbg(2, debug, "vpif_input_to_subdev\n");
649 646
647 if (!chan_cfg)
648 return -1;
649 if (input_index >= chan_cfg->input_count)
650 return -1;
650 subdev_name = chan_cfg->inputs[input_index].subdev_name; 651 subdev_name = chan_cfg->inputs[input_index].subdev_name;
651 if (!subdev_name) 652 if (!subdev_name)
652 return -1; 653 return -1;
@@ -685,6 +686,9 @@ static int vpif_set_input(
685 if (sd_index >= 0) { 686 if (sd_index >= 0) {
686 sd = vpif_obj.sd[sd_index]; 687 sd = vpif_obj.sd[sd_index];
687 subdev_info = &vpif_cfg->subdev_info[sd_index]; 688 subdev_info = &vpif_cfg->subdev_info[sd_index];
689 } else {
690 /* no subdevice, no input to setup */
691 return 0;
688 } 692 }
689 693
690 /* first setup input path from sub device to vpif */ 694 /* first setup input path from sub device to vpif */
@@ -1430,6 +1434,11 @@ static __init int vpif_probe(struct platform_device *pdev)
1430 int res_idx = 0; 1434 int res_idx = 0;
1431 int i, err; 1435 int i, err;
1432 1436
1437 if (!pdev->dev.platform_data) {
1438 dev_warn(&pdev->dev, "Missing platform data. Giving up.\n");
1439 return -EINVAL;
1440 }
1441
1433 vpif_dev = &pdev->dev; 1442 vpif_dev = &pdev->dev;
1434 1443
1435 err = initialize_vpif(); 1444 err = initialize_vpif();
@@ -1466,7 +1475,10 @@ static __init int vpif_probe(struct platform_device *pdev)
1466 } 1475 }
1467 1476
1468 if (!vpif_obj.config->asd_sizes) { 1477 if (!vpif_obj.config->asd_sizes) {
1469 i2c_adap = i2c_get_adapter(1); 1478 int i2c_id = vpif_obj.config->i2c_adapter_id;
1479
1480 i2c_adap = i2c_get_adapter(i2c_id);
1481 WARN_ON(!i2c_adap);
1470 for (i = 0; i < subdev_count; i++) { 1482 for (i = 0; i < subdev_count; i++) {
1471 subdevdata = &vpif_obj.config->subdev_info[i]; 1483 subdevdata = &vpif_obj.config->subdev_info[i];
1472 vpif_obj.sd[i] = 1484 vpif_obj.sd[i] =
diff --git a/drivers/media/platform/davinci/vpif_capture.h b/drivers/media/platform/davinci/vpif_capture.h
index 9e35b6771d22..cf494a596a44 100644
--- a/drivers/media/platform/davinci/vpif_capture.h
+++ b/drivers/media/platform/davinci/vpif_capture.h
@@ -10,10 +10,6 @@
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */ 13 */
18 14
19#ifndef VPIF_CAPTURE_H 15#ifndef VPIF_CAPTURE_H
@@ -67,7 +63,7 @@ struct common_obj {
67 struct vb2_queue buffer_queue; 63 struct vb2_queue buffer_queue;
68 /* Queue of filled frames */ 64 /* Queue of filled frames */
69 struct list_head dma_queue; 65 struct list_head dma_queue;
70 /* Used in video-buf */ 66 /* Protects the dma_queue field */
71 spinlock_t irqlock; 67 spinlock_t irqlock;
72 /* lock used to access this structure */ 68 /* lock used to access this structure */
73 struct mutex lock; 69 struct mutex lock;
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
index e5f18448dbf7..50c30731bb78 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -42,6 +42,7 @@ module_param(debug, int, 0644);
42MODULE_PARM_DESC(debug, "Debug level 0-1"); 42MODULE_PARM_DESC(debug, "Debug level 0-1");
43 43
44#define VPIF_DRIVER_NAME "vpif_display" 44#define VPIF_DRIVER_NAME "vpif_display"
45MODULE_ALIAS("platform:" VPIF_DRIVER_NAME);
45 46
46/* Is set to 1 in case of SDTV formats, 2 in case of HDTV formats. */ 47/* Is set to 1 in case of SDTV formats, 2 in case of HDTV formats. */
47static int ycmux_mode; 48static int ycmux_mode;
@@ -1244,6 +1245,11 @@ static __init int vpif_probe(struct platform_device *pdev)
1244 int res_idx = 0; 1245 int res_idx = 0;
1245 int i, err; 1246 int i, err;
1246 1247
1248 if (!pdev->dev.platform_data) {
1249 dev_warn(&pdev->dev, "Missing platform data. Giving up.\n");
1250 return -EINVAL;
1251 }
1252
1247 vpif_dev = &pdev->dev; 1253 vpif_dev = &pdev->dev;
1248 err = initialize_vpif(); 1254 err = initialize_vpif();
1249 1255
diff --git a/drivers/media/platform/davinci/vpss.c b/drivers/media/platform/davinci/vpss.c
index 373b796132f2..f2d27b932999 100644
--- a/drivers/media/platform/davinci/vpss.c
+++ b/drivers/media/platform/davinci/vpss.c
@@ -11,10 +11,6 @@
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 *
18 * common vpss system module platform driver for all video drivers. 14 * common vpss system module platform driver for all video drivers.
19 */ 15 */
20#include <linux/module.h> 16#include <linux/module.h>
diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c b/drivers/media/platform/exynos-gsc/gsc-core.c
index cbf75b6194b4..cbb03768f5d7 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.c
+++ b/drivers/media/platform/exynos-gsc/gsc-core.c
@@ -408,7 +408,7 @@ int gsc_try_fmt_mplane(struct gsc_ctx *ctx, struct v4l2_format *f)
408 if (pix_mp->field == V4L2_FIELD_ANY) 408 if (pix_mp->field == V4L2_FIELD_ANY)
409 pix_mp->field = V4L2_FIELD_NONE; 409 pix_mp->field = V4L2_FIELD_NONE;
410 else if (pix_mp->field != V4L2_FIELD_NONE) { 410 else if (pix_mp->field != V4L2_FIELD_NONE) {
411 pr_err("Not supported field order(%d)\n", pix_mp->field); 411 pr_debug("Not supported field order(%d)\n", pix_mp->field);
412 return -EINVAL; 412 return -EINVAL;
413 } 413 }
414 414
@@ -1118,6 +1118,7 @@ static int gsc_remove(struct platform_device *pdev)
1118 clk_disable_unprepare(gsc->clock[i]); 1118 clk_disable_unprepare(gsc->clock[i]);
1119 1119
1120 pm_runtime_put_noidle(&pdev->dev); 1120 pm_runtime_put_noidle(&pdev->dev);
1121 pm_runtime_disable(&pdev->dev);
1121 1122
1122 dev_dbg(&pdev->dev, "%s driver unloaded\n", pdev->name); 1123 dev_dbg(&pdev->dev, "%s driver unloaded\n", pdev->name);
1123 return 0; 1124 return 0;
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index f49f24b4462a..82505025d96c 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -675,8 +675,8 @@ static int gsc_m2m_open(struct file *file)
675 675
676error_ctrls: 676error_ctrls:
677 gsc_ctrls_delete(ctx); 677 gsc_ctrls_delete(ctx);
678error_fh:
679 v4l2_fh_del(&ctx->fh); 678 v4l2_fh_del(&ctx->fh);
679error_fh:
680 v4l2_fh_exit(&ctx->fh); 680 v4l2_fh_exit(&ctx->fh);
681 kfree(ctx); 681 kfree(ctx);
682unlock: 682unlock:
diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c
index 964f4a681934..8a7cd07dbe28 100644
--- a/drivers/media/platform/exynos4-is/fimc-capture.c
+++ b/drivers/media/platform/exynos4-is/fimc-capture.c
@@ -536,7 +536,7 @@ static int fimc_capture_release(struct file *file)
536 mutex_lock(&fimc->lock); 536 mutex_lock(&fimc->lock);
537 537
538 if (close && vc->streaming) { 538 if (close && vc->streaming) {
539 media_entity_pipeline_stop(&vc->ve.vdev.entity); 539 media_pipeline_stop(&vc->ve.vdev.entity);
540 vc->streaming = false; 540 vc->streaming = false;
541 } 541 }
542 542
@@ -1195,7 +1195,7 @@ static int fimc_cap_streamon(struct file *file, void *priv,
1195 if (fimc_capture_active(fimc)) 1195 if (fimc_capture_active(fimc))
1196 return -EBUSY; 1196 return -EBUSY;
1197 1197
1198 ret = media_entity_pipeline_start(entity, &vc->ve.pipe->mp); 1198 ret = media_pipeline_start(entity, &vc->ve.pipe->mp);
1199 if (ret < 0) 1199 if (ret < 0)
1200 return ret; 1200 return ret;
1201 1201
@@ -1229,7 +1229,7 @@ static int fimc_cap_streamon(struct file *file, void *priv,
1229 } 1229 }
1230 1230
1231err_p_stop: 1231err_p_stop:
1232 media_entity_pipeline_stop(entity); 1232 media_pipeline_stop(entity);
1233 return ret; 1233 return ret;
1234} 1234}
1235 1235
@@ -1244,7 +1244,7 @@ static int fimc_cap_streamoff(struct file *file, void *priv,
1244 if (ret < 0) 1244 if (ret < 0)
1245 return ret; 1245 return ret;
1246 1246
1247 media_entity_pipeline_stop(&vc->ve.vdev.entity); 1247 media_pipeline_stop(&vc->ve.vdev.entity);
1248 vc->streaming = false; 1248 vc->streaming = false;
1249 return 0; 1249 return 0;
1250} 1250}
@@ -1695,7 +1695,7 @@ static int fimc_subdev_set_selection(struct v4l2_subdev *sd,
1695 return 0; 1695 return 0;
1696} 1696}
1697 1697
1698static struct v4l2_subdev_pad_ops fimc_subdev_pad_ops = { 1698static const struct v4l2_subdev_pad_ops fimc_subdev_pad_ops = {
1699 .enum_mbus_code = fimc_subdev_enum_mbus_code, 1699 .enum_mbus_code = fimc_subdev_enum_mbus_code,
1700 .get_selection = fimc_subdev_get_selection, 1700 .get_selection = fimc_subdev_get_selection,
1701 .set_selection = fimc_subdev_set_selection, 1701 .set_selection = fimc_subdev_set_selection,
@@ -1703,7 +1703,7 @@ static struct v4l2_subdev_pad_ops fimc_subdev_pad_ops = {
1703 .set_fmt = fimc_subdev_set_fmt, 1703 .set_fmt = fimc_subdev_set_fmt,
1704}; 1704};
1705 1705
1706static struct v4l2_subdev_ops fimc_subdev_ops = { 1706static const struct v4l2_subdev_ops fimc_subdev_ops = {
1707 .pad = &fimc_subdev_pad_ops, 1707 .pad = &fimc_subdev_pad_ops,
1708}; 1708};
1709 1709
diff --git a/drivers/media/platform/exynos4-is/fimc-is-i2c.c b/drivers/media/platform/exynos4-is/fimc-is-i2c.c
index 6bba4ca022be..2f559663e51e 100644
--- a/drivers/media/platform/exynos4-is/fimc-is-i2c.c
+++ b/drivers/media/platform/exynos4-is/fimc-is-i2c.c
@@ -28,7 +28,14 @@ struct fimc_is_i2c {
28 * is implemented in the FIMC-IS subsystem firmware and the host CPU 28 * is implemented in the FIMC-IS subsystem firmware and the host CPU
29 * doesn't access the I2C bus controller. 29 * doesn't access the I2C bus controller.
30 */ 30 */
31static const struct i2c_algorithm fimc_is_i2c_algorithm; 31static u32 is_i2c_func(struct i2c_adapter *adap)
32{
33 return I2C_FUNC_I2C;
34}
35
36static const struct i2c_algorithm fimc_is_i2c_algorithm = {
37 .functionality = is_i2c_func,
38};
32 39
33static int fimc_is_i2c_probe(struct platform_device *pdev) 40static int fimc_is_i2c_probe(struct platform_device *pdev)
34{ 41{
diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c
index 518ad34f80d7..7f92144a1de3 100644
--- a/drivers/media/platform/exynos4-is/fimc-is.c
+++ b/drivers/media/platform/exynos4-is/fimc-is.c
@@ -825,12 +825,13 @@ static int fimc_is_probe(struct platform_device *pdev)
825 is->irq = irq_of_parse_and_map(dev->of_node, 0); 825 is->irq = irq_of_parse_and_map(dev->of_node, 0);
826 if (!is->irq) { 826 if (!is->irq) {
827 dev_err(dev, "no irq found\n"); 827 dev_err(dev, "no irq found\n");
828 return -EINVAL; 828 ret = -EINVAL;
829 goto err_iounmap;
829 } 830 }
830 831
831 ret = fimc_is_get_clocks(is); 832 ret = fimc_is_get_clocks(is);
832 if (ret < 0) 833 if (ret < 0)
833 return ret; 834 goto err_iounmap;
834 835
835 platform_set_drvdata(pdev, is); 836 platform_set_drvdata(pdev, is);
836 837
@@ -891,6 +892,8 @@ err_irq:
891 free_irq(is->irq, is); 892 free_irq(is->irq, is);
892err_clk: 893err_clk:
893 fimc_is_put_clocks(is); 894 fimc_is_put_clocks(is);
895err_iounmap:
896 iounmap(is->pmu_regs);
894 return ret; 897 return ret;
895} 898}
896 899
@@ -947,6 +950,7 @@ static int fimc_is_remove(struct platform_device *pdev)
947 fimc_is_unregister_subdevs(is); 950 fimc_is_unregister_subdevs(is);
948 vb2_dma_contig_clear_max_seg_size(dev); 951 vb2_dma_contig_clear_max_seg_size(dev);
949 fimc_is_put_clocks(is); 952 fimc_is_put_clocks(is);
953 iounmap(is->pmu_regs);
950 fimc_is_debugfs_remove(is); 954 fimc_is_debugfs_remove(is);
951 release_firmware(is->fw.f_w); 955 release_firmware(is->fw.f_w);
952 fimc_is_free_cpu_memory(is); 956 fimc_is_free_cpu_memory(is);
diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c b/drivers/media/platform/exynos4-is/fimc-isp-video.c
index 400ce0cb0c0d..55ba696b8cf4 100644
--- a/drivers/media/platform/exynos4-is/fimc-isp-video.c
+++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c
@@ -312,7 +312,7 @@ static int isp_video_release(struct file *file)
312 mutex_lock(&isp->video_lock); 312 mutex_lock(&isp->video_lock);
313 313
314 if (v4l2_fh_is_singular_file(file) && ivc->streaming) { 314 if (v4l2_fh_is_singular_file(file) && ivc->streaming) {
315 media_entity_pipeline_stop(entity); 315 media_pipeline_stop(entity);
316 ivc->streaming = 0; 316 ivc->streaming = 0;
317 } 317 }
318 318
@@ -489,7 +489,7 @@ static int isp_video_streamon(struct file *file, void *priv,
489 struct media_entity *me = &ve->vdev.entity; 489 struct media_entity *me = &ve->vdev.entity;
490 int ret; 490 int ret;
491 491
492 ret = media_entity_pipeline_start(me, &ve->pipe->mp); 492 ret = media_pipeline_start(me, &ve->pipe->mp);
493 if (ret < 0) 493 if (ret < 0)
494 return ret; 494 return ret;
495 495
@@ -504,7 +504,7 @@ static int isp_video_streamon(struct file *file, void *priv,
504 isp->video_capture.streaming = 1; 504 isp->video_capture.streaming = 1;
505 return 0; 505 return 0;
506p_stop: 506p_stop:
507 media_entity_pipeline_stop(me); 507 media_pipeline_stop(me);
508 return ret; 508 return ret;
509} 509}
510 510
@@ -519,7 +519,7 @@ static int isp_video_streamoff(struct file *file, void *priv,
519 if (ret < 0) 519 if (ret < 0)
520 return ret; 520 return ret;
521 521
522 media_entity_pipeline_stop(&video->ve.vdev.entity); 522 media_pipeline_stop(&video->ve.vdev.entity);
523 video->streaming = 0; 523 video->streaming = 0;
524 return 0; 524 return 0;
525} 525}
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c
index b91abf1c4d43..b4c4a33784c4 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -524,7 +524,7 @@ static int fimc_lite_release(struct file *file)
524 if (v4l2_fh_is_singular_file(file) && 524 if (v4l2_fh_is_singular_file(file) &&
525 atomic_read(&fimc->out_path) == FIMC_IO_DMA) { 525 atomic_read(&fimc->out_path) == FIMC_IO_DMA) {
526 if (fimc->streaming) { 526 if (fimc->streaming) {
527 media_entity_pipeline_stop(entity); 527 media_pipeline_stop(entity);
528 fimc->streaming = false; 528 fimc->streaming = false;
529 } 529 }
530 fimc_lite_stop_capture(fimc, false); 530 fimc_lite_stop_capture(fimc, false);
@@ -832,7 +832,7 @@ static int fimc_lite_streamon(struct file *file, void *priv,
832 if (fimc_lite_active(fimc)) 832 if (fimc_lite_active(fimc))
833 return -EBUSY; 833 return -EBUSY;
834 834
835 ret = media_entity_pipeline_start(entity, &fimc->ve.pipe->mp); 835 ret = media_pipeline_start(entity, &fimc->ve.pipe->mp);
836 if (ret < 0) 836 if (ret < 0)
837 return ret; 837 return ret;
838 838
@@ -849,7 +849,7 @@ static int fimc_lite_streamon(struct file *file, void *priv,
849 } 849 }
850 850
851err_p_stop: 851err_p_stop:
852 media_entity_pipeline_stop(entity); 852 media_pipeline_stop(entity);
853 return 0; 853 return 0;
854} 854}
855 855
@@ -863,7 +863,7 @@ static int fimc_lite_streamoff(struct file *file, void *priv,
863 if (ret < 0) 863 if (ret < 0)
864 return ret; 864 return ret;
865 865
866 media_entity_pipeline_stop(&fimc->ve.vdev.entity); 866 media_pipeline_stop(&fimc->ve.vdev.entity);
867 fimc->streaming = false; 867 fimc->streaming = false;
868 return 0; 868 return 0;
869} 869}
diff --git a/drivers/media/platform/exynos4-is/fimc-m2m.c b/drivers/media/platform/exynos4-is/fimc-m2m.c
index 6028e4fbaed3..d8724fe9e9da 100644
--- a/drivers/media/platform/exynos4-is/fimc-m2m.c
+++ b/drivers/media/platform/exynos4-is/fimc-m2m.c
@@ -663,8 +663,8 @@ error_m2m_ctx:
663 v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); 663 v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
664error_c: 664error_c:
665 fimc_ctrls_delete(ctx); 665 fimc_ctrls_delete(ctx);
666error_fh:
667 v4l2_fh_del(&ctx->fh); 666 v4l2_fh_del(&ctx->fh);
667error_fh:
668 v4l2_fh_exit(&ctx->fh); 668 v4l2_fh_exit(&ctx->fh);
669 kfree(ctx); 669 kfree(ctx);
670unlock: 670unlock:
diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index e3a8709138fa..e82450e90a67 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -402,8 +402,10 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
402 return ret; 402 return ret;
403 } 403 }
404 404
405 if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS) 405 if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS) {
406 of_node_put(ep);
406 return -EINVAL; 407 return -EINVAL;
408 }
407 409
408 pd->mux_id = (endpoint.base.port - 1) & 0x1; 410 pd->mux_id = (endpoint.base.port - 1) & 0x1;
409 411
@@ -1117,7 +1119,7 @@ static int __fimc_md_modify_pipeline(struct media_entity *entity, bool enable)
1117 1119
1118/* Locking: called with entity->graph_obj.mdev->graph_mutex mutex held. */ 1120/* Locking: called with entity->graph_obj.mdev->graph_mutex mutex held. */
1119static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable, 1121static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable,
1120 struct media_entity_graph *graph) 1122 struct media_graph *graph)
1121{ 1123{
1122 struct media_entity *entity_err = entity; 1124 struct media_entity *entity_err = entity;
1123 int ret; 1125 int ret;
@@ -1128,9 +1130,9 @@ static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable,
1128 * through active links. This is needed as we cannot power on/off the 1130 * through active links. This is needed as we cannot power on/off the
1129 * subdevs in random order. 1131 * subdevs in random order.
1130 */ 1132 */
1131 media_entity_graph_walk_start(graph, entity); 1133 media_graph_walk_start(graph, entity);
1132 1134
1133 while ((entity = media_entity_graph_walk_next(graph))) { 1135 while ((entity = media_graph_walk_next(graph))) {
1134 if (!is_media_entity_v4l2_video_device(entity)) 1136 if (!is_media_entity_v4l2_video_device(entity))
1135 continue; 1137 continue;
1136 1138
@@ -1143,9 +1145,9 @@ static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable,
1143 return 0; 1145 return 0;
1144 1146
1145err: 1147err:
1146 media_entity_graph_walk_start(graph, entity_err); 1148 media_graph_walk_start(graph, entity_err);
1147 1149
1148 while ((entity_err = media_entity_graph_walk_next(graph))) { 1150 while ((entity_err = media_graph_walk_next(graph))) {
1149 if (!is_media_entity_v4l2_video_device(entity_err)) 1151 if (!is_media_entity_v4l2_video_device(entity_err))
1150 continue; 1152 continue;
1151 1153
@@ -1161,7 +1163,7 @@ err:
1161static int fimc_md_link_notify(struct media_link *link, unsigned int flags, 1163static int fimc_md_link_notify(struct media_link *link, unsigned int flags,
1162 unsigned int notification) 1164 unsigned int notification)
1163{ 1165{
1164 struct media_entity_graph *graph = 1166 struct media_graph *graph =
1165 &container_of(link->graph_obj.mdev, struct fimc_md, 1167 &container_of(link->graph_obj.mdev, struct fimc_md,
1166 media_dev)->link_setup_graph; 1168 media_dev)->link_setup_graph;
1167 struct media_entity *sink = link->sink->entity; 1169 struct media_entity *sink = link->sink->entity;
@@ -1169,7 +1171,7 @@ static int fimc_md_link_notify(struct media_link *link, unsigned int flags,
1169 1171
1170 /* Before link disconnection */ 1172 /* Before link disconnection */
1171 if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH) { 1173 if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH) {
1172 ret = media_entity_graph_walk_init(graph, 1174 ret = media_graph_walk_init(graph,
1173 link->graph_obj.mdev); 1175 link->graph_obj.mdev);
1174 if (ret) 1176 if (ret)
1175 return ret; 1177 return ret;
@@ -1183,7 +1185,7 @@ static int fimc_md_link_notify(struct media_link *link, unsigned int flags,
1183 } else if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH) { 1185 } else if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH) {
1184 if (link->flags & MEDIA_LNK_FL_ENABLED) 1186 if (link->flags & MEDIA_LNK_FL_ENABLED)
1185 ret = __fimc_md_modify_pipelines(sink, true, graph); 1187 ret = __fimc_md_modify_pipelines(sink, true, graph);
1186 media_entity_graph_walk_cleanup(graph); 1188 media_graph_walk_cleanup(graph);
1187 } 1189 }
1188 1190
1189 return ret ? -EPIPE : 0; 1191 return ret ? -EPIPE : 0;
diff --git a/drivers/media/platform/exynos4-is/media-dev.h b/drivers/media/platform/exynos4-is/media-dev.h
index ed122cb2dd74..957787a2f480 100644
--- a/drivers/media/platform/exynos4-is/media-dev.h
+++ b/drivers/media/platform/exynos4-is/media-dev.h
@@ -154,7 +154,7 @@ struct fimc_md {
154 bool user_subdev_api; 154 bool user_subdev_api;
155 spinlock_t slock; 155 spinlock_t slock;
156 struct list_head pipelines; 156 struct list_head pipelines;
157 struct media_entity_graph link_setup_graph; 157 struct media_graph link_setup_graph;
158}; 158};
159 159
160static inline 160static inline
diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c
index befd9fc0adc4..f819b29efc38 100644
--- a/drivers/media/platform/exynos4-is/mipi-csis.c
+++ b/drivers/media/platform/exynos4-is/mipi-csis.c
@@ -649,23 +649,23 @@ static int s5pcsis_log_status(struct v4l2_subdev *sd)
649 return 0; 649 return 0;
650} 650}
651 651
652static struct v4l2_subdev_core_ops s5pcsis_core_ops = { 652static const struct v4l2_subdev_core_ops s5pcsis_core_ops = {
653 .s_power = s5pcsis_s_power, 653 .s_power = s5pcsis_s_power,
654 .log_status = s5pcsis_log_status, 654 .log_status = s5pcsis_log_status,
655}; 655};
656 656
657static struct v4l2_subdev_pad_ops s5pcsis_pad_ops = { 657static const struct v4l2_subdev_pad_ops s5pcsis_pad_ops = {
658 .enum_mbus_code = s5pcsis_enum_mbus_code, 658 .enum_mbus_code = s5pcsis_enum_mbus_code,
659 .get_fmt = s5pcsis_get_fmt, 659 .get_fmt = s5pcsis_get_fmt,
660 .set_fmt = s5pcsis_set_fmt, 660 .set_fmt = s5pcsis_set_fmt,
661}; 661};
662 662
663static struct v4l2_subdev_video_ops s5pcsis_video_ops = { 663static const struct v4l2_subdev_video_ops s5pcsis_video_ops = {
664 .s_rx_buffer = s5pcsis_s_rx_buffer, 664 .s_rx_buffer = s5pcsis_s_rx_buffer,
665 .s_stream = s5pcsis_s_stream, 665 .s_stream = s5pcsis_s_stream,
666}; 666};
667 667
668static struct v4l2_subdev_ops s5pcsis_subdev_ops = { 668static const struct v4l2_subdev_ops s5pcsis_subdev_ops = {
669 .core = &s5pcsis_core_ops, 669 .core = &s5pcsis_core_ops,
670 .pad = &s5pcsis_pad_ops, 670 .pad = &s5pcsis_pad_ops,
671 .video = &s5pcsis_video_ops, 671 .video = &s5pcsis_video_ops,
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
index 074659227864..502877a4b1df 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -351,16 +351,6 @@ static void mtk_vdec_worker(struct work_struct *work)
351 dst_vb2_v4l2 = container_of(dst_buf, struct vb2_v4l2_buffer, vb2_buf); 351 dst_vb2_v4l2 = container_of(dst_buf, struct vb2_v4l2_buffer, vb2_buf);
352 dst_buf_info = container_of(dst_vb2_v4l2, struct mtk_video_dec_buf, vb); 352 dst_buf_info = container_of(dst_vb2_v4l2, struct mtk_video_dec_buf, vb);
353 353
354 buf.va = vb2_plane_vaddr(src_buf, 0);
355 buf.dma_addr = vb2_dma_contig_plane_dma_addr(src_buf, 0);
356 buf.size = (size_t)src_buf->planes[0].bytesused;
357 if (!buf.va) {
358 v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
359 mtk_v4l2_err("[%d] id=%d src_addr is NULL!!",
360 ctx->id, src_buf->index);
361 return;
362 }
363
364 pfb = &dst_buf_info->frame_buffer; 354 pfb = &dst_buf_info->frame_buffer;
365 pfb->base_y.va = vb2_plane_vaddr(dst_buf, 0); 355 pfb->base_y.va = vb2_plane_vaddr(dst_buf, 0);
366 pfb->base_y.dma_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 0); 356 pfb->base_y.dma_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 0);
@@ -371,8 +361,6 @@ static void mtk_vdec_worker(struct work_struct *work)
371 pfb->base_c.size = ctx->picinfo.c_bs_sz + ctx->picinfo.c_len_sz; 361 pfb->base_c.size = ctx->picinfo.c_bs_sz + ctx->picinfo.c_len_sz;
372 pfb->status = 0; 362 pfb->status = 0;
373 mtk_v4l2_debug(3, "===>[%d] vdec_if_decode() ===>", ctx->id); 363 mtk_v4l2_debug(3, "===>[%d] vdec_if_decode() ===>", ctx->id);
374 mtk_v4l2_debug(3, "[%d] Bitstream VA=%p DMA=%pad Size=%zx vb=%p",
375 ctx->id, buf.va, &buf.dma_addr, buf.size, src_buf);
376 364
377 mtk_v4l2_debug(3, 365 mtk_v4l2_debug(3,
378 "id=%d Framebuf pfb=%p VA=%p Y_DMA=%pad C_DMA=%pad Size=%zx", 366 "id=%d Framebuf pfb=%p VA=%p Y_DMA=%pad C_DMA=%pad Size=%zx",
@@ -381,24 +369,36 @@ static void mtk_vdec_worker(struct work_struct *work)
381 &pfb->base_c.dma_addr, pfb->base_y.size); 369 &pfb->base_c.dma_addr, pfb->base_y.size);
382 370
383 if (src_buf_info->lastframe) { 371 if (src_buf_info->lastframe) {
384 /* update src buf status */ 372 mtk_v4l2_debug(1, "Got empty flush input buffer.");
385 src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx); 373 src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
386 src_buf_info->lastframe = false;
387 v4l2_m2m_buf_done(&src_buf_info->vb, VB2_BUF_STATE_DONE);
388 374
389 /* update dst buf status */ 375 /* update dst buf status */
390 dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx); 376 dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
377 mutex_lock(&ctx->lock);
391 dst_buf_info->used = false; 378 dst_buf_info->used = false;
379 mutex_unlock(&ctx->lock);
392 380
393 vdec_if_decode(ctx, NULL, NULL, &res_chg); 381 vdec_if_decode(ctx, NULL, NULL, &res_chg);
394 clean_display_buffer(ctx); 382 clean_display_buffer(ctx);
395 vb2_set_plane_payload(&dst_buf_info->vb.vb2_buf, 0, 0); 383 vb2_set_plane_payload(&dst_buf_info->vb.vb2_buf, 0, 0);
396 vb2_set_plane_payload(&dst_buf_info->vb.vb2_buf, 1, 0); 384 vb2_set_plane_payload(&dst_buf_info->vb.vb2_buf, 1, 0);
385 dst_vb2_v4l2->flags |= V4L2_BUF_FLAG_LAST;
397 v4l2_m2m_buf_done(&dst_buf_info->vb, VB2_BUF_STATE_DONE); 386 v4l2_m2m_buf_done(&dst_buf_info->vb, VB2_BUF_STATE_DONE);
398 clean_free_buffer(ctx); 387 clean_free_buffer(ctx);
399 v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx); 388 v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
400 return; 389 return;
401 } 390 }
391 buf.va = vb2_plane_vaddr(src_buf, 0);
392 buf.dma_addr = vb2_dma_contig_plane_dma_addr(src_buf, 0);
393 buf.size = (size_t)src_buf->planes[0].bytesused;
394 if (!buf.va) {
395 v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
396 mtk_v4l2_err("[%d] id=%d src_addr is NULL!!",
397 ctx->id, src_buf->index);
398 return;
399 }
400 mtk_v4l2_debug(3, "[%d] Bitstream VA=%p DMA=%pad Size=%zx vb=%p",
401 ctx->id, buf.va, &buf.dma_addr, buf.size, src_buf);
402 dst_buf_info->vb.vb2_buf.timestamp 402 dst_buf_info->vb.vb2_buf.timestamp
403 = src_buf_info->vb.vb2_buf.timestamp; 403 = src_buf_info->vb.vb2_buf.timestamp;
404 dst_buf_info->vb.timecode 404 dst_buf_info->vb.timecode
@@ -412,10 +412,9 @@ static void mtk_vdec_worker(struct work_struct *work)
412 412
413 if (ret) { 413 if (ret) {
414 mtk_v4l2_err( 414 mtk_v4l2_err(
415 " <===[%d], src_buf[%d]%d sz=0x%zx pts=%llu dst_buf[%d] vdec_if_decode() ret=%d res_chg=%d===>", 415 " <===[%d], src_buf[%d] sz=0x%zx pts=%llu dst_buf[%d] vdec_if_decode() ret=%d res_chg=%d===>",
416 ctx->id, 416 ctx->id,
417 src_buf->index, 417 src_buf->index,
418 src_buf_info->lastframe,
419 buf.size, 418 buf.size,
420 src_buf_info->vb.vb2_buf.timestamp, 419 src_buf_info->vb.vb2_buf.timestamp,
421 dst_buf->index, 420 dst_buf->index,
@@ -456,6 +455,65 @@ static void mtk_vdec_worker(struct work_struct *work)
456 v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx); 455 v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
457} 456}
458 457
458static int vidioc_try_decoder_cmd(struct file *file, void *priv,
459 struct v4l2_decoder_cmd *cmd)
460{
461 switch (cmd->cmd) {
462 case V4L2_DEC_CMD_STOP:
463 case V4L2_DEC_CMD_START:
464 if (cmd->flags != 0) {
465 mtk_v4l2_err("cmd->flags=%u", cmd->flags);
466 return -EINVAL;
467 }
468 break;
469 default:
470 return -EINVAL;
471 }
472 return 0;
473}
474
475
476static int vidioc_decoder_cmd(struct file *file, void *priv,
477 struct v4l2_decoder_cmd *cmd)
478{
479 struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
480 struct vb2_queue *src_vq, *dst_vq;
481 int ret;
482
483 ret = vidioc_try_decoder_cmd(file, priv, cmd);
484 if (ret)
485 return ret;
486
487 mtk_v4l2_debug(1, "decoder cmd=%u", cmd->cmd);
488 dst_vq = v4l2_m2m_get_vq(ctx->m2m_ctx,
489 V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
490 switch (cmd->cmd) {
491 case V4L2_DEC_CMD_STOP:
492 src_vq = v4l2_m2m_get_vq(ctx->m2m_ctx,
493 V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
494 if (!vb2_is_streaming(src_vq)) {
495 mtk_v4l2_debug(1, "Output stream is off. No need to flush.");
496 return 0;
497 }
498 if (!vb2_is_streaming(dst_vq)) {
499 mtk_v4l2_debug(1, "Capture stream is off. No need to flush.");
500 return 0;
501 }
502 v4l2_m2m_buf_queue(ctx->m2m_ctx, &ctx->empty_flush_buf->vb);
503 v4l2_m2m_try_schedule(ctx->m2m_ctx);
504 break;
505
506 case V4L2_DEC_CMD_START:
507 vb2_clear_last_buffer_dequeued(dst_vq);
508 break;
509
510 default:
511 return -EINVAL;
512 }
513
514 return 0;
515}
516
459void mtk_vdec_unlock(struct mtk_vcodec_ctx *ctx) 517void mtk_vdec_unlock(struct mtk_vcodec_ctx *ctx)
460{ 518{
461 mutex_unlock(&ctx->dev->dec_mutex); 519 mutex_unlock(&ctx->dev->dec_mutex);
@@ -521,10 +579,6 @@ static int vidioc_vdec_qbuf(struct file *file, void *priv,
521 struct v4l2_buffer *buf) 579 struct v4l2_buffer *buf)
522{ 580{
523 struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv); 581 struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
524 struct vb2_queue *vq;
525 struct vb2_buffer *vb;
526 struct mtk_video_dec_buf *mtkbuf;
527 struct vb2_v4l2_buffer *vb2_v4l2;
528 582
529 if (ctx->state == MTK_STATE_ABORT) { 583 if (ctx->state == MTK_STATE_ABORT) {
530 mtk_v4l2_err("[%d] Call on QBUF after unrecoverable error", 584 mtk_v4l2_err("[%d] Call on QBUF after unrecoverable error",
@@ -532,25 +586,6 @@ static int vidioc_vdec_qbuf(struct file *file, void *priv,
532 return -EIO; 586 return -EIO;
533 } 587 }
534 588
535 vq = v4l2_m2m_get_vq(ctx->m2m_ctx, buf->type);
536 if (buf->index >= vq->num_buffers) {
537 mtk_v4l2_debug(1, "buffer index %d out of range", buf->index);
538 return -EINVAL;
539 }
540 vb = vq->bufs[buf->index];
541 vb2_v4l2 = container_of(vb, struct vb2_v4l2_buffer, vb2_buf);
542 mtkbuf = container_of(vb2_v4l2, struct mtk_video_dec_buf, vb);
543
544 if ((buf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) &&
545 (buf->m.planes[0].bytesused == 0)) {
546 mtkbuf->lastframe = true;
547 mtk_v4l2_debug(1, "[%d] (%d) id=%d lastframe=%d (%d,%d, %d) vb=%p",
548 ctx->id, buf->type, buf->index,
549 mtkbuf->lastframe, buf->bytesused,
550 buf->m.planes[0].bytesused, buf->length,
551 vb);
552 }
553
554 return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf); 589 return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
555} 590}
556 591
@@ -1067,10 +1102,8 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb)
1067 int ret = 0; 1102 int ret = 0;
1068 unsigned int dpbsize = 1; 1103 unsigned int dpbsize = 1;
1069 struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); 1104 struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
1070 struct vb2_v4l2_buffer *vb2_v4l2 = container_of(vb, 1105 struct vb2_v4l2_buffer *vb2_v4l2 = NULL;
1071 struct vb2_v4l2_buffer, vb2_buf); 1106 struct mtk_video_dec_buf *buf = NULL;
1072 struct mtk_video_dec_buf *buf = container_of(vb2_v4l2,
1073 struct mtk_video_dec_buf, vb);
1074 1107
1075 mtk_v4l2_debug(3, "[%d] (%d) id=%d, vb=%p", 1108 mtk_v4l2_debug(3, "[%d] (%d) id=%d, vb=%p",
1076 ctx->id, vb->vb2_queue->type, 1109 ctx->id, vb->vb2_queue->type,
@@ -1079,10 +1112,11 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb)
1079 * check if this buffer is ready to be used after decode 1112 * check if this buffer is ready to be used after decode
1080 */ 1113 */
1081 if (vb->vb2_queue->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { 1114 if (vb->vb2_queue->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
1115 vb2_v4l2 = to_vb2_v4l2_buffer(vb);
1116 buf = container_of(vb2_v4l2, struct mtk_video_dec_buf, vb);
1082 mutex_lock(&ctx->lock); 1117 mutex_lock(&ctx->lock);
1083 if (buf->used == false) { 1118 if (buf->used == false) {
1084 v4l2_m2m_buf_queue(ctx->m2m_ctx, 1119 v4l2_m2m_buf_queue(ctx->m2m_ctx, vb2_v4l2);
1085 to_vb2_v4l2_buffer(vb));
1086 buf->queued_in_vb2 = true; 1120 buf->queued_in_vb2 = true;
1087 buf->queued_in_v4l2 = true; 1121 buf->queued_in_v4l2 = true;
1088 buf->ready_to_display = false; 1122 buf->ready_to_display = false;
@@ -1095,7 +1129,7 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb)
1095 return; 1129 return;
1096 } 1130 }
1097 1131
1098 v4l2_m2m_buf_queue(ctx->m2m_ctx, vb2_v4l2); 1132 v4l2_m2m_buf_queue(ctx->m2m_ctx, to_vb2_v4l2_buffer(vb));
1099 1133
1100 if (ctx->state != MTK_STATE_INIT) { 1134 if (ctx->state != MTK_STATE_INIT) {
1101 mtk_v4l2_debug(3, "[%d] already init driver %d", 1135 mtk_v4l2_debug(3, "[%d] already init driver %d",
@@ -1108,6 +1142,14 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb)
1108 mtk_v4l2_err("No src buffer"); 1142 mtk_v4l2_err("No src buffer");
1109 return; 1143 return;
1110 } 1144 }
1145 vb2_v4l2 = to_vb2_v4l2_buffer(src_buf);
1146 buf = container_of(vb2_v4l2, struct mtk_video_dec_buf, vb);
1147 if (buf->lastframe) {
1148 /* This shouldn't happen. Just in case. */
1149 mtk_v4l2_err("Invalid flush buffer.");
1150 v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
1151 return;
1152 }
1111 1153
1112 src_mem.va = vb2_plane_vaddr(src_buf, 0); 1154 src_mem.va = vb2_plane_vaddr(src_buf, 0);
1113 src_mem.dma_addr = vb2_dma_contig_plane_dma_addr(src_buf, 0); 1155 src_mem.dma_addr = vb2_dma_contig_plane_dma_addr(src_buf, 0);
@@ -1126,15 +1168,14 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb)
1126 * if there is no SPS header or picture info 1168 * if there is no SPS header or picture info
1127 * in bs 1169 * in bs
1128 */ 1170 */
1129 int log_level = ret ? 0 : 1;
1130 1171
1131 src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx); 1172 src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
1132 v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf), 1173 v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
1133 VB2_BUF_STATE_DONE); 1174 VB2_BUF_STATE_DONE);
1134 mtk_v4l2_debug(log_level, 1175 mtk_v4l2_debug(ret ? 0 : 1,
1135 "[%d] vdec_if_decode() src_buf=%d, size=%zu, fail=%d, res_chg=%d", 1176 "[%d] vdec_if_decode() src_buf=%d, size=%zu, fail=%d, res_chg=%d",
1136 ctx->id, src_buf->index, 1177 ctx->id, src_buf->index,
1137 src_mem.size, ret, res_chg); 1178 src_mem.size, ret, res_chg);
1138 return; 1179 return;
1139 } 1180 }
1140 1181
@@ -1224,9 +1265,15 @@ static void vb2ops_vdec_stop_streaming(struct vb2_queue *q)
1224 ctx->id, q->type, ctx->state, ctx->decoded_frame_cnt); 1265 ctx->id, q->type, ctx->state, ctx->decoded_frame_cnt);
1225 1266
1226 if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { 1267 if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
1227 while ((src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx))) 1268 while ((src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx))) {
1228 v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf), 1269 struct vb2_v4l2_buffer *vb2_v4l2 =
1229 VB2_BUF_STATE_ERROR); 1270 to_vb2_v4l2_buffer(src_buf);
1271 struct mtk_video_dec_buf *buf_info = container_of(
1272 vb2_v4l2, struct mtk_video_dec_buf, vb);
1273 if (!buf_info->lastframe)
1274 v4l2_m2m_buf_done(vb2_v4l2,
1275 VB2_BUF_STATE_ERROR);
1276 }
1230 return; 1277 return;
1231 } 1278 }
1232 1279
@@ -1406,6 +1453,9 @@ const struct v4l2_ioctl_ops mtk_vdec_ioctl_ops = {
1406 .vidioc_unsubscribe_event = v4l2_event_unsubscribe, 1453 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
1407 .vidioc_g_selection = vidioc_vdec_g_selection, 1454 .vidioc_g_selection = vidioc_vdec_g_selection,
1408 .vidioc_s_selection = vidioc_vdec_s_selection, 1455 .vidioc_s_selection = vidioc_vdec_s_selection,
1456
1457 .vidioc_decoder_cmd = vidioc_decoder_cmd,
1458 .vidioc_try_decoder_cmd = vidioc_try_decoder_cmd,
1409}; 1459};
1410 1460
1411int mtk_vcodec_dec_queue_init(void *priv, struct vb2_queue *src_vq, 1461int mtk_vcodec_dec_queue_init(void *priv, struct vb2_queue *src_vq,
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index d48287c727f4..4334b7394861 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -105,13 +105,21 @@ static int fops_vcodec_open(struct file *file)
105{ 105{
106 struct mtk_vcodec_dev *dev = video_drvdata(file); 106 struct mtk_vcodec_dev *dev = video_drvdata(file);
107 struct mtk_vcodec_ctx *ctx = NULL; 107 struct mtk_vcodec_ctx *ctx = NULL;
108 struct mtk_video_dec_buf *mtk_buf = NULL;
108 int ret = 0; 109 int ret = 0;
110 struct vb2_queue *src_vq;
109 111
110 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 112 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
111 if (!ctx) 113 if (!ctx)
112 return -ENOMEM; 114 return -ENOMEM;
115 mtk_buf = kzalloc(sizeof(*mtk_buf), GFP_KERNEL);
116 if (!mtk_buf) {
117 kfree(ctx);
118 return -ENOMEM;
119 }
113 120
114 mutex_lock(&dev->dev_mutex); 121 mutex_lock(&dev->dev_mutex);
122 ctx->empty_flush_buf = mtk_buf;
115 ctx->id = dev->id_counter++; 123 ctx->id = dev->id_counter++;
116 v4l2_fh_init(&ctx->fh, video_devdata(file)); 124 v4l2_fh_init(&ctx->fh, video_devdata(file));
117 file->private_data = &ctx->fh; 125 file->private_data = &ctx->fh;
@@ -135,6 +143,10 @@ static int fops_vcodec_open(struct file *file)
135 ret); 143 ret);
136 goto err_m2m_ctx_init; 144 goto err_m2m_ctx_init;
137 } 145 }
146 src_vq = v4l2_m2m_get_vq(ctx->m2m_ctx,
147 V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
148 ctx->empty_flush_buf->vb.vb2_buf.vb2_queue = src_vq;
149 ctx->empty_flush_buf->lastframe = true;
138 mtk_vcodec_dec_set_default_params(ctx); 150 mtk_vcodec_dec_set_default_params(ctx);
139 151
140 if (v4l2_fh_is_singular(&ctx->fh)) { 152 if (v4l2_fh_is_singular(&ctx->fh)) {
@@ -173,6 +185,7 @@ err_m2m_ctx_init:
173err_ctrls_setup: 185err_ctrls_setup:
174 v4l2_fh_del(&ctx->fh); 186 v4l2_fh_del(&ctx->fh);
175 v4l2_fh_exit(&ctx->fh); 187 v4l2_fh_exit(&ctx->fh);
188 kfree(ctx->empty_flush_buf);
176 kfree(ctx); 189 kfree(ctx);
177 mutex_unlock(&dev->dev_mutex); 190 mutex_unlock(&dev->dev_mutex);
178 191
@@ -203,6 +216,7 @@ static int fops_vcodec_release(struct file *file)
203 v4l2_ctrl_handler_free(&ctx->ctrl_hdl); 216 v4l2_ctrl_handler_free(&ctx->ctrl_hdl);
204 217
205 list_del_init(&ctx->list); 218 list_del_init(&ctx->list);
219 kfree(ctx->empty_flush_buf);
206 kfree(ctx); 220 kfree(ctx);
207 mutex_unlock(&dev->dev_mutex); 221 mutex_unlock(&dev->dev_mutex);
208 return 0; 222 return 0;
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index d7eb8ef855d2..3cffb381ac8e 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -254,6 +254,7 @@ struct vdec_pic_info {
254 * @decode_work: worker for the decoding 254 * @decode_work: worker for the decoding
255 * @encode_work: worker for the encoding 255 * @encode_work: worker for the encoding
256 * @last_decoded_picinfo: pic information get from latest decode 256 * @last_decoded_picinfo: pic information get from latest decode
257 * @empty_flush_buf: a fake size-0 capture buffer that indicates flush
257 * 258 *
258 * @colorspace: enum v4l2_colorspace; supplemental to pixelformat 259 * @colorspace: enum v4l2_colorspace; supplemental to pixelformat
259 * @ycbcr_enc: enum v4l2_ycbcr_encoding, Y'CbCr encoding 260 * @ycbcr_enc: enum v4l2_ycbcr_encoding, Y'CbCr encoding
@@ -291,6 +292,7 @@ struct mtk_vcodec_ctx {
291 struct work_struct decode_work; 292 struct work_struct decode_work;
292 struct work_struct encode_work; 293 struct work_struct encode_work;
293 struct vdec_pic_info last_decoded_picinfo; 294 struct vdec_pic_info last_decoded_picinfo;
295 struct mtk_video_dec_buf *empty_flush_buf;
294 296
295 enum v4l2_colorspace colorspace; 297 enum v4l2_colorspace colorspace;
296 enum v4l2_ycbcr_encoding ycbcr_enc; 298 enum v4l2_ycbcr_encoding ycbcr_enc;
diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
index 5a24c51aebb7..1abd14e79565 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
@@ -70,9 +70,8 @@ void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv)
70static int vcodec_vpu_send_msg(struct vdec_vpu_inst *vpu, void *msg, int len) 70static int vcodec_vpu_send_msg(struct vdec_vpu_inst *vpu, void *msg, int len)
71{ 71{
72 int err; 72 int err;
73 uint32_t msg_id = *(uint32_t *)msg;
74 73
75 mtk_vcodec_debug(vpu, "id=%X", msg_id); 74 mtk_vcodec_debug(vpu, "id=%X", *(uint32_t *)msg);
76 75
77 vpu->failure = 0; 76 vpu->failure = 0;
78 vpu->signaled = 0; 77 vpu->signaled = 0;
@@ -80,7 +79,7 @@ static int vcodec_vpu_send_msg(struct vdec_vpu_inst *vpu, void *msg, int len)
80 err = vpu_ipi_send(vpu->dev, vpu->id, msg, len); 79 err = vpu_ipi_send(vpu->dev, vpu->id, msg, len);
81 if (err) { 80 if (err) {
82 mtk_vcodec_err(vpu, "send fail vpu_id=%d msg_id=%X status=%d", 81 mtk_vcodec_err(vpu, "send fail vpu_id=%d msg_id=%X status=%d",
83 vpu->id, msg_id, err); 82 vpu->id, *(uint32_t *)msg, err);
84 return err; 83 return err;
85 } 84 }
86 85
diff --git a/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c b/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
index b76c80bdf30b..4eb3be37ba14 100644
--- a/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
+++ b/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
@@ -665,10 +665,10 @@ static int h264_enc_deinit(unsigned long handle)
665} 665}
666 666
667static const struct venc_common_if venc_h264_if = { 667static const struct venc_common_if venc_h264_if = {
668 h264_enc_init, 668 .init = h264_enc_init,
669 h264_enc_encode, 669 .encode = h264_enc_encode,
670 h264_enc_set_param, 670 .set_param = h264_enc_set_param,
671 h264_enc_deinit, 671 .deinit = h264_enc_deinit,
672}; 672};
673 673
674const struct venc_common_if *get_h264_enc_comm_if(void); 674const struct venc_common_if *get_h264_enc_comm_if(void);
diff --git a/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c b/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
index 544f57186243..a6fa145f2c54 100644
--- a/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
+++ b/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
@@ -470,10 +470,10 @@ static int vp8_enc_deinit(unsigned long handle)
470} 470}
471 471
472static const struct venc_common_if venc_vp8_if = { 472static const struct venc_common_if venc_vp8_if = {
473 vp8_enc_init, 473 .init = vp8_enc_init,
474 vp8_enc_encode, 474 .encode = vp8_enc_encode,
475 vp8_enc_set_param, 475 .set_param = vp8_enc_set_param,
476 vp8_enc_deinit, 476 .deinit = vp8_enc_deinit,
477}; 477};
478 478
479const struct venc_common_if *get_vp8_enc_comm_if(void); 479const struct venc_common_if *get_vp8_enc_comm_if(void);
diff --git a/drivers/media/platform/mtk-vcodec/venc_vpu_if.c b/drivers/media/platform/mtk-vcodec/venc_vpu_if.c
index a01c7599b510..0d882acf8830 100644
--- a/drivers/media/platform/mtk-vcodec/venc_vpu_if.c
+++ b/drivers/media/platform/mtk-vcodec/venc_vpu_if.c
@@ -79,10 +79,8 @@ static int vpu_enc_send_msg(struct venc_vpu_inst *vpu, void *msg,
79 79
80 status = vpu_ipi_send(vpu->dev, vpu->id, msg, len); 80 status = vpu_ipi_send(vpu->dev, vpu->id, msg, len);
81 if (status) { 81 if (status) {
82 uint32_t msg_id = *(uint32_t *)msg;
83
84 mtk_vcodec_err(vpu, "vpu_ipi_send msg_id %x len %d fail %d", 82 mtk_vcodec_err(vpu, "vpu_ipi_send msg_id %x len %d fail %d",
85 msg_id, len, status); 83 *(uint32_t *)msg, len, status);
86 return -EINVAL; 84 return -EINVAL;
87 } 85 }
88 if (vpu->failure) 86 if (vpu->failure)
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c
index 7354469670b7..218e6d7ae93a 100644
--- a/drivers/media/platform/omap3isp/ispvideo.c
+++ b/drivers/media/platform/omap3isp/ispvideo.c
@@ -225,22 +225,22 @@ isp_video_remote_subdev(struct isp_video *video, u32 *pad)
225static int isp_video_get_graph_data(struct isp_video *video, 225static int isp_video_get_graph_data(struct isp_video *video,
226 struct isp_pipeline *pipe) 226 struct isp_pipeline *pipe)
227{ 227{
228 struct media_entity_graph graph; 228 struct media_graph graph;
229 struct media_entity *entity = &video->video.entity; 229 struct media_entity *entity = &video->video.entity;
230 struct media_device *mdev = entity->graph_obj.mdev; 230 struct media_device *mdev = entity->graph_obj.mdev;
231 struct isp_video *far_end = NULL; 231 struct isp_video *far_end = NULL;
232 int ret; 232 int ret;
233 233
234 mutex_lock(&mdev->graph_mutex); 234 mutex_lock(&mdev->graph_mutex);
235 ret = media_entity_graph_walk_init(&graph, entity->graph_obj.mdev); 235 ret = media_graph_walk_init(&graph, mdev);
236 if (ret) { 236 if (ret) {
237 mutex_unlock(&mdev->graph_mutex); 237 mutex_unlock(&mdev->graph_mutex);
238 return ret; 238 return ret;
239 } 239 }
240 240
241 media_entity_graph_walk_start(&graph, entity); 241 media_graph_walk_start(&graph, entity);
242 242
243 while ((entity = media_entity_graph_walk_next(&graph))) { 243 while ((entity = media_graph_walk_next(&graph))) {
244 struct isp_video *__video; 244 struct isp_video *__video;
245 245
246 media_entity_enum_set(&pipe->ent_enum, entity); 246 media_entity_enum_set(&pipe->ent_enum, entity);
@@ -261,7 +261,7 @@ static int isp_video_get_graph_data(struct isp_video *video,
261 261
262 mutex_unlock(&mdev->graph_mutex); 262 mutex_unlock(&mdev->graph_mutex);
263 263
264 media_entity_graph_walk_cleanup(&graph); 264 media_graph_walk_cleanup(&graph);
265 265
266 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { 266 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
267 pipe->input = far_end; 267 pipe->input = far_end;
@@ -1112,7 +1112,7 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
1112 pipe->l3_ick = clk_get_rate(video->isp->clock[ISP_CLK_L3_ICK]); 1112 pipe->l3_ick = clk_get_rate(video->isp->clock[ISP_CLK_L3_ICK]);
1113 pipe->max_rate = pipe->l3_ick; 1113 pipe->max_rate = pipe->l3_ick;
1114 1114
1115 ret = media_entity_pipeline_start(&video->video.entity, &pipe->pipe); 1115 ret = media_pipeline_start(&video->video.entity, &pipe->pipe);
1116 if (ret < 0) 1116 if (ret < 0)
1117 goto err_pipeline_start; 1117 goto err_pipeline_start;
1118 1118
@@ -1169,7 +1169,7 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
1169 return 0; 1169 return 0;
1170 1170
1171err_check_format: 1171err_check_format:
1172 media_entity_pipeline_stop(&video->video.entity); 1172 media_pipeline_stop(&video->video.entity);
1173err_pipeline_start: 1173err_pipeline_start:
1174 /* TODO: Implement PM QoS */ 1174 /* TODO: Implement PM QoS */
1175 /* The DMA queue must be emptied here, otherwise CCDC interrupts that 1175 /* The DMA queue must be emptied here, otherwise CCDC interrupts that
@@ -1236,7 +1236,7 @@ isp_video_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
1236 video->error = false; 1236 video->error = false;
1237 1237
1238 /* TODO: Implement PM QoS */ 1238 /* TODO: Implement PM QoS */
1239 media_entity_pipeline_stop(&video->video.entity); 1239 media_pipeline_stop(&video->video.entity);
1240 1240
1241 media_entity_enum_cleanup(&pipe->ent_enum); 1241 media_entity_enum_cleanup(&pipe->ent_enum);
1242 1242
@@ -1350,6 +1350,7 @@ static int isp_video_open(struct file *file)
1350done: 1350done:
1351 if (ret < 0) { 1351 if (ret < 0) {
1352 v4l2_fh_del(&handle->vfh); 1352 v4l2_fh_del(&handle->vfh);
1353 v4l2_fh_exit(&handle->vfh);
1353 kfree(handle); 1354 kfree(handle);
1354 } 1355 }
1355 1356
@@ -1373,6 +1374,7 @@ static int isp_video_release(struct file *file)
1373 1374
1374 /* Release the file handle. */ 1375 /* Release the file handle. */
1375 v4l2_fh_del(vfh); 1376 v4l2_fh_del(vfh);
1377 v4l2_fh_exit(vfh);
1376 kfree(handle); 1378 kfree(handle);
1377 file->private_data = NULL; 1379 file->private_data = NULL;
1378 1380
diff --git a/drivers/media/platform/rcar_fdp1.c b/drivers/media/platform/rcar_fdp1.c
index 674cc1309b43..42f25d241edd 100644
--- a/drivers/media/platform/rcar_fdp1.c
+++ b/drivers/media/platform/rcar_fdp1.c
@@ -1596,7 +1596,7 @@ static int fdp1_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
1596 else 1596 else
1597 fdp1_try_fmt_capture(ctx, NULL, &f->fmt.pix_mp); 1597 fdp1_try_fmt_capture(ctx, NULL, &f->fmt.pix_mp);
1598 1598
1599 dprintk(ctx->fdp1, "Try %s format: %4s (0x%08x) %ux%u field %u\n", 1599 dprintk(ctx->fdp1, "Try %s format: %4.4s (0x%08x) %ux%u field %u\n",
1600 V4L2_TYPE_IS_OUTPUT(f->type) ? "output" : "capture", 1600 V4L2_TYPE_IS_OUTPUT(f->type) ? "output" : "capture",
1601 (char *)&f->fmt.pix_mp.pixelformat, f->fmt.pix_mp.pixelformat, 1601 (char *)&f->fmt.pix_mp.pixelformat, f->fmt.pix_mp.pixelformat,
1602 f->fmt.pix_mp.width, f->fmt.pix_mp.height, f->fmt.pix_mp.field); 1602 f->fmt.pix_mp.width, f->fmt.pix_mp.height, f->fmt.pix_mp.field);
@@ -1671,7 +1671,7 @@ static int fdp1_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
1671 1671
1672 fdp1_set_format(ctx, &f->fmt.pix_mp, f->type); 1672 fdp1_set_format(ctx, &f->fmt.pix_mp, f->type);
1673 1673
1674 dprintk(ctx->fdp1, "Set %s format: %4s (0x%08x) %ux%u field %u\n", 1674 dprintk(ctx->fdp1, "Set %s format: %4.4s (0x%08x) %ux%u field %u\n",
1675 V4L2_TYPE_IS_OUTPUT(f->type) ? "output" : "capture", 1675 V4L2_TYPE_IS_OUTPUT(f->type) ? "output" : "capture",
1676 (char *)&f->fmt.pix_mp.pixelformat, f->fmt.pix_mp.pixelformat, 1676 (char *)&f->fmt.pix_mp.pixelformat, f->fmt.pix_mp.pixelformat,
1677 f->fmt.pix_mp.width, f->fmt.pix_mp.height, f->fmt.pix_mp.field); 1677 f->fmt.pix_mp.width, f->fmt.pix_mp.height, f->fmt.pix_mp.field);
diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c
index 0413a861a59a..1b30be72f4f9 100644
--- a/drivers/media/platform/s3c-camif/camif-capture.c
+++ b/drivers/media/platform/s3c-camif/camif-capture.c
@@ -856,13 +856,13 @@ static int s3c_camif_streamon(struct file *file, void *priv,
856 if (s3c_vp_active(vp)) 856 if (s3c_vp_active(vp))
857 return 0; 857 return 0;
858 858
859 ret = media_entity_pipeline_start(sensor, camif->m_pipeline); 859 ret = media_pipeline_start(sensor, camif->m_pipeline);
860 if (ret < 0) 860 if (ret < 0)
861 return ret; 861 return ret;
862 862
863 ret = camif_pipeline_validate(camif); 863 ret = camif_pipeline_validate(camif);
864 if (ret < 0) { 864 if (ret < 0) {
865 media_entity_pipeline_stop(sensor); 865 media_pipeline_stop(sensor);
866 return ret; 866 return ret;
867 } 867 }
868 868
@@ -886,7 +886,7 @@ static int s3c_camif_streamoff(struct file *file, void *priv,
886 886
887 ret = vb2_streamoff(&vp->vb_queue, type); 887 ret = vb2_streamoff(&vp->vb_queue, type);
888 if (ret == 0) 888 if (ret == 0)
889 media_entity_pipeline_stop(&camif->sensor.sd->entity); 889 media_pipeline_stop(&camif->sensor.sd->entity);
890 return ret; 890 return ret;
891} 891}
892 892
@@ -1488,7 +1488,7 @@ static const struct v4l2_subdev_pad_ops s3c_camif_subdev_pad_ops = {
1488 .set_fmt = s3c_camif_subdev_set_fmt, 1488 .set_fmt = s3c_camif_subdev_set_fmt,
1489}; 1489};
1490 1490
1491static struct v4l2_subdev_ops s3c_camif_subdev_ops = { 1491static const struct v4l2_subdev_ops s3c_camif_subdev_ops = {
1492 .pad = &s3c_camif_subdev_pad_ops, 1492 .pad = &s3c_camif_subdev_pad_ops,
1493}; 1493};
1494 1494
diff --git a/drivers/media/platform/soc_camera/soc_camera_platform.c b/drivers/media/platform/soc_camera/soc_camera_platform.c
index 534d6c3c6d60..cb4986b8f798 100644
--- a/drivers/media/platform/soc_camera/soc_camera_platform.c
+++ b/drivers/media/platform/soc_camera/soc_camera_platform.c
@@ -59,7 +59,7 @@ static int soc_camera_platform_s_power(struct v4l2_subdev *sd, int on)
59 return soc_camera_set_power(p->icd->control, &p->icd->sdesc->subdev_desc, NULL, on); 59 return soc_camera_set_power(p->icd->control, &p->icd->sdesc->subdev_desc, NULL, on);
60} 60}
61 61
62static struct v4l2_subdev_core_ops platform_subdev_core_ops = { 62static const struct v4l2_subdev_core_ops platform_subdev_core_ops = {
63 .s_power = soc_camera_platform_s_power, 63 .s_power = soc_camera_platform_s_power,
64}; 64};
65 65
@@ -110,7 +110,7 @@ static int soc_camera_platform_g_mbus_config(struct v4l2_subdev *sd,
110 return 0; 110 return 0;
111} 111}
112 112
113static struct v4l2_subdev_video_ops platform_subdev_video_ops = { 113static const struct v4l2_subdev_video_ops platform_subdev_video_ops = {
114 .s_stream = soc_camera_platform_s_stream, 114 .s_stream = soc_camera_platform_s_stream,
115 .g_mbus_config = soc_camera_platform_g_mbus_config, 115 .g_mbus_config = soc_camera_platform_g_mbus_config,
116}; 116};
@@ -122,7 +122,7 @@ static const struct v4l2_subdev_pad_ops platform_subdev_pad_ops = {
122 .set_fmt = soc_camera_platform_fill_fmt, 122 .set_fmt = soc_camera_platform_fill_fmt,
123}; 123};
124 124
125static struct v4l2_subdev_ops platform_subdev_ops = { 125static const struct v4l2_subdev_ops platform_subdev_ops = {
126 .core = &platform_subdev_core_ops, 126 .core = &platform_subdev_core_ops,
127 .video = &platform_subdev_video_ops, 127 .video = &platform_subdev_video_ops,
128 .pad = &platform_subdev_pad_ops, 128 .pad = &platform_subdev_pad_ops,
diff --git a/drivers/media/platform/sti/bdisp/bdisp-debug.c b/drivers/media/platform/sti/bdisp/bdisp-debug.c
index 79c56356a7c7..7af66860d624 100644
--- a/drivers/media/platform/sti/bdisp/bdisp-debug.c
+++ b/drivers/media/platform/sti/bdisp/bdisp-debug.c
@@ -677,7 +677,7 @@ int bdisp_debugfs_create(struct bdisp_dev *bdisp)
677 677
678err: 678err:
679 bdisp_debugfs_remove(bdisp); 679 bdisp_debugfs_remove(bdisp);
680 return 0; 680 return -ENOMEM;
681} 681}
682 682
683void bdisp_debugfs_remove(struct bdisp_dev *bdisp) 683void bdisp_debugfs_remove(struct bdisp_dev *bdisp)
diff --git a/drivers/media/platform/sti/delta/Makefile b/drivers/media/platform/sti/delta/Makefile
new file mode 100644
index 000000000000..8d032508a933
--- /dev/null
+++ b/drivers/media/platform/sti/delta/Makefile
@@ -0,0 +1,6 @@
1obj-$(CONFIG_VIDEO_STI_DELTA_DRIVER) := st-delta.o
2st-delta-y := delta-v4l2.o delta-mem.o delta-ipc.o delta-debug.o
3
4# MJPEG support
5st-delta-$(CONFIG_VIDEO_STI_DELTA_MJPEG) += delta-mjpeg-hdr.o
6st-delta-$(CONFIG_VIDEO_STI_DELTA_MJPEG) += delta-mjpeg-dec.o
diff --git a/drivers/media/platform/sti/delta/delta-cfg.h b/drivers/media/platform/sti/delta/delta-cfg.h
new file mode 100644
index 000000000000..c6388f575800
--- /dev/null
+++ b/drivers/media/platform/sti/delta/delta-cfg.h
@@ -0,0 +1,64 @@
1/*
2 * Copyright (C) STMicroelectronics SA 2015
3 * Author: Hugues Fruchet <hugues.fruchet@st.com> for STMicroelectronics.
4 * License terms: GNU General Public License (GPL), version 2
5 */
6
7#ifndef DELTA_CFG_H
8#define DELTA_CFG_H
9
10#define DELTA_FW_VERSION "21.1-3"
11
12#define DELTA_MIN_WIDTH 32
13#define DELTA_MAX_WIDTH 4096
14#define DELTA_MIN_HEIGHT 32
15#define DELTA_MAX_HEIGHT 2400
16
17/* DELTA requires a 32x32 pixels alignment for frames */
18#define DELTA_WIDTH_ALIGNMENT 32
19#define DELTA_HEIGHT_ALIGNMENT 32
20
21#define DELTA_DEFAULT_WIDTH DELTA_MIN_WIDTH
22#define DELTA_DEFAULT_HEIGHT DELTA_MIN_HEIGHT
23#define DELTA_DEFAULT_FRAMEFORMAT V4L2_PIX_FMT_NV12
24#define DELTA_DEFAULT_STREAMFORMAT V4L2_PIX_FMT_MJPEG
25
26#define DELTA_MAX_RESO (DELTA_MAX_WIDTH * DELTA_MAX_HEIGHT)
27
28/* guard value for number of access units */
29#define DELTA_MAX_AUS 10
30
31/* IP perf dependent, can be tuned */
32#define DELTA_PEAK_FRAME_SMOOTHING 2
33
34/*
35 * guard output frame count:
36 * - at least 1 frame needed for display
37 * - at worst 21
38 * ( max h264 dpb (16) +
39 * decoding peak smoothing (2) +
40 * user display pipeline (3) )
41 */
42#define DELTA_MIN_FRAME_USER 1
43#define DELTA_MAX_DPB 16
44#define DELTA_MAX_FRAME_USER 3 /* platform/use-case dependent */
45#define DELTA_MAX_FRAMES (DELTA_MAX_DPB + DELTA_PEAK_FRAME_SMOOTHING +\
46 DELTA_MAX_FRAME_USER)
47
48#if DELTA_MAX_FRAMES > VIDEO_MAX_FRAME
49#undef DELTA_MAX_FRAMES
50#define DELTA_MAX_FRAMES (VIDEO_MAX_FRAME)
51#endif
52
53/* extra space to be allocated to store codec specific data per frame */
54#define DELTA_MAX_FRAME_PRIV_SIZE 100
55
56/* PM runtime auto power-off after 5ms of inactivity */
57#define DELTA_HW_AUTOSUSPEND_DELAY_MS 5
58
59#define DELTA_MAX_DECODERS 10
60#ifdef CONFIG_VIDEO_STI_DELTA_MJPEG
61extern const struct delta_dec mjpegdec;
62#endif
63
64#endif /* DELTA_CFG_H */
diff --git a/drivers/media/platform/sti/delta/delta-debug.c b/drivers/media/platform/sti/delta/delta-debug.c
new file mode 100644
index 000000000000..a7ebf2cc7783
--- /dev/null
+++ b/drivers/media/platform/sti/delta/delta-debug.c
@@ -0,0 +1,72 @@
1/*
2 * Copyright (C) STMicroelectronics SA 2015
3 * Authors: Hugues Fruchet <hugues.fruchet@st.com>
4 * Fabrice Lecoultre <fabrice.lecoultre@st.com>
5 * for STMicroelectronics.
6 * License terms: GNU General Public License (GPL), version 2
7 */
8
9#include "delta.h"
10#include "delta-debug.h"
11
12char *delta_streaminfo_str(struct delta_streaminfo *s, char *str,
13 unsigned int len)
14{
15 if (!s)
16 return NULL;
17
18 snprintf(str, len,
19 "%4.4s %dx%d %s %s dpb=%d %s %s %s%dx%d@(%d,%d) %s%d/%d",
20 (char *)&s->streamformat, s->width, s->height,
21 s->profile, s->level, s->dpb,
22 (s->field == V4L2_FIELD_NONE) ? "progressive" : "interlaced",
23 s->other,
24 s->flags & DELTA_STREAMINFO_FLAG_CROP ? "crop=" : "",
25 s->crop.width, s->crop.height,
26 s->crop.left, s->crop.top,
27 s->flags & DELTA_STREAMINFO_FLAG_PIXELASPECT ? "par=" : "",
28 s->pixelaspect.numerator,
29 s->pixelaspect.denominator);
30
31 return str;
32}
33
34char *delta_frameinfo_str(struct delta_frameinfo *f, char *str,
35 unsigned int len)
36{
37 if (!f)
38 return NULL;
39
40 snprintf(str, len,
41 "%4.4s %dx%d aligned %dx%d %s %s%dx%d@(%d,%d) %s%d/%d",
42 (char *)&f->pixelformat, f->width, f->height,
43 f->aligned_width, f->aligned_height,
44 (f->field == V4L2_FIELD_NONE) ? "progressive" : "interlaced",
45 f->flags & DELTA_STREAMINFO_FLAG_CROP ? "crop=" : "",
46 f->crop.width, f->crop.height,
47 f->crop.left, f->crop.top,
48 f->flags & DELTA_STREAMINFO_FLAG_PIXELASPECT ? "par=" : "",
49 f->pixelaspect.numerator,
50 f->pixelaspect.denominator);
51
52 return str;
53}
54
55void delta_trace_summary(struct delta_ctx *ctx)
56{
57 struct delta_dev *delta = ctx->dev;
58 struct delta_streaminfo *s = &ctx->streaminfo;
59 unsigned char str[100] = "";
60
61 if (!(ctx->flags & DELTA_FLAG_STREAMINFO))
62 return;
63
64 dev_dbg(delta->dev, "%s %s, %d frames decoded, %d frames output, %d frames dropped, %d stream errors, %d decode errors",
65 ctx->name,
66 delta_streaminfo_str(s, str, sizeof(str)),
67 ctx->decoded_frames,
68 ctx->output_frames,
69 ctx->dropped_frames,
70 ctx->stream_errors,
71 ctx->decode_errors);
72}
diff --git a/drivers/media/platform/sti/delta/delta-debug.h b/drivers/media/platform/sti/delta/delta-debug.h
new file mode 100644
index 000000000000..955c1587ac2d
--- /dev/null
+++ b/drivers/media/platform/sti/delta/delta-debug.h
@@ -0,0 +1,18 @@
1/*
2 * Copyright (C) STMicroelectronics SA 2015
3 * Authors: Hugues Fruchet <hugues.fruchet@st.com>
4 * Fabrice Lecoultre <fabrice.lecoultre@st.com>
5 * for STMicroelectronics.
6 * License terms: GNU General Public License (GPL), version 2
7 */
8
9#ifndef DELTA_DEBUG_H
10#define DELTA_DEBUG_H
11
12char *delta_streaminfo_str(struct delta_streaminfo *s, char *str,
13 unsigned int len);
14char *delta_frameinfo_str(struct delta_frameinfo *f, char *str,
15 unsigned int len);
16void delta_trace_summary(struct delta_ctx *ctx);
17
18#endif /* DELTA_DEBUG_H */
diff --git a/drivers/media/platform/sti/delta/delta-ipc.c b/drivers/media/platform/sti/delta/delta-ipc.c
new file mode 100644
index 000000000000..41e4a4c259b3
--- /dev/null
+++ b/drivers/media/platform/sti/delta/delta-ipc.c
@@ -0,0 +1,594 @@
1/*
2 * Copyright (C) STMicroelectronics SA 2015
3 * Author: Hugues Fruchet <hugues.fruchet@st.com> for STMicroelectronics.
4 * License terms: GNU General Public License (GPL), version 2
5 */
6
7#include <linux/rpmsg.h>
8
9#include "delta.h"
10#include "delta-ipc.h"
11#include "delta-mem.h"
12
13#define IPC_TIMEOUT 100
14#define IPC_SANITY_TAG 0xDEADBEEF
15
16enum delta_ipc_fw_command {
17 DELTA_IPC_OPEN,
18 DELTA_IPC_SET_STREAM,
19 DELTA_IPC_DECODE,
20 DELTA_IPC_CLOSE
21};
22
23#define to_rpmsg_driver(__drv) container_of(__drv, struct rpmsg_driver, drv)
24#define to_delta(__d) container_of(__d, struct delta_dev, rpmsg_driver)
25
26#define to_ctx(hdl) ((struct delta_ipc_ctx *)hdl)
27#define to_pctx(ctx) container_of(ctx, struct delta_ctx, ipc_ctx)
28
29struct delta_ipc_header_msg {
30 u32 tag;
31 void *host_hdl;
32 u32 copro_hdl;
33 u32 command;
34};
35
36#define to_host_hdl(ctx) ((void *)ctx)
37
38#define msg_to_ctx(msg) ((struct delta_ipc_ctx *)(msg)->header.host_hdl)
39#define msg_to_copro_hdl(msg) ((msg)->header.copro_hdl)
40
41static inline dma_addr_t to_paddr(struct delta_ipc_ctx *ctx, void *vaddr)
42{
43 return (ctx->ipc_buf->paddr + (vaddr - ctx->ipc_buf->vaddr));
44}
45
46static inline bool is_valid_data(struct delta_ipc_ctx *ctx,
47 void *data, u32 size)
48{
49 return ((data >= ctx->ipc_buf->vaddr) &&
50 ((data + size) <= (ctx->ipc_buf->vaddr + ctx->ipc_buf->size)));
51}
52
53/*
54 * IPC shared memory (@ipc_buf_size, @ipc_buf_paddr) is sent to copro
55 * at each instance opening. This memory is allocated by IPC client
56 * and given through delta_ipc_open(). All messages parameters
57 * (open, set_stream, decode) will have their phy address within
58 * this IPC shared memory, avoiding de-facto recopies inside delta-ipc.
59 * All the below messages structures are used on both host and firmware
60 * side and are packed (use only of 32 bits size fields in messages
61 * structures to ensure packing):
62 * - struct delta_ipc_open_msg
63 * - struct delta_ipc_set_stream_msg
64 * - struct delta_ipc_decode_msg
65 * - struct delta_ipc_close_msg
66 * - struct delta_ipc_cb_msg
67 */
68struct delta_ipc_open_msg {
69 struct delta_ipc_header_msg header;
70 u32 ipc_buf_size;
71 dma_addr_t ipc_buf_paddr;
72 char name[32];
73 u32 param_size;
74 dma_addr_t param_paddr;
75};
76
77struct delta_ipc_set_stream_msg {
78 struct delta_ipc_header_msg header;
79 u32 param_size;
80 dma_addr_t param_paddr;
81};
82
83struct delta_ipc_decode_msg {
84 struct delta_ipc_header_msg header;
85 u32 param_size;
86 dma_addr_t param_paddr;
87 u32 status_size;
88 dma_addr_t status_paddr;
89};
90
91struct delta_ipc_close_msg {
92 struct delta_ipc_header_msg header;
93};
94
95struct delta_ipc_cb_msg {
96 struct delta_ipc_header_msg header;
97 int err;
98};
99
100static void build_msg_header(struct delta_ipc_ctx *ctx,
101 enum delta_ipc_fw_command command,
102 struct delta_ipc_header_msg *header)
103{
104 header->tag = IPC_SANITY_TAG;
105 header->host_hdl = to_host_hdl(ctx);
106 header->copro_hdl = ctx->copro_hdl;
107 header->command = command;
108}
109
110int delta_ipc_open(struct delta_ctx *pctx, const char *name,
111 struct delta_ipc_param *param, u32 ipc_buf_size,
112 struct delta_buf **ipc_buf, void **hdl)
113{
114 struct delta_dev *delta = pctx->dev;
115 struct rpmsg_device *rpmsg_device = delta->rpmsg_device;
116 struct delta_ipc_ctx *ctx = &pctx->ipc_ctx;
117 struct delta_ipc_open_msg msg;
118 struct delta_buf *buf = &ctx->ipc_buf_struct;
119 int ret;
120
121 if (!rpmsg_device) {
122 dev_err(delta->dev,
123 "%s ipc: failed to open, rpmsg is not initialized\n",
124 pctx->name);
125 pctx->sys_errors++;
126 return -EINVAL;
127 }
128
129 if (!name) {
130 dev_err(delta->dev,
131 "%s ipc: failed to open, no name given\n",
132 pctx->name);
133 return -EINVAL;
134 }
135
136 if (!param || !param->data || !param->size) {
137 dev_err(delta->dev,
138 "%s ipc: failed to open, empty parameter\n",
139 pctx->name);
140 return -EINVAL;
141 }
142
143 if (!ipc_buf_size) {
144 dev_err(delta->dev,
145 "%s ipc: failed to open, no size given for ipc buffer\n",
146 pctx->name);
147 return -EINVAL;
148 }
149
150 if (param->size > ipc_buf_size) {
151 dev_err(delta->dev,
152 "%s ipc: failed to open, too large ipc parameter (%d bytes while max %d expected)\n",
153 pctx->name,
154 param->size, ctx->ipc_buf->size);
155 return -EINVAL;
156 }
157
158 /* init */
159 init_completion(&ctx->done);
160
161 /*
162 * allocation of contiguous buffer for
163 * data of commands exchanged between
164 * host and firmware coprocessor
165 */
166 ret = hw_alloc(pctx, ipc_buf_size,
167 "ipc data buffer", buf);
168 if (ret)
169 return ret;
170 ctx->ipc_buf = buf;
171
172 /* build rpmsg message */
173 build_msg_header(ctx, DELTA_IPC_OPEN, &msg.header);
174
175 msg.ipc_buf_size = ipc_buf_size;
176 msg.ipc_buf_paddr = ctx->ipc_buf->paddr;
177
178 memcpy(msg.name, name, sizeof(msg.name));
179 msg.name[sizeof(msg.name) - 1] = 0;
180
181 msg.param_size = param->size;
182 memcpy(ctx->ipc_buf->vaddr, param->data, msg.param_size);
183 msg.param_paddr = ctx->ipc_buf->paddr;
184
185 /* send it */
186 ret = rpmsg_send(rpmsg_device->ept, &msg, sizeof(msg));
187 if (ret) {
188 dev_err(delta->dev,
189 "%s ipc: failed to open, rpmsg_send failed (%d) for DELTA_IPC_OPEN (name=%s, size=%d, data=%p)\n",
190 pctx->name,
191 ret, name, param->size, param->data);
192 goto err;
193 }
194
195 /* wait for acknowledge */
196 if (!wait_for_completion_timeout
197 (&ctx->done, msecs_to_jiffies(IPC_TIMEOUT))) {
198 dev_err(delta->dev,
199 "%s ipc: failed to open, timeout waiting for DELTA_IPC_OPEN callback (name=%s, size=%d, data=%p)\n",
200 pctx->name,
201 name, param->size, param->data);
202 ret = -ETIMEDOUT;
203 goto err;
204 }
205
206 /* command completed, check error */
207 if (ctx->cb_err) {
208 dev_err(delta->dev,
209 "%s ipc: failed to open, DELTA_IPC_OPEN completed but with error (%d) (name=%s, size=%d, data=%p)\n",
210 pctx->name,
211 ctx->cb_err, name, param->size, param->data);
212 ret = -EIO;
213 goto err;
214 }
215
216 *ipc_buf = ctx->ipc_buf;
217 *hdl = (void *)ctx;
218
219 return 0;
220
221err:
222 pctx->sys_errors++;
223 if (ctx->ipc_buf) {
224 hw_free(pctx, ctx->ipc_buf);
225 ctx->ipc_buf = NULL;
226 }
227
228 return ret;
229};
230
231int delta_ipc_set_stream(void *hdl, struct delta_ipc_param *param)
232{
233 struct delta_ipc_ctx *ctx = to_ctx(hdl);
234 struct delta_ctx *pctx = to_pctx(ctx);
235 struct delta_dev *delta = pctx->dev;
236 struct rpmsg_device *rpmsg_device = delta->rpmsg_device;
237 struct delta_ipc_set_stream_msg msg;
238 int ret;
239
240 if (!hdl) {
241 dev_err(delta->dev,
242 "%s ipc: failed to set stream, invalid ipc handle\n",
243 pctx->name);
244 return -EINVAL;
245 }
246
247 if (!rpmsg_device) {
248 dev_err(delta->dev,
249 "%s ipc: failed to set stream, rpmsg is not initialized\n",
250 pctx->name);
251 return -EINVAL;
252 }
253
254 if (!param || !param->data || !param->size) {
255 dev_err(delta->dev,
256 "%s ipc: failed to set stream, empty parameter\n",
257 pctx->name);
258 return -EINVAL;
259 }
260
261 if (param->size > ctx->ipc_buf->size) {
262 dev_err(delta->dev,
263 "%s ipc: failed to set stream, too large ipc parameter(%d bytes while max %d expected)\n",
264 pctx->name,
265 param->size, ctx->ipc_buf->size);
266 return -EINVAL;
267 }
268
269 if (!is_valid_data(ctx, param->data, param->size)) {
270 dev_err(delta->dev,
271 "%s ipc: failed to set stream, parameter is not in expected address range (size=%d, data=%p not in %p..%p)\n",
272 pctx->name,
273 param->size,
274 param->data,
275 ctx->ipc_buf->vaddr,
276 ctx->ipc_buf->vaddr + ctx->ipc_buf->size - 1);
277 return -EINVAL;
278 }
279
280 /* build rpmsg message */
281 build_msg_header(ctx, DELTA_IPC_SET_STREAM, &msg.header);
282
283 msg.param_size = param->size;
284 msg.param_paddr = to_paddr(ctx, param->data);
285
286 /* send it */
287 ret = rpmsg_send(rpmsg_device->ept, &msg, sizeof(msg));
288 if (ret) {
289 dev_err(delta->dev,
290 "%s ipc: failed to set stream, rpmsg_send failed (%d) for DELTA_IPC_SET_STREAM (size=%d, data=%p)\n",
291 pctx->name,
292 ret, param->size, param->data);
293 pctx->sys_errors++;
294 return ret;
295 }
296
297 /* wait for acknowledge */
298 if (!wait_for_completion_timeout
299 (&ctx->done, msecs_to_jiffies(IPC_TIMEOUT))) {
300 dev_err(delta->dev,
301 "%s ipc: failed to set stream, timeout waiting for DELTA_IPC_SET_STREAM callback (size=%d, data=%p)\n",
302 pctx->name,
303 param->size, param->data);
304 pctx->sys_errors++;
305 return -ETIMEDOUT;
306 }
307
308 /* command completed, check status */
309 if (ctx->cb_err) {
310 dev_err(delta->dev,
311 "%s ipc: failed to set stream, DELTA_IPC_SET_STREAM completed but with error (%d) (size=%d, data=%p)\n",
312 pctx->name,
313 ctx->cb_err, param->size, param->data);
314 pctx->sys_errors++;
315 return -EIO;
316 }
317
318 return 0;
319}
320
321int delta_ipc_decode(void *hdl, struct delta_ipc_param *param,
322 struct delta_ipc_param *status)
323{
324 struct delta_ipc_ctx *ctx = to_ctx(hdl);
325 struct delta_ctx *pctx = to_pctx(ctx);
326 struct delta_dev *delta = pctx->dev;
327 struct rpmsg_device *rpmsg_device = delta->rpmsg_device;
328 struct delta_ipc_decode_msg msg;
329 int ret;
330
331 if (!hdl) {
332 dev_err(delta->dev,
333 "%s ipc: failed to decode, invalid ipc handle\n",
334 pctx->name);
335 return -EINVAL;
336 }
337
338 if (!rpmsg_device) {
339 dev_err(delta->dev,
340 "%s ipc: failed to decode, rpmsg is not initialized\n",
341 pctx->name);
342 return -EINVAL;
343 }
344
345 if (!param || !param->data || !param->size) {
346 dev_err(delta->dev,
347 "%s ipc: failed to decode, empty parameter\n",
348 pctx->name);
349 return -EINVAL;
350 }
351
352 if (!status || !status->data || !status->size) {
353 dev_err(delta->dev,
354 "%s ipc: failed to decode, empty status\n",
355 pctx->name);
356 return -EINVAL;
357 }
358
359 if (param->size + status->size > ctx->ipc_buf->size) {
360 dev_err(delta->dev,
361 "%s ipc: failed to decode, too large ipc parameter (%d bytes (param) + %d bytes (status) while max %d expected)\n",
362 pctx->name,
363 param->size,
364 status->size,
365 ctx->ipc_buf->size);
366 return -EINVAL;
367 }
368
369 if (!is_valid_data(ctx, param->data, param->size)) {
370 dev_err(delta->dev,
371 "%s ipc: failed to decode, parameter is not in expected address range (size=%d, data=%p not in %p..%p)\n",
372 pctx->name,
373 param->size,
374 param->data,
375 ctx->ipc_buf->vaddr,
376 ctx->ipc_buf->vaddr + ctx->ipc_buf->size - 1);
377 return -EINVAL;
378 }
379
380 if (!is_valid_data(ctx, status->data, status->size)) {
381 dev_err(delta->dev,
382 "%s ipc: failed to decode, status is not in expected address range (size=%d, data=%p not in %p..%p)\n",
383 pctx->name,
384 status->size,
385 status->data,
386 ctx->ipc_buf->vaddr,
387 ctx->ipc_buf->vaddr + ctx->ipc_buf->size - 1);
388 return -EINVAL;
389 }
390
391 /* build rpmsg message */
392 build_msg_header(ctx, DELTA_IPC_DECODE, &msg.header);
393
394 msg.param_size = param->size;
395 msg.param_paddr = to_paddr(ctx, param->data);
396
397 msg.status_size = status->size;
398 msg.status_paddr = to_paddr(ctx, status->data);
399
400 /* send it */
401 ret = rpmsg_send(rpmsg_device->ept, &msg, sizeof(msg));
402 if (ret) {
403 dev_err(delta->dev,
404 "%s ipc: failed to decode, rpmsg_send failed (%d) for DELTA_IPC_DECODE (size=%d, data=%p)\n",
405 pctx->name,
406 ret, param->size, param->data);
407 pctx->sys_errors++;
408 return ret;
409 }
410
411 /* wait for acknowledge */
412 if (!wait_for_completion_timeout
413 (&ctx->done, msecs_to_jiffies(IPC_TIMEOUT))) {
414 dev_err(delta->dev,
415 "%s ipc: failed to decode, timeout waiting for DELTA_IPC_DECODE callback (size=%d, data=%p)\n",
416 pctx->name,
417 param->size, param->data);
418 pctx->sys_errors++;
419 return -ETIMEDOUT;
420 }
421
422 /* command completed, check status */
423 if (ctx->cb_err) {
424 dev_err(delta->dev,
425 "%s ipc: failed to decode, DELTA_IPC_DECODE completed but with error (%d) (size=%d, data=%p)\n",
426 pctx->name,
427 ctx->cb_err, param->size, param->data);
428 pctx->sys_errors++;
429 return -EIO;
430 }
431
432 return 0;
433};
434
435void delta_ipc_close(void *hdl)
436{
437 struct delta_ipc_ctx *ctx = to_ctx(hdl);
438 struct delta_ctx *pctx = to_pctx(ctx);
439 struct delta_dev *delta = pctx->dev;
440 struct rpmsg_device *rpmsg_device = delta->rpmsg_device;
441 struct delta_ipc_close_msg msg;
442 int ret;
443
444 if (!hdl) {
445 dev_err(delta->dev,
446 "%s ipc: failed to close, invalid ipc handle\n",
447 pctx->name);
448 return;
449 }
450
451 if (ctx->ipc_buf) {
452 hw_free(pctx, ctx->ipc_buf);
453 ctx->ipc_buf = NULL;
454 }
455
456 if (!rpmsg_device) {
457 dev_err(delta->dev,
458 "%s ipc: failed to close, rpmsg is not initialized\n",
459 pctx->name);
460 return;
461 }
462
463 /* build rpmsg message */
464 build_msg_header(ctx, DELTA_IPC_CLOSE, &msg.header);
465
466 /* send it */
467 ret = rpmsg_send(rpmsg_device->ept, &msg, sizeof(msg));
468 if (ret) {
469 dev_err(delta->dev,
470 "%s ipc: failed to close, rpmsg_send failed (%d) for DELTA_IPC_CLOSE\n",
471 pctx->name, ret);
472 pctx->sys_errors++;
473 return;
474 }
475
476 /* wait for acknowledge */
477 if (!wait_for_completion_timeout
478 (&ctx->done, msecs_to_jiffies(IPC_TIMEOUT))) {
479 dev_err(delta->dev,
480 "%s ipc: failed to close, timeout waiting for DELTA_IPC_CLOSE callback\n",
481 pctx->name);
482 pctx->sys_errors++;
483 return;
484 }
485
486 /* command completed, check status */
487 if (ctx->cb_err) {
488 dev_err(delta->dev,
489 "%s ipc: failed to close, DELTA_IPC_CLOSE completed but with error (%d)\n",
490 pctx->name, ctx->cb_err);
491 pctx->sys_errors++;
492 }
493};
494
495static int delta_ipc_cb(struct rpmsg_device *rpdev, void *data,
496 int len, void *priv, u32 src)
497{
498 struct delta_ipc_ctx *ctx;
499 struct delta_ipc_cb_msg *msg;
500
501 /* sanity check */
502 if (!rpdev) {
503 dev_err(NULL, "rpdev is NULL\n");
504 return -EINVAL;
505 }
506
507 if (!data || !len) {
508 dev_err(&rpdev->dev,
509 "unexpected empty message received from src=%d\n", src);
510 return -EINVAL;
511 }
512
513 if (len != sizeof(*msg)) {
514 dev_err(&rpdev->dev,
515 "unexpected message length received from src=%d (received %d bytes while %zu bytes expected)\n",
516 len, src, sizeof(*msg));
517 return -EINVAL;
518 }
519
520 msg = (struct delta_ipc_cb_msg *)data;
521 if (msg->header.tag != IPC_SANITY_TAG) {
522 dev_err(&rpdev->dev,
523 "unexpected message tag received from src=%d (received %x tag while %x expected)\n",
524 src, msg->header.tag, IPC_SANITY_TAG);
525 return -EINVAL;
526 }
527
528 ctx = msg_to_ctx(msg);
529 if (!ctx) {
530 dev_err(&rpdev->dev,
531 "unexpected message with NULL host_hdl received from src=%d\n",
532 src);
533 return -EINVAL;
534 }
535
536 /*
537 * if not already known, save copro instance context
538 * to ensure re-entrance on copro side
539 */
540 if (!ctx->copro_hdl)
541 ctx->copro_hdl = msg_to_copro_hdl(msg);
542
543 /*
544 * all is fine,
545 * update status & complete command
546 */
547 ctx->cb_err = msg->err;
548 complete(&ctx->done);
549
550 return 0;
551}
552
553static int delta_ipc_probe(struct rpmsg_device *rpmsg_device)
554{
555 struct rpmsg_driver *rpdrv = to_rpmsg_driver(rpmsg_device->dev.driver);
556 struct delta_dev *delta = to_delta(rpdrv);
557
558 delta->rpmsg_device = rpmsg_device;
559
560 return 0;
561}
562
563static void delta_ipc_remove(struct rpmsg_device *rpmsg_device)
564{
565 struct rpmsg_driver *rpdrv = to_rpmsg_driver(rpmsg_device->dev.driver);
566 struct delta_dev *delta = to_delta(rpdrv);
567
568 delta->rpmsg_device = NULL;
569}
570
571static struct rpmsg_device_id delta_ipc_device_id_table[] = {
572 {.name = "rpmsg-delta"},
573 {},
574};
575
576static struct rpmsg_driver delta_rpmsg_driver = {
577 .drv = {.name = KBUILD_MODNAME},
578 .id_table = delta_ipc_device_id_table,
579 .probe = delta_ipc_probe,
580 .callback = delta_ipc_cb,
581 .remove = delta_ipc_remove,
582};
583
584int delta_ipc_init(struct delta_dev *delta)
585{
586 delta->rpmsg_driver = delta_rpmsg_driver;
587
588 return register_rpmsg_driver(&delta->rpmsg_driver);
589}
590
591void delta_ipc_exit(struct delta_dev *delta)
592{
593 unregister_rpmsg_driver(&delta->rpmsg_driver);
594}
diff --git a/drivers/media/platform/sti/delta/delta-ipc.h b/drivers/media/platform/sti/delta/delta-ipc.h
new file mode 100644
index 000000000000..cef2019c72d4
--- /dev/null
+++ b/drivers/media/platform/sti/delta/delta-ipc.h
@@ -0,0 +1,76 @@
1/*
2 * Copyright (C) STMicroelectronics SA 2015
3 * Author: Hugues Fruchet <hugues.fruchet@st.com> for STMicroelectronics.
4 * License terms: GNU General Public License (GPL), version 2
5 */
6
7#ifndef DELTA_IPC_H
8#define DELTA_IPC_H
9
10int delta_ipc_init(struct delta_dev *delta);
11void delta_ipc_exit(struct delta_dev *delta);
12
13/*
14 * delta_ipc_open - open a decoding instance on firmware side
15 * @ctx: (in) delta context
16 * @name: (in) name of decoder to be used
17 * @param: (in) open command parameters specific to decoder
18 * @param.size: (in) size of parameter
19 * @param.data: (in) virtual address of parameter
20 * @ipc_buf_size: (in) size of IPC shared buffer between host
21 * and copro used to share command data.
22 * Client have to set here the size of the biggest
23 * command parameters (+ status if any).
24 * Allocation will be done in this function which
25 * will give back to client in @ipc_buf the virtual
26 * & physical addresses & size of shared IPC buffer.
27 * All the further command data (parameters + status)
28 * have to be written in this shared IPC buffer
29 * virtual memory. This is done to avoid
30 * unnecessary copies of command data.
31 * @ipc_buf: (out) allocated IPC shared buffer
32 * @ipc_buf.size: (out) allocated size
33 * @ipc_buf.vaddr: (out) virtual address where to copy
34 * further command data
35 * @hdl: (out) handle of decoding instance.
36 */
37
38int delta_ipc_open(struct delta_ctx *ctx, const char *name,
39 struct delta_ipc_param *param, u32 ipc_buf_size,
40 struct delta_buf **ipc_buf, void **hdl);
41
42/*
43 * delta_ipc_set_stream - set information about stream to decoder
44 * @hdl: (in) handle of decoding instance.
45 * @param: (in) set stream command parameters specific to decoder
46 * @param.size: (in) size of parameter
47 * @param.data: (in) virtual address of parameter. Must be
48 * within IPC shared buffer range
49 */
50int delta_ipc_set_stream(void *hdl, struct delta_ipc_param *param);
51
52/*
53 * delta_ipc_decode - frame decoding synchronous request, returns only
54 * after decoding completion on firmware side.
55 * @hdl: (in) handle of decoding instance.
56 * @param: (in) decode command parameters specific to decoder
57 * @param.size: (in) size of parameter
58 * @param.data: (in) virtual address of parameter. Must be
59 * within IPC shared buffer range
60 * @status: (in/out) decode command status specific to decoder
61 * @status.size: (in) size of status
62 * @status.data: (in/out) virtual address of status. Must be
63 * within IPC shared buffer range.
64 * Status is filled by decoding instance
65 * after decoding completion.
66 */
67int delta_ipc_decode(void *hdl, struct delta_ipc_param *param,
68 struct delta_ipc_param *status);
69
70/*
71 * delta_ipc_close - close decoding instance
72 * @hdl: (in) handle of decoding instance to close.
73 */
74void delta_ipc_close(void *hdl);
75
76#endif /* DELTA_IPC_H */
diff --git a/drivers/media/platform/sti/delta/delta-mem.c b/drivers/media/platform/sti/delta/delta-mem.c
new file mode 100644
index 000000000000..d7b53d31caa6
--- /dev/null
+++ b/drivers/media/platform/sti/delta/delta-mem.c
@@ -0,0 +1,51 @@
1/*
2 * Copyright (C) STMicroelectronics SA 2015
3 * Author: Hugues Fruchet <hugues.fruchet@st.com> for STMicroelectronics.
4 * License terms: GNU General Public License (GPL), version 2
5 */
6
7#include "delta.h"
8#include "delta-mem.h"
9
10int hw_alloc(struct delta_ctx *ctx, u32 size, const char *name,
11 struct delta_buf *buf)
12{
13 struct delta_dev *delta = ctx->dev;
14 dma_addr_t dma_addr;
15 void *addr;
16 unsigned long attrs = DMA_ATTR_WRITE_COMBINE;
17
18 addr = dma_alloc_attrs(delta->dev, size, &dma_addr,
19 GFP_KERNEL | __GFP_NOWARN, attrs);
20 if (!addr) {
21 dev_err(delta->dev,
22 "%s hw_alloc:dma_alloc_coherent failed for %s (size=%d)\n",
23 ctx->name, name, size);
24 ctx->sys_errors++;
25 return -ENOMEM;
26 }
27
28 buf->size = size;
29 buf->paddr = dma_addr;
30 buf->vaddr = addr;
31 buf->name = name;
32 buf->attrs = attrs;
33
34 dev_dbg(delta->dev,
35 "%s allocate %d bytes of HW memory @(virt=0x%p, phy=0x%pad): %s\n",
36 ctx->name, size, buf->vaddr, &buf->paddr, buf->name);
37
38 return 0;
39}
40
41void hw_free(struct delta_ctx *ctx, struct delta_buf *buf)
42{
43 struct delta_dev *delta = ctx->dev;
44
45 dev_dbg(delta->dev,
46 "%s free %d bytes of HW memory @(virt=0x%p, phy=0x%pad): %s\n",
47 ctx->name, buf->size, buf->vaddr, &buf->paddr, buf->name);
48
49 dma_free_attrs(delta->dev, buf->size,
50 buf->vaddr, buf->paddr, buf->attrs);
51}
diff --git a/drivers/media/platform/sti/delta/delta-mem.h b/drivers/media/platform/sti/delta/delta-mem.h
new file mode 100644
index 000000000000..f8ca109e1241
--- /dev/null
+++ b/drivers/media/platform/sti/delta/delta-mem.h
@@ -0,0 +1,14 @@
1/*
2 * Copyright (C) STMicroelectronics SA 2015
3 * Author: Hugues Fruchet <hugues.fruchet@st.com> for STMicroelectronics.
4 * License terms: GNU General Public License (GPL), version 2
5 */
6
7#ifndef DELTA_MEM_H
8#define DELTA_MEM_H
9
10int hw_alloc(struct delta_ctx *ctx, u32 size, const char *name,
11 struct delta_buf *buf);
12void hw_free(struct delta_ctx *ctx, struct delta_buf *buf);
13
14#endif /* DELTA_MEM_H */
diff --git a/drivers/media/platform/sti/delta/delta-mjpeg-dec.c b/drivers/media/platform/sti/delta/delta-mjpeg-dec.c
new file mode 100644
index 000000000000..e79bdc611432
--- /dev/null
+++ b/drivers/media/platform/sti/delta/delta-mjpeg-dec.c
@@ -0,0 +1,455 @@
1/*
2 * Copyright (C) STMicroelectronics SA 2013
3 * Author: Hugues Fruchet <hugues.fruchet@st.com> for STMicroelectronics.
4 * License terms: GNU General Public License (GPL), version 2
5 */
6
7#include <linux/slab.h>
8
9#include "delta.h"
10#include "delta-ipc.h"
11#include "delta-mjpeg.h"
12#include "delta-mjpeg-fw.h"
13
14#define DELTA_MJPEG_MAX_RESO DELTA_MAX_RESO
15
16struct delta_mjpeg_ctx {
17 /* jpeg header */
18 struct mjpeg_header header_struct;
19 struct mjpeg_header *header;
20
21 /* ipc */
22 void *ipc_hdl;
23 struct delta_buf *ipc_buf;
24
25 /* decoded output frame */
26 struct delta_frame *out_frame;
27
28 unsigned char str[3000];
29};
30
31#define to_ctx(ctx) ((struct delta_mjpeg_ctx *)(ctx)->priv)
32
33static char *ipc_open_param_str(struct jpeg_video_decode_init_params_t *p,
34 char *str, unsigned int len)
35{
36 char *b = str;
37
38 if (!p)
39 return "";
40
41 b += snprintf(b, len,
42 "jpeg_video_decode_init_params_t\n"
43 "circular_buffer_begin_addr_p 0x%x\n"
44 "circular_buffer_end_addr_p 0x%x\n",
45 p->circular_buffer_begin_addr_p,
46 p->circular_buffer_end_addr_p);
47
48 return str;
49}
50
51static char *ipc_decode_param_str(struct jpeg_decode_params_t *p,
52 char *str, unsigned int len)
53{
54 char *b = str;
55
56 if (!p)
57 return "";
58
59 b += snprintf(b, len,
60 "jpeg_decode_params_t\n"
61 "picture_start_addr_p 0x%x\n"
62 "picture_end_addr_p 0x%x\n"
63 "decoding_mode %d\n"
64 "display_buffer_addr.display_decimated_luma_p 0x%x\n"
65 "display_buffer_addr.display_decimated_chroma_p 0x%x\n"
66 "main_aux_enable %d\n"
67 "additional_flags 0x%x\n"
68 "field_flag %x\n"
69 "is_jpeg_image %x\n",
70 p->picture_start_addr_p,
71 p->picture_end_addr_p,
72 p->decoding_mode,
73 p->display_buffer_addr.display_decimated_luma_p,
74 p->display_buffer_addr.display_decimated_chroma_p,
75 p->main_aux_enable, p->additional_flags,
76 p->field_flag,
77 p->is_jpeg_image);
78
79 return str;
80}
81
82static inline bool is_stream_error(enum jpeg_decoding_error_t err)
83{
84 switch (err) {
85 case JPEG_DECODER_UNDEFINED_HUFF_TABLE:
86 case JPEG_DECODER_BAD_RESTART_MARKER:
87 case JPEG_DECODER_BAD_SOS_SPECTRAL:
88 case JPEG_DECODER_BAD_SOS_SUCCESSIVE:
89 case JPEG_DECODER_BAD_HEADER_LENGTH:
90 case JPEG_DECODER_BAD_COUNT_VALUE:
91 case JPEG_DECODER_BAD_DHT_MARKER:
92 case JPEG_DECODER_BAD_INDEX_VALUE:
93 case JPEG_DECODER_BAD_NUMBER_HUFFMAN_TABLES:
94 case JPEG_DECODER_BAD_QUANT_TABLE_LENGTH:
95 case JPEG_DECODER_BAD_NUMBER_QUANT_TABLES:
96 case JPEG_DECODER_BAD_COMPONENT_COUNT:
97 return true;
98 default:
99 return false;
100 }
101}
102
103static inline const char *err_str(enum jpeg_decoding_error_t err)
104{
105 switch (err) {
106 case JPEG_DECODER_NO_ERROR:
107 return "JPEG_DECODER_NO_ERROR";
108 case JPEG_DECODER_UNDEFINED_HUFF_TABLE:
109 return "JPEG_DECODER_UNDEFINED_HUFF_TABLE";
110 case JPEG_DECODER_UNSUPPORTED_MARKER:
111 return "JPEG_DECODER_UNSUPPORTED_MARKER";
112 case JPEG_DECODER_UNABLE_ALLOCATE_MEMORY:
113 return "JPEG_DECODER_UNABLE_ALLOCATE_MEMORY";
114 case JPEG_DECODER_NON_SUPPORTED_SAMP_FACTORS:
115 return "JPEG_DECODER_NON_SUPPORTED_SAMP_FACTORS";
116 case JPEG_DECODER_BAD_PARAMETER:
117 return "JPEG_DECODER_BAD_PARAMETER";
118 case JPEG_DECODER_DECODE_ERROR:
119 return "JPEG_DECODER_DECODE_ERROR";
120 case JPEG_DECODER_BAD_RESTART_MARKER:
121 return "JPEG_DECODER_BAD_RESTART_MARKER";
122 case JPEG_DECODER_UNSUPPORTED_COLORSPACE:
123 return "JPEG_DECODER_UNSUPPORTED_COLORSPACE";
124 case JPEG_DECODER_BAD_SOS_SPECTRAL:
125 return "JPEG_DECODER_BAD_SOS_SPECTRAL";
126 case JPEG_DECODER_BAD_SOS_SUCCESSIVE:
127 return "JPEG_DECODER_BAD_SOS_SUCCESSIVE";
128 case JPEG_DECODER_BAD_HEADER_LENGTH:
129 return "JPEG_DECODER_BAD_HEADER_LENGTH";
130 case JPEG_DECODER_BAD_COUNT_VALUE:
131 return "JPEG_DECODER_BAD_COUNT_VALUE";
132 case JPEG_DECODER_BAD_DHT_MARKER:
133 return "JPEG_DECODER_BAD_DHT_MARKER";
134 case JPEG_DECODER_BAD_INDEX_VALUE:
135 return "JPEG_DECODER_BAD_INDEX_VALUE";
136 case JPEG_DECODER_BAD_NUMBER_HUFFMAN_TABLES:
137 return "JPEG_DECODER_BAD_NUMBER_HUFFMAN_TABLES";
138 case JPEG_DECODER_BAD_QUANT_TABLE_LENGTH:
139 return "JPEG_DECODER_BAD_QUANT_TABLE_LENGTH";
140 case JPEG_DECODER_BAD_NUMBER_QUANT_TABLES:
141 return "JPEG_DECODER_BAD_NUMBER_QUANT_TABLES";
142 case JPEG_DECODER_BAD_COMPONENT_COUNT:
143 return "JPEG_DECODER_BAD_COMPONENT_COUNT";
144 case JPEG_DECODER_DIVIDE_BY_ZERO_ERROR:
145 return "JPEG_DECODER_DIVIDE_BY_ZERO_ERROR";
146 case JPEG_DECODER_NOT_JPG_IMAGE:
147 return "JPEG_DECODER_NOT_JPG_IMAGE";
148 case JPEG_DECODER_UNSUPPORTED_ROTATION_ANGLE:
149 return "JPEG_DECODER_UNSUPPORTED_ROTATION_ANGLE";
150 case JPEG_DECODER_UNSUPPORTED_SCALING:
151 return "JPEG_DECODER_UNSUPPORTED_SCALING";
152 case JPEG_DECODER_INSUFFICIENT_OUTPUTBUFFER_SIZE:
153 return "JPEG_DECODER_INSUFFICIENT_OUTPUTBUFFER_SIZE";
154 case JPEG_DECODER_BAD_HWCFG_GP_VERSION_VALUE:
155 return "JPEG_DECODER_BAD_HWCFG_GP_VERSION_VALUE";
156 case JPEG_DECODER_BAD_VALUE_FROM_RED:
157 return "JPEG_DECODER_BAD_VALUE_FROM_RED";
158 case JPEG_DECODER_BAD_SUBREGION_PARAMETERS:
159 return "JPEG_DECODER_BAD_SUBREGION_PARAMETERS";
160 case JPEG_DECODER_PROGRESSIVE_DECODE_NOT_SUPPORTED:
161 return "JPEG_DECODER_PROGRESSIVE_DECODE_NOT_SUPPORTED";
162 case JPEG_DECODER_ERROR_TASK_TIMEOUT:
163 return "JPEG_DECODER_ERROR_TASK_TIMEOUT";
164 case JPEG_DECODER_ERROR_FEATURE_NOT_SUPPORTED:
165 return "JPEG_DECODER_ERROR_FEATURE_NOT_SUPPORTED";
166 default:
167 return "!unknown MJPEG error!";
168 }
169}
170
171static bool delta_mjpeg_check_status(struct delta_ctx *pctx,
172 struct jpeg_decode_return_params_t *status)
173{
174 struct delta_dev *delta = pctx->dev;
175 bool dump = false;
176
177 if (status->error_code == JPEG_DECODER_NO_ERROR)
178 goto out;
179
180 if (is_stream_error(status->error_code)) {
181 dev_warn_ratelimited(delta->dev,
182 "%s firmware: stream error @ frame %d (%s)\n",
183 pctx->name, pctx->decoded_frames,
184 err_str(status->error_code));
185 pctx->stream_errors++;
186 } else {
187 dev_warn_ratelimited(delta->dev,
188 "%s firmware: decode error @ frame %d (%s)\n",
189 pctx->name, pctx->decoded_frames,
190 err_str(status->error_code));
191 pctx->decode_errors++;
192 dump = true;
193 }
194
195out:
196 dev_dbg(delta->dev,
197 "%s firmware: decoding time(us)=%d\n", pctx->name,
198 status->decode_time_in_us);
199
200 return dump;
201}
202
203static int delta_mjpeg_ipc_open(struct delta_ctx *pctx)
204{
205 struct delta_dev *delta = pctx->dev;
206 struct delta_mjpeg_ctx *ctx = to_ctx(pctx);
207 int ret = 0;
208 struct jpeg_video_decode_init_params_t params_struct;
209 struct jpeg_video_decode_init_params_t *params = &params_struct;
210 struct delta_buf *ipc_buf;
211 u32 ipc_buf_size;
212 struct delta_ipc_param ipc_param;
213 void *hdl;
214
215 memset(params, 0, sizeof(*params));
216 params->circular_buffer_begin_addr_p = 0x00000000;
217 params->circular_buffer_end_addr_p = 0xffffffff;
218
219 dev_vdbg(delta->dev,
220 "%s %s\n", pctx->name,
221 ipc_open_param_str(params, ctx->str, sizeof(ctx->str)));
222
223 ipc_param.size = sizeof(*params);
224 ipc_param.data = params;
225 ipc_buf_size = sizeof(struct jpeg_decode_params_t) +
226 sizeof(struct jpeg_decode_return_params_t);
227 ret = delta_ipc_open(pctx, "JPEG_DECODER_HW0", &ipc_param,
228 ipc_buf_size, &ipc_buf, &hdl);
229 if (ret) {
230 dev_err(delta->dev,
231 "%s dumping command %s\n", pctx->name,
232 ipc_open_param_str(params, ctx->str, sizeof(ctx->str)));
233 return ret;
234 }
235
236 ctx->ipc_buf = ipc_buf;
237 ctx->ipc_hdl = hdl;
238
239 return 0;
240}
241
242static int delta_mjpeg_ipc_decode(struct delta_ctx *pctx, struct delta_au *au)
243{
244 struct delta_dev *delta = pctx->dev;
245 struct delta_mjpeg_ctx *ctx = to_ctx(pctx);
246 int ret = 0;
247 struct jpeg_decode_params_t *params = ctx->ipc_buf->vaddr;
248 struct jpeg_decode_return_params_t *status =
249 ctx->ipc_buf->vaddr + sizeof(*params);
250 struct delta_frame *frame;
251 struct delta_ipc_param ipc_param, ipc_status;
252
253 ret = delta_get_free_frame(pctx, &frame);
254 if (ret)
255 return ret;
256
257 memset(params, 0, sizeof(*params));
258
259 params->picture_start_addr_p = (u32)(au->paddr);
260 params->picture_end_addr_p = (u32)(au->paddr + au->size - 1);
261
262 /*
263 * !WARNING!
264 * the NV12 decoded frame is only available
265 * on decimated output when enabling flag
266 * "JPEG_ADDITIONAL_FLAG_420MB"...
267 * the non decimated output gives YUV422SP
268 */
269 params->main_aux_enable = JPEG_DISP_AUX_EN;
270 params->additional_flags = JPEG_ADDITIONAL_FLAG_420MB;
271 params->horizontal_decimation_factor = JPEG_HDEC_1;
272 params->vertical_decimation_factor = JPEG_VDEC_1;
273 params->decoding_mode = JPEG_NORMAL_DECODE;
274
275 params->display_buffer_addr.struct_size =
276 sizeof(struct jpeg_display_buffer_address_t);
277 params->display_buffer_addr.display_decimated_luma_p =
278 (u32)frame->paddr;
279 params->display_buffer_addr.display_decimated_chroma_p =
280 (u32)(frame->paddr
281 + frame->info.aligned_width * frame->info.aligned_height);
282
283 dev_vdbg(delta->dev,
284 "%s %s\n", pctx->name,
285 ipc_decode_param_str(params, ctx->str, sizeof(ctx->str)));
286
287 /* status */
288 memset(status, 0, sizeof(*status));
289 status->error_code = JPEG_DECODER_NO_ERROR;
290
291 ipc_param.size = sizeof(*params);
292 ipc_param.data = params;
293 ipc_status.size = sizeof(*status);
294 ipc_status.data = status;
295 ret = delta_ipc_decode(ctx->ipc_hdl, &ipc_param, &ipc_status);
296 if (ret) {
297 dev_err(delta->dev,
298 "%s dumping command %s\n", pctx->name,
299 ipc_decode_param_str(params, ctx->str,
300 sizeof(ctx->str)));
301 return ret;
302 }
303
304 pctx->decoded_frames++;
305
306 /* check firmware decoding status */
307 if (delta_mjpeg_check_status(pctx, status)) {
308 dev_err(delta->dev,
309 "%s dumping command %s\n", pctx->name,
310 ipc_decode_param_str(params, ctx->str,
311 sizeof(ctx->str)));
312 }
313
314 frame->field = V4L2_FIELD_NONE;
315 frame->flags = V4L2_BUF_FLAG_KEYFRAME;
316 frame->state |= DELTA_FRAME_DEC;
317
318 ctx->out_frame = frame;
319
320 return 0;
321}
322
323static int delta_mjpeg_open(struct delta_ctx *pctx)
324{
325 struct delta_mjpeg_ctx *ctx;
326
327 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
328 if (!ctx)
329 return -ENOMEM;
330 pctx->priv = ctx;
331
332 return 0;
333}
334
335static int delta_mjpeg_close(struct delta_ctx *pctx)
336{
337 struct delta_mjpeg_ctx *ctx = to_ctx(pctx);
338
339 if (ctx->ipc_hdl) {
340 delta_ipc_close(ctx->ipc_hdl);
341 ctx->ipc_hdl = NULL;
342 }
343
344 kfree(ctx);
345
346 return 0;
347}
348
349static int delta_mjpeg_get_streaminfo(struct delta_ctx *pctx,
350 struct delta_streaminfo *streaminfo)
351{
352 struct delta_mjpeg_ctx *ctx = to_ctx(pctx);
353
354 if (!ctx->header)
355 goto nodata;
356
357 streaminfo->streamformat = V4L2_PIX_FMT_MJPEG;
358 streaminfo->width = ctx->header->frame_width;
359 streaminfo->height = ctx->header->frame_height;
360
361 /* progressive stream */
362 streaminfo->field = V4L2_FIELD_NONE;
363
364 streaminfo->dpb = 1;
365
366 return 0;
367
368nodata:
369 return -ENODATA;
370}
371
372static int delta_mjpeg_decode(struct delta_ctx *pctx, struct delta_au *pau)
373{
374 struct delta_dev *delta = pctx->dev;
375 struct delta_mjpeg_ctx *ctx = to_ctx(pctx);
376 int ret;
377 struct delta_au au = *pau;
378 unsigned int data_offset;
379 struct mjpeg_header *header = &ctx->header_struct;
380
381 if (!ctx->header) {
382 ret = delta_mjpeg_read_header(pctx, au.vaddr, au.size,
383 header, &data_offset);
384 if (ret) {
385 pctx->stream_errors++;
386 goto err;
387 }
388 if (header->frame_width * header->frame_height >
389 DELTA_MJPEG_MAX_RESO) {
390 dev_err(delta->dev,
391 "%s stream resolution too large: %dx%d > %d pixels budget\n",
392 pctx->name,
393 header->frame_width,
394 header->frame_height, DELTA_MJPEG_MAX_RESO);
395 ret = -EINVAL;
396 goto err;
397 }
398 ctx->header = header;
399 goto out;
400 }
401
402 if (!ctx->ipc_hdl) {
403 ret = delta_mjpeg_ipc_open(pctx);
404 if (ret)
405 goto err;
406 }
407
408 ret = delta_mjpeg_read_header(pctx, au.vaddr, au.size,
409 ctx->header, &data_offset);
410 if (ret) {
411 pctx->stream_errors++;
412 goto err;
413 }
414
415 au.paddr += data_offset;
416 au.vaddr += data_offset;
417
418 ret = delta_mjpeg_ipc_decode(pctx, &au);
419 if (ret)
420 goto err;
421
422out:
423 return 0;
424
425err:
426 return ret;
427}
428
429static int delta_mjpeg_get_frame(struct delta_ctx *pctx,
430 struct delta_frame **frame)
431{
432 struct delta_mjpeg_ctx *ctx = to_ctx(pctx);
433
434 if (!ctx->out_frame)
435 return -ENODATA;
436
437 *frame = ctx->out_frame;
438
439 ctx->out_frame = NULL;
440
441 return 0;
442}
443
444const struct delta_dec mjpegdec = {
445 .name = "MJPEG",
446 .streamformat = V4L2_PIX_FMT_MJPEG,
447 .pixelformat = V4L2_PIX_FMT_NV12,
448 .open = delta_mjpeg_open,
449 .close = delta_mjpeg_close,
450 .get_streaminfo = delta_mjpeg_get_streaminfo,
451 .get_frameinfo = delta_get_frameinfo_default,
452 .decode = delta_mjpeg_decode,
453 .get_frame = delta_mjpeg_get_frame,
454 .recycle = delta_recycle_default,
455};
diff --git a/drivers/media/platform/sti/delta/delta-mjpeg-fw.h b/drivers/media/platform/sti/delta/delta-mjpeg-fw.h
new file mode 100644
index 000000000000..de803d0c2fe8
--- /dev/null
+++ b/drivers/media/platform/sti/delta/delta-mjpeg-fw.h
@@ -0,0 +1,225 @@
1/*
2 * Copyright (C) STMicroelectronics SA 2015
3 * Author: Hugues Fruchet <hugues.fruchet@st.com> for STMicroelectronics.
4 * License terms: GNU General Public License (GPL), version 2
5 */
6
7#ifndef DELTA_MJPEG_FW_H
8#define DELTA_MJPEG_FW_H
9
10/*
11 * struct jpeg_decoded_buffer_address_t
12 *
13 * defines the addresses where the decoded picture/additional
14 * info related to the block structures will be stored
15 *
16 * @display_luma_p: address of the luma buffer
17 * @display_chroma_p: address of the chroma buffer
18 */
19struct jpeg_decoded_buffer_address_t {
20 u32 luma_p;
21 u32 chroma_p;
22};
23
24/*
25 * struct jpeg_display_buffer_address_t
26 *
27 * defines the addresses (used by the Display Reconstruction block)
28 * where the pictures to be displayed will be stored
29 *
30 * @struct_size: size of the structure in bytes
31 * @display_luma_p: address of the luma buffer
32 * @display_chroma_p: address of the chroma buffer
33 * @display_decimated_luma_p: address of the decimated luma buffer
34 * @display_decimated_chroma_p: address of the decimated chroma buffer
35 */
36struct jpeg_display_buffer_address_t {
37 u32 struct_size;
38 u32 display_luma_p;
39 u32 display_chroma_p;
40 u32 display_decimated_luma_p;
41 u32 display_decimated_chroma_p;
42};
43
44/*
45 * used for enabling main/aux outputs for both display &
46 * reference reconstruction blocks
47 */
48enum jpeg_rcn_ref_disp_enable_t {
49 /* enable decimated (for display) reconstruction */
50 JPEG_DISP_AUX_EN = 0x00000010,
51 /* enable main (for display) reconstruction */
52 JPEG_DISP_MAIN_EN = 0x00000020,
53 /* enable both main & decimated (for display) reconstruction */
54 JPEG_DISP_AUX_MAIN_EN = 0x00000030,
55 /* enable only reference output(ex. for trick modes) */
56 JPEG_REF_MAIN_EN = 0x00000100,
57 /*
58 * enable reference output with decimated
59 * (for display) reconstruction
60 */
61 JPEG_REF_MAIN_DISP_AUX_EN = 0x00000110,
62 /*
63 * enable reference output with main
64 * (for display) reconstruction
65 */
66 JPEG_REF_MAIN_DISP_MAIN_EN = 0x00000120,
67 /*
68 * enable reference output with main & decimated
69 * (for display) reconstruction
70 */
71 JPEG_REF_MAIN_DISP_MAIN_AUX_EN = 0x00000130
72};
73
74/* identifies the horizontal decimation factor */
75enum jpeg_horizontal_deci_factor_t {
76 /* no resize */
77 JPEG_HDEC_1 = 0x00000000,
78 /* Advanced H/2 resize using improved 8-tap filters */
79 JPEG_HDEC_ADVANCED_2 = 0x00000101,
80 /* Advanced H/4 resize using improved 8-tap filters */
81 JPEG_HDEC_ADVANCED_4 = 0x00000102
82};
83
84/* identifies the vertical decimation factor */
85enum jpeg_vertical_deci_factor_t {
86 /* no resize */
87 JPEG_VDEC_1 = 0x00000000,
88 /* V/2 , progressive resize */
89 JPEG_VDEC_ADVANCED_2_PROG = 0x00000204,
90 /* V/2 , interlaced resize */
91 JPEG_VDEC_ADVANCED_2_INT = 0x000000208
92};
93
94/* status of the decoding process */
95enum jpeg_decoding_error_t {
96 JPEG_DECODER_NO_ERROR = 0,
97 JPEG_DECODER_UNDEFINED_HUFF_TABLE = 1,
98 JPEG_DECODER_UNSUPPORTED_MARKER = 2,
99 JPEG_DECODER_UNABLE_ALLOCATE_MEMORY = 3,
100 JPEG_DECODER_NON_SUPPORTED_SAMP_FACTORS = 4,
101 JPEG_DECODER_BAD_PARAMETER = 5,
102 JPEG_DECODER_DECODE_ERROR = 6,
103 JPEG_DECODER_BAD_RESTART_MARKER = 7,
104 JPEG_DECODER_UNSUPPORTED_COLORSPACE = 8,
105 JPEG_DECODER_BAD_SOS_SPECTRAL = 9,
106 JPEG_DECODER_BAD_SOS_SUCCESSIVE = 10,
107 JPEG_DECODER_BAD_HEADER_LENGTH = 11,
108 JPEG_DECODER_BAD_COUNT_VALUE = 12,
109 JPEG_DECODER_BAD_DHT_MARKER = 13,
110 JPEG_DECODER_BAD_INDEX_VALUE = 14,
111 JPEG_DECODER_BAD_NUMBER_HUFFMAN_TABLES = 15,
112 JPEG_DECODER_BAD_QUANT_TABLE_LENGTH = 16,
113 JPEG_DECODER_BAD_NUMBER_QUANT_TABLES = 17,
114 JPEG_DECODER_BAD_COMPONENT_COUNT = 18,
115 JPEG_DECODER_DIVIDE_BY_ZERO_ERROR = 19,
116 JPEG_DECODER_NOT_JPG_IMAGE = 20,
117 JPEG_DECODER_UNSUPPORTED_ROTATION_ANGLE = 21,
118 JPEG_DECODER_UNSUPPORTED_SCALING = 22,
119 JPEG_DECODER_INSUFFICIENT_OUTPUTBUFFER_SIZE = 23,
120 JPEG_DECODER_BAD_HWCFG_GP_VERSION_VALUE = 24,
121 JPEG_DECODER_BAD_VALUE_FROM_RED = 25,
122 JPEG_DECODER_BAD_SUBREGION_PARAMETERS = 26,
123 JPEG_DECODER_PROGRESSIVE_DECODE_NOT_SUPPORTED = 27,
124 JPEG_DECODER_ERROR_TASK_TIMEOUT = 28,
125 JPEG_DECODER_ERROR_FEATURE_NOT_SUPPORTED = 29
126};
127
128/* identifies the decoding mode */
129enum jpeg_decoding_mode_t {
130 JPEG_NORMAL_DECODE = 0,
131};
132
133enum jpeg_additional_flags_t {
134 JPEG_ADDITIONAL_FLAG_NONE = 0,
135 /* request firmware to return values of the CEH registers */
136 JPEG_ADDITIONAL_FLAG_CEH = 1,
137 /* output storage of auxiliary reconstruction in Raster format. */
138 JPEG_ADDITIONAL_FLAG_RASTER = 64,
139 /* output storage of auxiliary reconstruction in 420MB format. */
140 JPEG_ADDITIONAL_FLAG_420MB = 128
141};
142
143/*
144 * struct jpeg_video_decode_init_params_t - initialization command parameters
145 *
146 * @circular_buffer_begin_addr_p: start address of fw circular buffer
147 * @circular_buffer_end_addr_p: end address of fw circular buffer
148 */
149struct jpeg_video_decode_init_params_t {
150 u32 circular_buffer_begin_addr_p;
151 u32 circular_buffer_end_addr_p;
152 u32 reserved;
153};
154
155/*
156 * struct jpeg_decode_params_t - decode command parameters
157 *
158 * @picture_start_addr_p: start address of jpeg picture
159 * @picture_end_addr_p: end address of jpeg picture
160 * @decoded_buffer_addr: decoded picture buffer
161 * @display_buffer_addr: display picture buffer
162 * @main_aux_enable: enable main and/or aux outputs
163 * @horizontal_decimation_factor:horizontal decimation factor
164 * @vertical_decimation_factor: vertical decimation factor
165 * @xvalue0: the x(0) coordinate for subregion decoding
166 * @xvalue1: the x(1) coordinate for subregion decoding
167 * @yvalue0: the y(0) coordinate for subregion decoding
168 * @yvalue1: the y(1) coordinate for subregion decoding
169 * @decoding_mode: decoding mode
170 * @additional_flags: additional flags
171 * @field_flag: determines frame/field scan
172 * @is_jpeg_image: 1 = still jpeg, 0 = motion jpeg
173 */
174struct jpeg_decode_params_t {
175 u32 picture_start_addr_p;
176 u32 picture_end_addr_p;
177 struct jpeg_decoded_buffer_address_t decoded_buffer_addr;
178 struct jpeg_display_buffer_address_t display_buffer_addr;
179 enum jpeg_rcn_ref_disp_enable_t main_aux_enable;
180 enum jpeg_horizontal_deci_factor_t horizontal_decimation_factor;
181 enum jpeg_vertical_deci_factor_t vertical_decimation_factor;
182 u32 xvalue0;
183 u32 xvalue1;
184 u32 yvalue0;
185 u32 yvalue1;
186 enum jpeg_decoding_mode_t decoding_mode;
187 u32 additional_flags;
188 u32 field_flag;
189 u32 reserved;
190 u32 is_jpeg_image;
191};
192
193/*
194 * struct jpeg_decode_return_params_t
195 *
196 * status returned by firmware after decoding
197 *
198 * @decode_time_in_us: decoding time in microseconds
199 * @pm_cycles: profiling information
200 * @pm_dmiss: profiling information
201 * @pm_imiss: profiling information
202 * @pm_bundles: profiling information
203 * @pm_pft: profiling information
204 * @error_code: status of the decoding process
205 * @ceh_registers: array where values of the Contrast Enhancement
206 * Histogram (CEH) registers will be stored.
207 * ceh_registers[0] correspond to register MBE_CEH_0_7,
208 * ceh_registers[1] correspond to register MBE_CEH_8_15
209 * ceh_registers[2] correspond to register MBE_CEH_16_23
210 * Note that elements of this array will be updated only
211 * if additional_flags has JPEG_ADDITIONAL_FLAG_CEH set.
212 */
213struct jpeg_decode_return_params_t {
214 /* profiling info */
215 u32 decode_time_in_us;
216 u32 pm_cycles;
217 u32 pm_dmiss;
218 u32 pm_imiss;
219 u32 pm_bundles;
220 u32 pm_pft;
221 enum jpeg_decoding_error_t error_code;
222 u32 ceh_registers[32];
223};
224
225#endif /* DELTA_MJPEG_FW_H */
diff --git a/drivers/media/platform/sti/delta/delta-mjpeg-hdr.c b/drivers/media/platform/sti/delta/delta-mjpeg-hdr.c
new file mode 100644
index 000000000000..a8fd8fa0ecb5
--- /dev/null
+++ b/drivers/media/platform/sti/delta/delta-mjpeg-hdr.c
@@ -0,0 +1,149 @@
1/*
2 * Copyright (C) STMicroelectronics SA 2013
3 * Author: Hugues Fruchet <hugues.fruchet@st.com> for STMicroelectronics.
4 * License terms: GNU General Public License (GPL), version 2
5 */
6
7#include "delta.h"
8#include "delta-mjpeg.h"
9
10#define MJPEG_SOF_0 0xc0
11#define MJPEG_SOF_1 0xc1
12#define MJPEG_SOI 0xd8
13#define MJPEG_MARKER 0xff
14
15static char *header_str(struct mjpeg_header *header,
16 char *str,
17 unsigned int len)
18{
19 char *cur = str;
20 unsigned int left = len;
21
22 if (!header)
23 return "";
24
25 snprintf(cur, left, "[MJPEG header]\n"
26 "|- length = %d\n"
27 "|- precision = %d\n"
28 "|- width = %d\n"
29 "|- height = %d\n"
30 "|- components = %d\n",
31 header->length,
32 header->sample_precision,
33 header->frame_width,
34 header->frame_height,
35 header->nb_of_components);
36
37 return str;
38}
39
40static int delta_mjpeg_read_sof(struct delta_ctx *pctx,
41 unsigned char *data, unsigned int size,
42 struct mjpeg_header *header)
43{
44 struct delta_dev *delta = pctx->dev;
45 unsigned int offset = 0;
46
47 if (size < 64)
48 goto err_no_more;
49
50 memset(header, 0, sizeof(*header));
51 header->length = be16_to_cpu(*(__be16 *)(data + offset));
52 offset += sizeof(u16);
53 header->sample_precision = *(u8 *)(data + offset);
54 offset += sizeof(u8);
55 header->frame_height = be16_to_cpu(*(__be16 *)(data + offset));
56 offset += sizeof(u16);
57 header->frame_width = be16_to_cpu(*(__be16 *)(data + offset));
58 offset += sizeof(u16);
59 header->nb_of_components = *(u8 *)(data + offset);
60 offset += sizeof(u8);
61
62 if (header->nb_of_components >= MJPEG_MAX_COMPONENTS) {
63 dev_err(delta->dev,
64 "%s unsupported number of components (%d > %d)\n",
65 pctx->name, header->nb_of_components,
66 MJPEG_MAX_COMPONENTS);
67 return -EINVAL;
68 }
69
70 if ((offset + header->nb_of_components *
71 sizeof(header->components[0])) > size)
72 goto err_no_more;
73
74 return 0;
75
76err_no_more:
77 dev_err(delta->dev,
78 "%s sof: reached end of %d size input stream\n",
79 pctx->name, size);
80 return -ENODATA;
81}
82
83int delta_mjpeg_read_header(struct delta_ctx *pctx,
84 unsigned char *data, unsigned int size,
85 struct mjpeg_header *header,
86 unsigned int *data_offset)
87{
88 struct delta_dev *delta = pctx->dev;
89 unsigned char str[200];
90
91 unsigned int ret = 0;
92 unsigned int offset = 0;
93 unsigned int soi = 0;
94
95 if (size < 2)
96 goto err_no_more;
97
98 offset = 0;
99 while (1) {
100 if (data[offset] == MJPEG_MARKER)
101 switch (data[offset + 1]) {
102 case MJPEG_SOI:
103 soi = 1;
104 *data_offset = offset;
105 break;
106
107 case MJPEG_SOF_0:
108 case MJPEG_SOF_1:
109 if (!soi) {
110 dev_err(delta->dev,
111 "%s wrong sequence, got SOF while SOI not seen\n",
112 pctx->name);
113 return -EINVAL;
114 }
115
116 ret = delta_mjpeg_read_sof(pctx,
117 &data[offset + 2],
118 size - (offset + 2),
119 header);
120 if (ret)
121 goto err;
122
123 goto done;
124
125 default:
126 break;
127 }
128
129 offset++;
130 if ((offset + 2) >= size)
131 goto err_no_more;
132 }
133
134done:
135 dev_dbg(delta->dev,
136 "%s found header @ offset %d:\n%s", pctx->name,
137 *data_offset,
138 header_str(header, str, sizeof(str)));
139 return 0;
140
141err_no_more:
142 dev_err(delta->dev,
143 "%s no header found within %d bytes input stream\n",
144 pctx->name, size);
145 return -ENODATA;
146
147err:
148 return ret;
149}
diff --git a/drivers/media/platform/sti/delta/delta-mjpeg.h b/drivers/media/platform/sti/delta/delta-mjpeg.h
new file mode 100644
index 000000000000..18e6b37217ee
--- /dev/null
+++ b/drivers/media/platform/sti/delta/delta-mjpeg.h
@@ -0,0 +1,35 @@
1/*
2 * Copyright (C) STMicroelectronics SA 2013
3 * Author: Hugues Fruchet <hugues.fruchet@st.com> for STMicroelectronics.
4 * License terms: GNU General Public License (GPL), version 2
5 */
6
7#ifndef DELTA_MJPEG_H
8#define DELTA_MJPEG_H
9
10#include "delta.h"
11
12struct mjpeg_component {
13 unsigned int id;/* 1=Y, 2=Cb, 3=Cr, 4=L, 5=Q */
14 unsigned int h_sampling_factor;
15 unsigned int v_sampling_factor;
16 unsigned int quant_table_index;
17};
18
19#define MJPEG_MAX_COMPONENTS 5
20
21struct mjpeg_header {
22 unsigned int length;
23 unsigned int sample_precision;
24 unsigned int frame_width;
25 unsigned int frame_height;
26 unsigned int nb_of_components;
27 struct mjpeg_component components[MJPEG_MAX_COMPONENTS];
28};
29
30int delta_mjpeg_read_header(struct delta_ctx *pctx,
31 unsigned char *data, unsigned int size,
32 struct mjpeg_header *header,
33 unsigned int *data_offset);
34
35#endif /* DELTA_MJPEG_H */
diff --git a/drivers/media/platform/sti/delta/delta-v4l2.c b/drivers/media/platform/sti/delta/delta-v4l2.c
new file mode 100644
index 000000000000..c6f2e244b7a8
--- /dev/null
+++ b/drivers/media/platform/sti/delta/delta-v4l2.c
@@ -0,0 +1,1993 @@
1/*
2 * Copyright (C) STMicroelectronics SA 2015
3 * Authors: Hugues Fruchet <hugues.fruchet@st.com>
4 * Jean-Christophe Trotin <jean-christophe.trotin@st.com>
5 * for STMicroelectronics.
6 * License terms: GNU General Public License (GPL), version 2
7 */
8
9#include <linux/clk.h>
10#include <linux/module.h>
11#include <linux/platform_device.h>
12#include <linux/pm_runtime.h>
13#include <linux/slab.h>
14
15#include <media/v4l2-ioctl.h>
16#include <media/v4l2-event.h>
17#include <media/videobuf2-dma-contig.h>
18
19#include "delta.h"
20#include "delta-debug.h"
21#include "delta-ipc.h"
22
23#define DELTA_NAME "st-delta"
24
25#define DELTA_PREFIX "[---:----]"
26
27#define to_ctx(__fh) container_of(__fh, struct delta_ctx, fh)
28#define to_au(__vbuf) container_of(__vbuf, struct delta_au, vbuf)
29#define to_frame(__vbuf) container_of(__vbuf, struct delta_frame, vbuf)
30
31#define call_dec_op(dec, op, args...)\
32 ((dec && (dec)->op) ? (dec)->op(args) : 0)
33
34/* registry of available decoders */
35static const struct delta_dec *delta_decoders[] = {
36#ifdef CONFIG_VIDEO_STI_DELTA_MJPEG
37 &mjpegdec,
38#endif
39};
40
41static inline int frame_size(u32 w, u32 h, u32 fmt)
42{
43 switch (fmt) {
44 case V4L2_PIX_FMT_NV12:
45 return (w * h * 3) / 2;
46 default:
47 return 0;
48 }
49}
50
51static inline int frame_stride(u32 w, u32 fmt)
52{
53 switch (fmt) {
54 case V4L2_PIX_FMT_NV12:
55 return w;
56 default:
57 return 0;
58 }
59}
60
61static void dump_au(struct delta_ctx *ctx, struct delta_au *au)
62{
63 struct delta_dev *delta = ctx->dev;
64 u32 size = 10; /* dump first & last 10 bytes */
65 u8 *data = (u8 *)(au->vaddr);
66
67 if (au->size <= (size * 2))
68 dev_dbg(delta->dev, "%s dump au[%d] dts=%lld size=%d data=%*ph\n",
69 ctx->name, au->vbuf.vb2_buf.index, au->dts, au->size,
70 au->size, data);
71 else
72 dev_dbg(delta->dev, "%s dump au[%d] dts=%lld size=%d data=%*ph..%*ph\n",
73 ctx->name, au->vbuf.vb2_buf.index, au->dts, au->size,
74 size, data, size, data + au->size - size);
75}
76
77static void dump_frame(struct delta_ctx *ctx, struct delta_frame *frame)
78{
79 struct delta_dev *delta = ctx->dev;
80 u32 size = 10; /* dump first 10 bytes */
81 u8 *data = (u8 *)(frame->vaddr);
82
83 dev_dbg(delta->dev, "%s dump frame[%d] dts=%lld type=%s field=%s data=%*ph\n",
84 ctx->name, frame->index, frame->dts,
85 frame_type_str(frame->flags),
86 frame_field_str(frame->field),
87 size, data);
88}
89
90static void delta_au_done(struct delta_ctx *ctx, struct delta_au *au, int err)
91{
92 struct vb2_v4l2_buffer *vbuf;
93
94 vbuf = &au->vbuf;
95 vbuf->sequence = ctx->au_num++;
96 v4l2_m2m_buf_done(vbuf, err ? VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
97}
98
99static void delta_frame_done(struct delta_ctx *ctx, struct delta_frame *frame,
100 int err)
101{
102 struct vb2_v4l2_buffer *vbuf;
103
104 dump_frame(ctx, frame);
105
106 /* decoded frame is now output to user */
107 frame->state |= DELTA_FRAME_OUT;
108
109 vbuf = &frame->vbuf;
110 vbuf->sequence = ctx->frame_num++;
111 v4l2_m2m_buf_done(vbuf, err ? VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
112
113 if (frame->info.size) /* ignore EOS */
114 ctx->output_frames++;
115}
116
117static void requeue_free_frames(struct delta_ctx *ctx)
118{
119 struct vb2_v4l2_buffer *vbuf;
120 struct delta_frame *frame;
121 unsigned int i;
122
123 /* requeue all free frames */
124 for (i = 0; i < ctx->nb_of_frames; i++) {
125 frame = ctx->frames[i];
126 if (frame->state == DELTA_FRAME_FREE) {
127 vbuf = &frame->vbuf;
128 v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf);
129 frame->state = DELTA_FRAME_M2M;
130 }
131 }
132}
133
134static int delta_recycle(struct delta_ctx *ctx, struct delta_frame *frame)
135{
136 const struct delta_dec *dec = ctx->dec;
137
138 /* recycle frame on decoder side */
139 call_dec_op(dec, recycle, ctx, frame);
140
141 /* this frame is no more output */
142 frame->state &= ~DELTA_FRAME_OUT;
143
144 /* requeue free frame */
145 if (frame->state == DELTA_FRAME_FREE) {
146 struct vb2_v4l2_buffer *vbuf = &frame->vbuf;
147
148 v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf);
149 frame->state = DELTA_FRAME_M2M;
150 }
151
152 /* reset other frame fields */
153 frame->flags = 0;
154 frame->dts = 0;
155
156 return 0;
157}
158
159static void delta_push_dts(struct delta_ctx *ctx, u64 val)
160{
161 struct delta_dts *dts;
162
163 dts = kzalloc(sizeof(*dts), GFP_KERNEL);
164 if (!dts)
165 return;
166
167 INIT_LIST_HEAD(&dts->list);
168
169 /*
170 * protected by global lock acquired
171 * by V4L2 when calling delta_vb2_au_queue
172 */
173 dts->val = val;
174 list_add_tail(&dts->list, &ctx->dts);
175}
176
177static void delta_pop_dts(struct delta_ctx *ctx, u64 *val)
178{
179 struct delta_dev *delta = ctx->dev;
180 struct delta_dts *dts;
181
182 /*
183 * protected by global lock acquired
184 * by V4L2 when calling delta_vb2_au_queue
185 */
186 if (list_empty(&ctx->dts)) {
187 dev_warn(delta->dev, "%s no dts to pop ... output dts = 0\n",
188 ctx->name);
189 *val = 0;
190 return;
191 }
192
193 dts = list_first_entry(&ctx->dts, struct delta_dts, list);
194 list_del(&dts->list);
195
196 *val = dts->val;
197
198 kfree(dts);
199}
200
201static void delta_flush_dts(struct delta_ctx *ctx)
202{
203 struct delta_dts *dts;
204 struct delta_dts *next;
205
206 /*
207 * protected by global lock acquired
208 * by V4L2 when calling delta_vb2_au_queue
209 */
210
211 /* free all pending dts */
212 list_for_each_entry_safe(dts, next, &ctx->dts, list)
213 kfree(dts);
214
215 /* reset list */
216 INIT_LIST_HEAD(&ctx->dts);
217}
218
219static inline int frame_alignment(u32 fmt)
220{
221 switch (fmt) {
222 case V4L2_PIX_FMT_NV12:
223 case V4L2_PIX_FMT_NV21:
224 /* multiple of 2 */
225 return 2;
226 default:
227 return 1;
228 }
229}
230
231static inline int estimated_au_size(u32 w, u32 h)
232{
233 /*
234 * for a MJPEG stream encoded from YUV422 pixel format,
235 * assuming a compression ratio of 2, the maximum size
236 * of an access unit is (width x height x 2) / 2,
237 * so (width x height)
238 */
239 return (w * h);
240}
241
242static void set_default_params(struct delta_ctx *ctx)
243{
244 struct delta_frameinfo *frameinfo = &ctx->frameinfo;
245 struct delta_streaminfo *streaminfo = &ctx->streaminfo;
246
247 memset(frameinfo, 0, sizeof(*frameinfo));
248 frameinfo->pixelformat = V4L2_PIX_FMT_NV12;
249 frameinfo->width = DELTA_DEFAULT_WIDTH;
250 frameinfo->height = DELTA_DEFAULT_HEIGHT;
251 frameinfo->aligned_width = ALIGN(frameinfo->width,
252 DELTA_WIDTH_ALIGNMENT);
253 frameinfo->aligned_height = ALIGN(frameinfo->height,
254 DELTA_HEIGHT_ALIGNMENT);
255 frameinfo->size = frame_size(frameinfo->aligned_width,
256 frameinfo->aligned_height,
257 frameinfo->pixelformat);
258 frameinfo->field = V4L2_FIELD_NONE;
259 frameinfo->colorspace = V4L2_COLORSPACE_REC709;
260 frameinfo->xfer_func = V4L2_XFER_FUNC_DEFAULT;
261 frameinfo->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
262 frameinfo->quantization = V4L2_QUANTIZATION_DEFAULT;
263
264 memset(streaminfo, 0, sizeof(*streaminfo));
265 streaminfo->streamformat = DELTA_DEFAULT_STREAMFORMAT;
266 streaminfo->width = DELTA_DEFAULT_WIDTH;
267 streaminfo->height = DELTA_DEFAULT_HEIGHT;
268 streaminfo->field = V4L2_FIELD_NONE;
269 streaminfo->colorspace = V4L2_COLORSPACE_REC709;
270 streaminfo->xfer_func = V4L2_XFER_FUNC_DEFAULT;
271 streaminfo->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
272 streaminfo->quantization = V4L2_QUANTIZATION_DEFAULT;
273
274 ctx->max_au_size = estimated_au_size(streaminfo->width,
275 streaminfo->height);
276}
277
278static const struct delta_dec *delta_find_decoder(struct delta_ctx *ctx,
279 u32 streamformat,
280 u32 pixelformat)
281{
282 struct delta_dev *delta = ctx->dev;
283 const struct delta_dec *dec;
284 unsigned int i;
285
286 for (i = 0; i < delta->nb_of_decoders; i++) {
287 dec = delta->decoders[i];
288 if ((dec->pixelformat == pixelformat) &&
289 (dec->streamformat == streamformat))
290 return dec;
291 }
292
293 return NULL;
294}
295
296static void register_format(u32 format, u32 formats[], u32 *nb_of_formats)
297{
298 u32 i;
299
300 for (i = 0; i < *nb_of_formats; i++) {
301 if (format == formats[i])
302 return;
303 }
304
305 formats[(*nb_of_formats)++] = format;
306}
307
308static void register_formats(struct delta_dev *delta)
309{
310 unsigned int i;
311
312 for (i = 0; i < delta->nb_of_decoders; i++) {
313 register_format(delta->decoders[i]->pixelformat,
314 delta->pixelformats,
315 &delta->nb_of_pixelformats);
316
317 register_format(delta->decoders[i]->streamformat,
318 delta->streamformats,
319 &delta->nb_of_streamformats);
320 }
321}
322
323static void register_decoders(struct delta_dev *delta)
324{
325 unsigned int i;
326
327 for (i = 0; i < ARRAY_SIZE(delta_decoders); i++) {
328 if (delta->nb_of_decoders >= DELTA_MAX_DECODERS) {
329 dev_dbg(delta->dev,
330 "%s failed to register %s decoder (%d maximum reached)\n",
331 DELTA_PREFIX, delta_decoders[i]->name,
332 DELTA_MAX_DECODERS);
333 return;
334 }
335
336 delta->decoders[delta->nb_of_decoders++] = delta_decoders[i];
337 dev_info(delta->dev, "%s %s decoder registered\n",
338 DELTA_PREFIX, delta_decoders[i]->name);
339 }
340}
341
342static void delta_lock(void *priv)
343{
344 struct delta_ctx *ctx = priv;
345 struct delta_dev *delta = ctx->dev;
346
347 mutex_lock(&delta->lock);
348}
349
350static void delta_unlock(void *priv)
351{
352 struct delta_ctx *ctx = priv;
353 struct delta_dev *delta = ctx->dev;
354
355 mutex_unlock(&delta->lock);
356}
357
358static int delta_open_decoder(struct delta_ctx *ctx, u32 streamformat,
359 u32 pixelformat, const struct delta_dec **pdec)
360{
361 struct delta_dev *delta = ctx->dev;
362 const struct delta_dec *dec;
363 int ret;
364
365 dec = delta_find_decoder(ctx, streamformat, ctx->frameinfo.pixelformat);
366 if (!dec) {
367 dev_err(delta->dev, "%s no decoder found matching %4.4s => %4.4s\n",
368 ctx->name, (char *)&streamformat, (char *)&pixelformat);
369 return -EINVAL;
370 }
371
372 dev_dbg(delta->dev, "%s one decoder matching %4.4s => %4.4s\n",
373 ctx->name, (char *)&streamformat, (char *)&pixelformat);
374
375 /* update instance name */
376 snprintf(ctx->name, sizeof(ctx->name), "[%3d:%4.4s]",
377 delta->instance_id, (char *)&streamformat);
378
379 /* open decoder instance */
380 ret = call_dec_op(dec, open, ctx);
381 if (ret) {
382 dev_err(delta->dev, "%s failed to open decoder instance (%d)\n",
383 ctx->name, ret);
384 return ret;
385 }
386
387 dev_dbg(delta->dev, "%s %s decoder opened\n", ctx->name, dec->name);
388
389 *pdec = dec;
390
391 return ret;
392}
393
394/*
395 * V4L2 ioctl operations
396 */
397
398static int delta_querycap(struct file *file, void *priv,
399 struct v4l2_capability *cap)
400{
401 struct delta_ctx *ctx = to_ctx(file->private_data);
402 struct delta_dev *delta = ctx->dev;
403
404 strlcpy(cap->driver, DELTA_NAME, sizeof(cap->driver));
405 strlcpy(cap->card, delta->vdev->name, sizeof(cap->card));
406 snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
407 delta->pdev->name);
408
409 return 0;
410}
411
412static int delta_enum_fmt_stream(struct file *file, void *priv,
413 struct v4l2_fmtdesc *f)
414{
415 struct delta_ctx *ctx = to_ctx(file->private_data);
416 struct delta_dev *delta = ctx->dev;
417
418 if (unlikely(f->index >= delta->nb_of_streamformats))
419 return -EINVAL;
420
421 f->pixelformat = delta->streamformats[f->index];
422
423 return 0;
424}
425
426static int delta_enum_fmt_frame(struct file *file, void *priv,
427 struct v4l2_fmtdesc *f)
428{
429 struct delta_ctx *ctx = to_ctx(file->private_data);
430 struct delta_dev *delta = ctx->dev;
431
432 if (unlikely(f->index >= delta->nb_of_pixelformats))
433 return -EINVAL;
434
435 f->pixelformat = delta->pixelformats[f->index];
436
437 return 0;
438}
439
440static int delta_g_fmt_stream(struct file *file, void *fh,
441 struct v4l2_format *f)
442{
443 struct delta_ctx *ctx = to_ctx(file->private_data);
444 struct delta_dev *delta = ctx->dev;
445 struct v4l2_pix_format *pix = &f->fmt.pix;
446 struct delta_streaminfo *streaminfo = &ctx->streaminfo;
447 unsigned char str[100] = "";
448
449 if (!(ctx->flags & DELTA_FLAG_STREAMINFO))
450 dev_dbg(delta->dev,
451 "%s V4L2 GET_FMT (OUTPUT): no stream information available, default to %s\n",
452 ctx->name,
453 delta_streaminfo_str(streaminfo, str, sizeof(str)));
454
455 pix->pixelformat = streaminfo->streamformat;
456 pix->width = streaminfo->width;
457 pix->height = streaminfo->height;
458 pix->field = streaminfo->field;
459 pix->bytesperline = 0;
460 pix->sizeimage = ctx->max_au_size;
461 pix->colorspace = streaminfo->colorspace;
462 pix->xfer_func = streaminfo->xfer_func;
463 pix->ycbcr_enc = streaminfo->ycbcr_enc;
464 pix->quantization = streaminfo->quantization;
465
466 return 0;
467}
468
469static int delta_g_fmt_frame(struct file *file, void *fh, struct v4l2_format *f)
470{
471 struct delta_ctx *ctx = to_ctx(file->private_data);
472 struct delta_dev *delta = ctx->dev;
473 struct v4l2_pix_format *pix = &f->fmt.pix;
474 struct delta_frameinfo *frameinfo = &ctx->frameinfo;
475 struct delta_streaminfo *streaminfo = &ctx->streaminfo;
476 unsigned char str[100] = "";
477
478 if (!(ctx->flags & DELTA_FLAG_FRAMEINFO))
479 dev_dbg(delta->dev,
480 "%s V4L2 GET_FMT (CAPTURE): no frame information available, default to %s\n",
481 ctx->name,
482 delta_frameinfo_str(frameinfo, str, sizeof(str)));
483
484 pix->pixelformat = frameinfo->pixelformat;
485 pix->width = frameinfo->aligned_width;
486 pix->height = frameinfo->aligned_height;
487 pix->field = frameinfo->field;
488 pix->bytesperline = frame_stride(frameinfo->aligned_width,
489 frameinfo->pixelformat);
490 pix->sizeimage = frameinfo->size;
491
492 if (ctx->flags & DELTA_FLAG_STREAMINFO) {
493 /* align colorspace & friends on stream ones if any set */
494 frameinfo->colorspace = streaminfo->colorspace;
495 frameinfo->xfer_func = streaminfo->xfer_func;
496 frameinfo->ycbcr_enc = streaminfo->ycbcr_enc;
497 frameinfo->quantization = streaminfo->quantization;
498 }
499 pix->colorspace = frameinfo->colorspace;
500 pix->xfer_func = frameinfo->xfer_func;
501 pix->ycbcr_enc = frameinfo->ycbcr_enc;
502 pix->quantization = frameinfo->quantization;
503
504 return 0;
505}
506
507static int delta_try_fmt_stream(struct file *file, void *priv,
508 struct v4l2_format *f)
509{
510 struct delta_ctx *ctx = to_ctx(file->private_data);
511 struct delta_dev *delta = ctx->dev;
512 struct v4l2_pix_format *pix = &f->fmt.pix;
513 u32 streamformat = pix->pixelformat;
514 const struct delta_dec *dec;
515 u32 width, height;
516 u32 au_size;
517
518 dec = delta_find_decoder(ctx, streamformat, ctx->frameinfo.pixelformat);
519 if (!dec) {
520 dev_dbg(delta->dev,
521 "%s V4L2 TRY_FMT (OUTPUT): unsupported format %4.4s\n",
522 ctx->name, (char *)&pix->pixelformat);
523 return -EINVAL;
524 }
525
526 /* adjust width & height */
527 width = pix->width;
528 height = pix->height;
529 v4l_bound_align_image
530 (&pix->width,
531 DELTA_MIN_WIDTH,
532 dec->max_width ? dec->max_width : DELTA_MAX_WIDTH,
533 0,
534 &pix->height,
535 DELTA_MIN_HEIGHT,
536 dec->max_height ? dec->max_height : DELTA_MAX_HEIGHT,
537 0, 0);
538
539 if ((pix->width != width) || (pix->height != height))
540 dev_dbg(delta->dev,
541 "%s V4L2 TRY_FMT (OUTPUT): resolution updated %dx%d -> %dx%d to fit min/max/alignment\n",
542 ctx->name, width, height,
543 pix->width, pix->height);
544
545 au_size = estimated_au_size(pix->width, pix->height);
546 if (pix->sizeimage < au_size) {
547 dev_dbg(delta->dev,
548 "%s V4L2 TRY_FMT (OUTPUT): size updated %d -> %d to fit estimated size\n",
549 ctx->name, pix->sizeimage, au_size);
550 pix->sizeimage = au_size;
551 }
552
553 pix->bytesperline = 0;
554
555 if (pix->field == V4L2_FIELD_ANY)
556 pix->field = V4L2_FIELD_NONE;
557
558 return 0;
559}
560
561static int delta_try_fmt_frame(struct file *file, void *priv,
562 struct v4l2_format *f)
563{
564 struct delta_ctx *ctx = to_ctx(file->private_data);
565 struct delta_dev *delta = ctx->dev;
566 struct v4l2_pix_format *pix = &f->fmt.pix;
567 u32 pixelformat = pix->pixelformat;
568 const struct delta_dec *dec;
569 u32 width, height;
570
571 dec = delta_find_decoder(ctx, ctx->streaminfo.streamformat,
572 pixelformat);
573 if (!dec) {
574 dev_dbg(delta->dev,
575 "%s V4L2 TRY_FMT (CAPTURE): unsupported format %4.4s\n",
576 ctx->name, (char *)&pixelformat);
577 return -EINVAL;
578 }
579
580 /* adjust width & height */
581 width = pix->width;
582 height = pix->height;
583 v4l_bound_align_image(&pix->width,
584 DELTA_MIN_WIDTH, DELTA_MAX_WIDTH,
585 frame_alignment(pixelformat) - 1,
586 &pix->height,
587 DELTA_MIN_HEIGHT, DELTA_MAX_HEIGHT,
588 frame_alignment(pixelformat) - 1, 0);
589
590 if ((pix->width != width) || (pix->height != height))
591 dev_dbg(delta->dev,
592 "%s V4L2 TRY_FMT (CAPTURE): resolution updated %dx%d -> %dx%d to fit min/max/alignment\n",
593 ctx->name, width, height, pix->width, pix->height);
594
595 /* default decoder alignment constraint */
596 width = ALIGN(pix->width, DELTA_WIDTH_ALIGNMENT);
597 height = ALIGN(pix->height, DELTA_HEIGHT_ALIGNMENT);
598 if ((pix->width != width) || (pix->height != height))
599 dev_dbg(delta->dev,
600 "%s V4L2 TRY_FMT (CAPTURE): resolution updated %dx%d -> %dx%d to fit decoder alignment\n",
601 ctx->name, width, height, pix->width, pix->height);
602
603 if (!pix->colorspace) {
604 pix->colorspace = V4L2_COLORSPACE_REC709;
605 pix->xfer_func = V4L2_XFER_FUNC_DEFAULT;
606 pix->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
607 pix->quantization = V4L2_QUANTIZATION_DEFAULT;
608 }
609
610 pix->width = width;
611 pix->height = height;
612 pix->bytesperline = frame_stride(pix->width, pixelformat);
613 pix->sizeimage = frame_size(pix->width, pix->height, pixelformat);
614
615 if (pix->field == V4L2_FIELD_ANY)
616 pix->field = V4L2_FIELD_NONE;
617
618 return 0;
619}
620
621static int delta_s_fmt_stream(struct file *file, void *fh,
622 struct v4l2_format *f)
623{
624 struct delta_ctx *ctx = to_ctx(file->private_data);
625 struct delta_dev *delta = ctx->dev;
626 struct vb2_queue *vq;
627 struct v4l2_pix_format *pix = &f->fmt.pix;
628 int ret;
629
630 ret = delta_try_fmt_stream(file, fh, f);
631 if (ret) {
632 dev_dbg(delta->dev,
633 "%s V4L2 S_FMT (OUTPUT): unsupported format %4.4s\n",
634 ctx->name, (char *)&pix->pixelformat);
635 return ret;
636 }
637
638 vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
639 if (vb2_is_streaming(vq)) {
640 dev_dbg(delta->dev, "%s V4L2 S_FMT (OUTPUT): queue busy\n",
641 ctx->name);
642 return -EBUSY;
643 }
644
645 ctx->max_au_size = pix->sizeimage;
646 ctx->streaminfo.width = pix->width;
647 ctx->streaminfo.height = pix->height;
648 ctx->streaminfo.streamformat = pix->pixelformat;
649 ctx->streaminfo.colorspace = pix->colorspace;
650 ctx->streaminfo.xfer_func = pix->xfer_func;
651 ctx->streaminfo.ycbcr_enc = pix->ycbcr_enc;
652 ctx->streaminfo.quantization = pix->quantization;
653 ctx->flags |= DELTA_FLAG_STREAMINFO;
654
655 return 0;
656}
657
658static int delta_s_fmt_frame(struct file *file, void *fh, struct v4l2_format *f)
659{
660 struct delta_ctx *ctx = to_ctx(file->private_data);
661 struct delta_dev *delta = ctx->dev;
662 const struct delta_dec *dec = ctx->dec;
663 struct v4l2_pix_format *pix = &f->fmt.pix;
664 struct delta_frameinfo frameinfo;
665 unsigned char str[100] = "";
666 struct vb2_queue *vq;
667 int ret;
668
669 vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
670 if (vb2_is_streaming(vq)) {
671 dev_dbg(delta->dev, "%s V4L2 S_FMT (CAPTURE): queue busy\n",
672 ctx->name);
673 return -EBUSY;
674 }
675
676 if (ctx->state < DELTA_STATE_READY) {
677 /*
678 * decoder not yet opened and valid stream header not found,
679 * could not negotiate format with decoder, check at least
680 * pixel format & negotiate resolution boundaries
681 * and alignment...
682 */
683 ret = delta_try_fmt_frame(file, fh, f);
684 if (ret) {
685 dev_dbg(delta->dev,
686 "%s V4L2 S_FMT (CAPTURE): unsupported format %4.4s\n",
687 ctx->name, (char *)&pix->pixelformat);
688 return ret;
689 }
690
691 return 0;
692 }
693
694 /* set frame information to decoder */
695 memset(&frameinfo, 0, sizeof(frameinfo));
696 frameinfo.pixelformat = pix->pixelformat;
697 frameinfo.width = pix->width;
698 frameinfo.height = pix->height;
699 frameinfo.aligned_width = pix->width;
700 frameinfo.aligned_height = pix->height;
701 frameinfo.size = pix->sizeimage;
702 frameinfo.field = pix->field;
703 frameinfo.colorspace = pix->colorspace;
704 frameinfo.xfer_func = pix->xfer_func;
705 frameinfo.ycbcr_enc = pix->ycbcr_enc;
706 frameinfo.quantization = pix->quantization;
707 ret = call_dec_op(dec, set_frameinfo, ctx, &frameinfo);
708 if (ret)
709 return ret;
710
711 /* then get what decoder can really do */
712 ret = call_dec_op(dec, get_frameinfo, ctx, &frameinfo);
713 if (ret)
714 return ret;
715
716 ctx->flags |= DELTA_FLAG_FRAMEINFO;
717 ctx->frameinfo = frameinfo;
718 dev_dbg(delta->dev,
719 "%s V4L2 SET_FMT (CAPTURE): frameinfo updated to %s\n",
720 ctx->name,
721 delta_frameinfo_str(&frameinfo, str, sizeof(str)));
722
723 pix->pixelformat = frameinfo.pixelformat;
724 pix->width = frameinfo.aligned_width;
725 pix->height = frameinfo.aligned_height;
726 pix->bytesperline = frame_stride(pix->width, pix->pixelformat);
727 pix->sizeimage = frameinfo.size;
728 pix->field = frameinfo.field;
729 pix->colorspace = frameinfo.colorspace;
730 pix->xfer_func = frameinfo.xfer_func;
731 pix->ycbcr_enc = frameinfo.ycbcr_enc;
732 pix->quantization = frameinfo.quantization;
733
734 return 0;
735}
736
737static int delta_g_selection(struct file *file, void *fh,
738 struct v4l2_selection *s)
739{
740 struct delta_ctx *ctx = to_ctx(fh);
741 struct delta_frameinfo *frameinfo = &ctx->frameinfo;
742 struct v4l2_rect crop;
743
744 if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
745 return -EINVAL;
746
747 if ((ctx->flags & DELTA_FLAG_FRAMEINFO) &&
748 (frameinfo->flags & DELTA_FRAMEINFO_FLAG_CROP)) {
749 crop = frameinfo->crop;
750 } else {
751 /* default to video dimensions */
752 crop.left = 0;
753 crop.top = 0;
754 crop.width = frameinfo->width;
755 crop.height = frameinfo->height;
756 }
757
758 switch (s->target) {
759 case V4L2_SEL_TGT_COMPOSE:
760 case V4L2_SEL_TGT_COMPOSE_DEFAULT:
761 /* visible area inside video */
762 s->r = crop;
763 break;
764 case V4L2_SEL_TGT_COMPOSE_PADDED:
765 case V4L2_SEL_TGT_COMPOSE_BOUNDS:
766 /* up to aligned dimensions */
767 s->r.left = 0;
768 s->r.top = 0;
769 s->r.width = frameinfo->aligned_width;
770 s->r.height = frameinfo->aligned_height;
771 break;
772 default:
773 return -EINVAL;
774 }
775
776 return 0;
777}
778
779static void delta_complete_eos(struct delta_ctx *ctx,
780 struct delta_frame *frame)
781{
782 struct delta_dev *delta = ctx->dev;
783 const struct v4l2_event ev = {.type = V4L2_EVENT_EOS};
784
785 /*
786 * Send EOS to user:
787 * - by returning an empty frame flagged to V4L2_BUF_FLAG_LAST
788 * - and then send EOS event
789 */
790
791 /* empty frame */
792 frame->info.size = 0;
793
794 /* set the last buffer flag */
795 frame->flags |= V4L2_BUF_FLAG_LAST;
796
797 /* release frame to user */
798 delta_frame_done(ctx, frame, 0);
799
800 /* send EOS event */
801 v4l2_event_queue_fh(&ctx->fh, &ev);
802
803 dev_dbg(delta->dev, "%s EOS completed\n", ctx->name);
804}
805
806static int delta_try_decoder_cmd(struct file *file, void *fh,
807 struct v4l2_decoder_cmd *cmd)
808{
809 if (cmd->cmd != V4L2_DEC_CMD_STOP)
810 return -EINVAL;
811
812 if (cmd->flags & V4L2_DEC_CMD_STOP_TO_BLACK)
813 return -EINVAL;
814
815 if (!(cmd->flags & V4L2_DEC_CMD_STOP_IMMEDIATELY) &&
816 (cmd->stop.pts != 0))
817 return -EINVAL;
818
819 return 0;
820}
821
822static int delta_decoder_stop_cmd(struct delta_ctx *ctx, void *fh)
823{
824 const struct delta_dec *dec = ctx->dec;
825 struct delta_dev *delta = ctx->dev;
826 struct delta_frame *frame = NULL;
827 int ret = 0;
828
829 dev_dbg(delta->dev, "%s EOS received\n", ctx->name);
830
831 if (ctx->state != DELTA_STATE_READY)
832 return 0;
833
834 /* drain the decoder */
835 call_dec_op(dec, drain, ctx);
836
837 /* release to user drained frames */
838 while (1) {
839 frame = NULL;
840 ret = call_dec_op(dec, get_frame, ctx, &frame);
841 if (ret == -ENODATA) {
842 /* no more decoded frames */
843 break;
844 }
845 if (frame) {
846 dev_dbg(delta->dev, "%s drain frame[%d]\n",
847 ctx->name, frame->index);
848
849 /* pop timestamp and mark frame with it */
850 delta_pop_dts(ctx, &frame->dts);
851
852 /* release decoded frame to user */
853 delta_frame_done(ctx, frame, 0);
854 }
855 }
856
857 /* try to complete EOS */
858 ret = delta_get_free_frame(ctx, &frame);
859 if (ret)
860 goto delay_eos;
861
862 /* new frame available, EOS can now be completed */
863 delta_complete_eos(ctx, frame);
864
865 ctx->state = DELTA_STATE_EOS;
866
867 return 0;
868
869delay_eos:
870 /*
871 * EOS completion from driver is delayed because
872 * we don't have a free empty frame available.
873 * EOS completion is so delayed till next frame_queue() call
874 * to be sure to have a free empty frame available.
875 */
876 ctx->state = DELTA_STATE_WF_EOS;
877 dev_dbg(delta->dev, "%s EOS delayed\n", ctx->name);
878
879 return 0;
880}
881
882static int delta_decoder_cmd(struct file *file, void *fh,
883 struct v4l2_decoder_cmd *cmd)
884{
885 struct delta_ctx *ctx = to_ctx(fh);
886 int ret = 0;
887
888 ret = delta_try_decoder_cmd(file, fh, cmd);
889 if (ret)
890 return ret;
891
892 return delta_decoder_stop_cmd(ctx, fh);
893}
894
895static int delta_subscribe_event(struct v4l2_fh *fh,
896 const struct v4l2_event_subscription *sub)
897{
898 switch (sub->type) {
899 case V4L2_EVENT_EOS:
900 return v4l2_event_subscribe(fh, sub, 2, NULL);
901 default:
902 return -EINVAL;
903 }
904
905 return 0;
906}
907
908/* v4l2 ioctl ops */
909static const struct v4l2_ioctl_ops delta_ioctl_ops = {
910 .vidioc_querycap = delta_querycap,
911 .vidioc_enum_fmt_vid_cap = delta_enum_fmt_frame,
912 .vidioc_g_fmt_vid_cap = delta_g_fmt_frame,
913 .vidioc_try_fmt_vid_cap = delta_try_fmt_frame,
914 .vidioc_s_fmt_vid_cap = delta_s_fmt_frame,
915 .vidioc_enum_fmt_vid_out = delta_enum_fmt_stream,
916 .vidioc_g_fmt_vid_out = delta_g_fmt_stream,
917 .vidioc_try_fmt_vid_out = delta_try_fmt_stream,
918 .vidioc_s_fmt_vid_out = delta_s_fmt_stream,
919 .vidioc_reqbufs = v4l2_m2m_ioctl_reqbufs,
920 .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
921 .vidioc_querybuf = v4l2_m2m_ioctl_querybuf,
922 .vidioc_expbuf = v4l2_m2m_ioctl_expbuf,
923 .vidioc_qbuf = v4l2_m2m_ioctl_qbuf,
924 .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf,
925 .vidioc_streamon = v4l2_m2m_ioctl_streamon,
926 .vidioc_streamoff = v4l2_m2m_ioctl_streamoff,
927 .vidioc_g_selection = delta_g_selection,
928 .vidioc_try_decoder_cmd = delta_try_decoder_cmd,
929 .vidioc_decoder_cmd = delta_decoder_cmd,
930 .vidioc_subscribe_event = delta_subscribe_event,
931 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
932};
933
934/*
935 * mem-to-mem operations
936 */
937
938static void delta_run_work(struct work_struct *work)
939{
940 struct delta_ctx *ctx = container_of(work, struct delta_ctx, run_work);
941 struct delta_dev *delta = ctx->dev;
942 const struct delta_dec *dec = ctx->dec;
943 struct delta_au *au;
944 struct delta_frame *frame = NULL;
945 int ret = 0;
946 bool discard = false;
947 struct vb2_v4l2_buffer *vbuf;
948
949 if (!dec) {
950 dev_err(delta->dev, "%s no decoder opened yet\n", ctx->name);
951 return;
952 }
953
954 /* protect instance against reentrancy */
955 mutex_lock(&ctx->lock);
956
957 vbuf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
958 if (!vbuf) {
959 dev_err(delta->dev, "%s no buffer to decode\n", ctx->name);
960 mutex_unlock(&ctx->lock);
961 return;
962 }
963 au = to_au(vbuf);
964 au->size = vb2_get_plane_payload(&vbuf->vb2_buf, 0);
965 au->dts = vbuf->vb2_buf.timestamp;
966
967 /* dump access unit */
968 dump_au(ctx, au);
969
970 /* enable the hardware */
971 if (!dec->pm) {
972 ret = delta_get_sync(ctx);
973 if (ret)
974 goto err;
975 }
976
977 /* decode this access unit */
978 ret = call_dec_op(dec, decode, ctx, au);
979
980 /*
981 * if the (-ENODATA) value is returned, it refers to the interlaced
982 * stream case for which 2 access units are needed to get 1 frame.
983 * So, this returned value doesn't mean that the decoding fails, but
984 * indicates that the timestamp information of the access unit shall
985 * not be taken into account, and that the V4L2 buffer associated with
986 * the access unit shall be flagged with V4L2_BUF_FLAG_ERROR to inform
987 * the user of this situation
988 */
989 if (ret == -ENODATA) {
990 discard = true;
991 } else if (ret) {
992 dev_err(delta->dev, "%s decoding failed (%d)\n",
993 ctx->name, ret);
994
995 /* disable the hardware */
996 if (!dec->pm)
997 delta_put_autosuspend(ctx);
998
999 goto err;
1000 }
1001
1002 /* disable the hardware */
1003 if (!dec->pm)
1004 delta_put_autosuspend(ctx);
1005
1006 /* push au timestamp in FIFO */
1007 if (!discard)
1008 delta_push_dts(ctx, au->dts);
1009
1010 /* get available decoded frames */
1011 while (1) {
1012 ret = call_dec_op(dec, get_frame, ctx, &frame);
1013 if (ret == -ENODATA) {
1014 /* no more decoded frames */
1015 goto out;
1016 }
1017 if (ret) {
1018 dev_err(delta->dev, "%s cannot get decoded frame (%d)\n",
1019 ctx->name, ret);
1020 goto out;
1021 }
1022 if (!frame) {
1023 dev_err(delta->dev,
1024 "%s NULL decoded frame\n",
1025 ctx->name);
1026 ret = -EIO;
1027 goto out;
1028 }
1029
1030 /* pop timestamp and mark frame with it */
1031 delta_pop_dts(ctx, &frame->dts);
1032
1033 /* release decoded frame to user */
1034 delta_frame_done(ctx, frame, 0);
1035 }
1036
1037out:
1038 requeue_free_frames(ctx);
1039 delta_au_done(ctx, au, (discard ? -ENODATA : 0));
1040 mutex_unlock(&ctx->lock);
1041 v4l2_m2m_job_finish(delta->m2m_dev, ctx->fh.m2m_ctx);
1042 return;
1043
1044err:
1045 requeue_free_frames(ctx);
1046 delta_au_done(ctx, au, ret);
1047 mutex_unlock(&ctx->lock);
1048 v4l2_m2m_job_finish(delta->m2m_dev, ctx->fh.m2m_ctx);
1049}
1050
1051static void delta_device_run(void *priv)
1052{
1053 struct delta_ctx *ctx = priv;
1054 struct delta_dev *delta = ctx->dev;
1055
1056 queue_work(delta->work_queue, &ctx->run_work);
1057}
1058
1059static void delta_job_abort(void *priv)
1060{
1061 struct delta_ctx *ctx = priv;
1062 struct delta_dev *delta = ctx->dev;
1063
1064 dev_dbg(delta->dev, "%s aborting job\n", ctx->name);
1065
1066 ctx->aborting = true;
1067}
1068
1069static int delta_job_ready(void *priv)
1070{
1071 struct delta_ctx *ctx = priv;
1072 struct delta_dev *delta = ctx->dev;
1073 int src_bufs = v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx);
1074
1075 if (!src_bufs) {
1076 dev_dbg(delta->dev, "%s not ready: not enough video buffers.\n",
1077 ctx->name);
1078 return 0;
1079 }
1080
1081 if (!v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx)) {
1082 dev_dbg(delta->dev, "%s not ready: not enough video capture buffers.\n",
1083 ctx->name);
1084 return 0;
1085 }
1086
1087 if (ctx->aborting) {
1088 dev_dbg(delta->dev, "%s job not ready: aborting\n", ctx->name);
1089 return 0;
1090 }
1091
1092 dev_dbg(delta->dev, "%s job ready\n", ctx->name);
1093
1094 return 1;
1095}
1096
1097/* mem-to-mem ops */
1098static struct v4l2_m2m_ops delta_m2m_ops = {
1099 .device_run = delta_device_run,
1100 .job_ready = delta_job_ready,
1101 .job_abort = delta_job_abort,
1102 .lock = delta_lock,
1103 .unlock = delta_unlock,
1104};
1105
1106/*
1107 * VB2 queue operations
1108 */
1109
1110static int delta_vb2_au_queue_setup(struct vb2_queue *vq,
1111 unsigned int *num_buffers,
1112 unsigned int *num_planes,
1113 unsigned int sizes[],
1114 struct device *alloc_devs[])
1115{
1116 struct delta_ctx *ctx = vb2_get_drv_priv(vq);
1117 unsigned int size = ctx->max_au_size;
1118
1119 if (*num_planes)
1120 return sizes[0] < size ? -EINVAL : 0;
1121
1122 *num_planes = 1;
1123 if (*num_buffers < 1)
1124 *num_buffers = 1;
1125 if (*num_buffers > DELTA_MAX_AUS)
1126 *num_buffers = DELTA_MAX_AUS;
1127
1128 sizes[0] = size;
1129
1130 return 0;
1131}
1132
1133static int delta_vb2_au_prepare(struct vb2_buffer *vb)
1134{
1135 struct vb2_queue *q = vb->vb2_queue;
1136 struct delta_ctx *ctx = vb2_get_drv_priv(q);
1137 struct delta_dev *delta = ctx->dev;
1138 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
1139 struct delta_au *au = to_au(vbuf);
1140
1141 if (!au->prepared) {
1142 /* get memory addresses */
1143 au->vaddr = vb2_plane_vaddr(&au->vbuf.vb2_buf, 0);
1144 au->paddr = vb2_dma_contig_plane_dma_addr
1145 (&au->vbuf.vb2_buf, 0);
1146 au->prepared = true;
1147 dev_dbg(delta->dev, "%s au[%d] prepared; virt=0x%p, phy=0x%pad\n",
1148 ctx->name, vb->index, au->vaddr, &au->paddr);
1149 }
1150
1151 if (vbuf->field == V4L2_FIELD_ANY)
1152 vbuf->field = V4L2_FIELD_NONE;
1153
1154 return 0;
1155}
1156
1157static int delta_setup_frame(struct delta_ctx *ctx,
1158 struct delta_frame *frame)
1159{
1160 struct delta_dev *delta = ctx->dev;
1161 const struct delta_dec *dec = ctx->dec;
1162
1163 if (frame->index >= DELTA_MAX_FRAMES) {
1164 dev_err(delta->dev,
1165 "%s frame index=%d exceeds output frame count (%d)\n",
1166 ctx->name, frame->index, DELTA_MAX_FRAMES);
1167 return -EINVAL;
1168 }
1169
1170 if (ctx->nb_of_frames >= DELTA_MAX_FRAMES) {
1171 dev_err(delta->dev,
1172 "%s number of frames exceeds output frame count (%d > %d)\n",
1173 ctx->name, ctx->nb_of_frames, DELTA_MAX_FRAMES);
1174 return -EINVAL;
1175 }
1176
1177 if (frame->index != ctx->nb_of_frames) {
1178 dev_warn(delta->dev,
1179 "%s frame index discontinuity detected, expected %d, got %d\n",
1180 ctx->name, ctx->nb_of_frames, frame->index);
1181 }
1182
1183 frame->state = DELTA_FRAME_FREE;
1184 ctx->frames[ctx->nb_of_frames] = frame;
1185 ctx->nb_of_frames++;
1186
1187 /* setup frame on decoder side */
1188 return call_dec_op(dec, setup_frame, ctx, frame);
1189}
1190
1191/*
1192 * default implementation of get_frameinfo decoder ops
1193 * matching frame information from stream information
1194 * & with default pixel format & default alignment.
1195 */
1196int delta_get_frameinfo_default(struct delta_ctx *ctx,
1197 struct delta_frameinfo *frameinfo)
1198{
1199 struct delta_streaminfo *streaminfo = &ctx->streaminfo;
1200
1201 memset(frameinfo, 0, sizeof(*frameinfo));
1202 frameinfo->pixelformat = V4L2_PIX_FMT_NV12;
1203 frameinfo->width = streaminfo->width;
1204 frameinfo->height = streaminfo->height;
1205 frameinfo->aligned_width = ALIGN(streaminfo->width,
1206 DELTA_WIDTH_ALIGNMENT);
1207 frameinfo->aligned_height = ALIGN(streaminfo->height,
1208 DELTA_HEIGHT_ALIGNMENT);
1209 frameinfo->size = frame_size(frameinfo->aligned_width,
1210 frameinfo->aligned_height,
1211 frameinfo->pixelformat);
1212 if (streaminfo->flags & DELTA_STREAMINFO_FLAG_CROP) {
1213 frameinfo->flags |= DELTA_FRAMEINFO_FLAG_CROP;
1214 frameinfo->crop = streaminfo->crop;
1215 }
1216 if (streaminfo->flags & DELTA_STREAMINFO_FLAG_PIXELASPECT) {
1217 frameinfo->flags |= DELTA_FRAMEINFO_FLAG_PIXELASPECT;
1218 frameinfo->pixelaspect = streaminfo->pixelaspect;
1219 }
1220 frameinfo->field = streaminfo->field;
1221
1222 return 0;
1223}
1224
1225/*
1226 * default implementation of recycle decoder ops
1227 * consisting to relax the "decoded" frame state
1228 */
1229int delta_recycle_default(struct delta_ctx *pctx,
1230 struct delta_frame *frame)
1231{
1232 frame->state &= ~DELTA_FRAME_DEC;
1233
1234 return 0;
1235}
1236
1237static void dump_frames_status(struct delta_ctx *ctx)
1238{
1239 struct delta_dev *delta = ctx->dev;
1240 unsigned int i;
1241 struct delta_frame *frame;
1242 unsigned char str[100] = "";
1243
1244 dev_info(delta->dev,
1245 "%s dumping frames status...\n", ctx->name);
1246
1247 for (i = 0; i < ctx->nb_of_frames; i++) {
1248 frame = ctx->frames[i];
1249 dev_info(delta->dev,
1250 "%s frame[%d] %s\n",
1251 ctx->name, frame->index,
1252 frame_state_str(frame->state,
1253 str, sizeof(str)));
1254 }
1255}
1256
1257int delta_get_free_frame(struct delta_ctx *ctx,
1258 struct delta_frame **pframe)
1259{
1260 struct delta_dev *delta = ctx->dev;
1261 struct vb2_v4l2_buffer *vbuf;
1262 struct delta_frame *frame;
1263
1264 *pframe = NULL;
1265
1266 vbuf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
1267 if (!vbuf) {
1268 dev_err(delta->dev, "%s no frame available",
1269 ctx->name);
1270 return -EIO;
1271 }
1272
1273 frame = to_frame(vbuf);
1274 frame->state &= ~DELTA_FRAME_M2M;
1275 if (frame->state != DELTA_FRAME_FREE) {
1276 dev_err(delta->dev,
1277 "%s frame[%d] is not free\n",
1278 ctx->name, frame->index);
1279 dump_frames_status(ctx);
1280 return -ENODATA;
1281 }
1282
1283 dev_dbg(delta->dev,
1284 "%s get free frame[%d]\n", ctx->name, frame->index);
1285
1286 *pframe = frame;
1287 return 0;
1288}
1289
1290int delta_get_sync(struct delta_ctx *ctx)
1291{
1292 struct delta_dev *delta = ctx->dev;
1293 int ret = 0;
1294
1295 /* enable the hardware */
1296 ret = pm_runtime_get_sync(delta->dev);
1297 if (ret < 0) {
1298 dev_err(delta->dev, "%s pm_runtime_get_sync failed (%d)\n",
1299 __func__, ret);
1300 return ret;
1301 }
1302
1303 return 0;
1304}
1305
1306void delta_put_autosuspend(struct delta_ctx *ctx)
1307{
1308 struct delta_dev *delta = ctx->dev;
1309
1310 pm_runtime_put_autosuspend(delta->dev);
1311}
1312
1313static void delta_vb2_au_queue(struct vb2_buffer *vb)
1314{
1315 struct vb2_queue *q = vb->vb2_queue;
1316 struct delta_ctx *ctx = vb2_get_drv_priv(q);
1317 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
1318
1319 v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf);
1320}
1321
1322static int delta_vb2_au_start_streaming(struct vb2_queue *q,
1323 unsigned int count)
1324{
1325 struct delta_ctx *ctx = vb2_get_drv_priv(q);
1326 struct delta_dev *delta = ctx->dev;
1327 const struct delta_dec *dec = ctx->dec;
1328 struct delta_au *au;
1329 int ret = 0;
1330 struct vb2_v4l2_buffer *vbuf = NULL;
1331 struct delta_streaminfo *streaminfo = &ctx->streaminfo;
1332 struct delta_frameinfo *frameinfo = &ctx->frameinfo;
1333 unsigned char str1[100] = "";
1334 unsigned char str2[100] = "";
1335
1336 if ((ctx->state != DELTA_STATE_WF_FORMAT) &&
1337 (ctx->state != DELTA_STATE_WF_STREAMINFO))
1338 return 0;
1339
1340 if (ctx->state == DELTA_STATE_WF_FORMAT) {
1341 /* open decoder if not yet done */
1342 ret = delta_open_decoder(ctx,
1343 ctx->streaminfo.streamformat,
1344 ctx->frameinfo.pixelformat, &dec);
1345 if (ret)
1346 goto err;
1347 ctx->dec = dec;
1348 ctx->state = DELTA_STATE_WF_STREAMINFO;
1349 }
1350
1351 /*
1352 * first buffer should contain stream header,
1353 * decode it to get the infos related to stream
1354 * such as width, height, dpb, ...
1355 */
1356 vbuf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
1357 if (!vbuf) {
1358 dev_err(delta->dev, "%s failed to start streaming, no stream header buffer enqueued\n",
1359 ctx->name);
1360 ret = -EINVAL;
1361 goto err;
1362 }
1363 au = to_au(vbuf);
1364 au->size = vb2_get_plane_payload(&vbuf->vb2_buf, 0);
1365 au->dts = vbuf->vb2_buf.timestamp;
1366
1367 delta_push_dts(ctx, au->dts);
1368
1369 /* dump access unit */
1370 dump_au(ctx, au);
1371
1372 /* decode this access unit */
1373 ret = call_dec_op(dec, decode, ctx, au);
1374 if (ret) {
1375 dev_err(delta->dev, "%s failed to start streaming, header decoding failed (%d)\n",
1376 ctx->name, ret);
1377 goto err;
1378 }
1379
1380 ret = call_dec_op(dec, get_streaminfo, ctx, streaminfo);
1381 if (ret) {
1382 dev_dbg_ratelimited(delta->dev,
1383 "%s failed to start streaming, valid stream header not yet decoded\n",
1384 ctx->name);
1385 goto err;
1386 }
1387 ctx->flags |= DELTA_FLAG_STREAMINFO;
1388
1389 ret = call_dec_op(dec, get_frameinfo, ctx, frameinfo);
1390 if (ret)
1391 goto err;
1392 ctx->flags |= DELTA_FLAG_FRAMEINFO;
1393
1394 ctx->state = DELTA_STATE_READY;
1395
1396 dev_dbg(delta->dev, "%s %s => %s\n", ctx->name,
1397 delta_streaminfo_str(streaminfo, str1, sizeof(str1)),
1398 delta_frameinfo_str(frameinfo, str2, sizeof(str2)));
1399
1400 delta_au_done(ctx, au, ret);
1401 return 0;
1402
1403err:
1404 /*
1405 * return all buffers to vb2 in QUEUED state.
1406 * This will give ownership back to userspace
1407 */
1408 if (vbuf)
1409 v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_QUEUED);
1410
1411 while ((vbuf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx)))
1412 v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_QUEUED);
1413 return ret;
1414}
1415
1416static void delta_vb2_au_stop_streaming(struct vb2_queue *q)
1417{
1418 struct delta_ctx *ctx = vb2_get_drv_priv(q);
1419 struct vb2_v4l2_buffer *vbuf;
1420
1421 delta_flush_dts(ctx);
1422
1423 /* return all buffers to vb2 in ERROR state */
1424 while ((vbuf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx)))
1425 v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
1426
1427 ctx->au_num = 0;
1428
1429 ctx->aborting = false;
1430}
1431
1432static int delta_vb2_frame_queue_setup(struct vb2_queue *vq,
1433 unsigned int *num_buffers,
1434 unsigned int *num_planes,
1435 unsigned int sizes[],
1436 struct device *alloc_devs[])
1437{
1438 struct delta_ctx *ctx = vb2_get_drv_priv(vq);
1439 struct delta_dev *delta = ctx->dev;
1440 struct delta_streaminfo *streaminfo = &ctx->streaminfo;
1441 struct delta_frameinfo *frameinfo = &ctx->frameinfo;
1442 unsigned int size = frameinfo->size;
1443
1444 /*
1445 * the number of output buffers needed for decoding =
1446 * user need (*num_buffers given, usually for display pipeline) +
1447 * stream need (streaminfo->dpb) +
1448 * decoding peak smoothing (depends on DELTA IP perf)
1449 */
1450 if (*num_buffers < DELTA_MIN_FRAME_USER) {
1451 dev_dbg(delta->dev,
1452 "%s num_buffers too low (%d), increasing to %d\n",
1453 ctx->name, *num_buffers, DELTA_MIN_FRAME_USER);
1454 *num_buffers = DELTA_MIN_FRAME_USER;
1455 }
1456
1457 *num_buffers += streaminfo->dpb + DELTA_PEAK_FRAME_SMOOTHING;
1458
1459 if (*num_buffers > DELTA_MAX_FRAMES) {
1460 dev_dbg(delta->dev,
1461 "%s output frame count too high (%d), cut to %d\n",
1462 ctx->name, *num_buffers, DELTA_MAX_FRAMES);
1463 *num_buffers = DELTA_MAX_FRAMES;
1464 }
1465
1466 if (*num_planes)
1467 return sizes[0] < size ? -EINVAL : 0;
1468
1469 /* single plane for Y and CbCr */
1470 *num_planes = 1;
1471
1472 sizes[0] = size;
1473
1474 ctx->nb_of_frames = 0;
1475
1476 return 0;
1477}
1478
1479static int delta_vb2_frame_prepare(struct vb2_buffer *vb)
1480{
1481 struct vb2_queue *q = vb->vb2_queue;
1482 struct delta_ctx *ctx = vb2_get_drv_priv(q);
1483 struct delta_dev *delta = ctx->dev;
1484 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
1485 struct delta_frame *frame = to_frame(vbuf);
1486 int ret = 0;
1487
1488 if (!frame->prepared) {
1489 frame->index = vbuf->vb2_buf.index;
1490 frame->vaddr = vb2_plane_vaddr(&vbuf->vb2_buf, 0);
1491 frame->paddr = vb2_dma_contig_plane_dma_addr(&vbuf->vb2_buf, 0);
1492 frame->info = ctx->frameinfo;
1493
1494 ret = delta_setup_frame(ctx, frame);
1495 if (ret) {
1496 dev_err(delta->dev,
1497 "%s setup_frame() failed (%d)\n",
1498 ctx->name, ret);
1499 return ret;
1500 }
1501 frame->prepared = true;
1502 dev_dbg(delta->dev,
1503 "%s frame[%d] prepared; virt=0x%p, phy=0x%pad\n",
1504 ctx->name, vb->index, frame->vaddr,
1505 &frame->paddr);
1506 }
1507
1508 frame->flags = vbuf->flags;
1509
1510 return 0;
1511}
1512
1513static void delta_vb2_frame_finish(struct vb2_buffer *vb)
1514{
1515 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
1516 struct delta_frame *frame = to_frame(vbuf);
1517
1518 /* update V4L2 fields for user */
1519 vb2_set_plane_payload(&vbuf->vb2_buf, 0, frame->info.size);
1520 vb->timestamp = frame->dts;
1521 vbuf->field = frame->field;
1522 vbuf->flags = frame->flags;
1523}
1524
1525static void delta_vb2_frame_queue(struct vb2_buffer *vb)
1526{
1527 struct vb2_queue *q = vb->vb2_queue;
1528 struct delta_ctx *ctx = vb2_get_drv_priv(q);
1529 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
1530 struct delta_frame *frame = to_frame(vbuf);
1531
1532 if (ctx->state == DELTA_STATE_WF_EOS) {
1533 /* new frame available, EOS can now be completed */
1534 delta_complete_eos(ctx, frame);
1535
1536 ctx->state = DELTA_STATE_EOS;
1537
1538 /* return, no need to recycle this buffer to decoder */
1539 return;
1540 }
1541
1542 /* recycle this frame */
1543 delta_recycle(ctx, frame);
1544}
1545
1546static void delta_vb2_frame_stop_streaming(struct vb2_queue *q)
1547{
1548 struct delta_ctx *ctx = vb2_get_drv_priv(q);
1549 struct vb2_v4l2_buffer *vbuf;
1550 struct delta_frame *frame;
1551 const struct delta_dec *dec = ctx->dec;
1552 unsigned int i;
1553
1554 delta_flush_dts(ctx);
1555
1556 call_dec_op(dec, flush, ctx);
1557
1558 /*
1559 * return all buffers to vb2 in ERROR state
1560 * & reset each frame state to OUT
1561 */
1562 for (i = 0; i < ctx->nb_of_frames; i++) {
1563 frame = ctx->frames[i];
1564 if (!(frame->state & DELTA_FRAME_OUT)) {
1565 vbuf = &frame->vbuf;
1566 v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
1567 }
1568 frame->state = DELTA_FRAME_OUT;
1569 }
1570
1571 ctx->frame_num = 0;
1572
1573 ctx->aborting = false;
1574}
1575
1576/* VB2 queue ops */
1577static struct vb2_ops delta_vb2_au_ops = {
1578 .queue_setup = delta_vb2_au_queue_setup,
1579 .buf_prepare = delta_vb2_au_prepare,
1580 .buf_queue = delta_vb2_au_queue,
1581 .wait_prepare = vb2_ops_wait_prepare,
1582 .wait_finish = vb2_ops_wait_finish,
1583 .start_streaming = delta_vb2_au_start_streaming,
1584 .stop_streaming = delta_vb2_au_stop_streaming,
1585};
1586
1587static struct vb2_ops delta_vb2_frame_ops = {
1588 .queue_setup = delta_vb2_frame_queue_setup,
1589 .buf_prepare = delta_vb2_frame_prepare,
1590 .buf_finish = delta_vb2_frame_finish,
1591 .buf_queue = delta_vb2_frame_queue,
1592 .wait_prepare = vb2_ops_wait_prepare,
1593 .wait_finish = vb2_ops_wait_finish,
1594 .stop_streaming = delta_vb2_frame_stop_streaming,
1595};
1596
1597/*
1598 * V4L2 file operations
1599 */
1600
1601static int queue_init(void *priv,
1602 struct vb2_queue *src_vq, struct vb2_queue *dst_vq)
1603{
1604 struct vb2_queue *q;
1605 struct delta_ctx *ctx = priv;
1606 struct delta_dev *delta = ctx->dev;
1607 int ret;
1608
1609 /* setup vb2 queue for stream input */
1610 q = src_vq;
1611 q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
1612 q->io_modes = VB2_MMAP | VB2_DMABUF;
1613 q->drv_priv = ctx;
1614 /* overload vb2 buf with private au struct */
1615 q->buf_struct_size = sizeof(struct delta_au);
1616 q->ops = &delta_vb2_au_ops;
1617 q->mem_ops = &vb2_dma_contig_memops;
1618 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
1619 q->lock = &delta->lock;
1620 q->dev = delta->dev;
1621
1622 ret = vb2_queue_init(q);
1623 if (ret)
1624 return ret;
1625
1626 /* setup vb2 queue for frame output */
1627 q = dst_vq;
1628 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1629 q->io_modes = VB2_MMAP | VB2_DMABUF;
1630 q->drv_priv = ctx;
1631 /* overload vb2 buf with private frame struct */
1632 q->buf_struct_size = sizeof(struct delta_frame)
1633 + DELTA_MAX_FRAME_PRIV_SIZE;
1634 q->ops = &delta_vb2_frame_ops;
1635 q->mem_ops = &vb2_dma_contig_memops;
1636 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
1637 q->lock = &delta->lock;
1638 q->dev = delta->dev;
1639
1640 return vb2_queue_init(q);
1641}
1642
1643static int delta_open(struct file *file)
1644{
1645 struct delta_dev *delta = video_drvdata(file);
1646 struct delta_ctx *ctx = NULL;
1647 int ret = 0;
1648
1649 mutex_lock(&delta->lock);
1650
1651 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
1652 if (!ctx) {
1653 ret = -ENOMEM;
1654 goto err;
1655 }
1656 ctx->dev = delta;
1657
1658 v4l2_fh_init(&ctx->fh, video_devdata(file));
1659 file->private_data = &ctx->fh;
1660 v4l2_fh_add(&ctx->fh);
1661
1662 INIT_WORK(&ctx->run_work, delta_run_work);
1663 mutex_init(&ctx->lock);
1664
1665 ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(delta->m2m_dev, ctx,
1666 queue_init);
1667 if (IS_ERR(ctx->fh.m2m_ctx)) {
1668 ret = PTR_ERR(ctx->fh.m2m_ctx);
1669 dev_err(delta->dev, "%s failed to initialize m2m context (%d)\n",
1670 DELTA_PREFIX, ret);
1671 goto err_fh_del;
1672 }
1673
1674 /*
1675 * wait stream format to determine which
1676 * decoder to open
1677 */
1678 ctx->state = DELTA_STATE_WF_FORMAT;
1679
1680 INIT_LIST_HEAD(&ctx->dts);
1681
1682 /* set the instance name */
1683 delta->instance_id++;
1684 snprintf(ctx->name, sizeof(ctx->name), "[%3d:----]",
1685 delta->instance_id);
1686
1687 /* default parameters for frame and stream */
1688 set_default_params(ctx);
1689
1690 /* enable ST231 clocks */
1691 if (delta->clk_st231)
1692 if (clk_prepare_enable(delta->clk_st231))
1693 dev_warn(delta->dev, "failed to enable st231 clk\n");
1694
1695 /* enable FLASH_PROMIP clock */
1696 if (delta->clk_flash_promip)
1697 if (clk_prepare_enable(delta->clk_flash_promip))
1698 dev_warn(delta->dev, "failed to enable delta promip clk\n");
1699
1700 mutex_unlock(&delta->lock);
1701
1702 dev_dbg(delta->dev, "%s decoder instance created\n", ctx->name);
1703
1704 return 0;
1705
1706err_fh_del:
1707 v4l2_fh_del(&ctx->fh);
1708 v4l2_fh_exit(&ctx->fh);
1709 kfree(ctx);
1710err:
1711 mutex_unlock(&delta->lock);
1712
1713 return ret;
1714}
1715
1716static int delta_release(struct file *file)
1717{
1718 struct delta_ctx *ctx = to_ctx(file->private_data);
1719 struct delta_dev *delta = ctx->dev;
1720 const struct delta_dec *dec = ctx->dec;
1721
1722 mutex_lock(&delta->lock);
1723
1724 /* close decoder */
1725 call_dec_op(dec, close, ctx);
1726
1727 /*
1728 * trace a summary of instance
1729 * before closing (debug purpose)
1730 */
1731 delta_trace_summary(ctx);
1732
1733 v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
1734
1735 v4l2_fh_del(&ctx->fh);
1736 v4l2_fh_exit(&ctx->fh);
1737
1738 /* disable ST231 clocks */
1739 if (delta->clk_st231)
1740 clk_disable_unprepare(delta->clk_st231);
1741
1742 /* disable FLASH_PROMIP clock */
1743 if (delta->clk_flash_promip)
1744 clk_disable_unprepare(delta->clk_flash_promip);
1745
1746 dev_dbg(delta->dev, "%s decoder instance released\n", ctx->name);
1747
1748 kfree(ctx);
1749
1750 mutex_unlock(&delta->lock);
1751 return 0;
1752}
1753
1754/* V4L2 file ops */
1755static const struct v4l2_file_operations delta_fops = {
1756 .owner = THIS_MODULE,
1757 .open = delta_open,
1758 .release = delta_release,
1759 .unlocked_ioctl = video_ioctl2,
1760 .mmap = v4l2_m2m_fop_mmap,
1761 .poll = v4l2_m2m_fop_poll,
1762};
1763
1764/*
1765 * Platform device operations
1766 */
1767
1768static int delta_register_device(struct delta_dev *delta)
1769{
1770 int ret;
1771 struct video_device *vdev;
1772
1773 if (!delta)
1774 return -ENODEV;
1775
1776 delta->m2m_dev = v4l2_m2m_init(&delta_m2m_ops);
1777 if (IS_ERR(delta->m2m_dev)) {
1778 dev_err(delta->dev, "%s failed to initialize v4l2-m2m device\n",
1779 DELTA_PREFIX);
1780 ret = PTR_ERR(delta->m2m_dev);
1781 goto err;
1782 }
1783
1784 vdev = video_device_alloc();
1785 if (!vdev) {
1786 dev_err(delta->dev, "%s failed to allocate video device\n",
1787 DELTA_PREFIX);
1788 ret = -ENOMEM;
1789 goto err_m2m_release;
1790 }
1791
1792 vdev->fops = &delta_fops;
1793 vdev->ioctl_ops = &delta_ioctl_ops;
1794 vdev->release = video_device_release;
1795 vdev->lock = &delta->lock;
1796 vdev->vfl_dir = VFL_DIR_M2M;
1797 vdev->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M;
1798 vdev->v4l2_dev = &delta->v4l2_dev;
1799 snprintf(vdev->name, sizeof(vdev->name), "%s-%s",
1800 DELTA_NAME, DELTA_FW_VERSION);
1801
1802 ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
1803 if (ret) {
1804 dev_err(delta->dev, "%s failed to register video device\n",
1805 DELTA_PREFIX);
1806 goto err_vdev_release;
1807 }
1808
1809 delta->vdev = vdev;
1810 video_set_drvdata(vdev, delta);
1811 return 0;
1812
1813err_vdev_release:
1814 video_device_release(vdev);
1815err_m2m_release:
1816 v4l2_m2m_release(delta->m2m_dev);
1817err:
1818 return ret;
1819}
1820
1821static void delta_unregister_device(struct delta_dev *delta)
1822{
1823 if (!delta)
1824 return;
1825
1826 if (delta->m2m_dev)
1827 v4l2_m2m_release(delta->m2m_dev);
1828
1829 video_unregister_device(delta->vdev);
1830}
1831
1832static int delta_probe(struct platform_device *pdev)
1833{
1834 struct delta_dev *delta;
1835 struct device *dev = &pdev->dev;
1836 int ret;
1837
1838 delta = devm_kzalloc(dev, sizeof(*delta), GFP_KERNEL);
1839 if (!delta) {
1840 ret = -ENOMEM;
1841 goto err;
1842 }
1843
1844 delta->dev = dev;
1845 delta->pdev = pdev;
1846 platform_set_drvdata(pdev, delta);
1847
1848 mutex_init(&delta->lock);
1849
1850 /* get clock resources */
1851 delta->clk_delta = devm_clk_get(dev, "delta");
1852 if (IS_ERR(delta->clk_delta)) {
1853 dev_dbg(dev, "%s can't get delta clock\n", DELTA_PREFIX);
1854 delta->clk_delta = NULL;
1855 }
1856
1857 delta->clk_st231 = devm_clk_get(dev, "delta-st231");
1858 if (IS_ERR(delta->clk_st231)) {
1859 dev_dbg(dev, "%s can't get delta-st231 clock\n", DELTA_PREFIX);
1860 delta->clk_st231 = NULL;
1861 }
1862
1863 delta->clk_flash_promip = devm_clk_get(dev, "delta-flash-promip");
1864 if (IS_ERR(delta->clk_flash_promip)) {
1865 dev_dbg(dev, "%s can't get delta-flash-promip clock\n",
1866 DELTA_PREFIX);
1867 delta->clk_flash_promip = NULL;
1868 }
1869
1870 /* init pm_runtime used for power management */
1871 pm_runtime_set_autosuspend_delay(dev, DELTA_HW_AUTOSUSPEND_DELAY_MS);
1872 pm_runtime_use_autosuspend(dev);
1873 pm_runtime_set_suspended(dev);
1874 pm_runtime_enable(dev);
1875
1876 /* init firmware ipc channel */
1877 ret = delta_ipc_init(delta);
1878 if (ret) {
1879 dev_err(delta->dev, "%s failed to initialize firmware ipc channel\n",
1880 DELTA_PREFIX);
1881 goto err;
1882 }
1883
1884 /* register all available decoders */
1885 register_decoders(delta);
1886
1887 /* register all supported formats */
1888 register_formats(delta);
1889
1890 /* register on V4L2 */
1891 ret = v4l2_device_register(dev, &delta->v4l2_dev);
1892 if (ret) {
1893 dev_err(delta->dev, "%s failed to register V4L2 device\n",
1894 DELTA_PREFIX);
1895 goto err;
1896 }
1897
1898 delta->work_queue = create_workqueue(DELTA_NAME);
1899 if (!delta->work_queue) {
1900 dev_err(delta->dev, "%s failed to allocate work queue\n",
1901 DELTA_PREFIX);
1902 ret = -ENOMEM;
1903 goto err_v4l2;
1904 }
1905
1906 /* register device */
1907 ret = delta_register_device(delta);
1908 if (ret)
1909 goto err_work_queue;
1910
1911 dev_info(dev, "%s %s registered as /dev/video%d\n",
1912 DELTA_PREFIX, delta->vdev->name, delta->vdev->num);
1913
1914 return 0;
1915
1916err_work_queue:
1917 destroy_workqueue(delta->work_queue);
1918err_v4l2:
1919 v4l2_device_unregister(&delta->v4l2_dev);
1920err:
1921 return ret;
1922}
1923
1924static int delta_remove(struct platform_device *pdev)
1925{
1926 struct delta_dev *delta = platform_get_drvdata(pdev);
1927
1928 delta_ipc_exit(delta);
1929
1930 delta_unregister_device(delta);
1931
1932 destroy_workqueue(delta->work_queue);
1933
1934 pm_runtime_put_autosuspend(delta->dev);
1935 pm_runtime_disable(delta->dev);
1936
1937 v4l2_device_unregister(&delta->v4l2_dev);
1938
1939 return 0;
1940}
1941
1942static int delta_runtime_suspend(struct device *dev)
1943{
1944 struct delta_dev *delta = dev_get_drvdata(dev);
1945
1946 if (delta->clk_delta)
1947 clk_disable_unprepare(delta->clk_delta);
1948
1949 return 0;
1950}
1951
1952static int delta_runtime_resume(struct device *dev)
1953{
1954 struct delta_dev *delta = dev_get_drvdata(dev);
1955
1956 if (delta->clk_delta)
1957 if (clk_prepare_enable(delta->clk_delta))
1958 dev_warn(dev, "failed to prepare/enable delta clk\n");
1959
1960 return 0;
1961}
1962
1963/* PM ops */
1964static const struct dev_pm_ops delta_pm_ops = {
1965 .runtime_suspend = delta_runtime_suspend,
1966 .runtime_resume = delta_runtime_resume,
1967};
1968
1969static const struct of_device_id delta_match_types[] = {
1970 {
1971 .compatible = "st,st-delta",
1972 },
1973 {
1974 /* end node */
1975 }
1976};
1977
1978MODULE_DEVICE_TABLE(of, delta_match_types);
1979
1980static struct platform_driver delta_driver = {
1981 .probe = delta_probe,
1982 .remove = delta_remove,
1983 .driver = {
1984 .name = DELTA_NAME,
1985 .of_match_table = delta_match_types,
1986 .pm = &delta_pm_ops},
1987};
1988
1989module_platform_driver(delta_driver);
1990
1991MODULE_LICENSE("GPL");
1992MODULE_AUTHOR("Hugues Fruchet <hugues.fruchet@st.com>");
1993MODULE_DESCRIPTION("STMicroelectronics DELTA video decoder V4L2 driver");
diff --git a/drivers/media/platform/sti/delta/delta.h b/drivers/media/platform/sti/delta/delta.h
new file mode 100644
index 000000000000..60c073246a01
--- /dev/null
+++ b/drivers/media/platform/sti/delta/delta.h
@@ -0,0 +1,566 @@
1/*
2 * Copyright (C) STMicroelectronics SA 2015
3 * Author: Hugues Fruchet <hugues.fruchet@st.com> for STMicroelectronics.
4 * License terms: GNU General Public License (GPL), version 2
5 */
6
7#ifndef DELTA_H
8#define DELTA_H
9
10#include <linux/rpmsg.h>
11#include <media/v4l2-device.h>
12#include <media/v4l2-mem2mem.h>
13
14#include "delta-cfg.h"
15
16/*
17 * enum delta_state - state of decoding instance
18 *
19 *@DELTA_STATE_WF_FORMAT:
20 * Wait for compressed format to be set by V4L2 client in order
21 * to know what is the relevant decoder to open.
22 *
23 *@DELTA_STATE_WF_STREAMINFO:
24 * Wait for stream information to be available (bitstream
25 * header parsing is done).
26 *
27 *@DELTA_STATE_READY:
28 * Decoding instance is ready to decode compressed access unit.
29 *
30 *@DELTA_STATE_WF_EOS:
31 * Decoding instance is waiting for EOS (End Of Stream) completion.
32 *
33 *@DELTA_STATE_EOS:
34 * EOS (End Of Stream) is completed (signaled to user). Decoding instance
35 * should then be closed.
36 */
37enum delta_state {
38 DELTA_STATE_WF_FORMAT,
39 DELTA_STATE_WF_STREAMINFO,
40 DELTA_STATE_READY,
41 DELTA_STATE_WF_EOS,
42 DELTA_STATE_EOS
43};
44
45/*
46 * struct delta_streaminfo - information about stream to decode
47 *
48 * @flags: validity of fields (crop, pixelaspect, other)
49 * @width: width of video stream
50 * @height: height ""
51 * @streamformat: fourcc compressed format of video (MJPEG, MPEG2, ...)
52 * @dpb: number of frames needed to decode a single frame
53 * (h264 dpb, up to 16)
54 * @crop: cropping window inside decoded frame (1920x1080@0,0
55 * inside 1920x1088 frame for ex.)
56 * @pixelaspect: pixel aspect ratio of video (4/3, 5/4)
57 * @field: interlaced or not
58 * @profile: profile string
59 * @level: level string
60 * @other: other string information from codec
61 * @colorspace: colorspace identifier
62 * @xfer_func: transfer function identifier
63 * @ycbcr_enc: Y'CbCr encoding identifier
64 * @quantization: quantization identifier
65 */
66struct delta_streaminfo {
67 u32 flags;
68 u32 streamformat;
69 u32 width;
70 u32 height;
71 u32 dpb;
72 struct v4l2_rect crop;
73 struct v4l2_fract pixelaspect;
74 enum v4l2_field field;
75 u8 profile[32];
76 u8 level[32];
77 u8 other[32];
78 enum v4l2_colorspace colorspace;
79 enum v4l2_xfer_func xfer_func;
80 enum v4l2_ycbcr_encoding ycbcr_enc;
81 enum v4l2_quantization quantization;
82};
83
84#define DELTA_STREAMINFO_FLAG_CROP 0x0001
85#define DELTA_STREAMINFO_FLAG_PIXELASPECT 0x0002
86#define DELTA_STREAMINFO_FLAG_OTHER 0x0004
87
88/*
89 * struct delta_au - access unit structure.
90 *
91 * @vbuf: video buffer information for V4L2
92 * @list: V4L2 m2m list that the frame belongs to
93 * @prepared: if set vaddr/paddr are resolved
94 * @vaddr: virtual address (kernel can read/write)
95 * @paddr: physical address (for hardware)
96 * @flags: access unit type (V4L2_BUF_FLAG_KEYFRAME/PFRAME/BFRAME)
97 * @dts: decoding timestamp of this access unit
98 */
99struct delta_au {
100 struct vb2_v4l2_buffer vbuf; /* keep first */
101 struct list_head list; /* keep second */
102
103 bool prepared;
104 u32 size;
105 void *vaddr;
106 dma_addr_t paddr;
107 u32 flags;
108 u64 dts;
109};
110
111/*
112 * struct delta_frameinfo - information about decoded frame
113 *
114 * @flags: validity of fields (crop, pixelaspect)
115 * @pixelformat: fourcc code for uncompressed video format
116 * @width: width of frame
117 * @height: height of frame
118 * @aligned_width: width of frame (with encoder or decoder alignment
119 * constraint)
120 * @aligned_height: height of frame (with encoder or decoder alignment
121 * constraint)
122 * @size: maximum size in bytes required for data
123 * @crop: cropping window inside frame (1920x1080@0,0
124 * inside 1920x1088 frame for ex.)
125 * @pixelaspect: pixel aspect ratio of video (4/3, 5/4)
126 * @field: interlaced mode
127 * @colorspace: colorspace identifier
128 * @xfer_func: transfer function identifier
129 * @ycbcr_enc: Y'CbCr encoding identifier
130 * @quantization: quantization identifier
131 */
132struct delta_frameinfo {
133 u32 flags;
134 u32 pixelformat;
135 u32 width;
136 u32 height;
137 u32 aligned_width;
138 u32 aligned_height;
139 u32 size;
140 struct v4l2_rect crop;
141 struct v4l2_fract pixelaspect;
142 enum v4l2_field field;
143 enum v4l2_colorspace colorspace;
144 enum v4l2_xfer_func xfer_func;
145 enum v4l2_ycbcr_encoding ycbcr_enc;
146 enum v4l2_quantization quantization;
147};
148
149#define DELTA_FRAMEINFO_FLAG_CROP 0x0001
150#define DELTA_FRAMEINFO_FLAG_PIXELASPECT 0x0002
151
152/*
153 * struct delta_frame - frame structure.
154 *
155 * @vbuf: video buffer information for V4L2
156 * @list: V4L2 m2m list that the frame belongs to
157 * @info: frame information (width, height, format, alignment...)
158 * @prepared: if set pix/vaddr/paddr are resolved
159 * @index: frame index, aligned on V4L2 wow
160 * @vaddr: virtual address (kernel can read/write)
161 * @paddr: physical address (for hardware)
162 * @state: frame state for frame lifecycle tracking
163 * (DELTA_FRAME_FREE/DEC/OUT/REC/...)
164 * @flags: frame type (V4L2_BUF_FLAG_KEYFRAME/PFRAME/BFRAME)
165 * @dts: decoding timestamp of this frame
166 * @field: field order for interlaced frame
167 */
168struct delta_frame {
169 struct vb2_v4l2_buffer vbuf; /* keep first */
170 struct list_head list; /* keep second */
171
172 struct delta_frameinfo info;
173 bool prepared;
174 u32 index;
175 void *vaddr;
176 dma_addr_t paddr;
177 u32 state;
178 u32 flags;
179 u64 dts;
180 enum v4l2_field field;
181};
182
183/* frame state for frame lifecycle tracking */
184#define DELTA_FRAME_FREE 0x00 /* is free and can be used for decoding */
185#define DELTA_FRAME_REF 0x01 /* is a reference frame */
186#define DELTA_FRAME_BSY 0x02 /* is owned by decoder and busy */
187#define DELTA_FRAME_DEC 0x04 /* contains decoded content */
188#define DELTA_FRAME_OUT 0x08 /* has been given to user */
189#define DELTA_FRAME_RDY 0x10 /* is ready but still held by decoder */
190#define DELTA_FRAME_M2M 0x20 /* is owned by mem2mem framework */
191
192/*
193 * struct delta_dts - decoding timestamp.
194 *
195 * @list: list to chain timestamps
196 * @val: timestamp in microseconds
197 */
198struct delta_dts {
199 struct list_head list;
200 u64 val;
201};
202
203struct delta_buf {
204 u32 size;
205 void *vaddr;
206 dma_addr_t paddr;
207 const char *name;
208 unsigned long attrs;
209};
210
211struct delta_ipc_ctx {
212 int cb_err;
213 u32 copro_hdl;
214 struct completion done;
215 struct delta_buf ipc_buf_struct;
216 struct delta_buf *ipc_buf;
217};
218
219struct delta_ipc_param {
220 u32 size;
221 void *data;
222};
223
224struct delta_ctx;
225
226/*
227 * struct delta_dec - decoder structure.
228 *
229 * @name: name of this decoder
230 * @streamformat: input stream format that this decoder support
231 * @pixelformat: pixel format of decoded frame that this decoder support
232 * @max_width: (optional) maximum width that can decode this decoder
233 * if not set, maximum width is DELTA_MAX_WIDTH
234 * @max_height: (optional) maximum height that can decode this decoder
235 * if not set, maximum height is DELTA_MAX_HEIGHT
236 * @pm: (optional) if set, decoder will manage power on its own
237 * @open: open this decoder
238 * @close: close this decoder
239 * @setup_frame: setup frame to be used by decoder, see below
240 * @get_streaminfo: get stream related infos, see below
241 * @get_frameinfo: get decoded frame related infos, see below
242 * @set_frameinfo: (optional) set decoded frame related infos, see below
243 * @setup_frame: setup frame to be used by decoder, see below
244 * @decode: decode a single access unit, see below
245 * @get_frame: get the next decoded frame available, see below
246 * @recycle: recycle the given frame, see below
247 * @flush: (optional) flush decoder, see below
248 * @drain: (optional) drain decoder, see below
249 */
250struct delta_dec {
251 const char *name;
252 u32 streamformat;
253 u32 pixelformat;
254 u32 max_width;
255 u32 max_height;
256 bool pm;
257
258 /*
259 * decoder ops
260 */
261 int (*open)(struct delta_ctx *ctx);
262 int (*close)(struct delta_ctx *ctx);
263
264 /*
265 * setup_frame() - setup frame to be used by decoder
266 * @ctx: (in) instance
267 * @frame: (in) frame to use
268 * @frame.index (in) identifier of frame
269 * @frame.vaddr (in) virtual address (kernel can read/write)
270 * @frame.paddr (in) physical address (for hardware)
271 *
272 * Frame is to be allocated by caller, then given
273 * to decoder through this call.
274 * Several frames must be given to decoder (dpb),
275 * each frame is identified using its index.
276 */
277 int (*setup_frame)(struct delta_ctx *ctx, struct delta_frame *frame);
278
279 /*
280 * get_streaminfo() - get stream related infos
281 * @ctx: (in) instance
282 * @streaminfo: (out) width, height, dpb,...
283 *
284 * Precondition: stream header must have been successfully
285 * parsed to have this call successful & @streaminfo valid.
286 * Header parsing must be done using decode(), giving
287 * explicitly header access unit or first access unit of bitstream.
288 * If no valid header is found, get_streaminfo will return -ENODATA,
289 * in this case the next bistream access unit must be decoded till
290 * get_streaminfo becomes successful.
291 */
292 int (*get_streaminfo)(struct delta_ctx *ctx,
293 struct delta_streaminfo *streaminfo);
294
295 /*
296 * get_frameinfo() - get decoded frame related infos
297 * @ctx: (in) instance
298 * @frameinfo: (out) width, height, alignment, crop, ...
299 *
300 * Precondition: get_streaminfo() must be successful
301 */
302 int (*get_frameinfo)(struct delta_ctx *ctx,
303 struct delta_frameinfo *frameinfo);
304
305 /*
306 * set_frameinfo() - set decoded frame related infos
307 * @ctx: (in) instance
308 * @frameinfo: (out) width, height, alignment, crop, ...
309 *
310 * Optional.
311 * Typically used to negotiate with decoder the output
312 * frame if decoder can do post-processing.
313 */
314 int (*set_frameinfo)(struct delta_ctx *ctx,
315 struct delta_frameinfo *frameinfo);
316
317 /*
318 * decode() - decode a single access unit
319 * @ctx: (in) instance
320 * @au: (in/out) access unit
321 * @au.size (in) size of au to decode
322 * @au.vaddr (in) virtual address (kernel can read/write)
323 * @au.paddr (in) physical address (for hardware)
324 * @au.flags (out) au type (V4L2_BUF_FLAG_KEYFRAME/
325 * PFRAME/BFRAME)
326 *
327 * Decode the access unit given. Decode is synchronous;
328 * access unit memory is no more needed after this call.
329 * After this call, none, one or several frames could
330 * have been decoded, which can be retrieved using
331 * get_frame().
332 */
333 int (*decode)(struct delta_ctx *ctx, struct delta_au *au);
334
335 /*
336 * get_frame() - get the next decoded frame available
337 * @ctx: (in) instance
338 * @frame: (out) frame with decoded data:
339 * @frame.index (out) identifier of frame
340 * @frame.field (out) field order for interlaced frame
341 * @frame.state (out) frame state for frame lifecycle tracking
342 * @frame.flags (out) frame type (V4L2_BUF_FLAG_KEYFRAME/
343 * PFRAME/BFRAME)
344 *
345 * Get the next available decoded frame.
346 * If no frame is available, -ENODATA is returned.
347 * If a frame is available, frame structure is filled with
348 * relevant data, frame.index identifying this exact frame.
349 * When this frame is no more needed by upper layers,
350 * recycle() must be called giving this frame identifier.
351 */
352 int (*get_frame)(struct delta_ctx *ctx, struct delta_frame **frame);
353
354 /*
355 * recycle() - recycle the given frame
356 * @ctx: (in) instance
357 * @frame: (in) frame to recycle:
358 * @frame.index (in) identifier of frame
359 *
360 * recycle() is to be called by user when the decoded frame
361 * is no more needed (composition/display done).
362 * This frame will then be reused by decoder to proceed
363 * with next frame decoding.
364 * If not enough frames have been provided through setup_frame(),
365 * or recycle() is not called fast enough, the decoder can run out
366 * of available frames to proceed with decoding (starvation).
367 * This case is guarded by wq_recycle wait queue which ensures that
368 * decoder is called only if at least one frame is available.
369 */
370 int (*recycle)(struct delta_ctx *ctx, struct delta_frame *frame);
371
372 /*
373 * flush() - flush decoder
374 * @ctx: (in) instance
375 *
376 * Optional.
377 * Reset decoder context and discard all internal buffers.
378 * This allows implementation of seek, which leads to discontinuity
379 * of input bitstream that decoder must know to restart its internal
380 * decoding logic.
381 */
382 int (*flush)(struct delta_ctx *ctx);
383
384 /*
385 * drain() - drain decoder
386 * @ctx: (in) instance
387 *
388 * Optional.
389 * Mark decoder pending frames (decoded but not yet output) as ready
390 * so that they can be output to client at EOS (End Of Stream).
391 * get_frame() is to be called in a loop right after drain() to
392 * get all those pending frames.
393 */
394 int (*drain)(struct delta_ctx *ctx);
395};
396
397struct delta_dev;
398
399/*
400 * struct delta_ctx - instance structure.
401 *
402 * @flags: validity of fields (streaminfo)
403 * @fh: V4L2 file handle
404 * @dev: device context
405 * @dec: selected decoder context for this instance
406 * @ipc_ctx: context of IPC communication with firmware
407 * @state: instance state
408 * @frame_num: frame number
409 * @au_num: access unit number
410 * @max_au_size: max size of an access unit
411 * @streaminfo: stream information (width, height, dpb, interlacing...)
412 * @frameinfo: frame information (width, height, format, alignment...)
413 * @nb_of_frames: number of frames available for decoding
414 * @frames: array of decoding frames to keep track of frame
415 * state and manage frame recycling
416 * @decoded_frames: nb of decoded frames from opening
417 * @output_frames: nb of output frames from opening
418 * @dropped_frames: nb of frames dropped (ie access unit not parsed
419 * or frame decoded but not output)
420 * @stream_errors: nb of stream errors (corrupted, not supported, ...)
421 * @decode_errors: nb of decode errors (firmware error)
422 * @sys_errors: nb of system errors (memory, ipc, ...)
423 * @dts: FIFO of decoding timestamp.
424 * output frames are timestamped with incoming access
425 * unit timestamps using this fifo.
426 * @name: string naming this instance (debug purpose)
427 * @run_work: decoding work
428 * @lock: lock for decoding work serialization
429 * @aborting: true if current job aborted
430 * @priv: private decoder context for this instance, allocated
431 * by decoder @open time.
432 */
433struct delta_ctx {
434 u32 flags;
435 struct v4l2_fh fh;
436 struct delta_dev *dev;
437 const struct delta_dec *dec;
438 struct delta_ipc_ctx ipc_ctx;
439
440 enum delta_state state;
441 u32 frame_num;
442 u32 au_num;
443 size_t max_au_size;
444 struct delta_streaminfo streaminfo;
445 struct delta_frameinfo frameinfo;
446 u32 nb_of_frames;
447 struct delta_frame *frames[DELTA_MAX_FRAMES];
448 u32 decoded_frames;
449 u32 output_frames;
450 u32 dropped_frames;
451 u32 stream_errors;
452 u32 decode_errors;
453 u32 sys_errors;
454 struct list_head dts;
455 char name[100];
456 struct work_struct run_work;
457 struct mutex lock;
458 bool aborting;
459 void *priv;
460};
461
462#define DELTA_FLAG_STREAMINFO 0x0001
463#define DELTA_FLAG_FRAMEINFO 0x0002
464
465#define DELTA_MAX_FORMATS DELTA_MAX_DECODERS
466
467/*
468 * struct delta_dev - device struct, 1 per probe (so single one for
469 * all platform life)
470 *
471 * @v4l2_dev: v4l2 device
472 * @vdev: v4l2 video device
473 * @pdev: platform device
474 * @dev: device
475 * @m2m_dev: memory-to-memory V4L2 device
476 * @lock: device lock, for crit section & V4L2 ops serialization.
477 * @clk_delta: delta main clock
478 * @clk_st231: st231 coprocessor main clock
479 * @clk_flash_promip: flash promip clock
480 * @decoders: list of registered decoders
481 * @nb_of_decoders: nb of registered decoders
482 * @pixelformats: supported uncompressed video formats
483 * @nb_of_pixelformats: number of supported umcompressed video formats
484 * @streamformats: supported compressed video formats
485 * @nb_of_streamformats:number of supported compressed video formats
486 * @instance_id: rolling counter identifying an instance (debug purpose)
487 * @work_queue: decoding job work queue
488 * @rpmsg_driver: rpmsg IPC driver
489 * @rpmsg_device: rpmsg IPC device
490 */
491struct delta_dev {
492 struct v4l2_device v4l2_dev;
493 struct video_device *vdev;
494 struct platform_device *pdev;
495 struct device *dev;
496 struct v4l2_m2m_dev *m2m_dev;
497 struct mutex lock;
498 struct clk *clk_delta;
499 struct clk *clk_st231;
500 struct clk *clk_flash_promip;
501 const struct delta_dec *decoders[DELTA_MAX_DECODERS];
502 u32 nb_of_decoders;
503 u32 pixelformats[DELTA_MAX_FORMATS];
504 u32 nb_of_pixelformats;
505 u32 streamformats[DELTA_MAX_FORMATS];
506 u32 nb_of_streamformats;
507 u8 instance_id;
508 struct workqueue_struct *work_queue;
509 struct rpmsg_driver rpmsg_driver;
510 struct rpmsg_device *rpmsg_device;
511};
512
513static inline char *frame_type_str(u32 flags)
514{
515 if (flags & V4L2_BUF_FLAG_KEYFRAME)
516 return "I";
517 if (flags & V4L2_BUF_FLAG_PFRAME)
518 return "P";
519 if (flags & V4L2_BUF_FLAG_BFRAME)
520 return "B";
521 if (flags & V4L2_BUF_FLAG_LAST)
522 return "EOS";
523 return "?";
524}
525
526static inline char *frame_field_str(enum v4l2_field field)
527{
528 if (field == V4L2_FIELD_NONE)
529 return "-";
530 if (field == V4L2_FIELD_TOP)
531 return "T";
532 if (field == V4L2_FIELD_BOTTOM)
533 return "B";
534 if (field == V4L2_FIELD_INTERLACED)
535 return "I";
536 if (field == V4L2_FIELD_INTERLACED_TB)
537 return "TB";
538 if (field == V4L2_FIELD_INTERLACED_BT)
539 return "BT";
540 return "?";
541}
542
543static inline char *frame_state_str(u32 state, char *str, unsigned int len)
544{
545 snprintf(str, len, "%s %s %s %s %s %s",
546 (state & DELTA_FRAME_REF) ? "ref" : " ",
547 (state & DELTA_FRAME_BSY) ? "bsy" : " ",
548 (state & DELTA_FRAME_DEC) ? "dec" : " ",
549 (state & DELTA_FRAME_OUT) ? "out" : " ",
550 (state & DELTA_FRAME_M2M) ? "m2m" : " ",
551 (state & DELTA_FRAME_RDY) ? "rdy" : " ");
552 return str;
553}
554
555int delta_get_frameinfo_default(struct delta_ctx *ctx,
556 struct delta_frameinfo *frameinfo);
557int delta_recycle_default(struct delta_ctx *pctx,
558 struct delta_frame *frame);
559
560int delta_get_free_frame(struct delta_ctx *ctx,
561 struct delta_frame **pframe);
562
563int delta_get_sync(struct delta_ctx *ctx);
564void delta_put_autosuspend(struct delta_ctx *ctx);
565
566#endif /* DELTA_H */
diff --git a/drivers/media/platform/sti/hva/Makefile b/drivers/media/platform/sti/hva/Makefile
index ffb69cebaef3..e3ebe968472d 100644
--- a/drivers/media/platform/sti/hva/Makefile
+++ b/drivers/media/platform/sti/hva/Makefile
@@ -1,2 +1,3 @@
1obj-$(CONFIG_VIDEO_STI_HVA) := st-hva.o 1obj-$(CONFIG_VIDEO_STI_HVA) := st-hva.o
2st-hva-y := hva-v4l2.o hva-hw.o hva-mem.o hva-h264.o 2st-hva-y := hva-v4l2.o hva-hw.o hva-mem.o hva-h264.o
3st-hva-$(CONFIG_VIDEO_STI_HVA_DEBUGFS) += hva-debugfs.o
diff --git a/drivers/media/platform/sti/hva/hva-debugfs.c b/drivers/media/platform/sti/hva/hva-debugfs.c
new file mode 100644
index 000000000000..83a6258a155b
--- /dev/null
+++ b/drivers/media/platform/sti/hva/hva-debugfs.c
@@ -0,0 +1,422 @@
1/*
2 * Copyright (C) STMicroelectronics SA 2015
3 * Authors: Yannick Fertre <yannick.fertre@st.com>
4 * Hugues Fruchet <hugues.fruchet@st.com>
5 * License terms: GNU General Public License (GPL), version 2
6 */
7
8#include <linux/debugfs.h>
9
10#include "hva.h"
11#include "hva-hw.h"
12
13static void format_ctx(struct seq_file *s, struct hva_ctx *ctx)
14{
15 struct hva_streaminfo *stream = &ctx->streaminfo;
16 struct hva_frameinfo *frame = &ctx->frameinfo;
17 struct hva_controls *ctrls = &ctx->ctrls;
18 struct hva_ctx_dbg *dbg = &ctx->dbg;
19 u32 bitrate_mode, aspect, entropy, vui_sar, sei_fp;
20
21 seq_printf(s, "|-%s\n |\n", ctx->name);
22
23 seq_printf(s, " |-[%sframe info]\n",
24 ctx->flags & HVA_FLAG_FRAMEINFO ? "" : "default ");
25 seq_printf(s, " | |- pixel format=%4.4s\n"
26 " | |- wxh=%dx%d\n"
27 " | |- wxh (w/ encoder alignment constraint)=%dx%d\n"
28 " |\n",
29 (char *)&frame->pixelformat,
30 frame->width, frame->height,
31 frame->aligned_width, frame->aligned_height);
32
33 seq_printf(s, " |-[%sstream info]\n",
34 ctx->flags & HVA_FLAG_STREAMINFO ? "" : "default ");
35 seq_printf(s, " | |- stream format=%4.4s\n"
36 " | |- wxh=%dx%d\n"
37 " | |- %s\n"
38 " | |- %s\n"
39 " |\n",
40 (char *)&stream->streamformat,
41 stream->width, stream->height,
42 stream->profile, stream->level);
43
44 bitrate_mode = V4L2_CID_MPEG_VIDEO_BITRATE_MODE;
45 aspect = V4L2_CID_MPEG_VIDEO_ASPECT;
46 seq_puts(s, " |-[parameters]\n");
47 seq_printf(s, " | |- %s\n"
48 " | |- bitrate=%d bps\n"
49 " | |- GOP size=%d\n"
50 " | |- video aspect=%s\n"
51 " | |- framerate=%d/%d\n",
52 v4l2_ctrl_get_menu(bitrate_mode)[ctrls->bitrate_mode],
53 ctrls->bitrate,
54 ctrls->gop_size,
55 v4l2_ctrl_get_menu(aspect)[ctrls->aspect],
56 ctrls->time_per_frame.denominator,
57 ctrls->time_per_frame.numerator);
58
59 entropy = V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE;
60 vui_sar = V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC;
61 sei_fp = V4L2_CID_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE;
62 if (stream->streamformat == V4L2_PIX_FMT_H264) {
63 seq_printf(s, " | |- %s entropy mode\n"
64 " | |- CPB size=%d kB\n"
65 " | |- DCT8x8 enable=%s\n"
66 " | |- qpmin=%d\n"
67 " | |- qpmax=%d\n"
68 " | |- PAR enable=%s\n"
69 " | |- PAR id=%s\n"
70 " | |- SEI frame packing enable=%s\n"
71 " | |- SEI frame packing type=%s\n",
72 v4l2_ctrl_get_menu(entropy)[ctrls->entropy_mode],
73 ctrls->cpb_size,
74 ctrls->dct8x8 ? "true" : "false",
75 ctrls->qpmin,
76 ctrls->qpmax,
77 ctrls->vui_sar ? "true" : "false",
78 v4l2_ctrl_get_menu(vui_sar)[ctrls->vui_sar_idc],
79 ctrls->sei_fp ? "true" : "false",
80 v4l2_ctrl_get_menu(sei_fp)[ctrls->sei_fp_type]);
81 }
82
83 if (ctx->sys_errors || ctx->encode_errors || ctx->frame_errors) {
84 seq_puts(s, " |\n |-[errors]\n");
85 seq_printf(s, " | |- system=%d\n"
86 " | |- encoding=%d\n"
87 " | |- frame=%d\n",
88 ctx->sys_errors,
89 ctx->encode_errors,
90 ctx->frame_errors);
91 }
92
93 seq_puts(s, " |\n |-[performances]\n");
94 seq_printf(s, " | |- frames encoded=%d\n"
95 " | |- avg HW processing duration (0.1ms)=%d [min=%d, max=%d]\n"
96 " | |- avg encoding period (0.1ms)=%d [min=%d, max=%d]\n"
97 " | |- avg fps (0.1Hz)=%d\n"
98 " | |- max reachable fps (0.1Hz)=%d\n"
99 " | |- avg bitrate (kbps)=%d [min=%d, max=%d]\n"
100 " | |- last bitrate (kbps)=%d\n",
101 dbg->cnt_duration,
102 dbg->avg_duration,
103 dbg->min_duration,
104 dbg->max_duration,
105 dbg->avg_period,
106 dbg->min_period,
107 dbg->max_period,
108 dbg->avg_fps,
109 dbg->max_fps,
110 dbg->avg_bitrate,
111 dbg->min_bitrate,
112 dbg->max_bitrate,
113 dbg->last_bitrate);
114}
115
116/*
117 * performance debug info
118 */
119void hva_dbg_perf_begin(struct hva_ctx *ctx)
120{
121 u64 div;
122 u32 period;
123 u32 bitrate;
124 struct hva_ctx_dbg *dbg = &ctx->dbg;
125 ktime_t prev = dbg->begin;
126
127 dbg->begin = ktime_get();
128
129 if (dbg->is_valid_period) {
130 /* encoding period */
131 div = (u64)ktime_us_delta(dbg->begin, prev);
132 do_div(div, 100);
133 period = (u32)div;
134 dbg->min_period = min(period, dbg->min_period);
135 dbg->max_period = max(period, dbg->max_period);
136 dbg->total_period += period;
137 dbg->cnt_period++;
138
139 /*
140 * minimum and maximum bitrates are based on the
141 * encoding period values upon a window of 32 samples
142 */
143 dbg->window_duration += period;
144 dbg->cnt_window++;
145 if (dbg->cnt_window >= 32) {
146 /*
147 * bitrate in kbps = (size * 8 / 1000) /
148 * (duration / 10000)
149 * = size * 80 / duration
150 */
151 if (dbg->window_duration > 0) {
152 div = (u64)dbg->window_stream_size * 80;
153 do_div(div, dbg->window_duration);
154 bitrate = (u32)div;
155 dbg->last_bitrate = bitrate;
156 dbg->min_bitrate = min(bitrate,
157 dbg->min_bitrate);
158 dbg->max_bitrate = max(bitrate,
159 dbg->max_bitrate);
160 }
161 dbg->window_stream_size = 0;
162 dbg->window_duration = 0;
163 dbg->cnt_window = 0;
164 }
165 }
166
167 /*
168 * filter sequences valid for performance:
169 * - begin/begin (no stream available) is an invalid sequence
170 * - begin/end is a valid sequence
171 */
172 dbg->is_valid_period = false;
173}
174
175void hva_dbg_perf_end(struct hva_ctx *ctx, struct hva_stream *stream)
176{
177 struct device *dev = ctx_to_dev(ctx);
178 u64 div;
179 u32 duration;
180 u32 bytesused;
181 u32 timestamp;
182 struct hva_ctx_dbg *dbg = &ctx->dbg;
183 ktime_t end = ktime_get();
184
185 /* stream bytesused and timestamp in us */
186 bytesused = vb2_get_plane_payload(&stream->vbuf.vb2_buf, 0);
187 div = stream->vbuf.vb2_buf.timestamp;
188 do_div(div, 1000);
189 timestamp = (u32)div;
190
191 /* encoding duration */
192 div = (u64)ktime_us_delta(end, dbg->begin);
193
194 dev_dbg(dev,
195 "%s perf stream[%d] dts=%d encoded using %d bytes in %d us",
196 ctx->name,
197 stream->vbuf.sequence,
198 timestamp,
199 bytesused, (u32)div);
200
201 do_div(div, 100);
202 duration = (u32)div;
203
204 dbg->min_duration = min(duration, dbg->min_duration);
205 dbg->max_duration = max(duration, dbg->max_duration);
206 dbg->total_duration += duration;
207 dbg->cnt_duration++;
208
209 /*
210 * the average bitrate is based on the total stream size
211 * and the total encoding periods
212 */
213 dbg->total_stream_size += bytesused;
214 dbg->window_stream_size += bytesused;
215
216 dbg->is_valid_period = true;
217}
218
219static void hva_dbg_perf_compute(struct hva_ctx *ctx)
220{
221 u64 div;
222 struct hva_ctx_dbg *dbg = &ctx->dbg;
223
224 if (dbg->cnt_duration > 0) {
225 div = (u64)dbg->total_duration;
226 do_div(div, dbg->cnt_duration);
227 dbg->avg_duration = (u32)div;
228 } else {
229 dbg->avg_duration = 0;
230 }
231
232 if (dbg->total_duration > 0) {
233 div = (u64)dbg->cnt_duration * 100000;
234 do_div(div, dbg->total_duration);
235 dbg->max_fps = (u32)div;
236 } else {
237 dbg->max_fps = 0;
238 }
239
240 if (dbg->cnt_period > 0) {
241 div = (u64)dbg->total_period;
242 do_div(div, dbg->cnt_period);
243 dbg->avg_period = (u32)div;
244 } else {
245 dbg->avg_period = 0;
246 }
247
248 if (dbg->total_period > 0) {
249 div = (u64)dbg->cnt_period * 100000;
250 do_div(div, dbg->total_period);
251 dbg->avg_fps = (u32)div;
252 } else {
253 dbg->avg_fps = 0;
254 }
255
256 if (dbg->total_period > 0) {
257 /*
258 * bitrate in kbps = (video size * 8 / 1000) /
259 * (video duration / 10000)
260 * = video size * 80 / video duration
261 */
262 div = (u64)dbg->total_stream_size * 80;
263 do_div(div, dbg->total_period);
264 dbg->avg_bitrate = (u32)div;
265 } else {
266 dbg->avg_bitrate = 0;
267 }
268}
269
270/*
271 * device debug info
272 */
273
274static int hva_dbg_device(struct seq_file *s, void *data)
275{
276 struct hva_dev *hva = s->private;
277
278 seq_printf(s, "[%s]\n", hva->v4l2_dev.name);
279 seq_printf(s, "registered as /dev/video%d\n", hva->vdev->num);
280
281 return 0;
282}
283
284static int hva_dbg_encoders(struct seq_file *s, void *data)
285{
286 struct hva_dev *hva = s->private;
287 unsigned int i = 0;
288
289 seq_printf(s, "[encoders]\n|- %d registered encoders:\n",
290 hva->nb_of_encoders);
291
292 while (hva->encoders[i]) {
293 seq_printf(s, "|- %s: %4.4s => %4.4s\n", hva->encoders[i]->name,
294 (char *)&hva->encoders[i]->pixelformat,
295 (char *)&hva->encoders[i]->streamformat);
296 i++;
297 }
298
299 return 0;
300}
301
302static int hva_dbg_last(struct seq_file *s, void *data)
303{
304 struct hva_dev *hva = s->private;
305 struct hva_ctx *last_ctx = &hva->dbg.last_ctx;
306
307 if (last_ctx->flags & HVA_FLAG_STREAMINFO) {
308 seq_puts(s, "[last encoding]\n");
309
310 hva_dbg_perf_compute(last_ctx);
311 format_ctx(s, last_ctx);
312 } else {
313 seq_puts(s, "[no information recorded about last encoding]\n");
314 }
315
316 return 0;
317}
318
319static int hva_dbg_regs(struct seq_file *s, void *data)
320{
321 struct hva_dev *hva = s->private;
322
323 hva_hw_dump_regs(hva, s);
324
325 return 0;
326}
327
328#define hva_dbg_declare(name) \
329 static int hva_dbg_##name##_open(struct inode *i, struct file *f) \
330 { \
331 return single_open(f, hva_dbg_##name, i->i_private); \
332 } \
333 static const struct file_operations hva_dbg_##name##_fops = { \
334 .open = hva_dbg_##name##_open, \
335 .read = seq_read, \
336 .llseek = seq_lseek, \
337 .release = single_release, \
338 }
339
340#define hva_dbg_create_entry(name) \
341 debugfs_create_file(#name, 0444, hva->dbg.debugfs_entry, hva, \
342 &hva_dbg_##name##_fops)
343
344hva_dbg_declare(device);
345hva_dbg_declare(encoders);
346hva_dbg_declare(last);
347hva_dbg_declare(regs);
348
349void hva_debugfs_create(struct hva_dev *hva)
350{
351 hva->dbg.debugfs_entry = debugfs_create_dir(HVA_NAME, NULL);
352 if (!hva->dbg.debugfs_entry)
353 goto err;
354
355 if (!hva_dbg_create_entry(device))
356 goto err;
357
358 if (!hva_dbg_create_entry(encoders))
359 goto err;
360
361 if (!hva_dbg_create_entry(last))
362 goto err;
363
364 if (!hva_dbg_create_entry(regs))
365 goto err;
366
367 return;
368
369err:
370 hva_debugfs_remove(hva);
371}
372
373void hva_debugfs_remove(struct hva_dev *hva)
374{
375 debugfs_remove_recursive(hva->dbg.debugfs_entry);
376 hva->dbg.debugfs_entry = NULL;
377}
378
379/*
380 * context (instance) debug info
381 */
382
383static int hva_dbg_ctx(struct seq_file *s, void *data)
384{
385 struct hva_ctx *ctx = s->private;
386
387 seq_printf(s, "[running encoding %d]\n", ctx->id);
388
389 hva_dbg_perf_compute(ctx);
390 format_ctx(s, ctx);
391
392 return 0;
393}
394
395hva_dbg_declare(ctx);
396
397void hva_dbg_ctx_create(struct hva_ctx *ctx)
398{
399 struct hva_dev *hva = ctx->hva_dev;
400 char name[4] = "";
401
402 ctx->dbg.min_duration = UINT_MAX;
403 ctx->dbg.min_period = UINT_MAX;
404 ctx->dbg.min_bitrate = UINT_MAX;
405
406 snprintf(name, sizeof(name), "%d", hva->instance_id);
407
408 ctx->dbg.debugfs_entry = debugfs_create_file(name, 0444,
409 hva->dbg.debugfs_entry,
410 ctx, &hva_dbg_ctx_fops);
411}
412
413void hva_dbg_ctx_remove(struct hva_ctx *ctx)
414{
415 struct hva_dev *hva = ctx->hva_dev;
416
417 if (ctx->flags & HVA_FLAG_STREAMINFO)
418 /* save context before removing */
419 memcpy(&hva->dbg.last_ctx, ctx, sizeof(*ctx));
420
421 debugfs_remove(ctx->dbg.debugfs_entry);
422}
diff --git a/drivers/media/platform/sti/hva/hva-h264.c b/drivers/media/platform/sti/hva/hva-h264.c
index 8cc8467c0cd3..e6f247a983c7 100644
--- a/drivers/media/platform/sti/hva/hva-h264.c
+++ b/drivers/media/platform/sti/hva/hva-h264.c
@@ -607,6 +607,7 @@ static int hva_h264_prepare_task(struct hva_ctx *pctx,
607 "%s width(%d) or height(%d) exceeds limits (%dx%d)\n", 607 "%s width(%d) or height(%d) exceeds limits (%dx%d)\n",
608 pctx->name, frame_width, frame_height, 608 pctx->name, frame_width, frame_height,
609 H264_MAX_SIZE_W, H264_MAX_SIZE_H); 609 H264_MAX_SIZE_W, H264_MAX_SIZE_H);
610 pctx->frame_errors++;
610 return -EINVAL; 611 return -EINVAL;
611 } 612 }
612 613
@@ -717,6 +718,7 @@ static int hva_h264_prepare_task(struct hva_ctx *pctx,
717 default: 718 default:
718 dev_err(dev, "%s invalid source pixel format\n", 719 dev_err(dev, "%s invalid source pixel format\n",
719 pctx->name); 720 pctx->name);
721 pctx->frame_errors++;
720 return -EINVAL; 722 return -EINVAL;
721 } 723 }
722 724
@@ -741,6 +743,7 @@ static int hva_h264_prepare_task(struct hva_ctx *pctx,
741 743
742 if (td->framerate_den == 0) { 744 if (td->framerate_den == 0) {
743 dev_err(dev, "%s invalid framerate\n", pctx->name); 745 dev_err(dev, "%s invalid framerate\n", pctx->name);
746 pctx->frame_errors++;
744 return -EINVAL; 747 return -EINVAL;
745 } 748 }
746 749
@@ -831,6 +834,7 @@ static int hva_h264_prepare_task(struct hva_ctx *pctx,
831 (payload > MAX_SPS_PPS_SIZE)) { 834 (payload > MAX_SPS_PPS_SIZE)) {
832 dev_err(dev, "%s invalid sps/pps size %d\n", pctx->name, 835 dev_err(dev, "%s invalid sps/pps size %d\n", pctx->name,
833 payload); 836 payload);
837 pctx->frame_errors++;
834 return -EINVAL; 838 return -EINVAL;
835 } 839 }
836 840
@@ -842,6 +846,7 @@ static int hva_h264_prepare_task(struct hva_ctx *pctx,
842 (u8 *)stream->vaddr, 846 (u8 *)stream->vaddr,
843 &payload)) { 847 &payload)) {
844 dev_err(dev, "%s fail to get SEI nal\n", pctx->name); 848 dev_err(dev, "%s fail to get SEI nal\n", pctx->name);
849 pctx->frame_errors++;
845 return -EINVAL; 850 return -EINVAL;
846 } 851 }
847 852
@@ -963,6 +968,7 @@ err_seq_info:
963err_ctx: 968err_ctx:
964 devm_kfree(dev, ctx); 969 devm_kfree(dev, ctx);
965err: 970err:
971 pctx->sys_errors++;
966 return ret; 972 return ret;
967} 973}
968 974
diff --git a/drivers/media/platform/sti/hva/hva-hw.c b/drivers/media/platform/sti/hva/hva-hw.c
index 68d625b412b6..ec25bdcfa3d1 100644
--- a/drivers/media/platform/sti/hva/hva-hw.c
+++ b/drivers/media/platform/sti/hva/hva-hw.c
@@ -9,6 +9,9 @@
9#include <linux/interrupt.h> 9#include <linux/interrupt.h>
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/pm_runtime.h> 11#include <linux/pm_runtime.h>
12#ifdef CONFIG_VIDEO_STI_HVA_DEBUGFS
13#include <linux/seq_file.h>
14#endif
12 15
13#include "hva.h" 16#include "hva.h"
14#include "hva-hw.h" 17#include "hva-hw.h"
@@ -470,6 +473,7 @@ int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_hw_cmd_type cmd,
470 473
471 if (pm_runtime_get_sync(dev) < 0) { 474 if (pm_runtime_get_sync(dev) < 0) {
472 dev_err(dev, "%s failed to get pm_runtime\n", ctx->name); 475 dev_err(dev, "%s failed to get pm_runtime\n", ctx->name);
476 ctx->sys_errors++;
473 ret = -EFAULT; 477 ret = -EFAULT;
474 goto out; 478 goto out;
475 } 479 }
@@ -481,6 +485,7 @@ int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_hw_cmd_type cmd,
481 break; 485 break;
482 default: 486 default:
483 dev_dbg(dev, "%s unknown command 0x%x\n", ctx->name, cmd); 487 dev_dbg(dev, "%s unknown command 0x%x\n", ctx->name, cmd);
488 ctx->encode_errors++;
484 ret = -EFAULT; 489 ret = -EFAULT;
485 goto out; 490 goto out;
486 } 491 }
@@ -511,6 +516,7 @@ int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_hw_cmd_type cmd,
511 msecs_to_jiffies(2000))) { 516 msecs_to_jiffies(2000))) {
512 dev_err(dev, "%s %s: time out on completion\n", ctx->name, 517 dev_err(dev, "%s %s: time out on completion\n", ctx->name,
513 __func__); 518 __func__);
519 ctx->encode_errors++;
514 ret = -EFAULT; 520 ret = -EFAULT;
515 goto out; 521 goto out;
516 } 522 }
@@ -518,6 +524,8 @@ int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_hw_cmd_type cmd,
518 /* get encoding status */ 524 /* get encoding status */
519 ret = ctx->hw_err ? -EFAULT : 0; 525 ret = ctx->hw_err ? -EFAULT : 0;
520 526
527 ctx->encode_errors += ctx->hw_err ? 1 : 0;
528
521out: 529out:
522 disable_irq(hva->irq_its); 530 disable_irq(hva->irq_its);
523 disable_irq(hva->irq_err); 531 disable_irq(hva->irq_err);
@@ -536,3 +544,43 @@ out:
536 544
537 return ret; 545 return ret;
538} 546}
547
548#ifdef CONFIG_VIDEO_STI_HVA_DEBUGFS
549#define DUMP(reg) seq_printf(s, "%-30s: 0x%08X\n",\
550 #reg, readl_relaxed(hva->regs + reg))
551
552void hva_hw_dump_regs(struct hva_dev *hva, struct seq_file *s)
553{
554 struct device *dev = hva_to_dev(hva);
555
556 mutex_lock(&hva->protect_mutex);
557
558 if (pm_runtime_get_sync(dev) < 0) {
559 seq_puts(s, "Cannot wake up IP\n");
560 mutex_unlock(&hva->protect_mutex);
561 return;
562 }
563
564 seq_printf(s, "Registers:\nReg @ = 0x%p\n", hva->regs);
565
566 DUMP(HVA_HIF_REG_RST);
567 DUMP(HVA_HIF_REG_RST_ACK);
568 DUMP(HVA_HIF_REG_MIF_CFG);
569 DUMP(HVA_HIF_REG_HEC_MIF_CFG);
570 DUMP(HVA_HIF_REG_CFL);
571 DUMP(HVA_HIF_REG_SFL);
572 DUMP(HVA_HIF_REG_LMI_ERR);
573 DUMP(HVA_HIF_REG_EMI_ERR);
574 DUMP(HVA_HIF_REG_HEC_MIF_ERR);
575 DUMP(HVA_HIF_REG_HEC_STS);
576 DUMP(HVA_HIF_REG_HVC_STS);
577 DUMP(HVA_HIF_REG_HJE_STS);
578 DUMP(HVA_HIF_REG_CNT);
579 DUMP(HVA_HIF_REG_HEC_CHKSYN_DIS);
580 DUMP(HVA_HIF_REG_CLK_GATING);
581 DUMP(HVA_HIF_REG_VERSION);
582
583 pm_runtime_put_autosuspend(dev);
584 mutex_unlock(&hva->protect_mutex);
585}
586#endif
diff --git a/drivers/media/platform/sti/hva/hva-hw.h b/drivers/media/platform/sti/hva/hva-hw.h
index efb45b927524..b46017dcfae9 100644
--- a/drivers/media/platform/sti/hva/hva-hw.h
+++ b/drivers/media/platform/sti/hva/hva-hw.h
@@ -38,5 +38,8 @@ int hva_hw_runtime_suspend(struct device *dev);
38int hva_hw_runtime_resume(struct device *dev); 38int hva_hw_runtime_resume(struct device *dev);
39int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_hw_cmd_type cmd, 39int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_hw_cmd_type cmd,
40 struct hva_buffer *task); 40 struct hva_buffer *task);
41#ifdef CONFIG_VIDEO_STI_HVA_DEBUGFS
42void hva_hw_dump_regs(struct hva_dev *hva, struct seq_file *s);
43#endif
41 44
42#endif /* HVA_HW_H */ 45#endif /* HVA_HW_H */
diff --git a/drivers/media/platform/sti/hva/hva-mem.c b/drivers/media/platform/sti/hva/hva-mem.c
index 649f66007ad6..821c78ed208c 100644
--- a/drivers/media/platform/sti/hva/hva-mem.c
+++ b/drivers/media/platform/sti/hva/hva-mem.c
@@ -17,14 +17,17 @@ int hva_mem_alloc(struct hva_ctx *ctx, u32 size, const char *name,
17 void *base; 17 void *base;
18 18
19 b = devm_kzalloc(dev, sizeof(*b), GFP_KERNEL); 19 b = devm_kzalloc(dev, sizeof(*b), GFP_KERNEL);
20 if (!b) 20 if (!b) {
21 ctx->sys_errors++;
21 return -ENOMEM; 22 return -ENOMEM;
23 }
22 24
23 base = dma_alloc_attrs(dev, size, &paddr, GFP_KERNEL | GFP_DMA, 25 base = dma_alloc_attrs(dev, size, &paddr, GFP_KERNEL | GFP_DMA,
24 DMA_ATTR_WRITE_COMBINE); 26 DMA_ATTR_WRITE_COMBINE);
25 if (!base) { 27 if (!base) {
26 dev_err(dev, "%s %s : dma_alloc_attrs failed for %s (size=%d)\n", 28 dev_err(dev, "%s %s : dma_alloc_attrs failed for %s (size=%d)\n",
27 ctx->name, __func__, name, size); 29 ctx->name, __func__, name, size);
30 ctx->sys_errors++;
28 devm_kfree(dev, b); 31 devm_kfree(dev, b);
29 return -ENOMEM; 32 return -ENOMEM;
30 } 33 }
diff --git a/drivers/media/platform/sti/hva/hva-v4l2.c b/drivers/media/platform/sti/hva/hva-v4l2.c
index 6bf3c8588230..1c4fc33cbcb5 100644
--- a/drivers/media/platform/sti/hva/hva-v4l2.c
+++ b/drivers/media/platform/sti/hva/hva-v4l2.c
@@ -15,8 +15,6 @@
15#include "hva.h" 15#include "hva.h"
16#include "hva-hw.h" 16#include "hva-hw.h"
17 17
18#define HVA_NAME "st-hva"
19
20#define MIN_FRAMES 1 18#define MIN_FRAMES 1
21#define MIN_STREAMS 1 19#define MIN_STREAMS 1
22 20
@@ -226,6 +224,28 @@ static int hva_open_encoder(struct hva_ctx *ctx, u32 streamformat,
226 return ret; 224 return ret;
227} 225}
228 226
227static void hva_dbg_summary(struct hva_ctx *ctx)
228{
229 struct device *dev = ctx_to_dev(ctx);
230 struct hva_streaminfo *stream = &ctx->streaminfo;
231 struct hva_frameinfo *frame = &ctx->frameinfo;
232
233 if (!(ctx->flags & HVA_FLAG_STREAMINFO))
234 return;
235
236 dev_dbg(dev, "%s %4.4s %dx%d > %4.4s %dx%d %s %s: %d frames encoded, %d system errors, %d encoding errors, %d frame errors\n",
237 ctx->name,
238 (char *)&frame->pixelformat,
239 frame->aligned_width, frame->aligned_height,
240 (char *)&stream->streamformat,
241 stream->width, stream->height,
242 stream->profile, stream->level,
243 ctx->encoded_frames,
244 ctx->sys_errors,
245 ctx->encode_errors,
246 ctx->frame_errors);
247}
248
229/* 249/*
230 * V4L2 ioctl operations 250 * V4L2 ioctl operations
231 */ 251 */
@@ -614,19 +634,17 @@ static int hva_s_ctrl(struct v4l2_ctrl *ctrl)
614 break; 634 break;
615 case V4L2_CID_MPEG_VIDEO_H264_PROFILE: 635 case V4L2_CID_MPEG_VIDEO_H264_PROFILE:
616 ctx->ctrls.profile = ctrl->val; 636 ctx->ctrls.profile = ctrl->val;
617 if (ctx->flags & HVA_FLAG_STREAMINFO) 637 snprintf(ctx->streaminfo.profile,
618 snprintf(ctx->streaminfo.profile, 638 sizeof(ctx->streaminfo.profile),
619 sizeof(ctx->streaminfo.profile), 639 "%s profile",
620 "%s profile", 640 v4l2_ctrl_get_menu(ctrl->id)[ctrl->val]);
621 v4l2_ctrl_get_menu(ctrl->id)[ctrl->val]);
622 break; 641 break;
623 case V4L2_CID_MPEG_VIDEO_H264_LEVEL: 642 case V4L2_CID_MPEG_VIDEO_H264_LEVEL:
624 ctx->ctrls.level = ctrl->val; 643 ctx->ctrls.level = ctrl->val;
625 if (ctx->flags & HVA_FLAG_STREAMINFO) 644 snprintf(ctx->streaminfo.level,
626 snprintf(ctx->streaminfo.level, 645 sizeof(ctx->streaminfo.level),
627 sizeof(ctx->streaminfo.level), 646 "level %s",
628 "level %s", 647 v4l2_ctrl_get_menu(ctrl->id)[ctrl->val]);
629 v4l2_ctrl_get_menu(ctrl->id)[ctrl->val]);
630 break; 648 break;
631 case V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE: 649 case V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE:
632 ctx->ctrls.entropy_mode = ctrl->val; 650 ctx->ctrls.entropy_mode = ctrl->val;
@@ -793,6 +811,10 @@ static void hva_run_work(struct work_struct *work)
793 /* protect instance against reentrancy */ 811 /* protect instance against reentrancy */
794 mutex_lock(&ctx->lock); 812 mutex_lock(&ctx->lock);
795 813
814#ifdef CONFIG_VIDEO_STI_HVA_DEBUGFS
815 hva_dbg_perf_begin(ctx);
816#endif
817
796 src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); 818 src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
797 dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); 819 dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
798 820
@@ -812,6 +834,12 @@ static void hva_run_work(struct work_struct *work)
812 dst_buf->field = V4L2_FIELD_NONE; 834 dst_buf->field = V4L2_FIELD_NONE;
813 dst_buf->sequence = ctx->stream_num - 1; 835 dst_buf->sequence = ctx->stream_num - 1;
814 836
837 ctx->encoded_frames++;
838
839#ifdef CONFIG_VIDEO_STI_HVA_DEBUGFS
840 hva_dbg_perf_end(ctx, stream);
841#endif
842
815 v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE); 843 v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE);
816 v4l2_m2m_buf_done(dst_buf, VB2_BUF_STATE_DONE); 844 v4l2_m2m_buf_done(dst_buf, VB2_BUF_STATE_DONE);
817 } 845 }
@@ -1026,6 +1054,8 @@ err:
1026 v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_QUEUED); 1054 v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_QUEUED);
1027 } 1055 }
1028 1056
1057 ctx->sys_errors++;
1058
1029 return ret; 1059 return ret;
1030} 1060}
1031 1061
@@ -1150,6 +1180,7 @@ static int hva_open(struct file *file)
1150 if (ret) { 1180 if (ret) {
1151 dev_err(dev, "%s [x:x] failed to setup controls\n", 1181 dev_err(dev, "%s [x:x] failed to setup controls\n",
1152 HVA_PREFIX); 1182 HVA_PREFIX);
1183 ctx->sys_errors++;
1153 goto err_fh; 1184 goto err_fh;
1154 } 1185 }
1155 ctx->fh.ctrl_handler = &ctx->ctrl_handler; 1186 ctx->fh.ctrl_handler = &ctx->ctrl_handler;
@@ -1162,6 +1193,7 @@ static int hva_open(struct file *file)
1162 ret = PTR_ERR(ctx->fh.m2m_ctx); 1193 ret = PTR_ERR(ctx->fh.m2m_ctx);
1163 dev_err(dev, "%s failed to initialize m2m context (%d)\n", 1194 dev_err(dev, "%s failed to initialize m2m context (%d)\n",
1164 HVA_PREFIX, ret); 1195 HVA_PREFIX, ret);
1196 ctx->sys_errors++;
1165 goto err_ctrls; 1197 goto err_ctrls;
1166 } 1198 }
1167 1199
@@ -1175,6 +1207,10 @@ static int hva_open(struct file *file)
1175 /* default parameters for frame and stream */ 1207 /* default parameters for frame and stream */
1176 set_default_params(ctx); 1208 set_default_params(ctx);
1177 1209
1210#ifdef CONFIG_VIDEO_STI_HVA_DEBUGFS
1211 hva_dbg_ctx_create(ctx);
1212#endif
1213
1178 dev_info(dev, "%s encoder instance created\n", ctx->name); 1214 dev_info(dev, "%s encoder instance created\n", ctx->name);
1179 1215
1180 return 0; 1216 return 0;
@@ -1206,6 +1242,9 @@ static int hva_release(struct file *file)
1206 hva->nb_of_instances--; 1242 hva->nb_of_instances--;
1207 } 1243 }
1208 1244
1245 /* trace a summary of instance before closing (debug purpose) */
1246 hva_dbg_summary(ctx);
1247
1209 v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); 1248 v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
1210 1249
1211 v4l2_ctrl_handler_free(&ctx->ctrl_handler); 1250 v4l2_ctrl_handler_free(&ctx->ctrl_handler);
@@ -1213,6 +1252,10 @@ static int hva_release(struct file *file)
1213 v4l2_fh_del(&ctx->fh); 1252 v4l2_fh_del(&ctx->fh);
1214 v4l2_fh_exit(&ctx->fh); 1253 v4l2_fh_exit(&ctx->fh);
1215 1254
1255#ifdef CONFIG_VIDEO_STI_HVA_DEBUGFS
1256 hva_dbg_ctx_remove(ctx);
1257#endif
1258
1216 dev_info(dev, "%s encoder instance released\n", ctx->name); 1259 dev_info(dev, "%s encoder instance released\n", ctx->name);
1217 1260
1218 kfree(ctx); 1261 kfree(ctx);
@@ -1337,6 +1380,10 @@ static int hva_probe(struct platform_device *pdev)
1337 goto err_hw; 1380 goto err_hw;
1338 } 1381 }
1339 1382
1383#ifdef CONFIG_VIDEO_STI_HVA_DEBUGFS
1384 hva_debugfs_create(hva);
1385#endif
1386
1340 hva->work_queue = create_workqueue(HVA_NAME); 1387 hva->work_queue = create_workqueue(HVA_NAME);
1341 if (!hva->work_queue) { 1388 if (!hva->work_queue) {
1342 dev_err(dev, "%s %s failed to allocate work queue\n", 1389 dev_err(dev, "%s %s failed to allocate work queue\n",
@@ -1358,6 +1405,9 @@ static int hva_probe(struct platform_device *pdev)
1358err_work_queue: 1405err_work_queue:
1359 destroy_workqueue(hva->work_queue); 1406 destroy_workqueue(hva->work_queue);
1360err_v4l2: 1407err_v4l2:
1408#ifdef CONFIG_VIDEO_STI_HVA_DEBUGFS
1409 hva_debugfs_remove(hva);
1410#endif
1361 v4l2_device_unregister(&hva->v4l2_dev); 1411 v4l2_device_unregister(&hva->v4l2_dev);
1362err_hw: 1412err_hw:
1363 hva_hw_remove(hva); 1413 hva_hw_remove(hva);
@@ -1376,6 +1426,10 @@ static int hva_remove(struct platform_device *pdev)
1376 1426
1377 hva_hw_remove(hva); 1427 hva_hw_remove(hva);
1378 1428
1429#ifdef CONFIG_VIDEO_STI_HVA_DEBUGFS
1430 hva_debugfs_remove(hva);
1431#endif
1432
1379 v4l2_device_unregister(&hva->v4l2_dev); 1433 v4l2_device_unregister(&hva->v4l2_dev);
1380 1434
1381 dev_info(dev, "%s %s removed\n", HVA_PREFIX, pdev->name); 1435 dev_info(dev, "%s %s removed\n", HVA_PREFIX, pdev->name);
diff --git a/drivers/media/platform/sti/hva/hva.h b/drivers/media/platform/sti/hva/hva.h
index caa580825541..0d749b257a21 100644
--- a/drivers/media/platform/sti/hva/hva.h
+++ b/drivers/media/platform/sti/hva/hva.h
@@ -21,7 +21,8 @@
21 21
22#define ctx_to_hdev(c) (c->hva_dev) 22#define ctx_to_hdev(c) (c->hva_dev)
23 23
24#define HVA_PREFIX "[---:----]" 24#define HVA_NAME "st-hva"
25#define HVA_PREFIX "[---:----]"
25 26
26extern const struct hva_enc nv12h264enc; 27extern const struct hva_enc nv12h264enc;
27extern const struct hva_enc nv21h264enc; 28extern const struct hva_enc nv21h264enc;
@@ -153,6 +154,61 @@ struct hva_stream {
153#define to_hva_stream(vb) \ 154#define to_hva_stream(vb) \
154 container_of(vb, struct hva_stream, vbuf) 155 container_of(vb, struct hva_stream, vbuf)
155 156
157#ifdef CONFIG_VIDEO_STI_HVA_DEBUGFS
158/**
159 * struct hva_ctx_dbg - instance context debug info
160 *
161 * @debugfs_entry: debugfs entry
162 * @is_valid_period: true if the sequence is valid for performance
163 * @begin: start time of last HW task
164 * @total_duration: total HW processing durations in 0.1ms
165 * @cnt_duration: number of HW processings
166 * @min_duration: minimum HW processing duration in 0.1ms
167 * @max_duration: maximum HW processing duration in 0.1ms
168 * @avg_duration: average HW processing duration in 0.1ms
169 * @max_fps: maximum frames encoded per second (in 0.1Hz)
170 * @total_period: total encoding periods in 0.1ms
171 * @cnt_period: number of periods
172 * @min_period: minimum encoding period in 0.1ms
173 * @max_period: maximum encoding period in 0.1ms
174 * @avg_period: average encoding period in 0.1ms
175 * @total_stream_size: total number of encoded bytes
176 * @avg_fps: average frames encoded per second (in 0.1Hz)
177 * @window_duration: duration of the sampling window in 0.1ms
178 * @cnt_window: number of samples in the window
179 * @window_stream_size: number of encoded bytes upon the sampling window
180 * @last_bitrate: bitrate upon the last sampling window
181 * @min_bitrate: minimum bitrate in kbps
182 * @max_bitrate: maximum bitrate in kbps
183 * @avg_bitrate: average bitrate in kbps
184 */
185struct hva_ctx_dbg {
186 struct dentry *debugfs_entry;
187 bool is_valid_period;
188 ktime_t begin;
189 u32 total_duration;
190 u32 cnt_duration;
191 u32 min_duration;
192 u32 max_duration;
193 u32 avg_duration;
194 u32 max_fps;
195 u32 total_period;
196 u32 cnt_period;
197 u32 min_period;
198 u32 max_period;
199 u32 avg_period;
200 u32 total_stream_size;
201 u32 avg_fps;
202 u32 window_duration;
203 u32 cnt_window;
204 u32 window_stream_size;
205 u32 last_bitrate;
206 u32 min_bitrate;
207 u32 max_bitrate;
208 u32 avg_bitrate;
209};
210#endif
211
156struct hva_dev; 212struct hva_dev;
157struct hva_enc; 213struct hva_enc;
158 214
@@ -182,6 +238,11 @@ struct hva_enc;
182 * @priv: private codec data for this instance, allocated 238 * @priv: private codec data for this instance, allocated
183 * by encoder @open time 239 * by encoder @open time
184 * @hw_err: true if hardware error detected 240 * @hw_err: true if hardware error detected
241 * @encoded_frames: number of encoded frames
242 * @sys_errors: number of system errors (memory, resource, pm...)
243 * @encode_errors: number of encoding errors (hw/driver errors)
244 * @frame_errors: number of frame errors (format, size, header...)
245 * @dbg: context debug info
185 */ 246 */
186struct hva_ctx { 247struct hva_ctx {
187 struct hva_dev *hva_dev; 248 struct hva_dev *hva_dev;
@@ -207,11 +268,31 @@ struct hva_ctx {
207 struct hva_enc *enc; 268 struct hva_enc *enc;
208 void *priv; 269 void *priv;
209 bool hw_err; 270 bool hw_err;
271 u32 encoded_frames;
272 u32 sys_errors;
273 u32 encode_errors;
274 u32 frame_errors;
275#ifdef CONFIG_VIDEO_STI_HVA_DEBUGFS
276 struct hva_ctx_dbg dbg;
277#endif
210}; 278};
211 279
212#define HVA_FLAG_STREAMINFO 0x0001 280#define HVA_FLAG_STREAMINFO 0x0001
213#define HVA_FLAG_FRAMEINFO 0x0002 281#define HVA_FLAG_FRAMEINFO 0x0002
214 282
283#ifdef CONFIG_VIDEO_STI_HVA_DEBUGFS
284/**
285 * struct hva_dev_dbg - device debug info
286 *
287 * @debugfs_entry: debugfs entry
288 * @last_ctx: debug information about last running instance context
289 */
290struct hva_dev_dbg {
291 struct dentry *debugfs_entry;
292 struct hva_ctx last_ctx;
293};
294#endif
295
215#define HVA_MAX_INSTANCES 16 296#define HVA_MAX_INSTANCES 16
216#define HVA_MAX_ENCODERS 10 297#define HVA_MAX_ENCODERS 10
217#define HVA_MAX_FORMATS HVA_MAX_ENCODERS 298#define HVA_MAX_FORMATS HVA_MAX_ENCODERS
@@ -250,6 +331,7 @@ struct hva_ctx {
250 * @lmi_err_reg: local memory interface error register value 331 * @lmi_err_reg: local memory interface error register value
251 * @emi_err_reg: external memory interface error register value 332 * @emi_err_reg: external memory interface error register value
252 * @hec_mif_err_reg: HEC memory interface error register value 333 * @hec_mif_err_reg: HEC memory interface error register value
334 * @dbg: device debug info
253 */ 335 */
254struct hva_dev { 336struct hva_dev {
255 struct v4l2_device v4l2_dev; 337 struct v4l2_device v4l2_dev;
@@ -284,6 +366,9 @@ struct hva_dev {
284 u32 lmi_err_reg; 366 u32 lmi_err_reg;
285 u32 emi_err_reg; 367 u32 emi_err_reg;
286 u32 hec_mif_err_reg; 368 u32 hec_mif_err_reg;
369#ifdef CONFIG_VIDEO_STI_HVA_DEBUGFS
370 struct hva_dev_dbg dbg;
371#endif
287}; 372};
288 373
289/** 374/**
@@ -312,4 +397,13 @@ struct hva_enc {
312 struct hva_stream *stream); 397 struct hva_stream *stream);
313}; 398};
314 399
400#ifdef CONFIG_VIDEO_STI_HVA_DEBUGFS
401void hva_debugfs_create(struct hva_dev *hva);
402void hva_debugfs_remove(struct hva_dev *hva);
403void hva_dbg_ctx_create(struct hva_ctx *ctx);
404void hva_dbg_ctx_remove(struct hva_ctx *ctx);
405void hva_dbg_perf_begin(struct hva_ctx *ctx);
406void hva_dbg_perf_end(struct hva_ctx *ctx, struct hva_stream *stream);
407#endif
408
315#endif /* HVA_H */ 409#endif /* HVA_H */
diff --git a/drivers/media/platform/ti-vpe/vpdma.c b/drivers/media/platform/ti-vpe/vpdma.c
index 13bfd7184160..23472e3784ff 100644
--- a/drivers/media/platform/ti-vpe/vpdma.c
+++ b/drivers/media/platform/ti-vpe/vpdma.c
@@ -453,7 +453,7 @@ int vpdma_list_cleanup(struct vpdma_data *vpdma, int list_num,
453 if (ret) 453 if (ret)
454 return ret; 454 return ret;
455 455
456 while (vpdma_list_busy(vpdma, list_num) && timeout--) 456 while (vpdma_list_busy(vpdma, list_num) && --timeout)
457 ; 457 ;
458 458
459 if (timeout == 0) { 459 if (timeout == 0) {
diff --git a/drivers/media/platform/vim2m.c b/drivers/media/platform/vim2m.c
index a98f679bd88d..970b9b6dab25 100644
--- a/drivers/media/platform/vim2m.c
+++ b/drivers/media/platform/vim2m.c
@@ -907,6 +907,7 @@ static int vim2m_open(struct file *file)
907 if (hdl->error) { 907 if (hdl->error) {
908 rc = hdl->error; 908 rc = hdl->error;
909 v4l2_ctrl_handler_free(hdl); 909 v4l2_ctrl_handler_free(hdl);
910 kfree(ctx);
910 goto open_unlock; 911 goto open_unlock;
911 } 912 }
912 ctx->fh.ctrl_handler = hdl; 913 ctx->fh.ctrl_handler = hdl;
@@ -928,6 +929,7 @@ static int vim2m_open(struct file *file)
928 rc = PTR_ERR(ctx->fh.m2m_ctx); 929 rc = PTR_ERR(ctx->fh.m2m_ctx);
929 930
930 v4l2_ctrl_handler_free(hdl); 931 v4l2_ctrl_handler_free(hdl);
932 v4l2_fh_exit(&ctx->fh);
931 kfree(ctx); 933 kfree(ctx);
932 goto open_unlock; 934 goto open_unlock;
933 } 935 }
diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c b/drivers/media/platform/vivid/vivid-vid-cap.c
index c52dd8787794..a18e6fec219b 100644
--- a/drivers/media/platform/vivid/vivid-vid-cap.c
+++ b/drivers/media/platform/vivid/vivid-vid-cap.c
@@ -63,7 +63,7 @@ static const struct vivid_fmt formats_ovl[] = {
63}; 63};
64 64
65/* The number of discrete webcam framesizes */ 65/* The number of discrete webcam framesizes */
66#define VIVID_WEBCAM_SIZES 4 66#define VIVID_WEBCAM_SIZES 5
67/* The number of discrete webcam frameintervals */ 67/* The number of discrete webcam frameintervals */
68#define VIVID_WEBCAM_IVALS (VIVID_WEBCAM_SIZES * 2) 68#define VIVID_WEBCAM_IVALS (VIVID_WEBCAM_SIZES * 2)
69 69
@@ -73,6 +73,7 @@ static const struct v4l2_frmsize_discrete webcam_sizes[VIVID_WEBCAM_SIZES] = {
73 { 640, 360 }, 73 { 640, 360 },
74 { 1280, 720 }, 74 { 1280, 720 },
75 { 1920, 1080 }, 75 { 1920, 1080 },
76 { 3840, 2160 },
76}; 77};
77 78
78/* 79/*
@@ -80,7 +81,9 @@ static const struct v4l2_frmsize_discrete webcam_sizes[VIVID_WEBCAM_SIZES] = {
80 * elements in this array as there are in webcam_sizes. 81 * elements in this array as there are in webcam_sizes.
81 */ 82 */
82static const struct v4l2_fract webcam_intervals[VIVID_WEBCAM_IVALS] = { 83static const struct v4l2_fract webcam_intervals[VIVID_WEBCAM_IVALS] = {
84 { 1, 1 },
83 { 1, 2 }, 85 { 1, 2 },
86 { 1, 4 },
84 { 1, 5 }, 87 { 1, 5 },
85 { 1, 10 }, 88 { 1, 10 },
86 { 1, 15 }, 89 { 1, 15 },
diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c
index cd209dccff1b..b4b583f7137a 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.c
+++ b/drivers/media/platform/vsp1/vsp1_drm.c
@@ -90,7 +90,7 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int width,
90 if (ret == -ETIMEDOUT) 90 if (ret == -ETIMEDOUT)
91 dev_err(vsp1->dev, "DRM pipeline stop timeout\n"); 91 dev_err(vsp1->dev, "DRM pipeline stop timeout\n");
92 92
93 media_entity_pipeline_stop(&pipe->output->entity.subdev.entity); 93 media_pipeline_stop(&pipe->output->entity.subdev.entity);
94 94
95 for (i = 0; i < bru->entity.source_pad; ++i) { 95 for (i = 0; i < bru->entity.source_pad; ++i) {
96 vsp1->drm->inputs[i].enabled = false; 96 vsp1->drm->inputs[i].enabled = false;
@@ -196,7 +196,7 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int width,
196 if (ret < 0) 196 if (ret < 0)
197 return ret; 197 return ret;
198 198
199 ret = media_entity_pipeline_start(&pipe->output->entity.subdev.entity, 199 ret = media_pipeline_start(&pipe->output->entity.subdev.entity,
200 &pipe->pipe); 200 &pipe->pipe);
201 if (ret < 0) { 201 if (ret < 0) {
202 dev_dbg(vsp1->dev, "%s: pipeline start failed\n", __func__); 202 dev_dbg(vsp1->dev, "%s: pipeline start failed\n", __func__);
diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c
index 41e8b096dab8..3eaadbf7a876 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -548,20 +548,20 @@ out:
548static int vsp1_video_pipeline_build(struct vsp1_pipeline *pipe, 548static int vsp1_video_pipeline_build(struct vsp1_pipeline *pipe,
549 struct vsp1_video *video) 549 struct vsp1_video *video)
550{ 550{
551 struct media_entity_graph graph; 551 struct media_graph graph;
552 struct media_entity *entity = &video->video.entity; 552 struct media_entity *entity = &video->video.entity;
553 struct media_device *mdev = entity->graph_obj.mdev; 553 struct media_device *mdev = entity->graph_obj.mdev;
554 unsigned int i; 554 unsigned int i;
555 int ret; 555 int ret;
556 556
557 /* Walk the graph to locate the entities and video nodes. */ 557 /* Walk the graph to locate the entities and video nodes. */
558 ret = media_entity_graph_walk_init(&graph, mdev); 558 ret = media_graph_walk_init(&graph, mdev);
559 if (ret) 559 if (ret)
560 return ret; 560 return ret;
561 561
562 media_entity_graph_walk_start(&graph, entity); 562 media_graph_walk_start(&graph, entity);
563 563
564 while ((entity = media_entity_graph_walk_next(&graph))) { 564 while ((entity = media_graph_walk_next(&graph))) {
565 struct v4l2_subdev *subdev; 565 struct v4l2_subdev *subdev;
566 struct vsp1_rwpf *rwpf; 566 struct vsp1_rwpf *rwpf;
567 struct vsp1_entity *e; 567 struct vsp1_entity *e;
@@ -590,7 +590,7 @@ static int vsp1_video_pipeline_build(struct vsp1_pipeline *pipe,
590 } 590 }
591 } 591 }
592 592
593 media_entity_graph_walk_cleanup(&graph); 593 media_graph_walk_cleanup(&graph);
594 594
595 /* We need one output and at least one input. */ 595 /* We need one output and at least one input. */
596 if (pipe->num_inputs == 0 || !pipe->output) 596 if (pipe->num_inputs == 0 || !pipe->output)
@@ -848,7 +848,7 @@ static void vsp1_video_stop_streaming(struct vb2_queue *vq)
848 } 848 }
849 mutex_unlock(&pipe->lock); 849 mutex_unlock(&pipe->lock);
850 850
851 media_entity_pipeline_stop(&video->video.entity); 851 media_pipeline_stop(&video->video.entity);
852 vsp1_video_pipeline_put(pipe); 852 vsp1_video_pipeline_put(pipe);
853 853
854 /* Remove all buffers from the IRQ queue. */ 854 /* Remove all buffers from the IRQ queue. */
@@ -980,7 +980,7 @@ vsp1_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
980 return PTR_ERR(pipe); 980 return PTR_ERR(pipe);
981 } 981 }
982 982
983 ret = __media_entity_pipeline_start(&video->video.entity, &pipe->pipe); 983 ret = __media_pipeline_start(&video->video.entity, &pipe->pipe);
984 if (ret < 0) { 984 if (ret < 0) {
985 mutex_unlock(&mdev->graph_mutex); 985 mutex_unlock(&mdev->graph_mutex);
986 goto err_pipe; 986 goto err_pipe;
@@ -1003,7 +1003,7 @@ vsp1_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
1003 return 0; 1003 return 0;
1004 1004
1005err_stop: 1005err_stop:
1006 media_entity_pipeline_stop(&video->video.entity); 1006 media_pipeline_stop(&video->video.entity);
1007err_pipe: 1007err_pipe:
1008 vsp1_video_pipeline_put(pipe); 1008 vsp1_video_pipeline_put(pipe);
1009 return ret; 1009 return ret;
@@ -1021,6 +1021,7 @@ static const struct v4l2_ioctl_ops vsp1_video_ioctl_ops = {
1021 .vidioc_querybuf = vb2_ioctl_querybuf, 1021 .vidioc_querybuf = vb2_ioctl_querybuf,
1022 .vidioc_qbuf = vb2_ioctl_qbuf, 1022 .vidioc_qbuf = vb2_ioctl_qbuf,
1023 .vidioc_dqbuf = vb2_ioctl_dqbuf, 1023 .vidioc_dqbuf = vb2_ioctl_dqbuf,
1024 .vidioc_expbuf = vb2_ioctl_expbuf,
1024 .vidioc_create_bufs = vb2_ioctl_create_bufs, 1025 .vidioc_create_bufs = vb2_ioctl_create_bufs,
1025 .vidioc_prepare_buf = vb2_ioctl_prepare_buf, 1026 .vidioc_prepare_buf = vb2_ioctl_prepare_buf,
1026 .vidioc_streamon = vsp1_video_streamon, 1027 .vidioc_streamon = vsp1_video_streamon,
diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c
index 1d5836c3fb7a..522cdfdd3345 100644
--- a/drivers/media/platform/xilinx/xilinx-dma.c
+++ b/drivers/media/platform/xilinx/xilinx-dma.c
@@ -177,7 +177,7 @@ done:
177static int xvip_pipeline_validate(struct xvip_pipeline *pipe, 177static int xvip_pipeline_validate(struct xvip_pipeline *pipe,
178 struct xvip_dma *start) 178 struct xvip_dma *start)
179{ 179{
180 struct media_entity_graph graph; 180 struct media_graph graph;
181 struct media_entity *entity = &start->video.entity; 181 struct media_entity *entity = &start->video.entity;
182 struct media_device *mdev = entity->graph_obj.mdev; 182 struct media_device *mdev = entity->graph_obj.mdev;
183 unsigned int num_inputs = 0; 183 unsigned int num_inputs = 0;
@@ -187,15 +187,15 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe,
187 mutex_lock(&mdev->graph_mutex); 187 mutex_lock(&mdev->graph_mutex);
188 188
189 /* Walk the graph to locate the video nodes. */ 189 /* Walk the graph to locate the video nodes. */
190 ret = media_entity_graph_walk_init(&graph, entity->graph_obj.mdev); 190 ret = media_graph_walk_init(&graph, mdev);
191 if (ret) { 191 if (ret) {
192 mutex_unlock(&mdev->graph_mutex); 192 mutex_unlock(&mdev->graph_mutex);
193 return ret; 193 return ret;
194 } 194 }
195 195
196 media_entity_graph_walk_start(&graph, entity); 196 media_graph_walk_start(&graph, entity);
197 197
198 while ((entity = media_entity_graph_walk_next(&graph))) { 198 while ((entity = media_graph_walk_next(&graph))) {
199 struct xvip_dma *dma; 199 struct xvip_dma *dma;
200 200
201 if (entity->function != MEDIA_ENT_F_IO_V4L) 201 if (entity->function != MEDIA_ENT_F_IO_V4L)
@@ -213,7 +213,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe,
213 213
214 mutex_unlock(&mdev->graph_mutex); 214 mutex_unlock(&mdev->graph_mutex);
215 215
216 media_entity_graph_walk_cleanup(&graph); 216 media_graph_walk_cleanup(&graph);
217 217
218 /* We need exactly one output and zero or one input. */ 218 /* We need exactly one output and zero or one input. */
219 if (num_outputs != 1 || num_inputs > 1) 219 if (num_outputs != 1 || num_inputs > 1)
@@ -409,7 +409,7 @@ static int xvip_dma_start_streaming(struct vb2_queue *vq, unsigned int count)
409 pipe = dma->video.entity.pipe 409 pipe = dma->video.entity.pipe
410 ? to_xvip_pipeline(&dma->video.entity) : &dma->pipe; 410 ? to_xvip_pipeline(&dma->video.entity) : &dma->pipe;
411 411
412 ret = media_entity_pipeline_start(&dma->video.entity, &pipe->pipe); 412 ret = media_pipeline_start(&dma->video.entity, &pipe->pipe);
413 if (ret < 0) 413 if (ret < 0)
414 goto error; 414 goto error;
415 415
@@ -435,7 +435,7 @@ static int xvip_dma_start_streaming(struct vb2_queue *vq, unsigned int count)
435 return 0; 435 return 0;
436 436
437error_stop: 437error_stop:
438 media_entity_pipeline_stop(&dma->video.entity); 438 media_pipeline_stop(&dma->video.entity);
439 439
440error: 440error:
441 /* Give back all queued buffers to videobuf2. */ 441 /* Give back all queued buffers to videobuf2. */
@@ -463,7 +463,7 @@ static void xvip_dma_stop_streaming(struct vb2_queue *vq)
463 463
464 /* Cleanup the pipeline and mark it as being stopped. */ 464 /* Cleanup the pipeline and mark it as being stopped. */
465 xvip_pipeline_cleanup(pipe); 465 xvip_pipeline_cleanup(pipe);
466 media_entity_pipeline_stop(&dma->video.entity); 466 media_pipeline_stop(&dma->video.entity);
467 467
468 /* Give back all queued buffers to videobuf2. */ 468 /* Give back all queued buffers to videobuf2. */
469 spin_lock_irq(&dma->queued_lock); 469 spin_lock_irq(&dma->queued_lock);
diff --git a/drivers/media/platform/xilinx/xilinx-tpg.c b/drivers/media/platform/xilinx/xilinx-tpg.c
index 2ec1f6c4b274..9c49d1d10bee 100644
--- a/drivers/media/platform/xilinx/xilinx-tpg.c
+++ b/drivers/media/platform/xilinx/xilinx-tpg.c
@@ -460,21 +460,21 @@ static const struct v4l2_ctrl_ops xtpg_ctrl_ops = {
460 .s_ctrl = xtpg_s_ctrl, 460 .s_ctrl = xtpg_s_ctrl,
461}; 461};
462 462
463static struct v4l2_subdev_core_ops xtpg_core_ops = { 463static const struct v4l2_subdev_core_ops xtpg_core_ops = {
464}; 464};
465 465
466static struct v4l2_subdev_video_ops xtpg_video_ops = { 466static const struct v4l2_subdev_video_ops xtpg_video_ops = {
467 .s_stream = xtpg_s_stream, 467 .s_stream = xtpg_s_stream,
468}; 468};
469 469
470static struct v4l2_subdev_pad_ops xtpg_pad_ops = { 470static const struct v4l2_subdev_pad_ops xtpg_pad_ops = {
471 .enum_mbus_code = xvip_enum_mbus_code, 471 .enum_mbus_code = xvip_enum_mbus_code,
472 .enum_frame_size = xtpg_enum_frame_size, 472 .enum_frame_size = xtpg_enum_frame_size,
473 .get_fmt = xtpg_get_format, 473 .get_fmt = xtpg_get_format,
474 .set_fmt = xtpg_set_format, 474 .set_fmt = xtpg_set_format,
475}; 475};
476 476
477static struct v4l2_subdev_ops xtpg_ops = { 477static const struct v4l2_subdev_ops xtpg_ops = {
478 .core = &xtpg_core_ops, 478 .core = &xtpg_core_ops,
479 .video = &xtpg_video_ops, 479 .video = &xtpg_video_ops,
480 .pad = &xtpg_pad_ops, 480 .pad = &xtpg_pad_ops,
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c
index 2262b8139ca1..53bc8c010035 100644
--- a/drivers/media/radio/dsbr100.c
+++ b/drivers/media/radio/dsbr100.c
@@ -28,10 +28,6 @@
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details. 30 * GNU General Public License for more details.
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35*/ 31*/
36 32
37#include <linux/kernel.h> 33#include <linux/kernel.h>
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
index 82affaedf067..cbaf850f4791 100644
--- a/drivers/media/radio/radio-cadet.c
+++ b/drivers/media/radio/radio-cadet.c
@@ -309,9 +309,7 @@ static void cadet_handler(unsigned long data)
309 /* 309 /*
310 * Clean up and exit 310 * Clean up and exit
311 */ 311 */
312 init_timer(&dev->readtimer); 312 setup_timer(&dev->readtimer, cadet_handler, data);
313 dev->readtimer.function = cadet_handler;
314 dev->readtimer.data = data;
315 dev->readtimer.expires = jiffies + msecs_to_jiffies(50); 313 dev->readtimer.expires = jiffies + msecs_to_jiffies(50);
316 add_timer(&dev->readtimer); 314 add_timer(&dev->readtimer);
317} 315}
@@ -320,9 +318,7 @@ static void cadet_start_rds(struct cadet *dev)
320{ 318{
321 dev->rdsstat = 1; 319 dev->rdsstat = 1;
322 outb(0x80, dev->io); /* Select RDS fifo */ 320 outb(0x80, dev->io); /* Select RDS fifo */
323 init_timer(&dev->readtimer); 321 setup_timer(&dev->readtimer, cadet_handler, (unsigned long)dev);
324 dev->readtimer.function = cadet_handler;
325 dev->readtimer.data = (unsigned long)dev;
326 dev->readtimer.expires = jiffies + msecs_to_jiffies(50); 322 dev->readtimer.expires = jiffies + msecs_to_jiffies(50);
327 add_timer(&dev->readtimer); 323 add_timer(&dev->readtimer);
328} 324}
diff --git a/drivers/media/radio/radio-isa.c b/drivers/media/radio/radio-isa.c
index c309ee45a08e..7312e469e850 100644
--- a/drivers/media/radio/radio-isa.c
+++ b/drivers/media/radio/radio-isa.c
@@ -13,11 +13,6 @@
13 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details. 15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 */ 16 */
22 17
23#include <linux/module.h> 18#include <linux/module.h>
diff --git a/drivers/media/radio/radio-isa.h b/drivers/media/radio/radio-isa.h
index ba4c01f1bd0c..bab414919cf0 100644
--- a/drivers/media/radio/radio-isa.h
+++ b/drivers/media/radio/radio-isa.h
@@ -13,11 +13,6 @@
13 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details. 15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 */ 16 */
22 17
23#ifndef _RADIO_ISA_H_ 18#ifndef _RADIO_ISA_H_
diff --git a/drivers/media/radio/radio-keene.c b/drivers/media/radio/radio-keene.c
index 0c5d2db3b828..53a7c2e87762 100644
--- a/drivers/media/radio/radio-keene.c
+++ b/drivers/media/radio/radio-keene.c
@@ -10,10 +10,6 @@
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */ 13 */
18 14
19/* kernel includes */ 15/* kernel includes */
diff --git a/drivers/media/radio/radio-ma901.c b/drivers/media/radio/radio-ma901.c
index b3000ef85ee7..c2010a905a47 100644
--- a/drivers/media/radio/radio-ma901.c
+++ b/drivers/media/radio/radio-ma901.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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 */ 17 */
22 18
23#include <linux/kernel.h> 19#include <linux/kernel.h>
diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c
index c2927fd12615..95c12532e87a 100644
--- a/drivers/media/radio/radio-mr800.c
+++ b/drivers/media/radio/radio-mr800.c
@@ -15,10 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 18 */
23 19
24/* 20/*
diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
index 85667a95f003..23971f5502a8 100644
--- a/drivers/media/radio/radio-shark.c
+++ b/drivers/media/radio/radio-shark.c
@@ -19,10 +19,6 @@
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26*/ 22*/
27 23
28#include <linux/init.h> 24#include <linux/init.h>
diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
index 0e65a85d52c6..b50638ec5f09 100644
--- a/drivers/media/radio/radio-shark2.c
+++ b/drivers/media/radio/radio-shark2.c
@@ -19,10 +19,6 @@
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 */ 22 */
27 23
28#include <linux/init.h> 24#include <linux/init.h>
diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c
index a1930b300c06..9db8331a0c75 100644
--- a/drivers/media/radio/radio-tea5764.c
+++ b/drivers/media/radio/radio-tea5764.c
@@ -19,10 +19,6 @@
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * History: 22 * History:
27 * 2008-12-06 Fabio Belavenuto <belavenuto@gmail.com> 23 * 2008-12-06 Fabio Belavenuto <belavenuto@gmail.com>
28 * initial code 24 * initial code
diff --git a/drivers/media/radio/radio-tea5777.c b/drivers/media/radio/radio-tea5777.c
index 83fe7ab358df..04ed1a5d1177 100644
--- a/drivers/media/radio/radio-tea5777.c
+++ b/drivers/media/radio/radio-tea5777.c
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */ 20 */
25 21
26#include <linux/delay.h> 22#include <linux/delay.h>
diff --git a/drivers/media/radio/radio-tea5777.h b/drivers/media/radio/radio-tea5777.h
index 4bd942526a1b..6b5af3c8457b 100644
--- a/drivers/media/radio/radio-tea5777.h
+++ b/drivers/media/radio/radio-tea5777.h
@@ -21,10 +21,6 @@
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details. 22 * GNU General Public License for more details.
23 * 23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 *
28 */ 24 */
29 25
30#include <linux/videodev2.h> 26#include <linux/videodev2.h>
diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c
index a82eb9678d6c..fc4d9a73ab17 100644
--- a/drivers/media/radio/radio-timb.c
+++ b/drivers/media/radio/radio-timb.c
@@ -10,10 +10,6 @@
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 13 */
18 14
19#include <linux/io.h> 15#include <linux/io.h>
diff --git a/drivers/media/radio/radio-wl1273.c b/drivers/media/radio/radio-wl1273.c
index 9ce4b12299b4..7240223dc15a 100644
--- a/drivers/media/radio/radio-wl1273.c
+++ b/drivers/media/radio/radio-wl1273.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 15 */
20 16
21#include <linux/delay.h> 17#include <linux/delay.h>
diff --git a/drivers/media/radio/saa7706h.c b/drivers/media/radio/saa7706h.c
index ba8e357ba0a2..bf9eced906db 100644
--- a/drivers/media/radio/saa7706h.c
+++ b/drivers/media/radio/saa7706h.c
@@ -10,10 +10,6 @@
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 13 */
18 14
19#include <linux/module.h> 15#include <linux/module.h>
diff --git a/drivers/media/radio/si470x/radio-si470x-common.c b/drivers/media/radio/si470x/radio-si470x-common.c
index 1d827adab7eb..cd76facc22f5 100644
--- a/drivers/media/radio/si470x/radio-si470x-common.c
+++ b/drivers/media/radio/si470x/radio-si470x-common.c
@@ -15,10 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 18 */
23 19
24 20
diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c b/drivers/media/radio/si470x/radio-si470x-i2c.c
index 9b81969d76b5..b3034f80163f 100644
--- a/drivers/media/radio/si470x/radio-si470x-i2c.c
+++ b/drivers/media/radio/si470x/radio-si470x-i2c.c
@@ -15,10 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 18 */
23 19
24 20
diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c b/drivers/media/radio/si470x/radio-si470x-usb.c
index 1add136d37a3..571f29a34bf8 100644
--- a/drivers/media/radio/si470x/radio-si470x-usb.c
+++ b/drivers/media/radio/si470x/radio-si470x-usb.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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 */ 17 */
22 18
23 19
diff --git a/drivers/media/radio/si470x/radio-si470x.h b/drivers/media/radio/si470x/radio-si470x.h
index 6c0ca900702e..7d2defd9d399 100644
--- a/drivers/media/radio/si470x/radio-si470x.h
+++ b/drivers/media/radio/si470x/radio-si470x.h
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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 */ 17 */
22 18
23 19
diff --git a/drivers/media/radio/si4713/radio-platform-si4713.c b/drivers/media/radio/si4713/radio-platform-si4713.c
index 6c7597383ca2..6f93ef1249a6 100644
--- a/drivers/media/radio/si4713/radio-platform-si4713.c
+++ b/drivers/media/radio/si4713/radio-platform-si4713.c
@@ -15,10 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 18 */
23 19
24#include <linux/kernel.h> 20#include <linux/kernel.h>
diff --git a/drivers/media/radio/si4713/si4713.c b/drivers/media/radio/si4713/si4713.c
index bc2a8b5442ae..60f026a58076 100644
--- a/drivers/media/radio/si4713/si4713.c
+++ b/drivers/media/radio/si4713/si4713.c
@@ -15,10 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 18 */
23 19
24#include <linux/completion.h> 20#include <linux/completion.h>
diff --git a/drivers/media/radio/tef6862.c b/drivers/media/radio/tef6862.c
index 9f879f0ec0ef..ed210f4c476a 100644
--- a/drivers/media/radio/tef6862.c
+++ b/drivers/media/radio/tef6862.c
@@ -10,10 +10,6 @@
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 13 */
18 14
19#include <linux/module.h> 15#include <linux/module.h>
diff --git a/drivers/media/radio/wl128x/fmdrv.h b/drivers/media/radio/wl128x/fmdrv.h
index dd203de5de95..1ff2eec4ed52 100644
--- a/drivers/media/radio/wl128x/fmdrv.h
+++ b/drivers/media/radio/wl128x/fmdrv.h
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */ 17 */
22 18
23#ifndef _FM_DRV_H 19#ifndef _FM_DRV_H
diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
index 4be07656fbc0..74a1b3ecb30a 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -26,10 +26,6 @@
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details. 27 * GNU General Public License for more details.
28 * 28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 *
33 */ 29 */
34 30
35#include <linux/module.h> 31#include <linux/module.h>
diff --git a/drivers/media/radio/wl128x/fmdrv_common.h b/drivers/media/radio/wl128x/fmdrv_common.h
index d9b9c6cf83b4..7f1514eb1c07 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.h
+++ b/drivers/media/radio/wl128x/fmdrv_common.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#ifndef _FMDRV_COMMON_H 18#ifndef _FMDRV_COMMON_H
diff --git a/drivers/media/radio/wl128x/fmdrv_rx.c b/drivers/media/radio/wl128x/fmdrv_rx.c
index e7455f82fadc..f689adc831ce 100644
--- a/drivers/media/radio/wl128x/fmdrv_rx.c
+++ b/drivers/media/radio/wl128x/fmdrv_rx.c
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU 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 */ 18 */
23 19
24#include "fmdrv.h" 20#include "fmdrv.h"
diff --git a/drivers/media/radio/wl128x/fmdrv_rx.h b/drivers/media/radio/wl128x/fmdrv_rx.h
index 23922188882f..f647c9bc796a 100644
--- a/drivers/media/radio/wl128x/fmdrv_rx.h
+++ b/drivers/media/radio/wl128x/fmdrv_rx.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#ifndef _FMDRV_RX_H 18#ifndef _FMDRV_RX_H
diff --git a/drivers/media/radio/wl128x/fmdrv_tx.c b/drivers/media/radio/wl128x/fmdrv_tx.c
index 839970b0f313..47ac19466ed2 100644
--- a/drivers/media/radio/wl128x/fmdrv_tx.c
+++ b/drivers/media/radio/wl128x/fmdrv_tx.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#include <linux/delay.h> 18#include <linux/delay.h>
diff --git a/drivers/media/radio/wl128x/fmdrv_tx.h b/drivers/media/radio/wl128x/fmdrv_tx.h
index 11ae2e4c2d03..95e4daf7ba43 100644
--- a/drivers/media/radio/wl128x/fmdrv_tx.h
+++ b/drivers/media/radio/wl128x/fmdrv_tx.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#ifndef _FMDRV_TX_H 18#ifndef _FMDRV_TX_H
diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c b/drivers/media/radio/wl128x/fmdrv_v4l2.c
index fb42f0fd0c1f..71423f45c05c 100644
--- a/drivers/media/radio/wl128x/fmdrv_v4l2.c
+++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c
@@ -22,10 +22,6 @@
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details. 23 * GNU General Public License for more details.
24 * 24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 */ 25 */
30 26
31#include <linux/export.h> 27#include <linux/export.h>
diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.h b/drivers/media/radio/wl128x/fmdrv_v4l2.h
index 0ba79d745e2f..9babb4ab2fad 100644
--- a/drivers/media/radio/wl128x/fmdrv_v4l2.h
+++ b/drivers/media/radio/wl128x/fmdrv_v4l2.h
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */ 17 */
22 18
23#ifndef _FMDRV_V4L2_H 19#ifndef _FMDRV_V4L2_H
diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
index 629e8ca15ab3..d1d3fd00ed89 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -235,6 +235,17 @@ config IR_MESON
235 To compile this driver as a module, choose M here: the 235 To compile this driver as a module, choose M here: the
236 module will be called meson-ir. 236 module will be called meson-ir.
237 237
238config IR_MTK
239 tristate "Mediatek IR remote receiver"
240 depends on RC_CORE
241 depends on ARCH_MEDIATEK || COMPILE_TEST
242 ---help---
243 Say Y if you want to use the IR remote receiver available
244 on Mediatek SoCs.
245
246 To compile this driver as a module, choose M here: the
247 module will be called mtk-cir.
248
238config IR_NUVOTON 249config IR_NUVOTON
239 tristate "Nuvoton w836x7hg Consumer Infrared Transceiver" 250 tristate "Nuvoton w836x7hg Consumer Infrared Transceiver"
240 depends on PNP 251 depends on PNP
@@ -261,6 +272,15 @@ config IR_REDRAT3
261 To compile this driver as a module, choose M here: the 272 To compile this driver as a module, choose M here: the
262 module will be called redrat3. 273 module will be called redrat3.
263 274
275config IR_SPI
276 tristate "SPI connected IR LED"
277 depends on SPI && LIRC
278 ---help---
279 Say Y if you want to use an IR LED connected through SPI bus.
280
281 To compile this driver as a module, choose M here: the module will be
282 called ir-spi.
283
264config IR_STREAMZAP 284config IR_STREAMZAP
265 tristate "Streamzap PC Remote IR Receiver" 285 tristate "Streamzap PC Remote IR Receiver"
266 depends on USB_ARCH_HAS_HCD 286 depends on USB_ARCH_HAS_HCD
@@ -336,7 +356,7 @@ config IR_TTUSBIR
336 356
337config IR_RX51 357config IR_RX51
338 tristate "Nokia N900 IR transmitter diode" 358 tristate "Nokia N900 IR transmitter diode"
339 depends on OMAP_DM_TIMER && PWM_OMAP_DMTIMER && ARCH_OMAP2PLUS && LIRC 359 depends on (OMAP_DM_TIMER && PWM_OMAP_DMTIMER && ARCH_OMAP2PLUS || COMPILE_TEST) && RC_CORE
340 ---help--- 360 ---help---
341 Say Y or M here if you want to enable support for the IR 361 Say Y or M here if you want to enable support for the IR
342 transmitter diode built in the Nokia N900 (RX51) device. 362 transmitter diode built in the Nokia N900 (RX51) device.
diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile
index 3a984ee301e2..679aa0af85cd 100644
--- a/drivers/media/rc/Makefile
+++ b/drivers/media/rc/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_IR_NUVOTON) += nuvoton-cir.o
27obj-$(CONFIG_IR_ENE) += ene_ir.o 27obj-$(CONFIG_IR_ENE) += ene_ir.o
28obj-$(CONFIG_IR_REDRAT3) += redrat3.o 28obj-$(CONFIG_IR_REDRAT3) += redrat3.o
29obj-$(CONFIG_IR_RX51) += ir-rx51.o 29obj-$(CONFIG_IR_RX51) += ir-rx51.o
30obj-$(CONFIG_IR_SPI) += ir-spi.o
30obj-$(CONFIG_IR_STREAMZAP) += streamzap.o 31obj-$(CONFIG_IR_STREAMZAP) += streamzap.o
31obj-$(CONFIG_IR_WINBOND_CIR) += winbond-cir.o 32obj-$(CONFIG_IR_WINBOND_CIR) += winbond-cir.o
32obj-$(CONFIG_RC_LOOPBACK) += rc-loopback.o 33obj-$(CONFIG_RC_LOOPBACK) += rc-loopback.o
@@ -38,3 +39,4 @@ obj-$(CONFIG_RC_ST) += st_rc.o
38obj-$(CONFIG_IR_SUNXI) += sunxi-cir.o 39obj-$(CONFIG_IR_SUNXI) += sunxi-cir.o
39obj-$(CONFIG_IR_IMG) += img-ir/ 40obj-$(CONFIG_IR_IMG) += img-ir/
40obj-$(CONFIG_IR_SERIAL) += serial_ir.o 41obj-$(CONFIG_IR_SERIAL) += serial_ir.o
42obj-$(CONFIG_IR_MTK) += mtk-cir.o
diff --git a/drivers/media/rc/ati_remote.c b/drivers/media/rc/ati_remote.c
index 0884b7dc0e71..9cf3e69de16a 100644
--- a/drivers/media/rc/ati_remote.c
+++ b/drivers/media/rc/ati_remote.c
@@ -36,10 +36,6 @@
36 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 36 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37 * GNU General Public License for more details. 37 * GNU General Public License for more details.
38 * 38 *
39 * You should have received a copy of the GNU General Public License
40 * along with this program; if not, write to the Free Software
41 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
42 *
43 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 39 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
44 * 40 *
45 * Hardware & software notes 41 * Hardware & software notes
@@ -764,7 +760,6 @@ static void ati_remote_rc_init(struct ati_remote *ati_remote)
764 struct rc_dev *rdev = ati_remote->rdev; 760 struct rc_dev *rdev = ati_remote->rdev;
765 761
766 rdev->priv = ati_remote; 762 rdev->priv = ati_remote;
767 rdev->driver_type = RC_DRIVER_SCANCODE;
768 rdev->allowed_protocols = RC_BIT_OTHER; 763 rdev->allowed_protocols = RC_BIT_OTHER;
769 rdev->driver_name = "ati_remote"; 764 rdev->driver_name = "ati_remote";
770 765
@@ -851,7 +846,7 @@ static int ati_remote_probe(struct usb_interface *interface,
851 } 846 }
852 847
853 ati_remote = kzalloc(sizeof (struct ati_remote), GFP_KERNEL); 848 ati_remote = kzalloc(sizeof (struct ati_remote), GFP_KERNEL);
854 rc_dev = rc_allocate_device(); 849 rc_dev = rc_allocate_device(RC_DRIVER_SCANCODE);
855 if (!ati_remote || !rc_dev) 850 if (!ati_remote || !rc_dev)
856 goto exit_free_dev_rdev; 851 goto exit_free_dev_rdev;
857 852
diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c
index bd5512e64aea..60da963f40dc 100644
--- a/drivers/media/rc/ene_ir.c
+++ b/drivers/media/rc/ene_ir.c
@@ -13,11 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details. 14 * General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 * USA
20 *
21 * Special thanks to: 16 * Special thanks to:
22 * Sami R. <maesesami@gmail.com> for lot of help in debugging and therefore 17 * Sami R. <maesesami@gmail.com> for lot of help in debugging and therefore
23 * bringing to life support for transmission & learning mode. 18 * bringing to life support for transmission & learning mode.
@@ -1012,7 +1007,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1012 1007
1013 /* allocate memory */ 1008 /* allocate memory */
1014 dev = kzalloc(sizeof(struct ene_device), GFP_KERNEL); 1009 dev = kzalloc(sizeof(struct ene_device), GFP_KERNEL);
1015 rdev = rc_allocate_device(); 1010 rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
1016 if (!dev || !rdev) 1011 if (!dev || !rdev)
1017 goto exit_free_dev_rdev; 1012 goto exit_free_dev_rdev;
1018 1013
@@ -1058,8 +1053,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1058 if (!dev->hw_learning_and_tx_capable) 1053 if (!dev->hw_learning_and_tx_capable)
1059 learning_mode_force = false; 1054 learning_mode_force = false;
1060 1055
1061 rdev->driver_type = RC_DRIVER_IR_RAW; 1056 rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
1062 rdev->allowed_protocols = RC_BIT_ALL;
1063 rdev->priv = dev; 1057 rdev->priv = dev;
1064 rdev->open = ene_open; 1058 rdev->open = ene_open;
1065 rdev->close = ene_close; 1059 rdev->close = ene_close;
diff --git a/drivers/media/rc/ene_ir.h b/drivers/media/rc/ene_ir.h
index a7911e3b9bc0..494646b2a284 100644
--- a/drivers/media/rc/ene_ir.h
+++ b/drivers/media/rc/ene_ir.h
@@ -12,11 +12,6 @@
12 * WITHOUT ANY WARRANTY; without even the implied warranty of 12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details. 14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 * USA
20 */ 15 */
21#include <linux/spinlock.h> 16#include <linux/spinlock.h>
22 17
diff --git a/drivers/media/rc/fintek-cir.c b/drivers/media/rc/fintek-cir.c
index ecab69ea3d51..0d3562712f27 100644
--- a/drivers/media/rc/fintek-cir.c
+++ b/drivers/media/rc/fintek-cir.c
@@ -16,11 +16,6 @@
16 * WITHOUT ANY WARRANTY; without even the implied warranty of 16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details. 18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 */ 19 */
25 20
26#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -492,7 +487,7 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id
492 return ret; 487 return ret;
493 488
494 /* input device for IR remote (and tx) */ 489 /* input device for IR remote (and tx) */
495 rdev = rc_allocate_device(); 490 rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
496 if (!rdev) 491 if (!rdev)
497 goto exit_free_dev_rdev; 492 goto exit_free_dev_rdev;
498 493
@@ -534,8 +529,7 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id
534 529
535 /* Set up the rc device */ 530 /* Set up the rc device */
536 rdev->priv = fintek; 531 rdev->priv = fintek;
537 rdev->driver_type = RC_DRIVER_IR_RAW; 532 rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
538 rdev->allowed_protocols = RC_BIT_ALL;
539 rdev->open = fintek_open; 533 rdev->open = fintek_open;
540 rdev->close = fintek_close; 534 rdev->close = fintek_close;
541 rdev->input_name = FINTEK_DESCRIPTION; 535 rdev->input_name = FINTEK_DESCRIPTION;
diff --git a/drivers/media/rc/fintek-cir.h b/drivers/media/rc/fintek-cir.h
index b698f3d2ced9..ac34a774d018 100644
--- a/drivers/media/rc/fintek-cir.h
+++ b/drivers/media/rc/fintek-cir.h
@@ -16,11 +16,6 @@
16 * WITHOUT ANY WARRANTY; without even the implied warranty of 16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details. 18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 */ 19 */
25 20
26#include <linux/spinlock.h> 21#include <linux/spinlock.h>
diff --git a/drivers/media/rc/gpio-ir-recv.c b/drivers/media/rc/gpio-ir-recv.c
index 5b63b1f15cb1..4a4895e4d599 100644
--- a/drivers/media/rc/gpio-ir-recv.c
+++ b/drivers/media/rc/gpio-ir-recv.c
@@ -143,14 +143,13 @@ static int gpio_ir_recv_probe(struct platform_device *pdev)
143 if (!gpio_dev) 143 if (!gpio_dev)
144 return -ENOMEM; 144 return -ENOMEM;
145 145
146 rcdev = rc_allocate_device(); 146 rcdev = rc_allocate_device(RC_DRIVER_IR_RAW);
147 if (!rcdev) { 147 if (!rcdev) {
148 rc = -ENOMEM; 148 rc = -ENOMEM;
149 goto err_allocate_device; 149 goto err_allocate_device;
150 } 150 }
151 151
152 rcdev->priv = gpio_dev; 152 rcdev->priv = gpio_dev;
153 rcdev->driver_type = RC_DRIVER_IR_RAW;
154 rcdev->input_name = GPIO_IR_DEVICE_NAME; 153 rcdev->input_name = GPIO_IR_DEVICE_NAME;
155 rcdev->input_phys = GPIO_IR_DEVICE_NAME "/input0"; 154 rcdev->input_phys = GPIO_IR_DEVICE_NAME "/input0";
156 rcdev->input_id.bustype = BUS_HOST; 155 rcdev->input_id.bustype = BUS_HOST;
@@ -165,7 +164,7 @@ static int gpio_ir_recv_probe(struct platform_device *pdev)
165 if (pdata->allowed_protos) 164 if (pdata->allowed_protos)
166 rcdev->allowed_protocols = pdata->allowed_protos; 165 rcdev->allowed_protocols = pdata->allowed_protos;
167 else 166 else
168 rcdev->allowed_protocols = RC_BIT_ALL; 167 rcdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
169 rcdev->map_name = pdata->map_name ?: RC_MAP_EMPTY; 168 rcdev->map_name = pdata->map_name ?: RC_MAP_EMPTY;
170 169
171 gpio_dev->rcdev = rcdev; 170 gpio_dev->rcdev = rcdev;
diff --git a/drivers/media/rc/igorplugusb.c b/drivers/media/rc/igorplugusb.c
index 5cf983be07a2..0f0ed4ea4d06 100644
--- a/drivers/media/rc/igorplugusb.c
+++ b/drivers/media/rc/igorplugusb.c
@@ -190,7 +190,7 @@ static int igorplugusb_probe(struct usb_interface *intf,
190 190
191 usb_make_path(udev, ir->phys, sizeof(ir->phys)); 191 usb_make_path(udev, ir->phys, sizeof(ir->phys));
192 192
193 rc = rc_allocate_device(); 193 rc = rc_allocate_device(RC_DRIVER_IR_RAW);
194 if (!rc) 194 if (!rc)
195 goto fail; 195 goto fail;
196 196
@@ -198,13 +198,12 @@ static int igorplugusb_probe(struct usb_interface *intf,
198 rc->input_phys = ir->phys; 198 rc->input_phys = ir->phys;
199 usb_to_input_id(udev, &rc->input_id); 199 usb_to_input_id(udev, &rc->input_id);
200 rc->dev.parent = &intf->dev; 200 rc->dev.parent = &intf->dev;
201 rc->driver_type = RC_DRIVER_IR_RAW;
202 /* 201 /*
203 * This device can only store 36 pulses + spaces, which is not enough 202 * This device can only store 36 pulses + spaces, which is not enough
204 * for the NEC protocol and many others. 203 * for the NEC protocol and many others.
205 */ 204 */
206 rc->allowed_protocols = RC_BIT_ALL & ~(RC_BIT_NEC | RC_BIT_NECX | 205 rc->allowed_protocols = RC_BIT_ALL_IR_DECODER & ~(RC_BIT_NEC |
207 RC_BIT_NEC32 | RC_BIT_RC6_6A_20 | 206 RC_BIT_NECX | RC_BIT_NEC32 | RC_BIT_RC6_6A_20 |
208 RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | 207 RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE |
209 RC_BIT_SONY20 | RC_BIT_MCE_KBD | RC_BIT_SANYO); 208 RC_BIT_SONY20 | RC_BIT_MCE_KBD | RC_BIT_SANYO);
210 209
diff --git a/drivers/media/rc/iguanair.c b/drivers/media/rc/iguanair.c
index 5f634545ddd8..ccf24fd7ec1b 100644
--- a/drivers/media/rc/iguanair.c
+++ b/drivers/media/rc/iguanair.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 15 */
20 16
21#include <linux/device.h> 17#include <linux/device.h>
@@ -431,7 +427,7 @@ static int iguanair_probe(struct usb_interface *intf,
431 struct usb_host_interface *idesc; 427 struct usb_host_interface *idesc;
432 428
433 ir = kzalloc(sizeof(*ir), GFP_KERNEL); 429 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
434 rc = rc_allocate_device(); 430 rc = rc_allocate_device(RC_DRIVER_IR_RAW);
435 if (!ir || !rc) { 431 if (!ir || !rc) {
436 ret = -ENOMEM; 432 ret = -ENOMEM;
437 goto out; 433 goto out;
@@ -494,8 +490,7 @@ static int iguanair_probe(struct usb_interface *intf,
494 rc->input_phys = ir->phys; 490 rc->input_phys = ir->phys;
495 usb_to_input_id(ir->udev, &rc->input_id); 491 usb_to_input_id(ir->udev, &rc->input_id);
496 rc->dev.parent = &intf->dev; 492 rc->dev.parent = &intf->dev;
497 rc->driver_type = RC_DRIVER_IR_RAW; 493 rc->allowed_protocols = RC_BIT_ALL_IR_DECODER;
498 rc->allowed_protocols = RC_BIT_ALL;
499 rc->priv = ir; 494 rc->priv = ir;
500 rc->open = iguanair_open; 495 rc->open = iguanair_open;
501 rc->close = iguanair_close; 496 rc->close = iguanair_close;
@@ -504,7 +499,9 @@ static int iguanair_probe(struct usb_interface *intf,
504 rc->tx_ir = iguanair_tx; 499 rc->tx_ir = iguanair_tx;
505 rc->driver_name = DRIVER_NAME; 500 rc->driver_name = DRIVER_NAME;
506 rc->map_name = RC_MAP_RC6_MCE; 501 rc->map_name = RC_MAP_RC6_MCE;
507 rc->timeout = MS_TO_NS(100); 502 rc->min_timeout = 1;
503 rc->timeout = IR_DEFAULT_TIMEOUT;
504 rc->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
508 rc->rx_resolution = RX_RESOLUTION; 505 rc->rx_resolution = RX_RESOLUTION;
509 506
510 iguanair_set_tx_carrier(rc, 38000); 507 iguanair_set_tx_carrier(rc, 38000);
diff --git a/drivers/media/rc/img-ir/img-ir-hw.c b/drivers/media/rc/img-ir/img-ir-hw.c
index 7bb71bc9f534..431d33b36fb0 100644
--- a/drivers/media/rc/img-ir/img-ir-hw.c
+++ b/drivers/media/rc/img-ir/img-ir-hw.c
@@ -488,7 +488,15 @@ static int img_ir_set_filter(struct rc_dev *dev, enum rc_filter_type type,
488 /* convert scancode filter to raw filter */ 488 /* convert scancode filter to raw filter */
489 filter.minlen = 0; 489 filter.minlen = 0;
490 filter.maxlen = ~0; 490 filter.maxlen = ~0;
491 ret = hw->decoder->filter(sc_filter, &filter, hw->enabled_protocols); 491 if (type == RC_FILTER_NORMAL) {
492 /* guess scancode from protocol */
493 ret = hw->decoder->filter(sc_filter, &filter,
494 dev->enabled_protocols);
495 } else {
496 /* for wakeup user provided exact protocol variant */
497 ret = hw->decoder->filter(sc_filter, &filter,
498 1ULL << dev->wakeup_protocol);
499 }
492 if (ret) 500 if (ret)
493 goto unlock; 501 goto unlock;
494 dev_dbg(priv->dev, "IR raw %sfilter=%016llx & %016llx\n", 502 dev_dbg(priv->dev, "IR raw %sfilter=%016llx & %016llx\n",
@@ -581,6 +589,7 @@ static void img_ir_set_decoder(struct img_ir_priv *priv,
581 /* clear the wakeup scancode filter */ 589 /* clear the wakeup scancode filter */
582 rdev->scancode_wakeup_filter.data = 0; 590 rdev->scancode_wakeup_filter.data = 0;
583 rdev->scancode_wakeup_filter.mask = 0; 591 rdev->scancode_wakeup_filter.mask = 0;
592 rdev->wakeup_protocol = RC_TYPE_UNKNOWN;
584 593
585 /* clear raw filters */ 594 /* clear raw filters */
586 _img_ir_set_filter(priv, NULL); 595 _img_ir_set_filter(priv, NULL);
@@ -685,7 +694,6 @@ success:
685 if (!hw->decoder || !hw->decoder->filter) 694 if (!hw->decoder || !hw->decoder->filter)
686 wakeup_protocols = 0; 695 wakeup_protocols = 0;
687 rdev->allowed_wakeup_protocols = wakeup_protocols; 696 rdev->allowed_wakeup_protocols = wakeup_protocols;
688 rdev->enabled_wakeup_protocols = wakeup_protocols;
689 return 0; 697 return 0;
690} 698}
691 699
@@ -701,7 +709,6 @@ static void img_ir_set_protocol(struct img_ir_priv *priv, u64 proto)
701 mutex_lock(&rdev->lock); 709 mutex_lock(&rdev->lock);
702 rdev->enabled_protocols = proto; 710 rdev->enabled_protocols = proto;
703 rdev->allowed_wakeup_protocols = proto; 711 rdev->allowed_wakeup_protocols = proto;
704 rdev->enabled_wakeup_protocols = proto;
705 mutex_unlock(&rdev->lock); 712 mutex_unlock(&rdev->lock);
706} 713}
707 714
@@ -1071,7 +1078,7 @@ int img_ir_probe_hw(struct img_ir_priv *priv)
1071 } 1078 }
1072 1079
1073 /* Allocate hardware decoder */ 1080 /* Allocate hardware decoder */
1074 hw->rdev = rdev = rc_allocate_device(); 1081 hw->rdev = rdev = rc_allocate_device(RC_DRIVER_SCANCODE);
1075 if (!rdev) { 1082 if (!rdev) {
1076 dev_err(priv->dev, "cannot allocate input device\n"); 1083 dev_err(priv->dev, "cannot allocate input device\n");
1077 error = -ENOMEM; 1084 error = -ENOMEM;
diff --git a/drivers/media/rc/img-ir/img-ir-nec.c b/drivers/media/rc/img-ir/img-ir-nec.c
index 09314933ea08..044fd42b22a0 100644
--- a/drivers/media/rc/img-ir/img-ir-nec.c
+++ b/drivers/media/rc/img-ir/img-ir-nec.c
@@ -11,6 +11,7 @@
11 11
12#include "img-ir-hw.h" 12#include "img-ir-hw.h"
13#include <linux/bitrev.h> 13#include <linux/bitrev.h>
14#include <linux/log2.h>
14 15
15/* Convert NEC data to a scancode */ 16/* Convert NEC data to a scancode */
16static int img_ir_nec_scancode(int len, u64 raw, u64 enabled_protocols, 17static int img_ir_nec_scancode(int len, u64 raw, u64 enabled_protocols,
@@ -62,7 +63,23 @@ static int img_ir_nec_filter(const struct rc_scancode_filter *in,
62 data = in->data & 0xff; 63 data = in->data & 0xff;
63 data_m = in->mask & 0xff; 64 data_m = in->mask & 0xff;
64 65
65 if ((in->data | in->mask) & 0xff000000) { 66 protocols &= RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32;
67
68 /*
69 * If only one bit is set, we were requested to do an exact
70 * protocol. This should be the case for wakeup filters; for
71 * normal filters, guess the protocol from the scancode.
72 */
73 if (!is_power_of_2(protocols)) {
74 if ((in->data | in->mask) & 0xff000000)
75 protocols = RC_BIT_NEC32;
76 else if ((in->data | in->mask) & 0x00ff0000)
77 protocols = RC_BIT_NECX;
78 else
79 protocols = RC_BIT_NEC;
80 }
81
82 if (protocols == RC_BIT_NEC32) {
66 /* 32-bit NEC (used by Apple and TiVo remotes) */ 83 /* 32-bit NEC (used by Apple and TiVo remotes) */
67 /* scan encoding: as transmitted, MSBit = first received bit */ 84 /* scan encoding: as transmitted, MSBit = first received bit */
68 addr = bitrev8(in->data >> 24); 85 addr = bitrev8(in->data >> 24);
@@ -73,7 +90,7 @@ static int img_ir_nec_filter(const struct rc_scancode_filter *in,
73 data_m = bitrev8(in->mask >> 8); 90 data_m = bitrev8(in->mask >> 8);
74 data_inv = bitrev8(in->data >> 0); 91 data_inv = bitrev8(in->data >> 0);
75 data_inv_m = bitrev8(in->mask >> 0); 92 data_inv_m = bitrev8(in->mask >> 0);
76 } else if ((in->data | in->mask) & 0x00ff0000) { 93 } else if (protocols == RC_BIT_NECX) {
77 /* Extended NEC */ 94 /* Extended NEC */
78 /* scan encoding AAaaDD */ 95 /* scan encoding AAaaDD */
79 addr = (in->data >> 16) & 0xff; 96 addr = (in->data >> 16) & 0xff;
diff --git a/drivers/media/rc/img-ir/img-ir-raw.c b/drivers/media/rc/img-ir/img-ir-raw.c
index 33f37ed87ad2..8d2f8e2006e7 100644
--- a/drivers/media/rc/img-ir/img-ir-raw.c
+++ b/drivers/media/rc/img-ir/img-ir-raw.c
@@ -110,7 +110,7 @@ int img_ir_probe_raw(struct img_ir_priv *priv)
110 setup_timer(&raw->timer, img_ir_echo_timer, (unsigned long)priv); 110 setup_timer(&raw->timer, img_ir_echo_timer, (unsigned long)priv);
111 111
112 /* Allocate raw decoder */ 112 /* Allocate raw decoder */
113 raw->rdev = rdev = rc_allocate_device(); 113 raw->rdev = rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
114 if (!rdev) { 114 if (!rdev) {
115 dev_err(priv->dev, "cannot allocate raw input device\n"); 115 dev_err(priv->dev, "cannot allocate raw input device\n");
116 return -ENOMEM; 116 return -ENOMEM;
@@ -118,7 +118,6 @@ int img_ir_probe_raw(struct img_ir_priv *priv)
118 rdev->priv = priv; 118 rdev->priv = priv;
119 rdev->map_name = RC_MAP_EMPTY; 119 rdev->map_name = RC_MAP_EMPTY;
120 rdev->input_name = "IMG Infrared Decoder Raw"; 120 rdev->input_name = "IMG Infrared Decoder Raw";
121 rdev->driver_type = RC_DRIVER_IR_RAW;
122 121
123 /* Register raw decoder */ 122 /* Register raw decoder */
124 error = rc_register_device(rdev); 123 error = rc_register_device(rdev);
diff --git a/drivers/media/rc/img-ir/img-ir-sony.c b/drivers/media/rc/img-ir/img-ir-sony.c
index 7f7375f82ed6..3fcba271a419 100644
--- a/drivers/media/rc/img-ir/img-ir-sony.c
+++ b/drivers/media/rc/img-ir/img-ir-sony.c
@@ -68,19 +68,29 @@ static int img_ir_sony_filter(const struct rc_scancode_filter *in,
68 func = (in->data >> 0) & 0x7f; 68 func = (in->data >> 0) & 0x7f;
69 func_m = (in->mask >> 0) & 0x7f; 69 func_m = (in->mask >> 0) & 0x7f;
70 70
71 if (subdev & subdev_m) { 71 protocols &= RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20;
72
73 /*
74 * If only one bit is set, we were requested to do an exact
75 * protocol. This should be the case for wakeup filters; for
76 * normal filters, guess the protocol from the scancode.
77 */
78 if (!is_power_of_2(protocols)) {
79 if (subdev & subdev_m)
80 protocols = RC_BIT_SONY20;
81 else if (dev & dev_m & 0xe0)
82 protocols = RC_BIT_SONY15;
83 else
84 protocols = RC_BIT_SONY12;
85 }
86
87 if (protocols == RC_BIT_SONY20) {
72 /* can't encode subdev and higher device bits */ 88 /* can't encode subdev and higher device bits */
73 if (dev & dev_m & 0xe0) 89 if (dev & dev_m & 0xe0)
74 return -EINVAL; 90 return -EINVAL;
75 /* subdevice (extended) bits only in 20 bit encoding */
76 if (!(protocols & RC_BIT_SONY20))
77 return -EINVAL;
78 len = 20; 91 len = 20;
79 dev_m &= 0x1f; 92 dev_m &= 0x1f;
80 } else if (dev & dev_m & 0xe0) { 93 } else if (protocols == RC_BIT_SONY15) {
81 /* upper device bits only in 15 bit encoding */
82 if (!(protocols & RC_BIT_SONY15))
83 return -EINVAL;
84 len = 15; 94 len = 15;
85 subdev_m = 0; 95 subdev_m = 0;
86 } else { 96 } else {
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 0785a24af8fc..89823d24a384 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -20,10 +20,6 @@
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details. 22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 */ 23 */
28 24
29#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ 25#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
@@ -96,6 +92,7 @@ struct imon_usb_dev_descr {
96 __u16 flags; 92 __u16 flags;
97#define IMON_NO_FLAGS 0 93#define IMON_NO_FLAGS 0
98#define IMON_NEED_20MS_PKT_DELAY 1 94#define IMON_NEED_20MS_PKT_DELAY 1
95#define IMON_IR_RAW 2
99 struct imon_panel_key_table key_table[]; 96 struct imon_panel_key_table key_table[];
100}; 97};
101 98
@@ -126,6 +123,12 @@ struct imon_context {
126 unsigned char usb_tx_buf[8]; 123 unsigned char usb_tx_buf[8];
127 unsigned int send_packet_delay; 124 unsigned int send_packet_delay;
128 125
126 struct rx_data {
127 int count; /* length of 0 or 1 sequence */
128 int prev_bit; /* logic level of sequence */
129 int initial_space; /* initial space flag */
130 } rx;
131
129 struct tx_t { 132 struct tx_t {
130 unsigned char data_buf[35]; /* user data buffer */ 133 unsigned char data_buf[35]; /* user data buffer */
131 struct completion finished; /* wait for write to finish */ 134 struct completion finished; /* wait for write to finish */
@@ -328,6 +331,10 @@ static const struct imon_usb_dev_descr imon_DH102 = {
328 } 331 }
329}; 332};
330 333
334static const struct imon_usb_dev_descr imon_ir_raw = {
335 .flags = IMON_IR_RAW,
336};
337
331/* 338/*
332 * USB Device ID for iMON USB Control Boards 339 * USB Device ID for iMON USB Control Boards
333 * 340 *
@@ -411,6 +418,18 @@ static struct usb_device_id imon_usb_id_table[] = {
411 /* device specifics unknown */ 418 /* device specifics unknown */
412 { USB_DEVICE(0x15c2, 0x0046), 419 { USB_DEVICE(0x15c2, 0x0046),
413 .driver_info = (unsigned long)&imon_default_table}, 420 .driver_info = (unsigned long)&imon_default_table},
421 /* TriGem iMON (IR only) -- TG_iMON.inf */
422 { USB_DEVICE(0x0aa8, 0x8001),
423 .driver_info = (unsigned long)&imon_ir_raw},
424 /* SoundGraph iMON (IR only) -- sg_imon.inf */
425 { USB_DEVICE(0x04e8, 0xff30),
426 .driver_info = (unsigned long)&imon_ir_raw},
427 /* SoundGraph iMON VFD (IR & VFD) -- iMON_VFD.inf */
428 { USB_DEVICE(0x0aa8, 0xffda),
429 .driver_info = (unsigned long)&imon_ir_raw},
430 /* SoundGraph iMON SS (IR & VFD) -- iMON_SS.inf */
431 { USB_DEVICE(0x15c2, 0xffda),
432 .driver_info = (unsigned long)&imon_ir_raw},
414 {} 433 {}
415}; 434};
416 435
@@ -1577,11 +1596,94 @@ static int imon_parse_press_type(struct imon_context *ictx,
1577/** 1596/**
1578 * Process the incoming packet 1597 * Process the incoming packet
1579 */ 1598 */
1580static void imon_incoming_packet(struct imon_context *ictx, 1599/**
1600 * Convert bit count to time duration (in us) and submit
1601 * the value to lirc_dev.
1602 */
1603static void submit_data(struct imon_context *context)
1604{
1605 DEFINE_IR_RAW_EVENT(ev);
1606
1607 ev.pulse = context->rx.prev_bit;
1608 ev.duration = US_TO_NS(context->rx.count * BIT_DURATION);
1609 ir_raw_event_store_with_filter(context->rdev, &ev);
1610}
1611
1612/**
1613 * Process the incoming packet
1614 */
1615static void imon_incoming_ir_raw(struct imon_context *context,
1581 struct urb *urb, int intf) 1616 struct urb *urb, int intf)
1582{ 1617{
1583 int len = urb->actual_length; 1618 int len = urb->actual_length;
1584 unsigned char *buf = urb->transfer_buffer; 1619 unsigned char *buf = urb->transfer_buffer;
1620 struct device *dev = context->dev;
1621 int octet, bit;
1622 unsigned char mask;
1623
1624 if (len != 8) {
1625 dev_warn(dev, "imon %s: invalid incoming packet size (len = %d, intf%d)\n",
1626 __func__, len, intf);
1627 return;
1628 }
1629
1630 if (debug)
1631 dev_info(dev, "raw packet: %*ph\n", len, buf);
1632 /*
1633 * Translate received data to pulse and space lengths.
1634 * Received data is active low, i.e. pulses are 0 and
1635 * spaces are 1.
1636 *
1637 * My original algorithm was essentially similar to
1638 * Changwoo Ryu's with the exception that he switched
1639 * the incoming bits to active high and also fed an
1640 * initial space to LIRC at the start of a new sequence
1641 * if the previous bit was a pulse.
1642 *
1643 * I've decided to adopt his algorithm.
1644 */
1645
1646 if (buf[7] == 1 && context->rx.initial_space) {
1647 /* LIRC requires a leading space */
1648 context->rx.prev_bit = 0;
1649 context->rx.count = 4;
1650 submit_data(context);
1651 context->rx.count = 0;
1652 }
1653
1654 for (octet = 0; octet < 5; ++octet) {
1655 mask = 0x80;
1656 for (bit = 0; bit < 8; ++bit) {
1657 int curr_bit = !(buf[octet] & mask);
1658
1659 if (curr_bit != context->rx.prev_bit) {
1660 if (context->rx.count) {
1661 submit_data(context);
1662 context->rx.count = 0;
1663 }
1664 context->rx.prev_bit = curr_bit;
1665 }
1666 ++context->rx.count;
1667 mask >>= 1;
1668 }
1669 }
1670
1671 if (buf[7] == 10) {
1672 if (context->rx.count) {
1673 submit_data(context);
1674 context->rx.count = 0;
1675 }
1676 context->rx.initial_space = context->rx.prev_bit;
1677 }
1678
1679 ir_raw_event_handle(context->rdev);
1680}
1681
1682static void imon_incoming_scancode(struct imon_context *ictx,
1683 struct urb *urb, int intf)
1684{
1685 int len = urb->actual_length;
1686 unsigned char *buf = urb->transfer_buffer;
1585 struct device *dev = ictx->dev; 1687 struct device *dev = ictx->dev;
1586 unsigned long flags; 1688 unsigned long flags;
1587 u32 kc; 1689 u32 kc;
@@ -1761,7 +1863,10 @@ static void usb_rx_callback_intf0(struct urb *urb)
1761 break; 1863 break;
1762 1864
1763 case 0: 1865 case 0:
1764 imon_incoming_packet(ictx, urb, intfnum); 1866 if (ictx->rdev->driver_type == RC_DRIVER_IR_RAW)
1867 imon_incoming_ir_raw(ictx, urb, intfnum);
1868 else
1869 imon_incoming_scancode(ictx, urb, intfnum);
1765 break; 1870 break;
1766 1871
1767 default: 1872 default:
@@ -1802,7 +1907,10 @@ static void usb_rx_callback_intf1(struct urb *urb)
1802 break; 1907 break;
1803 1908
1804 case 0: 1909 case 0:
1805 imon_incoming_packet(ictx, urb, intfnum); 1910 if (ictx->rdev->driver_type == RC_DRIVER_IR_RAW)
1911 imon_incoming_ir_raw(ictx, urb, intfnum);
1912 else
1913 imon_incoming_scancode(ictx, urb, intfnum);
1806 break; 1914 break;
1807 1915
1808 default: 1916 default:
@@ -1910,11 +2018,14 @@ static void imon_set_display_type(struct imon_context *ictx)
1910 case 0x0041: 2018 case 0x0041:
1911 case 0x0042: 2019 case 0x0042:
1912 case 0x0043: 2020 case 0x0043:
2021 case 0x8001:
2022 case 0xff30:
1913 configured_display_type = IMON_DISPLAY_TYPE_NONE; 2023 configured_display_type = IMON_DISPLAY_TYPE_NONE;
1914 ictx->display_supported = false; 2024 ictx->display_supported = false;
1915 break; 2025 break;
1916 case 0x0036: 2026 case 0x0036:
1917 case 0x0044: 2027 case 0x0044:
2028 case 0xffda:
1918 default: 2029 default:
1919 configured_display_type = IMON_DISPLAY_TYPE_VFD; 2030 configured_display_type = IMON_DISPLAY_TYPE_VFD;
1920 break; 2031 break;
@@ -1939,7 +2050,8 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
1939 const unsigned char fp_packet[] = { 0x40, 0x00, 0x00, 0x00, 2050 const unsigned char fp_packet[] = { 0x40, 0x00, 0x00, 0x00,
1940 0x00, 0x00, 0x00, 0x88 }; 2051 0x00, 0x00, 0x00, 0x88 };
1941 2052
1942 rdev = rc_allocate_device(); 2053 rdev = rc_allocate_device(ictx->dev_descr->flags & IMON_IR_RAW ?
2054 RC_DRIVER_IR_RAW : RC_DRIVER_SCANCODE);
1943 if (!rdev) { 2055 if (!rdev) {
1944 dev_err(ictx->dev, "remote control dev allocation failed\n"); 2056 dev_err(ictx->dev, "remote control dev allocation failed\n");
1945 goto out; 2057 goto out;
@@ -1957,8 +2069,11 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
1957 rdev->dev.parent = ictx->dev; 2069 rdev->dev.parent = ictx->dev;
1958 2070
1959 rdev->priv = ictx; 2071 rdev->priv = ictx;
1960 rdev->driver_type = RC_DRIVER_SCANCODE; 2072 if (ictx->dev_descr->flags & IMON_IR_RAW)
1961 rdev->allowed_protocols = RC_BIT_OTHER | RC_BIT_RC6_MCE; /* iMON PAD or MCE */ 2073 rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
2074 else
2075 /* iMON PAD or MCE */
2076 rdev->allowed_protocols = RC_BIT_OTHER | RC_BIT_RC6_MCE;
1962 rdev->change_protocol = imon_ir_change_protocol; 2077 rdev->change_protocol = imon_ir_change_protocol;
1963 rdev->driver_name = MOD_NAME; 2078 rdev->driver_name = MOD_NAME;
1964 2079
@@ -1976,7 +2091,8 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
1976 2091
1977 imon_set_display_type(ictx); 2092 imon_set_display_type(ictx);
1978 2093
1979 if (ictx->rc_type == RC_BIT_RC6_MCE) 2094 if (ictx->rc_type == RC_BIT_RC6_MCE ||
2095 ictx->dev_descr->flags & IMON_IR_RAW)
1980 rdev->map_name = RC_MAP_IMON_MCE; 2096 rdev->map_name = RC_MAP_IMON_MCE;
1981 else 2097 else
1982 rdev->map_name = RC_MAP_IMON_PAD; 2098 rdev->map_name = RC_MAP_IMON_PAD;
diff --git a/drivers/media/rc/ir-hix5hd2.c b/drivers/media/rc/ir-hix5hd2.c
index d26907e684dc..50951f686852 100644
--- a/drivers/media/rc/ir-hix5hd2.c
+++ b/drivers/media/rc/ir-hix5hd2.c
@@ -229,7 +229,7 @@ static int hix5hd2_ir_probe(struct platform_device *pdev)
229 return priv->irq; 229 return priv->irq;
230 } 230 }
231 231
232 rdev = rc_allocate_device(); 232 rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
233 if (!rdev) 233 if (!rdev)
234 return -ENOMEM; 234 return -ENOMEM;
235 235
@@ -242,8 +242,7 @@ static int hix5hd2_ir_probe(struct platform_device *pdev)
242 clk_prepare_enable(priv->clock); 242 clk_prepare_enable(priv->clock);
243 priv->rate = clk_get_rate(priv->clock); 243 priv->rate = clk_get_rate(priv->clock);
244 244
245 rdev->driver_type = RC_DRIVER_IR_RAW; 245 rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
246 rdev->allowed_protocols = RC_BIT_ALL;
247 rdev->priv = priv; 246 rdev->priv = priv;
248 rdev->open = hix5hd2_ir_open; 247 rdev->open = hix5hd2_ir_open;
249 rdev->close = hix5hd2_ir_close; 248 rdev->close = hix5hd2_ir_close;
diff --git a/drivers/media/rc/ir-jvc-decoder.c b/drivers/media/rc/ir-jvc-decoder.c
index 182402f7b4d1..674bf156edcb 100644
--- a/drivers/media/rc/ir-jvc-decoder.c
+++ b/drivers/media/rc/ir-jvc-decoder.c
@@ -170,9 +170,48 @@ out:
170 return -EINVAL; 170 return -EINVAL;
171} 171}
172 172
173static const struct ir_raw_timings_pd ir_jvc_timings = {
174 .header_pulse = JVC_HEADER_PULSE,
175 .header_space = JVC_HEADER_SPACE,
176 .bit_pulse = JVC_BIT_PULSE,
177 .bit_space[0] = JVC_BIT_0_SPACE,
178 .bit_space[1] = JVC_BIT_1_SPACE,
179 .trailer_pulse = JVC_TRAILER_PULSE,
180 .trailer_space = JVC_TRAILER_SPACE,
181 .msb_first = 1,
182};
183
184/**
185 * ir_jvc_encode() - Encode a scancode as a stream of raw events
186 *
187 * @protocol: protocol to encode
188 * @scancode: scancode to encode
189 * @events: array of raw ir events to write into
190 * @max: maximum size of @events
191 *
192 * Returns: The number of events written.
193 * -ENOBUFS if there isn't enough space in the array to fit the
194 * encoding. In this case all @max events will have been written.
195 */
196static int ir_jvc_encode(enum rc_type protocol, u32 scancode,
197 struct ir_raw_event *events, unsigned int max)
198{
199 struct ir_raw_event *e = events;
200 int ret;
201 u32 raw = (bitrev8((scancode >> 8) & 0xff) << 8) |
202 (bitrev8((scancode >> 0) & 0xff) << 0);
203
204 ret = ir_raw_gen_pd(&e, max, &ir_jvc_timings, JVC_NBITS, raw);
205 if (ret < 0)
206 return ret;
207
208 return e - events;
209}
210
173static struct ir_raw_handler jvc_handler = { 211static struct ir_raw_handler jvc_handler = {
174 .protocols = RC_BIT_JVC, 212 .protocols = RC_BIT_JVC,
175 .decode = ir_jvc_decode, 213 .decode = ir_jvc_decode,
214 .encode = ir_jvc_encode,
176}; 215};
177 216
178static int __init ir_jvc_decode_init(void) 217static int __init ir_jvc_decode_init(void)
diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c
index c3277308a70b..8517d5153fcf 100644
--- a/drivers/media/rc/ir-lirc-codec.c
+++ b/drivers/media/rc/ir-lirc-codec.c
@@ -204,11 +204,17 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd,
204 204
205 /* legacy support */ 205 /* legacy support */
206 case LIRC_GET_SEND_MODE: 206 case LIRC_GET_SEND_MODE:
207 val = LIRC_CAN_SEND_PULSE & LIRC_CAN_SEND_MASK; 207 if (!dev->tx_ir)
208 return -ENOTTY;
209
210 val = LIRC_MODE_PULSE;
208 break; 211 break;
209 212
210 case LIRC_SET_SEND_MODE: 213 case LIRC_SET_SEND_MODE:
211 if (val != (LIRC_MODE_PULSE & LIRC_CAN_SEND_MASK)) 214 if (!dev->tx_ir)
215 return -ENOTTY;
216
217 if (val != LIRC_MODE_PULSE)
212 return -EINVAL; 218 return -EINVAL;
213 return 0; 219 return 0;
214 220
@@ -273,7 +279,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd,
273 case LIRC_GET_MIN_TIMEOUT: 279 case LIRC_GET_MIN_TIMEOUT:
274 if (!dev->max_timeout) 280 if (!dev->max_timeout)
275 return -ENOSYS; 281 return -ENOSYS;
276 val = dev->min_timeout / 1000; 282 val = DIV_ROUND_UP(dev->min_timeout, 1000);
277 break; 283 break;
278 284
279 case LIRC_GET_MAX_TIMEOUT: 285 case LIRC_GET_MAX_TIMEOUT:
@@ -341,7 +347,7 @@ static int ir_lirc_register(struct rc_dev *dev)
341 struct lirc_driver *drv; 347 struct lirc_driver *drv;
342 struct lirc_buffer *rbuf; 348 struct lirc_buffer *rbuf;
343 int rc = -ENOMEM; 349 int rc = -ENOMEM;
344 unsigned long features; 350 unsigned long features = 0;
345 351
346 drv = kzalloc(sizeof(struct lirc_driver), GFP_KERNEL); 352 drv = kzalloc(sizeof(struct lirc_driver), GFP_KERNEL);
347 if (!drv) 353 if (!drv)
@@ -355,7 +361,8 @@ static int ir_lirc_register(struct rc_dev *dev)
355 if (rc) 361 if (rc)
356 goto rbuf_init_failed; 362 goto rbuf_init_failed;
357 363
358 features = LIRC_CAN_REC_MODE2; 364 if (dev->driver_type != RC_DRIVER_IR_RAW_TX)
365 features |= LIRC_CAN_REC_MODE2;
359 if (dev->tx_ir) { 366 if (dev->tx_ir) {
360 features |= LIRC_CAN_SEND_PULSE; 367 features |= LIRC_CAN_SEND_PULSE;
361 if (dev->s_tx_mask) 368 if (dev->s_tx_mask)
diff --git a/drivers/media/rc/ir-mce_kbd-decoder.c b/drivers/media/rc/ir-mce_kbd-decoder.c
index d80986251ee0..5226d510e847 100644
--- a/drivers/media/rc/ir-mce_kbd-decoder.c
+++ b/drivers/media/rc/ir-mce_kbd-decoder.c
@@ -71,7 +71,7 @@ static unsigned char kbd_keycodes[256] = {
71 KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, 71 KEY_6, KEY_7, KEY_8, KEY_9, KEY_0,
72 KEY_ENTER, KEY_ESC, KEY_BACKSPACE, KEY_TAB, KEY_SPACE, 72 KEY_ENTER, KEY_ESC, KEY_BACKSPACE, KEY_TAB, KEY_SPACE,
73 KEY_MINUS, KEY_EQUAL, KEY_LEFTBRACE, KEY_RIGHTBRACE, KEY_BACKSLASH, 73 KEY_MINUS, KEY_EQUAL, KEY_LEFTBRACE, KEY_RIGHTBRACE, KEY_BACKSLASH,
74 KEY_RESERVED, KEY_SEMICOLON, KEY_APOSTROPHE, KEY_GRAVE, KEY_COMMA, 74 KEY_BACKSLASH, KEY_SEMICOLON, KEY_APOSTROPHE, KEY_GRAVE, KEY_COMMA,
75 KEY_DOT, KEY_SLASH, KEY_CAPSLOCK, KEY_F1, KEY_F2, 75 KEY_DOT, KEY_SLASH, KEY_CAPSLOCK, KEY_F1, KEY_F2,
76 KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, 76 KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7,
77 KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, 77 KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12,
diff --git a/drivers/media/rc/ir-nec-decoder.c b/drivers/media/rc/ir-nec-decoder.c
index 2a9d155548ab..3ce850314dca 100644
--- a/drivers/media/rc/ir-nec-decoder.c
+++ b/drivers/media/rc/ir-nec-decoder.c
@@ -170,7 +170,10 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
170 if (send_32bits) { 170 if (send_32bits) {
171 /* NEC transport, but modified protocol, used by at 171 /* NEC transport, but modified protocol, used by at
172 * least Apple and TiVo remotes */ 172 * least Apple and TiVo remotes */
173 scancode = data->bits; 173 scancode = not_address << 24 |
174 address << 16 |
175 not_command << 8 |
176 command;
174 IR_dprintk(1, "NEC (modified) scancode 0x%08x\n", scancode); 177 IR_dprintk(1, "NEC (modified) scancode 0x%08x\n", scancode);
175 rc_type = RC_TYPE_NEC32; 178 rc_type = RC_TYPE_NEC32;
176 } else if ((address ^ not_address) != 0xff) { 179 } else if ((address ^ not_address) != 0xff) {
@@ -201,9 +204,90 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
201 return -EINVAL; 204 return -EINVAL;
202} 205}
203 206
207/**
208 * ir_nec_scancode_to_raw() - encode an NEC scancode ready for modulation.
209 * @protocol: specific protocol to use
210 * @scancode: a single NEC scancode.
211 * @raw: raw data to be modulated.
212 */
213static u32 ir_nec_scancode_to_raw(enum rc_type protocol, u32 scancode)
214{
215 unsigned int addr, addr_inv, data, data_inv;
216
217 data = scancode & 0xff;
218
219 if (protocol == RC_TYPE_NEC32) {
220 /* 32-bit NEC (used by Apple and TiVo remotes) */
221 /* scan encoding: aaAAddDD */
222 addr_inv = (scancode >> 24) & 0xff;
223 addr = (scancode >> 16) & 0xff;
224 data_inv = (scancode >> 8) & 0xff;
225 } else if (protocol == RC_TYPE_NECX) {
226 /* Extended NEC */
227 /* scan encoding AAaaDD */
228 addr = (scancode >> 16) & 0xff;
229 addr_inv = (scancode >> 8) & 0xff;
230 data_inv = data ^ 0xff;
231 } else {
232 /* Normal NEC */
233 /* scan encoding: AADD */
234 addr = (scancode >> 8) & 0xff;
235 addr_inv = addr ^ 0xff;
236 data_inv = data ^ 0xff;
237 }
238
239 /* raw encoding: ddDDaaAA */
240 return data_inv << 24 |
241 data << 16 |
242 addr_inv << 8 |
243 addr;
244}
245
246static const struct ir_raw_timings_pd ir_nec_timings = {
247 .header_pulse = NEC_HEADER_PULSE,
248 .header_space = NEC_HEADER_SPACE,
249 .bit_pulse = NEC_BIT_PULSE,
250 .bit_space[0] = NEC_BIT_0_SPACE,
251 .bit_space[1] = NEC_BIT_1_SPACE,
252 .trailer_pulse = NEC_TRAILER_PULSE,
253 .trailer_space = NEC_TRAILER_SPACE,
254 .msb_first = 0,
255};
256
257/**
258 * ir_nec_encode() - Encode a scancode as a stream of raw events
259 *
260 * @protocol: protocol to encode
261 * @scancode: scancode to encode
262 * @events: array of raw ir events to write into
263 * @max: maximum size of @events
264 *
265 * Returns: The number of events written.
266 * -ENOBUFS if there isn't enough space in the array to fit the
267 * encoding. In this case all @max events will have been written.
268 */
269static int ir_nec_encode(enum rc_type protocol, u32 scancode,
270 struct ir_raw_event *events, unsigned int max)
271{
272 struct ir_raw_event *e = events;
273 int ret;
274 u32 raw;
275
276 /* Convert a NEC scancode to raw NEC data */
277 raw = ir_nec_scancode_to_raw(protocol, scancode);
278
279 /* Modulate the raw data using a pulse distance modulation */
280 ret = ir_raw_gen_pd(&e, max, &ir_nec_timings, NEC_NBITS, raw);
281 if (ret < 0)
282 return ret;
283
284 return e - events;
285}
286
204static struct ir_raw_handler nec_handler = { 287static struct ir_raw_handler nec_handler = {
205 .protocols = RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32, 288 .protocols = RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32,
206 .decode = ir_nec_decode, 289 .decode = ir_nec_decode,
290 .encode = ir_nec_encode,
207}; 291};
208 292
209static int __init ir_nec_decode_init(void) 293static int __init ir_nec_decode_init(void)
diff --git a/drivers/media/rc/ir-rc5-decoder.c b/drivers/media/rc/ir-rc5-decoder.c
index a0fd4e6b2155..fcfedf95def7 100644
--- a/drivers/media/rc/ir-rc5-decoder.c
+++ b/drivers/media/rc/ir-rc5-decoder.c
@@ -124,7 +124,7 @@ again:
124 if (data->is_rc5x && data->count == RC5X_NBITS) { 124 if (data->is_rc5x && data->count == RC5X_NBITS) {
125 /* RC5X */ 125 /* RC5X */
126 u8 xdata, command, system; 126 u8 xdata, command, system;
127 if (!(dev->enabled_protocols & RC_BIT_RC5X)) { 127 if (!(dev->enabled_protocols & RC_BIT_RC5X_20)) {
128 data->state = STATE_INACTIVE; 128 data->state = STATE_INACTIVE;
129 return 0; 129 return 0;
130 } 130 }
@@ -132,9 +132,9 @@ again:
132 command = (data->bits & 0x00FC0) >> 6; 132 command = (data->bits & 0x00FC0) >> 6;
133 system = (data->bits & 0x1F000) >> 12; 133 system = (data->bits & 0x1F000) >> 12;
134 toggle = (data->bits & 0x20000) ? 1 : 0; 134 toggle = (data->bits & 0x20000) ? 1 : 0;
135 command += (data->bits & 0x01000) ? 0 : 0x40; 135 command += (data->bits & 0x40000) ? 0 : 0x40;
136 scancode = system << 16 | command << 8 | xdata; 136 scancode = system << 16 | command << 8 | xdata;
137 protocol = RC_TYPE_RC5X; 137 protocol = RC_TYPE_RC5X_20;
138 138
139 } else if (!data->is_rc5x && data->count == RC5_NBITS) { 139 } else if (!data->is_rc5x && data->count == RC5_NBITS) {
140 /* RC5 */ 140 /* RC5 */
@@ -181,9 +181,106 @@ out:
181 return -EINVAL; 181 return -EINVAL;
182} 182}
183 183
184static const struct ir_raw_timings_manchester ir_rc5_timings = {
185 .leader = RC5_UNIT,
186 .pulse_space_start = 0,
187 .clock = RC5_UNIT,
188 .trailer_space = RC5_UNIT * 10,
189};
190
191static const struct ir_raw_timings_manchester ir_rc5x_timings[2] = {
192 {
193 .leader = RC5_UNIT,
194 .pulse_space_start = 0,
195 .clock = RC5_UNIT,
196 .trailer_space = RC5X_SPACE,
197 },
198 {
199 .clock = RC5_UNIT,
200 .trailer_space = RC5_UNIT * 10,
201 },
202};
203
204static const struct ir_raw_timings_manchester ir_rc5_sz_timings = {
205 .leader = RC5_UNIT,
206 .pulse_space_start = 0,
207 .clock = RC5_UNIT,
208 .trailer_space = RC5_UNIT * 10,
209};
210
211/**
212 * ir_rc5_encode() - Encode a scancode as a stream of raw events
213 *
214 * @protocol: protocol variant to encode
215 * @scancode: scancode to encode
216 * @events: array of raw ir events to write into
217 * @max: maximum size of @events
218 *
219 * Returns: The number of events written.
220 * -ENOBUFS if there isn't enough space in the array to fit the
221 * encoding. In this case all @max events will have been written.
222 * -EINVAL if the scancode is ambiguous or invalid.
223 */
224static int ir_rc5_encode(enum rc_type protocol, u32 scancode,
225 struct ir_raw_event *events, unsigned int max)
226{
227 int ret;
228 struct ir_raw_event *e = events;
229 unsigned int data, xdata, command, commandx, system, pre_space_data;
230
231 /* Detect protocol and convert scancode to raw data */
232 if (protocol == RC_TYPE_RC5) {
233 /* decode scancode */
234 command = (scancode & 0x003f) >> 0;
235 commandx = (scancode & 0x0040) >> 6;
236 system = (scancode & 0x1f00) >> 8;
237 /* encode data */
238 data = !commandx << 12 | system << 6 | command;
239
240 /* Modulate the data */
241 ret = ir_raw_gen_manchester(&e, max, &ir_rc5_timings,
242 RC5_NBITS, data);
243 if (ret < 0)
244 return ret;
245 } else if (protocol == RC_TYPE_RC5X_20) {
246 /* decode scancode */
247 xdata = (scancode & 0x00003f) >> 0;
248 command = (scancode & 0x003f00) >> 8;
249 commandx = !(scancode & 0x004000);
250 system = (scancode & 0x1f0000) >> 16;
251
252 /* encode data */
253 data = commandx << 18 | system << 12 | command << 6 | xdata;
254
255 /* Modulate the data */
256 pre_space_data = data >> (RC5X_NBITS - CHECK_RC5X_NBITS);
257 ret = ir_raw_gen_manchester(&e, max, &ir_rc5x_timings[0],
258 CHECK_RC5X_NBITS, pre_space_data);
259 if (ret < 0)
260 return ret;
261 ret = ir_raw_gen_manchester(&e, max - (e - events),
262 &ir_rc5x_timings[1],
263 RC5X_NBITS - CHECK_RC5X_NBITS,
264 data);
265 if (ret < 0)
266 return ret;
267 } else if (protocol == RC_TYPE_RC5_SZ) {
268 /* RC5-SZ scancode is raw enough for Manchester as it is */
269 ret = ir_raw_gen_manchester(&e, max, &ir_rc5_sz_timings,
270 RC5_SZ_NBITS, scancode & 0x2fff);
271 if (ret < 0)
272 return ret;
273 } else {
274 return -EINVAL;
275 }
276
277 return e - events;
278}
279
184static struct ir_raw_handler rc5_handler = { 280static struct ir_raw_handler rc5_handler = {
185 .protocols = RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ, 281 .protocols = RC_BIT_RC5 | RC_BIT_RC5X_20 | RC_BIT_RC5_SZ,
186 .decode = ir_rc5_decode, 282 .decode = ir_rc5_decode,
283 .encode = ir_rc5_encode,
187}; 284};
188 285
189static int __init ir_rc5_decode_init(void) 286static int __init ir_rc5_decode_init(void)
diff --git a/drivers/media/rc/ir-rc6-decoder.c b/drivers/media/rc/ir-rc6-decoder.c
index 5cc54c967a80..6fe2268dada0 100644
--- a/drivers/media/rc/ir-rc6-decoder.c
+++ b/drivers/media/rc/ir-rc6-decoder.c
@@ -286,11 +286,128 @@ out:
286 return -EINVAL; 286 return -EINVAL;
287} 287}
288 288
289static const struct ir_raw_timings_manchester ir_rc6_timings[4] = {
290 {
291 .leader = RC6_PREFIX_PULSE,
292 .pulse_space_start = 0,
293 .clock = RC6_UNIT,
294 .invert = 1,
295 .trailer_space = RC6_PREFIX_SPACE,
296 },
297 {
298 .clock = RC6_UNIT,
299 .invert = 1,
300 },
301 {
302 .clock = RC6_UNIT * 2,
303 .invert = 1,
304 },
305 {
306 .clock = RC6_UNIT,
307 .invert = 1,
308 .trailer_space = RC6_SUFFIX_SPACE,
309 },
310};
311
312/**
313 * ir_rc6_encode() - Encode a scancode as a stream of raw events
314 *
315 * @protocol: protocol to encode
316 * @scancode: scancode to encode
317 * @events: array of raw ir events to write into
318 * @max: maximum size of @events
319 *
320 * Returns: The number of events written.
321 * -ENOBUFS if there isn't enough space in the array to fit the
322 * encoding. In this case all @max events will have been written.
323 * -EINVAL if the scancode is ambiguous or invalid.
324 */
325static int ir_rc6_encode(enum rc_type protocol, u32 scancode,
326 struct ir_raw_event *events, unsigned int max)
327{
328 int ret;
329 struct ir_raw_event *e = events;
330
331 if (protocol == RC_TYPE_RC6_0) {
332 /* Modulate the preamble */
333 ret = ir_raw_gen_manchester(&e, max, &ir_rc6_timings[0], 0, 0);
334 if (ret < 0)
335 return ret;
336
337 /* Modulate the header (Start Bit & Mode-0) */
338 ret = ir_raw_gen_manchester(&e, max - (e - events),
339 &ir_rc6_timings[1],
340 RC6_HEADER_NBITS, (1 << 3));
341 if (ret < 0)
342 return ret;
343
344 /* Modulate Trailer Bit */
345 ret = ir_raw_gen_manchester(&e, max - (e - events),
346 &ir_rc6_timings[2], 1, 0);
347 if (ret < 0)
348 return ret;
349
350 /* Modulate rest of the data */
351 ret = ir_raw_gen_manchester(&e, max - (e - events),
352 &ir_rc6_timings[3], RC6_0_NBITS,
353 scancode);
354 if (ret < 0)
355 return ret;
356
357 } else {
358 int bits;
359
360 switch (protocol) {
361 case RC_TYPE_RC6_MCE:
362 case RC_TYPE_RC6_6A_32:
363 bits = 32;
364 break;
365 case RC_TYPE_RC6_6A_24:
366 bits = 24;
367 break;
368 case RC_TYPE_RC6_6A_20:
369 bits = 20;
370 break;
371 default:
372 return -EINVAL;
373 }
374
375 /* Modulate the preamble */
376 ret = ir_raw_gen_manchester(&e, max, &ir_rc6_timings[0], 0, 0);
377 if (ret < 0)
378 return ret;
379
380 /* Modulate the header (Start Bit & Header-version 6 */
381 ret = ir_raw_gen_manchester(&e, max - (e - events),
382 &ir_rc6_timings[1],
383 RC6_HEADER_NBITS, (1 << 3 | 6));
384 if (ret < 0)
385 return ret;
386
387 /* Modulate Trailer Bit */
388 ret = ir_raw_gen_manchester(&e, max - (e - events),
389 &ir_rc6_timings[2], 1, 0);
390 if (ret < 0)
391 return ret;
392
393 /* Modulate rest of the data */
394 ret = ir_raw_gen_manchester(&e, max - (e - events),
395 &ir_rc6_timings[3],
396 bits,
397 scancode);
398 if (ret < 0)
399 return ret;
400 }
401
402 return e - events;
403}
404
289static struct ir_raw_handler rc6_handler = { 405static struct ir_raw_handler rc6_handler = {
290 .protocols = RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | 406 .protocols = RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 |
291 RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 | 407 RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 |
292 RC_BIT_RC6_MCE, 408 RC_BIT_RC6_MCE,
293 .decode = ir_rc6_decode, 409 .decode = ir_rc6_decode,
410 .encode = ir_rc6_encode,
294}; 411};
295 412
296static int __init ir_rc6_decode_init(void) 413static int __init ir_rc6_decode_init(void)
diff --git a/drivers/media/rc/ir-rx51.c b/drivers/media/rc/ir-rx51.c
index e6efa8c267a0..49265f02e772 100644
--- a/drivers/media/rc/ir-rx51.c
+++ b/drivers/media/rc/ir-rx51.c
@@ -15,32 +15,23 @@
15 */ 15 */
16#include <linux/clk.h> 16#include <linux/clk.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/interrupt.h>
19#include <linux/uaccess.h>
20#include <linux/platform_device.h> 18#include <linux/platform_device.h>
21#include <linux/sched.h>
22#include <linux/wait.h> 19#include <linux/wait.h>
23#include <linux/pwm.h> 20#include <linux/pwm.h>
24#include <linux/of.h> 21#include <linux/of.h>
25#include <linux/hrtimer.h> 22#include <linux/hrtimer.h>
26 23
27#include <media/lirc.h> 24#include <media/rc-core.h>
28#include <media/lirc_dev.h>
29#include <linux/platform_data/media/ir-rx51.h> 25#include <linux/platform_data/media/ir-rx51.h>
30 26
31#define LIRC_RX51_DRIVER_FEATURES (LIRC_CAN_SET_SEND_DUTY_CYCLE | \
32 LIRC_CAN_SET_SEND_CARRIER | \
33 LIRC_CAN_SEND_PULSE)
34
35#define DRIVER_NAME "lirc_rx51"
36
37#define WBUF_LEN 256 27#define WBUF_LEN 256
38 28
39struct lirc_rx51 { 29struct ir_rx51 {
30 struct rc_dev *rcdev;
40 struct pwm_device *pwm; 31 struct pwm_device *pwm;
41 struct hrtimer timer; 32 struct hrtimer timer;
42 struct device *dev; 33 struct device *dev;
43 struct lirc_rx51_platform_data *pdata; 34 struct ir_rx51_platform_data *pdata;
44 wait_queue_head_t wqueue; 35 wait_queue_head_t wqueue;
45 36
46 unsigned int freq; /* carrier frequency */ 37 unsigned int freq; /* carrier frequency */
@@ -50,38 +41,37 @@ struct lirc_rx51 {
50 unsigned long device_is_open; 41 unsigned long device_is_open;
51}; 42};
52 43
53static inline void lirc_rx51_on(struct lirc_rx51 *lirc_rx51) 44static inline void ir_rx51_on(struct ir_rx51 *ir_rx51)
54{ 45{
55 pwm_enable(lirc_rx51->pwm); 46 pwm_enable(ir_rx51->pwm);
56} 47}
57 48
58static inline void lirc_rx51_off(struct lirc_rx51 *lirc_rx51) 49static inline void ir_rx51_off(struct ir_rx51 *ir_rx51)
59{ 50{
60 pwm_disable(lirc_rx51->pwm); 51 pwm_disable(ir_rx51->pwm);
61} 52}
62 53
63static int init_timing_params(struct lirc_rx51 *lirc_rx51) 54static int init_timing_params(struct ir_rx51 *ir_rx51)
64{ 55{
65 struct pwm_device *pwm = lirc_rx51->pwm; 56 struct pwm_device *pwm = ir_rx51->pwm;
66 int duty, period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, lirc_rx51->freq); 57 int duty, period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, ir_rx51->freq);
67 58
68 duty = DIV_ROUND_CLOSEST(lirc_rx51->duty_cycle * period, 100); 59 duty = DIV_ROUND_CLOSEST(ir_rx51->duty_cycle * period, 100);
69 60
70 pwm_config(pwm, duty, period); 61 pwm_config(pwm, duty, period);
71 62
72 return 0; 63 return 0;
73} 64}
74 65
75static enum hrtimer_restart lirc_rx51_timer_cb(struct hrtimer *timer) 66static enum hrtimer_restart ir_rx51_timer_cb(struct hrtimer *timer)
76{ 67{
77 struct lirc_rx51 *lirc_rx51 = 68 struct ir_rx51 *ir_rx51 = container_of(timer, struct ir_rx51, timer);
78 container_of(timer, struct lirc_rx51, timer);
79 ktime_t now; 69 ktime_t now;
80 70
81 if (lirc_rx51->wbuf_index < 0) { 71 if (ir_rx51->wbuf_index < 0) {
82 dev_err_ratelimited(lirc_rx51->dev, 72 dev_err_ratelimited(ir_rx51->dev,
83 "BUG wbuf_index has value of %i\n", 73 "BUG wbuf_index has value of %i\n",
84 lirc_rx51->wbuf_index); 74 ir_rx51->wbuf_index);
85 goto end; 75 goto end;
86 } 76 }
87 77
@@ -92,20 +82,20 @@ static enum hrtimer_restart lirc_rx51_timer_cb(struct hrtimer *timer)
92 do { 82 do {
93 u64 ns; 83 u64 ns;
94 84
95 if (lirc_rx51->wbuf_index >= WBUF_LEN) 85 if (ir_rx51->wbuf_index >= WBUF_LEN)
96 goto end; 86 goto end;
97 if (lirc_rx51->wbuf[lirc_rx51->wbuf_index] == -1) 87 if (ir_rx51->wbuf[ir_rx51->wbuf_index] == -1)
98 goto end; 88 goto end;
99 89
100 if (lirc_rx51->wbuf_index % 2) 90 if (ir_rx51->wbuf_index % 2)
101 lirc_rx51_off(lirc_rx51); 91 ir_rx51_off(ir_rx51);
102 else 92 else
103 lirc_rx51_on(lirc_rx51); 93 ir_rx51_on(ir_rx51);
104 94
105 ns = 1000 * lirc_rx51->wbuf[lirc_rx51->wbuf_index]; 95 ns = US_TO_NS(ir_rx51->wbuf[ir_rx51->wbuf_index]);
106 hrtimer_add_expires_ns(timer, ns); 96 hrtimer_add_expires_ns(timer, ns);
107 97
108 lirc_rx51->wbuf_index++; 98 ir_rx51->wbuf_index++;
109 99
110 now = timer->base->get_time(); 100 now = timer->base->get_time();
111 101
@@ -114,203 +104,112 @@ static enum hrtimer_restart lirc_rx51_timer_cb(struct hrtimer *timer)
114 return HRTIMER_RESTART; 104 return HRTIMER_RESTART;
115end: 105end:
116 /* Stop TX here */ 106 /* Stop TX here */
117 lirc_rx51_off(lirc_rx51); 107 ir_rx51_off(ir_rx51);
118 lirc_rx51->wbuf_index = -1; 108 ir_rx51->wbuf_index = -1;
119 109
120 wake_up_interruptible(&lirc_rx51->wqueue); 110 wake_up_interruptible(&ir_rx51->wqueue);
121 111
122 return HRTIMER_NORESTART; 112 return HRTIMER_NORESTART;
123} 113}
124 114
125static ssize_t lirc_rx51_write(struct file *file, const char *buf, 115static int ir_rx51_tx(struct rc_dev *dev, unsigned int *buffer,
126 size_t n, loff_t *ppos) 116 unsigned int count)
127{ 117{
128 int count, i; 118 struct ir_rx51 *ir_rx51 = dev->priv;
129 struct lirc_rx51 *lirc_rx51 = file->private_data;
130 119
131 if (n % sizeof(int)) 120 if (count > WBUF_LEN)
132 return -EINVAL; 121 return -EINVAL;
133 122
134 count = n / sizeof(int); 123 memcpy(ir_rx51->wbuf, buffer, count * sizeof(unsigned int));
135 if ((count > WBUF_LEN) || (count % 2 == 0))
136 return -EINVAL;
137 124
138 /* Wait any pending transfers to finish */ 125 /* Wait any pending transfers to finish */
139 wait_event_interruptible(lirc_rx51->wqueue, lirc_rx51->wbuf_index < 0); 126 wait_event_interruptible(ir_rx51->wqueue, ir_rx51->wbuf_index < 0);
140
141 if (copy_from_user(lirc_rx51->wbuf, buf, n))
142 return -EFAULT;
143
144 /* Sanity check the input pulses */
145 for (i = 0; i < count; i++)
146 if (lirc_rx51->wbuf[i] < 0)
147 return -EINVAL;
148 127
149 init_timing_params(lirc_rx51); 128 init_timing_params(ir_rx51);
150 if (count < WBUF_LEN) 129 if (count < WBUF_LEN)
151 lirc_rx51->wbuf[count] = -1; /* Insert termination mark */ 130 ir_rx51->wbuf[count] = -1; /* Insert termination mark */
152 131
153 /* 132 /*
154 * Adjust latency requirements so the device doesn't go in too 133 * Adjust latency requirements so the device doesn't go in too
155 * deep sleep states 134 * deep sleep states
156 */ 135 */
157 lirc_rx51->pdata->set_max_mpu_wakeup_lat(lirc_rx51->dev, 50); 136 ir_rx51->pdata->set_max_mpu_wakeup_lat(ir_rx51->dev, 50);
158 137
159 lirc_rx51_on(lirc_rx51); 138 ir_rx51_on(ir_rx51);
160 lirc_rx51->wbuf_index = 1; 139 ir_rx51->wbuf_index = 1;
161 hrtimer_start(&lirc_rx51->timer, 140 hrtimer_start(&ir_rx51->timer,
162 ns_to_ktime(1000 * lirc_rx51->wbuf[0]), 141 ns_to_ktime(US_TO_NS(ir_rx51->wbuf[0])),
163 HRTIMER_MODE_REL); 142 HRTIMER_MODE_REL);
164 /* 143 /*
165 * Don't return back to the userspace until the transfer has 144 * Don't return back to the userspace until the transfer has
166 * finished 145 * finished
167 */ 146 */
168 wait_event_interruptible(lirc_rx51->wqueue, lirc_rx51->wbuf_index < 0); 147 wait_event_interruptible(ir_rx51->wqueue, ir_rx51->wbuf_index < 0);
169 148
170 /* We can sleep again */ 149 /* We can sleep again */
171 lirc_rx51->pdata->set_max_mpu_wakeup_lat(lirc_rx51->dev, -1); 150 ir_rx51->pdata->set_max_mpu_wakeup_lat(ir_rx51->dev, -1);
172 151
173 return n; 152 return count;
174} 153}
175 154
176static long lirc_rx51_ioctl(struct file *filep, 155static int ir_rx51_open(struct rc_dev *dev)
177 unsigned int cmd, unsigned long arg)
178{ 156{
179 int result; 157 struct ir_rx51 *ir_rx51 = dev->priv;
180 unsigned long value;
181 unsigned int ivalue;
182 struct lirc_rx51 *lirc_rx51 = filep->private_data;
183
184 switch (cmd) {
185 case LIRC_GET_SEND_MODE:
186 result = put_user(LIRC_MODE_PULSE, (unsigned long *)arg);
187 if (result)
188 return result;
189 break;
190
191 case LIRC_SET_SEND_MODE:
192 result = get_user(value, (unsigned long *)arg);
193 if (result)
194 return result;
195
196 /* only LIRC_MODE_PULSE supported */
197 if (value != LIRC_MODE_PULSE)
198 return -ENOSYS;
199 break;
200
201 case LIRC_GET_REC_MODE:
202 result = put_user(0, (unsigned long *) arg);
203 if (result)
204 return result;
205 break;
206
207 case LIRC_GET_LENGTH:
208 return -ENOSYS;
209 break;
210
211 case LIRC_SET_SEND_DUTY_CYCLE:
212 result = get_user(ivalue, (unsigned int *) arg);
213 if (result)
214 return result;
215
216 if (ivalue <= 0 || ivalue > 100) {
217 dev_err(lirc_rx51->dev, ": invalid duty cycle %d\n",
218 ivalue);
219 return -EINVAL;
220 }
221
222 lirc_rx51->duty_cycle = ivalue;
223 break;
224
225 case LIRC_SET_SEND_CARRIER:
226 result = get_user(ivalue, (unsigned int *) arg);
227 if (result)
228 return result;
229
230 if (ivalue > 500000 || ivalue < 20000) {
231 dev_err(lirc_rx51->dev, ": invalid carrier freq %d\n",
232 ivalue);
233 return -EINVAL;
234 }
235
236 lirc_rx51->freq = ivalue;
237 break;
238
239 case LIRC_GET_FEATURES:
240 result = put_user(LIRC_RX51_DRIVER_FEATURES,
241 (unsigned long *) arg);
242 if (result)
243 return result;
244 break;
245
246 default:
247 return -ENOIOCTLCMD;
248 }
249
250 return 0;
251}
252 158
253static int lirc_rx51_open(struct inode *inode, struct file *file) 159 if (test_and_set_bit(1, &ir_rx51->device_is_open))
254{
255 struct lirc_rx51 *lirc_rx51 = lirc_get_pdata(file);
256 BUG_ON(!lirc_rx51);
257
258 file->private_data = lirc_rx51;
259
260 if (test_and_set_bit(1, &lirc_rx51->device_is_open))
261 return -EBUSY; 160 return -EBUSY;
262 161
263 lirc_rx51->pwm = pwm_get(lirc_rx51->dev, NULL); 162 ir_rx51->pwm = pwm_get(ir_rx51->dev, NULL);
264 if (IS_ERR(lirc_rx51->pwm)) { 163 if (IS_ERR(ir_rx51->pwm)) {
265 int res = PTR_ERR(lirc_rx51->pwm); 164 int res = PTR_ERR(ir_rx51->pwm);
266 165
267 dev_err(lirc_rx51->dev, "pwm_get failed: %d\n", res); 166 dev_err(ir_rx51->dev, "pwm_get failed: %d\n", res);
268 return res; 167 return res;
269 } 168 }
270 169
271 return 0; 170 return 0;
272} 171}
273 172
274static int lirc_rx51_release(struct inode *inode, struct file *file) 173static void ir_rx51_release(struct rc_dev *dev)
275{ 174{
276 struct lirc_rx51 *lirc_rx51 = file->private_data; 175 struct ir_rx51 *ir_rx51 = dev->priv;
277
278 hrtimer_cancel(&lirc_rx51->timer);
279 lirc_rx51_off(lirc_rx51);
280 pwm_put(lirc_rx51->pwm);
281 176
282 clear_bit(1, &lirc_rx51->device_is_open); 177 hrtimer_cancel(&ir_rx51->timer);
178 ir_rx51_off(ir_rx51);
179 pwm_put(ir_rx51->pwm);
283 180
284 return 0; 181 clear_bit(1, &ir_rx51->device_is_open);
285} 182}
286 183
287static struct lirc_rx51 lirc_rx51 = { 184static struct ir_rx51 ir_rx51 = {
288 .duty_cycle = 50, 185 .duty_cycle = 50,
289 .wbuf_index = -1, 186 .wbuf_index = -1,
290}; 187};
291 188
292static const struct file_operations lirc_fops = { 189static int ir_rx51_set_duty_cycle(struct rc_dev *dev, u32 duty)
293 .owner = THIS_MODULE, 190{
294 .write = lirc_rx51_write, 191 struct ir_rx51 *ir_rx51 = dev->priv;
295 .unlocked_ioctl = lirc_rx51_ioctl,
296 .read = lirc_dev_fop_read,
297 .poll = lirc_dev_fop_poll,
298 .open = lirc_rx51_open,
299 .release = lirc_rx51_release,
300};
301 192
302static struct lirc_driver lirc_rx51_driver = { 193 ir_rx51->duty_cycle = duty;
303 .name = DRIVER_NAME, 194
304 .minor = -1, 195 return 0;
305 .code_length = 1, 196}
306 .data = &lirc_rx51, 197
307 .fops = &lirc_fops, 198static int ir_rx51_set_tx_carrier(struct rc_dev *dev, u32 carrier)
308 .owner = THIS_MODULE, 199{
309}; 200 struct ir_rx51 *ir_rx51 = dev->priv;
201
202 if (carrier > 500000 || carrier < 20000)
203 return -EINVAL;
204
205 ir_rx51->freq = carrier;
206
207 return 0;
208}
310 209
311#ifdef CONFIG_PM 210#ifdef CONFIG_PM
312 211
313static int lirc_rx51_suspend(struct platform_device *dev, pm_message_t state) 212static int ir_rx51_suspend(struct platform_device *dev, pm_message_t state)
314{ 213{
315 /* 214 /*
316 * In case the device is still open, do not suspend. Normally 215 * In case the device is still open, do not suspend. Normally
@@ -320,34 +219,34 @@ static int lirc_rx51_suspend(struct platform_device *dev, pm_message_t state)
320 * were in a middle of a transmit. Thus, we defer any suspend 219 * were in a middle of a transmit. Thus, we defer any suspend
321 * actions until transmit has completed. 220 * actions until transmit has completed.
322 */ 221 */
323 if (test_and_set_bit(1, &lirc_rx51.device_is_open)) 222 if (test_and_set_bit(1, &ir_rx51.device_is_open))
324 return -EAGAIN; 223 return -EAGAIN;
325 224
326 clear_bit(1, &lirc_rx51.device_is_open); 225 clear_bit(1, &ir_rx51.device_is_open);
327 226
328 return 0; 227 return 0;
329} 228}
330 229
331static int lirc_rx51_resume(struct platform_device *dev) 230static int ir_rx51_resume(struct platform_device *dev)
332{ 231{
333 return 0; 232 return 0;
334} 233}
335 234
336#else 235#else
337 236
338#define lirc_rx51_suspend NULL 237#define ir_rx51_suspend NULL
339#define lirc_rx51_resume NULL 238#define ir_rx51_resume NULL
340 239
341#endif /* CONFIG_PM */ 240#endif /* CONFIG_PM */
342 241
343static int lirc_rx51_probe(struct platform_device *dev) 242static int ir_rx51_probe(struct platform_device *dev)
344{ 243{
345 struct pwm_device *pwm; 244 struct pwm_device *pwm;
245 struct rc_dev *rcdev;
346 246
347 lirc_rx51_driver.features = LIRC_RX51_DRIVER_FEATURES; 247 ir_rx51.pdata = dev->dev.platform_data;
348 lirc_rx51.pdata = dev->dev.platform_data;
349 248
350 if (!lirc_rx51.pdata) { 249 if (!ir_rx51.pdata) {
351 dev_err(&dev->dev, "Platform Data is missing\n"); 250 dev_err(&dev->dev, "Platform Data is missing\n");
352 return -ENXIO; 251 return -ENXIO;
353 } 252 }
@@ -362,51 +261,56 @@ static int lirc_rx51_probe(struct platform_device *dev)
362 } 261 }
363 262
364 /* Use default, in case userspace does not set the carrier */ 263 /* Use default, in case userspace does not set the carrier */
365 lirc_rx51.freq = DIV_ROUND_CLOSEST(pwm_get_period(pwm), NSEC_PER_SEC); 264 ir_rx51.freq = DIV_ROUND_CLOSEST(pwm_get_period(pwm), NSEC_PER_SEC);
366 pwm_put(pwm); 265 pwm_put(pwm);
367 266
368 hrtimer_init(&lirc_rx51.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 267 hrtimer_init(&ir_rx51.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
369 lirc_rx51.timer.function = lirc_rx51_timer_cb; 268 ir_rx51.timer.function = ir_rx51_timer_cb;
370 269
371 lirc_rx51.dev = &dev->dev; 270 ir_rx51.dev = &dev->dev;
372 lirc_rx51_driver.dev = &dev->dev;
373 lirc_rx51_driver.minor = lirc_register_driver(&lirc_rx51_driver);
374 init_waitqueue_head(&lirc_rx51.wqueue);
375 271
376 if (lirc_rx51_driver.minor < 0) { 272 rcdev = devm_rc_allocate_device(&dev->dev, RC_DRIVER_IR_RAW_TX);
377 dev_err(lirc_rx51.dev, ": lirc_register_driver failed: %d\n", 273 if (!rcdev)
378 lirc_rx51_driver.minor); 274 return -ENOMEM;
379 return lirc_rx51_driver.minor;
380 }
381 275
382 return 0; 276 rcdev->priv = &ir_rx51;
277 rcdev->open = ir_rx51_open;
278 rcdev->close = ir_rx51_release;
279 rcdev->tx_ir = ir_rx51_tx;
280 rcdev->s_tx_duty_cycle = ir_rx51_set_duty_cycle;
281 rcdev->s_tx_carrier = ir_rx51_set_tx_carrier;
282 rcdev->driver_name = KBUILD_MODNAME;
283
284 ir_rx51.rcdev = rcdev;
285
286 return devm_rc_register_device(&dev->dev, ir_rx51.rcdev);
383} 287}
384 288
385static int lirc_rx51_remove(struct platform_device *dev) 289static int ir_rx51_remove(struct platform_device *dev)
386{ 290{
387 return lirc_unregister_driver(lirc_rx51_driver.minor); 291 return 0;
388} 292}
389 293
390static const struct of_device_id lirc_rx51_match[] = { 294static const struct of_device_id ir_rx51_match[] = {
391 { 295 {
392 .compatible = "nokia,n900-ir", 296 .compatible = "nokia,n900-ir",
393 }, 297 },
394 {}, 298 {},
395}; 299};
396MODULE_DEVICE_TABLE(of, lirc_rx51_match); 300MODULE_DEVICE_TABLE(of, ir_rx51_match);
397 301
398struct platform_driver lirc_rx51_platform_driver = { 302static struct platform_driver ir_rx51_platform_driver = {
399 .probe = lirc_rx51_probe, 303 .probe = ir_rx51_probe,
400 .remove = lirc_rx51_remove, 304 .remove = ir_rx51_remove,
401 .suspend = lirc_rx51_suspend, 305 .suspend = ir_rx51_suspend,
402 .resume = lirc_rx51_resume, 306 .resume = ir_rx51_resume,
403 .driver = { 307 .driver = {
404 .name = DRIVER_NAME, 308 .name = KBUILD_MODNAME,
405 .of_match_table = of_match_ptr(lirc_rx51_match), 309 .of_match_table = of_match_ptr(ir_rx51_match),
406 }, 310 },
407}; 311};
408module_platform_driver(lirc_rx51_platform_driver); 312module_platform_driver(ir_rx51_platform_driver);
409 313
410MODULE_DESCRIPTION("LIRC TX driver for Nokia RX51"); 314MODULE_DESCRIPTION("IR TX driver for Nokia RX51");
411MODULE_AUTHOR("Nokia Corporation"); 315MODULE_AUTHOR("Nokia Corporation");
412MODULE_LICENSE("GPL"); 316MODULE_LICENSE("GPL");
diff --git a/drivers/media/rc/ir-sanyo-decoder.c b/drivers/media/rc/ir-sanyo-decoder.c
index b07d9caebeb1..520bb77dcb62 100644
--- a/drivers/media/rc/ir-sanyo-decoder.c
+++ b/drivers/media/rc/ir-sanyo-decoder.c
@@ -176,9 +176,52 @@ static int ir_sanyo_decode(struct rc_dev *dev, struct ir_raw_event ev)
176 return -EINVAL; 176 return -EINVAL;
177} 177}
178 178
179static const struct ir_raw_timings_pd ir_sanyo_timings = {
180 .header_pulse = SANYO_HEADER_PULSE,
181 .header_space = SANYO_HEADER_SPACE,
182 .bit_pulse = SANYO_BIT_PULSE,
183 .bit_space[0] = SANYO_BIT_0_SPACE,
184 .bit_space[1] = SANYO_BIT_1_SPACE,
185 .trailer_pulse = SANYO_TRAILER_PULSE,
186 .trailer_space = SANYO_TRAILER_SPACE,
187 .msb_first = 1,
188};
189
190/**
191 * ir_sanyo_encode() - Encode a scancode as a stream of raw events
192 *
193 * @protocol: protocol to encode
194 * @scancode: scancode to encode
195 * @events: array of raw ir events to write into
196 * @max: maximum size of @events
197 *
198 * Returns: The number of events written.
199 * -ENOBUFS if there isn't enough space in the array to fit the
200 * encoding. In this case all @max events will have been written.
201 */
202static int ir_sanyo_encode(enum rc_type protocol, u32 scancode,
203 struct ir_raw_event *events, unsigned int max)
204{
205 struct ir_raw_event *e = events;
206 int ret;
207 u64 raw;
208
209 raw = ((u64)(bitrev16(scancode >> 8) & 0xfff8) << (8 + 8 + 13 - 3)) |
210 ((u64)(bitrev16(~scancode >> 8) & 0xfff8) << (8 + 8 + 0 - 3)) |
211 ((bitrev8(scancode) & 0xff) << 8) |
212 (bitrev8(~scancode) & 0xff);
213
214 ret = ir_raw_gen_pd(&e, max, &ir_sanyo_timings, SANYO_NBITS, raw);
215 if (ret < 0)
216 return ret;
217
218 return e - events;
219}
220
179static struct ir_raw_handler sanyo_handler = { 221static struct ir_raw_handler sanyo_handler = {
180 .protocols = RC_BIT_SANYO, 222 .protocols = RC_BIT_SANYO,
181 .decode = ir_sanyo_decode, 223 .decode = ir_sanyo_decode,
224 .encode = ir_sanyo_encode,
182}; 225};
183 226
184static int __init ir_sanyo_decode_init(void) 227static int __init ir_sanyo_decode_init(void)
diff --git a/drivers/media/rc/ir-sharp-decoder.c b/drivers/media/rc/ir-sharp-decoder.c
index 317677f06f2c..b47e89e2c1bd 100644
--- a/drivers/media/rc/ir-sharp-decoder.c
+++ b/drivers/media/rc/ir-sharp-decoder.c
@@ -173,9 +173,59 @@ static int ir_sharp_decode(struct rc_dev *dev, struct ir_raw_event ev)
173 return -EINVAL; 173 return -EINVAL;
174} 174}
175 175
176static const struct ir_raw_timings_pd ir_sharp_timings = {
177 .header_pulse = 0,
178 .header_space = 0,
179 .bit_pulse = SHARP_BIT_PULSE,
180 .bit_space[0] = SHARP_BIT_0_PERIOD,
181 .bit_space[1] = SHARP_BIT_1_PERIOD,
182 .trailer_pulse = SHARP_BIT_PULSE,
183 .trailer_space = SHARP_ECHO_SPACE,
184 .msb_first = 1,
185};
186
187/**
188 * ir_sharp_encode() - Encode a scancode as a stream of raw events
189 *
190 * @protocol: protocol to encode
191 * @scancode: scancode to encode
192 * @events: array of raw ir events to write into
193 * @max: maximum size of @events
194 *
195 * Returns: The number of events written.
196 * -ENOBUFS if there isn't enough space in the array to fit the
197 * encoding. In this case all @max events will have been written.
198 */
199static int ir_sharp_encode(enum rc_type protocol, u32 scancode,
200 struct ir_raw_event *events, unsigned int max)
201{
202 struct ir_raw_event *e = events;
203 int ret;
204 u32 raw;
205
206 raw = (((bitrev8(scancode >> 8) >> 3) << 8) & 0x1f00) |
207 bitrev8(scancode);
208 ret = ir_raw_gen_pd(&e, max, &ir_sharp_timings, SHARP_NBITS,
209 (raw << 2) | 2);
210 if (ret < 0)
211 return ret;
212
213 max -= ret;
214
215 raw = (((bitrev8(scancode >> 8) >> 3) << 8) & 0x1f00) |
216 bitrev8(~scancode);
217 ret = ir_raw_gen_pd(&e, max, &ir_sharp_timings, SHARP_NBITS,
218 (raw << 2) | 1);
219 if (ret < 0)
220 return ret;
221
222 return e - events;
223}
224
176static struct ir_raw_handler sharp_handler = { 225static struct ir_raw_handler sharp_handler = {
177 .protocols = RC_BIT_SHARP, 226 .protocols = RC_BIT_SHARP,
178 .decode = ir_sharp_decode, 227 .decode = ir_sharp_decode,
228 .encode = ir_sharp_encode,
179}; 229};
180 230
181static int __init ir_sharp_decode_init(void) 231static int __init ir_sharp_decode_init(void)
diff --git a/drivers/media/rc/ir-sony-decoder.c b/drivers/media/rc/ir-sony-decoder.c
index baa972c76e0e..355fa8198f5a 100644
--- a/drivers/media/rc/ir-sony-decoder.c
+++ b/drivers/media/rc/ir-sony-decoder.c
@@ -169,9 +169,57 @@ finish_state_machine:
169 return 0; 169 return 0;
170} 170}
171 171
172static const struct ir_raw_timings_pl ir_sony_timings = {
173 .header_pulse = SONY_HEADER_PULSE,
174 .bit_space = SONY_BIT_SPACE,
175 .bit_pulse[0] = SONY_BIT_0_PULSE,
176 .bit_pulse[1] = SONY_BIT_1_PULSE,
177 .trailer_space = SONY_TRAILER_SPACE + SONY_BIT_SPACE,
178 .msb_first = 0,
179};
180
181/**
182 * ir_sony_encode() - Encode a scancode as a stream of raw events
183 *
184 * @protocol: protocol to encode
185 * @scancode: scancode to encode
186 * @events: array of raw ir events to write into
187 * @max: maximum size of @events
188 *
189 * Returns: The number of events written.
190 * -ENOBUFS if there isn't enough space in the array to fit the
191 * encoding. In this case all @max events will have been written.
192 */
193static int ir_sony_encode(enum rc_type protocol, u32 scancode,
194 struct ir_raw_event *events, unsigned int max)
195{
196 struct ir_raw_event *e = events;
197 u32 raw, len;
198 int ret;
199
200 if (protocol == RC_TYPE_SONY12) {
201 raw = (scancode & 0x7f) | ((scancode & 0x1f0000) >> 9);
202 len = 12;
203 } else if (protocol == RC_TYPE_SONY15) {
204 raw = (scancode & 0x7f) | ((scancode & 0xff0000) >> 9);
205 len = 15;
206 } else {
207 raw = (scancode & 0x7f) | ((scancode & 0x1f0000) >> 9) |
208 ((scancode & 0xff00) << 4);
209 len = 20;
210 }
211
212 ret = ir_raw_gen_pl(&e, max, &ir_sony_timings, len, raw);
213 if (ret < 0)
214 return ret;
215
216 return e - events;
217}
218
172static struct ir_raw_handler sony_handler = { 219static struct ir_raw_handler sony_handler = {
173 .protocols = RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20, 220 .protocols = RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20,
174 .decode = ir_sony_decode, 221 .decode = ir_sony_decode,
222 .encode = ir_sony_encode,
175}; 223};
176 224
177static int __init ir_sony_decode_init(void) 225static int __init ir_sony_decode_init(void)
diff --git a/drivers/media/rc/ir-spi.c b/drivers/media/rc/ir-spi.c
new file mode 100644
index 000000000000..c8863f36686a
--- /dev/null
+++ b/drivers/media/rc/ir-spi.c
@@ -0,0 +1,199 @@
1/*
2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3 * Author: Andi Shyti <andi.shyti@samsung.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * SPI driven IR LED device driver
10 */
11
12#include <linux/delay.h>
13#include <linux/fs.h>
14#include <linux/module.h>
15#include <linux/mutex.h>
16#include <linux/of_gpio.h>
17#include <linux/regulator/consumer.h>
18#include <linux/spi/spi.h>
19#include <media/rc-core.h>
20
21#define IR_SPI_DRIVER_NAME "ir-spi"
22
23/* pulse value for different duty cycles */
24#define IR_SPI_PULSE_DC_50 0xff00
25#define IR_SPI_PULSE_DC_60 0xfc00
26#define IR_SPI_PULSE_DC_70 0xf800
27#define IR_SPI_PULSE_DC_75 0xf000
28#define IR_SPI_PULSE_DC_80 0xc000
29#define IR_SPI_PULSE_DC_90 0x8000
30
31#define IR_SPI_DEFAULT_FREQUENCY 38000
32#define IR_SPI_BIT_PER_WORD 8
33#define IR_SPI_MAX_BUFSIZE 4096
34
35struct ir_spi_data {
36 u32 freq;
37 u8 duty_cycle;
38 bool negated;
39
40 u16 tx_buf[IR_SPI_MAX_BUFSIZE];
41 u16 pulse;
42 u16 space;
43
44 struct rc_dev *rc;
45 struct spi_device *spi;
46 struct regulator *regulator;
47};
48
49static int ir_spi_tx(struct rc_dev *dev,
50 unsigned int *buffer, unsigned int count)
51{
52 int i;
53 int ret;
54 unsigned int len = 0;
55 struct ir_spi_data *idata = dev->priv;
56 struct spi_transfer xfer;
57
58 /* convert the pulse/space signal to raw binary signal */
59 for (i = 0; i < count; i++) {
60 int j;
61 u16 val = ((i + 1) % 2) ? idata->pulse : idata->space;
62
63 if (len + buffer[i] >= IR_SPI_MAX_BUFSIZE)
64 return -EINVAL;
65
66 /*
67 * the first value in buffer is a pulse, so that 0, 2, 4, ...
68 * contain a pulse duration. On the contrary, 1, 3, 5, ...
69 * contain a space duration.
70 */
71 val = (i % 2) ? idata->space : idata->pulse;
72 for (j = 0; j < buffer[i]; j++)
73 idata->tx_buf[len++] = val;
74 }
75
76 memset(&xfer, 0, sizeof(xfer));
77
78 xfer.speed_hz = idata->freq;
79 xfer.len = len * sizeof(*idata->tx_buf);
80 xfer.tx_buf = idata->tx_buf;
81
82 ret = regulator_enable(idata->regulator);
83 if (ret)
84 return ret;
85
86 ret = spi_sync_transfer(idata->spi, &xfer, 1);
87 if (ret)
88 dev_err(&idata->spi->dev, "unable to deliver the signal\n");
89
90 regulator_disable(idata->regulator);
91
92 return ret ? ret : count;
93}
94
95static int ir_spi_set_tx_carrier(struct rc_dev *dev, u32 carrier)
96{
97 struct ir_spi_data *idata = dev->priv;
98
99 if (!carrier)
100 return -EINVAL;
101
102 idata->freq = carrier;
103
104 return 0;
105}
106
107static int ir_spi_set_duty_cycle(struct rc_dev *dev, u32 duty_cycle)
108{
109 struct ir_spi_data *idata = dev->priv;
110
111 if (duty_cycle >= 90)
112 idata->pulse = IR_SPI_PULSE_DC_90;
113 else if (duty_cycle >= 80)
114 idata->pulse = IR_SPI_PULSE_DC_80;
115 else if (duty_cycle >= 75)
116 idata->pulse = IR_SPI_PULSE_DC_75;
117 else if (duty_cycle >= 70)
118 idata->pulse = IR_SPI_PULSE_DC_70;
119 else if (duty_cycle >= 60)
120 idata->pulse = IR_SPI_PULSE_DC_60;
121 else
122 idata->pulse = IR_SPI_PULSE_DC_50;
123
124 if (idata->negated) {
125 idata->pulse = ~idata->pulse;
126 idata->space = 0xffff;
127 } else {
128 idata->space = 0;
129 }
130
131 return 0;
132}
133
134static int ir_spi_probe(struct spi_device *spi)
135{
136 int ret;
137 u8 dc;
138 struct ir_spi_data *idata;
139
140 idata = devm_kzalloc(&spi->dev, sizeof(*idata), GFP_KERNEL);
141 if (!idata)
142 return -ENOMEM;
143
144 idata->regulator = devm_regulator_get(&spi->dev, "irda_regulator");
145 if (IS_ERR(idata->regulator))
146 return PTR_ERR(idata->regulator);
147
148 idata->rc = devm_rc_allocate_device(&spi->dev, RC_DRIVER_IR_RAW_TX);
149 if (!idata->rc)
150 return -ENOMEM;
151
152 idata->rc->tx_ir = ir_spi_tx;
153 idata->rc->s_tx_carrier = ir_spi_set_tx_carrier;
154 idata->rc->s_tx_duty_cycle = ir_spi_set_duty_cycle;
155 idata->rc->driver_name = IR_SPI_DRIVER_NAME;
156 idata->rc->priv = idata;
157 idata->spi = spi;
158
159 idata->negated = of_property_read_bool(spi->dev.of_node,
160 "led-active-low");
161 ret = of_property_read_u8(spi->dev.of_node, "duty-cycle", &dc);
162 if (ret)
163 dc = 50;
164
165 /* ir_spi_set_duty_cycle cannot fail,
166 * it returns int to be compatible with the
167 * rc->s_tx_duty_cycle function
168 */
169 ir_spi_set_duty_cycle(idata->rc, dc);
170
171 idata->freq = IR_SPI_DEFAULT_FREQUENCY;
172
173 return devm_rc_register_device(&spi->dev, idata->rc);
174}
175
176static int ir_spi_remove(struct spi_device *spi)
177{
178 return 0;
179}
180
181static const struct of_device_id ir_spi_of_match[] = {
182 { .compatible = "ir-spi-led" },
183 {},
184};
185
186static struct spi_driver ir_spi_driver = {
187 .probe = ir_spi_probe,
188 .remove = ir_spi_remove,
189 .driver = {
190 .name = IR_SPI_DRIVER_NAME,
191 .of_match_table = ir_spi_of_match,
192 },
193};
194
195module_spi_driver(ir_spi_driver);
196
197MODULE_AUTHOR("Andi Shyti <andi.shyti@samsung.com>");
198MODULE_DESCRIPTION("SPI IR LED");
199MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c
index 367b28bed627..e9e4befbbebb 100644
--- a/drivers/media/rc/ite-cir.c
+++ b/drivers/media/rc/ite-cir.c
@@ -13,11 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details. 14 * General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 * USA.
20 *
21 * Inspired by the original lirc_it87 and lirc_ite8709 drivers, on top of the 16 * Inspired by the original lirc_it87 and lirc_ite8709 drivers, on top of the
22 * skeleton provided by the nuvoton-cir driver. 17 * skeleton provided by the nuvoton-cir driver.
23 * 18 *
@@ -1470,7 +1465,7 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
1470 return ret; 1465 return ret;
1471 1466
1472 /* input device for IR remote (and tx) */ 1467 /* input device for IR remote (and tx) */
1473 rdev = rc_allocate_device(); 1468 rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
1474 if (!rdev) 1469 if (!rdev)
1475 goto exit_free_dev_rdev; 1470 goto exit_free_dev_rdev;
1476 itdev->rdev = rdev; 1471 itdev->rdev = rdev;
@@ -1561,8 +1556,7 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
1561 1556
1562 /* set up ir-core props */ 1557 /* set up ir-core props */
1563 rdev->priv = itdev; 1558 rdev->priv = itdev;
1564 rdev->driver_type = RC_DRIVER_IR_RAW; 1559 rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
1565 rdev->allowed_protocols = RC_BIT_ALL;
1566 rdev->open = ite_open; 1560 rdev->open = ite_open;
1567 rdev->close = ite_close; 1561 rdev->close = ite_close;
1568 rdev->s_idle = ite_s_idle; 1562 rdev->s_idle = ite_s_idle;
diff --git a/drivers/media/rc/ite-cir.h b/drivers/media/rc/ite-cir.h
index aa899a0b9750..0e8ebc880d1f 100644
--- a/drivers/media/rc/ite-cir.h
+++ b/drivers/media/rc/ite-cir.h
@@ -12,11 +12,6 @@
12 * WITHOUT ANY WARRANTY; without even the implied warranty of 12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details. 14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 * USA.
20 */ 15 */
21 16
22/* platform driver name to register */ 17/* platform driver name to register */
diff --git a/drivers/media/rc/keymaps/Makefile b/drivers/media/rc/keymaps/Makefile
index d7b13fae1267..ffe9e612f8d6 100644
--- a/drivers/media/rc/keymaps/Makefile
+++ b/drivers/media/rc/keymaps/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
21 rc-cec.o \ 21 rc-cec.o \
22 rc-cinergy-1400.o \ 22 rc-cinergy-1400.o \
23 rc-cinergy.o \ 23 rc-cinergy.o \
24 rc-d680-dmb.o \
24 rc-delock-61959.o \ 25 rc-delock-61959.o \
25 rc-dib0700-nec.o \ 26 rc-dib0700-nec.o \
26 rc-dib0700-rc5.o \ 27 rc-dib0700-rc5.o \
@@ -31,6 +32,8 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
31 rc-dntv-live-dvbt-pro.o \ 32 rc-dntv-live-dvbt-pro.o \
32 rc-dtt200u.o \ 33 rc-dtt200u.o \
33 rc-dvbsky.o \ 34 rc-dvbsky.o \
35 rc-dvico-mce.o \
36 rc-dvico-portable.o \
34 rc-em-terratec.o \ 37 rc-em-terratec.o \
35 rc-encore-enltv2.o \ 38 rc-encore-enltv2.o \
36 rc-encore-enltv.o \ 39 rc-encore-enltv.o \
@@ -41,6 +44,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
41 rc-flyvideo.o \ 44 rc-flyvideo.o \
42 rc-fusionhdtv-mce.o \ 45 rc-fusionhdtv-mce.o \
43 rc-gadmei-rm008z.o \ 46 rc-gadmei-rm008z.o \
47 rc-geekbox.o \
44 rc-genius-tvgo-a11mce.o \ 48 rc-genius-tvgo-a11mce.o \
45 rc-gotview7135.o \ 49 rc-gotview7135.o \
46 rc-imon-mce.o \ 50 rc-imon-mce.o \
diff --git a/drivers/media/rc/keymaps/rc-d680-dmb.c b/drivers/media/rc/keymaps/rc-d680-dmb.c
new file mode 100644
index 000000000000..bb5745d29d8a
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-d680-dmb.c
@@ -0,0 +1,75 @@
1/*
2 * keymap imported from cxusb.c
3 *
4 * Copyright (C) 2016 Sean Young
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 as published by
8 * the Free Software Foundation; version 2.
9 */
10
11#include <media/rc-map.h>
12#include <linux/module.h>
13
14static struct rc_map_table rc_map_d680_dmb_table[] = {
15 { 0x0038, KEY_SWITCHVIDEOMODE }, /* TV/AV */
16 { 0x080c, KEY_ZOOM },
17 { 0x0800, KEY_0 },
18 { 0x0001, KEY_1 },
19 { 0x0802, KEY_2 },
20 { 0x0003, KEY_3 },
21 { 0x0804, KEY_4 },
22 { 0x0005, KEY_5 },
23 { 0x0806, KEY_6 },
24 { 0x0007, KEY_7 },
25 { 0x0808, KEY_8 },
26 { 0x0009, KEY_9 },
27 { 0x000a, KEY_MUTE },
28 { 0x0829, KEY_BACK },
29 { 0x0012, KEY_CHANNELUP },
30 { 0x0813, KEY_CHANNELDOWN },
31 { 0x002b, KEY_VOLUMEUP },
32 { 0x082c, KEY_VOLUMEDOWN },
33 { 0x0020, KEY_UP },
34 { 0x0821, KEY_DOWN },
35 { 0x0011, KEY_LEFT },
36 { 0x0810, KEY_RIGHT },
37 { 0x000d, KEY_OK },
38 { 0x081f, KEY_RECORD },
39 { 0x0017, KEY_PLAYPAUSE },
40 { 0x0816, KEY_PLAYPAUSE },
41 { 0x000b, KEY_STOP },
42 { 0x0827, KEY_FASTFORWARD },
43 { 0x0026, KEY_REWIND },
44 { 0x081e, KEY_UNKNOWN }, /* Time Shift */
45 { 0x000e, KEY_UNKNOWN }, /* Snapshot */
46 { 0x082d, KEY_UNKNOWN }, /* Mouse Cursor */
47 { 0x000f, KEY_UNKNOWN }, /* Minimize/Maximize */
48 { 0x0814, KEY_SHUFFLE }, /* Shuffle */
49 { 0x0025, KEY_POWER },
50};
51
52static struct rc_map_list d680_dmb_map = {
53 .map = {
54 .scan = rc_map_d680_dmb_table,
55 .size = ARRAY_SIZE(rc_map_d680_dmb_table),
56 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */
57 .name = RC_MAP_D680_DMB,
58 }
59};
60
61static int __init init_rc_map_d680_dmb(void)
62{
63 return rc_map_register(&d680_dmb_map);
64}
65
66static void __exit exit_rc_map_d680_dmb(void)
67{
68 rc_map_unregister(&d680_dmb_map);
69}
70
71module_init(init_rc_map_d680_dmb)
72module_exit(exit_rc_map_d680_dmb)
73
74MODULE_LICENSE("GPL");
75MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-dvico-mce.c b/drivers/media/rc/keymaps/rc-dvico-mce.c
new file mode 100644
index 000000000000..e5f098c50235
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-dvico-mce.c
@@ -0,0 +1,85 @@
1/*
2 * keymap imported from cxusb.c
3 *
4 * Copyright (C) 2016 Sean Young
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 as published by
8 * the Free Software Foundation; version 2.
9 */
10
11#include <media/rc-map.h>
12#include <linux/module.h>
13
14static struct rc_map_table rc_map_dvico_mce_table[] = {
15 { 0xfe02, KEY_TV },
16 { 0xfe0e, KEY_MP3 },
17 { 0xfe1a, KEY_DVD },
18 { 0xfe1e, KEY_FAVORITES },
19 { 0xfe16, KEY_SETUP },
20 { 0xfe46, KEY_POWER2 },
21 { 0xfe0a, KEY_EPG },
22 { 0xfe49, KEY_BACK },
23 { 0xfe4d, KEY_MENU },
24 { 0xfe51, KEY_UP },
25 { 0xfe5b, KEY_LEFT },
26 { 0xfe5f, KEY_RIGHT },
27 { 0xfe53, KEY_DOWN },
28 { 0xfe5e, KEY_OK },
29 { 0xfe59, KEY_INFO },
30 { 0xfe55, KEY_TAB },
31 { 0xfe0f, KEY_PREVIOUSSONG },/* Replay */
32 { 0xfe12, KEY_NEXTSONG }, /* Skip */
33 { 0xfe42, KEY_ENTER }, /* Windows/Start */
34 { 0xfe15, KEY_VOLUMEUP },
35 { 0xfe05, KEY_VOLUMEDOWN },
36 { 0xfe11, KEY_CHANNELUP },
37 { 0xfe09, KEY_CHANNELDOWN },
38 { 0xfe52, KEY_CAMERA },
39 { 0xfe5a, KEY_TUNER }, /* Live */
40 { 0xfe19, KEY_OPEN },
41 { 0xfe0b, KEY_1 },
42 { 0xfe17, KEY_2 },
43 { 0xfe1b, KEY_3 },
44 { 0xfe07, KEY_4 },
45 { 0xfe50, KEY_5 },
46 { 0xfe54, KEY_6 },
47 { 0xfe48, KEY_7 },
48 { 0xfe4c, KEY_8 },
49 { 0xfe58, KEY_9 },
50 { 0xfe13, KEY_ANGLE }, /* Aspect */
51 { 0xfe03, KEY_0 },
52 { 0xfe1f, KEY_ZOOM },
53 { 0xfe43, KEY_REWIND },
54 { 0xfe47, KEY_PLAYPAUSE },
55 { 0xfe4f, KEY_FASTFORWARD },
56 { 0xfe57, KEY_MUTE },
57 { 0xfe0d, KEY_STOP },
58 { 0xfe01, KEY_RECORD },
59 { 0xfe4e, KEY_POWER },
60};
61
62static struct rc_map_list dvico_mce_map = {
63 .map = {
64 .scan = rc_map_dvico_mce_table,
65 .size = ARRAY_SIZE(rc_map_dvico_mce_table),
66 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */
67 .name = RC_MAP_DVICO_MCE,
68 }
69};
70
71static int __init init_rc_map_dvico_mce(void)
72{
73 return rc_map_register(&dvico_mce_map);
74}
75
76static void __exit exit_rc_map_dvico_mce(void)
77{
78 rc_map_unregister(&dvico_mce_map);
79}
80
81module_init(init_rc_map_dvico_mce)
82module_exit(exit_rc_map_dvico_mce)
83
84MODULE_LICENSE("GPL");
85MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-dvico-portable.c b/drivers/media/rc/keymaps/rc-dvico-portable.c
new file mode 100644
index 000000000000..94ceeee94b3f
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-dvico-portable.c
@@ -0,0 +1,76 @@
1/*
2 * keymap imported from cxusb.c
3 *
4 * Copyright (C) 2016 Sean Young
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 as published by
8 * the Free Software Foundation; version 2.
9 */
10
11#include <media/rc-map.h>
12#include <linux/module.h>
13
14static struct rc_map_table rc_map_dvico_portable_table[] = {
15 { 0xfc02, KEY_SETUP }, /* Profile */
16 { 0xfc43, KEY_POWER2 },
17 { 0xfc06, KEY_EPG },
18 { 0xfc5a, KEY_BACK },
19 { 0xfc05, KEY_MENU },
20 { 0xfc47, KEY_INFO },
21 { 0xfc01, KEY_TAB },
22 { 0xfc42, KEY_PREVIOUSSONG },/* Replay */
23 { 0xfc49, KEY_VOLUMEUP },
24 { 0xfc09, KEY_VOLUMEDOWN },
25 { 0xfc54, KEY_CHANNELUP },
26 { 0xfc0b, KEY_CHANNELDOWN },
27 { 0xfc16, KEY_CAMERA },
28 { 0xfc40, KEY_TUNER }, /* ATV/DTV */
29 { 0xfc45, KEY_OPEN },
30 { 0xfc19, KEY_1 },
31 { 0xfc18, KEY_2 },
32 { 0xfc1b, KEY_3 },
33 { 0xfc1a, KEY_4 },
34 { 0xfc58, KEY_5 },
35 { 0xfc59, KEY_6 },
36 { 0xfc15, KEY_7 },
37 { 0xfc14, KEY_8 },
38 { 0xfc17, KEY_9 },
39 { 0xfc44, KEY_ANGLE }, /* Aspect */
40 { 0xfc55, KEY_0 },
41 { 0xfc07, KEY_ZOOM },
42 { 0xfc0a, KEY_REWIND },
43 { 0xfc08, KEY_PLAYPAUSE },
44 { 0xfc4b, KEY_FASTFORWARD },
45 { 0xfc5b, KEY_MUTE },
46 { 0xfc04, KEY_STOP },
47 { 0xfc56, KEY_RECORD },
48 { 0xfc57, KEY_POWER },
49 { 0xfc41, KEY_UNKNOWN }, /* INPUT */
50 { 0xfc00, KEY_UNKNOWN }, /* HD */
51};
52
53static struct rc_map_list dvico_portable_map = {
54 .map = {
55 .scan = rc_map_dvico_portable_table,
56 .size = ARRAY_SIZE(rc_map_dvico_portable_table),
57 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */
58 .name = RC_MAP_DVICO_PORTABLE,
59 }
60};
61
62static int __init init_rc_map_dvico_portable(void)
63{
64 return rc_map_register(&dvico_portable_map);
65}
66
67static void __exit exit_rc_map_dvico_portable(void)
68{
69 rc_map_unregister(&dvico_portable_map);
70}
71
72module_init(init_rc_map_dvico_portable)
73module_exit(exit_rc_map_dvico_portable)
74
75MODULE_LICENSE("GPL");
76MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-geekbox.c b/drivers/media/rc/keymaps/rc-geekbox.c
new file mode 100644
index 000000000000..affc4c481888
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-geekbox.c
@@ -0,0 +1,55 @@
1/*
2 * Keytable for the GeekBox remote controller
3 *
4 * Copyright (C) 2017 Martin Blumenstingl <martin.blumenstingl@googlemail.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 * You should have received a copy of the GNU General Public License
11 * along with this program. If not, see <http://www.gnu.org/licenses/>.
12 */
13
14#include <media/rc-map.h>
15#include <linux/module.h>
16
17static struct rc_map_table geekbox[] = {
18 { 0x01, KEY_BACK },
19 { 0x02, KEY_DOWN },
20 { 0x03, KEY_UP },
21 { 0x07, KEY_OK },
22 { 0x0b, KEY_VOLUMEUP },
23 { 0x0e, KEY_LEFT },
24 { 0x13, KEY_MENU },
25 { 0x14, KEY_POWER },
26 { 0x1a, KEY_RIGHT },
27 { 0x48, KEY_HOME },
28 { 0x58, KEY_VOLUMEDOWN },
29 { 0x5c, KEY_SCREEN },
30};
31
32static struct rc_map_list geekbox_map = {
33 .map = {
34 .scan = geekbox,
35 .size = ARRAY_SIZE(geekbox),
36 .rc_type = RC_TYPE_NEC,
37 .name = RC_MAP_GEEKBOX,
38 }
39};
40
41static int __init init_rc_map_geekbox(void)
42{
43 return rc_map_register(&geekbox_map);
44}
45
46static void __exit exit_rc_map_geekbox(void)
47{
48 rc_map_unregister(&geekbox_map);
49}
50
51module_init(init_rc_map_geekbox)
52module_exit(exit_rc_map_geekbox)
53
54MODULE_LICENSE("GPL");
55MODULE_AUTHOR("Martin Blumenstingl <martin.blumenstingl@googlemail.com>");
diff --git a/drivers/media/rc/keymaps/rc-rc6-mce.c b/drivers/media/rc/keymaps/rc-rc6-mce.c
index ef4006fe4de0..5be567506bcd 100644
--- a/drivers/media/rc/keymaps/rc-rc6-mce.c
+++ b/drivers/media/rc/keymaps/rc-rc6-mce.c
@@ -86,6 +86,7 @@ static struct rc_map_table rc6_mce[] = {
86 { 0x800f045e, KEY_BLUE }, 86 { 0x800f045e, KEY_BLUE },
87 87
88 { 0x800f0465, KEY_POWER2 }, /* TV Power */ 88 { 0x800f0465, KEY_POWER2 }, /* TV Power */
89 { 0x800f0469, KEY_MESSENGER },
89 { 0x800f046e, KEY_PLAYPAUSE }, 90 { 0x800f046e, KEY_PLAYPAUSE },
90 { 0x800f046f, KEY_PLAYER }, /* Start media application (NEW) */ 91 { 0x800f046f, KEY_PLAYER }, /* Start media application (NEW) */
91 92
diff --git a/drivers/media/rc/keymaps/rc-technisat-usb2.c b/drivers/media/rc/keymaps/rc-technisat-usb2.c
index f9733bb289d6..02c9c243c060 100644
--- a/drivers/media/rc/keymaps/rc-technisat-usb2.c
+++ b/drivers/media/rc/keymaps/rc-technisat-usb2.c
@@ -13,10 +13,6 @@
13 * License, or (at your option) any later version. 13 * License, or (at your option) any later version.
14 * 14 *
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * THIS PROGRAM IS PROVIDED "AS IS" AND BOTH THE COPYRIGHT HOLDER AND 16 * THIS PROGRAM IS PROVIDED "AS IS" AND BOTH THE COPYRIGHT HOLDER AND
21 * TECHNISAT DIGITAL UK LTD DISCLAIM ALL WARRANTIES WITH REGARD TO 17 * TECHNISAT DIGITAL UK LTD DISCLAIM ALL WARRANTIES WITH REGARD TO
22 * THIS PROGRAM INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY OR 18 * THIS PROGRAM INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY OR
diff --git a/drivers/media/rc/keymaps/rc-tivo.c b/drivers/media/rc/keymaps/rc-tivo.c
index 454e06295692..5cc1b456e329 100644
--- a/drivers/media/rc/keymaps/rc-tivo.c
+++ b/drivers/media/rc/keymaps/rc-tivo.c
@@ -15,62 +15,62 @@
15 * Initial mapping is for the TiVo remote included in the Nero LiquidTV bundle, 15 * Initial mapping is for the TiVo remote included in the Nero LiquidTV bundle,
16 * which also ships with a TiVo-branded IR transceiver, supported by the mceusb 16 * which also ships with a TiVo-branded IR transceiver, supported by the mceusb
17 * driver. Note that the remote uses an NEC-ish protocol, but instead of having 17 * driver. Note that the remote uses an NEC-ish protocol, but instead of having
18 * a command/not_command pair, it has a vendor ID of 0xa10c, but some keys, the 18 * a command/not_command pair, it has a vendor ID of 0x3085, but some keys, the
19 * NEC extended checksums do pass, so the table presently has the intended 19 * NEC extended checksums do pass, so the table presently has the intended
20 * values and the checksum-passed versions for those keys. 20 * values and the checksum-passed versions for those keys.
21 */ 21 */
22static struct rc_map_table tivo[] = { 22static struct rc_map_table tivo[] = {
23 { 0xa10c900f, KEY_MEDIA }, /* TiVo Button */ 23 { 0x3085f009, KEY_MEDIA }, /* TiVo Button */
24 { 0xa10c0807, KEY_POWER2 }, /* TV Power */ 24 { 0x3085e010, KEY_POWER2 }, /* TV Power */
25 { 0xa10c8807, KEY_TV }, /* Live TV/Swap */ 25 { 0x3085e011, KEY_TV }, /* Live TV/Swap */
26 { 0xa10c2c03, KEY_VIDEO_NEXT }, /* TV Input */ 26 { 0x3085c034, KEY_VIDEO_NEXT }, /* TV Input */
27 { 0xa10cc807, KEY_INFO }, 27 { 0x3085e013, KEY_INFO },
28 { 0xa10cfa05, KEY_CYCLEWINDOWS }, /* Window */ 28 { 0x3085a05f, KEY_CYCLEWINDOWS }, /* Window */
29 { 0x0085305f, KEY_CYCLEWINDOWS }, 29 { 0x0085305f, KEY_CYCLEWINDOWS },
30 { 0xa10c6c03, KEY_EPG }, /* Guide */ 30 { 0x3085c036, KEY_EPG }, /* Guide */
31 31
32 { 0xa10c2807, KEY_UP }, 32 { 0x3085e014, KEY_UP },
33 { 0xa10c6807, KEY_DOWN }, 33 { 0x3085e016, KEY_DOWN },
34 { 0xa10ce807, KEY_LEFT }, 34 { 0x3085e017, KEY_LEFT },
35 { 0xa10ca807, KEY_RIGHT }, 35 { 0x3085e015, KEY_RIGHT },
36 36
37 { 0xa10c1807, KEY_SCROLLDOWN }, /* Red Thumbs Down */ 37 { 0x3085e018, KEY_SCROLLDOWN }, /* Red Thumbs Down */
38 { 0xa10c9807, KEY_SELECT }, 38 { 0x3085e019, KEY_SELECT },
39 { 0xa10c5807, KEY_SCROLLUP }, /* Green Thumbs Up */ 39 { 0x3085e01a, KEY_SCROLLUP }, /* Green Thumbs Up */
40 40
41 { 0xa10c3807, KEY_VOLUMEUP }, 41 { 0x3085e01c, KEY_VOLUMEUP },
42 { 0xa10cb807, KEY_VOLUMEDOWN }, 42 { 0x3085e01d, KEY_VOLUMEDOWN },
43 { 0xa10cd807, KEY_MUTE }, 43 { 0x3085e01b, KEY_MUTE },
44 { 0xa10c040b, KEY_RECORD }, 44 { 0x3085d020, KEY_RECORD },
45 { 0xa10c7807, KEY_CHANNELUP }, 45 { 0x3085e01e, KEY_CHANNELUP },
46 { 0xa10cf807, KEY_CHANNELDOWN }, 46 { 0x3085e01f, KEY_CHANNELDOWN },
47 { 0x0085301f, KEY_CHANNELDOWN }, 47 { 0x0085301f, KEY_CHANNELDOWN },
48 48
49 { 0xa10c840b, KEY_PLAY }, 49 { 0x3085d021, KEY_PLAY },
50 { 0xa10cc40b, KEY_PAUSE }, 50 { 0x3085d023, KEY_PAUSE },
51 { 0xa10ca40b, KEY_SLOW }, 51 { 0x3085d025, KEY_SLOW },
52 { 0xa10c440b, KEY_REWIND }, 52 { 0x3085d022, KEY_REWIND },
53 { 0xa10c240b, KEY_FASTFORWARD }, 53 { 0x3085d024, KEY_FASTFORWARD },
54 { 0xa10c640b, KEY_PREVIOUS }, 54 { 0x3085d026, KEY_PREVIOUS },
55 { 0xa10ce40b, KEY_NEXT }, /* ->| */ 55 { 0x3085d027, KEY_NEXT }, /* ->| */
56 56
57 { 0xa10c220d, KEY_ZOOM }, /* Aspect */ 57 { 0x3085b044, KEY_ZOOM }, /* Aspect */
58 { 0xa10c120d, KEY_STOP }, 58 { 0x3085b048, KEY_STOP },
59 { 0xa10c520d, KEY_DVD }, /* DVD Menu */ 59 { 0x3085b04a, KEY_DVD }, /* DVD Menu */
60 60
61 { 0xa10c140b, KEY_NUMERIC_1 }, 61 { 0x3085d028, KEY_NUMERIC_1 },
62 { 0xa10c940b, KEY_NUMERIC_2 }, 62 { 0x3085d029, KEY_NUMERIC_2 },
63 { 0xa10c540b, KEY_NUMERIC_3 }, 63 { 0x3085d02a, KEY_NUMERIC_3 },
64 { 0xa10cd40b, KEY_NUMERIC_4 }, 64 { 0x3085d02b, KEY_NUMERIC_4 },
65 { 0xa10c340b, KEY_NUMERIC_5 }, 65 { 0x3085d02c, KEY_NUMERIC_5 },
66 { 0xa10cb40b, KEY_NUMERIC_6 }, 66 { 0x3085d02d, KEY_NUMERIC_6 },
67 { 0xa10c740b, KEY_NUMERIC_7 }, 67 { 0x3085d02e, KEY_NUMERIC_7 },
68 { 0xa10cf40b, KEY_NUMERIC_8 }, 68 { 0x3085d02f, KEY_NUMERIC_8 },
69 { 0x0085302f, KEY_NUMERIC_8 }, 69 { 0x0085302f, KEY_NUMERIC_8 },
70 { 0xa10c0c03, KEY_NUMERIC_9 }, 70 { 0x3085c030, KEY_NUMERIC_9 },
71 { 0xa10c8c03, KEY_NUMERIC_0 }, 71 { 0x3085c031, KEY_NUMERIC_0 },
72 { 0xa10ccc03, KEY_ENTER }, 72 { 0x3085c033, KEY_ENTER },
73 { 0xa10c4c03, KEY_CLEAR }, 73 { 0x3085c032, KEY_CLEAR },
74}; 74};
75 75
76static struct rc_map_list tivo_map = { 76static struct rc_map_list tivo_map = {
diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
index 3854809e8531..a54ca531d8ef 100644
--- a/drivers/media/rc/lirc_dev.c
+++ b/drivers/media/rc/lirc_dev.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -472,7 +468,7 @@ int lirc_dev_fop_open(struct inode *inode, struct file *file)
472 if (retval) { 468 if (retval) {
473 module_put(cdev->owner); 469 module_put(cdev->owner);
474 ir->open--; 470 ir->open--;
475 } else { 471 } else if (ir->buf) {
476 lirc_buffer_clear(ir->buf); 472 lirc_buffer_clear(ir->buf);
477 } 473 }
478 if (ir->task) 474 if (ir->task)
@@ -582,7 +578,7 @@ long lirc_dev_fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
582 result = put_user(ir->d.features, (__u32 __user *)arg); 578 result = put_user(ir->d.features, (__u32 __user *)arg);
583 break; 579 break;
584 case LIRC_GET_REC_MODE: 580 case LIRC_GET_REC_MODE:
585 if (LIRC_CAN_REC(ir->d.features)) { 581 if (!LIRC_CAN_REC(ir->d.features)) {
586 result = -ENOTTY; 582 result = -ENOTTY;
587 break; 583 break;
588 } 584 }
@@ -592,7 +588,7 @@ long lirc_dev_fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
592 (__u32 __user *)arg); 588 (__u32 __user *)arg);
593 break; 589 break;
594 case LIRC_SET_REC_MODE: 590 case LIRC_SET_REC_MODE:
595 if (LIRC_CAN_REC(ir->d.features)) { 591 if (!LIRC_CAN_REC(ir->d.features)) {
596 result = -ENOTTY; 592 result = -ENOTTY;
597 break; 593 break;
598 } 594 }
@@ -651,6 +647,9 @@ ssize_t lirc_dev_fop_read(struct file *file,
651 return -ENODEV; 647 return -ENODEV;
652 } 648 }
653 649
650 if (!LIRC_CAN_REC(ir->d.features))
651 return -EINVAL;
652
654 dev_dbg(ir->d.dev, LOGHEAD "read called\n", ir->d.name, ir->d.minor); 653 dev_dbg(ir->d.dev, LOGHEAD "read called\n", ir->d.name, ir->d.minor);
655 654
656 buf = kzalloc(ir->chunk_size, GFP_KERNEL); 655 buf = kzalloc(ir->chunk_size, GFP_KERNEL);
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index 9bf69179eee0..238d8eaf7d94 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -31,10 +31,6 @@
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details. 32 * GNU General Public License for more details.
33 * 33 *
34 * You should have received a copy of the GNU General Public License
35 * along with this program; if not, write to the Free Software
36 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
37 *
38 */ 34 */
39 35
40#include <linux/device.h> 36#include <linux/device.h>
@@ -890,7 +886,7 @@ static int mceusb_set_tx_carrier(struct rc_dev *dev, u32 carrier)
890 cmdbuf[3] = MCE_IRDATA_TRAILER; 886 cmdbuf[3] = MCE_IRDATA_TRAILER;
891 dev_dbg(ir->dev, "disabling carrier modulation"); 887 dev_dbg(ir->dev, "disabling carrier modulation");
892 mce_async_out(ir, cmdbuf, sizeof(cmdbuf)); 888 mce_async_out(ir, cmdbuf, sizeof(cmdbuf));
893 return carrier; 889 return 0;
894 } 890 }
895 891
896 for (prescaler = 0; prescaler < 4; ++prescaler) { 892 for (prescaler = 0; prescaler < 4; ++prescaler) {
@@ -904,7 +900,7 @@ static int mceusb_set_tx_carrier(struct rc_dev *dev, u32 carrier)
904 900
905 /* Transmit new carrier to mce device */ 901 /* Transmit new carrier to mce device */
906 mce_async_out(ir, cmdbuf, sizeof(cmdbuf)); 902 mce_async_out(ir, cmdbuf, sizeof(cmdbuf));
907 return carrier; 903 return 0;
908 } 904 }
909 } 905 }
910 906
@@ -1181,7 +1177,7 @@ static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir)
1181 struct rc_dev *rc; 1177 struct rc_dev *rc;
1182 int ret; 1178 int ret;
1183 1179
1184 rc = rc_allocate_device(); 1180 rc = rc_allocate_device(RC_DRIVER_IR_RAW);
1185 if (!rc) { 1181 if (!rc) {
1186 dev_err(dev, "remote dev allocation failed"); 1182 dev_err(dev, "remote dev allocation failed");
1187 goto out; 1183 goto out;
@@ -1201,8 +1197,7 @@ static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir)
1201 usb_to_input_id(ir->usbdev, &rc->input_id); 1197 usb_to_input_id(ir->usbdev, &rc->input_id);
1202 rc->dev.parent = dev; 1198 rc->dev.parent = dev;
1203 rc->priv = ir; 1199 rc->priv = ir;
1204 rc->driver_type = RC_DRIVER_IR_RAW; 1200 rc->allowed_protocols = RC_BIT_ALL_IR_DECODER;
1205 rc->allowed_protocols = RC_BIT_ALL;
1206 rc->timeout = MS_TO_NS(100); 1201 rc->timeout = MS_TO_NS(100);
1207 if (!ir->flags.no_tx) { 1202 if (!ir->flags.no_tx) {
1208 rc->s_tx_mask = mceusb_set_tx_mask; 1203 rc->s_tx_mask = mceusb_set_tx_mask;
diff --git a/drivers/media/rc/meson-ir.c b/drivers/media/rc/meson-ir.c
index 7eb3f4f1ddcd..5576dbd6b1a4 100644
--- a/drivers/media/rc/meson-ir.c
+++ b/drivers/media/rc/meson-ir.c
@@ -131,7 +131,7 @@ static int meson_ir_probe(struct platform_device *pdev)
131 return ir->irq; 131 return ir->irq;
132 } 132 }
133 133
134 ir->rc = rc_allocate_device(); 134 ir->rc = rc_allocate_device(RC_DRIVER_IR_RAW);
135 if (!ir->rc) { 135 if (!ir->rc) {
136 dev_err(dev, "failed to allocate rc device\n"); 136 dev_err(dev, "failed to allocate rc device\n");
137 return -ENOMEM; 137 return -ENOMEM;
@@ -144,8 +144,7 @@ static int meson_ir_probe(struct platform_device *pdev)
144 map_name = of_get_property(node, "linux,rc-map-name", NULL); 144 map_name = of_get_property(node, "linux,rc-map-name", NULL);
145 ir->rc->map_name = map_name ? map_name : RC_MAP_EMPTY; 145 ir->rc->map_name = map_name ? map_name : RC_MAP_EMPTY;
146 ir->rc->dev.parent = dev; 146 ir->rc->dev.parent = dev;
147 ir->rc->driver_type = RC_DRIVER_IR_RAW; 147 ir->rc->allowed_protocols = RC_BIT_ALL_IR_DECODER;
148 ir->rc->allowed_protocols = RC_BIT_ALL;
149 ir->rc->rx_resolution = US_TO_NS(MESON_TRATE); 148 ir->rc->rx_resolution = US_TO_NS(MESON_TRATE);
150 ir->rc->timeout = MS_TO_NS(200); 149 ir->rc->timeout = MS_TO_NS(200);
151 ir->rc->driver_name = DRIVER_NAME; 150 ir->rc->driver_name = DRIVER_NAME;
diff --git a/drivers/media/rc/mtk-cir.c b/drivers/media/rc/mtk-cir.c
new file mode 100644
index 000000000000..f1e164e441e8
--- /dev/null
+++ b/drivers/media/rc/mtk-cir.c
@@ -0,0 +1,335 @@
1/*
2 * Driver for Mediatek IR Receiver Controller
3 *
4 * Copyright (C) 2017 Sean Wang <sean.wang@mediatek.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <linux/clk.h>
18#include <linux/interrupt.h>
19#include <linux/module.h>
20#include <linux/of_platform.h>
21#include <linux/reset.h>
22#include <media/rc-core.h>
23
24#define MTK_IR_DEV KBUILD_MODNAME
25
26/* Register to enable PWM and IR */
27#define MTK_CONFIG_HIGH_REG 0x0c
28/* Enable IR pulse width detection */
29#define MTK_PWM_EN BIT(13)
30/* Enable IR hardware function */
31#define MTK_IR_EN BIT(0)
32
33/* Register to setting sample period */
34#define MTK_CONFIG_LOW_REG 0x10
35/* Field to set sample period */
36#define CHK_PERIOD DIV_ROUND_CLOSEST(MTK_IR_SAMPLE, \
37 MTK_IR_CLK_PERIOD)
38#define MTK_CHK_PERIOD (((CHK_PERIOD) << 8) & (GENMASK(20, 8)))
39#define MTK_CHK_PERIOD_MASK (GENMASK(20, 8))
40
41/* Register to clear state of state machine */
42#define MTK_IRCLR_REG 0x20
43/* Bit to restart IR receiving */
44#define MTK_IRCLR BIT(0)
45
46/* Register containing pulse width data */
47#define MTK_CHKDATA_REG(i) (0x88 + 4 * (i))
48#define MTK_WIDTH_MASK (GENMASK(7, 0))
49
50/* Register to enable IR interrupt */
51#define MTK_IRINT_EN_REG 0xcc
52/* Bit to enable interrupt */
53#define MTK_IRINT_EN BIT(0)
54
55/* Register to ack IR interrupt */
56#define MTK_IRINT_CLR_REG 0xd0
57/* Bit to clear interrupt status */
58#define MTK_IRINT_CLR BIT(0)
59
60/* Maximum count of samples */
61#define MTK_MAX_SAMPLES 0xff
62/* Indicate the end of IR message */
63#define MTK_IR_END(v, p) ((v) == MTK_MAX_SAMPLES && (p) == 0)
64/* Number of registers to record the pulse width */
65#define MTK_CHKDATA_SZ 17
66/* Source clock frequency */
67#define MTK_IR_BASE_CLK 273000000
68/* Frequency after IR internal divider */
69#define MTK_IR_CLK_FREQ (MTK_IR_BASE_CLK / 4)
70/* Period for MTK_IR_CLK in ns*/
71#define MTK_IR_CLK_PERIOD DIV_ROUND_CLOSEST(1000000000ul, \
72 MTK_IR_CLK_FREQ)
73/* Sample period in ns */
74#define MTK_IR_SAMPLE (MTK_IR_CLK_PERIOD * 0xc00)
75
76/*
77 * struct mtk_ir - This is the main datasructure for holding the state
78 * of the driver
79 * @dev: The device pointer
80 * @rc: The rc instrance
81 * @irq: The IRQ that we are using
82 * @base: The mapped register i/o base
83 * @clk: The clock that we are using
84 */
85struct mtk_ir {
86 struct device *dev;
87 struct rc_dev *rc;
88 void __iomem *base;
89 int irq;
90 struct clk *clk;
91};
92
93static void mtk_w32_mask(struct mtk_ir *ir, u32 val, u32 mask, unsigned int reg)
94{
95 u32 tmp;
96
97 tmp = __raw_readl(ir->base + reg);
98 tmp = (tmp & ~mask) | val;
99 __raw_writel(tmp, ir->base + reg);
100}
101
102static void mtk_w32(struct mtk_ir *ir, u32 val, unsigned int reg)
103{
104 __raw_writel(val, ir->base + reg);
105}
106
107static u32 mtk_r32(struct mtk_ir *ir, unsigned int reg)
108{
109 return __raw_readl(ir->base + reg);
110}
111
112static inline void mtk_irq_disable(struct mtk_ir *ir, u32 mask)
113{
114 u32 val;
115
116 val = mtk_r32(ir, MTK_IRINT_EN_REG);
117 mtk_w32(ir, val & ~mask, MTK_IRINT_EN_REG);
118}
119
120static inline void mtk_irq_enable(struct mtk_ir *ir, u32 mask)
121{
122 u32 val;
123
124 val = mtk_r32(ir, MTK_IRINT_EN_REG);
125 mtk_w32(ir, val | mask, MTK_IRINT_EN_REG);
126}
127
128static irqreturn_t mtk_ir_irq(int irqno, void *dev_id)
129{
130 struct mtk_ir *ir = dev_id;
131 u8 wid = 0;
132 u32 i, j, val;
133 DEFINE_IR_RAW_EVENT(rawir);
134
135 /*
136 * Reset decoder state machine explicitly is required
137 * because 1) the longest duration for space MTK IR hardware
138 * could record is not safely long. e.g 12ms if rx resolution
139 * is 46us by default. There is still the risk to satisfying
140 * every decoder to reset themselves through long enough
141 * trailing spaces and 2) the IRQ handler guarantees that
142 * start of IR message is always contained in and starting
143 * from register MTK_CHKDATA_REG(0).
144 */
145 ir_raw_event_reset(ir->rc);
146
147 /* First message must be pulse */
148 rawir.pulse = false;
149
150 /* Handle all pulse and space IR controller captures */
151 for (i = 0 ; i < MTK_CHKDATA_SZ ; i++) {
152 val = mtk_r32(ir, MTK_CHKDATA_REG(i));
153 dev_dbg(ir->dev, "@reg%d=0x%08x\n", i, val);
154
155 for (j = 0 ; j < 4 ; j++) {
156 wid = (val & (MTK_WIDTH_MASK << j * 8)) >> j * 8;
157 rawir.pulse = !rawir.pulse;
158 rawir.duration = wid * (MTK_IR_SAMPLE + 1);
159 ir_raw_event_store_with_filter(ir->rc, &rawir);
160 }
161 }
162
163 /*
164 * The maximum number of edges the IR controller can
165 * hold is MTK_CHKDATA_SZ * 4. So if received IR messages
166 * is over the limit, the last incomplete IR message would
167 * be appended trailing space and still would be sent into
168 * ir-rc-raw to decode. That helps it is possible that it
169 * has enough information to decode a scancode even if the
170 * trailing end of the message is missing.
171 */
172 if (!MTK_IR_END(wid, rawir.pulse)) {
173 rawir.pulse = false;
174 rawir.duration = MTK_MAX_SAMPLES * (MTK_IR_SAMPLE + 1);
175 ir_raw_event_store_with_filter(ir->rc, &rawir);
176 }
177
178 ir_raw_event_handle(ir->rc);
179
180 /*
181 * Restart controller for the next receive that would
182 * clear up all CHKDATA registers
183 */
184 mtk_w32_mask(ir, 0x1, MTK_IRCLR, MTK_IRCLR_REG);
185
186 /* Clear interrupt status */
187 mtk_w32_mask(ir, 0x1, MTK_IRINT_CLR, MTK_IRINT_CLR_REG);
188
189 return IRQ_HANDLED;
190}
191
192static int mtk_ir_probe(struct platform_device *pdev)
193{
194 struct device *dev = &pdev->dev;
195 struct device_node *dn = dev->of_node;
196 struct resource *res;
197 struct mtk_ir *ir;
198 u32 val;
199 int ret = 0;
200 const char *map_name;
201
202 ir = devm_kzalloc(dev, sizeof(struct mtk_ir), GFP_KERNEL);
203 if (!ir)
204 return -ENOMEM;
205
206 ir->dev = dev;
207
208 if (!of_device_is_compatible(dn, "mediatek,mt7623-cir"))
209 return -ENODEV;
210
211 ir->clk = devm_clk_get(dev, "clk");
212 if (IS_ERR(ir->clk)) {
213 dev_err(dev, "failed to get a ir clock.\n");
214 return PTR_ERR(ir->clk);
215 }
216
217 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
218 ir->base = devm_ioremap_resource(dev, res);
219 if (IS_ERR(ir->base)) {
220 dev_err(dev, "failed to map registers\n");
221 return PTR_ERR(ir->base);
222 }
223
224 ir->rc = devm_rc_allocate_device(dev, RC_DRIVER_IR_RAW);
225 if (!ir->rc) {
226 dev_err(dev, "failed to allocate device\n");
227 return -ENOMEM;
228 }
229
230 ir->rc->priv = ir;
231 ir->rc->input_name = MTK_IR_DEV;
232 ir->rc->input_phys = MTK_IR_DEV "/input0";
233 ir->rc->input_id.bustype = BUS_HOST;
234 ir->rc->input_id.vendor = 0x0001;
235 ir->rc->input_id.product = 0x0001;
236 ir->rc->input_id.version = 0x0001;
237 map_name = of_get_property(dn, "linux,rc-map-name", NULL);
238 ir->rc->map_name = map_name ?: RC_MAP_EMPTY;
239 ir->rc->dev.parent = dev;
240 ir->rc->driver_name = MTK_IR_DEV;
241 ir->rc->allowed_protocols = RC_BIT_ALL;
242 ir->rc->rx_resolution = MTK_IR_SAMPLE;
243 ir->rc->timeout = MTK_MAX_SAMPLES * (MTK_IR_SAMPLE + 1);
244
245 ret = devm_rc_register_device(dev, ir->rc);
246 if (ret) {
247 dev_err(dev, "failed to register rc device\n");
248 return ret;
249 }
250
251 platform_set_drvdata(pdev, ir);
252
253 ir->irq = platform_get_irq(pdev, 0);
254 if (ir->irq < 0) {
255 dev_err(dev, "no irq resource\n");
256 return -ENODEV;
257 }
258
259 /*
260 * Enable interrupt after proper hardware
261 * setup and IRQ handler registration
262 */
263 if (clk_prepare_enable(ir->clk)) {
264 dev_err(dev, "try to enable ir_clk failed\n");
265 ret = -EINVAL;
266 goto exit_clkdisable_clk;
267 }
268
269 mtk_irq_disable(ir, MTK_IRINT_EN);
270
271 ret = devm_request_irq(dev, ir->irq, mtk_ir_irq, 0, MTK_IR_DEV, ir);
272 if (ret) {
273 dev_err(dev, "failed request irq\n");
274 goto exit_clkdisable_clk;
275 }
276
277 /* Enable IR and PWM */
278 val = mtk_r32(ir, MTK_CONFIG_HIGH_REG);
279 val |= MTK_PWM_EN | MTK_IR_EN;
280 mtk_w32(ir, val, MTK_CONFIG_HIGH_REG);
281
282 /* Setting sample period */
283 mtk_w32_mask(ir, MTK_CHK_PERIOD, MTK_CHK_PERIOD_MASK,
284 MTK_CONFIG_LOW_REG);
285
286 mtk_irq_enable(ir, MTK_IRINT_EN);
287
288 dev_info(dev, "Initialized MT7623 IR driver, sample period = %luus\n",
289 DIV_ROUND_CLOSEST(MTK_IR_SAMPLE, 1000));
290
291 return 0;
292
293exit_clkdisable_clk:
294 clk_disable_unprepare(ir->clk);
295
296 return ret;
297}
298
299static int mtk_ir_remove(struct platform_device *pdev)
300{
301 struct mtk_ir *ir = platform_get_drvdata(pdev);
302
303 /*
304 * Avoid contention between remove handler and
305 * IRQ handler so that disabling IR interrupt and
306 * waiting for pending IRQ handler to complete
307 */
308 mtk_irq_disable(ir, MTK_IRINT_EN);
309 synchronize_irq(ir->irq);
310
311 clk_disable_unprepare(ir->clk);
312
313 return 0;
314}
315
316static const struct of_device_id mtk_ir_match[] = {
317 { .compatible = "mediatek,mt7623-cir" },
318 {},
319};
320MODULE_DEVICE_TABLE(of, mtk_ir_match);
321
322static struct platform_driver mtk_ir_driver = {
323 .probe = mtk_ir_probe,
324 .remove = mtk_ir_remove,
325 .driver = {
326 .name = MTK_IR_DEV,
327 .of_match_table = mtk_ir_match,
328 },
329};
330
331module_platform_driver(mtk_ir_driver);
332
333MODULE_DESCRIPTION("Mediatek IR Receiver Controller Driver");
334MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>");
335MODULE_LICENSE("GPL");
diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
index 4b78c891eb77..b109f8246b96 100644
--- a/drivers/media/rc/nuvoton-cir.c
+++ b/drivers/media/rc/nuvoton-cir.c
@@ -18,11 +18,6 @@
18 * WITHOUT ANY WARRANTY; without even the implied warranty of 18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details. 20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 * USA
26 */ 21 */
27 22
28#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -176,6 +171,41 @@ static void nvt_set_ioaddr(struct nvt_dev *nvt, unsigned long *ioaddr)
176 } 171 }
177} 172}
178 173
174static void nvt_write_wakeup_codes(struct rc_dev *dev,
175 const u8 *wbuf, int count)
176{
177 u8 tolerance, config;
178 struct nvt_dev *nvt = dev->priv;
179 int i;
180
181 /* hardcode the tolerance to 10% */
182 tolerance = DIV_ROUND_UP(count, 10);
183
184 spin_lock(&nvt->lock);
185
186 nvt_clear_cir_wake_fifo(nvt);
187 nvt_cir_wake_reg_write(nvt, count, CIR_WAKE_FIFO_CMP_DEEP);
188 nvt_cir_wake_reg_write(nvt, tolerance, CIR_WAKE_FIFO_CMP_TOL);
189
190 config = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRCON);
191
192 /* enable writes to wake fifo */
193 nvt_cir_wake_reg_write(nvt, config | CIR_WAKE_IRCON_MODE1,
194 CIR_WAKE_IRCON);
195
196 if (count)
197 pr_info("Wake samples (%d) =", count);
198 else
199 pr_info("Wake sample fifo cleared");
200
201 for (i = 0; i < count; i++)
202 nvt_cir_wake_reg_write(nvt, wbuf[i], CIR_WAKE_WR_FIFO_DATA);
203
204 nvt_cir_wake_reg_write(nvt, config, CIR_WAKE_IRCON);
205
206 spin_unlock(&nvt->lock);
207}
208
179static ssize_t wakeup_data_show(struct device *dev, 209static ssize_t wakeup_data_show(struct device *dev,
180 struct device_attribute *attr, 210 struct device_attribute *attr,
181 char *buf) 211 char *buf)
@@ -214,9 +244,7 @@ static ssize_t wakeup_data_store(struct device *dev,
214 const char *buf, size_t len) 244 const char *buf, size_t len)
215{ 245{
216 struct rc_dev *rc_dev = to_rc_dev(dev); 246 struct rc_dev *rc_dev = to_rc_dev(dev);
217 struct nvt_dev *nvt = rc_dev->priv; 247 u8 wake_buf[WAKEUP_MAX_SIZE];
218 unsigned long flags;
219 u8 tolerance, config, wake_buf[WAKEUP_MAX_SIZE];
220 char **argv; 248 char **argv;
221 int i, count; 249 int i, count;
222 unsigned int val; 250 unsigned int val;
@@ -245,27 +273,7 @@ static ssize_t wakeup_data_store(struct device *dev,
245 wake_buf[i] |= BUF_PULSE_BIT; 273 wake_buf[i] |= BUF_PULSE_BIT;
246 } 274 }
247 275
248 /* hardcode the tolerance to 10% */ 276 nvt_write_wakeup_codes(rc_dev, wake_buf, count);
249 tolerance = DIV_ROUND_UP(count, 10);
250
251 spin_lock_irqsave(&nvt->lock, flags);
252
253 nvt_clear_cir_wake_fifo(nvt);
254 nvt_cir_wake_reg_write(nvt, count, CIR_WAKE_FIFO_CMP_DEEP);
255 nvt_cir_wake_reg_write(nvt, tolerance, CIR_WAKE_FIFO_CMP_TOL);
256
257 config = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRCON);
258
259 /* enable writes to wake fifo */
260 nvt_cir_wake_reg_write(nvt, config | CIR_WAKE_IRCON_MODE1,
261 CIR_WAKE_IRCON);
262
263 for (i = 0; i < count; i++)
264 nvt_cir_wake_reg_write(nvt, wake_buf[i], CIR_WAKE_WR_FIFO_DATA);
265
266 nvt_cir_wake_reg_write(nvt, config, CIR_WAKE_IRCON);
267
268 spin_unlock_irqrestore(&nvt->lock, flags);
269 277
270 ret = len; 278 ret = len;
271out: 279out:
@@ -662,6 +670,62 @@ static int nvt_set_tx_carrier(struct rc_dev *dev, u32 carrier)
662 return 0; 670 return 0;
663} 671}
664 672
673static int nvt_ir_raw_set_wakeup_filter(struct rc_dev *dev,
674 struct rc_scancode_filter *sc_filter)
675{
676 u8 buf_val;
677 int i, ret, count;
678 unsigned int val;
679 struct ir_raw_event *raw;
680 u8 wake_buf[WAKEUP_MAX_SIZE];
681 bool complete;
682
683 /* Require mask to be set */
684 if (!sc_filter->mask)
685 return 0;
686
687 raw = kmalloc_array(WAKEUP_MAX_SIZE, sizeof(*raw), GFP_KERNEL);
688 if (!raw)
689 return -ENOMEM;
690
691 ret = ir_raw_encode_scancode(dev->wakeup_protocol, sc_filter->data,
692 raw, WAKEUP_MAX_SIZE);
693 complete = (ret != -ENOBUFS);
694 if (!complete)
695 ret = WAKEUP_MAX_SIZE;
696 else if (ret < 0)
697 goto out_raw;
698
699 /* Inspect the ir samples */
700 for (i = 0, count = 0; i < ret && count < WAKEUP_MAX_SIZE; ++i) {
701 /* NS to US */
702 val = DIV_ROUND_UP(raw[i].duration, 1000L) / SAMPLE_PERIOD;
703
704 /* Split too large values into several smaller ones */
705 while (val > 0 && count < WAKEUP_MAX_SIZE) {
706 /* Skip last value for better comparison tolerance */
707 if (complete && i == ret - 1 && val < BUF_LEN_MASK)
708 break;
709
710 /* Clamp values to BUF_LEN_MASK at most */
711 buf_val = (val > BUF_LEN_MASK) ? BUF_LEN_MASK : val;
712
713 wake_buf[count] = buf_val;
714 val -= buf_val;
715 if ((raw[i]).pulse)
716 wake_buf[count] |= BUF_PULSE_BIT;
717 count++;
718 }
719 }
720
721 nvt_write_wakeup_codes(dev, wake_buf, count);
722 ret = 0;
723out_raw:
724 kfree(raw);
725
726 return ret;
727}
728
665/* 729/*
666 * nvt_tx_ir 730 * nvt_tx_ir
667 * 731 *
@@ -998,7 +1062,7 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
998 return -ENOMEM; 1062 return -ENOMEM;
999 1063
1000 /* input device for IR remote (and tx) */ 1064 /* input device for IR remote (and tx) */
1001 nvt->rdev = devm_rc_allocate_device(&pdev->dev); 1065 nvt->rdev = devm_rc_allocate_device(&pdev->dev, RC_DRIVER_IR_RAW);
1002 if (!nvt->rdev) 1066 if (!nvt->rdev)
1003 return -ENOMEM; 1067 return -ENOMEM;
1004 rdev = nvt->rdev; 1068 rdev = nvt->rdev;
@@ -1061,12 +1125,14 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1061 1125
1062 /* Set up the rc device */ 1126 /* Set up the rc device */
1063 rdev->priv = nvt; 1127 rdev->priv = nvt;
1064 rdev->driver_type = RC_DRIVER_IR_RAW; 1128 rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
1065 rdev->allowed_protocols = RC_BIT_ALL; 1129 rdev->allowed_wakeup_protocols = RC_BIT_ALL_IR_ENCODER;
1130 rdev->encode_wakeup = true;
1066 rdev->open = nvt_open; 1131 rdev->open = nvt_open;
1067 rdev->close = nvt_close; 1132 rdev->close = nvt_close;
1068 rdev->tx_ir = nvt_tx_ir; 1133 rdev->tx_ir = nvt_tx_ir;
1069 rdev->s_tx_carrier = nvt_set_tx_carrier; 1134 rdev->s_tx_carrier = nvt_set_tx_carrier;
1135 rdev->s_wakeup_filter = nvt_ir_raw_set_wakeup_filter;
1070 rdev->input_name = "Nuvoton w836x7hg Infrared Remote Transceiver"; 1136 rdev->input_name = "Nuvoton w836x7hg Infrared Remote Transceiver";
1071 rdev->input_phys = "nuvoton/cir0"; 1137 rdev->input_phys = "nuvoton/cir0";
1072 rdev->input_id.bustype = BUS_HOST; 1138 rdev->input_id.bustype = BUS_HOST;
diff --git a/drivers/media/rc/nuvoton-cir.h b/drivers/media/rc/nuvoton-cir.h
index c41c5765e1d2..88a29df38a57 100644
--- a/drivers/media/rc/nuvoton-cir.h
+++ b/drivers/media/rc/nuvoton-cir.h
@@ -18,11 +18,6 @@
18 * WITHOUT ANY WARRANTY; without even the implied warranty of 18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details. 20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 * USA
26 */ 21 */
27 22
28#include <linux/spinlock.h> 23#include <linux/spinlock.h>
diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h
index 585d5e52118d..a70a5c557434 100644
--- a/drivers/media/rc/rc-core-priv.h
+++ b/drivers/media/rc/rc-core-priv.h
@@ -20,7 +20,6 @@
20#define MAX_IR_EVENT_SIZE 512 20#define MAX_IR_EVENT_SIZE 512
21 21
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/spinlock.h>
24#include <media/rc-core.h> 23#include <media/rc-core.h>
25 24
26struct ir_raw_handler { 25struct ir_raw_handler {
@@ -28,6 +27,8 @@ struct ir_raw_handler {
28 27
29 u64 protocols; /* which are handled by this handler */ 28 u64 protocols; /* which are handled by this handler */
30 int (*decode)(struct rc_dev *dev, struct ir_raw_event event); 29 int (*decode)(struct rc_dev *dev, struct ir_raw_event event);
30 int (*encode)(enum rc_type protocol, u32 scancode,
31 struct ir_raw_event *events, unsigned int max);
31 32
32 /* These two should only be used by the lirc decoder */ 33 /* These two should only be used by the lirc decoder */
33 int (*raw_register)(struct rc_dev *dev); 34 int (*raw_register)(struct rc_dev *dev);
@@ -37,7 +38,6 @@ struct ir_raw_handler {
37struct ir_raw_event_ctrl { 38struct ir_raw_event_ctrl {
38 struct list_head list; /* to keep track of raw clients */ 39 struct list_head list; /* to keep track of raw clients */
39 struct task_struct *thread; 40 struct task_struct *thread;
40 spinlock_t lock;
41 /* fifo for the pulse/space durations */ 41 /* fifo for the pulse/space durations */
42 DECLARE_KFIFO(kfifo, struct ir_raw_event, MAX_IR_EVENT_SIZE); 42 DECLARE_KFIFO(kfifo, struct ir_raw_event, MAX_IR_EVENT_SIZE);
43 ktime_t last_event; /* when last event occurred */ 43 ktime_t last_event; /* when last event occurred */
@@ -154,6 +154,111 @@ static inline bool is_timing_event(struct ir_raw_event ev)
154#define TO_US(duration) DIV_ROUND_CLOSEST((duration), 1000) 154#define TO_US(duration) DIV_ROUND_CLOSEST((duration), 1000)
155#define TO_STR(is_pulse) ((is_pulse) ? "pulse" : "space") 155#define TO_STR(is_pulse) ((is_pulse) ? "pulse" : "space")
156 156
157/* functions for IR encoders */
158
159static inline void init_ir_raw_event_duration(struct ir_raw_event *ev,
160 unsigned int pulse,
161 u32 duration)
162{
163 init_ir_raw_event(ev);
164 ev->duration = duration;
165 ev->pulse = pulse;
166}
167
168/**
169 * struct ir_raw_timings_manchester - Manchester coding timings
170 * @leader: duration of leader pulse (if any) 0 if continuing
171 * existing signal (see @pulse_space_start)
172 * @pulse_space_start: 1 for starting with pulse (0 for starting with space)
173 * @clock: duration of each pulse/space in ns
174 * @invert: if set clock logic is inverted
175 * (0 = space + pulse, 1 = pulse + space)
176 * @trailer_space: duration of trailer space in ns
177 */
178struct ir_raw_timings_manchester {
179 unsigned int leader;
180 unsigned int pulse_space_start:1;
181 unsigned int clock;
182 unsigned int invert:1;
183 unsigned int trailer_space;
184};
185
186int ir_raw_gen_manchester(struct ir_raw_event **ev, unsigned int max,
187 const struct ir_raw_timings_manchester *timings,
188 unsigned int n, unsigned int data);
189
190/**
191 * ir_raw_gen_pulse_space() - generate pulse and space raw events.
192 * @ev: Pointer to pointer to next free raw event.
193 * Will be incremented for each raw event written.
194 * @max: Pointer to number of raw events available in buffer.
195 * Will be decremented for each raw event written.
196 * @pulse_width: Width of pulse in ns.
197 * @space_width: Width of space in ns.
198 *
199 * Returns: 0 on success.
200 * -ENOBUFS if there isn't enough buffer space to write both raw
201 * events. In this case @max events will have been written.
202 */
203static inline int ir_raw_gen_pulse_space(struct ir_raw_event **ev,
204 unsigned int *max,
205 unsigned int pulse_width,
206 unsigned int space_width)
207{
208 if (!*max)
209 return -ENOBUFS;
210 init_ir_raw_event_duration((*ev)++, 1, pulse_width);
211 if (!--*max)
212 return -ENOBUFS;
213 init_ir_raw_event_duration((*ev)++, 0, space_width);
214 --*max;
215 return 0;
216}
217
218/**
219 * struct ir_raw_timings_pd - pulse-distance modulation timings
220 * @header_pulse: duration of header pulse in ns (0 for none)
221 * @header_space: duration of header space in ns
222 * @bit_pulse: duration of bit pulse in ns
223 * @bit_space: duration of bit space (for logic 0 and 1) in ns
224 * @trailer_pulse: duration of trailer pulse in ns
225 * @trailer_space: duration of trailer space in ns
226 * @msb_first: 1 if most significant bit is sent first
227 */
228struct ir_raw_timings_pd {
229 unsigned int header_pulse;
230 unsigned int header_space;
231 unsigned int bit_pulse;
232 unsigned int bit_space[2];
233 unsigned int trailer_pulse;
234 unsigned int trailer_space;
235 unsigned int msb_first:1;
236};
237
238int ir_raw_gen_pd(struct ir_raw_event **ev, unsigned int max,
239 const struct ir_raw_timings_pd *timings,
240 unsigned int n, u64 data);
241
242/**
243 * struct ir_raw_timings_pl - pulse-length modulation timings
244 * @header_pulse: duration of header pulse in ns (0 for none)
245 * @bit_space: duration of bit space in ns
246 * @bit_pulse: duration of bit pulse (for logic 0 and 1) in ns
247 * @trailer_space: duration of trailer space in ns
248 * @msb_first: 1 if most significant bit is sent first
249 */
250struct ir_raw_timings_pl {
251 unsigned int header_pulse;
252 unsigned int bit_space;
253 unsigned int bit_pulse[2];
254 unsigned int trailer_space;
255 unsigned int msb_first:1;
256};
257
258int ir_raw_gen_pl(struct ir_raw_event **ev, unsigned int max,
259 const struct ir_raw_timings_pl *timings,
260 unsigned int n, u64 data);
261
157/* 262/*
158 * Routines from rc-raw.c to be used internally and by decoders 263 * Routines from rc-raw.c to be used internally and by decoders
159 */ 264 */
diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c
index 1c42a9f2f290..7fa84b64a2ae 100644
--- a/drivers/media/rc/rc-ir-raw.c
+++ b/drivers/media/rc/rc-ir-raw.c
@@ -17,7 +17,6 @@
17#include <linux/mutex.h> 17#include <linux/mutex.h>
18#include <linux/kmod.h> 18#include <linux/kmod.h>
19#include <linux/sched.h> 19#include <linux/sched.h>
20#include <linux/freezer.h>
21#include "rc-core-priv.h" 20#include "rc-core-priv.h"
22 21
23/* Used to keep track of IR raw clients, protected by ir_raw_handler_lock */ 22/* Used to keep track of IR raw clients, protected by ir_raw_handler_lock */
@@ -34,32 +33,26 @@ static int ir_raw_event_thread(void *data)
34 struct ir_raw_handler *handler; 33 struct ir_raw_handler *handler;
35 struct ir_raw_event_ctrl *raw = (struct ir_raw_event_ctrl *)data; 34 struct ir_raw_event_ctrl *raw = (struct ir_raw_event_ctrl *)data;
36 35
37 while (!kthread_should_stop()) { 36 while (1) {
38 37 mutex_lock(&ir_raw_handler_lock);
39 spin_lock_irq(&raw->lock); 38 while (kfifo_out(&raw->kfifo, &ev, 1)) {
40 39 list_for_each_entry(handler, &ir_raw_handler_list, list)
41 if (!kfifo_len(&raw->kfifo)) { 40 if (raw->dev->enabled_protocols &
42 set_current_state(TASK_INTERRUPTIBLE); 41 handler->protocols || !handler->protocols)
43 42 handler->decode(raw->dev, ev);
44 if (kthread_should_stop()) 43 raw->prev_ev = ev;
45 set_current_state(TASK_RUNNING);
46
47 spin_unlock_irq(&raw->lock);
48 schedule();
49 continue;
50 } 44 }
45 mutex_unlock(&ir_raw_handler_lock);
51 46
52 if(!kfifo_out(&raw->kfifo, &ev, 1)) 47 set_current_state(TASK_INTERRUPTIBLE);
53 dev_err(&raw->dev->dev, "IR event FIFO is empty!\n");
54 spin_unlock_irq(&raw->lock);
55 48
56 mutex_lock(&ir_raw_handler_lock); 49 if (kthread_should_stop()) {
57 list_for_each_entry(handler, &ir_raw_handler_list, list) 50 __set_current_state(TASK_RUNNING);
58 if (raw->dev->enabled_protocols & handler->protocols || 51 break;
59 !handler->protocols) 52 } else if (!kfifo_is_empty(&raw->kfifo))
60 handler->decode(raw->dev, ev); 53 set_current_state(TASK_RUNNING);
61 raw->prev_ev = ev; 54
62 mutex_unlock(&ir_raw_handler_lock); 55 schedule();
63 } 56 }
64 57
65 return 0; 58 return 0;
@@ -218,14 +211,10 @@ EXPORT_SYMBOL_GPL(ir_raw_event_set_idle);
218 */ 211 */
219void ir_raw_event_handle(struct rc_dev *dev) 212void ir_raw_event_handle(struct rc_dev *dev)
220{ 213{
221 unsigned long flags;
222
223 if (!dev->raw) 214 if (!dev->raw)
224 return; 215 return;
225 216
226 spin_lock_irqsave(&dev->raw->lock, flags);
227 wake_up_process(dev->raw->thread); 217 wake_up_process(dev->raw->thread);
228 spin_unlock_irqrestore(&dev->raw->lock, flags);
229} 218}
230EXPORT_SYMBOL_GPL(ir_raw_event_handle); 219EXPORT_SYMBOL_GPL(ir_raw_event_handle);
231 220
@@ -246,10 +235,254 @@ static void ir_raw_disable_protocols(struct rc_dev *dev, u64 protocols)
246{ 235{
247 mutex_lock(&dev->lock); 236 mutex_lock(&dev->lock);
248 dev->enabled_protocols &= ~protocols; 237 dev->enabled_protocols &= ~protocols;
249 dev->enabled_wakeup_protocols &= ~protocols;
250 mutex_unlock(&dev->lock); 238 mutex_unlock(&dev->lock);
251} 239}
252 240
241/**
242 * ir_raw_gen_manchester() - Encode data with Manchester (bi-phase) modulation.
243 * @ev: Pointer to pointer to next free event. *@ev is incremented for
244 * each raw event filled.
245 * @max: Maximum number of raw events to fill.
246 * @timings: Manchester modulation timings.
247 * @n: Number of bits of data.
248 * @data: Data bits to encode.
249 *
250 * Encodes the @n least significant bits of @data using Manchester (bi-phase)
251 * modulation with the timing characteristics described by @timings, writing up
252 * to @max raw IR events using the *@ev pointer.
253 *
254 * Returns: 0 on success.
255 * -ENOBUFS if there isn't enough space in the array to fit the
256 * full encoded data. In this case all @max events will have been
257 * written.
258 */
259int ir_raw_gen_manchester(struct ir_raw_event **ev, unsigned int max,
260 const struct ir_raw_timings_manchester *timings,
261 unsigned int n, unsigned int data)
262{
263 bool need_pulse;
264 unsigned int i;
265 int ret = -ENOBUFS;
266
267 i = 1 << (n - 1);
268
269 if (timings->leader) {
270 if (!max--)
271 return ret;
272 if (timings->pulse_space_start) {
273 init_ir_raw_event_duration((*ev)++, 1, timings->leader);
274
275 if (!max--)
276 return ret;
277 init_ir_raw_event_duration((*ev), 0, timings->leader);
278 } else {
279 init_ir_raw_event_duration((*ev), 1, timings->leader);
280 }
281 i >>= 1;
282 } else {
283 /* continue existing signal */
284 --(*ev);
285 }
286 /* from here on *ev will point to the last event rather than the next */
287
288 while (n && i > 0) {
289 need_pulse = !(data & i);
290 if (timings->invert)
291 need_pulse = !need_pulse;
292 if (need_pulse == !!(*ev)->pulse) {
293 (*ev)->duration += timings->clock;
294 } else {
295 if (!max--)
296 goto nobufs;
297 init_ir_raw_event_duration(++(*ev), need_pulse,
298 timings->clock);
299 }
300
301 if (!max--)
302 goto nobufs;
303 init_ir_raw_event_duration(++(*ev), !need_pulse,
304 timings->clock);
305 i >>= 1;
306 }
307
308 if (timings->trailer_space) {
309 if (!(*ev)->pulse)
310 (*ev)->duration += timings->trailer_space;
311 else if (!max--)
312 goto nobufs;
313 else
314 init_ir_raw_event_duration(++(*ev), 0,
315 timings->trailer_space);
316 }
317
318 ret = 0;
319nobufs:
320 /* point to the next event rather than last event before returning */
321 ++(*ev);
322 return ret;
323}
324EXPORT_SYMBOL(ir_raw_gen_manchester);
325
326/**
327 * ir_raw_gen_pd() - Encode data to raw events with pulse-distance modulation.
328 * @ev: Pointer to pointer to next free event. *@ev is incremented for
329 * each raw event filled.
330 * @max: Maximum number of raw events to fill.
331 * @timings: Pulse distance modulation timings.
332 * @n: Number of bits of data.
333 * @data: Data bits to encode.
334 *
335 * Encodes the @n least significant bits of @data using pulse-distance
336 * modulation with the timing characteristics described by @timings, writing up
337 * to @max raw IR events using the *@ev pointer.
338 *
339 * Returns: 0 on success.
340 * -ENOBUFS if there isn't enough space in the array to fit the
341 * full encoded data. In this case all @max events will have been
342 * written.
343 */
344int ir_raw_gen_pd(struct ir_raw_event **ev, unsigned int max,
345 const struct ir_raw_timings_pd *timings,
346 unsigned int n, u64 data)
347{
348 int i;
349 int ret;
350 unsigned int space;
351
352 if (timings->header_pulse) {
353 ret = ir_raw_gen_pulse_space(ev, &max, timings->header_pulse,
354 timings->header_space);
355 if (ret)
356 return ret;
357 }
358
359 if (timings->msb_first) {
360 for (i = n - 1; i >= 0; --i) {
361 space = timings->bit_space[(data >> i) & 1];
362 ret = ir_raw_gen_pulse_space(ev, &max,
363 timings->bit_pulse,
364 space);
365 if (ret)
366 return ret;
367 }
368 } else {
369 for (i = 0; i < n; ++i, data >>= 1) {
370 space = timings->bit_space[data & 1];
371 ret = ir_raw_gen_pulse_space(ev, &max,
372 timings->bit_pulse,
373 space);
374 if (ret)
375 return ret;
376 }
377 }
378
379 ret = ir_raw_gen_pulse_space(ev, &max, timings->trailer_pulse,
380 timings->trailer_space);
381 return ret;
382}
383EXPORT_SYMBOL(ir_raw_gen_pd);
384
385/**
386 * ir_raw_gen_pl() - Encode data to raw events with pulse-length modulation.
387 * @ev: Pointer to pointer to next free event. *@ev is incremented for
388 * each raw event filled.
389 * @max: Maximum number of raw events to fill.
390 * @timings: Pulse distance modulation timings.
391 * @n: Number of bits of data.
392 * @data: Data bits to encode.
393 *
394 * Encodes the @n least significant bits of @data using space-distance
395 * modulation with the timing characteristics described by @timings, writing up
396 * to @max raw IR events using the *@ev pointer.
397 *
398 * Returns: 0 on success.
399 * -ENOBUFS if there isn't enough space in the array to fit the
400 * full encoded data. In this case all @max events will have been
401 * written.
402 */
403int ir_raw_gen_pl(struct ir_raw_event **ev, unsigned int max,
404 const struct ir_raw_timings_pl *timings,
405 unsigned int n, u64 data)
406{
407 int i;
408 int ret = -ENOBUFS;
409 unsigned int pulse;
410
411 if (!max--)
412 return ret;
413
414 init_ir_raw_event_duration((*ev)++, 1, timings->header_pulse);
415
416 if (timings->msb_first) {
417 for (i = n - 1; i >= 0; --i) {
418 if (!max--)
419 return ret;
420 init_ir_raw_event_duration((*ev)++, 0,
421 timings->bit_space);
422 if (!max--)
423 return ret;
424 pulse = timings->bit_pulse[(data >> i) & 1];
425 init_ir_raw_event_duration((*ev)++, 1, pulse);
426 }
427 } else {
428 for (i = 0; i < n; ++i, data >>= 1) {
429 if (!max--)
430 return ret;
431 init_ir_raw_event_duration((*ev)++, 0,
432 timings->bit_space);
433 if (!max--)
434 return ret;
435 pulse = timings->bit_pulse[data & 1];
436 init_ir_raw_event_duration((*ev)++, 1, pulse);
437 }
438 }
439
440 if (!max--)
441 return ret;
442
443 init_ir_raw_event_duration((*ev)++, 0, timings->trailer_space);
444
445 return 0;
446}
447EXPORT_SYMBOL(ir_raw_gen_pl);
448
449/**
450 * ir_raw_encode_scancode() - Encode a scancode as raw events
451 *
452 * @protocol: protocol
453 * @scancode: scancode filter describing a single scancode
454 * @events: array of raw events to write into
455 * @max: max number of raw events
456 *
457 * Attempts to encode the scancode as raw events.
458 *
459 * Returns: The number of events written.
460 * -ENOBUFS if there isn't enough space in the array to fit the
461 * encoding. In this case all @max events will have been written.
462 * -EINVAL if the scancode is ambiguous or invalid, or if no
463 * compatible encoder was found.
464 */
465int ir_raw_encode_scancode(enum rc_type protocol, u32 scancode,
466 struct ir_raw_event *events, unsigned int max)
467{
468 struct ir_raw_handler *handler;
469 int ret = -EINVAL;
470 u64 mask = 1ULL << protocol;
471
472 mutex_lock(&ir_raw_handler_lock);
473 list_for_each_entry(handler, &ir_raw_handler_list, list) {
474 if (handler->protocols & mask && handler->encode) {
475 ret = handler->encode(protocol, scancode, events, max);
476 if (ret >= 0 || ret == -ENOBUFS)
477 break;
478 }
479 }
480 mutex_unlock(&ir_raw_handler_lock);
481
482 return ret;
483}
484EXPORT_SYMBOL(ir_raw_encode_scancode);
485
253/* 486/*
254 * Used to (un)register raw event clients 487 * Used to (un)register raw event clients
255 */ 488 */
@@ -269,13 +502,18 @@ int ir_raw_event_register(struct rc_dev *dev)
269 dev->change_protocol = change_protocol; 502 dev->change_protocol = change_protocol;
270 INIT_KFIFO(dev->raw->kfifo); 503 INIT_KFIFO(dev->raw->kfifo);
271 504
272 spin_lock_init(&dev->raw->lock); 505 /*
273 dev->raw->thread = kthread_run(ir_raw_event_thread, dev->raw, 506 * raw transmitters do not need any event registration
274 "rc%u", dev->minor); 507 * because the event is coming from userspace
508 */
509 if (dev->driver_type != RC_DRIVER_IR_RAW_TX) {
510 dev->raw->thread = kthread_run(ir_raw_event_thread, dev->raw,
511 "rc%u", dev->minor);
275 512
276 if (IS_ERR(dev->raw->thread)) { 513 if (IS_ERR(dev->raw->thread)) {
277 rc = PTR_ERR(dev->raw->thread); 514 rc = PTR_ERR(dev->raw->thread);
278 goto out; 515 goto out;
516 }
279 } 517 }
280 518
281 mutex_lock(&ir_raw_handler_lock); 519 mutex_lock(&ir_raw_handler_lock);
diff --git a/drivers/media/rc/rc-loopback.c b/drivers/media/rc/rc-loopback.c
index 63dace8198b0..62195af24fbe 100644
--- a/drivers/media/rc/rc-loopback.c
+++ b/drivers/media/rc/rc-loopback.c
@@ -17,15 +17,12 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */ 20 */
25 21
26#include <linux/device.h> 22#include <linux/device.h>
27#include <linux/module.h> 23#include <linux/module.h>
28#include <linux/sched.h> 24#include <linux/sched.h>
25#include <linux/slab.h>
29#include <media/rc-core.h> 26#include <media/rc-core.h>
30 27
31#define DRIVER_NAME "rc-loopback" 28#define DRIVER_NAME "rc-loopback"
@@ -176,12 +173,47 @@ static int loop_set_carrier_report(struct rc_dev *dev, int enable)
176 return 0; 173 return 0;
177} 174}
178 175
176static int loop_set_wakeup_filter(struct rc_dev *dev,
177 struct rc_scancode_filter *sc)
178{
179 static const unsigned int max = 512;
180 struct ir_raw_event *raw;
181 int ret;
182 int i;
183
184 /* fine to disable filter */
185 if (!sc->mask)
186 return 0;
187
188 /* encode the specified filter and loop it back */
189 raw = kmalloc_array(max, sizeof(*raw), GFP_KERNEL);
190 if (!raw)
191 return -ENOMEM;
192
193 ret = ir_raw_encode_scancode(dev->wakeup_protocol, sc->data, raw, max);
194 /* still loop back the partial raw IR even if it's incomplete */
195 if (ret == -ENOBUFS)
196 ret = max;
197 if (ret >= 0) {
198 /* do the loopback */
199 for (i = 0; i < ret; ++i)
200 ir_raw_event_store(dev, &raw[i]);
201 ir_raw_event_handle(dev);
202
203 ret = 0;
204 }
205
206 kfree(raw);
207
208 return ret;
209}
210
179static int __init loop_init(void) 211static int __init loop_init(void)
180{ 212{
181 struct rc_dev *rc; 213 struct rc_dev *rc;
182 int ret; 214 int ret;
183 215
184 rc = rc_allocate_device(); 216 rc = rc_allocate_device(RC_DRIVER_IR_RAW);
185 if (!rc) { 217 if (!rc) {
186 printk(KERN_ERR DRIVER_NAME ": rc_dev allocation failed\n"); 218 printk(KERN_ERR DRIVER_NAME ": rc_dev allocation failed\n");
187 return -ENOMEM; 219 return -ENOMEM;
@@ -194,8 +226,9 @@ static int __init loop_init(void)
194 rc->driver_name = DRIVER_NAME; 226 rc->driver_name = DRIVER_NAME;
195 rc->map_name = RC_MAP_EMPTY; 227 rc->map_name = RC_MAP_EMPTY;
196 rc->priv = &loopdev; 228 rc->priv = &loopdev;
197 rc->driver_type = RC_DRIVER_IR_RAW; 229 rc->allowed_protocols = RC_BIT_ALL_IR_DECODER;
198 rc->allowed_protocols = RC_BIT_ALL; 230 rc->allowed_wakeup_protocols = RC_BIT_ALL_IR_ENCODER;
231 rc->encode_wakeup = true;
199 rc->timeout = 100 * 1000 * 1000; /* 100 ms */ 232 rc->timeout = 100 * 1000 * 1000; /* 100 ms */
200 rc->min_timeout = 1; 233 rc->min_timeout = 1;
201 rc->max_timeout = UINT_MAX; 234 rc->max_timeout = UINT_MAX;
@@ -209,6 +242,7 @@ static int __init loop_init(void)
209 rc->s_idle = loop_set_idle; 242 rc->s_idle = loop_set_idle;
210 rc->s_learning_mode = loop_set_learning_mode; 243 rc->s_learning_mode = loop_set_learning_mode;
211 rc->s_carrier_report = loop_set_carrier_report; 244 rc->s_carrier_report = loop_set_carrier_report;
245 rc->s_wakeup_filter = loop_set_wakeup_filter;
212 246
213 loopdev.txmask = RXMASK_REGULAR; 247 loopdev.txmask = RXMASK_REGULAR;
214 loopdev.txcarrier = 36000; 248 loopdev.txcarrier = 36000;
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index dedaf38c5ff6..2424946740e6 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -724,6 +724,72 @@ void rc_keydown_notimeout(struct rc_dev *dev, enum rc_type protocol,
724} 724}
725EXPORT_SYMBOL_GPL(rc_keydown_notimeout); 725EXPORT_SYMBOL_GPL(rc_keydown_notimeout);
726 726
727/**
728 * rc_validate_filter() - checks that the scancode and mask are valid and
729 * provides sensible defaults
730 * @dev: the struct rc_dev descriptor of the device
731 * @filter: the scancode and mask
732 * @return: 0 or -EINVAL if the filter is not valid
733 */
734static int rc_validate_filter(struct rc_dev *dev,
735 struct rc_scancode_filter *filter)
736{
737 static u32 masks[] = {
738 [RC_TYPE_RC5] = 0x1f7f,
739 [RC_TYPE_RC5X_20] = 0x1f7f3f,
740 [RC_TYPE_RC5_SZ] = 0x2fff,
741 [RC_TYPE_SONY12] = 0x1f007f,
742 [RC_TYPE_SONY15] = 0xff007f,
743 [RC_TYPE_SONY20] = 0x1fff7f,
744 [RC_TYPE_JVC] = 0xffff,
745 [RC_TYPE_NEC] = 0xffff,
746 [RC_TYPE_NECX] = 0xffffff,
747 [RC_TYPE_NEC32] = 0xffffffff,
748 [RC_TYPE_SANYO] = 0x1fffff,
749 [RC_TYPE_RC6_0] = 0xffff,
750 [RC_TYPE_RC6_6A_20] = 0xfffff,
751 [RC_TYPE_RC6_6A_24] = 0xffffff,
752 [RC_TYPE_RC6_6A_32] = 0xffffffff,
753 [RC_TYPE_RC6_MCE] = 0xffff7fff,
754 [RC_TYPE_SHARP] = 0x1fff,
755 };
756 u32 s = filter->data;
757 enum rc_type protocol = dev->wakeup_protocol;
758
759 switch (protocol) {
760 case RC_TYPE_NECX:
761 if ((((s >> 16) ^ ~(s >> 8)) & 0xff) == 0)
762 return -EINVAL;
763 break;
764 case RC_TYPE_NEC32:
765 if ((((s >> 24) ^ ~(s >> 16)) & 0xff) == 0)
766 return -EINVAL;
767 break;
768 case RC_TYPE_RC6_MCE:
769 if ((s & 0xffff0000) != 0x800f0000)
770 return -EINVAL;
771 break;
772 case RC_TYPE_RC6_6A_32:
773 if ((s & 0xffff0000) == 0x800f0000)
774 return -EINVAL;
775 break;
776 default:
777 break;
778 }
779
780 filter->data &= masks[protocol];
781 filter->mask &= masks[protocol];
782
783 /*
784 * If we have to raw encode the IR for wakeup, we cannot have a mask
785 */
786 if (dev->encode_wakeup &&
787 filter->mask != 0 && filter->mask != masks[protocol])
788 return -EINVAL;
789
790 return 0;
791}
792
727int rc_open(struct rc_dev *rdev) 793int rc_open(struct rc_dev *rdev)
728{ 794{
729 int rval = 0; 795 int rval = 0;
@@ -796,7 +862,7 @@ static const struct {
796 { RC_BIT_OTHER, "other", NULL }, 862 { RC_BIT_OTHER, "other", NULL },
797 { RC_BIT_UNKNOWN, "unknown", NULL }, 863 { RC_BIT_UNKNOWN, "unknown", NULL },
798 { RC_BIT_RC5 | 864 { RC_BIT_RC5 |
799 RC_BIT_RC5X, "rc-5", "ir-rc5-decoder" }, 865 RC_BIT_RC5X_20, "rc-5", "ir-rc5-decoder" },
800 { RC_BIT_NEC | 866 { RC_BIT_NEC |
801 RC_BIT_NECX | 867 RC_BIT_NECX |
802 RC_BIT_NEC32, "nec", "ir-nec-decoder" }, 868 RC_BIT_NEC32, "nec", "ir-nec-decoder" },
@@ -830,11 +896,6 @@ struct rc_filter_attribute {
830}; 896};
831#define to_rc_filter_attr(a) container_of(a, struct rc_filter_attribute, attr) 897#define to_rc_filter_attr(a) container_of(a, struct rc_filter_attribute, attr)
832 898
833#define RC_PROTO_ATTR(_name, _mode, _show, _store, _type) \
834 struct rc_filter_attribute dev_attr_##_name = { \
835 .attr = __ATTR(_name, _mode, _show, _store), \
836 .type = (_type), \
837 }
838#define RC_FILTER_ATTR(_name, _mode, _show, _store, _type, _mask) \ 899#define RC_FILTER_ATTR(_name, _mode, _show, _store, _type, _mask) \
839 struct rc_filter_attribute dev_attr_##_name = { \ 900 struct rc_filter_attribute dev_attr_##_name = { \
840 .attr = __ATTR(_name, _mode, _show, _store), \ 901 .attr = __ATTR(_name, _mode, _show, _store), \
@@ -860,13 +921,13 @@ static bool lirc_is_present(void)
860} 921}
861 922
862/** 923/**
863 * show_protocols() - shows the current/wakeup IR protocol(s) 924 * show_protocols() - shows the current IR protocol(s)
864 * @device: the device descriptor 925 * @device: the device descriptor
865 * @mattr: the device attribute struct 926 * @mattr: the device attribute struct
866 * @buf: a pointer to the output buffer 927 * @buf: a pointer to the output buffer
867 * 928 *
868 * This routine is a callback routine for input read the IR protocol type(s). 929 * This routine is a callback routine for input read the IR protocol type(s).
869 * it is trigged by reading /sys/class/rc/rc?/[wakeup_]protocols. 930 * it is trigged by reading /sys/class/rc/rc?/protocols.
870 * It returns the protocol names of supported protocols. 931 * It returns the protocol names of supported protocols.
871 * Enabled protocols are printed in brackets. 932 * Enabled protocols are printed in brackets.
872 * 933 *
@@ -877,7 +938,6 @@ static ssize_t show_protocols(struct device *device,
877 struct device_attribute *mattr, char *buf) 938 struct device_attribute *mattr, char *buf)
878{ 939{
879 struct rc_dev *dev = to_rc_dev(device); 940 struct rc_dev *dev = to_rc_dev(device);
880 struct rc_filter_attribute *fattr = to_rc_filter_attr(mattr);
881 u64 allowed, enabled; 941 u64 allowed, enabled;
882 char *tmp = buf; 942 char *tmp = buf;
883 int i; 943 int i;
@@ -891,15 +951,10 @@ static ssize_t show_protocols(struct device *device,
891 951
892 mutex_lock(&dev->lock); 952 mutex_lock(&dev->lock);
893 953
894 if (fattr->type == RC_FILTER_NORMAL) { 954 enabled = dev->enabled_protocols;
895 enabled = dev->enabled_protocols; 955 allowed = dev->allowed_protocols;
896 allowed = dev->allowed_protocols; 956 if (dev->raw && !allowed)
897 if (dev->raw && !allowed) 957 allowed = ir_raw_get_allowed_protocols();
898 allowed = ir_raw_get_allowed_protocols();
899 } else {
900 enabled = dev->enabled_wakeup_protocols;
901 allowed = dev->allowed_wakeup_protocols;
902 }
903 958
904 mutex_unlock(&dev->lock); 959 mutex_unlock(&dev->lock);
905 960
@@ -997,7 +1052,6 @@ static int parse_protocol_change(u64 *protocols, const char *buf)
997} 1052}
998 1053
999static void ir_raw_load_modules(u64 *protocols) 1054static void ir_raw_load_modules(u64 *protocols)
1000
1001{ 1055{
1002 u64 available; 1056 u64 available;
1003 int i, ret; 1057 int i, ret;
@@ -1030,8 +1084,7 @@ static void ir_raw_load_modules(u64 *protocols)
1030 if (!(*protocols & proto_names[i].type & ~available)) 1084 if (!(*protocols & proto_names[i].type & ~available))
1031 continue; 1085 continue;
1032 1086
1033 pr_err("Loaded IR protocol module %s, \ 1087 pr_err("Loaded IR protocol module %s, but protocol %s still not available\n",
1034 but protocol %s still not available\n",
1035 proto_names[i].module_name, 1088 proto_names[i].module_name,
1036 proto_names[i].name); 1089 proto_names[i].name);
1037 *protocols &= ~proto_names[i].type; 1090 *protocols &= ~proto_names[i].type;
@@ -1058,11 +1111,8 @@ static ssize_t store_protocols(struct device *device,
1058 const char *buf, size_t len) 1111 const char *buf, size_t len)
1059{ 1112{
1060 struct rc_dev *dev = to_rc_dev(device); 1113 struct rc_dev *dev = to_rc_dev(device);
1061 struct rc_filter_attribute *fattr = to_rc_filter_attr(mattr);
1062 u64 *current_protocols; 1114 u64 *current_protocols;
1063 int (*change_protocol)(struct rc_dev *dev, u64 *rc_type);
1064 struct rc_scancode_filter *filter; 1115 struct rc_scancode_filter *filter;
1065 int (*set_filter)(struct rc_dev *dev, struct rc_scancode_filter *filter);
1066 u64 old_protocols, new_protocols; 1116 u64 old_protocols, new_protocols;
1067 ssize_t rc; 1117 ssize_t rc;
1068 1118
@@ -1073,21 +1123,11 @@ static ssize_t store_protocols(struct device *device,
1073 if (!atomic_read(&dev->initialized)) 1123 if (!atomic_read(&dev->initialized))
1074 return -ERESTARTSYS; 1124 return -ERESTARTSYS;
1075 1125
1076 if (fattr->type == RC_FILTER_NORMAL) { 1126 IR_dprintk(1, "Normal protocol change requested\n");
1077 IR_dprintk(1, "Normal protocol change requested\n"); 1127 current_protocols = &dev->enabled_protocols;
1078 current_protocols = &dev->enabled_protocols; 1128 filter = &dev->scancode_filter;
1079 change_protocol = dev->change_protocol;
1080 filter = &dev->scancode_filter;
1081 set_filter = dev->s_filter;
1082 } else {
1083 IR_dprintk(1, "Wakeup protocol change requested\n");
1084 current_protocols = &dev->enabled_wakeup_protocols;
1085 change_protocol = dev->change_wakeup_protocol;
1086 filter = &dev->scancode_wakeup_filter;
1087 set_filter = dev->s_wakeup_filter;
1088 }
1089 1129
1090 if (!change_protocol) { 1130 if (!dev->change_protocol) {
1091 IR_dprintk(1, "Protocol switching not supported\n"); 1131 IR_dprintk(1, "Protocol switching not supported\n");
1092 return -EINVAL; 1132 return -EINVAL;
1093 } 1133 }
@@ -1100,7 +1140,7 @@ static ssize_t store_protocols(struct device *device,
1100 if (rc < 0) 1140 if (rc < 0)
1101 goto out; 1141 goto out;
1102 1142
1103 rc = change_protocol(dev, &new_protocols); 1143 rc = dev->change_protocol(dev, &new_protocols);
1104 if (rc < 0) { 1144 if (rc < 0) {
1105 IR_dprintk(1, "Error setting protocols to 0x%llx\n", 1145 IR_dprintk(1, "Error setting protocols to 0x%llx\n",
1106 (long long)new_protocols); 1146 (long long)new_protocols);
@@ -1123,16 +1163,16 @@ static ssize_t store_protocols(struct device *device,
1123 * Try setting the same filter with the new protocol (if any). 1163 * Try setting the same filter with the new protocol (if any).
1124 * Fall back to clearing the filter. 1164 * Fall back to clearing the filter.
1125 */ 1165 */
1126 if (set_filter && filter->mask) { 1166 if (dev->s_filter && filter->mask) {
1127 if (new_protocols) 1167 if (new_protocols)
1128 rc = set_filter(dev, filter); 1168 rc = dev->s_filter(dev, filter);
1129 else 1169 else
1130 rc = -1; 1170 rc = -1;
1131 1171
1132 if (rc < 0) { 1172 if (rc < 0) {
1133 filter->data = 0; 1173 filter->data = 0;
1134 filter->mask = 0; 1174 filter->mask = 0;
1135 set_filter(dev, filter); 1175 dev->s_filter(dev, filter);
1136 } 1176 }
1137 } 1177 }
1138 1178
@@ -1221,7 +1261,6 @@ static ssize_t store_filter(struct device *device,
1221 int ret; 1261 int ret;
1222 unsigned long val; 1262 unsigned long val;
1223 int (*set_filter)(struct rc_dev *dev, struct rc_scancode_filter *filter); 1263 int (*set_filter)(struct rc_dev *dev, struct rc_scancode_filter *filter);
1224 u64 *enabled_protocols;
1225 1264
1226 /* Device is being removed */ 1265 /* Device is being removed */
1227 if (!dev) 1266 if (!dev)
@@ -1236,11 +1275,9 @@ static ssize_t store_filter(struct device *device,
1236 1275
1237 if (fattr->type == RC_FILTER_NORMAL) { 1276 if (fattr->type == RC_FILTER_NORMAL) {
1238 set_filter = dev->s_filter; 1277 set_filter = dev->s_filter;
1239 enabled_protocols = &dev->enabled_protocols;
1240 filter = &dev->scancode_filter; 1278 filter = &dev->scancode_filter;
1241 } else { 1279 } else {
1242 set_filter = dev->s_wakeup_filter; 1280 set_filter = dev->s_wakeup_filter;
1243 enabled_protocols = &dev->enabled_wakeup_protocols;
1244 filter = &dev->scancode_wakeup_filter; 1281 filter = &dev->scancode_wakeup_filter;
1245 } 1282 }
1246 1283
@@ -1255,7 +1292,22 @@ static ssize_t store_filter(struct device *device,
1255 else 1292 else
1256 new_filter.data = val; 1293 new_filter.data = val;
1257 1294
1258 if (!*enabled_protocols && val) { 1295 if (fattr->type == RC_FILTER_WAKEUP) {
1296 /*
1297 * Refuse to set a filter unless a protocol is enabled
1298 * and the filter is valid for that protocol
1299 */
1300 if (dev->wakeup_protocol != RC_TYPE_UNKNOWN)
1301 ret = rc_validate_filter(dev, &new_filter);
1302 else
1303 ret = -EINVAL;
1304
1305 if (ret != 0)
1306 goto unlock;
1307 }
1308
1309 if (fattr->type == RC_FILTER_NORMAL && !dev->enabled_protocols &&
1310 val) {
1259 /* refuse to set a filter unless a protocol is enabled */ 1311 /* refuse to set a filter unless a protocol is enabled */
1260 ret = -EINVAL; 1312 ret = -EINVAL;
1261 goto unlock; 1313 goto unlock;
@@ -1272,6 +1324,182 @@ unlock:
1272 return (ret < 0) ? ret : len; 1324 return (ret < 0) ? ret : len;
1273} 1325}
1274 1326
1327/*
1328 * This is the list of all variants of all protocols, which is used by
1329 * the wakeup_protocols sysfs entry. In the protocols sysfs entry some
1330 * some protocols are grouped together (e.g. nec = nec + necx + nec32).
1331 *
1332 * For wakeup we need to know the exact protocol variant so the hardware
1333 * can be programmed exactly what to expect.
1334 */
1335static const char * const proto_variant_names[] = {
1336 [RC_TYPE_UNKNOWN] = "unknown",
1337 [RC_TYPE_OTHER] = "other",
1338 [RC_TYPE_RC5] = "rc-5",
1339 [RC_TYPE_RC5X_20] = "rc-5x-20",
1340 [RC_TYPE_RC5_SZ] = "rc-5-sz",
1341 [RC_TYPE_JVC] = "jvc",
1342 [RC_TYPE_SONY12] = "sony-12",
1343 [RC_TYPE_SONY15] = "sony-15",
1344 [RC_TYPE_SONY20] = "sony-20",
1345 [RC_TYPE_NEC] = "nec",
1346 [RC_TYPE_NECX] = "nec-x",
1347 [RC_TYPE_NEC32] = "nec-32",
1348 [RC_TYPE_SANYO] = "sanyo",
1349 [RC_TYPE_MCE_KBD] = "mce_kbd",
1350 [RC_TYPE_RC6_0] = "rc-6-0",
1351 [RC_TYPE_RC6_6A_20] = "rc-6-6a-20",
1352 [RC_TYPE_RC6_6A_24] = "rc-6-6a-24",
1353 [RC_TYPE_RC6_6A_32] = "rc-6-6a-32",
1354 [RC_TYPE_RC6_MCE] = "rc-6-mce",
1355 [RC_TYPE_SHARP] = "sharp",
1356 [RC_TYPE_XMP] = "xmp",
1357 [RC_TYPE_CEC] = "cec",
1358};
1359
1360/**
1361 * show_wakeup_protocols() - shows the wakeup IR protocol
1362 * @device: the device descriptor
1363 * @mattr: the device attribute struct
1364 * @buf: a pointer to the output buffer
1365 *
1366 * This routine is a callback routine for input read the IR protocol type(s).
1367 * it is trigged by reading /sys/class/rc/rc?/wakeup_protocols.
1368 * It returns the protocol names of supported protocols.
1369 * The enabled protocols are printed in brackets.
1370 *
1371 * dev->lock is taken to guard against races between device
1372 * registration, store_protocols and show_protocols.
1373 */
1374static ssize_t show_wakeup_protocols(struct device *device,
1375 struct device_attribute *mattr,
1376 char *buf)
1377{
1378 struct rc_dev *dev = to_rc_dev(device);
1379 u64 allowed;
1380 enum rc_type enabled;
1381 char *tmp = buf;
1382 int i;
1383
1384 /* Device is being removed */
1385 if (!dev)
1386 return -EINVAL;
1387
1388 if (!atomic_read(&dev->initialized))
1389 return -ERESTARTSYS;
1390
1391 mutex_lock(&dev->lock);
1392
1393 allowed = dev->allowed_wakeup_protocols;
1394 enabled = dev->wakeup_protocol;
1395
1396 mutex_unlock(&dev->lock);
1397
1398 IR_dprintk(1, "%s: allowed - 0x%llx, enabled - %d\n",
1399 __func__, (long long)allowed, enabled);
1400
1401 for (i = 0; i < ARRAY_SIZE(proto_variant_names); i++) {
1402 if (allowed & (1ULL << i)) {
1403 if (i == enabled)
1404 tmp += sprintf(tmp, "[%s] ",
1405 proto_variant_names[i]);
1406 else
1407 tmp += sprintf(tmp, "%s ",
1408 proto_variant_names[i]);
1409 }
1410 }
1411
1412 if (tmp != buf)
1413 tmp--;
1414 *tmp = '\n';
1415
1416 return tmp + 1 - buf;
1417}
1418
1419/**
1420 * store_wakeup_protocols() - changes the wakeup IR protocol(s)
1421 * @device: the device descriptor
1422 * @mattr: the device attribute struct
1423 * @buf: a pointer to the input buffer
1424 * @len: length of the input buffer
1425 *
1426 * This routine is for changing the IR protocol type.
1427 * It is trigged by writing to /sys/class/rc/rc?/wakeup_protocols.
1428 * Returns @len on success or a negative error code.
1429 *
1430 * dev->lock is taken to guard against races between device
1431 * registration, store_protocols and show_protocols.
1432 */
1433static ssize_t store_wakeup_protocols(struct device *device,
1434 struct device_attribute *mattr,
1435 const char *buf, size_t len)
1436{
1437 struct rc_dev *dev = to_rc_dev(device);
1438 enum rc_type protocol;
1439 ssize_t rc;
1440 u64 allowed;
1441 int i;
1442
1443 /* Device is being removed */
1444 if (!dev)
1445 return -EINVAL;
1446
1447 if (!atomic_read(&dev->initialized))
1448 return -ERESTARTSYS;
1449
1450 mutex_lock(&dev->lock);
1451
1452 allowed = dev->allowed_wakeup_protocols;
1453
1454 if (sysfs_streq(buf, "none")) {
1455 protocol = RC_TYPE_UNKNOWN;
1456 } else {
1457 for (i = 0; i < ARRAY_SIZE(proto_variant_names); i++) {
1458 if ((allowed & (1ULL << i)) &&
1459 sysfs_streq(buf, proto_variant_names[i])) {
1460 protocol = i;
1461 break;
1462 }
1463 }
1464
1465 if (i == ARRAY_SIZE(proto_variant_names)) {
1466 rc = -EINVAL;
1467 goto out;
1468 }
1469
1470 if (dev->encode_wakeup) {
1471 u64 mask = 1ULL << protocol;
1472
1473 ir_raw_load_modules(&mask);
1474 if (!mask) {
1475 rc = -EINVAL;
1476 goto out;
1477 }
1478 }
1479 }
1480
1481 if (dev->wakeup_protocol != protocol) {
1482 dev->wakeup_protocol = protocol;
1483 IR_dprintk(1, "Wakeup protocol changed to %d\n", protocol);
1484
1485 if (protocol == RC_TYPE_RC6_MCE)
1486 dev->scancode_wakeup_filter.data = 0x800f0000;
1487 else
1488 dev->scancode_wakeup_filter.data = 0;
1489 dev->scancode_wakeup_filter.mask = 0;
1490
1491 rc = dev->s_wakeup_filter(dev, &dev->scancode_wakeup_filter);
1492 if (rc == 0)
1493 rc = len;
1494 } else {
1495 rc = len;
1496 }
1497
1498out:
1499 mutex_unlock(&dev->lock);
1500 return rc;
1501}
1502
1275static void rc_dev_release(struct device *device) 1503static void rc_dev_release(struct device *device)
1276{ 1504{
1277 struct rc_dev *dev = to_rc_dev(device); 1505 struct rc_dev *dev = to_rc_dev(device);
@@ -1301,10 +1529,9 @@ static int rc_dev_uevent(struct device *device, struct kobj_uevent_env *env)
1301/* 1529/*
1302 * Static device attribute struct with the sysfs attributes for IR's 1530 * Static device attribute struct with the sysfs attributes for IR's
1303 */ 1531 */
1304static RC_PROTO_ATTR(protocols, S_IRUGO | S_IWUSR, 1532static DEVICE_ATTR(protocols, 0644, show_protocols, store_protocols);
1305 show_protocols, store_protocols, RC_FILTER_NORMAL); 1533static DEVICE_ATTR(wakeup_protocols, 0644, show_wakeup_protocols,
1306static RC_PROTO_ATTR(wakeup_protocols, S_IRUGO | S_IWUSR, 1534 store_wakeup_protocols);
1307 show_protocols, store_protocols, RC_FILTER_WAKEUP);
1308static RC_FILTER_ATTR(filter, S_IRUGO|S_IWUSR, 1535static RC_FILTER_ATTR(filter, S_IRUGO|S_IWUSR,
1309 show_filter, store_filter, RC_FILTER_NORMAL, false); 1536 show_filter, store_filter, RC_FILTER_NORMAL, false);
1310static RC_FILTER_ATTR(filter_mask, S_IRUGO|S_IWUSR, 1537static RC_FILTER_ATTR(filter_mask, S_IRUGO|S_IWUSR,
@@ -1315,7 +1542,7 @@ static RC_FILTER_ATTR(wakeup_filter_mask, S_IRUGO|S_IWUSR,
1315 show_filter, store_filter, RC_FILTER_WAKEUP, true); 1542 show_filter, store_filter, RC_FILTER_WAKEUP, true);
1316 1543
1317static struct attribute *rc_dev_protocol_attrs[] = { 1544static struct attribute *rc_dev_protocol_attrs[] = {
1318 &dev_attr_protocols.attr.attr, 1545 &dev_attr_protocols.attr,
1319 NULL, 1546 NULL,
1320}; 1547};
1321 1548
@@ -1323,15 +1550,6 @@ static struct attribute_group rc_dev_protocol_attr_grp = {
1323 .attrs = rc_dev_protocol_attrs, 1550 .attrs = rc_dev_protocol_attrs,
1324}; 1551};
1325 1552
1326static struct attribute *rc_dev_wakeup_protocol_attrs[] = {
1327 &dev_attr_wakeup_protocols.attr.attr,
1328 NULL,
1329};
1330
1331static struct attribute_group rc_dev_wakeup_protocol_attr_grp = {
1332 .attrs = rc_dev_wakeup_protocol_attrs,
1333};
1334
1335static struct attribute *rc_dev_filter_attrs[] = { 1553static struct attribute *rc_dev_filter_attrs[] = {
1336 &dev_attr_filter.attr.attr, 1554 &dev_attr_filter.attr.attr,
1337 &dev_attr_filter_mask.attr.attr, 1555 &dev_attr_filter_mask.attr.attr,
@@ -1345,6 +1563,7 @@ static struct attribute_group rc_dev_filter_attr_grp = {
1345static struct attribute *rc_dev_wakeup_filter_attrs[] = { 1563static struct attribute *rc_dev_wakeup_filter_attrs[] = {
1346 &dev_attr_wakeup_filter.attr.attr, 1564 &dev_attr_wakeup_filter.attr.attr,
1347 &dev_attr_wakeup_filter_mask.attr.attr, 1565 &dev_attr_wakeup_filter_mask.attr.attr,
1566 &dev_attr_wakeup_protocols.attr,
1348 NULL, 1567 NULL,
1349}; 1568};
1350 1569
@@ -1357,7 +1576,7 @@ static struct device_type rc_dev_type = {
1357 .uevent = rc_dev_uevent, 1576 .uevent = rc_dev_uevent,
1358}; 1577};
1359 1578
1360struct rc_dev *rc_allocate_device(void) 1579struct rc_dev *rc_allocate_device(enum rc_driver_type type)
1361{ 1580{
1362 struct rc_dev *dev; 1581 struct rc_dev *dev;
1363 1582
@@ -1365,25 +1584,31 @@ struct rc_dev *rc_allocate_device(void)
1365 if (!dev) 1584 if (!dev)
1366 return NULL; 1585 return NULL;
1367 1586
1368 dev->input_dev = input_allocate_device(); 1587 if (type != RC_DRIVER_IR_RAW_TX) {
1369 if (!dev->input_dev) { 1588 dev->input_dev = input_allocate_device();
1370 kfree(dev); 1589 if (!dev->input_dev) {
1371 return NULL; 1590 kfree(dev);
1372 } 1591 return NULL;
1592 }
1373 1593
1374 dev->input_dev->getkeycode = ir_getkeycode; 1594 dev->input_dev->getkeycode = ir_getkeycode;
1375 dev->input_dev->setkeycode = ir_setkeycode; 1595 dev->input_dev->setkeycode = ir_setkeycode;
1376 input_set_drvdata(dev->input_dev, dev); 1596 input_set_drvdata(dev->input_dev, dev);
1377 1597
1378 spin_lock_init(&dev->rc_map.lock); 1598 setup_timer(&dev->timer_keyup, ir_timer_keyup,
1379 spin_lock_init(&dev->keylock); 1599 (unsigned long)dev);
1600
1601 spin_lock_init(&dev->rc_map.lock);
1602 spin_lock_init(&dev->keylock);
1603 }
1380 mutex_init(&dev->lock); 1604 mutex_init(&dev->lock);
1381 setup_timer(&dev->timer_keyup, ir_timer_keyup, (unsigned long)dev);
1382 1605
1383 dev->dev.type = &rc_dev_type; 1606 dev->dev.type = &rc_dev_type;
1384 dev->dev.class = &rc_class; 1607 dev->dev.class = &rc_class;
1385 device_initialize(&dev->dev); 1608 device_initialize(&dev->dev);
1386 1609
1610 dev->driver_type = type;
1611
1387 __module_get(THIS_MODULE); 1612 __module_get(THIS_MODULE);
1388 return dev; 1613 return dev;
1389} 1614}
@@ -1410,7 +1635,8 @@ static void devm_rc_alloc_release(struct device *dev, void *res)
1410 rc_free_device(*(struct rc_dev **)res); 1635 rc_free_device(*(struct rc_dev **)res);
1411} 1636}
1412 1637
1413struct rc_dev *devm_rc_allocate_device(struct device *dev) 1638struct rc_dev *devm_rc_allocate_device(struct device *dev,
1639 enum rc_driver_type type)
1414{ 1640{
1415 struct rc_dev **dr, *rc; 1641 struct rc_dev **dr, *rc;
1416 1642
@@ -1418,7 +1644,7 @@ struct rc_dev *devm_rc_allocate_device(struct device *dev)
1418 if (!dr) 1644 if (!dr)
1419 return NULL; 1645 return NULL;
1420 1646
1421 rc = rc_allocate_device(); 1647 rc = rc_allocate_device(type);
1422 if (!rc) { 1648 if (!rc) {
1423 devres_free(dr); 1649 devres_free(dr);
1424 return NULL; 1650 return NULL;
@@ -1433,16 +1659,12 @@ struct rc_dev *devm_rc_allocate_device(struct device *dev)
1433} 1659}
1434EXPORT_SYMBOL_GPL(devm_rc_allocate_device); 1660EXPORT_SYMBOL_GPL(devm_rc_allocate_device);
1435 1661
1436int rc_register_device(struct rc_dev *dev) 1662static int rc_setup_rx_device(struct rc_dev *dev)
1437{ 1663{
1438 static bool raw_init = false; /* raw decoders loaded? */
1439 struct rc_map *rc_map;
1440 const char *path;
1441 int attr = 0;
1442 int minor;
1443 int rc; 1664 int rc;
1665 struct rc_map *rc_map;
1444 1666
1445 if (!dev || !dev->map_name) 1667 if (!dev->map_name)
1446 return -EINVAL; 1668 return -EINVAL;
1447 1669
1448 rc_map = rc_map_get(dev->map_name); 1670 rc_map = rc_map_get(dev->map_name);
@@ -1451,6 +1673,19 @@ int rc_register_device(struct rc_dev *dev)
1451 if (!rc_map || !rc_map->scan || rc_map->size == 0) 1673 if (!rc_map || !rc_map->scan || rc_map->size == 0)
1452 return -EINVAL; 1674 return -EINVAL;
1453 1675
1676 rc = ir_setkeytable(dev, rc_map);
1677 if (rc)
1678 return rc;
1679
1680 if (dev->change_protocol) {
1681 u64 rc_type = (1ll << rc_map->rc_type);
1682
1683 rc = dev->change_protocol(dev, &rc_type);
1684 if (rc < 0)
1685 goto out_table;
1686 dev->enabled_protocols = rc_type;
1687 }
1688
1454 set_bit(EV_KEY, dev->input_dev->evbit); 1689 set_bit(EV_KEY, dev->input_dev->evbit);
1455 set_bit(EV_REP, dev->input_dev->evbit); 1690 set_bit(EV_REP, dev->input_dev->evbit);
1456 set_bit(EV_MSC, dev->input_dev->evbit); 1691 set_bit(EV_MSC, dev->input_dev->evbit);
@@ -1460,6 +1695,61 @@ int rc_register_device(struct rc_dev *dev)
1460 if (dev->close) 1695 if (dev->close)
1461 dev->input_dev->close = ir_close; 1696 dev->input_dev->close = ir_close;
1462 1697
1698 /*
1699 * Default delay of 250ms is too short for some protocols, especially
1700 * since the timeout is currently set to 250ms. Increase it to 500ms,
1701 * to avoid wrong repetition of the keycodes. Note that this must be
1702 * set after the call to input_register_device().
1703 */
1704 dev->input_dev->rep[REP_DELAY] = 500;
1705
1706 /*
1707 * As a repeat event on protocols like RC-5 and NEC take as long as
1708 * 110/114ms, using 33ms as a repeat period is not the right thing
1709 * to do.
1710 */
1711 dev->input_dev->rep[REP_PERIOD] = 125;
1712
1713 dev->input_dev->dev.parent = &dev->dev;
1714 memcpy(&dev->input_dev->id, &dev->input_id, sizeof(dev->input_id));
1715 dev->input_dev->phys = dev->input_phys;
1716 dev->input_dev->name = dev->input_name;
1717
1718 /* rc_open will be called here */
1719 rc = input_register_device(dev->input_dev);
1720 if (rc)
1721 goto out_table;
1722
1723 return 0;
1724
1725out_table:
1726 ir_free_table(&dev->rc_map);
1727
1728 return rc;
1729}
1730
1731static void rc_free_rx_device(struct rc_dev *dev)
1732{
1733 if (!dev || dev->driver_type == RC_DRIVER_IR_RAW_TX)
1734 return;
1735
1736 ir_free_table(&dev->rc_map);
1737
1738 input_unregister_device(dev->input_dev);
1739 dev->input_dev = NULL;
1740}
1741
1742int rc_register_device(struct rc_dev *dev)
1743{
1744 static bool raw_init; /* 'false' default value, raw decoders loaded? */
1745 const char *path;
1746 int attr = 0;
1747 int minor;
1748 int rc;
1749
1750 if (!dev)
1751 return -EINVAL;
1752
1463 minor = ida_simple_get(&rc_ida, 0, RC_DEV_MAX, GFP_KERNEL); 1753 minor = ida_simple_get(&rc_ida, 0, RC_DEV_MAX, GFP_KERNEL);
1464 if (minor < 0) 1754 if (minor < 0)
1465 return minor; 1755 return minor;
@@ -1470,89 +1760,51 @@ int rc_register_device(struct rc_dev *dev)
1470 atomic_set(&dev->initialized, 0); 1760 atomic_set(&dev->initialized, 0);
1471 1761
1472 dev->dev.groups = dev->sysfs_groups; 1762 dev->dev.groups = dev->sysfs_groups;
1473 dev->sysfs_groups[attr++] = &rc_dev_protocol_attr_grp; 1763 if (dev->driver_type != RC_DRIVER_IR_RAW_TX)
1764 dev->sysfs_groups[attr++] = &rc_dev_protocol_attr_grp;
1474 if (dev->s_filter) 1765 if (dev->s_filter)
1475 dev->sysfs_groups[attr++] = &rc_dev_filter_attr_grp; 1766 dev->sysfs_groups[attr++] = &rc_dev_filter_attr_grp;
1476 if (dev->s_wakeup_filter) 1767 if (dev->s_wakeup_filter)
1477 dev->sysfs_groups[attr++] = &rc_dev_wakeup_filter_attr_grp; 1768 dev->sysfs_groups[attr++] = &rc_dev_wakeup_filter_attr_grp;
1478 if (dev->change_wakeup_protocol)
1479 dev->sysfs_groups[attr++] = &rc_dev_wakeup_protocol_attr_grp;
1480 dev->sysfs_groups[attr++] = NULL; 1769 dev->sysfs_groups[attr++] = NULL;
1481 1770
1482 rc = device_add(&dev->dev); 1771 rc = device_add(&dev->dev);
1483 if (rc) 1772 if (rc)
1484 goto out_unlock; 1773 goto out_unlock;
1485 1774
1486 rc = ir_setkeytable(dev, rc_map);
1487 if (rc)
1488 goto out_dev;
1489
1490 dev->input_dev->dev.parent = &dev->dev;
1491 memcpy(&dev->input_dev->id, &dev->input_id, sizeof(dev->input_id));
1492 dev->input_dev->phys = dev->input_phys;
1493 dev->input_dev->name = dev->input_name;
1494
1495 rc = input_register_device(dev->input_dev);
1496 if (rc)
1497 goto out_table;
1498
1499 /*
1500 * Default delay of 250ms is too short for some protocols, especially
1501 * since the timeout is currently set to 250ms. Increase it to 500ms,
1502 * to avoid wrong repetition of the keycodes. Note that this must be
1503 * set after the call to input_register_device().
1504 */
1505 dev->input_dev->rep[REP_DELAY] = 500;
1506
1507 /*
1508 * As a repeat event on protocols like RC-5 and NEC take as long as
1509 * 110/114ms, using 33ms as a repeat period is not the right thing
1510 * to do.
1511 */
1512 dev->input_dev->rep[REP_PERIOD] = 125;
1513
1514 path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL); 1775 path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL);
1515 dev_info(&dev->dev, "%s as %s\n", 1776 dev_info(&dev->dev, "%s as %s\n",
1516 dev->input_name ?: "Unspecified device", path ?: "N/A"); 1777 dev->input_name ?: "Unspecified device", path ?: "N/A");
1517 kfree(path); 1778 kfree(path);
1518 1779
1519 if (dev->driver_type == RC_DRIVER_IR_RAW) { 1780 if (dev->driver_type != RC_DRIVER_IR_RAW_TX) {
1781 rc = rc_setup_rx_device(dev);
1782 if (rc)
1783 goto out_dev;
1784 }
1785
1786 if (dev->driver_type == RC_DRIVER_IR_RAW ||
1787 dev->driver_type == RC_DRIVER_IR_RAW_TX) {
1520 if (!raw_init) { 1788 if (!raw_init) {
1521 request_module_nowait("ir-lirc-codec"); 1789 request_module_nowait("ir-lirc-codec");
1522 raw_init = true; 1790 raw_init = true;
1523 } 1791 }
1524 rc = ir_raw_event_register(dev); 1792 rc = ir_raw_event_register(dev);
1525 if (rc < 0) 1793 if (rc < 0)
1526 goto out_input; 1794 goto out_rx;
1527 }
1528
1529 if (dev->change_protocol) {
1530 u64 rc_type = (1ll << rc_map->rc_type);
1531 rc = dev->change_protocol(dev, &rc_type);
1532 if (rc < 0)
1533 goto out_raw;
1534 dev->enabled_protocols = rc_type;
1535 } 1795 }
1536 1796
1537 /* Allow the RC sysfs nodes to be accessible */ 1797 /* Allow the RC sysfs nodes to be accessible */
1538 atomic_set(&dev->initialized, 1); 1798 atomic_set(&dev->initialized, 1);
1539 1799
1540 IR_dprintk(1, "Registered rc%u (driver: %s, remote: %s, mode %s)\n", 1800 IR_dprintk(1, "Registered rc%u (driver: %s)\n",
1541 dev->minor, 1801 dev->minor,
1542 dev->driver_name ? dev->driver_name : "unknown", 1802 dev->driver_name ? dev->driver_name : "unknown");
1543 rc_map->name ? rc_map->name : "unknown",
1544 dev->driver_type == RC_DRIVER_IR_RAW ? "raw" : "cooked");
1545 1803
1546 return 0; 1804 return 0;
1547 1805
1548out_raw: 1806out_rx:
1549 if (dev->driver_type == RC_DRIVER_IR_RAW) 1807 rc_free_rx_device(dev);
1550 ir_raw_event_unregister(dev);
1551out_input:
1552 input_unregister_device(dev->input_dev);
1553 dev->input_dev = NULL;
1554out_table:
1555 ir_free_table(&dev->rc_map);
1556out_dev: 1808out_dev:
1557 device_del(&dev->dev); 1809 device_del(&dev->dev);
1558out_unlock: 1810out_unlock:
@@ -1598,12 +1850,7 @@ void rc_unregister_device(struct rc_dev *dev)
1598 if (dev->driver_type == RC_DRIVER_IR_RAW) 1850 if (dev->driver_type == RC_DRIVER_IR_RAW)
1599 ir_raw_event_unregister(dev); 1851 ir_raw_event_unregister(dev);
1600 1852
1601 /* Freeing the table should also call the stop callback */ 1853 rc_free_rx_device(dev);
1602 ir_free_table(&dev->rc_map);
1603 IR_dprintk(1, "Freed keycode table\n");
1604
1605 input_unregister_device(dev->input_dev);
1606 dev->input_dev = NULL;
1607 1854
1608 device_del(&dev->dev); 1855 device_del(&dev->dev);
1609 1856
diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index 2784f5dae398..56d43be2756b 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -39,10 +39,6 @@
39 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 39 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40 * GNU General Public License for more details. 40 * GNU General Public License for more details.
41 * 41 *
42 * You should have received a copy of the GNU General Public License
43 * along with this program; if not, write to the Free Software
44 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
45 *
46 */ 42 */
47 43
48#include <asm/unaligned.h> 44#include <asm/unaligned.h>
@@ -945,7 +941,7 @@ static struct rc_dev *redrat3_init_rc_dev(struct redrat3_dev *rr3)
945 int ret; 941 int ret;
946 u16 prod = le16_to_cpu(rr3->udev->descriptor.idProduct); 942 u16 prod = le16_to_cpu(rr3->udev->descriptor.idProduct);
947 943
948 rc = rc_allocate_device(); 944 rc = rc_allocate_device(RC_DRIVER_IR_RAW);
949 if (!rc) 945 if (!rc)
950 return NULL; 946 return NULL;
951 947
@@ -960,8 +956,7 @@ static struct rc_dev *redrat3_init_rc_dev(struct redrat3_dev *rr3)
960 usb_to_input_id(rr3->udev, &rc->input_id); 956 usb_to_input_id(rr3->udev, &rc->input_id);
961 rc->dev.parent = dev; 957 rc->dev.parent = dev;
962 rc->priv = rr3; 958 rc->priv = rr3;
963 rc->driver_type = RC_DRIVER_IR_RAW; 959 rc->allowed_protocols = RC_BIT_ALL_IR_DECODER;
964 rc->allowed_protocols = RC_BIT_ALL;
965 rc->min_timeout = MS_TO_NS(RR3_RX_MIN_TIMEOUT); 960 rc->min_timeout = MS_TO_NS(RR3_RX_MIN_TIMEOUT);
966 rc->max_timeout = MS_TO_NS(RR3_RX_MAX_TIMEOUT); 961 rc->max_timeout = MS_TO_NS(RR3_RX_MAX_TIMEOUT);
967 rc->timeout = US_TO_NS(redrat3_get_timeout(rr3)); 962 rc->timeout = US_TO_NS(redrat3_get_timeout(rr3));
diff --git a/drivers/media/rc/serial_ir.c b/drivers/media/rc/serial_ir.c
index 436bd58b5f05..923fb2299553 100644
--- a/drivers/media/rc/serial_ir.c
+++ b/drivers/media/rc/serial_ir.c
@@ -137,6 +137,7 @@ struct serial_ir {
137 ktime_t lastkt; 137 ktime_t lastkt;
138 struct rc_dev *rcdev; 138 struct rc_dev *rcdev;
139 struct platform_device *pdev; 139 struct platform_device *pdev;
140 struct timer_list timeout_timer;
140 141
141 unsigned int freq; 142 unsigned int freq;
142 unsigned int duty_cycle; 143 unsigned int duty_cycle;
@@ -395,9 +396,14 @@ static irqreturn_t serial_ir_irq_handler(int i, void *blah)
395 frbwrite(data, !(dcd ^ sense)); 396 frbwrite(data, !(dcd ^ sense));
396 serial_ir.lastkt = kt; 397 serial_ir.lastkt = kt;
397 last_dcd = dcd; 398 last_dcd = dcd;
398 ir_raw_event_handle(serial_ir.rcdev);
399 } 399 }
400 } while (!(sinp(UART_IIR) & UART_IIR_NO_INT)); /* still pending ? */ 400 } while (!(sinp(UART_IIR) & UART_IIR_NO_INT)); /* still pending ? */
401
402 mod_timer(&serial_ir.timeout_timer,
403 jiffies + nsecs_to_jiffies(serial_ir.rcdev->timeout));
404
405 ir_raw_event_handle(serial_ir.rcdev);
406
401 return IRQ_HANDLED; 407 return IRQ_HANDLED;
402} 408}
403 409
@@ -471,6 +477,16 @@ static int hardware_init_port(void)
471 return 0; 477 return 0;
472} 478}
473 479
480static void serial_ir_timeout(unsigned long arg)
481{
482 DEFINE_IR_RAW_EVENT(ev);
483
484 ev.timeout = true;
485 ev.duration = serial_ir.rcdev->timeout;
486 ir_raw_event_store_with_filter(serial_ir.rcdev, &ev);
487 ir_raw_event_handle(serial_ir.rcdev);
488}
489
474static int serial_ir_probe(struct platform_device *dev) 490static int serial_ir_probe(struct platform_device *dev)
475{ 491{
476 int i, nlow, nhigh, result; 492 int i, nlow, nhigh, result;
@@ -500,6 +516,9 @@ static int serial_ir_probe(struct platform_device *dev)
500 return -EBUSY; 516 return -EBUSY;
501 } 517 }
502 518
519 setup_timer(&serial_ir.timeout_timer, serial_ir_timeout,
520 (unsigned long)&serial_ir);
521
503 result = hardware_init_port(); 522 result = hardware_init_port();
504 if (result < 0) 523 if (result < 0)
505 return result; 524 return result;
@@ -738,7 +757,7 @@ static int __init serial_ir_init_module(void)
738 if (result) 757 if (result)
739 return result; 758 return result;
740 759
741 rcdev = devm_rc_allocate_device(&serial_ir.pdev->dev); 760 rcdev = devm_rc_allocate_device(&serial_ir.pdev->dev, RC_DRIVER_IR_RAW);
742 if (!rcdev) { 761 if (!rcdev) {
743 result = -ENOMEM; 762 result = -ENOMEM;
744 goto serial_cleanup; 763 goto serial_cleanup;
@@ -777,11 +796,12 @@ static int __init serial_ir_init_module(void)
777 rcdev->open = serial_ir_open; 796 rcdev->open = serial_ir_open;
778 rcdev->close = serial_ir_close; 797 rcdev->close = serial_ir_close;
779 rcdev->dev.parent = &serial_ir.pdev->dev; 798 rcdev->dev.parent = &serial_ir.pdev->dev;
780 rcdev->driver_type = RC_DRIVER_IR_RAW; 799 rcdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
781 rcdev->allowed_protocols = RC_BIT_ALL;
782 rcdev->driver_name = KBUILD_MODNAME; 800 rcdev->driver_name = KBUILD_MODNAME;
783 rcdev->map_name = RC_MAP_RC6_MCE; 801 rcdev->map_name = RC_MAP_RC6_MCE;
802 rcdev->min_timeout = 1;
784 rcdev->timeout = IR_DEFAULT_TIMEOUT; 803 rcdev->timeout = IR_DEFAULT_TIMEOUT;
804 rcdev->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
785 rcdev->rx_resolution = 250000; 805 rcdev->rx_resolution = 250000;
786 806
787 serial_ir.rcdev = rcdev; 807 serial_ir.rcdev = rcdev;
@@ -797,6 +817,7 @@ serial_cleanup:
797 817
798static void __exit serial_ir_exit_module(void) 818static void __exit serial_ir_exit_module(void)
799{ 819{
820 del_timer_sync(&serial_ir.timeout_timer);
800 rc_unregister_device(serial_ir.rcdev); 821 rc_unregister_device(serial_ir.rcdev);
801 serial_ir_exit(); 822 serial_ir_exit();
802} 823}
diff --git a/drivers/media/rc/st_rc.c b/drivers/media/rc/st_rc.c
index 1fa0c9d1c508..f0d7190e3919 100644
--- a/drivers/media/rc/st_rc.c
+++ b/drivers/media/rc/st_rc.c
@@ -235,7 +235,7 @@ static int st_rc_probe(struct platform_device *pdev)
235 if (!rc_dev) 235 if (!rc_dev)
236 return -ENOMEM; 236 return -ENOMEM;
237 237
238 rdev = rc_allocate_device(); 238 rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
239 239
240 if (!rdev) 240 if (!rdev)
241 return -ENOMEM; 241 return -ENOMEM;
@@ -290,8 +290,7 @@ static int st_rc_probe(struct platform_device *pdev)
290 platform_set_drvdata(pdev, rc_dev); 290 platform_set_drvdata(pdev, rc_dev);
291 st_rc_hardware_init(rc_dev); 291 st_rc_hardware_init(rc_dev);
292 292
293 rdev->driver_type = RC_DRIVER_IR_RAW; 293 rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
294 rdev->allowed_protocols = RC_BIT_ALL;
295 /* rx sampling rate is 10Mhz */ 294 /* rx sampling rate is 10Mhz */
296 rdev->rx_resolution = 100; 295 rdev->rx_resolution = 100;
297 rdev->timeout = US_TO_NS(MAX_SYMB_TIME); 296 rdev->timeout = US_TO_NS(MAX_SYMB_TIME);
diff --git a/drivers/media/rc/streamzap.c b/drivers/media/rc/streamzap.c
index 53f9b0af358a..b09c45abb5f3 100644
--- a/drivers/media/rc/streamzap.c
+++ b/drivers/media/rc/streamzap.c
@@ -25,10 +25,6 @@
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of 25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details. 27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 */ 28 */
33 29
34#include <linux/device.h> 30#include <linux/device.h>
@@ -291,7 +287,7 @@ static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz)
291 struct device *dev = sz->dev; 287 struct device *dev = sz->dev;
292 int ret; 288 int ret;
293 289
294 rdev = rc_allocate_device(); 290 rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
295 if (!rdev) { 291 if (!rdev) {
296 dev_err(dev, "remote dev allocation failed\n"); 292 dev_err(dev, "remote dev allocation failed\n");
297 goto out; 293 goto out;
@@ -308,8 +304,7 @@ static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz)
308 usb_to_input_id(sz->usbdev, &rdev->input_id); 304 usb_to_input_id(sz->usbdev, &rdev->input_id);
309 rdev->dev.parent = dev; 305 rdev->dev.parent = dev;
310 rdev->priv = sz; 306 rdev->priv = sz;
311 rdev->driver_type = RC_DRIVER_IR_RAW; 307 rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
312 rdev->allowed_protocols = RC_BIT_ALL;
313 rdev->driver_name = DRIVER_NAME; 308 rdev->driver_name = DRIVER_NAME;
314 rdev->map_name = RC_MAP_STREAMZAP; 309 rdev->map_name = RC_MAP_STREAMZAP;
315 310
diff --git a/drivers/media/rc/sunxi-cir.c b/drivers/media/rc/sunxi-cir.c
index eaadc081760a..25b006167810 100644
--- a/drivers/media/rc/sunxi-cir.c
+++ b/drivers/media/rc/sunxi-cir.c
@@ -212,7 +212,7 @@ static int sunxi_ir_probe(struct platform_device *pdev)
212 goto exit_clkdisable_clk; 212 goto exit_clkdisable_clk;
213 } 213 }
214 214
215 ir->rc = rc_allocate_device(); 215 ir->rc = rc_allocate_device(RC_DRIVER_IR_RAW);
216 if (!ir->rc) { 216 if (!ir->rc) {
217 dev_err(dev, "failed to allocate device\n"); 217 dev_err(dev, "failed to allocate device\n");
218 ret = -ENOMEM; 218 ret = -ENOMEM;
@@ -229,8 +229,7 @@ static int sunxi_ir_probe(struct platform_device *pdev)
229 ir->map_name = of_get_property(dn, "linux,rc-map-name", NULL); 229 ir->map_name = of_get_property(dn, "linux,rc-map-name", NULL);
230 ir->rc->map_name = ir->map_name ?: RC_MAP_EMPTY; 230 ir->rc->map_name = ir->map_name ?: RC_MAP_EMPTY;
231 ir->rc->dev.parent = dev; 231 ir->rc->dev.parent = dev;
232 ir->rc->driver_type = RC_DRIVER_IR_RAW; 232 ir->rc->allowed_protocols = RC_BIT_ALL_IR_DECODER;
233 ir->rc->allowed_protocols = RC_BIT_ALL;
234 ir->rc->rx_resolution = SUNXI_IR_SAMPLE; 233 ir->rc->rx_resolution = SUNXI_IR_SAMPLE;
235 ir->rc->timeout = MS_TO_NS(SUNXI_IR_TIMEOUT); 234 ir->rc->timeout = MS_TO_NS(SUNXI_IR_TIMEOUT);
236 ir->rc->driver_name = SUNXI_IR_DEV; 235 ir->rc->driver_name = SUNXI_IR_DEV;
diff --git a/drivers/media/rc/ttusbir.c b/drivers/media/rc/ttusbir.c
index bc214e2b3a36..23be7702e2df 100644
--- a/drivers/media/rc/ttusbir.c
+++ b/drivers/media/rc/ttusbir.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 15 */
20 16
21#include <linux/module.h> 17#include <linux/module.h>
@@ -205,7 +201,7 @@ static int ttusbir_probe(struct usb_interface *intf,
205 int altsetting = -1; 201 int altsetting = -1;
206 202
207 tt = kzalloc(sizeof(*tt), GFP_KERNEL); 203 tt = kzalloc(sizeof(*tt), GFP_KERNEL);
208 rc = rc_allocate_device(); 204 rc = rc_allocate_device(RC_DRIVER_IR_RAW);
209 if (!tt || !rc) { 205 if (!tt || !rc) {
210 ret = -ENOMEM; 206 ret = -ENOMEM;
211 goto out; 207 goto out;
@@ -317,12 +313,14 @@ static int ttusbir_probe(struct usb_interface *intf,
317 rc->input_phys = tt->phys; 313 rc->input_phys = tt->phys;
318 usb_to_input_id(tt->udev, &rc->input_id); 314 usb_to_input_id(tt->udev, &rc->input_id);
319 rc->dev.parent = &intf->dev; 315 rc->dev.parent = &intf->dev;
320 rc->driver_type = RC_DRIVER_IR_RAW; 316 rc->allowed_protocols = RC_BIT_ALL_IR_DECODER;
321 rc->allowed_protocols = RC_BIT_ALL;
322 rc->priv = tt; 317 rc->priv = tt;
323 rc->driver_name = DRIVER_NAME; 318 rc->driver_name = DRIVER_NAME;
324 rc->map_name = RC_MAP_TT_1500; 319 rc->map_name = RC_MAP_TT_1500;
325 rc->timeout = MS_TO_NS(100); 320 rc->min_timeout = 1;
321 rc->timeout = IR_DEFAULT_TIMEOUT;
322 rc->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
323
326 /* 324 /*
327 * The precision is NS_PER_BIT, but since every 8th bit can be 325 * The precision is NS_PER_BIT, but since every 8th bit can be
328 * overwritten with garbage the accuracy is at best 2 * NS_PER_BIT. 326 * overwritten with garbage the accuracy is at best 2 * NS_PER_BIT.
diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c
index 78491ed48d92..dc1c8305ad23 100644
--- a/drivers/media/rc/winbond-cir.c
+++ b/drivers/media/rc/winbond-cir.c
@@ -34,10 +34,6 @@
34 * but WITHOUT ANY WARRANTY; without even the implied warranty of 34 * but WITHOUT ANY WARRANTY; without even the implied warranty of
35 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 35 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 * GNU General Public License for more details. 36 * GNU General Public License for more details.
37 *
38 * You should have received a copy of the GNU General Public License
39 * along with this program; if not, write to the Free Software
40 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
41 */ 37 */
42 38
43#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 39#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -194,7 +190,6 @@ enum wbcir_txstate {
194#define WBCIR_NAME "Winbond CIR" 190#define WBCIR_NAME "Winbond CIR"
195#define WBCIR_ID_FAMILY 0xF1 /* Family ID for the WPCD376I */ 191#define WBCIR_ID_FAMILY 0xF1 /* Family ID for the WPCD376I */
196#define WBCIR_ID_CHIP 0x04 /* Chip ID for the WPCD376I */ 192#define WBCIR_ID_CHIP 0x04 /* Chip ID for the WPCD376I */
197#define INVALID_SCANCODE 0x7FFFFFFF /* Invalid with all protos */
198#define WAKEUP_IOMEM_LEN 0x10 /* Wake-Up I/O Reg Len */ 193#define WAKEUP_IOMEM_LEN 0x10 /* Wake-Up I/O Reg Len */
199#define EHFUNC_IOMEM_LEN 0x10 /* Enhanced Func I/O Reg Len */ 194#define EHFUNC_IOMEM_LEN 0x10 /* Enhanced Func I/O Reg Len */
200#define SP_IOMEM_LEN 0x08 /* Serial Port 3 (IR) Reg Len */ 195#define SP_IOMEM_LEN 0x08 /* Serial Port 3 (IR) Reg Len */
@@ -225,10 +220,6 @@ struct wbcir_data {
225 u32 txcarrier; 220 u32 txcarrier;
226}; 221};
227 222
228static enum wbcir_protocol protocol = IR_PROTOCOL_RC6;
229module_param(protocol, uint, 0444);
230MODULE_PARM_DESC(protocol, "IR protocol to use for the power-on command (0 = RC5, 1 = NEC, 2 = RC6A, default)");
231
232static bool invert; /* default = 0 */ 223static bool invert; /* default = 0 */
233module_param(invert, bool, 0444); 224module_param(invert, bool, 0444);
234MODULE_PARM_DESC(invert, "Invert the signal from the IR receiver"); 225MODULE_PARM_DESC(invert, "Invert the signal from the IR receiver");
@@ -237,15 +228,6 @@ static bool txandrx; /* default = 0 */
237module_param(txandrx, bool, 0444); 228module_param(txandrx, bool, 0444);
238MODULE_PARM_DESC(txandrx, "Allow simultaneous TX and RX"); 229MODULE_PARM_DESC(txandrx, "Allow simultaneous TX and RX");
239 230
240static unsigned int wake_sc = 0x800F040C;
241module_param(wake_sc, uint, 0644);
242MODULE_PARM_DESC(wake_sc, "Scancode of the power-on IR command");
243
244static unsigned int wake_rc6mode = 6;
245module_param(wake_rc6mode, uint, 0644);
246MODULE_PARM_DESC(wake_rc6mode, "RC6 mode for the power-on command (0 = 0, 6 = 6A, default)");
247
248
249 231
250/***************************************************************************** 232/*****************************************************************************
251 * 233 *
@@ -696,138 +678,153 @@ wbcir_shutdown(struct pnp_dev *device)
696{ 678{
697 struct device *dev = &device->dev; 679 struct device *dev = &device->dev;
698 struct wbcir_data *data = pnp_get_drvdata(device); 680 struct wbcir_data *data = pnp_get_drvdata(device);
681 struct rc_dev *rc = data->dev;
699 bool do_wake = true; 682 bool do_wake = true;
700 u8 match[11]; 683 u8 match[11];
701 u8 mask[11]; 684 u8 mask[11];
702 u8 rc6_csl = 0; 685 u8 rc6_csl = 0;
686 u8 proto;
687 u32 wake_sc = rc->scancode_wakeup_filter.data;
688 u32 mask_sc = rc->scancode_wakeup_filter.mask;
703 int i; 689 int i;
704 690
705 memset(match, 0, sizeof(match)); 691 memset(match, 0, sizeof(match));
706 memset(mask, 0, sizeof(mask)); 692 memset(mask, 0, sizeof(mask));
707 693
708 if (wake_sc == INVALID_SCANCODE || !device_may_wakeup(dev)) { 694 if (!mask_sc || !device_may_wakeup(dev)) {
709 do_wake = false; 695 do_wake = false;
710 goto finish; 696 goto finish;
711 } 697 }
712 698
713 switch (protocol) { 699 switch (rc->wakeup_protocol) {
714 case IR_PROTOCOL_RC5: 700 case RC_TYPE_RC5:
715 if (wake_sc > 0xFFF) {
716 do_wake = false;
717 dev_err(dev, "RC5 - Invalid wake scancode\n");
718 break;
719 }
720
721 /* Mask = 13 bits, ex toggle */ 701 /* Mask = 13 bits, ex toggle */
722 mask[0] = 0xFF; 702 mask[0] = (mask_sc & 0x003f);
723 mask[1] = 0x17; 703 mask[0] |= (mask_sc & 0x0300) >> 2;
704 mask[1] = (mask_sc & 0x1c00) >> 10;
705 if (mask_sc & 0x0040) /* 2nd start bit */
706 match[1] |= 0x10;
724 707
725 match[0] = (wake_sc & 0x003F); /* 6 command bits */ 708 match[0] = (wake_sc & 0x003F); /* 6 command bits */
726 match[0] |= (wake_sc & 0x0180) >> 1; /* 2 address bits */ 709 match[0] |= (wake_sc & 0x0300) >> 2; /* 2 address bits */
727 match[1] = (wake_sc & 0x0E00) >> 9; /* 3 address bits */ 710 match[1] = (wake_sc & 0x1c00) >> 10; /* 3 address bits */
728 if (!(wake_sc & 0x0040)) /* 2nd start bit */ 711 if (!(wake_sc & 0x0040)) /* 2nd start bit */
729 match[1] |= 0x10; 712 match[1] |= 0x10;
730 713
714 proto = IR_PROTOCOL_RC5;
731 break; 715 break;
732 716
733 case IR_PROTOCOL_NEC: 717 case RC_TYPE_NEC:
734 if (wake_sc > 0xFFFFFF) { 718 mask[1] = bitrev8(mask_sc);
735 do_wake = false; 719 mask[0] = mask[1];
736 dev_err(dev, "NEC - Invalid wake scancode\n"); 720 mask[3] = bitrev8(mask_sc >> 8);
737 break; 721 mask[2] = mask[3];
738 }
739 722
740 mask[0] = mask[1] = mask[2] = mask[3] = 0xFF; 723 match[1] = bitrev8(wake_sc);
741
742 match[1] = bitrev8((wake_sc & 0xFF));
743 match[0] = ~match[1]; 724 match[0] = ~match[1];
725 match[3] = bitrev8(wake_sc >> 8);
726 match[2] = ~match[3];
744 727
745 match[3] = bitrev8((wake_sc & 0xFF00) >> 8); 728 proto = IR_PROTOCOL_NEC;
746 if (wake_sc > 0xFFFF) 729 break;
747 match[2] = bitrev8((wake_sc & 0xFF0000) >> 16); 730
748 else 731 case RC_TYPE_NECX:
749 match[2] = ~match[3]; 732 mask[1] = bitrev8(mask_sc);
733 mask[0] = mask[1];
734 mask[2] = bitrev8(mask_sc >> 8);
735 mask[3] = bitrev8(mask_sc >> 16);
750 736
737 match[1] = bitrev8(wake_sc);
738 match[0] = ~match[1];
739 match[2] = bitrev8(wake_sc >> 8);
740 match[3] = bitrev8(wake_sc >> 16);
741
742 proto = IR_PROTOCOL_NEC;
751 break; 743 break;
752 744
753 case IR_PROTOCOL_RC6: 745 case RC_TYPE_NEC32:
746 mask[0] = bitrev8(mask_sc);
747 mask[1] = bitrev8(mask_sc >> 8);
748 mask[2] = bitrev8(mask_sc >> 16);
749 mask[3] = bitrev8(mask_sc >> 24);
754 750
755 if (wake_rc6mode == 0) { 751 match[0] = bitrev8(wake_sc);
756 if (wake_sc > 0xFFFF) { 752 match[1] = bitrev8(wake_sc >> 8);
757 do_wake = false; 753 match[2] = bitrev8(wake_sc >> 16);
758 dev_err(dev, "RC6 - Invalid wake scancode\n"); 754 match[3] = bitrev8(wake_sc >> 24);
759 break;
760 }
761 755
762 /* Command */ 756 proto = IR_PROTOCOL_NEC;
763 match[0] = wbcir_to_rc6cells(wake_sc >> 0); 757 break;
764 mask[0] = 0xFF; 758
765 match[1] = wbcir_to_rc6cells(wake_sc >> 4); 759 case RC_TYPE_RC6_0:
766 mask[1] = 0xFF; 760 /* Command */
767 761 match[0] = wbcir_to_rc6cells(wake_sc >> 0);
768 /* Address */ 762 mask[0] = wbcir_to_rc6cells(mask_sc >> 0);
769 match[2] = wbcir_to_rc6cells(wake_sc >> 8); 763 match[1] = wbcir_to_rc6cells(wake_sc >> 4);
770 mask[2] = 0xFF; 764 mask[1] = wbcir_to_rc6cells(mask_sc >> 4);
771 match[3] = wbcir_to_rc6cells(wake_sc >> 12); 765
772 mask[3] = 0xFF; 766 /* Address */
773 767 match[2] = wbcir_to_rc6cells(wake_sc >> 8);
774 /* Header */ 768 mask[2] = wbcir_to_rc6cells(mask_sc >> 8);
775 match[4] = 0x50; /* mode1 = mode0 = 0, ignore toggle */ 769 match[3] = wbcir_to_rc6cells(wake_sc >> 12);
776 mask[4] = 0xF0; 770 mask[3] = wbcir_to_rc6cells(mask_sc >> 12);
777 match[5] = 0x09; /* start bit = 1, mode2 = 0 */ 771
778 mask[5] = 0x0F; 772 /* Header */
779 773 match[4] = 0x50; /* mode1 = mode0 = 0, ignore toggle */
780 rc6_csl = 44; 774 mask[4] = 0xF0;
781 775 match[5] = 0x09; /* start bit = 1, mode2 = 0 */
782 } else if (wake_rc6mode == 6) { 776 mask[5] = 0x0F;
783 i = 0; 777
784 778 rc6_csl = 44;
785 /* Command */ 779 proto = IR_PROTOCOL_RC6;
786 match[i] = wbcir_to_rc6cells(wake_sc >> 0); 780 break;
787 mask[i++] = 0xFF; 781
788 match[i] = wbcir_to_rc6cells(wake_sc >> 4); 782 case RC_TYPE_RC6_6A_24:
789 mask[i++] = 0xFF; 783 case RC_TYPE_RC6_6A_32:
790 784 case RC_TYPE_RC6_MCE:
791 /* Address + Toggle */ 785 i = 0;
792 match[i] = wbcir_to_rc6cells(wake_sc >> 8); 786
793 mask[i++] = 0xFF; 787 /* Command */
794 match[i] = wbcir_to_rc6cells(wake_sc >> 12); 788 match[i] = wbcir_to_rc6cells(wake_sc >> 0);
795 mask[i++] = 0x3F; 789 mask[i++] = wbcir_to_rc6cells(mask_sc >> 0);
796 790 match[i] = wbcir_to_rc6cells(wake_sc >> 4);
797 /* Customer bits 7 - 0 */ 791 mask[i++] = wbcir_to_rc6cells(mask_sc >> 4);
798 match[i] = wbcir_to_rc6cells(wake_sc >> 16); 792
799 mask[i++] = 0xFF; 793 /* Address + Toggle */
794 match[i] = wbcir_to_rc6cells(wake_sc >> 8);
795 mask[i++] = wbcir_to_rc6cells(mask_sc >> 8);
796 match[i] = wbcir_to_rc6cells(wake_sc >> 12);
797 mask[i++] = wbcir_to_rc6cells(mask_sc >> 12);
798
799 /* Customer bits 7 - 0 */
800 match[i] = wbcir_to_rc6cells(wake_sc >> 16);
801 mask[i++] = wbcir_to_rc6cells(mask_sc >> 16);
802
803 if (rc->wakeup_protocol == RC_TYPE_RC6_6A_20) {
804 rc6_csl = 52;
805 } else {
800 match[i] = wbcir_to_rc6cells(wake_sc >> 20); 806 match[i] = wbcir_to_rc6cells(wake_sc >> 20);
801 mask[i++] = 0xFF; 807 mask[i++] = wbcir_to_rc6cells(mask_sc >> 20);
802 808
803 if (wake_sc & 0x80000000) { 809 if (rc->wakeup_protocol == RC_TYPE_RC6_6A_24) {
810 rc6_csl = 60;
811 } else {
804 /* Customer range bit and bits 15 - 8 */ 812 /* Customer range bit and bits 15 - 8 */
805 match[i] = wbcir_to_rc6cells(wake_sc >> 24); 813 match[i] = wbcir_to_rc6cells(wake_sc >> 24);
806 mask[i++] = 0xFF; 814 mask[i++] = wbcir_to_rc6cells(mask_sc >> 24);
807 match[i] = wbcir_to_rc6cells(wake_sc >> 28); 815 match[i] = wbcir_to_rc6cells(wake_sc >> 28);
808 mask[i++] = 0xFF; 816 mask[i++] = wbcir_to_rc6cells(mask_sc >> 28);
809 rc6_csl = 76; 817 rc6_csl = 76;
810 } else if (wake_sc <= 0x007FFFFF) {
811 rc6_csl = 60;
812 } else {
813 do_wake = false;
814 dev_err(dev, "RC6 - Invalid wake scancode\n");
815 break;
816 } 818 }
817
818 /* Header */
819 match[i] = 0x93; /* mode1 = mode0 = 1, submode = 0 */
820 mask[i++] = 0xFF;
821 match[i] = 0x0A; /* start bit = 1, mode2 = 1 */
822 mask[i++] = 0x0F;
823
824 } else {
825 do_wake = false;
826 dev_err(dev, "RC6 - Invalid wake mode\n");
827 } 819 }
828 820
821 /* Header */
822 match[i] = 0x93; /* mode1 = mode0 = 1, submode = 0 */
823 mask[i++] = 0xFF;
824 match[i] = 0x0A; /* start bit = 1, mode2 = 1 */
825 mask[i++] = 0x0F;
826 proto = IR_PROTOCOL_RC6;
829 break; 827 break;
830
831 default: 828 default:
832 do_wake = false; 829 do_wake = false;
833 break; 830 break;
@@ -855,7 +852,8 @@ finish:
855 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_EV_EN, 0x01, 0x07); 852 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_EV_EN, 0x01, 0x07);
856 853
857 /* Set CEIR_EN */ 854 /* Set CEIR_EN */
858 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_CTL, 0x01, 0x01); 855 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_CTL,
856 (proto << 4) | 0x01, 0x31);
859 857
860 } else { 858 } else {
861 /* Clear BUFF_EN, Clear END_EN, Clear MATCH_EN */ 859 /* Clear BUFF_EN, Clear END_EN, Clear MATCH_EN */
@@ -875,6 +873,15 @@ finish:
875 disable_irq(data->irq); 873 disable_irq(data->irq);
876} 874}
877 875
876/*
877 * Wakeup handling is done on shutdown.
878 */
879static int
880wbcir_set_wakeup_filter(struct rc_dev *rc, struct rc_scancode_filter *filter)
881{
882 return 0;
883}
884
878static int 885static int
879wbcir_suspend(struct pnp_dev *device, pm_message_t state) 886wbcir_suspend(struct pnp_dev *device, pm_message_t state)
880{ 887{
@@ -887,16 +894,11 @@ wbcir_suspend(struct pnp_dev *device, pm_message_t state)
887static void 894static void
888wbcir_init_hw(struct wbcir_data *data) 895wbcir_init_hw(struct wbcir_data *data)
889{ 896{
890 u8 tmp;
891
892 /* Disable interrupts */ 897 /* Disable interrupts */
893 wbcir_set_irqmask(data, WBCIR_IRQ_NONE); 898 wbcir_set_irqmask(data, WBCIR_IRQ_NONE);
894 899
895 /* Set PROT_SEL, RX_INV, Clear CEIR_EN (needed for the led) */ 900 /* Set RX_INV, Clear CEIR_EN (needed for the led) */
896 tmp = protocol << 4; 901 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_CTL, invert ? 8 : 0, 0x09);
897 if (invert)
898 tmp |= 0x08;
899 outb(tmp, data->wbase + WBCIR_REG_WCEIR_CTL);
900 902
901 /* Clear status bits NEC_REP, BUFF, MSG_END, MATCH */ 903 /* Clear status bits NEC_REP, BUFF, MSG_END, MATCH */
902 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_STS, 0x17, 0x17); 904 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_STS, 0x17, 0x17);
@@ -1059,13 +1061,12 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
1059 if (err) 1061 if (err)
1060 goto exit_free_data; 1062 goto exit_free_data;
1061 1063
1062 data->dev = rc_allocate_device(); 1064 data->dev = rc_allocate_device(RC_DRIVER_IR_RAW);
1063 if (!data->dev) { 1065 if (!data->dev) {
1064 err = -ENOMEM; 1066 err = -ENOMEM;
1065 goto exit_unregister_led; 1067 goto exit_unregister_led;
1066 } 1068 }
1067 1069
1068 data->dev->driver_type = RC_DRIVER_IR_RAW;
1069 data->dev->driver_name = DRVNAME; 1070 data->dev->driver_name = DRVNAME;
1070 data->dev->input_name = WBCIR_NAME; 1071 data->dev->input_name = WBCIR_NAME;
1071 data->dev->input_phys = "wbcir/cir0"; 1072 data->dev->input_phys = "wbcir/cir0";
@@ -1083,7 +1084,15 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
1083 data->dev->dev.parent = &device->dev; 1084 data->dev->dev.parent = &device->dev;
1084 data->dev->timeout = MS_TO_NS(100); 1085 data->dev->timeout = MS_TO_NS(100);
1085 data->dev->rx_resolution = US_TO_NS(2); 1086 data->dev->rx_resolution = US_TO_NS(2);
1086 data->dev->allowed_protocols = RC_BIT_ALL; 1087 data->dev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
1088 data->dev->allowed_wakeup_protocols = RC_BIT_NEC | RC_BIT_NECX |
1089 RC_BIT_NEC32 | RC_BIT_RC5 | RC_BIT_RC6_0 |
1090 RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 |
1091 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE;
1092 data->dev->wakeup_protocol = RC_TYPE_RC6_MCE;
1093 data->dev->scancode_wakeup_filter.data = 0x800f040c;
1094 data->dev->scancode_wakeup_filter.mask = 0xffff7fff;
1095 data->dev->s_wakeup_filter = wbcir_set_wakeup_filter;
1087 1096
1088 err = rc_register_device(data->dev); 1097 err = rc_register_device(data->dev);
1089 if (err) 1098 if (err)
@@ -1199,15 +1208,6 @@ wbcir_init(void)
1199{ 1208{
1200 int ret; 1209 int ret;
1201 1210
1202 switch (protocol) {
1203 case IR_PROTOCOL_RC5:
1204 case IR_PROTOCOL_NEC:
1205 case IR_PROTOCOL_RC6:
1206 break;
1207 default:
1208 pr_err("Invalid power-on protocol\n");
1209 }
1210
1211 ret = pnp_register_driver(&wbcir_driver); 1211 ret = pnp_register_driver(&wbcir_driver);
1212 if (ret) 1212 if (ret)
1213 pr_err("Unable to register driver\n"); 1213 pr_err("Unable to register driver\n");
diff --git a/drivers/media/tuners/fc0011.c b/drivers/media/tuners/fc0011.c
index 00489a9df4e4..192b1c7740df 100644
--- a/drivers/media/tuners/fc0011.c
+++ b/drivers/media/tuners/fc0011.c
@@ -15,10 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 18 */
23 19
24#include "fc0011.h" 20#include "fc0011.h"
diff --git a/drivers/media/tuners/fc0012-priv.h b/drivers/media/tuners/fc0012-priv.h
index 1a86ce1d3fcf..0fbf0114bdcd 100644
--- a/drivers/media/tuners/fc0012-priv.h
+++ b/drivers/media/tuners/fc0012-priv.h
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#ifndef _FC0012_PRIV_H_ 17#ifndef _FC0012_PRIV_H_
diff --git a/drivers/media/tuners/fc0012.c b/drivers/media/tuners/fc0012.c
index 30508f44e5f9..dcc323ffbde7 100644
--- a/drivers/media/tuners/fc0012.c
+++ b/drivers/media/tuners/fc0012.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#include "fc0012.h" 17#include "fc0012.h"
diff --git a/drivers/media/tuners/fc0012.h b/drivers/media/tuners/fc0012.h
index 4a23e418daf0..64d07a2adb2e 100644
--- a/drivers/media/tuners/fc0012.h
+++ b/drivers/media/tuners/fc0012.h
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#ifndef _FC0012_H_ 17#ifndef _FC0012_H_
diff --git a/drivers/media/tuners/fc0013-priv.h b/drivers/media/tuners/fc0013-priv.h
index bfd49dedea22..2eeaca8abae5 100644
--- a/drivers/media/tuners/fc0013-priv.h
+++ b/drivers/media/tuners/fc0013-priv.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */ 16 */
21 17
22#ifndef _FC0013_PRIV_H_ 18#ifndef _FC0013_PRIV_H_
diff --git a/drivers/media/tuners/fc0013.c b/drivers/media/tuners/fc0013.c
index f7cf0e9e7c99..91dfa770a5cc 100644
--- a/drivers/media/tuners/fc0013.c
+++ b/drivers/media/tuners/fc0013.c
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 */ 18 */
23 19
24#include "fc0013.h" 20#include "fc0013.h"
diff --git a/drivers/media/tuners/fc0013.h b/drivers/media/tuners/fc0013.h
index 8c34105c9383..4431e7ceb43d 100644
--- a/drivers/media/tuners/fc0013.h
+++ b/drivers/media/tuners/fc0013.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */ 16 */
21 17
22#ifndef _FC0013_H_ 18#ifndef _FC0013_H_
diff --git a/drivers/media/tuners/fc001x-common.h b/drivers/media/tuners/fc001x-common.h
index 718818156934..3a96ff76c195 100644
--- a/drivers/media/tuners/fc001x-common.h
+++ b/drivers/media/tuners/fc001x-common.h
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#ifndef _FC001X_COMMON_H_ 17#ifndef _FC001X_COMMON_H_
diff --git a/drivers/media/tuners/it913x.c b/drivers/media/tuners/it913x.c
index 6c3ef2181fcd..27e5bc1c3cb5 100644
--- a/drivers/media/tuners/it913x.c
+++ b/drivers/media/tuners/it913x.c
@@ -14,17 +14,14 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * 15 *
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
21 */ 17 */
22 18
23#include "it913x.h" 19#include "it913x.h"
20#include <linux/platform_device.h>
24#include <linux/regmap.h> 21#include <linux/regmap.h>
25 22
26struct it913x_dev { 23struct it913x_dev {
27 struct i2c_client *client; 24 struct platform_device *pdev;
28 struct regmap *regmap; 25 struct regmap *regmap;
29 struct dvb_frontend *fe; 26 struct dvb_frontend *fe;
30 u8 chip_ver:2; 27 u8 chip_ver:2;
@@ -39,13 +36,14 @@ struct it913x_dev {
39static int it913x_init(struct dvb_frontend *fe) 36static int it913x_init(struct dvb_frontend *fe)
40{ 37{
41 struct it913x_dev *dev = fe->tuner_priv; 38 struct it913x_dev *dev = fe->tuner_priv;
39 struct platform_device *pdev = dev->pdev;
42 int ret; 40 int ret;
43 unsigned int utmp; 41 unsigned int utmp;
44 u8 iqik_m_cal, nv_val, buf[2]; 42 u8 iqik_m_cal, nv_val, buf[2];
45 static const u8 nv[] = {48, 32, 24, 16, 12, 8, 6, 4, 2}; 43 static const u8 nv[] = {48, 32, 24, 16, 12, 8, 6, 4, 2};
46 unsigned long timeout; 44 unsigned long timeout;
47 45
48 dev_dbg(&dev->client->dev, "role %u\n", dev->role); 46 dev_dbg(&pdev->dev, "role %u\n", dev->role);
49 47
50 ret = regmap_write(dev->regmap, 0x80ec4c, 0x68); 48 ret = regmap_write(dev->regmap, 0x80ec4c, 0x68);
51 if (ret) 49 if (ret)
@@ -73,7 +71,7 @@ static int it913x_init(struct dvb_frontend *fe)
73 iqik_m_cal = 6; 71 iqik_m_cal = 6;
74 break; 72 break;
75 default: 73 default:
76 dev_err(&dev->client->dev, "unknown clock identifier %d\n", utmp); 74 dev_err(&pdev->dev, "unknown clock identifier %d\n", utmp);
77 goto err; 75 goto err;
78 } 76 }
79 77
@@ -98,14 +96,14 @@ static int it913x_init(struct dvb_frontend *fe)
98 break; 96 break;
99 } 97 }
100 98
101 dev_dbg(&dev->client->dev, "r_fbc_m_bdry took %u ms, val %u\n", 99 dev_dbg(&pdev->dev, "r_fbc_m_bdry took %u ms, val %u\n",
102 jiffies_to_msecs(jiffies) - 100 jiffies_to_msecs(jiffies) -
103 (jiffies_to_msecs(timeout) - TIMEOUT), utmp); 101 (jiffies_to_msecs(timeout) - TIMEOUT), utmp);
104 102
105 dev->fn_min = dev->xtal * utmp; 103 dev->fn_min = dev->xtal * utmp;
106 dev->fn_min /= (dev->fdiv * nv_val); 104 dev->fn_min /= (dev->fdiv * nv_val);
107 dev->fn_min *= 1000; 105 dev->fn_min *= 1000;
108 dev_dbg(&dev->client->dev, "fn_min %u\n", dev->fn_min); 106 dev_dbg(&pdev->dev, "fn_min %u\n", dev->fn_min);
109 107
110 /* 108 /*
111 * Chip version BX never sets that flag so we just wait 50ms in that 109 * Chip version BX never sets that flag so we just wait 50ms in that
@@ -125,7 +123,7 @@ static int it913x_init(struct dvb_frontend *fe)
125 break; 123 break;
126 } 124 }
127 125
128 dev_dbg(&dev->client->dev, "p_tsm_init_mode took %u ms, val %u\n", 126 dev_dbg(&pdev->dev, "p_tsm_init_mode took %u ms, val %u\n",
129 jiffies_to_msecs(jiffies) - 127 jiffies_to_msecs(jiffies) -
130 (jiffies_to_msecs(timeout) - TIMEOUT), utmp); 128 (jiffies_to_msecs(timeout) - TIMEOUT), utmp);
131 } else { 129 } else {
@@ -152,16 +150,17 @@ static int it913x_init(struct dvb_frontend *fe)
152 150
153 return 0; 151 return 0;
154err: 152err:
155 dev_dbg(&dev->client->dev, "failed %d\n", ret); 153 dev_dbg(&pdev->dev, "failed %d\n", ret);
156 return ret; 154 return ret;
157} 155}
158 156
159static int it913x_sleep(struct dvb_frontend *fe) 157static int it913x_sleep(struct dvb_frontend *fe)
160{ 158{
161 struct it913x_dev *dev = fe->tuner_priv; 159 struct it913x_dev *dev = fe->tuner_priv;
160 struct platform_device *pdev = dev->pdev;
162 int ret, len; 161 int ret, len;
163 162
164 dev_dbg(&dev->client->dev, "role %u\n", dev->role); 163 dev_dbg(&pdev->dev, "role %u\n", dev->role);
165 164
166 dev->active = false; 165 dev->active = false;
167 166
@@ -178,7 +177,7 @@ static int it913x_sleep(struct dvb_frontend *fe)
178 else 177 else
179 len = 15; 178 len = 15;
180 179
181 dev_dbg(&dev->client->dev, "role %u, len %d\n", dev->role, len); 180 dev_dbg(&pdev->dev, "role %u, len %d\n", dev->role, len);
182 181
183 ret = regmap_bulk_write(dev->regmap, 0x80ec02, 182 ret = regmap_bulk_write(dev->regmap, 0x80ec02,
184 "\x3f\x1f\x3f\x3e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 183 "\x3f\x1f\x3f\x3e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -210,13 +209,14 @@ static int it913x_sleep(struct dvb_frontend *fe)
210 209
211 return 0; 210 return 0;
212err: 211err:
213 dev_dbg(&dev->client->dev, "failed %d\n", ret); 212 dev_dbg(&pdev->dev, "failed %d\n", ret);
214 return ret; 213 return ret;
215} 214}
216 215
217static int it913x_set_params(struct dvb_frontend *fe) 216static int it913x_set_params(struct dvb_frontend *fe)
218{ 217{
219 struct it913x_dev *dev = fe->tuner_priv; 218 struct it913x_dev *dev = fe->tuner_priv;
219 struct platform_device *pdev = dev->pdev;
220 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 220 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
221 int ret; 221 int ret;
222 unsigned int utmp; 222 unsigned int utmp;
@@ -224,7 +224,7 @@ static int it913x_set_params(struct dvb_frontend *fe)
224 u16 iqik_m_cal, n_div; 224 u16 iqik_m_cal, n_div;
225 u8 u8tmp, n, l_band, lna_band; 225 u8 u8tmp, n, l_band, lna_band;
226 226
227 dev_dbg(&dev->client->dev, "role=%u, frequency %u, bandwidth_hz %u\n", 227 dev_dbg(&pdev->dev, "role=%u, frequency %u, bandwidth_hz %u\n",
228 dev->role, c->frequency, c->bandwidth_hz); 228 dev->role, c->frequency, c->bandwidth_hz);
229 229
230 if (!dev->active) { 230 if (!dev->active) {
@@ -290,7 +290,7 @@ static int it913x_set_params(struct dvb_frontend *fe)
290 pre_lo_freq += (u32) n << 13; 290 pre_lo_freq += (u32) n << 13;
291 /* Frequency OMEGA_IQIK_M_CAL_MID*/ 291 /* Frequency OMEGA_IQIK_M_CAL_MID*/
292 t_cal_freq = pre_lo_freq + (u32)iqik_m_cal; 292 t_cal_freq = pre_lo_freq + (u32)iqik_m_cal;
293 dev_dbg(&dev->client->dev, "t_cal_freq %u, pre_lo_freq %u\n", 293 dev_dbg(&pdev->dev, "t_cal_freq %u, pre_lo_freq %u\n",
294 t_cal_freq, pre_lo_freq); 294 t_cal_freq, pre_lo_freq);
295 295
296 if (c->frequency <= 440000000) { 296 if (c->frequency <= 440000000) {
@@ -369,7 +369,7 @@ static int it913x_set_params(struct dvb_frontend *fe)
369 369
370 return 0; 370 return 0;
371err: 371err:
372 dev_dbg(&dev->client->dev, "failed %d\n", ret); 372 dev_dbg(&pdev->dev, "failed %d\n", ret);
373 return ret; 373 return ret;
374} 374}
375 375
@@ -385,40 +385,32 @@ static const struct dvb_tuner_ops it913x_tuner_ops = {
385 .set_params = it913x_set_params, 385 .set_params = it913x_set_params,
386}; 386};
387 387
388static int it913x_probe(struct i2c_client *client, 388static int it913x_probe(struct platform_device *pdev)
389 const struct i2c_device_id *id)
390{ 389{
391 struct it913x_config *cfg = client->dev.platform_data; 390 struct it913x_platform_data *pdata = pdev->dev.platform_data;
392 struct dvb_frontend *fe = cfg->fe; 391 struct dvb_frontend *fe = pdata->fe;
393 struct it913x_dev *dev; 392 struct it913x_dev *dev;
393 const struct platform_device_id *id = platform_get_device_id(pdev);
394 int ret; 394 int ret;
395 char *chip_ver_str; 395 char *chip_ver_str;
396 static const struct regmap_config regmap_config = {
397 .reg_bits = 24,
398 .val_bits = 8,
399 };
400 396
401 dev = kzalloc(sizeof(struct it913x_dev), GFP_KERNEL); 397 dev = kzalloc(sizeof(struct it913x_dev), GFP_KERNEL);
402 if (dev == NULL) { 398 if (dev == NULL) {
403 ret = -ENOMEM; 399 ret = -ENOMEM;
404 dev_err(&client->dev, "kzalloc() failed\n"); 400 dev_err(&pdev->dev, "kzalloc() failed\n");
405 goto err; 401 goto err;
406 } 402 }
407 403
408 dev->client = client; 404 dev->pdev = pdev;
409 dev->fe = cfg->fe; 405 dev->regmap = pdata->regmap;
410 dev->chip_ver = cfg->chip_ver; 406 dev->fe = pdata->fe;
411 dev->role = cfg->role; 407 dev->chip_ver = id->driver_data;
412 dev->regmap = regmap_init_i2c(client, &regmap_config); 408 dev->role = pdata->role;
413 if (IS_ERR(dev->regmap)) {
414 ret = PTR_ERR(dev->regmap);
415 goto err_kfree;
416 }
417 409
418 fe->tuner_priv = dev; 410 fe->tuner_priv = dev;
419 memcpy(&fe->ops.tuner_ops, &it913x_tuner_ops, 411 memcpy(&fe->ops.tuner_ops, &it913x_tuner_ops,
420 sizeof(struct dvb_tuner_ops)); 412 sizeof(struct dvb_tuner_ops));
421 i2c_set_clientdata(client, dev); 413 platform_set_drvdata(pdev, dev);
422 414
423 if (dev->chip_ver == 1) 415 if (dev->chip_ver == 1)
424 chip_ver_str = "AX"; 416 chip_ver_str = "AX";
@@ -427,41 +419,37 @@ static int it913x_probe(struct i2c_client *client,
427 else 419 else
428 chip_ver_str = "??"; 420 chip_ver_str = "??";
429 421
430 dev_info(&dev->client->dev, "ITE IT913X %s successfully attached\n", 422 dev_info(&pdev->dev, "ITE IT913X %s successfully attached\n",
431 chip_ver_str); 423 chip_ver_str);
432 dev_dbg(&dev->client->dev, "chip_ver %u, role %u\n", 424 dev_dbg(&pdev->dev, "chip_ver %u, role %u\n", dev->chip_ver, dev->role);
433 dev->chip_ver, dev->role);
434 return 0; 425 return 0;
435
436err_kfree:
437 kfree(dev);
438err: 426err:
439 dev_dbg(&client->dev, "failed %d\n", ret); 427 dev_dbg(&pdev->dev, "failed %d\n", ret);
440 return ret; 428 return ret;
441} 429}
442 430
443static int it913x_remove(struct i2c_client *client) 431static int it913x_remove(struct platform_device *pdev)
444{ 432{
445 struct it913x_dev *dev = i2c_get_clientdata(client); 433 struct it913x_dev *dev = platform_get_drvdata(pdev);
446 struct dvb_frontend *fe = dev->fe; 434 struct dvb_frontend *fe = dev->fe;
447 435
448 dev_dbg(&client->dev, "\n"); 436 dev_dbg(&pdev->dev, "\n");
449 437
450 memset(&fe->ops.tuner_ops, 0, sizeof(struct dvb_tuner_ops)); 438 memset(&fe->ops.tuner_ops, 0, sizeof(struct dvb_tuner_ops));
451 fe->tuner_priv = NULL; 439 fe->tuner_priv = NULL;
452 regmap_exit(dev->regmap);
453 kfree(dev); 440 kfree(dev);
454 441
455 return 0; 442 return 0;
456} 443}
457 444
458static const struct i2c_device_id it913x_id_table[] = { 445static const struct platform_device_id it913x_id_table[] = {
459 {"it913x", 0}, 446 {"it9133ax-tuner", 1},
460 {} 447 {"it9133bx-tuner", 2},
448 {},
461}; 449};
462MODULE_DEVICE_TABLE(i2c, it913x_id_table); 450MODULE_DEVICE_TABLE(platform, it913x_id_table);
463 451
464static struct i2c_driver it913x_driver = { 452static struct platform_driver it913x_driver = {
465 .driver = { 453 .driver = {
466 .name = "it913x", 454 .name = "it913x",
467 .suppress_bind_attrs = true, 455 .suppress_bind_attrs = true,
@@ -471,7 +459,7 @@ static struct i2c_driver it913x_driver = {
471 .id_table = it913x_id_table, 459 .id_table = it913x_id_table,
472}; 460};
473 461
474module_i2c_driver(it913x_driver); 462module_platform_driver(it913x_driver);
475 463
476MODULE_DESCRIPTION("ITE IT913X silicon tuner driver"); 464MODULE_DESCRIPTION("ITE IT913X silicon tuner driver");
477MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); 465MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
diff --git a/drivers/media/tuners/it913x.h b/drivers/media/tuners/it913x.h
index 33de53d4a566..226f657228fb 100644
--- a/drivers/media/tuners/it913x.h
+++ b/drivers/media/tuners/it913x.h
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * 15 *
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
21 */ 17 */
22 18
23#ifndef IT913X_H 19#ifndef IT913X_H
@@ -25,26 +21,16 @@
25 21
26#include "dvb_frontend.h" 22#include "dvb_frontend.h"
27 23
28/* 24/**
29 * I2C address 25 * struct it913x_platform_data - Platform data for the it913x driver
30 * 0x38, 0x3a, 0x3c, 0x3e 26 * @regmap: af9033 demod driver regmap.
27 * @dvb_frontend: af9033 demod driver DVB frontend.
28 * @role: Chip role, single or dual configuration.
31 */ 29 */
32struct it913x_config {
33 /*
34 * pointer to DVB frontend
35 */
36 struct dvb_frontend *fe;
37 30
38 /* 31struct it913x_platform_data {
39 * chip version 32 struct regmap *regmap;
40 * 1 = IT9135 AX 33 struct dvb_frontend *fe;
41 * 2 = IT9135 BX
42 */
43 unsigned int chip_ver:2;
44
45 /*
46 * tuner role
47 */
48#define IT913X_ROLE_SINGLE 0 34#define IT913X_ROLE_SINGLE 0
49#define IT913X_ROLE_DUAL_MASTER 1 35#define IT913X_ROLE_DUAL_MASTER 1
50#define IT913X_ROLE_DUAL_SLAVE 2 36#define IT913X_ROLE_DUAL_SLAVE 2
diff --git a/drivers/media/tuners/max2165.c b/drivers/media/tuners/max2165.c
index c3f10925b0d4..a86c08114915 100644
--- a/drivers/media/tuners/max2165.c
+++ b/drivers/media/tuners/max2165.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include <linux/module.h> 18#include <linux/module.h>
diff --git a/drivers/media/tuners/max2165.h b/drivers/media/tuners/max2165.h
index aadd9fea59e4..3120c54ec154 100644
--- a/drivers/media/tuners/max2165.h
+++ b/drivers/media/tuners/max2165.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#ifndef __MAX2165_H__ 18#ifndef __MAX2165_H__
diff --git a/drivers/media/tuners/max2165_priv.h b/drivers/media/tuners/max2165_priv.h
index 91bbe021a08d..20d7751881a3 100644
--- a/drivers/media/tuners/max2165_priv.h
+++ b/drivers/media/tuners/max2165_priv.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#ifndef __MAX2165_PRIV_H__ 18#ifndef __MAX2165_PRIV_H__
diff --git a/drivers/media/tuners/mc44s803.c b/drivers/media/tuners/mc44s803.c
index aba580b4ac2c..12f545ef1243 100644
--- a/drivers/media/tuners/mc44s803.c
+++ b/drivers/media/tuners/mc44s803.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */ 16 */
21 17
22#include <linux/module.h> 18#include <linux/module.h>
diff --git a/drivers/media/tuners/mc44s803.h b/drivers/media/tuners/mc44s803.h
index 6b40df339284..f68133fb9760 100644
--- a/drivers/media/tuners/mc44s803.h
+++ b/drivers/media/tuners/mc44s803.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */ 16 */
21 17
22#ifndef MC44S803_H 18#ifndef MC44S803_H
diff --git a/drivers/media/tuners/mc44s803_priv.h b/drivers/media/tuners/mc44s803_priv.h
index 14a92780906d..52325395dfe7 100644
--- a/drivers/media/tuners/mc44s803_priv.h
+++ b/drivers/media/tuners/mc44s803_priv.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */ 16 */
21 17
22#ifndef MC44S803_PRIV_H 18#ifndef MC44S803_PRIV_H
diff --git a/drivers/media/tuners/mt2060.c b/drivers/media/tuners/mt2060.c
index 94077ea78dde..2e487f9a2cc3 100644
--- a/drivers/media/tuners/mt2060.c
+++ b/drivers/media/tuners/mt2060.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */ 16 */
21 17
22/* In that file, frequencies are expressed in kiloHertz to avoid 32 bits overflows */ 18/* In that file, frequencies are expressed in kiloHertz to avoid 32 bits overflows */
@@ -71,13 +67,24 @@ static int mt2060_writereg(struct mt2060_priv *priv, u8 reg, u8 val)
71// Writes a set of consecutive registers 67// Writes a set of consecutive registers
72static int mt2060_writeregs(struct mt2060_priv *priv,u8 *buf, u8 len) 68static int mt2060_writeregs(struct mt2060_priv *priv,u8 *buf, u8 len)
73{ 69{
70 int rem, val_len;
71 u8 xfer_buf[16];
74 struct i2c_msg msg = { 72 struct i2c_msg msg = {
75 .addr = priv->cfg->i2c_address, .flags = 0, .buf = buf, .len = len 73 .addr = priv->cfg->i2c_address, .flags = 0, .buf = xfer_buf
76 }; 74 };
77 if (i2c_transfer(priv->i2c, &msg, 1) != 1) { 75
78 printk(KERN_WARNING "mt2060 I2C write failed (len=%i)\n",(int)len); 76 for (rem = len - 1; rem > 0; rem -= priv->i2c_max_regs) {
79 return -EREMOTEIO; 77 val_len = min_t(int, rem, priv->i2c_max_regs);
78 msg.len = 1 + val_len;
79 xfer_buf[0] = buf[0] + len - 1 - rem;
80 memcpy(&xfer_buf[1], &buf[1 + len - 1 - rem], val_len);
81
82 if (i2c_transfer(priv->i2c, &msg, 1) != 1) {
83 printk(KERN_WARNING "mt2060 I2C write failed (len=%i)\n", val_len);
84 return -EREMOTEIO;
85 }
80 } 86 }
87
81 return 0; 88 return 0;
82} 89}
83 90
@@ -306,9 +313,16 @@ static int mt2060_init(struct dvb_frontend *fe)
306 if (fe->ops.i2c_gate_ctrl) 313 if (fe->ops.i2c_gate_ctrl)
307 fe->ops.i2c_gate_ctrl(fe, 1); /* open i2c_gate */ 314 fe->ops.i2c_gate_ctrl(fe, 1); /* open i2c_gate */
308 315
316 if (priv->sleep) {
317 ret = mt2060_writereg(priv, REG_MISC_CTRL, 0x20);
318 if (ret)
319 goto err_i2c_gate_ctrl;
320 }
321
309 ret = mt2060_writereg(priv, REG_VGAG, 322 ret = mt2060_writereg(priv, REG_VGAG,
310 (priv->cfg->clock_out << 6) | 0x33); 323 (priv->cfg->clock_out << 6) | 0x33);
311 324
325err_i2c_gate_ctrl:
312 if (fe->ops.i2c_gate_ctrl) 326 if (fe->ops.i2c_gate_ctrl)
313 fe->ops.i2c_gate_ctrl(fe, 0); /* close i2c_gate */ 327 fe->ops.i2c_gate_ctrl(fe, 0); /* close i2c_gate */
314 328
@@ -325,7 +339,13 @@ static int mt2060_sleep(struct dvb_frontend *fe)
325 339
326 ret = mt2060_writereg(priv, REG_VGAG, 340 ret = mt2060_writereg(priv, REG_VGAG,
327 (priv->cfg->clock_out << 6) | 0x30); 341 (priv->cfg->clock_out << 6) | 0x30);
342 if (ret)
343 goto err_i2c_gate_ctrl;
344
345 if (priv->sleep)
346 ret = mt2060_writereg(priv, REG_MISC_CTRL, 0xe8);
328 347
348err_i2c_gate_ctrl:
329 if (fe->ops.i2c_gate_ctrl) 349 if (fe->ops.i2c_gate_ctrl)
330 fe->ops.i2c_gate_ctrl(fe, 0); /* close i2c_gate */ 350 fe->ops.i2c_gate_ctrl(fe, 0); /* close i2c_gate */
331 351
@@ -369,6 +389,7 @@ struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter
369 priv->cfg = cfg; 389 priv->cfg = cfg;
370 priv->i2c = i2c; 390 priv->i2c = i2c;
371 priv->if1_freq = if1; 391 priv->if1_freq = if1;
392 priv->i2c_max_regs = ~0;
372 393
373 if (fe->ops.i2c_gate_ctrl) 394 if (fe->ops.i2c_gate_ctrl)
374 fe->ops.i2c_gate_ctrl(fe, 1); /* open i2c_gate */ 395 fe->ops.i2c_gate_ctrl(fe, 1); /* open i2c_gate */
@@ -396,6 +417,98 @@ struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter
396} 417}
397EXPORT_SYMBOL(mt2060_attach); 418EXPORT_SYMBOL(mt2060_attach);
398 419
420static int mt2060_probe(struct i2c_client *client,
421 const struct i2c_device_id *id)
422{
423 struct mt2060_platform_data *pdata = client->dev.platform_data;
424 struct dvb_frontend *fe;
425 struct mt2060_priv *dev;
426 int ret;
427 u8 chip_id;
428
429 dev_dbg(&client->dev, "\n");
430
431 if (!pdata) {
432 dev_err(&client->dev, "Cannot proceed without platform data\n");
433 ret = -EINVAL;
434 goto err;
435 }
436
437 dev = devm_kzalloc(&client->dev, sizeof(*dev), GFP_KERNEL);
438 if (!dev) {
439 ret = -ENOMEM;
440 goto err;
441 }
442
443 fe = pdata->dvb_frontend;
444 dev->config.i2c_address = client->addr;
445 dev->config.clock_out = pdata->clock_out;
446 dev->cfg = &dev->config;
447 dev->i2c = client->adapter;
448 dev->if1_freq = pdata->if1 ? pdata->if1 : 1220;
449 dev->client = client;
450 dev->i2c_max_regs = pdata->i2c_write_max ? pdata->i2c_write_max - 1 : ~0;
451 dev->sleep = true;
452
453 ret = mt2060_readreg(dev, REG_PART_REV, &chip_id);
454 if (ret) {
455 ret = -ENODEV;
456 goto err;
457 }
458
459 dev_dbg(&client->dev, "chip id=%02x\n", chip_id);
460
461 if (chip_id != PART_REV) {
462 ret = -ENODEV;
463 goto err;
464 }
465
466 /* Power on, calibrate, sleep */
467 ret = mt2060_writereg(dev, REG_MISC_CTRL, 0x20);
468 if (ret)
469 goto err;
470 mt2060_calibrate(dev);
471 ret = mt2060_writereg(dev, REG_MISC_CTRL, 0xe8);
472 if (ret)
473 goto err;
474
475 dev_info(&client->dev, "Microtune MT2060 successfully identified\n");
476 memcpy(&fe->ops.tuner_ops, &mt2060_tuner_ops, sizeof(fe->ops.tuner_ops));
477 fe->ops.tuner_ops.release = NULL;
478 fe->tuner_priv = dev;
479 i2c_set_clientdata(client, dev);
480
481 return 0;
482err:
483 dev_dbg(&client->dev, "failed=%d\n", ret);
484 return ret;
485}
486
487static int mt2060_remove(struct i2c_client *client)
488{
489 dev_dbg(&client->dev, "\n");
490
491 return 0;
492}
493
494static const struct i2c_device_id mt2060_id_table[] = {
495 {"mt2060", 0},
496 {}
497};
498MODULE_DEVICE_TABLE(i2c, mt2060_id_table);
499
500static struct i2c_driver mt2060_driver = {
501 .driver = {
502 .name = "mt2060",
503 .suppress_bind_attrs = true,
504 },
505 .probe = mt2060_probe,
506 .remove = mt2060_remove,
507 .id_table = mt2060_id_table,
508};
509
510module_i2c_driver(mt2060_driver);
511
399MODULE_AUTHOR("Olivier DANET"); 512MODULE_AUTHOR("Olivier DANET");
400MODULE_DESCRIPTION("Microtune MT2060 silicon tuner driver"); 513MODULE_DESCRIPTION("Microtune MT2060 silicon tuner driver");
401MODULE_LICENSE("GPL"); 514MODULE_LICENSE("GPL");
diff --git a/drivers/media/tuners/mt2060.h b/drivers/media/tuners/mt2060.h
index 6efed359a24f..cc534eb41378 100644
--- a/drivers/media/tuners/mt2060.h
+++ b/drivers/media/tuners/mt2060.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */ 16 */
21 17
22#ifndef MT2060_H 18#ifndef MT2060_H
@@ -25,6 +21,29 @@
25struct dvb_frontend; 21struct dvb_frontend;
26struct i2c_adapter; 22struct i2c_adapter;
27 23
24/*
25 * I2C address
26 * 0x60, ...
27 */
28
29/**
30 * struct mt2060_platform_data - Platform data for the mt2060 driver
31 * @clock_out: Clock output setting. 0 = off, 1 = CLK/4, 2 = CLK/2, 3 = CLK/1.
32 * @if1: First IF used [MHz]. 0 defaults to 1220.
33 * @i2c_write_max: Maximum number of bytes I2C adapter can write at once.
34 * 0 defaults to maximum.
35 * @dvb_frontend: DVB frontend.
36 */
37
38struct mt2060_platform_data {
39 u8 clock_out;
40 u16 if1;
41 unsigned int i2c_write_max:5;
42 struct dvb_frontend *dvb_frontend;
43};
44
45
46/* configuration struct for mt2060_attach() */
28struct mt2060_config { 47struct mt2060_config {
29 u8 i2c_address; 48 u8 i2c_address;
30 u8 clock_out; /* 0 = off, 1 = CLK/4, 2 = CLK/2, 3 = CLK/1 */ 49 u8 clock_out; /* 0 = off, 1 = CLK/4, 2 = CLK/2, 3 = CLK/1 */
diff --git a/drivers/media/tuners/mt2060_priv.h b/drivers/media/tuners/mt2060_priv.h
index 2b60de6c707d..a6c931c1a5a7 100644
--- a/drivers/media/tuners/mt2060_priv.h
+++ b/drivers/media/tuners/mt2060_priv.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */ 16 */
21 17
22#ifndef MT2060_PRIV_H 18#ifndef MT2060_PRIV_H
@@ -95,10 +91,21 @@
95struct mt2060_priv { 91struct mt2060_priv {
96 struct mt2060_config *cfg; 92 struct mt2060_config *cfg;
97 struct i2c_adapter *i2c; 93 struct i2c_adapter *i2c;
94 struct i2c_client *client;
95 struct mt2060_config config;
98 96
97 u8 i2c_max_regs;
99 u32 frequency; 98 u32 frequency;
100 u16 if1_freq; 99 u16 if1_freq;
101 u8 fmfreq; 100 u8 fmfreq;
101
102 /*
103 * Use REG_MISC_CTRL register for sleep. That drops sleep power usage
104 * about 0.9W (huge!). Register bit meanings are unknown, so let it be
105 * disabled by default to avoid possible regression. Convert driver to
106 * i2c model in order to enable it.
107 */
108 bool sleep;
102}; 109};
103 110
104#endif 111#endif
diff --git a/drivers/media/tuners/mt2131.c b/drivers/media/tuners/mt2131.c
index e7790e4afcfe..dd85d58fa8d0 100644
--- a/drivers/media/tuners/mt2131.c
+++ b/drivers/media/tuners/mt2131.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include <linux/module.h> 18#include <linux/module.h>
diff --git a/drivers/media/tuners/mt2131.h b/drivers/media/tuners/mt2131.h
index 8267a6ae5d84..050da5540b15 100644
--- a/drivers/media/tuners/mt2131.h
+++ b/drivers/media/tuners/mt2131.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#ifndef __MT2131_H__ 18#ifndef __MT2131_H__
diff --git a/drivers/media/tuners/mt2131_priv.h b/drivers/media/tuners/mt2131_priv.h
index 91283b599cb3..d2b6f29182cc 100644
--- a/drivers/media/tuners/mt2131_priv.h
+++ b/drivers/media/tuners/mt2131_priv.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#ifndef __MT2131_PRIV_H__ 18#ifndef __MT2131_PRIV_H__
diff --git a/drivers/media/tuners/mxl5007t.c b/drivers/media/tuners/mxl5007t.c
index b16dfa5e85fb..4081fd97c3b2 100644
--- a/drivers/media/tuners/mxl5007t.c
+++ b/drivers/media/tuners/mxl5007t.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#include <linux/i2c.h> 17#include <linux/i2c.h>
diff --git a/drivers/media/tuners/mxl5007t.h b/drivers/media/tuners/mxl5007t.h
index e786d1f23ff1..273f61aeb8be 100644
--- a/drivers/media/tuners/mxl5007t.h
+++ b/drivers/media/tuners/mxl5007t.h
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#ifndef __MXL5007T_H__ 17#ifndef __MXL5007T_H__
diff --git a/drivers/media/tuners/qt1010.c b/drivers/media/tuners/qt1010.c
index a2c6cd1c3923..ee33b7cc7682 100644
--- a/drivers/media/tuners/qt1010.c
+++ b/drivers/media/tuners/qt1010.c
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21#include "qt1010.h" 17#include "qt1010.h"
22#include "qt1010_priv.h" 18#include "qt1010_priv.h"
diff --git a/drivers/media/tuners/qt1010.h b/drivers/media/tuners/qt1010.h
index e3198f23437c..276e59e85032 100644
--- a/drivers/media/tuners/qt1010.h
+++ b/drivers/media/tuners/qt1010.h
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#ifndef QT1010_H 18#ifndef QT1010_H
diff --git a/drivers/media/tuners/qt1010_priv.h b/drivers/media/tuners/qt1010_priv.h
index 2c42d3f01636..4cb78ecc8985 100644
--- a/drivers/media/tuners/qt1010_priv.h
+++ b/drivers/media/tuners/qt1010_priv.h
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#ifndef QT1010_PRIV_H 18#ifndef QT1010_PRIV_H
diff --git a/drivers/media/tuners/tda18218.c b/drivers/media/tuners/tda18218.c
index 8357a3c08a70..c56fcf5d48e3 100644
--- a/drivers/media/tuners/tda18218.c
+++ b/drivers/media/tuners/tda18218.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#include "tda18218_priv.h" 17#include "tda18218_priv.h"
diff --git a/drivers/media/tuners/tda18218.h b/drivers/media/tuners/tda18218.h
index 076b5f2e888d..9c0e3fd7ed7f 100644
--- a/drivers/media/tuners/tda18218.h
+++ b/drivers/media/tuners/tda18218.h
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#ifndef TDA18218_H 17#ifndef TDA18218_H
diff --git a/drivers/media/tuners/tda18218_priv.h b/drivers/media/tuners/tda18218_priv.h
index 285b77366c8d..9d04781966e7 100644
--- a/drivers/media/tuners/tda18218_priv.h
+++ b/drivers/media/tuners/tda18218_priv.h
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#ifndef TDA18218_PRIV_H 17#ifndef TDA18218_PRIV_H
diff --git a/drivers/media/tuners/tda827x.c b/drivers/media/tuners/tda827x.c
index 2137eadf30f1..8400808f8f7f 100644
--- a/drivers/media/tuners/tda827x.c
+++ b/drivers/media/tuners/tda827x.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#include <linux/module.h> 17#include <linux/module.h>
diff --git a/drivers/media/tuners/xc4000.c b/drivers/media/tuners/xc4000.c
index 03eef9b87a24..e30948e4ff87 100644
--- a/drivers/media/tuners/xc4000.c
+++ b/drivers/media/tuners/xc4000.c
@@ -16,10 +16,6 @@
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */ 19 */
24 20
25#include <linux/module.h> 21#include <linux/module.h>
diff --git a/drivers/media/tuners/xc4000.h b/drivers/media/tuners/xc4000.h
index 40517860cf67..8af93b63ff9e 100644
--- a/drivers/media/tuners/xc4000.h
+++ b/drivers/media/tuners/xc4000.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#ifndef __XC4000_H__ 18#ifndef __XC4000_H__
diff --git a/drivers/media/tuners/xc5000.c b/drivers/media/tuners/xc5000.c
index 796e7638b3b2..0345b274eccc 100644
--- a/drivers/media/tuners/xc5000.c
+++ b/drivers/media/tuners/xc5000.c
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * 16 *
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 18 */
23 19
24#include <linux/module.h> 20#include <linux/module.h>
diff --git a/drivers/media/tuners/xc5000.h b/drivers/media/tuners/xc5000.h
index 336bd49eb09b..42bbec2409fd 100644
--- a/drivers/media/tuners/xc5000.h
+++ b/drivers/media/tuners/xc5000.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#ifndef __XC5000_H__ 18#ifndef __XC5000_H__
diff --git a/drivers/media/usb/au0828/au0828-cards.c b/drivers/media/usb/au0828/au0828-cards.c
index 6b469e8c4c6e..313f659f0bfb 100644
--- a/drivers/media/usb/au0828/au0828-cards.c
+++ b/drivers/media/usb/au0828/au0828-cards.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include "au0828.h" 18#include "au0828.h"
diff --git a/drivers/media/usb/au0828/au0828-cards.h b/drivers/media/usb/au0828/au0828-cards.h
index 48a1882c2b6b..1f4412ee6da4 100644
--- a/drivers/media/usb/au0828/au0828-cards.h
+++ b/drivers/media/usb/au0828/au0828-cards.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#define AU0828_BOARD_UNKNOWN 0 18#define AU0828_BOARD_UNKNOWN 0
diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index bf53553d2624..739df61cec4f 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include "au0828.h" 18#include "au0828.h"
@@ -153,9 +149,11 @@ static void au0828_unregister_media_device(struct au0828_dev *dev)
153 } 149 }
154 150
155 /* clear enable_source, disable_source */ 151 /* clear enable_source, disable_source */
152 mutex_lock(&mdev->graph_mutex);
156 dev->media_dev->source_priv = NULL; 153 dev->media_dev->source_priv = NULL;
157 dev->media_dev->enable_source = NULL; 154 dev->media_dev->enable_source = NULL;
158 dev->media_dev->disable_source = NULL; 155 dev->media_dev->disable_source = NULL;
156 mutex_unlock(&mdev->graph_mutex);
159 157
160 media_device_unregister(dev->media_dev); 158 media_device_unregister(dev->media_dev);
161 media_device_cleanup(dev->media_dev); 159 media_device_cleanup(dev->media_dev);
@@ -278,6 +276,7 @@ create_link:
278 } 276 }
279} 277}
280 278
279/* Callers should hold graph_mutex */
281static int au0828_enable_source(struct media_entity *entity, 280static int au0828_enable_source(struct media_entity *entity,
282 struct media_pipeline *pipe) 281 struct media_pipeline *pipe)
283{ 282{
@@ -291,8 +290,6 @@ static int au0828_enable_source(struct media_entity *entity,
291 if (!mdev) 290 if (!mdev)
292 return -ENODEV; 291 return -ENODEV;
293 292
294 mutex_lock(&mdev->graph_mutex);
295
296 dev = mdev->source_priv; 293 dev = mdev->source_priv;
297 294
298 /* 295 /*
@@ -397,7 +394,7 @@ static int au0828_enable_source(struct media_entity *entity,
397 goto end; 394 goto end;
398 } 395 }
399 396
400 ret = __media_entity_pipeline_start(entity, pipe); 397 ret = __media_pipeline_start(entity, pipe);
401 if (ret) { 398 if (ret) {
402 pr_err("Start Pipeline: %s->%s Error %d\n", 399 pr_err("Start Pipeline: %s->%s Error %d\n",
403 source->name, entity->name, ret); 400 source->name, entity->name, ret);
@@ -419,12 +416,12 @@ static int au0828_enable_source(struct media_entity *entity,
419 dev->active_source->name, dev->active_sink->name, 416 dev->active_source->name, dev->active_sink->name,
420 dev->active_link_owner->name, ret); 417 dev->active_link_owner->name, ret);
421end: 418end:
422 mutex_unlock(&mdev->graph_mutex);
423 pr_debug("au0828_enable_source() end %s %d %d\n", 419 pr_debug("au0828_enable_source() end %s %d %d\n",
424 entity->name, entity->function, ret); 420 entity->name, entity->function, ret);
425 return ret; 421 return ret;
426} 422}
427 423
424/* Callers should hold graph_mutex */
428static void au0828_disable_source(struct media_entity *entity) 425static void au0828_disable_source(struct media_entity *entity)
429{ 426{
430 int ret = 0; 427 int ret = 0;
@@ -434,13 +431,10 @@ static void au0828_disable_source(struct media_entity *entity)
434 if (!mdev) 431 if (!mdev)
435 return; 432 return;
436 433
437 mutex_lock(&mdev->graph_mutex);
438 dev = mdev->source_priv; 434 dev = mdev->source_priv;
439 435
440 if (!dev->active_link) { 436 if (!dev->active_link)
441 ret = -ENODEV; 437 return;
442 goto end;
443 }
444 438
445 /* link is active - stop pipeline from source (tuner) */ 439 /* link is active - stop pipeline from source (tuner) */
446 if (dev->active_link->sink->entity == dev->active_sink && 440 if (dev->active_link->sink->entity == dev->active_sink &&
@@ -450,8 +444,8 @@ static void au0828_disable_source(struct media_entity *entity)
450 * has active pipeline 444 * has active pipeline
451 */ 445 */
452 if (dev->active_link_owner != entity) 446 if (dev->active_link_owner != entity)
453 goto end; 447 return;
454 __media_entity_pipeline_stop(entity); 448 __media_pipeline_stop(entity);
455 ret = __media_entity_setup_link(dev->active_link, 0); 449 ret = __media_entity_setup_link(dev->active_link, 0);
456 if (ret) 450 if (ret)
457 pr_err("Deactivate link Error %d\n", ret); 451 pr_err("Deactivate link Error %d\n", ret);
@@ -465,9 +459,6 @@ static void au0828_disable_source(struct media_entity *entity)
465 dev->active_source = NULL; 459 dev->active_source = NULL;
466 dev->active_sink = NULL; 460 dev->active_sink = NULL;
467 } 461 }
468
469end:
470 mutex_unlock(&mdev->graph_mutex);
471} 462}
472#endif 463#endif
473 464
@@ -549,9 +540,11 @@ static int au0828_media_device_register(struct au0828_dev *dev,
549 return ret; 540 return ret;
550 } 541 }
551 /* set enable_source */ 542 /* set enable_source */
543 mutex_lock(&dev->media_dev->graph_mutex);
552 dev->media_dev->source_priv = (void *) dev; 544 dev->media_dev->source_priv = (void *) dev;
553 dev->media_dev->enable_source = au0828_enable_source; 545 dev->media_dev->enable_source = au0828_enable_source;
554 dev->media_dev->disable_source = au0828_disable_source; 546 dev->media_dev->disable_source = au0828_disable_source;
547 mutex_unlock(&dev->media_dev->graph_mutex);
555#endif 548#endif
556 return 0; 549 return 0;
557} 550}
diff --git a/drivers/media/usb/au0828/au0828-dvb.c b/drivers/media/usb/au0828/au0828-dvb.c
index 0e174e860614..7e0c9b795e52 100644
--- a/drivers/media/usb/au0828/au0828-dvb.c
+++ b/drivers/media/usb/au0828/au0828-dvb.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include "au0828.h" 18#include "au0828.h"
diff --git a/drivers/media/usb/au0828/au0828-i2c.c b/drivers/media/usb/au0828/au0828-i2c.c
index ae7ac6669769..42b352bb4f02 100644
--- a/drivers/media/usb/au0828/au0828-i2c.c
+++ b/drivers/media/usb/au0828/au0828-i2c.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#include "au0828.h" 18#include "au0828.h"
diff --git a/drivers/media/usb/au0828/au0828-input.c b/drivers/media/usb/au0828/au0828-input.c
index 1e66e7828d8f..9ec919c68482 100644
--- a/drivers/media/usb/au0828/au0828-input.c
+++ b/drivers/media/usb/au0828/au0828-input.c
@@ -298,7 +298,7 @@ int au0828_rc_register(struct au0828_dev *dev)
298 return -ENODEV; 298 return -ENODEV;
299 299
300 ir = kzalloc(sizeof(*ir), GFP_KERNEL); 300 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
301 rc = rc_allocate_device(); 301 rc = rc_allocate_device(RC_DRIVER_IR_RAW);
302 if (!ir || !rc) 302 if (!ir || !rc)
303 goto error; 303 goto error;
304 304
@@ -343,7 +343,6 @@ int au0828_rc_register(struct au0828_dev *dev)
343 rc->input_id.product = le16_to_cpu(dev->usbdev->descriptor.idProduct); 343 rc->input_id.product = le16_to_cpu(dev->usbdev->descriptor.idProduct);
344 rc->dev.parent = &dev->usbdev->dev; 344 rc->dev.parent = &dev->usbdev->dev;
345 rc->driver_name = "au0828-input"; 345 rc->driver_name = "au0828-input";
346 rc->driver_type = RC_DRIVER_IR_RAW;
347 rc->allowed_protocols = RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32 | 346 rc->allowed_protocols = RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32 |
348 RC_BIT_RC5; 347 RC_BIT_RC5;
349 348
diff --git a/drivers/media/usb/au0828/au0828-reg.h b/drivers/media/usb/au0828/au0828-reg.h
index 2140f4cfb645..7aaf10739c8b 100644
--- a/drivers/media/usb/au0828/au0828-reg.h
+++ b/drivers/media/usb/au0828/au0828-reg.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22/* We'll start to rename these registers once we have a better 18/* We'll start to rename these registers once we have a better
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 7a10eaa38f67..16f9125a985a 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -13,11 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 */ 16 */
22 17
23/* Developer Notes: 18/* Developer Notes:
diff --git a/drivers/media/usb/au0828/au0828.h b/drivers/media/usb/au0828/au0828.h
index dd7b378fe070..88e59748ebc2 100644
--- a/drivers/media/usb/au0828/au0828.h
+++ b/drivers/media/usb/au0828/au0828.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * 14 *
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/cpia2/cpia2.h b/drivers/media/usb/cpia2/cpia2.h
index cdef677d57ec..81f72c0b561f 100644
--- a/drivers/media/usb/cpia2/cpia2.h
+++ b/drivers/media/usb/cpia2/cpia2.h
@@ -22,10 +22,6 @@
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details. 23 * GNU General Public License for more details.
24 * 24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 *
29 ****************************************************************************/ 25 ****************************************************************************/
30 26
31#ifndef __CPIA2_H__ 27#ifndef __CPIA2_H__
diff --git a/drivers/media/usb/cpia2/cpia2_core.c b/drivers/media/usb/cpia2/cpia2_core.c
index 0310fd6ed103..431dd0b4b332 100644
--- a/drivers/media/usb/cpia2/cpia2_core.c
+++ b/drivers/media/usb/cpia2/cpia2_core.c
@@ -20,10 +20,6 @@
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 21 * GNU General Public License for more details.
22 * 22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 * Stripped of 2.4 stuff ready for main kernel submit by 23 * Stripped of 2.4 stuff ready for main kernel submit by
28 * Alan Cox <alan@lxorguk.ukuu.org.uk> 24 * Alan Cox <alan@lxorguk.ukuu.org.uk>
29 * 25 *
diff --git a/drivers/media/usb/cpia2/cpia2_registers.h b/drivers/media/usb/cpia2/cpia2_registers.h
index 3bbec514a967..eebe46ea9c01 100644
--- a/drivers/media/usb/cpia2/cpia2_registers.h
+++ b/drivers/media/usb/cpia2/cpia2_registers.h
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 ****************************************************************************/ 20 ****************************************************************************/
25 21
26#ifndef CPIA2_REGISTER_HEADER 22#ifndef CPIA2_REGISTER_HEADER
diff --git a/drivers/media/usb/cpia2/cpia2_usb.c b/drivers/media/usb/cpia2/cpia2_usb.c
index 37f9b30b0abc..1c7e16e5d88b 100644
--- a/drivers/media/usb/cpia2/cpia2_usb.c
+++ b/drivers/media/usb/cpia2/cpia2_usb.c
@@ -20,10 +20,6 @@
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 21 * GNU General Public License for more details.
22 * 22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 * Stripped of 2.4 stuff ready for main kernel submit by 23 * Stripped of 2.4 stuff ready for main kernel submit by
28 * Alan Cox <alan@lxorguk.ukuu.org.uk> 24 * Alan Cox <alan@lxorguk.ukuu.org.uk>
29 ****************************************************************************/ 25 ****************************************************************************/
@@ -551,12 +547,10 @@ static int write_packet(struct usb_device *udev,
551 if (!registers || size <= 0) 547 if (!registers || size <= 0)
552 return -EINVAL; 548 return -EINVAL;
553 549
554 buf = kmalloc(size, GFP_KERNEL); 550 buf = kmemdup(registers, size, GFP_KERNEL);
555 if (!buf) 551 if (!buf)
556 return -ENOMEM; 552 return -ENOMEM;
557 553
558 memcpy(buf, registers, size);
559
560 ret = usb_control_msg(udev, 554 ret = usb_control_msg(udev,
561 usb_sndctrlpipe(udev, 0), 555 usb_sndctrlpipe(udev, 0),
562 request, 556 request,
diff --git a/drivers/media/usb/cpia2/cpia2_v4l.c b/drivers/media/usb/cpia2/cpia2_v4l.c
index 9caea8344547..7122023e7004 100644
--- a/drivers/media/usb/cpia2/cpia2_v4l.c
+++ b/drivers/media/usb/cpia2/cpia2_v4l.c
@@ -21,10 +21,6 @@
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details. 22 * GNU General Public License for more details.
23 * 23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 *
28 * Stripped of 2.4 stuff ready for main kernel submit by 24 * Stripped of 2.4 stuff ready for main kernel submit by
29 * Alan Cox <alan@lxorguk.ukuu.org.uk> 25 * Alan Cox <alan@lxorguk.ukuu.org.uk>
30 ****************************************************************************/ 26 ****************************************************************************/
diff --git a/drivers/media/usb/cx231xx/Kconfig b/drivers/media/usb/cx231xx/Kconfig
index 0cced3e5b040..58de80bff4c7 100644
--- a/drivers/media/usb/cx231xx/Kconfig
+++ b/drivers/media/usb/cx231xx/Kconfig
@@ -50,6 +50,7 @@ config VIDEO_CX231XX_DVB
50 select DVB_LGDT3306A if MEDIA_SUBDRV_AUTOSELECT 50 select DVB_LGDT3306A if MEDIA_SUBDRV_AUTOSELECT
51 select DVB_TDA18271C2DD if MEDIA_SUBDRV_AUTOSELECT 51 select DVB_TDA18271C2DD if MEDIA_SUBDRV_AUTOSELECT
52 select DVB_SI2165 if MEDIA_SUBDRV_AUTOSELECT 52 select DVB_SI2165 if MEDIA_SUBDRV_AUTOSELECT
53 select DVB_SI2168 if MEDIA_SUBDRV_AUTOSELECT
53 select MEDIA_TUNER_SI2157 if MEDIA_SUBDRV_AUTOSELECT 54 select MEDIA_TUNER_SI2157 if MEDIA_SUBDRV_AUTOSELECT
54 55
55 ---help--- 56 ---help---
diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c
index 29d450c15f29..509d9711d590 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -18,10 +18,6 @@
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 21 */
26 22
27#include "cx231xx.h" 23#include "cx231xx.h"
diff --git a/drivers/media/usb/cx231xx/cx231xx-audio.c b/drivers/media/usb/cx231xx/cx231xx-audio.c
index 8263c4b0610b..cf80842dfa08 100644
--- a/drivers/media/usb/cx231xx/cx231xx-audio.c
+++ b/drivers/media/usb/cx231xx/cx231xx-audio.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#include "cx231xx.h" 19#include "cx231xx.h"
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 36bc25494319..f730fdbc9156 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -841,6 +841,33 @@ struct cx231xx_board cx231xx_boards[] = {
841 .gpio = NULL, 841 .gpio = NULL,
842 } }, 842 } },
843 }, 843 },
844 [CX231XX_BOARD_EVROMEDIA_FULL_HYBRID_FULLHD] = {
845 .name = "Evromedia USB Full Hybrid Full HD",
846 .tuner_type = TUNER_ABSENT,
847 .demod_addr = 0x64, /* 0xc8 >> 1 */
848 .demod_i2c_master = I2C_1_MUX_3,
849 .has_dvb = 1,
850 .ir_i2c_master = I2C_0,
851 .norm = V4L2_STD_PAL,
852 .output_mode = OUT_MODE_VIP11,
853 .tuner_addr = 0x60, /* 0xc0 >> 1 */
854 .tuner_i2c_master = I2C_2,
855 .input = {{
856 .type = CX231XX_VMUX_TELEVISION,
857 .vmux = 0,
858 .amux = CX231XX_AMUX_VIDEO,
859 }, {
860 .type = CX231XX_VMUX_COMPOSITE1,
861 .vmux = CX231XX_VIN_2_1,
862 .amux = CX231XX_AMUX_LINE_IN,
863 }, {
864 .type = CX231XX_VMUX_SVIDEO,
865 .vmux = CX231XX_VIN_1_1 |
866 (CX231XX_VIN_1_2 << 8) |
867 CX25840_SVIDEO_ON,
868 .amux = CX231XX_AMUX_LINE_IN,
869 } },
870 },
844}; 871};
845const unsigned int cx231xx_bcount = ARRAY_SIZE(cx231xx_boards); 872const unsigned int cx231xx_bcount = ARRAY_SIZE(cx231xx_boards);
846 873
@@ -908,6 +935,8 @@ struct usb_device_id cx231xx_id_table[] = {
908 .driver_info = CX231XX_BOARD_OTG102}, 935 .driver_info = CX231XX_BOARD_OTG102},
909 {USB_DEVICE(USB_VID_TERRATEC, 0x00a6), 936 {USB_DEVICE(USB_VID_TERRATEC, 0x00a6),
910 .driver_info = CX231XX_BOARD_TERRATEC_GRABBY}, 937 .driver_info = CX231XX_BOARD_TERRATEC_GRABBY},
938 {USB_DEVICE(0x1b80, 0xd3b2),
939 .driver_info = CX231XX_BOARD_EVROMEDIA_FULL_HYBRID_FULLHD},
911 {}, 940 {},
912}; 941};
913 942
diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c b/drivers/media/usb/cx231xx/cx231xx-core.c
index 550ec932f931..46646ecd2dbc 100644
--- a/drivers/media/usb/cx231xx/cx231xx-core.c
+++ b/drivers/media/usb/cx231xx/cx231xx-core.c
@@ -355,7 +355,12 @@ int cx231xx_send_vendor_cmd(struct cx231xx *dev,
355 */ 355 */
356 if ((ven_req->wLength > 4) && ((ven_req->bRequest == 0x4) || 356 if ((ven_req->wLength > 4) && ((ven_req->bRequest == 0x4) ||
357 (ven_req->bRequest == 0x5) || 357 (ven_req->bRequest == 0x5) ||
358 (ven_req->bRequest == 0x6))) { 358 (ven_req->bRequest == 0x6) ||
359
360 /* Internal Master 3 Bus can send
361 * and receive only 4 bytes per time
362 */
363 (ven_req->bRequest == 0x2))) {
359 unsend_size = 0; 364 unsend_size = 0;
360 pdata = ven_req->pBuff; 365 pdata = ven_req->pBuff;
361 366
diff --git a/drivers/media/usb/cx231xx/cx231xx-dif.h b/drivers/media/usb/cx231xx/cx231xx-dif.h
index 2b63c2f6d3b0..2b9eb9fd7c52 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dif.h
+++ b/drivers/media/usb/cx231xx/cx231xx-dif.h
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY, without even the implied warranty of 12 * but WITHOUT ANY WARRANTY, without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program, if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#ifndef _CX231XX_DIF_H 17#ifndef _CX231XX_DIF_H
diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
index 2868546999ca..46427fd3b220 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
@@ -33,6 +33,7 @@
33#include "s5h1411.h" 33#include "s5h1411.h"
34#include "lgdt3305.h" 34#include "lgdt3305.h"
35#include "si2165.h" 35#include "si2165.h"
36#include "si2168.h"
36#include "mb86a20s.h" 37#include "mb86a20s.h"
37#include "si2157.h" 38#include "si2157.h"
38#include "lgdt3306a.h" 39#include "lgdt3306a.h"
@@ -949,6 +950,75 @@ static int dvb_init(struct cx231xx *dev)
949 &pv_tda18271_config); 950 &pv_tda18271_config);
950 break; 951 break;
951 952
953 case CX231XX_BOARD_EVROMEDIA_FULL_HYBRID_FULLHD:
954 {
955 struct si2157_config si2157_config = {};
956 struct si2168_config si2168_config = {};
957 struct i2c_board_info info = {};
958 struct i2c_client *client;
959 struct i2c_adapter *adapter;
960
961 /* attach demodulator chip */
962 si2168_config.ts_mode = SI2168_TS_SERIAL; /* from *.inf file */
963 si2168_config.fe = &dev->dvb->frontend;
964 si2168_config.i2c_adapter = &adapter;
965 si2168_config.ts_clock_inv = true;
966
967 strlcpy(info.type, "si2168", sizeof(info.type));
968 info.addr = dev->board.demod_addr;
969 info.platform_data = &si2168_config;
970
971 request_module(info.type);
972 client = i2c_new_device(demod_i2c, &info);
973
974 if (client == NULL || client->dev.driver == NULL) {
975 result = -ENODEV;
976 goto out_free;
977 }
978
979 if (!try_module_get(client->dev.driver->owner)) {
980 i2c_unregister_device(client);
981 result = -ENODEV;
982 goto out_free;
983 }
984
985 dvb->i2c_client_demod = client;
986
987 /* attach tuner chip */
988 si2157_config.fe = dev->dvb->frontend;
989#ifdef CONFIG_MEDIA_CONTROLLER_DVB
990 si2157_config.mdev = dev->media_dev;
991#endif
992 si2157_config.if_port = 1;
993 si2157_config.inversion = false;
994
995 memset(&info, 0, sizeof(info));
996 strlcpy(info.type, "si2157", sizeof(info.type));
997 info.addr = dev->board.tuner_addr;
998 info.platform_data = &si2157_config;
999
1000 request_module(info.type);
1001 client = i2c_new_device(tuner_i2c, &info);
1002
1003 if (client == NULL || client->dev.driver == NULL) {
1004 module_put(dvb->i2c_client_demod->dev.driver->owner);
1005 i2c_unregister_device(dvb->i2c_client_demod);
1006 result = -ENODEV;
1007 goto out_free;
1008 }
1009
1010 if (!try_module_get(client->dev.driver->owner)) {
1011 i2c_unregister_device(client);
1012 module_put(dvb->i2c_client_demod->dev.driver->owner);
1013 i2c_unregister_device(dvb->i2c_client_demod);
1014 result = -ENODEV;
1015 goto out_free;
1016 }
1017
1018 dev->cx231xx_reset_analog_tuner = NULL;
1019 dev->dvb->i2c_client_tuner = client;
1020 break;
1021 }
952 default: 1022 default:
953 dev_err(dev->dev, 1023 dev_err(dev->dev,
954 "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n", 1024 "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
diff --git a/drivers/media/usb/cx231xx/cx231xx-input.c b/drivers/media/usb/cx231xx/cx231xx-input.c
index 15d8d1b5f05c..6e80f3c573f3 100644
--- a/drivers/media/usb/cx231xx/cx231xx-input.c
+++ b/drivers/media/usb/cx231xx/cx231xx-input.c
@@ -72,7 +72,7 @@ int cx231xx_ir_init(struct cx231xx *dev)
72 72
73 memset(&info, 0, sizeof(struct i2c_board_info)); 73 memset(&info, 0, sizeof(struct i2c_board_info));
74 memset(&dev->init_data, 0, sizeof(dev->init_data)); 74 memset(&dev->init_data, 0, sizeof(dev->init_data));
75 dev->init_data.rc_dev = rc_allocate_device(); 75 dev->init_data.rc_dev = rc_allocate_device(RC_DRIVER_SCANCODE);
76 if (!dev->init_data.rc_dev) 76 if (!dev->init_data.rc_dev)
77 return -ENOMEM; 77 return -ENOMEM;
78 78
diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
index 90c867683076..d9792ea4bbc6 100644
--- a/drivers/media/usb/cx231xx/cx231xx.h
+++ b/drivers/media/usb/cx231xx/cx231xx.h
@@ -78,6 +78,7 @@
78#define CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx 20 78#define CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx 20
79#define CX231XX_BOARD_HAUPPAUGE_955Q 21 79#define CX231XX_BOARD_HAUPPAUGE_955Q 21
80#define CX231XX_BOARD_TERRATEC_GRABBY 22 80#define CX231XX_BOARD_TERRATEC_GRABBY 22
81#define CX231XX_BOARD_EVROMEDIA_FULL_HYBRID_FULLHD 23
81 82
82/* Limits minimum and default number of buffers */ 83/* Limits minimum and default number of buffers */
83#define CX231XX_MIN_BUF 4 84#define CX231XX_MIN_BUF 4
diff --git a/drivers/media/usb/dvb-usb-v2/Kconfig b/drivers/media/usb/dvb-usb-v2/Kconfig
index 524533d3eb29..0e4944b2b0f4 100644
--- a/drivers/media/usb/dvb-usb-v2/Kconfig
+++ b/drivers/media/usb/dvb-usb-v2/Kconfig
@@ -156,3 +156,11 @@ config DVB_USB_DVBSKY
156 select DVB_SP2 if MEDIA_SUBDRV_AUTOSELECT 156 select DVB_SP2 if MEDIA_SUBDRV_AUTOSELECT
157 help 157 help
158 Say Y here to support the USB receivers from DVBSky. 158 Say Y here to support the USB receivers from DVBSky.
159
160config DVB_USB_ZD1301
161 tristate "ZyDAS ZD1301"
162 depends on DVB_USB_V2
163 select DVB_ZD1301_DEMOD if MEDIA_SUBDRV_AUTOSELECT
164 select MEDIA_TUNER_MT2060 if MEDIA_SUBDRV_AUTOSELECT
165 help
166 Say Y here to support the ZyDAS ZD1301 DVB USB receiver.
diff --git a/drivers/media/usb/dvb-usb-v2/Makefile b/drivers/media/usb/dvb-usb-v2/Makefile
index f10d4df0eae5..969f68e55265 100644
--- a/drivers/media/usb/dvb-usb-v2/Makefile
+++ b/drivers/media/usb/dvb-usb-v2/Makefile
@@ -40,6 +40,9 @@ obj-$(CONFIG_DVB_USB_RTL28XXU) += dvb-usb-rtl28xxu.o
40dvb-usb-dvbsky-objs := dvbsky.o 40dvb-usb-dvbsky-objs := dvbsky.o
41obj-$(CONFIG_DVB_USB_DVBSKY) += dvb-usb-dvbsky.o 41obj-$(CONFIG_DVB_USB_DVBSKY) += dvb-usb-dvbsky.o
42 42
43dvb-usb-zd1301-objs := zd1301.o
44obj-$(CONFIG_DVB_USB_ZD1301) += zd1301.o
45
43ccflags-y += -I$(srctree)/drivers/media/dvb-core 46ccflags-y += -I$(srctree)/drivers/media/dvb-core
44ccflags-y += -I$(srctree)/drivers/media/dvb-frontends 47ccflags-y += -I$(srctree)/drivers/media/dvb-frontends
45ccflags-y += -I$(srctree)/drivers/media/tuners 48ccflags-y += -I$(srctree)/drivers/media/tuners
diff --git a/drivers/media/usb/dvb-usb-v2/af9015.c b/drivers/media/usb/dvb-usb-v2/af9015.c
index 29011dfabb11..caa1e6101f58 100644
--- a/drivers/media/usb/dvb-usb-v2/af9015.c
+++ b/drivers/media/usb/dvb-usb-v2/af9015.c
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 */ 18 */
23 19
24#include "af9015.h" 20#include "af9015.h"
diff --git a/drivers/media/usb/dvb-usb-v2/af9015.h b/drivers/media/usb/dvb-usb-v2/af9015.h
index 1db1bb0d57bc..2dd9231a8ece 100644
--- a/drivers/media/usb/dvb-usb-v2/af9015.h
+++ b/drivers/media/usb/dvb-usb-v2/af9015.h
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 */ 18 */
23 19
24#ifndef AF9015_H 20#ifndef AF9015_H
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
index c673726d9b70..4df9486e19b9 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -335,14 +335,12 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
335 /* TODO: correct limits > 40 */ 335 /* TODO: correct limits > 40 */
336 ret = -EOPNOTSUPP; 336 ret = -EOPNOTSUPP;
337 } else if ((msg[0].addr == state->af9033_i2c_addr[0]) || 337 } else if ((msg[0].addr == state->af9033_i2c_addr[0]) ||
338 (msg[0].addr == state->af9033_i2c_addr[1]) || 338 (msg[0].addr == state->af9033_i2c_addr[1])) {
339 (state->chip_type == 0x9135)) {
340 /* demod access via firmware interface */ 339 /* demod access via firmware interface */
341 u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 | 340 u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
342 msg[0].buf[2]; 341 msg[0].buf[2];
343 342
344 if (msg[0].addr == state->af9033_i2c_addr[1] || 343 if (msg[0].addr == state->af9033_i2c_addr[1])
345 msg[0].addr == (state->af9033_i2c_addr[1] >> 1))
346 reg |= 0x100000; 344 reg |= 0x100000;
347 345
348 ret = af9035_rd_regs(d, reg, &msg[1].buf[0], 346 ret = af9035_rd_regs(d, reg, &msg[1].buf[0],
@@ -396,14 +394,12 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
396 /* TODO: correct limits > 40 */ 394 /* TODO: correct limits > 40 */
397 ret = -EOPNOTSUPP; 395 ret = -EOPNOTSUPP;
398 } else if ((msg[0].addr == state->af9033_i2c_addr[0]) || 396 } else if ((msg[0].addr == state->af9033_i2c_addr[0]) ||
399 (msg[0].addr == state->af9033_i2c_addr[1]) || 397 (msg[0].addr == state->af9033_i2c_addr[1])) {
400 (state->chip_type == 0x9135)) {
401 /* demod access via firmware interface */ 398 /* demod access via firmware interface */
402 u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 | 399 u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
403 msg[0].buf[2]; 400 msg[0].buf[2];
404 401
405 if (msg[0].addr == state->af9033_i2c_addr[1] || 402 if (msg[0].addr == state->af9033_i2c_addr[1])
406 msg[0].addr == (state->af9033_i2c_addr[1] >> 1))
407 reg |= 0x100000; 403 reg |= 0x100000;
408 404
409 ret = af9035_wr_regs(d, reg, &msg[0].buf[3], 405 ret = af9035_wr_regs(d, reg, &msg[0].buf[3],
@@ -496,7 +492,8 @@ static int af9035_identify_state(struct dvb_usb_device *d, const char **name)
496{ 492{
497 struct state *state = d_to_priv(d); 493 struct state *state = d_to_priv(d);
498 struct usb_interface *intf = d->intf; 494 struct usb_interface *intf = d->intf;
499 int ret, ts_mode_invalid; 495 int ret, i, ts_mode_invalid;
496 unsigned int utmp, eeprom_addr;
500 u8 tmp; 497 u8 tmp;
501 u8 wbuf[1] = { 1 }; 498 u8 wbuf[1] = { 1 };
502 u8 rbuf[4]; 499 u8 rbuf[4];
@@ -518,25 +515,48 @@ static int af9035_identify_state(struct dvb_usb_device *d, const char **name)
518 state->prechip_version, state->chip_version, state->chip_type); 515 state->prechip_version, state->chip_version, state->chip_type);
519 516
520 if (state->chip_type == 0x9135) { 517 if (state->chip_type == 0x9135) {
521 if (state->chip_version == 0x02) 518 if (state->chip_version == 0x02) {
522 *name = AF9035_FIRMWARE_IT9135_V2; 519 *name = AF9035_FIRMWARE_IT9135_V2;
523 else 520 utmp = 0x00461d;
521 } else {
524 *name = AF9035_FIRMWARE_IT9135_V1; 522 *name = AF9035_FIRMWARE_IT9135_V1;
525 state->eeprom_addr = EEPROM_BASE_IT9135; 523 utmp = 0x00461b;
524 }
525
526 /* Check if eeprom exists */
527 ret = af9035_rd_reg(d, utmp, &tmp);
528 if (ret < 0)
529 goto err;
530
531 if (tmp == 0x00) {
532 dev_dbg(&intf->dev, "no eeprom\n");
533 state->no_eeprom = true;
534 goto check_firmware_status;
535 }
536
537 eeprom_addr = EEPROM_BASE_IT9135;
526 } else if (state->chip_type == 0x9306) { 538 } else if (state->chip_type == 0x9306) {
527 *name = AF9035_FIRMWARE_IT9303; 539 *name = AF9035_FIRMWARE_IT9303;
528 state->eeprom_addr = EEPROM_BASE_IT9135; 540 state->no_eeprom = true;
541 goto check_firmware_status;
529 } else { 542 } else {
530 *name = AF9035_FIRMWARE_AF9035; 543 *name = AF9035_FIRMWARE_AF9035;
531 state->eeprom_addr = EEPROM_BASE_AF9035; 544 eeprom_addr = EEPROM_BASE_AF9035;
545 }
546
547 /* Read and store eeprom */
548 for (i = 0; i < 256; i += 32) {
549 ret = af9035_rd_regs(d, eeprom_addr + i, &state->eeprom[i], 32);
550 if (ret < 0)
551 goto err;
532 } 552 }
533 553
554 dev_dbg(&intf->dev, "eeprom dump:\n");
555 for (i = 0; i < 256; i += 16)
556 dev_dbg(&intf->dev, "%*ph\n", 16, &state->eeprom[i]);
534 557
535 /* check for dual tuner mode */ 558 /* check for dual tuner mode */
536 ret = af9035_rd_reg(d, state->eeprom_addr + EEPROM_TS_MODE, &tmp); 559 tmp = state->eeprom[EEPROM_TS_MODE];
537 if (ret < 0)
538 goto err;
539
540 ts_mode_invalid = 0; 560 ts_mode_invalid = 0;
541 switch (tmp) { 561 switch (tmp) {
542 case 0: 562 case 0:
@@ -560,7 +580,7 @@ static int af9035_identify_state(struct dvb_usb_device *d, const char **name)
560 if (ts_mode_invalid) 580 if (ts_mode_invalid)
561 dev_info(&intf->dev, "ts mode=%d not supported, defaulting to single tuner mode!", tmp); 581 dev_info(&intf->dev, "ts mode=%d not supported, defaulting to single tuner mode!", tmp);
562 582
563 583check_firmware_status:
564 ret = af9035_ctrl_msg(d, &req); 584 ret = af9035_ctrl_msg(d, &req);
565 if (ret < 0) 585 if (ret < 0)
566 goto err; 586 goto err;
@@ -750,15 +770,11 @@ static int af9035_download_firmware(struct dvb_usb_device *d,
750 goto err; 770 goto err;
751 771
752 /* tell the slave I2C address */ 772 /* tell the slave I2C address */
753 ret = af9035_rd_reg(d, 773 tmp = state->eeprom[EEPROM_2ND_DEMOD_ADDR];
754 state->eeprom_addr + EEPROM_2ND_DEMOD_ADDR,
755 &tmp);
756 if (ret < 0)
757 goto err;
758 774
759 /* use default I2C address if eeprom has no address set */ 775 /* Use default I2C address if eeprom has no address set */
760 if (!tmp) 776 if (!tmp)
761 tmp = 0x3a; 777 tmp = 0x1d << 1; /* 8-bit format used by chip */
762 778
763 if ((state->chip_type == 0x9135) || 779 if ((state->chip_type == 0x9135) ||
764 (state->chip_type == 0x9306)) { 780 (state->chip_type == 0x9306)) {
@@ -819,11 +835,11 @@ static int af9035_read_config(struct dvb_usb_device *d)
819 struct state *state = d_to_priv(d); 835 struct state *state = d_to_priv(d);
820 int ret, i; 836 int ret, i;
821 u8 tmp; 837 u8 tmp;
822 u16 tmp16, addr; 838 u16 tmp16;
823 839
824 /* demod I2C "address" */ 840 /* Demod I2C address */
825 state->af9033_i2c_addr[0] = 0x38; 841 state->af9033_i2c_addr[0] = 0x1c;
826 state->af9033_i2c_addr[1] = 0x3a; 842 state->af9033_i2c_addr[1] = 0x1d;
827 state->af9033_config[0].adc_multiplier = AF9033_ADC_MULTIPLIER_2X; 843 state->af9033_config[0].adc_multiplier = AF9033_ADC_MULTIPLIER_2X;
828 state->af9033_config[1].adc_multiplier = AF9033_ADC_MULTIPLIER_2X; 844 state->af9033_config[1].adc_multiplier = AF9033_ADC_MULTIPLIER_2X;
829 state->af9033_config[0].ts_mode = AF9033_TS_MODE_USB; 845 state->af9033_config[0].ts_mode = AF9033_TS_MODE_USB;
@@ -837,20 +853,16 @@ static int af9035_read_config(struct dvb_usb_device *d)
837 if (state->chip_version == 0x02) { 853 if (state->chip_version == 0x02) {
838 state->af9033_config[0].tuner = AF9033_TUNER_IT9135_60; 854 state->af9033_config[0].tuner = AF9033_TUNER_IT9135_60;
839 state->af9033_config[1].tuner = AF9033_TUNER_IT9135_60; 855 state->af9033_config[1].tuner = AF9033_TUNER_IT9135_60;
840 tmp16 = 0x00461d; /* eeprom memory mapped location */
841 } else { 856 } else {
842 state->af9033_config[0].tuner = AF9033_TUNER_IT9135_38; 857 state->af9033_config[0].tuner = AF9033_TUNER_IT9135_38;
843 state->af9033_config[1].tuner = AF9033_TUNER_IT9135_38; 858 state->af9033_config[1].tuner = AF9033_TUNER_IT9135_38;
844 tmp16 = 0x00461b; /* eeprom memory mapped location */
845 } 859 }
846 860
847 /* check if eeprom exists */ 861 if (state->no_eeprom) {
848 ret = af9035_rd_reg(d, tmp16, &tmp); 862 /* Remote controller to NEC polling by default */
849 if (ret < 0) 863 state->ir_mode = 0x05;
850 goto err; 864 state->ir_type = 0x00;
851 865
852 if (tmp == 0x00) {
853 dev_dbg(&intf->dev, "no eeprom\n");
854 goto skip_eeprom; 866 goto skip_eeprom;
855 } 867 }
856 } else if (state->chip_type == 0x9306) { 868 } else if (state->chip_type == 0x9306) {
@@ -861,29 +873,25 @@ static int af9035_read_config(struct dvb_usb_device *d)
861 return 0; 873 return 0;
862 } 874 }
863 875
876 /* Remote controller */
877 state->ir_mode = state->eeprom[EEPROM_IR_MODE];
878 state->ir_type = state->eeprom[EEPROM_IR_TYPE];
864 879
865 if (state->dual_mode) { 880 if (state->dual_mode) {
866 /* read 2nd demodulator I2C address */ 881 /* Read 2nd demodulator I2C address. 8-bit format on eeprom */
867 ret = af9035_rd_reg(d, 882 tmp = state->eeprom[EEPROM_2ND_DEMOD_ADDR];
868 state->eeprom_addr + EEPROM_2ND_DEMOD_ADDR,
869 &tmp);
870 if (ret < 0)
871 goto err;
872
873 if (tmp) 883 if (tmp)
874 state->af9033_i2c_addr[1] = tmp; 884 state->af9033_i2c_addr[1] = tmp >> 1;
875 885
876 dev_dbg(&intf->dev, "2nd demod I2C addr=%02x\n", tmp); 886 dev_dbg(&intf->dev, "2nd demod I2C addr=%02x\n",
887 state->af9033_i2c_addr[1]);
877 } 888 }
878 889
879 addr = state->eeprom_addr;
880
881 for (i = 0; i < state->dual_mode + 1; i++) { 890 for (i = 0; i < state->dual_mode + 1; i++) {
882 /* tuner */ 891 unsigned int eeprom_offset = 0;
883 ret = af9035_rd_reg(d, addr + EEPROM_1_TUNER_ID, &tmp);
884 if (ret < 0)
885 goto err;
886 892
893 /* tuner */
894 tmp = state->eeprom[EEPROM_1_TUNER_ID + eeprom_offset];
887 dev_dbg(&intf->dev, "[%d]tuner=%02x\n", i, tmp); 895 dev_dbg(&intf->dev, "[%d]tuner=%02x\n", i, tmp);
888 896
889 /* tuner sanity check */ 897 /* tuner sanity check */
@@ -956,21 +964,13 @@ static int af9035_read_config(struct dvb_usb_device *d)
956 } 964 }
957 965
958 /* tuner IF frequency */ 966 /* tuner IF frequency */
959 ret = af9035_rd_reg(d, addr + EEPROM_1_IF_L, &tmp); 967 tmp = state->eeprom[EEPROM_1_IF_L + eeprom_offset];
960 if (ret < 0) 968 tmp16 = tmp << 0;
961 goto err; 969 tmp = state->eeprom[EEPROM_1_IF_H + eeprom_offset];
962
963 tmp16 = tmp;
964
965 ret = af9035_rd_reg(d, addr + EEPROM_1_IF_H, &tmp);
966 if (ret < 0)
967 goto err;
968
969 tmp16 |= tmp << 8; 970 tmp16 |= tmp << 8;
970
971 dev_dbg(&intf->dev, "[%d]IF=%d\n", i, tmp16); 971 dev_dbg(&intf->dev, "[%d]IF=%d\n", i, tmp16);
972 972
973 addr += 0x10; /* shift for the 2nd tuner params */ 973 eeprom_offset += 0x10; /* shift for the 2nd tuner params */
974 } 974 }
975 975
976skip_eeprom: 976skip_eeprom:
@@ -1247,30 +1247,11 @@ static int af9035_frontend_detach(struct dvb_usb_adapter *adap)
1247 struct state *state = adap_to_priv(adap); 1247 struct state *state = adap_to_priv(adap);
1248 struct dvb_usb_device *d = adap_to_d(adap); 1248 struct dvb_usb_device *d = adap_to_d(adap);
1249 struct usb_interface *intf = d->intf; 1249 struct usb_interface *intf = d->intf;
1250 int demod2;
1251 1250
1252 dev_dbg(&intf->dev, "adap->id=%d\n", adap->id); 1251 dev_dbg(&intf->dev, "adap->id=%d\n", adap->id);
1253 1252
1254 /*
1255 * For dual tuner devices we have to resolve 2nd demod client, as there
1256 * is two different kind of tuner drivers; one is using I2C binding
1257 * and the other is using DVB attach/detach binding.
1258 */
1259 switch (state->af9033_config[adap->id].tuner) {
1260 case AF9033_TUNER_IT9135_38:
1261 case AF9033_TUNER_IT9135_51:
1262 case AF9033_TUNER_IT9135_52:
1263 case AF9033_TUNER_IT9135_60:
1264 case AF9033_TUNER_IT9135_61:
1265 case AF9033_TUNER_IT9135_62:
1266 demod2 = 2;
1267 break;
1268 default:
1269 demod2 = 1;
1270 }
1271
1272 if (adap->id == 1) { 1253 if (adap->id == 1) {
1273 if (state->i2c_client[demod2]) 1254 if (state->i2c_client[1])
1274 af9035_del_i2c_dev(d); 1255 af9035_del_i2c_dev(d);
1275 } else if (adap->id == 0) { 1256 } else if (adap->id == 0) {
1276 if (state->i2c_client[0]) 1257 if (state->i2c_client[0])
@@ -1510,50 +1491,58 @@ static int af9035_tuner_attach(struct dvb_usb_adapter *adap)
1510 case AF9033_TUNER_IT9135_38: 1491 case AF9033_TUNER_IT9135_38:
1511 case AF9033_TUNER_IT9135_51: 1492 case AF9033_TUNER_IT9135_51:
1512 case AF9033_TUNER_IT9135_52: 1493 case AF9033_TUNER_IT9135_52:
1513 {
1514 struct it913x_config it913x_config = {
1515 .fe = adap->fe[0],
1516 .chip_ver = 1,
1517 };
1518
1519 if (state->dual_mode) {
1520 if (adap->id == 0)
1521 it913x_config.role = IT913X_ROLE_DUAL_MASTER;
1522 else
1523 it913x_config.role = IT913X_ROLE_DUAL_SLAVE;
1524 }
1525
1526 ret = af9035_add_i2c_dev(d, "it913x",
1527 state->af9033_i2c_addr[adap->id] >> 1,
1528 &it913x_config, &d->i2c_adap);
1529 if (ret)
1530 goto err;
1531
1532 fe = adap->fe[0];
1533 break;
1534 }
1535 case AF9033_TUNER_IT9135_60: 1494 case AF9033_TUNER_IT9135_60:
1536 case AF9033_TUNER_IT9135_61: 1495 case AF9033_TUNER_IT9135_61:
1537 case AF9033_TUNER_IT9135_62: 1496 case AF9033_TUNER_IT9135_62:
1538 { 1497 {
1539 struct it913x_config it913x_config = { 1498 struct platform_device *pdev;
1499 const char *name;
1500 struct it913x_platform_data it913x_pdata = {
1501 .regmap = state->af9033_config[adap->id].regmap,
1540 .fe = adap->fe[0], 1502 .fe = adap->fe[0],
1541 .chip_ver = 2,
1542 }; 1503 };
1543 1504
1505 switch (state->af9033_config[adap->id].tuner) {
1506 case AF9033_TUNER_IT9135_38:
1507 case AF9033_TUNER_IT9135_51:
1508 case AF9033_TUNER_IT9135_52:
1509 name = "it9133ax-tuner";
1510 break;
1511 case AF9033_TUNER_IT9135_60:
1512 case AF9033_TUNER_IT9135_61:
1513 case AF9033_TUNER_IT9135_62:
1514 name = "it9133bx-tuner";
1515 break;
1516 default:
1517 ret = -ENODEV;
1518 goto err;
1519 }
1520
1544 if (state->dual_mode) { 1521 if (state->dual_mode) {
1545 if (adap->id == 0) 1522 if (adap->id == 0)
1546 it913x_config.role = IT913X_ROLE_DUAL_MASTER; 1523 it913x_pdata.role = IT913X_ROLE_DUAL_MASTER;
1547 else 1524 else
1548 it913x_config.role = IT913X_ROLE_DUAL_SLAVE; 1525 it913x_pdata.role = IT913X_ROLE_DUAL_SLAVE;
1526 } else {
1527 it913x_pdata.role = IT913X_ROLE_SINGLE;
1549 } 1528 }
1550 1529
1551 ret = af9035_add_i2c_dev(d, "it913x", 1530 request_module("%s", "it913x");
1552 state->af9033_i2c_addr[adap->id] >> 1, 1531 pdev = platform_device_register_data(&d->intf->dev, name,
1553 &it913x_config, &d->i2c_adap); 1532 PLATFORM_DEVID_AUTO,
1554 if (ret) 1533 &it913x_pdata,
1534 sizeof(it913x_pdata));
1535 if (IS_ERR(pdev) || !pdev->dev.driver) {
1536 ret = -ENODEV;
1537 goto err;
1538 }
1539 if (!try_module_get(pdev->dev.driver->owner)) {
1540 platform_device_unregister(pdev);
1541 ret = -ENODEV;
1555 goto err; 1542 goto err;
1543 }
1556 1544
1545 state->platform_device_tuner[adap->id] = pdev;
1557 fe = adap->fe[0]; 1546 fe = adap->fe[0];
1558 break; 1547 break;
1559 } 1548 }
@@ -1675,12 +1664,6 @@ static int af9035_tuner_detach(struct dvb_usb_adapter *adap)
1675 switch (state->af9033_config[adap->id].tuner) { 1664 switch (state->af9033_config[adap->id].tuner) {
1676 case AF9033_TUNER_TUA9001: 1665 case AF9033_TUNER_TUA9001:
1677 case AF9033_TUNER_FC2580: 1666 case AF9033_TUNER_FC2580:
1678 case AF9033_TUNER_IT9135_38:
1679 case AF9033_TUNER_IT9135_51:
1680 case AF9033_TUNER_IT9135_52:
1681 case AF9033_TUNER_IT9135_60:
1682 case AF9033_TUNER_IT9135_61:
1683 case AF9033_TUNER_IT9135_62:
1684 if (adap->id == 1) { 1667 if (adap->id == 1) {
1685 if (state->i2c_client[3]) 1668 if (state->i2c_client[3])
1686 af9035_del_i2c_dev(d); 1669 af9035_del_i2c_dev(d);
@@ -1688,6 +1671,23 @@ static int af9035_tuner_detach(struct dvb_usb_adapter *adap)
1688 if (state->i2c_client[1]) 1671 if (state->i2c_client[1])
1689 af9035_del_i2c_dev(d); 1672 af9035_del_i2c_dev(d);
1690 } 1673 }
1674 break;
1675 case AF9033_TUNER_IT9135_38:
1676 case AF9033_TUNER_IT9135_51:
1677 case AF9033_TUNER_IT9135_52:
1678 case AF9033_TUNER_IT9135_60:
1679 case AF9033_TUNER_IT9135_61:
1680 case AF9033_TUNER_IT9135_62:
1681 {
1682 struct platform_device *pdev;
1683
1684 pdev = state->platform_device_tuner[adap->id];
1685 if (pdev) {
1686 module_put(pdev->dev.driver->owner);
1687 platform_device_unregister(pdev);
1688 }
1689 break;
1690 }
1691 } 1691 }
1692 1692
1693 return 0; 1693 return 0;
@@ -1872,25 +1872,13 @@ static int af9035_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc)
1872{ 1872{
1873 struct state *state = d_to_priv(d); 1873 struct state *state = d_to_priv(d);
1874 struct usb_interface *intf = d->intf; 1874 struct usb_interface *intf = d->intf;
1875 int ret;
1876 u8 tmp;
1877
1878 ret = af9035_rd_reg(d, state->eeprom_addr + EEPROM_IR_MODE, &tmp);
1879 if (ret < 0)
1880 goto err;
1881 1875
1882 dev_dbg(&intf->dev, "ir_mode=%02x\n", tmp); 1876 dev_dbg(&intf->dev, "ir_mode=%02x ir_type=%02x\n",
1877 state->ir_mode, state->ir_type);
1883 1878
1884 /* don't activate rc if in HID mode or if not available */ 1879 /* don't activate rc if in HID mode or if not available */
1885 if (tmp == 5) { 1880 if (state->ir_mode == 0x05) {
1886 ret = af9035_rd_reg(d, state->eeprom_addr + EEPROM_IR_TYPE, 1881 switch (state->ir_type) {
1887 &tmp);
1888 if (ret < 0)
1889 goto err;
1890
1891 dev_dbg(&intf->dev, "ir_type=%02x\n", tmp);
1892
1893 switch (tmp) {
1894 case 0: /* NEC */ 1882 case 0: /* NEC */
1895 default: 1883 default:
1896 rc->allowed_protos = RC_BIT_NEC | RC_BIT_NECX | 1884 rc->allowed_protos = RC_BIT_NEC | RC_BIT_NECX |
@@ -1910,11 +1898,6 @@ static int af9035_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc)
1910 } 1898 }
1911 1899
1912 return 0; 1900 return 0;
1913
1914err:
1915 dev_dbg(&intf->dev, "failed=%d\n", ret);
1916
1917 return ret;
1918} 1901}
1919#else 1902#else
1920 #define af9035_get_rc_config NULL 1903 #define af9035_get_rc_config NULL
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.h b/drivers/media/usb/dvb-usb-v2/af9035.h
index 1f83c9218ad0..a76e6bf0ab1e 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.h
+++ b/drivers/media/usb/dvb-usb-v2/af9035.h
@@ -22,6 +22,7 @@
22#ifndef AF9035_H 22#ifndef AF9035_H
23#define AF9035_H 23#define AF9035_H
24 24
25#include <linux/platform_device.h>
25#include "dvb_usb.h" 26#include "dvb_usb.h"
26#include "af9033.h" 27#include "af9033.h"
27#include "tua9001.h" 28#include "tua9001.h"
@@ -61,15 +62,19 @@ struct state {
61 u8 prechip_version; 62 u8 prechip_version;
62 u8 chip_version; 63 u8 chip_version;
63 u16 chip_type; 64 u16 chip_type;
65 u8 eeprom[256];
66 bool no_eeprom;
67 u8 ir_mode;
68 u8 ir_type;
64 u8 dual_mode:1; 69 u8 dual_mode:1;
65 u8 no_read:1; 70 u8 no_read:1;
66 u16 eeprom_addr;
67 u8 af9033_i2c_addr[2]; 71 u8 af9033_i2c_addr[2];
68 struct af9033_config af9033_config[2]; 72 struct af9033_config af9033_config[2];
69 struct af9033_ops ops; 73 struct af9033_ops ops;
70 #define AF9035_I2C_CLIENT_MAX 4 74 #define AF9035_I2C_CLIENT_MAX 4
71 struct i2c_client *i2c_client[AF9035_I2C_CLIENT_MAX]; 75 struct i2c_client *i2c_client[AF9035_I2C_CLIENT_MAX];
72 struct i2c_adapter *i2c_adapter_demod; 76 struct i2c_adapter *i2c_adapter_demod;
77 struct platform_device *platform_device_tuner[2];
73}; 78};
74 79
75static const u32 clock_lut_af9035[] = { 80static const u32 clock_lut_af9035[] = {
diff --git a/drivers/media/usb/dvb-usb-v2/anysee.c b/drivers/media/usb/dvb-usb-v2/anysee.c
index ae917c042a52..6795c0c609b1 100644
--- a/drivers/media/usb/dvb-usb-v2/anysee.c
+++ b/drivers/media/usb/dvb-usb-v2/anysee.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * TODO: 16 * TODO:
21 * - add smart card reader support for Conditional Access (CA) 17 * - add smart card reader support for Conditional Access (CA)
22 * 18 *
diff --git a/drivers/media/usb/dvb-usb-v2/anysee.h b/drivers/media/usb/dvb-usb-v2/anysee.h
index 3ca2bca4ebaf..393e2fce2aed 100644
--- a/drivers/media/usb/dvb-usb-v2/anysee.h
+++ b/drivers/media/usb/dvb-usb-v2/anysee.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * TODO: 16 * TODO:
21 * - add smart card reader support for Conditional Access (CA) 17 * - add smart card reader support for Conditional Access (CA)
22 * 18 *
diff --git a/drivers/media/usb/dvb-usb-v2/au6610.c b/drivers/media/usb/dvb-usb-v2/au6610.c
index ae6a671b7fd5..6ee01cb64ca5 100644
--- a/drivers/media/usb/dvb-usb-v2/au6610.c
+++ b/drivers/media/usb/dvb-usb-v2/au6610.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#include "au6610.h" 17#include "au6610.h"
diff --git a/drivers/media/usb/dvb-usb-v2/au6610.h b/drivers/media/usb/dvb-usb-v2/au6610.h
index ea337bfc00b1..aacfcc6fa0f5 100644
--- a/drivers/media/usb/dvb-usb-v2/au6610.h
+++ b/drivers/media/usb/dvb-usb-v2/au6610.h
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#ifndef AU6610_H 17#ifndef AU6610_H
diff --git a/drivers/media/usb/dvb-usb-v2/ce6230.c b/drivers/media/usb/dvb-usb-v2/ce6230.c
index f67b14bc32e3..e596031a708d 100644
--- a/drivers/media/usb/dvb-usb-v2/ce6230.c
+++ b/drivers/media/usb/dvb-usb-v2/ce6230.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */ 16 */
21 17
22#include "ce6230.h" 18#include "ce6230.h"
diff --git a/drivers/media/usb/dvb-usb-v2/ce6230.h b/drivers/media/usb/dvb-usb-v2/ce6230.h
index 299e57e3390b..b25b3b938e49 100644
--- a/drivers/media/usb/dvb-usb-v2/ce6230.h
+++ b/drivers/media/usb/dvb-usb-v2/ce6230.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */ 16 */
21 17
22#ifndef CE6230_H 18#ifndef CE6230_H
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 a8e6624fbe83..955fb0d07507 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
@@ -147,7 +147,7 @@ static int dvb_usbv2_remote_init(struct dvb_usb_device *d)
147 if (!d->rc.map_name) 147 if (!d->rc.map_name)
148 return 0; 148 return 0;
149 149
150 dev = rc_allocate_device(); 150 dev = rc_allocate_device(d->rc.driver_type);
151 if (!dev) { 151 if (!dev) {
152 ret = -ENOMEM; 152 ret = -ENOMEM;
153 goto err; 153 goto err;
@@ -162,7 +162,6 @@ static int dvb_usbv2_remote_init(struct dvb_usb_device *d)
162 /* TODO: likely RC-core should took const char * */ 162 /* TODO: likely RC-core should took const char * */
163 dev->driver_name = (char *) d->props->driver_name; 163 dev->driver_name = (char *) d->props->driver_name;
164 dev->map_name = d->rc.map_name; 164 dev->map_name = d->rc.map_name;
165 dev->driver_type = d->rc.driver_type;
166 dev->allowed_protocols = d->rc.allowed_protos; 165 dev->allowed_protocols = d->rc.allowed_protos;
167 dev->change_protocol = d->rc.change_protocol; 166 dev->change_protocol = d->rc.change_protocol;
168 dev->priv = d; 167 dev->priv = d;
@@ -1013,8 +1012,8 @@ EXPORT_SYMBOL(dvb_usbv2_probe);
1013void dvb_usbv2_disconnect(struct usb_interface *intf) 1012void dvb_usbv2_disconnect(struct usb_interface *intf)
1014{ 1013{
1015 struct dvb_usb_device *d = usb_get_intfdata(intf); 1014 struct dvb_usb_device *d = usb_get_intfdata(intf);
1016 const char *name = d->name; 1015 const char *devname = kstrdup(dev_name(&d->udev->dev), GFP_KERNEL);
1017 struct device dev = d->udev->dev; 1016 const char *drvname = d->name;
1018 1017
1019 dev_dbg(&d->udev->dev, "%s: bInterfaceNumber=%d\n", __func__, 1018 dev_dbg(&d->udev->dev, "%s: bInterfaceNumber=%d\n", __func__,
1020 intf->cur_altsetting->desc.bInterfaceNumber); 1019 intf->cur_altsetting->desc.bInterfaceNumber);
@@ -1024,8 +1023,9 @@ void dvb_usbv2_disconnect(struct usb_interface *intf)
1024 1023
1025 dvb_usbv2_exit(d); 1024 dvb_usbv2_exit(d);
1026 1025
1027 dev_info(&dev, "%s: '%s' successfully deinitialized and disconnected\n", 1026 pr_info("%s: '%s:%s' successfully deinitialized and disconnected\n",
1028 KBUILD_MODNAME, name); 1027 KBUILD_MODNAME, drvname, devname);
1028 kfree(devname);
1029} 1029}
1030EXPORT_SYMBOL(dvb_usbv2_disconnect); 1030EXPORT_SYMBOL(dvb_usbv2_disconnect);
1031 1031
diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c b/drivers/media/usb/dvb-usb-v2/dvbsky.c
index 0636eac37bbb..5730760e4e93 100644
--- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#include "dvb_usb.h" 17#include "dvb_usb.h"
diff --git a/drivers/media/usb/dvb-usb-v2/ec168.c b/drivers/media/usb/dvb-usb-v2/ec168.c
index 0c2b377704ff..1db8aeef3655 100644
--- a/drivers/media/usb/dvb-usb-v2/ec168.c
+++ b/drivers/media/usb/dvb-usb-v2/ec168.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */ 16 */
21 17
22#include "ec168.h" 18#include "ec168.h"
diff --git a/drivers/media/usb/dvb-usb-v2/ec168.h b/drivers/media/usb/dvb-usb-v2/ec168.h
index 615a6569421f..704955bcaa10 100644
--- a/drivers/media/usb/dvb-usb-v2/ec168.h
+++ b/drivers/media/usb/dvb-usb-v2/ec168.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */ 16 */
21 17
22#ifndef EC168_H 18#ifndef EC168_H
diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c
index 5fea02672685..924adfdb660d 100644
--- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
+++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
@@ -48,10 +48,6 @@
48 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 48 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49 * GNU General Public License for more details. 49 * GNU General Public License for more details.
50 * 50 *
51 * You should have received a copy of the GNU General Public License
52 * along with this program; if not, write to the Free Software
53 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
54 *
55 * 51 *
56 * see Documentation/dvb/README.dvb-usb for more information 52 * see Documentation/dvb/README.dvb-usb for more information
57 * 53 *
@@ -99,9 +95,7 @@ static int dvb_usb_lme2510_debug;
99} while (0) 95} while (0)
100#define deb_info(level, args...) lme_debug(dvb_usb_lme2510_debug, level, args) 96#define deb_info(level, args...) lme_debug(dvb_usb_lme2510_debug, level, args)
101#define debug_data_snipet(level, name, p) \ 97#define debug_data_snipet(level, name, p) \
102 deb_info(level, name" (%02x%02x%02x%02x%02x%02x%02x%02x)", \ 98 deb_info(level, name" (%8phN)", p);
103 *p, *(p+1), *(p+2), *(p+3), *(p+4), \
104 *(p+5), *(p+6), *(p+7));
105#define info(args...) pr_info(DVB_USB_LOG_PREFIX": "args) 99#define info(args...) pr_info(DVB_USB_LOG_PREFIX": "args)
106 100
107module_param_named(debug, dvb_usb_lme2510_debug, int, 0644); 101module_param_named(debug, dvb_usb_lme2510_debug, int, 0644);
@@ -315,7 +309,7 @@ static void lme2510_int_response(struct urb *lme_urb)
315{ 309{
316 struct dvb_usb_adapter *adap = lme_urb->context; 310 struct dvb_usb_adapter *adap = lme_urb->context;
317 struct lme2510_state *st = adap_to_priv(adap); 311 struct lme2510_state *st = adap_to_priv(adap);
318 static u8 *ibuf, *rbuf; 312 u8 *ibuf, *rbuf;
319 int i = 0, offset; 313 int i = 0, offset;
320 u32 key; 314 u32 key;
321 u8 signal_lock = 0; 315 u8 signal_lock = 0;
@@ -1002,8 +996,9 @@ static int lme_name(struct dvb_usb_adapter *adap)
1002 struct dvb_usb_device *d = adap_to_d(adap); 996 struct dvb_usb_device *d = adap_to_d(adap);
1003 struct lme2510_state *st = adap_to_priv(adap); 997 struct lme2510_state *st = adap_to_priv(adap);
1004 const char *desc = d->name; 998 const char *desc = d->name;
1005 char *fe_name[] = {"", " LG TDQY-P001F", " SHARP:BS2F7HZ7395", 999 static const char * const fe_name[] = {
1006 " SHARP:BS2F7HZ0194", " RS2000"}; 1000 "", " LG TDQY-P001F", " SHARP:BS2F7HZ7395",
1001 " SHARP:BS2F7HZ0194", " RS2000"};
1007 char *name = adap->fe[0]->ops.info.name; 1002 char *name = adap->fe[0]->ops.info.name;
1008 1003
1009 strlcpy(name, desc, 128); 1004 strlcpy(name, desc, 128);
@@ -1124,7 +1119,7 @@ static int dm04_lme2510_tuner(struct dvb_usb_adapter *adap)
1124{ 1119{
1125 struct dvb_usb_device *d = adap_to_d(adap); 1120 struct dvb_usb_device *d = adap_to_d(adap);
1126 struct lme2510_state *st = adap_to_priv(adap); 1121 struct lme2510_state *st = adap_to_priv(adap);
1127 char *tun_msg[] = {"", "TDA8263", "IX2505V", "DVB_PLL_OPERA", "RS2000"}; 1122 static const char * const tun_msg[] = {"", "TDA8263", "IX2505V", "DVB_PLL_OPERA", "RS2000"};
1128 int ret = 0; 1123 int ret = 0;
1129 1124
1130 switch (st->tuner_config) { 1125 switch (st->tuner_config) {
@@ -1178,10 +1173,7 @@ static int lme2510_powerup(struct dvb_usb_device *d, int onoff)
1178 1173
1179 mutex_lock(&d->i2c_mutex); 1174 mutex_lock(&d->i2c_mutex);
1180 1175
1181 if (onoff) 1176 ret = lme2510_usb_talk(d, onoff ? lnb_on : lnb_off, len, rbuf, rlen);
1182 ret = lme2510_usb_talk(d, lnb_on, len, rbuf, rlen);
1183 else
1184 ret = lme2510_usb_talk(d, lnb_off, len, rbuf, rlen);
1185 1177
1186 st->i2c_talk_onoff = 1; 1178 st->i2c_talk_onoff = 1;
1187 1179
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c b/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c
index 639e156e0c1b..f0ed37da73d4 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#include "mxl111sf-demod.h" 17#include "mxl111sf-demod.h"
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.h b/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.h
index e6eae9d88e9f..9cb4972ce7a3 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.h
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.h
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#ifndef __MXL111SF_DEMOD_H__ 17#ifndef __MXL111SF_DEMOD_H__
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-gpio.c b/drivers/media/usb/dvb-usb-v2/mxl111sf-gpio.c
index 2180c13a6dcc..c66861c9342b 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-gpio.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-gpio.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#include "mxl111sf-gpio.h" 17#include "mxl111sf-gpio.h"
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-gpio.h b/drivers/media/usb/dvb-usb-v2/mxl111sf-gpio.h
index 16fa4d4daf88..af2c7bc8f301 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-gpio.h
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-gpio.h
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#ifndef _DVB_USB_MXL111SF_GPIO_H_ 17#ifndef _DVB_USB_MXL111SF_GPIO_H_
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c b/drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c
index 6427137a09ef..ffb49c28b15a 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#include "mxl111sf-i2c.h" 17#include "mxl111sf-i2c.h"
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.h b/drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.h
index c486fe02f018..28877c7a8175 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.h
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.h
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#ifndef _DVB_USB_MXL111SF_I2C_H_ 17#ifndef _DVB_USB_MXL111SF_I2C_H_
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-phy.c b/drivers/media/usb/dvb-usb-v2/mxl111sf-phy.c
index 5b0191178f9f..ffb6e7c72f57 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-phy.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-phy.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#include "mxl111sf-phy.h" 17#include "mxl111sf-phy.h"
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-phy.h b/drivers/media/usb/dvb-usb-v2/mxl111sf-phy.h
index 25aa4a1ea755..0a61e8a56584 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-phy.h
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-phy.h
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#ifndef _DVB_USB_MXL111SF_PHY_H_ 17#ifndef _DVB_USB_MXL111SF_PHY_H_
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-reg.h b/drivers/media/usb/dvb-usb-v2/mxl111sf-reg.h
index 1f4bfbcdbabb..ad3f806dcc7a 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-reg.h
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-reg.h
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#ifndef _DVB_USB_MXL111SF_REG_H_ 17#ifndef _DVB_USB_MXL111SF_REG_H_
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c b/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c
index f84bef6034dc..240d736bf1bb 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#include "mxl111sf-tuner.h" 17#include "mxl111sf-tuner.h"
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.h b/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.h
index e96d9a444ed1..11ea07a73271 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.h
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.h
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#ifndef __MXL111SF_TUNER_H__ 17#ifndef __MXL111SF_TUNER_H__
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index c583c638e468..e16ca07acf1d 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -1778,7 +1778,7 @@ static int rtl2832u_get_rc_config(struct dvb_usb_device *d,
1778 /* load empty to enable rc */ 1778 /* load empty to enable rc */
1779 if (!rc->map_name) 1779 if (!rc->map_name)
1780 rc->map_name = RC_MAP_EMPTY; 1780 rc->map_name = RC_MAP_EMPTY;
1781 rc->allowed_protos = RC_BIT_ALL; 1781 rc->allowed_protos = RC_BIT_ALL_IR_DECODER;
1782 rc->driver_type = RC_DRIVER_IR_RAW; 1782 rc->driver_type = RC_DRIVER_IR_RAW;
1783 rc->query = rtl2832u_rc_query; 1783 rc->query = rtl2832u_rc_query;
1784 rc->interval = 200; 1784 rc->interval = 200;
diff --git a/drivers/media/usb/dvb-usb-v2/zd1301.c b/drivers/media/usb/dvb-usb-v2/zd1301.c
new file mode 100644
index 000000000000..d1eb4b7bc051
--- /dev/null
+++ b/drivers/media/usb/dvb-usb-v2/zd1301.c
@@ -0,0 +1,298 @@
1/*
2 * ZyDAS ZD1301 driver (USB interface)
3 *
4 * Copyright (C) 2015 Antti Palosaari <crope@iki.fi>
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 as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include "dvb_usb.h"
18#include "zd1301_demod.h"
19#include "mt2060.h"
20#include <linux/i2c.h>
21#include <linux/platform_device.h>
22
23DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
24
25struct zd1301_dev {
26 #define BUF_LEN 8
27 u8 buf[BUF_LEN]; /* bulk USB control message */
28 struct zd1301_demod_platform_data demod_pdata;
29 struct mt2060_platform_data mt2060_pdata;
30 struct platform_device *platform_device_demod;
31 struct i2c_client *i2c_client_tuner;
32};
33
34static int zd1301_ctrl_msg(struct dvb_usb_device *d, const u8 *wbuf,
35 unsigned int wlen, u8 *rbuf, unsigned int rlen)
36{
37 struct zd1301_dev *dev = d_to_priv(d);
38 struct usb_interface *intf = d->intf;
39 int ret, actual_length;
40
41 mutex_lock(&d->usb_mutex);
42
43 memcpy(&dev->buf, wbuf, wlen);
44
45 dev_dbg(&intf->dev, ">>> %*ph\n", wlen, dev->buf);
46
47 ret = usb_bulk_msg(d->udev, usb_sndbulkpipe(d->udev, 0x04), dev->buf,
48 wlen, &actual_length, 1000);
49 if (ret) {
50 dev_err(&intf->dev, "1st usb_bulk_msg() failed %d\n", ret);
51 goto err_mutex_unlock;
52 }
53
54 if (rlen) {
55 ret = usb_bulk_msg(d->udev, usb_rcvbulkpipe(d->udev, 0x83),
56 dev->buf, rlen, &actual_length, 1000);
57 if (ret) {
58 dev_err(&intf->dev,
59 "2nd usb_bulk_msg() failed %d\n", ret);
60 goto err_mutex_unlock;
61 }
62
63 dev_dbg(&intf->dev, "<<< %*ph\n", actual_length, dev->buf);
64
65 if (actual_length != rlen) {
66 /*
67 * Chip replies often with 3 byte len stub. On that case
68 * we have to query new reply.
69 */
70 dev_dbg(&intf->dev, "repeating reply message\n");
71
72 ret = usb_bulk_msg(d->udev,
73 usb_rcvbulkpipe(d->udev, 0x83),
74 dev->buf, rlen, &actual_length,
75 1000);
76 if (ret) {
77 dev_err(&intf->dev,
78 "3rd usb_bulk_msg() failed %d\n", ret);
79 goto err_mutex_unlock;
80 }
81
82 dev_dbg(&intf->dev,
83 "<<< %*ph\n", actual_length, dev->buf);
84 }
85
86 memcpy(rbuf, dev->buf, rlen);
87 }
88
89err_mutex_unlock:
90 mutex_unlock(&d->usb_mutex);
91 return ret;
92}
93
94static int zd1301_demod_wreg(void *reg_priv, u16 reg, u8 val)
95{
96 struct dvb_usb_device *d = reg_priv;
97 struct usb_interface *intf = d->intf;
98 int ret;
99 u8 buf[7] = {0x07, 0x00, 0x03, 0x01,
100 (reg >> 0) & 0xff, (reg >> 8) & 0xff, val};
101
102 ret = zd1301_ctrl_msg(d, buf, 7, NULL, 0);
103 if (ret)
104 goto err;
105
106 return 0;
107err:
108 dev_dbg(&intf->dev, "failed=%d\n", ret);
109 return ret;
110}
111
112static int zd1301_demod_rreg(void *reg_priv, u16 reg, u8 *val)
113{
114 struct dvb_usb_device *d = reg_priv;
115 struct usb_interface *intf = d->intf;
116 int ret;
117 u8 buf[7] = {0x07, 0x00, 0x04, 0x01,
118 (reg >> 0) & 0xff, (reg >> 8) & 0xff, 0};
119
120 ret = zd1301_ctrl_msg(d, buf, 7, buf, 7);
121 if (ret)
122 goto err;
123
124 *val = buf[6];
125
126 return 0;
127err:
128 dev_dbg(&intf->dev, "failed=%d\n", ret);
129 return ret;
130}
131
132static int zd1301_frontend_attach(struct dvb_usb_adapter *adap)
133{
134 struct dvb_usb_device *d = adap_to_d(adap);
135 struct zd1301_dev *dev = adap_to_priv(adap);
136 struct usb_interface *intf = d->intf;
137 struct platform_device *pdev;
138 struct i2c_client *client;
139 struct i2c_board_info board_info;
140 struct i2c_adapter *adapter;
141 struct dvb_frontend *frontend;
142 int ret;
143
144 dev_dbg(&intf->dev, "\n");
145
146 /* Add platform demod */
147 dev->demod_pdata.reg_priv = d;
148 dev->demod_pdata.reg_read = zd1301_demod_rreg;
149 dev->demod_pdata.reg_write = zd1301_demod_wreg;
150 request_module("%s", "zd1301_demod");
151 pdev = platform_device_register_data(&intf->dev,
152 "zd1301_demod",
153 PLATFORM_DEVID_AUTO,
154 &dev->demod_pdata,
155 sizeof(dev->demod_pdata));
156 if (IS_ERR(pdev)) {
157 ret = PTR_ERR(pdev);
158 goto err;
159 }
160 if (!pdev->dev.driver) {
161 ret = -ENODEV;
162 goto err;
163 }
164 if (!try_module_get(pdev->dev.driver->owner)) {
165 ret = -ENODEV;
166 goto err_platform_device_unregister;
167 }
168
169 adapter = zd1301_demod_get_i2c_adapter(pdev);
170 frontend = zd1301_demod_get_dvb_frontend(pdev);
171 if (!adapter || !frontend) {
172 ret = -ENODEV;
173 goto err_module_put_demod;
174 }
175
176 /* Add I2C tuner */
177 dev->mt2060_pdata.i2c_write_max = 9;
178 dev->mt2060_pdata.dvb_frontend = frontend;
179 memset(&board_info, 0, sizeof(board_info));
180 strlcpy(board_info.type, "mt2060", I2C_NAME_SIZE);
181 board_info.addr = 0x60;
182 board_info.platform_data = &dev->mt2060_pdata;
183 request_module("%s", "mt2060");
184 client = i2c_new_device(adapter, &board_info);
185 if (!client || !client->dev.driver) {
186 ret = -ENODEV;
187 goto err_module_put_demod;
188 }
189 if (!try_module_get(client->dev.driver->owner)) {
190 ret = -ENODEV;
191 goto err_i2c_unregister_device;
192 }
193
194 dev->platform_device_demod = pdev;
195 dev->i2c_client_tuner = client;
196 adap->fe[0] = frontend;
197
198 return 0;
199err_i2c_unregister_device:
200 i2c_unregister_device(client);
201err_module_put_demod:
202 module_put(pdev->dev.driver->owner);
203err_platform_device_unregister:
204 platform_device_unregister(pdev);
205err:
206 dev_dbg(&intf->dev, "failed=%d\n", ret);
207 return ret;
208}
209
210static int zd1301_frontend_detach(struct dvb_usb_adapter *adap)
211{
212 struct dvb_usb_device *d = adap_to_d(adap);
213 struct zd1301_dev *dev = d_to_priv(d);
214 struct usb_interface *intf = d->intf;
215 struct platform_device *pdev;
216 struct i2c_client *client;
217
218 dev_dbg(&intf->dev, "\n");
219
220 client = dev->i2c_client_tuner;
221 pdev = dev->platform_device_demod;
222
223 /* Remove I2C tuner */
224 if (client) {
225 module_put(client->dev.driver->owner);
226 i2c_unregister_device(client);
227 }
228
229 /* Remove platform demod */
230 if (pdev) {
231 module_put(pdev->dev.driver->owner);
232 platform_device_unregister(pdev);
233 }
234
235 return 0;
236}
237
238static int zd1301_streaming_ctrl(struct dvb_frontend *fe, int onoff)
239{
240 struct dvb_usb_device *d = fe_to_d(fe);
241 struct usb_interface *intf = d->intf;
242 int ret;
243 u8 buf[3] = {0x03, 0x00, onoff ? 0x07 : 0x08};
244
245 dev_dbg(&intf->dev, "onoff=%d\n", onoff);
246
247 ret = zd1301_ctrl_msg(d, buf, 3, NULL, 0);
248 if (ret)
249 goto err;
250
251 return 0;
252err:
253 dev_dbg(&intf->dev, "failed=%d\n", ret);
254 return ret;
255}
256
257static const struct dvb_usb_device_properties zd1301_props = {
258 .driver_name = KBUILD_MODNAME,
259 .owner = THIS_MODULE,
260 .adapter_nr = adapter_nr,
261 .size_of_priv = sizeof(struct zd1301_dev),
262
263 .frontend_attach = zd1301_frontend_attach,
264 .frontend_detach = zd1301_frontend_detach,
265 .streaming_ctrl = zd1301_streaming_ctrl,
266
267 .num_adapters = 1,
268 .adapter = {
269 {
270 .stream = DVB_USB_STREAM_BULK(0x81, 6, 21 * 188),
271 },
272 },
273};
274
275static const struct usb_device_id zd1301_id_table[] = {
276 {DVB_USB_DEVICE(USB_VID_ZYDAS, 0x13a1, &zd1301_props,
277 "ZyDAS ZD1301 reference design", NULL)},
278 {}
279};
280MODULE_DEVICE_TABLE(usb, zd1301_id_table);
281
282/* Usb specific object needed to register this driver with the usb subsystem */
283static struct usb_driver zd1301_usb_driver = {
284 .name = KBUILD_MODNAME,
285 .id_table = zd1301_id_table,
286 .probe = dvb_usbv2_probe,
287 .disconnect = dvb_usbv2_disconnect,
288 .suspend = dvb_usbv2_suspend,
289 .resume = dvb_usbv2_resume,
290 .reset_resume = dvb_usbv2_reset_resume,
291 .no_dynamic_id = 1,
292 .soft_unbind = 1,
293};
294module_usb_driver(zd1301_usb_driver);
295
296MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
297MODULE_DESCRIPTION("ZyDAS ZD1301 driver");
298MODULE_LICENSE("GPL");
diff --git a/drivers/media/usb/dvb-usb/af9005-fe.c b/drivers/media/usb/dvb-usb/af9005-fe.c
index 9862d3e6b8e8..544bdf18fb2f 100644
--- a/drivers/media/usb/dvb-usb/af9005-fe.c
+++ b/drivers/media/usb/dvb-usb/af9005-fe.c
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 * see Documentation/dvb/README.dvb-usb for more information 18 * see Documentation/dvb/README.dvb-usb for more information
23 */ 19 */
24#include "af9005.h" 20#include "af9005.h"
diff --git a/drivers/media/usb/dvb-usb/af9005-remote.c b/drivers/media/usb/dvb-usb/af9005-remote.c
index 7e3961d0db6b..9b29ffa93075 100644
--- a/drivers/media/usb/dvb-usb/af9005-remote.c
+++ b/drivers/media/usb/dvb-usb/af9005-remote.c
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 * see Documentation/dvb/README.dvb-usb for more information 20 * see Documentation/dvb/README.dvb-usb for more information
25 */ 21 */
26#include "af9005.h" 22#include "af9005.h"
diff --git a/drivers/media/usb/dvb-usb/af9005.c b/drivers/media/usb/dvb-usb/af9005.c
index f5f476841aea..986763b1b2b3 100644
--- a/drivers/media/usb/dvb-usb/af9005.c
+++ b/drivers/media/usb/dvb-usb/af9005.c
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 * see Documentation/dvb/README.dvb-usb for more information 18 * see Documentation/dvb/README.dvb-usb for more information
23 */ 19 */
24#include "af9005.h" 20#include "af9005.h"
diff --git a/drivers/media/usb/dvb-usb/af9005.h b/drivers/media/usb/dvb-usb/af9005.h
index 6a2bf3de8456..a1eae0fa02ed 100644
--- a/drivers/media/usb/dvb-usb/af9005.h
+++ b/drivers/media/usb/dvb-usb/af9005.h
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 * see Documentation/dvb/README.dvb-usb for more information 18 * see Documentation/dvb/README.dvb-usb for more information
23 */ 19 */
24#ifndef _DVB_USB_AF9005_H_ 20#ifndef _DVB_USB_AF9005_H_
diff --git a/drivers/media/usb/dvb-usb/cinergyT2-core.c b/drivers/media/usb/dvb-usb/cinergyT2-core.c
index 6404205560eb..6131aa7914a9 100644
--- a/drivers/media/usb/dvb-usb/cinergyT2-core.c
+++ b/drivers/media/usb/dvb-usb/cinergyT2-core.c
@@ -21,10 +21,6 @@
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details. 22 * GNU General Public License for more details.
23 * 23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 *
28 */ 24 */
29 25
30#include "cinergyT2.h" 26#include "cinergyT2.h"
diff --git a/drivers/media/usb/dvb-usb/cinergyT2-fe.c b/drivers/media/usb/dvb-usb/cinergyT2-fe.c
index bbb10fab65bc..f9772ad0a2a5 100644
--- a/drivers/media/usb/dvb-usb/cinergyT2-fe.c
+++ b/drivers/media/usb/dvb-usb/cinergyT2-fe.c
@@ -21,10 +21,6 @@
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details. 22 * GNU General Public License for more details.
23 * 23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 *
28 */ 24 */
29 25
30#include "cinergyT2.h" 26#include "cinergyT2.h"
diff --git a/drivers/media/usb/dvb-usb/cinergyT2.h b/drivers/media/usb/dvb-usb/cinergyT2.h
index 84efe03771eb..c04b819be160 100644
--- a/drivers/media/usb/dvb-usb/cinergyT2.h
+++ b/drivers/media/usb/dvb-usb/cinergyT2.h
@@ -21,10 +21,6 @@
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details. 22 * GNU General Public License for more details.
23 * 23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 *
28 */ 24 */
29 25
30#ifndef _DVB_USB_CINERGYT2_H_ 26#ifndef _DVB_USB_CINERGYT2_H_
diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
index 9b8771eb31d4..51620e02292f 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -59,23 +59,24 @@ static int cxusb_ctrl_msg(struct dvb_usb_device *d,
59 u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen) 59 u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen)
60{ 60{
61 struct cxusb_state *st = d->priv; 61 struct cxusb_state *st = d->priv;
62 int ret, wo; 62 int ret;
63 63
64 if (1 + wlen > MAX_XFER_SIZE) { 64 if (1 + wlen > MAX_XFER_SIZE) {
65 warn("i2c wr: len=%d is too big!\n", wlen); 65 warn("i2c wr: len=%d is too big!\n", wlen);
66 return -EOPNOTSUPP; 66 return -EOPNOTSUPP;
67 } 67 }
68 68
69 wo = (rbuf == NULL || rlen == 0); /* write-only */ 69 if (rlen > MAX_XFER_SIZE) {
70 warn("i2c rd: len=%d is too big!\n", rlen);
71 return -EOPNOTSUPP;
72 }
70 73
71 mutex_lock(&d->data_mutex); 74 mutex_lock(&d->data_mutex);
72 st->data[0] = cmd; 75 st->data[0] = cmd;
73 memcpy(&st->data[1], wbuf, wlen); 76 memcpy(&st->data[1], wbuf, wlen);
74 if (wo) 77 ret = dvb_usb_generic_rw(d, st->data, 1 + wlen, st->data, rlen, 0);
75 ret = dvb_usb_generic_write(d, st->data, 1 + wlen); 78 if (!ret && rbuf && rlen)
76 else 79 memcpy(rbuf, st->data, rlen);
77 ret = dvb_usb_generic_rw(d, st->data, 1 + wlen,
78 rbuf, rlen, 0);
79 80
80 mutex_unlock(&d->data_mutex); 81 mutex_unlock(&d->data_mutex);
81 return ret; 82 return ret;
@@ -450,209 +451,46 @@ static int cxusb_d680_dmb_streaming_ctrl(
450 } 451 }
451} 452}
452 453
453static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 454static int cxusb_rc_query(struct dvb_usb_device *d)
454{ 455{
455 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
456 u8 ircode[4]; 456 u8 ircode[4];
457 int i;
458 457
459 cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4); 458 cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
460 459
461 *event = 0; 460 if (ircode[2] || ircode[3])
462 *state = REMOTE_NO_KEY_PRESSED; 461 rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN,
463 462 RC_SCANCODE_RC5(ircode[2], ircode[3]), 0);
464 for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
465 if (rc5_custom(&keymap[i]) == ircode[2] &&
466 rc5_data(&keymap[i]) == ircode[3]) {
467 *event = keymap[i].keycode;
468 *state = REMOTE_KEY_PRESSED;
469
470 return 0;
471 }
472 }
473
474 return 0; 463 return 0;
475} 464}
476 465
477static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d, u32 *event, 466static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d)
478 int *state)
479{ 467{
480 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
481 u8 ircode[4]; 468 u8 ircode[4];
482 int i;
483 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD, 469 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
484 .buf = ircode, .len = 4 }; 470 .buf = ircode, .len = 4 };
485 471
486 *event = 0;
487 *state = REMOTE_NO_KEY_PRESSED;
488
489 if (cxusb_i2c_xfer(&d->i2c_adap, &msg, 1) != 1) 472 if (cxusb_i2c_xfer(&d->i2c_adap, &msg, 1) != 1)
490 return 0; 473 return 0;
491 474
492 for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) { 475 if (ircode[1] || ircode[2])
493 if (rc5_custom(&keymap[i]) == ircode[1] && 476 rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN,
494 rc5_data(&keymap[i]) == ircode[2]) { 477 RC_SCANCODE_RC5(ircode[1], ircode[2]), 0);
495 *event = keymap[i].keycode;
496 *state = REMOTE_KEY_PRESSED;
497
498 return 0;
499 }
500 }
501
502 return 0; 478 return 0;
503} 479}
504 480
505static int cxusb_d680_dmb_rc_query(struct dvb_usb_device *d, u32 *event, 481static int cxusb_d680_dmb_rc_query(struct dvb_usb_device *d)
506 int *state)
507{ 482{
508 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
509 u8 ircode[2]; 483 u8 ircode[2];
510 int i;
511
512 *event = 0;
513 *state = REMOTE_NO_KEY_PRESSED;
514 484
515 if (cxusb_ctrl_msg(d, 0x10, NULL, 0, ircode, 2) < 0) 485 if (cxusb_ctrl_msg(d, 0x10, NULL, 0, ircode, 2) < 0)
516 return 0; 486 return 0;
517 487
518 for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) { 488 if (ircode[0] || ircode[1])
519 if (rc5_custom(&keymap[i]) == ircode[0] && 489 rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN,
520 rc5_data(&keymap[i]) == ircode[1]) { 490 RC_SCANCODE_RC5(ircode[0], ircode[1]), 0);
521 *event = keymap[i].keycode;
522 *state = REMOTE_KEY_PRESSED;
523
524 return 0;
525 }
526 }
527
528 return 0; 491 return 0;
529} 492}
530 493
531static struct rc_map_table rc_map_dvico_mce_table[] = {
532 { 0xfe02, KEY_TV },
533 { 0xfe0e, KEY_MP3 },
534 { 0xfe1a, KEY_DVD },
535 { 0xfe1e, KEY_FAVORITES },
536 { 0xfe16, KEY_SETUP },
537 { 0xfe46, KEY_POWER2 },
538 { 0xfe0a, KEY_EPG },
539 { 0xfe49, KEY_BACK },
540 { 0xfe4d, KEY_MENU },
541 { 0xfe51, KEY_UP },
542 { 0xfe5b, KEY_LEFT },
543 { 0xfe5f, KEY_RIGHT },
544 { 0xfe53, KEY_DOWN },
545 { 0xfe5e, KEY_OK },
546 { 0xfe59, KEY_INFO },
547 { 0xfe55, KEY_TAB },
548 { 0xfe0f, KEY_PREVIOUSSONG },/* Replay */
549 { 0xfe12, KEY_NEXTSONG }, /* Skip */
550 { 0xfe42, KEY_ENTER }, /* Windows/Start */
551 { 0xfe15, KEY_VOLUMEUP },
552 { 0xfe05, KEY_VOLUMEDOWN },
553 { 0xfe11, KEY_CHANNELUP },
554 { 0xfe09, KEY_CHANNELDOWN },
555 { 0xfe52, KEY_CAMERA },
556 { 0xfe5a, KEY_TUNER }, /* Live */
557 { 0xfe19, KEY_OPEN },
558 { 0xfe0b, KEY_1 },
559 { 0xfe17, KEY_2 },
560 { 0xfe1b, KEY_3 },
561 { 0xfe07, KEY_4 },
562 { 0xfe50, KEY_5 },
563 { 0xfe54, KEY_6 },
564 { 0xfe48, KEY_7 },
565 { 0xfe4c, KEY_8 },
566 { 0xfe58, KEY_9 },
567 { 0xfe13, KEY_ANGLE }, /* Aspect */
568 { 0xfe03, KEY_0 },
569 { 0xfe1f, KEY_ZOOM },
570 { 0xfe43, KEY_REWIND },
571 { 0xfe47, KEY_PLAYPAUSE },
572 { 0xfe4f, KEY_FASTFORWARD },
573 { 0xfe57, KEY_MUTE },
574 { 0xfe0d, KEY_STOP },
575 { 0xfe01, KEY_RECORD },
576 { 0xfe4e, KEY_POWER },
577};
578
579static struct rc_map_table rc_map_dvico_portable_table[] = {
580 { 0xfc02, KEY_SETUP }, /* Profile */
581 { 0xfc43, KEY_POWER2 },
582 { 0xfc06, KEY_EPG },
583 { 0xfc5a, KEY_BACK },
584 { 0xfc05, KEY_MENU },
585 { 0xfc47, KEY_INFO },
586 { 0xfc01, KEY_TAB },
587 { 0xfc42, KEY_PREVIOUSSONG },/* Replay */
588 { 0xfc49, KEY_VOLUMEUP },
589 { 0xfc09, KEY_VOLUMEDOWN },
590 { 0xfc54, KEY_CHANNELUP },
591 { 0xfc0b, KEY_CHANNELDOWN },
592 { 0xfc16, KEY_CAMERA },
593 { 0xfc40, KEY_TUNER }, /* ATV/DTV */
594 { 0xfc45, KEY_OPEN },
595 { 0xfc19, KEY_1 },
596 { 0xfc18, KEY_2 },
597 { 0xfc1b, KEY_3 },
598 { 0xfc1a, KEY_4 },
599 { 0xfc58, KEY_5 },
600 { 0xfc59, KEY_6 },
601 { 0xfc15, KEY_7 },
602 { 0xfc14, KEY_8 },
603 { 0xfc17, KEY_9 },
604 { 0xfc44, KEY_ANGLE }, /* Aspect */
605 { 0xfc55, KEY_0 },
606 { 0xfc07, KEY_ZOOM },
607 { 0xfc0a, KEY_REWIND },
608 { 0xfc08, KEY_PLAYPAUSE },
609 { 0xfc4b, KEY_FASTFORWARD },
610 { 0xfc5b, KEY_MUTE },
611 { 0xfc04, KEY_STOP },
612 { 0xfc56, KEY_RECORD },
613 { 0xfc57, KEY_POWER },
614 { 0xfc41, KEY_UNKNOWN }, /* INPUT */
615 { 0xfc00, KEY_UNKNOWN }, /* HD */
616};
617
618static struct rc_map_table rc_map_d680_dmb_table[] = {
619 { 0x0038, KEY_UNKNOWN }, /* TV/AV */
620 { 0x080c, KEY_ZOOM },
621 { 0x0800, KEY_0 },
622 { 0x0001, KEY_1 },
623 { 0x0802, KEY_2 },
624 { 0x0003, KEY_3 },
625 { 0x0804, KEY_4 },
626 { 0x0005, KEY_5 },
627 { 0x0806, KEY_6 },
628 { 0x0007, KEY_7 },
629 { 0x0808, KEY_8 },
630 { 0x0009, KEY_9 },
631 { 0x000a, KEY_MUTE },
632 { 0x0829, KEY_BACK },
633 { 0x0012, KEY_CHANNELUP },
634 { 0x0813, KEY_CHANNELDOWN },
635 { 0x002b, KEY_VOLUMEUP },
636 { 0x082c, KEY_VOLUMEDOWN },
637 { 0x0020, KEY_UP },
638 { 0x0821, KEY_DOWN },
639 { 0x0011, KEY_LEFT },
640 { 0x0810, KEY_RIGHT },
641 { 0x000d, KEY_OK },
642 { 0x081f, KEY_RECORD },
643 { 0x0017, KEY_PLAYPAUSE },
644 { 0x0816, KEY_PLAYPAUSE },
645 { 0x000b, KEY_STOP },
646 { 0x0827, KEY_FASTFORWARD },
647 { 0x0026, KEY_REWIND },
648 { 0x081e, KEY_UNKNOWN }, /* Time Shift */
649 { 0x000e, KEY_UNKNOWN }, /* Snapshot */
650 { 0x082d, KEY_UNKNOWN }, /* Mouse Cursor */
651 { 0x000f, KEY_UNKNOWN }, /* Minimize/Maximize */
652 { 0x0814, KEY_UNKNOWN }, /* Shuffle */
653 { 0x0025, KEY_POWER },
654};
655
656static int cxusb_dee1601_demod_init(struct dvb_frontend* fe) 494static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
657{ 495{
658 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 }; 496 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 };
@@ -1000,7 +838,7 @@ static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
1000 return -EIO; 838 return -EIO;
1001 839
1002 /* try to determine if there is no IR decoder on the I2C bus */ 840 /* try to determine if there is no IR decoder on the I2C bus */
1003 for (i = 0; adap->dev->props.rc.legacy.rc_map_table != NULL && i < 5; i++) { 841 for (i = 0; adap->dev->props.rc.core.rc_codes && i < 5; i++) {
1004 msleep(20); 842 msleep(20);
1005 if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1) 843 if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1)
1006 goto no_IR; 844 goto no_IR;
@@ -1008,7 +846,7 @@ static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
1008 continue; 846 continue;
1009 if (ircode[2] + ircode[3] != 0xff) { 847 if (ircode[2] + ircode[3] != 0xff) {
1010no_IR: 848no_IR:
1011 adap->dev->props.rc.legacy.rc_map_table = NULL; 849 adap->dev->props.rc.core.rc_codes = NULL;
1012 info("No IR receiver detected on this device."); 850 info("No IR receiver detected on this device.");
1013 break; 851 break;
1014 } 852 }
@@ -1720,11 +1558,12 @@ static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
1720 1558
1721 .i2c_algo = &cxusb_i2c_algo, 1559 .i2c_algo = &cxusb_i2c_algo,
1722 1560
1723 .rc.legacy = { 1561 .rc.core = {
1724 .rc_interval = 100, 1562 .rc_interval = 100,
1725 .rc_map_table = rc_map_dvico_portable_table, 1563 .rc_codes = RC_MAP_DVICO_PORTABLE,
1726 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table), 1564 .module_name = KBUILD_MODNAME,
1727 .rc_query = cxusb_rc_query, 1565 .rc_query = cxusb_rc_query,
1566 .allowed_protos = RC_BIT_UNKNOWN,
1728 }, 1567 },
1729 1568
1730 .generic_bulk_ctrl_endpoint = 0x01, 1569 .generic_bulk_ctrl_endpoint = 0x01,
@@ -1776,11 +1615,12 @@ static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
1776 1615
1777 .i2c_algo = &cxusb_i2c_algo, 1616 .i2c_algo = &cxusb_i2c_algo,
1778 1617
1779 .rc.legacy = { 1618 .rc.core = {
1780 .rc_interval = 150, 1619 .rc_interval = 100,
1781 .rc_map_table = rc_map_dvico_mce_table, 1620 .rc_codes = RC_MAP_DVICO_MCE,
1782 .rc_map_size = ARRAY_SIZE(rc_map_dvico_mce_table), 1621 .module_name = KBUILD_MODNAME,
1783 .rc_query = cxusb_rc_query, 1622 .rc_query = cxusb_rc_query,
1623 .allowed_protos = RC_BIT_UNKNOWN,
1784 }, 1624 },
1785 1625
1786 .generic_bulk_ctrl_endpoint = 0x01, 1626 .generic_bulk_ctrl_endpoint = 0x01,
@@ -1840,11 +1680,12 @@ static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
1840 1680
1841 .i2c_algo = &cxusb_i2c_algo, 1681 .i2c_algo = &cxusb_i2c_algo,
1842 1682
1843 .rc.legacy = { 1683 .rc.core = {
1844 .rc_interval = 100, 1684 .rc_interval = 100,
1845 .rc_map_table = rc_map_dvico_portable_table, 1685 .rc_codes = RC_MAP_DVICO_PORTABLE,
1846 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table), 1686 .module_name = KBUILD_MODNAME,
1847 .rc_query = cxusb_rc_query, 1687 .rc_query = cxusb_rc_query,
1688 .allowed_protos = RC_BIT_UNKNOWN,
1848 }, 1689 },
1849 1690
1850 .generic_bulk_ctrl_endpoint = 0x01, 1691 .generic_bulk_ctrl_endpoint = 0x01,
@@ -1895,11 +1736,12 @@ static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
1895 1736
1896 .i2c_algo = &cxusb_i2c_algo, 1737 .i2c_algo = &cxusb_i2c_algo,
1897 1738
1898 .rc.legacy = { 1739 .rc.core = {
1899 .rc_interval = 100, 1740 .rc_interval = 100,
1900 .rc_map_table = rc_map_dvico_portable_table, 1741 .rc_codes = RC_MAP_DVICO_PORTABLE,
1901 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table), 1742 .module_name = KBUILD_MODNAME,
1902 .rc_query = cxusb_rc_query, 1743 .rc_query = cxusb_rc_query,
1744 .allowed_protos = RC_BIT_UNKNOWN,
1903 }, 1745 },
1904 1746
1905 .generic_bulk_ctrl_endpoint = 0x01, 1747 .generic_bulk_ctrl_endpoint = 0x01,
@@ -1949,11 +1791,12 @@ static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
1949 1791
1950 .generic_bulk_ctrl_endpoint = 0x01, 1792 .generic_bulk_ctrl_endpoint = 0x01,
1951 1793
1952 .rc.legacy = { 1794 .rc.core = {
1953 .rc_interval = 100, 1795 .rc_interval = 100,
1954 .rc_map_table = rc_map_dvico_mce_table, 1796 .rc_codes = RC_MAP_DVICO_MCE,
1955 .rc_map_size = ARRAY_SIZE(rc_map_dvico_mce_table), 1797 .module_name = KBUILD_MODNAME,
1956 .rc_query = cxusb_bluebird2_rc_query, 1798 .rc_query = cxusb_bluebird2_rc_query,
1799 .allowed_protos = RC_BIT_UNKNOWN,
1957 }, 1800 },
1958 1801
1959 .num_device_descs = 1, 1802 .num_device_descs = 1,
@@ -2002,11 +1845,12 @@ static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
2002 1845
2003 .generic_bulk_ctrl_endpoint = 0x01, 1846 .generic_bulk_ctrl_endpoint = 0x01,
2004 1847
2005 .rc.legacy = { 1848 .rc.core = {
2006 .rc_interval = 100, 1849 .rc_interval = 100,
2007 .rc_map_table = rc_map_dvico_portable_table, 1850 .rc_codes = RC_MAP_DVICO_PORTABLE,
2008 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table), 1851 .module_name = KBUILD_MODNAME,
2009 .rc_query = cxusb_bluebird2_rc_query, 1852 .rc_query = cxusb_bluebird2_rc_query,
1853 .allowed_protos = RC_BIT_UNKNOWN,
2010 }, 1854 },
2011 1855
2012 .num_device_descs = 1, 1856 .num_device_descs = 1,
@@ -2057,11 +1901,12 @@ static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_prope
2057 1901
2058 .generic_bulk_ctrl_endpoint = 0x01, 1902 .generic_bulk_ctrl_endpoint = 0x01,
2059 1903
2060 .rc.legacy = { 1904 .rc.core = {
2061 .rc_interval = 100, 1905 .rc_interval = 100,
2062 .rc_map_table = rc_map_dvico_portable_table, 1906 .rc_codes = RC_MAP_DVICO_PORTABLE,
2063 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table), 1907 .module_name = KBUILD_MODNAME,
2064 .rc_query = cxusb_rc_query, 1908 .rc_query = cxusb_rc_query,
1909 .allowed_protos = RC_BIT_UNKNOWN,
2065 }, 1910 },
2066 1911
2067 .num_device_descs = 1, 1912 .num_device_descs = 1,
@@ -2155,11 +2000,12 @@ struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties = {
2155 2000
2156 .generic_bulk_ctrl_endpoint = 0x01, 2001 .generic_bulk_ctrl_endpoint = 0x01,
2157 2002
2158 .rc.legacy = { 2003 .rc.core = {
2159 .rc_interval = 100, 2004 .rc_interval = 100,
2160 .rc_map_table = rc_map_dvico_mce_table, 2005 .rc_codes = RC_MAP_DVICO_MCE,
2161 .rc_map_size = ARRAY_SIZE(rc_map_dvico_mce_table), 2006 .module_name = KBUILD_MODNAME,
2162 .rc_query = cxusb_rc_query, 2007 .rc_query = cxusb_rc_query,
2008 .allowed_protos = RC_BIT_UNKNOWN,
2163 }, 2009 },
2164 2010
2165 .num_device_descs = 1, 2011 .num_device_descs = 1,
@@ -2208,11 +2054,12 @@ static struct dvb_usb_device_properties cxusb_d680_dmb_properties = {
2208 2054
2209 .generic_bulk_ctrl_endpoint = 0x01, 2055 .generic_bulk_ctrl_endpoint = 0x01,
2210 2056
2211 .rc.legacy = { 2057 .rc.core = {
2212 .rc_interval = 100, 2058 .rc_interval = 100,
2213 .rc_map_table = rc_map_d680_dmb_table, 2059 .rc_codes = RC_MAP_D680_DMB,
2214 .rc_map_size = ARRAY_SIZE(rc_map_d680_dmb_table), 2060 .module_name = KBUILD_MODNAME,
2215 .rc_query = cxusb_d680_dmb_rc_query, 2061 .rc_query = cxusb_d680_dmb_rc_query,
2062 .allowed_protos = RC_BIT_UNKNOWN,
2216 }, 2063 },
2217 2064
2218 .num_device_descs = 1, 2065 .num_device_descs = 1,
@@ -2262,11 +2109,12 @@ static struct dvb_usb_device_properties cxusb_mygica_d689_properties = {
2262 2109
2263 .generic_bulk_ctrl_endpoint = 0x01, 2110 .generic_bulk_ctrl_endpoint = 0x01,
2264 2111
2265 .rc.legacy = { 2112 .rc.core = {
2266 .rc_interval = 100, 2113 .rc_interval = 100,
2267 .rc_map_table = rc_map_d680_dmb_table, 2114 .rc_codes = RC_MAP_D680_DMB,
2268 .rc_map_size = ARRAY_SIZE(rc_map_d680_dmb_table), 2115 .module_name = KBUILD_MODNAME,
2269 .rc_query = cxusb_d680_dmb_rc_query, 2116 .rc_query = cxusb_d680_dmb_rc_query,
2117 .allowed_protos = RC_BIT_UNKNOWN,
2270 }, 2118 },
2271 2119
2272 .num_device_descs = 1, 2120 .num_device_descs = 1,
@@ -2315,11 +2163,12 @@ static struct dvb_usb_device_properties cxusb_mygica_t230_properties = {
2315 2163
2316 .generic_bulk_ctrl_endpoint = 0x01, 2164 .generic_bulk_ctrl_endpoint = 0x01,
2317 2165
2318 .rc.legacy = { 2166 .rc.core = {
2319 .rc_interval = 100, 2167 .rc_interval = 100,
2320 .rc_map_table = rc_map_d680_dmb_table, 2168 .rc_codes = RC_MAP_D680_DMB,
2321 .rc_map_size = ARRAY_SIZE(rc_map_d680_dmb_table), 2169 .module_name = KBUILD_MODNAME,
2322 .rc_query = cxusb_d680_dmb_rc_query, 2170 .rc_query = cxusb_d680_dmb_rc_query,
2171 .allowed_protos = RC_BIT_UNKNOWN,
2323 }, 2172 },
2324 2173
2325 .num_device_descs = 1, 2174 .num_device_descs = 1,
diff --git a/drivers/media/usb/dvb-usb/dib0700_devices.c b/drivers/media/usb/dvb-usb/dib0700_devices.c
index b29d4894c2f1..81d7fd4f7776 100644
--- a/drivers/media/usb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/usb/dvb-usb/dib0700_devices.c
@@ -3815,6 +3815,7 @@ struct usb_device_id dib0700_usb_id_table[] = {
3815 { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E_SE) }, 3815 { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E_SE) },
3816 { USB_DEVICE(USB_VID_PCTV, USB_PID_DIBCOM_STK8096PVR) }, 3816 { USB_DEVICE(USB_VID_PCTV, USB_PID_DIBCOM_STK8096PVR) },
3817 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096PVR) }, 3817 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096PVR) },
3818 { USB_DEVICE(USB_VID_HAMA, USB_PID_HAMA_DVBT_HYBRID) },
3818 { 0 } /* Terminating entry */ 3819 { 0 } /* Terminating entry */
3819}; 3820};
3820MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); 3821MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
@@ -4379,7 +4380,7 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4379 }, 4380 },
4380 }, 4381 },
4381 4382
4382 .num_device_descs = 9, 4383 .num_device_descs = 10,
4383 .devices = { 4384 .devices = {
4384 { "Terratec Cinergy HT USB XE", 4385 { "Terratec Cinergy HT USB XE",
4385 { &dib0700_usb_id_table[27], NULL }, 4386 { &dib0700_usb_id_table[27], NULL },
@@ -4417,6 +4418,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4417 { &dib0700_usb_id_table[54], NULL }, 4418 { &dib0700_usb_id_table[54], NULL },
4418 { NULL }, 4419 { NULL },
4419 }, 4420 },
4421 { "Hama DVB=T Hybrid USB Stick",
4422 { &dib0700_usb_id_table[85], NULL },
4423 { NULL },
4424 },
4420 }, 4425 },
4421 4426
4422 .rc.core = { 4427 .rc.core = {
diff --git a/drivers/media/usb/dvb-usb/dtv5100.c b/drivers/media/usb/dvb-usb/dtv5100.c
index c60fb54f445f..2fa2abd3e726 100644
--- a/drivers/media/usb/dvb-usb/dtv5100.c
+++ b/drivers/media/usb/dvb-usb/dtv5100.c
@@ -15,10 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 18 */
23 19
24#include "dtv5100.h" 20#include "dtv5100.h"
diff --git a/drivers/media/usb/dvb-usb/dtv5100.h b/drivers/media/usb/dvb-usb/dtv5100.h
index 93e96e04a82a..1ab1eafd3187 100644
--- a/drivers/media/usb/dvb-usb/dtv5100.h
+++ b/drivers/media/usb/dvb-usb/dtv5100.h
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 16 */
21 17
22#ifndef _DVB_USB_DTV5100_H_ 18#ifndef _DVB_USB_DTV5100_H_
diff --git a/drivers/media/usb/dvb-usb/dvb-usb-firmware.c b/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
index f0023dbb7276..ab9866024ec7 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
+++ b/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
@@ -35,28 +35,33 @@ static int usb_cypress_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 le
35 35
36int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type) 36int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type)
37{ 37{
38 struct hexline hx; 38 struct hexline *hx;
39 u8 reset; 39 u8 reset;
40 int ret,pos=0; 40 int ret,pos=0;
41 41
42 hx = kmalloc(sizeof(*hx), GFP_KERNEL);
43 if (!hx)
44 return -ENOMEM;
45
42 /* stop the CPU */ 46 /* stop the CPU */
43 reset = 1; 47 reset = 1;
44 if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1)) != 1) 48 if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1)) != 1)
45 err("could not stop the USB controller CPU."); 49 err("could not stop the USB controller CPU.");
46 50
47 while ((ret = dvb_usb_get_hexline(fw,&hx,&pos)) > 0) { 51 while ((ret = dvb_usb_get_hexline(fw, hx, &pos)) > 0) {
48 deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n",hx.addr,hx.len,hx.chk); 52 deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n", hx->addr, hx->len, hx->chk);
49 ret = usb_cypress_writemem(udev,hx.addr,hx.data,hx.len); 53 ret = usb_cypress_writemem(udev, hx->addr, hx->data, hx->len);
50 54
51 if (ret != hx.len) { 55 if (ret != hx->len) {
52 err("error while transferring firmware (transferred size: %d, block size: %d)", 56 err("error while transferring firmware (transferred size: %d, block size: %d)",
53 ret,hx.len); 57 ret, hx->len);
54 ret = -EINVAL; 58 ret = -EINVAL;
55 break; 59 break;
56 } 60 }
57 } 61 }
58 if (ret < 0) { 62 if (ret < 0) {
59 err("firmware download failed at %d with %d",pos,ret); 63 err("firmware download failed at %d with %d",pos,ret);
64 kfree(hx);
60 return ret; 65 return ret;
61 } 66 }
62 67
@@ -70,6 +75,8 @@ int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw
70 } else 75 } else
71 ret = -EIO; 76 ret = -EIO;
72 77
78 kfree(hx);
79
73 return ret; 80 return ret;
74} 81}
75EXPORT_SYMBOL(usb_cypress_load_firmware); 82EXPORT_SYMBOL(usb_cypress_load_firmware);
diff --git a/drivers/media/usb/dvb-usb/dvb-usb-remote.c b/drivers/media/usb/dvb-usb/dvb-usb-remote.c
index c259f9e43542..059ded59208e 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb-remote.c
+++ b/drivers/media/usb/dvb-usb/dvb-usb-remote.c
@@ -265,7 +265,7 @@ static int rc_core_dvb_usb_remote_init(struct dvb_usb_device *d)
265 int err, rc_interval; 265 int err, rc_interval;
266 struct rc_dev *dev; 266 struct rc_dev *dev;
267 267
268 dev = rc_allocate_device(); 268 dev = rc_allocate_device(d->props.rc.core.driver_type);
269 if (!dev) 269 if (!dev)
270 return -ENOMEM; 270 return -ENOMEM;
271 271
@@ -273,7 +273,6 @@ static int rc_core_dvb_usb_remote_init(struct dvb_usb_device *d)
273 dev->map_name = d->props.rc.core.rc_codes; 273 dev->map_name = d->props.rc.core.rc_codes;
274 dev->change_protocol = d->props.rc.core.change_protocol; 274 dev->change_protocol = d->props.rc.core.change_protocol;
275 dev->allowed_protocols = d->props.rc.core.allowed_protos; 275 dev->allowed_protocols = d->props.rc.core.allowed_protos;
276 dev->driver_type = d->props.rc.core.driver_type;
277 usb_to_input_id(d->udev, &dev->input_id); 276 usb_to_input_id(d->udev, &dev->input_id);
278 dev->input_name = "IR-receiver inside an USB DVB receiver"; 277 dev->input_name = "IR-receiver inside an USB DVB receiver";
279 dev->input_phys = d->rc_phys; 278 dev->input_phys = d->rc_phys;
diff --git a/drivers/media/usb/dvb-usb/gp8psk.c b/drivers/media/usb/dvb-usb/gp8psk.c
index 2360e7e32b06..37f062225ed2 100644
--- a/drivers/media/usb/dvb-usb/gp8psk.c
+++ b/drivers/media/usb/dvb-usb/gp8psk.c
@@ -161,7 +161,7 @@ static int gp8psk_load_bcm4500fw(struct dvb_usb_device *d)
161 goto out_free; 161 goto out_free;
162 } 162 }
163 if (buflen > 64) { 163 if (buflen > 64) {
164 err("firmare chunk size bigger than 64 bytes."); 164 err("firmware chunk size bigger than 64 bytes.");
165 goto out_free; 165 goto out_free;
166 } 166 }
167 167
@@ -278,7 +278,7 @@ static int gp8psk_fe_reload(void *priv)
278 return gp8psk_bcm4500_reload(d); 278 return gp8psk_bcm4500_reload(d);
279} 279}
280 280
281const struct gp8psk_fe_ops gp8psk_fe_ops = { 281static const struct gp8psk_fe_ops gp8psk_fe_ops = {
282 .in = gp8psk_fe_in, 282 .in = gp8psk_fe_in,
283 .out = gp8psk_fe_out, 283 .out = gp8psk_fe_out,
284 .reload = gp8psk_fe_reload, 284 .reload = gp8psk_fe_reload,
diff --git a/drivers/media/usb/dvb-usb/technisat-usb2.c b/drivers/media/usb/dvb-usb/technisat-usb2.c
index 02c3bee6f83b..9f7dd1afcb15 100644
--- a/drivers/media/usb/dvb-usb/technisat-usb2.c
+++ b/drivers/media/usb/dvb-usb/technisat-usb2.c
@@ -14,10 +14,6 @@
14 * License, or (at your option) any later version. 14 * License, or (at your option) any later version.
15 * 15 *
16 * 16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 * THIS PROGRAM IS PROVIDED "AS IS" AND BOTH THE COPYRIGHT HOLDER AND 17 * THIS PROGRAM IS PROVIDED "AS IS" AND BOTH THE COPYRIGHT HOLDER AND
22 * TECHNISAT DIGITAL UK LTD DISCLAIM ALL WARRANTIES WITH REGARD TO 18 * TECHNISAT DIGITAL UK LTD DISCLAIM ALL WARRANTIES WITH REGARD TO
23 * THIS PROGRAM INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY OR 19 * THIS PROGRAM INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY OR
@@ -753,7 +749,7 @@ static struct dvb_usb_device_properties technisat_usb2_devices = {
753 .rc_codes = RC_MAP_TECHNISAT_USB2, 749 .rc_codes = RC_MAP_TECHNISAT_USB2,
754 .module_name = "technisat-usb2", 750 .module_name = "technisat-usb2",
755 .rc_query = technisat_usb2_rc_query, 751 .rc_query = technisat_usb2_rc_query,
756 .allowed_protos = RC_BIT_ALL, 752 .allowed_protos = RC_BIT_ALL_IR_DECODER,
757 .driver_type = RC_DRIVER_IR_RAW, 753 .driver_type = RC_DRIVER_IR_RAW,
758 } 754 }
759}; 755};
diff --git a/drivers/media/usb/em28xx/em28xx-audio.c b/drivers/media/usb/em28xx/em28xx-audio.c
index 7969ddb9e2dd..ffad7f1af166 100644
--- a/drivers/media/usb/em28xx/em28xx-audio.c
+++ b/drivers/media/usb/em28xx/em28xx-audio.c
@@ -19,10 +19,6 @@
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 */ 22 */
27 23
28#include "em28xx.h" 24#include "em28xx.h"
diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c
index 23c67494762d..5f90d0899a45 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -509,6 +509,7 @@ static struct em28xx_reg_seq plex_px_bcud[] = {
509 509
510/* 510/*
511 * 2040:0265 Hauppauge WinTV-dualHD DVB 511 * 2040:0265 Hauppauge WinTV-dualHD DVB
512 * 2040:026d Hauppauge WinTV-dualHD ATSC/QAM
512 * reg 0x80/0x84: 513 * reg 0x80/0x84:
513 * GPIO_0: Yellow LED tuner 1, 0=on, 1=off 514 * GPIO_0: Yellow LED tuner 1, 0=on, 1=off
514 * GPIO_1: Green LED tuner 1, 0=on, 1=off 515 * GPIO_1: Green LED tuner 1, 0=on, 1=off
@@ -2389,6 +2390,21 @@ struct em28xx_board em28xx_boards[] = {
2389 .ir_codes = RC_MAP_HAUPPAUGE, 2390 .ir_codes = RC_MAP_HAUPPAUGE,
2390 .leds = hauppauge_dualhd_leds, 2391 .leds = hauppauge_dualhd_leds,
2391 }, 2392 },
2393 /*
2394 * 2040:026d Hauppauge WinTV-dualHD (model 01595 - ATSC/QAM).
2395 * Empia EM28274, 2x LG LGDT3306A, 2x Silicon Labs Si2157
2396 */
2397 [EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595] = {
2398 .name = "Hauppauge WinTV-dualHD 01595 ATSC/QAM",
2399 .def_i2c_bus = 1,
2400 .i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE |
2401 EM28XX_I2C_FREQ_400_KHZ,
2402 .tuner_type = TUNER_ABSENT,
2403 .tuner_gpio = hauppauge_dualhd_dvb,
2404 .has_dvb = 1,
2405 .ir_codes = RC_MAP_HAUPPAUGE,
2406 .leds = hauppauge_dualhd_leds,
2407 },
2392}; 2408};
2393EXPORT_SYMBOL_GPL(em28xx_boards); 2409EXPORT_SYMBOL_GPL(em28xx_boards);
2394 2410
@@ -2514,6 +2530,8 @@ struct usb_device_id em28xx_id_table[] = {
2514 .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850 }, 2530 .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850 },
2515 { USB_DEVICE(0x2040, 0x0265), 2531 { USB_DEVICE(0x2040, 0x0265),
2516 .driver_info = EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB }, 2532 .driver_info = EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB },
2533 { USB_DEVICE(0x2040, 0x026d),
2534 .driver_info = EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595 },
2517 { USB_DEVICE(0x0438, 0xb002), 2535 { USB_DEVICE(0x0438, 0xb002),
2518 .driver_info = EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600 }, 2536 .driver_info = EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600 },
2519 { USB_DEVICE(0x2001, 0xf112), 2537 { USB_DEVICE(0x2001, 0xf112),
@@ -2945,6 +2963,7 @@ static void em28xx_card_setup(struct em28xx *dev)
2945 case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950: 2963 case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
2946 case EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C: 2964 case EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C:
2947 case EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB: 2965 case EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB:
2966 case EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595:
2948 { 2967 {
2949 struct tveeprom tv; 2968 struct tveeprom tv;
2950 2969
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
index 75a75dab2e8e..82edd37f0d73 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -37,6 +37,7 @@
37 37
38#include "lgdt330x.h" 38#include "lgdt330x.h"
39#include "lgdt3305.h" 39#include "lgdt3305.h"
40#include "lgdt3306a.h"
40#include "zl10353.h" 41#include "zl10353.h"
41#include "s5h1409.h" 42#include "s5h1409.h"
42#include "mt2060.h" 43#include "mt2060.h"
@@ -920,6 +921,17 @@ static struct tda18271_config pinnacle_80e_dvb_config = {
920 .role = TDA18271_MASTER, 921 .role = TDA18271_MASTER,
921}; 922};
922 923
924static struct lgdt3306a_config hauppauge_01595_lgdt3306a_config = {
925 .qam_if_khz = 4000,
926 .vsb_if_khz = 3250,
927 .spectral_inversion = 0,
928 .deny_i2c_rptr = 0,
929 .mpeg_mode = LGDT3306A_MPEG_SERIAL,
930 .tpclk_edge = LGDT3306A_TPCLK_RISING_EDGE,
931 .tpvalid_polarity = LGDT3306A_TP_VALID_HIGH,
932 .xtalMHz = 25,
933};
934
923/* ------------------------------------------------------------------ */ 935/* ------------------------------------------------------------------ */
924 936
925static int em28xx_attach_xc3028(u8 addr, struct em28xx *dev) 937static int em28xx_attach_xc3028(u8 addr, struct em28xx *dev)
@@ -1950,6 +1962,68 @@ static int em28xx_dvb_init(struct em28xx *dev)
1950 1962
1951 } 1963 }
1952 break; 1964 break;
1965 case EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595:
1966 {
1967 struct i2c_adapter *adapter;
1968 struct i2c_client *client;
1969 struct i2c_board_info info = {};
1970 struct lgdt3306a_config lgdt3306a_config;
1971 struct si2157_config si2157_config = {};
1972
1973 /* attach demod */
1974 lgdt3306a_config = hauppauge_01595_lgdt3306a_config;
1975 lgdt3306a_config.fe = &dvb->fe[0];
1976 lgdt3306a_config.i2c_adapter = &adapter;
1977 strlcpy(info.type, "lgdt3306a", sizeof(info.type));
1978 info.addr = 0x59;
1979 info.platform_data = &lgdt3306a_config;
1980 request_module(info.type);
1981 client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus],
1982 &info);
1983 if (client == NULL || client->dev.driver == NULL) {
1984 result = -ENODEV;
1985 goto out_free;
1986 }
1987
1988 if (!try_module_get(client->dev.driver->owner)) {
1989 i2c_unregister_device(client);
1990 result = -ENODEV;
1991 goto out_free;
1992 }
1993
1994 dvb->i2c_client_demod = client;
1995
1996 /* attach tuner */
1997 si2157_config.fe = dvb->fe[0];
1998 si2157_config.if_port = 1;
1999 si2157_config.inversion = 1;
2000#ifdef CONFIG_MEDIA_CONTROLLER_DVB
2001 si2157_config.mdev = dev->media_dev;
2002#endif
2003 memset(&info, 0, sizeof(struct i2c_board_info));
2004 strlcpy(info.type, "si2157", sizeof(info.type));
2005 info.addr = 0x60;
2006 info.platform_data = &si2157_config;
2007 request_module(info.type);
2008
2009 client = i2c_new_device(adapter, &info);
2010 if (client == NULL || client->dev.driver == NULL) {
2011 module_put(dvb->i2c_client_demod->dev.driver->owner);
2012 i2c_unregister_device(dvb->i2c_client_demod);
2013 result = -ENODEV;
2014 goto out_free;
2015 }
2016 if (!try_module_get(client->dev.driver->owner)) {
2017 i2c_unregister_device(client);
2018 module_put(dvb->i2c_client_demod->dev.driver->owner);
2019 i2c_unregister_device(dvb->i2c_client_demod);
2020 result = -ENODEV;
2021 goto out_free;
2022 }
2023
2024 dvb->i2c_client_tuner = client;
2025 }
2026 break;
1953 default: 2027 default:
1954 dev_err(&dev->intf->dev, 2028 dev_err(&dev->intf->dev,
1955 "The frontend of your DVB/ATSC card isn't supported yet\n"); 2029 "The frontend of your DVB/ATSC card isn't supported yet\n");
diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c
index 782ce095c8c5..eba75736e654 100644
--- a/drivers/media/usb/em28xx/em28xx-input.c
+++ b/drivers/media/usb/em28xx/em28xx-input.c
@@ -259,18 +259,21 @@ static int em2874_polling_getkey(struct em28xx_IR *ir,
259 break; 259 break;
260 260
261 case RC_BIT_NEC: 261 case RC_BIT_NEC:
262 poll_result->protocol = RC_TYPE_RC5;
263 poll_result->scancode = msg[1] << 8 | msg[2]; 262 poll_result->scancode = msg[1] << 8 | msg[2];
264 if ((msg[3] ^ msg[4]) != 0xff) /* 32 bits NEC */ 263 if ((msg[3] ^ msg[4]) != 0xff) { /* 32 bits NEC */
264 poll_result->protocol = RC_TYPE_NEC32;
265 poll_result->scancode = RC_SCANCODE_NEC32((msg[1] << 24) | 265 poll_result->scancode = RC_SCANCODE_NEC32((msg[1] << 24) |
266 (msg[2] << 16) | 266 (msg[2] << 16) |
267 (msg[3] << 8) | 267 (msg[3] << 8) |
268 (msg[4])); 268 (msg[4]));
269 else if ((msg[1] ^ msg[2]) != 0xff) /* 24 bits NEC */ 269 } else if ((msg[1] ^ msg[2]) != 0xff) { /* 24 bits NEC */
270 poll_result->protocol = RC_TYPE_NECX;
270 poll_result->scancode = RC_SCANCODE_NECX(msg[1] << 8 | 271 poll_result->scancode = RC_SCANCODE_NECX(msg[1] << 8 |
271 msg[2], msg[3]); 272 msg[2], msg[3]);
272 else /* Normal NEC */ 273 } else { /* Normal NEC */
274 poll_result->protocol = RC_TYPE_NEC;
273 poll_result->scancode = RC_SCANCODE_NEC(msg[1], msg[3]); 275 poll_result->scancode = RC_SCANCODE_NEC(msg[1], msg[3]);
276 }
274 break; 277 break;
275 278
276 case RC_BIT_RC6_0: 279 case RC_BIT_RC6_0:
@@ -719,7 +722,7 @@ static int em28xx_ir_init(struct em28xx *dev)
719 ir = kzalloc(sizeof(*ir), GFP_KERNEL); 722 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
720 if (!ir) 723 if (!ir)
721 return -ENOMEM; 724 return -ENOMEM;
722 rc = rc_allocate_device(); 725 rc = rc_allocate_device(RC_DRIVER_SCANCODE);
723 if (!rc) 726 if (!rc)
724 goto error; 727 goto error;
725 728
@@ -777,7 +780,7 @@ static int em28xx_ir_init(struct em28xx *dev)
777 case CHIP_ID_EM28178: 780 case CHIP_ID_EM28178:
778 ir->get_key = em2874_polling_getkey; 781 ir->get_key = em2874_polling_getkey;
779 rc->allowed_protocols = RC_BIT_RC5 | RC_BIT_NEC | 782 rc->allowed_protocols = RC_BIT_RC5 | RC_BIT_NEC |
780 RC_BIT_RC6_0; 783 RC_BIT_NECX | RC_BIT_NEC32 | RC_BIT_RC6_0;
781 break; 784 break;
782 default: 785 default:
783 err = -ENODEV; 786 err = -ENODEV;
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h
index ca59e2d4fccf..e9f379959fa5 100644
--- a/drivers/media/usb/em28xx/em28xx.h
+++ b/drivers/media/usb/em28xx/em28xx.h
@@ -147,6 +147,7 @@
147#define EM2884_BOARD_ELGATO_EYETV_HYBRID_2008 97 147#define EM2884_BOARD_ELGATO_EYETV_HYBRID_2008 97
148#define EM28178_BOARD_PLEX_PX_BCUD 98 148#define EM28178_BOARD_PLEX_PX_BCUD 98
149#define EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB 99 149#define EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB 99
150#define EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595 100
150 151
151/* Limits minimum and default number of buffers */ 152/* Limits minimum and default number of buffers */
152#define EM28XX_MIN_BUF 4 153#define EM28XX_MIN_BUF 4
diff --git a/drivers/media/usb/gspca/autogain_functions.c b/drivers/media/usb/gspca/autogain_functions.c
index 0e9ee8b50bb7..427db745e027 100644
--- a/drivers/media/usb/gspca/autogain_functions.c
+++ b/drivers/media/usb/gspca/autogain_functions.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 15 */
20#include "gspca.h" 16#include "gspca.h"
21 17
diff --git a/drivers/media/usb/gspca/benq.c b/drivers/media/usb/gspca/benq.c
index 5fa67b78ad49..60a728203b3b 100644
--- a/drivers/media/usb/gspca/benq.c
+++ b/drivers/media/usb/gspca/benq.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 15 */
20 16
21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/conex.c b/drivers/media/usb/gspca/conex.c
index 2e15c80d6e3d..bdcdf7999c56 100644
--- a/drivers/media/usb/gspca/conex.c
+++ b/drivers/media/usb/gspca/conex.c
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 16 */
21 17
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/cpia1.c b/drivers/media/usb/gspca/cpia1.c
index 52b88e9e656b..23d3285f182a 100644
--- a/drivers/media/usb/gspca/cpia1.c
+++ b/drivers/media/usb/gspca/cpia1.c
@@ -20,10 +20,6 @@
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 21 * GNU General Public License for more details.
22 * 22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 */ 23 */
28 24
29#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 25#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/etoms.c b/drivers/media/usb/gspca/etoms.c
index 26c9ee1f1045..8f84292936e9 100644
--- a/drivers/media/usb/gspca/etoms.c
+++ b/drivers/media/usb/gspca/etoms.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 15 */
20 16
21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/finepix.c b/drivers/media/usb/gspca/finepix.c
index ae9a55d7bbbb..7bb469aa61a7 100644
--- a/drivers/media/usb/gspca/finepix.c
+++ b/drivers/media/usb/gspca/finepix.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 15 */
20 16
21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index fa2cbb981905..16bc1dde2c8c 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -15,10 +15,6 @@
15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * for more details. 17 * for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 18 */
23 19
24#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 20#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/jeilinj.c b/drivers/media/usb/gspca/jeilinj.c
index 19736e237b37..34e043b7d1bc 100644
--- a/drivers/media/usb/gspca/jeilinj.c
+++ b/drivers/media/usb/gspca/jeilinj.c
@@ -18,10 +18,6 @@
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */ 21 */
26 22
27#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/jl2005bcd.c b/drivers/media/usb/gspca/jl2005bcd.c
index b12ecb72df4c..17c7a953564c 100644
--- a/drivers/media/usb/gspca/jl2005bcd.c
+++ b/drivers/media/usb/gspca/jl2005bcd.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 15 */
20 16
21#define MODULE_NAME "jl2005bcd" 17#define MODULE_NAME "jl2005bcd"
diff --git a/drivers/media/usb/gspca/jpeg.h b/drivers/media/usb/gspca/jpeg.h
index 0aa2b671faa4..d5ad7c96d039 100644
--- a/drivers/media/usb/gspca/jpeg.h
+++ b/drivers/media/usb/gspca/jpeg.h
@@ -18,10 +18,6 @@
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */ 21 */
26 22
27/* 23/*
diff --git a/drivers/media/usb/gspca/kinect.c b/drivers/media/usb/gspca/kinect.c
index 3cb30a37d6ac..2f28b38c5479 100644
--- a/drivers/media/usb/gspca/kinect.c
+++ b/drivers/media/usb/gspca/kinect.c
@@ -18,10 +18,6 @@
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */ 21 */
26 22
27#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/konica.c b/drivers/media/usb/gspca/konica.c
index 40aaaa9c5f30..71f273377f83 100644
--- a/drivers/media/usb/gspca/konica.c
+++ b/drivers/media/usb/gspca/konica.c
@@ -22,10 +22,6 @@
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details. 24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 */ 25 */
30 26
31#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 27#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/mars.c b/drivers/media/usb/gspca/mars.c
index 779a8785f421..25df55e840c7 100644
--- a/drivers/media/usb/gspca/mars.c
+++ b/drivers/media/usb/gspca/mars.c
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 16 */
21 17
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/mr97310a.c b/drivers/media/usb/gspca/mr97310a.c
index 6dfb364094ec..8b0e32a649ac 100644
--- a/drivers/media/usb/gspca/mr97310a.c
+++ b/drivers/media/usb/gspca/mr97310a.c
@@ -34,10 +34,6 @@
34 * but WITHOUT ANY WARRANTY; without even the implied warranty of 34 * but WITHOUT ANY WARRANTY; without even the implied warranty of
35 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 35 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 * GNU General Public License for more details. 36 * GNU General Public License for more details.
37 *
38 * You should have received a copy of the GNU General Public License
39 * along with this program; if not, write to the Free Software
40 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
41 */ 37 */
42 38
43#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 39#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/nw80x.c b/drivers/media/usb/gspca/nw80x.c
index 599f755e75b8..5d2d0bcb038d 100644
--- a/drivers/media/usb/gspca/nw80x.c
+++ b/drivers/media/usb/gspca/nw80x.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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 */ 17 */
22 18
23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/ov519.c b/drivers/media/usb/gspca/ov519.c
index 4dbca54cf2a8..f4c41f043cda 100644
--- a/drivers/media/usb/gspca/ov519.c
+++ b/drivers/media/usb/gspca/ov519.c
@@ -31,10 +31,6 @@
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details. 32 * GNU General Public License for more details.
33 * 33 *
34 * You should have received a copy of the GNU General Public License
35 * along with this program; if not, write to the Free Software
36 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
37 *
38 */ 34 */
39 35
40#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 36#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/ov534.c b/drivers/media/usb/gspca/ov534.c
index 9266a5c9abc5..32849ff86b09 100644
--- a/drivers/media/usb/gspca/ov534.c
+++ b/drivers/media/usb/gspca/ov534.c
@@ -24,10 +24,6 @@
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of 24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details. 26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 */ 27 */
32 28
33#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 29#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/ov534_9.c b/drivers/media/usb/gspca/ov534_9.c
index 47085cf2d723..b2a92e518118 100644
--- a/drivers/media/usb/gspca/ov534_9.c
+++ b/drivers/media/usb/gspca/ov534_9.c
@@ -18,10 +18,6 @@
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */ 21 */
26 22
27#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/pac207.c b/drivers/media/usb/gspca/pac207.c
index 51e11248bbb8..01c185d367e5 100644
--- a/drivers/media/usb/gspca/pac207.c
+++ b/drivers/media/usb/gspca/pac207.c
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */ 20 */
25 21
26#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/pac7302.c b/drivers/media/usb/gspca/pac7302.c
index be07a24c4518..595535e143e6 100644
--- a/drivers/media/usb/gspca/pac7302.c
+++ b/drivers/media/usb/gspca/pac7302.c
@@ -17,10 +17,6 @@
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */ 20 */
25 21
26/* 22/*
diff --git a/drivers/media/usb/gspca/pac7311.c b/drivers/media/usb/gspca/pac7311.c
index 25f86b1e74a8..8bac2d9326bf 100644
--- a/drivers/media/usb/gspca/pac7311.c
+++ b/drivers/media/usb/gspca/pac7311.c
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 16 */
21 17
22/* Some documentation about various registers as determined by trial and error. 18/* Some documentation about various registers as determined by trial and error.
diff --git a/drivers/media/usb/gspca/pac_common.h b/drivers/media/usb/gspca/pac_common.h
index fbc5e226c3e4..4047bcb6c2b5 100644
--- a/drivers/media/usb/gspca/pac_common.h
+++ b/drivers/media/usb/gspca/pac_common.h
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */ 20 */
25 21
26/* We calculate the autogain at the end of the transfer of a frame, at this 22/* We calculate the autogain at the end of the transfer of a frame, at this
diff --git a/drivers/media/usb/gspca/se401.c b/drivers/media/usb/gspca/se401.c
index 5102cea50471..477da0664b7d 100644
--- a/drivers/media/usb/gspca/se401.c
+++ b/drivers/media/usb/gspca/se401.c
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */ 20 */
25 21
26#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/se401.h b/drivers/media/usb/gspca/se401.h
index 96d8ebf3cf59..7cc0728c1410 100644
--- a/drivers/media/usb/gspca/se401.h
+++ b/drivers/media/usb/gspca/se401.h
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */ 20 */
25 21
26#define SE401_REQ_GET_CAMERA_DESCRIPTOR 0x06 22#define SE401_REQ_GET_CAMERA_DESCRIPTOR 0x06
diff --git a/drivers/media/usb/gspca/sn9c2028.c b/drivers/media/usb/gspca/sn9c2028.c
index 4f2050a5ec94..5d32dd359d84 100644
--- a/drivers/media/usb/gspca/sn9c2028.c
+++ b/drivers/media/usb/gspca/sn9c2028.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 15 */
20 16
21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/sn9c2028.h b/drivers/media/usb/gspca/sn9c2028.h
index f85bc106bc52..85761aa7c8b2 100644
--- a/drivers/media/usb/gspca/sn9c2028.h
+++ b/drivers/media/usb/gspca/sn9c2028.h
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU 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 */ 18 */
23 19
24static const unsigned char sn9c2028_sof_marker[] = { 20static const unsigned char sn9c2028_sof_marker[] = {
diff --git a/drivers/media/usb/gspca/sn9c20x.c b/drivers/media/usb/gspca/sn9c20x.c
index e7430b06526a..c605f78d6186 100644
--- a/drivers/media/usb/gspca/sn9c20x.c
+++ b/drivers/media/usb/gspca/sn9c20x.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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 */ 17 */
22 18
23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/sonixb.c b/drivers/media/usb/gspca/sonixb.c
index 6696b2ec34e9..5f3f2979540a 100644
--- a/drivers/media/usb/gspca/sonixb.c
+++ b/drivers/media/usb/gspca/sonixb.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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 */ 17 */
22 18
23/* Some documentation on known sonixb registers: 19/* Some documentation on known sonixb registers:
diff --git a/drivers/media/usb/gspca/sonixj.c b/drivers/media/usb/gspca/sonixj.c
index d49d76ec1421..5eeaf16ac5e8 100644
--- a/drivers/media/usb/gspca/sonixj.c
+++ b/drivers/media/usb/gspca/sonixj.c
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 16 */
21 17
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/spca1528.c b/drivers/media/usb/gspca/spca1528.c
index f38fd8949609..327ec901abe1 100644
--- a/drivers/media/usb/gspca/spca1528.c
+++ b/drivers/media/usb/gspca/spca1528.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 15 */
20 16
21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/spca500.c b/drivers/media/usb/gspca/spca500.c
index f011a309dd65..da2d9027914c 100644
--- a/drivers/media/usb/gspca/spca500.c
+++ b/drivers/media/usb/gspca/spca500.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/spca501.c b/drivers/media/usb/gspca/spca501.c
index d92fd17d6701..ae5a80987553 100644
--- a/drivers/media/usb/gspca/spca501.c
+++ b/drivers/media/usb/gspca/spca501.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/spca505.c b/drivers/media/usb/gspca/spca505.c
index 232b330d2dd3..1553cc766c04 100644
--- a/drivers/media/usb/gspca/spca505.c
+++ b/drivers/media/usb/gspca/spca505.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/spca506.c b/drivers/media/usb/gspca/spca506.c
index ee84863d27d4..843c93f5acf3 100644
--- a/drivers/media/usb/gspca/spca506.c
+++ b/drivers/media/usb/gspca/spca506.c
@@ -15,10 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 18 */
23 19
24#define MODULE_NAME "spca506" 20#define MODULE_NAME "spca506"
diff --git a/drivers/media/usb/gspca/spca508.c b/drivers/media/usb/gspca/spca508.c
index 75f2beb2ea5a..1e0ba6b24e21 100644
--- a/drivers/media/usb/gspca/spca508.c
+++ b/drivers/media/usb/gspca/spca508.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 15 */
20 16
21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/spca561.c b/drivers/media/usb/gspca/spca561.c
index 403d71cd65d9..4ff704cf9ed6 100644
--- a/drivers/media/usb/gspca/spca561.c
+++ b/drivers/media/usb/gspca/spca561.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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 */ 17 */
22 18
23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/sq905.c b/drivers/media/usb/gspca/sq905.c
index 9424c33f0ddb..f1da34a10ce8 100644
--- a/drivers/media/usb/gspca/sq905.c
+++ b/drivers/media/usb/gspca/sq905.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 15 */
20 16
21/* 17/*
diff --git a/drivers/media/usb/gspca/sq905c.c b/drivers/media/usb/gspca/sq905c.c
index 6c45dcc44eb0..8b4e4948a0cb 100644
--- a/drivers/media/usb/gspca/sq905c.c
+++ b/drivers/media/usb/gspca/sq905c.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 15 */
20 16
21/* 17/*
diff --git a/drivers/media/usb/gspca/sq930x.c b/drivers/media/usb/gspca/sq930x.c
index e274cf19a3ea..aa9a9411b801 100644
--- a/drivers/media/usb/gspca/sq930x.c
+++ b/drivers/media/usb/gspca/sq930x.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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 */ 17 */
22 18
23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/stk014.c b/drivers/media/usb/gspca/stk014.c
index d324d001e114..daf45db6c404 100644
--- a/drivers/media/usb/gspca/stk014.c
+++ b/drivers/media/usb/gspca/stk014.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 15 */
20 16
21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/stk1135.c b/drivers/media/usb/gspca/stk1135.c
index 48234c9a8b6c..3ab5ec2ca4bd 100644
--- a/drivers/media/usb/gspca/stk1135.c
+++ b/drivers/media/usb/gspca/stk1135.c
@@ -15,10 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 18 */
23 19
24#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 20#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/stk1135.h b/drivers/media/usb/gspca/stk1135.h
index e1dd92ab49bb..bd144012f73a 100644
--- a/drivers/media/usb/gspca/stk1135.h
+++ b/drivers/media/usb/gspca/stk1135.h
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 15 */
20 16
21#define STK1135_REG_GCTRL 0x000 /* GPIO control */ 17#define STK1135_REG_GCTRL 0x000 /* GPIO control */
diff --git a/drivers/media/usb/gspca/stv0680.c b/drivers/media/usb/gspca/stv0680.c
index 7f94ec74282e..29a65d05cbb2 100644
--- a/drivers/media/usb/gspca/stv0680.c
+++ b/drivers/media/usb/gspca/stv0680.c
@@ -21,10 +21,6 @@
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details. 22 * GNU General Public License for more details.
23 * 23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 *
28 */ 24 */
29 25
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 26#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx.c b/drivers/media/usb/gspca/stv06xx/stv06xx.c
index fef7a784b879..e72c3e1ab9ff 100644
--- a/drivers/media/usb/gspca/stv06xx/stv06xx.c
+++ b/drivers/media/usb/gspca/stv06xx/stv06xx.c
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * P/N 861037: Sensor HDCS1000 ASIC STV0600 17 * P/N 861037: Sensor HDCS1000 ASIC STV0600
22 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600 18 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600
23 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express 19 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx.h b/drivers/media/usb/gspca/stv06xx/stv06xx.h
index 34957a4ec150..f9d74e4d7cf9 100644
--- a/drivers/media/usb/gspca/stv06xx/stv06xx.h
+++ b/drivers/media/usb/gspca/stv06xx/stv06xx.h
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * P/N 861037: Sensor HDCS1000 ASIC STV0600 17 * P/N 861037: Sensor HDCS1000 ASIC STV0600
22 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600 18 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600
23 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express 19 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.c b/drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.c
index 2220b70d47e6..28252f6c4afd 100644
--- a/drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.c
+++ b/drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.c
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU 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 * P/N 861037: Sensor HDCS1000 ASIC STV0600 18 * P/N 861037: Sensor HDCS1000 ASIC STV0600
23 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600 19 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600
24 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express 20 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.h b/drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.h
index 1ba9158d0102..d2da0de05236 100644
--- a/drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.h
+++ b/drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.h
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU 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 * P/N 861037: Sensor HDCS1000 ASIC STV0600 18 * P/N 861037: Sensor HDCS1000 ASIC STV0600
23 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600 19 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600
24 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express 20 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c b/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c
index 8d785edcccf2..e1ce96e9405f 100644
--- a/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c
+++ b/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * P/N 861037: Sensor HDCS1000 ASIC STV0600 17 * P/N 861037: Sensor HDCS1000 ASIC STV0600
22 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600 18 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600
23 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express 19 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.h b/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.h
index 5071e5353fd3..33572d8bb368 100644
--- a/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.h
+++ b/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.h
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * P/N 861037: Sensor HDCS1000 ASIC STV0600 17 * P/N 861037: Sensor HDCS1000 ASIC STV0600
22 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600 18 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600
23 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express 19 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_sensor.h b/drivers/media/usb/gspca/stv06xx/stv06xx_sensor.h
index 3a498c2495c6..747d07c877fe 100644
--- a/drivers/media/usb/gspca/stv06xx/stv06xx_sensor.h
+++ b/drivers/media/usb/gspca/stv06xx/stv06xx_sensor.h
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * P/N 861037: Sensor HDCS1000 ASIC STV0600 17 * P/N 861037: Sensor HDCS1000 ASIC STV0600
22 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600 18 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600
23 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express 19 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_st6422.c b/drivers/media/usb/gspca/stv06xx/stv06xx_st6422.c
index 515a9e121653..4b76070515b5 100644
--- a/drivers/media/usb/gspca/stv06xx/stv06xx_st6422.c
+++ b/drivers/media/usb/gspca/stv06xx/stv06xx_st6422.c
@@ -20,10 +20,6 @@
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 21 * GNU General Public License for more details.
22 * 22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 */ 23 */
28 24
29#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 25#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_st6422.h b/drivers/media/usb/gspca/stv06xx/stv06xx_st6422.h
index 8f20fbf30f33..87324a69a0be 100644
--- a/drivers/media/usb/gspca/stv06xx/stv06xx_st6422.h
+++ b/drivers/media/usb/gspca/stv06xx/stv06xx_st6422.h
@@ -20,10 +20,6 @@
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 21 * GNU General Public License for more details.
22 * 22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 */ 23 */
28 24
29#ifndef STV06XX_ST6422_H_ 25#ifndef STV06XX_ST6422_H_
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c b/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c
index f86cec091bf4..d265e6b00994 100644
--- a/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c
+++ b/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * P/N 861037: Sensor HDCS1000 ASIC STV0600 17 * P/N 861037: Sensor HDCS1000 ASIC STV0600
22 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600 18 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600
23 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express 19 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express
@@ -120,9 +116,6 @@ static int vv6410_init(struct sd *sd)
120 for (i = 0; i < ARRAY_SIZE(stv_bridge_init); i++) 116 for (i = 0; i < ARRAY_SIZE(stv_bridge_init); i++)
121 stv06xx_write_bridge(sd, stv_bridge_init[i].addr, stv_bridge_init[i].data); 117 stv06xx_write_bridge(sd, stv_bridge_init[i].addr, stv_bridge_init[i].data);
122 118
123 if (err < 0)
124 return err;
125
126 err = stv06xx_write_sensor_bytes(sd, (u8 *) vv6410_sensor_init, 119 err = stv06xx_write_sensor_bytes(sd, (u8 *) vv6410_sensor_init,
127 ARRAY_SIZE(vv6410_sensor_init)); 120 ARRAY_SIZE(vv6410_sensor_init));
128 return (err < 0) ? err : 0; 121 return (err < 0) ? err : 0;
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.h b/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.h
index 53e67b40ca05..e8598893791e 100644
--- a/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.h
+++ b/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.h
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * P/N 861037: Sensor HDCS1000 ASIC STV0600 17 * P/N 861037: Sensor HDCS1000 ASIC STV0600
22 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600 18 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600
23 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express 19 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express
diff --git a/drivers/media/usb/gspca/sunplus.c b/drivers/media/usb/gspca/sunplus.c
index 38dc9e7aa313..8c2785aea3cd 100644
--- a/drivers/media/usb/gspca/sunplus.c
+++ b/drivers/media/usb/gspca/sunplus.c
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 16 */
21 17
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/t613.c b/drivers/media/usb/gspca/t613.c
index bb52fc1fe598..42667710af92 100644
--- a/drivers/media/usb/gspca/t613.c
+++ b/drivers/media/usb/gspca/t613.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 *Notes: * t613 + tas5130A 16 *Notes: * t613 + tas5130A
21 * * Focus to light do not balance well as in win. 17 * * Focus to light do not balance well as in win.
22 * Quality in win is not good, but its kinda better. 18 * Quality in win is not good, but its kinda better.
diff --git a/drivers/media/usb/gspca/tv8532.c b/drivers/media/usb/gspca/tv8532.c
index d497ba38af0d..bc2720e9cc4f 100644
--- a/drivers/media/usb/gspca/tv8532.c
+++ b/drivers/media/usb/gspca/tv8532.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21#define MODULE_NAME "tv8532" 17#define MODULE_NAME "tv8532"
22 18
diff --git a/drivers/media/usb/gspca/vc032x.c b/drivers/media/usb/gspca/vc032x.c
index b4efb2fb36fa..b935febf7146 100644
--- a/drivers/media/usb/gspca/vc032x.c
+++ b/drivers/media/usb/gspca/vc032x.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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 */ 17 */
22 18
23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/vicam.c b/drivers/media/usb/gspca/vicam.c
index 8860510c2f9c..554b90ef2200 100644
--- a/drivers/media/usb/gspca/vicam.c
+++ b/drivers/media/usb/gspca/vicam.c
@@ -20,10 +20,6 @@
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details. 22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 */ 23 */
28 24
29#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 25#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/w996Xcf.c b/drivers/media/usb/gspca/w996Xcf.c
index 896f1b2b9179..728d2322c433 100644
--- a/drivers/media/usb/gspca/w996Xcf.c
+++ b/drivers/media/usb/gspca/w996Xcf.c
@@ -18,10 +18,6 @@
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */ 21 */
26 22
27/* Note this is not a stand alone driver, it gets included in ov519.c, this 23/* Note this is not a stand alone driver, it gets included in ov519.c, this
diff --git a/drivers/media/usb/gspca/xirlink_cit.c b/drivers/media/usb/gspca/xirlink_cit.c
index d5ed9d36ce25..b600ea6460d3 100644
--- a/drivers/media/usb/gspca/xirlink_cit.c
+++ b/drivers/media/usb/gspca/xirlink_cit.c
@@ -21,10 +21,6 @@
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details. 22 * GNU General Public License for more details.
23 * 23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 *
28 */ 24 */
29 25
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 26#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/gspca/zc3xx.c b/drivers/media/usb/gspca/zc3xx.c
index d5d8c7e81762..e2d486bd8c28 100644
--- a/drivers/media/usb/gspca/zc3xx.c
+++ b/drivers/media/usb/gspca/zc3xx.c
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-audio.c b/drivers/media/usb/pvrusb2/pvrusb2-audio.c
index 3bac50a248d4..356afa250cd6 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-audio.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-audio.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#include "pvrusb2-audio.h" 18#include "pvrusb2-audio.h"
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-audio.h b/drivers/media/usb/pvrusb2/pvrusb2-audio.h
index 27cefb5cb170..4f3898473165 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-audio.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-audio.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#ifndef __PVRUSB2_AUDIO_H 18#ifndef __PVRUSB2_AUDIO_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-context.c b/drivers/media/usb/pvrusb2/pvrusb2-context.c
index c45f30715dcd..d9e8481e9e28 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-context.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-context.c
@@ -11,10 +11,6 @@
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 */ 14 */
19 15
20#include "pvrusb2-context.h" 16#include "pvrusb2-context.h"
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-context.h b/drivers/media/usb/pvrusb2/pvrusb2-context.h
index 1c1d442d9ea3..13e00c529611 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-context.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-context.h
@@ -11,10 +11,6 @@
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 */ 14 */
19#ifndef __PVRUSB2_CONTEXT_H 15#ifndef __PVRUSB2_CONTEXT_H
20#define __PVRUSB2_CONTEXT_H 16#define __PVRUSB2_CONTEXT_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-cs53l32a.c b/drivers/media/usb/pvrusb2/pvrusb2-cs53l32a.c
index 7f29a0464f36..679f3ff3b0a5 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-cs53l32a.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-cs53l32a.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22/* 18/*
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-cs53l32a.h b/drivers/media/usb/pvrusb2/pvrusb2-cs53l32a.h
index 86c17bee56f9..90dfb8b3f3e5 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-cs53l32a.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-cs53l32a.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#ifndef __PVRUSB2_CS53L32A_H 18#ifndef __PVRUSB2_CS53L32A_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-ctrl.c b/drivers/media/usb/pvrusb2/pvrusb2-ctrl.c
index 958db170a048..5f4ba84e5557 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-ctrl.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-ctrl.c
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20 16
21#include "pvrusb2-ctrl.h" 17#include "pvrusb2-ctrl.h"
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-ctrl.h b/drivers/media/usb/pvrusb2/pvrusb2-ctrl.h
index c175571868a3..4b9152e36fe4 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-ctrl.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-ctrl.h
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20#ifndef __PVRUSB2_CTRL_H 16#ifndef __PVRUSB2_CTRL_H
21#define __PVRUSB2_CTRL_H 17#define __PVRUSB2_CTRL_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-cx2584x-v4l.c b/drivers/media/usb/pvrusb2/pvrusb2-cx2584x-v4l.c
index 30eef97ef2ef..242b213b7599 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-cx2584x-v4l.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-cx2584x-v4l.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22/* 18/*
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-cx2584x-v4l.h b/drivers/media/usb/pvrusb2/pvrusb2-cx2584x-v4l.h
index 2eed7b7ee25e..dfddc88750d9 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-cx2584x-v4l.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-cx2584x-v4l.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#ifndef __PVRUSB2_CX2584X_V4L_H 18#ifndef __PVRUSB2_CX2584X_V4L_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-debug.h b/drivers/media/usb/pvrusb2/pvrusb2-debug.h
index 4ef2ebcd97a5..5cd16292e2fa 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-debug.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-debug.h
@@ -11,10 +11,6 @@
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 */ 14 */
19#ifndef __PVRUSB2_DEBUG_H 15#ifndef __PVRUSB2_DEBUG_H
20#define __PVRUSB2_DEBUG_H 16#define __PVRUSB2_DEBUG_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-debugifc.c b/drivers/media/usb/pvrusb2/pvrusb2-debugifc.c
index 58ec706ebdb3..d3f3bd96885f 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-debugifc.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-debugifc.c
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20 16
21#include <linux/string.h> 17#include <linux/string.h>
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-debugifc.h b/drivers/media/usb/pvrusb2/pvrusb2-debugifc.h
index a8dfc55f136f..fcaaa8dd68b8 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-debugifc.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-debugifc.h
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20#ifndef __PVRUSB2_DEBUGIFC_H 16#ifndef __PVRUSB2_DEBUGIFC_H
21#define __PVRUSB2_DEBUGIFC_H 17#define __PVRUSB2_DEBUGIFC_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-devattr.c b/drivers/media/usb/pvrusb2/pvrusb2-devattr.c
index 06c4c3dabcde..51b3312eaea1 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-devattr.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-devattr.c
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20 16
21/* 17/*
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-devattr.h b/drivers/media/usb/pvrusb2/pvrusb2-devattr.h
index 5aeefb6a991f..c1e7d4822cd1 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-devattr.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-devattr.h
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20#ifndef __PVRUSB2_DEVATTR_H 16#ifndef __PVRUSB2_DEVATTR_H
21#define __PVRUSB2_DEVATTR_H 17#define __PVRUSB2_DEVATTR_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-dvb.c b/drivers/media/usb/pvrusb2/pvrusb2-dvb.c
index 8c95793433e7..56c750535ee7 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-dvb.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-dvb.c
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20 16
21#include <linux/kthread.h> 17#include <linux/kthread.h>
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-eeprom.c b/drivers/media/usb/pvrusb2/pvrusb2-eeprom.c
index 276b17fb9aad..4af2fb5c85d5 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-eeprom.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-eeprom.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#include <linux/slab.h> 18#include <linux/slab.h>
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-eeprom.h b/drivers/media/usb/pvrusb2/pvrusb2-eeprom.h
index f1e33c807f46..1d81cac30f3d 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-eeprom.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-eeprom.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#ifndef __PVRUSB2_EEPROM_H 18#ifndef __PVRUSB2_EEPROM_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-encoder.c b/drivers/media/usb/pvrusb2/pvrusb2-encoder.c
index f0483621d2a3..ca637074fa1f 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-encoder.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-encoder.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#include <linux/device.h> // for linux/firmware.h 18#include <linux/device.h> // for linux/firmware.h
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-encoder.h b/drivers/media/usb/pvrusb2/pvrusb2-encoder.h
index a2bfb48f1ecd..10d7f0b48264 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-encoder.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-encoder.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#ifndef __PVRUSB2_ENCODER_H 18#ifndef __PVRUSB2_ENCODER_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-fx2-cmd.h b/drivers/media/usb/pvrusb2/pvrusb2-fx2-cmd.h
index 06a15a68bcfd..0a01de4e54db 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-fx2-cmd.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-fx2-cmd.h
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20 16
21#ifndef _PVRUSB2_FX2_CMD_H_ 17#ifndef _PVRUSB2_FX2_CMD_H_
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/usb/pvrusb2/pvrusb2-hdw-internal.h
index 23473a21319c..7a824196d5fa 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw-internal.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw-internal.h
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20#ifndef __PVRUSB2_HDW_INTERNAL_H 16#ifndef __PVRUSB2_HDW_INTERNAL_H
21#define __PVRUSB2_HDW_INTERNAL_H 17#define __PVRUSB2_HDW_INTERNAL_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
index e3ed8ffee9f7..ad5b25b89699 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20 16
21#include <linux/errno.h> 17#include <linux/errno.h>
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.h b/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
index a82a00dd7329..25648add77e5 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20#ifndef __PVRUSB2_HDW_H 16#ifndef __PVRUSB2_HDW_H
21#define __PVRUSB2_HDW_H 17#define __PVRUSB2_HDW_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
index cc63e5f4c26c..f727b54a53c6 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20 16
21#include <linux/i2c.h> 17#include <linux/i2c.h>
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.h b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.h
index a10a3e8e9345..1c44dee7fd69 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.h
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20#ifndef __PVRUSB2_I2C_CORE_H 16#ifndef __PVRUSB2_I2C_CORE_H
21#define __PVRUSB2_I2C_CORE_H 17#define __PVRUSB2_I2C_CORE_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-io.c b/drivers/media/usb/pvrusb2/pvrusb2-io.c
index e3103ecd4828..6d153fc23ec2 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-io.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-io.c
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20 16
21#include "pvrusb2-io.h" 17#include "pvrusb2-io.h"
@@ -37,13 +33,13 @@ static const char *pvr2_buffer_state_decode(enum pvr2_buffer_state);
37 if ((bp)->signature != BUFFER_SIG) { \ 33 if ((bp)->signature != BUFFER_SIG) { \
38 pvr2_trace(PVR2_TRACE_ERROR_LEGS, \ 34 pvr2_trace(PVR2_TRACE_ERROR_LEGS, \
39 "Buffer %p is bad at %s:%d", \ 35 "Buffer %p is bad at %s:%d", \
40 (bp),__FILE__,__LINE__); \ 36 (bp), __FILE__, __LINE__); \
41 pvr2_buffer_describe(bp,"BadSig"); \ 37 pvr2_buffer_describe(bp, "BadSig"); \
42 BUG(); \ 38 BUG(); \
43 } \ 39 } \
44} while (0) 40} while (0)
45#else 41#else
46#define BUFFER_CHECK(bp) do {} while(0) 42#define BUFFER_CHECK(bp) do {} while (0)
47#endif 43#endif
48 44
49struct pvr2_stream { 45struct pvr2_stream {
@@ -110,7 +106,7 @@ static const char *pvr2_buffer_state_decode(enum pvr2_buffer_state st)
110} 106}
111 107
112#ifdef SANITY_CHECK_BUFFERS 108#ifdef SANITY_CHECK_BUFFERS
113static void pvr2_buffer_describe(struct pvr2_buffer *bp,const char *msg) 109static void pvr2_buffer_describe(struct pvr2_buffer *bp, const char *msg)
114{ 110{
115 pvr2_trace(PVR2_TRACE_INFO, 111 pvr2_trace(PVR2_TRACE_INFO,
116 "buffer%s%s %p state=%s id=%d status=%d stream=%p purb=%p sig=0x%x", 112 "buffer%s%s %p state=%s id=%d status=%d stream=%p purb=%p sig=0x%x",
@@ -156,7 +152,7 @@ static void pvr2_buffer_remove(struct pvr2_buffer *bp)
156 (*bcnt) -= ccnt; 152 (*bcnt) -= ccnt;
157 pvr2_trace(PVR2_TRACE_BUF_FLOW, 153 pvr2_trace(PVR2_TRACE_BUF_FLOW,
158 "/*---TRACE_FLOW---*/ bufferPool %8s dec cap=%07d cnt=%02d", 154 "/*---TRACE_FLOW---*/ bufferPool %8s dec cap=%07d cnt=%02d",
159 pvr2_buffer_state_decode(bp->state),*bcnt,*cnt); 155 pvr2_buffer_state_decode(bp->state), *bcnt, *cnt);
160 bp->state = pvr2_buffer_state_none; 156 bp->state = pvr2_buffer_state_none;
161} 157}
162 158
@@ -171,9 +167,9 @@ static void pvr2_buffer_set_none(struct pvr2_buffer *bp)
171 bp, 167 bp,
172 pvr2_buffer_state_decode(bp->state), 168 pvr2_buffer_state_decode(bp->state),
173 pvr2_buffer_state_decode(pvr2_buffer_state_none)); 169 pvr2_buffer_state_decode(pvr2_buffer_state_none));
174 spin_lock_irqsave(&sp->list_lock,irq_flags); 170 spin_lock_irqsave(&sp->list_lock, irq_flags);
175 pvr2_buffer_remove(bp); 171 pvr2_buffer_remove(bp);
176 spin_unlock_irqrestore(&sp->list_lock,irq_flags); 172 spin_unlock_irqrestore(&sp->list_lock, irq_flags);
177} 173}
178 174
179static int pvr2_buffer_set_ready(struct pvr2_buffer *bp) 175static int pvr2_buffer_set_ready(struct pvr2_buffer *bp)
@@ -188,18 +184,18 @@ static int pvr2_buffer_set_ready(struct pvr2_buffer *bp)
188 bp, 184 bp,
189 pvr2_buffer_state_decode(bp->state), 185 pvr2_buffer_state_decode(bp->state),
190 pvr2_buffer_state_decode(pvr2_buffer_state_ready)); 186 pvr2_buffer_state_decode(pvr2_buffer_state_ready));
191 spin_lock_irqsave(&sp->list_lock,irq_flags); 187 spin_lock_irqsave(&sp->list_lock, irq_flags);
192 fl = (sp->r_count == 0); 188 fl = (sp->r_count == 0);
193 pvr2_buffer_remove(bp); 189 pvr2_buffer_remove(bp);
194 list_add_tail(&bp->list_overhead,&sp->ready_list); 190 list_add_tail(&bp->list_overhead, &sp->ready_list);
195 bp->state = pvr2_buffer_state_ready; 191 bp->state = pvr2_buffer_state_ready;
196 (sp->r_count)++; 192 (sp->r_count)++;
197 sp->r_bcount += bp->used_count; 193 sp->r_bcount += bp->used_count;
198 pvr2_trace(PVR2_TRACE_BUF_FLOW, 194 pvr2_trace(PVR2_TRACE_BUF_FLOW,
199 "/*---TRACE_FLOW---*/ bufferPool %8s inc cap=%07d cnt=%02d", 195 "/*---TRACE_FLOW---*/ bufferPool %8s inc cap=%07d cnt=%02d",
200 pvr2_buffer_state_decode(bp->state), 196 pvr2_buffer_state_decode(bp->state),
201 sp->r_bcount,sp->r_count); 197 sp->r_bcount, sp->r_count);
202 spin_unlock_irqrestore(&sp->list_lock,irq_flags); 198 spin_unlock_irqrestore(&sp->list_lock, irq_flags);
203 return fl; 199 return fl;
204} 200}
205 201
@@ -214,17 +210,17 @@ static void pvr2_buffer_set_idle(struct pvr2_buffer *bp)
214 bp, 210 bp,
215 pvr2_buffer_state_decode(bp->state), 211 pvr2_buffer_state_decode(bp->state),
216 pvr2_buffer_state_decode(pvr2_buffer_state_idle)); 212 pvr2_buffer_state_decode(pvr2_buffer_state_idle));
217 spin_lock_irqsave(&sp->list_lock,irq_flags); 213 spin_lock_irqsave(&sp->list_lock, irq_flags);
218 pvr2_buffer_remove(bp); 214 pvr2_buffer_remove(bp);
219 list_add_tail(&bp->list_overhead,&sp->idle_list); 215 list_add_tail(&bp->list_overhead, &sp->idle_list);
220 bp->state = pvr2_buffer_state_idle; 216 bp->state = pvr2_buffer_state_idle;
221 (sp->i_count)++; 217 (sp->i_count)++;
222 sp->i_bcount += bp->max_count; 218 sp->i_bcount += bp->max_count;
223 pvr2_trace(PVR2_TRACE_BUF_FLOW, 219 pvr2_trace(PVR2_TRACE_BUF_FLOW,
224 "/*---TRACE_FLOW---*/ bufferPool %8s inc cap=%07d cnt=%02d", 220 "/*---TRACE_FLOW---*/ bufferPool %8s inc cap=%07d cnt=%02d",
225 pvr2_buffer_state_decode(bp->state), 221 pvr2_buffer_state_decode(bp->state),
226 sp->i_bcount,sp->i_count); 222 sp->i_bcount, sp->i_count);
227 spin_unlock_irqrestore(&sp->list_lock,irq_flags); 223 spin_unlock_irqrestore(&sp->list_lock, irq_flags);
228} 224}
229 225
230static void pvr2_buffer_set_queued(struct pvr2_buffer *bp) 226static void pvr2_buffer_set_queued(struct pvr2_buffer *bp)
@@ -238,17 +234,17 @@ static void pvr2_buffer_set_queued(struct pvr2_buffer *bp)
238 bp, 234 bp,
239 pvr2_buffer_state_decode(bp->state), 235 pvr2_buffer_state_decode(bp->state),
240 pvr2_buffer_state_decode(pvr2_buffer_state_queued)); 236 pvr2_buffer_state_decode(pvr2_buffer_state_queued));
241 spin_lock_irqsave(&sp->list_lock,irq_flags); 237 spin_lock_irqsave(&sp->list_lock, irq_flags);
242 pvr2_buffer_remove(bp); 238 pvr2_buffer_remove(bp);
243 list_add_tail(&bp->list_overhead,&sp->queued_list); 239 list_add_tail(&bp->list_overhead, &sp->queued_list);
244 bp->state = pvr2_buffer_state_queued; 240 bp->state = pvr2_buffer_state_queued;
245 (sp->q_count)++; 241 (sp->q_count)++;
246 sp->q_bcount += bp->max_count; 242 sp->q_bcount += bp->max_count;
247 pvr2_trace(PVR2_TRACE_BUF_FLOW, 243 pvr2_trace(PVR2_TRACE_BUF_FLOW,
248 "/*---TRACE_FLOW---*/ bufferPool %8s inc cap=%07d cnt=%02d", 244 "/*---TRACE_FLOW---*/ bufferPool %8s inc cap=%07d cnt=%02d",
249 pvr2_buffer_state_decode(bp->state), 245 pvr2_buffer_state_decode(bp->state),
250 sp->q_bcount,sp->q_count); 246 sp->q_bcount, sp->q_count);
251 spin_unlock_irqrestore(&sp->list_lock,irq_flags); 247 spin_unlock_irqrestore(&sp->list_lock, irq_flags);
252} 248}
253 249
254static void pvr2_buffer_wipe(struct pvr2_buffer *bp) 250static void pvr2_buffer_wipe(struct pvr2_buffer *bp)
@@ -262,18 +258,18 @@ static int pvr2_buffer_init(struct pvr2_buffer *bp,
262 struct pvr2_stream *sp, 258 struct pvr2_stream *sp,
263 unsigned int id) 259 unsigned int id)
264{ 260{
265 memset(bp,0,sizeof(*bp)); 261 memset(bp, 0, sizeof(*bp));
266 bp->signature = BUFFER_SIG; 262 bp->signature = BUFFER_SIG;
267 bp->id = id; 263 bp->id = id;
268 pvr2_trace(PVR2_TRACE_BUF_POOL, 264 pvr2_trace(PVR2_TRACE_BUF_POOL,
269 "/*---TRACE_FLOW---*/ bufferInit %p stream=%p",bp,sp); 265 "/*---TRACE_FLOW---*/ bufferInit %p stream=%p", bp, sp);
270 bp->stream = sp; 266 bp->stream = sp;
271 bp->state = pvr2_buffer_state_none; 267 bp->state = pvr2_buffer_state_none;
272 INIT_LIST_HEAD(&bp->list_overhead); 268 INIT_LIST_HEAD(&bp->list_overhead);
273 bp->purb = usb_alloc_urb(0,GFP_KERNEL); 269 bp->purb = usb_alloc_urb(0, GFP_KERNEL);
274 if (! bp->purb) return -ENOMEM; 270 if (! bp->purb) return -ENOMEM;
275#ifdef SANITY_CHECK_BUFFERS 271#ifdef SANITY_CHECK_BUFFERS
276 pvr2_buffer_describe(bp,"create"); 272 pvr2_buffer_describe(bp, "create");
277#endif 273#endif
278 return 0; 274 return 0;
279} 275}
@@ -281,7 +277,7 @@ static int pvr2_buffer_init(struct pvr2_buffer *bp,
281static void pvr2_buffer_done(struct pvr2_buffer *bp) 277static void pvr2_buffer_done(struct pvr2_buffer *bp)
282{ 278{
283#ifdef SANITY_CHECK_BUFFERS 279#ifdef SANITY_CHECK_BUFFERS
284 pvr2_buffer_describe(bp,"delete"); 280 pvr2_buffer_describe(bp, "delete");
285#endif 281#endif
286 pvr2_buffer_wipe(bp); 282 pvr2_buffer_wipe(bp);
287 pvr2_buffer_set_none(bp); 283 pvr2_buffer_set_none(bp);
@@ -292,7 +288,7 @@ static void pvr2_buffer_done(struct pvr2_buffer *bp)
292 bp); 288 bp);
293} 289}
294 290
295static int pvr2_stream_buffer_count(struct pvr2_stream *sp,unsigned int cnt) 291static int pvr2_stream_buffer_count(struct pvr2_stream *sp, unsigned int cnt)
296{ 292{
297 int ret; 293 int ret;
298 unsigned int scnt; 294 unsigned int scnt;
@@ -312,10 +308,11 @@ static int pvr2_stream_buffer_count(struct pvr2_stream *sp,unsigned int cnt)
312 if (cnt > sp->buffer_total_count) { 308 if (cnt > sp->buffer_total_count) {
313 if (scnt > sp->buffer_slot_count) { 309 if (scnt > sp->buffer_slot_count) {
314 struct pvr2_buffer **nb; 310 struct pvr2_buffer **nb;
315 nb = kmalloc(scnt * sizeof(*nb),GFP_KERNEL); 311
312 nb = kmalloc_array(scnt, sizeof(*nb), GFP_KERNEL);
316 if (!nb) return -ENOMEM; 313 if (!nb) return -ENOMEM;
317 if (sp->buffer_slot_count) { 314 if (sp->buffer_slot_count) {
318 memcpy(nb,sp->buffers, 315 memcpy(nb, sp->buffers,
319 sp->buffer_slot_count * sizeof(*nb)); 316 sp->buffer_slot_count * sizeof(*nb));
320 kfree(sp->buffers); 317 kfree(sp->buffers);
321 } 318 }
@@ -324,9 +321,9 @@ static int pvr2_stream_buffer_count(struct pvr2_stream *sp,unsigned int cnt)
324 } 321 }
325 while (sp->buffer_total_count < cnt) { 322 while (sp->buffer_total_count < cnt) {
326 struct pvr2_buffer *bp; 323 struct pvr2_buffer *bp;
327 bp = kmalloc(sizeof(*bp),GFP_KERNEL); 324 bp = kmalloc(sizeof(*bp), GFP_KERNEL);
328 if (!bp) return -ENOMEM; 325 if (!bp) return -ENOMEM;
329 ret = pvr2_buffer_init(bp,sp,sp->buffer_total_count); 326 ret = pvr2_buffer_init(bp, sp, sp->buffer_total_count);
330 if (ret) { 327 if (ret) {
331 kfree(bp); 328 kfree(bp);
332 return -ENOMEM; 329 return -ENOMEM;
@@ -369,10 +366,10 @@ static int pvr2_stream_achieve_buffer_count(struct pvr2_stream *sp)
369 366
370 pvr2_trace(PVR2_TRACE_BUF_POOL, 367 pvr2_trace(PVR2_TRACE_BUF_POOL,
371 "/*---TRACE_FLOW---*/ poolCheck stream=%p cur=%d tgt=%d", 368 "/*---TRACE_FLOW---*/ poolCheck stream=%p cur=%d tgt=%d",
372 sp,sp->buffer_total_count,sp->buffer_target_count); 369 sp, sp->buffer_total_count, sp->buffer_target_count);
373 370
374 if (sp->buffer_total_count < sp->buffer_target_count) { 371 if (sp->buffer_total_count < sp->buffer_target_count) {
375 return pvr2_stream_buffer_count(sp,sp->buffer_target_count); 372 return pvr2_stream_buffer_count(sp, sp->buffer_target_count);
376 } 373 }
377 374
378 cnt = 0; 375 cnt = 0;
@@ -382,7 +379,7 @@ static int pvr2_stream_achieve_buffer_count(struct pvr2_stream *sp)
382 cnt++; 379 cnt++;
383 } 380 }
384 if (cnt) { 381 if (cnt) {
385 pvr2_stream_buffer_count(sp,sp->buffer_total_count - cnt); 382 pvr2_stream_buffer_count(sp, sp->buffer_total_count - cnt);
386 } 383 }
387 384
388 return 0; 385 return 0;
@@ -393,7 +390,7 @@ static void pvr2_stream_internal_flush(struct pvr2_stream *sp)
393 struct list_head *lp; 390 struct list_head *lp;
394 struct pvr2_buffer *bp1; 391 struct pvr2_buffer *bp1;
395 while ((lp = sp->queued_list.next) != &sp->queued_list) { 392 while ((lp = sp->queued_list.next) != &sp->queued_list) {
396 bp1 = list_entry(lp,struct pvr2_buffer,list_overhead); 393 bp1 = list_entry(lp, struct pvr2_buffer, list_overhead);
397 pvr2_buffer_wipe(bp1); 394 pvr2_buffer_wipe(bp1);
398 /* At this point, we should be guaranteed that no 395 /* At this point, we should be guaranteed that no
399 completion callback may happen on this buffer. But it's 396 completion callback may happen on this buffer. But it's
@@ -421,7 +418,7 @@ static void pvr2_stream_done(struct pvr2_stream *sp)
421{ 418{
422 mutex_lock(&sp->mutex); do { 419 mutex_lock(&sp->mutex); do {
423 pvr2_stream_internal_flush(sp); 420 pvr2_stream_internal_flush(sp);
424 pvr2_stream_buffer_count(sp,0); 421 pvr2_stream_buffer_count(sp, 0);
425 } while (0); mutex_unlock(&sp->mutex); 422 } while (0); mutex_unlock(&sp->mutex);
426} 423}
427 424
@@ -436,8 +433,8 @@ static void buffer_complete(struct urb *urb)
436 bp->status = 0; 433 bp->status = 0;
437 pvr2_trace(PVR2_TRACE_BUF_FLOW, 434 pvr2_trace(PVR2_TRACE_BUF_FLOW,
438 "/*---TRACE_FLOW---*/ bufferComplete %p stat=%d cnt=%d", 435 "/*---TRACE_FLOW---*/ bufferComplete %p stat=%d cnt=%d",
439 bp,urb->status,urb->actual_length); 436 bp, urb->status, urb->actual_length);
440 spin_lock_irqsave(&sp->list_lock,irq_flags); 437 spin_lock_irqsave(&sp->list_lock, irq_flags);
441 if ((!(urb->status)) || 438 if ((!(urb->status)) ||
442 (urb->status == -ENOENT) || 439 (urb->status == -ENOENT) ||
443 (urb->status == -ECONNRESET) || 440 (urb->status == -ECONNRESET) ||
@@ -458,12 +455,12 @@ static void buffer_complete(struct urb *urb)
458 (sp->buffers_failed)++; 455 (sp->buffers_failed)++;
459 pvr2_trace(PVR2_TRACE_TOLERANCE, 456 pvr2_trace(PVR2_TRACE_TOLERANCE,
460 "stream %p ignoring error %d - fail count increased to %u", 457 "stream %p ignoring error %d - fail count increased to %u",
461 sp,urb->status,sp->fail_count); 458 sp, urb->status, sp->fail_count);
462 } else { 459 } else {
463 (sp->buffers_failed)++; 460 (sp->buffers_failed)++;
464 bp->status = urb->status; 461 bp->status = urb->status;
465 } 462 }
466 spin_unlock_irqrestore(&sp->list_lock,irq_flags); 463 spin_unlock_irqrestore(&sp->list_lock, irq_flags);
467 pvr2_buffer_set_ready(bp); 464 pvr2_buffer_set_ready(bp);
468 if (sp->callback_func) { 465 if (sp->callback_func) {
469 sp->callback_func(sp->callback_data); 466 sp->callback_func(sp->callback_data);
@@ -473,9 +470,9 @@ static void buffer_complete(struct urb *urb)
473struct pvr2_stream *pvr2_stream_create(void) 470struct pvr2_stream *pvr2_stream_create(void)
474{ 471{
475 struct pvr2_stream *sp; 472 struct pvr2_stream *sp;
476 sp = kzalloc(sizeof(*sp),GFP_KERNEL); 473 sp = kzalloc(sizeof(*sp), GFP_KERNEL);
477 if (!sp) return sp; 474 if (!sp) return sp;
478 pvr2_trace(PVR2_TRACE_INIT,"pvr2_stream_create: sp=%p",sp); 475 pvr2_trace(PVR2_TRACE_INIT, "pvr2_stream_create: sp=%p", sp);
479 pvr2_stream_init(sp); 476 pvr2_stream_init(sp);
480 return sp; 477 return sp;
481} 478}
@@ -483,7 +480,7 @@ struct pvr2_stream *pvr2_stream_create(void)
483void pvr2_stream_destroy(struct pvr2_stream *sp) 480void pvr2_stream_destroy(struct pvr2_stream *sp)
484{ 481{
485 if (!sp) return; 482 if (!sp) return;
486 pvr2_trace(PVR2_TRACE_INIT,"pvr2_stream_destroy: sp=%p",sp); 483 pvr2_trace(PVR2_TRACE_INIT, "pvr2_stream_destroy: sp=%p", sp);
487 pvr2_stream_done(sp); 484 pvr2_stream_done(sp);
488 kfree(sp); 485 kfree(sp);
489} 486}
@@ -498,7 +495,7 @@ void pvr2_stream_setup(struct pvr2_stream *sp,
498 sp->dev = dev; 495 sp->dev = dev;
499 sp->endpoint = endpoint; 496 sp->endpoint = endpoint;
500 sp->fail_tolerance = tolerance; 497 sp->fail_tolerance = tolerance;
501 } while(0); mutex_unlock(&sp->mutex); 498 } while (0); mutex_unlock(&sp->mutex);
502} 499}
503 500
504void pvr2_stream_set_callback(struct pvr2_stream *sp, 501void pvr2_stream_set_callback(struct pvr2_stream *sp,
@@ -508,11 +505,11 @@ void pvr2_stream_set_callback(struct pvr2_stream *sp,
508 unsigned long irq_flags; 505 unsigned long irq_flags;
509 mutex_lock(&sp->mutex); 506 mutex_lock(&sp->mutex);
510 do { 507 do {
511 spin_lock_irqsave(&sp->list_lock,irq_flags); 508 spin_lock_irqsave(&sp->list_lock, irq_flags);
512 sp->callback_data = data; 509 sp->callback_data = data;
513 sp->callback_func = func; 510 sp->callback_func = func;
514 spin_unlock_irqrestore(&sp->list_lock,irq_flags); 511 spin_unlock_irqrestore(&sp->list_lock, irq_flags);
515 } while(0); 512 } while (0);
516 mutex_unlock(&sp->mutex); 513 mutex_unlock(&sp->mutex);
517} 514}
518 515
@@ -521,7 +518,7 @@ void pvr2_stream_get_stats(struct pvr2_stream *sp,
521 int zero_counts) 518 int zero_counts)
522{ 519{
523 unsigned long irq_flags; 520 unsigned long irq_flags;
524 spin_lock_irqsave(&sp->list_lock,irq_flags); 521 spin_lock_irqsave(&sp->list_lock, irq_flags);
525 if (stats) { 522 if (stats) {
526 stats->buffers_in_queue = sp->q_count; 523 stats->buffers_in_queue = sp->q_count;
527 stats->buffers_in_idle = sp->i_count; 524 stats->buffers_in_idle = sp->i_count;
@@ -535,7 +532,7 @@ void pvr2_stream_get_stats(struct pvr2_stream *sp,
535 sp->buffers_failed = 0; 532 sp->buffers_failed = 0;
536 sp->bytes_processed = 0; 533 sp->bytes_processed = 0;
537 } 534 }
538 spin_unlock_irqrestore(&sp->list_lock,irq_flags); 535 spin_unlock_irqrestore(&sp->list_lock, irq_flags);
539} 536}
540 537
541/* Query / set the nominal buffer count */ 538/* Query / set the nominal buffer count */
@@ -544,7 +541,7 @@ int pvr2_stream_get_buffer_count(struct pvr2_stream *sp)
544 return sp->buffer_target_count; 541 return sp->buffer_target_count;
545} 542}
546 543
547int pvr2_stream_set_buffer_count(struct pvr2_stream *sp,unsigned int cnt) 544int pvr2_stream_set_buffer_count(struct pvr2_stream *sp, unsigned int cnt)
548{ 545{
549 int ret; 546 int ret;
550 if (sp->buffer_target_count == cnt) return 0; 547 if (sp->buffer_target_count == cnt) return 0;
@@ -552,7 +549,7 @@ int pvr2_stream_set_buffer_count(struct pvr2_stream *sp,unsigned int cnt)
552 do { 549 do {
553 sp->buffer_target_count = cnt; 550 sp->buffer_target_count = cnt;
554 ret = pvr2_stream_achieve_buffer_count(sp); 551 ret = pvr2_stream_achieve_buffer_count(sp);
555 } while(0); 552 } while (0);
556 mutex_unlock(&sp->mutex); 553 mutex_unlock(&sp->mutex);
557 return ret; 554 return ret;
558} 555}
@@ -561,17 +558,17 @@ struct pvr2_buffer *pvr2_stream_get_idle_buffer(struct pvr2_stream *sp)
561{ 558{
562 struct list_head *lp = sp->idle_list.next; 559 struct list_head *lp = sp->idle_list.next;
563 if (lp == &sp->idle_list) return NULL; 560 if (lp == &sp->idle_list) return NULL;
564 return list_entry(lp,struct pvr2_buffer,list_overhead); 561 return list_entry(lp, struct pvr2_buffer, list_overhead);
565} 562}
566 563
567struct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *sp) 564struct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *sp)
568{ 565{
569 struct list_head *lp = sp->ready_list.next; 566 struct list_head *lp = sp->ready_list.next;
570 if (lp == &sp->ready_list) return NULL; 567 if (lp == &sp->ready_list) return NULL;
571 return list_entry(lp,struct pvr2_buffer,list_overhead); 568 return list_entry(lp, struct pvr2_buffer, list_overhead);
572} 569}
573 570
574struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id) 571struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp, int id)
575{ 572{
576 if (id < 0) return NULL; 573 if (id < 0) return NULL;
577 if (id >= sp->buffer_total_count) return NULL; 574 if (id >= sp->buffer_total_count) return NULL;
@@ -595,7 +592,7 @@ void pvr2_stream_kill(struct pvr2_stream *sp)
595 if (sp->buffer_total_count != sp->buffer_target_count) { 592 if (sp->buffer_total_count != sp->buffer_target_count) {
596 pvr2_stream_achieve_buffer_count(sp); 593 pvr2_stream_achieve_buffer_count(sp);
597 } 594 }
598 } while(0); 595 } while (0);
599 mutex_unlock(&sp->mutex); 596 mutex_unlock(&sp->mutex);
600} 597}
601 598
@@ -629,18 +626,18 @@ int pvr2_buffer_queue(struct pvr2_buffer *bp)
629 usb_fill_bulk_urb(bp->purb, // struct urb *urb 626 usb_fill_bulk_urb(bp->purb, // struct urb *urb
630 sp->dev, // struct usb_device *dev 627 sp->dev, // struct usb_device *dev
631 // endpoint (below) 628 // endpoint (below)
632 usb_rcvbulkpipe(sp->dev,sp->endpoint), 629 usb_rcvbulkpipe(sp->dev, sp->endpoint),
633 bp->ptr, // void *transfer_buffer 630 bp->ptr, // void *transfer_buffer
634 bp->max_count, // int buffer_length 631 bp->max_count, // int buffer_length
635 buffer_complete, 632 buffer_complete,
636 bp); 633 bp);
637 usb_submit_urb(bp->purb,GFP_KERNEL); 634 usb_submit_urb(bp->purb, GFP_KERNEL);
638 } while(0); 635 } while (0);
639 mutex_unlock(&sp->mutex); 636 mutex_unlock(&sp->mutex);
640 return ret; 637 return ret;
641} 638}
642 639
643int pvr2_buffer_set_buffer(struct pvr2_buffer *bp,void *ptr,unsigned int cnt) 640int pvr2_buffer_set_buffer(struct pvr2_buffer *bp, void *ptr, unsigned int cnt)
644{ 641{
645 int ret = 0; 642 int ret = 0;
646 unsigned long irq_flags; 643 unsigned long irq_flags;
@@ -649,7 +646,7 @@ int pvr2_buffer_set_buffer(struct pvr2_buffer *bp,void *ptr,unsigned int cnt)
649 sp = bp->stream; 646 sp = bp->stream;
650 mutex_lock(&sp->mutex); 647 mutex_lock(&sp->mutex);
651 do { 648 do {
652 spin_lock_irqsave(&sp->list_lock,irq_flags); 649 spin_lock_irqsave(&sp->list_lock, irq_flags);
653 if (bp->state != pvr2_buffer_state_idle) { 650 if (bp->state != pvr2_buffer_state_idle) {
654 ret = -EPERM; 651 ret = -EPERM;
655 } else { 652 } else {
@@ -661,10 +658,10 @@ int pvr2_buffer_set_buffer(struct pvr2_buffer *bp,void *ptr,unsigned int cnt)
661 "/*---TRACE_FLOW---*/ bufferPool %8s cap cap=%07d cnt=%02d", 658 "/*---TRACE_FLOW---*/ bufferPool %8s cap cap=%07d cnt=%02d",
662 pvr2_buffer_state_decode( 659 pvr2_buffer_state_decode(
663 pvr2_buffer_state_idle), 660 pvr2_buffer_state_idle),
664 bp->stream->i_bcount,bp->stream->i_count); 661 bp->stream->i_bcount, bp->stream->i_count);
665 } 662 }
666 spin_unlock_irqrestore(&sp->list_lock,irq_flags); 663 spin_unlock_irqrestore(&sp->list_lock, irq_flags);
667 } while(0); 664 } while (0);
668 mutex_unlock(&sp->mutex); 665 mutex_unlock(&sp->mutex);
669 return ret; 666 return ret;
670} 667}
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-io.h b/drivers/media/usb/pvrusb2/pvrusb2-io.h
index 0c47c6a95ab2..e769aeb9d529 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-io.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-io.h
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20#ifndef __PVRUSB2_IO_H 16#ifndef __PVRUSB2_IO_H
21#define __PVRUSB2_IO_H 17#define __PVRUSB2_IO_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-ioread.c b/drivers/media/usb/pvrusb2/pvrusb2-ioread.c
index 3c7ca2c2c108..602097bdcf14 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-ioread.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-ioread.c
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20 16
21#include "pvrusb2-ioread.h" 17#include "pvrusb2-ioread.h"
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-ioread.h b/drivers/media/usb/pvrusb2/pvrusb2-ioread.h
index 0b1f0fbc3438..5827ea09c5e3 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-ioread.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-ioread.h
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20#ifndef __PVRUSB2_IOREAD_H 16#ifndef __PVRUSB2_IOREAD_H
21#define __PVRUSB2_IOREAD_H 17#define __PVRUSB2_IOREAD_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-main.c b/drivers/media/usb/pvrusb2/pvrusb2-main.c
index 86be902a0049..cbe2c3a22458 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-main.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-main.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#include <linux/kernel.h> 18#include <linux/kernel.h>
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-std.c b/drivers/media/usb/pvrusb2/pvrusb2-std.c
index cd7bc18a1ba2..21bb20dba82c 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-std.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-std.c
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20 16
21#include "pvrusb2-std.h" 17#include "pvrusb2-std.h"
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-std.h b/drivers/media/usb/pvrusb2/pvrusb2-std.h
index ed4ec0474429..b48304f41472 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-std.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-std.h
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20#ifndef __PVRUSB2_STD_H 16#ifndef __PVRUSB2_STD_H
21#define __PVRUSB2_STD_H 17#define __PVRUSB2_STD_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c b/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c
index d977976b8d91..7bc6d090358e 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20 16
21#include <linux/string.h> 17#include <linux/string.h>
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-sysfs.h b/drivers/media/usb/pvrusb2/pvrusb2-sysfs.h
index 6f0579e1e07b..431f4fd19015 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-sysfs.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-sysfs.h
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20#ifndef __PVRUSB2_SYSFS_H 16#ifndef __PVRUSB2_SYSFS_H
21#define __PVRUSB2_SYSFS_H 17#define __PVRUSB2_SYSFS_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-util.h b/drivers/media/usb/pvrusb2/pvrusb2-util.h
index 5465bf9cd73e..b03ca3ef1ba0 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-util.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-util.h
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20#ifndef __PVRUSB2_UTIL_H 16#ifndef __PVRUSB2_UTIL_H
21#define __PVRUSB2_UTIL_H 17#define __PVRUSB2_UTIL_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
index bbbe18d5275a..8f13c60198ed 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#include <linux/kernel.h> 18#include <linux/kernel.h>
@@ -1054,7 +1050,7 @@ static int pvr2_v4l2_open(struct file *file)
1054 pvr2_trace(PVR2_TRACE_STRUCT, 1050 pvr2_trace(PVR2_TRACE_STRUCT,
1055 "Destroying pvr_v4l2_fh id=%p (input mask error)", 1051 "Destroying pvr_v4l2_fh id=%p (input mask error)",
1056 fhp); 1052 fhp);
1057 1053 v4l2_fh_exit(&fhp->fh);
1058 kfree(fhp); 1054 kfree(fhp);
1059 return ret; 1055 return ret;
1060 } 1056 }
@@ -1071,6 +1067,7 @@ static int pvr2_v4l2_open(struct file *file)
1071 pvr2_trace(PVR2_TRACE_STRUCT, 1067 pvr2_trace(PVR2_TRACE_STRUCT,
1072 "Destroying pvr_v4l2_fh id=%p (input map failure)", 1068 "Destroying pvr_v4l2_fh id=%p (input map failure)",
1073 fhp); 1069 fhp);
1070 v4l2_fh_exit(&fhp->fh);
1074 kfree(fhp); 1071 kfree(fhp);
1075 return -ENOMEM; 1072 return -ENOMEM;
1076 } 1073 }
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.h b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.h
index e455c9515841..ec755ee8f86a 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.h
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */ 15 */
20#ifndef __PVRUSB2_V4L2_H 16#ifndef __PVRUSB2_V4L2_H
21#define __PVRUSB2_V4L2_H 17#define __PVRUSB2_V4L2_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-video-v4l.c b/drivers/media/usb/pvrusb2/pvrusb2-video-v4l.c
index 6fee367139aa..b68aec2124b2 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-video-v4l.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-video-v4l.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22/* 18/*
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-video-v4l.h b/drivers/media/usb/pvrusb2/pvrusb2-video-v4l.h
index dacf3ec7f9e1..fa33f20655f4 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-video-v4l.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-video-v4l.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#ifndef __PVRUSB2_VIDEO_V4L_H 18#ifndef __PVRUSB2_VIDEO_V4L_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-wm8775.c b/drivers/media/usb/pvrusb2/pvrusb2-wm8775.c
index 7993983de5a6..8f357f771ba7 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-wm8775.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-wm8775.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22/* 18/*
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-wm8775.h b/drivers/media/usb/pvrusb2/pvrusb2-wm8775.h
index a4ee12e28d5c..c4ac7c2701d0 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-wm8775.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-wm8775.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#ifndef __PVRUSB2_WM8775_H 18#ifndef __PVRUSB2_WM8775_H
diff --git a/drivers/media/usb/pvrusb2/pvrusb2.h b/drivers/media/usb/pvrusb2/pvrusb2.h
index 95f98a87abb3..955290ba2d54 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */ 16 */
21 17
22#ifndef __PVRUSB2_H 18#ifndef __PVRUSB2_H
diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
index f7bb78c1873c..a9d4484f7626 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -30,10 +30,6 @@
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of 30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details. 32 * GNU General Public License for more details.
33 *
34 * You should have received a copy of the GNU General Public License
35 * along with this program; if not, write to the Free Software
36 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
37 */ 33 */
38 34
39#include <linux/module.h> 35#include <linux/module.h>
diff --git a/drivers/media/usb/stk1160/Kconfig b/drivers/media/usb/stk1160/Kconfig
index 95584c15dc5a..22dff4f3b921 100644
--- a/drivers/media/usb/stk1160/Kconfig
+++ b/drivers/media/usb/stk1160/Kconfig
@@ -8,17 +8,9 @@ config VIDEO_STK1160_COMMON
8 To compile this driver as a module, choose M here: the 8 To compile this driver as a module, choose M here: the
9 module will be called stk1160 9 module will be called stk1160
10 10
11config VIDEO_STK1160_AC97
12 bool "STK1160 AC97 codec support"
13 depends on VIDEO_STK1160_COMMON && SND
14
15 ---help---
16 Enables AC97 codec support for stk1160 driver.
17
18config VIDEO_STK1160 11config VIDEO_STK1160
19 tristate 12 tristate
20 depends on (!VIDEO_STK1160_AC97 || (SND='n') || SND) && VIDEO_STK1160_COMMON 13 depends on VIDEO_STK1160_COMMON
21 default y 14 default y
22 select VIDEOBUF2_VMALLOC 15 select VIDEOBUF2_VMALLOC
23 select VIDEO_SAA711X 16 select VIDEO_SAA711X
24 select SND_AC97_CODEC if SND
diff --git a/drivers/media/usb/stk1160/Makefile b/drivers/media/usb/stk1160/Makefile
index dfe3e90ff392..42d05463b353 100644
--- a/drivers/media/usb/stk1160/Makefile
+++ b/drivers/media/usb/stk1160/Makefile
@@ -1,10 +1,8 @@
1obj-stk1160-ac97-$(CONFIG_VIDEO_STK1160_AC97) := stk1160-ac97.o
2
3stk1160-y := stk1160-core.o \ 1stk1160-y := stk1160-core.o \
4 stk1160-v4l.o \ 2 stk1160-v4l.o \
5 stk1160-video.o \ 3 stk1160-video.o \
6 stk1160-i2c.o \ 4 stk1160-i2c.o \
7 $(obj-stk1160-ac97-y) 5 stk1160-ac97.o
8 6
9obj-$(CONFIG_VIDEO_STK1160) += stk1160.o 7obj-$(CONFIG_VIDEO_STK1160) += stk1160.o
10 8
diff --git a/drivers/media/usb/stk1160/stk1160-ac97.c b/drivers/media/usb/stk1160/stk1160-ac97.c
index 2dd308f9541f..2169be8a71dd 100644
--- a/drivers/media/usb/stk1160/stk1160-ac97.c
+++ b/drivers/media/usb/stk1160/stk1160-ac97.c
@@ -4,6 +4,9 @@
4 * Copyright (C) 2012 Ezequiel Garcia 4 * Copyright (C) 2012 Ezequiel Garcia
5 * <elezegarcia--a.t--gmail.com> 5 * <elezegarcia--a.t--gmail.com>
6 * 6 *
7 * Copyright (C) 2016 Marcel Hasler
8 * <mahasler--a.t--gmail.com>
9 *
7 * Based on Easycap driver by R.M. Thomas 10 * Based on Easycap driver by R.M. Thomas
8 * Copyright (C) 2010 R.M. Thomas 11 * Copyright (C) 2010 R.M. Thomas
9 * <rmthomas--a.t--sciolus.org> 12 * <rmthomas--a.t--sciolus.org>
@@ -20,20 +23,32 @@
20 * 23 *
21 */ 24 */
22 25
23#include <linux/module.h> 26#include <linux/delay.h>
24#include <sound/core.h>
25#include <sound/initval.h>
26#include <sound/ac97_codec.h>
27 27
28#include "stk1160.h" 28#include "stk1160.h"
29#include "stk1160-reg.h" 29#include "stk1160-reg.h"
30 30
31static struct snd_ac97 *stk1160_ac97; 31static int stk1160_ac97_wait_transfer_complete(struct stk1160 *dev)
32
33static void stk1160_write_ac97(struct snd_ac97 *ac97, u16 reg, u16 value)
34{ 32{
35 struct stk1160 *dev = ac97->private_data; 33 unsigned long timeout = jiffies + msecs_to_jiffies(STK1160_AC97_TIMEOUT);
34 u8 value;
35
36 /* Wait for AC97 transfer to complete */
37 while (time_is_after_jiffies(timeout)) {
38 stk1160_read_reg(dev, STK1160_AC97CTL_0, &value);
39
40 if (!(value & (STK1160_AC97CTL_0_CR | STK1160_AC97CTL_0_CW)))
41 return 0;
36 42
43 usleep_range(50, 100);
44 }
45
46 stk1160_err("AC97 transfer took too long, this should never happen!");
47 return -EBUSY;
48}
49
50static void stk1160_write_ac97(struct stk1160 *dev, u16 reg, u16 value)
51{
37 /* Set codec register address */ 52 /* Set codec register address */
38 stk1160_write_reg(dev, STK1160_AC97_ADDR, reg); 53 stk1160_write_reg(dev, STK1160_AC97_ADDR, reg);
39 54
@@ -41,28 +56,30 @@ static void stk1160_write_ac97(struct snd_ac97 *ac97, u16 reg, u16 value)
41 stk1160_write_reg(dev, STK1160_AC97_CMD, value & 0xff); 56 stk1160_write_reg(dev, STK1160_AC97_CMD, value & 0xff);
42 stk1160_write_reg(dev, STK1160_AC97_CMD + 1, (value & 0xff00) >> 8); 57 stk1160_write_reg(dev, STK1160_AC97_CMD + 1, (value & 0xff00) >> 8);
43 58
44 /* 59 /* Set command write bit to initiate write operation */
45 * Set command write bit to initiate write operation.
46 * The bit will be cleared when transfer is done.
47 */
48 stk1160_write_reg(dev, STK1160_AC97CTL_0, 0x8c); 60 stk1160_write_reg(dev, STK1160_AC97CTL_0, 0x8c);
61
62 /* Wait for command write bit to be cleared */
63 stk1160_ac97_wait_transfer_complete(dev);
49} 64}
50 65
51static u16 stk1160_read_ac97(struct snd_ac97 *ac97, u16 reg) 66#ifdef DEBUG
67static u16 stk1160_read_ac97(struct stk1160 *dev, u16 reg)
52{ 68{
53 struct stk1160 *dev = ac97->private_data;
54 u8 vall = 0; 69 u8 vall = 0;
55 u8 valh = 0; 70 u8 valh = 0;
56 71
57 /* Set codec register address */ 72 /* Set codec register address */
58 stk1160_write_reg(dev, STK1160_AC97_ADDR, reg); 73 stk1160_write_reg(dev, STK1160_AC97_ADDR, reg);
59 74
60 /* 75 /* Set command read bit to initiate read operation */
61 * Set command read bit to initiate read operation.
62 * The bit will be cleared when transfer is done.
63 */
64 stk1160_write_reg(dev, STK1160_AC97CTL_0, 0x8b); 76 stk1160_write_reg(dev, STK1160_AC97CTL_0, 0x8b);
65 77
78 /* Wait for command read bit to be cleared */
79 if (stk1160_ac97_wait_transfer_complete(dev) < 0)
80 return 0;
81
82
66 /* Retrieve register value */ 83 /* Retrieve register value */
67 stk1160_read_reg(dev, STK1160_AC97_CMD, &vall); 84 stk1160_read_reg(dev, STK1160_AC97_CMD, &vall);
68 stk1160_read_reg(dev, STK1160_AC97_CMD + 1, &valh); 85 stk1160_read_reg(dev, STK1160_AC97_CMD + 1, &valh);
@@ -70,81 +87,79 @@ static u16 stk1160_read_ac97(struct snd_ac97 *ac97, u16 reg)
70 return (valh << 8) | vall; 87 return (valh << 8) | vall;
71} 88}
72 89
73static void stk1160_reset_ac97(struct snd_ac97 *ac97) 90void stk1160_ac97_dump_regs(struct stk1160 *dev)
74{ 91{
75 struct stk1160 *dev = ac97->private_data; 92 u16 value;
76 /* Two-step reset AC97 interface and hardware codec */
77 stk1160_write_reg(dev, STK1160_AC97CTL_0, 0x94);
78 stk1160_write_reg(dev, STK1160_AC97CTL_0, 0x88);
79 93
80 /* Set 16-bit audio data and choose L&R channel*/ 94 value = stk1160_read_ac97(dev, 0x12); /* CD volume */
81 stk1160_write_reg(dev, STK1160_AC97CTL_1 + 2, 0x01); 95 stk1160_dbg("0x12 == 0x%04x", value);
96
97 value = stk1160_read_ac97(dev, 0x10); /* Line-in volume */
98 stk1160_dbg("0x10 == 0x%04x", value);
99
100 value = stk1160_read_ac97(dev, 0x0e); /* MIC volume (mono) */
101 stk1160_dbg("0x0e == 0x%04x", value);
102
103 value = stk1160_read_ac97(dev, 0x16); /* Aux volume */
104 stk1160_dbg("0x16 == 0x%04x", value);
105
106 value = stk1160_read_ac97(dev, 0x1a); /* Record select */
107 stk1160_dbg("0x1a == 0x%04x", value);
108
109 value = stk1160_read_ac97(dev, 0x02); /* Master volume */
110 stk1160_dbg("0x02 == 0x%04x", value);
111
112 value = stk1160_read_ac97(dev, 0x1c); /* Record gain */
113 stk1160_dbg("0x1c == 0x%04x", value);
82} 114}
115#endif
116
117static int stk1160_has_audio(struct stk1160 *dev)
118{
119 u8 value;
83 120
84static struct snd_ac97_bus_ops stk1160_ac97_ops = { 121 stk1160_read_reg(dev, STK1160_POSV_L, &value);
85 .read = stk1160_read_ac97, 122 return !(value & STK1160_POSV_L_ACDOUT);
86 .write = stk1160_write_ac97, 123}
87 .reset = stk1160_reset_ac97,
88};
89 124
90int stk1160_ac97_register(struct stk1160 *dev) 125static int stk1160_has_ac97(struct stk1160 *dev)
91{ 126{
92 struct snd_card *card = NULL; 127 u8 value;
93 struct snd_ac97_bus *ac97_bus; 128
94 struct snd_ac97_template ac97_template; 129 stk1160_read_reg(dev, STK1160_POSV_L, &value);
95 int rc; 130 return !(value & STK1160_POSV_L_ACSYNC);
96
97 /*
98 * Just want a card to access ac96 controls,
99 * the actual capture interface will be handled by snd-usb-audio
100 */
101 rc = snd_card_new(dev->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
102 THIS_MODULE, 0, &card);
103 if (rc < 0)
104 return rc;
105
106 /* TODO: I'm not sure where should I get these names :-( */
107 snprintf(card->shortname, sizeof(card->shortname),
108 "stk1160-mixer");
109 snprintf(card->longname, sizeof(card->longname),
110 "stk1160 ac97 codec mixer control");
111 strlcpy(card->driver, dev->dev->driver->name, sizeof(card->driver));
112
113 rc = snd_ac97_bus(card, 0, &stk1160_ac97_ops, NULL, &ac97_bus);
114 if (rc)
115 goto err;
116
117 /* We must set private_data before calling snd_ac97_mixer */
118 memset(&ac97_template, 0, sizeof(ac97_template));
119 ac97_template.private_data = dev;
120 ac97_template.scaps = AC97_SCAP_SKIP_MODEM;
121 rc = snd_ac97_mixer(ac97_bus, &ac97_template, &stk1160_ac97);
122 if (rc)
123 goto err;
124
125 dev->snd_card = card;
126 rc = snd_card_register(card);
127 if (rc)
128 goto err;
129
130 return 0;
131
132err:
133 dev->snd_card = NULL;
134 snd_card_free(card);
135 return rc;
136} 131}
137 132
138int stk1160_ac97_unregister(struct stk1160 *dev) 133void stk1160_ac97_setup(struct stk1160 *dev)
139{ 134{
140 struct snd_card *card = dev->snd_card; 135 if (!stk1160_has_audio(dev)) {
136 stk1160_info("Device doesn't support audio, skipping AC97 setup.");
137 return;
138 }
141 139
142 /* 140 if (!stk1160_has_ac97(dev)) {
143 * We need to check usb_device, 141 stk1160_info("Device uses internal 8-bit ADC, skipping AC97 setup.");
144 * because ac97 release attempts to communicate with codec 142 return;
145 */ 143 }
146 if (card && dev->udev)
147 snd_card_free(card);
148 144
149 return 0; 145 /* Two-step reset AC97 interface and hardware codec */
146 stk1160_write_reg(dev, STK1160_AC97CTL_0, 0x94);
147 stk1160_write_reg(dev, STK1160_AC97CTL_0, 0x8c);
148
149 /* Set 16-bit audio data and choose L&R channel*/
150 stk1160_write_reg(dev, STK1160_AC97CTL_1 + 2, 0x01);
151 stk1160_write_reg(dev, STK1160_AC97CTL_1 + 3, 0x00);
152
153 /* Setup channels */
154 stk1160_write_ac97(dev, 0x12, 0x8808); /* CD volume */
155 stk1160_write_ac97(dev, 0x10, 0x0808); /* Line-in volume */
156 stk1160_write_ac97(dev, 0x0e, 0x0008); /* MIC volume (mono) */
157 stk1160_write_ac97(dev, 0x16, 0x0808); /* Aux volume */
158 stk1160_write_ac97(dev, 0x1a, 0x0404); /* Record select */
159 stk1160_write_ac97(dev, 0x02, 0x0000); /* Master volume */
160 stk1160_write_ac97(dev, 0x1c, 0x0808); /* Record gain */
161
162#ifdef DEBUG
163 stk1160_ac97_dump_regs(dev);
164#endif
150} 165}
diff --git a/drivers/media/usb/stk1160/stk1160-core.c b/drivers/media/usb/stk1160/stk1160-core.c
index bc029478065a..c86eb6164713 100644
--- a/drivers/media/usb/stk1160/stk1160-core.c
+++ b/drivers/media/usb/stk1160/stk1160-core.c
@@ -20,8 +20,7 @@
20 * 20 *
21 * TODO: 21 * TODO:
22 * 22 *
23 * 1. (Try to) detect if we must register ac97 mixer 23 * 1. Support stream at lower speed: lower frame rate or lower frame size.
24 * 2. Support stream at lower speed: lower frame rate or lower frame size.
25 * 24 *
26 */ 25 */
27 26
@@ -373,7 +372,7 @@ static int stk1160_probe(struct usb_interface *interface,
373 /* select default input */ 372 /* select default input */
374 stk1160_select_input(dev); 373 stk1160_select_input(dev);
375 374
376 stk1160_ac97_register(dev); 375 stk1160_ac97_setup(dev);
377 376
378 rc = stk1160_video_register(dev); 377 rc = stk1160_video_register(dev);
379 if (rc < 0) 378 if (rc < 0)
@@ -411,9 +410,6 @@ static void stk1160_disconnect(struct usb_interface *interface)
411 /* Here is the only place where isoc get released */ 410 /* Here is the only place where isoc get released */
412 stk1160_uninit_isoc(dev); 411 stk1160_uninit_isoc(dev);
413 412
414 /* ac97 unregister needs to be done before usb_device is cleared */
415 stk1160_ac97_unregister(dev);
416
417 stk1160_clear_queue(dev); 413 stk1160_clear_queue(dev);
418 414
419 video_unregister_device(&dev->vdev); 415 video_unregister_device(&dev->vdev);
diff --git a/drivers/media/usb/stk1160/stk1160-reg.h b/drivers/media/usb/stk1160/stk1160-reg.h
index 81ff3a15d96e..7b08a3cc4504 100644
--- a/drivers/media/usb/stk1160/stk1160-reg.h
+++ b/drivers/media/usb/stk1160/stk1160-reg.h
@@ -26,6 +26,14 @@
26/* Remote Wakup Control */ 26/* Remote Wakup Control */
27#define STK1160_RMCTL 0x00c 27#define STK1160_RMCTL 0x00c
28 28
29/* Power-on Strapping Data */
30#define STK1160_POSVA 0x010
31#define STK1160_POSV_L 0x010
32#define STK1160_POSV_M 0x011
33#define STK1160_POSV_H 0x012
34#define STK1160_POSV_L_ACDOUT BIT(3)
35#define STK1160_POSV_L_ACSYNC BIT(2)
36
29/* 37/*
30 * Decoder Control Register: 38 * Decoder Control Register:
31 * This byte controls capture start/stop 39 * This byte controls capture start/stop
@@ -114,6 +122,8 @@
114/* AC97 Audio Control */ 122/* AC97 Audio Control */
115#define STK1160_AC97CTL_0 0x500 123#define STK1160_AC97CTL_0 0x500
116#define STK1160_AC97CTL_1 0x504 124#define STK1160_AC97CTL_1 0x504
125#define STK1160_AC97CTL_0_CR BIT(1)
126#define STK1160_AC97CTL_0_CW BIT(2)
117 127
118/* Use [0:6] bits of register 0x504 to set codec command address */ 128/* Use [0:6] bits of register 0x504 to set codec command address */
119#define STK1160_AC97_ADDR 0x504 129#define STK1160_AC97_ADDR 0x504
diff --git a/drivers/media/usb/stk1160/stk1160.h b/drivers/media/usb/stk1160/stk1160.h
index 1ed1cc43cdb2..acd1c811db08 100644
--- a/drivers/media/usb/stk1160/stk1160.h
+++ b/drivers/media/usb/stk1160/stk1160.h
@@ -50,6 +50,8 @@
50#define STK1160_MAX_INPUT 4 50#define STK1160_MAX_INPUT 4
51#define STK1160_SVIDEO_INPUT 4 51#define STK1160_SVIDEO_INPUT 4
52 52
53#define STK1160_AC97_TIMEOUT 50
54
53#define STK1160_I2C_TIMEOUT 100 55#define STK1160_I2C_TIMEOUT 100
54 56
55/* TODO: Print helpers 57/* TODO: Print helpers
@@ -197,11 +199,4 @@ int stk1160_read_reg_req_len(struct stk1160 *dev, u8 req, u16 reg,
197void stk1160_select_input(struct stk1160 *dev); 199void stk1160_select_input(struct stk1160 *dev);
198 200
199/* Provided by stk1160-ac97.c */ 201/* Provided by stk1160-ac97.c */
200#ifdef CONFIG_VIDEO_STK1160_AC97 202void stk1160_ac97_setup(struct stk1160 *dev);
201int stk1160_ac97_register(struct stk1160 *dev);
202int stk1160_ac97_unregister(struct stk1160 *dev);
203#else
204static inline int stk1160_ac97_register(struct stk1160 *dev) { return 0; }
205static inline int stk1160_ac97_unregister(struct stk1160 *dev) { return 0; }
206#endif
207
diff --git a/drivers/media/usb/stkwebcam/stk-sensor.c b/drivers/media/usb/stkwebcam/stk-sensor.c
index fbccbb2eed9f..985af9933c7e 100644
--- a/drivers/media/usb/stkwebcam/stk-sensor.c
+++ b/drivers/media/usb/stkwebcam/stk-sensor.c
@@ -19,10 +19,6 @@
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 */ 22 */
27 23
28/* Controlling the sensor via the STK1125 vendor specific control interface: 24/* Controlling the sensor via the STK1125 vendor specific control interface:
diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c
index a212248bc2a3..6e7fc36b658f 100644
--- a/drivers/media/usb/stkwebcam/stk-webcam.c
+++ b/drivers/media/usb/stkwebcam/stk-webcam.c
@@ -16,10 +16,6 @@
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */ 19 */
24 20
25#include <linux/module.h> 21#include <linux/module.h>
diff --git a/drivers/media/usb/stkwebcam/stk-webcam.h b/drivers/media/usb/stkwebcam/stk-webcam.h
index 92bb48e3c74e..0284120ce246 100644
--- a/drivers/media/usb/stkwebcam/stk-webcam.h
+++ b/drivers/media/usb/stkwebcam/stk-webcam.h
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 16 */
21 17
22#ifndef STKWEBCAM_H 18#ifndef STKWEBCAM_H
diff --git a/drivers/media/usb/tm6000/tm6000-cards.c b/drivers/media/usb/tm6000/tm6000-cards.c
index 8902ee36bc94..b293dea6554f 100644
--- a/drivers/media/usb/tm6000/tm6000-cards.c
+++ b/drivers/media/usb/tm6000/tm6000-cards.c
@@ -11,10 +11,6 @@
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 14 */
19 15
20#include <linux/init.h> 16#include <linux/init.h>
diff --git a/drivers/media/usb/tm6000/tm6000-core.c b/drivers/media/usb/tm6000/tm6000-core.c
index 8d104e5c4be3..8c265bd80faa 100644
--- a/drivers/media/usb/tm6000/tm6000-core.c
+++ b/drivers/media/usb/tm6000/tm6000-core.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#include <linux/module.h> 19#include <linux/module.h>
diff --git a/drivers/media/usb/tm6000/tm6000-dvb.c b/drivers/media/usb/tm6000/tm6000-dvb.c
index 70dbaec1219e..097ac321b7e1 100644
--- a/drivers/media/usb/tm6000/tm6000-dvb.c
+++ b/drivers/media/usb/tm6000/tm6000-dvb.c
@@ -11,10 +11,6 @@
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 14 */
19 15
20#include <linux/kernel.h> 16#include <linux/kernel.h>
diff --git a/drivers/media/usb/tm6000/tm6000-i2c.c b/drivers/media/usb/tm6000/tm6000-i2c.c
index b01d3ee56e77..cbcc1472f1c7 100644
--- a/drivers/media/usb/tm6000/tm6000-i2c.c
+++ b/drivers/media/usb/tm6000/tm6000-i2c.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#include <linux/module.h> 19#include <linux/module.h>
diff --git a/drivers/media/usb/tm6000/tm6000-input.c b/drivers/media/usb/tm6000/tm6000-input.c
index 26b2ebb62547..4afd4655d562 100644
--- a/drivers/media/usb/tm6000/tm6000-input.c
+++ b/drivers/media/usb/tm6000/tm6000-input.c
@@ -11,10 +11,6 @@
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 14 */
19 15
20#include <linux/module.h> 16#include <linux/module.h>
@@ -39,7 +35,7 @@ MODULE_PARM_DESC(enable_ir, "enable ir (default is enable)");
39 35
40static unsigned int ir_clock_mhz = 12; 36static unsigned int ir_clock_mhz = 12;
41module_param(ir_clock_mhz, int, 0644); 37module_param(ir_clock_mhz, int, 0644);
42MODULE_PARM_DESC(enable_ir, "ir clock, in MHz"); 38MODULE_PARM_DESC(ir_clock_mhz, "ir clock, in MHz");
43 39
44#define URB_SUBMIT_DELAY 100 /* ms - Delay to submit an URB request on retrial and init */ 40#define URB_SUBMIT_DELAY 100 /* ms - Delay to submit an URB request on retrial and init */
45#define URB_INT_LED_DELAY 100 /* ms - Delay to turn led on again on int mode */ 41#define URB_INT_LED_DELAY 100 /* ms - Delay to turn led on again on int mode */
@@ -429,7 +425,7 @@ int tm6000_ir_init(struct tm6000_core *dev)
429 return 0; 425 return 0;
430 426
431 ir = kzalloc(sizeof(*ir), GFP_ATOMIC); 427 ir = kzalloc(sizeof(*ir), GFP_ATOMIC);
432 rc = rc_allocate_device(); 428 rc = rc_allocate_device(RC_DRIVER_SCANCODE);
433 if (!ir || !rc) 429 if (!ir || !rc)
434 goto out; 430 goto out;
435 431
@@ -456,7 +452,6 @@ int tm6000_ir_init(struct tm6000_core *dev)
456 ir->polling = 50; 452 ir->polling = 50;
457 INIT_DELAYED_WORK(&ir->work, tm6000_ir_handle_key); 453 INIT_DELAYED_WORK(&ir->work, tm6000_ir_handle_key);
458 } 454 }
459 rc->driver_type = RC_DRIVER_SCANCODE;
460 455
461 snprintf(ir->name, sizeof(ir->name), "tm5600/60x0 IR (%s)", 456 snprintf(ir->name, sizeof(ir->name), "tm5600/60x0 IR (%s)",
462 dev->name); 457 dev->name);
diff --git a/drivers/media/usb/tm6000/tm6000-regs.h b/drivers/media/usb/tm6000/tm6000-regs.h
index a38c251ed57b..ab3fb74c476c 100644
--- a/drivers/media/usb/tm6000/tm6000-regs.h
+++ b/drivers/media/usb/tm6000/tm6000-regs.h
@@ -11,10 +11,6 @@
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 14 */
19 15
20/* 16/*
diff --git a/drivers/media/usb/tm6000/tm6000-stds.c b/drivers/media/usb/tm6000/tm6000-stds.c
index 4064a5e8fae1..aa43810d17f9 100644
--- a/drivers/media/usb/tm6000/tm6000-stds.c
+++ b/drivers/media/usb/tm6000/tm6000-stds.c
@@ -11,10 +11,6 @@
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 14 */
19 15
20#include <linux/module.h> 16#include <linux/module.h>
diff --git a/drivers/media/usb/tm6000/tm6000-usb-isoc.h b/drivers/media/usb/tm6000/tm6000-usb-isoc.h
index 99d15a55aa03..6a13a27c55d7 100644
--- a/drivers/media/usb/tm6000/tm6000-usb-isoc.h
+++ b/drivers/media/usb/tm6000/tm6000-usb-isoc.h
@@ -11,10 +11,6 @@
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 14 */
19 15
20#include <linux/videodev2.h> 16#include <linux/videodev2.h>
diff --git a/drivers/media/usb/tm6000/tm6000-video.c b/drivers/media/usb/tm6000/tm6000-video.c
index d9f3fa5db8dd..c4fdc1fa32ef 100644
--- a/drivers/media/usb/tm6000/tm6000-video.c
+++ b/drivers/media/usb/tm6000/tm6000-video.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#include <linux/module.h> 19#include <linux/module.h>
@@ -1375,8 +1371,11 @@ static int __tm6000_open(struct file *file)
1375 1371
1376 /* initialize hardware on analog mode */ 1372 /* initialize hardware on analog mode */
1377 rc = tm6000_init_analog_mode(dev); 1373 rc = tm6000_init_analog_mode(dev);
1378 if (rc < 0) 1374 if (rc < 0) {
1375 v4l2_fh_exit(&fh->fh);
1376 kfree(fh);
1379 return rc; 1377 return rc;
1378 }
1380 1379
1381 dev->mode = TM6000_MODE_ANALOG; 1380 dev->mode = TM6000_MODE_ANALOG;
1382 1381
diff --git a/drivers/media/usb/tm6000/tm6000.h b/drivers/media/usb/tm6000/tm6000.h
index f2127944776f..7ec478d75f55 100644
--- a/drivers/media/usb/tm6000/tm6000.h
+++ b/drivers/media/usb/tm6000/tm6000.h
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 17 */
22 18
23#include <linux/videodev2.h> 19#include <linux/videodev2.h>
diff --git a/drivers/media/usb/ttusb-dec/ttusb_dec.c b/drivers/media/usb/ttusb-dec/ttusb_dec.c
index fc0219f1b7df..01c7e6d4481c 100644
--- a/drivers/media/usb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/usb/ttusb-dec/ttusb_dec.c
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 */ 17 */
22 18
23#include <linux/list.h> 19#include <linux/list.h>
diff --git a/drivers/media/usb/ttusb-dec/ttusbdecfe.c b/drivers/media/usb/ttusb-dec/ttusbdecfe.c
index 2d9444905fdb..09693caa15e2 100644
--- a/drivers/media/usb/ttusb-dec/ttusbdecfe.c
+++ b/drivers/media/usb/ttusb-dec/ttusbdecfe.c
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */ 16 */
21 17
22#include "dvb_frontend.h" 18#include "dvb_frontend.h"
diff --git a/drivers/media/usb/ttusb-dec/ttusbdecfe.h b/drivers/media/usb/ttusb-dec/ttusbdecfe.h
index 15ccc3d1a20e..5aff58c1b075 100644
--- a/drivers/media/usb/ttusb-dec/ttusbdecfe.h
+++ b/drivers/media/usb/ttusb-dec/ttusbdecfe.h
@@ -13,10 +13,6 @@
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */ 16 */
21 17
22#ifndef TTUSBDECFE_H 18#ifndef TTUSBDECFE_H
diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c
index d3b6d3dfaa09..8135614f395a 100644
--- a/drivers/media/usb/usbtv/usbtv-video.c
+++ b/drivers/media/usb/usbtv/usbtv-video.c
@@ -757,6 +757,12 @@ static int usbtv_s_ctrl(struct v4l2_ctrl *ctrl)
757 data[1] = -ctrl->val & 0xff; 757 data[1] = -ctrl->val & 0xff;
758 } 758 }
759 break; 759 break;
760 case V4L2_CID_SHARPNESS:
761 index = USBTV_BASE + 0x0239;
762 data[0] = 0;
763 data[1] = ctrl->val;
764 size = 2;
765 break;
760 default: 766 default:
761 kfree(data); 767 kfree(data);
762 return -EINVAL; 768 return -EINVAL;
@@ -825,6 +831,8 @@ int usbtv_video_init(struct usbtv *usbtv)
825 V4L2_CID_SATURATION, 0, 0x3ff, 1, 0x200); 831 V4L2_CID_SATURATION, 0, 0x3ff, 1, 0x200);
826 v4l2_ctrl_new_std(&usbtv->ctrl, &usbtv_ctrl_ops, 832 v4l2_ctrl_new_std(&usbtv->ctrl, &usbtv_ctrl_ops,
827 V4L2_CID_HUE, -0xdff, 0xdff, 1, 0x000); 833 V4L2_CID_HUE, -0xdff, 0xdff, 1, 0x000);
834 v4l2_ctrl_new_std(&usbtv->ctrl, &usbtv_ctrl_ops,
835 V4L2_CID_SHARPNESS, 0x0, 0xff, 1, 0x60);
828 ret = usbtv->ctrl.error; 836 ret = usbtv->ctrl.error;
829 if (ret < 0) { 837 if (ret < 0) {
830 dev_warn(usbtv->dev, "Could not initialize controls\n"); 838 dev_warn(usbtv->dev, "Could not initialize controls\n");
diff --git a/drivers/media/usb/usbvision/usbvision-cards.c b/drivers/media/usb/usbvision/usbvision-cards.c
index 3103d0d020e8..fc2418b9f37c 100644
--- a/drivers/media/usb/usbvision/usbvision-cards.c
+++ b/drivers/media/usb/usbvision/usbvision-cards.c
@@ -16,10 +16,6 @@
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */ 19 */
24 20
25 21
diff --git a/drivers/media/usb/usbvision/usbvision-core.c b/drivers/media/usb/usbvision/usbvision-core.c
index bf041a9e69db..3f87fbc80be2 100644
--- a/drivers/media/usb/usbvision/usbvision-core.c
+++ b/drivers/media/usb/usbvision/usbvision-core.c
@@ -17,10 +17,6 @@
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 20 */
25 21
26#include <linux/kernel.h> 22#include <linux/kernel.h>
@@ -1417,8 +1413,6 @@ static void usbvision_ctrl_urb_complete(struct urb *urb)
1417 1413
1418 PDEBUG(DBG_IRQ, ""); 1414 PDEBUG(DBG_IRQ, "");
1419 usbvision->ctrl_urb_busy = 0; 1415 usbvision->ctrl_urb_busy = 0;
1420 if (waitqueue_active(&usbvision->ctrl_urb_wq))
1421 wake_up_interruptible(&usbvision->ctrl_urb_wq);
1422} 1416}
1423 1417
1424 1418
diff --git a/drivers/media/usb/usbvision/usbvision-i2c.c b/drivers/media/usb/usbvision/usbvision-i2c.c
index 120de2e020e1..5a3f788ad033 100644
--- a/drivers/media/usb/usbvision/usbvision-i2c.c
+++ b/drivers/media/usb/usbvision/usbvision-i2c.c
@@ -17,10 +17,6 @@
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 20 */
25 21
26 22
diff --git a/drivers/media/usb/usbvision/usbvision-video.c b/drivers/media/usb/usbvision/usbvision-video.c
index a7529196c327..f5c635a67d74 100644
--- a/drivers/media/usb/usbvision/usbvision-video.c
+++ b/drivers/media/usb/usbvision/usbvision-video.c
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 * Let's call the version 0.... until compression decoding is completely 20 * Let's call the version 0.... until compression decoding is completely
25 * implemented. 21 * implemented.
26 * 22 *
@@ -1340,7 +1336,6 @@ static struct usb_usbvision *usbvision_alloc(struct usb_device *dev,
1340 usbvision->ctrl_urb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL); 1336 usbvision->ctrl_urb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL);
1341 if (usbvision->ctrl_urb == NULL) 1337 if (usbvision->ctrl_urb == NULL)
1342 goto err_unreg; 1338 goto err_unreg;
1343 init_waitqueue_head(&usbvision->ctrl_urb_wq);
1344 1339
1345 return usbvision; 1340 return usbvision;
1346 1341
diff --git a/drivers/media/usb/usbvision/usbvision.h b/drivers/media/usb/usbvision/usbvision.h
index 4f2e4fde38f2..6ecdcd58248f 100644
--- a/drivers/media/usb/usbvision/usbvision.h
+++ b/drivers/media/usb/usbvision/usbvision.h
@@ -21,10 +21,6 @@
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details. 23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 */ 24 */
29 25
30 26
@@ -370,7 +366,6 @@ struct usb_usbvision {
370 unsigned char ctrl_urb_buffer[8]; 366 unsigned char ctrl_urb_buffer[8];
371 int ctrl_urb_busy; 367 int ctrl_urb_busy;
372 struct usb_ctrlrequest ctrl_urb_setup; 368 struct usb_ctrlrequest ctrl_urb_setup;
373 wait_queue_head_t ctrl_urb_wq; /* Processes waiting */
374 369
375 /* configuration part */ 370 /* configuration part */
376 int have_tuner; 371 int have_tuner;
diff --git a/drivers/media/usb/uvc/uvc_debugfs.c b/drivers/media/usb/uvc/uvc_debugfs.c
index 14561a5abb79..368f8f8dfcb5 100644
--- a/drivers/media/usb/uvc/uvc_debugfs.c
+++ b/drivers/media/usb/uvc/uvc_debugfs.c
@@ -75,14 +75,14 @@ static const struct file_operations uvc_debugfs_stats_fops = {
75 75
76static struct dentry *uvc_debugfs_root_dir; 76static struct dentry *uvc_debugfs_root_dir;
77 77
78int uvc_debugfs_init_stream(struct uvc_streaming *stream) 78void uvc_debugfs_init_stream(struct uvc_streaming *stream)
79{ 79{
80 struct usb_device *udev = stream->dev->udev; 80 struct usb_device *udev = stream->dev->udev;
81 struct dentry *dent; 81 struct dentry *dent;
82 char dir_name[32]; 82 char dir_name[32];
83 83
84 if (uvc_debugfs_root_dir == NULL) 84 if (uvc_debugfs_root_dir == NULL)
85 return -ENODEV; 85 return;
86 86
87 sprintf(dir_name, "%u-%u", udev->bus->busnum, udev->devnum); 87 sprintf(dir_name, "%u-%u", udev->bus->busnum, udev->devnum);
88 88
@@ -90,7 +90,7 @@ int uvc_debugfs_init_stream(struct uvc_streaming *stream)
90 if (IS_ERR_OR_NULL(dent)) { 90 if (IS_ERR_OR_NULL(dent)) {
91 uvc_printk(KERN_INFO, "Unable to create debugfs %s " 91 uvc_printk(KERN_INFO, "Unable to create debugfs %s "
92 "directory.\n", dir_name); 92 "directory.\n", dir_name);
93 return -ENODEV; 93 return;
94 } 94 }
95 95
96 stream->debugfs_dir = dent; 96 stream->debugfs_dir = dent;
@@ -100,10 +100,8 @@ int uvc_debugfs_init_stream(struct uvc_streaming *stream)
100 if (IS_ERR_OR_NULL(dent)) { 100 if (IS_ERR_OR_NULL(dent)) {
101 uvc_printk(KERN_INFO, "Unable to create debugfs stats file.\n"); 101 uvc_printk(KERN_INFO, "Unable to create debugfs stats file.\n");
102 uvc_debugfs_cleanup_stream(stream); 102 uvc_debugfs_cleanup_stream(stream);
103 return -ENODEV; 103 return;
104 } 104 }
105
106 return 0;
107} 105}
108 106
109void uvc_debugfs_cleanup_stream(struct uvc_streaming *stream) 107void uvc_debugfs_cleanup_stream(struct uvc_streaming *stream)
@@ -115,18 +113,17 @@ void uvc_debugfs_cleanup_stream(struct uvc_streaming *stream)
115 stream->debugfs_dir = NULL; 113 stream->debugfs_dir = NULL;
116} 114}
117 115
118int uvc_debugfs_init(void) 116void uvc_debugfs_init(void)
119{ 117{
120 struct dentry *dir; 118 struct dentry *dir;
121 119
122 dir = debugfs_create_dir("uvcvideo", usb_debug_root); 120 dir = debugfs_create_dir("uvcvideo", usb_debug_root);
123 if (IS_ERR_OR_NULL(dir)) { 121 if (IS_ERR_OR_NULL(dir)) {
124 uvc_printk(KERN_INFO, "Unable to create debugfs directory\n"); 122 uvc_printk(KERN_INFO, "Unable to create debugfs directory\n");
125 return -ENODATA; 123 return;
126 } 124 }
127 125
128 uvc_debugfs_root_dir = dir; 126 uvc_debugfs_root_dir = dir;
129 return 0;
130} 127}
131 128
132void uvc_debugfs_cleanup(void) 129void uvc_debugfs_cleanup(void)
diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c
index 77edd206d345..aa2199775cb8 100644
--- a/drivers/media/usb/uvc/uvc_queue.c
+++ b/drivers/media/usb/uvc/uvc_queue.c
@@ -43,6 +43,11 @@ uvc_queue_to_stream(struct uvc_video_queue *queue)
43 return container_of(queue, struct uvc_streaming, queue); 43 return container_of(queue, struct uvc_streaming, queue);
44} 44}
45 45
46static inline struct uvc_buffer *uvc_vbuf_to_buffer(struct vb2_v4l2_buffer *buf)
47{
48 return container_of(buf, struct uvc_buffer, buf);
49}
50
46/* 51/*
47 * Return all queued buffers to videobuf2 in the requested state. 52 * Return all queued buffers to videobuf2 in the requested state.
48 * 53 *
@@ -89,7 +94,7 @@ static int uvc_buffer_prepare(struct vb2_buffer *vb)
89{ 94{
90 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); 95 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
91 struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); 96 struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue);
92 struct uvc_buffer *buf = container_of(vbuf, struct uvc_buffer, buf); 97 struct uvc_buffer *buf = uvc_vbuf_to_buffer(vbuf);
93 98
94 if (vb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT && 99 if (vb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT &&
95 vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) { 100 vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) {
@@ -116,7 +121,7 @@ static void uvc_buffer_queue(struct vb2_buffer *vb)
116{ 121{
117 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); 122 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
118 struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); 123 struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue);
119 struct uvc_buffer *buf = container_of(vbuf, struct uvc_buffer, buf); 124 struct uvc_buffer *buf = uvc_vbuf_to_buffer(vbuf);
120 unsigned long flags; 125 unsigned long flags;
121 126
122 spin_lock_irqsave(&queue->irqlock, flags); 127 spin_lock_irqsave(&queue->irqlock, flags);
@@ -138,7 +143,7 @@ static void uvc_buffer_finish(struct vb2_buffer *vb)
138 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); 143 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
139 struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); 144 struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue);
140 struct uvc_streaming *stream = uvc_queue_to_stream(queue); 145 struct uvc_streaming *stream = uvc_queue_to_stream(queue);
141 struct uvc_buffer *buf = container_of(vbuf, struct uvc_buffer, buf); 146 struct uvc_buffer *buf = uvc_vbuf_to_buffer(vbuf);
142 147
143 if (vb->state == VB2_BUF_STATE_DONE) 148 if (vb->state == VB2_BUF_STATE_DONE)
144 uvc_video_clock_update(stream, vbuf, buf); 149 uvc_video_clock_update(stream, vbuf, buf);
@@ -412,7 +417,7 @@ struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
412 nextbuf = NULL; 417 nextbuf = NULL;
413 spin_unlock_irqrestore(&queue->irqlock, flags); 418 spin_unlock_irqrestore(&queue->irqlock, flags);
414 419
415 buf->state = buf->error ? VB2_BUF_STATE_ERROR : UVC_BUF_STATE_DONE; 420 buf->state = buf->error ? UVC_BUF_STATE_ERROR : UVC_BUF_STATE_DONE;
416 vb2_set_plane_payload(&buf->buf.vb2_buf, 0, buf->bytesused); 421 vb2_set_plane_payload(&buf->buf.vb2_buf, 0, buf->bytesused);
417 vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE); 422 vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE);
418 423
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index f3c1c852e401..07a6c833ef7b 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -1262,8 +1262,7 @@ static void uvc_video_decode_bulk(struct urb *urb, struct uvc_streaming *stream,
1262 uvc_video_decode_end(stream, buf, stream->bulk.header, 1262 uvc_video_decode_end(stream, buf, stream->bulk.header,
1263 stream->bulk.payload_size); 1263 stream->bulk.payload_size);
1264 if (buf->state == UVC_BUF_STATE_READY) 1264 if (buf->state == UVC_BUF_STATE_READY)
1265 buf = uvc_queue_next_buffer(&stream->queue, 1265 uvc_queue_next_buffer(&stream->queue, buf);
1266 buf);
1267 } 1266 }
1268 1267
1269 stream->bulk.header_size = 0; 1268 stream->bulk.header_size = 0;
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 3d6cc62f3cd2..4205e7a423f0 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -757,9 +757,9 @@ void uvc_video_decode_isight(struct urb *urb, struct uvc_streaming *stream,
757 struct uvc_buffer *buf); 757 struct uvc_buffer *buf);
758 758
759/* debugfs and statistics */ 759/* debugfs and statistics */
760int uvc_debugfs_init(void); 760void uvc_debugfs_init(void);
761void uvc_debugfs_cleanup(void); 761void uvc_debugfs_cleanup(void);
762int uvc_debugfs_init_stream(struct uvc_streaming *stream); 762void uvc_debugfs_init_stream(struct uvc_streaming *stream);
763void uvc_debugfs_cleanup_stream(struct uvc_streaming *stream); 763void uvc_debugfs_cleanup_stream(struct uvc_streaming *stream);
764 764
765size_t uvc_video_stats_dump(struct uvc_streaming *stream, char *buf, 765size_t uvc_video_stats_dump(struct uvc_streaming *stream, char *buf,
diff --git a/drivers/media/usb/zr364xx/zr364xx.c b/drivers/media/usb/zr364xx/zr364xx.c
index 3950708cbb32..f2d6fc03dda0 100644
--- a/drivers/media/usb/zr364xx/zr364xx.c
+++ b/drivers/media/usb/zr364xx/zr364xx.c
@@ -21,10 +21,6 @@
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details. 23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 */ 24 */
29 25
30 26
diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
index 5bada202b2d3..96cc733f35ef 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -42,7 +42,8 @@ static bool match_devname(struct v4l2_subdev *sd,
42 42
43static bool match_of(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) 43static bool match_of(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
44{ 44{
45 return sd->of_node == asd->match.of.node; 45 return !of_node_cmp(of_node_full_name(sd->of_node),
46 of_node_full_name(asd->match.of.node));
46} 47}
47 48
48static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) 49static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
@@ -99,18 +100,11 @@ static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier,
99{ 100{
100 int ret; 101 int ret;
101 102
102 /* Remove from the waiting list */
103 list_del(&asd->list);
104 sd->asd = asd;
105 sd->notifier = notifier;
106
107 if (notifier->bound) { 103 if (notifier->bound) {
108 ret = notifier->bound(notifier, sd, asd); 104 ret = notifier->bound(notifier, sd, asd);
109 if (ret < 0) 105 if (ret < 0)
110 return ret; 106 return ret;
111 } 107 }
112 /* Move from the global subdevice list to notifier's done */
113 list_move(&sd->async_list, &notifier->done);
114 108
115 ret = v4l2_device_register_subdev(notifier->v4l2_dev, sd); 109 ret = v4l2_device_register_subdev(notifier->v4l2_dev, sd);
116 if (ret < 0) { 110 if (ret < 0) {
@@ -119,6 +113,14 @@ static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier,
119 return ret; 113 return ret;
120 } 114 }
121 115
116 /* Remove from the waiting list */
117 list_del(&asd->list);
118 sd->asd = asd;
119 sd->notifier = notifier;
120
121 /* Move from the global subdevice list to notifier's done */
122 list_move(&sd->async_list, &notifier->done);
123
122 if (list_empty(&notifier->waiting) && notifier->complete) 124 if (list_empty(&notifier->waiting) && notifier->complete)
123 return notifier->complete(notifier); 125 return notifier->complete(notifier);
124 126
@@ -168,9 +170,6 @@ int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev,
168 170
169 mutex_lock(&list_lock); 171 mutex_lock(&list_lock);
170 172
171 /* Keep also completed notifiers on the list */
172 list_add(&notifier->list, &notifier_list);
173
174 list_for_each_entry_safe(sd, tmp, &subdev_list, async_list) { 173 list_for_each_entry_safe(sd, tmp, &subdev_list, async_list) {
175 int ret; 174 int ret;
176 175
@@ -185,6 +184,9 @@ int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev,
185 } 184 }
186 } 185 }
187 186
187 /* Keep also completed notifiers on the list */
188 list_add(&notifier->list, &notifier_list);
189
188 mutex_unlock(&list_lock); 190 mutex_unlock(&list_lock);
189 191
190 return 0; 192 return 0;
@@ -202,7 +204,7 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
202 if (!notifier->v4l2_dev) 204 if (!notifier->v4l2_dev)
203 return; 205 return;
204 206
205 dev = kmalloc(n_subdev * sizeof(*dev), GFP_KERNEL); 207 dev = kmalloc_array(n_subdev, sizeof(*dev), GFP_KERNEL);
206 if (!dev) { 208 if (!dev) {
207 dev_err(notifier->v4l2_dev->dev, 209 dev_err(notifier->v4l2_dev->dev,
208 "Failed to allocate device cache!\n"); 210 "Failed to allocate device cache!\n");
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index 47001e25fd9e..b9e08e3d6e0e 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -3367,6 +3367,9 @@ static void v4l2_ctrl_del_event(struct v4l2_subscribed_event *sev)
3367{ 3367{
3368 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id); 3368 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id);
3369 3369
3370 if (ctrl == NULL)
3371 return;
3372
3370 v4l2_ctrl_lock(ctrl); 3373 v4l2_ctrl_lock(ctrl);
3371 list_del(&sev->node); 3374 list_del(&sev->node);
3372 v4l2_ctrl_unlock(ctrl); 3375 v4l2_ctrl_unlock(ctrl);
diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
index 62bbed76dbbc..f364cc1b521d 100644
--- a/drivers/media/v4l2-core/v4l2-device.c
+++ b/drivers/media/v4l2-core/v4l2-device.c
@@ -253,6 +253,7 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev)
253 kfree(vdev); 253 kfree(vdev);
254 goto clean_up; 254 goto clean_up;
255 } 255 }
256 sd->devnode = vdev;
256#if defined(CONFIG_MEDIA_CONTROLLER) 257#if defined(CONFIG_MEDIA_CONTROLLER)
257 sd->entity.info.dev.major = VIDEO_MAJOR; 258 sd->entity.info.dev.major = VIDEO_MAJOR;
258 sd->entity.info.dev.minor = vdev->minor; 259 sd->entity.info.dev.minor = vdev->minor;
@@ -270,7 +271,6 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev)
270 } 271 }
271 } 272 }
272#endif 273#endif
273 sd->devnode = vdev;
274 } 274 }
275 return 0; 275 return 0;
276 276
diff --git a/drivers/media/v4l2-core/v4l2-event.c b/drivers/media/v4l2-core/v4l2-event.c
index 8d3171c6bee8..a75df6cb141f 100644
--- a/drivers/media/v4l2-core/v4l2-event.c
+++ b/drivers/media/v4l2-core/v4l2-event.c
@@ -15,11 +15,6 @@
15 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details. 17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301 USA
23 */ 18 */
24 19
25#include <media/v4l2-dev.h> 20#include <media/v4l2-dev.h>
diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c
index c183f0996fa1..3895999bf880 100644
--- a/drivers/media/v4l2-core/v4l2-fh.c
+++ b/drivers/media/v4l2-core/v4l2-fh.c
@@ -15,11 +15,6 @@
15 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details. 17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301 USA
23 */ 18 */
24 19
25#include <linux/bitops.h> 20#include <linux/bitops.h>
diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c
index 8bef4331bd51..303980b71aae 100644
--- a/drivers/media/v4l2-core/v4l2-mc.c
+++ b/drivers/media/v4l2-core/v4l2-mc.c
@@ -198,14 +198,20 @@ EXPORT_SYMBOL_GPL(v4l2_mc_create_media_graph);
198int v4l_enable_media_source(struct video_device *vdev) 198int v4l_enable_media_source(struct video_device *vdev)
199{ 199{
200 struct media_device *mdev = vdev->entity.graph_obj.mdev; 200 struct media_device *mdev = vdev->entity.graph_obj.mdev;
201 int ret; 201 int ret = 0, err;
202 202
203 if (!mdev || !mdev->enable_source) 203 if (!mdev)
204 return 0; 204 return 0;
205 ret = mdev->enable_source(&vdev->entity, &vdev->pipe); 205
206 if (ret) 206 mutex_lock(&mdev->graph_mutex);
207 return -EBUSY; 207 if (!mdev->enable_source)
208 return 0; 208 goto end;
209 err = mdev->enable_source(&vdev->entity, &vdev->pipe);
210 if (err)
211 ret = -EBUSY;
212end:
213 mutex_unlock(&mdev->graph_mutex);
214 return ret;
209} 215}
210EXPORT_SYMBOL_GPL(v4l_enable_media_source); 216EXPORT_SYMBOL_GPL(v4l_enable_media_source);
211 217
@@ -213,8 +219,12 @@ void v4l_disable_media_source(struct video_device *vdev)
213{ 219{
214 struct media_device *mdev = vdev->entity.graph_obj.mdev; 220 struct media_device *mdev = vdev->entity.graph_obj.mdev;
215 221
216 if (mdev && mdev->disable_source) 222 if (mdev) {
217 mdev->disable_source(&vdev->entity); 223 mutex_lock(&mdev->graph_mutex);
224 if (mdev->disable_source)
225 mdev->disable_source(&vdev->entity);
226 mutex_unlock(&mdev->graph_mutex);
227 }
218} 228}
219EXPORT_SYMBOL_GPL(v4l_disable_media_source); 229EXPORT_SYMBOL_GPL(v4l_disable_media_source);
220 230
@@ -256,13 +266,13 @@ EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_source);
256 * Return the total number of users of all video device nodes in the pipeline. 266 * Return the total number of users of all video device nodes in the pipeline.
257 */ 267 */
258static int pipeline_pm_use_count(struct media_entity *entity, 268static int pipeline_pm_use_count(struct media_entity *entity,
259 struct media_entity_graph *graph) 269 struct media_graph *graph)
260{ 270{
261 int use = 0; 271 int use = 0;
262 272
263 media_entity_graph_walk_start(graph, entity); 273 media_graph_walk_start(graph, entity);
264 274
265 while ((entity = media_entity_graph_walk_next(graph))) { 275 while ((entity = media_graph_walk_next(graph))) {
266 if (is_media_entity_v4l2_video_device(entity)) 276 if (is_media_entity_v4l2_video_device(entity))
267 use += entity->use_count; 277 use += entity->use_count;
268 } 278 }
@@ -315,7 +325,7 @@ static int pipeline_pm_power_one(struct media_entity *entity, int change)
315 * Return 0 on success or a negative error code on failure. 325 * Return 0 on success or a negative error code on failure.
316 */ 326 */
317static int pipeline_pm_power(struct media_entity *entity, int change, 327static int pipeline_pm_power(struct media_entity *entity, int change,
318 struct media_entity_graph *graph) 328 struct media_graph *graph)
319{ 329{
320 struct media_entity *first = entity; 330 struct media_entity *first = entity;
321 int ret = 0; 331 int ret = 0;
@@ -323,18 +333,18 @@ static int pipeline_pm_power(struct media_entity *entity, int change,
323 if (!change) 333 if (!change)
324 return 0; 334 return 0;
325 335
326 media_entity_graph_walk_start(graph, entity); 336 media_graph_walk_start(graph, entity);
327 337
328 while (!ret && (entity = media_entity_graph_walk_next(graph))) 338 while (!ret && (entity = media_graph_walk_next(graph)))
329 if (is_media_entity_v4l2_subdev(entity)) 339 if (is_media_entity_v4l2_subdev(entity))
330 ret = pipeline_pm_power_one(entity, change); 340 ret = pipeline_pm_power_one(entity, change);
331 341
332 if (!ret) 342 if (!ret)
333 return ret; 343 return ret;
334 344
335 media_entity_graph_walk_start(graph, first); 345 media_graph_walk_start(graph, first);
336 346
337 while ((first = media_entity_graph_walk_next(graph)) 347 while ((first = media_graph_walk_next(graph))
338 && first != entity) 348 && first != entity)
339 if (is_media_entity_v4l2_subdev(first)) 349 if (is_media_entity_v4l2_subdev(first))
340 pipeline_pm_power_one(first, -change); 350 pipeline_pm_power_one(first, -change);
@@ -368,7 +378,7 @@ EXPORT_SYMBOL_GPL(v4l2_pipeline_pm_use);
368int v4l2_pipeline_link_notify(struct media_link *link, u32 flags, 378int v4l2_pipeline_link_notify(struct media_link *link, u32 flags,
369 unsigned int notification) 379 unsigned int notification)
370{ 380{
371 struct media_entity_graph *graph = &link->graph_obj.mdev->pm_count_walk; 381 struct media_graph *graph = &link->graph_obj.mdev->pm_count_walk;
372 struct media_entity *source = link->source->entity; 382 struct media_entity *source = link->source->entity;
373 struct media_entity *sink = link->sink->entity; 383 struct media_entity *sink = link->sink->entity;
374 int source_use; 384 int source_use;
diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c
index 93b33681776c..4f59f442dd0a 100644
--- a/drivers/media/v4l2-core/v4l2-of.c
+++ b/drivers/media/v4l2-core/v4l2-of.c
@@ -26,7 +26,7 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node,
26 struct v4l2_of_bus_mipi_csi2 *bus = &endpoint->bus.mipi_csi2; 26 struct v4l2_of_bus_mipi_csi2 *bus = &endpoint->bus.mipi_csi2;
27 struct property *prop; 27 struct property *prop;
28 bool have_clk_lane = false; 28 bool have_clk_lane = false;
29 unsigned int flags = 0; 29 unsigned int flags = 0, lanes_used = 0;
30 u32 v; 30 u32 v;
31 31
32 prop = of_find_property(node, "data-lanes", NULL); 32 prop = of_find_property(node, "data-lanes", NULL);
@@ -38,6 +38,12 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node,
38 lane = of_prop_next_u32(prop, lane, &v); 38 lane = of_prop_next_u32(prop, lane, &v);
39 if (!lane) 39 if (!lane)
40 break; 40 break;
41
42 if (lanes_used & BIT(v))
43 pr_warn("%s: duplicated lane %u in data-lanes\n",
44 node->full_name, v);
45 lanes_used |= BIT(v);
46
41 bus->data_lanes[i] = v; 47 bus->data_lanes[i] = v;
42 } 48 }
43 bus->num_data_lanes = i; 49 bus->num_data_lanes = i;
@@ -63,6 +69,11 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node,
63 } 69 }
64 70
65 if (!of_property_read_u32(node, "clock-lanes", &v)) { 71 if (!of_property_read_u32(node, "clock-lanes", &v)) {
72 if (lanes_used & BIT(v))
73 pr_warn("%s: duplicated lane %u in clock-lanes\n",
74 node->full_name, v);
75 lanes_used |= BIT(v);
76
66 bus->clock_lane = v; 77 bus->clock_lane = v;
67 have_clk_lane = true; 78 have_clk_lane = true;
68 } 79 }
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 34a1e7c8b306..da78497ae5ed 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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 */ 17 */
22 18
23#include <linux/ioctl.h> 19#include <linux/ioctl.h>
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c
index c27d7e9a1bdb..8b2117ee0f60 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c
@@ -129,7 +129,7 @@ __vpfe_video_get_format(struct vpfe_video_device *video,
129/* make a note of pipeline details */ 129/* make a note of pipeline details */
130static int vpfe_prepare_pipeline(struct vpfe_video_device *video) 130static int vpfe_prepare_pipeline(struct vpfe_video_device *video)
131{ 131{
132 struct media_entity_graph graph; 132 struct media_graph graph;
133 struct media_entity *entity = &video->video_dev.entity; 133 struct media_entity *entity = &video->video_dev.entity;
134 struct media_device *mdev = entity->graph_obj.mdev; 134 struct media_device *mdev = entity->graph_obj.mdev;
135 struct vpfe_pipeline *pipe = &video->pipe; 135 struct vpfe_pipeline *pipe = &video->pipe;
@@ -145,13 +145,13 @@ static int vpfe_prepare_pipeline(struct vpfe_video_device *video)
145 pipe->outputs[pipe->output_num++] = video; 145 pipe->outputs[pipe->output_num++] = video;
146 146
147 mutex_lock(&mdev->graph_mutex); 147 mutex_lock(&mdev->graph_mutex);
148 ret = media_entity_graph_walk_init(&graph, entity->graph_obj.mdev); 148 ret = media_graph_walk_init(&graph, mdev);
149 if (ret) { 149 if (ret) {
150 mutex_unlock(&mdev->graph_mutex); 150 mutex_unlock(&mdev->graph_mutex);
151 return -ENOMEM; 151 return -ENOMEM;
152 } 152 }
153 media_entity_graph_walk_start(&graph, entity); 153 media_graph_walk_start(&graph, entity);
154 while ((entity = media_entity_graph_walk_next(&graph))) { 154 while ((entity = media_graph_walk_next(&graph))) {
155 if (entity == &video->video_dev.entity) 155 if (entity == &video->video_dev.entity)
156 continue; 156 continue;
157 if (!is_media_entity_v4l2_video_device(entity)) 157 if (!is_media_entity_v4l2_video_device(entity))
@@ -162,7 +162,7 @@ static int vpfe_prepare_pipeline(struct vpfe_video_device *video)
162 else 162 else
163 pipe->outputs[pipe->output_num++] = far_end; 163 pipe->outputs[pipe->output_num++] = far_end;
164 } 164 }
165 media_entity_graph_walk_cleanup(&graph); 165 media_graph_walk_cleanup(&graph);
166 mutex_unlock(&mdev->graph_mutex); 166 mutex_unlock(&mdev->graph_mutex);
167 167
168 return 0; 168 return 0;
@@ -300,12 +300,11 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe)
300 300
301 mdev = entity->graph_obj.mdev; 301 mdev = entity->graph_obj.mdev;
302 mutex_lock(&mdev->graph_mutex); 302 mutex_lock(&mdev->graph_mutex);
303 ret = media_entity_graph_walk_init(&pipe->graph, 303 ret = media_graph_walk_init(&pipe->graph, mdev);
304 entity->graph_obj.mdev);
305 if (ret) 304 if (ret)
306 goto out; 305 goto out;
307 media_entity_graph_walk_start(&pipe->graph, entity); 306 media_graph_walk_start(&pipe->graph, entity);
308 while ((entity = media_entity_graph_walk_next(&pipe->graph))) { 307 while ((entity = media_graph_walk_next(&pipe->graph))) {
309 308
310 if (!is_media_entity_v4l2_subdev(entity)) 309 if (!is_media_entity_v4l2_subdev(entity))
311 continue; 310 continue;
@@ -316,7 +315,7 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe)
316 } 315 }
317out: 316out:
318 if (ret) 317 if (ret)
319 media_entity_graph_walk_cleanup(&pipe->graph); 318 media_graph_walk_cleanup(&pipe->graph);
320 mutex_unlock(&mdev->graph_mutex); 319 mutex_unlock(&mdev->graph_mutex);
321 return ret; 320 return ret;
322} 321}
@@ -346,9 +345,9 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe)
346 345
347 mdev = entity->graph_obj.mdev; 346 mdev = entity->graph_obj.mdev;
348 mutex_lock(&mdev->graph_mutex); 347 mutex_lock(&mdev->graph_mutex);
349 media_entity_graph_walk_start(&pipe->graph, entity); 348 media_graph_walk_start(&pipe->graph, entity);
350 349
351 while ((entity = media_entity_graph_walk_next(&pipe->graph))) { 350 while ((entity = media_graph_walk_next(&pipe->graph))) {
352 351
353 if (!is_media_entity_v4l2_subdev(entity)) 352 if (!is_media_entity_v4l2_subdev(entity))
354 continue; 353 continue;
@@ -359,7 +358,7 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe)
359 } 358 }
360 mutex_unlock(&mdev->graph_mutex); 359 mutex_unlock(&mdev->graph_mutex);
361 360
362 media_entity_graph_walk_cleanup(&pipe->graph); 361 media_graph_walk_cleanup(&pipe->graph);
363 return ret ? -ETIMEDOUT : 0; 362 return ret ? -ETIMEDOUT : 0;
364} 363}
365 364
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.h b/drivers/staging/media/davinci_vpfe/vpfe_video.h
index aaec4403df3b..22136d3dadcb 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.h
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.h
@@ -52,7 +52,7 @@ enum vpfe_video_state {
52struct vpfe_pipeline { 52struct vpfe_pipeline {
53 /* media pipeline */ 53 /* media pipeline */
54 struct media_pipeline *pipe; 54 struct media_pipeline *pipe;
55 struct media_entity_graph graph; 55 struct media_graph graph;
56 /* state of the pipeline, continuous, 56 /* state of the pipeline, continuous,
57 * single-shot or stopped 57 * single-shot or stopped
58 */ 58 */
diff --git a/drivers/staging/media/lirc/Kconfig b/drivers/staging/media/lirc/Kconfig
index 25b7e7ccf554..bc67da254262 100644
--- a/drivers/staging/media/lirc/Kconfig
+++ b/drivers/staging/media/lirc/Kconfig
@@ -12,26 +12,6 @@ menuconfig LIRC_STAGING
12 12
13if LIRC_STAGING 13if LIRC_STAGING
14 14
15config LIRC_BT829
16 tristate "BT829 based hardware"
17 depends on LIRC && PCI
18 help
19 Driver for the IR interface on BT829-based hardware
20
21config LIRC_IMON
22 tristate "Legacy SoundGraph iMON Receiver and Display"
23 depends on LIRC && USB
24 help
25 Driver for the original SoundGraph iMON IR Receiver and Display
26
27 Current generation iMON devices use the input layer imon driver.
28
29config LIRC_PARALLEL
30 tristate "Homebrew Parallel Port Receiver"
31 depends on LIRC && PARPORT
32 help
33 Driver for Homebrew Parallel Port Receivers
34
35config LIRC_SASEM 15config LIRC_SASEM
36 tristate "Sasem USB IR Remote" 16 tristate "Sasem USB IR Remote"
37 depends on LIRC && USB 17 depends on LIRC && USB
@@ -40,7 +20,7 @@ config LIRC_SASEM
40 20
41config LIRC_SIR 21config LIRC_SIR
42 tristate "Built-in SIR IrDA port" 22 tristate "Built-in SIR IrDA port"
43 depends on LIRC 23 depends on RC_CORE
44 help 24 help
45 Driver for the SIR IrDA port 25 Driver for the SIR IrDA port
46 26
diff --git a/drivers/staging/media/lirc/Makefile b/drivers/staging/media/lirc/Makefile
index 7f919eab1989..28740c94349c 100644
--- a/drivers/staging/media/lirc/Makefile
+++ b/drivers/staging/media/lirc/Makefile
@@ -3,9 +3,6 @@
3 3
4# Each configuration option enables a list of files. 4# Each configuration option enables a list of files.
5 5
6obj-$(CONFIG_LIRC_BT829) += lirc_bt829.o
7obj-$(CONFIG_LIRC_IMON) += lirc_imon.o
8obj-$(CONFIG_LIRC_PARALLEL) += lirc_parallel.o
9obj-$(CONFIG_LIRC_SASEM) += lirc_sasem.o 6obj-$(CONFIG_LIRC_SASEM) += lirc_sasem.o
10obj-$(CONFIG_LIRC_SIR) += lirc_sir.o 7obj-$(CONFIG_LIRC_SIR) += lirc_sir.o
11obj-$(CONFIG_LIRC_ZILOG) += lirc_zilog.o 8obj-$(CONFIG_LIRC_ZILOG) += lirc_zilog.o
diff --git a/drivers/staging/media/lirc/lirc_bt829.c b/drivers/staging/media/lirc/lirc_bt829.c
deleted file mode 100644
index 04d881b391c7..000000000000
--- a/drivers/staging/media/lirc/lirc_bt829.c
+++ /dev/null
@@ -1,401 +0,0 @@
1/*
2 * Remote control driver for the TV-card based on bt829
3 *
4 * by Leonid Froenchenko <lfroen@galileo.co.il>
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 as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19*/
20
21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22
23#include <linux/kernel.h>
24#include <linux/module.h>
25#include <linux/threads.h>
26#include <linux/sched.h>
27#include <linux/ioport.h>
28#include <linux/pci.h>
29#include <linux/delay.h>
30
31#include <media/lirc_dev.h>
32
33static int poll_main(void);
34static int atir_init_start(void);
35
36static void write_index(unsigned char index, unsigned int value);
37static unsigned int read_index(unsigned char index);
38
39static void do_i2c_start(void);
40static void do_i2c_stop(void);
41
42static void seems_wr_byte(unsigned char al);
43static unsigned char seems_rd_byte(void);
44
45static unsigned int read_index(unsigned char al);
46static void write_index(unsigned char ah, unsigned int edx);
47
48static void cycle_delay(int cycle);
49
50static void do_set_bits(unsigned char bl);
51static unsigned char do_get_bits(void);
52
53#define DATA_PCI_OFF 0x7FFC00
54#define WAIT_CYCLE 20
55
56#define DRIVER_NAME "lirc_bt829"
57
58static bool debug;
59
60static int atir_minor;
61static phys_addr_t pci_addr_phys;
62static unsigned char __iomem *pci_addr_lin;
63
64static struct lirc_driver atir_driver;
65
66static struct pci_dev *do_pci_probe(void)
67{
68 struct pci_dev *my_dev;
69
70 my_dev = pci_get_device(PCI_VENDOR_ID_ATI,
71 PCI_DEVICE_ID_ATI_264VT, NULL);
72 if (my_dev) {
73 pr_err("Using device: %s\n", pci_name(my_dev));
74 pci_addr_phys = 0;
75 if (my_dev->resource[0].flags & IORESOURCE_MEM) {
76 pci_addr_phys = my_dev->resource[0].start;
77 pr_info("memory at %pa\n", &pci_addr_phys);
78 }
79 if (pci_addr_phys == 0) {
80 pr_err("no memory resource ?\n");
81 pci_dev_put(my_dev);
82 return NULL;
83 }
84 } else {
85 pr_err("pci_probe failed\n");
86 return NULL;
87 }
88 return my_dev;
89}
90
91static int atir_add_to_buf(void *data, struct lirc_buffer *buf)
92{
93 unsigned char key;
94 int status;
95
96 status = poll_main();
97 key = (status >> 8) & 0xFF;
98 if (status & 0xFF) {
99 dev_dbg(atir_driver.dev, "reading key %02X\n", key);
100 lirc_buffer_write(buf, &key);
101 return 0;
102 }
103 return -ENODATA;
104}
105
106static int atir_set_use_inc(void *data)
107{
108 dev_dbg(atir_driver.dev, "driver is opened\n");
109 return 0;
110}
111
112static void atir_set_use_dec(void *data)
113{
114 dev_dbg(atir_driver.dev, "driver is closed\n");
115}
116
117int init_module(void)
118{
119 struct pci_dev *pdev;
120 int rc;
121
122 pdev = do_pci_probe();
123 if (!pdev)
124 return -ENODEV;
125
126 rc = pci_enable_device(pdev);
127 if (rc)
128 goto err_put_dev;
129
130 if (!atir_init_start()) {
131 rc = -ENODEV;
132 goto err_disable;
133 }
134
135 strcpy(atir_driver.name, "ATIR");
136 atir_driver.minor = -1;
137 atir_driver.code_length = 8;
138 atir_driver.sample_rate = 10;
139 atir_driver.data = NULL;
140 atir_driver.add_to_buf = atir_add_to_buf;
141 atir_driver.set_use_inc = atir_set_use_inc;
142 atir_driver.set_use_dec = atir_set_use_dec;
143 atir_driver.dev = &pdev->dev;
144 atir_driver.owner = THIS_MODULE;
145
146 atir_minor = lirc_register_driver(&atir_driver);
147 if (atir_minor < 0) {
148 pr_err("failed to register driver!\n");
149 rc = atir_minor;
150 goto err_unmap;
151 }
152 dev_dbg(atir_driver.dev, "driver is registered on minor %d\n",
153 atir_minor);
154
155 return 0;
156
157err_unmap:
158 iounmap(pci_addr_lin);
159err_disable:
160 pci_disable_device(pdev);
161err_put_dev:
162 pci_dev_put(pdev);
163 return rc;
164}
165
166void cleanup_module(void)
167{
168 struct pci_dev *pdev = to_pci_dev(atir_driver.dev);
169
170 lirc_unregister_driver(atir_minor);
171 iounmap(pci_addr_lin);
172 pci_disable_device(pdev);
173 pci_dev_put(pdev);
174}
175
176static int atir_init_start(void)
177{
178 pci_addr_lin = ioremap(pci_addr_phys + DATA_PCI_OFF, 0x400);
179 if (!pci_addr_lin) {
180 pr_info("pci mem must be mapped\n");
181 return 0;
182 }
183 return 1;
184}
185
186static void cycle_delay(int cycle)
187{
188 udelay(WAIT_CYCLE * cycle);
189}
190
191static int poll_main(void)
192{
193 unsigned char status_high, status_low;
194
195 do_i2c_start();
196
197 seems_wr_byte(0xAA);
198 seems_wr_byte(0x01);
199
200 do_i2c_start();
201
202 seems_wr_byte(0xAB);
203
204 status_low = seems_rd_byte();
205 status_high = seems_rd_byte();
206
207 do_i2c_stop();
208
209 return (status_high << 8) | status_low;
210}
211
212static void do_i2c_start(void)
213{
214 do_set_bits(3);
215 cycle_delay(4);
216
217 do_set_bits(1);
218 cycle_delay(7);
219
220 do_set_bits(0);
221 cycle_delay(2);
222}
223
224static void do_i2c_stop(void)
225{
226 unsigned char bits;
227
228 bits = do_get_bits() & 0xFD;
229 do_set_bits(bits);
230 cycle_delay(1);
231
232 bits |= 1;
233 do_set_bits(bits);
234 cycle_delay(2);
235
236 bits |= 2;
237 do_set_bits(bits);
238 bits = 3;
239 do_set_bits(bits);
240 cycle_delay(2);
241}
242
243static void seems_wr_byte(unsigned char value)
244{
245 int i;
246 unsigned char reg;
247
248 reg = do_get_bits();
249 for (i = 0; i < 8; i++) {
250 if (value & 0x80)
251 reg |= 0x02;
252 else
253 reg &= 0xFD;
254
255 do_set_bits(reg);
256 cycle_delay(1);
257
258 reg |= 1;
259 do_set_bits(reg);
260 cycle_delay(1);
261
262 reg &= 0xFE;
263 do_set_bits(reg);
264 cycle_delay(1);
265 value <<= 1;
266 }
267 cycle_delay(2);
268
269 reg |= 2;
270 do_set_bits(reg);
271
272 reg |= 1;
273 do_set_bits(reg);
274
275 cycle_delay(1);
276 do_get_bits();
277
278 reg &= 0xFE;
279 do_set_bits(reg);
280 cycle_delay(3);
281}
282
283static unsigned char seems_rd_byte(void)
284{
285 int i;
286 int rd_byte;
287 unsigned char bits_2, bits_1;
288
289 bits_1 = do_get_bits() | 2;
290 do_set_bits(bits_1);
291
292 rd_byte = 0;
293 for (i = 0; i < 8; i++) {
294 bits_1 &= 0xFE;
295 do_set_bits(bits_1);
296 cycle_delay(2);
297
298 bits_1 |= 1;
299 do_set_bits(bits_1);
300 cycle_delay(1);
301
302 bits_2 = do_get_bits();
303 if (bits_2 & 2)
304 rd_byte |= 1;
305
306 rd_byte <<= 1;
307 }
308
309 bits_1 = 0;
310 if (bits_2 == 0)
311 bits_1 |= 2;
312
313 do_set_bits(bits_1);
314 cycle_delay(2);
315
316 bits_1 |= 1;
317 do_set_bits(bits_1);
318 cycle_delay(3);
319
320 bits_1 &= 0xFE;
321 do_set_bits(bits_1);
322 cycle_delay(2);
323
324 rd_byte >>= 1;
325 rd_byte &= 0xFF;
326 return rd_byte;
327}
328
329static void do_set_bits(unsigned char new_bits)
330{
331 int reg_val;
332
333 reg_val = read_index(0x34);
334 if (new_bits & 2) {
335 reg_val &= 0xFFFFFFDF;
336 reg_val |= 1;
337 } else {
338 reg_val &= 0xFFFFFFFE;
339 reg_val |= 0x20;
340 }
341 reg_val |= 0x10;
342 write_index(0x34, reg_val);
343
344 reg_val = read_index(0x31);
345 if (new_bits & 1)
346 reg_val |= 0x1000000;
347 else
348 reg_val &= 0xFEFFFFFF;
349
350 reg_val |= 0x8000000;
351 write_index(0x31, reg_val);
352}
353
354static unsigned char do_get_bits(void)
355{
356 unsigned char bits;
357 int reg_val;
358
359 reg_val = read_index(0x34);
360 reg_val |= 0x10;
361 reg_val &= 0xFFFFFFDF;
362 write_index(0x34, reg_val);
363
364 reg_val = read_index(0x34);
365 bits = 0;
366 if (reg_val & 8)
367 bits |= 2;
368 else
369 bits &= 0xFD;
370
371 reg_val = read_index(0x31);
372 if (reg_val & 0x1000000)
373 bits |= 1;
374 else
375 bits &= 0xFE;
376
377 return bits;
378}
379
380static unsigned int read_index(unsigned char index)
381{
382 unsigned char __iomem *addr;
383 /* addr = pci_addr_lin + DATA_PCI_OFF + ((index & 0xFF) << 2); */
384 addr = pci_addr_lin + ((index & 0xFF) << 2);
385 return readl(addr);
386}
387
388static void write_index(unsigned char index, unsigned int reg_val)
389{
390 unsigned char __iomem *addr;
391
392 addr = pci_addr_lin + ((index & 0xFF) << 2);
393 writel(reg_val, addr);
394}
395
396MODULE_AUTHOR("Froenchenko Leonid");
397MODULE_DESCRIPTION("IR remote driver for bt829 based TV cards");
398MODULE_LICENSE("GPL");
399
400module_param(debug, bool, S_IRUGO | S_IWUSR);
401MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/staging/media/lirc/lirc_imon.c b/drivers/staging/media/lirc/lirc_imon.c
deleted file mode 100644
index 1e650fba4a92..000000000000
--- a/drivers/staging/media/lirc/lirc_imon.c
+++ /dev/null
@@ -1,979 +0,0 @@
1/*
2 * lirc_imon.c: LIRC/VFD/LCD driver for SoundGraph iMON IR/VFD/LCD
3 * including the iMON PAD model
4 *
5 * Copyright(C) 2004 Venky Raju(dev@venky.ws)
6 * Copyright(C) 2009 Jarod Wilson <jarod@wilsonet.com>
7 *
8 * lirc_imon is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (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 General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
24
25#include <linux/errno.h>
26#include <linux/kernel.h>
27#include <linux/module.h>
28#include <linux/slab.h>
29#include <linux/uaccess.h>
30#include <linux/usb.h>
31
32#include <media/lirc.h>
33#include <media/lirc_dev.h>
34
35#define MOD_AUTHOR "Venky Raju <dev@venky.ws>"
36#define MOD_DESC "Driver for SoundGraph iMON MultiMedia IR/Display"
37#define MOD_NAME "lirc_imon"
38#define MOD_VERSION "0.8"
39
40#define DISPLAY_MINOR_BASE 144
41#define DEVICE_NAME "lcd%d"
42
43#define BUF_CHUNK_SIZE 4
44#define BUF_SIZE 128
45
46#define BIT_DURATION 250 /* each bit received is 250us */
47
48/*** P R O T O T Y P E S ***/
49
50/* USB Callback prototypes */
51static int imon_probe(struct usb_interface *interface,
52 const struct usb_device_id *id);
53static void imon_disconnect(struct usb_interface *interface);
54static void usb_rx_callback(struct urb *urb);
55static void usb_tx_callback(struct urb *urb);
56
57/* suspend/resume support */
58static int imon_resume(struct usb_interface *intf);
59static int imon_suspend(struct usb_interface *intf, pm_message_t message);
60
61/* Display file_operations function prototypes */
62static int display_open(struct inode *inode, struct file *file);
63static int display_close(struct inode *inode, struct file *file);
64
65/* VFD write operation */
66static ssize_t vfd_write(struct file *file, const char __user *buf,
67 size_t n_bytes, loff_t *pos);
68
69/* LIRC driver function prototypes */
70static int ir_open(void *data);
71static void ir_close(void *data);
72
73/*** G L O B A L S ***/
74#define IMON_DATA_BUF_SZ 35
75
76struct imon_context {
77 struct usb_device *usbdev;
78 /* Newer devices have two interfaces */
79 int display; /* not all controllers do */
80 int display_isopen; /* display port has been opened */
81 int ir_isopen; /* IR port open */
82 int dev_present; /* USB device presence */
83 struct mutex ctx_lock; /* to lock this object */
84 wait_queue_head_t remove_ok; /* For unexpected USB disconnects */
85
86 int vfd_proto_6p; /* some VFD require a 6th packet */
87
88 struct lirc_driver *driver;
89 struct usb_endpoint_descriptor *rx_endpoint;
90 struct usb_endpoint_descriptor *tx_endpoint;
91 struct urb *rx_urb;
92 struct urb *tx_urb;
93 unsigned char usb_rx_buf[8];
94 unsigned char usb_tx_buf[8];
95
96 struct rx_data {
97 int count; /* length of 0 or 1 sequence */
98 int prev_bit; /* logic level of sequence */
99 int initial_space; /* initial space flag */
100 } rx;
101
102 struct tx_t {
103 unsigned char data_buf[IMON_DATA_BUF_SZ]; /* user data buffer */
104 struct completion finished; /* wait for write to finish */
105 atomic_t busy; /* write in progress */
106 int status; /* status of tx completion */
107 } tx;
108};
109
110static const struct file_operations display_fops = {
111 .owner = THIS_MODULE,
112 .open = &display_open,
113 .write = &vfd_write,
114 .release = &display_close,
115 .llseek = noop_llseek,
116};
117
118/*
119 * USB Device ID for iMON USB Control Boards
120 *
121 * The Windows drivers contain 6 different inf files, more or less one for
122 * each new device until the 0x0034-0x0046 devices, which all use the same
123 * driver. Some of the devices in the 34-46 range haven't been definitively
124 * identified yet. Early devices have either a TriGem Computer, Inc. or a
125 * Samsung vendor ID (0x0aa8 and 0x04e8 respectively), while all later
126 * devices use the SoundGraph vendor ID (0x15c2).
127 */
128static struct usb_device_id imon_usb_id_table[] = {
129 /* TriGem iMON (IR only) -- TG_iMON.inf */
130 { USB_DEVICE(0x0aa8, 0x8001) },
131
132 /* SoundGraph iMON (IR only) -- sg_imon.inf */
133 { USB_DEVICE(0x04e8, 0xff30) },
134
135 /* SoundGraph iMON VFD (IR & VFD) -- iMON_VFD.inf */
136 { USB_DEVICE(0x0aa8, 0xffda) },
137
138 /* SoundGraph iMON SS (IR & VFD) -- iMON_SS.inf */
139 { USB_DEVICE(0x15c2, 0xffda) },
140
141 {}
142};
143
144/* Some iMON VFD models requires a 6th packet for VFD writes */
145static struct usb_device_id vfd_proto_6p_list[] = {
146 { USB_DEVICE(0x15c2, 0xffda) },
147 {}
148};
149
150/* Some iMON devices have no lcd/vfd, don't set one up */
151static struct usb_device_id ir_only_list[] = {
152 { USB_DEVICE(0x0aa8, 0x8001) },
153 { USB_DEVICE(0x04e8, 0xff30) },
154 {}
155};
156
157/* USB Device data */
158static struct usb_driver imon_driver = {
159 .name = MOD_NAME,
160 .probe = imon_probe,
161 .disconnect = imon_disconnect,
162 .suspend = imon_suspend,
163 .resume = imon_resume,
164 .id_table = imon_usb_id_table,
165};
166
167static struct usb_class_driver imon_class = {
168 .name = DEVICE_NAME,
169 .fops = &display_fops,
170 .minor_base = DISPLAY_MINOR_BASE,
171};
172
173/* to prevent races between open() and disconnect(), probing, etc */
174static DEFINE_MUTEX(driver_lock);
175
176static int debug;
177
178/*** M O D U L E C O D E ***/
179
180MODULE_AUTHOR(MOD_AUTHOR);
181MODULE_DESCRIPTION(MOD_DESC);
182MODULE_VERSION(MOD_VERSION);
183MODULE_LICENSE("GPL");
184MODULE_DEVICE_TABLE(usb, imon_usb_id_table);
185module_param(debug, int, S_IRUGO | S_IWUSR);
186MODULE_PARM_DESC(debug, "Debug messages: 0=no, 1=yes(default: no)");
187
188static void free_imon_context(struct imon_context *context)
189{
190 struct device *dev = context->driver->dev;
191
192 usb_free_urb(context->tx_urb);
193 usb_free_urb(context->rx_urb);
194 lirc_buffer_free(context->driver->rbuf);
195 kfree(context->driver->rbuf);
196 kfree(context->driver);
197 kfree(context);
198
199 dev_dbg(dev, "%s: iMON context freed\n", __func__);
200}
201
202static void deregister_from_lirc(struct imon_context *context)
203{
204 int retval;
205 int minor = context->driver->minor;
206
207 retval = lirc_unregister_driver(minor);
208 if (retval)
209 dev_err(&context->usbdev->dev,
210 "unable to deregister from lirc(%d)", retval);
211 else
212 dev_info(&context->usbdev->dev,
213 "Deregistered iMON driver (minor:%d)\n", minor);
214}
215
216/**
217 * Called when the Display device (e.g. /dev/lcd0)
218 * is opened by the application.
219 */
220static int display_open(struct inode *inode, struct file *file)
221{
222 struct usb_interface *interface;
223 struct imon_context *context = NULL;
224 int subminor;
225 int retval = 0;
226
227 /* prevent races with disconnect */
228 mutex_lock(&driver_lock);
229
230 subminor = iminor(inode);
231 interface = usb_find_interface(&imon_driver, subminor);
232 if (!interface) {
233 pr_err("%s: could not find interface for minor %d\n",
234 __func__, subminor);
235 retval = -ENODEV;
236 goto exit;
237 }
238 context = usb_get_intfdata(interface);
239
240 if (!context) {
241 dev_err(&interface->dev, "no context found for minor %d\n",
242 subminor);
243 retval = -ENODEV;
244 goto exit;
245 }
246
247 mutex_lock(&context->ctx_lock);
248
249 if (!context->display) {
250 dev_err(&interface->dev,
251 "%s: display not supported by device\n", __func__);
252 retval = -ENODEV;
253 } else if (context->display_isopen) {
254 dev_err(&interface->dev,
255 "%s: display port is already open\n", __func__);
256 retval = -EBUSY;
257 } else {
258 context->display_isopen = 1;
259 file->private_data = context;
260 dev_info(context->driver->dev, "display port opened\n");
261 }
262
263 mutex_unlock(&context->ctx_lock);
264
265exit:
266 mutex_unlock(&driver_lock);
267 return retval;
268}
269
270/**
271 * Called when the display device (e.g. /dev/lcd0)
272 * is closed by the application.
273 */
274static int display_close(struct inode *inode, struct file *file)
275{
276 struct imon_context *context = NULL;
277 int retval = 0;
278
279 context = file->private_data;
280
281 if (!context) {
282 pr_err("%s: no context for device\n", __func__);
283 return -ENODEV;
284 }
285
286 mutex_lock(&context->ctx_lock);
287
288 if (!context->display) {
289 dev_err(&context->usbdev->dev,
290 "%s: display not supported by device\n", __func__);
291 retval = -ENODEV;
292 } else if (!context->display_isopen) {
293 dev_err(&context->usbdev->dev,
294 "%s: display is not open\n", __func__);
295 retval = -EIO;
296 } else {
297 context->display_isopen = 0;
298 dev_info(context->driver->dev, "display port closed\n");
299 if (!context->dev_present && !context->ir_isopen) {
300 /*
301 * Device disconnected before close and IR port is not
302 * open. If IR port is open, context will be deleted by
303 * ir_close.
304 */
305 mutex_unlock(&context->ctx_lock);
306 free_imon_context(context);
307 return retval;
308 }
309 }
310
311 mutex_unlock(&context->ctx_lock);
312 return retval;
313}
314
315/**
316 * Sends a packet to the device -- this function must be called
317 * with context->ctx_lock held.
318 */
319static int send_packet(struct imon_context *context)
320{
321 unsigned int pipe;
322 int interval = 0;
323 int retval = 0;
324
325 /* Check if we need to use control or interrupt urb */
326 pipe = usb_sndintpipe(context->usbdev,
327 context->tx_endpoint->bEndpointAddress);
328 interval = context->tx_endpoint->bInterval;
329
330 usb_fill_int_urb(context->tx_urb, context->usbdev, pipe,
331 context->usb_tx_buf,
332 sizeof(context->usb_tx_buf),
333 usb_tx_callback, context, interval);
334
335 context->tx_urb->actual_length = 0;
336
337 reinit_completion(&context->tx.finished);
338 atomic_set(&context->tx.busy, 1);
339
340 retval = usb_submit_urb(context->tx_urb, GFP_KERNEL);
341 if (retval) {
342 atomic_set(&context->tx.busy, 0);
343 dev_err(&context->usbdev->dev, "error submitting urb(%d)\n",
344 retval);
345 } else {
346 /* Wait for transmission to complete (or abort) */
347 mutex_unlock(&context->ctx_lock);
348 retval = wait_for_completion_interruptible(
349 &context->tx.finished);
350 if (retval)
351 dev_err(&context->usbdev->dev,
352 "%s: task interrupted\n", __func__);
353 mutex_lock(&context->ctx_lock);
354
355 retval = context->tx.status;
356 if (retval)
357 dev_err(&context->usbdev->dev,
358 "packet tx failed (%d)\n", retval);
359 }
360
361 return retval;
362}
363
364/**
365 * Writes data to the VFD. The iMON VFD is 2x16 characters
366 * and requires data in 5 consecutive USB interrupt packets,
367 * each packet but the last carrying 7 bytes.
368 *
369 * I don't know if the VFD board supports features such as
370 * scrolling, clearing rows, blanking, etc. so at
371 * the caller must provide a full screen of data. If fewer
372 * than 32 bytes are provided spaces will be appended to
373 * generate a full screen.
374 */
375static ssize_t vfd_write(struct file *file, const char __user *buf,
376 size_t n_bytes, loff_t *pos)
377{
378 int i;
379 int offset;
380 int seq;
381 int retval = 0;
382 struct imon_context *context;
383 const unsigned char vfd_packet6[] = {
384 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF };
385 int *data_buf = NULL;
386
387 context = file->private_data;
388 if (!context) {
389 pr_err("%s: no context for device\n", __func__);
390 return -ENODEV;
391 }
392
393 mutex_lock(&context->ctx_lock);
394
395 if (!context->dev_present) {
396 dev_err(&context->usbdev->dev,
397 "%s: no iMON device present\n", __func__);
398 retval = -ENODEV;
399 goto exit;
400 }
401
402 if (n_bytes <= 0 || n_bytes > IMON_DATA_BUF_SZ - 3) {
403 dev_err(&context->usbdev->dev,
404 "%s: invalid payload size\n", __func__);
405 retval = -EINVAL;
406 goto exit;
407 }
408
409 data_buf = memdup_user(buf, n_bytes);
410 if (IS_ERR(data_buf)) {
411 mutex_unlock(&context->ctx_lock);
412 return PTR_ERR(data_buf);
413 }
414
415 memcpy(context->tx.data_buf, data_buf, n_bytes);
416
417 /* Pad with spaces */
418 for (i = n_bytes; i < IMON_DATA_BUF_SZ - 3; ++i)
419 context->tx.data_buf[i] = ' ';
420
421 for (i = IMON_DATA_BUF_SZ - 3; i < IMON_DATA_BUF_SZ; ++i)
422 context->tx.data_buf[i] = 0xFF;
423
424 offset = 0;
425 seq = 0;
426
427 do {
428 memcpy(context->usb_tx_buf, context->tx.data_buf + offset, 7);
429 context->usb_tx_buf[7] = (unsigned char)seq;
430
431 retval = send_packet(context);
432 if (retval) {
433 dev_err(&context->usbdev->dev,
434 "send packet failed for packet #%d\n",
435 seq / 2);
436 goto exit;
437 } else {
438 seq += 2;
439 offset += 7;
440 }
441
442 } while (offset < IMON_DATA_BUF_SZ);
443
444 if (context->vfd_proto_6p) {
445 /* Send packet #6 */
446 memcpy(context->usb_tx_buf, &vfd_packet6, sizeof(vfd_packet6));
447 context->usb_tx_buf[7] = (unsigned char)seq;
448 retval = send_packet(context);
449 if (retval)
450 dev_err(&context->usbdev->dev,
451 "send packet failed for packet #%d\n",
452 seq / 2);
453 }
454
455exit:
456 mutex_unlock(&context->ctx_lock);
457 kfree(data_buf);
458
459 return (!retval) ? n_bytes : retval;
460}
461
462/**
463 * Callback function for USB core API: transmit data
464 */
465static void usb_tx_callback(struct urb *urb)
466{
467 struct imon_context *context;
468
469 if (!urb)
470 return;
471 context = (struct imon_context *)urb->context;
472 if (!context)
473 return;
474
475 context->tx.status = urb->status;
476
477 /* notify waiters that write has finished */
478 atomic_set(&context->tx.busy, 0);
479 complete(&context->tx.finished);
480}
481
482/**
483 * Called by lirc_dev when the application opens /dev/lirc
484 */
485static int ir_open(void *data)
486{
487 struct imon_context *context;
488
489 /* prevent races with disconnect */
490 mutex_lock(&driver_lock);
491
492 context = data;
493
494 /* initial IR protocol decode variables */
495 context->rx.count = 0;
496 context->rx.initial_space = 1;
497 context->rx.prev_bit = 0;
498
499 init_completion(&context->tx.finished);
500
501 context->ir_isopen = 1;
502 dev_info(context->driver->dev, "IR port opened\n");
503
504 mutex_unlock(&driver_lock);
505 return 0;
506}
507
508/**
509 * Called by lirc_dev when the application closes /dev/lirc
510 */
511static void ir_close(void *data)
512{
513 struct imon_context *context;
514
515 context = data;
516 if (!context) {
517 pr_err("%s: no context for device\n", __func__);
518 return;
519 }
520
521 mutex_lock(&context->ctx_lock);
522
523 context->ir_isopen = 0;
524 dev_info(context->driver->dev, "IR port closed\n");
525
526 if (!context->dev_present) {
527 /*
528 * Device disconnected while IR port was still open. Driver
529 * was not deregistered at disconnect time, so do it now.
530 */
531 deregister_from_lirc(context);
532
533 if (!context->display_isopen) {
534 mutex_unlock(&context->ctx_lock);
535 free_imon_context(context);
536 return;
537 }
538 /*
539 * If display port is open, context will be deleted by
540 * display_close
541 */
542 }
543
544 mutex_unlock(&context->ctx_lock);
545}
546
547/**
548 * Convert bit count to time duration (in us) and submit
549 * the value to lirc_dev.
550 */
551static void submit_data(struct imon_context *context)
552{
553 unsigned char buf[4];
554 int value = context->rx.count;
555 int i;
556
557 dev_dbg(context->driver->dev, "submitting data to LIRC\n");
558
559 value *= BIT_DURATION;
560 value &= PULSE_MASK;
561 if (context->rx.prev_bit)
562 value |= PULSE_BIT;
563
564 for (i = 0; i < 4; ++i)
565 buf[i] = value >> (i * 8);
566
567 lirc_buffer_write(context->driver->rbuf, buf);
568 wake_up(&context->driver->rbuf->wait_poll);
569}
570
571/**
572 * Process the incoming packet
573 */
574static void imon_incoming_packet(struct imon_context *context,
575 struct urb *urb, int intf)
576{
577 int len = urb->actual_length;
578 unsigned char *buf = urb->transfer_buffer;
579 struct device *dev = context->driver->dev;
580 int octet, bit;
581 unsigned char mask;
582
583 /*
584 * just bail out if no listening IR client
585 */
586 if (!context->ir_isopen)
587 return;
588
589 if (len != 8) {
590 dev_warn(dev, "imon %s: invalid incoming packet size (len = %d, intf%d)\n",
591 __func__, len, intf);
592 return;
593 }
594
595 if (debug)
596 dev_info(dev, "raw packet: %*ph\n", len, buf);
597 /*
598 * Translate received data to pulse and space lengths.
599 * Received data is active low, i.e. pulses are 0 and
600 * spaces are 1.
601 *
602 * My original algorithm was essentially similar to
603 * Changwoo Ryu's with the exception that he switched
604 * the incoming bits to active high and also fed an
605 * initial space to LIRC at the start of a new sequence
606 * if the previous bit was a pulse.
607 *
608 * I've decided to adopt his algorithm.
609 */
610
611 if (buf[7] == 1 && context->rx.initial_space) {
612 /* LIRC requires a leading space */
613 context->rx.prev_bit = 0;
614 context->rx.count = 4;
615 submit_data(context);
616 context->rx.count = 0;
617 }
618
619 for (octet = 0; octet < 5; ++octet) {
620 mask = 0x80;
621 for (bit = 0; bit < 8; ++bit) {
622 int curr_bit = !(buf[octet] & mask);
623
624 if (curr_bit != context->rx.prev_bit) {
625 if (context->rx.count) {
626 submit_data(context);
627 context->rx.count = 0;
628 }
629 context->rx.prev_bit = curr_bit;
630 }
631 ++context->rx.count;
632 mask >>= 1;
633 }
634 }
635
636 if (buf[7] == 10) {
637 if (context->rx.count) {
638 submit_data(context);
639 context->rx.count = 0;
640 }
641 context->rx.initial_space = context->rx.prev_bit;
642 }
643}
644
645/**
646 * Callback function for USB core API: receive data
647 */
648static void usb_rx_callback(struct urb *urb)
649{
650 struct imon_context *context;
651 int intfnum = 0;
652
653 if (!urb)
654 return;
655
656 context = (struct imon_context *)urb->context;
657 if (!context)
658 return;
659
660 switch (urb->status) {
661 case -ENOENT: /* usbcore unlink successful! */
662 return;
663
664 case 0:
665 imon_incoming_packet(context, urb, intfnum);
666 break;
667
668 default:
669 dev_warn(context->driver->dev, "imon %s: status(%d): ignored\n",
670 __func__, urb->status);
671 break;
672 }
673
674 usb_submit_urb(context->rx_urb, GFP_ATOMIC);
675}
676
677/**
678 * Callback function for USB core API: Probe
679 */
680static int imon_probe(struct usb_interface *interface,
681 const struct usb_device_id *id)
682{
683 struct usb_device *usbdev = NULL;
684 struct usb_host_interface *iface_desc = NULL;
685 struct usb_endpoint_descriptor *rx_endpoint = NULL;
686 struct usb_endpoint_descriptor *tx_endpoint = NULL;
687 struct urb *rx_urb = NULL;
688 struct urb *tx_urb = NULL;
689 struct lirc_driver *driver = NULL;
690 struct lirc_buffer *rbuf = NULL;
691 struct device *dev = &interface->dev;
692 int ifnum;
693 int lirc_minor = 0;
694 int num_endpts;
695 int retval = -ENOMEM;
696 int display_ep_found = 0;
697 int ir_ep_found = 0;
698 int vfd_proto_6p = 0;
699 struct imon_context *context = NULL;
700 int i;
701 u16 vendor, product;
702
703 /* prevent races probing devices w/multiple interfaces */
704 mutex_lock(&driver_lock);
705
706 context = kzalloc(sizeof(*context), GFP_KERNEL);
707 if (!context)
708 goto driver_unlock;
709
710 /*
711 * Try to auto-detect the type of display if the user hasn't set
712 * it by hand via the display_type modparam. Default is VFD.
713 */
714 if (usb_match_id(interface, ir_only_list))
715 context->display = 0;
716 else
717 context->display = 1;
718
719 usbdev = usb_get_dev(interface_to_usbdev(interface));
720 iface_desc = interface->cur_altsetting;
721 num_endpts = iface_desc->desc.bNumEndpoints;
722 ifnum = iface_desc->desc.bInterfaceNumber;
723 vendor = le16_to_cpu(usbdev->descriptor.idVendor);
724 product = le16_to_cpu(usbdev->descriptor.idProduct);
725
726 dev_dbg(dev, "%s: found iMON device (%04x:%04x, intf%d)\n",
727 __func__, vendor, product, ifnum);
728
729 /*
730 * Scan the endpoint list and set:
731 * first input endpoint = IR endpoint
732 * first output endpoint = display endpoint
733 */
734 for (i = 0; i < num_endpts && !(ir_ep_found && display_ep_found); ++i) {
735 struct usb_endpoint_descriptor *ep;
736 int ep_dir;
737 int ep_type;
738
739 ep = &iface_desc->endpoint[i].desc;
740 ep_dir = ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK;
741 ep_type = usb_endpoint_type(ep);
742
743 if (!ir_ep_found &&
744 ep_dir == USB_DIR_IN &&
745 ep_type == USB_ENDPOINT_XFER_INT) {
746
747 rx_endpoint = ep;
748 ir_ep_found = 1;
749 dev_dbg(dev, "%s: found IR endpoint\n", __func__);
750
751 } else if (!display_ep_found && ep_dir == USB_DIR_OUT &&
752 ep_type == USB_ENDPOINT_XFER_INT) {
753 tx_endpoint = ep;
754 display_ep_found = 1;
755 dev_dbg(dev, "%s: found display endpoint\n", __func__);
756 }
757 }
758
759 /*
760 * Some iMON receivers have no display. Unfortunately, it seems
761 * that SoundGraph recycles device IDs between devices both with
762 * and without... :\
763 */
764 if (context->display == 0) {
765 display_ep_found = 0;
766 dev_dbg(dev, "%s: device has no display\n", __func__);
767 }
768
769 /* Input endpoint is mandatory */
770 if (!ir_ep_found) {
771 dev_err(dev, "%s: no valid input (IR) endpoint found.\n",
772 __func__);
773 retval = -ENODEV;
774 goto free_context;
775 }
776
777 /* Determine if display requires 6 packets */
778 if (display_ep_found) {
779 if (usb_match_id(interface, vfd_proto_6p_list))
780 vfd_proto_6p = 1;
781
782 dev_dbg(dev, "%s: vfd_proto_6p: %d\n",
783 __func__, vfd_proto_6p);
784 }
785
786 driver = kzalloc(sizeof(*driver), GFP_KERNEL);
787 if (!driver)
788 goto free_context;
789
790 rbuf = kmalloc(sizeof(*rbuf), GFP_KERNEL);
791 if (!rbuf)
792 goto free_driver;
793
794 if (lirc_buffer_init(rbuf, BUF_CHUNK_SIZE, BUF_SIZE)) {
795 dev_err(dev, "%s: lirc_buffer_init failed\n", __func__);
796 goto free_rbuf;
797 }
798 rx_urb = usb_alloc_urb(0, GFP_KERNEL);
799 if (!rx_urb)
800 goto free_lirc_buf;
801 tx_urb = usb_alloc_urb(0, GFP_KERNEL);
802 if (!tx_urb)
803 goto free_rx_urb;
804
805 mutex_init(&context->ctx_lock);
806 context->vfd_proto_6p = vfd_proto_6p;
807
808 strcpy(driver->name, MOD_NAME);
809 driver->minor = -1;
810 driver->code_length = BUF_CHUNK_SIZE * 8;
811 driver->sample_rate = 0;
812 driver->features = LIRC_CAN_REC_MODE2;
813 driver->data = context;
814 driver->rbuf = rbuf;
815 driver->set_use_inc = ir_open;
816 driver->set_use_dec = ir_close;
817 driver->dev = &interface->dev;
818 driver->owner = THIS_MODULE;
819
820 mutex_lock(&context->ctx_lock);
821
822 context->driver = driver;
823 /* start out in keyboard mode */
824
825 lirc_minor = lirc_register_driver(driver);
826 if (lirc_minor < 0) {
827 dev_err(dev, "%s: lirc_register_driver failed\n", __func__);
828 goto free_tx_urb;
829 }
830
831 dev_info(dev, "Registered iMON driver (lirc minor: %d)\n",
832 lirc_minor);
833
834 /* Needed while unregistering! */
835 driver->minor = lirc_minor;
836
837 context->usbdev = usbdev;
838 context->dev_present = 1;
839 context->rx_endpoint = rx_endpoint;
840 context->rx_urb = rx_urb;
841
842 /*
843 * tx is used to send characters to lcd/vfd, associate RF
844 * remotes, set IR protocol, and maybe more...
845 */
846 context->tx_endpoint = tx_endpoint;
847 context->tx_urb = tx_urb;
848
849 if (display_ep_found)
850 context->display = 1;
851
852 usb_fill_int_urb(context->rx_urb, context->usbdev,
853 usb_rcvintpipe(context->usbdev,
854 context->rx_endpoint->bEndpointAddress),
855 context->usb_rx_buf, sizeof(context->usb_rx_buf),
856 usb_rx_callback, context,
857 context->rx_endpoint->bInterval);
858
859 retval = usb_submit_urb(context->rx_urb, GFP_KERNEL);
860 if (retval) {
861 dev_err(dev, "usb_submit_urb failed for intf0 (%d)\n", retval);
862 goto unregister_lirc;
863 }
864
865 usb_set_intfdata(interface, context);
866
867 if (context->display && ifnum == 0) {
868 dev_dbg(dev, "%s: Registering iMON display with sysfs\n",
869 __func__);
870
871 if (usb_register_dev(interface, &imon_class)) {
872 /* Not a fatal error, so ignore */
873 dev_info(dev, "%s: could not get a minor number for display\n",
874 __func__);
875 }
876 }
877
878 dev_info(dev, "iMON device (%04x:%04x, intf%d) on usb<%d:%d> initialized\n",
879 vendor, product, ifnum, usbdev->bus->busnum, usbdev->devnum);
880
881 /* Everything went fine. Just unlock and return retval (with is 0) */
882 mutex_unlock(&context->ctx_lock);
883 goto driver_unlock;
884
885unregister_lirc:
886 lirc_unregister_driver(driver->minor);
887
888free_tx_urb:
889 mutex_unlock(&context->ctx_lock);
890 usb_free_urb(tx_urb);
891
892free_rx_urb:
893 usb_free_urb(rx_urb);
894
895free_lirc_buf:
896 lirc_buffer_free(rbuf);
897
898free_rbuf:
899 kfree(rbuf);
900
901free_driver:
902 kfree(driver);
903free_context:
904 kfree(context);
905 context = NULL;
906
907driver_unlock:
908 mutex_unlock(&driver_lock);
909
910 return retval;
911}
912
913/**
914 * Callback function for USB core API: disconnect
915 */
916static void imon_disconnect(struct usb_interface *interface)
917{
918 struct imon_context *context;
919 int ifnum;
920
921 /* prevent races with ir_open()/display_open() */
922 mutex_lock(&driver_lock);
923
924 context = usb_get_intfdata(interface);
925 ifnum = interface->cur_altsetting->desc.bInterfaceNumber;
926
927 mutex_lock(&context->ctx_lock);
928
929 usb_set_intfdata(interface, NULL);
930
931 /* Abort ongoing write */
932 if (atomic_read(&context->tx.busy)) {
933 usb_kill_urb(context->tx_urb);
934 complete(&context->tx.finished);
935 }
936
937 context->dev_present = 0;
938 usb_kill_urb(context->rx_urb);
939 if (context->display)
940 usb_deregister_dev(interface, &imon_class);
941
942 if (!context->ir_isopen && !context->dev_present) {
943 deregister_from_lirc(context);
944 mutex_unlock(&context->ctx_lock);
945 if (!context->display_isopen)
946 free_imon_context(context);
947 } else
948 mutex_unlock(&context->ctx_lock);
949
950 mutex_unlock(&driver_lock);
951
952 dev_info(&interface->dev, "%s: iMON device (intf%d) disconnected\n",
953 __func__, ifnum);
954}
955
956static int imon_suspend(struct usb_interface *intf, pm_message_t message)
957{
958 struct imon_context *context = usb_get_intfdata(intf);
959
960 usb_kill_urb(context->rx_urb);
961
962 return 0;
963}
964
965static int imon_resume(struct usb_interface *intf)
966{
967 struct imon_context *context = usb_get_intfdata(intf);
968
969 usb_fill_int_urb(context->rx_urb, context->usbdev,
970 usb_rcvintpipe(context->usbdev,
971 context->rx_endpoint->bEndpointAddress),
972 context->usb_rx_buf, sizeof(context->usb_rx_buf),
973 usb_rx_callback, context,
974 context->rx_endpoint->bInterval);
975
976 return usb_submit_urb(context->rx_urb, GFP_ATOMIC);
977}
978
979module_usb_driver(imon_driver);
diff --git a/drivers/staging/media/lirc/lirc_parallel.c b/drivers/staging/media/lirc/lirc_parallel.c
deleted file mode 100644
index bfb76a45bfbf..000000000000
--- a/drivers/staging/media/lirc/lirc_parallel.c
+++ /dev/null
@@ -1,741 +0,0 @@
1/*
2 * lirc_parallel.c
3 *
4 * lirc_parallel - device driver for infra-red signal receiving and
5 * transmitting unit built by the author
6 *
7 * Copyright (C) 1998 Christoph Bartelmus <lirc@bartelmus.de>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
25#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
26
27/*** Includes ***/
28
29#include <linux/module.h>
30#include <linux/sched.h>
31#include <linux/errno.h>
32#include <linux/signal.h>
33#include <linux/fs.h>
34#include <linux/kernel.h>
35#include <linux/ioport.h>
36#include <linux/ktime.h>
37#include <linux/mm.h>
38#include <linux/delay.h>
39
40#include <linux/io.h>
41#include <linux/irq.h>
42#include <linux/uaccess.h>
43#include <asm/div64.h>
44
45#include <linux/poll.h>
46#include <linux/parport.h>
47#include <linux/platform_device.h>
48
49#include <media/lirc.h>
50#include <media/lirc_dev.h>
51
52#include "lirc_parallel.h"
53
54#define LIRC_DRIVER_NAME "lirc_parallel"
55
56#ifndef LIRC_IRQ
57#define LIRC_IRQ 7
58#endif
59#ifndef LIRC_PORT
60#define LIRC_PORT 0x378
61#endif
62#ifndef LIRC_TIMER
63#define LIRC_TIMER 65536
64#endif
65
66/*** Global Variables ***/
67
68static bool debug;
69static bool check_pselecd;
70
71static unsigned int irq = LIRC_IRQ;
72static unsigned int io = LIRC_PORT;
73#ifdef LIRC_TIMER
74static unsigned int timer;
75static unsigned int default_timer = LIRC_TIMER;
76#endif
77
78#define RBUF_SIZE (256) /* this must be a power of 2 larger than 1 */
79
80static int rbuf[RBUF_SIZE];
81
82static DECLARE_WAIT_QUEUE_HEAD(lirc_wait);
83
84static unsigned int rptr;
85static unsigned int wptr;
86static unsigned int lost_irqs;
87static int is_open;
88
89static struct parport *pport;
90static struct pardevice *ppdevice;
91static int is_claimed;
92
93static unsigned int tx_mask = 1;
94
95/*** Internal Functions ***/
96
97static unsigned int in(int offset)
98{
99 switch (offset) {
100 case LIRC_LP_BASE:
101 return parport_read_data(pport);
102 case LIRC_LP_STATUS:
103 return parport_read_status(pport);
104 case LIRC_LP_CONTROL:
105 return parport_read_control(pport);
106 }
107 return 0; /* make compiler happy */
108}
109
110static void out(int offset, int value)
111{
112 switch (offset) {
113 case LIRC_LP_BASE:
114 parport_write_data(pport, value);
115 break;
116 case LIRC_LP_CONTROL:
117 parport_write_control(pport, value);
118 break;
119 case LIRC_LP_STATUS:
120 pr_info("attempt to write to status register\n");
121 break;
122 }
123}
124
125static unsigned int lirc_get_timer(void)
126{
127 return in(LIRC_PORT_TIMER) & LIRC_PORT_TIMER_BIT;
128}
129
130static unsigned int lirc_get_signal(void)
131{
132 return in(LIRC_PORT_SIGNAL) & LIRC_PORT_SIGNAL_BIT;
133}
134
135static void lirc_on(void)
136{
137 out(LIRC_PORT_DATA, tx_mask);
138}
139
140static void lirc_off(void)
141{
142 out(LIRC_PORT_DATA, 0);
143}
144
145static unsigned int init_lirc_timer(void)
146{
147 ktime_t kt, now, timeout;
148 unsigned int level, newlevel, timeelapsed, newtimer;
149 int count = 0;
150
151 kt = ktime_get();
152 /* wait max. 1 sec. */
153 timeout = ktime_add_ns(kt, NSEC_PER_SEC);
154 level = lirc_get_timer();
155 do {
156 newlevel = lirc_get_timer();
157 if (level == 0 && newlevel != 0)
158 count++;
159 level = newlevel;
160 now = ktime_get();
161 } while (count < 1000 && (ktime_before(now, timeout)));
162 timeelapsed = ktime_us_delta(now, kt);
163 if (count >= 1000 && timeelapsed > 0) {
164 if (default_timer == 0) {
165 /* autodetect timer */
166 newtimer = (1000000 * count) / timeelapsed;
167 pr_info("%u Hz timer detected\n", newtimer);
168 return newtimer;
169 }
170 newtimer = (1000000 * count) / timeelapsed;
171 if (abs(newtimer - default_timer) > default_timer / 10) {
172 /* bad timer */
173 pr_notice("bad timer: %u Hz\n", newtimer);
174 pr_notice("using default timer: %u Hz\n",
175 default_timer);
176 return default_timer;
177 }
178 pr_info("%u Hz timer detected\n", newtimer);
179 return newtimer; /* use detected value */
180 }
181
182 pr_notice("no timer detected\n");
183 return 0;
184}
185
186static int lirc_claim(void)
187{
188 if (parport_claim(ppdevice) != 0) {
189 pr_warn("could not claim port\n");
190 pr_warn("waiting for port becoming available\n");
191 if (parport_claim_or_block(ppdevice) < 0) {
192 pr_notice("could not claim port, giving up\n");
193 return 0;
194 }
195 }
196 out(LIRC_LP_CONTROL, LP_PSELECP | LP_PINITP);
197 is_claimed = 1;
198 return 1;
199}
200
201/*** interrupt handler ***/
202
203static void rbuf_write(int signal)
204{
205 unsigned int nwptr;
206
207 nwptr = (wptr + 1) & (RBUF_SIZE - 1);
208 if (nwptr == rptr) {
209 /* no new signals will be accepted */
210 lost_irqs++;
211 pr_notice("buffer overrun\n");
212 return;
213 }
214 rbuf[wptr] = signal;
215 wptr = nwptr;
216}
217
218static void lirc_lirc_irq_handler(void *blah)
219{
220 ktime_t kt, delkt;
221 static ktime_t lastkt;
222 static int init;
223 long signal;
224 int data;
225 unsigned int level, newlevel;
226 unsigned int timeout;
227
228 if (!is_open)
229 return;
230
231 if (!is_claimed)
232 return;
233
234#if 0
235 /* disable interrupt */
236 disable_irq(irq);
237 out(LIRC_PORT_IRQ, in(LIRC_PORT_IRQ) & (~LP_PINTEN));
238#endif
239 if (check_pselecd && (in(1) & LP_PSELECD))
240 return;
241
242#ifdef LIRC_TIMER
243 if (init) {
244 kt = ktime_get();
245
246 delkt = ktime_sub(kt, lastkt);
247 if (ktime_compare(delkt, ktime_set(15, 0)) > 0)
248 /* really long time */
249 data = PULSE_MASK;
250 else
251 data = (int)(ktime_to_us(delkt) + LIRC_SFH506_DELAY);
252
253 rbuf_write(data); /* space */
254 } else {
255 if (timer == 0) {
256 /*
257 * wake up; we'll lose this signal, but it will be
258 * garbage if the device is turned on anyway
259 */
260 timer = init_lirc_timer();
261 /* enable_irq(irq); */
262 return;
263 }
264 init = 1;
265 }
266
267 timeout = timer / 10; /* timeout after 1/10 sec. */
268 signal = 1;
269 level = lirc_get_timer();
270 do {
271 newlevel = lirc_get_timer();
272 if (level == 0 && newlevel != 0)
273 signal++;
274 level = newlevel;
275
276 /* giving up */
277 if (signal > timeout
278 || (check_pselecd && (in(1) & LP_PSELECD))) {
279 signal = 0;
280 pr_notice("timeout\n");
281 break;
282 }
283 } while (lirc_get_signal());
284
285 if (signal != 0) {
286 /* adjust value to usecs */
287 __u64 helper;
288
289 helper = ((__u64)signal) * 1000000;
290 do_div(helper, timer);
291 signal = (long)helper;
292
293 if (signal > LIRC_SFH506_DELAY)
294 data = signal - LIRC_SFH506_DELAY;
295 else
296 data = 1;
297 rbuf_write(PULSE_BIT | data); /* pulse */
298 }
299 lastkt = ktime_get();
300#else
301 /* add your code here */
302#endif
303
304 wake_up_interruptible(&lirc_wait);
305
306 /* enable interrupt */
307 /*
308 * enable_irq(irq);
309 * out(LIRC_PORT_IRQ, in(LIRC_PORT_IRQ)|LP_PINTEN);
310 */
311}
312
313/*** file operations ***/
314
315static loff_t lirc_lseek(struct file *filep, loff_t offset, int orig)
316{
317 return -ESPIPE;
318}
319
320static ssize_t lirc_read(struct file *filep, char __user *buf, size_t n,
321 loff_t *ppos)
322{
323 int result = 0;
324 int count = 0;
325 DECLARE_WAITQUEUE(wait, current);
326
327 if (n % sizeof(int))
328 return -EINVAL;
329
330 add_wait_queue(&lirc_wait, &wait);
331 set_current_state(TASK_INTERRUPTIBLE);
332 while (count < n) {
333 if (rptr != wptr) {
334 if (copy_to_user(buf + count, &rbuf[rptr],
335 sizeof(int))) {
336 result = -EFAULT;
337 break;
338 }
339 rptr = (rptr + 1) & (RBUF_SIZE - 1);
340 count += sizeof(int);
341 } else {
342 if (filep->f_flags & O_NONBLOCK) {
343 result = -EAGAIN;
344 break;
345 }
346 if (signal_pending(current)) {
347 result = -ERESTARTSYS;
348 break;
349 }
350 schedule();
351 set_current_state(TASK_INTERRUPTIBLE);
352 }
353 }
354 remove_wait_queue(&lirc_wait, &wait);
355 set_current_state(TASK_RUNNING);
356 return count ? count : result;
357}
358
359static ssize_t lirc_write(struct file *filep, const char __user *buf, size_t n,
360 loff_t *ppos)
361{
362 int count;
363 unsigned int i;
364 unsigned int level, newlevel;
365 unsigned long flags;
366 int counttimer;
367 int *wbuf;
368 ssize_t ret;
369
370 if (!is_claimed)
371 return -EBUSY;
372
373 count = n / sizeof(int);
374
375 if (n % sizeof(int) || count % 2 == 0)
376 return -EINVAL;
377
378 wbuf = memdup_user(buf, n);
379 if (IS_ERR(wbuf))
380 return PTR_ERR(wbuf);
381
382#ifdef LIRC_TIMER
383 if (timer == 0) {
384 /* try again if device is ready */
385 timer = init_lirc_timer();
386 if (timer == 0) {
387 ret = -EIO;
388 goto out;
389 }
390 }
391
392 /* adjust values from usecs */
393 for (i = 0; i < count; i++) {
394 __u64 helper;
395
396 helper = ((__u64)wbuf[i]) * timer;
397 do_div(helper, 1000000);
398 wbuf[i] = (int)helper;
399 }
400
401 local_irq_save(flags);
402 i = 0;
403 while (i < count) {
404 level = lirc_get_timer();
405 counttimer = 0;
406 lirc_on();
407 do {
408 newlevel = lirc_get_timer();
409 if (level == 0 && newlevel != 0)
410 counttimer++;
411 level = newlevel;
412 if (check_pselecd && (in(1) & LP_PSELECD)) {
413 lirc_off();
414 local_irq_restore(flags);
415 ret = -EIO;
416 goto out;
417 }
418 } while (counttimer < wbuf[i]);
419 i++;
420
421 lirc_off();
422 if (i == count)
423 break;
424 counttimer = 0;
425 do {
426 newlevel = lirc_get_timer();
427 if (level == 0 && newlevel != 0)
428 counttimer++;
429 level = newlevel;
430 if (check_pselecd && (in(1) & LP_PSELECD)) {
431 local_irq_restore(flags);
432 ret = -EIO;
433 goto out;
434 }
435 } while (counttimer < wbuf[i]);
436 i++;
437 }
438 local_irq_restore(flags);
439#else
440 /* place code that handles write without external timer here */
441#endif
442 ret = n;
443out:
444 kfree(wbuf);
445
446 return ret;
447}
448
449static unsigned int lirc_poll(struct file *file, poll_table *wait)
450{
451 poll_wait(file, &lirc_wait, wait);
452 if (rptr != wptr)
453 return POLLIN | POLLRDNORM;
454 return 0;
455}
456
457static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
458{
459 int result;
460 u32 __user *uptr = (u32 __user *)arg;
461 u32 features = LIRC_CAN_SET_TRANSMITTER_MASK |
462 LIRC_CAN_SEND_PULSE | LIRC_CAN_REC_MODE2;
463 u32 mode;
464 u32 value;
465
466 switch (cmd) {
467 case LIRC_GET_FEATURES:
468 result = put_user(features, uptr);
469 if (result)
470 return result;
471 break;
472 case LIRC_GET_SEND_MODE:
473 result = put_user(LIRC_MODE_PULSE, uptr);
474 if (result)
475 return result;
476 break;
477 case LIRC_GET_REC_MODE:
478 result = put_user(LIRC_MODE_MODE2, uptr);
479 if (result)
480 return result;
481 break;
482 case LIRC_SET_SEND_MODE:
483 result = get_user(mode, uptr);
484 if (result)
485 return result;
486 if (mode != LIRC_MODE_PULSE)
487 return -EINVAL;
488 break;
489 case LIRC_SET_REC_MODE:
490 result = get_user(mode, uptr);
491 if (result)
492 return result;
493 if (mode != LIRC_MODE_MODE2)
494 return -ENOSYS;
495 break;
496 case LIRC_SET_TRANSMITTER_MASK:
497 result = get_user(value, uptr);
498 if (result)
499 return result;
500 if ((value & LIRC_PARALLEL_TRANSMITTER_MASK) != value)
501 return LIRC_PARALLEL_MAX_TRANSMITTERS;
502 tx_mask = value;
503 break;
504 default:
505 return -ENOIOCTLCMD;
506 }
507 return 0;
508}
509
510static int lirc_open(struct inode *node, struct file *filep)
511{
512 if (is_open || !lirc_claim())
513 return -EBUSY;
514
515 parport_enable_irq(pport);
516
517 /* init read ptr */
518 rptr = 0;
519 wptr = 0;
520 lost_irqs = 0;
521
522 is_open = 1;
523 return 0;
524}
525
526static int lirc_close(struct inode *node, struct file *filep)
527{
528 if (is_claimed) {
529 is_claimed = 0;
530 parport_release(ppdevice);
531 }
532 is_open = 0;
533 return 0;
534}
535
536static const struct file_operations lirc_fops = {
537 .owner = THIS_MODULE,
538 .llseek = lirc_lseek,
539 .read = lirc_read,
540 .write = lirc_write,
541 .poll = lirc_poll,
542 .unlocked_ioctl = lirc_ioctl,
543#ifdef CONFIG_COMPAT
544 .compat_ioctl = lirc_ioctl,
545#endif
546 .open = lirc_open,
547 .release = lirc_close
548};
549
550static int set_use_inc(void *data)
551{
552 return 0;
553}
554
555static void set_use_dec(void *data)
556{
557}
558
559static struct lirc_driver driver = {
560 .name = LIRC_DRIVER_NAME,
561 .minor = -1,
562 .code_length = 1,
563 .sample_rate = 0,
564 .data = NULL,
565 .add_to_buf = NULL,
566 .set_use_inc = set_use_inc,
567 .set_use_dec = set_use_dec,
568 .fops = &lirc_fops,
569 .dev = NULL,
570 .owner = THIS_MODULE,
571};
572
573static struct platform_device *lirc_parallel_dev;
574
575static int lirc_parallel_probe(struct platform_device *dev)
576{
577 return 0;
578}
579
580static int lirc_parallel_remove(struct platform_device *dev)
581{
582 return 0;
583}
584
585static int lirc_parallel_suspend(struct platform_device *dev,
586 pm_message_t state)
587{
588 return 0;
589}
590
591static int lirc_parallel_resume(struct platform_device *dev)
592{
593 return 0;
594}
595
596static struct platform_driver lirc_parallel_driver = {
597 .probe = lirc_parallel_probe,
598 .remove = lirc_parallel_remove,
599 .suspend = lirc_parallel_suspend,
600 .resume = lirc_parallel_resume,
601 .driver = {
602 .name = LIRC_DRIVER_NAME,
603 },
604};
605
606static int pf(void *handle)
607{
608 parport_disable_irq(pport);
609 is_claimed = 0;
610 return 0;
611}
612
613static void kf(void *handle)
614{
615 if (!is_open)
616 return;
617 if (!lirc_claim())
618 return;
619 parport_enable_irq(pport);
620 lirc_off();
621 /* this is a bit annoying when you actually print...*/
622 /*
623 * printk(KERN_INFO "%s: reclaimed port\n", LIRC_DRIVER_NAME);
624 */
625}
626
627/*** module initialization and cleanup ***/
628
629static int __init lirc_parallel_init(void)
630{
631 int result;
632
633 result = platform_driver_register(&lirc_parallel_driver);
634 if (result) {
635 pr_notice("platform_driver_register returned %d\n", result);
636 return result;
637 }
638
639 lirc_parallel_dev = platform_device_alloc(LIRC_DRIVER_NAME, 0);
640 if (!lirc_parallel_dev) {
641 result = -ENOMEM;
642 goto exit_driver_unregister;
643 }
644
645 result = platform_device_add(lirc_parallel_dev);
646 if (result)
647 goto exit_device_put;
648
649 pport = parport_find_base(io);
650 if (!pport) {
651 pr_notice("no port at %x found\n", io);
652 result = -ENXIO;
653 goto exit_device_del;
654 }
655 ppdevice = parport_register_device(pport, LIRC_DRIVER_NAME,
656 pf, kf, lirc_lirc_irq_handler, 0,
657 NULL);
658 parport_put_port(pport);
659 if (!ppdevice) {
660 pr_notice("parport_register_device() failed\n");
661 result = -ENXIO;
662 goto exit_device_del;
663 }
664 if (parport_claim(ppdevice) != 0)
665 goto skip_init;
666 is_claimed = 1;
667 out(LIRC_LP_CONTROL, LP_PSELECP | LP_PINITP);
668
669#ifdef LIRC_TIMER
670 if (debug)
671 out(LIRC_PORT_DATA, tx_mask);
672
673 timer = init_lirc_timer();
674
675#if 0 /* continue even if device is offline */
676 if (timer == 0) {
677 is_claimed = 0;
678 parport_release(pport);
679 parport_unregister_device(ppdevice);
680 result = -EIO;
681 goto exit_device_del;
682 }
683
684#endif
685 if (debug)
686 out(LIRC_PORT_DATA, 0);
687#endif
688
689 is_claimed = 0;
690 parport_release(ppdevice);
691 skip_init:
692 driver.dev = &lirc_parallel_dev->dev;
693 driver.minor = lirc_register_driver(&driver);
694 if (driver.minor < 0) {
695 pr_notice("register_chrdev() failed\n");
696 parport_unregister_device(ppdevice);
697 result = -EIO;
698 goto exit_device_del;
699 }
700 pr_info("installed using port 0x%04x irq %d\n", io, irq);
701 return 0;
702
703exit_device_del:
704 platform_device_del(lirc_parallel_dev);
705exit_device_put:
706 platform_device_put(lirc_parallel_dev);
707exit_driver_unregister:
708 platform_driver_unregister(&lirc_parallel_driver);
709 return result;
710}
711
712static void __exit lirc_parallel_exit(void)
713{
714 parport_unregister_device(ppdevice);
715 lirc_unregister_driver(driver.minor);
716
717 platform_device_unregister(lirc_parallel_dev);
718 platform_driver_unregister(&lirc_parallel_driver);
719}
720
721module_init(lirc_parallel_init);
722module_exit(lirc_parallel_exit);
723
724MODULE_DESCRIPTION("Infrared receiver driver for parallel ports.");
725MODULE_AUTHOR("Christoph Bartelmus");
726MODULE_LICENSE("GPL");
727
728module_param(io, int, S_IRUGO);
729MODULE_PARM_DESC(io, "I/O address base (0x3bc, 0x378 or 0x278)");
730
731module_param(irq, int, S_IRUGO);
732MODULE_PARM_DESC(irq, "Interrupt (7 or 5)");
733
734module_param(tx_mask, int, S_IRUGO);
735MODULE_PARM_DESC(tx_mask, "Transmitter mask (default: 0x01)");
736
737module_param(debug, bool, S_IRUGO | S_IWUSR);
738MODULE_PARM_DESC(debug, "Enable debugging messages");
739
740module_param(check_pselecd, bool, S_IRUGO | S_IWUSR);
741MODULE_PARM_DESC(check_pselecd, "Check for printer (default: 0)");
diff --git a/drivers/staging/media/lirc/lirc_parallel.h b/drivers/staging/media/lirc/lirc_parallel.h
deleted file mode 100644
index 4bed6afe0632..000000000000
--- a/drivers/staging/media/lirc/lirc_parallel.h
+++ /dev/null
@@ -1,26 +0,0 @@
1/* lirc_parallel.h */
2
3#ifndef _LIRC_PARALLEL_H
4#define _LIRC_PARALLEL_H
5
6#include <linux/lp.h>
7
8#define LIRC_PORT_LEN 3
9
10#define LIRC_LP_BASE 0
11#define LIRC_LP_STATUS 1
12#define LIRC_LP_CONTROL 2
13
14#define LIRC_PORT_DATA LIRC_LP_BASE /* base */
15#define LIRC_PORT_TIMER LIRC_LP_STATUS /* status port */
16#define LIRC_PORT_TIMER_BIT LP_PBUSY /* busy signal */
17#define LIRC_PORT_SIGNAL LIRC_LP_STATUS /* status port */
18#define LIRC_PORT_SIGNAL_BIT LP_PACK /* ack signal */
19#define LIRC_PORT_IRQ LIRC_LP_CONTROL /* control port */
20
21#define LIRC_SFH506_DELAY 0 /* delay t_phl in usecs */
22
23#define LIRC_PARALLEL_MAX_TRANSMITTERS 8
24#define LIRC_PARALLEL_TRANSMITTER_MASK ((1<<LIRC_PARALLEL_MAX_TRANSMITTERS) - 1)
25
26#endif
diff --git a/drivers/staging/media/lirc/lirc_sir.c b/drivers/staging/media/lirc/lirc_sir.c
index 4f326e97ad75..c75ae43095ba 100644
--- a/drivers/staging/media/lirc/lirc_sir.c
+++ b/drivers/staging/media/lirc/lirc_sir.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * LIRC SIR driver, (C) 2000 Milan Pikula <www@fornax.sk> 2 * LIRC SIR driver, (C) 2000 Milan Pikula <www@fornax.sk>
3 * 3 *
4 * lirc_sir - Device driver for use with SIR (serial infra red) 4 * sir_ir - Device driver for use with SIR (serial infra red)
5 * mode of IrDA on many notebooks. 5 * mode of IrDA on many notebooks.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -58,8 +58,7 @@
58 58
59#include <linux/timer.h> 59#include <linux/timer.h>
60 60
61#include <media/lirc.h> 61#include <media/rc-core.h>
62#include <media/lirc_dev.h>
63 62
64/* SECTION: Definitions */ 63/* SECTION: Definitions */
65 64
@@ -87,11 +86,6 @@ static void init_act200(void);
87static void init_act220(void); 86static void init_act220(void);
88#endif 87#endif
89 88
90#define RBUF_LEN 1024
91#define WBUF_LEN 1024
92
93#define LIRC_DRIVER_NAME "lirc_sir"
94
95#define PULSE '[' 89#define PULSE '['
96 90
97#ifndef LIRC_SIR_TEKRAM 91#ifndef LIRC_SIR_TEKRAM
@@ -131,28 +125,19 @@ static ktime_t last;
131/* time of last UART data ready interrupt */ 125/* time of last UART data ready interrupt */
132static ktime_t last_intr_time; 126static ktime_t last_intr_time;
133static int last_value; 127static int last_value;
128static struct rc_dev *rcdev;
134 129
135static DECLARE_WAIT_QUEUE_HEAD(lirc_read_queue); 130static struct platform_device *sir_ir_dev;
136 131
137static DEFINE_SPINLOCK(hardware_lock); 132static DEFINE_SPINLOCK(hardware_lock);
138 133
139static int rx_buf[RBUF_LEN];
140static unsigned int rx_tail, rx_head;
141
142static bool debug; 134static bool debug;
143 135
144/* SECTION: Prototypes */ 136/* SECTION: Prototypes */
145 137
146/* Communication with user-space */ 138/* Communication with user-space */
147static unsigned int lirc_poll(struct file *file, poll_table *wait);
148static ssize_t lirc_read(struct file *file, char __user *buf, size_t count,
149 loff_t *ppos);
150static ssize_t lirc_write(struct file *file, const char __user *buf, size_t n,
151 loff_t *pos);
152static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
153static void add_read_queue(int flag, unsigned long val); 139static void add_read_queue(int flag, unsigned long val);
154static int init_chrdev(void); 140static int init_chrdev(void);
155static void drop_chrdev(void);
156/* Hardware */ 141/* Hardware */
157static irqreturn_t sir_interrupt(int irq, void *dev_id); 142static irqreturn_t sir_interrupt(int irq, void *dev_id);
158static void send_space(unsigned long len); 143static void send_space(unsigned long len);
@@ -189,72 +174,14 @@ static void safe_udelay(unsigned long usecs)
189} 174}
190 175
191/* SECTION: Communication with user-space */ 176/* SECTION: Communication with user-space */
192 177static int sir_tx_ir(struct rc_dev *dev, unsigned int *tx_buf,
193static unsigned int lirc_poll(struct file *file, poll_table *wait) 178 unsigned int count)
194{
195 poll_wait(file, &lirc_read_queue, wait);
196 if (rx_head != rx_tail)
197 return POLLIN | POLLRDNORM;
198 return 0;
199}
200
201static ssize_t lirc_read(struct file *file, char __user *buf, size_t count,
202 loff_t *ppos)
203{
204 int n = 0;
205 int retval = 0;
206 DECLARE_WAITQUEUE(wait, current);
207
208 if (count % sizeof(int))
209 return -EINVAL;
210
211 add_wait_queue(&lirc_read_queue, &wait);
212 set_current_state(TASK_INTERRUPTIBLE);
213 while (n < count) {
214 if (rx_head != rx_tail) {
215 if (copy_to_user(buf + n,
216 rx_buf + rx_head,
217 sizeof(int))) {
218 retval = -EFAULT;
219 break;
220 }
221 rx_head = (rx_head + 1) & (RBUF_LEN - 1);
222 n += sizeof(int);
223 } else {
224 if (file->f_flags & O_NONBLOCK) {
225 retval = -EAGAIN;
226 break;
227 }
228 if (signal_pending(current)) {
229 retval = -ERESTARTSYS;
230 break;
231 }
232 schedule();
233 set_current_state(TASK_INTERRUPTIBLE);
234 }
235 }
236 remove_wait_queue(&lirc_read_queue, &wait);
237 set_current_state(TASK_RUNNING);
238 return n ? n : retval;
239}
240static ssize_t lirc_write(struct file *file, const char __user *buf, size_t n,
241 loff_t *pos)
242{ 179{
243 unsigned long flags; 180 unsigned long flags;
244 int i, count; 181 int i;
245 int *tx_buf; 182
246
247 count = n / sizeof(int);
248 if (n % sizeof(int) || count % 2 == 0)
249 return -EINVAL;
250 tx_buf = memdup_user(buf, n);
251 if (IS_ERR(tx_buf))
252 return PTR_ERR(tx_buf);
253 i = 0;
254 local_irq_save(flags); 183 local_irq_save(flags);
255 while (1) { 184 for (i = 0; i < count;) {
256 if (i >= count)
257 break;
258 if (tx_buf[i]) 185 if (tx_buf[i])
259 send_pulse(tx_buf[i]); 186 send_pulse(tx_buf[i]);
260 i++; 187 i++;
@@ -265,138 +192,53 @@ static ssize_t lirc_write(struct file *file, const char __user *buf, size_t n,
265 i++; 192 i++;
266 } 193 }
267 local_irq_restore(flags); 194 local_irq_restore(flags);
268 kfree(tx_buf);
269 return count;
270}
271
272static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
273{
274 u32 __user *uptr = (u32 __user *)arg;
275 int retval = 0;
276 u32 value = 0;
277
278 if (cmd == LIRC_GET_FEATURES)
279 value = LIRC_CAN_SEND_PULSE | LIRC_CAN_REC_MODE2;
280 else if (cmd == LIRC_GET_SEND_MODE)
281 value = LIRC_MODE_PULSE;
282 else if (cmd == LIRC_GET_REC_MODE)
283 value = LIRC_MODE_MODE2;
284
285 switch (cmd) {
286 case LIRC_GET_FEATURES:
287 case LIRC_GET_SEND_MODE:
288 case LIRC_GET_REC_MODE:
289 retval = put_user(value, uptr);
290 break;
291
292 case LIRC_SET_SEND_MODE:
293 case LIRC_SET_REC_MODE:
294 retval = get_user(value, uptr);
295 break;
296 default:
297 retval = -ENOIOCTLCMD;
298
299 }
300
301 if (retval)
302 return retval;
303 if (cmd == LIRC_SET_REC_MODE) {
304 if (value != LIRC_MODE_MODE2)
305 retval = -ENOSYS;
306 } else if (cmd == LIRC_SET_SEND_MODE) {
307 if (value != LIRC_MODE_PULSE)
308 retval = -ENOSYS;
309 }
310 195
311 return retval; 196 return count;
312} 197}
313 198
314static void add_read_queue(int flag, unsigned long val) 199static void add_read_queue(int flag, unsigned long val)
315{ 200{
316 unsigned int new_rx_tail; 201 DEFINE_IR_RAW_EVENT(ev);
317 int newval;
318 202
319 pr_debug("add flag %d with val %lu\n", flag, val); 203 pr_debug("add flag %d with val %lu\n", flag, val);
320 204
321 newval = val & PULSE_MASK;
322
323 /* 205 /*
324 * statistically, pulses are ~TIME_CONST/2 too long. we could 206 * statistically, pulses are ~TIME_CONST/2 too long. we could
325 * maybe make this more exact, but this is good enough 207 * maybe make this more exact, but this is good enough
326 */ 208 */
327 if (flag) { 209 if (flag) {
328 /* pulse */ 210 /* pulse */
329 if (newval > TIME_CONST/2) 211 if (val > TIME_CONST / 2)
330 newval -= TIME_CONST/2; 212 val -= TIME_CONST / 2;
331 else /* should not ever happen */ 213 else /* should not ever happen */
332 newval = 1; 214 val = 1;
333 newval |= PULSE_BIT; 215 ev.pulse = true;
334 } else { 216 } else {
335 newval += TIME_CONST/2; 217 val += TIME_CONST / 2;
336 } 218 }
337 new_rx_tail = (rx_tail + 1) & (RBUF_LEN - 1); 219 ev.duration = US_TO_NS(val);
338 if (new_rx_tail == rx_head) {
339 pr_debug("Buffer overrun.\n");
340 return;
341 }
342 rx_buf[rx_tail] = newval;
343 rx_tail = new_rx_tail;
344 wake_up_interruptible(&lirc_read_queue);
345}
346 220
347static const struct file_operations lirc_fops = { 221 ir_raw_event_store_with_filter(rcdev, &ev);
348 .owner = THIS_MODULE,
349 .read = lirc_read,
350 .write = lirc_write,
351 .poll = lirc_poll,
352 .unlocked_ioctl = lirc_ioctl,
353#ifdef CONFIG_COMPAT
354 .compat_ioctl = lirc_ioctl,
355#endif
356 .open = lirc_dev_fop_open,
357 .release = lirc_dev_fop_close,
358 .llseek = no_llseek,
359};
360
361static int set_use_inc(void *data)
362{
363 return 0;
364} 222}
365 223
366static void set_use_dec(void *data)
367{
368}
369
370static struct lirc_driver driver = {
371 .name = LIRC_DRIVER_NAME,
372 .minor = -1,
373 .code_length = 1,
374 .sample_rate = 0,
375 .data = NULL,
376 .add_to_buf = NULL,
377 .set_use_inc = set_use_inc,
378 .set_use_dec = set_use_dec,
379 .fops = &lirc_fops,
380 .dev = NULL,
381 .owner = THIS_MODULE,
382};
383
384static struct platform_device *lirc_sir_dev;
385
386static int init_chrdev(void) 224static int init_chrdev(void)
387{ 225{
388 driver.dev = &lirc_sir_dev->dev; 226 rcdev = devm_rc_allocate_device(&sir_ir_dev->dev, RC_DRIVER_IR_RAW);
389 driver.minor = lirc_register_driver(&driver); 227 if (!rcdev)
390 if (driver.minor < 0) { 228 return -ENOMEM;
391 pr_err("init_chrdev() failed.\n"); 229
392 return -EIO; 230 rcdev->input_phys = KBUILD_MODNAME "/input0";
393 } 231 rcdev->input_id.bustype = BUS_HOST;
394 return 0; 232 rcdev->input_id.vendor = 0x0001;
395} 233 rcdev->input_id.product = 0x0001;
396 234 rcdev->input_id.version = 0x0100;
397static void drop_chrdev(void) 235 rcdev->tx_ir = sir_tx_ir;
398{ 236 rcdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
399 lirc_unregister_driver(driver.minor); 237 rcdev->map_name = RC_MAP_RC6_MCE;
238 rcdev->timeout = IR_DEFAULT_TIMEOUT;
239 rcdev->dev.parent = &sir_ir_dev->dev;
240
241 return devm_rc_register_device(&sir_ir_dev->dev, rcdev);
400} 242}
401 243
402/* SECTION: Hardware */ 244/* SECTION: Hardware */
@@ -420,14 +262,15 @@ static void sir_timeout(unsigned long data)
420 /* determine 'virtual' pulse end: */ 262 /* determine 'virtual' pulse end: */
421 pulse_end = min_t(unsigned long, 263 pulse_end = min_t(unsigned long,
422 ktime_us_delta(last, last_intr_time), 264 ktime_us_delta(last, last_intr_time),
423 PULSE_MASK); 265 IR_MAX_DURATION);
424 dev_dbg(driver.dev, "timeout add %d for %lu usec\n", 266 dev_dbg(&sir_ir_dev->dev, "timeout add %d for %lu usec\n",
425 last_value, pulse_end); 267 last_value, pulse_end);
426 add_read_queue(last_value, pulse_end); 268 add_read_queue(last_value, pulse_end);
427 last_value = 0; 269 last_value = 0;
428 last = last_intr_time; 270 last = last_intr_time;
429 } 271 }
430 spin_unlock_irqrestore(&timer_lock, flags); 272 spin_unlock_irqrestore(&timer_lock, flags);
273 ir_raw_event_handle(rcdev);
431} 274}
432 275
433static irqreturn_t sir_interrupt(int irq, void *dev_id) 276static irqreturn_t sir_interrupt(int irq, void *dev_id)
@@ -462,20 +305,20 @@ static irqreturn_t sir_interrupt(int irq, void *dev_id)
462 curr_time = ktime_get(); 305 curr_time = ktime_get();
463 delt = min_t(unsigned long, 306 delt = min_t(unsigned long,
464 ktime_us_delta(last, curr_time), 307 ktime_us_delta(last, curr_time),
465 PULSE_MASK); 308 IR_MAX_DURATION);
466 deltintr = min_t(unsigned long, 309 deltintr = min_t(unsigned long,
467 ktime_us_delta(last_intr_time, 310 ktime_us_delta(last_intr_time,
468 curr_time), 311 curr_time),
469 PULSE_MASK); 312 IR_MAX_DURATION);
470 dev_dbg(driver.dev, "t %lu, d %d\n", 313 dev_dbg(&sir_ir_dev->dev, "t %lu, d %d\n",
471 deltintr, (int)data); 314 deltintr, (int)data);
472 /* 315 /*
473 * if nothing came in last X cycles, 316 * if nothing came in last X cycles,
474 * it was gap 317 * it was gap
475 */ 318 */
476 if (deltintr > TIME_CONST * threshold) { 319 if (deltintr > TIME_CONST * threshold) {
477 if (last_value) { 320 if (last_value) {
478 dev_dbg(driver.dev, "GAP\n"); 321 dev_dbg(&sir_ir_dev->dev, "GAP\n");
479 /* simulate signal change */ 322 /* simulate signal change */
480 add_read_queue(last_value, 323 add_read_queue(last_value,
481 delt - 324 delt -
@@ -517,6 +360,7 @@ static irqreturn_t sir_interrupt(int irq, void *dev_id)
517 break; 360 break;
518 } 361 }
519 } 362 }
363 ir_raw_event_handle(rcdev);
520 return IRQ_RETVAL(IRQ_HANDLED); 364 return IRQ_RETVAL(IRQ_HANDLED);
521} 365}
522 366
@@ -655,12 +499,12 @@ static int init_port(void)
655 int retval; 499 int retval;
656 500
657 /* get I/O port access and IRQ line */ 501 /* get I/O port access and IRQ line */
658 if (request_region(io, 8, LIRC_DRIVER_NAME) == NULL) { 502 if (!request_region(io, 8, KBUILD_MODNAME)) {
659 pr_err("i/o port 0x%.4x already in use.\n", io); 503 pr_err("i/o port 0x%.4x already in use.\n", io);
660 return -EBUSY; 504 return -EBUSY;
661 } 505 }
662 retval = request_irq(irq, sir_interrupt, 0, 506 retval = request_irq(irq, sir_interrupt, 0,
663 LIRC_DRIVER_NAME, NULL); 507 KBUILD_MODNAME, NULL);
664 if (retval < 0) { 508 if (retval < 0) {
665 release_region(io, 8); 509 release_region(io, 8);
666 pr_err("IRQ %d already in use.\n", irq); 510 pr_err("IRQ %d already in use.\n", irq);
@@ -882,11 +726,10 @@ void init_act220(void)
882} 726}
883#endif 727#endif
884 728
885static int init_lirc_sir(void) 729static int init_sir_ir(void)
886{ 730{
887 int retval; 731 int retval;
888 732
889 init_waitqueue_head(&lirc_read_queue);
890 retval = init_port(); 733 retval = init_port();
891 if (retval < 0) 734 if (retval < 0)
892 return retval; 735 return retval;
@@ -895,42 +738,42 @@ static int init_lirc_sir(void)
895 return 0; 738 return 0;
896} 739}
897 740
898static int lirc_sir_probe(struct platform_device *dev) 741static int sir_ir_probe(struct platform_device *dev)
899{ 742{
900 return 0; 743 return 0;
901} 744}
902 745
903static int lirc_sir_remove(struct platform_device *dev) 746static int sir_ir_remove(struct platform_device *dev)
904{ 747{
905 return 0; 748 return 0;
906} 749}
907 750
908static struct platform_driver lirc_sir_driver = { 751static struct platform_driver sir_ir_driver = {
909 .probe = lirc_sir_probe, 752 .probe = sir_ir_probe,
910 .remove = lirc_sir_remove, 753 .remove = sir_ir_remove,
911 .driver = { 754 .driver = {
912 .name = "lirc_sir", 755 .name = "sir_ir",
913 }, 756 },
914}; 757};
915 758
916static int __init lirc_sir_init(void) 759static int __init sir_ir_init(void)
917{ 760{
918 int retval; 761 int retval;
919 762
920 retval = platform_driver_register(&lirc_sir_driver); 763 retval = platform_driver_register(&sir_ir_driver);
921 if (retval) { 764 if (retval) {
922 pr_err("Platform driver register failed!\n"); 765 pr_err("Platform driver register failed!\n");
923 return -ENODEV; 766 return -ENODEV;
924 } 767 }
925 768
926 lirc_sir_dev = platform_device_alloc("lirc_dev", 0); 769 sir_ir_dev = platform_device_alloc("sir_ir", 0);
927 if (!lirc_sir_dev) { 770 if (!sir_ir_dev) {
928 pr_err("Platform device alloc failed!\n"); 771 pr_err("Platform device alloc failed!\n");
929 retval = -ENOMEM; 772 retval = -ENOMEM;
930 goto pdev_alloc_fail; 773 goto pdev_alloc_fail;
931 } 774 }
932 775
933 retval = platform_device_add(lirc_sir_dev); 776 retval = platform_device_add(sir_ir_dev);
934 if (retval) { 777 if (retval) {
935 pr_err("Platform device add failed!\n"); 778 pr_err("Platform device add failed!\n");
936 retval = -ENODEV; 779 retval = -ENODEV;
@@ -941,35 +784,32 @@ static int __init lirc_sir_init(void)
941 if (retval < 0) 784 if (retval < 0)
942 goto fail; 785 goto fail;
943 786
944 retval = init_lirc_sir(); 787 retval = init_sir_ir();
945 if (retval) { 788 if (retval)
946 drop_chrdev();
947 goto fail; 789 goto fail;
948 }
949 790
950 return 0; 791 return 0;
951 792
952fail: 793fail:
953 platform_device_del(lirc_sir_dev); 794 platform_device_del(sir_ir_dev);
954pdev_add_fail: 795pdev_add_fail:
955 platform_device_put(lirc_sir_dev); 796 platform_device_put(sir_ir_dev);
956pdev_alloc_fail: 797pdev_alloc_fail:
957 platform_driver_unregister(&lirc_sir_driver); 798 platform_driver_unregister(&sir_ir_driver);
958 return retval; 799 return retval;
959} 800}
960 801
961static void __exit lirc_sir_exit(void) 802static void __exit sir_ir_exit(void)
962{ 803{
963 drop_hardware(); 804 drop_hardware();
964 drop_chrdev();
965 drop_port(); 805 drop_port();
966 platform_device_unregister(lirc_sir_dev); 806 platform_device_unregister(sir_ir_dev);
967 platform_driver_unregister(&lirc_sir_driver); 807 platform_driver_unregister(&sir_ir_driver);
968 pr_info("Uninstalled.\n"); 808 pr_info("Uninstalled.\n");
969} 809}
970 810
971module_init(lirc_sir_init); 811module_init(sir_ir_init);
972module_exit(lirc_sir_exit); 812module_exit(sir_ir_exit);
973 813
974#ifdef LIRC_SIR_TEKRAM 814#ifdef LIRC_SIR_TEKRAM
975MODULE_DESCRIPTION("Infrared receiver driver for Tekram Irmate 210"); 815MODULE_DESCRIPTION("Infrared receiver driver for Tekram Irmate 210");
diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c
index c16927ac8eb0..bb0e3b4a4558 100644
--- a/drivers/staging/media/omap4iss/iss_video.c
+++ b/drivers/staging/media/omap4iss/iss_video.c
@@ -205,21 +205,21 @@ iss_video_remote_subdev(struct iss_video *video, u32 *pad)
205static struct iss_video * 205static struct iss_video *
206iss_video_far_end(struct iss_video *video) 206iss_video_far_end(struct iss_video *video)
207{ 207{
208 struct media_entity_graph graph; 208 struct media_graph graph;
209 struct media_entity *entity = &video->video.entity; 209 struct media_entity *entity = &video->video.entity;
210 struct media_device *mdev = entity->graph_obj.mdev; 210 struct media_device *mdev = entity->graph_obj.mdev;
211 struct iss_video *far_end = NULL; 211 struct iss_video *far_end = NULL;
212 212
213 mutex_lock(&mdev->graph_mutex); 213 mutex_lock(&mdev->graph_mutex);
214 214
215 if (media_entity_graph_walk_init(&graph, mdev)) { 215 if (media_graph_walk_init(&graph, mdev)) {
216 mutex_unlock(&mdev->graph_mutex); 216 mutex_unlock(&mdev->graph_mutex);
217 return NULL; 217 return NULL;
218 } 218 }
219 219
220 media_entity_graph_walk_start(&graph, entity); 220 media_graph_walk_start(&graph, entity);
221 221
222 while ((entity = media_entity_graph_walk_next(&graph))) { 222 while ((entity = media_graph_walk_next(&graph))) {
223 if (entity == &video->video.entity) 223 if (entity == &video->video.entity)
224 continue; 224 continue;
225 225
@@ -235,7 +235,7 @@ iss_video_far_end(struct iss_video *video)
235 235
236 mutex_unlock(&mdev->graph_mutex); 236 mutex_unlock(&mdev->graph_mutex);
237 237
238 media_entity_graph_walk_cleanup(&graph); 238 media_graph_walk_cleanup(&graph);
239 239
240 return far_end; 240 return far_end;
241} 241}
@@ -854,7 +854,7 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
854{ 854{
855 struct iss_video_fh *vfh = to_iss_video_fh(fh); 855 struct iss_video_fh *vfh = to_iss_video_fh(fh);
856 struct iss_video *video = video_drvdata(file); 856 struct iss_video *video = video_drvdata(file);
857 struct media_entity_graph graph; 857 struct media_graph graph;
858 struct media_entity *entity = &video->video.entity; 858 struct media_entity *entity = &video->video.entity;
859 enum iss_pipeline_state state; 859 enum iss_pipeline_state state;
860 struct iss_pipeline *pipe; 860 struct iss_pipeline *pipe;
@@ -880,19 +880,19 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
880 if (ret) 880 if (ret)
881 goto err_graph_walk_init; 881 goto err_graph_walk_init;
882 882
883 ret = media_entity_graph_walk_init(&graph, entity->graph_obj.mdev); 883 ret = media_graph_walk_init(&graph, entity->graph_obj.mdev);
884 if (ret) 884 if (ret)
885 goto err_graph_walk_init; 885 goto err_graph_walk_init;
886 886
887 if (video->iss->pdata->set_constraints) 887 if (video->iss->pdata->set_constraints)
888 video->iss->pdata->set_constraints(video->iss, true); 888 video->iss->pdata->set_constraints(video->iss, true);
889 889
890 ret = media_entity_pipeline_start(entity, &pipe->pipe); 890 ret = media_pipeline_start(entity, &pipe->pipe);
891 if (ret < 0) 891 if (ret < 0)
892 goto err_media_entity_pipeline_start; 892 goto err_media_pipeline_start;
893 893
894 media_entity_graph_walk_start(&graph, entity); 894 media_graph_walk_start(&graph, entity);
895 while ((entity = media_entity_graph_walk_next(&graph))) 895 while ((entity = media_graph_walk_next(&graph)))
896 media_entity_enum_set(&pipe->ent_enum, entity); 896 media_entity_enum_set(&pipe->ent_enum, entity);
897 897
898 /* Verify that the currently configured format matches the output of 898 /* Verify that the currently configured format matches the output of
@@ -963,7 +963,7 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
963 spin_unlock_irqrestore(&video->qlock, flags); 963 spin_unlock_irqrestore(&video->qlock, flags);
964 } 964 }
965 965
966 media_entity_graph_walk_cleanup(&graph); 966 media_graph_walk_cleanup(&graph);
967 967
968 mutex_unlock(&video->stream_lock); 968 mutex_unlock(&video->stream_lock);
969 969
@@ -972,13 +972,13 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
972err_omap4iss_set_stream: 972err_omap4iss_set_stream:
973 vb2_streamoff(&vfh->queue, type); 973 vb2_streamoff(&vfh->queue, type);
974err_iss_video_check_format: 974err_iss_video_check_format:
975 media_entity_pipeline_stop(&video->video.entity); 975 media_pipeline_stop(&video->video.entity);
976err_media_entity_pipeline_start: 976err_media_pipeline_start:
977 if (video->iss->pdata->set_constraints) 977 if (video->iss->pdata->set_constraints)
978 video->iss->pdata->set_constraints(video->iss, false); 978 video->iss->pdata->set_constraints(video->iss, false);
979 video->queue = NULL; 979 video->queue = NULL;
980 980
981 media_entity_graph_walk_cleanup(&graph); 981 media_graph_walk_cleanup(&graph);
982 982
983err_graph_walk_init: 983err_graph_walk_init:
984 media_entity_enum_cleanup(&pipe->ent_enum); 984 media_entity_enum_cleanup(&pipe->ent_enum);
@@ -1026,7 +1026,7 @@ iss_video_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
1026 1026
1027 if (video->iss->pdata->set_constraints) 1027 if (video->iss->pdata->set_constraints)
1028 video->iss->pdata->set_constraints(video->iss, false); 1028 video->iss->pdata->set_constraints(video->iss, false);
1029 media_entity_pipeline_stop(&video->video.entity); 1029 media_pipeline_stop(&video->video.entity);
1030 1030
1031done: 1031done:
1032 mutex_unlock(&video->stream_lock); 1032 mutex_unlock(&video->stream_lock);
@@ -1141,6 +1141,7 @@ static int iss_video_open(struct file *file)
1141done: 1141done:
1142 if (ret < 0) { 1142 if (ret < 0) {
1143 v4l2_fh_del(&handle->vfh); 1143 v4l2_fh_del(&handle->vfh);
1144 v4l2_fh_exit(&handle->vfh);
1144 kfree(handle); 1145 kfree(handle);
1145 } 1146 }
1146 1147
@@ -1162,6 +1163,7 @@ static int iss_video_release(struct file *file)
1162 vb2_queue_release(&handle->queue); 1163 vb2_queue_release(&handle->queue);
1163 1164
1164 v4l2_fh_del(vfh); 1165 v4l2_fh_del(vfh);
1166 v4l2_fh_exit(vfh);
1165 kfree(handle); 1167 kfree(handle);
1166 file->private_data = NULL; 1168 file->private_data = NULL;
1167 1169
diff --git a/drivers/staging/media/s5p-cec/Kconfig b/drivers/staging/media/s5p-cec/Kconfig
index ddfd955da0d4..7a3489df3e70 100644
--- a/drivers/staging/media/s5p-cec/Kconfig
+++ b/drivers/staging/media/s5p-cec/Kconfig
@@ -1,6 +1,6 @@
1config VIDEO_SAMSUNG_S5P_CEC 1config VIDEO_SAMSUNG_S5P_CEC
2 tristate "Samsung S5P CEC driver" 2 tristate "Samsung S5P CEC driver"
3 depends on VIDEO_DEV && MEDIA_CEC_SUPPORT && (PLAT_S5P || ARCH_EXYNOS || COMPILE_TEST) 3 depends on VIDEO_DEV && MEDIA_CEC_SUPPORT && (ARCH_EXYNOS || COMPILE_TEST)
4 ---help--- 4 ---help---
5 This is a driver for Samsung S5P HDMI CEC interface. It uses the 5 This is a driver for Samsung S5P HDMI CEC interface. It uses the
6 generic CEC framework interface. 6 generic CEC framework interface.
diff --git a/drivers/staging/media/s5p-cec/exynos_hdmi_cec.h b/drivers/staging/media/s5p-cec/exynos_hdmi_cec.h
index 3e4fc7b05e83..7d9453505dce 100644
--- a/drivers/staging/media/s5p-cec/exynos_hdmi_cec.h
+++ b/drivers/staging/media/s5p-cec/exynos_hdmi_cec.h
@@ -14,7 +14,6 @@
14#define _EXYNOS_HDMI_CEC_H_ __FILE__ 14#define _EXYNOS_HDMI_CEC_H_ __FILE__
15 15
16#include <linux/regmap.h> 16#include <linux/regmap.h>
17#include <linux/miscdevice.h>
18#include "s5p_cec.h" 17#include "s5p_cec.h"
19 18
20void s5p_cec_set_divider(struct s5p_cec_dev *cec); 19void s5p_cec_set_divider(struct s5p_cec_dev *cec);
diff --git a/drivers/staging/media/s5p-cec/exynos_hdmi_cecctrl.c b/drivers/staging/media/s5p-cec/exynos_hdmi_cecctrl.c
index ce95e0fcd882..1edf667d562a 100644
--- a/drivers/staging/media/s5p-cec/exynos_hdmi_cecctrl.c
+++ b/drivers/staging/media/s5p-cec/exynos_hdmi_cecctrl.c
@@ -87,7 +87,6 @@ void s5p_cec_mask_tx_interrupts(struct s5p_cec_dev *cec)
87 reg |= S5P_CEC_IRQ_TX_DONE; 87 reg |= S5P_CEC_IRQ_TX_DONE;
88 reg |= S5P_CEC_IRQ_TX_ERROR; 88 reg |= S5P_CEC_IRQ_TX_ERROR;
89 writeb(reg, cec->reg + S5P_CEC_IRQ_MASK); 89 writeb(reg, cec->reg + S5P_CEC_IRQ_MASK);
90
91} 90}
92 91
93void s5p_cec_unmask_tx_interrupts(struct s5p_cec_dev *cec) 92void s5p_cec_unmask_tx_interrupts(struct s5p_cec_dev *cec)
@@ -186,13 +185,13 @@ u32 s5p_cec_get_status(struct s5p_cec_dev *cec)
186void s5p_clr_pending_tx(struct s5p_cec_dev *cec) 185void s5p_clr_pending_tx(struct s5p_cec_dev *cec)
187{ 186{
188 writeb(S5P_CEC_IRQ_TX_DONE | S5P_CEC_IRQ_TX_ERROR, 187 writeb(S5P_CEC_IRQ_TX_DONE | S5P_CEC_IRQ_TX_ERROR,
189 cec->reg + S5P_CEC_IRQ_CLEAR); 188 cec->reg + S5P_CEC_IRQ_CLEAR);
190} 189}
191 190
192void s5p_clr_pending_rx(struct s5p_cec_dev *cec) 191void s5p_clr_pending_rx(struct s5p_cec_dev *cec)
193{ 192{
194 writeb(S5P_CEC_IRQ_RX_DONE | S5P_CEC_IRQ_RX_ERROR, 193 writeb(S5P_CEC_IRQ_RX_DONE | S5P_CEC_IRQ_RX_ERROR,
195 cec->reg + S5P_CEC_IRQ_CLEAR); 194 cec->reg + S5P_CEC_IRQ_CLEAR);
196} 195}
197 196
198void s5p_cec_get_rx_buf(struct s5p_cec_dev *cec, u32 size, u8 *buffer) 197void s5p_cec_get_rx_buf(struct s5p_cec_dev *cec, u32 size, u8 *buffer)
diff --git a/include/linux/platform_data/media/ir-rx51.h b/include/linux/platform_data/media/ir-rx51.h
index 812d87307877..2c94ab568bfa 100644
--- a/include/linux/platform_data/media/ir-rx51.h
+++ b/include/linux/platform_data/media/ir-rx51.h
@@ -1,7 +1,7 @@
1#ifndef _LIRC_RX51_H 1#ifndef _IR_RX51_H
2#define _LIRC_RX51_H 2#define _IR_RX51_H
3 3
4struct lirc_rx51_platform_data { 4struct ir_rx51_platform_data {
5 int(*set_max_mpu_wakeup_lat)(struct device *dev, long t); 5 int(*set_max_mpu_wakeup_lat)(struct device *dev, long t);
6}; 6};
7 7
diff --git a/include/media/blackfin/ppi.h b/include/media/blackfin/ppi.h
index 4900baedd55a..987e49e8f9c9 100644
--- a/include/media/blackfin/ppi.h
+++ b/include/media/blackfin/ppi.h
@@ -11,10 +11,6 @@
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 14 */
19 15
20#ifndef _PPI_H_ 16#ifndef _PPI_H_
diff --git a/include/media/davinci/ccdc_types.h b/include/media/davinci/ccdc_types.h
index 5773874bf266..a27defcf972c 100644
--- a/include/media/davinci/ccdc_types.h
+++ b/include/media/davinci/ccdc_types.h
@@ -11,10 +11,6 @@
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 **************************************************************************/ 14 **************************************************************************/
19#ifndef _CCDC_TYPES_H 15#ifndef _CCDC_TYPES_H
20#define _CCDC_TYPES_H 16#define _CCDC_TYPES_H
diff --git a/include/media/davinci/dm355_ccdc.h b/include/media/davinci/dm355_ccdc.h
index c669a9fb75e5..e6bc72f6b60f 100644
--- a/include/media/davinci/dm355_ccdc.h
+++ b/include/media/davinci/dm355_ccdc.h
@@ -10,10 +10,6 @@
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */ 13 */
18#ifndef _DM355_CCDC_H 14#ifndef _DM355_CCDC_H
19#define _DM355_CCDC_H 15#define _DM355_CCDC_H
diff --git a/include/media/davinci/dm644x_ccdc.h b/include/media/davinci/dm644x_ccdc.h
index 984fb79031de..7c909da29d43 100644
--- a/include/media/davinci/dm644x_ccdc.h
+++ b/include/media/davinci/dm644x_ccdc.h
@@ -10,10 +10,6 @@
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */ 13 */
18#ifndef _DM644X_CCDC_H 14#ifndef _DM644X_CCDC_H
19#define _DM644X_CCDC_H 15#define _DM644X_CCDC_H
diff --git a/include/media/davinci/isif.h b/include/media/davinci/isif.h
index 7f3d76a4b9e3..170a7b9cf824 100644
--- a/include/media/davinci/isif.h
+++ b/include/media/davinci/isif.h
@@ -11,10 +11,6 @@
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * isif header file 14 * isif header file
19 */ 15 */
20#ifndef _ISIF_H 16#ifndef _ISIF_H
diff --git a/include/media/davinci/vpbe.h b/include/media/davinci/vpbe.h
index 4376beeb28c2..79a566d7defd 100644
--- a/include/media/davinci/vpbe.h
+++ b/include/media/davinci/vpbe.h
@@ -9,10 +9,6 @@
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */ 12 */
17#ifndef _VPBE_H 13#ifndef _VPBE_H
18#define _VPBE_H 14#define _VPBE_H
diff --git a/include/media/davinci/vpbe_osd.h b/include/media/davinci/vpbe_osd.h
index de59364d7ed2..32f77bcae6b3 100644
--- a/include/media/davinci/vpbe_osd.h
+++ b/include/media/davinci/vpbe_osd.h
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */ 19 */
24#ifndef _OSD_H 20#ifndef _OSD_H
25#define _OSD_H 21#define _OSD_H
diff --git a/include/media/davinci/vpbe_types.h b/include/media/davinci/vpbe_types.h
index 05dbe0ba514c..c10690b15935 100644
--- a/include/media/davinci/vpbe_types.h
+++ b/include/media/davinci/vpbe_types.h
@@ -9,10 +9,6 @@
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */ 12 */
17#ifndef _VPBE_TYPES_H 13#ifndef _VPBE_TYPES_H
18#define _VPBE_TYPES_H 14#define _VPBE_TYPES_H
diff --git a/include/media/davinci/vpbe_venc.h b/include/media/davinci/vpbe_venc.h
index 3dbd20026107..e32617bc7f9d 100644
--- a/include/media/davinci/vpbe_venc.h
+++ b/include/media/davinci/vpbe_venc.h
@@ -9,10 +9,6 @@
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */ 12 */
17#ifndef _VPBE_VENC_H 13#ifndef _VPBE_VENC_H
18#define _VPBE_VENC_H 14#define _VPBE_VENC_H
diff --git a/include/media/davinci/vpfe_capture.h b/include/media/davinci/vpfe_capture.h
index 28bcd71cdd26..8e1a4d88daa0 100644
--- a/include/media/davinci/vpfe_capture.h
+++ b/include/media/davinci/vpfe_capture.h
@@ -10,10 +10,6 @@
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */ 13 */
18 14
19#ifndef _VPFE_CAPTURE_H 15#ifndef _VPFE_CAPTURE_H
diff --git a/include/media/davinci/vpfe_types.h b/include/media/davinci/vpfe_types.h
index 76fb74bad08c..498a27404761 100644
--- a/include/media/davinci/vpfe_types.h
+++ b/include/media/davinci/vpfe_types.h
@@ -10,10 +10,6 @@
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */ 13 */
18#ifndef _VPFE_TYPES_H 14#ifndef _VPFE_TYPES_H
19#define _VPFE_TYPES_H 15#define _VPFE_TYPES_H
diff --git a/include/media/davinci/vpif_types.h b/include/media/davinci/vpif_types.h
index 3cb1704a0650..c49c306cba61 100644
--- a/include/media/davinci/vpif_types.h
+++ b/include/media/davinci/vpif_types.h
@@ -9,10 +9,6 @@
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */ 12 */
17#ifndef _VPIF_TYPES_H 13#ifndef _VPIF_TYPES_H
18#define _VPIF_TYPES_H 14#define _VPIF_TYPES_H
@@ -82,6 +78,7 @@ struct vpif_capture_config {
82 struct vpif_capture_chan_config chan_config[VPIF_CAPTURE_MAX_CHANNELS]; 78 struct vpif_capture_chan_config chan_config[VPIF_CAPTURE_MAX_CHANNELS];
83 struct vpif_subdev_info *subdev_info; 79 struct vpif_subdev_info *subdev_info;
84 int subdev_count; 80 int subdev_count;
81 int i2c_adapter_id;
85 const char *card_name; 82 const char *card_name;
86 struct v4l2_async_subdev **asd; /* Flat array, arranged in groups */ 83 struct v4l2_async_subdev **asd; /* Flat array, arranged in groups */
87 int *asd_sizes; /* 0-terminated array of asd group sizes */ 84 int *asd_sizes; /* 0-terminated array of asd group sizes */
diff --git a/include/media/davinci/vpss.h b/include/media/davinci/vpss.h
index 153473daaa32..98e7f41fc387 100644
--- a/include/media/davinci/vpss.h
+++ b/include/media/davinci/vpss.h
@@ -11,10 +11,6 @@
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * vpss - video processing subsystem module header file. 14 * vpss - video processing subsystem module header file.
19 * 15 *
20 * Include this header file if a driver needs to configure vpss system 16 * Include this header file if a driver needs to configure vpss system
diff --git a/include/media/drv-intf/tea575x.h b/include/media/drv-intf/tea575x.h
index fb272d48ba33..ba4923844d1d 100644
--- a/include/media/drv-intf/tea575x.h
+++ b/include/media/drv-intf/tea575x.h
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */ 19 */
24 20
25#include <linux/videodev2.h> 21#include <linux/videodev2.h>
diff --git a/include/media/i2c/adp1653.h b/include/media/i2c/adp1653.h
index 0b6709335dff..8a79f7200f5d 100644
--- a/include/media/i2c/adp1653.h
+++ b/include/media/i2c/adp1653.h
@@ -18,11 +18,6 @@
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details. 19 * General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 * 02110-1301 USA
25 *
26 */ 21 */
27 22
28#ifndef ADP1653_H 23#ifndef ADP1653_H
diff --git a/include/media/i2c/adv7183.h b/include/media/i2c/adv7183.h
index c5c2d377c0a6..2ad8c3d0b7d2 100644
--- a/include/media/i2c/adv7183.h
+++ b/include/media/i2c/adv7183.h
@@ -11,10 +11,6 @@
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 14 */
19 15
20#ifndef _ADV7183_H_ 16#ifndef _ADV7183_H_
diff --git a/include/media/i2c/as3645a.h b/include/media/i2c/as3645a.h
index 0e07484ddc33..fffd4b563f5a 100644
--- a/include/media/i2c/as3645a.h
+++ b/include/media/i2c/as3645a.h
@@ -14,11 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details. 15 * General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */ 17 */
23 18
24#ifndef __AS3645A_H__ 19#ifndef __AS3645A_H__
diff --git a/include/media/i2c/lm3560.h b/include/media/i2c/lm3560.h
index 5ed942a8ac32..a5bd310c9e1e 100644
--- a/include/media/i2c/lm3560.h
+++ b/include/media/i2c/lm3560.h
@@ -15,11 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details. 16 * General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 */ 18 */
24 19
25#ifndef __LM3560_H__ 20#ifndef __LM3560_H__
diff --git a/include/media/i2c/mt9m032.h b/include/media/i2c/mt9m032.h
index c3a78114d7a6..30d02a1af708 100644
--- a/include/media/i2c/mt9m032.h
+++ b/include/media/i2c/mt9m032.h
@@ -14,11 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details. 15 * General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */ 17 */
23 18
24#ifndef MT9M032_H 19#ifndef MT9M032_H
diff --git a/include/media/i2c/smiapp.h b/include/media/i2c/smiapp.h
index 635007e7441a..525d55b2afeb 100644
--- a/include/media/i2c/smiapp.h
+++ b/include/media/i2c/smiapp.h
@@ -15,11 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details. 16 * General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 */ 18 */
24 19
25#ifndef __SMIAPP_H_ 20#ifndef __SMIAPP_H_
diff --git a/include/media/i2c/ths7303.h b/include/media/i2c/ths7303.h
index a7b49297da82..834e2f95b630 100644
--- a/include/media/i2c/ths7303.h
+++ b/include/media/i2c/ths7303.h
@@ -16,10 +16,6 @@
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */ 19 */
24 20
25#ifndef THS7353_H 21#ifndef THS7353_H
diff --git a/include/media/i2c/tvp514x.h b/include/media/i2c/tvp514x.h
index 86ed7e806830..c4896702f2d0 100644
--- a/include/media/i2c/tvp514x.h
+++ b/include/media/i2c/tvp514x.h
@@ -20,10 +20,6 @@
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 21 * GNU General Public License for more details.
22 * 22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 */ 23 */
28 24
29#ifndef _TVP514X_H 25#ifndef _TVP514X_H
diff --git a/include/media/i2c/tvp7002.h b/include/media/i2c/tvp7002.h
index fadb6afe9ef0..5ee007c1cead 100644
--- a/include/media/i2c/tvp7002.h
+++ b/include/media/i2c/tvp7002.h
@@ -18,10 +18,6 @@
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 21 */
26#ifndef _TVP7002_H_ 22#ifndef _TVP7002_H_
27#define _TVP7002_H_ 23#define _TVP7002_H_
diff --git a/include/media/i2c/upd64031a.h b/include/media/i2c/upd64031a.h
index 3ad6a32e1bce..48ec03c4ef23 100644
--- a/include/media/i2c/upd64031a.h
+++ b/include/media/i2c/upd64031a.h
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */ 15 */
20 16
21#ifndef _UPD64031A_H_ 17#ifndef _UPD64031A_H_
diff --git a/include/media/i2c/upd64083.h b/include/media/i2c/upd64083.h
index 59b6f32ba300..4bed7371fdde 100644
--- a/include/media/i2c/upd64083.h
+++ b/include/media/i2c/upd64083.h
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */ 15 */
20 16
21#ifndef _UPD64083_H_ 17#ifndef _UPD64083_H_
diff --git a/include/media/media-device.h b/include/media/media-device.h
index c21b4c5f5871..6896266031b9 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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 */ 17 */
22 18
23#ifndef _MEDIA_DEVICE_H 19#ifndef _MEDIA_DEVICE_H
@@ -125,6 +121,8 @@ struct media_device_ops {
125 * bridge driver finds the media_device during probe. 121 * bridge driver finds the media_device during probe.
126 * Bridge driver sets source_priv with information 122 * Bridge driver sets source_priv with information
127 * necessary to run @enable_source and @disable_source handlers. 123 * necessary to run @enable_source and @disable_source handlers.
124 * Callers should hold graph_mutex to access and call @enable_source
125 * and @disable_source handlers.
128 */ 126 */
129struct media_device { 127struct media_device {
130 /* dev->driver_data points to this struct. */ 128 /* dev->driver_data points to this struct. */
@@ -154,7 +152,7 @@ struct media_device {
154 152
155 /* Serializes graph operations. */ 153 /* Serializes graph operations. */
156 struct mutex graph_mutex; 154 struct mutex graph_mutex;
157 struct media_entity_graph pm_count_walk; 155 struct media_graph pm_count_walk;
158 156
159 void *source_priv; 157 void *source_priv;
160 int (*enable_source)(struct media_entity *entity, 158 int (*enable_source)(struct media_entity *entity,
diff --git a/include/media/media-devnode.h b/include/media/media-devnode.h
index cd23e915764c..511615d3bf6f 100644
--- a/include/media/media-devnode.h
+++ b/include/media/media-devnode.h
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU 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 * -- 18 * --
23 * 19 *
24 * Common functions for media-related drivers to register and unregister media 20 * Common functions for media-related drivers to register and unregister media
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index b2203ee7a4c1..c7c254c5bca1 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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 */ 17 */
22 18
23#ifndef _MEDIA_ENTITY_H 19#ifndef _MEDIA_ENTITY_H
@@ -86,7 +82,7 @@ struct media_entity_enum {
86}; 82};
87 83
88/** 84/**
89 * struct media_entity_graph - Media graph traversal state 85 * struct media_graph - Media graph traversal state
90 * 86 *
91 * @stack: Graph traversal stack; the stack contains information 87 * @stack: Graph traversal stack; the stack contains information
92 * on the path the media entities to be walked and the 88 * on the path the media entities to be walked and the
@@ -94,7 +90,7 @@ struct media_entity_enum {
94 * @ent_enum: Visited entities 90 * @ent_enum: Visited entities
95 * @top: The top of the stack 91 * @top: The top of the stack
96 */ 92 */
97struct media_entity_graph { 93struct media_graph {
98 struct { 94 struct {
99 struct media_entity *entity; 95 struct media_entity *entity;
100 struct list_head *link; 96 struct list_head *link;
@@ -112,7 +108,7 @@ struct media_entity_graph {
112 */ 108 */
113struct media_pipeline { 109struct media_pipeline {
114 int streaming_count; 110 int streaming_count;
115 struct media_entity_graph graph; 111 struct media_graph graph;
116}; 112};
117 113
118/** 114/**
@@ -179,7 +175,7 @@ struct media_pad {
179 * return an error, in which case link setup will be 175 * return an error, in which case link setup will be
180 * cancelled. Optional. 176 * cancelled. Optional.
181 * @link_validate: Return whether a link is valid from the entity point of 177 * @link_validate: Return whether a link is valid from the entity point of
182 * view. The media_entity_pipeline_start() function 178 * view. The media_pipeline_start() function
183 * validates all links by calling this operation. Optional. 179 * validates all links by calling this operation. Optional.
184 * 180 *
185 * .. note:: 181 * .. note::
@@ -820,20 +816,20 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad);
820struct media_entity *media_entity_get(struct media_entity *entity); 816struct media_entity *media_entity_get(struct media_entity *entity);
821 817
822/** 818/**
823 * media_entity_graph_walk_init - Allocate resources used by graph walk. 819 * media_graph_walk_init - Allocate resources used by graph walk.
824 * 820 *
825 * @graph: Media graph structure that will be used to walk the graph 821 * @graph: Media graph structure that will be used to walk the graph
826 * @mdev: Pointer to the &media_device that contains the object 822 * @mdev: Pointer to the &media_device that contains the object
827 */ 823 */
828__must_check int media_entity_graph_walk_init( 824__must_check int media_graph_walk_init(
829 struct media_entity_graph *graph, struct media_device *mdev); 825 struct media_graph *graph, struct media_device *mdev);
830 826
831/** 827/**
832 * media_entity_graph_walk_cleanup - Release resources used by graph walk. 828 * media_graph_walk_cleanup - Release resources used by graph walk.
833 * 829 *
834 * @graph: Media graph structure that will be used to walk the graph 830 * @graph: Media graph structure that will be used to walk the graph
835 */ 831 */
836void media_entity_graph_walk_cleanup(struct media_entity_graph *graph); 832void media_graph_walk_cleanup(struct media_graph *graph);
837 833
838/** 834/**
839 * media_entity_put - Release the reference to the parent module 835 * media_entity_put - Release the reference to the parent module
@@ -847,40 +843,39 @@ void media_entity_graph_walk_cleanup(struct media_entity_graph *graph);
847void media_entity_put(struct media_entity *entity); 843void media_entity_put(struct media_entity *entity);
848 844
849/** 845/**
850 * media_entity_graph_walk_start - Start walking the media graph at a 846 * media_graph_walk_start - Start walking the media graph at a
851 * given entity 847 * given entity
852 * 848 *
853 * @graph: Media graph structure that will be used to walk the graph 849 * @graph: Media graph structure that will be used to walk the graph
854 * @entity: Starting entity 850 * @entity: Starting entity
855 * 851 *
856 * Before using this function, media_entity_graph_walk_init() must be 852 * Before using this function, media_graph_walk_init() must be
857 * used to allocate resources used for walking the graph. This 853 * used to allocate resources used for walking the graph. This
858 * function initializes the graph traversal structure to walk the 854 * function initializes the graph traversal structure to walk the
859 * entities graph starting at the given entity. The traversal 855 * entities graph starting at the given entity. The traversal
860 * structure must not be modified by the caller during graph 856 * structure must not be modified by the caller during graph
861 * traversal. After the graph walk, the resources must be released 857 * traversal. After the graph walk, the resources must be released
862 * using media_entity_graph_walk_cleanup(). 858 * using media_graph_walk_cleanup().
863 */ 859 */
864void media_entity_graph_walk_start(struct media_entity_graph *graph, 860void media_graph_walk_start(struct media_graph *graph,
865 struct media_entity *entity); 861 struct media_entity *entity);
866 862
867/** 863/**
868 * media_entity_graph_walk_next - Get the next entity in the graph 864 * media_graph_walk_next - Get the next entity in the graph
869 * @graph: Media graph structure 865 * @graph: Media graph structure
870 * 866 *
871 * Perform a depth-first traversal of the given media entities graph. 867 * Perform a depth-first traversal of the given media entities graph.
872 * 868 *
873 * The graph structure must have been previously initialized with a call to 869 * The graph structure must have been previously initialized with a call to
874 * media_entity_graph_walk_start(). 870 * media_graph_walk_start().
875 * 871 *
876 * Return: returns the next entity in the graph or %NULL if the whole graph 872 * Return: returns the next entity in the graph or %NULL if the whole graph
877 * have been traversed. 873 * have been traversed.
878 */ 874 */
879struct media_entity * 875struct media_entity *media_graph_walk_next(struct media_graph *graph);
880media_entity_graph_walk_next(struct media_entity_graph *graph);
881 876
882/** 877/**
883 * media_entity_pipeline_start - Mark a pipeline as streaming 878 * media_pipeline_start - Mark a pipeline as streaming
884 * @entity: Starting entity 879 * @entity: Starting entity
885 * @pipe: Media pipeline to be assigned to all entities in the pipeline. 880 * @pipe: Media pipeline to be assigned to all entities in the pipeline.
886 * 881 *
@@ -889,45 +884,45 @@ media_entity_graph_walk_next(struct media_entity_graph *graph);
889 * to every entity in the pipeline and stored in the media_entity pipe field. 884 * to every entity in the pipeline and stored in the media_entity pipe field.
890 * 885 *
891 * Calls to this function can be nested, in which case the same number of 886 * Calls to this function can be nested, in which case the same number of
892 * media_entity_pipeline_stop() calls will be required to stop streaming. The 887 * media_pipeline_stop() calls will be required to stop streaming. The
893 * pipeline pointer must be identical for all nested calls to 888 * pipeline pointer must be identical for all nested calls to
894 * media_entity_pipeline_start(). 889 * media_pipeline_start().
895 */ 890 */
896__must_check int media_entity_pipeline_start(struct media_entity *entity, 891__must_check int media_pipeline_start(struct media_entity *entity,
897 struct media_pipeline *pipe); 892 struct media_pipeline *pipe);
898/** 893/**
899 * __media_entity_pipeline_start - Mark a pipeline as streaming 894 * __media_pipeline_start - Mark a pipeline as streaming
900 * 895 *
901 * @entity: Starting entity 896 * @entity: Starting entity
902 * @pipe: Media pipeline to be assigned to all entities in the pipeline. 897 * @pipe: Media pipeline to be assigned to all entities in the pipeline.
903 * 898 *
904 * ..note:: This is the non-locking version of media_entity_pipeline_start() 899 * ..note:: This is the non-locking version of media_pipeline_start()
905 */ 900 */
906__must_check int __media_entity_pipeline_start(struct media_entity *entity, 901__must_check int __media_pipeline_start(struct media_entity *entity,
907 struct media_pipeline *pipe); 902 struct media_pipeline *pipe);
908 903
909/** 904/**
910 * media_entity_pipeline_stop - Mark a pipeline as not streaming 905 * media_pipeline_stop - Mark a pipeline as not streaming
911 * @entity: Starting entity 906 * @entity: Starting entity
912 * 907 *
913 * Mark all entities connected to a given entity through enabled links, either 908 * Mark all entities connected to a given entity through enabled links, either
914 * directly or indirectly, as not streaming. The media_entity pipe field is 909 * directly or indirectly, as not streaming. The media_entity pipe field is
915 * reset to %NULL. 910 * reset to %NULL.
916 * 911 *
917 * If multiple calls to media_entity_pipeline_start() have been made, the same 912 * If multiple calls to media_pipeline_start() have been made, the same
918 * number of calls to this function are required to mark the pipeline as not 913 * number of calls to this function are required to mark the pipeline as not
919 * streaming. 914 * streaming.
920 */ 915 */
921void media_entity_pipeline_stop(struct media_entity *entity); 916void media_pipeline_stop(struct media_entity *entity);
922 917
923/** 918/**
924 * __media_entity_pipeline_stop - Mark a pipeline as not streaming 919 * __media_pipeline_stop - Mark a pipeline as not streaming
925 * 920 *
926 * @entity: Starting entity 921 * @entity: Starting entity
927 * 922 *
928 * .. note:: This is the non-locking version of media_entity_pipeline_stop() 923 * .. note:: This is the non-locking version of media_pipeline_stop()
929 */ 924 */
930void __media_entity_pipeline_stop(struct media_entity *entity); 925void __media_pipeline_stop(struct media_entity *entity);
931 926
932/** 927/**
933 * media_devnode_create() - creates and initializes a device node interface 928 * media_devnode_create() - creates and initializes a device node interface
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index 55281b92105a..73ddd721d7ba 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -32,13 +32,16 @@ do { \
32/** 32/**
33 * enum rc_driver_type - type of the RC output 33 * enum rc_driver_type - type of the RC output
34 * 34 *
35 * @RC_DRIVER_SCANCODE: Driver or hardware generates a scancode 35 * @RC_DRIVER_SCANCODE: Driver or hardware generates a scancode
36 * @RC_DRIVER_IR_RAW: Driver or hardware generates pulse/space sequences. 36 * @RC_DRIVER_IR_RAW: Driver or hardware generates pulse/space sequences.
37 * It needs a Infra-Red pulse/space decoder 37 * It needs a Infra-Red pulse/space decoder
38 * @RC_DRIVER_IR_RAW_TX: Device transmitter only,
39 * driver requires pulse/space data sequence.
38 */ 40 */
39enum rc_driver_type { 41enum rc_driver_type {
40 RC_DRIVER_SCANCODE = 0, 42 RC_DRIVER_SCANCODE = 0,
41 RC_DRIVER_IR_RAW, 43 RC_DRIVER_IR_RAW,
44 RC_DRIVER_IR_RAW_TX,
42}; 45};
43 46
44/** 47/**
@@ -83,10 +86,13 @@ enum rc_filter_type {
83 * @input_dev: the input child device used to communicate events to userspace 86 * @input_dev: the input child device used to communicate events to userspace
84 * @driver_type: specifies if protocol decoding is done in hardware or software 87 * @driver_type: specifies if protocol decoding is done in hardware or software
85 * @idle: used to keep track of RX state 88 * @idle: used to keep track of RX state
89 * @encode_wakeup: wakeup filtering uses IR encode API, therefore the allowed
90 * wakeup protocols is the set of all raw encoders
86 * @allowed_protocols: bitmask with the supported RC_BIT_* protocols 91 * @allowed_protocols: bitmask with the supported RC_BIT_* protocols
87 * @enabled_protocols: bitmask with the enabled RC_BIT_* protocols 92 * @enabled_protocols: bitmask with the enabled RC_BIT_* protocols
88 * @allowed_wakeup_protocols: bitmask with the supported RC_BIT_* wakeup protocols 93 * @allowed_wakeup_protocols: bitmask with the supported RC_BIT_* wakeup protocols
89 * @enabled_wakeup_protocols: bitmask with the enabled RC_BIT_* wakeup protocols 94 * @wakeup_protocol: the enabled RC_TYPE_* wakeup protocol or
95 * RC_TYPE_UNKNOWN if disabled.
90 * @scancode_filter: scancode filter 96 * @scancode_filter: scancode filter
91 * @scancode_wakeup_filter: scancode wakeup filters 97 * @scancode_wakeup_filter: scancode wakeup filters
92 * @scancode_mask: some hardware decoders are not capable of providing the full 98 * @scancode_mask: some hardware decoders are not capable of providing the full
@@ -110,8 +116,6 @@ enum rc_filter_type {
110 * @rx_resolution : resolution (in ns) of input sampler 116 * @rx_resolution : resolution (in ns) of input sampler
111 * @tx_resolution: resolution (in ns) of output sampler 117 * @tx_resolution: resolution (in ns) of output sampler
112 * @change_protocol: allow changing the protocol used on hardware decoders 118 * @change_protocol: allow changing the protocol used on hardware decoders
113 * @change_wakeup_protocol: allow changing the protocol used for wakeup
114 * filtering
115 * @open: callback to allow drivers to enable polling/irq when IR input device 119 * @open: callback to allow drivers to enable polling/irq when IR input device
116 * is opened. 120 * is opened.
117 * @close: callback to allow drivers to disable polling/irq when IR input device 121 * @close: callback to allow drivers to disable polling/irq when IR input device
@@ -126,7 +130,9 @@ enum rc_filter_type {
126 * @s_learning_mode: enable wide band receiver used for learning 130 * @s_learning_mode: enable wide band receiver used for learning
127 * @s_carrier_report: enable carrier reports 131 * @s_carrier_report: enable carrier reports
128 * @s_filter: set the scancode filter 132 * @s_filter: set the scancode filter
129 * @s_wakeup_filter: set the wakeup scancode filter 133 * @s_wakeup_filter: set the wakeup scancode filter. If the mask is zero
134 * then wakeup should be disabled. wakeup_protocol will be set to
135 * a valid protocol if mask is nonzero.
130 * @s_timeout: set hardware timeout in ns 136 * @s_timeout: set hardware timeout in ns
131 */ 137 */
132struct rc_dev { 138struct rc_dev {
@@ -146,10 +152,11 @@ struct rc_dev {
146 struct input_dev *input_dev; 152 struct input_dev *input_dev;
147 enum rc_driver_type driver_type; 153 enum rc_driver_type driver_type;
148 bool idle; 154 bool idle;
155 bool encode_wakeup;
149 u64 allowed_protocols; 156 u64 allowed_protocols;
150 u64 enabled_protocols; 157 u64 enabled_protocols;
151 u64 allowed_wakeup_protocols; 158 u64 allowed_wakeup_protocols;
152 u64 enabled_wakeup_protocols; 159 enum rc_type wakeup_protocol;
153 struct rc_scancode_filter scancode_filter; 160 struct rc_scancode_filter scancode_filter;
154 struct rc_scancode_filter scancode_wakeup_filter; 161 struct rc_scancode_filter scancode_wakeup_filter;
155 u32 scancode_mask; 162 u32 scancode_mask;
@@ -169,7 +176,6 @@ struct rc_dev {
169 u32 rx_resolution; 176 u32 rx_resolution;
170 u32 tx_resolution; 177 u32 tx_resolution;
171 int (*change_protocol)(struct rc_dev *dev, u64 *rc_type); 178 int (*change_protocol)(struct rc_dev *dev, u64 *rc_type);
172 int (*change_wakeup_protocol)(struct rc_dev *dev, u64 *rc_type);
173 int (*open)(struct rc_dev *dev); 179 int (*open)(struct rc_dev *dev);
174 void (*close)(struct rc_dev *dev); 180 void (*close)(struct rc_dev *dev);
175 int (*s_tx_mask)(struct rc_dev *dev, u32 mask); 181 int (*s_tx_mask)(struct rc_dev *dev, u32 mask);
@@ -200,17 +206,19 @@ struct rc_dev {
200/** 206/**
201 * rc_allocate_device - Allocates a RC device 207 * rc_allocate_device - Allocates a RC device
202 * 208 *
209 * @rc_driver_type: specifies the type of the RC output to be allocated
203 * returns a pointer to struct rc_dev. 210 * returns a pointer to struct rc_dev.
204 */ 211 */
205struct rc_dev *rc_allocate_device(void); 212struct rc_dev *rc_allocate_device(enum rc_driver_type);
206 213
207/** 214/**
208 * devm_rc_allocate_device - Managed RC device allocation 215 * devm_rc_allocate_device - Managed RC device allocation
209 * 216 *
210 * @dev: pointer to struct device 217 * @dev: pointer to struct device
218 * @rc_driver_type: specifies the type of the RC output to be allocated
211 * returns a pointer to struct rc_dev. 219 * returns a pointer to struct rc_dev.
212 */ 220 */
213struct rc_dev *devm_rc_allocate_device(struct device *dev); 221struct rc_dev *devm_rc_allocate_device(struct device *dev, enum rc_driver_type);
214 222
215/** 223/**
216 * rc_free_device - Frees a RC device 224 * rc_free_device - Frees a RC device
@@ -306,6 +314,8 @@ int ir_raw_event_store_edge(struct rc_dev *dev, enum raw_event_type type);
306int ir_raw_event_store_with_filter(struct rc_dev *dev, 314int ir_raw_event_store_with_filter(struct rc_dev *dev,
307 struct ir_raw_event *ev); 315 struct ir_raw_event *ev);
308void ir_raw_event_set_idle(struct rc_dev *dev, bool idle); 316void ir_raw_event_set_idle(struct rc_dev *dev, bool idle);
317int ir_raw_encode_scancode(enum rc_type protocol, u32 scancode,
318 struct ir_raw_event *events, unsigned int max);
309 319
310static inline void ir_raw_event_reset(struct rc_dev *dev) 320static inline void ir_raw_event_reset(struct rc_dev *dev)
311{ 321{
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index e1cc14cba391..a704749280d2 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -17,7 +17,7 @@
17 * @RC_TYPE_UNKNOWN: Protocol not known 17 * @RC_TYPE_UNKNOWN: Protocol not known
18 * @RC_TYPE_OTHER: Protocol known but proprietary 18 * @RC_TYPE_OTHER: Protocol known but proprietary
19 * @RC_TYPE_RC5: Philips RC5 protocol 19 * @RC_TYPE_RC5: Philips RC5 protocol
20 * @RC_TYPE_RC5X: Philips RC5x protocol 20 * @RC_TYPE_RC5X_20: Philips RC5x 20 bit protocol
21 * @RC_TYPE_RC5_SZ: StreamZap variant of RC5 21 * @RC_TYPE_RC5_SZ: StreamZap variant of RC5
22 * @RC_TYPE_JVC: JVC protocol 22 * @RC_TYPE_JVC: JVC protocol
23 * @RC_TYPE_SONY12: Sony 12 bit protocol 23 * @RC_TYPE_SONY12: Sony 12 bit protocol
@@ -41,7 +41,7 @@ enum rc_type {
41 RC_TYPE_UNKNOWN = 0, 41 RC_TYPE_UNKNOWN = 0,
42 RC_TYPE_OTHER = 1, 42 RC_TYPE_OTHER = 1,
43 RC_TYPE_RC5 = 2, 43 RC_TYPE_RC5 = 2,
44 RC_TYPE_RC5X = 3, 44 RC_TYPE_RC5X_20 = 3,
45 RC_TYPE_RC5_SZ = 4, 45 RC_TYPE_RC5_SZ = 4,
46 RC_TYPE_JVC = 5, 46 RC_TYPE_JVC = 5,
47 RC_TYPE_SONY12 = 6, 47 RC_TYPE_SONY12 = 6,
@@ -66,7 +66,7 @@ enum rc_type {
66#define RC_BIT_UNKNOWN (1ULL << RC_TYPE_UNKNOWN) 66#define RC_BIT_UNKNOWN (1ULL << RC_TYPE_UNKNOWN)
67#define RC_BIT_OTHER (1ULL << RC_TYPE_OTHER) 67#define RC_BIT_OTHER (1ULL << RC_TYPE_OTHER)
68#define RC_BIT_RC5 (1ULL << RC_TYPE_RC5) 68#define RC_BIT_RC5 (1ULL << RC_TYPE_RC5)
69#define RC_BIT_RC5X (1ULL << RC_TYPE_RC5X) 69#define RC_BIT_RC5X_20 (1ULL << RC_TYPE_RC5X_20)
70#define RC_BIT_RC5_SZ (1ULL << RC_TYPE_RC5_SZ) 70#define RC_BIT_RC5_SZ (1ULL << RC_TYPE_RC5_SZ)
71#define RC_BIT_JVC (1ULL << RC_TYPE_JVC) 71#define RC_BIT_JVC (1ULL << RC_TYPE_JVC)
72#define RC_BIT_SONY12 (1ULL << RC_TYPE_SONY12) 72#define RC_BIT_SONY12 (1ULL << RC_TYPE_SONY12)
@@ -87,7 +87,7 @@ enum rc_type {
87#define RC_BIT_CEC (1ULL << RC_TYPE_CEC) 87#define RC_BIT_CEC (1ULL << RC_TYPE_CEC)
88 88
89#define RC_BIT_ALL (RC_BIT_UNKNOWN | RC_BIT_OTHER | \ 89#define RC_BIT_ALL (RC_BIT_UNKNOWN | RC_BIT_OTHER | \
90 RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ | \ 90 RC_BIT_RC5 | RC_BIT_RC5X_20 | RC_BIT_RC5_SZ | \
91 RC_BIT_JVC | \ 91 RC_BIT_JVC | \
92 RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20 | \ 92 RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20 | \
93 RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32 | \ 93 RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32 | \
@@ -95,7 +95,26 @@ enum rc_type {
95 RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | \ 95 RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | \
96 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | RC_BIT_SHARP | \ 96 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | RC_BIT_SHARP | \
97 RC_BIT_XMP | RC_BIT_CEC) 97 RC_BIT_XMP | RC_BIT_CEC)
98/* All rc protocols for which we have decoders */
99#define RC_BIT_ALL_IR_DECODER \
100 (RC_BIT_RC5 | RC_BIT_RC5X_20 | RC_BIT_RC5_SZ | \
101 RC_BIT_JVC | \
102 RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20 | \
103 RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32 | \
104 RC_BIT_SANYO | RC_BIT_MCE_KBD | RC_BIT_RC6_0 | \
105 RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | \
106 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | RC_BIT_SHARP | \
107 RC_BIT_XMP)
98 108
109#define RC_BIT_ALL_IR_ENCODER \
110 (RC_BIT_RC5 | RC_BIT_RC5X_20 | RC_BIT_RC5_SZ | \
111 RC_BIT_JVC | \
112 RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20 | \
113 RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32 | \
114 RC_BIT_SANYO | \
115 RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | \
116 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | \
117 RC_BIT_SHARP)
99 118
100#define RC_SCANCODE_UNKNOWN(x) (x) 119#define RC_SCANCODE_UNKNOWN(x) (x)
101#define RC_SCANCODE_OTHER(x) (x) 120#define RC_SCANCODE_OTHER(x) (x)
@@ -198,6 +217,7 @@ struct rc_map *rc_map_get(const char *name);
198#define RC_MAP_CEC "rc-cec" 217#define RC_MAP_CEC "rc-cec"
199#define RC_MAP_CINERGY_1400 "rc-cinergy-1400" 218#define RC_MAP_CINERGY_1400 "rc-cinergy-1400"
200#define RC_MAP_CINERGY "rc-cinergy" 219#define RC_MAP_CINERGY "rc-cinergy"
220#define RC_MAP_D680_DMB "rc-d680-dmb"
201#define RC_MAP_DELOCK_61959 "rc-delock-61959" 221#define RC_MAP_DELOCK_61959 "rc-delock-61959"
202#define RC_MAP_DIB0700_NEC_TABLE "rc-dib0700-nec" 222#define RC_MAP_DIB0700_NEC_TABLE "rc-dib0700-nec"
203#define RC_MAP_DIB0700_RC5_TABLE "rc-dib0700-rc5" 223#define RC_MAP_DIB0700_RC5_TABLE "rc-dib0700-rc5"
@@ -208,6 +228,8 @@ struct rc_map *rc_map_get(const char *name);
208#define RC_MAP_DNTV_LIVE_DVB_T "rc-dntv-live-dvb-t" 228#define RC_MAP_DNTV_LIVE_DVB_T "rc-dntv-live-dvb-t"
209#define RC_MAP_DTT200U "rc-dtt200u" 229#define RC_MAP_DTT200U "rc-dtt200u"
210#define RC_MAP_DVBSKY "rc-dvbsky" 230#define RC_MAP_DVBSKY "rc-dvbsky"
231#define RC_MAP_DVICO_MCE "rc-dvico-mce"
232#define RC_MAP_DVICO_PORTABLE "rc-dvico-portable"
211#define RC_MAP_EMPTY "rc-empty" 233#define RC_MAP_EMPTY "rc-empty"
212#define RC_MAP_EM_TERRATEC "rc-em-terratec" 234#define RC_MAP_EM_TERRATEC "rc-em-terratec"
213#define RC_MAP_ENCORE_ENLTV2 "rc-encore-enltv2" 235#define RC_MAP_ENCORE_ENLTV2 "rc-encore-enltv2"
@@ -219,6 +241,7 @@ struct rc_map *rc_map_get(const char *name);
219#define RC_MAP_FLYVIDEO "rc-flyvideo" 241#define RC_MAP_FLYVIDEO "rc-flyvideo"
220#define RC_MAP_FUSIONHDTV_MCE "rc-fusionhdtv-mce" 242#define RC_MAP_FUSIONHDTV_MCE "rc-fusionhdtv-mce"
221#define RC_MAP_GADMEI_RM008Z "rc-gadmei-rm008z" 243#define RC_MAP_GADMEI_RM008Z "rc-gadmei-rm008z"
244#define RC_MAP_GEEKBOX "rc-geekbox"
222#define RC_MAP_GENIUS_TVGO_A11MCE "rc-genius-tvgo-a11mce" 245#define RC_MAP_GENIUS_TVGO_A11MCE "rc-genius-tvgo-a11mce"
223#define RC_MAP_GOTVIEW7135 "rc-gotview7135" 246#define RC_MAP_GOTVIEW7135 "rc-gotview7135"
224#define RC_MAP_HAUPPAUGE_NEW "rc-hauppauge" 247#define RC_MAP_HAUPPAUGE_NEW "rc-hauppauge"
diff --git a/include/media/v4l2-event.h b/include/media/v4l2-event.h
index a700285c64a9..6741910c3a18 100644
--- a/include/media/v4l2-event.h
+++ b/include/media/v4l2-event.h
@@ -15,11 +15,6 @@
15 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details. 17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301 USA
23 */ 18 */
24 19
25#ifndef V4L2_EVENT_H 20#ifndef V4L2_EVENT_H
diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
index e19e6246e21c..62633e7d2630 100644
--- a/include/media/v4l2-fh.h
+++ b/include/media/v4l2-fh.h
@@ -16,11 +16,6 @@
16 * WITHOUT ANY WARRANTY; without even the implied warranty of 16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details. 18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23 * 02110-1301 USA
24 */ 19 */
25 20
26#ifndef V4L2_FH_H 21#ifndef V4L2_FH_H
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index cf778c5dca18..0ab1c5df6fac 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -592,9 +592,9 @@ struct v4l2_subdev_ir_ops {
592/** 592/**
593 * struct v4l2_subdev_pad_config - Used for storing subdev pad information. 593 * struct v4l2_subdev_pad_config - Used for storing subdev pad information.
594 * 594 *
595 * @try_fmt: pointer to &struct v4l2_mbus_framefmt 595 * @try_fmt: &struct v4l2_mbus_framefmt
596 * @try_crop: pointer to &struct v4l2_rect to be used for crop 596 * @try_crop: &struct v4l2_rect to be used for crop
597 * @try_compose: pointer to &struct v4l2_rect to be used for compose 597 * @try_compose: &struct v4l2_rect to be used for compose
598 * 598 *
599 * This structure only needs to be passed to the pad op if the 'which' field 599 * This structure only needs to be passed to the pad op if the 'which' field
600 * of the main argument is set to %V4L2_SUBDEV_FORMAT_TRY. For 600 * of the main argument is set to %V4L2_SUBDEV_FORMAT_TRY. For