summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@s-opensource.com>2016-12-15 05:38:35 -0500
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-12-15 05:38:35 -0500
commit65390ea01ce678379da32b01f39fcfac4903f256 (patch)
tree7f849d66121533c331cf61136b124218d87cbf86
parente7aa8c2eb11ba69b1b69099c3c7bd6be3087b0ba (diff)
parentd183e4efcae8d88a2f252e546978658ca6d273cc (diff)
Merge branch 'patchwork' into v4l_for_linus
* patchwork: (496 commits) [media] v4l: tvp5150: Add missing break in set control handler [media] v4l: tvp5150: Don't inline the tvp5150_selmux() function [media] v4l: tvp5150: Compile tvp5150_link_setup out if !CONFIG_MEDIA_CONTROLLER [media] em28xx: don't store usb_device at struct em28xx [media] em28xx: use usb_interface for dev_foo() calls [media] em28xx: don't change the device's name [media] mn88472: fix chip id check on probe [media] mn88473: fix chip id check on probe [media] lirc: fix error paths in lirc_cdev_add() [media] s5p-mfc: Add support for MFC v8 available in Exynos 5433 SoCs [media] s5p-mfc: Rework clock handling [media] s5p-mfc: Don't keep clock prepared all the time [media] s5p-mfc: Kill all IS_ERR_OR_NULL in clocks management code [media] s5p-mfc: Remove dead conditional code [media] s5p-mfc: Ensure that clock is disabled before turning power off [media] s5p-mfc: Remove special clock rate management [media] s5p-mfc: Use printk_ratelimited for reporting ioctl errors [media] s5p-mfc: Set DMA_ATTR_ALLOC_SINGLE_PAGES [media] vivid: Set color_enc on HSV formats [media] v4l2-tpg: Init hv_enc field with a valid value ...
-rw-r--r--Documentation/devicetree/bindings/media/exynos5-gsc.txt3
-rw-r--r--Documentation/devicetree/bindings/media/hix5hd2-ir.txt6
-rw-r--r--Documentation/devicetree/bindings/media/i2c/adv7604.txt3
-rw-r--r--Documentation/devicetree/bindings/media/mediatek-mdp.txt109
-rw-r--r--Documentation/devicetree/bindings/media/mediatek-vcodec.txt57
-rw-r--r--Documentation/devicetree/bindings/media/renesas,fdp1.txt37
-rw-r--r--Documentation/devicetree/bindings/media/s5p-mfc.txt1
-rw-r--r--Documentation/media/Makefile2
-rw-r--r--Documentation/media/kapi/cec-core.rst38
-rw-r--r--Documentation/media/kapi/csi2.rst61
-rw-r--r--Documentation/media/kapi/dtv-core.rst8
-rw-r--r--Documentation/media/media_kapi.rst1
-rw-r--r--Documentation/media/typical_media_device.svg2974
-rw-r--r--Documentation/media/uapi/cec/cec-ioc-adap-g-caps.rst156
-rw-r--r--Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst488
-rw-r--r--Documentation/media/uapi/cec/cec-ioc-dqevent.rst182
-rw-r--r--Documentation/media/uapi/cec/cec-ioc-g-mode.rst317
-rw-r--r--Documentation/media/uapi/cec/cec-ioc-receive.rst418
-rw-r--r--Documentation/media/uapi/v4l/control.rst88
-rw-r--r--Documentation/media/uapi/v4l/dev-codec.rst2
-rw-r--r--Documentation/media/uapi/v4l/extended-controls.rst6
-rw-r--r--Documentation/media/uapi/v4l/hsv-formats.rst19
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-002.rst5
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-003.rst5
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-006.rst31
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-013.rst5
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst157
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-reserved.rst10
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-rgb.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-srggb10p.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-srggb12.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-srggb16.rst (renamed from Documentation/media/uapi/v4l/pixfmt-sbggr16.rst)25
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-srggb8.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt.rst1
-rw-r--r--Documentation/media/uapi/v4l/subdev-image-processing-crop.svg299
-rw-r--r--Documentation/media/uapi/v4l/subdev-image-processing-full.svg779
-rw-r--r--Documentation/media/uapi/v4l/subdev-image-processing-scaling-multi-source.svg566
-rw-r--r--Documentation/media/uapi/v4l/v4l2.rst9
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-dv-timings.rst11
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-tuner.rst4
-rw-r--r--Documentation/media/v4l-drivers/au0828-cardlist.rst18
-rw-r--r--Documentation/media/v4l-drivers/bttv-cardlist.rst340
-rw-r--r--Documentation/media/v4l-drivers/cx23885-cardlist.rst122
-rw-r--r--Documentation/media/v4l-drivers/cx88-cardlist.rst188
-rw-r--r--Documentation/media/v4l-drivers/em28xx-cardlist.rst206
-rw-r--r--Documentation/media/v4l-drivers/gspca-cardlist.rst843
-rw-r--r--Documentation/media/v4l-drivers/index.rst3
-rw-r--r--Documentation/media/v4l-drivers/ivtv-cardlist.rst61
-rw-r--r--Documentation/media/v4l-drivers/rcar-fdp1.rst37
-rw-r--r--Documentation/media/v4l-drivers/saa7134-cardlist.rst400
-rw-r--r--Documentation/media/v4l-drivers/saa7164-cardlist.rst36
-rw-r--r--Documentation/media/v4l-drivers/tm6000-cardlist.rst39
-rw-r--r--Documentation/media/v4l-drivers/tuner-cardlist.rst188
-rw-r--r--Documentation/media/v4l-drivers/usbvision-cardlist.rst142
-rw-r--r--Documentation/media/videodev2.h.rst.exceptions7
-rw-r--r--MAINTAINERS43
-rw-r--r--arch/arm64/boot/dts/mediatek/mt8173.dtsi128
-rw-r--r--drivers/media/Kconfig18
-rw-r--r--drivers/media/Makefile4
-rw-r--r--drivers/media/cec/Makefile (renamed from drivers/staging/media/cec/Makefile)2
-rw-r--r--drivers/media/cec/cec-adap.c (renamed from drivers/staging/media/cec/cec-adap.c)244
-rw-r--r--drivers/media/cec/cec-api.c (renamed from drivers/staging/media/cec/cec-api.c)13
-rw-r--r--drivers/media/cec/cec-core.c (renamed from drivers/staging/media/cec/cec-core.c)18
-rw-r--r--drivers/media/cec/cec-priv.h (renamed from drivers/staging/media/cec/cec-priv.h)0
-rw-r--r--drivers/media/common/b2c2/flexcop-common.h1
-rw-r--r--drivers/media/common/b2c2/flexcop-eeprom.c3
-rw-r--r--drivers/media/common/b2c2/flexcop-i2c.c14
-rw-r--r--drivers/media/common/b2c2/flexcop-misc.c9
-rw-r--r--drivers/media/common/b2c2/flexcop.c3
-rw-r--r--drivers/media/common/cx2341x.c12
-rw-r--r--drivers/media/common/saa7146/saa7146_video.c4
-rw-r--r--drivers/media/common/siano/smsdvb-main.c2
-rw-r--r--drivers/media/common/tveeprom.c77
-rw-r--r--drivers/media/common/v4l2-tpg/v4l2-tpg-core.c412
-rw-r--r--drivers/media/dvb-core/Kconfig17
-rw-r--r--drivers/media/dvb-core/Makefile2
-rw-r--r--drivers/media/dvb-core/demux.h5
-rw-r--r--drivers/media/dvb-core/dmxdev.c28
-rw-r--r--drivers/media/dvb-core/dvb-usb-ids.h2
-rw-r--r--drivers/media/dvb-core/dvb_ca_en50221.c60
-rw-r--r--drivers/media/dvb-core/dvb_demux.c115
-rw-r--r--drivers/media/dvb-core/dvb_demux.h2
-rw-r--r--drivers/media/dvb-core/dvb_filter.c603
-rw-r--r--drivers/media/dvb-core/dvb_frontend.c107
-rw-r--r--drivers/media/dvb-core/dvb_frontend.h10
-rw-r--r--drivers/media/dvb-core/dvb_net.c952
-rw-r--r--drivers/media/dvb-core/dvbdev.c44
-rw-r--r--drivers/media/dvb-core/dvbdev.h25
-rw-r--r--drivers/media/dvb-frontends/Kconfig9
-rw-r--r--drivers/media/dvb-frontends/af9013.c4
-rw-r--r--drivers/media/dvb-frontends/af9033.c2
-rw-r--r--drivers/media/dvb-frontends/as102_fe.c2
-rw-r--r--drivers/media/dvb-frontends/ascot2e.c3
-rw-r--r--drivers/media/dvb-frontends/atbm8830.c2
-rw-r--r--drivers/media/dvb-frontends/au8522_common.c4
-rw-r--r--drivers/media/dvb-frontends/au8522_dig.c4
-rw-r--r--drivers/media/dvb-frontends/bcm3510.c4
-rw-r--r--drivers/media/dvb-frontends/cx22700.c4
-rw-r--r--drivers/media/dvb-frontends/cx24110.c8
-rw-r--r--drivers/media/dvb-frontends/cx24113.c7
-rw-r--r--drivers/media/dvb-frontends/cx24116.c12
-rw-r--r--drivers/media/dvb-frontends/cx24117.c8
-rw-r--r--drivers/media/dvb-frontends/cx24120.c7
-rw-r--r--drivers/media/dvb-frontends/cx24123.c8
-rw-r--r--drivers/media/dvb-frontends/cxd2841er.c6
-rw-r--r--drivers/media/dvb-frontends/dib0070.c53
-rw-r--r--drivers/media/dvb-frontends/dib0090.c165
-rw-r--r--drivers/media/dvb-frontends/dib3000mb.c141
-rw-r--r--drivers/media/dvb-frontends/dib3000mb_priv.h16
-rw-r--r--drivers/media/dvb-frontends/dib3000mc.c12
-rw-r--r--drivers/media/dvb-frontends/dib7000m.c77
-rw-r--r--drivers/media/dvb-frontends/dib7000p.c131
-rw-r--r--drivers/media/dvb-frontends/dib8000.c261
-rw-r--r--drivers/media/dvb-frontends/dib9000.c175
-rw-r--r--drivers/media/dvb-frontends/dibx000_common.c46
-rw-r--r--drivers/media/dvb-frontends/dibx000_common.h2
-rw-r--r--drivers/media/dvb-frontends/drx39xyj/drxj.c4
-rw-r--r--drivers/media/dvb-frontends/drxd_hard.c2
-rw-r--r--drivers/media/dvb-frontends/drxk_hard.c2
-rw-r--r--drivers/media/dvb-frontends/ds3000.c19
-rw-r--r--drivers/media/dvb-frontends/dvb-pll.c22
-rw-r--r--drivers/media/dvb-frontends/dvb_dummy_fe.c12
-rw-r--r--drivers/media/dvb-frontends/ec100.c4
-rw-r--r--drivers/media/dvb-frontends/gp8psk-fe.c4
-rw-r--r--drivers/media/dvb-frontends/hd29l2.c4
-rw-r--r--drivers/media/dvb-frontends/helene.c3
-rw-r--r--drivers/media/dvb-frontends/horus3a.c3
-rw-r--r--drivers/media/dvb-frontends/itd1000.c3
-rw-r--r--drivers/media/dvb-frontends/ix2505v.c3
-rw-r--r--drivers/media/dvb-frontends/l64781.c4
-rw-r--r--drivers/media/dvb-frontends/lg2160.c4
-rw-r--r--drivers/media/dvb-frontends/lgdt3305.c8
-rw-r--r--drivers/media/dvb-frontends/lgdt3306a.c4
-rw-r--r--drivers/media/dvb-frontends/lgdt330x.c11
-rw-r--r--drivers/media/dvb-frontends/lgs8gl5.c4
-rw-r--r--drivers/media/dvb-frontends/lgs8gxx.c2
-rw-r--r--drivers/media/dvb-frontends/m88ds3103.c4
-rw-r--r--drivers/media/dvb-frontends/m88rs2000.c13
-rw-r--r--drivers/media/dvb-frontends/mb86a16.c2
-rw-r--r--drivers/media/dvb-frontends/mb86a20s.c5
-rw-r--r--drivers/media/dvb-frontends/mn88472.c26
-rw-r--r--drivers/media/dvb-frontends/mn88473.c225
-rw-r--r--drivers/media/dvb-frontends/mn88473_priv.h2
-rw-r--r--drivers/media/dvb-frontends/mt312.c9
-rw-r--r--drivers/media/dvb-frontends/mt352.c4
-rw-r--r--drivers/media/dvb-frontends/nxt200x.c15
-rw-r--r--drivers/media/dvb-frontends/nxt6000.c140
-rw-r--r--drivers/media/dvb-frontends/or51132.c10
-rw-r--r--drivers/media/dvb-frontends/or51211.c7
-rw-r--r--drivers/media/dvb-frontends/rtl2830.c2
-rw-r--r--drivers/media/dvb-frontends/rtl2832.c2
-rw-r--r--drivers/media/dvb-frontends/s5h1409.c8
-rw-r--r--drivers/media/dvb-frontends/s5h1411.c8
-rw-r--r--drivers/media/dvb-frontends/s5h1420.c4
-rw-r--r--drivers/media/dvb-frontends/s5h1432.c8
-rw-r--r--drivers/media/dvb-frontends/s921.c8
-rw-r--r--drivers/media/dvb-frontends/si2165.c2
-rw-r--r--drivers/media/dvb-frontends/si21xx.c10
-rw-r--r--drivers/media/dvb-frontends/sp8870.c4
-rw-r--r--drivers/media/dvb-frontends/sp887x.c7
-rw-r--r--drivers/media/dvb-frontends/stb0899_drv.c34
-rw-r--r--drivers/media/dvb-frontends/stb6000.c3
-rw-r--r--drivers/media/dvb-frontends/stb6100.c6
-rw-r--r--drivers/media/dvb-frontends/stv0288.c13
-rw-r--r--drivers/media/dvb-frontends/stv0297.c8
-rw-r--r--drivers/media/dvb-frontends/stv0299.c11
-rw-r--r--drivers/media/dvb-frontends/stv0367.c4
-rw-r--r--drivers/media/dvb-frontends/stv0900_core.c2
-rw-r--r--drivers/media/dvb-frontends/stv0900_sw.c3
-rw-r--r--drivers/media/dvb-frontends/stv090x.c28
-rw-r--r--drivers/media/dvb-frontends/stv6110.c3
-rw-r--r--drivers/media/dvb-frontends/stv6110x.c4
-rw-r--r--drivers/media/dvb-frontends/tc90522.c7
-rw-r--r--drivers/media/dvb-frontends/tda10021.c7
-rw-r--r--drivers/media/dvb-frontends/tda10023.c10
-rw-r--r--drivers/media/dvb-frontends/tda10048.c16
-rw-r--r--drivers/media/dvb-frontends/tda1004x.c4
-rw-r--r--drivers/media/dvb-frontends/tda10071.c4
-rw-r--r--drivers/media/dvb-frontends/tda10086.c2
-rw-r--r--drivers/media/dvb-frontends/tda18271c2dd.c3
-rw-r--r--drivers/media/dvb-frontends/tda665x.c3
-rw-r--r--drivers/media/dvb-frontends/tda8083.c4
-rw-r--r--drivers/media/dvb-frontends/tda8261.c3
-rw-r--r--drivers/media/dvb-frontends/tda826x.c3
-rw-r--r--drivers/media/dvb-frontends/ts2020.c3
-rw-r--r--drivers/media/dvb-frontends/tua6100.c3
-rw-r--r--drivers/media/dvb-frontends/ves1820.c12
-rw-r--r--drivers/media/dvb-frontends/ves1x93.c4
-rw-r--r--drivers/media/dvb-frontends/zl10036.c8
-rw-r--r--drivers/media/dvb-frontends/zl10039.c6
-rw-r--r--drivers/media/dvb-frontends/zl10353.c4
-rw-r--r--drivers/media/firewire/firedtv-avc.c4
-rw-r--r--drivers/media/firewire/firedtv-rc.c5
-rw-r--r--drivers/media/i2c/Kconfig6
-rw-r--r--drivers/media/i2c/ad5820.c5
-rw-r--r--drivers/media/i2c/adv7511.c5
-rw-r--r--drivers/media/i2c/adv7604.c30
-rw-r--r--drivers/media/i2c/adv7842.c6
-rw-r--r--drivers/media/i2c/cx25840/cx25840-core.c11
-rw-r--r--drivers/media/i2c/cx25840/cx25840-ir.c7
-rw-r--r--drivers/media/i2c/msp3400-driver.c90
-rw-r--r--drivers/media/i2c/msp3400-kthreads.c115
-rw-r--r--drivers/media/i2c/smiapp-pll.c3
-rw-r--r--drivers/media/i2c/smiapp/smiapp-core.c916
-rw-r--r--drivers/media/i2c/smiapp/smiapp-regs.c4
-rw-r--r--drivers/media/i2c/smiapp/smiapp.h28
-rw-r--r--drivers/media/i2c/soc_camera/ov772x.c3
-rw-r--r--drivers/media/i2c/soc_camera/ov9740.c3
-rw-r--r--drivers/media/i2c/soc_camera/tw9910.c3
-rw-r--r--drivers/media/i2c/tvaudio.c5
-rw-r--r--drivers/media/i2c/tvp514x.c6
-rw-r--r--drivers/media/i2c/tvp5150.c298
-rw-r--r--drivers/media/media-device.c32
-rw-r--r--drivers/media/media-entity.c6
-rw-r--r--drivers/media/pci/b2c2/flexcop-dma.c6
-rw-r--r--drivers/media/pci/b2c2/flexcop-pci.c7
-rw-r--r--drivers/media/pci/bt8xx/btcx-risc.c46
-rw-r--r--drivers/media/pci/bt8xx/bttv-cards.c9
-rw-r--r--drivers/media/pci/bt8xx/bttv-driver.c6
-rw-r--r--drivers/media/pci/bt8xx/bttv-i2c.c6
-rw-r--r--drivers/media/pci/bt8xx/bttv-input.c4
-rw-r--r--drivers/media/pci/bt8xx/dst.c278
-rw-r--r--drivers/media/pci/bt8xx/dvb-bt8xx.c25
-rw-r--r--drivers/media/pci/cobalt/cobalt-v4l2.c23
-rw-r--r--drivers/media/pci/cx18/cx18-alsa-main.c8
-rw-r--r--drivers/media/pci/cx18/cx18-av-core.c17
-rw-r--r--drivers/media/pci/cx18/cx18-av-firmware.c3
-rw-r--r--drivers/media/pci/cx18/cx18-controls.c9
-rw-r--r--drivers/media/pci/cx18/cx18-driver.c35
-rw-r--r--drivers/media/pci/cx18/cx18-dvb.c6
-rw-r--r--drivers/media/pci/cx18/cx18-fileops.c6
-rw-r--r--drivers/media/pci/cx18/cx18-ioctl.c6
-rw-r--r--drivers/media/pci/cx18/cx18-irq.c4
-rw-r--r--drivers/media/pci/cx18/cx18-mailbox.c39
-rw-r--r--drivers/media/pci/cx18/cx18-queue.c8
-rw-r--r--drivers/media/pci/cx18/cx18-streams.c7
-rw-r--r--drivers/media/pci/cx23885/altera-ci.c15
-rw-r--r--drivers/media/pci/cx23885/altera-ci.h14
-rw-r--r--drivers/media/pci/cx23885/cimax2.c15
-rw-r--r--drivers/media/pci/cx23885/cx23885-417.c65
-rw-r--r--drivers/media/pci/cx23885/cx23885-alsa.c30
-rw-r--r--drivers/media/pci/cx23885/cx23885-cards.c53
-rw-r--r--drivers/media/pci/cx23885/cx23885-core.c146
-rw-r--r--drivers/media/pci/cx23885/cx23885-dvb.c41
-rw-r--r--drivers/media/pci/cx23885/cx23885-f300.c2
-rw-r--r--drivers/media/pci/cx23885/cx23885-i2c.c27
-rw-r--r--drivers/media/pci/cx23885/cx23885-input.c6
-rw-r--r--drivers/media/pci/cx23885/cx23885-ir.c4
-rw-r--r--drivers/media/pci/cx23885/cx23885-vbi.c7
-rw-r--r--drivers/media/pci/cx23885/cx23885-video.c26
-rw-r--r--drivers/media/pci/cx23885/cx23885.h2
-rw-r--r--drivers/media/pci/cx23885/cx23888-ir.c13
-rw-r--r--drivers/media/pci/cx23885/netup-eeprom.c4
-rw-r--r--drivers/media/pci/cx23885/netup-init.c8
-rw-r--r--drivers/media/pci/cx88/cx88-alsa.c304
-rw-r--r--drivers/media/pci/cx88/cx88-blackbird.c292
-rw-r--r--drivers/media/pci/cx88/cx88-cards.c485
-rw-r--r--drivers/media/pci/cx88/cx88-core.c420
-rw-r--r--drivers/media/pci/cx88/cx88-dsp.c136
-rw-r--r--drivers/media/pci/cx88/cx88-dvb.c331
-rw-r--r--drivers/media/pci/cx88/cx88-i2c.c136
-rw-r--r--drivers/media/pci/cx88/cx88-input.c60
-rw-r--r--drivers/media/pci/cx88/cx88-mpeg.c315
-rw-r--r--drivers/media/pci/cx88/cx88-reg.h123
-rw-r--r--drivers/media/pci/cx88/cx88-tvaudio.c169
-rw-r--r--drivers/media/pci/cx88/cx88-vbi.c47
-rw-r--r--drivers/media/pci/cx88/cx88-video.c403
-rw-r--r--drivers/media/pci/cx88/cx88-vp3054-i2c.c60
-rw-r--r--drivers/media/pci/cx88/cx88-vp3054-i2c.h38
-rw-r--r--drivers/media/pci/cx88/cx88.h203
-rw-r--r--drivers/media/pci/ddbridge/ddbridge-core.c6
-rw-r--r--drivers/media/pci/dm1105/dm1105.c3
-rw-r--r--drivers/media/pci/ivtv/ivtv-alsa-main.c12
-rw-r--r--drivers/media/pci/ivtv/ivtv-driver.c37
-rw-r--r--drivers/media/pci/ivtv/ivtv-firmware.c4
-rw-r--r--drivers/media/pci/ivtv/ivtv-yuv.c8
-rw-r--r--drivers/media/pci/ivtv/ivtvfb.c3
-rw-r--r--drivers/media/pci/meye/meye.c17
-rw-r--r--drivers/media/pci/netup_unidvb/netup_unidvb_core.c13
-rw-r--r--drivers/media/pci/pluto2/pluto2.c4
-rw-r--r--drivers/media/pci/pt1/pt1.c7
-rw-r--r--drivers/media/pci/pt1/va1j5jf8007s.c2
-rw-r--r--drivers/media/pci/pt1/va1j5jf8007t.c2
-rw-r--r--drivers/media/pci/saa7134/saa7134-alsa.c3
-rw-r--r--drivers/media/pci/saa7134/saa7134-cards.c8
-rw-r--r--drivers/media/pci/saa7134/saa7134-core.c39
-rw-r--r--drivers/media/pci/saa7134/saa7134-dvb.c32
-rw-r--r--drivers/media/pci/saa7134/saa7134-i2c.c31
-rw-r--r--drivers/media/pci/saa7134/saa7134-input.c13
-rw-r--r--drivers/media/pci/saa7164/saa7164-buffer.c3
-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.c12
-rw-r--r--drivers/media/pci/saa7164/saa7164-core.c66
-rw-r--r--drivers/media/pci/saa7164/saa7164-dvb.c34
-rw-r--r--drivers/media/pci/saa7164/saa7164-encoder.c18
-rw-r--r--drivers/media/pci/saa7164/saa7164-fw.c10
-rw-r--r--drivers/media/pci/saa7164/saa7164-vbi.c14
-rw-r--r--drivers/media/pci/solo6x10/solo6x10-v4l2.c4
-rw-r--r--drivers/media/pci/solo6x10/solo6x10.h3
-rw-r--r--drivers/media/pci/ttpci/Makefile2
-rw-r--r--drivers/media/pci/ttpci/av7110.c49
-rw-r--r--drivers/media/pci/ttpci/av7110.h7
-rw-r--r--drivers/media/pci/ttpci/av7110_hw.c12
-rw-r--r--drivers/media/pci/ttpci/budget-av.c3
-rw-r--r--drivers/media/pci/ttpci/budget-ci.c4
-rw-r--r--drivers/media/pci/ttpci/budget-patch.c3
-rw-r--r--drivers/media/pci/ttpci/budget.c3
-rw-r--r--drivers/media/pci/ttpci/budget.h8
-rw-r--r--drivers/media/pci/ttpci/dvb_filter.c114
-rw-r--r--drivers/media/pci/ttpci/dvb_filter.h (renamed from drivers/media/dvb-core/dvb_filter.h)0
-rw-r--r--drivers/media/pci/ttpci/ttpci-eeprom.c3
-rw-r--r--drivers/media/pci/tw5864/tw5864-reg.h8
-rw-r--r--drivers/media/pci/tw5864/tw5864-video.c13
-rw-r--r--drivers/media/pci/tw68/tw68-video.c16
-rw-r--r--drivers/media/pci/zoran/zoran_device.c35
-rw-r--r--drivers/media/pci/zoran/zoran_driver.c2
-rw-r--r--drivers/media/platform/Kconfig49
-rw-r--r--drivers/media/platform/Makefile3
-rw-r--r--drivers/media/platform/atmel/atmel-isc.c9
-rw-r--r--drivers/media/platform/blackfin/bfin_capture.c6
-rw-r--r--drivers/media/platform/blackfin/ppi.c2
-rw-r--r--drivers/media/platform/coda/coda-common.c7
-rw-r--r--drivers/media/platform/coda/coda-h264.c1
-rw-r--r--drivers/media/platform/davinci/dm355_ccdc.c4
-rw-r--r--drivers/media/platform/davinci/dm644x_ccdc.c4
-rw-r--r--drivers/media/platform/davinci/vpbe.c82
-rw-r--r--drivers/media/platform/davinci/vpfe_capture.c91
-rw-r--r--drivers/media/platform/davinci/vpif_capture.c37
-rw-r--r--drivers/media/platform/davinci/vpif_display.c39
-rw-r--r--drivers/media/platform/davinci/vpss.c7
-rw-r--r--drivers/media/platform/exynos-gsc/gsc-core.c279
-rw-r--r--drivers/media/platform/exynos-gsc/gsc-core.h11
-rw-r--r--drivers/media/platform/exynos-gsc/gsc-m2m.c38
-rw-r--r--drivers/media/platform/exynos4-is/fimc-core.c14
-rw-r--r--drivers/media/platform/exynos4-is/media-dev.c3
-rw-r--r--drivers/media/platform/marvell-ccic/mcam-core.c26
-rw-r--r--drivers/media/platform/mtk-mdp/Makefile9
-rw-r--r--drivers/media/platform/mtk-mdp/mtk_mdp_comp.c159
-rw-r--r--drivers/media/platform/mtk-mdp/mtk_mdp_comp.h72
-rw-r--r--drivers/media/platform/mtk-mdp/mtk_mdp_core.c290
-rw-r--r--drivers/media/platform/mtk-mdp/mtk_mdp_core.h260
-rw-r--r--drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h126
-rw-r--r--drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c1286
-rw-r--r--drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h22
-rw-r--r--drivers/media/platform/mtk-mdp/mtk_mdp_regs.c156
-rw-r--r--drivers/media/platform/mtk-mdp/mtk_mdp_regs.h31
-rw-r--r--drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c145
-rw-r--r--drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h41
-rw-r--r--drivers/media/platform/mtk-vcodec/Makefile15
-rw-r--r--drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c1451
-rw-r--r--drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h88
-rw-r--r--drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c394
-rw-r--r--drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c202
-rw-r--r--drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h28
-rw-r--r--drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h62
-rw-r--r--drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c8
-rw-r--r--drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.c3
-rw-r--r--drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c33
-rw-r--r--drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h5
-rw-r--r--drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c507
-rw-r--r--drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c634
-rw-r--r--drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c967
-rw-r--r--drivers/media/platform/mtk-vcodec/vdec_drv_base.h56
-rw-r--r--drivers/media/platform/mtk-vcodec/vdec_drv_if.c122
-rw-r--r--drivers/media/platform/mtk-vcodec/vdec_drv_if.h101
-rw-r--r--drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h103
-rw-r--r--drivers/media/platform/mtk-vcodec/vdec_vpu_if.c170
-rw-r--r--drivers/media/platform/mtk-vcodec/vdec_vpu_if.h96
-rw-r--r--drivers/media/platform/mtk-vpu/mtk_vpu.c21
-rw-r--r--drivers/media/platform/mtk-vpu/mtk_vpu.h48
-rw-r--r--drivers/media/platform/mx2_emmaprp.c10
-rw-r--r--drivers/media/platform/omap/omap_vout.c24
-rw-r--r--drivers/media/platform/omap/omap_vout_vrfb.c5
-rw-r--r--drivers/media/platform/omap3isp/isp.c23
-rw-r--r--drivers/media/platform/omap3isp/ispccdc.c9
-rw-r--r--drivers/media/platform/omap3isp/ispcsi2.c13
-rw-r--r--drivers/media/platform/omap3isp/ispcsiphy.c4
-rw-r--r--drivers/media/platform/omap3isp/isph3a_aewb.c8
-rw-r--r--drivers/media/platform/omap3isp/isph3a_af.c8
-rw-r--r--drivers/media/platform/omap3isp/isphist.c28
-rw-r--r--drivers/media/platform/omap3isp/ispstat.c58
-rw-r--r--drivers/media/platform/pxa_camera.c18
-rw-r--r--drivers/media/platform/rcar-fcp.c1
-rw-r--r--drivers/media/platform/rcar_fdp1.c2445
-rw-r--r--drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c17
-rw-r--r--drivers/media/platform/s5p-mfc/regs-mfc-v6.h3
-rw-r--r--drivers/media/platform/s5p-mfc/regs-mfc-v8.h2
-rw-r--r--drivers/media/platform/s5p-mfc/regs-mfc.h3
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc.c73
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_common.h12
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_debug.h6
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_dec.c15
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_enc.c2
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_opr.c6
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c7
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_pm.c132
-rw-r--r--drivers/media/platform/sti/bdisp/bdisp-v4l2.c1
-rw-r--r--drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c24
-rw-r--r--drivers/media/platform/sti/hva/hva-hw.c8
-rw-r--r--drivers/media/platform/ti-vpe/Makefile10
-rw-r--r--drivers/media/platform/ti-vpe/cal.c14
-rw-r--r--drivers/media/platform/ti-vpe/csc.c18
-rw-r--r--drivers/media/platform/ti-vpe/csc.h2
-rw-r--r--drivers/media/platform/ti-vpe/sc.c28
-rw-r--r--drivers/media/platform/ti-vpe/sc.h11
-rw-r--r--drivers/media/platform/ti-vpe/vpdma.c355
-rw-r--r--drivers/media/platform/ti-vpe/vpdma.h85
-rw-r--r--drivers/media/platform/ti-vpe/vpdma_priv.h130
-rw-r--r--drivers/media/platform/ti-vpe/vpe.c471
-rw-r--r--drivers/media/platform/via-camera.c7
-rw-r--r--drivers/media/platform/vivid/Kconfig2
-rw-r--r--drivers/media/platform/vivid/vivid-cec.c3
-rw-r--r--drivers/media/platform/vivid/vivid-cec.h1
-rw-r--r--drivers/media/platform/vivid/vivid-core.c13
-rw-r--r--drivers/media/platform/vivid/vivid-core.h3
-rw-r--r--drivers/media/platform/vivid/vivid-ctrls.c25
-rw-r--r--drivers/media/platform/vivid/vivid-vid-cap.c17
-rw-r--r--drivers/media/platform/vivid/vivid-vid-common.c70
-rw-r--r--drivers/media/platform/vivid/vivid-vid-out.c1
-rw-r--r--drivers/media/platform/vsp1/vsp1_drv.c1
-rw-r--r--drivers/media/platform/vsp1/vsp1_pipe.c8
-rw-r--r--drivers/media/platform/vsp1/vsp1_rwpf.c2
-rw-r--r--drivers/media/platform/vsp1/vsp1_video.c5
-rw-r--r--drivers/media/radio/radio-gemtek.c8
-rw-r--r--drivers/media/radio/radio-wl1273.c3
-rw-r--r--drivers/media/radio/si470x/radio-si470x-i2c.c7
-rw-r--r--drivers/media/radio/si470x/radio-si470x-usb.c15
-rw-r--r--drivers/media/radio/si4713/si4713.c13
-rw-r--r--drivers/media/radio/wl128x/fmdrv_common.c46
-rw-r--r--drivers/media/radio/wl128x/fmdrv_rx.c8
-rw-r--r--drivers/media/rc/Kconfig17
-rw-r--r--drivers/media/rc/Makefile1
-rw-r--r--drivers/media/rc/ati_remote.c3
-rw-r--r--drivers/media/rc/ene_ir.c3
-rw-r--r--drivers/media/rc/fintek-cir.c6
-rw-r--r--drivers/media/rc/imon.c61
-rw-r--r--drivers/media/rc/ir-hix5hd2.c25
-rw-r--r--drivers/media/rc/ir-sanyo-decoder.c3
-rw-r--r--drivers/media/rc/ite-cir.c11
-rw-r--r--drivers/media/rc/lirc_dev.c29
-rw-r--r--drivers/media/rc/mceusb.c102
-rw-r--r--drivers/media/rc/meson-ir.c1
-rw-r--r--drivers/media/rc/nuvoton-cir.c143
-rw-r--r--drivers/media/rc/nuvoton-cir.h4
-rw-r--r--drivers/media/rc/rc-ir-raw.c17
-rw-r--r--drivers/media/rc/rc-main.c70
-rw-r--r--drivers/media/rc/redrat3.c327
-rw-r--r--drivers/media/rc/serial_ir.c844
-rw-r--r--drivers/media/rc/streamzap.c11
-rw-r--r--drivers/media/rc/winbond-cir.c13
-rw-r--r--drivers/media/spi/gs1662.c4
-rw-r--r--drivers/media/tuners/fc0011.c11
-rw-r--r--drivers/media/tuners/fc0012.c3
-rw-r--r--drivers/media/tuners/fc0013.c3
-rw-r--r--drivers/media/tuners/max2165.c4
-rw-r--r--drivers/media/tuners/mc44s803.c8
-rw-r--r--drivers/media/tuners/mt2060.c3
-rw-r--r--drivers/media/tuners/mt2063.c4
-rw-r--r--drivers/media/tuners/mt20xx.c25
-rw-r--r--drivers/media/tuners/mt2131.c3
-rw-r--r--drivers/media/tuners/mt2266.c3
-rw-r--r--drivers/media/tuners/mxl5005s.c3
-rw-r--r--drivers/media/tuners/mxl5007t.c4
-rw-r--r--drivers/media/tuners/qt1010.c3
-rw-r--r--drivers/media/tuners/r820t.c4
-rw-r--r--drivers/media/tuners/tda18218.c3
-rw-r--r--drivers/media/tuners/tda18271-common.c4
-rw-r--r--drivers/media/tuners/tda18271-fe.c7
-rw-r--r--drivers/media/tuners/tda18271-maps.c6
-rw-r--r--drivers/media/tuners/tda827x.c3
-rw-r--r--drivers/media/tuners/tda8290.c8
-rw-r--r--drivers/media/tuners/tda9887.c2
-rw-r--r--drivers/media/tuners/tea5761.c10
-rw-r--r--drivers/media/tuners/tea5767.c4
-rw-r--r--drivers/media/tuners/tuner-simple.c49
-rw-r--r--drivers/media/tuners/tuner-xc2028.c120
-rw-r--r--drivers/media/tuners/xc4000.c29
-rw-r--r--drivers/media/tuners/xc5000.c4
-rw-r--r--drivers/media/usb/Kconfig5
-rw-r--r--drivers/media/usb/Makefile1
-rw-r--r--drivers/media/usb/au0828/au0828-video.c3
-rw-r--r--drivers/media/usb/b2c2/flexcop-usb.c11
-rw-r--r--drivers/media/usb/cpia2/cpia2_usb.c4
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-core.c10
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-dvb.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9035.c2
-rw-r--r--drivers/media/usb/dvb-usb-v2/dvbsky.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/lmedm04.c14
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c2
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c12
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c3
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf.c10
-rw-r--r--drivers/media/usb/dvb-usb/af9005-fe.c4
-rw-r--r--drivers/media/usb/dvb-usb/af9005.c1
-rw-r--r--drivers/media/usb/dvb-usb/cinergyT2-core.c6
-rw-r--r--drivers/media/usb/dvb-usb/cinergyT2-fe.c4
-rw-r--r--drivers/media/usb/dvb-usb/cxusb.c26
-rw-r--r--drivers/media/usb/dvb-usb/cxusb.h5
-rw-r--r--drivers/media/usb/dvb-usb/dib0700_core.c5
-rw-r--r--drivers/media/usb/dvb-usb/dib0700_devices.c3
-rw-r--r--drivers/media/usb/dvb-usb/dibusb-common.c2
-rw-r--r--drivers/media/usb/dvb-usb/dibusb-mc-common.c1
-rw-r--r--drivers/media/usb/dvb-usb/dtt200u-fe.c4
-rw-r--r--drivers/media/usb/dvb-usb/dvb-usb-dvb.c3
-rw-r--r--drivers/media/usb/dvb-usb/dvb-usb-firmware.c6
-rw-r--r--drivers/media/usb/dvb-usb/dvb-usb.h6
-rw-r--r--drivers/media/usb/dvb-usb/dw2102.c12
-rw-r--r--drivers/media/usb/dvb-usb/friio-fe.c4
-rw-r--r--drivers/media/usb/dvb-usb/friio.c4
-rw-r--r--drivers/media/usb/dvb-usb/gp8psk.c3
-rw-r--r--drivers/media/usb/dvb-usb/m920x.c10
-rw-r--r--drivers/media/usb/dvb-usb/opera1.c3
-rw-r--r--drivers/media/usb/dvb-usb/technisat-usb2.c3
-rw-r--r--drivers/media/usb/dvb-usb/vp702x-fe.c4
-rw-r--r--drivers/media/usb/dvb-usb/vp7045-fe.c4
-rw-r--r--drivers/media/usb/em28xx/Kconfig2
-rw-r--r--drivers/media/usb/em28xx/em28xx-audio.c95
-rw-r--r--drivers/media/usb/em28xx/em28xx-camera.c69
-rw-r--r--drivers/media/usb/em28xx/em28xx-cards.c204
-rw-r--r--drivers/media/usb/em28xx/em28xx-core.c206
-rw-r--r--drivers/media/usb/em28xx/em28xx-dvb.c112
-rw-r--r--drivers/media/usb/em28xx/em28xx-i2c.c291
-rw-r--r--drivers/media/usb/em28xx/em28xx-input.c65
-rw-r--r--drivers/media/usb/em28xx/em28xx-vbi.c9
-rw-r--r--drivers/media/usb/em28xx/em28xx-video.c163
-rw-r--r--drivers/media/usb/em28xx/em28xx.h19
-rw-r--r--drivers/media/usb/go7007/Kconfig2
-rw-r--r--drivers/media/usb/gspca/gspca.c3
-rw-r--r--drivers/media/usb/gspca/jl2005bcd.c5
-rw-r--r--drivers/media/usb/gspca/m5602/m5602_core.c11
-rw-r--r--drivers/media/usb/gspca/mr97310a.c3
-rw-r--r--drivers/media/usb/gspca/ov519.c3
-rw-r--r--drivers/media/usb/gspca/pac207.c4
-rw-r--r--drivers/media/usb/gspca/pac7302.c3
-rw-r--r--drivers/media/usb/gspca/sn9c20x.c6
-rw-r--r--drivers/media/usb/gspca/spca506.c3
-rw-r--r--drivers/media/usb/gspca/sq905.c3
-rw-r--r--drivers/media/usb/gspca/sq905c.c9
-rw-r--r--drivers/media/usb/gspca/stv06xx/stv06xx.c27
-rw-r--r--drivers/media/usb/gspca/sunplus.c3
-rw-r--r--drivers/media/usb/gspca/topro.c3
-rw-r--r--drivers/media/usb/gspca/zc3xx.c3
-rw-r--r--drivers/media/usb/hdpvr/hdpvr-core.c9
-rw-r--r--drivers/media/usb/hdpvr/hdpvr-i2c.c7
-rw-r--r--drivers/media/usb/hdpvr/hdpvr-video.c26
-rw-r--r--drivers/media/usb/pulse8-cec/Kconfig (renamed from drivers/staging/media/pulse8-cec/Kconfig)2
-rw-r--r--drivers/media/usb/pulse8-cec/Makefile (renamed from drivers/staging/media/pulse8-cec/Makefile)0
-rw-r--r--drivers/media/usb/pulse8-cec/pulse8-cec.c (renamed from drivers/staging/media/pulse8-cec/pulse8-cec.c)12
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-audio.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-cs53l32a.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-cx2584x-v4l.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-debugifc.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-eeprom.c7
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-encoder.c29
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-hdw.c181
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c47
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-io.c35
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-ioread.c36
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-std.c3
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-sysfs.c1
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-v4l2.c10
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-video-v4l.c4
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-wm8775.c3
-rw-r--r--drivers/media/usb/pwc/pwc-if.c4
-rw-r--r--drivers/media/usb/pwc/pwc-v4l.c6
-rw-r--r--drivers/media/usb/siano/smsusb.c4
-rw-r--r--drivers/media/usb/stkwebcam/stk-sensor.c10
-rw-r--r--drivers/media/usb/stkwebcam/stk-webcam.c14
-rw-r--r--drivers/media/usb/stkwebcam/stk-webcam.h2
-rw-r--r--drivers/media/usb/tm6000/tm6000-alsa.c4
-rw-r--r--drivers/media/usb/tm6000/tm6000-core.c14
-rw-r--r--drivers/media/usb/tm6000/tm6000-dvb.c16
-rw-r--r--drivers/media/usb/tm6000/tm6000-i2c.c3
-rw-r--r--drivers/media/usb/tm6000/tm6000-stds.c3
-rw-r--r--drivers/media/usb/tm6000/tm6000-video.c18
-rw-r--r--drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c3
-rw-r--r--drivers/media/usb/ttusb-dec/ttusb_dec.c92
-rw-r--r--drivers/media/usb/ttusb-dec/ttusbdecfe.c8
-rw-r--r--drivers/media/usb/usbtv/usbtv-video.c105
-rw-r--r--drivers/media/usb/usbtv/usbtv.h3
-rw-r--r--drivers/media/usb/usbvision/usbvision-core.c20
-rw-r--r--drivers/media/usb/usbvision/usbvision-video.c4
-rw-r--r--drivers/media/usb/uvc/uvc_driver.c177
-rw-r--r--drivers/media/usb/uvc/uvc_v4l2.c19
-rw-r--r--drivers/media/usb/uvc/uvcvideo.h12
-rw-r--r--drivers/media/usb/zr364xx/zr364xx.c6
-rw-r--r--drivers/media/v4l2-core/Kconfig1
-rw-r--r--drivers/media/v4l2-core/tuner-core.c121
-rw-r--r--drivers/media/v4l2-core/v4l2-compat-ioctl32.c30
-rw-r--r--drivers/media/v4l2-core/v4l2-ctrls.c2
-rw-r--r--drivers/media/v4l2-core/v4l2-dv-timings.c59
-rw-r--r--drivers/media/v4l2-core/v4l2-flash-led-class.c16
-rw-r--r--drivers/media/v4l2-core/v4l2-ioctl.c103
-rw-r--r--drivers/media/v4l2-core/videobuf-core.c3
-rw-r--r--drivers/media/v4l2-core/videobuf2-core.c25
-rw-r--r--drivers/media/v4l2-core/videobuf2-v4l2.c10
-rw-r--r--drivers/media/v4l2-core/videobuf2-vmalloc.c3
-rw-r--r--drivers/staging/media/Kconfig4
-rw-r--r--drivers/staging/media/Makefile2
-rw-r--r--drivers/staging/media/bcm2048/radio-bcm2048.c66
-rw-r--r--drivers/staging/media/bcm2048/radio-bcm2048.h5
-rw-r--r--drivers/staging/media/cec/Kconfig12
-rw-r--r--drivers/staging/media/cec/TODO32
-rw-r--r--drivers/staging/media/davinci_vpfe/Makefile4
-rw-r--r--drivers/staging/media/davinci_vpfe/dm365_resizer.c31
-rw-r--r--drivers/staging/media/davinci_vpfe/dm365_resizer.h2
-rw-r--r--drivers/staging/media/davinci_vpfe/vpfe_video.c8
-rw-r--r--drivers/staging/media/lirc/Kconfig13
-rw-r--r--drivers/staging/media/lirc/Makefile1
-rw-r--r--drivers/staging/media/lirc/lirc_imon.c11
-rw-r--r--drivers/staging/media/lirc/lirc_sasem.c5
-rw-r--r--drivers/staging/media/lirc/lirc_serial.c1130
-rw-r--r--drivers/staging/media/pulse8-cec/TODO52
-rw-r--r--drivers/staging/media/s5p-cec/Kconfig2
-rw-r--r--drivers/staging/media/s5p-cec/TODO12
-rw-r--r--drivers/staging/media/s5p-cec/s5p_cec.c11
-rw-r--r--drivers/staging/media/st-cec/Kconfig2
-rw-r--r--drivers/staging/media/st-cec/TODO7
-rw-r--r--drivers/staging/media/st-cec/stih-cec.c11
-rw-r--r--include/media/cec.h12
-rw-r--r--include/media/media-device.h38
-rw-r--r--include/media/rc-core.h18
-rw-r--r--include/media/v4l2-common.h7
-rw-r--r--include/media/v4l2-dv-timings.h20
-rw-r--r--include/media/v4l2-mem2mem.h3
-rw-r--r--include/media/v4l2-tpg.h24
-rw-r--r--include/uapi/linux/Kbuild2
-rw-r--r--include/uapi/linux/cec-funcs.h (renamed from include/linux/cec-funcs.h)76
-rw-r--r--include/uapi/linux/cec.h (renamed from include/linux/cec.h)94
-rw-r--r--include/uapi/linux/v4l2-controls.h1
-rw-r--r--include/uapi/linux/v4l2-dv-timings.h97
-rw-r--r--include/uapi/linux/videodev2.h118
633 files changed, 27616 insertions, 13386 deletions
diff --git a/Documentation/devicetree/bindings/media/exynos5-gsc.txt b/Documentation/devicetree/bindings/media/exynos5-gsc.txt
index 5fe9372abb37..26ca25b6d264 100644
--- a/Documentation/devicetree/bindings/media/exynos5-gsc.txt
+++ b/Documentation/devicetree/bindings/media/exynos5-gsc.txt
@@ -3,7 +3,8 @@
3G-Scaler is used for scaling and color space conversion on EXYNOS5 SoCs. 3G-Scaler is used for scaling and color space conversion on EXYNOS5 SoCs.
4 4
5Required properties: 5Required properties:
6- compatible: should be "samsung,exynos5-gsc" 6- compatible: should be "samsung,exynos5-gsc" (for Exynos 5250, 5420 and
7 5422 SoCs) or "samsung,exynos5433-gsc" (Exynos 5433)
7- reg: should contain G-Scaler physical address location and length. 8- reg: should contain G-Scaler physical address location and length.
8- interrupts: should contain G-Scaler interrupt number 9- interrupts: should contain G-Scaler interrupt number
9 10
diff --git a/Documentation/devicetree/bindings/media/hix5hd2-ir.txt b/Documentation/devicetree/bindings/media/hix5hd2-ir.txt
index fb5e7606643a..54e1bede6244 100644
--- a/Documentation/devicetree/bindings/media/hix5hd2-ir.txt
+++ b/Documentation/devicetree/bindings/media/hix5hd2-ir.txt
@@ -8,10 +8,11 @@ Required properties:
8 the device. The interrupt specifier format depends on the interrupt 8 the device. The interrupt specifier format depends on the interrupt
9 controller parent. 9 controller parent.
10 - clocks: clock phandle and specifier pair. 10 - clocks: clock phandle and specifier pair.
11 - hisilicon,power-syscon: phandle of syscon used to control power.
12 11
13Optional properties: 12Optional properties:
14 - linux,rc-map-name : Remote control map name. 13 - linux,rc-map-name : Remote control map name.
14 - hisilicon,power-syscon: DEPRECATED. Don't use this in new dts files.
15 Provide correct clocks instead.
15 16
16Example node: 17Example node:
17 18
@@ -19,7 +20,6 @@ Example node:
19 compatible = "hisilicon,hix5hd2-ir"; 20 compatible = "hisilicon,hix5hd2-ir";
20 reg = <0xf8001000 0x1000>; 21 reg = <0xf8001000 0x1000>;
21 interrupts = <0 47 4>; 22 interrupts = <0 47 4>;
22 clocks = <&clock HIX5HD2_FIXED_24M>; 23 clocks = <&clock HIX5HD2_IR_CLOCK>;
23 hisilicon,power-syscon = <&sysctrl>;
24 linux,rc-map-name = "rc-tivo"; 24 linux,rc-map-name = "rc-tivo";
25 }; 25 };
diff --git a/Documentation/devicetree/bindings/media/i2c/adv7604.txt b/Documentation/devicetree/bindings/media/i2c/adv7604.txt
index 8337f75c75da..9cbd92eb5d05 100644
--- a/Documentation/devicetree/bindings/media/i2c/adv7604.txt
+++ b/Documentation/devicetree/bindings/media/i2c/adv7604.txt
@@ -34,6 +34,7 @@ The digital output port node must contain at least one endpoint.
34Optional Properties: 34Optional Properties:
35 35
36 - reset-gpios: Reference to the GPIO connected to the device's reset pin. 36 - reset-gpios: Reference to the GPIO connected to the device's reset pin.
37 - default-input: Select which input is selected after reset.
37 38
38Optional Endpoint Properties: 39Optional Endpoint Properties:
39 40
@@ -47,8 +48,6 @@ Optional Endpoint Properties:
47 If none of hsync-active, vsync-active and pclk-sample is specified the 48 If none of hsync-active, vsync-active and pclk-sample is specified the
48 endpoint will use embedded BT.656 synchronization. 49 endpoint will use embedded BT.656 synchronization.
49 50
50 - default-input: Select which input is selected after reset.
51
52Example: 51Example:
53 52
54 hdmi_receiver@4c { 53 hdmi_receiver@4c {
diff --git a/Documentation/devicetree/bindings/media/mediatek-mdp.txt b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
new file mode 100644
index 000000000000..4182063a54db
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
@@ -0,0 +1,109 @@
1* Mediatek Media Data Path
2
3Media Data Path is used for scaling and color space conversion.
4
5Required properties (controller (parent) node):
6- compatible: "mediatek,mt8173-mdp"
7- mediatek,vpu: the node of video processor unit, see
8 Documentation/devicetree/bindings/media/mediatek-vpu.txt for details.
9
10Required properties (all function blocks, child node):
11- compatible: Should be one of
12 "mediatek,mt8173-mdp-rdma" - read DMA
13 "mediatek,mt8173-mdp-rsz" - resizer
14 "mediatek,mt8173-mdp-wdma" - write DMA
15 "mediatek,mt8173-mdp-wrot" - write DMA with rotation
16- reg: Physical base address and length of the function block register space
17- clocks: device clocks, see
18 Documentation/devicetree/bindings/clock/clock-bindings.txt for details.
19- power-domains: a phandle to the power domain, see
20 Documentation/devicetree/bindings/power/power_domain.txt for details.
21
22Required properties (DMA function blocks, child node):
23- compatible: Should be one of
24 "mediatek,mt8173-mdp-rdma"
25 "mediatek,mt8173-mdp-wdma"
26 "mediatek,mt8173-mdp-wrot"
27- iommus: should point to the respective IOMMU block with master port as
28 argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
29 for details.
30- mediatek,larb: must contain the local arbiters in the current Socs, see
31 Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.txt
32 for details.
33
34Example:
35mdp {
36 compatible = "mediatek,mt8173-mdp";
37 #address-cells = <2>;
38 #size-cells = <2>;
39 ranges;
40 mediatek,vpu = <&vpu>;
41
42 mdp_rdma0: rdma@14001000 {
43 compatible = "mediatek,mt8173-mdp-rdma";
44 reg = <0 0x14001000 0 0x1000>;
45 clocks = <&mmsys CLK_MM_MDP_RDMA0>,
46 <&mmsys CLK_MM_MUTEX_32K>;
47 power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>;
48 iommus = <&iommu M4U_PORT_MDP_RDMA0>;
49 mediatek,larb = <&larb0>;
50 };
51
52 mdp_rdma1: rdma@14002000 {
53 compatible = "mediatek,mt8173-mdp-rdma";
54 reg = <0 0x14002000 0 0x1000>;
55 clocks = <&mmsys CLK_MM_MDP_RDMA1>,
56 <&mmsys CLK_MM_MUTEX_32K>;
57 power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>;
58 iommus = <&iommu M4U_PORT_MDP_RDMA1>;
59 mediatek,larb = <&larb4>;
60 };
61
62 mdp_rsz0: rsz@14003000 {
63 compatible = "mediatek,mt8173-mdp-rsz";
64 reg = <0 0x14003000 0 0x1000>;
65 clocks = <&mmsys CLK_MM_MDP_RSZ0>;
66 power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>;
67 };
68
69 mdp_rsz1: rsz@14004000 {
70 compatible = "mediatek,mt8173-mdp-rsz";
71 reg = <0 0x14004000 0 0x1000>;
72 clocks = <&mmsys CLK_MM_MDP_RSZ1>;
73 power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>;
74 };
75
76 mdp_rsz2: rsz@14005000 {
77 compatible = "mediatek,mt8173-mdp-rsz";
78 reg = <0 0x14005000 0 0x1000>;
79 clocks = <&mmsys CLK_MM_MDP_RSZ2>;
80 power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>;
81 };
82
83 mdp_wdma0: wdma@14006000 {
84 compatible = "mediatek,mt8173-mdp-wdma";
85 reg = <0 0x14006000 0 0x1000>;
86 clocks = <&mmsys CLK_MM_MDP_WDMA>;
87 power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>;
88 iommus = <&iommu M4U_PORT_MDP_WDMA>;
89 mediatek,larb = <&larb0>;
90 };
91
92 mdp_wrot0: wrot@14007000 {
93 compatible = "mediatek,mt8173-mdp-wrot";
94 reg = <0 0x14007000 0 0x1000>;
95 clocks = <&mmsys CLK_MM_MDP_WROT0>;
96 power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>;
97 iommus = <&iommu M4U_PORT_MDP_WROT0>;
98 mediatek,larb = <&larb0>;
99 };
100
101 mdp_wrot1: wrot@14008000 {
102 compatible = "mediatek,mt8173-mdp-wrot";
103 reg = <0 0x14008000 0 0x1000>;
104 clocks = <&mmsys CLK_MM_MDP_WROT1>;
105 power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>;
106 iommus = <&iommu M4U_PORT_MDP_WROT1>;
107 mediatek,larb = <&larb4>;
108 };
109};
diff --git a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
index 59a47a5b924b..46c15c54175d 100644
--- a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
+++ b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
@@ -1,25 +1,74 @@
1Mediatek Video Codec 1Mediatek Video Codec
2 2
3Mediatek Video Codec is the video codec hw present in Mediatek SoCs which 3Mediatek Video Codec is the video codec hw present in Mediatek SoCs which
4supports high resolution encoding functionalities. 4supports high resolution encoding and decoding functionalities.
5 5
6Required properties: 6Required properties:
7- compatible : "mediatek,mt8173-vcodec-enc" for encoder 7- compatible : "mediatek,mt8173-vcodec-enc" for encoder
8 "mediatek,mt8173-vcodec-dec" for decoder.
8- reg : Physical base address of the video codec registers and length of 9- reg : Physical base address of the video codec registers and length of
9 memory mapped region. 10 memory mapped region.
10- interrupts : interrupt number to the cpu. 11- interrupts : interrupt number to the cpu.
11- mediatek,larb : must contain the local arbiters in the current Socs. 12- mediatek,larb : must contain the local arbiters in the current Socs.
12- clocks : list of clock specifiers, corresponding to entries in 13- clocks : list of clock specifiers, corresponding to entries in
13 the clock-names property. 14 the clock-names property.
14- clock-names: encoder must contain "venc_sel_src", "venc_sel", 15- clock-names: encoder must contain "venc_sel_src", "venc_sel",,
15- "venc_lt_sel_src", "venc_lt_sel". 16 "venc_lt_sel_src", "venc_lt_sel", decoder must contain "vcodecpll",
17 "univpll_d2", "clk_cci400_sel", "vdec_sel", "vdecpll", "vencpll",
18 "venc_lt_sel", "vdec_bus_clk_src".
16- iommus : should point to the respective IOMMU block with master port as 19- iommus : should point to the respective IOMMU block with master port as
17 argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt 20 argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
18 for details. 21 for details.
19- mediatek,vpu : the node of video processor unit 22- mediatek,vpu : the node of video processor unit
20 23
24
21Example: 25Example:
22vcodec_enc: vcodec@0x18002000 { 26
27vcodec_dec: vcodec@16000000 {
28 compatible = "mediatek,mt8173-vcodec-dec";
29 reg = <0 0x16000000 0 0x100>, /*VDEC_SYS*/
30 <0 0x16020000 0 0x1000>, /*VDEC_MISC*/
31 <0 0x16021000 0 0x800>, /*VDEC_LD*/
32 <0 0x16021800 0 0x800>, /*VDEC_TOP*/
33 <0 0x16022000 0 0x1000>, /*VDEC_CM*/
34 <0 0x16023000 0 0x1000>, /*VDEC_AD*/
35 <0 0x16024000 0 0x1000>, /*VDEC_AV*/
36 <0 0x16025000 0 0x1000>, /*VDEC_PP*/
37 <0 0x16026800 0 0x800>, /*VP8_VD*/
38 <0 0x16027000 0 0x800>, /*VP6_VD*/
39 <0 0x16027800 0 0x800>, /*VP8_VL*/
40 <0 0x16028400 0 0x400>; /*VP9_VD*/
41 interrupts = <GIC_SPI 204 IRQ_TYPE_LEVEL_LOW>;
42 mediatek,larb = <&larb1>;
43 iommus = <&iommu M4U_PORT_HW_VDEC_MC_EXT>,
44 <&iommu M4U_PORT_HW_VDEC_PP_EXT>,
45 <&iommu M4U_PORT_HW_VDEC_AVC_MV_EXT>,
46 <&iommu M4U_PORT_HW_VDEC_PRED_RD_EXT>,
47 <&iommu M4U_PORT_HW_VDEC_PRED_WR_EXT>,
48 <&iommu M4U_PORT_HW_VDEC_UFO_EXT>,
49 <&iommu M4U_PORT_HW_VDEC_VLD_EXT>,
50 <&iommu M4U_PORT_HW_VDEC_VLD2_EXT>;
51 mediatek,vpu = <&vpu>;
52 power-domains = <&scpsys MT8173_POWER_DOMAIN_VDEC>;
53 clocks = <&apmixedsys CLK_APMIXED_VCODECPLL>,
54 <&topckgen CLK_TOP_UNIVPLL_D2>,
55 <&topckgen CLK_TOP_CCI400_SEL>,
56 <&topckgen CLK_TOP_VDEC_SEL>,
57 <&topckgen CLK_TOP_VCODECPLL>,
58 <&apmixedsys CLK_APMIXED_VENCPLL>,
59 <&topckgen CLK_TOP_VENC_LT_SEL>,
60 <&topckgen CLK_TOP_VCODECPLL_370P5>;
61 clock-names = "vcodecpll",
62 "univpll_d2",
63 "clk_cci400_sel",
64 "vdec_sel",
65 "vdecpll",
66 "vencpll",
67 "venc_lt_sel",
68 "vdec_bus_clk_src";
69 };
70
71 vcodec_enc: vcodec@0x18002000 {
23 compatible = "mediatek,mt8173-vcodec-enc"; 72 compatible = "mediatek,mt8173-vcodec-enc";
24 reg = <0 0x18002000 0 0x1000>, /*VENC_SYS*/ 73 reg = <0 0x18002000 0 0x1000>, /*VENC_SYS*/
25 <0 0x19002000 0 0x1000>; /*VENC_LT_SYS*/ 74 <0 0x19002000 0 0x1000>; /*VENC_LT_SYS*/
diff --git a/Documentation/devicetree/bindings/media/renesas,fdp1.txt b/Documentation/devicetree/bindings/media/renesas,fdp1.txt
new file mode 100644
index 000000000000..8dd1007bb573
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/renesas,fdp1.txt
@@ -0,0 +1,37 @@
1Renesas R-Car Fine Display Processor (FDP1)
2-------------------------------------------
3
4The FDP1 is a de-interlacing module which converts interlaced video to
5progressive video. It is capable of performing pixel format conversion between
6YCbCr/YUV formats and RGB formats. Only YCbCr/YUV formats are supported as
7an input to the module.
8
9Required properties:
10
11 - compatible: must be "renesas,fdp1"
12 - reg: the register base and size for the device registers
13 - interrupts : interrupt specifier for the FDP1 instance
14 - clocks: reference to the functional clock
15
16Optional properties:
17
18 - power-domains: reference to the power domain that the FDP1 belongs to, if
19 any.
20 - renesas,fcp: a phandle referencing the FCP that handles memory accesses
21 for the FDP1. Not needed on Gen2, mandatory on Gen3.
22
23Please refer to the binding documentation for the clock and/or power domain
24providers for more details.
25
26
27Device node example
28-------------------
29
30 fdp1@fe940000 {
31 compatible = "renesas,fdp1";
32 reg = <0 0xfe940000 0 0x2400>;
33 interrupts = <GIC_SPI 262 IRQ_TYPE_LEVEL_HIGH>;
34 clocks = <&cpg CPG_MOD 119>;
35 power-domains = <&sysc R8A7795_PD_A3VP>;
36 renesas,fcp = <&fcpf0>;
37 };
diff --git a/Documentation/devicetree/bindings/media/s5p-mfc.txt b/Documentation/devicetree/bindings/media/s5p-mfc.txt
index 92c94f5ecbf1..2c901286d818 100644
--- a/Documentation/devicetree/bindings/media/s5p-mfc.txt
+++ b/Documentation/devicetree/bindings/media/s5p-mfc.txt
@@ -12,6 +12,7 @@ Required properties:
12 (b) "samsung,mfc-v6" for MFC v6 present in Exynos5 SoCs 12 (b) "samsung,mfc-v6" for MFC v6 present in Exynos5 SoCs
13 (c) "samsung,mfc-v7" for MFC v7 present in Exynos5420 SoC 13 (c) "samsung,mfc-v7" for MFC v7 present in Exynos5420 SoC
14 (d) "samsung,mfc-v8" for MFC v8 present in Exynos5800 SoC 14 (d) "samsung,mfc-v8" for MFC v8 present in Exynos5800 SoC
15 (e) "samsung,exynos5433-mfc" for MFC v8 present in Exynos5433 SoC
15 16
16 - reg : Physical base address of the IP registers and length of memory 17 - reg : Physical base address of the IP registers and length of memory
17 mapped region. 18 mapped region.
diff --git a/Documentation/media/Makefile b/Documentation/media/Makefile
index 4d8e2ff378c4..32663602ff25 100644
--- a/Documentation/media/Makefile
+++ b/Documentation/media/Makefile
@@ -88,7 +88,7 @@ $(BUILDDIR)/videodev2.h.rst: ${UAPI}/videodev2.h ${PARSER} $(SRC_DIR)/videodev2.
88$(BUILDDIR)/media.h.rst: ${UAPI}/media.h ${PARSER} $(SRC_DIR)/media.h.rst.exceptions 88$(BUILDDIR)/media.h.rst: ${UAPI}/media.h ${PARSER} $(SRC_DIR)/media.h.rst.exceptions
89 @$($(quiet)gen_rst) 89 @$($(quiet)gen_rst)
90 90
91$(BUILDDIR)/cec.h.rst: ${KAPI}/cec.h ${PARSER} $(SRC_DIR)/cec.h.rst.exceptions 91$(BUILDDIR)/cec.h.rst: ${UAPI}/cec.h ${PARSER} $(SRC_DIR)/cec.h.rst.exceptions
92 @$($(quiet)gen_rst) 92 @$($(quiet)gen_rst)
93 93
94$(BUILDDIR)/lirc.h.rst: ${UAPI}/lirc.h ${PARSER} $(SRC_DIR)/lirc.h.rst.exceptions 94$(BUILDDIR)/lirc.h.rst: ${UAPI}/lirc.h ${PARSER} $(SRC_DIR)/lirc.h.rst.exceptions
diff --git a/Documentation/media/kapi/cec-core.rst b/Documentation/media/kapi/cec-core.rst
index 88c33b53ec13..81c6d8e93774 100644
--- a/Documentation/media/kapi/cec-core.rst
+++ b/Documentation/media/kapi/cec-core.rst
@@ -37,9 +37,8 @@ The struct cec_adapter represents the CEC adapter hardware. It is created by
37calling cec_allocate_adapter() and deleted by calling cec_delete_adapter(): 37calling cec_allocate_adapter() and deleted by calling cec_delete_adapter():
38 38
39.. c:function:: 39.. c:function::
40 struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops, 40 struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops, void *priv,
41 void *priv, const char *name, u32 caps, u8 available_las, 41 const char *name, u32 caps, u8 available_las);
42 struct device *parent);
43 42
44.. c:function:: 43.. c:function::
45 void cec_delete_adapter(struct cec_adapter *adap); 44 void cec_delete_adapter(struct cec_adapter *adap);
@@ -66,20 +65,19 @@ available_las:
66 the number of simultaneous logical addresses that this 65 the number of simultaneous logical addresses that this
67 adapter can handle. Must be 1 <= available_las <= CEC_MAX_LOG_ADDRS. 66 adapter can handle. Must be 1 <= available_las <= CEC_MAX_LOG_ADDRS.
68 67
69parent:
70 the parent device.
71
72 68
73To register the /dev/cecX device node and the remote control device (if 69To register the /dev/cecX device node and the remote control device (if
74CEC_CAP_RC is set) you call: 70CEC_CAP_RC is set) you call:
75 71
76.. c:function:: 72.. c:function::
77 int cec_register_adapter(struct cec_adapter \*adap); 73 int cec_register_adapter(struct cec_adapter *adap, struct device *parent);
74
75where parent is the parent device.
78 76
79To unregister the devices call: 77To unregister the devices call:
80 78
81.. c:function:: 79.. c:function::
82 void cec_unregister_adapter(struct cec_adapter \*adap); 80 void cec_unregister_adapter(struct cec_adapter *adap);
83 81
84Note: if cec_register_adapter() fails, then call cec_delete_adapter() to 82Note: if cec_register_adapter() fails, then call cec_delete_adapter() to
85clean up. But if cec_register_adapter() succeeded, then only call 83clean up. But if cec_register_adapter() succeeded, then only call
@@ -106,13 +104,13 @@ your driver:
106 int (*adap_log_addr)(struct cec_adapter *adap, u8 logical_addr); 104 int (*adap_log_addr)(struct cec_adapter *adap, u8 logical_addr);
107 int (*adap_transmit)(struct cec_adapter *adap, u8 attempts, 105 int (*adap_transmit)(struct cec_adapter *adap, u8 attempts,
108 u32 signal_free_time, struct cec_msg *msg); 106 u32 signal_free_time, struct cec_msg *msg);
109 void (\*adap_log_status)(struct cec_adapter *adap); 107 void (*adap_status)(struct cec_adapter *adap, struct seq_file *file);
110 108
111 /* High-level callbacks */ 109 /* High-level callbacks */
112 ... 110 ...
113 }; 111 };
114 112
115The three low-level ops deal with various aspects of controlling the CEC adapter 113The five low-level ops deal with various aspects of controlling the CEC adapter
116hardware: 114hardware:
117 115
118 116
@@ -238,6 +236,18 @@ When a CEC message was received:
238 236
239Speaks for itself. 237Speaks for itself.
240 238
239Implementing the interrupt handler
240----------------------------------
241
242Typically the CEC hardware provides interrupts that signal when a transmit
243finished and whether it was successful or not, and it provides and interrupt
244when a CEC message was received.
245
246The CEC driver should always process the transmit interrupts first before
247handling the receive interrupt. The framework expects to see the cec_transmit_done
248call before the cec_received_msg call, otherwise it can get confused if the
249received message was in reply to the transmitted message.
250
241Implementing the High-Level CEC Adapter 251Implementing the High-Level CEC Adapter
242--------------------------------------- 252---------------------------------------
243 253
@@ -247,11 +257,11 @@ CEC protocol driven. The following high-level callbacks are available:
247.. code-block:: none 257.. code-block:: none
248 258
249 struct cec_adap_ops { 259 struct cec_adap_ops {
250 /\* Low-level callbacks \*/ 260 /* Low-level callbacks */
251 ... 261 ...
252 262
253 /\* High-level CEC message callback \*/ 263 /* High-level CEC message callback */
254 int (\*received)(struct cec_adapter \*adap, struct cec_msg \*msg); 264 int (*received)(struct cec_adapter *adap, struct cec_msg *msg);
255 }; 265 };
256 266
257The received() callback allows the driver to optionally handle a newly 267The received() callback allows the driver to optionally handle a newly
@@ -263,7 +273,7 @@ received CEC message
263If the driver wants to process a CEC message, then it can implement this 273If the driver wants to process a CEC message, then it can implement this
264callback. If it doesn't want to handle this message, then it should return 274callback. If it doesn't want to handle this message, then it should return
265-ENOMSG, otherwise the CEC framework assumes it processed this message and 275-ENOMSG, otherwise the CEC framework assumes it processed this message and
266it will not no anything with it. 276it will not do anything with it.
267 277
268 278
269CEC framework functions 279CEC framework functions
diff --git a/Documentation/media/kapi/csi2.rst b/Documentation/media/kapi/csi2.rst
new file mode 100644
index 000000000000..2004db00b12b
--- /dev/null
+++ b/Documentation/media/kapi/csi2.rst
@@ -0,0 +1,61 @@
1MIPI CSI-2
2==========
3
4CSI-2 is a data bus intended for transferring images from cameras to
5the host SoC. It is defined by the `MIPI alliance`_.
6
7.. _`MIPI alliance`: http://www.mipi.org/
8
9Transmitter drivers
10-------------------
11
12CSI-2 transmitter, such as a sensor or a TV tuner, drivers need to
13provide the CSI-2 receiver with information on the CSI-2 bus
14configuration. These include the V4L2_CID_LINK_FREQ and
15V4L2_CID_PIXEL_RATE controls and
16(:c:type:`v4l2_subdev_video_ops`->s_stream() callback). These
17interface elements must be present on the sub-device represents the
18CSI-2 transmitter.
19
20The V4L2_CID_LINK_FREQ control is used to tell the receiver driver the
21frequency (and not the symbol rate) of the link. The
22V4L2_CID_PIXEL_RATE is may be used by the receiver to obtain the pixel
23rate the transmitter uses. The
24:c:type:`v4l2_subdev_video_ops`->s_stream() callback provides an
25ability to start and stop the stream.
26
27The value of the V4L2_CID_PIXEL_RATE is calculated as follows::
28
29 pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample
30
31where
32
33.. list-table:: variables in pixel rate calculation
34 :header-rows: 1
35
36 * - variable or constant
37 - description
38 * - link_freq
39 - The value of the V4L2_CID_LINK_FREQ integer64 menu item.
40 * - nr_of_lanes
41 - Number of data lanes used on the CSI-2 link. This can
42 be obtained from the OF endpoint configuration.
43 * - 2
44 - Two bits are transferred per clock cycle per lane.
45 * - bits_per_sample
46 - Number of bits per sample.
47
48The transmitter drivers must configure the CSI-2 transmitter to *LP-11
49mode* whenever the transmitter is powered on but not active. Some
50transmitters do this automatically but some have to be explicitly
51programmed to do so.
52
53Receiver drivers
54----------------
55
56Before the receiver driver may enable the CSI-2 transmitter by using
57the :c:type:`v4l2_subdev_video_ops`->s_stream(), it must have powered
58the transmitter up by using the
59:c:type:`v4l2_subdev_core_ops`->s_power() callback. This may take
60place either indirectly by using :c:func:`v4l2_pipeline_pm_use` or
61directly.
diff --git a/Documentation/media/kapi/dtv-core.rst b/Documentation/media/kapi/dtv-core.rst
index a3c4642eabfc..ff86bf0abeae 100644
--- a/Documentation/media/kapi/dtv-core.rst
+++ b/Documentation/media/kapi/dtv-core.rst
@@ -8,14 +8,6 @@ Digital TV Common functions
8 8
9.. kernel-doc:: drivers/media/dvb-core/dvbdev.h 9.. kernel-doc:: drivers/media/dvb-core/dvbdev.h
10 10
11
12
13.. kernel-doc:: drivers/media/dvb-core/dvb_math.h
14 :export: drivers/media/dvb-core/dvb_math.c
15
16.. kernel-doc:: drivers/media/dvb-core/dvbdev.h
17 :export: drivers/media/dvb-core/dvbdev.c
18
19Digital TV Ring buffer 11Digital TV Ring buffer
20---------------------- 12----------------------
21 13
diff --git a/Documentation/media/media_kapi.rst b/Documentation/media/media_kapi.rst
index f282ca270369..bc0638956a43 100644
--- a/Documentation/media/media_kapi.rst
+++ b/Documentation/media/media_kapi.rst
@@ -33,3 +33,4 @@ For more details see the file COPYING in the source distribution of Linux.
33 kapi/rc-core 33 kapi/rc-core
34 kapi/mc-core 34 kapi/mc-core
35 kapi/cec-core 35 kapi/cec-core
36 kapi/csi2
diff --git a/Documentation/media/typical_media_device.svg b/Documentation/media/typical_media_device.svg
index f0c82f72c4b6..0c8abd69f39a 100644
--- a/Documentation/media/typical_media_device.svg
+++ b/Documentation/media/typical_media_device.svg
@@ -1,28 +1,2948 @@
1<?xml version="1.0" encoding="UTF-8" standalone="no"?> 1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<svg stroke-linejoin="round" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" clip-path="url(#a)" xml:space="preserve" fill-rule="evenodd" height="178.78mm" viewBox="0 0 24285.662 17877.829" width="251.99mm" version="1.2" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" preserveAspectRatio="xMidYMid" stroke-width="28.222"><defs><clipPath id="a" clipPathUnits="userSpaceOnUse"><rect y="0" x="0" width="28000" height="21000"/></clipPath></defs><g transform="matrix(1.004 0 0 1 -2185.6 -2186)" class="com.sun.star.drawing.CustomShape"><path fill="#fcf" d="m12231 4800c-516 0-1031 515-1031 1031v4124c0 516 515 1032 1031 1032h8538c516 0 1032-516 1032-1032v-4124c0-516-516-1031-1032-1031h-8538z"/></g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.CustomShape"><path fill="#ffc" d="m3595 15607c-293 0-585 292-585 585v2340c0 293 292 586 585 586h3275c293 0 586-293 586-586v-2340c0-293-293-585-586-585h-3275z"/></g><g transform="translate(-2197.3 -2186)" class="com.sun.star.drawing.CustomShape"><path fill="#e6e6e6" d="m2663 2186c-461 0-922 461-922 922v11169c0 461 461 923 922 923h3692c461 0 922-462 922-923v-11169c0-461-461-922-922-922h-3692z"/></g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.RectangleShape"><path fill="#ff8080" d="m4461 8602h-2260v-1086h4520v1086h-2260z"/><path fill="none" d="m4461 8602h-2260v-1086h4520v1086h-2260z" stroke="#3465af"/><text class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="8275" x="2579" class="TextPosition"><tspan fill="#000000">Audio decoder</tspan></tspan></tspan></text> 2<svg
3</g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.RectangleShape"><path fill="#ff8080" d="m4461 11772h-2260v-1270h4520v1270h-2260z"/><path fill="none" d="m4461 11772h-2260v-1270h4520v1270h-2260z" stroke="#3465af"/><text class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="11353" x="2617" class="TextPosition"><tspan fill="#000000">Video decoder</tspan></tspan></tspan></text> 3 xmlns:dc="http://purl.org/dc/elements/1.1/"
4</g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.RectangleShape"><path fill="#ff8080" d="m4453 10217h-2269v-1224h4537v1224h-2268z"/><path fill="none" d="m4453 10217h-2269v-1224h4537v1224h-2268z" stroke="#3465af"/><text class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="9821" x="2571" class="TextPosition"><tspan fill="#000000">Audio encoder</tspan></tspan></tspan></text> 4 xmlns:cc="http://creativecommons.org/ns#"
5</g><g transform="translate(-2140.9 -2468.2)" class="com.sun.star.drawing.RectangleShape"><path fill="#cfc" d="m15711 12832h-3810v-1281h7620v1281h-3810z"/><path fill="none" d="m15711 12832h-3810v-1281h7620v1281h-3810z" stroke="#3465af"/><text class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="12407" x="12377" class="TextPosition"><tspan fill="#000000">Button Key/IR input logic</tspan></tspan></tspan></text> 5 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
6</g><g transform="translate(-2140.9 -2411.8)" class="com.sun.star.drawing.RectangleShape"><path fill="#cfe7f5" d="m14169 14572h-2268v-1412h4536v1412h-2268z"/><path fill="none" d="m14169 14572h-2268v-1412h4536v1412h-2268z" stroke="#3465af"/><text class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="14082" x="12882" class="TextPosition"><tspan fill="#000000">EEPROM</tspan></tspan></tspan></text> 6 xmlns:svg="http://www.w3.org/2000/svg"
7</g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.RectangleShape"><path fill="#fc9" d="m5140 17662h-1563v-1715h3126v1715h-1563z"/><path fill="none" d="m5140 17662h-1563v-1715h3126v1715h-1563z" stroke="#3465af"/><text class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="17020" x="4276" class="TextPosition"><tspan fill="#000000">Sensor</tspan></tspan></tspan></text> 7 xmlns="http://www.w3.org/2000/svg"
8</g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.CustomShape"><path fill="#729fcf" d="m6719 8030 385-353v176h1167v-176l386 353-386 354v-177h-1167v177l-385-354z"/><path fill="none" d="m6719 8030 385-353v176h1167v-176l386 353-386 354v-177h-1167v177l-385-354z" stroke="#3465af"/></g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.CustomShape"><path fill="#729fcf" d="m6719 9612 385-353v176h1167v-176l386 353-386 354v-177h-1167v177l-385-354z"/><path fill="none" d="m6719 9612 385-353v176h1167v-176l386 353-386 354v-177h-1167v177l-385-354z" stroke="#3465af"/></g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.CustomShape"><path fill="#729fcf" d="m6721 11100 385-353v176h1166v-176l386 353-386 354v-177h-1166v177l-385-354z"/><path fill="none" d="m6721 11100 385-353v176h1166v-176l386 353-386 354v-177h-1166v177l-385-354z" stroke="#3465af"/></g><g transform="translate(-2140.9 -2411.8)" class="com.sun.star.drawing.CustomShape"><path fill="#729fcf" d="m9962 13854 385-353v176h1166v-176l386 353-386 354v-177h-1166v177l-385-354z"/><path fill="none" d="m9962 13854 385-353v176h1166v-176l386 353-386 354v-177h-1166v177l-385-354z" stroke="#3465af"/></g><g transform="translate(-2140.9 -2468.2)" class="com.sun.star.drawing.CustomShape"><path fill="#729fcf" d="m9962 12163 385-353v176h1166v-176l386 353-386 354v-177h-1166v177l-385-354z"/><path fill="none" d="m9962 12163 385-353v176h1166v-176l386 353-386 354v-177h-1166v177l-385-354z" stroke="#3465af"/></g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.CustomShape"><path fill="#729fcf" d="m9962 17158 670-353v176h2028v-176l671 353-671 354v-177h-2028v177l-670-354z"/><path fill="none" d="m9962 17158 670-353v176h2028v-176l671 353-671 354v-177h-2028v177l-670-354z" stroke="#3465af"/></g><g transform="matrix(0 .83339 -1.0005 0 30268 -5276.3)" class="com.sun.star.drawing.CustomShape"><path fill="#729fcf" d="m23229 12779 1009-978 1009 978h-505v2959h505l-1009 979-1009-979h504v-2959h-504z"/><path fill="none" d="m23229 12779 1009-978 1009 978h-505v2959h505l-1009 979-1009-979h504v-2959h-504z" stroke="#3465af"/></g><g transform="translate(-9973.6 -666.6)" class="com.sun.star.drawing.TextShape"><text class="TextShape"><tspan font-size="706px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="15832" x="24341" class="TextPosition" transform="matrix(0,-1,1,0,8509,40173)"><tspan fill="#000000">System Bus</tspan></tspan></tspan></text> 8 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
9</g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.RectangleShape"><path fill="#cff" d="m13151 9262h-1250v-875h2499v875h-1249z"/><path fill="none" d="m13151 9262h-1250v-875h2499v875h-1249z" stroke="#3465af"/><text class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="9040" x="12215" class="TextPosition"><tspan fill="#000000">Demux</tspan></tspan></tspan></text> 9 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
10</g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.CustomShape"><path fill="#729fcf" d="m9996 8765 373-357v178h1130v-178l374 357-374 358v-179h-1130v179l-373-358z"/><path fill="none" d="m9996 8765 373-357v178h1130v-178l374 357-374 358v-179h-1130v179l-373-358z" stroke="#3465af"/></g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.CustomShape"><path fill="#729fcf" d="m9996 7378 373-358v179h1130v-179l374 358-374 358v-179h-1130v179l-373-358z"/><path fill="none" d="m9996 7378 373-358v179h1130v-179l374 358-374 358v-179h-1130v179l-373-358z" stroke="#3465af"/></g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.RectangleShape"><path fill="#cff" d="m16322 7992h-4421v-1270h8841v1270h-4420z"/><path fill="none" d="m16322 7992h-4421v-1270h8841v1270h-4420z" stroke="#3465af"/><text class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="7573" x="12786" class="TextPosition"><tspan fill="#000000">Conditional Access Module</tspan></tspan></tspan></text> 10 clip-path="url(#a)"
11</g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.RectangleShape"><path fill="#ff8080" d="m4445 13287h-2269v-1224h4537v1224h-2268z"/><path fill="none" d="m4445 13287h-2269v-1224h4537v1224h-2268z" stroke="#3465af"/><text class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="12891" x="2601" class="TextPosition"><tspan fill="#000000">Video encoder</tspan></tspan></tspan></text> 11 xml:space="preserve"
12</g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.CustomShape"><path fill="#729fcf" d="m6721 12634 385-353v176h1166v-176l386 353-386 354v-177h-1166v177l-385-354z"/><path fill="none" d="m6721 12634 385-353v176h1166v-176l386 353-386 354v-177h-1166v177l-385-354z" stroke="#3465af"/></g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.CustomShape"><path fill="#729fcf" d="m20791 7545 385-353v176h1166v-176l386 353-386 354v-177h-1166v177l-385-354z"/><path fill="none" d="m20791 7545 385-353v176h1166v-176l386 353-386 354v-177h-1166v177l-385-354z" stroke="#3465af"/></g><g transform="translate(-2028 -2186)" class="com.sun.star.drawing.TextShape"><text class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="14478" x="1990" class="TextPosition"><tspan fill="#000000">Radio / Analog TV</tspan></tspan></tspan></text> 12 height="179mm"
13</g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.TextShape"><text class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="700" class="TextParagraph"><tspan y="10724" x="14956" class="TextPosition"><tspan fill="#000000">Digital TV</tspan></tspan></tspan></text> 13 viewBox="0 0 22648.239 17899.829"
14</g><g transform="translate(-8970.5 -1395.8)" class="com.sun.star.drawing.TextShape"><text class="TextShape"><tspan font-size="494px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="19167" x="14724" class="TextPosition"><tspan fill="#000000">PS.: picture is not complete: other blocks may be present</tspan></tspan></tspan></text> 14 width="235mm"
15</g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.TextShape"><text class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="18561" x="4199" class="TextPosition"><tspan fill="#000000">Webcam</tspan></tspan></tspan></text> 15 version="1.2"
16</g><g transform="translate(-2140.9 -2468.2)" class="com.sun.star.drawing.RectangleShape"><path fill="#f90" d="m14552 16372h-2650v-1412h5299v1412h-2649z"/><path fill="none" d="m14552 16372h-2650v-1412h5299v1412h-2649z" stroke="#3465af"/><text class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="15882" x="12265" class="TextPosition"><tspan fill="#000000">Processing blocks</tspan></tspan></tspan></text> 16 preserveAspectRatio="xMidYMid"
17</g><g transform="translate(-2140.9 -2468.2)" class="com.sun.star.drawing.CustomShape"><path fill="#729fcf" d="m9962 15654 385-353v176h1166v-176l386 353-386 354v-177h-1166v177l-385-354z"/><path fill="none" d="m9962 15654 385-353v176h1166v-176l386 353-386 354v-177h-1166v177l-385-354z" stroke="#3465af"/></g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.CustomShape"><path fill="#729fcf" d="m6702 16954 397-353v176h1201v-176l398 353-398 354v-177h-1201v177l-397-354z"/><path fill="none" d="m6702 16954 397-353v176h1201v-176l398 353-398 354v-177h-1201v177l-397-354z" stroke="#3465af"/></g><g transform="translate(-2479.5 -2186)" class="com.sun.star.drawing.TextShape"><text class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="8792" x="22850" class="TextPosition"><tspan fill="#000000">Smartcard</tspan></tspan></tspan></text> 17 id="svg2"
18</g><g transform="matrix(1.0048 0 0 1 -2207.4 -2186)" class="com.sun.star.drawing.CustomShape"><path fill="#fcf" d="m2766 2600c-333 0-666 333-666 666v2668c0 333 333 666 666 666h18368c333 0 667-333 667-666v-2668c0-333-334-666-667-666h-18368z"/></g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.RectangleShape"><path fill="#ff8080" d="m5121 5155h-1614v-1816h3227v1816h-1613z"/><path fill="none" d="m5121 5155h-1614v-1816h3227v1816h-1613z" stroke="#3465af"/><text font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextShape"><tspan class="TextParagraph"><tspan y="4111" x="4374" class="TextPosition"><tspan fill="#000000">Tuner</tspan></tspan></tspan><tspan class="TextParagraph"><tspan y="4814" x="4151" class="TextPosition"><tspan fill="#000000">FM/TV</tspan></tspan></tspan></text> 18 inkscape:version="0.91 r13725"
19</g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.CustomShape"><path fill="#ff8080" d="m2902 3702c0 111 40 202 88 202h530c48 0 89-91 89-202 0-110-41-202-89-202h-530c-48 0-88 92-88 202z"/><path fill="none" d="m2902 3702c0 111 40 202 88 202h530c48 0 89-91 89-202 0-110-41-202-89-202h-530c-48 0-88 92-88 202z" stroke="#3465af"/><path fill="#ffb3b3" d="m2902 3702c0 111 40 202 88 202s88-91 88-202c0-110-40-202-88-202s-88 92-88 202z"/><path fill="none" d="m2902 3702c0 111 40 202 88 202s88-91 88-202c0-110-40-202-88-202s-88 92-88 202z" stroke="#3465af"/></g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.CustomShape"><path fill="#ff8080" d="m2903 4267c0 110 40 202 88 202h530c48 0 89-92 89-202s-41-203-89-203h-530c-48 0-88 93-88 203z"/><path fill="none" d="m2903 4267c0 110 40 202 88 202h530c48 0 89-92 89-202s-41-203-89-203h-530c-48 0-88 93-88 203z" stroke="#3465af"/><path fill="#ffb3b3" d="m2903 4267c0 110 40 202 88 202s88-92 88-202-40-203-88-203-88 93-88 203z"/><path fill="none" d="m2903 4267c0 110 40 202 88 202s88-92 88-202-40-203-88-203-88 93-88 203z" stroke="#3465af"/></g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.CustomShape"><path fill="#729fcf" d="m6719 4196 385-353v176h1167v-176l386 353-386 354v-177h-1167v177l-385-354z"/><path fill="none" d="m6719 4196 385-353v176h1167v-176l386 353-386 354v-177h-1167v177l-385-354z" stroke="#3465af"/></g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.CustomShape"><path fill="#729fcf" d="m9979 4150 402-368v184h1217v-184l403 368-403 369v-185h-1217v185l-402-369z"/><path fill="none" d="m9979 4150 402-368v184h1217v-184l403 368-403 369v-185h-1217v185l-402-369z" stroke="#3465af"/></g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.RectangleShape"><path fill="#cff" d="m16500 6189h-4500v-1389h9e3v1389h-4500z"/><path fill="none" d="m16500 6189h-4500v-1389h9e3v1389h-4500z" stroke="#3465af"/><text class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="5710" x="12051" class="TextPosition"><tspan fill="#000000">Satellite Equipment Control (SEC)</tspan></tspan></tspan></text> 19 sodipodi:docname="typical_media_device.svg"
20</g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.CustomShape"><path fill="#cff" d="m13400 4600h-1400v-1e3h2800v1e3h-1400z"/><path fill="none" d="m13400 4600h-1400v-1e3h2800v1e3h-1400z" stroke="#3465af"/><text class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="4316" x="12465" class="TextPosition"><tspan fill="#000000">Demod</tspan></tspan></tspan></text> 20 style="fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round"><metadata
21</g><g transform="translate(-2140.9 -2186)" class="com.sun.star.drawing.CustomShape"><path fill="#729fcf" d="m9979 5451 402-368v184h1217v-184l403 368-403 369v-185h-1217v185l-402-369z"/><path fill="none" d="m9979 5451 402-368v184h1217v-184l403 368-403 369v-185h-1217v185l-402-369z" stroke="#3465af"/></g><path fill="#ff9" d="m7855.1 9099v7302h-1270v-14605h1270v7303z"/><path fill="none" d="m7855.1 9099v7302h-1270v-14605h1270v7303z" stroke="#3465af"/><text y="-6640.4663" x="-20770.572" transform="rotate(-90)" class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="7409.5396" x="-11193.634" class="TextPosition" transform="matrix(0,-1,1,0,-4473,23627)"><tspan fill="#000000">I2C Bus (control bus)</tspan></tspan></tspan></text> 21 id="metadata1533"><rdf:RDF><cc:Work
22<g transform="translate(-2197.3 -2186)" class="com.sun.star.drawing.TextShape"><text class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="3278" x="9391" class="TextPosition"><tspan fill="#000000">Digital TV Frontend</tspan></tspan></tspan></text> 22 rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
23</g><g transform="matrix(1.015 0 0 .99994 -2233.3 -2185.7)" class="com.sun.star.drawing.CustomShape"><g stroke="#3465af" fill="none"><path d="m3e3 2800c-18 0-35 1-53 3"/><path d="m2915 2808c-17 3-35 7-52 12"/><path d="m2832 2830c-16 6-33 12-49 20"/><path d="m2754 2864c-15 8-31 17-46 27"/><path d="m2681 2909c-14 10-28 21-42 32"/><path d="m2614 2962c-13 12-26 24-38 37"/><path d="m2554 3023c-11 13-22 27-33 41"/><path d="m2502 3091c-10 14-19 29-28 45"/><path d="m2459 3164c-8 16-15 32-22 49"/><path d="m2426 3243c-5 17-10 34-14 51"/><path d="m2406 3326c-3 18-5 35-6 53"/><path d="m2400 3411v53"/><path d="m2400 3497v53"/><path d="m2400 3582v53"/><path d="m2400 3668v53"/><path d="m2400 3753v53"/><path d="m2400 3839v53"/><path d="m2400 3924v53"/><path d="m2400 4009v54"/><path d="m2400 4095v53"/><path d="m2400 4180v53"/><path d="m2400 4266v53"/><path d="m2400 4351v53"/><path d="m2400 4437v53"/><path d="m2400 4522v53"/><path d="m2400 4607v54"/><path d="m2400 4693v53"/><path d="m2400 4778v53"/><path d="m2400 4864v53"/><path d="m2400 4949v53"/><path d="m2400 5035v53"/><path d="m2400 5120v53"/><path d="m2400 5205v54"/><path d="m2400 5291v53"/><path d="m2400 5376v53"/><path d="m2400 5462v53"/><path d="m2400 5547v53"/><path d="m2400 5633v53"/><path d="m2400 5718v53"/><path d="m2400 5803c0 18 1 36 3 53"/><path d="m2408 5888c4 18 8 35 13 52"/><path d="m2431 5971c6 16 13 33 20 49"/><path d="m2466 6049c8 15 17 31 27 46"/><path d="m2511 6122c10 14 21 28 32 42"/><path d="m2564 6188c12 13 25 26 38 38"/><path d="m2626 6248c13 11 27 23 41 33"/><path d="m2694 6300c14 10 29 19 45 27"/><path d="m2768 6343c15 7 32 15 48 21"/><path d="m2847 6375c17 5 34 10 51 14"/><path d="m2930 6395c17 2 35 4 53 5"/><path d="m3015 6400h53"/><path d="m3100 6400h53"/><path d="m3186 6400h53"/><path d="m3271 6400h53"/><path d="m3357 6400h53"/><path d="m3442 6400h53"/><path d="m3527 6400h54"/><path d="m3613 6400h53"/><path d="m3698 6400h53"/><path d="m3784 6400h53"/><path d="m3869 6400h53"/><path d="m3955 6400h53"/><path d="m4040 6400h53"/><path d="m4125 6400h54"/><path d="m4211 6400h53"/><path d="m4296 6400h53"/><path d="m4382 6400h53"/><path d="m4467 6400h53"/><path d="m4553 6400h53"/><path d="m4638 6400h53"/><path d="m4723 6400h54"/><path d="m4809 6400h53"/><path d="m4894 6400h53"/><path d="m4980 6400h53"/><path d="m5065 6400h53"/><path d="m5151 6400h53"/><path d="m5236 6400h53"/><path d="m5322 6400h53"/><path d="m5407 6400h53"/><path d="m5492 6400h53"/><path d="m5578 6400h53"/><path d="m5663 6400h53"/><path d="m5749 6400h53"/><path d="m5834 6400h53"/><path d="m5920 6400h53"/><path d="m6005 6400h53"/><path d="m6090 6400h53"/><path d="m6176 6400h53"/><path d="m6261 6400h53"/><path d="m6347 6400h53"/><path d="m6432 6400h53"/><path d="m6518 6400h53"/><path d="m6603 6400h53"/><path d="m6688 6400h54"/><path d="m6774 6400h53"/><path d="m6859 6400h53"/><path d="m6945 6400h53"/><path d="m7030 6400h53"/><path d="m7116 6400h53"/><path d="m7201 6400h53"/><path d="m7286 6400h54"/><path d="m7372 6400h53"/><path d="m7457 6400h53"/><path d="m7543 6400h53"/><path d="m7628 6400h53"/><path d="m7714 6400h53"/><path d="m7799 6400h53"/><path d="m7884 6400h54"/><path d="m7970 6400h53"/><path d="m8055 6400h53"/><path d="m8141 6400h53"/><path d="m8226 6400h53"/><path d="m8312 6400h53"/><path d="m8397 6400h53"/><path d="m8482 6400h54"/><path d="m8568 6400h53"/><path d="m8653 6400h53"/><path d="m8739 6400h53"/><path d="m8824 6400h53"/><path d="m8910 6400h53"/><path d="m8995 6400h53"/><path d="m9081 6400h53"/><path d="m9166 6400h53"/><path d="m9251 6400h53"/><path d="m9337 6400h53"/><path d="m9422 6400h53"/><path d="m9508 6400h53"/><path d="m9593 6400h53"/><path d="m9679 6400h53"/><path d="m9764 6400h53"/><path d="m9849 6400h53"/><path d="m9935 6400h53"/><path d="m10020 6400h53"/><path d="m10106 6400h53"/><path d="m10191 6400h53"/><path d="m10277 6400h53"/><path d="m10362 6400h53"/><path d="m10447 6400h53"/><path d="m10533 6400h53"/><path d="m10618 6400h53"/><path d="m10704 6400h53"/><path d="m10789 6400h53"/><path d="m10875 6400h53"/><path d="m10960 6400h53"/><path d="m11045 6400h54"/><path d="m11131 6400h53"/><path d="m11216 6400h53"/><path d="m11302 6400h53"/><path d="m11387 6400h53"/><path d="m11473 6400h53"/><path d="m11558 6400h53"/><path d="m11643 6400h54"/><path d="m11729 6400h53"/><path d="m11814 6400h53"/><path d="m11900 6400h53"/><path d="m11985 6400h53"/><path d="m12071 6400h53"/><path d="m12156 6400h53"/><path d="m12241 6400h54"/><path d="m12327 6400h53"/><path d="m12412 6400h53"/><path d="m12498 6400h53"/><path d="m12583 6400h53"/><path d="m12669 6400h53"/><path d="m12754 6400h53"/><path d="m12839 6400h54"/><path d="m12925 6400h53"/><path d="m13010 6400h53"/><path d="m13096 6400h53"/><path d="m13181 6400h53"/><path d="m13267 6400h53"/><path d="m13352 6400h53"/><path d="m13438 6400h53"/><path d="m13523 6400h53"/><path d="m13608 6400h53"/><path d="m13694 6400h53"/><path d="m13779 6400h53"/><path d="m13865 6400h53"/><path d="m13950 6400h53"/><path d="m14036 6400h53"/><path d="m14121 6400h53"/><path d="m14206 6400h53"/><path d="m14292 6400h53"/><path d="m14377 6400h53"/><path d="m14463 6400h53"/><path d="m14548 6400h53"/><path d="m14634 6400h53"/><path d="m14719 6400h53"/><path d="m14804 6400h54"/><path d="m14890 6400h53"/><path d="m14975 6400h53"/><path d="m15061 6400h53"/><path d="m15146 6400h53"/><path d="m15232 6400h53"/><path d="m15317 6400h53"/><path d="m15402 6400h54"/><path d="m15488 6400h53"/><path d="m15573 6400h53"/><path d="m15659 6400h53"/><path d="m15744 6400h53"/><path d="m15830 6400h53"/><path d="m15915 6400h53"/><path d="m16000 6400h54"/><path d="m16086 6400h53"/><path d="m16171 6400h53"/><path d="m16257 6400h53"/><path d="m16342 6400h53"/><path d="m16428 6400h53"/><path d="m16513 6400h53"/><path d="m16598 6400h54"/><path d="m16684 6400h53"/><path d="m16769 6400h53"/><path d="m16855 6400h53"/><path d="m16940 6400h53"/><path d="m17026 6400h53"/><path d="m17111 6400h53"/><path d="m17196 6400h54"/><path d="m17282 6400h53"/><path d="m17367 6400h53"/><path d="m17453 6400h53"/><path d="m17538 6400h53"/><path d="m17624 6400h53"/><path d="m17709 6400h53"/><path d="m17795 6400h53"/><path d="m17880 6400h53"/><path d="m17965 6400h53"/><path d="m18051 6400h53"/><path d="m18136 6400h53"/><path d="m18222 6400h53"/><path d="m18307 6400h53"/><path d="m18393 6400h53"/><path d="m18478 6400h53"/><path d="m18563 6400h53"/><path d="m18649 6400h53"/><path d="m18734 6400h53"/><path d="m18820 6400h53"/><path d="m18905 6400h53"/><path d="m18991 6400h53"/><path d="m19076 6400h53"/><path d="m19161 6400h54"/><path d="m19247 6400h53"/><path d="m19332 6400h53"/><path d="m19418 6400h53"/><path d="m19503 6400h53"/><path d="m19589 6400h53"/><path d="m19674 6400h53"/><path d="m19759 6400h54"/><path d="m19845 6400h53"/><path d="m19930 6400h53"/><path d="m20016 6400h53"/><path d="m20101 6400h53"/><path d="m20187 6400h53"/><path d="m20272 6400h53"/><path d="m20357 6400h54"/><path d="m20443 6400h53"/><path d="m20528 6400h53"/><path d="m20614 6400c17-1 35-2 53-5"/><path d="m20699 6390c17-4 34-9 51-14"/><path d="m20781 6365c16-6 32-13 48-21"/><path d="m20858 6329c15-8 31-17 45-27"/><path d="m20930 6283c14-10 28-21 42-32"/><path d="m20996 6229c13-12 25-25 37-38"/><path d="m21055 6167c11-14 22-28 33-42"/><path d="m21106 6098c10-15 19-30 27-45"/><path d="m21148 6024c7-16 14-33 20-49"/><path d="m21179 5944c5-17 9-34 13-51"/><path d="m21197 5861c2-18 4-35 4-53"/><path d="m21201 5776v-54"/><path d="m21201 5690v-53"/><path d="m21201 5605v-53"/><path d="m21201 5519v-53"/><path d="m21201 5434v-53"/><path d="m21201 5348v-53"/><path d="m21201 5263v-53"/><path d="m21201 5178v-54"/><path d="m21201 5092v-53"/><path d="m21201 5007v-53"/><path d="m21201 4921v-53"/><path d="m21201 4836v-53"/><path d="m21201 4750v-53"/><path d="m21201 4665v-53"/><path d="m21201 4579v-53"/><path d="m21201 4494v-53"/><path d="m21201 4409v-53"/><path d="m21201 4323v-53"/><path d="m21201 4238v-53"/><path d="m21201 4152v-53"/><path d="m21201 4067v-53"/><path d="m21201 3981v-53"/><path d="m21201 3896v-53"/><path d="m21201 3811v-53"/><path d="m21201 3725v-53"/><path d="m21201 3640v-53"/><path d="m21201 3554v-53"/><path d="m21201 3469v-53"/><path d="m21201 3383c-1-17-3-35-5-52"/><path d="m21190 3299c-4-17-8-35-14-51"/><path d="m21165 3217c-6-16-13-33-21-49"/><path d="m21129 3140c-9-16-18-31-28-46"/><path d="m21082 3068c-10-14-21-28-33-42"/><path d="m21027 3002c-12-13-24-25-37-37"/><path d="m20965 2944c-14-12-28-22-42-33"/><path d="m20896 2893c-15-9-30-18-46-27"/><path d="m20821 2852c-16-8-32-14-49-20"/><path d="m20741 2821c-17-5-34-9-51-12"/><path d="m20658 2804c-18-3-35-4-53-4"/><path d="m20573 2800h-53"/><path d="m20487 2800h-53"/><path d="m20402 2800h-53"/><path d="m20316 2800h-53"/><path d="m20231 2800h-53"/><path d="m20146 2800h-54"/><path d="m20060 2800h-53"/><path d="m19975 2800h-53"/><path d="m19889 2800h-53"/><path d="m19804 2800h-53"/><path d="m19718 2800h-53"/><path d="m19633 2800h-53"/><path d="m19548 2800h-54"/><path d="m19462 2800h-53"/><path d="m19377 2800h-53"/><path d="m19291 2800h-53"/><path d="m19206 2800h-53"/><path d="m19120 2800h-53"/><path d="m19035 2800h-53"/><path d="m18950 2800h-54"/><path d="m18864 2800h-53"/><path d="m18779 2800h-53"/><path d="m18693 2800h-53"/><path d="m18608 2800h-53"/><path d="m18522 2800h-53"/><path d="m18437 2800h-53"/><path d="m18352 2800h-54"/><path d="m18266 2800h-53"/><path d="m18181 2800h-53"/><path d="m18095 2800h-53"/><path d="m18010 2800h-53"/><path d="m17924 2800h-53"/><path d="m17839 2800h-53"/><path d="m17753 2800h-53"/><path d="m17668 2800h-53"/><path d="m17583 2800h-53"/><path d="m17497 2800h-53"/><path d="m17412 2800h-53"/><path d="m17326 2800h-53"/><path d="m17241 2800h-53"/><path d="m17155 2800h-53"/><path d="m17070 2800h-53"/><path d="m16985 2800h-53"/><path d="m16899 2800h-53"/><path d="m16814 2800h-53"/><path d="m16728 2800h-53"/><path d="m16643 2800h-53"/><path d="m16557 2800h-53"/><path d="m16472 2800h-53"/><path d="m16387 2800h-54"/><path d="m16301 2800h-53"/><path d="m16216 2800h-53"/><path d="m16130 2800h-53"/><path d="m16045 2800h-53"/><path d="m15959 2800h-53"/><path d="m15874 2800h-53"/><path d="m15789 2800h-54"/><path d="m15703 2800h-53"/><path d="m15618 2800h-53"/><path d="m15532 2800h-53"/><path d="m15447 2800h-53"/><path d="m15361 2800h-53"/><path d="m15276 2800h-53"/><path d="m15191 2800h-54"/><path d="m15105 2800h-53"/><path d="m15020 2800h-53"/><path d="m14934 2800h-53"/><path d="m14849 2800h-53"/><path d="m14763 2800h-53"/><path d="m14678 2800h-53"/><path d="m14593 2800h-54"/><path d="m14507 2800h-53"/><path d="m14422 2800h-53"/><path d="m14336 2800h-53"/><path d="m14251 2800h-53"/><path d="m14165 2800h-53"/><path d="m14080 2800h-53"/><path d="m13994 2800h-53"/><path d="m13909 2800h-53"/><path d="m13824 2800h-53"/><path d="m13738 2800h-53"/><path d="m13653 2800h-53"/><path d="m13567 2800h-53"/><path d="m13482 2800h-53"/><path d="m13396 2800h-53"/><path d="m13311 2800h-53"/><path d="m13226 2800h-53"/><path d="m13140 2800h-53"/><path d="m13055 2800h-53"/><path d="m12969 2800h-53"/><path d="m12884 2800h-53"/><path d="m12798 2800h-53"/><path d="m12713 2800h-53"/><path d="m12628 2800h-53"/><path d="m12542 2800h-53"/><path d="m12457 2800h-53"/><path d="m12371 2800h-53"/><path d="m12286 2800h-53"/><path d="m12200 2800h-53"/><path d="m12115 2800h-53"/><path d="m12030 2800h-54"/><path d="m11944 2800h-53"/><path d="m11859 2800h-53"/><path d="m11773 2800h-53"/><path d="m11688 2800h-53"/><path d="m11602 2800h-53"/><path d="m11517 2800h-53"/><path d="m11432 2800h-54"/><path d="m11346 2800h-53"/><path d="m11261 2800h-53"/><path d="m11175 2800h-53"/><path d="m11090 2800h-53"/><path d="m11004 2800h-53"/><path d="m10919 2800h-53"/><path d="m10834 2800h-54"/><path d="m10748 2800h-53"/><path d="m10663 2800h-53"/><path d="m10577 2800h-53"/><path d="m10492 2800h-53"/><path d="m10406 2800h-53"/><path d="m10321 2800h-53"/><path d="m10236 2800h-54"/><path d="m10150 2800h-53"/><path d="m10065 2800h-53"/><path d="m9979 2800h-53"/><path d="m9894 2800h-53"/><path d="m9808 2800h-53"/><path d="m9723 2800h-53"/><path d="m9637 2800h-53"/><path d="m9552 2800h-53"/><path d="m9467 2800h-53"/><path d="m9381 2800h-53"/><path d="m9296 2800h-53"/><path d="m9210 2800h-53"/><path d="m9125 2800h-53"/><path d="m9039 2800h-53"/><path d="m8954 2800h-53"/><path d="m8869 2800h-53"/><path d="m8783 2800h-53"/><path d="m8698 2800h-53"/><path d="m8612 2800h-53"/><path d="m8527 2800h-53"/><path d="m8441 2800h-53"/><path d="m8356 2800h-53"/><path d="m8271 2800h-54"/><path d="m8185 2800h-53"/><path d="m8100 2800h-53"/><path d="m8014 2800h-53"/><path d="m7929 2800h-53"/><path d="m7843 2800h-53"/><path d="m7758 2800h-53"/><path d="m7673 2800h-54"/><path d="m7587 2800h-53"/><path d="m7502 2800h-53"/><path d="m7416 2800h-53"/><path d="m7331 2800h-53"/><path d="m7245 2800h-53"/><path d="m7160 2800h-53"/><path d="m7075 2800h-54"/><path d="m6989 2800h-53"/><path d="m6904 2800h-53"/><path d="m6818 2800h-53"/><path d="m6733 2800h-53"/><path d="m6647 2800h-53"/><path d="m6562 2800h-53"/><path d="m6477 2800h-54"/><path d="m6391 2800h-53"/><path d="m6306 2800h-53"/><path d="m6220 2800h-53"/><path d="m6135 2800h-53"/><path d="m6049 2800h-53"/><path d="m5964 2800h-53"/><path d="m5879 2800h-54"/><path d="m5793 2800h-53"/><path d="m5708 2800h-53"/><path d="m5622 2800h-53"/><path d="m5537 2800h-53"/><path d="m5451 2800h-53"/><path d="m5366 2800h-53"/><path d="m5280 2800h-53"/><path d="m5195 2800h-53"/><path d="m5110 2800h-53"/><path d="m5024 2800h-53"/><path d="m4939 2800h-53"/><path d="m4853 2800h-53"/><path d="m4768 2800h-53"/><path d="m4682 2800h-53"/><path d="m4597 2800h-53"/><path d="m4512 2800h-53"/><path d="m4426 2800h-53"/><path d="m4341 2800h-53"/><path d="m4255 2800h-53"/><path d="m4170 2800h-53"/><path d="m4084 2800h-53"/><path d="m3999 2800h-53"/><path d="m3914 2800h-54"/><path d="m3828 2800h-53"/><path d="m3743 2800h-53"/><path d="m3657 2800h-53"/><path d="m3572 2800h-53"/><path d="m3486 2800h-53"/><path d="m3401 2800h-53"/><path d="m3316 2800h-54"/><path d="m3230 2800h-53"/><path d="m3145 2800h-53"/><path d="m3059 2800h-53"/></g></g><g transform="translate(-2197.3 -2186)"><rect height="1100.7" width="1213.6" y="6917.1" x="23255" fill="#f3e777"/><path fill="#ca4677" d="m22802 7700.4v-405.46l150.7-169.16c82.886-93.039 170.53-186.62 194.77-207.96l44.069-38.798 783.23-0.086 783.23-0.086v613.5 613.5h-978-978v-405.46zm1027.7 136.98v-78.372l-169.91 4.925-169.91 4.9249-5.09 45.854c-8.249 74.303 46.711 101.04 207.69 101.04h137.21v-78.372zm235.86-262.94 4.495-341.31 207.2-8.6408 207.2-8.6408 5.144-46.443c9.596-86.615-41.863-102.05-322.02-96.607l-246.71 4.7956-4.438 419.08-4.439 419.08h74.537 74.538l4.494-341.31zm391.3 313.72c26.41-19.286 36.255-41.399 32.697-73.447l-5.09-45.854h-174.05-174.05l-5.38 48.984c-9.97 90.771 0.993 97.91 150.36 97.91 99.305 0 148.27-7.6982 175.52-27.594zm-627.16-274.84v-77.768h-174.05-174.05v66.246c0 36.436 4.973 71.431 11.051 77.768 6.078 6.3366 84.401 11.521 174.05 11.521h163v-77.768zm659.89-4.9154 5.125-74.042-179.18 4.9155-179.18 4.9155-5.38 48.984c-10.473 95.348-2.259 99.57 183.28 94.197l170.2-4.9284 5.125-74.042zm-659.89-237.63v-78.372l-169.91 4.925-169.91 4.925-5.097 73.447-5.097 73.447h175 175v-78.372zm659.86 4.925-5.097-73.447h-174.05-174.05l-5.38 48.984c-10.289 93.673-2.146 97.91 188.15 97.91h175.52l-5.097-73.447zm-659.86-228.98v-77.768h-137.21c-97.358 0-147.91 7.8138-174.05 26.902-34.952 25.523-49.645 92.242-25.79 117.11 6.078 6.3366 84.401 11.521 174.05 11.521h163v-77.768z"/></g><g transform="matrix(.84874 0 0 .76147 2408.1 3615.3)"><rect height="3076.2" width="2734.3" y="13264" x="19249" fill="#6076b3"/><g stroke-linejoin="round" fill-rule="evenodd" stroke-width="28.222" fill="#e0ee2c"><rect y="13369" width="356.65" x="18937" height="180.95"/><rect y="13708" width="356.65" x="18937" height="180.95"/><rect y="14048" width="356.65" x="18937" height="180.95"/><rect y="14387" width="356.65" x="18937" height="180.95"/><rect y="14726" width="356.65" x="18937" height="180.95"/><rect y="15066" width="356.65" x="18937" height="180.95"/><rect y="15405" width="356.65" x="18937" height="180.95"/><rect y="15744" width="356.65" x="18937" height="180.95"/><rect y="16083" width="356.65" x="18937" height="180.95"/><rect y="13324" width="356.65" x="21939" height="180.95"/><rect y="13663" width="356.65" x="21939" height="180.95"/><rect y="14002" width="356.65" x="21939" height="180.95"/><rect y="14342" width="356.65" x="21939" height="180.95"/><rect y="14681" width="356.65" x="21939" height="180.95"/><rect y="15020" width="356.65" x="21939" height="180.95"/><rect y="15360" width="356.65" x="21939" height="180.95"/><rect y="15699" width="356.65" x="21939" height="180.95"/><rect y="16038" width="356.65" x="21939" height="180.95"/></g><g stroke-linejoin="round" fill-rule="evenodd" transform="matrix(.98702 0 0 .90336 -2675 7020.8)" class="com.sun.star.drawing.TextShape" stroke-width="28.222"><text class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"/></text> 23 rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><sodipodi:namedview
24<text style="word-spacing:0px;letter-spacing:0px" xml:space="preserve" font-size="1128.9px" y="9042.0264" x="22439.668" font-family="Sans" line-height="125%" fill="#000000"><tspan y="9042.0264" x="22439.668">CPU</tspan></text> 24 pagecolor="#ffffff"
25</g></g><g stroke-linejoin="round" fill-rule="evenodd" transform="translate(-11752 543.6)" class="com.sun.star.drawing.TextShape" stroke-width="28.222"><text class="TextShape"><tspan font-size="706px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="15832" x="24341" class="TextPosition" transform="matrix(0,-1,1,0,8509,40173)"><tspan fill="#000000">PCI, USB, SPI, I2C, ...</tspan></tspan></tspan></text> 25 bordercolor="#666666"
26</g><g stroke-linejoin="round" fill-rule="evenodd" transform="translate(-655.31 963.83)" class="com.sun.star.drawing.RectangleShape" stroke-width="28.222"><g transform="matrix(.49166 0 0 1.0059 6045.6 -82.24)"><path fill="#cfe7f5" d="m14169 14572h-2268v-1412h4536v1412h-2268z"/><path fill="none" d="m14169 14572h-2268v-1412h4536v1412h-2268z" stroke="#3465af"/></g><text y="-395.11282" x="-790.22229" class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="13686.9" x="12091.779" class="TextPosition"><tspan fill="#000000">Bridge</tspan></tspan></tspan></text> 26 borderopacity="1"
27<text y="338.66486" x="-846.66675" class="TextShape"><tspan font-size="635px" font-family="&apos;Times New Roman&apos;, serif" font-weight="400" class="TextParagraph"><tspan y="14420.677" x="12035.335" class="TextPosition"><tspan fill="#000000"> DMA</tspan></tspan></tspan></text> 27 objecttolerance="10"
28</g></svg> 28 gridtolerance="10"
29 guidetolerance="10"
30 inkscape:pageopacity="0"
31 inkscape:pageshadow="2"
32 inkscape:window-width="1920"
33 inkscape:window-height="997"
34 id="namedview1531"
35 showgrid="false"
36 fit-margin-top="0"
37 fit-margin-left="0"
38 fit-margin-right="0"
39 fit-margin-bottom="0"
40 inkscape:zoom="1.2707744"
41 inkscape:cx="410.32614"
42 inkscape:cy="316.736"
43 inkscape:window-x="1920"
44 inkscape:window-y="30"
45 inkscape:window-maximized="1"
46 inkscape:current-layer="svg2" /><defs
47 id="defs4"><clipPath
48 id="a"
49 clipPathUnits="userSpaceOnUse"><rect
50 y="0"
51 x="0"
52 width="28000"
53 height="21000"
54 id="rect7" /></clipPath></defs><path
55 style="fill:#ffccff"
56 inkscape:connector-curvature="0"
57 id="path11"
58 d="m 10145.77,2636.013 c -518.0641,0 -1035.1241,515 -1035.1241,1031 l 0,4124 c 0,516 517.06,1032 1035.1241,1032 l 8572.152,0 c 518.064,0 1036.128,-516 1036.128,-1032 l 0,-4124 c 0,-516 -518.064,-1031 -1036.128,-1031 l -8572.152,0 z" /><path
59 style="fill:#ffffcc"
60 inkscape:connector-curvature="0"
61 id="path15"
62 d="m 1505.5459,13443.013 c -293,0 -585,292 -585,585 l 0,2340 c 0,293 292,586 585,586 l 3275,0 c 293,0 586,-293 586,-586 l 0,-2340 c 0,-293 -293,-585 -586,-585 l -3275,0 z" /><path
63 style="fill:#e6e6e6"
64 inkscape:connector-curvature="0"
65 id="path19"
66 d="m 517.1459,22.013 c -461,0 -922,461 -922,922 l 0,11169 c 0,461 461,923 922,923 l 3692,0 c 461,0 922,-462 922,-923 l 0,-11169 c 0,-461 -461,-922 -922,-922 l -3692,0 z" /><path
67 style="fill:#ff8080"
68 inkscape:connector-curvature="0"
69 id="path23"
70 d="m 2371.5459,6438.013 -2260,0 0,-1086 4520,0 0,1086 -2260,0 z" /><path
71 style="fill:none;stroke:#3465af"
72 inkscape:connector-curvature="0"
73 id="path25"
74 d="m 2371.5459,6438.013 -2260,0 0,-1086 4520,0 0,1086 -2260,0 z" /><text
75 id="text27"
76 class="TextShape"
77 x="-2089.4541"
78 y="-2163.9871"><tspan
79 style="font-weight:400;font-size:635px;font-family:'Times New Roman', serif"
80 id="tspan29"
81 class="TextParagraph"
82 font-weight="400"
83 font-size="635px"><tspan
84 id="tspan31"
85 class="TextPosition"
86 x="489.5459"
87 y="6111.0132"><tspan
88 style="fill:#000000"
89 id="tspan33">Audio decoder</tspan></tspan></tspan></text>
90<path
91 style="fill:#ff8080"
92 inkscape:connector-curvature="0"
93 id="path37"
94 d="m 2371.5459,9608.013 -2260,0 0,-1270 4520,0 0,1270 -2260,0 z" /><path
95 style="fill:none;stroke:#3465af"
96 inkscape:connector-curvature="0"
97 id="path39"
98 d="m 2371.5459,9608.013 -2260,0 0,-1270 4520,0 0,1270 -2260,0 z" /><text
99 id="text41"
100 class="TextShape"
101 x="-2089.4541"
102 y="-2163.9871"><tspan
103 style="font-weight:400;font-size:635px;font-family:'Times New Roman', serif"
104 id="tspan43"
105 class="TextParagraph"
106 font-weight="400"
107 font-size="635px"><tspan
108 id="tspan45"
109 class="TextPosition"
110 x="527.5459"
111 y="9189.0127"><tspan
112 style="fill:#000000"
113 id="tspan47">Video decoder</tspan></tspan></tspan></text>
114<path
115 style="fill:#ff8080"
116 inkscape:connector-curvature="0"
117 id="path51"
118 d="m 2363.5459,8053.013 -2269,0 0,-1224 4537,0 0,1224 -2268,0 z" /><path
119 style="fill:none;stroke:#3465af"
120 inkscape:connector-curvature="0"
121 id="path53"
122 d="m 2363.5459,8053.013 -2269,0 0,-1224 4537,0 0,1224 -2268,0 z" /><text
123 id="text55"
124 class="TextShape"
125 x="-2089.4541"
126 y="-2163.9871"><tspan
127 style="font-weight:400;font-size:635px;font-family:'Times New Roman', serif"
128 id="tspan57"
129 class="TextParagraph"
130 font-weight="400"
131 font-size="635px"><tspan
132 id="tspan59"
133 class="TextPosition"
134 x="481.5459"
135 y="7657.0132"><tspan
136 style="fill:#000000"
137 id="tspan61">Audio encoder</tspan></tspan></tspan></text>
138<path
139 style="fill:#ccffcc"
140 inkscape:connector-curvature="0"
141 id="path65"
142 d="m 13621.546,10385.813 -3810.0001,0 0,-1281 7620.0001,0 0,1281 -3810,0 z" /><path
143 style="fill:none;stroke:#3465af"
144 inkscape:connector-curvature="0"
145 id="path67"
146 d="m 13621.546,10385.813 -3810.0001,0 0,-1281 7620.0001,0 0,1281 -3810,0 z" /><text
147 id="text69"
148 class="TextShape"
149 x="-2089.4541"
150 y="-2446.187"><tspan
151 style="font-weight:400;font-size:635px;font-family:'Times New Roman', serif"
152 id="tspan71"
153 class="TextParagraph"
154 font-weight="400"
155 font-size="635px"><tspan
156 id="tspan73"
157 class="TextPosition"
158 x="10287.546"
159 y="9960.8135"><tspan
160 style="fill:#000000"
161 id="tspan75">Button Key/IR input logic</tspan></tspan></tspan></text>
162<path
163 style="fill:#cfe7f5"
164 inkscape:connector-curvature="0"
165 id="path79"
166 d="m 12079.546,12182.213 -2268.0001,0 0,-1412 4536.0001,0 0,1412 -2268,0 z" /><path
167 style="fill:none;stroke:#3465af"
168 inkscape:connector-curvature="0"
169 id="path81"
170 d="m 12079.546,12182.213 -2268.0001,0 0,-1412 4536.0001,0 0,1412 -2268,0 z" /><text
171 id="text83"
172 class="TextShape"
173 x="-2089.4541"
174 y="-2389.7871"><tspan
175 style="font-weight:400;font-size:635px;font-family:'Times New Roman', serif"
176 id="tspan85"
177 class="TextParagraph"
178 font-weight="400"
179 font-size="635px"><tspan
180 id="tspan87"
181 class="TextPosition"
182 x="10792.546"
183 y="11692.213"><tspan
184 style="fill:#000000"
185 id="tspan89">EEPROM</tspan></tspan></tspan></text>
186<path
187 style="fill:#ffcc99"
188 inkscape:connector-curvature="0"
189 id="path93"
190 d="m 3050.5459,15498.013 -1563,0 0,-1715 3126,0 0,1715 -1563,0 z" /><path
191 style="fill:none;stroke:#3465af"
192 inkscape:connector-curvature="0"
193 id="path95"
194 d="m 3050.5459,15498.013 -1563,0 0,-1715 3126,0 0,1715 -1563,0 z" /><text
195 id="text97"
196 class="TextShape"
197 x="-2089.4541"
198 y="-2163.9871"><tspan
199 style="font-weight:400;font-size:635px;font-family:'Times New Roman', serif"
200 id="tspan99"
201 class="TextParagraph"
202 font-weight="400"
203 font-size="635px"><tspan
204 id="tspan101"
205 class="TextPosition"
206 x="2186.5459"
207 y="14856.013"><tspan
208 style="fill:#000000"
209 id="tspan103">Sensor</tspan></tspan></tspan></text>
210<path
211 style="fill:#729fcf"
212 inkscape:connector-curvature="0"
213 id="path107"
214 d="m 4629.5459,5866.013 385,-353 0,176 1167,0 0,-176 386,353 -386,354 0,-177 -1167,0 0,177 -385,-354 z" /><path
215 style="fill:none;stroke:#3465af"
216 inkscape:connector-curvature="0"
217 id="path109"
218 d="m 4629.5459,5866.013 385,-353 0,176 1167,0 0,-176 386,353 -386,354 0,-177 -1167,0 0,177 -385,-354 z" /><path
219 style="fill:#729fcf"
220 inkscape:connector-curvature="0"
221 id="path113"
222 d="m 4629.5459,7448.013 385,-353 0,176 1167,0 0,-176 386,353 -386,354 0,-177 -1167,0 0,177 -385,-354 z" /><path
223 style="fill:none;stroke:#3465af"
224 inkscape:connector-curvature="0"
225 id="path115"
226 d="m 4629.5459,7448.013 385,-353 0,176 1167,0 0,-176 386,353 -386,354 0,-177 -1167,0 0,177 -385,-354 z" /><path
227 style="fill:#729fcf"
228 inkscape:connector-curvature="0"
229 id="path119"
230 d="m 4631.5459,8936.013 385,-353 0,176 1166,0 0,-176 386,353 -386,354 0,-177 -1166,0 0,177 -385,-354 z" /><path
231 style="fill:none;stroke:#3465af"
232 inkscape:connector-curvature="0"
233 id="path121"
234 d="m 4631.5459,8936.013 385,-353 0,176 1166,0 0,-176 386,353 -386,354 0,-177 -1166,0 0,177 -385,-354 z" /><path
235 style="fill:#729fcf"
236 inkscape:connector-curvature="0"
237 id="path125"
238 d="m 7872.5459,11464.213 385,-353 0,176 1166,0 0,-176 386,353 -386,354 0,-177 -1166,0 0,177 -385,-354 z" /><path
239 style="fill:none;stroke:#3465af"
240 inkscape:connector-curvature="0"
241 id="path127"
242 d="m 7872.5459,11464.213 385,-353 0,176 1166,0 0,-176 386,353 -386,354 0,-177 -1166,0 0,177 -385,-354 z" /><path
243 style="fill:#729fcf"
244 inkscape:connector-curvature="0"
245 id="path131"
246 d="m 7872.5459,9716.813 385,-353 0,176 1166,0 0,-176 386,353 -386,354 0,-177 -1166,0 0,177 -385,-354 z" /><path
247 style="fill:none;stroke:#3465af"
248 inkscape:connector-curvature="0"
249 id="path133"
250 d="m 7872.5459,9716.813 385,-353 0,176 1166,0 0,-176 386,353 -386,354 0,-177 -1166,0 0,177 -385,-354 z" /><path
251 style="fill:#729fcf"
252 inkscape:connector-curvature="0"
253 id="path137"
254 d="m 7872.5459,14994.013 670,-353 0,176 2028.0001,0 0,-176 671,353 -671,354 0,-177 -2028.0001,0 0,177 -670,-354 z" /><path
255 style="fill:none;stroke:#3465af"
256 inkscape:connector-curvature="0"
257 id="path139"
258 d="m 7872.5459,14994.013 670,-353 0,176 2028.0001,0 0,-176 671,353 -671,354 0,-177 -2028.0001,0 0,177 -670,-354 z" /><path
259 style="fill:#729fcf"
260 inkscape:connector-curvature="0"
261 id="path143"
262 d="m 17534.058,14104.529 978.488,840.891 -978.488,840.89 0,-420.862 -2960.48,0 0,420.862 -979.489,-840.89 979.489,-840.891 0,420.029 2960.48,0 0,-420.029 z" /><path
263 style="fill:none;stroke:#3465af;stroke-width:25.77035904"
264 inkscape:connector-curvature="0"
265 id="path145"
266 d="m 17534.058,14104.529 978.488,840.891 -978.488,840.89 0,-420.862 -2960.48,0 0,420.862 -979.489,-840.89 979.489,-840.891 0,420.029 2960.48,0 0,-420.029 z" /><text
267 id="text149"
268 class="TextShape"
269 x="-9922.1533"
270 y="-644.58704"><tspan
271 style="font-weight:400;font-size:706px;font-family:'Times New Roman', serif"
272 id="tspan151"
273 class="TextParagraph"
274 font-weight="400"
275 font-size="706px"><tspan
276 id="tspan153"
277 transform="matrix(0,-1,1,0,8509,40173)"
278 class="TextPosition"
279 x="14418.847"
280 y="15187.413"><tspan
281 style="fill:#000000"
282 id="tspan155">System Bus</tspan></tspan></tspan></text>
283<path
284 style="fill:#ccffff"
285 inkscape:connector-curvature="0"
286 id="path159"
287 d="m 11061.546,7098.013 -1250.0001,0 0,-875 2499.0001,0 0,875 -1249,0 z" /><path
288 style="fill:none;stroke:#3465af"
289 inkscape:connector-curvature="0"
290 id="path161"
291 d="m 11061.546,7098.013 -1250.0001,0 0,-875 2499.0001,0 0,875 -1249,0 z" /><text
292 id="text163"
293 class="TextShape"
294 x="-2089.4541"
295 y="-2163.9871"><tspan
296 style="font-weight:400;font-size:635px;font-family:'Times New Roman', serif"
297 id="tspan165"
298 class="TextParagraph"
299 font-weight="400"
300 font-size="635px"><tspan
301 id="tspan167"
302 class="TextPosition"
303 x="10125.546"
304 y="6876.0132"><tspan
305 style="fill:#000000"
306 id="tspan169">Demux</tspan></tspan></tspan></text>
307<path
308 style="fill:#729fcf"
309 inkscape:connector-curvature="0"
310 id="path173"
311 d="m 7906.5459,6601.013 373,-357 0,178 1130,0 0,-178 374,357 -374,358 0,-179 -1130,0 0,179 -373,-358 z" /><path
312 style="fill:none;stroke:#3465af"
313 inkscape:connector-curvature="0"
314 id="path175"
315 d="m 7906.5459,6601.013 373,-357 0,178 1130,0 0,-178 374,357 -374,358 0,-179 -1130,0 0,179 -373,-358 z" /><path
316 style="fill:#729fcf"
317 inkscape:connector-curvature="0"
318 id="path179"
319 d="m 7906.5459,5214.013 373,-358 0,179 1130,0 0,-179 374,358 -374,358 0,-179 -1130,0 0,179 -373,-358 z" /><path
320 style="fill:none;stroke:#3465af"
321 inkscape:connector-curvature="0"
322 id="path181"
323 d="m 7906.5459,5214.013 373,-358 0,179 1130,0 0,-179 374,358 -374,358 0,-179 -1130,0 0,179 -373,-358 z" /><path
324 style="fill:#ccffff"
325 inkscape:connector-curvature="0"
326 id="path185"
327 d="m 14232.546,5828.013 -4421.0001,0 0,-1270 8841.0001,0 0,1270 -4420,0 z" /><path
328 style="fill:none;stroke:#3465af"
329 inkscape:connector-curvature="0"
330 id="path187"
331 d="m 14232.546,5828.013 -4421.0001,0 0,-1270 8841.0001,0 0,1270 -4420,0 z" /><text
332 id="text189"
333 class="TextShape"
334 x="-2089.4541"
335 y="-2163.9871"><tspan
336 style="font-weight:400;font-size:635px;font-family:'Times New Roman', serif"
337 id="tspan191"
338 class="TextParagraph"
339 font-weight="400"
340 font-size="635px"><tspan
341 id="tspan193"
342 class="TextPosition"
343 x="10696.546"
344 y="5409.0132"><tspan
345 style="fill:#000000"
346 id="tspan195">Conditional Access Module</tspan></tspan></tspan></text>
347<path
348 style="fill:#ff8080"
349 inkscape:connector-curvature="0"
350 id="path199"
351 d="m 2355.5459,11123.013 -2269,0 0,-1224 4537,0 0,1224 -2268,0 z" /><path
352 style="fill:none;stroke:#3465af"
353 inkscape:connector-curvature="0"
354 id="path201"
355 d="m 2355.5459,11123.013 -2269,0 0,-1224 4537,0 0,1224 -2268,0 z" /><text
356 id="text203"
357 class="TextShape"
358 x="-2089.4541"
359 y="-2163.9871"><tspan
360 style="font-weight:400;font-size:635px;font-family:'Times New Roman', serif"
361 id="tspan205"
362 class="TextParagraph"
363 font-weight="400"
364 font-size="635px"><tspan
365 id="tspan207"
366 class="TextPosition"
367 x="511.5459"
368 y="10727.013"><tspan
369 style="fill:#000000"
370 id="tspan209">Video encoder</tspan></tspan></tspan></text>
371<path
372 style="fill:#729fcf"
373 inkscape:connector-curvature="0"
374 id="path213"
375 d="m 4631.5459,10470.013 385,-353 0,176 1166,0 0,-176 386,353 -386,354 0,-177 -1166,0 0,177 -385,-354 z" /><path
376 style="fill:none;stroke:#3465af"
377 inkscape:connector-curvature="0"
378 id="path215"
379 d="m 4631.5459,10470.013 385,-353 0,176 1166,0 0,-176 386,353 -386,354 0,-177 -1166,0 0,177 -385,-354 z" /><path
380 style="fill:#729fcf"
381 inkscape:connector-curvature="0"
382 id="path219"
383 d="m 18701.546,5381.013 385,-353 0,176 1166,0 0,-176 386,353 -386,354 0,-177 -1166,0 0,177 -385,-354 z" /><path
384 style="fill:none;stroke:#3465af"
385 inkscape:connector-curvature="0"
386 id="path221"
387 d="m 18701.546,5381.013 385,-353 0,176 1166,0 0,-176 386,353 -386,354 0,-177 -1166,0 0,177 -385,-354 z" /><text
388 id="text225"
389 class="TextShape"
390 x="-1976.5541"
391 y="-2163.9871"><tspan
392 style="font-weight:400;font-size:635px;font-family:'Times New Roman', serif"
393 id="tspan227"
394 class="TextParagraph"
395 font-weight="400"
396 font-size="635px"><tspan
397 id="tspan229"
398 class="TextPosition"
399 x="13.4459"
400 y="12314.013"><tspan
401 style="fill:#000000"
402 id="tspan231">Radio / Analog TV</tspan></tspan></tspan></text>
403<text
404 id="text235"
405 class="TextShape"
406 x="-2089.4541"
407 y="-2163.9871"><tspan
408 style="font-weight:700;font-size:635px;font-family:'Times New Roman', serif"
409 id="tspan237"
410 class="TextParagraph"
411 font-weight="700"
412 font-size="635px"><tspan
413 id="tspan239"
414 class="TextPosition"
415 x="12866.546"
416 y="8560.0127"><tspan
417 style="fill:#000000"
418 id="tspan241">Digital TV</tspan></tspan></tspan></text>
419<text
420 id="text245"
421 class="TextShape"
422 x="-8919.0537"
423 y="-1373.787"><tspan
424 style="font-weight:400;font-size:494px;font-family:'Times New Roman', serif"
425 id="tspan247"
426 class="TextParagraph"
427 font-weight="400"
428 font-size="494px"><tspan
429 id="tspan249"
430 class="TextPosition"
431 x="5804.9458"
432 y="17793.213"><tspan
433 style="fill:#000000"
434 id="tspan251">PS.: picture is not complete: other blocks may be present</tspan></tspan></tspan></text>
435<text
436 id="text255"
437 class="TextShape"
438 x="-2089.4541"
439 y="-2163.9871"><tspan
440 style="font-weight:400;font-size:635px;font-family:'Times New Roman', serif"
441 id="tspan257"
442 class="TextParagraph"
443 font-weight="400"
444 font-size="635px"><tspan
445 id="tspan259"
446 class="TextPosition"
447 x="2109.5459"
448 y="16397.014"><tspan
449 style="fill:#000000"
450 id="tspan261">Webcam</tspan></tspan></tspan></text>
451<path
452 style="fill:#ff9900"
453 inkscape:connector-curvature="0"
454 id="path265"
455 d="m 12462.546,13925.813 -2650.0001,0 0,-1412 5299.0001,0 0,1412 -2649,0 z" /><path
456 style="fill:none;stroke:#3465af"
457 inkscape:connector-curvature="0"
458 id="path267"
459 d="m 12462.546,13925.813 -2650.0001,0 0,-1412 5299.0001,0 0,1412 -2649,0 z" /><text
460 id="text269"
461 class="TextShape"
462 x="-2089.4541"
463 y="-2446.187"><tspan
464 style="font-weight:400;font-size:635px;font-family:'Times New Roman', serif"
465 id="tspan271"
466 class="TextParagraph"
467 font-weight="400"
468 font-size="635px"><tspan
469 id="tspan273"
470 class="TextPosition"
471 x="10175.546"
472 y="13435.813"><tspan
473 style="fill:#000000"
474 id="tspan275">Processing blocks</tspan></tspan></tspan></text>
475<path
476 style="fill:#729fcf"
477 inkscape:connector-curvature="0"
478 id="path279"
479 d="m 7872.5459,13207.813 385,-353 0,176 1166,0 0,-176 386,353 -386,354 0,-177 -1166,0 0,177 -385,-354 z" /><path
480 style="fill:none;stroke:#3465af"
481 inkscape:connector-curvature="0"
482 id="path281"
483 d="m 7872.5459,13207.813 385,-353 0,176 1166,0 0,-176 386,353 -386,354 0,-177 -1166,0 0,177 -385,-354 z" /><path
484 style="fill:#729fcf"
485 inkscape:connector-curvature="0"
486 id="path285"
487 d="m 4612.5459,14790.013 397,-353 0,176 1201,0 0,-176 398,353 -398,354 0,-177 -1201,0 0,177 -397,-354 z" /><path
488 style="fill:none;stroke:#3465af"
489 inkscape:connector-curvature="0"
490 id="path287"
491 d="m 4612.5459,14790.013 397,-353 0,176 1201,0 0,-176 398,353 -398,354 0,-177 -1201,0 0,177 -397,-354 z" /><text
492 id="text291"
493 class="TextShape"
494 x="-2428.0542"
495 y="-2163.9871"><tspan
496 style="font-weight:400;font-size:635px;font-family:'Times New Roman', serif"
497 id="tspan293"
498 class="TextParagraph"
499 font-weight="400"
500 font-size="635px"><tspan
501 id="tspan295"
502 class="TextPosition"
503 x="20421.945"
504 y="6628.0132"><tspan
505 style="fill:#000000"
506 id="tspan297">Smartcard</tspan></tspan></tspan></text>
507<path
508 style="fill:#ffccff"
509 inkscape:connector-curvature="0"
510 id="path301"
511 d="m 623.3227,436.013 c -334.5984,0 -669.1968,333 -669.1968,666 l 0,2668 c 0,333 334.5984,666 669.1968,666 l 18456.1663,0 c 334.598,0 670.202,-333 670.202,-666 l 0,-2668 c 0,-333 -335.604,-666 -670.202,-666 l -18456.1663,0 z" /><path
512 style="fill:#ff8080"
513 inkscape:connector-curvature="0"
514 id="path305"
515 d="m 3031.5459,2991.013 -1614,0 0,-1816 3227,0 0,1816 -1613,0 z" /><path
516 style="fill:none;stroke:#3465af"
517 inkscape:connector-curvature="0"
518 id="path307"
519 d="m 3031.5459,2991.013 -1614,0 0,-1816 3227,0 0,1816 -1613,0 z" /><text
520 style="font-weight:400;font-size:635px;font-family:'Times New Roman', serif"
521 id="text309"
522 class="TextShape"
523 font-weight="400"
524 font-size="635px"
525 x="-2089.4541"
526 y="-2163.9871"><tspan
527 id="tspan311"
528 class="TextParagraph"><tspan
529 id="tspan313"
530 class="TextPosition"
531 x="2284.5459"
532 y="1947.0129"><tspan
533 style="fill:#000000"
534 id="tspan315">Tuner</tspan></tspan></tspan><tspan
535 id="tspan317"
536 class="TextParagraph"><tspan
537 id="tspan319"
538 class="TextPosition"
539 x="2061.5459"
540 y="2650.0129"><tspan
541 style="fill:#000000"
542 id="tspan321">FM/TV</tspan></tspan></tspan></text>
543<path
544 style="fill:#ff8080"
545 inkscape:connector-curvature="0"
546 id="path325"
547 d="m 812.5459,1538.013 c 0,111 40,202 88,202 l 530,0 c 48,0 89,-91 89,-202 0,-110 -41,-202 -89,-202 l -530,0 c -48,0 -88,92 -88,202 z" /><path
548 style="fill:none;stroke:#3465af"
549 inkscape:connector-curvature="0"
550 id="path327"
551 d="m 812.5459,1538.013 c 0,111 40,202 88,202 l 530,0 c 48,0 89,-91 89,-202 0,-110 -41,-202 -89,-202 l -530,0 c -48,0 -88,92 -88,202 z" /><path
552 style="fill:#ffb3b3"
553 inkscape:connector-curvature="0"
554 id="path329"
555 d="m 812.5459,1538.013 c 0,111 40,202 88,202 48,0 88,-91 88,-202 0,-110 -40,-202 -88,-202 -48,0 -88,92 -88,202 z" /><path
556 style="fill:none;stroke:#3465af"
557 inkscape:connector-curvature="0"
558 id="path331"
559 d="m 812.5459,1538.013 c 0,111 40,202 88,202 48,0 88,-91 88,-202 0,-110 -40,-202 -88,-202 -48,0 -88,92 -88,202 z" /><path
560 style="fill:#ff8080"
561 inkscape:connector-curvature="0"
562 id="path335"
563 d="m 813.5459,2103.013 c 0,110 40,202 88,202 l 530,0 c 48,0 89,-92 89,-202 0,-110 -41,-203 -89,-203 l -530,0 c -48,0 -88,93 -88,203 z" /><path
564 style="fill:none;stroke:#3465af"
565 inkscape:connector-curvature="0"
566 id="path337"
567 d="m 813.5459,2103.013 c 0,110 40,202 88,202 l 530,0 c 48,0 89,-92 89,-202 0,-110 -41,-203 -89,-203 l -530,0 c -48,0 -88,93 -88,203 z" /><path
568 style="fill:#ffb3b3"
569 inkscape:connector-curvature="0"
570 id="path339"
571 d="m 813.5459,2103.013 c 0,110 40,202 88,202 48,0 88,-92 88,-202 0,-110 -40,-203 -88,-203 -48,0 -88,93 -88,203 z" /><path
572 style="fill:none;stroke:#3465af"
573 inkscape:connector-curvature="0"
574 id="path341"
575 d="m 813.5459,2103.013 c 0,110 40,202 88,202 48,0 88,-92 88,-202 0,-110 -40,-203 -88,-203 -48,0 -88,93 -88,203 z" /><path
576 style="fill:#729fcf"
577 inkscape:connector-curvature="0"
578 id="path345"
579 d="m 4629.5459,2032.013 385,-353 0,176 1167,0 0,-176 386,353 -386,354 0,-177 -1167,0 0,177 -385,-354 z" /><path
580 style="fill:none;stroke:#3465af"
581 inkscape:connector-curvature="0"
582 id="path347"
583 d="m 4629.5459,2032.013 385,-353 0,176 1167,0 0,-176 386,353 -386,354 0,-177 -1167,0 0,177 -385,-354 z" /><path
584 style="fill:#729fcf"
585 inkscape:connector-curvature="0"
586 id="path351"
587 d="m 7889.5459,1986.013 402,-368 0,184 1217,0 0,-184 403,368 -403,369 0,-185 -1217,0 0,185 -402,-369 z" /><path
588 style="fill:none;stroke:#3465af"
589 inkscape:connector-curvature="0"
590 id="path353"
591 d="m 7889.5459,1986.013 402,-368 0,184 1217,0 0,-184 403,368 -403,369 0,-185 -1217,0 0,185 -402,-369 z" /><path
592 style="fill:#ccffff"
593 inkscape:connector-curvature="0"
594 id="path357"
595 d="m 14410.546,4025.013 -4500.0001,0 0,-1389 9000.0001,0 0,1389 -4500,0 z" /><path
596 style="fill:none;stroke:#3465af"
597 inkscape:connector-curvature="0"
598 id="path359"
599 d="m 14410.546,4025.013 -4500.0001,0 0,-1389 9000.0001,0 0,1389 -4500,0 z" /><text
600 id="text361"
601 class="TextShape"
602 x="-2089.4541"
603 y="-2163.9871"><tspan
604 style="font-weight:400;font-size:635px;font-family:'Times New Roman', serif"
605 id="tspan363"
606 class="TextParagraph"
607 font-weight="400"
608 font-size="635px"><tspan
609 id="tspan365"
610 class="TextPosition"
611 x="9961.5459"
612 y="3546.0129"><tspan
613 style="fill:#000000"
614 id="tspan367">Satellite Equipment Control (SEC)</tspan></tspan></tspan></text>
615<path
616 style="fill:#ccffff"
617 inkscape:connector-curvature="0"
618 id="path371"
619 d="m 11310.546,2436.013 -1400.0001,0 0,-1000 2800.0001,0 0,1000 -1400,0 z" /><path
620 style="fill:none;stroke:#3465af"
621 inkscape:connector-curvature="0"
622 id="path373"
623 d="m 11310.546,2436.013 -1400.0001,0 0,-1000 2800.0001,0 0,1000 -1400,0 z" /><text
624 id="text375"
625 class="TextShape"
626 x="-2089.4541"
627 y="-2163.9871"><tspan
628 style="font-weight:400;font-size:635px;font-family:'Times New Roman', serif"
629 id="tspan377"
630 class="TextParagraph"
631 font-weight="400"
632 font-size="635px"><tspan
633 id="tspan379"
634 class="TextPosition"
635 x="10375.546"
636 y="2152.0129"><tspan
637 style="fill:#000000"
638 id="tspan381">Demod</tspan></tspan></tspan></text>
639<path
640 style="fill:#729fcf"
641 inkscape:connector-curvature="0"
642 id="path385"
643 d="m 7889.5459,3287.013 402,-368 0,184 1217,0 0,-184 403,368 -403,369 0,-185 -1217,0 0,185 -402,-369 z" /><path
644 style="fill:none;stroke:#3465af"
645 inkscape:connector-curvature="0"
646 id="path387"
647 d="m 7889.5459,3287.013 402,-368 0,184 1217,0 0,-184 403,368 -403,369 0,-185 -1217,0 0,185 -402,-369 z" /><path
648 d="m 7906.5459,9121.013 0,7302 -1270,0 0,-14605 1270,0 0,7303 z"
649 id="path389"
650 inkscape:connector-curvature="0"
651 style="fill:#ffff99" /><path
652 d="m 7906.5459,9121.013 0,7302 -1270,0 0,-14605 1270,0 0,7303 z"
653 id="path391"
654 inkscape:connector-curvature="0"
655 style="fill:none;stroke:#3465af" /><text
656 y="-6589.021"
657 x="-20792.584"
658 transform="matrix(0,-1,1,0,0,0)"
659 class="TextShape"
660 id="text393"><tspan
661 font-size="635px"
662 font-weight="400"
663 class="TextParagraph"
664 id="tspan395"
665 style="font-weight:400;font-size:635px;font-family:'Times New Roman', serif"><tspan
666 y="7460.9849"
667 x="-11215.646"
668 class="TextPosition"
669 transform="matrix(0,-1,1,0,-4473,23627)"
670 id="tspan397"><tspan
671 id="tspan399"
672 style="fill:#000000">I2C Bus (control bus)</tspan></tspan></tspan></text>
673<text
674 id="text403"
675 class="TextShape"
676 x="-2145.854"
677 y="-2163.9871"><tspan
678 style="font-weight:400;font-size:635px;font-family:'Times New Roman', serif"
679 id="tspan405"
680 class="TextParagraph"
681 font-weight="400"
682 font-size="635px"><tspan
683 id="tspan407"
684 class="TextPosition"
685 x="7245.146"
686 y="1114.0129"><tspan
687 style="fill:#000000"
688 id="tspan409">Digital TV Frontend</tspan></tspan></tspan></text>
689<path
690 style="fill:none;stroke:#3465af;stroke-width:28.432024"
691 d="m 863.1459,636.145 c -18.27,0 -35.525,0.99994 -53.795,2.99982"
692 id="path415"
693 inkscape:connector-curvature="0" /><path
694 style="fill:none;stroke:#3465af;stroke-width:28.432024"
695 d="m 776.8709,644.14452 c -17.255,2.99982 -35.525,6.99958 -52.78,11.99928"
696 id="path417"
697 inkscape:connector-curvature="0" /><path
698 style="fill:none;stroke:#3465af;stroke-width:28.432024"
699 d="m 692.6259,666.1432 c -16.24,5.99964 -33.495,11.99928 -49.735,19.9988"
700 id="path419"
701 inkscape:connector-curvature="0" /><path
702 style="fill:none;stroke:#3465af;stroke-width:28.432024"
703 d="m 613.4559,700.14116 c -15.225,7.99952 -31.465,16.99898 -46.69,26.99838"
704 id="path421"
705 inkscape:connector-curvature="0" /><path
706 style="fill:none;stroke:#3465af;stroke-width:28.432024"
707 d="m 539.3609,745.13846 c -14.21,9.9994 -28.42,20.99874 -42.63,31.99808"
708 id="path423"
709 inkscape:connector-curvature="0" /><path
710 style="fill:none;stroke:#3465af;stroke-width:28.432024"
711 d="m 471.3559,798.13528 c -13.195,11.99928 -26.39,23.99856 -38.57,36.99778"
712 id="path425"
713 inkscape:connector-curvature="0" /><path
714 style="fill:none;stroke:#3465af;stroke-width:28.432024"
715 d="m 410.4559,859.13162 c -11.165,12.99922 -22.33,26.99838 -33.495,40.99754"
716 id="path427"
717 inkscape:connector-curvature="0" /><path
718 style="fill:none;stroke:#3465af;stroke-width:28.432024"
719 d="m 357.6759,927.12754 c -10.15,13.99916 -19.285,28.99826 -28.42,44.9973"
720 id="path429"
721 inkscape:connector-curvature="0" /><path
722 style="fill:none;stroke:#3465af;stroke-width:28.432024"
723 d="m 314.0309,1000.1232 c -8.12,15.999 -15.225,31.998 -22.33,48.997"
724 id="path431"
725 inkscape:connector-curvature="0" /><path
726 style="fill:none;stroke:#3465af;stroke-width:28.432024"
727 d="m 280.5359,1079.1184 c -5.075,16.999 -10.15,33.998 -14.21,50.997"
728 id="path433"
729 inkscape:connector-curvature="0" /><path
730 style="fill:none;stroke:#3465af;stroke-width:28.432024"
731 d="m 260.2359,1162.1134 c -3.045,17.999 -5.075,34.9979 -6.09,52.9969"
732 id="path435"
733 inkscape:connector-curvature="0" /><path
734 style="fill:none;stroke:#3465af;stroke-width:28.432024"
735 d="m 254.1459,1247.1083 0,52.9969"
736 id="path437"
737 inkscape:connector-curvature="0" /><path
738 style="fill:none;stroke:#3465af;stroke-width:28.432024"
739 d="m 254.1459,1333.1032 0,52.9968"
740 id="path439"
741 inkscape:connector-curvature="0" /><path
742 style="fill:none;stroke:#3465af;stroke-width:28.432024"
743 d="m 254.1459,1418.0981 0,52.9968"
744 id="path441"
745 inkscape:connector-curvature="0" /><path
746 style="fill:none;stroke:#3465af;stroke-width:28.432024"
747 d="m 254.1459,1504.0929 0,52.9968"
748 id="path443"
749 inkscape:connector-curvature="0" /><path
750 style="fill:none;stroke:#3465af;stroke-width:28.432024"
751 d="m 254.1459,1589.0878 0,52.9968"
752 id="path445"
753 inkscape:connector-curvature="0" /><path
754 style="fill:none;stroke:#3465af;stroke-width:28.432024"
755 d="m 254.1459,1675.0827 0,52.9968"
756 id="path447"
757 inkscape:connector-curvature="0" /><path
758 style="fill:none;stroke:#3465af;stroke-width:28.432024"
759 d="m 254.1459,1760.0776 0,52.9968"
760 id="path449"
761 inkscape:connector-curvature="0" /><path
762 style="fill:none;stroke:#3465af;stroke-width:28.432024"
763 d="m 254.1459,1845.0725 0,53.9967"
764 id="path451"
765 inkscape:connector-curvature="0" /><path
766 style="fill:none;stroke:#3465af;stroke-width:28.432024"
767 d="m 254.1459,1931.0673 0,52.9968"
768 id="path453"
769 inkscape:connector-curvature="0" /><path
770 style="fill:none;stroke:#3465af;stroke-width:28.432024"
771 d="m 254.1459,2016.0622 0,52.9968"
772 id="path455"
773 inkscape:connector-curvature="0" /><path
774 style="fill:none;stroke:#3465af;stroke-width:28.432024"
775 d="m 254.1459,2102.057 0,52.9969"
776 id="path457"
777 inkscape:connector-curvature="0" /><path
778 style="fill:none;stroke:#3465af;stroke-width:28.432024"
779 d="m 254.1459,2187.0519 0,52.9969"
780 id="path459"
781 inkscape:connector-curvature="0" /><path
782 style="fill:none;stroke:#3465af;stroke-width:28.432024"
783 d="m 254.1459,2273.0468 0,52.9968"
784 id="path461"
785 inkscape:connector-curvature="0" /><path
786 style="fill:none;stroke:#3465af;stroke-width:28.432024"
787 d="m 254.1459,2358.0417 0,52.9968"
788 id="path463"
789 inkscape:connector-curvature="0" /><path
790 style="fill:none;stroke:#3465af;stroke-width:28.432024"
791 d="m 254.1459,2443.0366 0,53.9967"
792 id="path465"
793 inkscape:connector-curvature="0" /><path
794 style="fill:none;stroke:#3465af;stroke-width:28.432024"
795 d="m 254.1459,2529.0314 0,52.9968"
796 id="path467"
797 inkscape:connector-curvature="0" /><path
798 style="fill:none;stroke:#3465af;stroke-width:28.432024"
799 d="m 254.1459,2614.0263 0,52.9968"
800 id="path469"
801 inkscape:connector-curvature="0" /><path
802 style="fill:none;stroke:#3465af;stroke-width:28.432024"
803 d="m 254.1459,2700.0212 0,52.9968"
804 id="path471"
805 inkscape:connector-curvature="0" /><path
806 style="fill:none;stroke:#3465af;stroke-width:28.432024"
807 d="m 254.1459,2785.0161 0,52.9968"
808 id="path473"
809 inkscape:connector-curvature="0" /><path
810 style="fill:none;stroke:#3465af;stroke-width:28.432024"
811 d="m 254.1459,2871.0109 0,52.9968"
812 id="path475"
813 inkscape:connector-curvature="0" /><path
814 style="fill:none;stroke:#3465af;stroke-width:28.432024"
815 d="m 254.1459,2956.0058 0,52.9968"
816 id="path477"
817 inkscape:connector-curvature="0" /><path
818 style="fill:none;stroke:#3465af;stroke-width:28.432024"
819 d="m 254.1459,3041.0007 0,53.9968"
820 id="path479"
821 inkscape:connector-curvature="0" /><path
822 style="fill:none;stroke:#3465af;stroke-width:28.432024"
823 d="m 254.1459,3126.9955 0,52.9969"
824 id="path481"
825 inkscape:connector-curvature="0" /><path
826 style="fill:none;stroke:#3465af;stroke-width:28.432024"
827 d="m 254.1459,3211.9904 0,52.9969"
828 id="path483"
829 inkscape:connector-curvature="0" /><path
830 style="fill:none;stroke:#3465af;stroke-width:28.432024"
831 d="m 254.1459,3297.9853 0,52.9968"
832 id="path485"
833 inkscape:connector-curvature="0" /><path
834 style="fill:none;stroke:#3465af;stroke-width:28.432024"
835 d="m 254.1459,3382.9802 0,52.9968"
836 id="path487"
837 inkscape:connector-curvature="0" /><path
838 style="fill:none;stroke:#3465af;stroke-width:28.432024"
839 d="m 254.1459,3468.975 0,52.9968"
840 id="path489"
841 inkscape:connector-curvature="0" /><path
842 style="fill:none;stroke:#3465af;stroke-width:28.432024"
843 d="m 254.1459,3553.9699 0,52.9968"
844 id="path491"
845 inkscape:connector-curvature="0" /><path
846 style="fill:none;stroke:#3465af;stroke-width:28.432024"
847 d="m 254.1459,3638.9648 c 0,17.9989 1.015,35.9979 3.045,52.9968"
848 id="path493"
849 inkscape:connector-curvature="0" /><path
850 style="fill:none;stroke:#3465af;stroke-width:28.432024"
851 d="m 262.2659,3723.9597 c 4.06,17.9989 8.12,34.9979 13.195,51.9969"
852 id="path495"
853 inkscape:connector-curvature="0" /><path
854 style="fill:none;stroke:#3465af;stroke-width:28.432024"
855 d="m 285.6109,3806.9547 c 6.09,15.9991 13.195,32.9981 20.3,48.9971"
856 id="path497"
857 inkscape:connector-curvature="0" /><path
858 style="fill:none;stroke:#3465af;stroke-width:28.432024"
859 d="m 321.1359,3884.9501 c 8.12,14.9991 17.255,30.9981 27.405,45.9972"
860 id="path499"
861 inkscape:connector-curvature="0" /><path
862 style="fill:none;stroke:#3465af;stroke-width:28.432024"
863 d="m 366.8109,3957.9457 c 10.15,13.9991 21.315,27.9983 32.48,41.9975"
864 id="path501"
865 inkscape:connector-curvature="0" /><path
866 style="fill:none;stroke:#3465af;stroke-width:28.432024"
867 d="m 420.6059,4023.9417 c 12.18,12.9992 25.375,25.9985 38.57,37.9977"
868 id="path503"
869 inkscape:connector-curvature="0" /><path
870 style="fill:none;stroke:#3465af;stroke-width:28.432024"
871 d="m 483.5359,4083.9381 c 13.195,10.9994 27.405,22.9986 41.615,32.998"
872 id="path505"
873 inkscape:connector-curvature="0" /><path
874 style="fill:none;stroke:#3465af;stroke-width:28.432024"
875 d="m 552.5559,4135.935 c 14.21,9.9994 29.435,18.9989 45.675,26.9984"
876 id="path507"
877 inkscape:connector-curvature="0" /><path
878 style="fill:none;stroke:#3465af;stroke-width:28.432024"
879 d="m 627.6659,4178.9324 c 15.225,6.9996 32.48,14.9991 48.72,20.9988"
880 id="path509"
881 inkscape:connector-curvature="0" /><path
882 style="fill:none;stroke:#3465af;stroke-width:28.432024"
883 d="m 707.8509,4210.9305 c 17.255,4.9997 34.51,9.9994 51.765,13.9992"
884 id="path511"
885 inkscape:connector-curvature="0" /><path
886 style="fill:none;stroke:#3465af;stroke-width:28.432024"
887 d="m 792.0959,4230.9293 c 17.255,1.9999 35.525,3.9998 53.795,4.9997"
888 id="path513"
889 inkscape:connector-curvature="0" /><path
890 style="fill:none;stroke:#3465af;stroke-width:28.432024"
891 d="m 878.3709,4235.929 53.795,0"
892 id="path515"
893 inkscape:connector-curvature="0" /><path
894 style="fill:none;stroke:#3465af;stroke-width:28.432024"
895 d="m 964.6459,4235.929 53.795,0"
896 id="path517"
897 inkscape:connector-curvature="0" /><path
898 style="fill:none;stroke:#3465af;stroke-width:28.432024"
899 d="m 1051.9359,4235.929 53.795,0"
900 id="path519"
901 inkscape:connector-curvature="0" /><path
902 style="fill:none;stroke:#3465af;stroke-width:28.432024"
903 d="m 1138.2109,4235.929 53.795,0"
904 id="path521"
905 inkscape:connector-curvature="0" /><path
906 style="fill:none;stroke:#3465af;stroke-width:28.432024"
907 d="m 1225.5009,4235.929 53.795,0"
908 id="path523"
909 inkscape:connector-curvature="0" /><path
910 style="fill:none;stroke:#3465af;stroke-width:28.432024"
911 d="m 1311.7759,4235.929 53.795,0"
912 id="path525"
913 inkscape:connector-curvature="0" /><path
914 style="fill:none;stroke:#3465af;stroke-width:28.432024"
915 d="m 1398.0509,4235.929 54.81,0"
916 id="path527"
917 inkscape:connector-curvature="0" /><path
918 style="fill:none;stroke:#3465af;stroke-width:28.432024"
919 d="m 1485.3409,4235.929 53.795,0"
920 id="path529"
921 inkscape:connector-curvature="0" /><path
922 style="fill:none;stroke:#3465af;stroke-width:28.432024"
923 d="m 1571.6159,4235.929 53.795,0"
924 id="path531"
925 inkscape:connector-curvature="0" /><path
926 style="fill:none;stroke:#3465af;stroke-width:28.432024"
927 d="m 1658.9059,4235.929 53.795,0"
928 id="path533"
929 inkscape:connector-curvature="0" /><path
930 style="fill:none;stroke:#3465af;stroke-width:28.432024"
931 d="m 1745.1809,4235.929 53.795,0"
932 id="path535"
933 inkscape:connector-curvature="0" /><path
934 style="fill:none;stroke:#3465af;stroke-width:28.432024"
935 d="m 1832.4709,4235.929 53.795,0"
936 id="path537"
937 inkscape:connector-curvature="0" /><path
938 style="fill:none;stroke:#3465af;stroke-width:28.432024"
939 d="m 1918.7459,4235.929 53.795,0"
940 id="path539"
941 inkscape:connector-curvature="0" /><path
942 style="fill:none;stroke:#3465af;stroke-width:28.432024"
943 d="m 2005.0209,4235.929 54.81,0"
944 id="path541"
945 inkscape:connector-curvature="0" /><path
946 style="fill:none;stroke:#3465af;stroke-width:28.432024"
947 d="m 2092.3109,4235.929 53.795,0"
948 id="path543"
949 inkscape:connector-curvature="0" /><path
950 style="fill:none;stroke:#3465af;stroke-width:28.432024"
951 d="m 2178.5859,4235.929 53.795,0"
952 id="path545"
953 inkscape:connector-curvature="0" /><path
954 style="fill:none;stroke:#3465af;stroke-width:28.432024"
955 d="m 2265.8759,4235.929 53.795,0"
956 id="path547"
957 inkscape:connector-curvature="0" /><path
958 style="fill:none;stroke:#3465af;stroke-width:28.432024"
959 d="m 2352.1509,4235.929 53.795,0"
960 id="path549"
961 inkscape:connector-curvature="0" /><path
962 style="fill:none;stroke:#3465af;stroke-width:28.432024"
963 d="m 2439.4409,4235.929 53.795,0"
964 id="path551"
965 inkscape:connector-curvature="0" /><path
966 style="fill:none;stroke:#3465af;stroke-width:28.432024"
967 d="m 2525.7159,4235.929 53.795,0"
968 id="path553"
969 inkscape:connector-curvature="0" /><path
970 style="fill:none;stroke:#3465af;stroke-width:28.432024"
971 d="m 2611.9909,4235.929 54.81,0"
972 id="path555"
973 inkscape:connector-curvature="0" /><path
974 style="fill:none;stroke:#3465af;stroke-width:28.432024"
975 d="m 2699.2809,4235.929 53.795,0"
976 id="path557"
977 inkscape:connector-curvature="0" /><path
978 style="fill:none;stroke:#3465af;stroke-width:28.432024"
979 d="m 2785.5559,4235.929 53.795,0"
980 id="path559"
981 inkscape:connector-curvature="0" /><path
982 style="fill:none;stroke:#3465af;stroke-width:28.432024"
983 d="m 2872.8459,4235.929 53.795,0"
984 id="path561"
985 inkscape:connector-curvature="0" /><path
986 style="fill:none;stroke:#3465af;stroke-width:28.432024"
987 d="m 2959.1209,4235.929 53.795,0"
988 id="path563"
989 inkscape:connector-curvature="0" /><path
990 style="fill:none;stroke:#3465af;stroke-width:28.432024"
991 d="m 3046.4109,4235.929 53.795,0"
992 id="path565"
993 inkscape:connector-curvature="0" /><path
994 style="fill:none;stroke:#3465af;stroke-width:28.432024"
995 d="m 3132.6859,4235.929 53.795,0"
996 id="path567"
997 inkscape:connector-curvature="0" /><path
998 style="fill:none;stroke:#3465af;stroke-width:28.432024"
999 d="m 3219.9759,4235.929 53.795,0"
1000 id="path569"
1001 inkscape:connector-curvature="0" /><path
1002 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1003 d="m 3306.2509,4235.929 53.795,0"
1004 id="path571"
1005 inkscape:connector-curvature="0" /><path
1006 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1007 d="m 3392.5259,4235.929 53.795,0"
1008 id="path573"
1009 inkscape:connector-curvature="0" /><path
1010 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1011 d="m 3479.8159,4235.929 53.795,0"
1012 id="path575"
1013 inkscape:connector-curvature="0" /><path
1014 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1015 d="m 3566.0909,4235.929 53.795,0"
1016 id="path577"
1017 inkscape:connector-curvature="0" /><path
1018 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1019 d="m 3653.3809,4235.929 53.795,0"
1020 id="path579"
1021 inkscape:connector-curvature="0" /><path
1022 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1023 d="m 3739.6559,4235.929 53.795,0"
1024 id="path581"
1025 inkscape:connector-curvature="0" /><path
1026 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1027 d="m 3826.9459,4235.929 53.795,0"
1028 id="path583"
1029 inkscape:connector-curvature="0" /><path
1030 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1031 d="m 3913.2209,4235.929 53.795,0"
1032 id="path585"
1033 inkscape:connector-curvature="0" /><path
1034 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1035 d="m 3999.4959,4235.929 53.795,0"
1036 id="path587"
1037 inkscape:connector-curvature="0" /><path
1038 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1039 d="m 4086.7859,4235.929 53.795,0"
1040 id="path589"
1041 inkscape:connector-curvature="0" /><path
1042 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1043 d="m 4173.0609,4235.929 53.795,0"
1044 id="path591"
1045 inkscape:connector-curvature="0" /><path
1046 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1047 d="m 4260.3509,4235.929 53.795,0"
1048 id="path593"
1049 inkscape:connector-curvature="0" /><path
1050 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1051 d="m 4346.6259,4235.929 53.795,0"
1052 id="path595"
1053 inkscape:connector-curvature="0" /><path
1054 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1055 d="m 4433.9159,4235.929 53.795,0"
1056 id="path597"
1057 inkscape:connector-curvature="0" /><path
1058 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1059 d="m 4520.1909,4235.929 53.795,0"
1060 id="path599"
1061 inkscape:connector-curvature="0" /><path
1062 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1063 d="m 4606.4659,4235.929 54.81,0"
1064 id="path601"
1065 inkscape:connector-curvature="0" /><path
1066 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1067 d="m 4693.7559,4235.929 53.795,0"
1068 id="path603"
1069 inkscape:connector-curvature="0" /><path
1070 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1071 d="m 4780.0309,4235.929 53.795,0"
1072 id="path605"
1073 inkscape:connector-curvature="0" /><path
1074 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1075 d="m 4867.3209,4235.929 53.795,0"
1076 id="path607"
1077 inkscape:connector-curvature="0" /><path
1078 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1079 d="m 4953.5959,4235.929 53.795,0"
1080 id="path609"
1081 inkscape:connector-curvature="0" /><path
1082 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1083 d="m 5040.8859,4235.929 53.795,0"
1084 id="path611"
1085 inkscape:connector-curvature="0" /><path
1086 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1087 d="m 5127.1609,4235.929 53.795,0"
1088 id="path613"
1089 inkscape:connector-curvature="0" /><path
1090 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1091 d="m 5213.4359,4235.929 54.81,0"
1092 id="path615"
1093 inkscape:connector-curvature="0" /><path
1094 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1095 d="m 5300.7259,4235.929 53.795,0"
1096 id="path617"
1097 inkscape:connector-curvature="0" /><path
1098 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1099 d="m 5387.0009,4235.929 53.795,0"
1100 id="path619"
1101 inkscape:connector-curvature="0" /><path
1102 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1103 d="m 5474.2909,4235.929 53.795,0"
1104 id="path621"
1105 inkscape:connector-curvature="0" /><path
1106 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1107 d="m 5560.5659,4235.929 53.795,0"
1108 id="path623"
1109 inkscape:connector-curvature="0" /><path
1110 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1111 d="m 5647.8559,4235.929 53.795,0"
1112 id="path625"
1113 inkscape:connector-curvature="0" /><path
1114 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1115 d="m 5734.1309,4235.929 53.795,0"
1116 id="path627"
1117 inkscape:connector-curvature="0" /><path
1118 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1119 d="m 5820.4059,4235.929 54.81,0"
1120 id="path629"
1121 inkscape:connector-curvature="0" /><path
1122 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1123 d="m 5907.6959,4235.929 53.795,0"
1124 id="path631"
1125 inkscape:connector-curvature="0" /><path
1126 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1127 d="m 5993.9709,4235.929 53.795,0"
1128 id="path633"
1129 inkscape:connector-curvature="0" /><path
1130 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1131 d="m 6081.2609,4235.929 53.795,0"
1132 id="path635"
1133 inkscape:connector-curvature="0" /><path
1134 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1135 d="m 6167.5359,4235.929 53.795,0"
1136 id="path637"
1137 inkscape:connector-curvature="0" /><path
1138 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1139 d="m 6254.8259,4235.929 53.795,0"
1140 id="path639"
1141 inkscape:connector-curvature="0" /><path
1142 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1143 d="m 6341.1009,4235.929 53.795,0"
1144 id="path641"
1145 inkscape:connector-curvature="0" /><path
1146 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1147 d="m 6427.3759,4235.929 54.81,0"
1148 id="path643"
1149 inkscape:connector-curvature="0" /><path
1150 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1151 d="m 6514.6659,4235.929 53.795,0"
1152 id="path645"
1153 inkscape:connector-curvature="0" /><path
1154 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1155 d="m 6600.9409,4235.929 53.795,0"
1156 id="path647"
1157 inkscape:connector-curvature="0" /><path
1158 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1159 d="m 6688.2309,4235.929 53.795,0"
1160 id="path649"
1161 inkscape:connector-curvature="0" /><path
1162 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1163 d="m 6774.5059,4235.929 53.795,0"
1164 id="path651"
1165 inkscape:connector-curvature="0" /><path
1166 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1167 d="m 6861.7959,4235.929 53.795,0"
1168 id="path653"
1169 inkscape:connector-curvature="0" /><path
1170 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1171 d="m 6948.0709,4235.929 53.795,0"
1172 id="path655"
1173 inkscape:connector-curvature="0" /><path
1174 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1175 d="m 7035.3609,4235.929 53.795,0"
1176 id="path657"
1177 inkscape:connector-curvature="0" /><path
1178 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1179 d="m 7121.6359,4235.929 53.795,0"
1180 id="path659"
1181 inkscape:connector-curvature="0" /><path
1182 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1183 d="m 7207.9109,4235.929 53.795,0"
1184 id="path661"
1185 inkscape:connector-curvature="0" /><path
1186 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1187 d="m 7295.2009,4235.929 53.795,0"
1188 id="path663"
1189 inkscape:connector-curvature="0" /><path
1190 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1191 d="m 7381.4759,4235.929 53.795,0"
1192 id="path665"
1193 inkscape:connector-curvature="0" /><path
1194 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1195 d="m 7468.7659,4235.929 53.795,0"
1196 id="path667"
1197 inkscape:connector-curvature="0" /><path
1198 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1199 d="m 7555.0409,4235.929 53.795,0"
1200 id="path669"
1201 inkscape:connector-curvature="0" /><path
1202 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1203 d="m 7642.3309,4235.929 53.795,0"
1204 id="path671"
1205 inkscape:connector-curvature="0" /><path
1206 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1207 d="m 7728.6059,4235.929 53.795,0"
1208 id="path673"
1209 inkscape:connector-curvature="0" /><path
1210 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1211 d="m 7814.8809,4235.929 53.795,0"
1212 id="path675"
1213 inkscape:connector-curvature="0" /><path
1214 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1215 d="m 7902.1709,4235.929 53.795,0"
1216 id="path677"
1217 inkscape:connector-curvature="0" /><path
1218 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1219 d="m 7988.4459,4235.929 53.795,0"
1220 id="path679"
1221 inkscape:connector-curvature="0" /><path
1222 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1223 d="m 8075.7359,4235.929 53.795,0"
1224 id="path681"
1225 inkscape:connector-curvature="0" /><path
1226 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1227 d="m 8162.0109,4235.929 53.795,0"
1228 id="path683"
1229 inkscape:connector-curvature="0" /><path
1230 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1231 d="m 8249.3009,4235.929 53.795,0"
1232 id="path685"
1233 inkscape:connector-curvature="0" /><path
1234 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1235 d="m 8335.5759,4235.929 53.795,0"
1236 id="path687"
1237 inkscape:connector-curvature="0" /><path
1238 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1239 d="m 8421.8509,4235.929 53.795,0"
1240 id="path689"
1241 inkscape:connector-curvature="0" /><path
1242 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1243 d="m 8509.1409,4235.929 53.795,0"
1244 id="path691"
1245 inkscape:connector-curvature="0" /><path
1246 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1247 d="m 8595.4159,4235.929 53.795,0"
1248 id="path693"
1249 inkscape:connector-curvature="0" /><path
1250 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1251 d="m 8682.7059,4235.929 53.795,0"
1252 id="path695"
1253 inkscape:connector-curvature="0" /><path
1254 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1255 d="m 8768.9809,4235.929 53.795,0"
1256 id="path697"
1257 inkscape:connector-curvature="0" /><path
1258 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1259 d="m 8856.2709,4235.929 53.795,0"
1260 id="path699"
1261 inkscape:connector-curvature="0" /><path
1262 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1263 d="m 8942.5459,4235.929 53.795,0"
1264 id="path701"
1265 inkscape:connector-curvature="0" /><path
1266 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1267 d="m 9028.8209,4235.929 54.81,0"
1268 id="path703"
1269 inkscape:connector-curvature="0" /><path
1270 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1271 d="m 9116.1109,4235.929 53.795,0"
1272 id="path705"
1273 inkscape:connector-curvature="0" /><path
1274 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1275 d="m 9202.3859,4235.929 53.795,0"
1276 id="path707"
1277 inkscape:connector-curvature="0" /><path
1278 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1279 d="m 9289.6759,4235.929 53.795,0"
1280 id="path709"
1281 inkscape:connector-curvature="0" /><path
1282 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1283 d="m 9375.9509,4235.929 53.795,0"
1284 id="path711"
1285 inkscape:connector-curvature="0" /><path
1286 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1287 d="m 9463.2409,4235.929 53.795,0"
1288 id="path713"
1289 inkscape:connector-curvature="0" /><path
1290 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1291 d="m 9549.5159,4235.929 53.795,0"
1292 id="path715"
1293 inkscape:connector-curvature="0" /><path
1294 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1295 d="m 9635.7909,4235.929 54.81,0"
1296 id="path717"
1297 inkscape:connector-curvature="0" /><path
1298 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1299 d="m 9723.0809,4235.929 53.795,0"
1300 id="path719"
1301 inkscape:connector-curvature="0" /><path
1302 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1303 d="m 9809.3559,4235.929 53.795,0"
1304 id="path721"
1305 inkscape:connector-curvature="0" /><path
1306 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1307 d="m 9896.6459,4235.929 53.795,0"
1308 id="path723"
1309 inkscape:connector-curvature="0" /><path
1310 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1311 d="m 9982.9209,4235.929 53.7951,0"
1312 id="path725"
1313 inkscape:connector-curvature="0" /><path
1314 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1315 d="m 10070.211,4235.929 53.795,0"
1316 id="path727"
1317 inkscape:connector-curvature="0" /><path
1318 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1319 d="m 10156.486,4235.929 53.795,0"
1320 id="path729"
1321 inkscape:connector-curvature="0" /><path
1322 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1323 d="m 10242.761,4235.929 54.81,0"
1324 id="path731"
1325 inkscape:connector-curvature="0" /><path
1326 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1327 d="m 10330.051,4235.929 53.795,0"
1328 id="path733"
1329 inkscape:connector-curvature="0" /><path
1330 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1331 d="m 10416.326,4235.929 53.795,0"
1332 id="path735"
1333 inkscape:connector-curvature="0" /><path
1334 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1335 d="m 10503.616,4235.929 53.795,0"
1336 id="path737"
1337 inkscape:connector-curvature="0" /><path
1338 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1339 d="m 10589.891,4235.929 53.795,0"
1340 id="path739"
1341 inkscape:connector-curvature="0" /><path
1342 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1343 d="m 10677.181,4235.929 53.795,0"
1344 id="path741"
1345 inkscape:connector-curvature="0" /><path
1346 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1347 d="m 10763.456,4235.929 53.795,0"
1348 id="path743"
1349 inkscape:connector-curvature="0" /><path
1350 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1351 d="m 10849.731,4235.929 54.81,0"
1352 id="path745"
1353 inkscape:connector-curvature="0" /><path
1354 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1355 d="m 10937.021,4235.929 53.795,0"
1356 id="path747"
1357 inkscape:connector-curvature="0" /><path
1358 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1359 d="m 11023.296,4235.929 53.795,0"
1360 id="path749"
1361 inkscape:connector-curvature="0" /><path
1362 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1363 d="m 11110.586,4235.929 53.795,0"
1364 id="path751"
1365 inkscape:connector-curvature="0" /><path
1366 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1367 d="m 11196.861,4235.929 53.795,0"
1368 id="path753"
1369 inkscape:connector-curvature="0" /><path
1370 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1371 d="m 11284.151,4235.929 53.795,0"
1372 id="path755"
1373 inkscape:connector-curvature="0" /><path
1374 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1375 d="m 11370.426,4235.929 53.795,0"
1376 id="path757"
1377 inkscape:connector-curvature="0" /><path
1378 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1379 d="m 11457.716,4235.929 53.795,0"
1380 id="path759"
1381 inkscape:connector-curvature="0" /><path
1382 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1383 d="m 11543.991,4235.929 53.795,0"
1384 id="path761"
1385 inkscape:connector-curvature="0" /><path
1386 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1387 d="m 11630.266,4235.929 53.795,0"
1388 id="path763"
1389 inkscape:connector-curvature="0" /><path
1390 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1391 d="m 11717.556,4235.929 53.795,0"
1392 id="path765"
1393 inkscape:connector-curvature="0" /><path
1394 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1395 d="m 11803.831,4235.929 53.795,0"
1396 id="path767"
1397 inkscape:connector-curvature="0" /><path
1398 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1399 d="m 11891.121,4235.929 53.795,0"
1400 id="path769"
1401 inkscape:connector-curvature="0" /><path
1402 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1403 d="m 11977.396,4235.929 53.795,0"
1404 id="path771"
1405 inkscape:connector-curvature="0" /><path
1406 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1407 d="m 12064.686,4235.929 53.795,0"
1408 id="path773"
1409 inkscape:connector-curvature="0" /><path
1410 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1411 d="m 12150.961,4235.929 53.795,0"
1412 id="path775"
1413 inkscape:connector-curvature="0" /><path
1414 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1415 d="m 12237.236,4235.929 53.795,0"
1416 id="path777"
1417 inkscape:connector-curvature="0" /><path
1418 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1419 d="m 12324.526,4235.929 53.795,0"
1420 id="path779"
1421 inkscape:connector-curvature="0" /><path
1422 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1423 d="m 12410.801,4235.929 53.795,0"
1424 id="path781"
1425 inkscape:connector-curvature="0" /><path
1426 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1427 d="m 12498.091,4235.929 53.795,0"
1428 id="path783"
1429 inkscape:connector-curvature="0" /><path
1430 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1431 d="m 12584.366,4235.929 53.795,0"
1432 id="path785"
1433 inkscape:connector-curvature="0" /><path
1434 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1435 d="m 12671.656,4235.929 53.795,0"
1436 id="path787"
1437 inkscape:connector-curvature="0" /><path
1438 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1439 d="m 12757.931,4235.929 53.795,0"
1440 id="path789"
1441 inkscape:connector-curvature="0" /><path
1442 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1443 d="m 12844.206,4235.929 54.81,0"
1444 id="path791"
1445 inkscape:connector-curvature="0" /><path
1446 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1447 d="m 12931.496,4235.929 53.795,0"
1448 id="path793"
1449 inkscape:connector-curvature="0" /><path
1450 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1451 d="m 13017.771,4235.929 53.795,0"
1452 id="path795"
1453 inkscape:connector-curvature="0" /><path
1454 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1455 d="m 13105.061,4235.929 53.795,0"
1456 id="path797"
1457 inkscape:connector-curvature="0" /><path
1458 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1459 d="m 13191.336,4235.929 53.795,0"
1460 id="path799"
1461 inkscape:connector-curvature="0" /><path
1462 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1463 d="m 13278.626,4235.929 53.795,0"
1464 id="path801"
1465 inkscape:connector-curvature="0" /><path
1466 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1467 d="m 13364.901,4235.929 53.795,0"
1468 id="path803"
1469 inkscape:connector-curvature="0" /><path
1470 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1471 d="m 13451.176,4235.929 54.81,0"
1472 id="path805"
1473 inkscape:connector-curvature="0" /><path
1474 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1475 d="m 13538.466,4235.929 53.795,0"
1476 id="path807"
1477 inkscape:connector-curvature="0" /><path
1478 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1479 d="m 13624.741,4235.929 53.795,0"
1480 id="path809"
1481 inkscape:connector-curvature="0" /><path
1482 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1483 d="m 13712.031,4235.929 53.795,0"
1484 id="path811"
1485 inkscape:connector-curvature="0" /><path
1486 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1487 d="m 13798.306,4235.929 53.795,0"
1488 id="path813"
1489 inkscape:connector-curvature="0" /><path
1490 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1491 d="m 13885.596,4235.929 53.795,0"
1492 id="path815"
1493 inkscape:connector-curvature="0" /><path
1494 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1495 d="m 13971.871,4235.929 53.795,0"
1496 id="path817"
1497 inkscape:connector-curvature="0" /><path
1498 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1499 d="m 14058.146,4235.929 54.81,0"
1500 id="path819"
1501 inkscape:connector-curvature="0" /><path
1502 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1503 d="m 14145.436,4235.929 53.795,0"
1504 id="path821"
1505 inkscape:connector-curvature="0" /><path
1506 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1507 d="m 14231.711,4235.929 53.795,0"
1508 id="path823"
1509 inkscape:connector-curvature="0" /><path
1510 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1511 d="m 14319.001,4235.929 53.795,0"
1512 id="path825"
1513 inkscape:connector-curvature="0" /><path
1514 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1515 d="m 14405.276,4235.929 53.795,0"
1516 id="path827"
1517 inkscape:connector-curvature="0" /><path
1518 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1519 d="m 14492.566,4235.929 53.795,0"
1520 id="path829"
1521 inkscape:connector-curvature="0" /><path
1522 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1523 d="m 14578.841,4235.929 53.795,0"
1524 id="path831"
1525 inkscape:connector-curvature="0" /><path
1526 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1527 d="m 14665.116,4235.929 54.81,0"
1528 id="path833"
1529 inkscape:connector-curvature="0" /><path
1530 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1531 d="m 14752.406,4235.929 53.795,0"
1532 id="path835"
1533 inkscape:connector-curvature="0" /><path
1534 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1535 d="m 14838.681,4235.929 53.795,0"
1536 id="path837"
1537 inkscape:connector-curvature="0" /><path
1538 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1539 d="m 14925.971,4235.929 53.795,0"
1540 id="path839"
1541 inkscape:connector-curvature="0" /><path
1542 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1543 d="m 15012.246,4235.929 53.795,0"
1544 id="path841"
1545 inkscape:connector-curvature="0" /><path
1546 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1547 d="m 15099.536,4235.929 53.795,0"
1548 id="path843"
1549 inkscape:connector-curvature="0" /><path
1550 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1551 d="m 15185.811,4235.929 53.795,0"
1552 id="path845"
1553 inkscape:connector-curvature="0" /><path
1554 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1555 d="m 15272.086,4235.929 54.81,0"
1556 id="path847"
1557 inkscape:connector-curvature="0" /><path
1558 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1559 d="m 15359.376,4235.929 53.795,0"
1560 id="path849"
1561 inkscape:connector-curvature="0" /><path
1562 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1563 d="m 15445.651,4235.929 53.795,0"
1564 id="path851"
1565 inkscape:connector-curvature="0" /><path
1566 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1567 d="m 15532.941,4235.929 53.795,0"
1568 id="path853"
1569 inkscape:connector-curvature="0" /><path
1570 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1571 d="m 15619.216,4235.929 53.795,0"
1572 id="path855"
1573 inkscape:connector-curvature="0" /><path
1574 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1575 d="m 15706.506,4235.929 53.795,0"
1576 id="path857"
1577 inkscape:connector-curvature="0" /><path
1578 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1579 d="m 15792.781,4235.929 53.795,0"
1580 id="path859"
1581 inkscape:connector-curvature="0" /><path
1582 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1583 d="m 15880.071,4235.929 53.795,0"
1584 id="path861"
1585 inkscape:connector-curvature="0" /><path
1586 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1587 d="m 15966.346,4235.929 53.795,0"
1588 id="path863"
1589 inkscape:connector-curvature="0" /><path
1590 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1591 d="m 16052.621,4235.929 53.795,0"
1592 id="path865"
1593 inkscape:connector-curvature="0" /><path
1594 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1595 d="m 16139.911,4235.929 53.795,0"
1596 id="path867"
1597 inkscape:connector-curvature="0" /><path
1598 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1599 d="m 16226.186,4235.929 53.795,0"
1600 id="path869"
1601 inkscape:connector-curvature="0" /><path
1602 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1603 d="m 16313.476,4235.929 53.795,0"
1604 id="path871"
1605 inkscape:connector-curvature="0" /><path
1606 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1607 d="m 16399.751,4235.929 53.795,0"
1608 id="path873"
1609 inkscape:connector-curvature="0" /><path
1610 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1611 d="m 16487.041,4235.929 53.795,0"
1612 id="path875"
1613 inkscape:connector-curvature="0" /><path
1614 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1615 d="m 16573.316,4235.929 53.795,0"
1616 id="path877"
1617 inkscape:connector-curvature="0" /><path
1618 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1619 d="m 16659.591,4235.929 53.795,0"
1620 id="path879"
1621 inkscape:connector-curvature="0" /><path
1622 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1623 d="m 16746.881,4235.929 53.795,0"
1624 id="path881"
1625 inkscape:connector-curvature="0" /><path
1626 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1627 d="m 16833.156,4235.929 53.795,0"
1628 id="path883"
1629 inkscape:connector-curvature="0" /><path
1630 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1631 d="m 16920.446,4235.929 53.795,0"
1632 id="path885"
1633 inkscape:connector-curvature="0" /><path
1634 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1635 d="m 17006.721,4235.929 53.795,0"
1636 id="path887"
1637 inkscape:connector-curvature="0" /><path
1638 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1639 d="m 17094.011,4235.929 53.795,0"
1640 id="path889"
1641 inkscape:connector-curvature="0" /><path
1642 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1643 d="m 17180.286,4235.929 53.795,0"
1644 id="path891"
1645 inkscape:connector-curvature="0" /><path
1646 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1647 d="m 17266.561,4235.929 54.81,0"
1648 id="path893"
1649 inkscape:connector-curvature="0" /><path
1650 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1651 d="m 17353.851,4235.929 53.795,0"
1652 id="path895"
1653 inkscape:connector-curvature="0" /><path
1654 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1655 d="m 17440.126,4235.929 53.795,0"
1656 id="path897"
1657 inkscape:connector-curvature="0" /><path
1658 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1659 d="m 17527.416,4235.929 53.795,0"
1660 id="path899"
1661 inkscape:connector-curvature="0" /><path
1662 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1663 d="m 17613.691,4235.929 53.795,0"
1664 id="path901"
1665 inkscape:connector-curvature="0" /><path
1666 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1667 d="m 17700.981,4235.929 53.795,0"
1668 id="path903"
1669 inkscape:connector-curvature="0" /><path
1670 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1671 d="m 17787.256,4235.929 53.795,0"
1672 id="path905"
1673 inkscape:connector-curvature="0" /><path
1674 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1675 d="m 17873.531,4235.929 54.81,0"
1676 id="path907"
1677 inkscape:connector-curvature="0" /><path
1678 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1679 d="m 17960.821,4235.929 53.795,0"
1680 id="path909"
1681 inkscape:connector-curvature="0" /><path
1682 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1683 d="m 18047.096,4235.929 53.795,0"
1684 id="path911"
1685 inkscape:connector-curvature="0" /><path
1686 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1687 d="m 18134.386,4235.929 53.795,0"
1688 id="path913"
1689 inkscape:connector-curvature="0" /><path
1690 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1691 d="m 18220.661,4235.929 53.795,0"
1692 id="path915"
1693 inkscape:connector-curvature="0" /><path
1694 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1695 d="m 18307.951,4235.929 53.795,0"
1696 id="path917"
1697 inkscape:connector-curvature="0" /><path
1698 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1699 d="m 18394.226,4235.929 53.795,0"
1700 id="path919"
1701 inkscape:connector-curvature="0" /><path
1702 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1703 d="m 18480.501,4235.929 54.81,0"
1704 id="path921"
1705 inkscape:connector-curvature="0" /><path
1706 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1707 d="m 18567.791,4235.929 53.795,0"
1708 id="path923"
1709 inkscape:connector-curvature="0" /><path
1710 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1711 d="m 18654.066,4235.929 53.795,0"
1712 id="path925"
1713 inkscape:connector-curvature="0" /><path
1714 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1715 d="m 18741.356,4235.929 c 17.255,-0.9999 35.525,-1.9999 53.795,-4.9997"
1716 id="path927"
1717 inkscape:connector-curvature="0" /><path
1718 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1719 d="m 18827.631,4225.9296 c 17.255,-3.9998 34.51,-8.9995 51.765,-13.9992"
1720 id="path929"
1721 inkscape:connector-curvature="0" /><path
1722 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1723 d="m 18910.861,4200.9311 c 16.24,-5.9996 32.48,-12.9992 48.72,-20.9987"
1724 id="path931"
1725 inkscape:connector-curvature="0" /><path
1726 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1727 d="m 18989.016,4164.9333 c 15.225,-7.9996 31.465,-16.999 45.675,-26.9984"
1728 id="path933"
1729 inkscape:connector-curvature="0" /><path
1730 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1731 d="m 19062.096,4118.936 c 14.21,-9.9994 28.42,-20.9987 42.63,-31.9981"
1732 id="path935"
1733 inkscape:connector-curvature="0" /><path
1734 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1735 d="m 19129.086,4064.9393 c 13.195,-11.9993 25.375,-24.9985 37.555,-37.9978"
1736 id="path937"
1737 inkscape:connector-curvature="0" /><path
1738 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1739 d="m 19188.971,4002.943 c 11.165,-13.9992 22.33,-27.9983 33.495,-41.9975"
1740 id="path939"
1741 inkscape:connector-curvature="0" /><path
1742 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1743 d="m 19240.736,3933.9471 c 10.15,-14.9991 19.285,-29.9982 27.405,-44.9973"
1744 id="path941"
1745 inkscape:connector-curvature="0" /><path
1746 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1747 d="m 19283.366,3859.9516 c 7.105,-15.9991 14.21,-32.9981 20.3,-48.9971"
1748 id="path943"
1749 inkscape:connector-curvature="0" /><path
1750 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1751 d="m 19314.831,3779.9564 c 5.075,-16.999 9.135,-33.998 13.195,-50.997"
1752 id="path945"
1753 inkscape:connector-curvature="0" /><path
1754 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1755 d="m 19333.101,3696.9613 c 2.03,-17.9989 4.06,-34.9979 4.06,-52.9968"
1756 id="path947"
1757 inkscape:connector-curvature="0" /><path
1758 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1759 d="m 19337.161,3611.9664 0,-53.9967"
1760 id="path949"
1761 inkscape:connector-curvature="0" /><path
1762 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1763 d="m 19337.161,3525.9716 0,-52.9968"
1764 id="path951"
1765 inkscape:connector-curvature="0" /><path
1766 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1767 d="m 19337.161,3440.9767 0,-52.9968"
1768 id="path953"
1769 inkscape:connector-curvature="0" /><path
1770 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1771 d="m 19337.161,3354.9819 0,-52.9969"
1772 id="path955"
1773 inkscape:connector-curvature="0" /><path
1774 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1775 d="m 19337.161,3269.987 0,-52.9969"
1776 id="path957"
1777 inkscape:connector-curvature="0" /><path
1778 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1779 d="m 19337.161,3183.9921 0,-52.9968"
1780 id="path959"
1781 inkscape:connector-curvature="0" /><path
1782 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1783 d="m 19337.161,3098.9972 0,-52.9968"
1784 id="path961"
1785 inkscape:connector-curvature="0" /><path
1786 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1787 d="m 19337.161,3014.0023 0,-53.9967"
1788 id="path963"
1789 inkscape:connector-curvature="0" /><path
1790 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1791 d="m 19337.161,2928.0075 0,-52.9968"
1792 id="path965"
1793 inkscape:connector-curvature="0" /><path
1794 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1795 d="m 19337.161,2843.0126 0,-52.9968"
1796 id="path967"
1797 inkscape:connector-curvature="0" /><path
1798 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1799 d="m 19337.161,2757.0177 0,-52.9968"
1800 id="path969"
1801 inkscape:connector-curvature="0" /><path
1802 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1803 d="m 19337.161,2672.0228 0,-52.9968"
1804 id="path971"
1805 inkscape:connector-curvature="0" /><path
1806 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1807 d="m 19337.161,2586.028 0,-52.9968"
1808 id="path973"
1809 inkscape:connector-curvature="0" /><path
1810 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1811 d="m 19337.161,2501.0331 0,-52.9968"
1812 id="path975"
1813 inkscape:connector-curvature="0" /><path
1814 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1815 d="m 19337.161,2415.0383 0,-52.9969"
1816 id="path977"
1817 inkscape:connector-curvature="0" /><path
1818 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1819 d="m 19337.161,2330.0434 0,-52.9969"
1820 id="path979"
1821 inkscape:connector-curvature="0" /><path
1822 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1823 d="m 19337.161,2245.0485 0,-52.9969"
1824 id="path981"
1825 inkscape:connector-curvature="0" /><path
1826 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1827 d="m 19337.161,2159.0536 0,-52.9968"
1828 id="path983"
1829 inkscape:connector-curvature="0" /><path
1830 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1831 d="m 19337.161,2074.0587 0,-52.9968"
1832 id="path985"
1833 inkscape:connector-curvature="0" /><path
1834 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1835 d="m 19337.161,1988.0639 0,-52.9968"
1836 id="path987"
1837 inkscape:connector-curvature="0" /><path
1838 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1839 d="m 19337.161,1903.069 0,-52.9968"
1840 id="path989"
1841 inkscape:connector-curvature="0" /><path
1842 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1843 d="m 19337.161,1817.0741 0,-52.9968"
1844 id="path991"
1845 inkscape:connector-curvature="0" /><path
1846 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1847 d="m 19337.161,1732.0792 0,-52.9968"
1848 id="path993"
1849 inkscape:connector-curvature="0" /><path
1850 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1851 d="m 19337.161,1647.0843 0,-52.9968"
1852 id="path995"
1853 inkscape:connector-curvature="0" /><path
1854 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1855 d="m 19337.161,1561.0895 0,-52.9968"
1856 id="path997"
1857 inkscape:connector-curvature="0" /><path
1858 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1859 d="m 19337.161,1476.0946 0,-52.9968"
1860 id="path999"
1861 inkscape:connector-curvature="0" /><path
1862 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1863 d="m 19337.161,1390.0998 0,-52.9969"
1864 id="path1001"
1865 inkscape:connector-curvature="0" /><path
1866 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1867 d="m 19337.161,1305.1049 0,-52.9969"
1868 id="path1003"
1869 inkscape:connector-curvature="0" /><path
1870 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1871 d="m 19337.161,1219.11 c -1.015,-16.999 -3.045,-34.9979 -5.075,-51.9969"
1872 id="path1005"
1873 inkscape:connector-curvature="0" /><path
1874 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1875 d="m 19325.996,1135.1151 c -4.06,-16.999 -8.12,-34.9979 -14.21,-50.997"
1876 id="path1007"
1877 inkscape:connector-curvature="0" /><path
1878 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1879 d="m 19300.621,1053.12 c -6.09,-15.9991 -13.195,-32.998 -21.315,-48.9971"
1880 id="path1009"
1881 inkscape:connector-curvature="0" /><path
1882 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1883 d="m 19264.081,976.1246 c -9.135,-15.99904 -18.27,-30.99814 -28.42,-45.99724"
1884 id="path1011"
1885 inkscape:connector-curvature="0" /><path
1886 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1887 d="m 19216.376,904.12892 c -10.15,-13.99916 -21.315,-27.99832 -33.495,-41.99748"
1888 id="path1013"
1889 inkscape:connector-curvature="0" /><path
1890 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1891 d="m 19160.551,838.13288 c -12.18,-12.99922 -24.36,-24.9985 -37.555,-36.99778"
1892 id="path1015"
1893 inkscape:connector-curvature="0" /><path
1894 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1895 d="m 19097.621,780.13636 c -14.21,-11.99928 -28.42,-21.99868 -42.63,-32.99802"
1896 id="path1017"
1897 inkscape:connector-curvature="0" /><path
1898 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1899 d="m 19027.586,729.13942 c -15.225,-8.99946 -30.45,-17.99892 -46.69,-26.99838"
1900 id="path1019"
1901 inkscape:connector-curvature="0" /><path
1902 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1903 d="m 18951.461,688.14188 c -16.24,-7.99952 -32.48,-13.99916 -49.735,-19.9988"
1904 id="path1021"
1905 inkscape:connector-curvature="0" /><path
1906 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1907 d="m 18870.261,657.14374 c -17.255,-4.9997 -34.51,-8.99946 -51.765,-11.99928"
1908 id="path1023"
1909 inkscape:connector-curvature="0" /><path
1910 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1911 d="m 18786.016,640.14476 c -18.27,-2.99982 -35.525,-3.99976 -53.795,-3.99976"
1912 id="path1025"
1913 inkscape:connector-curvature="0" /><path
1914 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1915 d="m 18699.741,636.145 -53.795,0"
1916 id="path1027"
1917 inkscape:connector-curvature="0" /><path
1918 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1919 d="m 18612.451,636.145 -53.795,0"
1920 id="path1029"
1921 inkscape:connector-curvature="0" /><path
1922 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1923 d="m 18526.176,636.145 -53.795,0"
1924 id="path1031"
1925 inkscape:connector-curvature="0" /><path
1926 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1927 d="m 18438.886,636.145 -53.795,0"
1928 id="path1033"
1929 inkscape:connector-curvature="0" /><path
1930 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1931 d="m 18352.611,636.145 -53.795,0"
1932 id="path1035"
1933 inkscape:connector-curvature="0" /><path
1934 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1935 d="m 18266.336,636.145 -54.81,0"
1936 id="path1037"
1937 inkscape:connector-curvature="0" /><path
1938 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1939 d="m 18179.046,636.145 -53.795,0"
1940 id="path1039"
1941 inkscape:connector-curvature="0" /><path
1942 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1943 d="m 18092.771,636.145 -53.795,0"
1944 id="path1041"
1945 inkscape:connector-curvature="0" /><path
1946 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1947 d="m 18005.481,636.145 -53.795,0"
1948 id="path1043"
1949 inkscape:connector-curvature="0" /><path
1950 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1951 d="m 17919.206,636.145 -53.795,0"
1952 id="path1045"
1953 inkscape:connector-curvature="0" /><path
1954 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1955 d="m 17831.916,636.145 -53.795,0"
1956 id="path1047"
1957 inkscape:connector-curvature="0" /><path
1958 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1959 d="m 17745.641,636.145 -53.795,0"
1960 id="path1049"
1961 inkscape:connector-curvature="0" /><path
1962 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1963 d="m 17659.366,636.145 -54.81,0"
1964 id="path1051"
1965 inkscape:connector-curvature="0" /><path
1966 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1967 d="m 17572.076,636.145 -53.795,0"
1968 id="path1053"
1969 inkscape:connector-curvature="0" /><path
1970 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1971 d="m 17485.801,636.145 -53.795,0"
1972 id="path1055"
1973 inkscape:connector-curvature="0" /><path
1974 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1975 d="m 17398.511,636.145 -53.795,0"
1976 id="path1057"
1977 inkscape:connector-curvature="0" /><path
1978 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1979 d="m 17312.236,636.145 -53.795,0"
1980 id="path1059"
1981 inkscape:connector-curvature="0" /><path
1982 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1983 d="m 17224.946,636.145 -53.795,0"
1984 id="path1061"
1985 inkscape:connector-curvature="0" /><path
1986 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1987 d="m 17138.671,636.145 -53.795,0"
1988 id="path1063"
1989 inkscape:connector-curvature="0" /><path
1990 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1991 d="m 17052.396,636.145 -54.81,0"
1992 id="path1065"
1993 inkscape:connector-curvature="0" /><path
1994 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1995 d="m 16965.106,636.145 -53.795,0"
1996 id="path1067"
1997 inkscape:connector-curvature="0" /><path
1998 style="fill:none;stroke:#3465af;stroke-width:28.432024"
1999 d="m 16878.831,636.145 -53.795,0"
2000 id="path1069"
2001 inkscape:connector-curvature="0" /><path
2002 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2003 d="m 16791.541,636.145 -53.795,0"
2004 id="path1071"
2005 inkscape:connector-curvature="0" /><path
2006 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2007 d="m 16705.266,636.145 -53.795,0"
2008 id="path1073"
2009 inkscape:connector-curvature="0" /><path
2010 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2011 d="m 16617.976,636.145 -53.795,0"
2012 id="path1075"
2013 inkscape:connector-curvature="0" /><path
2014 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2015 d="m 16531.701,636.145 -53.795,0"
2016 id="path1077"
2017 inkscape:connector-curvature="0" /><path
2018 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2019 d="m 16445.426,636.145 -54.81,0"
2020 id="path1079"
2021 inkscape:connector-curvature="0" /><path
2022 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2023 d="m 16358.136,636.145 -53.795,0"
2024 id="path1081"
2025 inkscape:connector-curvature="0" /><path
2026 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2027 d="m 16271.861,636.145 -53.795,0"
2028 id="path1083"
2029 inkscape:connector-curvature="0" /><path
2030 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2031 d="m 16184.571,636.145 -53.795,0"
2032 id="path1085"
2033 inkscape:connector-curvature="0" /><path
2034 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2035 d="m 16098.296,636.145 -53.795,0"
2036 id="path1087"
2037 inkscape:connector-curvature="0" /><path
2038 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2039 d="m 16011.006,636.145 -53.795,0"
2040 id="path1089"
2041 inkscape:connector-curvature="0" /><path
2042 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2043 d="m 15924.731,636.145 -53.795,0"
2044 id="path1091"
2045 inkscape:connector-curvature="0" /><path
2046 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2047 d="m 15837.441,636.145 -53.795,0"
2048 id="path1093"
2049 inkscape:connector-curvature="0" /><path
2050 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2051 d="m 15751.166,636.145 -53.795,0"
2052 id="path1095"
2053 inkscape:connector-curvature="0" /><path
2054 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2055 d="m 15664.891,636.145 -53.795,0"
2056 id="path1097"
2057 inkscape:connector-curvature="0" /><path
2058 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2059 d="m 15577.601,636.145 -53.795,0"
2060 id="path1099"
2061 inkscape:connector-curvature="0" /><path
2062 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2063 d="m 15491.326,636.145 -53.795,0"
2064 id="path1101"
2065 inkscape:connector-curvature="0" /><path
2066 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2067 d="m 15404.036,636.145 -53.795,0"
2068 id="path1103"
2069 inkscape:connector-curvature="0" /><path
2070 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2071 d="m 15317.761,636.145 -53.795,0"
2072 id="path1105"
2073 inkscape:connector-curvature="0" /><path
2074 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2075 d="m 15230.471,636.145 -53.795,0"
2076 id="path1107"
2077 inkscape:connector-curvature="0" /><path
2078 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2079 d="m 15144.196,636.145 -53.795,0"
2080 id="path1109"
2081 inkscape:connector-curvature="0" /><path
2082 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2083 d="m 15057.921,636.145 -53.795,0"
2084 id="path1111"
2085 inkscape:connector-curvature="0" /><path
2086 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2087 d="m 14970.631,636.145 -53.795,0"
2088 id="path1113"
2089 inkscape:connector-curvature="0" /><path
2090 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2091 d="m 14884.356,636.145 -53.795,0"
2092 id="path1115"
2093 inkscape:connector-curvature="0" /><path
2094 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2095 d="m 14797.066,636.145 -53.795,0"
2096 id="path1117"
2097 inkscape:connector-curvature="0" /><path
2098 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2099 d="m 14710.791,636.145 -53.795,0"
2100 id="path1119"
2101 inkscape:connector-curvature="0" /><path
2102 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2103 d="m 14623.501,636.145 -53.795,0"
2104 id="path1121"
2105 inkscape:connector-curvature="0" /><path
2106 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2107 d="m 14537.226,636.145 -53.795,0"
2108 id="path1123"
2109 inkscape:connector-curvature="0" /><path
2110 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2111 d="m 14450.951,636.145 -54.81,0"
2112 id="path1125"
2113 inkscape:connector-curvature="0" /><path
2114 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2115 d="m 14363.661,636.145 -53.795,0"
2116 id="path1127"
2117 inkscape:connector-curvature="0" /><path
2118 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2119 d="m 14277.386,636.145 -53.795,0"
2120 id="path1129"
2121 inkscape:connector-curvature="0" /><path
2122 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2123 d="m 14190.096,636.145 -53.795,0"
2124 id="path1131"
2125 inkscape:connector-curvature="0" /><path
2126 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2127 d="m 14103.821,636.145 -53.795,0"
2128 id="path1133"
2129 inkscape:connector-curvature="0" /><path
2130 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2131 d="m 14016.531,636.145 -53.795,0"
2132 id="path1135"
2133 inkscape:connector-curvature="0" /><path
2134 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2135 d="m 13930.256,636.145 -53.795,0"
2136 id="path1137"
2137 inkscape:connector-curvature="0" /><path
2138 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2139 d="m 13843.981,636.145 -54.81,0"
2140 id="path1139"
2141 inkscape:connector-curvature="0" /><path
2142 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2143 d="m 13756.691,636.145 -53.795,0"
2144 id="path1141"
2145 inkscape:connector-curvature="0" /><path
2146 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2147 d="m 13670.416,636.145 -53.795,0"
2148 id="path1143"
2149 inkscape:connector-curvature="0" /><path
2150 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2151 d="m 13583.126,636.145 -53.795,0"
2152 id="path1145"
2153 inkscape:connector-curvature="0" /><path
2154 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2155 d="m 13496.851,636.145 -53.795,0"
2156 id="path1147"
2157 inkscape:connector-curvature="0" /><path
2158 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2159 d="m 13409.561,636.145 -53.795,0"
2160 id="path1149"
2161 inkscape:connector-curvature="0" /><path
2162 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2163 d="m 13323.286,636.145 -53.795,0"
2164 id="path1151"
2165 inkscape:connector-curvature="0" /><path
2166 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2167 d="m 13237.011,636.145 -54.81,0"
2168 id="path1153"
2169 inkscape:connector-curvature="0" /><path
2170 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2171 d="m 13149.721,636.145 -53.795,0"
2172 id="path1155"
2173 inkscape:connector-curvature="0" /><path
2174 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2175 d="m 13063.446,636.145 -53.795,0"
2176 id="path1157"
2177 inkscape:connector-curvature="0" /><path
2178 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2179 d="m 12976.156,636.145 -53.795,0"
2180 id="path1159"
2181 inkscape:connector-curvature="0" /><path
2182 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2183 d="m 12889.881,636.145 -53.795,0"
2184 id="path1161"
2185 inkscape:connector-curvature="0" /><path
2186 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2187 d="m 12802.591,636.145 -53.795,0"
2188 id="path1163"
2189 inkscape:connector-curvature="0" /><path
2190 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2191 d="m 12716.316,636.145 -53.795,0"
2192 id="path1165"
2193 inkscape:connector-curvature="0" /><path
2194 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2195 d="m 12630.041,636.145 -54.81,0"
2196 id="path1167"
2197 inkscape:connector-curvature="0" /><path
2198 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2199 d="m 12542.751,636.145 -53.795,0"
2200 id="path1169"
2201 inkscape:connector-curvature="0" /><path
2202 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2203 d="m 12456.476,636.145 -53.795,0"
2204 id="path1171"
2205 inkscape:connector-curvature="0" /><path
2206 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2207 d="m 12369.186,636.145 -53.795,0"
2208 id="path1173"
2209 inkscape:connector-curvature="0" /><path
2210 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2211 d="m 12282.911,636.145 -53.795,0"
2212 id="path1175"
2213 inkscape:connector-curvature="0" /><path
2214 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2215 d="m 12195.621,636.145 -53.795,0"
2216 id="path1177"
2217 inkscape:connector-curvature="0" /><path
2218 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2219 d="m 12109.346,636.145 -53.795,0"
2220 id="path1179"
2221 inkscape:connector-curvature="0" /><path
2222 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2223 d="m 12022.056,636.145 -53.795,0"
2224 id="path1181"
2225 inkscape:connector-curvature="0" /><path
2226 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2227 d="m 11935.781,636.145 -53.795,0"
2228 id="path1183"
2229 inkscape:connector-curvature="0" /><path
2230 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2231 d="m 11849.506,636.145 -53.795,0"
2232 id="path1185"
2233 inkscape:connector-curvature="0" /><path
2234 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2235 d="m 11762.216,636.145 -53.795,0"
2236 id="path1187"
2237 inkscape:connector-curvature="0" /><path
2238 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2239 d="m 11675.941,636.145 -53.795,0"
2240 id="path1189"
2241 inkscape:connector-curvature="0" /><path
2242 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2243 d="m 11588.651,636.145 -53.795,0"
2244 id="path1191"
2245 inkscape:connector-curvature="0" /><path
2246 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2247 d="m 11502.376,636.145 -53.795,0"
2248 id="path1193"
2249 inkscape:connector-curvature="0" /><path
2250 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2251 d="m 11415.086,636.145 -53.795,0"
2252 id="path1195"
2253 inkscape:connector-curvature="0" /><path
2254 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2255 d="m 11328.811,636.145 -53.795,0"
2256 id="path1197"
2257 inkscape:connector-curvature="0" /><path
2258 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2259 d="m 11242.536,636.145 -53.795,0"
2260 id="path1199"
2261 inkscape:connector-curvature="0" /><path
2262 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2263 d="m 11155.246,636.145 -53.795,0"
2264 id="path1201"
2265 inkscape:connector-curvature="0" /><path
2266 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2267 d="m 11068.971,636.145 -53.795,0"
2268 id="path1203"
2269 inkscape:connector-curvature="0" /><path
2270 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2271 d="m 10981.681,636.145 -53.795,0"
2272 id="path1205"
2273 inkscape:connector-curvature="0" /><path
2274 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2275 d="m 10895.406,636.145 -53.795,0"
2276 id="path1207"
2277 inkscape:connector-curvature="0" /><path
2278 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2279 d="m 10808.116,636.145 -53.795,0"
2280 id="path1209"
2281 inkscape:connector-curvature="0" /><path
2282 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2283 d="m 10721.841,636.145 -53.795,0"
2284 id="path1211"
2285 inkscape:connector-curvature="0" /><path
2286 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2287 d="m 10635.566,636.145 -53.795,0"
2288 id="path1213"
2289 inkscape:connector-curvature="0" /><path
2290 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2291 d="m 10548.276,636.145 -53.795,0"
2292 id="path1215"
2293 inkscape:connector-curvature="0" /><path
2294 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2295 d="m 10462.001,636.145 -53.795,0"
2296 id="path1217"
2297 inkscape:connector-curvature="0" /><path
2298 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2299 d="m 10374.711,636.145 -53.795,0"
2300 id="path1219"
2301 inkscape:connector-curvature="0" /><path
2302 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2303 d="m 10288.436,636.145 -53.795,0"
2304 id="path1221"
2305 inkscape:connector-curvature="0" /><path
2306 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2307 d="m 10201.146,636.145 -53.795,0"
2308 id="path1223"
2309 inkscape:connector-curvature="0" /><path
2310 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2311 d="m 10114.871,636.145 -53.795,0"
2312 id="path1225"
2313 inkscape:connector-curvature="0" /><path
2314 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2315 d="m 10028.596,636.145 -54.8101,0"
2316 id="path1227"
2317 inkscape:connector-curvature="0" /><path
2318 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2319 d="m 9941.3059,636.145 -53.795,0"
2320 id="path1229"
2321 inkscape:connector-curvature="0" /><path
2322 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2323 d="m 9855.0309,636.145 -53.795,0"
2324 id="path1231"
2325 inkscape:connector-curvature="0" /><path
2326 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2327 d="m 9767.7409,636.145 -53.795,0"
2328 id="path1233"
2329 inkscape:connector-curvature="0" /><path
2330 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2331 d="m 9681.4659,636.145 -53.795,0"
2332 id="path1235"
2333 inkscape:connector-curvature="0" /><path
2334 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2335 d="m 9594.1759,636.145 -53.795,0"
2336 id="path1237"
2337 inkscape:connector-curvature="0" /><path
2338 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2339 d="m 9507.9009,636.145 -53.795,0"
2340 id="path1239"
2341 inkscape:connector-curvature="0" /><path
2342 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2343 d="m 9421.6259,636.145 -54.81,0"
2344 id="path1241"
2345 inkscape:connector-curvature="0" /><path
2346 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2347 d="m 9334.3359,636.145 -53.795,0"
2348 id="path1243"
2349 inkscape:connector-curvature="0" /><path
2350 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2351 d="m 9248.0609,636.145 -53.795,0"
2352 id="path1245"
2353 inkscape:connector-curvature="0" /><path
2354 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2355 d="m 9160.7709,636.145 -53.795,0"
2356 id="path1247"
2357 inkscape:connector-curvature="0" /><path
2358 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2359 d="m 9074.4959,636.145 -53.795,0"
2360 id="path1249"
2361 inkscape:connector-curvature="0" /><path
2362 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2363 d="m 8987.2059,636.145 -53.795,0"
2364 id="path1251"
2365 inkscape:connector-curvature="0" /><path
2366 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2367 d="m 8900.9309,636.145 -53.795,0"
2368 id="path1253"
2369 inkscape:connector-curvature="0" /><path
2370 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2371 d="m 8814.6559,636.145 -54.81,0"
2372 id="path1255"
2373 inkscape:connector-curvature="0" /><path
2374 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2375 d="m 8727.3659,636.145 -53.795,0"
2376 id="path1257"
2377 inkscape:connector-curvature="0" /><path
2378 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2379 d="m 8641.0909,636.145 -53.795,0"
2380 id="path1259"
2381 inkscape:connector-curvature="0" /><path
2382 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2383 d="m 8553.8009,636.145 -53.795,0"
2384 id="path1261"
2385 inkscape:connector-curvature="0" /><path
2386 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2387 d="m 8467.5259,636.145 -53.795,0"
2388 id="path1263"
2389 inkscape:connector-curvature="0" /><path
2390 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2391 d="m 8380.2359,636.145 -53.795,0"
2392 id="path1265"
2393 inkscape:connector-curvature="0" /><path
2394 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2395 d="m 8293.9609,636.145 -53.795,0"
2396 id="path1267"
2397 inkscape:connector-curvature="0" /><path
2398 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2399 d="m 8207.6859,636.145 -54.81,0"
2400 id="path1269"
2401 inkscape:connector-curvature="0" /><path
2402 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2403 d="m 8120.3959,636.145 -53.795,0"
2404 id="path1271"
2405 inkscape:connector-curvature="0" /><path
2406 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2407 d="m 8034.1209,636.145 -53.795,0"
2408 id="path1273"
2409 inkscape:connector-curvature="0" /><path
2410 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2411 d="m 7946.8309,636.145 -53.795,0"
2412 id="path1275"
2413 inkscape:connector-curvature="0" /><path
2414 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2415 d="m 7860.5559,636.145 -53.795,0"
2416 id="path1277"
2417 inkscape:connector-curvature="0" /><path
2418 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2419 d="m 7773.2659,636.145 -53.795,0"
2420 id="path1279"
2421 inkscape:connector-curvature="0" /><path
2422 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2423 d="m 7686.9909,636.145 -53.795,0"
2424 id="path1281"
2425 inkscape:connector-curvature="0" /><path
2426 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2427 d="m 7599.7009,636.145 -53.795,0"
2428 id="path1283"
2429 inkscape:connector-curvature="0" /><path
2430 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2431 d="m 7513.4259,636.145 -53.795,0"
2432 id="path1285"
2433 inkscape:connector-curvature="0" /><path
2434 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2435 d="m 7427.1509,636.145 -53.795,0"
2436 id="path1287"
2437 inkscape:connector-curvature="0" /><path
2438 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2439 d="m 7339.8609,636.145 -53.795,0"
2440 id="path1289"
2441 inkscape:connector-curvature="0" /><path
2442 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2443 d="m 7253.5859,636.145 -53.795,0"
2444 id="path1291"
2445 inkscape:connector-curvature="0" /><path
2446 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2447 d="m 7166.2959,636.145 -53.795,0"
2448 id="path1293"
2449 inkscape:connector-curvature="0" /><path
2450 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2451 d="m 7080.0209,636.145 -53.795,0"
2452 id="path1295"
2453 inkscape:connector-curvature="0" /><path
2454 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2455 d="m 6992.7309,636.145 -53.795,0"
2456 id="path1297"
2457 inkscape:connector-curvature="0" /><path
2458 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2459 d="m 6906.4559,636.145 -53.795,0"
2460 id="path1299"
2461 inkscape:connector-curvature="0" /><path
2462 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2463 d="m 6820.1809,636.145 -53.795,0"
2464 id="path1301"
2465 inkscape:connector-curvature="0" /><path
2466 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2467 d="m 6732.8909,636.145 -53.795,0"
2468 id="path1303"
2469 inkscape:connector-curvature="0" /><path
2470 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2471 d="m 6646.6159,636.145 -53.795,0"
2472 id="path1305"
2473 inkscape:connector-curvature="0" /><path
2474 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2475 d="m 6559.3259,636.145 -53.795,0"
2476 id="path1307"
2477 inkscape:connector-curvature="0" /><path
2478 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2479 d="m 6473.0509,636.145 -53.795,0"
2480 id="path1309"
2481 inkscape:connector-curvature="0" /><path
2482 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2483 d="m 6385.7609,636.145 -53.795,0"
2484 id="path1311"
2485 inkscape:connector-curvature="0" /><path
2486 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2487 d="m 6299.4859,636.145 -53.795,0"
2488 id="path1313"
2489 inkscape:connector-curvature="0" /><path
2490 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2491 d="m 6213.2109,636.145 -54.81,0"
2492 id="path1315"
2493 inkscape:connector-curvature="0" /><path
2494 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2495 d="m 6125.9209,636.145 -53.795,0"
2496 id="path1317"
2497 inkscape:connector-curvature="0" /><path
2498 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2499 d="m 6039.6459,636.145 -53.795,0"
2500 id="path1319"
2501 inkscape:connector-curvature="0" /><path
2502 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2503 d="m 5952.3559,636.145 -53.795,0"
2504 id="path1321"
2505 inkscape:connector-curvature="0" /><path
2506 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2507 d="m 5866.0809,636.145 -53.795,0"
2508 id="path1323"
2509 inkscape:connector-curvature="0" /><path
2510 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2511 d="m 5778.7909,636.145 -53.795,0"
2512 id="path1325"
2513 inkscape:connector-curvature="0" /><path
2514 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2515 d="m 5692.5159,636.145 -53.795,0"
2516 id="path1327"
2517 inkscape:connector-curvature="0" /><path
2518 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2519 d="m 5606.2409,636.145 -54.81,0"
2520 id="path1329"
2521 inkscape:connector-curvature="0" /><path
2522 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2523 d="m 5518.9509,636.145 -53.795,0"
2524 id="path1331"
2525 inkscape:connector-curvature="0" /><path
2526 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2527 d="m 5432.6759,636.145 -53.795,0"
2528 id="path1333"
2529 inkscape:connector-curvature="0" /><path
2530 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2531 d="m 5345.3859,636.145 -53.795,0"
2532 id="path1335"
2533 inkscape:connector-curvature="0" /><path
2534 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2535 d="m 5259.1109,636.145 -53.795,0"
2536 id="path1337"
2537 inkscape:connector-curvature="0" /><path
2538 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2539 d="m 5171.8209,636.145 -53.795,0"
2540 id="path1339"
2541 inkscape:connector-curvature="0" /><path
2542 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2543 d="m 5085.5459,636.145 -53.795,0"
2544 id="path1341"
2545 inkscape:connector-curvature="0" /><path
2546 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2547 d="m 4999.2709,636.145 -54.81,0"
2548 id="path1343"
2549 inkscape:connector-curvature="0" /><path
2550 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2551 d="m 4911.9809,636.145 -53.795,0"
2552 id="path1345"
2553 inkscape:connector-curvature="0" /><path
2554 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2555 d="m 4825.7059,636.145 -53.795,0"
2556 id="path1347"
2557 inkscape:connector-curvature="0" /><path
2558 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2559 d="m 4738.4159,636.145 -53.795,0"
2560 id="path1349"
2561 inkscape:connector-curvature="0" /><path
2562 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2563 d="m 4652.1409,636.145 -53.795,0"
2564 id="path1351"
2565 inkscape:connector-curvature="0" /><path
2566 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2567 d="m 4564.8509,636.145 -53.795,0"
2568 id="path1353"
2569 inkscape:connector-curvature="0" /><path
2570 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2571 d="m 4478.5759,636.145 -53.795,0"
2572 id="path1355"
2573 inkscape:connector-curvature="0" /><path
2574 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2575 d="m 4392.3009,636.145 -54.81,0"
2576 id="path1357"
2577 inkscape:connector-curvature="0" /><path
2578 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2579 d="m 4305.0109,636.145 -53.795,0"
2580 id="path1359"
2581 inkscape:connector-curvature="0" /><path
2582 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2583 d="m 4218.7359,636.145 -53.795,0"
2584 id="path1361"
2585 inkscape:connector-curvature="0" /><path
2586 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2587 d="m 4131.4459,636.145 -53.795,0"
2588 id="path1363"
2589 inkscape:connector-curvature="0" /><path
2590 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2591 d="m 4045.1709,636.145 -53.795,0"
2592 id="path1365"
2593 inkscape:connector-curvature="0" /><path
2594 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2595 d="m 3957.8809,636.145 -53.795,0"
2596 id="path1367"
2597 inkscape:connector-curvature="0" /><path
2598 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2599 d="m 3871.6059,636.145 -53.795,0"
2600 id="path1369"
2601 inkscape:connector-curvature="0" /><path
2602 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2603 d="m 3785.3309,636.145 -54.81,0"
2604 id="path1371"
2605 inkscape:connector-curvature="0" /><path
2606 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2607 d="m 3698.0409,636.145 -53.795,0"
2608 id="path1373"
2609 inkscape:connector-curvature="0" /><path
2610 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2611 d="m 3611.7659,636.145 -53.795,0"
2612 id="path1375"
2613 inkscape:connector-curvature="0" /><path
2614 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2615 d="m 3524.4759,636.145 -53.795,0"
2616 id="path1377"
2617 inkscape:connector-curvature="0" /><path
2618 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2619 d="m 3438.2009,636.145 -53.795,0"
2620 id="path1379"
2621 inkscape:connector-curvature="0" /><path
2622 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2623 d="m 3350.9109,636.145 -53.795,0"
2624 id="path1381"
2625 inkscape:connector-curvature="0" /><path
2626 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2627 d="m 3264.6359,636.145 -53.795,0"
2628 id="path1383"
2629 inkscape:connector-curvature="0" /><path
2630 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2631 d="m 3177.3459,636.145 -53.795,0"
2632 id="path1385"
2633 inkscape:connector-curvature="0" /><path
2634 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2635 d="m 3091.0709,636.145 -53.795,0"
2636 id="path1387"
2637 inkscape:connector-curvature="0" /><path
2638 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2639 d="m 3004.7959,636.145 -53.795,0"
2640 id="path1389"
2641 inkscape:connector-curvature="0" /><path
2642 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2643 d="m 2917.5059,636.145 -53.795,0"
2644 id="path1391"
2645 inkscape:connector-curvature="0" /><path
2646 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2647 d="m 2831.2309,636.145 -53.795,0"
2648 id="path1393"
2649 inkscape:connector-curvature="0" /><path
2650 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2651 d="m 2743.9409,636.145 -53.795,0"
2652 id="path1395"
2653 inkscape:connector-curvature="0" /><path
2654 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2655 d="m 2657.6659,636.145 -53.795,0"
2656 id="path1397"
2657 inkscape:connector-curvature="0" /><path
2658 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2659 d="m 2570.3759,636.145 -53.795,0"
2660 id="path1399"
2661 inkscape:connector-curvature="0" /><path
2662 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2663 d="m 2484.1009,636.145 -53.795,0"
2664 id="path1401"
2665 inkscape:connector-curvature="0" /><path
2666 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2667 d="m 2397.8259,636.145 -53.795,0"
2668 id="path1403"
2669 inkscape:connector-curvature="0" /><path
2670 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2671 d="m 2310.5359,636.145 -53.795,0"
2672 id="path1405"
2673 inkscape:connector-curvature="0" /><path
2674 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2675 d="m 2224.2609,636.145 -53.795,0"
2676 id="path1407"
2677 inkscape:connector-curvature="0" /><path
2678 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2679 d="m 2136.9709,636.145 -53.795,0"
2680 id="path1409"
2681 inkscape:connector-curvature="0" /><path
2682 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2683 d="m 2050.6959,636.145 -53.795,0"
2684 id="path1411"
2685 inkscape:connector-curvature="0" /><path
2686 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2687 d="m 1963.4059,636.145 -53.795,0"
2688 id="path1413"
2689 inkscape:connector-curvature="0" /><path
2690 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2691 d="m 1877.1309,636.145 -53.795,0"
2692 id="path1415"
2693 inkscape:connector-curvature="0" /><path
2694 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2695 d="m 1790.8559,636.145 -54.81,0"
2696 id="path1417"
2697 inkscape:connector-curvature="0" /><path
2698 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2699 d="m 1703.5659,636.145 -53.795,0"
2700 id="path1419"
2701 inkscape:connector-curvature="0" /><path
2702 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2703 d="m 1617.2909,636.145 -53.795,0"
2704 id="path1421"
2705 inkscape:connector-curvature="0" /><path
2706 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2707 d="m 1530.0009,636.145 -53.795,0"
2708 id="path1423"
2709 inkscape:connector-curvature="0" /><path
2710 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2711 d="m 1443.7259,636.145 -53.795,0"
2712 id="path1425"
2713 inkscape:connector-curvature="0" /><path
2714 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2715 d="m 1356.4359,636.145 -53.795,0"
2716 id="path1427"
2717 inkscape:connector-curvature="0" /><path
2718 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2719 d="m 1270.1609,636.145 -53.795,0"
2720 id="path1429"
2721 inkscape:connector-curvature="0" /><path
2722 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2723 d="m 1183.8859,636.145 -54.81,0"
2724 id="path1431"
2725 inkscape:connector-curvature="0" /><path
2726 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2727 d="m 1096.5959,636.145 -53.795,0"
2728 id="path1433"
2729 inkscape:connector-curvature="0" /><path
2730 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2731 d="m 1010.3209,636.145 -53.795,0"
2732 id="path1435"
2733 inkscape:connector-curvature="0" /><path
2734 style="fill:none;stroke:#3465af;stroke-width:28.432024"
2735 d="m 923.0309,636.145 -53.795,0"
2736 id="path1437"
2737 inkscape:connector-curvature="0" /><g
2738 id="g4044"><rect
2739 height="1100.7"
2740 width="1213.6"
2741 y="4753.1133"
2742 x="21109.146"
2743 id="rect1441"
2744 style="fill:#f3e777" /><path
2745 d="m 20656.146,5536.413 0,-405.46 150.7,-169.16 c 82.886,-93.039 170.53,-186.62 194.77,-207.96 l 44.069,-38.798 783.23,-0.086 783.23,-0.086 0,613.5 0,613.5 -978,0 -978,0 0,-405.46 z m 1027.7,136.98 0,-78.372 -169.91,4.925 -169.91,4.9249 -5.09,45.854 c -8.249,74.303 46.711,101.04 207.69,101.04 l 137.21,0 0,-78.372 z m 235.86,-262.94 4.495,-341.31 207.2,-8.6408 207.2,-8.6408 5.144,-46.443 c 9.596,-86.615 -41.863,-102.05 -322.02,-96.607 l -246.71,4.7956 -4.438,419.08 -4.439,419.08 74.537,0 74.538,0 4.494,-341.31 z m 391.3,313.72 c 26.41,-19.286 36.255,-41.399 32.697,-73.447 l -5.09,-45.854 -174.05,0 -174.05,0 -5.38,48.984 c -9.97,90.771 0.993,97.91 150.36,97.91 99.305,0 148.27,-7.6982 175.52,-27.594 z m -627.16,-274.84 0,-77.768 -174.05,0 -174.05,0 0,66.246 c 0,36.436 4.973,71.431 11.051,77.768 6.078,6.3366 84.401,11.521 174.05,11.521 l 163,0 0,-77.768 z m 659.89,-4.9154 5.125,-74.042 -179.18,4.9155 -179.18,4.9155 -5.38,48.984 c -10.473,95.348 -2.259,99.57 183.28,94.197 l 170.2,-4.9284 5.125,-74.042 z m -659.89,-237.63 0,-78.372 -169.91,4.925 -169.91,4.925 -5.097,73.447 -5.097,73.447 175,0 175,0 0,-78.372 z m 659.86,4.925 -5.097,-73.447 -174.05,0 -174.05,0 -5.38,48.984 c -10.289,93.673 -2.146,97.91 188.15,97.91 l 175.52,0 -5.097,-73.447 z m -659.86,-228.98 0,-77.768 -137.21,0 c -97.358,0 -147.91,7.8138 -174.05,26.902 -34.952,25.523 -49.645,92.242 -25.79,117.11 6.078,6.3366 84.401,11.521 174.05,11.521 l 163,0 0,-77.768 z"
2746 id="path1443"
2747 inkscape:connector-curvature="0"
2748 style="fill:#ca4677" /></g><text
2749 style="font-size:9.10937119px;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round"
2750 class="TextShape"
2751 id="text1489"
2752 transform="scale(1.1035537,0.9061634)"
2753 x="171.41566"
2754 y="9913.7109"><tspan
2755 font-size="635px"
2756 font-weight="400"
2757 class="TextParagraph"
2758 id="tspan1491"
2759 style="font-weight:400;font-size:482.03753662px;font-family:'Times New Roman', serif" /></text>
2760<g
2761 id="g4048"><rect
2762 height="2342.4341"
2763 width="2320.7097"
2764 y="13737.451"
2765 x="18796.941"
2766 id="rect1447"
2767 style="fill:#6076b3" /><rect
2768 id="rect1451"
2769 height="137.78799"
2770 x="18532.135"
2771 width="302.70312"
2772 y="13817.405"
2773 style="fill:#e0ee2c;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round" /><rect
2774 id="rect1453"
2775 height="137.78799"
2776 x="18532.135"
2777 width="302.70312"
2778 y="14075.544"
2779 style="fill:#e0ee2c;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round" /><rect
2780 id="rect1455"
2781 height="137.78799"
2782 x="18532.135"
2783 width="302.70312"
2784 y="14334.443"
2785 style="fill:#e0ee2c;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round" /><rect
2786 id="rect1457"
2787 height="137.78799"
2788 x="18532.135"
2789 width="302.70312"
2790 y="14592.582"
2791 style="fill:#e0ee2c;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round" /><rect
2792 id="rect1459"
2793 height="137.78799"
2794 x="18532.135"
2795 width="302.70312"
2796 y="14850.721"
2797 style="fill:#e0ee2c;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round" /><rect
2798 id="rect1461"
2799 height="137.78799"
2800 x="18532.135"
2801 width="302.70312"
2802 y="15109.62"
2803 style="fill:#e0ee2c;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round" /><rect
2804 id="rect1463"
2805 height="137.78799"
2806 x="18532.135"
2807 width="302.70312"
2808 y="15367.759"
2809 style="fill:#e0ee2c;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round" /><rect
2810 id="rect1465"
2811 height="137.78799"
2812 x="18532.135"
2813 width="302.70312"
2814 y="15625.896"
2815 style="fill:#e0ee2c;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round" /><rect
2816 id="rect1467"
2817 height="137.78799"
2818 x="18532.135"
2819 width="302.70312"
2820 y="15884.035"
2821 style="fill:#e0ee2c;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round" /><rect
2822 id="rect1469"
2823 height="137.78799"
2824 x="21080.053"
2825 width="302.70312"
2826 y="13783.14"
2827 style="fill:#e0ee2c;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round" /><rect
2828 id="rect1471"
2829 height="137.78799"
2830 x="21080.053"
2831 width="302.70312"
2832 y="14041.277"
2833 style="fill:#e0ee2c;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round" /><rect
2834 id="rect1473"
2835 height="137.78799"
2836 x="21080.053"
2837 width="302.70312"
2838 y="14299.416"
2839 style="fill:#e0ee2c;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round" /><rect
2840 id="rect1475"
2841 height="137.78799"
2842 x="21080.053"
2843 width="302.70312"
2844 y="14558.315"
2845 style="fill:#e0ee2c;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round" /><rect
2846 id="rect1477"
2847 height="137.78799"
2848 x="21080.053"
2849 width="302.70312"
2850 y="14816.454"
2851 style="fill:#e0ee2c;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round" /><rect
2852 id="rect1479"
2853 height="137.78799"
2854 x="21080.053"
2855 width="302.70312"
2856 y="15074.593"
2857 style="fill:#e0ee2c;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round" /><rect
2858 id="rect1481"
2859 height="137.78799"
2860 x="21080.053"
2861 width="302.70312"
2862 y="15333.492"
2863 style="fill:#e0ee2c;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round" /><rect
2864 id="rect1483"
2865 height="137.78799"
2866 x="21080.053"
2867 width="302.70312"
2868 y="15591.631"
2869 style="fill:#e0ee2c;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round" /><rect
2870 id="rect1485"
2871 height="137.78799"
2872 x="21080.053"
2873 width="302.70312"
2874 y="15849.769"
2875 style="fill:#e0ee2c;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round" /><text
2876 transform="scale(1.1035537,0.9061634)"
2877 sodipodi:linespacing="125%"
2878 id="text1493"
2879 line-height="125%"
2880 x="17205.688"
2881 y="16777.641"
2882 font-size="1128.9px"
2883 xml:space="preserve"
2884 style="font-size:856.96411133px;line-height:125%;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round"><tspan
2885 id="tspan1495"
2886 x="17205.688"
2887 y="16777.641">CPU</tspan></text>
2888</g><text
2889 style="fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round"
2890 id="text1499"
2891 class="TextShape"
2892 x="-11700.553"
2893 y="565.61298"><tspan
2894 style="font-weight:400;font-size:706px;font-family:'Times New Roman', serif"
2895 id="tspan1501"
2896 class="TextParagraph"
2897 font-weight="400"
2898 font-size="706px"><tspan
2899 id="tspan1503"
2900 transform="matrix(0,-1,1,0,8509,40173)"
2901 class="TextPosition"
2902 x="12640.447"
2903 y="16397.613"><tspan
2904 style="fill:#000000"
2905 id="tspan1505">PCI, USB, SPI, I2C, ...</tspan></tspan></tspan></text>
2906<path
2907 d="m 12408.066,15561.578 -1115.084,0 0,-1420.331 2230.169,0 0,1420.331 -1115.085,0 z"
2908 id="path1511"
2909 inkscape:connector-curvature="0"
2910 style="fill:#cfe7f5;fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round" /><path
2911 d="m 12408.066,15561.578 -1115.084,0 0,-1420.331 2230.169,0 0,1420.331 -1115.085,0 z"
2912 id="path1513"
2913 inkscape:connector-curvature="0"
2914 style="fill:none;fill-rule:evenodd;stroke:#3465af;stroke-width:19.84712601;stroke-linejoin:round" /><text
2915 style="fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round"
2916 id="text1515"
2917 class="TextShape"
2918 x="-1394.0863"
2919 y="590.73016"><tspan
2920 style="font-weight:400;font-size:635px;font-family:'Times New Roman', serif"
2921 id="tspan1517"
2922 class="TextParagraph"
2923 font-weight="400"
2924 font-size="635px"><tspan
2925 id="tspan1519"
2926 class="TextPosition"
2927 x="11487.915"
2928 y="14672.743"><tspan
2929 style="fill:#000000"
2930 id="tspan1521">Bridge</tspan></tspan></tspan></text>
2931<text
2932 style="fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round"
2933 id="text1523"
2934 class="TextShape"
2935 x="-1450.5308"
2936 y="1324.5078"><tspan
2937 style="font-weight:400;font-size:635px;font-family:'Times New Roman', serif"
2938 id="tspan1525"
2939 class="TextParagraph"
2940 font-weight="400"
2941 font-size="635px"><tspan
2942 id="tspan1527"
2943 class="TextPosition"
2944 x="11431.471"
2945 y="15406.52"><tspan
2946 style="fill:#000000"
2947 id="tspan1529"> DMA</tspan></tspan></tspan></text>
2948</svg> \ No newline at end of file
diff --git a/Documentation/media/uapi/cec/cec-ioc-adap-g-caps.rst b/Documentation/media/uapi/cec/cec-ioc-adap-g-caps.rst
index a35dca281178..2b0ddb14b280 100644
--- a/Documentation/media/uapi/cec/cec-ioc-adap-g-caps.rst
+++ b/Documentation/media/uapi/cec/cec-ioc-adap-g-caps.rst
@@ -48,41 +48,21 @@ returns the information to the application. The ioctl never fails.
48 :stub-columns: 0 48 :stub-columns: 0
49 :widths: 1 1 16 49 :widths: 1 1 16
50 50
51 51 * - char
52 - .. row 1 52 - ``driver[32]``
53 53 - The name of the cec adapter driver.
54 - char 54 * - char
55 55 - ``name[32]``
56 - ``driver[32]`` 56 - The name of this CEC adapter. The combination ``driver`` and
57 57 ``name`` must be unique.
58 - The name of the cec adapter driver. 58 * - __u32
59 59 - ``capabilities``
60 - .. row 2 60 - The capabilities of the CEC adapter, see
61 61 :ref:`cec-capabilities`.
62 - char 62 * - __u32
63 63 - ``version``
64 - ``name[32]`` 64 - CEC Framework API version, formatted with the ``KERNEL_VERSION()``
65 65 macro.
66 - The name of this CEC adapter. The combination ``driver`` and
67 ``name`` must be unique.
68
69 - .. row 3
70
71 - __u32
72
73 - ``capabilities``
74
75 - The capabilities of the CEC adapter, see
76 :ref:`cec-capabilities`.
77
78 - .. row 4
79
80 - __u32
81
82 - ``version``
83
84 - CEC Framework API version, formatted with the ``KERNEL_VERSION()``
85 macro.
86 66
87 67
88.. tabularcolumns:: |p{4.4cm}|p{2.5cm}|p{10.6cm}| 68.. tabularcolumns:: |p{4.4cm}|p{2.5cm}|p{10.6cm}|
@@ -94,68 +74,50 @@ returns the information to the application. The ioctl never fails.
94 :stub-columns: 0 74 :stub-columns: 0
95 :widths: 3 1 8 75 :widths: 3 1 8
96 76
97 77 * .. _`CEC-CAP-PHYS-ADDR`:
98 - .. _`CEC-CAP-PHYS-ADDR`: 78
99 79 - ``CEC_CAP_PHYS_ADDR``
100 - ``CEC_CAP_PHYS_ADDR`` 80 - 0x00000001
101 81 - Userspace has to configure the physical address by calling
102 - 0x00000001 82 :ref:`ioctl CEC_ADAP_S_PHYS_ADDR <CEC_ADAP_S_PHYS_ADDR>`. If
103 83 this capability isn't set, then setting the physical address is
104 - Userspace has to configure the physical address by calling 84 handled by the kernel whenever the EDID is set (for an HDMI
105 :ref:`ioctl CEC_ADAP_S_PHYS_ADDR <CEC_ADAP_S_PHYS_ADDR>`. If 85 receiver) or read (for an HDMI transmitter).
106 this capability isn't set, then setting the physical address is 86 * .. _`CEC-CAP-LOG-ADDRS`:
107 handled by the kernel whenever the EDID is set (for an HDMI 87
108 receiver) or read (for an HDMI transmitter). 88 - ``CEC_CAP_LOG_ADDRS``
109 89 - 0x00000002
110 - .. _`CEC-CAP-LOG-ADDRS`: 90 - Userspace has to configure the logical addresses by calling
111 91 :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`. If
112 - ``CEC_CAP_LOG_ADDRS`` 92 this capability isn't set, then the kernel will have configured
113 93 this.
114 - 0x00000002 94 * .. _`CEC-CAP-TRANSMIT`:
115 95
116 - Userspace has to configure the logical addresses by calling 96 - ``CEC_CAP_TRANSMIT``
117 :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`. If 97 - 0x00000004
118 this capability isn't set, then the kernel will have configured 98 - Userspace can transmit CEC messages by calling
119 this. 99 :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>`. This implies that
120 100 userspace can be a follower as well, since being able to transmit
121 - .. _`CEC-CAP-TRANSMIT`: 101 messages is a prerequisite of becoming a follower. If this
122 102 capability isn't set, then the kernel will handle all CEC
123 - ``CEC_CAP_TRANSMIT`` 103 transmits and process all CEC messages it receives.
124 104 * .. _`CEC-CAP-PASSTHROUGH`:
125 - 0x00000004 105
126 106 - ``CEC_CAP_PASSTHROUGH``
127 - Userspace can transmit CEC messages by calling 107 - 0x00000008
128 :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>`. This implies that 108 - Userspace can use the passthrough mode by calling
129 userspace can be a follower as well, since being able to transmit 109 :ref:`ioctl CEC_S_MODE <CEC_S_MODE>`.
130 messages is a prerequisite of becoming a follower. If this 110 * .. _`CEC-CAP-RC`:
131 capability isn't set, then the kernel will handle all CEC 111
132 transmits and process all CEC messages it receives. 112 - ``CEC_CAP_RC``
133 113 - 0x00000010
134 - .. _`CEC-CAP-PASSTHROUGH`: 114 - This adapter supports the remote control protocol.
135 115 * .. _`CEC-CAP-MONITOR-ALL`:
136 - ``CEC_CAP_PASSTHROUGH`` 116
137 117 - ``CEC_CAP_MONITOR_ALL``
138 - 0x00000008 118 - 0x00000020
139 119 - The CEC hardware can monitor all messages, not just directed and
140 - Userspace can use the passthrough mode by calling 120 broadcast messages.
141 :ref:`ioctl CEC_S_MODE <CEC_S_MODE>`.
142
143 - .. _`CEC-CAP-RC`:
144
145 - ``CEC_CAP_RC``
146
147 - 0x00000010
148
149 - This adapter supports the remote control protocol.
150
151 - .. _`CEC-CAP-MONITOR-ALL`:
152
153 - ``CEC_CAP_MONITOR_ALL``
154
155 - 0x00000020
156
157 - The CEC hardware can monitor all messages, not just directed and
158 broadcast messages.
159 121
160 122
161 123
diff --git a/Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst b/Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst
index 940a16d8d55e..b878637e91b3 100644
--- a/Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst
+++ b/Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst
@@ -77,134 +77,79 @@ logical address types are already defined will return with error ``EBUSY``.
77 :stub-columns: 0 77 :stub-columns: 0
78 :widths: 1 1 16 78 :widths: 1 1 16
79 79
80 80 * - __u8
81 - .. row 1 81 - ``log_addr[CEC_MAX_LOG_ADDRS]``
82 82 - The actual logical addresses that were claimed. This is set by the
83 - __u8 83 driver. If no logical address could be claimed, then it is set to
84 84 ``CEC_LOG_ADDR_INVALID``. If this adapter is Unregistered, then
85 - ``log_addr[CEC_MAX_LOG_ADDRS]`` 85 ``log_addr[0]`` is set to 0xf and all others to
86 86 ``CEC_LOG_ADDR_INVALID``.
87 - The actual logical addresses that were claimed. This is set by the 87 * - __u16
88 driver. If no logical address could be claimed, then it is set to 88 - ``log_addr_mask``
89 ``CEC_LOG_ADDR_INVALID``. If this adapter is Unregistered, then 89 - The bitmask of all logical addresses this adapter has claimed. If
90 ``log_addr[0]`` is set to 0xf and all others to 90 this adapter is Unregistered then ``log_addr_mask`` sets bit 15
91 ``CEC_LOG_ADDR_INVALID``. 91 and clears all other bits. If this adapter is not configured at
92 92 all, then ``log_addr_mask`` is set to 0. Set by the driver.
93 - .. row 2 93 * - __u8
94 94 - ``cec_version``
95 - __u16 95 - The CEC version that this adapter shall use. See
96 96 :ref:`cec-versions`. Used to implement the
97 - ``log_addr_mask`` 97 ``CEC_MSG_CEC_VERSION`` and ``CEC_MSG_REPORT_FEATURES`` messages.
98 98 Note that :ref:`CEC_OP_CEC_VERSION_1_3A <CEC-OP-CEC-VERSION-1-3A>` is not allowed by the CEC
99 - The bitmask of all logical addresses this adapter has claimed. If 99 framework.
100 this adapter is Unregistered then ``log_addr_mask`` sets bit 15 100 * - __u8
101 and clears all other bits. If this adapter is not configured at 101 - ``num_log_addrs``
102 all, then ``log_addr_mask`` is set to 0. Set by the driver. 102 - Number of logical addresses to set up. Must be ≤
103 103 ``available_log_addrs`` as returned by
104 - .. row 3 104 :ref:`CEC_ADAP_G_CAPS`. All arrays in
105 105 this structure are only filled up to index
106 - __u8 106 ``available_log_addrs``-1. The remaining array elements will be
107 107 ignored. Note that the CEC 2.0 standard allows for a maximum of 2
108 - ``cec_version`` 108 logical addresses, although some hardware has support for more.
109 109 ``CEC_MAX_LOG_ADDRS`` is 4. The driver will return the actual
110 - The CEC version that this adapter shall use. See 110 number of logical addresses it could claim, which may be less than
111 :ref:`cec-versions`. Used to implement the 111 what was requested. If this field is set to 0, then the CEC
112 ``CEC_MSG_CEC_VERSION`` and ``CEC_MSG_REPORT_FEATURES`` messages. 112 adapter shall clear all claimed logical addresses and all other
113 Note that :ref:`CEC_OP_CEC_VERSION_1_3A <CEC-OP-CEC-VERSION-1-3A>` is not allowed by the CEC 113 fields will be ignored.
114 framework. 114 * - __u32
115 115 - ``vendor_id``
116 - .. row 4 116 - The vendor ID is a 24-bit number that identifies the specific
117 117 vendor or entity. Based on this ID vendor specific commands may be
118 - __u8 118 defined. If you do not want a vendor ID then set it to
119 119 ``CEC_VENDOR_ID_NONE``.
120 - ``num_log_addrs`` 120 * - __u32
121 121 - ``flags``
122 - Number of logical addresses to set up. Must be ≤ 122 - Flags. See :ref:`cec-log-addrs-flags` for a list of available flags.
123 ``available_log_addrs`` as returned by 123 * - char
124 :ref:`CEC_ADAP_G_CAPS`. All arrays in 124 - ``osd_name[15]``
125 this structure are only filled up to index 125 - The On-Screen Display name as is returned by the
126 ``available_log_addrs``-1. The remaining array elements will be 126 ``CEC_MSG_SET_OSD_NAME`` message.
127 ignored. Note that the CEC 2.0 standard allows for a maximum of 2 127 * - __u8
128 logical addresses, although some hardware has support for more. 128 - ``primary_device_type[CEC_MAX_LOG_ADDRS]``
129 ``CEC_MAX_LOG_ADDRS`` is 4. The driver will return the actual 129 - Primary device type for each logical address. See
130 number of logical addresses it could claim, which may be less than 130 :ref:`cec-prim-dev-types` for possible types.
131 what was requested. If this field is set to 0, then the CEC 131 * - __u8
132 adapter shall clear all claimed logical addresses and all other 132 - ``log_addr_type[CEC_MAX_LOG_ADDRS]``
133 fields will be ignored. 133 - Logical address types. See :ref:`cec-log-addr-types` for
134 134 possible types. The driver will update this with the actual
135 - .. row 5 135 logical address type that it claimed (e.g. it may have to fallback
136 136 to :ref:`CEC_LOG_ADDR_TYPE_UNREGISTERED <CEC-LOG-ADDR-TYPE-UNREGISTERED>`).
137 - __u32 137 * - __u8
138 138 - ``all_device_types[CEC_MAX_LOG_ADDRS]``
139 - ``vendor_id`` 139 - CEC 2.0 specific: the bit mask of all device types. See
140 140 :ref:`cec-all-dev-types-flags`. It is used in the CEC 2.0
141 - The vendor ID is a 24-bit number that identifies the specific 141 ``CEC_MSG_REPORT_FEATURES`` message. For CEC 1.4 you can either leave
142 vendor or entity. Based on this ID vendor specific commands may be 142 this field to 0, or fill it in according to the CEC 2.0 guidelines to
143 defined. If you do not want a vendor ID then set it to 143 give the CEC framework more information about the device type, even
144 ``CEC_VENDOR_ID_NONE``. 144 though the framework won't use it directly in the CEC message.
145 145 * - __u8
146 - .. row 6 146 - ``features[CEC_MAX_LOG_ADDRS][12]``
147 147 - Features for each logical address. It is used in the CEC 2.0
148 - __u32 148 ``CEC_MSG_REPORT_FEATURES`` message. The 12 bytes include both the
149 149 RC Profile and the Device Features. For CEC 1.4 you can either leave
150 - ``flags`` 150 this field to all 0, or fill it in according to the CEC 2.0 guidelines to
151 151 give the CEC framework more information about the device type, even
152 - Flags. See :ref:`cec-log-addrs-flags` for a list of available flags. 152 though the framework won't use it directly in the CEC message.
153
154 - .. row 7
155
156 - char
157
158 - ``osd_name[15]``
159
160 - The On-Screen Display name as is returned by the
161 ``CEC_MSG_SET_OSD_NAME`` message.
162
163 - .. row 8
164
165 - __u8
166
167 - ``primary_device_type[CEC_MAX_LOG_ADDRS]``
168
169 - Primary device type for each logical address. See
170 :ref:`cec-prim-dev-types` for possible types.
171
172 - .. row 9
173
174 - __u8
175
176 - ``log_addr_type[CEC_MAX_LOG_ADDRS]``
177
178 - Logical address types. See :ref:`cec-log-addr-types` for
179 possible types. The driver will update this with the actual
180 logical address type that it claimed (e.g. it may have to fallback
181 to :ref:`CEC_LOG_ADDR_TYPE_UNREGISTERED <CEC-LOG-ADDR-TYPE-UNREGISTERED>`).
182
183 - .. row 10
184
185 - __u8
186
187 - ``all_device_types[CEC_MAX_LOG_ADDRS]``
188
189 - CEC 2.0 specific: the bit mask of all device types. See
190 :ref:`cec-all-dev-types-flags`. It is used in the CEC 2.0
191 ``CEC_MSG_REPORT_FEATURES`` message. For CEC 1.4 you can either leave
192 this field to 0, or fill it in according to the CEC 2.0 guidelines to
193 give the CEC framework more information about the device type, even
194 though the framework won't use it directly in the CEC message.
195
196 - .. row 11
197
198 - __u8
199
200 - ``features[CEC_MAX_LOG_ADDRS][12]``
201
202 - Features for each logical address. It is used in the CEC 2.0
203 ``CEC_MSG_REPORT_FEATURES`` message. The 12 bytes include both the
204 RC Profile and the Device Features. For CEC 1.4 you can either leave
205 this field to all 0, or fill it in according to the CEC 2.0 guidelines to
206 give the CEC framework more information about the device type, even
207 though the framework won't use it directly in the CEC message.
208 153
209.. _cec-log-addrs-flags: 154.. _cec-log-addrs-flags:
210 155
@@ -213,17 +158,33 @@ logical address types are already defined will return with error ``EBUSY``.
213 :stub-columns: 0 158 :stub-columns: 0
214 :widths: 3 1 4 159 :widths: 3 1 4
215 160
161 * .. _`CEC-LOG-ADDRS-FL-ALLOW-UNREG-FALLBACK`:
162
163 - ``CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK``
164 - 1
165 - By default if no logical address of the requested type can be claimed, then
166 it will go back to the unconfigured state. If this flag is set, then it will
167 fallback to the Unregistered logical address. Note that if the Unregistered
168 logical address was explicitly requested, then this flag has no effect.
169 * .. _`CEC-LOG-ADDRS-FL-ALLOW-RC-PASSTHRU`:
216 170
217 - .. _`CEC-LOG-ADDRS-FL-ALLOW-UNREG-FALLBACK`: 171 - ``CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU``
172 - 2
173 - By default the ``CEC_MSG_USER_CONTROL_PRESSED`` and ``CEC_MSG_USER_CONTROL_RELEASED``
174 messages are only passed on to the follower(s), if any. If this flag is set,
175 then these messages are also passed on to the remote control input subsystem
176 and will appear as keystrokes. This features needs to be enabled explicitly.
177 If CEC is used to enter e.g. passwords, then you may not want to enable this
178 to avoid trivial snooping of the keystrokes.
179 * .. _`CEC-LOG-ADDRS-FL-CDC-ONLY`:
218 180
219 - ``CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK`` 181 - `CEC_LOG_ADDRS_FL_CDC_ONLY`
182 - 4
183 - If this flag is set, then the device is CDC-Only. CDC-Only CEC devices
184 are CEC devices that can only handle CDC messages.
220 185
221 - 1 186 All other messages are ignored.
222 187
223 - By default if no logical address of the requested type can be claimed, then
224 it will go back to the unconfigured state. If this flag is set, then it will
225 fallback to the Unregistered logical address. Note that if the Unregistered
226 logical address was explicitly requested, then this flag has no effect.
227 188
228.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}| 189.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
229 190
@@ -234,30 +195,21 @@ logical address types are already defined will return with error ``EBUSY``.
234 :stub-columns: 0 195 :stub-columns: 0
235 :widths: 3 1 4 196 :widths: 3 1 4
236 197
198 * .. _`CEC-OP-CEC-VERSION-1-3A`:
237 199
238 - .. _`CEC-OP-CEC-VERSION-1-3A`: 200 - ``CEC_OP_CEC_VERSION_1_3A``
239 201 - 4
240 - ``CEC_OP_CEC_VERSION_1_3A`` 202 - CEC version according to the HDMI 1.3a standard.
241 203 * .. _`CEC-OP-CEC-VERSION-1-4B`:
242 - 4
243
244 - CEC version according to the HDMI 1.3a standard.
245
246 - .. _`CEC-OP-CEC-VERSION-1-4B`:
247
248 - ``CEC_OP_CEC_VERSION_1_4B``
249 204
250 - 5 205 - ``CEC_OP_CEC_VERSION_1_4B``
206 - 5
207 - CEC version according to the HDMI 1.4b standard.
208 * .. _`CEC-OP-CEC-VERSION-2-0`:
251 209
252 - CEC version according to the HDMI 1.4b standard. 210 - ``CEC_OP_CEC_VERSION_2_0``
253 211 - 6
254 - .. _`CEC-OP-CEC-VERSION-2-0`: 212 - CEC version according to the HDMI 2.0 standard.
255
256 - ``CEC_OP_CEC_VERSION_2_0``
257
258 - 6
259
260 - CEC version according to the HDMI 2.0 standard.
261 213
262 214
263.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}| 215.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
@@ -269,62 +221,41 @@ logical address types are already defined will return with error ``EBUSY``.
269 :stub-columns: 0 221 :stub-columns: 0
270 :widths: 3 1 4 222 :widths: 3 1 4
271 223
224 * .. _`CEC-OP-PRIM-DEVTYPE-TV`:
272 225
273 - .. _`CEC-OP-PRIM-DEVTYPE-TV`: 226 - ``CEC_OP_PRIM_DEVTYPE_TV``
274 227 - 0
275 - ``CEC_OP_PRIM_DEVTYPE_TV`` 228 - Use for a TV.
276 229 * .. _`CEC-OP-PRIM-DEVTYPE-RECORD`:
277 - 0
278
279 - Use for a TV.
280 230
281 - .. _`CEC-OP-PRIM-DEVTYPE-RECORD`: 231 - ``CEC_OP_PRIM_DEVTYPE_RECORD``
232 - 1
233 - Use for a recording device.
234 * .. _`CEC-OP-PRIM-DEVTYPE-TUNER`:
282 235
283 - ``CEC_OP_PRIM_DEVTYPE_RECORD`` 236 - ``CEC_OP_PRIM_DEVTYPE_TUNER``
237 - 3
238 - Use for a device with a tuner.
239 * .. _`CEC-OP-PRIM-DEVTYPE-PLAYBACK`:
284 240
285 - 1 241 - ``CEC_OP_PRIM_DEVTYPE_PLAYBACK``
242 - 4
243 - Use for a playback device.
244 * .. _`CEC-OP-PRIM-DEVTYPE-AUDIOSYSTEM`:
286 245
287 - Use for a recording device. 246 - ``CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM``
247 - 5
248 - Use for an audio system (e.g. an audio/video receiver).
249 * .. _`CEC-OP-PRIM-DEVTYPE-SWITCH`:
288 250
289 - .. _`CEC-OP-PRIM-DEVTYPE-TUNER`: 251 - ``CEC_OP_PRIM_DEVTYPE_SWITCH``
252 - 6
253 - Use for a CEC switch.
254 * .. _`CEC-OP-PRIM-DEVTYPE-VIDEOPROC`:
290 255
291 - ``CEC_OP_PRIM_DEVTYPE_TUNER`` 256 - ``CEC_OP_PRIM_DEVTYPE_VIDEOPROC``
292 257 - 7
293 - 3 258 - Use for a video processor device.
294
295 - Use for a device with a tuner.
296
297 - .. _`CEC-OP-PRIM-DEVTYPE-PLAYBACK`:
298
299 - ``CEC_OP_PRIM_DEVTYPE_PLAYBACK``
300
301 - 4
302
303 - Use for a playback device.
304
305 - .. _`CEC-OP-PRIM-DEVTYPE-AUDIOSYSTEM`:
306
307 - ``CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM``
308
309 - 5
310
311 - Use for an audio system (e.g. an audio/video receiver).
312
313 - .. _`CEC-OP-PRIM-DEVTYPE-SWITCH`:
314
315 - ``CEC_OP_PRIM_DEVTYPE_SWITCH``
316
317 - 6
318
319 - Use for a CEC switch.
320
321 - .. _`CEC-OP-PRIM-DEVTYPE-VIDEOPROC`:
322
323 - ``CEC_OP_PRIM_DEVTYPE_VIDEOPROC``
324
325 - 7
326
327 - Use for a video processor device.
328 259
329 260
330.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}| 261.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
@@ -336,64 +267,43 @@ logical address types are already defined will return with error ``EBUSY``.
336 :stub-columns: 0 267 :stub-columns: 0
337 :widths: 3 1 16 268 :widths: 3 1 16
338 269
270 * .. _`CEC-LOG-ADDR-TYPE-TV`:
339 271
340 - .. _`CEC-LOG-ADDR-TYPE-TV`: 272 - ``CEC_LOG_ADDR_TYPE_TV``
341 273 - 0
342 - ``CEC_LOG_ADDR_TYPE_TV`` 274 - Use for a TV.
343 275 * .. _`CEC-LOG-ADDR-TYPE-RECORD`:
344 - 0
345
346 - Use for a TV.
347
348 - .. _`CEC-LOG-ADDR-TYPE-RECORD`:
349
350 - ``CEC_LOG_ADDR_TYPE_RECORD``
351
352 - 1
353
354 - Use for a recording device.
355
356 - .. _`CEC-LOG-ADDR-TYPE-TUNER`:
357
358 - ``CEC_LOG_ADDR_TYPE_TUNER``
359
360 - 2
361
362 - Use for a tuner device.
363 276
364 - .. _`CEC-LOG-ADDR-TYPE-PLAYBACK`: 277 - ``CEC_LOG_ADDR_TYPE_RECORD``
278 - 1
279 - Use for a recording device.
280 * .. _`CEC-LOG-ADDR-TYPE-TUNER`:
365 281
366 - ``CEC_LOG_ADDR_TYPE_PLAYBACK`` 282 - ``CEC_LOG_ADDR_TYPE_TUNER``
283 - 2
284 - Use for a tuner device.
285 * .. _`CEC-LOG-ADDR-TYPE-PLAYBACK`:
367 286
368 - 3 287 - ``CEC_LOG_ADDR_TYPE_PLAYBACK``
288 - 3
289 - Use for a playback device.
290 * .. _`CEC-LOG-ADDR-TYPE-AUDIOSYSTEM`:
369 291
370 - Use for a playback device. 292 - ``CEC_LOG_ADDR_TYPE_AUDIOSYSTEM``
293 - 4
294 - Use for an audio system device.
295 * .. _`CEC-LOG-ADDR-TYPE-SPECIFIC`:
371 296
372 - .. _`CEC-LOG-ADDR-TYPE-AUDIOSYSTEM`: 297 - ``CEC_LOG_ADDR_TYPE_SPECIFIC``
298 - 5
299 - Use for a second TV or for a video processor device.
300 * .. _`CEC-LOG-ADDR-TYPE-UNREGISTERED`:
373 301
374 - ``CEC_LOG_ADDR_TYPE_AUDIOSYSTEM`` 302 - ``CEC_LOG_ADDR_TYPE_UNREGISTERED``
375 303 - 6
376 - 4 304 - Use this if you just want to remain unregistered. Used for pure
377 305 CEC switches or CDC-only devices (CDC: Capability Discovery and
378 - Use for an audio system device. 306 Control).
379
380 - .. _`CEC-LOG-ADDR-TYPE-SPECIFIC`:
381
382 - ``CEC_LOG_ADDR_TYPE_SPECIFIC``
383
384 - 5
385
386 - Use for a second TV or for a video processor device.
387
388 - .. _`CEC-LOG-ADDR-TYPE-UNREGISTERED`:
389
390 - ``CEC_LOG_ADDR_TYPE_UNREGISTERED``
391
392 - 6
393
394 - Use this if you just want to remain unregistered. Used for pure
395 CEC switches or CDC-only devices (CDC: Capability Discovery and
396 Control).
397 307
398 308
399 309
@@ -406,54 +316,36 @@ logical address types are already defined will return with error ``EBUSY``.
406 :stub-columns: 0 316 :stub-columns: 0
407 :widths: 3 1 4 317 :widths: 3 1 4
408 318
319 * .. _`CEC-OP-ALL-DEVTYPE-TV`:
409 320
410 - .. _`CEC-OP-ALL-DEVTYPE-TV`: 321 - ``CEC_OP_ALL_DEVTYPE_TV``
411 322 - 0x80
412 - ``CEC_OP_ALL_DEVTYPE_TV`` 323 - This supports the TV type.
413 324 * .. _`CEC-OP-ALL-DEVTYPE-RECORD`:
414 - 0x80
415
416 - This supports the TV type.
417
418 - .. _`CEC-OP-ALL-DEVTYPE-RECORD`:
419
420 - ``CEC_OP_ALL_DEVTYPE_RECORD``
421
422 - 0x40
423
424 - This supports the Recording type.
425
426 - .. _`CEC-OP-ALL-DEVTYPE-TUNER`:
427
428 - ``CEC_OP_ALL_DEVTYPE_TUNER``
429
430 - 0x20
431
432 - This supports the Tuner type.
433
434 - .. _`CEC-OP-ALL-DEVTYPE-PLAYBACK`:
435
436 - ``CEC_OP_ALL_DEVTYPE_PLAYBACK``
437
438 - 0x10
439
440 - This supports the Playback type.
441
442 - .. _`CEC-OP-ALL-DEVTYPE-AUDIOSYSTEM`:
443
444 - ``CEC_OP_ALL_DEVTYPE_AUDIOSYSTEM``
445
446 - 0x08
447 325
448 - This supports the Audio System type. 326 - ``CEC_OP_ALL_DEVTYPE_RECORD``
327 - 0x40
328 - This supports the Recording type.
329 * .. _`CEC-OP-ALL-DEVTYPE-TUNER`:
449 330
450 - .. _`CEC-OP-ALL-DEVTYPE-SWITCH`: 331 - ``CEC_OP_ALL_DEVTYPE_TUNER``
332 - 0x20
333 - This supports the Tuner type.
334 * .. _`CEC-OP-ALL-DEVTYPE-PLAYBACK`:
451 335
452 - ``CEC_OP_ALL_DEVTYPE_SWITCH`` 336 - ``CEC_OP_ALL_DEVTYPE_PLAYBACK``
337 - 0x10
338 - This supports the Playback type.
339 * .. _`CEC-OP-ALL-DEVTYPE-AUDIOSYSTEM`:
453 340
454 - 0x04 341 - ``CEC_OP_ALL_DEVTYPE_AUDIOSYSTEM``
342 - 0x08
343 - This supports the Audio System type.
344 * .. _`CEC-OP-ALL-DEVTYPE-SWITCH`:
455 345
456 - This supports the CEC Switch or Video Processing type. 346 - ``CEC_OP_ALL_DEVTYPE_SWITCH``
347 - 0x04
348 - This supports the CEC Switch or Video Processing type.
457 349
458 350
459 351
diff --git a/Documentation/media/uapi/cec/cec-ioc-dqevent.rst b/Documentation/media/uapi/cec/cec-ioc-dqevent.rst
index e283588a830b..e256c6605de7 100644
--- a/Documentation/media/uapi/cec/cec-ioc-dqevent.rst
+++ b/Documentation/media/uapi/cec/cec-ioc-dqevent.rst
@@ -58,26 +58,16 @@ it is guaranteed that the state did change in between the two events.
58 :stub-columns: 0 58 :stub-columns: 0
59 :widths: 1 1 8 59 :widths: 1 1 8
60 60
61 61 * - __u16
62 - .. row 1 62 - ``phys_addr``
63 63 - The current physical address. This is ``CEC_PHYS_ADDR_INVALID`` if no
64 - __u16
65
66 - ``phys_addr``
67
68 - The current physical address. This is ``CEC_PHYS_ADDR_INVALID`` if no
69 valid physical address is set. 64 valid physical address is set.
70 65 * - __u16
71 - .. row 2 66 - ``log_addr_mask``
72 67 - The current set of claimed logical addresses. This is 0 if no logical
73 - __u16 68 addresses are claimed or if ``phys_addr`` is ``CEC_PHYS_ADDR_INVALID``.
74 69 If bit 15 is set (``1 << CEC_LOG_ADDR_UNREGISTERED``) then this device
75 - ``log_addr_mask`` 70 has the unregistered logical address. In that case all other bits are 0.
76
77 - The current set of claimed logical addresses. This is 0 if no logical
78 addresses are claimed or if ``phys_addr`` is ``CEC_PHYS_ADDR_INVALID``.
79 If bit 15 is set (``1 << CEC_LOG_ADDR_UNREGISTERED``) then this device
80 has the unregistered logical address. In that case all other bits are 0.
81 71
82 72
83.. c:type:: cec_event_lost_msgs 73.. c:type:: cec_event_lost_msgs
@@ -89,22 +79,17 @@ it is guaranteed that the state did change in between the two events.
89 :stub-columns: 0 79 :stub-columns: 0
90 :widths: 1 1 16 80 :widths: 1 1 16
91 81
92 82 * - __u32
93 - .. row 1 83 - ``lost_msgs``
94 84 - Set to the number of lost messages since the filehandle was opened
95 - __u32 85 or since the last time this event was dequeued for this
96 86 filehandle. The messages lost are the oldest messages. So when a
97 - ``lost_msgs`` 87 new message arrives and there is no more room, then the oldest
98 88 message is discarded to make room for the new one. The internal
99 - Set to the number of lost messages since the filehandle was opened 89 size of the message queue guarantees that all messages received in
100 or since the last time this event was dequeued for this 90 the last two seconds will be stored. Since messages should be
101 filehandle. The messages lost are the oldest messages. So when a 91 replied to within a second according to the CEC specification,
102 new message arrives and there is no more room, then the oldest 92 this is more than enough.
103 message is discarded to make room for the new one. The internal
104 size of the message queue guarantees that all messages received in
105 the last two seconds will be stored. Since messages should be
106 replied to within a second according to the CEC specification,
107 this is more than enough.
108 93
109 94
110.. tabularcolumns:: |p{1.0cm}|p{4.2cm}|p{2.5cm}|p{8.8cm}| 95.. tabularcolumns:: |p{1.0cm}|p{4.2cm}|p{2.5cm}|p{8.8cm}|
@@ -116,62 +101,32 @@ it is guaranteed that the state did change in between the two events.
116 :stub-columns: 0 101 :stub-columns: 0
117 :widths: 1 1 1 8 102 :widths: 1 1 1 8
118 103
119 104 * - __u64
120 - .. row 1 105 - ``ts``
121 106 - :cspan:`1` Timestamp of the event in ns.
122 - __u64 107
123 108 The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock. To access
124 - ``ts`` 109 the same clock from userspace use :c:func:`clock_gettime`.
125 110 * - __u32
126 - :cspan:`1` Timestamp of the event in ns. 111 - ``event``
127 112 - :cspan:`1` The CEC event type, see :ref:`cec-events`.
128 The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock. To access 113 * - __u32
129 the same clock from userspace use :c:func:`clock_gettime`. 114 - ``flags``
130 115 - :cspan:`1` Event flags, see :ref:`cec-event-flags`.
131 - .. row 2 116 * - union
132 117 - (anonymous)
133 - __u32 118 -
134 119 -
135 - ``event`` 120 * -
136 121 - struct cec_event_state_change
137 - :cspan:`1` The CEC event type, see :ref:`cec-events`. 122 - ``state_change``
138 123 - The new adapter state as sent by the :ref:`CEC_EVENT_STATE_CHANGE <CEC-EVENT-STATE-CHANGE>`
139 - .. row 3 124 event.
140 125 * -
141 - __u32 126 - struct cec_event_lost_msgs
142 127 - ``lost_msgs``
143 - ``flags`` 128 - The number of lost messages as sent by the :ref:`CEC_EVENT_LOST_MSGS <CEC-EVENT-LOST-MSGS>`
144 129 event.
145 - :cspan:`1` Event flags, see :ref:`cec-event-flags`.
146
147 - .. row 4
148
149 - union
150
151 - (anonymous)
152
153 -
154 -
155
156 - .. row 5
157
158 -
159 - struct cec_event_state_change
160
161 - ``state_change``
162
163 - The new adapter state as sent by the :ref:`CEC_EVENT_STATE_CHANGE <CEC-EVENT-STATE-CHANGE>`
164 event.
165
166 - .. row 6
167
168 -
169 - struct cec_event_lost_msgs
170
171 - ``lost_msgs``
172
173 - The number of lost messages as sent by the :ref:`CEC_EVENT_LOST_MSGS <CEC-EVENT-LOST-MSGS>`
174 event.
175 130
176 131
177.. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{11.0cm}| 132.. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{11.0cm}|
@@ -183,25 +138,19 @@ it is guaranteed that the state did change in between the two events.
183 :stub-columns: 0 138 :stub-columns: 0
184 :widths: 3 1 16 139 :widths: 3 1 16
185 140
141 * .. _`CEC-EVENT-STATE-CHANGE`:
186 142
187 - .. _`CEC-EVENT-STATE-CHANGE`: 143 - ``CEC_EVENT_STATE_CHANGE``
188 144 - 1
189 - ``CEC_EVENT_STATE_CHANGE`` 145 - Generated when the CEC Adapter's state changes. When open() is
190 146 called an initial event will be generated for that filehandle with
191 - 1 147 the CEC Adapter's state at that time.
192 148 * .. _`CEC-EVENT-LOST-MSGS`:
193 - Generated when the CEC Adapter's state changes. When open() is
194 called an initial event will be generated for that filehandle with
195 the CEC Adapter's state at that time.
196
197 - .. _`CEC-EVENT-LOST-MSGS`:
198 149
199 - ``CEC_EVENT_LOST_MSGS`` 150 - ``CEC_EVENT_LOST_MSGS``
200 151 - 2
201 - 2 152 - Generated if one or more CEC messages were lost because the
202 153 application didn't dequeue CEC messages fast enough.
203 - Generated if one or more CEC messages were lost because the
204 application didn't dequeue CEC messages fast enough.
205 154
206 155
207.. tabularcolumns:: |p{6.0cm}|p{0.6cm}|p{10.9cm}| 156.. tabularcolumns:: |p{6.0cm}|p{0.6cm}|p{10.9cm}|
@@ -213,17 +162,14 @@ it is guaranteed that the state did change in between the two events.
213 :stub-columns: 0 162 :stub-columns: 0
214 :widths: 3 1 8 163 :widths: 3 1 8
215 164
165 * .. _`CEC-EVENT-FL-INITIAL-VALUE`:
216 166
217 - .. _`CEC-EVENT-FL-INITIAL-VALUE`: 167 - ``CEC_EVENT_FL_INITIAL_VALUE``
218 168 - 1
219 - ``CEC_EVENT_FL_INITIAL_VALUE`` 169 - Set for the initial events that are generated when the device is
220 170 opened. See the table above for which events do this. This allows
221 - 1 171 applications to learn the initial state of the CEC adapter at
222 172 open() time.
223 - Set for the initial events that are generated when the device is
224 opened. See the table above for which events do this. This allows
225 applications to learn the initial state of the CEC adapter at
226 open() time.
227 173
228 174
229 175
diff --git a/Documentation/media/uapi/cec/cec-ioc-g-mode.rst b/Documentation/media/uapi/cec/cec-ioc-g-mode.rst
index 70a41902ab58..4f5818b9d277 100644
--- a/Documentation/media/uapi/cec/cec-ioc-g-mode.rst
+++ b/Documentation/media/uapi/cec/cec-ioc-g-mode.rst
@@ -83,37 +83,28 @@ Available initiator modes are:
83 :stub-columns: 0 83 :stub-columns: 0
84 :widths: 3 1 16 84 :widths: 3 1 16
85 85
86 86 * .. _`CEC-MODE-NO-INITIATOR`:
87 - .. _`CEC-MODE-NO-INITIATOR`: 87
88 88 - ``CEC_MODE_NO_INITIATOR``
89 - ``CEC_MODE_NO_INITIATOR`` 89 - 0x0
90 90 - This is not an initiator, i.e. it cannot transmit CEC messages or
91 - 0x0 91 make any other changes to the CEC adapter.
92 92 * .. _`CEC-MODE-INITIATOR`:
93 - This is not an initiator, i.e. it cannot transmit CEC messages or 93
94 make any other changes to the CEC adapter. 94 - ``CEC_MODE_INITIATOR``
95 95 - 0x1
96 - .. _`CEC-MODE-INITIATOR`: 96 - This is an initiator (the default when the device is opened) and
97 97 it can transmit CEC messages and make changes to the CEC adapter,
98 - ``CEC_MODE_INITIATOR`` 98 unless there is an exclusive initiator.
99 99 * .. _`CEC-MODE-EXCL-INITIATOR`:
100 - 0x1 100
101 101 - ``CEC_MODE_EXCL_INITIATOR``
102 - This is an initiator (the default when the device is opened) and 102 - 0x2
103 it can transmit CEC messages and make changes to the CEC adapter, 103 - This is an exclusive initiator and this file descriptor is the
104 unless there is an exclusive initiator. 104 only one that can transmit CEC messages and make changes to the
105 105 CEC adapter. If someone else is already the exclusive initiator
106 - .. _`CEC-MODE-EXCL-INITIATOR`: 106 then an attempt to become one will return the ``EBUSY`` error code
107 107 error.
108 - ``CEC_MODE_EXCL_INITIATOR``
109
110 - 0x2
111
112 - This is an exclusive initiator and this file descriptor is the
113 only one that can transmit CEC messages and make changes to the
114 CEC adapter. If someone else is already the exclusive initiator
115 then an attempt to become one will return the ``EBUSY`` error code
116 error.
117 108
118 109
119Available follower modes are: 110Available follower modes are:
@@ -127,86 +118,68 @@ Available follower modes are:
127 :stub-columns: 0 118 :stub-columns: 0
128 :widths: 3 1 16 119 :widths: 3 1 16
129 120
130 121 * .. _`CEC-MODE-NO-FOLLOWER`:
131 - .. _`CEC-MODE-NO-FOLLOWER`: 122
132 123 - ``CEC_MODE_NO_FOLLOWER``
133 - ``CEC_MODE_NO_FOLLOWER`` 124 - 0x00
134 125 - This is not a follower (the default when the device is opened).
135 - 0x00 126 * .. _`CEC-MODE-FOLLOWER`:
136 127
137 - This is not a follower (the default when the device is opened). 128 - ``CEC_MODE_FOLLOWER``
138 129 - 0x10
139 - .. _`CEC-MODE-FOLLOWER`: 130 - This is a follower and it will receive CEC messages unless there
140 131 is an exclusive follower. You cannot become a follower if
141 - ``CEC_MODE_FOLLOWER`` 132 :ref:`CEC_CAP_TRANSMIT <CEC-CAP-TRANSMIT>` is not set or if :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>`
142 133 was specified, the ``EINVAL`` error code is returned in that case.
143 - 0x10 134 * .. _`CEC-MODE-EXCL-FOLLOWER`:
144 135
145 - This is a follower and it will receive CEC messages unless there 136 - ``CEC_MODE_EXCL_FOLLOWER``
146 is an exclusive follower. You cannot become a follower if 137 - 0x20
147 :ref:`CEC_CAP_TRANSMIT <CEC-CAP-TRANSMIT>` is not set or if :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>` 138 - This is an exclusive follower and only this file descriptor will
148 was specified, the ``EINVAL`` error code is returned in that case. 139 receive CEC messages for processing. If someone else is already
149 140 the exclusive follower then an attempt to become one will return
150 - .. _`CEC-MODE-EXCL-FOLLOWER`: 141 the ``EBUSY`` error code. You cannot become a follower if
151 142 :ref:`CEC_CAP_TRANSMIT <CEC-CAP-TRANSMIT>` is not set or if :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>`
152 - ``CEC_MODE_EXCL_FOLLOWER`` 143 was specified, the ``EINVAL`` error code is returned in that case.
153 144 * .. _`CEC-MODE-EXCL-FOLLOWER-PASSTHRU`:
154 - 0x20 145
155 146 - ``CEC_MODE_EXCL_FOLLOWER_PASSTHRU``
156 - This is an exclusive follower and only this file descriptor will 147 - 0x30
157 receive CEC messages for processing. If someone else is already 148 - This is an exclusive follower and only this file descriptor will
158 the exclusive follower then an attempt to become one will return 149 receive CEC messages for processing. In addition it will put the
159 the ``EBUSY`` error code. You cannot become a follower if 150 CEC device into passthrough mode, allowing the exclusive follower
160 :ref:`CEC_CAP_TRANSMIT <CEC-CAP-TRANSMIT>` is not set or if :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>` 151 to handle most core messages instead of relying on the CEC
161 was specified, the ``EINVAL`` error code is returned in that case. 152 framework for that. If someone else is already the exclusive
162 153 follower then an attempt to become one will return the ``EBUSY`` error
163 - .. _`CEC-MODE-EXCL-FOLLOWER-PASSTHRU`: 154 code. You cannot become a follower if :ref:`CEC_CAP_TRANSMIT <CEC-CAP-TRANSMIT>`
164 155 is not set or if :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>` was specified,
165 - ``CEC_MODE_EXCL_FOLLOWER_PASSTHRU`` 156 the ``EINVAL`` error code is returned in that case.
166 157 * .. _`CEC-MODE-MONITOR`:
167 - 0x30 158
168 159 - ``CEC_MODE_MONITOR``
169 - This is an exclusive follower and only this file descriptor will 160 - 0xe0
170 receive CEC messages for processing. In addition it will put the 161 - Put the file descriptor into monitor mode. Can only be used in
171 CEC device into passthrough mode, allowing the exclusive follower 162 combination with :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>`, otherwise EINVAL error
172 to handle most core messages instead of relying on the CEC 163 code will be returned. In monitor mode all messages this CEC
173 framework for that. If someone else is already the exclusive 164 device transmits and all messages it receives (both broadcast
174 follower then an attempt to become one will return the ``EBUSY`` error 165 messages and directed messages for one its logical addresses) will
175 code. You cannot become a follower if :ref:`CEC_CAP_TRANSMIT <CEC-CAP-TRANSMIT>` 166 be reported. This is very useful for debugging. This is only
176 is not set or if :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>` was specified, 167 allowed if the process has the ``CAP_NET_ADMIN`` capability. If
177 the ``EINVAL`` error code is returned in that case. 168 that is not set, then the ``EPERM`` error code is returned.
178 169 * .. _`CEC-MODE-MONITOR-ALL`:
179 - .. _`CEC-MODE-MONITOR`: 170
180 171 - ``CEC_MODE_MONITOR_ALL``
181 - ``CEC_MODE_MONITOR`` 172 - 0xf0
182 173 - Put the file descriptor into 'monitor all' mode. Can only be used
183 - 0xe0 174 in combination with :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>`, otherwise
184 175 the ``EINVAL`` error code will be returned. In 'monitor all' mode all messages
185 - Put the file descriptor into monitor mode. Can only be used in 176 this CEC device transmits and all messages it receives, including
186 combination with :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>`, otherwise EINVAL error 177 directed messages for other CEC devices will be reported. This is
187 code will be returned. In monitor mode all messages this CEC 178 very useful for debugging, but not all devices support this. This
188 device transmits and all messages it receives (both broadcast 179 mode requires that the :ref:`CEC_CAP_MONITOR_ALL <CEC-CAP-MONITOR-ALL>` capability is set,
189 messages and directed messages for one its logical addresses) will 180 otherwise the ``EINVAL`` error code is returned. This is only allowed if
190 be reported. This is very useful for debugging. This is only 181 the process has the ``CAP_NET_ADMIN`` capability. If that is not
191 allowed if the process has the ``CAP_NET_ADMIN`` capability. If 182 set, then the ``EPERM`` error code is returned.
192 that is not set, then the ``EPERM`` error code is returned.
193
194 - .. _`CEC-MODE-MONITOR-ALL`:
195
196 - ``CEC_MODE_MONITOR_ALL``
197
198 - 0xf0
199
200 - Put the file descriptor into 'monitor all' mode. Can only be used
201 in combination with :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>`, otherwise
202 the ``EINVAL`` error code will be returned. In 'monitor all' mode all messages
203 this CEC device transmits and all messages it receives, including
204 directed messages for other CEC devices will be reported. This is
205 very useful for debugging, but not all devices support this. This
206 mode requires that the :ref:`CEC_CAP_MONITOR_ALL <CEC-CAP-MONITOR-ALL>` capability is set,
207 otherwise the ``EINVAL`` error code is returned. This is only allowed if
208 the process has the ``CAP_NET_ADMIN`` capability. If that is not
209 set, then the ``EPERM`` error code is returned.
210 183
211 184
212Core message processing details: 185Core message processing details:
@@ -220,76 +193,58 @@ Core message processing details:
220 :stub-columns: 0 193 :stub-columns: 0
221 :widths: 1 8 194 :widths: 1 8
222 195
223 196 * .. _`CEC-MSG-GET-CEC-VERSION`:
224 - .. _`CEC-MSG-GET-CEC-VERSION`: 197
225 198 - ``CEC_MSG_GET_CEC_VERSION``
226 - ``CEC_MSG_GET_CEC_VERSION`` 199 - When in passthrough mode this message has to be handled by
227 200 userspace, otherwise the core will return the CEC version that was
228 - When in passthrough mode this message has to be handled by 201 set with :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`.
229 userspace, otherwise the core will return the CEC version that was 202 * .. _`CEC-MSG-GIVE-DEVICE-VENDOR-ID`:
230 set with :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`. 203
231 204 - ``CEC_MSG_GIVE_DEVICE_VENDOR_ID``
232 - .. _`CEC-MSG-GIVE-DEVICE-VENDOR-ID`: 205 - When in passthrough mode this message has to be handled by
233 206 userspace, otherwise the core will return the vendor ID that was
234 - ``CEC_MSG_GIVE_DEVICE_VENDOR_ID`` 207 set with :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`.
235 208 * .. _`CEC-MSG-ABORT`:
236 - When in passthrough mode this message has to be handled by 209
237 userspace, otherwise the core will return the vendor ID that was 210 - ``CEC_MSG_ABORT``
238 set with :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`. 211 - When in passthrough mode this message has to be handled by
239 212 userspace, otherwise the core will return a feature refused
240 - .. _`CEC-MSG-ABORT`: 213 message as per the specification.
241 214 * .. _`CEC-MSG-GIVE-PHYSICAL-ADDR`:
242 - ``CEC_MSG_ABORT`` 215
243 216 - ``CEC_MSG_GIVE_PHYSICAL_ADDR``
244 - When in passthrough mode this message has to be handled by 217 - When in passthrough mode this message has to be handled by
245 userspace, otherwise the core will return a feature refused 218 userspace, otherwise the core will report the current physical
246 message as per the specification. 219 address.
247 220 * .. _`CEC-MSG-GIVE-OSD-NAME`:
248 - .. _`CEC-MSG-GIVE-PHYSICAL-ADDR`: 221
249 222 - ``CEC_MSG_GIVE_OSD_NAME``
250 - ``CEC_MSG_GIVE_PHYSICAL_ADDR`` 223 - When in passthrough mode this message has to be handled by
251 224 userspace, otherwise the core will report the current OSD name as
252 - When in passthrough mode this message has to be handled by 225 was set with :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`.
253 userspace, otherwise the core will report the current physical 226 * .. _`CEC-MSG-GIVE-FEATURES`:
254 address. 227
255 228 - ``CEC_MSG_GIVE_FEATURES``
256 - .. _`CEC-MSG-GIVE-OSD-NAME`: 229 - When in passthrough mode this message has to be handled by
257 230 userspace, otherwise the core will report the current features as
258 - ``CEC_MSG_GIVE_OSD_NAME`` 231 was set with :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`
259 232 or the message is ignored if the CEC version was older than 2.0.
260 - When in passthrough mode this message has to be handled by 233 * .. _`CEC-MSG-USER-CONTROL-PRESSED`:
261 userspace, otherwise the core will report the current OSD name as 234
262 was set with :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`. 235 - ``CEC_MSG_USER_CONTROL_PRESSED``
263 236 - If :ref:`CEC_CAP_RC <CEC-CAP-RC>` is set, then generate a remote control key
264 - .. _`CEC-MSG-GIVE-FEATURES`: 237 press. This message is always passed on to userspace.
265 238 * .. _`CEC-MSG-USER-CONTROL-RELEASED`:
266 - ``CEC_MSG_GIVE_FEATURES`` 239
267 240 - ``CEC_MSG_USER_CONTROL_RELEASED``
268 - When in passthrough mode this message has to be handled by 241 - If :ref:`CEC_CAP_RC <CEC-CAP-RC>` is set, then generate a remote control key
269 userspace, otherwise the core will report the current features as 242 release. This message is always passed on to userspace.
270 was set with :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>` 243 * .. _`CEC-MSG-REPORT-PHYSICAL-ADDR`:
271 or the message is ignored if the CEC version was older than 2.0. 244
272 245 - ``CEC_MSG_REPORT_PHYSICAL_ADDR``
273 - .. _`CEC-MSG-USER-CONTROL-PRESSED`: 246 - The CEC framework will make note of the reported physical address
274 247 and then just pass the message on to userspace.
275 - ``CEC_MSG_USER_CONTROL_PRESSED``
276
277 - If :ref:`CEC_CAP_RC <CEC-CAP-RC>` is set, then generate a remote control key
278 press. This message is always passed on to userspace.
279
280 - .. _`CEC-MSG-USER-CONTROL-RELEASED`:
281
282 - ``CEC_MSG_USER_CONTROL_RELEASED``
283
284 - If :ref:`CEC_CAP_RC <CEC-CAP-RC>` is set, then generate a remote control key
285 release. This message is always passed on to userspace.
286
287 - .. _`CEC-MSG-REPORT-PHYSICAL-ADDR`:
288
289 - ``CEC_MSG_REPORT_PHYSICAL_ADDR``
290
291 - The CEC framework will make note of the reported physical address
292 and then just pass the message on to userspace.
293 248
294 249
295 250
diff --git a/Documentation/media/uapi/cec/cec-ioc-receive.rst b/Documentation/media/uapi/cec/cec-ioc-receive.rst
index d585b1bba6ac..bdf015b1d1dc 100644
--- a/Documentation/media/uapi/cec/cec-ioc-receive.rst
+++ b/Documentation/media/uapi/cec/cec-ioc-receive.rst
@@ -86,173 +86,126 @@ result.
86 :stub-columns: 0 86 :stub-columns: 0
87 :widths: 1 1 16 87 :widths: 1 1 16
88 88
89 * - __u64
90 - ``tx_ts``
91 - Timestamp in ns of when the last byte of the message was transmitted.
92 The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock. To access
93 the same clock from userspace use :c:func:`clock_gettime`.
94 * - __u64
95 - ``rx_ts``
96 - Timestamp in ns of when the last byte of the message was received.
97 The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock. To access
98 the same clock from userspace use :c:func:`clock_gettime`.
99 * - __u32
100 - ``len``
101 - The length of the message. For :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` this is filled in
102 by the application. The driver will fill this in for
103 :ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`. For :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` it will be
104 filled in by the driver with the length of the reply message if ``reply`` was set.
105 * - __u32
106 - ``timeout``
107 - The timeout in milliseconds. This is the time the device will wait
108 for a message to be received before timing out. If it is set to 0,
109 then it will wait indefinitely when it is called by :ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`.
110 If it is 0 and it is called by :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>`,
111 then it will be replaced by 1000 if the ``reply`` is non-zero or
112 ignored if ``reply`` is 0.
113 * - __u32
114 - ``sequence``
115 - A non-zero sequence number is automatically assigned by the CEC framework
116 for all transmitted messages. It is used by the CEC framework when it queues
117 the transmit result (when transmit was called in non-blocking mode). This
118 allows the application to associate the received message with the original
119 transmit.
120 * - __u32
121 - ``flags``
122 - Flags. See :ref:`cec-msg-flags` for a list of available flags.
123 * - __u8
124 - ``tx_status``
125 - The status bits of the transmitted message. See
126 :ref:`cec-tx-status` for the possible status values. It is 0 if
127 this messages was received, not transmitted.
128 * - __u8
129 - ``msg[16]``
130 - The message payload. For :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` this is filled in by the
131 application. The driver will fill this in for :ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`.
132 For :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` it will be filled in by the driver with
133 the payload of the reply message if ``timeout`` was set.
134 * - __u8
135 - ``reply``
136 - Wait until this message is replied. If ``reply`` is 0 and the
137 ``timeout`` is 0, then don't wait for a reply but return after
138 transmitting the message. Ignored by :ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`.
139 The case where ``reply`` is 0 (this is the opcode for the Feature Abort
140 message) and ``timeout`` is non-zero is specifically allowed to make it
141 possible to send a message and wait up to ``timeout`` milliseconds for a
142 Feature Abort reply. In this case ``rx_status`` will either be set
143 to :ref:`CEC_RX_STATUS_TIMEOUT <CEC-RX-STATUS-TIMEOUT>` or
144 :ref:`CEC_RX_STATUS_FEATURE_ABORT <CEC-RX-STATUS-FEATURE-ABORT>`.
145
146 If the transmitter message is ``CEC_MSG_INITIATE_ARC`` then the ``reply``
147 values ``CEC_MSG_REPORT_ARC_INITIATED`` and ``CEC_MSG_REPORT_ARC_TERMINATED``
148 are processed differently: either value will match both possible replies.
149 The reason is that the ``CEC_MSG_INITIATE_ARC`` message is the only CEC
150 message that has two possible replies other than Feature Abort. The
151 ``reply`` field will be updated with the actual reply so that it is
152 synchronized with the contents of the received message.
153 * - __u8
154 - ``rx_status``
155 - The status bits of the received message. See
156 :ref:`cec-rx-status` for the possible status values. It is 0 if
157 this message was transmitted, not received, unless this is the
158 reply to a transmitted message. In that case both ``rx_status``
159 and ``tx_status`` are set.
160 * - __u8
161 - ``tx_status``
162 - The status bits of the transmitted message. See
163 :ref:`cec-tx-status` for the possible status values. It is 0 if
164 this messages was received, not transmitted.
165 * - __u8
166 - ``tx_arb_lost_cnt``
167 - A counter of the number of transmit attempts that resulted in the
168 Arbitration Lost error. This is only set if the hardware supports
169 this, otherwise it is always 0. This counter is only valid if the
170 :ref:`CEC_TX_STATUS_ARB_LOST <CEC-TX-STATUS-ARB-LOST>` status bit is set.
171 * - __u8
172 - ``tx_nack_cnt``
173 - A counter of the number of transmit attempts that resulted in the
174 Not Acknowledged error. This is only set if the hardware supports
175 this, otherwise it is always 0. This counter is only valid if the
176 :ref:`CEC_TX_STATUS_NACK <CEC-TX-STATUS-NACK>` status bit is set.
177 * - __u8
178 - ``tx_low_drive_cnt``
179 - A counter of the number of transmit attempts that resulted in the
180 Arbitration Lost error. This is only set if the hardware supports
181 this, otherwise it is always 0. This counter is only valid if the
182 :ref:`CEC_TX_STATUS_LOW_DRIVE <CEC-TX-STATUS-LOW-DRIVE>` status bit is set.
183 * - __u8
184 - ``tx_error_cnt``
185 - A counter of the number of transmit errors other than Arbitration
186 Lost or Not Acknowledged. This is only set if the hardware
187 supports this, otherwise it is always 0. This counter is only
188 valid if the :ref:`CEC_TX_STATUS_ERROR <CEC-TX-STATUS-ERROR>` status bit is set.
189
190
191.. _cec-msg-flags:
192
193.. flat-table:: Flags for struct cec_msg
194 :header-rows: 0
195 :stub-columns: 0
196 :widths: 3 1 4
89 197
90 - .. row 1 198 * .. _`CEC-MSG-FL-REPLY-TO-FOLLOWERS`:
91
92 - __u64
93
94 - ``tx_ts``
95
96 - Timestamp in ns of when the last byte of the message was transmitted.
97 The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock. To access
98 the same clock from userspace use :c:func:`clock_gettime`.
99
100 - .. row 2
101
102 - __u64
103
104 - ``rx_ts``
105
106 - Timestamp in ns of when the last byte of the message was received.
107 The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock. To access
108 the same clock from userspace use :c:func:`clock_gettime`.
109
110 - .. row 3
111
112 - __u32
113
114 - ``len``
115
116 - The length of the message. For :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` this is filled in
117 by the application. The driver will fill this in for
118 :ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`. For :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` it will be
119 filled in by the driver with the length of the reply message if ``reply`` was set.
120
121 - .. row 4
122
123 - __u32
124
125 - ``timeout``
126
127 - The timeout in milliseconds. This is the time the device will wait
128 for a message to be received before timing out. If it is set to 0,
129 then it will wait indefinitely when it is called by :ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`.
130 If it is 0 and it is called by :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>`,
131 then it will be replaced by 1000 if the ``reply`` is non-zero or
132 ignored if ``reply`` is 0.
133
134 - .. row 5
135
136 - __u32
137
138 - ``sequence``
139
140 - A non-zero sequence number is automatically assigned by the CEC framework
141 for all transmitted messages. It is used by the CEC framework when it queues
142 the transmit result (when transmit was called in non-blocking mode). This
143 allows the application to associate the received message with the original
144 transmit.
145
146 - .. row 6
147
148 - __u32
149
150 - ``flags``
151
152 - Flags. No flags are defined yet, so set this to 0.
153
154 - .. row 7
155
156 - __u8
157
158 - ``tx_status``
159
160 - The status bits of the transmitted message. See
161 :ref:`cec-tx-status` for the possible status values. It is 0 if
162 this messages was received, not transmitted.
163
164 - .. row 8
165
166 - __u8
167
168 - ``msg[16]``
169
170 - The message payload. For :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` this is filled in by the
171 application. The driver will fill this in for :ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`.
172 For :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` it will be filled in by the driver with
173 the payload of the reply message if ``timeout`` was set.
174
175 - .. row 8
176
177 - __u8
178
179 - ``reply``
180
181 - Wait until this message is replied. If ``reply`` is 0 and the
182 ``timeout`` is 0, then don't wait for a reply but return after
183 transmitting the message. Ignored by :ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`.
184 The case where ``reply`` is 0 (this is the opcode for the Feature Abort
185 message) and ``timeout`` is non-zero is specifically allowed to make it
186 possible to send a message and wait up to ``timeout`` milliseconds for a
187 Feature Abort reply. In this case ``rx_status`` will either be set
188 to :ref:`CEC_RX_STATUS_TIMEOUT <CEC-RX-STATUS-TIMEOUT>` or
189 :ref:`CEC_RX_STATUS_FEATURE_ABORT <CEC-RX-STATUS-FEATURE-ABORT>`.
190
191 - .. row 9
192
193 - __u8
194
195 - ``rx_status``
196
197 - The status bits of the received message. See
198 :ref:`cec-rx-status` for the possible status values. It is 0 if
199 this message was transmitted, not received, unless this is the
200 reply to a transmitted message. In that case both ``rx_status``
201 and ``tx_status`` are set.
202
203 - .. row 10
204
205 - __u8
206
207 - ``tx_status``
208
209 - The status bits of the transmitted message. See
210 :ref:`cec-tx-status` for the possible status values. It is 0 if
211 this messages was received, not transmitted.
212
213 - .. row 11
214
215 - __u8
216
217 - ``tx_arb_lost_cnt``
218
219 - A counter of the number of transmit attempts that resulted in the
220 Arbitration Lost error. This is only set if the hardware supports
221 this, otherwise it is always 0. This counter is only valid if the
222 :ref:`CEC_TX_STATUS_ARB_LOST <CEC-TX-STATUS-ARB-LOST>` status bit is set.
223
224 - .. row 12
225
226 - __u8
227
228 - ``tx_nack_cnt``
229
230 - A counter of the number of transmit attempts that resulted in the
231 Not Acknowledged error. This is only set if the hardware supports
232 this, otherwise it is always 0. This counter is only valid if the
233 :ref:`CEC_TX_STATUS_NACK <CEC-TX-STATUS-NACK>` status bit is set.
234
235 - .. row 13
236
237 - __u8
238
239 - ``tx_low_drive_cnt``
240
241 - A counter of the number of transmit attempts that resulted in the
242 Arbitration Lost error. This is only set if the hardware supports
243 this, otherwise it is always 0. This counter is only valid if the
244 :ref:`CEC_TX_STATUS_LOW_DRIVE <CEC-TX-STATUS-LOW-DRIVE>` status bit is set.
245
246 - .. row 14
247
248 - __u8
249
250 - ``tx_error_cnt``
251 199
252 - A counter of the number of transmit errors other than Arbitration 200 - ``CEC_MSG_FL_REPLY_TO_FOLLOWERS``
253 Lost or Not Acknowledged. This is only set if the hardware 201 - 1
254 supports this, otherwise it is always 0. This counter is only 202 - If a CEC transmit expects a reply, then by default that reply is only sent to
255 valid if the :ref:`CEC_TX_STATUS_ERROR <CEC-TX-STATUS-ERROR>` status bit is set. 203 the filehandle that called :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>`. If this
204 flag is set, then the reply is also sent to all followers, if any. If the
205 filehandle that called :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` is also a
206 follower, then that filehandle will receive the reply twice: once as the
207 result of the :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>`, and once via
208 :ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`.
256 209
257 210
258.. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{11.0cm}| 211.. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{11.0cm}|
@@ -264,64 +217,46 @@ result.
264 :stub-columns: 0 217 :stub-columns: 0
265 :widths: 3 1 16 218 :widths: 3 1 16
266 219
267 220 * .. _`CEC-TX-STATUS-OK`:
268 - .. _`CEC-TX-STATUS-OK`: 221
269 222 - ``CEC_TX_STATUS_OK``
270 - ``CEC_TX_STATUS_OK`` 223 - 0x01
271 224 - The message was transmitted successfully. This is mutually
272 - 0x01 225 exclusive with :ref:`CEC_TX_STATUS_MAX_RETRIES <CEC-TX-STATUS-MAX-RETRIES>`. Other bits can still
273 226 be set if earlier attempts met with failure before the transmit
274 - The message was transmitted successfully. This is mutually 227 was eventually successful.
275 exclusive with :ref:`CEC_TX_STATUS_MAX_RETRIES <CEC-TX-STATUS-MAX-RETRIES>`. Other bits can still 228 * .. _`CEC-TX-STATUS-ARB-LOST`:
276 be set if earlier attempts met with failure before the transmit 229
277 was eventually successful. 230 - ``CEC_TX_STATUS_ARB_LOST``
278 231 - 0x02
279 - .. _`CEC-TX-STATUS-ARB-LOST`: 232 - CEC line arbitration was lost.
280 233 * .. _`CEC-TX-STATUS-NACK`:
281 - ``CEC_TX_STATUS_ARB_LOST`` 234
282 235 - ``CEC_TX_STATUS_NACK``
283 - 0x02 236 - 0x04
284 237 - Message was not acknowledged.
285 - CEC line arbitration was lost. 238 * .. _`CEC-TX-STATUS-LOW-DRIVE`:
286 239
287 - .. _`CEC-TX-STATUS-NACK`: 240 - ``CEC_TX_STATUS_LOW_DRIVE``
288 241 - 0x08
289 - ``CEC_TX_STATUS_NACK`` 242 - Low drive was detected on the CEC bus. This indicates that a
290 243 follower detected an error on the bus and requests a
291 - 0x04 244 retransmission.
292 245 * .. _`CEC-TX-STATUS-ERROR`:
293 - Message was not acknowledged. 246
294 247 - ``CEC_TX_STATUS_ERROR``
295 - .. _`CEC-TX-STATUS-LOW-DRIVE`: 248 - 0x10
296 249 - Some error occurred. This is used for any errors that do not fit
297 - ``CEC_TX_STATUS_LOW_DRIVE`` 250 the previous two, either because the hardware could not tell which
298 251 error occurred, or because the hardware tested for other
299 - 0x08 252 conditions besides those two.
300 253 * .. _`CEC-TX-STATUS-MAX-RETRIES`:
301 - Low drive was detected on the CEC bus. This indicates that a 254
302 follower detected an error on the bus and requests a 255 - ``CEC_TX_STATUS_MAX_RETRIES``
303 retransmission. 256 - 0x20
304 257 - The transmit failed after one or more retries. This status bit is
305 - .. _`CEC-TX-STATUS-ERROR`: 258 mutually exclusive with :ref:`CEC_TX_STATUS_OK <CEC-TX-STATUS-OK>`. Other bits can still
306 259 be set to explain which failures were seen.
307 - ``CEC_TX_STATUS_ERROR``
308
309 - 0x10
310
311 - Some error occurred. This is used for any errors that do not fit
312 the previous two, either because the hardware could not tell which
313 error occurred, or because the hardware tested for other
314 conditions besides those two.
315
316 - .. _`CEC-TX-STATUS-MAX-RETRIES`:
317
318 - ``CEC_TX_STATUS_MAX_RETRIES``
319
320 - 0x20
321
322 - The transmit failed after one or more retries. This status bit is
323 mutually exclusive with :ref:`CEC_TX_STATUS_OK <CEC-TX-STATUS-OK>`. Other bits can still
324 be set to explain which failures were seen.
325 260
326 261
327.. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{11.0cm}| 262.. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{11.0cm}|
@@ -333,32 +268,23 @@ result.
333 :stub-columns: 0 268 :stub-columns: 0
334 :widths: 3 1 16 269 :widths: 3 1 16
335 270
271 * .. _`CEC-RX-STATUS-OK`:
336 272
337 - .. _`CEC-RX-STATUS-OK`: 273 - ``CEC_RX_STATUS_OK``
338 274 - 0x01
339 - ``CEC_RX_STATUS_OK`` 275 - The message was received successfully.
340 276 * .. _`CEC-RX-STATUS-TIMEOUT`:
341 - 0x01
342
343 - The message was received successfully.
344
345 - .. _`CEC-RX-STATUS-TIMEOUT`:
346
347 - ``CEC_RX_STATUS_TIMEOUT``
348
349 - 0x02
350
351 - The reply to an earlier transmitted message timed out.
352
353 - .. _`CEC-RX-STATUS-FEATURE-ABORT`:
354
355 - ``CEC_RX_STATUS_FEATURE_ABORT``
356 277
357 - 0x04 278 - ``CEC_RX_STATUS_TIMEOUT``
279 - 0x02
280 - The reply to an earlier transmitted message timed out.
281 * .. _`CEC-RX-STATUS-FEATURE-ABORT`:
358 282
359 - The message was received successfully but the reply was 283 - ``CEC_RX_STATUS_FEATURE_ABORT``
360 ``CEC_MSG_FEATURE_ABORT``. This status is only set if this message 284 - 0x04
361 was the reply to an earlier transmitted message. 285 - The message was received successfully but the reply was
286 ``CEC_MSG_FEATURE_ABORT``. This status is only set if this message
287 was the reply to an earlier transmitted message.
362 288
363 289
364 290
diff --git a/Documentation/media/uapi/v4l/control.rst b/Documentation/media/uapi/v4l/control.rst
index d3f1450c4b08..51112badb804 100644
--- a/Documentation/media/uapi/v4l/control.rst
+++ b/Documentation/media/uapi/v4l/control.rst
@@ -312,21 +312,20 @@ more menu type controls.
312 312
313.. _enum_all_controls: 313.. _enum_all_controls:
314 314
315Example: Enumerating all user controls 315Example: Enumerating all controls
316====================================== 316=================================
317 317
318.. code-block:: c 318.. code-block:: c
319 319
320
321 struct v4l2_queryctrl queryctrl; 320 struct v4l2_queryctrl queryctrl;
322 struct v4l2_querymenu querymenu; 321 struct v4l2_querymenu querymenu;
323 322
324 static void enumerate_menu(void) 323 static void enumerate_menu(__u32 id)
325 { 324 {
326 printf(" Menu items:\\n"); 325 printf(" Menu items:\\n");
327 326
328 memset(&querymenu, 0, sizeof(querymenu)); 327 memset(&querymenu, 0, sizeof(querymenu));
329 querymenu.id = queryctrl.id; 328 querymenu.id = id;
330 329
331 for (querymenu.index = queryctrl.minimum; 330 for (querymenu.index = queryctrl.minimum;
332 querymenu.index <= queryctrl.maximum; 331 querymenu.index <= queryctrl.maximum;
@@ -339,6 +338,55 @@ Example: Enumerating all user controls
339 338
340 memset(&queryctrl, 0, sizeof(queryctrl)); 339 memset(&queryctrl, 0, sizeof(queryctrl));
341 340
341 queryctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL;
342 while (0 == ioctl(fd, VIDIOC_QUERYCTRL, &queryctrl)) {
343 if (!(queryctrl.flags & V4L2_CTRL_FLAG_DISABLED)) {
344 printf("Control %s\\n", queryctrl.name);
345
346 if (queryctrl.type == V4L2_CTRL_TYPE_MENU)
347 enumerate_menu(queryctrl.id);
348 }
349
350 queryctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL;
351 }
352 if (errno != EINVAL) {
353 perror("VIDIOC_QUERYCTRL");
354 exit(EXIT_FAILURE);
355 }
356
357Example: Enumerating all controls including compound controls
358=============================================================
359
360.. code-block:: c
361
362 struct v4l2_query_ext_ctrl query_ext_ctrl;
363
364 memset(&query_ext_ctrl, 0, sizeof(query_ext_ctrl));
365
366 query_ext_ctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL | V4L2_CTRL_FLAG_NEXT_COMPOUND;
367 while (0 == ioctl(fd, VIDIOC_QUERY_EXT_CTRL, &query_ext_ctrl)) {
368 if (!(query_ext_ctrl.flags & V4L2_CTRL_FLAG_DISABLED)) {
369 printf("Control %s\\n", query_ext_ctrl.name);
370
371 if (query_ext_ctrl.type == V4L2_CTRL_TYPE_MENU)
372 enumerate_menu(query_ext_ctrl.id);
373 }
374
375 query_ext_ctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL | V4L2_CTRL_FLAG_NEXT_COMPOUND;
376 }
377 if (errno != EINVAL) {
378 perror("VIDIOC_QUERY_EXT_CTRL");
379 exit(EXIT_FAILURE);
380 }
381
382Example: Enumerating all user controls (old style)
383==================================================
384
385.. code-block:: c
386
387
388 memset(&queryctrl, 0, sizeof(queryctrl));
389
342 for (queryctrl.id = V4L2_CID_BASE; 390 for (queryctrl.id = V4L2_CID_BASE;
343 queryctrl.id < V4L2_CID_LASTP1; 391 queryctrl.id < V4L2_CID_LASTP1;
344 queryctrl.id++) { 392 queryctrl.id++) {
@@ -349,7 +397,7 @@ Example: Enumerating all user controls
349 printf("Control %s\\n", queryctrl.name); 397 printf("Control %s\\n", queryctrl.name);
350 398
351 if (queryctrl.type == V4L2_CTRL_TYPE_MENU) 399 if (queryctrl.type == V4L2_CTRL_TYPE_MENU)
352 enumerate_menu(); 400 enumerate_menu(queryctrl.id);
353 } else { 401 } else {
354 if (errno == EINVAL) 402 if (errno == EINVAL)
355 continue; 403 continue;
@@ -368,7 +416,7 @@ Example: Enumerating all user controls
368 printf("Control %s\\n", queryctrl.name); 416 printf("Control %s\\n", queryctrl.name);
369 417
370 if (queryctrl.type == V4L2_CTRL_TYPE_MENU) 418 if (queryctrl.type == V4L2_CTRL_TYPE_MENU)
371 enumerate_menu(); 419 enumerate_menu(queryctrl.id);
372 } else { 420 } else {
373 if (errno == EINVAL) 421 if (errno == EINVAL)
374 break; 422 break;
@@ -379,32 +427,6 @@ Example: Enumerating all user controls
379 } 427 }
380 428
381 429
382Example: Enumerating all user controls (alternative)
383====================================================
384
385.. code-block:: c
386
387 memset(&queryctrl, 0, sizeof(queryctrl));
388
389 queryctrl.id = V4L2_CTRL_CLASS_USER | V4L2_CTRL_FLAG_NEXT_CTRL;
390 while (0 == ioctl(fd, VIDIOC_QUERYCTRL, &queryctrl)) {
391 if (V4L2_CTRL_ID2CLASS(queryctrl.id) != V4L2_CTRL_CLASS_USER)
392 break;
393 if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED)
394 continue;
395
396 printf("Control %s\\n", queryctrl.name);
397
398 if (queryctrl.type == V4L2_CTRL_TYPE_MENU)
399 enumerate_menu();
400
401 queryctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL;
402 }
403 if (errno != EINVAL) {
404 perror("VIDIOC_QUERYCTRL");
405 exit(EXIT_FAILURE);
406 }
407
408Example: Changing controls 430Example: Changing controls
409========================== 431==========================
410 432
diff --git a/Documentation/media/uapi/v4l/dev-codec.rst b/Documentation/media/uapi/v4l/dev-codec.rst
index d9f218449ddd..c61e938bd8dc 100644
--- a/Documentation/media/uapi/v4l/dev-codec.rst
+++ b/Documentation/media/uapi/v4l/dev-codec.rst
@@ -26,7 +26,7 @@ parameters
26 The MPEG controls actually support many more codecs than 26 The MPEG controls actually support many more codecs than
27 just MPEG. See :ref:`mpeg-controls`. 27 just MPEG. See :ref:`mpeg-controls`.
28 28
29Memory-to-memory devices can often be used as a shared resource: you can 29Memory-to-memory devices function as a shared resource: you can
30open the video node multiple times, each application setting up their 30open the video node multiple times, each application setting up their
31own codec properties that are local to the file handle, and each can use 31own codec properties that are local to the file handle, and each can use
32it independently from the others. The driver will arbitrate access to 32it independently from the others. The driver will arbitrate access to
diff --git a/Documentation/media/uapi/v4l/extended-controls.rst b/Documentation/media/uapi/v4l/extended-controls.rst
index 7725c33d8b69..abb105724c05 100644
--- a/Documentation/media/uapi/v4l/extended-controls.rst
+++ b/Documentation/media/uapi/v4l/extended-controls.rst
@@ -2846,7 +2846,7 @@ JPEG Control IDs
2846 input image is sampled, in respect to maximum sample rate in each 2846 input image is sampled, in respect to maximum sample rate in each
2847 spatial dimension. See :ref:`itu-t81`, clause A.1.1. for more 2847 spatial dimension. See :ref:`itu-t81`, clause A.1.1. for more
2848 details. The ``V4L2_CID_JPEG_CHROMA_SUBSAMPLING`` control determines 2848 details. The ``V4L2_CID_JPEG_CHROMA_SUBSAMPLING`` control determines
2849 how Cb and Cr components are downsampled after coverting an input 2849 how Cb and Cr components are downsampled after converting an input
2850 image from RGB to Y'CbCr color space. 2850 image from RGB to Y'CbCr color space.
2851 2851
2852.. tabularcolumns:: |p{7.0cm}|p{10.5cm}| 2852.. tabularcolumns:: |p{7.0cm}|p{10.5cm}|
@@ -3017,6 +3017,10 @@ Image Process Control IDs
3017 test pattern images. These hardware specific test patterns can be 3017 test pattern images. These hardware specific test patterns can be
3018 used to test if a device is working properly. 3018 used to test if a device is working properly.
3019 3019
3020``V4L2_CID_DEINTERLACING_MODE (menu)``
3021 The video deinterlacing mode (such as Bob, Weave, ...). The menu items are
3022 driver specific and are documented in :ref:`v4l-drivers`.
3023
3020 3024
3021.. _dv-controls: 3025.. _dv-controls:
3022 3026
diff --git a/Documentation/media/uapi/v4l/hsv-formats.rst b/Documentation/media/uapi/v4l/hsv-formats.rst
new file mode 100644
index 000000000000..f0f2615eaa95
--- /dev/null
+++ b/Documentation/media/uapi/v4l/hsv-formats.rst
@@ -0,0 +1,19 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3.. _hsv-formats:
4
5***********
6HSV Formats
7***********
8
9These formats store the color information of the image
10in a geometrical representation. The colors are mapped into a
11cylinder, where the angle is the HUE, the height is the VALUE
12and the distance to the center is the SATURATION. This is a very
13useful format for image segmentation algorithms.
14
15
16.. toctree::
17 :maxdepth: 1
18
19 pixfmt-packed-hsv
diff --git a/Documentation/media/uapi/v4l/pixfmt-002.rst b/Documentation/media/uapi/v4l/pixfmt-002.rst
index 0d9e697f5d4e..2ee164c25637 100644
--- a/Documentation/media/uapi/v4l/pixfmt-002.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-002.rst
@@ -121,6 +121,11 @@ Single-planar format structure
121 - This information supplements the ``colorspace`` and must be set by 121 - This information supplements the ``colorspace`` and must be set by
122 the driver for capture streams and by the application for output 122 the driver for capture streams and by the application for output
123 streams, see :ref:`colorspaces`. 123 streams, see :ref:`colorspaces`.
124 * - enum :c:type:`v4l2_hsv_encoding`
125 - ``hsv_enc``
126 - This information supplements the ``colorspace`` and must be set by
127 the driver for capture streams and by the application for output
128 streams, see :ref:`colorspaces`.
124 * - enum :c:type:`v4l2_quantization` 129 * - enum :c:type:`v4l2_quantization`
125 - ``quantization`` 130 - ``quantization``
126 - This information supplements the ``colorspace`` and must be set by 131 - This information supplements the ``colorspace`` and must be set by
diff --git a/Documentation/media/uapi/v4l/pixfmt-003.rst b/Documentation/media/uapi/v4l/pixfmt-003.rst
index ae9ea7a791de..337e8188caf1 100644
--- a/Documentation/media/uapi/v4l/pixfmt-003.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-003.rst
@@ -78,6 +78,11 @@ describing all planes of that format.
78 - This information supplements the ``colorspace`` and must be set by 78 - This information supplements the ``colorspace`` and must be set by
79 the driver for capture streams and by the application for output 79 the driver for capture streams and by the application for output
80 streams, see :ref:`colorspaces`. 80 streams, see :ref:`colorspaces`.
81 * - enum :c:type:`v4l2_hsv_encoding`
82 - ``hsv_enc``
83 - This information supplements the ``colorspace`` and must be set by
84 the driver for capture streams and by the application for output
85 streams, see :ref:`colorspaces`.
81 * - enum :c:type:`v4l2_quantization` 86 * - enum :c:type:`v4l2_quantization`
82 - ``quantization`` 87 - ``quantization``
83 - This information supplements the ``colorspace`` and must be set by 88 - This information supplements the ``colorspace`` and must be set by
diff --git a/Documentation/media/uapi/v4l/pixfmt-006.rst b/Documentation/media/uapi/v4l/pixfmt-006.rst
index a9890ff6038b..7ae7dcf73f63 100644
--- a/Documentation/media/uapi/v4l/pixfmt-006.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-006.rst
@@ -19,9 +19,16 @@ colorspace field of struct :c:type:`v4l2_pix_format`
19or struct :c:type:`v4l2_pix_format_mplane` 19or struct :c:type:`v4l2_pix_format_mplane`
20needs to be filled in. 20needs to be filled in.
21 21
22.. note:: 22.. _hsv-colorspace:
23 23
24 The default R'G'B' quantization is full range for all 24On :ref:`HSV formats <hsv-formats>` the *Hue* is defined as the angle on
25the cylindrical color representation. Usually this angle is measured in
26degrees, i.e. 0-360. When we map this angle value into 8 bits, there are
27two basic ways to do it: Divide the angular value by 2 (0-179), or use the
28whole range, 0-255, dividing the angular value by 1.41. The enum
29:c:type:`v4l2_hsv_encoding` specifies which encoding is used.
30
31.. note:: The default R'G'B' quantization is full range for all
25 colorspaces except for BT.2020 which uses limited range R'G'B' 32 colorspaces except for BT.2020 which uses limited range R'G'B'
26 quantization. 33 quantization.
27 34
@@ -123,6 +130,24 @@ needs to be filled in.
123 130
124 131
125 132
133.. c:type:: v4l2_hsv_encoding
134
135.. tabularcolumns:: |p{6.5cm}|p{11.0cm}|
136
137.. flat-table:: V4L2 HSV Encodings
138 :header-rows: 1
139 :stub-columns: 0
140
141 * - Identifier
142 - Details
143 * - ``V4L2_HSV_ENC_180``
144 - For the Hue, each LSB is two degrees.
145 * - ``V4L2_HSV_ENC_256``
146 - For the Hue, the 360 degrees are mapped into 8 bits, i.e. each
147 LSB is roughly 1.41 degrees.
148
149
150
126.. c:type:: v4l2_quantization 151.. c:type:: v4l2_quantization
127 152
128.. tabularcolumns:: |p{6.5cm}|p{11.0cm}| 153.. tabularcolumns:: |p{6.5cm}|p{11.0cm}|
@@ -136,7 +161,7 @@ needs to be filled in.
136 * - ``V4L2_QUANTIZATION_DEFAULT`` 161 * - ``V4L2_QUANTIZATION_DEFAULT``
137 - Use the default quantization encoding as defined by the 162 - Use the default quantization encoding as defined by the
138 colorspace. This is always full range for R'G'B' (except for the 163 colorspace. This is always full range for R'G'B' (except for the
139 BT.2020 colorspace) and usually limited range for Y'CbCr. 164 BT.2020 colorspace) and HSV. It is usually limited range for Y'CbCr.
140 * - ``V4L2_QUANTIZATION_FULL_RANGE`` 165 * - ``V4L2_QUANTIZATION_FULL_RANGE``
141 - Use the full range quantization encoding. I.e. the range [0…1] is 166 - Use the full range quantization encoding. I.e. the range [0…1] is
142 mapped to [0…255] (with possible clipping to [1…254] to avoid the 167 mapped to [0…255] (with possible clipping to [1…254] to avoid the
diff --git a/Documentation/media/uapi/v4l/pixfmt-013.rst b/Documentation/media/uapi/v4l/pixfmt-013.rst
index 542c087152e3..728d7ede10fa 100644
--- a/Documentation/media/uapi/v4l/pixfmt-013.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-013.rst
@@ -85,3 +85,8 @@ Compressed Formats
85 - ``V4L2_PIX_FMT_VP8`` 85 - ``V4L2_PIX_FMT_VP8``
86 - 'VP80' 86 - 'VP80'
87 - VP8 video elementary stream. 87 - VP8 video elementary stream.
88 * .. _V4L2-PIX-FMT-VP9:
89
90 - ``V4L2_PIX_FMT_VP9``
91 - 'VP90'
92 - VP9 video elementary stream.
diff --git a/Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst b/Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst
new file mode 100644
index 000000000000..3fdb34ce2f09
--- /dev/null
+++ b/Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst
@@ -0,0 +1,157 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3.. _packed-hsv:
4
5******************
6Packed HSV formats
7******************
8
9Description
10===========
11
12The *hue* (h) is measured in degrees, the equivalence between degrees and LSBs
13depends on the hsv-encoding used, see :ref:`colorspaces`.
14The *saturation* (s) and the *value* (v) are measured in percentage of the
15cylinder: 0 being the smallest value and 255 the maximum.
16
17
18The values are packed in 24 or 32 bit formats.
19
20.. raw:: latex
21
22 \newline\begin{adjustbox}{width=\columnwidth}
23
24.. tabularcolumns:: |p{4.2cm}|p{1.0cm}|p{0.7cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.2cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.2cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.2cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{1.7cm}|
25
26.. _packed-hsv-formats:
27
28.. flat-table:: Packed HSV Image Formats
29 :header-rows: 2
30 :stub-columns: 0
31
32 * - Identifier
33 - Code
34 -
35 - :cspan:`7` Byte 0 in memory
36 -
37 - :cspan:`7` Byte 1
38 -
39 - :cspan:`7` Byte 2
40 -
41 - :cspan:`7` Byte 3
42 * -
43 -
44 - Bit
45 - 7
46 - 6
47 - 5
48 - 4
49 - 3
50 - 2
51 - 1
52 - 0
53 -
54 - 7
55 - 6
56 - 5
57 - 4
58 - 3
59 - 2
60 - 1
61 - 0
62 -
63 - 7
64 - 6
65 - 5
66 - 4
67 - 3
68 - 2
69 - 1
70 - 0
71 -
72 - 7
73 - 6
74 - 5
75 - 4
76 - 3
77 - 2
78 - 1
79 - 0
80 * .. _V4L2-PIX-FMT-HSV32:
81
82 - ``V4L2_PIX_FMT_HSV32``
83 - 'HSV4'
84 -
85 -
86 -
87 -
88 -
89 -
90 -
91 -
92 -
93 -
94 - h\ :sub:`7`
95 - h\ :sub:`6`
96 - h\ :sub:`5`
97 - h\ :sub:`4`
98 - h\ :sub:`3`
99 - h\ :sub:`2`
100 - h\ :sub:`1`
101 - h\ :sub:`0`
102 -
103 - s\ :sub:`7`
104 - s\ :sub:`6`
105 - s\ :sub:`5`
106 - s\ :sub:`4`
107 - s\ :sub:`3`
108 - s\ :sub:`2`
109 - s\ :sub:`1`
110 - s\ :sub:`0`
111 -
112 - v\ :sub:`7`
113 - v\ :sub:`6`
114 - v\ :sub:`5`
115 - v\ :sub:`4`
116 - v\ :sub:`3`
117 - v\ :sub:`2`
118 - v\ :sub:`1`
119 - v\ :sub:`0`
120 * .. _V4L2-PIX-FMT-HSV24:
121
122 - ``V4L2_PIX_FMT_HSV24``
123 - 'HSV3'
124 -
125 - h\ :sub:`7`
126 - h\ :sub:`6`
127 - h\ :sub:`5`
128 - h\ :sub:`4`
129 - h\ :sub:`3`
130 - h\ :sub:`2`
131 - h\ :sub:`1`
132 - h\ :sub:`0`
133 -
134 - s\ :sub:`7`
135 - s\ :sub:`6`
136 - s\ :sub:`5`
137 - s\ :sub:`4`
138 - s\ :sub:`3`
139 - s\ :sub:`2`
140 - s\ :sub:`1`
141 - s\ :sub:`0`
142 -
143 - v\ :sub:`7`
144 - v\ :sub:`6`
145 - v\ :sub:`5`
146 - v\ :sub:`4`
147 - v\ :sub:`3`
148 - v\ :sub:`2`
149 - v\ :sub:`1`
150 - v\ :sub:`0`
151 -
152 -
153.. raw:: latex
154
155 \end{adjustbox}\newline\newline
156
157Bit 7 is the most significant bit.
diff --git a/Documentation/media/uapi/v4l/pixfmt-reserved.rst b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
index bd7bf3dae6af..521adb795535 100644
--- a/Documentation/media/uapi/v4l/pixfmt-reserved.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
@@ -234,7 +234,15 @@ please make a proposal on the linux-media mailing list.
234 repeated for each line, i.e. the number of entries in the pointer 234 repeated for each line, i.e. the number of entries in the pointer
235 array. Anything what's in between the UYVY lines is JPEG data and 235 array. Anything what's in between the UYVY lines is JPEG data and
236 should be concatenated to form the JPEG stream. 236 should be concatenated to form the JPEG stream.
237 237 * .. _V4L2-PIX-FMT-MT21C:
238
239 - ``V4L2_PIX_FMT_MT21C``
240 - 'MT21'
241 - Compressed two-planar YVU420 format used by Mediatek MT8173.
242 The compression is lossless.
243 It is an opaque intermediate format and the MDP hardware must be
244 used to convert ``V4L2_PIX_FMT_MT21C`` to ``V4L2_PIX_FMT_NV12M``,
245 ``V4L2_PIX_FMT_YUV420M`` or ``V4L2_PIX_FMT_YVU420``.
238 246
239 247
240.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}| 248.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
diff --git a/Documentation/media/uapi/v4l/pixfmt-rgb.rst b/Documentation/media/uapi/v4l/pixfmt-rgb.rst
index 9cc980882e80..b0f35136021e 100644
--- a/Documentation/media/uapi/v4l/pixfmt-rgb.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-rgb.rst
@@ -12,9 +12,9 @@ RGB Formats
12 12
13 pixfmt-packed-rgb 13 pixfmt-packed-rgb
14 pixfmt-srggb8 14 pixfmt-srggb8
15 pixfmt-sbggr16
16 pixfmt-srggb10 15 pixfmt-srggb10
17 pixfmt-srggb10p 16 pixfmt-srggb10p
18 pixfmt-srggb10alaw8 17 pixfmt-srggb10alaw8
19 pixfmt-srggb10dpcm8 18 pixfmt-srggb10dpcm8
20 pixfmt-srggb12 19 pixfmt-srggb12
20 pixfmt-srggb16
diff --git a/Documentation/media/uapi/v4l/pixfmt-srggb10p.rst b/Documentation/media/uapi/v4l/pixfmt-srggb10p.rst
index 9a41c8d811d0..b6d426c70ccd 100644
--- a/Documentation/media/uapi/v4l/pixfmt-srggb10p.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-srggb10p.rst
@@ -28,7 +28,7 @@ bits of each pixel, in the same order.
28Each n-pixel row contains n/2 green samples and n/2 blue or red samples, 28Each n-pixel row contains n/2 green samples and n/2 blue or red samples,
29with alternating green-red and green-blue rows. They are conventionally 29with alternating green-red and green-blue rows. They are conventionally
30described as GRGR... BGBG..., RGRG... GBGB..., etc. Below is an example 30described as GRGR... BGBG..., RGRG... GBGB..., etc. Below is an example
31of one of these formats: 31of a small V4L2_PIX_FMT_SBGGR10P image:
32 32
33**Byte Order.** 33**Byte Order.**
34Each cell is one byte. 34Each cell is one byte.
diff --git a/Documentation/media/uapi/v4l/pixfmt-srggb12.rst b/Documentation/media/uapi/v4l/pixfmt-srggb12.rst
index a50ee143cb08..15041e568a0a 100644
--- a/Documentation/media/uapi/v4l/pixfmt-srggb12.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-srggb12.rst
@@ -26,7 +26,7 @@ high bits filled with zeros. Each n-pixel row contains n/2 green samples
26and n/2 blue or red samples, with alternating red and blue rows. Bytes 26and n/2 blue or red samples, with alternating red and blue rows. Bytes
27are stored in memory in little endian order. They are conventionally 27are stored in memory in little endian order. They are conventionally
28described as GRGR... BGBG..., RGRG... GBGB..., etc. Below is an example 28described as GRGR... BGBG..., RGRG... GBGB..., etc. Below is an example
29of one of these formats: 29of a small V4L2_PIX_FMT_SBGGR12 image:
30 30
31**Byte Order.** 31**Byte Order.**
32Each cell is one byte, the 4 most significant bits in the high bytes are 32Each cell is one byte, the 4 most significant bits in the high bytes are
diff --git a/Documentation/media/uapi/v4l/pixfmt-sbggr16.rst b/Documentation/media/uapi/v4l/pixfmt-srggb16.rst
index 6f7f327db85c..d407b2b2050f 100644
--- a/Documentation/media/uapi/v4l/pixfmt-sbggr16.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-srggb16.rst
@@ -1,21 +1,28 @@
1.. -*- coding: utf-8; mode: rst -*- 1.. -*- coding: utf-8; mode: rst -*-
2 2
3.. _V4L2-PIX-FMT-SBGGR16: 3.. _V4L2-PIX-FMT-SRGGB16:
4.. _v4l2-pix-fmt-sbggr16:
5.. _v4l2-pix-fmt-sgbrg16:
6.. _v4l2-pix-fmt-sgrbg16:
4 7
5*****************************
6V4L2_PIX_FMT_SBGGR16 ('BYR2')
7*****************************
8 8
9Bayer RGB format 9***************************************************************************************************************************
10V4L2_PIX_FMT_SRGGB16 ('RG16'), V4L2_PIX_FMT_SGRBG16 ('GR16'), V4L2_PIX_FMT_SGBRG16 ('GB16'), V4L2_PIX_FMT_SBGGR16 ('BYR2'),
11***************************************************************************************************************************
12
13
1416-bit Bayer formats
10 15
11 16
12Description 17Description
13=========== 18===========
14 19
15This format is similar to 20These four pixel formats are raw sRGB / Bayer formats with 16 bits per
16:ref:`V4L2_PIX_FMT_SBGGR8 <V4L2-PIX-FMT-SBGGR8>`, except each pixel 21sample. Each sample is stored in a 16-bit word. Each n-pixel row contains
17has a depth of 16 bits. The least significant byte is stored at lower 22n/2 green samples and n/2 blue or red samples, with alternating red and blue
18memory addresses (little-endian). 23rows. Bytes are stored in memory in little endian order. They are
24conventionally described as GRGR... BGBG..., RGRG... GBGB..., etc. Below is
25an example of a small V4L2_PIX_FMT_SBGGR16 image:
19 26
20**Byte Order.** 27**Byte Order.**
21Each cell is one byte. 28Each cell is one byte.
diff --git a/Documentation/media/uapi/v4l/pixfmt-srggb8.rst b/Documentation/media/uapi/v4l/pixfmt-srggb8.rst
index a3987d2e97fd..5ac25a634d30 100644
--- a/Documentation/media/uapi/v4l/pixfmt-srggb8.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-srggb8.rst
@@ -20,7 +20,7 @@ These four pixel formats are raw sRGB / Bayer formats with 8 bits per
20sample. Each sample is stored in a byte. Each n-pixel row contains n/2 20sample. Each sample is stored in a byte. Each n-pixel row contains n/2
21green samples and n/2 blue or red samples, with alternating red and 21green samples and n/2 blue or red samples, with alternating red and
22blue rows. They are conventionally described as GRGR... BGBG..., 22blue rows. They are conventionally described as GRGR... BGBG...,
23RGRG... GBGB..., etc. Below is an example of one of these formats: 23RGRG... GBGB..., etc. Below is an example of a small V4L2_PIX_FMT_SBGGR8 image:
24 24
25**Byte Order.** 25**Byte Order.**
26Each cell is one byte. 26Each cell is one byte.
diff --git a/Documentation/media/uapi/v4l/pixfmt.rst b/Documentation/media/uapi/v4l/pixfmt.rst
index 4d297f6eb5f1..4f184c7aedab 100644
--- a/Documentation/media/uapi/v4l/pixfmt.rst
+++ b/Documentation/media/uapi/v4l/pixfmt.rst
@@ -29,6 +29,7 @@ see also :ref:`VIDIOC_G_FBUF <VIDIOC_G_FBUF>`.)
29 pixfmt-indexed 29 pixfmt-indexed
30 pixfmt-rgb 30 pixfmt-rgb
31 yuv-formats 31 yuv-formats
32 hsv-formats
32 depth-formats 33 depth-formats
33 pixfmt-013 34 pixfmt-013
34 sdr-formats 35 sdr-formats
diff --git a/Documentation/media/uapi/v4l/subdev-image-processing-crop.svg b/Documentation/media/uapi/v4l/subdev-image-processing-crop.svg
index ba02e6f6214d..1903dd3846c2 100644
--- a/Documentation/media/uapi/v4l/subdev-image-processing-crop.svg
+++ b/Documentation/media/uapi/v4l/subdev-image-processing-crop.svg
@@ -7,9 +7,9 @@
7 xmlns="http://www.w3.org/2000/svg" 7 xmlns="http://www.w3.org/2000/svg"
8 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" 8 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
9 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" 9 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
10 width="43cm" 10 width="42.799767cm"
11 height="10cm" 11 height="9.9348345cm"
12 viewBox="-194 128 844 196" 12 viewBox="-194 128 840.06984 194.72276"
13 id="svg2" 13 id="svg2"
14 version="1.1" 14 version="1.1"
15 inkscape:version="0.91 r13725" 15 inkscape:version="0.91 r13725"
@@ -22,6 +22,7 @@
22 <dc:format>image/svg+xml</dc:format> 22 <dc:format>image/svg+xml</dc:format>
23 <dc:type 23 <dc:type
24 rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> 24 rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
25 <dc:title />
25 </cc:Work> 26 </cc:Work>
26 </rdf:RDF> 27 </rdf:RDF>
27 </metadata> 28 </metadata>
@@ -40,23 +41,27 @@
40 inkscape:window-height="997" 41 inkscape:window-height="997"
41 id="namedview96" 42 id="namedview96"
42 showgrid="false" 43 showgrid="false"
44 fit-margin-top="0"
45 fit-margin-left="0"
46 fit-margin-right="0"
47 fit-margin-bottom="0"
43 inkscape:zoom="0.3649199" 48 inkscape:zoom="0.3649199"
44 inkscape:cx="767.29168" 49 inkscape:cx="764.40286"
45 inkscape:cy="177.16535" 50 inkscape:cy="176.91347"
46 inkscape:window-x="1920" 51 inkscape:window-x="1920"
47 inkscape:window-y="30" 52 inkscape:window-y="30"
48 inkscape:window-maximized="1" 53 inkscape:window-maximized="1"
49 inkscape:current-layer="svg2" /> 54 inkscape:current-layer="svg2" />
50 <rect 55 <rect
51 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 56 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
52 x="-8" 57 x="-9.6002426"
53 y="130" 58 y="128.86047"
54 width="469.774" 59 width="469.77399"
55 height="193" 60 height="193"
56 id="rect4" /> 61 id="rect4" />
57 <g 62 <g
58 id="g6" 63 id="g6"
59 style=""> 64 transform="translate(-1.6002426,-1.1395339)">
60 <rect 65 <rect
61 style="fill:#ffffff" 66 style="fill:#ffffff"
62 x="4.5" 67 x="4.5"
@@ -65,7 +70,7 @@
65 height="104" 70 height="104"
66 id="rect8" /> 71 id="rect8" />
67 <rect 72 <rect
68 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#a52a2a" 73 style="fill:none;fill-opacity:0;stroke:#a52a2a;stroke-width:2"
69 x="4.5" 74 x="4.5"
70 y="189" 75 y="189"
71 width="159" 76 width="159"
@@ -74,7 +79,7 @@
74 </g> 79 </g>
75 <g 80 <g
76 id="g12" 81 id="g12"
77 style=""> 82 transform="translate(-1.6002426,-1.1395339)">
78 <rect 83 <rect
79 style="fill:#ffffff" 84 style="fill:#ffffff"
80 x="63.5" 85 x="63.5"
@@ -83,7 +88,7 @@
83 height="77" 88 height="77"
84 id="rect14" /> 89 id="rect14" />
85 <rect 90 <rect
86 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#0000ff" 91 style="fill:none;fill-opacity:0;stroke:#0000ff;stroke-width:2"
87 x="63.5" 92 x="63.5"
88 y="211" 93 y="211"
89 width="94" 94 width="94"
@@ -91,223 +96,207 @@
91 id="rect16" /> 96 id="rect16" />
92 </g> 97 </g>
93 <text 98 <text
94 style="fill:#0000ff;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 99 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#0000ff"
95 x="74.5" 100 x="72.899757"
96 y="227.75" 101 y="226.61047"
97 id="text18"> 102 id="text18">
98 <tspan 103 <tspan
99 x="74.5" 104 x="72.899757"
100 y="227.75" 105 y="226.61047"
101 id="tspan20" 106 id="tspan20">sink</tspan>
102 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">sink</tspan>
103 <tspan 107 <tspan
104 x="74.5" 108 x="72.899757"
105 y="243.75" 109 y="242.61047"
106 id="tspan22" 110 id="tspan22">crop</tspan>
107 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">crop</tspan>
108 <tspan 111 <tspan
109 x="74.5" 112 x="72.899757"
110 y="259.75" 113 y="258.61047"
111 id="tspan24" 114 id="tspan24">selection</tspan>
112 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">selection</tspan>
113 </text> 115 </text>
114 <text 116 <text
115 style="fill:#000000;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 117 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#000000"
116 x="29.5" 118 x="27.899757"
117 y="158" 119 y="156.86047"
118 id="text26"> 120 id="text26">
119 <tspan 121 <tspan
120 x="29.5" 122 x="27.899757"
121 y="158" 123 y="156.86047"
122 id="tspan28" 124 id="tspan28" />
123 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;" />
124 </text> 125 </text>
125 <text 126 <text
126 style="fill:#a52a2a;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 127 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#a52a2a"
127 x="8.53836" 128 x="6.938117"
128 y="157.914" 129 y="156.77448"
129 id="text30"> 130 id="text30">
130 <tspan 131 <tspan
131 x="8.53836" 132 x="6.938117"
132 y="157.914" 133 y="156.77448"
133 id="tspan32" 134 id="tspan32">sink media</tspan>
134 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">sink media</tspan>
135 <tspan 135 <tspan
136 x="8.53836" 136 x="6.938117"
137 y="173.914" 137 y="172.77448"
138 id="tspan34" 138 id="tspan34">bus format</tspan>
139 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">bus format</tspan>
140 </text> 139 </text>
141 <text 140 <text
142 style="fill:#8b6914;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 141 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#8b6914"
143 x="349.774" 142 x="348.17374"
144 y="155" 143 y="153.86047"
145 id="text36"> 144 id="text36">
146 <tspan 145 <tspan
147 x="349.774" 146 x="348.17374"
148 y="155" 147 y="153.86047"
149 id="tspan38" 148 id="tspan38">source media</tspan>
150 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">source media</tspan>
151 <tspan 149 <tspan
152 x="349.774" 150 x="348.17374"
153 y="171" 151 y="169.86047"
154 id="tspan40" 152 id="tspan40">bus format</tspan>
155 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">bus format</tspan>
156 </text> 153 </text>
157 <g 154 <g
158 id="g42" 155 id="g42"
159 style=""> 156 transform="translate(-1.6002426,-1.1395339)">
160 <rect 157 <rect
161 style="fill:#ffffff" 158 style="fill:#ffffff"
162 x="350.488" 159 x="350.48801"
163 y="190.834" 160 y="190.834"
164 width="93.2863" 161 width="93.286301"
165 height="75.166" 162 height="75.166"
166 id="rect44" /> 163 id="rect44" />
167 <rect 164 <rect
168 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#8b6914" 165 style="fill:none;fill-opacity:0;stroke:#8b6914;stroke-width:2"
169 x="350.488" 166 x="350.48801"
170 y="190.834" 167 y="190.834"
171 width="93.2863" 168 width="93.286301"
172 height="75.166" 169 height="75.166"
173 id="rect46" /> 170 id="rect46" />
174 </g> 171 </g>
175 <line 172 <line
176 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 173 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
177 x1="350.488" 174 x1="348.88776"
178 y1="266" 175 y1="264.86047"
179 x2="63.5" 176 x2="61.899757"
180 y2="288" 177 y2="286.86047"
181 id="line48" /> 178 id="line48" />
182 <line 179 <line
183 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 180 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
184 x1="350.488" 181 x1="348.88776"
185 y1="190.834" 182 y1="189.69447"
186 x2="63.5" 183 x2="61.899757"
187 y2="211" 184 y2="209.86047"
188 id="line50" /> 185 id="line50" />
189 <line 186 <line
190 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 187 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
191 x1="443.774" 188 x1="442.17374"
192 y1="266" 189 y1="264.86047"
193 x2="157.5" 190 x2="155.89977"
194 y2="288" 191 y2="286.86047"
195 id="line52" /> 192 id="line52" />
196 <line 193 <line
197 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 194 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
198 x1="443.774" 195 x1="442.17374"
199 y1="190.834" 196 y1="189.69447"
200 x2="157.5" 197 x2="155.89977"
201 y2="211" 198 y2="209.86047"
202 id="line54" /> 199 id="line54" />
203 <g 200 <g
204 id="g56" 201 id="g56"
205 style=""> 202 transform="translate(-1.6002426,-1.1395339)">
206 <ellipse 203 <circle
207 style="fill:#ffffff" 204 style="fill:#ffffff"
208 cx="473.1" 205 cx="473.10001"
209 cy="219.984" 206 cy="219.98399"
210 rx="8.5" 207 id="ellipse58"
211 ry="8.5" 208 r="8.5" />
212 id="ellipse58" /> 209 <circle
213 <ellipse 210 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
214 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 211 cx="473.10001"
215 cx="473.1" 212 cy="219.98399"
216 cy="219.984" 213 id="ellipse60"
217 rx="8.5" 214 r="8.5" />
218 ry="8.5" 215 <circle
219 id="ellipse60" /> 216 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
220 <ellipse 217 cx="473.10001"
221 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 218 cy="219.98399"
222 cx="473.1" 219 id="ellipse62"
223 cy="219.984" 220 r="8.5" />
224 rx="8.5"
225 ry="8.5"
226 id="ellipse62" />
227 </g> 221 </g>
228 <g 222 <g
229 id="g64" 223 id="g64"
230 style=""> 224 transform="translate(-1.6002426,-1.1395339)">
231 <line 225 <line
232 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 226 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
233 x1="481.6" 227 x1="481.60001"
234 y1="219.984" 228 y1="219.98399"
235 x2="637.934" 229 x2="637.93402"
236 y2="220.012" 230 y2="220.01199"
237 id="line66" /> 231 id="line66" />
238 <polygon 232 <polygon
239 style="fill:#000000" 233 style="fill:#000000"
240 points="645.434,220.014 635.433,225.012 637.934,220.012 635.435,215.012 " 234 points="635.435,215.012 645.434,220.014 635.433,225.012 637.934,220.012 "
241 id="polygon68" /> 235 id="polygon68" />
242 <polygon 236 <polygon
243 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 237 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
244 points="645.434,220.014 635.433,225.012 637.934,220.012 635.435,215.012 " 238 points="635.435,215.012 645.434,220.014 635.433,225.012 637.934,220.012 "
245 id="polygon70" /> 239 id="polygon70" />
246 </g> 240 </g>
247 <text 241 <text
248 style="fill:#000000;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 242 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#000000"
249 x="506.908" 243 x="505.30774"
250 y="209.8" 244 y="208.66048"
251 id="text72"> 245 id="text72">
252 <tspan 246 <tspan
253 x="506.908" 247 x="505.30774"
254 y="209.8" 248 y="208.66048"
255 id="tspan74" 249 id="tspan74">pad 1 (source)</tspan>
256 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">pad 1 (source)</tspan>
257 </text> 250 </text>
258 <g 251 <g
259 id="g76" 252 id="g76"
260 style=""> 253 transform="translate(-1.6002426,-1.1395339)">
261 <ellipse 254 <circle
262 style="fill:#ffffff" 255 style="fill:#ffffff"
263 cx="-20.3982" 256 cx="-20.398199"
264 cy="241.512" 257 cy="241.51199"
265 rx="8.5" 258 id="ellipse78"
266 ry="8.5" 259 r="8.5" />
267 id="ellipse78" /> 260 <circle
268 <ellipse 261 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
269 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 262 cx="-20.398199"
270 cx="-20.3982" 263 cy="241.51199"
271 cy="241.512" 264 id="ellipse80"
272 rx="8.5" 265 r="8.5" />
273 ry="8.5" 266 <circle
274 id="ellipse80" /> 267 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
275 <ellipse 268 cx="-20.398199"
276 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 269 cy="241.51199"
277 cx="-20.3982" 270 id="ellipse82"
278 cy="241.512" 271 r="8.5" />
279 rx="8.5"
280 ry="8.5"
281 id="ellipse82" />
282 </g> 272 </g>
283 <g 273 <g
284 id="g84" 274 id="g84"
285 style=""> 275 transform="translate(-1.6002426,-1.1395339)">
286 <line 276 <line
287 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 277 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
288 x1="-192.398" 278 x1="-192.39799"
289 y1="241.8" 279 y1="241.8"
290 x2="-38.6343" 280 x2="-38.6343"
291 y2="241.529" 281 y2="241.52901"
292 id="line86" /> 282 id="line86" />
293 <polygon 283 <polygon
294 style="fill:#000000" 284 style="fill:#000000"
295 points="-31.1343,241.516 -41.1254,246.534 -38.6343,241.529 -41.1431,236.534 " 285 points="-41.1431,236.534 -31.1343,241.516 -41.1254,246.534 -38.6343,241.529 "
296 id="polygon88" /> 286 id="polygon88" />
297 <polygon 287 <polygon
298 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 288 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
299 points="-31.1343,241.516 -41.1254,246.534 -38.6343,241.529 -41.1431,236.534 " 289 points="-41.1431,236.534 -31.1343,241.516 -41.1254,246.534 -38.6343,241.529 "
300 id="polygon90" /> 290 id="polygon90" />
301 </g> 291 </g>
302 <text 292 <text
303 style="fill:#000000;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 293 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#000000"
304 x="-147.858" 294 x="-149.45824"
305 y="229.8" 295 y="228.66048"
306 id="text92"> 296 id="text92">
307 <tspan 297 <tspan
308 x="-147.858" 298 x="-149.45824"
309 y="229.8" 299 y="228.66048"
310 id="tspan94" 300 id="tspan94">pad 0 (sink)</tspan>
311 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">pad 0 (sink)</tspan>
312 </text> 301 </text>
313</svg> 302</svg>
diff --git a/Documentation/media/uapi/v4l/subdev-image-processing-full.svg b/Documentation/media/uapi/v4l/subdev-image-processing-full.svg
index c82291a4493e..91cf51832c12 100644
--- a/Documentation/media/uapi/v4l/subdev-image-processing-full.svg
+++ b/Documentation/media/uapi/v4l/subdev-image-processing-full.svg
@@ -7,9 +7,9 @@
7 xmlns="http://www.w3.org/2000/svg" 7 xmlns="http://www.w3.org/2000/svg"
8 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" 8 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
9 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" 9 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
10 width="59cm" 10 width="58.825298cm"
11 height="18cm" 11 height="17.279287cm"
12 viewBox="-186 71 1178 346" 12 viewBox="-186 71 1174.5119 332.1463"
13 id="svg2" 13 id="svg2"
14 version="1.1" 14 version="1.1"
15 inkscape:version="0.91 r13725" 15 inkscape:version="0.91 r13725"
@@ -22,6 +22,7 @@
22 <dc:format>image/svg+xml</dc:format> 22 <dc:format>image/svg+xml</dc:format>
23 <dc:type 23 <dc:type
24 rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> 24 rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
25 <dc:title />
25 </cc:Work> 26 </cc:Work>
26 </rdf:RDF> 27 </rdf:RDF>
27 </metadata> 28 </metadata>
@@ -40,151 +41,147 @@
40 inkscape:window-height="997" 41 inkscape:window-height="997"
41 id="namedview256" 42 id="namedview256"
42 showgrid="false" 43 showgrid="false"
44 fit-margin-top="0"
45 fit-margin-left="0"
46 fit-margin-right="0"
47 fit-margin-bottom="0"
43 inkscape:zoom="0.26595857" 48 inkscape:zoom="0.26595857"
44 inkscape:cx="1052.7956" 49 inkscape:cx="1050.1367"
45 inkscape:cy="318.89764" 50 inkscape:cy="307.01645"
46 inkscape:window-x="1920" 51 inkscape:window-x="1920"
47 inkscape:window-y="30" 52 inkscape:window-y="30"
48 inkscape:window-maximized="1" 53 inkscape:window-maximized="1"
49 inkscape:current-layer="svg2" /> 54 inkscape:current-layer="svg2" />
50 <g 55 <g
51 id="g4" 56 id="g4"
52 style=""> 57 transform="translate(-1.4982376,-7.6949076)">
53 <rect 58 <rect
54 style="fill:#ffffff" 59 style="fill:#ffffff"
55 x="318.9" 60 x="318.89999"
56 y="129" 61 y="129"
57 width="208.1" 62 width="208.10001"
58 height="249" 63 height="249"
59 id="rect6" /> 64 id="rect6" />
60 <rect 65 <rect
61 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#ff765a" 66 style="fill:none;fill-opacity:0;stroke:#ff765a;stroke-width:2"
62 x="318.9" 67 x="318.89999"
63 y="129" 68 y="129"
64 width="208.1" 69 width="208.10001"
65 height="249" 70 height="249"
66 id="rect8" /> 71 id="rect8" />
67 </g> 72 </g>
68 <rect 73 <rect
69 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 74 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
70 x="-2" 75 x="-3.4982376"
71 y="73" 76 y="65.305092"
72 width="806" 77 width="806"
73 height="343" 78 height="343"
74 id="rect10" /> 79 id="rect10" />
75 <g 80 <g
76 id="g12" 81 id="g12"
77 style=""> 82 transform="translate(-1.4982376,-7.6949076)">
78 <ellipse 83 <circle
79 style="fill:#ffffff" 84 style="fill:#ffffff"
80 cx="-12.5" 85 cx="-12.5"
81 cy="166.712" 86 cy="166.71201"
82 rx="8.5" 87 id="ellipse14"
83 ry="8.5" 88 r="8.5" />
84 id="ellipse14" /> 89 <circle
85 <ellipse 90 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
86 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000"
87 cx="-12.5" 91 cx="-12.5"
88 cy="166.712" 92 cy="166.71201"
89 rx="8.5" 93 id="ellipse16"
90 ry="8.5" 94 r="8.5" />
91 id="ellipse16" /> 95 <circle
92 <ellipse 96 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
93 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000"
94 cx="-12.5" 97 cx="-12.5"
95 cy="166.712" 98 cy="166.71201"
96 rx="8.5" 99 id="ellipse18"
97 ry="8.5" 100 r="8.5" />
98 id="ellipse18" />
99 </g> 101 </g>
100 <g 102 <g
101 id="g20" 103 id="g20"
102 style=""> 104 transform="translate(-1.4982376,-7.6949076)">
103 <ellipse 105 <circle
104 style="fill:#ffffff" 106 style="fill:#ffffff"
105 cx="815.232" 107 cx="815.23199"
106 cy="205.184" 108 cy="205.18401"
107 rx="8.5" 109 id="ellipse22"
108 ry="8.5" 110 r="8.5" />
109 id="ellipse22" /> 111 <circle
110 <ellipse 112 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
111 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 113 cx="815.23199"
112 cx="815.232" 114 cy="205.18401"
113 cy="205.184" 115 id="ellipse24"
114 rx="8.5" 116 r="8.5" />
115 ry="8.5" 117 <circle
116 id="ellipse24" /> 118 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
117 <ellipse 119 cx="815.23199"
118 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 120 cy="205.18401"
119 cx="815.232" 121 id="ellipse26"
120 cy="205.184" 122 r="8.5" />
121 rx="8.5"
122 ry="8.5"
123 id="ellipse26" />
124 </g> 123 </g>
125 <g 124 <g
126 id="g28" 125 id="g28"
127 style=""> 126 transform="translate(-1.4982376,-7.6949076)">
128 <line 127 <line
129 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 128 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
130 x1="-184.5" 129 x1="-184.5"
131 y1="167" 130 y1="167"
132 x2="-30.7361" 131 x2="-30.736099"
133 y2="166.729" 132 y2="166.729"
134 id="line30" /> 133 id="line30" />
135 <polygon 134 <polygon
136 style="fill:#000000" 135 style="fill:#000000"
137 points="-23.2361,166.716 -33.2272,171.734 -30.7361,166.729 -33.2449,161.734 " 136 points="-33.2449,161.734 -23.2361,166.716 -33.2272,171.734 -30.7361,166.729 "
138 id="polygon32" /> 137 id="polygon32" />
139 <polygon 138 <polygon
140 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 139 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
141 points="-23.2361,166.716 -33.2272,171.734 -30.7361,166.729 -33.2449,161.734 " 140 points="-33.2449,161.734 -23.2361,166.716 -33.2272,171.734 -30.7361,166.729 "
142 id="polygon34" /> 141 id="polygon34" />
143 </g> 142 </g>
144 <g 143 <g
145 id="g36" 144 id="g36"
146 style=""> 145 transform="translate(-1.4982376,-7.6949076)">
147 <line 146 <line
148 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 147 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
149 x1="823.732" 148 x1="823.73199"
150 y1="205.184" 149 y1="205.18401"
151 x2="980.066" 150 x2="980.06598"
152 y2="205.212" 151 y2="205.21201"
153 id="line38" /> 152 id="line38" />
154 <polygon 153 <polygon
155 style="fill:#000000" 154 style="fill:#000000"
156 points="987.566,205.214 977.565,210.212 980.066,205.212 977.567,200.212 " 155 points="977.567,200.212 987.566,205.214 977.565,210.212 980.066,205.212 "
157 id="polygon40" /> 156 id="polygon40" />
158 <polygon 157 <polygon
159 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 158 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
160 points="987.566,205.214 977.565,210.212 980.066,205.212 977.567,200.212 " 159 points="977.567,200.212 987.566,205.214 977.565,210.212 980.066,205.212 "
161 id="polygon42" /> 160 id="polygon42" />
162 </g> 161 </g>
163 <text 162 <text
164 style="fill:#000000;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 163 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#000000"
165 x="-139.96" 164 x="-141.45824"
166 y="155" 165 y="147.3051"
167 id="text44"> 166 id="text44">
168 <tspan 167 <tspan
169 x="-139.96" 168 x="-141.45824"
170 y="155" 169 y="147.3051"
171 id="tspan46" 170 id="tspan46">pad 0 (sink)</tspan>
172 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">pad 0 (sink)</tspan>
173 </text> 171 </text>
174 <text 172 <text
175 style="fill:#000000;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 173 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#000000"
176 x="849.04" 174 x="847.54175"
177 y="195" 175 y="187.3051"
178 id="text48"> 176 id="text48">
179 <tspan 177 <tspan
180 x="849.04" 178 x="847.54175"
181 y="195" 179 y="187.3051"
182 id="tspan50" 180 id="tspan50">pad 2 (source)</tspan>
183 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">pad 2 (source)</tspan>
184 </text> 181 </text>
185 <g 182 <g
186 id="g52" 183 id="g52"
187 style=""> 184 transform="translate(-1.4982376,-7.6949076)">
188 <rect 185 <rect
189 style="fill:#ffffff" 186 style="fill:#ffffff"
190 x="5.5" 187 x="5.5"
@@ -193,7 +190,7 @@
193 height="104" 190 height="104"
194 id="rect54" /> 191 id="rect54" />
195 <rect 192 <rect
196 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#a52a2a" 193 style="fill:none;fill-opacity:0;stroke:#a52a2a;stroke-width:2"
197 x="5.5" 194 x="5.5"
198 y="120" 195 y="120"
199 width="159" 196 width="159"
@@ -202,7 +199,7 @@
202 </g> 199 </g>
203 <g 200 <g
204 id="g58" 201 id="g58"
205 style=""> 202 transform="translate(-1.4982376,-7.6949076)">
206 <rect 203 <rect
207 style="fill:#ffffff" 204 style="fill:#ffffff"
208 x="62.5" 205 x="62.5"
@@ -211,7 +208,7 @@
211 height="77" 208 height="77"
212 id="rect60" /> 209 id="rect60" />
213 <rect 210 <rect
214 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#0000ff" 211 style="fill:none;fill-opacity:0;stroke:#0000ff;stroke-width:2"
215 x="62.5" 212 x="62.5"
216 y="136" 213 y="136"
217 width="94" 214 width="94"
@@ -219,551 +216,527 @@
219 id="rect62" /> 216 id="rect62" />
220 </g> 217 </g>
221 <text 218 <text
222 style="fill:#000000;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 219 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#000000"
223 x="30.5" 220 x="29.001762"
224 y="89" 221 y="81.305092"
225 id="text64"> 222 id="text64">
226 <tspan 223 <tspan
227 x="30.5" 224 x="29.001762"
228 y="89" 225 y="81.305092"
229 id="tspan66" 226 id="tspan66" />
230 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;" />
231 </text> 227 </text>
232 <text 228 <text
233 style="fill:#a52a2a;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 229 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#a52a2a"
234 x="9.53836" 230 x="8.040122"
235 y="88.9138" 231 y="81.218895"
236 id="text68"> 232 id="text68">
237 <tspan 233 <tspan
238 x="9.53836" 234 x="8.040122"
239 y="88.9138" 235 y="81.218895"
240 id="tspan70" 236 id="tspan70">sink media</tspan>
241 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">sink media</tspan>
242 <tspan 237 <tspan
243 x="9.53836" 238 x="8.040122"
244 y="104.914" 239 y="97.219093"
245 id="tspan72" 240 id="tspan72">bus format</tspan>
246 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">bus format</tspan>
247 </text> 241 </text>
248 <g 242 <g
249 id="g74" 243 id="g74"
250 style=""> 244 transform="translate(-1.4982376,-7.6949076)">
251 <rect 245 <rect
252 style="fill:#ffffff" 246 style="fill:#ffffff"
253 x="333.644" 247 x="333.64401"
254 y="185.65" 248 y="185.64999"
255 width="165.2" 249 width="165.2"
256 height="172.478" 250 height="172.478"
257 id="rect76" /> 251 id="rect76" />
258 <rect 252 <rect
259 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#00ff00" 253 style="fill:none;fill-opacity:0;stroke:#00ff00;stroke-width:2"
260 x="333.644" 254 x="333.64401"
261 y="185.65" 255 y="185.64999"
262 width="165.2" 256 width="165.2"
263 height="172.478" 257 height="172.478"
264 id="rect78" /> 258 id="rect78" />
265 </g> 259 </g>
266 <line 260 <line
267 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 261 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
268 x1="333.644" 262 x1="332.14578"
269 y1="358.128" 263 y1="350.43307"
270 x2="62.5" 264 x2="61.001762"
271 y2="213" 265 y2="205.3051"
272 id="line80" /> 266 id="line80" />
273 <line 267 <line
274 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 268 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
275 x1="333.644" 269 x1="332.14578"
276 y1="185.65" 270 y1="177.95509"
277 x2="62.5" 271 x2="61.001762"
278 y2="136" 272 y2="128.3051"
279 id="line82" /> 273 id="line82" />
280 <line 274 <line
281 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 275 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
282 x1="498.844" 276 x1="497.34576"
283 y1="358.128" 277 y1="350.43307"
284 x2="156.5" 278 x2="155.00177"
285 y2="213" 279 y2="205.3051"
286 id="line84" /> 280 id="line84" />
287 <line 281 <line
288 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 282 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
289 x1="498.844" 283 x1="497.34576"
290 y1="185.65" 284 y1="177.95509"
291 x2="156.5" 285 x2="155.00177"
292 y2="136" 286 y2="128.3051"
293 id="line86" /> 287 id="line86" />
294 <text 288 <text
295 style="fill:#00ff00;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 289 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#00ff00"
296 x="334.704" 290 x="333.20578"
297 y="149.442" 291 y="141.7471"
298 id="text88"> 292 id="text88">
299 <tspan 293 <tspan
300 x="334.704" 294 x="333.20578"
301 y="149.442" 295 y="141.7471"
302 id="tspan90" 296 id="tspan90">sink compose</tspan>
303 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">sink compose</tspan>
304 <tspan 297 <tspan
305 x="334.704" 298 x="333.20578"
306 y="165.442" 299 y="157.7471"
307 id="tspan92" 300 id="tspan92">selection (scaling)</tspan>
308 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">selection (scaling)</tspan>
309 </text> 301 </text>
310 <g 302 <g
311 id="g94" 303 id="g94"
312 style=""> 304 transform="translate(-1.4982376,-7.6949076)">
313 <rect 305 <rect
314 style="fill:#ffffff" 306 style="fill:#ffffff"
315 x="409.322" 307 x="409.32199"
316 y="194.565" 308 y="194.565"
317 width="100.186" 309 width="100.186"
318 height="71.4523" 310 height="71.452301"
319 id="rect96" /> 311 id="rect96" />
320 <rect 312 <rect
321 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#a020f0" 313 style="fill:none;fill-opacity:0;stroke:#a020f0;stroke-width:2"
322 x="409.322" 314 x="409.32199"
323 y="194.565" 315 y="194.565"
324 width="100.186" 316 width="100.186"
325 height="71.4523" 317 height="71.452301"
326 id="rect98" /> 318 id="rect98" />
327 </g> 319 </g>
328 <text 320 <text
329 style="fill:#8b6914;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 321 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#8b6914"
330 x="689.5" 322 x="688.00177"
331 y="105.128" 323 y="97.43309"
332 id="text100"> 324 id="text100">
333 <tspan 325 <tspan
334 x="689.5" 326 x="688.00177"
335 y="105.128" 327 y="97.43309"
336 id="tspan102" 328 id="tspan102">source media</tspan>
337 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">source media</tspan>
338 <tspan 329 <tspan
339 x="689.5" 330 x="688.00177"
340 y="121.128" 331 y="113.43309"
341 id="tspan104" 332 id="tspan104">bus format</tspan>
342 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">bus format</tspan>
343 </text> 333 </text>
344 <g 334 <g
345 id="g106" 335 id="g106"
346 style=""> 336 transform="translate(-1.4982376,-7.6949076)">
347 <rect 337 <rect
348 style="fill:#ffffff" 338 style="fill:#ffffff"
349 x="688.488" 339 x="688.48798"
350 y="173.834" 340 y="173.834"
351 width="100.186" 341 width="100.186"
352 height="71.4523" 342 height="71.452301"
353 id="rect108" /> 343 id="rect108" />
354 <rect 344 <rect
355 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#8b6914" 345 style="fill:none;fill-opacity:0;stroke:#8b6914;stroke-width:2"
356 x="688.488" 346 x="688.48798"
357 y="173.834" 347 y="173.834"
358 width="100.186" 348 width="100.186"
359 height="71.4523" 349 height="71.452301"
360 id="rect110" /> 350 id="rect110" />
361 </g> 351 </g>
362 <line 352 <line
363 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 353 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
364 x1="688.488" 354 x1="686.98975"
365 y1="245.286" 355 y1="237.59109"
366 x2="409.322" 356 x2="407.82376"
367 y2="266.018" 357 y2="258.32309"
368 id="line112" /> 358 id="line112" />
369 <line 359 <line
370 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 360 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
371 x1="688.488" 361 x1="686.98975"
372 y1="173.834" 362 y1="166.1391"
373 x2="409.322" 363 x2="407.82376"
374 y2="194.565" 364 y2="186.8701"
375 id="line114" /> 365 id="line114" />
376 <line 366 <line
377 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 367 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
378 x1="788.674" 368 x1="787.17578"
379 y1="245.286" 369 y1="237.59109"
380 x2="509.508" 370 x2="508.00977"
381 y2="266.018" 371 y2="258.32309"
382 id="line116" /> 372 id="line116" />
383 <line 373 <line
384 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 374 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
385 x1="788.674" 375 x1="787.17578"
386 y1="173.834" 376 y1="166.1391"
387 x2="509.508" 377 x2="508.00977"
388 y2="194.565" 378 y2="186.8701"
389 id="line118" /> 379 id="line118" />
390 <text 380 <text
391 style="fill:#ff765a;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 381 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#ff765a"
392 x="325" 382 x="323.50177"
393 y="103" 383 y="95.305092"
394 id="text120"> 384 id="text120">
395 <tspan 385 <tspan
396 x="325" 386 x="323.50177"
397 y="103" 387 y="95.305092"
398 id="tspan122" 388 id="tspan122">sink compose</tspan>
399 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">sink compose</tspan>
400 <tspan 389 <tspan
401 x="325" 390 x="323.50177"
402 y="119" 391 y="111.30509"
403 id="tspan124" 392 id="tspan124">bounds selection</tspan>
404 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">bounds selection</tspan>
405 </text> 393 </text>
406 <g 394 <g
407 id="g126" 395 id="g126"
408 style=""> 396 transform="translate(-1.4982376,-7.6949076)">
409 <ellipse 397 <circle
410 style="fill:#ffffff" 398 style="fill:#ffffff"
411 cx="-12.0982" 399 cx="-12.0982"
412 cy="341.512" 400 cy="341.51199"
413 rx="8.5" 401 id="ellipse128"
414 ry="8.5" 402 r="8.5" />
415 id="ellipse128" /> 403 <circle
416 <ellipse 404 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
417 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000"
418 cx="-12.0982" 405 cx="-12.0982"
419 cy="341.512" 406 cy="341.51199"
420 rx="8.5" 407 id="ellipse130"
421 ry="8.5" 408 r="8.5" />
422 id="ellipse130" /> 409 <circle
423 <ellipse 410 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
424 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000"
425 cx="-12.0982" 411 cx="-12.0982"
426 cy="341.512" 412 cy="341.51199"
427 rx="8.5" 413 id="ellipse132"
428 ry="8.5" 414 r="8.5" />
429 id="ellipse132" />
430 </g> 415 </g>
431 <g 416 <g
432 id="g134" 417 id="g134"
433 style=""> 418 transform="translate(-1.4982376,-7.6949076)">
434 <line 419 <line
435 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 420 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
436 x1="-184.098" 421 x1="-184.09801"
437 y1="341.8" 422 y1="341.79999"
438 x2="-30.3343" 423 x2="-30.334299"
439 y2="341.529" 424 y2="341.52899"
440 id="line136" /> 425 id="line136" />
441 <polygon 426 <polygon
442 style="fill:#000000" 427 style="fill:#000000"
443 points="-22.8343,341.516 -32.8254,346.534 -30.3343,341.529 -32.8431,336.534 " 428 points="-32.8431,336.534 -22.8343,341.516 -32.8254,346.534 -30.3343,341.529 "
444 id="polygon138" /> 429 id="polygon138" />
445 <polygon 430 <polygon
446 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 431 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
447 points="-22.8343,341.516 -32.8254,346.534 -30.3343,341.529 -32.8431,336.534 " 432 points="-32.8431,336.534 -22.8343,341.516 -32.8254,346.534 -30.3343,341.529 "
448 id="polygon140" /> 433 id="polygon140" />
449 </g> 434 </g>
450 <text 435 <text
451 style="fill:#000000;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 436 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#000000"
452 x="-139" 437 x="-140.49823"
453 y="329" 438 y="321.30508"
454 id="text142"> 439 id="text142">
455 <tspan 440 <tspan
456 x="-139" 441 x="-140.49823"
457 y="329" 442 y="321.30508"
458 id="tspan144" 443 id="tspan144">pad 1 (sink)</tspan>
459 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">pad 1 (sink)</tspan>
460 </text> 444 </text>
461 <g 445 <g
462 id="g146" 446 id="g146"
463 style=""> 447 transform="translate(-1.4982376,-7.6949076)">
464 <rect 448 <rect
465 style="fill:#ffffff" 449 style="fill:#ffffff"
466 x="7.80824" 450 x="7.8082399"
467 y="292.8" 451 y="292.79999"
468 width="112.092" 452 width="112.092"
469 height="82.2" 453 height="82.199997"
470 id="rect148" /> 454 id="rect148" />
471 <rect 455 <rect
472 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#a52a2a" 456 style="fill:none;fill-opacity:0;stroke:#a52a2a;stroke-width:2"
473 x="7.80824" 457 x="7.8082399"
474 y="292.8" 458 y="292.79999"
475 width="112.092" 459 width="112.092"
476 height="82.2" 460 height="82.199997"
477 id="rect150" /> 461 id="rect150" />
478 </g> 462 </g>
479 <g 463 <g
480 id="g152" 464 id="g152"
481 style=""> 465 transform="translate(-1.4982376,-7.6949076)">
482 <rect 466 <rect
483 style="fill:#ffffff" 467 style="fill:#ffffff"
484 x="52.9" 468 x="52.900002"
485 y="314.8" 469 y="314.79999"
486 width="58.1" 470 width="58.099998"
487 height="50.2" 471 height="50.200001"
488 id="rect154" /> 472 id="rect154" />
489 <rect 473 <rect
490 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#0000ff" 474 style="fill:none;fill-opacity:0;stroke:#0000ff;stroke-width:2"
491 x="52.9" 475 x="52.900002"
492 y="314.8" 476 y="314.79999"
493 width="58.1" 477 width="58.099998"
494 height="50.2" 478 height="50.200001"
495 id="rect156" /> 479 id="rect156" />
496 </g> 480 </g>
497 <text 481 <text
498 style="fill:#000000;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 482 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#000000"
499 x="31.9" 483 x="30.401762"
500 y="259.8" 484 y="252.10509"
501 id="text158"> 485 id="text158">
502 <tspan 486 <tspan
503 x="31.9" 487 x="30.401762"
504 y="259.8" 488 y="252.10509"
505 id="tspan160" 489 id="tspan160" />
506 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;" />
507 </text> 490 </text>
508 <line 491 <line
509 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 492 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
510 x1="358.9" 493 x1="357.40176"
511 y1="251.9" 494 y1="244.20509"
512 x2="52.9" 495 x2="51.401764"
513 y2="314.8" 496 y2="307.10507"
514 id="line162" /> 497 id="line162" />
515 <line 498 <line
516 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 499 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
517 x1="358.9" 500 x1="357.40176"
518 y1="316" 501 y1="308.30508"
519 x2="52.9" 502 x2="51.401764"
520 y2="365" 503 y2="357.30508"
521 id="line164" /> 504 id="line164" />
522 <line 505 <line
523 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 506 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
524 x1="434" 507 x1="432.50177"
525 y1="316" 508 y1="308.30508"
526 x2="111" 509 x2="109.50176"
527 y2="365" 510 y2="357.30508"
528 id="line166" /> 511 id="line166" />
529 <line 512 <line
530 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 513 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
531 x1="434" 514 x1="432.50177"
532 y1="251.9" 515 y1="244.20509"
533 x2="111" 516 x2="109.50176"
534 y2="314.8" 517 y2="307.10507"
535 id="line168" /> 518 id="line168" />
536 <rect 519 <rect
537 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#00ff00" 520 style="fill:none;fill-opacity:0;stroke:#00ff00;stroke-width:2"
538 x="358.9" 521 x="357.40176"
539 y="251.9" 522 y="244.20509"
540 width="75.1" 523 width="75.099998"
541 height="64.1" 524 height="64.099998"
542 id="rect170" /> 525 id="rect170" />
543 <rect 526 <rect
544 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#a020f0" 527 style="fill:none;fill-opacity:0;stroke:#a020f0;stroke-width:2"
545 x="443.262" 528 x="441.76376"
546 y="284.466" 529 y="276.77109"
547 width="64.738" 530 width="64.737999"
548 height="48.534" 531 height="48.534"
549 id="rect172" /> 532 id="rect172" />
550 <g 533 <g
551 id="g174" 534 id="g174"
552 style=""> 535 transform="translate(-1.4982376,-7.6949076)">
553 <rect 536 <rect
554 style="fill:#ffffff" 537 style="fill:#ffffff"
555 x="693.428" 538 x="693.42798"
556 y="324.734" 539 y="324.73401"
557 width="63.572" 540 width="63.571999"
558 height="49.266" 541 height="49.265999"
559 id="rect176" /> 542 id="rect176" />
560 <rect 543 <rect
561 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#8b6914" 544 style="fill:none;fill-opacity:0;stroke:#8b6914;stroke-width:2"
562 x="693.428" 545 x="693.42798"
563 y="324.734" 546 y="324.73401"
564 width="63.572" 547 width="63.571999"
565 height="49.266" 548 height="49.265999"
566 id="rect178" /> 549 id="rect178" />
567 </g> 550 </g>
568 <line 551 <line
569 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 552 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
570 x1="693.428" 553 x1="691.92975"
571 y1="374" 554 y1="366.30508"
572 x2="443.262" 555 x2="441.76376"
573 y2="333" 556 y2="325.30508"
574 id="line180" /> 557 id="line180" />
575 <line 558 <line
576 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 559 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
577 x1="693.428" 560 x1="691.92975"
578 y1="324.734" 561 y1="317.03909"
579 x2="443.262" 562 x2="441.76376"
580 y2="284.466" 563 y2="276.77109"
581 id="line182" /> 564 id="line182" />
582 <line 565 <line
583 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 566 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
584 x1="757" 567 x1="755.50177"
585 y1="374" 568 y1="366.30508"
586 x2="508" 569 x2="506.50177"
587 y2="333" 570 y2="325.30508"
588 id="line184" /> 571 id="line184" />
589 <line 572 <line
590 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 573 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
591 x1="757" 574 x1="755.50177"
592 y1="324.734" 575 y1="317.03909"
593 x2="508" 576 x2="506.50177"
594 y2="284.466" 577 y2="276.77109"
595 id="line186" /> 578 id="line186" />
596 <g 579 <g
597 id="g188" 580 id="g188"
598 style=""> 581 transform="translate(-1.4982376,-7.6949076)">
599 <ellipse 582 <circle
600 style="fill:#ffffff" 583 style="fill:#ffffff"
601 cx="815.44" 584 cx="815.44"
602 cy="343.984" 585 cy="343.98401"
603 rx="8.5" 586 id="ellipse190"
604 ry="8.5" 587 r="8.5" />
605 id="ellipse190" /> 588 <circle
606 <ellipse 589 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
607 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000"
608 cx="815.44" 590 cx="815.44"
609 cy="343.984" 591 cy="343.98401"
610 rx="8.5" 592 id="ellipse192"
611 ry="8.5" 593 r="8.5" />
612 id="ellipse192" /> 594 <circle
613 <ellipse 595 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
614 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000"
615 cx="815.44" 596 cx="815.44"
616 cy="343.984" 597 cy="343.98401"
617 rx="8.5" 598 id="ellipse194"
618 ry="8.5" 599 r="8.5" />
619 id="ellipse194" />
620 </g> 600 </g>
621 <g 601 <g
622 id="g196" 602 id="g196"
623 style=""> 603 transform="translate(-1.4982376,-7.6949076)">
624 <line 604 <line
625 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 605 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
626 x1="823.94" 606 x1="823.94"
627 y1="343.984" 607 y1="343.98401"
628 x2="980.274" 608 x2="980.27399"
629 y2="344.012" 609 y2="344.01199"
630 id="line198" /> 610 id="line198" />
631 <polygon 611 <polygon
632 style="fill:#000000" 612 style="fill:#000000"
633 points="987.774,344.014 977.773,349.012 980.274,344.012 977.775,339.012 " 613 points="977.775,339.012 987.774,344.014 977.773,349.012 980.274,344.012 "
634 id="polygon200" /> 614 id="polygon200" />
635 <polygon 615 <polygon
636 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 616 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
637 points="987.774,344.014 977.773,349.012 980.274,344.012 977.775,339.012 " 617 points="977.775,339.012 987.774,344.014 977.773,349.012 980.274,344.012 "
638 id="polygon202" /> 618 id="polygon202" />
639 </g> 619 </g>
640 <text 620 <text
641 style="fill:#000000;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 621 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#000000"
642 x="849.248" 622 x="847.74976"
643 y="333.8" 623 y="326.10507"
644 id="text204"> 624 id="text204">
645 <tspan 625 <tspan
646 x="849.248" 626 x="847.74976"
647 y="333.8" 627 y="326.10507"
648 id="tspan206" 628 id="tspan206">pad 3 (source)</tspan>
649 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">pad 3 (source)</tspan>
650 </text> 629 </text>
651 <text 630 <text
652 style="fill:#0000ff;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 631 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#0000ff"
653 x="197" 632 x="195.50177"
654 y="91" 633 y="83.305092"
655 id="text208"> 634 id="text208">
656 <tspan 635 <tspan
657 x="197" 636 x="195.50177"
658 y="91" 637 y="83.305092"
659 id="tspan210" 638 id="tspan210">sink</tspan>
660 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">sink</tspan>
661 <tspan 639 <tspan
662 x="197" 640 x="195.50177"
663 y="107" 641 y="99.305092"
664 id="tspan212" 642 id="tspan212">crop</tspan>
665 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">crop</tspan>
666 <tspan 643 <tspan
667 x="197" 644 x="195.50177"
668 y="123" 645 y="115.30509"
669 id="tspan214" 646 id="tspan214">selection</tspan>
670 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">selection</tspan>
671 </text> 647 </text>
672 <text 648 <text
673 style="fill:#a020f0;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 649 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#a020f0"
674 x="553" 650 x="551.50177"
675 y="95" 651 y="87.305092"
676 id="text216"> 652 id="text216">
677 <tspan 653 <tspan
678 x="553" 654 x="551.50177"
679 y="95" 655 y="87.305092"
680 id="tspan218" 656 id="tspan218">source</tspan>
681 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">source</tspan>
682 <tspan 657 <tspan
683 x="553" 658 x="551.50177"
684 y="111" 659 y="103.30509"
685 id="tspan220" 660 id="tspan220">crop</tspan>
686 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">crop</tspan>
687 <tspan 661 <tspan
688 x="553" 662 x="551.50177"
689 y="127" 663 y="119.30509"
690 id="tspan222" 664 id="tspan222">selection</tspan>
691 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">selection</tspan>
692 </text> 665 </text>
693 <g 666 <g
694 id="g224" 667 id="g224"
695 style=""> 668 transform="translate(-1.4982376,-7.6949076)">
696 <line 669 <line
697 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#0000ff" 670 style="fill:none;fill-opacity:0;stroke:#0000ff;stroke-width:2"
698 x1="211" 671 x1="211"
699 y1="132" 672 y1="132"
700 x2="166.21" 673 x2="166.21001"
701 y2="135.287" 674 y2="135.287"
702 id="line226" /> 675 id="line226" />
703 <polygon 676 <polygon
704 style="fill:#0000ff" 677 style="fill:#0000ff"
705 points="158.73,135.836 168.337,130.118 166.21,135.287 169.069,140.091 " 678 points="169.069,140.091 158.73,135.836 168.337,130.118 166.21,135.287 "
706 id="polygon228" /> 679 id="polygon228" />
707 <polygon 680 <polygon
708 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#0000ff" 681 style="fill:none;fill-opacity:0;stroke:#0000ff;stroke-width:2"
709 points="158.73,135.836 168.337,130.118 166.21,135.287 169.069,140.091 " 682 points="169.069,140.091 158.73,135.836 168.337,130.118 166.21,135.287 "
710 id="polygon230" /> 683 id="polygon230" />
711 </g> 684 </g>
712 <g 685 <g
713 id="g232" 686 id="g232"
714 style=""> 687 transform="translate(-1.4982376,-7.6949076)">
715 <line 688 <line
716 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#0000ff" 689 style="fill:none;fill-opacity:0;stroke:#0000ff;stroke-width:2"
717 x1="209" 690 x1="209"
718 y1="131" 691 y1="131"
719 x2="115.581" 692 x2="115.581"
720 y2="306.209" 693 y2="306.20901"
721 id="line234" /> 694 id="line234" />
722 <polygon 695 <polygon
723 style="fill:#0000ff" 696 style="fill:#0000ff"
724 points="112.052,312.827 112.345,301.65 115.581,306.209 121.169,306.355 " 697 points="121.169,306.355 112.052,312.827 112.345,301.65 115.581,306.209 "
725 id="polygon236" /> 698 id="polygon236" />
726 <polygon 699 <polygon
727 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#0000ff" 700 style="fill:none;fill-opacity:0;stroke:#0000ff;stroke-width:2"
728 points="112.052,312.827 112.345,301.65 115.581,306.209 121.169,306.355 " 701 points="121.169,306.355 112.052,312.827 112.345,301.65 115.581,306.209 "
729 id="polygon238" /> 702 id="polygon238" />
730 </g> 703 </g>
731 <g 704 <g
732 id="g240" 705 id="g240"
733 style=""> 706 transform="translate(-1.4982376,-7.6949076)">
734 <line 707 <line
735 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#a020f0" 708 style="fill:none;fill-opacity:0;stroke:#a020f0;stroke-width:2"
736 x1="550.492" 709 x1="550.492"
737 y1="133.214" 710 y1="133.214"
738 x2="514.916" 711 x2="514.91602"
739 y2="186.469" 712 y2="186.46899"
740 id="line242" /> 713 id="line242" />
741 <polygon 714 <polygon
742 style="fill:#a020f0" 715 style="fill:#a020f0"
743 points="510.75,192.706 512.147,181.613 514.916,186.469 520.463,187.168 " 716 points="520.463,187.168 510.75,192.706 512.147,181.613 514.916,186.469 "
744 id="polygon244" /> 717 id="polygon244" />
745 <polygon 718 <polygon
746 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#a020f0" 719 style="fill:none;fill-opacity:0;stroke:#a020f0;stroke-width:2"
747 points="510.75,192.706 512.147,181.613 514.916,186.469 520.463,187.168 " 720 points="520.463,187.168 510.75,192.706 512.147,181.613 514.916,186.469 "
748 id="polygon246" /> 721 id="polygon246" />
749 </g> 722 </g>
750 <g 723 <g
751 id="g248" 724 id="g248"
752 style=""> 725 transform="translate(-1.4982376,-7.6949076)">
753 <line 726 <line
754 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#a020f0" 727 style="fill:none;fill-opacity:0;stroke:#a020f0;stroke-width:2"
755 x1="550.072" 728 x1="550.07202"
756 y1="133.787" 729 y1="133.787"
757 x2="510.618" 730 x2="510.61801"
758 y2="275.089" 731 y2="275.08899"
759 id="line250" /> 732 id="line250" />
760 <polygon 733 <polygon
761 style="fill:#a020f0" 734 style="fill:#a020f0"
762 points="508.601,282.312 506.475,271.336 510.618,275.089 516.106,274.025 " 735 points="516.106,274.025 508.601,282.312 506.475,271.336 510.618,275.089 "
763 id="polygon252" /> 736 id="polygon252" />
764 <polygon 737 <polygon
765 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#a020f0" 738 style="fill:none;fill-opacity:0;stroke:#a020f0;stroke-width:2"
766 points="508.601,282.312 506.475,271.336 510.618,275.089 516.106,274.025 " 739 points="516.106,274.025 508.601,282.312 506.475,271.336 510.618,275.089 "
767 id="polygon254" /> 740 id="polygon254" />
768 </g> 741 </g>
769</svg> 742</svg>
diff --git a/Documentation/media/uapi/v4l/subdev-image-processing-scaling-multi-source.svg b/Documentation/media/uapi/v4l/subdev-image-processing-scaling-multi-source.svg
index e7b3786f8a9b..cedcbf598923 100644
--- a/Documentation/media/uapi/v4l/subdev-image-processing-scaling-multi-source.svg
+++ b/Documentation/media/uapi/v4l/subdev-image-processing-scaling-multi-source.svg
@@ -7,9 +7,9 @@
7 xmlns="http://www.w3.org/2000/svg" 7 xmlns="http://www.w3.org/2000/svg"
8 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" 8 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
9 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" 9 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
10 width="59cm" 10 width="58.803326cm"
11 height="17cm" 11 height="16.463955cm"
12 viewBox="-194 128 1179 330" 12 viewBox="-194 128 1175.0698 319.59442"
13 id="svg2" 13 id="svg2"
14 version="1.1" 14 version="1.1"
15 inkscape:version="0.91 r13725" 15 inkscape:version="0.91 r13725"
@@ -22,6 +22,7 @@
22 <dc:format>image/svg+xml</dc:format> 22 <dc:format>image/svg+xml</dc:format>
23 <dc:type 23 <dc:type
24 rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> 24 rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
25 <dc:title />
25 </cc:Work> 26 </cc:Work>
26 </rdf:RDF> 27 </rdf:RDF>
27 </metadata> 28 </metadata>
@@ -40,23 +41,27 @@
40 inkscape:window-height="997" 41 inkscape:window-height="997"
41 id="namedview182" 42 id="namedview182"
42 showgrid="false" 43 showgrid="false"
44 fit-margin-top="0"
45 fit-margin-left="0"
46 fit-margin-right="0"
47 fit-margin-bottom="0"
43 inkscape:zoom="0.26595857" 48 inkscape:zoom="0.26595857"
44 inkscape:cx="1052.7956" 49 inkscape:cx="1049.9581"
45 inkscape:cy="301.1811" 50 inkscape:cy="292.5708"
46 inkscape:window-x="1920" 51 inkscape:window-x="1920"
47 inkscape:window-y="30" 52 inkscape:window-y="30"
48 inkscape:window-maximized="1" 53 inkscape:window-maximized="1"
49 inkscape:current-layer="svg2" /> 54 inkscape:current-layer="svg2" />
50 <rect 55 <rect
51 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 56 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
52 x="-8" 57 x="-9.6002426"
53 y="130" 58 y="124.14409"
54 width="806" 59 width="806"
55 height="327" 60 height="327"
56 id="rect4" /> 61 id="rect4" />
57 <g 62 <g
58 id="g6" 63 id="g6"
59 style=""> 64 transform="translate(-1.6002426,-5.8559115)">
60 <rect 65 <rect
61 style="fill:#ffffff" 66 style="fill:#ffffff"
62 x="4.5" 67 x="4.5"
@@ -65,7 +70,7 @@
65 height="104" 70 height="104"
66 id="rect8" /> 71 id="rect8" />
67 <rect 72 <rect
68 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#a52a2a" 73 style="fill:none;fill-opacity:0;stroke:#a52a2a;stroke-width:2"
69 x="4.5" 74 x="4.5"
70 y="189" 75 y="189"
71 width="159" 76 width="159"
@@ -74,7 +79,7 @@
74 </g> 79 </g>
75 <g 80 <g
76 id="g12" 81 id="g12"
77 style=""> 82 transform="translate(-1.6002426,-5.8559115)">
78 <rect 83 <rect
79 style="fill:#ffffff" 84 style="fill:#ffffff"
80 x="49.5" 85 x="49.5"
@@ -83,7 +88,7 @@
83 height="77" 88 height="77"
84 id="rect14" /> 89 id="rect14" />
85 <rect 90 <rect
86 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#0000ff" 91 style="fill:none;fill-opacity:0;stroke:#0000ff;stroke-width:2"
87 x="49.5" 92 x="49.5"
88 y="204" 93 y="204"
89 width="94" 94 width="94"
@@ -91,470 +96,445 @@
91 id="rect16" /> 96 id="rect16" />
92 </g> 97 </g>
93 <text 98 <text
94 style="fill:#0000ff;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 99 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#0000ff"
95 x="60" 100 x="58.399757"
96 y="224" 101 y="218.14409"
97 id="text18"> 102 id="text18">
98 <tspan 103 <tspan
99 x="60" 104 x="58.399757"
100 y="224" 105 y="218.14409"
101 id="tspan20" 106 id="tspan20">sink</tspan>
102 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">sink</tspan>
103 <tspan 107 <tspan
104 x="60" 108 x="58.399757"
105 y="240" 109 y="234.14409"
106 id="tspan22" 110 id="tspan22">crop</tspan>
107 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">crop</tspan>
108 <tspan 111 <tspan
109 x="60" 112 x="58.399757"
110 y="256" 113 y="250.14409"
111 id="tspan24" 114 id="tspan24">selection</tspan>
112 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">selection</tspan>
113 </text> 115 </text>
114 <text 116 <text
115 style="fill:#000000;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 117 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#000000"
116 x="29.5" 118 x="27.899757"
117 y="158" 119 y="152.14409"
118 id="text26"> 120 id="text26">
119 <tspan 121 <tspan
120 x="29.5" 122 x="27.899757"
121 y="158" 123 y="152.14409"
122 id="tspan28" 124 id="tspan28" />
123 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;" />
124 </text> 125 </text>
125 <text 126 <text
126 style="fill:#a52a2a;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 127 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#a52a2a"
127 x="8.53836" 128 x="6.938117"
128 y="157.914" 129 y="152.05809"
129 id="text30"> 130 id="text30">
130 <tspan 131 <tspan
131 x="8.53836" 132 x="6.938117"
132 y="157.914" 133 y="152.05809"
133 id="tspan32" 134 id="tspan32">sink media</tspan>
134 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">sink media</tspan>
135 <tspan 135 <tspan
136 x="8.53836" 136 x="6.938117"
137 y="173.914" 137 y="168.05809"
138 id="tspan34" 138 id="tspan34">bus format</tspan>
139 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">bus format</tspan>
140 </text> 139 </text>
141 <g 140 <g
142 id="g36" 141 id="g36"
143 style=""> 142 transform="translate(-1.6002426,-5.8559115)">
144 <rect 143 <rect
145 style="fill:#ffffff" 144 style="fill:#ffffff"
146 x="333.644" 145 x="333.64401"
147 y="185.65" 146 y="185.64999"
148 width="165.2" 147 width="165.2"
149 height="172.478" 148 height="172.478"
150 id="rect38" /> 149 id="rect38" />
151 <rect 150 <rect
152 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#00ff00" 151 style="fill:none;fill-opacity:0;stroke:#00ff00;stroke-width:2"
153 x="333.644" 152 x="333.64401"
154 y="185.65" 153 y="185.64999"
155 width="165.2" 154 width="165.2"
156 height="172.478" 155 height="172.478"
157 id="rect40" /> 156 id="rect40" />
158 </g> 157 </g>
159 <line 158 <line
160 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 159 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
161 x1="333.644" 160 x1="332.04376"
162 y1="358.128" 161 y1="352.27206"
163 x2="49.5" 162 x2="47.899757"
164 y2="281" 163 y2="275.14407"
165 id="line42" /> 164 id="line42" />
166 <line 165 <line
167 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 166 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
168 x1="333.644" 167 x1="332.04376"
169 y1="185.65" 168 y1="179.79408"
170 x2="49.5" 169 x2="47.899757"
171 y2="204" 170 y2="198.14409"
172 id="line44" /> 171 id="line44" />
173 <line 172 <line
174 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 173 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
175 x1="498.844" 174 x1="497.24374"
176 y1="358.128" 175 y1="352.27206"
177 x2="143.5" 176 x2="141.89977"
178 y2="281" 177 y2="275.14407"
179 id="line46" /> 178 id="line46" />
180 <line 179 <line
181 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 180 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
182 x1="498.844" 181 x1="497.24374"
183 y1="185.65" 182 y1="179.79408"
184 x2="143.5" 183 x2="141.89977"
185 y2="204" 184 y2="198.14409"
186 id="line48" /> 185 id="line48" />
187 <text 186 <text
188 style="fill:#00ff00;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 187 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#00ff00"
189 x="334.704" 188 x="333.10376"
190 y="149.442" 189 y="143.58609"
191 id="text50"> 190 id="text50">
192 <tspan 191 <tspan
193 x="334.704" 192 x="333.10376"
194 y="149.442" 193 y="143.58609"
195 id="tspan52" 194 id="tspan52">sink compose</tspan>
196 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">sink compose</tspan>
197 <tspan 195 <tspan
198 x="334.704" 196 x="333.10376"
199 y="165.442" 197 y="159.58609"
200 id="tspan54" 198 id="tspan54">selection (scaling)</tspan>
201 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">selection (scaling)</tspan>
202 </text> 199 </text>
203 <g 200 <g
204 id="g56" 201 id="g56"
205 style=""> 202 transform="translate(-1.6002426,-5.8559115)">
206 <rect 203 <rect
207 style="fill:#ffffff" 204 style="fill:#ffffff"
208 x="382.322" 205 x="382.32199"
209 y="199.565" 206 y="199.565"
210 width="100.186" 207 width="100.186"
211 height="71.4523" 208 height="71.452301"
212 id="rect58" /> 209 id="rect58" />
213 <rect 210 <rect
214 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#a020f0" 211 style="fill:none;fill-opacity:0;stroke:#a020f0;stroke-width:2"
215 x="382.322" 212 x="382.32199"
216 y="199.565" 213 y="199.565"
217 width="100.186" 214 width="100.186"
218 height="71.4523" 215 height="71.452301"
219 id="rect60" /> 216 id="rect60" />
220 </g> 217 </g>
221 <text 218 <text
222 style="fill:#a020f0;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 219 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#a020f0"
223 x="543.322" 220 x="541.7218"
224 y="149.442" 221 y="143.58609"
225 id="text62"> 222 id="text62">
226 <tspan 223 <tspan
227 x="543.322" 224 x="541.7218"
228 y="149.442" 225 y="143.58609"
229 id="tspan64" 226 id="tspan64">source</tspan>
230 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">source</tspan>
231 <tspan 227 <tspan
232 x="543.322" 228 x="541.7218"
233 y="165.442" 229 y="159.58609"
234 id="tspan66" 230 id="tspan66">crop</tspan>
235 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">crop</tspan>
236 <tspan 231 <tspan
237 x="543.322" 232 x="541.7218"
238 y="181.442" 233 y="175.58609"
239 id="tspan68" 234 id="tspan68">selection</tspan>
240 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">selection</tspan>
241 </text> 235 </text>
242 <text 236 <text
243 style="fill:#8b6914;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 237 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#8b6914"
244 x="691.5" 238 x="689.89978"
245 y="157.128" 239 y="151.27209"
246 id="text70"> 240 id="text70">
247 <tspan 241 <tspan
248 x="691.5" 242 x="689.89978"
249 y="157.128" 243 y="151.27209"
250 id="tspan72" 244 id="tspan72">source media</tspan>
251 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">source media</tspan>
252 <tspan 245 <tspan
253 x="691.5" 246 x="689.89978"
254 y="173.128" 247 y="167.27209"
255 id="tspan74" 248 id="tspan74">bus format</tspan>
256 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">bus format</tspan>
257 </text> 249 </text>
258 <g 250 <g
259 id="g76" 251 id="g76"
260 style=""> 252 transform="translate(-1.6002426,-5.8559115)">
261 <rect 253 <rect
262 style="fill:#ffffff" 254 style="fill:#ffffff"
263 x="690.488" 255 x="690.48798"
264 y="225.834" 256 y="225.834"
265 width="100.186" 257 width="100.186"
266 height="71.4523" 258 height="71.452301"
267 id="rect78" /> 259 id="rect78" />
268 <rect 260 <rect
269 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#8b6914" 261 style="fill:none;fill-opacity:0;stroke:#8b6914;stroke-width:2"
270 x="690.488" 262 x="690.48798"
271 y="225.834" 263 y="225.834"
272 width="100.186" 264 width="100.186"
273 height="71.4523" 265 height="71.452301"
274 id="rect80" /> 266 id="rect80" />
275 </g> 267 </g>
276 <line 268 <line
277 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 269 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
278 x1="690.488" 270 x1="688.88776"
279 y1="297.286" 271 y1="291.43008"
280 x2="382.322" 272 x2="380.72174"
281 y2="271.018" 273 y2="265.16208"
282 id="line82" /> 274 id="line82" />
283 <line 275 <line
284 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 276 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
285 x1="690.488" 277 x1="688.88776"
286 y1="225.834" 278 y1="219.97809"
287 x2="382.322" 279 x2="380.72174"
288 y2="199.565" 280 y2="193.70909"
289 id="line84" /> 281 id="line84" />
290 <line 282 <line
291 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 283 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
292 x1="790.674" 284 x1="789.07379"
293 y1="297.286" 285 y1="291.43008"
294 x2="482.508" 286 x2="480.90775"
295 y2="271.018" 287 y2="265.16208"
296 id="line86" /> 288 id="line86" />
297 <line 289 <line
298 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 290 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
299 x1="790.674" 291 x1="789.07379"
300 y1="225.834" 292 y1="219.97809"
301 x2="482.508" 293 x2="480.90775"
302 y2="199.565" 294 y2="193.70909"
303 id="line88" /> 295 id="line88" />
304 <g 296 <g
305 id="g90" 297 id="g90"
306 style=""> 298 transform="translate(-1.6002426,-5.8559115)">
307 <ellipse 299 <circle
308 style="fill:#ffffff" 300 style="fill:#ffffff"
309 cx="808.1" 301 cx="808.09998"
310 cy="249.984" 302 cy="249.98399"
311 rx="8.5" 303 id="ellipse92"
312 ry="8.5" 304 r="8.5" />
313 id="ellipse92" /> 305 <circle
314 <ellipse 306 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
315 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 307 cx="808.09998"
316 cx="808.1" 308 cy="249.98399"
317 cy="249.984" 309 id="ellipse94"
318 rx="8.5" 310 r="8.5" />
319 ry="8.5" 311 <circle
320 id="ellipse94" /> 312 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
321 <ellipse 313 cx="808.09998"
322 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 314 cy="249.98399"
323 cx="808.1" 315 id="ellipse96"
324 cy="249.984" 316 r="8.5" />
325 rx="8.5"
326 ry="8.5"
327 id="ellipse96" />
328 </g> 317 </g>
329 <g 318 <g
330 id="g98" 319 id="g98"
331 style=""> 320 transform="translate(-1.6002426,-5.8559115)">
332 <line 321 <line
333 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 322 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
334 x1="816.6" 323 x1="816.59998"
335 y1="249.984" 324 y1="249.98399"
336 x2="972.934" 325 x2="972.93402"
337 y2="250.012" 326 y2="250.01199"
338 id="line100" /> 327 id="line100" />
339 <polygon 328 <polygon
340 style="fill:#000000" 329 style="fill:#000000"
341 points="980.434,250.014 970.433,255.012 972.934,250.012 970.435,245.012 " 330 points="970.435,245.012 980.434,250.014 970.433,255.012 972.934,250.012 "
342 id="polygon102" /> 331 id="polygon102" />
343 <polygon 332 <polygon
344 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 333 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
345 points="980.434,250.014 970.433,255.012 972.934,250.012 970.435,245.012 " 334 points="970.435,245.012 980.434,250.014 970.433,255.012 972.934,250.012 "
346 id="polygon104" /> 335 id="polygon104" />
347 </g> 336 </g>
348 <text 337 <text
349 style="fill:#000000;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 338 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#000000"
350 x="841.908" 339 x="840.3078"
351 y="239.8" 340 y="233.94409"
352 id="text106"> 341 id="text106">
353 <tspan 342 <tspan
354 x="841.908" 343 x="840.3078"
355 y="239.8" 344 y="233.94409"
356 id="tspan108" 345 id="tspan108">pad 1 (source)</tspan>
357 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">pad 1 (source)</tspan>
358 </text> 346 </text>
359 <g 347 <g
360 id="g110" 348 id="g110"
361 style=""> 349 transform="translate(-1.6002426,-5.8559115)">
362 <ellipse 350 <circle
363 style="fill:#ffffff" 351 style="fill:#ffffff"
364 cx="-20.3982" 352 cx="-20.398199"
365 cy="241.512" 353 cy="241.51199"
366 rx="8.5" 354 id="ellipse112"
367 ry="8.5" 355 r="8.5" />
368 id="ellipse112" /> 356 <circle
369 <ellipse 357 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
370 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 358 cx="-20.398199"
371 cx="-20.3982" 359 cy="241.51199"
372 cy="241.512" 360 id="ellipse114"
373 rx="8.5" 361 r="8.5" />
374 ry="8.5" 362 <circle
375 id="ellipse114" /> 363 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
376 <ellipse 364 cx="-20.398199"
377 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 365 cy="241.51199"
378 cx="-20.3982" 366 id="ellipse116"
379 cy="241.512" 367 r="8.5" />
380 rx="8.5"
381 ry="8.5"
382 id="ellipse116" />
383 </g> 368 </g>
384 <g 369 <g
385 id="g118" 370 id="g118"
386 style=""> 371 transform="translate(-1.6002426,-5.8559115)">
387 <line 372 <line
388 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 373 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
389 x1="-192.398" 374 x1="-192.39799"
390 y1="241.8" 375 y1="241.8"
391 x2="-38.6343" 376 x2="-38.6343"
392 y2="241.529" 377 y2="241.52901"
393 id="line120" /> 378 id="line120" />
394 <polygon 379 <polygon
395 style="fill:#000000" 380 style="fill:#000000"
396 points="-31.1343,241.516 -41.1254,246.534 -38.6343,241.529 -41.1431,236.534 " 381 points="-41.1431,236.534 -31.1343,241.516 -41.1254,246.534 -38.6343,241.529 "
397 id="polygon122" /> 382 id="polygon122" />
398 <polygon 383 <polygon
399 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 384 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
400 points="-31.1343,241.516 -41.1254,246.534 -38.6343,241.529 -41.1431,236.534 " 385 points="-41.1431,236.534 -31.1343,241.516 -41.1254,246.534 -38.6343,241.529 "
401 id="polygon124" /> 386 id="polygon124" />
402 </g> 387 </g>
403 <text 388 <text
404 style="fill:#000000;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 389 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#000000"
405 x="-147.858" 390 x="-149.45824"
406 y="229.8" 391 y="223.94409"
407 id="text126"> 392 id="text126">
408 <tspan 393 <tspan
409 x="-147.858" 394 x="-149.45824"
410 y="229.8" 395 y="223.94409"
411 id="tspan128" 396 id="tspan128">pad 0 (sink)</tspan>
412 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">pad 0 (sink)</tspan>
413 </text> 397 </text>
414 <rect 398 <rect
415 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#a020f0" 399 style="fill:none;fill-opacity:0;stroke:#a020f0;stroke-width:2"
416 x="389.822" 400 x="388.22174"
417 y="276.666" 401 y="270.81006"
418 width="100.186" 402 width="100.186"
419 height="71.4523" 403 height="71.452301"
420 id="rect130" /> 404 id="rect130" />
421 <g 405 <g
422 id="g132" 406 id="g132"
423 style=""> 407 transform="translate(-1.6002426,-5.8559115)">
424 <rect 408 <rect
425 style="fill:#ffffff" 409 style="fill:#ffffff"
426 x="689.988" 410 x="689.98798"
427 y="345.934" 411 y="345.93399"
428 width="100.186" 412 width="100.186"
429 height="71.4523" 413 height="71.452301"
430 id="rect134" /> 414 id="rect134" />
431 <rect 415 <rect
432 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#8b6914" 416 style="fill:none;fill-opacity:0;stroke:#8b6914;stroke-width:2"
433 x="689.988" 417 x="689.98798"
434 y="345.934" 418 y="345.93399"
435 width="100.186" 419 width="100.186"
436 height="71.4523" 420 height="71.452301"
437 id="rect136" /> 421 id="rect136" />
438 </g> 422 </g>
439 <line 423 <line
440 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 424 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
441 x1="689.988" 425 x1="688.38776"
442 y1="417.386" 426 y1="411.53006"
443 x2="389.822" 427 x2="388.22174"
444 y2="348.118" 428 y2="342.26208"
445 id="line138" /> 429 id="line138" />
446 <line 430 <line
447 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 431 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
448 x1="689.988" 432 x1="688.38776"
449 y1="345.934" 433 y1="340.07806"
450 x2="389.822" 434 x2="388.22174"
451 y2="276.666" 435 y2="270.81006"
452 id="line140" /> 436 id="line140" />
453 <line 437 <line
454 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 438 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
455 x1="790.174" 439 x1="788.57379"
456 y1="417.386" 440 y1="411.53006"
457 x2="490.008" 441 x2="488.40775"
458 y2="348.118" 442 y2="342.26208"
459 id="line142" /> 443 id="line142" />
460 <line 444 <line
461 style="fill:none;fill-opacity:0;stroke-width:2;stroke-dasharray:4;stroke:#e60505" 445 style="fill:none;fill-opacity:0;stroke:#e60505;stroke-width:2;stroke-dasharray:4"
462 x1="790.174" 446 x1="788.57379"
463 y1="345.934" 447 y1="340.07806"
464 x2="490.008" 448 x2="488.40775"
465 y2="276.666" 449 y2="270.81006"
466 id="line144" /> 450 id="line144" />
467 <g 451 <g
468 id="g146" 452 id="g146"
469 style=""> 453 transform="translate(-1.6002426,-5.8559115)">
470 <ellipse 454 <circle
471 style="fill:#ffffff" 455 style="fill:#ffffff"
472 cx="805.6" 456 cx="805.59998"
473 cy="384.084" 457 cy="384.08401"
474 rx="8.5" 458 id="ellipse148"
475 ry="8.5" 459 r="8.5" />
476 id="ellipse148" /> 460 <circle
477 <ellipse 461 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
478 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 462 cx="805.59998"
479 cx="805.6" 463 cy="384.08401"
480 cy="384.084" 464 id="ellipse150"
481 rx="8.5" 465 r="8.5" />
482 ry="8.5" 466 <circle
483 id="ellipse150" /> 467 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
484 <ellipse 468 cx="805.59998"
485 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 469 cy="384.08401"
486 cx="805.6" 470 id="ellipse152"
487 cy="384.084" 471 r="8.5" />
488 rx="8.5"
489 ry="8.5"
490 id="ellipse152" />
491 </g> 472 </g>
492 <g 473 <g
493 id="g154" 474 id="g154"
494 style=""> 475 transform="translate(-1.6002426,-5.8559115)">
495 <line 476 <line
496 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 477 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
497 x1="814.1" 478 x1="814.09998"
498 y1="384.084" 479 y1="384.08401"
499 x2="970.434" 480 x2="970.43402"
500 y2="384.112" 481 y2="384.112"
501 id="line156" /> 482 id="line156" />
502 <polygon 483 <polygon
503 style="fill:#000000" 484 style="fill:#000000"
504 points="977.934,384.114 967.933,389.112 970.434,384.112 967.935,379.112 " 485 points="967.935,379.112 977.934,384.114 967.933,389.112 970.434,384.112 "
505 id="polygon158" /> 486 id="polygon158" />
506 <polygon 487 <polygon
507 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#000000" 488 style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
508 points="977.934,384.114 967.933,389.112 970.434,384.112 967.935,379.112 " 489 points="967.935,379.112 977.934,384.114 967.933,389.112 970.434,384.112 "
509 id="polygon160" /> 490 id="polygon160" />
510 </g> 491 </g>
511 <text 492 <text
512 style="fill:#000000;text-anchor:start;font-size:12.8;font-family:sans-serif;font-style:normal;font-weight:normal;-inkscape-font-specification:sans-serif;font-stretch:normal;font-variant:normal;" 493 style="font-style:normal;font-weight:normal;font-size:12.80000019px;font-family:sanserif;text-anchor:start;fill:#000000"
513 x="839.408" 494 x="837.8078"
514 y="373.9" 495 y="368.04407"
515 id="text162"> 496 id="text162">
516 <tspan 497 <tspan
517 x="839.408" 498 x="837.8078"
518 y="373.9" 499 y="368.04407"
519 id="tspan164" 500 id="tspan164">pad 2 (source)</tspan>
520 style="-inkscape-font-specification:sans-serif;font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">pad 2 (source)</tspan>
521 </text> 501 </text>
522 <g 502 <g
523 id="g166" 503 id="g166"
524 style=""> 504 transform="translate(-1.6002426,-5.8559115)">
525 <line 505 <line
526 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#a020f0" 506 style="fill:none;fill-opacity:0;stroke:#a020f0;stroke-width:2"
527 x1="546" 507 x1="546"
528 y1="191" 508 y1="191"
529 x2="492.157" 509 x2="492.15701"
530 y2="198.263" 510 y2="198.263"
531 id="line168" /> 511 id="line168" />
532 <polygon 512 <polygon
533 style="fill:#a020f0" 513 style="fill:#a020f0"
534 points="484.724,199.266 493.966,192.974 492.157,198.263 495.303,202.884 " 514 points="495.303,202.884 484.724,199.266 493.966,192.974 492.157,198.263 "
535 id="polygon170" /> 515 id="polygon170" />
536 <polygon 516 <polygon
537 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#a020f0" 517 style="fill:none;fill-opacity:0;stroke:#a020f0;stroke-width:2"
538 points="484.724,199.266 493.966,192.974 492.157,198.263 495.303,202.884 " 518 points="495.303,202.884 484.724,199.266 493.966,192.974 492.157,198.263 "
539 id="polygon172" /> 519 id="polygon172" />
540 </g> 520 </g>
541 <g 521 <g
542 id="g174" 522 id="g174"
543 style=""> 523 transform="translate(-1.6002426,-5.8559115)">
544 <line 524 <line
545 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#a020f0" 525 style="fill:none;fill-opacity:0;stroke:#a020f0;stroke-width:2"
546 x1="546.908" 526 x1="546.90802"
547 y1="190.725" 527 y1="190.72501"
548 x2="495.383" 528 x2="495.383"
549 y2="268.548" 529 y2="268.548"
550 id="line176" /> 530 id="line176" />
551 <polygon 531 <polygon
552 style="fill:#a020f0" 532 style="fill:#a020f0"
553 points="491.242,274.802 492.594,263.703 495.383,268.548 500.932,269.224 " 533 points="500.932,269.224 491.242,274.802 492.594,263.703 495.383,268.548 "
554 id="polygon178" /> 534 id="polygon178" />
555 <polygon 535 <polygon
556 style="fill:none;fill-opacity:0;stroke-width:2;stroke:#a020f0" 536 style="fill:none;fill-opacity:0;stroke:#a020f0;stroke-width:2"
557 points="491.242,274.802 492.594,263.703 495.383,268.548 500.932,269.224 " 537 points="500.932,269.224 491.242,274.802 492.594,263.703 495.383,268.548 "
558 id="polygon180" /> 538 id="polygon180" />
559 </g> 539 </g>
560</svg> 540</svg>
diff --git a/Documentation/media/uapi/v4l/v4l2.rst b/Documentation/media/uapi/v4l/v4l2.rst
index 55b959dda07e..f52a11c949d3 100644
--- a/Documentation/media/uapi/v4l/v4l2.rst
+++ b/Documentation/media/uapi/v4l/v4l2.rst
@@ -68,6 +68,10 @@ Authors, in alphabetical order:
68 68
69 - SDR API. 69 - SDR API.
70 70
71- Ribalda, Ricardo
72
73 - Introduce HSV formats and other minor changes.
74
71- Rubli, Martin 75- Rubli, Martin
72 76
73 - Designed and documented the VIDIOC_ENUM_FRAMESIZES and VIDIOC_ENUM_FRAMEINTERVALS ioctls. 77 - Designed and documented the VIDIOC_ENUM_FRAMESIZES and VIDIOC_ENUM_FRAMEINTERVALS ioctls.
@@ -89,6 +93,11 @@ part can be used and distributed without restrictions.
89Revision History 93Revision History
90**************** 94****************
91 95
96:revision: 4.10 / 2016-07-15 (*rr*)
97
98Introduce HSV formats.
99
100
92:revision: 4.5 / 2015-10-29 (*rr*) 101:revision: 4.5 / 2015-10-29 (*rr*)
93 102
94Extend VIDIOC_G_EXT_CTRLS;. Replace ctrl_class with a new union with 103Extend VIDIOC_G_EXT_CTRLS;. Replace ctrl_class with a new union with
diff --git a/Documentation/media/uapi/v4l/vidioc-g-dv-timings.rst b/Documentation/media/uapi/v4l/vidioc-g-dv-timings.rst
index 7dd943ff14cd..aea276502f5e 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-dv-timings.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-dv-timings.rst
@@ -270,3 +270,14 @@ EBUSY
270 - Some formats like SMPTE-125M have an interlaced signal with a odd 270 - Some formats like SMPTE-125M have an interlaced signal with a odd
271 total height. For these formats, if this flag is set, the first 271 total height. For these formats, if this flag is set, the first
272 field has the extra line. Else, it is the second field. 272 field has the extra line. Else, it is the second field.
273 * - ``V4L2_DV_FL_HAS_PICTURE_ASPECT``
274 - If set, then the picture_aspect field is valid. Otherwise assume that
275 the pixels are square, so the picture aspect ratio is the same as the
276 width to height ratio.
277 * - ``V4L2_DV_FL_HAS_CEA861_VIC``
278 - If set, then the cea861_vic field is valid and contains the Video
279 Identification Code as per the CEA-861 standard.
280 * - ``V4L2_DV_FL_HAS_HDMI_VIC``
281 - If set, then the hdmi_vic field is valid and contains the Video
282 Identification Code as per the HDMI standard (HDMI Vendor Specific
283 InfoFrame).
diff --git a/Documentation/media/uapi/v4l/vidioc-g-tuner.rst b/Documentation/media/uapi/v4l/vidioc-g-tuner.rst
index e8aa8cd7065f..57c79fa43866 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-tuner.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-tuner.rst
@@ -201,10 +201,10 @@ To change the radio frequency the
201 * - ``V4L2_TUNER_SDR`` 201 * - ``V4L2_TUNER_SDR``
202 - 4 202 - 4
203 - Tuner controls the A/D and/or D/A block of a 203 - Tuner controls the A/D and/or D/A block of a
204 Sofware Digital Radio (SDR) 204 Software Digital Radio (SDR)
205 * - ``V4L2_TUNER_RF`` 205 * - ``V4L2_TUNER_RF``
206 - 5 206 - 5
207 - Tuner controls the RF part of a Sofware Digital Radio (SDR) 207 - Tuner controls the RF part of a Software Digital Radio (SDR)
208 208
209 209
210.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}| 210.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
diff --git a/Documentation/media/v4l-drivers/au0828-cardlist.rst b/Documentation/media/v4l-drivers/au0828-cardlist.rst
index aed51b4ffb46..82d2567bc7c1 100644
--- a/Documentation/media/v4l-drivers/au0828-cardlist.rst
+++ b/Documentation/media/v4l-drivers/au0828-cardlist.rst
@@ -1,11 +1,13 @@
1AU0828 cards list 1AU0828 cards list
2================= 2=================
3 3
4.. code-block:: none 4=========== ========================== =======================================================================================================================
5 5Card number Card name USB IDs
6 0 -> Unknown board (au0828) 6=========== ========================== =======================================================================================================================
7 1 -> Hauppauge HVR950Q (au0828) [2040:7200,2040:7210,2040:7217,2040:721b,2040:721e,2040:721f,2040:7280,0fd9:0008,2040:7260,2040:7213,2040:7270] 70 Unknown board
8 2 -> Hauppauge HVR850 (au0828) [2040:7240] 81 Hauppauge HVR950Q 2040:7200, 2040:7210, 2040:7217, 2040:721b, 2040:721e, 2040:721f, 2040:7280, 0fd9:0008, 2040:7260, 2040:7213, 2040:7270
9 3 -> DViCO FusionHDTV USB (au0828) [0fe9:d620] 92 Hauppauge HVR850 2040:7240
10 4 -> Hauppauge HVR950Q rev xxF8 (au0828) [2040:7201,2040:7211,2040:7281] 103 DViCO FusionHDTV USB 0fe9:d620
11 5 -> Hauppauge Woodbury (au0828) [05e1:0480,2040:8200] 114 Hauppauge HVR950Q rev xxF8 2040:7201, 2040:7211, 2040:7281
125 Hauppauge Woodbury 05e1:0480, 2040:8200
13=========== ========================== =======================================================================================================================
diff --git a/Documentation/media/v4l-drivers/bttv-cardlist.rst b/Documentation/media/v4l-drivers/bttv-cardlist.rst
index 97a966e7f9c4..28a01cd6cf2e 100644
--- a/Documentation/media/v4l-drivers/bttv-cardlist.rst
+++ b/Documentation/media/v4l-drivers/bttv-cardlist.rst
@@ -1,172 +1,174 @@
1BTTV cards list 1BTTV cards list
2=============== 2===============
3 3
4.. code-block:: none 4=========== ================================================================================= ==============================================================================================================================================================================
5 5Card number Card name PCI IDs
6 0 -> *** UNKNOWN/GENERIC *** 6=========== ================================================================================= ==============================================================================================================================================================================
7 1 -> MIRO PCTV 70 *** UNKNOWN/GENERIC ***
8 2 -> Hauppauge (bt848) 81 MIRO PCTV
9 3 -> STB, Gateway P/N 6000699 (bt848) 92 Hauppauge (bt848)
10 4 -> Intel Create and Share PCI/ Smart Video Recorder III 103 STB, Gateway P/N 6000699 (bt848)
11 5 -> Diamond DTV2000 114 Intel Create and Share PCI/ Smart Video Recorder III
12 6 -> AVerMedia TVPhone 125 Diamond DTV2000
13 7 -> MATRIX-Vision MV-Delta 136 AVerMedia TVPhone
14 8 -> Lifeview FlyVideo II (Bt848) LR26 / MAXI TV Video PCI2 LR26 147 MATRIX-Vision MV-Delta
15 9 -> IMS/IXmicro TurboTV 158 Lifeview FlyVideo II (Bt848) LR26 / MAXI TV Video PCI2 LR26
16 10 -> Hauppauge (bt878) [0070:13eb,0070:3900,2636:10b4] 169 IMS/IXmicro TurboTV
17 11 -> MIRO PCTV pro 1710 Hauppauge (bt878) 0070:13eb, 0070:3900, 2636:10b4
18 12 -> ADS Technologies Channel Surfer TV (bt848) 1811 MIRO PCTV pro
19 13 -> AVerMedia TVCapture 98 [1461:0002,1461:0004,1461:0300] 1912 ADS Technologies Channel Surfer TV (bt848)
20 14 -> Aimslab Video Highway Xtreme (VHX) 2013 AVerMedia TVCapture 98 1461:0002, 1461:0004, 1461:0300
21 15 -> Zoltrix TV-Max [a1a0:a0fc] 2114 Aimslab Video Highway Xtreme (VHX)
22 16 -> Prolink Pixelview PlayTV (bt878) 2215 Zoltrix TV-Max a1a0:a0fc
23 17 -> Leadtek WinView 601 2316 Prolink Pixelview PlayTV (bt878)
24 18 -> AVEC Intercapture 2417 Leadtek WinView 601
25 19 -> Lifeview FlyVideo II EZ /FlyKit LR38 Bt848 (capture only) 2518 AVEC Intercapture
26 20 -> CEI Raffles Card 2619 Lifeview FlyVideo II EZ /FlyKit LR38 Bt848 (capture only)
27 21 -> Lifeview FlyVideo 98/ Lucky Star Image World ConferenceTV LR50 2720 CEI Raffles Card
28 22 -> Askey CPH050/ Phoebe Tv Master + FM [14ff:3002] 2821 Lifeview FlyVideo 98/ Lucky Star Image World ConferenceTV LR50
29 23 -> Modular Technology MM201/MM202/MM205/MM210/MM215 PCTV, bt878 [14c7:0101] 2922 Askey CPH050/ Phoebe Tv Master + FM 14ff:3002
30 24 -> Askey CPH05X/06X (bt878) [many vendors] [144f:3002,144f:3005,144f:5000,14ff:3000] 3023 Modular Technology MM201/MM202/MM205/MM210/MM215 PCTV, bt878 14c7:0101
31 25 -> Terratec TerraTV+ Version 1.0 (Bt848)/ Terra TValue Version 1.0/ Vobis TV-Boostar 3124 Askey CPH05X/06X (bt878) [many vendors] 144f:3002, 144f:3005, 144f:5000, 14ff:3000
32 26 -> Hauppauge WinCam newer (bt878) 3225 Terratec TerraTV+ Version 1.0 (Bt848)/ Terra TValue Version 1.0/ Vobis TV-Boostar
33 27 -> Lifeview FlyVideo 98/ MAXI TV Video PCI2 LR50 3326 Hauppauge WinCam newer (bt878)
34 28 -> Terratec TerraTV+ Version 1.1 (bt878) [153b:1127,1852:1852] 3427 Lifeview FlyVideo 98/ MAXI TV Video PCI2 LR50
35 29 -> Imagenation PXC200 [1295:200a] 3528 Terratec TerraTV+ Version 1.1 (bt878) 153b:1127, 1852:1852
36 30 -> Lifeview FlyVideo 98 LR50 [1f7f:1850] 3629 Imagenation PXC200 1295:200a
37 31 -> Formac iProTV, Formac ProTV I (bt848) 3730 Lifeview FlyVideo 98 LR50 1f7f:1850
38 32 -> Intel Create and Share PCI/ Smart Video Recorder III 3831 Formac iProTV, Formac ProTV I (bt848)
39 33 -> Terratec TerraTValue Version Bt878 [153b:1117,153b:1118,153b:1119,153b:111a,153b:1134,153b:5018] 3932 Intel Create and Share PCI/ Smart Video Recorder III
40 34 -> Leadtek WinFast 2000/ WinFast 2000 XP [107d:6606,107d:6609,6606:217d,f6ff:fff6] 4033 Terratec TerraTValue Version Bt878 153b:1117, 153b:1118, 153b:1119, 153b:111a, 153b:1134, 153b:5018
41 35 -> Lifeview FlyVideo 98 LR50 / Chronos Video Shuttle II [1851:1850,1851:a050] 4134 Leadtek WinFast 2000/ WinFast 2000 XP 107d:6606, 107d:6609, 6606:217d, f6ff:fff6
42 36 -> Lifeview FlyVideo 98FM LR50 / Typhoon TView TV/FM Tuner [1852:1852] 4235 Lifeview FlyVideo 98 LR50 / Chronos Video Shuttle II 1851:1850, 1851:a050
43 37 -> Prolink PixelView PlayTV pro 4336 Lifeview FlyVideo 98FM LR50 / Typhoon TView TV/FM Tuner 1852:1852
44 38 -> Askey CPH06X TView99 [144f:3000,144f:a005,a04f:a0fc] 4437 Prolink PixelView PlayTV pro
45 39 -> Pinnacle PCTV Studio/Rave [11bd:0012,bd11:1200,bd11:ff00,11bd:ff12] 4538 Askey CPH06X TView99 144f:3000, 144f:a005, a04f:a0fc
46 40 -> STB TV PCI FM, Gateway P/N 6000704 (bt878), 3Dfx VoodooTV 100 [10b4:2636,10b4:2645,121a:3060] 4639 Pinnacle PCTV Studio/Rave 11bd:0012, bd11:1200, bd11:ff00, 11bd:ff12
47 41 -> AVerMedia TVPhone 98 [1461:0001,1461:0003] 4740 STB TV PCI FM, Gateway P/N 6000704 (bt878), 3Dfx VoodooTV 100 10b4:2636, 10b4:2645, 121a:3060
48 42 -> ProVideo PV951 [aa0c:146c] 4841 AVerMedia TVPhone 98 1461:0001, 1461:0003
49 43 -> Little OnAir TV 4942 ProVideo PV951 aa0c:146c
50 44 -> Sigma TVII-FM 5043 Little OnAir TV
51 45 -> MATRIX-Vision MV-Delta 2 5144 Sigma TVII-FM
52 46 -> Zoltrix Genie TV/FM [15b0:4000,15b0:400a,15b0:400d,15b0:4010,15b0:4016] 5245 MATRIX-Vision MV-Delta 2
53 47 -> Terratec TV/Radio+ [153b:1123] 5346 Zoltrix Genie TV/FM 15b0:4000, 15b0:400a, 15b0:400d, 15b0:4010, 15b0:4016
54 48 -> Askey CPH03x/ Dynalink Magic TView 5447 Terratec TV/Radio+ 153b:1123
55 49 -> IODATA GV-BCTV3/PCI [10fc:4020] 5548 Askey CPH03x/ Dynalink Magic TView
56 50 -> Prolink PV-BT878P+4E / PixelView PlayTV PAK / Lenco MXTV-9578 CP 5649 IODATA GV-BCTV3/PCI 10fc:4020
57 51 -> Eagle Wireless Capricorn2 (bt878A) 5750 Prolink PV-BT878P+4E / PixelView PlayTV PAK / Lenco MXTV-9578 CP
58 52 -> Pinnacle PCTV Studio Pro 5851 Eagle Wireless Capricorn2 (bt878A)
59 53 -> Typhoon TView RDS + FM Stereo / KNC1 TV Station RDS 5952 Pinnacle PCTV Studio Pro
60 54 -> Lifeview FlyVideo 2000 /FlyVideo A2/ Lifetec LT 9415 TV [LR90] 6053 Typhoon TView RDS + FM Stereo / KNC1 TV Station RDS
61 55 -> Askey CPH031/ BESTBUY Easy TV 6154 Lifeview FlyVideo 2000 /FlyVideo A2/ Lifetec LT 9415 TV [LR90]
62 56 -> Lifeview FlyVideo 98FM LR50 [a051:41a0] 6255 Askey CPH031/ BESTBUY Easy TV
63 57 -> GrandTec 'Grand Video Capture' (Bt848) [4344:4142] 6356 Lifeview FlyVideo 98FM LR50 a051:41a0
64 58 -> Askey CPH060/ Phoebe TV Master Only (No FM) 6457 GrandTec 'Grand Video Capture' (Bt848) 4344:4142
65 59 -> Askey CPH03x TV Capturer 6558 Askey CPH060/ Phoebe TV Master Only (No FM)
66 60 -> Modular Technology MM100PCTV 6659 Askey CPH03x TV Capturer
67 61 -> AG Electronics GMV1 [15cb:0101] 6760 Modular Technology MM100PCTV
68 62 -> Askey CPH061/ BESTBUY Easy TV (bt878) 6861 AG Electronics GMV1 15cb:0101
69 63 -> ATI TV-Wonder [1002:0001] 6962 Askey CPH061/ BESTBUY Easy TV (bt878)
70 64 -> ATI TV-Wonder VE [1002:0003] 7063 ATI TV-Wonder 1002:0001
71 65 -> Lifeview FlyVideo 2000S LR90 7164 ATI TV-Wonder VE 1002:0003
72 66 -> Terratec TValueRadio [153b:1135,153b:ff3b] 7265 Lifeview FlyVideo 2000S LR90
73 67 -> IODATA GV-BCTV4/PCI [10fc:4050] 7366 Terratec TValueRadio 153b:1135, 153b:ff3b
74 68 -> 3Dfx VoodooTV FM (Euro) [10b4:2637] 7467 IODATA GV-BCTV4/PCI 10fc:4050
75 69 -> Active Imaging AIMMS 7568 3Dfx VoodooTV FM (Euro) 10b4:2637
76 70 -> Prolink Pixelview PV-BT878P+ (Rev.4C,8E) 7669 Active Imaging AIMMS
77 71 -> Lifeview FlyVideo 98EZ (capture only) LR51 [1851:1851] 7770 Prolink Pixelview PV-BT878P+ (Rev.4C,8E)
78 72 -> Prolink Pixelview PV-BT878P+9B (PlayTV Pro rev.9B FM+NICAM) [1554:4011] 7871 Lifeview FlyVideo 98EZ (capture only) LR51 1851:1851
79 73 -> Sensoray 311/611 [6000:0311,6000:0611] 7972 Prolink Pixelview PV-BT878P+9B (PlayTV Pro rev.9B FM+NICAM) 1554:4011
80 74 -> RemoteVision MX (RV605) 8073 Sensoray 311/611 6000:0311, 6000:0611
81 75 -> Powercolor MTV878/ MTV878R/ MTV878F 8174 RemoteVision MX (RV605)
82 76 -> Canopus WinDVR PCI (COMPAQ Presario 3524JP, 5112JP) [0e11:0079] 8275 Powercolor MTV878/ MTV878R/ MTV878F
83 77 -> GrandTec Multi Capture Card (Bt878) 8376 Canopus WinDVR PCI (COMPAQ Presario 3524JP, 5112JP) 0e11:0079
84 78 -> Jetway TV/Capture JW-TV878-FBK, Kworld KW-TV878RF [0a01:17de] 8477 GrandTec Multi Capture Card (Bt878)
85 79 -> DSP Design TCVIDEO 8578 Jetway TV/Capture JW-TV878-FBK, Kworld KW-TV878RF 0a01:17de
86 80 -> Hauppauge WinTV PVR [0070:4500] 8679 DSP Design TCVIDEO
87 81 -> IODATA GV-BCTV5/PCI [10fc:4070,10fc:d018] 8780 Hauppauge WinTV PVR 0070:4500
88 82 -> Osprey 100/150 (878) [0070:ff00] 8881 IODATA GV-BCTV5/PCI 10fc:4070, 10fc:d018
89 83 -> Osprey 100/150 (848) 8982 Osprey 100/150 (878) 0070:ff00
90 84 -> Osprey 101 (848) 9083 Osprey 100/150 (848)
91 85 -> Osprey 101/151 9184 Osprey 101 (848)
92 86 -> Osprey 101/151 w/ svid 9285 Osprey 101/151
93 87 -> Osprey 200/201/250/251 9386 Osprey 101/151 w/ svid
94 88 -> Osprey 200/250 [0070:ff01] 9487 Osprey 200/201/250/251
95 89 -> Osprey 210/220/230 9588 Osprey 200/250 0070:ff01
96 90 -> Osprey 500 [0070:ff02] 9689 Osprey 210/220/230
97 91 -> Osprey 540 [0070:ff04] 9790 Osprey 500 0070:ff02
98 92 -> Osprey 2000 [0070:ff03] 9891 Osprey 540 0070:ff04
99 93 -> IDS Eagle 9992 Osprey 2000 0070:ff03
100 94 -> Pinnacle PCTV Sat [11bd:001c] 10093 IDS Eagle
101 95 -> Formac ProTV II (bt878) 10194 Pinnacle PCTV Sat 11bd:001c
102 96 -> MachTV 10295 Formac ProTV II (bt878)
103 97 -> Euresys Picolo 10396 MachTV
104 98 -> ProVideo PV150 [aa00:1460,aa01:1461,aa02:1462,aa03:1463,aa04:1464,aa05:1465,aa06:1466,aa07:1467] 10497 Euresys Picolo
105 99 -> AD-TVK503 10598 ProVideo PV150 aa00:1460, aa01:1461, aa02:1462, aa03:1463, aa04:1464, aa05:1465, aa06:1466, aa07:1467
106 100 -> Hercules Smart TV Stereo 10699 AD-TVK503
107 101 -> Pace TV & Radio Card 107100 Hercules Smart TV Stereo
108 102 -> IVC-200 [0000:a155,0001:a155,0002:a155,0003:a155,0100:a155,0101:a155,0102:a155,0103:a155,0800:a155,0801:a155,0802:a155,0803:a155] 108101 Pace TV & Radio Card
109 103 -> Grand X-Guard / Trust 814PCI [0304:0102] 109102 IVC-200 0000:a155, 0001:a155, 0002:a155, 0003:a155, 0100:a155, 0101:a155, 0102:a155, 0103:a155, 0800:a155, 0801:a155, 0802:a155, 0803:a155
110 104 -> Nebula Electronics DigiTV [0071:0101] 110103 Grand X-Guard / Trust 814PCI 0304:0102
111 105 -> ProVideo PV143 [aa00:1430,aa00:1431,aa00:1432,aa00:1433,aa03:1433] 111104 Nebula Electronics DigiTV 0071:0101
112 106 -> PHYTEC VD-009-X1 VD-011 MiniDIN (bt878) 112105 ProVideo PV143 aa00:1430, aa00:1431, aa00:1432, aa00:1433, aa03:1433
113 107 -> PHYTEC VD-009-X1 VD-011 Combi (bt878) 113106 PHYTEC VD-009-X1 VD-011 MiniDIN (bt878)
114 108 -> PHYTEC VD-009 MiniDIN (bt878) 114107 PHYTEC VD-009-X1 VD-011 Combi (bt878)
115 109 -> PHYTEC VD-009 Combi (bt878) 115108 PHYTEC VD-009 MiniDIN (bt878)
116 110 -> IVC-100 [ff00:a132] 116109 PHYTEC VD-009 Combi (bt878)
117 111 -> IVC-120G [ff00:a182,ff01:a182,ff02:a182,ff03:a182,ff04:a182,ff05:a182,ff06:a182,ff07:a182,ff08:a182,ff09:a182,ff0a:a182,ff0b:a182,ff0c:a182,ff0d:a182,ff0e:a182,ff0f:a182] 117110 IVC-100 ff00:a132
118 112 -> pcHDTV HD-2000 TV [7063:2000] 118111 IVC-120G ff00:a182, ff01:a182, ff02:a182, ff03:a182, ff04:a182, ff05:a182, ff06:a182, ff07:a182, ff08:a182, ff09:a182, ff0a:a182, ff0b:a182, ff0c:a182, ff0d:a182, ff0e:a182, ff0f:a182
119 113 -> Twinhan DST + clones [11bd:0026,1822:0001,270f:fc00,1822:0026] 119112 pcHDTV HD-2000 TV 7063:2000
120 114 -> Winfast VC100 [107d:6607] 120113 Twinhan DST + clones 11bd:0026, 1822:0001, 270f:fc00, 1822:0026
121 115 -> Teppro TEV-560/InterVision IV-560 121114 Winfast VC100 107d:6607
122 116 -> SIMUS GVC1100 [aa6a:82b2] 122115 Teppro TEV-560/InterVision IV-560
123 117 -> NGS NGSTV+ 123116 SIMUS GVC1100 aa6a:82b2
124 118 -> LMLBT4 124117 NGS NGSTV+
125 119 -> Tekram M205 PRO 125118 LMLBT4
126 120 -> Conceptronic CONTVFMi 126119 Tekram M205 PRO
127 121 -> Euresys Picolo Tetra [1805:0105,1805:0106,1805:0107,1805:0108] 127120 Conceptronic CONTVFMi
128 122 -> Spirit TV Tuner 128121 Euresys Picolo Tetra 1805:0105, 1805:0106, 1805:0107, 1805:0108
129 123 -> AVerMedia AVerTV DVB-T 771 [1461:0771] 129122 Spirit TV Tuner
130 124 -> AverMedia AverTV DVB-T 761 [1461:0761] 130123 AVerMedia AVerTV DVB-T 771 1461:0771
131 125 -> MATRIX Vision Sigma-SQ 131124 AverMedia AverTV DVB-T 761 1461:0761
132 126 -> MATRIX Vision Sigma-SLC 132125 MATRIX Vision Sigma-SQ
133 127 -> APAC Viewcomp 878(AMAX) 133126 MATRIX Vision Sigma-SLC
134 128 -> DViCO FusionHDTV DVB-T Lite [18ac:db10,18ac:db11] 134127 APAC Viewcomp 878(AMAX)
135 129 -> V-Gear MyVCD 135128 DViCO FusionHDTV DVB-T Lite 18ac:db10, 18ac:db11
136 130 -> Super TV Tuner 136129 V-Gear MyVCD
137 131 -> Tibet Systems 'Progress DVR' CS16 137130 Super TV Tuner
138 132 -> Kodicom 4400R (master) 138131 Tibet Systems 'Progress DVR' CS16
139 133 -> Kodicom 4400R (slave) 139132 Kodicom 4400R (master)
140 134 -> Adlink RTV24 140133 Kodicom 4400R (slave)
141 135 -> DViCO FusionHDTV 5 Lite [18ac:d500] 141134 Adlink RTV24
142 136 -> Acorp Y878F [9511:1540] 142135 DViCO FusionHDTV 5 Lite 18ac:d500
143 137 -> Conceptronic CTVFMi v2 [036e:109e] 143136 Acorp Y878F 9511:1540
144 138 -> Prolink Pixelview PV-BT878P+ (Rev.2E) 144137 Conceptronic CTVFMi v2 036e:109e
145 139 -> Prolink PixelView PlayTV MPEG2 PV-M4900 145138 Prolink Pixelview PV-BT878P+ (Rev.2E)
146 140 -> Osprey 440 [0070:ff07] 146139 Prolink PixelView PlayTV MPEG2 PV-M4900
147 141 -> Asound Skyeye PCTV 147140 Osprey 440 0070:ff07
148 142 -> Sabrent TV-FM (bttv version) 148141 Asound Skyeye PCTV
149 143 -> Hauppauge ImpactVCB (bt878) [0070:13eb] 149142 Sabrent TV-FM (bttv version)
150 144 -> MagicTV 150143 Hauppauge ImpactVCB (bt878) 0070:13eb
151 145 -> SSAI Security Video Interface [4149:5353] 151144 MagicTV
152 146 -> SSAI Ultrasound Video Interface [414a:5353] 152145 SSAI Security Video Interface 4149:5353
153 147 -> VoodooTV 200 (USA) [121a:3000] 153146 SSAI Ultrasound Video Interface 414a:5353
154 148 -> DViCO FusionHDTV 2 [dbc0:d200] 154147 VoodooTV 200 (USA) 121a:3000
155 149 -> Typhoon TV-Tuner PCI (50684) 155148 DViCO FusionHDTV 2 dbc0:d200
156 150 -> Geovision GV-600 [008a:763c] 156149 Typhoon TV-Tuner PCI (50684)
157 151 -> Kozumi KTV-01C 157150 Geovision GV-600 008a:763c
158 152 -> Encore ENL TV-FM-2 [1000:1801] 158151 Kozumi KTV-01C
159 153 -> PHYTEC VD-012 (bt878) 159152 Encore ENL TV-FM-2 1000:1801
160 154 -> PHYTEC VD-012-X1 (bt878) 160153 PHYTEC VD-012 (bt878)
161 155 -> PHYTEC VD-012-X2 (bt878) 161154 PHYTEC VD-012-X1 (bt878)
162 156 -> IVCE-8784 [0000:f050,0001:f050,0002:f050,0003:f050] 162155 PHYTEC VD-012-X2 (bt878)
163 157 -> Geovision GV-800(S) (master) [800a:763d] 163156 IVCE-8784 0000:f050, 0001:f050, 0002:f050, 0003:f050
164 158 -> Geovision GV-800(S) (slave) [800b:763d,800c:763d,800d:763d] 164157 Geovision GV-800(S) (master) 800a:763d
165 159 -> ProVideo PV183 [1830:1540,1831:1540,1832:1540,1833:1540,1834:1540,1835:1540,1836:1540,1837:1540] 165158 Geovision GV-800(S) (slave) 800b:763d, 800c:763d, 800d:763d
166 160 -> Tongwei Video Technology TD-3116 [f200:3116] 166159 ProVideo PV183 1830:1540, 1831:1540, 1832:1540, 1833:1540, 1834:1540, 1835:1540, 1836:1540, 1837:1540
167 161 -> Aposonic W-DVR [0279:0228] 167160 Tongwei Video Technology TD-3116 f200:3116
168 162 -> Adlink MPG24 168161 Aposonic W-DVR 0279:0228
169 163 -> Bt848 Capture 14MHz 169162 Adlink MPG24
170 164 -> CyberVision CV06 (SV) 170163 Bt848 Capture 14MHz
171 165 -> Kworld V-Stream Xpert TV PVR878 171164 CyberVision CV06 (SV)
172 166 -> PCI-8604PW 172165 Kworld V-Stream Xpert TV PVR878
173166 PCI-8604PW
174=========== ================================================================================= ==============================================================================================================================================================================
diff --git a/Documentation/media/v4l-drivers/cx23885-cardlist.rst b/Documentation/media/v4l-drivers/cx23885-cardlist.rst
index f38003255b9a..fd20b50d2c1d 100644
--- a/Documentation/media/v4l-drivers/cx23885-cardlist.rst
+++ b/Documentation/media/v4l-drivers/cx23885-cardlist.rst
@@ -1,63 +1,65 @@
1cx23885 cards list 1cx23885 cards list
2================== 2==================
3 3
4.. code-block:: none 4=========== ==================================== ======================================================================================
5 5Card number Card name PCI IDs
6 0 -> UNKNOWN/GENERIC [0070:3400] 6=========== ==================================== ======================================================================================
7 1 -> Hauppauge WinTV-HVR1800lp [0070:7600] 70 UNKNOWN/GENERIC 0070:3400
8 2 -> Hauppauge WinTV-HVR1800 [0070:7800,0070:7801,0070:7809] 81 Hauppauge WinTV-HVR1800lp 0070:7600
9 3 -> Hauppauge WinTV-HVR1250 [0070:7911] 92 Hauppauge WinTV-HVR1800 0070:7800, 0070:7801, 0070:7809
10 4 -> DViCO FusionHDTV5 Express [18ac:d500] 103 Hauppauge WinTV-HVR1250 0070:7911
11 5 -> Hauppauge WinTV-HVR1500Q [0070:7790,0070:7797] 114 DViCO FusionHDTV5 Express 18ac:d500
12 6 -> Hauppauge WinTV-HVR1500 [0070:7710,0070:7717] 125 Hauppauge WinTV-HVR1500Q 0070:7790, 0070:7797
13 7 -> Hauppauge WinTV-HVR1200 [0070:71d1,0070:71d3] 136 Hauppauge WinTV-HVR1500 0070:7710, 0070:7717
14 8 -> Hauppauge WinTV-HVR1700 [0070:8101] 147 Hauppauge WinTV-HVR1200 0070:71d1, 0070:71d3
15 9 -> Hauppauge WinTV-HVR1400 [0070:8010] 158 Hauppauge WinTV-HVR1700 0070:8101
16 10 -> DViCO FusionHDTV7 Dual Express [18ac:d618] 169 Hauppauge WinTV-HVR1400 0070:8010
17 11 -> DViCO FusionHDTV DVB-T Dual Express [18ac:db78] 1710 DViCO FusionHDTV7 Dual Express 18ac:d618
18 12 -> Leadtek Winfast PxDVR3200 H [107d:6681] 1811 DViCO FusionHDTV DVB-T Dual Express 18ac:db78
19 13 -> Compro VideoMate E650F [185b:e800] 1912 Leadtek Winfast PxDVR3200 H 107d:6681
20 14 -> TurboSight TBS 6920 [6920:8888] 2013 Compro VideoMate E650F 185b:e800
21 15 -> TeVii S470 [d470:9022] 2114 TurboSight TBS 6920 6920:8888
22 16 -> DVBWorld DVB-S2 2005 [0001:2005] 2215 TeVii S470 d470:9022
23 17 -> NetUP Dual DVB-S2 CI [1b55:2a2c] 2316 DVBWorld DVB-S2 2005 0001:2005
24 18 -> Hauppauge WinTV-HVR1270 [0070:2211] 2417 NetUP Dual DVB-S2 CI 1b55:2a2c
25 19 -> Hauppauge WinTV-HVR1275 [0070:2215,0070:221d,0070:22f2] 2518 Hauppauge WinTV-HVR1270 0070:2211
26 20 -> Hauppauge WinTV-HVR1255 [0070:2251,0070:22f1] 2619 Hauppauge WinTV-HVR1275 0070:2215, 0070:221d, 0070:22f2
27 21 -> Hauppauge WinTV-HVR1210 [0070:2291,0070:2295,0070:2299,0070:229d,0070:22f0,0070:22f3,0070:22f4,0070:22f5] 2720 Hauppauge WinTV-HVR1255 0070:2251, 0070:22f1
28 22 -> Mygica X8506 DMB-TH [14f1:8651] 2821 Hauppauge WinTV-HVR1210 0070:2291, 0070:2295, 0070:2299, 0070:229d, 0070:22f0, 0070:22f3, 0070:22f4, 0070:22f5
29 23 -> Magic-Pro ProHDTV Extreme 2 [14f1:8657] 2922 Mygica X8506 DMB-TH 14f1:8651
30 24 -> Hauppauge WinTV-HVR1850 [0070:8541] 3023 Magic-Pro ProHDTV Extreme 2 14f1:8657
31 25 -> Compro VideoMate E800 [1858:e800] 3124 Hauppauge WinTV-HVR1850 0070:8541
32 26 -> Hauppauge WinTV-HVR1290 [0070:8551] 3225 Compro VideoMate E800 1858:e800
33 27 -> Mygica X8558 PRO DMB-TH [14f1:8578] 3326 Hauppauge WinTV-HVR1290 0070:8551
34 28 -> LEADTEK WinFast PxTV1200 [107d:6f22] 3427 Mygica X8558 PRO DMB-TH 14f1:8578
35 29 -> GoTView X5 3D Hybrid [5654:2390] 3528 LEADTEK WinFast PxTV1200 107d:6f22
36 30 -> NetUP Dual DVB-T/C-CI RF [1b55:e2e4] 3629 GoTView X5 3D Hybrid 5654:2390
37 31 -> Leadtek Winfast PxDVR3200 H XC4000 [107d:6f39] 3730 NetUP Dual DVB-T/C-CI RF 1b55:e2e4
38 32 -> MPX-885 3831 Leadtek Winfast PxDVR3200 H XC4000 107d:6f39
39 33 -> Mygica X8502/X8507 ISDB-T [14f1:8502] 3932 MPX-885
40 34 -> TerraTec Cinergy T PCIe Dual [153b:117e] 4033 Mygica X8502/X8507 ISDB-T 14f1:8502
41 35 -> TeVii S471 [d471:9022] 4134 TerraTec Cinergy T PCIe Dual 153b:117e
42 36 -> Hauppauge WinTV-HVR1255 [0070:2259] 4235 TeVii S471 d471:9022
43 37 -> Prof Revolution DVB-S2 8000 [8000:3034] 4336 Hauppauge WinTV-HVR1255 0070:2259
44 38 -> Hauppauge WinTV-HVR4400/HVR5500 [0070:c108,0070:c138,0070:c1f8] 4437 Prof Revolution DVB-S2 8000 8000:3034
45 39 -> AVerTV Hybrid Express Slim HC81R [1461:d939] 4538 Hauppauge WinTV-HVR4400/HVR5500 0070:c108, 0070:c138, 0070:c1f8
46 40 -> TurboSight TBS 6981 [6981:8888] 4639 AVerTV Hybrid Express Slim HC81R 1461:d939
47 41 -> TurboSight TBS 6980 [6980:8888] 4740 TurboSight TBS 6981 6981:8888
48 42 -> Leadtek Winfast PxPVR2200 [107d:6f21] 4841 TurboSight TBS 6980 6980:8888
49 43 -> Hauppauge ImpactVCB-e [0070:7133] 4942 Leadtek Winfast PxPVR2200 107d:6f21
50 44 -> DViCO FusionHDTV DVB-T Dual Express2 [18ac:db98] 5043 Hauppauge ImpactVCB-e 0070:7133
51 45 -> DVBSky T9580 [4254:9580] 5144 DViCO FusionHDTV DVB-T Dual Express2 18ac:db98
52 46 -> DVBSky T980C [4254:980c] 5245 DVBSky T9580 4254:9580
53 47 -> DVBSky S950C [4254:950c] 5346 DVBSky T980C 4254:980c
54 48 -> Technotrend TT-budget CT2-4500 CI [13c2:3013] 5447 DVBSky S950C 4254:950c
55 49 -> DVBSky S950 [4254:0950] 5548 Technotrend TT-budget CT2-4500 CI 13c2:3013
56 50 -> DVBSky S952 [4254:0952] 5649 DVBSky S950 4254:0950
57 51 -> DVBSky T982 [4254:0982] 5750 DVBSky S952 4254:0952
58 52 -> Hauppauge WinTV-HVR5525 [0070:f038] 5851 DVBSky T982 4254:0982
59 53 -> Hauppauge WinTV Starburst [0070:c12a] 5952 Hauppauge WinTV-HVR5525 0070:f038
60 54 -> ViewCast 260e [1576:0260] 6053 Hauppauge WinTV Starburst 0070:c12a
61 55 -> ViewCast 460e [1576:0460] 6154 ViewCast 260e 1576:0260
62 56 -> Hauppauge WinTV-QuadHD-DVB [0070:6a28,0070:6b28] 6255 ViewCast 460e 1576:0460
63 57 -> Hauppauge WinTV-QuadHD-ATSC [0070:6a18,0070:6b18] 6356 Hauppauge WinTV-QuadHD-DVB 0070:6a28, 0070:6b28
6457 Hauppauge WinTV-QuadHD-ATSC 0070:6a18, 0070:6b18
65=========== ==================================== ======================================================================================
diff --git a/Documentation/media/v4l-drivers/cx88-cardlist.rst b/Documentation/media/v4l-drivers/cx88-cardlist.rst
index 01128341e1ea..8cc1cea17035 100644
--- a/Documentation/media/v4l-drivers/cx88-cardlist.rst
+++ b/Documentation/media/v4l-drivers/cx88-cardlist.rst
@@ -1,96 +1,98 @@
1CX88 cards list 1CX88 cards list
2=============== 2===============
3 3
4.. code-block:: none 4=========== =================================================== ======================================================================================
5 5Card number Card name PCI IDs
6 0 -> UNKNOWN/GENERIC 6=========== =================================================== ======================================================================================
7 1 -> Hauppauge WinTV 34xxx models [0070:3400,0070:3401] 70 UNKNOWN/GENERIC
8 2 -> GDI Black Gold [14c7:0106,14c7:0107] 81 Hauppauge WinTV 34xxx models 0070:3400, 0070:3401
9 3 -> PixelView [1554:4811] 92 GDI Black Gold 14c7:0106, 14c7:0107
10 4 -> ATI TV Wonder Pro [1002:00f8,1002:00f9] 103 PixelView 1554:4811
11 5 -> Leadtek Winfast 2000XP Expert [107d:6611,107d:6613] 114 ATI TV Wonder Pro 1002:00f8, 1002:00f9
12 6 -> AverTV Studio 303 (M126) [1461:000b] 125 Leadtek Winfast 2000XP Expert 107d:6611, 107d:6613
13 7 -> MSI TV-@nywhere Master [1462:8606] 136 AverTV Studio 303 (M126) 1461:000b
14 8 -> Leadtek Winfast DV2000 [107d:6620,107d:6621] 147 MSI TV-@nywhere Master 1462:8606
15 9 -> Leadtek PVR 2000 [107d:663b,107d:663c,107d:6632,107d:6630,107d:6638,107d:6631,107d:6637,107d:663d] 158 Leadtek Winfast DV2000 107d:6620, 107d:6621
16 10 -> IODATA GV-VCP3/PCI [10fc:d003] 169 Leadtek PVR 2000 107d:663b, 107d:663c, 107d:6632, 107d:6630, 107d:6638, 107d:6631, 107d:6637, 107d:663d
17 11 -> Prolink PlayTV PVR 1710 IODATA GV-VCP3/PCI 10fc:d003
18 12 -> ASUS PVR-416 [1043:4823,1461:c111] 1811 Prolink PlayTV PVR
19 13 -> MSI TV-@nywhere 1912 ASUS PVR-416 1043:4823, 1461:c111
20 14 -> KWorld/VStream XPert DVB-T [17de:08a6] 2013 MSI TV-@nywhere
21 15 -> DViCO FusionHDTV DVB-T1 [18ac:db00] 2114 KWorld/VStream XPert DVB-T 17de:08a6
22 16 -> KWorld LTV883RF 2215 DViCO FusionHDTV DVB-T1 18ac:db00
23 17 -> DViCO FusionHDTV 3 Gold-Q [18ac:d810,18ac:d800] 2316 KWorld LTV883RF
24 18 -> Hauppauge Nova-T DVB-T [0070:9002,0070:9001,0070:9000] 2417 DViCO FusionHDTV 3 Gold-Q 18ac:d810, 18ac:d800
25 19 -> Conexant DVB-T reference design [14f1:0187] 2518 Hauppauge Nova-T DVB-T 0070:9002, 0070:9001, 0070:9000
26 20 -> Provideo PV259 [1540:2580] 2619 Conexant DVB-T reference design 14f1:0187
27 21 -> DViCO FusionHDTV DVB-T Plus [18ac:db10,18ac:db11] 2720 Provideo PV259 1540:2580
28 22 -> pcHDTV HD3000 HDTV [7063:3000] 2821 DViCO FusionHDTV DVB-T Plus 18ac:db10, 18ac:db11
29 23 -> digitalnow DNTV Live! DVB-T [17de:a8a6] 2922 pcHDTV HD3000 HDTV 7063:3000
30 24 -> Hauppauge WinTV 28xxx (Roslyn) models [0070:2801] 3023 digitalnow DNTV Live! DVB-T 17de:a8a6
31 25 -> Digital-Logic MICROSPACE Entertainment Center (MEC) [14f1:0342] 3124 Hauppauge WinTV 28xxx (Roslyn) models 0070:2801
32 26 -> IODATA GV/BCTV7E [10fc:d035] 3225 Digital-Logic MICROSPACE Entertainment Center (MEC) 14f1:0342
33 27 -> PixelView PlayTV Ultra Pro (Stereo) 3326 IODATA GV/BCTV7E 10fc:d035
34 28 -> DViCO FusionHDTV 3 Gold-T [18ac:d820] 3427 PixelView PlayTV Ultra Pro (Stereo)
35 29 -> ADS Tech Instant TV DVB-T PCI [1421:0334] 3528 DViCO FusionHDTV 3 Gold-T 18ac:d820
36 30 -> TerraTec Cinergy 1400 DVB-T [153b:1166] 3629 ADS Tech Instant TV DVB-T PCI 1421:0334
37 31 -> DViCO FusionHDTV 5 Gold [18ac:d500] 3730 TerraTec Cinergy 1400 DVB-T 153b:1166
38 32 -> AverMedia UltraTV Media Center PCI 550 [1461:8011] 3831 DViCO FusionHDTV 5 Gold 18ac:d500
39 33 -> Kworld V-Stream Xpert DVD 3932 AverMedia UltraTV Media Center PCI 550 1461:8011
40 34 -> ATI HDTV Wonder [1002:a101] 4033 Kworld V-Stream Xpert DVD
41 35 -> WinFast DTV1000-T [107d:665f] 4134 ATI HDTV Wonder 1002:a101
42 36 -> AVerTV 303 (M126) [1461:000a] 4235 WinFast DTV1000-T 107d:665f
43 37 -> Hauppauge Nova-S-Plus DVB-S [0070:9201,0070:9202] 4336 AVerTV 303 (M126) 1461:000a
44 38 -> Hauppauge Nova-SE2 DVB-S [0070:9200] 4437 Hauppauge Nova-S-Plus DVB-S 0070:9201, 0070:9202
45 39 -> KWorld DVB-S 100 [17de:08b2,1421:0341] 4538 Hauppauge Nova-SE2 DVB-S 0070:9200
46 40 -> Hauppauge WinTV-HVR1100 DVB-T/Hybrid [0070:9400,0070:9402] 4639 KWorld DVB-S 100 17de:08b2, 1421:0341
47 41 -> Hauppauge WinTV-HVR1100 DVB-T/Hybrid (Low Profile) [0070:9800,0070:9802] 4740 Hauppauge WinTV-HVR1100 DVB-T/Hybrid 0070:9400, 0070:9402
48 42 -> digitalnow DNTV Live! DVB-T Pro [1822:0025,1822:0019] 4841 Hauppauge WinTV-HVR1100 DVB-T/Hybrid (Low Profile) 0070:9800, 0070:9802
49 43 -> KWorld/VStream XPert DVB-T with cx22702 [17de:08a1,12ab:2300] 4942 digitalnow DNTV Live! DVB-T Pro 1822:0025, 1822:0019
50 44 -> DViCO FusionHDTV DVB-T Dual Digital [18ac:db50,18ac:db54] 5043 KWorld/VStream XPert DVB-T with cx22702 17de:08a1, 12ab:2300
51 45 -> KWorld HardwareMpegTV XPert [17de:0840,1421:0305] 5144 DViCO FusionHDTV DVB-T Dual Digital 18ac:db50, 18ac:db54
52 46 -> DViCO FusionHDTV DVB-T Hybrid [18ac:db40,18ac:db44] 5245 KWorld HardwareMpegTV XPert 17de:0840, 1421:0305
53 47 -> pcHDTV HD5500 HDTV [7063:5500] 5346 DViCO FusionHDTV DVB-T Hybrid 18ac:db40, 18ac:db44
54 48 -> Kworld MCE 200 Deluxe [17de:0841] 5447 pcHDTV HD5500 HDTV 7063:5500
55 49 -> PixelView PlayTV P7000 [1554:4813] 5548 Kworld MCE 200 Deluxe 17de:0841
56 50 -> NPG Tech Real TV FM Top 10 [14f1:0842] 5649 PixelView PlayTV P7000 1554:4813
57 51 -> WinFast DTV2000 H [107d:665e] 5750 NPG Tech Real TV FM Top 10 14f1:0842
58 52 -> Geniatech DVB-S [14f1:0084] 5851 WinFast DTV2000 H 107d:665e
59 53 -> Hauppauge WinTV-HVR3000 TriMode Analog/DVB-S/DVB-T [0070:1404,0070:1400,0070:1401,0070:1402] 5952 Geniatech DVB-S 14f1:0084
60 54 -> Norwood Micro TV Tuner 6053 Hauppauge WinTV-HVR3000 TriMode Analog/DVB-S/DVB-T 0070:1404, 0070:1400, 0070:1401, 0070:1402
61 55 -> Shenzhen Tungsten Ages Tech TE-DTV-250 / Swann OEM [c180:c980] 6154 Norwood Micro TV Tuner
62 56 -> Hauppauge WinTV-HVR1300 DVB-T/Hybrid MPEG Encoder [0070:9600,0070:9601,0070:9602] 6255 Shenzhen Tungsten Ages Tech TE-DTV-250 / Swann OEM c180:c980
63 57 -> ADS Tech Instant Video PCI [1421:0390] 6356 Hauppauge WinTV-HVR1300 DVB-T/Hybrid MPEG Encoder 0070:9600, 0070:9601, 0070:9602
64 58 -> Pinnacle PCTV HD 800i [11bd:0051] 6457 ADS Tech Instant Video PCI 1421:0390
65 59 -> DViCO FusionHDTV 5 PCI nano [18ac:d530] 6558 Pinnacle PCTV HD 800i 11bd:0051
66 60 -> Pinnacle Hybrid PCTV [12ab:1788] 6659 DViCO FusionHDTV 5 PCI nano 18ac:d530
67 61 -> Leadtek TV2000 XP Global [107d:6f18,107d:6618,107d:6619] 6760 Pinnacle Hybrid PCTV 12ab:1788
68 62 -> PowerColor RA330 [14f1:ea3d] 6861 Leadtek TV2000 XP Global 107d:6f18, 107d:6618, 107d:6619
69 63 -> Geniatech X8000-MT DVBT [14f1:8852] 6962 PowerColor RA330 14f1:ea3d
70 64 -> DViCO FusionHDTV DVB-T PRO [18ac:db30] 7063 Geniatech X8000-MT DVBT 14f1:8852
71 65 -> DViCO FusionHDTV 7 Gold [18ac:d610] 7164 DViCO FusionHDTV DVB-T PRO 18ac:db30
72 66 -> Prolink Pixelview MPEG 8000GT [1554:4935] 7265 DViCO FusionHDTV 7 Gold 18ac:d610
73 67 -> Kworld PlusTV HD PCI 120 (ATSC 120) [17de:08c1] 7366 Prolink Pixelview MPEG 8000GT 1554:4935
74 68 -> Hauppauge WinTV-HVR4000 DVB-S/S2/T/Hybrid [0070:6900,0070:6904,0070:6902] 7467 Kworld PlusTV HD PCI 120 (ATSC 120) 17de:08c1
75 69 -> Hauppauge WinTV-HVR4000(Lite) DVB-S/S2 [0070:6905,0070:6906] 7568 Hauppauge WinTV-HVR4000 DVB-S/S2/T/Hybrid 0070:6900, 0070:6904, 0070:6902
76 70 -> TeVii S460 DVB-S/S2 [d460:9022] 7669 Hauppauge WinTV-HVR4000(Lite) DVB-S/S2 0070:6905, 0070:6906
77 71 -> Omicom SS4 DVB-S/S2 PCI [A044:2011] 7770 TeVii S460 DVB-S/S2 d460:9022
78 72 -> TBS 8920 DVB-S/S2 [8920:8888] 7871 Omicom SS4 DVB-S/S2 PCI A044:2011
79 73 -> TeVii S420 DVB-S [d420:9022] 7972 TBS 8920 DVB-S/S2 8920:8888
80 74 -> Prolink Pixelview Global Extreme [1554:4976] 8073 TeVii S420 DVB-S d420:9022
81 75 -> PROF 7300 DVB-S/S2 [B033:3033] 8174 Prolink Pixelview Global Extreme 1554:4976
82 76 -> SATTRADE ST4200 DVB-S/S2 [b200:4200] 8275 PROF 7300 DVB-S/S2 B033:3033
83 77 -> TBS 8910 DVB-S [8910:8888] 8376 SATTRADE ST4200 DVB-S/S2 b200:4200
84 78 -> Prof 6200 DVB-S [b022:3022] 8477 TBS 8910 DVB-S 8910:8888
85 79 -> Terratec Cinergy HT PCI MKII [153b:1177] 8578 Prof 6200 DVB-S b022:3022
86 80 -> Hauppauge WinTV-IR Only [0070:9290] 8679 Terratec Cinergy HT PCI MKII 153b:1177
87 81 -> Leadtek WinFast DTV1800 Hybrid [107d:6654] 8780 Hauppauge WinTV-IR Only 0070:9290
88 82 -> WinFast DTV2000 H rev. J [107d:6f2b] 8881 Leadtek WinFast DTV1800 Hybrid 107d:6654
89 83 -> Prof 7301 DVB-S/S2 [b034:3034] 8982 WinFast DTV2000 H rev. J 107d:6f2b
90 84 -> Samsung SMT 7020 DVB-S [18ac:dc00,18ac:dccd] 9083 Prof 7301 DVB-S/S2 b034:3034
91 85 -> Twinhan VP-1027 DVB-S [1822:0023] 9184 Samsung SMT 7020 DVB-S 18ac:dc00, 18ac:dccd
92 86 -> TeVii S464 DVB-S/S2 [d464:9022] 9285 Twinhan VP-1027 DVB-S 1822:0023
93 87 -> Leadtek WinFast DTV2000 H PLUS [107d:6f42] 9386 TeVii S464 DVB-S/S2 d464:9022
94 88 -> Leadtek WinFast DTV1800 H (XC4000) [107d:6f38] 9487 Leadtek WinFast DTV2000 H PLUS 107d:6f42
95 89 -> Leadtek TV2000 XP Global (SC4100) [107d:6f36] 9588 Leadtek WinFast DTV1800 H (XC4000) 107d:6f38
96 90 -> Leadtek TV2000 XP Global (XC4100) [107d:6f43] 9689 Leadtek TV2000 XP Global (SC4100) 107d:6f36
9790 Leadtek TV2000 XP Global (XC4100) 107d:6f43
98=========== =================================================== ======================================================================================
diff --git a/Documentation/media/v4l-drivers/em28xx-cardlist.rst b/Documentation/media/v4l-drivers/em28xx-cardlist.rst
index e72f2e5c0898..76b1d301754c 100644
--- a/Documentation/media/v4l-drivers/em28xx-cardlist.rst
+++ b/Documentation/media/v4l-drivers/em28xx-cardlist.rst
@@ -1,105 +1,107 @@
1EM28xx cards list 1EM28xx cards list
2================= 2=================
3 3
4.. code-block:: none 4=========== ==================================================================== ================ ==================================================================================================================================
5 5Card number Card name Empia Chip USB IDs
6 0 -> Unknown EM2800 video grabber (em2800) [eb1a:2800] 6=========== ==================================================================== ================ ==================================================================================================================================
7 1 -> Unknown EM2750/28xx video grabber (em2820/em2840) [eb1a:2710,eb1a:2820,eb1a:2821,eb1a:2860,eb1a:2861,eb1a:2862,eb1a:2863,eb1a:2870,eb1a:2881,eb1a:2883,eb1a:2868,eb1a:2875] 70 Unknown EM2800 video grabber em2800 eb1a:2800
8 2 -> Terratec Cinergy 250 USB (em2820/em2840) [0ccd:0036] 81 Unknown EM2750/28xx video grabber em2820 or em2840 eb1a:2710, eb1a:2820, eb1a:2821, eb1a:2860, eb1a:2861, eb1a:2862, eb1a:2863, eb1a:2870, eb1a:2881, eb1a:2883, eb1a:2868, eb1a:2875
9 3 -> Pinnacle PCTV USB 2 (em2820/em2840) [2304:0208] 92 Terratec Cinergy 250 USB em2820 or em2840 0ccd:0036
10 4 -> Hauppauge WinTV USB 2 (em2820/em2840) [2040:4200,2040:4201] 103 Pinnacle PCTV USB 2 em2820 or em2840 2304:0208
11 5 -> MSI VOX USB 2.0 (em2820/em2840) 114 Hauppauge WinTV USB 2 em2820 or em2840 2040:4200, 2040:4201
12 6 -> Terratec Cinergy 200 USB (em2800) 125 MSI VOX USB 2.0 em2820 or em2840
13 7 -> Leadtek Winfast USB II (em2800) [0413:6023] 136 Terratec Cinergy 200 USB em2800
14 8 -> Kworld USB2800 (em2800) 147 Leadtek Winfast USB II em2800 0413:6023
15 9 -> Pinnacle Dazzle DVC 90/100/101/107 / Kaiser Baas Video to DVD maker (em2820/em2840) [1b80:e302,1b80:e304,2304:0207,2304:021a,093b:a003] 158 Kworld USB2800 em2800
16 10 -> Hauppauge WinTV HVR 900 (em2880) [2040:6500] 169 Pinnacle Dazzle DVC 90/100/101/107 / Kaiser Baas Video to DVD maker em2820 or em2840 1b80:e302, 1b80:e304, 2304:0207, 2304:021a, 093b:a003
17 11 -> Terratec Hybrid XS (em2880) 1710 Hauppauge WinTV HVR 900 em2880 2040:6500
18 12 -> Kworld PVR TV 2800 RF (em2820/em2840) 1811 Terratec Hybrid XS em2880
19 13 -> Terratec Prodigy XS (em2880) 1912 Kworld PVR TV 2800 RF em2820 or em2840
20 14 -> SIIG AVTuner-PVR / Pixelview Prolink PlayTV USB 2.0 (em2820/em2840) 2013 Terratec Prodigy XS em2880
21 15 -> V-Gear PocketTV (em2800) 2114 SIIG AVTuner-PVR / Pixelview Prolink PlayTV USB 2.0 em2820 or em2840
22 16 -> Hauppauge WinTV HVR 950 (em2883) [2040:6513,2040:6517,2040:651b] 2215 V-Gear PocketTV em2800
23 17 -> Pinnacle PCTV HD Pro Stick (em2880) [2304:0227] 2316 Hauppauge WinTV HVR 950 em2883 2040:6513, 2040:6517, 2040:651b
24 18 -> Hauppauge WinTV HVR 900 (R2) (em2880) [2040:6502] 2417 Pinnacle PCTV HD Pro Stick em2880 2304:0227
25 19 -> EM2860/SAA711X Reference Design (em2860) 2518 Hauppauge WinTV HVR 900 (R2) em2880 2040:6502
26 20 -> AMD ATI TV Wonder HD 600 (em2880) [0438:b002] 2619 EM2860/SAA711X Reference Design em2860
27 21 -> eMPIA Technology, Inc. GrabBeeX+ Video Encoder (em2800) [eb1a:2801] 2720 AMD ATI TV Wonder HD 600 em2880 0438:b002
28 22 -> EM2710/EM2750/EM2751 webcam grabber (em2750) [eb1a:2750,eb1a:2751] 2821 eMPIA Technology, Inc. GrabBeeX+ Video Encoder em2800 eb1a:2801
29 23 -> Huaqi DLCW-130 (em2750) 2922 EM2710/EM2750/EM2751 webcam grabber em2750 eb1a:2750, eb1a:2751
30 24 -> D-Link DUB-T210 TV Tuner (em2820/em2840) [2001:f112] 3023 Huaqi DLCW-130 em2750
31 25 -> Gadmei UTV310 (em2820/em2840) 3124 D-Link DUB-T210 TV Tuner em2820 or em2840 2001:f112
32 26 -> Hercules Smart TV USB 2.0 (em2820/em2840) 3225 Gadmei UTV310 em2820 or em2840
33 27 -> Pinnacle PCTV USB 2 (Philips FM1216ME) (em2820/em2840) 3326 Hercules Smart TV USB 2.0 em2820 or em2840
34 28 -> Leadtek Winfast USB II Deluxe (em2820/em2840) 3427 Pinnacle PCTV USB 2 (Philips FM1216ME) em2820 or em2840
35 29 -> EM2860/TVP5150 Reference Design (em2860) 3528 Leadtek Winfast USB II Deluxe em2820 or em2840
36 30 -> Videology 20K14XUSB USB2.0 (em2820/em2840) 3629 EM2860/TVP5150 Reference Design em2860
37 31 -> Usbgear VD204v9 (em2821) 3730 Videology 20K14XUSB USB2.0 em2820 or em2840
38 32 -> Supercomp USB 2.0 TV (em2821) 3831 Usbgear VD204v9 em2821
39 33 -> Elgato Video Capture (em2860) [0fd9:0033] 3932 Supercomp USB 2.0 TV em2821
40 34 -> Terratec Cinergy A Hybrid XS (em2860) [0ccd:004f] 4033 Elgato Video Capture em2860 0fd9:0033
41 35 -> Typhoon DVD Maker (em2860) 4134 Terratec Cinergy A Hybrid XS em2860 0ccd:004f
42 36 -> NetGMBH Cam (em2860) 4235 Typhoon DVD Maker em2860
43 37 -> Gadmei UTV330 (em2860) [eb1a:50a6] 4336 NetGMBH Cam em2860
44 38 -> Yakumo MovieMixer (em2861) 4437 Gadmei UTV330 em2860 eb1a:50a6
45 39 -> KWorld PVRTV 300U (em2861) [eb1a:e300] 4538 Yakumo MovieMixer em2861
46 40 -> Plextor ConvertX PX-TV100U (em2861) [093b:a005] 4639 KWorld PVRTV 300U em2861 eb1a:e300
47 41 -> Kworld 350 U DVB-T (em2870) [eb1a:e350] 4740 Plextor ConvertX PX-TV100U em2861 093b:a005
48 42 -> Kworld 355 U DVB-T (em2870) [eb1a:e355,eb1a:e357,eb1a:e359] 4841 Kworld 350 U DVB-T em2870 eb1a:e350
49 43 -> Terratec Cinergy T XS (em2870) 4942 Kworld 355 U DVB-T em2870 eb1a:e355, eb1a:e357, eb1a:e359
50 44 -> Terratec Cinergy T XS (MT2060) (em2870) [0ccd:0043] 5043 Terratec Cinergy T XS em2870
51 45 -> Pinnacle PCTV DVB-T (em2870) 5144 Terratec Cinergy T XS (MT2060) em2870 0ccd:0043
52 46 -> Compro, VideoMate U3 (em2870) [185b:2870] 5245 Pinnacle PCTV DVB-T em2870
53 47 -> KWorld DVB-T 305U (em2880) [eb1a:e305] 5346 Compro, VideoMate U3 em2870 185b:2870
54 48 -> KWorld DVB-T 310U (em2880) 5447 KWorld DVB-T 305U em2880 eb1a:e305
55 49 -> MSI DigiVox A/D (em2880) [eb1a:e310] 5548 KWorld DVB-T 310U em2880
56 50 -> MSI DigiVox A/D II (em2880) [eb1a:e320] 5649 MSI DigiVox A/D em2880 eb1a:e310
57 51 -> Terratec Hybrid XS Secam (em2880) [0ccd:004c] 5750 MSI DigiVox A/D II em2880 eb1a:e320
58 52 -> DNT DA2 Hybrid (em2881) 5851 Terratec Hybrid XS Secam em2880 0ccd:004c
59 53 -> Pinnacle Hybrid Pro (em2881) 5952 DNT DA2 Hybrid em2881
60 54 -> Kworld VS-DVB-T 323UR (em2882) [eb1a:e323] 6053 Pinnacle Hybrid Pro em2881
61 55 -> Terratec Cinnergy Hybrid T USB XS (em2882) (em2882) [0ccd:005e,0ccd:0042] 6154 Kworld VS-DVB-T 323UR em2882 eb1a:e323
62 56 -> Pinnacle Hybrid Pro (330e) (em2882) [2304:0226] 6255 Terratec Cinnergy Hybrid T USB XS (em2882) em2882 0ccd:005e, 0ccd:0042
63 57 -> Kworld PlusTV HD Hybrid 330 (em2883) [eb1a:a316] 6356 Pinnacle Hybrid Pro (330e) em2882 2304:0226
64 58 -> Compro VideoMate ForYou/Stereo (em2820/em2840) [185b:2041] 6457 Kworld PlusTV HD Hybrid 330 em2883 eb1a:a316
65 59 -> Pinnacle PCTV HD Mini (em2874) [2304:023f] 6558 Compro VideoMate ForYou/Stereo em2820 or em2840 185b:2041
66 60 -> Hauppauge WinTV HVR 850 (em2883) [2040:651f] 6659 Pinnacle PCTV HD Mini em2874 2304:023f
67 61 -> Pixelview PlayTV Box 4 USB 2.0 (em2820/em2840) 6760 Hauppauge WinTV HVR 850 em2883 2040:651f
68 62 -> Gadmei TVR200 (em2820/em2840) 6861 Pixelview PlayTV Box 4 USB 2.0 em2820 or em2840
69 63 -> Kaiomy TVnPC U2 (em2860) [eb1a:e303] 6962 Gadmei TVR200 em2820 or em2840
70 64 -> Easy Cap Capture DC-60 (em2860) [1b80:e309] 7063 Kaiomy TVnPC U2 em2860 eb1a:e303
71 65 -> IO-DATA GV-MVP/SZ (em2820/em2840) [04bb:0515] 7164 Easy Cap Capture DC-60 em2860 1b80:e309
72 66 -> Empire dual TV (em2880) 7265 IO-DATA GV-MVP/SZ em2820 or em2840 04bb:0515
73 67 -> Terratec Grabby (em2860) [0ccd:0096,0ccd:10AF] 7366 Empire dual TV em2880
74 68 -> Terratec AV350 (em2860) [0ccd:0084] 7467 Terratec Grabby em2860 0ccd:0096, 0ccd:10AF
75 69 -> KWorld ATSC 315U HDTV TV Box (em2882) [eb1a:a313] 7568 Terratec AV350 em2860 0ccd:0084
76 70 -> Evga inDtube (em2882) 7669 KWorld ATSC 315U HDTV TV Box em2882 eb1a:a313
77 71 -> Silvercrest Webcam 1.3mpix (em2820/em2840) 7770 Evga inDtube em2882
78 72 -> Gadmei UTV330+ (em2861) 7871 Silvercrest Webcam 1.3mpix em2820 or em2840
79 73 -> Reddo DVB-C USB TV Box (em2870) 7972 Gadmei UTV330+ em2861
80 74 -> Actionmaster/LinXcel/Digitus VC211A (em2800) 8073 Reddo DVB-C USB TV Box em2870
81 75 -> Dikom DK300 (em2882) 8174 Actionmaster/LinXcel/Digitus VC211A em2800
82 76 -> KWorld PlusTV 340U or UB435-Q (ATSC) (em2870) [1b80:a340] 8275 Dikom DK300 em2882
83 77 -> EM2874 Leadership ISDBT (em2874) 8376 KWorld PlusTV 340U or UB435-Q (ATSC) em2870 1b80:a340
84 78 -> PCTV nanoStick T2 290e (em28174) [2013:024f] 8477 EM2874 Leadership ISDBT em2874
85 79 -> Terratec Cinergy H5 (em2884) [eb1a:2885,0ccd:10a2,0ccd:10ad,0ccd:10b6] 8578 PCTV nanoStick T2 290e em28174 2013:024f
86 80 -> PCTV DVB-S2 Stick (460e) (em28174) [2013:024c] 8679 Terratec Cinergy H5 em2884 eb1a:2885, 0ccd:10a2, 0ccd:10ad, 0ccd:10b6
87 81 -> Hauppauge WinTV HVR 930C (em2884) [2040:1605] 8780 PCTV DVB-S2 Stick (460e) em28174 2013:024c
88 82 -> Terratec Cinergy HTC Stick (em2884) [0ccd:00b2] 8881 Hauppauge WinTV HVR 930C em2884 2040:1605
89 83 -> Honestech Vidbox NW03 (em2860) [eb1a:5006] 8982 Terratec Cinergy HTC Stick em2884 0ccd:00b2
90 84 -> MaxMedia UB425-TC (em2874) [1b80:e425] 9083 Honestech Vidbox NW03 em2860 eb1a:5006
91 85 -> PCTV QuatroStick (510e) (em2884) [2304:0242] 9184 MaxMedia UB425-TC em2874 1b80:e425
92 86 -> PCTV QuatroStick nano (520e) (em2884) [2013:0251] 9285 PCTV QuatroStick (510e) em2884 2304:0242
93 87 -> Terratec Cinergy HTC USB XS (em2884) [0ccd:008e,0ccd:00ac] 9386 PCTV QuatroStick nano (520e) em2884 2013:0251
94 88 -> C3 Tech Digital Duo HDTV/SDTV USB (em2884) [1b80:e755] 9487 Terratec Cinergy HTC USB XS em2884 0ccd:008e, 0ccd:00ac
95 89 -> Delock 61959 (em2874) [1b80:e1cc] 9588 C3 Tech Digital Duo HDTV/SDTV USB em2884 1b80:e755
96 90 -> KWorld USB ATSC TV Stick UB435-Q V2 (em2874) [1b80:e346] 9689 Delock 61959 em2874 1b80:e1cc
97 91 -> SpeedLink Vicious And Devine Laplace webcam (em2765) [1ae7:9003,1ae7:9004] 9790 KWorld USB ATSC TV Stick UB435-Q V2 em2874 1b80:e346
98 92 -> PCTV DVB-S2 Stick (461e) (em28178) [2013:0258] 9891 SpeedLink Vicious And Devine Laplace webcam em2765 1ae7:9003, 1ae7:9004
99 93 -> KWorld USB ATSC TV Stick UB435-Q V3 (em2874) [1b80:e34c] 9992 PCTV DVB-S2 Stick (461e) em28178 2013:0258
100 94 -> PCTV tripleStick (292e) (em28178) [2013:025f,2040:0264] 10093 KWorld USB ATSC TV Stick UB435-Q V3 em2874 1b80:e34c
101 95 -> Leadtek VC100 (em2861) [0413:6f07] 10194 PCTV tripleStick (292e) em28178 2013:025f, 2040:0264
102 96 -> Terratec Cinergy T2 Stick HD (em28178) [eb1a:8179] 10295 Leadtek VC100 em2861 0413:6f07
103 97 -> Elgato EyeTV Hybrid 2008 INT (em2884) [0fd9:0018] 10396 Terratec Cinergy T2 Stick HD em28178 eb1a:8179
104 98 -> PLEX PX-BCUD (em28178) [3275:0085] 10497 Elgato EyeTV Hybrid 2008 INT em2884 0fd9:0018
105 99 -> Hauppauge WinTV-dualHD DVB (em28174) [2040:0265] 10598 PLEX PX-BCUD em28178 3275:0085
10699 Hauppauge WinTV-dualHD DVB em28174 2040:0265
107=========== ==================================================================== ================ ==================================================================================================================================
diff --git a/Documentation/media/v4l-drivers/gspca-cardlist.rst b/Documentation/media/v4l-drivers/gspca-cardlist.rst
index 33a8ac7d73ab..e18d87e80d78 100644
--- a/Documentation/media/v4l-drivers/gspca-cardlist.rst
+++ b/Documentation/media/v4l-drivers/gspca-cardlist.rst
@@ -6,407 +6,444 @@ The modules for the gspca webcam drivers are:
6- gspca_main: main driver 6- gspca_main: main driver
7- gspca\_\ *driver*: subdriver module with *driver* as follows 7- gspca\_\ *driver*: subdriver module with *driver* as follows
8 8
9========= ========= ==================================================================== 9========= ========= ===================================================================
10*driver* vend:prod Device 10*driver* vend:prod Device
11========= ========= ==================================================================== 11========= ========= ===================================================================
12spca501 0000:0000 MystFromOri Unknown Camera 12spca501 0000:0000 MystFromOri Unknown Camera
13spca508 0130:0130 Clone Digital Webcam 11043 13spca508 0130:0130 Clone Digital Webcam 11043
14zc3xx 03f0:1b07 HP Premium Starter Cam 14se401 03e8:0004 Endpoints/AoxSE401
15m5602 0402:5602 ALi Video Camera Controller 15zc3xx 03f0:1b07 HP Premium Starter Cam
16spca501 040a:0002 Kodak DVC-325 16m5602 0402:5602 ALi Video Camera Controller
17spca500 040a:0300 Kodak EZ200 17spca501 040a:0002 Kodak DVC-325
18zc3xx 041e:041e Creative WebCam Live! 18spca500 040a:0300 Kodak EZ200
19ov519 041e:4003 Video Blaster WebCam Go Plus 19zc3xx 041e:041e Creative WebCam Live!
20spca500 041e:400a Creative PC-CAM 300 20ov519 041e:4003 Video Blaster WebCam Go Plus
21sunplus 041e:400b Creative PC-CAM 600 21stv0680 041e:4007 Go Mini
22sunplus 041e:4012 PC-Cam350 22spca500 041e:400a Creative PC-CAM 300
23sunplus 041e:4013 Creative Pccam750 23sunplus 041e:400b Creative PC-CAM 600
24zc3xx 041e:4017 Creative Webcam Mobile PD1090 24sunplus 041e:4012 PC-Cam350
25spca508 041e:4018 Creative Webcam Vista (PD1100) 25sunplus 041e:4013 Creative Pccam750
26spca561 041e:401a Creative Webcam Vista (PD1100) 26zc3xx 041e:4017 Creative Webcam Mobile PD1090
27zc3xx 041e:401c Creative NX 27spca508 041e:4018 Creative Webcam Vista (PD1100)
28spca505 041e:401d Creative Webcam NX ULTRA 28spca561 041e:401a Creative Webcam Vista (PD1100)
29zc3xx 041e:401e Creative Nx Pro 29zc3xx 041e:401c Creative NX
30zc3xx 041e:401f Creative Webcam Notebook PD1171 30spca505 041e:401d Creative Webcam NX ULTRA
31pac207 041e:4028 Creative Webcam Vista Plus 31zc3xx 041e:401e Creative Nx Pro
32zc3xx 041e:4029 Creative WebCam Vista Pro 32zc3xx 041e:401f Creative Webcam Notebook PD1171
33zc3xx 041e:4034 Creative Instant P0620 33zc3xx 041e:4022 Webcam NX Pro
34zc3xx 041e:4035 Creative Instant P0620D 34pac207 041e:4028 Creative Webcam Vista Plus
35zc3xx 041e:4036 Creative Live ! 35zc3xx 041e:4029 Creative WebCam Vista Pro
36sq930x 041e:4038 Creative Joy-IT 36zc3xx 041e:4034 Creative Instant P0620
37zc3xx 041e:403a Creative Nx Pro 2 37zc3xx 041e:4035 Creative Instant P0620D
38spca561 041e:403b Creative Webcam Vista (VF0010) 38zc3xx 041e:4036 Creative Live !
39sq930x 041e:403c Creative Live! Ultra 39sq930x 041e:4038 Creative Joy-IT
40sq930x 041e:403d Creative Live! Ultra for Notebooks 40zc3xx 041e:403a Creative Nx Pro 2
41sq930x 041e:4041 Creative Live! Motion 41spca561 041e:403b Creative Webcam Vista (VF0010)
42zc3xx 041e:4051 Creative Live!Cam Notebook Pro (VF0250) 42sq930x 041e:403c Creative Live! Ultra
43ov519 041e:4052 Creative Live! VISTA IM 43sq930x 041e:403d Creative Live! Ultra for Notebooks
44zc3xx 041e:4053 Creative Live!Cam Video IM 44sq930x 041e:4041 Creative Live! Motion
45vc032x 041e:405b Creative Live! Cam Notebook Ultra (VC0130) 45zc3xx 041e:4051 Creative Live!Cam Notebook Pro (VF0250)
46ov519 041e:405f Creative Live! VISTA VF0330 46ov519 041e:4052 Creative Live! VISTA IM
47ov519 041e:4060 Creative Live! VISTA VF0350 47zc3xx 041e:4053 Creative Live!Cam Video IM
48ov519 041e:4061 Creative Live! VISTA VF0400 48vc032x 041e:405b Creative Live! Cam Notebook Ultra (VC0130)
49ov519 041e:4064 Creative Live! VISTA VF0420 49ov519 041e:405f Creative Live! VISTA VF0330
50ov519 041e:4067 Creative Live! Cam Video IM (VF0350) 50ov519 041e:4060 Creative Live! VISTA VF0350
51ov519 041e:4068 Creative Live! VISTA VF0470 51ov519 041e:4061 Creative Live! VISTA VF0400
52spca561 0458:7004 Genius VideoCAM Express V2 52ov519 041e:4064 Creative Live! VISTA VF0420
53sn9c2028 0458:7005 Genius Smart 300, version 2 53ov519 041e:4067 Creative Live! Cam Video IM (VF0350)
54sunplus 0458:7006 Genius Dsc 1.3 Smart 54ov519 041e:4068 Creative Live! VISTA VF0470
55zc3xx 0458:7007 Genius VideoCam V2 55sn9c2028 0458:7003 GeniusVideocam Live v2
56zc3xx 0458:700c Genius VideoCam V3 56spca561 0458:7004 Genius VideoCAM Express V2
57zc3xx 0458:700f Genius VideoCam Web V2 57sn9c2028 0458:7005 Genius Smart 300, version 2
58sonixj 0458:7025 Genius Eye 311Q 58sunplus 0458:7006 Genius Dsc 1.3 Smart
59sn9c20x 0458:7029 Genius Look 320s 59zc3xx 0458:7007 Genius VideoCam V2
60sonixj 0458:702e Genius Slim 310 NB 60zc3xx 0458:700c Genius VideoCam V3
61sn9c20x 0458:7045 Genius Look 1320 V2 61zc3xx 0458:700f Genius VideoCam Web V2
62sn9c20x 0458:704a Genius Slim 1320 62sonixj 0458:7025 Genius Eye 311Q
63sn9c20x 0458:704c Genius i-Look 1321 63sn9c20x 0458:7029 Genius Look 320s
64sn9c20x 045e:00f4 LifeCam VX-6000 (SN9C20x + OV9650) 64sonixj 0458:702e Genius Slim 310 NB
65sonixj 045e:00f5 MicroSoft VX3000 65sn9c20x 0458:7045 Genius Look 1320 V2
66sonixj 045e:00f7 MicroSoft VX1000 66sn9c20x 0458:704a Genius Slim 1320
67ov519 045e:028c Micro$oft xbox cam 67sn9c20x 0458:704c Genius i-Look 1321
68spca508 0461:0815 Micro Innovation IC200 68sn9c20x 045e:00f4 LifeCam VX-6000 (SN9C20x + OV9650)
69sunplus 0461:0821 Fujifilm MV-1 69sonixj 045e:00f5 MicroSoft VX3000
70zc3xx 0461:0a00 MicroInnovation WebCam320 70sonixj 045e:00f7 MicroSoft VX1000
71stv06xx 046d:0840 QuickCam Express 71ov519 045e:028c Micro$oft xbox cam
72stv06xx 046d:0850 LEGO cam / QuickCam Web 72kinect 045e:02ae Xbox NUI Camera
73stv06xx 046d:0870 Dexxa WebCam USB 73kinect 045e:02bf Kinect for Windows NUI Camera
74spca500 046d:0890 Logitech QuickCam traveler 74spca561 0461:0815 Micro Innovations IC200 Webcam
75vc032x 046d:0892 Logitech Orbicam 75sunplus 0461:0821 Fujifilm MV-1
76vc032x 046d:0896 Logitech Orbicam 76zc3xx 0461:0a00 MicroInnovation WebCam320
77vc032x 046d:0897 Logitech QuickCam for Dell notebooks 77stv06xx 046D:08F0 QuickCamMessenger
78zc3xx 046d:089d Logitech QuickCam E2500 78stv06xx 046D:08F5 QuickCamCommunicate
79zc3xx 046d:08a0 Logitech QC IM 79stv06xx 046D:08F6 QuickCamMessenger (new)
80zc3xx 046d:08a1 Logitech QC IM 0x08A1 +sound 80stv06xx 046d:0840 QuickCamExpress
81zc3xx 046d:08a2 Labtec Webcam Pro 81stv06xx 046d:0850 LEGOcam / QuickCam Web
82zc3xx 046d:08a3 Logitech QC Chat 82stv06xx 046d:0870 DexxaWebCam USB
83zc3xx 046d:08a6 Logitech QCim 83spca500 046d:0890 Logitech QuickCam traveler
84zc3xx 046d:08a7 Logitech QuickCam Image 84vc032x 046d:0892 Logitech Orbicam
85zc3xx 046d:08a9 Logitech Notebook Deluxe 85vc032x 046d:0896 Logitech Orbicam
86zc3xx 046d:08aa Labtec Webcam Notebook 86vc032x 046d:0897 Logitech QuickCam for Dell notebooks
87zc3xx 046d:08ac Logitech QuickCam Cool 87zc3xx 046d:089d Logitech QuickCam E2500
88zc3xx 046d:08ad Logitech QCCommunicate STX 88zc3xx 046d:08a0 Logitech QC IM
89zc3xx 046d:08ae Logitech QuickCam for Notebooks 89zc3xx 046d:08a1 Logitech QC IM 0x08A1 +sound
90zc3xx 046d:08af Logitech QuickCam Cool 90zc3xx 046d:08a2 Labtec Webcam Pro
91zc3xx 046d:08b9 Logitech QuickCam Express 91zc3xx 046d:08a3 Logitech QC Chat
92zc3xx 046d:08d7 Logitech QCam STX 92zc3xx 046d:08a6 Logitech QCim
93zc3xx 046d:08d9 Logitech QuickCam IM/Connect 93zc3xx 046d:08a7 Logitech QuickCam Image
94zc3xx 046d:08d8 Logitech Notebook Deluxe 94zc3xx 046d:08a9 Logitech Notebook Deluxe
95zc3xx 046d:08da Logitech QuickCam Messenger 95zc3xx 046d:08aa Labtec Webcam Notebook
96zc3xx 046d:08dd Logitech QuickCam for Notebooks 96zc3xx 046d:08ac Logitech QuickCam Cool
97spca500 046d:0900 Logitech Inc. ClickSmart 310 97zc3xx 046d:08ad Logitech QCCommunicate STX
98spca500 046d:0901 Logitech Inc. ClickSmart 510 98zc3xx 046d:08ae Logitech QuickCam for Notebooks
99sunplus 046d:0905 Logitech ClickSmart 820 99zc3xx 046d:08af Logitech QuickCam Cool
100tv8532 046d:0920 Logitech QuickCam Express 100zc3xx 046d:08b9 Logitech QuickCam Express
101tv8532 046d:0921 Labtec Webcam 101zc3xx 046d:08d7 Logitech QCam STX
102spca561 046d:0928 Logitech QC Express Etch2 102zc3xx 046d:08d8 Logitech Notebook Deluxe
103spca561 046d:0929 Labtec Webcam Elch2 103zc3xx 046d:08d9 Logitech QuickCam IM/Connect
104spca561 046d:092a Logitech QC for Notebook 104zc3xx 046d:08da Logitech QuickCam Messenger
105spca561 046d:092b Labtec Webcam Plus 105zc3xx 046d:08dd Logitech QuickCam for Notebooks
106spca561 046d:092c Logitech QC chat Elch2 106spca500 046d:0900 Logitech Inc. ClickSmart 310
107spca561 046d:092d Logitech QC Elch2 107spca500 046d:0901 Logitech Inc. ClickSmart 510
108spca561 046d:092e Logitech QC Elch2 108sunplus 046d:0905 Logitech ClickSmart 820
109spca561 046d:092f Logitech QuickCam Express Plus 109tv8532 046d:0920 Logitech QuickCam Express
110sunplus 046d:0960 Logitech ClickSmart 420 110tv8532 046d:0921 Labtec Webcam
111nw80x 046d:d001 Logitech QuickCam Pro (dark focus ring) 111spca561 046d:0928 Logitech QC Express Etch2
112sunplus 0471:0322 Philips DMVC1300K 112spca561 046d:0929 Labtec Webcam Elch2
113zc3xx 0471:0325 Philips SPC 200 NC 113spca561 046d:092a Logitech QC for Notebook
114zc3xx 0471:0326 Philips SPC 300 NC 114spca561 046d:092b Labtec Webcam Plus
115sonixj 0471:0327 Philips SPC 600 NC 115spca561 046d:092c Logitech QC chat Elch2
116sonixj 0471:0328 Philips SPC 700 NC 116spca561 046d:092d Logitech QC Elch2
117zc3xx 0471:032d Philips SPC 210 NC 117spca561 046d:092e Logitech QC Elch2
118zc3xx 0471:032e Philips SPC 315 NC 118spca561 046d:092f Logitech QuickCam Express Plus
119sonixj 0471:0330 Philips SPC 710 NC 119sunplus 046d:0960 Logitech ClickSmart 420
120spca501 0497:c001 Smile International 120nw80x 046d:d001 Logitech QuickCam Pro (dark focus ring)
121sunplus 04a5:3003 Benq DC 1300 121se401 0471:030b PhilipsPCVC665K
122sunplus 04a5:3008 Benq DC 1500 122sunplus 0471:0322 Philips DMVC1300K
123sunplus 04a5:300a Benq DC 3410 123zc3xx 0471:0325 Philips SPC 200 NC
124spca500 04a5:300c Benq DC 1016 124zc3xx 0471:0326 Philips SPC 300 NC
125benq 04a5:3035 Benq DC E300 125sonixj 0471:0327 Philips SPC 600 NC
126finepix 04cb:0104 Fujifilm FinePix 4800 126sonixj 0471:0328 Philips SPC 700 NC
127finepix 04cb:0109 Fujifilm FinePix A202 127zc3xx 0471:032d Philips SPC 210 NC
128finepix 04cb:010b Fujifilm FinePix A203 128zc3xx 0471:032e Philips SPC 315 NC
129finepix 04cb:010f Fujifilm FinePix A204 129sonixj 0471:0330 Philips SPC 710 NC
130finepix 04cb:0111 Fujifilm FinePix A205 130se401 047d:5001 Kensington67014
131finepix 04cb:0113 Fujifilm FinePix A210 131se401 047d:5002 Kensington6701(5/7)
132finepix 04cb:0115 Fujifilm FinePix A303 132se401 047d:5003 Kensington67016
133finepix 04cb:0117 Fujifilm FinePix A310 133spca501 0497:c001 Smile International
134finepix 04cb:0119 Fujifilm FinePix F401 134sunplus 04a5:3003 Benq DC 1300
135finepix 04cb:011b Fujifilm FinePix F402 135sunplus 04a5:3008 Benq DC 1500
136finepix 04cb:011d Fujifilm FinePix F410 136sunplus 04a5:300a Benq DC 3410
137finepix 04cb:0121 Fujifilm FinePix F601 137spca500 04a5:300c Benq DC 1016
138finepix 04cb:0123 Fujifilm FinePix F700 138benq 04a5:3035 Benq DC E300
139finepix 04cb:0125 Fujifilm FinePix M603 139vicam 04c1:009d HomeConnect Webcam [vicam]
140finepix 04cb:0127 Fujifilm FinePix S300 140konica 04c8:0720 IntelYC 76
141finepix 04cb:0129 Fujifilm FinePix S304 141finepix 04cb:0104 Fujifilm FinePix 4800
142finepix 04cb:012b Fujifilm FinePix S500 142finepix 04cb:0109 Fujifilm FinePix A202
143finepix 04cb:012d Fujifilm FinePix S602 143finepix 04cb:010b Fujifilm FinePix A203
144finepix 04cb:012f Fujifilm FinePix S700 144finepix 04cb:010f Fujifilm FinePix A204
145finepix 04cb:0131 Fujifilm FinePix unknown model 145finepix 04cb:0111 Fujifilm FinePix A205
146finepix 04cb:013b Fujifilm FinePix unknown model 146finepix 04cb:0113 Fujifilm FinePix A210
147finepix 04cb:013d Fujifilm FinePix unknown model 147finepix 04cb:0115 Fujifilm FinePix A303
148finepix 04cb:013f Fujifilm FinePix F420 148finepix 04cb:0117 Fujifilm FinePix A310
149sunplus 04f1:1001 JVC GC A50 149finepix 04cb:0119 Fujifilm FinePix F401
150spca561 04fc:0561 Flexcam 100 150finepix 04cb:011b Fujifilm FinePix F402
151spca1528 04fc:1528 Sunplus MD80 clone 151finepix 04cb:011d Fujifilm FinePix F410
152sunplus 04fc:500c Sunplus CA500C 152finepix 04cb:0121 Fujifilm FinePix F601
153sunplus 04fc:504a Aiptek Mini PenCam 1.3 153finepix 04cb:0123 Fujifilm FinePix F700
154sunplus 04fc:504b Maxell MaxPocket LE 1.3 154finepix 04cb:0125 Fujifilm FinePix M603
155sunplus 04fc:5330 Digitrex 2110 155finepix 04cb:0127 Fujifilm FinePix S300
156sunplus 04fc:5360 Sunplus Generic 156finepix 04cb:0129 Fujifilm FinePix S304
157spca500 04fc:7333 PalmPixDC85 157finepix 04cb:012b Fujifilm FinePix S500
158sunplus 04fc:ffff Pure DigitalDakota 158finepix 04cb:012d Fujifilm FinePix S602
159nw80x 0502:d001 DVC V6 159finepix 04cb:012f Fujifilm FinePix S700
160spca501 0506:00df 3Com HomeConnect Lite 160finepix 04cb:0131 Fujifilm FinePix unknown model
161sunplus 052b:1507 Megapixel 5 Pretec DC-1007 161finepix 04cb:013b Fujifilm FinePix unknown model
162sunplus 052b:1513 Megapix V4 162finepix 04cb:013d Fujifilm FinePix unknown model
163sunplus 052b:1803 MegaImage VI 163finepix 04cb:013f Fujifilm FinePix F420
164nw80x 052b:d001 EZCam Pro p35u 164sunplus 04f1:1001 JVC GC A50
165tv8532 0545:808b Veo Stingray 165spca561 04fc:0561 Flexcam 100
166tv8532 0545:8333 Veo Stingray 166spca1528 04fc:1528 Sunplus MD80 clone
167sunplus 0546:3155 Polaroid PDC3070 167sunplus 04fc:500c Sunplus CA500C
168sunplus 0546:3191 Polaroid Ion 80 168sunplus 04fc:504a Aiptek Mini PenCam 1.3
169sunplus 0546:3273 Polaroid PDC2030 169sunplus 04fc:504b Maxell MaxPocket LE 1.3
170ov519 054c:0154 Sonny toy4 170sunplus 04fc:5330 Digitrex 2110
171ov519 054c:0155 Sonny toy5 171sunplus 04fc:5360 Sunplus Generic
172cpia1 0553:0002 CPIA CPiA (version1) based cameras 172spca500 04fc:7333 PalmPixDC85
173zc3xx 055f:c005 Mustek Wcam300A 173sunplus 04fc:ffff Pure DigitalDakota
174spca500 055f:c200 Mustek Gsmart 300 174nw80x 0502:d001 DVC V6
175sunplus 055f:c211 Kowa Bs888e Microcamera 175spca501 0506:00df 3Com HomeConnect Lite
176spca500 055f:c220 Gsmart Mini 176sunplus 052b:1507 Megapixel 5 Pretec DC-1007
177sunplus 055f:c230 Mustek Digicam 330K 177sunplus 052b:1513 Megapix V4
178sunplus 055f:c232 Mustek MDC3500 178sunplus 052b:1803 MegaImage VI
179sunplus 055f:c360 Mustek DV4000 Mpeg4 179nw80x 052b:d001 EZCam Pro p35u
180sunplus 055f:c420 Mustek gSmart Mini 2 180tv8532 0545:808b Veo Stingray
181sunplus 055f:c430 Mustek Gsmart LCD 2 181tv8532 0545:8333 Veo Stingray
182sunplus 055f:c440 Mustek DV 3000 182sunplus 0546:3155 Polaroid PDC3070
183sunplus 055f:c520 Mustek gSmart Mini 3 183sunplus 0546:3191 Polaroid Ion 80
184sunplus 055f:c530 Mustek Gsmart LCD 3 184sunplus 0546:3273 Polaroid PDC2030
185sunplus 055f:c540 Gsmart D30 185touptek 0547:6801 TTUCMOS08000KPB, AS MU800
186sunplus 055f:c630 Mustek MDC4000 186dtcs033 0547:7303 Anchor Chips, Inc
187sunplus 055f:c650 Mustek MDC5500Z 187ov519 054c:0154 Sonny toy4
188nw80x 055f:d001 Mustek Wcam 300 mini 188ov519 054c:0155 Sonny toy5
189zc3xx 055f:d003 Mustek WCam300A 189cpia1 0553:0002 CPIA CPiA (version1) based cameras
190zc3xx 055f:d004 Mustek WCam300 AN 190stv0680 0553:0202 STV0680 Camera
191conex 0572:0041 Creative Notebook cx11646 191zc3xx 055f:c005 Mustek Wcam300A
192ov519 05a9:0511 Video Blaster WebCam 3/WebCam Plus, D-Link USB Digital Video Camera 192spca500 055f:c200 Mustek Gsmart 300
193ov519 05a9:0518 Creative WebCam 193sunplus 055f:c211 Kowa Bs888e Microcamera
194ov519 05a9:0519 OV519 Microphone 194spca500 055f:c220 Gsmart Mini
195ov519 05a9:0530 OmniVision 195sunplus 055f:c230 Mustek Digicam 330K
196ov534_9 05a9:1550 OmniVision VEHO Filmscanner 196sunplus 055f:c232 Mustek MDC3500
197ov519 05a9:2800 OmniVision SuperCAM 197sunplus 055f:c360 Mustek DV4000 Mpeg4
198ov519 05a9:4519 Webcam Classic 198sunplus 055f:c420 Mustek gSmart Mini 2
199ov534_9 05a9:8065 OmniVision test kit ov538+ov9712 199sunplus 055f:c430 Mustek Gsmart LCD 2
200ov519 05a9:8519 OmniVision 200sunplus 055f:c440 Mustek DV 3000
201ov519 05a9:a511 D-Link USB Digital Video Camera 201sunplus 055f:c520 Mustek gSmart Mini 3
202ov519 05a9:a518 D-Link DSB-C310 Webcam 202sunplus 055f:c530 Mustek Gsmart LCD 3
203sunplus 05da:1018 Digital Dream Enigma 1.3 203sunplus 055f:c540 Gsmart D30
204stk014 05e1:0893 Syntek DV4000 204sunplus 055f:c630 Mustek MDC4000
205gl860 05e3:0503 Genesys Logic PC Camera 205sunplus 055f:c650 Mustek MDC5500Z
206gl860 05e3:f191 Genesys Logic PC Camera 206nw80x 055f:d001 Mustek Wcam 300 mini
207spca561 060b:a001 Maxell Compact Pc PM3 207zc3xx 055f:d003 Mustek WCam300A
208zc3xx 0698:2003 CTX M730V built in 208zc3xx 055f:d004 Mustek WCam300 AN
209topro 06a2:0003 TP6800 PC Camera, CmoX CX0342 webcam 209conex 0572:0041 Creative Notebook cx11646
210topro 06a2:6810 Creative Qmax 210ov519 05a9:0511 Video Blaster WebCam 3/WebCam Plus, D-Link USB Digital Video Camera
211nw80x 06a5:0000 Typhoon Webcam 100 USB 211ov519 05a9:0518 Creative WebCam
212nw80x 06a5:d001 Divio based webcams 212ov519 05a9:0519 OV519 Microphone
213nw80x 06a5:d800 Divio Chicony TwinkleCam, Trust SpaceCam 213ov519 05a9:0530 OmniVision
214spca500 06bd:0404 Agfa CL20 214ov534_9 05a9:1550 OmniVision VEHO Filmscanner
215spca500 06be:0800 Optimedia 215ov519 05a9:2800 OmniVision SuperCAM
216nw80x 06be:d001 EZCam Pro p35u 216ov519 05a9:4519 Webcam Classic
217sunplus 06d6:0031 Trust 610 LCD PowerC@m Zoom 217ov534_9 05a9:8065 OmniVision test kit ov538+ov9712
218spca506 06e1:a190 ADS Instant VCD 218ov519 05a9:8519 OmniVision
219ov534 06f8:3002 Hercules Blog Webcam 219ov519 05a9:a511 D-Link USB Digital Video Camera
220ov534_9 06f8:3003 Hercules Dualpix HD Weblog 220ov519 05a9:a518 D-Link DSB-C310 Webcam
221sonixj 06f8:3004 Hercules Classic Silver 221sunplus 05da:1018 Digital Dream Enigma 1.3
222sonixj 06f8:3008 Hercules Deluxe Optical Glass 222stk014 05e1:0893 Syntek DV4000
223pac7302 06f8:3009 Hercules Classic Link 223gl860 05e3:0503 Genesys Logic PC Camera
224pac7302 06f8:301b Hercules Link 224gl860 05e3:f191 Genesys Logic PC Camera
225nw80x 0728:d001 AVerMedia Camguard 225vicam 0602:1001 ViCam Webcam
226spca508 0733:0110 ViewQuest VQ110 226spca561 060b:a001 Maxell Compact Pc PM3
227spca501 0733:0401 Intel Create and Share 227zc3xx 0698:2003 CTX M730V built in
228spca501 0733:0402 ViewQuest M318B 228topro 06a2:0003 TP6800 PC Camera, CmoX CX0342 webcam
229spca505 0733:0430 Intel PC Camera Pro 229topro 06a2:6810 Creative Qmax
230sunplus 0733:1311 Digital Dream Epsilon 1.3 230nw80x 06a5:0000 Typhoon Webcam 100 USB
231sunplus 0733:1314 Mercury 2.1MEG Deluxe Classic Cam 231nw80x 06a5:d001 Divio based webcams
232sunplus 0733:2211 Jenoptik jdc 21 LCD 232nw80x 06a5:d800 Divio Chicony TwinkleCam, Trust SpaceCam
233sunplus 0733:2221 Mercury Digital Pro 3.1p 233spca500 06bd:0404 Agfa CL20
234sunplus 0733:3261 Concord 3045 spca536a 234spca500 06be:0800 Optimedia
235sunplus 0733:3281 Cyberpix S550V 235nw80x 06be:d001 EZCam Pro p35u
236spca506 0734:043b 3DeMon USB Capture aka 236sunplus 06d6:0031 Trust 610 LCD PowerC@m Zoom
237cpia1 0813:0001 QX3 camera 237sunplus 06d6:0041 Aashima Technology B.V.
238ov519 0813:0002 Dual Mode USB Camera Plus 238spca506 06e1:a190 ADS Instant VCD
239spca500 084d:0003 D-Link DSC-350 239ov534 06f8:3002 Hercules Blog Webcam
240spca500 08ca:0103 Aiptek PocketDV 240ov534_9 06f8:3003 Hercules Dualpix HD Weblog
241sunplus 08ca:0104 Aiptek PocketDVII 1.3 241sonixj 06f8:3004 Hercules Classic Silver
242sunplus 08ca:0106 Aiptek Pocket DV3100+ 242sonixj 06f8:3008 Hercules Deluxe Optical Glass
243mr97310a 08ca:0110 Trust Spyc@m 100 243pac7302 06f8:3009 Hercules Classic Link
244mr97310a 08ca:0111 Aiptek PenCam VGA+ 244pac7302 06f8:301b Hercules Link
245sunplus 08ca:2008 Aiptek Mini PenCam 2 M 245nw80x 0728:d001 AVerMedia Camguard
246sunplus 08ca:2010 Aiptek PocketCam 3M 246spca508 0733:0110 ViewQuest VQ110
247sunplus 08ca:2016 Aiptek PocketCam 2 Mega 247spca501 0733:0401 Intel Create and Share
248sunplus 08ca:2018 Aiptek Pencam SD 2M 248spca501 0733:0402 ViewQuest M318B
249sunplus 08ca:2020 Aiptek Slim 3000F 249spca505 0733:0430 Intel PC Camera Pro
250sunplus 08ca:2022 Aiptek Slim 3200 250sunplus 0733:1311 Digital Dream Epsilon 1.3
251sunplus 08ca:2024 Aiptek DV3500 Mpeg4 251sunplus 0733:1314 Mercury 2.1MEG Deluxe Classic Cam
252sunplus 08ca:2028 Aiptek PocketCam4M 252sunplus 0733:2211 Jenoptik jdc 21 LCD
253sunplus 08ca:2040 Aiptek PocketDV4100M 253sunplus 0733:2221 Mercury Digital Pro 3.1p
254sunplus 08ca:2042 Aiptek PocketDV5100 254sunplus 0733:3261 Concord 3045 spca536a
255sunplus 08ca:2050 Medion MD 41437 255sunplus 0733:3281 Cyberpix S550V
256sunplus 08ca:2060 Aiptek PocketDV5300 256spca506 0734:043b 3DeMon USB Capture aka
257tv8532 0923:010f ICM532 cams 257cpia1 0813:0001 QX3 camera
258mars 093a:050f Mars-Semi Pc-Camera 258ov519 0813:0002 Dual Mode USB Camera Plus
259mr97310a 093a:010e All known CIF cams with this ID 259spca500 084d:0003 D-Link DSC-350
260mr97310a 093a:010f All known VGA cams with this ID 260spca500 08ca:0103 Aiptek PocketDV
261pac207 093a:2460 Qtec Webcam 100 261sunplus 08ca:0104 Aiptek PocketDVII 1.3
262pac207 093a:2461 HP Webcam 262sunplus 08ca:0106 Aiptek Pocket DV3100+
263pac207 093a:2463 Philips SPC 220 NC 263mr97310a 08ca:0110 Trust Spyc@m 100
264pac207 093a:2464 Labtec Webcam 1200 264mr97310a 08ca:0111 Aiptek PenCam VGA+
265pac207 093a:2468 Webcam WB-1400T 265sunplus 08ca:2008 Aiptek Mini PenCam 2 M
266pac207 093a:2470 Genius GF112 266sunplus 08ca:2010 Aiptek PocketCam 3M
267pac207 093a:2471 Genius VideoCam ge111 267sunplus 08ca:2016 Aiptek PocketCam 2 Mega
268pac207 093a:2472 Genius VideoCam ge110 268sunplus 08ca:2018 Aiptek Pencam SD 2M
269pac207 093a:2474 Genius iLook 111 269sunplus 08ca:2020 Aiptek Slim 3000F
270pac207 093a:2476 Genius e-Messenger 112 270sunplus 08ca:2022 Aiptek Slim 3200
271pac7311 093a:2600 PAC7311 Typhoon 271sunplus 08ca:2024 Aiptek DV3500 Mpeg4
272pac7311 093a:2601 Philips SPC 610 NC 272sunplus 08ca:2028 Aiptek PocketCam4M
273pac7311 093a:2603 Philips SPC 500 NC 273sunplus 08ca:2040 Aiptek PocketDV4100M
274pac7311 093a:2608 Trust WB-3300p 274sunplus 08ca:2042 Aiptek PocketDV5100
275pac7311 093a:260e Gigaware VGA PC Camera, Trust WB-3350p, SIGMA cam 2350 275sunplus 08ca:2050 Medion MD 41437
276pac7311 093a:260f SnakeCam 276sunplus 08ca:2060 Aiptek PocketDV5300
277pac7302 093a:2620 Apollo AC-905 277tv8532 0923:010f ICM532 cams
278pac7302 093a:2621 PAC731x 278mr97310a 093a:010e All known CIF cams with this ID
279pac7302 093a:2622 Genius Eye 312 279mr97310a 093a:010f All known VGA cams with this ID
280pac7302 093a:2624 PAC7302 280mars 093a:050f Mars-Semi Pc-Camera
281pac7302 093a:2625 Genius iSlim 310 281pac207 093a:2460 Qtec Webcam 100
282pac7302 093a:2626 Labtec 2200 282pac207 093a:2461 HP Webcam
283pac7302 093a:2627 Genius FaceCam 300 283pac207 093a:2463 Philips SPC 220 NC
284pac7302 093a:2628 Genius iLook 300 284pac207 093a:2464 Labtec Webcam 1200
285pac7302 093a:2629 Genious iSlim 300 285pac207 093a:2468 Webcam WB-1400T
286pac7302 093a:262a Webcam 300k 286pac207 093a:2470 Genius GF112
287pac7302 093a:262c Philips SPC 230 NC 287pac207 093a:2471 Genius VideoCam ge111
288jl2005bcd 0979:0227 Various brands, 19 known cameras supported 288pac207 093a:2472 Genius VideoCam ge110
289jeilinj 0979:0280 Sakar 57379 289pac207 093a:2474 Genius iLook 111
290jeilinj 0979:0280 Sportscam DV15 290pac207 093a:2476 Genius e-Messenger 112
291zc3xx 0ac8:0302 Z-star Vimicro zc0302 291pac7311 093a:2600 PAC7311 Typhoon
292vc032x 0ac8:0321 Vimicro generic vc0321 292pac7311 093a:2601 Philips SPC 610 NC
293vc032x 0ac8:0323 Vimicro Vc0323 293pac7311 093a:2603 Philips SPC 500 NC
294vc032x 0ac8:0328 A4Tech PK-130MG 294pac7311 093a:2608 Trust WB-3300p
295zc3xx 0ac8:301b Z-Star zc301b 295pac7311 093a:260e Gigaware VGA PC Camera, Trust WB-3350p, SIGMA cam 2350
296zc3xx 0ac8:303b Vimicro 0x303b 296pac7311 093a:260f SnakeCam
297zc3xx 0ac8:305b Z-star Vimicro zc0305b 297pac7302 093a:2620 Apollo AC-905
298zc3xx 0ac8:307b PC Camera (ZS0211) 298pac7302 093a:2621 PAC731x
299vc032x 0ac8:c001 Sony embedded vimicro 299pac7302 093a:2622 Genius Eye 312
300vc032x 0ac8:c002 Sony embedded vimicro 300pac7302 093a:2623 Pixart Imaging, Inc.
301vc032x 0ac8:c301 Samsung Q1 Ultra Premium 301pac7302 093a:2624 PAC7302
302spca508 0af9:0010 Hama USB Sightcam 100 302pac7302 093a:2625 Genius iSlim 310
303spca508 0af9:0011 Hama USB Sightcam 100 303pac7302 093a:2626 Labtec 2200
304ov519 0b62:0059 iBOT2 Webcam 304pac7302 093a:2627 Genius FaceCam 300
305sonixb 0c45:6001 Genius VideoCAM NB 305pac7302 093a:2628 Genius iLook 300
306sonixb 0c45:6005 Microdia Sweex Mini Webcam 306pac7302 093a:2629 Genious iSlim 300
307sonixb 0c45:6007 Sonix sn9c101 + Tas5110D 307pac7302 093a:262a Webcam 300k
308sonixb 0c45:6009 spcaCam@120 308pac7302 093a:262c Philips SPC 230 NC
309sonixb 0c45:600d spcaCam@120 309jl2005bcd 0979:0227 Various brands, 19 known cameras supported
310sonixb 0c45:6011 Microdia PC Camera (SN9C102) 310jeilinj 0979:0270 Sakar 57379
311sonixb 0c45:6019 Generic Sonix OV7630 311jeilinj 0979:0280 Sportscam DV15, Sakar 57379
312sonixb 0c45:6024 Generic Sonix Tas5130c 312zc3xx 0ac8:0301 Web Camera
313sonixb 0c45:6025 Xcam Shanga 313zc3xx 0ac8:0302 Z-star Vimicro zc0302
314sonixb 0c45:6028 Sonix Btc Pc380 314vc032x 0ac8:0321 Vimicro generic vc0321
315sonixb 0c45:6029 spcaCam@150 315vc032x 0ac8:0323 Vimicro Vc0323
316sonixb 0c45:602c Generic Sonix OV7630 316vc032x 0ac8:0328 A4Tech PK-130MG
317sonixb 0c45:602d LIC-200 LG 317zc3xx 0ac8:301b Z-Star zc301b
318sonixb 0c45:602e Genius VideoCam Messenger 318zc3xx 0ac8:303b Vimicro 0x303b
319sonixj 0c45:6040 Speed NVC 350K 319zc3xx 0ac8:305b Z-star Vimicro zc0305b
320sonixj 0c45:607c Sonix sn9c102p Hv7131R 320zc3xx 0ac8:307b PC Camera (ZS0211)
321sonixj 0c45:60c0 Sangha Sn535 321vc032x 0ac8:c001 Sony embedded vimicro
322sonixj 0c45:60ce USB-PC-Camera-168 (TALK-5067) 322vc032x 0ac8:c002 Sony embedded vimicro
323sonixj 0c45:60ec SN9C105+MO4000 323vc032x 0ac8:c301 Samsung Q1 Ultra Premium
324sonixj 0c45:60fb Surfer NoName 324spca508 0af9:0010 Hama USB Sightcam 100
325sonixj 0c45:60fc LG-LIC300 325spca508 0af9:0011 Hama USB Sightcam 100
326sonixj 0c45:60fe Microdia Audio 326ov519 0b62:0059 iBOT2 Webcam
327sonixj 0c45:6100 PC Camera (SN9C128) 327sonixb 0c45:6001 Genius VideoCAM NB
328sonixj 0c45:6102 PC Camera (SN9C128) 328sonixb 0c45:6005 Microdia Sweex Mini Webcam
329sonixj 0c45:610a PC Camera (SN9C128) 329sonixb 0c45:6007 Sonix sn9c101 + Tas5110D
330sonixj 0c45:610b PC Camera (SN9C128) 330sonixb 0c45:6009 spcaCam@120
331sonixj 0c45:610c PC Camera (SN9C128) 331sonixb 0c45:600d spcaCam@120
332sonixj 0c45:610e PC Camera (SN9C128) 332sonixb 0c45:6011 Microdia PC Camera (SN9C102)
333sonixj 0c45:6128 Microdia/Sonix SNP325 333sonixb 0c45:6019 Generic Sonix OV7630
334sonixj 0c45:612a Avant Camera 334sonixb 0c45:6024 Generic Sonix Tas5130c
335sonixj 0c45:612b Speed-Link REFLECT2 335sonixb 0c45:6025 Xcam Shanga
336sonixj 0c45:612c Typhoon Rasy Cam 1.3MPix 336sonixb 0c45:6027 GeniusEye 310
337sonixj 0c45:6130 Sonix Pccam 337sonixb 0c45:6028 Sonix Btc Pc380
338sonixj 0c45:6138 Sn9c120 Mo4000 338sonixb 0c45:6029 spcaCam@150
339sonixj 0c45:613a Microdia Sonix PC Camera 339sonixb 0c45:602a Meade ETX-105EC Camera
340sonixj 0c45:613b Surfer SN-206 340sonixb 0c45:602c Generic Sonix OV7630
341sonixj 0c45:613c Sonix Pccam168 341sonixb 0c45:602d LIC-200 LG
342sonixj 0c45:6142 Hama PC-Webcam AC-150 342sonixb 0c45:602e Genius VideoCam Messenger
343sonixj 0c45:6143 Sonix Pccam168 343sonixj 0c45:6040 Speed NVC 350K
344sonixj 0c45:6148 Digitus DA-70811/ZSMC USB PC Camera ZS211/Microdia 344sonixj 0c45:607c Sonix sn9c102p Hv7131R
345sonixj 0c45:614a Frontech E-Ccam (JIL-2225) 345sonixb 0c45:6083 VideoCAM Look
346sn9c20x 0c45:6240 PC Camera (SN9C201 + MT9M001) 346sonixb 0c45:608c VideoCAM Look
347sn9c20x 0c45:6242 PC Camera (SN9C201 + MT9M111) 347sonixb 0c45:608f PC Camera (SN9C103 + OV7630)
348sn9c20x 0c45:6248 PC Camera (SN9C201 + OV9655) 348sonixb 0c45:60a8 VideoCAM Look
349sn9c20x 0c45:624c PC Camera (SN9C201 + MT9M112) 349sonixb 0c45:60aa VideoCAM Look
350sn9c20x 0c45:624e PC Camera (SN9C201 + SOI968) 350sonixb 0c45:60af VideoCAM Look
351sn9c20x 0c45:624f PC Camera (SN9C201 + OV9650) 351sonixb 0c45:60b0 Genius VideoCam Look
352sn9c20x 0c45:6251 PC Camera (SN9C201 + OV9650) 352sonixj 0c45:60c0 Sangha Sn535
353sn9c20x 0c45:6253 PC Camera (SN9C201 + OV9650) 353sonixj 0c45:60ce USB-PC-Camera-168 (TALK-5067)
354sn9c20x 0c45:6260 PC Camera (SN9C201 + OV7670) 354sonixj 0c45:60ec SN9C105+MO4000
355sn9c20x 0c45:6270 PC Camera (SN9C201 + MT9V011/MT9V111/MT9V112) 355sonixj 0c45:60fb Surfer NoName
356sn9c20x 0c45:627b PC Camera (SN9C201 + OV7660) 356sonixj 0c45:60fc LG-LIC300
357sn9c20x 0c45:627c PC Camera (SN9C201 + HV7131R) 357sonixj 0c45:60fe Microdia Audio
358sn9c20x 0c45:627f PC Camera (SN9C201 + OV9650) 358sonixj 0c45:6100 PC Camera (SN9C128)
359sn9c20x 0c45:6280 PC Camera (SN9C202 + MT9M001) 359sonixj 0c45:6102 PC Camera (SN9C128)
360sn9c20x 0c45:6282 PC Camera (SN9C202 + MT9M111) 360sonixj 0c45:610a PC Camera (SN9C128)
361sn9c20x 0c45:6288 PC Camera (SN9C202 + OV9655) 361sonixj 0c45:610b PC Camera (SN9C128)
362sn9c20x 0c45:628c PC Camera (SN9C201 + MT9M112) 362sonixj 0c45:610c PC Camera (SN9C128)
363sn9c20x 0c45:628e PC Camera (SN9C202 + SOI968) 363sonixj 0c45:610e PC Camera (SN9C128)
364sn9c20x 0c45:628f PC Camera (SN9C202 + OV9650) 364sonixj 0c45:6128 Microdia/Sonix SNP325
365sn9c20x 0c45:62a0 PC Camera (SN9C202 + OV7670) 365sonixj 0c45:612a Avant Camera
366sn9c20x 0c45:62b0 PC Camera (SN9C202 + MT9V011/MT9V111/MT9V112) 366sonixj 0c45:612b Speed-Link REFLECT2
367sn9c20x 0c45:62b3 PC Camera (SN9C202 + OV9655) 367sonixj 0c45:612c Typhoon Rasy Cam 1.3MPix
368sn9c20x 0c45:62bb PC Camera (SN9C202 + OV7660) 368sonixj 0c45:612e PC Camera (SN9C110)
369sn9c20x 0c45:62bc PC Camera (SN9C202 + HV7131R) 369sonixj 0c45:6130 Sonix Pccam
370sn9c2028 0c45:8001 Wild Planet Digital Spy Camera 370sonixj 0c45:6138 Sn9c120 Mo4000
371sn9c2028 0c45:8003 Sakar #11199, #6637x, #67480 keychain cams 371sonixj 0c45:613a Microdia Sonix PC Camera
372sn9c2028 0c45:8008 Mini-Shotz ms-350 372sonixj 0c45:613b Surfer SN-206
373sn9c2028 0c45:800a Vivitar Vivicam 3350B 373sonixj 0c45:613c Sonix Pccam168
374sunplus 0d64:0303 Sunplus FashionCam DXG 374sonixj 0c45:613e PC Camera (SN9C120)
375ov519 0e96:c001 TRUST 380 USB2 SPACEC@M 375sonixj 0c45:6142 Hama PC-Webcam AC-150
376etoms 102c:6151 Qcam Sangha CIF 376sonixj 0c45:6143 Sonix Pccam168
377etoms 102c:6251 Qcam xxxxxx VGA 377sonixj 0c45:6148 Digitus DA-70811/ZSMC USB PC Camera ZS211/Microdia
378ov519 1046:9967 W9967CF/W9968CF WebCam IC, Video Blaster WebCam Go 378sonixj 0c45:614a Frontech E-Ccam (JIL-2225)
379zc3xx 10fd:0128 Typhoon Webshot II USB 300k 0x0128 379sn9c20x 0c45:6240 PC Camera (SN9C201 + MT9M001)
380spca561 10fd:7e50 FlyCam Usb 100 380sn9c20x 0c45:6242 PC Camera (SN9C201 + MT9M111)
381zc3xx 10fd:8050 Typhoon Webshot II USB 300k 381sn9c20x 0c45:6248 PC Camera (SN9C201 + OV9655)
382ov534 1415:2000 Sony HD Eye for PS3 (SLEH 00201) 382sn9c20x 0c45:624c PC Camera (SN9C201 + MT9M112)
383pac207 145f:013a Trust WB-1300N 383sn9c20x 0c45:624e PC Camera (SN9C201 + SOI968)
384sn9c20x 145f:013d Trust WB-3600R 384sn9c20x 0c45:624f PC Camera (SN9C201 + OV9650)
385vc032x 15b8:6001 HP 2.0 Megapixel 385sn9c20x 0c45:6251 PC Camera (SN9C201 + OV9650)
386vc032x 15b8:6002 HP 2.0 Megapixel rz406aa 386sn9c20x 0c45:6253 PC Camera (SN9C201 + OV9650)
387spca501 1776:501c Arowana 300K CMOS Camera 387sn9c20x 0c45:6260 PC Camera (SN9C201 + OV7670)
388t613 17a1:0128 TASCORP JPEG Webcam, NGS Cyclops 388sn9c20x 0c45:6270 PC Camera (SN9C201 + MT9V011/MT9V111/MT9V112)
389vc032x 17ef:4802 Lenovo Vc0323+MI1310_SOC 389sn9c20x 0c45:627b PC Camera (SN9C201 + OV7660)
390pac207 2001:f115 D-Link DSB-C120 390sn9c20x 0c45:627c PC Camera (SN9C201 + HV7131R)
391sq905c 2770:9050 Disney pix micro (CIF) 391sn9c20x 0c45:627f PC Camera (SN9C201 + OV9650)
392sq905c 2770:9051 Lego Bionicle 392sn9c20x 0c45:6280 PC Camera (SN9C202 + MT9M001)
393sq905c 2770:9052 Disney pix micro 2 (VGA) 393sn9c20x 0c45:6282 PC Camera (SN9C202 + MT9M111)
394sq905c 2770:905c All 11 known cameras with this ID 394sn9c20x 0c45:6288 PC Camera (SN9C202 + OV9655)
395sq905 2770:9120 All 24 known cameras with this ID 395sn9c20x 0c45:628c PC Camera (SN9C201 + MT9M112)
396sq905c 2770:913d All 4 known cameras with this ID 396sn9c20x 0c45:628e PC Camera (SN9C202 + SOI968)
397sq930x 2770:930b Sweex Motion Tracking / I-Tec iCam Tracer 397sn9c20x 0c45:628f PC Camera (SN9C202 + OV9650)
398sq930x 2770:930c Trust WB-3500T / NSG Robbie 2.0 398sn9c20x 0c45:62a0 PC Camera (SN9C202 + OV7670)
399spca500 2899:012c Toptro Industrial 399sn9c20x 0c45:62b0 PC Camera (SN9C202 + MT9V011/MT9V111/MT9V112)
400ov519 8020:ef04 ov519 400sn9c20x 0c45:62b3 PC Camera (SN9C202 + OV9655)
401spca508 8086:0110 Intel Easy PC Camera 401sn9c20x 0c45:62bb PC Camera (SN9C202 + OV7660)
402spca500 8086:0630 Intel Pocket PC Camera 402sn9c20x 0c45:62bc PC Camera (SN9C202 + HV7131R)
403spca506 99fa:8988 Grandtec V.cap 403sn9c2028 0c45:8001 Wild Planet Digital Spy Camera
404sn9c20x a168:0610 Dino-Lite Digital Microscope (SN9C201 + HV7131R) 404sn9c2028 0c45:8003 Sakar #11199, #6637x, #67480 keychain cams
405sn9c20x a168:0611 Dino-Lite Digital Microscope (SN9C201 + HV7131R) 405sn9c2028 0c45:8008 Mini-Shotz ms-350
406sn9c20x a168:0613 Dino-Lite Digital Microscope (SN9C201 + HV7131R) 406sn9c2028 0c45:800a Vivitar Vivicam 3350B
407sn9c20x a168:0618 Dino-Lite Digital Microscope (SN9C201 + HV7131R) 407sunplus 0d64:0303 Sunplus FashionCam DXG
408sn9c20x a168:0614 Dino-Lite Digital Microscope (SN9C201 + MT9M111) 408ov519 0e96:c001 TRUST 380 USB2 SPACEC@M
409sn9c20x a168:0615 Dino-Lite Digital Microscope (SN9C201 + MT9M111) 409etoms 102c:6151 Qcam Sangha CIF
410sn9c20x a168:0617 Dino-Lite Digital Microscope (SN9C201 + MT9M111) 410etoms 102c:6251 Qcam xxxxxx VGA
411spca561 abcd:cdee Petcam 411ov519 1046:9967 W9967CF/W9968CF WebCam IC, Video Blaster WebCam Go
412========= ========= ==================================================================== 412zc3xx 10fd:0128 Typhoon Webshot II USB 300k 0x0128
413spca561 10fd:7e50 FlyCam Usb 100
414zc3xx 10fd:804d Typhoon Webshot II Webcam [zc0301]
415zc3xx 10fd:8050 Typhoon Webshot II USB 300k
416ov534 1415:2000 Sony HD Eye for PS3 (SLEH 00201)
417pac207 145f:013a Trust WB-1300N
418pac7302 145f:013c Trust
419sn9c20x 145f:013d Trust WB-3600R
420vc032x 15b8:6001 HP 2.0 Megapixel
421vc032x 15b8:6002 HP 2.0 Megapixel rz406aa
422stk1135 174f:6a31 ASUSlaptop, MT9M112 sensor
423spca501 1776:501c Arowana 300K CMOS Camera
424t613 17a1:0128 TASCORP JPEG Webcam, NGS Cyclops
425vc032x 17ef:4802 Lenovo Vc0323+MI1310_SOC
426pac7302 1ae7:2001 SpeedLinkSnappy Mic SL-6825-SBK
427pac207 2001:f115 D-Link DSB-C120
428sq905c 2770:9050 Disney pix micro (CIF)
429sq905c 2770:9051 Lego Bionicle
430sq905c 2770:9052 Disney pix micro 2 (VGA)
431sq905c 2770:905c All 11 known cameras with this ID
432sq905 2770:9120 All 24 known cameras with this ID
433sq905c 2770:913d All 4 known cameras with this ID
434sq930x 2770:930b Sweex Motion Tracking / I-Tec iCam Tracer
435sq930x 2770:930c Trust WB-3500T / NSG Robbie 2.0
436spca500 2899:012c Toptro Industrial
437ov519 8020:ef04 ov519
438spca508 8086:0110 Intel Easy PC Camera
439spca500 8086:0630 Intel Pocket PC Camera
440spca506 99fa:8988 Grandtec V.cap
441sn9c20x a168:0610 Dino-Lite Digital Microscope (SN9C201 + HV7131R)
442sn9c20x a168:0611 Dino-Lite Digital Microscope (SN9C201 + HV7131R)
443sn9c20x a168:0613 Dino-Lite Digital Microscope (SN9C201 + HV7131R)
444sn9c20x a168:0614 Dino-Lite Digital Microscope (SN9C201 + MT9M111)
445sn9c20x a168:0615 Dino-Lite Digital Microscope (SN9C201 + MT9M111)
446sn9c20x a168:0617 Dino-Lite Digital Microscope (SN9C201 + MT9M111)
447sn9c20x a168:0618 Dino-Lite Digital Microscope (SN9C201 + HV7131R)
448spca561 abcd:cdee Petcam
449========= ========= ===================================================================
diff --git a/Documentation/media/v4l-drivers/index.rst b/Documentation/media/v4l-drivers/index.rst
index aac566f88833..a606d1cdac13 100644
--- a/Documentation/media/v4l-drivers/index.rst
+++ b/Documentation/media/v4l-drivers/index.rst
@@ -2,6 +2,8 @@
2 2
3.. include:: <isonum.txt> 3.. include:: <isonum.txt>
4 4
5.. _v4l-drivers:
6
5################################################ 7################################################
6Video4Linux (V4L) driver-specific documentation 8Video4Linux (V4L) driver-specific documentation
7################################################ 9################################################
@@ -46,6 +48,7 @@ For more details see the file COPYING in the source distribution of Linux.
46 pvrusb2 48 pvrusb2
47 pxa_camera 49 pxa_camera
48 radiotrack 50 radiotrack
51 rcar-fdp1
49 saa7134 52 saa7134
50 sh_mobile_ceu_camera 53 sh_mobile_ceu_camera
51 si470x 54 si470x
diff --git a/Documentation/media/v4l-drivers/ivtv-cardlist.rst b/Documentation/media/v4l-drivers/ivtv-cardlist.rst
index cd7e79d2963e..754ffa820b4c 100644
--- a/Documentation/media/v4l-drivers/ivtv-cardlist.rst
+++ b/Documentation/media/v4l-drivers/ivtv-cardlist.rst
@@ -1,29 +1,38 @@
1IVTV cards list 1IVTV cards list
2=============== 2===============
3 3
4.. code-block:: none 4=========== ============================================================= ====================================================
5 5Card number Card name PCI IDs
6 1 -> Hauppauge WinTV PVR-250 6=========== ============================================================= ====================================================
7 2 -> Hauppauge WinTV PVR-350 70 Hauppauge WinTV PVR-250 IVTV16 104d:813d
8 3 -> Hauppauge WinTV PVR-150 or PVR-500 81 Hauppauge WinTV PVR-350 IVTV16 104d:813d
9 4 -> AVerMedia M179 [1461:a3ce,1461:a3cf] 92 Hauppauge WinTV PVR-150 IVTV16 104d:813d
10 5 -> Yuan MPG600/Kuroutoshikou iTVC16-STVLP [12ab:fff3,12ab:ffff] 103 AVerMedia M179 IVTV15 1461:a3cf, IVTV15 1461:a3ce
11 6 -> Yuan MPG160/Kuroutoshikou iTVC15-STVLP [12ab:0000,10fc:40a0] 114 Yuan MPG600, Kuroutoshikou ITVC16-STVLP IVTV16 12ab:fff3, IVTV16 12ab:ffff
12 7 -> Yuan PG600/DiamondMM PVR-550 [ff92:0070,ffab:0600] 125 YUAN MPG160, Kuroutoshikou ITVC15-STVLP, I/O Data GV-M2TV/PCI IVTV15 10fc:40a0
13 8 -> Adaptec AVC-2410 [9005:0093] 136 Yuan PG600, Diamond PVR-550 IVTV16 ff92:0070, IVTV16 ffab:0600
14 9 -> Adaptec AVC-2010 [9005:0092] 147 Adaptec VideOh! AVC-2410 IVTV16 9005:0093
15 10 -> NAGASE TRANSGEAR 5000TV [1461:bfff] 158 Adaptec VideOh! AVC-2010 IVTV16 9005:0092
16 11 -> AOpen VA2000MAX-STN6 [0000:ff5f] 169 Nagase Transgear 5000TV IVTV16 1461:bfff
17 12 -> YUAN MPG600GR/Kuroutoshikou CX23416GYC-STVLP [12ab:0600,fbab:0600,1154:0523] 1710 AOpen VA2000MAX-SNT6 IVTV16 0000:ff5f
18 13 -> I/O Data GV-MVP/RX [10fc:d01e,10fc:d038,10fc:d039] 1811 Yuan MPG600GR, Kuroutoshikou CX23416GYC-STVLP IVTV16 12ab:0600, IVTV16 fbab:0600, IVTV16 1154:0523
19 14 -> I/O Data GV-MVP/RX2E [10fc:d025] 1912 I/O Data GV-MVP/RX, GV-MVP/RX2W (dual tuner) IVTV16 10fc:d01e, IVTV16 10fc:d038, IVTV16 10fc:d039
20 15 -> GOTVIEW PCI DVD (partial support only) [12ab:0600] 2013 I/O Data GV-MVP/RX2E IVTV16 10fc:d025
21 16 -> GOTVIEW PCI DVD2 Deluxe [ffac:0600] 2114 GotView PCI DVD IVTV16 12ab:0600
22 17 -> Yuan MPC622 [ff01:d998] 2215 GotView PCI DVD2 Deluxe IVTV16 ffac:0600
23 18 -> Digital Cowboy DCT-MTVP1 [1461:bfff] 2316 Yuan MPC622 IVTV16 ff01:d998
24 19 -> Yuan PG600V2/GotView PCI DVD Lite [ffab:0600,ffad:0600] 2417 Digital Cowboy DCT-MTVP1 IVTV16 1461:bfff
25 20 -> Club3D ZAP-TV1x01 [ffab:0600] 2518 Yuan PG600-2, GotView PCI DVD Lite IVTV16 ffab:0600, IVTV16 ffad:0600
26 21 -> AverTV MCE 116 Plus [1461:c439] 2619 Club3D ZAP-TV1x01 IVTV16 ffab:0600
27 22 -> ASUS Falcon2 [1043:4b66,1043:462e,1043:4b2e] 2720 AVerTV MCE 116 Plus IVTV16 1461:c439
28 23 -> AverMedia PVR-150 Plus [1461:c035] 2821 ASUS Falcon2 IVTV16 1043:4b66, IVTV16 1043:462e, IVTV16 1043:4b2e
29 24 -> AverMedia EZMaker PCI Deluxe [1461:c03f] 2922 AVerMedia PVR-150 Plus / AVerTV M113 Partsnic (Daewoo) Tuner IVTV16 1461:c034, IVTV16 1461:c035
3023 AVerMedia EZMaker PCI Deluxe IVTV16 1461:c03f
3124 AVerMedia M104 IVTV16 1461:c136
3225 Buffalo PC-MV5L/PCI IVTV16 1154:052b
3326 AVerMedia UltraTV 1500 MCE / AVerTV M113 Philips Tuner IVTV16 1461:c019, IVTV16 1461:c01b
3427 Sony VAIO Giga Pocket (ENX Kikyou) IVTV16 104d:813d
3528 Hauppauge WinTV PVR-350 (V1) IVTV16 104d:813d
3629 Yuan MPG600GR, Kuroutoshikou CX23416GYC-STVLP (no GR) IVTV16 104d:813d
3730 Yuan MPG600GR, Kuroutoshikou CX23416GYC-STVLP (no GR/YCS) IVTV16 104d:813d
38=========== ============================================================= ====================================================
diff --git a/Documentation/media/v4l-drivers/rcar-fdp1.rst b/Documentation/media/v4l-drivers/rcar-fdp1.rst
new file mode 100644
index 000000000000..a59b1e8e3e9c
--- /dev/null
+++ b/Documentation/media/v4l-drivers/rcar-fdp1.rst
@@ -0,0 +1,37 @@
1Renesas R-Car Fine Display Processor (FDP1) Driver
2==================================================
3
4The R-Car FDP1 driver implements driver-specific controls as follows.
5
6``V4L2_CID_DEINTERLACING_MODE (menu)``
7 The video deinterlacing mode (such as Bob, Weave, ...). The R-Car FDP1
8 driver implements the following modes.
9
10.. flat-table::
11 :header-rows: 0
12 :stub-columns: 0
13 :widths: 1 4
14
15 * - ``"Progressive" (0)``
16 - The input image video stream is progressive (not interlaced). No
17 deinterlacing is performed. Apart from (optional) format and encoding
18 conversion output frames are identical to the input frames.
19 * - ``"Adaptive 2D/3D" (1)``
20 - Motion adaptive version of 2D and 3D deinterlacing. Use 3D deinterlacing
21 in the presence of fast motion and 2D deinterlacing with diagonal
22 interpolation otherwise.
23 * - ``"Fixed 2D" (2)``
24 - The current field is scaled vertically by averaging adjacent lines to
25 recover missing lines. This method is also known as blending or Line
26 Averaging (LAV).
27 * - ``"Fixed 3D" (3)``
28 - The previous and next fields are averaged to recover lines missing from
29 the current field. This method is also known as Field Averaging (FAV).
30 * - ``"Previous field" (4)``
31 - The current field is weaved with the previous field, i.e. the previous
32 field is used to fill missing lines from the current field. This method
33 is also known as weave deinterlacing.
34 * - ``"Next field" (5)``
35 - The current field is weaved with the next field, i.e. the next field is
36 used to fill missing lines from the current field. This method is also
37 known as weave deinterlacing.
diff --git a/Documentation/media/v4l-drivers/saa7134-cardlist.rst b/Documentation/media/v4l-drivers/saa7134-cardlist.rst
index 22c1510d9fa6..a5efa8f4b8e4 100644
--- a/Documentation/media/v4l-drivers/saa7134-cardlist.rst
+++ b/Documentation/media/v4l-drivers/saa7134-cardlist.rst
@@ -1,202 +1,204 @@
1SAA7134 cards list 1SAA7134 cards list
2================== 2==================
3 3
4.. code-block:: none 4=========== ======================================================= ================================================================
5 5Card number Card name PCI IDs
6 0 -> UNKNOWN/GENERIC 6=========== ======================================================= ================================================================
7 1 -> Proteus Pro [philips reference design] [1131:2001,1131:2001] 70 UNKNOWN/GENERIC
8 2 -> LifeView FlyVIDEO3000 [5168:0138,4e42:0138] 81 Proteus Pro [philips reference design] 1131:2001, 1131:2001
9 3 -> LifeView/Typhoon FlyVIDEO2000 [5168:0138,4e42:0138] 92 LifeView FlyVIDEO3000 5168:0138, 4e42:0138
10 4 -> EMPRESS [1131:6752] 103 LifeView/Typhoon FlyVIDEO2000 5168:0138, 4e42:0138
11 5 -> SKNet Monster TV [1131:4e85] 114 EMPRESS 1131:6752
12 6 -> Tevion MD 9717 125 SKNet Monster TV 1131:4e85
13 7 -> KNC One TV-Station RDS / Typhoon TV Tuner RDS [1131:fe01,1894:fe01] 136 Tevion MD 9717
14 8 -> Terratec Cinergy 400 TV [153b:1142] 147 KNC One TV-Station RDS / Typhoon TV Tuner RDS 1131:fe01, 1894:fe01
15 9 -> Medion 5044 158 Terratec Cinergy 400 TV 153b:1142
16 10 -> Kworld/KuroutoShikou SAA7130-TVPCI 169 Medion 5044
17 11 -> Terratec Cinergy 600 TV [153b:1143] 1710 Kworld/KuroutoShikou SAA7130-TVPCI
18 12 -> Medion 7134 [16be:0003,16be:5000] 1811 Terratec Cinergy 600 TV 153b:1143
19 13 -> Typhoon TV+Radio 90031 1912 Medion 7134 16be:0003, 16be:5000
20 14 -> ELSA EX-VISION 300TV [1048:226b] 2013 Typhoon TV+Radio 90031
21 15 -> ELSA EX-VISION 500TV [1048:226a] 2114 ELSA EX-VISION 300TV 1048:226b
22 16 -> ASUS TV-FM 7134 [1043:4842,1043:4830,1043:4840] 2215 ELSA EX-VISION 500TV 1048:226a
23 17 -> AOPEN VA1000 POWER [1131:7133] 2316 ASUS TV-FM 7134 1043:4842, 1043:4830, 1043:4840
24 18 -> BMK MPEX No Tuner 2417 AOPEN VA1000 POWER 1131:7133
25 19 -> Compro VideoMate TV [185b:c100] 2518 BMK MPEX No Tuner
26 20 -> Matrox CronosPlus [102B:48d0] 2619 Compro VideoMate TV 185b:c100
27 21 -> 10MOONS PCI TV CAPTURE CARD [1131:2001] 2720 Matrox CronosPlus 102B:48d0
28 22 -> AverMedia M156 / Medion 2819 [1461:a70b] 2821 10MOONS PCI TV CAPTURE CARD 1131:2001
29 23 -> BMK MPEX Tuner 2922 AverMedia M156 / Medion 2819 1461:a70b
30 24 -> KNC One TV-Station DVR [1894:a006] 3023 BMK MPEX Tuner
31 25 -> ASUS TV-FM 7133 [1043:4843] 3124 KNC One TV-Station DVR 1894:a006
32 26 -> Pinnacle PCTV Stereo (saa7134) [11bd:002b] 3225 ASUS TV-FM 7133 1043:4843
33 27 -> Manli MuchTV M-TV002 3326 Pinnacle PCTV Stereo (saa7134) 11bd:002b
34 28 -> Manli MuchTV M-TV001 3427 Manli MuchTV M-TV002
35 29 -> Nagase Sangyo TransGear 3000TV [1461:050c] 3528 Manli MuchTV M-TV001
36 30 -> Elitegroup ECS TVP3XP FM1216 Tuner Card(PAL-BG,FM) [1019:4cb4] 3629 Nagase Sangyo TransGear 3000TV 1461:050c
37 31 -> Elitegroup ECS TVP3XP FM1236 Tuner Card (NTSC,FM) [1019:4cb5] 3730 Elitegroup ECS TVP3XP FM1216 Tuner Card(PAL-BG,FM) 1019:4cb4
38 32 -> AVACS SmartTV 3831 Elitegroup ECS TVP3XP FM1236 Tuner Card (NTSC,FM) 1019:4cb5
39 33 -> AVerMedia DVD EZMaker [1461:10ff] 3932 AVACS SmartTV
40 34 -> Noval Prime TV 7133 4033 AVerMedia DVD EZMaker 1461:10ff
41 35 -> AverMedia AverTV Studio 305 [1461:2115] 4134 Noval Prime TV 7133
42 36 -> UPMOST PURPLE TV [12ab:0800] 4235 AverMedia AverTV Studio 305 1461:2115
43 37 -> Items MuchTV Plus / IT-005 4336 UPMOST PURPLE TV 12ab:0800
44 38 -> Terratec Cinergy 200 TV [153b:1152] 4437 Items MuchTV Plus / IT-005
45 39 -> LifeView FlyTV Platinum Mini [5168:0212,4e42:0212,5169:1502] 4538 Terratec Cinergy 200 TV 153b:1152
46 40 -> Compro VideoMate TV PVR/FM [185b:c100] 4639 LifeView FlyTV Platinum Mini 5168:0212, 4e42:0212, 5169:1502
47 41 -> Compro VideoMate TV Gold+ [185b:c100] 4740 Compro VideoMate TV PVR/FM 185b:c100
48 42 -> Sabrent SBT-TVFM (saa7130) 4841 Compro VideoMate TV Gold+ 185b:c100
49 43 -> :Zolid Xpert TV7134 4942 Sabrent SBT-TVFM (saa7130)
50 44 -> Empire PCI TV-Radio LE 5043 :Zolid Xpert TV7134
51 45 -> Avermedia AVerTV Studio 307 [1461:9715] 5144 Empire PCI TV-Radio LE
52 46 -> AVerMedia Cardbus TV/Radio (E500) [1461:d6ee] 5245 Avermedia AVerTV Studio 307 1461:9715
53 47 -> Terratec Cinergy 400 mobile [153b:1162] 5346 AVerMedia Cardbus TV/Radio (E500) 1461:d6ee
54 48 -> Terratec Cinergy 600 TV MK3 [153b:1158] 5447 Terratec Cinergy 400 mobile 153b:1162
55 49 -> Compro VideoMate Gold+ Pal [185b:c200] 5548 Terratec Cinergy 600 TV MK3 153b:1158
56 50 -> Pinnacle PCTV 300i DVB-T + PAL [11bd:002d] 5649 Compro VideoMate Gold+ Pal 185b:c200
57 51 -> ProVideo PV952 [1540:9524] 5750 Pinnacle PCTV 300i DVB-T + PAL 11bd:002d
58 52 -> AverMedia AverTV/305 [1461:2108] 5851 ProVideo PV952 1540:9524
59 53 -> ASUS TV-FM 7135 [1043:4845] 5952 AverMedia AverTV/305 1461:2108
60 54 -> LifeView FlyTV Platinum FM / Gold [5168:0214,5168:5214,1489:0214,5168:0304] 6053 ASUS TV-FM 7135 1043:4845
61 55 -> LifeView FlyDVB-T DUO / MSI TV@nywhere Duo [5168:0306,4E42:0306] 6154 LifeView FlyTV Platinum FM / Gold 5168:0214, 5168:5214, 1489:0214, 5168:0304
62 56 -> Avermedia AVerTV 307 [1461:a70a] 6255 LifeView FlyDVB-T DUO / MSI TV@nywhere Duo 5168:0306, 4E42:0306
63 57 -> Avermedia AVerTV GO 007 FM [1461:f31f] 6356 Avermedia AVerTV 307 1461:a70a
64 58 -> ADS Tech Instant TV (saa7135) [1421:0350,1421:0351,1421:0370,1421:1370] 6457 Avermedia AVerTV GO 007 FM 1461:f31f
65 59 -> Kworld/Tevion V-Stream Xpert TV PVR7134 6558 ADS Tech Instant TV (saa7135) 1421:0350, 1421:0351, 1421:0370, 1421:1370
66 60 -> LifeView/Typhoon/Genius FlyDVB-T Duo Cardbus [5168:0502,4e42:0502,1489:0502] 6659 Kworld/Tevion V-Stream Xpert TV PVR7134
67 61 -> Philips TOUGH DVB-T reference design [1131:2004] 6760 LifeView/Typhoon/Genius FlyDVB-T Duo Cardbus 5168:0502, 4e42:0502, 1489:0502
68 62 -> Compro VideoMate TV Gold+II 6861 Philips TOUGH DVB-T reference design 1131:2004
69 63 -> Kworld Xpert TV PVR7134 6962 Compro VideoMate TV Gold+II
70 64 -> FlyTV mini Asus Digimatrix [1043:0210] 7063 Kworld Xpert TV PVR7134
71 65 -> V-Stream Studio TV Terminator 7164 FlyTV mini Asus Digimatrix 1043:0210
72 66 -> Yuan TUN-900 (saa7135) 7265 V-Stream Studio TV Terminator
73 67 -> Beholder BeholdTV 409 FM [0000:4091] 7366 Yuan TUN-900 (saa7135)
74 68 -> GoTView 7135 PCI [5456:7135] 7467 Beholder BeholdTV 409 FM 0000:4091
75 69 -> Philips EUROPA V3 reference design [1131:2004] 7568 GoTView 7135 PCI 5456:7135
76 70 -> Compro Videomate DVB-T300 [185b:c900] 7669 Philips EUROPA V3 reference design 1131:2004
77 71 -> Compro Videomate DVB-T200 [185b:c901] 7770 Compro Videomate DVB-T300 185b:c900
78 72 -> RTD Embedded Technologies VFG7350 [1435:7350] 7871 Compro Videomate DVB-T200 185b:c901
79 73 -> RTD Embedded Technologies VFG7330 [1435:7330] 7972 RTD Embedded Technologies VFG7350 1435:7350
80 74 -> LifeView FlyTV Platinum Mini2 [14c0:1212] 8073 RTD Embedded Technologies VFG7330 1435:7330
81 75 -> AVerMedia AVerTVHD MCE A180 [1461:1044] 8174 LifeView FlyTV Platinum Mini2 14c0:1212
82 76 -> SKNet MonsterTV Mobile [1131:4ee9] 8275 AVerMedia AVerTVHD MCE A180 1461:1044
83 77 -> Pinnacle PCTV 40i/50i/110i (saa7133) [11bd:002e] 8376 SKNet MonsterTV Mobile 1131:4ee9
84 78 -> ASUSTeK P7131 Dual [1043:4862] 8477 Pinnacle PCTV 40i/50i/110i (saa7133) 11bd:002e
85 79 -> Sedna/MuchTV PC TV Cardbus TV/Radio (ITO25 Rev:2B) 8578 ASUSTeK P7131 Dual 1043:4862
86 80 -> ASUS Digimatrix TV [1043:0210] 8679 Sedna/MuchTV PC TV Cardbus TV/Radio (ITO25 Rev:2B)
87 81 -> Philips Tiger reference design [1131:2018] 8780 ASUS Digimatrix TV 1043:0210
88 82 -> MSI TV@Anywhere plus [1462:6231,1462:8624] 8881 Philips Tiger reference design 1131:2018
89 83 -> Terratec Cinergy 250 PCI TV [153b:1160] 8982 MSI TV@Anywhere plus 1462:6231, 1462:8624
90 84 -> LifeView FlyDVB Trio [5168:0319] 9083 Terratec Cinergy 250 PCI TV 153b:1160
91 85 -> AverTV DVB-T 777 [1461:2c05,1461:2c05] 9184 LifeView FlyDVB Trio 5168:0319
92 86 -> LifeView FlyDVB-T / Genius VideoWonder DVB-T [5168:0301,1489:0301] 9285 AverTV DVB-T 777 1461:2c05, 1461:2c05
93 87 -> ADS Instant TV Duo Cardbus PTV331 [0331:1421] 9386 LifeView FlyDVB-T / Genius VideoWonder DVB-T 5168:0301, 1489:0301
94 88 -> Tevion/KWorld DVB-T 220RF [17de:7201] 9487 ADS Instant TV Duo Cardbus PTV331 0331:1421
95 89 -> ELSA EX-VISION 700TV [1048:226c] 9588 Tevion/KWorld DVB-T 220RF 17de:7201
96 90 -> Kworld ATSC110/115 [17de:7350,17de:7352] 9689 ELSA EX-VISION 700TV 1048:226c
97 91 -> AVerMedia A169 B [1461:7360] 9790 Kworld ATSC110/115 17de:7350, 17de:7352
98 92 -> AVerMedia A169 B1 [1461:6360] 9891 AVerMedia A169 B 1461:7360
99 93 -> Medion 7134 Bridge #2 [16be:0005] 9992 AVerMedia A169 B1 1461:6360
100 94 -> LifeView FlyDVB-T Hybrid Cardbus/MSI TV @nywhere A/D NB [5168:3306,5168:3502,5168:3307,4e42:3502] 10093 Medion 7134 Bridge #2 16be:0005
101 95 -> LifeView FlyVIDEO3000 (NTSC) [5169:0138] 10194 LifeView FlyDVB-T Hybrid Cardbus/MSI TV @nywhere A/D NB 5168:3306, 5168:3502, 5168:3307, 4e42:3502
102 96 -> Medion Md8800 Quadro [16be:0007,16be:0008,16be:000d] 10295 LifeView FlyVIDEO3000 (NTSC) 5169:0138
103 97 -> LifeView FlyDVB-S /Acorp TV134DS [5168:0300,4e42:0300] 10396 Medion Md8800 Quadro 16be:0007, 16be:0008, 16be:000d
104 98 -> Proteus Pro 2309 [0919:2003] 10497 LifeView FlyDVB-S /Acorp TV134DS 5168:0300, 4e42:0300
105 99 -> AVerMedia TV Hybrid A16AR [1461:2c00] 10598 Proteus Pro 2309 0919:2003
106 100 -> Asus Europa2 OEM [1043:4860] 10699 AVerMedia TV Hybrid A16AR 1461:2c00
107 101 -> Pinnacle PCTV 310i [11bd:002f] 107100 Asus Europa2 OEM 1043:4860
108 102 -> Avermedia AVerTV Studio 507 [1461:9715] 108101 Pinnacle PCTV 310i 11bd:002f
109 103 -> Compro Videomate DVB-T200A 109102 Avermedia AVerTV Studio 507 1461:9715
110 104 -> Hauppauge WinTV-HVR1110 DVB-T/Hybrid [0070:6700,0070:6701,0070:6702,0070:6703,0070:6704,0070:6705] 110103 Compro Videomate DVB-T200A
111 105 -> Terratec Cinergy HT PCMCIA [153b:1172] 111104 Hauppauge WinTV-HVR1110 DVB-T/Hybrid 0070:6700, 0070:6701, 0070:6702, 0070:6703, 0070:6704, 0070:6705
112 106 -> Encore ENLTV [1131:2342,1131:2341,3016:2344] 112105 Terratec Cinergy HT PCMCIA 153b:1172
113 107 -> Encore ENLTV-FM [1131:230f] 113106 Encore ENLTV 1131:2342, 1131:2341, 3016:2344
114 108 -> Terratec Cinergy HT PCI [153b:1175] 114107 Encore ENLTV-FM 1131:230f
115 109 -> Philips Tiger - S Reference design 115108 Terratec Cinergy HT PCI 153b:1175
116 110 -> Avermedia M102 [1461:f31e] 116109 Philips Tiger - S Reference design
117 111 -> ASUS P7131 4871 [1043:4871] 117110 Avermedia M102 1461:f31e
118 112 -> ASUSTeK P7131 Hybrid [1043:4876] 118111 ASUS P7131 4871 1043:4871
119 113 -> Elitegroup ECS TVP3XP FM1246 Tuner Card (PAL,FM) [1019:4cb6] 119112 ASUSTeK P7131 Hybrid 1043:4876
120 114 -> KWorld DVB-T 210 [17de:7250] 120113 Elitegroup ECS TVP3XP FM1246 Tuner Card (PAL,FM) 1019:4cb6
121 115 -> Sabrent PCMCIA TV-PCB05 [0919:2003] 121114 KWorld DVB-T 210 17de:7250
122 116 -> 10MOONS TM300 TV Card [1131:2304] 122115 Sabrent PCMCIA TV-PCB05 0919:2003
123 117 -> Avermedia Super 007 [1461:f01d] 123116 10MOONS TM300 TV Card 1131:2304
124 118 -> Beholder BeholdTV 401 [0000:4016] 124117 Avermedia Super 007 1461:f01d
125 119 -> Beholder BeholdTV 403 [0000:4036] 125118 Beholder BeholdTV 401 0000:4016
126 120 -> Beholder BeholdTV 403 FM [0000:4037] 126119 Beholder BeholdTV 403 0000:4036
127 121 -> Beholder BeholdTV 405 [0000:4050] 127120 Beholder BeholdTV 403 FM 0000:4037
128 122 -> Beholder BeholdTV 405 FM [0000:4051] 128121 Beholder BeholdTV 405 0000:4050
129 123 -> Beholder BeholdTV 407 [0000:4070] 129122 Beholder BeholdTV 405 FM 0000:4051
130 124 -> Beholder BeholdTV 407 FM [0000:4071] 130123 Beholder BeholdTV 407 0000:4070
131 125 -> Beholder BeholdTV 409 [0000:4090] 131124 Beholder BeholdTV 407 FM 0000:4071
132 126 -> Beholder BeholdTV 505 FM [5ace:5050] 132125 Beholder BeholdTV 409 0000:4090
133 127 -> Beholder BeholdTV 507 FM / BeholdTV 509 FM [5ace:5070,5ace:5090] 133126 Beholder BeholdTV 505 FM 5ace:5050
134 128 -> Beholder BeholdTV Columbus TV/FM [0000:5201] 134127 Beholder BeholdTV 507 FM / BeholdTV 509 FM 5ace:5070, 5ace:5090
135 129 -> Beholder BeholdTV 607 FM [5ace:6070] 135128 Beholder BeholdTV Columbus TV/FM 0000:5201
136 130 -> Beholder BeholdTV M6 [5ace:6190] 136129 Beholder BeholdTV 607 FM 5ace:6070
137 131 -> Twinhan Hybrid DTV-DVB 3056 PCI [1822:0022] 137130 Beholder BeholdTV M6 5ace:6190
138 132 -> Genius TVGO AM11MCE 138131 Twinhan Hybrid DTV-DVB 3056 PCI 1822:0022
139 133 -> NXP Snake DVB-S reference design 139132 Genius TVGO AM11MCE
140 134 -> Medion/Creatix CTX953 Hybrid [16be:0010] 140133 NXP Snake DVB-S reference design
141 135 -> MSI TV@nywhere A/D v1.1 [1462:8625] 141134 Medion/Creatix CTX953 Hybrid 16be:0010
142 136 -> AVerMedia Cardbus TV/Radio (E506R) [1461:f436] 142135 MSI TV@nywhere A/D v1.1 1462:8625
143 137 -> AVerMedia Hybrid TV/Radio (A16D) [1461:f936] 143136 AVerMedia Cardbus TV/Radio (E506R) 1461:f436
144 138 -> Avermedia M115 [1461:a836] 144137 AVerMedia Hybrid TV/Radio (A16D) 1461:f936
145 139 -> Compro VideoMate T750 [185b:c900] 145138 Avermedia M115 1461:a836
146 140 -> Avermedia DVB-S Pro A700 [1461:a7a1] 146139 Compro VideoMate T750 185b:c900
147 141 -> Avermedia DVB-S Hybrid+FM A700 [1461:a7a2] 147140 Avermedia DVB-S Pro A700 1461:a7a1
148 142 -> Beholder BeholdTV H6 [5ace:6290] 148141 Avermedia DVB-S Hybrid+FM A700 1461:a7a2
149 143 -> Beholder BeholdTV M63 [5ace:6191] 149142 Beholder BeholdTV H6 5ace:6290
150 144 -> Beholder BeholdTV M6 Extra [5ace:6193] 150143 Beholder BeholdTV M63 5ace:6191
151 145 -> AVerMedia MiniPCI DVB-T Hybrid M103 [1461:f636,1461:f736] 151144 Beholder BeholdTV M6 Extra 5ace:6193
152 146 -> ASUSTeK P7131 Analog 152145 AVerMedia MiniPCI DVB-T Hybrid M103 1461:f636, 1461:f736
153 147 -> Asus Tiger 3in1 [1043:4878] 153146 ASUSTeK P7131 Analog
154 148 -> Encore ENLTV-FM v5.3 [1a7f:2008] 154147 Asus Tiger 3in1 1043:4878
155 149 -> Avermedia PCI pure analog (M135A) [1461:f11d] 155148 Encore ENLTV-FM v5.3 1a7f:2008
156 150 -> Zogis Real Angel 220 156149 Avermedia PCI pure analog (M135A) 1461:f11d
157 151 -> ADS Tech Instant HDTV [1421:0380] 157150 Zogis Real Angel 220
158 152 -> Asus Tiger Rev:1.00 [1043:4857] 158151 ADS Tech Instant HDTV 1421:0380
159 153 -> Kworld Plus TV Analog Lite PCI [17de:7128] 159152 Asus Tiger Rev:1.00 1043:4857
160 154 -> Avermedia AVerTV GO 007 FM Plus [1461:f31d] 160153 Kworld Plus TV Analog Lite PCI 17de:7128
161 155 -> Hauppauge WinTV-HVR1150 ATSC/QAM-Hybrid [0070:6706,0070:6708] 161154 Avermedia AVerTV GO 007 FM Plus 1461:f31d
162 156 -> Hauppauge WinTV-HVR1120 DVB-T/Hybrid [0070:6707,0070:6709,0070:670a] 162155 Hauppauge WinTV-HVR1150 ATSC/QAM-Hybrid 0070:6706, 0070:6708
163 157 -> Avermedia AVerTV Studio 507UA [1461:a11b] 163156 Hauppauge WinTV-HVR1120 DVB-T/Hybrid 0070:6707, 0070:6709, 0070:670a
164 158 -> AVerMedia Cardbus TV/Radio (E501R) [1461:b7e9] 164157 Avermedia AVerTV Studio 507UA 1461:a11b
165 159 -> Beholder BeholdTV 505 RDS [0000:505B] 165158 AVerMedia Cardbus TV/Radio (E501R) 1461:b7e9
166 160 -> Beholder BeholdTV 507 RDS [0000:5071] 166159 Beholder BeholdTV 505 RDS 0000:505B
167 161 -> Beholder BeholdTV 507 RDS [0000:507B] 167160 Beholder BeholdTV 507 RDS 0000:5071
168 162 -> Beholder BeholdTV 607 FM [5ace:6071] 168161 Beholder BeholdTV 507 RDS 0000:507B
169 163 -> Beholder BeholdTV 609 FM [5ace:6090] 169162 Beholder BeholdTV 607 FM 5ace:6071
170 164 -> Beholder BeholdTV 609 FM [5ace:6091] 170163 Beholder BeholdTV 609 FM 5ace:6090
171 165 -> Beholder BeholdTV 607 RDS [5ace:6072] 171164 Beholder BeholdTV 609 FM 5ace:6091
172 166 -> Beholder BeholdTV 607 RDS [5ace:6073] 172165 Beholder BeholdTV 607 RDS 5ace:6072
173 167 -> Beholder BeholdTV 609 RDS [5ace:6092] 173166 Beholder BeholdTV 607 RDS 5ace:6073
174 168 -> Beholder BeholdTV 609 RDS [5ace:6093] 174167 Beholder BeholdTV 609 RDS 5ace:6092
175 169 -> Compro VideoMate S350/S300 [185b:c900] 175168 Beholder BeholdTV 609 RDS 5ace:6093
176 170 -> AverMedia AverTV Studio 505 [1461:a115] 176169 Compro VideoMate S350/S300 185b:c900
177 171 -> Beholder BeholdTV X7 [5ace:7595] 177170 AverMedia AverTV Studio 505 1461:a115
178 172 -> RoverMedia TV Link Pro FM [19d1:0138] 178171 Beholder BeholdTV X7 5ace:7595
179 173 -> Zolid Hybrid TV Tuner PCI [1131:2004] 179172 RoverMedia TV Link Pro FM 19d1:0138
180 174 -> Asus Europa Hybrid OEM [1043:4847] 180173 Zolid Hybrid TV Tuner PCI 1131:2004
181 175 -> Leadtek Winfast DTV1000S [107d:6655] 181174 Asus Europa Hybrid OEM 1043:4847
182 176 -> Beholder BeholdTV 505 RDS [0000:5051] 182175 Leadtek Winfast DTV1000S 107d:6655
183 177 -> Hawell HW-404M7 183176 Beholder BeholdTV 505 RDS 0000:5051
184 178 -> Beholder BeholdTV H7 [5ace:7190] 184177 Hawell HW-404M7
185 179 -> Beholder BeholdTV A7 [5ace:7090] 185178 Beholder BeholdTV H7 5ace:7190
186 180 -> Avermedia PCI M733A [1461:4155,1461:4255] 186179 Beholder BeholdTV A7 5ace:7090
187 181 -> TechoTrend TT-budget T-3000 [13c2:2804] 187180 Avermedia PCI M733A 1461:4155, 1461:4255
188 182 -> Kworld PCI SBTVD/ISDB-T Full-Seg Hybrid [17de:b136] 188181 TechoTrend TT-budget T-3000 13c2:2804
189 183 -> Compro VideoMate Vista M1F [185b:c900] 189182 Kworld PCI SBTVD/ISDB-T Full-Seg Hybrid 17de:b136
190 184 -> Encore ENLTV-FM 3 [1a7f:2108] 190183 Compro VideoMate Vista M1F 185b:c900
191 185 -> MagicPro ProHDTV Pro2 DMB-TH/Hybrid [17de:d136] 191184 Encore ENLTV-FM 3 1a7f:2108
192 186 -> Beholder BeholdTV 501 [5ace:5010] 192185 MagicPro ProHDTV Pro2 DMB-TH/Hybrid 17de:d136
193 187 -> Beholder BeholdTV 503 FM [5ace:5030] 193186 Beholder BeholdTV 501 5ace:5010
194 188 -> Sensoray 811/911 [6000:0811,6000:0911] 194187 Beholder BeholdTV 503 FM 5ace:5030
195 189 -> Kworld PC150-U [17de:a134] 195188 Sensoray 811/911 6000:0811, 6000:0911
196 190 -> Asus My Cinema PS3-100 [1043:48cd] 196189 Kworld PC150-U 17de:a134
197 191 -> Hawell HW-9004V1 197190 Asus My Cinema PS3-100 1043:48cd
198 192 -> AverMedia AverTV Satellite Hybrid+FM A706 [1461:2055] 198191 Hawell HW-9004V1
199 193 -> WIS Voyager or compatible [1905:7007] 199192 AverMedia AverTV Satellite Hybrid+FM A706 1461:2055
200 194 -> AverMedia AverTV/505 [1461:a10a] 200193 WIS Voyager or compatible 1905:7007
201 195 -> Leadtek Winfast TV2100 FM [107d:6f3a] 201194 AverMedia AverTV/505 1461:a10a
202 196 -> SnaZio* TVPVR PRO [1779:13cf] 202195 Leadtek Winfast TV2100 FM 107d:6f3a
203196 SnaZio* TVPVR PRO 1779:13cf
204=========== ======================================================= ================================================================
diff --git a/Documentation/media/v4l-drivers/saa7164-cardlist.rst b/Documentation/media/v4l-drivers/saa7164-cardlist.rst
index b937836cd54c..7d17d38df3bc 100644
--- a/Documentation/media/v4l-drivers/saa7164-cardlist.rst
+++ b/Documentation/media/v4l-drivers/saa7164-cardlist.rst
@@ -1,19 +1,21 @@
1SAA7134 cards list 1SAA7164 cards list
2================== 2==================
3 3
4.. code-block:: none 4=========== ==================================== ====================
5 5Card number Card name PCI IDs
6 0 -> Unknown 6=========== ==================================== ====================
7 1 -> Generic Rev2 70 Unknown
8 2 -> Generic Rev3 81 Generic Rev2
9 3 -> Hauppauge WinTV-HVR2250 [0070:8880,0070:8810] 92 Generic Rev3
10 4 -> Hauppauge WinTV-HVR2200 [0070:8980] 103 Hauppauge WinTV-HVR2250 0070:8880, 0070:8810
11 5 -> Hauppauge WinTV-HVR2200 [0070:8900] 114 Hauppauge WinTV-HVR2200 0070:8980
12 6 -> Hauppauge WinTV-HVR2200 [0070:8901] 125 Hauppauge WinTV-HVR2200 0070:8900
13 7 -> Hauppauge WinTV-HVR2250 [0070:8891,0070:8851] 136 Hauppauge WinTV-HVR2200 0070:8901
14 8 -> Hauppauge WinTV-HVR2250 [0070:88A1] 147 Hauppauge WinTV-HVR2250 0070:8891, 0070:8851
15 9 -> Hauppauge WinTV-HVR2200 [0070:8940] 158 Hauppauge WinTV-HVR2250 0070:88A1
16 10 -> Hauppauge WinTV-HVR2200 [0070:8953] 169 Hauppauge WinTV-HVR2200 0070:8940
17 11 -> Hauppauge WinTV-HVR2255(proto) 1710 Hauppauge WinTV-HVR2200 0070:8953
18 12 -> Hauppauge WinTV-HVR2255 [0070:f111] 1811 Hauppauge WinTV-HVR2255(proto) 0070:f111
19 13 -> Hauppauge WinTV-HVR2205 [0070:f123,0070:f120] 1912 Hauppauge WinTV-HVR2255 0070:f111
2013 Hauppauge WinTV-HVR2205 0070:f123, 0070:f120
21=========== ==================================== ====================
diff --git a/Documentation/media/v4l-drivers/tm6000-cardlist.rst b/Documentation/media/v4l-drivers/tm6000-cardlist.rst
index 2fbd3886b5f0..ae2952683ccf 100644
--- a/Documentation/media/v4l-drivers/tm6000-cardlist.rst
+++ b/Documentation/media/v4l-drivers/tm6000-cardlist.rst
@@ -1,21 +1,24 @@
1TM6000 cards list 1TM6000 cards list
2================= 2=================
3 3
4.. code-block:: none 4=========== ================================================= ==========================================
5 5Card number Card name USB IDs
6 1 -> Generic tm5600 board (tm5600) [6000:0001] 6=========== ================================================= ==========================================
7 2 -> Generic tm6000 board (tm6000) [6000:0001] 70 Unknown tm6000 video grabber
8 3 -> Generic tm6010 board (tm6010) [6000:0002] 81 Generic tm5600 board 6000:0001
9 4 -> 10Moons UT821 (tm5600) [6000:0001] 92 Generic tm6000 board
10 5 -> 10Moons UT330 (tm5600) 103 Generic tm6010 board 6000:0002
11 6 -> ADSTech Dual TV (tm6000) [06e1:f332] 114 10Moons UT 821
12 7 -> FreeCom and similar (tm6000) [14aa:0620] 125 10Moons UT 330
13 8 -> ADSTech Mini Dual TV (tm6000) [06e1:b339] 136 ADSTECH Dual TV USB 06e1:f332
14 9 -> Hauppauge WinTV HVR-900H/USB2 Stick (tm6010) [2040:6600,2040:6601,2040:6610,2040:6611] 147 Freecom Hybrid Stick / Moka DVB-T Receiver Dual 14aa:0620
15 10 -> Beholder Wander (tm6010) [6000:dec0] 158 ADSTECH Mini Dual TV USB 06e1:b339
16 11 -> Beholder Voyager (tm6010) [6000:dec1] 169 Hauppauge WinTV HVR-900H / WinTV USB2-Stick 2040:6600, 2040:6601, 2040:6610, 2040:6611
17 12 -> TerraTec Cinergy Hybrid XE/Cinergy Hybrid Stick (tm6010) [0ccd:0086,0ccd:00a5] 1710 Beholder Wander DVB-T/TV/FM USB2.0 6000:dec0
18 13 -> TwinHan TU501 (tm6010) [13d3:3240,13d3:3241,13d3:3243,13d3:3264] 1811 Beholder Voyager TV/FM USB2.0 6000:dec1
19 14 -> Beholder Wander Lite (tm6010) [6000:dec2] 1912 Terratec Cinergy Hybrid XE / Cinergy Hybrid-Stick 0ccd:0086, 0ccd:00A5
20 15 -> Beholder Voyager Lite (tm6010) [6000:dec3] 2013 Twinhan TU501(704D1) 13d3:3240, 13d3:3241, 13d3:3243, 13d3:3264
21 2114 Beholder Wander Lite DVB-T/TV/FM USB2.0 6000:dec2
2215 Beholder Voyager Lite TV/FM USB2.0 6000:dec3
2316 Terratec Grabster AV 150/250 MX 0ccd:0079
24=========== ================================================= ==========================================
diff --git a/Documentation/media/v4l-drivers/tuner-cardlist.rst b/Documentation/media/v4l-drivers/tuner-cardlist.rst
index 2f1e1029c04e..276dd90e0c59 100644
--- a/Documentation/media/v4l-drivers/tuner-cardlist.rst
+++ b/Documentation/media/v4l-drivers/tuner-cardlist.rst
@@ -1,96 +1,98 @@
1Tuner cards list 1Tuner cards list
2================ 2================
3 3
4.. code-block:: none 4============ =====================================================
5 5Tuner number Card name
6 tuner=0 - Temic PAL (4002 FH5) 6============ =====================================================
7 tuner=1 - Philips PAL_I (FI1246 and compatibles) 70 Temic PAL (4002 FH5)
8 tuner=2 - Philips NTSC (FI1236,FM1236 and compatibles) 81 Philips PAL_I (FI1246 and compatibles)
9 tuner=3 - Philips (SECAM+PAL_BG) (FI1216MF, FM1216MF, FR1216MF) 92 Philips NTSC (FI1236,FM1236 and compatibles)
10 tuner=4 - NoTuner 103 Philips (SECAM+PAL_BG) (FI1216MF, FM1216MF, FR1216MF)
11 tuner=5 - Philips PAL_BG (FI1216 and compatibles) 114 NoTuner
12 tuner=6 - Temic NTSC (4032 FY5) 125 Philips PAL_BG (FI1216 and compatibles)
13 tuner=7 - Temic PAL_I (4062 FY5) 136 Temic NTSC (4032 FY5)
14 tuner=8 - Temic NTSC (4036 FY5) 147 Temic PAL_I (4062 FY5)
15 tuner=9 - Alps HSBH1 158 Temic NTSC (4036 FY5)
16 tuner=10 - Alps TSBE1 169 Alps HSBH1
17 tuner=11 - Alps TSBB5 1710 Alps TSBE1
18 tuner=12 - Alps TSBE5 1811 Alps TSBB5
19 tuner=13 - Alps TSBC5 1912 Alps TSBE5
20 tuner=14 - Temic PAL_BG (4006FH5) 2013 Alps TSBC5
21 tuner=15 - Alps TSCH6 2114 Temic PAL_BG (4006FH5)
22 tuner=16 - Temic PAL_DK (4016 FY5) 2215 Alps TSCH6
23 tuner=17 - Philips NTSC_M (MK2) 2316 Temic PAL_DK (4016 FY5)
24 tuner=18 - Temic PAL_I (4066 FY5) 2417 Philips NTSC_M (MK2)
25 tuner=19 - Temic PAL* auto (4006 FN5) 2518 Temic PAL_I (4066 FY5)
26 tuner=20 - Temic PAL_BG (4009 FR5) or PAL_I (4069 FR5) 2619 Temic PAL* auto (4006 FN5)
27 tuner=21 - Temic NTSC (4039 FR5) 2720 Temic PAL_BG (4009 FR5) or PAL_I (4069 FR5)
28 tuner=22 - Temic PAL/SECAM multi (4046 FM5) 2821 Temic NTSC (4039 FR5)
29 tuner=23 - Philips PAL_DK (FI1256 and compatibles) 2922 Temic PAL/SECAM multi (4046 FM5)
30 tuner=24 - Philips PAL/SECAM multi (FQ1216ME) 3023 Philips PAL_DK (FI1256 and compatibles)
31 tuner=25 - LG PAL_I+FM (TAPC-I001D) 3124 Philips PAL/SECAM multi (FQ1216ME)
32 tuner=26 - LG PAL_I (TAPC-I701D) 3225 LG PAL_I+FM (TAPC-I001D)
33 tuner=27 - LG NTSC+FM (TPI8NSR01F) 3326 LG PAL_I (TAPC-I701D)
34 tuner=28 - LG PAL_BG+FM (TPI8PSB01D) 3427 LG NTSC+FM (TPI8NSR01F)
35 tuner=29 - LG PAL_BG (TPI8PSB11D) 3528 LG PAL_BG+FM (TPI8PSB01D)
36 tuner=30 - Temic PAL* auto + FM (4009 FN5) 3629 LG PAL_BG (TPI8PSB11D)
37 tuner=31 - SHARP NTSC_JP (2U5JF5540) 3730 Temic PAL* auto + FM (4009 FN5)
38 tuner=32 - Samsung PAL TCPM9091PD27 3831 SHARP NTSC_JP (2U5JF5540)
39 tuner=33 - MT20xx universal 3932 Samsung PAL TCPM9091PD27
40 tuner=34 - Temic PAL_BG (4106 FH5) 4033 MT20xx universal
41 tuner=35 - Temic PAL_DK/SECAM_L (4012 FY5) 4134 Temic PAL_BG (4106 FH5)
42 tuner=36 - Temic NTSC (4136 FY5) 4235 Temic PAL_DK/SECAM_L (4012 FY5)
43 tuner=37 - LG PAL (newer TAPC series) 4336 Temic NTSC (4136 FY5)
44 tuner=38 - Philips PAL/SECAM multi (FM1216ME MK3) 4437 LG PAL (newer TAPC series)
45 tuner=39 - LG NTSC (newer TAPC series) 4538 Philips PAL/SECAM multi (FM1216ME MK3)
46 tuner=40 - HITACHI V7-J180AT 4639 LG NTSC (newer TAPC series)
47 tuner=41 - Philips PAL_MK (FI1216 MK) 4740 HITACHI V7-J180AT
48 tuner=42 - Philips FCV1236D ATSC/NTSC dual in 4841 Philips PAL_MK (FI1216 MK)
49 tuner=43 - Philips NTSC MK3 (FM1236MK3 or FM1236/F) 4942 Philips FCV1236D ATSC/NTSC dual in
50 tuner=44 - Philips 4 in 1 (ATI TV Wonder Pro/Conexant) 5043 Philips NTSC MK3 (FM1236MK3 or FM1236/F)
51 tuner=45 - Microtune 4049 FM5 5144 Philips 4 in 1 (ATI TV Wonder Pro/Conexant)
52 tuner=46 - Panasonic VP27s/ENGE4324D 5245 Microtune 4049 FM5
53 tuner=47 - LG NTSC (TAPE series) 5346 Panasonic VP27s/ENGE4324D
54 tuner=48 - Tenna TNF 8831 BGFF) 5447 LG NTSC (TAPE series)
55 tuner=49 - Microtune 4042 FI5 ATSC/NTSC dual in 5548 Tenna TNF 8831 BGFF)
56 tuner=50 - TCL 2002N 5649 Microtune 4042 FI5 ATSC/NTSC dual in
57 tuner=51 - Philips PAL/SECAM_D (FM 1256 I-H3) 5750 TCL 2002N
58 tuner=52 - Thomson DTT 7610 (ATSC/NTSC) 5851 Philips PAL/SECAM_D (FM 1256 I-H3)
59 tuner=53 - Philips FQ1286 5952 Thomson DTT 7610 (ATSC/NTSC)
60 tuner=54 - Philips/NXP TDA 8290/8295 + 8275/8275A/18271 6053 Philips FQ1286
61 tuner=55 - TCL 2002MB 6154 Philips/NXP TDA 8290/8295 + 8275/8275A/18271
62 tuner=56 - Philips PAL/SECAM multi (FQ1216AME MK4) 6255 TCL 2002MB
63 tuner=57 - Philips FQ1236A MK4 6356 Philips PAL/SECAM multi (FQ1216AME MK4)
64 tuner=58 - Ymec TVision TVF-8531MF/8831MF/8731MF 6457 Philips FQ1236A MK4
65 tuner=59 - Ymec TVision TVF-5533MF 6558 Ymec TVision TVF-8531MF/8831MF/8731MF
66 tuner=60 - Thomson DTT 761X (ATSC/NTSC) 6659 Ymec TVision TVF-5533MF
67 tuner=61 - Tena TNF9533-D/IF/TNF9533-B/DF 6760 Thomson DTT 761X (ATSC/NTSC)
68 tuner=62 - Philips TEA5767HN FM Radio 6861 Tena TNF9533-D/IF/TNF9533-B/DF
69 tuner=63 - Philips FMD1216ME MK3 Hybrid Tuner 6962 Philips TEA5767HN FM Radio
70 tuner=64 - LG TDVS-H06xF 7063 Philips FMD1216ME MK3 Hybrid Tuner
71 tuner=65 - Ymec TVF66T5-B/DFF 7164 LG TDVS-H06xF
72 tuner=66 - LG TALN series 7265 Ymec TVF66T5-B/DFF
73 tuner=67 - Philips TD1316 Hybrid Tuner 7366 LG TALN series
74 tuner=68 - Philips TUV1236D ATSC/NTSC dual in 7467 Philips TD1316 Hybrid Tuner
75 tuner=69 - Tena TNF 5335 and similar models 7568 Philips TUV1236D ATSC/NTSC dual in
76 tuner=70 - Samsung TCPN 2121P30A 7669 Tena TNF 5335 and similar models
77 tuner=71 - Xceive xc2028/xc3028 tuner 7770 Samsung TCPN 2121P30A
78 tuner=72 - Thomson FE6600 7871 Xceive xc2028/xc3028 tuner
79 tuner=73 - Samsung TCPG 6121P30A 7972 Thomson FE6600
80 tuner=75 - Philips TEA5761 FM Radio 8073 Samsung TCPG 6121P30A
81 tuner=76 - Xceive 5000 tuner 8175 Philips TEA5761 FM Radio
82 tuner=77 - TCL tuner MF02GIP-5N-E 8276 Xceive 5000 tuner
83 tuner=78 - Philips FMD1216MEX MK3 Hybrid Tuner 8377 TCL tuner MF02GIP-5N-E
84 tuner=79 - Philips PAL/SECAM multi (FM1216 MK5) 8478 Philips FMD1216MEX MK3 Hybrid Tuner
85 tuner=80 - Philips FQ1216LME MK3 PAL/SECAM w/active loopthrough 8579 Philips PAL/SECAM multi (FM1216 MK5)
86 tuner=81 - Partsnic (Daewoo) PTI-5NF05 8680 Philips FQ1216LME MK3 PAL/SECAM w/active loopthrough
87 tuner=82 - Philips CU1216L 8781 Partsnic (Daewoo) PTI-5NF05
88 tuner=83 - NXP TDA18271 8882 Philips CU1216L
89 tuner=84 - Sony BTF-Pxn01Z 8983 NXP TDA18271
90 tuner=85 - Philips FQ1236 MK5 9084 Sony BTF-Pxn01Z
91 tuner=86 - Tena TNF5337 MFD 9185 Philips FQ1236 MK5
92 tuner=87 - Xceive 4000 tuner 9286 Tena TNF5337 MFD
93 tuner=88 - Xceive 5000C tuner 9387 Xceive 4000 tuner
94 tuner=89 - Sony BTF-PG472Z PAL/SECAM 9488 Xceive 5000C tuner
95 tuner=90 - Sony BTF-PK467Z NTSC-M-JP 9589 Sony BTF-PG472Z PAL/SECAM
96 tuner=91 - Sony BTF-PB463Z NTSC-M 9690 Sony BTF-PK467Z NTSC-M-JP
9791 Sony BTF-PB463Z NTSC-M
98============ =====================================================
diff --git a/Documentation/media/v4l-drivers/usbvision-cardlist.rst b/Documentation/media/v4l-drivers/usbvision-cardlist.rst
index 3d8be9cb1b5a..44d53dff0984 100644
--- a/Documentation/media/v4l-drivers/usbvision-cardlist.rst
+++ b/Documentation/media/v4l-drivers/usbvision-cardlist.rst
@@ -1,72 +1,74 @@
1Usbvision cards list 1USBvision cards list
2==================== 2====================
3 3
4.. code-block:: none 4=========== ======================================================== =========
5 5Card number Card name USB IDs
6 0 -> Xanboo [0a6f:0400] 6=========== ======================================================== =========
7 1 -> Belkin USB VideoBus II Adapter [050d:0106] 70 Xanboo 0a6f:0400
8 2 -> Belkin Components USB VideoBus [050d:0207] 81 Belkin USB VideoBus II Adapter 050d:0106
9 3 -> Belkin USB VideoBus II [050d:0208] 92 Belkin Components USB VideoBus 050d:0207
10 4 -> echoFX InterView Lite [0571:0002] 103 Belkin USB VideoBus II 050d:0208
11 5 -> USBGear USBG-V1 resp. HAMA USB [0573:0003] 114 echoFX InterView Lite 0571:0002
12 6 -> D-Link V100 [0573:0400] 125 USBGear USBG-V1 resp. HAMA USB 0573:0003
13 7 -> X10 USB Camera [0573:2000] 136 D-Link V100 0573:0400
14 8 -> Hauppauge WinTV USB Live (PAL B/G) [0573:2d00] 147 X10 USB Camera 0573:2000
15 9 -> Hauppauge WinTV USB Live Pro (NTSC M/N) [0573:2d01] 158 Hauppauge WinTV USB Live (PAL B/G) 0573:2d00
16 10 -> Zoran Co. PMD (Nogatech) AV-grabber Manhattan [0573:2101] 169 Hauppauge WinTV USB Live Pro (NTSC M/N) 0573:2d01
17 11 -> Nogatech USB-TV (NTSC) FM [0573:4100] 1710 Zoran Co. PMD (Nogatech) AV-grabber Manhattan 0573:2101
18 12 -> PNY USB-TV (NTSC) FM [0573:4110] 1811 Nogatech USB-TV (NTSC) FM 0573:4100
19 13 -> PixelView PlayTv-USB PRO (PAL) FM [0573:4450] 1912 PNY USB-TV (NTSC) FM 0573:4110
20 14 -> ZTV ZT-721 2.4GHz USB A/V Receiver [0573:4550] 2013 PixelView PlayTv-USB PRO (PAL) FM 0573:4450
21 15 -> Hauppauge WinTV USB (NTSC M/N) [0573:4d00] 2114 ZTV ZT-721 2.4GHz USB A/V Receiver 0573:4550
22 16 -> Hauppauge WinTV USB (PAL B/G) [0573:4d01] 2215 Hauppauge WinTV USB (NTSC M/N) 0573:4d00
23 17 -> Hauppauge WinTV USB (PAL I) [0573:4d02] 2316 Hauppauge WinTV USB (PAL B/G) 0573:4d01
24 18 -> Hauppauge WinTV USB (PAL/SECAM L) [0573:4d03] 2417 Hauppauge WinTV USB (PAL I) 0573:4d02
25 19 -> Hauppauge WinTV USB (PAL D/K) [0573:4d04] 2518 Hauppauge WinTV USB (PAL/SECAM L) 0573:4d03
26 20 -> Hauppauge WinTV USB (NTSC FM) [0573:4d10] 2619 Hauppauge WinTV USB (PAL D/K) 0573:4d04
27 21 -> Hauppauge WinTV USB (PAL B/G FM) [0573:4d11] 2720 Hauppauge WinTV USB (NTSC FM) 0573:4d10
28 22 -> Hauppauge WinTV USB (PAL I FM) [0573:4d12] 2821 Hauppauge WinTV USB (PAL B/G FM) 0573:4d11
29 23 -> Hauppauge WinTV USB (PAL D/K FM) [0573:4d14] 2922 Hauppauge WinTV USB (PAL I FM) 0573:4d12
30 24 -> Hauppauge WinTV USB Pro (NTSC M/N) [0573:4d2a] 3023 Hauppauge WinTV USB (PAL D/K FM) 0573:4d14
31 25 -> Hauppauge WinTV USB Pro (NTSC M/N) V2 [0573:4d2b] 3124 Hauppauge WinTV USB Pro (NTSC M/N) 0573:4d2a
32 26 -> Hauppauge WinTV USB Pro (PAL/SECAM B/G/I/D/K/L) [0573:4d2c] 3225 Hauppauge WinTV USB Pro (NTSC M/N) V2 0573:4d2b
33 27 -> Hauppauge WinTV USB Pro (NTSC M/N) V3 [0573:4d20] 3326 Hauppauge WinTV USB Pro (PAL/SECAM B/G/I/D/K/L) 0573:4d2c
34 28 -> Hauppauge WinTV USB Pro (PAL B/G) [0573:4d21] 3427 Hauppauge WinTV USB Pro (NTSC M/N) V3 0573:4d20
35 29 -> Hauppauge WinTV USB Pro (PAL I) [0573:4d22] 3528 Hauppauge WinTV USB Pro (PAL B/G) 0573:4d21
36 30 -> Hauppauge WinTV USB Pro (PAL/SECAM L) [0573:4d23] 3629 Hauppauge WinTV USB Pro (PAL I) 0573:4d22
37 31 -> Hauppauge WinTV USB Pro (PAL D/K) [0573:4d24] 3730 Hauppauge WinTV USB Pro (PAL/SECAM L) 0573:4d23
38 32 -> Hauppauge WinTV USB Pro (PAL/SECAM BGDK/I/L) [0573:4d25] 3831 Hauppauge WinTV USB Pro (PAL D/K) 0573:4d24
39 33 -> Hauppauge WinTV USB Pro (PAL/SECAM BGDK/I/L) V2 [0573:4d26] 3932 Hauppauge WinTV USB Pro (PAL/SECAM BGDK/I/L) 0573:4d25
40 34 -> Hauppauge WinTV USB Pro (PAL B/G) V2 [0573:4d27] 4033 Hauppauge WinTV USB Pro (PAL/SECAM BGDK/I/L) V2 0573:4d26
41 35 -> Hauppauge WinTV USB Pro (PAL B/G,D/K) [0573:4d28] 4134 Hauppauge WinTV USB Pro (PAL B/G) V2 0573:4d27
42 36 -> Hauppauge WinTV USB Pro (PAL I,D/K) [0573:4d29] 4235 Hauppauge WinTV USB Pro (PAL B/G,D/K) 0573:4d28
43 37 -> Hauppauge WinTV USB Pro (NTSC M/N FM) [0573:4d30] 4336 Hauppauge WinTV USB Pro (PAL I,D/K) 0573:4d29
44 38 -> Hauppauge WinTV USB Pro (PAL B/G FM) [0573:4d31] 4437 Hauppauge WinTV USB Pro (NTSC M/N FM) 0573:4d30
45 39 -> Hauppauge WinTV USB Pro (PAL I FM) [0573:4d32] 4538 Hauppauge WinTV USB Pro (PAL B/G FM) 0573:4d31
46 40 -> Hauppauge WinTV USB Pro (PAL D/K FM) [0573:4d34] 4639 Hauppauge WinTV USB Pro (PAL I FM) 0573:4d32
47 41 -> Hauppauge WinTV USB Pro (Temic PAL/SECAM B/G/I/D/K/L FM) [0573:4d35] 4740 Hauppauge WinTV USB Pro (PAL D/K FM) 0573:4d34
48 42 -> Hauppauge WinTV USB Pro (Temic PAL B/G FM) [0573:4d36] 4841 Hauppauge WinTV USB Pro (Temic PAL/SECAM B/G/I/D/K/L FM) 0573:4d35
49 43 -> Hauppauge WinTV USB Pro (PAL/SECAM B/G/I/D/K/L FM) [0573:4d37] 4942 Hauppauge WinTV USB Pro (Temic PAL B/G FM) 0573:4d36
50 44 -> Hauppauge WinTV USB Pro (NTSC M/N FM) V2 [0573:4d38] 5043 Hauppauge WinTV USB Pro (PAL/SECAM B/G/I/D/K/L FM) 0573:4d37
51 45 -> Camtel Technology USB TV Genie Pro FM Model TVB330 [0768:0006] 5144 Hauppauge WinTV USB Pro (NTSC M/N FM) V2 0573:4d38
52 46 -> Digital Video Creator I [07d0:0001] 5245 Camtel Technology USB TV Genie Pro FM Model TVB330 0768:0006
53 47 -> Global Village GV-007 (NTSC) [07d0:0002] 5346 Digital Video Creator I 07d0:0001
54 48 -> Dazzle Fusion Model DVC-50 Rev 1 (NTSC) [07d0:0003] 5447 Global Village GV-007 (NTSC) 07d0:0002
55 49 -> Dazzle Fusion Model DVC-80 Rev 1 (PAL) [07d0:0004] 5548 Dazzle Fusion Model DVC-50 Rev 1 (NTSC) 07d0:0003
56 50 -> Dazzle Fusion Model DVC-90 Rev 1 (SECAM) [07d0:0005] 5649 Dazzle Fusion Model DVC-80 Rev 1 (PAL) 07d0:0004
57 51 -> Eskape Labs MyTV2Go [07f8:9104] 5750 Dazzle Fusion Model DVC-90 Rev 1 (SECAM) 07d0:0005
58 52 -> Pinnacle Studio PCTV USB (PAL) [2304:010d] 5851 Eskape Labs MyTV2Go 07f8:9104
59 53 -> Pinnacle Studio PCTV USB (SECAM) [2304:0109] 5952 Pinnacle Studio PCTV USB (PAL) 2304:010d
60 54 -> Pinnacle Studio PCTV USB (PAL) FM [2304:0110] 6053 Pinnacle Studio PCTV USB (SECAM) 2304:0109
61 55 -> Miro PCTV USB [2304:0111] 6154 Pinnacle Studio PCTV USB (PAL) FM 2304:0110
62 56 -> Pinnacle Studio PCTV USB (NTSC) FM [2304:0112] 6255 Miro PCTV USB 2304:0111
63 57 -> Pinnacle Studio PCTV USB (PAL) FM V2 [2304:0210] 6356 Pinnacle Studio PCTV USB (NTSC) FM 2304:0112
64 58 -> Pinnacle Studio PCTV USB (NTSC) FM V2 [2304:0212] 6457 Pinnacle Studio PCTV USB (PAL) FM V2 2304:0210
65 59 -> Pinnacle Studio PCTV USB (PAL) FM V3 [2304:0214] 6558 Pinnacle Studio PCTV USB (NTSC) FM V2 2304:0212
66 60 -> Pinnacle Studio Linx Video input cable (NTSC) [2304:0300] 6659 Pinnacle Studio PCTV USB (PAL) FM V3 2304:0214
67 61 -> Pinnacle Studio Linx Video input cable (PAL) [2304:0301] 6760 Pinnacle Studio Linx Video input cable (NTSC) 2304:0300
68 62 -> Pinnacle PCTV Bungee USB (PAL) FM [2304:0419] 6861 Pinnacle Studio Linx Video input cable (PAL) 2304:0301
69 63 -> Hauppauge WinTv-USB [2400:4200] 6962 Pinnacle PCTV Bungee USB (PAL) FM 2304:0419
70 64 -> Pinnacle Studio PCTV USB (NTSC) FM V3 [2304:0113] 7063 Hauppauge WinTv-USB 2400:4200
71 65 -> Nogatech USB MicroCam NTSC (NV3000N) [0573:3000] 7164 Pinnacle Studio PCTV USB (NTSC) FM V3 2304:0113
72 66 -> Nogatech USB MicroCam PAL (NV3001P) [0573:3001] 7265 Nogatech USB MicroCam NTSC (NV3000N) 0573:3000
7366 Nogatech USB MicroCam PAL (NV3001P) 0573:3001
74=========== ======================================================== =========
diff --git a/Documentation/media/videodev2.h.rst.exceptions b/Documentation/media/videodev2.h.rst.exceptions
index 1d3f27d922b2..e11a0d0a8931 100644
--- a/Documentation/media/videodev2.h.rst.exceptions
+++ b/Documentation/media/videodev2.h.rst.exceptions
@@ -87,6 +87,10 @@ replace symbol V4L2_YCBCR_ENC_XV601 :c:type:`v4l2_ycbcr_encoding`
87replace symbol V4L2_YCBCR_ENC_XV709 :c:type:`v4l2_ycbcr_encoding` 87replace symbol V4L2_YCBCR_ENC_XV709 :c:type:`v4l2_ycbcr_encoding`
88replace symbol V4L2_YCBCR_ENC_SMPTE240M :c:type:`v4l2_ycbcr_encoding` 88replace symbol V4L2_YCBCR_ENC_SMPTE240M :c:type:`v4l2_ycbcr_encoding`
89 89
90# Documented enum v4l2_hsv_encoding
91replace symbol V4L2_HSV_ENC_180 :c:type:`v4l2_hsv_encoding`
92replace symbol V4L2_HSV_ENC_256 :c:type:`v4l2_hsv_encoding`
93
90# Documented enum v4l2_quantization 94# Documented enum v4l2_quantization
91replace symbol V4L2_QUANTIZATION_DEFAULT :c:type:`v4l2_quantization` 95replace symbol V4L2_QUANTIZATION_DEFAULT :c:type:`v4l2_quantization`
92replace symbol V4L2_QUANTIZATION_FULL_RANGE :c:type:`v4l2_quantization` 96replace symbol V4L2_QUANTIZATION_FULL_RANGE :c:type:`v4l2_quantization`
@@ -276,6 +280,9 @@ replace define V4L2_DV_FL_REDUCED_FPS dv-bt-standards
276replace define V4L2_DV_FL_HALF_LINE dv-bt-standards 280replace define V4L2_DV_FL_HALF_LINE dv-bt-standards
277replace define V4L2_DV_FL_IS_CE_VIDEO dv-bt-standards 281replace define V4L2_DV_FL_IS_CE_VIDEO dv-bt-standards
278replace define V4L2_DV_FL_FIRST_FIELD_EXTRA_LINE dv-bt-standards 282replace define V4L2_DV_FL_FIRST_FIELD_EXTRA_LINE dv-bt-standards
283replace define V4L2_DV_FL_HAS_PICTURE_ASPECT dv-bt-standards
284replace define V4L2_DV_FL_HAS_CEA861_VIC dv-bt-standards
285replace define V4L2_DV_FL_HAS_HDMI_VIC dv-bt-standards
279 286
280replace define V4L2_DV_BT_656_1120 dv-timing-types 287replace define V4L2_DV_BT_656_1120 dv-timing-types
281 288
diff --git a/MAINTAINERS b/MAINTAINERS
index c77e3bff262f..592fdbaa283e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2982,15 +2982,15 @@ L: linux-media@vger.kernel.org
2982T: git git://linuxtv.org/media_tree.git 2982T: git git://linuxtv.org/media_tree.git
2983W: http://linuxtv.org 2983W: http://linuxtv.org
2984S: Supported 2984S: Supported
2985F: Documentation/cec.txt 2985F: Documentation/media/kapi/cec-core.rst
2986F: Documentation/media/uapi/cec 2986F: Documentation/media/uapi/cec
2987F: drivers/staging/media/cec/ 2987F: drivers/media/cec/
2988F: drivers/media/cec-edid.c 2988F: drivers/media/cec-edid.c
2989F: drivers/media/rc/keymaps/rc-cec.c 2989F: drivers/media/rc/keymaps/rc-cec.c
2990F: include/media/cec.h 2990F: include/media/cec.h
2991F: include/media/cec-edid.h 2991F: include/media/cec-edid.h
2992F: include/linux/cec.h 2992F: include/uapi/linux/cec.h
2993F: include/linux/cec-funcs.h 2993F: include/uapi/linux/cec-funcs.h
2994 2994
2995CELL BROADBAND ENGINE ARCHITECTURE 2995CELL BROADBAND ENGINE ARCHITECTURE
2996M: Arnd Bergmann <arnd@arndb.de> 2996M: Arnd Bergmann <arnd@arndb.de>
@@ -7748,6 +7748,15 @@ F: Documentation/devicetree/bindings/media/renesas,fcp.txt
7748F: drivers/media/platform/rcar-fcp.c 7748F: drivers/media/platform/rcar-fcp.c
7749F: include/media/rcar-fcp.h 7749F: include/media/rcar-fcp.h
7750 7750
7751MEDIA DRIVERS FOR RENESAS - FDP1
7752M: Kieran Bingham <kieran@bingham.xyz>
7753L: linux-media@vger.kernel.org
7754L: linux-renesas-soc@vger.kernel.org
7755T: git git://linuxtv.org/media_tree.git
7756S: Supported
7757F: Documentation/devicetree/bindings/media/renesas,fdp1.txt
7758F: drivers/media/platform/rcar_fdp1.c
7759
7751MEDIA DRIVERS FOR RENESAS - VIN 7760MEDIA DRIVERS FOR RENESAS - VIN
7752M: Niklas Söderlund <niklas.soderlund@ragnatech.se> 7761M: Niklas Söderlund <niklas.soderlund@ragnatech.se>
7753L: linux-media@vger.kernel.org 7762L: linux-media@vger.kernel.org
@@ -7854,6 +7863,24 @@ L: netdev@vger.kernel.org
7854S: Maintained 7863S: Maintained
7855F: drivers/net/ethernet/mediatek/ 7864F: drivers/net/ethernet/mediatek/
7856 7865
7866MEDIATEK MEDIA DRIVER
7867M: Tiffany Lin <tiffany.lin@mediatek.com>
7868M: Andrew-CT Chen <andrew-ct.chen@mediatek.com>
7869S: Supported
7870F: drivers/media/platform/mtk-vcodec/
7871F: drivers/media/platform/mtk-vpu/
7872F: Documentation/devicetree/bindings/media/mediatek-vcodec.txt
7873F: Documentation/devicetree/bindings/media/mediatek-vpu.txt
7874
7875MEDIATEK MDP DRIVER
7876M: Minghsiu Tsai <minghsiu.tsai@mediatek.com>
7877M: Houlong Wei <houlong.wei@mediatek.com>
7878M: Andrew-CT Chen <andrew-ct.chen@mediatek.com>
7879S: Supported
7880F: drivers/media/platform/mtk-mdp/
7881F: drivers/media/platform/mtk-vpu/
7882F: Documentation/devicetree/bindings/media/mediatek-mdp.txt
7883
7857MEDIATEK MT7601U WIRELESS LAN DRIVER 7884MEDIATEK MT7601U WIRELESS LAN DRIVER
7858M: Jakub Kicinski <kubakici@wp.pl> 7885M: Jakub Kicinski <kubakici@wp.pl>
7859L: linux-wireless@vger.kernel.org 7886L: linux-wireless@vger.kernel.org
@@ -9803,7 +9830,7 @@ M: Hans Verkuil <hverkuil@xs4all.nl>
9803L: linux-media@vger.kernel.org 9830L: linux-media@vger.kernel.org
9804T: git git://linuxtv.org/media_tree.git 9831T: git git://linuxtv.org/media_tree.git
9805S: Maintained 9832S: Maintained
9806F: drivers/staging/media/pulse8-cec 9833F: drivers/media/usb/pulse8-cec/*
9807 9834
9808PVRUSB2 VIDEO4LINUX DRIVER 9835PVRUSB2 VIDEO4LINUX DRIVER
9809M: Mike Isely <isely@pobox.com> 9836M: Mike Isely <isely@pobox.com>
@@ -10623,6 +10650,12 @@ S: Maintained
10623F: Documentation/devicetree/bindings/serial/ 10650F: Documentation/devicetree/bindings/serial/
10624F: drivers/tty/serial/ 10651F: drivers/tty/serial/
10625 10652
10653SERIAL IR RECEIVER
10654M: Sean Young <sean@mess.org>
10655L: linux-media@vger.kernel.org
10656S: Maintained
10657F: drivers/media/rc/serial_ir.c
10658
10626STI CEC DRIVER 10659STI CEC DRIVER
10627M: Benjamin Gaignard <benjamin.gaignard@linaro.org> 10660M: Benjamin Gaignard <benjamin.gaignard@linaro.org>
10628L: kernel@stlinux.com 10661L: kernel@stlinux.com
diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 1c71e256601d..6689abf99367 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -41,6 +41,14 @@
41 dpi0 = &dpi0; 41 dpi0 = &dpi0;
42 dsi0 = &dsi0; 42 dsi0 = &dsi0;
43 dsi1 = &dsi1; 43 dsi1 = &dsi1;
44 mdp_rdma0 = &mdp_rdma0;
45 mdp_rdma1 = &mdp_rdma1;
46 mdp_rsz0 = &mdp_rsz0;
47 mdp_rsz1 = &mdp_rsz1;
48 mdp_rsz2 = &mdp_rsz2;
49 mdp_wdma0 = &mdp_wdma0;
50 mdp_wrot0 = &mdp_wrot0;
51 mdp_wrot1 = &mdp_wrot1;
44 }; 52 };
45 53
46 cpus { 54 cpus {
@@ -755,6 +763,82 @@
755 #clock-cells = <1>; 763 #clock-cells = <1>;
756 }; 764 };
757 765
766 mdp {
767 compatible = "mediatek,mt8173-mdp";
768 #address-cells = <2>;
769 #size-cells = <2>;
770 ranges;
771 mediatek,vpu = <&vpu>;
772
773 mdp_rdma0: rdma@14001000 {
774 compatible = "mediatek,mt8173-mdp-rdma";
775 reg = <0 0x14001000 0 0x1000>;
776 clocks = <&mmsys CLK_MM_MDP_RDMA0>,
777 <&mmsys CLK_MM_MUTEX_32K>;
778 power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>;
779 iommus = <&iommu M4U_PORT_MDP_RDMA0>;
780 mediatek,larb = <&larb0>;
781 };
782
783 mdp_rdma1: rdma@14002000 {
784 compatible = "mediatek,mt8173-mdp-rdma";
785 reg = <0 0x14002000 0 0x1000>;
786 clocks = <&mmsys CLK_MM_MDP_RDMA1>,
787 <&mmsys CLK_MM_MUTEX_32K>;
788 power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>;
789 iommus = <&iommu M4U_PORT_MDP_RDMA1>;
790 mediatek,larb = <&larb4>;
791 };
792
793 mdp_rsz0: rsz@14003000 {
794 compatible = "mediatek,mt8173-mdp-rsz";
795 reg = <0 0x14003000 0 0x1000>;
796 clocks = <&mmsys CLK_MM_MDP_RSZ0>;
797 power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>;
798 };
799
800 mdp_rsz1: rsz@14004000 {
801 compatible = "mediatek,mt8173-mdp-rsz";
802 reg = <0 0x14004000 0 0x1000>;
803 clocks = <&mmsys CLK_MM_MDP_RSZ1>;
804 power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>;
805 };
806
807 mdp_rsz2: rsz@14005000 {
808 compatible = "mediatek,mt8173-mdp-rsz";
809 reg = <0 0x14005000 0 0x1000>;
810 clocks = <&mmsys CLK_MM_MDP_RSZ2>;
811 power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>;
812 };
813
814 mdp_wdma0: wdma@14006000 {
815 compatible = "mediatek,mt8173-mdp-wdma";
816 reg = <0 0x14006000 0 0x1000>;
817 clocks = <&mmsys CLK_MM_MDP_WDMA>;
818 power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>;
819 iommus = <&iommu M4U_PORT_MDP_WDMA>;
820 mediatek,larb = <&larb0>;
821 };
822
823 mdp_wrot0: wrot@14007000 {
824 compatible = "mediatek,mt8173-mdp-wrot";
825 reg = <0 0x14007000 0 0x1000>;
826 clocks = <&mmsys CLK_MM_MDP_WROT0>;
827 power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>;
828 iommus = <&iommu M4U_PORT_MDP_WROT0>;
829 mediatek,larb = <&larb0>;
830 };
831
832 mdp_wrot1: wrot@14008000 {
833 compatible = "mediatek,mt8173-mdp-wrot";
834 reg = <0 0x14008000 0 0x1000>;
835 clocks = <&mmsys CLK_MM_MDP_WROT1>;
836 power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>;
837 iommus = <&iommu M4U_PORT_MDP_WROT1>;
838 mediatek,larb = <&larb4>;
839 };
840 };
841
758 ovl0: ovl@1400c000 { 842 ovl0: ovl@1400c000 {
759 compatible = "mediatek,mt8173-disp-ovl"; 843 compatible = "mediatek,mt8173-disp-ovl";
760 reg = <0 0x1400c000 0 0x1000>; 844 reg = <0 0x1400c000 0 0x1000>;
@@ -1051,6 +1135,50 @@
1051 #clock-cells = <1>; 1135 #clock-cells = <1>;
1052 }; 1136 };
1053 1137
1138 vcodec_dec: vcodec@16000000 {
1139 compatible = "mediatek,mt8173-vcodec-dec";
1140 reg = <0 0x16000000 0 0x100>, /* VDEC_SYS */
1141 <0 0x16020000 0 0x1000>, /* VDEC_MISC */
1142 <0 0x16021000 0 0x800>, /* VDEC_LD */
1143 <0 0x16021800 0 0x800>, /* VDEC_TOP */
1144 <0 0x16022000 0 0x1000>, /* VDEC_CM */
1145 <0 0x16023000 0 0x1000>, /* VDEC_AD */
1146 <0 0x16024000 0 0x1000>, /* VDEC_AV */
1147 <0 0x16025000 0 0x1000>, /* VDEC_PP */
1148 <0 0x16026800 0 0x800>, /* VDEC_HWD */
1149 <0 0x16027000 0 0x800>, /* VDEC_HWQ */
1150 <0 0x16027800 0 0x800>, /* VDEC_HWB */
1151 <0 0x16028400 0 0x400>; /* VDEC_HWG */
1152 interrupts = <GIC_SPI 204 IRQ_TYPE_LEVEL_LOW>;
1153 mediatek,larb = <&larb1>;
1154 iommus = <&iommu M4U_PORT_HW_VDEC_MC_EXT>,
1155 <&iommu M4U_PORT_HW_VDEC_PP_EXT>,
1156 <&iommu M4U_PORT_HW_VDEC_AVC_MV_EXT>,
1157 <&iommu M4U_PORT_HW_VDEC_PRED_RD_EXT>,
1158 <&iommu M4U_PORT_HW_VDEC_PRED_WR_EXT>,
1159 <&iommu M4U_PORT_HW_VDEC_UFO_EXT>,
1160 <&iommu M4U_PORT_HW_VDEC_VLD_EXT>,
1161 <&iommu M4U_PORT_HW_VDEC_VLD2_EXT>;
1162 mediatek,vpu = <&vpu>;
1163 power-domains = <&scpsys MT8173_POWER_DOMAIN_VDEC>;
1164 clocks = <&apmixedsys CLK_APMIXED_VCODECPLL>,
1165 <&topckgen CLK_TOP_UNIVPLL_D2>,
1166 <&topckgen CLK_TOP_CCI400_SEL>,
1167 <&topckgen CLK_TOP_VDEC_SEL>,
1168 <&topckgen CLK_TOP_VCODECPLL>,
1169 <&apmixedsys CLK_APMIXED_VENCPLL>,
1170 <&topckgen CLK_TOP_VENC_LT_SEL>,
1171 <&topckgen CLK_TOP_VCODECPLL_370P5>;
1172 clock-names = "vcodecpll",
1173 "univpll_d2",
1174 "clk_cci400_sel",
1175 "vdec_sel",
1176 "vdecpll",
1177 "vencpll",
1178 "venc_lt_sel",
1179 "vdec_bus_clk_src";
1180 };
1181
1054 larb1: larb@16010000 { 1182 larb1: larb@16010000 {
1055 compatible = "mediatek,mt8173-smi-larb"; 1183 compatible = "mediatek,mt8173-smi-larb";
1056 reg = <0 0x16010000 0 0x1000>; 1184 reg = <0 0x16010000 0 0x1000>;
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index 7b8540291217..3512316e7a46 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -80,6 +80,22 @@ config MEDIA_RC_SUPPORT
80 80
81 Say Y when you have a TV or an IR device. 81 Say Y when you have a TV or an IR device.
82 82
83config MEDIA_CEC_SUPPORT
84 bool "HDMI CEC support"
85 select MEDIA_CEC_EDID
86 ---help---
87 Enable support for HDMI CEC (Consumer Electronics Control),
88 which is an optional HDMI feature.
89
90 Say Y when you have an HDMI receiver, transmitter or a USB CEC
91 adapter that supports HDMI CEC.
92
93config MEDIA_CEC_DEBUG
94 bool "HDMI CEC debugfs interface"
95 depends on MEDIA_CEC_SUPPORT && DEBUG_FS
96 ---help---
97 Turns on the DebugFS interface for CEC devices.
98
83config MEDIA_CEC_EDID 99config MEDIA_CEC_EDID
84 bool 100 bool
85 101
@@ -99,7 +115,7 @@ config MEDIA_CONTROLLER
99 115
100config MEDIA_CONTROLLER_DVB 116config MEDIA_CONTROLLER_DVB
101 bool "Enable Media controller for DVB (EXPERIMENTAL)" 117 bool "Enable Media controller for DVB (EXPERIMENTAL)"
102 depends on MEDIA_CONTROLLER 118 depends on MEDIA_CONTROLLER && DVB_CORE
103 ---help--- 119 ---help---
104 Enable the media controller API support for DVB. 120 Enable the media controller API support for DVB.
105 121
diff --git a/drivers/media/Makefile b/drivers/media/Makefile
index 0deaa93efdee..d87ccb8eeabe 100644
--- a/drivers/media/Makefile
+++ b/drivers/media/Makefile
@@ -6,6 +6,10 @@ ifeq ($(CONFIG_MEDIA_CEC_EDID),y)
6 obj-$(CONFIG_MEDIA_SUPPORT) += cec-edid.o 6 obj-$(CONFIG_MEDIA_SUPPORT) += cec-edid.o
7endif 7endif
8 8
9ifeq ($(CONFIG_MEDIA_CEC_SUPPORT),y)
10 obj-$(CONFIG_MEDIA_SUPPORT) += cec/
11endif
12
9media-objs := media-device.o media-devnode.o media-entity.o 13media-objs := media-device.o media-devnode.o media-entity.o
10 14
11# 15#
diff --git a/drivers/staging/media/cec/Makefile b/drivers/media/cec/Makefile
index bd7f3c593468..d6686337275f 100644
--- a/drivers/staging/media/cec/Makefile
+++ b/drivers/media/cec/Makefile
@@ -1,5 +1,5 @@
1cec-objs := cec-core.o cec-adap.o cec-api.o 1cec-objs := cec-core.o cec-adap.o cec-api.o
2 2
3ifeq ($(CONFIG_MEDIA_CEC),y) 3ifeq ($(CONFIG_MEDIA_CEC_SUPPORT),y)
4 obj-$(CONFIG_MEDIA_SUPPORT) += cec.o 4 obj-$(CONFIG_MEDIA_SUPPORT) += cec.o
5endif 5endif
diff --git a/drivers/staging/media/cec/cec-adap.c b/drivers/media/cec/cec-adap.c
index 611e07b78bfe..0ea4efb3de66 100644
--- a/drivers/staging/media/cec/cec-adap.c
+++ b/drivers/media/cec/cec-adap.c
@@ -587,7 +587,6 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
587 msg->tx_nack_cnt = 0; 587 msg->tx_nack_cnt = 0;
588 msg->tx_low_drive_cnt = 0; 588 msg->tx_low_drive_cnt = 0;
589 msg->tx_error_cnt = 0; 589 msg->tx_error_cnt = 0;
590 msg->flags = 0;
591 msg->sequence = ++adap->sequence; 590 msg->sequence = ++adap->sequence;
592 if (!msg->sequence) 591 if (!msg->sequence)
593 msg->sequence = ++adap->sequence; 592 msg->sequence = ++adap->sequence;
@@ -596,6 +595,10 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
596 /* Make sure the timeout isn't 0. */ 595 /* Make sure the timeout isn't 0. */
597 msg->timeout = 1000; 596 msg->timeout = 1000;
598 } 597 }
598 if (msg->timeout)
599 msg->flags &= CEC_MSG_FL_REPLY_TO_FOLLOWERS;
600 else
601 msg->flags = 0;
599 602
600 /* Sanity checks */ 603 /* Sanity checks */
601 if (msg->len == 0 || msg->len > CEC_MAX_MSG_SIZE) { 604 if (msg->len == 0 || msg->len > CEC_MAX_MSG_SIZE) {
@@ -763,23 +766,133 @@ EXPORT_SYMBOL_GPL(cec_transmit_msg);
763static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg, 766static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg,
764 bool is_reply); 767 bool is_reply);
765 768
769#define DIRECTED 0x80
770#define BCAST1_4 0x40
771#define BCAST2_0 0x20 /* broadcast only allowed for >= 2.0 */
772#define BCAST (BCAST1_4 | BCAST2_0)
773#define BOTH (BCAST | DIRECTED)
774
775/*
776 * Specify minimum length and whether the message is directed, broadcast
777 * or both. Messages that do not match the criteria are ignored as per
778 * the CEC specification.
779 */
780static const u8 cec_msg_size[256] = {
781 [CEC_MSG_ACTIVE_SOURCE] = 4 | BCAST,
782 [CEC_MSG_IMAGE_VIEW_ON] = 2 | DIRECTED,
783 [CEC_MSG_TEXT_VIEW_ON] = 2 | DIRECTED,
784 [CEC_MSG_INACTIVE_SOURCE] = 4 | DIRECTED,
785 [CEC_MSG_REQUEST_ACTIVE_SOURCE] = 2 | BCAST,
786 [CEC_MSG_ROUTING_CHANGE] = 6 | BCAST,
787 [CEC_MSG_ROUTING_INFORMATION] = 4 | BCAST,
788 [CEC_MSG_SET_STREAM_PATH] = 4 | BCAST,
789 [CEC_MSG_STANDBY] = 2 | BOTH,
790 [CEC_MSG_RECORD_OFF] = 2 | DIRECTED,
791 [CEC_MSG_RECORD_ON] = 3 | DIRECTED,
792 [CEC_MSG_RECORD_STATUS] = 3 | DIRECTED,
793 [CEC_MSG_RECORD_TV_SCREEN] = 2 | DIRECTED,
794 [CEC_MSG_CLEAR_ANALOGUE_TIMER] = 13 | DIRECTED,
795 [CEC_MSG_CLEAR_DIGITAL_TIMER] = 16 | DIRECTED,
796 [CEC_MSG_CLEAR_EXT_TIMER] = 13 | DIRECTED,
797 [CEC_MSG_SET_ANALOGUE_TIMER] = 13 | DIRECTED,
798 [CEC_MSG_SET_DIGITAL_TIMER] = 16 | DIRECTED,
799 [CEC_MSG_SET_EXT_TIMER] = 13 | DIRECTED,
800 [CEC_MSG_SET_TIMER_PROGRAM_TITLE] = 2 | DIRECTED,
801 [CEC_MSG_TIMER_CLEARED_STATUS] = 3 | DIRECTED,
802 [CEC_MSG_TIMER_STATUS] = 3 | DIRECTED,
803 [CEC_MSG_CEC_VERSION] = 3 | DIRECTED,
804 [CEC_MSG_GET_CEC_VERSION] = 2 | DIRECTED,
805 [CEC_MSG_GIVE_PHYSICAL_ADDR] = 2 | DIRECTED,
806 [CEC_MSG_GET_MENU_LANGUAGE] = 2 | DIRECTED,
807 [CEC_MSG_REPORT_PHYSICAL_ADDR] = 5 | BCAST,
808 [CEC_MSG_SET_MENU_LANGUAGE] = 5 | BCAST,
809 [CEC_MSG_REPORT_FEATURES] = 6 | BCAST,
810 [CEC_MSG_GIVE_FEATURES] = 2 | DIRECTED,
811 [CEC_MSG_DECK_CONTROL] = 3 | DIRECTED,
812 [CEC_MSG_DECK_STATUS] = 3 | DIRECTED,
813 [CEC_MSG_GIVE_DECK_STATUS] = 3 | DIRECTED,
814 [CEC_MSG_PLAY] = 3 | DIRECTED,
815 [CEC_MSG_GIVE_TUNER_DEVICE_STATUS] = 3 | DIRECTED,
816 [CEC_MSG_SELECT_ANALOGUE_SERVICE] = 6 | DIRECTED,
817 [CEC_MSG_SELECT_DIGITAL_SERVICE] = 9 | DIRECTED,
818 [CEC_MSG_TUNER_DEVICE_STATUS] = 7 | DIRECTED,
819 [CEC_MSG_TUNER_STEP_DECREMENT] = 2 | DIRECTED,
820 [CEC_MSG_TUNER_STEP_INCREMENT] = 2 | DIRECTED,
821 [CEC_MSG_DEVICE_VENDOR_ID] = 5 | BCAST,
822 [CEC_MSG_GIVE_DEVICE_VENDOR_ID] = 2 | DIRECTED,
823 [CEC_MSG_VENDOR_COMMAND] = 2 | DIRECTED,
824 [CEC_MSG_VENDOR_COMMAND_WITH_ID] = 5 | BOTH,
825 [CEC_MSG_VENDOR_REMOTE_BUTTON_DOWN] = 2 | BOTH,
826 [CEC_MSG_VENDOR_REMOTE_BUTTON_UP] = 2 | BOTH,
827 [CEC_MSG_SET_OSD_STRING] = 3 | DIRECTED,
828 [CEC_MSG_GIVE_OSD_NAME] = 2 | DIRECTED,
829 [CEC_MSG_SET_OSD_NAME] = 2 | DIRECTED,
830 [CEC_MSG_MENU_REQUEST] = 3 | DIRECTED,
831 [CEC_MSG_MENU_STATUS] = 3 | DIRECTED,
832 [CEC_MSG_USER_CONTROL_PRESSED] = 3 | DIRECTED,
833 [CEC_MSG_USER_CONTROL_RELEASED] = 2 | DIRECTED,
834 [CEC_MSG_GIVE_DEVICE_POWER_STATUS] = 2 | DIRECTED,
835 [CEC_MSG_REPORT_POWER_STATUS] = 3 | DIRECTED | BCAST2_0,
836 [CEC_MSG_FEATURE_ABORT] = 4 | DIRECTED,
837 [CEC_MSG_ABORT] = 2 | DIRECTED,
838 [CEC_MSG_GIVE_AUDIO_STATUS] = 2 | DIRECTED,
839 [CEC_MSG_GIVE_SYSTEM_AUDIO_MODE_STATUS] = 2 | DIRECTED,
840 [CEC_MSG_REPORT_AUDIO_STATUS] = 3 | DIRECTED,
841 [CEC_MSG_REPORT_SHORT_AUDIO_DESCRIPTOR] = 2 | DIRECTED,
842 [CEC_MSG_REQUEST_SHORT_AUDIO_DESCRIPTOR] = 2 | DIRECTED,
843 [CEC_MSG_SET_SYSTEM_AUDIO_MODE] = 3 | BOTH,
844 [CEC_MSG_SYSTEM_AUDIO_MODE_REQUEST] = 2 | DIRECTED,
845 [CEC_MSG_SYSTEM_AUDIO_MODE_STATUS] = 3 | DIRECTED,
846 [CEC_MSG_SET_AUDIO_RATE] = 3 | DIRECTED,
847 [CEC_MSG_INITIATE_ARC] = 2 | DIRECTED,
848 [CEC_MSG_REPORT_ARC_INITIATED] = 2 | DIRECTED,
849 [CEC_MSG_REPORT_ARC_TERMINATED] = 2 | DIRECTED,
850 [CEC_MSG_REQUEST_ARC_INITIATION] = 2 | DIRECTED,
851 [CEC_MSG_REQUEST_ARC_TERMINATION] = 2 | DIRECTED,
852 [CEC_MSG_TERMINATE_ARC] = 2 | DIRECTED,
853 [CEC_MSG_REQUEST_CURRENT_LATENCY] = 4 | BCAST,
854 [CEC_MSG_REPORT_CURRENT_LATENCY] = 7 | BCAST,
855 [CEC_MSG_CDC_MESSAGE] = 2 | BCAST,
856};
857
766/* Called by the CEC adapter if a message is received */ 858/* Called by the CEC adapter if a message is received */
767void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg) 859void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg)
768{ 860{
769 struct cec_data *data; 861 struct cec_data *data;
770 u8 msg_init = cec_msg_initiator(msg); 862 u8 msg_init = cec_msg_initiator(msg);
771 u8 msg_dest = cec_msg_destination(msg); 863 u8 msg_dest = cec_msg_destination(msg);
864 u8 cmd = msg->msg[1];
772 bool is_reply = false; 865 bool is_reply = false;
773 bool valid_la = true; 866 bool valid_la = true;
867 u8 min_len = 0;
774 868
775 if (WARN_ON(!msg->len || msg->len > CEC_MAX_MSG_SIZE)) 869 if (WARN_ON(!msg->len || msg->len > CEC_MAX_MSG_SIZE))
776 return; 870 return;
777 871
872 /*
873 * Some CEC adapters will receive the messages that they transmitted.
874 * This test filters out those messages by checking if we are the
875 * initiator, and just returning in that case.
876 *
877 * Note that this won't work if this is an Unregistered device.
878 *
879 * It is bad practice if the hardware receives the message that it
880 * transmitted and luckily most CEC adapters behave correctly in this
881 * respect.
882 */
883 if (msg_init != CEC_LOG_ADDR_UNREGISTERED &&
884 cec_has_log_addr(adap, msg_init))
885 return;
886
778 msg->rx_ts = ktime_get_ns(); 887 msg->rx_ts = ktime_get_ns();
779 msg->rx_status = CEC_RX_STATUS_OK; 888 msg->rx_status = CEC_RX_STATUS_OK;
780 msg->sequence = msg->reply = msg->timeout = 0; 889 msg->sequence = msg->reply = msg->timeout = 0;
781 msg->tx_status = 0; 890 msg->tx_status = 0;
782 msg->tx_ts = 0; 891 msg->tx_ts = 0;
892 msg->tx_arb_lost_cnt = 0;
893 msg->tx_nack_cnt = 0;
894 msg->tx_low_drive_cnt = 0;
895 msg->tx_error_cnt = 0;
783 msg->flags = 0; 896 msg->flags = 0;
784 memset(msg->msg + msg->len, 0, sizeof(msg->msg) - msg->len); 897 memset(msg->msg + msg->len, 0, sizeof(msg->msg) - msg->len);
785 898
@@ -790,9 +903,71 @@ void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg)
790 if (!cec_msg_is_broadcast(msg)) 903 if (!cec_msg_is_broadcast(msg))
791 valid_la = cec_has_log_addr(adap, msg_dest); 904 valid_la = cec_has_log_addr(adap, msg_dest);
792 905
906 /*
907 * Check if the length is not too short or if the message is a
908 * broadcast message where a directed message was expected or
909 * vice versa. If so, then the message has to be ignored (according
910 * to section CEC 7.3 and CEC 12.2).
911 */
912 if (valid_la && msg->len > 1 && cec_msg_size[cmd]) {
913 u8 dir_fl = cec_msg_size[cmd] & BOTH;
914
915 min_len = cec_msg_size[cmd] & 0x1f;
916 if (msg->len < min_len)
917 valid_la = false;
918 else if (!cec_msg_is_broadcast(msg) && !(dir_fl & DIRECTED))
919 valid_la = false;
920 else if (cec_msg_is_broadcast(msg) && !(dir_fl & BCAST1_4))
921 valid_la = false;
922 else if (cec_msg_is_broadcast(msg) &&
923 adap->log_addrs.cec_version >= CEC_OP_CEC_VERSION_2_0 &&
924 !(dir_fl & BCAST2_0))
925 valid_la = false;
926 }
927 if (valid_la && min_len) {
928 /* These messages have special length requirements */
929 switch (cmd) {
930 case CEC_MSG_TIMER_STATUS:
931 if (msg->msg[2] & 0x10) {
932 switch (msg->msg[2] & 0xf) {
933 case CEC_OP_PROG_INFO_NOT_ENOUGH_SPACE:
934 case CEC_OP_PROG_INFO_MIGHT_NOT_BE_ENOUGH_SPACE:
935 if (msg->len < 5)
936 valid_la = false;
937 break;
938 }
939 } else if ((msg->msg[2] & 0xf) == CEC_OP_PROG_ERROR_DUPLICATE) {
940 if (msg->len < 5)
941 valid_la = false;
942 }
943 break;
944 case CEC_MSG_RECORD_ON:
945 switch (msg->msg[2]) {
946 case CEC_OP_RECORD_SRC_OWN:
947 break;
948 case CEC_OP_RECORD_SRC_DIGITAL:
949 if (msg->len < 10)
950 valid_la = false;
951 break;
952 case CEC_OP_RECORD_SRC_ANALOG:
953 if (msg->len < 7)
954 valid_la = false;
955 break;
956 case CEC_OP_RECORD_SRC_EXT_PLUG:
957 if (msg->len < 4)
958 valid_la = false;
959 break;
960 case CEC_OP_RECORD_SRC_EXT_PHYS_ADDR:
961 if (msg->len < 5)
962 valid_la = false;
963 break;
964 }
965 break;
966 }
967 }
968
793 /* It's a valid message and not a poll or CDC message */ 969 /* It's a valid message and not a poll or CDC message */
794 if (valid_la && msg->len > 1 && msg->msg[1] != CEC_MSG_CDC_MESSAGE) { 970 if (valid_la && msg->len > 1 && cmd != CEC_MSG_CDC_MESSAGE) {
795 u8 cmd = msg->msg[1];
796 bool abort = cmd == CEC_MSG_FEATURE_ABORT; 971 bool abort = cmd == CEC_MSG_FEATURE_ABORT;
797 972
798 /* The aborted command is in msg[2] */ 973 /* The aborted command is in msg[2] */
@@ -806,6 +981,18 @@ void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg)
806 list_for_each_entry(data, &adap->wait_queue, list) { 981 list_for_each_entry(data, &adap->wait_queue, list) {
807 struct cec_msg *dst = &data->msg; 982 struct cec_msg *dst = &data->msg;
808 983
984 /*
985 * The *only* CEC message that has two possible replies
986 * is CEC_MSG_INITIATE_ARC.
987 * In this case allow either of the two replies.
988 */
989 if (!abort && dst->msg[1] == CEC_MSG_INITIATE_ARC &&
990 (cmd == CEC_MSG_REPORT_ARC_INITIATED ||
991 cmd == CEC_MSG_REPORT_ARC_TERMINATED) &&
992 (dst->reply == CEC_MSG_REPORT_ARC_INITIATED ||
993 dst->reply == CEC_MSG_REPORT_ARC_TERMINATED))
994 dst->reply = cmd;
995
809 /* Does the command match? */ 996 /* Does the command match? */
810 if ((abort && cmd != dst->msg[1]) || 997 if ((abort && cmd != dst->msg[1]) ||
811 (!abort && cmd != dst->reply)) 998 (!abort && cmd != dst->reply))
@@ -823,6 +1010,7 @@ void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg)
823 dst->rx_status = msg->rx_status; 1010 dst->rx_status = msg->rx_status;
824 if (abort) 1011 if (abort)
825 dst->rx_status |= CEC_RX_STATUS_FEATURE_ABORT; 1012 dst->rx_status |= CEC_RX_STATUS_FEATURE_ABORT;
1013 msg->flags = dst->flags;
826 /* Remove it from the wait_queue */ 1014 /* Remove it from the wait_queue */
827 list_del_init(&data->list); 1015 list_del_init(&data->list);
828 1016
@@ -1068,7 +1256,8 @@ configured:
1068 mutex_unlock(&adap->lock); 1256 mutex_unlock(&adap->lock);
1069 1257
1070 for (i = 0; i < las->num_log_addrs; i++) { 1258 for (i = 0; i < las->num_log_addrs; i++) {
1071 if (las->log_addr[i] == CEC_LOG_ADDR_INVALID) 1259 if (las->log_addr[i] == CEC_LOG_ADDR_INVALID ||
1260 (las->flags & CEC_LOG_ADDRS_FL_CDC_ONLY))
1072 continue; 1261 continue;
1073 1262
1074 /* 1263 /*
@@ -1190,6 +1379,29 @@ int __cec_s_log_addrs(struct cec_adapter *adap,
1190 return 0; 1379 return 0;
1191 } 1380 }
1192 1381
1382 if (log_addrs->flags & CEC_LOG_ADDRS_FL_CDC_ONLY) {
1383 /*
1384 * Sanitize log_addrs fields if a CDC-Only device is
1385 * requested.
1386 */
1387 log_addrs->num_log_addrs = 1;
1388 log_addrs->osd_name[0] = '\0';
1389 log_addrs->vendor_id = CEC_VENDOR_ID_NONE;
1390 log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_UNREGISTERED;
1391 /*
1392 * This is just an internal convention since a CDC-Only device
1393 * doesn't have to be a switch. But switches already use
1394 * unregistered, so it makes some kind of sense to pick this
1395 * as the primary device. Since a CDC-Only device never sends
1396 * any 'normal' CEC messages this primary device type is never
1397 * sent over the CEC bus.
1398 */
1399 log_addrs->primary_device_type[0] = CEC_OP_PRIM_DEVTYPE_SWITCH;
1400 log_addrs->all_device_types[0] = 0;
1401 log_addrs->features[0][0] = 0;
1402 log_addrs->features[0][1] = 0;
1403 }
1404
1193 /* Ensure the osd name is 0-terminated */ 1405 /* Ensure the osd name is 0-terminated */
1194 log_addrs->osd_name[sizeof(log_addrs->osd_name) - 1] = '\0'; 1406 log_addrs->osd_name[sizeof(log_addrs->osd_name) - 1] = '\0';
1195 1407
@@ -1223,6 +1435,7 @@ int __cec_s_log_addrs(struct cec_adapter *adap,
1223 const u8 feature_sz = ARRAY_SIZE(log_addrs->features[0]); 1435 const u8 feature_sz = ARRAY_SIZE(log_addrs->features[0]);
1224 u8 *features = log_addrs->features[i]; 1436 u8 *features = log_addrs->features[i];
1225 bool op_is_dev_features = false; 1437 bool op_is_dev_features = false;
1438 unsigned j;
1226 1439
1227 log_addrs->log_addr[i] = CEC_LOG_ADDR_INVALID; 1440 log_addrs->log_addr[i] = CEC_LOG_ADDR_INVALID;
1228 if (type_mask & (1 << log_addrs->log_addr_type[i])) { 1441 if (type_mask & (1 << log_addrs->log_addr_type[i])) {
@@ -1249,19 +1462,19 @@ int __cec_s_log_addrs(struct cec_adapter *adap,
1249 dprintk(1, "unknown logical address type\n"); 1462 dprintk(1, "unknown logical address type\n");
1250 return -EINVAL; 1463 return -EINVAL;
1251 } 1464 }
1252 for (i = 0; i < feature_sz; i++) { 1465 for (j = 0; j < feature_sz; j++) {
1253 if ((features[i] & 0x80) == 0) { 1466 if ((features[j] & 0x80) == 0) {
1254 if (op_is_dev_features) 1467 if (op_is_dev_features)
1255 break; 1468 break;
1256 op_is_dev_features = true; 1469 op_is_dev_features = true;
1257 } 1470 }
1258 } 1471 }
1259 if (!op_is_dev_features || i == feature_sz) { 1472 if (!op_is_dev_features || j == feature_sz) {
1260 dprintk(1, "malformed features\n"); 1473 dprintk(1, "malformed features\n");
1261 return -EINVAL; 1474 return -EINVAL;
1262 } 1475 }
1263 /* Zero unused part of the feature array */ 1476 /* Zero unused part of the feature array */
1264 memset(features + i + 1, 0, feature_sz - i - 1); 1477 memset(features + j + 1, 0, feature_sz - j - 1);
1265 } 1478 }
1266 1479
1267 if (log_addrs->cec_version >= CEC_OP_CEC_VERSION_2_0) { 1480 if (log_addrs->cec_version >= CEC_OP_CEC_VERSION_2_0) {
@@ -1410,6 +1623,11 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg,
1410 1623
1411 dprintk(1, "cec_receive_notify: %*ph\n", msg->len, msg->msg); 1624 dprintk(1, "cec_receive_notify: %*ph\n", msg->len, msg->msg);
1412 1625
1626 /* If this is a CDC-Only device, then ignore any non-CDC messages */
1627 if (cec_is_cdc_only(&adap->log_addrs) &&
1628 msg->msg[1] != CEC_MSG_CDC_MESSAGE)
1629 return 0;
1630
1413 if (adap->ops->received) { 1631 if (adap->ops->received) {
1414 /* Allow drivers to process the message first */ 1632 /* Allow drivers to process the message first */
1415 if (adap->ops->received(adap, msg) != -ENOMSG) 1633 if (adap->ops->received(adap, msg) != -ENOMSG)
@@ -1478,7 +1696,8 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg,
1478 } 1696 }
1479 1697
1480 case CEC_MSG_USER_CONTROL_PRESSED: 1698 case CEC_MSG_USER_CONTROL_PRESSED:
1481 if (!(adap->capabilities & CEC_CAP_RC)) 1699 if (!(adap->capabilities & CEC_CAP_RC) ||
1700 !(adap->log_addrs.flags & CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU))
1482 break; 1701 break;
1483 1702
1484#if IS_REACHABLE(CONFIG_RC_CORE) 1703#if IS_REACHABLE(CONFIG_RC_CORE)
@@ -1515,7 +1734,8 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg,
1515 break; 1734 break;
1516 1735
1517 case CEC_MSG_USER_CONTROL_RELEASED: 1736 case CEC_MSG_USER_CONTROL_RELEASED:
1518 if (!(adap->capabilities & CEC_CAP_RC)) 1737 if (!(adap->capabilities & CEC_CAP_RC) ||
1738 !(adap->log_addrs.flags & CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU))
1519 break; 1739 break;
1520#if IS_REACHABLE(CONFIG_RC_CORE) 1740#if IS_REACHABLE(CONFIG_RC_CORE)
1521 rc_keyup(adap->rc); 1741 rc_keyup(adap->rc);
@@ -1573,8 +1793,8 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg,
1573 } 1793 }
1574 1794
1575skip_processing: 1795skip_processing:
1576 /* If this was a reply, then we're done */ 1796 /* If this was a reply, then we're done, unless otherwise specified */
1577 if (is_reply) 1797 if (is_reply && !(msg->flags & CEC_MSG_FL_REPLY_TO_FOLLOWERS))
1578 return 0; 1798 return 0;
1579 1799
1580 /* 1800 /*
diff --git a/drivers/staging/media/cec/cec-api.c b/drivers/media/cec/cec-api.c
index e274e2f22398..8950b6c9d6a9 100644
--- a/drivers/staging/media/cec/cec-api.c
+++ b/drivers/media/cec/cec-api.c
@@ -88,7 +88,7 @@ static long cec_adap_g_caps(struct cec_adapter *adap,
88{ 88{
89 struct cec_caps caps = {}; 89 struct cec_caps caps = {};
90 90
91 strlcpy(caps.driver, adap->devnode.parent->driver->name, 91 strlcpy(caps.driver, adap->devnode.dev.parent->driver->name,
92 sizeof(caps.driver)); 92 sizeof(caps.driver));
93 strlcpy(caps.name, adap->name, sizeof(caps.name)); 93 strlcpy(caps.name, adap->name, sizeof(caps.name));
94 caps.available_log_addrs = adap->available_log_addrs; 94 caps.available_log_addrs = adap->available_log_addrs;
@@ -162,7 +162,9 @@ static long cec_adap_s_log_addrs(struct cec_adapter *adap, struct cec_fh *fh,
162 return -ENOTTY; 162 return -ENOTTY;
163 if (copy_from_user(&log_addrs, parg, sizeof(log_addrs))) 163 if (copy_from_user(&log_addrs, parg, sizeof(log_addrs)))
164 return -EFAULT; 164 return -EFAULT;
165 log_addrs.flags &= CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK; 165 log_addrs.flags &= CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK |
166 CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU |
167 CEC_LOG_ADDRS_FL_CDC_ONLY;
166 mutex_lock(&adap->lock); 168 mutex_lock(&adap->lock);
167 if (!adap->is_configuring && 169 if (!adap->is_configuring &&
168 (!log_addrs.num_log_addrs || !adap->is_configured) && 170 (!log_addrs.num_log_addrs || !adap->is_configured) &&
@@ -189,6 +191,12 @@ static long cec_transmit(struct cec_adapter *adap, struct cec_fh *fh,
189 return -ENOTTY; 191 return -ENOTTY;
190 if (copy_from_user(&msg, parg, sizeof(msg))) 192 if (copy_from_user(&msg, parg, sizeof(msg)))
191 return -EFAULT; 193 return -EFAULT;
194
195 /* A CDC-Only device can only send CDC messages */
196 if ((adap->log_addrs.flags & CEC_LOG_ADDRS_FL_CDC_ONLY) &&
197 (msg.len == 1 || msg.msg[1] != CEC_MSG_CDC_MESSAGE))
198 return -EINVAL;
199
192 mutex_lock(&adap->lock); 200 mutex_lock(&adap->lock);
193 if (!adap->is_configured) 201 if (!adap->is_configured)
194 err = -ENONET; 202 err = -ENONET;
@@ -273,6 +281,7 @@ static long cec_receive(struct cec_adapter *adap, struct cec_fh *fh,
273 err = cec_receive_msg(fh, &msg, block); 281 err = cec_receive_msg(fh, &msg, block);
274 if (err) 282 if (err)
275 return err; 283 return err;
284 msg.flags = 0;
276 if (copy_to_user(parg, &msg, sizeof(msg))) 285 if (copy_to_user(parg, &msg, sizeof(msg)))
277 return -EFAULT; 286 return -EFAULT;
278 return 0; 287 return 0;
diff --git a/drivers/staging/media/cec/cec-core.c b/drivers/media/cec/cec-core.c
index b0137e247dc9..aca3ab83a8a1 100644
--- a/drivers/staging/media/cec/cec-core.c
+++ b/drivers/media/cec/cec-core.c
@@ -132,7 +132,6 @@ static int __must_check cec_devnode_register(struct cec_devnode *devnode,
132 devnode->dev.bus = &cec_bus_type; 132 devnode->dev.bus = &cec_bus_type;
133 devnode->dev.devt = MKDEV(MAJOR(cec_dev_t), minor); 133 devnode->dev.devt = MKDEV(MAJOR(cec_dev_t), minor);
134 devnode->dev.release = cec_devnode_release; 134 devnode->dev.release = cec_devnode_release;
135 devnode->dev.parent = devnode->parent;
136 dev_set_name(&devnode->dev, "cec%d", devnode->minor); 135 dev_set_name(&devnode->dev, "cec%d", devnode->minor);
137 device_initialize(&devnode->dev); 136 device_initialize(&devnode->dev);
138 137
@@ -198,13 +197,11 @@ static void cec_devnode_unregister(struct cec_devnode *devnode)
198 197
199struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops, 198struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops,
200 void *priv, const char *name, u32 caps, 199 void *priv, const char *name, u32 caps,
201 u8 available_las, struct device *parent) 200 u8 available_las)
202{ 201{
203 struct cec_adapter *adap; 202 struct cec_adapter *adap;
204 int res; 203 int res;
205 204
206 if (WARN_ON(!parent))
207 return ERR_PTR(-EINVAL);
208 if (WARN_ON(!caps)) 205 if (WARN_ON(!caps))
209 return ERR_PTR(-EINVAL); 206 return ERR_PTR(-EINVAL);
210 if (WARN_ON(!ops)) 207 if (WARN_ON(!ops))
@@ -214,8 +211,6 @@ struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops,
214 adap = kzalloc(sizeof(*adap), GFP_KERNEL); 211 adap = kzalloc(sizeof(*adap), GFP_KERNEL);
215 if (!adap) 212 if (!adap)
216 return ERR_PTR(-ENOMEM); 213 return ERR_PTR(-ENOMEM);
217 adap->owner = parent->driver->owner;
218 adap->devnode.parent = parent;
219 strlcpy(adap->name, name, sizeof(adap->name)); 214 strlcpy(adap->name, name, sizeof(adap->name));
220 adap->phys_addr = CEC_PHYS_ADDR_INVALID; 215 adap->phys_addr = CEC_PHYS_ADDR_INVALID;
221 adap->log_addrs.cec_version = CEC_OP_CEC_VERSION_2_0; 216 adap->log_addrs.cec_version = CEC_OP_CEC_VERSION_2_0;
@@ -264,7 +259,6 @@ struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops,
264 adap->rc->input_id.vendor = 0; 259 adap->rc->input_id.vendor = 0;
265 adap->rc->input_id.product = 0; 260 adap->rc->input_id.product = 0;
266 adap->rc->input_id.version = 1; 261 adap->rc->input_id.version = 1;
267 adap->rc->dev.parent = parent;
268 adap->rc->driver_type = RC_DRIVER_SCANCODE; 262 adap->rc->driver_type = RC_DRIVER_SCANCODE;
269 adap->rc->driver_name = CEC_NAME; 263 adap->rc->driver_name = CEC_NAME;
270 adap->rc->allowed_protocols = RC_BIT_CEC; 264 adap->rc->allowed_protocols = RC_BIT_CEC;
@@ -278,14 +272,22 @@ struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops,
278} 272}
279EXPORT_SYMBOL_GPL(cec_allocate_adapter); 273EXPORT_SYMBOL_GPL(cec_allocate_adapter);
280 274
281int cec_register_adapter(struct cec_adapter *adap) 275int cec_register_adapter(struct cec_adapter *adap,
276 struct device *parent)
282{ 277{
283 int res; 278 int res;
284 279
285 if (IS_ERR_OR_NULL(adap)) 280 if (IS_ERR_OR_NULL(adap))
286 return 0; 281 return 0;
287 282
283 if (WARN_ON(!parent))
284 return -EINVAL;
285
286 adap->owner = parent->driver->owner;
287 adap->devnode.dev.parent = parent;
288
288#if IS_REACHABLE(CONFIG_RC_CORE) 289#if IS_REACHABLE(CONFIG_RC_CORE)
290 adap->rc->dev.parent = parent;
289 if (adap->capabilities & CEC_CAP_RC) { 291 if (adap->capabilities & CEC_CAP_RC) {
290 res = rc_register_device(adap->rc); 292 res = rc_register_device(adap->rc);
291 293
diff --git a/drivers/staging/media/cec/cec-priv.h b/drivers/media/cec/cec-priv.h
index 70767a7900f2..70767a7900f2 100644
--- a/drivers/staging/media/cec/cec-priv.h
+++ b/drivers/media/cec/cec-priv.h
diff --git a/drivers/media/common/b2c2/flexcop-common.h b/drivers/media/common/b2c2/flexcop-common.h
index 2b2460e9e6b4..2533574c0cf4 100644
--- a/drivers/media/common/b2c2/flexcop-common.h
+++ b/drivers/media/common/b2c2/flexcop-common.h
@@ -14,7 +14,6 @@
14 14
15#include "dmxdev.h" 15#include "dmxdev.h"
16#include "dvb_demux.h" 16#include "dvb_demux.h"
17#include "dvb_filter.h"
18#include "dvb_net.h" 17#include "dvb_net.h"
19#include "dvb_frontend.h" 18#include "dvb_frontend.h"
20 19
diff --git a/drivers/media/common/b2c2/flexcop-eeprom.c b/drivers/media/common/b2c2/flexcop-eeprom.c
index a25373a9bd84..844c7836c2a6 100644
--- a/drivers/media/common/b2c2/flexcop-eeprom.c
+++ b/drivers/media/common/b2c2/flexcop-eeprom.c
@@ -136,8 +136,7 @@ int flexcop_eeprom_check_mac_addr(struct flexcop_device *fc, int extended)
136 136
137 if ((ret = flexcop_eeprom_lrc_read(fc,0x3f8,buf,8,4)) == 0) { 137 if ((ret = flexcop_eeprom_lrc_read(fc,0x3f8,buf,8,4)) == 0) {
138 if (extended != 0) { 138 if (extended != 0) {
139 err("TODO: extended (EUI64) MAC addresses aren't " 139 err("TODO: extended (EUI64) MAC addresses aren't completely supported yet");
140 "completely supported yet");
141 ret = -EINVAL; 140 ret = -EINVAL;
142 } else 141 } else
143 memcpy(fc->dvb_adapter.proposed_mac,buf,6); 142 memcpy(fc->dvb_adapter.proposed_mac,buf,6);
diff --git a/drivers/media/common/b2c2/flexcop-i2c.c b/drivers/media/common/b2c2/flexcop-i2c.c
index 965d5eb33752..58d39a59fc09 100644
--- a/drivers/media/common/b2c2/flexcop-i2c.c
+++ b/drivers/media/common/b2c2/flexcop-i2c.c
@@ -33,8 +33,8 @@ static int flexcop_i2c_operation(struct flexcop_device *fc,
33 return -EREMOTEIO; 33 return -EREMOTEIO;
34 } 34 }
35 } 35 }
36 deb_i2c("tried %d times i2c operation, " 36 deb_i2c("tried %d times i2c operation, never finished or too many ack errors.\n",
37 "never finished or too many ack errors.\n", i); 37 i);
38 return -EREMOTEIO; 38 return -EREMOTEIO;
39} 39}
40 40
@@ -124,10 +124,10 @@ int flexcop_i2c_request(struct flexcop_i2c_adapter *i2c,
124#ifdef DUMP_I2C_MESSAGES 124#ifdef DUMP_I2C_MESSAGES
125 printk(KERN_DEBUG "%d ", i2c->port); 125 printk(KERN_DEBUG "%d ", i2c->port);
126 if (op == FC_READ) 126 if (op == FC_READ)
127 printk("rd("); 127 printk(KERN_CONT "rd(");
128 else 128 else
129 printk("wr("); 129 printk(KERN_CONT "wr(");
130 printk("%02x): %02x ", chipaddr, addr); 130 printk(KERN_CONT "%02x): %02x ", chipaddr, addr);
131#endif 131#endif
132 132
133 /* in that case addr is the only value -> 133 /* in that case addr is the only value ->
@@ -151,7 +151,7 @@ int flexcop_i2c_request(struct flexcop_i2c_adapter *i2c,
151 151
152#ifdef DUMP_I2C_MESSAGES 152#ifdef DUMP_I2C_MESSAGES
153 for (i = 0; i < bytes_to_transfer; i++) 153 for (i = 0; i < bytes_to_transfer; i++)
154 printk("%02x ", buf[i]); 154 printk(KERN_CONT "%02x ", buf[i]);
155#endif 155#endif
156 156
157 if (ret < 0) 157 if (ret < 0)
@@ -163,7 +163,7 @@ int flexcop_i2c_request(struct flexcop_i2c_adapter *i2c,
163 } 163 }
164 164
165#ifdef DUMP_I2C_MESSAGES 165#ifdef DUMP_I2C_MESSAGES
166 printk("\n"); 166 printk(KERN_CONT "\n");
167#endif 167#endif
168 168
169 return 0; 169 return 0;
diff --git a/drivers/media/common/b2c2/flexcop-misc.c b/drivers/media/common/b2c2/flexcop-misc.c
index b8eff235367d..bb0d95fe64f9 100644
--- a/drivers/media/common/b2c2/flexcop-misc.c
+++ b/drivers/media/common/b2c2/flexcop-misc.c
@@ -23,18 +23,15 @@ void flexcop_determine_revision(struct flexcop_device *fc)
23 fc->rev = FLEXCOP_III; 23 fc->rev = FLEXCOP_III;
24 break; 24 break;
25 default: 25 default:
26 err("unknown FlexCop Revision: %x. Please report this to " 26 err("unknown FlexCop Revision: %x. Please report this to linux-dvb@linuxtv.org.",
27 "linux-dvb@linuxtv.org.",
28 v.misc_204.Rev_N_sig_revision_hi); 27 v.misc_204.Rev_N_sig_revision_hi);
29 break; 28 break;
30 } 29 }
31 30
32 if ((fc->has_32_hw_pid_filter = v.misc_204.Rev_N_sig_caps)) 31 if ((fc->has_32_hw_pid_filter = v.misc_204.Rev_N_sig_caps))
33 deb_info("this FlexCop has " 32 deb_info("this FlexCop has the additional 32 hardware pid filter.\n");
34 "the additional 32 hardware pid filter.\n");
35 else 33 else
36 deb_info("this FlexCop has " 34 deb_info("this FlexCop has the 6 basic main hardware pid filter.\n");
37 "the 6 basic main hardware pid filter.\n");
38 /* bus parts have to decide if hw pid filtering is used or not. */ 35 /* bus parts have to decide if hw pid filtering is used or not. */
39} 36}
40 37
diff --git a/drivers/media/common/b2c2/flexcop.c b/drivers/media/common/b2c2/flexcop.c
index 0f5114d406f8..4338ab0043b4 100644
--- a/drivers/media/common/b2c2/flexcop.c
+++ b/drivers/media/common/b2c2/flexcop.c
@@ -46,8 +46,7 @@ int b2c2_flexcop_debug;
46EXPORT_SYMBOL_GPL(b2c2_flexcop_debug); 46EXPORT_SYMBOL_GPL(b2c2_flexcop_debug);
47module_param_named(debug, b2c2_flexcop_debug, int, 0644); 47module_param_named(debug, b2c2_flexcop_debug, int, 0644);
48MODULE_PARM_DESC(debug, 48MODULE_PARM_DESC(debug,
49 "set debug level (1=info,2=tuner,4=i2c,8=ts," 49 "set debug level (1=info,2=tuner,4=i2c,8=ts,16=sram,32=reg (|-able))."
50 "16=sram,32=reg (|-able))."
51 DEBSTATUS); 50 DEBSTATUS);
52#undef DEBSTATUS 51#undef DEBSTATUS
53 52
diff --git a/drivers/media/common/cx2341x.c b/drivers/media/common/cx2341x.c
index 5e4afa0131e6..2725702eda7b 100644
--- a/drivers/media/common/cx2341x.c
+++ b/drivers/media/common/cx2341x.c
@@ -1190,8 +1190,8 @@ void cx2341x_log_status(const struct cx2341x_mpeg_params *p, const char *prefix)
1190 prefix, 1190 prefix,
1191 cx2341x_menu_item(p, V4L2_CID_MPEG_STREAM_TYPE)); 1191 cx2341x_menu_item(p, V4L2_CID_MPEG_STREAM_TYPE));
1192 if (p->stream_insert_nav_packets) 1192 if (p->stream_insert_nav_packets)
1193 printk(" (with navigation packets)"); 1193 printk(KERN_CONT " (with navigation packets)");
1194 printk("\n"); 1194 printk(KERN_CONT "\n");
1195 printk(KERN_INFO "%s: VBI Format: %s\n", 1195 printk(KERN_INFO "%s: VBI Format: %s\n",
1196 prefix, 1196 prefix,
1197 cx2341x_menu_item(p, V4L2_CID_MPEG_STREAM_VBI_FMT)); 1197 cx2341x_menu_item(p, V4L2_CID_MPEG_STREAM_VBI_FMT));
@@ -1209,8 +1209,8 @@ void cx2341x_log_status(const struct cx2341x_mpeg_params *p, const char *prefix)
1209 cx2341x_menu_item(p, V4L2_CID_MPEG_VIDEO_BITRATE_MODE), 1209 cx2341x_menu_item(p, V4L2_CID_MPEG_VIDEO_BITRATE_MODE),
1210 p->video_bitrate); 1210 p->video_bitrate);
1211 if (p->video_bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR) 1211 if (p->video_bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR)
1212 printk(", Peak %d", p->video_bitrate_peak); 1212 printk(KERN_CONT ", Peak %d", p->video_bitrate_peak);
1213 printk("\n"); 1213 printk(KERN_CONT "\n");
1214 printk(KERN_INFO 1214 printk(KERN_INFO
1215 "%s: Video: GOP Size %d, %d B-Frames, %sGOP Closure\n", 1215 "%s: Video: GOP Size %d, %d B-Frames, %sGOP Closure\n",
1216 prefix, 1216 prefix,
@@ -1232,9 +1232,9 @@ void cx2341x_log_status(const struct cx2341x_mpeg_params *p, const char *prefix)
1232 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_MODE), 1232 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_MODE),
1233 p->audio_mute ? " (muted)" : ""); 1233 p->audio_mute ? " (muted)" : "");
1234 if (p->audio_mode == V4L2_MPEG_AUDIO_MODE_JOINT_STEREO) 1234 if (p->audio_mode == V4L2_MPEG_AUDIO_MODE_JOINT_STEREO)
1235 printk(", %s", cx2341x_menu_item(p, 1235 printk(KERN_CONT ", %s", cx2341x_menu_item(p,
1236 V4L2_CID_MPEG_AUDIO_MODE_EXTENSION)); 1236 V4L2_CID_MPEG_AUDIO_MODE_EXTENSION));
1237 printk(", %s, %s\n", 1237 printk(KERN_CONT ", %s, %s\n",
1238 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_EMPHASIS), 1238 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_EMPHASIS),
1239 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_CRC)); 1239 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_CRC));
1240 1240
diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c
index ea2f3bf7368b..e034bcfcf757 100644
--- a/drivers/media/common/saa7146/saa7146_video.c
+++ b/drivers/media/common/saa7146/saa7146_video.c
@@ -390,6 +390,7 @@ static int video_end(struct saa7146_fh *fh, struct file *file)
390{ 390{
391 struct saa7146_dev *dev = fh->dev; 391 struct saa7146_dev *dev = fh->dev;
392 struct saa7146_vv *vv = dev->vv_data; 392 struct saa7146_vv *vv = dev->vv_data;
393 struct saa7146_dmaqueue *q = &vv->video_dmaq;
393 struct saa7146_format *fmt = NULL; 394 struct saa7146_format *fmt = NULL;
394 unsigned long flags; 395 unsigned long flags;
395 unsigned int resource; 396 unsigned int resource;
@@ -428,6 +429,9 @@ static int video_end(struct saa7146_fh *fh, struct file *file)
428 /* shut down all used video dma transfers */ 429 /* shut down all used video dma transfers */
429 saa7146_write(dev, MC1, dmas); 430 saa7146_write(dev, MC1, dmas);
430 431
432 if (q->curr)
433 saa7146_buffer_finish(dev, q, VIDEOBUF_DONE);
434
431 spin_unlock_irqrestore(&dev->slock, flags); 435 spin_unlock_irqrestore(&dev->slock, flags);
432 436
433 vv->video_fh = NULL; 437 vv->video_fh = NULL;
diff --git a/drivers/media/common/siano/smsdvb-main.c b/drivers/media/common/siano/smsdvb-main.c
index 9148e14c9d07..affde1426b7a 100644
--- a/drivers/media/common/siano/smsdvb-main.c
+++ b/drivers/media/common/siano/smsdvb-main.c
@@ -1044,7 +1044,7 @@ static void smsdvb_release(struct dvb_frontend *fe)
1044 /* do nothing */ 1044 /* do nothing */
1045} 1045}
1046 1046
1047static struct dvb_frontend_ops smsdvb_fe_ops = { 1047static const struct dvb_frontend_ops smsdvb_fe_ops = {
1048 .info = { 1048 .info = {
1049 .name = "Siano Mobile Digital MDTV Receiver", 1049 .name = "Siano Mobile Digital MDTV Receiver",
1050 .frequency_min = 44250000, 1050 .frequency_min = 44250000,
diff --git a/drivers/media/common/tveeprom.c b/drivers/media/common/tveeprom.c
index 47da0378cad8..11976031aff8 100644
--- a/drivers/media/common/tveeprom.c
+++ b/drivers/media/common/tveeprom.c
@@ -28,6 +28,7 @@
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 */ 29 */
30 30
31#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31 32
32#include <linux/module.h> 33#include <linux/module.h>
33#include <linux/errno.h> 34#include <linux/errno.h>
@@ -45,22 +46,9 @@ MODULE_DESCRIPTION("i2c Hauppauge eeprom decoder driver");
45MODULE_AUTHOR("John Klar"); 46MODULE_AUTHOR("John Klar");
46MODULE_LICENSE("GPL"); 47MODULE_LICENSE("GPL");
47 48
48static int debug;
49module_param(debug, int, 0644);
50MODULE_PARM_DESC(debug, "Debug level (0-1)");
51
52#define STRM(array, i) \ 49#define STRM(array, i) \
53 (i < sizeof(array) / sizeof(char *) ? array[i] : "unknown") 50 (i < sizeof(array) / sizeof(char *) ? array[i] : "unknown")
54 51
55#define tveeprom_info(fmt, arg...) \
56 v4l_printk(KERN_INFO, "tveeprom", c->adapter, c->addr, fmt , ## arg)
57#define tveeprom_warn(fmt, arg...) \
58 v4l_printk(KERN_WARNING, "tveeprom", c->adapter, c->addr, fmt , ## arg)
59#define tveeprom_dbg(fmt, arg...) do { \
60 if (debug) \
61 v4l_printk(KERN_DEBUG, "tveeprom", \
62 c->adapter, c->addr, fmt , ## arg); \
63 } while (0)
64 52
65/* 53/*
66 * The Hauppauge eeprom uses an 8bit field to determine which 54 * The Hauppauge eeprom uses an 8bit field to determine which
@@ -510,19 +498,13 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
510 len = eeprom_data[i] & 0x07; 498 len = eeprom_data[i] & 0x07;
511 ++i; 499 ++i;
512 } else { 500 } else {
513 tveeprom_warn("Encountered bad packet header [%02x]. " 501 pr_warn("Encountered bad packet header [%02x]. Corrupt or not a Hauppauge eeprom.\n",
514 "Corrupt or not a Hauppauge eeprom.\n",
515 eeprom_data[i]); 502 eeprom_data[i]);
516 return; 503 return;
517 } 504 }
518 505
519 if (debug) { 506 pr_debug("Tag [%02x] + %d bytes: %*ph\n",
520 tveeprom_info("Tag [%02x] + %d bytes:", 507 eeprom_data[i], len - 1, len, &eeprom_data[i]);
521 eeprom_data[i], len - 1);
522 for (j = 1; j < len; j++)
523 printk(KERN_CONT " %02x", eeprom_data[i + j]);
524 printk(KERN_CONT "\n");
525 }
526 508
527 /* process by tag */ 509 /* process by tag */
528 tag = eeprom_data[i]; 510 tag = eeprom_data[i];
@@ -662,14 +644,14 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
662 /* case 0x12: tag 'InfoBits' */ 644 /* case 0x12: tag 'InfoBits' */
663 645
664 default: 646 default:
665 tveeprom_dbg("Not sure what to do with tag [%02x]\n", 647 pr_debug("Not sure what to do with tag [%02x]\n",
666 tag); 648 tag);
667 /* dump the rest of the packet? */ 649 /* dump the rest of the packet? */
668 } 650 }
669 } 651 }
670 652
671 if (!done) { 653 if (!done) {
672 tveeprom_warn("Ran out of data!\n"); 654 pr_warn("Ran out of data!\n");
673 return; 655 return;
674 } 656 }
675 657
@@ -682,8 +664,8 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
682 } 664 }
683 665
684 if (hasRadioTuner(tuner1) && !tvee->has_radio) { 666 if (hasRadioTuner(tuner1) && !tvee->has_radio) {
685 tveeprom_info("The eeprom says no radio is present, but the tuner type\n"); 667 pr_info("The eeprom says no radio is present, but the tuner type\n");
686 tveeprom_info("indicates otherwise. I will assume that radio is present.\n"); 668 pr_info("indicates otherwise. I will assume that radio is present.\n");
687 tvee->has_radio = 1; 669 tvee->has_radio = 1;
688 } 670 }
689 671
@@ -718,46 +700,46 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
718 } 700 }
719 } 701 }
720 702
721 tveeprom_info("Hauppauge model %d, rev %s, serial# %u\n", 703 pr_info("Hauppauge model %d, rev %s, serial# %u\n",
722 tvee->model, tvee->rev_str, tvee->serial_number); 704 tvee->model, tvee->rev_str, tvee->serial_number);
723 if (tvee->has_MAC_address == 1) 705 if (tvee->has_MAC_address == 1)
724 tveeprom_info("MAC address is %pM\n", tvee->MAC_address); 706 pr_info("MAC address is %pM\n", tvee->MAC_address);
725 tveeprom_info("tuner model is %s (idx %d, type %d)\n", 707 pr_info("tuner model is %s (idx %d, type %d)\n",
726 t_name1, tuner1, tvee->tuner_type); 708 t_name1, tuner1, tvee->tuner_type);
727 tveeprom_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n", 709 pr_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n",
728 t_fmt_name1[0], t_fmt_name1[1], t_fmt_name1[2], 710 t_fmt_name1[0], t_fmt_name1[1], t_fmt_name1[2],
729 t_fmt_name1[3], t_fmt_name1[4], t_fmt_name1[5], 711 t_fmt_name1[3], t_fmt_name1[4], t_fmt_name1[5],
730 t_fmt_name1[6], t_fmt_name1[7], t_format1); 712 t_fmt_name1[6], t_fmt_name1[7], t_format1);
731 if (tuner2) 713 if (tuner2)
732 tveeprom_info("second tuner model is %s (idx %d, type %d)\n", 714 pr_info("second tuner model is %s (idx %d, type %d)\n",
733 t_name2, tuner2, tvee->tuner2_type); 715 t_name2, tuner2, tvee->tuner2_type);
734 if (t_format2) 716 if (t_format2)
735 tveeprom_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n", 717 pr_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n",
736 t_fmt_name2[0], t_fmt_name2[1], t_fmt_name2[2], 718 t_fmt_name2[0], t_fmt_name2[1], t_fmt_name2[2],
737 t_fmt_name2[3], t_fmt_name2[4], t_fmt_name2[5], 719 t_fmt_name2[3], t_fmt_name2[4], t_fmt_name2[5],
738 t_fmt_name2[6], t_fmt_name2[7], t_format2); 720 t_fmt_name2[6], t_fmt_name2[7], t_format2);
739 if (audioic < 0) { 721 if (audioic < 0) {
740 tveeprom_info("audio processor is unknown (no idx)\n"); 722 pr_info("audio processor is unknown (no idx)\n");
741 tvee->audio_processor = TVEEPROM_AUDPROC_OTHER; 723 tvee->audio_processor = TVEEPROM_AUDPROC_OTHER;
742 } else { 724 } else {
743 if (audioic < ARRAY_SIZE(audio_ic)) 725 if (audioic < ARRAY_SIZE(audio_ic))
744 tveeprom_info("audio processor is %s (idx %d)\n", 726 pr_info("audio processor is %s (idx %d)\n",
745 audio_ic[audioic].name, audioic); 727 audio_ic[audioic].name, audioic);
746 else 728 else
747 tveeprom_info("audio processor is unknown (idx %d)\n", 729 pr_info("audio processor is unknown (idx %d)\n",
748 audioic); 730 audioic);
749 } 731 }
750 if (tvee->decoder_processor) 732 if (tvee->decoder_processor)
751 tveeprom_info("decoder processor is %s (idx %d)\n", 733 pr_info("decoder processor is %s (idx %d)\n",
752 STRM(decoderIC, tvee->decoder_processor), 734 STRM(decoderIC, tvee->decoder_processor),
753 tvee->decoder_processor); 735 tvee->decoder_processor);
754 if (tvee->has_ir) 736 if (tvee->has_ir)
755 tveeprom_info("has %sradio, has %sIR receiver, has %sIR transmitter\n", 737 pr_info("has %sradio, has %sIR receiver, has %sIR transmitter\n",
756 tvee->has_radio ? "" : "no ", 738 tvee->has_radio ? "" : "no ",
757 (tvee->has_ir & 2) ? "" : "no ", 739 (tvee->has_ir & 2) ? "" : "no ",
758 (tvee->has_ir & 4) ? "" : "no "); 740 (tvee->has_ir & 4) ? "" : "no ");
759 else 741 else
760 tveeprom_info("has %sradio\n", 742 pr_info("has %sradio\n",
761 tvee->has_radio ? "" : "no "); 743 tvee->has_radio ? "" : "no ");
762} 744}
763EXPORT_SYMBOL(tveeprom_hauppauge_analog); 745EXPORT_SYMBOL(tveeprom_hauppauge_analog);
@@ -773,26 +755,17 @@ int tveeprom_read(struct i2c_client *c, unsigned char *eedata, int len)
773 buf = 0; 755 buf = 0;
774 err = i2c_master_send(c, &buf, 1); 756 err = i2c_master_send(c, &buf, 1);
775 if (err != 1) { 757 if (err != 1) {
776 tveeprom_info("Huh, no eeprom present (err=%d)?\n", err); 758 pr_info("Huh, no eeprom present (err=%d)?\n", err);
777 return -1; 759 return -1;
778 } 760 }
779 err = i2c_master_recv(c, eedata, len); 761 err = i2c_master_recv(c, eedata, len);
780 if (err != len) { 762 if (err != len) {
781 tveeprom_warn("i2c eeprom read error (err=%d)\n", err); 763 pr_warn("i2c eeprom read error (err=%d)\n", err);
782 return -1; 764 return -1;
783 } 765 }
784 if (debug) { 766
785 int i; 767 print_hex_dump_debug("full 256-byte eeprom dump:", DUMP_PREFIX_NONE,
786 768 16, 1, eedata, len, true);
787 tveeprom_info("full 256-byte eeprom dump:\n");
788 for (i = 0; i < len; i++) {
789 if (0 == (i % 16))
790 tveeprom_info("%02x:", i);
791 printk(KERN_CONT " %02x", eedata[i]);
792 if (15 == (i % 16))
793 printk(KERN_CONT "\n");
794 }
795 }
796 return 0; 769 return 0;
797} 770}
798EXPORT_SYMBOL(tveeprom_read); 771EXPORT_SYMBOL(tveeprom_read);
diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
index 1684810cab83..e47b46e2d26c 100644
--- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
+++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
@@ -117,6 +117,7 @@ void tpg_init(struct tpg_data *tpg, unsigned w, unsigned h)
117 tpg_s_fourcc(tpg, V4L2_PIX_FMT_RGB24); 117 tpg_s_fourcc(tpg, V4L2_PIX_FMT_RGB24);
118 tpg->colorspace = V4L2_COLORSPACE_SRGB; 118 tpg->colorspace = V4L2_COLORSPACE_SRGB;
119 tpg->perc_fill = 100; 119 tpg->perc_fill = 100;
120 tpg->hsv_enc = V4L2_HSV_ENC_180;
120} 121}
121EXPORT_SYMBOL_GPL(tpg_init); 122EXPORT_SYMBOL_GPL(tpg_init);
122 123
@@ -234,16 +235,18 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
234 case V4L2_PIX_FMT_XBGR32: 235 case V4L2_PIX_FMT_XBGR32:
235 case V4L2_PIX_FMT_ARGB32: 236 case V4L2_PIX_FMT_ARGB32:
236 case V4L2_PIX_FMT_ABGR32: 237 case V4L2_PIX_FMT_ABGR32:
238 tpg->color_enc = TGP_COLOR_ENC_RGB;
239 break;
237 case V4L2_PIX_FMT_GREY: 240 case V4L2_PIX_FMT_GREY:
238 case V4L2_PIX_FMT_Y16: 241 case V4L2_PIX_FMT_Y16:
239 case V4L2_PIX_FMT_Y16_BE: 242 case V4L2_PIX_FMT_Y16_BE:
240 tpg->is_yuv = false; 243 tpg->color_enc = TGP_COLOR_ENC_LUMA;
241 break; 244 break;
242 case V4L2_PIX_FMT_YUV444: 245 case V4L2_PIX_FMT_YUV444:
243 case V4L2_PIX_FMT_YUV555: 246 case V4L2_PIX_FMT_YUV555:
244 case V4L2_PIX_FMT_YUV565: 247 case V4L2_PIX_FMT_YUV565:
245 case V4L2_PIX_FMT_YUV32: 248 case V4L2_PIX_FMT_YUV32:
246 tpg->is_yuv = true; 249 tpg->color_enc = TGP_COLOR_ENC_YCBCR;
247 break; 250 break;
248 case V4L2_PIX_FMT_YUV420M: 251 case V4L2_PIX_FMT_YUV420M:
249 case V4L2_PIX_FMT_YVU420M: 252 case V4L2_PIX_FMT_YVU420M:
@@ -256,7 +259,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
256 tpg->hdownsampling[1] = 2; 259 tpg->hdownsampling[1] = 2;
257 tpg->hdownsampling[2] = 2; 260 tpg->hdownsampling[2] = 2;
258 tpg->planes = 3; 261 tpg->planes = 3;
259 tpg->is_yuv = true; 262 tpg->color_enc = TGP_COLOR_ENC_YCBCR;
260 break; 263 break;
261 case V4L2_PIX_FMT_YUV422M: 264 case V4L2_PIX_FMT_YUV422M:
262 case V4L2_PIX_FMT_YVU422M: 265 case V4L2_PIX_FMT_YVU422M:
@@ -268,7 +271,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
268 tpg->hdownsampling[1] = 2; 271 tpg->hdownsampling[1] = 2;
269 tpg->hdownsampling[2] = 2; 272 tpg->hdownsampling[2] = 2;
270 tpg->planes = 3; 273 tpg->planes = 3;
271 tpg->is_yuv = true; 274 tpg->color_enc = TGP_COLOR_ENC_YCBCR;
272 break; 275 break;
273 case V4L2_PIX_FMT_NV16M: 276 case V4L2_PIX_FMT_NV16M:
274 case V4L2_PIX_FMT_NV61M: 277 case V4L2_PIX_FMT_NV61M:
@@ -280,7 +283,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
280 tpg->hdownsampling[1] = 1; 283 tpg->hdownsampling[1] = 1;
281 tpg->hmask[1] = ~1; 284 tpg->hmask[1] = ~1;
282 tpg->planes = 2; 285 tpg->planes = 2;
283 tpg->is_yuv = true; 286 tpg->color_enc = TGP_COLOR_ENC_YCBCR;
284 break; 287 break;
285 case V4L2_PIX_FMT_NV12M: 288 case V4L2_PIX_FMT_NV12M:
286 case V4L2_PIX_FMT_NV21M: 289 case V4L2_PIX_FMT_NV21M:
@@ -292,7 +295,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
292 tpg->hdownsampling[1] = 1; 295 tpg->hdownsampling[1] = 1;
293 tpg->hmask[1] = ~1; 296 tpg->hmask[1] = ~1;
294 tpg->planes = 2; 297 tpg->planes = 2;
295 tpg->is_yuv = true; 298 tpg->color_enc = TGP_COLOR_ENC_YCBCR;
296 break; 299 break;
297 case V4L2_PIX_FMT_YUV444M: 300 case V4L2_PIX_FMT_YUV444M:
298 case V4L2_PIX_FMT_YVU444M: 301 case V4L2_PIX_FMT_YVU444M:
@@ -302,21 +305,25 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
302 tpg->vdownsampling[2] = 1; 305 tpg->vdownsampling[2] = 1;
303 tpg->hdownsampling[1] = 1; 306 tpg->hdownsampling[1] = 1;
304 tpg->hdownsampling[2] = 1; 307 tpg->hdownsampling[2] = 1;
305 tpg->is_yuv = true; 308 tpg->color_enc = TGP_COLOR_ENC_YCBCR;
306 break; 309 break;
307 case V4L2_PIX_FMT_NV24: 310 case V4L2_PIX_FMT_NV24:
308 case V4L2_PIX_FMT_NV42: 311 case V4L2_PIX_FMT_NV42:
309 tpg->vdownsampling[1] = 1; 312 tpg->vdownsampling[1] = 1;
310 tpg->hdownsampling[1] = 1; 313 tpg->hdownsampling[1] = 1;
311 tpg->planes = 2; 314 tpg->planes = 2;
312 tpg->is_yuv = true; 315 tpg->color_enc = TGP_COLOR_ENC_YCBCR;
313 break; 316 break;
314 case V4L2_PIX_FMT_YUYV: 317 case V4L2_PIX_FMT_YUYV:
315 case V4L2_PIX_FMT_UYVY: 318 case V4L2_PIX_FMT_UYVY:
316 case V4L2_PIX_FMT_YVYU: 319 case V4L2_PIX_FMT_YVYU:
317 case V4L2_PIX_FMT_VYUY: 320 case V4L2_PIX_FMT_VYUY:
318 tpg->hmask[0] = ~1; 321 tpg->hmask[0] = ~1;
319 tpg->is_yuv = true; 322 tpg->color_enc = TGP_COLOR_ENC_YCBCR;
323 break;
324 case V4L2_PIX_FMT_HSV24:
325 case V4L2_PIX_FMT_HSV32:
326 tpg->color_enc = TGP_COLOR_ENC_HSV;
320 break; 327 break;
321 default: 328 default:
322 return false; 329 return false;
@@ -351,6 +358,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
351 break; 358 break;
352 case V4L2_PIX_FMT_RGB24: 359 case V4L2_PIX_FMT_RGB24:
353 case V4L2_PIX_FMT_BGR24: 360 case V4L2_PIX_FMT_BGR24:
361 case V4L2_PIX_FMT_HSV24:
354 tpg->twopixelsize[0] = 2 * 3; 362 tpg->twopixelsize[0] = 2 * 3;
355 break; 363 break;
356 case V4L2_PIX_FMT_BGR666: 364 case V4L2_PIX_FMT_BGR666:
@@ -361,6 +369,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
361 case V4L2_PIX_FMT_ARGB32: 369 case V4L2_PIX_FMT_ARGB32:
362 case V4L2_PIX_FMT_ABGR32: 370 case V4L2_PIX_FMT_ABGR32:
363 case V4L2_PIX_FMT_YUV32: 371 case V4L2_PIX_FMT_YUV32:
372 case V4L2_PIX_FMT_HSV32:
364 tpg->twopixelsize[0] = 2 * 4; 373 tpg->twopixelsize[0] = 2 * 4;
365 break; 374 break;
366 case V4L2_PIX_FMT_NV12: 375 case V4L2_PIX_FMT_NV12:
@@ -490,6 +499,71 @@ static inline int linear_to_rec709(int v)
490 return tpg_linear_to_rec709[v]; 499 return tpg_linear_to_rec709[v];
491} 500}
492 501
502static void color_to_hsv(struct tpg_data *tpg, int r, int g, int b,
503 int *h, int *s, int *v)
504{
505 int max_rgb, min_rgb, diff_rgb;
506 int aux;
507 int third;
508 int third_size;
509
510 r >>= 4;
511 g >>= 4;
512 b >>= 4;
513
514 /* Value */
515 max_rgb = max3(r, g, b);
516 *v = max_rgb;
517 if (!max_rgb) {
518 *h = 0;
519 *s = 0;
520 return;
521 }
522
523 /* Saturation */
524 min_rgb = min3(r, g, b);
525 diff_rgb = max_rgb - min_rgb;
526 aux = 255 * diff_rgb;
527 aux += max_rgb / 2;
528 aux /= max_rgb;
529 *s = aux;
530 if (!aux) {
531 *h = 0;
532 return;
533 }
534
535 third_size = (tpg->real_hsv_enc == V4L2_HSV_ENC_180) ? 60 : 85;
536
537 /* Hue */
538 if (max_rgb == r) {
539 aux = g - b;
540 third = 0;
541 } else if (max_rgb == g) {
542 aux = b - r;
543 third = third_size;
544 } else {
545 aux = r - g;
546 third = third_size * 2;
547 }
548
549 aux *= third_size / 2;
550 aux += diff_rgb / 2;
551 aux /= diff_rgb;
552 aux += third;
553
554 /* Clamp Hue */
555 if (tpg->real_hsv_enc == V4L2_HSV_ENC_180) {
556 if (aux < 0)
557 aux += 180;
558 else if (aux > 180)
559 aux -= 180;
560 } else {
561 aux = aux & 0xff;
562 }
563
564 *h = aux;
565}
566
493static void rgb2ycbcr(const int m[3][3], int r, int g, int b, 567static void rgb2ycbcr(const int m[3][3], int r, int g, int b,
494 int y_offset, int *y, int *cb, int *cr) 568 int y_offset, int *y, int *cb, int *cr)
495{ 569{
@@ -729,6 +803,8 @@ static void precalculate_color(struct tpg_data *tpg, int k)
729 int r = tpg_colors[col].r; 803 int r = tpg_colors[col].r;
730 int g = tpg_colors[col].g; 804 int g = tpg_colors[col].g;
731 int b = tpg_colors[col].b; 805 int b = tpg_colors[col].b;
806 int y, cb, cr;
807 bool ycbcr_valid = false;
732 808
733 if (k == TPG_COLOR_TEXTBG) { 809 if (k == TPG_COLOR_TEXTBG) {
734 col = tpg_get_textbg_color(tpg); 810 col = tpg_get_textbg_color(tpg);
@@ -759,9 +835,9 @@ static void precalculate_color(struct tpg_data *tpg, int k)
759 g <<= 4; 835 g <<= 4;
760 b <<= 4; 836 b <<= 4;
761 } 837 }
762 if (tpg->qual == TPG_QUAL_GRAY || tpg->fourcc == V4L2_PIX_FMT_GREY || 838
763 tpg->fourcc == V4L2_PIX_FMT_Y16 || 839 if (tpg->qual == TPG_QUAL_GRAY ||
764 tpg->fourcc == V4L2_PIX_FMT_Y16_BE) { 840 tpg->color_enc == TGP_COLOR_ENC_LUMA) {
765 /* Rec. 709 Luma function */ 841 /* Rec. 709 Luma function */
766 /* (0.2126, 0.7152, 0.0722) * (255 * 256) */ 842 /* (0.2126, 0.7152, 0.0722) * (255 * 256) */
767 r = g = b = (13879 * r + 46688 * g + 4713 * b) >> 16; 843 r = g = b = (13879 * r + 46688 * g + 4713 * b) >> 16;
@@ -775,7 +851,8 @@ static void precalculate_color(struct tpg_data *tpg, int k)
775 * Remember that r, g and b are still in the 0 - 0xff0 range. 851 * Remember that r, g and b are still in the 0 - 0xff0 range.
776 */ 852 */
777 if (tpg->real_rgb_range == V4L2_DV_RGB_RANGE_LIMITED && 853 if (tpg->real_rgb_range == V4L2_DV_RGB_RANGE_LIMITED &&
778 tpg->rgb_range == V4L2_DV_RGB_RANGE_FULL && !tpg->is_yuv) { 854 tpg->rgb_range == V4L2_DV_RGB_RANGE_FULL &&
855 tpg->color_enc == TGP_COLOR_ENC_RGB) {
779 /* 856 /*
780 * Convert from full range (which is what r, g and b are) 857 * Convert from full range (which is what r, g and b are)
781 * to limited range (which is the 'real' RGB range), which 858 * to limited range (which is the 'real' RGB range), which
@@ -785,7 +862,9 @@ static void precalculate_color(struct tpg_data *tpg, int k)
785 g = (g * 219) / 255 + (16 << 4); 862 g = (g * 219) / 255 + (16 << 4);
786 b = (b * 219) / 255 + (16 << 4); 863 b = (b * 219) / 255 + (16 << 4);
787 } else if (tpg->real_rgb_range != V4L2_DV_RGB_RANGE_LIMITED && 864 } else if (tpg->real_rgb_range != V4L2_DV_RGB_RANGE_LIMITED &&
788 tpg->rgb_range == V4L2_DV_RGB_RANGE_LIMITED && !tpg->is_yuv) { 865 tpg->rgb_range == V4L2_DV_RGB_RANGE_LIMITED &&
866 tpg->color_enc == TGP_COLOR_ENC_RGB) {
867
789 /* 868 /*
790 * Clamp r, g and b to the limited range and convert to full 869 * Clamp r, g and b to the limited range and convert to full
791 * range since that's what we deliver. 870 * range since that's what we deliver.
@@ -798,10 +877,10 @@ static void precalculate_color(struct tpg_data *tpg, int k)
798 b = (b - (16 << 4)) * 255 / 219; 877 b = (b - (16 << 4)) * 255 / 219;
799 } 878 }
800 879
801 if (tpg->brightness != 128 || tpg->contrast != 128 || 880 if ((tpg->brightness != 128 || tpg->contrast != 128 ||
802 tpg->saturation != 128 || tpg->hue) { 881 tpg->saturation != 128 || tpg->hue) &&
882 tpg->color_enc != TGP_COLOR_ENC_LUMA) {
803 /* Implement these operations */ 883 /* Implement these operations */
804 int y, cb, cr;
805 int tmp_cb, tmp_cr; 884 int tmp_cb, tmp_cr;
806 885
807 /* First convert to YCbCr */ 886 /* First convert to YCbCr */
@@ -818,29 +897,45 @@ static void precalculate_color(struct tpg_data *tpg, int k)
818 897
819 cb = (128 << 4) + (tmp_cb * tpg->contrast * tpg->saturation) / (128 * 128); 898 cb = (128 << 4) + (tmp_cb * tpg->contrast * tpg->saturation) / (128 * 128);
820 cr = (128 << 4) + (tmp_cr * tpg->contrast * tpg->saturation) / (128 * 128); 899 cr = (128 << 4) + (tmp_cr * tpg->contrast * tpg->saturation) / (128 * 128);
821 if (tpg->is_yuv) { 900 if (tpg->color_enc == TGP_COLOR_ENC_YCBCR)
822 tpg->colors[k][0] = clamp(y >> 4, 1, 254); 901 ycbcr_valid = true;
823 tpg->colors[k][1] = clamp(cb >> 4, 1, 254); 902 else
824 tpg->colors[k][2] = clamp(cr >> 4, 1, 254); 903 ycbcr_to_color(tpg, y, cb, cr, &r, &g, &b);
825 return; 904 } else if ((tpg->brightness != 128 || tpg->contrast != 128) &&
826 } 905 tpg->color_enc == TGP_COLOR_ENC_LUMA) {
827 ycbcr_to_color(tpg, y, cb, cr, &r, &g, &b); 906 r = (16 << 4) + ((r - (16 << 4)) * tpg->contrast) / 128;
907 r += (tpg->brightness << 4) - (128 << 4);
828 } 908 }
829 909
830 if (tpg->is_yuv) { 910 switch (tpg->color_enc) {
831 /* Convert to YCbCr */ 911 case TGP_COLOR_ENC_HSV:
832 int y, cb, cr; 912 {
913 int h, s, v;
833 914
834 color_to_ycbcr(tpg, r, g, b, &y, &cb, &cr); 915 color_to_hsv(tpg, r, g, b, &h, &s, &v);
916 tpg->colors[k][0] = h;
917 tpg->colors[k][1] = s;
918 tpg->colors[k][2] = v;
919 break;
920 }
921 case TGP_COLOR_ENC_YCBCR:
922 {
923 /* Convert to YCbCr */
924 if (!ycbcr_valid)
925 color_to_ycbcr(tpg, r, g, b, &y, &cb, &cr);
835 926
927 y >>= 4;
928 cb >>= 4;
929 cr >>= 4;
836 if (tpg->real_quantization == V4L2_QUANTIZATION_LIM_RANGE) { 930 if (tpg->real_quantization == V4L2_QUANTIZATION_LIM_RANGE) {
837 y = clamp(y, 16 << 4, 235 << 4); 931 y = clamp(y, 16, 235);
838 cb = clamp(cb, 16 << 4, 240 << 4); 932 cb = clamp(cb, 16, 240);
839 cr = clamp(cr, 16 << 4, 240 << 4); 933 cr = clamp(cr, 16, 240);
934 } else {
935 y = clamp(y, 1, 254);
936 cb = clamp(cb, 1, 254);
937 cr = clamp(cr, 1, 254);
840 } 938 }
841 y = clamp(y >> 4, 1, 254);
842 cb = clamp(cb >> 4, 1, 254);
843 cr = clamp(cr >> 4, 1, 254);
844 switch (tpg->fourcc) { 939 switch (tpg->fourcc) {
845 case V4L2_PIX_FMT_YUV444: 940 case V4L2_PIX_FMT_YUV444:
846 y >>= 4; 941 y >>= 4;
@@ -861,7 +956,15 @@ static void precalculate_color(struct tpg_data *tpg, int k)
861 tpg->colors[k][0] = y; 956 tpg->colors[k][0] = y;
862 tpg->colors[k][1] = cb; 957 tpg->colors[k][1] = cb;
863 tpg->colors[k][2] = cr; 958 tpg->colors[k][2] = cr;
864 } else { 959 break;
960 }
961 case TGP_COLOR_ENC_LUMA:
962 {
963 tpg->colors[k][0] = r >> 4;
964 break;
965 }
966 case TGP_COLOR_ENC_RGB:
967 {
865 if (tpg->real_quantization == V4L2_QUANTIZATION_LIM_RANGE) { 968 if (tpg->real_quantization == V4L2_QUANTIZATION_LIM_RANGE) {
866 r = (r * 219) / 255 + (16 << 4); 969 r = (r * 219) / 255 + (16 << 4);
867 g = (g * 219) / 255 + (16 << 4); 970 g = (g * 219) / 255 + (16 << 4);
@@ -911,6 +1014,8 @@ static void precalculate_color(struct tpg_data *tpg, int k)
911 tpg->colors[k][0] = r; 1014 tpg->colors[k][0] = r;
912 tpg->colors[k][1] = g; 1015 tpg->colors[k][1] = g;
913 tpg->colors[k][2] = b; 1016 tpg->colors[k][2] = b;
1017 break;
1018 }
914 } 1019 }
915} 1020}
916 1021
@@ -928,7 +1033,7 @@ static void gen_twopix(struct tpg_data *tpg,
928{ 1033{
929 unsigned offset = odd * tpg->twopixelsize[0] / 2; 1034 unsigned offset = odd * tpg->twopixelsize[0] / 2;
930 u8 alpha = tpg->alpha_component; 1035 u8 alpha = tpg->alpha_component;
931 u8 r_y, g_u, b_v; 1036 u8 r_y_h, g_u_s, b_v;
932 1037
933 if (tpg->alpha_red_only && color != TPG_COLOR_CSC_RED && 1038 if (tpg->alpha_red_only && color != TPG_COLOR_CSC_RED &&
934 color != TPG_COLOR_100_RED && 1039 color != TPG_COLOR_100_RED &&
@@ -936,161 +1041,161 @@ static void gen_twopix(struct tpg_data *tpg,
936 alpha = 0; 1041 alpha = 0;
937 if (color == TPG_COLOR_RANDOM) 1042 if (color == TPG_COLOR_RANDOM)
938 precalculate_color(tpg, color); 1043 precalculate_color(tpg, color);
939 r_y = tpg->colors[color][0]; /* R or precalculated Y */ 1044 r_y_h = tpg->colors[color][0]; /* R or precalculated Y, H */
940 g_u = tpg->colors[color][1]; /* G or precalculated U */ 1045 g_u_s = tpg->colors[color][1]; /* G or precalculated U, V */
941 b_v = tpg->colors[color][2]; /* B or precalculated V */ 1046 b_v = tpg->colors[color][2]; /* B or precalculated V */
942 1047
943 switch (tpg->fourcc) { 1048 switch (tpg->fourcc) {
944 case V4L2_PIX_FMT_GREY: 1049 case V4L2_PIX_FMT_GREY:
945 buf[0][offset] = r_y; 1050 buf[0][offset] = r_y_h;
946 break; 1051 break;
947 case V4L2_PIX_FMT_Y16: 1052 case V4L2_PIX_FMT_Y16:
948 /* 1053 /*
949 * Ideally both bytes should be set to r_y, but then you won't 1054 * Ideally both bytes should be set to r_y_h, but then you won't
950 * be able to detect endian problems. So keep it 0 except for 1055 * be able to detect endian problems. So keep it 0 except for
951 * the corner case where r_y is 0xff so white really will be 1056 * the corner case where r_y_h is 0xff so white really will be
952 * white (0xffff). 1057 * white (0xffff).
953 */ 1058 */
954 buf[0][offset] = r_y == 0xff ? r_y : 0; 1059 buf[0][offset] = r_y_h == 0xff ? r_y_h : 0;
955 buf[0][offset+1] = r_y; 1060 buf[0][offset+1] = r_y_h;
956 break; 1061 break;
957 case V4L2_PIX_FMT_Y16_BE: 1062 case V4L2_PIX_FMT_Y16_BE:
958 /* See comment for V4L2_PIX_FMT_Y16 above */ 1063 /* See comment for V4L2_PIX_FMT_Y16 above */
959 buf[0][offset] = r_y; 1064 buf[0][offset] = r_y_h;
960 buf[0][offset+1] = r_y == 0xff ? r_y : 0; 1065 buf[0][offset+1] = r_y_h == 0xff ? r_y_h : 0;
961 break; 1066 break;
962 case V4L2_PIX_FMT_YUV422M: 1067 case V4L2_PIX_FMT_YUV422M:
963 case V4L2_PIX_FMT_YUV422P: 1068 case V4L2_PIX_FMT_YUV422P:
964 case V4L2_PIX_FMT_YUV420: 1069 case V4L2_PIX_FMT_YUV420:
965 case V4L2_PIX_FMT_YUV420M: 1070 case V4L2_PIX_FMT_YUV420M:
966 buf[0][offset] = r_y; 1071 buf[0][offset] = r_y_h;
967 if (odd) { 1072 if (odd) {
968 buf[1][0] = (buf[1][0] + g_u) / 2; 1073 buf[1][0] = (buf[1][0] + g_u_s) / 2;
969 buf[2][0] = (buf[2][0] + b_v) / 2; 1074 buf[2][0] = (buf[2][0] + b_v) / 2;
970 buf[1][1] = buf[1][0]; 1075 buf[1][1] = buf[1][0];
971 buf[2][1] = buf[2][0]; 1076 buf[2][1] = buf[2][0];
972 break; 1077 break;
973 } 1078 }
974 buf[1][0] = g_u; 1079 buf[1][0] = g_u_s;
975 buf[2][0] = b_v; 1080 buf[2][0] = b_v;
976 break; 1081 break;
977 case V4L2_PIX_FMT_YVU422M: 1082 case V4L2_PIX_FMT_YVU422M:
978 case V4L2_PIX_FMT_YVU420: 1083 case V4L2_PIX_FMT_YVU420:
979 case V4L2_PIX_FMT_YVU420M: 1084 case V4L2_PIX_FMT_YVU420M:
980 buf[0][offset] = r_y; 1085 buf[0][offset] = r_y_h;
981 if (odd) { 1086 if (odd) {
982 buf[1][0] = (buf[1][0] + b_v) / 2; 1087 buf[1][0] = (buf[1][0] + b_v) / 2;
983 buf[2][0] = (buf[2][0] + g_u) / 2; 1088 buf[2][0] = (buf[2][0] + g_u_s) / 2;
984 buf[1][1] = buf[1][0]; 1089 buf[1][1] = buf[1][0];
985 buf[2][1] = buf[2][0]; 1090 buf[2][1] = buf[2][0];
986 break; 1091 break;
987 } 1092 }
988 buf[1][0] = b_v; 1093 buf[1][0] = b_v;
989 buf[2][0] = g_u; 1094 buf[2][0] = g_u_s;
990 break; 1095 break;
991 1096
992 case V4L2_PIX_FMT_NV12: 1097 case V4L2_PIX_FMT_NV12:
993 case V4L2_PIX_FMT_NV12M: 1098 case V4L2_PIX_FMT_NV12M:
994 case V4L2_PIX_FMT_NV16: 1099 case V4L2_PIX_FMT_NV16:
995 case V4L2_PIX_FMT_NV16M: 1100 case V4L2_PIX_FMT_NV16M:
996 buf[0][offset] = r_y; 1101 buf[0][offset] = r_y_h;
997 if (odd) { 1102 if (odd) {
998 buf[1][0] = (buf[1][0] + g_u) / 2; 1103 buf[1][0] = (buf[1][0] + g_u_s) / 2;
999 buf[1][1] = (buf[1][1] + b_v) / 2; 1104 buf[1][1] = (buf[1][1] + b_v) / 2;
1000 break; 1105 break;
1001 } 1106 }
1002 buf[1][0] = g_u; 1107 buf[1][0] = g_u_s;
1003 buf[1][1] = b_v; 1108 buf[1][1] = b_v;
1004 break; 1109 break;
1005 case V4L2_PIX_FMT_NV21: 1110 case V4L2_PIX_FMT_NV21:
1006 case V4L2_PIX_FMT_NV21M: 1111 case V4L2_PIX_FMT_NV21M:
1007 case V4L2_PIX_FMT_NV61: 1112 case V4L2_PIX_FMT_NV61:
1008 case V4L2_PIX_FMT_NV61M: 1113 case V4L2_PIX_FMT_NV61M:
1009 buf[0][offset] = r_y; 1114 buf[0][offset] = r_y_h;
1010 if (odd) { 1115 if (odd) {
1011 buf[1][0] = (buf[1][0] + b_v) / 2; 1116 buf[1][0] = (buf[1][0] + b_v) / 2;
1012 buf[1][1] = (buf[1][1] + g_u) / 2; 1117 buf[1][1] = (buf[1][1] + g_u_s) / 2;
1013 break; 1118 break;
1014 } 1119 }
1015 buf[1][0] = b_v; 1120 buf[1][0] = b_v;
1016 buf[1][1] = g_u; 1121 buf[1][1] = g_u_s;
1017 break; 1122 break;
1018 1123
1019 case V4L2_PIX_FMT_YUV444M: 1124 case V4L2_PIX_FMT_YUV444M:
1020 buf[0][offset] = r_y; 1125 buf[0][offset] = r_y_h;
1021 buf[1][offset] = g_u; 1126 buf[1][offset] = g_u_s;
1022 buf[2][offset] = b_v; 1127 buf[2][offset] = b_v;
1023 break; 1128 break;
1024 1129
1025 case V4L2_PIX_FMT_YVU444M: 1130 case V4L2_PIX_FMT_YVU444M:
1026 buf[0][offset] = r_y; 1131 buf[0][offset] = r_y_h;
1027 buf[1][offset] = b_v; 1132 buf[1][offset] = b_v;
1028 buf[2][offset] = g_u; 1133 buf[2][offset] = g_u_s;
1029 break; 1134 break;
1030 1135
1031 case V4L2_PIX_FMT_NV24: 1136 case V4L2_PIX_FMT_NV24:
1032 buf[0][offset] = r_y; 1137 buf[0][offset] = r_y_h;
1033 buf[1][2 * offset] = g_u; 1138 buf[1][2 * offset] = g_u_s;
1034 buf[1][2 * offset + 1] = b_v; 1139 buf[1][2 * offset + 1] = b_v;
1035 break; 1140 break;
1036 1141
1037 case V4L2_PIX_FMT_NV42: 1142 case V4L2_PIX_FMT_NV42:
1038 buf[0][offset] = r_y; 1143 buf[0][offset] = r_y_h;
1039 buf[1][2 * offset] = b_v; 1144 buf[1][2 * offset] = b_v;
1040 buf[1][2 * offset + 1] = g_u; 1145 buf[1][2 * offset + 1] = g_u_s;
1041 break; 1146 break;
1042 1147
1043 case V4L2_PIX_FMT_YUYV: 1148 case V4L2_PIX_FMT_YUYV:
1044 buf[0][offset] = r_y; 1149 buf[0][offset] = r_y_h;
1045 if (odd) { 1150 if (odd) {
1046 buf[0][1] = (buf[0][1] + g_u) / 2; 1151 buf[0][1] = (buf[0][1] + g_u_s) / 2;
1047 buf[0][3] = (buf[0][3] + b_v) / 2; 1152 buf[0][3] = (buf[0][3] + b_v) / 2;
1048 break; 1153 break;
1049 } 1154 }
1050 buf[0][1] = g_u; 1155 buf[0][1] = g_u_s;
1051 buf[0][3] = b_v; 1156 buf[0][3] = b_v;
1052 break; 1157 break;
1053 case V4L2_PIX_FMT_UYVY: 1158 case V4L2_PIX_FMT_UYVY:
1054 buf[0][offset + 1] = r_y; 1159 buf[0][offset + 1] = r_y_h;
1055 if (odd) { 1160 if (odd) {
1056 buf[0][0] = (buf[0][0] + g_u) / 2; 1161 buf[0][0] = (buf[0][0] + g_u_s) / 2;
1057 buf[0][2] = (buf[0][2] + b_v) / 2; 1162 buf[0][2] = (buf[0][2] + b_v) / 2;
1058 break; 1163 break;
1059 } 1164 }
1060 buf[0][0] = g_u; 1165 buf[0][0] = g_u_s;
1061 buf[0][2] = b_v; 1166 buf[0][2] = b_v;
1062 break; 1167 break;
1063 case V4L2_PIX_FMT_YVYU: 1168 case V4L2_PIX_FMT_YVYU:
1064 buf[0][offset] = r_y; 1169 buf[0][offset] = r_y_h;
1065 if (odd) { 1170 if (odd) {
1066 buf[0][1] = (buf[0][1] + b_v) / 2; 1171 buf[0][1] = (buf[0][1] + b_v) / 2;
1067 buf[0][3] = (buf[0][3] + g_u) / 2; 1172 buf[0][3] = (buf[0][3] + g_u_s) / 2;
1068 break; 1173 break;
1069 } 1174 }
1070 buf[0][1] = b_v; 1175 buf[0][1] = b_v;
1071 buf[0][3] = g_u; 1176 buf[0][3] = g_u_s;
1072 break; 1177 break;
1073 case V4L2_PIX_FMT_VYUY: 1178 case V4L2_PIX_FMT_VYUY:
1074 buf[0][offset + 1] = r_y; 1179 buf[0][offset + 1] = r_y_h;
1075 if (odd) { 1180 if (odd) {
1076 buf[0][0] = (buf[0][0] + b_v) / 2; 1181 buf[0][0] = (buf[0][0] + b_v) / 2;
1077 buf[0][2] = (buf[0][2] + g_u) / 2; 1182 buf[0][2] = (buf[0][2] + g_u_s) / 2;
1078 break; 1183 break;
1079 } 1184 }
1080 buf[0][0] = b_v; 1185 buf[0][0] = b_v;
1081 buf[0][2] = g_u; 1186 buf[0][2] = g_u_s;
1082 break; 1187 break;
1083 case V4L2_PIX_FMT_RGB332: 1188 case V4L2_PIX_FMT_RGB332:
1084 buf[0][offset] = (r_y << 5) | (g_u << 2) | b_v; 1189 buf[0][offset] = (r_y_h << 5) | (g_u_s << 2) | b_v;
1085 break; 1190 break;
1086 case V4L2_PIX_FMT_YUV565: 1191 case V4L2_PIX_FMT_YUV565:
1087 case V4L2_PIX_FMT_RGB565: 1192 case V4L2_PIX_FMT_RGB565:
1088 buf[0][offset] = (g_u << 5) | b_v; 1193 buf[0][offset] = (g_u_s << 5) | b_v;
1089 buf[0][offset + 1] = (r_y << 3) | (g_u >> 3); 1194 buf[0][offset + 1] = (r_y_h << 3) | (g_u_s >> 3);
1090 break; 1195 break;
1091 case V4L2_PIX_FMT_RGB565X: 1196 case V4L2_PIX_FMT_RGB565X:
1092 buf[0][offset] = (r_y << 3) | (g_u >> 3); 1197 buf[0][offset] = (r_y_h << 3) | (g_u_s >> 3);
1093 buf[0][offset + 1] = (g_u << 5) | b_v; 1198 buf[0][offset + 1] = (g_u_s << 5) | b_v;
1094 break; 1199 break;
1095 case V4L2_PIX_FMT_RGB444: 1200 case V4L2_PIX_FMT_RGB444:
1096 case V4L2_PIX_FMT_XRGB444: 1201 case V4L2_PIX_FMT_XRGB444:
@@ -1098,8 +1203,8 @@ static void gen_twopix(struct tpg_data *tpg,
1098 /* fall through */ 1203 /* fall through */
1099 case V4L2_PIX_FMT_YUV444: 1204 case V4L2_PIX_FMT_YUV444:
1100 case V4L2_PIX_FMT_ARGB444: 1205 case V4L2_PIX_FMT_ARGB444:
1101 buf[0][offset] = (g_u << 4) | b_v; 1206 buf[0][offset] = (g_u_s << 4) | b_v;
1102 buf[0][offset + 1] = (alpha & 0xf0) | r_y; 1207 buf[0][offset + 1] = (alpha & 0xf0) | r_y_h;
1103 break; 1208 break;
1104 case V4L2_PIX_FMT_RGB555: 1209 case V4L2_PIX_FMT_RGB555:
1105 case V4L2_PIX_FMT_XRGB555: 1210 case V4L2_PIX_FMT_XRGB555:
@@ -1107,42 +1212,45 @@ static void gen_twopix(struct tpg_data *tpg,
1107 /* fall through */ 1212 /* fall through */
1108 case V4L2_PIX_FMT_YUV555: 1213 case V4L2_PIX_FMT_YUV555:
1109 case V4L2_PIX_FMT_ARGB555: 1214 case V4L2_PIX_FMT_ARGB555:
1110 buf[0][offset] = (g_u << 5) | b_v; 1215 buf[0][offset] = (g_u_s << 5) | b_v;
1111 buf[0][offset + 1] = (alpha & 0x80) | (r_y << 2) | (g_u >> 3); 1216 buf[0][offset + 1] = (alpha & 0x80) | (r_y_h << 2)
1217 | (g_u_s >> 3);
1112 break; 1218 break;
1113 case V4L2_PIX_FMT_RGB555X: 1219 case V4L2_PIX_FMT_RGB555X:
1114 case V4L2_PIX_FMT_XRGB555X: 1220 case V4L2_PIX_FMT_XRGB555X:
1115 alpha = 0; 1221 alpha = 0;
1116 /* fall through */ 1222 /* fall through */
1117 case V4L2_PIX_FMT_ARGB555X: 1223 case V4L2_PIX_FMT_ARGB555X:
1118 buf[0][offset] = (alpha & 0x80) | (r_y << 2) | (g_u >> 3); 1224 buf[0][offset] = (alpha & 0x80) | (r_y_h << 2) | (g_u_s >> 3);
1119 buf[0][offset + 1] = (g_u << 5) | b_v; 1225 buf[0][offset + 1] = (g_u_s << 5) | b_v;
1120 break; 1226 break;
1121 case V4L2_PIX_FMT_RGB24: 1227 case V4L2_PIX_FMT_RGB24:
1122 buf[0][offset] = r_y; 1228 case V4L2_PIX_FMT_HSV24:
1123 buf[0][offset + 1] = g_u; 1229 buf[0][offset] = r_y_h;
1230 buf[0][offset + 1] = g_u_s;
1124 buf[0][offset + 2] = b_v; 1231 buf[0][offset + 2] = b_v;
1125 break; 1232 break;
1126 case V4L2_PIX_FMT_BGR24: 1233 case V4L2_PIX_FMT_BGR24:
1127 buf[0][offset] = b_v; 1234 buf[0][offset] = b_v;
1128 buf[0][offset + 1] = g_u; 1235 buf[0][offset + 1] = g_u_s;
1129 buf[0][offset + 2] = r_y; 1236 buf[0][offset + 2] = r_y_h;
1130 break; 1237 break;
1131 case V4L2_PIX_FMT_BGR666: 1238 case V4L2_PIX_FMT_BGR666:
1132 buf[0][offset] = (b_v << 2) | (g_u >> 4); 1239 buf[0][offset] = (b_v << 2) | (g_u_s >> 4);
1133 buf[0][offset + 1] = (g_u << 4) | (r_y >> 2); 1240 buf[0][offset + 1] = (g_u_s << 4) | (r_y_h >> 2);
1134 buf[0][offset + 2] = r_y << 6; 1241 buf[0][offset + 2] = r_y_h << 6;
1135 buf[0][offset + 3] = 0; 1242 buf[0][offset + 3] = 0;
1136 break; 1243 break;
1137 case V4L2_PIX_FMT_RGB32: 1244 case V4L2_PIX_FMT_RGB32:
1138 case V4L2_PIX_FMT_XRGB32: 1245 case V4L2_PIX_FMT_XRGB32:
1246 case V4L2_PIX_FMT_HSV32:
1139 alpha = 0; 1247 alpha = 0;
1140 /* fall through */ 1248 /* fall through */
1141 case V4L2_PIX_FMT_YUV32: 1249 case V4L2_PIX_FMT_YUV32:
1142 case V4L2_PIX_FMT_ARGB32: 1250 case V4L2_PIX_FMT_ARGB32:
1143 buf[0][offset] = alpha; 1251 buf[0][offset] = alpha;
1144 buf[0][offset + 1] = r_y; 1252 buf[0][offset + 1] = r_y_h;
1145 buf[0][offset + 2] = g_u; 1253 buf[0][offset + 2] = g_u_s;
1146 buf[0][offset + 3] = b_v; 1254 buf[0][offset + 3] = b_v;
1147 break; 1255 break;
1148 case V4L2_PIX_FMT_BGR32: 1256 case V4L2_PIX_FMT_BGR32:
@@ -1151,87 +1259,87 @@ static void gen_twopix(struct tpg_data *tpg,
1151 /* fall through */ 1259 /* fall through */
1152 case V4L2_PIX_FMT_ABGR32: 1260 case V4L2_PIX_FMT_ABGR32:
1153 buf[0][offset] = b_v; 1261 buf[0][offset] = b_v;
1154 buf[0][offset + 1] = g_u; 1262 buf[0][offset + 1] = g_u_s;
1155 buf[0][offset + 2] = r_y; 1263 buf[0][offset + 2] = r_y_h;
1156 buf[0][offset + 3] = alpha; 1264 buf[0][offset + 3] = alpha;
1157 break; 1265 break;
1158 case V4L2_PIX_FMT_SBGGR8: 1266 case V4L2_PIX_FMT_SBGGR8:
1159 buf[0][offset] = odd ? g_u : b_v; 1267 buf[0][offset] = odd ? g_u_s : b_v;
1160 buf[1][offset] = odd ? r_y : g_u; 1268 buf[1][offset] = odd ? r_y_h : g_u_s;
1161 break; 1269 break;
1162 case V4L2_PIX_FMT_SGBRG8: 1270 case V4L2_PIX_FMT_SGBRG8:
1163 buf[0][offset] = odd ? b_v : g_u; 1271 buf[0][offset] = odd ? b_v : g_u_s;
1164 buf[1][offset] = odd ? g_u : r_y; 1272 buf[1][offset] = odd ? g_u_s : r_y_h;
1165 break; 1273 break;
1166 case V4L2_PIX_FMT_SGRBG8: 1274 case V4L2_PIX_FMT_SGRBG8:
1167 buf[0][offset] = odd ? r_y : g_u; 1275 buf[0][offset] = odd ? r_y_h : g_u_s;
1168 buf[1][offset] = odd ? g_u : b_v; 1276 buf[1][offset] = odd ? g_u_s : b_v;
1169 break; 1277 break;
1170 case V4L2_PIX_FMT_SRGGB8: 1278 case V4L2_PIX_FMT_SRGGB8:
1171 buf[0][offset] = odd ? g_u : r_y; 1279 buf[0][offset] = odd ? g_u_s : r_y_h;
1172 buf[1][offset] = odd ? b_v : g_u; 1280 buf[1][offset] = odd ? b_v : g_u_s;
1173 break; 1281 break;
1174 case V4L2_PIX_FMT_SBGGR10: 1282 case V4L2_PIX_FMT_SBGGR10:
1175 buf[0][offset] = odd ? g_u << 2 : b_v << 2; 1283 buf[0][offset] = odd ? g_u_s << 2 : b_v << 2;
1176 buf[0][offset + 1] = odd ? g_u >> 6 : b_v >> 6; 1284 buf[0][offset + 1] = odd ? g_u_s >> 6 : b_v >> 6;
1177 buf[1][offset] = odd ? r_y << 2 : g_u << 2; 1285 buf[1][offset] = odd ? r_y_h << 2 : g_u_s << 2;
1178 buf[1][offset + 1] = odd ? r_y >> 6 : g_u >> 6; 1286 buf[1][offset + 1] = odd ? r_y_h >> 6 : g_u_s >> 6;
1179 buf[0][offset] |= (buf[0][offset] >> 2) & 3; 1287 buf[0][offset] |= (buf[0][offset] >> 2) & 3;
1180 buf[1][offset] |= (buf[1][offset] >> 2) & 3; 1288 buf[1][offset] |= (buf[1][offset] >> 2) & 3;
1181 break; 1289 break;
1182 case V4L2_PIX_FMT_SGBRG10: 1290 case V4L2_PIX_FMT_SGBRG10:
1183 buf[0][offset] = odd ? b_v << 2 : g_u << 2; 1291 buf[0][offset] = odd ? b_v << 2 : g_u_s << 2;
1184 buf[0][offset + 1] = odd ? b_v >> 6 : g_u >> 6; 1292 buf[0][offset + 1] = odd ? b_v >> 6 : g_u_s >> 6;
1185 buf[1][offset] = odd ? g_u << 2 : r_y << 2; 1293 buf[1][offset] = odd ? g_u_s << 2 : r_y_h << 2;
1186 buf[1][offset + 1] = odd ? g_u >> 6 : r_y >> 6; 1294 buf[1][offset + 1] = odd ? g_u_s >> 6 : r_y_h >> 6;
1187 buf[0][offset] |= (buf[0][offset] >> 2) & 3; 1295 buf[0][offset] |= (buf[0][offset] >> 2) & 3;
1188 buf[1][offset] |= (buf[1][offset] >> 2) & 3; 1296 buf[1][offset] |= (buf[1][offset] >> 2) & 3;
1189 break; 1297 break;
1190 case V4L2_PIX_FMT_SGRBG10: 1298 case V4L2_PIX_FMT_SGRBG10:
1191 buf[0][offset] = odd ? r_y << 2 : g_u << 2; 1299 buf[0][offset] = odd ? r_y_h << 2 : g_u_s << 2;
1192 buf[0][offset + 1] = odd ? r_y >> 6 : g_u >> 6; 1300 buf[0][offset + 1] = odd ? r_y_h >> 6 : g_u_s >> 6;
1193 buf[1][offset] = odd ? g_u << 2 : b_v << 2; 1301 buf[1][offset] = odd ? g_u_s << 2 : b_v << 2;
1194 buf[1][offset + 1] = odd ? g_u >> 6 : b_v >> 6; 1302 buf[1][offset + 1] = odd ? g_u_s >> 6 : b_v >> 6;
1195 buf[0][offset] |= (buf[0][offset] >> 2) & 3; 1303 buf[0][offset] |= (buf[0][offset] >> 2) & 3;
1196 buf[1][offset] |= (buf[1][offset] >> 2) & 3; 1304 buf[1][offset] |= (buf[1][offset] >> 2) & 3;
1197 break; 1305 break;
1198 case V4L2_PIX_FMT_SRGGB10: 1306 case V4L2_PIX_FMT_SRGGB10:
1199 buf[0][offset] = odd ? g_u << 2 : r_y << 2; 1307 buf[0][offset] = odd ? g_u_s << 2 : r_y_h << 2;
1200 buf[0][offset + 1] = odd ? g_u >> 6 : r_y >> 6; 1308 buf[0][offset + 1] = odd ? g_u_s >> 6 : r_y_h >> 6;
1201 buf[1][offset] = odd ? b_v << 2 : g_u << 2; 1309 buf[1][offset] = odd ? b_v << 2 : g_u_s << 2;
1202 buf[1][offset + 1] = odd ? b_v >> 6 : g_u >> 6; 1310 buf[1][offset + 1] = odd ? b_v >> 6 : g_u_s >> 6;
1203 buf[0][offset] |= (buf[0][offset] >> 2) & 3; 1311 buf[0][offset] |= (buf[0][offset] >> 2) & 3;
1204 buf[1][offset] |= (buf[1][offset] >> 2) & 3; 1312 buf[1][offset] |= (buf[1][offset] >> 2) & 3;
1205 break; 1313 break;
1206 case V4L2_PIX_FMT_SBGGR12: 1314 case V4L2_PIX_FMT_SBGGR12:
1207 buf[0][offset] = odd ? g_u << 4 : b_v << 4; 1315 buf[0][offset] = odd ? g_u_s << 4 : b_v << 4;
1208 buf[0][offset + 1] = odd ? g_u >> 4 : b_v >> 4; 1316 buf[0][offset + 1] = odd ? g_u_s >> 4 : b_v >> 4;
1209 buf[1][offset] = odd ? r_y << 4 : g_u << 4; 1317 buf[1][offset] = odd ? r_y_h << 4 : g_u_s << 4;
1210 buf[1][offset + 1] = odd ? r_y >> 4 : g_u >> 4; 1318 buf[1][offset + 1] = odd ? r_y_h >> 4 : g_u_s >> 4;
1211 buf[0][offset] |= (buf[0][offset] >> 4) & 0xf; 1319 buf[0][offset] |= (buf[0][offset] >> 4) & 0xf;
1212 buf[1][offset] |= (buf[1][offset] >> 4) & 0xf; 1320 buf[1][offset] |= (buf[1][offset] >> 4) & 0xf;
1213 break; 1321 break;
1214 case V4L2_PIX_FMT_SGBRG12: 1322 case V4L2_PIX_FMT_SGBRG12:
1215 buf[0][offset] = odd ? b_v << 4 : g_u << 4; 1323 buf[0][offset] = odd ? b_v << 4 : g_u_s << 4;
1216 buf[0][offset + 1] = odd ? b_v >> 4 : g_u >> 4; 1324 buf[0][offset + 1] = odd ? b_v >> 4 : g_u_s >> 4;
1217 buf[1][offset] = odd ? g_u << 4 : r_y << 4; 1325 buf[1][offset] = odd ? g_u_s << 4 : r_y_h << 4;
1218 buf[1][offset + 1] = odd ? g_u >> 4 : r_y >> 4; 1326 buf[1][offset + 1] = odd ? g_u_s >> 4 : r_y_h >> 4;
1219 buf[0][offset] |= (buf[0][offset] >> 4) & 0xf; 1327 buf[0][offset] |= (buf[0][offset] >> 4) & 0xf;
1220 buf[1][offset] |= (buf[1][offset] >> 4) & 0xf; 1328 buf[1][offset] |= (buf[1][offset] >> 4) & 0xf;
1221 break; 1329 break;
1222 case V4L2_PIX_FMT_SGRBG12: 1330 case V4L2_PIX_FMT_SGRBG12:
1223 buf[0][offset] = odd ? r_y << 4 : g_u << 4; 1331 buf[0][offset] = odd ? r_y_h << 4 : g_u_s << 4;
1224 buf[0][offset + 1] = odd ? r_y >> 4 : g_u >> 4; 1332 buf[0][offset + 1] = odd ? r_y_h >> 4 : g_u_s >> 4;
1225 buf[1][offset] = odd ? g_u << 4 : b_v << 4; 1333 buf[1][offset] = odd ? g_u_s << 4 : b_v << 4;
1226 buf[1][offset + 1] = odd ? g_u >> 4 : b_v >> 4; 1334 buf[1][offset + 1] = odd ? g_u_s >> 4 : b_v >> 4;
1227 buf[0][offset] |= (buf[0][offset] >> 4) & 0xf; 1335 buf[0][offset] |= (buf[0][offset] >> 4) & 0xf;
1228 buf[1][offset] |= (buf[1][offset] >> 4) & 0xf; 1336 buf[1][offset] |= (buf[1][offset] >> 4) & 0xf;
1229 break; 1337 break;
1230 case V4L2_PIX_FMT_SRGGB12: 1338 case V4L2_PIX_FMT_SRGGB12:
1231 buf[0][offset] = odd ? g_u << 4 : r_y << 4; 1339 buf[0][offset] = odd ? g_u_s << 4 : r_y_h << 4;
1232 buf[0][offset + 1] = odd ? g_u >> 4 : r_y >> 4; 1340 buf[0][offset + 1] = odd ? g_u_s >> 4 : r_y_h >> 4;
1233 buf[1][offset] = odd ? b_v << 4 : g_u << 4; 1341 buf[1][offset] = odd ? b_v << 4 : g_u_s << 4;
1234 buf[1][offset + 1] = odd ? b_v >> 4 : g_u >> 4; 1342 buf[1][offset + 1] = odd ? b_v >> 4 : g_u_s >> 4;
1235 buf[0][offset] |= (buf[0][offset] >> 4) & 0xf; 1343 buf[0][offset] |= (buf[0][offset] >> 4) & 0xf;
1236 buf[1][offset] |= (buf[1][offset] >> 4) & 0xf; 1344 buf[1][offset] |= (buf[1][offset] >> 4) & 0xf;
1237 break; 1345 break;
@@ -1828,6 +1936,7 @@ static void tpg_recalc(struct tpg_data *tpg)
1828 tpg->recalc_lines = true; 1936 tpg->recalc_lines = true;
1829 tpg->real_xfer_func = tpg->xfer_func; 1937 tpg->real_xfer_func = tpg->xfer_func;
1830 tpg->real_ycbcr_enc = tpg->ycbcr_enc; 1938 tpg->real_ycbcr_enc = tpg->ycbcr_enc;
1939 tpg->real_hsv_enc = tpg->hsv_enc;
1831 tpg->real_quantization = tpg->quantization; 1940 tpg->real_quantization = tpg->quantization;
1832 1941
1833 if (tpg->xfer_func == V4L2_XFER_FUNC_DEFAULT) 1942 if (tpg->xfer_func == V4L2_XFER_FUNC_DEFAULT)
@@ -1840,7 +1949,8 @@ static void tpg_recalc(struct tpg_data *tpg)
1840 1949
1841 if (tpg->quantization == V4L2_QUANTIZATION_DEFAULT) 1950 if (tpg->quantization == V4L2_QUANTIZATION_DEFAULT)
1842 tpg->real_quantization = 1951 tpg->real_quantization =
1843 V4L2_MAP_QUANTIZATION_DEFAULT(!tpg->is_yuv, 1952 V4L2_MAP_QUANTIZATION_DEFAULT(
1953 tpg->color_enc != TGP_COLOR_ENC_YCBCR,
1844 tpg->colorspace, tpg->real_ycbcr_enc); 1954 tpg->colorspace, tpg->real_ycbcr_enc);
1845 1955
1846 tpg_precalculate_colors(tpg); 1956 tpg_precalculate_colors(tpg);
@@ -1887,11 +1997,28 @@ static int tpg_pattern_avg(const struct tpg_data *tpg,
1887 return -1; 1997 return -1;
1888} 1998}
1889 1999
2000static const char *tpg_color_enc_str(enum tgp_color_enc
2001 color_enc)
2002{
2003 switch (color_enc) {
2004 case TGP_COLOR_ENC_HSV:
2005 return "HSV";
2006 case TGP_COLOR_ENC_YCBCR:
2007 return "Y'CbCr";
2008 case TGP_COLOR_ENC_LUMA:
2009 return "Luma";
2010 case TGP_COLOR_ENC_RGB:
2011 default:
2012 return "R'G'B";
2013
2014 }
2015}
2016
1890void tpg_log_status(struct tpg_data *tpg) 2017void tpg_log_status(struct tpg_data *tpg)
1891{ 2018{
1892 pr_info("tpg source WxH: %ux%u (%s)\n", 2019 pr_info("tpg source WxH: %ux%u (%s)\n",
1893 tpg->src_width, tpg->src_height, 2020 tpg->src_width, tpg->src_height,
1894 tpg->is_yuv ? "YCbCr" : "RGB"); 2021 tpg_color_enc_str(tpg->color_enc));
1895 pr_info("tpg field: %u\n", tpg->field); 2022 pr_info("tpg field: %u\n", tpg->field);
1896 pr_info("tpg crop: %ux%u@%dx%d\n", tpg->crop.width, tpg->crop.height, 2023 pr_info("tpg crop: %ux%u@%dx%d\n", tpg->crop.width, tpg->crop.height,
1897 tpg->crop.left, tpg->crop.top); 2024 tpg->crop.left, tpg->crop.top);
@@ -1900,6 +2027,7 @@ void tpg_log_status(struct tpg_data *tpg)
1900 pr_info("tpg colorspace: %d\n", tpg->colorspace); 2027 pr_info("tpg colorspace: %d\n", tpg->colorspace);
1901 pr_info("tpg transfer function: %d/%d\n", tpg->xfer_func, tpg->real_xfer_func); 2028 pr_info("tpg transfer function: %d/%d\n", tpg->xfer_func, tpg->real_xfer_func);
1902 pr_info("tpg Y'CbCr encoding: %d/%d\n", tpg->ycbcr_enc, tpg->real_ycbcr_enc); 2029 pr_info("tpg Y'CbCr encoding: %d/%d\n", tpg->ycbcr_enc, tpg->real_ycbcr_enc);
2030 pr_info("tpg HSV encoding: %d/%d\n", tpg->hsv_enc, tpg->real_hsv_enc);
1903 pr_info("tpg quantization: %d/%d\n", tpg->quantization, tpg->real_quantization); 2031 pr_info("tpg quantization: %d/%d\n", tpg->quantization, tpg->real_quantization);
1904 pr_info("tpg RGB range: %d/%d\n", tpg->rgb_range, tpg->real_rgb_range); 2032 pr_info("tpg RGB range: %d/%d\n", tpg->rgb_range, tpg->real_rgb_range);
1905} 2033}
diff --git a/drivers/media/dvb-core/Kconfig b/drivers/media/dvb-core/Kconfig
index fa7a2490ed5f..eeef94a0c84e 100644
--- a/drivers/media/dvb-core/Kconfig
+++ b/drivers/media/dvb-core/Kconfig
@@ -5,7 +5,7 @@
5config DVB_MAX_ADAPTERS 5config DVB_MAX_ADAPTERS
6 int "maximum number of DVB/ATSC adapters" 6 int "maximum number of DVB/ATSC adapters"
7 depends on DVB_CORE 7 depends on DVB_CORE
8 default 8 8 default 16
9 range 1 255 9 range 1 255
10 help 10 help
11 Maximum number of DVB/ATSC adapters. Increasing this number 11 Maximum number of DVB/ATSC adapters. Increasing this number
@@ -13,7 +13,7 @@ config DVB_MAX_ADAPTERS
13 if a much lower number of DVB/ATSC adapters is present. 13 if a much lower number of DVB/ATSC adapters is present.
14 Only values in the range 4-32 are tested. 14 Only values in the range 4-32 are tested.
15 15
16 If you are unsure about this, use the default value 8 16 If you are unsure about this, use the default value 16
17 17
18config DVB_DYNAMIC_MINORS 18config DVB_DYNAMIC_MINORS
19 bool "Dynamic DVB minor allocation" 19 bool "Dynamic DVB minor allocation"
@@ -27,3 +27,16 @@ config DVB_DYNAMIC_MINORS
27 will be required to manage the device nodes. 27 will be required to manage the device nodes.
28 28
29 If you are unsure about this, say N here. 29 If you are unsure about this, say N here.
30
31config DVB_DEMUX_SECTION_LOSS_LOG
32 bool "Enable DVB demux section packet loss log"
33 depends on DVB_CORE
34 default n
35 help
36 Enable extra log messages meant to detect packet loss
37 inside the Kernel.
38
39 Should not be enabled on normal cases, as logs can
40 be very verbose.
41
42 If you are unsure about this, say N here.
diff --git a/drivers/media/dvb-core/Makefile b/drivers/media/dvb-core/Makefile
index 8f22bcd7c1f9..281bc89576e6 100644
--- a/drivers/media/dvb-core/Makefile
+++ b/drivers/media/dvb-core/Makefile
@@ -4,7 +4,7 @@
4 4
5dvb-net-$(CONFIG_DVB_NET) := dvb_net.o 5dvb-net-$(CONFIG_DVB_NET) := dvb_net.o
6 6
7dvb-core-objs := dvbdev.o dmxdev.o dvb_demux.o dvb_filter.o \ 7dvb-core-objs := dvbdev.o dmxdev.o dvb_demux.o \
8 dvb_ca_en50221.o dvb_frontend.o \ 8 dvb_ca_en50221.o dvb_frontend.o \
9 $(dvb-net-y) dvb_ringbuffer.o dvb_math.o 9 $(dvb-net-y) dvb_ringbuffer.o dvb_math.o
10 10
diff --git a/drivers/media/dvb-core/demux.h b/drivers/media/dvb-core/demux.h
index aeda2b64931c..f8adf4506a45 100644
--- a/drivers/media/dvb-core/demux.h
+++ b/drivers/media/dvb-core/demux.h
@@ -103,7 +103,6 @@ struct dmx_ts_feed {
103 u16 pid, 103 u16 pid,
104 int type, 104 int type,
105 enum dmx_ts_pes pes_type, 105 enum dmx_ts_pes pes_type,
106 size_t circular_buffer_size,
107 ktime_t timeout); 106 ktime_t timeout);
108 int (*start_filtering)(struct dmx_ts_feed *feed); 107 int (*start_filtering)(struct dmx_ts_feed *feed);
109 int (*stop_filtering)(struct dmx_ts_feed *feed); 108 int (*stop_filtering)(struct dmx_ts_feed *feed);
@@ -181,7 +180,6 @@ struct dmx_section_feed {
181 /* public: */ 180 /* public: */
182 int (*set)(struct dmx_section_feed *feed, 181 int (*set)(struct dmx_section_feed *feed,
183 u16 pid, 182 u16 pid,
184 size_t circular_buffer_size,
185 int check_crc); 183 int check_crc);
186 int (*allocate_filter)(struct dmx_section_feed *feed, 184 int (*allocate_filter)(struct dmx_section_feed *feed,
187 struct dmx_section_filter **filter); 185 struct dmx_section_filter **filter);
@@ -206,8 +204,7 @@ struct dmx_section_feed {
206 * the &dmx_demux. 204 * the &dmx_demux.
207 * Any TS packets that match the filter settings are copied to a circular 205 * Any TS packets that match the filter settings are copied to a circular
208 * buffer. The filtered TS packets are delivered to the client using this 206 * buffer. The filtered TS packets are delivered to the client using this
209 * callback function. The size of the circular buffer is controlled by the 207 * callback function.
210 * circular_buffer_size parameter of the &dmx_ts_feed.@set function.
211 * It is expected that the @buffer1 and @buffer2 callback parameters point to 208 * It is expected that the @buffer1 and @buffer2 callback parameters point to
212 * addresses within the circular buffer, but other implementations are also 209 * addresses within the circular buffer, but other implementations are also
213 * possible. Note that the called party should not try to free the memory 210 * possible. Note that the called party should not try to free the memory
diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c
index 7b67e1dd97fd..efe55a3e80d0 100644
--- a/drivers/media/dvb-core/dmxdev.c
+++ b/drivers/media/dvb-core/dmxdev.c
@@ -20,6 +20,8 @@
20 * 20 *
21 */ 21 */
22 22
23#define pr_fmt(fmt) "dmxdev: " fmt
24
23#include <linux/sched.h> 25#include <linux/sched.h>
24#include <linux/spinlock.h> 26#include <linux/spinlock.h>
25#include <linux/slab.h> 27#include <linux/slab.h>
@@ -36,7 +38,11 @@ static int debug;
36module_param(debug, int, 0644); 38module_param(debug, int, 0644);
37MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); 39MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
38 40
39#define dprintk if (debug) printk 41#define dprintk(fmt, arg...) do { \
42 if (debug) \
43 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
44 __func__, ##arg); \
45} while (0)
40 46
41static int dvb_dmxdev_buffer_write(struct dvb_ringbuffer *buf, 47static int dvb_dmxdev_buffer_write(struct dvb_ringbuffer *buf,
42 const u8 *src, size_t len) 48 const u8 *src, size_t len)
@@ -50,7 +56,7 @@ static int dvb_dmxdev_buffer_write(struct dvb_ringbuffer *buf,
50 56
51 free = dvb_ringbuffer_free(buf); 57 free = dvb_ringbuffer_free(buf);
52 if (len > free) { 58 if (len > free) {
53 dprintk("dmxdev: buffer overflow\n"); 59 dprintk("buffer overflow\n");
54 return -EOVERFLOW; 60 return -EOVERFLOW;
55 } 61 }
56 62
@@ -126,7 +132,7 @@ static int dvb_dvr_open(struct inode *inode, struct file *file)
126 struct dmxdev *dmxdev = dvbdev->priv; 132 struct dmxdev *dmxdev = dvbdev->priv;
127 struct dmx_frontend *front; 133 struct dmx_frontend *front;
128 134
129 dprintk("function : %s\n", __func__); 135 dprintk("%s\n", __func__);
130 136
131 if (mutex_lock_interruptible(&dmxdev->mutex)) 137 if (mutex_lock_interruptible(&dmxdev->mutex))
132 return -ERESTARTSYS; 138 return -ERESTARTSYS;
@@ -258,7 +264,7 @@ static int dvb_dvr_set_buffer_size(struct dmxdev *dmxdev,
258 void *newmem; 264 void *newmem;
259 void *oldmem; 265 void *oldmem;
260 266
261 dprintk("function : %s\n", __func__); 267 dprintk("%s\n", __func__);
262 268
263 if (buf->size == size) 269 if (buf->size == size)
264 return 0; 270 return 0;
@@ -367,7 +373,7 @@ static int dvb_dmxdev_section_callback(const u8 *buffer1, size_t buffer1_len,
367 return 0; 373 return 0;
368 } 374 }
369 del_timer(&dmxdevfilter->timer); 375 del_timer(&dmxdevfilter->timer);
370 dprintk("dmxdev: section callback %*ph\n", 6, buffer1); 376 dprintk("section callback %*ph\n", 6, buffer1);
371 ret = dvb_dmxdev_buffer_write(&dmxdevfilter->buffer, buffer1, 377 ret = dvb_dmxdev_buffer_write(&dmxdevfilter->buffer, buffer1,
372 buffer1_len); 378 buffer1_len);
373 if (ret == buffer1_len) { 379 if (ret == buffer1_len) {
@@ -589,7 +595,7 @@ static int dvb_dmxdev_start_feed(struct dmxdev *dmxdev,
589 tsfeed = feed->ts; 595 tsfeed = feed->ts;
590 tsfeed->priv = filter; 596 tsfeed->priv = filter;
591 597
592 ret = tsfeed->set(tsfeed, feed->pid, ts_type, ts_pes, 32768, timeout); 598 ret = tsfeed->set(tsfeed, feed->pid, ts_type, ts_pes, timeout);
593 if (ret < 0) { 599 if (ret < 0) {
594 dmxdev->demux->release_ts_feed(dmxdev->demux, tsfeed); 600 dmxdev->demux->release_ts_feed(dmxdev->demux, tsfeed);
595 return ret; 601 return ret;
@@ -655,15 +661,15 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter)
655 secfeed, 661 secfeed,
656 dvb_dmxdev_section_callback); 662 dvb_dmxdev_section_callback);
657 if (ret < 0) { 663 if (ret < 0) {
658 printk("DVB (%s): could not alloc feed\n", 664 pr_err("DVB (%s): could not alloc feed\n",
659 __func__); 665 __func__);
660 return ret; 666 return ret;
661 } 667 }
662 668
663 ret = (*secfeed)->set(*secfeed, para->pid, 32768, 669 ret = (*secfeed)->set(*secfeed, para->pid,
664 (para->flags & DMX_CHECK_CRC) ? 1 : 0); 670 (para->flags & DMX_CHECK_CRC) ? 1 : 0);
665 if (ret < 0) { 671 if (ret < 0) {
666 printk("DVB (%s): could not set feed\n", 672 pr_err("DVB (%s): could not set feed\n",
667 __func__); 673 __func__);
668 dvb_dmxdev_feed_restart(filter); 674 dvb_dmxdev_feed_restart(filter);
669 return ret; 675 return ret;
@@ -844,7 +850,7 @@ static int dvb_dmxdev_filter_set(struct dmxdev *dmxdev,
844 struct dmxdev_filter *dmxdevfilter, 850 struct dmxdev_filter *dmxdevfilter,
845 struct dmx_sct_filter_params *params) 851 struct dmx_sct_filter_params *params)
846{ 852{
847 dprintk("function : %s, PID=0x%04x, flags=%02x, timeout=%d\n", 853 dprintk("%s: PID=0x%04x, flags=%02x, timeout=%d\n",
848 __func__, params->pid, params->flags, params->timeout); 854 __func__, params->pid, params->flags, params->timeout);
849 855
850 dvb_dmxdev_filter_stop(dmxdevfilter); 856 dvb_dmxdev_filter_stop(dmxdevfilter);
@@ -1184,7 +1190,7 @@ static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait)
1184 struct dmxdev *dmxdev = dvbdev->priv; 1190 struct dmxdev *dmxdev = dvbdev->priv;
1185 unsigned int mask = 0; 1191 unsigned int mask = 0;
1186 1192
1187 dprintk("function : %s\n", __func__); 1193 dprintk("%s\n", __func__);
1188 1194
1189 if (dmxdev->exit) 1195 if (dmxdev->exit)
1190 return POLLERR; 1196 return POLLERR;
diff --git a/drivers/media/dvb-core/dvb-usb-ids.h b/drivers/media/dvb-core/dvb-usb-ids.h
index a7a4674ccc40..779f4224b63e 100644
--- a/drivers/media/dvb-core/dvb-usb-ids.h
+++ b/drivers/media/dvb-core/dvb-usb-ids.h
@@ -262,6 +262,7 @@
262#define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI 0x3012 262#define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI 0x3012
263#define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI_2 0x3015 263#define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI_2 0x3015
264#define USB_PID_TECHNOTREND_TVSTICK_CT2_4400 0x3014 264#define USB_PID_TECHNOTREND_TVSTICK_CT2_4400 0x3014
265#define USB_PID_TECHNOTREND_CONNECT_S2_4650_CI 0x3017
265#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a 266#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a
266#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081 267#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081
267#define USB_PID_TERRATEC_CINERGY_HT_USB_XE 0x0058 268#define USB_PID_TERRATEC_CINERGY_HT_USB_XE 0x0058
@@ -411,4 +412,5 @@
411#define USB_PID_SVEON_STV27 0xd3af 412#define USB_PID_SVEON_STV27 0xd3af
412#define USB_PID_TURBOX_DTT_2000 0xd3a4 413#define USB_PID_TURBOX_DTT_2000 0xd3a4
413#define USB_PID_WINTV_SOLOHD 0x0264 414#define USB_PID_WINTV_SOLOHD 0x0264
415#define USB_PID_EVOLVEO_XTRATV_STICK 0xa115
414#endif 416#endif
diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index b5b5b195ea7f..fd893141211c 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -28,6 +28,8 @@
28 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 28 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
29 */ 29 */
30 30
31#define pr_fmt(fmt) "dvb_ca_en50221: " fmt
32
31#include <linux/errno.h> 33#include <linux/errno.h>
32#include <linux/slab.h> 34#include <linux/slab.h>
33#include <linux/list.h> 35#include <linux/list.h>
@@ -46,7 +48,10 @@ static int dvb_ca_en50221_debug;
46module_param_named(cam_debug, dvb_ca_en50221_debug, int, 0644); 48module_param_named(cam_debug, dvb_ca_en50221_debug, int, 0644);
47MODULE_PARM_DESC(cam_debug, "enable verbose debug messages"); 49MODULE_PARM_DESC(cam_debug, "enable verbose debug messages");
48 50
49#define dprintk if (dvb_ca_en50221_debug) printk 51#define dprintk(fmt, arg...) do { \
52 if (dvb_ca_en50221_debug) \
53 printk(KERN_DEBUG pr_fmt("%s: " fmt), __func__, ##arg);\
54} while (0)
50 55
51#define INIT_TIMEOUT_SECS 10 56#define INIT_TIMEOUT_SECS 10
52 57
@@ -166,7 +171,7 @@ static void dvb_ca_private_free(struct dvb_ca_private *ca)
166{ 171{
167 unsigned int i; 172 unsigned int i;
168 173
169 dvb_unregister_device(ca->dvbdev); 174 dvb_free_device(ca->dvbdev);
170 for (i = 0; i < ca->slot_count; i++) 175 for (i = 0; i < ca->slot_count; i++)
171 vfree(ca->slot_info[i].rx_buffer.data); 176 vfree(ca->slot_info[i].rx_buffer.data);
172 177
@@ -298,7 +303,8 @@ static int dvb_ca_en50221_wait_if_status(struct dvb_ca_private *ca, int slot,
298 303
299 /* if we got the flags, it was successful! */ 304 /* if we got the flags, it was successful! */
300 if (res & waitfor) { 305 if (res & waitfor) {
301 dprintk("%s succeeded timeout:%lu\n", __func__, jiffies - start); 306 dprintk("%s succeeded timeout:%lu\n",
307 __func__, jiffies - start);
302 return 0; 308 return 0;
303 } 309 }
304 310
@@ -519,8 +525,9 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
519 525
520 /* is it a version we support? */ 526 /* is it a version we support? */
521 if (strncmp(dvb_str + 8, "1.00", 4)) { 527 if (strncmp(dvb_str + 8, "1.00", 4)) {
522 printk("dvb_ca adapter %d: Unsupported DVB CAM module version %c%c%c%c\n", 528 pr_err("dvb_ca adapter %d: Unsupported DVB CAM module version %c%c%c%c\n",
523 ca->dvbdev->adapter->num, dvb_str[8], dvb_str[9], dvb_str[10], dvb_str[11]); 529 ca->dvbdev->adapter->num, dvb_str[8], dvb_str[9],
530 dvb_str[10], dvb_str[11]);
524 return -EINVAL; 531 return -EINVAL;
525 } 532 }
526 533
@@ -557,8 +564,8 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
557 break; 564 break;
558 565
559 default: /* Unknown tuple type - just skip this tuple and move to the next one */ 566 default: /* Unknown tuple type - just skip this tuple and move to the next one */
560 dprintk("dvb_ca: Skipping unknown tuple type:0x%x length:0x%x\n", tupleType, 567 dprintk("dvb_ca: Skipping unknown tuple type:0x%x length:0x%x\n",
561 tupleLength); 568 tupleType, tupleLength);
562 break; 569 break;
563 } 570 }
564 } 571 }
@@ -567,7 +574,8 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
567 return -EINVAL; 574 return -EINVAL;
568 575
569 dprintk("Valid DVB CAM detected MANID:%x DEVID:%x CONFIGBASE:0x%x CONFIGOPTION:0x%x\n", 576 dprintk("Valid DVB CAM detected MANID:%x DEVID:%x CONFIGBASE:0x%x CONFIGOPTION:0x%x\n",
570 manfid, devid, ca->slot_info[slot].config_base, ca->slot_info[slot].config_option); 577 manfid, devid, ca->slot_info[slot].config_base,
578 ca->slot_info[slot].config_option);
571 579
572 // success! 580 // success!
573 return 0; 581 return 0;
@@ -661,14 +669,15 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
661 /* check it will fit */ 669 /* check it will fit */
662 if (ebuf == NULL) { 670 if (ebuf == NULL) {
663 if (bytes_read > ca->slot_info[slot].link_buf_size) { 671 if (bytes_read > ca->slot_info[slot].link_buf_size) {
664 printk("dvb_ca adapter %d: CAM tried to send a buffer larger than the link buffer size (%i > %i)!\n", 672 pr_err("dvb_ca adapter %d: CAM tried to send a buffer larger than the link buffer size (%i > %i)!\n",
665 ca->dvbdev->adapter->num, bytes_read, ca->slot_info[slot].link_buf_size); 673 ca->dvbdev->adapter->num, bytes_read,
674 ca->slot_info[slot].link_buf_size);
666 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT; 675 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
667 status = -EIO; 676 status = -EIO;
668 goto exit; 677 goto exit;
669 } 678 }
670 if (bytes_read < 2) { 679 if (bytes_read < 2) {
671 printk("dvb_ca adapter %d: CAM sent a buffer that was less than 2 bytes!\n", 680 pr_err("dvb_ca adapter %d: CAM sent a buffer that was less than 2 bytes!\n",
672 ca->dvbdev->adapter->num); 681 ca->dvbdev->adapter->num);
673 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT; 682 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
674 status = -EIO; 683 status = -EIO;
@@ -676,7 +685,7 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
676 } 685 }
677 } else { 686 } else {
678 if (bytes_read > ecount) { 687 if (bytes_read > ecount) {
679 printk("dvb_ca adapter %d: CAM tried to send a buffer larger than the ecount size!\n", 688 pr_err("dvb_ca adapter %d: CAM tried to send a buffer larger than the ecount size!\n",
680 ca->dvbdev->adapter->num); 689 ca->dvbdev->adapter->num);
681 status = -EIO; 690 status = -EIO;
682 goto exit; 691 goto exit;
@@ -1062,7 +1071,7 @@ static int dvb_ca_en50221_thread(void *data)
1062 1071
1063 case DVB_CA_SLOTSTATE_WAITREADY: 1072 case DVB_CA_SLOTSTATE_WAITREADY:
1064 if (time_after(jiffies, ca->slot_info[slot].timeout)) { 1073 if (time_after(jiffies, ca->slot_info[slot].timeout)) {
1065 printk("dvb_ca adaptor %d: PC card did not respond :(\n", 1074 pr_err("dvb_ca adaptor %d: PC card did not respond :(\n",
1066 ca->dvbdev->adapter->num); 1075 ca->dvbdev->adapter->num);
1067 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID; 1076 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
1068 dvb_ca_en50221_thread_update_delay(ca); 1077 dvb_ca_en50221_thread_update_delay(ca);
@@ -1084,14 +1093,14 @@ static int dvb_ca_en50221_thread(void *data)
1084 } 1093 }
1085 } 1094 }
1086 1095
1087 printk("dvb_ca adapter %d: Invalid PC card inserted :(\n", 1096 pr_err("dvb_ca adapter %d: Invalid PC card inserted :(\n",
1088 ca->dvbdev->adapter->num); 1097 ca->dvbdev->adapter->num);
1089 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID; 1098 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
1090 dvb_ca_en50221_thread_update_delay(ca); 1099 dvb_ca_en50221_thread_update_delay(ca);
1091 break; 1100 break;
1092 } 1101 }
1093 if (dvb_ca_en50221_set_configoption(ca, slot) != 0) { 1102 if (dvb_ca_en50221_set_configoption(ca, slot) != 0) {
1094 printk("dvb_ca adapter %d: Unable to initialise CAM :(\n", 1103 pr_err("dvb_ca adapter %d: Unable to initialise CAM :(\n",
1095 ca->dvbdev->adapter->num); 1104 ca->dvbdev->adapter->num);
1096 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID; 1105 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
1097 dvb_ca_en50221_thread_update_delay(ca); 1106 dvb_ca_en50221_thread_update_delay(ca);
@@ -1099,7 +1108,7 @@ static int dvb_ca_en50221_thread(void *data)
1099 } 1108 }
1100 if (ca->pub->write_cam_control(ca->pub, slot, 1109 if (ca->pub->write_cam_control(ca->pub, slot,
1101 CTRLIF_COMMAND, CMDREG_RS) != 0) { 1110 CTRLIF_COMMAND, CMDREG_RS) != 0) {
1102 printk("dvb_ca adapter %d: Unable to reset CAM IF\n", 1111 pr_err("dvb_ca adapter %d: Unable to reset CAM IF\n",
1103 ca->dvbdev->adapter->num); 1112 ca->dvbdev->adapter->num);
1104 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID; 1113 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
1105 dvb_ca_en50221_thread_update_delay(ca); 1114 dvb_ca_en50221_thread_update_delay(ca);
@@ -1114,7 +1123,7 @@ static int dvb_ca_en50221_thread(void *data)
1114 1123
1115 case DVB_CA_SLOTSTATE_WAITFR: 1124 case DVB_CA_SLOTSTATE_WAITFR:
1116 if (time_after(jiffies, ca->slot_info[slot].timeout)) { 1125 if (time_after(jiffies, ca->slot_info[slot].timeout)) {
1117 printk("dvb_ca adapter %d: DVB CAM did not respond :(\n", 1126 pr_err("dvb_ca adapter %d: DVB CAM did not respond :(\n",
1118 ca->dvbdev->adapter->num); 1127 ca->dvbdev->adapter->num);
1119 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID; 1128 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
1120 dvb_ca_en50221_thread_update_delay(ca); 1129 dvb_ca_en50221_thread_update_delay(ca);
@@ -1141,7 +1150,8 @@ static int dvb_ca_en50221_thread(void *data)
1141 } 1150 }
1142 } 1151 }
1143 1152
1144 printk("dvb_ca adapter %d: DVB CAM link initialisation failed :(\n", ca->dvbdev->adapter->num); 1153 pr_err("dvb_ca adapter %d: DVB CAM link initialisation failed :(\n",
1154 ca->dvbdev->adapter->num);
1145 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID; 1155 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
1146 dvb_ca_en50221_thread_update_delay(ca); 1156 dvb_ca_en50221_thread_update_delay(ca);
1147 break; 1157 break;
@@ -1150,7 +1160,8 @@ static int dvb_ca_en50221_thread(void *data)
1150 if (ca->slot_info[slot].rx_buffer.data == NULL) { 1160 if (ca->slot_info[slot].rx_buffer.data == NULL) {
1151 rxbuf = vmalloc(RX_BUFFER_SIZE); 1161 rxbuf = vmalloc(RX_BUFFER_SIZE);
1152 if (rxbuf == NULL) { 1162 if (rxbuf == NULL) {
1153 printk("dvb_ca adapter %d: Unable to allocate CAM rx buffer :(\n", ca->dvbdev->adapter->num); 1163 pr_err("dvb_ca adapter %d: Unable to allocate CAM rx buffer :(\n",
1164 ca->dvbdev->adapter->num);
1154 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID; 1165 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
1155 dvb_ca_en50221_thread_update_delay(ca); 1166 dvb_ca_en50221_thread_update_delay(ca);
1156 break; 1167 break;
@@ -1161,7 +1172,8 @@ static int dvb_ca_en50221_thread(void *data)
1161 ca->pub->slot_ts_enable(ca->pub, slot); 1172 ca->pub->slot_ts_enable(ca->pub, slot);
1162 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_RUNNING; 1173 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_RUNNING;
1163 dvb_ca_en50221_thread_update_delay(ca); 1174 dvb_ca_en50221_thread_update_delay(ca);
1164 printk("dvb_ca adapter %d: DVB CAM detected and initialised successfully\n", ca->dvbdev->adapter->num); 1175 pr_err("dvb_ca adapter %d: DVB CAM detected and initialised successfully\n",
1176 ca->dvbdev->adapter->num);
1165 break; 1177 break;
1166 1178
1167 case DVB_CA_SLOTSTATE_RUNNING: 1179 case DVB_CA_SLOTSTATE_RUNNING:
@@ -1497,7 +1509,8 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user * buf,
1497 pktlen = 2; 1509 pktlen = 2;
1498 do { 1510 do {
1499 if (idx == -1) { 1511 if (idx == -1) {
1500 printk("dvb_ca adapter %d: BUG: read packet ended before last_fragment encountered\n", ca->dvbdev->adapter->num); 1512 pr_err("dvb_ca adapter %d: BUG: read packet ended before last_fragment encountered\n",
1513 ca->dvbdev->adapter->num);
1501 status = -EIO; 1514 status = -EIO;
1502 goto exit; 1515 goto exit;
1503 } 1516 }
@@ -1755,8 +1768,8 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
1755 ca->dvbdev->adapter->num, ca->dvbdev->id); 1768 ca->dvbdev->adapter->num, ca->dvbdev->id);
1756 if (IS_ERR(ca->thread)) { 1769 if (IS_ERR(ca->thread)) {
1757 ret = PTR_ERR(ca->thread); 1770 ret = PTR_ERR(ca->thread);
1758 printk("dvb_ca_init: failed to start kernel_thread (%d)\n", 1771 pr_err("dvb_ca_init: failed to start kernel_thread (%d)\n",
1759 ret); 1772 ret);
1760 goto unregister_device; 1773 goto unregister_device;
1761 } 1774 }
1762 return 0; 1775 return 0;
@@ -1794,6 +1807,7 @@ void dvb_ca_en50221_release(struct dvb_ca_en50221 *pubca)
1794 for (i = 0; i < ca->slot_count; i++) { 1807 for (i = 0; i < ca->slot_count; i++) {
1795 dvb_ca_en50221_slot_shutdown(ca, i); 1808 dvb_ca_en50221_slot_shutdown(ca, i);
1796 } 1809 }
1810 dvb_remove_device(ca->dvbdev);
1797 dvb_ca_private_put(ca); 1811 dvb_ca_private_put(ca);
1798 pubca->private = NULL; 1812 pubca->private = NULL;
1799} 1813}
diff --git a/drivers/media/dvb-core/dvb_demux.c b/drivers/media/dvb-core/dvb_demux.c
index a0cf7b0d03e8..3ad0b2cd26b1 100644
--- a/drivers/media/dvb-core/dvb_demux.c
+++ b/drivers/media/dvb-core/dvb_demux.c
@@ -21,6 +21,8 @@
21 * 21 *
22 */ 22 */
23 23
24#define pr_fmt(fmt) "dvb_demux: " fmt
25
24#include <linux/sched.h> 26#include <linux/sched.h>
25#include <linux/spinlock.h> 27#include <linux/spinlock.h>
26#include <linux/slab.h> 28#include <linux/slab.h>
@@ -34,12 +36,6 @@
34 36
35#include "dvb_demux.h" 37#include "dvb_demux.h"
36 38
37#define NOBUFS
38/*
39** #define DVB_DEMUX_SECTION_LOSS_LOG to monitor payload loss in the syslog
40*/
41// #define DVB_DEMUX_SECTION_LOSS_LOG
42
43static int dvb_demux_tscheck; 39static int dvb_demux_tscheck;
44module_param(dvb_demux_tscheck, int, 0644); 40module_param(dvb_demux_tscheck, int, 0644);
45MODULE_PARM_DESC(dvb_demux_tscheck, 41MODULE_PARM_DESC(dvb_demux_tscheck,
@@ -55,10 +51,13 @@ module_param(dvb_demux_feed_err_pkts, int, 0644);
55MODULE_PARM_DESC(dvb_demux_feed_err_pkts, 51MODULE_PARM_DESC(dvb_demux_feed_err_pkts,
56 "when set to 0, drop packets with the TEI bit set (1 by default)"); 52 "when set to 0, drop packets with the TEI bit set (1 by default)");
57 53
58#define dprintk_tscheck(x...) do { \ 54#define dprintk(fmt, arg...) \
59 if (dvb_demux_tscheck && printk_ratelimit()) \ 55 printk(KERN_DEBUG pr_fmt("%s: " fmt), __func__, ##arg)
60 printk(x); \ 56
61 } while (0) 57#define dprintk_tscheck(x...) do { \
58 if (dvb_demux_tscheck && printk_ratelimit()) \
59 dprintk(x); \
60} while (0)
62 61
63/****************************************************************************** 62/******************************************************************************
64 * static inlined helper functions 63 * static inlined helper functions
@@ -109,21 +108,23 @@ static inline int dvb_dmx_swfilter_payload(struct dvb_demux_feed *feed,
109{ 108{
110 int count = payload(buf); 109 int count = payload(buf);
111 int p; 110 int p;
112 //int ccok; 111#ifdef CONFIG_DVB_DEMUX_SECTION_LOSS_LOG
113 //u8 cc; 112 int ccok;
113 u8 cc;
114#endif
114 115
115 if (count == 0) 116 if (count == 0)
116 return -1; 117 return -1;
117 118
118 p = 188 - count; 119 p = 188 - count;
119 120
120 /* 121#ifdef CONFIG_DVB_DEMUX_SECTION_LOSS_LOG
121 cc = buf[3] & 0x0f; 122 cc = buf[3] & 0x0f;
122 ccok = ((feed->cc + 1) & 0x0f) == cc; 123 ccok = ((feed->cc + 1) & 0x0f) == cc;
123 feed->cc = cc; 124 feed->cc = cc;
124 if (!ccok) 125 if (!ccok)
125 printk("missed packet!\n"); 126 dprintk("missed packet!\n");
126 */ 127#endif
127 128
128 if (buf[1] & 0x40) // PUSI ? 129 if (buf[1] & 0x40) // PUSI ?
129 feed->peslen = 0xfffa; 130 feed->peslen = 0xfffa;
@@ -189,7 +190,7 @@ static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed)
189{ 190{
190 struct dmx_section_feed *sec = &feed->feed.sec; 191 struct dmx_section_feed *sec = &feed->feed.sec;
191 192
192#ifdef DVB_DEMUX_SECTION_LOSS_LOG 193#ifdef CONFIG_DVB_DEMUX_SECTION_LOSS_LOG
193 if (sec->secbufp < sec->tsfeedp) { 194 if (sec->secbufp < sec->tsfeedp) {
194 int i, n = sec->tsfeedp - sec->secbufp; 195 int i, n = sec->tsfeedp - sec->secbufp;
195 196
@@ -199,12 +200,12 @@ static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed)
199 * but just first and last. 200 * but just first and last.
200 */ 201 */
201 if (sec->secbuf[0] != 0xff || sec->secbuf[n - 1] != 0xff) { 202 if (sec->secbuf[0] != 0xff || sec->secbuf[n - 1] != 0xff) {
202 printk("dvb_demux.c section ts padding loss: %d/%d\n", 203 dprintk("dvb_demux.c section ts padding loss: %d/%d\n",
203 n, sec->tsfeedp); 204 n, sec->tsfeedp);
204 printk("dvb_demux.c pad data:"); 205 dprintk("dvb_demux.c pad data:");
205 for (i = 0; i < n; i++) 206 for (i = 0; i < n; i++)
206 printk(" %02x", sec->secbuf[i]); 207 pr_cont(" %02x", sec->secbuf[i]);
207 printk("\n"); 208 pr_cont("\n");
208 } 209 }
209 } 210 }
210#endif 211#endif
@@ -242,8 +243,8 @@ static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed,
242 return 0; 243 return 0;
243 244
244 if (sec->tsfeedp + len > DMX_MAX_SECFEED_SIZE) { 245 if (sec->tsfeedp + len > DMX_MAX_SECFEED_SIZE) {
245#ifdef DVB_DEMUX_SECTION_LOSS_LOG 246#ifdef CONFIG_DVB_DEMUX_SECTION_LOSS_LOG
246 printk("dvb_demux.c section buffer full loss: %d/%d\n", 247 dprintk("dvb_demux.c section buffer full loss: %d/%d\n",
247 sec->tsfeedp + len - DMX_MAX_SECFEED_SIZE, 248 sec->tsfeedp + len - DMX_MAX_SECFEED_SIZE,
248 DMX_MAX_SECFEED_SIZE); 249 DMX_MAX_SECFEED_SIZE);
249#endif 250#endif
@@ -276,9 +277,9 @@ static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed,
276 /* dump [secbuf .. secbuf+seclen) */ 277 /* dump [secbuf .. secbuf+seclen) */
277 if (feed->pusi_seen) 278 if (feed->pusi_seen)
278 dvb_dmx_swfilter_section_feed(feed); 279 dvb_dmx_swfilter_section_feed(feed);
279#ifdef DVB_DEMUX_SECTION_LOSS_LOG 280#ifdef CONFIG_DVB_DEMUX_SECTION_LOSS_LOG
280 else 281 else
281 printk("dvb_demux.c pusi not seen, discarding section data\n"); 282 dprintk("dvb_demux.c pusi not seen, discarding section data\n");
282#endif 283#endif
283 sec->secbufp += seclen; /* secbufp and secbuf moving together is */ 284 sec->secbufp += seclen; /* secbufp and secbuf moving together is */
284 sec->secbuf += seclen; /* redundant but saves pointer arithmetic */ 285 sec->secbuf += seclen; /* redundant but saves pointer arithmetic */
@@ -312,9 +313,9 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed,
312 } 313 }
313 314
314 if (!ccok || dc_i) { 315 if (!ccok || dc_i) {
315#ifdef DVB_DEMUX_SECTION_LOSS_LOG 316#ifdef CONFIG_DVB_DEMUX_SECTION_LOSS_LOG
316 printk("dvb_demux.c discontinuity detected %d bytes lost\n", 317 dprintk("dvb_demux.c discontinuity detected %d bytes lost\n",
317 count); 318 count);
318 /* 319 /*
319 * those bytes under sume circumstances will again be reported 320 * those bytes under sume circumstances will again be reported
320 * in the following dvb_dmx_swfilter_section_new 321 * in the following dvb_dmx_swfilter_section_new
@@ -344,9 +345,10 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed,
344 dvb_dmx_swfilter_section_copy_dump(feed, after, 345 dvb_dmx_swfilter_section_copy_dump(feed, after,
345 after_len); 346 after_len);
346 } 347 }
347#ifdef DVB_DEMUX_SECTION_LOSS_LOG 348#ifdef CONFIG_DVB_DEMUX_SECTION_LOSS_LOG
348 else if (count > 0) 349 else if (count > 0)
349 printk("dvb_demux.c PUSI=1 but %d bytes lost\n", count); 350 dprintk("dvb_demux.c PUSI=1 but %d bytes lost\n",
351 count);
350#endif 352#endif
351 } else { 353 } else {
352 /* PUSI=0 (is not set), no section boundary */ 354 /* PUSI=0 (is not set), no section boundary */
@@ -415,9 +417,9 @@ static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf)
415 1024); 417 1024);
416 speed_timedelta = ktime_ms_delta(cur_time, 418 speed_timedelta = ktime_ms_delta(cur_time,
417 demux->speed_last_time); 419 demux->speed_last_time);
418 printk(KERN_INFO "TS speed %llu Kbits/sec \n", 420 dprintk("TS speed %llu Kbits/sec \n",
419 div64_u64(speed_bytes, 421 div64_u64(speed_bytes,
420 speed_timedelta)); 422 speed_timedelta));
421 } 423 }
422 424
423 demux->speed_last_time = cur_time; 425 demux->speed_last_time = cur_time;
@@ -426,8 +428,7 @@ static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf)
426 } 428 }
427 429
428 if (buf[1] & 0x80) { 430 if (buf[1] & 0x80) {
429 dprintk_tscheck("TEI detected. " 431 dprintk_tscheck("TEI detected. PID=0x%x data1=0x%x\n",
430 "PID=0x%x data1=0x%x\n",
431 pid, buf[1]); 432 pid, buf[1]);
432 /* data in this packet can't be trusted - drop it unless 433 /* data in this packet can't be trusted - drop it unless
433 * module option dvb_demux_feed_err_pkts is set */ 434 * module option dvb_demux_feed_err_pkts is set */
@@ -635,7 +636,7 @@ static void dvb_demux_feed_add(struct dvb_demux_feed *feed)
635{ 636{
636 spin_lock_irq(&feed->demux->lock); 637 spin_lock_irq(&feed->demux->lock);
637 if (dvb_demux_feed_find(feed)) { 638 if (dvb_demux_feed_find(feed)) {
638 printk(KERN_ERR "%s: feed already in list (type=%x state=%x pid=%x)\n", 639 pr_err("%s: feed already in list (type=%x state=%x pid=%x)\n",
639 __func__, feed->type, feed->state, feed->pid); 640 __func__, feed->type, feed->state, feed->pid);
640 goto out; 641 goto out;
641 } 642 }
@@ -649,7 +650,7 @@ static void dvb_demux_feed_del(struct dvb_demux_feed *feed)
649{ 650{
650 spin_lock_irq(&feed->demux->lock); 651 spin_lock_irq(&feed->demux->lock);
651 if (!(dvb_demux_feed_find(feed))) { 652 if (!(dvb_demux_feed_find(feed))) {
652 printk(KERN_ERR "%s: feed not in list (type=%x state=%x pid=%x)\n", 653 pr_err("%s: feed not in list (type=%x state=%x pid=%x)\n",
653 __func__, feed->type, feed->state, feed->pid); 654 __func__, feed->type, feed->state, feed->pid);
654 goto out; 655 goto out;
655 } 656 }
@@ -660,8 +661,7 @@ out:
660} 661}
661 662
662static int dmx_ts_feed_set(struct dmx_ts_feed *ts_feed, u16 pid, int ts_type, 663static int dmx_ts_feed_set(struct dmx_ts_feed *ts_feed, u16 pid, int ts_type,
663 enum dmx_ts_pes pes_type, 664 enum dmx_ts_pes pes_type, ktime_t timeout)
664 size_t circular_buffer_size, ktime_t timeout)
665{ 665{
666 struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed; 666 struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed;
667 struct dvb_demux *demux = feed->demux; 667 struct dvb_demux *demux = feed->demux;
@@ -691,23 +691,10 @@ static int dmx_ts_feed_set(struct dmx_ts_feed *ts_feed, u16 pid, int ts_type,
691 dvb_demux_feed_add(feed); 691 dvb_demux_feed_add(feed);
692 692
693 feed->pid = pid; 693 feed->pid = pid;
694 feed->buffer_size = circular_buffer_size;
695 feed->timeout = timeout; 694 feed->timeout = timeout;
696 feed->ts_type = ts_type; 695 feed->ts_type = ts_type;
697 feed->pes_type = pes_type; 696 feed->pes_type = pes_type;
698 697
699 if (feed->buffer_size) {
700#ifdef NOBUFS
701 feed->buffer = NULL;
702#else
703 feed->buffer = vmalloc(feed->buffer_size);
704 if (!feed->buffer) {
705 mutex_unlock(&demux->mutex);
706 return -ENOMEM;
707 }
708#endif
709 }
710
711 feed->state = DMX_STATE_READY; 698 feed->state = DMX_STATE_READY;
712 mutex_unlock(&demux->mutex); 699 mutex_unlock(&demux->mutex);
713 700
@@ -796,7 +783,6 @@ static int dvbdmx_allocate_ts_feed(struct dmx_demux *dmx,
796 feed->demux = demux; 783 feed->demux = demux;
797 feed->pid = 0xffff; 784 feed->pid = 0xffff;
798 feed->peslen = 0xfffa; 785 feed->peslen = 0xfffa;
799 feed->buffer = NULL;
800 786
801 (*ts_feed) = &feed->feed.ts; 787 (*ts_feed) = &feed->feed.ts;
802 (*ts_feed)->parent = dmx; 788 (*ts_feed)->parent = dmx;
@@ -833,10 +819,6 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx,
833 mutex_unlock(&demux->mutex); 819 mutex_unlock(&demux->mutex);
834 return -EINVAL; 820 return -EINVAL;
835 } 821 }
836#ifndef NOBUFS
837 vfree(feed->buffer);
838 feed->buffer = NULL;
839#endif
840 822
841 feed->state = DMX_STATE_FREE; 823 feed->state = DMX_STATE_FREE;
842 feed->filter->state = DMX_STATE_FREE; 824 feed->filter->state = DMX_STATE_FREE;
@@ -888,8 +870,7 @@ static int dmx_section_feed_allocate_filter(struct dmx_section_feed *feed,
888} 870}
889 871
890static int dmx_section_feed_set(struct dmx_section_feed *feed, 872static int dmx_section_feed_set(struct dmx_section_feed *feed,
891 u16 pid, size_t circular_buffer_size, 873 u16 pid, int check_crc)
892 int check_crc)
893{ 874{
894 struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; 875 struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
895 struct dvb_demux *dvbdmx = dvbdmxfeed->demux; 876 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
@@ -903,19 +884,8 @@ static int dmx_section_feed_set(struct dmx_section_feed *feed,
903 dvb_demux_feed_add(dvbdmxfeed); 884 dvb_demux_feed_add(dvbdmxfeed);
904 885
905 dvbdmxfeed->pid = pid; 886 dvbdmxfeed->pid = pid;
906 dvbdmxfeed->buffer_size = circular_buffer_size;
907 dvbdmxfeed->feed.sec.check_crc = check_crc; 887 dvbdmxfeed->feed.sec.check_crc = check_crc;
908 888
909#ifdef NOBUFS
910 dvbdmxfeed->buffer = NULL;
911#else
912 dvbdmxfeed->buffer = vmalloc(dvbdmxfeed->buffer_size);
913 if (!dvbdmxfeed->buffer) {
914 mutex_unlock(&dvbdmx->mutex);
915 return -ENOMEM;
916 }
917#endif
918
919 dvbdmxfeed->state = DMX_STATE_READY; 889 dvbdmxfeed->state = DMX_STATE_READY;
920 mutex_unlock(&dvbdmx->mutex); 890 mutex_unlock(&dvbdmx->mutex);
921 return 0; 891 return 0;
@@ -1074,7 +1044,6 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux,
1074 dvbdmxfeed->feed.sec.secbufp = dvbdmxfeed->feed.sec.seclen = 0; 1044 dvbdmxfeed->feed.sec.secbufp = dvbdmxfeed->feed.sec.seclen = 0;
1075 dvbdmxfeed->feed.sec.tsfeedp = 0; 1045 dvbdmxfeed->feed.sec.tsfeedp = 0;
1076 dvbdmxfeed->filter = NULL; 1046 dvbdmxfeed->filter = NULL;
1077 dvbdmxfeed->buffer = NULL;
1078 1047
1079 (*feed) = &dvbdmxfeed->feed.sec; 1048 (*feed) = &dvbdmxfeed->feed.sec;
1080 (*feed)->is_filtering = 0; 1049 (*feed)->is_filtering = 0;
@@ -1103,10 +1072,6 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux,
1103 mutex_unlock(&dvbdmx->mutex); 1072 mutex_unlock(&dvbdmx->mutex);
1104 return -EINVAL; 1073 return -EINVAL;
1105 } 1074 }
1106#ifndef NOBUFS
1107 vfree(dvbdmxfeed->buffer);
1108 dvbdmxfeed->buffer = NULL;
1109#endif
1110 dvbdmxfeed->state = DMX_STATE_FREE; 1075 dvbdmxfeed->state = DMX_STATE_FREE;
1111 1076
1112 dvb_demux_feed_del(dvbdmxfeed); 1077 dvb_demux_feed_del(dvbdmxfeed);
@@ -1268,7 +1233,7 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux)
1268 1233
1269 dvbdemux->cnt_storage = vmalloc(MAX_PID + 1); 1234 dvbdemux->cnt_storage = vmalloc(MAX_PID + 1);
1270 if (!dvbdemux->cnt_storage) 1235 if (!dvbdemux->cnt_storage)
1271 printk(KERN_WARNING "Couldn't allocate memory for TS/TEI check. Disabling it\n"); 1236 pr_warn("Couldn't allocate memory for TS/TEI check. Disabling it\n");
1272 1237
1273 INIT_LIST_HEAD(&dvbdemux->frontend_list); 1238 INIT_LIST_HEAD(&dvbdemux->frontend_list);
1274 1239
diff --git a/drivers/media/dvb-core/dvb_demux.h b/drivers/media/dvb-core/dvb_demux.h
index 5ed3cab4ad28..9235b008ea0a 100644
--- a/drivers/media/dvb-core/dvb_demux.h
+++ b/drivers/media/dvb-core/dvb_demux.h
@@ -80,8 +80,6 @@ struct dvb_demux_feed {
80 int type; 80 int type;
81 int state; 81 int state;
82 u16 pid; 82 u16 pid;
83 u8 *buffer;
84 int buffer_size;
85 83
86 ktime_t timeout; 84 ktime_t timeout;
87 struct dvb_demux_filter *filter; 85 struct dvb_demux_filter *filter;
diff --git a/drivers/media/dvb-core/dvb_filter.c b/drivers/media/dvb-core/dvb_filter.c
deleted file mode 100644
index 772003fb1821..000000000000
--- a/drivers/media/dvb-core/dvb_filter.c
+++ /dev/null
@@ -1,603 +0,0 @@
1#include <linux/kernel.h>
2#include <linux/module.h>
3#include <linux/string.h>
4#include "dvb_filter.h"
5
6#if 0
7static unsigned int bitrates[3][16] =
8{{0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,0},
9 {0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,0},
10 {0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,0}};
11#endif
12
13static u32 freq[4] = {480, 441, 320, 0};
14
15static unsigned int ac3_bitrates[32] =
16 {32,40,48,56,64,80,96,112,128,160,192,224,256,320,384,448,512,576,640,
17 0,0,0,0,0,0,0,0,0,0,0,0,0};
18
19static u32 ac3_frames[3][32] =
20 {{64,80,96,112,128,160,192,224,256,320,384,448,512,640,768,896,1024,
21 1152,1280,0,0,0,0,0,0,0,0,0,0,0,0,0},
22 {69,87,104,121,139,174,208,243,278,348,417,487,557,696,835,975,1114,
23 1253,1393,0,0,0,0,0,0,0,0,0,0,0,0,0},
24 {96,120,144,168,192,240,288,336,384,480,576,672,768,960,1152,1344,
25 1536,1728,1920,0,0,0,0,0,0,0,0,0,0,0,0,0}};
26
27
28
29#if 0
30static void setup_ts2pes(ipack *pa, ipack *pv, u16 *pida, u16 *pidv,
31 void (*pes_write)(u8 *buf, int count, void *data),
32 void *priv)
33{
34 dvb_filter_ipack_init(pa, IPACKS, pes_write);
35 dvb_filter_ipack_init(pv, IPACKS, pes_write);
36 pa->pid = pida;
37 pv->pid = pidv;
38 pa->data = priv;
39 pv->data = priv;
40}
41#endif
42
43#if 0
44static void ts_to_pes(ipack *p, u8 *buf) // don't need count (=188)
45{
46 u8 off = 0;
47
48 if (!buf || !p ){
49 printk("NULL POINTER IDIOT\n");
50 return;
51 }
52 if (buf[1]&PAY_START) {
53 if (p->plength == MMAX_PLENGTH-6 && p->found>6){
54 p->plength = p->found-6;
55 p->found = 0;
56 send_ipack(p);
57 dvb_filter_ipack_reset(p);
58 }
59 }
60 if (buf[3] & ADAPT_FIELD) { // adaptation field?
61 off = buf[4] + 1;
62 if (off+4 > 187) return;
63 }
64 dvb_filter_instant_repack(buf+4+off, TS_SIZE-4-off, p);
65}
66#endif
67
68#if 0
69/* needs 5 byte input, returns picture coding type*/
70static int read_picture_header(u8 *headr, struct mpg_picture *pic, int field, int pr)
71{
72 u8 pct;
73
74 if (pr) printk( "Pic header: ");
75 pic->temporal_reference[field] = (( headr[0] << 2 ) |
76 (headr[1] & 0x03) )& 0x03ff;
77 if (pr) printk( " temp ref: 0x%04x", pic->temporal_reference[field]);
78
79 pct = ( headr[1] >> 2 ) & 0x07;
80 pic->picture_coding_type[field] = pct;
81 if (pr) {
82 switch(pct){
83 case I_FRAME:
84 printk( " I-FRAME");
85 break;
86 case B_FRAME:
87 printk( " B-FRAME");
88 break;
89 case P_FRAME:
90 printk( " P-FRAME");
91 break;
92 }
93 }
94
95
96 pic->vinfo.vbv_delay = (( headr[1] >> 5 ) | ( headr[2] << 3) |
97 ( (headr[3] & 0x1F) << 11) ) & 0xffff;
98
99 if (pr) printk( " vbv delay: 0x%04x", pic->vinfo.vbv_delay);
100
101 pic->picture_header_parameter = ( headr[3] & 0xe0 ) |
102 ((headr[4] & 0x80) >> 3);
103
104 if ( pct == B_FRAME ){
105 pic->picture_header_parameter |= ( headr[4] >> 3 ) & 0x0f;
106 }
107 if (pr) printk( " pic head param: 0x%x",
108 pic->picture_header_parameter);
109
110 return pct;
111}
112#endif
113
114#if 0
115/* needs 4 byte input */
116static int read_gop_header(u8 *headr, struct mpg_picture *pic, int pr)
117{
118 if (pr) printk("GOP header: ");
119
120 pic->time_code = (( headr[0] << 17 ) | ( headr[1] << 9) |
121 ( headr[2] << 1 ) | (headr[3] &0x01)) & 0x1ffffff;
122
123 if (pr) printk(" time: %d:%d.%d ", (headr[0]>>2)& 0x1F,
124 ((headr[0]<<4)& 0x30)| ((headr[1]>>4)& 0x0F),
125 ((headr[1]<<3)& 0x38)| ((headr[2]>>5)& 0x0F));
126
127 if ( ( headr[3] & 0x40 ) != 0 ){
128 pic->closed_gop = 1;
129 } else {
130 pic->closed_gop = 0;
131 }
132 if (pr) printk("closed: %d", pic->closed_gop);
133
134 if ( ( headr[3] & 0x20 ) != 0 ){
135 pic->broken_link = 1;
136 } else {
137 pic->broken_link = 0;
138 }
139 if (pr) printk(" broken: %d\n", pic->broken_link);
140
141 return 0;
142}
143#endif
144
145#if 0
146/* needs 8 byte input */
147static int read_sequence_header(u8 *headr, struct dvb_video_info *vi, int pr)
148{
149 int sw;
150 int form = -1;
151
152 if (pr) printk("Reading sequence header\n");
153
154 vi->horizontal_size = ((headr[1] &0xF0) >> 4) | (headr[0] << 4);
155 vi->vertical_size = ((headr[1] &0x0F) << 8) | (headr[2]);
156
157 sw = (int)((headr[3]&0xF0) >> 4) ;
158
159 switch( sw ){
160 case 1:
161 if (pr)
162 printk("Videostream: ASPECT: 1:1");
163 vi->aspect_ratio = 100;
164 break;
165 case 2:
166 if (pr)
167 printk("Videostream: ASPECT: 4:3");
168 vi->aspect_ratio = 133;
169 break;
170 case 3:
171 if (pr)
172 printk("Videostream: ASPECT: 16:9");
173 vi->aspect_ratio = 177;
174 break;
175 case 4:
176 if (pr)
177 printk("Videostream: ASPECT: 2.21:1");
178 vi->aspect_ratio = 221;
179 break;
180
181 case 5 ... 15:
182 if (pr)
183 printk("Videostream: ASPECT: reserved");
184 vi->aspect_ratio = 0;
185 break;
186
187 default:
188 vi->aspect_ratio = 0;
189 return -1;
190 }
191
192 if (pr)
193 printk(" Size = %dx%d",vi->horizontal_size,vi->vertical_size);
194
195 sw = (int)(headr[3]&0x0F);
196
197 switch ( sw ) {
198 case 1:
199 if (pr)
200 printk(" FRate: 23.976 fps");
201 vi->framerate = 23976;
202 form = -1;
203 break;
204 case 2:
205 if (pr)
206 printk(" FRate: 24 fps");
207 vi->framerate = 24000;
208 form = -1;
209 break;
210 case 3:
211 if (pr)
212 printk(" FRate: 25 fps");
213 vi->framerate = 25000;
214 form = VIDEO_MODE_PAL;
215 break;
216 case 4:
217 if (pr)
218 printk(" FRate: 29.97 fps");
219 vi->framerate = 29970;
220 form = VIDEO_MODE_NTSC;
221 break;
222 case 5:
223 if (pr)
224 printk(" FRate: 30 fps");
225 vi->framerate = 30000;
226 form = VIDEO_MODE_NTSC;
227 break;
228 case 6:
229 if (pr)
230 printk(" FRate: 50 fps");
231 vi->framerate = 50000;
232 form = VIDEO_MODE_PAL;
233 break;
234 case 7:
235 if (pr)
236 printk(" FRate: 60 fps");
237 vi->framerate = 60000;
238 form = VIDEO_MODE_NTSC;
239 break;
240 }
241
242 vi->bit_rate = (headr[4] << 10) | (headr[5] << 2) | (headr[6] & 0x03);
243
244 vi->vbv_buffer_size
245 = (( headr[6] & 0xF8) >> 3 ) | (( headr[7] & 0x1F )<< 5);
246
247 if (pr){
248 printk(" BRate: %d Mbit/s",4*(vi->bit_rate)/10000);
249 printk(" vbvbuffer %d",16*1024*(vi->vbv_buffer_size));
250 printk("\n");
251 }
252
253 vi->video_format = form;
254
255 return 0;
256}
257#endif
258
259
260#if 0
261static int get_vinfo(u8 *mbuf, int count, struct dvb_video_info *vi, int pr)
262{
263 u8 *headr;
264 int found = 0;
265 int c = 0;
266
267 while (found < 4 && c+4 < count){
268 u8 *b;
269
270 b = mbuf+c;
271 if ( b[0] == 0x00 && b[1] == 0x00 && b[2] == 0x01
272 && b[3] == 0xb3) found = 4;
273 else {
274 c++;
275 }
276 }
277
278 if (! found) return -1;
279 c += 4;
280 if (c+12 >= count) return -1;
281 headr = mbuf+c;
282 if (read_sequence_header(headr, vi, pr) < 0) return -1;
283 vi->off = c-4;
284 return 0;
285}
286#endif
287
288
289#if 0
290static int get_ainfo(u8 *mbuf, int count, struct dvb_audio_info *ai, int pr)
291{
292 u8 *headr;
293 int found = 0;
294 int c = 0;
295 int fr = 0;
296
297 while (found < 2 && c < count){
298 u8 b[2];
299 memcpy( b, mbuf+c, 2);
300
301 if ( b[0] == 0xff && (b[1] & 0xf8) == 0xf8)
302 found = 2;
303 else {
304 c++;
305 }
306 }
307
308 if (!found) return -1;
309
310 if (c+3 >= count) return -1;
311 headr = mbuf+c;
312
313 ai->layer = (headr[1] & 0x06) >> 1;
314
315 if (pr)
316 printk("Audiostream: Layer: %d", 4-ai->layer);
317
318
319 ai->bit_rate = bitrates[(3-ai->layer)][(headr[2] >> 4 )]*1000;
320
321 if (pr){
322 if (ai->bit_rate == 0)
323 printk(" Bit rate: free");
324 else if (ai->bit_rate == 0xf)
325 printk(" BRate: reserved");
326 else
327 printk(" BRate: %d kb/s", ai->bit_rate/1000);
328 }
329
330 fr = (headr[2] & 0x0c ) >> 2;
331 ai->frequency = freq[fr]*100;
332 if (pr){
333 if (ai->frequency == 3)
334 printk(" Freq: reserved\n");
335 else
336 printk(" Freq: %d kHz\n",ai->frequency);
337
338 }
339 ai->off = c;
340 return 0;
341}
342#endif
343
344
345int dvb_filter_get_ac3info(u8 *mbuf, int count, struct dvb_audio_info *ai, int pr)
346{
347 u8 *headr;
348 int found = 0;
349 int c = 0;
350 u8 frame = 0;
351 int fr = 0;
352
353 while ( !found && c < count){
354 u8 *b = mbuf+c;
355
356 if ( b[0] == 0x0b && b[1] == 0x77 )
357 found = 1;
358 else {
359 c++;
360 }
361 }
362
363 if (!found) return -1;
364 if (pr)
365 printk("Audiostream: AC3");
366
367 ai->off = c;
368 if (c+5 >= count) return -1;
369
370 ai->layer = 0; // 0 for AC3
371 headr = mbuf+c+2;
372
373 frame = (headr[2]&0x3f);
374 ai->bit_rate = ac3_bitrates[frame >> 1]*1000;
375
376 if (pr)
377 printk(" BRate: %d kb/s", (int) ai->bit_rate/1000);
378
379 ai->frequency = (headr[2] & 0xc0 ) >> 6;
380 fr = (headr[2] & 0xc0 ) >> 6;
381 ai->frequency = freq[fr]*100;
382 if (pr) printk (" Freq: %d Hz\n", (int) ai->frequency);
383
384
385 ai->framesize = ac3_frames[fr][frame >> 1];
386 if ((frame & 1) && (fr == 1)) ai->framesize++;
387 ai->framesize = ai->framesize << 1;
388 if (pr) printk (" Framesize %d\n",(int) ai->framesize);
389
390
391 return 0;
392}
393EXPORT_SYMBOL(dvb_filter_get_ac3info);
394
395
396#if 0
397static u8 *skip_pes_header(u8 **bufp)
398{
399 u8 *inbuf = *bufp;
400 u8 *buf = inbuf;
401 u8 *pts = NULL;
402 int skip = 0;
403
404 static const int mpeg1_skip_table[16] = {
405 1, 0xffff, 5, 10, 0xffff, 0xffff, 0xffff, 0xffff,
406 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
407 };
408
409
410 if ((inbuf[6] & 0xc0) == 0x80){ /* mpeg2 */
411 if (buf[7] & PTS_ONLY)
412 pts = buf+9;
413 else pts = NULL;
414 buf = inbuf + 9 + inbuf[8];
415 } else { /* mpeg1 */
416 for (buf = inbuf + 6; *buf == 0xff; buf++)
417 if (buf == inbuf + 6 + 16) {
418 break;
419 }
420 if ((*buf & 0xc0) == 0x40)
421 buf += 2;
422 skip = mpeg1_skip_table [*buf >> 4];
423 if (skip == 5 || skip == 10) pts = buf;
424 else pts = NULL;
425
426 buf += mpeg1_skip_table [*buf >> 4];
427 }
428
429 *bufp = buf;
430 return pts;
431}
432#endif
433
434#if 0
435static void initialize_quant_matrix( u32 *matrix )
436{
437 int i;
438
439 matrix[0] = 0x08101013;
440 matrix[1] = 0x10131616;
441 matrix[2] = 0x16161616;
442 matrix[3] = 0x1a181a1b;
443 matrix[4] = 0x1b1b1a1a;
444 matrix[5] = 0x1a1a1b1b;
445 matrix[6] = 0x1b1d1d1d;
446 matrix[7] = 0x2222221d;
447 matrix[8] = 0x1d1d1b1b;
448 matrix[9] = 0x1d1d2020;
449 matrix[10] = 0x22222526;
450 matrix[11] = 0x25232322;
451 matrix[12] = 0x23262628;
452 matrix[13] = 0x28283030;
453 matrix[14] = 0x2e2e3838;
454 matrix[15] = 0x3a454553;
455
456 for ( i = 16 ; i < 32 ; i++ )
457 matrix[i] = 0x10101010;
458}
459#endif
460
461#if 0
462static void initialize_mpg_picture(struct mpg_picture *pic)
463{
464 int i;
465
466 /* set MPEG1 */
467 pic->mpeg1_flag = 1;
468 pic->profile_and_level = 0x4A ; /* MP@LL */
469 pic->progressive_sequence = 1;
470 pic->low_delay = 0;
471
472 pic->sequence_display_extension_flag = 0;
473 for ( i = 0 ; i < 4 ; i++ ){
474 pic->frame_centre_horizontal_offset[i] = 0;
475 pic->frame_centre_vertical_offset[i] = 0;
476 }
477 pic->last_frame_centre_horizontal_offset = 0;
478 pic->last_frame_centre_vertical_offset = 0;
479
480 pic->picture_display_extension_flag[0] = 0;
481 pic->picture_display_extension_flag[1] = 0;
482 pic->sequence_header_flag = 0;
483 pic->gop_flag = 0;
484 pic->sequence_end_flag = 0;
485}
486#endif
487
488#if 0
489static void mpg_set_picture_parameter( int32_t field_type, struct mpg_picture *pic )
490{
491 int16_t last_h_offset;
492 int16_t last_v_offset;
493
494 int16_t *p_h_offset;
495 int16_t *p_v_offset;
496
497 if ( pic->mpeg1_flag ){
498 pic->picture_structure[field_type] = VIDEO_FRAME_PICTURE;
499 pic->top_field_first = 0;
500 pic->repeat_first_field = 0;
501 pic->progressive_frame = 1;
502 pic->picture_coding_parameter = 0x000010;
503 }
504
505 /* Reset flag */
506 pic->picture_display_extension_flag[field_type] = 0;
507
508 last_h_offset = pic->last_frame_centre_horizontal_offset;
509 last_v_offset = pic->last_frame_centre_vertical_offset;
510 if ( field_type == FIRST_FIELD ){
511 p_h_offset = pic->frame_centre_horizontal_offset;
512 p_v_offset = pic->frame_centre_vertical_offset;
513 *p_h_offset = last_h_offset;
514 *(p_h_offset + 1) = last_h_offset;
515 *(p_h_offset + 2) = last_h_offset;
516 *p_v_offset = last_v_offset;
517 *(p_v_offset + 1) = last_v_offset;
518 *(p_v_offset + 2) = last_v_offset;
519 } else {
520 pic->frame_centre_horizontal_offset[3] = last_h_offset;
521 pic->frame_centre_vertical_offset[3] = last_v_offset;
522 }
523}
524#endif
525
526#if 0
527static void init_mpg_picture( struct mpg_picture *pic, int chan, int32_t field_type)
528{
529 pic->picture_header = 0;
530 pic->sequence_header_data
531 = ( INIT_HORIZONTAL_SIZE << 20 )
532 | ( INIT_VERTICAL_SIZE << 8 )
533 | ( INIT_ASPECT_RATIO << 4 )
534 | ( INIT_FRAME_RATE );
535 pic->mpeg1_flag = 0;
536 pic->vinfo.horizontal_size
537 = INIT_DISP_HORIZONTAL_SIZE;
538 pic->vinfo.vertical_size
539 = INIT_DISP_VERTICAL_SIZE;
540 pic->picture_display_extension_flag[field_type]
541 = 0;
542 pic->pts_flag[field_type] = 0;
543
544 pic->sequence_gop_header = 0;
545 pic->picture_header = 0;
546 pic->sequence_header_flag = 0;
547 pic->gop_flag = 0;
548 pic->sequence_end_flag = 0;
549 pic->sequence_display_extension_flag = 0;
550 pic->last_frame_centre_horizontal_offset = 0;
551 pic->last_frame_centre_vertical_offset = 0;
552 pic->channel = chan;
553}
554#endif
555
556void dvb_filter_pes2ts_init(struct dvb_filter_pes2ts *p2ts, unsigned short pid,
557 dvb_filter_pes2ts_cb_t *cb, void *priv)
558{
559 unsigned char *buf=p2ts->buf;
560
561 buf[0]=0x47;
562 buf[1]=(pid>>8);
563 buf[2]=pid&0xff;
564 p2ts->cc=0;
565 p2ts->cb=cb;
566 p2ts->priv=priv;
567}
568EXPORT_SYMBOL(dvb_filter_pes2ts_init);
569
570int dvb_filter_pes2ts(struct dvb_filter_pes2ts *p2ts, unsigned char *pes,
571 int len, int payload_start)
572{
573 unsigned char *buf=p2ts->buf;
574 int ret=0, rest;
575
576 //len=6+((pes[4]<<8)|pes[5]);
577
578 if (payload_start)
579 buf[1]|=0x40;
580 else
581 buf[1]&=~0x40;
582 while (len>=184) {
583 buf[3]=0x10|((p2ts->cc++)&0x0f);
584 memcpy(buf+4, pes, 184);
585 if ((ret=p2ts->cb(p2ts->priv, buf)))
586 return ret;
587 len-=184; pes+=184;
588 buf[1]&=~0x40;
589 }
590 if (!len)
591 return 0;
592 buf[3]=0x30|((p2ts->cc++)&0x0f);
593 rest=183-len;
594 if (rest) {
595 buf[5]=0x00;
596 if (rest-1)
597 memset(buf+6, 0xff, rest-1);
598 }
599 buf[4]=rest;
600 memcpy(buf+5+rest, pes, len);
601 return p2ts->cb(p2ts->priv, buf);
602}
603EXPORT_SYMBOL(dvb_filter_pes2ts);
diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index 01511e5a5566..db74cb74d271 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -28,6 +28,8 @@
28/* Enables DVBv3 compatibility bits at the headers */ 28/* Enables DVBv3 compatibility bits at the headers */
29#define __DVB_CORE__ 29#define __DVB_CORE__
30 30
31#define pr_fmt(fmt) "dvb_frontend: " fmt
32
31#include <linux/string.h> 33#include <linux/string.h>
32#include <linux/kernel.h> 34#include <linux/kernel.h>
33#include <linux/sched.h> 35#include <linux/sched.h>
@@ -67,6 +69,9 @@ MODULE_PARM_DESC(dvb_powerdown_on_sleep, "0: do not power down, 1: turn LNB volt
67module_param(dvb_mfe_wait_time, int, 0644); 69module_param(dvb_mfe_wait_time, int, 0644);
68MODULE_PARM_DESC(dvb_mfe_wait_time, "Wait up to <mfe_wait_time> seconds on open() for multi-frontend to become available (default:5 seconds)"); 70MODULE_PARM_DESC(dvb_mfe_wait_time, "Wait up to <mfe_wait_time> seconds on open() for multi-frontend to become available (default:5 seconds)");
69 71
72#define dprintk(fmt, arg...) \
73 printk(KERN_DEBUG pr_fmt("%s: " fmt), __func__, ##arg)
74
70#define FESTATE_IDLE 1 75#define FESTATE_IDLE 1
71#define FESTATE_RETUNE 2 76#define FESTATE_RETUNE 2
72#define FESTATE_TUNING_FAST 4 77#define FESTATE_TUNING_FAST 4
@@ -99,8 +104,6 @@ MODULE_PARM_DESC(dvb_mfe_wait_time, "Wait up to <mfe_wait_time> seconds on open(
99static DEFINE_MUTEX(frontend_mutex); 104static DEFINE_MUTEX(frontend_mutex);
100 105
101struct dvb_frontend_private { 106struct dvb_frontend_private {
102 struct kref refcount;
103
104 /* thread/frontend values */ 107 /* thread/frontend values */
105 struct dvb_device *dvbdev; 108 struct dvb_device *dvbdev;
106 struct dvb_frontend_parameters parameters_out; 109 struct dvb_frontend_parameters parameters_out;
@@ -138,21 +141,30 @@ struct dvb_frontend_private {
138#endif 141#endif
139}; 142};
140 143
141static void dvb_frontend_private_free(struct kref *ref) 144static void dvb_frontend_invoke_release(struct dvb_frontend *fe,
145 void (*release)(struct dvb_frontend *fe));
146
147static void dvb_frontend_free(struct kref *ref)
142{ 148{
143 struct dvb_frontend_private *fepriv = 149 struct dvb_frontend *fe =
144 container_of(ref, struct dvb_frontend_private, refcount); 150 container_of(ref, struct dvb_frontend, refcount);
151 struct dvb_frontend_private *fepriv = fe->frontend_priv;
152
153 dvb_free_device(fepriv->dvbdev);
154
155 dvb_frontend_invoke_release(fe, fe->ops.release);
156
145 kfree(fepriv); 157 kfree(fepriv);
146} 158}
147 159
148static void dvb_frontend_private_put(struct dvb_frontend_private *fepriv) 160static void dvb_frontend_put(struct dvb_frontend *fe)
149{ 161{
150 kref_put(&fepriv->refcount, dvb_frontend_private_free); 162 kref_put(&fe->refcount, dvb_frontend_free);
151} 163}
152 164
153static void dvb_frontend_private_get(struct dvb_frontend_private *fepriv) 165static void dvb_frontend_get(struct dvb_frontend *fe)
154{ 166{
155 kref_get(&fepriv->refcount); 167 kref_get(&fe->refcount);
156} 168}
157 169
158static void dvb_frontend_wakeup(struct dvb_frontend *fe); 170static void dvb_frontend_wakeup(struct dvb_frontend *fe);
@@ -1515,12 +1527,8 @@ static int dtv_set_frontend(struct dvb_frontend *fe);
1515 1527
1516static bool is_dvbv3_delsys(u32 delsys) 1528static bool is_dvbv3_delsys(u32 delsys)
1517{ 1529{
1518 bool status; 1530 return (delsys == SYS_DVBT) || (delsys == SYS_DVBC_ANNEX_A) ||
1519 1531 (delsys == SYS_DVBS) || (delsys == SYS_ATSC);
1520 status = (delsys == SYS_DVBT) || (delsys == SYS_DVBC_ANNEX_A) ||
1521 (delsys == SYS_DVBS) || (delsys == SYS_ATSC);
1522
1523 return status;
1524} 1532}
1525 1533
1526/** 1534/**
@@ -2356,7 +2364,8 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
2356 int i; 2364 int i;
2357 u8 last = 1; 2365 u8 last = 1;
2358 if (dvb_frontend_debug) 2366 if (dvb_frontend_debug)
2359 printk("%s switch command: 0x%04lx\n", __func__, swcmd); 2367 dprintk("%s switch command: 0x%04lx\n",
2368 __func__, swcmd);
2360 nexttime = ktime_get_boottime(); 2369 nexttime = ktime_get_boottime();
2361 if (dvb_frontend_debug) 2370 if (dvb_frontend_debug)
2362 tv[0] = nexttime; 2371 tv[0] = nexttime;
@@ -2379,10 +2388,10 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
2379 dvb_frontend_sleep_until(&nexttime, 8000); 2388 dvb_frontend_sleep_until(&nexttime, 8000);
2380 } 2389 }
2381 if (dvb_frontend_debug) { 2390 if (dvb_frontend_debug) {
2382 printk("%s(%d): switch delay (should be 32k followed by all 8k\n", 2391 dprintk("%s(%d): switch delay (should be 32k followed by all 8k)\n",
2383 __func__, fe->dvb->num); 2392 __func__, fe->dvb->num);
2384 for (i = 1; i < 10; i++) 2393 for (i = 1; i < 10; i++)
2385 printk("%d: %d\n", i, 2394 pr_info("%d: %d\n", i,
2386 (int) ktime_us_delta(tv[i], tv[i-1])); 2395 (int) ktime_us_delta(tv[i], tv[i-1]));
2387 } 2396 }
2388 err = 0; 2397 err = 0;
@@ -2545,7 +2554,7 @@ static int dvb_frontend_open(struct inode *inode, struct file *file)
2545 fepriv->events.eventr = fepriv->events.eventw = 0; 2554 fepriv->events.eventr = fepriv->events.eventw = 0;
2546 } 2555 }
2547 2556
2548 dvb_frontend_private_get(fepriv); 2557 dvb_frontend_get(fe);
2549 2558
2550 if (adapter->mfe_shared) 2559 if (adapter->mfe_shared)
2551 mutex_unlock (&adapter->mfe_lock); 2560 mutex_unlock (&adapter->mfe_lock);
@@ -2595,7 +2604,7 @@ static int dvb_frontend_release(struct inode *inode, struct file *file)
2595 fe->ops.ts_bus_ctrl(fe, 0); 2604 fe->ops.ts_bus_ctrl(fe, 0);
2596 } 2605 }
2597 2606
2598 dvb_frontend_private_put(fepriv); 2607 dvb_frontend_put(fe);
2599 2608
2600 return ret; 2609 return ret;
2601} 2610}
@@ -2685,7 +2694,14 @@ int dvb_register_frontend(struct dvb_adapter* dvb,
2685 } 2694 }
2686 fepriv = fe->frontend_priv; 2695 fepriv = fe->frontend_priv;
2687 2696
2688 kref_init(&fepriv->refcount); 2697 kref_init(&fe->refcount);
2698
2699 /*
2700 * After initialization, there need to be two references: one
2701 * for dvb_unregister_frontend(), and another one for
2702 * dvb_frontend_detach().
2703 */
2704 dvb_frontend_get(fe);
2689 2705
2690 sema_init(&fepriv->sem, 1); 2706 sema_init(&fepriv->sem, 1);
2691 init_waitqueue_head (&fepriv->wait_queue); 2707 init_waitqueue_head (&fepriv->wait_queue);
@@ -2720,50 +2736,33 @@ int dvb_unregister_frontend(struct dvb_frontend* fe)
2720 dev_dbg(fe->dvb->device, "%s:\n", __func__); 2736 dev_dbg(fe->dvb->device, "%s:\n", __func__);
2721 2737
2722 mutex_lock(&frontend_mutex); 2738 mutex_lock(&frontend_mutex);
2723 dvb_frontend_stop (fe); 2739 dvb_frontend_stop(fe);
2724 dvb_unregister_device (fepriv->dvbdev); 2740 dvb_remove_device(fepriv->dvbdev);
2725 2741
2726 /* fe is invalid now */ 2742 /* fe is invalid now */
2727 mutex_unlock(&frontend_mutex); 2743 mutex_unlock(&frontend_mutex);
2728 dvb_frontend_private_put(fepriv); 2744 dvb_frontend_put(fe);
2729 return 0; 2745 return 0;
2730} 2746}
2731EXPORT_SYMBOL(dvb_unregister_frontend); 2747EXPORT_SYMBOL(dvb_unregister_frontend);
2732 2748
2733#ifdef CONFIG_MEDIA_ATTACH 2749static void dvb_frontend_invoke_release(struct dvb_frontend *fe,
2734void dvb_frontend_detach(struct dvb_frontend* fe) 2750 void (*release)(struct dvb_frontend *fe))
2735{ 2751{
2736 void *ptr; 2752 if (release) {
2737 2753 release(fe);
2738 if (fe->ops.release_sec) { 2754#ifdef CONFIG_MEDIA_ATTACH
2739 fe->ops.release_sec(fe); 2755 dvb_detach(release);
2740 dvb_detach(fe->ops.release_sec); 2756#endif
2741 }
2742 if (fe->ops.tuner_ops.release) {
2743 fe->ops.tuner_ops.release(fe);
2744 dvb_detach(fe->ops.tuner_ops.release);
2745 }
2746 if (fe->ops.analog_ops.release) {
2747 fe->ops.analog_ops.release(fe);
2748 dvb_detach(fe->ops.analog_ops.release);
2749 }
2750 ptr = (void*)fe->ops.release;
2751 if (ptr) {
2752 fe->ops.release(fe);
2753 dvb_detach(ptr);
2754 } 2757 }
2755} 2758}
2756#else 2759
2757void dvb_frontend_detach(struct dvb_frontend* fe) 2760void dvb_frontend_detach(struct dvb_frontend* fe)
2758{ 2761{
2759 if (fe->ops.release_sec) 2762 dvb_frontend_invoke_release(fe, fe->ops.release_sec);
2760 fe->ops.release_sec(fe); 2763 dvb_frontend_invoke_release(fe, fe->ops.tuner_ops.release);
2761 if (fe->ops.tuner_ops.release) 2764 dvb_frontend_invoke_release(fe, fe->ops.analog_ops.release);
2762 fe->ops.tuner_ops.release(fe); 2765 dvb_frontend_invoke_release(fe, fe->ops.detach);
2763 if (fe->ops.analog_ops.release) 2766 dvb_frontend_put(fe);
2764 fe->ops.analog_ops.release(fe);
2765 if (fe->ops.release)
2766 fe->ops.release(fe);
2767} 2767}
2768#endif
2769EXPORT_SYMBOL(dvb_frontend_detach); 2768EXPORT_SYMBOL(dvb_frontend_detach);
diff --git a/drivers/media/dvb-core/dvb_frontend.h b/drivers/media/dvb-core/dvb_frontend.h
index fb6e84811504..482912d3b77a 100644
--- a/drivers/media/dvb-core/dvb_frontend.h
+++ b/drivers/media/dvb-core/dvb_frontend.h
@@ -225,7 +225,7 @@ struct dvb_tuner_ops {
225 225
226 struct dvb_tuner_info info; 226 struct dvb_tuner_info info;
227 227
228 int (*release)(struct dvb_frontend *fe); 228 void (*release)(struct dvb_frontend *fe);
229 int (*init)(struct dvb_frontend *fe); 229 int (*init)(struct dvb_frontend *fe);
230 int (*sleep)(struct dvb_frontend *fe); 230 int (*sleep)(struct dvb_frontend *fe);
231 int (*suspend)(struct dvb_frontend *fe); 231 int (*suspend)(struct dvb_frontend *fe);
@@ -323,7 +323,11 @@ struct dtv_frontend_properties;
323 * 323 *
324 * @info: embedded struct dvb_tuner_info with tuner properties 324 * @info: embedded struct dvb_tuner_info with tuner properties
325 * @delsys: Delivery systems supported by the frontend 325 * @delsys: Delivery systems supported by the frontend
326 * @release: callback function called when frontend is dettached. 326 * @detach: callback function called when frontend is detached.
327 * drivers should clean up, but not yet free the struct
328 * dvb_frontend allocation.
329 * @release: callback function called when frontend is ready to be
330 * freed.
327 * drivers should free any allocated memory. 331 * drivers should free any allocated memory.
328 * @release_sec: callback function requesting that the Satelite Equipment 332 * @release_sec: callback function requesting that the Satelite Equipment
329 * Control (SEC) driver to release and free any memory 333 * Control (SEC) driver to release and free any memory
@@ -408,6 +412,7 @@ struct dvb_frontend_ops {
408 412
409 u8 delsys[MAX_DELSYS]; 413 u8 delsys[MAX_DELSYS];
410 414
415 void (*detach)(struct dvb_frontend *fe);
411 void (*release)(struct dvb_frontend* fe); 416 void (*release)(struct dvb_frontend* fe);
412 void (*release_sec)(struct dvb_frontend* fe); 417 void (*release_sec)(struct dvb_frontend* fe);
413 418
@@ -655,6 +660,7 @@ struct dtv_frontend_properties {
655 */ 660 */
656 661
657struct dvb_frontend { 662struct dvb_frontend {
663 struct kref refcount;
658 struct dvb_frontend_ops ops; 664 struct dvb_frontend_ops ops;
659 struct dvb_adapter *dvb; 665 struct dvb_adapter *dvb;
660 void *demodulator_priv; 666 void *demodulator_priv;
diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c
index 0da622f5fe69..dfc03a95df71 100644
--- a/drivers/media/dvb-core/dvb_net.c
+++ b/drivers/media/dvb-core/dvb_net.c
@@ -54,6 +54,8 @@
54 * 54 *
55 */ 55 */
56 56
57#define pr_fmt(fmt) "dvb_net: " fmt
58
57#include <linux/module.h> 59#include <linux/module.h>
58#include <linux/kernel.h> 60#include <linux/kernel.h>
59#include <linux/netdevice.h> 61#include <linux/netdevice.h>
@@ -309,451 +311,589 @@ static inline void reset_ule( struct dvb_net_priv *p )
309 * Decode ULE SNDUs according to draft-ietf-ipdvb-ule-03.txt from a sequence of 311 * Decode ULE SNDUs according to draft-ietf-ipdvb-ule-03.txt from a sequence of
310 * TS cells of a single PID. 312 * TS cells of a single PID.
311 */ 313 */
312static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
313{
314 struct dvb_net_priv *priv = netdev_priv(dev);
315 unsigned long skipped = 0L;
316 const u8 *ts, *ts_end, *from_where = NULL;
317 u8 ts_remain = 0, how_much = 0, new_ts = 1;
318 struct ethhdr *ethh = NULL;
319 bool error = false;
320 314
315struct dvb_net_ule_handle {
316 struct net_device *dev;
317 struct dvb_net_priv *priv;
318 struct ethhdr *ethh;
319 const u8 *buf;
320 size_t buf_len;
321 unsigned long skipped;
322 const u8 *ts, *ts_end, *from_where;
323 u8 ts_remain, how_much, new_ts;
324 bool error;
321#ifdef ULE_DEBUG 325#ifdef ULE_DEBUG
322 /* The code inside ULE_DEBUG keeps a history of the last 100 TS cells processed. */ 326 /*
327 * The code inside ULE_DEBUG keeps a history of the
328 * last 100 TS cells processed.
329 */
323 static unsigned char ule_hist[100*TS_SZ]; 330 static unsigned char ule_hist[100*TS_SZ];
324 static unsigned char *ule_where = ule_hist, ule_dump; 331 static unsigned char *ule_where = ule_hist, ule_dump;
325#endif 332#endif
333};
326 334
327 /* For all TS cells in current buffer. 335static int dvb_net_ule_new_ts_cell(struct dvb_net_ule_handle *h)
328 * Appearently, we are called for every single TS cell. 336{
329 */ 337 /* We are about to process a new TS cell. */
330 for (ts = buf, ts_end = buf + buf_len; ts < ts_end; /* no default incr. */ ) {
331
332 if (new_ts) {
333 /* We are about to process a new TS cell. */
334 338
335#ifdef ULE_DEBUG 339#ifdef ULE_DEBUG
336 if (ule_where >= &ule_hist[100*TS_SZ]) ule_where = ule_hist; 340 if (h->ule_where >= &h->ule_hist[100*TS_SZ])
337 memcpy( ule_where, ts, TS_SZ ); 341 h->ule_where = h->ule_hist;
338 if (ule_dump) { 342 memcpy(h->ule_where, h->ts, TS_SZ);
339 hexdump( ule_where, TS_SZ ); 343 if (h->ule_dump) {
340 ule_dump = 0; 344 hexdump(h->ule_where, TS_SZ);
341 } 345 h->ule_dump = 0;
342 ule_where += TS_SZ; 346 }
347 h->ule_where += TS_SZ;
343#endif 348#endif
344 349
345 /* Check TS error conditions: sync_byte, transport_error_indicator, scrambling_control . */ 350 /*
346 if ((ts[0] != TS_SYNC) || (ts[1] & TS_TEI) || ((ts[3] & TS_SC) != 0)) { 351 * Check TS h->error conditions: sync_byte, transport_error_indicator,
347 printk(KERN_WARNING "%lu: Invalid TS cell: SYNC %#x, TEI %u, SC %#x.\n", 352 * scrambling_control .
348 priv->ts_count, ts[0], 353 */
349 (ts[1] & TS_TEI) >> 7, 354 if ((h->ts[0] != TS_SYNC) || (h->ts[1] & TS_TEI) ||
350 (ts[3] & TS_SC) >> 6); 355 ((h->ts[3] & TS_SC) != 0)) {
351 356 pr_warn("%lu: Invalid TS cell: SYNC %#x, TEI %u, SC %#x.\n",
352 /* Drop partly decoded SNDU, reset state, resync on PUSI. */ 357 h->priv->ts_count, h->ts[0],
353 if (priv->ule_skb) { 358 (h->ts[1] & TS_TEI) >> 7,
354 dev_kfree_skb( priv->ule_skb ); 359 (h->ts[3] & TS_SC) >> 6);
355 /* Prepare for next SNDU. */ 360
356 dev->stats.rx_errors++; 361 /* Drop partly decoded SNDU, reset state, resync on PUSI. */
357 dev->stats.rx_frame_errors++; 362 if (h->priv->ule_skb) {
358 } 363 dev_kfree_skb(h->priv->ule_skb);
359 reset_ule(priv); 364 /* Prepare for next SNDU. */
360 priv->need_pusi = 1; 365 h->dev->stats.rx_errors++;
366 h->dev->stats.rx_frame_errors++;
367 }
368 reset_ule(h->priv);
369 h->priv->need_pusi = 1;
361 370
362 /* Continue with next TS cell. */ 371 /* Continue with next TS cell. */
363 ts += TS_SZ; 372 h->ts += TS_SZ;
364 priv->ts_count++; 373 h->priv->ts_count++;
365 continue; 374 return 1;
366 } 375 }
367 376
368 ts_remain = 184; 377 h->ts_remain = 184;
369 from_where = ts + 4; 378 h->from_where = h->ts + 4;
379
380 return 0;
381}
382
383static int dvb_net_ule_ts_pusi(struct dvb_net_ule_handle *h)
384{
385 if (h->ts[1] & TS_PUSI) {
386 /* Find beginning of first ULE SNDU in current TS cell. */
387 /* Synchronize continuity counter. */
388 h->priv->tscc = h->ts[3] & 0x0F;
389 /* There is a pointer field here. */
390 if (h->ts[4] > h->ts_remain) {
391 pr_err("%lu: Invalid ULE packet (pointer field %d)\n",
392 h->priv->ts_count, h->ts[4]);
393 h->ts += TS_SZ;
394 h->priv->ts_count++;
395 return 1;
370 } 396 }
371 /* Synchronize on PUSI, if required. */ 397 /* Skip to destination of pointer field. */
372 if (priv->need_pusi) { 398 h->from_where = &h->ts[5] + h->ts[4];
373 if (ts[1] & TS_PUSI) { 399 h->ts_remain -= 1 + h->ts[4];
374 /* Find beginning of first ULE SNDU in current TS cell. */ 400 h->skipped = 0;
375 /* Synchronize continuity counter. */ 401 } else {
376 priv->tscc = ts[3] & 0x0F; 402 h->skipped++;
377 /* There is a pointer field here. */ 403 h->ts += TS_SZ;
378 if (ts[4] > ts_remain) { 404 h->priv->ts_count++;
379 printk(KERN_ERR "%lu: Invalid ULE packet " 405 return 1;
380 "(pointer field %d)\n", priv->ts_count, ts[4]); 406 }
381 ts += TS_SZ; 407
382 priv->ts_count++; 408 return 0;
383 continue; 409}
384 } 410
385 /* Skip to destination of pointer field. */ 411static int dvb_net_ule_new_ts(struct dvb_net_ule_handle *h)
386 from_where = &ts[5] + ts[4]; 412{
387 ts_remain -= 1 + ts[4]; 413 /* Check continuity counter. */
388 skipped = 0; 414 if ((h->ts[3] & 0x0F) == h->priv->tscc)
389 } else { 415 h->priv->tscc = (h->priv->tscc + 1) & 0x0F;
390 skipped++; 416 else {
391 ts += TS_SZ; 417 /* TS discontinuity handling: */
392 priv->ts_count++; 418 pr_warn("%lu: TS discontinuity: got %#x, expected %#x.\n",
393 continue; 419 h->priv->ts_count, h->ts[3] & 0x0F,
394 } 420 h->priv->tscc);
421 /* Drop partly decoded SNDU, reset state, resync on PUSI. */
422 if (h->priv->ule_skb) {
423 dev_kfree_skb(h->priv->ule_skb);
424 /* Prepare for next SNDU. */
425 // reset_ule(h->priv); moved to below.
426 h->dev->stats.rx_errors++;
427 h->dev->stats.rx_frame_errors++;
395 } 428 }
429 reset_ule(h->priv);
430 /* skip to next PUSI. */
431 h->priv->need_pusi = 1;
432 return 1;
433 }
434 /*
435 * If we still have an incomplete payload, but PUSI is
436 * set; some TS cells are missing.
437 * This is only possible here, if we missed exactly 16 TS
438 * cells (continuity counter wrap).
439 */
440 if (h->ts[1] & TS_PUSI) {
441 if (!h->priv->need_pusi) {
442 if (!(*h->from_where < (h->ts_remain-1)) ||
443 *h->from_where != h->priv->ule_sndu_remain) {
444 /*
445 * Pointer field is invalid.
446 * Drop this TS cell and any started ULE SNDU.
447 */
448 pr_warn("%lu: Invalid pointer field: %u.\n",
449 h->priv->ts_count,
450 *h->from_where);
396 451
397 if (new_ts) { 452 /*
398 /* Check continuity counter. */ 453 * Drop partly decoded SNDU, reset state,
399 if ((ts[3] & 0x0F) == priv->tscc) 454 * resync on PUSI.
400 priv->tscc = (priv->tscc + 1) & 0x0F; 455 */
401 else { 456 if (h->priv->ule_skb) {
402 /* TS discontinuity handling: */ 457 h->error = true;
403 printk(KERN_WARNING "%lu: TS discontinuity: got %#x, " 458 dev_kfree_skb(h->priv->ule_skb);
404 "expected %#x.\n", priv->ts_count, ts[3] & 0x0F, priv->tscc);
405 /* Drop partly decoded SNDU, reset state, resync on PUSI. */
406 if (priv->ule_skb) {
407 dev_kfree_skb( priv->ule_skb );
408 /* Prepare for next SNDU. */
409 // reset_ule(priv); moved to below.
410 dev->stats.rx_errors++;
411 dev->stats.rx_frame_errors++;
412 } 459 }
413 reset_ule(priv); 460
414 /* skip to next PUSI. */ 461 if (h->error || h->priv->ule_sndu_remain) {
415 priv->need_pusi = 1; 462 h->dev->stats.rx_errors++;
416 continue; 463 h->dev->stats.rx_frame_errors++;
417 } 464 h->error = false;
418 /* If we still have an incomplete payload, but PUSI is
419 * set; some TS cells are missing.
420 * This is only possible here, if we missed exactly 16 TS
421 * cells (continuity counter wrap). */
422 if (ts[1] & TS_PUSI) {
423 if (! priv->need_pusi) {
424 if (!(*from_where < (ts_remain-1)) || *from_where != priv->ule_sndu_remain) {
425 /* Pointer field is invalid. Drop this TS cell and any started ULE SNDU. */
426 printk(KERN_WARNING "%lu: Invalid pointer "
427 "field: %u.\n", priv->ts_count, *from_where);
428
429 /* Drop partly decoded SNDU, reset state, resync on PUSI. */
430 if (priv->ule_skb) {
431 error = true;
432 dev_kfree_skb(priv->ule_skb);
433 }
434
435 if (error || priv->ule_sndu_remain) {
436 dev->stats.rx_errors++;
437 dev->stats.rx_frame_errors++;
438 error = false;
439 }
440
441 reset_ule(priv);
442 priv->need_pusi = 1;
443 continue;
444 }
445 /* Skip pointer field (we're processing a
446 * packed payload). */
447 from_where += 1;
448 ts_remain -= 1;
449 } else
450 priv->need_pusi = 0;
451
452 if (priv->ule_sndu_remain > 183) {
453 /* Current SNDU lacks more data than there could be available in the
454 * current TS cell. */
455 dev->stats.rx_errors++;
456 dev->stats.rx_length_errors++;
457 printk(KERN_WARNING "%lu: Expected %d more SNDU bytes, but "
458 "got PUSI (pf %d, ts_remain %d). Flushing incomplete payload.\n",
459 priv->ts_count, priv->ule_sndu_remain, ts[4], ts_remain);
460 dev_kfree_skb(priv->ule_skb);
461 /* Prepare for next SNDU. */
462 reset_ule(priv);
463 /* Resync: go to where pointer field points to: start of next ULE SNDU. */
464 from_where += ts[4];
465 ts_remain -= ts[4];
466 } 465 }
466
467 reset_ule(h->priv);
468 h->priv->need_pusi = 1;
469 return 1;
467 } 470 }
471 /*
472 * Skip pointer field (we're processing a
473 * packed payload).
474 */
475 h->from_where += 1;
476 h->ts_remain -= 1;
477 } else
478 h->priv->need_pusi = 0;
479
480 if (h->priv->ule_sndu_remain > 183) {
481 /*
482 * Current SNDU lacks more data than there
483 * could be available in the current TS cell.
484 */
485 h->dev->stats.rx_errors++;
486 h->dev->stats.rx_length_errors++;
487 pr_warn("%lu: Expected %d more SNDU bytes, but got PUSI (pf %d, h->ts_remain %d). Flushing incomplete payload.\n",
488 h->priv->ts_count,
489 h->priv->ule_sndu_remain,
490 h->ts[4], h->ts_remain);
491 dev_kfree_skb(h->priv->ule_skb);
492 /* Prepare for next SNDU. */
493 reset_ule(h->priv);
494 /*
495 * Resync: go to where pointer field points to:
496 * start of next ULE SNDU.
497 */
498 h->from_where += h->ts[4];
499 h->ts_remain -= h->ts[4];
468 } 500 }
501 }
502 return 0;
503}
469 504
470 /* Check if new payload needs to be started. */
471 if (priv->ule_skb == NULL) {
472 /* Start a new payload with skb.
473 * Find ULE header. It is only guaranteed that the
474 * length field (2 bytes) is contained in the current
475 * TS.
476 * Check ts_remain has to be >= 2 here. */
477 if (ts_remain < 2) {
478 printk(KERN_WARNING "Invalid payload packing: only %d "
479 "bytes left in TS. Resyncing.\n", ts_remain);
480 priv->ule_sndu_len = 0;
481 priv->need_pusi = 1;
482 ts += TS_SZ;
483 continue;
484 }
485 505
486 if (! priv->ule_sndu_len) { 506/*
487 /* Got at least two bytes, thus extrace the SNDU length. */ 507 * Start a new payload with skb.
488 priv->ule_sndu_len = from_where[0] << 8 | from_where[1]; 508 * Find ULE header. It is only guaranteed that the
489 if (priv->ule_sndu_len & 0x8000) { 509 * length field (2 bytes) is contained in the current
490 /* D-Bit is set: no dest mac present. */ 510 * TS.
491 priv->ule_sndu_len &= 0x7FFF; 511 * Check h.ts_remain has to be >= 2 here.
492 priv->ule_dbit = 1; 512 */
493 } else 513static int dvb_net_ule_new_payload(struct dvb_net_ule_handle *h)
494 priv->ule_dbit = 0; 514{
495 515 if (h->ts_remain < 2) {
496 if (priv->ule_sndu_len < 5) { 516 pr_warn("Invalid payload packing: only %d bytes left in TS. Resyncing.\n",
497 printk(KERN_WARNING "%lu: Invalid ULE SNDU length %u. " 517 h->ts_remain);
498 "Resyncing.\n", priv->ts_count, priv->ule_sndu_len); 518 h->priv->ule_sndu_len = 0;
499 dev->stats.rx_errors++; 519 h->priv->need_pusi = 1;
500 dev->stats.rx_length_errors++; 520 h->ts += TS_SZ;
501 priv->ule_sndu_len = 0; 521 return 1;
502 priv->need_pusi = 1; 522 }
503 new_ts = 1;
504 ts += TS_SZ;
505 priv->ts_count++;
506 continue;
507 }
508 ts_remain -= 2; /* consume the 2 bytes SNDU length. */
509 from_where += 2;
510 }
511 523
512 priv->ule_sndu_remain = priv->ule_sndu_len + 2; 524 if (!h->priv->ule_sndu_len) {
525 /* Got at least two bytes, thus extrace the SNDU length. */
526 h->priv->ule_sndu_len = h->from_where[0] << 8 |
527 h->from_where[1];
528 if (h->priv->ule_sndu_len & 0x8000) {
529 /* D-Bit is set: no dest mac present. */
530 h->priv->ule_sndu_len &= 0x7FFF;
531 h->priv->ule_dbit = 1;
532 } else
533 h->priv->ule_dbit = 0;
534
535 if (h->priv->ule_sndu_len < 5) {
536 pr_warn("%lu: Invalid ULE SNDU length %u. Resyncing.\n",
537 h->priv->ts_count,
538 h->priv->ule_sndu_len);
539 h->dev->stats.rx_errors++;
540 h->dev->stats.rx_length_errors++;
541 h->priv->ule_sndu_len = 0;
542 h->priv->need_pusi = 1;
543 h->new_ts = 1;
544 h->ts += TS_SZ;
545 h->priv->ts_count++;
546 return 1;
547 }
548 h->ts_remain -= 2; /* consume the 2 bytes SNDU length. */
549 h->from_where += 2;
550 }
551
552 h->priv->ule_sndu_remain = h->priv->ule_sndu_len + 2;
553 /*
554 * State of current TS:
555 * h->ts_remain (remaining bytes in the current TS cell)
556 * 0 ule_type is not available now, we need the next TS cell
557 * 1 the first byte of the ule_type is present
558 * >=2 full ULE header present, maybe some payload data as well.
559 */
560 switch (h->ts_remain) {
561 case 1:
562 h->priv->ule_sndu_remain--;
563 h->priv->ule_sndu_type = h->from_where[0] << 8;
564
565 /* first byte of ule_type is set. */
566 h->priv->ule_sndu_type_1 = 1;
567 h->ts_remain -= 1;
568 h->from_where += 1;
569 /* fallthrough */
570 case 0:
571 h->new_ts = 1;
572 h->ts += TS_SZ;
573 h->priv->ts_count++;
574 return 1;
575
576 default: /* complete ULE header is present in current TS. */
577 /* Extract ULE type field. */
578 if (h->priv->ule_sndu_type_1) {
579 h->priv->ule_sndu_type_1 = 0;
580 h->priv->ule_sndu_type |= h->from_where[0];
581 h->from_where += 1; /* points to payload start. */
582 h->ts_remain -= 1;
583 } else {
584 /* Complete type is present in new TS. */
585 h->priv->ule_sndu_type = h->from_where[0] << 8 |
586 h->from_where[1];
587 h->from_where += 2; /* points to payload start. */
588 h->ts_remain -= 2;
589 }
590 break;
591 }
592
593 /*
594 * Allocate the skb (decoder target buffer) with the correct size,
595 * as follows:
596 *
597 * prepare for the largest case: bridged SNDU with MAC address
598 * (dbit = 0).
599 */
600 h->priv->ule_skb = dev_alloc_skb(h->priv->ule_sndu_len +
601 ETH_HLEN + ETH_ALEN);
602 if (!h->priv->ule_skb) {
603 pr_notice("%s: Memory squeeze, dropping packet.\n",
604 h->dev->name);
605 h->dev->stats.rx_dropped++;
606 return -1;
607 }
608
609 /* This includes the CRC32 _and_ dest mac, if !dbit. */
610 h->priv->ule_sndu_remain = h->priv->ule_sndu_len;
611 h->priv->ule_skb->dev = h->dev;
612 /*
613 * Leave space for Ethernet or bridged SNDU header
614 * (eth hdr plus one MAC addr).
615 */
616 skb_reserve(h->priv->ule_skb, ETH_HLEN + ETH_ALEN);
617
618 return 0;
619}
620
621
622static int dvb_net_ule_should_drop(struct dvb_net_ule_handle *h)
623{
624 static const u8 bc_addr[ETH_ALEN] = { [0 ... ETH_ALEN - 1] = 0xff };
625
626 /*
627 * The destination MAC address is the next data in the skb. It comes
628 * before any extension headers.
629 *
630 * Check if the payload of this SNDU should be passed up the stack.
631 */
632 if (h->priv->rx_mode == RX_MODE_PROMISC)
633 return 0;
634
635 if (h->priv->ule_skb->data[0] & 0x01) {
636 /* multicast or broadcast */
637 if (!ether_addr_equal(h->priv->ule_skb->data, bc_addr)) {
638 /* multicast */
639 if (h->priv->rx_mode == RX_MODE_MULTI) {
640 int i;
641
642 for (i = 0; i < h->priv->multi_num &&
643 !ether_addr_equal(h->priv->ule_skb->data,
644 h->priv->multi_macs[i]);
645 i++)
646 ;
647 if (i == h->priv->multi_num)
648 return 1;
649 } else if (h->priv->rx_mode != RX_MODE_ALL_MULTI)
650 return 1; /* no broadcast; */
513 /* 651 /*
514 * State of current TS: 652 * else:
515 * ts_remain (remaining bytes in the current TS cell) 653 * all multicast mode: accept all multicast packets
516 * 0 ule_type is not available now, we need the next TS cell
517 * 1 the first byte of the ule_type is present
518 * >=2 full ULE header present, maybe some payload data as well.
519 */ 654 */
520 switch (ts_remain) { 655 }
521 case 1: 656 /* else: broadcast */
522 priv->ule_sndu_remain--; 657 } else if (!ether_addr_equal(h->priv->ule_skb->data, h->dev->dev_addr))
523 priv->ule_sndu_type = from_where[0] << 8; 658 return 1;
524 priv->ule_sndu_type_1 = 1; /* first byte of ule_type is set. */
525 ts_remain -= 1; from_where += 1;
526 /* Continue w/ next TS. */
527 case 0:
528 new_ts = 1;
529 ts += TS_SZ;
530 priv->ts_count++;
531 continue;
532
533 default: /* complete ULE header is present in current TS. */
534 /* Extract ULE type field. */
535 if (priv->ule_sndu_type_1) {
536 priv->ule_sndu_type_1 = 0;
537 priv->ule_sndu_type |= from_where[0];
538 from_where += 1; /* points to payload start. */
539 ts_remain -= 1;
540 } else {
541 /* Complete type is present in new TS. */
542 priv->ule_sndu_type = from_where[0] << 8 | from_where[1];
543 from_where += 2; /* points to payload start. */
544 ts_remain -= 2;
545 }
546 break;
547 }
548 659
549 /* Allocate the skb (decoder target buffer) with the correct size, as follows: 660 return 0;
550 * prepare for the largest case: bridged SNDU with MAC address (dbit = 0). */ 661}
551 priv->ule_skb = dev_alloc_skb( priv->ule_sndu_len + ETH_HLEN + ETH_ALEN ); 662
552 if (priv->ule_skb == NULL) { 663
553 printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", 664static void dvb_net_ule_check_crc(struct dvb_net_ule_handle *h,
554 dev->name); 665 u32 ule_crc, u32 expected_crc)
555 dev->stats.rx_dropped++; 666{
556 return; 667 u8 dest_addr[ETH_ALEN];
557 } 668
669 if (ule_crc != expected_crc) {
670 pr_warn("%lu: CRC32 check FAILED: %08x / %08x, SNDU len %d type %#x, ts_remain %d, next 2: %x.\n",
671 h->priv->ts_count, ule_crc, expected_crc,
672 h->priv->ule_sndu_len, h->priv->ule_sndu_type,
673 h->ts_remain,
674 h->ts_remain > 2 ?
675 *(unsigned short *)h->from_where : 0);
676
677 #ifdef ULE_DEBUG
678 hexdump(iov[0].iov_base, iov[0].iov_len);
679 hexdump(iov[1].iov_base, iov[1].iov_len);
680 hexdump(iov[2].iov_base, iov[2].iov_len);
681
682 if (h->ule_where == h->ule_hist) {
683 hexdump(&h->ule_hist[98*TS_SZ], TS_SZ);
684 hexdump(&h->ule_hist[99*TS_SZ], TS_SZ);
685 } else if (h->ule_where == &h->ule_hist[TS_SZ]) {
686 hexdump(&h->ule_hist[99*TS_SZ], TS_SZ);
687 hexdump(h->ule_hist, TS_SZ);
688 } else {
689 hexdump(h->ule_where - TS_SZ - TS_SZ, TS_SZ);
690 hexdump(h->ule_where - TS_SZ, TS_SZ);
691 }
692 h->ule_dump = 1;
693 #endif
694
695 h->dev->stats.rx_errors++;
696 h->dev->stats.rx_crc_errors++;
697 dev_kfree_skb(h->priv->ule_skb);
698
699 return;
700 }
701
702 /* CRC32 verified OK. */
703
704 /* CRC32 was OK, so remove it from skb. */
705 h->priv->ule_skb->tail -= 4;
706 h->priv->ule_skb->len -= 4;
707
708 if (!h->priv->ule_dbit) {
709 if (dvb_net_ule_should_drop(h)) {
710#ifdef ULE_DEBUG
711 netdev_dbg(h->dev,
712 "Dropping SNDU: MAC destination address does not match: dest addr: %pM, h->dev addr: %pM\n",
713 h->priv->ule_skb->data, h->dev->dev_addr);
714#endif
715 dev_kfree_skb(h->priv->ule_skb);
716 return;
717 }
718
719 skb_copy_from_linear_data(h->priv->ule_skb, dest_addr,
720 ETH_ALEN);
721 skb_pull(h->priv->ule_skb, ETH_ALEN);
722 }
723
724 /* Handle ULE Extension Headers. */
725 if (h->priv->ule_sndu_type < ETH_P_802_3_MIN) {
726 /* There is an extension header. Handle it accordingly. */
727 int l = handle_ule_extensions(h->priv);
728
729 if (l < 0) {
730 /*
731 * Mandatory extension header unknown or TEST SNDU.
732 * Drop it.
733 */
734
735 // pr_warn("Dropping SNDU, extension headers.\n" );
736 dev_kfree_skb(h->priv->ule_skb);
737 return;
738 }
739 skb_pull(h->priv->ule_skb, l);
740 }
741
742 /*
743 * Construct/assure correct ethernet header.
744 * Note: in bridged mode (h->priv->ule_bridged != 0)
745 * we already have the (original) ethernet
746 * header at the start of the payload (after
747 * optional dest. address and any extension
748 * headers).
749 */
750 if (!h->priv->ule_bridged) {
751 skb_push(h->priv->ule_skb, ETH_HLEN);
752 h->ethh = (struct ethhdr *)h->priv->ule_skb->data;
753 if (!h->priv->ule_dbit) {
754 /*
755 * dest_addr buffer is only valid if
756 * h->priv->ule_dbit == 0
757 */
758 memcpy(h->ethh->h_dest, dest_addr, ETH_ALEN);
759 eth_zero_addr(h->ethh->h_source);
760 } else /* zeroize source and dest */
761 memset(h->ethh, 0, ETH_ALEN * 2);
558 762
559 /* This includes the CRC32 _and_ dest mac, if !dbit. */ 763 h->ethh->h_proto = htons(h->priv->ule_sndu_type);
560 priv->ule_sndu_remain = priv->ule_sndu_len; 764 }
561 priv->ule_skb->dev = dev; 765 /* else: skb is in correct state; nothing to do. */
562 /* Leave space for Ethernet or bridged SNDU header (eth hdr plus one MAC addr). */ 766 h->priv->ule_bridged = 0;
563 skb_reserve( priv->ule_skb, ETH_HLEN + ETH_ALEN ); 767
768 /* Stuff into kernel's protocol stack. */
769 h->priv->ule_skb->protocol = dvb_net_eth_type_trans(h->priv->ule_skb,
770 h->dev);
771 /*
772 * If D-bit is set (i.e. destination MAC address not present),
773 * receive the packet anyhow.
774 */
775#if 0
776 if (h->priv->ule_dbit && skb->pkt_type == PACKET_OTHERHOST)
777 h->priv->ule_skb->pkt_type = PACKET_HOST;
778#endif
779 h->dev->stats.rx_packets++;
780 h->dev->stats.rx_bytes += h->priv->ule_skb->len;
781 netif_rx(h->priv->ule_skb);
782}
783
784static void dvb_net_ule(struct net_device *dev, const u8 *buf, size_t buf_len)
785{
786 int ret;
787 struct dvb_net_ule_handle h = {
788 .dev = dev,
789 .buf = buf,
790 .buf_len = buf_len,
791 .skipped = 0L,
792 .ts = NULL,
793 .ts_end = NULL,
794 .from_where = NULL,
795 .ts_remain = 0,
796 .how_much = 0,
797 .new_ts = 1,
798 .ethh = NULL,
799 .error = false,
800#ifdef ULE_DEBUG
801 .ule_where = ule_hist,
802#endif
803 };
804
805 /*
806 * For all TS cells in current buffer.
807 * Appearently, we are called for every single TS cell.
808 */
809 for (h.ts = h.buf, h.ts_end = h.buf + h.buf_len;
810 h.ts < h.ts_end; /* no incr. */) {
811 if (h.new_ts) {
812 /* We are about to process a new TS cell. */
813 if (dvb_net_ule_new_ts_cell(&h))
814 continue;
815 }
816
817 /* Synchronize on PUSI, if required. */
818 if (h.priv->need_pusi) {
819 if (dvb_net_ule_ts_pusi(&h))
820 continue;
821 }
822
823 if (h.new_ts) {
824 if (dvb_net_ule_new_ts(&h))
825 continue;
826 }
827
828 /* Check if new payload needs to be started. */
829 if (h.priv->ule_skb == NULL) {
830 ret = dvb_net_ule_new_payload(&h);
831 if (ret < 0)
832 return;
833 if (ret)
834 continue;
564 } 835 }
565 836
566 /* Copy data into our current skb. */ 837 /* Copy data into our current skb. */
567 how_much = min(priv->ule_sndu_remain, (int)ts_remain); 838 h.how_much = min(h.priv->ule_sndu_remain, (int)h.ts_remain);
568 memcpy(skb_put(priv->ule_skb, how_much), from_where, how_much); 839 memcpy(skb_put(h.priv->ule_skb, h.how_much),
569 priv->ule_sndu_remain -= how_much; 840 h.from_where, h.how_much);
570 ts_remain -= how_much; 841 h.priv->ule_sndu_remain -= h.how_much;
571 from_where += how_much; 842 h.ts_remain -= h.how_much;
843 h.from_where += h.how_much;
572 844
573 /* Check for complete payload. */ 845 /* Check for complete payload. */
574 if (priv->ule_sndu_remain <= 0) { 846 if (h.priv->ule_sndu_remain <= 0) {
575 /* Check CRC32, we've got it in our skb already. */ 847 /* Check CRC32, we've got it in our skb already. */
576 __be16 ulen = htons(priv->ule_sndu_len); 848 __be16 ulen = htons(h.priv->ule_sndu_len);
577 __be16 utype = htons(priv->ule_sndu_type); 849 __be16 utype = htons(h.priv->ule_sndu_type);
578 const u8 *tail; 850 const u8 *tail;
579 struct kvec iov[3] = { 851 struct kvec iov[3] = {
580 { &ulen, sizeof ulen }, 852 { &ulen, sizeof ulen },
581 { &utype, sizeof utype }, 853 { &utype, sizeof utype },
582 { priv->ule_skb->data, priv->ule_skb->len - 4 } 854 { h.priv->ule_skb->data,
855 h.priv->ule_skb->len - 4 }
583 }; 856 };
584 u32 ule_crc = ~0L, expected_crc; 857 u32 ule_crc = ~0L, expected_crc;
585 if (priv->ule_dbit) { 858 if (h.priv->ule_dbit) {
586 /* Set D-bit for CRC32 verification, 859 /* Set D-bit for CRC32 verification,
587 * if it was set originally. */ 860 * if it was set originally. */
588 ulen |= htons(0x8000); 861 ulen |= htons(0x8000);
589 } 862 }
590 863
591 ule_crc = iov_crc32(ule_crc, iov, 3); 864 ule_crc = iov_crc32(ule_crc, iov, 3);
592 tail = skb_tail_pointer(priv->ule_skb); 865 tail = skb_tail_pointer(h.priv->ule_skb);
593 expected_crc = *(tail - 4) << 24 | 866 expected_crc = *(tail - 4) << 24 |
594 *(tail - 3) << 16 | 867 *(tail - 3) << 16 |
595 *(tail - 2) << 8 | 868 *(tail - 2) << 8 |
596 *(tail - 1); 869 *(tail - 1);
597 if (ule_crc != expected_crc) {
598 printk(KERN_WARNING "%lu: CRC32 check FAILED: %08x / %08x, SNDU len %d type %#x, ts_remain %d, next 2: %x.\n",
599 priv->ts_count, ule_crc, expected_crc, priv->ule_sndu_len, priv->ule_sndu_type, ts_remain, ts_remain > 2 ? *(unsigned short *)from_where : 0);
600 870
601#ifdef ULE_DEBUG 871 dvb_net_ule_check_crc(&h, ule_crc, expected_crc);
602 hexdump( iov[0].iov_base, iov[0].iov_len );
603 hexdump( iov[1].iov_base, iov[1].iov_len );
604 hexdump( iov[2].iov_base, iov[2].iov_len );
605
606 if (ule_where == ule_hist) {
607 hexdump( &ule_hist[98*TS_SZ], TS_SZ );
608 hexdump( &ule_hist[99*TS_SZ], TS_SZ );
609 } else if (ule_where == &ule_hist[TS_SZ]) {
610 hexdump( &ule_hist[99*TS_SZ], TS_SZ );
611 hexdump( ule_hist, TS_SZ );
612 } else {
613 hexdump( ule_where - TS_SZ - TS_SZ, TS_SZ );
614 hexdump( ule_where - TS_SZ, TS_SZ );
615 }
616 ule_dump = 1;
617#endif
618 872
619 dev->stats.rx_errors++;
620 dev->stats.rx_crc_errors++;
621 dev_kfree_skb(priv->ule_skb);
622 } else {
623 /* CRC32 verified OK. */
624 u8 dest_addr[ETH_ALEN];
625 static const u8 bc_addr[ETH_ALEN] =
626 { [ 0 ... ETH_ALEN-1] = 0xff };
627
628 /* CRC32 was OK. Remove it from skb. */
629 priv->ule_skb->tail -= 4;
630 priv->ule_skb->len -= 4;
631
632 if (!priv->ule_dbit) {
633 /*
634 * The destination MAC address is the
635 * next data in the skb. It comes
636 * before any extension headers.
637 *
638 * Check if the payload of this SNDU
639 * should be passed up the stack.
640 */
641 register int drop = 0;
642 if (priv->rx_mode != RX_MODE_PROMISC) {
643 if (priv->ule_skb->data[0] & 0x01) {
644 /* multicast or broadcast */
645 if (!ether_addr_equal(priv->ule_skb->data, bc_addr)) {
646 /* multicast */
647 if (priv->rx_mode == RX_MODE_MULTI) {
648 int i;
649 for(i = 0; i < priv->multi_num &&
650 !ether_addr_equal(priv->ule_skb->data,
651 priv->multi_macs[i]); i++)
652 ;
653 if (i == priv->multi_num)
654 drop = 1;
655 } else if (priv->rx_mode != RX_MODE_ALL_MULTI)
656 drop = 1; /* no broadcast; */
657 /* else: all multicast mode: accept all multicast packets */
658 }
659 /* else: broadcast */
660 }
661 else if (!ether_addr_equal(priv->ule_skb->data, dev->dev_addr))
662 drop = 1;
663 /* else: destination address matches the MAC address of our receiver device */
664 }
665 /* else: promiscuous mode; pass everything up the stack */
666
667 if (drop) {
668#ifdef ULE_DEBUG
669 netdev_dbg(dev, "Dropping SNDU: MAC destination address does not match: dest addr: %pM, dev addr: %pM\n",
670 priv->ule_skb->data, dev->dev_addr);
671#endif
672 dev_kfree_skb(priv->ule_skb);
673 goto sndu_done;
674 }
675 else
676 {
677 skb_copy_from_linear_data(priv->ule_skb,
678 dest_addr,
679 ETH_ALEN);
680 skb_pull(priv->ule_skb, ETH_ALEN);
681 }
682 }
683
684 /* Handle ULE Extension Headers. */
685 if (priv->ule_sndu_type < ETH_P_802_3_MIN) {
686 /* There is an extension header. Handle it accordingly. */
687 int l = handle_ule_extensions(priv);
688 if (l < 0) {
689 /* Mandatory extension header unknown or TEST SNDU. Drop it. */
690 // printk( KERN_WARNING "Dropping SNDU, extension headers.\n" );
691 dev_kfree_skb(priv->ule_skb);
692 goto sndu_done;
693 }
694 skb_pull(priv->ule_skb, l);
695 }
696
697 /*
698 * Construct/assure correct ethernet header.
699 * Note: in bridged mode (priv->ule_bridged !=
700 * 0) we already have the (original) ethernet
701 * header at the start of the payload (after
702 * optional dest. address and any extension
703 * headers).
704 */
705
706 if (!priv->ule_bridged) {
707 skb_push(priv->ule_skb, ETH_HLEN);
708 ethh = (struct ethhdr *)priv->ule_skb->data;
709 if (!priv->ule_dbit) {
710 /* dest_addr buffer is only valid if priv->ule_dbit == 0 */
711 memcpy(ethh->h_dest, dest_addr, ETH_ALEN);
712 eth_zero_addr(ethh->h_source);
713 }
714 else /* zeroize source and dest */
715 memset( ethh, 0, ETH_ALEN*2 );
716
717 ethh->h_proto = htons(priv->ule_sndu_type);
718 }
719 /* else: skb is in correct state; nothing to do. */
720 priv->ule_bridged = 0;
721
722 /* Stuff into kernel's protocol stack. */
723 priv->ule_skb->protocol = dvb_net_eth_type_trans(priv->ule_skb, dev);
724 /* If D-bit is set (i.e. destination MAC address not present),
725 * receive the packet anyhow. */
726 /* if (priv->ule_dbit && skb->pkt_type == PACKET_OTHERHOST)
727 priv->ule_skb->pkt_type = PACKET_HOST; */
728 dev->stats.rx_packets++;
729 dev->stats.rx_bytes += priv->ule_skb->len;
730 netif_rx(priv->ule_skb);
731 }
732 sndu_done:
733 /* Prepare for next SNDU. */ 873 /* Prepare for next SNDU. */
734 reset_ule(priv); 874 reset_ule(h.priv);
735 } 875 }
736 876
737 /* More data in current TS (look at the bytes following the CRC32)? */ 877 /* More data in current TS (look at the bytes following the CRC32)? */
738 if (ts_remain >= 2 && *((unsigned short *)from_where) != 0xFFFF) { 878 if (h.ts_remain >= 2 && *((unsigned short *)h.from_where) != 0xFFFF) {
739 /* Next ULE SNDU starts right there. */ 879 /* Next ULE SNDU starts right there. */
740 new_ts = 0; 880 h.new_ts = 0;
741 priv->ule_skb = NULL; 881 h.priv->ule_skb = NULL;
742 priv->ule_sndu_type_1 = 0; 882 h.priv->ule_sndu_type_1 = 0;
743 priv->ule_sndu_len = 0; 883 h.priv->ule_sndu_len = 0;
744 // printk(KERN_WARNING "More data in current TS: [%#x %#x %#x %#x]\n", 884 // pr_warn("More data in current TS: [%#x %#x %#x %#x]\n",
745 // *(from_where + 0), *(from_where + 1), 885 // *(h.from_where + 0), *(h.from_where + 1),
746 // *(from_where + 2), *(from_where + 3)); 886 // *(h.from_where + 2), *(h.from_where + 3));
747 // printk(KERN_WARNING "ts @ %p, stopped @ %p:\n", ts, from_where + 0); 887 // pr_warn("h.ts @ %p, stopped @ %p:\n", h.ts, h.from_where + 0);
748 // hexdump(ts, 188); 888 // hexdump(h.ts, 188);
749 } else { 889 } else {
750 new_ts = 1; 890 h.new_ts = 1;
751 ts += TS_SZ; 891 h.ts += TS_SZ;
752 priv->ts_count++; 892 h.priv->ts_count++;
753 if (priv->ule_skb == NULL) { 893 if (h.priv->ule_skb == NULL) {
754 priv->need_pusi = 1; 894 h.priv->need_pusi = 1;
755 priv->ule_sndu_type_1 = 0; 895 h.priv->ule_sndu_type_1 = 0;
756 priv->ule_sndu_len = 0; 896 h.priv->ule_sndu_len = 0;
757 } 897 }
758 } 898 }
759 } /* for all available TS cells */ 899 } /* for all available TS cells */
@@ -766,10 +906,10 @@ static int dvb_net_ts_callback(const u8 *buffer1, size_t buffer1_len,
766 struct net_device *dev = feed->priv; 906 struct net_device *dev = feed->priv;
767 907
768 if (buffer2) 908 if (buffer2)
769 printk(KERN_WARNING "buffer2 not NULL: %p.\n", buffer2); 909 pr_warn("buffer2 not NULL: %p.\n", buffer2);
770 if (buffer1_len > 32768) 910 if (buffer1_len > 32768)
771 printk(KERN_WARNING "length > 32k: %zu.\n", buffer1_len); 911 pr_warn("length > 32k: %zu.\n", buffer1_len);
772 /* printk("TS callback: %u bytes, %u TS cells @ %p.\n", 912 /* pr_info("TS callback: %u bytes, %u TS cells @ %p.\n",
773 buffer1_len, buffer1_len / TS_SZ, buffer1); */ 913 buffer1_len, buffer1_len / TS_SZ, buffer1); */
774 dvb_net_ule(dev, buffer1, buffer1_len); 914 dvb_net_ule(dev, buffer1, buffer1_len);
775 return 0; 915 return 0;
@@ -786,7 +926,7 @@ static void dvb_net_sec(struct net_device *dev,
786 926
787 /* note: pkt_len includes a 32bit checksum */ 927 /* note: pkt_len includes a 32bit checksum */
788 if (pkt_len < 16) { 928 if (pkt_len < 16) {
789 printk("%s: IP/MPE packet length = %d too small.\n", 929 pr_warn("%s: IP/MPE packet length = %d too small.\n",
790 dev->name, pkt_len); 930 dev->name, pkt_len);
791 stats->rx_errors++; 931 stats->rx_errors++;
792 stats->rx_length_errors++; 932 stats->rx_length_errors++;
@@ -824,7 +964,7 @@ static void dvb_net_sec(struct net_device *dev,
824 * 12 byte MPE header; 4 byte checksum; + 2 byte alignment, 8 byte LLC/SNAP 964 * 12 byte MPE header; 4 byte checksum; + 2 byte alignment, 8 byte LLC/SNAP
825 */ 965 */
826 if (!(skb = dev_alloc_skb(pkt_len - 4 - 12 + 14 + 2 - snap))) { 966 if (!(skb = dev_alloc_skb(pkt_len - 4 - 12 + 14 + 2 - snap))) {
827 //printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name); 967 //pr_notice("%s: Memory squeeze, dropping packet.\n", dev->name);
828 stats->rx_dropped++; 968 stats->rx_dropped++;
829 return; 969 return;
830 } 970 }
@@ -903,7 +1043,7 @@ static int dvb_net_filter_sec_set(struct net_device *dev,
903 *secfilter=NULL; 1043 *secfilter=NULL;
904 ret = priv->secfeed->allocate_filter(priv->secfeed, secfilter); 1044 ret = priv->secfeed->allocate_filter(priv->secfeed, secfilter);
905 if (ret<0) { 1045 if (ret<0) {
906 printk("%s: could not get filter\n", dev->name); 1046 pr_err("%s: could not get filter\n", dev->name);
907 return ret; 1047 return ret;
908 } 1048 }
909 1049
@@ -944,7 +1084,7 @@ static int dvb_net_feed_start(struct net_device *dev)
944 netdev_dbg(dev, "rx_mode %i\n", priv->rx_mode); 1084 netdev_dbg(dev, "rx_mode %i\n", priv->rx_mode);
945 mutex_lock(&priv->mutex); 1085 mutex_lock(&priv->mutex);
946 if (priv->tsfeed || priv->secfeed || priv->secfilter || priv->multi_secfilter[0]) 1086 if (priv->tsfeed || priv->secfeed || priv->secfilter || priv->multi_secfilter[0])
947 printk("%s: BUG %d\n", __func__, __LINE__); 1087 pr_err("%s: BUG %d\n", __func__, __LINE__);
948 1088
949 priv->secfeed=NULL; 1089 priv->secfeed=NULL;
950 priv->secfilter=NULL; 1090 priv->secfilter=NULL;
@@ -955,14 +1095,15 @@ static int dvb_net_feed_start(struct net_device *dev)
955 ret=demux->allocate_section_feed(demux, &priv->secfeed, 1095 ret=demux->allocate_section_feed(demux, &priv->secfeed,
956 dvb_net_sec_callback); 1096 dvb_net_sec_callback);
957 if (ret<0) { 1097 if (ret<0) {
958 printk("%s: could not allocate section feed\n", dev->name); 1098 pr_err("%s: could not allocate section feed\n",
1099 dev->name);
959 goto error; 1100 goto error;
960 } 1101 }
961 1102
962 ret = priv->secfeed->set(priv->secfeed, priv->pid, 32768, 1); 1103 ret = priv->secfeed->set(priv->secfeed, priv->pid, 1);
963 1104
964 if (ret<0) { 1105 if (ret<0) {
965 printk("%s: could not set section feed\n", dev->name); 1106 pr_err("%s: could not set section feed\n", dev->name);
966 priv->demux->release_section_feed(priv->demux, priv->secfeed); 1107 priv->demux->release_section_feed(priv->demux, priv->secfeed);
967 priv->secfeed=NULL; 1108 priv->secfeed=NULL;
968 goto error; 1109 goto error;
@@ -1003,7 +1144,7 @@ static int dvb_net_feed_start(struct net_device *dev)
1003 netdev_dbg(dev, "alloc tsfeed\n"); 1144 netdev_dbg(dev, "alloc tsfeed\n");
1004 ret = demux->allocate_ts_feed(demux, &priv->tsfeed, dvb_net_ts_callback); 1145 ret = demux->allocate_ts_feed(demux, &priv->tsfeed, dvb_net_ts_callback);
1005 if (ret < 0) { 1146 if (ret < 0) {
1006 printk("%s: could not allocate ts feed\n", dev->name); 1147 pr_err("%s: could not allocate ts feed\n", dev->name);
1007 goto error; 1148 goto error;
1008 } 1149 }
1009 1150
@@ -1013,12 +1154,11 @@ static int dvb_net_feed_start(struct net_device *dev)
1013 priv->pid, /* pid */ 1154 priv->pid, /* pid */
1014 TS_PACKET, /* type */ 1155 TS_PACKET, /* type */
1015 DMX_PES_OTHER, /* pes type */ 1156 DMX_PES_OTHER, /* pes type */
1016 32768, /* circular buffer size */
1017 timeout /* timeout */ 1157 timeout /* timeout */
1018 ); 1158 );
1019 1159
1020 if (ret < 0) { 1160 if (ret < 0) {
1021 printk("%s: could not set ts feed\n", dev->name); 1161 pr_err("%s: could not set ts feed\n", dev->name);
1022 priv->demux->release_ts_feed(priv->demux, priv->tsfeed); 1162 priv->demux->release_ts_feed(priv->demux, priv->tsfeed);
1023 priv->tsfeed = NULL; 1163 priv->tsfeed = NULL;
1024 goto error; 1164 goto error;
@@ -1067,7 +1207,7 @@ static int dvb_net_feed_stop(struct net_device *dev)
1067 priv->demux->release_section_feed(priv->demux, priv->secfeed); 1207 priv->demux->release_section_feed(priv->demux, priv->secfeed);
1068 priv->secfeed = NULL; 1208 priv->secfeed = NULL;
1069 } else 1209 } else
1070 printk("%s: no feed to stop\n", dev->name); 1210 pr_err("%s: no feed to stop\n", dev->name);
1071 } else if (priv->feedtype == DVB_NET_FEEDTYPE_ULE) { 1211 } else if (priv->feedtype == DVB_NET_FEEDTYPE_ULE) {
1072 if (priv->tsfeed) { 1212 if (priv->tsfeed) {
1073 if (priv->tsfeed->is_filtering) { 1213 if (priv->tsfeed->is_filtering) {
@@ -1078,7 +1218,7 @@ static int dvb_net_feed_stop(struct net_device *dev)
1078 priv->tsfeed = NULL; 1218 priv->tsfeed = NULL;
1079 } 1219 }
1080 else 1220 else
1081 printk("%s: no ts feed to stop\n", dev->name); 1221 pr_err("%s: no ts feed to stop\n", dev->name);
1082 } else 1222 } else
1083 ret = -EINVAL; 1223 ret = -EINVAL;
1084 mutex_unlock(&priv->mutex); 1224 mutex_unlock(&priv->mutex);
@@ -1279,7 +1419,7 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
1279 free_netdev(net); 1419 free_netdev(net);
1280 return result; 1420 return result;
1281 } 1421 }
1282 printk("dvb_net: created network interface %s\n", net->name); 1422 pr_info("created network interface %s\n", net->name);
1283 1423
1284 return if_num; 1424 return if_num;
1285} 1425}
@@ -1298,7 +1438,7 @@ static int dvb_net_remove_if(struct dvb_net *dvbnet, unsigned long num)
1298 dvb_net_stop(net); 1438 dvb_net_stop(net);
1299 flush_work(&priv->set_multicast_list_wq); 1439 flush_work(&priv->set_multicast_list_wq);
1300 flush_work(&priv->restart_net_feed_wq); 1440 flush_work(&priv->restart_net_feed_wq);
1301 printk("dvb_net: removed network interface %s\n", net->name); 1441 pr_info("removed network interface %s\n", net->name);
1302 unregister_netdev(net); 1442 unregister_netdev(net);
1303 dvbnet->state[num]=0; 1443 dvbnet->state[num]=0;
1304 dvbnet->device[num] = NULL; 1444 dvbnet->device[num] = NULL;
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 75a3f4b57fd4..38c844667789 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -21,6 +21,8 @@
21 * 21 *
22 */ 22 */
23 23
24#define pr_fmt(fmt) "dvbdev: " fmt
25
24#include <linux/types.h> 26#include <linux/types.h>
25#include <linux/errno.h> 27#include <linux/errno.h>
26#include <linux/string.h> 28#include <linux/string.h>
@@ -43,7 +45,11 @@ static int dvbdev_debug;
43module_param(dvbdev_debug, int, 0644); 45module_param(dvbdev_debug, int, 0644);
44MODULE_PARM_DESC(dvbdev_debug, "Turn on/off device debugging (default:off)."); 46MODULE_PARM_DESC(dvbdev_debug, "Turn on/off device debugging (default:off).");
45 47
46#define dprintk if (dvbdev_debug) printk 48#define dprintk(fmt, arg...) do { \
49 if (dvbdev_debug) \
50 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
51 __func__, ##arg); \
52} while (0)
47 53
48static LIST_HEAD(dvb_adapter_list); 54static LIST_HEAD(dvb_adapter_list);
49static DEFINE_MUTEX(dvbdev_register_lock); 55static DEFINE_MUTEX(dvbdev_register_lock);
@@ -354,7 +360,7 @@ static int dvb_create_media_entity(struct dvb_device *dvbdev,
354 if (ret) 360 if (ret)
355 return ret; 361 return ret;
356 362
357 printk(KERN_DEBUG "%s: media entity '%s' registered.\n", 363 pr_info("%s: media entity '%s' registered.\n",
358 __func__, dvbdev->entity->name); 364 __func__, dvbdev->entity->name);
359 365
360 return 0; 366 return 0;
@@ -438,7 +444,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
438 if ((id = dvbdev_get_free_id (adap, type)) < 0){ 444 if ((id = dvbdev_get_free_id (adap, type)) < 0){
439 mutex_unlock(&dvbdev_register_lock); 445 mutex_unlock(&dvbdev_register_lock);
440 *pdvbdev = NULL; 446 *pdvbdev = NULL;
441 printk(KERN_ERR "%s: couldn't find free device id\n", __func__); 447 pr_err("%s: couldn't find free device id\n", __func__);
442 return -ENFILE; 448 return -ENFILE;
443 } 449 }
444 450
@@ -493,8 +499,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
493 499
494 ret = dvb_register_media_device(dvbdev, type, minor, demux_sink_pads); 500 ret = dvb_register_media_device(dvbdev, type, minor, demux_sink_pads);
495 if (ret) { 501 if (ret) {
496 printk(KERN_ERR 502 pr_err("%s: dvb_register_media_device failed to create the mediagraph\n",
497 "%s: dvb_register_media_device failed to create the mediagraph\n",
498 __func__); 503 __func__);
499 504
500 dvb_media_device_free(dvbdev); 505 dvb_media_device_free(dvbdev);
@@ -511,11 +516,11 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
511 MKDEV(DVB_MAJOR, minor), 516 MKDEV(DVB_MAJOR, minor),
512 dvbdev, "dvb%d.%s%d", adap->num, dnames[type], id); 517 dvbdev, "dvb%d.%s%d", adap->num, dnames[type], id);
513 if (IS_ERR(clsdev)) { 518 if (IS_ERR(clsdev)) {
514 printk(KERN_ERR "%s: failed to create device dvb%d.%s%d (%ld)\n", 519 pr_err("%s: failed to create device dvb%d.%s%d (%ld)\n",
515 __func__, adap->num, dnames[type], id, PTR_ERR(clsdev)); 520 __func__, adap->num, dnames[type], id, PTR_ERR(clsdev));
516 return PTR_ERR(clsdev); 521 return PTR_ERR(clsdev);
517 } 522 }
518 dprintk(KERN_DEBUG "DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n", 523 dprintk("DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n",
519 adap->num, dnames[type], id, minor, minor); 524 adap->num, dnames[type], id, minor, minor);
520 525
521 return 0; 526 return 0;
@@ -523,7 +528,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
523EXPORT_SYMBOL(dvb_register_device); 528EXPORT_SYMBOL(dvb_register_device);
524 529
525 530
526void dvb_unregister_device(struct dvb_device *dvbdev) 531void dvb_remove_device(struct dvb_device *dvbdev)
527{ 532{
528 if (!dvbdev) 533 if (!dvbdev)
529 return; 534 return;
@@ -537,9 +542,26 @@ void dvb_unregister_device(struct dvb_device *dvbdev)
537 device_destroy(dvb_class, MKDEV(DVB_MAJOR, dvbdev->minor)); 542 device_destroy(dvb_class, MKDEV(DVB_MAJOR, dvbdev->minor));
538 543
539 list_del (&dvbdev->list_head); 544 list_del (&dvbdev->list_head);
545}
546EXPORT_SYMBOL(dvb_remove_device);
547
548
549void dvb_free_device(struct dvb_device *dvbdev)
550{
551 if (!dvbdev)
552 return;
553
540 kfree (dvbdev->fops); 554 kfree (dvbdev->fops);
541 kfree (dvbdev); 555 kfree (dvbdev);
542} 556}
557EXPORT_SYMBOL(dvb_free_device);
558
559
560void dvb_unregister_device(struct dvb_device *dvbdev)
561{
562 dvb_remove_device(dvbdev);
563 dvb_free_device(dvbdev);
564}
543EXPORT_SYMBOL(dvb_unregister_device); 565EXPORT_SYMBOL(dvb_unregister_device);
544 566
545 567
@@ -808,7 +830,7 @@ int dvb_register_adapter(struct dvb_adapter *adap, const char *name,
808 memset (adap, 0, sizeof(struct dvb_adapter)); 830 memset (adap, 0, sizeof(struct dvb_adapter));
809 INIT_LIST_HEAD (&adap->device_list); 831 INIT_LIST_HEAD (&adap->device_list);
810 832
811 printk(KERN_INFO "DVB: registering new adapter (%s)\n", name); 833 pr_info("DVB: registering new adapter (%s)\n", name);
812 834
813 adap->num = num; 835 adap->num = num;
814 adap->name = name; 836 adap->name = name;
@@ -926,13 +948,13 @@ static int __init init_dvbdev(void)
926 dev_t dev = MKDEV(DVB_MAJOR, 0); 948 dev_t dev = MKDEV(DVB_MAJOR, 0);
927 949
928 if ((retval = register_chrdev_region(dev, MAX_DVB_MINORS, "DVB")) != 0) { 950 if ((retval = register_chrdev_region(dev, MAX_DVB_MINORS, "DVB")) != 0) {
929 printk(KERN_ERR "dvb-core: unable to get major %d\n", DVB_MAJOR); 951 pr_err("dvb-core: unable to get major %d\n", DVB_MAJOR);
930 return retval; 952 return retval;
931 } 953 }
932 954
933 cdev_init(&dvb_device_cdev, &dvb_device_fops); 955 cdev_init(&dvb_device_cdev, &dvb_device_fops);
934 if ((retval = cdev_add(&dvb_device_cdev, dev, MAX_DVB_MINORS)) != 0) { 956 if ((retval = cdev_add(&dvb_device_cdev, dev, MAX_DVB_MINORS)) != 0) {
935 printk(KERN_ERR "dvb-core: unable register character device\n"); 957 pr_err("dvb-core: unable register character device\n");
936 goto error; 958 goto error;
937 } 959 }
938 960
diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h
index 4aff7bd3dea8..8c0a7b51555e 100644
--- a/drivers/media/dvb-core/dvbdev.h
+++ b/drivers/media/dvb-core/dvbdev.h
@@ -34,7 +34,7 @@
34#if defined(CONFIG_DVB_MAX_ADAPTERS) && CONFIG_DVB_MAX_ADAPTERS > 0 34#if defined(CONFIG_DVB_MAX_ADAPTERS) && CONFIG_DVB_MAX_ADAPTERS > 0
35 #define DVB_MAX_ADAPTERS CONFIG_DVB_MAX_ADAPTERS 35 #define DVB_MAX_ADAPTERS CONFIG_DVB_MAX_ADAPTERS
36#else 36#else
37 #define DVB_MAX_ADAPTERS 8 37 #define DVB_MAX_ADAPTERS 16
38#endif 38#endif
39 39
40#define DVB_UNSET (-1) 40#define DVB_UNSET (-1)
@@ -212,8 +212,31 @@ int dvb_register_device(struct dvb_adapter *adap,
212 int demux_sink_pads); 212 int demux_sink_pads);
213 213
214/** 214/**
215 * dvb_remove_device - Remove a registered DVB device
216 *
217 * This does not free memory. To do that, call dvb_free_device().
218 *
219 * @dvbdev: pointer to struct dvb_device
220 */
221void dvb_remove_device(struct dvb_device *dvbdev);
222
223/**
224 * dvb_free_device - Free memory occupied by a DVB device.
225 *
226 * Call dvb_unregister_device() before calling this function.
227 *
228 * @dvbdev: pointer to struct dvb_device
229 */
230void dvb_free_device(struct dvb_device *dvbdev);
231
232/**
215 * dvb_unregister_device - Unregisters a DVB device 233 * dvb_unregister_device - Unregisters a DVB device
216 * 234 *
235 * This is a combination of dvb_remove_device() and dvb_free_device().
236 * Using this function is usually a mistake, and is often an indicator
237 * for a use-after-free bug (when a userspace process keeps a file
238 * handle to a detached device).
239 *
217 * @dvbdev: pointer to struct dvb_device 240 * @dvbdev: pointer to struct dvb_device
218 */ 241 */
219void dvb_unregister_device(struct dvb_device *dvbdev); 242void dvb_unregister_device(struct dvb_device *dvbdev);
diff --git a/drivers/media/dvb-frontends/Kconfig b/drivers/media/dvb-frontends/Kconfig
index b71b747ee0ba..c841fa1770be 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -642,7 +642,7 @@ config DVB_S5H1409
642 to support this frontend. 642 to support this frontend.
643 643
644config DVB_AU8522 644config DVB_AU8522
645 depends on I2C 645 depends on DVB_CORE && I2C
646 tristate 646 tristate
647 647
648config DVB_AU8522_DTV 648config DVB_AU8522_DTV
@@ -656,7 +656,7 @@ config DVB_AU8522_DTV
656 656
657config DVB_AU8522_V4L 657config DVB_AU8522_V4L
658 tristate "Auvitek AU8522 based ATV demod" 658 tristate "Auvitek AU8522 based ATV demod"
659 depends on VIDEO_V4L2 && I2C 659 depends on VIDEO_V4L2 && DVB_CORE && I2C
660 select DVB_AU8522 660 select DVB_AU8522
661 default m if !MEDIA_SUBDRV_AUTOSELECT 661 default m if !MEDIA_SUBDRV_AUTOSELECT
662 help 662 help
@@ -722,7 +722,7 @@ config DVB_PLL
722 722
723config DVB_TUNER_DIB0070 723config DVB_TUNER_DIB0070
724 tristate "DiBcom DiB0070 silicon base-band tuner" 724 tristate "DiBcom DiB0070 silicon base-band tuner"
725 depends on I2C 725 depends on DVB_CORE && I2C
726 default m if !MEDIA_SUBDRV_AUTOSELECT 726 default m if !MEDIA_SUBDRV_AUTOSELECT
727 help 727 help
728 A driver for the silicon baseband tuner DiB0070 from DiBcom. 728 A driver for the silicon baseband tuner DiB0070 from DiBcom.
@@ -731,7 +731,7 @@ config DVB_TUNER_DIB0070
731 731
732config DVB_TUNER_DIB0090 732config DVB_TUNER_DIB0090
733 tristate "DiBcom DiB0090 silicon base-band tuner" 733 tristate "DiBcom DiB0090 silicon base-band tuner"
734 depends on I2C 734 depends on DVB_CORE && I2C
735 default m if !MEDIA_SUBDRV_AUTOSELECT 735 default m if !MEDIA_SUBDRV_AUTOSELECT
736 help 736 help
737 A driver for the silicon baseband tuner DiB0090 from DiBcom. 737 A driver for the silicon baseband tuner DiB0090 from DiBcom.
@@ -879,5 +879,6 @@ comment "Tools to develop new frontends"
879 879
880config DVB_DUMMY_FE 880config DVB_DUMMY_FE
881 tristate "Dummy frontend driver" 881 tristate "Dummy frontend driver"
882 depends on DVB_CORE
882 default n 883 default n
883endmenu 884endmenu
diff --git a/drivers/media/dvb-frontends/af9013.c b/drivers/media/dvb-frontends/af9013.c
index 8bcde336ffd7..c6cb3bbc912a 100644
--- a/drivers/media/dvb-frontends/af9013.c
+++ b/drivers/media/dvb-frontends/af9013.c
@@ -1351,7 +1351,7 @@ static void af9013_release(struct dvb_frontend *fe)
1351 kfree(state); 1351 kfree(state);
1352} 1352}
1353 1353
1354static struct dvb_frontend_ops af9013_ops; 1354static const struct dvb_frontend_ops af9013_ops;
1355 1355
1356static int af9013_download_firmware(struct af9013_state *state) 1356static int af9013_download_firmware(struct af9013_state *state)
1357{ 1357{
@@ -1516,7 +1516,7 @@ err:
1516} 1516}
1517EXPORT_SYMBOL(af9013_attach); 1517EXPORT_SYMBOL(af9013_attach);
1518 1518
1519static struct dvb_frontend_ops af9013_ops = { 1519static const struct dvb_frontend_ops af9013_ops = {
1520 .delsys = { SYS_DVBT }, 1520 .delsys = { SYS_DVBT },
1521 .info = { 1521 .info = {
1522 .name = "Afatech AF9013", 1522 .name = "Afatech AF9013",
diff --git a/drivers/media/dvb-frontends/af9033.c b/drivers/media/dvb-frontends/af9033.c
index 9a8157a5f49d..f8818028752e 100644
--- a/drivers/media/dvb-frontends/af9033.c
+++ b/drivers/media/dvb-frontends/af9033.c
@@ -1198,7 +1198,7 @@ err:
1198 return ret; 1198 return ret;
1199} 1199}
1200 1200
1201static struct dvb_frontend_ops af9033_ops = { 1201static const struct dvb_frontend_ops af9033_ops = {
1202 .delsys = { SYS_DVBT }, 1202 .delsys = { SYS_DVBT },
1203 .info = { 1203 .info = {
1204 .name = "Afatech AF9033 (DVB-T)", 1204 .name = "Afatech AF9033 (DVB-T)",
diff --git a/drivers/media/dvb-frontends/as102_fe.c b/drivers/media/dvb-frontends/as102_fe.c
index 9412fcd1bddb..98d575f2744c 100644
--- a/drivers/media/dvb-frontends/as102_fe.c
+++ b/drivers/media/dvb-frontends/as102_fe.c
@@ -415,7 +415,7 @@ static void as102_fe_release(struct dvb_frontend *fe)
415} 415}
416 416
417 417
418static struct dvb_frontend_ops as102_fe_ops = { 418static const struct dvb_frontend_ops as102_fe_ops = {
419 .delsys = { SYS_DVBT }, 419 .delsys = { SYS_DVBT },
420 .info = { 420 .info = {
421 .name = "Abilis AS102 DVB-T", 421 .name = "Abilis AS102 DVB-T",
diff --git a/drivers/media/dvb-frontends/ascot2e.c b/drivers/media/dvb-frontends/ascot2e.c
index ad304eed656d..0ee0df53b91b 100644
--- a/drivers/media/dvb-frontends/ascot2e.c
+++ b/drivers/media/dvb-frontends/ascot2e.c
@@ -254,14 +254,13 @@ static int ascot2e_init(struct dvb_frontend *fe)
254 return ascot2e_leave_power_save(priv); 254 return ascot2e_leave_power_save(priv);
255} 255}
256 256
257static int ascot2e_release(struct dvb_frontend *fe) 257static void ascot2e_release(struct dvb_frontend *fe)
258{ 258{
259 struct ascot2e_priv *priv = fe->tuner_priv; 259 struct ascot2e_priv *priv = fe->tuner_priv;
260 260
261 dev_dbg(&priv->i2c->dev, "%s()\n", __func__); 261 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
262 kfree(fe->tuner_priv); 262 kfree(fe->tuner_priv);
263 fe->tuner_priv = NULL; 263 fe->tuner_priv = NULL;
264 return 0;
265} 264}
266 265
267static int ascot2e_sleep(struct dvb_frontend *fe) 266static int ascot2e_sleep(struct dvb_frontend *fe)
diff --git a/drivers/media/dvb-frontends/atbm8830.c b/drivers/media/dvb-frontends/atbm8830.c
index 47248b868e38..07ce05578278 100644
--- a/drivers/media/dvb-frontends/atbm8830.c
+++ b/drivers/media/dvb-frontends/atbm8830.c
@@ -428,7 +428,7 @@ static int atbm8830_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
428 return atbm8830_write_reg(priv, REG_I2C_GATE, enable ? 1 : 0); 428 return atbm8830_write_reg(priv, REG_I2C_GATE, enable ? 1 : 0);
429} 429}
430 430
431static struct dvb_frontend_ops atbm8830_ops = { 431static const struct dvb_frontend_ops atbm8830_ops = {
432 .delsys = { SYS_DTMB }, 432 .delsys = { SYS_DTMB },
433 .info = { 433 .info = {
434 .name = "AltoBeam ATBM8830/8831 DMB-TH", 434 .name = "AltoBeam ATBM8830/8831 DMB-TH",
diff --git a/drivers/media/dvb-frontends/au8522_common.c b/drivers/media/dvb-frontends/au8522_common.c
index f135126bc373..cf4ac240a01f 100644
--- a/drivers/media/dvb-frontends/au8522_common.c
+++ b/drivers/media/dvb-frontends/au8522_common.c
@@ -50,8 +50,8 @@ int au8522_writereg(struct au8522_state *state, u16 reg, u8 data)
50 ret = i2c_transfer(state->i2c, &msg, 1); 50 ret = i2c_transfer(state->i2c, &msg, 1);
51 51
52 if (ret != 1) 52 if (ret != 1)
53 printk("%s: writereg error (reg == 0x%02x, val == 0x%04x, " 53 printk("%s: writereg error (reg == 0x%02x, val == 0x%04x, ret == %i)\n",
54 "ret == %i)\n", __func__, reg, data, ret); 54 __func__, reg, data, ret);
55 55
56 return (ret != 1) ? -1 : 0; 56 return (ret != 1) ? -1 : 0;
57} 57}
diff --git a/drivers/media/dvb-frontends/au8522_dig.c b/drivers/media/dvb-frontends/au8522_dig.c
index e676b9461a59..7ed326e43fc4 100644
--- a/drivers/media/dvb-frontends/au8522_dig.c
+++ b/drivers/media/dvb-frontends/au8522_dig.c
@@ -834,7 +834,7 @@ static int au8522_get_tune_settings(struct dvb_frontend *fe,
834 return 0; 834 return 0;
835} 835}
836 836
837static struct dvb_frontend_ops au8522_ops; 837static const struct dvb_frontend_ops au8522_ops;
838 838
839 839
840static void au8522_release(struct dvb_frontend *fe) 840static void au8522_release(struct dvb_frontend *fe)
@@ -894,7 +894,7 @@ error:
894} 894}
895EXPORT_SYMBOL(au8522_attach); 895EXPORT_SYMBOL(au8522_attach);
896 896
897static struct dvb_frontend_ops au8522_ops = { 897static const struct dvb_frontend_ops au8522_ops = {
898 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B }, 898 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
899 .info = { 899 .info = {
900 .name = "Auvitek AU8522 QAM/8VSB Frontend", 900 .name = "Auvitek AU8522 QAM/8VSB Frontend",
diff --git a/drivers/media/dvb-frontends/bcm3510.c b/drivers/media/dvb-frontends/bcm3510.c
index bb698839e477..617c5e29f919 100644
--- a/drivers/media/dvb-frontends/bcm3510.c
+++ b/drivers/media/dvb-frontends/bcm3510.c
@@ -788,7 +788,7 @@ static int bcm3510_init(struct dvb_frontend* fe)
788} 788}
789 789
790 790
791static struct dvb_frontend_ops bcm3510_ops; 791static const struct dvb_frontend_ops bcm3510_ops;
792 792
793struct dvb_frontend* bcm3510_attach(const struct bcm3510_config *config, 793struct dvb_frontend* bcm3510_attach(const struct bcm3510_config *config,
794 struct i2c_adapter *i2c) 794 struct i2c_adapter *i2c)
@@ -834,7 +834,7 @@ error:
834} 834}
835EXPORT_SYMBOL(bcm3510_attach); 835EXPORT_SYMBOL(bcm3510_attach);
836 836
837static struct dvb_frontend_ops bcm3510_ops = { 837static const struct dvb_frontend_ops bcm3510_ops = {
838 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B }, 838 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
839 .info = { 839 .info = {
840 .name = "Broadcom BCM3510 VSB/QAM frontend", 840 .name = "Broadcom BCM3510 VSB/QAM frontend",
diff --git a/drivers/media/dvb-frontends/cx22700.c b/drivers/media/dvb-frontends/cx22700.c
index 5cad925609e0..2b629e23ceeb 100644
--- a/drivers/media/dvb-frontends/cx22700.c
+++ b/drivers/media/dvb-frontends/cx22700.c
@@ -380,7 +380,7 @@ static void cx22700_release(struct dvb_frontend* fe)
380 kfree(state); 380 kfree(state);
381} 381}
382 382
383static struct dvb_frontend_ops cx22700_ops; 383static const struct dvb_frontend_ops cx22700_ops;
384 384
385struct dvb_frontend* cx22700_attach(const struct cx22700_config* config, 385struct dvb_frontend* cx22700_attach(const struct cx22700_config* config,
386 struct i2c_adapter* i2c) 386 struct i2c_adapter* i2c)
@@ -408,7 +408,7 @@ error:
408 return NULL; 408 return NULL;
409} 409}
410 410
411static struct dvb_frontend_ops cx22700_ops = { 411static const struct dvb_frontend_ops cx22700_ops = {
412 .delsys = { SYS_DVBT }, 412 .delsys = { SYS_DVBT },
413 .info = { 413 .info = {
414 .name = "Conexant CX22700 DVB-T", 414 .name = "Conexant CX22700 DVB-T",
diff --git a/drivers/media/dvb-frontends/cx24110.c b/drivers/media/dvb-frontends/cx24110.c
index 6cb81ec12847..cf1bc99d1f32 100644
--- a/drivers/media/dvb-frontends/cx24110.c
+++ b/drivers/media/dvb-frontends/cx24110.c
@@ -120,8 +120,8 @@ static int cx24110_writereg (struct cx24110_state* state, int reg, int data)
120 int err; 120 int err;
121 121
122 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { 122 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
123 dprintk ("%s: writereg error (err == %i, reg == 0x%02x," 123 dprintk("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n",
124 " data == 0x%02x)\n", __func__, err, reg, data); 124 __func__, err, reg, data);
125 return -EREMOTEIO; 125 return -EREMOTEIO;
126 } 126 }
127 127
@@ -592,7 +592,7 @@ static void cx24110_release(struct dvb_frontend* fe)
592 kfree(state); 592 kfree(state);
593} 593}
594 594
595static struct dvb_frontend_ops cx24110_ops; 595static const struct dvb_frontend_ops cx24110_ops;
596 596
597struct dvb_frontend* cx24110_attach(const struct cx24110_config* config, 597struct dvb_frontend* cx24110_attach(const struct cx24110_config* config,
598 struct i2c_adapter* i2c) 598 struct i2c_adapter* i2c)
@@ -625,7 +625,7 @@ error:
625 return NULL; 625 return NULL;
626} 626}
627 627
628static struct dvb_frontend_ops cx24110_ops = { 628static const struct dvb_frontend_ops cx24110_ops = {
629 .delsys = { SYS_DVBS }, 629 .delsys = { SYS_DVBS },
630 .info = { 630 .info = {
631 .name = "Conexant CX24110 DVB-S", 631 .name = "Conexant CX24110 DVB-S",
diff --git a/drivers/media/dvb-frontends/cx24113.c b/drivers/media/dvb-frontends/cx24113.c
index 3883c3b31aef..db44ebb7c561 100644
--- a/drivers/media/dvb-frontends/cx24113.c
+++ b/drivers/media/dvb-frontends/cx24113.c
@@ -108,8 +108,8 @@ static int cx24113_writereg(struct cx24113_state *state, int reg, int data)
108 .flags = 0, .buf = buf, .len = 2 }; 108 .flags = 0, .buf = buf, .len = 2 };
109 int err = i2c_transfer(state->i2c, &msg, 1); 109 int err = i2c_transfer(state->i2c, &msg, 1);
110 if (err != 1) { 110 if (err != 1) {
111 printk(KERN_DEBUG "%s: writereg error(err == %i, reg == 0x%02x," 111 printk(KERN_DEBUG "%s: writereg error(err == %i, reg == 0x%02x, data == 0x%02x)\n",
112 " data == 0x%02x)\n", __func__, err, reg, data); 112 __func__, err, reg, data);
113 return err; 113 return err;
114 } 114 }
115 115
@@ -527,13 +527,12 @@ static int cx24113_get_frequency(struct dvb_frontend *fe, u32 *frequency)
527 return 0; 527 return 0;
528} 528}
529 529
530static int cx24113_release(struct dvb_frontend *fe) 530static void cx24113_release(struct dvb_frontend *fe)
531{ 531{
532 struct cx24113_state *state = fe->tuner_priv; 532 struct cx24113_state *state = fe->tuner_priv;
533 dprintk("\n"); 533 dprintk("\n");
534 fe->tuner_priv = NULL; 534 fe->tuner_priv = NULL;
535 kfree(state); 535 kfree(state);
536 return 0;
537} 536}
538 537
539static const struct dvb_tuner_ops cx24113_tuner_ops = { 538static const struct dvb_tuner_ops cx24113_tuner_ops = {
diff --git a/drivers/media/dvb-frontends/cx24116.c b/drivers/media/dvb-frontends/cx24116.c
index 8814f36d53fb..e105532bfba8 100644
--- a/drivers/media/dvb-frontends/cx24116.c
+++ b/drivers/media/dvb-frontends/cx24116.c
@@ -209,8 +209,8 @@ static int cx24116_writereg(struct cx24116_state *state, int reg, int data)
209 209
210 err = i2c_transfer(state->i2c, &msg, 1); 210 err = i2c_transfer(state->i2c, &msg, 1);
211 if (err != 1) { 211 if (err != 1) {
212 printk(KERN_ERR "%s: writereg error(err == %i, reg == 0x%02x," 212 printk(KERN_ERR "%s: writereg error(err == %i, reg == 0x%02x, value == 0x%02x)\n",
213 " value == 0x%02x)\n", __func__, err, reg, data); 213 __func__, err, reg, data);
214 return -EREMOTEIO; 214 return -EREMOTEIO;
215 } 215 }
216 216
@@ -498,8 +498,8 @@ static int cx24116_firmware_ondemand(struct dvb_frontend *fe)
498 printk(KERN_INFO "%s: Waiting for firmware upload(2)...\n", 498 printk(KERN_INFO "%s: Waiting for firmware upload(2)...\n",
499 __func__); 499 __func__);
500 if (ret) { 500 if (ret) {
501 printk(KERN_ERR "%s: No firmware uploaded " 501 printk(KERN_ERR "%s: No firmware uploaded (timeout or file not found?)\n",
502 "(timeout or file not found?)\n", __func__); 502 __func__);
503 return ret; 503 return ret;
504 } 504 }
505 505
@@ -1116,7 +1116,7 @@ static void cx24116_release(struct dvb_frontend *fe)
1116 kfree(state); 1116 kfree(state);
1117} 1117}
1118 1118
1119static struct dvb_frontend_ops cx24116_ops; 1119static const struct dvb_frontend_ops cx24116_ops;
1120 1120
1121struct dvb_frontend *cx24116_attach(const struct cx24116_config *config, 1121struct dvb_frontend *cx24116_attach(const struct cx24116_config *config,
1122 struct i2c_adapter *i2c) 1122 struct i2c_adapter *i2c)
@@ -1467,7 +1467,7 @@ static int cx24116_get_algo(struct dvb_frontend *fe)
1467 return DVBFE_ALGO_HW; 1467 return DVBFE_ALGO_HW;
1468} 1468}
1469 1469
1470static struct dvb_frontend_ops cx24116_ops = { 1470static const struct dvb_frontend_ops cx24116_ops = {
1471 .delsys = { SYS_DVBS, SYS_DVBS2 }, 1471 .delsys = { SYS_DVBS, SYS_DVBS2 },
1472 .info = { 1472 .info = {
1473 .name = "Conexant CX24116/CX24118", 1473 .name = "Conexant CX24116/CX24118",
diff --git a/drivers/media/dvb-frontends/cx24117.c b/drivers/media/dvb-frontends/cx24117.c
index a3f7eb4e609d..d37cb7762bd6 100644
--- a/drivers/media/dvb-frontends/cx24117.c
+++ b/drivers/media/dvb-frontends/cx24117.c
@@ -474,8 +474,8 @@ static int cx24117_firmware_ondemand(struct dvb_frontend *fe)
474 "%s: Waiting for firmware upload(2)...\n", __func__); 474 "%s: Waiting for firmware upload(2)...\n", __func__);
475 if (ret) { 475 if (ret) {
476 dev_err(&state->priv->i2c->dev, 476 dev_err(&state->priv->i2c->dev,
477 "%s: No firmware uploaded " 477 "%s: No firmware uploaded (timeout or file not found?)\n",
478 "(timeout or file not found?)\n", __func__); 478__func__);
479 return ret; 479 return ret;
480 } 480 }
481 481
@@ -1164,7 +1164,7 @@ static void cx24117_release(struct dvb_frontend *fe)
1164 kfree(state); 1164 kfree(state);
1165} 1165}
1166 1166
1167static struct dvb_frontend_ops cx24117_ops; 1167static const struct dvb_frontend_ops cx24117_ops;
1168 1168
1169struct dvb_frontend *cx24117_attach(const struct cx24117_config *config, 1169struct dvb_frontend *cx24117_attach(const struct cx24117_config *config,
1170 struct i2c_adapter *i2c) 1170 struct i2c_adapter *i2c)
@@ -1618,7 +1618,7 @@ static int cx24117_get_frontend(struct dvb_frontend *fe,
1618 return 0; 1618 return 0;
1619} 1619}
1620 1620
1621static struct dvb_frontend_ops cx24117_ops = { 1621static const struct dvb_frontend_ops cx24117_ops = {
1622 .delsys = { SYS_DVBS, SYS_DVBS2 }, 1622 .delsys = { SYS_DVBS, SYS_DVBS2 },
1623 .info = { 1623 .info = {
1624 .name = "Conexant CX24117/CX24132", 1624 .name = "Conexant CX24117/CX24132",
diff --git a/drivers/media/dvb-frontends/cx24120.c b/drivers/media/dvb-frontends/cx24120.c
index 066ee387bf25..7f11dcc94d85 100644
--- a/drivers/media/dvb-frontends/cx24120.c
+++ b/drivers/media/dvb-frontends/cx24120.c
@@ -267,7 +267,7 @@ out:
267 return ret; 267 return ret;
268} 268}
269 269
270static struct dvb_frontend_ops cx24120_ops; 270static const struct dvb_frontend_ops cx24120_ops;
271 271
272struct dvb_frontend *cx24120_attach(const struct cx24120_config *config, 272struct dvb_frontend *cx24120_attach(const struct cx24120_config *config,
273 struct i2c_adapter *i2c) 273 struct i2c_adapter *i2c)
@@ -1154,8 +1154,7 @@ static int cx24120_set_frontend(struct dvb_frontend *fe)
1154 dev_dbg(&state->i2c->dev, 1154 dev_dbg(&state->i2c->dev,
1155 "delivery system(%d) not supported\n", 1155 "delivery system(%d) not supported\n",
1156 c->delivery_system); 1156 c->delivery_system);
1157 ret = -EINVAL; 1157 return -EINVAL;
1158 break;
1159 } 1158 }
1160 1159
1161 state->dnxt.delsys = c->delivery_system; 1160 state->dnxt.delsys = c->delivery_system;
@@ -1552,7 +1551,7 @@ static int cx24120_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
1552 return 0; 1551 return 0;
1553} 1552}
1554 1553
1555static struct dvb_frontend_ops cx24120_ops = { 1554static const struct dvb_frontend_ops cx24120_ops = {
1556 .delsys = { SYS_DVBS, SYS_DVBS2 }, 1555 .delsys = { SYS_DVBS, SYS_DVBS2 },
1557 .info = { 1556 .info = {
1558 .name = "Conexant CX24120/CX24118", 1557 .name = "Conexant CX24120/CX24118",
diff --git a/drivers/media/dvb-frontends/cx24123.c b/drivers/media/dvb-frontends/cx24123.c
index 113b0949408a..8aed8cc9f93d 100644
--- a/drivers/media/dvb-frontends/cx24123.c
+++ b/drivers/media/dvb-frontends/cx24123.c
@@ -255,8 +255,8 @@ static int cx24123_i2c_writereg(struct cx24123_state *state,
255 255
256 err = i2c_transfer(state->i2c, &msg, 1); 256 err = i2c_transfer(state->i2c, &msg, 1);
257 if (err != 1) { 257 if (err != 1) {
258 printk("%s: writereg error(err == %i, reg == 0x%02x," 258 printk("%s: writereg error(err == %i, reg == 0x%02x, data == 0x%02x)\n",
259 " data == 0x%02x)\n", __func__, err, reg, data); 259 __func__, err, reg, data);
260 return err; 260 return err;
261 } 261 }
262 262
@@ -1049,7 +1049,7 @@ struct i2c_adapter *
1049} 1049}
1050EXPORT_SYMBOL(cx24123_get_tuner_i2c_adapter); 1050EXPORT_SYMBOL(cx24123_get_tuner_i2c_adapter);
1051 1051
1052static struct dvb_frontend_ops cx24123_ops; 1052static const struct dvb_frontend_ops cx24123_ops;
1053 1053
1054struct dvb_frontend *cx24123_attach(const struct cx24123_config *config, 1054struct dvb_frontend *cx24123_attach(const struct cx24123_config *config,
1055 struct i2c_adapter *i2c) 1055 struct i2c_adapter *i2c)
@@ -1111,7 +1111,7 @@ error:
1111} 1111}
1112EXPORT_SYMBOL(cx24123_attach); 1112EXPORT_SYMBOL(cx24123_attach);
1113 1113
1114static struct dvb_frontend_ops cx24123_ops = { 1114static const struct dvb_frontend_ops cx24123_ops = {
1115 .delsys = { SYS_DVBS }, 1115 .delsys = { SYS_DVBS },
1116 .info = { 1116 .info = {
1117 .name = "Conexant CX24123/CX24109", 1117 .name = "Conexant CX24123/CX24109",
diff --git a/drivers/media/dvb-frontends/cxd2841er.c b/drivers/media/dvb-frontends/cxd2841er.c
index 5afb9c508f65..614bfb3740f1 100644
--- a/drivers/media/dvb-frontends/cxd2841er.c
+++ b/drivers/media/dvb-frontends/cxd2841er.c
@@ -3719,7 +3719,7 @@ static int cxd2841er_init_tc(struct dvb_frontend *fe)
3719 return 0; 3719 return 0;
3720} 3720}
3721 3721
3722static struct dvb_frontend_ops cxd2841er_dvbs_s2_ops; 3722static const struct dvb_frontend_ops cxd2841er_dvbs_s2_ops;
3723static struct dvb_frontend_ops cxd2841er_t_c_ops; 3723static struct dvb_frontend_ops cxd2841er_t_c_ops;
3724 3724
3725static struct dvb_frontend *cxd2841er_attach(struct cxd2841er_config *cfg, 3725static struct dvb_frontend *cxd2841er_attach(struct cxd2841er_config *cfg,
@@ -3801,7 +3801,7 @@ struct dvb_frontend *cxd2841er_attach_t_c(struct cxd2841er_config *cfg,
3801} 3801}
3802EXPORT_SYMBOL(cxd2841er_attach_t_c); 3802EXPORT_SYMBOL(cxd2841er_attach_t_c);
3803 3803
3804static struct dvb_frontend_ops cxd2841er_dvbs_s2_ops = { 3804static const struct dvb_frontend_ops cxd2841er_dvbs_s2_ops = {
3805 .delsys = { SYS_DVBS, SYS_DVBS2 }, 3805 .delsys = { SYS_DVBS, SYS_DVBS2 },
3806 .info = { 3806 .info = {
3807 .name = "Sony CXD2841ER DVB-S/S2 demodulator", 3807 .name = "Sony CXD2841ER DVB-S/S2 demodulator",
@@ -3829,7 +3829,7 @@ static struct dvb_frontend_ops cxd2841er_dvbs_s2_ops = {
3829 .tune = cxd2841er_tune_s 3829 .tune = cxd2841er_tune_s
3830}; 3830};
3831 3831
3832static struct dvb_frontend_ops cxd2841er_t_c_ops = { 3832static struct dvb_frontend_ops cxd2841er_t_c_ops = {
3833 .delsys = { SYS_DVBT, SYS_DVBT2, SYS_DVBC_ANNEX_A }, 3833 .delsys = { SYS_DVBT, SYS_DVBT2, SYS_DVBC_ANNEX_A },
3834 .info = { 3834 .info = {
3835 .name = "", /* will set in attach function */ 3835 .name = "", /* will set in attach function */
diff --git a/drivers/media/dvb-frontends/dib0070.c b/drivers/media/dvb-frontends/dib0070.c
index ee7d66997ccd..befc8172159d 100644
--- a/drivers/media/dvb-frontends/dib0070.c
+++ b/drivers/media/dvb-frontends/dib0070.c
@@ -24,6 +24,8 @@
24 * 24 *
25 */ 25 */
26 26
27#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
28
27#include <linux/kernel.h> 29#include <linux/kernel.h>
28#include <linux/slab.h> 30#include <linux/slab.h>
29#include <linux/i2c.h> 31#include <linux/i2c.h>
@@ -38,12 +40,10 @@ static int debug;
38module_param(debug, int, 0644); 40module_param(debug, int, 0644);
39MODULE_PARM_DESC(debug, "turn on debugging (default: 0)"); 41MODULE_PARM_DESC(debug, "turn on debugging (default: 0)");
40 42
41#define dprintk(args...) do { \ 43#define dprintk(fmt, arg...) do { \
42 if (debug) { \ 44 if (debug) \
43 printk(KERN_DEBUG "DiB0070: "); \ 45 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
44 printk(args); \ 46 __func__, ##arg); \
45 printk("\n"); \
46 } \
47} while (0) 47} while (0)
48 48
49#define DIB0070_P1D 0x00 49#define DIB0070_P1D 0x00
@@ -87,7 +87,7 @@ static u16 dib0070_read_reg(struct dib0070_state *state, u8 reg)
87 u16 ret; 87 u16 ret;
88 88
89 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { 89 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
90 dprintk("could not acquire lock"); 90 dprintk("could not acquire lock\n");
91 return 0; 91 return 0;
92 } 92 }
93 93
@@ -104,7 +104,7 @@ static u16 dib0070_read_reg(struct dib0070_state *state, u8 reg)
104 state->msg[1].len = 2; 104 state->msg[1].len = 2;
105 105
106 if (i2c_transfer(state->i2c, state->msg, 2) != 2) { 106 if (i2c_transfer(state->i2c, state->msg, 2) != 2) {
107 printk(KERN_WARNING "DiB0070 I2C read failed\n"); 107 pr_warn("DiB0070 I2C read failed\n");
108 ret = 0; 108 ret = 0;
109 } else 109 } else
110 ret = (state->i2c_read_buffer[0] << 8) 110 ret = (state->i2c_read_buffer[0] << 8)
@@ -119,7 +119,7 @@ static int dib0070_write_reg(struct dib0070_state *state, u8 reg, u16 val)
119 int ret; 119 int ret;
120 120
121 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { 121 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
122 dprintk("could not acquire lock"); 122 dprintk("could not acquire lock\n");
123 return -EINVAL; 123 return -EINVAL;
124 } 124 }
125 state->i2c_write_buffer[0] = reg; 125 state->i2c_write_buffer[0] = reg;
@@ -133,7 +133,7 @@ static int dib0070_write_reg(struct dib0070_state *state, u8 reg, u16 val)
133 state->msg[0].len = 3; 133 state->msg[0].len = 3;
134 134
135 if (i2c_transfer(state->i2c, state->msg, 1) != 1) { 135 if (i2c_transfer(state->i2c, state->msg, 1) != 1) {
136 printk(KERN_WARNING "DiB0070 I2C write failed\n"); 136 pr_warn("DiB0070 I2C write failed\n");
137 ret = -EREMOTEIO; 137 ret = -EREMOTEIO;
138 } else 138 } else
139 ret = 0; 139 ret = 0;
@@ -205,7 +205,7 @@ static int dib0070_captrim(struct dib0070_state *state, enum frontend_tune_state
205 205
206 adc = dib0070_read_reg(state, 0x19); 206 adc = dib0070_read_reg(state, 0x19);
207 207
208 dprintk("CAPTRIM=%hd; ADC = %hd (ADC) & %dmV", state->captrim, adc, (u32) adc*(u32)1800/(u32)1024); 208 dprintk("CAPTRIM=%hd; ADC = %hd (ADC) & %dmV\n", state->captrim, adc, (u32) adc*(u32)1800/(u32)1024);
209 209
210 if (adc >= 400) { 210 if (adc >= 400) {
211 adc -= 400; 211 adc -= 400;
@@ -216,7 +216,7 @@ static int dib0070_captrim(struct dib0070_state *state, enum frontend_tune_state
216 } 216 }
217 217
218 if (adc < state->adc_diff) { 218 if (adc < state->adc_diff) {
219 dprintk("CAPTRIM=%hd is closer to target (%hd/%hd)", state->captrim, adc, state->adc_diff); 219 dprintk("CAPTRIM=%hd is closer to target (%hd/%hd)\n", state->captrim, adc, state->adc_diff);
220 state->adc_diff = adc; 220 state->adc_diff = adc;
221 state->fcaptrim = state->captrim; 221 state->fcaptrim = state->captrim;
222 } 222 }
@@ -241,7 +241,7 @@ static int dib0070_set_ctrl_lo5(struct dvb_frontend *fe, u8 vco_bias_trim, u8 hf
241 struct dib0070_state *state = fe->tuner_priv; 241 struct dib0070_state *state = fe->tuner_priv;
242 u16 lo5 = (third_order_filt << 14) | (0 << 13) | (1 << 12) | (3 << 9) | (cp_current << 6) | (hf_div_trim << 3) | (vco_bias_trim << 0); 242 u16 lo5 = (third_order_filt << 14) | (0 << 13) | (1 << 12) | (3 << 9) | (cp_current << 6) | (hf_div_trim << 3) | (vco_bias_trim << 0);
243 243
244 dprintk("CTRL_LO5: 0x%x", lo5); 244 dprintk("CTRL_LO5: 0x%x\n", lo5);
245 return dib0070_write_reg(state, 0x15, lo5); 245 return dib0070_write_reg(state, 0x15, lo5);
246} 246}
247 247
@@ -256,7 +256,7 @@ void dib0070_ctrl_agc_filter(struct dvb_frontend *fe, u8 open)
256 dib0070_write_reg(state, 0x1b, 0x4112); 256 dib0070_write_reg(state, 0x1b, 0x4112);
257 if (state->cfg->vga_filter != 0) { 257 if (state->cfg->vga_filter != 0) {
258 dib0070_write_reg(state, 0x1a, state->cfg->vga_filter); 258 dib0070_write_reg(state, 0x1a, state->cfg->vga_filter);
259 dprintk("vga filter register is set to %x", state->cfg->vga_filter); 259 dprintk("vga filter register is set to %x\n", state->cfg->vga_filter);
260 } else 260 } else
261 dib0070_write_reg(state, 0x1a, 0x0009); 261 dib0070_write_reg(state, 0x1a, 0x0009);
262 } 262 }
@@ -380,7 +380,7 @@ static int dib0070_tune_digital(struct dvb_frontend *fe)
380 } 380 }
381 381
382 if (*tune_state == CT_TUNER_START) { 382 if (*tune_state == CT_TUNER_START) {
383 dprintk("Tuning for Band: %hd (%d kHz)", band, freq); 383 dprintk("Tuning for Band: %hd (%d kHz)\n", band, freq);
384 if (state->current_rf != freq) { 384 if (state->current_rf != freq) {
385 u8 REFDIV; 385 u8 REFDIV;
386 u32 FBDiv, Rest, FREF, VCOF_kHz; 386 u32 FBDiv, Rest, FREF, VCOF_kHz;
@@ -458,12 +458,12 @@ static int dib0070_tune_digital(struct dvb_frontend *fe)
458 dib0070_write_reg(state, 0x20, 458 dib0070_write_reg(state, 0x20,
459 0x0040 | 0x0020 | 0x0010 | 0x0008 | 0x0002 | 0x0001 | state->current_tune_table_index->tuner_enable); 459 0x0040 | 0x0020 | 0x0010 | 0x0008 | 0x0002 | 0x0001 | state->current_tune_table_index->tuner_enable);
460 460
461 dprintk("REFDIV: %hd, FREF: %d", REFDIV, FREF); 461 dprintk("REFDIV: %hd, FREF: %d\n", REFDIV, FREF);
462 dprintk("FBDIV: %d, Rest: %d", FBDiv, Rest); 462 dprintk("FBDIV: %d, Rest: %d\n", FBDiv, Rest);
463 dprintk("Num: %hd, Den: %hd, SD: %hd", (u16) Rest, Den, (state->lo4 >> 12) & 0x1); 463 dprintk("Num: %hd, Den: %hd, SD: %hd\n", (u16) Rest, Den, (state->lo4 >> 12) & 0x1);
464 dprintk("HFDIV code: %hd", state->current_tune_table_index->hfdiv); 464 dprintk("HFDIV code: %hd\n", state->current_tune_table_index->hfdiv);
465 dprintk("VCO = %hd", state->current_tune_table_index->vco_band); 465 dprintk("VCO = %hd\n", state->current_tune_table_index->vco_band);
466 dprintk("VCOF: ((%hd*%d) << 1))", state->current_tune_table_index->vco_multi, freq); 466 dprintk("VCOF: ((%hd*%d) << 1))\n", state->current_tune_table_index->vco_multi, freq);
467 467
468 *tune_state = CT_TUNER_STEP_0; 468 *tune_state = CT_TUNER_STEP_0;
469 } else { /* we are already tuned to this frequency - the configuration is correct */ 469 } else { /* we are already tuned to this frequency - the configuration is correct */
@@ -625,7 +625,7 @@ static void dib0070_wbd_offset_calibration(struct dib0070_state *state)
625 u8 gain; 625 u8 gain;
626 for (gain = 6; gain < 8; gain++) { 626 for (gain = 6; gain < 8; gain++) {
627 state->wbd_offset_3_3[gain - 6] = ((dib0070_read_wbd_offset(state, gain) * 8 * 18 / 33 + 1) / 2); 627 state->wbd_offset_3_3[gain - 6] = ((dib0070_read_wbd_offset(state, gain) * 8 * 18 / 33 + 1) / 2);
628 dprintk("Gain: %d, WBDOffset (3.3V) = %hd", gain, state->wbd_offset_3_3[gain-6]); 628 dprintk("Gain: %d, WBDOffset (3.3V) = %hd\n", gain, state->wbd_offset_3_3[gain-6]);
629 } 629 }
630} 630}
631 631
@@ -665,10 +665,10 @@ static int dib0070_reset(struct dvb_frontend *fe)
665 state->revision = DIB0070S_P1A; 665 state->revision = DIB0070S_P1A;
666 666
667 /* P1F or not */ 667 /* P1F or not */
668 dprintk("Revision: %x", state->revision); 668 dprintk("Revision: %x\n", state->revision);
669 669
670 if (state->revision == DIB0070_P1D) { 670 if (state->revision == DIB0070_P1D) {
671 dprintk("Error: this driver is not to be used meant for P1D or earlier"); 671 dprintk("Error: this driver is not to be used meant for P1D or earlier\n");
672 return -EINVAL; 672 return -EINVAL;
673 } 673 }
674 674
@@ -722,11 +722,10 @@ static int dib0070_get_frequency(struct dvb_frontend *fe, u32 *frequency)
722 return 0; 722 return 0;
723} 723}
724 724
725static int dib0070_release(struct dvb_frontend *fe) 725static void dib0070_release(struct dvb_frontend *fe)
726{ 726{
727 kfree(fe->tuner_priv); 727 kfree(fe->tuner_priv);
728 fe->tuner_priv = NULL; 728 fe->tuner_priv = NULL;
729 return 0;
730} 729}
731 730
732static const struct dvb_tuner_ops dib0070_ops = { 731static const struct dvb_tuner_ops dib0070_ops = {
@@ -761,7 +760,7 @@ struct dvb_frontend *dib0070_attach(struct dvb_frontend *fe, struct i2c_adapter
761 if (dib0070_reset(fe) != 0) 760 if (dib0070_reset(fe) != 0)
762 goto free_mem; 761 goto free_mem;
763 762
764 printk(KERN_INFO "DiB0070: successfully identified\n"); 763 pr_info("DiB0070: successfully identified\n");
765 memcpy(&fe->ops.tuner_ops, &dib0070_ops, sizeof(struct dvb_tuner_ops)); 764 memcpy(&fe->ops.tuner_ops, &dib0070_ops, sizeof(struct dvb_tuner_ops));
766 765
767 fe->tuner_priv = state; 766 fe->tuner_priv = state;
diff --git a/drivers/media/dvb-frontends/dib0090.c b/drivers/media/dvb-frontends/dib0090.c
index 14c403254fe0..fd3b33296b15 100644
--- a/drivers/media/dvb-frontends/dib0090.c
+++ b/drivers/media/dvb-frontends/dib0090.c
@@ -24,6 +24,8 @@
24 * 24 *
25 */ 25 */
26 26
27#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
28
27#include <linux/kernel.h> 29#include <linux/kernel.h>
28#include <linux/slab.h> 30#include <linux/slab.h>
29#include <linux/i2c.h> 31#include <linux/i2c.h>
@@ -38,12 +40,10 @@ static int debug;
38module_param(debug, int, 0644); 40module_param(debug, int, 0644);
39MODULE_PARM_DESC(debug, "turn on debugging (default: 0)"); 41MODULE_PARM_DESC(debug, "turn on debugging (default: 0)");
40 42
41#define dprintk(args...) do { \ 43#define dprintk(fmt, arg...) do { \
42 if (debug) { \ 44 if (debug) \
43 printk(KERN_DEBUG "DiB0090: "); \ 45 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
44 printk(args); \ 46 __func__, ##arg); \
45 printk("\n"); \
46 } \
47} while (0) 47} while (0)
48 48
49#define CONFIG_SYS_DVBT 49#define CONFIG_SYS_DVBT
@@ -218,7 +218,7 @@ static u16 dib0090_read_reg(struct dib0090_state *state, u8 reg)
218 u16 ret; 218 u16 ret;
219 219
220 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { 220 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
221 dprintk("could not acquire lock"); 221 dprintk("could not acquire lock\n");
222 return 0; 222 return 0;
223 } 223 }
224 224
@@ -235,7 +235,7 @@ static u16 dib0090_read_reg(struct dib0090_state *state, u8 reg)
235 state->msg[1].len = 2; 235 state->msg[1].len = 2;
236 236
237 if (i2c_transfer(state->i2c, state->msg, 2) != 2) { 237 if (i2c_transfer(state->i2c, state->msg, 2) != 2) {
238 printk(KERN_WARNING "DiB0090 I2C read failed\n"); 238 pr_warn("DiB0090 I2C read failed\n");
239 ret = 0; 239 ret = 0;
240 } else 240 } else
241 ret = (state->i2c_read_buffer[0] << 8) 241 ret = (state->i2c_read_buffer[0] << 8)
@@ -250,7 +250,7 @@ static int dib0090_write_reg(struct dib0090_state *state, u32 reg, u16 val)
250 int ret; 250 int ret;
251 251
252 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { 252 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
253 dprintk("could not acquire lock"); 253 dprintk("could not acquire lock\n");
254 return -EINVAL; 254 return -EINVAL;
255 } 255 }
256 256
@@ -265,7 +265,7 @@ static int dib0090_write_reg(struct dib0090_state *state, u32 reg, u16 val)
265 state->msg[0].len = 3; 265 state->msg[0].len = 3;
266 266
267 if (i2c_transfer(state->i2c, state->msg, 1) != 1) { 267 if (i2c_transfer(state->i2c, state->msg, 1) != 1) {
268 printk(KERN_WARNING "DiB0090 I2C write failed\n"); 268 pr_warn("DiB0090 I2C write failed\n");
269 ret = -EREMOTEIO; 269 ret = -EREMOTEIO;
270 } else 270 } else
271 ret = 0; 271 ret = 0;
@@ -279,7 +279,7 @@ static u16 dib0090_fw_read_reg(struct dib0090_fw_state *state, u8 reg)
279 u16 ret; 279 u16 ret;
280 280
281 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { 281 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
282 dprintk("could not acquire lock"); 282 dprintk("could not acquire lock\n");
283 return 0; 283 return 0;
284 } 284 }
285 285
@@ -291,7 +291,7 @@ static u16 dib0090_fw_read_reg(struct dib0090_fw_state *state, u8 reg)
291 state->msg.buf = state->i2c_read_buffer; 291 state->msg.buf = state->i2c_read_buffer;
292 state->msg.len = 2; 292 state->msg.len = 2;
293 if (i2c_transfer(state->i2c, &state->msg, 1) != 1) { 293 if (i2c_transfer(state->i2c, &state->msg, 1) != 1) {
294 printk(KERN_WARNING "DiB0090 I2C read failed\n"); 294 pr_warn("DiB0090 I2C read failed\n");
295 ret = 0; 295 ret = 0;
296 } else 296 } else
297 ret = (state->i2c_read_buffer[0] << 8) 297 ret = (state->i2c_read_buffer[0] << 8)
@@ -306,7 +306,7 @@ static int dib0090_fw_write_reg(struct dib0090_fw_state *state, u8 reg, u16 val)
306 int ret; 306 int ret;
307 307
308 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { 308 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
309 dprintk("could not acquire lock"); 309 dprintk("could not acquire lock\n");
310 return -EINVAL; 310 return -EINVAL;
311 } 311 }
312 312
@@ -319,7 +319,7 @@ static int dib0090_fw_write_reg(struct dib0090_fw_state *state, u8 reg, u16 val)
319 state->msg.buf = state->i2c_write_buffer; 319 state->msg.buf = state->i2c_write_buffer;
320 state->msg.len = 2; 320 state->msg.len = 2;
321 if (i2c_transfer(state->i2c, &state->msg, 1) != 1) { 321 if (i2c_transfer(state->i2c, &state->msg, 1) != 1) {
322 printk(KERN_WARNING "DiB0090 I2C write failed\n"); 322 pr_warn("DiB0090 I2C write failed\n");
323 ret = -EREMOTEIO; 323 ret = -EREMOTEIO;
324 } else 324 } else
325 ret = 0; 325 ret = 0;
@@ -351,7 +351,7 @@ static int dib0090_identify(struct dvb_frontend *fe)
351 identity->p1g = 0; 351 identity->p1g = 0;
352 identity->in_soc = 0; 352 identity->in_soc = 0;
353 353
354 dprintk("Tuner identification (Version = 0x%04x)", v); 354 dprintk("Tuner identification (Version = 0x%04x)\n", v);
355 355
356 /* without PLL lock info */ 356 /* without PLL lock info */
357 v &= ~KROSUS_PLL_LOCKED; 357 v &= ~KROSUS_PLL_LOCKED;
@@ -366,19 +366,19 @@ static int dib0090_identify(struct dvb_frontend *fe)
366 identity->in_soc = 1; 366 identity->in_soc = 1;
367 switch (identity->version) { 367 switch (identity->version) {
368 case SOC_8090_P1G_11R1: 368 case SOC_8090_P1G_11R1:
369 dprintk("SOC 8090 P1-G11R1 Has been detected"); 369 dprintk("SOC 8090 P1-G11R1 Has been detected\n");
370 identity->p1g = 1; 370 identity->p1g = 1;
371 break; 371 break;
372 case SOC_8090_P1G_21R1: 372 case SOC_8090_P1G_21R1:
373 dprintk("SOC 8090 P1-G21R1 Has been detected"); 373 dprintk("SOC 8090 P1-G21R1 Has been detected\n");
374 identity->p1g = 1; 374 identity->p1g = 1;
375 break; 375 break;
376 case SOC_7090_P1G_11R1: 376 case SOC_7090_P1G_11R1:
377 dprintk("SOC 7090 P1-G11R1 Has been detected"); 377 dprintk("SOC 7090 P1-G11R1 Has been detected\n");
378 identity->p1g = 1; 378 identity->p1g = 1;
379 break; 379 break;
380 case SOC_7090_P1G_21R1: 380 case SOC_7090_P1G_21R1:
381 dprintk("SOC 7090 P1-G21R1 Has been detected"); 381 dprintk("SOC 7090 P1-G21R1 Has been detected\n");
382 identity->p1g = 1; 382 identity->p1g = 1;
383 break; 383 break;
384 default: 384 default:
@@ -387,16 +387,16 @@ static int dib0090_identify(struct dvb_frontend *fe)
387 } else { 387 } else {
388 switch ((identity->version >> 5) & 0x7) { 388 switch ((identity->version >> 5) & 0x7) {
389 case MP001: 389 case MP001:
390 dprintk("MP001 : 9090/8096"); 390 dprintk("MP001 : 9090/8096\n");
391 break; 391 break;
392 case MP005: 392 case MP005:
393 dprintk("MP005 : Single Sband"); 393 dprintk("MP005 : Single Sband\n");
394 break; 394 break;
395 case MP008: 395 case MP008:
396 dprintk("MP008 : diversity VHF-UHF-LBAND"); 396 dprintk("MP008 : diversity VHF-UHF-LBAND\n");
397 break; 397 break;
398 case MP009: 398 case MP009:
399 dprintk("MP009 : diversity 29098 CBAND-UHF-LBAND-SBAND"); 399 dprintk("MP009 : diversity 29098 CBAND-UHF-LBAND-SBAND\n");
400 break; 400 break;
401 default: 401 default:
402 goto identification_error; 402 goto identification_error;
@@ -404,21 +404,21 @@ static int dib0090_identify(struct dvb_frontend *fe)
404 404
405 switch (identity->version & 0x1f) { 405 switch (identity->version & 0x1f) {
406 case P1G_21R2: 406 case P1G_21R2:
407 dprintk("P1G_21R2 detected"); 407 dprintk("P1G_21R2 detected\n");
408 identity->p1g = 1; 408 identity->p1g = 1;
409 break; 409 break;
410 case P1G: 410 case P1G:
411 dprintk("P1G detected"); 411 dprintk("P1G detected\n");
412 identity->p1g = 1; 412 identity->p1g = 1;
413 break; 413 break;
414 case P1D_E_F: 414 case P1D_E_F:
415 dprintk("P1D/E/F detected"); 415 dprintk("P1D/E/F detected\n");
416 break; 416 break;
417 case P1C: 417 case P1C:
418 dprintk("P1C detected"); 418 dprintk("P1C detected\n");
419 break; 419 break;
420 case P1A_B: 420 case P1A_B:
421 dprintk("P1-A/B detected: driver is deactivated - not available"); 421 dprintk("P1-A/B detected: driver is deactivated - not available\n");
422 goto identification_error; 422 goto identification_error;
423 break; 423 break;
424 default: 424 default:
@@ -441,7 +441,7 @@ static int dib0090_fw_identify(struct dvb_frontend *fe)
441 identity->p1g = 0; 441 identity->p1g = 0;
442 identity->in_soc = 0; 442 identity->in_soc = 0;
443 443
444 dprintk("FE: Tuner identification (Version = 0x%04x)", v); 444 dprintk("FE: Tuner identification (Version = 0x%04x)\n", v);
445 445
446 /* without PLL lock info */ 446 /* without PLL lock info */
447 v &= ~KROSUS_PLL_LOCKED; 447 v &= ~KROSUS_PLL_LOCKED;
@@ -456,19 +456,19 @@ static int dib0090_fw_identify(struct dvb_frontend *fe)
456 identity->in_soc = 1; 456 identity->in_soc = 1;
457 switch (identity->version) { 457 switch (identity->version) {
458 case SOC_8090_P1G_11R1: 458 case SOC_8090_P1G_11R1:
459 dprintk("SOC 8090 P1-G11R1 Has been detected"); 459 dprintk("SOC 8090 P1-G11R1 Has been detected\n");
460 identity->p1g = 1; 460 identity->p1g = 1;
461 break; 461 break;
462 case SOC_8090_P1G_21R1: 462 case SOC_8090_P1G_21R1:
463 dprintk("SOC 8090 P1-G21R1 Has been detected"); 463 dprintk("SOC 8090 P1-G21R1 Has been detected\n");
464 identity->p1g = 1; 464 identity->p1g = 1;
465 break; 465 break;
466 case SOC_7090_P1G_11R1: 466 case SOC_7090_P1G_11R1:
467 dprintk("SOC 7090 P1-G11R1 Has been detected"); 467 dprintk("SOC 7090 P1-G11R1 Has been detected\n");
468 identity->p1g = 1; 468 identity->p1g = 1;
469 break; 469 break;
470 case SOC_7090_P1G_21R1: 470 case SOC_7090_P1G_21R1:
471 dprintk("SOC 7090 P1-G21R1 Has been detected"); 471 dprintk("SOC 7090 P1-G21R1 Has been detected\n");
472 identity->p1g = 1; 472 identity->p1g = 1;
473 break; 473 break;
474 default: 474 default:
@@ -477,16 +477,16 @@ static int dib0090_fw_identify(struct dvb_frontend *fe)
477 } else { 477 } else {
478 switch ((identity->version >> 5) & 0x7) { 478 switch ((identity->version >> 5) & 0x7) {
479 case MP001: 479 case MP001:
480 dprintk("MP001 : 9090/8096"); 480 dprintk("MP001 : 9090/8096\n");
481 break; 481 break;
482 case MP005: 482 case MP005:
483 dprintk("MP005 : Single Sband"); 483 dprintk("MP005 : Single Sband\n");
484 break; 484 break;
485 case MP008: 485 case MP008:
486 dprintk("MP008 : diversity VHF-UHF-LBAND"); 486 dprintk("MP008 : diversity VHF-UHF-LBAND\n");
487 break; 487 break;
488 case MP009: 488 case MP009:
489 dprintk("MP009 : diversity 29098 CBAND-UHF-LBAND-SBAND"); 489 dprintk("MP009 : diversity 29098 CBAND-UHF-LBAND-SBAND\n");
490 break; 490 break;
491 default: 491 default:
492 goto identification_error; 492 goto identification_error;
@@ -494,21 +494,21 @@ static int dib0090_fw_identify(struct dvb_frontend *fe)
494 494
495 switch (identity->version & 0x1f) { 495 switch (identity->version & 0x1f) {
496 case P1G_21R2: 496 case P1G_21R2:
497 dprintk("P1G_21R2 detected"); 497 dprintk("P1G_21R2 detected\n");
498 identity->p1g = 1; 498 identity->p1g = 1;
499 break; 499 break;
500 case P1G: 500 case P1G:
501 dprintk("P1G detected"); 501 dprintk("P1G detected\n");
502 identity->p1g = 1; 502 identity->p1g = 1;
503 break; 503 break;
504 case P1D_E_F: 504 case P1D_E_F:
505 dprintk("P1D/E/F detected"); 505 dprintk("P1D/E/F detected\n");
506 break; 506 break;
507 case P1C: 507 case P1C:
508 dprintk("P1C detected"); 508 dprintk("P1C detected\n");
509 break; 509 break;
510 case P1A_B: 510 case P1A_B:
511 dprintk("P1-A/B detected: driver is deactivated - not available"); 511 dprintk("P1-A/B detected: driver is deactivated - not available\n");
512 goto identification_error; 512 goto identification_error;
513 break; 513 break;
514 default: 514 default:
@@ -574,7 +574,7 @@ static void dib0090_reset_digital(struct dvb_frontend *fe, const struct dib0090_
574 } while (--i); 574 } while (--i);
575 575
576 if (i == 0) { 576 if (i == 0) {
577 dprintk("Pll: Unable to lock Pll"); 577 dprintk("Pll: Unable to lock Pll\n");
578 return; 578 return;
579 } 579 }
580 580
@@ -596,7 +596,7 @@ static int dib0090_fw_reset_digital(struct dvb_frontend *fe, const struct dib009
596 u16 v; 596 u16 v;
597 int i; 597 int i;
598 598
599 dprintk("fw reset digital"); 599 dprintk("fw reset digital\n");
600 HARD_RESET(state); 600 HARD_RESET(state);
601 601
602 dib0090_fw_write_reg(state, 0x24, EN_PLL | EN_CRYSTAL); 602 dib0090_fw_write_reg(state, 0x24, EN_PLL | EN_CRYSTAL);
@@ -645,7 +645,7 @@ static int dib0090_fw_reset_digital(struct dvb_frontend *fe, const struct dib009
645 } while (--i); 645 } while (--i);
646 646
647 if (i == 0) { 647 if (i == 0) {
648 dprintk("Pll: Unable to lock Pll"); 648 dprintk("Pll: Unable to lock Pll\n");
649 return -EIO; 649 return -EIO;
650 } 650 }
651 651
@@ -922,7 +922,7 @@ static void dib0090_wbd_target(struct dib0090_state *state, u32 rf)
922#endif 922#endif
923 923
924 state->wbd_target = dib0090_wbd_to_db(state, state->wbd_offset + offset); 924 state->wbd_target = dib0090_wbd_to_db(state, state->wbd_offset + offset);
925 dprintk("wbd-target: %d dB", (u32) state->wbd_target); 925 dprintk("wbd-target: %d dB\n", (u32) state->wbd_target);
926} 926}
927 927
928static const int gain_reg_addr[4] = { 928static const int gain_reg_addr[4] = {
@@ -1019,7 +1019,7 @@ static void dib0090_gain_apply(struct dib0090_state *state, s16 gain_delta, s16
1019 gain_reg[3] |= ((bb % 10) * 100) / 125; 1019 gain_reg[3] |= ((bb % 10) * 100) / 125;
1020 1020
1021#ifdef DEBUG_AGC 1021#ifdef DEBUG_AGC
1022 dprintk("GA CALC: DB: %3d(rf) + %3d(bb) = %3d gain_reg[0]=%04x gain_reg[1]=%04x gain_reg[2]=%04x gain_reg[0]=%04x", rf, bb, rf + bb, 1022 dprintk("GA CALC: DB: %3d(rf) + %3d(bb) = %3d gain_reg[0]=%04x gain_reg[1]=%04x gain_reg[2]=%04x gain_reg[0]=%04x\n", rf, bb, rf + bb,
1023 gain_reg[0], gain_reg[1], gain_reg[2], gain_reg[3]); 1023 gain_reg[0], gain_reg[1], gain_reg[2], gain_reg[3]);
1024#endif 1024#endif
1025 1025
@@ -1050,7 +1050,7 @@ static void dib0090_set_rframp_pwm(struct dib0090_state *state, const u16 * cfg)
1050 1050
1051 dib0090_write_reg(state, 0x2a, 0xffff); 1051 dib0090_write_reg(state, 0x2a, 0xffff);
1052 1052
1053 dprintk("total RF gain: %ddB, step: %d", (u32) cfg[0], dib0090_read_reg(state, 0x2a)); 1053 dprintk("total RF gain: %ddB, step: %d\n", (u32) cfg[0], dib0090_read_reg(state, 0x2a));
1054 1054
1055 dib0090_write_regs(state, 0x2c, cfg + 3, 6); 1055 dib0090_write_regs(state, 0x2c, cfg + 3, 6);
1056 dib0090_write_regs(state, 0x3e, cfg + 9, 2); 1056 dib0090_write_regs(state, 0x3e, cfg + 9, 2);
@@ -1069,7 +1069,7 @@ static void dib0090_set_bbramp_pwm(struct dib0090_state *state, const u16 * cfg)
1069 dib0090_set_boost(state, cfg[0] > 500); /* we want the boost if the gain is higher that 50dB */ 1069 dib0090_set_boost(state, cfg[0] > 500); /* we want the boost if the gain is higher that 50dB */
1070 1070
1071 dib0090_write_reg(state, 0x33, 0xffff); 1071 dib0090_write_reg(state, 0x33, 0xffff);
1072 dprintk("total BB gain: %ddB, step: %d", (u32) cfg[0], dib0090_read_reg(state, 0x33)); 1072 dprintk("total BB gain: %ddB, step: %d\n", (u32) cfg[0], dib0090_read_reg(state, 0x33));
1073 dib0090_write_regs(state, 0x35, cfg + 3, 4); 1073 dib0090_write_regs(state, 0x35, cfg + 3, 4);
1074} 1074}
1075 1075
@@ -1122,7 +1122,7 @@ void dib0090_pwm_gain_reset(struct dvb_frontend *fe)
1122 1122
1123 /* activate the ramp generator using PWM control */ 1123 /* activate the ramp generator using PWM control */
1124 if (state->rf_ramp) 1124 if (state->rf_ramp)
1125 dprintk("ramp RF gain = %d BAND = %s version = %d", 1125 dprintk("ramp RF gain = %d BAND = %s version = %d\n",
1126 state->rf_ramp[0], 1126 state->rf_ramp[0],
1127 (state->current_band == BAND_CBAND) ? "CBAND" : "NOT CBAND", 1127 (state->current_band == BAND_CBAND) ? "CBAND" : "NOT CBAND",
1128 state->identity.version & 0x1f); 1128 state->identity.version & 0x1f);
@@ -1130,10 +1130,10 @@ void dib0090_pwm_gain_reset(struct dvb_frontend *fe)
1130 if (rf_ramp && ((state->rf_ramp && state->rf_ramp[0] == 0) || 1130 if (rf_ramp && ((state->rf_ramp && state->rf_ramp[0] == 0) ||
1131 (state->current_band == BAND_CBAND && 1131 (state->current_band == BAND_CBAND &&
1132 (state->identity.version & 0x1f) <= P1D_E_F))) { 1132 (state->identity.version & 0x1f) <= P1D_E_F))) {
1133 dprintk("DE-Engage mux for direct gain reg control"); 1133 dprintk("DE-Engage mux for direct gain reg control\n");
1134 en_pwm_rf_mux = 0; 1134 en_pwm_rf_mux = 0;
1135 } else 1135 } else
1136 dprintk("Engage mux for PWM control"); 1136 dprintk("Engage mux for PWM control\n");
1137 1137
1138 dib0090_write_reg(state, 0x32, (en_pwm_rf_mux << 12) | (en_pwm_rf_mux << 11)); 1138 dib0090_write_reg(state, 0x32, (en_pwm_rf_mux << 12) | (en_pwm_rf_mux << 11));
1139 1139
@@ -1352,7 +1352,7 @@ u16 dib0090_get_wbd_target(struct dvb_frontend *fe)
1352 while (f_MHz > wbd->max_freq) 1352 while (f_MHz > wbd->max_freq)
1353 wbd++; 1353 wbd++;
1354 1354
1355 dprintk("using wbd-table-entry with max freq %d", wbd->max_freq); 1355 dprintk("using wbd-table-entry with max freq %d\n", wbd->max_freq);
1356 1356
1357 if (current_temp < 0) 1357 if (current_temp < 0)
1358 current_temp = 0; 1358 current_temp = 0;
@@ -1373,8 +1373,8 @@ u16 dib0090_get_wbd_target(struct dvb_frontend *fe)
1373 wbd_tcold += ((wbd_thot - wbd_tcold) * current_temp) >> 7; 1373 wbd_tcold += ((wbd_thot - wbd_tcold) * current_temp) >> 7;
1374 1374
1375 state->wbd_target = dib0090_wbd_to_db(state, state->wbd_offset + wbd_tcold); 1375 state->wbd_target = dib0090_wbd_to_db(state, state->wbd_offset + wbd_tcold);
1376 dprintk("wbd-target: %d dB", (u32) state->wbd_target); 1376 dprintk("wbd-target: %d dB\n", (u32) state->wbd_target);
1377 dprintk("wbd offset applied is %d", wbd_tcold); 1377 dprintk("wbd offset applied is %d\n", wbd_tcold);
1378 1378
1379 return state->wbd_offset + wbd_tcold; 1379 return state->wbd_offset + wbd_tcold;
1380} 1380}
@@ -1415,7 +1415,7 @@ int dib0090_update_rframp_7090(struct dvb_frontend *fe, u8 cfg_sensitivity)
1415 if ((!state->identity.p1g) || (!state->identity.in_soc) 1415 if ((!state->identity.p1g) || (!state->identity.in_soc)
1416 || ((state->identity.version != SOC_7090_P1G_21R1) 1416 || ((state->identity.version != SOC_7090_P1G_21R1)
1417 && (state->identity.version != SOC_7090_P1G_11R1))) { 1417 && (state->identity.version != SOC_7090_P1G_11R1))) {
1418 dprintk("%s() function can only be used for dib7090P", __func__); 1418 dprintk("%s() function can only be used for dib7090P\n", __func__);
1419 return -ENODEV; 1419 return -ENODEV;
1420 } 1420 }
1421 1421
@@ -1598,7 +1598,7 @@ static int dib0090_reset(struct dvb_frontend *fe)
1598 dib0090_write_reg(state, 0x14, 1); 1598 dib0090_write_reg(state, 0x14, 1);
1599 else 1599 else
1600 dib0090_write_reg(state, 0x14, 2); 1600 dib0090_write_reg(state, 0x14, 2);
1601 dprintk("Pll lock : %d", (dib0090_read_reg(state, 0x1a) >> 11) & 0x1); 1601 dprintk("Pll lock : %d\n", (dib0090_read_reg(state, 0x1a) >> 11) & 0x1);
1602 1602
1603 state->calibrate = DC_CAL | WBD_CAL | TEMP_CAL; /* enable iq-offset-calibration and wbd-calibration when tuning next time */ 1603 state->calibrate = DC_CAL | WBD_CAL | TEMP_CAL; /* enable iq-offset-calibration and wbd-calibration when tuning next time */
1604 1604
@@ -1711,7 +1711,8 @@ static int dib0090_dc_offset_calibration(struct dib0090_state *state, enum front
1711 1711
1712 /* fall through */ 1712 /* fall through */
1713 case CT_TUNER_STEP_0: 1713 case CT_TUNER_STEP_0:
1714 dprintk("Start/continue DC calibration for %s path", (state->dc->i == 1) ? "I" : "Q"); 1714 dprintk("Start/continue DC calibration for %s path\n",
1715 (state->dc->i == 1) ? "I" : "Q");
1715 dib0090_write_reg(state, 0x01, state->dc->bb1); 1716 dib0090_write_reg(state, 0x01, state->dc->bb1);
1716 dib0090_write_reg(state, 0x07, state->bb7 | (state->dc->i << 7)); 1717 dib0090_write_reg(state, 0x07, state->bb7 | (state->dc->i << 7));
1717 1718
@@ -1733,13 +1734,13 @@ static int dib0090_dc_offset_calibration(struct dib0090_state *state, enum front
1733 break; 1734 break;
1734 1735
1735 case CT_TUNER_STEP_5: /* found an offset */ 1736 case CT_TUNER_STEP_5: /* found an offset */
1736 dprintk("adc_diff = %d, current step= %d", (u32) state->adc_diff, state->step); 1737 dprintk("adc_diff = %d, current step= %d\n", (u32) state->adc_diff, state->step);
1737 if (state->step == 0 && state->adc_diff < 0) { 1738 if (state->step == 0 && state->adc_diff < 0) {
1738 state->min_adc_diff = -1023; 1739 state->min_adc_diff = -1023;
1739 dprintk("Change of sign of the minimum adc diff"); 1740 dprintk("Change of sign of the minimum adc diff\n");
1740 } 1741 }
1741 1742
1742 dprintk("adc_diff = %d, min_adc_diff = %d current_step = %d", state->adc_diff, state->min_adc_diff, state->step); 1743 dprintk("adc_diff = %d, min_adc_diff = %d current_step = %d\n", state->adc_diff, state->min_adc_diff, state->step);
1743 1744
1744 /* first turn for this frequency */ 1745 /* first turn for this frequency */
1745 if (state->step == 0) { 1746 if (state->step == 0) {
@@ -1758,12 +1759,12 @@ static int dib0090_dc_offset_calibration(struct dib0090_state *state, enum front
1758 } else { 1759 } else {
1759 /* the minimum was what we have seen in the step before */ 1760 /* the minimum was what we have seen in the step before */
1760 if (ABS(state->adc_diff) > ABS(state->min_adc_diff)) { 1761 if (ABS(state->adc_diff) > ABS(state->min_adc_diff)) {
1761 dprintk("Since adc_diff N = %d > adc_diff step N-1 = %d, Come back one step", state->adc_diff, state->min_adc_diff); 1762 dprintk("Since adc_diff N = %d > adc_diff step N-1 = %d, Come back one step\n", state->adc_diff, state->min_adc_diff);
1762 state->step--; 1763 state->step--;
1763 } 1764 }
1764 1765
1765 dib0090_set_trim(state); 1766 dib0090_set_trim(state);
1766 dprintk("BB Offset Cal, BBreg=%hd,Offset=%hd,Value Set=%hd", state->dc->addr, state->adc_diff, state->step); 1767 dprintk("BB Offset Cal, BBreg=%hd,Offset=%hd,Value Set=%hd\n", state->dc->addr, state->adc_diff, state->step);
1767 1768
1768 state->dc++; 1769 state->dc++;
1769 if (state->dc->addr == 0) /* done */ 1770 if (state->dc->addr == 0) /* done */
@@ -1819,7 +1820,7 @@ static int dib0090_wbd_calibration(struct dib0090_state *state, enum frontend_tu
1819 1820
1820 case CT_TUNER_STEP_0: 1821 case CT_TUNER_STEP_0:
1821 state->wbd_offset = dib0090_get_slow_adc_val(state); 1822 state->wbd_offset = dib0090_get_slow_adc_val(state);
1822 dprintk("WBD calibration offset = %d", state->wbd_offset); 1823 dprintk("WBD calibration offset = %d\n", state->wbd_offset);
1823 *tune_state = CT_TUNER_START; /* reset done -> real tuning can now begin */ 1824 *tune_state = CT_TUNER_START; /* reset done -> real tuning can now begin */
1824 state->calibrate &= ~WBD_CAL; 1825 state->calibrate &= ~WBD_CAL;
1825 break; 1826 break;
@@ -2064,7 +2065,7 @@ int dib0090_update_tuning_table_7090(struct dvb_frontend *fe,
2064 if ((!state->identity.p1g) || (!state->identity.in_soc) 2065 if ((!state->identity.p1g) || (!state->identity.in_soc)
2065 || ((state->identity.version != SOC_7090_P1G_21R1) 2066 || ((state->identity.version != SOC_7090_P1G_21R1)
2066 && (state->identity.version != SOC_7090_P1G_11R1))) { 2067 && (state->identity.version != SOC_7090_P1G_11R1))) {
2067 dprintk("%s() function can only be used for dib7090", __func__); 2068 dprintk("%s() function can only be used for dib7090\n", __func__);
2068 return -ENODEV; 2069 return -ENODEV;
2069 } 2070 }
2070 2071
@@ -2098,7 +2099,8 @@ static int dib0090_captrim_search(struct dib0090_state *state, enum frontend_tun
2098 force_soft_search = 1; 2099 force_soft_search = 1;
2099 2100
2100 if (*tune_state == CT_TUNER_START) { 2101 if (*tune_state == CT_TUNER_START) {
2101 dprintk("Start Captrim search : %s", (force_soft_search == 1) ? "FORCE SOFT SEARCH" : "AUTO"); 2102 dprintk("Start Captrim search : %s\n",
2103 (force_soft_search == 1) ? "FORCE SOFT SEARCH" : "AUTO");
2102 dib0090_write_reg(state, 0x10, 0x2B1); 2104 dib0090_write_reg(state, 0x10, 0x2B1);
2103 dib0090_write_reg(state, 0x1e, 0x0032); 2105 dib0090_write_reg(state, 0x1e, 0x0032);
2104 2106
@@ -2140,13 +2142,13 @@ static int dib0090_captrim_search(struct dib0090_state *state, enum frontend_tun
2140 dib0090_read_reg(state, 0x40); 2142 dib0090_read_reg(state, 0x40);
2141 2143
2142 state->fcaptrim = dib0090_read_reg(state, 0x18) & 0x7F; 2144 state->fcaptrim = dib0090_read_reg(state, 0x18) & 0x7F;
2143 dprintk("***Final Captrim= 0x%x", state->fcaptrim); 2145 dprintk("***Final Captrim= 0x%x\n", state->fcaptrim);
2144 *tune_state = CT_TUNER_STEP_3; 2146 *tune_state = CT_TUNER_STEP_3;
2145 2147
2146 } else { 2148 } else {
2147 /* MERGE for all krosus before P1G */ 2149 /* MERGE for all krosus before P1G */
2148 adc = dib0090_get_slow_adc_val(state); 2150 adc = dib0090_get_slow_adc_val(state);
2149 dprintk("CAPTRIM=%d; ADC = %d (ADC) & %dmV", (u32) state->captrim, (u32) adc, (u32) (adc) * (u32) 1800 / (u32) 1024); 2151 dprintk("CAPTRIM=%d; ADC = %d (ADC) & %dmV\n", (u32) state->captrim, (u32) adc, (u32) (adc) * (u32) 1800 / (u32) 1024);
2150 2152
2151 if (state->rest == 0 || state->identity.in_soc) { /* Just for 8090P SOCS where auto captrim HW bug : TO CHECK IN ACI for SOCS !!! if 400 for 8090p SOC => tune issue !!! */ 2153 if (state->rest == 0 || state->identity.in_soc) { /* Just for 8090P SOCS where auto captrim HW bug : TO CHECK IN ACI for SOCS !!! if 400 for 8090p SOC => tune issue !!! */
2152 adc_target = 200; 2154 adc_target = 200;
@@ -2162,7 +2164,7 @@ static int dib0090_captrim_search(struct dib0090_state *state, enum frontend_tun
2162 } 2164 }
2163 2165
2164 if (adc < state->adc_diff) { 2166 if (adc < state->adc_diff) {
2165 dprintk("CAPTRIM=%d is closer to target (%d/%d)", (u32) state->captrim, (u32) adc, (u32) state->adc_diff); 2167 dprintk("CAPTRIM=%d is closer to target (%d/%d)\n", (u32) state->captrim, (u32) adc, (u32) state->adc_diff);
2166 state->adc_diff = adc; 2168 state->adc_diff = adc;
2167 state->fcaptrim = state->captrim; 2169 state->fcaptrim = state->captrim;
2168 } 2170 }
@@ -2216,7 +2218,7 @@ static int dib0090_get_temperature(struct dib0090_state *state, enum frontend_tu
2216 val = dib0090_get_slow_adc_val(state); 2218 val = dib0090_get_slow_adc_val(state);
2217 state->temperature = ((s16) ((val - state->adc_diff) * 180) >> 8) + 55; 2219 state->temperature = ((s16) ((val - state->adc_diff) * 180) >> 8) + 55;
2218 2220
2219 dprintk("temperature: %d C", state->temperature - 30); 2221 dprintk("temperature: %d C\n", state->temperature - 30);
2220 2222
2221 *tune_state = CT_TUNER_STEP_2; 2223 *tune_state = CT_TUNER_STEP_2;
2222 break; 2224 break;
@@ -2478,13 +2480,13 @@ static int dib0090_tune(struct dvb_frontend *fe)
2478 wbd++; 2480 wbd++;
2479 2481
2480 dib0090_write_reg(state, 0x1e, 0x07ff); 2482 dib0090_write_reg(state, 0x1e, 0x07ff);
2481 dprintk("Final Captrim: %d", (u32) state->fcaptrim); 2483 dprintk("Final Captrim: %d\n", (u32) state->fcaptrim);
2482 dprintk("HFDIV code: %d", (u32) pll->hfdiv_code); 2484 dprintk("HFDIV code: %d\n", (u32) pll->hfdiv_code);
2483 dprintk("VCO = %d", (u32) pll->vco_band); 2485 dprintk("VCO = %d\n", (u32) pll->vco_band);
2484 dprintk("VCOF in kHz: %d ((%d*%d) << 1))", (u32) ((pll->hfdiv * state->rf_request) * 2), (u32) pll->hfdiv, (u32) state->rf_request); 2486 dprintk("VCOF in kHz: %d ((%d*%d) << 1))\n", (u32) ((pll->hfdiv * state->rf_request) * 2), (u32) pll->hfdiv, (u32) state->rf_request);
2485 dprintk("REFDIV: %d, FREF: %d", (u32) 1, (u32) state->config->io.clock_khz); 2487 dprintk("REFDIV: %d, FREF: %d\n", (u32) 1, (u32) state->config->io.clock_khz);
2486 dprintk("FBDIV: %d, Rest: %d", (u32) dib0090_read_reg(state, 0x15), (u32) dib0090_read_reg(state, 0x17)); 2488 dprintk("FBDIV: %d, Rest: %d\n", (u32) dib0090_read_reg(state, 0x15), (u32) dib0090_read_reg(state, 0x17));
2487 dprintk("Num: %d, Den: %d, SD: %d", (u32) dib0090_read_reg(state, 0x17), (u32) (dib0090_read_reg(state, 0x16) >> 8), 2489 dprintk("Num: %d, Den: %d, SD: %d\n", (u32) dib0090_read_reg(state, 0x17), (u32) (dib0090_read_reg(state, 0x16) >> 8),
2488 (u32) dib0090_read_reg(state, 0x1c) & 0x3); 2490 (u32) dib0090_read_reg(state, 0x1c) & 0x3);
2489 2491
2490#define WBD 0x781 /* 1 1 1 1 0000 0 0 1 */ 2492#define WBD 0x781 /* 1 1 1 1 0000 0 0 1 */
@@ -2498,7 +2500,7 @@ static int dib0090_tune(struct dvb_frontend *fe)
2498 dib0090_write_reg(state, 0x10, state->wbdmux); 2500 dib0090_write_reg(state, 0x10, state->wbdmux);
2499 2501
2500 if ((tune->tuner_enable == EN_CAB) && state->identity.p1g) { 2502 if ((tune->tuner_enable == EN_CAB) && state->identity.p1g) {
2501 dprintk("P1G : The cable band is selected and lna_tune = %d", tune->lna_tune); 2503 dprintk("P1G : The cable band is selected and lna_tune = %d\n", tune->lna_tune);
2502 dib0090_write_reg(state, 0x09, tune->lna_bias); 2504 dib0090_write_reg(state, 0x09, tune->lna_bias);
2503 dib0090_write_reg(state, 0x0b, 0xb800 | (tune->lna_tune << 6) | (tune->switch_trim)); 2505 dib0090_write_reg(state, 0x0b, 0xb800 | (tune->lna_tune << 6) | (tune->switch_trim));
2504 } else 2506 } else
@@ -2524,11 +2526,10 @@ static int dib0090_tune(struct dvb_frontend *fe)
2524 return ret; 2526 return ret;
2525} 2527}
2526 2528
2527static int dib0090_release(struct dvb_frontend *fe) 2529static void dib0090_release(struct dvb_frontend *fe)
2528{ 2530{
2529 kfree(fe->tuner_priv); 2531 kfree(fe->tuner_priv);
2530 fe->tuner_priv = NULL; 2532 fe->tuner_priv = NULL;
2531 return 0;
2532} 2533}
2533 2534
2534enum frontend_tune_state dib0090_get_tune_state(struct dvb_frontend *fe) 2535enum frontend_tune_state dib0090_get_tune_state(struct dvb_frontend *fe)
@@ -2643,7 +2644,7 @@ struct dvb_frontend *dib0090_register(struct dvb_frontend *fe, struct i2c_adapte
2643 if (dib0090_reset(fe) != 0) 2644 if (dib0090_reset(fe) != 0)
2644 goto free_mem; 2645 goto free_mem;
2645 2646
2646 printk(KERN_INFO "DiB0090: successfully identified\n"); 2647 pr_info("DiB0090: successfully identified\n");
2647 memcpy(&fe->ops.tuner_ops, &dib0090_ops, sizeof(struct dvb_tuner_ops)); 2648 memcpy(&fe->ops.tuner_ops, &dib0090_ops, sizeof(struct dvb_tuner_ops));
2648 2649
2649 return fe; 2650 return fe;
@@ -2670,7 +2671,7 @@ struct dvb_frontend *dib0090_fw_register(struct dvb_frontend *fe, struct i2c_ada
2670 if (dib0090_fw_reset_digital(fe, st->config) != 0) 2671 if (dib0090_fw_reset_digital(fe, st->config) != 0)
2671 goto free_mem; 2672 goto free_mem;
2672 2673
2673 dprintk("DiB0090 FW: successfully identified"); 2674 dprintk("DiB0090 FW: successfully identified\n");
2674 memcpy(&fe->ops.tuner_ops, &dib0090_fw_ops, sizeof(struct dvb_tuner_ops)); 2675 memcpy(&fe->ops.tuner_ops, &dib0090_fw_ops, sizeof(struct dvb_tuner_ops));
2675 2676
2676 return fe; 2677 return fe;
diff --git a/drivers/media/dvb-frontends/dib3000mb.c b/drivers/media/dvb-frontends/dib3000mb.c
index 6821ecb53d63..068bec104e29 100644
--- a/drivers/media/dvb-frontends/dib3000mb.c
+++ b/drivers/media/dvb-frontends/dib3000mb.c
@@ -21,6 +21,8 @@
21 * 21 *
22 */ 22 */
23 23
24#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25
24#include <linux/kernel.h> 26#include <linux/kernel.h>
25#include <linux/module.h> 27#include <linux/module.h>
26#include <linux/init.h> 28#include <linux/init.h>
@@ -42,13 +44,13 @@ static int debug;
42module_param(debug, int, 0644); 44module_param(debug, int, 0644);
43MODULE_PARM_DESC(debug, "set debugging level (1=info,2=xfer,4=setfe,8=getfe (|-able))."); 45MODULE_PARM_DESC(debug, "set debugging level (1=info,2=xfer,4=setfe,8=getfe (|-able)).");
44 46
45#define deb_info(args...) dprintk(0x01,args) 47#define deb_info(args...) dprintk(0x01, args)
46#define deb_i2c(args...) dprintk(0x02,args) 48#define deb_i2c(args...) dprintk(0x02, args)
47#define deb_srch(args...) dprintk(0x04,args) 49#define deb_srch(args...) dprintk(0x04, args)
48#define deb_info(args...) dprintk(0x01,args) 50#define deb_info(args...) dprintk(0x01, args)
49#define deb_xfer(args...) dprintk(0x02,args) 51#define deb_xfer(args...) dprintk(0x02, args)
50#define deb_setf(args...) dprintk(0x04,args) 52#define deb_setf(args...) dprintk(0x04, args)
51#define deb_getf(args...) dprintk(0x08,args) 53#define deb_getf(args...) dprintk(0x08, args)
52 54
53static int dib3000_read_reg(struct dib3000_state *state, u16 reg) 55static int dib3000_read_reg(struct dib3000_state *state, u16 reg)
54{ 56{
@@ -126,103 +128,96 @@ static int dib3000mb_set_frontend(struct dvb_frontend *fe, int tuner)
126 fe->ops.tuner_ops.set_params(fe); 128 fe->ops.tuner_ops.set_params(fe);
127 if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); 129 if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
128 130
129 deb_setf("bandwidth: ");
130 switch (c->bandwidth_hz) { 131 switch (c->bandwidth_hz) {
131 case 8000000: 132 case 8000000:
132 deb_setf("8 MHz\n");
133 wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[2]); 133 wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[2]);
134 wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_8mhz); 134 wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_8mhz);
135 break; 135 break;
136 case 7000000: 136 case 7000000:
137 deb_setf("7 MHz\n");
138 wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[1]); 137 wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[1]);
139 wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_7mhz); 138 wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_7mhz);
140 break; 139 break;
141 case 6000000: 140 case 6000000:
142 deb_setf("6 MHz\n");
143 wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[0]); 141 wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[0]);
144 wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_6mhz); 142 wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_6mhz);
145 break; 143 break;
146 case 0: 144 case 0:
147 return -EOPNOTSUPP; 145 return -EOPNOTSUPP;
148 default: 146 default:
149 err("unknown bandwidth value."); 147 pr_err("unknown bandwidth value.\n");
150 return -EINVAL; 148 return -EINVAL;
151 } 149 }
150 deb_setf("bandwidth: %d MHZ\n", c->bandwidth_hz / 1000000);
152 } 151 }
153 wr(DIB3000MB_REG_LOCK1_MASK, DIB3000MB_LOCK1_SEARCH_4); 152 wr(DIB3000MB_REG_LOCK1_MASK, DIB3000MB_LOCK1_SEARCH_4);
154 153
155 deb_setf("transmission mode: ");
156 switch (c->transmission_mode) { 154 switch (c->transmission_mode) {
157 case TRANSMISSION_MODE_2K: 155 case TRANSMISSION_MODE_2K:
158 deb_setf("2k\n"); 156 deb_setf("transmission mode: 2k\n");
159 wr(DIB3000MB_REG_FFT, DIB3000_TRANSMISSION_MODE_2K); 157 wr(DIB3000MB_REG_FFT, DIB3000_TRANSMISSION_MODE_2K);
160 break; 158 break;
161 case TRANSMISSION_MODE_8K: 159 case TRANSMISSION_MODE_8K:
162 deb_setf("8k\n"); 160 deb_setf("transmission mode: 8k\n");
163 wr(DIB3000MB_REG_FFT, DIB3000_TRANSMISSION_MODE_8K); 161 wr(DIB3000MB_REG_FFT, DIB3000_TRANSMISSION_MODE_8K);
164 break; 162 break;
165 case TRANSMISSION_MODE_AUTO: 163 case TRANSMISSION_MODE_AUTO:
166 deb_setf("auto\n"); 164 deb_setf("transmission mode: auto\n");
167 break; 165 break;
168 default: 166 default:
169 return -EINVAL; 167 return -EINVAL;
170 } 168 }
171 169
172 deb_setf("guard: ");
173 switch (c->guard_interval) { 170 switch (c->guard_interval) {
174 case GUARD_INTERVAL_1_32: 171 case GUARD_INTERVAL_1_32:
175 deb_setf("1_32\n"); 172 deb_setf("guard 1_32\n");
176 wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_32); 173 wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_32);
177 break; 174 break;
178 case GUARD_INTERVAL_1_16: 175 case GUARD_INTERVAL_1_16:
179 deb_setf("1_16\n"); 176 deb_setf("guard 1_16\n");
180 wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_16); 177 wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_16);
181 break; 178 break;
182 case GUARD_INTERVAL_1_8: 179 case GUARD_INTERVAL_1_8:
183 deb_setf("1_8\n"); 180 deb_setf("guard 1_8\n");
184 wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_8); 181 wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_8);
185 break; 182 break;
186 case GUARD_INTERVAL_1_4: 183 case GUARD_INTERVAL_1_4:
187 deb_setf("1_4\n"); 184 deb_setf("guard 1_4\n");
188 wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_4); 185 wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_4);
189 break; 186 break;
190 case GUARD_INTERVAL_AUTO: 187 case GUARD_INTERVAL_AUTO:
191 deb_setf("auto\n"); 188 deb_setf("guard auto\n");
192 break; 189 break;
193 default: 190 default:
194 return -EINVAL; 191 return -EINVAL;
195 } 192 }
196 193
197 deb_setf("inversion: ");
198 switch (c->inversion) { 194 switch (c->inversion) {
199 case INVERSION_OFF: 195 case INVERSION_OFF:
200 deb_setf("off\n"); 196 deb_setf("inversion off\n");
201 wr(DIB3000MB_REG_DDS_INV, DIB3000_DDS_INVERSION_OFF); 197 wr(DIB3000MB_REG_DDS_INV, DIB3000_DDS_INVERSION_OFF);
202 break; 198 break;
203 case INVERSION_AUTO: 199 case INVERSION_AUTO:
204 deb_setf("auto "); 200 deb_setf("inversion auto\n");
205 break; 201 break;
206 case INVERSION_ON: 202 case INVERSION_ON:
207 deb_setf("on\n"); 203 deb_setf("inversion on\n");
208 wr(DIB3000MB_REG_DDS_INV, DIB3000_DDS_INVERSION_ON); 204 wr(DIB3000MB_REG_DDS_INV, DIB3000_DDS_INVERSION_ON);
209 break; 205 break;
210 default: 206 default:
211 return -EINVAL; 207 return -EINVAL;
212 } 208 }
213 209
214 deb_setf("modulation: ");
215 switch (c->modulation) { 210 switch (c->modulation) {
216 case QPSK: 211 case QPSK:
217 deb_setf("qpsk\n"); 212 deb_setf("modulation: qpsk\n");
218 wr(DIB3000MB_REG_QAM, DIB3000_CONSTELLATION_QPSK); 213 wr(DIB3000MB_REG_QAM, DIB3000_CONSTELLATION_QPSK);
219 break; 214 break;
220 case QAM_16: 215 case QAM_16:
221 deb_setf("qam16\n"); 216 deb_setf("modulation: qam16\n");
222 wr(DIB3000MB_REG_QAM, DIB3000_CONSTELLATION_16QAM); 217 wr(DIB3000MB_REG_QAM, DIB3000_CONSTELLATION_16QAM);
223 break; 218 break;
224 case QAM_64: 219 case QAM_64:
225 deb_setf("qam64\n"); 220 deb_setf("modulation: qam64\n");
226 wr(DIB3000MB_REG_QAM, DIB3000_CONSTELLATION_64QAM); 221 wr(DIB3000MB_REG_QAM, DIB3000_CONSTELLATION_64QAM);
227 break; 222 break;
228 case QAM_AUTO: 223 case QAM_AUTO:
@@ -230,69 +225,64 @@ static int dib3000mb_set_frontend(struct dvb_frontend *fe, int tuner)
230 default: 225 default:
231 return -EINVAL; 226 return -EINVAL;
232 } 227 }
233 deb_setf("hierarchy: ");
234 switch (c->hierarchy) { 228 switch (c->hierarchy) {
235 case HIERARCHY_NONE: 229 case HIERARCHY_NONE:
236 deb_setf("none "); 230 deb_setf("hierarchy: none\n");
237 /* fall through */ 231 /* fall through */
238 case HIERARCHY_1: 232 case HIERARCHY_1:
239 deb_setf("alpha=1\n"); 233 deb_setf("hierarchy: alpha=1\n");
240 wr(DIB3000MB_REG_VIT_ALPHA, DIB3000_ALPHA_1); 234 wr(DIB3000MB_REG_VIT_ALPHA, DIB3000_ALPHA_1);
241 break; 235 break;
242 case HIERARCHY_2: 236 case HIERARCHY_2:
243 deb_setf("alpha=2\n"); 237 deb_setf("hierarchy: alpha=2\n");
244 wr(DIB3000MB_REG_VIT_ALPHA, DIB3000_ALPHA_2); 238 wr(DIB3000MB_REG_VIT_ALPHA, DIB3000_ALPHA_2);
245 break; 239 break;
246 case HIERARCHY_4: 240 case HIERARCHY_4:
247 deb_setf("alpha=4\n"); 241 deb_setf("hierarchy: alpha=4\n");
248 wr(DIB3000MB_REG_VIT_ALPHA, DIB3000_ALPHA_4); 242 wr(DIB3000MB_REG_VIT_ALPHA, DIB3000_ALPHA_4);
249 break; 243 break;
250 case HIERARCHY_AUTO: 244 case HIERARCHY_AUTO:
251 deb_setf("alpha=auto\n"); 245 deb_setf("hierarchy: alpha=auto\n");
252 break; 246 break;
253 default: 247 default:
254 return -EINVAL; 248 return -EINVAL;
255 } 249 }
256 250
257 deb_setf("hierarchy: ");
258 if (c->hierarchy == HIERARCHY_NONE) { 251 if (c->hierarchy == HIERARCHY_NONE) {
259 deb_setf("none\n");
260 wr(DIB3000MB_REG_VIT_HRCH, DIB3000_HRCH_OFF); 252 wr(DIB3000MB_REG_VIT_HRCH, DIB3000_HRCH_OFF);
261 wr(DIB3000MB_REG_VIT_HP, DIB3000_SELECT_HP); 253 wr(DIB3000MB_REG_VIT_HP, DIB3000_SELECT_HP);
262 fe_cr = c->code_rate_HP; 254 fe_cr = c->code_rate_HP;
263 } else if (c->hierarchy != HIERARCHY_AUTO) { 255 } else if (c->hierarchy != HIERARCHY_AUTO) {
264 deb_setf("on\n");
265 wr(DIB3000MB_REG_VIT_HRCH, DIB3000_HRCH_ON); 256 wr(DIB3000MB_REG_VIT_HRCH, DIB3000_HRCH_ON);
266 wr(DIB3000MB_REG_VIT_HP, DIB3000_SELECT_LP); 257 wr(DIB3000MB_REG_VIT_HP, DIB3000_SELECT_LP);
267 fe_cr = c->code_rate_LP; 258 fe_cr = c->code_rate_LP;
268 } 259 }
269 deb_setf("fec: ");
270 switch (fe_cr) { 260 switch (fe_cr) {
271 case FEC_1_2: 261 case FEC_1_2:
272 deb_setf("1_2\n"); 262 deb_setf("fec: 1_2\n");
273 wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_1_2); 263 wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_1_2);
274 break; 264 break;
275 case FEC_2_3: 265 case FEC_2_3:
276 deb_setf("2_3\n"); 266 deb_setf("fec: 2_3\n");
277 wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_2_3); 267 wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_2_3);
278 break; 268 break;
279 case FEC_3_4: 269 case FEC_3_4:
280 deb_setf("3_4\n"); 270 deb_setf("fec: 3_4\n");
281 wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_3_4); 271 wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_3_4);
282 break; 272 break;
283 case FEC_5_6: 273 case FEC_5_6:
284 deb_setf("5_6\n"); 274 deb_setf("fec: 5_6\n");
285 wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_5_6); 275 wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_5_6);
286 break; 276 break;
287 case FEC_7_8: 277 case FEC_7_8:
288 deb_setf("7_8\n"); 278 deb_setf("fec: 7_8\n");
289 wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_7_8); 279 wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_7_8);
290 break; 280 break;
291 case FEC_NONE: 281 case FEC_NONE:
292 deb_setf("none "); 282 deb_setf("fec: none\n");
293 break; 283 break;
294 case FEC_AUTO: 284 case FEC_AUTO:
295 deb_setf("auto\n"); 285 deb_setf("fec: auto\n");
296 break; 286 break;
297 default: 287 default:
298 return -EINVAL; 288 return -EINVAL;
@@ -357,7 +347,8 @@ static int dib3000mb_set_frontend(struct dvb_frontend *fe, int tuner)
357 rd(DIB3000MB_REG_LOCK2_VALUE))) < 0 && as_count++ < 100) 347 rd(DIB3000MB_REG_LOCK2_VALUE))) < 0 && as_count++ < 100)
358 msleep(1); 348 msleep(1);
359 349
360 deb_setf("search_state after autosearch %d after %d checks\n",search_state,as_count); 350 deb_setf("search_state after autosearch %d after %d checks\n",
351 search_state, as_count);
361 352
362 if (search_state == 1) { 353 if (search_state == 1) {
363 if (dib3000mb_get_frontend(fe, c) == 0) { 354 if (dib3000mb_get_frontend(fe, c) == 0) {
@@ -464,7 +455,7 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe,
464 return 0; 455 return 0;
465 456
466 dds_val = ((rd(DIB3000MB_REG_DDS_VALUE_MSB) & 0xff) << 16) + rd(DIB3000MB_REG_DDS_VALUE_LSB); 457 dds_val = ((rd(DIB3000MB_REG_DDS_VALUE_MSB) & 0xff) << 16) + rd(DIB3000MB_REG_DDS_VALUE_LSB);
467 deb_getf("DDS_VAL: %x %x %x",dds_val, rd(DIB3000MB_REG_DDS_VALUE_MSB), rd(DIB3000MB_REG_DDS_VALUE_LSB)); 458 deb_getf("DDS_VAL: %x %x %x\n", dds_val, rd(DIB3000MB_REG_DDS_VALUE_MSB), rd(DIB3000MB_REG_DDS_VALUE_LSB));
468 if (dds_val < threshold) 459 if (dds_val < threshold)
469 inv_test1 = 0; 460 inv_test1 = 0;
470 else if (dds_val == threshold) 461 else if (dds_val == threshold)
@@ -473,7 +464,7 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe,
473 inv_test1 = 2; 464 inv_test1 = 2;
474 465
475 dds_val = ((rd(DIB3000MB_REG_DDS_FREQ_MSB) & 0xff) << 16) + rd(DIB3000MB_REG_DDS_FREQ_LSB); 466 dds_val = ((rd(DIB3000MB_REG_DDS_FREQ_MSB) & 0xff) << 16) + rd(DIB3000MB_REG_DDS_FREQ_LSB);
476 deb_getf("DDS_FREQ: %x %x %x",dds_val, rd(DIB3000MB_REG_DDS_FREQ_MSB), rd(DIB3000MB_REG_DDS_FREQ_LSB)); 467 deb_getf("DDS_FREQ: %x %x %x\n", dds_val, rd(DIB3000MB_REG_DDS_FREQ_MSB), rd(DIB3000MB_REG_DDS_FREQ_LSB));
477 if (dds_val < threshold) 468 if (dds_val < threshold)
478 inv_test2 = 0; 469 inv_test2 = 0;
479 else if (dds_val == threshold) 470 else if (dds_val == threshold)
@@ -490,19 +481,19 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe,
490 481
491 switch ((tps_val = rd(DIB3000MB_REG_TPS_QAM))) { 482 switch ((tps_val = rd(DIB3000MB_REG_TPS_QAM))) {
492 case DIB3000_CONSTELLATION_QPSK: 483 case DIB3000_CONSTELLATION_QPSK:
493 deb_getf("QPSK "); 484 deb_getf("QPSK\n");
494 c->modulation = QPSK; 485 c->modulation = QPSK;
495 break; 486 break;
496 case DIB3000_CONSTELLATION_16QAM: 487 case DIB3000_CONSTELLATION_16QAM:
497 deb_getf("QAM16 "); 488 deb_getf("QAM16\n");
498 c->modulation = QAM_16; 489 c->modulation = QAM_16;
499 break; 490 break;
500 case DIB3000_CONSTELLATION_64QAM: 491 case DIB3000_CONSTELLATION_64QAM:
501 deb_getf("QAM64 "); 492 deb_getf("QAM64\n");
502 c->modulation = QAM_64; 493 c->modulation = QAM_64;
503 break; 494 break;
504 default: 495 default:
505 err("Unexpected constellation returned by TPS (%d)", tps_val); 496 pr_err("Unexpected constellation returned by TPS (%d)\n", tps_val);
506 break; 497 break;
507 } 498 }
508 deb_getf("TPS: %d\n", tps_val); 499 deb_getf("TPS: %d\n", tps_val);
@@ -513,23 +504,23 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe,
513 c->code_rate_HP = FEC_NONE; 504 c->code_rate_HP = FEC_NONE;
514 switch ((tps_val = rd(DIB3000MB_REG_TPS_VIT_ALPHA))) { 505 switch ((tps_val = rd(DIB3000MB_REG_TPS_VIT_ALPHA))) {
515 case DIB3000_ALPHA_0: 506 case DIB3000_ALPHA_0:
516 deb_getf("HIERARCHY_NONE "); 507 deb_getf("HIERARCHY_NONE\n");
517 c->hierarchy = HIERARCHY_NONE; 508 c->hierarchy = HIERARCHY_NONE;
518 break; 509 break;
519 case DIB3000_ALPHA_1: 510 case DIB3000_ALPHA_1:
520 deb_getf("HIERARCHY_1 "); 511 deb_getf("HIERARCHY_1\n");
521 c->hierarchy = HIERARCHY_1; 512 c->hierarchy = HIERARCHY_1;
522 break; 513 break;
523 case DIB3000_ALPHA_2: 514 case DIB3000_ALPHA_2:
524 deb_getf("HIERARCHY_2 "); 515 deb_getf("HIERARCHY_2\n");
525 c->hierarchy = HIERARCHY_2; 516 c->hierarchy = HIERARCHY_2;
526 break; 517 break;
527 case DIB3000_ALPHA_4: 518 case DIB3000_ALPHA_4:
528 deb_getf("HIERARCHY_4 "); 519 deb_getf("HIERARCHY_4\n");
529 c->hierarchy = HIERARCHY_4; 520 c->hierarchy = HIERARCHY_4;
530 break; 521 break;
531 default: 522 default:
532 err("Unexpected ALPHA value returned by TPS (%d)", tps_val); 523 pr_err("Unexpected ALPHA value returned by TPS (%d)\n", tps_val);
533 break; 524 break;
534 } 525 }
535 deb_getf("TPS: %d\n", tps_val); 526 deb_getf("TPS: %d\n", tps_val);
@@ -546,65 +537,65 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe,
546 537
547 switch (tps_val) { 538 switch (tps_val) {
548 case DIB3000_FEC_1_2: 539 case DIB3000_FEC_1_2:
549 deb_getf("FEC_1_2 "); 540 deb_getf("FEC_1_2\n");
550 *cr = FEC_1_2; 541 *cr = FEC_1_2;
551 break; 542 break;
552 case DIB3000_FEC_2_3: 543 case DIB3000_FEC_2_3:
553 deb_getf("FEC_2_3 "); 544 deb_getf("FEC_2_3\n");
554 *cr = FEC_2_3; 545 *cr = FEC_2_3;
555 break; 546 break;
556 case DIB3000_FEC_3_4: 547 case DIB3000_FEC_3_4:
557 deb_getf("FEC_3_4 "); 548 deb_getf("FEC_3_4\n");
558 *cr = FEC_3_4; 549 *cr = FEC_3_4;
559 break; 550 break;
560 case DIB3000_FEC_5_6: 551 case DIB3000_FEC_5_6:
561 deb_getf("FEC_5_6 "); 552 deb_getf("FEC_5_6\n");
562 *cr = FEC_4_5; 553 *cr = FEC_4_5;
563 break; 554 break;
564 case DIB3000_FEC_7_8: 555 case DIB3000_FEC_7_8:
565 deb_getf("FEC_7_8 "); 556 deb_getf("FEC_7_8\n");
566 *cr = FEC_7_8; 557 *cr = FEC_7_8;
567 break; 558 break;
568 default: 559 default:
569 err("Unexpected FEC returned by TPS (%d)", tps_val); 560 pr_err("Unexpected FEC returned by TPS (%d)\n", tps_val);
570 break; 561 break;
571 } 562 }
572 deb_getf("TPS: %d\n",tps_val); 563 deb_getf("TPS: %d\n",tps_val);
573 564
574 switch ((tps_val = rd(DIB3000MB_REG_TPS_GUARD_TIME))) { 565 switch ((tps_val = rd(DIB3000MB_REG_TPS_GUARD_TIME))) {
575 case DIB3000_GUARD_TIME_1_32: 566 case DIB3000_GUARD_TIME_1_32:
576 deb_getf("GUARD_INTERVAL_1_32 "); 567 deb_getf("GUARD_INTERVAL_1_32\n");
577 c->guard_interval = GUARD_INTERVAL_1_32; 568 c->guard_interval = GUARD_INTERVAL_1_32;
578 break; 569 break;
579 case DIB3000_GUARD_TIME_1_16: 570 case DIB3000_GUARD_TIME_1_16:
580 deb_getf("GUARD_INTERVAL_1_16 "); 571 deb_getf("GUARD_INTERVAL_1_16\n");
581 c->guard_interval = GUARD_INTERVAL_1_16; 572 c->guard_interval = GUARD_INTERVAL_1_16;
582 break; 573 break;
583 case DIB3000_GUARD_TIME_1_8: 574 case DIB3000_GUARD_TIME_1_8:
584 deb_getf("GUARD_INTERVAL_1_8 "); 575 deb_getf("GUARD_INTERVAL_1_8\n");
585 c->guard_interval = GUARD_INTERVAL_1_8; 576 c->guard_interval = GUARD_INTERVAL_1_8;
586 break; 577 break;
587 case DIB3000_GUARD_TIME_1_4: 578 case DIB3000_GUARD_TIME_1_4:
588 deb_getf("GUARD_INTERVAL_1_4 "); 579 deb_getf("GUARD_INTERVAL_1_4\n");
589 c->guard_interval = GUARD_INTERVAL_1_4; 580 c->guard_interval = GUARD_INTERVAL_1_4;
590 break; 581 break;
591 default: 582 default:
592 err("Unexpected Guard Time returned by TPS (%d)", tps_val); 583 pr_err("Unexpected Guard Time returned by TPS (%d)\n", tps_val);
593 break; 584 break;
594 } 585 }
595 deb_getf("TPS: %d\n", tps_val); 586 deb_getf("TPS: %d\n", tps_val);
596 587
597 switch ((tps_val = rd(DIB3000MB_REG_TPS_FFT))) { 588 switch ((tps_val = rd(DIB3000MB_REG_TPS_FFT))) {
598 case DIB3000_TRANSMISSION_MODE_2K: 589 case DIB3000_TRANSMISSION_MODE_2K:
599 deb_getf("TRANSMISSION_MODE_2K "); 590 deb_getf("TRANSMISSION_MODE_2K\n");
600 c->transmission_mode = TRANSMISSION_MODE_2K; 591 c->transmission_mode = TRANSMISSION_MODE_2K;
601 break; 592 break;
602 case DIB3000_TRANSMISSION_MODE_8K: 593 case DIB3000_TRANSMISSION_MODE_8K:
603 deb_getf("TRANSMISSION_MODE_8K "); 594 deb_getf("TRANSMISSION_MODE_8K\n");
604 c->transmission_mode = TRANSMISSION_MODE_8K; 595 c->transmission_mode = TRANSMISSION_MODE_8K;
605 break; 596 break;
606 default: 597 default:
607 err("unexpected transmission mode return by TPS (%d)", tps_val); 598 pr_err("unexpected transmission mode return by TPS (%d)\n", tps_val);
608 break; 599 break;
609 } 600 }
610 deb_getf("TPS: %d\n", tps_val); 601 deb_getf("TPS: %d\n", tps_val);
@@ -751,7 +742,7 @@ static int dib3000mb_tuner_pass_ctrl(struct dvb_frontend *fe, int onoff, u8 pll_
751 return 0; 742 return 0;
752} 743}
753 744
754static struct dvb_frontend_ops dib3000mb_ops; 745static const struct dvb_frontend_ops dib3000mb_ops;
755 746
756struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config, 747struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
757 struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops) 748 struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops)
@@ -791,7 +782,7 @@ error:
791 return NULL; 782 return NULL;
792} 783}
793 784
794static struct dvb_frontend_ops dib3000mb_ops = { 785static const struct dvb_frontend_ops dib3000mb_ops = {
795 .delsys = { SYS_DVBT }, 786 .delsys = { SYS_DVBT },
796 .info = { 787 .info = {
797 .name = "DiBcom 3000M-B DVB-T", 788 .name = "DiBcom 3000M-B DVB-T",
diff --git a/drivers/media/dvb-frontends/dib3000mb_priv.h b/drivers/media/dvb-frontends/dib3000mb_priv.h
index 0459d5c84314..ef7f5d136c6b 100644
--- a/drivers/media/dvb-frontends/dib3000mb_priv.h
+++ b/drivers/media/dvb-frontends/dib3000mb_priv.h
@@ -13,20 +13,15 @@
13#ifndef __DIB3000MB_PRIV_H_INCLUDED__ 13#ifndef __DIB3000MB_PRIV_H_INCLUDED__
14#define __DIB3000MB_PRIV_H_INCLUDED__ 14#define __DIB3000MB_PRIV_H_INCLUDED__
15 15
16/* info and err, taken from usb.h, if there is anything available like by default. */
17#define err(format, arg...) printk(KERN_ERR "dib3000: " format "\n" , ## arg)
18#define info(format, arg...) printk(KERN_INFO "dib3000: " format "\n" , ## arg)
19#define warn(format, arg...) printk(KERN_WARNING "dib3000: " format "\n" , ## arg)
20
21/* handy shortcuts */ 16/* handy shortcuts */
22#define rd(reg) dib3000_read_reg(state,reg) 17#define rd(reg) dib3000_read_reg(state,reg)
23 18
24#define wr(reg,val) if (dib3000_write_reg(state,reg,val)) \ 19#define wr(reg,val) if (dib3000_write_reg(state,reg,val)) \
25 { err("while sending 0x%04x to 0x%04x.",val,reg); return -EREMOTEIO; } 20 { pr_err("while sending 0x%04x to 0x%04x.", val, reg); return -EREMOTEIO; }
26 21
27#define wr_foreach(a,v) { int i; \ 22#define wr_foreach(a,v) { int i; \
28 if (sizeof(a) != sizeof(v)) \ 23 if (sizeof(a) != sizeof(v)) \
29 err("sizeof: %zu %zu is different",sizeof(a),sizeof(v));\ 24 pr_err("sizeof: %zu %zu is different", sizeof(a), sizeof(v));\
30 for (i=0; i < sizeof(a)/sizeof(u16); i++) \ 25 for (i=0; i < sizeof(a)/sizeof(u16); i++) \
31 wr(a[i],v[i]); \ 26 wr(a[i],v[i]); \
32 } 27 }
@@ -37,8 +32,11 @@
37 32
38/* debug */ 33/* debug */
39 34
40#define dprintk(level,args...) \ 35#define dprintk(level, fmt, arg...) do { \
41 do { if ((debug & level)) { printk(args); } } while (0) 36 if (debug & level) \
37 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
38 __func__, ##arg); \
39} while (0)
42 40
43/* mask for enabling a specific pid for the pid_filter */ 41/* mask for enabling a specific pid for the pid_filter */
44#define DIB3000_ACTIVATE_PID_FILTERING (0x2000) 42#define DIB3000_ACTIVATE_PID_FILTERING (0x2000)
diff --git a/drivers/media/dvb-frontends/dib3000mc.c b/drivers/media/dvb-frontends/dib3000mc.c
index da0f1dc5aaf7..224283fe100a 100644
--- a/drivers/media/dvb-frontends/dib3000mc.c
+++ b/drivers/media/dvb-frontends/dib3000mc.c
@@ -11,6 +11,8 @@
11 * published by the Free Software Foundation, version 2. 11 * published by the Free Software Foundation, version 2.
12 */ 12 */
13 13
14#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15
14#include <linux/kernel.h> 16#include <linux/kernel.h>
15#include <linux/slab.h> 17#include <linux/slab.h>
16#include <linux/i2c.h> 18#include <linux/i2c.h>
@@ -27,7 +29,11 @@ static int buggy_sfn_workaround;
27module_param(buggy_sfn_workaround, int, 0644); 29module_param(buggy_sfn_workaround, int, 0644);
28MODULE_PARM_DESC(buggy_sfn_workaround, "Enable work-around for buggy SFNs (default: 0)"); 30MODULE_PARM_DESC(buggy_sfn_workaround, "Enable work-around for buggy SFNs (default: 0)");
29 31
30#define dprintk(args...) do { if (debug) { printk(KERN_DEBUG "DiB3000MC/P:"); printk(args); printk("\n"); } } while (0) 32#define dprintk(fmt, arg...) do { \
33 if (debug) \
34 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
35 __func__, ##arg); \
36} while (0)
31 37
32struct dib3000mc_state { 38struct dib3000mc_state {
33 struct dvb_frontend demod; 39 struct dvb_frontend demod;
@@ -873,7 +879,7 @@ int dib3000mc_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 defa
873} 879}
874EXPORT_SYMBOL(dib3000mc_i2c_enumeration); 880EXPORT_SYMBOL(dib3000mc_i2c_enumeration);
875 881
876static struct dvb_frontend_ops dib3000mc_ops; 882static const struct dvb_frontend_ops dib3000mc_ops;
877 883
878struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg) 884struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg)
879{ 885{
@@ -906,7 +912,7 @@ error:
906} 912}
907EXPORT_SYMBOL(dib3000mc_attach); 913EXPORT_SYMBOL(dib3000mc_attach);
908 914
909static struct dvb_frontend_ops dib3000mc_ops = { 915static const struct dvb_frontend_ops dib3000mc_ops = {
910 .delsys = { SYS_DVBT }, 916 .delsys = { SYS_DVBT },
911 .info = { 917 .info = {
912 .name = "DiBcom 3000MC/P", 918 .name = "DiBcom 3000MC/P",
diff --git a/drivers/media/dvb-frontends/dib7000m.c b/drivers/media/dvb-frontends/dib7000m.c
index b3ddae8885ac..5ce9f93a65c3 100644
--- a/drivers/media/dvb-frontends/dib7000m.c
+++ b/drivers/media/dvb-frontends/dib7000m.c
@@ -8,6 +8,9 @@
8 * modify it under the terms of the GNU General Public License as 8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation, version 2. 9 * published by the Free Software Foundation, version 2.
10 */ 10 */
11
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
11#include <linux/kernel.h> 14#include <linux/kernel.h>
12#include <linux/slab.h> 15#include <linux/slab.h>
13#include <linux/i2c.h> 16#include <linux/i2c.h>
@@ -21,7 +24,11 @@ static int debug;
21module_param(debug, int, 0644); 24module_param(debug, int, 0644);
22MODULE_PARM_DESC(debug, "turn on debugging (default: 0)"); 25MODULE_PARM_DESC(debug, "turn on debugging (default: 0)");
23 26
24#define dprintk(args...) do { if (debug) { printk(KERN_DEBUG "DiB7000M: "); printk(args); printk("\n"); } } while (0) 27#define dprintk(fmt, arg...) do { \
28 if (debug) \
29 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
30 __func__, ##arg); \
31} while (0)
25 32
26struct dib7000m_state { 33struct dib7000m_state {
27 struct dvb_frontend demod; 34 struct dvb_frontend demod;
@@ -74,7 +81,7 @@ static u16 dib7000m_read_word(struct dib7000m_state *state, u16 reg)
74 u16 ret; 81 u16 ret;
75 82
76 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { 83 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
77 dprintk("could not acquire lock"); 84 dprintk("could not acquire lock\n");
78 return 0; 85 return 0;
79 } 86 }
80 87
@@ -92,7 +99,7 @@ static u16 dib7000m_read_word(struct dib7000m_state *state, u16 reg)
92 state->msg[1].len = 2; 99 state->msg[1].len = 2;
93 100
94 if (i2c_transfer(state->i2c_adap, state->msg, 2) != 2) 101 if (i2c_transfer(state->i2c_adap, state->msg, 2) != 2)
95 dprintk("i2c read error on %d",reg); 102 dprintk("i2c read error on %d\n", reg);
96 103
97 ret = (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1]; 104 ret = (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
98 mutex_unlock(&state->i2c_buffer_lock); 105 mutex_unlock(&state->i2c_buffer_lock);
@@ -105,7 +112,7 @@ static int dib7000m_write_word(struct dib7000m_state *state, u16 reg, u16 val)
105 int ret; 112 int ret;
106 113
107 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { 114 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
108 dprintk("could not acquire lock"); 115 dprintk("could not acquire lock\n");
109 return -EINVAL; 116 return -EINVAL;
110 } 117 }
111 118
@@ -154,7 +161,7 @@ static int dib7000m_set_output_mode(struct dib7000m_state *state, int mode)
154 fifo_threshold = 1792; 161 fifo_threshold = 1792;
155 smo_mode = (dib7000m_read_word(state, 294 + state->reg_offs) & 0x0010) | (1 << 1); 162 smo_mode = (dib7000m_read_word(state, 294 + state->reg_offs) & 0x0010) | (1 << 1);
156 163
157 dprintk( "setting output mode for demod %p to %d", &state->demod, mode); 164 dprintk("setting output mode for demod %p to %d\n", &state->demod, mode);
158 165
159 switch (mode) { 166 switch (mode) {
160 case OUTMODE_MPEG2_PAR_GATED_CLK: // STBs with parallel gated clock 167 case OUTMODE_MPEG2_PAR_GATED_CLK: // STBs with parallel gated clock
@@ -181,7 +188,7 @@ static int dib7000m_set_output_mode(struct dib7000m_state *state, int mode)
181 outreg = 0; 188 outreg = 0;
182 break; 189 break;
183 default: 190 default:
184 dprintk( "Unhandled output_mode passed to be set for demod %p",&state->demod); 191 dprintk("Unhandled output_mode passed to be set for demod %p\n", &state->demod);
185 break; 192 break;
186 } 193 }
187 194
@@ -302,7 +309,7 @@ static int dib7000m_set_adc_state(struct dib7000m_state *state, enum dibx000_adc
302 break; 309 break;
303 } 310 }
304 311
305// dprintk( "913: %x, 914: %x", reg_913, reg_914); 312// dprintk("913: %x, 914: %x\n", reg_913, reg_914);
306 ret |= dib7000m_write_word(state, 913, reg_913); 313 ret |= dib7000m_write_word(state, 913, reg_913);
307 ret |= dib7000m_write_word(state, 914, reg_914); 314 ret |= dib7000m_write_word(state, 914, reg_914);
308 315
@@ -320,10 +327,10 @@ static int dib7000m_set_bandwidth(struct dib7000m_state *state, u32 bw)
320 state->current_bandwidth = bw; 327 state->current_bandwidth = bw;
321 328
322 if (state->timf == 0) { 329 if (state->timf == 0) {
323 dprintk( "using default timf"); 330 dprintk("using default timf\n");
324 timf = state->timf_default; 331 timf = state->timf_default;
325 } else { 332 } else {
326 dprintk( "using updated timf"); 333 dprintk("using updated timf\n");
327 timf = state->timf; 334 timf = state->timf;
328 } 335 }
329 336
@@ -340,7 +347,7 @@ static int dib7000m_set_diversity_in(struct dvb_frontend *demod, int onoff)
340 struct dib7000m_state *state = demod->demodulator_priv; 347 struct dib7000m_state *state = demod->demodulator_priv;
341 348
342 if (state->div_force_off) { 349 if (state->div_force_off) {
343 dprintk( "diversity combination deactivated - forced by COFDM parameters"); 350 dprintk("diversity combination deactivated - forced by COFDM parameters\n");
344 onoff = 0; 351 onoff = 0;
345 } 352 }
346 state->div_state = (u8)onoff; 353 state->div_state = (u8)onoff;
@@ -580,10 +587,10 @@ static int dib7000m_demod_reset(struct dib7000m_state *state)
580 dib7000mc_reset_pll(state); 587 dib7000mc_reset_pll(state);
581 588
582 if (dib7000m_reset_gpio(state) != 0) 589 if (dib7000m_reset_gpio(state) != 0)
583 dprintk( "GPIO reset was not successful."); 590 dprintk("GPIO reset was not successful.\n");
584 591
585 if (dib7000m_set_output_mode(state, OUTMODE_HIGH_Z) != 0) 592 if (dib7000m_set_output_mode(state, OUTMODE_HIGH_Z) != 0)
586 dprintk( "OUTPUT_MODE could not be reset."); 593 dprintk("OUTPUT_MODE could not be reset.\n");
587 594
588 /* unforce divstr regardless whether i2c enumeration was done or not */ 595 /* unforce divstr regardless whether i2c enumeration was done or not */
589 dib7000m_write_word(state, 1794, dib7000m_read_word(state, 1794) & ~(1 << 1) ); 596 dib7000m_write_word(state, 1794, dib7000m_read_word(state, 1794) & ~(1 << 1) );
@@ -650,7 +657,7 @@ static int dib7000m_agc_soft_split(struct dib7000m_state *state)
650 (agc - state->current_agc->split.min_thres) / 657 (agc - state->current_agc->split.min_thres) /
651 (state->current_agc->split.max_thres - state->current_agc->split.min_thres); 658 (state->current_agc->split.max_thres - state->current_agc->split.min_thres);
652 659
653 dprintk( "AGC split_offset: %d",split_offset); 660 dprintk("AGC split_offset: %d\n", split_offset);
654 661
655 // P_agc_force_split and P_agc_split_offset 662 // P_agc_force_split and P_agc_split_offset
656 return dib7000m_write_word(state, 103, (dib7000m_read_word(state, 103) & 0xff00) | split_offset); 663 return dib7000m_write_word(state, 103, (dib7000m_read_word(state, 103) & 0xff00) | split_offset);
@@ -687,7 +694,7 @@ static int dib7000m_set_agc_config(struct dib7000m_state *state, u8 band)
687 } 694 }
688 695
689 if (agc == NULL) { 696 if (agc == NULL) {
690 dprintk( "no valid AGC configuration found for band 0x%02x",band); 697 dprintk("no valid AGC configuration found for band 0x%02x\n", band);
691 return -EINVAL; 698 return -EINVAL;
692 } 699 }
693 700
@@ -703,7 +710,7 @@ static int dib7000m_set_agc_config(struct dib7000m_state *state, u8 band)
703 dib7000m_write_word(state, 98, (agc->alpha_mant << 5) | agc->alpha_exp); 710 dib7000m_write_word(state, 98, (agc->alpha_mant << 5) | agc->alpha_exp);
704 dib7000m_write_word(state, 99, (agc->beta_mant << 6) | agc->beta_exp); 711 dib7000m_write_word(state, 99, (agc->beta_mant << 6) | agc->beta_exp);
705 712
706 dprintk( "WBD: ref: %d, sel: %d, active: %d, alpha: %d", 713 dprintk("WBD: ref: %d, sel: %d, active: %d, alpha: %d\n",
707 state->wbd_ref != 0 ? state->wbd_ref : agc->wbd_ref, agc->wbd_sel, !agc->perform_agc_softsplit, agc->wbd_sel); 714 state->wbd_ref != 0 ? state->wbd_ref : agc->wbd_ref, agc->wbd_sel, !agc->perform_agc_softsplit, agc->wbd_sel);
708 715
709 /* AGC continued */ 716 /* AGC continued */
@@ -724,7 +731,7 @@ static int dib7000m_set_agc_config(struct dib7000m_state *state, u8 band)
724 731
725 if (state->revision > 0x4000) { // settings for the MC 732 if (state->revision > 0x4000) { // settings for the MC
726 dib7000m_write_word(state, 71, agc->agc1_pt3); 733 dib7000m_write_word(state, 71, agc->agc1_pt3);
727// dprintk( "929: %x %d %d", 734// dprintk("929: %x %d %d\n",
728// (dib7000m_read_word(state, 929) & 0xffe3) | (agc->wbd_inv << 4) | (agc->wbd_sel << 2), agc->wbd_inv, agc->wbd_sel); 735// (dib7000m_read_word(state, 929) & 0xffe3) | (agc->wbd_inv << 4) | (agc->wbd_sel << 2), agc->wbd_inv, agc->wbd_sel);
729 dib7000m_write_word(state, 929, (dib7000m_read_word(state, 929) & 0xffe3) | (agc->wbd_inv << 4) | (agc->wbd_sel << 2)); 736 dib7000m_write_word(state, 929, (dib7000m_read_word(state, 929) & 0xffe3) | (agc->wbd_inv << 4) | (agc->wbd_sel << 2));
730 } else { 737 } else {
@@ -742,7 +749,7 @@ static void dib7000m_update_timf(struct dib7000m_state *state)
742 state->timf = timf * 160 / (state->current_bandwidth / 50); 749 state->timf = timf * 160 / (state->current_bandwidth / 50);
743 dib7000m_write_word(state, 23, (u16) (timf >> 16)); 750 dib7000m_write_word(state, 23, (u16) (timf >> 16));
744 dib7000m_write_word(state, 24, (u16) (timf & 0xffff)); 751 dib7000m_write_word(state, 24, (u16) (timf & 0xffff));
745 dprintk( "updated timf_frequency: %d (default: %d)",state->timf, state->timf_default); 752 dprintk("updated timf_frequency: %d (default: %d)\n", state->timf, state->timf_default);
746} 753}
747 754
748static int dib7000m_agc_startup(struct dvb_frontend *demod) 755static int dib7000m_agc_startup(struct dvb_frontend *demod)
@@ -804,7 +811,7 @@ static int dib7000m_agc_startup(struct dvb_frontend *demod)
804 811
805 dib7000m_restart_agc(state); 812 dib7000m_restart_agc(state);
806 813
807 dprintk( "SPLIT %p: %hd", demod, agc_split); 814 dprintk("SPLIT %p: %hd\n", demod, agc_split);
808 815
809 (*agc_state)++; 816 (*agc_state)++;
810 ret = 5; 817 ret = 5;
@@ -1013,12 +1020,12 @@ static int dib7000m_autosearch_irq(struct dib7000m_state *state, u16 reg)
1013 u16 irq_pending = dib7000m_read_word(state, reg); 1020 u16 irq_pending = dib7000m_read_word(state, reg);
1014 1021
1015 if (irq_pending & 0x1) { // failed 1022 if (irq_pending & 0x1) { // failed
1016 dprintk( "autosearch failed"); 1023 dprintk("autosearch failed\n");
1017 return 1; 1024 return 1;
1018 } 1025 }
1019 1026
1020 if (irq_pending & 0x2) { // succeeded 1027 if (irq_pending & 0x2) { // succeeded
1021 dprintk( "autosearch succeeded"); 1028 dprintk("autosearch succeeded\n");
1022 return 2; 1029 return 2;
1023 } 1030 }
1024 return 0; // still pending 1031 return 0; // still pending
@@ -1102,7 +1109,7 @@ static int dib7000m_wakeup(struct dvb_frontend *demod)
1102 dib7000m_set_power_mode(state, DIB7000M_POWER_ALL); 1109 dib7000m_set_power_mode(state, DIB7000M_POWER_ALL);
1103 1110
1104 if (dib7000m_set_adc_state(state, DIBX000_SLOW_ADC_ON) != 0) 1111 if (dib7000m_set_adc_state(state, DIBX000_SLOW_ADC_ON) != 0)
1105 dprintk( "could not start Slow ADC"); 1112 dprintk("could not start Slow ADC\n");
1106 1113
1107 return 0; 1114 return 0;
1108} 1115}
@@ -1121,7 +1128,7 @@ static int dib7000m_identify(struct dib7000m_state *state)
1121 u16 value; 1128 u16 value;
1122 1129
1123 if ((value = dib7000m_read_word(state, 896)) != 0x01b3) { 1130 if ((value = dib7000m_read_word(state, 896)) != 0x01b3) {
1124 dprintk( "wrong Vendor ID (0x%x)",value); 1131 dprintk("wrong Vendor ID (0x%x)\n", value);
1125 return -EREMOTEIO; 1132 return -EREMOTEIO;
1126 } 1133 }
1127 1134
@@ -1130,21 +1137,21 @@ static int dib7000m_identify(struct dib7000m_state *state)
1130 state->revision != 0x4001 && 1137 state->revision != 0x4001 &&
1131 state->revision != 0x4002 && 1138 state->revision != 0x4002 &&
1132 state->revision != 0x4003) { 1139 state->revision != 0x4003) {
1133 dprintk( "wrong Device ID (0x%x)",value); 1140 dprintk("wrong Device ID (0x%x)\n", value);
1134 return -EREMOTEIO; 1141 return -EREMOTEIO;
1135 } 1142 }
1136 1143
1137 /* protect this driver to be used with 7000PC */ 1144 /* protect this driver to be used with 7000PC */
1138 if (state->revision == 0x4000 && dib7000m_read_word(state, 769) == 0x4000) { 1145 if (state->revision == 0x4000 && dib7000m_read_word(state, 769) == 0x4000) {
1139 dprintk( "this driver does not work with DiB7000PC"); 1146 dprintk("this driver does not work with DiB7000PC\n");
1140 return -EREMOTEIO; 1147 return -EREMOTEIO;
1141 } 1148 }
1142 1149
1143 switch (state->revision) { 1150 switch (state->revision) {
1144 case 0x4000: dprintk( "found DiB7000MA/PA/MB/PB"); break; 1151 case 0x4000: dprintk("found DiB7000MA/PA/MB/PB\n"); break;
1145 case 0x4001: state->reg_offs = 1; dprintk( "found DiB7000HC"); break; 1152 case 0x4001: state->reg_offs = 1; dprintk("found DiB7000HC\n"); break;
1146 case 0x4002: state->reg_offs = 1; dprintk( "found DiB7000MC"); break; 1153 case 0x4002: state->reg_offs = 1; dprintk("found DiB7000MC\n"); break;
1147 case 0x4003: state->reg_offs = 1; dprintk( "found DiB9000"); break; 1154 case 0x4003: state->reg_offs = 1; dprintk("found DiB9000\n"); break;
1148 } 1155 }
1149 1156
1150 return 0; 1157 return 0;
@@ -1242,7 +1249,7 @@ static int dib7000m_set_frontend(struct dvb_frontend *fe)
1242 found = dib7000m_autosearch_is_irq(fe); 1249 found = dib7000m_autosearch_is_irq(fe);
1243 } while (found == 0 && i--); 1250 } while (found == 0 && i--);
1244 1251
1245 dprintk("autosearch returns: %d",found); 1252 dprintk("autosearch returns: %d\n", found);
1246 if (found == 0 || found == 1) 1253 if (found == 0 || found == 1)
1247 return 0; // no channel found 1254 return 0; // no channel found
1248 1255
@@ -1330,7 +1337,7 @@ int dib7000m_pid_filter_ctrl(struct dvb_frontend *fe, u8 onoff)
1330 struct dib7000m_state *state = fe->demodulator_priv; 1337 struct dib7000m_state *state = fe->demodulator_priv;
1331 u16 val = dib7000m_read_word(state, 294 + state->reg_offs) & 0xffef; 1338 u16 val = dib7000m_read_word(state, 294 + state->reg_offs) & 0xffef;
1332 val |= (onoff & 0x1) << 4; 1339 val |= (onoff & 0x1) << 4;
1333 dprintk("PID filter enabled %d", onoff); 1340 dprintk("PID filter enabled %d\n", onoff);
1334 return dib7000m_write_word(state, 294 + state->reg_offs, val); 1341 return dib7000m_write_word(state, 294 + state->reg_offs, val);
1335} 1342}
1336EXPORT_SYMBOL(dib7000m_pid_filter_ctrl); 1343EXPORT_SYMBOL(dib7000m_pid_filter_ctrl);
@@ -1338,7 +1345,7 @@ EXPORT_SYMBOL(dib7000m_pid_filter_ctrl);
1338int dib7000m_pid_filter(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff) 1345int dib7000m_pid_filter(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff)
1339{ 1346{
1340 struct dib7000m_state *state = fe->demodulator_priv; 1347 struct dib7000m_state *state = fe->demodulator_priv;
1341 dprintk("PID filter: index %x, PID %d, OnOff %d", id, pid, onoff); 1348 dprintk("PID filter: index %x, PID %d, OnOff %d\n", id, pid, onoff);
1342 return dib7000m_write_word(state, 300 + state->reg_offs + id, 1349 return dib7000m_write_word(state, 300 + state->reg_offs + id,
1343 onoff ? (1 << 13) | pid : 0); 1350 onoff ? (1 << 13) | pid : 0);
1344} 1351}
@@ -1362,7 +1369,7 @@ int dib7000m_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods,
1362 if (dib7000m_identify(&st) != 0) { 1369 if (dib7000m_identify(&st) != 0) {
1363 st.i2c_addr = default_addr; 1370 st.i2c_addr = default_addr;
1364 if (dib7000m_identify(&st) != 0) { 1371 if (dib7000m_identify(&st) != 0) {
1365 dprintk("DiB7000M #%d: not identified", k); 1372 dprintk("DiB7000M #%d: not identified\n", k);
1366 return -EIO; 1373 return -EIO;
1367 } 1374 }
1368 } 1375 }
@@ -1375,7 +1382,7 @@ int dib7000m_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods,
1375 /* set new i2c address and force divstart */ 1382 /* set new i2c address and force divstart */
1376 dib7000m_write_word(&st, 1794, (new_addr << 2) | 0x2); 1383 dib7000m_write_word(&st, 1794, (new_addr << 2) | 0x2);
1377 1384
1378 dprintk("IC %d initialized (to i2c_address 0x%x)", k, new_addr); 1385 dprintk("IC %d initialized (to i2c_address 0x%x)\n", k, new_addr);
1379 } 1386 }
1380 1387
1381 for (k = 0; k < no_of_demods; k++) { 1388 for (k = 0; k < no_of_demods; k++) {
@@ -1394,7 +1401,7 @@ int dib7000m_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods,
1394EXPORT_SYMBOL(dib7000m_i2c_enumeration); 1401EXPORT_SYMBOL(dib7000m_i2c_enumeration);
1395#endif 1402#endif
1396 1403
1397static struct dvb_frontend_ops dib7000m_ops; 1404static const struct dvb_frontend_ops dib7000m_ops;
1398struct dvb_frontend * dib7000m_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib7000m_config *cfg) 1405struct dvb_frontend * dib7000m_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib7000m_config *cfg)
1399{ 1406{
1400 struct dvb_frontend *demod; 1407 struct dvb_frontend *demod;
@@ -1432,7 +1439,7 @@ error:
1432} 1439}
1433EXPORT_SYMBOL(dib7000m_attach); 1440EXPORT_SYMBOL(dib7000m_attach);
1434 1441
1435static struct dvb_frontend_ops dib7000m_ops = { 1442static const struct dvb_frontend_ops dib7000m_ops = {
1436 .delsys = { SYS_DVBT }, 1443 .delsys = { SYS_DVBT },
1437 .info = { 1444 .info = {
1438 .name = "DiBcom 7000MA/MB/PA/PB/MC", 1445 .name = "DiBcom 7000MA/MB/PA/PB/MC",
diff --git a/drivers/media/dvb-frontends/dib7000p.c b/drivers/media/dvb-frontends/dib7000p.c
index b861d4437f2a..a27c0001f2d6 100644
--- a/drivers/media/dvb-frontends/dib7000p.c
+++ b/drivers/media/dvb-frontends/dib7000p.c
@@ -7,6 +7,9 @@
7 * modify it under the terms of the GNU General Public License as 7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2. 8 * published by the Free Software Foundation, version 2.
9 */ 9 */
10
11#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
12
10#include <linux/kernel.h> 13#include <linux/kernel.h>
11#include <linux/slab.h> 14#include <linux/slab.h>
12#include <linux/i2c.h> 15#include <linux/i2c.h>
@@ -26,7 +29,11 @@ static int buggy_sfn_workaround;
26module_param(buggy_sfn_workaround, int, 0644); 29module_param(buggy_sfn_workaround, int, 0644);
27MODULE_PARM_DESC(buggy_sfn_workaround, "Enable work-around for buggy SFNs (default: 0)"); 30MODULE_PARM_DESC(buggy_sfn_workaround, "Enable work-around for buggy SFNs (default: 0)");
28 31
29#define dprintk(args...) do { if (debug) { printk(KERN_DEBUG "DiB7000P: "); printk(args); printk("\n"); } } while (0) 32#define dprintk(fmt, arg...) do { \
33 if (debug) \
34 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
35 __func__, ##arg); \
36} while (0)
30 37
31struct i2c_device { 38struct i2c_device {
32 struct i2c_adapter *i2c_adap; 39 struct i2c_adapter *i2c_adap;
@@ -98,7 +105,7 @@ static u16 dib7000p_read_word(struct dib7000p_state *state, u16 reg)
98 u16 ret; 105 u16 ret;
99 106
100 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { 107 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
101 dprintk("could not acquire lock"); 108 dprintk("could not acquire lock\n");
102 return 0; 109 return 0;
103 } 110 }
104 111
@@ -116,7 +123,7 @@ static u16 dib7000p_read_word(struct dib7000p_state *state, u16 reg)
116 state->msg[1].len = 2; 123 state->msg[1].len = 2;
117 124
118 if (i2c_transfer(state->i2c_adap, state->msg, 2) != 2) 125 if (i2c_transfer(state->i2c_adap, state->msg, 2) != 2)
119 dprintk("i2c read error on %d", reg); 126 dprintk("i2c read error on %d\n", reg);
120 127
121 ret = (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1]; 128 ret = (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
122 mutex_unlock(&state->i2c_buffer_lock); 129 mutex_unlock(&state->i2c_buffer_lock);
@@ -128,7 +135,7 @@ static int dib7000p_write_word(struct dib7000p_state *state, u16 reg, u16 val)
128 int ret; 135 int ret;
129 136
130 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { 137 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
131 dprintk("could not acquire lock"); 138 dprintk("could not acquire lock\n");
132 return -EINVAL; 139 return -EINVAL;
133 } 140 }
134 141
@@ -174,7 +181,7 @@ static int dib7000p_set_output_mode(struct dib7000p_state *state, int mode)
174 fifo_threshold = 1792; 181 fifo_threshold = 1792;
175 smo_mode = (dib7000p_read_word(state, 235) & 0x0050) | (1 << 1); 182 smo_mode = (dib7000p_read_word(state, 235) & 0x0050) | (1 << 1);
176 183
177 dprintk("setting output mode for demod %p to %d", &state->demod, mode); 184 dprintk("setting output mode for demod %p to %d\n", &state->demod, mode);
178 185
179 switch (mode) { 186 switch (mode) {
180 case OUTMODE_MPEG2_PAR_GATED_CLK: 187 case OUTMODE_MPEG2_PAR_GATED_CLK:
@@ -204,7 +211,7 @@ static int dib7000p_set_output_mode(struct dib7000p_state *state, int mode)
204 outreg = 0; 211 outreg = 0;
205 break; 212 break;
206 default: 213 default:
207 dprintk("Unhandled output_mode passed to be set for demod %p", &state->demod); 214 dprintk("Unhandled output_mode passed to be set for demod %p\n", &state->demod);
208 break; 215 break;
209 } 216 }
210 217
@@ -224,7 +231,7 @@ static int dib7000p_set_diversity_in(struct dvb_frontend *demod, int onoff)
224 struct dib7000p_state *state = demod->demodulator_priv; 231 struct dib7000p_state *state = demod->demodulator_priv;
225 232
226 if (state->div_force_off) { 233 if (state->div_force_off) {
227 dprintk("diversity combination deactivated - forced by COFDM parameters"); 234 dprintk("diversity combination deactivated - forced by COFDM parameters\n");
228 onoff = 0; 235 onoff = 0;
229 dib7000p_write_word(state, 207, 0); 236 dib7000p_write_word(state, 207, 0);
230 } else 237 } else
@@ -374,10 +381,10 @@ static int dib7000p_set_bandwidth(struct dib7000p_state *state, u32 bw)
374 state->current_bandwidth = bw; 381 state->current_bandwidth = bw;
375 382
376 if (state->timf == 0) { 383 if (state->timf == 0) {
377 dprintk("using default timf"); 384 dprintk("using default timf\n");
378 timf = state->cfg.bw->timf; 385 timf = state->cfg.bw->timf;
379 } else { 386 } else {
380 dprintk("using updated timf"); 387 dprintk("using updated timf\n");
381 timf = state->timf; 388 timf = state->timf;
382 } 389 }
383 390
@@ -494,7 +501,7 @@ static int dib7000p_update_pll(struct dvb_frontend *fe, struct dibx000_bandwidth
494 loopdiv = (reg_1856 >> 6) & 0x3f; 501 loopdiv = (reg_1856 >> 6) & 0x3f;
495 502
496 if ((bw != NULL) && (bw->pll_prediv != prediv || bw->pll_ratio != loopdiv)) { 503 if ((bw != NULL) && (bw->pll_prediv != prediv || bw->pll_ratio != loopdiv)) {
497 dprintk("Updating pll (prediv: old = %d new = %d ; loopdiv : old = %d new = %d)", prediv, bw->pll_prediv, loopdiv, bw->pll_ratio); 504 dprintk("Updating pll (prediv: old = %d new = %d ; loopdiv : old = %d new = %d)\n", prediv, bw->pll_prediv, loopdiv, bw->pll_ratio);
498 reg_1856 &= 0xf000; 505 reg_1856 &= 0xf000;
499 reg_1857 = dib7000p_read_word(state, 1857); 506 reg_1857 = dib7000p_read_word(state, 1857);
500 dib7000p_write_word(state, 1857, reg_1857 & ~(1 << 15)); 507 dib7000p_write_word(state, 1857, reg_1857 & ~(1 << 15));
@@ -511,7 +518,7 @@ static int dib7000p_update_pll(struct dvb_frontend *fe, struct dibx000_bandwidth
511 dib7000p_write_word(state, 1857, reg_1857 | (1 << 15)); 518 dib7000p_write_word(state, 1857, reg_1857 | (1 << 15));
512 519
513 while (((dib7000p_read_word(state, 1856) >> 15) & 0x1) != 1) 520 while (((dib7000p_read_word(state, 1856) >> 15) & 0x1) != 1)
514 dprintk("Waiting for PLL to lock"); 521 dprintk("Waiting for PLL to lock\n");
515 522
516 return 0; 523 return 0;
517 } 524 }
@@ -521,7 +528,7 @@ static int dib7000p_update_pll(struct dvb_frontend *fe, struct dibx000_bandwidth
521static int dib7000p_reset_gpio(struct dib7000p_state *st) 528static int dib7000p_reset_gpio(struct dib7000p_state *st)
522{ 529{
523 /* reset the GPIOs */ 530 /* reset the GPIOs */
524 dprintk("gpio dir: %x: val: %x, pwm_pos: %x", st->gpio_dir, st->gpio_val, st->cfg.gpio_pwm_pos); 531 dprintk("gpio dir: %x: val: %x, pwm_pos: %x\n", st->gpio_dir, st->gpio_val, st->cfg.gpio_pwm_pos);
525 532
526 dib7000p_write_word(st, 1029, st->gpio_dir); 533 dib7000p_write_word(st, 1029, st->gpio_dir);
527 dib7000p_write_word(st, 1030, st->gpio_val); 534 dib7000p_write_word(st, 1030, st->gpio_val);
@@ -669,7 +676,7 @@ static int dib7000p_demod_reset(struct dib7000p_state *state)
669 dib7000p_reset_pll(state); 676 dib7000p_reset_pll(state);
670 677
671 if (dib7000p_reset_gpio(state) != 0) 678 if (dib7000p_reset_gpio(state) != 0)
672 dprintk("GPIO reset was not successful."); 679 dprintk("GPIO reset was not successful.\n");
673 680
674 if (state->version == SOC7090) { 681 if (state->version == SOC7090) {
675 dib7000p_write_word(state, 899, 0); 682 dib7000p_write_word(state, 899, 0);
@@ -681,7 +688,7 @@ static int dib7000p_demod_reset(struct dib7000p_state *state)
681 dib7000p_write_word(state, 273, (0<<6) | 30); 688 dib7000p_write_word(state, 273, (0<<6) | 30);
682 } 689 }
683 if (dib7000p_set_output_mode(state, OUTMODE_HIGH_Z) != 0) 690 if (dib7000p_set_output_mode(state, OUTMODE_HIGH_Z) != 0)
684 dprintk("OUTPUT_MODE could not be reset."); 691 dprintk("OUTPUT_MODE could not be reset.\n");
685 692
686 dib7000p_set_adc_state(state, DIBX000_SLOW_ADC_ON); 693 dib7000p_set_adc_state(state, DIBX000_SLOW_ADC_ON);
687 dib7000p_sad_calib(state); 694 dib7000p_sad_calib(state);
@@ -759,7 +766,7 @@ static int dib7000p_set_agc_config(struct dib7000p_state *state, u8 band)
759 } 766 }
760 767
761 if (agc == NULL) { 768 if (agc == NULL) {
762 dprintk("no valid AGC configuration found for band 0x%02x", band); 769 dprintk("no valid AGC configuration found for band 0x%02x\n", band);
763 return -EINVAL; 770 return -EINVAL;
764 } 771 }
765 772
@@ -776,7 +783,7 @@ static int dib7000p_set_agc_config(struct dib7000p_state *state, u8 band)
776 dib7000p_write_word(state, 102, (agc->beta_mant << 6) | agc->beta_exp); 783 dib7000p_write_word(state, 102, (agc->beta_mant << 6) | agc->beta_exp);
777 784
778 /* AGC continued */ 785 /* AGC continued */
779 dprintk("WBD: ref: %d, sel: %d, active: %d, alpha: %d", 786 dprintk("WBD: ref: %d, sel: %d, active: %d, alpha: %d\n",
780 state->wbd_ref != 0 ? state->wbd_ref : agc->wbd_ref, agc->wbd_sel, !agc->perform_agc_softsplit, agc->wbd_sel); 787 state->wbd_ref != 0 ? state->wbd_ref : agc->wbd_ref, agc->wbd_sel, !agc->perform_agc_softsplit, agc->wbd_sel);
781 788
782 if (state->wbd_ref != 0) 789 if (state->wbd_ref != 0)
@@ -806,7 +813,7 @@ static void dib7000p_set_dds(struct dib7000p_state *state, s32 offset_khz)
806 u32 dds = state->cfg.bw->ifreq & 0x1ffffff; 813 u32 dds = state->cfg.bw->ifreq & 0x1ffffff;
807 u8 invert = !!(state->cfg.bw->ifreq & (1 << 25)); 814 u8 invert = !!(state->cfg.bw->ifreq & (1 << 25));
808 815
809 dprintk("setting a frequency offset of %dkHz internal freq = %d invert = %d", offset_khz, internal, invert); 816 dprintk("setting a frequency offset of %dkHz internal freq = %d invert = %d\n", offset_khz, internal, invert);
810 817
811 if (offset_khz < 0) 818 if (offset_khz < 0)
812 unit_khz_dds_val *= -1; 819 unit_khz_dds_val *= -1;
@@ -902,7 +909,7 @@ static int dib7000p_agc_startup(struct dvb_frontend *demod)
902 909
903 dib7000p_restart_agc(state); 910 dib7000p_restart_agc(state);
904 911
905 dprintk("SPLIT %p: %hd", demod, agc_split); 912 dprintk("SPLIT %p: %hd\n", demod, agc_split);
906 913
907 (*agc_state)++; 914 (*agc_state)++;
908 ret = 5; 915 ret = 5;
@@ -934,7 +941,7 @@ static void dib7000p_update_timf(struct dib7000p_state *state)
934 state->timf = timf * 160 / (state->current_bandwidth / 50); 941 state->timf = timf * 160 / (state->current_bandwidth / 50);
935 dib7000p_write_word(state, 23, (u16) (timf >> 16)); 942 dib7000p_write_word(state, 23, (u16) (timf >> 16));
936 dib7000p_write_word(state, 24, (u16) (timf & 0xffff)); 943 dib7000p_write_word(state, 24, (u16) (timf & 0xffff));
937 dprintk("updated timf_frequency: %d (default: %d)", state->timf, state->cfg.bw->timf); 944 dprintk("updated timf_frequency: %d (default: %d)\n", state->timf, state->cfg.bw->timf);
938 945
939} 946}
940 947
@@ -1202,7 +1209,7 @@ static void dib7000p_spur_protect(struct dib7000p_state *state, u32 rf_khz, u32
1202 int bw_khz = bw; 1209 int bw_khz = bw;
1203 u32 pha; 1210 u32 pha;
1204 1211
1205 dprintk("relative position of the Spur: %dk (RF: %dk, XTAL: %dk)", f_rel, rf_khz, xtal); 1212 dprintk("relative position of the Spur: %dk (RF: %dk, XTAL: %dk)\n", f_rel, rf_khz, xtal);
1206 1213
1207 if (f_rel < -bw_khz / 2 || f_rel > bw_khz / 2) 1214 if (f_rel < -bw_khz / 2 || f_rel > bw_khz / 2)
1208 return; 1215 return;
@@ -1252,7 +1259,7 @@ static void dib7000p_spur_protect(struct dib7000p_state *state, u32 rf_khz, u32
1252 coef_im[k] = (1 << 24) - 1; 1259 coef_im[k] = (1 << 24) - 1;
1253 coef_im[k] /= (1 << 15); 1260 coef_im[k] /= (1 << 15);
1254 1261
1255 dprintk("PALF COEF: %d re: %d im: %d", k, coef_re[k], coef_im[k]); 1262 dprintk("PALF COEF: %d re: %d im: %d\n", k, coef_re[k], coef_im[k]);
1256 1263
1257 dib7000p_write_word(state, 143, (0 << 14) | (k << 10) | (coef_re[k] & 0x3ff)); 1264 dib7000p_write_word(state, 143, (0 << 14) | (k << 10) | (coef_re[k] & 0x3ff));
1258 dib7000p_write_word(state, 144, coef_im[k] & 0x3ff); 1265 dib7000p_write_word(state, 144, coef_im[k] & 0x3ff);
@@ -1280,7 +1287,7 @@ static int dib7000p_tune(struct dvb_frontend *demod)
1280 /* P_ctrl_inh_cor=0, P_ctrl_alpha_cor=4, P_ctrl_inh_isi=0, P_ctrl_alpha_isi=3, P_ctrl_inh_cor4=1, P_ctrl_alpha_cor4=3 */ 1287 /* P_ctrl_inh_cor=0, P_ctrl_alpha_cor=4, P_ctrl_inh_isi=0, P_ctrl_alpha_isi=3, P_ctrl_inh_cor4=1, P_ctrl_alpha_cor4=3 */
1281 tmp = (0 << 14) | (4 << 10) | (0 << 9) | (3 << 5) | (1 << 4) | (0x3); 1288 tmp = (0 << 14) | (4 << 10) | (0 << 9) | (3 << 5) | (1 << 4) | (0x3);
1282 if (state->sfn_workaround_active) { 1289 if (state->sfn_workaround_active) {
1283 dprintk("SFN workaround is active"); 1290 dprintk("SFN workaround is active\n");
1284 tmp |= (1 << 9); 1291 tmp |= (1 << 9);
1285 dib7000p_write_word(state, 166, 0x4000); 1292 dib7000p_write_word(state, 166, 0x4000);
1286 } else { 1293 } else {
@@ -1390,15 +1397,15 @@ static int dib7000p_sleep(struct dvb_frontend *demod)
1390static int dib7000p_identify(struct dib7000p_state *st) 1397static int dib7000p_identify(struct dib7000p_state *st)
1391{ 1398{
1392 u16 value; 1399 u16 value;
1393 dprintk("checking demod on I2C address: %d (%x)", st->i2c_addr, st->i2c_addr); 1400 dprintk("checking demod on I2C address: %d (%x)\n", st->i2c_addr, st->i2c_addr);
1394 1401
1395 if ((value = dib7000p_read_word(st, 768)) != 0x01b3) { 1402 if ((value = dib7000p_read_word(st, 768)) != 0x01b3) {
1396 dprintk("wrong Vendor ID (read=0x%x)", value); 1403 dprintk("wrong Vendor ID (read=0x%x)\n", value);
1397 return -EREMOTEIO; 1404 return -EREMOTEIO;
1398 } 1405 }
1399 1406
1400 if ((value = dib7000p_read_word(st, 769)) != 0x4000) { 1407 if ((value = dib7000p_read_word(st, 769)) != 0x4000) {
1401 dprintk("wrong Device ID (%x)", value); 1408 dprintk("wrong Device ID (%x)\n", value);
1402 return -EREMOTEIO; 1409 return -EREMOTEIO;
1403 } 1410 }
1404 1411
@@ -1536,7 +1543,7 @@ static int dib7000p_set_frontend(struct dvb_frontend *fe)
1536 found = dib7000p_autosearch_is_irq(fe); 1543 found = dib7000p_autosearch_is_irq(fe);
1537 } while (found == 0 && i--); 1544 } while (found == 0 && i--);
1538 1545
1539 dprintk("autosearch returns: %d", found); 1546 dprintk("autosearch returns: %d\n", found);
1540 if (found == 0 || found == 1) 1547 if (found == 0 || found == 1)
1541 return 0; 1548 return 0;
1542 1549
@@ -1951,7 +1958,7 @@ static int dib7000p_get_stats(struct dvb_frontend *demod, enum fe_status stat)
1951 time_us = dib7000p_get_time_us(demod); 1958 time_us = dib7000p_get_time_us(demod);
1952 state->ber_jiffies_stats = jiffies + msecs_to_jiffies((time_us + 500) / 1000); 1959 state->ber_jiffies_stats = jiffies + msecs_to_jiffies((time_us + 500) / 1000);
1953 1960
1954 dprintk("Next all layers stats available in %u us.", time_us); 1961 dprintk("Next all layers stats available in %u us.\n", time_us);
1955 1962
1956 dib7000p_read_ber(demod, &val); 1963 dib7000p_read_ber(demod, &val);
1957 c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER; 1964 c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER;
@@ -2019,7 +2026,7 @@ static int dib7000pc_detection(struct i2c_adapter *i2c_adap)
2019 2026
2020 if (i2c_transfer(i2c_adap, msg, 2) == 2) 2027 if (i2c_transfer(i2c_adap, msg, 2) == 2)
2021 if (rx[0] == 0x01 && rx[1] == 0xb3) { 2028 if (rx[0] == 0x01 && rx[1] == 0xb3) {
2022 dprintk("-D- DiB7000PC detected"); 2029 dprintk("-D- DiB7000PC detected\n");
2023 return 1; 2030 return 1;
2024 } 2031 }
2025 2032
@@ -2027,11 +2034,11 @@ static int dib7000pc_detection(struct i2c_adapter *i2c_adap)
2027 2034
2028 if (i2c_transfer(i2c_adap, msg, 2) == 2) 2035 if (i2c_transfer(i2c_adap, msg, 2) == 2)
2029 if (rx[0] == 0x01 && rx[1] == 0xb3) { 2036 if (rx[0] == 0x01 && rx[1] == 0xb3) {
2030 dprintk("-D- DiB7000PC detected"); 2037 dprintk("-D- DiB7000PC detected\n");
2031 return 1; 2038 return 1;
2032 } 2039 }
2033 2040
2034 dprintk("-D- DiB7000PC not detected"); 2041 dprintk("-D- DiB7000PC not detected\n");
2035 2042
2036 kfree(rx); 2043 kfree(rx);
2037rx_memory_error: 2044rx_memory_error:
@@ -2050,14 +2057,14 @@ static int dib7000p_pid_filter_ctrl(struct dvb_frontend *fe, u8 onoff)
2050 struct dib7000p_state *state = fe->demodulator_priv; 2057 struct dib7000p_state *state = fe->demodulator_priv;
2051 u16 val = dib7000p_read_word(state, 235) & 0xffef; 2058 u16 val = dib7000p_read_word(state, 235) & 0xffef;
2052 val |= (onoff & 0x1) << 4; 2059 val |= (onoff & 0x1) << 4;
2053 dprintk("PID filter enabled %d", onoff); 2060 dprintk("PID filter enabled %d\n", onoff);
2054 return dib7000p_write_word(state, 235, val); 2061 return dib7000p_write_word(state, 235, val);
2055} 2062}
2056 2063
2057static int dib7000p_pid_filter(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff) 2064static int dib7000p_pid_filter(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff)
2058{ 2065{
2059 struct dib7000p_state *state = fe->demodulator_priv; 2066 struct dib7000p_state *state = fe->demodulator_priv;
2060 dprintk("PID filter: index %x, PID %d, OnOff %d", id, pid, onoff); 2067 dprintk("PID filter: index %x, PID %d, OnOff %d\n", id, pid, onoff);
2061 return dib7000p_write_word(state, 241 + id, onoff ? (1 << 13) | pid : 0); 2068 return dib7000p_write_word(state, 241 + id, onoff ? (1 << 13) | pid : 0);
2062} 2069}
2063 2070
@@ -2100,7 +2107,7 @@ static int dib7000p_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u
2100 /* set new i2c address and force divstart */ 2107 /* set new i2c address and force divstart */
2101 dib7000p_write_word(dpst, 1285, (new_addr << 2) | 0x2); 2108 dib7000p_write_word(dpst, 1285, (new_addr << 2) | 0x2);
2102 2109
2103 dprintk("IC %d initialized (to i2c_address 0x%x)", k, new_addr); 2110 dprintk("IC %d initialized (to i2c_address 0x%x)\n", k, new_addr);
2104 } 2111 }
2105 2112
2106 for (k = 0; k < no_of_demods; k++) { 2113 for (k = 0; k < no_of_demods; k++) {
@@ -2136,21 +2143,21 @@ static s32 dib7000p_get_adc_power(struct dvb_frontend *fe)
2136 buf[0] = dib7000p_read_word(state, 0x184); 2143 buf[0] = dib7000p_read_word(state, 0x184);
2137 buf[1] = dib7000p_read_word(state, 0x185); 2144 buf[1] = dib7000p_read_word(state, 0x185);
2138 pow_i = (buf[0] << 16) | buf[1]; 2145 pow_i = (buf[0] << 16) | buf[1];
2139 dprintk("raw pow_i = %d", pow_i); 2146 dprintk("raw pow_i = %d\n", pow_i);
2140 2147
2141 tmp_val = pow_i; 2148 tmp_val = pow_i;
2142 while (tmp_val >>= 1) 2149 while (tmp_val >>= 1)
2143 exp++; 2150 exp++;
2144 2151
2145 mant = (pow_i * 1000 / (1 << exp)); 2152 mant = (pow_i * 1000 / (1 << exp));
2146 dprintk(" mant = %d exp = %d", mant / 1000, exp); 2153 dprintk(" mant = %d exp = %d\n", mant / 1000, exp);
2147 2154
2148 ix = (u8) ((mant - 1000) / 100); /* index of the LUT */ 2155 ix = (u8) ((mant - 1000) / 100); /* index of the LUT */
2149 dprintk(" ix = %d", ix); 2156 dprintk(" ix = %d\n", ix);
2150 2157
2151 pow_i = (lut_1000ln_mant[ix] + 693 * (exp - 20) - 6908); 2158 pow_i = (lut_1000ln_mant[ix] + 693 * (exp - 20) - 6908);
2152 pow_i = (pow_i << 8) / 1000; 2159 pow_i = (pow_i << 8) / 1000;
2153 dprintk(" pow_i = %d", pow_i); 2160 dprintk(" pow_i = %d\n", pow_i);
2154 2161
2155 return pow_i; 2162 return pow_i;
2156} 2163}
@@ -2185,7 +2192,7 @@ static int w7090p_tuner_write_serpar(struct i2c_adapter *i2c_adap, struct i2c_ms
2185 n_overflow = (dib7000p_read_word(state, 1984) >> 1) & 0x1; 2192 n_overflow = (dib7000p_read_word(state, 1984) >> 1) & 0x1;
2186 i--; 2193 i--;
2187 if (i == 0) 2194 if (i == 0)
2188 dprintk("Tuner ITF: write busy (overflow)"); 2195 dprintk("Tuner ITF: write busy (overflow)\n");
2189 } 2196 }
2190 dib7000p_write_word(state, 1985, (1 << 6) | (serpar_num & 0x3f)); 2197 dib7000p_write_word(state, 1985, (1 << 6) | (serpar_num & 0x3f));
2191 dib7000p_write_word(state, 1986, (msg[0].buf[1] << 8) | msg[0].buf[2]); 2198 dib7000p_write_word(state, 1986, (msg[0].buf[1] << 8) | msg[0].buf[2]);
@@ -2205,7 +2212,7 @@ static int w7090p_tuner_read_serpar(struct i2c_adapter *i2c_adap, struct i2c_msg
2205 n_overflow = (dib7000p_read_word(state, 1984) >> 1) & 0x1; 2212 n_overflow = (dib7000p_read_word(state, 1984) >> 1) & 0x1;
2206 i--; 2213 i--;
2207 if (i == 0) 2214 if (i == 0)
2208 dprintk("TunerITF: read busy (overflow)"); 2215 dprintk("TunerITF: read busy (overflow)\n");
2209 } 2216 }
2210 dib7000p_write_word(state, 1985, (0 << 6) | (serpar_num & 0x3f)); 2217 dib7000p_write_word(state, 1985, (0 << 6) | (serpar_num & 0x3f));
2211 2218
@@ -2214,7 +2221,7 @@ static int w7090p_tuner_read_serpar(struct i2c_adapter *i2c_adap, struct i2c_msg
2214 n_empty = dib7000p_read_word(state, 1984) & 0x1; 2221 n_empty = dib7000p_read_word(state, 1984) & 0x1;
2215 i--; 2222 i--;
2216 if (i == 0) 2223 if (i == 0)
2217 dprintk("TunerITF: read busy (empty)"); 2224 dprintk("TunerITF: read busy (empty)\n");
2218 } 2225 }
2219 read_word = dib7000p_read_word(state, 1987); 2226 read_word = dib7000p_read_word(state, 1987);
2220 msg[1].buf[0] = (read_word >> 8) & 0xff; 2227 msg[1].buf[0] = (read_word >> 8) & 0xff;
@@ -2435,7 +2442,7 @@ static u32 dib7090_calcSyncFreq(u32 P_Kin, u32 P_Kout, u32 insertExtSynchro, u32
2435 2442
2436static int dib7090_cfg_DibTx(struct dib7000p_state *state, u32 P_Kin, u32 P_Kout, u32 insertExtSynchro, u32 synchroMode, u32 syncWord, u32 syncSize) 2443static int dib7090_cfg_DibTx(struct dib7000p_state *state, u32 P_Kin, u32 P_Kout, u32 insertExtSynchro, u32 synchroMode, u32 syncWord, u32 syncSize)
2437{ 2444{
2438 dprintk("Configure DibStream Tx"); 2445 dprintk("Configure DibStream Tx\n");
2439 2446
2440 dib7000p_write_word(state, 1615, 1); 2447 dib7000p_write_word(state, 1615, 1);
2441 dib7000p_write_word(state, 1603, P_Kin); 2448 dib7000p_write_word(state, 1603, P_Kin);
@@ -2455,7 +2462,7 @@ static int dib7090_cfg_DibRx(struct dib7000p_state *state, u32 P_Kin, u32 P_Kout
2455{ 2462{
2456 u32 syncFreq; 2463 u32 syncFreq;
2457 2464
2458 dprintk("Configure DibStream Rx"); 2465 dprintk("Configure DibStream Rx\n");
2459 if ((P_Kin != 0) && (P_Kout != 0)) { 2466 if ((P_Kin != 0) && (P_Kout != 0)) {
2460 syncFreq = dib7090_calcSyncFreq(P_Kin, P_Kout, insertExtSynchro, syncSize); 2467 syncFreq = dib7090_calcSyncFreq(P_Kin, P_Kout, insertExtSynchro, syncSize);
2461 dib7000p_write_word(state, 1542, syncFreq); 2468 dib7000p_write_word(state, 1542, syncFreq);
@@ -2492,7 +2499,7 @@ static void dib7090_enMpegMux(struct dib7000p_state *state, int onoff)
2492static void dib7090_configMpegMux(struct dib7000p_state *state, 2499static void dib7090_configMpegMux(struct dib7000p_state *state,
2493 u16 pulseWidth, u16 enSerialMode, u16 enSerialClkDiv2) 2500 u16 pulseWidth, u16 enSerialMode, u16 enSerialClkDiv2)
2494{ 2501{
2495 dprintk("Enable Mpeg mux"); 2502 dprintk("Enable Mpeg mux\n");
2496 2503
2497 dib7090_enMpegMux(state, 0); 2504 dib7090_enMpegMux(state, 0);
2498 2505
@@ -2513,17 +2520,17 @@ static void dib7090_setDibTxMux(struct dib7000p_state *state, int mode)
2513 2520
2514 switch (mode) { 2521 switch (mode) {
2515 case MPEG_ON_DIBTX: 2522 case MPEG_ON_DIBTX:
2516 dprintk("SET MPEG ON DIBSTREAM TX"); 2523 dprintk("SET MPEG ON DIBSTREAM TX\n");
2517 dib7090_cfg_DibTx(state, 8, 5, 0, 0, 0, 0); 2524 dib7090_cfg_DibTx(state, 8, 5, 0, 0, 0, 0);
2518 reg_1288 |= (1<<9); 2525 reg_1288 |= (1<<9);
2519 break; 2526 break;
2520 case DIV_ON_DIBTX: 2527 case DIV_ON_DIBTX:
2521 dprintk("SET DIV_OUT ON DIBSTREAM TX"); 2528 dprintk("SET DIV_OUT ON DIBSTREAM TX\n");
2522 dib7090_cfg_DibTx(state, 5, 5, 0, 0, 0, 0); 2529 dib7090_cfg_DibTx(state, 5, 5, 0, 0, 0, 0);
2523 reg_1288 |= (1<<8); 2530 reg_1288 |= (1<<8);
2524 break; 2531 break;
2525 case ADC_ON_DIBTX: 2532 case ADC_ON_DIBTX:
2526 dprintk("SET ADC_OUT ON DIBSTREAM TX"); 2533 dprintk("SET ADC_OUT ON DIBSTREAM TX\n");
2527 dib7090_cfg_DibTx(state, 20, 5, 10, 0, 0, 0); 2534 dib7090_cfg_DibTx(state, 20, 5, 10, 0, 0, 0);
2528 reg_1288 |= (1<<7); 2535 reg_1288 |= (1<<7);
2529 break; 2536 break;
@@ -2539,17 +2546,17 @@ static void dib7090_setHostBusMux(struct dib7000p_state *state, int mode)
2539 2546
2540 switch (mode) { 2547 switch (mode) {
2541 case DEMOUT_ON_HOSTBUS: 2548 case DEMOUT_ON_HOSTBUS:
2542 dprintk("SET DEM OUT OLD INTERF ON HOST BUS"); 2549 dprintk("SET DEM OUT OLD INTERF ON HOST BUS\n");
2543 dib7090_enMpegMux(state, 0); 2550 dib7090_enMpegMux(state, 0);
2544 reg_1288 |= (1<<6); 2551 reg_1288 |= (1<<6);
2545 break; 2552 break;
2546 case DIBTX_ON_HOSTBUS: 2553 case DIBTX_ON_HOSTBUS:
2547 dprintk("SET DIBSTREAM TX ON HOST BUS"); 2554 dprintk("SET DIBSTREAM TX ON HOST BUS\n");
2548 dib7090_enMpegMux(state, 0); 2555 dib7090_enMpegMux(state, 0);
2549 reg_1288 |= (1<<5); 2556 reg_1288 |= (1<<5);
2550 break; 2557 break;
2551 case MPEG_ON_HOSTBUS: 2558 case MPEG_ON_HOSTBUS:
2552 dprintk("SET MPEG MUX ON HOST BUS"); 2559 dprintk("SET MPEG MUX ON HOST BUS\n");
2553 reg_1288 |= (1<<4); 2560 reg_1288 |= (1<<4);
2554 break; 2561 break;
2555 default: 2562 default:
@@ -2565,7 +2572,7 @@ static int dib7090_set_diversity_in(struct dvb_frontend *fe, int onoff)
2565 2572
2566 switch (onoff) { 2573 switch (onoff) {
2567 case 0: /* only use the internal way - not the diversity input */ 2574 case 0: /* only use the internal way - not the diversity input */
2568 dprintk("%s mode OFF : by default Enable Mpeg INPUT", __func__); 2575 dprintk("%s mode OFF : by default Enable Mpeg INPUT\n", __func__);
2569 dib7090_cfg_DibRx(state, 8, 5, 0, 0, 0, 8, 0); 2576 dib7090_cfg_DibRx(state, 8, 5, 0, 0, 0, 8, 0);
2570 2577
2571 /* Do not divide the serial clock of MPEG MUX */ 2578 /* Do not divide the serial clock of MPEG MUX */
@@ -2581,7 +2588,7 @@ static int dib7090_set_diversity_in(struct dvb_frontend *fe, int onoff)
2581 break; 2588 break;
2582 case 1: /* both ways */ 2589 case 1: /* both ways */
2583 case 2: /* only the diversity input */ 2590 case 2: /* only the diversity input */
2584 dprintk("%s ON : Enable diversity INPUT", __func__); 2591 dprintk("%s ON : Enable diversity INPUT\n", __func__);
2585 dib7090_cfg_DibRx(state, 5, 5, 0, 0, 0, 0, 0); 2592 dib7090_cfg_DibRx(state, 5, 5, 0, 0, 0, 0, 0);
2586 state->input_mode_mpeg = 0; 2593 state->input_mode_mpeg = 0;
2587 break; 2594 break;
@@ -2612,11 +2619,11 @@ static int dib7090_set_output_mode(struct dvb_frontend *fe, int mode)
2612 2619
2613 case OUTMODE_MPEG2_SERIAL: 2620 case OUTMODE_MPEG2_SERIAL:
2614 if (prefer_mpeg_mux_use) { 2621 if (prefer_mpeg_mux_use) {
2615 dprintk("setting output mode TS_SERIAL using Mpeg Mux"); 2622 dprintk("setting output mode TS_SERIAL using Mpeg Mux\n");
2616 dib7090_configMpegMux(state, 3, 1, 1); 2623 dib7090_configMpegMux(state, 3, 1, 1);
2617 dib7090_setHostBusMux(state, MPEG_ON_HOSTBUS); 2624 dib7090_setHostBusMux(state, MPEG_ON_HOSTBUS);
2618 } else {/* Use Smooth block */ 2625 } else {/* Use Smooth block */
2619 dprintk("setting output mode TS_SERIAL using Smooth bloc"); 2626 dprintk("setting output mode TS_SERIAL using Smooth bloc\n");
2620 dib7090_setHostBusMux(state, DEMOUT_ON_HOSTBUS); 2627 dib7090_setHostBusMux(state, DEMOUT_ON_HOSTBUS);
2621 outreg |= (2<<6) | (0 << 1); 2628 outreg |= (2<<6) | (0 << 1);
2622 } 2629 }
@@ -2624,24 +2631,24 @@ static int dib7090_set_output_mode(struct dvb_frontend *fe, int mode)
2624 2631
2625 case OUTMODE_MPEG2_PAR_GATED_CLK: 2632 case OUTMODE_MPEG2_PAR_GATED_CLK:
2626 if (prefer_mpeg_mux_use) { 2633 if (prefer_mpeg_mux_use) {
2627 dprintk("setting output mode TS_PARALLEL_GATED using Mpeg Mux"); 2634 dprintk("setting output mode TS_PARALLEL_GATED using Mpeg Mux\n");
2628 dib7090_configMpegMux(state, 2, 0, 0); 2635 dib7090_configMpegMux(state, 2, 0, 0);
2629 dib7090_setHostBusMux(state, MPEG_ON_HOSTBUS); 2636 dib7090_setHostBusMux(state, MPEG_ON_HOSTBUS);
2630 } else { /* Use Smooth block */ 2637 } else { /* Use Smooth block */
2631 dprintk("setting output mode TS_PARALLEL_GATED using Smooth block"); 2638 dprintk("setting output mode TS_PARALLEL_GATED using Smooth block\n");
2632 dib7090_setHostBusMux(state, DEMOUT_ON_HOSTBUS); 2639 dib7090_setHostBusMux(state, DEMOUT_ON_HOSTBUS);
2633 outreg |= (0<<6); 2640 outreg |= (0<<6);
2634 } 2641 }
2635 break; 2642 break;
2636 2643
2637 case OUTMODE_MPEG2_PAR_CONT_CLK: /* Using Smooth block only */ 2644 case OUTMODE_MPEG2_PAR_CONT_CLK: /* Using Smooth block only */
2638 dprintk("setting output mode TS_PARALLEL_CONT using Smooth block"); 2645 dprintk("setting output mode TS_PARALLEL_CONT using Smooth block\n");
2639 dib7090_setHostBusMux(state, DEMOUT_ON_HOSTBUS); 2646 dib7090_setHostBusMux(state, DEMOUT_ON_HOSTBUS);
2640 outreg |= (1<<6); 2647 outreg |= (1<<6);
2641 break; 2648 break;
2642 2649
2643 case OUTMODE_MPEG2_FIFO: /* Using Smooth block because not supported by new Mpeg Mux bloc */ 2650 case OUTMODE_MPEG2_FIFO: /* Using Smooth block because not supported by new Mpeg Mux bloc */
2644 dprintk("setting output mode TS_FIFO using Smooth block"); 2651 dprintk("setting output mode TS_FIFO using Smooth block\n");
2645 dib7090_setHostBusMux(state, DEMOUT_ON_HOSTBUS); 2652 dib7090_setHostBusMux(state, DEMOUT_ON_HOSTBUS);
2646 outreg |= (5<<6); 2653 outreg |= (5<<6);
2647 smo_mode |= (3 << 1); 2654 smo_mode |= (3 << 1);
@@ -2649,13 +2656,13 @@ static int dib7090_set_output_mode(struct dvb_frontend *fe, int mode)
2649 break; 2656 break;
2650 2657
2651 case OUTMODE_DIVERSITY: 2658 case OUTMODE_DIVERSITY:
2652 dprintk("setting output mode MODE_DIVERSITY"); 2659 dprintk("setting output mode MODE_DIVERSITY\n");
2653 dib7090_setDibTxMux(state, DIV_ON_DIBTX); 2660 dib7090_setDibTxMux(state, DIV_ON_DIBTX);
2654 dib7090_setHostBusMux(state, DIBTX_ON_HOSTBUS); 2661 dib7090_setHostBusMux(state, DIBTX_ON_HOSTBUS);
2655 break; 2662 break;
2656 2663
2657 case OUTMODE_ANALOG_ADC: 2664 case OUTMODE_ANALOG_ADC:
2658 dprintk("setting output mode MODE_ANALOG_ADC"); 2665 dprintk("setting output mode MODE_ANALOG_ADC\n");
2659 dib7090_setDibTxMux(state, ADC_ON_DIBTX); 2666 dib7090_setDibTxMux(state, ADC_ON_DIBTX);
2660 dib7090_setHostBusMux(state, DIBTX_ON_HOSTBUS); 2667 dib7090_setHostBusMux(state, DIBTX_ON_HOSTBUS);
2661 break; 2668 break;
@@ -2678,7 +2685,7 @@ static int dib7090_tuner_sleep(struct dvb_frontend *fe, int onoff)
2678 struct dib7000p_state *state = fe->demodulator_priv; 2685 struct dib7000p_state *state = fe->demodulator_priv;
2679 u16 en_cur_state; 2686 u16 en_cur_state;
2680 2687
2681 dprintk("sleep dib7090: %d", onoff); 2688 dprintk("sleep dib7090: %d\n", onoff);
2682 2689
2683 en_cur_state = dib7000p_read_word(state, 1922); 2690 en_cur_state = dib7000p_read_word(state, 1922);
2684 2691
@@ -2714,7 +2721,7 @@ static int dib7090_slave_reset(struct dvb_frontend *fe)
2714 return 0; 2721 return 0;
2715} 2722}
2716 2723
2717static struct dvb_frontend_ops dib7000p_ops; 2724static const struct dvb_frontend_ops dib7000p_ops;
2718static struct dvb_frontend *dib7000p_init(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib7000p_config *cfg) 2725static struct dvb_frontend *dib7000p_init(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib7000p_config *cfg)
2719{ 2726{
2720 struct dvb_frontend *demod; 2727 struct dvb_frontend *demod;
@@ -2804,7 +2811,7 @@ void *dib7000p_attach(struct dib7000p_ops *ops)
2804} 2811}
2805EXPORT_SYMBOL(dib7000p_attach); 2812EXPORT_SYMBOL(dib7000p_attach);
2806 2813
2807static struct dvb_frontend_ops dib7000p_ops = { 2814static const struct dvb_frontend_ops dib7000p_ops = {
2808 .delsys = { SYS_DVBT }, 2815 .delsys = { SYS_DVBT },
2809 .info = { 2816 .info = {
2810 .name = "DiBcom 7000PC", 2817 .name = "DiBcom 7000PC",
diff --git a/drivers/media/dvb-frontends/dib8000.c b/drivers/media/dvb-frontends/dib8000.c
index ddf9c44877a2..e501ec964df1 100644
--- a/drivers/media/dvb-frontends/dib8000.c
+++ b/drivers/media/dvb-frontends/dib8000.c
@@ -7,6 +7,9 @@
7 * modify it under the terms of the GNU General Public License as 7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2. 8 * published by the Free Software Foundation, version 2.
9 */ 9 */
10
11#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
12
10#include <linux/kernel.h> 13#include <linux/kernel.h>
11#include <linux/slab.h> 14#include <linux/slab.h>
12#include <linux/i2c.h> 15#include <linux/i2c.h>
@@ -31,7 +34,11 @@ static int debug;
31module_param(debug, int, 0644); 34module_param(debug, int, 0644);
32MODULE_PARM_DESC(debug, "turn on debugging (default: 0)"); 35MODULE_PARM_DESC(debug, "turn on debugging (default: 0)");
33 36
34#define dprintk(args...) do { if (debug) { printk(KERN_DEBUG "DiB8000: "); printk(args); printk("\n"); } } while (0) 37#define dprintk(fmt, arg...) do { \
38 if (debug) \
39 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
40 __func__, ##arg); \
41} while (0)
35 42
36struct i2c_device { 43struct i2c_device {
37 struct i2c_adapter *adap; 44 struct i2c_adapter *adap;
@@ -147,7 +154,7 @@ static u16 dib8000_i2c_read16(struct i2c_device *i2c, u16 reg)
147 }; 154 };
148 155
149 if (mutex_lock_interruptible(i2c->i2c_buffer_lock) < 0) { 156 if (mutex_lock_interruptible(i2c->i2c_buffer_lock) < 0) {
150 dprintk("could not acquire lock"); 157 dprintk("could not acquire lock\n");
151 return 0; 158 return 0;
152 } 159 }
153 160
@@ -157,7 +164,7 @@ static u16 dib8000_i2c_read16(struct i2c_device *i2c, u16 reg)
157 msg[1].buf = i2c->i2c_read_buffer; 164 msg[1].buf = i2c->i2c_read_buffer;
158 165
159 if (i2c_transfer(i2c->adap, msg, 2) != 2) 166 if (i2c_transfer(i2c->adap, msg, 2) != 2)
160 dprintk("i2c read error on %d", reg); 167 dprintk("i2c read error on %d\n", reg);
161 168
162 ret = (msg[1].buf[0] << 8) | msg[1].buf[1]; 169 ret = (msg[1].buf[0] << 8) | msg[1].buf[1];
163 mutex_unlock(i2c->i2c_buffer_lock); 170 mutex_unlock(i2c->i2c_buffer_lock);
@@ -182,7 +189,7 @@ static u16 __dib8000_read_word(struct dib8000_state *state, u16 reg)
182 state->msg[1].len = 2; 189 state->msg[1].len = 2;
183 190
184 if (i2c_transfer(state->i2c.adap, state->msg, 2) != 2) 191 if (i2c_transfer(state->i2c.adap, state->msg, 2) != 2)
185 dprintk("i2c read error on %d", reg); 192 dprintk("i2c read error on %d\n", reg);
186 193
187 ret = (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1]; 194 ret = (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
188 195
@@ -194,7 +201,7 @@ static u16 dib8000_read_word(struct dib8000_state *state, u16 reg)
194 u16 ret; 201 u16 ret;
195 202
196 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { 203 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
197 dprintk("could not acquire lock"); 204 dprintk("could not acquire lock\n");
198 return 0; 205 return 0;
199 } 206 }
200 207
@@ -210,7 +217,7 @@ static u32 dib8000_read32(struct dib8000_state *state, u16 reg)
210 u16 rw[2]; 217 u16 rw[2];
211 218
212 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { 219 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
213 dprintk("could not acquire lock"); 220 dprintk("could not acquire lock\n");
214 return 0; 221 return 0;
215 } 222 }
216 223
@@ -228,7 +235,7 @@ static int dib8000_i2c_write16(struct i2c_device *i2c, u16 reg, u16 val)
228 int ret = 0; 235 int ret = 0;
229 236
230 if (mutex_lock_interruptible(i2c->i2c_buffer_lock) < 0) { 237 if (mutex_lock_interruptible(i2c->i2c_buffer_lock) < 0) {
231 dprintk("could not acquire lock"); 238 dprintk("could not acquire lock\n");
232 return -EINVAL; 239 return -EINVAL;
233 } 240 }
234 241
@@ -249,7 +256,7 @@ static int dib8000_write_word(struct dib8000_state *state, u16 reg, u16 val)
249 int ret; 256 int ret;
250 257
251 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { 258 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
252 dprintk("could not acquire lock"); 259 dprintk("could not acquire lock\n");
253 return -EINVAL; 260 return -EINVAL;
254 } 261 }
255 262
@@ -395,7 +402,7 @@ static void dib8000_set_acquisition_mode(struct dib8000_state *state)
395{ 402{
396 u16 nud = dib8000_read_word(state, 298); 403 u16 nud = dib8000_read_word(state, 298);
397 nud |= (1 << 3) | (1 << 0); 404 nud |= (1 << 3) | (1 << 0);
398 dprintk("acquisition mode activated"); 405 dprintk("acquisition mode activated\n");
399 dib8000_write_word(state, 298, nud); 406 dib8000_write_word(state, 298, nud);
400} 407}
401static int dib8000_set_output_mode(struct dvb_frontend *fe, int mode) 408static int dib8000_set_output_mode(struct dvb_frontend *fe, int mode)
@@ -408,7 +415,7 @@ static int dib8000_set_output_mode(struct dvb_frontend *fe, int mode)
408 fifo_threshold = 1792; 415 fifo_threshold = 1792;
409 smo_mode = (dib8000_read_word(state, 299) & 0x0050) | (1 << 1); 416 smo_mode = (dib8000_read_word(state, 299) & 0x0050) | (1 << 1);
410 417
411 dprintk("-I- Setting output mode for demod %p to %d", 418 dprintk("-I- Setting output mode for demod %p to %d\n",
412 &state->fe[0], mode); 419 &state->fe[0], mode);
413 420
414 switch (mode) { 421 switch (mode) {
@@ -443,7 +450,7 @@ static int dib8000_set_output_mode(struct dvb_frontend *fe, int mode)
443 break; 450 break;
444 451
445 default: 452 default:
446 dprintk("Unhandled output_mode passed to be set for demod %p", 453 dprintk("Unhandled output_mode passed to be set for demod %p\n",
447 &state->fe[0]); 454 &state->fe[0]);
448 return -EINVAL; 455 return -EINVAL;
449 } 456 }
@@ -464,7 +471,7 @@ static int dib8000_set_diversity_in(struct dvb_frontend *fe, int onoff)
464 struct dib8000_state *state = fe->demodulator_priv; 471 struct dib8000_state *state = fe->demodulator_priv;
465 u16 tmp, sync_wait = dib8000_read_word(state, 273) & 0xfff0; 472 u16 tmp, sync_wait = dib8000_read_word(state, 273) & 0xfff0;
466 473
467 dprintk("set diversity input to %i", onoff); 474 dprintk("set diversity input to %i\n", onoff);
468 if (!state->differential_constellation) { 475 if (!state->differential_constellation) {
469 dib8000_write_word(state, 272, 1 << 9); //dvsy_off_lmod4 = 1 476 dib8000_write_word(state, 272, 1 << 9); //dvsy_off_lmod4 = 1
470 dib8000_write_word(state, 273, sync_wait | (1 << 2) | 2); // sync_enable = 1; comb_mode = 2 477 dib8000_write_word(state, 273, sync_wait | (1 << 2) | 2); // sync_enable = 1; comb_mode = 2
@@ -531,7 +538,7 @@ static void dib8000_set_power_mode(struct dib8000_state *state, enum dib8000_pow
531 break; 538 break;
532 } 539 }
533 540
534 dprintk("powermode : 774 : %x ; 775 : %x; 776 : %x ; 900 : %x; 1280 : %x", reg_774, reg_775, reg_776, reg_900, reg_1280); 541 dprintk("powermode : 774 : %x ; 775 : %x; 776 : %x ; 900 : %x; 1280 : %x\n", reg_774, reg_775, reg_776, reg_900, reg_1280);
535 dib8000_write_word(state, 774, reg_774); 542 dib8000_write_word(state, 774, reg_774);
536 dib8000_write_word(state, 775, reg_775); 543 dib8000_write_word(state, 775, reg_775);
537 dib8000_write_word(state, 776, reg_776); 544 dib8000_write_word(state, 776, reg_776);
@@ -619,10 +626,10 @@ static int dib8000_set_bandwidth(struct dvb_frontend *fe, u32 bw)
619 bw = 6000; 626 bw = 6000;
620 627
621 if (state->timf == 0) { 628 if (state->timf == 0) {
622 dprintk("using default timf"); 629 dprintk("using default timf\n");
623 timf = state->timf_default; 630 timf = state->timf_default;
624 } else { 631 } else {
625 dprintk("using updated timf"); 632 dprintk("using updated timf\n");
626 timf = state->timf; 633 timf = state->timf;
627 } 634 }
628 635
@@ -667,7 +674,7 @@ static int dib8000_set_wbd_ref(struct dvb_frontend *fe, u16 value)
667 674
668static void dib8000_reset_pll_common(struct dib8000_state *state, const struct dibx000_bandwidth_config *bw) 675static void dib8000_reset_pll_common(struct dib8000_state *state, const struct dibx000_bandwidth_config *bw)
669{ 676{
670 dprintk("ifreq: %d %x, inversion: %d", bw->ifreq, bw->ifreq, bw->ifreq >> 25); 677 dprintk("ifreq: %d %x, inversion: %d\n", bw->ifreq, bw->ifreq, bw->ifreq >> 25);
671 if (state->revision != 0x8090) { 678 if (state->revision != 0x8090) {
672 dib8000_write_word(state, 23, 679 dib8000_write_word(state, 23,
673 (u16) (((bw->internal * 1000) >> 16) & 0xffff)); 680 (u16) (((bw->internal * 1000) >> 16) & 0xffff));
@@ -704,7 +711,7 @@ static void dib8000_reset_pll(struct dib8000_state *state)
704 clk_cfg1 = (clk_cfg1 & 0xfff7) | (pll->pll_bypass << 3); 711 clk_cfg1 = (clk_cfg1 & 0xfff7) | (pll->pll_bypass << 3);
705 dib8000_write_word(state, 902, clk_cfg1); 712 dib8000_write_word(state, 902, clk_cfg1);
706 713
707 dprintk("clk_cfg1: 0x%04x", clk_cfg1); 714 dprintk("clk_cfg1: 0x%04x\n", clk_cfg1);
708 715
709 /* smpl_cfg: P_refclksel=2, P_ensmplsel=1 nodivsmpl=1 */ 716 /* smpl_cfg: P_refclksel=2, P_ensmplsel=1 nodivsmpl=1 */
710 if (state->cfg.pll->ADClkSrc == 0) 717 if (state->cfg.pll->ADClkSrc == 0)
@@ -754,7 +761,7 @@ static int dib8000_update_pll(struct dvb_frontend *fe,
754 pll->pll_ratio == loopdiv)) 761 pll->pll_ratio == loopdiv))
755 return -EINVAL; 762 return -EINVAL;
756 763
757 dprintk("Updating pll (prediv: old = %d new = %d ; loopdiv : old = %d new = %d)", prediv, pll->pll_prediv, loopdiv, pll->pll_ratio); 764 dprintk("Updating pll (prediv: old = %d new = %d ; loopdiv : old = %d new = %d)\n", prediv, pll->pll_prediv, loopdiv, pll->pll_ratio);
758 if (state->revision == 0x8090) { 765 if (state->revision == 0x8090) {
759 reg_1856 &= 0xf000; 766 reg_1856 &= 0xf000;
760 reg_1857 = dib8000_read_word(state, 1857); 767 reg_1857 = dib8000_read_word(state, 1857);
@@ -767,11 +774,11 @@ static int dib8000_update_pll(struct dvb_frontend *fe,
767 774
768 /* write new system clk into P_sec_len */ 775 /* write new system clk into P_sec_len */
769 internal = dib8000_read32(state, 23) / 1000; 776 internal = dib8000_read32(state, 23) / 1000;
770 dprintk("Old Internal = %d", internal); 777 dprintk("Old Internal = %d\n", internal);
771 xtal = 2 * (internal / loopdiv) * prediv; 778 xtal = 2 * (internal / loopdiv) * prediv;
772 internal = 1000 * (xtal/pll->pll_prediv) * pll->pll_ratio; 779 internal = 1000 * (xtal/pll->pll_prediv) * pll->pll_ratio;
773 dprintk("Xtal = %d , New Fmem = %d New Fdemod = %d, New Fsampling = %d", xtal, internal/1000, internal/2000, internal/8000); 780 dprintk("Xtal = %d , New Fmem = %d New Fdemod = %d, New Fsampling = %d\n", xtal, internal/1000, internal/2000, internal/8000);
774 dprintk("New Internal = %d", internal); 781 dprintk("New Internal = %d\n", internal);
775 782
776 dib8000_write_word(state, 23, 783 dib8000_write_word(state, 23,
777 (u16) (((internal / 2) >> 16) & 0xffff)); 784 (u16) (((internal / 2) >> 16) & 0xffff));
@@ -780,22 +787,22 @@ static int dib8000_update_pll(struct dvb_frontend *fe,
780 dib8000_write_word(state, 1857, reg_1857 | (1 << 15)); 787 dib8000_write_word(state, 1857, reg_1857 | (1 << 15));
781 788
782 while (((dib8000_read_word(state, 1856)>>15)&0x1) != 1) 789 while (((dib8000_read_word(state, 1856)>>15)&0x1) != 1)
783 dprintk("Waiting for PLL to lock"); 790 dprintk("Waiting for PLL to lock\n");
784 791
785 /* verify */ 792 /* verify */
786 reg_1856 = dib8000_read_word(state, 1856); 793 reg_1856 = dib8000_read_word(state, 1856);
787 dprintk("PLL Updated with prediv = %d and loopdiv = %d", 794 dprintk("PLL Updated with prediv = %d and loopdiv = %d\n",
788 reg_1856&0x3f, (reg_1856>>6)&0x3f); 795 reg_1856&0x3f, (reg_1856>>6)&0x3f);
789 } else { 796 } else {
790 if (bw != state->current_demod_bw) { 797 if (bw != state->current_demod_bw) {
791 /** Bandwidth change => force PLL update **/ 798 /** Bandwidth change => force PLL update **/
792 dprintk("PLL: Bandwidth Change %d MHz -> %d MHz (prediv: %d->%d)", state->current_demod_bw / 1000, bw / 1000, oldprediv, state->cfg.pll->pll_prediv); 799 dprintk("PLL: Bandwidth Change %d MHz -> %d MHz (prediv: %d->%d)\n", state->current_demod_bw / 1000, bw / 1000, oldprediv, state->cfg.pll->pll_prediv);
793 800
794 if (state->cfg.pll->pll_prediv != oldprediv) { 801 if (state->cfg.pll->pll_prediv != oldprediv) {
795 /** Full PLL change only if prediv is changed **/ 802 /** Full PLL change only if prediv is changed **/
796 803
797 /** full update => bypass and reconfigure **/ 804 /** full update => bypass and reconfigure **/
798 dprintk("PLL: New Setting for %d MHz Bandwidth (prediv: %d, ratio: %d)", bw/1000, state->cfg.pll->pll_prediv, state->cfg.pll->pll_ratio); 805 dprintk("PLL: New Setting for %d MHz Bandwidth (prediv: %d, ratio: %d)\n", bw/1000, state->cfg.pll->pll_prediv, state->cfg.pll->pll_ratio);
799 dib8000_write_word(state, 902, dib8000_read_word(state, 902) | (1<<3)); /* bypass PLL */ 806 dib8000_write_word(state, 902, dib8000_read_word(state, 902) | (1<<3)); /* bypass PLL */
800 dib8000_reset_pll(state); 807 dib8000_reset_pll(state);
801 dib8000_write_word(state, 898, 0x0004); /* sad */ 808 dib8000_write_word(state, 898, 0x0004); /* sad */
@@ -807,7 +814,7 @@ static int dib8000_update_pll(struct dvb_frontend *fe,
807 814
808 if (ratio != 0) { 815 if (ratio != 0) {
809 /** ratio update => only change ratio **/ 816 /** ratio update => only change ratio **/
810 dprintk("PLL: Update ratio (prediv: %d, ratio: %d)", state->cfg.pll->pll_prediv, ratio); 817 dprintk("PLL: Update ratio (prediv: %d, ratio: %d)\n", state->cfg.pll->pll_prediv, ratio);
811 dib8000_write_word(state, 901, (state->cfg.pll->pll_prediv << 8) | (ratio << 0)); /* only the PLL ratio is updated. */ 818 dib8000_write_word(state, 901, (state->cfg.pll->pll_prediv << 8) | (ratio << 0)); /* only the PLL ratio is updated. */
812 } 819 }
813 } 820 }
@@ -841,7 +848,7 @@ static int dib8000_cfg_gpio(struct dib8000_state *st, u8 num, u8 dir, u8 val)
841 st->cfg.gpio_val |= (val & 0x01) << num; /* set the new value */ 848 st->cfg.gpio_val |= (val & 0x01) << num; /* set the new value */
842 dib8000_write_word(st, 1030, st->cfg.gpio_val); 849 dib8000_write_word(st, 1030, st->cfg.gpio_val);
843 850
844 dprintk("gpio dir: %x: gpio val: %x", st->cfg.gpio_dir, st->cfg.gpio_val); 851 dprintk("gpio dir: %x: gpio val: %x\n", st->cfg.gpio_dir, st->cfg.gpio_val);
845 852
846 return 0; 853 return 0;
847} 854}
@@ -958,29 +965,29 @@ static u16 dib8000_identify(struct i2c_device *client)
958 value = dib8000_i2c_read16(client, 896); 965 value = dib8000_i2c_read16(client, 896);
959 966
960 if ((value = dib8000_i2c_read16(client, 896)) != 0x01b3) { 967 if ((value = dib8000_i2c_read16(client, 896)) != 0x01b3) {
961 dprintk("wrong Vendor ID (read=0x%x)", value); 968 dprintk("wrong Vendor ID (read=0x%x)\n", value);
962 return 0; 969 return 0;
963 } 970 }
964 971
965 value = dib8000_i2c_read16(client, 897); 972 value = dib8000_i2c_read16(client, 897);
966 if (value != 0x8000 && value != 0x8001 && 973 if (value != 0x8000 && value != 0x8001 &&
967 value != 0x8002 && value != 0x8090) { 974 value != 0x8002 && value != 0x8090) {
968 dprintk("wrong Device ID (%x)", value); 975 dprintk("wrong Device ID (%x)\n", value);
969 return 0; 976 return 0;
970 } 977 }
971 978
972 switch (value) { 979 switch (value) {
973 case 0x8000: 980 case 0x8000:
974 dprintk("found DiB8000A"); 981 dprintk("found DiB8000A\n");
975 break; 982 break;
976 case 0x8001: 983 case 0x8001:
977 dprintk("found DiB8000B"); 984 dprintk("found DiB8000B\n");
978 break; 985 break;
979 case 0x8002: 986 case 0x8002:
980 dprintk("found DiB8000C"); 987 dprintk("found DiB8000C\n");
981 break; 988 break;
982 case 0x8090: 989 case 0x8090:
983 dprintk("found DiB8096P"); 990 dprintk("found DiB8096P\n");
984 break; 991 break;
985 } 992 }
986 return value; 993 return value;
@@ -1037,7 +1044,7 @@ static int dib8000_reset(struct dvb_frontend *fe)
1037 dib8000_write_word(state, 1287, 0x0003); 1044 dib8000_write_word(state, 1287, 0x0003);
1038 1045
1039 if (state->revision == 0x8000) 1046 if (state->revision == 0x8000)
1040 dprintk("error : dib8000 MA not supported"); 1047 dprintk("error : dib8000 MA not supported\n");
1041 1048
1042 dibx000_reset_i2c_master(&state->i2c_master); 1049 dibx000_reset_i2c_master(&state->i2c_master);
1043 1050
@@ -1069,7 +1076,7 @@ static int dib8000_reset(struct dvb_frontend *fe)
1069 if (state->cfg.drives) 1076 if (state->cfg.drives)
1070 dib8000_write_word(state, 906, state->cfg.drives); 1077 dib8000_write_word(state, 906, state->cfg.drives);
1071 else { 1078 else {
1072 dprintk("using standard PAD-drive-settings, please adjust settings in config-struct to be optimal."); 1079 dprintk("using standard PAD-drive-settings, please adjust settings in config-struct to be optimal.\n");
1073 /* min drive SDRAM - not optimal - adjust */ 1080 /* min drive SDRAM - not optimal - adjust */
1074 dib8000_write_word(state, 906, 0x2d98); 1081 dib8000_write_word(state, 906, 0x2d98);
1075 } 1082 }
@@ -1080,11 +1087,11 @@ static int dib8000_reset(struct dvb_frontend *fe)
1080 dib8000_write_word(state, 898, 0x0004); 1087 dib8000_write_word(state, 898, 0x0004);
1081 1088
1082 if (dib8000_reset_gpio(state) != 0) 1089 if (dib8000_reset_gpio(state) != 0)
1083 dprintk("GPIO reset was not successful."); 1090 dprintk("GPIO reset was not successful.\n");
1084 1091
1085 if ((state->revision != 0x8090) && 1092 if ((state->revision != 0x8090) &&
1086 (dib8000_set_output_mode(fe, OUTMODE_HIGH_Z) != 0)) 1093 (dib8000_set_output_mode(fe, OUTMODE_HIGH_Z) != 0))
1087 dprintk("OUTPUT_MODE could not be resetted."); 1094 dprintk("OUTPUT_MODE could not be resetted.\n");
1088 1095
1089 state->current_agc = NULL; 1096 state->current_agc = NULL;
1090 1097
@@ -1176,7 +1183,7 @@ static int dib8000_set_agc_config(struct dib8000_state *state, u8 band)
1176 } 1183 }
1177 1184
1178 if (agc == NULL) { 1185 if (agc == NULL) {
1179 dprintk("no valid AGC configuration found for band 0x%02x", band); 1186 dprintk("no valid AGC configuration found for band 0x%02x\n", band);
1180 return -EINVAL; 1187 return -EINVAL;
1181 } 1188 }
1182 1189
@@ -1192,7 +1199,7 @@ static int dib8000_set_agc_config(struct dib8000_state *state, u8 band)
1192 dib8000_write_word(state, 102, (agc->alpha_mant << 5) | agc->alpha_exp); 1199 dib8000_write_word(state, 102, (agc->alpha_mant << 5) | agc->alpha_exp);
1193 dib8000_write_word(state, 103, (agc->beta_mant << 6) | agc->beta_exp); 1200 dib8000_write_word(state, 103, (agc->beta_mant << 6) | agc->beta_exp);
1194 1201
1195 dprintk("WBD: ref: %d, sel: %d, active: %d, alpha: %d", 1202 dprintk("WBD: ref: %d, sel: %d, active: %d, alpha: %d\n",
1196 state->wbd_ref != 0 ? state->wbd_ref : agc->wbd_ref, agc->wbd_sel, !agc->perform_agc_softsplit, agc->wbd_sel); 1203 state->wbd_ref != 0 ? state->wbd_ref : agc->wbd_ref, agc->wbd_sel, !agc->perform_agc_softsplit, agc->wbd_sel);
1197 1204
1198 /* AGC continued */ 1205 /* AGC continued */
@@ -1251,7 +1258,7 @@ static int dib8000_agc_soft_split(struct dib8000_state *state)
1251 (agc - state->current_agc->split.min_thres) / 1258 (agc - state->current_agc->split.min_thres) /
1252 (state->current_agc->split.max_thres - state->current_agc->split.min_thres); 1259 (state->current_agc->split.max_thres - state->current_agc->split.min_thres);
1253 1260
1254 dprintk("AGC split_offset: %d", split_offset); 1261 dprintk("AGC split_offset: %d\n", split_offset);
1255 1262
1256 // P_agc_force_split and P_agc_split_offset 1263 // P_agc_force_split and P_agc_split_offset
1257 dib8000_write_word(state, 107, (dib8000_read_word(state, 107) & 0xff00) | split_offset); 1264 dib8000_write_word(state, 107, (dib8000_read_word(state, 107) & 0xff00) | split_offset);
@@ -1395,7 +1402,7 @@ static void dib8096p_cfg_DibTx(struct dib8000_state *state, u32 P_Kin,
1395 u32 P_Kout, u32 insertExtSynchro, u32 synchroMode, 1402 u32 P_Kout, u32 insertExtSynchro, u32 synchroMode,
1396 u32 syncWord, u32 syncSize) 1403 u32 syncWord, u32 syncSize)
1397{ 1404{
1398 dprintk("Configure DibStream Tx"); 1405 dprintk("Configure DibStream Tx\n");
1399 1406
1400 dib8000_write_word(state, 1615, 1); 1407 dib8000_write_word(state, 1615, 1);
1401 dib8000_write_word(state, 1603, P_Kin); 1408 dib8000_write_word(state, 1603, P_Kin);
@@ -1414,7 +1421,7 @@ static void dib8096p_cfg_DibRx(struct dib8000_state *state, u32 P_Kin,
1414{ 1421{
1415 u32 syncFreq; 1422 u32 syncFreq;
1416 1423
1417 dprintk("Configure DibStream Rx synchroMode = %d", synchroMode); 1424 dprintk("Configure DibStream Rx synchroMode = %d\n", synchroMode);
1418 1425
1419 if ((P_Kin != 0) && (P_Kout != 0)) { 1426 if ((P_Kin != 0) && (P_Kout != 0)) {
1420 syncFreq = dib8096p_calcSyncFreq(P_Kin, P_Kout, 1427 syncFreq = dib8096p_calcSyncFreq(P_Kin, P_Kout,
@@ -1456,7 +1463,7 @@ static void dib8096p_configMpegMux(struct dib8000_state *state,
1456{ 1463{
1457 u16 reg_1287; 1464 u16 reg_1287;
1458 1465
1459 dprintk("Enable Mpeg mux"); 1466 dprintk("Enable Mpeg mux\n");
1460 1467
1461 dib8096p_enMpegMux(state, 0); 1468 dib8096p_enMpegMux(state, 0);
1462 1469
@@ -1477,15 +1484,15 @@ static void dib8096p_setDibTxMux(struct dib8000_state *state, int mode)
1477 1484
1478 switch (mode) { 1485 switch (mode) {
1479 case MPEG_ON_DIBTX: 1486 case MPEG_ON_DIBTX:
1480 dprintk("SET MPEG ON DIBSTREAM TX"); 1487 dprintk("SET MPEG ON DIBSTREAM TX\n");
1481 dib8096p_cfg_DibTx(state, 8, 5, 0, 0, 0, 0); 1488 dib8096p_cfg_DibTx(state, 8, 5, 0, 0, 0, 0);
1482 reg_1288 |= (1 << 9); break; 1489 reg_1288 |= (1 << 9); break;
1483 case DIV_ON_DIBTX: 1490 case DIV_ON_DIBTX:
1484 dprintk("SET DIV_OUT ON DIBSTREAM TX"); 1491 dprintk("SET DIV_OUT ON DIBSTREAM TX\n");
1485 dib8096p_cfg_DibTx(state, 5, 5, 0, 0, 0, 0); 1492 dib8096p_cfg_DibTx(state, 5, 5, 0, 0, 0, 0);
1486 reg_1288 |= (1 << 8); break; 1493 reg_1288 |= (1 << 8); break;
1487 case ADC_ON_DIBTX: 1494 case ADC_ON_DIBTX:
1488 dprintk("SET ADC_OUT ON DIBSTREAM TX"); 1495 dprintk("SET ADC_OUT ON DIBSTREAM TX\n");
1489 dib8096p_cfg_DibTx(state, 20, 5, 10, 0, 0, 0); 1496 dib8096p_cfg_DibTx(state, 20, 5, 10, 0, 0, 0);
1490 reg_1288 |= (1 << 7); break; 1497 reg_1288 |= (1 << 7); break;
1491 default: 1498 default:
@@ -1500,17 +1507,17 @@ static void dib8096p_setHostBusMux(struct dib8000_state *state, int mode)
1500 1507
1501 switch (mode) { 1508 switch (mode) {
1502 case DEMOUT_ON_HOSTBUS: 1509 case DEMOUT_ON_HOSTBUS:
1503 dprintk("SET DEM OUT OLD INTERF ON HOST BUS"); 1510 dprintk("SET DEM OUT OLD INTERF ON HOST BUS\n");
1504 dib8096p_enMpegMux(state, 0); 1511 dib8096p_enMpegMux(state, 0);
1505 reg_1288 |= (1 << 6); 1512 reg_1288 |= (1 << 6);
1506 break; 1513 break;
1507 case DIBTX_ON_HOSTBUS: 1514 case DIBTX_ON_HOSTBUS:
1508 dprintk("SET DIBSTREAM TX ON HOST BUS"); 1515 dprintk("SET DIBSTREAM TX ON HOST BUS\n");
1509 dib8096p_enMpegMux(state, 0); 1516 dib8096p_enMpegMux(state, 0);
1510 reg_1288 |= (1 << 5); 1517 reg_1288 |= (1 << 5);
1511 break; 1518 break;
1512 case MPEG_ON_HOSTBUS: 1519 case MPEG_ON_HOSTBUS:
1513 dprintk("SET MPEG MUX ON HOST BUS"); 1520 dprintk("SET MPEG MUX ON HOST BUS\n");
1514 reg_1288 |= (1 << 4); 1521 reg_1288 |= (1 << 4);
1515 break; 1522 break;
1516 default: 1523 default:
@@ -1526,7 +1533,7 @@ static int dib8096p_set_diversity_in(struct dvb_frontend *fe, int onoff)
1526 1533
1527 switch (onoff) { 1534 switch (onoff) {
1528 case 0: /* only use the internal way - not the diversity input */ 1535 case 0: /* only use the internal way - not the diversity input */
1529 dprintk("%s mode OFF : by default Enable Mpeg INPUT", 1536 dprintk("%s mode OFF : by default Enable Mpeg INPUT\n",
1530 __func__); 1537 __func__);
1531 /* outputRate = 8 */ 1538 /* outputRate = 8 */
1532 dib8096p_cfg_DibRx(state, 8, 5, 0, 0, 0, 8, 0); 1539 dib8096p_cfg_DibRx(state, 8, 5, 0, 0, 0, 8, 0);
@@ -1544,7 +1551,7 @@ static int dib8096p_set_diversity_in(struct dvb_frontend *fe, int onoff)
1544 break; 1551 break;
1545 case 1: /* both ways */ 1552 case 1: /* both ways */
1546 case 2: /* only the diversity input */ 1553 case 2: /* only the diversity input */
1547 dprintk("%s ON : Enable diversity INPUT", __func__); 1554 dprintk("%s ON : Enable diversity INPUT\n", __func__);
1548 dib8096p_cfg_DibRx(state, 5, 5, 0, 0, 0, 0, 0); 1555 dib8096p_cfg_DibRx(state, 5, 5, 0, 0, 0, 0, 0);
1549 state->input_mode_mpeg = 0; 1556 state->input_mode_mpeg = 0;
1550 break; 1557 break;
@@ -1576,11 +1583,11 @@ static int dib8096p_set_output_mode(struct dvb_frontend *fe, int mode)
1576 1583
1577 case OUTMODE_MPEG2_SERIAL: 1584 case OUTMODE_MPEG2_SERIAL:
1578 if (prefer_mpeg_mux_use) { 1585 if (prefer_mpeg_mux_use) {
1579 dprintk("dib8096P setting output mode TS_SERIAL using Mpeg Mux"); 1586 dprintk("dib8096P setting output mode TS_SERIAL using Mpeg Mux\n");
1580 dib8096p_configMpegMux(state, 3, 1, 1); 1587 dib8096p_configMpegMux(state, 3, 1, 1);
1581 dib8096p_setHostBusMux(state, MPEG_ON_HOSTBUS); 1588 dib8096p_setHostBusMux(state, MPEG_ON_HOSTBUS);
1582 } else {/* Use Smooth block */ 1589 } else {/* Use Smooth block */
1583 dprintk("dib8096P setting output mode TS_SERIAL using Smooth bloc"); 1590 dprintk("dib8096P setting output mode TS_SERIAL using Smooth bloc\n");
1584 dib8096p_setHostBusMux(state, 1591 dib8096p_setHostBusMux(state,
1585 DEMOUT_ON_HOSTBUS); 1592 DEMOUT_ON_HOSTBUS);
1586 outreg |= (2 << 6) | (0 << 1); 1593 outreg |= (2 << 6) | (0 << 1);
@@ -1589,11 +1596,11 @@ static int dib8096p_set_output_mode(struct dvb_frontend *fe, int mode)
1589 1596
1590 case OUTMODE_MPEG2_PAR_GATED_CLK: 1597 case OUTMODE_MPEG2_PAR_GATED_CLK:
1591 if (prefer_mpeg_mux_use) { 1598 if (prefer_mpeg_mux_use) {
1592 dprintk("dib8096P setting output mode TS_PARALLEL_GATED using Mpeg Mux"); 1599 dprintk("dib8096P setting output mode TS_PARALLEL_GATED using Mpeg Mux\n");
1593 dib8096p_configMpegMux(state, 2, 0, 0); 1600 dib8096p_configMpegMux(state, 2, 0, 0);
1594 dib8096p_setHostBusMux(state, MPEG_ON_HOSTBUS); 1601 dib8096p_setHostBusMux(state, MPEG_ON_HOSTBUS);
1595 } else { /* Use Smooth block */ 1602 } else { /* Use Smooth block */
1596 dprintk("dib8096P setting output mode TS_PARALLEL_GATED using Smooth block"); 1603 dprintk("dib8096P setting output mode TS_PARALLEL_GATED using Smooth block\n");
1597 dib8096p_setHostBusMux(state, 1604 dib8096p_setHostBusMux(state,
1598 DEMOUT_ON_HOSTBUS); 1605 DEMOUT_ON_HOSTBUS);
1599 outreg |= (0 << 6); 1606 outreg |= (0 << 6);
@@ -1601,7 +1608,7 @@ static int dib8096p_set_output_mode(struct dvb_frontend *fe, int mode)
1601 break; 1608 break;
1602 1609
1603 case OUTMODE_MPEG2_PAR_CONT_CLK: /* Using Smooth block only */ 1610 case OUTMODE_MPEG2_PAR_CONT_CLK: /* Using Smooth block only */
1604 dprintk("dib8096P setting output mode TS_PARALLEL_CONT using Smooth block"); 1611 dprintk("dib8096P setting output mode TS_PARALLEL_CONT using Smooth block\n");
1605 dib8096p_setHostBusMux(state, DEMOUT_ON_HOSTBUS); 1612 dib8096p_setHostBusMux(state, DEMOUT_ON_HOSTBUS);
1606 outreg |= (1 << 6); 1613 outreg |= (1 << 6);
1607 break; 1614 break;
@@ -1609,7 +1616,7 @@ static int dib8096p_set_output_mode(struct dvb_frontend *fe, int mode)
1609 case OUTMODE_MPEG2_FIFO: 1616 case OUTMODE_MPEG2_FIFO:
1610 /* Using Smooth block because not supported 1617 /* Using Smooth block because not supported
1611 by new Mpeg Mux bloc */ 1618 by new Mpeg Mux bloc */
1612 dprintk("dib8096P setting output mode TS_FIFO using Smooth block"); 1619 dprintk("dib8096P setting output mode TS_FIFO using Smooth block\n");
1613 dib8096p_setHostBusMux(state, DEMOUT_ON_HOSTBUS); 1620 dib8096p_setHostBusMux(state, DEMOUT_ON_HOSTBUS);
1614 outreg |= (5 << 6); 1621 outreg |= (5 << 6);
1615 smo_mode |= (3 << 1); 1622 smo_mode |= (3 << 1);
@@ -1617,13 +1624,13 @@ static int dib8096p_set_output_mode(struct dvb_frontend *fe, int mode)
1617 break; 1624 break;
1618 1625
1619 case OUTMODE_DIVERSITY: 1626 case OUTMODE_DIVERSITY:
1620 dprintk("dib8096P setting output mode MODE_DIVERSITY"); 1627 dprintk("dib8096P setting output mode MODE_DIVERSITY\n");
1621 dib8096p_setDibTxMux(state, DIV_ON_DIBTX); 1628 dib8096p_setDibTxMux(state, DIV_ON_DIBTX);
1622 dib8096p_setHostBusMux(state, DIBTX_ON_HOSTBUS); 1629 dib8096p_setHostBusMux(state, DIBTX_ON_HOSTBUS);
1623 break; 1630 break;
1624 1631
1625 case OUTMODE_ANALOG_ADC: 1632 case OUTMODE_ANALOG_ADC:
1626 dprintk("dib8096P setting output mode MODE_ANALOG_ADC"); 1633 dprintk("dib8096P setting output mode MODE_ANALOG_ADC\n");
1627 dib8096p_setDibTxMux(state, ADC_ON_DIBTX); 1634 dib8096p_setDibTxMux(state, ADC_ON_DIBTX);
1628 dib8096p_setHostBusMux(state, DIBTX_ON_HOSTBUS); 1635 dib8096p_setHostBusMux(state, DIBTX_ON_HOSTBUS);
1629 break; 1636 break;
@@ -1632,7 +1639,7 @@ static int dib8096p_set_output_mode(struct dvb_frontend *fe, int mode)
1632 if (mode != OUTMODE_HIGH_Z) 1639 if (mode != OUTMODE_HIGH_Z)
1633 outreg |= (1<<10); 1640 outreg |= (1<<10);
1634 1641
1635 dprintk("output_mpeg2_in_188_bytes = %d", 1642 dprintk("output_mpeg2_in_188_bytes = %d\n",
1636 state->cfg.output_mpeg2_in_188_bytes); 1643 state->cfg.output_mpeg2_in_188_bytes);
1637 if (state->cfg.output_mpeg2_in_188_bytes) 1644 if (state->cfg.output_mpeg2_in_188_bytes)
1638 smo_mode |= (1 << 5); 1645 smo_mode |= (1 << 5);
@@ -1678,7 +1685,7 @@ static int dib8096p_tuner_write_serpar(struct i2c_adapter *i2c_adap,
1678 n_overflow = (dib8000_read_word(state, 1984) >> 1) & 0x1; 1685 n_overflow = (dib8000_read_word(state, 1984) >> 1) & 0x1;
1679 i--; 1686 i--;
1680 if (i == 0) 1687 if (i == 0)
1681 dprintk("Tuner ITF: write busy (overflow)"); 1688 dprintk("Tuner ITF: write busy (overflow)\n");
1682 } 1689 }
1683 dib8000_write_word(state, 1985, (1 << 6) | (serpar_num & 0x3f)); 1690 dib8000_write_word(state, 1985, (1 << 6) | (serpar_num & 0x3f));
1684 dib8000_write_word(state, 1986, (msg[0].buf[1] << 8) | msg[0].buf[2]); 1691 dib8000_write_word(state, 1986, (msg[0].buf[1] << 8) | msg[0].buf[2]);
@@ -1699,7 +1706,7 @@ static int dib8096p_tuner_read_serpar(struct i2c_adapter *i2c_adap,
1699 n_overflow = (dib8000_read_word(state, 1984) >> 1) & 0x1; 1706 n_overflow = (dib8000_read_word(state, 1984) >> 1) & 0x1;
1700 i--; 1707 i--;
1701 if (i == 0) 1708 if (i == 0)
1702 dprintk("TunerITF: read busy (overflow)"); 1709 dprintk("TunerITF: read busy (overflow)\n");
1703 } 1710 }
1704 dib8000_write_word(state, 1985, (0<<6) | (serpar_num&0x3f)); 1711 dib8000_write_word(state, 1985, (0<<6) | (serpar_num&0x3f));
1705 1712
@@ -1708,7 +1715,7 @@ static int dib8096p_tuner_read_serpar(struct i2c_adapter *i2c_adap,
1708 n_empty = dib8000_read_word(state, 1984)&0x1; 1715 n_empty = dib8000_read_word(state, 1984)&0x1;
1709 i--; 1716 i--;
1710 if (i == 0) 1717 if (i == 0)
1711 dprintk("TunerITF: read busy (empty)"); 1718 dprintk("TunerITF: read busy (empty)\n");
1712 } 1719 }
1713 1720
1714 read_word = dib8000_read_word(state, 1987); 1721 read_word = dib8000_read_word(state, 1987);
@@ -1889,7 +1896,7 @@ static int dib8096p_tuner_sleep(struct dvb_frontend *fe, int onoff)
1889 struct dib8000_state *state = fe->demodulator_priv; 1896 struct dib8000_state *state = fe->demodulator_priv;
1890 u16 en_cur_state; 1897 u16 en_cur_state;
1891 1898
1892 dprintk("sleep dib8096p: %d", onoff); 1899 dprintk("sleep dib8096p: %d\n", onoff);
1893 1900
1894 en_cur_state = dib8000_read_word(state, 1922); 1901 en_cur_state = dib8000_read_word(state, 1922);
1895 1902
@@ -1958,7 +1965,7 @@ static void dib8000_update_timf(struct dib8000_state *state)
1958 1965
1959 dib8000_write_word(state, 29, (u16) (timf >> 16)); 1966 dib8000_write_word(state, 29, (u16) (timf >> 16));
1960 dib8000_write_word(state, 30, (u16) (timf & 0xffff)); 1967 dib8000_write_word(state, 30, (u16) (timf & 0xffff));
1961 dprintk("Updated timing frequency: %d (default: %d)", state->timf, state->timf_default); 1968 dprintk("Updated timing frequency: %d (default: %d)\n", state->timf, state->timf_default);
1962} 1969}
1963 1970
1964static u32 dib8000_ctrl_timf(struct dvb_frontend *fe, uint8_t op, uint32_t timf) 1971static u32 dib8000_ctrl_timf(struct dvb_frontend *fe, uint8_t op, uint32_t timf)
@@ -2118,7 +2125,7 @@ static u16 dib8000_get_init_prbs(struct dib8000_state *state, u16 subchannel)
2118 int sub_channel_prbs_group = 0; 2125 int sub_channel_prbs_group = 0;
2119 2126
2120 sub_channel_prbs_group = (subchannel / 3) + 1; 2127 sub_channel_prbs_group = (subchannel / 3) + 1;
2121 dprintk("sub_channel_prbs_group = %d , subchannel =%d prbs = 0x%04x", sub_channel_prbs_group, subchannel, lut_prbs_8k[sub_channel_prbs_group]); 2128 dprintk("sub_channel_prbs_group = %d , subchannel =%d prbs = 0x%04x\n", sub_channel_prbs_group, subchannel, lut_prbs_8k[sub_channel_prbs_group]);
2122 2129
2123 switch (state->fe[0]->dtv_property_cache.transmission_mode) { 2130 switch (state->fe[0]->dtv_property_cache.transmission_mode) {
2124 case TRANSMISSION_MODE_2K: 2131 case TRANSMISSION_MODE_2K:
@@ -2604,7 +2611,7 @@ static int dib8000_autosearch_start(struct dvb_frontend *fe)
2604 slist = 0; 2611 slist = 0;
2605 } 2612 }
2606 } 2613 }
2607 dprintk("Using list for autosearch : %d", slist); 2614 dprintk("Using list for autosearch : %d\n", slist);
2608 2615
2609 dib8000_set_isdbt_common_channel(state, slist, 1); 2616 dib8000_set_isdbt_common_channel(state, slist, 1);
2610 2617
@@ -2638,17 +2645,17 @@ static int dib8000_autosearch_irq(struct dvb_frontend *fe)
2638 if ((state->revision >= 0x8002) && 2645 if ((state->revision >= 0x8002) &&
2639 (state->autosearch_state == AS_SEARCHING_FFT)) { 2646 (state->autosearch_state == AS_SEARCHING_FFT)) {
2640 if (irq_pending & 0x1) { 2647 if (irq_pending & 0x1) {
2641 dprintk("dib8000_autosearch_irq: max correlation result available"); 2648 dprintk("dib8000_autosearch_irq: max correlation result available\n");
2642 return 3; 2649 return 3;
2643 } 2650 }
2644 } else { 2651 } else {
2645 if (irq_pending & 0x1) { /* failed */ 2652 if (irq_pending & 0x1) { /* failed */
2646 dprintk("dib8000_autosearch_irq failed"); 2653 dprintk("dib8000_autosearch_irq failed\n");
2647 return 1; 2654 return 1;
2648 } 2655 }
2649 2656
2650 if (irq_pending & 0x2) { /* succeeded */ 2657 if (irq_pending & 0x2) { /* succeeded */
2651 dprintk("dib8000_autosearch_irq succeeded"); 2658 dprintk("dib8000_autosearch_irq succeeded\n");
2652 return 2; 2659 return 2;
2653 } 2660 }
2654 } 2661 }
@@ -2699,7 +2706,7 @@ static void dib8000_set_dds(struct dib8000_state *state, s32 offset_khz)
2699 dds += abs_offset_khz * unit_khz_dds_val; 2706 dds += abs_offset_khz * unit_khz_dds_val;
2700 } 2707 }
2701 2708
2702 dprintk("setting a DDS frequency offset of %c%dkHz", invert ? '-' : ' ', dds / unit_khz_dds_val); 2709 dprintk("setting a DDS frequency offset of %c%dkHz\n", invert ? '-' : ' ', dds / unit_khz_dds_val);
2703 2710
2704 if (abs_offset_khz <= (state->cfg.pll->internal / ratio)) { 2711 if (abs_offset_khz <= (state->cfg.pll->internal / ratio)) {
2705 /* Max dds offset is the half of the demod freq */ 2712 /* Max dds offset is the half of the demod freq */
@@ -2738,7 +2745,7 @@ static void dib8000_set_frequency_offset(struct dib8000_state *state)
2738 } 2745 }
2739 } 2746 }
2740 2747
2741 dprintk("%dkhz tuner offset (frequency = %dHz & current_rf = %dHz) total_dds_offset_hz = %d", c->frequency - current_rf, c->frequency, current_rf, total_dds_offset_khz); 2748 dprintk("%dkhz tuner offset (frequency = %dHz & current_rf = %dHz) total_dds_offset_hz = %d\n", c->frequency - current_rf, c->frequency, current_rf, total_dds_offset_khz);
2742 2749
2743 /* apply dds offset now */ 2750 /* apply dds offset now */
2744 dib8000_set_dds(state, total_dds_offset_khz); 2751 dib8000_set_dds(state, total_dds_offset_khz);
@@ -2890,7 +2897,7 @@ static u16 dib8000_read_lock(struct dvb_frontend *fe)
2890static int dib8090p_init_sdram(struct dib8000_state *state) 2897static int dib8090p_init_sdram(struct dib8000_state *state)
2891{ 2898{
2892 u16 reg = 0; 2899 u16 reg = 0;
2893 dprintk("init sdram"); 2900 dprintk("init sdram\n");
2894 2901
2895 reg = dib8000_read_word(state, 274) & 0xfff0; 2902 reg = dib8000_read_word(state, 274) & 0xfff0;
2896 dib8000_write_word(state, 274, reg | 0x7); /* P_dintlv_delay_ram = 7 because of MobileSdram */ 2903 dib8000_write_word(state, 274, reg | 0x7); /* P_dintlv_delay_ram = 7 because of MobileSdram */
@@ -2931,7 +2938,7 @@ static int is_manual_mode(struct dtv_frontend_properties *c)
2931 * Transmission mode is only detected on auto mode, currently 2938 * Transmission mode is only detected on auto mode, currently
2932 */ 2939 */
2933 if (c->transmission_mode == TRANSMISSION_MODE_AUTO) { 2940 if (c->transmission_mode == TRANSMISSION_MODE_AUTO) {
2934 dprintk("transmission mode auto"); 2941 dprintk("transmission mode auto\n");
2935 return 0; 2942 return 0;
2936 } 2943 }
2937 2944
@@ -2939,7 +2946,7 @@ static int is_manual_mode(struct dtv_frontend_properties *c)
2939 * Guard interval is only detected on auto mode, currently 2946 * Guard interval is only detected on auto mode, currently
2940 */ 2947 */
2941 if (c->guard_interval == GUARD_INTERVAL_AUTO) { 2948 if (c->guard_interval == GUARD_INTERVAL_AUTO) {
2942 dprintk("guard interval auto"); 2949 dprintk("guard interval auto\n");
2943 return 0; 2950 return 0;
2944 } 2951 }
2945 2952
@@ -2948,7 +2955,7 @@ static int is_manual_mode(struct dtv_frontend_properties *c)
2948 * layer should be enabled 2955 * layer should be enabled
2949 */ 2956 */
2950 if (!c->isdbt_layer_enabled) { 2957 if (!c->isdbt_layer_enabled) {
2951 dprintk("no layer modulation specified"); 2958 dprintk("no layer modulation specified\n");
2952 return 0; 2959 return 0;
2953 } 2960 }
2954 2961
@@ -2970,7 +2977,7 @@ static int is_manual_mode(struct dtv_frontend_properties *c)
2970 2977
2971 if ((c->layer[i].modulation == QAM_AUTO) || 2978 if ((c->layer[i].modulation == QAM_AUTO) ||
2972 (c->layer[i].fec == FEC_AUTO)) { 2979 (c->layer[i].fec == FEC_AUTO)) {
2973 dprintk("layer %c has either modulation or FEC auto", 2980 dprintk("layer %c has either modulation or FEC auto\n",
2974 'A' + i); 2981 'A' + i);
2975 return 0; 2982 return 0;
2976 } 2983 }
@@ -2981,7 +2988,7 @@ static int is_manual_mode(struct dtv_frontend_properties *c)
2981 * fallback to auto mode. 2988 * fallback to auto mode.
2982 */ 2989 */
2983 if (n_segs == 0 || n_segs > 13) { 2990 if (n_segs == 0 || n_segs > 13) {
2984 dprintk("number of segments is invalid"); 2991 dprintk("number of segments is invalid\n");
2985 return 0; 2992 return 0;
2986 } 2993 }
2987 2994
@@ -3009,7 +3016,7 @@ static int dib8000_tune(struct dvb_frontend *fe)
3009 3016
3010#if 0 3017#if 0
3011 if (*tune_state < CT_DEMOD_STOP) 3018 if (*tune_state < CT_DEMOD_STOP)
3012 dprintk("IN: context status = %d, TUNE_STATE %d autosearch step = %u jiffies = %lu", 3019 dprintk("IN: context status = %d, TUNE_STATE %d autosearch step = %u jiffies = %lu\n",
3013 state->channel_parameters_set, *tune_state, state->autosearch_state, now); 3020 state->channel_parameters_set, *tune_state, state->autosearch_state, now);
3014#endif 3021#endif
3015 3022
@@ -3022,7 +3029,7 @@ static int dib8000_tune(struct dvb_frontend *fe)
3022 state->status = FE_STATUS_TUNE_PENDING; 3029 state->status = FE_STATUS_TUNE_PENDING;
3023 state->channel_parameters_set = is_manual_mode(c); 3030 state->channel_parameters_set = is_manual_mode(c);
3024 3031
3025 dprintk("Tuning channel on %s search mode", 3032 dprintk("Tuning channel on %s search mode\n",
3026 state->channel_parameters_set ? "manual" : "auto"); 3033 state->channel_parameters_set ? "manual" : "auto");
3027 3034
3028 dib8000_viterbi_state(state, 0); /* force chan dec in restart */ 3035 dib8000_viterbi_state(state, 0); /* force chan dec in restart */
@@ -3102,7 +3109,7 @@ static int dib8000_tune(struct dvb_frontend *fe)
3102 corm[1] = (dib8000_read_word(state, 596) << 16) | (dib8000_read_word(state, 597)); 3109 corm[1] = (dib8000_read_word(state, 596) << 16) | (dib8000_read_word(state, 597));
3103 corm[0] = (dib8000_read_word(state, 598) << 16) | (dib8000_read_word(state, 599)); 3110 corm[0] = (dib8000_read_word(state, 598) << 16) | (dib8000_read_word(state, 599));
3104 } 3111 }
3105 /* dprintk("corm fft: %u %u %u", corm[0], corm[1], corm[2]); */ 3112 /* dprintk("corm fft: %u %u %u\n", corm[0], corm[1], corm[2]); */
3106 3113
3107 max_value = 0; 3114 max_value = 0;
3108 for (find_index = 1 ; find_index < 3 ; find_index++) { 3115 for (find_index = 1 ; find_index < 3 ; find_index++) {
@@ -3122,7 +3129,7 @@ static int dib8000_tune(struct dvb_frontend *fe)
3122 state->found_nfft = TRANSMISSION_MODE_8K; 3129 state->found_nfft = TRANSMISSION_MODE_8K;
3123 break; 3130 break;
3124 } 3131 }
3125 /* dprintk("Autosearch FFT has found Mode %d", max_value + 1); */ 3132 /* dprintk("Autosearch FFT has found Mode %d\n", max_value + 1); */
3126 3133
3127 *tune_state = CT_DEMOD_SEARCH_NEXT; 3134 *tune_state = CT_DEMOD_SEARCH_NEXT;
3128 state->autosearch_state = AS_SEARCHING_GUARD; 3135 state->autosearch_state = AS_SEARCHING_GUARD;
@@ -3137,7 +3144,7 @@ static int dib8000_tune(struct dvb_frontend *fe)
3137 state->found_guard = dib8000_read_word(state, 572) & 0x3; 3144 state->found_guard = dib8000_read_word(state, 572) & 0x3;
3138 else 3145 else
3139 state->found_guard = dib8000_read_word(state, 570) & 0x3; 3146 state->found_guard = dib8000_read_word(state, 570) & 0x3;
3140 /* dprintk("guard interval found=%i", state->found_guard); */ 3147 /* dprintk("guard interval found=%i\n", state->found_guard); */
3141 3148
3142 *tune_state = CT_DEMOD_STEP_3; 3149 *tune_state = CT_DEMOD_STEP_3;
3143 break; 3150 break;
@@ -3233,7 +3240,7 @@ static int dib8000_tune(struct dvb_frontend *fe)
3233 /* defines timeout for mpeg lock depending on interleaver length of longest layer */ 3240 /* defines timeout for mpeg lock depending on interleaver length of longest layer */
3234 for (i = 0; i < 3; i++) { 3241 for (i = 0; i < 3; i++) {
3235 if (c->layer[i].interleaving >= deeper_interleaver) { 3242 if (c->layer[i].interleaving >= deeper_interleaver) {
3236 dprintk("layer%i: time interleaver = %d ", i, c->layer[i].interleaving); 3243 dprintk("layer%i: time interleaver = %d\n", i, c->layer[i].interleaving);
3237 if (c->layer[i].segment_count > 0) { /* valid layer */ 3244 if (c->layer[i].segment_count > 0) { /* valid layer */
3238 deeper_interleaver = c->layer[0].interleaving; 3245 deeper_interleaver = c->layer[0].interleaving;
3239 state->longest_intlv_layer = i; 3246 state->longest_intlv_layer = i;
@@ -3252,7 +3259,7 @@ static int dib8000_tune(struct dvb_frontend *fe)
3252 locks *= 2; 3259 locks *= 2;
3253 3260
3254 *timeout = now + msecs_to_jiffies(200 * locks); /* give the mpeg lock 800ms if sram is present */ 3261 *timeout = now + msecs_to_jiffies(200 * locks); /* give the mpeg lock 800ms if sram is present */
3255 dprintk("Deeper interleaver mode = %d on layer %d : timeout mult factor = %d => will use timeout = %ld", 3262 dprintk("Deeper interleaver mode = %d on layer %d : timeout mult factor = %d => will use timeout = %ld\n",
3256 deeper_interleaver, state->longest_intlv_layer, locks, *timeout); 3263 deeper_interleaver, state->longest_intlv_layer, locks, *timeout);
3257 3264
3258 *tune_state = CT_DEMOD_STEP_10; 3265 *tune_state = CT_DEMOD_STEP_10;
@@ -3263,7 +3270,7 @@ static int dib8000_tune(struct dvb_frontend *fe)
3263 case CT_DEMOD_STEP_10: /* 40 */ 3270 case CT_DEMOD_STEP_10: /* 40 */
3264 locks = dib8000_read_lock(fe); 3271 locks = dib8000_read_lock(fe);
3265 if (locks&(1<<(7-state->longest_intlv_layer))) { /* mpeg lock : check the longest one */ 3272 if (locks&(1<<(7-state->longest_intlv_layer))) { /* mpeg lock : check the longest one */
3266 dprintk("ISDB-T layer locks: Layer A %s, Layer B %s, Layer C %s", 3273 dprintk("ISDB-T layer locks: Layer A %s, Layer B %s, Layer C %s\n",
3267 c->layer[0].segment_count ? (locks >> 7) & 0x1 ? "locked" : "NOT LOCKED" : "not enabled", 3274 c->layer[0].segment_count ? (locks >> 7) & 0x1 ? "locked" : "NOT LOCKED" : "not enabled",
3268 c->layer[1].segment_count ? (locks >> 6) & 0x1 ? "locked" : "NOT LOCKED" : "not enabled", 3275 c->layer[1].segment_count ? (locks >> 6) & 0x1 ? "locked" : "NOT LOCKED" : "not enabled",
3269 c->layer[2].segment_count ? (locks >> 5) & 0x1 ? "locked" : "NOT LOCKED" : "not enabled"); 3276 c->layer[2].segment_count ? (locks >> 5) & 0x1 ? "locked" : "NOT LOCKED" : "not enabled");
@@ -3283,7 +3290,7 @@ static int dib8000_tune(struct dvb_frontend *fe)
3283 *tune_state = CT_DEMOD_STEP_11; 3290 *tune_state = CT_DEMOD_STEP_11;
3284 } else { /* we are done mpeg of the longest interleaver xas not locking but let's try if an other layer has locked in the same time */ 3291 } else { /* we are done mpeg of the longest interleaver xas not locking but let's try if an other layer has locked in the same time */
3285 if (locks & (0x7 << 5)) { 3292 if (locks & (0x7 << 5)) {
3286 dprintk("Not all ISDB-T layers locked in %d ms: Layer A %s, Layer B %s, Layer C %s", 3293 dprintk("Not all ISDB-T layers locked in %d ms: Layer A %s, Layer B %s, Layer C %s\n",
3287 jiffies_to_msecs(now - *timeout), 3294 jiffies_to_msecs(now - *timeout),
3288 c->layer[0].segment_count ? (locks >> 7) & 0x1 ? "locked" : "NOT LOCKED" : "not enabled", 3295 c->layer[0].segment_count ? (locks >> 7) & 0x1 ? "locked" : "NOT LOCKED" : "not enabled",
3289 c->layer[1].segment_count ? (locks >> 6) & 0x1 ? "locked" : "NOT LOCKED" : "not enabled", 3296 c->layer[1].segment_count ? (locks >> 6) & 0x1 ? "locked" : "NOT LOCKED" : "not enabled",
@@ -3348,7 +3355,7 @@ static int dib8000_wakeup(struct dvb_frontend *fe)
3348 dib8000_set_power_mode(state, DIB8000_POWER_ALL); 3355 dib8000_set_power_mode(state, DIB8000_POWER_ALL);
3349 dib8000_set_adc_state(state, DIBX000_ADC_ON); 3356 dib8000_set_adc_state(state, DIBX000_ADC_ON);
3350 if (dib8000_set_adc_state(state, DIBX000_SLOW_ADC_ON) != 0) 3357 if (dib8000_set_adc_state(state, DIBX000_SLOW_ADC_ON) != 0)
3351 dprintk("could not start Slow ADC"); 3358 dprintk("could not start Slow ADC\n");
3352 3359
3353 if (state->revision == 0x8090) 3360 if (state->revision == 0x8090)
3354 dib8000_sad_calib(state); 3361 dib8000_sad_calib(state);
@@ -3401,11 +3408,11 @@ static int dib8000_get_frontend(struct dvb_frontend *fe,
3401 if (!(stat & FE_HAS_SYNC)) 3408 if (!(stat & FE_HAS_SYNC))
3402 return 0; 3409 return 0;
3403 3410
3404 dprintk("dib8000_get_frontend: TMCC lock"); 3411 dprintk("dib8000_get_frontend: TMCC lock\n");
3405 for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { 3412 for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) {
3406 state->fe[index_frontend]->ops.read_status(state->fe[index_frontend], &stat); 3413 state->fe[index_frontend]->ops.read_status(state->fe[index_frontend], &stat);
3407 if (stat&FE_HAS_SYNC) { 3414 if (stat&FE_HAS_SYNC) {
3408 dprintk("TMCC lock on the slave%i", index_frontend); 3415 dprintk("TMCC lock on the slave%i\n", index_frontend);
3409 /* synchronize the cache with the other frontends */ 3416 /* synchronize the cache with the other frontends */
3410 state->fe[index_frontend]->ops.get_frontend(state->fe[index_frontend], c); 3417 state->fe[index_frontend]->ops.get_frontend(state->fe[index_frontend], c);
3411 for (sub_index_frontend = 0; (sub_index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[sub_index_frontend] != NULL); sub_index_frontend++) { 3418 for (sub_index_frontend = 0; (sub_index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[sub_index_frontend] != NULL); sub_index_frontend++) {
@@ -3437,41 +3444,41 @@ static int dib8000_get_frontend(struct dvb_frontend *fe,
3437 switch ((val & 0x30) >> 4) { 3444 switch ((val & 0x30) >> 4) {
3438 case 1: 3445 case 1:
3439 c->transmission_mode = TRANSMISSION_MODE_2K; 3446 c->transmission_mode = TRANSMISSION_MODE_2K;
3440 dprintk("dib8000_get_frontend: transmission mode 2K"); 3447 dprintk("dib8000_get_frontend: transmission mode 2K\n");
3441 break; 3448 break;
3442 case 2: 3449 case 2:
3443 c->transmission_mode = TRANSMISSION_MODE_4K; 3450 c->transmission_mode = TRANSMISSION_MODE_4K;
3444 dprintk("dib8000_get_frontend: transmission mode 4K"); 3451 dprintk("dib8000_get_frontend: transmission mode 4K\n");
3445 break; 3452 break;
3446 case 3: 3453 case 3:
3447 default: 3454 default:
3448 c->transmission_mode = TRANSMISSION_MODE_8K; 3455 c->transmission_mode = TRANSMISSION_MODE_8K;
3449 dprintk("dib8000_get_frontend: transmission mode 8K"); 3456 dprintk("dib8000_get_frontend: transmission mode 8K\n");
3450 break; 3457 break;
3451 } 3458 }
3452 3459
3453 switch (val & 0x3) { 3460 switch (val & 0x3) {
3454 case 0: 3461 case 0:
3455 c->guard_interval = GUARD_INTERVAL_1_32; 3462 c->guard_interval = GUARD_INTERVAL_1_32;
3456 dprintk("dib8000_get_frontend: Guard Interval = 1/32 "); 3463 dprintk("dib8000_get_frontend: Guard Interval = 1/32\n");
3457 break; 3464 break;
3458 case 1: 3465 case 1:
3459 c->guard_interval = GUARD_INTERVAL_1_16; 3466 c->guard_interval = GUARD_INTERVAL_1_16;
3460 dprintk("dib8000_get_frontend: Guard Interval = 1/16 "); 3467 dprintk("dib8000_get_frontend: Guard Interval = 1/16\n");
3461 break; 3468 break;
3462 case 2: 3469 case 2:
3463 dprintk("dib8000_get_frontend: Guard Interval = 1/8 "); 3470 dprintk("dib8000_get_frontend: Guard Interval = 1/8\n");
3464 c->guard_interval = GUARD_INTERVAL_1_8; 3471 c->guard_interval = GUARD_INTERVAL_1_8;
3465 break; 3472 break;
3466 case 3: 3473 case 3:
3467 dprintk("dib8000_get_frontend: Guard Interval = 1/4 "); 3474 dprintk("dib8000_get_frontend: Guard Interval = 1/4\n");
3468 c->guard_interval = GUARD_INTERVAL_1_4; 3475 c->guard_interval = GUARD_INTERVAL_1_4;
3469 break; 3476 break;
3470 } 3477 }
3471 3478
3472 val = dib8000_read_word(state, 505); 3479 val = dib8000_read_word(state, 505);
3473 c->isdbt_partial_reception = val & 1; 3480 c->isdbt_partial_reception = val & 1;
3474 dprintk("dib8000_get_frontend: partial_reception = %d ", c->isdbt_partial_reception); 3481 dprintk("dib8000_get_frontend: partial_reception = %d\n", c->isdbt_partial_reception);
3475 3482
3476 for (i = 0; i < 3; i++) { 3483 for (i = 0; i < 3; i++) {
3477 int show; 3484 int show;
@@ -3485,7 +3492,7 @@ static int dib8000_get_frontend(struct dvb_frontend *fe,
3485 show = 1; 3492 show = 1;
3486 3493
3487 if (show) 3494 if (show)
3488 dprintk("dib8000_get_frontend: Layer %d segments = %d ", 3495 dprintk("dib8000_get_frontend: Layer %d segments = %d\n",
3489 i, c->layer[i].segment_count); 3496 i, c->layer[i].segment_count);
3490 3497
3491 val = dib8000_read_word(state, 499 + i) & 0x3; 3498 val = dib8000_read_word(state, 499 + i) & 0x3;
@@ -3494,7 +3501,7 @@ static int dib8000_get_frontend(struct dvb_frontend *fe,
3494 val = 4; 3501 val = 4;
3495 c->layer[i].interleaving = val; 3502 c->layer[i].interleaving = val;
3496 if (show) 3503 if (show)
3497 dprintk("dib8000_get_frontend: Layer %d time_intlv = %d ", 3504 dprintk("dib8000_get_frontend: Layer %d time_intlv = %d\n",
3498 i, c->layer[i].interleaving); 3505 i, c->layer[i].interleaving);
3499 3506
3500 val = dib8000_read_word(state, 481 + i); 3507 val = dib8000_read_word(state, 481 + i);
@@ -3502,27 +3509,27 @@ static int dib8000_get_frontend(struct dvb_frontend *fe,
3502 case 1: 3509 case 1:
3503 c->layer[i].fec = FEC_1_2; 3510 c->layer[i].fec = FEC_1_2;
3504 if (show) 3511 if (show)
3505 dprintk("dib8000_get_frontend: Layer %d Code Rate = 1/2 ", i); 3512 dprintk("dib8000_get_frontend: Layer %d Code Rate = 1/2\n", i);
3506 break; 3513 break;
3507 case 2: 3514 case 2:
3508 c->layer[i].fec = FEC_2_3; 3515 c->layer[i].fec = FEC_2_3;
3509 if (show) 3516 if (show)
3510 dprintk("dib8000_get_frontend: Layer %d Code Rate = 2/3 ", i); 3517 dprintk("dib8000_get_frontend: Layer %d Code Rate = 2/3\n", i);
3511 break; 3518 break;
3512 case 3: 3519 case 3:
3513 c->layer[i].fec = FEC_3_4; 3520 c->layer[i].fec = FEC_3_4;
3514 if (show) 3521 if (show)
3515 dprintk("dib8000_get_frontend: Layer %d Code Rate = 3/4 ", i); 3522 dprintk("dib8000_get_frontend: Layer %d Code Rate = 3/4\n", i);
3516 break; 3523 break;
3517 case 5: 3524 case 5:
3518 c->layer[i].fec = FEC_5_6; 3525 c->layer[i].fec = FEC_5_6;
3519 if (show) 3526 if (show)
3520 dprintk("dib8000_get_frontend: Layer %d Code Rate = 5/6 ", i); 3527 dprintk("dib8000_get_frontend: Layer %d Code Rate = 5/6\n", i);
3521 break; 3528 break;
3522 default: 3529 default:
3523 c->layer[i].fec = FEC_7_8; 3530 c->layer[i].fec = FEC_7_8;
3524 if (show) 3531 if (show)
3525 dprintk("dib8000_get_frontend: Layer %d Code Rate = 7/8 ", i); 3532 dprintk("dib8000_get_frontend: Layer %d Code Rate = 7/8\n", i);
3526 break; 3533 break;
3527 } 3534 }
3528 3535
@@ -3531,23 +3538,23 @@ static int dib8000_get_frontend(struct dvb_frontend *fe,
3531 case 0: 3538 case 0:
3532 c->layer[i].modulation = DQPSK; 3539 c->layer[i].modulation = DQPSK;
3533 if (show) 3540 if (show)
3534 dprintk("dib8000_get_frontend: Layer %d DQPSK ", i); 3541 dprintk("dib8000_get_frontend: Layer %d DQPSK\n", i);
3535 break; 3542 break;
3536 case 1: 3543 case 1:
3537 c->layer[i].modulation = QPSK; 3544 c->layer[i].modulation = QPSK;
3538 if (show) 3545 if (show)
3539 dprintk("dib8000_get_frontend: Layer %d QPSK ", i); 3546 dprintk("dib8000_get_frontend: Layer %d QPSK\n", i);
3540 break; 3547 break;
3541 case 2: 3548 case 2:
3542 c->layer[i].modulation = QAM_16; 3549 c->layer[i].modulation = QAM_16;
3543 if (show) 3550 if (show)
3544 dprintk("dib8000_get_frontend: Layer %d QAM16 ", i); 3551 dprintk("dib8000_get_frontend: Layer %d QAM16\n", i);
3545 break; 3552 break;
3546 case 3: 3553 case 3:
3547 default: 3554 default:
3548 c->layer[i].modulation = QAM_64; 3555 c->layer[i].modulation = QAM_64;
3549 if (show) 3556 if (show)
3550 dprintk("dib8000_get_frontend: Layer %d QAM64 ", i); 3557 dprintk("dib8000_get_frontend: Layer %d QAM64\n", i);
3551 break; 3558 break;
3552 } 3559 }
3553 } 3560 }
@@ -3578,12 +3585,12 @@ static int dib8000_set_frontend(struct dvb_frontend *fe)
3578 unsigned long delay, callback_time; 3585 unsigned long delay, callback_time;
3579 3586
3580 if (c->frequency == 0) { 3587 if (c->frequency == 0) {
3581 dprintk("dib8000: must at least specify frequency "); 3588 dprintk("dib8000: must at least specify frequency\n");
3582 return 0; 3589 return 0;
3583 } 3590 }
3584 3591
3585 if (c->bandwidth_hz == 0) { 3592 if (c->bandwidth_hz == 0) {
3586 dprintk("dib8000: no bandwidth specified, set to default "); 3593 dprintk("dib8000: no bandwidth specified, set to default\n");
3587 c->bandwidth_hz = 6000000; 3594 c->bandwidth_hz = 6000000;
3588 } 3595 }
3589 3596
@@ -3671,7 +3678,7 @@ static int dib8000_set_frontend(struct dvb_frontend *fe)
3671 /* we are in autosearch */ 3678 /* we are in autosearch */
3672 if (state->channel_parameters_set == 0) { /* searching */ 3679 if (state->channel_parameters_set == 0) { /* searching */
3673 if ((dib8000_get_status(state->fe[index_frontend]) == FE_STATUS_DEMOD_SUCCESS) || (dib8000_get_status(state->fe[index_frontend]) == FE_STATUS_FFT_SUCCESS)) { 3680 if ((dib8000_get_status(state->fe[index_frontend]) == FE_STATUS_DEMOD_SUCCESS) || (dib8000_get_status(state->fe[index_frontend]) == FE_STATUS_FFT_SUCCESS)) {
3674 dprintk("autosearch succeeded on fe%i", index_frontend); 3681 dprintk("autosearch succeeded on fe%i\n", index_frontend);
3675 dib8000_get_frontend(state->fe[index_frontend], c); /* we read the channel parameters from the frontend which was successful */ 3682 dib8000_get_frontend(state->fe[index_frontend], c); /* we read the channel parameters from the frontend which was successful */
3676 state->channel_parameters_set = 1; 3683 state->channel_parameters_set = 1;
3677 3684
@@ -3708,11 +3715,11 @@ static int dib8000_set_frontend(struct dvb_frontend *fe)
3708 active = 1; 3715 active = 1;
3709 } 3716 }
3710 if (active == 0) 3717 if (active == 0)
3711 dprintk("tuning done with status %d", dib8000_get_status(state->fe[0])); 3718 dprintk("tuning done with status %d\n", dib8000_get_status(state->fe[0]));
3712 } 3719 }
3713 3720
3714 if ((active == 1) && (callback_time == 0)) { 3721 if ((active == 1) && (callback_time == 0)) {
3715 dprintk("strange callback time something went wrong"); 3722 dprintk("strange callback time something went wrong\n");
3716 active = 0; 3723 active = 0;
3717 } 3724 }
3718 3725
@@ -4172,7 +4179,7 @@ static int dib8000_get_stats(struct dvb_frontend *fe, enum fe_status stat)
4172 time_us = dib8000_get_time_us(fe, -1); 4179 time_us = dib8000_get_time_us(fe, -1);
4173 state->ber_jiffies_stats = jiffies + msecs_to_jiffies((time_us + 500) / 1000); 4180 state->ber_jiffies_stats = jiffies + msecs_to_jiffies((time_us + 500) / 1000);
4174 4181
4175 dprintk("Next all layers stats available in %u us.", time_us); 4182 dprintk("Next all layers stats available in %u us.\n", time_us);
4176 4183
4177 dib8000_read_ber(fe, &val); 4184 dib8000_read_ber(fe, &val);
4178 c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER; 4185 c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER;
@@ -4239,12 +4246,12 @@ static int dib8000_set_slave_frontend(struct dvb_frontend *fe, struct dvb_fronte
4239 while ((index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL)) 4246 while ((index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL))
4240 index_frontend++; 4247 index_frontend++;
4241 if (index_frontend < MAX_NUMBER_OF_FRONTENDS) { 4248 if (index_frontend < MAX_NUMBER_OF_FRONTENDS) {
4242 dprintk("set slave fe %p to index %i", fe_slave, index_frontend); 4249 dprintk("set slave fe %p to index %i\n", fe_slave, index_frontend);
4243 state->fe[index_frontend] = fe_slave; 4250 state->fe[index_frontend] = fe_slave;
4244 return 0; 4251 return 0;
4245 } 4252 }
4246 4253
4247 dprintk("too many slave frontend"); 4254 dprintk("too many slave frontend\n");
4248 return -ENOMEM; 4255 return -ENOMEM;
4249} 4256}
4250 4257
@@ -4256,12 +4263,12 @@ static int dib8000_remove_slave_frontend(struct dvb_frontend *fe)
4256 while ((index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL)) 4263 while ((index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL))
4257 index_frontend++; 4264 index_frontend++;
4258 if (index_frontend != 1) { 4265 if (index_frontend != 1) {
4259 dprintk("remove slave fe %p (index %i)", state->fe[index_frontend-1], index_frontend-1); 4266 dprintk("remove slave fe %p (index %i)\n", state->fe[index_frontend-1], index_frontend-1);
4260 state->fe[index_frontend] = NULL; 4267 state->fe[index_frontend] = NULL;
4261 return 0; 4268 return 0;
4262 } 4269 }
4263 4270
4264 dprintk("no frontend to be removed"); 4271 dprintk("no frontend to be removed\n");
4265 return -ENODEV; 4272 return -ENODEV;
4266} 4273}
4267 4274
@@ -4283,18 +4290,18 @@ static int dib8000_i2c_enumeration(struct i2c_adapter *host, int no_of_demods,
4283 4290
4284 client.i2c_write_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL); 4291 client.i2c_write_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL);
4285 if (!client.i2c_write_buffer) { 4292 if (!client.i2c_write_buffer) {
4286 dprintk("%s: not enough memory", __func__); 4293 dprintk("%s: not enough memory\n", __func__);
4287 return -ENOMEM; 4294 return -ENOMEM;
4288 } 4295 }
4289 client.i2c_read_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL); 4296 client.i2c_read_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL);
4290 if (!client.i2c_read_buffer) { 4297 if (!client.i2c_read_buffer) {
4291 dprintk("%s: not enough memory", __func__); 4298 dprintk("%s: not enough memory\n", __func__);
4292 ret = -ENOMEM; 4299 ret = -ENOMEM;
4293 goto error_memory_read; 4300 goto error_memory_read;
4294 } 4301 }
4295 client.i2c_buffer_lock = kzalloc(sizeof(struct mutex), GFP_KERNEL); 4302 client.i2c_buffer_lock = kzalloc(sizeof(struct mutex), GFP_KERNEL);
4296 if (!client.i2c_buffer_lock) { 4303 if (!client.i2c_buffer_lock) {
4297 dprintk("%s: not enough memory", __func__); 4304 dprintk("%s: not enough memory\n", __func__);
4298 ret = -ENOMEM; 4305 ret = -ENOMEM;
4299 goto error_memory_lock; 4306 goto error_memory_lock;
4300 } 4307 }
@@ -4313,7 +4320,7 @@ static int dib8000_i2c_enumeration(struct i2c_adapter *host, int no_of_demods,
4313 dib8000_i2c_write16(&client, 1287, 0x0003); 4320 dib8000_i2c_write16(&client, 1287, 0x0003);
4314 client.addr = default_addr; 4321 client.addr = default_addr;
4315 if (dib8000_identify(&client) == 0) { 4322 if (dib8000_identify(&client) == 0) {
4316 dprintk("#%d: not identified", k); 4323 dprintk("#%d: not identified\n", k);
4317 ret = -EINVAL; 4324 ret = -EINVAL;
4318 goto error; 4325 goto error;
4319 } 4326 }
@@ -4327,7 +4334,7 @@ static int dib8000_i2c_enumeration(struct i2c_adapter *host, int no_of_demods,
4327 client.addr = new_addr; 4334 client.addr = new_addr;
4328 dib8000_identify(&client); 4335 dib8000_identify(&client);
4329 4336
4330 dprintk("IC %d initialized (to i2c_address 0x%x)", k, new_addr); 4337 dprintk("IC %d initialized (to i2c_address 0x%x)\n", k, new_addr);
4331 } 4338 }
4332 4339
4333 for (k = 0; k < no_of_demods; k++) { 4340 for (k = 0; k < no_of_demods; k++) {
@@ -4385,14 +4392,14 @@ static int dib8000_pid_filter_ctrl(struct dvb_frontend *fe, u8 onoff)
4385 u16 val = dib8000_read_word(st, 299) & 0xffef; 4392 u16 val = dib8000_read_word(st, 299) & 0xffef;
4386 val |= (onoff & 0x1) << 4; 4393 val |= (onoff & 0x1) << 4;
4387 4394
4388 dprintk("pid filter enabled %d", onoff); 4395 dprintk("pid filter enabled %d\n", onoff);
4389 return dib8000_write_word(st, 299, val); 4396 return dib8000_write_word(st, 299, val);
4390} 4397}
4391 4398
4392static int dib8000_pid_filter(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff) 4399static int dib8000_pid_filter(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff)
4393{ 4400{
4394 struct dib8000_state *st = fe->demodulator_priv; 4401 struct dib8000_state *st = fe->demodulator_priv;
4395 dprintk("Index %x, PID %d, OnOff %d", id, pid, onoff); 4402 dprintk("Index %x, PID %d, OnOff %d\n", id, pid, onoff);
4396 return dib8000_write_word(st, 305 + id, onoff ? (1 << 13) | pid : 0); 4403 return dib8000_write_word(st, 305 + id, onoff ? (1 << 13) | pid : 0);
4397} 4404}
4398 4405
@@ -4431,7 +4438,7 @@ static struct dvb_frontend *dib8000_init(struct i2c_adapter *i2c_adap, u8 i2c_ad
4431 struct dvb_frontend *fe; 4438 struct dvb_frontend *fe;
4432 struct dib8000_state *state; 4439 struct dib8000_state *state;
4433 4440
4434 dprintk("dib8000_init"); 4441 dprintk("dib8000_init\n");
4435 4442
4436 state = kzalloc(sizeof(struct dib8000_state), GFP_KERNEL); 4443 state = kzalloc(sizeof(struct dib8000_state), GFP_KERNEL);
4437 if (state == NULL) 4444 if (state == NULL)
diff --git a/drivers/media/dvb-frontends/dib9000.c b/drivers/media/dvb-frontends/dib9000.c
index 5897977d2d00..c95fff4f9582 100644
--- a/drivers/media/dvb-frontends/dib9000.c
+++ b/drivers/media/dvb-frontends/dib9000.c
@@ -7,6 +7,9 @@
7 * modify it under the terms of the GNU General Public License as 7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2. 8 * published by the Free Software Foundation, version 2.
9 */ 9 */
10
11#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
12
10#include <linux/kernel.h> 13#include <linux/kernel.h>
11#include <linux/i2c.h> 14#include <linux/i2c.h>
12#include <linux/mutex.h> 15#include <linux/mutex.h>
@@ -21,7 +24,12 @@ static int debug;
21module_param(debug, int, 0644); 24module_param(debug, int, 0644);
22MODULE_PARM_DESC(debug, "turn on debugging (default: 0)"); 25MODULE_PARM_DESC(debug, "turn on debugging (default: 0)");
23 26
24#define dprintk(args...) do { if (debug) { printk(KERN_DEBUG "DiB9000: "); printk(args); printk("\n"); } } while (0) 27#define dprintk(fmt, arg...) do { \
28 if (debug) \
29 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
30 __func__, ##arg); \
31} while (0)
32
25#define MAX_NUMBER_OF_FRONTENDS 6 33#define MAX_NUMBER_OF_FRONTENDS 6
26 34
27struct i2c_device { 35struct i2c_device {
@@ -258,7 +266,7 @@ static int dib9000_read16_attr(struct dib9000_state *state, u16 reg, u8 *b, u32
258 state->msg[1].buf = b; 266 state->msg[1].buf = b;
259 ret = i2c_transfer(state->i2c.i2c_adap, state->msg, 2) != 2 ? -EREMOTEIO : 0; 267 ret = i2c_transfer(state->i2c.i2c_adap, state->msg, 2) != 2 ? -EREMOTEIO : 0;
260 if (ret != 0) { 268 if (ret != 0) {
261 dprintk("i2c read error on %d", reg); 269 dprintk("i2c read error on %d\n", reg);
262 return -EREMOTEIO; 270 return -EREMOTEIO;
263 } 271 }
264 272
@@ -285,7 +293,7 @@ static u16 dib9000_i2c_read16(struct i2c_device *i2c, u16 reg)
285 i2c->i2c_write_buffer[1] = reg & 0xff; 293 i2c->i2c_write_buffer[1] = reg & 0xff;
286 294
287 if (i2c_transfer(i2c->i2c_adap, msg, 2) != 2) { 295 if (i2c_transfer(i2c->i2c_adap, msg, 2) != 2) {
288 dprintk("read register %x error", reg); 296 dprintk("read register %x error\n", reg);
289 return 0; 297 return 0;
290 } 298 }
291 299
@@ -440,7 +448,7 @@ static int dib9000_risc_mem_read(struct dib9000_state *state, u8 cmd, u8 * b, u1
440 return -EIO; 448 return -EIO;
441 449
442 if (mutex_lock_interruptible(&state->platform.risc.mem_lock) < 0) { 450 if (mutex_lock_interruptible(&state->platform.risc.mem_lock) < 0) {
443 dprintk("could not get the lock"); 451 dprintk("could not get the lock\n");
444 return -EINTR; 452 return -EINTR;
445 } 453 }
446 dib9000_risc_mem_setup(state, cmd | 0x80); 454 dib9000_risc_mem_setup(state, cmd | 0x80);
@@ -456,7 +464,7 @@ static int dib9000_risc_mem_write(struct dib9000_state *state, u8 cmd, const u8
456 return -EIO; 464 return -EIO;
457 465
458 if (mutex_lock_interruptible(&state->platform.risc.mem_lock) < 0) { 466 if (mutex_lock_interruptible(&state->platform.risc.mem_lock) < 0) {
459 dprintk("could not get the lock"); 467 dprintk("could not get the lock\n");
460 return -EINTR; 468 return -EINTR;
461 } 469 }
462 dib9000_risc_mem_setup(state, cmd); 470 dib9000_risc_mem_setup(state, cmd);
@@ -479,13 +487,13 @@ static int dib9000_firmware_download(struct dib9000_state *state, u8 risc_id, u1
479 dib9000_write_word(state, 1025 + offs, 0); 487 dib9000_write_word(state, 1025 + offs, 0);
480 dib9000_write_word(state, 1031 + offs, key); 488 dib9000_write_word(state, 1031 + offs, key);
481 489
482 dprintk("going to download %dB of microcode", len); 490 dprintk("going to download %dB of microcode\n", len);
483 if (dib9000_write16_noinc(state, 1026 + offs, (u8 *) code, (u16) len) != 0) { 491 if (dib9000_write16_noinc(state, 1026 + offs, (u8 *) code, (u16) len) != 0) {
484 dprintk("error while downloading microcode for RISC %c", 'A' + risc_id); 492 dprintk("error while downloading microcode for RISC %c\n", 'A' + risc_id);
485 return -EIO; 493 return -EIO;
486 } 494 }
487 495
488 dprintk("Microcode for RISC %c loaded", 'A' + risc_id); 496 dprintk("Microcode for RISC %c loaded\n", 'A' + risc_id);
489 497
490 return 0; 498 return 0;
491} 499}
@@ -511,10 +519,10 @@ static int dib9000_mbx_host_init(struct dib9000_state *state, u8 risc_id)
511 } while ((reset_reg & 0x8000) && --tries); 519 } while ((reset_reg & 0x8000) && --tries);
512 520
513 if (reset_reg & 0x8000) { 521 if (reset_reg & 0x8000) {
514 dprintk("MBX: init ERROR, no response from RISC %c", 'A' + risc_id); 522 dprintk("MBX: init ERROR, no response from RISC %c\n", 'A' + risc_id);
515 return -EIO; 523 return -EIO;
516 } 524 }
517 dprintk("MBX: initialized"); 525 dprintk("MBX: initialized\n");
518 return 0; 526 return 0;
519} 527}
520 528
@@ -531,30 +539,27 @@ static int dib9000_mbx_send_attr(struct dib9000_state *state, u8 id, u16 * data,
531 return -EINVAL; 539 return -EINVAL;
532 540
533 if (mutex_lock_interruptible(&state->platform.risc.mbx_if_lock) < 0) { 541 if (mutex_lock_interruptible(&state->platform.risc.mbx_if_lock) < 0) {
534 dprintk("could not get the lock"); 542 dprintk("could not get the lock\n");
535 return -EINTR; 543 return -EINTR;
536 } 544 }
537 tmp = MAX_MAILBOX_TRY; 545 tmp = MAX_MAILBOX_TRY;
538 do { 546 do {
539 size = dib9000_read_word_attr(state, 1043, attr) & 0xff; 547 size = dib9000_read_word_attr(state, 1043, attr) & 0xff;
540 if ((size + len + 1) > MBX_MAX_WORDS && --tmp) { 548 if ((size + len + 1) > MBX_MAX_WORDS && --tmp) {
541 dprintk("MBX: RISC mbx full, retrying"); 549 dprintk("MBX: RISC mbx full, retrying\n");
542 msleep(100); 550 msleep(100);
543 } else 551 } else
544 break; 552 break;
545 } while (1); 553 } while (1);
546 554
547 /*dprintk( "MBX: size: %d", size); */ 555 /*dprintk( "MBX: size: %d\n", size); */
548 556
549 if (tmp == 0) { 557 if (tmp == 0) {
550 ret = -EINVAL; 558 ret = -EINVAL;
551 goto out; 559 goto out;
552 } 560 }
553#ifdef DUMP_MSG 561#ifdef DUMP_MSG
554 dprintk("--> %02x %d ", id, len + 1); 562 dprintk("--> %02x %d %*ph\n", id, len + 1, len, data);
555 for (i = 0; i < len; i++)
556 dprintk("%04x ", data[i]);
557 dprintk("\n");
558#endif 563#endif
559 564
560 /* byte-order conversion - works on big (where it is not necessary) or little endian */ 565 /* byte-order conversion - works on big (where it is not necessary) or little endian */
@@ -596,7 +601,7 @@ static u8 dib9000_mbx_read(struct dib9000_state *state, u16 * data, u8 risc_id,
596 return 0; 601 return 0;
597 602
598 if (mutex_lock_interruptible(&state->platform.risc.mbx_if_lock) < 0) { 603 if (mutex_lock_interruptible(&state->platform.risc.mbx_if_lock) < 0) {
599 dprintk("could not get the lock"); 604 dprintk("could not get the lock\n");
600 return 0; 605 return 0;
601 } 606 }
602 if (risc_id == 1) 607 if (risc_id == 1)
@@ -622,13 +627,13 @@ static u8 dib9000_mbx_read(struct dib9000_state *state, u16 * data, u8 risc_id,
622 } 627 }
623 628
624#ifdef DUMP_MSG 629#ifdef DUMP_MSG
625 dprintk("<-- "); 630 dprintk("<--\n");
626 for (i = 0; i < size + 1; i++) 631 for (i = 0; i < size + 1; i++)
627 dprintk("%04x ", d[i]); 632 dprintk("%04x\n", d[i]);
628 dprintk("\n"); 633 dprintk("\n");
629#endif 634#endif
630 } else { 635 } else {
631 dprintk("MBX: message is too big for message cache (%d), flushing message", size); 636 dprintk("MBX: message is too big for message cache (%d), flushing message\n", size);
632 size--; /* Initial word already read */ 637 size--; /* Initial word already read */
633 while (size--) 638 while (size--)
634 dib9000_read16_noinc_attr(state, 1029 + mc_base, (u8 *) data, 2, attr); 639 dib9000_read16_noinc_attr(state, 1029 + mc_base, (u8 *) data, 2, attr);
@@ -649,9 +654,11 @@ static int dib9000_risc_debug_buf(struct dib9000_state *state, u16 * data, u8 si
649 b[2 * (size - 2) - 1] = '\0'; /* Bullet proof the buffer */ 654 b[2 * (size - 2) - 1] = '\0'; /* Bullet proof the buffer */
650 if (*b == '~') { 655 if (*b == '~') {
651 b++; 656 b++;
652 dprintk("%s", b); 657 dprintk("%s\n", b);
653 } else 658 } else
654 dprintk("RISC%d: %d.%04d %s", state->fe_id, ts / 10000, ts % 10000, *b ? b : "<empty>"); 659 dprintk("RISC%d: %d.%04d %s\n",
660 state->fe_id,
661 ts / 10000, ts % 10000, *b ? b : "<empty>");
655 return 1; 662 return 1;
656} 663}
657 664
@@ -666,7 +673,7 @@ static int dib9000_mbx_fetch_to_cache(struct dib9000_state *state, u16 attr)
666 if (*block == 0) { 673 if (*block == 0) {
667 size = dib9000_mbx_read(state, block, 1, attr); 674 size = dib9000_mbx_read(state, block, 1, attr);
668 675
669/* dprintk( "MBX: fetched %04x message to cache", *block); */ 676/* dprintk( "MBX: fetched %04x message to cache\n", *block); */
670 677
671 switch (*block >> 8) { 678 switch (*block >> 8) {
672 case IN_MSG_DEBUG_BUF: 679 case IN_MSG_DEBUG_BUF:
@@ -686,7 +693,7 @@ static int dib9000_mbx_fetch_to_cache(struct dib9000_state *state, u16 attr)
686 return 1; 693 return 1;
687 } 694 }
688 } 695 }
689 dprintk("MBX: no free cache-slot found for new message..."); 696 dprintk("MBX: no free cache-slot found for new message...\n");
690 return -1; 697 return -1;
691} 698}
692 699
@@ -706,7 +713,7 @@ static int dib9000_mbx_process(struct dib9000_state *state, u16 attr)
706 return -1; 713 return -1;
707 714
708 if (mutex_lock_interruptible(&state->platform.risc.mbx_lock) < 0) { 715 if (mutex_lock_interruptible(&state->platform.risc.mbx_lock) < 0) {
709 dprintk("could not get the lock"); 716 dprintk("could not get the lock\n");
710 return -1; 717 return -1;
711 } 718 }
712 719
@@ -715,7 +722,7 @@ static int dib9000_mbx_process(struct dib9000_state *state, u16 attr)
715 722
716 dib9000_read_word_attr(state, 1229, attr); /* Clear the IRQ */ 723 dib9000_read_word_attr(state, 1229, attr); /* Clear the IRQ */
717/* if (tmp) */ 724/* if (tmp) */
718/* dprintk( "cleared IRQ: %x", tmp); */ 725/* dprintk( "cleared IRQ: %x\n", tmp); */
719 mutex_unlock(&state->platform.risc.mbx_lock); 726 mutex_unlock(&state->platform.risc.mbx_lock);
720 727
721 return ret; 728 return ret;
@@ -750,7 +757,7 @@ static int dib9000_mbx_get_message_attr(struct dib9000_state *state, u16 id, u16
750 } while (--timeout); 757 } while (--timeout);
751 758
752 if (timeout == 0) { 759 if (timeout == 0) {
753 dprintk("waiting for message %d timed out", id); 760 dprintk("waiting for message %d timed out\n", id);
754 return -1; 761 return -1;
755 } 762 }
756 763
@@ -770,7 +777,7 @@ static int dib9000_risc_check_version(struct dib9000_state *state)
770 return -EIO; 777 return -EIO;
771 778
772 fw_version = (r[0] << 8) | r[1]; 779 fw_version = (r[0] << 8) | r[1];
773 dprintk("RISC: ver: %d.%02d (IC: %d)", fw_version >> 10, fw_version & 0x3ff, (r[2] << 8) | r[3]); 780 dprintk("RISC: ver: %d.%02d (IC: %d)\n", fw_version >> 10, fw_version & 0x3ff, (r[2] << 8) | r[3]);
774 781
775 if ((fw_version >> 10) != 7) 782 if ((fw_version >> 10) != 7)
776 return -EINVAL; 783 return -EINVAL;
@@ -850,40 +857,40 @@ static u16 dib9000_identify(struct i2c_device *client)
850 857
851 value = dib9000_i2c_read16(client, 896); 858 value = dib9000_i2c_read16(client, 896);
852 if (value != 0x01b3) { 859 if (value != 0x01b3) {
853 dprintk("wrong Vendor ID (0x%x)", value); 860 dprintk("wrong Vendor ID (0x%x)\n", value);
854 return 0; 861 return 0;
855 } 862 }
856 863
857 value = dib9000_i2c_read16(client, 897); 864 value = dib9000_i2c_read16(client, 897);
858 if (value != 0x4000 && value != 0x4001 && value != 0x4002 && value != 0x4003 && value != 0x4004 && value != 0x4005) { 865 if (value != 0x4000 && value != 0x4001 && value != 0x4002 && value != 0x4003 && value != 0x4004 && value != 0x4005) {
859 dprintk("wrong Device ID (0x%x)", value); 866 dprintk("wrong Device ID (0x%x)\n", value);
860 return 0; 867 return 0;
861 } 868 }
862 869
863 /* protect this driver to be used with 7000PC */ 870 /* protect this driver to be used with 7000PC */
864 if (value == 0x4000 && dib9000_i2c_read16(client, 769) == 0x4000) { 871 if (value == 0x4000 && dib9000_i2c_read16(client, 769) == 0x4000) {
865 dprintk("this driver does not work with DiB7000PC"); 872 dprintk("this driver does not work with DiB7000PC\n");
866 return 0; 873 return 0;
867 } 874 }
868 875
869 switch (value) { 876 switch (value) {
870 case 0x4000: 877 case 0x4000:
871 dprintk("found DiB7000MA/PA/MB/PB"); 878 dprintk("found DiB7000MA/PA/MB/PB\n");
872 break; 879 break;
873 case 0x4001: 880 case 0x4001:
874 dprintk("found DiB7000HC"); 881 dprintk("found DiB7000HC\n");
875 break; 882 break;
876 case 0x4002: 883 case 0x4002:
877 dprintk("found DiB7000MC"); 884 dprintk("found DiB7000MC\n");
878 break; 885 break;
879 case 0x4003: 886 case 0x4003:
880 dprintk("found DiB9000A"); 887 dprintk("found DiB9000A\n");
881 break; 888 break;
882 case 0x4004: 889 case 0x4004:
883 dprintk("found DiB9000H"); 890 dprintk("found DiB9000H\n");
884 break; 891 break;
885 case 0x4005: 892 case 0x4005:
886 dprintk("found DiB9000M"); 893 dprintk("found DiB9000M\n");
887 break; 894 break;
888 } 895 }
889 896
@@ -1013,7 +1020,7 @@ static int dib9000_risc_apb_access_read(struct dib9000_state *state, u32 address
1013 if (address >= 1024 || !state->platform.risc.fw_is_running) 1020 if (address >= 1024 || !state->platform.risc.fw_is_running)
1014 return -EINVAL; 1021 return -EINVAL;
1015 1022
1016 /* dprintk( "APB access thru rd fw %d %x", address, attribute); */ 1023 /* dprintk( "APB access thru rd fw %d %x\n", address, attribute); */
1017 1024
1018 mb[0] = (u16) address; 1025 mb[0] = (u16) address;
1019 mb[1] = len / 2; 1026 mb[1] = len / 2;
@@ -1043,7 +1050,7 @@ static int dib9000_risc_apb_access_write(struct dib9000_state *state, u32 addres
1043 if (len > 18) 1050 if (len > 18)
1044 return -EINVAL; 1051 return -EINVAL;
1045 1052
1046 /* dprintk( "APB access thru wr fw %d %x", address, attribute); */ 1053 /* dprintk( "APB access thru wr fw %d %x\n", address, attribute); */
1047 1054
1048 mb[0] = (u16)address; 1055 mb[0] = (u16)address;
1049 for (i = 0; i + 1 < len; i += 2) 1056 for (i = 0; i + 1 < len; i += 2)
@@ -1191,7 +1198,7 @@ static int dib9000_fw_get_channel(struct dvb_frontend *fe)
1191 int ret = 0; 1198 int ret = 0;
1192 1199
1193 if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) { 1200 if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) {
1194 dprintk("could not get the lock"); 1201 dprintk("could not get the lock\n");
1195 return -EINTR; 1202 return -EINTR;
1196 } 1203 }
1197 if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0) { 1204 if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0) {
@@ -1534,7 +1541,7 @@ static int dib9000_fw_set_output_mode(struct dvb_frontend *fe, int mode)
1534 struct dib9000_state *state = fe->demodulator_priv; 1541 struct dib9000_state *state = fe->demodulator_priv;
1535 u16 outreg, smo_mode; 1542 u16 outreg, smo_mode;
1536 1543
1537 dprintk("setting output mode for demod %p to %d", fe, mode); 1544 dprintk("setting output mode for demod %p to %d\n", fe, mode);
1538 1545
1539 switch (mode) { 1546 switch (mode) {
1540 case OUTMODE_MPEG2_PAR_GATED_CLK: 1547 case OUTMODE_MPEG2_PAR_GATED_CLK:
@@ -1556,7 +1563,7 @@ static int dib9000_fw_set_output_mode(struct dvb_frontend *fe, int mode)
1556 outreg = 0; 1563 outreg = 0;
1557 break; 1564 break;
1558 default: 1565 default:
1559 dprintk("Unhandled output_mode passed to be set for demod %p", &state->fe[0]); 1566 dprintk("Unhandled output_mode passed to be set for demod %p\n", &state->fe[0]);
1560 return -EINVAL; 1567 return -EINVAL;
1561 } 1568 }
1562 1569
@@ -1590,7 +1597,7 @@ static int dib9000_tuner_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msg[]
1590 len = 16; 1597 len = 16;
1591 1598
1592 if (dib9000_read_word(state, 790) != 0) 1599 if (dib9000_read_word(state, 790) != 0)
1593 dprintk("TunerITF: read busy"); 1600 dprintk("TunerITF: read busy\n");
1594 1601
1595 dib9000_write_word(state, 784, (u16) (msg[index_msg].addr)); 1602 dib9000_write_word(state, 784, (u16) (msg[index_msg].addr));
1596 dib9000_write_word(state, 787, (len / 2) - 1); 1603 dib9000_write_word(state, 787, (len / 2) - 1);
@@ -1601,7 +1608,7 @@ static int dib9000_tuner_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msg[]
1601 i--; 1608 i--;
1602 1609
1603 if (i == 0) 1610 if (i == 0)
1604 dprintk("TunerITF: read failed"); 1611 dprintk("TunerITF: read failed\n");
1605 1612
1606 for (i = 0; i < len; i += 2) { 1613 for (i = 0; i < len; i += 2) {
1607 t = dib9000_read_word(state, 785); 1614 t = dib9000_read_word(state, 785);
@@ -1609,13 +1616,13 @@ static int dib9000_tuner_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msg[]
1609 msg[index_msg].buf[i + 1] = (t) & 0xff; 1616 msg[index_msg].buf[i + 1] = (t) & 0xff;
1610 } 1617 }
1611 if (dib9000_read_word(state, 790) != 0) 1618 if (dib9000_read_word(state, 790) != 0)
1612 dprintk("TunerITF: read more data than expected"); 1619 dprintk("TunerITF: read more data than expected\n");
1613 } else { 1620 } else {
1614 i = 1000; 1621 i = 1000;
1615 while (dib9000_read_word(state, 789) && i) 1622 while (dib9000_read_word(state, 789) && i)
1616 i--; 1623 i--;
1617 if (i == 0) 1624 if (i == 0)
1618 dprintk("TunerITF: write busy"); 1625 dprintk("TunerITF: write busy\n");
1619 1626
1620 len = msg[index_msg].len; 1627 len = msg[index_msg].len;
1621 if (len > 16) 1628 if (len > 16)
@@ -1631,7 +1638,7 @@ static int dib9000_tuner_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msg[]
1631 while (dib9000_read_word(state, 791) > 0 && i) 1638 while (dib9000_read_word(state, 791) > 0 && i)
1632 i--; 1639 i--;
1633 if (i == 0) 1640 if (i == 0)
1634 dprintk("TunerITF: write failed"); 1641 dprintk("TunerITF: write failed\n");
1635 } 1642 }
1636 } 1643 }
1637 return num; 1644 return num;
@@ -1676,7 +1683,7 @@ static int dib9000_fw_component_bus_xfer(struct i2c_adapter *i2c_adap, struct i2
1676 } 1683 }
1677 1684
1678 if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) { 1685 if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) {
1679 dprintk("could not get the lock"); 1686 dprintk("could not get the lock\n");
1680 return 0; 1687 return 0;
1681 } 1688 }
1682 1689
@@ -1759,7 +1766,7 @@ static int dib9000_cfg_gpio(struct dib9000_state *st, u8 num, u8 dir, u8 val)
1759 st->gpio_val |= (val & 0x01) << num; /* set the new value */ 1766 st->gpio_val |= (val & 0x01) << num; /* set the new value */
1760 dib9000_write_word(st, 774, st->gpio_val); 1767 dib9000_write_word(st, 774, st->gpio_val);
1761 1768
1762 dprintk("gpio dir: %04x: gpio val: %04x", st->gpio_dir, st->gpio_val); 1769 dprintk("gpio dir: %04x: gpio val: %04x\n", st->gpio_dir, st->gpio_val);
1763 1770
1764 return 0; 1771 return 0;
1765} 1772}
@@ -1779,7 +1786,7 @@ int dib9000_fw_pid_filter_ctrl(struct dvb_frontend *fe, u8 onoff)
1779 1786
1780 if ((state->pid_ctrl_index != -2) && (state->pid_ctrl_index < 9)) { 1787 if ((state->pid_ctrl_index != -2) && (state->pid_ctrl_index < 9)) {
1781 /* postpone the pid filtering cmd */ 1788 /* postpone the pid filtering cmd */
1782 dprintk("pid filter cmd postpone"); 1789 dprintk("pid filter cmd postpone\n");
1783 state->pid_ctrl_index++; 1790 state->pid_ctrl_index++;
1784 state->pid_ctrl[state->pid_ctrl_index].cmd = DIB9000_PID_FILTER_CTRL; 1791 state->pid_ctrl[state->pid_ctrl_index].cmd = DIB9000_PID_FILTER_CTRL;
1785 state->pid_ctrl[state->pid_ctrl_index].onoff = onoff; 1792 state->pid_ctrl[state->pid_ctrl_index].onoff = onoff;
@@ -1787,14 +1794,14 @@ int dib9000_fw_pid_filter_ctrl(struct dvb_frontend *fe, u8 onoff)
1787 } 1794 }
1788 1795
1789 if (mutex_lock_interruptible(&state->demod_lock) < 0) { 1796 if (mutex_lock_interruptible(&state->demod_lock) < 0) {
1790 dprintk("could not get the lock"); 1797 dprintk("could not get the lock\n");
1791 return -EINTR; 1798 return -EINTR;
1792 } 1799 }
1793 1800
1794 val = dib9000_read_word(state, 294 + 1) & 0xffef; 1801 val = dib9000_read_word(state, 294 + 1) & 0xffef;
1795 val |= (onoff & 0x1) << 4; 1802 val |= (onoff & 0x1) << 4;
1796 1803
1797 dprintk("PID filter enabled %d", onoff); 1804 dprintk("PID filter enabled %d\n", onoff);
1798 ret = dib9000_write_word(state, 294 + 1, val); 1805 ret = dib9000_write_word(state, 294 + 1, val);
1799 mutex_unlock(&state->demod_lock); 1806 mutex_unlock(&state->demod_lock);
1800 return ret; 1807 return ret;
@@ -1809,7 +1816,7 @@ int dib9000_fw_pid_filter(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff)
1809 1816
1810 if (state->pid_ctrl_index != -2) { 1817 if (state->pid_ctrl_index != -2) {
1811 /* postpone the pid filtering cmd */ 1818 /* postpone the pid filtering cmd */
1812 dprintk("pid filter postpone"); 1819 dprintk("pid filter postpone\n");
1813 if (state->pid_ctrl_index < 9) { 1820 if (state->pid_ctrl_index < 9) {
1814 state->pid_ctrl_index++; 1821 state->pid_ctrl_index++;
1815 state->pid_ctrl[state->pid_ctrl_index].cmd = DIB9000_PID_FILTER; 1822 state->pid_ctrl[state->pid_ctrl_index].cmd = DIB9000_PID_FILTER;
@@ -1817,15 +1824,15 @@ int dib9000_fw_pid_filter(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff)
1817 state->pid_ctrl[state->pid_ctrl_index].pid = pid; 1824 state->pid_ctrl[state->pid_ctrl_index].pid = pid;
1818 state->pid_ctrl[state->pid_ctrl_index].onoff = onoff; 1825 state->pid_ctrl[state->pid_ctrl_index].onoff = onoff;
1819 } else 1826 } else
1820 dprintk("can not add any more pid ctrl cmd"); 1827 dprintk("can not add any more pid ctrl cmd\n");
1821 return 0; 1828 return 0;
1822 } 1829 }
1823 1830
1824 if (mutex_lock_interruptible(&state->demod_lock) < 0) { 1831 if (mutex_lock_interruptible(&state->demod_lock) < 0) {
1825 dprintk("could not get the lock"); 1832 dprintk("could not get the lock\n");
1826 return -EINTR; 1833 return -EINTR;
1827 } 1834 }
1828 dprintk("Index %x, PID %d, OnOff %d", id, pid, onoff); 1835 dprintk("Index %x, PID %d, OnOff %d\n", id, pid, onoff);
1829 ret = dib9000_write_word(state, 300 + 1 + id, 1836 ret = dib9000_write_word(state, 300 + 1 + id,
1830 onoff ? (1 << 13) | pid : 0); 1837 onoff ? (1 << 13) | pid : 0);
1831 mutex_unlock(&state->demod_lock); 1838 mutex_unlock(&state->demod_lock);
@@ -1868,7 +1875,7 @@ static int dib9000_sleep(struct dvb_frontend *fe)
1868 int ret = 0; 1875 int ret = 0;
1869 1876
1870 if (mutex_lock_interruptible(&state->demod_lock) < 0) { 1877 if (mutex_lock_interruptible(&state->demod_lock) < 0) {
1871 dprintk("could not get the lock"); 1878 dprintk("could not get the lock\n");
1872 return -EINTR; 1879 return -EINTR;
1873 } 1880 }
1874 for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { 1881 for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) {
@@ -1899,7 +1906,7 @@ static int dib9000_get_frontend(struct dvb_frontend *fe,
1899 1906
1900 if (state->get_frontend_internal == 0) { 1907 if (state->get_frontend_internal == 0) {
1901 if (mutex_lock_interruptible(&state->demod_lock) < 0) { 1908 if (mutex_lock_interruptible(&state->demod_lock) < 0) {
1902 dprintk("could not get the lock"); 1909 dprintk("could not get the lock\n");
1903 return -EINTR; 1910 return -EINTR;
1904 } 1911 }
1905 } 1912 }
@@ -1907,7 +1914,7 @@ static int dib9000_get_frontend(struct dvb_frontend *fe,
1907 for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { 1914 for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) {
1908 state->fe[index_frontend]->ops.read_status(state->fe[index_frontend], &stat); 1915 state->fe[index_frontend]->ops.read_status(state->fe[index_frontend], &stat);
1909 if (stat & FE_HAS_SYNC) { 1916 if (stat & FE_HAS_SYNC) {
1910 dprintk("TPS lock on the slave%i", index_frontend); 1917 dprintk("TPS lock on the slave%i\n", index_frontend);
1911 1918
1912 /* synchronize the cache with the other frontends */ 1919 /* synchronize the cache with the other frontends */
1913 state->fe[index_frontend]->ops.get_frontend(state->fe[index_frontend], c); 1920 state->fe[index_frontend]->ops.get_frontend(state->fe[index_frontend], c);
@@ -1995,18 +2002,18 @@ static int dib9000_set_frontend(struct dvb_frontend *fe)
1995 2002
1996 /* check that the correct parameters are set */ 2003 /* check that the correct parameters are set */
1997 if (state->fe[0]->dtv_property_cache.frequency == 0) { 2004 if (state->fe[0]->dtv_property_cache.frequency == 0) {
1998 dprintk("dib9000: must specify frequency "); 2005 dprintk("dib9000: must specify frequency\n");
1999 return 0; 2006 return 0;
2000 } 2007 }
2001 2008
2002 if (state->fe[0]->dtv_property_cache.bandwidth_hz == 0) { 2009 if (state->fe[0]->dtv_property_cache.bandwidth_hz == 0) {
2003 dprintk("dib9000: must specify bandwidth "); 2010 dprintk("dib9000: must specify bandwidth\n");
2004 return 0; 2011 return 0;
2005 } 2012 }
2006 2013
2007 state->pid_ctrl_index = -1; /* postpone the pid filtering cmd */ 2014 state->pid_ctrl_index = -1; /* postpone the pid filtering cmd */
2008 if (mutex_lock_interruptible(&state->demod_lock) < 0) { 2015 if (mutex_lock_interruptible(&state->demod_lock) < 0) {
2009 dprintk("could not get the lock"); 2016 dprintk("could not get the lock\n");
2010 return 0; 2017 return 0;
2011 } 2018 }
2012 2019
@@ -2073,14 +2080,14 @@ static int dib9000_set_frontend(struct dvb_frontend *fe)
2073 2080
2074 /* check the tune result */ 2081 /* check the tune result */
2075 if (exit_condition == 1) { /* tune failed */ 2082 if (exit_condition == 1) { /* tune failed */
2076 dprintk("tune failed"); 2083 dprintk("tune failed\n");
2077 mutex_unlock(&state->demod_lock); 2084 mutex_unlock(&state->demod_lock);
2078 /* tune failed; put all the pid filtering cmd to junk */ 2085 /* tune failed; put all the pid filtering cmd to junk */
2079 state->pid_ctrl_index = -1; 2086 state->pid_ctrl_index = -1;
2080 return 0; 2087 return 0;
2081 } 2088 }
2082 2089
2083 dprintk("tune success on frontend%i", index_frontend_success); 2090 dprintk("tune success on frontend%i\n", index_frontend_success);
2084 2091
2085 /* synchronize all the channel cache */ 2092 /* synchronize all the channel cache */
2086 state->get_frontend_internal = 1; 2093 state->get_frontend_internal = 1;
@@ -2169,7 +2176,7 @@ static int dib9000_read_status(struct dvb_frontend *fe, enum fe_status *stat)
2169 u16 lock = 0, lock_slave = 0; 2176 u16 lock = 0, lock_slave = 0;
2170 2177
2171 if (mutex_lock_interruptible(&state->demod_lock) < 0) { 2178 if (mutex_lock_interruptible(&state->demod_lock) < 0) {
2172 dprintk("could not get the lock"); 2179 dprintk("could not get the lock\n");
2173 return -EINTR; 2180 return -EINTR;
2174 } 2181 }
2175 for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) 2182 for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++)
@@ -2202,11 +2209,11 @@ static int dib9000_read_ber(struct dvb_frontend *fe, u32 * ber)
2202 int ret = 0; 2209 int ret = 0;
2203 2210
2204 if (mutex_lock_interruptible(&state->demod_lock) < 0) { 2211 if (mutex_lock_interruptible(&state->demod_lock) < 0) {
2205 dprintk("could not get the lock"); 2212 dprintk("could not get the lock\n");
2206 return -EINTR; 2213 return -EINTR;
2207 } 2214 }
2208 if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) { 2215 if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) {
2209 dprintk("could not get the lock"); 2216 dprintk("could not get the lock\n");
2210 ret = -EINTR; 2217 ret = -EINTR;
2211 goto error; 2218 goto error;
2212 } 2219 }
@@ -2237,7 +2244,7 @@ static int dib9000_read_signal_strength(struct dvb_frontend *fe, u16 * strength)
2237 int ret = 0; 2244 int ret = 0;
2238 2245
2239 if (mutex_lock_interruptible(&state->demod_lock) < 0) { 2246 if (mutex_lock_interruptible(&state->demod_lock) < 0) {
2240 dprintk("could not get the lock"); 2247 dprintk("could not get the lock\n");
2241 return -EINTR; 2248 return -EINTR;
2242 } 2249 }
2243 *strength = 0; 2250 *strength = 0;
@@ -2250,7 +2257,7 @@ static int dib9000_read_signal_strength(struct dvb_frontend *fe, u16 * strength)
2250 } 2257 }
2251 2258
2252 if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) { 2259 if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) {
2253 dprintk("could not get the lock"); 2260 dprintk("could not get the lock\n");
2254 ret = -EINTR; 2261 ret = -EINTR;
2255 goto error; 2262 goto error;
2256 } 2263 }
@@ -2281,7 +2288,7 @@ static u32 dib9000_get_snr(struct dvb_frontend *fe)
2281 u16 val; 2288 u16 val;
2282 2289
2283 if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) { 2290 if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) {
2284 dprintk("could not get the lock"); 2291 dprintk("could not get the lock\n");
2285 return 0; 2292 return 0;
2286 } 2293 }
2287 if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0) { 2294 if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0) {
@@ -2320,7 +2327,7 @@ static int dib9000_read_snr(struct dvb_frontend *fe, u16 * snr)
2320 u32 snr_master; 2327 u32 snr_master;
2321 2328
2322 if (mutex_lock_interruptible(&state->demod_lock) < 0) { 2329 if (mutex_lock_interruptible(&state->demod_lock) < 0) {
2323 dprintk("could not get the lock"); 2330 dprintk("could not get the lock\n");
2324 return -EINTR; 2331 return -EINTR;
2325 } 2332 }
2326 snr_master = dib9000_get_snr(fe); 2333 snr_master = dib9000_get_snr(fe);
@@ -2345,11 +2352,11 @@ static int dib9000_read_unc_blocks(struct dvb_frontend *fe, u32 * unc)
2345 int ret = 0; 2352 int ret = 0;
2346 2353
2347 if (mutex_lock_interruptible(&state->demod_lock) < 0) { 2354 if (mutex_lock_interruptible(&state->demod_lock) < 0) {
2348 dprintk("could not get the lock"); 2355 dprintk("could not get the lock\n");
2349 return -EINTR; 2356 return -EINTR;
2350 } 2357 }
2351 if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) { 2358 if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) {
2352 dprintk("could not get the lock"); 2359 dprintk("could not get the lock\n");
2353 ret = -EINTR; 2360 ret = -EINTR;
2354 goto error; 2361 goto error;
2355 } 2362 }
@@ -2376,12 +2383,12 @@ int dib9000_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 defaul
2376 2383
2377 client.i2c_write_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL); 2384 client.i2c_write_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL);
2378 if (!client.i2c_write_buffer) { 2385 if (!client.i2c_write_buffer) {
2379 dprintk("%s: not enough memory", __func__); 2386 dprintk("%s: not enough memory\n", __func__);
2380 return -ENOMEM; 2387 return -ENOMEM;
2381 } 2388 }
2382 client.i2c_read_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL); 2389 client.i2c_read_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL);
2383 if (!client.i2c_read_buffer) { 2390 if (!client.i2c_read_buffer) {
2384 dprintk("%s: not enough memory", __func__); 2391 dprintk("%s: not enough memory\n", __func__);
2385 ret = -ENOMEM; 2392 ret = -ENOMEM;
2386 goto error_memory; 2393 goto error_memory;
2387 } 2394 }
@@ -2408,7 +2415,7 @@ int dib9000_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 defaul
2408 if (dib9000_identify(&client) == 0) { 2415 if (dib9000_identify(&client) == 0) {
2409 client.i2c_addr = default_addr; 2416 client.i2c_addr = default_addr;
2410 if (dib9000_identify(&client) == 0) { 2417 if (dib9000_identify(&client) == 0) {
2411 dprintk("DiB9000 #%d: not identified", k); 2418 dprintk("DiB9000 #%d: not identified\n", k);
2412 ret = -EIO; 2419 ret = -EIO;
2413 goto error; 2420 goto error;
2414 } 2421 }
@@ -2417,7 +2424,7 @@ int dib9000_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 defaul
2417 dib9000_i2c_write16(&client, 1795, (1 << 10) | (4 << 6)); 2424 dib9000_i2c_write16(&client, 1795, (1 << 10) | (4 << 6));
2418 dib9000_i2c_write16(&client, 1794, (new_addr << 2) | 2); 2425 dib9000_i2c_write16(&client, 1794, (new_addr << 2) | 2);
2419 2426
2420 dprintk("IC %d initialized (to i2c_address 0x%x)", k, new_addr); 2427 dprintk("IC %d initialized (to i2c_address 0x%x)\n", k, new_addr);
2421 } 2428 }
2422 2429
2423 for (k = 0; k < no_of_demods; k++) { 2430 for (k = 0; k < no_of_demods; k++) {
@@ -2445,12 +2452,12 @@ int dib9000_set_slave_frontend(struct dvb_frontend *fe, struct dvb_frontend *fe_
2445 while ((index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL)) 2452 while ((index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL))
2446 index_frontend++; 2453 index_frontend++;
2447 if (index_frontend < MAX_NUMBER_OF_FRONTENDS) { 2454 if (index_frontend < MAX_NUMBER_OF_FRONTENDS) {
2448 dprintk("set slave fe %p to index %i", fe_slave, index_frontend); 2455 dprintk("set slave fe %p to index %i\n", fe_slave, index_frontend);
2449 state->fe[index_frontend] = fe_slave; 2456 state->fe[index_frontend] = fe_slave;
2450 return 0; 2457 return 0;
2451 } 2458 }
2452 2459
2453 dprintk("too many slave frontend"); 2460 dprintk("too many slave frontend\n");
2454 return -ENOMEM; 2461 return -ENOMEM;
2455} 2462}
2456EXPORT_SYMBOL(dib9000_set_slave_frontend); 2463EXPORT_SYMBOL(dib9000_set_slave_frontend);
@@ -2463,12 +2470,12 @@ int dib9000_remove_slave_frontend(struct dvb_frontend *fe)
2463 while ((index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL)) 2470 while ((index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL))
2464 index_frontend++; 2471 index_frontend++;
2465 if (index_frontend != 1) { 2472 if (index_frontend != 1) {
2466 dprintk("remove slave fe %p (index %i)", state->fe[index_frontend - 1], index_frontend - 1); 2473 dprintk("remove slave fe %p (index %i)\n", state->fe[index_frontend - 1], index_frontend - 1);
2467 state->fe[index_frontend] = NULL; 2474 state->fe[index_frontend] = NULL;
2468 return 0; 2475 return 0;
2469 } 2476 }
2470 2477
2471 dprintk("no frontend to be removed"); 2478 dprintk("no frontend to be removed\n");
2472 return -ENODEV; 2479 return -ENODEV;
2473} 2480}
2474EXPORT_SYMBOL(dib9000_remove_slave_frontend); 2481EXPORT_SYMBOL(dib9000_remove_slave_frontend);
@@ -2483,7 +2490,7 @@ struct dvb_frontend *dib9000_get_slave_frontend(struct dvb_frontend *fe, int sla
2483} 2490}
2484EXPORT_SYMBOL(dib9000_get_slave_frontend); 2491EXPORT_SYMBOL(dib9000_get_slave_frontend);
2485 2492
2486static struct dvb_frontend_ops dib9000_ops; 2493static const struct dvb_frontend_ops dib9000_ops;
2487struct dvb_frontend *dib9000_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, const struct dib9000_config *cfg) 2494struct dvb_frontend *dib9000_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, const struct dib9000_config *cfg)
2488{ 2495{
2489 struct dvb_frontend *fe; 2496 struct dvb_frontend *fe;
@@ -2560,7 +2567,7 @@ error:
2560} 2567}
2561EXPORT_SYMBOL(dib9000_attach); 2568EXPORT_SYMBOL(dib9000_attach);
2562 2569
2563static struct dvb_frontend_ops dib9000_ops = { 2570static const struct dvb_frontend_ops dib9000_ops = {
2564 .delsys = { SYS_DVBT }, 2571 .delsys = { SYS_DVBT },
2565 .info = { 2572 .info = {
2566 .name = "DiBcom 9000", 2573 .name = "DiBcom 9000",
diff --git a/drivers/media/dvb-frontends/dibx000_common.c b/drivers/media/dvb-frontends/dibx000_common.c
index 723358d7ca84..bc28184c7fb0 100644
--- a/drivers/media/dvb-frontends/dibx000_common.c
+++ b/drivers/media/dvb-frontends/dibx000_common.c
@@ -1,3 +1,5 @@
1#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
2
1#include <linux/i2c.h> 3#include <linux/i2c.h>
2#include <linux/mutex.h> 4#include <linux/mutex.h>
3#include <linux/module.h> 5#include <linux/module.h>
@@ -8,14 +10,18 @@ static int debug;
8module_param(debug, int, 0644); 10module_param(debug, int, 0644);
9MODULE_PARM_DESC(debug, "turn on debugging (default: 0)"); 11MODULE_PARM_DESC(debug, "turn on debugging (default: 0)");
10 12
11#define dprintk(args...) do { if (debug) { printk(KERN_DEBUG "DiBX000: "); printk(args); printk("\n"); } } while (0) 13#define dprintk(fmt, arg...) do { \
14 if (debug) \
15 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
16 __func__, ##arg); \
17} while (0)
12 18
13static int dibx000_write_word(struct dibx000_i2c_master *mst, u16 reg, u16 val) 19static int dibx000_write_word(struct dibx000_i2c_master *mst, u16 reg, u16 val)
14{ 20{
15 int ret; 21 int ret;
16 22
17 if (mutex_lock_interruptible(&mst->i2c_buffer_lock) < 0) { 23 if (mutex_lock_interruptible(&mst->i2c_buffer_lock) < 0) {
18 dprintk("could not acquire lock"); 24 dprintk("could not acquire lock\n");
19 return -EINVAL; 25 return -EINVAL;
20 } 26 }
21 27
@@ -41,7 +47,7 @@ static u16 dibx000_read_word(struct dibx000_i2c_master *mst, u16 reg)
41 u16 ret; 47 u16 ret;
42 48
43 if (mutex_lock_interruptible(&mst->i2c_buffer_lock) < 0) { 49 if (mutex_lock_interruptible(&mst->i2c_buffer_lock) < 0) {
44 dprintk("could not acquire lock"); 50 dprintk("could not acquire lock\n");
45 return 0; 51 return 0;
46 } 52 }
47 53
@@ -59,7 +65,7 @@ static u16 dibx000_read_word(struct dibx000_i2c_master *mst, u16 reg)
59 mst->msg[1].len = 2; 65 mst->msg[1].len = 2;
60 66
61 if (i2c_transfer(mst->i2c_adap, mst->msg, 2) != 2) 67 if (i2c_transfer(mst->i2c_adap, mst->msg, 2) != 2)
62 dprintk("i2c read error on %d", reg); 68 dprintk("i2c read error on %d\n", reg);
63 69
64 ret = (mst->i2c_read_buffer[0] << 8) | mst->i2c_read_buffer[1]; 70 ret = (mst->i2c_read_buffer[0] << 8) | mst->i2c_read_buffer[1];
65 mutex_unlock(&mst->i2c_buffer_lock); 71 mutex_unlock(&mst->i2c_buffer_lock);
@@ -192,7 +198,7 @@ static int dibx000_i2c_select_interface(struct dibx000_i2c_master *mst,
192 enum dibx000_i2c_interface intf) 198 enum dibx000_i2c_interface intf)
193{ 199{
194 if (mst->device_rev > DIB3000MC && mst->selected_interface != intf) { 200 if (mst->device_rev > DIB3000MC && mst->selected_interface != intf) {
195 dprintk("selecting interface: %d", intf); 201 dprintk("selecting interface: %d\n", intf);
196 mst->selected_interface = intf; 202 mst->selected_interface = intf;
197 return dibx000_write_word(mst, mst->base_reg + 4, intf); 203 return dibx000_write_word(mst, mst->base_reg + 4, intf);
198 } 204 }
@@ -290,7 +296,7 @@ static int dibx000_i2c_gated_gpio67_xfer(struct i2c_adapter *i2c_adap,
290 dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_GPIO_6_7); 296 dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_GPIO_6_7);
291 297
292 if (mutex_lock_interruptible(&mst->i2c_buffer_lock) < 0) { 298 if (mutex_lock_interruptible(&mst->i2c_buffer_lock) < 0) {
293 dprintk("could not acquire lock"); 299 dprintk("could not acquire lock\n");
294 return -EINVAL; 300 return -EINVAL;
295 } 301 }
296 302
@@ -337,7 +343,7 @@ static int dibx000_i2c_gated_tuner_xfer(struct i2c_adapter *i2c_adap,
337 dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_TUNER); 343 dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_TUNER);
338 344
339 if (mutex_lock_interruptible(&mst->i2c_buffer_lock) < 0) { 345 if (mutex_lock_interruptible(&mst->i2c_buffer_lock) < 0) {
340 dprintk("could not acquire lock"); 346 dprintk("could not acquire lock\n");
341 return -EINVAL; 347 return -EINVAL;
342 } 348 }
343 memset(mst->msg, 0, sizeof(struct i2c_msg) * (2 + num)); 349 memset(mst->msg, 0, sizeof(struct i2c_msg) * (2 + num));
@@ -391,7 +397,7 @@ struct i2c_adapter *dibx000_get_i2c_adapter(struct dibx000_i2c_master *mst,
391 i2c = &mst->master_i2c_adap_gpio67; 397 i2c = &mst->master_i2c_adap_gpio67;
392 break; 398 break;
393 default: 399 default:
394 printk(KERN_ERR "DiBX000: incorrect I2C interface selected\n"); 400 pr_err("incorrect I2C interface selected\n");
395 break; 401 break;
396 } 402 }
397 403
@@ -434,7 +440,7 @@ int dibx000_init_i2c_master(struct dibx000_i2c_master *mst, u16 device_rev,
434 440
435 mutex_init(&mst->i2c_buffer_lock); 441 mutex_init(&mst->i2c_buffer_lock);
436 if (mutex_lock_interruptible(&mst->i2c_buffer_lock) < 0) { 442 if (mutex_lock_interruptible(&mst->i2c_buffer_lock) < 0) {
437 dprintk("could not acquire lock"); 443 dprintk("could not acquire lock\n");
438 return -EINVAL; 444 return -EINVAL;
439 } 445 }
440 memset(mst->msg, 0, sizeof(struct i2c_msg)); 446 memset(mst->msg, 0, sizeof(struct i2c_msg));
@@ -456,29 +462,25 @@ int dibx000_init_i2c_master(struct dibx000_i2c_master *mst, u16 device_rev,
456 if (i2c_adapter_init 462 if (i2c_adapter_init
457 (&mst->gated_tuner_i2c_adap, &dibx000_i2c_gated_tuner_algo, 463 (&mst->gated_tuner_i2c_adap, &dibx000_i2c_gated_tuner_algo,
458 "DiBX000 tuner I2C bus", mst) != 0) 464 "DiBX000 tuner I2C bus", mst) != 0)
459 printk(KERN_ERR 465 pr_err("could not initialize the tuner i2c_adapter\n");
460 "DiBX000: could not initialize the tuner i2c_adapter\n");
461 466
462 mst->master_i2c_adap_gpio12.dev.parent = mst->i2c_adap->dev.parent; 467 mst->master_i2c_adap_gpio12.dev.parent = mst->i2c_adap->dev.parent;
463 if (i2c_adapter_init 468 if (i2c_adapter_init
464 (&mst->master_i2c_adap_gpio12, &dibx000_i2c_master_gpio12_xfer_algo, 469 (&mst->master_i2c_adap_gpio12, &dibx000_i2c_master_gpio12_xfer_algo,
465 "DiBX000 master GPIO12 I2C bus", mst) != 0) 470 "DiBX000 master GPIO12 I2C bus", mst) != 0)
466 printk(KERN_ERR 471 pr_err("could not initialize the master i2c_adapter\n");
467 "DiBX000: could not initialize the master i2c_adapter\n");
468 472
469 mst->master_i2c_adap_gpio34.dev.parent = mst->i2c_adap->dev.parent; 473 mst->master_i2c_adap_gpio34.dev.parent = mst->i2c_adap->dev.parent;
470 if (i2c_adapter_init 474 if (i2c_adapter_init
471 (&mst->master_i2c_adap_gpio34, &dibx000_i2c_master_gpio34_xfer_algo, 475 (&mst->master_i2c_adap_gpio34, &dibx000_i2c_master_gpio34_xfer_algo,
472 "DiBX000 master GPIO34 I2C bus", mst) != 0) 476 "DiBX000 master GPIO34 I2C bus", mst) != 0)
473 printk(KERN_ERR 477 pr_err("could not initialize the master i2c_adapter\n");
474 "DiBX000: could not initialize the master i2c_adapter\n");
475 478
476 mst->master_i2c_adap_gpio67.dev.parent = mst->i2c_adap->dev.parent; 479 mst->master_i2c_adap_gpio67.dev.parent = mst->i2c_adap->dev.parent;
477 if (i2c_adapter_init 480 if (i2c_adapter_init
478 (&mst->master_i2c_adap_gpio67, &dibx000_i2c_gated_gpio67_algo, 481 (&mst->master_i2c_adap_gpio67, &dibx000_i2c_gated_gpio67_algo,
479 "DiBX000 master GPIO67 I2C bus", mst) != 0) 482 "DiBX000 master GPIO67 I2C bus", mst) != 0)
480 printk(KERN_ERR 483 pr_err("could not initialize the master i2c_adapter\n");
481 "DiBX000: could not initialize the master i2c_adapter\n");
482 484
483 /* initialize the i2c-master by closing the gate */ 485 /* initialize the i2c-master by closing the gate */
484 dibx000_i2c_gate_ctrl(mst, mst->i2c_write_buffer, 0, 0); 486 dibx000_i2c_gate_ctrl(mst, mst->i2c_write_buffer, 0, 0);
@@ -500,16 +502,6 @@ void dibx000_exit_i2c_master(struct dibx000_i2c_master *mst)
500} 502}
501EXPORT_SYMBOL(dibx000_exit_i2c_master); 503EXPORT_SYMBOL(dibx000_exit_i2c_master);
502 504
503
504u32 systime(void)
505{
506 struct timespec t;
507
508 t = current_kernel_time();
509 return (t.tv_sec * 10000) + (t.tv_nsec / 100000);
510}
511EXPORT_SYMBOL(systime);
512
513MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>"); 505MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
514MODULE_DESCRIPTION("Common function the DiBcom demodulator family"); 506MODULE_DESCRIPTION("Common function the DiBcom demodulator family");
515MODULE_LICENSE("GPL"); 507MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/dibx000_common.h b/drivers/media/dvb-frontends/dibx000_common.h
index b538e0555c95..61f4152f24ee 100644
--- a/drivers/media/dvb-frontends/dibx000_common.h
+++ b/drivers/media/dvb-frontends/dibx000_common.h
@@ -47,8 +47,6 @@ extern void dibx000_exit_i2c_master(struct dibx000_i2c_master *mst);
47extern void dibx000_reset_i2c_master(struct dibx000_i2c_master *mst); 47extern void dibx000_reset_i2c_master(struct dibx000_i2c_master *mst);
48extern int dibx000_i2c_set_speed(struct i2c_adapter *i2c_adap, u16 speed); 48extern int dibx000_i2c_set_speed(struct i2c_adapter *i2c_adap, u16 speed);
49 49
50extern u32 systime(void);
51
52#define BAND_LBAND 0x01 50#define BAND_LBAND 0x01
53#define BAND_UHF 0x02 51#define BAND_UHF 0x02
54#define BAND_VHF 0x04 52#define BAND_VHF 0x04
diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c
index bd6d2ee0f7c9..f1c3e3b09b65 100644
--- a/drivers/media/dvb-frontends/drx39xyj/drxj.c
+++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
@@ -12264,7 +12264,7 @@ static void drx39xxj_release(struct dvb_frontend *fe)
12264 kfree(state); 12264 kfree(state);
12265} 12265}
12266 12266
12267static struct dvb_frontend_ops drx39xxj_ops; 12267static const struct dvb_frontend_ops drx39xxj_ops;
12268 12268
12269struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c) 12269struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c)
12270{ 12270{
@@ -12363,7 +12363,7 @@ error:
12363} 12363}
12364EXPORT_SYMBOL(drx39xxj_attach); 12364EXPORT_SYMBOL(drx39xxj_attach);
12365 12365
12366static struct dvb_frontend_ops drx39xxj_ops = { 12366static const struct dvb_frontend_ops drx39xxj_ops = {
12367 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B }, 12367 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
12368 .info = { 12368 .info = {
12369 .name = "Micronas DRX39xxj family Frontend", 12369 .name = "Micronas DRX39xxj family Frontend",
diff --git a/drivers/media/dvb-frontends/drxd_hard.c b/drivers/media/dvb-frontends/drxd_hard.c
index 445a15c2714f..4143f0326684 100644
--- a/drivers/media/dvb-frontends/drxd_hard.c
+++ b/drivers/media/dvb-frontends/drxd_hard.c
@@ -2912,7 +2912,7 @@ static void drxd_release(struct dvb_frontend *fe)
2912 kfree(state); 2912 kfree(state);
2913} 2913}
2914 2914
2915static struct dvb_frontend_ops drxd_ops = { 2915static const struct dvb_frontend_ops drxd_ops = {
2916 .delsys = { SYS_DVBT}, 2916 .delsys = { SYS_DVBT},
2917 .info = { 2917 .info = {
2918 .name = "Micronas DRXD DVB-T", 2918 .name = "Micronas DRXD DVB-T",
diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c
index c595adc61c6f..146edf344dd8 100644
--- a/drivers/media/dvb-frontends/drxk_hard.c
+++ b/drivers/media/dvb-frontends/drxk_hard.c
@@ -6737,7 +6737,7 @@ static int drxk_get_tune_settings(struct dvb_frontend *fe,
6737 } 6737 }
6738} 6738}
6739 6739
6740static struct dvb_frontend_ops drxk_ops = { 6740static const struct dvb_frontend_ops drxk_ops = {
6741 /* .delsys will be filled dynamically */ 6741 /* .delsys will be filled dynamically */
6742 .info = { 6742 .info = {
6743 .name = "DRXK", 6743 .name = "DRXK",
diff --git a/drivers/media/dvb-frontends/ds3000.c b/drivers/media/dvb-frontends/ds3000.c
index 447b518e287a..0b17a45c5640 100644
--- a/drivers/media/dvb-frontends/ds3000.c
+++ b/drivers/media/dvb-frontends/ds3000.c
@@ -248,8 +248,8 @@ static int ds3000_writereg(struct ds3000_state *state, int reg, int data)
248 248
249 err = i2c_transfer(state->i2c, &msg, 1); 249 err = i2c_transfer(state->i2c, &msg, 1);
250 if (err != 1) { 250 if (err != 1) {
251 printk(KERN_ERR "%s: writereg error(err == %i, reg == 0x%02x," 251 printk(KERN_ERR "%s: writereg error(err == %i, reg == 0x%02x, value == 0x%02x)\n",
252 " value == 0x%02x)\n", __func__, err, reg, data); 252 __func__, err, reg, data);
253 return -EREMOTEIO; 253 return -EREMOTEIO;
254 } 254 }
255 255
@@ -296,8 +296,8 @@ static int ds3000_writeFW(struct ds3000_state *state, int reg,
296 296
297 ret = i2c_transfer(state->i2c, &msg, 1); 297 ret = i2c_transfer(state->i2c, &msg, 1);
298 if (ret != 1) { 298 if (ret != 1) {
299 printk(KERN_ERR "%s: write error(err == %i, " 299 printk(KERN_ERR "%s: write error(err == %i, reg == 0x%02x\n",
300 "reg == 0x%02x\n", __func__, ret, reg); 300 __func__, ret, reg);
301 ret = -EREMOTEIO; 301 ret = -EREMOTEIO;
302 goto error; 302 goto error;
303 } 303 }
@@ -364,8 +364,8 @@ static int ds3000_firmware_ondemand(struct dvb_frontend *fe)
364 state->i2c->dev.parent); 364 state->i2c->dev.parent);
365 printk(KERN_INFO "%s: Waiting for firmware upload(2)...\n", __func__); 365 printk(KERN_INFO "%s: Waiting for firmware upload(2)...\n", __func__);
366 if (ret) { 366 if (ret) {
367 printk(KERN_ERR "%s: No firmware uploaded (timeout or file not " 367 printk(KERN_ERR "%s: No firmware uploaded (timeout or file not found?)\n",
368 "found?)\n", __func__); 368 __func__);
369 return ret; 369 return ret;
370 } 370 }
371 371
@@ -830,7 +830,7 @@ static void ds3000_release(struct dvb_frontend *fe)
830 kfree(state); 830 kfree(state);
831} 831}
832 832
833static struct dvb_frontend_ops ds3000_ops; 833static const struct dvb_frontend_ops ds3000_ops;
834 834
835struct dvb_frontend *ds3000_attach(const struct ds3000_config *config, 835struct dvb_frontend *ds3000_attach(const struct ds3000_config *config,
836 struct i2c_adapter *i2c) 836 struct i2c_adapter *i2c)
@@ -1104,7 +1104,7 @@ static int ds3000_initfe(struct dvb_frontend *fe)
1104 return 0; 1104 return 0;
1105} 1105}
1106 1106
1107static struct dvb_frontend_ops ds3000_ops = { 1107static const struct dvb_frontend_ops ds3000_ops = {
1108 .delsys = { SYS_DVBS, SYS_DVBS2 }, 1108 .delsys = { SYS_DVBS, SYS_DVBS2 },
1109 .info = { 1109 .info = {
1110 .name = "Montage Technology DS3000", 1110 .name = "Montage Technology DS3000",
@@ -1144,8 +1144,7 @@ static struct dvb_frontend_ops ds3000_ops = {
1144module_param(debug, int, 0644); 1144module_param(debug, int, 0644);
1145MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); 1145MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)");
1146 1146
1147MODULE_DESCRIPTION("DVB Frontend module for Montage Technology " 1147MODULE_DESCRIPTION("DVB Frontend module for Montage Technology DS3000 hardware");
1148 "DS3000 hardware");
1149MODULE_AUTHOR("Konstantin Dimitrov <kosio.dimitrov@gmail.com>"); 1148MODULE_AUTHOR("Konstantin Dimitrov <kosio.dimitrov@gmail.com>");
1150MODULE_LICENSE("GPL"); 1149MODULE_LICENSE("GPL");
1151MODULE_FIRMWARE(DS3000_DEFAULT_FIRMWARE); 1150MODULE_FIRMWARE(DS3000_DEFAULT_FIRMWARE);
diff --git a/drivers/media/dvb-frontends/dvb-pll.c b/drivers/media/dvb-frontends/dvb-pll.c
index 735a96662022..ef976eb23344 100644
--- a/drivers/media/dvb-frontends/dvb-pll.c
+++ b/drivers/media/dvb-frontends/dvb-pll.c
@@ -18,6 +18,8 @@
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 19 */
20 20
21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22
21#include <linux/slab.h> 23#include <linux/slab.h>
22#include <linux/module.h> 24#include <linux/module.h>
23#include <linux/dvb/frontend.h> 25#include <linux/dvb/frontend.h>
@@ -25,6 +27,9 @@
25 27
26#include "dvb-pll.h" 28#include "dvb-pll.h"
27 29
30#define dprintk(fmt, arg...) \
31 printk(KERN_DEBUG pr_fmt("%s: " fmt), __func__, ##arg)
32
28struct dvb_pll_priv { 33struct dvb_pll_priv {
29 /* pll number */ 34 /* pll number */
30 int nr; 35 int nr;
@@ -362,7 +367,7 @@ static void opera1_bw(struct dvb_frontend *fe, u8 *buf)
362 367
363 result = i2c_transfer(priv->i2c, &msg, 1); 368 result = i2c_transfer(priv->i2c, &msg, 1);
364 if (result != 1) 369 if (result != 1)
365 printk(KERN_ERR "%s: i2c_transfer failed:%d", 370 pr_err("%s: i2c_transfer failed:%d",
366 __func__, result); 371 __func__, result);
367 372
368 if (b_w <= 10000) 373 if (b_w <= 10000)
@@ -432,7 +437,7 @@ static void samsung_dtos403ih102a_set(struct dvb_frontend *fe, u8 *buf)
432 437
433 result = i2c_transfer(priv->i2c, &msg, 1); 438 result = i2c_transfer(priv->i2c, &msg, 1);
434 if (result != 1) 439 if (result != 1)
435 printk(KERN_ERR "%s: i2c_transfer failed:%d", 440 pr_err("%s: i2c_transfer failed:%d",
436 __func__, result); 441 __func__, result);
437 442
438 buf[2] = 0x9e; 443 buf[2] = 0x9e;
@@ -578,7 +583,7 @@ static int dvb_pll_configure(struct dvb_frontend *fe, u8 *buf,
578 } 583 }
579 584
580 if (debug) 585 if (debug)
581 printk("pll: %s: freq=%d | i=%d/%d\n", desc->name, 586 dprintk("pll: %s: freq=%d | i=%d/%d\n", desc->name,
582 frequency, i, desc->count); 587 frequency, i, desc->count);
583 if (i == desc->count) 588 if (i == desc->count)
584 return -EINVAL; 589 return -EINVAL;
@@ -594,18 +599,17 @@ static int dvb_pll_configure(struct dvb_frontend *fe, u8 *buf,
594 desc->set(fe, buf); 599 desc->set(fe, buf);
595 600
596 if (debug) 601 if (debug)
597 printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n", 602 dprintk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n",
598 desc->name, div, buf[0], buf[1], buf[2], buf[3]); 603 desc->name, div, buf[0], buf[1], buf[2], buf[3]);
599 604
600 // calculate the frequency we set it to 605 // calculate the frequency we set it to
601 return (div * desc->entries[i].stepsize) - desc->iffreq; 606 return (div * desc->entries[i].stepsize) - desc->iffreq;
602} 607}
603 608
604static int dvb_pll_release(struct dvb_frontend *fe) 609static void dvb_pll_release(struct dvb_frontend *fe)
605{ 610{
606 kfree(fe->tuner_priv); 611 kfree(fe->tuner_priv);
607 fe->tuner_priv = NULL; 612 fe->tuner_priv = NULL;
608 return 0;
609} 613}
610 614
611static int dvb_pll_sleep(struct dvb_frontend *fe) 615static int dvb_pll_sleep(struct dvb_frontend *fe)
@@ -803,10 +807,10 @@ struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr,
803 fe->tuner_priv = priv; 807 fe->tuner_priv = priv;
804 808
805 if ((debug) || (id[priv->nr] == pll_desc_id)) { 809 if ((debug) || (id[priv->nr] == pll_desc_id)) {
806 printk("dvb-pll[%d]", priv->nr); 810 dprintk("dvb-pll[%d]", priv->nr);
807 if (i2c != NULL) 811 if (i2c != NULL)
808 printk(" %d-%04x", i2c_adapter_id(i2c), pll_addr); 812 pr_cont(" %d-%04x", i2c_adapter_id(i2c), pll_addr);
809 printk(": id# %d (%s) attached, %s\n", pll_desc_id, desc->name, 813 pr_cont(": id# %d (%s) attached, %s\n", pll_desc_id, desc->name,
810 id[priv->nr] == pll_desc_id ? 814 id[priv->nr] == pll_desc_id ?
811 "insmod option" : "autodetected"); 815 "insmod option" : "autodetected");
812 } 816 }
diff --git a/drivers/media/dvb-frontends/dvb_dummy_fe.c b/drivers/media/dvb-frontends/dvb_dummy_fe.c
index e5bd8c62ad3a..efc3c31a7635 100644
--- a/drivers/media/dvb-frontends/dvb_dummy_fe.c
+++ b/drivers/media/dvb-frontends/dvb_dummy_fe.c
@@ -119,7 +119,7 @@ static void dvb_dummy_fe_release(struct dvb_frontend* fe)
119 kfree(state); 119 kfree(state);
120} 120}
121 121
122static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops; 122static const struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops;
123 123
124struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void) 124struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void)
125{ 125{
@@ -136,7 +136,7 @@ struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void)
136 return &state->frontend; 136 return &state->frontend;
137} 137}
138 138
139static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops; 139static const struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops;
140 140
141struct dvb_frontend *dvb_dummy_fe_qpsk_attach(void) 141struct dvb_frontend *dvb_dummy_fe_qpsk_attach(void)
142{ 142{
@@ -153,7 +153,7 @@ struct dvb_frontend *dvb_dummy_fe_qpsk_attach(void)
153 return &state->frontend; 153 return &state->frontend;
154} 154}
155 155
156static struct dvb_frontend_ops dvb_dummy_fe_qam_ops; 156static const struct dvb_frontend_ops dvb_dummy_fe_qam_ops;
157 157
158struct dvb_frontend *dvb_dummy_fe_qam_attach(void) 158struct dvb_frontend *dvb_dummy_fe_qam_attach(void)
159{ 159{
@@ -170,7 +170,7 @@ struct dvb_frontend *dvb_dummy_fe_qam_attach(void)
170 return &state->frontend; 170 return &state->frontend;
171} 171}
172 172
173static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = { 173static const struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = {
174 .delsys = { SYS_DVBT }, 174 .delsys = { SYS_DVBT },
175 .info = { 175 .info = {
176 .name = "Dummy DVB-T", 176 .name = "Dummy DVB-T",
@@ -201,7 +201,7 @@ static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = {
201 .read_ucblocks = dvb_dummy_fe_read_ucblocks, 201 .read_ucblocks = dvb_dummy_fe_read_ucblocks,
202}; 202};
203 203
204static struct dvb_frontend_ops dvb_dummy_fe_qam_ops = { 204static const struct dvb_frontend_ops dvb_dummy_fe_qam_ops = {
205 .delsys = { SYS_DVBC_ANNEX_A }, 205 .delsys = { SYS_DVBC_ANNEX_A },
206 .info = { 206 .info = {
207 .name = "Dummy DVB-C", 207 .name = "Dummy DVB-C",
@@ -230,7 +230,7 @@ static struct dvb_frontend_ops dvb_dummy_fe_qam_ops = {
230 .read_ucblocks = dvb_dummy_fe_read_ucblocks, 230 .read_ucblocks = dvb_dummy_fe_read_ucblocks,
231}; 231};
232 232
233static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops = { 233static const struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops = {
234 .delsys = { SYS_DVBS }, 234 .delsys = { SYS_DVBS },
235 .info = { 235 .info = {
236 .name = "Dummy DVB-S", 236 .name = "Dummy DVB-S",
diff --git a/drivers/media/dvb-frontends/ec100.c b/drivers/media/dvb-frontends/ec100.c
index c9012e677cd1..d97ce21e26e1 100644
--- a/drivers/media/dvb-frontends/ec100.c
+++ b/drivers/media/dvb-frontends/ec100.c
@@ -280,7 +280,7 @@ static void ec100_release(struct dvb_frontend *fe)
280 kfree(state); 280 kfree(state);
281} 281}
282 282
283static struct dvb_frontend_ops ec100_ops; 283static const struct dvb_frontend_ops ec100_ops;
284 284
285struct dvb_frontend *ec100_attach(const struct ec100_config *config, 285struct dvb_frontend *ec100_attach(const struct ec100_config *config,
286 struct i2c_adapter *i2c) 286 struct i2c_adapter *i2c)
@@ -315,7 +315,7 @@ error:
315} 315}
316EXPORT_SYMBOL(ec100_attach); 316EXPORT_SYMBOL(ec100_attach);
317 317
318static struct dvb_frontend_ops ec100_ops = { 318static const struct dvb_frontend_ops ec100_ops = {
319 .delsys = { SYS_DVBT }, 319 .delsys = { SYS_DVBT },
320 .info = { 320 .info = {
321 .name = "E3C EC100 DVB-T", 321 .name = "E3C EC100 DVB-T",
diff --git a/drivers/media/dvb-frontends/gp8psk-fe.c b/drivers/media/dvb-frontends/gp8psk-fe.c
index 93f59bfea092..efe015df7f1d 100644
--- a/drivers/media/dvb-frontends/gp8psk-fe.c
+++ b/drivers/media/dvb-frontends/gp8psk-fe.c
@@ -323,7 +323,7 @@ static void gp8psk_fe_release(struct dvb_frontend* fe)
323 kfree(st); 323 kfree(st);
324} 324}
325 325
326static struct dvb_frontend_ops gp8psk_fe_ops; 326static const struct dvb_frontend_ops gp8psk_fe_ops;
327 327
328struct dvb_frontend *gp8psk_fe_attach(const struct gp8psk_fe_ops *ops, 328struct dvb_frontend *gp8psk_fe_attach(const struct gp8psk_fe_ops *ops,
329 void *priv, bool is_rev1) 329 void *priv, bool is_rev1)
@@ -351,7 +351,7 @@ struct dvb_frontend *gp8psk_fe_attach(const struct gp8psk_fe_ops *ops,
351} 351}
352EXPORT_SYMBOL_GPL(gp8psk_fe_attach); 352EXPORT_SYMBOL_GPL(gp8psk_fe_attach);
353 353
354static struct dvb_frontend_ops gp8psk_fe_ops = { 354static const struct dvb_frontend_ops gp8psk_fe_ops = {
355 .delsys = { SYS_DVBS }, 355 .delsys = { SYS_DVBS },
356 .info = { 356 .info = {
357 .name = "Genpix DVB-S", 357 .name = "Genpix DVB-S",
diff --git a/drivers/media/dvb-frontends/hd29l2.c b/drivers/media/dvb-frontends/hd29l2.c
index 1c7eb477e2cd..8b53633cf325 100644
--- a/drivers/media/dvb-frontends/hd29l2.c
+++ b/drivers/media/dvb-frontends/hd29l2.c
@@ -793,7 +793,7 @@ static void hd29l2_release(struct dvb_frontend *fe)
793 kfree(priv); 793 kfree(priv);
794} 794}
795 795
796static struct dvb_frontend_ops hd29l2_ops; 796static const struct dvb_frontend_ops hd29l2_ops;
797 797
798struct dvb_frontend *hd29l2_attach(const struct hd29l2_config *config, 798struct dvb_frontend *hd29l2_attach(const struct hd29l2_config *config,
799 struct i2c_adapter *i2c) 799 struct i2c_adapter *i2c)
@@ -828,7 +828,7 @@ err:
828} 828}
829EXPORT_SYMBOL(hd29l2_attach); 829EXPORT_SYMBOL(hd29l2_attach);
830 830
831static struct dvb_frontend_ops hd29l2_ops = { 831static const struct dvb_frontend_ops hd29l2_ops = {
832 .delsys = { SYS_DVBT }, 832 .delsys = { SYS_DVBT },
833 .info = { 833 .info = {
834 .name = "HDIC HD29L2 DMB-TH", 834 .name = "HDIC HD29L2 DMB-TH",
diff --git a/drivers/media/dvb-frontends/helene.c b/drivers/media/dvb-frontends/helene.c
index dc43c5f6d0ea..ef35c2b30ea3 100644
--- a/drivers/media/dvb-frontends/helene.c
+++ b/drivers/media/dvb-frontends/helene.c
@@ -434,14 +434,13 @@ static int helene_init(struct dvb_frontend *fe)
434 return helene_leave_power_save(priv); 434 return helene_leave_power_save(priv);
435} 435}
436 436
437static int helene_release(struct dvb_frontend *fe) 437static void helene_release(struct dvb_frontend *fe)
438{ 438{
439 struct helene_priv *priv = fe->tuner_priv; 439 struct helene_priv *priv = fe->tuner_priv;
440 440
441 dev_dbg(&priv->i2c->dev, "%s()\n", __func__); 441 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
442 kfree(fe->tuner_priv); 442 kfree(fe->tuner_priv);
443 fe->tuner_priv = NULL; 443 fe->tuner_priv = NULL;
444 return 0;
445} 444}
446 445
447static int helene_sleep(struct dvb_frontend *fe) 446static int helene_sleep(struct dvb_frontend *fe)
diff --git a/drivers/media/dvb-frontends/horus3a.c b/drivers/media/dvb-frontends/horus3a.c
index 0c089b5986a1..94bb4f7a2298 100644
--- a/drivers/media/dvb-frontends/horus3a.c
+++ b/drivers/media/dvb-frontends/horus3a.c
@@ -151,14 +151,13 @@ static int horus3a_init(struct dvb_frontend *fe)
151 return 0; 151 return 0;
152} 152}
153 153
154static int horus3a_release(struct dvb_frontend *fe) 154static void horus3a_release(struct dvb_frontend *fe)
155{ 155{
156 struct horus3a_priv *priv = fe->tuner_priv; 156 struct horus3a_priv *priv = fe->tuner_priv;
157 157
158 dev_dbg(&priv->i2c->dev, "%s()\n", __func__); 158 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
159 kfree(fe->tuner_priv); 159 kfree(fe->tuner_priv);
160 fe->tuner_priv = NULL; 160 fe->tuner_priv = NULL;
161 return 0;
162} 161}
163 162
164static int horus3a_sleep(struct dvb_frontend *fe) 163static int horus3a_sleep(struct dvb_frontend *fe)
diff --git a/drivers/media/dvb-frontends/itd1000.c b/drivers/media/dvb-frontends/itd1000.c
index cadcae4cff89..475525134327 100644
--- a/drivers/media/dvb-frontends/itd1000.c
+++ b/drivers/media/dvb-frontends/itd1000.c
@@ -348,11 +348,10 @@ static int itd1000_sleep(struct dvb_frontend *fe)
348 return 0; 348 return 0;
349} 349}
350 350
351static int itd1000_release(struct dvb_frontend *fe) 351static void itd1000_release(struct dvb_frontend *fe)
352{ 352{
353 kfree(fe->tuner_priv); 353 kfree(fe->tuner_priv);
354 fe->tuner_priv = NULL; 354 fe->tuner_priv = NULL;
355 return 0;
356} 355}
357 356
358static const struct dvb_tuner_ops itd1000_tuner_ops = { 357static const struct dvb_tuner_ops itd1000_tuner_ops = {
diff --git a/drivers/media/dvb-frontends/ix2505v.c b/drivers/media/dvb-frontends/ix2505v.c
index 2826bbb36b73..ca371680a69f 100644
--- a/drivers/media/dvb-frontends/ix2505v.c
+++ b/drivers/media/dvb-frontends/ix2505v.c
@@ -94,14 +94,13 @@ static int ix2505v_write(struct ix2505v_state *state, u8 buf[], u8 count)
94 return 0; 94 return 0;
95} 95}
96 96
97static int ix2505v_release(struct dvb_frontend *fe) 97static void ix2505v_release(struct dvb_frontend *fe)
98{ 98{
99 struct ix2505v_state *state = fe->tuner_priv; 99 struct ix2505v_state *state = fe->tuner_priv;
100 100
101 fe->tuner_priv = NULL; 101 fe->tuner_priv = NULL;
102 kfree(state); 102 kfree(state);
103 103
104 return 0;
105} 104}
106 105
107/** 106/**
diff --git a/drivers/media/dvb-frontends/l64781.c b/drivers/media/dvb-frontends/l64781.c
index 2f3d0519e19b..68923c84679a 100644
--- a/drivers/media/dvb-frontends/l64781.c
+++ b/drivers/media/dvb-frontends/l64781.c
@@ -496,7 +496,7 @@ static void l64781_release(struct dvb_frontend* fe)
496 kfree(state); 496 kfree(state);
497} 497}
498 498
499static struct dvb_frontend_ops l64781_ops; 499static const struct dvb_frontend_ops l64781_ops;
500 500
501struct dvb_frontend* l64781_attach(const struct l64781_config* config, 501struct dvb_frontend* l64781_attach(const struct l64781_config* config,
502 struct i2c_adapter* i2c) 502 struct i2c_adapter* i2c)
@@ -571,7 +571,7 @@ error:
571 return NULL; 571 return NULL;
572} 572}
573 573
574static struct dvb_frontend_ops l64781_ops = { 574static const struct dvb_frontend_ops l64781_ops = {
575 .delsys = { SYS_DVBT }, 575 .delsys = { SYS_DVBT },
576 .info = { 576 .info = {
577 .name = "LSI L64781 DVB-T", 577 .name = "LSI L64781 DVB-T",
diff --git a/drivers/media/dvb-frontends/lg2160.c b/drivers/media/dvb-frontends/lg2160.c
index f51a3a0b3949..3b31e5f20f46 100644
--- a/drivers/media/dvb-frontends/lg2160.c
+++ b/drivers/media/dvb-frontends/lg2160.c
@@ -1359,7 +1359,7 @@ static void lg216x_release(struct dvb_frontend *fe)
1359 kfree(state); 1359 kfree(state);
1360} 1360}
1361 1361
1362static struct dvb_frontend_ops lg2160_ops = { 1362static const struct dvb_frontend_ops lg2160_ops = {
1363 .delsys = { SYS_ATSCMH }, 1363 .delsys = { SYS_ATSCMH },
1364 .info = { 1364 .info = {
1365 .name = "LG Electronics LG2160 ATSC/MH Frontend", 1365 .name = "LG Electronics LG2160 ATSC/MH Frontend",
@@ -1387,7 +1387,7 @@ static struct dvb_frontend_ops lg2160_ops = {
1387 .release = lg216x_release, 1387 .release = lg216x_release,
1388}; 1388};
1389 1389
1390static struct dvb_frontend_ops lg2161_ops = { 1390static const struct dvb_frontend_ops lg2161_ops = {
1391 .delsys = { SYS_ATSCMH }, 1391 .delsys = { SYS_ATSCMH },
1392 .info = { 1392 .info = {
1393 .name = "LG Electronics LG2161 ATSC/MH Frontend", 1393 .name = "LG Electronics LG2161 ATSC/MH Frontend",
diff --git a/drivers/media/dvb-frontends/lgdt3305.c b/drivers/media/dvb-frontends/lgdt3305.c
index 4503e8852fd1..9f5d9380bf5f 100644
--- a/drivers/media/dvb-frontends/lgdt3305.c
+++ b/drivers/media/dvb-frontends/lgdt3305.c
@@ -1103,8 +1103,8 @@ static void lgdt3305_release(struct dvb_frontend *fe)
1103 kfree(state); 1103 kfree(state);
1104} 1104}
1105 1105
1106static struct dvb_frontend_ops lgdt3304_ops; 1106static const struct dvb_frontend_ops lgdt3304_ops;
1107static struct dvb_frontend_ops lgdt3305_ops; 1107static const struct dvb_frontend_ops lgdt3305_ops;
1108 1108
1109struct dvb_frontend *lgdt3305_attach(const struct lgdt3305_config *config, 1109struct dvb_frontend *lgdt3305_attach(const struct lgdt3305_config *config,
1110 struct i2c_adapter *i2c_adap) 1110 struct i2c_adapter *i2c_adap)
@@ -1164,7 +1164,7 @@ fail:
1164} 1164}
1165EXPORT_SYMBOL(lgdt3305_attach); 1165EXPORT_SYMBOL(lgdt3305_attach);
1166 1166
1167static struct dvb_frontend_ops lgdt3304_ops = { 1167static const struct dvb_frontend_ops lgdt3304_ops = {
1168 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B }, 1168 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
1169 .info = { 1169 .info = {
1170 .name = "LG Electronics LGDT3304 VSB/QAM Frontend", 1170 .name = "LG Electronics LGDT3304 VSB/QAM Frontend",
@@ -1187,7 +1187,7 @@ static struct dvb_frontend_ops lgdt3304_ops = {
1187 .release = lgdt3305_release, 1187 .release = lgdt3305_release,
1188}; 1188};
1189 1189
1190static struct dvb_frontend_ops lgdt3305_ops = { 1190static const struct dvb_frontend_ops lgdt3305_ops = {
1191 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B }, 1191 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
1192 .info = { 1192 .info = {
1193 .name = "LG Electronics LGDT3305 VSB/QAM Frontend", 1193 .name = "LG Electronics LGDT3305 VSB/QAM Frontend",
diff --git a/drivers/media/dvb-frontends/lgdt3306a.c b/drivers/media/dvb-frontends/lgdt3306a.c
index 0ca4e810e9d8..19dca46b1171 100644
--- a/drivers/media/dvb-frontends/lgdt3306a.c
+++ b/drivers/media/dvb-frontends/lgdt3306a.c
@@ -1767,7 +1767,7 @@ static void lgdt3306a_release(struct dvb_frontend *fe)
1767 kfree(state); 1767 kfree(state);
1768} 1768}
1769 1769
1770static struct dvb_frontend_ops lgdt3306a_ops; 1770static const struct dvb_frontend_ops lgdt3306a_ops;
1771 1771
1772struct dvb_frontend *lgdt3306a_attach(const struct lgdt3306a_config *config, 1772struct dvb_frontend *lgdt3306a_attach(const struct lgdt3306a_config *config,
1773 struct i2c_adapter *i2c_adap) 1773 struct i2c_adapter *i2c_adap)
@@ -2103,7 +2103,7 @@ static void lgdt3306a_DumpRegs(struct lgdt3306a_state *state)
2103 2103
2104 2104
2105 2105
2106static struct dvb_frontend_ops lgdt3306a_ops = { 2106static const struct dvb_frontend_ops lgdt3306a_ops = {
2107 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B }, 2107 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
2108 .info = { 2108 .info = {
2109 .name = "LG Electronics LGDT3306A VSB/QAM Frontend", 2109 .name = "LG Electronics LGDT3306A VSB/QAM Frontend",
diff --git a/drivers/media/dvb-frontends/lgdt330x.c b/drivers/media/dvb-frontends/lgdt330x.c
index 96bf254da21e..2f4a0316f89c 100644
--- a/drivers/media/dvb-frontends/lgdt330x.c
+++ b/drivers/media/dvb-frontends/lgdt330x.c
@@ -405,8 +405,7 @@ static int lgdt330x_set_parameters(struct dvb_frontend *fe)
405 return -1; 405 return -1;
406 } 406 }
407 if (err < 0) 407 if (err < 0)
408 printk(KERN_WARNING "lgdt330x: %s: error blasting " 408 printk(KERN_WARNING "lgdt330x: %s: error blasting bytes to lgdt3303 for modulation type(%d)\n",
409 "bytes to lgdt3303 for modulation type(%d)\n",
410 __func__, p->modulation); 409 __func__, p->modulation);
411 410
412 /* 411 /*
@@ -729,8 +728,8 @@ static void lgdt330x_release(struct dvb_frontend* fe)
729 kfree(state); 728 kfree(state);
730} 729}
731 730
732static struct dvb_frontend_ops lgdt3302_ops; 731static const struct dvb_frontend_ops lgdt3302_ops;
733static struct dvb_frontend_ops lgdt3303_ops; 732static const struct dvb_frontend_ops lgdt3303_ops;
734 733
735struct dvb_frontend* lgdt330x_attach(const struct lgdt330x_config* config, 734struct dvb_frontend* lgdt330x_attach(const struct lgdt330x_config* config,
736 struct i2c_adapter* i2c) 735 struct i2c_adapter* i2c)
@@ -775,7 +774,7 @@ error:
775 return NULL; 774 return NULL;
776} 775}
777 776
778static struct dvb_frontend_ops lgdt3302_ops = { 777static const struct dvb_frontend_ops lgdt3302_ops = {
779 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B }, 778 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
780 .info = { 779 .info = {
781 .name= "LG Electronics LGDT3302 VSB/QAM Frontend", 780 .name= "LG Electronics LGDT3302 VSB/QAM Frontend",
@@ -798,7 +797,7 @@ static struct dvb_frontend_ops lgdt3302_ops = {
798 .release = lgdt330x_release, 797 .release = lgdt330x_release,
799}; 798};
800 799
801static struct dvb_frontend_ops lgdt3303_ops = { 800static const struct dvb_frontend_ops lgdt3303_ops = {
802 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B }, 801 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
803 .info = { 802 .info = {
804 .name= "LG Electronics LGDT3303 VSB/QAM Frontend", 803 .name= "LG Electronics LGDT3303 VSB/QAM Frontend",
diff --git a/drivers/media/dvb-frontends/lgs8gl5.c b/drivers/media/dvb-frontends/lgs8gl5.c
index fbfd87b5b803..970e42fdbc1b 100644
--- a/drivers/media/dvb-frontends/lgs8gl5.c
+++ b/drivers/media/dvb-frontends/lgs8gl5.c
@@ -376,7 +376,7 @@ lgs8gl5_release(struct dvb_frontend *fe)
376} 376}
377 377
378 378
379static struct dvb_frontend_ops lgs8gl5_ops; 379static const struct dvb_frontend_ops lgs8gl5_ops;
380 380
381 381
382struct dvb_frontend* 382struct dvb_frontend*
@@ -412,7 +412,7 @@ error:
412EXPORT_SYMBOL(lgs8gl5_attach); 412EXPORT_SYMBOL(lgs8gl5_attach);
413 413
414 414
415static struct dvb_frontend_ops lgs8gl5_ops = { 415static const struct dvb_frontend_ops lgs8gl5_ops = {
416 .delsys = { SYS_DTMB }, 416 .delsys = { SYS_DTMB },
417 .info = { 417 .info = {
418 .name = "Legend Silicon LGS-8GL5 DMB-TH", 418 .name = "Legend Silicon LGS-8GL5 DMB-TH",
diff --git a/drivers/media/dvb-frontends/lgs8gxx.c b/drivers/media/dvb-frontends/lgs8gxx.c
index 919daeb96747..6d2e62469d58 100644
--- a/drivers/media/dvb-frontends/lgs8gxx.c
+++ b/drivers/media/dvb-frontends/lgs8gxx.c
@@ -985,7 +985,7 @@ static int lgs8gxx_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
985 return lgs8gxx_write_reg(priv, 0x01, 0); 985 return lgs8gxx_write_reg(priv, 0x01, 0);
986} 986}
987 987
988static struct dvb_frontend_ops lgs8gxx_ops = { 988static const struct dvb_frontend_ops lgs8gxx_ops = {
989 .delsys = { SYS_DTMB }, 989 .delsys = { SYS_DTMB },
990 .info = { 990 .info = {
991 .name = "Legend Silicon LGS8913/LGS8GXX DMB-TH", 991 .name = "Legend Silicon LGS8913/LGS8GXX DMB-TH",
diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c
index e0fe5bc9dbce..50bce68ffd66 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -16,7 +16,7 @@
16 16
17#include "m88ds3103_priv.h" 17#include "m88ds3103_priv.h"
18 18
19static struct dvb_frontend_ops m88ds3103_ops; 19static const struct dvb_frontend_ops m88ds3103_ops;
20 20
21/* write single register with mask */ 21/* write single register with mask */
22static int m88ds3103_update_bits(struct m88ds3103_dev *dev, 22static int m88ds3103_update_bits(struct m88ds3103_dev *dev,
@@ -1295,7 +1295,7 @@ struct dvb_frontend *m88ds3103_attach(const struct m88ds3103_config *cfg,
1295} 1295}
1296EXPORT_SYMBOL(m88ds3103_attach); 1296EXPORT_SYMBOL(m88ds3103_attach);
1297 1297
1298static struct dvb_frontend_ops m88ds3103_ops = { 1298static const struct dvb_frontend_ops m88ds3103_ops = {
1299 .delsys = {SYS_DVBS, SYS_DVBS2}, 1299 .delsys = {SYS_DVBS, SYS_DVBS2},
1300 .info = { 1300 .info = {
1301 .name = "Montage Technology M88DS3103", 1301 .name = "Montage Technology M88DS3103",
diff --git a/drivers/media/dvb-frontends/m88rs2000.c b/drivers/media/dvb-frontends/m88rs2000.c
index ef79a4ec31e2..ce6c21d405ee 100644
--- a/drivers/media/dvb-frontends/m88rs2000.c
+++ b/drivers/media/dvb-frontends/m88rs2000.c
@@ -75,8 +75,8 @@ static int m88rs2000_writereg(struct m88rs2000_state *state,
75 ret = i2c_transfer(state->i2c, &msg, 1); 75 ret = i2c_transfer(state->i2c, &msg, 1);
76 76
77 if (ret != 1) 77 if (ret != 1)
78 deb_info("%s: writereg error (reg == 0x%02x, val == 0x%02x, " 78 deb_info("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n",
79 "ret == %i)\n", __func__, reg, data, ret); 79 __func__, reg, data, ret);
80 80
81 return (ret != 1) ? -EREMOTEIO : 0; 81 return (ret != 1) ? -EREMOTEIO : 0;
82} 82}
@@ -618,10 +618,9 @@ static int m88rs2000_set_frontend(struct dvb_frontend *fe)
618 state->no_lock_count = 0; 618 state->no_lock_count = 0;
619 619
620 if (c->delivery_system != SYS_DVBS) { 620 if (c->delivery_system != SYS_DVBS) {
621 deb_info("%s: unsupported delivery " 621 deb_info("%s: unsupported delivery system selected (%d)\n",
622 "system selected (%d)\n", 622 __func__, c->delivery_system);
623 __func__, c->delivery_system); 623 return -EOPNOTSUPP;
624 return -EOPNOTSUPP;
625 } 624 }
626 625
627 /* Set Tuner */ 626 /* Set Tuner */
@@ -753,7 +752,7 @@ static void m88rs2000_release(struct dvb_frontend *fe)
753 kfree(state); 752 kfree(state);
754} 753}
755 754
756static struct dvb_frontend_ops m88rs2000_ops = { 755static const struct dvb_frontend_ops m88rs2000_ops = {
757 .delsys = { SYS_DVBS }, 756 .delsys = { SYS_DVBS },
758 .info = { 757 .info = {
759 .name = "M88RS2000 DVB-S", 758 .name = "M88RS2000 DVB-S",
diff --git a/drivers/media/dvb-frontends/mb86a16.c b/drivers/media/dvb-frontends/mb86a16.c
index 79bc671e8769..9bb122c39c1b 100644
--- a/drivers/media/dvb-frontends/mb86a16.c
+++ b/drivers/media/dvb-frontends/mb86a16.c
@@ -1816,7 +1816,7 @@ static enum dvbfe_algo mb86a16_frontend_algo(struct dvb_frontend *fe)
1816 return DVBFE_ALGO_CUSTOM; 1816 return DVBFE_ALGO_CUSTOM;
1817} 1817}
1818 1818
1819static struct dvb_frontend_ops mb86a16_ops = { 1819static const struct dvb_frontend_ops mb86a16_ops = {
1820 .delsys = { SYS_DVBS }, 1820 .delsys = { SYS_DVBS },
1821 .info = { 1821 .info = {
1822 .name = "Fujitsu MB86A16 DVB-S", 1822 .name = "Fujitsu MB86A16 DVB-S",
diff --git a/drivers/media/dvb-frontends/mb86a20s.c b/drivers/media/dvb-frontends/mb86a20s.c
index fe79358b035e..e8ac8c3e2ec0 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -1967,6 +1967,7 @@ static int mb86a20s_read_status_and_stats(struct dvb_frontend *fe,
1967 if (status_nr < 0) { 1967 if (status_nr < 0) {
1968 dev_err(&state->i2c->dev, 1968 dev_err(&state->i2c->dev,
1969 "%s: Can't read frontend lock status\n", __func__); 1969 "%s: Can't read frontend lock status\n", __func__);
1970 rc = status_nr;
1970 goto error; 1971 goto error;
1971 } 1972 }
1972 1973
@@ -2059,7 +2060,7 @@ static int mb86a20s_get_frontend_algo(struct dvb_frontend *fe)
2059 return DVBFE_ALGO_HW; 2060 return DVBFE_ALGO_HW;
2060} 2061}
2061 2062
2062static struct dvb_frontend_ops mb86a20s_ops; 2063static const struct dvb_frontend_ops mb86a20s_ops;
2063 2064
2064struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config, 2065struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config,
2065 struct i2c_adapter *i2c) 2066 struct i2c_adapter *i2c)
@@ -2107,7 +2108,7 @@ error:
2107} 2108}
2108EXPORT_SYMBOL(mb86a20s_attach); 2109EXPORT_SYMBOL(mb86a20s_attach);
2109 2110
2110static struct dvb_frontend_ops mb86a20s_ops = { 2111static const struct dvb_frontend_ops mb86a20s_ops = {
2111 .delsys = { SYS_ISDBT }, 2112 .delsys = { SYS_ISDBT },
2112 /* Use dib8000 values per default */ 2113 /* Use dib8000 values per default */
2113 .info = { 2114 .info = {
diff --git a/drivers/media/dvb-frontends/mn88472.c b/drivers/media/dvb-frontends/mn88472.c
index 18fb2df1e2bd..29dd13b36c28 100644
--- a/drivers/media/dvb-frontends/mn88472.c
+++ b/drivers/media/dvb-frontends/mn88472.c
@@ -411,7 +411,7 @@ err:
411 return ret; 411 return ret;
412} 412}
413 413
414static struct dvb_frontend_ops mn88472_ops = { 414static const struct dvb_frontend_ops mn88472_ops = {
415 .delsys = {SYS_DVBT, SYS_DVBT2, SYS_DVBC_ANNEX_A}, 415 .delsys = {SYS_DVBT, SYS_DVBT2, SYS_DVBC_ANNEX_A},
416 .info = { 416 .info = {
417 .name = "Panasonic MN88472", 417 .name = "Panasonic MN88472",
@@ -488,18 +488,6 @@ static int mn88472_probe(struct i2c_client *client,
488 goto err_kfree; 488 goto err_kfree;
489 } 489 }
490 490
491 /* Check demod answers with correct chip id */
492 ret = regmap_read(dev->regmap[0], 0xff, &utmp);
493 if (ret)
494 goto err_regmap_0_regmap_exit;
495
496 dev_dbg(&client->dev, "chip id=%02x\n", utmp);
497
498 if (utmp != 0x02) {
499 ret = -ENODEV;
500 goto err_regmap_0_regmap_exit;
501 }
502
503 /* 491 /*
504 * Chip has three I2C addresses for different register banks. Used 492 * Chip has three I2C addresses for different register banks. Used
505 * addresses are 0x18, 0x1a and 0x1c. We register two dummy clients, 493 * addresses are 0x18, 0x1a and 0x1c. We register two dummy clients,
@@ -536,6 +524,18 @@ static int mn88472_probe(struct i2c_client *client,
536 } 524 }
537 i2c_set_clientdata(dev->client[2], dev); 525 i2c_set_clientdata(dev->client[2], dev);
538 526
527 /* Check demod answers with correct chip id */
528 ret = regmap_read(dev->regmap[2], 0xff, &utmp);
529 if (ret)
530 goto err_regmap_2_regmap_exit;
531
532 dev_dbg(&client->dev, "chip id=%02x\n", utmp);
533
534 if (utmp != 0x02) {
535 ret = -ENODEV;
536 goto err_regmap_2_regmap_exit;
537 }
538
539 /* Sleep because chip is active by default */ 539 /* Sleep because chip is active by default */
540 ret = regmap_write(dev->regmap[2], 0x05, 0x3e); 540 ret = regmap_write(dev->regmap[2], 0x05, 0x3e);
541 if (ret) 541 if (ret)
diff --git a/drivers/media/dvb-frontends/mn88473.c b/drivers/media/dvb-frontends/mn88473.c
index 451974a1d7ed..c221c7d2ac3e 100644
--- a/drivers/media/dvb-frontends/mn88473.c
+++ b/drivers/media/dvb-frontends/mn88473.c
@@ -239,62 +239,68 @@ static int mn88473_read_status(struct dvb_frontend *fe, enum fe_status *status)
239 struct i2c_client *client = fe->demodulator_priv; 239 struct i2c_client *client = fe->demodulator_priv;
240 struct mn88473_dev *dev = i2c_get_clientdata(client); 240 struct mn88473_dev *dev = i2c_get_clientdata(client);
241 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 241 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
242 int ret; 242 int ret, i, stmp;
243 unsigned int uitmp; 243 unsigned int utmp, utmp1, utmp2;
244 u8 buf[5];
244 245
245 if (!dev->active) { 246 if (!dev->active) {
246 ret = -EAGAIN; 247 ret = -EAGAIN;
247 goto err; 248 goto err;
248 } 249 }
249 250
250 *status = 0; 251 /* Lock detection */
251
252 switch (c->delivery_system) { 252 switch (c->delivery_system) {
253 case SYS_DVBT: 253 case SYS_DVBT:
254 ret = regmap_read(dev->regmap[0], 0x62, &uitmp); 254 ret = regmap_read(dev->regmap[0], 0x62, &utmp);
255 if (ret) 255 if (ret)
256 goto err; 256 goto err;
257 257
258 if (!(uitmp & 0xa0)) { 258 if (!(utmp & 0xa0)) {
259 if ((uitmp & 0x0f) >= 0x09) 259 if ((utmp & 0x0f) >= 0x09)
260 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | 260 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER |
261 FE_HAS_VITERBI | FE_HAS_SYNC | 261 FE_HAS_VITERBI | FE_HAS_SYNC |
262 FE_HAS_LOCK; 262 FE_HAS_LOCK;
263 else if ((uitmp & 0x0f) >= 0x03) 263 else if ((utmp & 0x0f) >= 0x03)
264 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER; 264 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER;
265 } else {
266 *status = 0;
265 } 267 }
266 break; 268 break;
267 case SYS_DVBT2: 269 case SYS_DVBT2:
268 ret = regmap_read(dev->regmap[2], 0x8b, &uitmp); 270 ret = regmap_read(dev->regmap[2], 0x8b, &utmp);
269 if (ret) 271 if (ret)
270 goto err; 272 goto err;
271 273
272 if (!(uitmp & 0x40)) { 274 if (!(utmp & 0x40)) {
273 if ((uitmp & 0x0f) >= 0x0d) 275 if ((utmp & 0x0f) >= 0x0d)
274 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | 276 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER |
275 FE_HAS_VITERBI | FE_HAS_SYNC | 277 FE_HAS_VITERBI | FE_HAS_SYNC |
276 FE_HAS_LOCK; 278 FE_HAS_LOCK;
277 else if ((uitmp & 0x0f) >= 0x0a) 279 else if ((utmp & 0x0f) >= 0x0a)
278 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | 280 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER |
279 FE_HAS_VITERBI; 281 FE_HAS_VITERBI;
280 else if ((uitmp & 0x0f) >= 0x07) 282 else if ((utmp & 0x0f) >= 0x07)
281 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER; 283 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER;
284 } else {
285 *status = 0;
282 } 286 }
283 break; 287 break;
284 case SYS_DVBC_ANNEX_A: 288 case SYS_DVBC_ANNEX_A:
285 ret = regmap_read(dev->regmap[1], 0x85, &uitmp); 289 ret = regmap_read(dev->regmap[1], 0x85, &utmp);
286 if (ret) 290 if (ret)
287 goto err; 291 goto err;
288 292
289 if (!(uitmp & 0x40)) { 293 if (!(utmp & 0x40)) {
290 ret = regmap_read(dev->regmap[1], 0x89, &uitmp); 294 ret = regmap_read(dev->regmap[1], 0x89, &utmp);
291 if (ret) 295 if (ret)
292 goto err; 296 goto err;
293 297
294 if (uitmp & 0x01) 298 if (utmp & 0x01)
295 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | 299 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER |
296 FE_HAS_VITERBI | FE_HAS_SYNC | 300 FE_HAS_VITERBI | FE_HAS_SYNC |
297 FE_HAS_LOCK; 301 FE_HAS_LOCK;
302 } else {
303 *status = 0;
298 } 304 }
299 break; 305 break;
300 default: 306 default:
@@ -302,6 +308,148 @@ static int mn88473_read_status(struct dvb_frontend *fe, enum fe_status *status)
302 goto err; 308 goto err;
303 } 309 }
304 310
311 /* Signal strength */
312 if (*status & FE_HAS_SIGNAL) {
313 for (i = 0; i < 2; i++) {
314 ret = regmap_bulk_read(dev->regmap[2], 0x86 + i,
315 &buf[i], 1);
316 if (ret)
317 goto err;
318 }
319
320 /* AGCRD[15:6] gives us a 10bit value ([5:0] are always 0) */
321 utmp1 = buf[0] << 8 | buf[1] << 0 | buf[0] >> 2;
322 dev_dbg(&client->dev, "strength=%u\n", utmp1);
323
324 c->strength.stat[0].scale = FE_SCALE_RELATIVE;
325 c->strength.stat[0].uvalue = utmp1;
326 } else {
327 c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
328 }
329
330 /* CNR */
331 if (*status & FE_HAS_VITERBI && c->delivery_system == SYS_DVBT) {
332 /* DVB-T CNR */
333 ret = regmap_bulk_read(dev->regmap[0], 0x8f, buf, 2);
334 if (ret)
335 goto err;
336
337 utmp = buf[0] << 8 | buf[1] << 0;
338 if (utmp) {
339 /* CNR[dB]: 10 * (log10(65536 / value) + 0.2) */
340 /* log10(65536) = 80807124, 0.2 = 3355443 */
341 stmp = div_u64(((u64)80807124 - intlog10(utmp)
342 + 3355443) * 10000, 1 << 24);
343 dev_dbg(&client->dev, "cnr=%d value=%u\n", stmp, utmp);
344 } else {
345 stmp = 0;
346 }
347
348 c->cnr.stat[0].svalue = stmp;
349 c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
350 } else if (*status & FE_HAS_VITERBI &&
351 c->delivery_system == SYS_DVBT2) {
352 /* DVB-T2 CNR */
353 for (i = 0; i < 3; i++) {
354 ret = regmap_bulk_read(dev->regmap[2], 0xb7 + i,
355 &buf[i], 1);
356 if (ret)
357 goto err;
358 }
359
360 utmp = buf[1] << 8 | buf[2] << 0;
361 utmp1 = (buf[0] >> 2) & 0x01; /* 0=SISO, 1=MISO */
362 if (utmp) {
363 if (utmp1) {
364 /* CNR[dB]: 10 * (log10(16384 / value) - 0.6) */
365 /* log10(16384) = 70706234, 0.6 = 10066330 */
366 stmp = div_u64(((u64)70706234 - intlog10(utmp)
367 - 10066330) * 10000, 1 << 24);
368 dev_dbg(&client->dev, "cnr=%d value=%u MISO\n",
369 stmp, utmp);
370 } else {
371 /* CNR[dB]: 10 * (log10(65536 / value) + 0.2) */
372 /* log10(65536) = 80807124, 0.2 = 3355443 */
373 stmp = div_u64(((u64)80807124 - intlog10(utmp)
374 + 3355443) * 10000, 1 << 24);
375 dev_dbg(&client->dev, "cnr=%d value=%u SISO\n",
376 stmp, utmp);
377 }
378 } else {
379 stmp = 0;
380 }
381
382 c->cnr.stat[0].svalue = stmp;
383 c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
384 } else if (*status & FE_HAS_VITERBI &&
385 c->delivery_system == SYS_DVBC_ANNEX_A) {
386 /* DVB-C CNR */
387 ret = regmap_bulk_read(dev->regmap[1], 0xa1, buf, 4);
388 if (ret)
389 goto err;
390
391 utmp1 = buf[0] << 8 | buf[1] << 0; /* signal */
392 utmp2 = buf[2] << 8 | buf[3] << 0; /* noise */
393 if (utmp1 && utmp2) {
394 /* CNR[dB]: 10 * log10(8 * (signal / noise)) */
395 /* log10(8) = 15151336 */
396 stmp = div_u64(((u64)15151336 + intlog10(utmp1)
397 - intlog10(utmp2)) * 10000, 1 << 24);
398 dev_dbg(&client->dev, "cnr=%d signal=%u noise=%u\n",
399 stmp, utmp1, utmp2);
400 } else {
401 stmp = 0;
402 }
403
404 c->cnr.stat[0].svalue = stmp;
405 c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
406 } else {
407 c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
408 }
409
410 /* BER */
411 if (*status & FE_HAS_LOCK && (c->delivery_system == SYS_DVBT ||
412 c->delivery_system == SYS_DVBC_ANNEX_A)) {
413 /* DVB-T & DVB-C BER */
414 ret = regmap_bulk_read(dev->regmap[0], 0x92, buf, 5);
415 if (ret)
416 goto err;
417
418 utmp1 = buf[0] << 16 | buf[1] << 8 | buf[2] << 0;
419 utmp2 = buf[3] << 8 | buf[4] << 0;
420 utmp2 = utmp2 * 8 * 204;
421 dev_dbg(&client->dev, "post_bit_error=%u post_bit_count=%u\n",
422 utmp1, utmp2);
423
424 c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER;
425 c->post_bit_error.stat[0].uvalue += utmp1;
426 c->post_bit_count.stat[0].scale = FE_SCALE_COUNTER;
427 c->post_bit_count.stat[0].uvalue += utmp2;
428 } else {
429 c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
430 c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
431 }
432
433 /* PER */
434 if (*status & FE_HAS_LOCK) {
435 ret = regmap_bulk_read(dev->regmap[0], 0xdd, buf, 4);
436 if (ret)
437 goto err;
438
439 utmp1 = buf[0] << 8 | buf[1] << 0;
440 utmp2 = buf[2] << 8 | buf[3] << 0;
441 dev_dbg(&client->dev, "block_error=%u block_count=%u\n",
442 utmp1, utmp2);
443
444 c->block_error.stat[0].scale = FE_SCALE_COUNTER;
445 c->block_error.stat[0].uvalue += utmp1;
446 c->block_count.stat[0].scale = FE_SCALE_COUNTER;
447 c->block_count.stat[0].uvalue += utmp2;
448 } else {
449 c->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
450 c->block_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
451 }
452
305 return 0; 453 return 0;
306err: 454err:
307 dev_dbg(&client->dev, "failed=%d\n", ret); 455 dev_dbg(&client->dev, "failed=%d\n", ret);
@@ -312,6 +460,7 @@ static int mn88473_init(struct dvb_frontend *fe)
312{ 460{
313 struct i2c_client *client = fe->demodulator_priv; 461 struct i2c_client *client = fe->demodulator_priv;
314 struct mn88473_dev *dev = i2c_get_clientdata(client); 462 struct mn88473_dev *dev = i2c_get_clientdata(client);
463 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
315 int ret, len, remain; 464 int ret, len, remain;
316 unsigned int uitmp; 465 unsigned int uitmp;
317 const struct firmware *fw; 466 const struct firmware *fw;
@@ -378,6 +527,20 @@ warm:
378 527
379 dev->active = true; 528 dev->active = true;
380 529
530 /* init stats here to indicate which stats are supported */
531 c->strength.len = 1;
532 c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
533 c->cnr.len = 1;
534 c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
535 c->post_bit_error.len = 1;
536 c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
537 c->post_bit_count.len = 1;
538 c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
539 c->block_error.len = 1;
540 c->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
541 c->block_count.len = 1;
542 c->block_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
543
381 return 0; 544 return 0;
382err_release_firmware: 545err_release_firmware:
383 release_firmware(fw); 546 release_firmware(fw);
@@ -485,18 +648,6 @@ static int mn88473_probe(struct i2c_client *client,
485 goto err_kfree; 648 goto err_kfree;
486 } 649 }
487 650
488 /* Check demod answers with correct chip id */
489 ret = regmap_read(dev->regmap[0], 0xff, &uitmp);
490 if (ret)
491 goto err_regmap_0_regmap_exit;
492
493 dev_dbg(&client->dev, "chip id=%02x\n", uitmp);
494
495 if (uitmp != 0x03) {
496 ret = -ENODEV;
497 goto err_regmap_0_regmap_exit;
498 }
499
500 /* 651 /*
501 * Chip has three I2C addresses for different register banks. Used 652 * Chip has three I2C addresses for different register banks. Used
502 * addresses are 0x18, 0x1a and 0x1c. We register two dummy clients, 653 * addresses are 0x18, 0x1a and 0x1c. We register two dummy clients,
@@ -533,6 +684,18 @@ static int mn88473_probe(struct i2c_client *client,
533 } 684 }
534 i2c_set_clientdata(dev->client[2], dev); 685 i2c_set_clientdata(dev->client[2], dev);
535 686
687 /* Check demod answers with correct chip id */
688 ret = regmap_read(dev->regmap[2], 0xff, &uitmp);
689 if (ret)
690 goto err_regmap_2_regmap_exit;
691
692 dev_dbg(&client->dev, "chip id=%02x\n", uitmp);
693
694 if (uitmp != 0x03) {
695 ret = -ENODEV;
696 goto err_regmap_2_regmap_exit;
697 }
698
536 /* Sleep because chip is active by default */ 699 /* Sleep because chip is active by default */
537 ret = regmap_write(dev->regmap[2], 0x05, 0x3e); 700 ret = regmap_write(dev->regmap[2], 0x05, 0x3e);
538 if (ret) 701 if (ret)
diff --git a/drivers/media/dvb-frontends/mn88473_priv.h b/drivers/media/dvb-frontends/mn88473_priv.h
index e6c65893e451..5fc463d147c8 100644
--- a/drivers/media/dvb-frontends/mn88473_priv.h
+++ b/drivers/media/dvb-frontends/mn88473_priv.h
@@ -18,7 +18,9 @@
18#define MN88473_PRIV_H 18#define MN88473_PRIV_H
19 19
20#include "dvb_frontend.h" 20#include "dvb_frontend.h"
21#include "dvb_math.h"
21#include "mn88473.h" 22#include "mn88473.h"
23#include <linux/math64.h>
22#include <linux/firmware.h> 24#include <linux/firmware.h>
23#include <linux/regmap.h> 25#include <linux/regmap.h>
24 26
diff --git a/drivers/media/dvb-frontends/mt312.c b/drivers/media/dvb-frontends/mt312.c
index fc08429c99b7..961b9a2508e0 100644
--- a/drivers/media/dvb-frontends/mt312.c
+++ b/drivers/media/dvb-frontends/mt312.c
@@ -457,8 +457,8 @@ static int mt312_read_status(struct dvb_frontend *fe, enum fe_status *s)
457 if (ret < 0) 457 if (ret < 0)
458 return ret; 458 return ret;
459 459
460 dprintk("QPSK_STAT_H: 0x%02x, QPSK_STAT_L: 0x%02x," 460 dprintk("QPSK_STAT_H: 0x%02x, QPSK_STAT_L: 0x%02x, FEC_STATUS: 0x%02x\n",
461 " FEC_STATUS: 0x%02x\n", status[0], status[1], status[2]); 461 status[0], status[1], status[2]);
462 462
463 if (status[0] & 0xc0) 463 if (status[0] & 0xc0)
464 *s |= FE_HAS_SIGNAL; /* signal noise ratio */ 464 *s |= FE_HAS_SIGNAL; /* signal noise ratio */
@@ -748,7 +748,7 @@ static void mt312_release(struct dvb_frontend *fe)
748} 748}
749 749
750#define MT312_SYS_CLK 90000000UL /* 90 MHz */ 750#define MT312_SYS_CLK 90000000UL /* 90 MHz */
751static struct dvb_frontend_ops mt312_ops = { 751static const struct dvb_frontend_ops mt312_ops = {
752 .delsys = { SYS_DVBS }, 752 .delsys = { SYS_DVBS },
753 .info = { 753 .info = {
754 .name = "Zarlink ???? DVB-S", 754 .name = "Zarlink ???? DVB-S",
@@ -827,8 +827,7 @@ struct dvb_frontend *mt312_attach(const struct mt312_config *config,
827 state->freq_mult = 9; 827 state->freq_mult = 9;
828 break; 828 break;
829 default: 829 default:
830 printk(KERN_WARNING "Only Zarlink VP310/MT312/ZL10313" 830 printk(KERN_WARNING "Only Zarlink VP310/MT312/ZL10313 are supported chips.\n");
831 " are supported chips.\n");
832 goto error; 831 goto error;
833 } 832 }
834 833
diff --git a/drivers/media/dvb-frontends/mt352.c b/drivers/media/dvb-frontends/mt352.c
index c0bb6328956b..48ea0408f02a 100644
--- a/drivers/media/dvb-frontends/mt352.c
+++ b/drivers/media/dvb-frontends/mt352.c
@@ -538,7 +538,7 @@ static void mt352_release(struct dvb_frontend* fe)
538 kfree(state); 538 kfree(state);
539} 539}
540 540
541static struct dvb_frontend_ops mt352_ops; 541static const struct dvb_frontend_ops mt352_ops;
542 542
543struct dvb_frontend* mt352_attach(const struct mt352_config* config, 543struct dvb_frontend* mt352_attach(const struct mt352_config* config,
544 struct i2c_adapter* i2c) 544 struct i2c_adapter* i2c)
@@ -566,7 +566,7 @@ error:
566 return NULL; 566 return NULL;
567} 567}
568 568
569static struct dvb_frontend_ops mt352_ops = { 569static const struct dvb_frontend_ops mt352_ops = {
570 .delsys = { SYS_DVBT }, 570 .delsys = { SYS_DVBT },
571 .info = { 571 .info = {
572 .name = "Zarlink MT352 DVB-T", 572 .name = "Zarlink MT352 DVB-T",
diff --git a/drivers/media/dvb-frontends/nxt200x.c b/drivers/media/dvb-frontends/nxt200x.c
index 79c3040912ab..2fe40372ca07 100644
--- a/drivers/media/dvb-frontends/nxt200x.c
+++ b/drivers/media/dvb-frontends/nxt200x.c
@@ -289,8 +289,7 @@ static void nxt200x_microcontroller_stop (struct nxt200x_state* state)
289 counter++; 289 counter++;
290 } 290 }
291 291
292 pr_warn("Timeout waiting for nxt200x to stop. This is ok after " 292 pr_warn("Timeout waiting for nxt200x to stop. This is ok after firmware upload.\n");
293 "firmware upload.\n");
294 return; 293 return;
295} 294}
296 295
@@ -893,8 +892,8 @@ static int nxt2002_init(struct dvb_frontend* fe)
893 state->i2c->dev.parent); 892 state->i2c->dev.parent);
894 pr_debug("%s: Waiting for firmware upload(2)...\n", __func__); 893 pr_debug("%s: Waiting for firmware upload(2)...\n", __func__);
895 if (ret) { 894 if (ret) {
896 pr_err("%s: No firmware uploaded (timeout or file not found?)" 895 pr_err("%s: No firmware uploaded (timeout or file not found?)\n",
897 "\n", __func__); 896 __func__);
898 return ret; 897 return ret;
899 } 898 }
900 899
@@ -960,8 +959,8 @@ static int nxt2004_init(struct dvb_frontend* fe)
960 state->i2c->dev.parent); 959 state->i2c->dev.parent);
961 pr_debug("%s: Waiting for firmware upload(2)...\n", __func__); 960 pr_debug("%s: Waiting for firmware upload(2)...\n", __func__);
962 if (ret) { 961 if (ret) {
963 pr_err("%s: No firmware uploaded (timeout or file not found?)" 962 pr_err("%s: No firmware uploaded (timeout or file not found?)\n",
964 "\n", __func__); 963 __func__);
965 return ret; 964 return ret;
966 } 965 }
967 966
@@ -1150,7 +1149,7 @@ static void nxt200x_release(struct dvb_frontend* fe)
1150 kfree(state); 1149 kfree(state);
1151} 1150}
1152 1151
1153static struct dvb_frontend_ops nxt200x_ops; 1152static const struct dvb_frontend_ops nxt200x_ops;
1154 1153
1155struct dvb_frontend* nxt200x_attach(const struct nxt200x_config* config, 1154struct dvb_frontend* nxt200x_attach(const struct nxt200x_config* config,
1156 struct i2c_adapter* i2c) 1155 struct i2c_adapter* i2c)
@@ -1213,7 +1212,7 @@ error:
1213 return NULL; 1212 return NULL;
1214} 1213}
1215 1214
1216static struct dvb_frontend_ops nxt200x_ops = { 1215static const struct dvb_frontend_ops nxt200x_ops = {
1217 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B }, 1216 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
1218 .info = { 1217 .info = {
1219 .name = "Nextwave NXT200X VSB/QAM frontend", 1218 .name = "Nextwave NXT200X VSB/QAM frontend",
diff --git a/drivers/media/dvb-frontends/nxt6000.c b/drivers/media/dvb-frontends/nxt6000.c
index 73f9505367ac..1ce5ea28489b 100644
--- a/drivers/media/dvb-frontends/nxt6000.c
+++ b/drivers/media/dvb-frontends/nxt6000.c
@@ -19,6 +19,8 @@
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/ 20*/
21 21
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
23
22#include <linux/init.h> 24#include <linux/init.h>
23#include <linux/kernel.h> 25#include <linux/kernel.h>
24#include <linux/module.h> 26#include <linux/module.h>
@@ -39,7 +41,11 @@ struct nxt6000_state {
39}; 41};
40 42
41static int debug; 43static int debug;
42#define dprintk if (debug) printk 44#define dprintk(fmt, arg...) do { \
45 if (debug) \
46 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
47 __func__, ##arg); \
48} while (0)
43 49
44static int nxt6000_writereg(struct nxt6000_state* state, u8 reg, u8 data) 50static int nxt6000_writereg(struct nxt6000_state* state, u8 reg, u8 data)
45{ 51{
@@ -215,119 +221,129 @@ static void nxt6000_dump_status(struct nxt6000_state *state)
215{ 221{
216 u8 val; 222 u8 val;
217 223
218/* 224#if 0
219 printk("RS_COR_STAT: 0x%02X\n", nxt6000_readreg(fe, RS_COR_STAT)); 225 pr_info("RS_COR_STAT: 0x%02X\n",
220 printk("VIT_SYNC_STATUS: 0x%02X\n", nxt6000_readreg(fe, VIT_SYNC_STATUS)); 226 nxt6000_readreg(fe, RS_COR_STAT));
221 printk("OFDM_COR_STAT: 0x%02X\n", nxt6000_readreg(fe, OFDM_COR_STAT)); 227 pr_info("VIT_SYNC_STATUS: 0x%02X\n",
222 printk("OFDM_SYR_STAT: 0x%02X\n", nxt6000_readreg(fe, OFDM_SYR_STAT)); 228 nxt6000_readreg(fe, VIT_SYNC_STATUS));
223 printk("OFDM_TPS_RCVD_1: 0x%02X\n", nxt6000_readreg(fe, OFDM_TPS_RCVD_1)); 229 pr_info("OFDM_COR_STAT: 0x%02X\n",
224 printk("OFDM_TPS_RCVD_2: 0x%02X\n", nxt6000_readreg(fe, OFDM_TPS_RCVD_2)); 230 nxt6000_readreg(fe, OFDM_COR_STAT));
225 printk("OFDM_TPS_RCVD_3: 0x%02X\n", nxt6000_readreg(fe, OFDM_TPS_RCVD_3)); 231 pr_info("OFDM_SYR_STAT: 0x%02X\n",
226 printk("OFDM_TPS_RCVD_4: 0x%02X\n", nxt6000_readreg(fe, OFDM_TPS_RCVD_4)); 232 nxt6000_readreg(fe, OFDM_SYR_STAT));
227 printk("OFDM_TPS_RESERVED_1: 0x%02X\n", nxt6000_readreg(fe, OFDM_TPS_RESERVED_1)); 233 pr_info("OFDM_TPS_RCVD_1: 0x%02X\n",
228 printk("OFDM_TPS_RESERVED_2: 0x%02X\n", nxt6000_readreg(fe, OFDM_TPS_RESERVED_2)); 234 nxt6000_readreg(fe, OFDM_TPS_RCVD_1));
229*/ 235 pr_info("OFDM_TPS_RCVD_2: 0x%02X\n",
230 printk("NXT6000 status:"); 236 nxt6000_readreg(fe, OFDM_TPS_RCVD_2));
237 pr_info("OFDM_TPS_RCVD_3: 0x%02X\n",
238 nxt6000_readreg(fe, OFDM_TPS_RCVD_3));
239 pr_info("OFDM_TPS_RCVD_4: 0x%02X\n",
240 nxt6000_readreg(fe, OFDM_TPS_RCVD_4));
241 pr_info("OFDM_TPS_RESERVED_1: 0x%02X\n",
242 nxt6000_readreg(fe, OFDM_TPS_RESERVED_1));
243 pr_info("OFDM_TPS_RESERVED_2: 0x%02X\n",
244 nxt6000_readreg(fe, OFDM_TPS_RESERVED_2));
245#endif
246 pr_info("NXT6000 status:");
231 247
232 val = nxt6000_readreg(state, RS_COR_STAT); 248 val = nxt6000_readreg(state, RS_COR_STAT);
233 249
234 printk(" DATA DESCR LOCK: %d,", val & 0x01); 250 pr_cont(" DATA DESCR LOCK: %d,", val & 0x01);
235 printk(" DATA SYNC LOCK: %d,", (val >> 1) & 0x01); 251 pr_cont(" DATA SYNC LOCK: %d,", (val >> 1) & 0x01);
236 252
237 val = nxt6000_readreg(state, VIT_SYNC_STATUS); 253 val = nxt6000_readreg(state, VIT_SYNC_STATUS);
238 254
239 printk(" VITERBI LOCK: %d,", (val >> 7) & 0x01); 255 pr_cont(" VITERBI LOCK: %d,", (val >> 7) & 0x01);
240 256
241 switch ((val >> 4) & 0x07) { 257 switch ((val >> 4) & 0x07) {
242 258
243 case 0x00: 259 case 0x00:
244 printk(" VITERBI CODERATE: 1/2,"); 260 pr_cont(" VITERBI CODERATE: 1/2,");
245 break; 261 break;
246 262
247 case 0x01: 263 case 0x01:
248 printk(" VITERBI CODERATE: 2/3,"); 264 pr_cont(" VITERBI CODERATE: 2/3,");
249 break; 265 break;
250 266
251 case 0x02: 267 case 0x02:
252 printk(" VITERBI CODERATE: 3/4,"); 268 pr_cont(" VITERBI CODERATE: 3/4,");
253 break; 269 break;
254 270
255 case 0x03: 271 case 0x03:
256 printk(" VITERBI CODERATE: 5/6,"); 272 pr_cont(" VITERBI CODERATE: 5/6,");
257 break; 273 break;
258 274
259 case 0x04: 275 case 0x04:
260 printk(" VITERBI CODERATE: 7/8,"); 276 pr_cont(" VITERBI CODERATE: 7/8,");
261 break; 277 break;
262 278
263 default: 279 default:
264 printk(" VITERBI CODERATE: Reserved,"); 280 pr_cont(" VITERBI CODERATE: Reserved,");
265 281
266 } 282 }
267 283
268 val = nxt6000_readreg(state, OFDM_COR_STAT); 284 val = nxt6000_readreg(state, OFDM_COR_STAT);
269 285
270 printk(" CHCTrack: %d,", (val >> 7) & 0x01); 286 pr_cont(" CHCTrack: %d,", (val >> 7) & 0x01);
271 printk(" TPSLock: %d,", (val >> 6) & 0x01); 287 pr_cont(" TPSLock: %d,", (val >> 6) & 0x01);
272 printk(" SYRLock: %d,", (val >> 5) & 0x01); 288 pr_cont(" SYRLock: %d,", (val >> 5) & 0x01);
273 printk(" AGCLock: %d,", (val >> 4) & 0x01); 289 pr_cont(" AGCLock: %d,", (val >> 4) & 0x01);
274 290
275 switch (val & 0x0F) { 291 switch (val & 0x0F) {
276 292
277 case 0x00: 293 case 0x00:
278 printk(" CoreState: IDLE,"); 294 pr_cont(" CoreState: IDLE,");
279 break; 295 break;
280 296
281 case 0x02: 297 case 0x02:
282 printk(" CoreState: WAIT_AGC,"); 298 pr_cont(" CoreState: WAIT_AGC,");
283 break; 299 break;
284 300
285 case 0x03: 301 case 0x03:
286 printk(" CoreState: WAIT_SYR,"); 302 pr_cont(" CoreState: WAIT_SYR,");
287 break; 303 break;
288 304
289 case 0x04: 305 case 0x04:
290 printk(" CoreState: WAIT_PPM,"); 306 pr_cont(" CoreState: WAIT_PPM,");
291 break; 307 break;
292 308
293 case 0x01: 309 case 0x01:
294 printk(" CoreState: WAIT_TRL,"); 310 pr_cont(" CoreState: WAIT_TRL,");
295 break; 311 break;
296 312
297 case 0x05: 313 case 0x05:
298 printk(" CoreState: WAIT_TPS,"); 314 pr_cont(" CoreState: WAIT_TPS,");
299 break; 315 break;
300 316
301 case 0x06: 317 case 0x06:
302 printk(" CoreState: MONITOR_TPS,"); 318 pr_cont(" CoreState: MONITOR_TPS,");
303 break; 319 break;
304 320
305 default: 321 default:
306 printk(" CoreState: Reserved,"); 322 pr_cont(" CoreState: Reserved,");
307 323
308 } 324 }
309 325
310 val = nxt6000_readreg(state, OFDM_SYR_STAT); 326 val = nxt6000_readreg(state, OFDM_SYR_STAT);
311 327
312 printk(" SYRLock: %d,", (val >> 4) & 0x01); 328 pr_cont(" SYRLock: %d,", (val >> 4) & 0x01);
313 printk(" SYRMode: %s,", (val >> 2) & 0x01 ? "8K" : "2K"); 329 pr_cont(" SYRMode: %s,", (val >> 2) & 0x01 ? "8K" : "2K");
314 330
315 switch ((val >> 4) & 0x03) { 331 switch ((val >> 4) & 0x03) {
316 332
317 case 0x00: 333 case 0x00:
318 printk(" SYRGuard: 1/32,"); 334 pr_cont(" SYRGuard: 1/32,");
319 break; 335 break;
320 336
321 case 0x01: 337 case 0x01:
322 printk(" SYRGuard: 1/16,"); 338 pr_cont(" SYRGuard: 1/16,");
323 break; 339 break;
324 340
325 case 0x02: 341 case 0x02:
326 printk(" SYRGuard: 1/8,"); 342 pr_cont(" SYRGuard: 1/8,");
327 break; 343 break;
328 344
329 case 0x03: 345 case 0x03:
330 printk(" SYRGuard: 1/4,"); 346 pr_cont(" SYRGuard: 1/4,");
331 break; 347 break;
332 } 348 }
333 349
@@ -336,77 +352,77 @@ static void nxt6000_dump_status(struct nxt6000_state *state)
336 switch ((val >> 4) & 0x07) { 352 switch ((val >> 4) & 0x07) {
337 353
338 case 0x00: 354 case 0x00:
339 printk(" TPSLP: 1/2,"); 355 pr_cont(" TPSLP: 1/2,");
340 break; 356 break;
341 357
342 case 0x01: 358 case 0x01:
343 printk(" TPSLP: 2/3,"); 359 pr_cont(" TPSLP: 2/3,");
344 break; 360 break;
345 361
346 case 0x02: 362 case 0x02:
347 printk(" TPSLP: 3/4,"); 363 pr_cont(" TPSLP: 3/4,");
348 break; 364 break;
349 365
350 case 0x03: 366 case 0x03:
351 printk(" TPSLP: 5/6,"); 367 pr_cont(" TPSLP: 5/6,");
352 break; 368 break;
353 369
354 case 0x04: 370 case 0x04:
355 printk(" TPSLP: 7/8,"); 371 pr_cont(" TPSLP: 7/8,");
356 break; 372 break;
357 373
358 default: 374 default:
359 printk(" TPSLP: Reserved,"); 375 pr_cont(" TPSLP: Reserved,");
360 376
361 } 377 }
362 378
363 switch (val & 0x07) { 379 switch (val & 0x07) {
364 380
365 case 0x00: 381 case 0x00:
366 printk(" TPSHP: 1/2,"); 382 pr_cont(" TPSHP: 1/2,");
367 break; 383 break;
368 384
369 case 0x01: 385 case 0x01:
370 printk(" TPSHP: 2/3,"); 386 pr_cont(" TPSHP: 2/3,");
371 break; 387 break;
372 388
373 case 0x02: 389 case 0x02:
374 printk(" TPSHP: 3/4,"); 390 pr_cont(" TPSHP: 3/4,");
375 break; 391 break;
376 392
377 case 0x03: 393 case 0x03:
378 printk(" TPSHP: 5/6,"); 394 pr_cont(" TPSHP: 5/6,");
379 break; 395 break;
380 396
381 case 0x04: 397 case 0x04:
382 printk(" TPSHP: 7/8,"); 398 pr_cont(" TPSHP: 7/8,");
383 break; 399 break;
384 400
385 default: 401 default:
386 printk(" TPSHP: Reserved,"); 402 pr_cont(" TPSHP: Reserved,");
387 403
388 } 404 }
389 405
390 val = nxt6000_readreg(state, OFDM_TPS_RCVD_4); 406 val = nxt6000_readreg(state, OFDM_TPS_RCVD_4);
391 407
392 printk(" TPSMode: %s,", val & 0x01 ? "8K" : "2K"); 408 pr_cont(" TPSMode: %s,", val & 0x01 ? "8K" : "2K");
393 409
394 switch ((val >> 4) & 0x03) { 410 switch ((val >> 4) & 0x03) {
395 411
396 case 0x00: 412 case 0x00:
397 printk(" TPSGuard: 1/32,"); 413 pr_cont(" TPSGuard: 1/32,");
398 break; 414 break;
399 415
400 case 0x01: 416 case 0x01:
401 printk(" TPSGuard: 1/16,"); 417 pr_cont(" TPSGuard: 1/16,");
402 break; 418 break;
403 419
404 case 0x02: 420 case 0x02:
405 printk(" TPSGuard: 1/8,"); 421 pr_cont(" TPSGuard: 1/8,");
406 break; 422 break;
407 423
408 case 0x03: 424 case 0x03:
409 printk(" TPSGuard: 1/4,"); 425 pr_cont(" TPSGuard: 1/4,");
410 break; 426 break;
411 427
412 } 428 }
@@ -416,8 +432,8 @@ static void nxt6000_dump_status(struct nxt6000_state *state)
416 val = nxt6000_readreg(state, RF_AGC_STATUS); 432 val = nxt6000_readreg(state, RF_AGC_STATUS);
417 val = nxt6000_readreg(state, RF_AGC_STATUS); 433 val = nxt6000_readreg(state, RF_AGC_STATUS);
418 434
419 printk(" RF AGC LOCK: %d,", (val >> 4) & 0x01); 435 pr_cont(" RF AGC LOCK: %d,", (val >> 4) & 0x01);
420 printk("\n"); 436 pr_cont("\n");
421} 437}
422 438
423static int nxt6000_read_status(struct dvb_frontend *fe, enum fe_status *status) 439static int nxt6000_read_status(struct dvb_frontend *fe, enum fe_status *status)
@@ -548,7 +564,7 @@ static int nxt6000_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
548 } 564 }
549} 565}
550 566
551static struct dvb_frontend_ops nxt6000_ops; 567static const struct dvb_frontend_ops nxt6000_ops;
552 568
553struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config, 569struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config,
554 struct i2c_adapter* i2c) 570 struct i2c_adapter* i2c)
@@ -576,7 +592,7 @@ error:
576 return NULL; 592 return NULL;
577} 593}
578 594
579static struct dvb_frontend_ops nxt6000_ops = { 595static const struct dvb_frontend_ops nxt6000_ops = {
580 .delsys = { SYS_DVBT }, 596 .delsys = { SYS_DVBT },
581 .info = { 597 .info = {
582 .name = "NxtWave NXT6000 DVB-T", 598 .name = "NxtWave NXT6000 DVB-T",
diff --git a/drivers/media/dvb-frontends/or51132.c b/drivers/media/dvb-frontends/or51132.c
index a165af990672..17bdadd7d0e1 100644
--- a/drivers/media/dvb-frontends/or51132.c
+++ b/drivers/media/dvb-frontends/or51132.c
@@ -342,15 +342,13 @@ static int or51132_set_parameters(struct dvb_frontend *fe)
342 fwname); 342 fwname);
343 ret = request_firmware(&fw, fwname, state->i2c->dev.parent); 343 ret = request_firmware(&fw, fwname, state->i2c->dev.parent);
344 if (ret) { 344 if (ret) {
345 printk(KERN_WARNING "or51132: No firmware up" 345 printk(KERN_WARNING "or51132: No firmware uploaded(timeout or file not found?)\n");
346 "loaded(timeout or file not found?)\n");
347 return ret; 346 return ret;
348 } 347 }
349 ret = or51132_load_firmware(fe, fw); 348 ret = or51132_load_firmware(fe, fw);
350 release_firmware(fw); 349 release_firmware(fw);
351 if (ret) { 350 if (ret) {
352 printk(KERN_WARNING "or51132: Writing firmware to " 351 printk(KERN_WARNING "or51132: Writing firmware to device failed!\n");
353 "device failed!\n");
354 return ret; 352 return ret;
355 } 353 }
356 printk("or51132: Firmware upload complete.\n"); 354 printk("or51132: Firmware upload complete.\n");
@@ -561,7 +559,7 @@ static void or51132_release(struct dvb_frontend* fe)
561 kfree(state); 559 kfree(state);
562} 560}
563 561
564static struct dvb_frontend_ops or51132_ops; 562static const struct dvb_frontend_ops or51132_ops;
565 563
566struct dvb_frontend* or51132_attach(const struct or51132_config* config, 564struct dvb_frontend* or51132_attach(const struct or51132_config* config,
567 struct i2c_adapter* i2c) 565 struct i2c_adapter* i2c)
@@ -585,7 +583,7 @@ struct dvb_frontend* or51132_attach(const struct or51132_config* config,
585 return &state->frontend; 583 return &state->frontend;
586} 584}
587 585
588static struct dvb_frontend_ops or51132_ops = { 586static const struct dvb_frontend_ops or51132_ops = {
589 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B }, 587 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
590 .info = { 588 .info = {
591 .name = "Oren OR51132 VSB/QAM Frontend", 589 .name = "Oren OR51132 VSB/QAM Frontend",
diff --git a/drivers/media/dvb-frontends/or51211.c b/drivers/media/dvb-frontends/or51211.c
index e82413b975e6..27eb73aa4f62 100644
--- a/drivers/media/dvb-frontends/or51211.c
+++ b/drivers/media/dvb-frontends/or51211.c
@@ -377,8 +377,7 @@ static int or51211_init(struct dvb_frontend* fe)
377 OR51211_DEFAULT_FIRMWARE); 377 OR51211_DEFAULT_FIRMWARE);
378 pr_info("Got Hotplug firmware\n"); 378 pr_info("Got Hotplug firmware\n");
379 if (ret) { 379 if (ret) {
380 pr_warn("No firmware uploaded " 380 pr_warn("No firmware uploaded (timeout or file not found?)\n");
381 "(timeout or file not found?)\n");
382 return ret; 381 return ret;
383 } 382 }
384 383
@@ -508,7 +507,7 @@ static void or51211_release(struct dvb_frontend* fe)
508 kfree(state); 507 kfree(state);
509} 508}
510 509
511static struct dvb_frontend_ops or51211_ops; 510static const struct dvb_frontend_ops or51211_ops;
512 511
513struct dvb_frontend* or51211_attach(const struct or51211_config* config, 512struct dvb_frontend* or51211_attach(const struct or51211_config* config,
514 struct i2c_adapter* i2c) 513 struct i2c_adapter* i2c)
@@ -532,7 +531,7 @@ struct dvb_frontend* or51211_attach(const struct or51211_config* config,
532 return &state->frontend; 531 return &state->frontend;
533} 532}
534 533
535static struct dvb_frontend_ops or51211_ops = { 534static const struct dvb_frontend_ops or51211_ops = {
536 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B }, 535 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
537 .info = { 536 .info = {
538 .name = "Oren OR51211 VSB Frontend", 537 .name = "Oren OR51211 VSB Frontend",
diff --git a/drivers/media/dvb-frontends/rtl2830.c b/drivers/media/dvb-frontends/rtl2830.c
index 87226056f226..7bbfe11d11ed 100644
--- a/drivers/media/dvb-frontends/rtl2830.c
+++ b/drivers/media/dvb-frontends/rtl2830.c
@@ -548,7 +548,7 @@ static int rtl2830_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
548 return 0; 548 return 0;
549} 549}
550 550
551static struct dvb_frontend_ops rtl2830_ops = { 551static const struct dvb_frontend_ops rtl2830_ops = {
552 .delsys = {SYS_DVBT}, 552 .delsys = {SYS_DVBT},
553 .info = { 553 .info = {
554 .name = "Realtek RTL2830 (DVB-T)", 554 .name = "Realtek RTL2830 (DVB-T)",
diff --git a/drivers/media/dvb-frontends/rtl2832.c b/drivers/media/dvb-frontends/rtl2832.c
index 0ced01f1012e..94bf5b7d6f3f 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -837,7 +837,7 @@ static int rtl2832_deselect(struct i2c_mux_core *muxc, u32 chan_id)
837 return 0; 837 return 0;
838} 838}
839 839
840static struct dvb_frontend_ops rtl2832_ops = { 840static const struct dvb_frontend_ops rtl2832_ops = {
841 .delsys = { SYS_DVBT }, 841 .delsys = { SYS_DVBT },
842 .info = { 842 .info = {
843 .name = "Realtek RTL2832 (DVB-T)", 843 .name = "Realtek RTL2832 (DVB-T)",
diff --git a/drivers/media/dvb-frontends/s5h1409.c b/drivers/media/dvb-frontends/s5h1409.c
index c68965ad97c0..f370c6df0a8b 100644
--- a/drivers/media/dvb-frontends/s5h1409.c
+++ b/drivers/media/dvb-frontends/s5h1409.c
@@ -321,8 +321,8 @@ static int s5h1409_writereg(struct s5h1409_state *state, u8 reg, u16 data)
321 ret = i2c_transfer(state->i2c, &msg, 1); 321 ret = i2c_transfer(state->i2c, &msg, 1);
322 322
323 if (ret != 1) 323 if (ret != 1)
324 printk(KERN_ERR "%s: error (reg == 0x%02x, val == 0x%04x, " 324 printk(KERN_ERR "%s: error (reg == 0x%02x, val == 0x%04x, ret == %i)\n",
325 "ret == %i)\n", __func__, reg, data, ret); 325 __func__, reg, data, ret);
326 326
327 return (ret != 1) ? -1 : 0; 327 return (ret != 1) ? -1 : 0;
328} 328}
@@ -949,7 +949,7 @@ static void s5h1409_release(struct dvb_frontend *fe)
949 kfree(state); 949 kfree(state);
950} 950}
951 951
952static struct dvb_frontend_ops s5h1409_ops; 952static const struct dvb_frontend_ops s5h1409_ops;
953 953
954struct dvb_frontend *s5h1409_attach(const struct s5h1409_config *config, 954struct dvb_frontend *s5h1409_attach(const struct s5h1409_config *config,
955 struct i2c_adapter *i2c) 955 struct i2c_adapter *i2c)
@@ -995,7 +995,7 @@ error:
995} 995}
996EXPORT_SYMBOL(s5h1409_attach); 996EXPORT_SYMBOL(s5h1409_attach);
997 997
998static struct dvb_frontend_ops s5h1409_ops = { 998static const struct dvb_frontend_ops s5h1409_ops = {
999 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B }, 999 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
1000 .info = { 1000 .info = {
1001 .name = "Samsung S5H1409 QAM/8VSB Frontend", 1001 .name = "Samsung S5H1409 QAM/8VSB Frontend",
diff --git a/drivers/media/dvb-frontends/s5h1411.c b/drivers/media/dvb-frontends/s5h1411.c
index 90f86e82b087..f29750a96196 100644
--- a/drivers/media/dvb-frontends/s5h1411.c
+++ b/drivers/media/dvb-frontends/s5h1411.c
@@ -350,8 +350,8 @@ static int s5h1411_writereg(struct s5h1411_state *state,
350 ret = i2c_transfer(state->i2c, &msg, 1); 350 ret = i2c_transfer(state->i2c, &msg, 1);
351 351
352 if (ret != 1) 352 if (ret != 1)
353 printk(KERN_ERR "%s: writereg error 0x%02x 0x%02x 0x%04x, " 353 printk(KERN_ERR "%s: writereg error 0x%02x 0x%02x 0x%04x, ret == %i)\n",
354 "ret == %i)\n", __func__, addr, reg, data, ret); 354 __func__, addr, reg, data, ret);
355 355
356 return (ret != 1) ? -1 : 0; 356 return (ret != 1) ? -1 : 0;
357} 357}
@@ -864,7 +864,7 @@ static void s5h1411_release(struct dvb_frontend *fe)
864 kfree(state); 864 kfree(state);
865} 865}
866 866
867static struct dvb_frontend_ops s5h1411_ops; 867static const struct dvb_frontend_ops s5h1411_ops;
868 868
869struct dvb_frontend *s5h1411_attach(const struct s5h1411_config *config, 869struct dvb_frontend *s5h1411_attach(const struct s5h1411_config *config,
870 struct i2c_adapter *i2c) 870 struct i2c_adapter *i2c)
@@ -914,7 +914,7 @@ error:
914} 914}
915EXPORT_SYMBOL(s5h1411_attach); 915EXPORT_SYMBOL(s5h1411_attach);
916 916
917static struct dvb_frontend_ops s5h1411_ops = { 917static const struct dvb_frontend_ops s5h1411_ops = {
918 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B }, 918 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
919 .info = { 919 .info = {
920 .name = "Samsung S5H1411 QAM/8VSB Frontend", 920 .name = "Samsung S5H1411 QAM/8VSB Frontend",
diff --git a/drivers/media/dvb-frontends/s5h1420.c b/drivers/media/dvb-frontends/s5h1420.c
index d7d0b7d57ad7..f9a18fe94d88 100644
--- a/drivers/media/dvb-frontends/s5h1420.c
+++ b/drivers/media/dvb-frontends/s5h1420.c
@@ -880,7 +880,7 @@ struct i2c_adapter *s5h1420_get_tuner_i2c_adapter(struct dvb_frontend *fe)
880} 880}
881EXPORT_SYMBOL(s5h1420_get_tuner_i2c_adapter); 881EXPORT_SYMBOL(s5h1420_get_tuner_i2c_adapter);
882 882
883static struct dvb_frontend_ops s5h1420_ops; 883static const struct dvb_frontend_ops s5h1420_ops;
884 884
885struct dvb_frontend *s5h1420_attach(const struct s5h1420_config *config, 885struct dvb_frontend *s5h1420_attach(const struct s5h1420_config *config,
886 struct i2c_adapter *i2c) 886 struct i2c_adapter *i2c)
@@ -934,7 +934,7 @@ error:
934} 934}
935EXPORT_SYMBOL(s5h1420_attach); 935EXPORT_SYMBOL(s5h1420_attach);
936 936
937static struct dvb_frontend_ops s5h1420_ops = { 937static const struct dvb_frontend_ops s5h1420_ops = {
938 .delsys = { SYS_DVBS }, 938 .delsys = { SYS_DVBS },
939 .info = { 939 .info = {
940 .name = "Samsung S5H1420/PnpNetwork PN1010 DVB-S", 940 .name = "Samsung S5H1420/PnpNetwork PN1010 DVB-S",
diff --git a/drivers/media/dvb-frontends/s5h1432.c b/drivers/media/dvb-frontends/s5h1432.c
index 4215652f8eb7..a32fd9bc51a9 100644
--- a/drivers/media/dvb-frontends/s5h1432.c
+++ b/drivers/media/dvb-frontends/s5h1432.c
@@ -63,8 +63,8 @@ static int s5h1432_writereg(struct s5h1432_state *state,
63 ret = i2c_transfer(state->i2c, &msg, 1); 63 ret = i2c_transfer(state->i2c, &msg, 1);
64 64
65 if (ret != 1) 65 if (ret != 1)
66 printk(KERN_ERR "%s: writereg error 0x%02x 0x%02x 0x%04x, " 66 printk(KERN_ERR "%s: writereg error 0x%02x 0x%02x 0x%04x, ret == %i)\n",
67 "ret == %i)\n", __func__, addr, reg, data, ret); 67 __func__, addr, reg, data, ret);
68 68
69 return (ret != 1) ? -1 : 0; 69 return (ret != 1) ? -1 : 0;
70} 70}
@@ -341,7 +341,7 @@ static void s5h1432_release(struct dvb_frontend *fe)
341 kfree(state); 341 kfree(state);
342} 342}
343 343
344static struct dvb_frontend_ops s5h1432_ops; 344static const struct dvb_frontend_ops s5h1432_ops;
345 345
346struct dvb_frontend *s5h1432_attach(const struct s5h1432_config *config, 346struct dvb_frontend *s5h1432_attach(const struct s5h1432_config *config,
347 struct i2c_adapter *i2c) 347 struct i2c_adapter *i2c)
@@ -370,7 +370,7 @@ struct dvb_frontend *s5h1432_attach(const struct s5h1432_config *config,
370} 370}
371EXPORT_SYMBOL(s5h1432_attach); 371EXPORT_SYMBOL(s5h1432_attach);
372 372
373static struct dvb_frontend_ops s5h1432_ops = { 373static const struct dvb_frontend_ops s5h1432_ops = {
374 .delsys = { SYS_DVBT }, 374 .delsys = { SYS_DVBT },
375 .info = { 375 .info = {
376 .name = "Samsung s5h1432 DVB-T Frontend", 376 .name = "Samsung s5h1432 DVB-T Frontend",
diff --git a/drivers/media/dvb-frontends/s921.c b/drivers/media/dvb-frontends/s921.c
index b5e3d90eba5e..274544a3ae0e 100644
--- a/drivers/media/dvb-frontends/s921.c
+++ b/drivers/media/dvb-frontends/s921.c
@@ -214,8 +214,8 @@ static int s921_i2c_writereg(struct s921_state *state,
214 214
215 rc = i2c_transfer(state->i2c, &msg, 1); 215 rc = i2c_transfer(state->i2c, &msg, 1);
216 if (rc != 1) { 216 if (rc != 1) {
217 printk("%s: writereg rcor(rc == %i, reg == 0x%02x," 217 printk("%s: writereg rcor(rc == %i, reg == 0x%02x, data == 0x%02x)\n",
218 " data == 0x%02x)\n", __func__, rc, reg, data); 218 __func__, rc, reg, data);
219 return rc; 219 return rc;
220 } 220 }
221 221
@@ -477,7 +477,7 @@ static void s921_release(struct dvb_frontend *fe)
477 kfree(state); 477 kfree(state);
478} 478}
479 479
480static struct dvb_frontend_ops s921_ops; 480static const struct dvb_frontend_ops s921_ops;
481 481
482struct dvb_frontend *s921_attach(const struct s921_config *config, 482struct dvb_frontend *s921_attach(const struct s921_config *config,
483 struct i2c_adapter *i2c) 483 struct i2c_adapter *i2c)
@@ -505,7 +505,7 @@ struct dvb_frontend *s921_attach(const struct s921_config *config,
505} 505}
506EXPORT_SYMBOL(s921_attach); 506EXPORT_SYMBOL(s921_attach);
507 507
508static struct dvb_frontend_ops s921_ops = { 508static const struct dvb_frontend_ops s921_ops = {
509 .delsys = { SYS_ISDBT }, 509 .delsys = { SYS_ISDBT },
510 /* Use dib8000 values per default */ 510 /* Use dib8000 values per default */
511 .info = { 511 .info = {
diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index 78669ea68c61..528b82a5dd46 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -978,7 +978,7 @@ static int si2165_set_frontend(struct dvb_frontend *fe)
978 return 0; 978 return 0;
979} 979}
980 980
981static struct dvb_frontend_ops si2165_ops = { 981static const struct dvb_frontend_ops si2165_ops = {
982 .info = { 982 .info = {
983 .name = "Silicon Labs ", 983 .name = "Silicon Labs ",
984 /* For DVB-C */ 984 /* For DVB-C */
diff --git a/drivers/media/dvb-frontends/si21xx.c b/drivers/media/dvb-frontends/si21xx.c
index 62ad7a7be9f8..4e8c3ac4303f 100644
--- a/drivers/media/dvb-frontends/si21xx.c
+++ b/drivers/media/dvb-frontends/si21xx.c
@@ -245,8 +245,8 @@ static int si21_writeregs(struct si21xx_state *state, u8 reg1,
245 ret = i2c_transfer(state->i2c, &msg, 1); 245 ret = i2c_transfer(state->i2c, &msg, 1);
246 246
247 if (ret != 1) 247 if (ret != 1)
248 dprintk("%s: writereg error (reg1 == 0x%02x, data == 0x%02x, " 248 dprintk("%s: writereg error (reg1 == 0x%02x, data == 0x%02x, ret == %i)\n",
249 "ret == %i)\n", __func__, reg1, data[0], ret); 249 __func__, reg1, data[0], ret);
250 250
251 return (ret != 1) ? -EREMOTEIO : 0; 251 return (ret != 1) ? -EREMOTEIO : 0;
252} 252}
@@ -265,8 +265,8 @@ static int si21_writereg(struct si21xx_state *state, u8 reg, u8 data)
265 ret = i2c_transfer(state->i2c, &msg, 1); 265 ret = i2c_transfer(state->i2c, &msg, 1);
266 266
267 if (ret != 1) 267 if (ret != 1)
268 dprintk("%s: writereg error (reg == 0x%02x, data == 0x%02x, " 268 dprintk("%s: writereg error (reg == 0x%02x, data == 0x%02x, ret == %i)\n",
269 "ret == %i)\n", __func__, reg, data, ret); 269 __func__, reg, data, ret);
270 270
271 return (ret != 1) ? -EREMOTEIO : 0; 271 return (ret != 1) ? -EREMOTEIO : 0;
272} 272}
@@ -866,7 +866,7 @@ static void si21xx_release(struct dvb_frontend *fe)
866 kfree(state); 866 kfree(state);
867} 867}
868 868
869static struct dvb_frontend_ops si21xx_ops = { 869static const struct dvb_frontend_ops si21xx_ops = {
870 .delsys = { SYS_DVBS }, 870 .delsys = { SYS_DVBS },
871 .info = { 871 .info = {
872 .name = "SL SI21XX DVB-S", 872 .name = "SL SI21XX DVB-S",
diff --git a/drivers/media/dvb-frontends/sp8870.c b/drivers/media/dvb-frontends/sp8870.c
index e87ac30d7fb8..04454cb78467 100644
--- a/drivers/media/dvb-frontends/sp8870.c
+++ b/drivers/media/dvb-frontends/sp8870.c
@@ -551,7 +551,7 @@ static void sp8870_release(struct dvb_frontend* fe)
551 kfree(state); 551 kfree(state);
552} 552}
553 553
554static struct dvb_frontend_ops sp8870_ops; 554static const struct dvb_frontend_ops sp8870_ops;
555 555
556struct dvb_frontend* sp8870_attach(const struct sp8870_config* config, 556struct dvb_frontend* sp8870_attach(const struct sp8870_config* config,
557 struct i2c_adapter* i2c) 557 struct i2c_adapter* i2c)
@@ -580,7 +580,7 @@ error:
580 return NULL; 580 return NULL;
581} 581}
582 582
583static struct dvb_frontend_ops sp8870_ops = { 583static const struct dvb_frontend_ops sp8870_ops = {
584 .delsys = { SYS_DVBT }, 584 .delsys = { SYS_DVBT },
585 .info = { 585 .info = {
586 .name = "Spase SP8870 DVB-T", 586 .name = "Spase SP8870 DVB-T",
diff --git a/drivers/media/dvb-frontends/sp887x.c b/drivers/media/dvb-frontends/sp887x.c
index 4378fe1b978e..7c511c3cd4ca 100644
--- a/drivers/media/dvb-frontends/sp887x.c
+++ b/drivers/media/dvb-frontends/sp887x.c
@@ -63,8 +63,7 @@ static int sp887x_writereg (struct sp887x_state* state, u16 reg, u16 data)
63 if (!(reg == 0xf1a && data == 0x000 && 63 if (!(reg == 0xf1a && data == 0x000 &&
64 (ret == -EREMOTEIO || ret == -EFAULT))) 64 (ret == -EREMOTEIO || ret == -EFAULT)))
65 { 65 {
66 printk("%s: writereg error " 66 printk("%s: writereg error (reg %03x, data %03x, ret == %i)\n",
67 "(reg %03x, data %03x, ret == %i)\n",
68 __func__, reg & 0xffff, data & 0xffff, ret); 67 __func__, reg & 0xffff, data & 0xffff, ret);
69 return ret; 68 return ret;
70 } 69 }
@@ -562,7 +561,7 @@ static void sp887x_release(struct dvb_frontend* fe)
562 kfree(state); 561 kfree(state);
563} 562}
564 563
565static struct dvb_frontend_ops sp887x_ops; 564static const struct dvb_frontend_ops sp887x_ops;
566 565
567struct dvb_frontend* sp887x_attach(const struct sp887x_config* config, 566struct dvb_frontend* sp887x_attach(const struct sp887x_config* config,
568 struct i2c_adapter* i2c) 567 struct i2c_adapter* i2c)
@@ -591,7 +590,7 @@ error:
591 return NULL; 590 return NULL;
592} 591}
593 592
594static struct dvb_frontend_ops sp887x_ops = { 593static const struct dvb_frontend_ops sp887x_ops = {
595 .delsys = { SYS_DVBT }, 594 .delsys = { SYS_DVBT },
596 .info = { 595 .info = {
597 .name = "Spase SP887x DVB-T", 596 .name = "Spase SP887x DVB-T",
diff --git a/drivers/media/dvb-frontends/stb0899_drv.c b/drivers/media/dvb-frontends/stb0899_drv.c
index 3d171b0e00c2..02347598277a 100644
--- a/drivers/media/dvb-frontends/stb0899_drv.c
+++ b/drivers/media/dvb-frontends/stb0899_drv.c
@@ -485,15 +485,8 @@ int stb0899_read_regs(struct stb0899_state *state, unsigned int reg, u8 *buf, u3
485 (((reg & 0xff00) == 0xf200) || ((reg & 0xff00) == 0xf600))) 485 (((reg & 0xff00) == 0xf200) || ((reg & 0xff00) == 0xf600)))
486 _stb0899_read_reg(state, (reg | 0x00ff)); 486 _stb0899_read_reg(state, (reg | 0x00ff));
487 487
488 if (unlikely(*state->verbose >= FE_DEBUGREG)) { 488 dprintk(state->verbose, FE_DEBUGREG, 1,
489 int i; 489 "%s [0x%04x]: %*ph", __func__, reg, count, buf);
490
491 printk(KERN_DEBUG "%s [0x%04x]:", __func__, reg);
492 for (i = 0; i < count; i++) {
493 printk(" %02x", buf[i]);
494 }
495 printk("\n");
496 }
497 490
498 return 0; 491 return 0;
499err: 492err:
@@ -522,14 +515,8 @@ int stb0899_write_regs(struct stb0899_state *state, unsigned int reg, u8 *data,
522 buf[1] = reg & 0xff; 515 buf[1] = reg & 0xff;
523 memcpy(&buf[2], data, count); 516 memcpy(&buf[2], data, count);
524 517
525 if (unlikely(*state->verbose >= FE_DEBUGREG)) { 518 dprintk(state->verbose, FE_DEBUGREG, 1,
526 int i; 519 "%s [0x%04x]: %*ph", __func__, reg, count, data);
527
528 printk(KERN_DEBUG "%s [0x%04x]:", __func__, reg);
529 for (i = 0; i < count; i++)
530 printk(" %02x", data[i]);
531 printk("\n");
532 }
533 ret = i2c_transfer(state->i2c, &i2c_msg, 1); 520 ret = i2c_transfer(state->i2c, &i2c_msg, 1);
534 521
535 /* 522 /*
@@ -614,13 +601,19 @@ static int stb0899_postproc(struct stb0899_state *state, u8 ctl, int enable)
614 return 0; 601 return 0;
615} 602}
616 603
617static void stb0899_release(struct dvb_frontend *fe) 604static void stb0899_detach(struct dvb_frontend *fe)
618{ 605{
619 struct stb0899_state *state = fe->demodulator_priv; 606 struct stb0899_state *state = fe->demodulator_priv;
620 607
621 dprintk(state->verbose, FE_DEBUG, 1, "Release Frontend");
622 /* post process event */ 608 /* post process event */
623 stb0899_postproc(state, STB0899_POSTPROC_GPIO_POWER, 0); 609 stb0899_postproc(state, STB0899_POSTPROC_GPIO_POWER, 0);
610}
611
612static void stb0899_release(struct dvb_frontend *fe)
613{
614 struct stb0899_state *state = fe->demodulator_priv;
615
616 dprintk(state->verbose, FE_DEBUG, 1, "Release Frontend");
624 kfree(state); 617 kfree(state);
625} 618}
626 619
@@ -1586,7 +1579,7 @@ static enum dvbfe_algo stb0899_frontend_algo(struct dvb_frontend *fe)
1586 return DVBFE_ALGO_CUSTOM; 1579 return DVBFE_ALGO_CUSTOM;
1587} 1580}
1588 1581
1589static struct dvb_frontend_ops stb0899_ops = { 1582static const struct dvb_frontend_ops stb0899_ops = {
1590 .delsys = { SYS_DVBS, SYS_DVBS2, SYS_DSS }, 1583 .delsys = { SYS_DVBS, SYS_DVBS2, SYS_DSS },
1591 .info = { 1584 .info = {
1592 .name = "STB0899 Multistandard", 1585 .name = "STB0899 Multistandard",
@@ -1603,6 +1596,7 @@ static struct dvb_frontend_ops stb0899_ops = {
1603 FE_CAN_QPSK 1596 FE_CAN_QPSK
1604 }, 1597 },
1605 1598
1599 .detach = stb0899_detach,
1606 .release = stb0899_release, 1600 .release = stb0899_release,
1607 .init = stb0899_init, 1601 .init = stb0899_init,
1608 .sleep = stb0899_sleep, 1602 .sleep = stb0899_sleep,
diff --git a/drivers/media/dvb-frontends/stb6000.c b/drivers/media/dvb-frontends/stb6000.c
index 73347d51f340..69c03892f2da 100644
--- a/drivers/media/dvb-frontends/stb6000.c
+++ b/drivers/media/dvb-frontends/stb6000.c
@@ -41,11 +41,10 @@ struct stb6000_priv {
41 u32 frequency; 41 u32 frequency;
42}; 42};
43 43
44static int stb6000_release(struct dvb_frontend *fe) 44static void stb6000_release(struct dvb_frontend *fe)
45{ 45{
46 kfree(fe->tuner_priv); 46 kfree(fe->tuner_priv);
47 fe->tuner_priv = NULL; 47 fe->tuner_priv = NULL;
48 return 0;
49} 48}
50 49
51static int stb6000_sleep(struct dvb_frontend *fe) 50static int stb6000_sleep(struct dvb_frontend *fe)
diff --git a/drivers/media/dvb-frontends/stb6100.c b/drivers/media/dvb-frontends/stb6100.c
index 5add1182c3ca..17a955d0031b 100644
--- a/drivers/media/dvb-frontends/stb6100.c
+++ b/drivers/media/dvb-frontends/stb6100.c
@@ -61,7 +61,7 @@ struct stb6100_lkup {
61 u8 reg; 61 u8 reg;
62}; 62};
63 63
64static int stb6100_release(struct dvb_frontend *fe); 64static void stb6100_release(struct dvb_frontend *fe);
65 65
66static const struct stb6100_lkup lkup[] = { 66static const struct stb6100_lkup lkup[] = {
67 { 0, 950000, 0x0a }, 67 { 0, 950000, 0x0a },
@@ -560,14 +560,12 @@ struct dvb_frontend *stb6100_attach(struct dvb_frontend *fe,
560 return fe; 560 return fe;
561} 561}
562 562
563static int stb6100_release(struct dvb_frontend *fe) 563static void stb6100_release(struct dvb_frontend *fe)
564{ 564{
565 struct stb6100_state *state = fe->tuner_priv; 565 struct stb6100_state *state = fe->tuner_priv;
566 566
567 fe->tuner_priv = NULL; 567 fe->tuner_priv = NULL;
568 kfree(state); 568 kfree(state);
569
570 return 0;
571} 569}
572 570
573EXPORT_SYMBOL(stb6100_attach); 571EXPORT_SYMBOL(stb6100_attach);
diff --git a/drivers/media/dvb-frontends/stv0288.c b/drivers/media/dvb-frontends/stv0288.c
index c93d9a45f7f7..45cbc898ad25 100644
--- a/drivers/media/dvb-frontends/stv0288.c
+++ b/drivers/media/dvb-frontends/stv0288.c
@@ -74,8 +74,8 @@ static int stv0288_writeregI(struct stv0288_state *state, u8 reg, u8 data)
74 ret = i2c_transfer(state->i2c, &msg, 1); 74 ret = i2c_transfer(state->i2c, &msg, 1);
75 75
76 if (ret != 1) 76 if (ret != 1)
77 dprintk("%s: writereg error (reg == 0x%02x, val == 0x%02x, " 77 dprintk("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n",
78 "ret == %i)\n", __func__, reg, data, ret); 78 __func__, reg, data, ret);
79 79
80 return (ret != 1) ? -EREMOTEIO : 0; 80 return (ret != 1) ? -EREMOTEIO : 0;
81} 81}
@@ -465,10 +465,9 @@ static int stv0288_set_frontend(struct dvb_frontend *fe)
465 dprintk("%s : FE_SET_FRONTEND\n", __func__); 465 dprintk("%s : FE_SET_FRONTEND\n", __func__);
466 466
467 if (c->delivery_system != SYS_DVBS) { 467 if (c->delivery_system != SYS_DVBS) {
468 dprintk("%s: unsupported delivery " 468 dprintk("%s: unsupported delivery system selected (%d)\n",
469 "system selected (%d)\n", 469 __func__, c->delivery_system);
470 __func__, c->delivery_system); 470 return -EOPNOTSUPP;
471 return -EOPNOTSUPP;
472 } 471 }
473 472
474 if (state->config->set_ts_params) 473 if (state->config->set_ts_params)
@@ -536,7 +535,7 @@ static void stv0288_release(struct dvb_frontend *fe)
536 kfree(state); 535 kfree(state);
537} 536}
538 537
539static struct dvb_frontend_ops stv0288_ops = { 538static const struct dvb_frontend_ops stv0288_ops = {
540 .delsys = { SYS_DVBS }, 539 .delsys = { SYS_DVBS },
541 .info = { 540 .info = {
542 .name = "ST STV0288 DVB-S", 541 .name = "ST STV0288 DVB-S",
diff --git a/drivers/media/dvb-frontends/stv0297.c b/drivers/media/dvb-frontends/stv0297.c
index 81b27b7c0c96..db94d4d109f9 100644
--- a/drivers/media/dvb-frontends/stv0297.c
+++ b/drivers/media/dvb-frontends/stv0297.c
@@ -57,8 +57,8 @@ static int stv0297_writereg(struct stv0297_state *state, u8 reg, u8 data)
57 ret = i2c_transfer(state->i2c, &msg, 1); 57 ret = i2c_transfer(state->i2c, &msg, 1);
58 58
59 if (ret != 1) 59 if (ret != 1)
60 dprintk("%s: writereg error (reg == 0x%02x, val == 0x%02x, " 60 dprintk("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n",
61 "ret == %i)\n", __func__, reg, data, ret); 61 __func__, reg, data, ret);
62 62
63 return (ret != 1) ? -1 : 0; 63 return (ret != 1) ? -1 : 0;
64} 64}
@@ -658,7 +658,7 @@ static void stv0297_release(struct dvb_frontend *fe)
658 kfree(state); 658 kfree(state);
659} 659}
660 660
661static struct dvb_frontend_ops stv0297_ops; 661static const struct dvb_frontend_ops stv0297_ops;
662 662
663struct dvb_frontend *stv0297_attach(const struct stv0297_config *config, 663struct dvb_frontend *stv0297_attach(const struct stv0297_config *config,
664 struct i2c_adapter *i2c) 664 struct i2c_adapter *i2c)
@@ -690,7 +690,7 @@ error:
690 return NULL; 690 return NULL;
691} 691}
692 692
693static struct dvb_frontend_ops stv0297_ops = { 693static const struct dvb_frontend_ops stv0297_ops = {
694 .delsys = { SYS_DVBC_ANNEX_A }, 694 .delsys = { SYS_DVBC_ANNEX_A },
695 .info = { 695 .info = {
696 .name = "ST STV0297 DVB-C", 696 .name = "ST STV0297 DVB-C",
diff --git a/drivers/media/dvb-frontends/stv0299.c b/drivers/media/dvb-frontends/stv0299.c
index 7927fa925f2f..b36b21a13201 100644
--- a/drivers/media/dvb-frontends/stv0299.c
+++ b/drivers/media/dvb-frontends/stv0299.c
@@ -88,8 +88,8 @@ static int stv0299_writeregI (struct stv0299_state* state, u8 reg, u8 data)
88 ret = i2c_transfer (state->i2c, &msg, 1); 88 ret = i2c_transfer (state->i2c, &msg, 1);
89 89
90 if (ret != 1) 90 if (ret != 1)
91 dprintk("%s: writereg error (reg == 0x%02x, val == 0x%02x, " 91 dprintk("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n",
92 "ret == %i)\n", __func__, reg, data, ret); 92 __func__, reg, data, ret);
93 93
94 return (ret != 1) ? -EREMOTEIO : 0; 94 return (ret != 1) ? -EREMOTEIO : 0;
95} 95}
@@ -673,7 +673,7 @@ static void stv0299_release(struct dvb_frontend* fe)
673 kfree(state); 673 kfree(state);
674} 674}
675 675
676static struct dvb_frontend_ops stv0299_ops; 676static const struct dvb_frontend_ops stv0299_ops;
677 677
678struct dvb_frontend* stv0299_attach(const struct stv0299_config* config, 678struct dvb_frontend* stv0299_attach(const struct stv0299_config* config,
679 struct i2c_adapter* i2c) 679 struct i2c_adapter* i2c)
@@ -713,7 +713,7 @@ error:
713 return NULL; 713 return NULL;
714} 714}
715 715
716static struct dvb_frontend_ops stv0299_ops = { 716static const struct dvb_frontend_ops stv0299_ops = {
717 .delsys = { SYS_DVBS }, 717 .delsys = { SYS_DVBS },
718 .info = { 718 .info = {
719 .name = "ST STV0299 DVB-S", 719 .name = "ST STV0299 DVB-S",
@@ -761,8 +761,7 @@ module_param(debug, int, 0644);
761MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); 761MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
762 762
763MODULE_DESCRIPTION("ST STV0299 DVB Demodulator driver"); 763MODULE_DESCRIPTION("ST STV0299 DVB Demodulator driver");
764MODULE_AUTHOR("Ralph Metzler, Holger Waechtler, Peter Schildmann, Felix Domke, " 764MODULE_AUTHOR("Ralph Metzler, Holger Waechtler, Peter Schildmann, Felix Domke, Andreas Oberritter, Andrew de Quincey, Kenneth Aafly");
765 "Andreas Oberritter, Andrew de Quincey, Kenneth Aafly");
766MODULE_LICENSE("GPL"); 765MODULE_LICENSE("GPL");
767 766
768EXPORT_SYMBOL(stv0299_attach); 767EXPORT_SYMBOL(stv0299_attach);
diff --git a/drivers/media/dvb-frontends/stv0367.c b/drivers/media/dvb-frontends/stv0367.c
index abc379aea713..4ac1ce2831ba 100644
--- a/drivers/media/dvb-frontends/stv0367.c
+++ b/drivers/media/dvb-frontends/stv0367.c
@@ -2272,7 +2272,7 @@ static void stv0367_release(struct dvb_frontend *fe)
2272 kfree(state); 2272 kfree(state);
2273} 2273}
2274 2274
2275static struct dvb_frontend_ops stv0367ter_ops = { 2275static const struct dvb_frontend_ops stv0367ter_ops = {
2276 .delsys = { SYS_DVBT }, 2276 .delsys = { SYS_DVBT },
2277 .info = { 2277 .info = {
2278 .name = "ST STV0367 DVB-T", 2278 .name = "ST STV0367 DVB-T",
@@ -3390,7 +3390,7 @@ static int stv0367cab_read_ucblcks(struct dvb_frontend *fe, u32 *ucblocks)
3390 return 0; 3390 return 0;
3391}; 3391};
3392 3392
3393static struct dvb_frontend_ops stv0367cab_ops = { 3393static const struct dvb_frontend_ops stv0367cab_ops = {
3394 .delsys = { SYS_DVBC_ANNEX_A }, 3394 .delsys = { SYS_DVBC_ANNEX_A },
3395 .info = { 3395 .info = {
3396 .name = "ST STV0367 DVB-C", 3396 .name = "ST STV0367 DVB-C",
diff --git a/drivers/media/dvb-frontends/stv0900_core.c b/drivers/media/dvb-frontends/stv0900_core.c
index f667005a6661..43a0f69b4b14 100644
--- a/drivers/media/dvb-frontends/stv0900_core.c
+++ b/drivers/media/dvb-frontends/stv0900_core.c
@@ -1875,7 +1875,7 @@ static int stv0900_get_frontend(struct dvb_frontend *fe,
1875 return 0; 1875 return 0;
1876} 1876}
1877 1877
1878static struct dvb_frontend_ops stv0900_ops = { 1878static const struct dvb_frontend_ops stv0900_ops = {
1879 .delsys = { SYS_DVBS, SYS_DVBS2, SYS_DSS }, 1879 .delsys = { SYS_DVBS, SYS_DVBS2, SYS_DSS },
1880 .info = { 1880 .info = {
1881 .name = "STV0900 frontend", 1881 .name = "STV0900 frontend",
diff --git a/drivers/media/dvb-frontends/stv0900_sw.c b/drivers/media/dvb-frontends/stv0900_sw.c
index fa63a9e929ce..bded82774f4b 100644
--- a/drivers/media/dvb-frontends/stv0900_sw.c
+++ b/drivers/media/dvb-frontends/stv0900_sw.c
@@ -1485,8 +1485,7 @@ static u32 stv0900_search_srate_coarse(struct dvb_frontend *fe)
1485 current_step++; 1485 current_step++;
1486 direction *= -1; 1486 direction *= -1;
1487 1487
1488 dprintk("lock: I2C_DEMOD_MODE_FIELD =0. Search started." 1488 dprintk("lock: I2C_DEMOD_MODE_FIELD =0. Search started. tuner freq=%d agc2=0x%x srate_coarse=%d tmg_cpt=%d\n",
1489 " tuner freq=%d agc2=0x%x srate_coarse=%d tmg_cpt=%d\n",
1490 tuner_freq, agc2_integr, coarse_srate, timingcpt); 1489 tuner_freq, agc2_integr, coarse_srate, timingcpt);
1491 1490
1492 if ((timingcpt >= 5) && 1491 if ((timingcpt >= 5) &&
diff --git a/drivers/media/dvb-frontends/stv090x.c b/drivers/media/dvb-frontends/stv090x.c
index 25bdf6e0f963..7ef469c0c866 100644
--- a/drivers/media/dvb-frontends/stv090x.c
+++ b/drivers/media/dvb-frontends/stv090x.c
@@ -739,14 +739,8 @@ static int stv090x_write_regs(struct stv090x_state *state, unsigned int reg, u8
739 buf[1] = reg & 0xff; 739 buf[1] = reg & 0xff;
740 memcpy(&buf[2], data, count); 740 memcpy(&buf[2], data, count);
741 741
742 if (unlikely(*state->verbose >= FE_DEBUGREG)) { 742 dprintk(FE_DEBUGREG, 1, "%s [0x%04x]: %*ph",
743 int i; 743 __func__, reg, count, data);
744
745 printk(KERN_DEBUG "%s [0x%04x]:", __func__, reg);
746 for (i = 0; i < count; i++)
747 printk(" %02x", data[i]);
748 printk("\n");
749 }
750 744
751 ret = i2c_transfer(state->i2c, &i2c_msg, 1); 745 ret = i2c_transfer(state->i2c, &i2c_msg, 1);
752 if (ret != 1) { 746 if (ret != 1) {
@@ -3698,9 +3692,12 @@ static int stv090x_read_cnr(struct dvb_frontend *fe, u16 *cnr)
3698 } 3692 }
3699 val /= 16; 3693 val /= 16;
3700 last = ARRAY_SIZE(stv090x_s2cn_tab) - 1; 3694 last = ARRAY_SIZE(stv090x_s2cn_tab) - 1;
3701 div = stv090x_s2cn_tab[0].read - 3695 div = stv090x_s2cn_tab[last].real -
3702 stv090x_s2cn_tab[last].read; 3696 stv090x_s2cn_tab[3].real;
3703 *cnr = 0xFFFF - ((val * 0xFFFF) / div); 3697 val = stv090x_table_lookup(stv090x_s2cn_tab, last, val);
3698 if (val < 0)
3699 val = 0;
3700 *cnr = val * 0xFFFF / div;
3704 } 3701 }
3705 break; 3702 break;
3706 3703
@@ -3720,9 +3717,10 @@ static int stv090x_read_cnr(struct dvb_frontend *fe, u16 *cnr)
3720 } 3717 }
3721 val /= 16; 3718 val /= 16;
3722 last = ARRAY_SIZE(stv090x_s1cn_tab) - 1; 3719 last = ARRAY_SIZE(stv090x_s1cn_tab) - 1;
3723 div = stv090x_s1cn_tab[0].read - 3720 div = stv090x_s1cn_tab[last].real -
3724 stv090x_s1cn_tab[last].read; 3721 stv090x_s1cn_tab[0].real;
3725 *cnr = 0xFFFF - ((val * 0xFFFF) / div); 3722 val = stv090x_table_lookup(stv090x_s1cn_tab, last, val);
3723 *cnr = val * 0xFFFF / div;
3726 } 3724 }
3727 break; 3725 break;
3728 default: 3726 default:
@@ -4886,7 +4884,7 @@ static int stv090x_set_gpio(struct dvb_frontend *fe, u8 gpio, u8 dir,
4886 return stv090x_write_reg(state, STV090x_GPIOxCFG(gpio), reg); 4884 return stv090x_write_reg(state, STV090x_GPIOxCFG(gpio), reg);
4887} 4885}
4888 4886
4889static struct dvb_frontend_ops stv090x_ops = { 4887static const struct dvb_frontend_ops stv090x_ops = {
4890 .delsys = { SYS_DVBS, SYS_DVBS2, SYS_DSS }, 4888 .delsys = { SYS_DVBS, SYS_DVBS2, SYS_DSS },
4891 .info = { 4889 .info = {
4892 .name = "STV090x Multistandard", 4890 .name = "STV090x Multistandard",
diff --git a/drivers/media/dvb-frontends/stv6110.c b/drivers/media/dvb-frontends/stv6110.c
index 66a5a7f2295c..6a72d0be2ec5 100644
--- a/drivers/media/dvb-frontends/stv6110.c
+++ b/drivers/media/dvb-frontends/stv6110.c
@@ -59,11 +59,10 @@ static s32 abssub(s32 a, s32 b)
59 return b - a; 59 return b - a;
60}; 60};
61 61
62static int stv6110_release(struct dvb_frontend *fe) 62static void stv6110_release(struct dvb_frontend *fe)
63{ 63{
64 kfree(fe->tuner_priv); 64 kfree(fe->tuner_priv);
65 fe->tuner_priv = NULL; 65 fe->tuner_priv = NULL;
66 return 0;
67} 66}
68 67
69static int stv6110_write_regs(struct dvb_frontend *fe, u8 buf[], 68static int stv6110_write_regs(struct dvb_frontend *fe, u8 buf[],
diff --git a/drivers/media/dvb-frontends/stv6110x.c b/drivers/media/dvb-frontends/stv6110x.c
index c611ad210b5c..66eba38f1014 100644
--- a/drivers/media/dvb-frontends/stv6110x.c
+++ b/drivers/media/dvb-frontends/stv6110x.c
@@ -335,14 +335,12 @@ static int stv6110x_get_status(struct dvb_frontend *fe, u32 *status)
335} 335}
336 336
337 337
338static int stv6110x_release(struct dvb_frontend *fe) 338static void stv6110x_release(struct dvb_frontend *fe)
339{ 339{
340 struct stv6110x_state *stv6110x = fe->tuner_priv; 340 struct stv6110x_state *stv6110x = fe->tuner_priv;
341 341
342 fe->tuner_priv = NULL; 342 fe->tuner_priv = NULL;
343 kfree(stv6110x); 343 kfree(stv6110x);
344
345 return 0;
346} 344}
347 345
348static const struct dvb_tuner_ops stv6110x_ops = { 346static const struct dvb_tuner_ops stv6110x_ops = {
diff --git a/drivers/media/dvb-frontends/tc90522.c b/drivers/media/dvb-frontends/tc90522.c
index 31cd32532387..4687e1546af2 100644
--- a/drivers/media/dvb-frontends/tc90522.c
+++ b/drivers/media/dvb-frontends/tc90522.c
@@ -656,7 +656,7 @@ tc90522_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
656 for (i = 0; i < num; i++) 656 for (i = 0; i < num; i++)
657 if (msgs[i].flags & I2C_M_RD) 657 if (msgs[i].flags & I2C_M_RD)
658 rd_num++; 658 rd_num++;
659 new_msgs = kmalloc(sizeof(*new_msgs) * (num + rd_num), GFP_KERNEL); 659 new_msgs = kmalloc_array(num + rd_num, sizeof(*new_msgs), GFP_KERNEL);
660 if (!new_msgs) 660 if (!new_msgs)
661 return -ENOMEM; 661 return -ENOMEM;
662 662
@@ -794,14 +794,13 @@ static int tc90522_probe(struct i2c_client *client,
794 i2c_set_adapdata(adap, state); 794 i2c_set_adapdata(adap, state);
795 ret = i2c_add_adapter(adap); 795 ret = i2c_add_adapter(adap);
796 if (ret < 0) 796 if (ret < 0)
797 goto err; 797 goto free_state;
798 cfg->tuner_i2c = state->cfg.tuner_i2c = adap; 798 cfg->tuner_i2c = state->cfg.tuner_i2c = adap;
799 799
800 i2c_set_clientdata(client, &state->cfg); 800 i2c_set_clientdata(client, &state->cfg);
801 dev_info(&client->dev, "Toshiba TC90522 attached.\n"); 801 dev_info(&client->dev, "Toshiba TC90522 attached.\n");
802 return 0; 802 return 0;
803 803free_state:
804err:
805 kfree(state); 804 kfree(state);
806 return ret; 805 return ret;
807} 806}
diff --git a/drivers/media/dvb-frontends/tda10021.c b/drivers/media/dvb-frontends/tda10021.c
index 806c56691ca5..32ba8401e743 100644
--- a/drivers/media/dvb-frontends/tda10021.c
+++ b/drivers/media/dvb-frontends/tda10021.c
@@ -77,8 +77,7 @@ static int _tda10021_writereg (struct tda10021_state* state, u8 reg, u8 data)
77 77
78 ret = i2c_transfer (state->i2c, &msg, 1); 78 ret = i2c_transfer (state->i2c, &msg, 1);
79 if (ret != 1) 79 if (ret != 1)
80 printk("DVB: TDA10021(%d): %s, writereg error " 80 printk("DVB: TDA10021(%d): %s, writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n",
81 "(reg == 0x%02x, val == 0x%02x, ret == %i)\n",
82 state->frontend.dvb->num, __func__, reg, data, ret); 81 state->frontend.dvb->num, __func__, reg, data, ret);
83 82
84 msleep(10); 83 msleep(10);
@@ -444,7 +443,7 @@ static void tda10021_release(struct dvb_frontend* fe)
444 kfree(state); 443 kfree(state);
445} 444}
446 445
447static struct dvb_frontend_ops tda10021_ops; 446static const struct dvb_frontend_ops tda10021_ops;
448 447
449struct dvb_frontend* tda10021_attach(const struct tda1002x_config* config, 448struct dvb_frontend* tda10021_attach(const struct tda1002x_config* config,
450 struct i2c_adapter* i2c, 449 struct i2c_adapter* i2c,
@@ -484,7 +483,7 @@ error:
484 return NULL; 483 return NULL;
485} 484}
486 485
487static struct dvb_frontend_ops tda10021_ops = { 486static const struct dvb_frontend_ops tda10021_ops = {
488 .delsys = { SYS_DVBC_ANNEX_A, SYS_DVBC_ANNEX_C }, 487 .delsys = { SYS_DVBC_ANNEX_A, SYS_DVBC_ANNEX_C },
489 .info = { 488 .info = {
490 .name = "Philips TDA10021 DVB-C", 489 .name = "Philips TDA10021 DVB-C",
diff --git a/drivers/media/dvb-frontends/tda10023.c b/drivers/media/dvb-frontends/tda10023.c
index 3b8c7e499d0d..8028007c68eb 100644
--- a/drivers/media/dvb-frontends/tda10023.c
+++ b/drivers/media/dvb-frontends/tda10023.c
@@ -72,8 +72,7 @@ static u8 tda10023_readreg (struct tda10023_state* state, u8 reg)
72 ret = i2c_transfer (state->i2c, msg, 2); 72 ret = i2c_transfer (state->i2c, msg, 2);
73 if (ret != 2) { 73 if (ret != 2) {
74 int num = state->frontend.dvb ? state->frontend.dvb->num : -1; 74 int num = state->frontend.dvb ? state->frontend.dvb->num : -1;
75 printk(KERN_ERR "DVB: TDA10023(%d): %s: readreg error " 75 printk(KERN_ERR "DVB: TDA10023(%d): %s: readreg error (reg == 0x%02x, ret == %i)\n",
76 "(reg == 0x%02x, ret == %i)\n",
77 num, __func__, reg, ret); 76 num, __func__, reg, ret);
78 } 77 }
79 return b1[0]; 78 return b1[0];
@@ -88,8 +87,7 @@ static int tda10023_writereg (struct tda10023_state* state, u8 reg, u8 data)
88 ret = i2c_transfer (state->i2c, &msg, 1); 87 ret = i2c_transfer (state->i2c, &msg, 1);
89 if (ret != 1) { 88 if (ret != 1) {
90 int num = state->frontend.dvb ? state->frontend.dvb->num : -1; 89 int num = state->frontend.dvb ? state->frontend.dvb->num : -1;
91 printk(KERN_ERR "DVB: TDA10023(%d): %s, writereg error " 90 printk(KERN_ERR "DVB: TDA10023(%d): %s, writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n",
92 "(reg == 0x%02x, val == 0x%02x, ret == %i)\n",
93 num, __func__, reg, data, ret); 91 num, __func__, reg, data, ret);
94 } 92 }
95 return (ret != 1) ? -EREMOTEIO : 0; 93 return (ret != 1) ? -EREMOTEIO : 0;
@@ -516,7 +514,7 @@ static void tda10023_release(struct dvb_frontend* fe)
516 kfree(state); 514 kfree(state);
517} 515}
518 516
519static struct dvb_frontend_ops tda10023_ops; 517static const struct dvb_frontend_ops tda10023_ops;
520 518
521struct dvb_frontend *tda10023_attach(const struct tda10023_config *config, 519struct dvb_frontend *tda10023_attach(const struct tda10023_config *config,
522 struct i2c_adapter *i2c, 520 struct i2c_adapter *i2c,
@@ -573,7 +571,7 @@ error:
573 return NULL; 571 return NULL;
574} 572}
575 573
576static struct dvb_frontend_ops tda10023_ops = { 574static const struct dvb_frontend_ops tda10023_ops = {
577 .delsys = { SYS_DVBC_ANNEX_A, SYS_DVBC_ANNEX_C }, 575 .delsys = { SYS_DVBC_ANNEX_A, SYS_DVBC_ANNEX_C },
578 .info = { 576 .info = {
579 .name = "Philips TDA10023 DVB-C", 577 .name = "Philips TDA10023 DVB-C",
diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c
index c2bf89d0b0b0..92ab34c3e0be 100644
--- a/drivers/media/dvb-frontends/tda10048.c
+++ b/drivers/media/dvb-frontends/tda10048.c
@@ -1063,38 +1063,34 @@ static void tda10048_establish_defaults(struct dvb_frontend *fe)
1063 /* Validate/default the config */ 1063 /* Validate/default the config */
1064 if (config->dtv6_if_freq_khz == 0) { 1064 if (config->dtv6_if_freq_khz == 0) {
1065 config->dtv6_if_freq_khz = TDA10048_IF_4300; 1065 config->dtv6_if_freq_khz = TDA10048_IF_4300;
1066 printk(KERN_WARNING "%s() tda10048_config.dtv6_if_freq_khz " 1066 printk(KERN_WARNING "%s() tda10048_config.dtv6_if_freq_khz is not set (defaulting to %d)\n",
1067 "is not set (defaulting to %d)\n",
1068 __func__, 1067 __func__,
1069 config->dtv6_if_freq_khz); 1068 config->dtv6_if_freq_khz);
1070 } 1069 }
1071 1070
1072 if (config->dtv7_if_freq_khz == 0) { 1071 if (config->dtv7_if_freq_khz == 0) {
1073 config->dtv7_if_freq_khz = TDA10048_IF_4300; 1072 config->dtv7_if_freq_khz = TDA10048_IF_4300;
1074 printk(KERN_WARNING "%s() tda10048_config.dtv7_if_freq_khz " 1073 printk(KERN_WARNING "%s() tda10048_config.dtv7_if_freq_khz is not set (defaulting to %d)\n",
1075 "is not set (defaulting to %d)\n",
1076 __func__, 1074 __func__,
1077 config->dtv7_if_freq_khz); 1075 config->dtv7_if_freq_khz);
1078 } 1076 }
1079 1077
1080 if (config->dtv8_if_freq_khz == 0) { 1078 if (config->dtv8_if_freq_khz == 0) {
1081 config->dtv8_if_freq_khz = TDA10048_IF_4300; 1079 config->dtv8_if_freq_khz = TDA10048_IF_4300;
1082 printk(KERN_WARNING "%s() tda10048_config.dtv8_if_freq_khz " 1080 printk(KERN_WARNING "%s() tda10048_config.dtv8_if_freq_khz is not set (defaulting to %d)\n",
1083 "is not set (defaulting to %d)\n",
1084 __func__, 1081 __func__,
1085 config->dtv8_if_freq_khz); 1082 config->dtv8_if_freq_khz);
1086 } 1083 }
1087 1084
1088 if (config->clk_freq_khz == 0) { 1085 if (config->clk_freq_khz == 0) {
1089 config->clk_freq_khz = TDA10048_CLK_16000; 1086 config->clk_freq_khz = TDA10048_CLK_16000;
1090 printk(KERN_WARNING "%s() tda10048_config.clk_freq_khz " 1087 printk(KERN_WARNING "%s() tda10048_config.clk_freq_khz is not set (defaulting to %d)\n",
1091 "is not set (defaulting to %d)\n",
1092 __func__, 1088 __func__,
1093 config->clk_freq_khz); 1089 config->clk_freq_khz);
1094 } 1090 }
1095} 1091}
1096 1092
1097static struct dvb_frontend_ops tda10048_ops; 1093static const struct dvb_frontend_ops tda10048_ops;
1098 1094
1099struct dvb_frontend *tda10048_attach(const struct tda10048_config *config, 1095struct dvb_frontend *tda10048_attach(const struct tda10048_config *config,
1100 struct i2c_adapter *i2c) 1096 struct i2c_adapter *i2c)
@@ -1156,7 +1152,7 @@ error:
1156} 1152}
1157EXPORT_SYMBOL(tda10048_attach); 1153EXPORT_SYMBOL(tda10048_attach);
1158 1154
1159static struct dvb_frontend_ops tda10048_ops = { 1155static const struct dvb_frontend_ops tda10048_ops = {
1160 .delsys = { SYS_DVBT }, 1156 .delsys = { SYS_DVBT },
1161 .info = { 1157 .info = {
1162 .name = "NXP TDA10048HN DVB-T", 1158 .name = "NXP TDA10048HN DVB-T",
diff --git a/drivers/media/dvb-frontends/tda1004x.c b/drivers/media/dvb-frontends/tda1004x.c
index b89848313fb9..e674508c349c 100644
--- a/drivers/media/dvb-frontends/tda1004x.c
+++ b/drivers/media/dvb-frontends/tda1004x.c
@@ -1245,7 +1245,7 @@ static void tda1004x_release(struct dvb_frontend* fe)
1245 kfree(state); 1245 kfree(state);
1246} 1246}
1247 1247
1248static struct dvb_frontend_ops tda10045_ops = { 1248static const struct dvb_frontend_ops tda10045_ops = {
1249 .delsys = { SYS_DVBT }, 1249 .delsys = { SYS_DVBT },
1250 .info = { 1250 .info = {
1251 .name = "Philips TDA10045H DVB-T", 1251 .name = "Philips TDA10045H DVB-T",
@@ -1315,7 +1315,7 @@ struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config,
1315 return &state->frontend; 1315 return &state->frontend;
1316} 1316}
1317 1317
1318static struct dvb_frontend_ops tda10046_ops = { 1318static const struct dvb_frontend_ops tda10046_ops = {
1319 .delsys = { SYS_DVBT }, 1319 .delsys = { SYS_DVBT },
1320 .info = { 1320 .info = {
1321 .name = "Philips TDA10046H DVB-T", 1321 .name = "Philips TDA10046H DVB-T",
diff --git a/drivers/media/dvb-frontends/tda10071.c b/drivers/media/dvb-frontends/tda10071.c
index 37ebeef2bbd0..a59f4fd09df6 100644
--- a/drivers/media/dvb-frontends/tda10071.c
+++ b/drivers/media/dvb-frontends/tda10071.c
@@ -20,7 +20,7 @@
20 20
21#include "tda10071_priv.h" 21#include "tda10071_priv.h"
22 22
23static struct dvb_frontend_ops tda10071_ops; 23static const struct dvb_frontend_ops tda10071_ops;
24 24
25/* 25/*
26 * XXX: regmap_update_bits() does not fit our needs as it does not support 26 * XXX: regmap_update_bits() does not fit our needs as it does not support
@@ -1102,7 +1102,7 @@ static int tda10071_get_tune_settings(struct dvb_frontend *fe,
1102 return 0; 1102 return 0;
1103} 1103}
1104 1104
1105static struct dvb_frontend_ops tda10071_ops = { 1105static const struct dvb_frontend_ops tda10071_ops = {
1106 .delsys = { SYS_DVBS, SYS_DVBS2 }, 1106 .delsys = { SYS_DVBS, SYS_DVBS2 },
1107 .info = { 1107 .info = {
1108 .name = "NXP TDA10071", 1108 .name = "NXP TDA10071",
diff --git a/drivers/media/dvb-frontends/tda10086.c b/drivers/media/dvb-frontends/tda10086.c
index 31d0acb54fe8..b6d16c05904d 100644
--- a/drivers/media/dvb-frontends/tda10086.c
+++ b/drivers/media/dvb-frontends/tda10086.c
@@ -706,7 +706,7 @@ static void tda10086_release(struct dvb_frontend* fe)
706 kfree(state); 706 kfree(state);
707} 707}
708 708
709static struct dvb_frontend_ops tda10086_ops = { 709static const struct dvb_frontend_ops tda10086_ops = {
710 .delsys = { SYS_DVBS }, 710 .delsys = { SYS_DVBS },
711 .info = { 711 .info = {
712 .name = "Philips TDA10086 DVB-S", 712 .name = "Philips TDA10086 DVB-S",
diff --git a/drivers/media/dvb-frontends/tda18271c2dd.c b/drivers/media/dvb-frontends/tda18271c2dd.c
index bc247f9b553a..6859fa5d5a85 100644
--- a/drivers/media/dvb-frontends/tda18271c2dd.c
+++ b/drivers/media/dvb-frontends/tda18271c2dd.c
@@ -1126,11 +1126,10 @@ static int init(struct dvb_frontend *fe)
1126 return 0; 1126 return 0;
1127} 1127}
1128 1128
1129static int release(struct dvb_frontend *fe) 1129static void release(struct dvb_frontend *fe)
1130{ 1130{
1131 kfree(fe->tuner_priv); 1131 kfree(fe->tuner_priv);
1132 fe->tuner_priv = NULL; 1132 fe->tuner_priv = NULL;
1133 return 0;
1134} 1133}
1135 1134
1136 1135
diff --git a/drivers/media/dvb-frontends/tda665x.c b/drivers/media/dvb-frontends/tda665x.c
index 7ca965987f40..a63dec44295b 100644
--- a/drivers/media/dvb-frontends/tda665x.c
+++ b/drivers/media/dvb-frontends/tda665x.c
@@ -197,13 +197,12 @@ static int tda665x_set_params(struct dvb_frontend *fe)
197 return 0; 197 return 0;
198} 198}
199 199
200static int tda665x_release(struct dvb_frontend *fe) 200static void tda665x_release(struct dvb_frontend *fe)
201{ 201{
202 struct tda665x_state *state = fe->tuner_priv; 202 struct tda665x_state *state = fe->tuner_priv;
203 203
204 fe->tuner_priv = NULL; 204 fe->tuner_priv = NULL;
205 kfree(state); 205 kfree(state);
206 return 0;
207} 206}
208 207
209static const struct dvb_tuner_ops tda665x_ops = { 208static const struct dvb_tuner_ops tda665x_ops = {
diff --git a/drivers/media/dvb-frontends/tda8083.c b/drivers/media/dvb-frontends/tda8083.c
index 9072d6463094..aa3200d3c352 100644
--- a/drivers/media/dvb-frontends/tda8083.c
+++ b/drivers/media/dvb-frontends/tda8083.c
@@ -421,7 +421,7 @@ static void tda8083_release(struct dvb_frontend* fe)
421 kfree(state); 421 kfree(state);
422} 422}
423 423
424static struct dvb_frontend_ops tda8083_ops; 424static const struct dvb_frontend_ops tda8083_ops;
425 425
426struct dvb_frontend* tda8083_attach(const struct tda8083_config* config, 426struct dvb_frontend* tda8083_attach(const struct tda8083_config* config,
427 struct i2c_adapter* i2c) 427 struct i2c_adapter* i2c)
@@ -449,7 +449,7 @@ error:
449 return NULL; 449 return NULL;
450} 450}
451 451
452static struct dvb_frontend_ops tda8083_ops = { 452static const struct dvb_frontend_ops tda8083_ops = {
453 .delsys = { SYS_DVBS }, 453 .delsys = { SYS_DVBS },
454 .info = { 454 .info = {
455 .name = "Philips TDA8083 DVB-S", 455 .name = "Philips TDA8083 DVB-S",
diff --git a/drivers/media/dvb-frontends/tda8261.c b/drivers/media/dvb-frontends/tda8261.c
index e0df93191b9e..4eb294f330bc 100644
--- a/drivers/media/dvb-frontends/tda8261.c
+++ b/drivers/media/dvb-frontends/tda8261.c
@@ -152,13 +152,12 @@ static int tda8261_set_params(struct dvb_frontend *fe)
152 return 0; 152 return 0;
153} 153}
154 154
155static int tda8261_release(struct dvb_frontend *fe) 155static void tda8261_release(struct dvb_frontend *fe)
156{ 156{
157 struct tda8261_state *state = fe->tuner_priv; 157 struct tda8261_state *state = fe->tuner_priv;
158 158
159 fe->tuner_priv = NULL; 159 fe->tuner_priv = NULL;
160 kfree(state); 160 kfree(state);
161 return 0;
162} 161}
163 162
164static const struct dvb_tuner_ops tda8261_ops = { 163static const struct dvb_tuner_ops tda8261_ops = {
diff --git a/drivers/media/dvb-frontends/tda826x.c b/drivers/media/dvb-frontends/tda826x.c
index 2ec671df1441..da427b4c2aaa 100644
--- a/drivers/media/dvb-frontends/tda826x.c
+++ b/drivers/media/dvb-frontends/tda826x.c
@@ -41,11 +41,10 @@ struct tda826x_priv {
41 u32 frequency; 41 u32 frequency;
42}; 42};
43 43
44static int tda826x_release(struct dvb_frontend *fe) 44static void tda826x_release(struct dvb_frontend *fe)
45{ 45{
46 kfree(fe->tuner_priv); 46 kfree(fe->tuner_priv);
47 fe->tuner_priv = NULL; 47 fe->tuner_priv = NULL;
48 return 0;
49} 48}
50 49
51static int tda826x_sleep(struct dvb_frontend *fe) 50static int tda826x_sleep(struct dvb_frontend *fe)
diff --git a/drivers/media/dvb-frontends/ts2020.c b/drivers/media/dvb-frontends/ts2020.c
index a9f6bbea6df3..931e5c98da8a 100644
--- a/drivers/media/dvb-frontends/ts2020.c
+++ b/drivers/media/dvb-frontends/ts2020.c
@@ -56,7 +56,7 @@ struct ts2020_reg_val {
56 56
57static void ts2020_stat_work(struct work_struct *work); 57static void ts2020_stat_work(struct work_struct *work);
58 58
59static int ts2020_release(struct dvb_frontend *fe) 59static void ts2020_release(struct dvb_frontend *fe)
60{ 60{
61 struct ts2020_priv *priv = fe->tuner_priv; 61 struct ts2020_priv *priv = fe->tuner_priv;
62 struct i2c_client *client = priv->client; 62 struct i2c_client *client = priv->client;
@@ -64,7 +64,6 @@ static int ts2020_release(struct dvb_frontend *fe)
64 dev_dbg(&client->dev, "\n"); 64 dev_dbg(&client->dev, "\n");
65 65
66 i2c_unregister_device(client); 66 i2c_unregister_device(client);
67 return 0;
68} 67}
69 68
70static int ts2020_sleep(struct dvb_frontend *fe) 69static int ts2020_sleep(struct dvb_frontend *fe)
diff --git a/drivers/media/dvb-frontends/tua6100.c b/drivers/media/dvb-frontends/tua6100.c
index 6da12b9e55eb..05ee16d29851 100644
--- a/drivers/media/dvb-frontends/tua6100.c
+++ b/drivers/media/dvb-frontends/tua6100.c
@@ -42,11 +42,10 @@ struct tua6100_priv {
42 u32 frequency; 42 u32 frequency;
43}; 43};
44 44
45static int tua6100_release(struct dvb_frontend *fe) 45static void tua6100_release(struct dvb_frontend *fe)
46{ 46{
47 kfree(fe->tuner_priv); 47 kfree(fe->tuner_priv);
48 fe->tuner_priv = NULL; 48 fe->tuner_priv = NULL;
49 return 0;
50} 49}
51 50
52static int tua6100_sleep(struct dvb_frontend *fe) 51static int tua6100_sleep(struct dvb_frontend *fe)
diff --git a/drivers/media/dvb-frontends/ves1820.c b/drivers/media/dvb-frontends/ves1820.c
index b09fe88c40f8..178363704bd4 100644
--- a/drivers/media/dvb-frontends/ves1820.c
+++ b/drivers/media/dvb-frontends/ves1820.c
@@ -65,8 +65,8 @@ static int ves1820_writereg(struct ves1820_state *state, u8 reg, u8 data)
65 ret = i2c_transfer(state->i2c, &msg, 1); 65 ret = i2c_transfer(state->i2c, &msg, 1);
66 66
67 if (ret != 1) 67 if (ret != 1)
68 printk("ves1820: %s(): writereg error (reg == 0x%02x, " 68 printk("ves1820: %s(): writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n",
69 "val == 0x%02x, ret == %i)\n", __func__, reg, data, ret); 69 __func__, reg, data, ret);
70 70
71 return (ret != 1) ? -EREMOTEIO : 0; 71 return (ret != 1) ? -EREMOTEIO : 0;
72} 72}
@@ -84,8 +84,8 @@ static u8 ves1820_readreg(struct ves1820_state *state, u8 reg)
84 ret = i2c_transfer(state->i2c, msg, 2); 84 ret = i2c_transfer(state->i2c, msg, 2);
85 85
86 if (ret != 2) 86 if (ret != 2)
87 printk("ves1820: %s(): readreg error (reg == 0x%02x, " 87 printk("ves1820: %s(): readreg error (reg == 0x%02x, ret == %i)\n",
88 "ret == %i)\n", __func__, reg, ret); 88 __func__, reg, ret);
89 89
90 return b1[0]; 90 return b1[0];
91} 91}
@@ -369,7 +369,7 @@ static void ves1820_release(struct dvb_frontend* fe)
369 kfree(state); 369 kfree(state);
370} 370}
371 371
372static struct dvb_frontend_ops ves1820_ops; 372static const struct dvb_frontend_ops ves1820_ops;
373 373
374struct dvb_frontend* ves1820_attach(const struct ves1820_config* config, 374struct dvb_frontend* ves1820_attach(const struct ves1820_config* config,
375 struct i2c_adapter* i2c, 375 struct i2c_adapter* i2c,
@@ -408,7 +408,7 @@ error:
408 return NULL; 408 return NULL;
409} 409}
410 410
411static struct dvb_frontend_ops ves1820_ops = { 411static const struct dvb_frontend_ops ves1820_ops = {
412 .delsys = { SYS_DVBC_ANNEX_A }, 412 .delsys = { SYS_DVBC_ANNEX_A },
413 .info = { 413 .info = {
414 .name = "VLSI VES1820 DVB-C", 414 .name = "VLSI VES1820 DVB-C",
diff --git a/drivers/media/dvb-frontends/ves1x93.c b/drivers/media/dvb-frontends/ves1x93.c
index ed113e216e14..d0ee52f66a8e 100644
--- a/drivers/media/dvb-frontends/ves1x93.c
+++ b/drivers/media/dvb-frontends/ves1x93.c
@@ -454,7 +454,7 @@ static int ves1x93_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
454 } 454 }
455} 455}
456 456
457static struct dvb_frontend_ops ves1x93_ops; 457static const struct dvb_frontend_ops ves1x93_ops;
458 458
459struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config, 459struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config,
460 struct i2c_adapter* i2c) 460 struct i2c_adapter* i2c)
@@ -512,7 +512,7 @@ error:
512 return NULL; 512 return NULL;
513} 513}
514 514
515static struct dvb_frontend_ops ves1x93_ops = { 515static const struct dvb_frontend_ops ves1x93_ops = {
516 .delsys = { SYS_DVBS }, 516 .delsys = { SYS_DVBS },
517 .info = { 517 .info = {
518 .name = "VLSI VES1x93 DVB-S", 518 .name = "VLSI VES1x93 DVB-S",
diff --git a/drivers/media/dvb-frontends/zl10036.c b/drivers/media/dvb-frontends/zl10036.c
index 7ed81315965f..a6d020fe9b8b 100644
--- a/drivers/media/dvb-frontends/zl10036.c
+++ b/drivers/media/dvb-frontends/zl10036.c
@@ -85,8 +85,8 @@ static int zl10036_read_status_reg(struct zl10036_state *state)
85 deb_i2c("R(status): %02x [FL=%d]\n", status, 85 deb_i2c("R(status): %02x [FL=%d]\n", status,
86 (status & STATUS_FL) ? 1 : 0); 86 (status & STATUS_FL) ? 1 : 0);
87 if (status & STATUS_POR) 87 if (status & STATUS_POR)
88 deb_info("%s: Power-On-Reset bit enabled - " 88 deb_info("%s: Power-On-Reset bit enabled - need to initialize the tuner\n",
89 "need to initialize the tuner\n", __func__); 89 __func__);
90 90
91 return status; 91 return status;
92} 92}
@@ -134,14 +134,12 @@ static int zl10036_write(struct zl10036_state *state, u8 buf[], u8 count)
134 return 0; 134 return 0;
135} 135}
136 136
137static int zl10036_release(struct dvb_frontend *fe) 137static void zl10036_release(struct dvb_frontend *fe)
138{ 138{
139 struct zl10036_state *state = fe->tuner_priv; 139 struct zl10036_state *state = fe->tuner_priv;
140 140
141 fe->tuner_priv = NULL; 141 fe->tuner_priv = NULL;
142 kfree(state); 142 kfree(state);
143
144 return 0;
145} 143}
146 144
147static int zl10036_sleep(struct dvb_frontend *fe) 145static int zl10036_sleep(struct dvb_frontend *fe)
diff --git a/drivers/media/dvb-frontends/zl10039.c b/drivers/media/dvb-frontends/zl10039.c
index f8c271be196c..60a2954f8ff8 100644
--- a/drivers/media/dvb-frontends/zl10039.c
+++ b/drivers/media/dvb-frontends/zl10039.c
@@ -152,8 +152,7 @@ static int zl10039_init(struct dvb_frontend *fe)
152 /* Reset logic */ 152 /* Reset logic */
153 ret = zl10039_writereg(state, GENERAL, 0x40); 153 ret = zl10039_writereg(state, GENERAL, 0x40);
154 if (ret < 0) { 154 if (ret < 0) {
155 dprintk("Note: i2c write error normal when resetting the " 155 dprintk("Note: i2c write error normal when resetting the tuner\n");
156 "tuner\n");
157 } 156 }
158 /* Wake up */ 157 /* Wake up */
159 ret = zl10039_writereg(state, GENERAL, 0x01); 158 ret = zl10039_writereg(state, GENERAL, 0x01);
@@ -245,14 +244,13 @@ error:
245 return ret; 244 return ret;
246} 245}
247 246
248static int zl10039_release(struct dvb_frontend *fe) 247static void zl10039_release(struct dvb_frontend *fe)
249{ 248{
250 struct zl10039_state *state = fe->tuner_priv; 249 struct zl10039_state *state = fe->tuner_priv;
251 250
252 dprintk("%s\n", __func__); 251 dprintk("%s\n", __func__);
253 kfree(state); 252 kfree(state);
254 fe->tuner_priv = NULL; 253 fe->tuner_priv = NULL;
255 return 0;
256} 254}
257 255
258static const struct dvb_tuner_ops zl10039_ops = { 256static const struct dvb_tuner_ops zl10039_ops = {
diff --git a/drivers/media/dvb-frontends/zl10353.c b/drivers/media/dvb-frontends/zl10353.c
index 3b08176d7bec..4f3ff3e853ac 100644
--- a/drivers/media/dvb-frontends/zl10353.c
+++ b/drivers/media/dvb-frontends/zl10353.c
@@ -602,7 +602,7 @@ static void zl10353_release(struct dvb_frontend *fe)
602 kfree(state); 602 kfree(state);
603} 603}
604 604
605static struct dvb_frontend_ops zl10353_ops; 605static const struct dvb_frontend_ops zl10353_ops;
606 606
607struct dvb_frontend *zl10353_attach(const struct zl10353_config *config, 607struct dvb_frontend *zl10353_attach(const struct zl10353_config *config,
608 struct i2c_adapter *i2c) 608 struct i2c_adapter *i2c)
@@ -634,7 +634,7 @@ error:
634 return NULL; 634 return NULL;
635} 635}
636 636
637static struct dvb_frontend_ops zl10353_ops = { 637static const struct dvb_frontend_ops zl10353_ops = {
638 .delsys = { SYS_DVBT }, 638 .delsys = { SYS_DVBT },
639 .info = { 639 .info = {
640 .name = "Zarlink ZL10353 DVB-T", 640 .name = "Zarlink ZL10353 DVB-T",
diff --git a/drivers/media/firewire/firedtv-avc.c b/drivers/media/firewire/firedtv-avc.c
index 251a556112a9..5bde6c209cd7 100644
--- a/drivers/media/firewire/firedtv-avc.c
+++ b/drivers/media/firewire/firedtv-avc.c
@@ -1181,8 +1181,8 @@ int avc_ca_pmt(struct firedtv *fdtv, char *msg, int length)
1181 if (es_info_length > 0) { 1181 if (es_info_length > 0) {
1182 pmt_cmd_id = msg[read_pos++]; 1182 pmt_cmd_id = msg[read_pos++];
1183 if (pmt_cmd_id != 1 && pmt_cmd_id != 4) 1183 if (pmt_cmd_id != 1 && pmt_cmd_id != 4)
1184 dev_err(fdtv->device, "invalid pmt_cmd_id %d " 1184 dev_err(fdtv->device, "invalid pmt_cmd_id %d at stream level\n",
1185 "at stream level\n", pmt_cmd_id); 1185 pmt_cmd_id);
1186 1186
1187 if (es_info_length > sizeof(c->operand) - 4 - 1187 if (es_info_length > sizeof(c->operand) - 4 -
1188 write_pos) { 1188 write_pos) {
diff --git a/drivers/media/firewire/firedtv-rc.c b/drivers/media/firewire/firedtv-rc.c
index f82d4a93feb3..04dea2aac583 100644
--- a/drivers/media/firewire/firedtv-rc.c
+++ b/drivers/media/firewire/firedtv-rc.c
@@ -184,8 +184,9 @@ void fdtv_handle_rc(struct firedtv *fdtv, unsigned int code)
184 else if (code >= 0x4540 && code <= 0x4542) 184 else if (code >= 0x4540 && code <= 0x4542)
185 code = oldtable[code - 0x4521]; 185 code = oldtable[code - 0x4521];
186 else { 186 else {
187 printk(KERN_DEBUG "firedtv: invalid key code 0x%04x " 187 dev_dbg(fdtv->device,
188 "from remote control\n", code); 188 "invalid key code 0x%04x from remote control\n",
189 code);
189 return; 190 return;
190 } 191 }
191 192
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 2669b4bad910..b31fa6fae009 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -221,7 +221,7 @@ config VIDEO_ADV7604
221 221
222config VIDEO_ADV7604_CEC 222config VIDEO_ADV7604_CEC
223 bool "Enable Analog Devices ADV7604 CEC support" 223 bool "Enable Analog Devices ADV7604 CEC support"
224 depends on VIDEO_ADV7604 && MEDIA_CEC 224 depends on VIDEO_ADV7604 && MEDIA_CEC_SUPPORT
225 ---help--- 225 ---help---
226 When selected the adv7604 will support the optional 226 When selected the adv7604 will support the optional
227 HDMI CEC feature. 227 HDMI CEC feature.
@@ -242,7 +242,7 @@ config VIDEO_ADV7842
242 242
243config VIDEO_ADV7842_CEC 243config VIDEO_ADV7842_CEC
244 bool "Enable Analog Devices ADV7842 CEC support" 244 bool "Enable Analog Devices ADV7842 CEC support"
245 depends on VIDEO_ADV7842 && MEDIA_CEC 245 depends on VIDEO_ADV7842 && MEDIA_CEC_SUPPORT
246 ---help--- 246 ---help---
247 When selected the adv7842 will support the optional 247 When selected the adv7842 will support the optional
248 HDMI CEC feature. 248 HDMI CEC feature.
@@ -481,7 +481,7 @@ config VIDEO_ADV7511
481 481
482config VIDEO_ADV7511_CEC 482config VIDEO_ADV7511_CEC
483 bool "Enable Analog Devices ADV7511 CEC support" 483 bool "Enable Analog Devices ADV7511 CEC support"
484 depends on VIDEO_ADV7511 && MEDIA_CEC 484 depends on VIDEO_ADV7511 && MEDIA_CEC_SUPPORT
485 ---help--- 485 ---help---
486 When selected the adv7511 will support the optional 486 When selected the adv7511 will support the optional
487 HDMI CEC feature. 487 HDMI CEC feature.
diff --git a/drivers/media/i2c/ad5820.c b/drivers/media/i2c/ad5820.c
index beab2f381b81..a9026a91855e 100644
--- a/drivers/media/i2c/ad5820.c
+++ b/drivers/media/i2c/ad5820.c
@@ -65,16 +65,17 @@ static int ad5820_write(struct ad5820_device *coil, u16 data)
65{ 65{
66 struct i2c_client *client = v4l2_get_subdevdata(&coil->subdev); 66 struct i2c_client *client = v4l2_get_subdevdata(&coil->subdev);
67 struct i2c_msg msg; 67 struct i2c_msg msg;
68 __be16 be_data;
68 int r; 69 int r;
69 70
70 if (!client->adapter) 71 if (!client->adapter)
71 return -ENODEV; 72 return -ENODEV;
72 73
73 data = cpu_to_be16(data); 74 be_data = cpu_to_be16(data);
74 msg.addr = client->addr; 75 msg.addr = client->addr;
75 msg.flags = 0; 76 msg.flags = 0;
76 msg.len = 2; 77 msg.len = 2;
77 msg.buf = (u8 *)&data; 78 msg.buf = (u8 *)&be_data;
78 79
79 r = i2c_transfer(client->adapter, &msg, 1); 80 r = i2c_transfer(client->adapter, &msg, 1);
80 if (r < 0) { 81 if (r < 0) {
diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index 5ba0f21bcfe4..8c9e28949ab1 100644
--- a/drivers/media/i2c/adv7511.c
+++ b/drivers/media/i2c/adv7511.c
@@ -1732,9 +1732,10 @@ static bool adv7511_check_edid_status(struct v4l2_subdev *sd)
1732static int adv7511_registered(struct v4l2_subdev *sd) 1732static int adv7511_registered(struct v4l2_subdev *sd)
1733{ 1733{
1734 struct adv7511_state *state = get_adv7511_state(sd); 1734 struct adv7511_state *state = get_adv7511_state(sd);
1735 struct i2c_client *client = v4l2_get_subdevdata(sd);
1735 int err; 1736 int err;
1736 1737
1737 err = cec_register_adapter(state->cec_adap); 1738 err = cec_register_adapter(state->cec_adap, &client->dev);
1738 if (err) 1739 if (err)
1739 cec_delete_adapter(state->cec_adap); 1740 cec_delete_adapter(state->cec_adap);
1740 return err; 1741 return err;
@@ -1928,7 +1929,7 @@ static int adv7511_probe(struct i2c_client *client, const struct i2c_device_id *
1928 state->cec_adap = cec_allocate_adapter(&adv7511_cec_adap_ops, 1929 state->cec_adap = cec_allocate_adapter(&adv7511_cec_adap_ops,
1929 state, dev_name(&client->dev), CEC_CAP_TRANSMIT | 1930 state, dev_name(&client->dev), CEC_CAP_TRANSMIT |
1930 CEC_CAP_LOG_ADDRS | CEC_CAP_PASSTHROUGH | CEC_CAP_RC, 1931 CEC_CAP_LOG_ADDRS | CEC_CAP_PASSTHROUGH | CEC_CAP_RC,
1931 ADV7511_MAX_ADDRS, &client->dev); 1932 ADV7511_MAX_ADDRS);
1932 err = PTR_ERR_OR_ZERO(state->cec_adap); 1933 err = PTR_ERR_OR_ZERO(state->cec_adap);
1933 if (err) { 1934 if (err) {
1934 destroy_workqueue(state->work_queue); 1935 destroy_workqueue(state->work_queue);
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 4003831de712..d0375cac6a05 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -1566,10 +1566,24 @@ static int adv76xx_query_dv_timings(struct v4l2_subdev *sd,
1566 V4L2_DV_INTERLACED : V4L2_DV_PROGRESSIVE; 1566 V4L2_DV_INTERLACED : V4L2_DV_PROGRESSIVE;
1567 1567
1568 if (is_digital_input(sd)) { 1568 if (is_digital_input(sd)) {
1569 bool hdmi_signal = hdmi_read(sd, 0x05) & 0x80;
1570 u8 vic = 0;
1571 u32 w, h;
1572
1573 w = hdmi_read16(sd, 0x07, info->linewidth_mask);
1574 h = hdmi_read16(sd, 0x09, info->field0_height_mask);
1575
1576 if (hdmi_signal && (io_read(sd, 0x60) & 1))
1577 vic = infoframe_read(sd, 0x04);
1578
1579 if (vic && v4l2_find_dv_timings_cea861_vic(timings, vic) &&
1580 bt->width == w && bt->height == h)
1581 goto found;
1582
1569 timings->type = V4L2_DV_BT_656_1120; 1583 timings->type = V4L2_DV_BT_656_1120;
1570 1584
1571 bt->width = hdmi_read16(sd, 0x07, info->linewidth_mask); 1585 bt->width = w;
1572 bt->height = hdmi_read16(sd, 0x09, info->field0_height_mask); 1586 bt->height = h;
1573 bt->pixelclock = info->read_hdmi_pixelclock(sd); 1587 bt->pixelclock = info->read_hdmi_pixelclock(sd);
1574 bt->hfrontporch = hdmi_read16(sd, 0x20, info->hfrontporch_mask); 1588 bt->hfrontporch = hdmi_read16(sd, 0x20, info->hfrontporch_mask);
1575 bt->hsync = hdmi_read16(sd, 0x22, info->hsync_mask); 1589 bt->hsync = hdmi_read16(sd, 0x22, info->hsync_mask);
@@ -2617,9 +2631,10 @@ static int adv76xx_subscribe_event(struct v4l2_subdev *sd,
2617static int adv76xx_registered(struct v4l2_subdev *sd) 2631static int adv76xx_registered(struct v4l2_subdev *sd)
2618{ 2632{
2619 struct adv76xx_state *state = to_state(sd); 2633 struct adv76xx_state *state = to_state(sd);
2634 struct i2c_client *client = v4l2_get_subdevdata(sd);
2620 int err; 2635 int err;
2621 2636
2622 err = cec_register_adapter(state->cec_adap); 2637 err = cec_register_adapter(state->cec_adap, &client->dev);
2623 if (err) 2638 if (err)
2624 cec_delete_adapter(state->cec_adap); 2639 cec_delete_adapter(state->cec_adap);
2625 return err; 2640 return err;
@@ -3074,13 +3089,13 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
3074 return ret; 3089 return ret;
3075 } 3090 }
3076 3091
3077 if (!of_property_read_u32(endpoint, "default-input", &v)) 3092 of_node_put(endpoint);
3093
3094 if (!of_property_read_u32(np, "default-input", &v))
3078 state->pdata.default_input = v; 3095 state->pdata.default_input = v;
3079 else 3096 else
3080 state->pdata.default_input = -1; 3097 state->pdata.default_input = -1;
3081 3098
3082 of_node_put(endpoint);
3083
3084 flags = bus_cfg.bus.parallel.flags; 3099 flags = bus_cfg.bus.parallel.flags;
3085 3100
3086 if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) 3101 if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
@@ -3497,8 +3512,7 @@ static int adv76xx_probe(struct i2c_client *client,
3497 state->cec_adap = cec_allocate_adapter(&adv76xx_cec_adap_ops, 3512 state->cec_adap = cec_allocate_adapter(&adv76xx_cec_adap_ops,
3498 state, dev_name(&client->dev), 3513 state, dev_name(&client->dev),
3499 CEC_CAP_TRANSMIT | CEC_CAP_LOG_ADDRS | 3514 CEC_CAP_TRANSMIT | CEC_CAP_LOG_ADDRS |
3500 CEC_CAP_PASSTHROUGH | CEC_CAP_RC, ADV76XX_MAX_ADDRS, 3515 CEC_CAP_PASSTHROUGH | CEC_CAP_RC, ADV76XX_MAX_ADDRS);
3501 &client->dev);
3502 err = PTR_ERR_OR_ZERO(state->cec_adap); 3516 err = PTR_ERR_OR_ZERO(state->cec_adap);
3503 if (err) 3517 if (err)
3504 goto err_entity; 3518 goto err_entity;
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 8c2a52e280af..2d61f0cc2b5b 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -3250,9 +3250,10 @@ static int adv7842_subscribe_event(struct v4l2_subdev *sd,
3250static int adv7842_registered(struct v4l2_subdev *sd) 3250static int adv7842_registered(struct v4l2_subdev *sd)
3251{ 3251{
3252 struct adv7842_state *state = to_state(sd); 3252 struct adv7842_state *state = to_state(sd);
3253 struct i2c_client *client = v4l2_get_subdevdata(sd);
3253 int err; 3254 int err;
3254 3255
3255 err = cec_register_adapter(state->cec_adap); 3256 err = cec_register_adapter(state->cec_adap, &client->dev);
3256 if (err) 3257 if (err)
3257 cec_delete_adapter(state->cec_adap); 3258 cec_delete_adapter(state->cec_adap);
3258 return err; 3259 return err;
@@ -3568,8 +3569,7 @@ static int adv7842_probe(struct i2c_client *client,
3568 state->cec_adap = cec_allocate_adapter(&adv7842_cec_adap_ops, 3569 state->cec_adap = cec_allocate_adapter(&adv7842_cec_adap_ops,
3569 state, dev_name(&client->dev), 3570 state, dev_name(&client->dev),
3570 CEC_CAP_TRANSMIT | CEC_CAP_LOG_ADDRS | 3571 CEC_CAP_TRANSMIT | CEC_CAP_LOG_ADDRS |
3571 CEC_CAP_PASSTHROUGH | CEC_CAP_RC, ADV7842_MAX_ADDRS, 3572 CEC_CAP_PASSTHROUGH | CEC_CAP_RC, ADV7842_MAX_ADDRS);
3572 &client->dev);
3573 err = PTR_ERR_OR_ZERO(state->cec_adap); 3573 err = PTR_ERR_OR_ZERO(state->cec_adap);
3574 if (err) 3574 if (err)
3575 goto err_entity; 3575 goto err_entity;
diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
index 142ae28803bb..0dcf450052ac 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -873,10 +873,7 @@ void cx25840_std_setup(struct i2c_client *client)
873 "Chroma sub-carrier freq = %d.%06d MHz\n", 873 "Chroma sub-carrier freq = %d.%06d MHz\n",
874 fsc / 1000000, fsc % 1000000); 874 fsc / 1000000, fsc % 1000000);
875 875
876 v4l_dbg(1, cx25840_debug, client, "hblank %i, hactive %i, " 876 v4l_dbg(1, cx25840_debug, client, "hblank %i, hactive %i, vblank %i, vactive %i, vblank656 %i, src_dec %i, burst 0x%02x, luma_lpf %i, uv_lpf %i, comb 0x%02x, sc 0x%06x\n",
877 "vblank %i, vactive %i, vblank656 %i, src_dec %i, "
878 "burst 0x%02x, luma_lpf %i, uv_lpf %i, comb 0x%02x, "
879 "sc 0x%06x\n",
880 hblank, hactive, vblank, vactive, vblank656, 877 hblank, hactive, vblank, vactive, vblank656,
881 src_decimation, burst, luma_lpf, uv_lpf, comb, sc); 878 src_decimation, burst, luma_lpf, uv_lpf, comb, sc);
882 } 879 }
@@ -5169,11 +5166,9 @@ static int cx25840_probe(struct i2c_client *client,
5169 id = CX2310X_AV; 5166 id = CX2310X_AV;
5170 } else if ((device_id & 0xff) == (device_id >> 8)) { 5167 } else if ((device_id & 0xff) == (device_id >> 8)) {
5171 v4l_err(client, 5168 v4l_err(client,
5172 "likely a confused/unresponsive cx2388[578] A/V decoder" 5169 "likely a confused/unresponsive cx2388[578] A/V decoder found @ 0x%x (%s)\n",
5173 " found @ 0x%x (%s)\n",
5174 client->addr << 1, client->adapter->name); 5170 client->addr << 1, client->adapter->name);
5175 v4l_err(client, "A method to reset it from the cx25840 driver" 5171 v4l_err(client, "A method to reset it from the cx25840 driver software is not known at this time\n");
5176 " software is not known at this time\n");
5177 return -ENODEV; 5172 return -ENODEV;
5178 } else { 5173 } else {
5179 v4l_dbg(1, cx25840_debug, client, "cx25840 not found\n"); 5174 v4l_dbg(1, cx25840_debug, client, "cx25840 not found\n");
diff --git a/drivers/media/i2c/cx25840/cx25840-ir.c b/drivers/media/i2c/cx25840/cx25840-ir.c
index 4b782012cadc..15fbd9607cee 100644
--- a/drivers/media/i2c/cx25840/cx25840-ir.c
+++ b/drivers/media/i2c/cx25840/cx25840-ir.c
@@ -1113,8 +1113,8 @@ int cx25840_ir_log_status(struct v4l2_subdev *sd)
1113 j = 0; 1113 j = 0;
1114 break; 1114 break;
1115 } 1115 }
1116 v4l2_info(sd, "\tNext carrier edge window: 16 clocks " 1116 v4l2_info(sd, "\tNext carrier edge window: 16 clocks -%1d/+%1d, %u to %u Hz\n",
1117 "-%1d/+%1d, %u to %u Hz\n", i, j, 1117 i, j,
1118 clock_divider_to_freq(rxclk, 16 + j), 1118 clock_divider_to_freq(rxclk, 16 + j),
1119 clock_divider_to_freq(rxclk, 16 - i)); 1119 clock_divider_to_freq(rxclk, 16 - i));
1120 } 1120 }
@@ -1124,8 +1124,7 @@ int cx25840_ir_log_status(struct v4l2_subdev *sd)
1124 v4l2_info(sd, "\tLow pass filter: %s\n", 1124 v4l2_info(sd, "\tLow pass filter: %s\n",
1125 filtr ? "enabled" : "disabled"); 1125 filtr ? "enabled" : "disabled");
1126 if (filtr) 1126 if (filtr)
1127 v4l2_info(sd, "\tMin acceptable pulse width (LPF): %u us, " 1127 v4l2_info(sd, "\tMin acceptable pulse width (LPF): %u us, %u ns\n",
1128 "%u ns\n",
1129 lpf_count_to_us(filtr), 1128 lpf_count_to_us(filtr),
1130 lpf_count_to_ns(filtr)); 1129 lpf_count_to_ns(filtr));
1131 v4l2_info(sd, "\tPulse width timer timed-out: %s\n", 1130 v4l2_info(sd, "\tPulse width timer timed-out: %s\n",
diff --git a/drivers/media/i2c/msp3400-driver.c b/drivers/media/i2c/msp3400-driver.c
index 503b7c4f0a9b..201a9800ea52 100644
--- a/drivers/media/i2c/msp3400-driver.c
+++ b/drivers/media/i2c/msp3400-driver.c
@@ -146,11 +146,11 @@ int msp_reset(struct i2c_client *client)
146 }, 146 },
147 }; 147 };
148 148
149 v4l_dbg(3, msp_debug, client, "msp_reset\n"); 149 dev_dbg_lvl(&client->dev, 3, msp_debug, "msp_reset\n");
150 if (i2c_transfer(client->adapter, &reset[0], 1) != 1 || 150 if (i2c_transfer(client->adapter, &reset[0], 1) != 1 ||
151 i2c_transfer(client->adapter, &reset[1], 1) != 1 || 151 i2c_transfer(client->adapter, &reset[1], 1) != 1 ||
152 i2c_transfer(client->adapter, test, 2) != 2) { 152 i2c_transfer(client->adapter, test, 2) != 2) {
153 v4l_err(client, "chip reset failed\n"); 153 dev_err(&client->dev, "chip reset failed\n");
154 return -1; 154 return -1;
155 } 155 }
156 return 0; 156 return 0;
@@ -182,17 +182,17 @@ static int msp_read(struct i2c_client *client, int dev, int addr)
182 for (err = 0; err < 3; err++) { 182 for (err = 0; err < 3; err++) {
183 if (i2c_transfer(client->adapter, msgs, 2) == 2) 183 if (i2c_transfer(client->adapter, msgs, 2) == 2)
184 break; 184 break;
185 v4l_warn(client, "I/O error #%d (read 0x%02x/0x%02x)\n", err, 185 dev_warn(&client->dev, "I/O error #%d (read 0x%02x/0x%02x)\n", err,
186 dev, addr); 186 dev, addr);
187 schedule_timeout_interruptible(msecs_to_jiffies(10)); 187 schedule_timeout_interruptible(msecs_to_jiffies(10));
188 } 188 }
189 if (err == 3) { 189 if (err == 3) {
190 v4l_warn(client, "resetting chip, sound will go off.\n"); 190 dev_warn(&client->dev, "resetting chip, sound will go off.\n");
191 msp_reset(client); 191 msp_reset(client);
192 return -1; 192 return -1;
193 } 193 }
194 retval = read[0] << 8 | read[1]; 194 retval = read[0] << 8 | read[1];
195 v4l_dbg(3, msp_debug, client, "msp_read(0x%x, 0x%x): 0x%x\n", 195 dev_dbg_lvl(&client->dev, 3, msp_debug, "msp_read(0x%x, 0x%x): 0x%x\n",
196 dev, addr, retval); 196 dev, addr, retval);
197 return retval; 197 return retval;
198} 198}
@@ -218,17 +218,17 @@ static int msp_write(struct i2c_client *client, int dev, int addr, int val)
218 buffer[3] = val >> 8; 218 buffer[3] = val >> 8;
219 buffer[4] = val & 0xff; 219 buffer[4] = val & 0xff;
220 220
221 v4l_dbg(3, msp_debug, client, "msp_write(0x%x, 0x%x, 0x%x)\n", 221 dev_dbg_lvl(&client->dev, 3, msp_debug, "msp_write(0x%x, 0x%x, 0x%x)\n",
222 dev, addr, val); 222 dev, addr, val);
223 for (err = 0; err < 3; err++) { 223 for (err = 0; err < 3; err++) {
224 if (i2c_master_send(client, buffer, 5) == 5) 224 if (i2c_master_send(client, buffer, 5) == 5)
225 break; 225 break;
226 v4l_warn(client, "I/O error #%d (write 0x%02x/0x%02x)\n", err, 226 dev_warn(&client->dev, "I/O error #%d (write 0x%02x/0x%02x)\n", err,
227 dev, addr); 227 dev, addr);
228 schedule_timeout_interruptible(msecs_to_jiffies(10)); 228 schedule_timeout_interruptible(msecs_to_jiffies(10));
229 } 229 }
230 if (err == 3) { 230 if (err == 3) {
231 v4l_warn(client, "resetting chip, sound will go off.\n"); 231 dev_warn(&client->dev, "resetting chip, sound will go off.\n");
232 msp_reset(client); 232 msp_reset(client);
233 return -1; 233 return -1;
234 } 234 }
@@ -301,7 +301,7 @@ void msp_set_scart(struct i2c_client *client, int in, int out)
301 } else 301 } else
302 state->acb = 0xf60; /* Mute Input and SCART 1 Output */ 302 state->acb = 0xf60; /* Mute Input and SCART 1 Output */
303 303
304 v4l_dbg(1, msp_debug, client, "scart switch: %s => %d (ACB=0x%04x)\n", 304 dev_dbg_lvl(&client->dev, 1, msp_debug, "scart switch: %s => %d (ACB=0x%04x)\n",
305 scart_names[in], out, state->acb); 305 scart_names[in], out, state->acb);
306 msp_write_dsp(client, 0x13, state->acb); 306 msp_write_dsp(client, 0x13, state->acb);
307 307
@@ -359,7 +359,7 @@ static int msp_s_ctrl(struct v4l2_ctrl *ctrl)
359 if (!reallymuted) 359 if (!reallymuted)
360 val = (val * 0x7f / 65535) << 8; 360 val = (val * 0x7f / 65535) << 8;
361 361
362 v4l_dbg(1, msp_debug, client, "mute=%s scanning=%s volume=%d\n", 362 dev_dbg_lvl(&client->dev, 1, msp_debug, "mute=%s scanning=%s volume=%d\n",
363 state->muted->val ? "on" : "off", 363 state->muted->val ? "on" : "off",
364 state->scan_in_progress ? "yes" : "no", 364 state->scan_in_progress ? "yes" : "no",
365 state->volume->val); 365 state->volume->val);
@@ -426,7 +426,7 @@ static int msp_s_radio(struct v4l2_subdev *sd)
426 if (state->radio) 426 if (state->radio)
427 return 0; 427 return 0;
428 state->radio = 1; 428 state->radio = 1;
429 v4l_dbg(1, msp_debug, client, "switching to radio mode\n"); 429 dev_dbg_lvl(&client->dev, 1, msp_debug, "switching to radio mode\n");
430 state->watch_stereo = 0; 430 state->watch_stereo = 0;
431 switch (state->opmode) { 431 switch (state->opmode) {
432 case OPMODE_MANUAL: 432 case OPMODE_MANUAL:
@@ -461,7 +461,7 @@ static int msp_querystd(struct v4l2_subdev *sd, v4l2_std_id *id)
461 461
462 *id &= state->detected_std; 462 *id &= state->detected_std;
463 463
464 v4l_dbg(2, msp_debug, client, 464 dev_dbg_lvl(&client->dev, 2, msp_debug,
465 "detected standard: %s(0x%08Lx)\n", 465 "detected standard: %s(0x%08Lx)\n",
466 msp_standard_std_name(state->std), state->detected_std); 466 msp_standard_std_name(state->std), state->detected_std);
467 467
@@ -555,7 +555,7 @@ static int msp_s_i2s_clock_freq(struct v4l2_subdev *sd, u32 freq)
555 struct msp_state *state = to_state(sd); 555 struct msp_state *state = to_state(sd);
556 struct i2c_client *client = v4l2_get_subdevdata(sd); 556 struct i2c_client *client = v4l2_get_subdevdata(sd);
557 557
558 v4l_dbg(1, msp_debug, client, "Setting I2S speed to %d\n", freq); 558 dev_dbg_lvl(&client->dev, 1, msp_debug, "Setting I2S speed to %d\n", freq);
559 559
560 switch (freq) { 560 switch (freq) {
561 case 1024000: 561 case 1024000:
@@ -579,7 +579,7 @@ static int msp_log_status(struct v4l2_subdev *sd)
579 579
580 if (state->opmode == OPMODE_AUTOSELECT) 580 if (state->opmode == OPMODE_AUTOSELECT)
581 msp_detect_stereo(client); 581 msp_detect_stereo(client);
582 v4l_info(client, "%s rev1 = 0x%04x rev2 = 0x%04x\n", 582 dev_info(&client->dev, "%s rev1 = 0x%04x rev2 = 0x%04x\n",
583 client->name, state->rev1, state->rev2); 583 client->name, state->rev1, state->rev2);
584 snprintf(prefix, sizeof(prefix), "%s: Audio: ", sd->name); 584 snprintf(prefix, sizeof(prefix), "%s: Audio: ", sd->name);
585 v4l2_ctrl_handler_log_status(&state->hdl, prefix); 585 v4l2_ctrl_handler_log_status(&state->hdl, prefix);
@@ -596,23 +596,23 @@ static int msp_log_status(struct v4l2_subdev *sd)
596 default: p = "unknown"; break; 596 default: p = "unknown"; break;
597 } 597 }
598 if (state->mode == MSP_MODE_EXTERN) { 598 if (state->mode == MSP_MODE_EXTERN) {
599 v4l_info(client, "Mode: %s\n", p); 599 dev_info(&client->dev, "Mode: %s\n", p);
600 } else if (state->opmode == OPMODE_MANUAL) { 600 } else if (state->opmode == OPMODE_MANUAL) {
601 v4l_info(client, "Mode: %s (%s%s)\n", p, 601 dev_info(&client->dev, "Mode: %s (%s%s)\n", p,
602 (state->rxsubchans & V4L2_TUNER_SUB_STEREO) ? "stereo" : "mono", 602 (state->rxsubchans & V4L2_TUNER_SUB_STEREO) ? "stereo" : "mono",
603 (state->rxsubchans & V4L2_TUNER_SUB_LANG2) ? ", dual" : ""); 603 (state->rxsubchans & V4L2_TUNER_SUB_LANG2) ? ", dual" : "");
604 } else { 604 } else {
605 if (state->opmode == OPMODE_AUTODETECT) 605 if (state->opmode == OPMODE_AUTODETECT)
606 v4l_info(client, "Mode: %s\n", p); 606 dev_info(&client->dev, "Mode: %s\n", p);
607 v4l_info(client, "Standard: %s (%s%s)\n", 607 dev_info(&client->dev, "Standard: %s (%s%s)\n",
608 msp_standard_std_name(state->std), 608 msp_standard_std_name(state->std),
609 (state->rxsubchans & V4L2_TUNER_SUB_STEREO) ? "stereo" : "mono", 609 (state->rxsubchans & V4L2_TUNER_SUB_STEREO) ? "stereo" : "mono",
610 (state->rxsubchans & V4L2_TUNER_SUB_LANG2) ? ", dual" : ""); 610 (state->rxsubchans & V4L2_TUNER_SUB_LANG2) ? ", dual" : "");
611 } 611 }
612 v4l_info(client, "Audmode: 0x%04x\n", state->audmode); 612 dev_info(&client->dev, "Audmode: 0x%04x\n", state->audmode);
613 v4l_info(client, "Routing: 0x%08x (input) 0x%08x (output)\n", 613 dev_info(&client->dev, "Routing: 0x%08x (input) 0x%08x (output)\n",
614 state->route_in, state->route_out); 614 state->route_in, state->route_out);
615 v4l_info(client, "ACB: 0x%04x\n", state->acb); 615 dev_info(&client->dev, "ACB: 0x%04x\n", state->acb);
616 return 0; 616 return 0;
617} 617}
618 618
@@ -620,7 +620,7 @@ static int msp_log_status(struct v4l2_subdev *sd)
620static int msp_suspend(struct device *dev) 620static int msp_suspend(struct device *dev)
621{ 621{
622 struct i2c_client *client = to_i2c_client(dev); 622 struct i2c_client *client = to_i2c_client(dev);
623 v4l_dbg(1, msp_debug, client, "suspend\n"); 623 dev_dbg_lvl(&client->dev, 1, msp_debug, "suspend\n");
624 msp_reset(client); 624 msp_reset(client);
625 return 0; 625 return 0;
626} 626}
@@ -628,7 +628,7 @@ static int msp_suspend(struct device *dev)
628static int msp_resume(struct device *dev) 628static int msp_resume(struct device *dev)
629{ 629{
630 struct i2c_client *client = to_i2c_client(dev); 630 struct i2c_client *client = to_i2c_client(dev);
631 v4l_dbg(1, msp_debug, client, "resume\n"); 631 dev_dbg_lvl(&client->dev, 1, msp_debug, "resume\n");
632 msp_wake_thread(client); 632 msp_wake_thread(client);
633 return 0; 633 return 0;
634} 634}
@@ -670,6 +670,13 @@ static const struct v4l2_subdev_ops msp_ops = {
670 670
671/* ----------------------------------------------------------------------- */ 671/* ----------------------------------------------------------------------- */
672 672
673
674static const char * const opmode_str[] = {
675 [OPMODE_MANUAL] = "manual",
676 [OPMODE_AUTODETECT] = "autodetect",
677 [OPMODE_AUTOSELECT] = "autodetect and autoselect",
678};
679
673static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id) 680static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
674{ 681{
675 struct msp_state *state; 682 struct msp_state *state;
@@ -689,7 +696,7 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
689 strlcpy(client->name, "msp3400", sizeof(client->name)); 696 strlcpy(client->name, "msp3400", sizeof(client->name));
690 697
691 if (msp_reset(client) == -1) { 698 if (msp_reset(client) == -1) {
692 v4l_dbg(1, msp_debug, client, "msp3400 not found\n"); 699 dev_dbg_lvl(&client->dev, 1, msp_debug, "msp3400 not found\n");
693 return -ENODEV; 700 return -ENODEV;
694 } 701 }
695 702
@@ -724,10 +731,10 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
724 state->rev1 = msp_read_dsp(client, 0x1e); 731 state->rev1 = msp_read_dsp(client, 0x1e);
725 if (state->rev1 != -1) 732 if (state->rev1 != -1)
726 state->rev2 = msp_read_dsp(client, 0x1f); 733 state->rev2 = msp_read_dsp(client, 0x1f);
727 v4l_dbg(1, msp_debug, client, "rev1=0x%04x, rev2=0x%04x\n", 734 dev_dbg_lvl(&client->dev, 1, msp_debug, "rev1=0x%04x, rev2=0x%04x\n",
728 state->rev1, state->rev2); 735 state->rev1, state->rev2);
729 if (state->rev1 == -1 || (state->rev1 == 0 && state->rev2 == 0)) { 736 if (state->rev1 == -1 || (state->rev1 == 0 && state->rev2 == 0)) {
730 v4l_dbg(1, msp_debug, client, 737 dev_dbg_lvl(&client->dev, 1, msp_debug,
731 "not an msp3400 (cannot read chip version)\n"); 738 "not an msp3400 (cannot read chip version)\n");
732 return -ENODEV; 739 return -ENODEV;
733 } 740 }
@@ -791,7 +798,8 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
791 msp_family == 3 && msp_revision == 'G' && msp_prod_hi == 3; 798 msp_family == 3 && msp_revision == 'G' && msp_prod_hi == 3;
792 799
793 state->opmode = opmode; 800 state->opmode = opmode;
794 if (state->opmode == OPMODE_AUTO) { 801 if (state->opmode < OPMODE_MANUAL
802 || state->opmode > OPMODE_AUTOSELECT) {
795 /* MSP revision G and up have both autodetect and autoselect */ 803 /* MSP revision G and up have both autodetect and autoselect */
796 if (msp_revision >= 'G') 804 if (msp_revision >= 'G')
797 state->opmode = OPMODE_AUTOSELECT; 805 state->opmode = OPMODE_AUTOSELECT;
@@ -829,43 +837,35 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
829 v4l2_ctrl_cluster(2, &state->volume); 837 v4l2_ctrl_cluster(2, &state->volume);
830 v4l2_ctrl_handler_setup(hdl); 838 v4l2_ctrl_handler_setup(hdl);
831 839
832 /* hello world :-) */ 840 dev_info(&client->dev,
833 v4l_info(client, "MSP%d4%02d%c-%c%d found @ 0x%x (%s)\n", 841 "MSP%d4%02d%c-%c%d found on %s: supports %s%s%s, mode is %s\n",
834 msp_family, msp_product, 842 msp_family, msp_product,
835 msp_revision, msp_hard, msp_rom, 843 msp_revision, msp_hard, msp_rom,
836 client->addr << 1, client->adapter->name); 844 client->adapter->name,
837 v4l_info(client, "%s ", client->name); 845 (state->has_nicam) ? "nicam" : "",
838 if (state->has_nicam && state->has_radio) 846 (state->has_nicam && state->has_radio) ? " and " : "",
839 printk(KERN_CONT "supports nicam and radio, "); 847 (state->has_radio) ? "radio" : "",
840 else if (state->has_nicam) 848 opmode_str[state->opmode]);
841 printk(KERN_CONT "supports nicam, ");
842 else if (state->has_radio)
843 printk(KERN_CONT "supports radio, ");
844 printk(KERN_CONT "mode is ");
845 849
846 /* version-specific initialization */ 850 /* version-specific initialization */
847 switch (state->opmode) { 851 switch (state->opmode) {
848 case OPMODE_MANUAL: 852 case OPMODE_MANUAL:
849 printk(KERN_CONT "manual");
850 thread_func = msp3400c_thread; 853 thread_func = msp3400c_thread;
851 break; 854 break;
852 case OPMODE_AUTODETECT: 855 case OPMODE_AUTODETECT:
853 printk(KERN_CONT "autodetect");
854 thread_func = msp3410d_thread; 856 thread_func = msp3410d_thread;
855 break; 857 break;
856 case OPMODE_AUTOSELECT: 858 case OPMODE_AUTOSELECT:
857 printk(KERN_CONT "autodetect and autoselect");
858 thread_func = msp34xxg_thread; 859 thread_func = msp34xxg_thread;
859 break; 860 break;
860 } 861 }
861 printk(KERN_CONT "\n");
862 862
863 /* startup control thread if needed */ 863 /* startup control thread if needed */
864 if (thread_func) { 864 if (thread_func) {
865 state->kthread = kthread_run(thread_func, client, "msp34xx"); 865 state->kthread = kthread_run(thread_func, client, "msp34xx");
866 866
867 if (IS_ERR(state->kthread)) 867 if (IS_ERR(state->kthread))
868 v4l_warn(client, "kernel_thread() failed\n"); 868 dev_warn(&client->dev, "kernel_thread() failed\n");
869 msp_wake_thread(client); 869 msp_wake_thread(client);
870 } 870 }
871 return 0; 871 return 0;
diff --git a/drivers/media/i2c/msp3400-kthreads.c b/drivers/media/i2c/msp3400-kthreads.c
index 17120804fab7..eec7aa4c6f98 100644
--- a/drivers/media/i2c/msp3400-kthreads.c
+++ b/drivers/media/i2c/msp3400-kthreads.c
@@ -220,7 +220,7 @@ void msp3400c_set_mode(struct i2c_client *client, int mode)
220 int tuner = (state->route_in >> 3) & 1; 220 int tuner = (state->route_in >> 3) & 1;
221 int i; 221 int i;
222 222
223 v4l_dbg(1, msp_debug, client, "set_mode: %d\n", mode); 223 dev_dbg_lvl(&client->dev, 1, msp_debug, "set_mode: %d\n", mode);
224 state->mode = mode; 224 state->mode = mode;
225 state->rxsubchans = V4L2_TUNER_SUB_MONO; 225 state->rxsubchans = V4L2_TUNER_SUB_MONO;
226 226
@@ -266,7 +266,7 @@ static void msp3400c_set_audmode(struct i2c_client *client)
266 /* this method would break everything, let's make sure 266 /* this method would break everything, let's make sure
267 * it's never called 267 * it's never called
268 */ 268 */
269 v4l_dbg(1, msp_debug, client, 269 dev_dbg_lvl(&client->dev, 1, msp_debug,
270 "set_audmode called with mode=%d instead of set_source (ignored)\n", 270 "set_audmode called with mode=%d instead of set_source (ignored)\n",
271 state->audmode); 271 state->audmode);
272 return; 272 return;
@@ -295,7 +295,7 @@ static void msp3400c_set_audmode(struct i2c_client *client)
295 /* switch demodulator */ 295 /* switch demodulator */
296 switch (state->mode) { 296 switch (state->mode) {
297 case MSP_MODE_FM_TERRA: 297 case MSP_MODE_FM_TERRA:
298 v4l_dbg(1, msp_debug, client, "FM set_audmode: %s\n", modestr); 298 dev_dbg_lvl(&client->dev, 1, msp_debug, "FM set_audmode: %s\n", modestr);
299 switch (audmode) { 299 switch (audmode) {
300 case V4L2_TUNER_MODE_STEREO: 300 case V4L2_TUNER_MODE_STEREO:
301 msp_write_dsp(client, 0x000e, 0x3001); 301 msp_write_dsp(client, 0x000e, 0x3001);
@@ -309,7 +309,7 @@ static void msp3400c_set_audmode(struct i2c_client *client)
309 } 309 }
310 break; 310 break;
311 case MSP_MODE_FM_SAT: 311 case MSP_MODE_FM_SAT:
312 v4l_dbg(1, msp_debug, client, "SAT set_audmode: %s\n", modestr); 312 dev_dbg_lvl(&client->dev, 1, msp_debug, "SAT set_audmode: %s\n", modestr);
313 switch (audmode) { 313 switch (audmode) {
314 case V4L2_TUNER_MODE_MONO: 314 case V4L2_TUNER_MODE_MONO:
315 msp3400c_set_carrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5)); 315 msp3400c_set_carrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5));
@@ -329,31 +329,31 @@ static void msp3400c_set_audmode(struct i2c_client *client)
329 case MSP_MODE_FM_NICAM1: 329 case MSP_MODE_FM_NICAM1:
330 case MSP_MODE_FM_NICAM2: 330 case MSP_MODE_FM_NICAM2:
331 case MSP_MODE_AM_NICAM: 331 case MSP_MODE_AM_NICAM:
332 v4l_dbg(1, msp_debug, client, 332 dev_dbg_lvl(&client->dev, 1, msp_debug,
333 "NICAM set_audmode: %s\n", modestr); 333 "NICAM set_audmode: %s\n", modestr);
334 if (state->nicam_on) 334 if (state->nicam_on)
335 src = 0x0100; /* NICAM */ 335 src = 0x0100; /* NICAM */
336 break; 336 break;
337 case MSP_MODE_BTSC: 337 case MSP_MODE_BTSC:
338 v4l_dbg(1, msp_debug, client, 338 dev_dbg_lvl(&client->dev, 1, msp_debug,
339 "BTSC set_audmode: %s\n", modestr); 339 "BTSC set_audmode: %s\n", modestr);
340 break; 340 break;
341 case MSP_MODE_EXTERN: 341 case MSP_MODE_EXTERN:
342 v4l_dbg(1, msp_debug, client, 342 dev_dbg_lvl(&client->dev, 1, msp_debug,
343 "extern set_audmode: %s\n", modestr); 343 "extern set_audmode: %s\n", modestr);
344 src = 0x0200; /* SCART */ 344 src = 0x0200; /* SCART */
345 break; 345 break;
346 case MSP_MODE_FM_RADIO: 346 case MSP_MODE_FM_RADIO:
347 v4l_dbg(1, msp_debug, client, 347 dev_dbg_lvl(&client->dev, 1, msp_debug,
348 "FM-Radio set_audmode: %s\n", modestr); 348 "FM-Radio set_audmode: %s\n", modestr);
349 break; 349 break;
350 default: 350 default:
351 v4l_dbg(1, msp_debug, client, "mono set_audmode\n"); 351 dev_dbg_lvl(&client->dev, 1, msp_debug, "mono set_audmode\n");
352 return; 352 return;
353 } 353 }
354 354
355 /* switch audio */ 355 /* switch audio */
356 v4l_dbg(1, msp_debug, client, "set audmode %d\n", audmode); 356 dev_dbg_lvl(&client->dev, 1, msp_debug, "set audmode %d\n", audmode);
357 switch (audmode) { 357 switch (audmode) {
358 case V4L2_TUNER_MODE_STEREO: 358 case V4L2_TUNER_MODE_STEREO:
359 case V4L2_TUNER_MODE_LANG1_LANG2: 359 case V4L2_TUNER_MODE_LANG1_LANG2:
@@ -361,7 +361,7 @@ static void msp3400c_set_audmode(struct i2c_client *client)
361 break; 361 break;
362 case V4L2_TUNER_MODE_MONO: 362 case V4L2_TUNER_MODE_MONO:
363 if (state->mode == MSP_MODE_AM_NICAM) { 363 if (state->mode == MSP_MODE_AM_NICAM) {
364 v4l_dbg(1, msp_debug, client, "switching to AM mono\n"); 364 dev_dbg_lvl(&client->dev, 1, msp_debug, "switching to AM mono\n");
365 /* AM mono decoding is handled by tuner, not MSP chip */ 365 /* AM mono decoding is handled by tuner, not MSP chip */
366 /* SCART switching control register */ 366 /* SCART switching control register */
367 msp_set_scart(client, SCART_MONO, 0); 367 msp_set_scart(client, SCART_MONO, 0);
@@ -377,7 +377,7 @@ static void msp3400c_set_audmode(struct i2c_client *client)
377 src |= 0x0010; 377 src |= 0x0010;
378 break; 378 break;
379 } 379 }
380 v4l_dbg(1, msp_debug, client, 380 dev_dbg_lvl(&client->dev, 1, msp_debug,
381 "set_audmode final source/matrix = 0x%x\n", src); 381 "set_audmode final source/matrix = 0x%x\n", src);
382 382
383 msp_set_source(client, src); 383 msp_set_source(client, src);
@@ -388,23 +388,23 @@ static void msp3400c_print_mode(struct i2c_client *client)
388 struct msp_state *state = to_state(i2c_get_clientdata(client)); 388 struct msp_state *state = to_state(i2c_get_clientdata(client));
389 389
390 if (state->main == state->second) 390 if (state->main == state->second)
391 v4l_dbg(1, msp_debug, client, 391 dev_dbg_lvl(&client->dev, 1, msp_debug,
392 "mono sound carrier: %d.%03d MHz\n", 392 "mono sound carrier: %d.%03d MHz\n",
393 state->main / 910000, (state->main / 910) % 1000); 393 state->main / 910000, (state->main / 910) % 1000);
394 else 394 else
395 v4l_dbg(1, msp_debug, client, 395 dev_dbg_lvl(&client->dev, 1, msp_debug,
396 "main sound carrier: %d.%03d MHz\n", 396 "main sound carrier: %d.%03d MHz\n",
397 state->main / 910000, (state->main / 910) % 1000); 397 state->main / 910000, (state->main / 910) % 1000);
398 if (state->mode == MSP_MODE_FM_NICAM1 || state->mode == MSP_MODE_FM_NICAM2) 398 if (state->mode == MSP_MODE_FM_NICAM1 || state->mode == MSP_MODE_FM_NICAM2)
399 v4l_dbg(1, msp_debug, client, 399 dev_dbg_lvl(&client->dev, 1, msp_debug,
400 "NICAM/FM carrier : %d.%03d MHz\n", 400 "NICAM/FM carrier : %d.%03d MHz\n",
401 state->second / 910000, (state->second/910) % 1000); 401 state->second / 910000, (state->second/910) % 1000);
402 if (state->mode == MSP_MODE_AM_NICAM) 402 if (state->mode == MSP_MODE_AM_NICAM)
403 v4l_dbg(1, msp_debug, client, 403 dev_dbg_lvl(&client->dev, 1, msp_debug,
404 "NICAM/AM carrier : %d.%03d MHz\n", 404 "NICAM/AM carrier : %d.%03d MHz\n",
405 state->second / 910000, (state->second / 910) % 1000); 405 state->second / 910000, (state->second / 910) % 1000);
406 if (state->mode == MSP_MODE_FM_TERRA && state->main != state->second) { 406 if (state->mode == MSP_MODE_FM_TERRA && state->main != state->second) {
407 v4l_dbg(1, msp_debug, client, 407 dev_dbg_lvl(&client->dev, 1, msp_debug,
408 "FM-stereo carrier : %d.%03d MHz\n", 408 "FM-stereo carrier : %d.%03d MHz\n",
409 state->second / 910000, (state->second / 910) % 1000); 409 state->second / 910000, (state->second / 910) % 1000);
410 } 410 }
@@ -425,7 +425,7 @@ static int msp3400c_detect_stereo(struct i2c_client *client)
425 val = msp_read_dsp(client, 0x18); 425 val = msp_read_dsp(client, 0x18);
426 if (val > 32767) 426 if (val > 32767)
427 val -= 65536; 427 val -= 65536;
428 v4l_dbg(2, msp_debug, client, 428 dev_dbg_lvl(&client->dev, 2, msp_debug,
429 "stereo detect register: %d\n", val); 429 "stereo detect register: %d\n", val);
430 if (val > 8192) { 430 if (val > 8192) {
431 rxsubchans = V4L2_TUNER_SUB_STEREO; 431 rxsubchans = V4L2_TUNER_SUB_STEREO;
@@ -440,7 +440,7 @@ static int msp3400c_detect_stereo(struct i2c_client *client)
440 case MSP_MODE_FM_NICAM2: 440 case MSP_MODE_FM_NICAM2:
441 case MSP_MODE_AM_NICAM: 441 case MSP_MODE_AM_NICAM:
442 val = msp_read_dem(client, 0x23); 442 val = msp_read_dem(client, 0x23);
443 v4l_dbg(2, msp_debug, client, "nicam sync=%d, mode=%d\n", 443 dev_dbg_lvl(&client->dev, 2, msp_debug, "nicam sync=%d, mode=%d\n",
444 val & 1, (val & 0x1e) >> 1); 444 val & 1, (val & 0x1e) >> 1);
445 445
446 if (val & 1) { 446 if (val & 1) {
@@ -471,14 +471,14 @@ static int msp3400c_detect_stereo(struct i2c_client *client)
471 } 471 }
472 if (rxsubchans != state->rxsubchans) { 472 if (rxsubchans != state->rxsubchans) {
473 update = 1; 473 update = 1;
474 v4l_dbg(1, msp_debug, client, 474 dev_dbg_lvl(&client->dev, 1, msp_debug,
475 "watch: rxsubchans %02x => %02x\n", 475 "watch: rxsubchans %02x => %02x\n",
476 state->rxsubchans, rxsubchans); 476 state->rxsubchans, rxsubchans);
477 state->rxsubchans = rxsubchans; 477 state->rxsubchans = rxsubchans;
478 } 478 }
479 if (newnicam != state->nicam_on) { 479 if (newnicam != state->nicam_on) {
480 update = 1; 480 update = 1;
481 v4l_dbg(1, msp_debug, client, "watch: nicam %d => %d\n", 481 dev_dbg_lvl(&client->dev, 1, msp_debug, "watch: nicam %d => %d\n",
482 state->nicam_on, newnicam); 482 state->nicam_on, newnicam);
483 state->nicam_on = newnicam; 483 state->nicam_on = newnicam;
484 } 484 }
@@ -508,23 +508,23 @@ int msp3400c_thread(void *data)
508 struct msp3400c_carrier_detect *cd; 508 struct msp3400c_carrier_detect *cd;
509 int count, max1, max2, val1, val2, val, i; 509 int count, max1, max2, val1, val2, val, i;
510 510
511 v4l_dbg(1, msp_debug, client, "msp3400 daemon started\n"); 511 dev_dbg_lvl(&client->dev, 1, msp_debug, "msp3400 daemon started\n");
512 state->detected_std = V4L2_STD_ALL; 512 state->detected_std = V4L2_STD_ALL;
513 set_freezable(); 513 set_freezable();
514 for (;;) { 514 for (;;) {
515 v4l_dbg(2, msp_debug, client, "msp3400 thread: sleep\n"); 515 dev_dbg_lvl(&client->dev, 2, msp_debug, "msp3400 thread: sleep\n");
516 msp_sleep(state, -1); 516 msp_sleep(state, -1);
517 v4l_dbg(2, msp_debug, client, "msp3400 thread: wakeup\n"); 517 dev_dbg_lvl(&client->dev, 2, msp_debug, "msp3400 thread: wakeup\n");
518 518
519restart: 519restart:
520 v4l_dbg(2, msp_debug, client, "thread: restart scan\n"); 520 dev_dbg_lvl(&client->dev, 2, msp_debug, "thread: restart scan\n");
521 state->restart = 0; 521 state->restart = 0;
522 if (kthread_should_stop()) 522 if (kthread_should_stop())
523 break; 523 break;
524 524
525 if (state->radio || MSP_MODE_EXTERN == state->mode) { 525 if (state->radio || MSP_MODE_EXTERN == state->mode) {
526 /* no carrier scan, just unmute */ 526 /* no carrier scan, just unmute */
527 v4l_dbg(1, msp_debug, client, 527 dev_dbg_lvl(&client->dev, 1, msp_debug,
528 "thread: no carrier scan\n"); 528 "thread: no carrier scan\n");
529 state->scan_in_progress = 0; 529 state->scan_in_progress = 0;
530 msp_update_volume(state); 530 msp_update_volume(state);
@@ -553,7 +553,7 @@ restart:
553 /* autodetect doesn't work well with AM ... */ 553 /* autodetect doesn't work well with AM ... */
554 max1 = 3; 554 max1 = 3;
555 count = 0; 555 count = 0;
556 v4l_dbg(1, msp_debug, client, "AM sound override\n"); 556 dev_dbg_lvl(&client->dev, 1, msp_debug, "AM sound override\n");
557 } 557 }
558 558
559 for (i = 0; i < count; i++) { 559 for (i = 0; i < count; i++) {
@@ -565,7 +565,7 @@ restart:
565 val -= 65536; 565 val -= 65536;
566 if (val1 < val) 566 if (val1 < val)
567 val1 = val, max1 = i; 567 val1 = val, max1 = i;
568 v4l_dbg(1, msp_debug, client, 568 dev_dbg_lvl(&client->dev, 1, msp_debug,
569 "carrier1 val: %5d / %s\n", val, cd[i].name); 569 "carrier1 val: %5d / %s\n", val, cd[i].name);
570 } 570 }
571 571
@@ -602,7 +602,7 @@ restart:
602 val -= 65536; 602 val -= 65536;
603 if (val2 < val) 603 if (val2 < val)
604 val2 = val, max2 = i; 604 val2 = val, max2 = i;
605 v4l_dbg(1, msp_debug, client, 605 dev_dbg_lvl(&client->dev, 1, msp_debug,
606 "carrier2 val: %5d / %s\n", val, cd[i].name); 606 "carrier2 val: %5d / %s\n", val, cd[i].name);
607 } 607 }
608 608
@@ -687,7 +687,7 @@ no_second:
687 watch_stereo(client); 687 watch_stereo(client);
688 } 688 }
689 } 689 }
690 v4l_dbg(1, msp_debug, client, "thread: exit\n"); 690 dev_dbg_lvl(&client->dev, 1, msp_debug, "thread: exit\n");
691 return 0; 691 return 0;
692} 692}
693 693
@@ -698,23 +698,23 @@ int msp3410d_thread(void *data)
698 struct msp_state *state = to_state(i2c_get_clientdata(client)); 698 struct msp_state *state = to_state(i2c_get_clientdata(client));
699 int val, i, std, count; 699 int val, i, std, count;
700 700
701 v4l_dbg(1, msp_debug, client, "msp3410 daemon started\n"); 701 dev_dbg_lvl(&client->dev, 1, msp_debug, "msp3410 daemon started\n");
702 state->detected_std = V4L2_STD_ALL; 702 state->detected_std = V4L2_STD_ALL;
703 set_freezable(); 703 set_freezable();
704 for (;;) { 704 for (;;) {
705 v4l_dbg(2, msp_debug, client, "msp3410 thread: sleep\n"); 705 dev_dbg_lvl(&client->dev, 2, msp_debug, "msp3410 thread: sleep\n");
706 msp_sleep(state, -1); 706 msp_sleep(state, -1);
707 v4l_dbg(2, msp_debug, client, "msp3410 thread: wakeup\n"); 707 dev_dbg_lvl(&client->dev, 2, msp_debug, "msp3410 thread: wakeup\n");
708 708
709restart: 709restart:
710 v4l_dbg(2, msp_debug, client, "thread: restart scan\n"); 710 dev_dbg_lvl(&client->dev, 2, msp_debug, "thread: restart scan\n");
711 state->restart = 0; 711 state->restart = 0;
712 if (kthread_should_stop()) 712 if (kthread_should_stop())
713 break; 713 break;
714 714
715 if (state->mode == MSP_MODE_EXTERN) { 715 if (state->mode == MSP_MODE_EXTERN) {
716 /* no carrier scan needed, just unmute */ 716 /* no carrier scan needed, just unmute */
717 v4l_dbg(1, msp_debug, client, 717 dev_dbg_lvl(&client->dev, 1, msp_debug,
718 "thread: no carrier scan\n"); 718 "thread: no carrier scan\n");
719 state->scan_in_progress = 0; 719 state->scan_in_progress = 0;
720 msp_update_volume(state); 720 msp_update_volume(state);
@@ -740,7 +740,7 @@ restart:
740 goto restart; 740 goto restart;
741 741
742 if (msp_debug) 742 if (msp_debug)
743 v4l_dbg(2, msp_debug, client, 743 dev_dbg_lvl(&client->dev, 2, msp_debug,
744 "setting standard: %s (0x%04x)\n", 744 "setting standard: %s (0x%04x)\n",
745 msp_standard_std_name(std), std); 745 msp_standard_std_name(std), std);
746 746
@@ -758,14 +758,14 @@ restart:
758 val = msp_read_dem(client, 0x7e); 758 val = msp_read_dem(client, 0x7e);
759 if (val < 0x07ff) 759 if (val < 0x07ff)
760 break; 760 break;
761 v4l_dbg(2, msp_debug, client, 761 dev_dbg_lvl(&client->dev, 2, msp_debug,
762 "detection still in progress\n"); 762 "detection still in progress\n");
763 } 763 }
764 } 764 }
765 for (i = 0; msp_stdlist[i].name != NULL; i++) 765 for (i = 0; msp_stdlist[i].name != NULL; i++)
766 if (msp_stdlist[i].retval == val) 766 if (msp_stdlist[i].retval == val)
767 break; 767 break;
768 v4l_dbg(1, msp_debug, client, "current standard: %s (0x%04x)\n", 768 dev_dbg_lvl(&client->dev, 1, msp_debug, "current standard: %s (0x%04x)\n",
769 msp_standard_std_name(val), val); 769 msp_standard_std_name(val), val);
770 state->main = msp_stdlist[i].main; 770 state->main = msp_stdlist[i].main;
771 state->second = msp_stdlist[i].second; 771 state->second = msp_stdlist[i].second;
@@ -775,8 +775,7 @@ restart:
775 if (msp_amsound && !state->radio && 775 if (msp_amsound && !state->radio &&
776 (state->v4l2_std & V4L2_STD_SECAM) && (val != 0x0009)) { 776 (state->v4l2_std & V4L2_STD_SECAM) && (val != 0x0009)) {
777 /* autodetection has failed, let backup */ 777 /* autodetection has failed, let backup */
778 v4l_dbg(1, msp_debug, client, "autodetection failed," 778 dev_dbg_lvl(&client->dev, 1, msp_debug, "autodetection failed, switching to backup standard: %s (0x%04x)\n",
779 " switching to backup standard: %s (0x%04x)\n",
780 msp_stdlist[8].name ? 779 msp_stdlist[8].name ?
781 msp_stdlist[8].name : "unknown", val); 780 msp_stdlist[8].name : "unknown", val);
782 state->std = val = 0x0009; 781 state->std = val = 0x0009;
@@ -850,7 +849,7 @@ restart:
850 watch_stereo(client); 849 watch_stereo(client);
851 } 850 }
852 } 851 }
853 v4l_dbg(1, msp_debug, client, "thread: exit\n"); 852 dev_dbg_lvl(&client->dev, 1, msp_debug, "thread: exit\n");
854 return 0; 853 return 0;
855} 854}
856 855
@@ -867,23 +866,23 @@ static int msp34xxg_modus(struct i2c_client *client)
867 struct msp_state *state = to_state(i2c_get_clientdata(client)); 866 struct msp_state *state = to_state(i2c_get_clientdata(client));
868 867
869 if (state->radio) { 868 if (state->radio) {
870 v4l_dbg(1, msp_debug, client, "selected radio modus\n"); 869 dev_dbg_lvl(&client->dev, 1, msp_debug, "selected radio modus\n");
871 return 0x0001; 870 return 0x0001;
872 } 871 }
873 if (state->v4l2_std == V4L2_STD_NTSC_M_JP) { 872 if (state->v4l2_std == V4L2_STD_NTSC_M_JP) {
874 v4l_dbg(1, msp_debug, client, "selected M (EIA-J) modus\n"); 873 dev_dbg_lvl(&client->dev, 1, msp_debug, "selected M (EIA-J) modus\n");
875 return 0x4001; 874 return 0x4001;
876 } 875 }
877 if (state->v4l2_std == V4L2_STD_NTSC_M_KR) { 876 if (state->v4l2_std == V4L2_STD_NTSC_M_KR) {
878 v4l_dbg(1, msp_debug, client, "selected M (A2) modus\n"); 877 dev_dbg_lvl(&client->dev, 1, msp_debug, "selected M (A2) modus\n");
879 return 0x0001; 878 return 0x0001;
880 } 879 }
881 if (state->v4l2_std == V4L2_STD_SECAM_L) { 880 if (state->v4l2_std == V4L2_STD_SECAM_L) {
882 v4l_dbg(1, msp_debug, client, "selected SECAM-L modus\n"); 881 dev_dbg_lvl(&client->dev, 1, msp_debug, "selected SECAM-L modus\n");
883 return 0x6001; 882 return 0x6001;
884 } 883 }
885 if (state->v4l2_std & V4L2_STD_MN) { 884 if (state->v4l2_std & V4L2_STD_MN) {
886 v4l_dbg(1, msp_debug, client, "selected M (BTSC) modus\n"); 885 dev_dbg_lvl(&client->dev, 1, msp_debug, "selected M (BTSC) modus\n");
887 return 0x2001; 886 return 0x2001;
888 } 887 }
889 return 0x7001; 888 return 0x7001;
@@ -927,7 +926,7 @@ static void msp34xxg_set_source(struct i2c_client *client, u16 reg, int in)
927 else 926 else
928 source = (in << 8) | matrix; 927 source = (in << 8) | matrix;
929 928
930 v4l_dbg(1, msp_debug, client, 929 dev_dbg_lvl(&client->dev, 1, msp_debug,
931 "set source to %d (0x%x) for output %02x\n", in, source, reg); 930 "set source to %d (0x%x) for output %02x\n", in, source, reg);
932 msp_write_dsp(client, reg, source); 931 msp_write_dsp(client, reg, source);
933} 932}
@@ -996,23 +995,23 @@ int msp34xxg_thread(void *data)
996 struct msp_state *state = to_state(i2c_get_clientdata(client)); 995 struct msp_state *state = to_state(i2c_get_clientdata(client));
997 int val, i; 996 int val, i;
998 997
999 v4l_dbg(1, msp_debug, client, "msp34xxg daemon started\n"); 998 dev_dbg_lvl(&client->dev, 1, msp_debug, "msp34xxg daemon started\n");
1000 state->detected_std = V4L2_STD_ALL; 999 state->detected_std = V4L2_STD_ALL;
1001 set_freezable(); 1000 set_freezable();
1002 for (;;) { 1001 for (;;) {
1003 v4l_dbg(2, msp_debug, client, "msp34xxg thread: sleep\n"); 1002 dev_dbg_lvl(&client->dev, 2, msp_debug, "msp34xxg thread: sleep\n");
1004 msp_sleep(state, -1); 1003 msp_sleep(state, -1);
1005 v4l_dbg(2, msp_debug, client, "msp34xxg thread: wakeup\n"); 1004 dev_dbg_lvl(&client->dev, 2, msp_debug, "msp34xxg thread: wakeup\n");
1006 1005
1007restart: 1006restart:
1008 v4l_dbg(1, msp_debug, client, "thread: restart scan\n"); 1007 dev_dbg_lvl(&client->dev, 1, msp_debug, "thread: restart scan\n");
1009 state->restart = 0; 1008 state->restart = 0;
1010 if (kthread_should_stop()) 1009 if (kthread_should_stop())
1011 break; 1010 break;
1012 1011
1013 if (state->mode == MSP_MODE_EXTERN) { 1012 if (state->mode == MSP_MODE_EXTERN) {
1014 /* no carrier scan needed, just unmute */ 1013 /* no carrier scan needed, just unmute */
1015 v4l_dbg(1, msp_debug, client, 1014 dev_dbg_lvl(&client->dev, 1, msp_debug,
1016 "thread: no carrier scan\n"); 1015 "thread: no carrier scan\n");
1017 state->scan_in_progress = 0; 1016 state->scan_in_progress = 0;
1018 msp_update_volume(state); 1017 msp_update_volume(state);
@@ -1029,7 +1028,7 @@ restart:
1029 goto unmute; 1028 goto unmute;
1030 1029
1031 /* watch autodetect */ 1030 /* watch autodetect */
1032 v4l_dbg(1, msp_debug, client, 1031 dev_dbg_lvl(&client->dev, 1, msp_debug,
1033 "started autodetect, waiting for result\n"); 1032 "started autodetect, waiting for result\n");
1034 for (i = 0; i < 10; i++) { 1033 for (i = 0; i < 10; i++) {
1035 if (msp_sleep(state, 100)) 1034 if (msp_sleep(state, 100))
@@ -1041,17 +1040,17 @@ restart:
1041 state->std = val; 1040 state->std = val;
1042 break; 1041 break;
1043 } 1042 }
1044 v4l_dbg(2, msp_debug, client, 1043 dev_dbg_lvl(&client->dev, 2, msp_debug,
1045 "detection still in progress\n"); 1044 "detection still in progress\n");
1046 } 1045 }
1047 if (state->std == 1) { 1046 if (state->std == 1) {
1048 v4l_dbg(1, msp_debug, client, 1047 dev_dbg_lvl(&client->dev, 1, msp_debug,
1049 "detection still in progress after 10 tries. giving up.\n"); 1048 "detection still in progress after 10 tries. giving up.\n");
1050 continue; 1049 continue;
1051 } 1050 }
1052 1051
1053unmute: 1052unmute:
1054 v4l_dbg(1, msp_debug, client, 1053 dev_dbg_lvl(&client->dev, 1, msp_debug,
1055 "detected standard: %s (0x%04x)\n", 1054 "detected standard: %s (0x%04x)\n",
1056 msp_standard_std_name(state->std), state->std); 1055 msp_standard_std_name(state->std), state->std);
1057 state->detected_std = msp_standard_std(state->std); 1056 state->detected_std = msp_standard_std(state->std);
@@ -1084,7 +1083,7 @@ unmute:
1084 goto restart; 1083 goto restart;
1085 } 1084 }
1086 } 1085 }
1087 v4l_dbg(1, msp_debug, client, "thread: exit\n"); 1086 dev_dbg_lvl(&client->dev, 1, msp_debug, "thread: exit\n");
1088 return 0; 1087 return 0;
1089} 1088}
1090 1089
@@ -1111,7 +1110,7 @@ static int msp34xxg_detect_stereo(struct i2c_client *client)
1111 state->rxsubchans = 1110 state->rxsubchans =
1112 V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; 1111 V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
1113 } 1112 }
1114 v4l_dbg(1, msp_debug, client, 1113 dev_dbg_lvl(&client->dev, 1, msp_debug,
1115 "status=0x%x, stereo=%d, bilingual=%d -> rxsubchans=%d\n", 1114 "status=0x%x, stereo=%d, bilingual=%d -> rxsubchans=%d\n",
1116 status, is_stereo, is_bilingual, state->rxsubchans); 1115 status, is_stereo, is_bilingual, state->rxsubchans);
1117 return (oldrx != state->rxsubchans); 1116 return (oldrx != state->rxsubchans);
diff --git a/drivers/media/i2c/smiapp-pll.c b/drivers/media/i2c/smiapp-pll.c
index e3348db56c46..771db56332b2 100644
--- a/drivers/media/i2c/smiapp-pll.c
+++ b/drivers/media/i2c/smiapp-pll.c
@@ -479,7 +479,8 @@ int smiapp_pll_calculate(struct device *dev,
479 return 0; 479 return 0;
480 } 480 }
481 481
482 dev_info(dev, "unable to compute pre_pll divisor\n"); 482 dev_dbg(dev, "unable to compute pre_pll divisor\n");
483
483 return rval; 484 return rval;
484} 485}
485EXPORT_SYMBOL_GPL(smiapp_pll_calculate); 486EXPORT_SYMBOL_GPL(smiapp_pll_calculate);
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 44f8c7e10a35..59872b31f832 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -26,6 +26,7 @@
26#include <linux/gpio.h> 26#include <linux/gpio.h>
27#include <linux/gpio/consumer.h> 27#include <linux/gpio/consumer.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/pm_runtime.h>
29#include <linux/regulator/consumer.h> 30#include <linux/regulator/consumer.h>
30#include <linux/slab.h> 31#include <linux/slab.h>
31#include <linux/smiapp.h> 32#include <linux/smiapp.h>
@@ -68,10 +69,9 @@ static int smiapp_read_frame_fmt(struct smiapp_sensor *sensor)
68 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); 69 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
69 u32 fmt_model_type, fmt_model_subtype, ncol_desc, nrow_desc; 70 u32 fmt_model_type, fmt_model_subtype, ncol_desc, nrow_desc;
70 unsigned int i; 71 unsigned int i;
71 int rval; 72 int pixel_count = 0;
72 int line_count = 0; 73 int line_count = 0;
73 int embedded_start = -1, embedded_end = -1; 74 int rval;
74 int image_start = 0;
75 75
76 rval = smiapp_read(sensor, SMIAPP_REG_U8_FRAME_FORMAT_MODEL_TYPE, 76 rval = smiapp_read(sensor, SMIAPP_REG_U8_FRAME_FORMAT_MODEL_TYPE,
77 &fmt_model_type); 77 &fmt_model_type);
@@ -101,12 +101,11 @@ static int smiapp_read_frame_fmt(struct smiapp_sensor *sensor)
101 u32 pixels; 101 u32 pixels;
102 char *which; 102 char *which;
103 char *what; 103 char *what;
104 u32 reg;
104 105
105 if (fmt_model_type == SMIAPP_FRAME_FORMAT_MODEL_TYPE_2BYTE) { 106 if (fmt_model_type == SMIAPP_FRAME_FORMAT_MODEL_TYPE_2BYTE) {
106 rval = smiapp_read( 107 reg = SMIAPP_REG_U16_FRAME_FORMAT_DESCRIPTOR_2(i);
107 sensor, 108 rval = smiapp_read(sensor, reg, &desc);
108 SMIAPP_REG_U16_FRAME_FORMAT_DESCRIPTOR_2(i),
109 &desc);
110 if (rval) 109 if (rval)
111 return rval; 110 return rval;
112 111
@@ -117,10 +116,8 @@ static int smiapp_read_frame_fmt(struct smiapp_sensor *sensor)
117 pixels = desc & SMIAPP_FRAME_FORMAT_DESC_2_PIXELS_MASK; 116 pixels = desc & SMIAPP_FRAME_FORMAT_DESC_2_PIXELS_MASK;
118 } else if (fmt_model_type 117 } else if (fmt_model_type
119 == SMIAPP_FRAME_FORMAT_MODEL_TYPE_4BYTE) { 118 == SMIAPP_FRAME_FORMAT_MODEL_TYPE_4BYTE) {
120 rval = smiapp_read( 119 reg = SMIAPP_REG_U32_FRAME_FORMAT_DESCRIPTOR_4(i);
121 sensor, 120 rval = smiapp_read(sensor, reg, &desc);
122 SMIAPP_REG_U32_FRAME_FORMAT_DESCRIPTOR_4(i),
123 &desc);
124 if (rval) 121 if (rval)
125 return rval; 122 return rval;
126 123
@@ -159,40 +156,47 @@ static int smiapp_read_frame_fmt(struct smiapp_sensor *sensor)
159 break; 156 break;
160 default: 157 default:
161 what = "invalid"; 158 what = "invalid";
162 dev_dbg(&client->dev, "pixelcode %d\n", pixelcode);
163 break; 159 break;
164 } 160 }
165 161
166 dev_dbg(&client->dev, "%s pixels: %d %s\n", 162 dev_dbg(&client->dev,
167 what, pixels, which); 163 "0x%8.8x %s pixels: %d %s (pixelcode %u)\n", reg,
168 164 what, pixels, which, pixelcode);
169 if (i < ncol_desc) 165
166 if (i < ncol_desc) {
167 if (pixelcode ==
168 SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_VISIBLE)
169 sensor->visible_pixel_start = pixel_count;
170 pixel_count += pixels;
170 continue; 171 continue;
172 }
171 173
172 /* Handle row descriptors */ 174 /* Handle row descriptors */
173 if (pixelcode 175 switch (pixelcode) {
174 == SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_EMBEDDED) { 176 case SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_EMBEDDED:
175 embedded_start = line_count; 177 if (sensor->embedded_end)
176 } else { 178 break;
177 if (pixelcode == SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_VISIBLE 179 sensor->embedded_start = line_count;
178 || pixels >= sensor->limits[SMIAPP_LIMIT_MIN_FRAME_LENGTH_LINES] / 2) 180 sensor->embedded_end = line_count + pixels;
179 image_start = line_count; 181 break;
180 if (embedded_start != -1 && embedded_end == -1) 182 case SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_VISIBLE:
181 embedded_end = line_count; 183 sensor->image_start = line_count;
184 break;
182 } 185 }
183 line_count += pixels; 186 line_count += pixels;
184 } 187 }
185 188
186 if (embedded_start == -1 || embedded_end == -1) { 189 if (sensor->embedded_end > sensor->image_start) {
187 embedded_start = 0; 190 dev_dbg(&client->dev,
188 embedded_end = 0; 191 "adjusting image start line to %u (was %u)\n",
192 sensor->embedded_end, sensor->image_start);
193 sensor->image_start = sensor->embedded_end;
189 } 194 }
190 195
191 sensor->image_start = image_start;
192
193 dev_dbg(&client->dev, "embedded data from lines %d to %d\n", 196 dev_dbg(&client->dev, "embedded data from lines %d to %d\n",
194 embedded_start, embedded_end); 197 sensor->embedded_start, sensor->embedded_end);
195 dev_dbg(&client->dev, "image data starts at line %d\n", image_start); 198 dev_dbg(&client->dev, "image data starts at line %d\n",
199 sensor->image_start);
196 200
197 return 0; 201 return 0;
198} 202}
@@ -443,8 +447,7 @@ static int smiapp_set_ctrl(struct v4l2_ctrl *ctrl)
443 orient |= SMIAPP_IMAGE_ORIENTATION_VFLIP; 447 orient |= SMIAPP_IMAGE_ORIENTATION_VFLIP;
444 448
445 orient ^= sensor->hvflip_inv_mask; 449 orient ^= sensor->hvflip_inv_mask;
446 rval = smiapp_write(sensor, 450 rval = smiapp_write(sensor, SMIAPP_REG_U8_IMAGE_ORIENTATION,
447 SMIAPP_REG_U8_IMAGE_ORIENTATION,
448 orient); 451 orient);
449 if (rval < 0) 452 if (rval < 0)
450 return rval; 453 return rval;
@@ -459,10 +462,8 @@ static int smiapp_set_ctrl(struct v4l2_ctrl *ctrl)
459 __smiapp_update_exposure_limits(sensor); 462 __smiapp_update_exposure_limits(sensor);
460 463
461 if (exposure > sensor->exposure->maximum) { 464 if (exposure > sensor->exposure->maximum) {
462 sensor->exposure->val = 465 sensor->exposure->val = sensor->exposure->maximum;
463 sensor->exposure->maximum; 466 rval = smiapp_set_ctrl(sensor->exposure);
464 rval = smiapp_set_ctrl(
465 sensor->exposure);
466 if (rval < 0) 467 if (rval < 0)
467 return rval; 468 return rval;
468 } 469 }
@@ -621,7 +622,7 @@ static int smiapp_init_controls(struct smiapp_sensor *sensor)
621static int smiapp_init_late_controls(struct smiapp_sensor *sensor) 622static int smiapp_init_late_controls(struct smiapp_sensor *sensor)
622{ 623{
623 unsigned long *valid_link_freqs = &sensor->valid_link_freqs[ 624 unsigned long *valid_link_freqs = &sensor->valid_link_freqs[
624 sensor->csi_format->compressed - SMIAPP_COMPRESSED_BASE]; 625 sensor->csi_format->compressed - sensor->compressed_min_bpp];
625 unsigned int max, i; 626 unsigned int max, i;
626 627
627 for (i = 0; i < ARRAY_SIZE(sensor->test_data); i++) { 628 for (i = 0; i < ARRAY_SIZE(sensor->test_data); i++) {
@@ -754,6 +755,7 @@ static int smiapp_get_mbus_formats(struct smiapp_sensor *sensor)
754{ 755{
755 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); 756 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
756 struct smiapp_pll *pll = &sensor->pll; 757 struct smiapp_pll *pll = &sensor->pll;
758 u8 compressed_max_bpp = 0;
757 unsigned int type, n; 759 unsigned int type, n;
758 unsigned int i, pixel_order; 760 unsigned int i, pixel_order;
759 int rval; 761 int rval;
@@ -826,16 +828,27 @@ static int smiapp_get_mbus_formats(struct smiapp_sensor *sensor)
826 pll->scale_m = sensor->scale_m; 828 pll->scale_m = sensor->scale_m;
827 829
828 for (i = 0; i < ARRAY_SIZE(smiapp_csi_data_formats); i++) { 830 for (i = 0; i < ARRAY_SIZE(smiapp_csi_data_formats); i++) {
831 sensor->compressed_min_bpp =
832 min(smiapp_csi_data_formats[i].compressed,
833 sensor->compressed_min_bpp);
834 compressed_max_bpp =
835 max(smiapp_csi_data_formats[i].compressed,
836 compressed_max_bpp);
837 }
838
839 sensor->valid_link_freqs = devm_kcalloc(
840 &client->dev,
841 compressed_max_bpp - sensor->compressed_min_bpp + 1,
842 sizeof(*sensor->valid_link_freqs), GFP_KERNEL);
843
844 for (i = 0; i < ARRAY_SIZE(smiapp_csi_data_formats); i++) {
829 const struct smiapp_csi_data_format *f = 845 const struct smiapp_csi_data_format *f =
830 &smiapp_csi_data_formats[i]; 846 &smiapp_csi_data_formats[i];
831 unsigned long *valid_link_freqs = 847 unsigned long *valid_link_freqs =
832 &sensor->valid_link_freqs[ 848 &sensor->valid_link_freqs[
833 f->compressed - SMIAPP_COMPRESSED_BASE]; 849 f->compressed - sensor->compressed_min_bpp];
834 unsigned int j; 850 unsigned int j;
835 851
836 BUG_ON(f->compressed < SMIAPP_COMPRESSED_BASE);
837 BUG_ON(f->compressed > SMIAPP_COMPRESSED_MAX);
838
839 if (!(sensor->default_mbus_frame_fmts & 1 << i)) 852 if (!(sensor->default_mbus_frame_fmts & 1 << i))
840 continue; 853 continue;
841 854
@@ -914,12 +927,6 @@ static int smiapp_update_mode(struct smiapp_sensor *sensor)
914 unsigned int binning_mode; 927 unsigned int binning_mode;
915 int rval; 928 int rval;
916 929
917 dev_dbg(&client->dev, "frame size: %dx%d\n",
918 sensor->src->crop[SMIAPP_PAD_SRC].width,
919 sensor->src->crop[SMIAPP_PAD_SRC].height);
920 dev_dbg(&client->dev, "csi format width: %d\n",
921 sensor->csi_format->width);
922
923 /* Binning has to be set up here; it affects limits */ 930 /* Binning has to be set up here; it affects limits */
924 if (sensor->binning_horizontal == 1 && 931 if (sensor->binning_horizontal == 1 &&
925 sensor->binning_vertical == 1) { 932 sensor->binning_vertical == 1) {
@@ -1196,9 +1203,17 @@ out:
1196 * Power management 1203 * Power management
1197 */ 1204 */
1198 1205
1199static int smiapp_power_on(struct smiapp_sensor *sensor) 1206static int smiapp_power_on(struct device *dev)
1200{ 1207{
1201 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); 1208 struct i2c_client *client = to_i2c_client(dev);
1209 struct v4l2_subdev *subdev = i2c_get_clientdata(client);
1210 struct smiapp_subdev *ssd = to_smiapp_subdev(subdev);
1211 /*
1212 * The sub-device related to the I2C device is always the
1213 * source one, i.e. ssds[0].
1214 */
1215 struct smiapp_sensor *sensor =
1216 container_of(ssd, struct smiapp_sensor, ssds[0]);
1202 unsigned int sleep; 1217 unsigned int sleep;
1203 int rval; 1218 int rval;
1204 1219
@@ -1307,8 +1322,7 @@ static int smiapp_power_on(struct smiapp_sensor *sensor)
1307 if (!sensor->pixel_array) 1322 if (!sensor->pixel_array)
1308 return 0; 1323 return 0;
1309 1324
1310 rval = v4l2_ctrl_handler_setup( 1325 rval = v4l2_ctrl_handler_setup(&sensor->pixel_array->ctrl_handler);
1311 &sensor->pixel_array->ctrl_handler);
1312 if (rval) 1326 if (rval)
1313 goto out_cci_addr_fail; 1327 goto out_cci_addr_fail;
1314 1328
@@ -1325,16 +1339,24 @@ static int smiapp_power_on(struct smiapp_sensor *sensor)
1325 return 0; 1339 return 0;
1326 1340
1327out_cci_addr_fail: 1341out_cci_addr_fail:
1342
1328 gpiod_set_value(sensor->xshutdown, 0); 1343 gpiod_set_value(sensor->xshutdown, 0);
1329 clk_disable_unprepare(sensor->ext_clk); 1344 clk_disable_unprepare(sensor->ext_clk);
1330 1345
1331out_xclk_fail: 1346out_xclk_fail:
1332 regulator_disable(sensor->vana); 1347 regulator_disable(sensor->vana);
1348
1333 return rval; 1349 return rval;
1334} 1350}
1335 1351
1336static void smiapp_power_off(struct smiapp_sensor *sensor) 1352static int smiapp_power_off(struct device *dev)
1337{ 1353{
1354 struct i2c_client *client = to_i2c_client(dev);
1355 struct v4l2_subdev *subdev = i2c_get_clientdata(client);
1356 struct smiapp_subdev *ssd = to_smiapp_subdev(subdev);
1357 struct smiapp_sensor *sensor =
1358 container_of(ssd, struct smiapp_sensor, ssds[0]);
1359
1338 /* 1360 /*
1339 * Currently power/clock to lens are enable/disabled separately 1361 * Currently power/clock to lens are enable/disabled separately
1340 * but they are essentially the same signals. So if the sensor is 1362 * but they are essentially the same signals. So if the sensor is
@@ -1352,31 +1374,31 @@ static void smiapp_power_off(struct smiapp_sensor *sensor)
1352 usleep_range(5000, 5000); 1374 usleep_range(5000, 5000);
1353 regulator_disable(sensor->vana); 1375 regulator_disable(sensor->vana);
1354 sensor->streaming = false; 1376 sensor->streaming = false;
1377
1378 return 0;
1355} 1379}
1356 1380
1357static int smiapp_set_power(struct v4l2_subdev *subdev, int on) 1381static int smiapp_set_power(struct v4l2_subdev *subdev, int on)
1358{ 1382{
1359 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev); 1383 int rval;
1360 int ret = 0;
1361 1384
1362 mutex_lock(&sensor->power_mutex); 1385 if (!on) {
1386 pm_runtime_mark_last_busy(subdev->dev);
1387 pm_runtime_put_autosuspend(subdev->dev);
1363 1388
1364 if (on && !sensor->power_count) { 1389 return 0;
1365 /* Power on and perform initialisation. */
1366 ret = smiapp_power_on(sensor);
1367 if (ret < 0)
1368 goto out;
1369 } else if (!on && sensor->power_count == 1) {
1370 smiapp_power_off(sensor);
1371 } 1390 }
1372 1391
1373 /* Update the power count. */ 1392 rval = pm_runtime_get_sync(subdev->dev);
1374 sensor->power_count += on ? 1 : -1; 1393 if (rval >= 0)
1375 WARN_ON(sensor->power_count < 0); 1394 return 0;
1376 1395
1377out: 1396 if (rval != -EBUSY && rval != -EAGAIN)
1378 mutex_unlock(&sensor->power_mutex); 1397 pm_runtime_set_active(subdev->dev);
1379 return ret; 1398
1399 pm_runtime_put(subdev->dev);
1400
1401 return rval;
1380} 1402}
1381 1403
1382/* ----------------------------------------------------------------------------- 1404/* -----------------------------------------------------------------------------
@@ -1614,7 +1636,8 @@ static int __smiapp_get_format(struct v4l2_subdev *subdev,
1614 struct smiapp_subdev *ssd = to_smiapp_subdev(subdev); 1636 struct smiapp_subdev *ssd = to_smiapp_subdev(subdev);
1615 1637
1616 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 1638 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1617 fmt->format = *v4l2_subdev_get_try_format(subdev, cfg, fmt->pad); 1639 fmt->format = *v4l2_subdev_get_try_format(subdev, cfg,
1640 fmt->pad);
1618 } else { 1641 } else {
1619 struct v4l2_rect *r; 1642 struct v4l2_rect *r;
1620 1643
@@ -1714,7 +1737,6 @@ static void smiapp_propagate(struct v4l2_subdev *subdev,
1714static const struct smiapp_csi_data_format 1737static const struct smiapp_csi_data_format
1715*smiapp_validate_csi_data_format(struct smiapp_sensor *sensor, u32 code) 1738*smiapp_validate_csi_data_format(struct smiapp_sensor *sensor, u32 code)
1716{ 1739{
1717 const struct smiapp_csi_data_format *csi_format = sensor->csi_format;
1718 unsigned int i; 1740 unsigned int i;
1719 1741
1720 for (i = 0; i < ARRAY_SIZE(smiapp_csi_data_formats); i++) { 1742 for (i = 0; i < ARRAY_SIZE(smiapp_csi_data_formats); i++) {
@@ -1723,7 +1745,7 @@ static const struct smiapp_csi_data_format
1723 return &smiapp_csi_data_formats[i]; 1745 return &smiapp_csi_data_formats[i];
1724 } 1746 }
1725 1747
1726 return csi_format; 1748 return sensor->csi_format;
1727} 1749}
1728 1750
1729static int smiapp_set_format_source(struct v4l2_subdev *subdev, 1751static int smiapp_set_format_source(struct v4l2_subdev *subdev,
@@ -1769,7 +1791,7 @@ static int smiapp_set_format_source(struct v4l2_subdev *subdev,
1769 1791
1770 valid_link_freqs = 1792 valid_link_freqs =
1771 &sensor->valid_link_freqs[sensor->csi_format->compressed 1793 &sensor->valid_link_freqs[sensor->csi_format->compressed
1772 - SMIAPP_COMPRESSED_BASE]; 1794 - sensor->compressed_min_bpp];
1773 1795
1774 __v4l2_ctrl_modify_range( 1796 __v4l2_ctrl_modify_range(
1775 sensor->link_freq, 0, 1797 sensor->link_freq, 0,
@@ -2057,8 +2079,7 @@ static int smiapp_set_compose(struct v4l2_subdev *subdev,
2057 smiapp_set_compose_scaler(subdev, cfg, sel, crops, comp); 2079 smiapp_set_compose_scaler(subdev, cfg, sel, crops, comp);
2058 2080
2059 *comp = sel->r; 2081 *comp = sel->r;
2060 smiapp_propagate(subdev, cfg, sel->which, 2082 smiapp_propagate(subdev, cfg, sel->which, V4L2_SEL_TGT_COMPOSE);
2061 V4L2_SEL_TGT_COMPOSE);
2062 2083
2063 if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE) 2084 if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE)
2064 return smiapp_update_mode(sensor); 2085 return smiapp_update_mode(sensor);
@@ -2135,9 +2156,8 @@ static int smiapp_set_crop(struct v4l2_subdev *subdev,
2135 ->height; 2156 ->height;
2136 src_size = &_r; 2157 src_size = &_r;
2137 } else { 2158 } else {
2138 src_size = 2159 src_size = v4l2_subdev_get_try_compose(
2139 v4l2_subdev_get_try_compose( 2160 subdev, cfg, ssd->sink_pad);
2140 subdev, cfg, ssd->sink_pad);
2141 } 2161 }
2142 } 2162 }
2143 2163
@@ -2161,6 +2181,15 @@ static int smiapp_set_crop(struct v4l2_subdev *subdev,
2161 return 0; 2181 return 0;
2162} 2182}
2163 2183
2184static void smiapp_get_native_size(struct smiapp_subdev *ssd,
2185 struct v4l2_rect *r)
2186{
2187 r->top = 0;
2188 r->left = 0;
2189 r->width = ssd->sensor->limits[SMIAPP_LIMIT_X_ADDR_MAX] + 1;
2190 r->height = ssd->sensor->limits[SMIAPP_LIMIT_Y_ADDR_MAX] + 1;
2191}
2192
2164static int __smiapp_get_selection(struct v4l2_subdev *subdev, 2193static int __smiapp_get_selection(struct v4l2_subdev *subdev,
2165 struct v4l2_subdev_pad_config *cfg, 2194 struct v4l2_subdev_pad_config *cfg,
2166 struct v4l2_subdev_selection *sel) 2195 struct v4l2_subdev_selection *sel)
@@ -2192,17 +2221,12 @@ static int __smiapp_get_selection(struct v4l2_subdev *subdev,
2192 switch (sel->target) { 2221 switch (sel->target) {
2193 case V4L2_SEL_TGT_CROP_BOUNDS: 2222 case V4L2_SEL_TGT_CROP_BOUNDS:
2194 case V4L2_SEL_TGT_NATIVE_SIZE: 2223 case V4L2_SEL_TGT_NATIVE_SIZE:
2195 if (ssd == sensor->pixel_array) { 2224 if (ssd == sensor->pixel_array)
2196 sel->r.left = sel->r.top = 0; 2225 smiapp_get_native_size(ssd, &sel->r);
2197 sel->r.width = 2226 else if (sel->pad == ssd->sink_pad)
2198 sensor->limits[SMIAPP_LIMIT_X_ADDR_MAX] + 1;
2199 sel->r.height =
2200 sensor->limits[SMIAPP_LIMIT_Y_ADDR_MAX] + 1;
2201 } else if (sel->pad == ssd->sink_pad) {
2202 sel->r = sink_fmt; 2227 sel->r = sink_fmt;
2203 } else { 2228 else
2204 sel->r = *comp; 2229 sel->r = *comp;
2205 }
2206 break; 2230 break;
2207 case V4L2_SEL_TGT_CROP: 2231 case V4L2_SEL_TGT_CROP:
2208 case V4L2_SEL_TGT_COMPOSE_BOUNDS: 2232 case V4L2_SEL_TGT_COMPOSE_BOUNDS:
@@ -2303,15 +2327,26 @@ smiapp_sysfs_nvm_read(struct device *dev, struct device_attribute *attr,
2303 return -EBUSY; 2327 return -EBUSY;
2304 2328
2305 if (!sensor->nvm_size) { 2329 if (!sensor->nvm_size) {
2330 int rval;
2331
2306 /* NVM not read yet - read it now */ 2332 /* NVM not read yet - read it now */
2307 sensor->nvm_size = sensor->hwcfg->nvm_size; 2333 sensor->nvm_size = sensor->hwcfg->nvm_size;
2308 if (smiapp_set_power(subdev, 1) < 0) 2334
2335 rval = pm_runtime_get_sync(&client->dev);
2336 if (rval < 0) {
2337 if (rval != -EBUSY && rval != -EAGAIN)
2338 pm_runtime_set_active(&client->dev);
2339 pm_runtime_put(&client->dev);
2309 return -ENODEV; 2340 return -ENODEV;
2341 }
2342
2310 if (smiapp_read_nvm(sensor, sensor->nvm)) { 2343 if (smiapp_read_nvm(sensor, sensor->nvm)) {
2311 dev_err(&client->dev, "nvm read failed\n"); 2344 dev_err(&client->dev, "nvm read failed\n");
2312 return -ENODEV; 2345 return -ENODEV;
2313 } 2346 }
2314 smiapp_set_power(subdev, 0); 2347
2348 pm_runtime_mark_last_busy(&client->dev);
2349 pm_runtime_put_autosuspend(&client->dev);
2315 } 2350 }
2316 /* 2351 /*
2317 * NVM is still way below a PAGE_SIZE, so we can safely 2352 * NVM is still way below a PAGE_SIZE, so we can safely
@@ -2475,383 +2510,160 @@ static const struct v4l2_subdev_ops smiapp_ops;
2475static const struct v4l2_subdev_internal_ops smiapp_internal_ops; 2510static const struct v4l2_subdev_internal_ops smiapp_internal_ops;
2476static const struct media_entity_operations smiapp_entity_ops; 2511static const struct media_entity_operations smiapp_entity_ops;
2477 2512
2478static int smiapp_register_subdevs(struct smiapp_sensor *sensor) 2513static int smiapp_register_subdev(struct smiapp_sensor *sensor,
2514 struct smiapp_subdev *ssd,
2515 struct smiapp_subdev *sink_ssd,
2516 u16 source_pad, u16 sink_pad, u32 link_flags)
2479{ 2517{
2480 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); 2518 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
2481 struct smiapp_subdev *ssds[] = {
2482 sensor->scaler,
2483 sensor->binner,
2484 sensor->pixel_array,
2485 };
2486 unsigned int i;
2487 int rval; 2519 int rval;
2488 2520
2489 for (i = 0; i < SMIAPP_SUBDEVS - 1; i++) { 2521 if (!sink_ssd)
2490 struct smiapp_subdev *this = ssds[i + 1]; 2522 return 0;
2491 struct smiapp_subdev *last = ssds[i];
2492
2493 if (!last)
2494 continue;
2495 2523
2496 rval = media_entity_pads_init(&this->sd.entity, 2524 rval = media_entity_pads_init(&ssd->sd.entity,
2497 this->npads, this->pads); 2525 ssd->npads, ssd->pads);
2498 if (rval) { 2526 if (rval) {
2499 dev_err(&client->dev, 2527 dev_err(&client->dev,
2500 "media_entity_pads_init failed\n"); 2528 "media_entity_pads_init failed\n");
2501 return rval; 2529 return rval;
2502 } 2530 }
2503 2531
2504 rval = v4l2_device_register_subdev(sensor->src->sd.v4l2_dev, 2532 rval = v4l2_device_register_subdev(sensor->src->sd.v4l2_dev,
2505 &this->sd); 2533 &ssd->sd);
2506 if (rval) { 2534 if (rval) {
2507 dev_err(&client->dev, 2535 dev_err(&client->dev,
2508 "v4l2_device_register_subdev failed\n"); 2536 "v4l2_device_register_subdev failed\n");
2509 return rval; 2537 return rval;
2510 } 2538 }
2511 2539
2512 rval = media_create_pad_link(&this->sd.entity, 2540 rval = media_create_pad_link(&ssd->sd.entity, source_pad,
2513 this->source_pad, 2541 &sink_ssd->sd.entity, sink_pad,
2514 &last->sd.entity, 2542 link_flags);
2515 last->sink_pad, 2543 if (rval) {
2516 MEDIA_LNK_FL_ENABLED | 2544 dev_err(&client->dev,
2517 MEDIA_LNK_FL_IMMUTABLE); 2545 "media_create_pad_link failed\n");
2518 if (rval) { 2546 v4l2_device_unregister_subdev(&ssd->sd);
2519 dev_err(&client->dev, 2547 return rval;
2520 "media_create_pad_link failed\n");
2521 return rval;
2522 }
2523 } 2548 }
2524 2549
2525 return 0; 2550 return 0;
2526} 2551}
2527 2552
2528static void smiapp_cleanup(struct smiapp_sensor *sensor) 2553static void smiapp_unregistered(struct v4l2_subdev *subdev)
2529{ 2554{
2530 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); 2555 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
2531 2556 unsigned int i;
2532 device_remove_file(&client->dev, &dev_attr_nvm);
2533 device_remove_file(&client->dev, &dev_attr_ident);
2534 2557
2535 smiapp_free_controls(sensor); 2558 for (i = 1; i < sensor->ssds_used; i++)
2559 v4l2_device_unregister_subdev(&sensor->ssds[i].sd);
2536} 2560}
2537 2561
2538static int smiapp_init(struct smiapp_sensor *sensor) 2562static int smiapp_registered(struct v4l2_subdev *subdev)
2539{ 2563{
2540 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); 2564 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
2541 struct smiapp_pll *pll = &sensor->pll;
2542 struct smiapp_subdev *last = NULL;
2543 unsigned int i;
2544 int rval; 2565 int rval;
2545 2566
2546 sensor->vana = devm_regulator_get(&client->dev, "vana"); 2567 if (sensor->scaler) {
2547 if (IS_ERR(sensor->vana)) { 2568 rval = smiapp_register_subdev(
2548 dev_err(&client->dev, "could not get regulator for vana\n"); 2569 sensor, sensor->binner, sensor->scaler,
2549 return PTR_ERR(sensor->vana); 2570 SMIAPP_PAD_SRC, SMIAPP_PAD_SINK,
2550 } 2571 MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE);
2551 2572 if (rval < 0)
2552 sensor->ext_clk = devm_clk_get(&client->dev, NULL); 2573 return rval;
2553 if (IS_ERR(sensor->ext_clk)) {
2554 dev_err(&client->dev, "could not get clock (%ld)\n",
2555 PTR_ERR(sensor->ext_clk));
2556 return -EPROBE_DEFER;
2557 }
2558
2559 rval = clk_set_rate(sensor->ext_clk,
2560 sensor->hwcfg->ext_clk);
2561 if (rval < 0) {
2562 dev_err(&client->dev,
2563 "unable to set clock freq to %u\n",
2564 sensor->hwcfg->ext_clk);
2565 return rval;
2566 } 2574 }
2567 2575
2568 sensor->xshutdown = devm_gpiod_get_optional(&client->dev, "xshutdown", 2576 rval = smiapp_register_subdev(
2569 GPIOD_OUT_LOW); 2577 sensor, sensor->pixel_array, sensor->binner,
2570 if (IS_ERR(sensor->xshutdown)) 2578 SMIAPP_PA_PAD_SRC, SMIAPP_PAD_SINK,
2571 return PTR_ERR(sensor->xshutdown); 2579 MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE);
2572
2573 rval = smiapp_power_on(sensor);
2574 if (rval) 2580 if (rval)
2575 return -ENODEV; 2581 goto out_err;
2576
2577 rval = smiapp_identify_module(sensor);
2578 if (rval) {
2579 rval = -ENODEV;
2580 goto out_power_off;
2581 }
2582
2583 rval = smiapp_get_all_limits(sensor);
2584 if (rval) {
2585 rval = -ENODEV;
2586 goto out_power_off;
2587 }
2588
2589 /*
2590 * Handle Sensor Module orientation on the board.
2591 *
2592 * The application of H-FLIP and V-FLIP on the sensor is modified by
2593 * the sensor orientation on the board.
2594 *
2595 * For SMIAPP_BOARD_SENSOR_ORIENT_180 the default behaviour is to set
2596 * both H-FLIP and V-FLIP for normal operation which also implies
2597 * that a set/unset operation for user space HFLIP and VFLIP v4l2
2598 * controls will need to be internally inverted.
2599 *
2600 * Rotation also changes the bayer pattern.
2601 */
2602 if (sensor->hwcfg->module_board_orient ==
2603 SMIAPP_MODULE_BOARD_ORIENT_180)
2604 sensor->hvflip_inv_mask = SMIAPP_IMAGE_ORIENTATION_HFLIP |
2605 SMIAPP_IMAGE_ORIENTATION_VFLIP;
2606
2607 rval = smiapp_call_quirk(sensor, limits);
2608 if (rval) {
2609 dev_err(&client->dev, "limits quirks failed\n");
2610 goto out_power_off;
2611 }
2612
2613 if (sensor->limits[SMIAPP_LIMIT_BINNING_CAPABILITY]) {
2614 u32 val;
2615
2616 rval = smiapp_read(sensor,
2617 SMIAPP_REG_U8_BINNING_SUBTYPES, &val);
2618 if (rval < 0) {
2619 rval = -ENODEV;
2620 goto out_power_off;
2621 }
2622 sensor->nbinning_subtypes = min_t(u8, val,
2623 SMIAPP_BINNING_SUBTYPES);
2624
2625 for (i = 0; i < sensor->nbinning_subtypes; i++) {
2626 rval = smiapp_read(
2627 sensor, SMIAPP_REG_U8_BINNING_TYPE_n(i), &val);
2628 if (rval < 0) {
2629 rval = -ENODEV;
2630 goto out_power_off;
2631 }
2632 sensor->binning_subtypes[i] =
2633 *(struct smiapp_binning_subtype *)&val;
2634 2582
2635 dev_dbg(&client->dev, "binning %xx%x\n", 2583 return 0;
2636 sensor->binning_subtypes[i].horizontal,
2637 sensor->binning_subtypes[i].vertical);
2638 }
2639 }
2640 sensor->binning_horizontal = 1;
2641 sensor->binning_vertical = 1;
2642 2584
2643 if (device_create_file(&client->dev, &dev_attr_ident) != 0) { 2585out_err:
2644 dev_err(&client->dev, "sysfs ident entry creation failed\n"); 2586 smiapp_unregistered(subdev);
2645 rval = -ENOENT;
2646 goto out_power_off;
2647 }
2648 /* SMIA++ NVM initialization - it will be read from the sensor
2649 * when it is first requested by userspace.
2650 */
2651 if (sensor->minfo.smiapp_version && sensor->hwcfg->nvm_size) {
2652 sensor->nvm = devm_kzalloc(&client->dev,
2653 sensor->hwcfg->nvm_size, GFP_KERNEL);
2654 if (sensor->nvm == NULL) {
2655 dev_err(&client->dev, "nvm buf allocation failed\n");
2656 rval = -ENOMEM;
2657 goto out_cleanup;
2658 }
2659 2587
2660 if (device_create_file(&client->dev, &dev_attr_nvm) != 0) { 2588 return rval;
2661 dev_err(&client->dev, "sysfs nvm entry failed\n"); 2589}
2662 rval = -EBUSY;
2663 goto out_cleanup;
2664 }
2665 }
2666 2590
2667 /* We consider this as profile 0 sensor if any of these are zero. */ 2591static void smiapp_cleanup(struct smiapp_sensor *sensor)
2668 if (!sensor->limits[SMIAPP_LIMIT_MIN_OP_SYS_CLK_DIV] || 2592{
2669 !sensor->limits[SMIAPP_LIMIT_MAX_OP_SYS_CLK_DIV] || 2593 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
2670 !sensor->limits[SMIAPP_LIMIT_MIN_OP_PIX_CLK_DIV] ||
2671 !sensor->limits[SMIAPP_LIMIT_MAX_OP_PIX_CLK_DIV]) {
2672 sensor->minfo.smiapp_profile = SMIAPP_PROFILE_0;
2673 } else if (sensor->limits[SMIAPP_LIMIT_SCALING_CAPABILITY]
2674 != SMIAPP_SCALING_CAPABILITY_NONE) {
2675 if (sensor->limits[SMIAPP_LIMIT_SCALING_CAPABILITY]
2676 == SMIAPP_SCALING_CAPABILITY_HORIZONTAL)
2677 sensor->minfo.smiapp_profile = SMIAPP_PROFILE_1;
2678 else
2679 sensor->minfo.smiapp_profile = SMIAPP_PROFILE_2;
2680 sensor->scaler = &sensor->ssds[sensor->ssds_used];
2681 sensor->ssds_used++;
2682 } else if (sensor->limits[SMIAPP_LIMIT_DIGITAL_CROP_CAPABILITY]
2683 == SMIAPP_DIGITAL_CROP_CAPABILITY_INPUT_CROP) {
2684 sensor->scaler = &sensor->ssds[sensor->ssds_used];
2685 sensor->ssds_used++;
2686 }
2687 sensor->binner = &sensor->ssds[sensor->ssds_used];
2688 sensor->ssds_used++;
2689 sensor->pixel_array = &sensor->ssds[sensor->ssds_used];
2690 sensor->ssds_used++;
2691 2594
2692 sensor->scale_m = sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN]; 2595 device_remove_file(&client->dev, &dev_attr_nvm);
2596 device_remove_file(&client->dev, &dev_attr_ident);
2693 2597
2694 /* prepare PLL configuration input values */ 2598 smiapp_free_controls(sensor);
2695 pll->bus_type = SMIAPP_PLL_BUS_TYPE_CSI2; 2599}
2696 pll->csi2.lanes = sensor->hwcfg->lanes;
2697 pll->ext_clk_freq_hz = sensor->hwcfg->ext_clk;
2698 pll->scale_n = sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN];
2699 /* Profile 0 sensors have no separate OP clock branch. */
2700 if (sensor->minfo.smiapp_profile == SMIAPP_PROFILE_0)
2701 pll->flags |= SMIAPP_PLL_FLAG_NO_OP_CLOCKS;
2702
2703 for (i = 0; i < SMIAPP_SUBDEVS; i++) {
2704 struct {
2705 struct smiapp_subdev *ssd;
2706 char *name;
2707 } const __this[] = {
2708 { sensor->scaler, "scaler", },
2709 { sensor->binner, "binner", },
2710 { sensor->pixel_array, "pixel array", },
2711 }, *_this = &__this[i];
2712 struct smiapp_subdev *this = _this->ssd;
2713
2714 if (!this)
2715 continue;
2716 2600
2717 if (this != sensor->src) 2601static void smiapp_create_subdev(struct smiapp_sensor *sensor,
2718 v4l2_subdev_init(&this->sd, &smiapp_ops); 2602 struct smiapp_subdev *ssd, const char *name,
2603 unsigned short num_pads)
2604{
2605 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
2719 2606
2720 this->sensor = sensor; 2607 if (!ssd)
2608 return;
2721 2609
2722 if (this == sensor->pixel_array) { 2610 if (ssd != sensor->src)
2723 this->npads = 1; 2611 v4l2_subdev_init(&ssd->sd, &smiapp_ops);
2724 } else {
2725 this->npads = 2;
2726 this->source_pad = 1;
2727 }
2728 2612
2729 snprintf(this->sd.name, 2613 ssd->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
2730 sizeof(this->sd.name), "%s %s %d-%4.4x", 2614 ssd->sensor = sensor;
2731 sensor->minfo.name, _this->name,
2732 i2c_adapter_id(client->adapter), client->addr);
2733
2734 this->sink_fmt.width =
2735 sensor->limits[SMIAPP_LIMIT_X_ADDR_MAX] + 1;
2736 this->sink_fmt.height =
2737 sensor->limits[SMIAPP_LIMIT_Y_ADDR_MAX] + 1;
2738 this->compose.width = this->sink_fmt.width;
2739 this->compose.height = this->sink_fmt.height;
2740 this->crop[this->source_pad] = this->compose;
2741 this->pads[this->source_pad].flags = MEDIA_PAD_FL_SOURCE;
2742 if (this != sensor->pixel_array) {
2743 this->crop[this->sink_pad] = this->compose;
2744 this->pads[this->sink_pad].flags = MEDIA_PAD_FL_SINK;
2745 }
2746 2615
2747 this->sd.entity.ops = &smiapp_entity_ops; 2616 ssd->npads = num_pads;
2617 ssd->source_pad = num_pads - 1;
2748 2618
2749 if (last == NULL) { 2619 snprintf(ssd->sd.name,
2750 last = this; 2620 sizeof(ssd->sd.name), "%s %s %d-%4.4x", sensor->minfo.name,
2751 continue; 2621 name, i2c_adapter_id(client->adapter), client->addr);
2752 }
2753 2622
2754 this->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; 2623 smiapp_get_native_size(ssd, &ssd->sink_fmt);
2755 this->sd.internal_ops = &smiapp_internal_ops;
2756 this->sd.owner = THIS_MODULE;
2757 v4l2_set_subdevdata(&this->sd, client);
2758 2624
2759 last = this; 2625 ssd->compose.width = ssd->sink_fmt.width;
2626 ssd->compose.height = ssd->sink_fmt.height;
2627 ssd->crop[ssd->source_pad] = ssd->compose;
2628 ssd->pads[ssd->source_pad].flags = MEDIA_PAD_FL_SOURCE;
2629 if (ssd != sensor->pixel_array) {
2630 ssd->crop[ssd->sink_pad] = ssd->compose;
2631 ssd->pads[ssd->sink_pad].flags = MEDIA_PAD_FL_SINK;
2760 } 2632 }
2761 2633
2762 dev_dbg(&client->dev, "profile %d\n", sensor->minfo.smiapp_profile); 2634 ssd->sd.entity.ops = &smiapp_entity_ops;
2763 2635
2764 sensor->pixel_array->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; 2636 if (ssd == sensor->src)
2765 2637 return;
2766 /* final steps */
2767 smiapp_read_frame_fmt(sensor);
2768 rval = smiapp_init_controls(sensor);
2769 if (rval < 0)
2770 goto out_cleanup;
2771
2772 rval = smiapp_call_quirk(sensor, init);
2773 if (rval)
2774 goto out_cleanup;
2775 2638
2776 rval = smiapp_get_mbus_formats(sensor); 2639 ssd->sd.internal_ops = &smiapp_internal_ops;
2777 if (rval) { 2640 ssd->sd.owner = THIS_MODULE;
2778 rval = -ENODEV; 2641 ssd->sd.dev = &client->dev;
2779 goto out_cleanup; 2642 v4l2_set_subdevdata(&ssd->sd, client);
2780 }
2781
2782 rval = smiapp_init_late_controls(sensor);
2783 if (rval) {
2784 rval = -ENODEV;
2785 goto out_cleanup;
2786 }
2787
2788 mutex_lock(&sensor->mutex);
2789 rval = smiapp_update_mode(sensor);
2790 mutex_unlock(&sensor->mutex);
2791 if (rval) {
2792 dev_err(&client->dev, "update mode failed\n");
2793 goto out_cleanup;
2794 }
2795
2796 sensor->streaming = false;
2797 sensor->dev_init_done = true;
2798
2799 smiapp_power_off(sensor);
2800
2801 return 0;
2802
2803out_cleanup:
2804 smiapp_cleanup(sensor);
2805
2806out_power_off:
2807 smiapp_power_off(sensor);
2808 return rval;
2809}
2810
2811static int smiapp_registered(struct v4l2_subdev *subdev)
2812{
2813 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
2814 struct i2c_client *client = v4l2_get_subdevdata(subdev);
2815 int rval;
2816
2817 if (!client->dev.of_node) {
2818 rval = smiapp_init(sensor);
2819 if (rval)
2820 return rval;
2821 }
2822
2823 rval = smiapp_register_subdevs(sensor);
2824 if (rval)
2825 smiapp_cleanup(sensor);
2826
2827 return rval;
2828} 2643}
2829 2644
2830static int smiapp_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) 2645static int smiapp_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
2831{ 2646{
2832 struct smiapp_subdev *ssd = to_smiapp_subdev(sd); 2647 struct smiapp_subdev *ssd = to_smiapp_subdev(sd);
2833 struct smiapp_sensor *sensor = ssd->sensor; 2648 struct smiapp_sensor *sensor = ssd->sensor;
2834 u32 mbus_code =
2835 smiapp_csi_data_formats[smiapp_pixel_order(sensor)].code;
2836 unsigned int i; 2649 unsigned int i;
2650 int rval;
2837 2651
2838 mutex_lock(&sensor->mutex); 2652 mutex_lock(&sensor->mutex);
2839 2653
2840 for (i = 0; i < ssd->npads; i++) { 2654 for (i = 0; i < ssd->npads; i++) {
2841 struct v4l2_mbus_framefmt *try_fmt = 2655 struct v4l2_mbus_framefmt *try_fmt =
2842 v4l2_subdev_get_try_format(sd, fh->pad, i); 2656 v4l2_subdev_get_try_format(sd, fh->pad, i);
2843 struct v4l2_rect *try_crop = v4l2_subdev_get_try_crop(sd, fh->pad, i); 2657 struct v4l2_rect *try_crop =
2658 v4l2_subdev_get_try_crop(sd, fh->pad, i);
2844 struct v4l2_rect *try_comp; 2659 struct v4l2_rect *try_comp;
2845 2660
2846 try_fmt->width = sensor->limits[SMIAPP_LIMIT_X_ADDR_MAX] + 1; 2661 smiapp_get_native_size(ssd, try_crop);
2847 try_fmt->height = sensor->limits[SMIAPP_LIMIT_Y_ADDR_MAX] + 1;
2848 try_fmt->code = mbus_code;
2849 try_fmt->field = V4L2_FIELD_NONE;
2850 2662
2851 try_crop->top = 0; 2663 try_fmt->width = try_crop->width;
2852 try_crop->left = 0; 2664 try_fmt->height = try_crop->height;
2853 try_crop->width = try_fmt->width; 2665 try_fmt->code = sensor->internal_csi_format->code;
2854 try_crop->height = try_fmt->height; 2666 try_fmt->field = V4L2_FIELD_NONE;
2855 2667
2856 if (ssd != sensor->pixel_array) 2668 if (ssd != sensor->pixel_array)
2857 continue; 2669 continue;
@@ -2862,12 +2674,23 @@ static int smiapp_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
2862 2674
2863 mutex_unlock(&sensor->mutex); 2675 mutex_unlock(&sensor->mutex);
2864 2676
2865 return smiapp_set_power(sd, 1); 2677 rval = pm_runtime_get_sync(sd->dev);
2678 if (rval >= 0)
2679 return 0;
2680
2681 if (rval != -EBUSY && rval != -EAGAIN)
2682 pm_runtime_set_active(sd->dev);
2683 pm_runtime_put(sd->dev);
2684
2685 return rval;
2866} 2686}
2867 2687
2868static int smiapp_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) 2688static int smiapp_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
2869{ 2689{
2870 return smiapp_set_power(sd, 0); 2690 pm_runtime_mark_last_busy(sd->dev);
2691 pm_runtime_put_autosuspend(sd->dev);
2692
2693 return 0;
2871} 2694}
2872 2695
2873static const struct v4l2_subdev_video_ops smiapp_video_ops = { 2696static const struct v4l2_subdev_video_ops smiapp_video_ops = {
@@ -2904,6 +2727,7 @@ static const struct media_entity_operations smiapp_entity_ops = {
2904 2727
2905static const struct v4l2_subdev_internal_ops smiapp_internal_src_ops = { 2728static const struct v4l2_subdev_internal_ops smiapp_internal_src_ops = {
2906 .registered = smiapp_registered, 2729 .registered = smiapp_registered,
2730 .unregistered = smiapp_unregistered,
2907 .open = smiapp_open, 2731 .open = smiapp_open,
2908 .close = smiapp_close, 2732 .close = smiapp_close,
2909}; 2733};
@@ -2924,20 +2748,20 @@ static int smiapp_suspend(struct device *dev)
2924 struct i2c_client *client = to_i2c_client(dev); 2748 struct i2c_client *client = to_i2c_client(dev);
2925 struct v4l2_subdev *subdev = i2c_get_clientdata(client); 2749 struct v4l2_subdev *subdev = i2c_get_clientdata(client);
2926 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev); 2750 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
2927 bool streaming; 2751 bool streaming = sensor->streaming;
2928 2752 int rval;
2929 BUG_ON(mutex_is_locked(&sensor->mutex));
2930 2753
2931 if (sensor->power_count == 0) 2754 rval = pm_runtime_get_sync(dev);
2932 return 0; 2755 if (rval < 0) {
2756 if (rval != -EBUSY && rval != -EAGAIN)
2757 pm_runtime_set_active(&client->dev);
2758 pm_runtime_put(dev);
2759 return -EAGAIN;
2760 }
2933 2761
2934 if (sensor->streaming) 2762 if (sensor->streaming)
2935 smiapp_stop_streaming(sensor); 2763 smiapp_stop_streaming(sensor);
2936 2764
2937 streaming = sensor->streaming;
2938
2939 smiapp_power_off(sensor);
2940
2941 /* save state for resume */ 2765 /* save state for resume */
2942 sensor->streaming = streaming; 2766 sensor->streaming = streaming;
2943 2767
@@ -2949,14 +2773,9 @@ static int smiapp_resume(struct device *dev)
2949 struct i2c_client *client = to_i2c_client(dev); 2773 struct i2c_client *client = to_i2c_client(dev);
2950 struct v4l2_subdev *subdev = i2c_get_clientdata(client); 2774 struct v4l2_subdev *subdev = i2c_get_clientdata(client);
2951 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev); 2775 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
2952 int rval; 2776 int rval = 0;
2953
2954 if (sensor->power_count == 0)
2955 return 0;
2956 2777
2957 rval = smiapp_power_on(sensor); 2778 pm_runtime_put(dev);
2958 if (rval)
2959 return rval;
2960 2779
2961 if (sensor->streaming) 2780 if (sensor->streaming)
2962 rval = smiapp_start_streaming(sensor); 2781 rval = smiapp_start_streaming(sensor);
@@ -3051,6 +2870,7 @@ static int smiapp_probe(struct i2c_client *client,
3051{ 2870{
3052 struct smiapp_sensor *sensor; 2871 struct smiapp_sensor *sensor;
3053 struct smiapp_hwconfig *hwcfg = smiapp_get_hwconfig(&client->dev); 2872 struct smiapp_hwconfig *hwcfg = smiapp_get_hwconfig(&client->dev);
2873 unsigned int i;
3054 int rval; 2874 int rval;
3055 2875
3056 if (hwcfg == NULL) 2876 if (hwcfg == NULL)
@@ -3062,35 +2882,240 @@ static int smiapp_probe(struct i2c_client *client,
3062 2882
3063 sensor->hwcfg = hwcfg; 2883 sensor->hwcfg = hwcfg;
3064 mutex_init(&sensor->mutex); 2884 mutex_init(&sensor->mutex);
3065 mutex_init(&sensor->power_mutex);
3066 sensor->src = &sensor->ssds[sensor->ssds_used]; 2885 sensor->src = &sensor->ssds[sensor->ssds_used];
3067 2886
3068 v4l2_i2c_subdev_init(&sensor->src->sd, client, &smiapp_ops); 2887 v4l2_i2c_subdev_init(&sensor->src->sd, client, &smiapp_ops);
3069 sensor->src->sd.internal_ops = &smiapp_internal_src_ops; 2888 sensor->src->sd.internal_ops = &smiapp_internal_src_ops;
3070 sensor->src->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
3071 sensor->src->sensor = sensor;
3072 2889
3073 sensor->src->pads[0].flags = MEDIA_PAD_FL_SOURCE; 2890 sensor->vana = devm_regulator_get(&client->dev, "vana");
3074 rval = media_entity_pads_init(&sensor->src->sd.entity, 2, 2891 if (IS_ERR(sensor->vana)) {
3075 sensor->src->pads); 2892 dev_err(&client->dev, "could not get regulator for vana\n");
3076 if (rval < 0) 2893 return PTR_ERR(sensor->vana);
2894 }
2895
2896 sensor->ext_clk = devm_clk_get(&client->dev, NULL);
2897 if (IS_ERR(sensor->ext_clk)) {
2898 dev_err(&client->dev, "could not get clock (%ld)\n",
2899 PTR_ERR(sensor->ext_clk));
2900 return -EPROBE_DEFER;
2901 }
2902
2903 rval = clk_set_rate(sensor->ext_clk, sensor->hwcfg->ext_clk);
2904 if (rval < 0) {
2905 dev_err(&client->dev,
2906 "unable to set clock freq to %u\n",
2907 sensor->hwcfg->ext_clk);
3077 return rval; 2908 return rval;
2909 }
3078 2910
3079 if (client->dev.of_node) { 2911 sensor->xshutdown = devm_gpiod_get_optional(&client->dev, "xshutdown",
3080 rval = smiapp_init(sensor); 2912 GPIOD_OUT_LOW);
3081 if (rval) 2913 if (IS_ERR(sensor->xshutdown))
3082 goto out_media_entity_cleanup; 2914 return PTR_ERR(sensor->xshutdown);
2915
2916 pm_runtime_enable(&client->dev);
2917
2918 rval = pm_runtime_get_sync(&client->dev);
2919 if (rval < 0) {
2920 rval = -ENODEV;
2921 goto out_power_off;
2922 }
2923
2924 rval = smiapp_identify_module(sensor);
2925 if (rval) {
2926 rval = -ENODEV;
2927 goto out_power_off;
2928 }
2929
2930 rval = smiapp_get_all_limits(sensor);
2931 if (rval) {
2932 rval = -ENODEV;
2933 goto out_power_off;
3083 } 2934 }
3084 2935
2936 rval = smiapp_read_frame_fmt(sensor);
2937 if (rval) {
2938 rval = -ENODEV;
2939 goto out_power_off;
2940 }
2941
2942 /*
2943 * Handle Sensor Module orientation on the board.
2944 *
2945 * The application of H-FLIP and V-FLIP on the sensor is modified by
2946 * the sensor orientation on the board.
2947 *
2948 * For SMIAPP_BOARD_SENSOR_ORIENT_180 the default behaviour is to set
2949 * both H-FLIP and V-FLIP for normal operation which also implies
2950 * that a set/unset operation for user space HFLIP and VFLIP v4l2
2951 * controls will need to be internally inverted.
2952 *
2953 * Rotation also changes the bayer pattern.
2954 */
2955 if (sensor->hwcfg->module_board_orient ==
2956 SMIAPP_MODULE_BOARD_ORIENT_180)
2957 sensor->hvflip_inv_mask = SMIAPP_IMAGE_ORIENTATION_HFLIP |
2958 SMIAPP_IMAGE_ORIENTATION_VFLIP;
2959
2960 rval = smiapp_call_quirk(sensor, limits);
2961 if (rval) {
2962 dev_err(&client->dev, "limits quirks failed\n");
2963 goto out_power_off;
2964 }
2965
2966 if (sensor->limits[SMIAPP_LIMIT_BINNING_CAPABILITY]) {
2967 u32 val;
2968
2969 rval = smiapp_read(sensor,
2970 SMIAPP_REG_U8_BINNING_SUBTYPES, &val);
2971 if (rval < 0) {
2972 rval = -ENODEV;
2973 goto out_power_off;
2974 }
2975 sensor->nbinning_subtypes = min_t(u8, val,
2976 SMIAPP_BINNING_SUBTYPES);
2977
2978 for (i = 0; i < sensor->nbinning_subtypes; i++) {
2979 rval = smiapp_read(
2980 sensor, SMIAPP_REG_U8_BINNING_TYPE_n(i), &val);
2981 if (rval < 0) {
2982 rval = -ENODEV;
2983 goto out_power_off;
2984 }
2985 sensor->binning_subtypes[i] =
2986 *(struct smiapp_binning_subtype *)&val;
2987
2988 dev_dbg(&client->dev, "binning %xx%x\n",
2989 sensor->binning_subtypes[i].horizontal,
2990 sensor->binning_subtypes[i].vertical);
2991 }
2992 }
2993 sensor->binning_horizontal = 1;
2994 sensor->binning_vertical = 1;
2995
2996 if (device_create_file(&client->dev, &dev_attr_ident) != 0) {
2997 dev_err(&client->dev, "sysfs ident entry creation failed\n");
2998 rval = -ENOENT;
2999 goto out_power_off;
3000 }
3001 /* SMIA++ NVM initialization - it will be read from the sensor
3002 * when it is first requested by userspace.
3003 */
3004 if (sensor->minfo.smiapp_version && sensor->hwcfg->nvm_size) {
3005 sensor->nvm = devm_kzalloc(&client->dev,
3006 sensor->hwcfg->nvm_size, GFP_KERNEL);
3007 if (sensor->nvm == NULL) {
3008 rval = -ENOMEM;
3009 goto out_cleanup;
3010 }
3011
3012 if (device_create_file(&client->dev, &dev_attr_nvm) != 0) {
3013 dev_err(&client->dev, "sysfs nvm entry failed\n");
3014 rval = -EBUSY;
3015 goto out_cleanup;
3016 }
3017 }
3018
3019 /* We consider this as profile 0 sensor if any of these are zero. */
3020 if (!sensor->limits[SMIAPP_LIMIT_MIN_OP_SYS_CLK_DIV] ||
3021 !sensor->limits[SMIAPP_LIMIT_MAX_OP_SYS_CLK_DIV] ||
3022 !sensor->limits[SMIAPP_LIMIT_MIN_OP_PIX_CLK_DIV] ||
3023 !sensor->limits[SMIAPP_LIMIT_MAX_OP_PIX_CLK_DIV]) {
3024 sensor->minfo.smiapp_profile = SMIAPP_PROFILE_0;
3025 } else if (sensor->limits[SMIAPP_LIMIT_SCALING_CAPABILITY]
3026 != SMIAPP_SCALING_CAPABILITY_NONE) {
3027 if (sensor->limits[SMIAPP_LIMIT_SCALING_CAPABILITY]
3028 == SMIAPP_SCALING_CAPABILITY_HORIZONTAL)
3029 sensor->minfo.smiapp_profile = SMIAPP_PROFILE_1;
3030 else
3031 sensor->minfo.smiapp_profile = SMIAPP_PROFILE_2;
3032 sensor->scaler = &sensor->ssds[sensor->ssds_used];
3033 sensor->ssds_used++;
3034 } else if (sensor->limits[SMIAPP_LIMIT_DIGITAL_CROP_CAPABILITY]
3035 == SMIAPP_DIGITAL_CROP_CAPABILITY_INPUT_CROP) {
3036 sensor->scaler = &sensor->ssds[sensor->ssds_used];
3037 sensor->ssds_used++;
3038 }
3039 sensor->binner = &sensor->ssds[sensor->ssds_used];
3040 sensor->ssds_used++;
3041 sensor->pixel_array = &sensor->ssds[sensor->ssds_used];
3042 sensor->ssds_used++;
3043
3044 sensor->scale_m = sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN];
3045
3046 /* prepare PLL configuration input values */
3047 sensor->pll.bus_type = SMIAPP_PLL_BUS_TYPE_CSI2;
3048 sensor->pll.csi2.lanes = sensor->hwcfg->lanes;
3049 sensor->pll.ext_clk_freq_hz = sensor->hwcfg->ext_clk;
3050 sensor->pll.scale_n = sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN];
3051 /* Profile 0 sensors have no separate OP clock branch. */
3052 if (sensor->minfo.smiapp_profile == SMIAPP_PROFILE_0)
3053 sensor->pll.flags |= SMIAPP_PLL_FLAG_NO_OP_CLOCKS;
3054
3055 smiapp_create_subdev(sensor, sensor->scaler, "scaler", 2);
3056 smiapp_create_subdev(sensor, sensor->binner, "binner", 2);
3057 smiapp_create_subdev(sensor, sensor->pixel_array, "pixel_array", 1);
3058
3059 dev_dbg(&client->dev, "profile %d\n", sensor->minfo.smiapp_profile);
3060
3061 sensor->pixel_array->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
3062
3063 rval = smiapp_init_controls(sensor);
3064 if (rval < 0)
3065 goto out_cleanup;
3066
3067 rval = smiapp_call_quirk(sensor, init);
3068 if (rval)
3069 goto out_cleanup;
3070
3071 rval = smiapp_get_mbus_formats(sensor);
3072 if (rval) {
3073 rval = -ENODEV;
3074 goto out_cleanup;
3075 }
3076
3077 rval = smiapp_init_late_controls(sensor);
3078 if (rval) {
3079 rval = -ENODEV;
3080 goto out_cleanup;
3081 }
3082
3083 mutex_lock(&sensor->mutex);
3084 rval = smiapp_update_mode(sensor);
3085 mutex_unlock(&sensor->mutex);
3086 if (rval) {
3087 dev_err(&client->dev, "update mode failed\n");
3088 goto out_cleanup;
3089 }
3090
3091 sensor->streaming = false;
3092 sensor->dev_init_done = true;
3093
3094 rval = media_entity_pads_init(&sensor->src->sd.entity, 2,
3095 sensor->src->pads);
3096 if (rval < 0)
3097 goto out_media_entity_cleanup;
3098
3085 rval = v4l2_async_register_subdev(&sensor->src->sd); 3099 rval = v4l2_async_register_subdev(&sensor->src->sd);
3086 if (rval < 0) 3100 if (rval < 0)
3087 goto out_media_entity_cleanup; 3101 goto out_media_entity_cleanup;
3088 3102
3103 pm_runtime_set_autosuspend_delay(&client->dev, 1000);
3104 pm_runtime_use_autosuspend(&client->dev);
3105 pm_runtime_put_autosuspend(&client->dev);
3106
3089 return 0; 3107 return 0;
3090 3108
3091out_media_entity_cleanup: 3109out_media_entity_cleanup:
3092 media_entity_cleanup(&sensor->src->sd.entity); 3110 media_entity_cleanup(&sensor->src->sd.entity);
3093 3111
3112out_cleanup:
3113 smiapp_cleanup(sensor);
3114
3115out_power_off:
3116 pm_runtime_put(&client->dev);
3117 pm_runtime_disable(&client->dev);
3118
3094 return rval; 3119 return rval;
3095} 3120}
3096 3121
@@ -3102,11 +3127,8 @@ static int smiapp_remove(struct i2c_client *client)
3102 3127
3103 v4l2_async_unregister_subdev(subdev); 3128 v4l2_async_unregister_subdev(subdev);
3104 3129
3105 if (sensor->power_count) { 3130 pm_runtime_suspend(&client->dev);
3106 gpiod_set_value(sensor->xshutdown, 0); 3131 pm_runtime_disable(&client->dev);
3107 clk_disable_unprepare(sensor->ext_clk);
3108 sensor->power_count = 0;
3109 }
3110 3132
3111 for (i = 0; i < sensor->ssds_used; i++) { 3133 for (i = 0; i < sensor->ssds_used; i++) {
3112 v4l2_device_unregister_subdev(&sensor->ssds[i].sd); 3134 v4l2_device_unregister_subdev(&sensor->ssds[i].sd);
@@ -3130,8 +3152,8 @@ static const struct i2c_device_id smiapp_id_table[] = {
3130MODULE_DEVICE_TABLE(i2c, smiapp_id_table); 3152MODULE_DEVICE_TABLE(i2c, smiapp_id_table);
3131 3153
3132static const struct dev_pm_ops smiapp_pm_ops = { 3154static const struct dev_pm_ops smiapp_pm_ops = {
3133 .suspend = smiapp_suspend, 3155 SET_SYSTEM_SLEEP_PM_OPS(smiapp_suspend, smiapp_resume)
3134 .resume = smiapp_resume, 3156 SET_RUNTIME_PM_OPS(smiapp_power_off, smiapp_power_on, NULL)
3135}; 3157};
3136 3158
3137static struct i2c_driver smiapp_i2c_driver = { 3159static struct i2c_driver smiapp_i2c_driver = {
diff --git a/drivers/media/i2c/smiapp/smiapp-regs.c b/drivers/media/i2c/smiapp/smiapp-regs.c
index 1e501c06d18c..d6779e35d36f 100644
--- a/drivers/media/i2c/smiapp/smiapp-regs.c
+++ b/drivers/media/i2c/smiapp/smiapp-regs.c
@@ -268,8 +268,8 @@ int smiapp_write_no_quirk(struct smiapp_sensor *sensor, u32 reg, u32 val)
268 if (r == 1) { 268 if (r == 1) {
269 if (retries) 269 if (retries)
270 dev_err(&client->dev, 270 dev_err(&client->dev,
271 "sensor i2c stall encountered. " 271 "sensor i2c stall encountered. retries: %d\n",
272 "retries: %d\n", retries); 272 retries);
273 return 0; 273 return 0;
274 } 274 }
275 275
diff --git a/drivers/media/i2c/smiapp/smiapp.h b/drivers/media/i2c/smiapp/smiapp.h
index aae72bc87bf7..f74d695018b9 100644
--- a/drivers/media/i2c/smiapp/smiapp.h
+++ b/drivers/media/i2c/smiapp/smiapp.h
@@ -150,11 +150,6 @@ struct smiapp_csi_data_format {
150#define SMIAPP_PAD_SRC 1 150#define SMIAPP_PAD_SRC 1
151#define SMIAPP_PADS 2 151#define SMIAPP_PADS 2
152 152
153#define SMIAPP_COMPRESSED_BASE 8
154#define SMIAPP_COMPRESSED_MAX 16
155#define SMIAPP_NR_OF_COMPRESSED (SMIAPP_COMPRESSED_MAX - \
156 SMIAPP_COMPRESSED_BASE + 1)
157
158struct smiapp_binning_subtype { 153struct smiapp_binning_subtype {
159 u8 horizontal:4; 154 u8 horizontal:4;
160 u8 vertical:4; 155 u8 vertical:4;
@@ -162,9 +157,9 @@ struct smiapp_binning_subtype {
162 157
163struct smiapp_subdev { 158struct smiapp_subdev {
164 struct v4l2_subdev sd; 159 struct v4l2_subdev sd;
165 struct media_pad pads[2]; 160 struct media_pad pads[SMIAPP_PADS];
166 struct v4l2_rect sink_fmt; 161 struct v4l2_rect sink_fmt;
167 struct v4l2_rect crop[2]; 162 struct v4l2_rect crop[SMIAPP_PADS];
168 struct v4l2_rect compose; /* compose on sink */ 163 struct v4l2_rect compose; /* compose on sink */
169 unsigned short sink_pad; 164 unsigned short sink_pad;
170 unsigned short source_pad; 165 unsigned short source_pad;
@@ -181,16 +176,9 @@ struct smiapp_sensor {
181 * "mutex" is used to serialise access to all fields here 176 * "mutex" is used to serialise access to all fields here
182 * except v4l2_ctrls at the end of the struct. "mutex" is also 177 * except v4l2_ctrls at the end of the struct. "mutex" is also
183 * used to serialise access to file handle specific 178 * used to serialise access to file handle specific
184 * information. The exception to this rule is the power_mutex 179 * information.
185 * below.
186 */ 180 */
187 struct mutex mutex; 181 struct mutex mutex;
188 /*
189 * power_mutex is used to serialise power management related
190 * activities. Acquiring "mutex" at that time isn't necessary
191 * since there are no other users anyway.
192 */
193 struct mutex power_mutex;
194 struct smiapp_subdev ssds[SMIAPP_SUBDEVS]; 182 struct smiapp_subdev ssds[SMIAPP_SUBDEVS];
195 u32 ssds_used; 183 u32 ssds_used;
196 struct smiapp_subdev *src; 184 struct smiapp_subdev *src;
@@ -218,12 +206,14 @@ struct smiapp_sensor {
218 206
219 u8 hvflip_inv_mask; /* H/VFLIP inversion due to sensor orientation */ 207 u8 hvflip_inv_mask; /* H/VFLIP inversion due to sensor orientation */
220 u8 frame_skip; 208 u8 frame_skip;
221 u16 image_start; /* Offset to first line after metadata lines */ 209 u16 embedded_start; /* embedded data start line */
222 210 u16 embedded_end;
223 int power_count; 211 u16 image_start; /* image data start line */
212 u16 visible_pixel_start; /* start pixel of the visible image */
224 213
225 bool streaming; 214 bool streaming;
226 bool dev_init_done; 215 bool dev_init_done;
216 u8 compressed_min_bpp;
227 217
228 u8 *nvm; /* nvm memory buffer */ 218 u8 *nvm; /* nvm memory buffer */
229 unsigned int nvm_size; /* bytes */ 219 unsigned int nvm_size; /* bytes */
@@ -233,7 +223,7 @@ struct smiapp_sensor {
233 struct smiapp_pll pll; 223 struct smiapp_pll pll;
234 224
235 /* Is a default format supported for a given BPP? */ 225 /* Is a default format supported for a given BPP? */
236 unsigned long valid_link_freqs[SMIAPP_NR_OF_COMPRESSED]; 226 unsigned long *valid_link_freqs;
237 227
238 /* Pixel array controls */ 228 /* Pixel array controls */
239 struct v4l2_ctrl *analog_gain; 229 struct v4l2_ctrl *analog_gain;
diff --git a/drivers/media/i2c/soc_camera/ov772x.c b/drivers/media/i2c/soc_camera/ov772x.c
index 7e68762b3a4b..985a3672b243 100644
--- a/drivers/media/i2c/soc_camera/ov772x.c
+++ b/drivers/media/i2c/soc_camera/ov772x.c
@@ -1064,8 +1064,7 @@ static int ov772x_probe(struct i2c_client *client,
1064 1064
1065 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { 1065 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
1066 dev_err(&adapter->dev, 1066 dev_err(&adapter->dev,
1067 "I2C-Adapter doesn't support " 1067 "I2C-Adapter doesn't support I2C_FUNC_SMBUS_BYTE_DATA\n");
1068 "I2C_FUNC_SMBUS_BYTE_DATA\n");
1069 return -EIO; 1068 return -EIO;
1070 } 1069 }
1071 1070
diff --git a/drivers/media/i2c/soc_camera/ov9740.c b/drivers/media/i2c/soc_camera/ov9740.c
index 0da632d7d33a..f11f76cdacad 100644
--- a/drivers/media/i2c/soc_camera/ov9740.c
+++ b/drivers/media/i2c/soc_camera/ov9740.c
@@ -881,8 +881,7 @@ static int ov9740_video_probe(struct i2c_client *client)
881 goto done; 881 goto done;
882 } 882 }
883 883
884 dev_info(&client->dev, "ov9740 Model ID 0x%04x, Revision 0x%02x, " 884 dev_info(&client->dev, "ov9740 Model ID 0x%04x, Revision 0x%02x, Manufacturer 0x%02x, SMIA Version 0x%02x\n",
885 "Manufacturer 0x%02x, SMIA Version 0x%02x\n",
886 priv->model, priv->revision, priv->manid, priv->smiaver); 885 priv->model, priv->revision, priv->manid, priv->smiaver);
887 886
888 ret = v4l2_ctrl_handler_setup(&priv->hdl); 887 ret = v4l2_ctrl_handler_setup(&priv->hdl);
diff --git a/drivers/media/i2c/soc_camera/tw9910.c b/drivers/media/i2c/soc_camera/tw9910.c
index 4002c07f3857..c9c49ed707b8 100644
--- a/drivers/media/i2c/soc_camera/tw9910.c
+++ b/drivers/media/i2c/soc_camera/tw9910.c
@@ -947,8 +947,7 @@ static int tw9910_probe(struct i2c_client *client,
947 947
948 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { 948 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
949 dev_err(&client->dev, 949 dev_err(&client->dev,
950 "I2C-Adapter doesn't support " 950 "I2C-Adapter doesn't support I2C_FUNC_SMBUS_BYTE_DATA\n");
951 "I2C_FUNC_SMBUS_BYTE_DATA\n");
952 return -EIO; 951 return -EIO;
953 } 952 }
954 953
diff --git a/drivers/media/i2c/tvaudio.c b/drivers/media/i2c/tvaudio.c
index 42d1e26e581c..ce86534450ac 100644
--- a/drivers/media/i2c/tvaudio.c
+++ b/drivers/media/i2c/tvaudio.c
@@ -1894,8 +1894,9 @@ static int tvaudio_probe(struct i2c_client *client, const struct i2c_device_id *
1894 printk(KERN_INFO "tvaudio: TV audio decoder + audio/video mux driver\n"); 1894 printk(KERN_INFO "tvaudio: TV audio decoder + audio/video mux driver\n");
1895 printk(KERN_INFO "tvaudio: known chips: "); 1895 printk(KERN_INFO "tvaudio: known chips: ");
1896 for (desc = chiplist; desc->name != NULL; desc++) 1896 for (desc = chiplist; desc->name != NULL; desc++)
1897 printk("%s%s", (desc == chiplist) ? "" : ", ", desc->name); 1897 printk(KERN_CONT "%s%s",
1898 printk("\n"); 1898 (desc == chiplist) ? "" : ", ", desc->name);
1899 printk(KERN_CONT "\n");
1899 } 1900 }
1900 1901
1901 chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); 1902 chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
index d5c9347f4c6d..0c62899c3667 100644
--- a/drivers/media/i2c/tvp514x.c
+++ b/drivers/media/i2c/tvp514x.c
@@ -894,7 +894,7 @@ static int tvp514x_enum_mbus_code(struct v4l2_subdev *sd,
894 if (index != 0) 894 if (index != 0)
895 return -EINVAL; 895 return -EINVAL;
896 896
897 code->code = MEDIA_BUS_FMT_YUYV8_2X8; 897 code->code = MEDIA_BUS_FMT_UYVY8_2X8;
898 898
899 return 0; 899 return 0;
900} 900}
@@ -922,7 +922,7 @@ static int tvp514x_get_pad_format(struct v4l2_subdev *sd,
922 return 0; 922 return 0;
923 } 923 }
924 924
925 format->format.code = MEDIA_BUS_FMT_YUYV8_2X8; 925 format->format.code = MEDIA_BUS_FMT_UYVY8_2X8;
926 format->format.width = tvp514x_std_list[decoder->current_std].width; 926 format->format.width = tvp514x_std_list[decoder->current_std].width;
927 format->format.height = tvp514x_std_list[decoder->current_std].height; 927 format->format.height = tvp514x_std_list[decoder->current_std].height;
928 format->format.colorspace = V4L2_COLORSPACE_SMPTE170M; 928 format->format.colorspace = V4L2_COLORSPACE_SMPTE170M;
@@ -946,7 +946,7 @@ static int tvp514x_set_pad_format(struct v4l2_subdev *sd,
946 struct tvp514x_decoder *decoder = to_decoder(sd); 946 struct tvp514x_decoder *decoder = to_decoder(sd);
947 947
948 if (fmt->format.field != V4L2_FIELD_INTERLACED || 948 if (fmt->format.field != V4L2_FIELD_INTERLACED ||
949 fmt->format.code != MEDIA_BUS_FMT_YUYV8_2X8 || 949 fmt->format.code != MEDIA_BUS_FMT_UYVY8_2X8 ||
950 fmt->format.colorspace != V4L2_COLORSPACE_SMPTE170M || 950 fmt->format.colorspace != V4L2_COLORSPACE_SMPTE170M ||
951 fmt->format.width != tvp514x_std_list[decoder->current_std].width || 951 fmt->format.width != tvp514x_std_list[decoder->current_std].width ||
952 fmt->format.height != tvp514x_std_list[decoder->current_std].height) 952 fmt->format.height != tvp514x_std_list[decoder->current_std].height)
diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 4740da39d698..3a0fe8cc64e9 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -36,6 +36,8 @@ static int debug;
36module_param(debug, int, 0644); 36module_param(debug, int, 0644);
37MODULE_PARM_DESC(debug, "Debug level (0-2)"); 37MODULE_PARM_DESC(debug, "Debug level (0-2)");
38 38
39#define dprintk0(__dev, __arg...) dev_dbg_lvl(__dev, 0, 0, __arg)
40
39struct tvp5150 { 41struct tvp5150 {
40 struct v4l2_subdev sd; 42 struct v4l2_subdev sd;
41#ifdef CONFIG_MEDIA_CONTROLLER 43#ifdef CONFIG_MEDIA_CONTROLLER
@@ -74,11 +76,11 @@ static int tvp5150_read(struct v4l2_subdev *sd, unsigned char addr)
74 76
75 rc = i2c_smbus_read_byte_data(c, addr); 77 rc = i2c_smbus_read_byte_data(c, addr);
76 if (rc < 0) { 78 if (rc < 0) {
77 v4l2_err(sd, "i2c i/o error: rc == %d\n", rc); 79 dev_err(sd->dev, "i2c i/o error: rc == %d\n", rc);
78 return rc; 80 return rc;
79 } 81 }
80 82
81 v4l2_dbg(2, debug, sd, "tvp5150: read 0x%02x = 0x%02x\n", addr, rc); 83 dev_dbg_lvl(sd->dev, 2, debug, "tvp5150: read 0x%02x = %02x\n", addr, rc);
82 84
83 return rc; 85 return rc;
84} 86}
@@ -89,10 +91,10 @@ static int tvp5150_write(struct v4l2_subdev *sd, unsigned char addr,
89 struct i2c_client *c = v4l2_get_subdevdata(sd); 91 struct i2c_client *c = v4l2_get_subdevdata(sd);
90 int rc; 92 int rc;
91 93
92 v4l2_dbg(2, debug, sd, "tvp5150: writing 0x%02x 0x%02x\n", addr, value); 94 dev_dbg_lvl(sd->dev, 2, debug, "tvp5150: writing %02x %02x\n", addr, value);
93 rc = i2c_smbus_write_byte_data(c, addr, value); 95 rc = i2c_smbus_write_byte_data(c, addr, value);
94 if (rc < 0) 96 if (rc < 0)
95 v4l2_err(sd, "i2c i/o error: rc == %d\n", rc); 97 dev_err(sd->dev, "i2c i/o error: rc == %d\n", rc);
96 98
97 return rc; 99 return rc;
98} 100}
@@ -100,138 +102,140 @@ static int tvp5150_write(struct v4l2_subdev *sd, unsigned char addr,
100static void dump_reg_range(struct v4l2_subdev *sd, char *s, u8 init, 102static void dump_reg_range(struct v4l2_subdev *sd, char *s, u8 init,
101 const u8 end, int max_line) 103 const u8 end, int max_line)
102{ 104{
103 int i = 0; 105 u8 buf[16];
106 int i = 0, j, len;
104 107
105 while (init != (u8)(end + 1)) { 108 if (max_line > 16) {
106 if ((i % max_line) == 0) { 109 dprintk0(sd->dev, "too much data to dump\n");
107 if (i > 0) 110 return;
108 printk("\n"); 111 }
109 printk("tvp5150: %s reg 0x%02x = ", s, init); 112
110 } 113 for (i = init; i < end; i += max_line) {
111 printk("%02x ", tvp5150_read(sd, init)); 114 len = (end - i > max_line) ? max_line : end - i;
115
116 for (j = 0; j < len; j++)
117 buf[j] = tvp5150_read(sd, i + j);
112 118
113 init++; 119 dprintk0(sd->dev, "%s reg %02x = %*ph\n", s, i, len, buf);
114 i++;
115 } 120 }
116 printk("\n");
117} 121}
118 122
119static int tvp5150_log_status(struct v4l2_subdev *sd) 123static int tvp5150_log_status(struct v4l2_subdev *sd)
120{ 124{
121 printk("tvp5150: Video input source selection #1 = 0x%02x\n", 125 dprintk0(sd->dev, "tvp5150: Video input source selection #1 = 0x%02x\n",
122 tvp5150_read(sd, TVP5150_VD_IN_SRC_SEL_1)); 126 tvp5150_read(sd, TVP5150_VD_IN_SRC_SEL_1));
123 printk("tvp5150: Analog channel controls = 0x%02x\n", 127 dprintk0(sd->dev, "tvp5150: Analog channel controls = 0x%02x\n",
124 tvp5150_read(sd, TVP5150_ANAL_CHL_CTL)); 128 tvp5150_read(sd, TVP5150_ANAL_CHL_CTL));
125 printk("tvp5150: Operation mode controls = 0x%02x\n", 129 dprintk0(sd->dev, "tvp5150: Operation mode controls = 0x%02x\n",
126 tvp5150_read(sd, TVP5150_OP_MODE_CTL)); 130 tvp5150_read(sd, TVP5150_OP_MODE_CTL));
127 printk("tvp5150: Miscellaneous controls = 0x%02x\n", 131 dprintk0(sd->dev, "tvp5150: Miscellaneous controls = 0x%02x\n",
128 tvp5150_read(sd, TVP5150_MISC_CTL)); 132 tvp5150_read(sd, TVP5150_MISC_CTL));
129 printk("tvp5150: Autoswitch mask= 0x%02x\n", 133 dprintk0(sd->dev, "tvp5150: Autoswitch mask= 0x%02x\n",
130 tvp5150_read(sd, TVP5150_AUTOSW_MSK)); 134 tvp5150_read(sd, TVP5150_AUTOSW_MSK));
131 printk("tvp5150: Color killer threshold control = 0x%02x\n", 135 dprintk0(sd->dev, "tvp5150: Color killer threshold control = 0x%02x\n",
132 tvp5150_read(sd, TVP5150_COLOR_KIL_THSH_CTL)); 136 tvp5150_read(sd, TVP5150_COLOR_KIL_THSH_CTL));
133 printk("tvp5150: Luminance processing controls #1 #2 and #3 = %02x %02x %02x\n", 137 dprintk0(sd->dev, "tvp5150: Luminance processing controls #1 #2 and #3 = %02x %02x %02x\n",
134 tvp5150_read(sd, TVP5150_LUMA_PROC_CTL_1), 138 tvp5150_read(sd, TVP5150_LUMA_PROC_CTL_1),
135 tvp5150_read(sd, TVP5150_LUMA_PROC_CTL_2), 139 tvp5150_read(sd, TVP5150_LUMA_PROC_CTL_2),
136 tvp5150_read(sd, TVP5150_LUMA_PROC_CTL_3)); 140 tvp5150_read(sd, TVP5150_LUMA_PROC_CTL_3));
137 printk("tvp5150: Brightness control = 0x%02x\n", 141 dprintk0(sd->dev, "tvp5150: Brightness control = 0x%02x\n",
138 tvp5150_read(sd, TVP5150_BRIGHT_CTL)); 142 tvp5150_read(sd, TVP5150_BRIGHT_CTL));
139 printk("tvp5150: Color saturation control = 0x%02x\n", 143 dprintk0(sd->dev, "tvp5150: Color saturation control = 0x%02x\n",
140 tvp5150_read(sd, TVP5150_SATURATION_CTL)); 144 tvp5150_read(sd, TVP5150_SATURATION_CTL));
141 printk("tvp5150: Hue control = 0x%02x\n", 145 dprintk0(sd->dev, "tvp5150: Hue control = 0x%02x\n",
142 tvp5150_read(sd, TVP5150_HUE_CTL)); 146 tvp5150_read(sd, TVP5150_HUE_CTL));
143 printk("tvp5150: Contrast control = 0x%02x\n", 147 dprintk0(sd->dev, "tvp5150: Contrast control = 0x%02x\n",
144 tvp5150_read(sd, TVP5150_CONTRAST_CTL)); 148 tvp5150_read(sd, TVP5150_CONTRAST_CTL));
145 printk("tvp5150: Outputs and data rates select = 0x%02x\n", 149 dprintk0(sd->dev, "tvp5150: Outputs and data rates select = 0x%02x\n",
146 tvp5150_read(sd, TVP5150_DATA_RATE_SEL)); 150 tvp5150_read(sd, TVP5150_DATA_RATE_SEL));
147 printk("tvp5150: Configuration shared pins = 0x%02x\n", 151 dprintk0(sd->dev, "tvp5150: Configuration shared pins = 0x%02x\n",
148 tvp5150_read(sd, TVP5150_CONF_SHARED_PIN)); 152 tvp5150_read(sd, TVP5150_CONF_SHARED_PIN));
149 printk("tvp5150: Active video cropping start = 0x%02x%02x\n", 153 dprintk0(sd->dev, "tvp5150: Active video cropping start = 0x%02x%02x\n",
150 tvp5150_read(sd, TVP5150_ACT_VD_CROP_ST_MSB), 154 tvp5150_read(sd, TVP5150_ACT_VD_CROP_ST_MSB),
151 tvp5150_read(sd, TVP5150_ACT_VD_CROP_ST_LSB)); 155 tvp5150_read(sd, TVP5150_ACT_VD_CROP_ST_LSB));
152 printk("tvp5150: Active video cropping stop = 0x%02x%02x\n", 156 dprintk0(sd->dev, "tvp5150: Active video cropping stop = 0x%02x%02x\n",
153 tvp5150_read(sd, TVP5150_ACT_VD_CROP_STP_MSB), 157 tvp5150_read(sd, TVP5150_ACT_VD_CROP_STP_MSB),
154 tvp5150_read(sd, TVP5150_ACT_VD_CROP_STP_LSB)); 158 tvp5150_read(sd, TVP5150_ACT_VD_CROP_STP_LSB));
155 printk("tvp5150: Genlock/RTC = 0x%02x\n", 159 dprintk0(sd->dev, "tvp5150: Genlock/RTC = 0x%02x\n",
156 tvp5150_read(sd, TVP5150_GENLOCK)); 160 tvp5150_read(sd, TVP5150_GENLOCK));
157 printk("tvp5150: Horizontal sync start = 0x%02x\n", 161 dprintk0(sd->dev, "tvp5150: Horizontal sync start = 0x%02x\n",
158 tvp5150_read(sd, TVP5150_HORIZ_SYNC_START)); 162 tvp5150_read(sd, TVP5150_HORIZ_SYNC_START));
159 printk("tvp5150: Vertical blanking start = 0x%02x\n", 163 dprintk0(sd->dev, "tvp5150: Vertical blanking start = 0x%02x\n",
160 tvp5150_read(sd, TVP5150_VERT_BLANKING_START)); 164 tvp5150_read(sd, TVP5150_VERT_BLANKING_START));
161 printk("tvp5150: Vertical blanking stop = 0x%02x\n", 165 dprintk0(sd->dev, "tvp5150: Vertical blanking stop = 0x%02x\n",
162 tvp5150_read(sd, TVP5150_VERT_BLANKING_STOP)); 166 tvp5150_read(sd, TVP5150_VERT_BLANKING_STOP));
163 printk("tvp5150: Chrominance processing control #1 and #2 = %02x %02x\n", 167 dprintk0(sd->dev, "tvp5150: Chrominance processing control #1 and #2 = %02x %02x\n",
164 tvp5150_read(sd, TVP5150_CHROMA_PROC_CTL_1), 168 tvp5150_read(sd, TVP5150_CHROMA_PROC_CTL_1),
165 tvp5150_read(sd, TVP5150_CHROMA_PROC_CTL_2)); 169 tvp5150_read(sd, TVP5150_CHROMA_PROC_CTL_2));
166 printk("tvp5150: Interrupt reset register B = 0x%02x\n", 170 dprintk0(sd->dev, "tvp5150: Interrupt reset register B = 0x%02x\n",
167 tvp5150_read(sd, TVP5150_INT_RESET_REG_B)); 171 tvp5150_read(sd, TVP5150_INT_RESET_REG_B));
168 printk("tvp5150: Interrupt enable register B = 0x%02x\n", 172 dprintk0(sd->dev, "tvp5150: Interrupt enable register B = 0x%02x\n",
169 tvp5150_read(sd, TVP5150_INT_ENABLE_REG_B)); 173 tvp5150_read(sd, TVP5150_INT_ENABLE_REG_B));
170 printk("tvp5150: Interrupt configuration register B = 0x%02x\n", 174 dprintk0(sd->dev, "tvp5150: Interrupt configuration register B = 0x%02x\n",
171 tvp5150_read(sd, TVP5150_INTT_CONFIG_REG_B)); 175 tvp5150_read(sd, TVP5150_INTT_CONFIG_REG_B));
172 printk("tvp5150: Video standard = 0x%02x\n", 176 dprintk0(sd->dev, "tvp5150: Video standard = 0x%02x\n",
173 tvp5150_read(sd, TVP5150_VIDEO_STD)); 177 tvp5150_read(sd, TVP5150_VIDEO_STD));
174 printk("tvp5150: Chroma gain factor: Cb=0x%02x Cr=0x%02x\n", 178 dprintk0(sd->dev, "tvp5150: Chroma gain factor: Cb=0x%02x Cr=0x%02x\n",
175 tvp5150_read(sd, TVP5150_CB_GAIN_FACT), 179 tvp5150_read(sd, TVP5150_CB_GAIN_FACT),
176 tvp5150_read(sd, TVP5150_CR_GAIN_FACTOR)); 180 tvp5150_read(sd, TVP5150_CR_GAIN_FACTOR));
177 printk("tvp5150: Macrovision on counter = 0x%02x\n", 181 dprintk0(sd->dev, "tvp5150: Macrovision on counter = 0x%02x\n",
178 tvp5150_read(sd, TVP5150_MACROVISION_ON_CTR)); 182 tvp5150_read(sd, TVP5150_MACROVISION_ON_CTR));
179 printk("tvp5150: Macrovision off counter = 0x%02x\n", 183 dprintk0(sd->dev, "tvp5150: Macrovision off counter = 0x%02x\n",
180 tvp5150_read(sd, TVP5150_MACROVISION_OFF_CTR)); 184 tvp5150_read(sd, TVP5150_MACROVISION_OFF_CTR));
181 printk("tvp5150: ITU-R BT.656.%d timing(TVP5150AM1 only)\n", 185 dprintk0(sd->dev, "tvp5150: ITU-R BT.656.%d timing(TVP5150AM1 only)\n",
182 (tvp5150_read(sd, TVP5150_REV_SELECT) & 1) ? 3 : 4); 186 (tvp5150_read(sd, TVP5150_REV_SELECT) & 1) ? 3 : 4);
183 printk("tvp5150: Device ID = %02x%02x\n", 187 dprintk0(sd->dev, "tvp5150: Device ID = %02x%02x\n",
184 tvp5150_read(sd, TVP5150_MSB_DEV_ID), 188 tvp5150_read(sd, TVP5150_MSB_DEV_ID),
185 tvp5150_read(sd, TVP5150_LSB_DEV_ID)); 189 tvp5150_read(sd, TVP5150_LSB_DEV_ID));
186 printk("tvp5150: ROM version = (hex) %02x.%02x\n", 190 dprintk0(sd->dev, "tvp5150: ROM version = (hex) %02x.%02x\n",
187 tvp5150_read(sd, TVP5150_ROM_MAJOR_VER), 191 tvp5150_read(sd, TVP5150_ROM_MAJOR_VER),
188 tvp5150_read(sd, TVP5150_ROM_MINOR_VER)); 192 tvp5150_read(sd, TVP5150_ROM_MINOR_VER));
189 printk("tvp5150: Vertical line count = 0x%02x%02x\n", 193 dprintk0(sd->dev, "tvp5150: Vertical line count = 0x%02x%02x\n",
190 tvp5150_read(sd, TVP5150_VERT_LN_COUNT_MSB), 194 tvp5150_read(sd, TVP5150_VERT_LN_COUNT_MSB),
191 tvp5150_read(sd, TVP5150_VERT_LN_COUNT_LSB)); 195 tvp5150_read(sd, TVP5150_VERT_LN_COUNT_LSB));
192 printk("tvp5150: Interrupt status register B = 0x%02x\n", 196 dprintk0(sd->dev, "tvp5150: Interrupt status register B = 0x%02x\n",
193 tvp5150_read(sd, TVP5150_INT_STATUS_REG_B)); 197 tvp5150_read(sd, TVP5150_INT_STATUS_REG_B));
194 printk("tvp5150: Interrupt active register B = 0x%02x\n", 198 dprintk0(sd->dev, "tvp5150: Interrupt active register B = 0x%02x\n",
195 tvp5150_read(sd, TVP5150_INT_ACTIVE_REG_B)); 199 tvp5150_read(sd, TVP5150_INT_ACTIVE_REG_B));
196 printk("tvp5150: Status regs #1 to #5 = %02x %02x %02x %02x %02x\n", 200 dprintk0(sd->dev, "tvp5150: Status regs #1 to #5 = %02x %02x %02x %02x %02x\n",
197 tvp5150_read(sd, TVP5150_STATUS_REG_1), 201 tvp5150_read(sd, TVP5150_STATUS_REG_1),
198 tvp5150_read(sd, TVP5150_STATUS_REG_2), 202 tvp5150_read(sd, TVP5150_STATUS_REG_2),
199 tvp5150_read(sd, TVP5150_STATUS_REG_3), 203 tvp5150_read(sd, TVP5150_STATUS_REG_3),
200 tvp5150_read(sd, TVP5150_STATUS_REG_4), 204 tvp5150_read(sd, TVP5150_STATUS_REG_4),
201 tvp5150_read(sd, TVP5150_STATUS_REG_5)); 205 tvp5150_read(sd, TVP5150_STATUS_REG_5));
202 206
203 dump_reg_range(sd, "Teletext filter 1", TVP5150_TELETEXT_FIL1_INI, 207 dump_reg_range(sd, "Teletext filter 1", TVP5150_TELETEXT_FIL1_INI,
204 TVP5150_TELETEXT_FIL1_END, 8); 208 TVP5150_TELETEXT_FIL1_END, 8);
205 dump_reg_range(sd, "Teletext filter 2", TVP5150_TELETEXT_FIL2_INI, 209 dump_reg_range(sd, "Teletext filter 2", TVP5150_TELETEXT_FIL2_INI,
206 TVP5150_TELETEXT_FIL2_END, 8); 210 TVP5150_TELETEXT_FIL2_END, 8);
207 211
208 printk("tvp5150: Teletext filter enable = 0x%02x\n", 212 dprintk0(sd->dev, "tvp5150: Teletext filter enable = 0x%02x\n",
209 tvp5150_read(sd, TVP5150_TELETEXT_FIL_ENA)); 213 tvp5150_read(sd, TVP5150_TELETEXT_FIL_ENA));
210 printk("tvp5150: Interrupt status register A = 0x%02x\n", 214 dprintk0(sd->dev, "tvp5150: Interrupt status register A = 0x%02x\n",
211 tvp5150_read(sd, TVP5150_INT_STATUS_REG_A)); 215 tvp5150_read(sd, TVP5150_INT_STATUS_REG_A));
212 printk("tvp5150: Interrupt enable register A = 0x%02x\n", 216 dprintk0(sd->dev, "tvp5150: Interrupt enable register A = 0x%02x\n",
213 tvp5150_read(sd, TVP5150_INT_ENABLE_REG_A)); 217 tvp5150_read(sd, TVP5150_INT_ENABLE_REG_A));
214 printk("tvp5150: Interrupt configuration = 0x%02x\n", 218 dprintk0(sd->dev, "tvp5150: Interrupt configuration = 0x%02x\n",
215 tvp5150_read(sd, TVP5150_INT_CONF)); 219 tvp5150_read(sd, TVP5150_INT_CONF));
216 printk("tvp5150: VDP status register = 0x%02x\n", 220 dprintk0(sd->dev, "tvp5150: VDP status register = 0x%02x\n",
217 tvp5150_read(sd, TVP5150_VDP_STATUS_REG)); 221 tvp5150_read(sd, TVP5150_VDP_STATUS_REG));
218 printk("tvp5150: FIFO word count = 0x%02x\n", 222 dprintk0(sd->dev, "tvp5150: FIFO word count = 0x%02x\n",
219 tvp5150_read(sd, TVP5150_FIFO_WORD_COUNT)); 223 tvp5150_read(sd, TVP5150_FIFO_WORD_COUNT));
220 printk("tvp5150: FIFO interrupt threshold = 0x%02x\n", 224 dprintk0(sd->dev, "tvp5150: FIFO interrupt threshold = 0x%02x\n",
221 tvp5150_read(sd, TVP5150_FIFO_INT_THRESHOLD)); 225 tvp5150_read(sd, TVP5150_FIFO_INT_THRESHOLD));
222 printk("tvp5150: FIFO reset = 0x%02x\n", 226 dprintk0(sd->dev, "tvp5150: FIFO reset = 0x%02x\n",
223 tvp5150_read(sd, TVP5150_FIFO_RESET)); 227 tvp5150_read(sd, TVP5150_FIFO_RESET));
224 printk("tvp5150: Line number interrupt = 0x%02x\n", 228 dprintk0(sd->dev, "tvp5150: Line number interrupt = 0x%02x\n",
225 tvp5150_read(sd, TVP5150_LINE_NUMBER_INT)); 229 tvp5150_read(sd, TVP5150_LINE_NUMBER_INT));
226 printk("tvp5150: Pixel alignment register = 0x%02x%02x\n", 230 dprintk0(sd->dev, "tvp5150: Pixel alignment register = 0x%02x%02x\n",
227 tvp5150_read(sd, TVP5150_PIX_ALIGN_REG_HIGH), 231 tvp5150_read(sd, TVP5150_PIX_ALIGN_REG_HIGH),
228 tvp5150_read(sd, TVP5150_PIX_ALIGN_REG_LOW)); 232 tvp5150_read(sd, TVP5150_PIX_ALIGN_REG_LOW));
229 printk("tvp5150: FIFO output control = 0x%02x\n", 233 dprintk0(sd->dev, "tvp5150: FIFO output control = 0x%02x\n",
230 tvp5150_read(sd, TVP5150_FIFO_OUT_CTRL)); 234 tvp5150_read(sd, TVP5150_FIFO_OUT_CTRL));
231 printk("tvp5150: Full field enable = 0x%02x\n", 235 dprintk0(sd->dev, "tvp5150: Full field enable = 0x%02x\n",
232 tvp5150_read(sd, TVP5150_FULL_FIELD_ENA)); 236 tvp5150_read(sd, TVP5150_FULL_FIELD_ENA));
233 printk("tvp5150: Full field mode register = 0x%02x\n", 237 dprintk0(sd->dev, "tvp5150: Full field mode register = 0x%02x\n",
234 tvp5150_read(sd, TVP5150_FULL_FIELD_MODE_REG)); 238 tvp5150_read(sd, TVP5150_FULL_FIELD_MODE_REG));
235 239
236 dump_reg_range(sd, "CC data", TVP5150_CC_DATA_INI, 240 dump_reg_range(sd, "CC data", TVP5150_CC_DATA_INI,
237 TVP5150_CC_DATA_END, 8); 241 TVP5150_CC_DATA_END, 8);
@@ -254,7 +258,7 @@ static int tvp5150_log_status(struct v4l2_subdev *sd)
254 Basic functions 258 Basic functions
255 ****************************************************************************/ 259 ****************************************************************************/
256 260
257static inline void tvp5150_selmux(struct v4l2_subdev *sd) 261static void tvp5150_selmux(struct v4l2_subdev *sd)
258{ 262{
259 int opmode = 0; 263 int opmode = 0;
260 struct tvp5150 *decoder = to_tvp5150(sd); 264 struct tvp5150 *decoder = to_tvp5150(sd);
@@ -280,8 +284,7 @@ static inline void tvp5150_selmux(struct v4l2_subdev *sd)
280 break; 284 break;
281 } 285 }
282 286
283 v4l2_dbg(1, debug, sd, "Selecting video route: route input=%i, output=%i " 287 dev_dbg_lvl(sd->dev, 1, debug, "Selecting video route: route input=%i, output=%i => tvp5150 input=%i, opmode=%i\n",
284 "=> tvp5150 input=%i, opmode=%i\n",
285 decoder->input, decoder->output, 288 decoder->input, decoder->output,
286 input, opmode); 289 input, opmode);
287 290
@@ -293,7 +296,7 @@ static inline void tvp5150_selmux(struct v4l2_subdev *sd)
293 */ 296 */
294 val = tvp5150_read(sd, TVP5150_MISC_CTL); 297 val = tvp5150_read(sd, TVP5150_MISC_CTL);
295 if (val < 0) { 298 if (val < 0) {
296 v4l2_err(sd, "%s: failed with error = %d\n", __func__, val); 299 dev_err(sd->dev, "%s: failed with error = %d\n", __func__, val);
297 return; 300 return;
298 } 301 }
299 302
@@ -611,7 +614,7 @@ static int tvp5150_g_sliced_vbi_cap(struct v4l2_subdev *sd,
611 const struct i2c_vbi_ram_value *regs = vbi_ram_default; 614 const struct i2c_vbi_ram_value *regs = vbi_ram_default;
612 int line; 615 int line;
613 616
614 v4l2_dbg(1, debug, sd, "g_sliced_vbi_cap\n"); 617 dev_dbg_lvl(sd->dev, 1, debug, "g_sliced_vbi_cap\n");
615 memset(cap, 0, sizeof *cap); 618 memset(cap, 0, sizeof *cap);
616 619
617 while (regs->reg != (u16)-1 ) { 620 while (regs->reg != (u16)-1 ) {
@@ -649,7 +652,7 @@ static int tvp5150_set_vbi(struct v4l2_subdev *sd,
649 int pos=0; 652 int pos=0;
650 653
651 if (std == V4L2_STD_ALL) { 654 if (std == V4L2_STD_ALL) {
652 v4l2_err(sd, "VBI can't be configured without knowing number of lines\n"); 655 dev_err(sd->dev, "VBI can't be configured without knowing number of lines\n");
653 return 0; 656 return 0;
654 } else if (std & V4L2_STD_625_50) { 657 } else if (std & V4L2_STD_625_50) {
655 /* Don't follow NTSC Line number convension */ 658 /* Don't follow NTSC Line number convension */
@@ -697,7 +700,7 @@ static int tvp5150_get_vbi(struct v4l2_subdev *sd,
697 int i, ret = 0; 700 int i, ret = 0;
698 701
699 if (std == V4L2_STD_ALL) { 702 if (std == V4L2_STD_ALL) {
700 v4l2_err(sd, "VBI can't be configured without knowing number of lines\n"); 703 dev_err(sd->dev, "VBI can't be configured without knowing number of lines\n");
701 return 0; 704 return 0;
702 } else if (std & V4L2_STD_625_50) { 705 } else if (std & V4L2_STD_625_50) {
703 /* Don't follow NTSC Line number convension */ 706 /* Don't follow NTSC Line number convension */
@@ -712,7 +715,7 @@ static int tvp5150_get_vbi(struct v4l2_subdev *sd,
712 for (i = 0; i <= 1; i++) { 715 for (i = 0; i <= 1; i++) {
713 ret = tvp5150_read(sd, reg + i); 716 ret = tvp5150_read(sd, reg + i);
714 if (ret < 0) { 717 if (ret < 0) {
715 v4l2_err(sd, "%s: failed with error = %d\n", 718 dev_err(sd->dev, "%s: failed with error = %d\n",
716 __func__, ret); 719 __func__, ret);
717 return 0; 720 return 0;
718 } 721 }
@@ -749,7 +752,7 @@ static int tvp5150_set_std(struct v4l2_subdev *sd, v4l2_std_id std)
749 fmt = VIDEO_STD_SECAM_BIT; 752 fmt = VIDEO_STD_SECAM_BIT;
750 } 753 }
751 754
752 v4l2_dbg(1, debug, sd, "Set video std register to %d.\n", fmt); 755 dev_dbg_lvl(sd->dev, 1, debug, "Set video std register to %d.\n", fmt);
753 tvp5150_write(sd, TVP5150_VIDEO_STD, fmt); 756 tvp5150_write(sd, TVP5150_VIDEO_STD, fmt);
754 return 0; 757 return 0;
755} 758}
@@ -815,6 +818,7 @@ static int tvp5150_s_ctrl(struct v4l2_ctrl *ctrl)
815 return 0; 818 return 0;
816 case V4L2_CID_HUE: 819 case V4L2_CID_HUE:
817 tvp5150_write(sd, TVP5150_HUE_CTL, ctrl->val); 820 tvp5150_write(sd, TVP5150_HUE_CTL, ctrl->val);
821 break;
818 case V4L2_CID_TEST_PATTERN: 822 case V4L2_CID_TEST_PATTERN:
819 decoder->enable = ctrl->val ? false : true; 823 decoder->enable = ctrl->val ? false : true;
820 tvp5150_selmux(sd); 824 tvp5150_selmux(sd);
@@ -866,7 +870,7 @@ static int tvp5150_fill_fmt(struct v4l2_subdev *sd,
866 f->field = V4L2_FIELD_ALTERNATE; 870 f->field = V4L2_FIELD_ALTERNATE;
867 f->colorspace = V4L2_COLORSPACE_SMPTE170M; 871 f->colorspace = V4L2_COLORSPACE_SMPTE170M;
868 872
869 v4l2_dbg(1, debug, sd, "width = %d, height = %d\n", f->width, 873 dev_dbg_lvl(sd->dev, 1, debug, "width = %d, height = %d\n", f->width,
870 f->height); 874 f->height);
871 return 0; 875 return 0;
872} 876}
@@ -884,7 +888,7 @@ static int tvp5150_set_selection(struct v4l2_subdev *sd,
884 sel->target != V4L2_SEL_TGT_CROP) 888 sel->target != V4L2_SEL_TGT_CROP)
885 return -EINVAL; 889 return -EINVAL;
886 890
887 v4l2_dbg(1, debug, sd, "%s left=%d, top=%d, width=%d, height=%d\n", 891 dev_dbg_lvl(sd->dev, 1, debug, "%s left=%d, top=%d, width=%d, height=%d\n",
888 __func__, rect.left, rect.top, rect.width, rect.height); 892 __func__, rect.left, rect.top, rect.width, rect.height);
889 893
890 /* tvp5150 has some special limits */ 894 /* tvp5150 has some special limits */
@@ -1010,11 +1014,11 @@ static int tvp5150_enum_frame_size(struct v4l2_subdev *sd,
1010 Media entity ops 1014 Media entity ops
1011 ****************************************************************************/ 1015 ****************************************************************************/
1012 1016
1017#ifdef CONFIG_MEDIA_CONTROLLER
1013static int tvp5150_link_setup(struct media_entity *entity, 1018static int tvp5150_link_setup(struct media_entity *entity,
1014 const struct media_pad *local, 1019 const struct media_pad *local,
1015 const struct media_pad *remote, u32 flags) 1020 const struct media_pad *remote, u32 flags)
1016{ 1021{
1017#ifdef CONFIG_MEDIA_CONTROLLER
1018 struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); 1022 struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
1019 struct tvp5150 *decoder = to_tvp5150(sd); 1023 struct tvp5150 *decoder = to_tvp5150(sd);
1020 int i; 1024 int i;
@@ -1031,7 +1035,6 @@ static int tvp5150_link_setup(struct media_entity *entity,
1031 decoder->input = i; 1035 decoder->input = i;
1032 1036
1033 tvp5150_selmux(sd); 1037 tvp5150_selmux(sd);
1034#endif
1035 1038
1036 return 0; 1039 return 0;
1037} 1040}
@@ -1039,6 +1042,7 @@ static int tvp5150_link_setup(struct media_entity *entity,
1039static const struct media_entity_operations tvp5150_sd_media_ops = { 1042static const struct media_entity_operations tvp5150_sd_media_ops = {
1040 .link_setup = tvp5150_link_setup, 1043 .link_setup = tvp5150_link_setup,
1041}; 1044};
1045#endif
1042 1046
1043/**************************************************************************** 1047/****************************************************************************
1044 I2C Command 1048 I2C Command
@@ -1148,7 +1152,7 @@ static int tvp5150_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *
1148 1152
1149 res = tvp5150_read(sd, reg->reg & 0xff); 1153 res = tvp5150_read(sd, reg->reg & 0xff);
1150 if (res < 0) { 1154 if (res < 0) {
1151 v4l2_err(sd, "%s: failed with error = %d\n", __func__, res); 1155 dev_err(sd->dev, "%s: failed with error = %d\n", __func__, res);
1152 return res; 1156 return res;
1153 } 1157 }
1154 1158
@@ -1288,21 +1292,21 @@ static int tvp5150_detect_version(struct tvp5150 *core)
1288 core->dev_id = (regs[0] << 8) | regs[1]; 1292 core->dev_id = (regs[0] << 8) | regs[1];
1289 core->rom_ver = (regs[2] << 8) | regs[3]; 1293 core->rom_ver = (regs[2] << 8) | regs[3];
1290 1294
1291 v4l2_info(sd, "tvp%04x (%u.%u) chip found @ 0x%02x (%s)\n", 1295 dev_info(sd->dev, "tvp%04x (%u.%u) chip found @ 0x%02x (%s)\n",
1292 core->dev_id, regs[2], regs[3], c->addr << 1, 1296 core->dev_id, regs[2], regs[3], c->addr << 1,
1293 c->adapter->name); 1297 c->adapter->name);
1294 1298
1295 if (core->dev_id == 0x5150 && core->rom_ver == 0x0321) { 1299 if (core->dev_id == 0x5150 && core->rom_ver == 0x0321) {
1296 v4l2_info(sd, "tvp5150a detected.\n"); 1300 dev_info(sd->dev, "tvp5150a detected.\n");
1297 } else if (core->dev_id == 0x5150 && core->rom_ver == 0x0400) { 1301 } else if (core->dev_id == 0x5150 && core->rom_ver == 0x0400) {
1298 v4l2_info(sd, "tvp5150am1 detected.\n"); 1302 dev_info(sd->dev, "tvp5150am1 detected.\n");
1299 1303
1300 /* ITU-T BT.656.4 timing */ 1304 /* ITU-T BT.656.4 timing */
1301 tvp5150_write(sd, TVP5150_REV_SELECT, 0); 1305 tvp5150_write(sd, TVP5150_REV_SELECT, 0);
1302 } else if (core->dev_id == 0x5151 && core->rom_ver == 0x0100) { 1306 } else if (core->dev_id == 0x5151 && core->rom_ver == 0x0100) {
1303 v4l2_info(sd, "tvp5151 detected.\n"); 1307 dev_info(sd->dev, "tvp5151 detected.\n");
1304 } else { 1308 } else {
1305 v4l2_info(sd, "*** unknown tvp%04x chip detected.\n", 1309 dev_info(sd->dev, "*** unknown tvp%04x chip detected.\n",
1306 core->dev_id); 1310 core->dev_id);
1307 } 1311 }
1308 1312
@@ -1381,7 +1385,7 @@ static int tvp5150_parse_dt(struct tvp5150 *decoder, struct device_node *np)
1381 for_each_available_child_of_node(connectors, child) { 1385 for_each_available_child_of_node(connectors, child) {
1382 ret = of_property_read_u32(child, "input", &input_type); 1386 ret = of_property_read_u32(child, "input", &input_type);
1383 if (ret) { 1387 if (ret) {
1384 v4l2_err(&decoder->sd, 1388 dev_err(decoder->sd.dev,
1385 "missing type property in node %s\n", 1389 "missing type property in node %s\n",
1386 child->name); 1390 child->name);
1387 goto err_connector; 1391 goto err_connector;
@@ -1396,7 +1400,7 @@ static int tvp5150_parse_dt(struct tvp5150 *decoder, struct device_node *np)
1396 1400
1397 /* Each input connector can only be defined once */ 1401 /* Each input connector can only be defined once */
1398 if (input->name) { 1402 if (input->name) {
1399 v4l2_err(&decoder->sd, 1403 dev_err(decoder->sd.dev,
1400 "input %s with same type already exists\n", 1404 "input %s with same type already exists\n",
1401 input->name); 1405 input->name);
1402 ret = -EINVAL; 1406 ret = -EINVAL;
@@ -1417,7 +1421,7 @@ static int tvp5150_parse_dt(struct tvp5150 *decoder, struct device_node *np)
1417 1421
1418 ret = of_property_read_string(child, "label", &name); 1422 ret = of_property_read_string(child, "label", &name);
1419 if (ret < 0) { 1423 if (ret < 0) {
1420 v4l2_err(&decoder->sd, 1424 dev_err(decoder->sd.dev,
1421 "missing label property in node %s\n", 1425 "missing label property in node %s\n",
1422 child->name); 1426 child->name);
1423 goto err_connector; 1427 goto err_connector;
@@ -1465,7 +1469,7 @@ static int tvp5150_probe(struct i2c_client *c,
1465 if (IS_ENABLED(CONFIG_OF) && np) { 1469 if (IS_ENABLED(CONFIG_OF) && np) {
1466 res = tvp5150_parse_dt(core, np); 1470 res = tvp5150_parse_dt(core, np);
1467 if (res) { 1471 if (res) {
1468 v4l2_err(sd, "DT parsing error: %d\n", res); 1472 dev_err(sd->dev, "DT parsing error: %d\n", res);
1469 return res; 1473 return res;
1470 } 1474 }
1471 } else { 1475 } else {
@@ -1549,7 +1553,7 @@ static int tvp5150_remove(struct i2c_client *c)
1549 struct v4l2_subdev *sd = i2c_get_clientdata(c); 1553 struct v4l2_subdev *sd = i2c_get_clientdata(c);
1550 struct tvp5150 *decoder = to_tvp5150(sd); 1554 struct tvp5150 *decoder = to_tvp5150(sd);
1551 1555
1552 v4l2_dbg(1, debug, sd, 1556 dev_dbg_lvl(sd->dev, 1, debug,
1553 "tvp5150.c: removing tvp5150 adapter on address 0x%x\n", 1557 "tvp5150.c: removing tvp5150 adapter on address 0x%x\n",
1554 c->addr << 1); 1558 c->addr << 1);
1555 1559
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 2783531f9fc0..8756275e9fc4 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -801,9 +801,13 @@ void media_device_unregister(struct media_device *mdev)
801 /* Remove all interfaces from the media device */ 801 /* Remove all interfaces from the media device */
802 list_for_each_entry_safe(intf, tmp_intf, &mdev->interfaces, 802 list_for_each_entry_safe(intf, tmp_intf, &mdev->interfaces,
803 graph_obj.list) { 803 graph_obj.list) {
804 /*
805 * Unlink the interface, but don't free it here; the
806 * module which created it is responsible for freeing
807 * it
808 */
804 __media_remove_intf_links(intf); 809 __media_remove_intf_links(intf);
805 media_gobj_destroy(&intf->graph_obj); 810 media_gobj_destroy(&intf->graph_obj);
806 kfree(intf);
807 } 811 }
808 812
809 mutex_unlock(&mdev->graph_mutex); 813 mutex_unlock(&mdev->graph_mutex);
@@ -817,32 +821,6 @@ void media_device_unregister(struct media_device *mdev)
817} 821}
818EXPORT_SYMBOL_GPL(media_device_unregister); 822EXPORT_SYMBOL_GPL(media_device_unregister);
819 823
820static void media_device_release_devres(struct device *dev, void *res)
821{
822}
823
824struct media_device *media_device_get_devres(struct device *dev)
825{
826 struct media_device *mdev;
827
828 mdev = devres_find(dev, media_device_release_devres, NULL, NULL);
829 if (mdev)
830 return mdev;
831
832 mdev = devres_alloc(media_device_release_devres,
833 sizeof(struct media_device), GFP_KERNEL);
834 if (!mdev)
835 return NULL;
836 return devres_get(dev, mdev, NULL, NULL);
837}
838EXPORT_SYMBOL_GPL(media_device_get_devres);
839
840struct media_device *media_device_find_devres(struct device *dev)
841{
842 return devres_find(dev, media_device_release_devres, NULL, NULL);
843}
844EXPORT_SYMBOL_GPL(media_device_find_devres);
845
846#if IS_ENABLED(CONFIG_PCI) 824#if IS_ENABLED(CONFIG_PCI)
847void media_device_pci_init(struct media_device *mdev, 825void media_device_pci_init(struct media_device *mdev,
848 struct pci_dev *pci_dev, 826 struct pci_dev *pci_dev,
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index c68239e60487..f9f723f5e4f0 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -205,10 +205,16 @@ void media_gobj_destroy(struct media_gobj *gobj)
205{ 205{
206 dev_dbg_obj(__func__, gobj); 206 dev_dbg_obj(__func__, gobj);
207 207
208 /* Do nothing if the object is not linked. */
209 if (gobj->mdev == NULL)
210 return;
211
208 gobj->mdev->topology_version++; 212 gobj->mdev->topology_version++;
209 213
210 /* Remove the object from mdev list */ 214 /* Remove the object from mdev list */
211 list_del(&gobj->list); 215 list_del(&gobj->list);
216
217 gobj->mdev = NULL;
212} 218}
213 219
214int media_entity_pads_init(struct media_entity *entity, u16 num_pads, 220int media_entity_pads_init(struct media_entity *entity, u16 num_pads,
diff --git a/drivers/media/pci/b2c2/flexcop-dma.c b/drivers/media/pci/b2c2/flexcop-dma.c
index 2881e0d956ad..913dc97f8b49 100644
--- a/drivers/media/pci/b2c2/flexcop-dma.c
+++ b/drivers/media/pci/b2c2/flexcop-dma.c
@@ -57,8 +57,7 @@ int flexcop_dma_config(struct flexcop_device *fc,
57 fc->write_ibi_reg(fc,dma2_014,v0x4); 57 fc->write_ibi_reg(fc,dma2_014,v0x4);
58 fc->write_ibi_reg(fc,dma2_01c,v0xc); 58 fc->write_ibi_reg(fc,dma2_01c,v0xc);
59 } else { 59 } else {
60 err("either DMA1 or DMA2 can be configured within one " 60 err("either DMA1 or DMA2 can be configured within one flexcop_dma_config call.");
61 "flexcop_dma_config call.");
62 return -EINVAL; 61 return -EINVAL;
63 } 62 }
64 63
@@ -82,8 +81,7 @@ int flexcop_dma_xfer_control(struct flexcop_device *fc,
82 r0x0 = dma2_010; 81 r0x0 = dma2_010;
83 r0xc = dma2_01c; 82 r0xc = dma2_01c;
84 } else { 83 } else {
85 err("either transfer DMA1 or DMA2 can be started within one " 84 err("either transfer DMA1 or DMA2 can be started within one flexcop_dma_xfer_control call.");
86 "flexcop_dma_xfer_control call.");
87 return -EINVAL; 85 return -EINVAL;
88 } 86 }
89 87
diff --git a/drivers/media/pci/b2c2/flexcop-pci.c b/drivers/media/pci/b2c2/flexcop-pci.c
index 4cac1fc233f2..99ce28442a75 100644
--- a/drivers/media/pci/b2c2/flexcop-pci.c
+++ b/drivers/media/pci/b2c2/flexcop-pci.c
@@ -185,8 +185,7 @@ static irqreturn_t flexcop_pci_isr(int irq, void *dev_id)
185 fc->read_ibi_reg(fc,dma1_008).dma_0x8.dma_cur_addr << 2; 185 fc->read_ibi_reg(fc,dma1_008).dma_0x8.dma_cur_addr << 2;
186 u32 cur_pos = cur_addr - fc_pci->dma[0].dma_addr0; 186 u32 cur_pos = cur_addr - fc_pci->dma[0].dma_addr0;
187 187
188 deb_irq("%u irq: %08x cur_addr: %llx: cur_pos: %08x, " 188 deb_irq("%u irq: %08x cur_addr: %llx: cur_pos: %08x, last_cur_pos: %08x ",
189 "last_cur_pos: %08x ",
190 jiffies_to_usecs(jiffies - fc_pci->last_irq), 189 jiffies_to_usecs(jiffies - fc_pci->last_irq),
191 v.raw, (unsigned long long)cur_addr, cur_pos, 190 v.raw, (unsigned long long)cur_addr, cur_pos,
192 fc_pci->last_dma1_cur_pos); 191 fc_pci->last_dma1_cur_pos);
@@ -220,8 +219,8 @@ static irqreturn_t flexcop_pci_isr(int irq, void *dev_id)
220 fc_pci->last_dma1_cur_pos = cur_pos; 219 fc_pci->last_dma1_cur_pos = cur_pos;
221 fc_pci->count++; 220 fc_pci->count++;
222 } else { 221 } else {
223 deb_irq("isr for flexcop called, " 222 deb_irq("isr for flexcop called, apparently without reason (%08x)\n",
224 "apparently without reason (%08x)\n", v.raw); 223 v.raw);
225 ret = IRQ_NONE; 224 ret = IRQ_NONE;
226 } 225 }
227 226
diff --git a/drivers/media/pci/bt8xx/btcx-risc.c b/drivers/media/pci/bt8xx/btcx-risc.c
index 57c7f58c3af2..70bdf93fc020 100644
--- a/drivers/media/pci/bt8xx/btcx-risc.c
+++ b/drivers/media/pci/bt8xx/btcx-risc.c
@@ -22,6 +22,8 @@
22 22
23*/ 23*/
24 24
25#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
26
25#include <linux/module.h> 27#include <linux/module.h>
26#include <linux/init.h> 28#include <linux/init.h>
27#include <linux/pci.h> 29#include <linux/pci.h>
@@ -36,6 +38,13 @@ static unsigned int btcx_debug;
36module_param(btcx_debug, int, 0644); 38module_param(btcx_debug, int, 0644);
37MODULE_PARM_DESC(btcx_debug,"debug messages, default is 0 (no)"); 39MODULE_PARM_DESC(btcx_debug,"debug messages, default is 0 (no)");
38 40
41#define dprintk(fmt, arg...) do { \
42 if (btcx_debug) \
43 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
44 __func__, ##arg); \
45} while (0)
46
47
39/* ---------------------------------------------------------- */ 48/* ---------------------------------------------------------- */
40/* allocate/free risc memory */ 49/* allocate/free risc memory */
41 50
@@ -46,11 +55,11 @@ void btcx_riscmem_free(struct pci_dev *pci,
46{ 55{
47 if (NULL == risc->cpu) 56 if (NULL == risc->cpu)
48 return; 57 return;
49 if (btcx_debug) { 58
50 memcnt--; 59 memcnt--;
51 printk("btcx: riscmem free [%d] dma=%lx\n", 60 dprintk("btcx: riscmem free [%d] dma=%lx\n",
52 memcnt, (unsigned long)risc->dma); 61 memcnt, (unsigned long)risc->dma);
53 } 62
54 pci_free_consistent(pci, risc->size, risc->cpu, risc->dma); 63 pci_free_consistent(pci, risc->size, risc->cpu, risc->dma);
55 memset(risc,0,sizeof(*risc)); 64 memset(risc,0,sizeof(*risc));
56} 65}
@@ -71,11 +80,10 @@ int btcx_riscmem_alloc(struct pci_dev *pci,
71 risc->cpu = cpu; 80 risc->cpu = cpu;
72 risc->dma = dma; 81 risc->dma = dma;
73 risc->size = size; 82 risc->size = size;
74 if (btcx_debug) { 83
75 memcnt++; 84 memcnt++;
76 printk("btcx: riscmem alloc [%d] dma=%lx cpu=%p size=%d\n", 85 dprintk("btcx: riscmem alloc [%d] dma=%lx cpu=%p size=%d\n",
77 memcnt, (unsigned long)dma, cpu, size); 86 memcnt, (unsigned long)dma, cpu, size);
78 }
79 } 87 }
80 memset(risc->cpu,0,risc->size); 88 memset(risc->cpu,0,risc->size);
81 return 0; 89 return 0;
@@ -137,9 +145,8 @@ btcx_align(struct v4l2_rect *win, struct v4l2_clip *clips, unsigned int n, int m
137 dx = nx - win->left; 145 dx = nx - win->left;
138 win->left = nx; 146 win->left = nx;
139 win->width = nw; 147 win->width = nw;
140 if (btcx_debug) 148 dprintk("btcx: window align %dx%d+%d+%d [dx=%d]\n",
141 printk(KERN_DEBUG "btcx: window align %dx%d+%d+%d [dx=%d]\n", 149 win->width, win->height, win->left, win->top, dx);
142 win->width, win->height, win->left, win->top, dx);
143 150
144 /* fixup clips */ 151 /* fixup clips */
145 for (i = 0; i < n; i++) { 152 for (i = 0; i < n; i++) {
@@ -149,10 +156,9 @@ btcx_align(struct v4l2_rect *win, struct v4l2_clip *clips, unsigned int n, int m
149 nw += mask+1; 156 nw += mask+1;
150 clips[i].c.left = nx; 157 clips[i].c.left = nx;
151 clips[i].c.width = nw; 158 clips[i].c.width = nw;
152 if (btcx_debug) 159 dprintk("btcx: clip align %dx%d+%d+%d\n",
153 printk(KERN_DEBUG "btcx: clip align %dx%d+%d+%d\n", 160 clips[i].c.width, clips[i].c.height,
154 clips[i].c.width, clips[i].c.height, 161 clips[i].c.left, clips[i].c.top);
155 clips[i].c.left, clips[i].c.top);
156 } 162 }
157 return 0; 163 return 0;
158} 164}
@@ -228,10 +234,10 @@ btcx_calc_skips(int line, int width, int *maxy,
228 *maxy = maxline; 234 *maxy = maxline;
229 235
230 if (btcx_debug) { 236 if (btcx_debug) {
231 printk(KERN_DEBUG "btcx: skips line %d-%d:",line,maxline); 237 dprintk("btcx: skips line %d-%d:", line, maxline);
232 for (skip = 0; skip < *nskips; skip++) { 238 for (skip = 0; skip < *nskips; skip++) {
233 printk(" %d-%d",skips[skip].start,skips[skip].end); 239 pr_cont(" %d-%d", skips[skip].start, skips[skip].end);
234 } 240 }
235 printk("\n"); 241 pr_cont("\n");
236 } 242 }
237} 243}
diff --git a/drivers/media/pci/bt8xx/bttv-cards.c b/drivers/media/pci/bt8xx/bttv-cards.c
index 8a17cc0bfa07..a1b0f3193bc0 100644
--- a/drivers/media/pci/bt8xx/bttv-cards.c
+++ b/drivers/media/pci/bt8xx/bttv-cards.c
@@ -125,10 +125,8 @@ module_param_array(remote, int, NULL, 0444);
125module_param_array(audiodev, int, NULL, 0444); 125module_param_array(audiodev, int, NULL, 0444);
126module_param_array(audiomux, int, NULL, 0444); 126module_param_array(audiomux, int, NULL, 0444);
127 127
128MODULE_PARM_DESC(triton1,"set ETBF pci config bit " 128MODULE_PARM_DESC(triton1, "set ETBF pci config bit [enable bug compatibility for triton1 + others]");
129 "[enable bug compatibility for triton1 + others]"); 129MODULE_PARM_DESC(vsfx, "set VSFX pci config bit [yet another chipset flaw workaround]");
130MODULE_PARM_DESC(vsfx,"set VSFX pci config bit "
131 "[yet another chipset flaw workaround]");
132MODULE_PARM_DESC(latency,"pci latency timer"); 130MODULE_PARM_DESC(latency,"pci latency timer");
133MODULE_PARM_DESC(card,"specify TV/grabber card model, see CARDLIST file for a list"); 131MODULE_PARM_DESC(card,"specify TV/grabber card model, see CARDLIST file for a list");
134MODULE_PARM_DESC(pll, "specify installed crystal (0=none, 28=28 MHz, 35=35 MHz, 14=14 MHz)"); 132MODULE_PARM_DESC(pll, "specify installed crystal (0=none, 28=28 MHz, 35=35 MHz, 14=14 MHz)");
@@ -141,8 +139,7 @@ MODULE_PARM_DESC(audiodev, "specify audio device:\n"
141 "\t\t 2 = tda7432\n" 139 "\t\t 2 = tda7432\n"
142 "\t\t 3 = tvaudio"); 140 "\t\t 3 = tvaudio");
143MODULE_PARM_DESC(saa6588, "if 1, then load the saa6588 RDS module, default (0) is to use the card definition."); 141MODULE_PARM_DESC(saa6588, "if 1, then load the saa6588 RDS module, default (0) is to use the card definition.");
144MODULE_PARM_DESC(no_overlay,"allow override overlay default (0 disables, 1 enables)" 142MODULE_PARM_DESC(no_overlay, "allow override overlay default (0 disables, 1 enables) [some VIA/SIS chipsets are known to have problem with overlay]");
145 " [some VIA/SIS chipsets are known to have problem with overlay]");
146 143
147/* ----------------------------------------------------------------------- */ 144/* ----------------------------------------------------------------------- */
148/* list of card IDs for bt878+ cards */ 145/* list of card IDs for bt878+ cards */
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 97b91a9f9fa9..fb4aefbcc8f8 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -148,8 +148,7 @@ MODULE_PARM_DESC(irq_debug, "irq handler debug messages, default is 0 (no)");
148MODULE_PARM_DESC(disable_ir, "disable infrared remote support"); 148MODULE_PARM_DESC(disable_ir, "disable infrared remote support");
149MODULE_PARM_DESC(gbuffers, "number of capture buffers. range 2-32, default 8"); 149MODULE_PARM_DESC(gbuffers, "number of capture buffers. range 2-32, default 8");
150MODULE_PARM_DESC(gbufsize, "size of the capture buffers, default is 0x208000"); 150MODULE_PARM_DESC(gbufsize, "size of the capture buffers, default is 0x208000");
151MODULE_PARM_DESC(reset_crop, "reset cropping parameters at open(), default " 151MODULE_PARM_DESC(reset_crop, "reset cropping parameters at open(), default is 1 (yes) for compatibility with older applications");
152 "is 1 (yes) for compatibility with older applications");
153MODULE_PARM_DESC(automute, "mute audio on bad/missing video signal, default is 1 (yes)"); 152MODULE_PARM_DESC(automute, "mute audio on bad/missing video signal, default is 1 (yes)");
154MODULE_PARM_DESC(chroma_agc, "enables the AGC of chroma signal, default is 0 (no)"); 153MODULE_PARM_DESC(chroma_agc, "enables the AGC of chroma signal, default is 0 (no)");
155MODULE_PARM_DESC(agc_crush, "enables the luminance AGC crush, default is 1 (yes)"); 154MODULE_PARM_DESC(agc_crush, "enables the luminance AGC crush, default is 1 (yes)");
@@ -3506,8 +3505,7 @@ static void bttv_irq_debug_low_latency(struct bttv *btv, u32 rc)
3506 (unsigned long)rc); 3505 (unsigned long)rc);
3507 3506
3508 if (0 == (btread(BT848_DSTATUS) & BT848_DSTATUS_HLOC)) { 3507 if (0 == (btread(BT848_DSTATUS) & BT848_DSTATUS_HLOC)) {
3509 pr_notice("%d: Oh, there (temporarily?) is no input signal. " 3508 pr_notice("%d: Oh, there (temporarily?) is no input signal. Ok, then this is harmless, don't worry ;)\n",
3510 "Ok, then this is harmless, don't worry ;)\n",
3511 btv->c.nr); 3509 btv->c.nr);
3512 return; 3510 return;
3513 } 3511 }
diff --git a/drivers/media/pci/bt8xx/bttv-i2c.c b/drivers/media/pci/bt8xx/bttv-i2c.c
index d43911deb617..274fd036b306 100644
--- a/drivers/media/pci/bt8xx/bttv-i2c.c
+++ b/drivers/media/pci/bt8xx/bttv-i2c.c
@@ -44,15 +44,13 @@ static int i2c_scan;
44module_param(i2c_debug, int, 0644); 44module_param(i2c_debug, int, 0644);
45MODULE_PARM_DESC(i2c_debug, "configure i2c debug level"); 45MODULE_PARM_DESC(i2c_debug, "configure i2c debug level");
46module_param(i2c_hw, int, 0444); 46module_param(i2c_hw, int, 0444);
47MODULE_PARM_DESC(i2c_hw,"force use of hardware i2c support, " 47MODULE_PARM_DESC(i2c_hw, "force use of hardware i2c support, instead of software bitbang");
48 "instead of software bitbang");
49module_param(i2c_scan, int, 0444); 48module_param(i2c_scan, int, 0444);
50MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); 49MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
51 50
52static unsigned int i2c_udelay = 5; 51static unsigned int i2c_udelay = 5;
53module_param(i2c_udelay, int, 0444); 52module_param(i2c_udelay, int, 0444);
54MODULE_PARM_DESC(i2c_udelay,"soft i2c delay at insmod time, in usecs " 53MODULE_PARM_DESC(i2c_udelay, "soft i2c delay at insmod time, in usecs (should be 5 or higher). Lower value means higher bus speed.");
55 "(should be 5 or higher). Lower value means higher bus speed.");
56 54
57/* ----------------------------------------------------------------------- */ 55/* ----------------------------------------------------------------------- */
58/* I2C functions - bitbanging adapter (software i2c) */ 56/* I2C functions - bitbanging adapter (software i2c) */
diff --git a/drivers/media/pci/bt8xx/bttv-input.c b/drivers/media/pci/bt8xx/bttv-input.c
index a75c53da224a..4da720e4867e 100644
--- a/drivers/media/pci/bt8xx/bttv-input.c
+++ b/drivers/media/pci/bt8xx/bttv-input.c
@@ -185,8 +185,8 @@ static u32 bttv_rc5_decode(unsigned int code)
185 return 0; 185 return 0;
186 } 186 }
187 } 187 }
188 dprintk("code=%x, rc5=%x, start=%x, toggle=%x, address=%x, " 188 dprintk("code=%x, rc5=%x, start=%x, toggle=%x, address=%x, instr=%x\n",
189 "instr=%x\n", rc5, org_code, RC5_START(rc5), 189 rc5, org_code, RC5_START(rc5),
190 RC5_TOGGLE(rc5), RC5_ADDR(rc5), RC5_INSTR(rc5)); 190 RC5_TOGGLE(rc5), RC5_ADDR(rc5), RC5_INSTR(rc5));
191 return rc5; 191 return rc5;
192} 192}
diff --git a/drivers/media/pci/bt8xx/dst.c b/drivers/media/pci/bt8xx/dst.c
index 35bc9b2287b4..7166d2279465 100644
--- a/drivers/media/pci/bt8xx/dst.c
+++ b/drivers/media/pci/bt8xx/dst.c
@@ -18,6 +18,8 @@
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/ 19*/
20 20
21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22
21#include <linux/kernel.h> 23#include <linux/kernel.h>
22#include <linux/module.h> 24#include <linux/module.h>
23#include <linux/init.h> 25#include <linux/init.h>
@@ -30,9 +32,9 @@
30#include "dst_priv.h" 32#include "dst_priv.h"
31#include "dst_common.h" 33#include "dst_common.h"
32 34
33static unsigned int verbose = 1; 35static unsigned int verbose;
34module_param(verbose, int, 0644); 36module_param(verbose, int, 0644);
35MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); 37MODULE_PARM_DESC(verbose, "verbosity level (0 to 3)");
36 38
37static unsigned int dst_addons; 39static unsigned int dst_addons;
38module_param(dst_addons, int, 0644); 40module_param(dst_addons, int, 0644);
@@ -46,29 +48,10 @@ MODULE_PARM_DESC(dst_algo, "tuning algo: default is 0=(SW), 1=(HW)");
46#define ATTEMPT_TUNE 2 48#define ATTEMPT_TUNE 2
47#define HAS_POWER 4 49#define HAS_POWER 4
48 50
49#define DST_ERROR 0 51#define dprintk(level, fmt, arg...) do { \
50#define DST_NOTICE 1 52 if (level >= verbose) \
51#define DST_INFO 2 53 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
52#define DST_DEBUG 3 54 __func__, ##arg); \
53
54#define dprintk(x, y, z, format, arg...) do { \
55 if (z) { \
56 if ((x > DST_ERROR) && (x > y)) \
57 printk(KERN_ERR "dst(%d) %s: " format "\n", \
58 state->bt->nr, __func__ , ##arg); \
59 else if ((x > DST_NOTICE) && (x > y)) \
60 printk(KERN_NOTICE "dst(%d) %s: " format "\n", \
61 state->bt->nr, __func__ , ##arg); \
62 else if ((x > DST_INFO) && (x > y)) \
63 printk(KERN_INFO "dst(%d) %s: " format "\n", \
64 state->bt->nr, __func__ , ##arg); \
65 else if ((x > DST_DEBUG) && (x > y)) \
66 printk(KERN_DEBUG "dst(%d) %s: " format "\n", \
67 state->bt->nr, __func__ , ##arg); \
68 } else { \
69 if (x > y) \
70 printk(format, ##arg); \
71 } \
72} while(0) 55} while(0)
73 56
74static int dst_command(struct dst_state *state, u8 *data, u8 len); 57static int dst_command(struct dst_state *state, u8 *data, u8 len);
@@ -91,9 +74,11 @@ static int dst_gpio_outb(struct dst_state *state, u32 mask, u32 enbb,
91 enb.enb.mask = mask; 74 enb.enb.mask = mask;
92 enb.enb.enable = enbb; 75 enb.enb.enable = enbb;
93 76
94 dprintk(verbose, DST_INFO, 1, "mask=[%04x], enbb=[%04x], outhigh=[%04x]", mask, enbb, outhigh); 77 dprintk(2, "mask=[%04x], enbb=[%04x], outhigh=[%04x]\n",
78 mask, enbb, outhigh);
95 if ((err = bt878_device_control(state->bt, DST_IG_ENABLE, &enb)) < 0) { 79 if ((err = bt878_device_control(state->bt, DST_IG_ENABLE, &enb)) < 0) {
96 dprintk(verbose, DST_INFO, 1, "dst_gpio_enb error (err == %i, mask == %02x, enb == %02x)", err, mask, enbb); 80 dprintk(2, "dst_gpio_enb error (err == %i, mask == %02x, enb == %02x)\n",
81 err, mask, enbb);
97 return -EREMOTEIO; 82 return -EREMOTEIO;
98 } 83 }
99 udelay(1000); 84 udelay(1000);
@@ -105,7 +90,8 @@ static int dst_gpio_outb(struct dst_state *state, u32 mask, u32 enbb,
105 bits.outp.mask = enbb; 90 bits.outp.mask = enbb;
106 bits.outp.highvals = outhigh; 91 bits.outp.highvals = outhigh;
107 if ((err = bt878_device_control(state->bt, DST_IG_WRITE, &bits)) < 0) { 92 if ((err = bt878_device_control(state->bt, DST_IG_WRITE, &bits)) < 0) {
108 dprintk(verbose, DST_INFO, 1, "dst_gpio_outb error (err == %i, enbb == %02x, outhigh == %02x)", err, enbb, outhigh); 93 dprintk(2, "dst_gpio_outb error (err == %i, enbb == %02x, outhigh == %02x)\n",
94 err, enbb, outhigh);
109 return -EREMOTEIO; 95 return -EREMOTEIO;
110 } 96 }
111 97
@@ -119,7 +105,7 @@ static int dst_gpio_inb(struct dst_state *state, u8 *result)
119 105
120 *result = 0; 106 *result = 0;
121 if ((err = bt878_device_control(state->bt, DST_IG_READ, &rd_packet)) < 0) { 107 if ((err = bt878_device_control(state->bt, DST_IG_READ, &rd_packet)) < 0) {
122 dprintk(verbose, DST_ERROR, 1, "dst_gpio_inb error (err == %i)", err); 108 pr_err("dst_gpio_inb error (err == %i)\n", err);
123 return -EREMOTEIO; 109 return -EREMOTEIO;
124 } 110 }
125 *result = (u8) rd_packet.rd.value; 111 *result = (u8) rd_packet.rd.value;
@@ -129,14 +115,14 @@ static int dst_gpio_inb(struct dst_state *state, u8 *result)
129 115
130int rdc_reset_state(struct dst_state *state) 116int rdc_reset_state(struct dst_state *state)
131{ 117{
132 dprintk(verbose, DST_INFO, 1, "Resetting state machine"); 118 dprintk(2, "Resetting state machine\n");
133 if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, 0, NO_DELAY) < 0) { 119 if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, 0, NO_DELAY) < 0) {
134 dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); 120 pr_err("dst_gpio_outb ERROR !\n");
135 return -1; 121 return -1;
136 } 122 }
137 msleep(10); 123 msleep(10);
138 if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, RDC_8820_INT, NO_DELAY) < 0) { 124 if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, RDC_8820_INT, NO_DELAY) < 0) {
139 dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); 125 pr_err("dst_gpio_outb ERROR !\n");
140 msleep(10); 126 msleep(10);
141 return -1; 127 return -1;
142 } 128 }
@@ -147,14 +133,14 @@ EXPORT_SYMBOL(rdc_reset_state);
147 133
148static int rdc_8820_reset(struct dst_state *state) 134static int rdc_8820_reset(struct dst_state *state)
149{ 135{
150 dprintk(verbose, DST_DEBUG, 1, "Resetting DST"); 136 dprintk(3, "Resetting DST\n");
151 if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, 0, NO_DELAY) < 0) { 137 if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, 0, NO_DELAY) < 0) {
152 dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); 138 pr_err("dst_gpio_outb ERROR !\n");
153 return -1; 139 return -1;
154 } 140 }
155 udelay(1000); 141 udelay(1000);
156 if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, RDC_8820_RESET, DELAY) < 0) { 142 if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, RDC_8820_RESET, DELAY) < 0) {
157 dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); 143 pr_err("dst_gpio_outb ERROR !\n");
158 return -1; 144 return -1;
159 } 145 }
160 146
@@ -164,7 +150,7 @@ static int rdc_8820_reset(struct dst_state *state)
164static int dst_pio_enable(struct dst_state *state) 150static int dst_pio_enable(struct dst_state *state)
165{ 151{
166 if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_ENABLE, 0, NO_DELAY) < 0) { 152 if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_ENABLE, 0, NO_DELAY) < 0) {
167 dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); 153 pr_err("dst_gpio_outb ERROR !\n");
168 return -1; 154 return -1;
169 } 155 }
170 udelay(1000); 156 udelay(1000);
@@ -175,7 +161,7 @@ static int dst_pio_enable(struct dst_state *state)
175int dst_pio_disable(struct dst_state *state) 161int dst_pio_disable(struct dst_state *state)
176{ 162{
177 if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_DISABLE, RDC_8820_PIO_0_DISABLE, NO_DELAY) < 0) { 163 if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_DISABLE, RDC_8820_PIO_0_DISABLE, NO_DELAY) < 0) {
178 dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); 164 pr_err("dst_gpio_outb ERROR !\n");
179 return -1; 165 return -1;
180 } 166 }
181 if (state->type_flags & DST_TYPE_HAS_FW_1) 167 if (state->type_flags & DST_TYPE_HAS_FW_1)
@@ -192,16 +178,16 @@ int dst_wait_dst_ready(struct dst_state *state, u8 delay_mode)
192 178
193 for (i = 0; i < 200; i++) { 179 for (i = 0; i < 200; i++) {
194 if (dst_gpio_inb(state, &reply) < 0) { 180 if (dst_gpio_inb(state, &reply) < 0) {
195 dprintk(verbose, DST_ERROR, 1, "dst_gpio_inb ERROR !"); 181 pr_err("dst_gpio_inb ERROR !\n");
196 return -1; 182 return -1;
197 } 183 }
198 if ((reply & RDC_8820_PIO_0_ENABLE) == 0) { 184 if ((reply & RDC_8820_PIO_0_ENABLE) == 0) {
199 dprintk(verbose, DST_INFO, 1, "dst wait ready after %d", i); 185 dprintk(2, "dst wait ready after %d\n", i);
200 return 1; 186 return 1;
201 } 187 }
202 msleep(10); 188 msleep(10);
203 } 189 }
204 dprintk(verbose, DST_NOTICE, 1, "dst wait NOT ready after %d", i); 190 dprintk(1, "dst wait NOT ready after %d\n", i);
205 191
206 return 0; 192 return 0;
207} 193}
@@ -209,7 +195,7 @@ EXPORT_SYMBOL(dst_wait_dst_ready);
209 195
210int dst_error_recovery(struct dst_state *state) 196int dst_error_recovery(struct dst_state *state)
211{ 197{
212 dprintk(verbose, DST_NOTICE, 1, "Trying to return from previous errors."); 198 dprintk(1, "Trying to return from previous errors.\n");
213 dst_pio_disable(state); 199 dst_pio_disable(state);
214 msleep(10); 200 msleep(10);
215 dst_pio_enable(state); 201 dst_pio_enable(state);
@@ -221,7 +207,7 @@ EXPORT_SYMBOL(dst_error_recovery);
221 207
222int dst_error_bailout(struct dst_state *state) 208int dst_error_bailout(struct dst_state *state)
223{ 209{
224 dprintk(verbose, DST_INFO, 1, "Trying to bailout from previous error."); 210 dprintk(2, "Trying to bailout from previous error.\n");
225 rdc_8820_reset(state); 211 rdc_8820_reset(state);
226 dst_pio_disable(state); 212 dst_pio_disable(state);
227 msleep(10); 213 msleep(10);
@@ -232,13 +218,13 @@ EXPORT_SYMBOL(dst_error_bailout);
232 218
233int dst_comm_init(struct dst_state *state) 219int dst_comm_init(struct dst_state *state)
234{ 220{
235 dprintk(verbose, DST_INFO, 1, "Initializing DST."); 221 dprintk(2, "Initializing DST.\n");
236 if ((dst_pio_enable(state)) < 0) { 222 if ((dst_pio_enable(state)) < 0) {
237 dprintk(verbose, DST_ERROR, 1, "PIO Enable Failed"); 223 pr_err("PIO Enable Failed\n");
238 return -1; 224 return -1;
239 } 225 }
240 if ((rdc_reset_state(state)) < 0) { 226 if ((rdc_reset_state(state)) < 0) {
241 dprintk(verbose, DST_ERROR, 1, "RDC 8820 State RESET Failed."); 227 pr_err("RDC 8820 State RESET Failed.\n");
242 return -1; 228 return -1;
243 } 229 }
244 if (state->type_flags & DST_TYPE_HAS_FW_1) 230 if (state->type_flags & DST_TYPE_HAS_FW_1)
@@ -260,23 +246,21 @@ int write_dst(struct dst_state *state, u8 *data, u8 len)
260 }; 246 };
261 247
262 int err; 248 int err;
263 u8 cnt, i; 249 u8 cnt;
264 250
265 dprintk(verbose, DST_NOTICE, 0, "writing [ "); 251 dprintk(1, "writing [ %*ph ]\n", len, data);
266 for (i = 0; i < len; i++)
267 dprintk(verbose, DST_NOTICE, 0, "%02x ", data[i]);
268 dprintk(verbose, DST_NOTICE, 0, "]\n");
269 252
270 for (cnt = 0; cnt < 2; cnt++) { 253 for (cnt = 0; cnt < 2; cnt++) {
271 if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) { 254 if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) {
272 dprintk(verbose, DST_INFO, 1, "_write_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)", err, len, data[0]); 255 dprintk(2, "_write_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n",
256 err, len, data[0]);
273 dst_error_recovery(state); 257 dst_error_recovery(state);
274 continue; 258 continue;
275 } else 259 } else
276 break; 260 break;
277 } 261 }
278 if (cnt >= 2) { 262 if (cnt >= 2) {
279 dprintk(verbose, DST_INFO, 1, "RDC 8820 RESET"); 263 dprintk(2, "RDC 8820 RESET\n");
280 dst_error_bailout(state); 264 dst_error_bailout(state);
281 265
282 return -1; 266 return -1;
@@ -300,23 +284,20 @@ int read_dst(struct dst_state *state, u8 *ret, u8 len)
300 284
301 for (cnt = 0; cnt < 2; cnt++) { 285 for (cnt = 0; cnt < 2; cnt++) {
302 if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) { 286 if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) {
303 dprintk(verbose, DST_INFO, 1, "read_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)", err, len, ret[0]); 287 dprintk(2, "read_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n",
288 err, len, ret[0]);
304 dst_error_recovery(state); 289 dst_error_recovery(state);
305 continue; 290 continue;
306 } else 291 } else
307 break; 292 break;
308 } 293 }
309 if (cnt >= 2) { 294 if (cnt >= 2) {
310 dprintk(verbose, DST_INFO, 1, "RDC 8820 RESET"); 295 dprintk(2, "RDC 8820 RESET\n");
311 dst_error_bailout(state); 296 dst_error_bailout(state);
312 297
313 return -1; 298 return -1;
314 } 299 }
315 dprintk(verbose, DST_DEBUG, 1, "reply is 0x%x", ret[0]); 300 dprintk(3, "reply is %*ph\n", len, ret);
316 for (err = 1; err < len; err++)
317 dprintk(verbose, DST_DEBUG, 0, " 0x%x", ret[err]);
318 if (err > 1)
319 dprintk(verbose, DST_DEBUG, 0, "\n");
320 301
321 return 0; 302 return 0;
322} 303}
@@ -326,11 +307,11 @@ static int dst_set_polarization(struct dst_state *state)
326{ 307{
327 switch (state->voltage) { 308 switch (state->voltage) {
328 case SEC_VOLTAGE_13: /* Vertical */ 309 case SEC_VOLTAGE_13: /* Vertical */
329 dprintk(verbose, DST_INFO, 1, "Polarization=[Vertical]"); 310 dprintk(2, "Polarization=[Vertical]\n");
330 state->tx_tuna[8] &= ~0x40; 311 state->tx_tuna[8] &= ~0x40;
331 break; 312 break;
332 case SEC_VOLTAGE_18: /* Horizontal */ 313 case SEC_VOLTAGE_18: /* Horizontal */
333 dprintk(verbose, DST_INFO, 1, "Polarization=[Horizontal]"); 314 dprintk(2, "Polarization=[Horizontal]\n");
334 state->tx_tuna[8] |= 0x40; 315 state->tx_tuna[8] |= 0x40;
335 break; 316 break;
336 case SEC_VOLTAGE_OFF: 317 case SEC_VOLTAGE_OFF:
@@ -343,7 +324,7 @@ static int dst_set_polarization(struct dst_state *state)
343static int dst_set_freq(struct dst_state *state, u32 freq) 324static int dst_set_freq(struct dst_state *state, u32 freq)
344{ 325{
345 state->frequency = freq; 326 state->frequency = freq;
346 dprintk(verbose, DST_INFO, 1, "set Frequency %u", freq); 327 dprintk(2, "set Frequency %u\n", freq);
347 328
348 if (state->dst_type == DST_TYPE_IS_SAT) { 329 if (state->dst_type == DST_TYPE_IS_SAT) {
349 freq = freq / 1000; 330 freq = freq / 1000;
@@ -463,7 +444,7 @@ static int dst_set_symbolrate(struct dst_state *state, u32 srate)
463 if (state->dst_type == DST_TYPE_IS_TERR) { 444 if (state->dst_type == DST_TYPE_IS_TERR) {
464 return -EOPNOTSUPP; 445 return -EOPNOTSUPP;
465 } 446 }
466 dprintk(verbose, DST_INFO, 1, "set symrate %u", srate); 447 dprintk(2, "set symrate %u\n", srate);
467 srate /= 1000; 448 srate /= 1000;
468 if (state->dst_type == DST_TYPE_IS_SAT) { 449 if (state->dst_type == DST_TYPE_IS_SAT) {
469 if (state->type_flags & DST_TYPE_HAS_SYMDIV) { 450 if (state->type_flags & DST_TYPE_HAS_SYMDIV) {
@@ -471,7 +452,7 @@ static int dst_set_symbolrate(struct dst_state *state, u32 srate)
471 sval <<= 20; 452 sval <<= 20;
472 do_div(sval, 88000); 453 do_div(sval, 88000);
473 symcalc = (u32) sval; 454 symcalc = (u32) sval;
474 dprintk(verbose, DST_INFO, 1, "set symcalc %u", symcalc); 455 dprintk(2, "set symcalc %u\n", symcalc);
475 state->tx_tuna[5] = (u8) (symcalc >> 12); 456 state->tx_tuna[5] = (u8) (symcalc >> 12);
476 state->tx_tuna[6] = (u8) (symcalc >> 4); 457 state->tx_tuna[6] = (u8) (symcalc >> 4);
477 state->tx_tuna[7] = (u8) (symcalc << 4); 458 state->tx_tuna[7] = (u8) (symcalc << 4);
@@ -486,7 +467,7 @@ static int dst_set_symbolrate(struct dst_state *state, u32 srate)
486 state->tx_tuna[8] |= 0x20; 467 state->tx_tuna[8] |= 0x20;
487 } 468 }
488 } else if (state->dst_type == DST_TYPE_IS_CABLE) { 469 } else if (state->dst_type == DST_TYPE_IS_CABLE) {
489 dprintk(verbose, DST_DEBUG, 1, "%s", state->fw_name); 470 dprintk(3, "%s\n", state->fw_name);
490 if (!strncmp(state->fw_name, "DCTNEW", 6)) { 471 if (!strncmp(state->fw_name, "DCTNEW", 6)) {
491 state->tx_tuna[5] = (u8) (srate >> 8); 472 state->tx_tuna[5] = (u8) (srate >> 8);
492 state->tx_tuna[6] = (u8) srate; 473 state->tx_tuna[6] = (u8) srate;
@@ -561,24 +542,24 @@ static void dst_type_flags_print(struct dst_state *state)
561{ 542{
562 u32 type_flags = state->type_flags; 543 u32 type_flags = state->type_flags;
563 544
564 dprintk(verbose, DST_ERROR, 0, "DST type flags :"); 545 pr_err("DST type flags :\n");
565 if (type_flags & DST_TYPE_HAS_TS188) 546 if (type_flags & DST_TYPE_HAS_TS188)
566 dprintk(verbose, DST_ERROR, 0, " 0x%x newtuner", DST_TYPE_HAS_TS188); 547 pr_err(" 0x%x newtuner\n", DST_TYPE_HAS_TS188);
567 if (type_flags & DST_TYPE_HAS_NEWTUNE_2) 548 if (type_flags & DST_TYPE_HAS_NEWTUNE_2)
568 dprintk(verbose, DST_ERROR, 0, " 0x%x newtuner 2", DST_TYPE_HAS_NEWTUNE_2); 549 pr_err(" 0x%x newtuner 2\n", DST_TYPE_HAS_NEWTUNE_2);
569 if (type_flags & DST_TYPE_HAS_TS204) 550 if (type_flags & DST_TYPE_HAS_TS204)
570 dprintk(verbose, DST_ERROR, 0, " 0x%x ts204", DST_TYPE_HAS_TS204); 551 pr_err(" 0x%x ts204\n", DST_TYPE_HAS_TS204);
571 if (type_flags & DST_TYPE_HAS_VLF) 552 if (type_flags & DST_TYPE_HAS_VLF)
572 dprintk(verbose, DST_ERROR, 0, " 0x%x VLF", DST_TYPE_HAS_VLF); 553 pr_err(" 0x%x VLF\n", DST_TYPE_HAS_VLF);
573 if (type_flags & DST_TYPE_HAS_SYMDIV) 554 if (type_flags & DST_TYPE_HAS_SYMDIV)
574 dprintk(verbose, DST_ERROR, 0, " 0x%x symdiv", DST_TYPE_HAS_SYMDIV); 555 pr_err(" 0x%x symdiv\n", DST_TYPE_HAS_SYMDIV);
575 if (type_flags & DST_TYPE_HAS_FW_1) 556 if (type_flags & DST_TYPE_HAS_FW_1)
576 dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 1", DST_TYPE_HAS_FW_1); 557 pr_err(" 0x%x firmware version = 1\n", DST_TYPE_HAS_FW_1);
577 if (type_flags & DST_TYPE_HAS_FW_2) 558 if (type_flags & DST_TYPE_HAS_FW_2)
578 dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 2", DST_TYPE_HAS_FW_2); 559 pr_err(" 0x%x firmware version = 2\n", DST_TYPE_HAS_FW_2);
579 if (type_flags & DST_TYPE_HAS_FW_3) 560 if (type_flags & DST_TYPE_HAS_FW_3)
580 dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 3", DST_TYPE_HAS_FW_3); 561 pr_err(" 0x%x firmware version = 3\n", DST_TYPE_HAS_FW_3);
581 dprintk(verbose, DST_ERROR, 0, "\n"); 562 pr_err("\n");
582} 563}
583 564
584 565
@@ -603,10 +584,10 @@ static int dst_type_print(struct dst_state *state, u8 type)
603 break; 584 break;
604 585
605 default: 586 default:
606 dprintk(verbose, DST_INFO, 1, "invalid dst type %d", type); 587 dprintk(2, "invalid dst type %d\n", type);
607 return -EINVAL; 588 return -EINVAL;
608 } 589 }
609 dprintk(verbose, DST_INFO, 1, "DST type: %s", otype); 590 dprintk(2, "DST type: %s\n", otype);
610 591
611 return 0; 592 return 0;
612} 593}
@@ -914,12 +895,12 @@ static int dst_get_mac(struct dst_state *state)
914 u8 get_mac[] = { 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 895 u8 get_mac[] = { 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
915 get_mac[7] = dst_check_sum(get_mac, 7); 896 get_mac[7] = dst_check_sum(get_mac, 7);
916 if (dst_command(state, get_mac, 8) < 0) { 897 if (dst_command(state, get_mac, 8) < 0) {
917 dprintk(verbose, DST_INFO, 1, "Unsupported Command"); 898 dprintk(2, "Unsupported Command\n");
918 return -1; 899 return -1;
919 } 900 }
920 memset(&state->mac_address, '\0', 8); 901 memset(&state->mac_address, '\0', 8);
921 memcpy(&state->mac_address, &state->rxbuffer, 6); 902 memcpy(&state->mac_address, &state->rxbuffer, 6);
922 dprintk(verbose, DST_ERROR, 1, "MAC Address=[%pM]", state->mac_address); 903 pr_err("MAC Address=[%pM]\n", state->mac_address);
923 904
924 return 0; 905 return 0;
925} 906}
@@ -929,11 +910,11 @@ static int dst_fw_ver(struct dst_state *state)
929 u8 get_ver[] = { 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 910 u8 get_ver[] = { 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
930 get_ver[7] = dst_check_sum(get_ver, 7); 911 get_ver[7] = dst_check_sum(get_ver, 7);
931 if (dst_command(state, get_ver, 8) < 0) { 912 if (dst_command(state, get_ver, 8) < 0) {
932 dprintk(verbose, DST_INFO, 1, "Unsupported Command"); 913 dprintk(2, "Unsupported Command\n");
933 return -1; 914 return -1;
934 } 915 }
935 memcpy(&state->fw_version, &state->rxbuffer, 8); 916 memcpy(&state->fw_version, &state->rxbuffer, 8);
936 dprintk(verbose, DST_ERROR, 1, "Firmware Ver = %x.%x Build = %02x, on %x:%x, %x-%x-20%02x", 917 pr_err("Firmware Ver = %x.%x Build = %02x, on %x:%x, %x-%x-20%02x\n",
937 state->fw_version[0] >> 4, state->fw_version[0] & 0x0f, 918 state->fw_version[0] >> 4, state->fw_version[0] & 0x0f,
938 state->fw_version[1], 919 state->fw_version[1],
939 state->fw_version[5], state->fw_version[6], 920 state->fw_version[5], state->fw_version[6],
@@ -950,17 +931,17 @@ static int dst_card_type(struct dst_state *state)
950 u8 get_type[] = { 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 931 u8 get_type[] = { 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
951 get_type[7] = dst_check_sum(get_type, 7); 932 get_type[7] = dst_check_sum(get_type, 7);
952 if (dst_command(state, get_type, 8) < 0) { 933 if (dst_command(state, get_type, 8) < 0) {
953 dprintk(verbose, DST_INFO, 1, "Unsupported Command"); 934 dprintk(2, "Unsupported Command\n");
954 return -1; 935 return -1;
955 } 936 }
956 memset(&state->card_info, '\0', 8); 937 memset(&state->card_info, '\0', 8);
957 memcpy(&state->card_info, &state->rxbuffer, 7); 938 memcpy(&state->card_info, &state->rxbuffer, 7);
958 dprintk(verbose, DST_ERROR, 1, "Device Model=[%s]", &state->card_info[0]); 939 pr_err("Device Model=[%s]\n", &state->card_info[0]);
959 940
960 for (j = 0, p_tuner_list = tuner_list; j < ARRAY_SIZE(tuner_list); j++, p_tuner_list++) { 941 for (j = 0, p_tuner_list = tuner_list; j < ARRAY_SIZE(tuner_list); j++, p_tuner_list++) {
961 if (!strcmp(&state->card_info[0], p_tuner_list->board_name)) { 942 if (!strcmp(&state->card_info[0], p_tuner_list->board_name)) {
962 state->tuner_type = p_tuner_list->tuner_type; 943 state->tuner_type = p_tuner_list->tuner_type;
963 dprintk(verbose, DST_ERROR, 1, "DST has [%s] tuner, tuner type=[%d]", 944 pr_err("DST has [%s] tuner, tuner type=[%d]\n",
964 p_tuner_list->tuner_name, p_tuner_list->tuner_type); 945 p_tuner_list->tuner_name, p_tuner_list->tuner_type);
965 } 946 }
966 } 947 }
@@ -973,26 +954,19 @@ static int dst_get_vendor(struct dst_state *state)
973 u8 get_vendor[] = { 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 954 u8 get_vendor[] = { 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
974 get_vendor[7] = dst_check_sum(get_vendor, 7); 955 get_vendor[7] = dst_check_sum(get_vendor, 7);
975 if (dst_command(state, get_vendor, 8) < 0) { 956 if (dst_command(state, get_vendor, 8) < 0) {
976 dprintk(verbose, DST_INFO, 1, "Unsupported Command"); 957 dprintk(2, "Unsupported Command\n");
977 return -1; 958 return -1;
978 } 959 }
979 memset(&state->vendor, '\0', 8); 960 memset(&state->vendor, '\0', 8);
980 memcpy(&state->vendor, &state->rxbuffer, 7); 961 memcpy(&state->vendor, &state->rxbuffer, 7);
981 dprintk(verbose, DST_ERROR, 1, "Vendor=[%s]", &state->vendor[0]); 962 pr_err("Vendor=[%s]\n", &state->vendor[0]);
982 963
983 return 0; 964 return 0;
984} 965}
985 966
986static void debug_dst_buffer(struct dst_state *state) 967static void debug_dst_buffer(struct dst_state *state)
987{ 968{
988 int i; 969 dprintk(3, "%s: [ %*ph ]\n", __func__, 8, state->rxbuffer);
989
990 if (verbose > 2) {
991 printk("%s: [", __func__);
992 for (i = 0; i < 8; i++)
993 printk(" %02x", state->rxbuffer[i]);
994 printk("]\n");
995 }
996} 970}
997 971
998static int dst_check_stv0299(struct dst_state *state) 972static int dst_check_stv0299(struct dst_state *state)
@@ -1001,13 +975,13 @@ static int dst_check_stv0299(struct dst_state *state)
1001 975
1002 check_stv0299[7] = dst_check_sum(check_stv0299, 7); 976 check_stv0299[7] = dst_check_sum(check_stv0299, 7);
1003 if (dst_command(state, check_stv0299, 8) < 0) { 977 if (dst_command(state, check_stv0299, 8) < 0) {
1004 dprintk(verbose, DST_ERROR, 1, "Cmd=[0x04] failed"); 978 pr_err("Cmd=[0x04] failed\n");
1005 return -1; 979 return -1;
1006 } 980 }
1007 debug_dst_buffer(state); 981 debug_dst_buffer(state);
1008 982
1009 if (memcmp(&check_stv0299, &state->rxbuffer, 8)) { 983 if (memcmp(&check_stv0299, &state->rxbuffer, 8)) {
1010 dprintk(verbose, DST_ERROR, 1, "Found a STV0299 NIM"); 984 pr_err("Found a STV0299 NIM\n");
1011 state->tuner_type = TUNER_TYPE_STV0299; 985 state->tuner_type = TUNER_TYPE_STV0299;
1012 return 0; 986 return 0;
1013 } 987 }
@@ -1021,13 +995,13 @@ static int dst_check_mb86a15(struct dst_state *state)
1021 995
1022 check_mb86a15[7] = dst_check_sum(check_mb86a15, 7); 996 check_mb86a15[7] = dst_check_sum(check_mb86a15, 7);
1023 if (dst_command(state, check_mb86a15, 8) < 0) { 997 if (dst_command(state, check_mb86a15, 8) < 0) {
1024 dprintk(verbose, DST_ERROR, 1, "Cmd=[0x10], failed"); 998 pr_err("Cmd=[0x10], failed\n");
1025 return -1; 999 return -1;
1026 } 1000 }
1027 debug_dst_buffer(state); 1001 debug_dst_buffer(state);
1028 1002
1029 if (memcmp(&check_mb86a15, &state->rxbuffer, 8) < 0) { 1003 if (memcmp(&check_mb86a15, &state->rxbuffer, 8) < 0) {
1030 dprintk(verbose, DST_ERROR, 1, "Found a MB86A15 NIM"); 1004 pr_err("Found a MB86A15 NIM\n");
1031 state->tuner_type = TUNER_TYPE_MB86A15; 1005 state->tuner_type = TUNER_TYPE_MB86A15;
1032 return 0; 1006 return 0;
1033 } 1007 }
@@ -1042,21 +1016,21 @@ static int dst_get_tuner_info(struct dst_state *state)
1042 1016
1043 get_tuner_1[7] = dst_check_sum(get_tuner_1, 7); 1017 get_tuner_1[7] = dst_check_sum(get_tuner_1, 7);
1044 get_tuner_2[7] = dst_check_sum(get_tuner_2, 7); 1018 get_tuner_2[7] = dst_check_sum(get_tuner_2, 7);
1045 dprintk(verbose, DST_ERROR, 1, "DST TYpe = MULTI FE"); 1019 pr_err("DST TYpe = MULTI FE\n");
1046 if (state->type_flags & DST_TYPE_HAS_MULTI_FE) { 1020 if (state->type_flags & DST_TYPE_HAS_MULTI_FE) {
1047 if (dst_command(state, get_tuner_1, 8) < 0) { 1021 if (dst_command(state, get_tuner_1, 8) < 0) {
1048 dprintk(verbose, DST_INFO, 1, "Cmd=[0x13], Unsupported"); 1022 dprintk(2, "Cmd=[0x13], Unsupported\n");
1049 goto force; 1023 goto force;
1050 } 1024 }
1051 } else { 1025 } else {
1052 if (dst_command(state, get_tuner_2, 8) < 0) { 1026 if (dst_command(state, get_tuner_2, 8) < 0) {
1053 dprintk(verbose, DST_INFO, 1, "Cmd=[0xb], Unsupported"); 1027 dprintk(2, "Cmd=[0xb], Unsupported\n");
1054 goto force; 1028 goto force;
1055 } 1029 }
1056 } 1030 }
1057 memcpy(&state->board_info, &state->rxbuffer, 8); 1031 memcpy(&state->board_info, &state->rxbuffer, 8);
1058 if (state->type_flags & DST_TYPE_HAS_MULTI_FE) { 1032 if (state->type_flags & DST_TYPE_HAS_MULTI_FE) {
1059 dprintk(verbose, DST_ERROR, 1, "DST type has TS=188"); 1033 pr_err("DST type has TS=188\n");
1060 } 1034 }
1061 if (state->board_info[0] == 0xbc) { 1035 if (state->board_info[0] == 0xbc) {
1062 if (state->dst_type != DST_TYPE_IS_ATSC) 1036 if (state->dst_type != DST_TYPE_IS_ATSC)
@@ -1066,7 +1040,7 @@ static int dst_get_tuner_info(struct dst_state *state)
1066 1040
1067 if (state->board_info[1] == 0x01) { 1041 if (state->board_info[1] == 0x01) {
1068 state->dst_hw_cap |= DST_TYPE_HAS_DBOARD; 1042 state->dst_hw_cap |= DST_TYPE_HAS_DBOARD;
1069 dprintk(verbose, DST_ERROR, 1, "DST has Daughterboard"); 1043 pr_err("DST has Daughterboard\n");
1070 } 1044 }
1071 } 1045 }
1072 1046
@@ -1074,7 +1048,7 @@ static int dst_get_tuner_info(struct dst_state *state)
1074force: 1048force:
1075 if (!strncmp(state->fw_name, "DCT-CI", 6)) { 1049 if (!strncmp(state->fw_name, "DCT-CI", 6)) {
1076 state->type_flags |= DST_TYPE_HAS_TS204; 1050 state->type_flags |= DST_TYPE_HAS_TS204;
1077 dprintk(verbose, DST_ERROR, 1, "Forcing [%s] to TS188", state->fw_name); 1051 pr_err("Forcing [%s] to TS188\n", state->fw_name);
1078 } 1052 }
1079 1053
1080 return -1; 1054 return -1;
@@ -1103,7 +1077,7 @@ static int dst_get_device_id(struct dst_state *state)
1103 if (read_dst(state, &reply, GET_ACK)) 1077 if (read_dst(state, &reply, GET_ACK))
1104 return -1; /* Read failure */ 1078 return -1; /* Read failure */
1105 if (reply != ACK) { 1079 if (reply != ACK) {
1106 dprintk(verbose, DST_INFO, 1, "Write not Acknowledged! [Reply=0x%02x]", reply); 1080 dprintk(2, "Write not Acknowledged! [Reply=0x%02x]\n", reply);
1107 return -1; /* Unack'd write */ 1081 return -1; /* Unack'd write */
1108 } 1082 }
1109 if (!dst_wait_dst_ready(state, DEVICE_INIT)) 1083 if (!dst_wait_dst_ready(state, DEVICE_INIT))
@@ -1113,7 +1087,7 @@ static int dst_get_device_id(struct dst_state *state)
1113 1087
1114 dst_pio_disable(state); 1088 dst_pio_disable(state);
1115 if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { 1089 if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) {
1116 dprintk(verbose, DST_INFO, 1, "Checksum failure!"); 1090 dprintk(2, "Checksum failure!\n");
1117 return -1; /* Checksum failure */ 1091 return -1; /* Checksum failure */
1118 } 1092 }
1119 state->rxbuffer[7] = '\0'; 1093 state->rxbuffer[7] = '\0';
@@ -1125,7 +1099,7 @@ static int dst_get_device_id(struct dst_state *state)
1125 1099
1126 /* Card capabilities */ 1100 /* Card capabilities */
1127 state->dst_hw_cap = p_dst_type->dst_feature; 1101 state->dst_hw_cap = p_dst_type->dst_feature;
1128 dprintk(verbose, DST_ERROR, 1, "Recognise [%s]", p_dst_type->device_id); 1102 pr_err("Recognise [%s]\n", p_dst_type->device_id);
1129 strncpy(&state->fw_name[0], p_dst_type->device_id, 6); 1103 strncpy(&state->fw_name[0], p_dst_type->device_id, 6);
1130 /* Multiple tuners */ 1104 /* Multiple tuners */
1131 if (p_dst_type->tuner_type & TUNER_TYPE_MULTI) { 1105 if (p_dst_type->tuner_type & TUNER_TYPE_MULTI) {
@@ -1133,7 +1107,7 @@ static int dst_get_device_id(struct dst_state *state)
1133 case DST_TYPE_IS_SAT: 1107 case DST_TYPE_IS_SAT:
1134 /* STV0299 check */ 1108 /* STV0299 check */
1135 if (dst_check_stv0299(state) < 0) { 1109 if (dst_check_stv0299(state) < 0) {
1136 dprintk(verbose, DST_ERROR, 1, "Unsupported"); 1110 pr_err("Unsupported\n");
1137 state->tuner_type = TUNER_TYPE_MB86A15; 1111 state->tuner_type = TUNER_TYPE_MB86A15;
1138 } 1112 }
1139 break; 1113 break;
@@ -1141,7 +1115,7 @@ static int dst_get_device_id(struct dst_state *state)
1141 break; 1115 break;
1142 } 1116 }
1143 if (dst_check_mb86a15(state) < 0) 1117 if (dst_check_mb86a15(state) < 0)
1144 dprintk(verbose, DST_ERROR, 1, "Unsupported"); 1118 pr_err("Unsupported\n");
1145 /* Single tuner */ 1119 /* Single tuner */
1146 } else { 1120 } else {
1147 state->tuner_type = p_dst_type->tuner_type; 1121 state->tuner_type = p_dst_type->tuner_type;
@@ -1149,7 +1123,7 @@ static int dst_get_device_id(struct dst_state *state)
1149 for (j = 0, p_tuner_list = tuner_list; j < ARRAY_SIZE(tuner_list); j++, p_tuner_list++) { 1123 for (j = 0, p_tuner_list = tuner_list; j < ARRAY_SIZE(tuner_list); j++, p_tuner_list++) {
1150 if (!(strncmp(p_dst_type->device_id, p_tuner_list->fw_name, 7)) && 1124 if (!(strncmp(p_dst_type->device_id, p_tuner_list->fw_name, 7)) &&
1151 p_tuner_list->tuner_type == state->tuner_type) { 1125 p_tuner_list->tuner_type == state->tuner_type) {
1152 dprintk(verbose, DST_ERROR, 1, "[%s] has a [%s]", 1126 pr_err("[%s] has a [%s]\n",
1153 p_dst_type->device_id, p_tuner_list->tuner_name); 1127 p_dst_type->device_id, p_tuner_list->tuner_name);
1154 } 1128 }
1155 } 1129 }
@@ -1158,8 +1132,8 @@ static int dst_get_device_id(struct dst_state *state)
1158 } 1132 }
1159 1133
1160 if (i >= ARRAY_SIZE(dst_tlist)) { 1134 if (i >= ARRAY_SIZE(dst_tlist)) {
1161 dprintk(verbose, DST_ERROR, 1, "Unable to recognize %s or %s", &state->rxbuffer[0], &state->rxbuffer[1]); 1135 pr_err("Unable to recognize %s or %s\n", &state->rxbuffer[0], &state->rxbuffer[1]);
1162 dprintk(verbose, DST_ERROR, 1, "please email linux-dvb@linuxtv.org with this type in"); 1136 pr_err("please email linux-dvb@linuxtv.org with this type in");
1163 use_dst_type = DST_TYPE_IS_SAT; 1137 use_dst_type = DST_TYPE_IS_SAT;
1164 use_type_flags = DST_TYPE_HAS_SYMDIV; 1138 use_type_flags = DST_TYPE_HAS_SYMDIV;
1165 } 1139 }
@@ -1176,7 +1150,7 @@ static int dst_probe(struct dst_state *state)
1176 mutex_init(&state->dst_mutex); 1150 mutex_init(&state->dst_mutex);
1177 if (dst_addons & DST_TYPE_HAS_CA) { 1151 if (dst_addons & DST_TYPE_HAS_CA) {
1178 if ((rdc_8820_reset(state)) < 0) { 1152 if ((rdc_8820_reset(state)) < 0) {
1179 dprintk(verbose, DST_ERROR, 1, "RDC 8820 RESET Failed."); 1153 pr_err("RDC 8820 RESET Failed.\n");
1180 return -1; 1154 return -1;
1181 } 1155 }
1182 msleep(4000); 1156 msleep(4000);
@@ -1184,35 +1158,35 @@ static int dst_probe(struct dst_state *state)
1184 msleep(100); 1158 msleep(100);
1185 } 1159 }
1186 if ((dst_comm_init(state)) < 0) { 1160 if ((dst_comm_init(state)) < 0) {
1187 dprintk(verbose, DST_ERROR, 1, "DST Initialization Failed."); 1161 pr_err("DST Initialization Failed.\n");
1188 return -1; 1162 return -1;
1189 } 1163 }
1190 msleep(100); 1164 msleep(100);
1191 if (dst_get_device_id(state) < 0) { 1165 if (dst_get_device_id(state) < 0) {
1192 dprintk(verbose, DST_ERROR, 1, "unknown device."); 1166 pr_err("unknown device.\n");
1193 return -1; 1167 return -1;
1194 } 1168 }
1195 if (dst_get_mac(state) < 0) { 1169 if (dst_get_mac(state) < 0) {
1196 dprintk(verbose, DST_INFO, 1, "MAC: Unsupported command"); 1170 dprintk(2, "MAC: Unsupported command\n");
1197 } 1171 }
1198 if ((state->type_flags & DST_TYPE_HAS_MULTI_FE) || (state->type_flags & DST_TYPE_HAS_FW_BUILD)) { 1172 if ((state->type_flags & DST_TYPE_HAS_MULTI_FE) || (state->type_flags & DST_TYPE_HAS_FW_BUILD)) {
1199 if (dst_get_tuner_info(state) < 0) 1173 if (dst_get_tuner_info(state) < 0)
1200 dprintk(verbose, DST_INFO, 1, "Tuner: Unsupported command"); 1174 dprintk(2, "Tuner: Unsupported command\n");
1201 } 1175 }
1202 if (state->type_flags & DST_TYPE_HAS_TS204) { 1176 if (state->type_flags & DST_TYPE_HAS_TS204) {
1203 dst_packsize(state, 204); 1177 dst_packsize(state, 204);
1204 } 1178 }
1205 if (state->type_flags & DST_TYPE_HAS_FW_BUILD) { 1179 if (state->type_flags & DST_TYPE_HAS_FW_BUILD) {
1206 if (dst_fw_ver(state) < 0) { 1180 if (dst_fw_ver(state) < 0) {
1207 dprintk(verbose, DST_INFO, 1, "FW: Unsupported command"); 1181 dprintk(2, "FW: Unsupported command\n");
1208 return 0; 1182 return 0;
1209 } 1183 }
1210 if (dst_card_type(state) < 0) { 1184 if (dst_card_type(state) < 0) {
1211 dprintk(verbose, DST_INFO, 1, "Card: Unsupported command"); 1185 dprintk(2, "Card: Unsupported command\n");
1212 return 0; 1186 return 0;
1213 } 1187 }
1214 if (dst_get_vendor(state) < 0) { 1188 if (dst_get_vendor(state) < 0) {
1215 dprintk(verbose, DST_INFO, 1, "Vendor: Unsupported command"); 1189 dprintk(2, "Vendor: Unsupported command\n");
1216 return 0; 1190 return 0;
1217 } 1191 }
1218 } 1192 }
@@ -1226,33 +1200,33 @@ static int dst_command(struct dst_state *state, u8 *data, u8 len)
1226 1200
1227 mutex_lock(&state->dst_mutex); 1201 mutex_lock(&state->dst_mutex);
1228 if ((dst_comm_init(state)) < 0) { 1202 if ((dst_comm_init(state)) < 0) {
1229 dprintk(verbose, DST_NOTICE, 1, "DST Communication Initialization Failed."); 1203 dprintk(1, "DST Communication Initialization Failed.\n");
1230 goto error; 1204 goto error;
1231 } 1205 }
1232 if (write_dst(state, data, len)) { 1206 if (write_dst(state, data, len)) {
1233 dprintk(verbose, DST_INFO, 1, "Trying to recover.. "); 1207 dprintk(2, "Trying to recover..\n");
1234 if ((dst_error_recovery(state)) < 0) { 1208 if ((dst_error_recovery(state)) < 0) {
1235 dprintk(verbose, DST_ERROR, 1, "Recovery Failed."); 1209 pr_err("Recovery Failed.\n");
1236 goto error; 1210 goto error;
1237 } 1211 }
1238 goto error; 1212 goto error;
1239 } 1213 }
1240 if ((dst_pio_disable(state)) < 0) { 1214 if ((dst_pio_disable(state)) < 0) {
1241 dprintk(verbose, DST_ERROR, 1, "PIO Disable Failed."); 1215 pr_err("PIO Disable Failed.\n");
1242 goto error; 1216 goto error;
1243 } 1217 }
1244 if (state->type_flags & DST_TYPE_HAS_FW_1) 1218 if (state->type_flags & DST_TYPE_HAS_FW_1)
1245 mdelay(3); 1219 mdelay(3);
1246 if (read_dst(state, &reply, GET_ACK)) { 1220 if (read_dst(state, &reply, GET_ACK)) {
1247 dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. "); 1221 dprintk(3, "Trying to recover..\n");
1248 if ((dst_error_recovery(state)) < 0) { 1222 if ((dst_error_recovery(state)) < 0) {
1249 dprintk(verbose, DST_INFO, 1, "Recovery Failed."); 1223 dprintk(2, "Recovery Failed.\n");
1250 goto error; 1224 goto error;
1251 } 1225 }
1252 goto error; 1226 goto error;
1253 } 1227 }
1254 if (reply != ACK) { 1228 if (reply != ACK) {
1255 dprintk(verbose, DST_INFO, 1, "write not acknowledged 0x%02x ", reply); 1229 dprintk(2, "write not acknowledged 0x%02x\n", reply);
1256 goto error; 1230 goto error;
1257 } 1231 }
1258 if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3)) 1232 if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3))
@@ -1264,15 +1238,15 @@ static int dst_command(struct dst_state *state, u8 *data, u8 len)
1264 if (!dst_wait_dst_ready(state, NO_DELAY)) 1238 if (!dst_wait_dst_ready(state, NO_DELAY))
1265 goto error; 1239 goto error;
1266 if (read_dst(state, state->rxbuffer, FIXED_COMM)) { 1240 if (read_dst(state, state->rxbuffer, FIXED_COMM)) {
1267 dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. "); 1241 dprintk(3, "Trying to recover..\n");
1268 if ((dst_error_recovery(state)) < 0) { 1242 if ((dst_error_recovery(state)) < 0) {
1269 dprintk(verbose, DST_INFO, 1, "Recovery failed."); 1243 dprintk(2, "Recovery failed.\n");
1270 goto error; 1244 goto error;
1271 } 1245 }
1272 goto error; 1246 goto error;
1273 } 1247 }
1274 if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { 1248 if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) {
1275 dprintk(verbose, DST_INFO, 1, "checksum failure"); 1249 dprintk(2, "checksum failure\n");
1276 goto error; 1250 goto error;
1277 } 1251 }
1278 mutex_unlock(&state->dst_mutex); 1252 mutex_unlock(&state->dst_mutex);
@@ -1348,19 +1322,19 @@ static int dst_get_tuna(struct dst_state *state)
1348 else 1322 else
1349 retval = read_dst(state, &state->rx_tuna[2], FIXED_COMM); 1323 retval = read_dst(state, &state->rx_tuna[2], FIXED_COMM);
1350 if (retval < 0) { 1324 if (retval < 0) {
1351 dprintk(verbose, DST_DEBUG, 1, "read not successful"); 1325 dprintk(3, "read not successful\n");
1352 return retval; 1326 return retval;
1353 } 1327 }
1354 if ((state->type_flags & DST_TYPE_HAS_VLF) && 1328 if ((state->type_flags & DST_TYPE_HAS_VLF) &&
1355 !(state->dst_type == DST_TYPE_IS_ATSC)) { 1329 !(state->dst_type == DST_TYPE_IS_ATSC)) {
1356 1330
1357 if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) { 1331 if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) {
1358 dprintk(verbose, DST_INFO, 1, "checksum failure ? "); 1332 dprintk(2, "checksum failure ?\n");
1359 return -EIO; 1333 return -EIO;
1360 } 1334 }
1361 } else { 1335 } else {
1362 if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[2], 7)) { 1336 if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[2], 7)) {
1363 dprintk(verbose, DST_INFO, 1, "checksum failure? "); 1337 dprintk(2, "checksum failure?\n");
1364 return -EIO; 1338 return -EIO;
1365 } 1339 }
1366 } 1340 }
@@ -1387,7 +1361,7 @@ static int dst_write_tuna(struct dvb_frontend *fe)
1387 int retval; 1361 int retval;
1388 u8 reply; 1362 u8 reply;
1389 1363
1390 dprintk(verbose, DST_INFO, 1, "type_flags 0x%x ", state->type_flags); 1364 dprintk(2, "type_flags 0x%x\n", state->type_flags);
1391 state->decode_freq = 0; 1365 state->decode_freq = 0;
1392 state->decode_lock = state->decode_strength = state->decode_snr = 0; 1366 state->decode_lock = state->decode_strength = state->decode_snr = 0;
1393 if (state->dst_type == DST_TYPE_IS_SAT) { 1367 if (state->dst_type == DST_TYPE_IS_SAT) {
@@ -1397,7 +1371,7 @@ static int dst_write_tuna(struct dvb_frontend *fe)
1397 state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE); 1371 state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE);
1398 mutex_lock(&state->dst_mutex); 1372 mutex_lock(&state->dst_mutex);
1399 if ((dst_comm_init(state)) < 0) { 1373 if ((dst_comm_init(state)) < 0) {
1400 dprintk(verbose, DST_DEBUG, 1, "DST Communication initialization failed."); 1374 dprintk(3, "DST Communication initialization failed.\n");
1401 goto error; 1375 goto error;
1402 } 1376 }
1403// if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { 1377// if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
@@ -1412,19 +1386,19 @@ static int dst_write_tuna(struct dvb_frontend *fe)
1412 } 1386 }
1413 if (retval < 0) { 1387 if (retval < 0) {
1414 dst_pio_disable(state); 1388 dst_pio_disable(state);
1415 dprintk(verbose, DST_DEBUG, 1, "write not successful"); 1389 dprintk(3, "write not successful\n");
1416 goto werr; 1390 goto werr;
1417 } 1391 }
1418 if ((dst_pio_disable(state)) < 0) { 1392 if ((dst_pio_disable(state)) < 0) {
1419 dprintk(verbose, DST_DEBUG, 1, "DST PIO disable failed !"); 1393 dprintk(3, "DST PIO disable failed !\n");
1420 goto error; 1394 goto error;
1421 } 1395 }
1422 if ((read_dst(state, &reply, GET_ACK) < 0)) { 1396 if ((read_dst(state, &reply, GET_ACK) < 0)) {
1423 dprintk(verbose, DST_DEBUG, 1, "read verify not successful."); 1397 dprintk(3, "read verify not successful.\n");
1424 goto error; 1398 goto error;
1425 } 1399 }
1426 if (reply != ACK) { 1400 if (reply != ACK) {
1427 dprintk(verbose, DST_DEBUG, 1, "write not acknowledged 0x%02x ", reply); 1401 dprintk(3, "write not acknowledged 0x%02x\n", reply);
1428 goto error; 1402 goto error;
1429 } 1403 }
1430 state->diseq_flags |= ATTEMPT_TUNE; 1404 state->diseq_flags |= ATTEMPT_TUNE;
@@ -1622,7 +1596,7 @@ static int dst_set_frontend(struct dvb_frontend *fe)
1622 retval = dst_set_freq(state, p->frequency); 1596 retval = dst_set_freq(state, p->frequency);
1623 if(retval != 0) 1597 if(retval != 0)
1624 return retval; 1598 return retval;
1625 dprintk(verbose, DST_DEBUG, 1, "Set Frequency=[%d]", p->frequency); 1599 dprintk(3, "Set Frequency=[%d]\n", p->frequency);
1626 1600
1627 if (state->dst_type == DST_TYPE_IS_SAT) { 1601 if (state->dst_type == DST_TYPE_IS_SAT) {
1628 if (state->type_flags & DST_TYPE_HAS_OBS_REGS) 1602 if (state->type_flags & DST_TYPE_HAS_OBS_REGS)
@@ -1630,7 +1604,7 @@ static int dst_set_frontend(struct dvb_frontend *fe)
1630 dst_set_fec(state, p->fec_inner); 1604 dst_set_fec(state, p->fec_inner);
1631 dst_set_symbolrate(state, p->symbol_rate); 1605 dst_set_symbolrate(state, p->symbol_rate);
1632 dst_set_polarization(state); 1606 dst_set_polarization(state);
1633 dprintk(verbose, DST_DEBUG, 1, "Set Symbolrate=[%d]", p->symbol_rate); 1607 dprintk(3, "Set Symbolrate=[%d]\n", p->symbol_rate);
1634 1608
1635 } else if (state->dst_type == DST_TYPE_IS_TERR) 1609 } else if (state->dst_type == DST_TYPE_IS_TERR)
1636 dst_set_bandwidth(state, p->bandwidth_hz); 1610 dst_set_bandwidth(state, p->bandwidth_hz);
@@ -1656,7 +1630,7 @@ static int dst_tune_frontend(struct dvb_frontend* fe,
1656 1630
1657 if (re_tune) { 1631 if (re_tune) {
1658 dst_set_freq(state, p->frequency); 1632 dst_set_freq(state, p->frequency);
1659 dprintk(verbose, DST_DEBUG, 1, "Set Frequency=[%d]", p->frequency); 1633 dprintk(3, "Set Frequency=[%d]\n", p->frequency);
1660 1634
1661 if (state->dst_type == DST_TYPE_IS_SAT) { 1635 if (state->dst_type == DST_TYPE_IS_SAT) {
1662 if (state->type_flags & DST_TYPE_HAS_OBS_REGS) 1636 if (state->type_flags & DST_TYPE_HAS_OBS_REGS)
@@ -1664,7 +1638,7 @@ static int dst_tune_frontend(struct dvb_frontend* fe,
1664 dst_set_fec(state, p->fec_inner); 1638 dst_set_fec(state, p->fec_inner);
1665 dst_set_symbolrate(state, p->symbol_rate); 1639 dst_set_symbolrate(state, p->symbol_rate);
1666 dst_set_polarization(state); 1640 dst_set_polarization(state);
1667 dprintk(verbose, DST_DEBUG, 1, "Set Symbolrate=[%d]", p->symbol_rate); 1641 dprintk(3, "Set Symbolrate=[%d]\n", p->symbol_rate);
1668 1642
1669 } else if (state->dst_type == DST_TYPE_IS_TERR) 1643 } else if (state->dst_type == DST_TYPE_IS_TERR)
1670 dst_set_bandwidth(state, p->bandwidth_hz); 1644 dst_set_bandwidth(state, p->bandwidth_hz);
@@ -1722,10 +1696,10 @@ static void bt8xx_dst_release(struct dvb_frontend *fe)
1722 kfree(state); 1696 kfree(state);
1723} 1697}
1724 1698
1725static struct dvb_frontend_ops dst_dvbt_ops; 1699static const struct dvb_frontend_ops dst_dvbt_ops;
1726static struct dvb_frontend_ops dst_dvbs_ops; 1700static const struct dvb_frontend_ops dst_dvbs_ops;
1727static struct dvb_frontend_ops dst_dvbc_ops; 1701static const struct dvb_frontend_ops dst_dvbc_ops;
1728static struct dvb_frontend_ops dst_atsc_ops; 1702static const struct dvb_frontend_ops dst_atsc_ops;
1729 1703
1730struct dst_state *dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter) 1704struct dst_state *dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter)
1731{ 1705{
@@ -1750,7 +1724,7 @@ struct dst_state *dst_attach(struct dst_state *state, struct dvb_adapter *dvb_ad
1750 memcpy(&state->frontend.ops, &dst_atsc_ops, sizeof(struct dvb_frontend_ops)); 1724 memcpy(&state->frontend.ops, &dst_atsc_ops, sizeof(struct dvb_frontend_ops));
1751 break; 1725 break;
1752 default: 1726 default:
1753 dprintk(verbose, DST_ERROR, 1, "unknown DST type. please report to the LinuxTV.org DVB mailinglist."); 1727 pr_err("unknown DST type. please report to the LinuxTV.org DVB mailinglist.\n");
1754 kfree(state); 1728 kfree(state);
1755 return NULL; 1729 return NULL;
1756 } 1730 }
@@ -1761,7 +1735,7 @@ struct dst_state *dst_attach(struct dst_state *state, struct dvb_adapter *dvb_ad
1761 1735
1762EXPORT_SYMBOL(dst_attach); 1736EXPORT_SYMBOL(dst_attach);
1763 1737
1764static struct dvb_frontend_ops dst_dvbt_ops = { 1738static const struct dvb_frontend_ops dst_dvbt_ops = {
1765 .delsys = { SYS_DVBT }, 1739 .delsys = { SYS_DVBT },
1766 .info = { 1740 .info = {
1767 .name = "DST DVB-T", 1741 .name = "DST DVB-T",
@@ -1790,7 +1764,7 @@ static struct dvb_frontend_ops dst_dvbt_ops = {
1790 .read_snr = dst_read_snr, 1764 .read_snr = dst_read_snr,
1791}; 1765};
1792 1766
1793static struct dvb_frontend_ops dst_dvbs_ops = { 1767static const struct dvb_frontend_ops dst_dvbs_ops = {
1794 .delsys = { SYS_DVBS }, 1768 .delsys = { SYS_DVBS },
1795 .info = { 1769 .info = {
1796 .name = "DST DVB-S", 1770 .name = "DST DVB-S",
@@ -1819,7 +1793,7 @@ static struct dvb_frontend_ops dst_dvbs_ops = {
1819 .set_tone = dst_set_tone, 1793 .set_tone = dst_set_tone,
1820}; 1794};
1821 1795
1822static struct dvb_frontend_ops dst_dvbc_ops = { 1796static const struct dvb_frontend_ops dst_dvbc_ops = {
1823 .delsys = { SYS_DVBC_ANNEX_A }, 1797 .delsys = { SYS_DVBC_ANNEX_A },
1824 .info = { 1798 .info = {
1825 .name = "DST DVB-C", 1799 .name = "DST DVB-C",
@@ -1848,7 +1822,7 @@ static struct dvb_frontend_ops dst_dvbc_ops = {
1848 .read_snr = dst_read_snr, 1822 .read_snr = dst_read_snr,
1849}; 1823};
1850 1824
1851static struct dvb_frontend_ops dst_atsc_ops = { 1825static const struct dvb_frontend_ops dst_atsc_ops = {
1852 .delsys = { SYS_ATSC }, 1826 .delsys = { SYS_ATSC },
1853 .info = { 1827 .info = {
1854 .name = "DST ATSC", 1828 .name = "DST ATSC",
diff --git a/drivers/media/pci/bt8xx/dvb-bt8xx.c b/drivers/media/pci/bt8xx/dvb-bt8xx.c
index e69d338ab9be..6100fa71ece8 100644
--- a/drivers/media/pci/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/pci/bt8xx/dvb-bt8xx.c
@@ -19,7 +19,7 @@
19 * 19 *
20 */ 20 */
21 21
22#define pr_fmt(fmt) "dvb_bt8xx: " fmt 22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
23 23
24#include <linux/bitops.h> 24#include <linux/bitops.h>
25#include <linux/module.h> 25#include <linux/module.h>
@@ -44,10 +44,12 @@ MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
44 44
45DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 45DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
46 46
47#define dprintk( args... ) \ 47#define dprintk(fmt, arg...) do { \
48 do { \ 48 if (debug) \
49 if (debug) printk(KERN_DEBUG args); \ 49 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
50 } while (0) 50 __func__, ##arg); \
51} while (0)
52
51 53
52#define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ 54#define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
53 55
@@ -55,7 +57,7 @@ static void dvb_bt8xx_task(unsigned long data)
55{ 57{
56 struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *)data; 58 struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *)data;
57 59
58 //printk("%d ", card->bt->finished_block); 60 dprintk("%d\n", card->bt->finished_block);
59 61
60 while (card->bt->last_block != card->bt->finished_block) { 62 while (card->bt->last_block != card->bt->finished_block) {
61 (card->bt->TS_Size ? dvb_dmx_swfilter_204 : dvb_dmx_swfilter) 63 (card->bt->TS_Size ? dvb_dmx_swfilter_204 : dvb_dmx_swfilter)
@@ -443,7 +445,7 @@ static void or51211_reset(struct dvb_frontend * fe)
443 /* reset & PRM1,2&4 are outputs */ 445 /* reset & PRM1,2&4 are outputs */
444 int ret = bttv_gpio_enable(bt->bttv_nr, 0x001F, 0x001F); 446 int ret = bttv_gpio_enable(bt->bttv_nr, 0x001F, 0x001F);
445 if (ret != 0) 447 if (ret != 0)
446 printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR (%i)\n", ret); 448 pr_warn("or51211: Init Error - Can't Reset DVR (%i)\n", ret);
447 bttv_write_gpio(bt->bttv_nr, 0x001F, 0x0000); /* Reset */ 449 bttv_write_gpio(bt->bttv_nr, 0x001F, 0x0000); /* Reset */
448 msleep(20); 450 msleep(20);
449 /* Now set for normal operation */ 451 /* Now set for normal operation */
@@ -560,7 +562,8 @@ static void digitv_alps_tded4_reset(struct dvb_bt8xx_card *bt)
560 562
561 int ret = bttv_gpio_enable(bt->bttv_nr, 0x08, 0x08); 563 int ret = bttv_gpio_enable(bt->bttv_nr, 0x08, 0x08);
562 if (ret != 0) 564 if (ret != 0)
563 printk(KERN_WARNING "digitv_alps_tded4: Init Error - Can't Reset DVR (%i)\n", ret); 565 pr_warn("digitv_alps_tded4: Init Error - Can't Reset DVR (%i)\n",
566 ret);
564 567
565 /* Pulse the reset line */ 568 /* Pulse the reset line */
566 bttv_write_gpio(bt->bttv_nr, 0x08, 0x08); /* High */ 569 bttv_write_gpio(bt->bttv_nr, 0x08, 0x08); /* High */
@@ -620,7 +623,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
620 dvb_attach(simple_tuner_attach, card->fe, 623 dvb_attach(simple_tuner_attach, card->fe,
621 card->i2c_adapter, 0x61, 624 card->i2c_adapter, 0x61,
622 TUNER_LG_TDVS_H06XF); 625 TUNER_LG_TDVS_H06XF);
623 dprintk ("dvb_bt8xx: lgdt330x detected\n"); 626 dprintk("dvb_bt8xx: lgdt330x detected\n");
624 } 627 }
625 break; 628 break;
626 629
@@ -635,7 +638,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
635 card->fe = dvb_attach(nxt6000_attach, &vp3021_alps_tded4_config, card->i2c_adapter); 638 card->fe = dvb_attach(nxt6000_attach, &vp3021_alps_tded4_config, card->i2c_adapter);
636 if (card->fe != NULL) { 639 if (card->fe != NULL) {
637 card->fe->ops.tuner_ops.set_params = vp3021_alps_tded4_tuner_set_params; 640 card->fe->ops.tuner_ops.set_params = vp3021_alps_tded4_tuner_set_params;
638 dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n"); 641 dprintk("dvb_bt8xx: an nxt6000 was detected on your digitv card\n");
639 break; 642 break;
640 } 643 }
641 644
@@ -645,7 +648,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
645 648
646 if (card->fe != NULL) { 649 if (card->fe != NULL) {
647 card->fe->ops.tuner_ops.calc_regs = digitv_alps_tded4_tuner_calc_regs; 650 card->fe->ops.tuner_ops.calc_regs = digitv_alps_tded4_tuner_calc_regs;
648 dprintk ("dvb_bt8xx: an mt352 was detected on your digitv card\n"); 651 dprintk("dvb_bt8xx: an mt352 was detected on your digitv card\n");
649 } 652 }
650 break; 653 break;
651 654
diff --git a/drivers/media/pci/cobalt/cobalt-v4l2.c b/drivers/media/pci/cobalt/cobalt-v4l2.c
index 5c76637900d0..def4a3b37084 100644
--- a/drivers/media/pci/cobalt/cobalt-v4l2.c
+++ b/drivers/media/pci/cobalt/cobalt-v4l2.c
@@ -527,7 +527,7 @@ static void cobalt_video_input_status_show(struct cobalt_stream *s)
527 cvi_ctrl = ioread32(&cvi->control); 527 cvi_ctrl = ioread32(&cvi->control);
528 cvi_stat = ioread32(&cvi->status); 528 cvi_stat = ioread32(&cvi->status);
529 vmr_ctrl = ioread32(&vmr->control); 529 vmr_ctrl = ioread32(&vmr->control);
530 vmr_stat = ioread32(&vmr->control); 530 vmr_stat = ioread32(&vmr->status);
531 cobalt_info("rx%d: cvi resolution: %dx%d\n", rx, 531 cobalt_info("rx%d: cvi resolution: %dx%d\n", rx,
532 ioread32(&cvi->frame_width), ioread32(&cvi->frame_height)); 532 ioread32(&cvi->frame_width), ioread32(&cvi->frame_height));
533 cobalt_info("rx%d: cvi control: %s%s%s\n", rx, 533 cobalt_info("rx%d: cvi control: %s%s%s\n", rx,
@@ -1084,12 +1084,33 @@ static int cobalt_g_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
1084 return 0; 1084 return 0;
1085} 1085}
1086 1086
1087static int cobalt_cropcap(struct file *file, void *fh, struct v4l2_cropcap *cc)
1088{
1089 struct cobalt_stream *s = video_drvdata(file);
1090 struct v4l2_dv_timings timings;
1091 int err = 0;
1092
1093 if (cc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1094 return -EINVAL;
1095 if (s->input == 1)
1096 timings = cea1080p60;
1097 else
1098 err = v4l2_subdev_call(s->sd, video, g_dv_timings, &timings);
1099 if (!err) {
1100 cc->bounds.width = cc->defrect.width = timings.bt.width;
1101 cc->bounds.height = cc->defrect.height = timings.bt.height;
1102 cc->pixelaspect = v4l2_dv_timings_aspect_ratio(&timings);
1103 }
1104 return err;
1105}
1106
1087static const struct v4l2_ioctl_ops cobalt_ioctl_ops = { 1107static const struct v4l2_ioctl_ops cobalt_ioctl_ops = {
1088 .vidioc_querycap = cobalt_querycap, 1108 .vidioc_querycap = cobalt_querycap,
1089 .vidioc_g_parm = cobalt_g_parm, 1109 .vidioc_g_parm = cobalt_g_parm,
1090 .vidioc_log_status = cobalt_log_status, 1110 .vidioc_log_status = cobalt_log_status,
1091 .vidioc_streamon = vb2_ioctl_streamon, 1111 .vidioc_streamon = vb2_ioctl_streamon,
1092 .vidioc_streamoff = vb2_ioctl_streamoff, 1112 .vidioc_streamoff = vb2_ioctl_streamoff,
1113 .vidioc_cropcap = cobalt_cropcap,
1093 .vidioc_enum_input = cobalt_enum_input, 1114 .vidioc_enum_input = cobalt_enum_input,
1094 .vidioc_g_input = cobalt_g_input, 1115 .vidioc_g_input = cobalt_g_input,
1095 .vidioc_s_input = cobalt_s_input, 1116 .vidioc_s_input = cobalt_s_input,
diff --git a/drivers/media/pci/cx18/cx18-alsa-main.c b/drivers/media/pci/cx18/cx18-alsa-main.c
index 0b0e8015ad34..9fb7f5978c8b 100644
--- a/drivers/media/pci/cx18/cx18-alsa-main.c
+++ b/drivers/media/pci/cx18/cx18-alsa-main.c
@@ -217,8 +217,8 @@ static int cx18_alsa_load(struct cx18 *cx)
217 217
218 s = &cx->streams[CX18_ENC_STREAM_TYPE_PCM]; 218 s = &cx->streams[CX18_ENC_STREAM_TYPE_PCM];
219 if (s->video_dev.v4l2_dev == NULL) { 219 if (s->video_dev.v4l2_dev == NULL) {
220 CX18_DEBUG_ALSA_INFO("%s: PCM stream for card is disabled - " 220 CX18_DEBUG_ALSA_INFO("%s: PCM stream for card is disabled - skipping\n",
221 "skipping\n", __func__); 221 __func__);
222 return 0; 222 return 0;
223 } 223 }
224 224
@@ -232,8 +232,8 @@ static int cx18_alsa_load(struct cx18 *cx)
232 CX18_ALSA_ERR("%s: failed to create struct snd_cx18_card\n", 232 CX18_ALSA_ERR("%s: failed to create struct snd_cx18_card\n",
233 __func__); 233 __func__);
234 } else { 234 } else {
235 CX18_DEBUG_ALSA_INFO("%s: created cx18 ALSA interface instance " 235 CX18_DEBUG_ALSA_INFO("%s: created cx18 ALSA interface instance\n",
236 "\n", __func__); 236 __func__);
237 } 237 }
238 return 0; 238 return 0;
239} 239}
diff --git a/drivers/media/pci/cx18/cx18-av-core.c b/drivers/media/pci/cx18/cx18-av-core.c
index 30bbe8d1ea55..7f7306fd9a7f 100644
--- a/drivers/media/pci/cx18/cx18-av-core.c
+++ b/drivers/media/pci/cx18/cx18-av-core.c
@@ -468,21 +468,19 @@ void cx18_av_std_setup(struct cx18 *cx)
468 CX18_DEBUG_INFO_DEV(sd, "Pixel rate = %d.%06d Mpixel/sec\n", 468 CX18_DEBUG_INFO_DEV(sd, "Pixel rate = %d.%06d Mpixel/sec\n",
469 pll / 8000000, (pll / 8) % 1000000); 469 pll / 8000000, (pll / 8) % 1000000);
470 470
471 CX18_DEBUG_INFO_DEV(sd, "ADC XTAL/pixel clock decimation ratio " 471 CX18_DEBUG_INFO_DEV(sd, "ADC XTAL/pixel clock decimation ratio = %d.%03d\n",
472 "= %d.%03d\n", src_decimation / 256, 472 src_decimation / 256,
473 ((src_decimation % 256) * 1000) / 256); 473 ((src_decimation % 256) * 1000) / 256);
474 474
475 tmp = 28636360 * (u64) sc; 475 tmp = 28636360 * (u64) sc;
476 do_div(tmp, src_decimation); 476 do_div(tmp, src_decimation);
477 fsc = tmp >> 13; 477 fsc = tmp >> 13;
478 CX18_DEBUG_INFO_DEV(sd, 478 CX18_DEBUG_INFO_DEV(sd,
479 "Chroma sub-carrier initial freq = %d.%06d " 479 "Chroma sub-carrier initial freq = %d.%06d MHz\n",
480 "MHz\n", fsc / 1000000, fsc % 1000000); 480 fsc / 1000000, fsc % 1000000);
481 481
482 CX18_DEBUG_INFO_DEV(sd, "hblank %i, hactive %i, vblank %i, " 482 CX18_DEBUG_INFO_DEV(sd,
483 "vactive %i, vblank656 %i, src_dec %i, " 483 "hblank %i, hactive %i, vblank %i, vactive %i, vblank656 %i, src_dec %i, burst 0x%02x, luma_lpf %i, uv_lpf %i, comb 0x%02x, sc 0x%06x\n",
484 "burst 0x%02x, luma_lpf %i, uv_lpf %i, "
485 "comb 0x%02x, sc 0x%06x\n",
486 hblank, hactive, vblank, vactive, vblank656, 484 hblank, hactive, vblank, vactive, vblank656,
487 src_decimation, burst, luma_lpf, uv_lpf, 485 src_decimation, burst, luma_lpf, uv_lpf,
488 comb, sc); 486 comb, sc);
@@ -1069,8 +1067,7 @@ static void log_video_status(struct cx18 *cx)
1069 CX18_INFO_DEV(sd, "Specified video input: Composite %d\n", 1067 CX18_INFO_DEV(sd, "Specified video input: Composite %d\n",
1070 vid_input - CX18_AV_COMPOSITE1 + 1); 1068 vid_input - CX18_AV_COMPOSITE1 + 1);
1071 } else { 1069 } else {
1072 CX18_INFO_DEV(sd, "Specified video input: " 1070 CX18_INFO_DEV(sd, "Specified video input: S-Video (Luma In%d, Chroma In%d)\n",
1073 "S-Video (Luma In%d, Chroma In%d)\n",
1074 (vid_input & 0xf0) >> 4, 1071 (vid_input & 0xf0) >> 4,
1075 (vid_input & 0xf00) >> 8); 1072 (vid_input & 0xf00) >> 8);
1076 } 1073 }
diff --git a/drivers/media/pci/cx18/cx18-av-firmware.c b/drivers/media/pci/cx18/cx18-av-firmware.c
index a34fd082b76e..160e2e53383f 100644
--- a/drivers/media/pci/cx18/cx18-av-firmware.c
+++ b/drivers/media/pci/cx18/cx18-av-firmware.c
@@ -61,8 +61,7 @@ static int cx18_av_verifyfw(struct cx18 *cx, const struct firmware *fw)
61 dl_control &= 0xffff3fff; /* ignore top 2 bits of address */ 61 dl_control &= 0xffff3fff; /* ignore top 2 bits of address */
62 expected = 0x0f000000 | ((u32)data[addr] << 16) | addr; 62 expected = 0x0f000000 | ((u32)data[addr] << 16) | addr;
63 if (expected != dl_control) { 63 if (expected != dl_control) {
64 CX18_ERR_DEV(sd, "verification of %s firmware load " 64 CX18_ERR_DEV(sd, "verification of %s firmware load failed: expected %#010x got %#010x\n",
65 "failed: expected %#010x got %#010x\n",
66 FWFILE, expected, dl_control); 65 FWFILE, expected, dl_control);
67 ret = -EIO; 66 ret = -EIO;
68 break; 67 break;
diff --git a/drivers/media/pci/cx18/cx18-controls.c b/drivers/media/pci/cx18/cx18-controls.c
index adb5a8c72c06..812a2507945a 100644
--- a/drivers/media/pci/cx18/cx18-controls.c
+++ b/drivers/media/pci/cx18/cx18-controls.c
@@ -44,8 +44,7 @@ static int cx18_s_stream_vbi_fmt(struct cx2341x_handler *cxhdl, u32 fmt)
44 type == V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD)) { 44 type == V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD)) {
45 /* Only IVTV fmt VBI insertion & only MPEG-2 PS type streams */ 45 /* Only IVTV fmt VBI insertion & only MPEG-2 PS type streams */
46 cx->vbi.insert_mpeg = V4L2_MPEG_STREAM_VBI_FMT_NONE; 46 cx->vbi.insert_mpeg = V4L2_MPEG_STREAM_VBI_FMT_NONE;
47 CX18_DEBUG_INFO("disabled insertion of sliced VBI data into " 47 CX18_DEBUG_INFO("disabled insertion of sliced VBI data into the MPEG stream\n");
48 "the MPEG stream\n");
49 return 0; 48 return 0;
50 } 49 }
51 50
@@ -63,16 +62,14 @@ static int cx18_s_stream_vbi_fmt(struct cx2341x_handler *cxhdl, u32 fmt)
63 } 62 }
64 cx->vbi.insert_mpeg = 63 cx->vbi.insert_mpeg =
65 V4L2_MPEG_STREAM_VBI_FMT_NONE; 64 V4L2_MPEG_STREAM_VBI_FMT_NONE;
66 CX18_WARN("Unable to allocate buffers for " 65 CX18_WARN("Unable to allocate buffers for sliced VBI data insertion\n");
67 "sliced VBI data insertion\n");
68 return -ENOMEM; 66 return -ENOMEM;
69 } 67 }
70 } 68 }
71 } 69 }
72 70
73 cx->vbi.insert_mpeg = fmt; 71 cx->vbi.insert_mpeg = fmt;
74 CX18_DEBUG_INFO("enabled insertion of sliced VBI data into the MPEG PS," 72 CX18_DEBUG_INFO("enabled insertion of sliced VBI data into the MPEG PS,when sliced VBI is enabled\n");
75 "when sliced VBI is enabled\n");
76 73
77 /* 74 /*
78 * If our current settings have no lines set for capture, store a valid, 75 * If our current settings have no lines set for capture, store a valid,
diff --git a/drivers/media/pci/cx18/cx18-driver.c b/drivers/media/pci/cx18/cx18-driver.c
index 2f23b26b16c0..b8eedbe51c8f 100644
--- a/drivers/media/pci/cx18/cx18-driver.c
+++ b/drivers/media/pci/cx18/cx18-driver.c
@@ -405,8 +405,8 @@ static void cx18_process_eeprom(struct cx18 *cx)
405 CX18_ERR("Invalid EEPROM\n"); 405 CX18_ERR("Invalid EEPROM\n");
406 return; 406 return;
407 default: 407 default:
408 CX18_ERR("Unknown model %d, defaulting to original HVR-1600 " 408 CX18_ERR("Unknown model %d, defaulting to original HVR-1600 (cardtype=1)\n",
409 "(cardtype=1)\n", tv.model); 409 tv.model);
410 cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); 410 cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT);
411 break; 411 break;
412 } 412 }
@@ -635,8 +635,8 @@ static void cx18_process_options(struct cx18 *cx)
635 /* convert from kB to bytes */ 635 /* convert from kB to bytes */
636 cx->stream_buf_size[i] *= 1024; 636 cx->stream_buf_size[i] *= 1024;
637 } 637 }
638 CX18_DEBUG_INFO("Stream type %d options: %d MB, %d buffers, " 638 CX18_DEBUG_INFO("Stream type %d options: %d MB, %d buffers, %d bytes\n",
639 "%d bytes\n", i, cx->options.megabytes[i], 639 i, cx->options.megabytes[i],
640 cx->stream_buffers[i], cx->stream_buf_size[i]); 640 cx->stream_buffers[i], cx->stream_buf_size[i]);
641 } 641 }
642 642
@@ -838,14 +838,13 @@ static int cx18_setup_pci(struct cx18 *cx, struct pci_dev *pci_dev,
838 pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &pci_latency); 838 pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &pci_latency);
839 839
840 if (pci_latency < 64 && cx18_pci_latency) { 840 if (pci_latency < 64 && cx18_pci_latency) {
841 CX18_INFO("Unreasonably low latency timer, " 841 CX18_INFO("Unreasonably low latency timer, setting to 64 (was %d)\n",
842 "setting to 64 (was %d)\n", pci_latency); 842 pci_latency);
843 pci_write_config_byte(pci_dev, PCI_LATENCY_TIMER, 64); 843 pci_write_config_byte(pci_dev, PCI_LATENCY_TIMER, 64);
844 pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &pci_latency); 844 pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &pci_latency);
845 } 845 }
846 846
847 CX18_DEBUG_INFO("cx%d (rev %d) at %02x:%02x.%x, " 847 CX18_DEBUG_INFO("cx%d (rev %d) at %02x:%02x.%x, irq: %d, latency: %d, memory: 0x%llx\n",
848 "irq: %d, latency: %d, memory: 0x%llx\n",
849 cx->pci_dev->device, cx->card_rev, pci_dev->bus->number, 848 cx->pci_dev->device, cx->card_rev, pci_dev->bus->number,
850 PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn), 849 PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn),
851 cx->pci_dev->irq, pci_latency, (u64)cx->base_addr); 850 cx->pci_dev->irq, pci_latency, (u64)cx->base_addr);
@@ -910,8 +909,8 @@ static int cx18_probe(struct pci_dev *pci_dev,
910 /* FIXME - module parameter arrays constrain max instances */ 909 /* FIXME - module parameter arrays constrain max instances */
911 i = atomic_inc_return(&cx18_instance) - 1; 910 i = atomic_inc_return(&cx18_instance) - 1;
912 if (i >= CX18_MAX_CARDS) { 911 if (i >= CX18_MAX_CARDS) {
913 printk(KERN_ERR "cx18: cannot manage card %d, driver has a " 912 printk(KERN_ERR "cx18: cannot manage card %d, driver has a limit of 0 - %d\n",
914 "limit of 0 - %d\n", i, CX18_MAX_CARDS - 1); 913 i, CX18_MAX_CARDS - 1);
915 return -ENOMEM; 914 return -ENOMEM;
916 } 915 }
917 916
@@ -926,8 +925,8 @@ static int cx18_probe(struct pci_dev *pci_dev,
926 925
927 retval = v4l2_device_register(&pci_dev->dev, &cx->v4l2_dev); 926 retval = v4l2_device_register(&pci_dev->dev, &cx->v4l2_dev);
928 if (retval) { 927 if (retval) {
929 printk(KERN_ERR "cx18: v4l2_device_register of card %d failed" 928 printk(KERN_ERR "cx18: v4l2_device_register of card %d failed\n",
930 "\n", cx->instance); 929 cx->instance);
931 kfree(cx); 930 kfree(cx);
932 return retval; 931 return retval;
933 } 932 }
@@ -958,13 +957,10 @@ static int cx18_probe(struct pci_dev *pci_dev,
958 cx->enc_mem = ioremap_nocache(cx->base_addr + CX18_MEM_OFFSET, 957 cx->enc_mem = ioremap_nocache(cx->base_addr + CX18_MEM_OFFSET,
959 CX18_MEM_SIZE); 958 CX18_MEM_SIZE);
960 if (!cx->enc_mem) { 959 if (!cx->enc_mem) {
961 CX18_ERR("ioremap failed. Can't get a window into CX23418 " 960 CX18_ERR("ioremap failed. Can't get a window into CX23418 memory and register space\n");
962 "memory and register space\n"); 961 CX18_ERR("Each capture card with a CX23418 needs 64 MB of vmalloc address space for the window\n");
963 CX18_ERR("Each capture card with a CX23418 needs 64 MB of "
964 "vmalloc address space for the window\n");
965 CX18_ERR("Check the output of 'grep Vmalloc /proc/meminfo'\n"); 962 CX18_ERR("Check the output of 'grep Vmalloc /proc/meminfo'\n");
966 CX18_ERR("Use the vmalloc= kernel command line option to set " 963 CX18_ERR("Use the vmalloc= kernel command line option to set VmallocTotal to a larger value\n");
967 "VmallocTotal to a larger value\n");
968 retval = -ENOMEM; 964 retval = -ENOMEM;
969 goto free_mem; 965 goto free_mem;
970 } 966 }
@@ -1000,8 +996,7 @@ static int cx18_probe(struct pci_dev *pci_dev,
1000 /* Initialize GPIO Reset Controller to do chip resets during i2c init */ 996 /* Initialize GPIO Reset Controller to do chip resets during i2c init */
1001 if (cx->card->hw_all & CX18_HW_GPIO_RESET_CTRL) { 997 if (cx->card->hw_all & CX18_HW_GPIO_RESET_CTRL) {
1002 if (cx18_gpio_register(cx, CX18_HW_GPIO_RESET_CTRL) != 0) 998 if (cx18_gpio_register(cx, CX18_HW_GPIO_RESET_CTRL) != 0)
1003 CX18_WARN("Could not register GPIO reset controller" 999 CX18_WARN("Could not register GPIO reset controllersubdevice; proceeding anyway.\n");
1004 "subdevice; proceeding anyway.\n");
1005 else 1000 else
1006 cx->hw_flags |= CX18_HW_GPIO_RESET_CTRL; 1001 cx->hw_flags |= CX18_HW_GPIO_RESET_CTRL;
1007 } 1002 }
diff --git a/drivers/media/pci/cx18/cx18-dvb.c b/drivers/media/pci/cx18/cx18-dvb.c
index 3eac59c51231..03d0478170a7 100644
--- a/drivers/media/pci/cx18/cx18-dvb.c
+++ b/drivers/media/pci/cx18/cx18-dvb.c
@@ -155,10 +155,8 @@ static int yuan_mpc718_mt352_reqfw(struct cx18_stream *stream,
155 } 155 }
156 156
157 if (ret) { 157 if (ret) {
158 CX18_ERR("The MPC718 board variant with the MT352 DVB-T" 158 CX18_ERR("The MPC718 board variant with the MT352 DVB-Tdemodualtor will not work without it\n");
159 "demodualtor will not work without it\n"); 159 CX18_ERR("Run 'linux/Documentation/dvb/get_dvb_firmware mpc718' if you need the firmware\n");
160 CX18_ERR("Run 'linux/Documentation/dvb/get_dvb_firmware "
161 "mpc718' if you need the firmware\n");
162 } 160 }
163 return ret; 161 return ret;
164} 162}
diff --git a/drivers/media/pci/cx18/cx18-fileops.c b/drivers/media/pci/cx18/cx18-fileops.c
index df837408efd5..78b399b8613e 100644
--- a/drivers/media/pci/cx18/cx18-fileops.c
+++ b/drivers/media/pci/cx18/cx18-fileops.c
@@ -49,8 +49,7 @@ int cx18_claim_stream(struct cx18_open_id *id, int type)
49 49
50 /* Nothing should ever try to directly claim the IDX stream */ 50 /* Nothing should ever try to directly claim the IDX stream */
51 if (type == CX18_ENC_STREAM_TYPE_IDX) { 51 if (type == CX18_ENC_STREAM_TYPE_IDX) {
52 CX18_WARN("MPEG Index stream cannot be claimed " 52 CX18_WARN("MPEG Index stream cannot be claimed directly, but something tried.\n");
53 "directly, but something tried.\n");
54 return -EINVAL; 53 return -EINVAL;
55 } 54 }
56 55
@@ -728,8 +727,7 @@ void cx18_stop_capture(struct cx18_open_id *id, int gop_end)
728 /* Stop internal use associated VBI and IDX streams */ 727 /* Stop internal use associated VBI and IDX streams */
729 if (test_bit(CX18_F_S_STREAMING, &s_vbi->s_flags) && 728 if (test_bit(CX18_F_S_STREAMING, &s_vbi->s_flags) &&
730 !test_bit(CX18_F_S_APPL_IO, &s_vbi->s_flags)) { 729 !test_bit(CX18_F_S_APPL_IO, &s_vbi->s_flags)) {
731 CX18_DEBUG_INFO("close stopping embedded VBI " 730 CX18_DEBUG_INFO("close stopping embedded VBI capture\n");
732 "capture\n");
733 cx18_stop_v4l2_encode_stream(s_vbi, 0); 731 cx18_stop_v4l2_encode_stream(s_vbi, 0);
734 } 732 }
735 if (test_bit(CX18_F_S_STREAMING, &s_idx->s_flags)) { 733 if (test_bit(CX18_F_S_STREAMING, &s_idx->s_flags)) {
diff --git a/drivers/media/pci/cx18/cx18-ioctl.c b/drivers/media/pci/cx18/cx18-ioctl.c
index fecca2a63891..0faeb979ceb9 100644
--- a/drivers/media/pci/cx18/cx18-ioctl.c
+++ b/drivers/media/pci/cx18/cx18-ioctl.c
@@ -951,8 +951,7 @@ static int cx18_encoder_cmd(struct file *file, void *fh,
951 return 0; 951 return 0;
952 h = cx18_find_handle(cx); 952 h = cx18_find_handle(cx);
953 if (h == CX18_INVALID_TASK_HANDLE) { 953 if (h == CX18_INVALID_TASK_HANDLE) {
954 CX18_ERR("Can't find valid task handle for " 954 CX18_ERR("Can't find valid task handle for V4L2_ENC_CMD_PAUSE\n");
955 "V4L2_ENC_CMD_PAUSE\n");
956 return -EBADFD; 955 return -EBADFD;
957 } 956 }
958 cx18_mute(cx); 957 cx18_mute(cx);
@@ -968,8 +967,7 @@ static int cx18_encoder_cmd(struct file *file, void *fh,
968 return 0; 967 return 0;
969 h = cx18_find_handle(cx); 968 h = cx18_find_handle(cx);
970 if (h == CX18_INVALID_TASK_HANDLE) { 969 if (h == CX18_INVALID_TASK_HANDLE) {
971 CX18_ERR("Can't find valid task handle for " 970 CX18_ERR("Can't find valid task handle for V4L2_ENC_CMD_RESUME\n");
972 "V4L2_ENC_CMD_RESUME\n");
973 return -EBADFD; 971 return -EBADFD;
974 } 972 }
975 cx18_vapi(cx, CX18_CPU_CAPTURE_RESUME, 1, h); 973 cx18_vapi(cx, CX18_CPU_CAPTURE_RESUME, 1, h);
diff --git a/drivers/media/pci/cx18/cx18-irq.c b/drivers/media/pci/cx18/cx18-irq.c
index 80edfe93a3d8..361426485e98 100644
--- a/drivers/media/pci/cx18/cx18-irq.c
+++ b/drivers/media/pci/cx18/cx18-irq.c
@@ -59,8 +59,8 @@ irqreturn_t cx18_irq_handler(int irq, void *dev_id)
59 cx18_write_reg_expect(cx, hw2, HW2_INT_CLR_STATUS, ~hw2, hw2); 59 cx18_write_reg_expect(cx, hw2, HW2_INT_CLR_STATUS, ~hw2, hw2);
60 60
61 if (sw1 || sw2 || hw2) 61 if (sw1 || sw2 || hw2)
62 CX18_DEBUG_HI_IRQ("received interrupts " 62 CX18_DEBUG_HI_IRQ("received interrupts SW1: %x SW2: %x HW2: %x\n",
63 "SW1: %x SW2: %x HW2: %x\n", sw1, sw2, hw2); 63 sw1, sw2, hw2);
64 64
65 /* 65 /*
66 * SW1 responses have to happen first. The sending XPU times out the 66 * SW1 responses have to happen first. The sending XPU times out the
diff --git a/drivers/media/pci/cx18/cx18-mailbox.c b/drivers/media/pci/cx18/cx18-mailbox.c
index 1f8aa9a749a1..d3cf3588879f 100644
--- a/drivers/media/pci/cx18/cx18-mailbox.c
+++ b/drivers/media/pci/cx18/cx18-mailbox.c
@@ -123,8 +123,8 @@ static void dump_mb(struct cx18 *cx, struct cx18_mailbox *mb, char *name)
123 if (!(cx18_debug & CX18_DBGFLG_API)) 123 if (!(cx18_debug & CX18_DBGFLG_API))
124 return; 124 return;
125 125
126 CX18_DEBUG_API("%s: req %#010x ack %#010x cmd %#010x err %#010x args%s" 126 CX18_DEBUG_API("%s: req %#010x ack %#010x cmd %#010x err %#010x args%s\n",
127 "\n", name, mb->request, mb->ack, mb->cmd, mb->error, 127 name, mb->request, mb->ack, mb->cmd, mb->error,
128 u32arr2hex(mb->args, MAX_MB_ARGUMENTS, argstr)); 128 u32arr2hex(mb->args, MAX_MB_ARGUMENTS, argstr));
129} 129}
130 130
@@ -255,8 +255,8 @@ static void epu_dma_done(struct cx18 *cx, struct cx18_in_work_order *order)
255 s = cx18_handle_to_stream(cx, handle); 255 s = cx18_handle_to_stream(cx, handle);
256 256
257 if (s == NULL) { 257 if (s == NULL) {
258 CX18_WARN("Got DMA done notification for unknown/inactive" 258 CX18_WARN("Got DMA done notification for unknown/inactive handle %d, %s mailbox seq no %d\n",
259 " handle %d, %s mailbox seq no %d\n", handle, 259 handle,
260 (order->flags & CX18_F_EWO_MB_STALE_UPON_RECEIPT) ? 260 (order->flags & CX18_F_EWO_MB_STALE_UPON_RECEIPT) ?
261 "stale" : "good", mb->request); 261 "stale" : "good", mb->request);
262 return; 262 return;
@@ -290,9 +290,8 @@ static void epu_dma_done(struct cx18 *cx, struct cx18_in_work_order *order)
290 if ((order->flags & CX18_F_EWO_MB_STALE_UPON_RECEIPT) && 290 if ((order->flags & CX18_F_EWO_MB_STALE_UPON_RECEIPT) &&
291 !(id >= s->mdl_base_idx && 291 !(id >= s->mdl_base_idx &&
292 id < (s->mdl_base_idx + s->buffers))) { 292 id < (s->mdl_base_idx + s->buffers))) {
293 CX18_WARN("Fell behind! Ignoring stale mailbox with " 293 CX18_WARN("Fell behind! Ignoring stale mailbox with inconsistent data. Lost MDL for mailbox seq no %d\n",
294 " inconsistent data. Lost MDL for mailbox " 294 mb->request);
295 "seq no %d\n", mb->request);
296 break; 295 break;
297 } 296 }
298 mdl = cx18_queue_get_mdl(s, id, mdl_ack->data_used); 297 mdl = cx18_queue_get_mdl(s, id, mdl_ack->data_used);
@@ -418,9 +417,7 @@ static void mb_ack_irq(struct cx18 *cx, struct cx18_in_work_order *order)
418 /* Don't ack if the RPU has gotten impatient and timed us out */ 417 /* Don't ack if the RPU has gotten impatient and timed us out */
419 if (req != cx18_readl(cx, &ack_mb->request) || 418 if (req != cx18_readl(cx, &ack_mb->request) ||
420 req == cx18_readl(cx, &ack_mb->ack)) { 419 req == cx18_readl(cx, &ack_mb->ack)) {
421 CX18_DEBUG_WARN("Possibly falling behind: %s self-ack'ed our " 420 CX18_DEBUG_WARN("Possibly falling behind: %s self-ack'ed our incoming %s to EPU mailbox (sequence no. %u) while processing\n",
422 "incoming %s to EPU mailbox (sequence no. %u) "
423 "while processing\n",
424 rpu_str[order->rpu], rpu_str[order->rpu], req); 421 rpu_str[order->rpu], rpu_str[order->rpu], req);
425 order->flags |= CX18_F_EWO_MB_STALE_WHILE_PROC; 422 order->flags |= CX18_F_EWO_MB_STALE_WHILE_PROC;
426 return; 423 return;
@@ -555,8 +552,7 @@ void cx18_api_epu_cmd_irq(struct cx18 *cx, int rpu)
555 552
556 order = alloc_in_work_order_irq(cx); 553 order = alloc_in_work_order_irq(cx);
557 if (order == NULL) { 554 if (order == NULL) {
558 CX18_WARN("Unable to find blank work order form to schedule " 555 CX18_WARN("Unable to find blank work order form to schedule incoming mailbox command processing\n");
559 "incoming mailbox command processing\n");
560 return; 556 return;
561 } 557 }
562 558
@@ -573,9 +569,7 @@ void cx18_api_epu_cmd_irq(struct cx18 *cx, int rpu)
573 (&order_mb->request)[i] = cx18_readl(cx, &mb->request + i); 569 (&order_mb->request)[i] = cx18_readl(cx, &mb->request + i);
574 570
575 if (order_mb->request == order_mb->ack) { 571 if (order_mb->request == order_mb->ack) {
576 CX18_DEBUG_WARN("Possibly falling behind: %s self-ack'ed our " 572 CX18_DEBUG_WARN("Possibly falling behind: %s self-ack'ed our incoming %s to EPU mailbox (sequence no. %u)\n",
577 "incoming %s to EPU mailbox (sequence no. %u)"
578 "\n",
579 rpu_str[rpu], rpu_str[rpu], order_mb->request); 573 rpu_str[rpu], rpu_str[rpu], order_mb->request);
580 if (cx18_debug & CX18_DBGFLG_WARN) 574 if (cx18_debug & CX18_DBGFLG_WARN)
581 dump_mb(cx, order_mb, "incoming"); 575 dump_mb(cx, order_mb, "incoming");
@@ -663,8 +657,8 @@ static int cx18_api_call(struct cx18 *cx, u32 cmd, int args, u32 data[])
663 if (req != ack) { 657 if (req != ack) {
664 /* waited long enough, make the mbox "not busy" from our end */ 658 /* waited long enough, make the mbox "not busy" from our end */
665 cx18_writel(cx, req, &mb->ack); 659 cx18_writel(cx, req, &mb->ack);
666 CX18_ERR("mbox was found stuck busy when setting up for %s; " 660 CX18_ERR("mbox was found stuck busy when setting up for %s; clearing busy and trying to proceed\n",
667 "clearing busy and trying to proceed\n", info->name); 661 info->name);
668 } else if (ret != timeout) 662 } else if (ret != timeout)
669 CX18_DEBUG_API("waited %u msecs for busy mbox to be acked\n", 663 CX18_DEBUG_API("waited %u msecs for busy mbox to be acked\n",
670 jiffies_to_msecs(timeout-ret)); 664 jiffies_to_msecs(timeout-ret));
@@ -707,14 +701,10 @@ static int cx18_api_call(struct cx18 *cx, u32 cmd, int args, u32 data[])
707 mutex_unlock(mb_lock); 701 mutex_unlock(mb_lock);
708 if (ret >= timeout) { 702 if (ret >= timeout) {
709 /* Timed out */ 703 /* Timed out */
710 CX18_DEBUG_WARN("sending %s timed out waiting %d msecs " 704 CX18_DEBUG_WARN("sending %s timed out waiting %d msecs for RPU acknowledgment\n",
711 "for RPU acknowledgement\n",
712 info->name, jiffies_to_msecs(ret)); 705 info->name, jiffies_to_msecs(ret));
713 } else { 706 } else {
714 CX18_DEBUG_WARN("woken up before mailbox ack was ready " 707 CX18_DEBUG_WARN("woken up before mailbox ack was ready after submitting %s to RPU. only waited %d msecs on req %u but awakened with unmatched ack %u\n",
715 "after submitting %s to RPU. only "
716 "waited %d msecs on req %u but awakened"
717 " with unmatched ack %u\n",
718 info->name, 708 info->name,
719 jiffies_to_msecs(ret), 709 jiffies_to_msecs(ret),
720 req, ack); 710 req, ack);
@@ -723,8 +713,7 @@ static int cx18_api_call(struct cx18 *cx, u32 cmd, int args, u32 data[])
723 } 713 }
724 714
725 if (ret >= timeout) 715 if (ret >= timeout)
726 CX18_DEBUG_WARN("failed to be awakened upon RPU acknowledgment " 716 CX18_DEBUG_WARN("failed to be awakened upon RPU acknowledgment sending %s; timed out waiting %d msecs\n",
727 "sending %s; timed out waiting %d msecs\n",
728 info->name, jiffies_to_msecs(ret)); 717 info->name, jiffies_to_msecs(ret));
729 else 718 else
730 CX18_DEBUG_HI_API("waited %u msecs for %s to be acked\n", 719 CX18_DEBUG_HI_API("waited %u msecs for %s to be acked\n",
diff --git a/drivers/media/pci/cx18/cx18-queue.c b/drivers/media/pci/cx18/cx18-queue.c
index 2a247d264b87..13e96d6055eb 100644
--- a/drivers/media/pci/cx18/cx18-queue.c
+++ b/drivers/media/pci/cx18/cx18-queue.c
@@ -164,9 +164,8 @@ struct cx18_mdl *cx18_queue_get_mdl(struct cx18_stream *s, u32 id,
164 mdl->skipped++; 164 mdl->skipped++;
165 if (mdl->skipped >= atomic_read(&s->q_busy.depth)-1) { 165 if (mdl->skipped >= atomic_read(&s->q_busy.depth)-1) {
166 /* mdl must have fallen out of rotation */ 166 /* mdl must have fallen out of rotation */
167 CX18_WARN("Skipped %s, MDL %d, %d " 167 CX18_WARN("Skipped %s, MDL %d, %d times - it must have dropped out of rotation\n",
168 "times - it must have dropped out of " 168 s->name, mdl->id,
169 "rotation\n", s->name, mdl->id,
170 mdl->skipped); 169 mdl->skipped);
171 /* Sweep it up to put it back into rotation */ 170 /* Sweep it up to put it back into rotation */
172 list_move_tail(&mdl->list, &sweep_up); 171 list_move_tail(&mdl->list, &sweep_up);
@@ -352,8 +351,7 @@ int cx18_stream_alloc(struct cx18_stream *s)
352 if (s->buffers == 0) 351 if (s->buffers == 0)
353 return 0; 352 return 0;
354 353
355 CX18_DEBUG_INFO("Allocate %s stream: %d x %d buffers " 354 CX18_DEBUG_INFO("Allocate %s stream: %d x %d buffers (%d.%02d kB total)\n",
356 "(%d.%02d kB total)\n",
357 s->name, s->buffers, s->buf_size, 355 s->name, s->buffers, s->buf_size,
358 s->buffers * s->buf_size / 1024, 356 s->buffers * s->buf_size / 1024,
359 (s->buffers * s->buf_size * 100 / 1024) % 100); 357 (s->buffers * s->buf_size * 100 / 1024) % 100);
diff --git a/drivers/media/pci/cx18/cx18-streams.c b/drivers/media/pci/cx18/cx18-streams.c
index f3802ec1b383..7f699f0ee76c 100644
--- a/drivers/media/pci/cx18/cx18-streams.c
+++ b/drivers/media/pci/cx18/cx18-streams.c
@@ -353,8 +353,8 @@ static int cx18_prep_dev(struct cx18 *cx, int type)
353 if (cx->card->hw_all & CX18_HW_DVB) { 353 if (cx->card->hw_all & CX18_HW_DVB) {
354 s->dvb = kzalloc(sizeof(struct cx18_dvb), GFP_KERNEL); 354 s->dvb = kzalloc(sizeof(struct cx18_dvb), GFP_KERNEL);
355 if (s->dvb == NULL) { 355 if (s->dvb == NULL) {
356 CX18_ERR("Couldn't allocate cx18_dvb structure" 356 CX18_ERR("Couldn't allocate cx18_dvb structure for %s\n",
357 " for %s\n", s->name); 357 s->name);
358 return -ENOMEM; 358 return -ENOMEM;
359 } 359 }
360 } else { 360 } else {
@@ -462,8 +462,7 @@ static int cx18_reg_dev(struct cx18 *cx, int type)
462 462
463 case VFL_TYPE_VBI: 463 case VFL_TYPE_VBI:
464 if (cx->stream_buffers[type]) 464 if (cx->stream_buffers[type])
465 CX18_INFO("Registered device %s for %s " 465 CX18_INFO("Registered device %s for %s (%d x %d bytes)\n",
466 "(%d x %d bytes)\n",
467 name, s->name, cx->stream_buffers[type], 466 name, s->name, cx->stream_buffers[type],
468 cx->stream_buf_size[type]); 467 cx->stream_buf_size[type]);
469 else 468 else
diff --git a/drivers/media/pci/cx23885/altera-ci.c b/drivers/media/pci/cx23885/altera-ci.c
index aaf4e46ff3e9..5c94e312cba3 100644
--- a/drivers/media/pci/cx23885/altera-ci.c
+++ b/drivers/media/pci/cx23885/altera-ci.c
@@ -48,6 +48,9 @@
48 * | DATA7| DATA6| DATA5| DATA4| DATA3| DATA2| DATA1| DATA0| 48 * | DATA7| DATA6| DATA5| DATA4| DATA3| DATA2| DATA1| DATA0|
49 * +-------+-------+-------+-------+-------+-------+-------+-------+ 49 * +-------+-------+-------+-------+-------+-------+-------+-------+
50 */ 50 */
51
52#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
53
51#include <dvb_demux.h> 54#include <dvb_demux.h>
52#include <dvb_frontend.h> 55#include <dvb_frontend.h>
53#include "altera-ci.h" 56#include "altera-ci.h"
@@ -84,16 +87,18 @@ MODULE_DESCRIPTION("altera FPGA CI module");
84MODULE_AUTHOR("Igor M. Liplianin <liplianin@netup.ru>"); 87MODULE_AUTHOR("Igor M. Liplianin <liplianin@netup.ru>");
85MODULE_LICENSE("GPL"); 88MODULE_LICENSE("GPL");
86 89
87#define ci_dbg_print(args...) \ 90#define ci_dbg_print(fmt, args...) \
88 do { \ 91 do { \
89 if (ci_dbg) \ 92 if (ci_dbg) \
90 printk(KERN_DEBUG args); \ 93 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
94 __func__, ##args); \
91 } while (0) 95 } while (0)
92 96
93#define pid_dbg_print(args...) \ 97#define pid_dbg_print(fmt, args...) \
94 do { \ 98 do { \
95 if (pid_dbg) \ 99 if (pid_dbg) \
96 printk(KERN_DEBUG args); \ 100 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
101 __func__, ##args); \
97 } while (0) 102 } while (0)
98 103
99struct altera_ci_state; 104struct altera_ci_state;
@@ -718,7 +723,7 @@ int altera_ci_init(struct altera_ci_config *config, int ci_nr)
718 if (temp_int != NULL) { 723 if (temp_int != NULL) {
719 inter = temp_int->internal; 724 inter = temp_int->internal;
720 (inter->cis_used)++; 725 (inter->cis_used)++;
721 inter->fpga_rw = config->fpga_rw; 726 inter->fpga_rw = config->fpga_rw;
722 ci_dbg_print("%s: Find Internal Structure!\n", __func__); 727 ci_dbg_print("%s: Find Internal Structure!\n", __func__);
723 } else { 728 } else {
724 inter = kzalloc(sizeof(struct fpga_internal), GFP_KERNEL); 729 inter = kzalloc(sizeof(struct fpga_internal), GFP_KERNEL);
diff --git a/drivers/media/pci/cx23885/altera-ci.h b/drivers/media/pci/cx23885/altera-ci.h
index 57a40c84b46e..ababd80fee93 100644
--- a/drivers/media/pci/cx23885/altera-ci.h
+++ b/drivers/media/pci/cx23885/altera-ci.h
@@ -48,24 +48,24 @@ extern int altera_ci_tuner_reset(void *dev, int ci_nr);
48 48
49static inline int altera_ci_init(struct altera_ci_config *config, int ci_nr) 49static inline int altera_ci_init(struct altera_ci_config *config, int ci_nr)
50{ 50{
51 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 51 pr_warn("%s: driver disabled by Kconfig\n", __func__);
52 return 0; 52 return 0;
53} 53}
54 54
55static inline void altera_ci_release(void *dev, int ci_nr) 55static inline void altera_ci_release(void *dev, int ci_nr)
56{ 56{
57 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 57 pr_warn("%s: driver disabled by Kconfig\n", __func__);
58} 58}
59 59
60static inline int altera_ci_irq(void *dev) 60static inline int altera_ci_irq(void *dev)
61{ 61{
62 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 62 pr_warn("%s: driver disabled by Kconfig\n", __func__);
63 return 0; 63 return 0;
64} 64}
65 65
66static inline int altera_ci_tuner_reset(void *dev, int ci_nr) 66static inline int altera_ci_tuner_reset(void *dev, int ci_nr)
67{ 67{
68 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 68 pr_warn("%s: driver disabled by Kconfig\n", __func__);
69 return 0; 69 return 0;
70} 70}
71 71
@@ -74,19 +74,19 @@ static inline int altera_ci_tuner_reset(void *dev, int ci_nr)
74static inline int altera_hw_filt_init(struct altera_ci_config *config, 74static inline int altera_hw_filt_init(struct altera_ci_config *config,
75 int hw_filt_nr) 75 int hw_filt_nr)
76{ 76{
77 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 77 pr_warn("%s: driver disabled by Kconfig\n", __func__);
78 return 0; 78 return 0;
79} 79}
80 80
81static inline void altera_hw_filt_release(void *dev, int filt_nr) 81static inline void altera_hw_filt_release(void *dev, int filt_nr)
82{ 82{
83 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 83 pr_warn("%s: driver disabled by Kconfig\n", __func__);
84} 84}
85 85
86static inline int altera_pid_feed_control(void *dev, int filt_nr, 86static inline int altera_pid_feed_control(void *dev, int filt_nr,
87 struct dvb_demux_feed *dvbdmxfeed, int onoff) 87 struct dvb_demux_feed *dvbdmxfeed, int onoff)
88{ 88{
89 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 89 pr_warn("%s: driver disabled by Kconfig\n", __func__);
90 return 0; 90 return 0;
91} 91}
92 92
diff --git a/drivers/media/pci/cx23885/cimax2.c b/drivers/media/pci/cx23885/cimax2.c
index 631e4f24aea6..5e8e134d81c2 100644
--- a/drivers/media/pci/cx23885/cimax2.c
+++ b/drivers/media/pci/cx23885/cimax2.c
@@ -65,10 +65,11 @@ static unsigned int ci_irq_enable;
65module_param(ci_irq_enable, int, 0644); 65module_param(ci_irq_enable, int, 0644);
66MODULE_PARM_DESC(ci_irq_enable, "Enable IRQ from CAM"); 66MODULE_PARM_DESC(ci_irq_enable, "Enable IRQ from CAM");
67 67
68#define ci_dbg_print(args...) \ 68#define ci_dbg_print(fmt, args...) \
69 do { \ 69 do { \
70 if (ci_dbg) \ 70 if (ci_dbg) \
71 printk(KERN_DEBUG args); \ 71 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
72 __func__, ##args); \
72 } while (0) 73 } while (0)
73 74
74#define ci_irq_flags() (ci_irq_enable ? NETUP_IRQ_IRQAM : 0) 75#define ci_irq_flags() (ci_irq_enable ? NETUP_IRQ_IRQAM : 0)
@@ -135,8 +136,7 @@ static int netup_write_i2c(struct i2c_adapter *i2c_adap, u8 addr, u8 reg,
135 }; 136 };
136 137
137 if (1 + len > sizeof(buffer)) { 138 if (1 + len > sizeof(buffer)) {
138 printk(KERN_WARNING 139 pr_warn("%s: i2c wr reg=%04x: len=%d is too big!\n",
139 "%s: i2c wr reg=%04x: len=%d is too big!\n",
140 KBUILD_MODNAME, reg, len); 140 KBUILD_MODNAME, reg, len);
141 return -EINVAL; 141 return -EINVAL;
142 } 142 }
@@ -365,11 +365,8 @@ static void netup_read_ci_status(struct work_struct *work)
365 if (ret != 0) 365 if (ret != 0)
366 return; 366 return;
367 367
368 ci_dbg_print("%s: Slot Status Addr=[0x%04x], " 368 ci_dbg_print("%s: Slot Status Addr=[0x%04x], Reg=[0x%02x], data=%02x, TS config = %02x\n",
369 "Reg=[0x%02x], data=%02x, " 369 __func__, state->ci_i2c_addr, 0, buf[0], buf[0]);
370 "TS config = %02x\n", __func__,
371 state->ci_i2c_addr, 0, buf[0],
372 buf[0]);
373 370
374 371
375 if (buf[0] & 1) 372 if (buf[0] & 1)
diff --git a/drivers/media/pci/cx23885/cx23885-417.c b/drivers/media/pci/cx23885/cx23885-417.c
index da892f3e3c29..2ff1d1e274be 100644
--- a/drivers/media/pci/cx23885/cx23885-417.c
+++ b/drivers/media/pci/cx23885/cx23885-417.c
@@ -20,6 +20,9 @@
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 */ 21 */
22 22
23#include "cx23885.h"
24#include "cx23885-ioctl.h"
25
23#include <linux/module.h> 26#include <linux/module.h>
24#include <linux/moduleparam.h> 27#include <linux/moduleparam.h>
25#include <linux/init.h> 28#include <linux/init.h>
@@ -32,9 +35,6 @@
32#include <media/v4l2-ioctl.h> 35#include <media/v4l2-ioctl.h>
33#include <media/drv-intf/cx2341x.h> 36#include <media/drv-intf/cx2341x.h>
34 37
35#include "cx23885.h"
36#include "cx23885-ioctl.h"
37
38#define CX23885_FIRM_IMAGE_SIZE 376836 38#define CX23885_FIRM_IMAGE_SIZE 376836
39#define CX23885_FIRM_IMAGE_NAME "v4l-cx23885-enc.fw" 39#define CX23885_FIRM_IMAGE_NAME "v4l-cx23885-enc.fw"
40 40
@@ -55,8 +55,8 @@ MODULE_PARM_DESC(v4l_debug, "enable V4L debug messages");
55 55
56#define dprintk(level, fmt, arg...)\ 56#define dprintk(level, fmt, arg...)\
57 do { if (v4l_debug >= level) \ 57 do { if (v4l_debug >= level) \
58 printk(KERN_DEBUG "%s: " fmt, \ 58 printk(KERN_DEBUG pr_fmt("%s: 417:" fmt), \
59 (dev) ? dev->name : "cx23885[?]", ## arg); \ 59 __func__, ##arg); \
60 } while (0) 60 } while (0)
61 61
62static struct cx23885_tvnorm cx23885_tvnorms[] = { 62static struct cx23885_tvnorm cx23885_tvnorms[] = {
@@ -769,10 +769,8 @@ static int cx23885_mbox_func(void *priv,
769 without side effects */ 769 without side effects */
770 mc417_memory_read(dev, dev->cx23417_mailbox - 4, &value); 770 mc417_memory_read(dev, dev->cx23417_mailbox - 4, &value);
771 if (value != 0x12345678) { 771 if (value != 0x12345678) {
772 printk(KERN_ERR 772 pr_err("Firmware and/or mailbox pointer not initialized or corrupted, signature = 0x%x, cmd = %s\n",
773 "Firmware and/or mailbox pointer not initialized " 773 value, cmd_to_str(command));
774 "or corrupted, signature = 0x%x, cmd = %s\n", value,
775 cmd_to_str(command));
776 return -1; 774 return -1;
777 } 775 }
778 776
@@ -781,8 +779,8 @@ static int cx23885_mbox_func(void *priv,
781 */ 779 */
782 mc417_memory_read(dev, dev->cx23417_mailbox, &flag); 780 mc417_memory_read(dev, dev->cx23417_mailbox, &flag);
783 if (flag) { 781 if (flag) {
784 printk(KERN_ERR "ERROR: Mailbox appears to be in use " 782 pr_err("ERROR: Mailbox appears to be in use (%x), cmd = %s\n",
785 "(%x), cmd = %s\n", flag, cmd_to_str(command)); 783 flag, cmd_to_str(command));
786 return -1; 784 return -1;
787 } 785 }
788 786
@@ -811,7 +809,7 @@ static int cx23885_mbox_func(void *priv,
811 if (0 != (flag & 4)) 809 if (0 != (flag & 4))
812 break; 810 break;
813 if (time_after(jiffies, timeout)) { 811 if (time_after(jiffies, timeout)) {
814 printk(KERN_ERR "ERROR: API Mailbox timeout\n"); 812 pr_err("ERROR: API Mailbox timeout\n");
815 return -1; 813 return -1;
816 } 814 }
817 udelay(10); 815 udelay(10);
@@ -888,7 +886,7 @@ static int cx23885_find_mailbox(struct cx23885_dev *dev)
888 return i+1; 886 return i+1;
889 } 887 }
890 } 888 }
891 printk(KERN_ERR "Mailbox signature values not found!\n"); 889 pr_err("Mailbox signature values not found!\n");
892 return -1; 890 return -1;
893} 891}
894 892
@@ -923,7 +921,7 @@ static int cx23885_load_firmware(struct cx23885_dev *dev)
923 IVTV_REG_APU, 0); 921 IVTV_REG_APU, 0);
924 922
925 if (retval != 0) { 923 if (retval != 0) {
926 printk(KERN_ERR "%s: Error with mc417_register_write\n", 924 pr_err("%s: Error with mc417_register_write\n",
927 __func__); 925 __func__);
928 return -1; 926 return -1;
929 } 927 }
@@ -932,25 +930,21 @@ static int cx23885_load_firmware(struct cx23885_dev *dev)
932 &dev->pci->dev); 930 &dev->pci->dev);
933 931
934 if (retval != 0) { 932 if (retval != 0) {
935 printk(KERN_ERR 933 pr_err("ERROR: Hotplug firmware request failed (%s).\n",
936 "ERROR: Hotplug firmware request failed (%s).\n", 934 CX23885_FIRM_IMAGE_NAME);
937 CX23885_FIRM_IMAGE_NAME); 935 pr_err("Please fix your hotplug setup, the board will not work without firmware loaded!\n");
938 printk(KERN_ERR "Please fix your hotplug setup, the board will "
939 "not work without firmware loaded!\n");
940 return -1; 936 return -1;
941 } 937 }
942 938
943 if (firmware->size != CX23885_FIRM_IMAGE_SIZE) { 939 if (firmware->size != CX23885_FIRM_IMAGE_SIZE) {
944 printk(KERN_ERR "ERROR: Firmware size mismatch " 940 pr_err("ERROR: Firmware size mismatch (have %zu, expected %d)\n",
945 "(have %zu, expected %d)\n", 941 firmware->size, CX23885_FIRM_IMAGE_SIZE);
946 firmware->size, CX23885_FIRM_IMAGE_SIZE);
947 release_firmware(firmware); 942 release_firmware(firmware);
948 return -1; 943 return -1;
949 } 944 }
950 945
951 if (0 != memcmp(firmware->data, magic, 8)) { 946 if (0 != memcmp(firmware->data, magic, 8)) {
952 printk(KERN_ERR 947 pr_err("ERROR: Firmware magic mismatch, wrong file?\n");
953 "ERROR: Firmware magic mismatch, wrong file?\n");
954 release_firmware(firmware); 948 release_firmware(firmware);
955 return -1; 949 return -1;
956 } 950 }
@@ -962,7 +956,7 @@ static int cx23885_load_firmware(struct cx23885_dev *dev)
962 value = *dataptr; 956 value = *dataptr;
963 checksum += ~value; 957 checksum += ~value;
964 if (mc417_memory_write(dev, i, value) != 0) { 958 if (mc417_memory_write(dev, i, value) != 0) {
965 printk(KERN_ERR "ERROR: Loading firmware failed!\n"); 959 pr_err("ERROR: Loading firmware failed!\n");
966 release_firmware(firmware); 960 release_firmware(firmware);
967 return -1; 961 return -1;
968 } 962 }
@@ -973,15 +967,14 @@ static int cx23885_load_firmware(struct cx23885_dev *dev)
973 dprintk(1, "Verifying firmware ...\n"); 967 dprintk(1, "Verifying firmware ...\n");
974 for (i--; i >= 0; i--) { 968 for (i--; i >= 0; i--) {
975 if (mc417_memory_read(dev, i, &value) != 0) { 969 if (mc417_memory_read(dev, i, &value) != 0) {
976 printk(KERN_ERR "ERROR: Reading firmware failed!\n"); 970 pr_err("ERROR: Reading firmware failed!\n");
977 release_firmware(firmware); 971 release_firmware(firmware);
978 return -1; 972 return -1;
979 } 973 }
980 checksum -= ~value; 974 checksum -= ~value;
981 } 975 }
982 if (checksum) { 976 if (checksum) {
983 printk(KERN_ERR 977 pr_err("ERROR: Firmware load failed (checksum mismatch).\n");
984 "ERROR: Firmware load failed (checksum mismatch).\n");
985 release_firmware(firmware); 978 release_firmware(firmware);
986 return -1; 979 return -1;
987 } 980 }
@@ -1006,7 +999,7 @@ static int cx23885_load_firmware(struct cx23885_dev *dev)
1006 mc417_register_read(dev, 0x900C, &gpio_value); 999 mc417_register_read(dev, 0x900C, &gpio_value);
1007 1000
1008 if (retval < 0) 1001 if (retval < 0)
1009 printk(KERN_ERR "%s: Error with mc417_register_write\n", 1002 pr_err("%s: Error with mc417_register_write\n",
1010 __func__); 1003 __func__);
1011 return 0; 1004 return 0;
1012} 1005}
@@ -1058,27 +1051,25 @@ static int cx23885_initialize_codec(struct cx23885_dev *dev, int startencoder)
1058 dprintk(2, "%s() PING OK\n", __func__); 1051 dprintk(2, "%s() PING OK\n", __func__);
1059 retval = cx23885_load_firmware(dev); 1052 retval = cx23885_load_firmware(dev);
1060 if (retval < 0) { 1053 if (retval < 0) {
1061 printk(KERN_ERR "%s() f/w load failed\n", __func__); 1054 pr_err("%s() f/w load failed\n", __func__);
1062 return retval; 1055 return retval;
1063 } 1056 }
1064 retval = cx23885_find_mailbox(dev); 1057 retval = cx23885_find_mailbox(dev);
1065 if (retval < 0) { 1058 if (retval < 0) {
1066 printk(KERN_ERR "%s() mailbox < 0, error\n", 1059 pr_err("%s() mailbox < 0, error\n",
1067 __func__); 1060 __func__);
1068 return -1; 1061 return -1;
1069 } 1062 }
1070 dev->cx23417_mailbox = retval; 1063 dev->cx23417_mailbox = retval;
1071 retval = cx23885_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); 1064 retval = cx23885_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0);
1072 if (retval < 0) { 1065 if (retval < 0) {
1073 printk(KERN_ERR 1066 pr_err("ERROR: cx23417 firmware ping failed!\n");
1074 "ERROR: cx23417 firmware ping failed!\n");
1075 return -1; 1067 return -1;
1076 } 1068 }
1077 retval = cx23885_api_cmd(dev, CX2341X_ENC_GET_VERSION, 0, 1, 1069 retval = cx23885_api_cmd(dev, CX2341X_ENC_GET_VERSION, 0, 1,
1078 &version); 1070 &version);
1079 if (retval < 0) { 1071 if (retval < 0) {
1080 printk(KERN_ERR "ERROR: cx23417 firmware get encoder :" 1072 pr_err("ERROR: cx23417 firmware get encoder :version failed!\n");
1081 "version failed!\n");
1082 return -1; 1073 return -1;
1083 } 1074 }
1084 dprintk(1, "cx23417 firmware version is 0x%08x\n", version); 1075 dprintk(1, "cx23417 firmware version is 0x%08x\n", version);
@@ -1563,11 +1554,11 @@ int cx23885_417_register(struct cx23885_dev *dev)
1563 err = video_register_device(dev->v4l_device, 1554 err = video_register_device(dev->v4l_device,
1564 VFL_TYPE_GRABBER, -1); 1555 VFL_TYPE_GRABBER, -1);
1565 if (err < 0) { 1556 if (err < 0) {
1566 printk(KERN_INFO "%s: can't register mpeg device\n", dev->name); 1557 pr_info("%s: can't register mpeg device\n", dev->name);
1567 return err; 1558 return err;
1568 } 1559 }
1569 1560
1570 printk(KERN_INFO "%s: registered device %s [mpeg]\n", 1561 pr_info("%s: registered device %s [mpeg]\n",
1571 dev->name, video_device_node_name(dev->v4l_device)); 1562 dev->name, video_device_node_name(dev->v4l_device));
1572 1563
1573 /* ST: Configure the encoder paramaters, but don't begin 1564 /* ST: Configure the encoder paramaters, but don't begin
diff --git a/drivers/media/pci/cx23885/cx23885-alsa.c b/drivers/media/pci/cx23885/cx23885-alsa.c
index 6115d4e148ba..c148f9a4a9ac 100644
--- a/drivers/media/pci/cx23885/cx23885-alsa.c
+++ b/drivers/media/pci/cx23885/cx23885-alsa.c
@@ -17,6 +17,9 @@
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 */ 18 */
19 19
20#include "cx23885.h"
21#include "cx23885-reg.h"
22
20#include <linux/module.h> 23#include <linux/module.h>
21#include <linux/init.h> 24#include <linux/init.h>
22#include <linux/device.h> 25#include <linux/device.h>
@@ -35,20 +38,14 @@
35 38
36#include <sound/tlv.h> 39#include <sound/tlv.h>
37 40
38
39#include "cx23885.h"
40#include "cx23885-reg.h"
41
42#define AUDIO_SRAM_CHANNEL SRAM_CH07 41#define AUDIO_SRAM_CHANNEL SRAM_CH07
43 42
44#define dprintk(level, fmt, arg...) do { \ 43#define dprintk(level, fmt, arg...) do { \
45 if (audio_debug + 1 > level) \ 44 if (audio_debug + 1 > level) \
46 printk(KERN_INFO "%s: " fmt, chip->dev->name , ## arg); \ 45 printk(KERN_DEBUG pr_fmt("%s: alsa: " fmt), \
46 chip->dev->name, ##arg); \
47} while(0) 47} while(0)
48 48
49#define dprintk_core(level, fmt, arg...) if (audio_debug >= level) \
50 printk(KERN_DEBUG "%s: " fmt, chip->dev->name , ## arg)
51
52/**************************************************************************** 49/****************************************************************************
53 Module global static vars 50 Module global static vars
54 ****************************************************************************/ 51 ****************************************************************************/
@@ -186,8 +183,8 @@ static int cx23885_start_audio_dma(struct cx23885_audio_dev *chip)
186 cx_write(AUD_INT_A_GPCNT_CTL, GP_COUNT_CONTROL_RESET); 183 cx_write(AUD_INT_A_GPCNT_CTL, GP_COUNT_CONTROL_RESET);
187 atomic_set(&chip->count, 0); 184 atomic_set(&chip->count, 0);
188 185
189 dprintk(1, "Start audio DMA, %d B/line, %d lines/FIFO, %d periods, %d " 186 dprintk(1, "Start audio DMA, %d B/line, %d lines/FIFO, %d periods, %d byte buffer\n",
190 "byte buffer\n", buf->bpl, cx_read(audio_ch->cmds_start+12)>>1, 187 buf->bpl, cx_read(audio_ch->cmds_start+12)>>1,
191 chip->num_periods, buf->bpl * chip->num_periods); 188 chip->num_periods, buf->bpl * chip->num_periods);
192 189
193 /* Enables corresponding bits at AUD_INT_STAT */ 190 /* Enables corresponding bits at AUD_INT_STAT */
@@ -247,7 +244,7 @@ int cx23885_audio_irq(struct cx23885_dev *dev, u32 status, u32 mask)
247 244
248 /* risc op code error */ 245 /* risc op code error */
249 if (status & AUD_INT_OPC_ERR) { 246 if (status & AUD_INT_OPC_ERR) {
250 printk(KERN_WARNING "%s/1: Audio risc op code error\n", 247 pr_warn("%s/1: Audio risc op code error\n",
251 dev->name); 248 dev->name);
252 cx_clear(AUD_INT_DMA_CTL, 0x11); 249 cx_clear(AUD_INT_DMA_CTL, 0x11);
253 cx23885_sram_channel_dump(dev, 250 cx23885_sram_channel_dump(dev,
@@ -327,8 +324,7 @@ static int snd_cx23885_pcm_open(struct snd_pcm_substream *substream)
327 int err; 324 int err;
328 325
329 if (!chip) { 326 if (!chip) {
330 printk(KERN_ERR "BUG: cx23885 can't find device struct." 327 pr_err("BUG: cx23885 can't find device struct. Can't proceed with open\n");
331 " Can't proceed with open\n");
332 return -ENODEV; 328 return -ENODEV;
333 } 329 }
334 330
@@ -555,8 +551,8 @@ struct cx23885_audio_dev *cx23885_audio_register(struct cx23885_dev *dev)
555 return NULL; 551 return NULL;
556 552
557 if (dev->sram_channels[AUDIO_SRAM_CHANNEL].cmds_start == 0) { 553 if (dev->sram_channels[AUDIO_SRAM_CHANNEL].cmds_start == 0) {
558 printk(KERN_WARNING "%s(): Missing SRAM channel configuration " 554 pr_warn("%s(): Missing SRAM channel configuration for analog TV Audio\n",
559 "for analog TV Audio\n", __func__); 555 __func__);
560 return NULL; 556 return NULL;
561 } 557 }
562 558
@@ -590,8 +586,8 @@ struct cx23885_audio_dev *cx23885_audio_register(struct cx23885_dev *dev)
590 586
591error: 587error:
592 snd_card_free(card); 588 snd_card_free(card);
593 printk(KERN_ERR "%s(): Failed to register analog " 589 pr_err("%s(): Failed to register analog audio adapter\n",
594 "audio adapter\n", __func__); 590 __func__);
595 591
596 return NULL; 592 return NULL;
597} 593}
diff --git a/drivers/media/pci/cx23885/cx23885-cards.c b/drivers/media/pci/cx23885/cx23885-cards.c
index 99ba8d6328f0..0350f13c5a9f 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -15,6 +15,8 @@
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 */ 16 */
17 17
18#include "cx23885.h"
19
18#include <linux/init.h> 20#include <linux/init.h>
19#include <linux/module.h> 21#include <linux/module.h>
20#include <linux/pci.h> 22#include <linux/pci.h>
@@ -23,7 +25,6 @@
23#include <linux/firmware.h> 25#include <linux/firmware.h>
24#include <misc/altera.h> 26#include <misc/altera.h>
25 27
26#include "cx23885.h"
27#include "tuner-xc2028.h" 28#include "tuner-xc2028.h"
28#include "netup-eeprom.h" 29#include "netup-eeprom.h"
29#include "netup-init.h" 30#include "netup-init.h"
@@ -1096,26 +1097,24 @@ void cx23885_card_list(struct cx23885_dev *dev)
1096 1097
1097 if (0 == dev->pci->subsystem_vendor && 1098 if (0 == dev->pci->subsystem_vendor &&
1098 0 == dev->pci->subsystem_device) { 1099 0 == dev->pci->subsystem_device) {
1099 printk(KERN_INFO 1100 pr_info("%s: Board has no valid PCIe Subsystem ID and can't\n"
1100 "%s: Board has no valid PCIe Subsystem ID and can't\n" 1101 "%s: be autodetected. Pass card=<n> insmod option\n"
1101 "%s: be autodetected. Pass card=<n> insmod option\n" 1102 "%s: to workaround that. Redirect complaints to the\n"
1102 "%s: to workaround that. Redirect complaints to the\n" 1103 "%s: vendor of the TV card. Best regards,\n"
1103 "%s: vendor of the TV card. Best regards,\n" 1104 "%s: -- tux\n",
1104 "%s: -- tux\n", 1105 dev->name, dev->name, dev->name, dev->name, dev->name);
1105 dev->name, dev->name, dev->name, dev->name, dev->name);
1106 } else { 1106 } else {
1107 printk(KERN_INFO 1107 pr_info("%s: Your board isn't known (yet) to the driver.\n"
1108 "%s: Your board isn't known (yet) to the driver.\n" 1108 "%s: Try to pick one of the existing card configs via\n"
1109 "%s: Try to pick one of the existing card configs via\n" 1109 "%s: card=<n> insmod option. Updating to the latest\n"
1110 "%s: card=<n> insmod option. Updating to the latest\n" 1110 "%s: version might help as well.\n",
1111 "%s: version might help as well.\n", 1111 dev->name, dev->name, dev->name, dev->name);
1112 dev->name, dev->name, dev->name, dev->name);
1113 } 1112 }
1114 printk(KERN_INFO "%s: Here is a list of valid choices for the card=<n> insmod option:\n", 1113 pr_info("%s: Here is a list of valid choices for the card=<n> insmod option:\n",
1115 dev->name); 1114 dev->name);
1116 for (i = 0; i < cx23885_bcount; i++) 1115 for (i = 0; i < cx23885_bcount; i++)
1117 printk(KERN_INFO "%s: card=%d -> %s\n", 1116 pr_info("%s: card=%d -> %s\n",
1118 dev->name, i, cx23885_boards[i].name); 1117 dev->name, i, cx23885_boards[i].name);
1119} 1118}
1120 1119
1121static void viewcast_eeprom(struct cx23885_dev *dev, u8 *eeprom_data) 1120static void viewcast_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
@@ -1304,14 +1303,13 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
1304 */ 1303 */
1305 break; 1304 break;
1306 default: 1305 default:
1307 printk(KERN_WARNING "%s: warning: " 1306 pr_warn("%s: warning: unknown hauppauge model #%d\n",
1308 "unknown hauppauge model #%d\n",
1309 dev->name, tv.model); 1307 dev->name, tv.model);
1310 break; 1308 break;
1311 } 1309 }
1312 1310
1313 printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n", 1311 pr_info("%s: hauppauge eeprom: model=%d\n",
1314 dev->name, tv.model); 1312 dev->name, tv.model);
1315} 1313}
1316 1314
1317/* Some TBS cards require initing a chip using a bitbanged SPI attached 1315/* Some TBS cards require initing a chip using a bitbanged SPI attached
@@ -1353,8 +1351,8 @@ int cx23885_tuner_callback(void *priv, int component, int command, int arg)
1353 return 0; 1351 return 0;
1354 1352
1355 if (command != 0) { 1353 if (command != 0) {
1356 printk(KERN_ERR "%s(): Unknown command 0x%x.\n", 1354 pr_err("%s(): Unknown command 0x%x.\n",
1357 __func__, command); 1355 __func__, command);
1358 return -EINVAL; 1356 return -EINVAL;
1359 } 1357 }
1360 1358
@@ -2337,14 +2335,13 @@ void cx23885_card_setup(struct cx23885_dev *dev)
2337 filename = "dvb-netup-altera-01.fw"; 2335 filename = "dvb-netup-altera-01.fw";
2338 break; 2336 break;
2339 } 2337 }
2340 printk(KERN_INFO "NetUP card rev=0x%x fw_filename=%s\n", 2338 pr_info("NetUP card rev=0x%x fw_filename=%s\n",
2341 cinfo.rev, filename); 2339 cinfo.rev, filename);
2342 2340
2343 ret = request_firmware(&fw, filename, &dev->pci->dev); 2341 ret = request_firmware(&fw, filename, &dev->pci->dev);
2344 if (ret != 0) 2342 if (ret != 0)
2345 printk(KERN_ERR "did not find the firmware file. (%s) " 2343 pr_err("did not find the firmware file. (%s) Please see linux/Documentation/dvb/ for more details on firmware-problems.",
2346 "Please see linux/Documentation/dvb/ for more details " 2344 filename);
2347 "on firmware-problems.", filename);
2348 else 2345 else
2349 altera_init(&netup_config, fw); 2346 altera_init(&netup_config, fw);
2350 2347
diff --git a/drivers/media/pci/cx23885/cx23885-core.c b/drivers/media/pci/cx23885/cx23885-core.c
index c86b1093ab99..02b5ec549369 100644
--- a/drivers/media/pci/cx23885/cx23885-core.c
+++ b/drivers/media/pci/cx23885/cx23885-core.c
@@ -15,6 +15,8 @@
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 */ 16 */
17 17
18#include "cx23885.h"
19
18#include <linux/init.h> 20#include <linux/init.h>
19#include <linux/list.h> 21#include <linux/list.h>
20#include <linux/module.h> 22#include <linux/module.h>
@@ -27,7 +29,6 @@
27#include <asm/div64.h> 29#include <asm/div64.h>
28#include <linux/firmware.h> 30#include <linux/firmware.h>
29 31
30#include "cx23885.h"
31#include "cimax2.h" 32#include "cimax2.h"
32#include "altera-ci.h" 33#include "altera-ci.h"
33#include "cx23888-ir.h" 34#include "cx23888-ir.h"
@@ -50,7 +51,8 @@ MODULE_PARM_DESC(card, "card type");
50 51
51#define dprintk(level, fmt, arg...)\ 52#define dprintk(level, fmt, arg...)\
52 do { if (debug >= level)\ 53 do { if (debug >= level)\
53 printk(KERN_DEBUG "%s: " fmt, dev->name, ## arg);\ 54 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
55 __func__, ##arg); \
54 } while (0) 56 } while (0)
55 57
56static unsigned int cx23885_devcount; 58static unsigned int cx23885_devcount;
@@ -407,19 +409,18 @@ static int cx23885_risc_decode(u32 risc)
407 }; 409 };
408 int i; 410 int i;
409 411
410 printk("0x%08x [ %s", risc, 412 printk(KERN_DEBUG "0x%08x [ %s", risc,
411 instr[risc >> 28] ? instr[risc >> 28] : "INVALID"); 413 instr[risc >> 28] ? instr[risc >> 28] : "INVALID");
412 for (i = ARRAY_SIZE(bits) - 1; i >= 0; i--) 414 for (i = ARRAY_SIZE(bits) - 1; i >= 0; i--)
413 if (risc & (1 << (i + 12))) 415 if (risc & (1 << (i + 12)))
414 printk(" %s", bits[i]); 416 pr_cont(" %s", bits[i]);
415 printk(" count=%d ]\n", risc & 0xfff); 417 pr_cont(" count=%d ]\n", risc & 0xfff);
416 return incr[risc >> 28] ? incr[risc >> 28] : 1; 418 return incr[risc >> 28] ? incr[risc >> 28] : 1;
417} 419}
418 420
419static void cx23885_wakeup(struct cx23885_tsport *port, 421static void cx23885_wakeup(struct cx23885_tsport *port,
420 struct cx23885_dmaqueue *q, u32 count) 422 struct cx23885_dmaqueue *q, u32 count)
421{ 423{
422 struct cx23885_dev *dev = port->dev;
423 struct cx23885_buffer *buf; 424 struct cx23885_buffer *buf;
424 425
425 if (list_empty(&q->active)) 426 if (list_empty(&q->active))
@@ -530,44 +531,44 @@ void cx23885_sram_channel_dump(struct cx23885_dev *dev,
530 u32 risc; 531 u32 risc;
531 unsigned int i, j, n; 532 unsigned int i, j, n;
532 533
533 printk(KERN_WARNING "%s: %s - dma channel status dump\n", 534 pr_warn("%s: %s - dma channel status dump\n",
534 dev->name, ch->name); 535 dev->name, ch->name);
535 for (i = 0; i < ARRAY_SIZE(name); i++) 536 for (i = 0; i < ARRAY_SIZE(name); i++)
536 printk(KERN_WARNING "%s: cmds: %-15s: 0x%08x\n", 537 pr_warn("%s: cmds: %-15s: 0x%08x\n",
537 dev->name, name[i], 538 dev->name, name[i],
538 cx_read(ch->cmds_start + 4*i)); 539 cx_read(ch->cmds_start + 4*i));
539 540
540 for (i = 0; i < 4; i++) { 541 for (i = 0; i < 4; i++) {
541 risc = cx_read(ch->cmds_start + 4 * (i + 14)); 542 risc = cx_read(ch->cmds_start + 4 * (i + 14));
542 printk(KERN_WARNING "%s: risc%d: ", dev->name, i); 543 pr_warn("%s: risc%d: ", dev->name, i);
543 cx23885_risc_decode(risc); 544 cx23885_risc_decode(risc);
544 } 545 }
545 for (i = 0; i < (64 >> 2); i += n) { 546 for (i = 0; i < (64 >> 2); i += n) {
546 risc = cx_read(ch->ctrl_start + 4 * i); 547 risc = cx_read(ch->ctrl_start + 4 * i);
547 /* No consideration for bits 63-32 */ 548 /* No consideration for bits 63-32 */
548 549
549 printk(KERN_WARNING "%s: (0x%08x) iq %x: ", dev->name, 550 pr_warn("%s: (0x%08x) iq %x: ", dev->name,
550 ch->ctrl_start + 4 * i, i); 551 ch->ctrl_start + 4 * i, i);
551 n = cx23885_risc_decode(risc); 552 n = cx23885_risc_decode(risc);
552 for (j = 1; j < n; j++) { 553 for (j = 1; j < n; j++) {
553 risc = cx_read(ch->ctrl_start + 4 * (i + j)); 554 risc = cx_read(ch->ctrl_start + 4 * (i + j));
554 printk(KERN_WARNING "%s: iq %x: 0x%08x [ arg #%d ]\n", 555 pr_warn("%s: iq %x: 0x%08x [ arg #%d ]\n",
555 dev->name, i+j, risc, j); 556 dev->name, i+j, risc, j);
556 } 557 }
557 } 558 }
558 559
559 printk(KERN_WARNING "%s: fifo: 0x%08x -> 0x%x\n", 560 pr_warn("%s: fifo: 0x%08x -> 0x%x\n",
560 dev->name, ch->fifo_start, ch->fifo_start+ch->fifo_size); 561 dev->name, ch->fifo_start, ch->fifo_start+ch->fifo_size);
561 printk(KERN_WARNING "%s: ctrl: 0x%08x -> 0x%x\n", 562 pr_warn("%s: ctrl: 0x%08x -> 0x%x\n",
562 dev->name, ch->ctrl_start, ch->ctrl_start + 6*16); 563 dev->name, ch->ctrl_start, ch->ctrl_start + 6*16);
563 printk(KERN_WARNING "%s: ptr1_reg: 0x%08x\n", 564 pr_warn("%s: ptr1_reg: 0x%08x\n",
564 dev->name, cx_read(ch->ptr1_reg)); 565 dev->name, cx_read(ch->ptr1_reg));
565 printk(KERN_WARNING "%s: ptr2_reg: 0x%08x\n", 566 pr_warn("%s: ptr2_reg: 0x%08x\n",
566 dev->name, cx_read(ch->ptr2_reg)); 567 dev->name, cx_read(ch->ptr2_reg));
567 printk(KERN_WARNING "%s: cnt1_reg: 0x%08x\n", 568 pr_warn("%s: cnt1_reg: 0x%08x\n",
568 dev->name, cx_read(ch->cnt1_reg)); 569 dev->name, cx_read(ch->cnt1_reg));
569 printk(KERN_WARNING "%s: cnt2_reg: 0x%08x\n", 570 pr_warn("%s: cnt2_reg: 0x%08x\n",
570 dev->name, cx_read(ch->cnt2_reg)); 571 dev->name, cx_read(ch->cnt2_reg));
571} 572}
572 573
573static void cx23885_risc_disasm(struct cx23885_tsport *port, 574static void cx23885_risc_disasm(struct cx23885_tsport *port,
@@ -576,14 +577,14 @@ static void cx23885_risc_disasm(struct cx23885_tsport *port,
576 struct cx23885_dev *dev = port->dev; 577 struct cx23885_dev *dev = port->dev;
577 unsigned int i, j, n; 578 unsigned int i, j, n;
578 579
579 printk(KERN_INFO "%s: risc disasm: %p [dma=0x%08lx]\n", 580 pr_info("%s: risc disasm: %p [dma=0x%08lx]\n",
580 dev->name, risc->cpu, (unsigned long)risc->dma); 581 dev->name, risc->cpu, (unsigned long)risc->dma);
581 for (i = 0; i < (risc->size >> 2); i += n) { 582 for (i = 0; i < (risc->size >> 2); i += n) {
582 printk(KERN_INFO "%s: %04d: ", dev->name, i); 583 pr_info("%s: %04d: ", dev->name, i);
583 n = cx23885_risc_decode(le32_to_cpu(risc->cpu[i])); 584 n = cx23885_risc_decode(le32_to_cpu(risc->cpu[i]));
584 for (j = 1; j < n; j++) 585 for (j = 1; j < n; j++)
585 printk(KERN_INFO "%s: %04d: 0x%08x [ arg #%d ]\n", 586 pr_info("%s: %04d: 0x%08x [ arg #%d ]\n",
586 dev->name, i + j, risc->cpu[i + j], j); 587 dev->name, i + j, risc->cpu[i + j], j);
587 if (risc->cpu[i] == cpu_to_le32(RISC_JUMP)) 588 if (risc->cpu[i] == cpu_to_le32(RISC_JUMP))
588 break; 589 break;
589 } 590 }
@@ -674,8 +675,8 @@ static int get_resources(struct cx23885_dev *dev)
674 dev->name)) 675 dev->name))
675 return 0; 676 return 0;
676 677
677 printk(KERN_ERR "%s: can't get MMIO memory @ 0x%llx\n", 678 pr_err("%s: can't get MMIO memory @ 0x%llx\n",
678 dev->name, (unsigned long long)pci_resource_start(dev->pci, 0)); 679 dev->name, (unsigned long long)pci_resource_start(dev->pci, 0));
679 680
680 return -EBUSY; 681 return -EBUSY;
681} 682}
@@ -793,15 +794,15 @@ static void cx23885_dev_checkrevision(struct cx23885_dev *dev)
793 dev->hwrevision = 0xb1; 794 dev->hwrevision = 0xb1;
794 break; 795 break;
795 default: 796 default:
796 printk(KERN_ERR "%s() New hardware revision found 0x%x\n", 797 pr_err("%s() New hardware revision found 0x%x\n",
797 __func__, dev->hwrevision); 798 __func__, dev->hwrevision);
798 } 799 }
799 if (dev->hwrevision) 800 if (dev->hwrevision)
800 printk(KERN_INFO "%s() Hardware revision = 0x%02x\n", 801 pr_info("%s() Hardware revision = 0x%02x\n",
801 __func__, dev->hwrevision); 802 __func__, dev->hwrevision);
802 else 803 else
803 printk(KERN_ERR "%s() Hardware revision unknown 0x%x\n", 804 pr_err("%s() Hardware revision unknown 0x%x\n",
804 __func__, dev->hwrevision); 805 __func__, dev->hwrevision);
805} 806}
806 807
807/* Find the first v4l2_subdev member of the group id in hw */ 808/* Find the first v4l2_subdev member of the group id in hw */
@@ -915,8 +916,7 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
915 cx23885_init_tsport(dev, &dev->ts2, 2); 916 cx23885_init_tsport(dev, &dev->ts2, 2);
916 917
917 if (get_resources(dev) < 0) { 918 if (get_resources(dev) < 0) {
918 printk(KERN_ERR "CORE %s No more PCIe resources for " 919 pr_err("CORE %s No more PCIe resources for subsystem: %04x:%04x\n",
919 "subsystem: %04x:%04x\n",
920 dev->name, dev->pci->subsystem_vendor, 920 dev->name, dev->pci->subsystem_vendor,
921 dev->pci->subsystem_device); 921 dev->pci->subsystem_device);
922 922
@@ -930,11 +930,11 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
930 930
931 dev->bmmio = (u8 __iomem *)dev->lmmio; 931 dev->bmmio = (u8 __iomem *)dev->lmmio;
932 932
933 printk(KERN_INFO "CORE %s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n", 933 pr_info("CORE %s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n",
934 dev->name, dev->pci->subsystem_vendor, 934 dev->name, dev->pci->subsystem_vendor,
935 dev->pci->subsystem_device, cx23885_boards[dev->board].name, 935 dev->pci->subsystem_device, cx23885_boards[dev->board].name,
936 dev->board, card[dev->nr] == dev->board ? 936 dev->board, card[dev->nr] == dev->board ?
937 "insmod option" : "autodetected"); 937 "insmod option" : "autodetected");
938 938
939 cx23885_pci_quirks(dev); 939 cx23885_pci_quirks(dev);
940 940
@@ -980,8 +980,8 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
980 980
981 if (cx23885_boards[dev->board].porta == CX23885_ANALOG_VIDEO) { 981 if (cx23885_boards[dev->board].porta == CX23885_ANALOG_VIDEO) {
982 if (cx23885_video_register(dev) < 0) { 982 if (cx23885_video_register(dev) < 0) {
983 printk(KERN_ERR "%s() Failed to register analog " 983 pr_err("%s() Failed to register analog video adapters on VID_A\n",
984 "video adapters on VID_A\n", __func__); 984 __func__);
985 } 985 }
986 } 986 }
987 987
@@ -990,14 +990,13 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
990 dev->ts1.num_frontends = 990 dev->ts1.num_frontends =
991 cx23885_boards[dev->board].num_fds_portb; 991 cx23885_boards[dev->board].num_fds_portb;
992 if (cx23885_dvb_register(&dev->ts1) < 0) { 992 if (cx23885_dvb_register(&dev->ts1) < 0) {
993 printk(KERN_ERR "%s() Failed to register dvb adapters on VID_B\n", 993 pr_err("%s() Failed to register dvb adapters on VID_B\n",
994 __func__); 994 __func__);
995 } 995 }
996 } else 996 } else
997 if (cx23885_boards[dev->board].portb == CX23885_MPEG_ENCODER) { 997 if (cx23885_boards[dev->board].portb == CX23885_MPEG_ENCODER) {
998 if (cx23885_417_register(dev) < 0) { 998 if (cx23885_417_register(dev) < 0) {
999 printk(KERN_ERR 999 pr_err("%s() Failed to register 417 on VID_B\n",
1000 "%s() Failed to register 417 on VID_B\n",
1001 __func__); 1000 __func__);
1002 } 1001 }
1003 } 1002 }
@@ -1007,15 +1006,13 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
1007 dev->ts2.num_frontends = 1006 dev->ts2.num_frontends =
1008 cx23885_boards[dev->board].num_fds_portc; 1007 cx23885_boards[dev->board].num_fds_portc;
1009 if (cx23885_dvb_register(&dev->ts2) < 0) { 1008 if (cx23885_dvb_register(&dev->ts2) < 0) {
1010 printk(KERN_ERR 1009 pr_err("%s() Failed to register dvb on VID_C\n",
1011 "%s() Failed to register dvb on VID_C\n",
1012 __func__); 1010 __func__);
1013 } 1011 }
1014 } else 1012 } else
1015 if (cx23885_boards[dev->board].portc == CX23885_MPEG_ENCODER) { 1013 if (cx23885_boards[dev->board].portc == CX23885_MPEG_ENCODER) {
1016 if (cx23885_417_register(dev) < 0) { 1014 if (cx23885_417_register(dev) < 0) {
1017 printk(KERN_ERR 1015 pr_err("%s() Failed to register 417 on VID_C\n",
1018 "%s() Failed to register 417 on VID_C\n",
1019 __func__); 1016 __func__);
1020 } 1017 }
1021 } 1018 }
@@ -1344,7 +1341,7 @@ int cx23885_start_dma(struct cx23885_tsport *port,
1344 1341
1345 if ((!(cx23885_boards[dev->board].portb & CX23885_MPEG_DVB)) && 1342 if ((!(cx23885_boards[dev->board].portb & CX23885_MPEG_DVB)) &&
1346 (!(cx23885_boards[dev->board].portc & CX23885_MPEG_DVB))) { 1343 (!(cx23885_boards[dev->board].portc & CX23885_MPEG_DVB))) {
1347 printk("%s() Unsupported .portb/c (0x%08x)/(0x%08x)\n", 1344 pr_err("%s() Unsupported .portb/c (0x%08x)/(0x%08x)\n",
1348 __func__, 1345 __func__,
1349 cx23885_boards[dev->board].portb, 1346 cx23885_boards[dev->board].portb,
1350 cx23885_boards[dev->board].portc); 1347 cx23885_boards[dev->board].portc);
@@ -1531,7 +1528,6 @@ void cx23885_buf_queue(struct cx23885_tsport *port, struct cx23885_buffer *buf)
1531 1528
1532static void do_cancel_buffers(struct cx23885_tsport *port, char *reason) 1529static void do_cancel_buffers(struct cx23885_tsport *port, char *reason)
1533{ 1530{
1534 struct cx23885_dev *dev = port->dev;
1535 struct cx23885_dmaqueue *q = &port->mpegq; 1531 struct cx23885_dmaqueue *q = &port->mpegq;
1536 struct cx23885_buffer *buf; 1532 struct cx23885_buffer *buf;
1537 unsigned long flags; 1533 unsigned long flags;
@@ -1551,8 +1547,6 @@ static void do_cancel_buffers(struct cx23885_tsport *port, char *reason)
1551 1547
1552void cx23885_cancel_buffers(struct cx23885_tsport *port) 1548void cx23885_cancel_buffers(struct cx23885_tsport *port)
1553{ 1549{
1554 struct cx23885_dev *dev = port->dev;
1555
1556 dprintk(1, "%s()\n", __func__); 1550 dprintk(1, "%s()\n", __func__);
1557 cx23885_stop_dma(port); 1551 cx23885_stop_dma(port);
1558 do_cancel_buffers(port, "cancel"); 1552 do_cancel_buffers(port, "cancel");
@@ -1579,8 +1573,8 @@ int cx23885_irq_417(struct cx23885_dev *dev, u32 status)
1579 (status & VID_B_MSK_VBI_SYNC) || 1573 (status & VID_B_MSK_VBI_SYNC) ||
1580 (status & VID_B_MSK_OF) || 1574 (status & VID_B_MSK_OF) ||
1581 (status & VID_B_MSK_VBI_OF)) { 1575 (status & VID_B_MSK_VBI_OF)) {
1582 printk(KERN_ERR "%s: V4L mpeg risc op code error, status " 1576 pr_err("%s: V4L mpeg risc op code error, status = 0x%x\n",
1583 "= 0x%x\n", dev->name, status); 1577 dev->name, status);
1584 if (status & VID_B_MSK_BAD_PKT) 1578 if (status & VID_B_MSK_BAD_PKT)
1585 dprintk(1, " VID_B_MSK_BAD_PKT\n"); 1579 dprintk(1, " VID_B_MSK_BAD_PKT\n");
1586 if (status & VID_B_MSK_OPC_ERR) 1580 if (status & VID_B_MSK_OPC_ERR)
@@ -1641,7 +1635,7 @@ static int cx23885_irq_ts(struct cx23885_tsport *port, u32 status)
1641 dprintk(7, " (VID_BC_MSK_OF 0x%08x)\n", 1635 dprintk(7, " (VID_BC_MSK_OF 0x%08x)\n",
1642 VID_BC_MSK_OF); 1636 VID_BC_MSK_OF);
1643 1637
1644 printk(KERN_ERR "%s: mpeg risc op code error\n", dev->name); 1638 pr_err("%s: mpeg risc op code error\n", dev->name);
1645 1639
1646 cx_clear(port->reg_dma_ctl, port->dma_ctl_val); 1640 cx_clear(port->reg_dma_ctl, port->dma_ctl_val);
1647 cx23885_sram_channel_dump(dev, 1641 cx23885_sram_channel_dump(dev,
@@ -1881,15 +1875,14 @@ void cx23885_gpio_set(struct cx23885_dev *dev, u32 mask)
1881 1875
1882 if (mask & 0x0007fff8) { 1876 if (mask & 0x0007fff8) {
1883 if (encoder_on_portb(dev) || encoder_on_portc(dev)) 1877 if (encoder_on_portb(dev) || encoder_on_portc(dev))
1884 printk(KERN_ERR 1878 pr_err("%s: Setting GPIO on encoder ports\n",
1885 "%s: Setting GPIO on encoder ports\n",
1886 dev->name); 1879 dev->name);
1887 cx_set(MC417_RWD, (mask & 0x0007fff8) >> 3); 1880 cx_set(MC417_RWD, (mask & 0x0007fff8) >> 3);
1888 } 1881 }
1889 1882
1890 /* TODO: 23-19 */ 1883 /* TODO: 23-19 */
1891 if (mask & 0x00f80000) 1884 if (mask & 0x00f80000)
1892 printk(KERN_INFO "%s: Unsupported\n", dev->name); 1885 pr_info("%s: Unsupported\n", dev->name);
1893} 1886}
1894 1887
1895void cx23885_gpio_clear(struct cx23885_dev *dev, u32 mask) 1888void cx23885_gpio_clear(struct cx23885_dev *dev, u32 mask)
@@ -1899,15 +1892,14 @@ void cx23885_gpio_clear(struct cx23885_dev *dev, u32 mask)
1899 1892
1900 if (mask & 0x0007fff8) { 1893 if (mask & 0x0007fff8) {
1901 if (encoder_on_portb(dev) || encoder_on_portc(dev)) 1894 if (encoder_on_portb(dev) || encoder_on_portc(dev))
1902 printk(KERN_ERR 1895 pr_err("%s: Clearing GPIO moving on encoder ports\n",
1903 "%s: Clearing GPIO moving on encoder ports\n",
1904 dev->name); 1896 dev->name);
1905 cx_clear(MC417_RWD, (mask & 0x7fff8) >> 3); 1897 cx_clear(MC417_RWD, (mask & 0x7fff8) >> 3);
1906 } 1898 }
1907 1899
1908 /* TODO: 23-19 */ 1900 /* TODO: 23-19 */
1909 if (mask & 0x00f80000) 1901 if (mask & 0x00f80000)
1910 printk(KERN_INFO "%s: Unsupported\n", dev->name); 1902 pr_info("%s: Unsupported\n", dev->name);
1911} 1903}
1912 1904
1913u32 cx23885_gpio_get(struct cx23885_dev *dev, u32 mask) 1905u32 cx23885_gpio_get(struct cx23885_dev *dev, u32 mask)
@@ -1917,15 +1909,14 @@ u32 cx23885_gpio_get(struct cx23885_dev *dev, u32 mask)
1917 1909
1918 if (mask & 0x0007fff8) { 1910 if (mask & 0x0007fff8) {
1919 if (encoder_on_portb(dev) || encoder_on_portc(dev)) 1911 if (encoder_on_portb(dev) || encoder_on_portc(dev))
1920 printk(KERN_ERR 1912 pr_err("%s: Reading GPIO moving on encoder ports\n",
1921 "%s: Reading GPIO moving on encoder ports\n",
1922 dev->name); 1913 dev->name);
1923 return (cx_read(MC417_RWD) & ((mask & 0x7fff8) >> 3)) << 3; 1914 return (cx_read(MC417_RWD) & ((mask & 0x7fff8) >> 3)) << 3;
1924 } 1915 }
1925 1916
1926 /* TODO: 23-19 */ 1917 /* TODO: 23-19 */
1927 if (mask & 0x00f80000) 1918 if (mask & 0x00f80000)
1928 printk(KERN_INFO "%s: Unsupported\n", dev->name); 1919 pr_info("%s: Unsupported\n", dev->name);
1929 1920
1930 return 0; 1921 return 0;
1931} 1922}
@@ -1939,8 +1930,7 @@ void cx23885_gpio_enable(struct cx23885_dev *dev, u32 mask, int asoutput)
1939 1930
1940 if (mask & 0x0007fff8) { 1931 if (mask & 0x0007fff8) {
1941 if (encoder_on_portb(dev) || encoder_on_portc(dev)) 1932 if (encoder_on_portb(dev) || encoder_on_portc(dev))
1942 printk(KERN_ERR 1933 pr_err("%s: Enabling GPIO on encoder ports\n",
1943 "%s: Enabling GPIO on encoder ports\n",
1944 dev->name); 1934 dev->name);
1945 } 1935 }
1946 1936
@@ -1995,8 +1985,8 @@ static int cx23885_initdev(struct pci_dev *pci_dev,
1995 /* print pci info */ 1985 /* print pci info */
1996 dev->pci_rev = pci_dev->revision; 1986 dev->pci_rev = pci_dev->revision;
1997 pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat); 1987 pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat);
1998 printk(KERN_INFO "%s/0: found at %s, rev: %d, irq: %d, " 1988 pr_info("%s/0: found at %s, rev: %d, irq: %d, latency: %d, mmio: 0x%llx\n",
1999 "latency: %d, mmio: 0x%llx\n", dev->name, 1989 dev->name,
2000 pci_name(pci_dev), dev->pci_rev, pci_dev->irq, 1990 pci_name(pci_dev), dev->pci_rev, pci_dev->irq,
2001 dev->pci_lat, 1991 dev->pci_lat,
2002 (unsigned long long)pci_resource_start(pci_dev, 0)); 1992 (unsigned long long)pci_resource_start(pci_dev, 0));
@@ -2004,14 +1994,14 @@ static int cx23885_initdev(struct pci_dev *pci_dev,
2004 pci_set_master(pci_dev); 1994 pci_set_master(pci_dev);
2005 err = pci_set_dma_mask(pci_dev, 0xffffffff); 1995 err = pci_set_dma_mask(pci_dev, 0xffffffff);
2006 if (err) { 1996 if (err) {
2007 printk("%s/0: Oops: no 32bit PCI DMA ???\n", dev->name); 1997 pr_err("%s/0: Oops: no 32bit PCI DMA ???\n", dev->name);
2008 goto fail_ctrl; 1998 goto fail_ctrl;
2009 } 1999 }
2010 2000
2011 err = request_irq(pci_dev->irq, cx23885_irq, 2001 err = request_irq(pci_dev->irq, cx23885_irq,
2012 IRQF_SHARED, dev->name, dev); 2002 IRQF_SHARED, dev->name, dev);
2013 if (err < 0) { 2003 if (err < 0) {
2014 printk(KERN_ERR "%s: can't get IRQ %d\n", 2004 pr_err("%s: can't get IRQ %d\n",
2015 dev->name, pci_dev->irq); 2005 dev->name, pci_dev->irq);
2016 goto fail_irq; 2006 goto fail_irq;
2017 } 2007 }
@@ -2097,7 +2087,7 @@ static struct pci_driver cx23885_pci_driver = {
2097 2087
2098static int __init cx23885_init(void) 2088static int __init cx23885_init(void)
2099{ 2089{
2100 printk(KERN_INFO "cx23885 driver version %s loaded\n", 2090 pr_info("cx23885 driver version %s loaded\n",
2101 CX23885_VERSION); 2091 CX23885_VERSION);
2102 return pci_register_driver(&cx23885_pci_driver); 2092 return pci_register_driver(&cx23885_pci_driver);
2103} 2093}
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
index 818f3c2fc98d..589a168d1df4 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -15,6 +15,8 @@
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 */ 16 */
17 17
18#include "cx23885.h"
19
18#include <linux/module.h> 20#include <linux/module.h>
19#include <linux/init.h> 21#include <linux/init.h>
20#include <linux/device.h> 22#include <linux/device.h>
@@ -23,7 +25,6 @@
23#include <linux/file.h> 25#include <linux/file.h>
24#include <linux/suspend.h> 26#include <linux/suspend.h>
25 27
26#include "cx23885.h"
27#include <media/v4l2-common.h> 28#include <media/v4l2-common.h>
28 29
29#include "dvb_ca_en50221.h" 30#include "dvb_ca_en50221.h"
@@ -80,7 +81,8 @@ static unsigned int debug;
80 81
81#define dprintk(level, fmt, arg...)\ 82#define dprintk(level, fmt, arg...)\
82 do { if (debug >= level)\ 83 do { if (debug >= level)\
83 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\ 84 printk(KERN_DEBUG pr_fmt("%s dvb: " fmt), \
85 __func__, ##arg); \
84 } while (0) 86 } while (0)
85 87
86/* ------------------------------------------------------------------ */ 88/* ------------------------------------------------------------------ */
@@ -1101,7 +1103,7 @@ static int dvb_register_ci_mac(struct cx23885_tsport *port)
1101 netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo); 1103 netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo);
1102 memcpy(port->frontends.adapter.proposed_mac, 1104 memcpy(port->frontends.adapter.proposed_mac,
1103 cinfo.port[port->nr - 1].mac, 6); 1105 cinfo.port[port->nr - 1].mac, 6);
1104 printk(KERN_INFO "NetUP Dual DVB-S2 CI card port%d MAC=%pM\n", 1106 pr_info("NetUP Dual DVB-S2 CI card port%d MAC=%pM\n",
1105 port->nr, port->frontends.adapter.proposed_mac); 1107 port->nr, port->frontends.adapter.proposed_mac);
1106 1108
1107 netup_ci_init(port); 1109 netup_ci_init(port);
@@ -1127,7 +1129,7 @@ static int dvb_register_ci_mac(struct cx23885_tsport *port)
1127 /* Read entire EEPROM */ 1129 /* Read entire EEPROM */
1128 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1; 1130 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1129 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, sizeof(eeprom)); 1131 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, sizeof(eeprom));
1130 printk(KERN_INFO "TeVii S470 MAC= %pM\n", eeprom + 0xa0); 1132 pr_info("TeVii S470 MAC= %pM\n", eeprom + 0xa0);
1131 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6); 1133 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6);
1132 return 0; 1134 return 0;
1133 } 1135 }
@@ -1144,7 +1146,7 @@ static int dvb_register_ci_mac(struct cx23885_tsport *port)
1144 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1; 1146 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1145 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, 1147 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
1146 sizeof(eeprom)); 1148 sizeof(eeprom));
1147 printk(KERN_INFO "%s port %d MAC address: %pM\n", 1149 pr_info("%s port %d MAC address: %pM\n",
1148 cx23885_boards[dev->board].name, port->nr, 1150 cx23885_boards[dev->board].name, port->nr,
1149 eeprom + 0xc0 + (port->nr-1) * 8); 1151 eeprom + 0xc0 + (port->nr-1) * 8);
1150 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0 + 1152 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0 +
@@ -1185,7 +1187,7 @@ static int dvb_register_ci_mac(struct cx23885_tsport *port)
1185 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1; 1187 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1186 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, 1188 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
1187 sizeof(eeprom)); 1189 sizeof(eeprom));
1188 printk(KERN_INFO "%s MAC address: %pM\n", 1190 pr_info("%s MAC address: %pM\n",
1189 cx23885_boards[dev->board].name, eeprom + 0xc0); 1191 cx23885_boards[dev->board].name, eeprom + 0xc0);
1190 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0, 6); 1192 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0, 6);
1191 return 0; 1193 return 0;
@@ -1464,7 +1466,7 @@ static int dvb_register(struct cx23885_tsport *port)
1464 return -ENODEV; 1466 return -ENODEV;
1465 1467
1466 if (dib7000p_ops.i2c_enumeration(&i2c_bus->i2c_adap, 1, 0x12, &dib7070p_dib7000p_config) < 0) { 1468 if (dib7000p_ops.i2c_enumeration(&i2c_bus->i2c_adap, 1, 0x12, &dib7070p_dib7000p_config) < 0) {
1467 printk(KERN_WARNING "Unable to enumerate dib7000p\n"); 1469 pr_warn("Unable to enumerate dib7000p\n");
1468 return -ENODEV; 1470 return -ENODEV;
1469 } 1471 }
1470 fe0->dvb.frontend = dib7000p_ops.init(&i2c_bus->i2c_adap, 0x80, &dib7070p_dib7000p_config); 1472 fe0->dvb.frontend = dib7000p_ops.init(&i2c_bus->i2c_adap, 0x80, &dib7070p_dib7000p_config);
@@ -1524,7 +1526,7 @@ static int dvb_register(struct cx23885_tsport *port)
1524 fe = dvb_attach(xc4000_attach, fe0->dvb.frontend, 1526 fe = dvb_attach(xc4000_attach, fe0->dvb.frontend,
1525 &dev->i2c_bus[1].i2c_adap, &cfg); 1527 &dev->i2c_bus[1].i2c_adap, &cfg);
1526 if (!fe) { 1528 if (!fe) {
1527 printk(KERN_ERR "%s/2: xc4000 attach failed\n", 1529 pr_err("%s/2: xc4000 attach failed\n",
1528 dev->name); 1530 dev->name);
1529 goto frontend_detach; 1531 goto frontend_detach;
1530 } 1532 }
@@ -1597,8 +1599,7 @@ static int dvb_register(struct cx23885_tsport *port)
1597 &i2c_bus->i2c_adap, 1599 &i2c_bus->i2c_adap,
1598 LNBH24_PCL | LNBH24_TTX, 1600 LNBH24_PCL | LNBH24_TTX,
1599 LNBH24_TEN, 0x09)) 1601 LNBH24_TEN, 0x09))
1600 printk(KERN_ERR 1602 pr_err("No LNBH24 found!\n");
1601 "No LNBH24 found!\n");
1602 1603
1603 } 1604 }
1604 } 1605 }
@@ -1618,8 +1619,7 @@ static int dvb_register(struct cx23885_tsport *port)
1618 &i2c_bus->i2c_adap, 1619 &i2c_bus->i2c_adap,
1619 LNBH24_PCL | LNBH24_TTX, 1620 LNBH24_PCL | LNBH24_TTX,
1620 LNBH24_TEN, 0x0a)) 1621 LNBH24_TEN, 0x0a))
1621 printk(KERN_ERR 1622 pr_err("No LNBH24 found!\n");
1622 "No LNBH24 found!\n");
1623 1623
1624 } 1624 }
1625 } 1625 }
@@ -2482,14 +2482,13 @@ static int dvb_register(struct cx23885_tsport *port)
2482 break; 2482 break;
2483 2483
2484 default: 2484 default:
2485 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card " 2485 pr_info("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
2486 " isn't supported yet\n", 2486 dev->name);
2487 dev->name);
2488 break; 2487 break;
2489 } 2488 }
2490 2489
2491 if ((NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend)) { 2490 if ((NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend)) {
2492 printk(KERN_ERR "%s: frontend initialization failed\n", 2491 pr_err("%s: frontend initialization failed\n",
2493 dev->name); 2492 dev->name);
2494 goto frontend_detach; 2493 goto frontend_detach;
2495 } 2494 }
@@ -2570,7 +2569,7 @@ int cx23885_dvb_register(struct cx23885_tsport *port)
2570 * are for safety, and should provide a good foundation for the 2569 * are for safety, and should provide a good foundation for the
2571 * future addition of any multi-frontend cx23885 based boards. 2570 * future addition of any multi-frontend cx23885 based boards.
2572 */ 2571 */
2573 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__, 2572 pr_info("%s() allocating %d frontend(s)\n", __func__,
2574 port->num_frontends); 2573 port->num_frontends);
2575 2574
2576 for (i = 1; i <= port->num_frontends; i++) { 2575 for (i = 1; i <= port->num_frontends; i++) {
@@ -2578,7 +2577,7 @@ int cx23885_dvb_register(struct cx23885_tsport *port)
2578 2577
2579 if (vb2_dvb_alloc_frontend( 2578 if (vb2_dvb_alloc_frontend(
2580 &port->frontends, i) == NULL) { 2579 &port->frontends, i) == NULL) {
2581 printk(KERN_ERR "%s() failed to alloc\n", __func__); 2580 pr_err("%s() failed to alloc\n", __func__);
2582 return -ENOMEM; 2581 return -ENOMEM;
2583 } 2582 }
2584 2583
@@ -2597,7 +2596,7 @@ int cx23885_dvb_register(struct cx23885_tsport *port)
2597 2596
2598 /* dvb stuff */ 2597 /* dvb stuff */
2599 /* We have to init the queue for each frontend on a port. */ 2598 /* We have to init the queue for each frontend on a port. */
2600 printk(KERN_INFO "%s: cx23885 based dvb card\n", dev->name); 2599 pr_info("%s: cx23885 based dvb card\n", dev->name);
2601 q = &fe0->dvb.dvbq; 2600 q = &fe0->dvb.dvbq;
2602 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 2601 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
2603 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ; 2602 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ;
@@ -2617,8 +2616,8 @@ int cx23885_dvb_register(struct cx23885_tsport *port)
2617 } 2616 }
2618 err = dvb_register(port); 2617 err = dvb_register(port);
2619 if (err != 0) 2618 if (err != 0)
2620 printk(KERN_ERR "%s() dvb_register failed err = %d\n", 2619 pr_err("%s() dvb_register failed err = %d\n",
2621 __func__, err); 2620 __func__, err);
2622 2621
2623 return err; 2622 return err;
2624} 2623}
diff --git a/drivers/media/pci/cx23885/cx23885-f300.c b/drivers/media/pci/cx23885/cx23885-f300.c
index a6c45eb0a105..460cb8f314b2 100644
--- a/drivers/media/pci/cx23885/cx23885-f300.c
+++ b/drivers/media/pci/cx23885/cx23885-f300.c
@@ -122,7 +122,7 @@ static u8 f300_xfer(struct dvb_frontend *fe, u8 *buf)
122 } 122 }
123 123
124 if (i > 7) { 124 if (i > 7) {
125 printk(KERN_ERR "%s: timeout, the slave no response\n", 125 pr_err("%s: timeout, the slave no response\n",
126 __func__); 126 __func__);
127 ret = 1; /* timeout, the slave no response */ 127 ret = 1; /* timeout, the slave no response */
128 } else { /* the slave not busy, prepare for getting data */ 128 } else { /* the slave not busy, prepare for getting data */
diff --git a/drivers/media/pci/cx23885/cx23885-i2c.c b/drivers/media/pci/cx23885/cx23885-i2c.c
index 61591225be9a..8528032090f2 100644
--- a/drivers/media/pci/cx23885/cx23885-i2c.c
+++ b/drivers/media/pci/cx23885/cx23885-i2c.c
@@ -15,14 +15,14 @@
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 */ 16 */
17 17
18#include "cx23885.h"
19
18#include <linux/module.h> 20#include <linux/module.h>
19#include <linux/moduleparam.h> 21#include <linux/moduleparam.h>
20#include <linux/init.h> 22#include <linux/init.h>
21#include <linux/delay.h> 23#include <linux/delay.h>
22#include <asm/io.h> 24#include <asm/io.h>
23 25
24#include "cx23885.h"
25
26#include <media/v4l2-common.h> 26#include <media/v4l2-common.h>
27 27
28static unsigned int i2c_debug; 28static unsigned int i2c_debug;
@@ -35,7 +35,8 @@ MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time");
35 35
36#define dprintk(level, fmt, arg...)\ 36#define dprintk(level, fmt, arg...)\
37 do { if (i2c_debug >= level)\ 37 do { if (i2c_debug >= level)\
38 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\ 38 printk(KERN_DEBUG pr_fmt("%s: i2c:" fmt), \
39 __func__, ##arg); \
39 } while (0) 40 } while (0)
40 41
41#define I2C_WAIT_DELAY 32 42#define I2C_WAIT_DELAY 32
@@ -119,9 +120,9 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap,
119 if (!i2c_wait_done(i2c_adap)) 120 if (!i2c_wait_done(i2c_adap))
120 goto eio; 121 goto eio;
121 if (i2c_debug) { 122 if (i2c_debug) {
122 printk(" <W %02x %02x", msg->addr << 1, msg->buf[0]); 123 printk(KERN_DEBUG " <W %02x %02x", msg->addr << 1, msg->buf[0]);
123 if (!(ctrl & I2C_NOSTOP)) 124 if (!(ctrl & I2C_NOSTOP))
124 printk(" >\n"); 125 pr_cont(" >\n");
125 } 126 }
126 127
127 for (cnt = 1; cnt < msg->len; cnt++) { 128 for (cnt = 1; cnt < msg->len; cnt++) {
@@ -141,9 +142,9 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap,
141 if (!i2c_wait_done(i2c_adap)) 142 if (!i2c_wait_done(i2c_adap))
142 goto eio; 143 goto eio;
143 if (i2c_debug) { 144 if (i2c_debug) {
144 dprintk(1, " %02x", msg->buf[cnt]); 145 pr_cont(" %02x", msg->buf[cnt]);
145 if (!(ctrl & I2C_NOSTOP)) 146 if (!(ctrl & I2C_NOSTOP))
146 dprintk(1, " >\n"); 147 pr_cont(" >\n");
147 } 148 }
148 } 149 }
149 return msg->len; 150 return msg->len;
@@ -151,7 +152,7 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap,
151 eio: 152 eio:
152 retval = -EIO; 153 retval = -EIO;
153 if (i2c_debug) 154 if (i2c_debug)
154 printk(KERN_ERR " ERR: %d\n", retval); 155 pr_err(" ERR: %d\n", retval);
155 return retval; 156 return retval;
156} 157}
157 158
@@ -212,15 +213,13 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap,
212 eio: 213 eio:
213 retval = -EIO; 214 retval = -EIO;
214 if (i2c_debug) 215 if (i2c_debug)
215 printk(KERN_ERR " ERR: %d\n", retval); 216 pr_err(" ERR: %d\n", retval);
216 return retval; 217 return retval;
217} 218}
218 219
219static int i2c_xfer(struct i2c_adapter *i2c_adap, 220static int i2c_xfer(struct i2c_adapter *i2c_adap,
220 struct i2c_msg *msgs, int num) 221 struct i2c_msg *msgs, int num)
221{ 222{
222 struct cx23885_i2c *bus = i2c_adap->algo_data;
223 struct cx23885_dev *dev = bus->dev;
224 int i, retval = 0; 223 int i, retval = 0;
225 224
226 dprintk(1, "%s(num = %d)\n", __func__, num); 225 dprintk(1, "%s(num = %d)\n", __func__, num);
@@ -302,7 +301,7 @@ static void do_i2c_scan(char *name, struct i2c_client *c)
302 rc = i2c_master_recv(c, &buf, 0); 301 rc = i2c_master_recv(c, &buf, 0);
303 if (rc < 0) 302 if (rc < 0)
304 continue; 303 continue;
305 printk(KERN_INFO "%s: i2c scan: found device @ 0x%04x [%s]\n", 304 pr_info("%s: i2c scan: found device @ 0x%04x [%s]\n",
306 name, i, i2c_devs[i] ? i2c_devs[i] : "???"); 305 name, i, i2c_devs[i] ? i2c_devs[i] : "???");
307 } 306 }
308} 307}
@@ -330,12 +329,12 @@ int cx23885_i2c_register(struct cx23885_i2c *bus)
330 if (0 == bus->i2c_rc) { 329 if (0 == bus->i2c_rc) {
331 dprintk(1, "%s: i2c bus %d registered\n", dev->name, bus->nr); 330 dprintk(1, "%s: i2c bus %d registered\n", dev->name, bus->nr);
332 if (i2c_scan) { 331 if (i2c_scan) {
333 printk(KERN_INFO "%s: scan bus %d:\n", 332 pr_info("%s: scan bus %d:\n",
334 dev->name, bus->nr); 333 dev->name, bus->nr);
335 do_i2c_scan(dev->name, &bus->i2c_client); 334 do_i2c_scan(dev->name, &bus->i2c_client);
336 } 335 }
337 } else 336 } else
338 printk(KERN_WARNING "%s: i2c bus %d register FAILED\n", 337 pr_warn("%s: i2c bus %d register FAILED\n",
339 dev->name, bus->nr); 338 dev->name, bus->nr);
340 339
341 /* Instantiate the IR receiver device, if present */ 340 /* Instantiate the IR receiver device, if present */
diff --git a/drivers/media/pci/cx23885/cx23885-input.c b/drivers/media/pci/cx23885/cx23885-input.c
index 410c3141c163..1f092febdbd1 100644
--- a/drivers/media/pci/cx23885/cx23885-input.c
+++ b/drivers/media/pci/cx23885/cx23885-input.c
@@ -30,13 +30,13 @@
30 * GNU General Public License for more details. 30 * GNU General Public License for more details.
31 */ 31 */
32 32
33#include "cx23885.h"
34#include "cx23885-input.h"
35
33#include <linux/slab.h> 36#include <linux/slab.h>
34#include <media/rc-core.h> 37#include <media/rc-core.h>
35#include <media/v4l2-subdev.h> 38#include <media/v4l2-subdev.h>
36 39
37#include "cx23885.h"
38#include "cx23885-input.h"
39
40#define MODULE_NAME "cx23885" 40#define MODULE_NAME "cx23885"
41 41
42static void cx23885_input_process_measurements(struct cx23885_dev *dev, 42static void cx23885_input_process_measurements(struct cx23885_dev *dev,
diff --git a/drivers/media/pci/cx23885/cx23885-ir.c b/drivers/media/pci/cx23885/cx23885-ir.c
index 89dc4cc3e1ce..2cd5ac41ab75 100644
--- a/drivers/media/pci/cx23885/cx23885-ir.c
+++ b/drivers/media/pci/cx23885/cx23885-ir.c
@@ -16,12 +16,12 @@
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 */ 17 */
18 18
19#include <media/v4l2-device.h>
20
21#include "cx23885.h" 19#include "cx23885.h"
22#include "cx23885-ir.h" 20#include "cx23885-ir.h"
23#include "cx23885-input.h" 21#include "cx23885-input.h"
24 22
23#include <media/v4l2-device.h>
24
25#define CX23885_IR_RX_FIFO_SERVICE_REQ 0 25#define CX23885_IR_RX_FIFO_SERVICE_REQ 0
26#define CX23885_IR_RX_END_OF_RX_DETECTED 1 26#define CX23885_IR_RX_END_OF_RX_DETECTED 1
27#define CX23885_IR_RX_HW_FIFO_OVERRUN 2 27#define CX23885_IR_RX_HW_FIFO_OVERRUN 2
diff --git a/drivers/media/pci/cx23885/cx23885-vbi.c b/drivers/media/pci/cx23885/cx23885-vbi.c
index 75e7fa7b1121..369e545cac04 100644
--- a/drivers/media/pci/cx23885/cx23885-vbi.c
+++ b/drivers/media/pci/cx23885/cx23885-vbi.c
@@ -15,13 +15,13 @@
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 */ 16 */
17 17
18#include "cx23885.h"
19
18#include <linux/kernel.h> 20#include <linux/kernel.h>
19#include <linux/module.h> 21#include <linux/module.h>
20#include <linux/moduleparam.h> 22#include <linux/moduleparam.h>
21#include <linux/init.h> 23#include <linux/init.h>
22 24
23#include "cx23885.h"
24
25static unsigned int vbibufs = 4; 25static unsigned int vbibufs = 4;
26module_param(vbibufs, int, 0644); 26module_param(vbibufs, int, 0644);
27MODULE_PARM_DESC(vbibufs, "number of vbi buffers, range 2-32"); 27MODULE_PARM_DESC(vbibufs, "number of vbi buffers, range 2-32");
@@ -32,7 +32,8 @@ MODULE_PARM_DESC(vbi_debug, "enable debug messages [vbi]");
32 32
33#define dprintk(level, fmt, arg...)\ 33#define dprintk(level, fmt, arg...)\
34 do { if (vbi_debug >= level)\ 34 do { if (vbi_debug >= level)\
35 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\ 35 printk(KERN_DEBUG pr_fmt("%s: vbi:" fmt), \
36 __func__, ##arg); \
36 } while (0) 37 } while (0)
37 38
38/* ------------------------------------------------------------------ */ 39/* ------------------------------------------------------------------ */
diff --git a/drivers/media/pci/cx23885/cx23885-video.c b/drivers/media/pci/cx23885/cx23885-video.c
index 33d168ef278d..ecc580af0148 100644
--- a/drivers/media/pci/cx23885/cx23885-video.c
+++ b/drivers/media/pci/cx23885/cx23885-video.c
@@ -15,6 +15,9 @@
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 */ 16 */
17 17
18#include "cx23885.h"
19#include "cx23885-video.h"
20
18#include <linux/init.h> 21#include <linux/init.h>
19#include <linux/list.h> 22#include <linux/list.h>
20#include <linux/module.h> 23#include <linux/module.h>
@@ -27,8 +30,6 @@
27#include <linux/kthread.h> 30#include <linux/kthread.h>
28#include <asm/div64.h> 31#include <asm/div64.h>
29 32
30#include "cx23885.h"
31#include "cx23885-video.h"
32#include <media/v4l2-common.h> 33#include <media/v4l2-common.h>
33#include <media/v4l2-ioctl.h> 34#include <media/v4l2-ioctl.h>
34#include <media/v4l2-event.h> 35#include <media/v4l2-event.h>
@@ -66,7 +67,8 @@ MODULE_PARM_DESC(vid_limit, "capture memory limit in megabytes");
66 67
67#define dprintk(level, fmt, arg...)\ 68#define dprintk(level, fmt, arg...)\
68 do { if (video_debug >= level)\ 69 do { if (video_debug >= level)\
69 printk(KERN_DEBUG "%s: " fmt, dev->name, ## arg);\ 70 printk(KERN_DEBUG pr_fmt("%s: video:" fmt), \
71 __func__, ##arg); \
70 } while (0) 72 } while (0)
71 73
72/* ------------------------------------------------------------------- */ 74/* ------------------------------------------------------------------- */
@@ -194,7 +196,7 @@ u8 cx23885_flatiron_read(struct cx23885_dev *dev, u8 reg)
194 196
195 ret = i2c_transfer(&dev->i2c_bus[2].i2c_adap, &msg[0], 2); 197 ret = i2c_transfer(&dev->i2c_bus[2].i2c_adap, &msg[0], 2);
196 if (ret != 2) 198 if (ret != 2)
197 printk(KERN_ERR "%s() error\n", __func__); 199 pr_err("%s() error\n", __func__);
198 200
199 return b1[0]; 201 return b1[0];
200} 202}
@@ -811,7 +813,6 @@ static int vidioc_log_status(struct file *file, void *priv)
811static int cx23885_query_audinput(struct file *file, void *priv, 813static int cx23885_query_audinput(struct file *file, void *priv,
812 struct v4l2_audio *i) 814 struct v4l2_audio *i)
813{ 815{
814 struct cx23885_dev *dev = video_drvdata(file);
815 static const char *iname[] = { 816 static const char *iname[] = {
816 [0] = "Baseband L/R 1", 817 [0] = "Baseband L/R 1",
817 [1] = "Baseband L/R 2", 818 [1] = "Baseband L/R 2",
@@ -1000,7 +1001,7 @@ static int cx23885_set_freq_via_ops(struct cx23885_dev *dev,
1000 fe->ops.tuner_ops.set_analog_params(fe, &params); 1001 fe->ops.tuner_ops.set_analog_params(fe, &params);
1001 } 1002 }
1002 else 1003 else
1003 printk(KERN_ERR "%s() No analog tuner, aborting\n", __func__); 1004 pr_err("%s() No analog tuner, aborting\n", __func__);
1004 1005
1005 /* When changing channels it is required to reset TVAUDIO */ 1006 /* When changing channels it is required to reset TVAUDIO */
1006 msleep(100); 1007 msleep(100);
@@ -1058,15 +1059,14 @@ int cx23885_video_irq(struct cx23885_dev *dev, u32 status)
1058 if (status & VID_BC_MSK_OPC_ERR) { 1059 if (status & VID_BC_MSK_OPC_ERR) {
1059 dprintk(7, " (VID_BC_MSK_OPC_ERR 0x%08x)\n", 1060 dprintk(7, " (VID_BC_MSK_OPC_ERR 0x%08x)\n",
1060 VID_BC_MSK_OPC_ERR); 1061 VID_BC_MSK_OPC_ERR);
1061 printk(KERN_WARNING "%s: video risc op code error\n", 1062 pr_warn("%s: video risc op code error\n",
1062 dev->name); 1063 dev->name);
1063 cx23885_sram_channel_dump(dev, 1064 cx23885_sram_channel_dump(dev,
1064 &dev->sram_channels[SRAM_CH01]); 1065 &dev->sram_channels[SRAM_CH01]);
1065 } 1066 }
1066 1067
1067 if (status & VID_BC_MSK_SYNC) 1068 if (status & VID_BC_MSK_SYNC)
1068 dprintk(7, " (VID_BC_MSK_SYNC 0x%08x) " 1069 dprintk(7, " (VID_BC_MSK_SYNC 0x%08x) video lines miss-match\n",
1069 "video lines miss-match\n",
1070 VID_BC_MSK_SYNC); 1070 VID_BC_MSK_SYNC);
1071 1071
1072 if (status & VID_BC_MSK_OF) 1072 if (status & VID_BC_MSK_OF)
@@ -1297,11 +1297,11 @@ int cx23885_video_register(struct cx23885_dev *dev)
1297 err = video_register_device(dev->video_dev, VFL_TYPE_GRABBER, 1297 err = video_register_device(dev->video_dev, VFL_TYPE_GRABBER,
1298 video_nr[dev->nr]); 1298 video_nr[dev->nr]);
1299 if (err < 0) { 1299 if (err < 0) {
1300 printk(KERN_INFO "%s: can't register video device\n", 1300 pr_info("%s: can't register video device\n",
1301 dev->name); 1301 dev->name);
1302 goto fail_unreg; 1302 goto fail_unreg;
1303 } 1303 }
1304 printk(KERN_INFO "%s: registered device %s [v4l2]\n", 1304 pr_info("%s: registered device %s [v4l2]\n",
1305 dev->name, video_device_node_name(dev->video_dev)); 1305 dev->name, video_device_node_name(dev->video_dev));
1306 1306
1307 /* register VBI device */ 1307 /* register VBI device */
@@ -1311,11 +1311,11 @@ int cx23885_video_register(struct cx23885_dev *dev)
1311 err = video_register_device(dev->vbi_dev, VFL_TYPE_VBI, 1311 err = video_register_device(dev->vbi_dev, VFL_TYPE_VBI,
1312 vbi_nr[dev->nr]); 1312 vbi_nr[dev->nr]);
1313 if (err < 0) { 1313 if (err < 0) {
1314 printk(KERN_INFO "%s: can't register vbi device\n", 1314 pr_info("%s: can't register vbi device\n",
1315 dev->name); 1315 dev->name);
1316 goto fail_unreg; 1316 goto fail_unreg;
1317 } 1317 }
1318 printk(KERN_INFO "%s: registered device %s\n", 1318 pr_info("%s: registered device %s\n",
1319 dev->name, video_device_node_name(dev->vbi_dev)); 1319 dev->name, video_device_node_name(dev->vbi_dev));
1320 1320
1321 /* Register ALSA audio device */ 1321 /* Register ALSA audio device */
diff --git a/drivers/media/pci/cx23885/cx23885.h b/drivers/media/pci/cx23885/cx23885.h
index a6735afe2269..cb714ab60d69 100644
--- a/drivers/media/pci/cx23885/cx23885.h
+++ b/drivers/media/pci/cx23885/cx23885.h
@@ -15,6 +15,8 @@
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 */ 16 */
17 17
18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19
18#include <linux/pci.h> 20#include <linux/pci.h>
19#include <linux/i2c.h> 21#include <linux/i2c.h>
20#include <linux/kdev_t.h> 22#include <linux/kdev_t.h>
diff --git a/drivers/media/pci/cx23885/cx23888-ir.c b/drivers/media/pci/cx23885/cx23888-ir.c
index c1aa888af705..040323b0f945 100644
--- a/drivers/media/pci/cx23885/cx23888-ir.c
+++ b/drivers/media/pci/cx23885/cx23888-ir.c
@@ -16,15 +16,15 @@
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 */ 17 */
18 18
19#include "cx23885.h"
20#include "cx23888-ir.h"
21
19#include <linux/kfifo.h> 22#include <linux/kfifo.h>
20#include <linux/slab.h> 23#include <linux/slab.h>
21 24
22#include <media/v4l2-device.h> 25#include <media/v4l2-device.h>
23#include <media/rc-core.h> 26#include <media/rc-core.h>
24 27
25#include "cx23885.h"
26#include "cx23888-ir.h"
27
28static unsigned int ir_888_debug; 28static unsigned int ir_888_debug;
29module_param(ir_888_debug, int, 0644); 29module_param(ir_888_debug, int, 0644);
30MODULE_PARM_DESC(ir_888_debug, "enable debug messages [CX23888 IR controller]"); 30MODULE_PARM_DESC(ir_888_debug, "enable debug messages [CX23888 IR controller]");
@@ -1015,8 +1015,8 @@ static int cx23888_ir_log_status(struct v4l2_subdev *sd)
1015 j = 0; 1015 j = 0;
1016 break; 1016 break;
1017 } 1017 }
1018 v4l2_info(sd, "\tNext carrier edge window: 16 clocks " 1018 v4l2_info(sd, "\tNext carrier edge window: 16 clocks -%1d/+%1d, %u to %u Hz\n",
1019 "-%1d/+%1d, %u to %u Hz\n", i, j, 1019 i, j,
1020 clock_divider_to_freq(rxclk, 16 + j), 1020 clock_divider_to_freq(rxclk, 16 + j),
1021 clock_divider_to_freq(rxclk, 16 - i)); 1021 clock_divider_to_freq(rxclk, 16 - i));
1022 } 1022 }
@@ -1026,8 +1026,7 @@ static int cx23888_ir_log_status(struct v4l2_subdev *sd)
1026 v4l2_info(sd, "\tLow pass filter: %s\n", 1026 v4l2_info(sd, "\tLow pass filter: %s\n",
1027 filtr ? "enabled" : "disabled"); 1027 filtr ? "enabled" : "disabled");
1028 if (filtr) 1028 if (filtr)
1029 v4l2_info(sd, "\tMin acceptable pulse width (LPF): %u us, " 1029 v4l2_info(sd, "\tMin acceptable pulse width (LPF): %u us, %u ns\n",
1030 "%u ns\n",
1031 lpf_count_to_us(filtr), 1030 lpf_count_to_us(filtr),
1032 lpf_count_to_ns(filtr)); 1031 lpf_count_to_ns(filtr));
1033 v4l2_info(sd, "\tPulse width timer timed-out: %s\n", 1032 v4l2_info(sd, "\tPulse width timer timed-out: %s\n",
diff --git a/drivers/media/pci/cx23885/netup-eeprom.c b/drivers/media/pci/cx23885/netup-eeprom.c
index b6542ee4385b..6384c12aa38e 100644
--- a/drivers/media/pci/cx23885/netup-eeprom.c
+++ b/drivers/media/pci/cx23885/netup-eeprom.c
@@ -52,7 +52,7 @@ int netup_eeprom_read(struct i2c_adapter *i2c_adap, u8 addr)
52 ret = i2c_transfer(i2c_adap, msg, 2); 52 ret = i2c_transfer(i2c_adap, msg, 2);
53 53
54 if (ret != 2) { 54 if (ret != 2) {
55 printk(KERN_ERR "eeprom i2c read error, status=%d\n", ret); 55 pr_err("eeprom i2c read error, status=%d\n", ret);
56 return -1; 56 return -1;
57 } 57 }
58 58
@@ -80,7 +80,7 @@ int netup_eeprom_write(struct i2c_adapter *i2c_adap, u8 addr, u8 data)
80 ret = i2c_transfer(i2c_adap, msg, 1); 80 ret = i2c_transfer(i2c_adap, msg, 1);
81 81
82 if (ret != 1) { 82 if (ret != 1) {
83 printk(KERN_ERR "eeprom i2c write error, status=%d\n", ret); 83 pr_err("eeprom i2c write error, status=%d\n", ret);
84 return -1; 84 return -1;
85 } 85 }
86 86
diff --git a/drivers/media/pci/cx23885/netup-init.c b/drivers/media/pci/cx23885/netup-init.c
index 76d9487aafc8..6a27ef5d9ec2 100644
--- a/drivers/media/pci/cx23885/netup-init.c
+++ b/drivers/media/pci/cx23885/netup-init.c
@@ -40,7 +40,7 @@ static void i2c_av_write(struct i2c_adapter *i2c, u16 reg, u8 val)
40 ret = i2c_transfer(i2c, &msg, 1); 40 ret = i2c_transfer(i2c, &msg, 1);
41 41
42 if (ret != 1) 42 if (ret != 1)
43 printk(KERN_ERR "%s: i2c write error!\n", __func__); 43 pr_err("%s: i2c write error!\n", __func__);
44} 44}
45 45
46static void i2c_av_write4(struct i2c_adapter *i2c, u16 reg, u32 val) 46static void i2c_av_write4(struct i2c_adapter *i2c, u16 reg, u32 val)
@@ -64,7 +64,7 @@ static void i2c_av_write4(struct i2c_adapter *i2c, u16 reg, u32 val)
64 ret = i2c_transfer(i2c, &msg, 1); 64 ret = i2c_transfer(i2c, &msg, 1);
65 65
66 if (ret != 1) 66 if (ret != 1)
67 printk(KERN_ERR "%s: i2c write error!\n", __func__); 67 pr_err("%s: i2c write error!\n", __func__);
68} 68}
69 69
70static u8 i2c_av_read(struct i2c_adapter *i2c, u16 reg) 70static u8 i2c_av_read(struct i2c_adapter *i2c, u16 reg)
@@ -84,7 +84,7 @@ static u8 i2c_av_read(struct i2c_adapter *i2c, u16 reg)
84 ret = i2c_transfer(i2c, &msg, 1); 84 ret = i2c_transfer(i2c, &msg, 1);
85 85
86 if (ret != 1) 86 if (ret != 1)
87 printk(KERN_ERR "%s: i2c write error!\n", __func__); 87 pr_err("%s: i2c write error!\n", __func__);
88 88
89 msg.flags = I2C_M_RD; 89 msg.flags = I2C_M_RD;
90 msg.len = 1; 90 msg.len = 1;
@@ -92,7 +92,7 @@ static u8 i2c_av_read(struct i2c_adapter *i2c, u16 reg)
92 ret = i2c_transfer(i2c, &msg, 1); 92 ret = i2c_transfer(i2c, &msg, 1);
93 93
94 if (ret != 1) 94 if (ret != 1)
95 printk(KERN_ERR "%s: i2c read error!\n", __func__); 95 pr_err("%s: i2c read error!\n", __func__);
96 96
97 return buf[0]; 97 return buf[0];
98} 98}
diff --git a/drivers/media/pci/cx88/cx88-alsa.c b/drivers/media/pci/cx88/cx88-alsa.c
index 723f06462104..c81fe4681d14 100644
--- a/drivers/media/pci/cx88/cx88-alsa.c
+++ b/drivers/media/pci/cx88/cx88-alsa.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Support for audio capture 2 * Support for audio capture
4 * PCI function #1 of the cx2388x. 3 * PCI function #1 of the cx2388x.
5 * 4 *
@@ -18,14 +17,14 @@
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 19 * 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 */ 20 */
26 21
22#include "cx88.h"
23#include "cx88-reg.h"
24
27#include <linux/module.h> 25#include <linux/module.h>
28#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/delay.h>
29#include <linux/device.h> 28#include <linux/device.h>
30#include <linux/interrupt.h> 29#include <linux/interrupt.h>
31#include <linux/vmalloc.h> 30#include <linux/vmalloc.h>
@@ -33,7 +32,6 @@
33#include <linux/pci.h> 32#include <linux/pci.h>
34#include <linux/slab.h> 33#include <linux/slab.h>
35 34
36#include <asm/delay.h>
37#include <sound/core.h> 35#include <sound/core.h>
38#include <sound/pcm.h> 36#include <sound/pcm.h>
39#include <sound/pcm_params.h> 37#include <sound/pcm_params.h>
@@ -42,22 +40,15 @@
42#include <sound/tlv.h> 40#include <sound/tlv.h>
43#include <media/i2c/wm8775.h> 41#include <media/i2c/wm8775.h>
44 42
45#include "cx88.h"
46#include "cx88-reg.h"
47
48#define dprintk(level, fmt, arg...) do { \ 43#define dprintk(level, fmt, arg...) do { \
49 if (debug + 1 > level) \ 44 if (debug + 1 > level) \
50 printk(KERN_INFO "%s/1: " fmt, chip->core->name , ## arg);\ 45 printk(KERN_DEBUG pr_fmt("%s: alsa: " fmt), \
51} while(0) 46 chip->core->name, ##arg); \
52 47} while (0)
53#define dprintk_core(level, fmt, arg...) do { \
54 if (debug + 1 > level) \
55 printk(KERN_DEBUG "%s/1: " fmt, chip->core->name , ## arg);\
56} while(0)
57 48
58/**************************************************************************** 49/*
59 Data type declarations - Can be moded to a header file later 50 * Data type declarations - Can be moded to a header file later
60 ****************************************************************************/ 51 */
61 52
62struct cx88_audio_buffer { 53struct cx88_audio_buffer {
63 unsigned int bpl; 54 unsigned int bpl;
@@ -91,13 +82,10 @@ struct cx88_audio_dev {
91 82
92 struct snd_pcm_substream *substream; 83 struct snd_pcm_substream *substream;
93}; 84};
94typedef struct cx88_audio_dev snd_cx88_card_t;
95 85
96 86/*
97 87 * Module global static vars
98/**************************************************************************** 88 */
99 Module global static vars
100 ****************************************************************************/
101 89
102static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 90static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
103static const char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 91static const char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
@@ -109,10 +97,9 @@ MODULE_PARM_DESC(enable, "Enable cx88x soundcard. default enabled.");
109module_param_array(index, int, NULL, 0444); 97module_param_array(index, int, NULL, 0444);
110MODULE_PARM_DESC(index, "Index value for cx88x capture interface(s)."); 98MODULE_PARM_DESC(index, "Index value for cx88x capture interface(s).");
111 99
112 100/*
113/**************************************************************************** 101 * Module macros
114 Module macros 102 */
115 ****************************************************************************/
116 103
117MODULE_DESCRIPTION("ALSA driver module for cx2388x based TV cards"); 104MODULE_DESCRIPTION("ALSA driver module for cx2388x based TV cards");
118MODULE_AUTHOR("Ricardo Cerqueira"); 105MODULE_AUTHOR("Ricardo Cerqueira");
@@ -120,25 +107,23 @@ MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>");
120MODULE_LICENSE("GPL"); 107MODULE_LICENSE("GPL");
121MODULE_VERSION(CX88_VERSION); 108MODULE_VERSION(CX88_VERSION);
122 109
123MODULE_SUPPORTED_DEVICE("{{Conexant,23881}," 110MODULE_SUPPORTED_DEVICE("{{Conexant,23881},{{Conexant,23882},{{Conexant,23883}");
124 "{{Conexant,23882},"
125 "{{Conexant,23883}");
126static unsigned int debug; 111static unsigned int debug;
127module_param(debug,int,0644); 112module_param(debug, int, 0644);
128MODULE_PARM_DESC(debug,"enable debug messages"); 113MODULE_PARM_DESC(debug, "enable debug messages");
129 114
130/**************************************************************************** 115/*
131 Module specific funtions 116 * Module specific functions
132 ****************************************************************************/ 117 */
133 118
134/* 119/*
135 * BOARD Specific: Sets audio DMA 120 * BOARD Specific: Sets audio DMA
136 */ 121 */
137 122
138static int _cx88_start_audio_dma(snd_cx88_card_t *chip) 123static int _cx88_start_audio_dma(struct cx88_audio_dev *chip)
139{ 124{
140 struct cx88_audio_buffer *buf = chip->buf; 125 struct cx88_audio_buffer *buf = chip->buf;
141 struct cx88_core *core=chip->core; 126 struct cx88_core *core = chip->core;
142 const struct sram_channel *audio_ch = &cx88_sram_channels[SRAM_CH25]; 127 const struct sram_channel *audio_ch = &cx88_sram_channels[SRAM_CH25];
143 128
144 /* Make sure RISC/FIFO are off before changing FIFO/RISC settings */ 129 /* Make sure RISC/FIFO are off before changing FIFO/RISC settings */
@@ -154,8 +139,9 @@ static int _cx88_start_audio_dma(snd_cx88_card_t *chip)
154 cx_write(MO_AUDD_GPCNTRL, GP_COUNT_CONTROL_RESET); 139 cx_write(MO_AUDD_GPCNTRL, GP_COUNT_CONTROL_RESET);
155 atomic_set(&chip->count, 0); 140 atomic_set(&chip->count, 0);
156 141
157 dprintk(1, "Start audio DMA, %d B/line, %d lines/FIFO, %d periods, %d " 142 dprintk(1,
158 "byte buffer\n", buf->bpl, cx_read(audio_ch->cmds_start + 8)>>1, 143 "Start audio DMA, %d B/line, %d lines/FIFO, %d periods, %d byte buffer\n",
144 buf->bpl, cx_read(audio_ch->cmds_start + 8) >> 1,
159 chip->num_periods, buf->bpl * chip->num_periods); 145 chip->num_periods, buf->bpl * chip->num_periods);
160 146
161 /* Enables corresponding bits at AUD_INT_STAT */ 147 /* Enables corresponding bits at AUD_INT_STAT */
@@ -169,8 +155,11 @@ static int _cx88_start_audio_dma(snd_cx88_card_t *chip)
169 cx_set(MO_PCI_INTMSK, chip->core->pci_irqmask | PCI_INT_AUDINT); 155 cx_set(MO_PCI_INTMSK, chip->core->pci_irqmask | PCI_INT_AUDINT);
170 156
171 /* start dma */ 157 /* start dma */
172 cx_set(MO_DEV_CNTRL2, (1<<5)); /* Enables Risc Processor */ 158
173 cx_set(MO_AUD_DMACNTRL, 0x11); /* audio downstream FIFO and RISC enable */ 159 /* Enables Risc Processor */
160 cx_set(MO_DEV_CNTRL2, (1 << 5));
161 /* audio downstream FIFO and RISC enable */
162 cx_set(MO_AUD_DMACNTRL, 0x11);
174 163
175 if (debug) 164 if (debug)
176 cx88_sram_channel_dump(chip->core, audio_ch); 165 cx88_sram_channel_dump(chip->core, audio_ch);
@@ -181,9 +170,10 @@ static int _cx88_start_audio_dma(snd_cx88_card_t *chip)
181/* 170/*
182 * BOARD Specific: Resets audio DMA 171 * BOARD Specific: Resets audio DMA
183 */ 172 */
184static int _cx88_stop_audio_dma(snd_cx88_card_t *chip) 173static int _cx88_stop_audio_dma(struct cx88_audio_dev *chip)
185{ 174{
186 struct cx88_core *core=chip->core; 175 struct cx88_core *core = chip->core;
176
187 dprintk(1, "Stopping audio DMA\n"); 177 dprintk(1, "Stopping audio DMA\n");
188 178
189 /* stop dma */ 179 /* stop dma */
@@ -195,7 +185,8 @@ static int _cx88_stop_audio_dma(snd_cx88_card_t *chip)
195 AUD_INT_DN_RISCI2 | AUD_INT_DN_RISCI1); 185 AUD_INT_DN_RISCI2 | AUD_INT_DN_RISCI1);
196 186
197 if (debug) 187 if (debug)
198 cx88_sram_channel_dump(chip->core, &cx88_sram_channels[SRAM_CH25]); 188 cx88_sram_channel_dump(chip->core,
189 &cx88_sram_channels[SRAM_CH25]);
199 190
200 return 0; 191 return 0;
201} 192}
@@ -221,7 +212,7 @@ static const char *cx88_aud_irqs[32] = {
221/* 212/*
222 * BOARD Specific: Threats IRQ audio specific calls 213 * BOARD Specific: Threats IRQ audio specific calls
223 */ 214 */
224static void cx8801_aud_irq(snd_cx88_card_t *chip) 215static void cx8801_aud_irq(struct cx88_audio_dev *chip)
225{ 216{
226 struct cx88_core *core = chip->core; 217 struct cx88_core *core = chip->core;
227 u32 status, mask; 218 u32 status, mask;
@@ -232,12 +223,12 @@ static void cx8801_aud_irq(snd_cx88_card_t *chip)
232 return; 223 return;
233 cx_write(MO_AUD_INTSTAT, status); 224 cx_write(MO_AUD_INTSTAT, status);
234 if (debug > 1 || (status & mask & ~0xff)) 225 if (debug > 1 || (status & mask & ~0xff))
235 cx88_print_irqbits(core->name, "irq aud", 226 cx88_print_irqbits("irq aud",
236 cx88_aud_irqs, ARRAY_SIZE(cx88_aud_irqs), 227 cx88_aud_irqs, ARRAY_SIZE(cx88_aud_irqs),
237 status, mask); 228 status, mask);
238 /* risc op code error */ 229 /* risc op code error */
239 if (status & AUD_INT_OPC_ERR) { 230 if (status & AUD_INT_OPC_ERR) {
240 printk(KERN_WARNING "%s/1: Audio risc op code error\n",core->name); 231 pr_warn("Audio risc op code error\n");
241 cx_clear(MO_AUD_DMACNTRL, 0x11); 232 cx_clear(MO_AUD_DMACNTRL, 0x11);
242 cx88_sram_channel_dump(core, &cx88_sram_channels[SRAM_CH25]); 233 cx88_sram_channel_dump(core, &cx88_sram_channels[SRAM_CH25]);
243 } 234 }
@@ -259,7 +250,7 @@ static void cx8801_aud_irq(snd_cx88_card_t *chip)
259 */ 250 */
260static irqreturn_t cx8801_irq(int irq, void *dev_id) 251static irqreturn_t cx8801_irq(int irq, void *dev_id)
261{ 252{
262 snd_cx88_card_t *chip = dev_id; 253 struct cx88_audio_dev *chip = dev_id;
263 struct cx88_core *core = chip->core; 254 struct cx88_core *core = chip->core;
264 u32 status; 255 u32 status;
265 int loop, handled = 0; 256 int loop, handled = 0;
@@ -267,7 +258,7 @@ static irqreturn_t cx8801_irq(int irq, void *dev_id)
267 for (loop = 0; loop < MAX_IRQ_LOOP; loop++) { 258 for (loop = 0; loop < MAX_IRQ_LOOP; loop++) {
268 status = cx_read(MO_PCI_INTSTAT) & 259 status = cx_read(MO_PCI_INTSTAT) &
269 (core->pci_irqmask | PCI_INT_AUDINT); 260 (core->pci_irqmask | PCI_INT_AUDINT);
270 if (0 == status) 261 if (status == 0)
271 goto out; 262 goto out;
272 dprintk(3, "cx8801_irq loop %d/%d, status %x\n", 263 dprintk(3, "cx8801_irq loop %d/%d, status %x\n",
273 loop, MAX_IRQ_LOOP, status); 264 loop, MAX_IRQ_LOOP, status);
@@ -280,10 +271,8 @@ static irqreturn_t cx8801_irq(int irq, void *dev_id)
280 cx8801_aud_irq(chip); 271 cx8801_aud_irq(chip);
281 } 272 }
282 273
283 if (MAX_IRQ_LOOP == loop) { 274 if (loop == MAX_IRQ_LOOP) {
284 printk(KERN_ERR 275 pr_err("IRQ loop detected, disabling interrupts\n");
285 "%s/1: IRQ loop detected, disabling interrupts\n",
286 core->name);
287 cx_clear(MO_PCI_INTMSK, PCI_INT_AUDINT); 276 cx_clear(MO_PCI_INTMSK, PCI_INT_AUDINT);
288 } 277 }
289 278
@@ -298,26 +287,25 @@ static int cx88_alsa_dma_init(struct cx88_audio_dev *chip, int nr_pages)
298 int i; 287 int i;
299 288
300 buf->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT); 289 buf->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT);
301 if (NULL == buf->vaddr) { 290 if (!buf->vaddr) {
302 dprintk(1, "vmalloc_32(%d pages) failed\n", nr_pages); 291 dprintk(1, "vmalloc_32(%d pages) failed\n", nr_pages);
303 return -ENOMEM; 292 return -ENOMEM;
304 } 293 }
305 294
306 dprintk(1, "vmalloc is at addr 0x%08lx, size=%d\n", 295 dprintk(1, "vmalloc is at addr 0x%08lx, size=%d\n",
307 (unsigned long)buf->vaddr, 296 (unsigned long)buf->vaddr, nr_pages << PAGE_SHIFT);
308 nr_pages << PAGE_SHIFT);
309 297
310 memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT); 298 memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT);
311 buf->nr_pages = nr_pages; 299 buf->nr_pages = nr_pages;
312 300
313 buf->sglist = vzalloc(buf->nr_pages * sizeof(*buf->sglist)); 301 buf->sglist = vzalloc(buf->nr_pages * sizeof(*buf->sglist));
314 if (NULL == buf->sglist) 302 if (!buf->sglist)
315 goto vzalloc_err; 303 goto vzalloc_err;
316 304
317 sg_init_table(buf->sglist, buf->nr_pages); 305 sg_init_table(buf->sglist, buf->nr_pages);
318 for (i = 0; i < buf->nr_pages; i++) { 306 for (i = 0; i < buf->nr_pages; i++) {
319 pg = vmalloc_to_page(buf->vaddr + i * PAGE_SIZE); 307 pg = vmalloc_to_page(buf->vaddr + i * PAGE_SIZE);
320 if (NULL == pg) 308 if (!pg)
321 goto vmalloc_to_page_err; 309 goto vmalloc_to_page_err;
322 sg_set_page(&buf->sglist[i], pg, PAGE_SIZE, 0); 310 sg_set_page(&buf->sglist[i], pg, PAGE_SIZE, 0);
323 } 311 }
@@ -339,7 +327,7 @@ static int cx88_alsa_dma_map(struct cx88_audio_dev *dev)
339 buf->sglen = dma_map_sg(&dev->pci->dev, buf->sglist, 327 buf->sglen = dma_map_sg(&dev->pci->dev, buf->sglist,
340 buf->nr_pages, PCI_DMA_FROMDEVICE); 328 buf->nr_pages, PCI_DMA_FROMDEVICE);
341 329
342 if (0 == buf->sglen) { 330 if (buf->sglen == 0) {
343 pr_warn("%s: cx88_alsa_map_sg failed\n", __func__); 331 pr_warn("%s: cx88_alsa_map_sg failed\n", __func__);
344 return -ENOMEM; 332 return -ENOMEM;
345 } 333 }
@@ -353,7 +341,8 @@ static int cx88_alsa_dma_unmap(struct cx88_audio_dev *dev)
353 if (!buf->sglen) 341 if (!buf->sglen)
354 return 0; 342 return 0;
355 343
356 dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->sglen, PCI_DMA_FROMDEVICE); 344 dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->sglen,
345 PCI_DMA_FROMDEVICE);
357 buf->sglen = 0; 346 buf->sglen = 0;
358 return 0; 347 return 0;
359} 348}
@@ -367,18 +356,18 @@ static int cx88_alsa_dma_free(struct cx88_audio_buffer *buf)
367 return 0; 356 return 0;
368} 357}
369 358
370 359static int dsp_buffer_free(struct cx88_audio_dev *chip)
371static int dsp_buffer_free(snd_cx88_card_t *chip)
372{ 360{
373 struct cx88_riscmem *risc = &chip->buf->risc; 361 struct cx88_riscmem *risc = &chip->buf->risc;
374 362
375 BUG_ON(!chip->dma_size); 363 WARN_ON(!chip->dma_size);
376 364
377 dprintk(2,"Freeing buffer\n"); 365 dprintk(2, "Freeing buffer\n");
378 cx88_alsa_dma_unmap(chip); 366 cx88_alsa_dma_unmap(chip);
379 cx88_alsa_dma_free(chip->buf); 367 cx88_alsa_dma_free(chip->buf);
380 if (risc->cpu) 368 if (risc->cpu)
381 pci_free_consistent(chip->pci, risc->size, risc->cpu, risc->dma); 369 pci_free_consistent(chip->pci, risc->size,
370 risc->cpu, risc->dma);
382 kfree(chip->buf); 371 kfree(chip->buf);
383 372
384 chip->buf = NULL; 373 chip->buf = NULL;
@@ -386,9 +375,9 @@ static int dsp_buffer_free(snd_cx88_card_t *chip)
386 return 0; 375 return 0;
387} 376}
388 377
389/**************************************************************************** 378/*
390 ALSA PCM Interface 379 * ALSA PCM Interface
391 ****************************************************************************/ 380 */
392 381
393/* 382/*
394 * Digital hardware definition 383 * Digital hardware definition
@@ -406,13 +395,15 @@ static const struct snd_pcm_hardware snd_cx88_digital_hw = {
406 .rate_max = 48000, 395 .rate_max = 48000,
407 .channels_min = 2, 396 .channels_min = 2,
408 .channels_max = 2, 397 .channels_max = 2,
409 /* Analog audio output will be full of clicks and pops if there 398 /*
410 are not exactly four lines in the SRAM FIFO buffer. */ 399 * Analog audio output will be full of clicks and pops if there
411 .period_bytes_min = DEFAULT_FIFO_SIZE/4, 400 * are not exactly four lines in the SRAM FIFO buffer.
412 .period_bytes_max = DEFAULT_FIFO_SIZE/4, 401 */
402 .period_bytes_min = DEFAULT_FIFO_SIZE / 4,
403 .period_bytes_max = DEFAULT_FIFO_SIZE / 4,
413 .periods_min = 1, 404 .periods_min = 1,
414 .periods_max = 1024, 405 .periods_max = 1024,
415 .buffer_bytes_max = (1024*1024), 406 .buffer_bytes_max = (1024 * 1024),
416}; 407};
417 408
418/* 409/*
@@ -420,17 +411,17 @@ static const struct snd_pcm_hardware snd_cx88_digital_hw = {
420 */ 411 */
421static int snd_cx88_pcm_open(struct snd_pcm_substream *substream) 412static int snd_cx88_pcm_open(struct snd_pcm_substream *substream)
422{ 413{
423 snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); 414 struct cx88_audio_dev *chip = snd_pcm_substream_chip(substream);
424 struct snd_pcm_runtime *runtime = substream->runtime; 415 struct snd_pcm_runtime *runtime = substream->runtime;
425 int err; 416 int err;
426 417
427 if (!chip) { 418 if (!chip) {
428 printk(KERN_ERR "BUG: cx88 can't find device struct." 419 pr_err("BUG: cx88 can't find device struct. Can't proceed with open\n");
429 " Can't proceed with open\n");
430 return -ENODEV; 420 return -ENODEV;
431 } 421 }
432 422
433 err = snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS); 423 err = snd_pcm_hw_constraint_pow2(runtime, 0,
424 SNDRV_PCM_HW_PARAM_PERIODS);
434 if (err < 0) 425 if (err < 0)
435 goto _error; 426 goto _error;
436 427
@@ -440,6 +431,7 @@ static int snd_cx88_pcm_open(struct snd_pcm_substream *substream)
440 431
441 if (cx88_sram_channels[SRAM_CH25].fifo_size != DEFAULT_FIFO_SIZE) { 432 if (cx88_sram_channels[SRAM_CH25].fifo_size != DEFAULT_FIFO_SIZE) {
442 unsigned int bpl = cx88_sram_channels[SRAM_CH25].fifo_size / 4; 433 unsigned int bpl = cx88_sram_channels[SRAM_CH25].fifo_size / 4;
434
443 bpl &= ~7; /* must be multiple of 8 */ 435 bpl &= ~7; /* must be multiple of 8 */
444 runtime->hw.period_bytes_min = bpl; 436 runtime->hw.period_bytes_min = bpl;
445 runtime->hw.period_bytes_max = bpl; 437 runtime->hw.period_bytes_max = bpl;
@@ -447,7 +439,7 @@ static int snd_cx88_pcm_open(struct snd_pcm_substream *substream)
447 439
448 return 0; 440 return 0;
449_error: 441_error:
450 dprintk(1,"Error opening PCM!\n"); 442 dprintk(1, "Error opening PCM!\n");
451 return err; 443 return err;
452} 444}
453 445
@@ -462,10 +454,10 @@ static int snd_cx88_close(struct snd_pcm_substream *substream)
462/* 454/*
463 * hw_params callback 455 * hw_params callback
464 */ 456 */
465static int snd_cx88_hw_params(struct snd_pcm_substream * substream, 457static int snd_cx88_hw_params(struct snd_pcm_substream *substream,
466 struct snd_pcm_hw_params * hw_params) 458 struct snd_pcm_hw_params *hw_params)
467{ 459{
468 snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); 460 struct cx88_audio_dev *chip = snd_pcm_substream_chip(substream);
469 461
470 struct cx88_audio_buffer *buf; 462 struct cx88_audio_buffer *buf;
471 int ret; 463 int ret;
@@ -479,18 +471,18 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream,
479 chip->num_periods = params_periods(hw_params); 471 chip->num_periods = params_periods(hw_params);
480 chip->dma_size = chip->period_size * params_periods(hw_params); 472 chip->dma_size = chip->period_size * params_periods(hw_params);
481 473
482 BUG_ON(!chip->dma_size); 474 WARN_ON(!chip->dma_size);
483 BUG_ON(chip->num_periods & (chip->num_periods-1)); 475 WARN_ON(chip->num_periods & (chip->num_periods - 1));
484 476
485 buf = kzalloc(sizeof(*buf), GFP_KERNEL); 477 buf = kzalloc(sizeof(*buf), GFP_KERNEL);
486 if (NULL == buf) 478 if (!buf)
487 return -ENOMEM; 479 return -ENOMEM;
488 480
489 chip->buf = buf; 481 chip->buf = buf;
490 buf->bpl = chip->period_size; 482 buf->bpl = chip->period_size;
491 483
492 ret = cx88_alsa_dma_init(chip, 484 ret = cx88_alsa_dma_init(chip,
493 (PAGE_ALIGN(chip->dma_size) >> PAGE_SHIFT)); 485 (PAGE_ALIGN(chip->dma_size) >> PAGE_SHIFT));
494 if (ret < 0) 486 if (ret < 0)
495 goto error; 487 goto error;
496 488
@@ -504,7 +496,7 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream,
504 goto error; 496 goto error;
505 497
506 /* Loop back to start of program */ 498 /* Loop back to start of program */
507 buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP|RISC_IRQ1|RISC_CNT_INC); 499 buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC);
508 buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma); 500 buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
509 501
510 substream->runtime->dma_area = chip->buf->vaddr; 502 substream->runtime->dma_area = chip->buf->vaddr;
@@ -520,10 +512,9 @@ error:
520/* 512/*
521 * hw free callback 513 * hw free callback
522 */ 514 */
523static int snd_cx88_hw_free(struct snd_pcm_substream * substream) 515static int snd_cx88_hw_free(struct snd_pcm_substream *substream)
524{ 516{
525 517 struct cx88_audio_dev *chip = snd_pcm_substream_chip(substream);
526 snd_cx88_card_t *chip = snd_pcm_substream_chip(substream);
527 518
528 if (substream->runtime->dma_area) { 519 if (substream->runtime->dma_area) {
529 dsp_buffer_free(chip); 520 dsp_buffer_free(chip);
@@ -546,7 +537,7 @@ static int snd_cx88_prepare(struct snd_pcm_substream *substream)
546 */ 537 */
547static int snd_cx88_card_trigger(struct snd_pcm_substream *substream, int cmd) 538static int snd_cx88_card_trigger(struct snd_pcm_substream *substream, int cmd)
548{ 539{
549 snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); 540 struct cx88_audio_dev *chip = snd_pcm_substream_chip(substream);
550 int err; 541 int err;
551 542
552 /* Local interrupts are already disabled by ALSA */ 543 /* Local interrupts are already disabled by ALSA */
@@ -554,13 +545,13 @@ static int snd_cx88_card_trigger(struct snd_pcm_substream *substream, int cmd)
554 545
555 switch (cmd) { 546 switch (cmd) {
556 case SNDRV_PCM_TRIGGER_START: 547 case SNDRV_PCM_TRIGGER_START:
557 err=_cx88_start_audio_dma(chip); 548 err = _cx88_start_audio_dma(chip);
558 break; 549 break;
559 case SNDRV_PCM_TRIGGER_STOP: 550 case SNDRV_PCM_TRIGGER_STOP:
560 err=_cx88_stop_audio_dma(chip); 551 err = _cx88_stop_audio_dma(chip);
561 break; 552 break;
562 default: 553 default:
563 err=-EINVAL; 554 err = -EINVAL;
564 break; 555 break;
565 } 556 }
566 557
@@ -574,7 +565,7 @@ static int snd_cx88_card_trigger(struct snd_pcm_substream *substream, int cmd)
574 */ 565 */
575static snd_pcm_uframes_t snd_cx88_pointer(struct snd_pcm_substream *substream) 566static snd_pcm_uframes_t snd_cx88_pointer(struct snd_pcm_substream *substream)
576{ 567{
577 snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); 568 struct cx88_audio_dev *chip = snd_pcm_substream_chip(substream);
578 struct snd_pcm_runtime *runtime = substream->runtime; 569 struct snd_pcm_runtime *runtime = substream->runtime;
579 u16 count; 570 u16 count;
580 571
@@ -583,16 +574,17 @@ static snd_pcm_uframes_t snd_cx88_pointer(struct snd_pcm_substream *substream)
583// dprintk(2, "%s - count %d (+%u), period %d, frame %lu\n", __func__, 574// dprintk(2, "%s - count %d (+%u), period %d, frame %lu\n", __func__,
584// count, new, count & (runtime->periods-1), 575// count, new, count & (runtime->periods-1),
585// runtime->period_size * (count & (runtime->periods-1))); 576// runtime->period_size * (count & (runtime->periods-1)));
586 return runtime->period_size * (count & (runtime->periods-1)); 577 return runtime->period_size * (count & (runtime->periods - 1));
587} 578}
588 579
589/* 580/*
590 * page callback (needed for mmap) 581 * page callback (needed for mmap)
591 */ 582 */
592static struct page *snd_cx88_page(struct snd_pcm_substream *substream, 583static struct page *snd_cx88_page(struct snd_pcm_substream *substream,
593 unsigned long offset) 584 unsigned long offset)
594{ 585{
595 void *pageptr = substream->runtime->dma_area + offset; 586 void *pageptr = substream->runtime->dma_area + offset;
587
596 return vmalloc_to_page(pageptr); 588 return vmalloc_to_page(pageptr);
597} 589}
598 590
@@ -614,7 +606,8 @@ static const struct snd_pcm_ops snd_cx88_pcm_ops = {
614/* 606/*
615 * create a PCM device 607 * create a PCM device
616 */ 608 */
617static int snd_cx88_pcm(snd_cx88_card_t *chip, int device, const char *name) 609static int snd_cx88_pcm(struct cx88_audio_dev *chip, int device,
610 const char *name)
618{ 611{
619 int err; 612 int err;
620 struct snd_pcm *pcm; 613 struct snd_pcm *pcm;
@@ -629,9 +622,9 @@ static int snd_cx88_pcm(snd_cx88_card_t *chip, int device, const char *name)
629 return 0; 622 return 0;
630} 623}
631 624
632/**************************************************************************** 625/*
633 CONTROL INTERFACE 626 * CONTROL INTERFACE
634 ****************************************************************************/ 627 */
635static int snd_cx88_volume_info(struct snd_kcontrol *kcontrol, 628static int snd_cx88_volume_info(struct snd_kcontrol *kcontrol,
636 struct snd_ctl_elem_info *info) 629 struct snd_ctl_elem_info *info)
637{ 630{
@@ -646,8 +639,8 @@ static int snd_cx88_volume_info(struct snd_kcontrol *kcontrol,
646static int snd_cx88_volume_get(struct snd_kcontrol *kcontrol, 639static int snd_cx88_volume_get(struct snd_kcontrol *kcontrol,
647 struct snd_ctl_elem_value *value) 640 struct snd_ctl_elem_value *value)
648{ 641{
649 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); 642 struct cx88_audio_dev *chip = snd_kcontrol_chip(kcontrol);
650 struct cx88_core *core=chip->core; 643 struct cx88_core *core = chip->core;
651 int vol = 0x3f - (cx_read(AUD_VOL_CTL) & 0x3f), 644 int vol = 0x3f - (cx_read(AUD_VOL_CTL) & 0x3f),
652 bal = cx_read(AUD_BAL_CTL); 645 bal = cx_read(AUD_BAL_CTL);
653 646
@@ -659,9 +652,9 @@ static int snd_cx88_volume_get(struct snd_kcontrol *kcontrol,
659} 652}
660 653
661static void snd_cx88_wm8775_volume_put(struct snd_kcontrol *kcontrol, 654static void snd_cx88_wm8775_volume_put(struct snd_kcontrol *kcontrol,
662 struct snd_ctl_elem_value *value) 655 struct snd_ctl_elem_value *value)
663{ 656{
664 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); 657 struct cx88_audio_dev *chip = snd_kcontrol_chip(kcontrol);
665 struct cx88_core *core = chip->core; 658 struct cx88_core *core = chip->core;
666 int left = value->value.integer.value[0]; 659 int left = value->value.integer.value[0];
667 int right = value->value.integer.value[1]; 660 int right = value->value.integer.value[1];
@@ -683,8 +676,8 @@ static void snd_cx88_wm8775_volume_put(struct snd_kcontrol *kcontrol,
683static int snd_cx88_volume_put(struct snd_kcontrol *kcontrol, 676static int snd_cx88_volume_put(struct snd_kcontrol *kcontrol,
684 struct snd_ctl_elem_value *value) 677 struct snd_ctl_elem_value *value)
685{ 678{
686 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); 679 struct cx88_audio_dev *chip = snd_kcontrol_chip(kcontrol);
687 struct cx88_core *core=chip->core; 680 struct cx88_core *core = chip->core;
688 int left, right, v, b; 681 int left, right, v, b;
689 int changed = 0; 682 int changed = 0;
690 u32 old; 683 u32 old;
@@ -733,7 +726,7 @@ static const struct snd_kcontrol_new snd_cx88_volume = {
733static int snd_cx88_switch_get(struct snd_kcontrol *kcontrol, 726static int snd_cx88_switch_get(struct snd_kcontrol *kcontrol,
734 struct snd_ctl_elem_value *value) 727 struct snd_ctl_elem_value *value)
735{ 728{
736 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); 729 struct cx88_audio_dev *chip = snd_kcontrol_chip(kcontrol);
737 struct cx88_core *core = chip->core; 730 struct cx88_core *core = chip->core;
738 u32 bit = kcontrol->private_value; 731 u32 bit = kcontrol->private_value;
739 732
@@ -742,9 +735,9 @@ static int snd_cx88_switch_get(struct snd_kcontrol *kcontrol,
742} 735}
743 736
744static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol, 737static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol,
745 struct snd_ctl_elem_value *value) 738 struct snd_ctl_elem_value *value)
746{ 739{
747 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); 740 struct cx88_audio_dev *chip = snd_kcontrol_chip(kcontrol);
748 struct cx88_core *core = chip->core; 741 struct cx88_core *core = chip->core;
749 u32 bit = kcontrol->private_value; 742 u32 bit = kcontrol->private_value;
750 int ret = 0; 743 int ret = 0;
@@ -756,8 +749,9 @@ static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol,
756 vol ^= bit; 749 vol ^= bit;
757 cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, vol); 750 cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, vol);
758 /* Pass mute onto any WM8775 */ 751 /* Pass mute onto any WM8775 */
759 if (core->sd_wm8775 && ((1<<6) == bit)) 752 if (core->sd_wm8775 && ((1 << 6) == bit))
760 wm8775_s_ctrl(core, V4L2_CID_AUDIO_MUTE, 0 != (vol & bit)); 753 wm8775_s_ctrl(core,
754 V4L2_CID_AUDIO_MUTE, 0 != (vol & bit));
761 ret = 1; 755 ret = 1;
762 } 756 }
763 spin_unlock_irq(&chip->reg_lock); 757 spin_unlock_irq(&chip->reg_lock);
@@ -770,7 +764,7 @@ static const struct snd_kcontrol_new snd_cx88_dac_switch = {
770 .info = snd_ctl_boolean_mono_info, 764 .info = snd_ctl_boolean_mono_info,
771 .get = snd_cx88_switch_get, 765 .get = snd_cx88_switch_get,
772 .put = snd_cx88_switch_put, 766 .put = snd_cx88_switch_put,
773 .private_value = (1<<8), 767 .private_value = (1 << 8),
774}; 768};
775 769
776static const struct snd_kcontrol_new snd_cx88_source_switch = { 770static const struct snd_kcontrol_new snd_cx88_source_switch = {
@@ -779,13 +773,13 @@ static const struct snd_kcontrol_new snd_cx88_source_switch = {
779 .info = snd_ctl_boolean_mono_info, 773 .info = snd_ctl_boolean_mono_info,
780 .get = snd_cx88_switch_get, 774 .get = snd_cx88_switch_get,
781 .put = snd_cx88_switch_put, 775 .put = snd_cx88_switch_put,
782 .private_value = (1<<6), 776 .private_value = (1 << 6),
783}; 777};
784 778
785static int snd_cx88_alc_get(struct snd_kcontrol *kcontrol, 779static int snd_cx88_alc_get(struct snd_kcontrol *kcontrol,
786 struct snd_ctl_elem_value *value) 780 struct snd_ctl_elem_value *value)
787{ 781{
788 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); 782 struct cx88_audio_dev *chip = snd_kcontrol_chip(kcontrol);
789 struct cx88_core *core = chip->core; 783 struct cx88_core *core = chip->core;
790 s32 val; 784 s32 val;
791 785
@@ -795,9 +789,9 @@ static int snd_cx88_alc_get(struct snd_kcontrol *kcontrol,
795} 789}
796 790
797static int snd_cx88_alc_put(struct snd_kcontrol *kcontrol, 791static int snd_cx88_alc_put(struct snd_kcontrol *kcontrol,
798 struct snd_ctl_elem_value *value) 792 struct snd_ctl_elem_value *value)
799{ 793{
800 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); 794 struct cx88_audio_dev *chip = snd_kcontrol_chip(kcontrol);
801 struct cx88_core *core = chip->core; 795 struct cx88_core *core = chip->core;
802 796
803 wm8775_s_ctrl(core, V4L2_CID_AUDIO_LOUDNESS, 797 wm8775_s_ctrl(core, V4L2_CID_AUDIO_LOUDNESS,
@@ -813,9 +807,9 @@ static struct snd_kcontrol_new snd_cx88_alc_switch = {
813 .put = snd_cx88_alc_put, 807 .put = snd_cx88_alc_put,
814}; 808};
815 809
816/**************************************************************************** 810/*
817 Basic Flow for Sound Devices 811 * Basic Flow for Sound Devices
818 ****************************************************************************/ 812 */
819 813
820/* 814/*
821 * PCI ID Table - 14f1:8801 and 14f1:8811 means function 1: Audio 815 * PCI ID Table - 14f1:8801 and 14f1:8811 means function 1: Audio
@@ -823,8 +817,8 @@ static struct snd_kcontrol_new snd_cx88_alc_switch = {
823 */ 817 */
824 818
825static const struct pci_device_id cx88_audio_pci_tbl[] = { 819static const struct pci_device_id cx88_audio_pci_tbl[] = {
826 {0x14f1,0x8801,PCI_ANY_ID,PCI_ANY_ID,0,0,0}, 820 {0x14f1, 0x8801, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
827 {0x14f1,0x8811,PCI_ANY_ID,PCI_ANY_ID,0,0,0}, 821 {0x14f1, 0x8811, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
828 {0, } 822 {0, }
829}; 823};
830MODULE_DEVICE_TABLE(pci, cx88_audio_pci_tbl); 824MODULE_DEVICE_TABLE(pci, cx88_audio_pci_tbl);
@@ -833,13 +827,12 @@ MODULE_DEVICE_TABLE(pci, cx88_audio_pci_tbl);
833 * Chip-specific destructor 827 * Chip-specific destructor
834 */ 828 */
835 829
836static int snd_cx88_free(snd_cx88_card_t *chip) 830static int snd_cx88_free(struct cx88_audio_dev *chip)
837{ 831{
838
839 if (chip->irq >= 0) 832 if (chip->irq >= 0)
840 free_irq(chip->irq, chip); 833 free_irq(chip->irq, chip);
841 834
842 cx88_core_put(chip->core,chip->pci); 835 cx88_core_put(chip->core, chip->pci);
843 836
844 pci_disable_device(chip->pci); 837 pci_disable_device(chip->pci);
845 return 0; 838 return 0;
@@ -848,27 +841,26 @@ static int snd_cx88_free(snd_cx88_card_t *chip)
848/* 841/*
849 * Component Destructor 842 * Component Destructor
850 */ 843 */
851static void snd_cx88_dev_free(struct snd_card * card) 844static void snd_cx88_dev_free(struct snd_card *card)
852{ 845{
853 snd_cx88_card_t *chip = card->private_data; 846 struct cx88_audio_dev *chip = card->private_data;
854 847
855 snd_cx88_free(chip); 848 snd_cx88_free(chip);
856} 849}
857 850
858
859/* 851/*
860 * Alsa Constructor - Component probe 852 * Alsa Constructor - Component probe
861 */ 853 */
862 854
863static int devno; 855static int devno;
864static int snd_cx88_create(struct snd_card *card, struct pci_dev *pci, 856static int snd_cx88_create(struct snd_card *card, struct pci_dev *pci,
865 snd_cx88_card_t **rchip, 857 struct cx88_audio_dev **rchip,
866 struct cx88_core **core_ptr) 858 struct cx88_core **core_ptr)
867{ 859{
868 snd_cx88_card_t *chip; 860 struct cx88_audio_dev *chip;
869 struct cx88_core *core; 861 struct cx88_core *core;
870 int err; 862 int err;
871 unsigned char pci_lat; 863 unsigned char pci_lat;
872 864
873 *rchip = NULL; 865 *rchip = NULL;
874 866
@@ -881,19 +873,18 @@ static int snd_cx88_create(struct snd_card *card, struct pci_dev *pci,
881 chip = card->private_data; 873 chip = card->private_data;
882 874
883 core = cx88_core_get(pci); 875 core = cx88_core_get(pci);
884 if (NULL == core) { 876 if (!core) {
885 err = -EINVAL; 877 err = -EINVAL;
886 return err; 878 return err;
887 } 879 }
888 880
889 err = pci_set_dma_mask(pci,DMA_BIT_MASK(32)); 881 err = pci_set_dma_mask(pci, DMA_BIT_MASK(32));
890 if (err) { 882 if (err) {
891 dprintk(0, "%s/1: Oops: no 32bit PCI DMA ???\n",core->name); 883 dprintk(0, "%s/1: Oops: no 32bit PCI DMA ???\n", core->name);
892 cx88_core_put(core, pci); 884 cx88_core_put(core, pci);
893 return err; 885 return err;
894 } 886 }
895 887
896
897 /* pci init */ 888 /* pci init */
898 chip->card = card; 889 chip->card = card;
899 chip->pci = pci; 890 chip->pci = pci;
@@ -907,17 +898,18 @@ static int snd_cx88_create(struct snd_card *card, struct pci_dev *pci,
907 IRQF_SHARED, chip->core->name, chip); 898 IRQF_SHARED, chip->core->name, chip);
908 if (err < 0) { 899 if (err < 0) {
909 dprintk(0, "%s: can't get IRQ %d\n", 900 dprintk(0, "%s: can't get IRQ %d\n",
910 chip->core->name, chip->pci->irq); 901 chip->core->name, chip->pci->irq);
911 return err; 902 return err;
912 } 903 }
913 904
914 /* print pci info */ 905 /* print pci info */
915 pci_read_config_byte(pci, PCI_LATENCY_TIMER, &pci_lat); 906 pci_read_config_byte(pci, PCI_LATENCY_TIMER, &pci_lat);
916 907
917 dprintk(1,"ALSA %s/%i: found at %s, rev: %d, irq: %d, " 908 dprintk(1,
918 "latency: %d, mmio: 0x%llx\n", core->name, devno, 909 "ALSA %s/%i: found at %s, rev: %d, irq: %d, latency: %d, mmio: 0x%llx\n",
919 pci_name(pci), pci->revision, pci->irq, 910 core->name, devno,
920 pci_lat, (unsigned long long)pci_resource_start(pci,0)); 911 pci_name(pci), pci->revision, pci->irq,
912 pci_lat, (unsigned long long)pci_resource_start(pci, 0));
921 913
922 chip->irq = pci->irq; 914 chip->irq = pci->irq;
923 synchronize_irq(chip->irq); 915 synchronize_irq(chip->irq);
@@ -931,10 +923,10 @@ static int snd_cx88_create(struct snd_card *card, struct pci_dev *pci,
931static int cx88_audio_initdev(struct pci_dev *pci, 923static int cx88_audio_initdev(struct pci_dev *pci,
932 const struct pci_device_id *pci_id) 924 const struct pci_device_id *pci_id)
933{ 925{
934 struct snd_card *card; 926 struct snd_card *card;
935 snd_cx88_card_t *chip; 927 struct cx88_audio_dev *chip;
936 struct cx88_core *core = NULL; 928 struct cx88_core *core = NULL;
937 int err; 929 int err;
938 930
939 if (devno >= SNDRV_CARDS) 931 if (devno >= SNDRV_CARDS)
940 return (-ENODEV); 932 return (-ENODEV);
@@ -945,7 +937,7 @@ static int cx88_audio_initdev(struct pci_dev *pci,
945 } 937 }
946 938
947 err = snd_card_new(&pci->dev, index[devno], id[devno], THIS_MODULE, 939 err = snd_card_new(&pci->dev, index[devno], id[devno], THIS_MODULE,
948 sizeof(snd_cx88_card_t), &card); 940 sizeof(struct cx88_audio_dev), &card);
949 if (err < 0) 941 if (err < 0)
950 return err; 942 return err;
951 943
@@ -973,19 +965,20 @@ static int cx88_audio_initdev(struct pci_dev *pci,
973 if (core->sd_wm8775) 965 if (core->sd_wm8775)
974 snd_ctl_add(card, snd_ctl_new1(&snd_cx88_alc_switch, chip)); 966 snd_ctl_add(card, snd_ctl_new1(&snd_cx88_alc_switch, chip));
975 967
976 strcpy (card->driver, "CX88x"); 968 strcpy(card->driver, "CX88x");
977 sprintf(card->shortname, "Conexant CX%x", pci->device); 969 sprintf(card->shortname, "Conexant CX%x", pci->device);
978 sprintf(card->longname, "%s at %#llx", 970 sprintf(card->longname, "%s at %#llx",
979 card->shortname,(unsigned long long)pci_resource_start(pci, 0)); 971 card->shortname,
980 strcpy (card->mixername, "CX88"); 972 (unsigned long long)pci_resource_start(pci, 0));
973 strcpy(card->mixername, "CX88");
981 974
982 dprintk (0, "%s/%i: ALSA support for cx2388x boards\n", 975 dprintk(0, "%s/%i: ALSA support for cx2388x boards\n",
983 card->driver,devno); 976 card->driver, devno);
984 977
985 err = snd_card_register(card); 978 err = snd_card_register(card);
986 if (err < 0) 979 if (err < 0)
987 goto error; 980 goto error;
988 pci_set_drvdata(pci,card); 981 pci_set_drvdata(pci, card);
989 982
990 devno++; 983 devno++;
991 return 0; 984 return 0;
@@ -994,6 +987,7 @@ error:
994 snd_card_free(card); 987 snd_card_free(card);
995 return err; 988 return err;
996} 989}
990
997/* 991/*
998 * ALSA destructor 992 * ALSA destructor
999 */ 993 */
diff --git a/drivers/media/pci/cx88/cx88-blackbird.c b/drivers/media/pci/cx88/cx88-blackbird.c
index b532e49e8f33..aa49c9597d9c 100644
--- a/drivers/media/pci/cx88/cx88-blackbird.c
+++ b/drivers/media/pci/cx88/cx88-blackbird.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Support for a cx23416 mpeg encoder via cx2388x host port. 2 * Support for a cx23416 mpeg encoder via cx2388x host port.
4 * "blackbird" reference design. 3 * "blackbird" reference design.
5 * 4 *
@@ -20,12 +19,10 @@
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details. 21 * 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 */ 22 */
28 23
24#include "cx88.h"
25
29#include <linux/module.h> 26#include <linux/module.h>
30#include <linux/init.h> 27#include <linux/init.h>
31#include <linux/slab.h> 28#include <linux/slab.h>
@@ -38,21 +35,20 @@
38#include <media/v4l2-event.h> 35#include <media/v4l2-event.h>
39#include <media/drv-intf/cx2341x.h> 36#include <media/drv-intf/cx2341x.h>
40 37
41#include "cx88.h"
42
43MODULE_DESCRIPTION("driver for cx2388x/cx23416 based mpeg encoder cards"); 38MODULE_DESCRIPTION("driver for cx2388x/cx23416 based mpeg encoder cards");
44MODULE_AUTHOR("Jelle Foks <jelle@foks.us>, Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); 39MODULE_AUTHOR("Jelle Foks <jelle@foks.us>, Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
45MODULE_LICENSE("GPL"); 40MODULE_LICENSE("GPL");
46MODULE_VERSION(CX88_VERSION); 41MODULE_VERSION(CX88_VERSION);
47 42
48static unsigned int debug; 43static unsigned int debug;
49module_param(debug,int,0644); 44module_param(debug, int, 0644);
50MODULE_PARM_DESC(debug,"enable debug messages [blackbird]"); 45MODULE_PARM_DESC(debug, "enable debug messages [blackbird]");
51 46
52#define dprintk(level, fmt, arg...) do { \ 47#define dprintk(level, fmt, arg...) do { \
53 if (debug + 1 > level) \ 48 if (debug + 1 > level) \
54 printk(KERN_DEBUG "%s/2-bb: " fmt, dev->core->name , ## arg); \ 49 printk(KERN_DEBUG pr_fmt("%s: blackbird:" fmt), \
55} while(0) 50 __func__, ##arg); \
51} while (0)
56 52
57/* ------------------------------------------------------------------ */ 53/* ------------------------------------------------------------------ */
58 54
@@ -70,6 +66,7 @@ enum blackbird_capture_type {
70 BLACKBIRD_RAW_CAPTURE, 66 BLACKBIRD_RAW_CAPTURE,
71 BLACKBIRD_RAW_PASSTHRU_CAPTURE 67 BLACKBIRD_RAW_PASSTHRU_CAPTURE
72}; 68};
69
73enum blackbird_capture_bits { 70enum blackbird_capture_bits {
74 BLACKBIRD_RAW_BITS_NONE = 0x00, 71 BLACKBIRD_RAW_BITS_NONE = 0x00,
75 BLACKBIRD_RAW_BITS_YUV_CAPTURE = 0x01, 72 BLACKBIRD_RAW_BITS_YUV_CAPTURE = 0x01,
@@ -78,33 +75,40 @@ enum blackbird_capture_bits {
78 BLACKBIRD_RAW_BITS_PASSTHRU_CAPTURE = 0x08, 75 BLACKBIRD_RAW_BITS_PASSTHRU_CAPTURE = 0x08,
79 BLACKBIRD_RAW_BITS_TO_HOST_CAPTURE = 0x10 76 BLACKBIRD_RAW_BITS_TO_HOST_CAPTURE = 0x10
80}; 77};
78
81enum blackbird_capture_end { 79enum blackbird_capture_end {
82 BLACKBIRD_END_AT_GOP, /* stop at the end of gop, generate irq */ 80 BLACKBIRD_END_AT_GOP, /* stop at the end of gop, generate irq */
83 BLACKBIRD_END_NOW, /* stop immediately, no irq */ 81 BLACKBIRD_END_NOW, /* stop immediately, no irq */
84}; 82};
83
85enum blackbird_framerate { 84enum blackbird_framerate {
86 BLACKBIRD_FRAMERATE_NTSC_30, /* NTSC: 30fps */ 85 BLACKBIRD_FRAMERATE_NTSC_30, /* NTSC: 30fps */
87 BLACKBIRD_FRAMERATE_PAL_25 /* PAL: 25fps */ 86 BLACKBIRD_FRAMERATE_PAL_25 /* PAL: 25fps */
88}; 87};
88
89enum blackbird_stream_port { 89enum blackbird_stream_port {
90 BLACKBIRD_OUTPUT_PORT_MEMORY, 90 BLACKBIRD_OUTPUT_PORT_MEMORY,
91 BLACKBIRD_OUTPUT_PORT_STREAMING, 91 BLACKBIRD_OUTPUT_PORT_STREAMING,
92 BLACKBIRD_OUTPUT_PORT_SERIAL 92 BLACKBIRD_OUTPUT_PORT_SERIAL
93}; 93};
94
94enum blackbird_data_xfer_status { 95enum blackbird_data_xfer_status {
95 BLACKBIRD_MORE_BUFFERS_FOLLOW, 96 BLACKBIRD_MORE_BUFFERS_FOLLOW,
96 BLACKBIRD_LAST_BUFFER, 97 BLACKBIRD_LAST_BUFFER,
97}; 98};
99
98enum blackbird_picture_mask { 100enum blackbird_picture_mask {
99 BLACKBIRD_PICTURE_MASK_NONE, 101 BLACKBIRD_PICTURE_MASK_NONE,
100 BLACKBIRD_PICTURE_MASK_I_FRAMES, 102 BLACKBIRD_PICTURE_MASK_I_FRAMES,
101 BLACKBIRD_PICTURE_MASK_I_P_FRAMES = 0x3, 103 BLACKBIRD_PICTURE_MASK_I_P_FRAMES = 0x3,
102 BLACKBIRD_PICTURE_MASK_ALL_FRAMES = 0x7, 104 BLACKBIRD_PICTURE_MASK_ALL_FRAMES = 0x7,
103}; 105};
106
104enum blackbird_vbi_mode_bits { 107enum blackbird_vbi_mode_bits {
105 BLACKBIRD_VBI_BITS_SLICED, 108 BLACKBIRD_VBI_BITS_SLICED,
106 BLACKBIRD_VBI_BITS_RAW, 109 BLACKBIRD_VBI_BITS_RAW,
107}; 110};
111
108enum blackbird_vbi_insertion_bits { 112enum blackbird_vbi_insertion_bits {
109 BLACKBIRD_VBI_BITS_INSERT_IN_XTENSION_USR_DATA, 113 BLACKBIRD_VBI_BITS_INSERT_IN_XTENSION_USR_DATA,
110 BLACKBIRD_VBI_BITS_INSERT_IN_PRIVATE_PACKETS = 0x1 << 1, 114 BLACKBIRD_VBI_BITS_INSERT_IN_PRIVATE_PACKETS = 0x1 << 1,
@@ -112,56 +116,69 @@ enum blackbird_vbi_insertion_bits {
112 BLACKBIRD_VBI_BITS_SEPARATE_STREAM_USR_DATA = 0x4 << 1, 116 BLACKBIRD_VBI_BITS_SEPARATE_STREAM_USR_DATA = 0x4 << 1,
113 BLACKBIRD_VBI_BITS_SEPARATE_STREAM_PRV_DATA = 0x5 << 1, 117 BLACKBIRD_VBI_BITS_SEPARATE_STREAM_PRV_DATA = 0x5 << 1,
114}; 118};
119
115enum blackbird_dma_unit { 120enum blackbird_dma_unit {
116 BLACKBIRD_DMA_BYTES, 121 BLACKBIRD_DMA_BYTES,
117 BLACKBIRD_DMA_FRAMES, 122 BLACKBIRD_DMA_FRAMES,
118}; 123};
124
119enum blackbird_dma_transfer_status_bits { 125enum blackbird_dma_transfer_status_bits {
120 BLACKBIRD_DMA_TRANSFER_BITS_DONE = 0x01, 126 BLACKBIRD_DMA_TRANSFER_BITS_DONE = 0x01,
121 BLACKBIRD_DMA_TRANSFER_BITS_ERROR = 0x04, 127 BLACKBIRD_DMA_TRANSFER_BITS_ERROR = 0x04,
122 BLACKBIRD_DMA_TRANSFER_BITS_LL_ERROR = 0x10, 128 BLACKBIRD_DMA_TRANSFER_BITS_LL_ERROR = 0x10,
123}; 129};
130
124enum blackbird_pause { 131enum blackbird_pause {
125 BLACKBIRD_PAUSE_ENCODING, 132 BLACKBIRD_PAUSE_ENCODING,
126 BLACKBIRD_RESUME_ENCODING, 133 BLACKBIRD_RESUME_ENCODING,
127}; 134};
135
128enum blackbird_copyright { 136enum blackbird_copyright {
129 BLACKBIRD_COPYRIGHT_OFF, 137 BLACKBIRD_COPYRIGHT_OFF,
130 BLACKBIRD_COPYRIGHT_ON, 138 BLACKBIRD_COPYRIGHT_ON,
131}; 139};
140
132enum blackbird_notification_type { 141enum blackbird_notification_type {
133 BLACKBIRD_NOTIFICATION_REFRESH, 142 BLACKBIRD_NOTIFICATION_REFRESH,
134}; 143};
144
135enum blackbird_notification_status { 145enum blackbird_notification_status {
136 BLACKBIRD_NOTIFICATION_OFF, 146 BLACKBIRD_NOTIFICATION_OFF,
137 BLACKBIRD_NOTIFICATION_ON, 147 BLACKBIRD_NOTIFICATION_ON,
138}; 148};
149
139enum blackbird_notification_mailbox { 150enum blackbird_notification_mailbox {
140 BLACKBIRD_NOTIFICATION_NO_MAILBOX = -1, 151 BLACKBIRD_NOTIFICATION_NO_MAILBOX = -1,
141}; 152};
153
142enum blackbird_field1_lines { 154enum blackbird_field1_lines {
143 BLACKBIRD_FIELD1_SAA7114 = 0x00EF, /* 239 */ 155 BLACKBIRD_FIELD1_SAA7114 = 0x00EF, /* 239 */
144 BLACKBIRD_FIELD1_SAA7115 = 0x00F0, /* 240 */ 156 BLACKBIRD_FIELD1_SAA7115 = 0x00F0, /* 240 */
145 BLACKBIRD_FIELD1_MICRONAS = 0x0105, /* 261 */ 157 BLACKBIRD_FIELD1_MICRONAS = 0x0105, /* 261 */
146}; 158};
159
147enum blackbird_field2_lines { 160enum blackbird_field2_lines {
148 BLACKBIRD_FIELD2_SAA7114 = 0x00EF, /* 239 */ 161 BLACKBIRD_FIELD2_SAA7114 = 0x00EF, /* 239 */
149 BLACKBIRD_FIELD2_SAA7115 = 0x00F0, /* 240 */ 162 BLACKBIRD_FIELD2_SAA7115 = 0x00F0, /* 240 */
150 BLACKBIRD_FIELD2_MICRONAS = 0x0106, /* 262 */ 163 BLACKBIRD_FIELD2_MICRONAS = 0x0106, /* 262 */
151}; 164};
165
152enum blackbird_custom_data_type { 166enum blackbird_custom_data_type {
153 BLACKBIRD_CUSTOM_EXTENSION_USR_DATA, 167 BLACKBIRD_CUSTOM_EXTENSION_USR_DATA,
154 BLACKBIRD_CUSTOM_PRIVATE_PACKET, 168 BLACKBIRD_CUSTOM_PRIVATE_PACKET,
155}; 169};
170
156enum blackbird_mute { 171enum blackbird_mute {
157 BLACKBIRD_UNMUTE, 172 BLACKBIRD_UNMUTE,
158 BLACKBIRD_MUTE, 173 BLACKBIRD_MUTE,
159}; 174};
175
160enum blackbird_mute_video_mask { 176enum blackbird_mute_video_mask {
161 BLACKBIRD_MUTE_VIDEO_V_MASK = 0x0000FF00, 177 BLACKBIRD_MUTE_VIDEO_V_MASK = 0x0000FF00,
162 BLACKBIRD_MUTE_VIDEO_U_MASK = 0x00FF0000, 178 BLACKBIRD_MUTE_VIDEO_U_MASK = 0x00FF0000,
163 BLACKBIRD_MUTE_VIDEO_Y_MASK = 0xFF000000, 179 BLACKBIRD_MUTE_VIDEO_Y_MASK = 0xFF000000,
164}; 180};
181
165enum blackbird_mute_video_shift { 182enum blackbird_mute_video_shift {
166 BLACKBIRD_MUTE_VIDEO_V_SHIFT = 8, 183 BLACKBIRD_MUTE_VIDEO_V_SHIFT = 8,
167 BLACKBIRD_MUTE_VIDEO_U_SHIFT = 16, 184 BLACKBIRD_MUTE_VIDEO_U_SHIFT = 16,
@@ -215,14 +232,14 @@ static void host_setup(struct cx88_core *core)
215static int wait_ready_gpio0_bit1(struct cx88_core *core, u32 state) 232static int wait_ready_gpio0_bit1(struct cx88_core *core, u32 state)
216{ 233{
217 unsigned long timeout = jiffies + msecs_to_jiffies(1); 234 unsigned long timeout = jiffies + msecs_to_jiffies(1);
218 u32 gpio0,need; 235 u32 gpio0, need;
219 236
220 need = state ? 2 : 0; 237 need = state ? 2 : 0;
221 for (;;) { 238 for (;;) {
222 gpio0 = cx_read(MO_GP0_IO) & 2; 239 gpio0 = cx_read(MO_GP0_IO) & 2;
223 if (need == gpio0) 240 if (need == gpio0)
224 return 0; 241 return 0;
225 if (time_after(jiffies,timeout)) 242 if (time_after(jiffies, timeout))
226 return -1; 243 return -1;
227 udelay(1); 244 udelay(1);
228 } 245 }
@@ -241,7 +258,7 @@ static int memory_write(struct cx88_core *core, u32 address, u32 value)
241 cx_read(P1_MDATA0); 258 cx_read(P1_MDATA0);
242 cx_read(P1_MADDR0); 259 cx_read(P1_MADDR0);
243 260
244 return wait_ready_gpio0_bit1(core,1); 261 return wait_ready_gpio0_bit1(core, 1);
245} 262}
246 263
247static int memory_read(struct cx88_core *core, u32 address, u32 *value) 264static int memory_read(struct cx88_core *core, u32 address, u32 *value)
@@ -255,7 +272,7 @@ static int memory_read(struct cx88_core *core, u32 address, u32 *value)
255 cx_writeb(P1_MADDR0, (unsigned int)address); 272 cx_writeb(P1_MADDR0, (unsigned int)address);
256 cx_read(P1_MADDR0); 273 cx_read(P1_MADDR0);
257 274
258 retval = wait_ready_gpio0_bit1(core,1); 275 retval = wait_ready_gpio0_bit1(core, 1);
259 276
260 cx_writeb(P1_MDATA3, 0); 277 cx_writeb(P1_MDATA3, 0);
261 val = (unsigned char)cx_read(P1_MDATA3) << 24; 278 val = (unsigned char)cx_read(P1_MDATA3) << 24;
@@ -282,10 +299,9 @@ static int register_write(struct cx88_core *core, u32 address, u32 value)
282 cx_read(P1_RDATA0); 299 cx_read(P1_RDATA0);
283 cx_read(P1_RADDR0); 300 cx_read(P1_RADDR0);
284 301
285 return wait_ready_gpio0_bit1(core,1); 302 return wait_ready_gpio0_bit1(core, 1);
286} 303}
287 304
288
289static int register_read(struct cx88_core *core, u32 address, u32 *value) 305static int register_read(struct cx88_core *core, u32 address, u32 *value)
290{ 306{
291 int retval; 307 int retval;
@@ -296,7 +312,7 @@ static int register_read(struct cx88_core *core, u32 address, u32 *value)
296 cx_writeb(P1_RRDWR, 0); 312 cx_writeb(P1_RRDWR, 0);
297 cx_read(P1_RADDR0); 313 cx_read(P1_RADDR0);
298 314
299 retval = wait_ready_gpio0_bit1(core,1); 315 retval = wait_ready_gpio0_bit1(core, 1);
300 val = (unsigned char)cx_read(P1_RDATA0); 316 val = (unsigned char)cx_read(P1_RDATA0);
301 val |= (unsigned char)cx_read(P1_RDATA1) << 8; 317 val |= (unsigned char)cx_read(P1_RDATA1) << 8;
302 val |= (unsigned char)cx_read(P1_RDATA2) << 16; 318 val |= (unsigned char)cx_read(P1_RDATA2) << 16;
@@ -308,20 +324,24 @@ static int register_read(struct cx88_core *core, u32 address, u32 *value)
308 324
309/* ------------------------------------------------------------------ */ 325/* ------------------------------------------------------------------ */
310 326
311static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 data[CX2341X_MBOX_MAX_DATA]) 327static int blackbird_mbox_func(void *priv, u32 command, int in,
328 int out, u32 data[CX2341X_MBOX_MAX_DATA])
312{ 329{
313 struct cx8802_dev *dev = priv; 330 struct cx8802_dev *dev = priv;
314 unsigned long timeout; 331 unsigned long timeout;
315 u32 value, flag, retval; 332 u32 value, flag, retval;
316 int i; 333 int i;
317 334
318 dprintk(1,"%s: 0x%X\n", __func__, command); 335 dprintk(1, "%s: 0x%X\n", __func__, command);
319 336
320 /* this may not be 100% safe if we can't read any memory location 337 /*
321 without side effects */ 338 * this may not be 100% safe if we can't read any memory location
339 * without side effects
340 */
322 memory_read(dev->core, dev->mailbox - 4, &value); 341 memory_read(dev->core, dev->mailbox - 4, &value);
323 if (value != 0x12345678) { 342 if (value != 0x12345678) {
324 dprintk(0, "Firmware and/or mailbox pointer not initialized or corrupted\n"); 343 dprintk(0,
344 "Firmware and/or mailbox pointer not initialized or corrupted\n");
325 return -EIO; 345 return -EIO;
326 } 346 }
327 347
@@ -336,7 +356,8 @@ static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 dat
336 356
337 /* write command + args + fill remaining with zeros */ 357 /* write command + args + fill remaining with zeros */
338 memory_write(dev->core, dev->mailbox + 1, command); /* command code */ 358 memory_write(dev->core, dev->mailbox + 1, command); /* command code */
339 memory_write(dev->core, dev->mailbox + 3, IVTV_API_STD_TIMEOUT); /* timeout */ 359 /* timeout */
360 memory_write(dev->core, dev->mailbox + 3, IVTV_API_STD_TIMEOUT);
340 for (i = 0; i < in; i++) { 361 for (i = 0; i < in; i++) {
341 memory_write(dev->core, dev->mailbox + 4 + i, data[i]); 362 memory_write(dev->core, dev->mailbox + 4 + i, data[i]);
342 dprintk(1, "API Input %d = %d\n", i, data[i]); 363 dprintk(1, "API Input %d = %d\n", i, data[i]);
@@ -353,7 +374,7 @@ static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 dat
353 memory_read(dev->core, dev->mailbox, &flag); 374 memory_read(dev->core, dev->mailbox, &flag);
354 if (0 != (flag & 4)) 375 if (0 != (flag & 4))
355 break; 376 break;
356 if (time_after(jiffies,timeout)) { 377 if (time_after(jiffies, timeout)) {
357 dprintk(0, "ERROR: API Mailbox timeout %x\n", command); 378 dprintk(0, "ERROR: API Mailbox timeout %x\n", command);
358 return -EIO; 379 return -EIO;
359 } 380 }
@@ -367,15 +388,19 @@ static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 dat
367 } 388 }
368 389
369 memory_read(dev->core, dev->mailbox + 2, &retval); 390 memory_read(dev->core, dev->mailbox + 2, &retval);
370 dprintk(1, "API result = %d\n",retval); 391 dprintk(1, "API result = %d\n", retval);
371 392
372 flag = 0; 393 flag = 0;
373 memory_write(dev->core, dev->mailbox, flag); 394 memory_write(dev->core, dev->mailbox, flag);
374 return retval; 395 return retval;
375} 396}
397
376/* ------------------------------------------------------------------ */ 398/* ------------------------------------------------------------------ */
377 399
378/* We don't need to call the API often, so using just one mailbox will probably suffice */ 400/*
401 * We don't need to call the API often, so using just one mailbox
402 * will probably suffice
403 */
379static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command, 404static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command,
380 u32 inputcnt, u32 outputcnt, ...) 405 u32 inputcnt, u32 outputcnt, ...)
381{ 406{
@@ -385,9 +410,9 @@ static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command,
385 410
386 va_start(vargs, outputcnt); 411 va_start(vargs, outputcnt);
387 412
388 for (i = 0; i < inputcnt; i++) { 413 for (i = 0; i < inputcnt; i++)
389 data[i] = va_arg(vargs, int); 414 data[i] = va_arg(vargs, int);
390 } 415
391 err = blackbird_mbox_func(dev, command, inputcnt, outputcnt, data); 416 err = blackbird_mbox_func(dev, command, inputcnt, outputcnt, data);
392 for (i = 0; i < outputcnt; i++) { 417 for (i = 0; i < outputcnt; i++) {
393 int *vptr = va_arg(vargs, int *); 418 int *vptr = va_arg(vargs, int *);
@@ -399,8 +424,8 @@ static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command,
399 424
400static int blackbird_find_mailbox(struct cx8802_dev *dev) 425static int blackbird_find_mailbox(struct cx8802_dev *dev)
401{ 426{
402 u32 signature[4]={0x12345678, 0x34567812, 0x56781234, 0x78123456}; 427 u32 signature[4] = {0x12345678, 0x34567812, 0x56781234, 0x78123456};
403 int signaturecnt=0; 428 int signaturecnt = 0;
404 u32 value; 429 u32 value;
405 int i; 430 int i;
406 431
@@ -410,9 +435,9 @@ static int blackbird_find_mailbox(struct cx8802_dev *dev)
410 signaturecnt++; 435 signaturecnt++;
411 else 436 else
412 signaturecnt = 0; 437 signaturecnt = 0;
413 if (4 == signaturecnt) { 438 if (signaturecnt == 4) {
414 dprintk(1, "Mailbox signature found\n"); 439 dprintk(1, "Mailbox signature found\n");
415 return i+1; 440 return i + 1;
416 } 441 }
417 } 442 }
418 dprintk(0, "Mailbox signature values not found!\n"); 443 dprintk(0, "Mailbox signature values not found!\n");
@@ -431,10 +456,13 @@ static int blackbird_load_firmware(struct cx8802_dev *dev)
431 __le32 *dataptr; 456 __le32 *dataptr;
432 457
433 retval = register_write(dev->core, IVTV_REG_VPU, 0xFFFFFFED); 458 retval = register_write(dev->core, IVTV_REG_VPU, 0xFFFFFFED);
434 retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST); 459 retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS,
435 retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_REFRESH, 0x80000640); 460 IVTV_CMD_HW_BLOCKS_RST);
436 retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_PRECHARGE, 0x1A); 461 retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_REFRESH,
437 msleep(1); 462 0x80000640);
463 retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_PRECHARGE,
464 0x1A);
465 usleep_range(10000, 20000);
438 retval |= register_write(dev->core, IVTV_REG_APU, 0); 466 retval |= register_write(dev->core, IVTV_REG_APU, 0);
439 467
440 if (retval < 0) 468 if (retval < 0)
@@ -443,29 +471,28 @@ static int blackbird_load_firmware(struct cx8802_dev *dev)
443 retval = request_firmware(&firmware, CX2341X_FIRM_ENC_FILENAME, 471 retval = request_firmware(&firmware, CX2341X_FIRM_ENC_FILENAME,
444 &dev->pci->dev); 472 &dev->pci->dev);
445 473
446
447 if (retval != 0) { 474 if (retval != 0) {
448 pr_err("Hotplug firmware request failed (%s).\n", 475 pr_err("Hotplug firmware request failed (%s).\n",
449 CX2341X_FIRM_ENC_FILENAME); 476 CX2341X_FIRM_ENC_FILENAME);
450 pr_err("Please fix your hotplug setup, the board will not work without firmware loaded!\n"); 477 pr_err("Please fix your hotplug setup, the board will not work without firmware loaded!\n");
451 return -EIO; 478 return -EIO;
452 } 479 }
453 480
454 if (firmware->size != BLACKBIRD_FIRM_IMAGE_SIZE) { 481 if (firmware->size != BLACKBIRD_FIRM_IMAGE_SIZE) {
455 pr_err("Firmware size mismatch (have %zd, expected %d)\n", 482 pr_err("Firmware size mismatch (have %zd, expected %d)\n",
456 firmware->size, BLACKBIRD_FIRM_IMAGE_SIZE); 483 firmware->size, BLACKBIRD_FIRM_IMAGE_SIZE);
457 release_firmware(firmware); 484 release_firmware(firmware);
458 return -EINVAL; 485 return -EINVAL;
459 } 486 }
460 487
461 if (0 != memcmp(firmware->data, magic, 8)) { 488 if (memcmp(firmware->data, magic, 8) != 0) {
462 pr_err("Firmware magic mismatch, wrong file?\n"); 489 pr_err("Firmware magic mismatch, wrong file?\n");
463 release_firmware(firmware); 490 release_firmware(firmware);
464 return -EINVAL; 491 return -EINVAL;
465 } 492 }
466 493
467 /* transfer to the chip */ 494 /* transfer to the chip */
468 dprintk(1,"Loading firmware ...\n"); 495 dprintk(1, "Loading firmware ...\n");
469 dataptr = (__le32 *)firmware->data; 496 dataptr = (__le32 *)firmware->data;
470 for (i = 0; i < (firmware->size >> 2); i++) { 497 for (i = 0; i < (firmware->size >> 2); i++) {
471 value = le32_to_cpu(*dataptr); 498 value = le32_to_cpu(*dataptr);
@@ -486,10 +513,11 @@ static int blackbird_load_firmware(struct cx8802_dev *dev)
486 } 513 }
487 dprintk(0, "Firmware upload successful.\n"); 514 dprintk(0, "Firmware upload successful.\n");
488 515
489 retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST); 516 retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS,
517 IVTV_CMD_HW_BLOCKS_RST);
490 retval |= register_read(dev->core, IVTV_REG_SPU, &value); 518 retval |= register_read(dev->core, IVTV_REG_SPU, &value);
491 retval |= register_write(dev->core, IVTV_REG_SPU, value & 0xFFFFFFFE); 519 retval |= register_write(dev->core, IVTV_REG_SPU, value & 0xFFFFFFFE);
492 msleep(1); 520 usleep_range(10000, 20000);
493 521
494 retval |= register_read(dev->core, IVTV_REG_VPU, &value); 522 retval |= register_read(dev->core, IVTV_REG_VPU, &value);
495 retval |= register_write(dev->core, IVTV_REG_VPU, value & 0xFFFFFFE8); 523 retval |= register_write(dev->core, IVTV_REG_VPU, value & 0xFFFFFFE8);
@@ -499,19 +527,19 @@ static int blackbird_load_firmware(struct cx8802_dev *dev)
499 return 0; 527 return 0;
500} 528}
501 529
502/** 530/*
503 Settings used by the windows tv app for PVR2000: 531 * Settings used by the windows tv app for PVR2000:
504================================================================================================================= 532 * =================================================================================================================
505Profile | Codec | Resolution | CBR/VBR | Video Qlty | V. Bitrate | Frmrate | Audio Codec | A. Bitrate | A. Mode 533 * Profile | Codec | Resolution | CBR/VBR | Video Qlty | V. Bitrate | Frmrate | Audio Codec | A. Bitrate | A. Mode
506----------------------------------------------------------------------------------------------------------------- 534 * -----------------------------------------------------------------------------------------------------------------
507MPEG-1 | MPEG1 | 352x288PAL | (CBR) | 1000:Optimal | 2000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo 535 * MPEG-1 | MPEG1 | 352x288PAL | (CBR) | 1000:Optimal | 2000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo
508MPEG-2 | MPEG2 | 720x576PAL | VBR | 600 :Good | 4000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo 536 * MPEG-2 | MPEG2 | 720x576PAL | VBR | 600 :Good | 4000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo
509VCD | MPEG1 | 352x288PAL | (CBR) | 1000:Optimal | 1150 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo 537 * VCD | MPEG1 | 352x288PAL | (CBR) | 1000:Optimal | 1150 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo
510DVD | MPEG2 | 720x576PAL | VBR | 600 :Good | 6000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo 538 * DVD | MPEG2 | 720x576PAL | VBR | 600 :Good | 6000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo
511DB* DVD | MPEG2 | 720x576PAL | CBR | 600 :Good | 6000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo 539 * DB* DVD | MPEG2 | 720x576PAL | CBR | 600 :Good | 6000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo
512================================================================================================================= 540 * =================================================================================================================
513*DB: "DirectBurn" 541 * [*] DB: "DirectBurn"
514*/ 542 */
515 543
516static void blackbird_codec_settings(struct cx8802_dev *dev) 544static void blackbird_codec_settings(struct cx8802_dev *dev)
517{ 545{
@@ -519,11 +547,12 @@ static void blackbird_codec_settings(struct cx8802_dev *dev)
519 547
520 /* assign frame size */ 548 /* assign frame size */
521 blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0, 549 blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0,
522 core->height, core->width); 550 core->height, core->width);
523 551
524 dev->cxhdl.width = core->width; 552 dev->cxhdl.width = core->width;
525 dev->cxhdl.height = core->height; 553 dev->cxhdl.height = core->height;
526 cx2341x_handler_set_50hz(&dev->cxhdl, dev->core->tvnorm & V4L2_STD_625_50); 554 cx2341x_handler_set_50hz(&dev->cxhdl,
555 dev->core->tvnorm & V4L2_STD_625_50);
527 cx2341x_handler_setup(&dev->cxhdl); 556 cx2341x_handler_setup(&dev->cxhdl);
528} 557}
529 558
@@ -533,7 +562,7 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev)
533 int version; 562 int version;
534 int retval; 563 int retval;
535 564
536 dprintk(1,"Initialize codec\n"); 565 dprintk(1, "Initialize codec\n");
537 retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */ 566 retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */
538 if (retval < 0) { 567 if (retval < 0) {
539 /* ping was not successful, reset and upload firmware */ 568 /* ping was not successful, reset and upload firmware */
@@ -549,15 +578,18 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev)
549 578
550 dev->mailbox = retval; 579 dev->mailbox = retval;
551 580
552 retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */ 581 /* ping */
582 retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0);
553 if (retval < 0) { 583 if (retval < 0) {
554 dprintk(0, "ERROR: Firmware ping failed!\n"); 584 dprintk(0, "ERROR: Firmware ping failed!\n");
555 return -1; 585 return -1;
556 } 586 }
557 587
558 retval = blackbird_api_cmd(dev, CX2341X_ENC_GET_VERSION, 0, 1, &version); 588 retval = blackbird_api_cmd(dev, CX2341X_ENC_GET_VERSION,
589 0, 1, &version);
559 if (retval < 0) { 590 if (retval < 0) {
560 dprintk(0, "ERROR: Firmware get encoder version failed!\n"); 591 dprintk(0,
592 "ERROR: Firmware get encoder version failed!\n");
561 return -1; 593 return -1;
562 } 594 }
563 dprintk(0, "Firmware version is 0x%08x\n", version); 595 dprintk(0, "Firmware version is 0x%08x\n", version);
@@ -571,13 +603,11 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev)
571 blackbird_codec_settings(dev); 603 blackbird_codec_settings(dev);
572 604
573 blackbird_api_cmd(dev, CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, 0, 605 blackbird_api_cmd(dev, CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, 0,
574 BLACKBIRD_FIELD1_SAA7115, 606 BLACKBIRD_FIELD1_SAA7115, BLACKBIRD_FIELD2_SAA7115);
575 BLACKBIRD_FIELD2_SAA7115
576 );
577 607
578 blackbird_api_cmd(dev, CX2341X_ENC_SET_PLACEHOLDER, 12, 0, 608 blackbird_api_cmd(dev, CX2341X_ENC_SET_PLACEHOLDER, 12, 0,
579 BLACKBIRD_CUSTOM_EXTENSION_USR_DATA, 609 BLACKBIRD_CUSTOM_EXTENSION_USR_DATA,
580 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 610 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
581 611
582 return 0; 612 return 0;
583} 613}
@@ -615,9 +645,7 @@ static int blackbird_start_codec(struct cx8802_dev *dev)
615 645
616 /* start capturing to the host interface */ 646 /* start capturing to the host interface */
617 blackbird_api_cmd(dev, CX2341X_ENC_START_CAPTURE, 2, 0, 647 blackbird_api_cmd(dev, CX2341X_ENC_START_CAPTURE, 2, 0,
618 BLACKBIRD_MPEG_CAPTURE, 648 BLACKBIRD_MPEG_CAPTURE, BLACKBIRD_RAW_BITS_NONE);
619 BLACKBIRD_RAW_BITS_NONE
620 );
621 649
622 return 0; 650 return 0;
623} 651}
@@ -625,10 +653,9 @@ static int blackbird_start_codec(struct cx8802_dev *dev)
625static int blackbird_stop_codec(struct cx8802_dev *dev) 653static int blackbird_stop_codec(struct cx8802_dev *dev)
626{ 654{
627 blackbird_api_cmd(dev, CX2341X_ENC_STOP_CAPTURE, 3, 0, 655 blackbird_api_cmd(dev, CX2341X_ENC_STOP_CAPTURE, 3, 0,
628 BLACKBIRD_END_NOW, 656 BLACKBIRD_END_NOW,
629 BLACKBIRD_MPEG_CAPTURE, 657 BLACKBIRD_MPEG_CAPTURE,
630 BLACKBIRD_RAW_BITS_NONE 658 BLACKBIRD_RAW_BITS_NONE);
631 );
632 659
633 cx2341x_handler_set_busy(&dev->cxhdl, 0); 660 cx2341x_handler_set_busy(&dev->cxhdl, 0);
634 661
@@ -638,8 +665,8 @@ static int blackbird_stop_codec(struct cx8802_dev *dev)
638/* ------------------------------------------------------------------ */ 665/* ------------------------------------------------------------------ */
639 666
640static int queue_setup(struct vb2_queue *q, 667static int queue_setup(struct vb2_queue *q,
641 unsigned int *num_buffers, unsigned int *num_planes, 668 unsigned int *num_buffers, unsigned int *num_planes,
642 unsigned int sizes[], struct device *alloc_devs[]) 669 unsigned int sizes[], struct device *alloc_devs[])
643{ 670{
644 struct cx8802_dev *dev = q->drv_priv; 671 struct cx8802_dev *dev = q->drv_priv;
645 672
@@ -699,7 +726,8 @@ static int start_streaming(struct vb2_queue *q, unsigned int count)
699 726
700 err = drv->request_acquire(drv); 727 err = drv->request_acquire(drv);
701 if (err != 0) { 728 if (err != 0) {
702 dprintk(1, "%s: Unable to acquire hardware, %d\n", __func__, err); 729 dprintk(1, "%s: Unable to acquire hardware, %d\n", __func__,
730 err);
703 goto fail; 731 goto fail;
704 } 732 }
705 733
@@ -770,7 +798,7 @@ static const struct vb2_ops blackbird_qops = {
770/* ------------------------------------------------------------------ */ 798/* ------------------------------------------------------------------ */
771 799
772static int vidioc_querycap(struct file *file, void *priv, 800static int vidioc_querycap(struct file *file, void *priv,
773 struct v4l2_capability *cap) 801 struct v4l2_capability *cap)
774{ 802{
775 struct cx8802_dev *dev = video_drvdata(file); 803 struct cx8802_dev *dev = video_drvdata(file);
776 struct cx88_core *core = dev->core; 804 struct cx88_core *core = dev->core;
@@ -781,8 +809,8 @@ static int vidioc_querycap(struct file *file, void *priv,
781 return 0; 809 return 0;
782} 810}
783 811
784static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv, 812static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
785 struct v4l2_fmtdesc *f) 813 struct v4l2_fmtdesc *f)
786{ 814{
787 if (f->index != 0) 815 if (f->index != 0)
788 return -EINVAL; 816 return -EINVAL;
@@ -794,7 +822,7 @@ static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv,
794} 822}
795 823
796static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, 824static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
797 struct v4l2_format *f) 825 struct v4l2_format *f)
798{ 826{
799 struct cx8802_dev *dev = video_drvdata(file); 827 struct cx8802_dev *dev = video_drvdata(file);
800 struct cx88_core *core = dev->core; 828 struct cx88_core *core = dev->core;
@@ -810,11 +838,11 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
810} 838}
811 839
812static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, 840static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
813 struct v4l2_format *f) 841 struct v4l2_format *f)
814{ 842{
815 struct cx8802_dev *dev = video_drvdata(file); 843 struct cx8802_dev *dev = video_drvdata(file);
816 struct cx88_core *core = dev->core; 844 struct cx88_core *core = dev->core;
817 unsigned maxw, maxh; 845 unsigned int maxw, maxh;
818 enum v4l2_field field; 846 enum v4l2_field field;
819 847
820 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; 848 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
@@ -850,7 +878,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
850} 878}
851 879
852static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, 880static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
853 struct v4l2_format *f) 881 struct v4l2_format *f)
854{ 882{
855 struct cx8802_dev *dev = video_drvdata(file); 883 struct cx8802_dev *dev = video_drvdata(file);
856 struct cx88_core *core = dev->core; 884 struct cx88_core *core = dev->core;
@@ -864,20 +892,21 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
864 core->width = f->fmt.pix.width; 892 core->width = f->fmt.pix.width;
865 core->height = f->fmt.pix.height; 893 core->height = f->fmt.pix.height;
866 core->field = f->fmt.pix.field; 894 core->field = f->fmt.pix.field;
867 cx88_set_scale(core, f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field); 895 cx88_set_scale(core, f->fmt.pix.width, f->fmt.pix.height,
896 f->fmt.pix.field);
868 blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0, 897 blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0,
869 f->fmt.pix.height, f->fmt.pix.width); 898 f->fmt.pix.height, f->fmt.pix.width);
870 return 0; 899 return 0;
871} 900}
872 901
873static int vidioc_s_frequency (struct file *file, void *priv, 902static int vidioc_s_frequency(struct file *file, void *priv,
874 const struct v4l2_frequency *f) 903 const struct v4l2_frequency *f)
875{ 904{
876 struct cx8802_dev *dev = video_drvdata(file); 905 struct cx8802_dev *dev = video_drvdata(file);
877 struct cx88_core *core = dev->core; 906 struct cx88_core *core = dev->core;
878 bool streaming; 907 bool streaming;
879 908
880 if (unlikely(UNSET == core->board.tuner_type)) 909 if (unlikely(core->board.tuner_type == UNSET))
881 return -EINVAL; 910 return -EINVAL;
882 if (unlikely(f->tuner != 0)) 911 if (unlikely(f->tuner != 0))
883 return -EINVAL; 912 return -EINVAL;
@@ -885,16 +914,15 @@ static int vidioc_s_frequency (struct file *file, void *priv,
885 if (streaming) 914 if (streaming)
886 blackbird_stop_codec(dev); 915 blackbird_stop_codec(dev);
887 916
888 cx88_set_freq (core,f); 917 cx88_set_freq(core, f);
889 blackbird_initialize_codec(dev); 918 blackbird_initialize_codec(dev);
890 cx88_set_scale(core, core->width, core->height, 919 cx88_set_scale(core, core->width, core->height, core->field);
891 core->field);
892 if (streaming) 920 if (streaming)
893 blackbird_start_codec(dev); 921 blackbird_start_codec(dev);
894 return 0; 922 return 0;
895} 923}
896 924
897static int vidioc_log_status (struct file *file, void *priv) 925static int vidioc_log_status(struct file *file, void *priv)
898{ 926{
899 struct cx8802_dev *dev = video_drvdata(file); 927 struct cx8802_dev *dev = video_drvdata(file);
900 struct cx88_core *core = dev->core; 928 struct cx88_core *core = dev->core;
@@ -906,21 +934,22 @@ static int vidioc_log_status (struct file *file, void *priv)
906 return 0; 934 return 0;
907} 935}
908 936
909static int vidioc_enum_input (struct file *file, void *priv, 937static int vidioc_enum_input(struct file *file, void *priv,
910 struct v4l2_input *i) 938 struct v4l2_input *i)
911{ 939{
912 struct cx8802_dev *dev = video_drvdata(file); 940 struct cx8802_dev *dev = video_drvdata(file);
913 struct cx88_core *core = dev->core; 941 struct cx88_core *core = dev->core;
914 return cx88_enum_input (core,i); 942
943 return cx88_enum_input(core, i);
915} 944}
916 945
917static int vidioc_g_frequency (struct file *file, void *priv, 946static int vidioc_g_frequency(struct file *file, void *priv,
918 struct v4l2_frequency *f) 947 struct v4l2_frequency *f)
919{ 948{
920 struct cx8802_dev *dev = video_drvdata(file); 949 struct cx8802_dev *dev = video_drvdata(file);
921 struct cx88_core *core = dev->core; 950 struct cx88_core *core = dev->core;
922 951
923 if (unlikely(UNSET == core->board.tuner_type)) 952 if (unlikely(core->board.tuner_type == UNSET))
924 return -EINVAL; 953 return -EINVAL;
925 if (unlikely(f->tuner != 0)) 954 if (unlikely(f->tuner != 0))
926 return -EINVAL; 955 return -EINVAL;
@@ -931,7 +960,7 @@ static int vidioc_g_frequency (struct file *file, void *priv,
931 return 0; 960 return 0;
932} 961}
933 962
934static int vidioc_g_input (struct file *file, void *priv, unsigned int *i) 963static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
935{ 964{
936 struct cx8802_dev *dev = video_drvdata(file); 965 struct cx8802_dev *dev = video_drvdata(file);
937 struct cx88_core *core = dev->core; 966 struct cx88_core *core = dev->core;
@@ -940,31 +969,31 @@ static int vidioc_g_input (struct file *file, void *priv, unsigned int *i)
940 return 0; 969 return 0;
941} 970}
942 971
943static int vidioc_s_input (struct file *file, void *priv, unsigned int i) 972static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
944{ 973{
945 struct cx8802_dev *dev = video_drvdata(file); 974 struct cx8802_dev *dev = video_drvdata(file);
946 struct cx88_core *core = dev->core; 975 struct cx88_core *core = dev->core;
947 976
948 if (i >= 4) 977 if (i >= 4)
949 return -EINVAL; 978 return -EINVAL;
950 if (0 == INPUT(i).type) 979 if (!INPUT(i).type)
951 return -EINVAL; 980 return -EINVAL;
952 981
953 cx88_newstation(core); 982 cx88_newstation(core);
954 cx88_video_mux(core,i); 983 cx88_video_mux(core, i);
955 return 0; 984 return 0;
956} 985}
957 986
958static int vidioc_g_tuner (struct file *file, void *priv, 987static int vidioc_g_tuner(struct file *file, void *priv,
959 struct v4l2_tuner *t) 988 struct v4l2_tuner *t)
960{ 989{
961 struct cx8802_dev *dev = video_drvdata(file); 990 struct cx8802_dev *dev = video_drvdata(file);
962 struct cx88_core *core = dev->core; 991 struct cx88_core *core = dev->core;
963 u32 reg; 992 u32 reg;
964 993
965 if (unlikely(UNSET == core->board.tuner_type)) 994 if (unlikely(core->board.tuner_type == UNSET))
966 return -EINVAL; 995 return -EINVAL;
967 if (0 != t->index) 996 if (t->index != 0)
968 return -EINVAL; 997 return -EINVAL;
969 998
970 strcpy(t->name, "Television"); 999 strcpy(t->name, "Television");
@@ -972,21 +1001,21 @@ static int vidioc_g_tuner (struct file *file, void *priv,
972 t->rangehigh = 0xffffffffUL; 1001 t->rangehigh = 0xffffffffUL;
973 call_all(core, tuner, g_tuner, t); 1002 call_all(core, tuner, g_tuner, t);
974 1003
975 cx88_get_stereo(core ,t); 1004 cx88_get_stereo(core, t);
976 reg = cx_read(MO_DEVICE_STATUS); 1005 reg = cx_read(MO_DEVICE_STATUS);
977 t->signal = (reg & (1<<5)) ? 0xffff : 0x0000; 1006 t->signal = (reg & (1 << 5)) ? 0xffff : 0x0000;
978 return 0; 1007 return 0;
979} 1008}
980 1009
981static int vidioc_s_tuner (struct file *file, void *priv, 1010static int vidioc_s_tuner(struct file *file, void *priv,
982 const struct v4l2_tuner *t) 1011 const struct v4l2_tuner *t)
983{ 1012{
984 struct cx8802_dev *dev = video_drvdata(file); 1013 struct cx8802_dev *dev = video_drvdata(file);
985 struct cx88_core *core = dev->core; 1014 struct cx88_core *core = dev->core;
986 1015
987 if (UNSET == core->board.tuner_type) 1016 if (core->board.tuner_type == UNSET)
988 return -EINVAL; 1017 return -EINVAL;
989 if (0 != t->index) 1018 if (t->index != 0)
990 return -EINVAL; 1019 return -EINVAL;
991 1020
992 cx88_set_stereo(core, t->audmode, 1); 1021 cx88_set_stereo(core, t->audmode, 1);
@@ -1010,8 +1039,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id)
1010 return cx88_set_tvnorm(core, id); 1039 return cx88_set_tvnorm(core, id);
1011} 1040}
1012 1041
1013static const struct v4l2_file_operations mpeg_fops = 1042static const struct v4l2_file_operations mpeg_fops = {
1014{
1015 .owner = THIS_MODULE, 1043 .owner = THIS_MODULE,
1016 .open = v4l2_fh_open, 1044 .open = v4l2_fh_open,
1017 .release = vb2_fop_release, 1045 .release = vb2_fop_release,
@@ -1050,7 +1078,7 @@ static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {
1050static struct video_device cx8802_mpeg_template = { 1078static struct video_device cx8802_mpeg_template = {
1051 .name = "cx8802", 1079 .name = "cx8802",
1052 .fops = &mpeg_fops, 1080 .fops = &mpeg_fops,
1053 .ioctl_ops = &mpeg_ioctl_ops, 1081 .ioctl_ops = &mpeg_ioctl_ops,
1054 .tvnorms = CX88_NORMS, 1082 .tvnorms = CX88_NORMS,
1055}; 1083};
1056 1084
@@ -1064,7 +1092,9 @@ static int cx8802_blackbird_advise_acquire(struct cx8802_driver *drv)
1064 1092
1065 switch (core->boardnr) { 1093 switch (core->boardnr) {
1066 case CX88_BOARD_HAUPPAUGE_HVR1300: 1094 case CX88_BOARD_HAUPPAUGE_HVR1300:
1067 /* By default, core setup will leave the cx22702 out of reset, on the bus. 1095 /*
1096 * By default, core setup will leave the cx22702 out of reset,
1097 * on the bus.
1068 * We left the hardware on power up with the cx22702 active. 1098 * We left the hardware on power up with the cx22702 active.
1069 * We're being given access to re-arrange the GPIOs. 1099 * We're being given access to re-arrange the GPIOs.
1070 * Take the bus off the cx22702 and put the cx23416 on it. 1100 * Take the bus off the cx22702 and put the cx23416 on it.
@@ -1118,12 +1148,11 @@ static int blackbird_register_video(struct cx8802_dev *dev)
1118 dev->mpeg_dev.queue = &dev->vb2_mpegq; 1148 dev->mpeg_dev.queue = &dev->vb2_mpegq;
1119 err = video_register_device(&dev->mpeg_dev, VFL_TYPE_GRABBER, -1); 1149 err = video_register_device(&dev->mpeg_dev, VFL_TYPE_GRABBER, -1);
1120 if (err < 0) { 1150 if (err < 0) {
1121 printk(KERN_INFO "%s/2: can't register mpeg device\n", 1151 pr_info("can't register mpeg device\n");
1122 dev->core->name);
1123 return err; 1152 return err;
1124 } 1153 }
1125 printk(KERN_INFO "%s/2: registered device %s [mpeg]\n", 1154 pr_info("registered device %s [mpeg]\n",
1126 dev->core->name, video_device_node_name(&dev->mpeg_dev)); 1155 video_device_node_name(&dev->mpeg_dev));
1127 return 0; 1156 return 0;
1128} 1157}
1129 1158
@@ -1136,8 +1165,8 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv)
1136 struct vb2_queue *q; 1165 struct vb2_queue *q;
1137 int err; 1166 int err;
1138 1167
1139 dprintk( 1, "%s\n", __func__); 1168 dprintk(1, "%s\n", __func__);
1140 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", 1169 dprintk(1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
1141 core->boardnr, 1170 core->boardnr,
1142 core->name, 1171 core->name,
1143 core->pci_bus, 1172 core->pci_bus,
@@ -1158,16 +1187,15 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv)
1158 v4l2_ctrl_add_handler(&dev->cxhdl.hdl, &core->video_hdl, NULL); 1187 v4l2_ctrl_add_handler(&dev->cxhdl.hdl, &core->video_hdl, NULL);
1159 1188
1160 /* blackbird stuff */ 1189 /* blackbird stuff */
1161 printk("%s/2: cx23416 based mpeg encoder (blackbird reference design)\n", 1190 pr_info("cx23416 based mpeg encoder (blackbird reference design)\n");
1162 core->name);
1163 host_setup(dev->core); 1191 host_setup(dev->core);
1164 1192
1165 blackbird_initialize_codec(dev); 1193 blackbird_initialize_codec(dev);
1166 1194
1167 /* initial device configuration: needed ? */ 1195 /* initial device configuration: needed ? */
1168// init_controls(core); 1196// init_controls(core);
1169 cx88_set_tvnorm(core,core->tvnorm); 1197 cx88_set_tvnorm(core, core->tvnorm);
1170 cx88_video_mux(core,0); 1198 cx88_video_mux(core, 0);
1171 cx2341x_handler_set_50hz(&dev->cxhdl, core->height == 576); 1199 cx2341x_handler_set_50hz(&dev->cxhdl, core->height == 576);
1172 cx2341x_handler_setup(&dev->cxhdl); 1200 cx2341x_handler_setup(&dev->cxhdl);
1173 1201
@@ -1219,8 +1247,8 @@ static struct cx8802_driver cx8802_blackbird_driver = {
1219 1247
1220static int __init blackbird_init(void) 1248static int __init blackbird_init(void)
1221{ 1249{
1222 printk(KERN_INFO "cx2388x blackbird driver version %s loaded\n", 1250 pr_info("cx2388x blackbird driver version %s loaded\n",
1223 CX88_VERSION); 1251 CX88_VERSION);
1224 return cx8802_register_driver(&cx8802_blackbird_driver); 1252 return cx8802_register_driver(&cx8802_blackbird_driver);
1225} 1253}
1226 1254
diff --git a/drivers/media/pci/cx88/cx88-cards.c b/drivers/media/pci/cx88/cx88-cards.c
index 8f2556ec3971..cdfbde277b8b 100644
--- a/drivers/media/pci/cx88/cx88-cards.c
+++ b/drivers/media/pci/cx88/cx88-cards.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * device driver for Conexant 2388x based TV cards 2 * device driver for Conexant 2388x based TV cards
4 * card-specific stuff. 3 * card-specific stuff.
5 * 4 *
@@ -14,22 +13,18 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 15 * 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 */ 16 */
22 17
18#include "cx88.h"
19#include "tea5767.h"
20#include "xc4000.h"
21
23#include <linux/init.h> 22#include <linux/init.h>
24#include <linux/module.h> 23#include <linux/module.h>
25#include <linux/pci.h> 24#include <linux/pci.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/slab.h> 26#include <linux/slab.h>
28 27
29#include "cx88.h"
30#include "tea5767.h"
31#include "xc4000.h"
32
33static unsigned int tuner[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; 28static unsigned int tuner[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
34static unsigned int radio[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; 29static unsigned int radio[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
35static unsigned int card[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; 30static unsigned int card[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
@@ -38,32 +33,23 @@ module_param_array(tuner, int, NULL, 0444);
38module_param_array(radio, int, NULL, 0444); 33module_param_array(radio, int, NULL, 0444);
39module_param_array(card, int, NULL, 0444); 34module_param_array(card, int, NULL, 0444);
40 35
41MODULE_PARM_DESC(tuner,"tuner type"); 36MODULE_PARM_DESC(tuner, "tuner type");
42MODULE_PARM_DESC(radio,"radio tuner type"); 37MODULE_PARM_DESC(radio, "radio tuner type");
43MODULE_PARM_DESC(card,"card type"); 38MODULE_PARM_DESC(card, "card type");
44 39
45static unsigned int latency = UNSET; 40static unsigned int latency = UNSET;
46module_param(latency,int,0444); 41module_param(latency, int, 0444);
47MODULE_PARM_DESC(latency,"pci latency timer"); 42MODULE_PARM_DESC(latency, "pci latency timer");
48 43
49static int disable_ir; 44static int disable_ir;
50module_param(disable_ir, int, 0444); 45module_param(disable_ir, int, 0444);
51MODULE_PARM_DESC(disable_ir, "Disable IR support"); 46MODULE_PARM_DESC(disable_ir, "Disable IR support");
52 47
53#define info_printk(core, fmt, arg...) \ 48#define dprintk(level, fmt, arg...) do { \
54 printk(KERN_INFO "%s: " fmt, core->name , ## arg)
55
56#define warn_printk(core, fmt, arg...) \
57 printk(KERN_WARNING "%s: " fmt, core->name , ## arg)
58
59#define err_printk(core, fmt, arg...) \
60 printk(KERN_ERR "%s: " fmt, core->name , ## arg)
61
62#define dprintk(level,fmt, arg...) do { \
63 if (cx88_core_debug >= level) \ 49 if (cx88_core_debug >= level) \
64 printk(KERN_DEBUG "%s: " fmt, core->name , ## arg); \ 50 printk(KERN_DEBUG pr_fmt("%s: core:" fmt), \
65 } while(0) 51 __func__, ##arg); \
66 52} while (0)
67 53
68/* ------------------------------------------------------------------ */ 54/* ------------------------------------------------------------------ */
69/* board config info */ 55/* board config info */
@@ -291,7 +277,6 @@ static const struct cx88_board cx88_boards[] = {
291 .gpio2 = 0x0035e700, 277 .gpio2 = 0x0035e700,
292 .gpio3 = 0x02000000, 278 .gpio3 = 0x02000000,
293 }, { 279 }, {
294
295 .type = CX88_VMUX_COMPOSITE1, 280 .type = CX88_VMUX_COMPOSITE1,
296 .vmux = 1, 281 .vmux = 1,
297 .gpio0 = 0x0035c700, 282 .gpio0 = 0x0035c700,
@@ -505,22 +490,22 @@ static const struct cx88_board cx88_boards[] = {
505 .tuner_addr = ADDR_UNSET, 490 .tuner_addr = ADDR_UNSET,
506 .radio_addr = ADDR_UNSET, 491 .radio_addr = ADDR_UNSET,
507 /* 492 /*
508 GPIO[0] resets DT3302 DTV receiver 493 * GPIO[0] resets DT3302 DTV receiver
509 0 - reset asserted 494 * 0 - reset asserted
510 1 - normal operation 495 * 1 - normal operation
511 GPIO[1] mutes analog audio output connector 496 * GPIO[1] mutes analog audio output connector
512 0 - enable selected source 497 * 0 - enable selected source
513 1 - mute 498 * 1 - mute
514 GPIO[2] selects source for analog audio output connector 499 * GPIO[2] selects source for analog audio output connector
515 0 - analog audio input connector on tab 500 * 0 - analog audio input connector on tab
516 1 - analog DAC output from CX23881 chip 501 * 1 - analog DAC output from CX23881 chip
517 GPIO[3] selects RF input connector on tuner module 502 * GPIO[3] selects RF input connector on tuner module
518 0 - RF connector labeled CABLE 503 * 0 - RF connector labeled CABLE
519 1 - RF connector labeled ANT 504 * 1 - RF connector labeled ANT
520 GPIO[4] selects high RF for QAM256 mode 505 * GPIO[4] selects high RF for QAM256 mode
521 0 - normal RF 506 * 0 - normal RF
522 1 - high RF 507 * 1 - high RF
523 */ 508 */
524 .input = { { 509 .input = { {
525 .type = CX88_VMUX_TELEVISION, 510 .type = CX88_VMUX_TELEVISION,
526 .vmux = 0, 511 .vmux = 0,
@@ -743,7 +728,10 @@ static const struct cx88_board cx88_boards[] = {
743 .radio_type = UNSET, 728 .radio_type = UNSET,
744 .tuner_addr = ADDR_UNSET, 729 .tuner_addr = ADDR_UNSET,
745 .radio_addr = ADDR_UNSET, 730 .radio_addr = ADDR_UNSET,
746 /* Some variants use a tda9874 and so need the tvaudio module. */ 731 /*
732 * Some variants use a tda9874 and so need the
733 * tvaudio module.
734 */
747 .audio_chip = CX88_AUDIO_TVAUDIO, 735 .audio_chip = CX88_AUDIO_TVAUDIO,
748 .input = { { 736 .input = { {
749 .type = CX88_VMUX_TELEVISION, 737 .type = CX88_VMUX_TELEVISION,
@@ -1209,8 +1197,10 @@ static const struct cx88_board cx88_boards[] = {
1209 .mpeg = CX88_MPEG_DVB, 1197 .mpeg = CX88_MPEG_DVB,
1210 }, 1198 },
1211 [CX88_BOARD_KWORLD_MCE200_DELUXE] = { 1199 [CX88_BOARD_KWORLD_MCE200_DELUXE] = {
1212 /* FIXME: tested TV input only, disabled composite, 1200 /*
1213 svideo and radio until they can be tested also. */ 1201 * FIXME: tested TV input only, disabled composite,
1202 * svideo and radio until they can be tested also.
1203 */
1214 .name = "Kworld MCE 200 Deluxe", 1204 .name = "Kworld MCE 200 Deluxe",
1215 .tuner_type = TUNER_TENA_9533_DI, 1205 .tuner_type = TUNER_TENA_9533_DI,
1216 .radio_type = UNSET, 1206 .radio_type = UNSET,
@@ -1721,16 +1711,24 @@ static const struct cx88_board cx88_boards[] = {
1721 }, 1711 },
1722 }, 1712 },
1723 [CX88_BOARD_POWERCOLOR_REAL_ANGEL] = { 1713 [CX88_BOARD_POWERCOLOR_REAL_ANGEL] = {
1724 .name = "PowerColor RA330", /* Long names may confuse LIRC. */ 1714 /* Long names may confuse LIRC. */
1715 .name = "PowerColor RA330",
1725 .tuner_type = TUNER_XC2028, 1716 .tuner_type = TUNER_XC2028,
1726 .tuner_addr = 0x61, 1717 .tuner_addr = 0x61,
1727 .input = { { 1718 .input = { {
1719 /*
1720 * Due to the way the cx88 driver is written,
1721 * there is no way to deactivate audio pass-
1722 * through without this entry. Furthermore, if
1723 * the TV mux entry is first, you get audio
1724 * from the tuner on boot for a little while.
1725 */
1728 .type = CX88_VMUX_DEBUG, 1726 .type = CX88_VMUX_DEBUG,
1729 .vmux = 3, /* Due to the way the cx88 driver is written, */ 1727 .vmux = 3,
1730 .gpio0 = 0x00ff, /* there is no way to deactivate audio pass- */ 1728 .gpio0 = 0x00ff,
1731 .gpio1 = 0xf39d, /* through without this entry. Furthermore, if */ 1729 .gpio1 = 0xf39d,
1732 .gpio3 = 0x0000, /* the TV mux entry is first, you get audio */ 1730 .gpio3 = 0x0000,
1733 }, { /* from the tuner on boot for a little while. */ 1731 }, {
1734 .type = CX88_VMUX_TELEVISION, 1732 .type = CX88_VMUX_TELEVISION,
1735 .vmux = 0, 1733 .vmux = 0,
1736 .gpio0 = 0x00ff, 1734 .gpio0 = 0x00ff,
@@ -1883,11 +1881,12 @@ static const struct cx88_board cx88_boards[] = {
1883 .gpio2 = 0x0cf7, 1881 .gpio2 = 0x0cf7,
1884 }, 1882 },
1885 }, 1883 },
1886 /* Both radio, analog and ATSC work with this board. 1884 /*
1887 However, for analog to work, s5h1409 gate should be open, 1885 * Both radio, analog and ATSC work with this board.
1888 otherwise, tuner-xc3028 won't be detected. 1886 * However, for analog to work, s5h1409 gate should be open,
1889 A proper fix require using the newer i2c methods to add 1887 * otherwise, tuner-xc3028 won't be detected.
1890 tuner-xc3028 without doing an i2c probe. 1888 * A proper fix require using the newer i2c methods to add
1889 * tuner-xc3028 without doing an i2c probe.
1891 */ 1890 */
1892 [CX88_BOARD_KWORLD_ATSC_120] = { 1891 [CX88_BOARD_KWORLD_ATSC_120] = {
1893 .name = "Kworld PlusTV HD PCI 120 (ATSC 120)", 1892 .name = "Kworld PlusTV HD PCI 120 (ATSC 120)",
@@ -2821,15 +2820,15 @@ static const struct cx88_subid cx88_subids[] = {
2821 }, 2820 },
2822}; 2821};
2823 2822
2824/* ----------------------------------------------------------------------- */ 2823/*
2825/* some leadtek specific stuff */ 2824 * some leadtek specific stuff
2826 2825 */
2827static void leadtek_eeprom(struct cx88_core *core, u8 *eeprom_data) 2826static void leadtek_eeprom(struct cx88_core *core, u8 *eeprom_data)
2828{ 2827{
2829 if (eeprom_data[4] != 0x7d || 2828 if (eeprom_data[4] != 0x7d ||
2830 eeprom_data[5] != 0x10 || 2829 eeprom_data[5] != 0x10 ||
2831 eeprom_data[7] != 0x66) { 2830 eeprom_data[7] != 0x66) {
2832 warn_printk(core, "Leadtek eeprom invalid.\n"); 2831 pr_warn("Leadtek eeprom invalid.\n");
2833 return; 2832 return;
2834 } 2833 }
2835 2834
@@ -2847,9 +2846,8 @@ static void leadtek_eeprom(struct cx88_core *core, u8 *eeprom_data)
2847 break; 2846 break;
2848 } 2847 }
2849 2848
2850 info_printk(core, "Leadtek Winfast 2000XP Expert config: " 2849 pr_info("Leadtek Winfast 2000XP Expert config: tuner=%d, eeprom[0]=0x%02x\n",
2851 "tuner=%d, eeprom[0]=0x%02x\n", 2850 core->board.tuner_type, eeprom_data[0]);
2852 core->board.tuner_type, eeprom_data[0]);
2853} 2851}
2854 2852
2855static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data) 2853static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
@@ -2863,8 +2861,7 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
2863 core->model = tv.model; 2861 core->model = tv.model;
2864 2862
2865 /* Make sure we support the board model */ 2863 /* Make sure we support the board model */
2866 switch (tv.model) 2864 switch (tv.model) {
2867 {
2868 case 14009: /* WinTV-HVR3000 (Retail, IR, b/panel video, 3.5mm audio in) */ 2865 case 14009: /* WinTV-HVR3000 (Retail, IR, b/panel video, 3.5mm audio in) */
2869 case 14019: /* WinTV-HVR3000 (Retail, IR Blaster, b/panel video, 3.5mm audio in) */ 2866 case 14019: /* WinTV-HVR3000 (Retail, IR Blaster, b/panel video, 3.5mm audio in) */
2870 case 14029: /* WinTV-HVR3000 (Retail, IR, b/panel video, 3.5mm audio in - 880 bridge) */ 2867 case 14029: /* WinTV-HVR3000 (Retail, IR, b/panel video, 3.5mm audio in - 880 bridge) */
@@ -2905,50 +2902,50 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
2905 cx_set(MO_GP0_IO, 0x008989FF); 2902 cx_set(MO_GP0_IO, 0x008989FF);
2906 break; 2903 break;
2907 default: 2904 default:
2908 warn_printk(core, "warning: unknown hauppauge model #%d\n", 2905 pr_warn("warning: unknown hauppauge model #%d\n", tv.model);
2909 tv.model);
2910 break; 2906 break;
2911 } 2907 }
2912 2908
2913 info_printk(core, "hauppauge eeprom: model=%d\n", tv.model); 2909 pr_info("hauppauge eeprom: model=%d\n", tv.model);
2914} 2910}
2915 2911
2916/* ----------------------------------------------------------------------- */ 2912/*
2917/* some GDI (was: Modular Technology) specific stuff */ 2913 * some GDI (was: Modular Technology) specific stuff
2914 */
2918 2915
2919static const struct { 2916static const struct {
2920 int id; 2917 int id;
2921 int fm; 2918 int fm;
2922 const char *name; 2919 const char *name;
2923} gdi_tuner[] = { 2920} gdi_tuner[] = {
2924 [ 0x01 ] = { .id = UNSET, 2921 [0x01] = { .id = UNSET,
2925 .name = "NTSC_M" }, 2922 .name = "NTSC_M" },
2926 [ 0x02 ] = { .id = UNSET, 2923 [0x02] = { .id = UNSET,
2927 .name = "PAL_B" }, 2924 .name = "PAL_B" },
2928 [ 0x03 ] = { .id = UNSET, 2925 [0x03] = { .id = UNSET,
2929 .name = "PAL_I" }, 2926 .name = "PAL_I" },
2930 [ 0x04 ] = { .id = UNSET, 2927 [0x04] = { .id = UNSET,
2931 .name = "PAL_D" }, 2928 .name = "PAL_D" },
2932 [ 0x05 ] = { .id = UNSET, 2929 [0x05] = { .id = UNSET,
2933 .name = "SECAM" }, 2930 .name = "SECAM" },
2934 2931
2935 [ 0x10 ] = { .id = UNSET, 2932 [0x10] = { .id = UNSET,
2936 .fm = 1, 2933 .fm = 1,
2937 .name = "TEMIC_4049" }, 2934 .name = "TEMIC_4049" },
2938 [ 0x11 ] = { .id = TUNER_TEMIC_4136FY5, 2935 [0x11] = { .id = TUNER_TEMIC_4136FY5,
2939 .name = "TEMIC_4136" }, 2936 .name = "TEMIC_4136" },
2940 [ 0x12 ] = { .id = UNSET, 2937 [0x12] = { .id = UNSET,
2941 .name = "TEMIC_4146" }, 2938 .name = "TEMIC_4146" },
2942 2939
2943 [ 0x20 ] = { .id = TUNER_PHILIPS_FQ1216ME, 2940 [0x20] = { .id = TUNER_PHILIPS_FQ1216ME,
2944 .fm = 1, 2941 .fm = 1,
2945 .name = "PHILIPS_FQ1216_MK3" }, 2942 .name = "PHILIPS_FQ1216_MK3" },
2946 [ 0x21 ] = { .id = UNSET, .fm = 1, 2943 [0x21] = { .id = UNSET, .fm = 1,
2947 .name = "PHILIPS_FQ1236_MK3" }, 2944 .name = "PHILIPS_FQ1236_MK3" },
2948 [ 0x22 ] = { .id = UNSET, 2945 [0x22] = { .id = UNSET,
2949 .name = "PHILIPS_FI1236_MK3" }, 2946 .name = "PHILIPS_FI1236_MK3" },
2950 [ 0x23 ] = { .id = UNSET, 2947 [0x23] = { .id = UNSET,
2951 .name = "PHILIPS_FI1216_MK3" }, 2948 .name = "PHILIPS_FI1216_MK3" },
2952}; 2949};
2953 2950
2954static void gdi_eeprom(struct cx88_core *core, u8 *eeprom_data) 2951static void gdi_eeprom(struct cx88_core *core, u8 *eeprom_data)
@@ -2956,16 +2953,17 @@ static void gdi_eeprom(struct cx88_core *core, u8 *eeprom_data)
2956 const char *name = (eeprom_data[0x0d] < ARRAY_SIZE(gdi_tuner)) 2953 const char *name = (eeprom_data[0x0d] < ARRAY_SIZE(gdi_tuner))
2957 ? gdi_tuner[eeprom_data[0x0d]].name : NULL; 2954 ? gdi_tuner[eeprom_data[0x0d]].name : NULL;
2958 2955
2959 info_printk(core, "GDI: tuner=%s\n", name ? name : "unknown"); 2956 pr_info("GDI: tuner=%s\n", name ? name : "unknown");
2960 if (NULL == name) 2957 if (!name)
2961 return; 2958 return;
2962 core->board.tuner_type = gdi_tuner[eeprom_data[0x0d]].id; 2959 core->board.tuner_type = gdi_tuner[eeprom_data[0x0d]].id;
2963 core->board.radio.type = gdi_tuner[eeprom_data[0x0d]].fm ? 2960 core->board.radio.type = gdi_tuner[eeprom_data[0x0d]].fm ?
2964 CX88_RADIO : 0; 2961 CX88_RADIO : 0;
2965} 2962}
2966 2963
2967/* ------------------------------------------------------------------- */ 2964/*
2968/* some Divco specific stuff */ 2965 * some Divco specific stuff
2966 */
2969static int cx88_dvico_xc2028_callback(struct cx88_core *core, 2967static int cx88_dvico_xc2028_callback(struct cx88_core *core,
2970 int command, int arg) 2968 int command, int arg)
2971{ 2969{
@@ -2994,9 +2992,9 @@ static int cx88_dvico_xc2028_callback(struct cx88_core *core,
2994 return 0; 2992 return 0;
2995} 2993}
2996 2994
2997 2995/*
2998/* ----------------------------------------------------------------------- */ 2996 * some Geniatech specific stuff
2999/* some Geniatech specific stuff */ 2997 */
3000 2998
3001static int cx88_xc3028_geniatech_tuner_callback(struct cx88_core *core, 2999static int cx88_xc3028_geniatech_tuner_callback(struct cx88_core *core,
3002 int command, int mode) 3000 int command, int mode)
@@ -3059,8 +3057,9 @@ static int cx88_xc4000_winfast2000h_plus_callback(struct cx88_core *core,
3059 return -EINVAL; 3057 return -EINVAL;
3060} 3058}
3061 3059
3062/* ------------------------------------------------------------------- */ 3060/*
3063/* some Divco specific stuff */ 3061 * some Divco specific stuff
3062 */
3064static int cx88_pv_8000gt_callback(struct cx88_core *core, 3063static int cx88_pv_8000gt_callback(struct cx88_core *core,
3065 int command, int arg) 3064 int command, int arg)
3066{ 3065{
@@ -3079,8 +3078,9 @@ static int cx88_pv_8000gt_callback(struct cx88_core *core,
3079 return 0; 3078 return 0;
3080} 3079}
3081 3080
3082/* ----------------------------------------------------------------------- */ 3081/*
3083/* some DViCO specific stuff */ 3082 * some DViCO specific stuff
3083 */
3084 3084
3085static void dvico_fusionhdtv_hybrid_init(struct cx88_core *core) 3085static void dvico_fusionhdtv_hybrid_init(struct cx88_core *core)
3086{ 3086{
@@ -3107,8 +3107,8 @@ static void dvico_fusionhdtv_hybrid_init(struct cx88_core *core)
3107 msg.len = (i != 12 ? 5 : 2); 3107 msg.len = (i != 12 ? 5 : 2);
3108 err = i2c_transfer(&core->i2c_adap, &msg, 1); 3108 err = i2c_transfer(&core->i2c_adap, &msg, 1);
3109 if (err != 1) { 3109 if (err != 1) {
3110 warn_printk(core, "dvico_fusionhdtv_hybrid_init buf %d " 3110 pr_warn("dvico_fusionhdtv_hybrid_init buf %d failed (err = %d)!\n",
3111 "failed (err = %d)!\n", i, err); 3111 i, err);
3112 return; 3112 return;
3113 } 3113 }
3114 } 3114 }
@@ -3176,11 +3176,11 @@ static int cx88_xc4000_tuner_callback(struct cx88_core *core,
3176 return -EINVAL; 3176 return -EINVAL;
3177} 3177}
3178 3178
3179/* ----------------------------------------------------------------------- */ 3179/*
3180/* Tuner callback function. Currently only needed for the Pinnacle * 3180 * Tuner callback function. Currently only needed for the Pinnacle
3181 * PCTV HD 800i with an xc5000 sillicon tuner. This is used for both * 3181 * PCTV HD 800i with an xc5000 sillicon tuner. This is used for both
3182 * analog tuner attach (tuner-core.c) and dvb tuner attach (cx88-dvb.c) */ 3182 * analog tuner attach (tuner-core.c) and dvb tuner attach (cx88-dvb.c)
3183 3183 */
3184static int cx88_xc5000_tuner_callback(struct cx88_core *core, 3184static int cx88_xc5000_tuner_callback(struct cx88_core *core,
3185 int command, int arg) 3185 int command, int arg)
3186{ 3186{
@@ -3188,38 +3188,38 @@ static int cx88_xc5000_tuner_callback(struct cx88_core *core,
3188 case CX88_BOARD_PINNACLE_PCTV_HD_800i: 3188 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
3189 if (command == 0) { /* This is the reset command from xc5000 */ 3189 if (command == 0) { /* This is the reset command from xc5000 */
3190 3190
3191 /* djh - According to the engineer at PCTV Systems, 3191 /*
3192 the xc5000 reset pin is supposed to be on GPIO12. 3192 * djh - According to the engineer at PCTV Systems,
3193 However, despite three nights of effort, pulling 3193 * the xc5000 reset pin is supposed to be on GPIO12.
3194 that GPIO low didn't reset the xc5000. While 3194 * However, despite three nights of effort, pulling
3195 pulling MO_SRST_IO low does reset the xc5000, this 3195 * that GPIO low didn't reset the xc5000. While
3196 also resets in the s5h1409 being reset as well. 3196 * pulling MO_SRST_IO low does reset the xc5000, this
3197 This causes tuning to always fail since the internal 3197 * also resets in the s5h1409 being reset as well.
3198 state of the s5h1409 does not match the driver's 3198 * This causes tuning to always fail since the internal
3199 state. Given that the only two conditions in which 3199 * state of the s5h1409 does not match the driver's
3200 the driver performs a reset is during firmware load 3200 * state. Given that the only two conditions in which
3201 and powering down the chip, I am taking out the 3201 * the driver performs a reset is during firmware load
3202 reset. We know that the chip is being reset 3202 * and powering down the chip, I am taking out the
3203 when the cx88 comes online, and not being able to 3203 * reset. We know that the chip is being reset
3204 do power management for this board is worse than 3204 * when the cx88 comes online, and not being able to
3205 not having any tuning at all. */ 3205 * do power management for this board is worse than
3206 * not having any tuning at all.
3207 */
3206 return 0; 3208 return 0;
3207 } else {
3208 dprintk(1, "xc5000: unknown tuner callback command.\n");
3209 return -EINVAL;
3210 } 3209 }
3211 break; 3210
3211 dprintk(1, "xc5000: unknown tuner callback command.\n");
3212 return -EINVAL;
3212 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD: 3213 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
3213 if (command == 0) { /* This is the reset command from xc5000 */ 3214 if (command == 0) { /* This is the reset command from xc5000 */
3214 cx_clear(MO_GP0_IO, 0x00000010); 3215 cx_clear(MO_GP0_IO, 0x00000010);
3215 msleep(10); 3216 usleep_range(10000, 20000);
3216 cx_set(MO_GP0_IO, 0x00000010); 3217 cx_set(MO_GP0_IO, 0x00000010);
3217 return 0; 3218 return 0;
3218 } else {
3219 dprintk(1, "xc5000: unknown tuner callback command.\n");
3220 return -EINVAL;
3221 } 3219 }
3222 break; 3220
3221 dprintk(1, "xc5000: unknown tuner callback command.\n");
3222 return -EINVAL;
3223 } 3223 }
3224 return 0; /* Should never be here */ 3224 return 0; /* Should never be here */
3225} 3225}
@@ -3230,14 +3230,14 @@ int cx88_tuner_callback(void *priv, int component, int command, int arg)
3230 struct cx88_core *core; 3230 struct cx88_core *core;
3231 3231
3232 if (!i2c_algo) { 3232 if (!i2c_algo) {
3233 printk(KERN_ERR "cx88: Error - i2c private data undefined.\n"); 3233 pr_err("Error - i2c private data undefined.\n");
3234 return -EINVAL; 3234 return -EINVAL;
3235 } 3235 }
3236 3236
3237 core = i2c_algo->data; 3237 core = i2c_algo->data;
3238 3238
3239 if (!core) { 3239 if (!core) {
3240 printk(KERN_ERR "cx88: Error - device struct undefined.\n"); 3240 pr_err("Error - device struct undefined.\n");
3241 return -EINVAL; 3241 return -EINVAL;
3242 } 3242 }
3243 3243
@@ -3245,18 +3245,18 @@ int cx88_tuner_callback(void *priv, int component, int command, int arg)
3245 return -EINVAL; 3245 return -EINVAL;
3246 3246
3247 switch (core->board.tuner_type) { 3247 switch (core->board.tuner_type) {
3248 case TUNER_XC2028: 3248 case TUNER_XC2028:
3249 dprintk(1, "Calling XC2028/3028 callback\n"); 3249 dprintk(1, "Calling XC2028/3028 callback\n");
3250 return cx88_xc2028_tuner_callback(core, command, arg); 3250 return cx88_xc2028_tuner_callback(core, command, arg);
3251 case TUNER_XC4000: 3251 case TUNER_XC4000:
3252 dprintk(1, "Calling XC4000 callback\n"); 3252 dprintk(1, "Calling XC4000 callback\n");
3253 return cx88_xc4000_tuner_callback(core, command, arg); 3253 return cx88_xc4000_tuner_callback(core, command, arg);
3254 case TUNER_XC5000: 3254 case TUNER_XC5000:
3255 dprintk(1, "Calling XC5000 callback\n"); 3255 dprintk(1, "Calling XC5000 callback\n");
3256 return cx88_xc5000_tuner_callback(core, command, arg); 3256 return cx88_xc5000_tuner_callback(core, command, arg);
3257 } 3257 }
3258 err_printk(core, "Error: Calling callback for tuner %d\n", 3258 pr_err("Error: Calling callback for tuner %d\n",
3259 core->board.tuner_type); 3259 core->board.tuner_type);
3260 return -EINVAL; 3260 return -EINVAL;
3261} 3261}
3262EXPORT_SYMBOL(cx88_tuner_callback); 3262EXPORT_SYMBOL(cx88_tuner_callback);
@@ -3267,28 +3267,20 @@ static void cx88_card_list(struct cx88_core *core, struct pci_dev *pci)
3267{ 3267{
3268 int i; 3268 int i;
3269 3269
3270 if (0 == pci->subsystem_vendor && 3270 if (!pci->subsystem_vendor && !pci->subsystem_device) {
3271 0 == pci->subsystem_device) { 3271 pr_err("Your board has no valid PCI Subsystem ID and thus can't\n");
3272 printk(KERN_ERR 3272 pr_err("be autodetected. Please pass card=<n> insmod option to\n");
3273 "%s: Your board has no valid PCI Subsystem ID and thus can't\n" 3273 pr_err("workaround that. Redirect complaints to the vendor of\n");
3274 "%s: be autodetected. Please pass card=<n> insmod option to\n" 3274 pr_err("the TV card\n");
3275 "%s: workaround that. Redirect complaints to the vendor of\n"
3276 "%s: the TV card. Best regards,\n"
3277 "%s: -- tux\n",
3278 core->name,core->name,core->name,core->name,core->name);
3279 } else { 3275 } else {
3280 printk(KERN_ERR 3276 pr_err("Your board isn't known (yet) to the driver. You can\n");
3281 "%s: Your board isn't known (yet) to the driver. You can\n" 3277 pr_err("try to pick one of the existing card configs via\n");
3282 "%s: try to pick one of the existing card configs via\n" 3278 pr_err("card=<n> insmod option. Updating to the latest\n");
3283 "%s: card=<n> insmod option. Updating to the latest\n" 3279 pr_err("version might help as well.\n");
3284 "%s: version might help as well.\n",
3285 core->name,core->name,core->name,core->name);
3286 } 3280 }
3287 err_printk(core, "Here is a list of valid choices for the card=<n> " 3281 pr_err("Here is a list of valid choices for the card=<n> insmod option:\n");
3288 "insmod option:\n");
3289 for (i = 0; i < ARRAY_SIZE(cx88_boards); i++) 3282 for (i = 0; i < ARRAY_SIZE(cx88_boards); i++)
3290 printk(KERN_ERR "%s: card=%d -> %s\n", 3283 pr_err(" card=%d -> %s\n", i, cx88_boards[i].name);
3291 core->name, i, cx88_boards[i].name);
3292} 3284}
3293 3285
3294static void cx88_card_setup_pre_i2c(struct cx88_core *core) 3286static void cx88_card_setup_pre_i2c(struct cx88_core *core)
@@ -3296,7 +3288,9 @@ static void cx88_card_setup_pre_i2c(struct cx88_core *core)
3296 switch (core->boardnr) { 3288 switch (core->boardnr) {
3297 case CX88_BOARD_HAUPPAUGE_HVR1300: 3289 case CX88_BOARD_HAUPPAUGE_HVR1300:
3298 /* 3290 /*
3299 * Bring the 702 demod up before i2c scanning/attach or devices are hidden 3291 * Bring the 702 demod up before i2c scanning/attach or
3292 * devices are hidden.
3293 *
3300 * We leave here with the 702 on the bus 3294 * We leave here with the 702 on the bus
3301 * 3295 *
3302 * "reset the IR receiver on GPIO[3]" 3296 * "reset the IR receiver on GPIO[3]"
@@ -3317,7 +3311,7 @@ static void cx88_card_setup_pre_i2c(struct cx88_core *core)
3317 cx_write(MO_GP2_IO, 0xef5); 3311 cx_write(MO_GP2_IO, 0xef5);
3318 mdelay(50); 3312 mdelay(50);
3319 cx_write(MO_GP2_IO, 0xcf7); 3313 cx_write(MO_GP2_IO, 0xcf7);
3320 msleep(10); 3314 usleep_range(10000, 20000);
3321 break; 3315 break;
3322 3316
3323 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD: 3317 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
@@ -3353,7 +3347,7 @@ static void cx88_card_setup_pre_i2c(struct cx88_core *core)
3353 case CX88_BOARD_TWINHAN_VP1027_DVBS: 3347 case CX88_BOARD_TWINHAN_VP1027_DVBS:
3354 cx_write(MO_GP0_IO, 0x00003230); 3348 cx_write(MO_GP0_IO, 0x00003230);
3355 cx_write(MO_GP0_IO, 0x00003210); 3349 cx_write(MO_GP0_IO, 0x00003210);
3356 msleep(1); 3350 usleep_range(10000, 20000);
3357 cx_write(MO_GP0_IO, 0x00001230); 3351 cx_write(MO_GP0_IO, 0x00001230);
3358 break; 3352 break;
3359 } 3353 }
@@ -3384,11 +3378,13 @@ void cx88_setup_xc3028(struct cx88_core *core, struct xc2028_ctrl *ctl)
3384 ctl->demod = XC3028_FE_OREN538; 3378 ctl->demod = XC3028_FE_OREN538;
3385 break; 3379 break;
3386 case CX88_BOARD_GENIATECH_X8000_MT: 3380 case CX88_BOARD_GENIATECH_X8000_MT:
3387 /* FIXME: For this board, the xc3028 never recovers after being 3381 /*
3388 powered down (the reset GPIO probably is not set properly). 3382 * FIXME: For this board, the xc3028 never recovers after being
3389 We don't have access to the hardware so we cannot determine 3383 * powered down (the reset GPIO probably is not set properly).
3390 which GPIO is used for xc3028, so just disable power xc3028 3384 * We don't have access to the hardware so we cannot determine
3391 power management for now */ 3385 * which GPIO is used for xc3028, so just disable power xc3028
3386 * power management for now
3387 */
3392 ctl->disable_power_mgmt = 1; 3388 ctl->disable_power_mgmt = 1;
3393 break; 3389 break;
3394 case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL: 3390 case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL:
@@ -3418,7 +3414,7 @@ static void cx88_card_setup(struct cx88_core *core)
3418 3414
3419 memset(&tun_setup, 0, sizeof(tun_setup)); 3415 memset(&tun_setup, 0, sizeof(tun_setup));
3420 3416
3421 if (0 == core->i2c_rc) { 3417 if (!core->i2c_rc) {
3422 core->i2c_client.addr = 0xa0 >> 1; 3418 core->i2c_client.addr = 0xa0 >> 1;
3423 tveeprom_read(&core->i2c_client, eeprom, sizeof(eeprom)); 3419 tveeprom_read(&core->i2c_client, eeprom, sizeof(eeprom));
3424 } 3420 }
@@ -3426,17 +3422,17 @@ static void cx88_card_setup(struct cx88_core *core)
3426 switch (core->boardnr) { 3422 switch (core->boardnr) {
3427 case CX88_BOARD_HAUPPAUGE: 3423 case CX88_BOARD_HAUPPAUGE:
3428 case CX88_BOARD_HAUPPAUGE_ROSLYN: 3424 case CX88_BOARD_HAUPPAUGE_ROSLYN:
3429 if (0 == core->i2c_rc) 3425 if (!core->i2c_rc)
3430 hauppauge_eeprom(core, eeprom+8); 3426 hauppauge_eeprom(core, eeprom + 8);
3431 break; 3427 break;
3432 case CX88_BOARD_GDI: 3428 case CX88_BOARD_GDI:
3433 if (0 == core->i2c_rc) 3429 if (!core->i2c_rc)
3434 gdi_eeprom(core, eeprom); 3430 gdi_eeprom(core, eeprom);
3435 break; 3431 break;
3436 case CX88_BOARD_LEADTEK_PVR2000: 3432 case CX88_BOARD_LEADTEK_PVR2000:
3437 case CX88_BOARD_WINFAST_DV2000: 3433 case CX88_BOARD_WINFAST_DV2000:
3438 case CX88_BOARD_WINFAST2000XP_EXPERT: 3434 case CX88_BOARD_WINFAST2000XP_EXPERT:
3439 if (0 == core->i2c_rc) 3435 if (!core->i2c_rc)
3440 leadtek_eeprom(core, eeprom); 3436 leadtek_eeprom(core, eeprom);
3441 break; 3437 break;
3442 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 3438 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
@@ -3449,7 +3445,7 @@ static void cx88_card_setup(struct cx88_core *core)
3449 case CX88_BOARD_HAUPPAUGE_HVR4000: 3445 case CX88_BOARD_HAUPPAUGE_HVR4000:
3450 case CX88_BOARD_HAUPPAUGE_HVR4000LITE: 3446 case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
3451 case CX88_BOARD_HAUPPAUGE_IRONLY: 3447 case CX88_BOARD_HAUPPAUGE_IRONLY:
3452 if (0 == core->i2c_rc) 3448 if (!core->i2c_rc)
3453 hauppauge_eeprom(core, eeprom); 3449 hauppauge_eeprom(core, eeprom);
3454 break; 3450 break;
3455 case CX88_BOARD_KWORLD_DVBS_100: 3451 case CX88_BOARD_KWORLD_DVBS_100:
@@ -3460,7 +3456,7 @@ static void cx88_card_setup(struct cx88_core *core)
3460 /* GPIO0:0 is hooked to demod reset */ 3456 /* GPIO0:0 is hooked to demod reset */
3461 /* GPIO0:4 is hooked to xc3028 reset */ 3457 /* GPIO0:4 is hooked to xc3028 reset */
3462 cx_write(MO_GP0_IO, 0x00111100); 3458 cx_write(MO_GP0_IO, 0x00111100);
3463 msleep(1); 3459 usleep_range(10000, 20000);
3464 cx_write(MO_GP0_IO, 0x00111111); 3460 cx_write(MO_GP0_IO, 0x00111111);
3465 break; 3461 break;
3466 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: 3462 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
@@ -3476,9 +3472,9 @@ static void cx88_card_setup(struct cx88_core *core)
3476 /* GPIO0:0 is hooked to mt352 reset pin */ 3472 /* GPIO0:0 is hooked to mt352 reset pin */
3477 cx_set(MO_GP0_IO, 0x00000101); 3473 cx_set(MO_GP0_IO, 0x00000101);
3478 cx_clear(MO_GP0_IO, 0x00000001); 3474 cx_clear(MO_GP0_IO, 0x00000001);
3479 msleep(1); 3475 usleep_range(10000, 20000);
3480 cx_set(MO_GP0_IO, 0x00000101); 3476 cx_set(MO_GP0_IO, 0x00000101);
3481 if (0 == core->i2c_rc && 3477 if (!core->i2c_rc &&
3482 core->boardnr == CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID) 3478 core->boardnr == CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID)
3483 dvico_fusionhdtv_hybrid_init(core); 3479 dvico_fusionhdtv_hybrid_init(core);
3484 break; 3480 break;
@@ -3487,7 +3483,7 @@ static void cx88_card_setup(struct cx88_core *core)
3487 cx_set(MO_GP0_IO, 0x00000707); 3483 cx_set(MO_GP0_IO, 0x00000707);
3488 cx_set(MO_GP2_IO, 0x00000101); 3484 cx_set(MO_GP2_IO, 0x00000101);
3489 cx_clear(MO_GP2_IO, 0x00000001); 3485 cx_clear(MO_GP2_IO, 0x00000001);
3490 msleep(1); 3486 usleep_range(10000, 20000);
3491 cx_clear(MO_GP0_IO, 0x00000007); 3487 cx_clear(MO_GP0_IO, 0x00000007);
3492 cx_set(MO_GP2_IO, 0x00000101); 3488 cx_set(MO_GP2_IO, 0x00000101);
3493 break; 3489 break;
@@ -3495,23 +3491,23 @@ static void cx88_card_setup(struct cx88_core *core)
3495 cx_write(MO_GP0_IO, 0x00080808); 3491 cx_write(MO_GP0_IO, 0x00080808);
3496 break; 3492 break;
3497 case CX88_BOARD_ATI_HDTVWONDER: 3493 case CX88_BOARD_ATI_HDTVWONDER:
3498 if (0 == core->i2c_rc) { 3494 if (!core->i2c_rc) {
3499 /* enable tuner */ 3495 /* enable tuner */
3500 int i; 3496 int i;
3501 static const u8 buffer [][2] = { 3497 static const u8 buffer[][2] = {
3502 {0x10,0x12}, 3498 {0x10, 0x12},
3503 {0x13,0x04}, 3499 {0x13, 0x04},
3504 {0x16,0x00}, 3500 {0x16, 0x00},
3505 {0x14,0x04}, 3501 {0x14, 0x04},
3506 {0x17,0x00} 3502 {0x17, 0x00}
3507 }; 3503 };
3508 core->i2c_client.addr = 0x0a; 3504 core->i2c_client.addr = 0x0a;
3509 3505
3510 for (i = 0; i < ARRAY_SIZE(buffer); i++) 3506 for (i = 0; i < ARRAY_SIZE(buffer); i++)
3511 if (2 != i2c_master_send(&core->i2c_client, 3507 if (i2c_master_send(&core->i2c_client,
3512 buffer[i],2)) 3508 buffer[i], 2) != 2)
3513 warn_printk(core, "Unable to enable " 3509 pr_warn("Unable to enable tuner(%i).\n",
3514 "tuner(%i).\n", i); 3510 i);
3515 } 3511 }
3516 break; 3512 break;
3517 case CX88_BOARD_MSI_TVANYWHERE_MASTER: 3513 case CX88_BOARD_MSI_TVANYWHERE_MASTER:
@@ -3545,7 +3541,7 @@ static void cx88_card_setup(struct cx88_core *core)
3545 cx_write(MO_GP0_IO, 0x8000); 3541 cx_write(MO_GP0_IO, 0x8000);
3546 msleep(100); 3542 msleep(100);
3547 cx_write(MO_SRST_IO, 0); 3543 cx_write(MO_SRST_IO, 0);
3548 msleep(10); 3544 usleep_range(10000, 20000);
3549 cx_write(MO_GP0_IO, 0x8080); 3545 cx_write(MO_GP0_IO, 0x8080);
3550 msleep(100); 3546 msleep(100);
3551 cx_write(MO_SRST_IO, 1); 3547 cx_write(MO_SRST_IO, 1);
@@ -3553,9 +3549,8 @@ static void cx88_card_setup(struct cx88_core *core)
3553 break; 3549 break;
3554 } /*end switch() */ 3550 } /*end switch() */
3555 3551
3556
3557 /* Setup tuners */ 3552 /* Setup tuners */
3558 if ((core->board.radio_type != UNSET)) { 3553 if (core->board.radio_type != UNSET) {
3559 tun_setup.mode_mask = T_RADIO; 3554 tun_setup.mode_mask = T_RADIO;
3560 tun_setup.type = core->board.radio_type; 3555 tun_setup.type = core->board.radio_type;
3561 tun_setup.addr = core->board.radio_addr; 3556 tun_setup.addr = core->board.radio_addr;
@@ -3610,35 +3605,30 @@ static int cx88_pci_quirks(const char *name, struct pci_dev *pci)
3610 3605
3611 /* check pci quirks */ 3606 /* check pci quirks */
3612 if (pci_pci_problems & PCIPCI_TRITON) { 3607 if (pci_pci_problems & PCIPCI_TRITON) {
3613 printk(KERN_INFO "%s: quirk: PCIPCI_TRITON -- set TBFX\n", 3608 pr_info("quirk: PCIPCI_TRITON -- set TBFX\n");
3614 name);
3615 ctrl |= CX88X_EN_TBFX; 3609 ctrl |= CX88X_EN_TBFX;
3616 } 3610 }
3617 if (pci_pci_problems & PCIPCI_NATOMA) { 3611 if (pci_pci_problems & PCIPCI_NATOMA) {
3618 printk(KERN_INFO "%s: quirk: PCIPCI_NATOMA -- set TBFX\n", 3612 pr_info("quirk: PCIPCI_NATOMA -- set TBFX\n");
3619 name);
3620 ctrl |= CX88X_EN_TBFX; 3613 ctrl |= CX88X_EN_TBFX;
3621 } 3614 }
3622 if (pci_pci_problems & PCIPCI_VIAETBF) { 3615 if (pci_pci_problems & PCIPCI_VIAETBF) {
3623 printk(KERN_INFO "%s: quirk: PCIPCI_VIAETBF -- set TBFX\n", 3616 pr_info("quirk: PCIPCI_VIAETBF -- set TBFX\n");
3624 name);
3625 ctrl |= CX88X_EN_TBFX; 3617 ctrl |= CX88X_EN_TBFX;
3626 } 3618 }
3627 if (pci_pci_problems & PCIPCI_VSFX) { 3619 if (pci_pci_problems & PCIPCI_VSFX) {
3628 printk(KERN_INFO "%s: quirk: PCIPCI_VSFX -- set VSFX\n", 3620 pr_info("quirk: PCIPCI_VSFX -- set VSFX\n");
3629 name);
3630 ctrl |= CX88X_EN_VSFX; 3621 ctrl |= CX88X_EN_VSFX;
3631 } 3622 }
3632#ifdef PCIPCI_ALIMAGIK 3623#ifdef PCIPCI_ALIMAGIK
3633 if (pci_pci_problems & PCIPCI_ALIMAGIK) { 3624 if (pci_pci_problems & PCIPCI_ALIMAGIK) {
3634 printk(KERN_INFO "%s: quirk: PCIPCI_ALIMAGIK -- latency fixup\n", 3625 pr_info("quirk: PCIPCI_ALIMAGIK -- latency fixup\n");
3635 name);
3636 lat = 0x0A; 3626 lat = 0x0A;
3637 } 3627 }
3638#endif 3628#endif
3639 3629
3640 /* check insmod options */ 3630 /* check insmod options */
3641 if (UNSET != latency) 3631 if (latency != UNSET)
3642 lat = latency; 3632 lat = latency;
3643 3633
3644 /* apply stuff */ 3634 /* apply stuff */
@@ -3647,9 +3637,8 @@ static int cx88_pci_quirks(const char *name, struct pci_dev *pci)
3647 value |= ctrl; 3637 value |= ctrl;
3648 pci_write_config_byte(pci, CX88X_DEVCTRL, value); 3638 pci_write_config_byte(pci, CX88X_DEVCTRL, value);
3649 } 3639 }
3650 if (UNSET != lat) { 3640 if (lat != UNSET) {
3651 printk(KERN_INFO "%s: setting pci latency timer to %d\n", 3641 pr_info("setting pci latency timer to %d\n", latency);
3652 name, latency);
3653 pci_write_config_byte(pci, PCI_LATENCY_TIMER, latency); 3642 pci_write_config_byte(pci, PCI_LATENCY_TIMER, latency);
3654 } 3643 }
3655 return 0; 3644 return 0;
@@ -3657,27 +3646,28 @@ static int cx88_pci_quirks(const char *name, struct pci_dev *pci)
3657 3646
3658int cx88_get_resources(const struct cx88_core *core, struct pci_dev *pci) 3647int cx88_get_resources(const struct cx88_core *core, struct pci_dev *pci)
3659{ 3648{
3660 if (request_mem_region(pci_resource_start(pci,0), 3649 if (request_mem_region(pci_resource_start(pci, 0),
3661 pci_resource_len(pci,0), 3650 pci_resource_len(pci, 0),
3662 core->name)) 3651 core->name))
3663 return 0; 3652 return 0;
3664 printk(KERN_ERR 3653 pr_err("func %d: Can't get MMIO memory @ 0x%llx, subsystem: %04x:%04x\n",
3665 "%s/%d: Can't get MMIO memory @ 0x%llx, subsystem: %04x:%04x\n", 3654 PCI_FUNC(pci->devfn),
3666 core->name, PCI_FUNC(pci->devfn),
3667 (unsigned long long)pci_resource_start(pci, 0), 3655 (unsigned long long)pci_resource_start(pci, 0),
3668 pci->subsystem_vendor, pci->subsystem_device); 3656 pci->subsystem_vendor, pci->subsystem_device);
3669 return -EBUSY; 3657 return -EBUSY;
3670} 3658}
3671 3659
3672/* Allocate and initialize the cx88 core struct. One should hold the 3660/*
3673 * devlist mutex before calling this. */ 3661 * Allocate and initialize the cx88 core struct. One should hold the
3662 * devlist mutex before calling this.
3663 */
3674struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr) 3664struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
3675{ 3665{
3676 struct cx88_core *core; 3666 struct cx88_core *core;
3677 int i; 3667 int i;
3678 3668
3679 core = kzalloc(sizeof(*core), GFP_KERNEL); 3669 core = kzalloc(sizeof(*core), GFP_KERNEL);
3680 if (core == NULL) 3670 if (!core)
3681 return NULL; 3671 return NULL;
3682 3672
3683 atomic_inc(&core->refcount); 3673 atomic_inc(&core->refcount);
@@ -3715,7 +3705,7 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
3715 return NULL; 3705 return NULL;
3716 } 3706 }
3717 3707
3718 if (0 != cx88_get_resources(core, pci)) { 3708 if (cx88_get_resources(core, pci) != 0) {
3719 v4l2_ctrl_handler_free(&core->video_hdl); 3709 v4l2_ctrl_handler_free(&core->video_hdl);
3720 v4l2_ctrl_handler_free(&core->audio_hdl); 3710 v4l2_ctrl_handler_free(&core->audio_hdl);
3721 v4l2_device_unregister(&core->v4l2_dev); 3711 v4l2_device_unregister(&core->v4l2_dev);
@@ -3729,9 +3719,9 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
3729 pci_resource_len(pci, 0)); 3719 pci_resource_len(pci, 0));
3730 core->bmmio = (u8 __iomem *)core->lmmio; 3720 core->bmmio = (u8 __iomem *)core->lmmio;
3731 3721
3732 if (core->lmmio == NULL) { 3722 if (!core->lmmio) {
3733 release_mem_region(pci_resource_start(pci, 0), 3723 release_mem_region(pci_resource_start(pci, 0),
3734 pci_resource_len(pci, 0)); 3724 pci_resource_len(pci, 0));
3735 v4l2_ctrl_handler_free(&core->video_hdl); 3725 v4l2_ctrl_handler_free(&core->video_hdl);
3736 v4l2_ctrl_handler_free(&core->audio_hdl); 3726 v4l2_ctrl_handler_free(&core->audio_hdl);
3737 v4l2_device_unregister(&core->v4l2_dev); 3727 v4l2_device_unregister(&core->v4l2_dev);
@@ -3743,11 +3733,11 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
3743 core->boardnr = UNSET; 3733 core->boardnr = UNSET;
3744 if (card[core->nr] < ARRAY_SIZE(cx88_boards)) 3734 if (card[core->nr] < ARRAY_SIZE(cx88_boards))
3745 core->boardnr = card[core->nr]; 3735 core->boardnr = card[core->nr];
3746 for (i = 0; UNSET == core->boardnr && i < ARRAY_SIZE(cx88_subids); i++) 3736 for (i = 0; core->boardnr == UNSET && i < ARRAY_SIZE(cx88_subids); i++)
3747 if (pci->subsystem_vendor == cx88_subids[i].subvendor && 3737 if (pci->subsystem_vendor == cx88_subids[i].subvendor &&
3748 pci->subsystem_device == cx88_subids[i].subdevice) 3738 pci->subsystem_device == cx88_subids[i].subdevice)
3749 core->boardnr = cx88_subids[i].card; 3739 core->boardnr = cx88_subids[i].card;
3750 if (UNSET == core->boardnr) { 3740 if (core->boardnr == UNSET) {
3751 core->boardnr = CX88_BOARD_UNKNOWN; 3741 core->boardnr = CX88_BOARD_UNKNOWN;
3752 cx88_card_list(core, pci); 3742 cx88_card_list(core, pci);
3753 } 3743 }
@@ -3757,7 +3747,7 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
3757 if (!core->board.num_frontends && (core->board.mpeg & CX88_MPEG_DVB)) 3747 if (!core->board.num_frontends && (core->board.mpeg & CX88_MPEG_DVB))
3758 core->board.num_frontends = 1; 3748 core->board.num_frontends = 1;
3759 3749
3760 info_printk(core, "subsystem: %04x:%04x, board: %s [card=%d,%s], frontend(s): %d\n", 3750 pr_info("subsystem: %04x:%04x, board: %s [card=%d,%s], frontend(s): %d\n",
3761 pci->subsystem_vendor, pci->subsystem_device, core->board.name, 3751 pci->subsystem_vendor, pci->subsystem_device, core->board.name,
3762 core->boardnr, card[core->nr] == core->boardnr ? 3752 core->boardnr, card[core->nr] == core->boardnr ?
3763 "insmod option" : "autodetected", 3753 "insmod option" : "autodetected",
@@ -3777,10 +3767,12 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
3777 cx88_i2c_init(core, pci); 3767 cx88_i2c_init(core, pci);
3778 3768
3779 /* load tuner module, if needed */ 3769 /* load tuner module, if needed */
3780 if (UNSET != core->board.tuner_type) { 3770 if (core->board.tuner_type != UNSET) {
3781 /* Ignore 0x6b and 0x6f on cx88 boards. 3771 /*
3772 * Ignore 0x6b and 0x6f on cx88 boards.
3782 * FusionHDTV5 RT Gold has an ir receiver at 0x6b 3773 * FusionHDTV5 RT Gold has an ir receiver at 0x6b
3783 * and an RTC at 0x6f which can get corrupted if probed. */ 3774 * and an RTC at 0x6f which can get corrupted if probed.
3775 */
3784 static const unsigned short tv_addrs[] = { 3776 static const unsigned short tv_addrs[] = {
3785 0x42, 0x43, 0x4a, 0x4b, /* tda8290 */ 3777 0x42, 0x43, 0x4a, 0x4b, /* tda8290 */
3786 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 3778 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
@@ -3789,24 +3781,27 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
3789 }; 3781 };
3790 int has_demod = (core->board.tda9887_conf & TDA9887_PRESENT); 3782 int has_demod = (core->board.tda9887_conf & TDA9887_PRESENT);
3791 3783
3792 /* I don't trust the radio_type as is stored in the card 3784 /*
3793 definitions, so we just probe for it. 3785 * I don't trust the radio_type as is stored in the card
3794 The radio_type is sometimes missing, or set to UNSET but 3786 * definitions, so we just probe for it.
3795 later code configures a tea5767. 3787 * The radio_type is sometimes missing, or set to UNSET but
3788 * later code configures a tea5767.
3796 */ 3789 */
3797 v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap, 3790 v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap,
3798 "tuner", 0, v4l2_i2c_tuner_addrs(ADDRS_RADIO)); 3791 "tuner", 0,
3792 v4l2_i2c_tuner_addrs(ADDRS_RADIO));
3799 if (has_demod) 3793 if (has_demod)
3800 v4l2_i2c_new_subdev(&core->v4l2_dev, 3794 v4l2_i2c_new_subdev(&core->v4l2_dev,
3801 &core->i2c_adap, "tuner", 3795 &core->i2c_adap, "tuner",
3802 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); 3796 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
3803 if (core->board.tuner_addr == ADDR_UNSET) { 3797 if (core->board.tuner_addr == ADDR_UNSET) {
3804 v4l2_i2c_new_subdev(&core->v4l2_dev, 3798 v4l2_i2c_new_subdev(&core->v4l2_dev,
3805 &core->i2c_adap, "tuner", 3799 &core->i2c_adap, "tuner",
3806 0, has_demod ? tv_addrs + 4 : tv_addrs); 3800 0, has_demod ? tv_addrs + 4 : tv_addrs);
3807 } else { 3801 } else {
3808 v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap, 3802 v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap,
3809 "tuner", core->board.tuner_addr, NULL); 3803 "tuner", core->board.tuner_addr,
3804 NULL);
3810 } 3805 }
3811 } 3806 }
3812 3807
diff --git a/drivers/media/pci/cx88/cx88-core.c b/drivers/media/pci/cx88/cx88-core.c
index 46fe8c1eb9d4..973a9cd4c635 100644
--- a/drivers/media/pci/cx88/cx88-core.c
+++ b/drivers/media/pci/cx88/cx88-core.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * device driver for Conexant 2388x based TV cards 2 * device driver for Conexant 2388x based TV cards
4 * driver core 3 * driver core
5 * 4 *
@@ -19,12 +18,10 @@
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 20 * 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 */ 21 */
27 22
23#include "cx88.h"
24
28#include <linux/init.h> 25#include <linux/init.h>
29#include <linux/list.h> 26#include <linux/list.h>
30#include <linux/module.h> 27#include <linux/module.h>
@@ -38,7 +35,6 @@
38#include <linux/videodev2.h> 35#include <linux/videodev2.h>
39#include <linux/mutex.h> 36#include <linux/mutex.h>
40 37
41#include "cx88.h"
42#include <media/v4l2-common.h> 38#include <media/v4l2-common.h>
43#include <media/v4l2-ioctl.h> 39#include <media/v4l2-ioctl.h>
44 40
@@ -53,17 +49,22 @@ module_param_named(core_debug, cx88_core_debug, int, 0644);
53MODULE_PARM_DESC(core_debug, "enable debug messages [core]"); 49MODULE_PARM_DESC(core_debug, "enable debug messages [core]");
54 50
55static unsigned int nicam; 51static unsigned int nicam;
56module_param(nicam,int,0644); 52module_param(nicam, int, 0644);
57MODULE_PARM_DESC(nicam,"tv audio is nicam"); 53MODULE_PARM_DESC(nicam, "tv audio is nicam");
58 54
59static unsigned int nocomb; 55static unsigned int nocomb;
60module_param(nocomb,int,0644); 56module_param(nocomb, int, 0644);
61MODULE_PARM_DESC(nocomb,"disable comb filter"); 57MODULE_PARM_DESC(nocomb, "disable comb filter");
58
59#define dprintk0(fmt, arg...) \
60 printk(KERN_DEBUG pr_fmt("%s: core:" fmt), \
61 __func__, ##arg) \
62 62
63#define dprintk(level,fmt, arg...) do { \ 63#define dprintk(level, fmt, arg...) do { \
64 if (cx88_core_debug >= level) \ 64 if (cx88_core_debug >= level) \
65 printk(KERN_DEBUG "%s: " fmt, core->name , ## arg); \ 65 printk(KERN_DEBUG pr_fmt("%s: core:" fmt), \
66 } while(0) 66 __func__, ##arg); \
67} while (0)
67 68
68static unsigned int cx88_devcount; 69static unsigned int cx88_devcount;
69static LIST_HEAD(cx88_devlist); 70static LIST_HEAD(cx88_devlist);
@@ -71,15 +72,17 @@ static DEFINE_MUTEX(devlist);
71 72
72#define NO_SYNC_LINE (-1U) 73#define NO_SYNC_LINE (-1U)
73 74
74/* @lpi: lines per IRQ, or 0 to not generate irqs. Note: IRQ to be 75/*
75 generated _after_ lpi lines are transferred. */ 76 * @lpi: lines per IRQ, or 0 to not generate irqs. Note: IRQ to be
76static __le32* cx88_risc_field(__le32 *rp, struct scatterlist *sglist, 77 * generated _after_ lpi lines are transferred.
77 unsigned int offset, u32 sync_line, 78 */
78 unsigned int bpl, unsigned int padding, 79static __le32 *cx88_risc_field(__le32 *rp, struct scatterlist *sglist,
79 unsigned int lines, unsigned int lpi, bool jump) 80 unsigned int offset, u32 sync_line,
81 unsigned int bpl, unsigned int padding,
82 unsigned int lines, unsigned int lpi, bool jump)
80{ 83{
81 struct scatterlist *sg; 84 struct scatterlist *sg;
82 unsigned int line,todo,sol; 85 unsigned int line, todo, sol;
83 86
84 if (jump) { 87 if (jump) {
85 (*rp++) = cpu_to_le32(RISC_JUMP); 88 (*rp++) = cpu_to_le32(RISC_JUMP);
@@ -97,33 +100,34 @@ static __le32* cx88_risc_field(__le32 *rp, struct scatterlist *sglist,
97 offset -= sg_dma_len(sg); 100 offset -= sg_dma_len(sg);
98 sg = sg_next(sg); 101 sg = sg_next(sg);
99 } 102 }
100 if (lpi && line>0 && !(line % lpi)) 103 if (lpi && line > 0 && !(line % lpi))
101 sol = RISC_SOL | RISC_IRQ1 | RISC_CNT_INC; 104 sol = RISC_SOL | RISC_IRQ1 | RISC_CNT_INC;
102 else 105 else
103 sol = RISC_SOL; 106 sol = RISC_SOL;
104 if (bpl <= sg_dma_len(sg)-offset) { 107 if (bpl <= sg_dma_len(sg) - offset) {
105 /* fits into current chunk */ 108 /* fits into current chunk */
106 *(rp++)=cpu_to_le32(RISC_WRITE|sol|RISC_EOL|bpl); 109 *(rp++) = cpu_to_le32(RISC_WRITE | sol |
107 *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset); 110 RISC_EOL | bpl);
108 offset+=bpl; 111 *(rp++) = cpu_to_le32(sg_dma_address(sg) + offset);
112 offset += bpl;
109 } else { 113 } else {
110 /* scanline needs to be split */ 114 /* scanline needs to be split */
111 todo = bpl; 115 todo = bpl;
112 *(rp++)=cpu_to_le32(RISC_WRITE|sol| 116 *(rp++) = cpu_to_le32(RISC_WRITE | sol |
113 (sg_dma_len(sg)-offset)); 117 (sg_dma_len(sg) - offset));
114 *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset); 118 *(rp++) = cpu_to_le32(sg_dma_address(sg) + offset);
115 todo -= (sg_dma_len(sg)-offset); 119 todo -= (sg_dma_len(sg) - offset);
116 offset = 0; 120 offset = 0;
117 sg = sg_next(sg); 121 sg = sg_next(sg);
118 while (todo > sg_dma_len(sg)) { 122 while (todo > sg_dma_len(sg)) {
119 *(rp++)=cpu_to_le32(RISC_WRITE| 123 *(rp++) = cpu_to_le32(RISC_WRITE |
120 sg_dma_len(sg)); 124 sg_dma_len(sg));
121 *(rp++)=cpu_to_le32(sg_dma_address(sg)); 125 *(rp++) = cpu_to_le32(sg_dma_address(sg));
122 todo -= sg_dma_len(sg); 126 todo -= sg_dma_len(sg);
123 sg = sg_next(sg); 127 sg = sg_next(sg);
124 } 128 }
125 *(rp++)=cpu_to_le32(RISC_WRITE|RISC_EOL|todo); 129 *(rp++) = cpu_to_le32(RISC_WRITE | RISC_EOL | todo);
126 *(rp++)=cpu_to_le32(sg_dma_address(sg)); 130 *(rp++) = cpu_to_le32(sg_dma_address(sg));
127 offset += todo; 131 offset += todo;
128 } 132 }
129 offset += padding; 133 offset += padding;
@@ -137,41 +141,46 @@ int cx88_risc_buffer(struct pci_dev *pci, struct cx88_riscmem *risc,
137 unsigned int top_offset, unsigned int bottom_offset, 141 unsigned int top_offset, unsigned int bottom_offset,
138 unsigned int bpl, unsigned int padding, unsigned int lines) 142 unsigned int bpl, unsigned int padding, unsigned int lines)
139{ 143{
140 u32 instructions,fields; 144 u32 instructions, fields;
141 __le32 *rp; 145 __le32 *rp;
142 146
143 fields = 0; 147 fields = 0;
144 if (UNSET != top_offset) 148 if (top_offset != UNSET)
145 fields++; 149 fields++;
146 if (UNSET != bottom_offset) 150 if (bottom_offset != UNSET)
147 fields++; 151 fields++;
148 152
149 /* estimate risc mem: worst case is one write per page border + 153 /*
150 one write per scan line + syncs + jump (all 2 dwords). Padding 154 * estimate risc mem: worst case is one write per page border +
151 can cause next bpl to start close to a page border. First DMA 155 * one write per scan line + syncs + jump (all 2 dwords). Padding
152 region may be smaller than PAGE_SIZE */ 156 * can cause next bpl to start close to a page border. First DMA
153 instructions = fields * (1 + ((bpl + padding) * lines) / PAGE_SIZE + lines); 157 * region may be smaller than PAGE_SIZE
158 */
159 instructions = fields * (1 + ((bpl + padding) * lines) /
160 PAGE_SIZE + lines);
154 instructions += 4; 161 instructions += 4;
155 risc->size = instructions * 8; 162 risc->size = instructions * 8;
156 risc->dma = 0; 163 risc->dma = 0;
157 risc->cpu = pci_zalloc_consistent(pci, risc->size, &risc->dma); 164 risc->cpu = pci_zalloc_consistent(pci, risc->size, &risc->dma);
158 if (NULL == risc->cpu) 165 if (!risc->cpu)
159 return -ENOMEM; 166 return -ENOMEM;
160 167
161 /* write risc instructions */ 168 /* write risc instructions */
162 rp = risc->cpu; 169 rp = risc->cpu;
163 if (UNSET != top_offset) 170 if (top_offset != UNSET)
164 rp = cx88_risc_field(rp, sglist, top_offset, 0, 171 rp = cx88_risc_field(rp, sglist, top_offset, 0,
165 bpl, padding, lines, 0, true); 172 bpl, padding, lines, 0, true);
166 if (UNSET != bottom_offset) 173 if (bottom_offset != UNSET)
167 rp = cx88_risc_field(rp, sglist, bottom_offset, 0x200, 174 rp = cx88_risc_field(rp, sglist, bottom_offset, 0x200,
168 bpl, padding, lines, 0, top_offset == UNSET); 175 bpl, padding, lines, 0,
176 top_offset == UNSET);
169 177
170 /* save pointer to jmp instruction address */ 178 /* save pointer to jmp instruction address */
171 risc->jmp = rp; 179 risc->jmp = rp;
172 BUG_ON((risc->jmp - risc->cpu + 2) * sizeof (*risc->cpu) > risc->size); 180 WARN_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size);
173 return 0; 181 return 0;
174} 182}
183EXPORT_SYMBOL(cx88_risc_buffer);
175 184
176int cx88_risc_databuffer(struct pci_dev *pci, struct cx88_riscmem *risc, 185int cx88_risc_databuffer(struct pci_dev *pci, struct cx88_riscmem *risc,
177 struct scatterlist *sglist, unsigned int bpl, 186 struct scatterlist *sglist, unsigned int bpl,
@@ -180,32 +189,38 @@ int cx88_risc_databuffer(struct pci_dev *pci, struct cx88_riscmem *risc,
180 u32 instructions; 189 u32 instructions;
181 __le32 *rp; 190 __le32 *rp;
182 191
183 /* estimate risc mem: worst case is one write per page border + 192 /*
184 one write per scan line + syncs + jump (all 2 dwords). Here 193 * estimate risc mem: worst case is one write per page border +
185 there is no padding and no sync. First DMA region may be smaller 194 * one write per scan line + syncs + jump (all 2 dwords). Here
186 than PAGE_SIZE */ 195 * there is no padding and no sync. First DMA region may be smaller
196 * than PAGE_SIZE
197 */
187 instructions = 1 + (bpl * lines) / PAGE_SIZE + lines; 198 instructions = 1 + (bpl * lines) / PAGE_SIZE + lines;
188 instructions += 3; 199 instructions += 3;
189 risc->size = instructions * 8; 200 risc->size = instructions * 8;
190 risc->dma = 0; 201 risc->dma = 0;
191 risc->cpu = pci_zalloc_consistent(pci, risc->size, &risc->dma); 202 risc->cpu = pci_zalloc_consistent(pci, risc->size, &risc->dma);
192 if (NULL == risc->cpu) 203 if (!risc->cpu)
193 return -ENOMEM; 204 return -ENOMEM;
194 205
195 /* write risc instructions */ 206 /* write risc instructions */
196 rp = risc->cpu; 207 rp = risc->cpu;
197 rp = cx88_risc_field(rp, sglist, 0, NO_SYNC_LINE, bpl, 0, lines, lpi, !lpi); 208 rp = cx88_risc_field(rp, sglist, 0, NO_SYNC_LINE, bpl, 0,
209 lines, lpi, !lpi);
198 210
199 /* save pointer to jmp instruction address */ 211 /* save pointer to jmp instruction address */
200 risc->jmp = rp; 212 risc->jmp = rp;
201 BUG_ON((risc->jmp - risc->cpu + 2) * sizeof (*risc->cpu) > risc->size); 213 WARN_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size);
202 return 0; 214 return 0;
203} 215}
216EXPORT_SYMBOL(cx88_risc_databuffer);
204 217
205/* ------------------------------------------------------------------ */ 218/*
206/* our SRAM memory layout */ 219 * our SRAM memory layout
220 */
207 221
208/* we are going to put all thr risc programs into host memory, so we 222/*
223 * we are going to put all thr risc programs into host memory, so we
209 * can use the whole SDRAM for the DMA fifos. To simplify things, we 224 * can use the whole SDRAM for the DMA fifos. To simplify things, we
210 * use a static memory layout. That surely will waste memory in case 225 * use a static memory layout. That surely will waste memory in case
211 * we don't use all DMA channels at the same time (which will be the 226 * we don't use all DMA channels at the same time (which will be the
@@ -329,12 +344,13 @@ const struct sram_channel cx88_sram_channels[] = {
329 .cnt2_reg = MO_DMA27_CNT2, 344 .cnt2_reg = MO_DMA27_CNT2,
330 }, 345 },
331}; 346};
347EXPORT_SYMBOL(cx88_sram_channels);
332 348
333int cx88_sram_channel_setup(struct cx88_core *core, 349int cx88_sram_channel_setup(struct cx88_core *core,
334 const struct sram_channel *ch, 350 const struct sram_channel *ch,
335 unsigned int bpl, u32 risc) 351 unsigned int bpl, u32 risc)
336{ 352{
337 unsigned int i,lines; 353 unsigned int i, lines;
338 u32 cdt; 354 u32 cdt;
339 355
340 bpl = (bpl + 7) & ~7; /* alignment */ 356 bpl = (bpl + 7) & ~7; /* alignment */
@@ -342,16 +358,16 @@ int cx88_sram_channel_setup(struct cx88_core *core,
342 lines = ch->fifo_size / bpl; 358 lines = ch->fifo_size / bpl;
343 if (lines > 6) 359 if (lines > 6)
344 lines = 6; 360 lines = 6;
345 BUG_ON(lines < 2); 361 WARN_ON(lines < 2);
346 362
347 /* write CDT */ 363 /* write CDT */
348 for (i = 0; i < lines; i++) 364 for (i = 0; i < lines; i++)
349 cx_write(cdt + 16*i, ch->fifo_start + bpl*i); 365 cx_write(cdt + 16 * i, ch->fifo_start + bpl * i);
350 366
351 /* write CMDS */ 367 /* write CMDS */
352 cx_write(ch->cmds_start + 0, risc); 368 cx_write(ch->cmds_start + 0, risc);
353 cx_write(ch->cmds_start + 4, cdt); 369 cx_write(ch->cmds_start + 4, cdt);
354 cx_write(ch->cmds_start + 8, (lines*16) >> 3); 370 cx_write(ch->cmds_start + 8, (lines * 16) >> 3);
355 cx_write(ch->cmds_start + 12, ch->ctrl_start); 371 cx_write(ch->cmds_start + 12, ch->ctrl_start);
356 cx_write(ch->cmds_start + 16, 64 >> 2); 372 cx_write(ch->cmds_start + 16, 64 >> 2);
357 for (i = 20; i < 64; i += 4) 373 for (i = 20; i < 64; i += 4)
@@ -360,12 +376,13 @@ int cx88_sram_channel_setup(struct cx88_core *core,
360 /* fill registers */ 376 /* fill registers */
361 cx_write(ch->ptr1_reg, ch->fifo_start); 377 cx_write(ch->ptr1_reg, ch->fifo_start);
362 cx_write(ch->ptr2_reg, cdt); 378 cx_write(ch->ptr2_reg, cdt);
363 cx_write(ch->cnt1_reg, (bpl >> 3) -1); 379 cx_write(ch->cnt1_reg, (bpl >> 3) - 1);
364 cx_write(ch->cnt2_reg, (lines*16) >> 3); 380 cx_write(ch->cnt2_reg, (lines * 16) >> 3);
365 381
366 dprintk(2,"sram setup %s: bpl=%d lines=%d\n", ch->name, bpl, lines); 382 dprintk(2, "sram setup %s: bpl=%d lines=%d\n", ch->name, bpl, lines);
367 return 0; 383 return 0;
368} 384}
385EXPORT_SYMBOL(cx88_sram_channel_setup);
369 386
370/* ------------------------------------------------------------------ */ 387/* ------------------------------------------------------------------ */
371/* debug helper code */ 388/* debug helper code */
@@ -373,23 +390,23 @@ int cx88_sram_channel_setup(struct cx88_core *core,
373static int cx88_risc_decode(u32 risc) 390static int cx88_risc_decode(u32 risc)
374{ 391{
375 static const char * const instr[16] = { 392 static const char * const instr[16] = {
376 [ RISC_SYNC >> 28 ] = "sync", 393 [RISC_SYNC >> 28] = "sync",
377 [ RISC_WRITE >> 28 ] = "write", 394 [RISC_WRITE >> 28] = "write",
378 [ RISC_WRITEC >> 28 ] = "writec", 395 [RISC_WRITEC >> 28] = "writec",
379 [ RISC_READ >> 28 ] = "read", 396 [RISC_READ >> 28] = "read",
380 [ RISC_READC >> 28 ] = "readc", 397 [RISC_READC >> 28] = "readc",
381 [ RISC_JUMP >> 28 ] = "jump", 398 [RISC_JUMP >> 28] = "jump",
382 [ RISC_SKIP >> 28 ] = "skip", 399 [RISC_SKIP >> 28] = "skip",
383 [ RISC_WRITERM >> 28 ] = "writerm", 400 [RISC_WRITERM >> 28] = "writerm",
384 [ RISC_WRITECM >> 28 ] = "writecm", 401 [RISC_WRITECM >> 28] = "writecm",
385 [ RISC_WRITECR >> 28 ] = "writecr", 402 [RISC_WRITECR >> 28] = "writecr",
386 }; 403 };
387 static int const incr[16] = { 404 static int const incr[16] = {
388 [ RISC_WRITE >> 28 ] = 2, 405 [RISC_WRITE >> 28] = 2,
389 [ RISC_JUMP >> 28 ] = 2, 406 [RISC_JUMP >> 28] = 2,
390 [ RISC_WRITERM >> 28 ] = 3, 407 [RISC_WRITERM >> 28] = 3,
391 [ RISC_WRITECM >> 28 ] = 3, 408 [RISC_WRITECM >> 28] = 3,
392 [ RISC_WRITECR >> 28 ] = 4, 409 [RISC_WRITECR >> 28] = 4,
393 }; 410 };
394 static const char * const bits[] = { 411 static const char * const bits[] = {
395 "12", "13", "14", "resync", 412 "12", "13", "14", "resync",
@@ -399,16 +416,15 @@ static int cx88_risc_decode(u32 risc)
399 }; 416 };
400 int i; 417 int i;
401 418
402 printk("0x%08x [ %s", risc, 419 dprintk0("0x%08x [ %s", risc,
403 instr[risc >> 28] ? instr[risc >> 28] : "INVALID"); 420 instr[risc >> 28] ? instr[risc >> 28] : "INVALID");
404 for (i = ARRAY_SIZE(bits)-1; i >= 0; i--) 421 for (i = ARRAY_SIZE(bits) - 1; i >= 0; i--)
405 if (risc & (1 << (i + 12))) 422 if (risc & (1 << (i + 12)))
406 printk(" %s",bits[i]); 423 pr_cont(" %s", bits[i]);
407 printk(" count=%d ]\n", risc & 0xfff); 424 pr_cont(" count=%d ]\n", risc & 0xfff);
408 return incr[risc >> 28] ? incr[risc >> 28] : 1; 425 return incr[risc >> 28] ? incr[risc >> 28] : 1;
409} 426}
410 427
411
412void cx88_sram_channel_dump(struct cx88_core *core, 428void cx88_sram_channel_dump(struct cx88_core *core,
413 const struct sram_channel *ch) 429 const struct sram_channel *ch)
414{ 430{
@@ -426,46 +442,41 @@ void cx88_sram_channel_dump(struct cx88_core *core,
426 "line / byte", 442 "line / byte",
427 }; 443 };
428 u32 risc; 444 u32 risc;
429 unsigned int i,j,n; 445 unsigned int i, j, n;
430 446
431 printk("%s: %s - dma channel status dump\n", 447 dprintk0("%s - dma channel status dump\n", ch->name);
432 core->name,ch->name);
433 for (i = 0; i < ARRAY_SIZE(name); i++) 448 for (i = 0; i < ARRAY_SIZE(name); i++)
434 printk("%s: cmds: %-12s: 0x%08x\n", 449 dprintk0(" cmds: %-12s: 0x%08x\n",
435 core->name,name[i], 450 name[i], cx_read(ch->cmds_start + 4 * i));
436 cx_read(ch->cmds_start + 4*i));
437 for (n = 1, i = 0; i < 4; i++) { 451 for (n = 1, i = 0; i < 4; i++) {
438 risc = cx_read(ch->cmds_start + 4 * (i+11)); 452 risc = cx_read(ch->cmds_start + 4 * (i + 11));
439 printk("%s: risc%d: ", core->name, i); 453 pr_cont(" risc%d: ", i);
440 if (--n) 454 if (--n)
441 printk("0x%08x [ arg #%d ]\n", risc, n); 455 pr_cont("0x%08x [ arg #%d ]\n", risc, n);
442 else 456 else
443 n = cx88_risc_decode(risc); 457 n = cx88_risc_decode(risc);
444 } 458 }
445 for (i = 0; i < 16; i += n) { 459 for (i = 0; i < 16; i += n) {
446 risc = cx_read(ch->ctrl_start + 4 * i); 460 risc = cx_read(ch->ctrl_start + 4 * i);
447 printk("%s: iq %x: ", core->name, i); 461 dprintk0(" iq %x: ", i);
448 n = cx88_risc_decode(risc); 462 n = cx88_risc_decode(risc);
449 for (j = 1; j < n; j++) { 463 for (j = 1; j < n; j++) {
450 risc = cx_read(ch->ctrl_start + 4 * (i+j)); 464 risc = cx_read(ch->ctrl_start + 4 * (i + j));
451 printk("%s: iq %x: 0x%08x [ arg #%d ]\n", 465 pr_cont(" iq %x: 0x%08x [ arg #%d ]\n",
452 core->name, i+j, risc, j); 466 i + j, risc, j);
453 } 467 }
454 } 468 }
455 469
456 printk("%s: fifo: 0x%08x -> 0x%x\n", 470 dprintk0("fifo: 0x%08x -> 0x%x\n",
457 core->name, ch->fifo_start, ch->fifo_start+ch->fifo_size); 471 ch->fifo_start, ch->fifo_start + ch->fifo_size);
458 printk("%s: ctrl: 0x%08x -> 0x%x\n", 472 dprintk0("ctrl: 0x%08x -> 0x%x\n",
459 core->name, ch->ctrl_start, ch->ctrl_start+6*16); 473 ch->ctrl_start, ch->ctrl_start + 6 * 16);
460 printk("%s: ptr1_reg: 0x%08x\n", 474 dprintk0(" ptr1_reg: 0x%08x\n", cx_read(ch->ptr1_reg));
461 core->name,cx_read(ch->ptr1_reg)); 475 dprintk0(" ptr2_reg: 0x%08x\n", cx_read(ch->ptr2_reg));
462 printk("%s: ptr2_reg: 0x%08x\n", 476 dprintk0(" cnt1_reg: 0x%08x\n", cx_read(ch->cnt1_reg));
463 core->name,cx_read(ch->ptr2_reg)); 477 dprintk0(" cnt2_reg: 0x%08x\n", cx_read(ch->cnt2_reg));
464 printk("%s: cnt1_reg: 0x%08x\n",
465 core->name,cx_read(ch->cnt1_reg));
466 printk("%s: cnt2_reg: 0x%08x\n",
467 core->name,cx_read(ch->cnt2_reg));
468} 478}
479EXPORT_SYMBOL(cx88_sram_channel_dump);
469 480
470static const char *cx88_pci_irqs[32] = { 481static const char *cx88_pci_irqs[32] = {
471 "vid", "aud", "ts", "vip", "hst", "5", "6", "tm1", 482 "vid", "aud", "ts", "vip", "hst", "5", "6", "tm1",
@@ -474,25 +485,26 @@ static const char *cx88_pci_irqs[32] = {
474 "i2c", "i2c_rack", "ir_smp", "gpio0", "gpio1" 485 "i2c", "i2c_rack", "ir_smp", "gpio0", "gpio1"
475}; 486};
476 487
477void cx88_print_irqbits(const char *name, const char *tag, const char *strings[], 488void cx88_print_irqbits(const char *tag, const char *strings[],
478 int len, u32 bits, u32 mask) 489 int len, u32 bits, u32 mask)
479{ 490{
480 unsigned int i; 491 unsigned int i;
481 492
482 printk(KERN_DEBUG "%s: %s [0x%x]", name, tag, bits); 493 dprintk0("%s [0x%x]", tag, bits);
483 for (i = 0; i < len; i++) { 494 for (i = 0; i < len; i++) {
484 if (!(bits & (1 << i))) 495 if (!(bits & (1 << i)))
485 continue; 496 continue;
486 if (strings[i]) 497 if (strings[i])
487 printk(" %s", strings[i]); 498 pr_cont(" %s", strings[i]);
488 else 499 else
489 printk(" %d", i); 500 pr_cont(" %d", i);
490 if (!(mask & (1 << i))) 501 if (!(mask & (1 << i)))
491 continue; 502 continue;
492 printk("*"); 503 pr_cont("*");
493 } 504 }
494 printk("\n"); 505 pr_cont("\n");
495} 506}
507EXPORT_SYMBOL(cx88_print_irqbits);
496 508
497/* ------------------------------------------------------------------ */ 509/* ------------------------------------------------------------------ */
498 510
@@ -505,11 +517,12 @@ int cx88_core_irq(struct cx88_core *core, u32 status)
505 handled++; 517 handled++;
506 } 518 }
507 if (!handled) 519 if (!handled)
508 cx88_print_irqbits(core->name, "irq pci", 520 cx88_print_irqbits("irq pci",
509 cx88_pci_irqs, ARRAY_SIZE(cx88_pci_irqs), 521 cx88_pci_irqs, ARRAY_SIZE(cx88_pci_irqs),
510 status, core->pci_irqmask); 522 status, core->pci_irqmask);
511 return handled; 523 return handled;
512} 524}
525EXPORT_SYMBOL(cx88_core_irq);
513 526
514void cx88_wakeup(struct cx88_core *core, 527void cx88_wakeup(struct cx88_core *core,
515 struct cx88_dmaqueue *q, u32 count) 528 struct cx88_dmaqueue *q, u32 count)
@@ -524,6 +537,7 @@ void cx88_wakeup(struct cx88_core *core,
524 list_del(&buf->list); 537 list_del(&buf->list);
525 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); 538 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
526} 539}
540EXPORT_SYMBOL(cx88_wakeup);
527 541
528void cx88_shutdown(struct cx88_core *core) 542void cx88_shutdown(struct cx88_core *core)
529{ 543{
@@ -548,10 +562,11 @@ void cx88_shutdown(struct cx88_core *core)
548 /* stop capturing */ 562 /* stop capturing */
549 cx_write(VID_CAPTURE_CONTROL, 0); 563 cx_write(VID_CAPTURE_CONTROL, 0);
550} 564}
565EXPORT_SYMBOL(cx88_shutdown);
551 566
552int cx88_reset(struct cx88_core *core) 567int cx88_reset(struct cx88_core *core)
553{ 568{
554 dprintk(1,"%s\n",__func__); 569 dprintk(1, "");
555 cx88_shutdown(core); 570 cx88_shutdown(core);
556 571
557 /* clear irq status */ 572 /* clear irq status */
@@ -563,13 +578,15 @@ int cx88_reset(struct cx88_core *core)
563 msleep(100); 578 msleep(100);
564 579
565 /* init sram */ 580 /* init sram */
566 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH21], 720*4, 0); 581 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH21],
582 720 * 4, 0);
567 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH22], 128, 0); 583 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH22], 128, 0);
568 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH23], 128, 0); 584 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH23], 128, 0);
569 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH24], 128, 0); 585 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH24], 128, 0);
570 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH25], 128, 0); 586 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH25], 128, 0);
571 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH26], 128, 0); 587 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH26], 128, 0);
572 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28], 188*4, 0); 588 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28],
589 188 * 4, 0);
573 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH27], 128, 0); 590 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH27], 128, 0);
574 591
575 /* misc init ... */ 592 /* misc init ... */
@@ -597,11 +614,12 @@ int cx88_reset(struct cx88_core *core)
597 614
598 /* Reset on-board parts */ 615 /* Reset on-board parts */
599 cx_write(MO_SRST_IO, 0); 616 cx_write(MO_SRST_IO, 0);
600 msleep(10); 617 usleep_range(10000, 20000);
601 cx_write(MO_SRST_IO, 1); 618 cx_write(MO_SRST_IO, 1);
602 619
603 return 0; 620 return 0;
604} 621}
622EXPORT_SYMBOL(cx88_reset);
605 623
606/* ------------------------------------------------------------------ */ 624/* ------------------------------------------------------------------ */
607 625
@@ -631,10 +649,11 @@ static inline unsigned int norm_fsc8(v4l2_std_id norm)
631 if (norm & V4L2_STD_NTSC) // All NTSC/M and variants 649 if (norm & V4L2_STD_NTSC) // All NTSC/M and variants
632 return 28636360; // 3.57954545 MHz +/- 10 Hz 650 return 28636360; // 3.57954545 MHz +/- 10 Hz
633 651
634 /* SECAM have also different sub carrier for chroma, 652 /*
635 but step_db and step_dr, at cx88_set_tvnorm already handles that. 653 * SECAM have also different sub carrier for chroma,
636 654 * but step_db and step_dr, at cx88_set_tvnorm already handles that.
637 The same FSC applies to PAL/BGDKIH, PAL/60, NTSC/4.43 and PAL/N 655 *
656 * The same FSC applies to PAL/BGDKIH, PAL/60, NTSC/4.43 and PAL/N
638 */ 657 */
639 658
640 return 35468950; // 4.43361875 MHz +/- 5 Hz 659 return 35468950; // 4.43361875 MHz +/- 5 Hz
@@ -642,13 +661,12 @@ static inline unsigned int norm_fsc8(v4l2_std_id norm)
642 661
643static inline unsigned int norm_htotal(v4l2_std_id norm) 662static inline unsigned int norm_htotal(v4l2_std_id norm)
644{ 663{
645 664 unsigned int fsc4 = norm_fsc8(norm) / 2;
646 unsigned int fsc4=norm_fsc8(norm)/2;
647 665
648 /* returns 4*FSC / vtotal / frames per seconds */ 666 /* returns 4*FSC / vtotal / frames per seconds */
649 return (norm & V4L2_STD_625_50) ? 667 return (norm & V4L2_STD_625_50) ?
650 ((fsc4+312)/625+12)/25 : 668 ((fsc4 + 312) / 625 + 12) / 25 :
651 ((fsc4+262)/525*1001+15000)/30000; 669 ((fsc4 + 262) / 525 * 1001 + 15000) / 30000;
652} 670}
653 671
654static inline unsigned int norm_vbipack(v4l2_std_id norm) 672static inline unsigned int norm_vbipack(v4l2_std_id norm)
@@ -656,14 +674,14 @@ static inline unsigned int norm_vbipack(v4l2_std_id norm)
656 return (norm & V4L2_STD_625_50) ? 511 : 400; 674 return (norm & V4L2_STD_625_50) ? 511 : 400;
657} 675}
658 676
659int cx88_set_scale(struct cx88_core *core, unsigned int width, unsigned int height, 677int cx88_set_scale(struct cx88_core *core, unsigned int width,
660 enum v4l2_field field) 678 unsigned int height, enum v4l2_field field)
661{ 679{
662 unsigned int swidth = norm_swidth(core->tvnorm); 680 unsigned int swidth = norm_swidth(core->tvnorm);
663 unsigned int sheight = norm_maxh(core->tvnorm); 681 unsigned int sheight = norm_maxh(core->tvnorm);
664 u32 value; 682 u32 value;
665 683
666 dprintk(1,"set_scale: %dx%d [%s%s,%s]\n", width, height, 684 dprintk(1, "set_scale: %dx%d [%s%s,%s]\n", width, height,
667 V4L2_FIELD_HAS_TOP(field) ? "T" : "", 685 V4L2_FIELD_HAS_TOP(field) ? "T" : "",
668 V4L2_FIELD_HAS_BOTTOM(field) ? "B" : "", 686 V4L2_FIELD_HAS_BOTTOM(field) ? "B" : "",
669 v4l2_norm_to_name(core->tvnorm)); 687 v4l2_norm_to_name(core->tvnorm));
@@ -675,30 +693,30 @@ int cx88_set_scale(struct cx88_core *core, unsigned int width, unsigned int heig
675 value &= 0x3fe; 693 value &= 0x3fe;
676 cx_write(MO_HDELAY_EVEN, value); 694 cx_write(MO_HDELAY_EVEN, value);
677 cx_write(MO_HDELAY_ODD, value); 695 cx_write(MO_HDELAY_ODD, value);
678 dprintk(1,"set_scale: hdelay 0x%04x (width %d)\n", value,swidth); 696 dprintk(1, "set_scale: hdelay 0x%04x (width %d)\n", value, swidth);
679 697
680 value = (swidth * 4096 / width) - 4096; 698 value = (swidth * 4096 / width) - 4096;
681 cx_write(MO_HSCALE_EVEN, value); 699 cx_write(MO_HSCALE_EVEN, value);
682 cx_write(MO_HSCALE_ODD, value); 700 cx_write(MO_HSCALE_ODD, value);
683 dprintk(1,"set_scale: hscale 0x%04x\n", value); 701 dprintk(1, "set_scale: hscale 0x%04x\n", value);
684 702
685 cx_write(MO_HACTIVE_EVEN, width); 703 cx_write(MO_HACTIVE_EVEN, width);
686 cx_write(MO_HACTIVE_ODD, width); 704 cx_write(MO_HACTIVE_ODD, width);
687 dprintk(1,"set_scale: hactive 0x%04x\n", width); 705 dprintk(1, "set_scale: hactive 0x%04x\n", width);
688 706
689 // recalc V scale Register (delay is constant) 707 // recalc V scale Register (delay is constant)
690 cx_write(MO_VDELAY_EVEN, norm_vdelay(core->tvnorm)); 708 cx_write(MO_VDELAY_EVEN, norm_vdelay(core->tvnorm));
691 cx_write(MO_VDELAY_ODD, norm_vdelay(core->tvnorm)); 709 cx_write(MO_VDELAY_ODD, norm_vdelay(core->tvnorm));
692 dprintk(1,"set_scale: vdelay 0x%04x\n", norm_vdelay(core->tvnorm)); 710 dprintk(1, "set_scale: vdelay 0x%04x\n", norm_vdelay(core->tvnorm));
693 711
694 value = (0x10000 - (sheight * 512 / height - 512)) & 0x1fff; 712 value = (0x10000 - (sheight * 512 / height - 512)) & 0x1fff;
695 cx_write(MO_VSCALE_EVEN, value); 713 cx_write(MO_VSCALE_EVEN, value);
696 cx_write(MO_VSCALE_ODD, value); 714 cx_write(MO_VSCALE_ODD, value);
697 dprintk(1,"set_scale: vscale 0x%04x\n", value); 715 dprintk(1, "set_scale: vscale 0x%04x\n", value);
698 716
699 cx_write(MO_VACTIVE_EVEN, sheight); 717 cx_write(MO_VACTIVE_EVEN, sheight);
700 cx_write(MO_VACTIVE_ODD, sheight); 718 cx_write(MO_VACTIVE_ODD, sheight);
701 dprintk(1,"set_scale: vactive 0x%04x\n", sheight); 719 dprintk(1, "set_scale: vactive 0x%04x\n", sheight);
702 720
703 // setup filters 721 // setup filters
704 value = 0; 722 value = 0;
@@ -709,7 +727,7 @@ int cx88_set_scale(struct cx88_core *core, unsigned int width, unsigned int heig
709 } 727 }
710 if (INPUT(core->input).type == CX88_VMUX_SVIDEO) 728 if (INPUT(core->input).type == CX88_VMUX_SVIDEO)
711 value |= (1 << 13) | (1 << 5); 729 value |= (1 << 13) | (1 << 5);
712 if (V4L2_FIELD_INTERLACED == field) 730 if (field == V4L2_FIELD_INTERLACED)
713 value |= (1 << 3); // VINT (interlaced vertical scaling) 731 value |= (1 << 3); // VINT (interlaced vertical scaling)
714 if (width < 385) 732 if (width < 385)
715 value |= (1 << 0); // 3-tap interpolation 733 value |= (1 << 0); // 3-tap interpolation
@@ -720,10 +738,11 @@ int cx88_set_scale(struct cx88_core *core, unsigned int width, unsigned int heig
720 738
721 cx_andor(MO_FILTER_EVEN, 0x7ffc7f, value); /* preserve PEAKEN, PSEL */ 739 cx_andor(MO_FILTER_EVEN, 0x7ffc7f, value); /* preserve PEAKEN, PSEL */
722 cx_andor(MO_FILTER_ODD, 0x7ffc7f, value); 740 cx_andor(MO_FILTER_ODD, 0x7ffc7f, value);
723 dprintk(1,"set_scale: filter 0x%04x\n", value); 741 dprintk(1, "set_scale: filter 0x%04x\n", value);
724 742
725 return 0; 743 return 0;
726} 744}
745EXPORT_SYMBOL(cx88_set_scale);
727 746
728static const u32 xtal = 28636363; 747static const u32 xtal = 28636363;
729 748
@@ -740,36 +759,36 @@ static int set_pll(struct cx88_core *core, int prescale, u32 ofreq)
740 prescale = 5; 759 prescale = 5;
741 760
742 pll = ofreq * 8 * prescale * (u64)(1 << 20); 761 pll = ofreq * 8 * prescale * (u64)(1 << 20);
743 do_div(pll,xtal); 762 do_div(pll, xtal);
744 reg = (pll & 0x3ffffff) | (pre[prescale] << 26); 763 reg = (pll & 0x3ffffff) | (pre[prescale] << 26);
745 if (((reg >> 20) & 0x3f) < 14) { 764 if (((reg >> 20) & 0x3f) < 14) {
746 printk("%s/0: pll out of range\n",core->name); 765 pr_err("pll out of range\n");
747 return -1; 766 return -1;
748 } 767 }
749 768
750 dprintk(1,"set_pll: MO_PLL_REG 0x%08x [old=0x%08x,freq=%d]\n", 769 dprintk(1, "set_pll: MO_PLL_REG 0x%08x [old=0x%08x,freq=%d]\n",
751 reg, cx_read(MO_PLL_REG), ofreq); 770 reg, cx_read(MO_PLL_REG), ofreq);
752 cx_write(MO_PLL_REG, reg); 771 cx_write(MO_PLL_REG, reg);
753 for (i = 0; i < 100; i++) { 772 for (i = 0; i < 100; i++) {
754 reg = cx_read(MO_DEVICE_STATUS); 773 reg = cx_read(MO_DEVICE_STATUS);
755 if (reg & (1<<2)) { 774 if (reg & (1 << 2)) {
756 dprintk(1,"pll locked [pre=%d,ofreq=%d]\n", 775 dprintk(1, "pll locked [pre=%d,ofreq=%d]\n",
757 prescale,ofreq); 776 prescale, ofreq);
758 return 0; 777 return 0;
759 } 778 }
760 dprintk(1,"pll not locked yet, waiting ...\n"); 779 dprintk(1, "pll not locked yet, waiting ...\n");
761 msleep(10); 780 usleep_range(10000, 20000);
762 } 781 }
763 dprintk(1,"pll NOT locked [pre=%d,ofreq=%d]\n",prescale,ofreq); 782 dprintk(1, "pll NOT locked [pre=%d,ofreq=%d]\n", prescale, ofreq);
764 return -1; 783 return -1;
765} 784}
766 785
767int cx88_start_audio_dma(struct cx88_core *core) 786int cx88_start_audio_dma(struct cx88_core *core)
768{ 787{
769 /* constant 128 made buzz in analog Nicam-stereo for bigger fifo_size */ 788 /* constant 128 made buzz in analog Nicam-stereo for bigger fifo_size */
770 int bpl = cx88_sram_channels[SRAM_CH25].fifo_size/4; 789 int bpl = cx88_sram_channels[SRAM_CH25].fifo_size / 4;
771 790
772 int rds_bpl = cx88_sram_channels[SRAM_CH27].fifo_size/AUD_RDS_LINES; 791 int rds_bpl = cx88_sram_channels[SRAM_CH27].fifo_size / AUD_RDS_LINES;
773 792
774 /* If downstream RISC is enabled, bail out; ALSA is managing DMA */ 793 /* If downstream RISC is enabled, bail out; ALSA is managing DMA */
775 if (cx_read(MO_AUD_DMACNTRL) & 0x10) 794 if (cx_read(MO_AUD_DMACNTRL) & 0x10)
@@ -806,8 +825,8 @@ static int set_tvaudio(struct cx88_core *core)
806{ 825{
807 v4l2_std_id norm = core->tvnorm; 826 v4l2_std_id norm = core->tvnorm;
808 827
809 if (CX88_VMUX_TELEVISION != INPUT(core->input).type && 828 if (INPUT(core->input).type != CX88_VMUX_TELEVISION &&
810 CX88_VMUX_CABLE != INPUT(core->input).type) 829 INPUT(core->input).type != CX88_VMUX_CABLE)
811 return 0; 830 return 0;
812 831
813 if (V4L2_STD_PAL_BG & norm) { 832 if (V4L2_STD_PAL_BG & norm) {
@@ -822,7 +841,8 @@ static int set_tvaudio(struct cx88_core *core)
822 } else if (V4L2_STD_SECAM_L & norm) { 841 } else if (V4L2_STD_SECAM_L & norm) {
823 core->tvaudio = WW_L; 842 core->tvaudio = WW_L;
824 843
825 } else if ((V4L2_STD_SECAM_B | V4L2_STD_SECAM_G | V4L2_STD_SECAM_H) & norm) { 844 } else if ((V4L2_STD_SECAM_B | V4L2_STD_SECAM_G | V4L2_STD_SECAM_H) &
845 norm) {
826 core->tvaudio = WW_BG; 846 core->tvaudio = WW_BG;
827 847
828 } else if (V4L2_STD_SECAM_DK & norm) { 848 } else if (V4L2_STD_SECAM_DK & norm) {
@@ -836,8 +856,8 @@ static int set_tvaudio(struct cx88_core *core)
836 core->tvaudio = WW_EIAJ; 856 core->tvaudio = WW_EIAJ;
837 857
838 } else { 858 } else {
839 printk("%s/0: tvaudio support needs work for this tv norm [%s], sorry\n", 859 pr_info("tvaudio support needs work for this tv norm [%s], sorry\n",
840 core->name, v4l2_norm_to_name(core->tvnorm)); 860 v4l2_norm_to_name(core->tvnorm));
841 core->tvaudio = WW_NONE; 861 core->tvaudio = WW_NONE;
842 return 0; 862 return 0;
843 } 863 }
@@ -847,23 +867,21 @@ static int set_tvaudio(struct cx88_core *core)
847 /* cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO); */ 867 /* cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO); */
848 868
849/* 869/*
850 This should be needed only on cx88-alsa. It seems that some cx88 chips have 870 * This should be needed only on cx88-alsa. It seems that some cx88 chips have
851 bugs and does require DMA enabled for it to work. 871 * bugs and does require DMA enabled for it to work.
852 */ 872 */
853 cx88_start_audio_dma(core); 873 cx88_start_audio_dma(core);
854 return 0; 874 return 0;
855} 875}
856 876
857
858
859int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm) 877int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm)
860{ 878{
861 u32 fsc8; 879 u32 fsc8;
862 u32 adc_clock; 880 u32 adc_clock;
863 u32 vdec_clock; 881 u32 vdec_clock;
864 u32 step_db,step_dr; 882 u32 step_db, step_dr;
865 u64 tmp64; 883 u64 tmp64;
866 u32 bdelay,agcdelay,htotal; 884 u32 bdelay, agcdelay, htotal;
867 u32 cxiformat, cxoformat; 885 u32 cxiformat, cxoformat;
868 886
869 if (norm == core->tvnorm) 887 if (norm == core->tvnorm)
@@ -912,62 +930,67 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm)
912 cxoformat = 0x181f0008; 930 cxoformat = 0x181f0008;
913 } 931 }
914 932
915 dprintk(1,"set_tvnorm: \"%s\" fsc8=%d adc=%d vdec=%d db/dr=%d/%d\n", 933 dprintk(1, "set_tvnorm: \"%s\" fsc8=%d adc=%d vdec=%d db/dr=%d/%d\n",
916 v4l2_norm_to_name(core->tvnorm), fsc8, adc_clock, vdec_clock, 934 v4l2_norm_to_name(core->tvnorm), fsc8, adc_clock, vdec_clock,
917 step_db, step_dr); 935 step_db, step_dr);
918 set_pll(core,2,vdec_clock); 936 set_pll(core, 2, vdec_clock);
919 937
920 dprintk(1,"set_tvnorm: MO_INPUT_FORMAT 0x%08x [old=0x%08x]\n", 938 dprintk(1, "set_tvnorm: MO_INPUT_FORMAT 0x%08x [old=0x%08x]\n",
921 cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f); 939 cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f);
922 /* Chroma AGC must be disabled if SECAM is used, we enable it 940 /*
923 by default on PAL and NTSC */ 941 * Chroma AGC must be disabled if SECAM is used, we enable it
942 * by default on PAL and NTSC
943 */
924 cx_andor(MO_INPUT_FORMAT, 0x40f, 944 cx_andor(MO_INPUT_FORMAT, 0x40f,
925 norm & V4L2_STD_SECAM ? cxiformat : cxiformat | 0x400); 945 norm & V4L2_STD_SECAM ? cxiformat : cxiformat | 0x400);
926 946
927 // FIXME: as-is from DScaler 947 // FIXME: as-is from DScaler
928 dprintk(1,"set_tvnorm: MO_OUTPUT_FORMAT 0x%08x [old=0x%08x]\n", 948 dprintk(1, "set_tvnorm: MO_OUTPUT_FORMAT 0x%08x [old=0x%08x]\n",
929 cxoformat, cx_read(MO_OUTPUT_FORMAT)); 949 cxoformat, cx_read(MO_OUTPUT_FORMAT));
930 cx_write(MO_OUTPUT_FORMAT, cxoformat); 950 cx_write(MO_OUTPUT_FORMAT, cxoformat);
931 951
932 // MO_SCONV_REG = adc clock / video dec clock * 2^17 952 // MO_SCONV_REG = adc clock / video dec clock * 2^17
933 tmp64 = adc_clock * (u64)(1 << 17); 953 tmp64 = adc_clock * (u64)(1 << 17);
934 do_div(tmp64, vdec_clock); 954 do_div(tmp64, vdec_clock);
935 dprintk(1,"set_tvnorm: MO_SCONV_REG 0x%08x [old=0x%08x]\n", 955 dprintk(1, "set_tvnorm: MO_SCONV_REG 0x%08x [old=0x%08x]\n",
936 (u32)tmp64, cx_read(MO_SCONV_REG)); 956 (u32)tmp64, cx_read(MO_SCONV_REG));
937 cx_write(MO_SCONV_REG, (u32)tmp64); 957 cx_write(MO_SCONV_REG, (u32)tmp64);
938 958
939 // MO_SUB_STEP = 8 * fsc / video dec clock * 2^22 959 // MO_SUB_STEP = 8 * fsc / video dec clock * 2^22
940 tmp64 = step_db * (u64)(1 << 22); 960 tmp64 = step_db * (u64)(1 << 22);
941 do_div(tmp64, vdec_clock); 961 do_div(tmp64, vdec_clock);
942 dprintk(1,"set_tvnorm: MO_SUB_STEP 0x%08x [old=0x%08x]\n", 962 dprintk(1, "set_tvnorm: MO_SUB_STEP 0x%08x [old=0x%08x]\n",
943 (u32)tmp64, cx_read(MO_SUB_STEP)); 963 (u32)tmp64, cx_read(MO_SUB_STEP));
944 cx_write(MO_SUB_STEP, (u32)tmp64); 964 cx_write(MO_SUB_STEP, (u32)tmp64);
945 965
946 // MO_SUB_STEP_DR = 8 * 4406250 / video dec clock * 2^22 966 // MO_SUB_STEP_DR = 8 * 4406250 / video dec clock * 2^22
947 tmp64 = step_dr * (u64)(1 << 22); 967 tmp64 = step_dr * (u64)(1 << 22);
948 do_div(tmp64, vdec_clock); 968 do_div(tmp64, vdec_clock);
949 dprintk(1,"set_tvnorm: MO_SUB_STEP_DR 0x%08x [old=0x%08x]\n", 969 dprintk(1, "set_tvnorm: MO_SUB_STEP_DR 0x%08x [old=0x%08x]\n",
950 (u32)tmp64, cx_read(MO_SUB_STEP_DR)); 970 (u32)tmp64, cx_read(MO_SUB_STEP_DR));
951 cx_write(MO_SUB_STEP_DR, (u32)tmp64); 971 cx_write(MO_SUB_STEP_DR, (u32)tmp64);
952 972
953 // bdelay + agcdelay 973 // bdelay + agcdelay
954 bdelay = vdec_clock * 65 / 20000000 + 21; 974 bdelay = vdec_clock * 65 / 20000000 + 21;
955 agcdelay = vdec_clock * 68 / 20000000 + 15; 975 agcdelay = vdec_clock * 68 / 20000000 + 15;
956 dprintk(1,"set_tvnorm: MO_AGC_BURST 0x%08x [old=0x%08x,bdelay=%d,agcdelay=%d]\n", 976 dprintk(1,
957 (bdelay << 8) | agcdelay, cx_read(MO_AGC_BURST), bdelay, agcdelay); 977 "set_tvnorm: MO_AGC_BURST 0x%08x [old=0x%08x,bdelay=%d,agcdelay=%d]\n",
978 (bdelay << 8) | agcdelay, cx_read(MO_AGC_BURST),
979 bdelay, agcdelay);
958 cx_write(MO_AGC_BURST, (bdelay << 8) | agcdelay); 980 cx_write(MO_AGC_BURST, (bdelay << 8) | agcdelay);
959 981
960 // htotal 982 // htotal
961 tmp64 = norm_htotal(norm) * (u64)vdec_clock; 983 tmp64 = norm_htotal(norm) * (u64)vdec_clock;
962 do_div(tmp64, fsc8); 984 do_div(tmp64, fsc8);
963 htotal = (u32)tmp64; 985 htotal = (u32)tmp64;
964 dprintk(1,"set_tvnorm: MO_HTOTAL 0x%08x [old=0x%08x,htotal=%d]\n", 986 dprintk(1,
987 "set_tvnorm: MO_HTOTAL 0x%08x [old=0x%08x,htotal=%d]\n",
965 htotal, cx_read(MO_HTOTAL), (u32)tmp64); 988 htotal, cx_read(MO_HTOTAL), (u32)tmp64);
966 cx_andor(MO_HTOTAL, 0x07ff, htotal); 989 cx_andor(MO_HTOTAL, 0x07ff, htotal);
967 990
968 // vbi stuff, set vbi offset to 10 (for 20 Clk*2 pixels), this makes 991 // vbi stuff, set vbi offset to 10 (for 20 Clk*2 pixels), this makes
969 // the effective vbi offset ~244 samples, the same as the Bt8x8 992 // the effective vbi offset ~244 samples, the same as the Bt8x8
970 cx_write(MO_VBI_PACKET, (10<<11) | norm_vbipack(norm)); 993 cx_write(MO_VBI_PACKET, (10 << 11) | norm_vbipack(norm));
971 994
972 // this is needed as well to set all tvnorm parameter 995 // this is needed as well to set all tvnorm parameter
973 cx88_set_scale(core, 320, 240, V4L2_FIELD_INTERLACED); 996 cx88_set_scale(core, 320, 240, V4L2_FIELD_INTERLACED);
@@ -978,12 +1001,16 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm)
978 // tell i2c chips 1001 // tell i2c chips
979 call_all(core, video, s_std, norm); 1002 call_all(core, video, s_std, norm);
980 1003
981 /* The chroma_agc control should be inaccessible if the video format is SECAM */ 1004 /*
1005 * The chroma_agc control should be inaccessible
1006 * if the video format is SECAM
1007 */
982 v4l2_ctrl_grab(core->chroma_agc, cxiformat == VideoFormatSECAM); 1008 v4l2_ctrl_grab(core->chroma_agc, cxiformat == VideoFormatSECAM);
983 1009
984 // done 1010 // done
985 return 0; 1011 return 0;
986} 1012}
1013EXPORT_SYMBOL(cx88_set_tvnorm);
987 1014
988/* ------------------------------------------------------------------ */ 1015/* ------------------------------------------------------------------ */
989 1016
@@ -1008,8 +1035,9 @@ void cx88_vdev_init(struct cx88_core *core,
1008 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", 1035 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
1009 core->name, type, core->board.name); 1036 core->name, type, core->board.name);
1010} 1037}
1038EXPORT_SYMBOL(cx88_vdev_init);
1011 1039
1012struct cx88_core* cx88_core_get(struct pci_dev *pci) 1040struct cx88_core *cx88_core_get(struct pci_dev *pci)
1013{ 1041{
1014 struct cx88_core *core; 1042 struct cx88_core *core;
1015 1043
@@ -1020,7 +1048,7 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
1020 if (PCI_SLOT(pci->devfn) != core->pci_slot) 1048 if (PCI_SLOT(pci->devfn) != core->pci_slot)
1021 continue; 1049 continue;
1022 1050
1023 if (0 != cx88_get_resources(core, pci)) { 1051 if (cx88_get_resources(core, pci) != 0) {
1024 mutex_unlock(&devlist); 1052 mutex_unlock(&devlist);
1025 return NULL; 1053 return NULL;
1026 } 1054 }
@@ -1030,7 +1058,7 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
1030 } 1058 }
1031 1059
1032 core = cx88_core_create(pci, cx88_devcount); 1060 core = cx88_core_create(pci, cx88_devcount);
1033 if (NULL != core) { 1061 if (core) {
1034 cx88_devcount++; 1062 cx88_devcount++;
1035 list_add_tail(&core->devlist, &cx88_devlist); 1063 list_add_tail(&core->devlist, &cx88_devlist);
1036 } 1064 }
@@ -1038,18 +1066,19 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
1038 mutex_unlock(&devlist); 1066 mutex_unlock(&devlist);
1039 return core; 1067 return core;
1040} 1068}
1069EXPORT_SYMBOL(cx88_core_get);
1041 1070
1042void cx88_core_put(struct cx88_core *core, struct pci_dev *pci) 1071void cx88_core_put(struct cx88_core *core, struct pci_dev *pci)
1043{ 1072{
1044 release_mem_region(pci_resource_start(pci,0), 1073 release_mem_region(pci_resource_start(pci, 0),
1045 pci_resource_len(pci,0)); 1074 pci_resource_len(pci, 0));
1046 1075
1047 if (!atomic_dec_and_test(&core->refcount)) 1076 if (!atomic_dec_and_test(&core->refcount))
1048 return; 1077 return;
1049 1078
1050 mutex_lock(&devlist); 1079 mutex_lock(&devlist);
1051 cx88_ir_fini(core); 1080 cx88_ir_fini(core);
1052 if (0 == core->i2c_rc) { 1081 if (core->i2c_rc == 0) {
1053 if (core->i2c_rtc) 1082 if (core->i2c_rtc)
1054 i2c_unregister_device(core->i2c_rtc); 1083 i2c_unregister_device(core->i2c_rtc);
1055 i2c_del_adapter(&core->i2c_adap); 1084 i2c_del_adapter(&core->i2c_adap);
@@ -1063,29 +1092,4 @@ void cx88_core_put(struct cx88_core *core, struct pci_dev *pci)
1063 v4l2_device_unregister(&core->v4l2_dev); 1092 v4l2_device_unregister(&core->v4l2_dev);
1064 kfree(core); 1093 kfree(core);
1065} 1094}
1066
1067/* ------------------------------------------------------------------ */
1068
1069EXPORT_SYMBOL(cx88_print_irqbits);
1070
1071EXPORT_SYMBOL(cx88_core_irq);
1072EXPORT_SYMBOL(cx88_wakeup);
1073EXPORT_SYMBOL(cx88_reset);
1074EXPORT_SYMBOL(cx88_shutdown);
1075
1076EXPORT_SYMBOL(cx88_risc_buffer);
1077EXPORT_SYMBOL(cx88_risc_databuffer);
1078
1079EXPORT_SYMBOL(cx88_sram_channels);
1080EXPORT_SYMBOL(cx88_sram_channel_setup);
1081EXPORT_SYMBOL(cx88_sram_channel_dump);
1082
1083EXPORT_SYMBOL(cx88_set_tvnorm);
1084EXPORT_SYMBOL(cx88_set_scale);
1085
1086EXPORT_SYMBOL(cx88_vdev_init);
1087EXPORT_SYMBOL(cx88_core_get);
1088EXPORT_SYMBOL(cx88_core_put); 1095EXPORT_SYMBOL(cx88_core_put);
1089
1090EXPORT_SYMBOL(cx88_ir_start);
1091EXPORT_SYMBOL(cx88_ir_stop);
diff --git a/drivers/media/pci/cx88/cx88-dsp.c b/drivers/media/pci/cx88/cx88-dsp.c
index a9907265ff66..105029088120 100644
--- a/drivers/media/pci/cx88/cx88-dsp.c
+++ b/drivers/media/pci/cx88/cx88-dsp.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Stereo and SAP detection for cx88 2 * Stereo and SAP detection for cx88
4 * 3 *
5 * Copyright (c) 2009 Marton Balint <cus@fazekas.hu> 4 * Copyright (c) 2009 Marton Balint <cus@fazekas.hu>
@@ -13,41 +12,41 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 14 * 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 */ 15 */
21 16
17#include "cx88.h"
18#include "cx88-reg.h"
19
22#include <linux/slab.h> 20#include <linux/slab.h>
23#include <linux/kernel.h> 21#include <linux/kernel.h>
24#include <linux/module.h> 22#include <linux/module.h>
25#include <linux/jiffies.h> 23#include <linux/jiffies.h>
26#include <asm/div64.h> 24#include <asm/div64.h>
27 25
28#include "cx88.h"
29#include "cx88-reg.h"
30
31#define INT_PI ((s32)(3.141592653589 * 32768.0)) 26#define INT_PI ((s32)(3.141592653589 * 32768.0))
32 27
33#define compat_remainder(a, b) \ 28#define compat_remainder(a, b) \
34 ((float)(((s32)((a)*100))%((s32)((b)*100)))/100.0) 29 ((float)(((s32)((a) * 100)) % ((s32)((b) * 100))) / 100.0)
35 30
36#define baseband_freq(carrier, srate, tone) ((s32)( \ 31#define baseband_freq(carrier, srate, tone) ((s32)( \
37 (compat_remainder(carrier + tone, srate)) / srate * 2 * INT_PI)) 32 (compat_remainder(carrier + tone, srate)) / srate * 2 * INT_PI))
38 33
39/* We calculate the baseband frequencies of the carrier and the pilot tones 34/*
40 * based on the the sampling rate of the audio rds fifo. */ 35 * We calculate the baseband frequencies of the carrier and the pilot tones
36 * based on the the sampling rate of the audio rds fifo.
37 */
41 38
42#define FREQ_A2_CARRIER baseband_freq(54687.5, 2689.36, 0.0) 39#define FREQ_A2_CARRIER baseband_freq(54687.5, 2689.36, 0.0)
43#define FREQ_A2_DUAL baseband_freq(54687.5, 2689.36, 274.1) 40#define FREQ_A2_DUAL baseband_freq(54687.5, 2689.36, 274.1)
44#define FREQ_A2_STEREO baseband_freq(54687.5, 2689.36, 117.5) 41#define FREQ_A2_STEREO baseband_freq(54687.5, 2689.36, 117.5)
45 42
46/* The frequencies below are from the reference driver. They probably need 43/*
44 * The frequencies below are from the reference driver. They probably need
47 * further adjustments, because they are not tested at all. You may even need 45 * further adjustments, because they are not tested at all. You may even need
48 * to play a bit with the registers of the chip to select the proper signal 46 * to play a bit with the registers of the chip to select the proper signal
49 * for the input of the audio rds fifo, and measure it's sampling rate to 47 * for the input of the audio rds fifo, and measure it's sampling rate to
50 * calculate the proper baseband frequencies... */ 48 * calculate the proper baseband frequencies...
49 */
51 50
52#define FREQ_A2M_CARRIER ((s32)(2.114516 * 32768.0)) 51#define FREQ_A2M_CARRIER ((s32)(2.114516 * 32768.0))
53#define FREQ_A2M_DUAL ((s32)(2.754916 * 32768.0)) 52#define FREQ_A2M_DUAL ((s32)(2.754916 * 32768.0))
@@ -71,43 +70,52 @@ static unsigned int dsp_debug;
71module_param(dsp_debug, int, 0644); 70module_param(dsp_debug, int, 0644);
72MODULE_PARM_DESC(dsp_debug, "enable audio dsp debug messages"); 71MODULE_PARM_DESC(dsp_debug, "enable audio dsp debug messages");
73 72
74#define dprintk(level, fmt, arg...) if (dsp_debug >= level) \ 73#define dprintk(level, fmt, arg...) do { \
75 printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg) 74 if (dsp_debug >= level) \
75 printk(KERN_DEBUG pr_fmt("%s: dsp:" fmt), \
76 __func__, ##arg); \
77} while (0)
76 78
77static s32 int_cos(u32 x) 79static s32 int_cos(u32 x)
78{ 80{
79 u32 t2, t4, t6, t8; 81 u32 t2, t4, t6, t8;
80 s32 ret; 82 s32 ret;
81 u16 period = x / INT_PI; 83 u16 period = x / INT_PI;
84
82 if (period % 2) 85 if (period % 2)
83 return -int_cos(x - INT_PI); 86 return -int_cos(x - INT_PI);
84 x = x % INT_PI; 87 x = x % INT_PI;
85 if (x > INT_PI/2) 88 if (x > INT_PI / 2)
86 return -int_cos(INT_PI/2 - (x % (INT_PI/2))); 89 return -int_cos(INT_PI / 2 - (x % (INT_PI / 2)));
87 /* Now x is between 0 and INT_PI/2. 90 /*
88 * To calculate cos(x) we use it's Taylor polinom. */ 91 * Now x is between 0 and INT_PI/2.
89 t2 = x*x/32768/2; 92 * To calculate cos(x) we use it's Taylor polinom.
90 t4 = t2*x/32768*x/32768/3/4; 93 */
91 t6 = t4*x/32768*x/32768/5/6; 94 t2 = x * x / 32768 / 2;
92 t8 = t6*x/32768*x/32768/7/8; 95 t4 = t2 * x / 32768 * x / 32768 / 3 / 4;
93 ret = 32768-t2+t4-t6+t8; 96 t6 = t4 * x / 32768 * x / 32768 / 5 / 6;
97 t8 = t6 * x / 32768 * x / 32768 / 7 / 8;
98 ret = 32768 - t2 + t4 - t6 + t8;
94 return ret; 99 return ret;
95} 100}
96 101
97static u32 int_goertzel(s16 x[], u32 N, u32 freq) 102static u32 int_goertzel(s16 x[], u32 N, u32 freq)
98{ 103{
99 /* We use the Goertzel algorithm to determine the power of the 104 /*
100 * given frequency in the signal */ 105 * We use the Goertzel algorithm to determine the power of the
106 * given frequency in the signal
107 */
101 s32 s_prev = 0; 108 s32 s_prev = 0;
102 s32 s_prev2 = 0; 109 s32 s_prev2 = 0;
103 s32 coeff = 2*int_cos(freq); 110 s32 coeff = 2 * int_cos(freq);
104 u32 i; 111 u32 i;
105 112
106 u64 tmp; 113 u64 tmp;
107 u32 divisor; 114 u32 divisor;
108 115
109 for (i = 0; i < N; i++) { 116 for (i = 0; i < N; i++) {
110 s32 s = x[i] + ((s64)coeff*s_prev/32768) - s_prev2; 117 s32 s = x[i] + ((s64)coeff * s_prev / 32768) - s_prev2;
118
111 s_prev2 = s_prev; 119 s_prev2 = s_prev;
112 s_prev = s; 120 s_prev = s;
113 } 121 }
@@ -115,17 +123,20 @@ static u32 int_goertzel(s16 x[], u32 N, u32 freq)
115 tmp = (s64)s_prev2 * s_prev2 + (s64)s_prev * s_prev - 123 tmp = (s64)s_prev2 * s_prev2 + (s64)s_prev * s_prev -
116 (s64)coeff * s_prev2 * s_prev / 32768; 124 (s64)coeff * s_prev2 * s_prev / 32768;
117 125
118 /* XXX: N must be low enough so that N*N fits in s32. 126 /*
119 * Else we need two divisions. */ 127 * XXX: N must be low enough so that N*N fits in s32.
128 * Else we need two divisions.
129 */
120 divisor = N * N; 130 divisor = N * N;
121 do_div(tmp, divisor); 131 do_div(tmp, divisor);
122 132
123 return (u32) tmp; 133 return (u32)tmp;
124} 134}
125 135
126static u32 freq_magnitude(s16 x[], u32 N, u32 freq) 136static u32 freq_magnitude(s16 x[], u32 N, u32 freq)
127{ 137{
128 u32 sum = int_goertzel(x, N, freq); 138 u32 sum = int_goertzel(x, N, freq);
139
129 return (u32)int_sqrt(sum); 140 return (u32)int_sqrt(sum);
130} 141}
131 142
@@ -138,7 +149,7 @@ static u32 noise_magnitude(s16 x[], u32 N, u32 freq_start, u32 freq_end)
138 149
139 if (N > 192) { 150 if (N > 192) {
140 /* The last 192 samples are enough for noise detection */ 151 /* The last 192 samples are enough for noise detection */
141 x += (N-192); 152 x += (N - 192);
142 N = 192; 153 N = 192;
143 } 154 }
144 155
@@ -176,8 +187,8 @@ static s32 detect_a2_a2m_eiaj(struct cx88_core *core, s16 x[], u32 N)
176 dual_freq = FREQ_EIAJ_DUAL; 187 dual_freq = FREQ_EIAJ_DUAL;
177 break; 188 break;
178 default: 189 default:
179 printk(KERN_WARNING "%s/0: unsupported audio mode %d for %s\n", 190 pr_warn("unsupported audio mode %d for %s\n",
180 core->name, core->tvaudio, __func__); 191 core->tvaudio, __func__);
181 return UNSET; 192 return UNSET;
182 } 193 }
183 194
@@ -186,8 +197,9 @@ static s32 detect_a2_a2m_eiaj(struct cx88_core *core, s16 x[], u32 N)
186 dual = freq_magnitude(x, N, dual_freq); 197 dual = freq_magnitude(x, N, dual_freq);
187 noise = noise_magnitude(x, N, FREQ_NOISE_START, FREQ_NOISE_END); 198 noise = noise_magnitude(x, N, FREQ_NOISE_START, FREQ_NOISE_END);
188 199
189 dprintk(1, "detect a2/a2m/eiaj: carrier=%d, stereo=%d, dual=%d, " 200 dprintk(1,
190 "noise=%d\n", carrier, stereo, dual, noise); 201 "detect a2/a2m/eiaj: carrier=%d, stereo=%d, dual=%d, noise=%d\n",
202 carrier, stereo, dual, noise);
191 203
192 if (stereo > dual) 204 if (stereo > dual)
193 ret = V4L2_TUNER_SUB_STEREO; 205 ret = V4L2_TUNER_SUB_STEREO;
@@ -196,20 +208,22 @@ static s32 detect_a2_a2m_eiaj(struct cx88_core *core, s16 x[], u32 N)
196 208
197 if (core->tvaudio == WW_EIAJ) { 209 if (core->tvaudio == WW_EIAJ) {
198 /* EIAJ checks may need adjustments */ 210 /* EIAJ checks may need adjustments */
199 if ((carrier > max(stereo, dual)*2) && 211 if ((carrier > max(stereo, dual) * 2) &&
200 (carrier < max(stereo, dual)*6) && 212 (carrier < max(stereo, dual) * 6) &&
201 (carrier > 20 && carrier < 200) && 213 (carrier > 20 && carrier < 200) &&
202 (max(stereo, dual) > min(stereo, dual))) { 214 (max(stereo, dual) > min(stereo, dual))) {
203 /* For EIAJ the carrier is always present, 215 /*
204 so we probably don't need noise detection */ 216 * For EIAJ the carrier is always present,
217 * so we probably don't need noise detection
218 */
205 return ret; 219 return ret;
206 } 220 }
207 } else { 221 } else {
208 if ((carrier > max(stereo, dual)*2) && 222 if ((carrier > max(stereo, dual) * 2) &&
209 (carrier < max(stereo, dual)*8) && 223 (carrier < max(stereo, dual) * 8) &&
210 (carrier > 20 && carrier < 200) && 224 (carrier > 20 && carrier < 200) &&
211 (noise < 10) && 225 (noise < 10) &&
212 (max(stereo, dual) > min(stereo, dual)*2)) { 226 (max(stereo, dual) > min(stereo, dual) * 2)) {
213 return ret; 227 return ret;
214 } 228 }
215 } 229 }
@@ -222,8 +236,9 @@ static s32 detect_btsc(struct cx88_core *core, s16 x[], u32 N)
222 s32 sap = freq_magnitude(x, N, FREQ_BTSC_SAP); 236 s32 sap = freq_magnitude(x, N, FREQ_BTSC_SAP);
223 s32 dual_ref = freq_magnitude(x, N, FREQ_BTSC_DUAL_REF); 237 s32 dual_ref = freq_magnitude(x, N, FREQ_BTSC_DUAL_REF);
224 s32 dual = freq_magnitude(x, N, FREQ_BTSC_DUAL); 238 s32 dual = freq_magnitude(x, N, FREQ_BTSC_DUAL);
225 dprintk(1, "detect btsc: dual_ref=%d, dual=%d, sap_ref=%d, sap=%d" 239
226 "\n", dual_ref, dual, sap_ref, sap); 240 dprintk(1, "detect btsc: dual_ref=%d, dual=%d, sap_ref=%d, sap=%d\n",
241 dual_ref, dual, sap_ref, sap);
227 /* FIXME: Currently not supported */ 242 /* FIXME: Currently not supported */
228 return UNSET; 243 return UNSET;
229} 244}
@@ -234,36 +249,31 @@ static s16 *read_rds_samples(struct cx88_core *core, u32 *N)
234 s16 *samples; 249 s16 *samples;
235 250
236 unsigned int i; 251 unsigned int i;
237 unsigned int bpl = srch->fifo_size/AUD_RDS_LINES; 252 unsigned int bpl = srch->fifo_size / AUD_RDS_LINES;
238 unsigned int spl = bpl/4; 253 unsigned int spl = bpl / 4;
239 unsigned int sample_count = spl*(AUD_RDS_LINES-1); 254 unsigned int sample_count = spl * (AUD_RDS_LINES - 1);
240 255
241 u32 current_address = cx_read(srch->ptr1_reg); 256 u32 current_address = cx_read(srch->ptr1_reg);
242 u32 offset = (current_address - srch->fifo_start + bpl); 257 u32 offset = (current_address - srch->fifo_start + bpl);
243 258
244 dprintk(1, "read RDS samples: current_address=%08x (offset=%08x), " 259 dprintk(1,
245 "sample_count=%d, aud_intstat=%08x\n", current_address, 260 "read RDS samples: current_address=%08x (offset=%08x), sample_count=%d, aud_intstat=%08x\n",
261 current_address,
246 current_address - srch->fifo_start, sample_count, 262 current_address - srch->fifo_start, sample_count,
247 cx_read(MO_AUD_INTSTAT)); 263 cx_read(MO_AUD_INTSTAT));
248 264 samples = kmalloc_array(sample_count, sizeof(*samples), GFP_KERNEL);
249 samples = kmalloc(sizeof(s16)*sample_count, GFP_KERNEL);
250 if (!samples) 265 if (!samples)
251 return NULL; 266 return NULL;
252 267
253 *N = sample_count; 268 *N = sample_count;
254 269
255 for (i = 0; i < sample_count; i++) { 270 for (i = 0; i < sample_count; i++) {
256 offset = offset % (AUD_RDS_LINES*bpl); 271 offset = offset % (AUD_RDS_LINES * bpl);
257 samples[i] = cx_read(srch->fifo_start + offset); 272 samples[i] = cx_read(srch->fifo_start + offset);
258 offset += 4; 273 offset += 4;
259 } 274 }
260 275
261 if (dsp_debug >= 2) { 276 dprintk(2, "RDS samples dump: %*ph\n", sample_count, samples);
262 dprintk(2, "RDS samples dump: ");
263 for (i = 0; i < sample_count; i++)
264 printk("%hd ", samples[i]);
265 printk(".\n");
266 }
267 277
268 return samples; 278 return samples;
269} 279}
@@ -310,11 +320,11 @@ s32 cx88_dsp_detect_stereo_sap(struct cx88_core *core)
310 320
311 kfree(samples); 321 kfree(samples);
312 322
313 if (UNSET != ret) 323 if (ret != UNSET)
314 dprintk(1, "stereo/sap detection result:%s%s%s\n", 324 dprintk(1, "stereo/sap detection result:%s%s%s\n",
315 (ret & V4L2_TUNER_SUB_MONO) ? " mono" : "", 325 (ret & V4L2_TUNER_SUB_MONO) ? " mono" : "",
316 (ret & V4L2_TUNER_SUB_STEREO) ? " stereo" : "", 326 (ret & V4L2_TUNER_SUB_STEREO) ? " stereo" : "",
317 (ret & V4L2_TUNER_SUB_LANG2) ? " dual" : ""); 327 (ret & V4L2_TUNER_SUB_LANG2) ? " dual" : "");
318 328
319 return ret; 329 return ret;
320} 330}
diff --git a/drivers/media/pci/cx88/cx88-dvb.c b/drivers/media/pci/cx88/cx88-dvb.c
index ac2392d8887a..ddf90678df34 100644
--- a/drivers/media/pci/cx88/cx88-dvb.c
+++ b/drivers/media/pci/cx88/cx88-dvb.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * device driver for Conexant 2388x based TV cards 2 * device driver for Conexant 2388x based TV cards
4 * MPEG Transport Stream (DVB) routines 3 * MPEG Transport Stream (DVB) routines
5 * 4 *
@@ -15,12 +14,11 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 16 * 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 */ 17 */
23 18
19#include "cx88.h"
20#include "dvb-pll.h"
21
24#include <linux/module.h> 22#include <linux/module.h>
25#include <linux/init.h> 23#include <linux/init.h>
26#include <linux/device.h> 24#include <linux/device.h>
@@ -29,8 +27,6 @@
29#include <linux/file.h> 27#include <linux/file.h>
30#include <linux/suspend.h> 28#include <linux/suspend.h>
31 29
32#include "cx88.h"
33#include "dvb-pll.h"
34#include <media/v4l2-common.h> 30#include <media/v4l2-common.h>
35 31
36#include "mt352.h" 32#include "mt352.h"
@@ -69,7 +65,7 @@ MODULE_VERSION(CX88_VERSION);
69 65
70static unsigned int debug; 66static unsigned int debug;
71module_param(debug, int, 0644); 67module_param(debug, int, 0644);
72MODULE_PARM_DESC(debug,"enable debug messages [dvb]"); 68MODULE_PARM_DESC(debug, "enable debug messages [dvb]");
73 69
74static unsigned int dvb_buf_tscnt = 32; 70static unsigned int dvb_buf_tscnt = 32;
75module_param(dvb_buf_tscnt, int, 0644); 71module_param(dvb_buf_tscnt, int, 0644);
@@ -77,14 +73,17 @@ MODULE_PARM_DESC(dvb_buf_tscnt, "DVB Buffer TS count [dvb]");
77 73
78DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 74DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
79 75
80#define dprintk(level,fmt, arg...) if (debug >= level) \ 76#define dprintk(level, fmt, arg...) do { \
81 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg) 77 if (debug >= level) \
78 printk(KERN_DEBUG pr_fmt("%s: dvb:" fmt), \
79 __func__, ##arg); \
80} while (0)
82 81
83/* ------------------------------------------------------------------ */ 82/* ------------------------------------------------------------------ */
84 83
85static int queue_setup(struct vb2_queue *q, 84static int queue_setup(struct vb2_queue *q,
86 unsigned int *num_buffers, unsigned int *num_planes, 85 unsigned int *num_buffers, unsigned int *num_planes,
87 unsigned int sizes[], struct device *alloc_devs[]) 86 unsigned int sizes[], struct device *alloc_devs[])
88{ 87{
89 struct cx8802_dev *dev = q->drv_priv; 88 struct cx8802_dev *dev = q->drv_priv;
90 89
@@ -169,23 +168,23 @@ static const struct vb2_ops dvb_qops = {
169 168
170/* ------------------------------------------------------------------ */ 169/* ------------------------------------------------------------------ */
171 170
172static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire) 171static int cx88_dvb_bus_ctrl(struct dvb_frontend *fe, int acquire)
173{ 172{
174 struct cx8802_dev *dev= fe->dvb->priv; 173 struct cx8802_dev *dev = fe->dvb->priv;
175 struct cx8802_driver *drv = NULL; 174 struct cx8802_driver *drv = NULL;
176 int ret = 0; 175 int ret = 0;
177 int fe_id; 176 int fe_id;
178 177
179 fe_id = vb2_dvb_find_frontend(&dev->frontends, fe); 178 fe_id = vb2_dvb_find_frontend(&dev->frontends, fe);
180 if (!fe_id) { 179 if (!fe_id) {
181 printk(KERN_ERR "%s() No frontend found\n", __func__); 180 pr_err("%s() No frontend found\n", __func__);
182 return -EINVAL; 181 return -EINVAL;
183 } 182 }
184 183
185 mutex_lock(&dev->core->lock); 184 mutex_lock(&dev->core->lock);
186 drv = cx8802_get_driver(dev, CX88_MPEG_DVB); 185 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
187 if (drv) { 186 if (drv) {
188 if (acquire){ 187 if (acquire) {
189 dev->frontends.active_fe_id = fe_id; 188 dev->frontends.active_fe_id = fe_id;
190 ret = drv->request_acquire(drv); 189 ret = drv->request_acquire(drv);
191 } else { 190 } else {
@@ -222,13 +221,13 @@ static void cx88_dvb_gate_ctrl(struct cx88_core *core, int open)
222 221
223/* ------------------------------------------------------------------ */ 222/* ------------------------------------------------------------------ */
224 223
225static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe) 224static int dvico_fusionhdtv_demod_init(struct dvb_frontend *fe)
226{ 225{
227 static const u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 }; 226 static const u8 clock_config[] = { CLOCK_CTL, 0x38, 0x39 };
228 static const u8 reset [] = { RESET, 0x80 }; 227 static const u8 reset[] = { RESET, 0x80 };
229 static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; 228 static const u8 adc_ctl_1_cfg[] = { ADC_CTL_1, 0x40 };
230 static const u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 }; 229 static const u8 agc_cfg[] = { AGC_TARGET, 0x24, 0x20 };
231 static const u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 }; 230 static const u8 gpp_ctl_cfg[] = { GPP_CTL, 0x33 };
232 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 }; 231 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
233 232
234 mt352_write(fe, clock_config, sizeof(clock_config)); 233 mt352_write(fe, clock_config, sizeof(clock_config));
@@ -244,11 +243,11 @@ static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
244 243
245static int dvico_dual_demod_init(struct dvb_frontend *fe) 244static int dvico_dual_demod_init(struct dvb_frontend *fe)
246{ 245{
247 static const u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 }; 246 static const u8 clock_config[] = { CLOCK_CTL, 0x38, 0x38 };
248 static const u8 reset [] = { RESET, 0x80 }; 247 static const u8 reset[] = { RESET, 0x80 };
249 static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; 248 static const u8 adc_ctl_1_cfg[] = { ADC_CTL_1, 0x40 };
250 static const u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 }; 249 static const u8 agc_cfg[] = { AGC_TARGET, 0x28, 0x20 };
251 static const u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 }; 250 static const u8 gpp_ctl_cfg[] = { GPP_CTL, 0x33 };
252 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 }; 251 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
253 252
254 mt352_write(fe, clock_config, sizeof(clock_config)); 253 mt352_write(fe, clock_config, sizeof(clock_config));
@@ -263,12 +262,12 @@ static int dvico_dual_demod_init(struct dvb_frontend *fe)
263 return 0; 262 return 0;
264} 263}
265 264
266static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe) 265static int dntv_live_dvbt_demod_init(struct dvb_frontend *fe)
267{ 266{
268 static const u8 clock_config [] = { 0x89, 0x38, 0x39 }; 267 static const u8 clock_config[] = { 0x89, 0x38, 0x39 };
269 static const u8 reset [] = { 0x50, 0x80 }; 268 static const u8 reset[] = { 0x50, 0x80 };
270 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 }; 269 static const u8 adc_ctl_1_cfg[] = { 0x8E, 0x40 };
271 static const u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF, 270 static const u8 agc_cfg[] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
272 0x00, 0xFF, 0x00, 0x40, 0x40 }; 271 0x00, 0xFF, 0x00, 0x40, 0x40 };
273 static const u8 dntv_extra[] = { 0xB5, 0x7A }; 272 static const u8 dntv_extra[] = { 0xB5, 0x7A };
274 static const u8 capt_range_cfg[] = { 0x75, 0x32 }; 273 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
@@ -312,12 +311,12 @@ static struct mb86a16_config twinhan_vp1027 = {
312}; 311};
313 312
314#if IS_ENABLED(CONFIG_VIDEO_CX88_VP3054) 313#if IS_ENABLED(CONFIG_VIDEO_CX88_VP3054)
315static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe) 314static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend *fe)
316{ 315{
317 static const u8 clock_config [] = { 0x89, 0x38, 0x38 }; 316 static const u8 clock_config[] = { 0x89, 0x38, 0x38 };
318 static const u8 reset [] = { 0x50, 0x80 }; 317 static const u8 reset[] = { 0x50, 0x80 };
319 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 }; 318 static const u8 adc_ctl_1_cfg[] = { 0x8E, 0x40 };
320 static const u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF, 319 static const u8 agc_cfg[] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
321 0x00, 0xFF, 0x00, 0x40, 0x40 }; 320 0x00, 0xFF, 0x00, 0x40, 0x40 };
322 static const u8 dntv_extra[] = { 0xB5, 0x7A }; 321 static const u8 dntv_extra[] = { 0xB5, 0x7A };
323 static const u8 capt_range_cfg[] = { 0x75, 0x32 }; 322 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
@@ -374,9 +373,10 @@ static const struct cx22702_config hauppauge_hvr_config = {
374 .output_mode = CX22702_SERIAL_OUTPUT, 373 .output_mode = CX22702_SERIAL_OUTPUT,
375}; 374};
376 375
377static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured) 376static int or51132_set_ts_param(struct dvb_frontend *fe, int is_punctured)
378{ 377{
379 struct cx8802_dev *dev= fe->dvb->priv; 378 struct cx8802_dev *dev = fe->dvb->priv;
379
380 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00; 380 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
381 return 0; 381 return 0;
382} 382}
@@ -386,9 +386,9 @@ static const struct or51132_config pchdtv_hd3000 = {
386 .set_ts_params = or51132_set_ts_param, 386 .set_ts_params = or51132_set_ts_param,
387}; 387};
388 388
389static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index) 389static int lgdt330x_pll_rf_set(struct dvb_frontend *fe, int index)
390{ 390{
391 struct cx8802_dev *dev= fe->dvb->priv; 391 struct cx8802_dev *dev = fe->dvb->priv;
392 struct cx88_core *core = dev->core; 392 struct cx88_core *core = dev->core;
393 393
394 dprintk(1, "%s: index = %d\n", __func__, index); 394 dprintk(1, "%s: index = %d\n", __func__, index);
@@ -399,9 +399,10 @@ static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
399 return 0; 399 return 0;
400} 400}
401 401
402static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured) 402static int lgdt330x_set_ts_param(struct dvb_frontend *fe, int is_punctured)
403{ 403{
404 struct cx8802_dev *dev= fe->dvb->priv; 404 struct cx8802_dev *dev = fe->dvb->priv;
405
405 if (is_punctured) 406 if (is_punctured)
406 dev->ts_gen_cntrl |= 0x04; 407 dev->ts_gen_cntrl |= 0x04;
407 else 408 else
@@ -430,9 +431,10 @@ static const struct lgdt330x_config pchdtv_hd5500 = {
430 .set_ts_params = lgdt330x_set_ts_param, 431 .set_ts_params = lgdt330x_set_ts_param,
431}; 432};
432 433
433static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured) 434static int nxt200x_set_ts_param(struct dvb_frontend *fe, int is_punctured)
434{ 435{
435 struct cx8802_dev *dev= fe->dvb->priv; 436 struct cx8802_dev *dev = fe->dvb->priv;
437
436 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00; 438 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
437 return 0; 439 return 0;
438} 440}
@@ -442,18 +444,19 @@ static const struct nxt200x_config ati_hdtvwonder = {
442 .set_ts_params = nxt200x_set_ts_param, 444 .set_ts_params = nxt200x_set_ts_param,
443}; 445};
444 446
445static int cx24123_set_ts_param(struct dvb_frontend* fe, 447static int cx24123_set_ts_param(struct dvb_frontend *fe,
446 int is_punctured) 448 int is_punctured)
447{ 449{
448 struct cx8802_dev *dev= fe->dvb->priv; 450 struct cx8802_dev *dev = fe->dvb->priv;
451
449 dev->ts_gen_cntrl = 0x02; 452 dev->ts_gen_cntrl = 0x02;
450 return 0; 453 return 0;
451} 454}
452 455
453static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe, 456static int kworld_dvbs_100_set_voltage(struct dvb_frontend *fe,
454 enum fe_sec_voltage voltage) 457 enum fe_sec_voltage voltage)
455{ 458{
456 struct cx8802_dev *dev= fe->dvb->priv; 459 struct cx8802_dev *dev = fe->dvb->priv;
457 struct cx88_core *core = dev->core; 460 struct cx88_core *core = dev->core;
458 461
459 if (voltage == SEC_VOLTAGE_OFF) 462 if (voltage == SEC_VOLTAGE_OFF)
@@ -469,11 +472,11 @@ static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
469static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe, 472static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
470 enum fe_sec_voltage voltage) 473 enum fe_sec_voltage voltage)
471{ 474{
472 struct cx8802_dev *dev= fe->dvb->priv; 475 struct cx8802_dev *dev = fe->dvb->priv;
473 struct cx88_core *core = dev->core; 476 struct cx88_core *core = dev->core;
474 477
475 if (voltage == SEC_VOLTAGE_OFF) { 478 if (voltage == SEC_VOLTAGE_OFF) {
476 dprintk(1,"LNB Voltage OFF\n"); 479 dprintk(1, "LNB Voltage OFF\n");
477 cx_write(MO_GP0_IO, 0x0000efff); 480 cx_write(MO_GP0_IO, 0x0000efff);
478 } 481 }
479 482
@@ -485,7 +488,7 @@ static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
485static int tevii_dvbs_set_voltage(struct dvb_frontend *fe, 488static int tevii_dvbs_set_voltage(struct dvb_frontend *fe,
486 enum fe_sec_voltage voltage) 489 enum fe_sec_voltage voltage)
487{ 490{
488 struct cx8802_dev *dev= fe->dvb->priv; 491 struct cx8802_dev *dev = fe->dvb->priv;
489 struct cx88_core *core = dev->core; 492 struct cx88_core *core = dev->core;
490 493
491 cx_set(MO_GP0_IO, 0x6040); 494 cx_set(MO_GP0_IO, 0x6040);
@@ -625,9 +628,7 @@ static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
625 return -EINVAL; 628 return -EINVAL;
626 629
627 if (!fe0->dvb.frontend) { 630 if (!fe0->dvb.frontend) {
628 printk(KERN_ERR "%s/2: dvb frontend not attached. " 631 pr_err("dvb frontend not attached. Can't attach xc3028\n");
629 "Can't attach xc3028\n",
630 dev->core->name);
631 return -EINVAL; 632 return -EINVAL;
632 } 633 }
633 634
@@ -640,16 +641,14 @@ static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
640 641
641 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg); 642 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
642 if (!fe) { 643 if (!fe) {
643 printk(KERN_ERR "%s/2: xc3028 attach failed\n", 644 pr_err("xc3028 attach failed\n");
644 dev->core->name);
645 dvb_frontend_detach(fe0->dvb.frontend); 645 dvb_frontend_detach(fe0->dvb.frontend);
646 dvb_unregister_frontend(fe0->dvb.frontend); 646 dvb_unregister_frontend(fe0->dvb.frontend);
647 fe0->dvb.frontend = NULL; 647 fe0->dvb.frontend = NULL;
648 return -EINVAL; 648 return -EINVAL;
649 } 649 }
650 650
651 printk(KERN_INFO "%s/2: xc3028 attached\n", 651 pr_info("xc3028 attached\n");
652 dev->core->name);
653 652
654 return 0; 653 return 0;
655} 654}
@@ -665,41 +664,40 @@ static int attach_xc4000(struct cx8802_dev *dev, struct xc4000_config *cfg)
665 return -EINVAL; 664 return -EINVAL;
666 665
667 if (!fe0->dvb.frontend) { 666 if (!fe0->dvb.frontend) {
668 printk(KERN_ERR "%s/2: dvb frontend not attached. " 667 pr_err("dvb frontend not attached. Can't attach xc4000\n");
669 "Can't attach xc4000\n",
670 dev->core->name);
671 return -EINVAL; 668 return -EINVAL;
672 } 669 }
673 670
674 fe = dvb_attach(xc4000_attach, fe0->dvb.frontend, &dev->core->i2c_adap, 671 fe = dvb_attach(xc4000_attach, fe0->dvb.frontend, &dev->core->i2c_adap,
675 cfg); 672 cfg);
676 if (!fe) { 673 if (!fe) {
677 printk(KERN_ERR "%s/2: xc4000 attach failed\n", 674 pr_err("xc4000 attach failed\n");
678 dev->core->name);
679 dvb_frontend_detach(fe0->dvb.frontend); 675 dvb_frontend_detach(fe0->dvb.frontend);
680 dvb_unregister_frontend(fe0->dvb.frontend); 676 dvb_unregister_frontend(fe0->dvb.frontend);
681 fe0->dvb.frontend = NULL; 677 fe0->dvb.frontend = NULL;
682 return -EINVAL; 678 return -EINVAL;
683 } 679 }
684 680
685 printk(KERN_INFO "%s/2: xc4000 attached\n", dev->core->name); 681 pr_info("xc4000 attached\n");
686 682
687 return 0; 683 return 0;
688} 684}
689 685
690static int cx24116_set_ts_param(struct dvb_frontend *fe, 686static int cx24116_set_ts_param(struct dvb_frontend *fe,
691 int is_punctured) 687 int is_punctured)
692{ 688{
693 struct cx8802_dev *dev = fe->dvb->priv; 689 struct cx8802_dev *dev = fe->dvb->priv;
690
694 dev->ts_gen_cntrl = 0x2; 691 dev->ts_gen_cntrl = 0x2;
695 692
696 return 0; 693 return 0;
697} 694}
698 695
699static int stv0900_set_ts_param(struct dvb_frontend *fe, 696static int stv0900_set_ts_param(struct dvb_frontend *fe,
700 int is_punctured) 697 int is_punctured)
701{ 698{
702 struct cx8802_dev *dev = fe->dvb->priv; 699 struct cx8802_dev *dev = fe->dvb->priv;
700
703 dev->ts_gen_cntrl = 0; 701 dev->ts_gen_cntrl = 0;
704 702
705 return 0; 703 return 0;
@@ -713,10 +711,10 @@ static int cx24116_reset_device(struct dvb_frontend *fe)
713 /* Reset the part */ 711 /* Reset the part */
714 /* Put the cx24116 into reset */ 712 /* Put the cx24116 into reset */
715 cx_write(MO_SRST_IO, 0); 713 cx_write(MO_SRST_IO, 0);
716 msleep(10); 714 usleep_range(10000, 20000);
717 /* Take the cx24116 out of reset */ 715 /* Take the cx24116 out of reset */
718 cx_write(MO_SRST_IO, 1); 716 cx_write(MO_SRST_IO, 1);
719 msleep(10); 717 usleep_range(10000, 20000);
720 718
721 return 0; 719 return 0;
722} 720}
@@ -734,9 +732,10 @@ static const struct cx24116_config tevii_s460_config = {
734}; 732};
735 733
736static int ds3000_set_ts_param(struct dvb_frontend *fe, 734static int ds3000_set_ts_param(struct dvb_frontend *fe,
737 int is_punctured) 735 int is_punctured)
738{ 736{
739 struct cx8802_dev *dev = fe->dvb->priv; 737 struct cx8802_dev *dev = fe->dvb->priv;
738
740 dev->ts_gen_cntrl = 4; 739 dev->ts_gen_cntrl = 4;
741 740
742 return 0; 741 return 0;
@@ -800,12 +799,12 @@ static int cx8802_alloc_frontends(struct cx8802_dev *dev)
800 if (!core->board.num_frontends) 799 if (!core->board.num_frontends)
801 return -ENODEV; 800 return -ENODEV;
802 801
803 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__, 802 pr_info("%s: allocating %d frontend(s)\n", __func__,
804 core->board.num_frontends); 803 core->board.num_frontends);
805 for (i = 1; i <= core->board.num_frontends; i++) { 804 for (i = 1; i <= core->board.num_frontends; i++) {
806 fe = vb2_dvb_alloc_frontend(&dev->frontends, i); 805 fe = vb2_dvb_alloc_frontend(&dev->frontends, i);
807 if (!fe) { 806 if (!fe) {
808 printk(KERN_ERR "%s() failed to alloc\n", __func__); 807 pr_err("%s() failed to alloc\n", __func__);
809 vb2_dvb_dealloc_frontends(&dev->frontends); 808 vb2_dvb_dealloc_frontends(&dev->frontends);
810 return -ENOMEM; 809 return -ENOMEM;
811 } 810 }
@@ -813,8 +812,6 @@ static int cx8802_alloc_frontends(struct cx8802_dev *dev)
813 return 0; 812 return 0;
814} 813}
815 814
816
817
818static const u8 samsung_smt_7020_inittab[] = { 815static const u8 samsung_smt_7020_inittab[] = {
819 0x01, 0x15, 816 0x01, 0x15,
820 0x02, 0x00, 817 0x02, 0x00,
@@ -866,7 +863,6 @@ static const u8 samsung_smt_7020_inittab[] = {
866 0xff, 0xff, 863 0xff, 0xff,
867}; 864};
868 865
869
870static int samsung_smt_7020_tuner_set_params(struct dvb_frontend *fe) 866static int samsung_smt_7020_tuner_set_params(struct dvb_frontend *fe)
871{ 867{
872 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 868 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
@@ -899,7 +895,7 @@ static int samsung_smt_7020_tuner_set_params(struct dvb_frontend *fe)
899} 895}
900 896
901static int samsung_smt_7020_set_tone(struct dvb_frontend *fe, 897static int samsung_smt_7020_set_tone(struct dvb_frontend *fe,
902 enum fe_sec_tone_mode tone) 898 enum fe_sec_tone_mode tone)
903{ 899{
904 struct cx8802_dev *dev = fe->dvb->priv; 900 struct cx8802_dev *dev = fe->dvb->priv;
905 struct cx88_core *core = dev->core; 901 struct cx88_core *core = dev->core;
@@ -954,7 +950,7 @@ static int samsung_smt_7020_set_voltage(struct dvb_frontend *fe,
954} 950}
955 951
956static int samsung_smt_7020_stv0299_set_symbol_rate(struct dvb_frontend *fe, 952static int samsung_smt_7020_stv0299_set_symbol_rate(struct dvb_frontend *fe,
957 u32 srate, u32 ratio) 953 u32 srate, u32 ratio)
958{ 954{
959 u8 aclk = 0; 955 u8 aclk = 0;
960 u8 bclk = 0; 956 u8 bclk = 0;
@@ -988,7 +984,6 @@ static int samsung_smt_7020_stv0299_set_symbol_rate(struct dvb_frontend *fe,
988 return 0; 984 return 0;
989} 985}
990 986
991
992static const struct stv0299_config samsung_stv0299_config = { 987static const struct stv0299_config samsung_stv0299_config = {
993 .demod_address = 0x68, 988 .demod_address = 0x68,
994 .inittab = samsung_smt_7020_inittab, 989 .inittab = samsung_smt_7020_inittab,
@@ -1008,8 +1003,8 @@ static int dvb_register(struct cx8802_dev *dev)
1008 int mfe_shared = 0; /* bus not shared by default */ 1003 int mfe_shared = 0; /* bus not shared by default */
1009 int res = -EINVAL; 1004 int res = -EINVAL;
1010 1005
1011 if (0 != core->i2c_rc) { 1006 if (core->i2c_rc != 0) {
1012 printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name); 1007 pr_err("no i2c-bus available, cannot attach dvb drivers\n");
1013 goto frontend_detach; 1008 goto frontend_detach;
1014 } 1009 }
1015 1010
@@ -1030,7 +1025,7 @@ static int dvb_register(struct cx8802_dev *dev)
1030 fe0->dvb.frontend = dvb_attach(cx22702_attach, 1025 fe0->dvb.frontend = dvb_attach(cx22702_attach,
1031 &connexant_refboard_config, 1026 &connexant_refboard_config,
1032 &core->i2c_adap); 1027 &core->i2c_adap);
1033 if (fe0->dvb.frontend != NULL) { 1028 if (fe0->dvb.frontend) {
1034 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 1029 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
1035 0x61, &core->i2c_adap, 1030 0x61, &core->i2c_adap,
1036 DVB_PLL_THOMSON_DTT759X)) 1031 DVB_PLL_THOMSON_DTT759X))
@@ -1044,7 +1039,7 @@ static int dvb_register(struct cx8802_dev *dev)
1044 fe0->dvb.frontend = dvb_attach(cx22702_attach, 1039 fe0->dvb.frontend = dvb_attach(cx22702_attach,
1045 &connexant_refboard_config, 1040 &connexant_refboard_config,
1046 &core->i2c_adap); 1041 &core->i2c_adap);
1047 if (fe0->dvb.frontend != NULL) { 1042 if (fe0->dvb.frontend) {
1048 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 1043 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
1049 0x60, &core->i2c_adap, 1044 0x60, &core->i2c_adap,
1050 DVB_PLL_THOMSON_DTT7579)) 1045 DVB_PLL_THOMSON_DTT7579))
@@ -1058,10 +1053,10 @@ static int dvb_register(struct cx8802_dev *dev)
1058 fe0->dvb.frontend = dvb_attach(cx22702_attach, 1053 fe0->dvb.frontend = dvb_attach(cx22702_attach,
1059 &hauppauge_hvr_config, 1054 &hauppauge_hvr_config,
1060 &core->i2c_adap); 1055 &core->i2c_adap);
1061 if (fe0->dvb.frontend != NULL) { 1056 if (fe0->dvb.frontend) {
1062 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 1057 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1063 &core->i2c_adap, 0x61, 1058 &core->i2c_adap, 0x61,
1064 TUNER_PHILIPS_FMD1216ME_MK3)) 1059 TUNER_PHILIPS_FMD1216ME_MK3))
1065 goto frontend_detach; 1060 goto frontend_detach;
1066 } 1061 }
1067 break; 1062 break;
@@ -1069,10 +1064,10 @@ static int dvb_register(struct cx8802_dev *dev)
1069 fe0->dvb.frontend = dvb_attach(cx22702_attach, 1064 fe0->dvb.frontend = dvb_attach(cx22702_attach,
1070 &hauppauge_hvr_config, 1065 &hauppauge_hvr_config,
1071 &core->i2c_adap); 1066 &core->i2c_adap);
1072 if (fe0->dvb.frontend != NULL) { 1067 if (fe0->dvb.frontend) {
1073 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 1068 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1074 &core->i2c_adap, 0x61, 1069 &core->i2c_adap, 0x61,
1075 TUNER_PHILIPS_FMD1216MEX_MK3)) 1070 TUNER_PHILIPS_FMD1216MEX_MK3))
1076 goto frontend_detach; 1071 goto frontend_detach;
1077 } 1072 }
1078 break; 1073 break;
@@ -1082,8 +1077,8 @@ static int dvb_register(struct cx8802_dev *dev)
1082 dev->frontends.gate = 2; 1077 dev->frontends.gate = 2;
1083 /* DVB-S init */ 1078 /* DVB-S init */
1084 fe0->dvb.frontend = dvb_attach(cx24123_attach, 1079 fe0->dvb.frontend = dvb_attach(cx24123_attach,
1085 &hauppauge_novas_config, 1080 &hauppauge_novas_config,
1086 &dev->core->i2c_adap); 1081 &dev->core->i2c_adap);
1087 if (fe0->dvb.frontend) { 1082 if (fe0->dvb.frontend) {
1088 if (!dvb_attach(isl6421_attach, 1083 if (!dvb_attach(isl6421_attach,
1089 fe0->dvb.frontend, 1084 fe0->dvb.frontend,
@@ -1097,8 +1092,8 @@ static int dvb_register(struct cx8802_dev *dev)
1097 goto frontend_detach; 1092 goto frontend_detach;
1098 /* DVB-T init */ 1093 /* DVB-T init */
1099 fe1->dvb.frontend = dvb_attach(cx22702_attach, 1094 fe1->dvb.frontend = dvb_attach(cx22702_attach,
1100 &hauppauge_hvr_config, 1095 &hauppauge_hvr_config,
1101 &dev->core->i2c_adap); 1096 &dev->core->i2c_adap);
1102 if (fe1->dvb.frontend) { 1097 if (fe1->dvb.frontend) {
1103 fe1->dvb.frontend->id = 1; 1098 fe1->dvb.frontend->id = 1;
1104 if (!dvb_attach(simple_tuner_attach, 1099 if (!dvb_attach(simple_tuner_attach,
@@ -1112,7 +1107,7 @@ static int dvb_register(struct cx8802_dev *dev)
1112 fe0->dvb.frontend = dvb_attach(mt352_attach, 1107 fe0->dvb.frontend = dvb_attach(mt352_attach,
1113 &dvico_fusionhdtv, 1108 &dvico_fusionhdtv,
1114 &core->i2c_adap); 1109 &core->i2c_adap);
1115 if (fe0->dvb.frontend != NULL) { 1110 if (fe0->dvb.frontend) {
1116 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 1111 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
1117 0x60, NULL, DVB_PLL_THOMSON_DTT7579)) 1112 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
1118 goto frontend_detach; 1113 goto frontend_detach;
@@ -1122,19 +1117,21 @@ static int dvb_register(struct cx8802_dev *dev)
1122 fe0->dvb.frontend = dvb_attach(zl10353_attach, 1117 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1123 &dvico_fusionhdtv_plus_v1_1, 1118 &dvico_fusionhdtv_plus_v1_1,
1124 &core->i2c_adap); 1119 &core->i2c_adap);
1125 if (fe0->dvb.frontend != NULL) { 1120 if (fe0->dvb.frontend) {
1126 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 1121 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
1127 0x60, NULL, DVB_PLL_THOMSON_DTT7579)) 1122 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
1128 goto frontend_detach; 1123 goto frontend_detach;
1129 } 1124 }
1130 break; 1125 break;
1131 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: 1126 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
1132 /* The tin box says DEE1601, but it seems to be DTT7579 1127 /*
1133 * compatible, with a slightly different MT352 AGC gain. */ 1128 * The tin box says DEE1601, but it seems to be DTT7579
1129 * compatible, with a slightly different MT352 AGC gain.
1130 */
1134 fe0->dvb.frontend = dvb_attach(mt352_attach, 1131 fe0->dvb.frontend = dvb_attach(mt352_attach,
1135 &dvico_fusionhdtv_dual, 1132 &dvico_fusionhdtv_dual,
1136 &core->i2c_adap); 1133 &core->i2c_adap);
1137 if (fe0->dvb.frontend != NULL) { 1134 if (fe0->dvb.frontend) {
1138 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 1135 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
1139 0x61, NULL, DVB_PLL_THOMSON_DTT7579)) 1136 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
1140 goto frontend_detach; 1137 goto frontend_detach;
@@ -1144,7 +1141,7 @@ static int dvb_register(struct cx8802_dev *dev)
1144 fe0->dvb.frontend = dvb_attach(zl10353_attach, 1141 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1145 &dvico_fusionhdtv_plus_v1_1, 1142 &dvico_fusionhdtv_plus_v1_1,
1146 &core->i2c_adap); 1143 &core->i2c_adap);
1147 if (fe0->dvb.frontend != NULL) { 1144 if (fe0->dvb.frontend) {
1148 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 1145 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
1149 0x61, NULL, DVB_PLL_THOMSON_DTT7579)) 1146 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
1150 goto frontend_detach; 1147 goto frontend_detach;
@@ -1154,7 +1151,7 @@ static int dvb_register(struct cx8802_dev *dev)
1154 fe0->dvb.frontend = dvb_attach(mt352_attach, 1151 fe0->dvb.frontend = dvb_attach(mt352_attach,
1155 &dvico_fusionhdtv, 1152 &dvico_fusionhdtv,
1156 &core->i2c_adap); 1153 &core->i2c_adap);
1157 if (fe0->dvb.frontend != NULL) { 1154 if (fe0->dvb.frontend) {
1158 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 1155 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
1159 0x61, NULL, DVB_PLL_LG_Z201)) 1156 0x61, NULL, DVB_PLL_LG_Z201))
1160 goto frontend_detach; 1157 goto frontend_detach;
@@ -1166,7 +1163,7 @@ static int dvb_register(struct cx8802_dev *dev)
1166 fe0->dvb.frontend = dvb_attach(mt352_attach, 1163 fe0->dvb.frontend = dvb_attach(mt352_attach,
1167 &dntv_live_dvbt_config, 1164 &dntv_live_dvbt_config,
1168 &core->i2c_adap); 1165 &core->i2c_adap);
1169 if (fe0->dvb.frontend != NULL) { 1166 if (fe0->dvb.frontend) {
1170 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 1167 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
1171 0x61, NULL, DVB_PLL_UNKNOWN_1)) 1168 0x61, NULL, DVB_PLL_UNKNOWN_1))
1172 goto frontend_detach; 1169 goto frontend_detach;
@@ -1175,27 +1172,27 @@ static int dvb_register(struct cx8802_dev *dev)
1175 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: 1172 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
1176#if IS_ENABLED(CONFIG_VIDEO_CX88_VP3054) 1173#if IS_ENABLED(CONFIG_VIDEO_CX88_VP3054)
1177 /* MT352 is on a secondary I2C bus made from some GPIO lines */ 1174 /* MT352 is on a secondary I2C bus made from some GPIO lines */
1178 fe0->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config, 1175 fe0->dvb.frontend = dvb_attach(mt352_attach,
1176 &dntv_live_dvbt_pro_config,
1179 &dev->vp3054->adap); 1177 &dev->vp3054->adap);
1180 if (fe0->dvb.frontend != NULL) { 1178 if (fe0->dvb.frontend) {
1181 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 1179 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1182 &core->i2c_adap, 0x61, 1180 &core->i2c_adap, 0x61,
1183 TUNER_PHILIPS_FMD1216ME_MK3)) 1181 TUNER_PHILIPS_FMD1216ME_MK3))
1184 goto frontend_detach; 1182 goto frontend_detach;
1185 } 1183 }
1186#else 1184#else
1187 printk(KERN_ERR "%s/2: built without vp3054 support\n", 1185 pr_err("built without vp3054 support\n");
1188 core->name);
1189#endif 1186#endif
1190 break; 1187 break;
1191 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID: 1188 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
1192 fe0->dvb.frontend = dvb_attach(zl10353_attach, 1189 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1193 &dvico_fusionhdtv_hybrid, 1190 &dvico_fusionhdtv_hybrid,
1194 &core->i2c_adap); 1191 &core->i2c_adap);
1195 if (fe0->dvb.frontend != NULL) { 1192 if (fe0->dvb.frontend) {
1196 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 1193 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1197 &core->i2c_adap, 0x61, 1194 &core->i2c_adap, 0x61,
1198 TUNER_THOMSON_FE6600)) 1195 TUNER_THOMSON_FE6600))
1199 goto frontend_detach; 1196 goto frontend_detach;
1200 } 1197 }
1201 break; 1198 break;
@@ -1203,7 +1200,7 @@ static int dvb_register(struct cx8802_dev *dev)
1203 fe0->dvb.frontend = dvb_attach(zl10353_attach, 1200 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1204 &dvico_fusionhdtv_xc3028, 1201 &dvico_fusionhdtv_xc3028,
1205 &core->i2c_adap); 1202 &core->i2c_adap);
1206 if (fe0->dvb.frontend == NULL) 1203 if (!fe0->dvb.frontend)
1207 fe0->dvb.frontend = dvb_attach(mt352_attach, 1204 fe0->dvb.frontend = dvb_attach(mt352_attach,
1208 &dvico_fusionhdtv_mt352_xc3028, 1205 &dvico_fusionhdtv_mt352_xc3028,
1209 &core->i2c_adap); 1206 &core->i2c_adap);
@@ -1220,7 +1217,7 @@ static int dvb_register(struct cx8802_dev *dev)
1220 case CX88_BOARD_PCHDTV_HD3000: 1217 case CX88_BOARD_PCHDTV_HD3000:
1221 fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000, 1218 fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
1222 &core->i2c_adap); 1219 &core->i2c_adap);
1223 if (fe0->dvb.frontend != NULL) { 1220 if (fe0->dvb.frontend) {
1224 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 1221 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1225 &core->i2c_adap, 0x61, 1222 &core->i2c_adap, 0x61,
1226 TUNER_THOMSON_DTT761X)) 1223 TUNER_THOMSON_DTT761X))
@@ -1241,7 +1238,7 @@ static int dvb_register(struct cx8802_dev *dev)
1241 fe0->dvb.frontend = dvb_attach(lgdt330x_attach, 1238 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
1242 &fusionhdtv_3_gold, 1239 &fusionhdtv_3_gold,
1243 &core->i2c_adap); 1240 &core->i2c_adap);
1244 if (fe0->dvb.frontend != NULL) { 1241 if (fe0->dvb.frontend) {
1245 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 1242 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1246 &core->i2c_adap, 0x61, 1243 &core->i2c_adap, 0x61,
1247 TUNER_MICROTUNE_4042FI5)) 1244 TUNER_MICROTUNE_4042FI5))
@@ -1259,7 +1256,7 @@ static int dvb_register(struct cx8802_dev *dev)
1259 fe0->dvb.frontend = dvb_attach(lgdt330x_attach, 1256 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
1260 &fusionhdtv_3_gold, 1257 &fusionhdtv_3_gold,
1261 &core->i2c_adap); 1258 &core->i2c_adap);
1262 if (fe0->dvb.frontend != NULL) { 1259 if (fe0->dvb.frontend) {
1263 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 1260 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1264 &core->i2c_adap, 0x61, 1261 &core->i2c_adap, 0x61,
1265 TUNER_THOMSON_DTT761X)) 1262 TUNER_THOMSON_DTT761X))
@@ -1277,13 +1274,13 @@ static int dvb_register(struct cx8802_dev *dev)
1277 fe0->dvb.frontend = dvb_attach(lgdt330x_attach, 1274 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
1278 &fusionhdtv_5_gold, 1275 &fusionhdtv_5_gold,
1279 &core->i2c_adap); 1276 &core->i2c_adap);
1280 if (fe0->dvb.frontend != NULL) { 1277 if (fe0->dvb.frontend) {
1281 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 1278 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1282 &core->i2c_adap, 0x61, 1279 &core->i2c_adap, 0x61,
1283 TUNER_LG_TDVS_H06XF)) 1280 TUNER_LG_TDVS_H06XF))
1284 goto frontend_detach; 1281 goto frontend_detach;
1285 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend, 1282 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
1286 &core->i2c_adap, 0x43)) 1283 &core->i2c_adap, 0x43))
1287 goto frontend_detach; 1284 goto frontend_detach;
1288 } 1285 }
1289 break; 1286 break;
@@ -1298,13 +1295,13 @@ static int dvb_register(struct cx8802_dev *dev)
1298 fe0->dvb.frontend = dvb_attach(lgdt330x_attach, 1295 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
1299 &pchdtv_hd5500, 1296 &pchdtv_hd5500,
1300 &core->i2c_adap); 1297 &core->i2c_adap);
1301 if (fe0->dvb.frontend != NULL) { 1298 if (fe0->dvb.frontend) {
1302 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 1299 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1303 &core->i2c_adap, 0x61, 1300 &core->i2c_adap, 0x61,
1304 TUNER_LG_TDVS_H06XF)) 1301 TUNER_LG_TDVS_H06XF))
1305 goto frontend_detach; 1302 goto frontend_detach;
1306 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend, 1303 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
1307 &core->i2c_adap, 0x43)) 1304 &core->i2c_adap, 0x43))
1308 goto frontend_detach; 1305 goto frontend_detach;
1309 } 1306 }
1310 break; 1307 break;
@@ -1312,7 +1309,7 @@ static int dvb_register(struct cx8802_dev *dev)
1312 fe0->dvb.frontend = dvb_attach(nxt200x_attach, 1309 fe0->dvb.frontend = dvb_attach(nxt200x_attach,
1313 &ati_hdtvwonder, 1310 &ati_hdtvwonder,
1314 &core->i2c_adap); 1311 &core->i2c_adap);
1315 if (fe0->dvb.frontend != NULL) { 1312 if (fe0->dvb.frontend) {
1316 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 1313 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1317 &core->i2c_adap, 0x61, 1314 &core->i2c_adap, 0x61,
1318 TUNER_PHILIPS_TUV1236D)) 1315 TUNER_PHILIPS_TUV1236D))
@@ -1333,8 +1330,8 @@ static int dvb_register(struct cx8802_dev *dev)
1333 override_tone = false; 1330 override_tone = false;
1334 1331
1335 if (!dvb_attach(isl6421_attach, fe0->dvb.frontend, 1332 if (!dvb_attach(isl6421_attach, fe0->dvb.frontend,
1336 &core->i2c_adap, 0x08, ISL6421_DCL, 0x00, 1333 &core->i2c_adap, 0x08, ISL6421_DCL,
1337 override_tone)) 1334 0x00, override_tone))
1338 goto frontend_detach; 1335 goto frontend_detach;
1339 } 1336 }
1340 break; 1337 break;
@@ -1360,7 +1357,7 @@ static int dvb_register(struct cx8802_dev *dev)
1360 fe0->dvb.frontend = dvb_attach(s5h1409_attach, 1357 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1361 &pinnacle_pctv_hd_800i_config, 1358 &pinnacle_pctv_hd_800i_config,
1362 &core->i2c_adap); 1359 &core->i2c_adap);
1363 if (fe0->dvb.frontend != NULL) { 1360 if (fe0->dvb.frontend) {
1364 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend, 1361 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
1365 &core->i2c_adap, 1362 &core->i2c_adap,
1366 &pinnacle_pctv_hd_800i_tuner_config)) 1363 &pinnacle_pctv_hd_800i_tuner_config))
@@ -1369,9 +1366,9 @@ static int dvb_register(struct cx8802_dev *dev)
1369 break; 1366 break;
1370 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: 1367 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
1371 fe0->dvb.frontend = dvb_attach(s5h1409_attach, 1368 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1372 &dvico_hdtv5_pci_nano_config, 1369 &dvico_hdtv5_pci_nano_config,
1373 &core->i2c_adap); 1370 &core->i2c_adap);
1374 if (fe0->dvb.frontend != NULL) { 1371 if (fe0->dvb.frontend) {
1375 struct dvb_frontend *fe; 1372 struct dvb_frontend *fe;
1376 struct xc2028_config cfg = { 1373 struct xc2028_config cfg = {
1377 .i2c_adap = &core->i2c_adap, 1374 .i2c_adap = &core->i2c_adap,
@@ -1385,7 +1382,7 @@ static int dvb_register(struct cx8802_dev *dev)
1385 1382
1386 fe = dvb_attach(xc2028_attach, 1383 fe = dvb_attach(xc2028_attach,
1387 fe0->dvb.frontend, &cfg); 1384 fe0->dvb.frontend, &cfg);
1388 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 1385 if (fe && fe->ops.tuner_ops.set_config)
1389 fe->ops.tuner_ops.set_config(fe, &ctl); 1386 fe->ops.tuner_ops.set_config(fe, &ctl);
1390 } 1387 }
1391 break; 1388 break;
@@ -1427,7 +1424,7 @@ static int dvb_register(struct cx8802_dev *dev)
1427 if (attach_xc3028(0x61, dev) < 0) 1424 if (attach_xc3028(0x61, dev) < 0)
1428 goto frontend_detach; 1425 goto frontend_detach;
1429 break; 1426 break;
1430 case CX88_BOARD_KWORLD_ATSC_120: 1427 case CX88_BOARD_KWORLD_ATSC_120:
1431 fe0->dvb.frontend = dvb_attach(s5h1409_attach, 1428 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1432 &kworld_atsc_120_config, 1429 &kworld_atsc_120_config,
1433 &core->i2c_adap); 1430 &core->i2c_adap);
@@ -1438,7 +1435,7 @@ static int dvb_register(struct cx8802_dev *dev)
1438 fe0->dvb.frontend = dvb_attach(s5h1411_attach, 1435 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1439 &dvico_fusionhdtv7_config, 1436 &dvico_fusionhdtv7_config,
1440 &core->i2c_adap); 1437 &core->i2c_adap);
1441 if (fe0->dvb.frontend != NULL) { 1438 if (fe0->dvb.frontend) {
1442 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend, 1439 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
1443 &core->i2c_adap, 1440 &core->i2c_adap,
1444 &dvico_fusionhdtv7_tuner_config)) 1441 &dvico_fusionhdtv7_tuner_config))
@@ -1451,8 +1448,8 @@ static int dvb_register(struct cx8802_dev *dev)
1451 dev->frontends.gate = 2; 1448 dev->frontends.gate = 2;
1452 /* DVB-S/S2 Init */ 1449 /* DVB-S/S2 Init */
1453 fe0->dvb.frontend = dvb_attach(cx24116_attach, 1450 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1454 &hauppauge_hvr4000_config, 1451 &hauppauge_hvr4000_config,
1455 &dev->core->i2c_adap); 1452 &dev->core->i2c_adap);
1456 if (fe0->dvb.frontend) { 1453 if (fe0->dvb.frontend) {
1457 if (!dvb_attach(isl6421_attach, 1454 if (!dvb_attach(isl6421_attach,
1458 fe0->dvb.frontend, 1455 fe0->dvb.frontend,
@@ -1466,8 +1463,8 @@ static int dvb_register(struct cx8802_dev *dev)
1466 goto frontend_detach; 1463 goto frontend_detach;
1467 /* DVB-T Init */ 1464 /* DVB-T Init */
1468 fe1->dvb.frontend = dvb_attach(cx22702_attach, 1465 fe1->dvb.frontend = dvb_attach(cx22702_attach,
1469 &hauppauge_hvr_config, 1466 &hauppauge_hvr_config,
1470 &dev->core->i2c_adap); 1467 &dev->core->i2c_adap);
1471 if (fe1->dvb.frontend) { 1468 if (fe1->dvb.frontend) {
1472 fe1->dvb.frontend->id = 1; 1469 fe1->dvb.frontend->id = 1;
1473 if (!dvb_attach(simple_tuner_attach, 1470 if (!dvb_attach(simple_tuner_attach,
@@ -1479,8 +1476,8 @@ static int dvb_register(struct cx8802_dev *dev)
1479 break; 1476 break;
1480 case CX88_BOARD_HAUPPAUGE_HVR4000LITE: 1477 case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
1481 fe0->dvb.frontend = dvb_attach(cx24116_attach, 1478 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1482 &hauppauge_hvr4000_config, 1479 &hauppauge_hvr4000_config,
1483 &dev->core->i2c_adap); 1480 &dev->core->i2c_adap);
1484 if (fe0->dvb.frontend) { 1481 if (fe0->dvb.frontend) {
1485 if (!dvb_attach(isl6421_attach, 1482 if (!dvb_attach(isl6421_attach,
1486 fe0->dvb.frontend, 1483 fe0->dvb.frontend,
@@ -1495,7 +1492,7 @@ static int dvb_register(struct cx8802_dev *dev)
1495 fe0->dvb.frontend = dvb_attach(stv0299_attach, 1492 fe0->dvb.frontend = dvb_attach(stv0299_attach,
1496 &tevii_tuner_sharp_config, 1493 &tevii_tuner_sharp_config,
1497 &core->i2c_adap); 1494 &core->i2c_adap);
1498 if (fe0->dvb.frontend != NULL) { 1495 if (fe0->dvb.frontend) {
1499 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60, 1496 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
1500 &core->i2c_adap, DVB_PLL_OPERA1)) 1497 &core->i2c_adap, DVB_PLL_OPERA1))
1501 goto frontend_detach; 1498 goto frontend_detach;
@@ -1506,8 +1503,9 @@ static int dvb_register(struct cx8802_dev *dev)
1506 fe0->dvb.frontend = dvb_attach(stv0288_attach, 1503 fe0->dvb.frontend = dvb_attach(stv0288_attach,
1507 &tevii_tuner_earda_config, 1504 &tevii_tuner_earda_config,
1508 &core->i2c_adap); 1505 &core->i2c_adap);
1509 if (fe0->dvb.frontend != NULL) { 1506 if (fe0->dvb.frontend) {
1510 if (!dvb_attach(stb6000_attach, fe0->dvb.frontend, 0x61, 1507 if (!dvb_attach(stb6000_attach,
1508 fe0->dvb.frontend, 0x61,
1511 &core->i2c_adap)) 1509 &core->i2c_adap))
1512 goto frontend_detach; 1510 goto frontend_detach;
1513 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage; 1511 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
@@ -1519,16 +1517,16 @@ static int dvb_register(struct cx8802_dev *dev)
1519 fe0->dvb.frontend = dvb_attach(cx24116_attach, 1517 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1520 &tevii_s460_config, 1518 &tevii_s460_config,
1521 &core->i2c_adap); 1519 &core->i2c_adap);
1522 if (fe0->dvb.frontend != NULL) 1520 if (fe0->dvb.frontend)
1523 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; 1521 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
1524 break; 1522 break;
1525 case CX88_BOARD_TEVII_S464: 1523 case CX88_BOARD_TEVII_S464:
1526 fe0->dvb.frontend = dvb_attach(ds3000_attach, 1524 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1527 &tevii_ds3000_config, 1525 &tevii_ds3000_config,
1528 &core->i2c_adap); 1526 &core->i2c_adap);
1529 if (fe0->dvb.frontend != NULL) { 1527 if (fe0->dvb.frontend) {
1530 dvb_attach(ts2020_attach, fe0->dvb.frontend, 1528 dvb_attach(ts2020_attach, fe0->dvb.frontend,
1531 &tevii_ts2020_config, &core->i2c_adap); 1529 &tevii_ts2020_config, &core->i2c_adap);
1532 fe0->dvb.frontend->ops.set_voltage = 1530 fe0->dvb.frontend->ops.set_voltage =
1533 tevii_dvbs_set_voltage; 1531 tevii_dvbs_set_voltage;
1534 } 1532 }
@@ -1540,7 +1538,7 @@ static int dvb_register(struct cx8802_dev *dev)
1540 fe0->dvb.frontend = dvb_attach(cx24116_attach, 1538 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1541 &hauppauge_hvr4000_config, 1539 &hauppauge_hvr4000_config,
1542 &core->i2c_adap); 1540 &core->i2c_adap);
1543 if (fe0->dvb.frontend != NULL) 1541 if (fe0->dvb.frontend)
1544 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; 1542 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
1545 break; 1543 break;
1546 case CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII: 1544 case CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII:
@@ -1557,9 +1555,9 @@ static int dvb_register(struct cx8802_dev *dev)
1557 struct dvb_tuner_ops *tuner_ops = NULL; 1555 struct dvb_tuner_ops *tuner_ops = NULL;
1558 1556
1559 fe0->dvb.frontend = dvb_attach(stv0900_attach, 1557 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1560 &prof_7301_stv0900_config, 1558 &prof_7301_stv0900_config,
1561 &core->i2c_adap, 0); 1559 &core->i2c_adap, 0);
1562 if (fe0->dvb.frontend != NULL) { 1560 if (fe0->dvb.frontend) {
1563 if (!dvb_attach(stb6100_attach, fe0->dvb.frontend, 1561 if (!dvb_attach(stb6100_attach, fe0->dvb.frontend,
1564 &prof_7301_stb6100_config, 1562 &prof_7301_stb6100_config,
1565 &core->i2c_adap)) 1563 &core->i2c_adap))
@@ -1589,8 +1587,8 @@ static int dvb_register(struct cx8802_dev *dev)
1589 mdelay(200); 1587 mdelay(200);
1590 1588
1591 fe0->dvb.frontend = dvb_attach(stv0299_attach, 1589 fe0->dvb.frontend = dvb_attach(stv0299_attach,
1592 &samsung_stv0299_config, 1590 &samsung_stv0299_config,
1593 &dev->core->i2c_adap); 1591 &dev->core->i2c_adap);
1594 if (fe0->dvb.frontend) { 1592 if (fe0->dvb.frontend) {
1595 fe0->dvb.frontend->ops.tuner_ops.set_params = 1593 fe0->dvb.frontend->ops.tuner_ops.set_params =
1596 samsung_smt_7020_tuner_set_params; 1594 samsung_smt_7020_tuner_set_params;
@@ -1606,8 +1604,8 @@ static int dvb_register(struct cx8802_dev *dev)
1606 case CX88_BOARD_TWINHAN_VP1027_DVBS: 1604 case CX88_BOARD_TWINHAN_VP1027_DVBS:
1607 dev->ts_gen_cntrl = 0x00; 1605 dev->ts_gen_cntrl = 0x00;
1608 fe0->dvb.frontend = dvb_attach(mb86a16_attach, 1606 fe0->dvb.frontend = dvb_attach(mb86a16_attach,
1609 &twinhan_vp1027, 1607 &twinhan_vp1027,
1610 &core->i2c_adap); 1608 &core->i2c_adap);
1611 if (fe0->dvb.frontend) { 1609 if (fe0->dvb.frontend) {
1612 core->prev_set_voltage = 1610 core->prev_set_voltage =
1613 fe0->dvb.frontend->ops.set_voltage; 1611 fe0->dvb.frontend->ops.set_voltage;
@@ -1617,15 +1615,12 @@ static int dvb_register(struct cx8802_dev *dev)
1617 break; 1615 break;
1618 1616
1619 default: 1617 default:
1620 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n", 1618 pr_err("The frontend of your DVB/ATSC card isn't supported yet\n");
1621 core->name);
1622 break; 1619 break;
1623 } 1620 }
1624 1621
1625 if ( (NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend) ) { 1622 if ((NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend)) {
1626 printk(KERN_ERR 1623 pr_err("frontend initialization failed\n");
1627 "%s/2: frontend initialization failed\n",
1628 core->name);
1629 goto frontend_detach; 1624 goto frontend_detach;
1630 } 1625 }
1631 /* define general-purpose callback pointer */ 1626 /* define general-purpose callback pointer */
@@ -1660,7 +1655,8 @@ static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
1660{ 1655{
1661 struct cx88_core *core = drv->core; 1656 struct cx88_core *core = drv->core;
1662 int err = 0; 1657 int err = 0;
1663 dprintk( 1, "%s\n", __func__); 1658
1659 dprintk(1, "%s\n", __func__);
1664 1660
1665 switch (core->boardnr) { 1661 switch (core->boardnr) {
1666 case CX88_BOARD_HAUPPAUGE_HVR1300: 1662 case CX88_BOARD_HAUPPAUGE_HVR1300:
@@ -1724,7 +1720,8 @@ static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
1724{ 1720{
1725 struct cx88_core *core = drv->core; 1721 struct cx88_core *core = drv->core;
1726 int err = 0; 1722 int err = 0;
1727 dprintk( 1, "%s\n", __func__); 1723
1724 dprintk(1, "%s\n", __func__);
1728 1725
1729 switch (core->boardnr) { 1726 switch (core->boardnr) {
1730 case CX88_BOARD_HAUPPAUGE_HVR1300: 1727 case CX88_BOARD_HAUPPAUGE_HVR1300:
@@ -1747,8 +1744,8 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv)
1747 struct vb2_dvb_frontend *fe; 1744 struct vb2_dvb_frontend *fe;
1748 int i; 1745 int i;
1749 1746
1750 dprintk( 1, "%s\n", __func__); 1747 dprintk(1, "%s\n", __func__);
1751 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", 1748 dprintk(1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
1752 core->boardnr, 1749 core->boardnr,
1753 core->name, 1750 core->name,
1754 core->pci_bus, 1751 core->pci_bus,
@@ -1760,25 +1757,25 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv)
1760 1757
1761 /* If vp3054 isn't enabled, a stub will just return 0 */ 1758 /* If vp3054 isn't enabled, a stub will just return 0 */
1762 err = vp3054_i2c_probe(dev); 1759 err = vp3054_i2c_probe(dev);
1763 if (0 != err) 1760 if (err != 0)
1764 goto fail_core; 1761 goto fail_core;
1765 1762
1766 /* dvb stuff */ 1763 /* dvb stuff */
1767 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name); 1764 pr_info("cx2388x based DVB/ATSC card\n");
1768 dev->ts_gen_cntrl = 0x0c; 1765 dev->ts_gen_cntrl = 0x0c;
1769 1766
1770 err = cx8802_alloc_frontends(dev); 1767 err = cx8802_alloc_frontends(dev);
1771 if (err) 1768 if (err)
1772 goto fail_core; 1769 goto fail_core;
1773 1770
1774 err = -ENODEV;
1775 for (i = 1; i <= core->board.num_frontends; i++) { 1771 for (i = 1; i <= core->board.num_frontends; i++) {
1776 struct vb2_queue *q; 1772 struct vb2_queue *q;
1777 1773
1778 fe = vb2_dvb_get_frontend(&core->dvbdev->frontends, i); 1774 fe = vb2_dvb_get_frontend(&core->dvbdev->frontends, i);
1779 if (fe == NULL) { 1775 if (!fe) {
1780 printk(KERN_ERR "%s() failed to get frontend(%d)\n", 1776 pr_err("%s() failed to get frontend(%d)\n",
1781 __func__, i); 1777 __func__, i);
1778 err = -ENODEV;
1782 goto fail_probe; 1779 goto fail_probe;
1783 } 1780 }
1784 q = &fe->dvb.dvbq; 1781 q = &fe->dvb.dvbq;
@@ -1805,8 +1802,7 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv)
1805 err = dvb_register(dev); 1802 err = dvb_register(dev);
1806 if (err) 1803 if (err)
1807 /* frontends/adapter de-allocated in dvb_register */ 1804 /* frontends/adapter de-allocated in dvb_register */
1808 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n", 1805 pr_err("dvb_register failed (err = %d)\n", err);
1809 core->name, err);
1810 return err; 1806 return err;
1811fail_probe: 1807fail_probe:
1812 vb2_dvb_dealloc_frontends(&core->dvbdev->frontends); 1808 vb2_dvb_dealloc_frontends(&core->dvbdev->frontends);
@@ -1819,7 +1815,7 @@ static int cx8802_dvb_remove(struct cx8802_driver *drv)
1819 struct cx88_core *core = drv->core; 1815 struct cx88_core *core = drv->core;
1820 struct cx8802_dev *dev = drv->core->dvbdev; 1816 struct cx8802_dev *dev = drv->core->dvbdev;
1821 1817
1822 dprintk( 1, "%s\n", __func__); 1818 dprintk(1, "%s\n", __func__);
1823 1819
1824 vb2_dvb_unregister_bus(&dev->frontends); 1820 vb2_dvb_unregister_bus(&dev->frontends);
1825 1821
@@ -1841,8 +1837,7 @@ static struct cx8802_driver cx8802_dvb_driver = {
1841 1837
1842static int __init dvb_init(void) 1838static int __init dvb_init(void)
1843{ 1839{
1844 printk(KERN_INFO "cx88/2: cx2388x dvb driver version %s loaded\n", 1840 pr_info("cx2388x dvb driver version %s loaded\n", CX88_VERSION);
1845 CX88_VERSION);
1846 return cx8802_register_driver(&cx8802_dvb_driver); 1841 return cx8802_register_driver(&cx8802_dvb_driver);
1847} 1842}
1848 1843
diff --git a/drivers/media/pci/cx88/cx88-i2c.c b/drivers/media/pci/cx88/cx88-i2c.c
index cf2d69615838..f7692775fb5a 100644
--- a/drivers/media/pci/cx88/cx88-i2c.c
+++ b/drivers/media/pci/cx88/cx88-i2c.c
@@ -1,55 +1,53 @@
1 1
2/* 2/*
3 *
4 * cx88-i2c.c -- all the i2c code is here
5 *
6 * Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)
7 * & Marcus Metzler (mocm@thp.uni-koeln.de)
8 * (c) 2002 Yurij Sysoev <yurij@naturesoft.net>
9 * (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org>
10 *
11 * (c) 2005 Mauro Carvalho Chehab <mchehab@infradead.org>
12 * - Multituner support and i2c address binding
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 */
3 24
4 cx88-i2c.c -- all the i2c code is here 25#include "cx88.h"
5
6 Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)
7 & Marcus Metzler (mocm@thp.uni-koeln.de)
8 (c) 2002 Yurij Sysoev <yurij@naturesoft.net>
9 (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org>
10
11 (c) 2005 Mauro Carvalho Chehab <mchehab@infradead.org>
12 - Multituner support and i2c address binding
13
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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
28*/
29 26
30#include <linux/module.h>
31#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/io.h>
29#include <linux/module.h>
32 30
33#include <asm/io.h>
34
35#include "cx88.h"
36#include <media/v4l2-common.h> 31#include <media/v4l2-common.h>
37 32
38static unsigned int i2c_debug; 33static unsigned int i2c_debug;
39module_param(i2c_debug, int, 0644); 34module_param(i2c_debug, int, 0644);
40MODULE_PARM_DESC(i2c_debug,"enable debug messages [i2c]"); 35MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]");
41 36
42static unsigned int i2c_scan; 37static unsigned int i2c_scan;
43module_param(i2c_scan, int, 0444); 38module_param(i2c_scan, int, 0444);
44MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); 39MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time");
45 40
46static unsigned int i2c_udelay = 5; 41static unsigned int i2c_udelay = 5;
47module_param(i2c_udelay, int, 0644); 42module_param(i2c_udelay, int, 0644);
48MODULE_PARM_DESC(i2c_udelay,"i2c delay at insmod time, in usecs " 43MODULE_PARM_DESC(i2c_udelay,
49 "(should be 5 or higher). Lower value means higher bus speed."); 44 "i2c delay at insmod time, in usecs (should be 5 or higher). Lower value means higher bus speed.");
50 45
51#define dprintk(level,fmt, arg...) if (i2c_debug >= level) \ 46#define dprintk(level, fmt, arg...) do { \
52 printk(KERN_DEBUG "%s: " fmt, core->name , ## arg) 47 if (i2c_debug >= level) \
48 printk(KERN_DEBUG pr_fmt("%s: i2c:" fmt), \
49 __func__, ##arg); \
50} while (0)
53 51
54/* ----------------------------------------------------------------------- */ 52/* ----------------------------------------------------------------------- */
55 53
@@ -109,26 +107,26 @@ static const struct i2c_algo_bit_data cx8800_i2c_algo_template = {
109/* ----------------------------------------------------------------------- */ 107/* ----------------------------------------------------------------------- */
110 108
111static const char * const i2c_devs[128] = { 109static const char * const i2c_devs[128] = {
112 [ 0x1c >> 1 ] = "lgdt330x", 110 [0x1c >> 1] = "lgdt330x",
113 [ 0x86 >> 1 ] = "tda9887/cx22702", 111 [0x86 >> 1] = "tda9887/cx22702",
114 [ 0xa0 >> 1 ] = "eeprom", 112 [0xa0 >> 1] = "eeprom",
115 [ 0xc0 >> 1 ] = "tuner (analog)", 113 [0xc0 >> 1] = "tuner (analog)",
116 [ 0xc2 >> 1 ] = "tuner (analog/dvb)", 114 [0xc2 >> 1] = "tuner (analog/dvb)",
117 [ 0xc8 >> 1 ] = "xc5000", 115 [0xc8 >> 1] = "xc5000",
118}; 116};
119 117
120static void do_i2c_scan(const char *name, struct i2c_client *c) 118static void do_i2c_scan(const char *name, struct i2c_client *c)
121{ 119{
122 unsigned char buf; 120 unsigned char buf;
123 int i,rc; 121 int i, rc;
124 122
125 for (i = 0; i < ARRAY_SIZE(i2c_devs); i++) { 123 for (i = 0; i < ARRAY_SIZE(i2c_devs); i++) {
126 c->addr = i; 124 c->addr = i;
127 rc = i2c_master_recv(c,&buf,0); 125 rc = i2c_master_recv(c, &buf, 0);
128 if (rc < 0) 126 if (rc < 0)
129 continue; 127 continue;
130 printk("%s: i2c scan: found device @ 0x%x [%s]\n", 128 pr_info("i2c scan: found device @ 0x%x [%s]\n",
131 name, i << 1, i2c_devs[i] ? i2c_devs[i] : "???"); 129 i << 1, i2c_devs[i] ? i2c_devs[i] : "???");
132 } 130 }
133} 131}
134 132
@@ -136,14 +134,13 @@ static void do_i2c_scan(const char *name, struct i2c_client *c)
136int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci) 134int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci)
137{ 135{
138 /* Prevents usage of invalid delay values */ 136 /* Prevents usage of invalid delay values */
139 if (i2c_udelay<5) 137 if (i2c_udelay < 5)
140 i2c_udelay=5; 138 i2c_udelay = 5;
141 139
142 core->i2c_algo = cx8800_i2c_algo_template; 140 core->i2c_algo = cx8800_i2c_algo_template;
143 141
144
145 core->i2c_adap.dev.parent = &pci->dev; 142 core->i2c_adap.dev.parent = &pci->dev;
146 strlcpy(core->i2c_adap.name,core->name,sizeof(core->i2c_adap.name)); 143 strlcpy(core->i2c_adap.name, core->name, sizeof(core->i2c_adap.name));
147 core->i2c_adap.owner = THIS_MODULE; 144 core->i2c_adap.owner = THIS_MODULE;
148 core->i2c_algo.udelay = i2c_udelay; 145 core->i2c_algo.udelay = i2c_udelay;
149 core->i2c_algo.data = core; 146 core->i2c_algo.data = core;
@@ -152,32 +149,35 @@ int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci)
152 core->i2c_client.adapter = &core->i2c_adap; 149 core->i2c_client.adapter = &core->i2c_adap;
153 strlcpy(core->i2c_client.name, "cx88xx internal", I2C_NAME_SIZE); 150 strlcpy(core->i2c_client.name, "cx88xx internal", I2C_NAME_SIZE);
154 151
155 cx8800_bit_setscl(core,1); 152 cx8800_bit_setscl(core, 1);
156 cx8800_bit_setsda(core,1); 153 cx8800_bit_setsda(core, 1);
157 154
158 core->i2c_rc = i2c_bit_add_bus(&core->i2c_adap); 155 core->i2c_rc = i2c_bit_add_bus(&core->i2c_adap);
159 if (0 == core->i2c_rc) { 156 if (core->i2c_rc == 0) {
160 static u8 tuner_data[] = 157 static u8 tuner_data[] = {
161 { 0x0b, 0xdc, 0x86, 0x52 }; 158 0x0b, 0xdc, 0x86, 0x52 };
162 static struct i2c_msg tuner_msg = 159 static struct i2c_msg tuner_msg = {
163 { .flags = 0, .addr = 0xc2 >> 1, .buf = tuner_data, .len = 4 }; 160 .flags = 0,
161 .addr = 0xc2 >> 1,
162 .buf = tuner_data,
163 .len = 4
164 };
164 165
165 dprintk(1, "i2c register ok\n"); 166 dprintk(1, "i2c register ok\n");
166 switch( core->boardnr ) { 167 switch (core->boardnr) {
167 case CX88_BOARD_HAUPPAUGE_HVR1300: 168 case CX88_BOARD_HAUPPAUGE_HVR1300:
168 case CX88_BOARD_HAUPPAUGE_HVR3000: 169 case CX88_BOARD_HAUPPAUGE_HVR3000:
169 case CX88_BOARD_HAUPPAUGE_HVR4000: 170 case CX88_BOARD_HAUPPAUGE_HVR4000:
170 printk("%s: i2c init: enabling analog demod on HVR1300/3000/4000 tuner\n", 171 pr_info("i2c init: enabling analog demod on HVR1300/3000/4000 tuner\n");
171 core->name); 172 i2c_transfer(core->i2c_client.adapter, &tuner_msg, 1);
172 i2c_transfer(core->i2c_client.adapter, &tuner_msg, 1); 173 break;
173 break; 174 default:
174 default: 175 break;
175 break;
176 } 176 }
177 if (i2c_scan) 177 if (i2c_scan)
178 do_i2c_scan(core->name,&core->i2c_client); 178 do_i2c_scan(core->name, &core->i2c_client);
179 } else 179 } else
180 printk("%s: i2c register FAILED\n", core->name); 180 pr_err("i2c register FAILED\n");
181 181
182 return core->i2c_rc; 182 return core->i2c_rc;
183} 183}
diff --git a/drivers/media/pci/cx88/cx88-input.c b/drivers/media/pci/cx88/cx88-input.c
index cd7687183381..dcfea3502e42 100644
--- a/drivers/media/pci/cx88/cx88-input.c
+++ b/drivers/media/pci/cx88/cx88-input.c
@@ -16,19 +16,16 @@
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
21#include "cx88.h"
22
25#include <linux/init.h> 23#include <linux/init.h>
26#include <linux/hrtimer.h> 24#include <linux/hrtimer.h>
27#include <linux/pci.h> 25#include <linux/pci.h>
28#include <linux/slab.h> 26#include <linux/slab.h>
29#include <linux/module.h> 27#include <linux/module.h>
30 28
31#include "cx88.h"
32#include <media/rc-core.h> 29#include <media/rc-core.h>
33 30
34#define MODULE_NAME "cx88xx" 31#define MODULE_NAME "cx88xx"
@@ -57,7 +54,7 @@ struct cx88_IR {
57 u32 mask_keyup; 54 u32 mask_keyup;
58}; 55};
59 56
60static unsigned ir_samplerate = 4; 57static unsigned int ir_samplerate = 4;
61module_param(ir_samplerate, uint, 0444); 58module_param(ir_samplerate, uint, 0444);
62MODULE_PARM_DESC(ir_samplerate, "IR samplerate in kHz, 1 - 20, default 4"); 59MODULE_PARM_DESC(ir_samplerate, "IR samplerate in kHz, 1 - 20, default 4");
63 60
@@ -65,11 +62,15 @@ static int ir_debug;
65module_param(ir_debug, int, 0644); /* debug level [IR] */ 62module_param(ir_debug, int, 0644); /* debug level [IR] */
66MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); 63MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]");
67 64
68#define ir_dprintk(fmt, arg...) if (ir_debug) \ 65#define ir_dprintk(fmt, arg...) do { \
69 printk(KERN_DEBUG "%s IR: " fmt , ir->core->name , ##arg) 66 if (ir_debug) \
67 printk(KERN_DEBUG "%s IR: " fmt, ir->core->name, ##arg);\
68} while (0)
70 69
71#define dprintk(fmt, arg...) if (ir_debug) \ 70#define dprintk(fmt, arg...) do { \
72 printk(KERN_DEBUG "cx88 IR: " fmt , ##arg) 71 if (ir_debug) \
72 printk(KERN_DEBUG "cx88 IR: " fmt, ##arg); \
73} while (0)
73 74
74/* ---------------------------------------------------------------------- */ 75/* ---------------------------------------------------------------------- */
75 76
@@ -82,21 +83,22 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
82 gpio = cx_read(ir->gpio_addr); 83 gpio = cx_read(ir->gpio_addr);
83 switch (core->boardnr) { 84 switch (core->boardnr) {
84 case CX88_BOARD_NPGTECH_REALTV_TOP10FM: 85 case CX88_BOARD_NPGTECH_REALTV_TOP10FM:
85 /* This board apparently uses a combination of 2 GPIO 86 /*
86 to represent the keys. Additionally, the second GPIO 87 * This board apparently uses a combination of 2 GPIO
87 can be used for parity. 88 * to represent the keys. Additionally, the second GPIO
88 89 * can be used for parity.
89 Example: 90 *
90 91 * Example:
91 for key "5" 92 *
92 gpio = 0x758, auxgpio = 0xe5 or 0xf5 93 * for key "5"
93 for key "Power" 94 * gpio = 0x758, auxgpio = 0xe5 or 0xf5
94 gpio = 0x758, auxgpio = 0xed or 0xfd 95 * for key "Power"
96 * gpio = 0x758, auxgpio = 0xed or 0xfd
95 */ 97 */
96 98
97 auxgpio = cx_read(MO_GP1_IO); 99 auxgpio = cx_read(MO_GP1_IO);
98 /* Take out the parity part */ 100 /* Take out the parity part */
99 gpio=(gpio & 0x7fd) + (auxgpio & 0xef); 101 gpio = (gpio & 0x7fd) + (auxgpio & 0xef);
100 break; 102 break;
101 case CX88_BOARD_WINFAST_DTV1000: 103 case CX88_BOARD_WINFAST_DTV1000:
102 case CX88_BOARD_WINFAST_DTV1800H: 104 case CX88_BOARD_WINFAST_DTV1800H:
@@ -145,7 +147,7 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
145 147
146 if (0 == (gpio & ir->mask_keyup)) 148 if (0 == (gpio & ir->mask_keyup))
147 rc_keydown_notimeout(ir->dev, RC_TYPE_NECX, scancode, 149 rc_keydown_notimeout(ir->dev, RC_TYPE_NECX, scancode,
148 0); 150 0);
149 else 151 else
150 rc_keyup(ir->dev); 152 rc_keyup(ir->dev);
151 153
@@ -234,12 +236,14 @@ int cx88_ir_start(struct cx88_core *core)
234 236
235 return 0; 237 return 0;
236} 238}
239EXPORT_SYMBOL(cx88_ir_start);
237 240
238void cx88_ir_stop(struct cx88_core *core) 241void cx88_ir_stop(struct cx88_core *core)
239{ 242{
240 if (core->ir->users) 243 if (core->ir->users)
241 __cx88_ir_stop(core); 244 __cx88_ir_stop(core);
242} 245}
246EXPORT_SYMBOL(cx88_ir_stop);
243 247
244static int cx88_ir_open(struct rc_dev *rc) 248static int cx88_ir_open(struct rc_dev *rc)
245{ 249{
@@ -511,7 +515,7 @@ int cx88_ir_fini(struct cx88_core *core)
511 struct cx88_IR *ir = core->ir; 515 struct cx88_IR *ir = core->ir;
512 516
513 /* skip detach on non attached boards */ 517 /* skip detach on non attached boards */
514 if (NULL == ir) 518 if (!ir)
515 return 0; 519 return 0;
516 520
517 cx88_ir_stop(core); 521 cx88_ir_stop(core);
@@ -529,7 +533,7 @@ void cx88_ir_irq(struct cx88_core *core)
529{ 533{
530 struct cx88_IR *ir = core->ir; 534 struct cx88_IR *ir = core->ir;
531 u32 samples; 535 u32 samples;
532 unsigned todo, bits; 536 unsigned int todo, bits;
533 struct ir_raw_event ev; 537 struct ir_raw_event ev;
534 538
535 if (!ir || !ir->sampling) 539 if (!ir || !ir->sampling)
@@ -579,7 +583,7 @@ static int get_key_pvr2000(struct IR_i2c *ir, enum rc_type *protocol,
579 } 583 }
580 584
581 dprintk("IR Key/Flags: (0x%02x/0x%02x)\n", 585 dprintk("IR Key/Flags: (0x%02x/0x%02x)\n",
582 code & 0xff, flags & 0xff); 586 code & 0xff, flags & 0xff);
583 587
584 *protocol = RC_TYPE_UNKNOWN; 588 *protocol = RC_TYPE_UNKNOWN;
585 *scancode = code & 0xff; 589 *scancode = code & 0xff;
@@ -601,7 +605,7 @@ void cx88_i2c_init_ir(struct cx88_core *core)
601 const unsigned short *addr_list = default_addr_list; 605 const unsigned short *addr_list = default_addr_list;
602 const unsigned short *addrp; 606 const unsigned short *addrp;
603 /* Instantiate the IR receiver device, if present */ 607 /* Instantiate the IR receiver device, if present */
604 if (0 != core->i2c_rc) 608 if (core->i2c_rc != 0)
605 return; 609 return;
606 610
607 memset(&info, 0, sizeof(struct i2c_board_info)); 611 memset(&info, 0, sizeof(struct i2c_board_info));
@@ -639,8 +643,8 @@ void cx88_i2c_init_ir(struct cx88_core *core)
639 info.platform_data = &core->init_data; 643 info.platform_data = &core->init_data;
640 } 644 }
641 if (i2c_smbus_xfer(&core->i2c_adap, *addrp, 0, 645 if (i2c_smbus_xfer(&core->i2c_adap, *addrp, 0,
642 I2C_SMBUS_READ, 0, 646 I2C_SMBUS_READ, 0,
643 I2C_SMBUS_QUICK, NULL) >= 0) { 647 I2C_SMBUS_QUICK, NULL) >= 0) {
644 info.addr = *addrp; 648 info.addr = *addrp;
645 i2c_new_device(&core->i2c_adap, &info); 649 i2c_new_device(&core->i2c_adap, &info);
646 break; 650 break;
diff --git a/drivers/media/pci/cx88/cx88-mpeg.c b/drivers/media/pci/cx88/cx88-mpeg.c
index 245357adbc25..52ff00ebd4bd 100644
--- a/drivers/media/pci/cx88/cx88-mpeg.c
+++ b/drivers/media/pci/cx88/cx88-mpeg.c
@@ -16,21 +16,17 @@
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
21#include "cx88.h"
22
25#include <linux/module.h> 23#include <linux/module.h>
26#include <linux/slab.h> 24#include <linux/slab.h>
27#include <linux/init.h> 25#include <linux/init.h>
28#include <linux/device.h> 26#include <linux/device.h>
29#include <linux/dma-mapping.h> 27#include <linux/dma-mapping.h>
30#include <linux/interrupt.h> 28#include <linux/interrupt.h>
31#include <asm/delay.h> 29#include <linux/delay.h>
32
33#include "cx88.h"
34 30
35/* ------------------------------------------------------------------ */ 31/* ------------------------------------------------------------------ */
36 32
@@ -42,23 +38,20 @@ MODULE_LICENSE("GPL");
42MODULE_VERSION(CX88_VERSION); 38MODULE_VERSION(CX88_VERSION);
43 39
44static unsigned int debug; 40static unsigned int debug;
45module_param(debug,int,0644); 41module_param(debug, int, 0644);
46MODULE_PARM_DESC(debug,"enable debug messages [mpeg]"); 42MODULE_PARM_DESC(debug, "enable debug messages [mpeg]");
47 43
48#define dprintk(level, fmt, arg...) do { \ 44#define dprintk(level, fmt, arg...) do { \
49 if (debug + 1 > level) \ 45 if (debug + 1 > level) \
50 printk(KERN_DEBUG "%s/2-mpeg: " fmt, dev->core->name, ## arg); \ 46 printk(KERN_DEBUG pr_fmt("%s: mpeg:" fmt), \
51} while(0) 47 __func__, ##arg); \
52 48} while (0)
53#define mpeg_dbg(level, fmt, arg...) do { \
54 if (debug + 1 > level) \
55 printk(KERN_DEBUG "%s/2-mpeg: " fmt, core->name, ## arg); \
56} while(0)
57 49
58#if defined(CONFIG_MODULES) && defined(MODULE) 50#if defined(CONFIG_MODULES) && defined(MODULE)
59static void request_module_async(struct work_struct *work) 51static void request_module_async(struct work_struct *work)
60{ 52{
61 struct cx8802_dev *dev=container_of(work, struct cx8802_dev, request_module_wk); 53 struct cx8802_dev *dev = container_of(work, struct cx8802_dev,
54 request_module_wk);
62 55
63 if (dev->core->board.mpeg & CX88_MPEG_DVB) 56 if (dev->core->board.mpeg & CX88_MPEG_DVB)
64 request_module("cx88-dvb"); 57 request_module("cx88-dvb");
@@ -81,18 +74,17 @@ static void flush_request_modules(struct cx8802_dev *dev)
81#define flush_request_modules(dev) 74#define flush_request_modules(dev)
82#endif /* CONFIG_MODULES */ 75#endif /* CONFIG_MODULES */
83 76
84
85static LIST_HEAD(cx8802_devlist); 77static LIST_HEAD(cx8802_devlist);
86static DEFINE_MUTEX(cx8802_mutex); 78static DEFINE_MUTEX(cx8802_mutex);
87/* ------------------------------------------------------------------ */ 79/* ------------------------------------------------------------------ */
88 80
89int cx8802_start_dma(struct cx8802_dev *dev, 81int cx8802_start_dma(struct cx8802_dev *dev,
90 struct cx88_dmaqueue *q, 82 struct cx88_dmaqueue *q,
91 struct cx88_buffer *buf) 83 struct cx88_buffer *buf)
92{ 84{
93 struct cx88_core *core = dev->core; 85 struct cx88_core *core = dev->core;
94 86
95 dprintk(1, "cx8802_start_dma w: %d, h: %d, f: %d\n", 87 dprintk(1, "w: %d, h: %d, f: %d\n",
96 core->width, core->height, core->field); 88 core->width, core->height, core->field);
97 89
98 /* setup fifo + format */ 90 /* setup fifo + format */
@@ -102,33 +94,35 @@ int cx8802_start_dma(struct cx8802_dev *dev,
102 /* write TS length to chip */ 94 /* write TS length to chip */
103 cx_write(MO_TS_LNGTH, dev->ts_packet_size); 95 cx_write(MO_TS_LNGTH, dev->ts_packet_size);
104 96
105 /* FIXME: this needs a review. 97 /*
106 * also: move to cx88-blackbird + cx88-dvb source files? */ 98 * FIXME: this needs a review.
99 * also: move to cx88-blackbird + cx88-dvb source files?
100 */
107 101
108 dprintk( 1, "core->active_type_id = 0x%08x\n", core->active_type_id); 102 dprintk(1, "core->active_type_id = 0x%08x\n", core->active_type_id);
109 103
110 if ( (core->active_type_id == CX88_MPEG_DVB) && 104 if ((core->active_type_id == CX88_MPEG_DVB) &&
111 (core->board.mpeg & CX88_MPEG_DVB) ) { 105 (core->board.mpeg & CX88_MPEG_DVB)) {
112 106 dprintk(1, "cx8802_start_dma doing .dvb\n");
113 dprintk( 1, "cx8802_start_dma doing .dvb\n");
114 /* negedge driven & software reset */ 107 /* negedge driven & software reset */
115 cx_write(TS_GEN_CNTRL, 0x0040 | dev->ts_gen_cntrl); 108 cx_write(TS_GEN_CNTRL, 0x0040 | dev->ts_gen_cntrl);
116 udelay(100); 109 udelay(100);
117 cx_write(MO_PINMUX_IO, 0x00); 110 cx_write(MO_PINMUX_IO, 0x00);
118 cx_write(TS_HW_SOP_CNTRL, 0x47<<16|188<<4|0x01); 111 cx_write(TS_HW_SOP_CNTRL, 0x47 << 16 | 188 << 4 | 0x01);
119 switch (core->boardnr) { 112 switch (core->boardnr) {
120 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q: 113 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
121 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T: 114 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
122 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: 115 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
123 case CX88_BOARD_PCHDTV_HD5500: 116 case CX88_BOARD_PCHDTV_HD5500:
124 cx_write(TS_SOP_STAT, 1<<13); 117 cx_write(TS_SOP_STAT, 1 << 13);
125 break; 118 break;
126 case CX88_BOARD_SAMSUNG_SMT_7020: 119 case CX88_BOARD_SAMSUNG_SMT_7020:
127 cx_write(TS_SOP_STAT, 0x00); 120 cx_write(TS_SOP_STAT, 0x00);
128 break; 121 break;
129 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 122 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
130 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: 123 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
131 cx_write(MO_PINMUX_IO, 0x88); /* Enable MPEG parallel IO and video signal pins */ 124 /* Enable MPEG parallel IO and video signal pins */
125 cx_write(MO_PINMUX_IO, 0x88);
132 udelay(100); 126 udelay(100);
133 break; 127 break;
134 case CX88_BOARD_HAUPPAUGE_HVR1300: 128 case CX88_BOARD_HAUPPAUGE_HVR1300:
@@ -152,22 +146,24 @@ int cx8802_start_dma(struct cx8802_dev *dev,
152 } 146 }
153 cx_write(TS_GEN_CNTRL, dev->ts_gen_cntrl); 147 cx_write(TS_GEN_CNTRL, dev->ts_gen_cntrl);
154 udelay(100); 148 udelay(100);
155 } else if ( (core->active_type_id == CX88_MPEG_BLACKBIRD) && 149 } else if ((core->active_type_id == CX88_MPEG_BLACKBIRD) &&
156 (core->board.mpeg & CX88_MPEG_BLACKBIRD) ) { 150 (core->board.mpeg & CX88_MPEG_BLACKBIRD)) {
157 dprintk( 1, "cx8802_start_dma doing .blackbird\n"); 151 dprintk(1, "cx8802_start_dma doing .blackbird\n");
158 cx_write(MO_PINMUX_IO, 0x88); /* enable MPEG parallel IO */ 152 cx_write(MO_PINMUX_IO, 0x88); /* enable MPEG parallel IO */
159 153
160 cx_write(TS_GEN_CNTRL, 0x46); /* punctured clock TS & posedge driven & software reset */ 154 /* punctured clock TS & posedge driven & software reset */
155 cx_write(TS_GEN_CNTRL, 0x46);
161 udelay(100); 156 udelay(100);
162 157
163 cx_write(TS_HW_SOP_CNTRL, 0x408); /* mpeg start byte */ 158 cx_write(TS_HW_SOP_CNTRL, 0x408); /* mpeg start byte */
164 cx_write(TS_VALERR_CNTRL, 0x2000); 159 cx_write(TS_VALERR_CNTRL, 0x2000);
165 160
166 cx_write(TS_GEN_CNTRL, 0x06); /* punctured clock TS & posedge driven */ 161 /* punctured clock TS & posedge driven */
162 cx_write(TS_GEN_CNTRL, 0x06);
167 udelay(100); 163 udelay(100);
168 } else { 164 } else {
169 printk( "%s() Failed. Unsupported value in .mpeg (0x%08x)\n", __func__, 165 pr_err("%s() Failed. Unsupported value in .mpeg (0x%08x)\n",
170 core->board.mpeg ); 166 __func__, core->board.mpeg);
171 return -EINVAL; 167 return -EINVAL;
172 } 168 }
173 169
@@ -176,20 +172,22 @@ int cx8802_start_dma(struct cx8802_dev *dev,
176 q->count = 0; 172 q->count = 0;
177 173
178 /* enable irqs */ 174 /* enable irqs */
179 dprintk( 1, "setting the interrupt mask\n" ); 175 dprintk(1, "setting the interrupt mask\n");
180 cx_set(MO_PCI_INTMSK, core->pci_irqmask | PCI_INT_TSINT); 176 cx_set(MO_PCI_INTMSK, core->pci_irqmask | PCI_INT_TSINT);
181 cx_set(MO_TS_INTMSK, 0x1f0011); 177 cx_set(MO_TS_INTMSK, 0x1f0011);
182 178
183 /* start dma */ 179 /* start dma */
184 cx_set(MO_DEV_CNTRL2, (1<<5)); 180 cx_set(MO_DEV_CNTRL2, (1 << 5));
185 cx_set(MO_TS_DMACNTRL, 0x11); 181 cx_set(MO_TS_DMACNTRL, 0x11);
186 return 0; 182 return 0;
187} 183}
184EXPORT_SYMBOL(cx8802_start_dma);
188 185
189static int cx8802_stop_dma(struct cx8802_dev *dev) 186static int cx8802_stop_dma(struct cx8802_dev *dev)
190{ 187{
191 struct cx88_core *core = dev->core; 188 struct cx88_core *core = dev->core;
192 dprintk( 1, "cx8802_stop_dma\n" ); 189
190 dprintk(1, "\n");
193 191
194 /* stop dma */ 192 /* stop dma */
195 cx_clear(MO_TS_DMACNTRL, 0x11); 193 cx_clear(MO_TS_DMACNTRL, 0x11);
@@ -208,12 +206,12 @@ static int cx8802_restart_queue(struct cx8802_dev *dev,
208{ 206{
209 struct cx88_buffer *buf; 207 struct cx88_buffer *buf;
210 208
211 dprintk( 1, "cx8802_restart_queue\n" ); 209 dprintk(1, "\n");
212 if (list_empty(&q->active)) 210 if (list_empty(&q->active))
213 return 0; 211 return 0;
214 212
215 buf = list_entry(q->active.next, struct cx88_buffer, list); 213 buf = list_entry(q->active.next, struct cx88_buffer, list);
216 dprintk(2,"restart_queue [%p/%d]: restart dma\n", 214 dprintk(2, "restart_queue [%p/%d]: restart dma\n",
217 buf, buf->vb.vb2_buf.index); 215 buf, buf->vb.vb2_buf.index);
218 cx8802_start_dma(dev, q, buf); 216 cx8802_start_dma(dev, q, buf);
219 return 0; 217 return 0;
@@ -222,7 +220,7 @@ static int cx8802_restart_queue(struct cx8802_dev *dev,
222/* ------------------------------------------------------------------ */ 220/* ------------------------------------------------------------------ */
223 221
224int cx8802_buf_prepare(struct vb2_queue *q, struct cx8802_dev *dev, 222int cx8802_buf_prepare(struct vb2_queue *q, struct cx8802_dev *dev,
225 struct cx88_buffer *buf) 223 struct cx88_buffer *buf)
226{ 224{
227 int size = dev->ts_packet_size * dev->ts_packet_count; 225 int size = dev->ts_packet_size * dev->ts_packet_count;
228 struct sg_table *sgt = vb2_dma_sg_plane_desc(&buf->vb.vb2_buf, 0); 226 struct sg_table *sgt = vb2_dma_sg_plane_desc(&buf->vb.vb2_buf, 0);
@@ -234,43 +232,46 @@ int cx8802_buf_prepare(struct vb2_queue *q, struct cx8802_dev *dev,
234 vb2_set_plane_payload(&buf->vb.vb2_buf, 0, size); 232 vb2_set_plane_payload(&buf->vb.vb2_buf, 0, size);
235 233
236 rc = cx88_risc_databuffer(dev->pci, risc, sgt->sgl, 234 rc = cx88_risc_databuffer(dev->pci, risc, sgt->sgl,
237 dev->ts_packet_size, dev->ts_packet_count, 0); 235 dev->ts_packet_size, dev->ts_packet_count, 0);
238 if (rc) { 236 if (rc) {
239 if (risc->cpu) 237 if (risc->cpu)
240 pci_free_consistent(dev->pci, risc->size, risc->cpu, risc->dma); 238 pci_free_consistent(dev->pci, risc->size,
239 risc->cpu, risc->dma);
241 memset(risc, 0, sizeof(*risc)); 240 memset(risc, 0, sizeof(*risc));
242 return rc; 241 return rc;
243 } 242 }
244 return 0; 243 return 0;
245} 244}
245EXPORT_SYMBOL(cx8802_buf_prepare);
246 246
247void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf) 247void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf)
248{ 248{
249 struct cx88_buffer *prev; 249 struct cx88_buffer *prev;
250 struct cx88_dmaqueue *cx88q = &dev->mpegq; 250 struct cx88_dmaqueue *cx88q = &dev->mpegq;
251 251
252 dprintk( 1, "cx8802_buf_queue\n" ); 252 dprintk(1, "\n");
253 /* add jump to start */ 253 /* add jump to start */
254 buf->risc.cpu[1] = cpu_to_le32(buf->risc.dma + 8); 254 buf->risc.cpu[1] = cpu_to_le32(buf->risc.dma + 8);
255 buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_CNT_INC); 255 buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_CNT_INC);
256 buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma + 8); 256 buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma + 8);
257 257
258 if (list_empty(&cx88q->active)) { 258 if (list_empty(&cx88q->active)) {
259 dprintk( 1, "queue is empty - first active\n" ); 259 dprintk(1, "queue is empty - first active\n");
260 list_add_tail(&buf->list, &cx88q->active); 260 list_add_tail(&buf->list, &cx88q->active);
261 dprintk(1,"[%p/%d] %s - first active\n", 261 dprintk(1, "[%p/%d] %s - first active\n",
262 buf, buf->vb.vb2_buf.index, __func__); 262 buf, buf->vb.vb2_buf.index, __func__);
263 263
264 } else { 264 } else {
265 buf->risc.cpu[0] |= cpu_to_le32(RISC_IRQ1); 265 buf->risc.cpu[0] |= cpu_to_le32(RISC_IRQ1);
266 dprintk( 1, "queue is not empty - append to active\n" ); 266 dprintk(1, "queue is not empty - append to active\n");
267 prev = list_entry(cx88q->active.prev, struct cx88_buffer, list); 267 prev = list_entry(cx88q->active.prev, struct cx88_buffer, list);
268 list_add_tail(&buf->list, &cx88q->active); 268 list_add_tail(&buf->list, &cx88q->active);
269 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); 269 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
270 dprintk( 1, "[%p/%d] %s - append to active\n", 270 dprintk(1, "[%p/%d] %s - append to active\n",
271 buf, buf->vb.vb2_buf.index, __func__); 271 buf, buf->vb.vb2_buf.index, __func__);
272 } 272 }
273} 273}
274EXPORT_SYMBOL(cx8802_buf_queue);
274 275
275/* ----------------------------------------------------------- */ 276/* ----------------------------------------------------------- */
276 277
@@ -280,23 +281,24 @@ static void do_cancel_buffers(struct cx8802_dev *dev)
280 struct cx88_buffer *buf; 281 struct cx88_buffer *buf;
281 unsigned long flags; 282 unsigned long flags;
282 283
283 spin_lock_irqsave(&dev->slock,flags); 284 spin_lock_irqsave(&dev->slock, flags);
284 while (!list_empty(&q->active)) { 285 while (!list_empty(&q->active)) {
285 buf = list_entry(q->active.next, struct cx88_buffer, list); 286 buf = list_entry(q->active.next, struct cx88_buffer, list);
286 list_del(&buf->list); 287 list_del(&buf->list);
287 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); 288 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
288 } 289 }
289 spin_unlock_irqrestore(&dev->slock,flags); 290 spin_unlock_irqrestore(&dev->slock, flags);
290} 291}
291 292
292void cx8802_cancel_buffers(struct cx8802_dev *dev) 293void cx8802_cancel_buffers(struct cx8802_dev *dev)
293{ 294{
294 dprintk( 1, "cx8802_cancel_buffers" ); 295 dprintk(1, "\n");
295 cx8802_stop_dma(dev); 296 cx8802_stop_dma(dev);
296 do_cancel_buffers(dev); 297 do_cancel_buffers(dev);
297} 298}
299EXPORT_SYMBOL(cx8802_cancel_buffers);
298 300
299static const char * cx88_mpeg_irqs[32] = { 301static const char *cx88_mpeg_irqs[32] = {
300 "ts_risci1", NULL, NULL, NULL, 302 "ts_risci1", NULL, NULL, NULL,
301 "ts_risci2", NULL, NULL, NULL, 303 "ts_risci2", NULL, NULL, NULL,
302 "ts_oflow", NULL, NULL, NULL, 304 "ts_oflow", NULL, NULL, NULL,
@@ -310,7 +312,7 @@ static void cx8802_mpeg_irq(struct cx8802_dev *dev)
310 struct cx88_core *core = dev->core; 312 struct cx88_core *core = dev->core;
311 u32 status, mask, count; 313 u32 status, mask, count;
312 314
313 dprintk( 1, "cx8802_mpeg_irq\n" ); 315 dprintk(1, "\n");
314 status = cx_read(MO_TS_INTSTAT); 316 status = cx_read(MO_TS_INTSTAT);
315 mask = cx_read(MO_TS_INTMSK); 317 mask = cx_read(MO_TS_INTMSK);
316 if (0 == (status & mask)) 318 if (0 == (status & mask))
@@ -319,20 +321,21 @@ static void cx8802_mpeg_irq(struct cx8802_dev *dev)
319 cx_write(MO_TS_INTSTAT, status); 321 cx_write(MO_TS_INTSTAT, status);
320 322
321 if (debug || (status & mask & ~0xff)) 323 if (debug || (status & mask & ~0xff))
322 cx88_print_irqbits(core->name, "irq mpeg ", 324 cx88_print_irqbits("irq mpeg ",
323 cx88_mpeg_irqs, ARRAY_SIZE(cx88_mpeg_irqs), 325 cx88_mpeg_irqs, ARRAY_SIZE(cx88_mpeg_irqs),
324 status, mask); 326 status, mask);
325 327
326 /* risc op code error */ 328 /* risc op code error */
327 if (status & (1 << 16)) { 329 if (status & (1 << 16)) {
328 printk(KERN_WARNING "%s: mpeg risc op code error\n",core->name); 330 pr_warn("mpeg risc op code error\n");
329 cx_clear(MO_TS_DMACNTRL, 0x11); 331 cx_clear(MO_TS_DMACNTRL, 0x11);
330 cx88_sram_channel_dump(dev->core, &cx88_sram_channels[SRAM_CH28]); 332 cx88_sram_channel_dump(dev->core,
333 &cx88_sram_channels[SRAM_CH28]);
331 } 334 }
332 335
333 /* risc1 y */ 336 /* risc1 y */
334 if (status & 0x01) { 337 if (status & 0x01) {
335 dprintk( 1, "wake up\n" ); 338 dprintk(1, "wake up\n");
336 spin_lock(&dev->slock); 339 spin_lock(&dev->slock);
337 count = cx_read(MO_TS_GPCNT); 340 count = cx_read(MO_TS_GPCNT);
338 cx88_wakeup(dev->core, &dev->mpegq, count); 341 cx88_wakeup(dev->core, &dev->mpegq, count);
@@ -341,7 +344,7 @@ static void cx8802_mpeg_irq(struct cx8802_dev *dev)
341 344
342 /* other general errors */ 345 /* other general errors */
343 if (status & 0x1f0100) { 346 if (status & 0x1f0100) {
344 dprintk( 0, "general errors: 0x%08x\n", status & 0x1f0100 ); 347 dprintk(0, "general errors: 0x%08x\n", status & 0x1f0100);
345 spin_lock(&dev->slock); 348 spin_lock(&dev->slock);
346 cx8802_stop_dma(dev); 349 cx8802_stop_dma(dev);
347 spin_unlock(&dev->slock); 350 spin_unlock(&dev->slock);
@@ -360,24 +363,23 @@ static irqreturn_t cx8802_irq(int irq, void *dev_id)
360 for (loop = 0; loop < MAX_IRQ_LOOP; loop++) { 363 for (loop = 0; loop < MAX_IRQ_LOOP; loop++) {
361 status = cx_read(MO_PCI_INTSTAT) & 364 status = cx_read(MO_PCI_INTSTAT) &
362 (core->pci_irqmask | PCI_INT_TSINT); 365 (core->pci_irqmask | PCI_INT_TSINT);
363 if (0 == status) 366 if (status == 0)
364 goto out; 367 goto out;
365 dprintk( 1, "cx8802_irq\n" ); 368 dprintk(1, "cx8802_irq\n");
366 dprintk( 1, " loop: %d/%d\n", loop, MAX_IRQ_LOOP ); 369 dprintk(1, " loop: %d/%d\n", loop, MAX_IRQ_LOOP);
367 dprintk( 1, " status: %d\n", status ); 370 dprintk(1, " status: %d\n", status);
368 handled = 1; 371 handled = 1;
369 cx_write(MO_PCI_INTSTAT, status); 372 cx_write(MO_PCI_INTSTAT, status);
370 373
371 if (status & core->pci_irqmask) 374 if (status & core->pci_irqmask)
372 cx88_core_irq(core,status); 375 cx88_core_irq(core, status);
373 if (status & PCI_INT_TSINT) 376 if (status & PCI_INT_TSINT)
374 cx8802_mpeg_irq(dev); 377 cx8802_mpeg_irq(dev);
375 } 378 }
376 if (MAX_IRQ_LOOP == loop) { 379 if (loop == MAX_IRQ_LOOP) {
377 dprintk( 0, "clearing mask\n" ); 380 dprintk(0, "clearing mask\n");
378 printk(KERN_WARNING "%s/0: irq loop -- clearing mask\n", 381 pr_warn("irq loop -- clearing mask\n");
379 core->name); 382 cx_write(MO_PCI_INTMSK, 0);
380 cx_write(MO_PCI_INTMSK,0);
381 } 383 }
382 384
383 out: 385 out:
@@ -393,18 +395,18 @@ static int cx8802_init_common(struct cx8802_dev *dev)
393 if (pci_enable_device(dev->pci)) 395 if (pci_enable_device(dev->pci))
394 return -EIO; 396 return -EIO;
395 pci_set_master(dev->pci); 397 pci_set_master(dev->pci);
396 err = pci_set_dma_mask(dev->pci,DMA_BIT_MASK(32)); 398 err = pci_set_dma_mask(dev->pci, DMA_BIT_MASK(32));
397 if (err) { 399 if (err) {
398 printk("%s/2: Oops: no 32bit PCI DMA ???\n",dev->core->name); 400 pr_err("Oops: no 32bit PCI DMA ???\n");
399 return -EIO; 401 return -EIO;
400 } 402 }
401 403
402 dev->pci_rev = dev->pci->revision; 404 dev->pci_rev = dev->pci->revision;
403 pci_read_config_byte(dev->pci, PCI_LATENCY_TIMER, &dev->pci_lat); 405 pci_read_config_byte(dev->pci, PCI_LATENCY_TIMER, &dev->pci_lat);
404 printk(KERN_INFO "%s/2: found at %s, rev: %d, irq: %d, " 406 pr_info("found at %s, rev: %d, irq: %d, latency: %d, mmio: 0x%llx\n",
405 "latency: %d, mmio: 0x%llx\n", dev->core->name, 407 pci_name(dev->pci), dev->pci_rev, dev->pci->irq,
406 pci_name(dev->pci), dev->pci_rev, dev->pci->irq, 408 dev->pci_lat,
407 dev->pci_lat,(unsigned long long)pci_resource_start(dev->pci,0)); 409 (unsigned long long)pci_resource_start(dev->pci, 0));
408 410
409 /* initialize driver struct */ 411 /* initialize driver struct */
410 spin_lock_init(&dev->slock); 412 spin_lock_init(&dev->slock);
@@ -416,20 +418,19 @@ static int cx8802_init_common(struct cx8802_dev *dev)
416 err = request_irq(dev->pci->irq, cx8802_irq, 418 err = request_irq(dev->pci->irq, cx8802_irq,
417 IRQF_SHARED, dev->core->name, dev); 419 IRQF_SHARED, dev->core->name, dev);
418 if (err < 0) { 420 if (err < 0) {
419 printk(KERN_ERR "%s: can't get IRQ %d\n", 421 pr_err("can't get IRQ %d\n", dev->pci->irq);
420 dev->core->name, dev->pci->irq);
421 return err; 422 return err;
422 } 423 }
423 cx_set(MO_PCI_INTMSK, core->pci_irqmask); 424 cx_set(MO_PCI_INTMSK, core->pci_irqmask);
424 425
425 /* everything worked */ 426 /* everything worked */
426 pci_set_drvdata(dev->pci,dev); 427 pci_set_drvdata(dev->pci, dev);
427 return 0; 428 return 0;
428} 429}
429 430
430static void cx8802_fini_common(struct cx8802_dev *dev) 431static void cx8802_fini_common(struct cx8802_dev *dev)
431{ 432{
432 dprintk( 2, "cx8802_fini_common\n" ); 433 dprintk(2, "\n");
433 cx8802_stop_dma(dev); 434 cx8802_stop_dma(dev);
434 pci_disable_device(dev->pci); 435 pci_disable_device(dev->pci);
435 436
@@ -442,14 +443,13 @@ static void cx8802_fini_common(struct cx8802_dev *dev)
442static int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state) 443static int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state)
443{ 444{
444 struct cx8802_dev *dev = pci_get_drvdata(pci_dev); 445 struct cx8802_dev *dev = pci_get_drvdata(pci_dev);
445 struct cx88_core *core = dev->core;
446 unsigned long flags; 446 unsigned long flags;
447 447
448 /* stop mpeg dma */ 448 /* stop mpeg dma */
449 spin_lock_irqsave(&dev->slock, flags); 449 spin_lock_irqsave(&dev->slock, flags);
450 if (!list_empty(&dev->mpegq.active)) { 450 if (!list_empty(&dev->mpegq.active)) {
451 dprintk( 2, "suspend\n" ); 451 dprintk(2, "suspend\n");
452 printk("%s: suspend mpeg\n", core->name); 452 pr_info("suspend mpeg\n");
453 cx8802_stop_dma(dev); 453 cx8802_stop_dma(dev);
454 } 454 }
455 spin_unlock_irqrestore(&dev->slock, flags); 455 spin_unlock_irqrestore(&dev->slock, flags);
@@ -458,7 +458,8 @@ static int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state)
458 cx88_shutdown(dev->core); 458 cx88_shutdown(dev->core);
459 459
460 pci_save_state(pci_dev); 460 pci_save_state(pci_dev);
461 if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) { 461 if (pci_set_power_state(pci_dev,
462 pci_choose_state(pci_dev, state)) != 0) {
462 pci_disable_device(pci_dev); 463 pci_disable_device(pci_dev);
463 dev->state.disabled = 1; 464 dev->state.disabled = 1;
464 } 465 }
@@ -468,23 +469,20 @@ static int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state)
468static int cx8802_resume_common(struct pci_dev *pci_dev) 469static int cx8802_resume_common(struct pci_dev *pci_dev)
469{ 470{
470 struct cx8802_dev *dev = pci_get_drvdata(pci_dev); 471 struct cx8802_dev *dev = pci_get_drvdata(pci_dev);
471 struct cx88_core *core = dev->core;
472 unsigned long flags; 472 unsigned long flags;
473 int err; 473 int err;
474 474
475 if (dev->state.disabled) { 475 if (dev->state.disabled) {
476 err=pci_enable_device(pci_dev); 476 err = pci_enable_device(pci_dev);
477 if (err) { 477 if (err) {
478 printk(KERN_ERR "%s: can't enable device\n", 478 pr_err("can't enable device\n");
479 dev->core->name);
480 return err; 479 return err;
481 } 480 }
482 dev->state.disabled = 0; 481 dev->state.disabled = 0;
483 } 482 }
484 err=pci_set_power_state(pci_dev, PCI_D0); 483 err = pci_set_power_state(pci_dev, PCI_D0);
485 if (err) { 484 if (err) {
486 printk(KERN_ERR "%s: can't enable device\n", 485 pr_err("can't enable device\n");
487 dev->core->name);
488 pci_disable_device(pci_dev); 486 pci_disable_device(pci_dev);
489 dev->state.disabled = 1; 487 dev->state.disabled = 1;
490 488
@@ -498,15 +496,16 @@ static int cx8802_resume_common(struct pci_dev *pci_dev)
498 /* restart video+vbi capture */ 496 /* restart video+vbi capture */
499 spin_lock_irqsave(&dev->slock, flags); 497 spin_lock_irqsave(&dev->slock, flags);
500 if (!list_empty(&dev->mpegq.active)) { 498 if (!list_empty(&dev->mpegq.active)) {
501 printk("%s: resume mpeg\n", core->name); 499 pr_info("resume mpeg\n");
502 cx8802_restart_queue(dev,&dev->mpegq); 500 cx8802_restart_queue(dev, &dev->mpegq);
503 } 501 }
504 spin_unlock_irqrestore(&dev->slock, flags); 502 spin_unlock_irqrestore(&dev->slock, flags);
505 503
506 return 0; 504 return 0;
507} 505}
508 506
509struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype) 507struct cx8802_driver *cx8802_get_driver(struct cx8802_dev *dev,
508 enum cx88_board_type btype)
510{ 509{
511 struct cx8802_driver *d; 510 struct cx8802_driver *d;
512 511
@@ -516,6 +515,7 @@ struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board
516 515
517 return NULL; 516 return NULL;
518} 517}
518EXPORT_SYMBOL(cx8802_get_driver);
519 519
520/* Driver asked for hardware access. */ 520/* Driver asked for hardware access. */
521static int cx8802_request_acquire(struct cx8802_driver *drv) 521static int cx8802_request_acquire(struct cx8802_driver *drv)
@@ -533,7 +533,8 @@ static int cx8802_request_acquire(struct cx8802_driver *drv)
533 core->last_analog_input = core->input; 533 core->last_analog_input = core->input;
534 core->input = 0; 534 core->input = 0;
535 for (i = 0; 535 for (i = 0;
536 i < (sizeof(core->board.input) / sizeof(struct cx88_input)); 536 i < (sizeof(core->board.input) /
537 sizeof(struct cx88_input));
537 i++) { 538 i++) {
538 if (core->board.input[i].type == CX88_VMUX_DVB) { 539 if (core->board.input[i].type == CX88_VMUX_DVB) {
539 core->input = i; 540 core->input = i;
@@ -542,15 +543,14 @@ static int cx8802_request_acquire(struct cx8802_driver *drv)
542 } 543 }
543 } 544 }
544 545
545 if (drv->advise_acquire) 546 if (drv->advise_acquire) {
546 {
547 core->active_ref++; 547 core->active_ref++;
548 if (core->active_type_id == CX88_BOARD_NONE) { 548 if (core->active_type_id == CX88_BOARD_NONE) {
549 core->active_type_id = drv->type_id; 549 core->active_type_id = drv->type_id;
550 drv->advise_acquire(drv); 550 drv->advise_acquire(drv);
551 } 551 }
552 552
553 mpeg_dbg(1,"%s() Post acquire GPIO=%x\n", __func__, cx_read(MO_GP0_IO)); 553 dprintk(1, "Post acquire GPIO=%x\n", cx_read(MO_GP0_IO));
554 } 554 }
555 555
556 return 0; 556 return 0;
@@ -561,17 +561,18 @@ static int cx8802_request_release(struct cx8802_driver *drv)
561{ 561{
562 struct cx88_core *core = drv->core; 562 struct cx88_core *core = drv->core;
563 563
564 if (drv->advise_release && --core->active_ref == 0) 564 if (drv->advise_release && --core->active_ref == 0) {
565 {
566 if (drv->type_id == CX88_MPEG_DVB) { 565 if (drv->type_id == CX88_MPEG_DVB) {
567 /* If the DVB driver is releasing, reset the input 566 /*
568 state to the last configured analog input */ 567 * If the DVB driver is releasing, reset the input
568 * state to the last configured analog input
569 */
569 core->input = core->last_analog_input; 570 core->input = core->last_analog_input;
570 } 571 }
571 572
572 drv->advise_release(drv); 573 drv->advise_release(drv);
573 core->active_type_id = CX88_BOARD_NONE; 574 core->active_type_id = CX88_BOARD_NONE;
574 mpeg_dbg(1,"%s() Post release GPIO=%x\n", __func__, cx_read(MO_GP0_IO)); 575 dprintk(1, "Post release GPIO=%x\n", cx_read(MO_GP0_IO));
575 } 576 }
576 577
577 return 0; 578 return 0;
@@ -579,21 +580,21 @@ static int cx8802_request_release(struct cx8802_driver *drv)
579 580
580static int cx8802_check_driver(struct cx8802_driver *drv) 581static int cx8802_check_driver(struct cx8802_driver *drv)
581{ 582{
582 if (drv == NULL) 583 if (!drv)
583 return -ENODEV; 584 return -ENODEV;
584 585
585 if ((drv->type_id != CX88_MPEG_DVB) && 586 if ((drv->type_id != CX88_MPEG_DVB) &&
586 (drv->type_id != CX88_MPEG_BLACKBIRD)) 587 (drv->type_id != CX88_MPEG_BLACKBIRD))
587 return -EINVAL; 588 return -EINVAL;
588 589
589 if ((drv->hw_access != CX8802_DRVCTL_SHARED) && 590 if ((drv->hw_access != CX8802_DRVCTL_SHARED) &&
590 (drv->hw_access != CX8802_DRVCTL_EXCLUSIVE)) 591 (drv->hw_access != CX8802_DRVCTL_EXCLUSIVE))
591 return -EINVAL; 592 return -EINVAL;
592 593
593 if ((drv->probe == NULL) || 594 if ((!drv->probe) ||
594 (drv->remove == NULL) || 595 (!drv->remove) ||
595 (drv->advise_acquire == NULL) || 596 (!drv->advise_acquire) ||
596 (drv->advise_release == NULL)) 597 (!drv->advise_release))
597 return -EINVAL; 598 return -EINVAL;
598 599
599 return 0; 600 return 0;
@@ -605,28 +606,28 @@ int cx8802_register_driver(struct cx8802_driver *drv)
605 struct cx8802_driver *driver; 606 struct cx8802_driver *driver;
606 int err, i = 0; 607 int err, i = 0;
607 608
608 printk(KERN_INFO 609 pr_info("registering cx8802 driver, type: %s access: %s\n",
609 "cx88/2: registering cx8802 driver, type: %s access: %s\n", 610 drv->type_id == CX88_MPEG_DVB ? "dvb" : "blackbird",
610 drv->type_id == CX88_MPEG_DVB ? "dvb" : "blackbird", 611 drv->hw_access == CX8802_DRVCTL_SHARED ?
611 drv->hw_access == CX8802_DRVCTL_SHARED ? "shared" : "exclusive"); 612 "shared" : "exclusive");
612 613
613 if ((err = cx8802_check_driver(drv)) != 0) { 614 err = cx8802_check_driver(drv);
614 printk(KERN_ERR "cx88/2: cx8802_driver is invalid\n"); 615 if (err) {
616 pr_err("cx8802_driver is invalid\n");
615 return err; 617 return err;
616 } 618 }
617 619
618 mutex_lock(&cx8802_mutex); 620 mutex_lock(&cx8802_mutex);
619 621
620 list_for_each_entry(dev, &cx8802_devlist, devlist) { 622 list_for_each_entry(dev, &cx8802_devlist, devlist) {
621 printk(KERN_INFO 623 pr_info("subsystem: %04x:%04x, board: %s [card=%d]\n",
622 "%s/2: subsystem: %04x:%04x, board: %s [card=%d]\n", 624 dev->pci->subsystem_vendor,
623 dev->core->name, dev->pci->subsystem_vendor, 625 dev->pci->subsystem_device, dev->core->board.name,
624 dev->pci->subsystem_device, dev->core->board.name, 626 dev->core->boardnr);
625 dev->core->boardnr);
626 627
627 /* Bring up a new struct for each driver instance */ 628 /* Bring up a new struct for each driver instance */
628 driver = kzalloc(sizeof(*drv),GFP_KERNEL); 629 driver = kzalloc(sizeof(*drv), GFP_KERNEL);
629 if (driver == NULL) { 630 if (!driver) {
630 err = -ENOMEM; 631 err = -ENOMEM;
631 goto out; 632 goto out;
632 } 633 }
@@ -645,9 +646,7 @@ int cx8802_register_driver(struct cx8802_driver *drv)
645 i++; 646 i++;
646 list_add_tail(&driver->drvlist, &dev->drvlist); 647 list_add_tail(&driver->drvlist, &dev->drvlist);
647 } else { 648 } else {
648 printk(KERN_ERR 649 pr_err("cx8802 probe failed, err = %d\n", err);
649 "%s/2: cx8802 probe failed, err = %d\n",
650 dev->core->name, err);
651 } 650 }
652 mutex_unlock(&drv->core->lock); 651 mutex_unlock(&drv->core->lock);
653 } 652 }
@@ -657,6 +656,7 @@ out:
657 mutex_unlock(&cx8802_mutex); 656 mutex_unlock(&cx8802_mutex);
658 return err; 657 return err;
659} 658}
659EXPORT_SYMBOL(cx8802_register_driver);
660 660
661int cx8802_unregister_driver(struct cx8802_driver *drv) 661int cx8802_unregister_driver(struct cx8802_driver *drv)
662{ 662{
@@ -664,19 +664,18 @@ int cx8802_unregister_driver(struct cx8802_driver *drv)
664 struct cx8802_driver *d, *dtmp; 664 struct cx8802_driver *d, *dtmp;
665 int err = 0; 665 int err = 0;
666 666
667 printk(KERN_INFO 667 pr_info("unregistering cx8802 driver, type: %s access: %s\n",
668 "cx88/2: unregistering cx8802 driver, type: %s access: %s\n", 668 drv->type_id == CX88_MPEG_DVB ? "dvb" : "blackbird",
669 drv->type_id == CX88_MPEG_DVB ? "dvb" : "blackbird", 669 drv->hw_access == CX8802_DRVCTL_SHARED ?
670 drv->hw_access == CX8802_DRVCTL_SHARED ? "shared" : "exclusive"); 670 "shared" : "exclusive");
671 671
672 mutex_lock(&cx8802_mutex); 672 mutex_lock(&cx8802_mutex);
673 673
674 list_for_each_entry(dev, &cx8802_devlist, devlist) { 674 list_for_each_entry(dev, &cx8802_devlist, devlist) {
675 printk(KERN_INFO 675 pr_info("subsystem: %04x:%04x, board: %s [card=%d]\n",
676 "%s/2: subsystem: %04x:%04x, board: %s [card=%d]\n", 676 dev->pci->subsystem_vendor,
677 dev->core->name, dev->pci->subsystem_vendor, 677 dev->pci->subsystem_device, dev->core->board.name,
678 dev->pci->subsystem_device, dev->core->board.name, 678 dev->core->boardnr);
679 dev->core->boardnr);
680 679
681 mutex_lock(&dev->core->lock); 680 mutex_lock(&dev->core->lock);
682 681
@@ -690,8 +689,8 @@ int cx8802_unregister_driver(struct cx8802_driver *drv)
690 list_del(&d->drvlist); 689 list_del(&d->drvlist);
691 kfree(d); 690 kfree(d);
692 } else 691 } else
693 printk(KERN_ERR "%s/2: cx8802 driver remove " 692 pr_err("cx8802 driver remove failed (%d)\n",
694 "failed (%d)\n", dev->core->name, err); 693 err);
695 } 694 }
696 695
697 mutex_unlock(&dev->core->lock); 696 mutex_unlock(&dev->core->lock);
@@ -701,6 +700,7 @@ int cx8802_unregister_driver(struct cx8802_driver *drv)
701 700
702 return err; 701 return err;
703} 702}
703EXPORT_SYMBOL(cx8802_unregister_driver);
704 704
705/* ----------------------------------------------------------- */ 705/* ----------------------------------------------------------- */
706static int cx8802_probe(struct pci_dev *pci_dev, 706static int cx8802_probe(struct pci_dev *pci_dev,
@@ -712,18 +712,18 @@ static int cx8802_probe(struct pci_dev *pci_dev,
712 712
713 /* general setup */ 713 /* general setup */
714 core = cx88_core_get(pci_dev); 714 core = cx88_core_get(pci_dev);
715 if (NULL == core) 715 if (!core)
716 return -EINVAL; 716 return -EINVAL;
717 717
718 printk("%s/2: cx2388x 8802 Driver Manager\n", core->name); 718 pr_info("cx2388x 8802 Driver Manager\n");
719 719
720 err = -ENODEV; 720 err = -ENODEV;
721 if (!core->board.mpeg) 721 if (!core->board.mpeg)
722 goto fail_core; 722 goto fail_core;
723 723
724 err = -ENOMEM; 724 err = -ENOMEM;
725 dev = kzalloc(sizeof(*dev),GFP_KERNEL); 725 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
726 if (NULL == dev) 726 if (!dev)
727 goto fail_core; 727 goto fail_core;
728 dev->pci = pci_dev; 728 dev->pci = pci_dev;
729 dev->core = core; 729 dev->core = core;
@@ -737,7 +737,7 @@ static int cx8802_probe(struct pci_dev *pci_dev,
737 737
738 INIT_LIST_HEAD(&dev->drvlist); 738 INIT_LIST_HEAD(&dev->drvlist);
739 mutex_lock(&cx8802_mutex); 739 mutex_lock(&cx8802_mutex);
740 list_add_tail(&dev->devlist,&cx8802_devlist); 740 list_add_tail(&dev->devlist, &cx8802_devlist);
741 mutex_unlock(&cx8802_mutex); 741 mutex_unlock(&cx8802_mutex);
742 742
743 /* now autoload cx88-dvb or cx88-blackbird */ 743 /* now autoload cx88-dvb or cx88-blackbird */
@@ -748,7 +748,7 @@ static int cx8802_probe(struct pci_dev *pci_dev,
748 kfree(dev); 748 kfree(dev);
749 fail_core: 749 fail_core:
750 core->dvbdev = NULL; 750 core->dvbdev = NULL;
751 cx88_core_put(core,pci_dev); 751 cx88_core_put(core, pci_dev);
752 return err; 752 return err;
753} 753}
754 754
@@ -758,7 +758,7 @@ static void cx8802_remove(struct pci_dev *pci_dev)
758 758
759 dev = pci_get_drvdata(pci_dev); 759 dev = pci_get_drvdata(pci_dev);
760 760
761 dprintk( 1, "%s\n", __func__); 761 dprintk(1, "%s\n", __func__);
762 762
763 flush_request_modules(dev); 763 flush_request_modules(dev);
764 764
@@ -768,17 +768,15 @@ static void cx8802_remove(struct pci_dev *pci_dev)
768 struct cx8802_driver *drv, *tmp; 768 struct cx8802_driver *drv, *tmp;
769 int err; 769 int err;
770 770
771 printk(KERN_WARNING "%s/2: Trying to remove cx8802 driver " 771 pr_warn("Trying to remove cx8802 driver while cx8802 sub-drivers still loaded?!\n");
772 "while cx8802 sub-drivers still loaded?!\n",
773 dev->core->name);
774 772
775 list_for_each_entry_safe(drv, tmp, &dev->drvlist, drvlist) { 773 list_for_each_entry_safe(drv, tmp, &dev->drvlist, drvlist) {
776 err = drv->remove(drv); 774 err = drv->remove(drv);
777 if (err == 0) { 775 if (err == 0) {
778 list_del(&drv->drvlist); 776 list_del(&drv->drvlist);
779 } else 777 } else
780 printk(KERN_ERR "%s/2: cx8802 driver remove " 778 pr_err("cx8802 driver remove failed (%d)\n",
781 "failed (%d)\n", dev->core->name, err); 779 err);
782 kfree(drv); 780 kfree(drv);
783 } 781 }
784 } 782 }
@@ -790,7 +788,7 @@ static void cx8802_remove(struct pci_dev *pci_dev)
790 788
791 /* common */ 789 /* common */
792 cx8802_fini_common(dev); 790 cx8802_fini_common(dev);
793 cx88_core_put(dev->core,dev->pci); 791 cx88_core_put(dev->core, dev->pci);
794 kfree(dev); 792 kfree(dev);
795} 793}
796 794
@@ -800,7 +798,7 @@ static const struct pci_device_id cx8802_pci_tbl[] = {
800 .device = 0x8802, 798 .device = 0x8802,
801 .subvendor = PCI_ANY_ID, 799 .subvendor = PCI_ANY_ID,
802 .subdevice = PCI_ANY_ID, 800 .subdevice = PCI_ANY_ID,
803 },{ 801 }, {
804 /* --- end of list --- */ 802 /* --- end of list --- */
805 } 803 }
806}; 804};
@@ -814,12 +812,3 @@ static struct pci_driver cx8802_pci_driver = {
814}; 812};
815 813
816module_pci_driver(cx8802_pci_driver); 814module_pci_driver(cx8802_pci_driver);
817
818EXPORT_SYMBOL(cx8802_buf_prepare);
819EXPORT_SYMBOL(cx8802_buf_queue);
820EXPORT_SYMBOL(cx8802_cancel_buffers);
821EXPORT_SYMBOL(cx8802_start_dma);
822
823EXPORT_SYMBOL(cx8802_register_driver);
824EXPORT_SYMBOL(cx8802_unregister_driver);
825EXPORT_SYMBOL(cx8802_get_driver);
diff --git a/drivers/media/pci/cx88/cx88-reg.h b/drivers/media/pci/cx88/cx88-reg.h
index 2ec52d1cdea0..f1e1dd634a72 100644
--- a/drivers/media/pci/cx88/cx88-reg.h
+++ b/drivers/media/pci/cx88/cx88-reg.h
@@ -1,32 +1,28 @@
1/* 1/*
2 2 * cx88x-hw.h - CX2388x register offsets
3 cx88x-hw.h - CX2388x register offsets 3 *
4 4 * Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)
5 Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de) 5 * 2001 Michael Eskin
6 2001 Michael Eskin 6 * 2002 Yurij Sysoev <yurij@naturesoft.net>
7 2002 Yurij Sysoev <yurij@naturesoft.net> 7 * 2003 Gerd Knorr <kraxel@bytesex.org>
8 2003 Gerd Knorr <kraxel@bytesex.org> 8 *
9 9 * This program is free software; you can redistribute it and/or modify
10 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 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 the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version.
13 (at your option) any later version. 13 *
14 14 * This program is distributed in the hope that it will be useful,
15 This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details.
18 GNU General Public License for more details. 18 */
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 19
25#ifndef _CX88_REG_H_ 20#ifndef _CX88_REG_H_
26#define _CX88_REG_H_ 21#define _CX88_REG_H_
27 22
28/* ---------------------------------------------------------------------- */ 23/*
29/* PCI IDs and config space */ 24 * PCI IDs and config space
25 */
30 26
31#ifndef PCI_VENDOR_ID_CONEXANT 27#ifndef PCI_VENDOR_ID_CONEXANT
32# define PCI_VENDOR_ID_CONEXANT 0x14F1 28# define PCI_VENDOR_ID_CONEXANT 0x14F1
@@ -39,8 +35,9 @@
39#define CX88X_EN_TBFX 0x02 35#define CX88X_EN_TBFX 0x02
40#define CX88X_EN_VSFX 0x04 36#define CX88X_EN_VSFX 0x04
41 37
42/* ---------------------------------------------------------------------- */ 38/*
43/* PCI controller registers */ 39 * PCI controller registers
40 */
44 41
45/* Command and Status Register */ 42/* Command and Status Register */
46#define F0_CMD_STAT_MM 0x2f0004 43#define F0_CMD_STAT_MM 0x2f0004
@@ -63,8 +60,9 @@
63#define F3_BAR0_MM 0x2f0310 60#define F3_BAR0_MM 0x2f0310
64#define F4_BAR0_MM 0x2f0410 61#define F4_BAR0_MM 0x2f0410
65 62
66/* ---------------------------------------------------------------------- */ 63/*
67/* DMA Controller registers */ 64 * DMA Controller registers
65 */
68 66
69#define MO_PDMA_STHRSH 0x200000 // Source threshold 67#define MO_PDMA_STHRSH 0x200000 // Source threshold
70#define MO_PDMA_STADRS 0x200004 // Source target address 68#define MO_PDMA_STADRS 0x200004 // Source target address
@@ -157,9 +155,9 @@
157#define MO_DMA31_CNT2 0x300168 // {11}RW* DMA Table Size : Ch#31 155#define MO_DMA31_CNT2 0x300168 // {11}RW* DMA Table Size : Ch#31
158#define MO_DMA32_CNT2 0x30016C // {11}RW* DMA Table Size : Ch#32 156#define MO_DMA32_CNT2 0x30016C // {11}RW* DMA Table Size : Ch#32
159 157
160 158/*
161/* ---------------------------------------------------------------------- */ 159 * Video registers
162/* Video registers */ 160 */
163 161
164#define MO_VIDY_DMA 0x310000 // {64}RWp Video Y 162#define MO_VIDY_DMA 0x310000 // {64}RWp Video Y
165#define MO_VIDU_DMA 0x310008 // {64}RWp Video U 163#define MO_VIDU_DMA 0x310008 // {64}RWp Video U
@@ -217,9 +215,9 @@
217#define MO_VID_DMACNTRL 0x31C040 // {8}RW Video DMA control 215#define MO_VID_DMACNTRL 0x31C040 // {8}RW Video DMA control
218#define MO_VID_XFR_STAT 0x31C044 // {1}RO Video transfer status 216#define MO_VID_XFR_STAT 0x31C044 // {1}RO Video transfer status
219 217
220 218/*
221/* ---------------------------------------------------------------------- */ 219 * audio registers
222/* audio registers */ 220 */
223 221
224#define MO_AUDD_DMA 0x320000 // {64}RWp Audio downstream 222#define MO_AUDD_DMA 0x320000 // {64}RWp Audio downstream
225#define MO_AUDU_DMA 0x320008 // {64}RWp Audio upstream 223#define MO_AUDU_DMA 0x320008 // {64}RWp Audio upstream
@@ -437,9 +435,9 @@
437#define AUD_PHACC_FREQ_8LSB 0x320d2b 435#define AUD_PHACC_FREQ_8LSB 0x320d2b
438#define AUD_QAM_MODE 0x320d04 436#define AUD_QAM_MODE 0x320d04
439 437
440 438/*
441/* ---------------------------------------------------------------------- */ 439 * transport stream registers
442/* transport stream registers */ 440 */
443 441
444#define MO_TS_DMA 0x330000 // {64}RWp Transport stream downstream 442#define MO_TS_DMA 0x330000 // {64}RWp Transport stream downstream
445#define MO_TS_GPCNT 0x33C020 // {16}RO TS general purpose counter 443#define MO_TS_GPCNT 0x33C020 // {16}RO TS general purpose counter
@@ -455,9 +453,9 @@
455#define TS_FIFO_OVFL_STAT 0x33C05C 453#define TS_FIFO_OVFL_STAT 0x33C05C
456#define TS_VALERR_CNTRL 0x33C060 454#define TS_VALERR_CNTRL 0x33C060
457 455
458 456/*
459/* ---------------------------------------------------------------------- */ 457 * VIP registers
460/* VIP registers */ 458 */
461 459
462#define MO_VIPD_DMA 0x340000 // {64}RWp VIP downstream 460#define MO_VIPD_DMA 0x340000 // {64}RWp VIP downstream
463#define MO_VIPU_DMA 0x340008 // {64}RWp VIP upstream 461#define MO_VIPU_DMA 0x340008 // {64}RWp VIP upstream
@@ -475,9 +473,9 @@
475#define MO_VIP_INTCNTRL 0x34C05C // VIP Interrupt Control 473#define MO_VIP_INTCNTRL 0x34C05C // VIP Interrupt Control
476#define MO_VIP_XFTERM 0x340060 // VIP transfer terminate 474#define MO_VIP_XFTERM 0x340060 // VIP transfer terminate
477 475
478 476/*
479/* ---------------------------------------------------------------------- */ 477 * misc registers
480/* misc registers */ 478 */
481 479
482#define MO_M2M_DMA 0x350000 // {64}RWp Mem2Mem DMA Bfr 480#define MO_M2M_DMA 0x350000 // {64}RWp Mem2Mem DMA Bfr
483#define MO_GP0_IO 0x350010 // {32}RW* GPIOoutput enablesdata I/O 481#define MO_GP0_IO 0x350010 // {32}RW* GPIOoutput enablesdata I/O
@@ -509,9 +507,9 @@
509#define MO_INT1_STAT 0x35C064 // DMA RISC interrupt status 507#define MO_INT1_STAT 0x35C064 // DMA RISC interrupt status
510#define MO_INT1_MSTAT 0x35C068 // DMA RISC interrupt masked status 508#define MO_INT1_MSTAT 0x35C068 // DMA RISC interrupt masked status
511 509
512 510/*
513/* ---------------------------------------------------------------------- */ 511 * i2c bus registers
514/* i2c bus registers */ 512 */
515 513
516#define MO_I2C 0x368000 // I2C data/control 514#define MO_I2C 0x368000 // I2C data/control
517#define MO_I2C_DIV (0xf<<4) 515#define MO_I2C_DIV (0xf<<4)
@@ -521,9 +519,11 @@
521#define MO_I2C_SDA (1<<0) 519#define MO_I2C_SDA (1<<0)
522 520
523 521
524/* ---------------------------------------------------------------------- */ 522/*
525/* general purpose host registers */ 523 * general purpose host registers
526/* FIXME: tyops? s/0x35/0x38/ ?? */ 524 *
525 * FIXME: tyops? s/0x35/0x38/ ??
526 */
527 527
528#define MO_GPHSTD_DMA 0x350000 // {64}RWp Host downstream 528#define MO_GPHSTD_DMA 0x350000 // {64}RWp Host downstream
529#define MO_GPHSTU_DMA 0x350008 // {64}RWp Host upstream 529#define MO_GPHSTU_DMA 0x350008 // {64}RWp Host upstream
@@ -545,9 +545,9 @@
545#define MO_GPHST_XFR_STAT 0x38C044 // Host transfer status 545#define MO_GPHST_XFR_STAT 0x38C044 // Host transfer status
546#define MO_GPHST_SOFT_RST 0x38C06C // Host software reset 546#define MO_GPHST_SOFT_RST 0x38C06C // Host software reset
547 547
548 548/*
549/* ---------------------------------------------------------------------- */ 549 * RISC instructions
550/* RISC instructions */ 550 */
551 551
552#define RISC_SYNC 0x80000000 552#define RISC_SYNC 0x80000000
553#define RISC_SYNC_ODD 0x80000000 553#define RISC_SYNC_ODD 0x80000000
@@ -576,11 +576,11 @@
576#define RISC_CNT_INC 0x00010000 576#define RISC_CNT_INC 0x00010000
577#define RISC_CNT_RSVR 0x00020000 577#define RISC_CNT_RSVR 0x00020000
578#define RISC_CNT_RESET 0x00030000 578#define RISC_CNT_RESET 0x00030000
579#define RISC_JMP_SRP 0x01 579#define RISC_JMP_SRP 0x01
580 580
581 581/*
582/* ---------------------------------------------------------------------- */ 582 * various constants
583/* various constants */ 583 */
584 584
585// DMA 585// DMA
586/* Interrupt mask/status */ 586/* Interrupt mask/status */
@@ -822,15 +822,4 @@
822#define DEFAULT_SAT_U_NTSC 0x7F 822#define DEFAULT_SAT_U_NTSC 0x7F
823#define DEFAULT_SAT_V_NTSC 0x5A 823#define DEFAULT_SAT_V_NTSC 0x5A
824 824
825typedef enum
826{
827 SOURCE_TUNER = 0,
828 SOURCE_COMPOSITE,
829 SOURCE_SVIDEO,
830 SOURCE_OTHER1,
831 SOURCE_OTHER2,
832 SOURCE_COMPVIASVIDEO,
833 SOURCE_CCIR656
834} VIDEOSOURCETYPE;
835
836#endif /* _CX88_REG_H_ */ 825#endif /* _CX88_REG_H_ */
diff --git a/drivers/media/pci/cx88/cx88-tvaudio.c b/drivers/media/pci/cx88/cx88-tvaudio.c
index 6bbce6ad6295..545ad4c4d1c7 100644
--- a/drivers/media/pci/cx88/cx88-tvaudio.c
+++ b/drivers/media/pci/cx88/cx88-tvaudio.c
@@ -1,39 +1,36 @@
1/* 1/*
2 * cx88x-audio.c - Conexant CX23880/23881 audio downstream driver driver
3 *
4 * (c) 2001 Michael Eskin, Tom Zakrajsek [Windows version]
5 * (c) 2002 Yurij Sysoev <yurij@naturesoft.net>
6 * (c) 2003 Gerd Knorr <kraxel@bytesex.org>
7 *
8 * -----------------------------------------------------------------------
9 *
10 * Lot of voodoo here. Even the data sheet doesn't help to
11 * understand what is going on here, the documentation for the audio
12 * part of the cx2388x chip is *very* bad.
13 *
14 * Some of this comes from party done linux driver sources I got from
15 * [undocumented].
16 *
17 * Some comes from the dscaler sources, one of the dscaler driver guy works
18 * for Conexant ...
19 *
20 * -----------------------------------------------------------------------
21 *
22 * This program is free software; you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation; either version 2 of the License, or
25 * (at your option) any later version.
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
31 */
2 32
3 cx88x-audio.c - Conexant CX23880/23881 audio downstream driver driver 33#include "cx88.h"
4
5 (c) 2001 Michael Eskin, Tom Zakrajsek [Windows version]
6 (c) 2002 Yurij Sysoev <yurij@naturesoft.net>
7 (c) 2003 Gerd Knorr <kraxel@bytesex.org>
8
9 -----------------------------------------------------------------------
10
11 Lot of voodoo here. Even the data sheet doesn't help to
12 understand what is going on here, the documentation for the audio
13 part of the cx2388x chip is *very* bad.
14
15 Some of this comes from party done linux driver sources I got from
16 [undocumented].
17
18 Some comes from the dscaler sources, one of the dscaler driver guy works
19 for Conexant ...
20
21 -----------------------------------------------------------------------
22
23 This program is free software; you can redistribute it and/or modify
24 it under the terms of the GNU General Public License as published by
25 the Free Software Foundation; either version 2 of the License, or
26 (at your option) any later version.
27
28 This program is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 GNU General Public License for more details.
32
33 You should have received a copy of the GNU General Public License
34 along with this program; if not, write to the Free Software
35 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
36*/
37 34
38#include <linux/module.h> 35#include <linux/module.h>
39#include <linux/errno.h> 36#include <linux/errno.h>
@@ -50,24 +47,24 @@
50#include <linux/delay.h> 47#include <linux/delay.h>
51#include <linux/kthread.h> 48#include <linux/kthread.h>
52 49
53#include "cx88.h"
54
55static unsigned int audio_debug; 50static unsigned int audio_debug;
56module_param(audio_debug, int, 0644); 51module_param(audio_debug, int, 0644);
57MODULE_PARM_DESC(audio_debug, "enable debug messages [audio]"); 52MODULE_PARM_DESC(audio_debug, "enable debug messages [audio]");
58 53
59static unsigned int always_analog; 54static unsigned int always_analog;
60module_param(always_analog,int,0644); 55module_param(always_analog, int, 0644);
61MODULE_PARM_DESC(always_analog,"force analog audio out"); 56MODULE_PARM_DESC(always_analog, "force analog audio out");
62 57
63static unsigned int radio_deemphasis; 58static unsigned int radio_deemphasis;
64module_param(radio_deemphasis,int,0644); 59module_param(radio_deemphasis, int, 0644);
65MODULE_PARM_DESC(radio_deemphasis, "Radio deemphasis time constant, " 60MODULE_PARM_DESC(radio_deemphasis,
66 "0=None, 1=50us (elsewhere), 2=75us (USA)"); 61 "Radio deemphasis time constant, 0=None, 1=50us (elsewhere), 2=75us (USA)");
67 62
68#define dprintk(fmt, arg...) if (audio_debug) \ 63#define dprintk(fmt, arg...) do { \
69 printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg) 64 if (audio_debug) \
70 65 printk(KERN_DEBUG pr_fmt("%s: tvaudio:" fmt), \
66 __func__, ##arg); \
67} while (0)
71/* ----------------------------------------------------------- */ 68/* ----------------------------------------------------------- */
72 69
73static const char * const aud_ctl_names[64] = { 70static const char * const aud_ctl_names[64] = {
@@ -145,7 +142,10 @@ static void set_audio_finish(struct cx88_core *core, u32 ctl)
145 if (core->board.mpeg & CX88_MPEG_BLACKBIRD) { 142 if (core->board.mpeg & CX88_MPEG_BLACKBIRD) {
146 cx_write(AUD_I2SINPUTCNTL, 4); 143 cx_write(AUD_I2SINPUTCNTL, 4);
147 cx_write(AUD_BAUDRATE, 1); 144 cx_write(AUD_BAUDRATE, 1);
148 /* 'pass-thru mode': this enables the i2s output to the mpeg encoder */ 145 /*
146 * 'pass-thru mode': this enables the i2s
147 * output to the mpeg encoder
148 */
149 cx_set(AUD_CTL, EN_I2SOUT_ENABLE); 149 cx_set(AUD_CTL, EN_I2SOUT_ENABLE);
150 cx_write(AUD_I2SOUTPUTCNTL, 1); 150 cx_write(AUD_I2SOUTPUTCNTL, 1);
151 cx_write(AUD_I2SCNTL, 0); 151 cx_write(AUD_I2SCNTL, 0);
@@ -349,7 +349,7 @@ static void set_audio_standard_NICAM(struct cx88_core *core, u32 mode)
349 { /* end of list */ }, 349 { /* end of list */ },
350 }; 350 };
351 351
352 set_audio_start(core,SEL_NICAM); 352 set_audio_start(core, SEL_NICAM);
353 switch (core->tvaudio) { 353 switch (core->tvaudio) {
354 case WW_L: 354 case WW_L:
355 dprintk("%s SECAM-L NICAM (status: devel)\n", __func__); 355 dprintk("%s SECAM-L NICAM (status: devel)\n", __func__);
@@ -638,7 +638,6 @@ static void set_audio_standard_A2(struct cx88_core *core, u32 mode)
638 case WW_M: 638 case WW_M:
639 dprintk("%s Warning: wrong value\n", __func__); 639 dprintk("%s Warning: wrong value\n", __func__);
640 return; 640 return;
641 break;
642 } 641 }
643 642
644 mode |= EN_FMRADIO_EN_RDS | EN_DMTRX_SUMDIFF; 643 mode |= EN_FMRADIO_EN_RDS | EN_DMTRX_SUMDIFF;
@@ -695,13 +694,15 @@ static void set_audio_standard_FM(struct cx88_core *core,
695 { /* end of list */ }, 694 { /* end of list */ },
696 }; 695 };
697 696
698 /* It is enough to leave default values? */ 697 /*
699 /* No, it's not! The deemphasis registers are reset to the 75us 698 * It is enough to leave default values?
699 *
700 * No, it's not! The deemphasis registers are reset to the 75us
700 * values by default. Analyzing the spectrum of the decoded audio 701 * values by default. Analyzing the spectrum of the decoded audio
701 * reveals that "no deemphasis" is the same as 75 us, while the 50 us 702 * reveals that "no deemphasis" is the same as 75 us, while the 50 us
702 * setting results in less deemphasis. */ 703 * setting results in less deemphasis.
704 */
703 static const struct rlist fm_no_deemph[] = { 705 static const struct rlist fm_no_deemph[] = {
704
705 {AUD_POLYPH80SCALEFAC, 0x0003}, 706 {AUD_POLYPH80SCALEFAC, 0x0003},
706 { /* end of list */ }, 707 { /* end of list */ },
707 }; 708 };
@@ -745,7 +746,7 @@ static int cx88_detect_nicam(struct cx88_core *core)
745 } 746 }
746 747
747 /* wait a little bit for next reading status */ 748 /* wait a little bit for next reading status */
748 msleep(10); 749 usleep_range(10000, 20000);
749 } 750 }
750 751
751 dprintk("nicam is not detected.\n"); 752 dprintk("nicam is not detected.\n");
@@ -766,10 +767,12 @@ void cx88_set_tvaudio(struct cx88_core *core)
766 /* prepare all dsp registers */ 767 /* prepare all dsp registers */
767 set_audio_standard_A2(core, EN_A2_FORCE_MONO1); 768 set_audio_standard_A2(core, EN_A2_FORCE_MONO1);
768 769
769 /* set nicam mode - otherwise 770 /*
770 AUD_NICAM_STATUS2 contains wrong values */ 771 * set nicam mode - otherwise
772 * AUD_NICAM_STATUS2 contains wrong values
773 */
771 set_audio_standard_NICAM(core, EN_NICAM_AUTO_STEREO); 774 set_audio_standard_NICAM(core, EN_NICAM_AUTO_STEREO);
772 if (0 == cx88_detect_nicam(core)) { 775 if (cx88_detect_nicam(core) == 0) {
773 /* fall back to fm / am mono */ 776 /* fall back to fm / am mono */
774 set_audio_standard_A2(core, EN_A2_FORCE_MONO1); 777 set_audio_standard_A2(core, EN_A2_FORCE_MONO1);
775 core->audiomode_current = V4L2_TUNER_MODE_MONO; 778 core->audiomode_current = V4L2_TUNER_MODE_MONO;
@@ -798,23 +801,25 @@ void cx88_set_tvaudio(struct cx88_core *core)
798 break; 801 break;
799 case WW_NONE: 802 case WW_NONE:
800 case WW_I2SPT: 803 case WW_I2SPT:
801 printk("%s/0: unknown tv audio mode [%d]\n", 804 pr_info("unknown tv audio mode [%d]\n", core->tvaudio);
802 core->name, core->tvaudio);
803 break; 805 break;
804 } 806 }
805 return;
806} 807}
808EXPORT_SYMBOL(cx88_set_tvaudio);
807 809
808void cx88_newstation(struct cx88_core *core) 810void cx88_newstation(struct cx88_core *core)
809{ 811{
810 core->audiomode_manual = UNSET; 812 core->audiomode_manual = UNSET;
811 core->last_change = jiffies; 813 core->last_change = jiffies;
812} 814}
815EXPORT_SYMBOL(cx88_newstation);
813 816
814void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t) 817void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t)
815{ 818{
816 static const char * const m[] = { "stereo", "dual mono", "mono", "sap" }; 819 static const char * const m[] = { "stereo", "dual mono",
817 static const char * const p[] = { "no pilot", "pilot c1", "pilot c2", "?" }; 820 "mono", "sap" };
821 static const char * const p[] = { "no pilot", "pilot c1",
822 "pilot c2", "?" };
818 u32 reg, mode, pilot; 823 u32 reg, mode, pilot;
819 824
820 reg = cx_read(AUD_STATUS); 825 reg = cx_read(AUD_STATUS);
@@ -869,15 +874,18 @@ void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t)
869 } 874 }
870 875
871 /* If software stereo detection is not supported... */ 876 /* If software stereo detection is not supported... */
872 if (UNSET == t->rxsubchans) { 877 if (t->rxsubchans == UNSET) {
873 t->rxsubchans = V4L2_TUNER_SUB_MONO; 878 t->rxsubchans = V4L2_TUNER_SUB_MONO;
874 /* If the hardware itself detected stereo, also return 879 /*
875 stereo as an available subchannel */ 880 * If the hardware itself detected stereo, also return
876 if (V4L2_TUNER_MODE_STEREO == t->audmode) 881 * stereo as an available subchannel
882 */
883 if (t->audmode == V4L2_TUNER_MODE_STEREO)
877 t->rxsubchans |= V4L2_TUNER_SUB_STEREO; 884 t->rxsubchans |= V4L2_TUNER_SUB_STEREO;
878 } 885 }
879 return;
880} 886}
887EXPORT_SYMBOL(cx88_get_stereo);
888
881 889
882void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual) 890void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
883{ 891{
@@ -887,7 +895,7 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
887 if (manual) { 895 if (manual) {
888 core->audiomode_manual = mode; 896 core->audiomode_manual = mode;
889 } else { 897 } else {
890 if (UNSET != core->audiomode_manual) 898 if (core->audiomode_manual != UNSET)
891 return; 899 return;
892 } 900 }
893 core->audiomode_current = mode; 901 core->audiomode_current = mode;
@@ -915,7 +923,7 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
915 case WW_M: 923 case WW_M:
916 case WW_I: 924 case WW_I:
917 case WW_L: 925 case WW_L:
918 if (1 == core->use_nicam) { 926 if (core->use_nicam == 1) {
919 switch (mode) { 927 switch (mode) {
920 case V4L2_TUNER_MODE_MONO: 928 case V4L2_TUNER_MODE_MONO:
921 case V4L2_TUNER_MODE_LANG1: 929 case V4L2_TUNER_MODE_LANG1:
@@ -933,7 +941,8 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
933 break; 941 break;
934 } 942 }
935 } else { 943 } else {
936 if ((core->tvaudio == WW_I) || (core->tvaudio == WW_L)) { 944 if ((core->tvaudio == WW_I) ||
945 (core->tvaudio == WW_L)) {
937 /* fall back to fm / am mono */ 946 /* fall back to fm / am mono */
938 set_audio_standard_A2(core, EN_A2_FORCE_MONO1); 947 set_audio_standard_A2(core, EN_A2_FORCE_MONO1);
939 } else { 948 } else {
@@ -975,15 +984,14 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
975 break; 984 break;
976 } 985 }
977 986
978 if (UNSET != ctl) { 987 if (ctl != UNSET) {
979 dprintk("cx88_set_stereo: mask 0x%x, ctl 0x%x " 988 dprintk("cx88_set_stereo: mask 0x%x, ctl 0x%x [status=0x%x,ctl=0x%x,vol=0x%x]\n",
980 "[status=0x%x,ctl=0x%x,vol=0x%x]\n",
981 mask, ctl, cx_read(AUD_STATUS), 989 mask, ctl, cx_read(AUD_STATUS),
982 cx_read(AUD_CTL), cx_sread(SHADOW_AUD_VOL_CTL)); 990 cx_read(AUD_CTL), cx_sread(SHADOW_AUD_VOL_CTL));
983 cx_andor(AUD_CTL, mask, ctl); 991 cx_andor(AUD_CTL, mask, ctl);
984 } 992 }
985 return;
986} 993}
994EXPORT_SYMBOL(cx88_set_stereo);
987 995
988int cx88_audio_thread(void *data) 996int cx88_audio_thread(void *data)
989{ 997{
@@ -1012,7 +1020,7 @@ int cx88_audio_thread(void *data)
1012 memset(&t, 0, sizeof(t)); 1020 memset(&t, 0, sizeof(t));
1013 cx88_get_stereo(core, &t); 1021 cx88_get_stereo(core, &t);
1014 1022
1015 if (UNSET != core->audiomode_manual) 1023 if (core->audiomode_manual != UNSET)
1016 /* manually set, don't do anything. */ 1024 /* manually set, don't do anything. */
1017 continue; 1025 continue;
1018 1026
@@ -1033,8 +1041,10 @@ int cx88_audio_thread(void *data)
1033 case WW_FM: 1041 case WW_FM:
1034 case WW_I2SADC: 1042 case WW_I2SADC:
1035hw_autodetect: 1043hw_autodetect:
1036 /* stereo autodetection is supported by hardware so 1044 /*
1037 we don't need to do it manually. Do nothing. */ 1045 * stereo autodetection is supported by hardware so
1046 * we don't need to do it manually. Do nothing.
1047 */
1038 break; 1048 break;
1039 } 1049 }
1040 } 1050 }
@@ -1042,11 +1052,4 @@ hw_autodetect:
1042 dprintk("cx88: tvaudio thread exiting\n"); 1052 dprintk("cx88: tvaudio thread exiting\n");
1043 return 0; 1053 return 0;
1044} 1054}
1045
1046/* ----------------------------------------------------------- */
1047
1048EXPORT_SYMBOL(cx88_set_tvaudio);
1049EXPORT_SYMBOL(cx88_newstation);
1050EXPORT_SYMBOL(cx88_set_stereo);
1051EXPORT_SYMBOL(cx88_get_stereo);
1052EXPORT_SYMBOL(cx88_audio_thread); 1055EXPORT_SYMBOL(cx88_audio_thread);
diff --git a/drivers/media/pci/cx88/cx88-vbi.c b/drivers/media/pci/cx88/cx88-vbi.c
index d3237cf8ffa3..2d0ef19e6d65 100644
--- a/drivers/media/pci/cx88/cx88-vbi.c
+++ b/drivers/media/pci/cx88/cx88-vbi.c
@@ -1,22 +1,26 @@
1/* 1/*
2 */ 2 */
3
4#include "cx88.h"
5
3#include <linux/kernel.h> 6#include <linux/kernel.h>
4#include <linux/module.h> 7#include <linux/module.h>
5#include <linux/init.h> 8#include <linux/init.h>
6 9
7#include "cx88.h"
8
9static unsigned int vbi_debug; 10static unsigned int vbi_debug;
10module_param(vbi_debug,int,0644); 11module_param(vbi_debug, int, 0644);
11MODULE_PARM_DESC(vbi_debug,"enable debug messages [vbi]"); 12MODULE_PARM_DESC(vbi_debug, "enable debug messages [vbi]");
12 13
13#define dprintk(level,fmt, arg...) if (vbi_debug >= level) \ 14#define dprintk(level, fmt, arg...) do { \
14 printk(KERN_DEBUG "%s: " fmt, dev->core->name , ## arg) 15 if (vbi_debug >= level) \
16 printk(KERN_DEBUG pr_fmt("%s: vbi:" fmt), \
17 __func__, ##arg); \
18} while (0)
15 19
16/* ------------------------------------------------------------------ */ 20/* ------------------------------------------------------------------ */
17 21
18int cx8800_vbi_fmt (struct file *file, void *priv, 22int cx8800_vbi_fmt(struct file *file, void *priv,
19 struct v4l2_format *f) 23 struct v4l2_format *f)
20{ 24{
21 struct cx8800_dev *dev = video_drvdata(file); 25 struct cx8800_dev *dev = video_drvdata(file);
22 26
@@ -44,8 +48,8 @@ int cx8800_vbi_fmt (struct file *file, void *priv,
44} 48}
45 49
46static int cx8800_start_vbi_dma(struct cx8800_dev *dev, 50static int cx8800_start_vbi_dma(struct cx8800_dev *dev,
47 struct cx88_dmaqueue *q, 51 struct cx88_dmaqueue *q,
48 struct cx88_buffer *buf) 52 struct cx88_buffer *buf)
49{ 53{
50 struct cx88_core *core = dev->core; 54 struct cx88_core *core = dev->core;
51 55
@@ -53,9 +57,9 @@ static int cx8800_start_vbi_dma(struct cx8800_dev *dev,
53 cx88_sram_channel_setup(dev->core, &cx88_sram_channels[SRAM_CH24], 57 cx88_sram_channel_setup(dev->core, &cx88_sram_channels[SRAM_CH24],
54 VBI_LINE_LENGTH, buf->risc.dma); 58 VBI_LINE_LENGTH, buf->risc.dma);
55 59
56 cx_write(MO_VBOS_CONTROL, ( (1 << 18) | // comb filter delay fixup 60 cx_write(MO_VBOS_CONTROL, (1 << 18) | /* comb filter delay fixup */
57 (1 << 15) | // enable vbi capture 61 (1 << 15) | /* enable vbi capture */
58 (1 << 11) )); 62 (1 << 11));
59 63
60 /* reset counter */ 64 /* reset counter */
61 cx_write(MO_VBI_GPCNTRL, GP_COUNT_CONTROL_RESET); 65 cx_write(MO_VBI_GPCNTRL, GP_COUNT_CONTROL_RESET);
@@ -66,10 +70,10 @@ static int cx8800_start_vbi_dma(struct cx8800_dev *dev,
66 cx_set(MO_VID_INTMSK, 0x0f0088); 70 cx_set(MO_VID_INTMSK, 0x0f0088);
67 71
68 /* enable capture */ 72 /* enable capture */
69 cx_set(VID_CAPTURE_CONTROL,0x18); 73 cx_set(VID_CAPTURE_CONTROL, 0x18);
70 74
71 /* start dma */ 75 /* start dma */
72 cx_set(MO_DEV_CNTRL2, (1<<5)); 76 cx_set(MO_DEV_CNTRL2, (1 << 5));
73 cx_set(MO_VID_DMACNTRL, 0x88); 77 cx_set(MO_VID_DMACNTRL, 0x88);
74 78
75 return 0; 79 return 0;
@@ -83,7 +87,7 @@ void cx8800_stop_vbi_dma(struct cx8800_dev *dev)
83 cx_clear(MO_VID_DMACNTRL, 0x88); 87 cx_clear(MO_VID_DMACNTRL, 0x88);
84 88
85 /* disable capture */ 89 /* disable capture */
86 cx_clear(VID_CAPTURE_CONTROL,0x18); 90 cx_clear(VID_CAPTURE_CONTROL, 0x18);
87 91
88 /* disable irqs */ 92 /* disable irqs */
89 cx_clear(MO_PCI_INTMSK, PCI_INT_VIDINT); 93 cx_clear(MO_PCI_INTMSK, PCI_INT_VIDINT);
@@ -99,7 +103,7 @@ int cx8800_restart_vbi_queue(struct cx8800_dev *dev,
99 return 0; 103 return 0;
100 104
101 buf = list_entry(q->active.next, struct cx88_buffer, list); 105 buf = list_entry(q->active.next, struct cx88_buffer, list);
102 dprintk(2,"restart_queue [%p/%d]: restart dma\n", 106 dprintk(2, "restart_queue [%p/%d]: restart dma\n",
103 buf, buf->vb.vb2_buf.index); 107 buf, buf->vb.vb2_buf.index);
104 cx8800_start_vbi_dma(dev, q, buf); 108 cx8800_start_vbi_dma(dev, q, buf);
105 return 0; 109 return 0;
@@ -108,8 +112,8 @@ int cx8800_restart_vbi_queue(struct cx8800_dev *dev,
108/* ------------------------------------------------------------------ */ 112/* ------------------------------------------------------------------ */
109 113
110static int queue_setup(struct vb2_queue *q, 114static int queue_setup(struct vb2_queue *q,
111 unsigned int *num_buffers, unsigned int *num_planes, 115 unsigned int *num_buffers, unsigned int *num_planes,
112 unsigned int sizes[], struct device *alloc_devs[]) 116 unsigned int sizes[], struct device *alloc_devs[])
113{ 117{
114 struct cx8800_dev *dev = q->drv_priv; 118 struct cx8800_dev *dev = q->drv_priv;
115 119
@@ -121,7 +125,6 @@ static int queue_setup(struct vb2_queue *q,
121 return 0; 125 return 0;
122} 126}
123 127
124
125static int buffer_prepare(struct vb2_buffer *vb) 128static int buffer_prepare(struct vb2_buffer *vb)
126{ 129{
127 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); 130 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
@@ -175,7 +178,7 @@ static void buffer_queue(struct vb2_buffer *vb)
175 if (list_empty(&q->active)) { 178 if (list_empty(&q->active)) {
176 list_add_tail(&buf->list, &q->active); 179 list_add_tail(&buf->list, &q->active);
177 cx8800_start_vbi_dma(dev, q, buf); 180 cx8800_start_vbi_dma(dev, q, buf);
178 dprintk(2,"[%p/%d] vbi_queue - first active\n", 181 dprintk(2, "[%p/%d] vbi_queue - first active\n",
179 buf, buf->vb.vb2_buf.index); 182 buf, buf->vb.vb2_buf.index);
180 183
181 } else { 184 } else {
@@ -183,7 +186,7 @@ static void buffer_queue(struct vb2_buffer *vb)
183 prev = list_entry(q->active.prev, struct cx88_buffer, list); 186 prev = list_entry(q->active.prev, struct cx88_buffer, list);
184 list_add_tail(&buf->list, &q->active); 187 list_add_tail(&buf->list, &q->active);
185 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); 188 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
186 dprintk(2,"[%p/%d] buffer_queue - append to active\n", 189 dprintk(2, "[%p/%d] buffer_queue - append to active\n",
187 buf, buf->vb.vb2_buf.index); 190 buf, buf->vb.vb2_buf.index);
188 } 191 }
189} 192}
diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
index d83eb3b10f54..c7d4e87ccb64 100644
--- a/drivers/media/pci/cx88/cx88-video.c
+++ b/drivers/media/pci/cx88/cx88-video.c
@@ -19,12 +19,10 @@
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
24#include "cx88.h"
25
28#include <linux/init.h> 26#include <linux/init.h>
29#include <linux/list.h> 27#include <linux/list.h>
30#include <linux/module.h> 28#include <linux/module.h>
@@ -37,7 +35,6 @@
37#include <linux/kthread.h> 35#include <linux/kthread.h>
38#include <asm/div64.h> 36#include <asm/div64.h>
39 37
40#include "cx88.h"
41#include <media/v4l2-common.h> 38#include <media/v4l2-common.h>
42#include <media/v4l2-ioctl.h> 39#include <media/v4l2-ioctl.h>
43#include <media/v4l2-event.h> 40#include <media/v4l2-event.h>
@@ -58,20 +55,23 @@ module_param_array(video_nr, int, NULL, 0444);
58module_param_array(vbi_nr, int, NULL, 0444); 55module_param_array(vbi_nr, int, NULL, 0444);
59module_param_array(radio_nr, int, NULL, 0444); 56module_param_array(radio_nr, int, NULL, 0444);
60 57
61MODULE_PARM_DESC(video_nr,"video device numbers"); 58MODULE_PARM_DESC(video_nr, "video device numbers");
62MODULE_PARM_DESC(vbi_nr,"vbi device numbers"); 59MODULE_PARM_DESC(vbi_nr, "vbi device numbers");
63MODULE_PARM_DESC(radio_nr,"radio device numbers"); 60MODULE_PARM_DESC(radio_nr, "radio device numbers");
64 61
65static unsigned int video_debug; 62static unsigned int video_debug;
66module_param(video_debug,int,0644); 63module_param(video_debug, int, 0644);
67MODULE_PARM_DESC(video_debug,"enable debug messages [video]"); 64MODULE_PARM_DESC(video_debug, "enable debug messages [video]");
68 65
69static unsigned int irq_debug; 66static unsigned int irq_debug;
70module_param(irq_debug,int,0644); 67module_param(irq_debug, int, 0644);
71MODULE_PARM_DESC(irq_debug,"enable debug messages [IRQ handler]"); 68MODULE_PARM_DESC(irq_debug, "enable debug messages [IRQ handler]");
72 69
73#define dprintk(level,fmt, arg...) if (video_debug >= level) \ 70#define dprintk(level, fmt, arg...) do { \
74 printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg) 71 if (video_debug >= level) \
72 printk(KERN_DEBUG pr_fmt("%s: video:" fmt), \
73 __func__, ##arg); \
74} while (0)
75 75
76/* ------------------------------------------------------------------- */ 76/* ------------------------------------------------------------------- */
77/* static data */ 77/* static data */
@@ -83,55 +83,56 @@ static const struct cx8800_fmt formats[] = {
83 .cxformat = ColorFormatY8, 83 .cxformat = ColorFormatY8,
84 .depth = 8, 84 .depth = 8,
85 .flags = FORMAT_FLAGS_PACKED, 85 .flags = FORMAT_FLAGS_PACKED,
86 },{ 86 }, {
87 .name = "15 bpp RGB, le", 87 .name = "15 bpp RGB, le",
88 .fourcc = V4L2_PIX_FMT_RGB555, 88 .fourcc = V4L2_PIX_FMT_RGB555,
89 .cxformat = ColorFormatRGB15, 89 .cxformat = ColorFormatRGB15,
90 .depth = 16, 90 .depth = 16,
91 .flags = FORMAT_FLAGS_PACKED, 91 .flags = FORMAT_FLAGS_PACKED,
92 },{ 92 }, {
93 .name = "15 bpp RGB, be", 93 .name = "15 bpp RGB, be",
94 .fourcc = V4L2_PIX_FMT_RGB555X, 94 .fourcc = V4L2_PIX_FMT_RGB555X,
95 .cxformat = ColorFormatRGB15 | ColorFormatBSWAP, 95 .cxformat = ColorFormatRGB15 | ColorFormatBSWAP,
96 .depth = 16, 96 .depth = 16,
97 .flags = FORMAT_FLAGS_PACKED, 97 .flags = FORMAT_FLAGS_PACKED,
98 },{ 98 }, {
99 .name = "16 bpp RGB, le", 99 .name = "16 bpp RGB, le",
100 .fourcc = V4L2_PIX_FMT_RGB565, 100 .fourcc = V4L2_PIX_FMT_RGB565,
101 .cxformat = ColorFormatRGB16, 101 .cxformat = ColorFormatRGB16,
102 .depth = 16, 102 .depth = 16,
103 .flags = FORMAT_FLAGS_PACKED, 103 .flags = FORMAT_FLAGS_PACKED,
104 },{ 104 }, {
105 .name = "16 bpp RGB, be", 105 .name = "16 bpp RGB, be",
106 .fourcc = V4L2_PIX_FMT_RGB565X, 106 .fourcc = V4L2_PIX_FMT_RGB565X,
107 .cxformat = ColorFormatRGB16 | ColorFormatBSWAP, 107 .cxformat = ColorFormatRGB16 | ColorFormatBSWAP,
108 .depth = 16, 108 .depth = 16,
109 .flags = FORMAT_FLAGS_PACKED, 109 .flags = FORMAT_FLAGS_PACKED,
110 },{ 110 }, {
111 .name = "24 bpp RGB, le", 111 .name = "24 bpp RGB, le",
112 .fourcc = V4L2_PIX_FMT_BGR24, 112 .fourcc = V4L2_PIX_FMT_BGR24,
113 .cxformat = ColorFormatRGB24, 113 .cxformat = ColorFormatRGB24,
114 .depth = 24, 114 .depth = 24,
115 .flags = FORMAT_FLAGS_PACKED, 115 .flags = FORMAT_FLAGS_PACKED,
116 },{ 116 }, {
117 .name = "32 bpp RGB, le", 117 .name = "32 bpp RGB, le",
118 .fourcc = V4L2_PIX_FMT_BGR32, 118 .fourcc = V4L2_PIX_FMT_BGR32,
119 .cxformat = ColorFormatRGB32, 119 .cxformat = ColorFormatRGB32,
120 .depth = 32, 120 .depth = 32,
121 .flags = FORMAT_FLAGS_PACKED, 121 .flags = FORMAT_FLAGS_PACKED,
122 },{ 122 }, {
123 .name = "32 bpp RGB, be", 123 .name = "32 bpp RGB, be",
124 .fourcc = V4L2_PIX_FMT_RGB32, 124 .fourcc = V4L2_PIX_FMT_RGB32,
125 .cxformat = ColorFormatRGB32 | ColorFormatBSWAP | ColorFormatWSWAP, 125 .cxformat = ColorFormatRGB32 | ColorFormatBSWAP |
126 ColorFormatWSWAP,
126 .depth = 32, 127 .depth = 32,
127 .flags = FORMAT_FLAGS_PACKED, 128 .flags = FORMAT_FLAGS_PACKED,
128 },{ 129 }, {
129 .name = "4:2:2, packed, YUYV", 130 .name = "4:2:2, packed, YUYV",
130 .fourcc = V4L2_PIX_FMT_YUYV, 131 .fourcc = V4L2_PIX_FMT_YUYV,
131 .cxformat = ColorFormatYUY2, 132 .cxformat = ColorFormatYUY2,
132 .depth = 16, 133 .depth = 16,
133 .flags = FORMAT_FLAGS_PACKED, 134 .flags = FORMAT_FLAGS_PACKED,
134 },{ 135 }, {
135 .name = "4:2:2, packed, UYVY", 136 .name = "4:2:2, packed, UYVY",
136 .fourcc = V4L2_PIX_FMT_UYVY, 137 .fourcc = V4L2_PIX_FMT_UYVY,
137 .cxformat = ColorFormatYUY2 | ColorFormatBSWAP, 138 .cxformat = ColorFormatYUY2 | ColorFormatBSWAP,
@@ -140,13 +141,13 @@ static const struct cx8800_fmt formats[] = {
140 }, 141 },
141}; 142};
142 143
143static const struct cx8800_fmt* format_by_fourcc(unsigned int fourcc) 144static const struct cx8800_fmt *format_by_fourcc(unsigned int fourcc)
144{ 145{
145 unsigned int i; 146 unsigned int i;
146 147
147 for (i = 0; i < ARRAY_SIZE(formats); i++) 148 for (i = 0; i < ARRAY_SIZE(formats); i++)
148 if (formats[i].fourcc == fourcc) 149 if (formats[i].fourcc == fourcc)
149 return formats+i; 150 return formats + i;
150 return NULL; 151 return NULL;
151} 152}
152 153
@@ -180,7 +181,7 @@ static const struct cx88_ctrl cx8800_vid_ctls[] = {
180 .reg = MO_CONTR_BRIGHT, 181 .reg = MO_CONTR_BRIGHT,
181 .mask = 0x00ff, 182 .mask = 0x00ff,
182 .shift = 0, 183 .shift = 0,
183 },{ 184 }, {
184 .id = V4L2_CID_CONTRAST, 185 .id = V4L2_CID_CONTRAST,
185 .minimum = 0, 186 .minimum = 0,
186 .maximum = 0xff, 187 .maximum = 0xff,
@@ -190,7 +191,7 @@ static const struct cx88_ctrl cx8800_vid_ctls[] = {
190 .reg = MO_CONTR_BRIGHT, 191 .reg = MO_CONTR_BRIGHT,
191 .mask = 0xff00, 192 .mask = 0xff00,
192 .shift = 8, 193 .shift = 8,
193 },{ 194 }, {
194 .id = V4L2_CID_HUE, 195 .id = V4L2_CID_HUE,
195 .minimum = 0, 196 .minimum = 0,
196 .maximum = 0xff, 197 .maximum = 0xff,
@@ -200,7 +201,7 @@ static const struct cx88_ctrl cx8800_vid_ctls[] = {
200 .reg = MO_HUE, 201 .reg = MO_HUE,
201 .mask = 0x00ff, 202 .mask = 0x00ff,
202 .shift = 0, 203 .shift = 0,
203 },{ 204 }, {
204 /* strictly, this only describes only U saturation. 205 /* strictly, this only describes only U saturation.
205 * V saturation is handled specially through code. 206 * V saturation is handled specially through code.
206 */ 207 */
@@ -220,8 +221,10 @@ static const struct cx88_ctrl cx8800_vid_ctls[] = {
220 .step = 1, 221 .step = 1,
221 .default_value = 0x0, 222 .default_value = 0x0,
222 .off = 0, 223 .off = 0,
223 /* NOTE: the value is converted and written to both even 224 /*
224 and odd registers in the code */ 225 * NOTE: the value is converted and written to both even
226 * and odd registers in the code
227 */
225 .reg = MO_FILTER_ODD, 228 .reg = MO_FILTER_ODD,
226 .mask = 7 << 7, 229 .mask = 7 << 7,
227 .shift = 7, 230 .shift = 7,
@@ -265,7 +268,7 @@ static const struct cx88_ctrl cx8800_aud_ctls[] = {
265 .sreg = SHADOW_AUD_VOL_CTL, 268 .sreg = SHADOW_AUD_VOL_CTL,
266 .mask = (1 << 6), 269 .mask = (1 << 6),
267 .shift = 6, 270 .shift = 6,
268 },{ 271 }, {
269 .id = V4L2_CID_AUDIO_VOLUME, 272 .id = V4L2_CID_AUDIO_VOLUME,
270 .minimum = 0, 273 .minimum = 0,
271 .maximum = 0x3f, 274 .maximum = 0x3f,
@@ -275,7 +278,7 @@ static const struct cx88_ctrl cx8800_aud_ctls[] = {
275 .sreg = SHADOW_AUD_VOL_CTL, 278 .sreg = SHADOW_AUD_VOL_CTL,
276 .mask = 0x3f, 279 .mask = 0x3f,
277 .shift = 0, 280 .shift = 0,
278 },{ 281 }, {
279 .id = V4L2_CID_AUDIO_BALANCE, 282 .id = V4L2_CID_AUDIO_BALANCE,
280 .minimum = 0, 283 .minimum = 0,
281 .maximum = 0x7f, 284 .maximum = 0x7f,
@@ -299,10 +302,10 @@ int cx88_video_mux(struct cx88_core *core, unsigned int input)
299{ 302{
300 /* struct cx88_core *core = dev->core; */ 303 /* struct cx88_core *core = dev->core; */
301 304
302 dprintk(1,"video_mux: %d [vmux=%d,gpio=0x%x,0x%x,0x%x,0x%x]\n", 305 dprintk(1, "video_mux: %d [vmux=%d,gpio=0x%x,0x%x,0x%x,0x%x]\n",
303 input, INPUT(input).vmux, 306 input, INPUT(input).vmux,
304 INPUT(input).gpio0,INPUT(input).gpio1, 307 INPUT(input).gpio0, INPUT(input).gpio1,
305 INPUT(input).gpio2,INPUT(input).gpio3); 308 INPUT(input).gpio2, INPUT(input).gpio3);
306 core->input = input; 309 core->input = input;
307 cx_andor(MO_INPUT_FORMAT, 0x03 << 14, INPUT(input).vmux << 14); 310 cx_andor(MO_INPUT_FORMAT, 0x03 << 14, INPUT(input).vmux << 14);
308 cx_write(MO_GP3_IO, INPUT(input).gpio3); 311 cx_write(MO_GP3_IO, INPUT(input).gpio3);
@@ -325,19 +328,25 @@ int cx88_video_mux(struct cx88_core *core, unsigned int input)
325 break; 328 break;
326 } 329 }
327 330
328 /* if there are audioroutes defined, we have an external 331 /*
329 ADC to deal with audio */ 332 * if there are audioroutes defined, we have an external
333 * ADC to deal with audio
334 */
330 if (INPUT(input).audioroute) { 335 if (INPUT(input).audioroute) {
331 /* The wm8775 module has the "2" route hardwired into 336 /*
332 the initialization. Some boards may use different 337 * The wm8775 module has the "2" route hardwired into
333 routes for different inputs. HVR-1300 surely does */ 338 * the initialization. Some boards may use different
339 * routes for different inputs. HVR-1300 surely does
340 */
334 if (core->sd_wm8775) { 341 if (core->sd_wm8775) {
335 call_all(core, audio, s_routing, 342 call_all(core, audio, s_routing,
336 INPUT(input).audioroute, 0, 0); 343 INPUT(input).audioroute, 0, 0);
337 } 344 }
338 /* cx2388's C-ADC is connected to the tuner only. 345 /*
339 When used with S-Video, that ADC is busy dealing with 346 * cx2388's C-ADC is connected to the tuner only.
340 chroma, so an external must be used for baseband audio */ 347 * When used with S-Video, that ADC is busy dealing with
348 * chroma, so an external must be used for baseband audio
349 */
341 if (INPUT(input).type != CX88_VMUX_TELEVISION && 350 if (INPUT(input).type != CX88_VMUX_TELEVISION &&
342 INPUT(input).type != CX88_VMUX_CABLE) { 351 INPUT(input).type != CX88_VMUX_CABLE) {
343 /* "I2S ADC mode" */ 352 /* "I2S ADC mode" */
@@ -369,26 +378,27 @@ static int start_video_dma(struct cx8800_dev *dev,
369 cx_write(MO_COLOR_CTRL, dev->fmt->cxformat | ColorFormatGamma); 378 cx_write(MO_COLOR_CTRL, dev->fmt->cxformat | ColorFormatGamma);
370 379
371 /* reset counter */ 380 /* reset counter */
372 cx_write(MO_VIDY_GPCNTRL,GP_COUNT_CONTROL_RESET); 381 cx_write(MO_VIDY_GPCNTRL, GP_COUNT_CONTROL_RESET);
373 q->count = 0; 382 q->count = 0;
374 383
375 /* enable irqs */ 384 /* enable irqs */
376 cx_set(MO_PCI_INTMSK, core->pci_irqmask | PCI_INT_VIDINT); 385 cx_set(MO_PCI_INTMSK, core->pci_irqmask | PCI_INT_VIDINT);
377 386
378 /* Enables corresponding bits at PCI_INT_STAT: 387 /*
379 bits 0 to 4: video, audio, transport stream, VIP, Host 388 * Enables corresponding bits at PCI_INT_STAT:
380 bit 7: timer 389 * bits 0 to 4: video, audio, transport stream, VIP, Host
381 bits 8 and 9: DMA complete for: SRC, DST 390 * bit 7: timer
382 bits 10 and 11: BERR signal asserted for RISC: RD, WR 391 * bits 8 and 9: DMA complete for: SRC, DST
383 bits 12 to 15: BERR signal asserted for: BRDG, SRC, DST, IPB 392 * bits 10 and 11: BERR signal asserted for RISC: RD, WR
393 * bits 12 to 15: BERR signal asserted for: BRDG, SRC, DST, IPB
384 */ 394 */
385 cx_set(MO_VID_INTMSK, 0x0f0011); 395 cx_set(MO_VID_INTMSK, 0x0f0011);
386 396
387 /* enable capture */ 397 /* enable capture */
388 cx_set(VID_CAPTURE_CONTROL,0x06); 398 cx_set(VID_CAPTURE_CONTROL, 0x06);
389 399
390 /* start dma */ 400 /* start dma */
391 cx_set(MO_DEV_CNTRL2, (1<<5)); 401 cx_set(MO_DEV_CNTRL2, (1 << 5));
392 cx_set(MO_VID_DMACNTRL, 0x11); /* Planar Y and packed FIFO and RISC enable */ 402 cx_set(MO_VID_DMACNTRL, 0x11); /* Planar Y and packed FIFO and RISC enable */
393 403
394 return 0; 404 return 0;
@@ -403,7 +413,7 @@ static int stop_video_dma(struct cx8800_dev *dev)
403 cx_clear(MO_VID_DMACNTRL, 0x11); 413 cx_clear(MO_VID_DMACNTRL, 0x11);
404 414
405 /* disable capture */ 415 /* disable capture */
406 cx_clear(VID_CAPTURE_CONTROL,0x06); 416 cx_clear(VID_CAPTURE_CONTROL, 0x06);
407 417
408 /* disable irqs */ 418 /* disable irqs */
409 cx_clear(MO_PCI_INTMSK, PCI_INT_VIDINT); 419 cx_clear(MO_PCI_INTMSK, PCI_INT_VIDINT);
@@ -414,12 +424,11 @@ static int stop_video_dma(struct cx8800_dev *dev)
414static int restart_video_queue(struct cx8800_dev *dev, 424static int restart_video_queue(struct cx8800_dev *dev,
415 struct cx88_dmaqueue *q) 425 struct cx88_dmaqueue *q)
416{ 426{
417 struct cx88_core *core = dev->core;
418 struct cx88_buffer *buf; 427 struct cx88_buffer *buf;
419 428
420 if (!list_empty(&q->active)) { 429 if (!list_empty(&q->active)) {
421 buf = list_entry(q->active.next, struct cx88_buffer, list); 430 buf = list_entry(q->active.next, struct cx88_buffer, list);
422 dprintk(2,"restart_queue [%p/%d]: restart dma\n", 431 dprintk(2, "restart_queue [%p/%d]: restart dma\n",
423 buf, buf->vb.vb2_buf.index); 432 buf, buf->vb.vb2_buf.index);
424 start_video_dma(dev, q, buf); 433 start_video_dma(dev, q, buf);
425 } 434 }
@@ -430,8 +439,8 @@ static int restart_video_queue(struct cx8800_dev *dev,
430/* ------------------------------------------------------------------ */ 439/* ------------------------------------------------------------------ */
431 440
432static int queue_setup(struct vb2_queue *q, 441static int queue_setup(struct vb2_queue *q,
433 unsigned int *num_buffers, unsigned int *num_planes, 442 unsigned int *num_buffers, unsigned int *num_planes,
434 unsigned int sizes[], struct device *alloc_devs[]) 443 unsigned int sizes[], struct device *alloc_devs[])
435{ 444{
436 struct cx8800_dev *dev = q->drv_priv; 445 struct cx8800_dev *dev = q->drv_priv;
437 struct cx88_core *core = dev->core; 446 struct cx88_core *core = dev->core;
@@ -488,7 +497,8 @@ static int buffer_prepare(struct vb2_buffer *vb)
488 core->height >> 1); 497 core->height >> 1);
489 break; 498 break;
490 } 499 }
491 dprintk(2,"[%p/%d] buffer_prepare - %dx%d %dbpp \"%s\" - dma=0x%08lx\n", 500 dprintk(2,
501 "[%p/%d] buffer_prepare - %dx%d %dbpp \"%s\" - dma=0x%08lx\n",
492 buf, buf->vb.vb2_buf.index, 502 buf, buf->vb.vb2_buf.index,
493 core->width, core->height, dev->fmt->depth, dev->fmt->name, 503 core->width, core->height, dev->fmt->depth, dev->fmt->name,
494 (unsigned long)buf->risc.dma); 504 (unsigned long)buf->risc.dma);
@@ -513,7 +523,6 @@ static void buffer_queue(struct vb2_buffer *vb)
513 struct cx8800_dev *dev = vb->vb2_queue->drv_priv; 523 struct cx8800_dev *dev = vb->vb2_queue->drv_priv;
514 struct cx88_buffer *buf = container_of(vbuf, struct cx88_buffer, vb); 524 struct cx88_buffer *buf = container_of(vbuf, struct cx88_buffer, vb);
515 struct cx88_buffer *prev; 525 struct cx88_buffer *prev;
516 struct cx88_core *core = dev->core;
517 struct cx88_dmaqueue *q = &dev->vidq; 526 struct cx88_dmaqueue *q = &dev->vidq;
518 527
519 /* add jump to start */ 528 /* add jump to start */
@@ -523,7 +532,7 @@ static void buffer_queue(struct vb2_buffer *vb)
523 532
524 if (list_empty(&q->active)) { 533 if (list_empty(&q->active)) {
525 list_add_tail(&buf->list, &q->active); 534 list_add_tail(&buf->list, &q->active);
526 dprintk(2,"[%p/%d] buffer_queue - first active\n", 535 dprintk(2, "[%p/%d] buffer_queue - first active\n",
527 buf, buf->vb.vb2_buf.index); 536 buf, buf->vb.vb2_buf.index);
528 537
529 } else { 538 } else {
@@ -596,7 +605,7 @@ static int radio_open(struct file *file)
596 if (core->board.radio.audioroute) { 605 if (core->board.radio.audioroute) {
597 if (core->sd_wm8775) { 606 if (core->sd_wm8775) {
598 call_all(core, audio, s_routing, 607 call_all(core, audio, s_routing,
599 core->board.radio.audioroute, 0, 0); 608 core->board.radio.audioroute, 0, 0);
600 } 609 }
601 /* "I2S ADC mode" */ 610 /* "I2S ADC mode" */
602 core->tvaudio = WW_I2SADC; 611 core->tvaudio = WW_I2SADC;
@@ -650,9 +659,10 @@ static int cx8800_s_vid_ctrl(struct v4l2_ctrl *ctrl)
650 value = ((ctrl->val - cc->off) << cc->shift) & cc->mask; 659 value = ((ctrl->val - cc->off) << cc->shift) & cc->mask;
651 break; 660 break;
652 } 661 }
653 dprintk(1, "set_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n", 662 dprintk(1,
654 ctrl->id, ctrl->name, ctrl->val, cc->reg, value, 663 "set_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n",
655 mask, cc->sreg ? " [shadowed]" : ""); 664 ctrl->id, ctrl->name, ctrl->val, cc->reg, value,
665 mask, cc->sreg ? " [shadowed]" : "");
656 if (cc->sreg) 666 if (cc->sreg)
657 cx_sandor(cc->sreg, cc->reg, mask, value); 667 cx_sandor(cc->sreg, cc->reg, mask, value);
658 else 668 else
@@ -665,7 +675,7 @@ static int cx8800_s_aud_ctrl(struct v4l2_ctrl *ctrl)
665 struct cx88_core *core = 675 struct cx88_core *core =
666 container_of(ctrl->handler, struct cx88_core, audio_hdl); 676 container_of(ctrl->handler, struct cx88_core, audio_hdl);
667 const struct cx88_ctrl *cc = ctrl->priv; 677 const struct cx88_ctrl *cc = ctrl->priv;
668 u32 value,mask; 678 u32 value, mask;
669 679
670 /* Pass changes onto any WM8775 */ 680 /* Pass changes onto any WM8775 */
671 if (core->sd_wm8775) { 681 if (core->sd_wm8775) {
@@ -688,7 +698,8 @@ static int cx8800_s_aud_ctrl(struct v4l2_ctrl *ctrl)
688 mask = cc->mask; 698 mask = cc->mask;
689 switch (ctrl->id) { 699 switch (ctrl->id) {
690 case V4L2_CID_AUDIO_BALANCE: 700 case V4L2_CID_AUDIO_BALANCE:
691 value = (ctrl->val < 0x40) ? (0x7f - ctrl->val) : (ctrl->val - 0x40); 701 value = (ctrl->val < 0x40) ?
702 (0x7f - ctrl->val) : (ctrl->val - 0x40);
692 break; 703 break;
693 case V4L2_CID_AUDIO_VOLUME: 704 case V4L2_CID_AUDIO_VOLUME:
694 value = 0x3f - (ctrl->val & 0x3f); 705 value = 0x3f - (ctrl->val & 0x3f);
@@ -697,9 +708,10 @@ static int cx8800_s_aud_ctrl(struct v4l2_ctrl *ctrl)
697 value = ((ctrl->val - cc->off) << cc->shift) & cc->mask; 708 value = ((ctrl->val - cc->off) << cc->shift) & cc->mask;
698 break; 709 break;
699 } 710 }
700 dprintk(1,"set_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n", 711 dprintk(1,
701 ctrl->id, ctrl->name, ctrl->val, cc->reg, value, 712 "set_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n",
702 mask, cc->sreg ? " [shadowed]" : ""); 713 ctrl->id, ctrl->name, ctrl->val, cc->reg, value,
714 mask, cc->sreg ? " [shadowed]" : "");
703 if (cc->sreg) 715 if (cc->sreg)
704 cx_sandor(cc->sreg, cc->reg, mask, value); 716 cx_sandor(cc->sreg, cc->reg, mask, value);
705 else 717 else
@@ -711,7 +723,7 @@ static int cx8800_s_aud_ctrl(struct v4l2_ctrl *ctrl)
711/* VIDEO IOCTLS */ 723/* VIDEO IOCTLS */
712 724
713static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, 725static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
714 struct v4l2_format *f) 726 struct v4l2_format *f)
715{ 727{
716 struct cx8800_dev *dev = video_drvdata(file); 728 struct cx8800_dev *dev = video_drvdata(file);
717 struct cx88_core *core = dev->core; 729 struct cx88_core *core = dev->core;
@@ -729,7 +741,7 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
729} 741}
730 742
731static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, 743static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
732 struct v4l2_format *f) 744 struct v4l2_format *f)
733{ 745{
734 struct cx8800_dev *dev = video_drvdata(file); 746 struct cx8800_dev *dev = video_drvdata(file);
735 struct cx88_core *core = dev->core; 747 struct cx88_core *core = dev->core;
@@ -738,7 +750,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
738 unsigned int maxw, maxh; 750 unsigned int maxw, maxh;
739 751
740 fmt = format_by_fourcc(f->fmt.pix.pixelformat); 752 fmt = format_by_fourcc(f->fmt.pix.pixelformat);
741 if (NULL == fmt) 753 if (!fmt)
742 return -EINVAL; 754 return -EINVAL;
743 755
744 maxw = norm_maxw(core->tvnorm); 756 maxw = norm_maxw(core->tvnorm);
@@ -775,13 +787,13 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
775} 787}
776 788
777static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, 789static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
778 struct v4l2_format *f) 790 struct v4l2_format *f)
779{ 791{
780 struct cx8800_dev *dev = video_drvdata(file); 792 struct cx8800_dev *dev = video_drvdata(file);
781 struct cx88_core *core = dev->core; 793 struct cx88_core *core = dev->core;
782 int err = vidioc_try_fmt_vid_cap (file,priv,f); 794 int err = vidioc_try_fmt_vid_cap(file, priv, f);
783 795
784 if (0 != err) 796 if (err != 0)
785 return err; 797 return err;
786 if (vb2_is_busy(&dev->vb2_vidq) || vb2_is_busy(&dev->vb2_vbiq)) 798 if (vb2_is_busy(&dev->vb2_vidq) || vb2_is_busy(&dev->vb2_vbiq))
787 return -EBUSY; 799 return -EBUSY;
@@ -795,13 +807,13 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
795} 807}
796 808
797void cx88_querycap(struct file *file, struct cx88_core *core, 809void cx88_querycap(struct file *file, struct cx88_core *core,
798 struct v4l2_capability *cap) 810 struct v4l2_capability *cap)
799{ 811{
800 struct video_device *vdev = video_devdata(file); 812 struct video_device *vdev = video_devdata(file);
801 813
802 strlcpy(cap->card, core->board.name, sizeof(cap->card)); 814 strlcpy(cap->card, core->board.name, sizeof(cap->card));
803 cap->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING; 815 cap->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
804 if (UNSET != core->board.tuner_type) 816 if (core->board.tuner_type != UNSET)
805 cap->device_caps |= V4L2_CAP_TUNER; 817 cap->device_caps |= V4L2_CAP_TUNER;
806 switch (vdev->vfl_type) { 818 switch (vdev->vfl_type) {
807 case VFL_TYPE_RADIO: 819 case VFL_TYPE_RADIO:
@@ -822,7 +834,7 @@ void cx88_querycap(struct file *file, struct cx88_core *core,
822EXPORT_SYMBOL(cx88_querycap); 834EXPORT_SYMBOL(cx88_querycap);
823 835
824static int vidioc_querycap(struct file *file, void *priv, 836static int vidioc_querycap(struct file *file, void *priv,
825 struct v4l2_capability *cap) 837 struct v4l2_capability *cap)
826{ 838{
827 struct cx8800_dev *dev = video_drvdata(file); 839 struct cx8800_dev *dev = video_drvdata(file);
828 struct cx88_core *core = dev->core; 840 struct cx88_core *core = dev->core;
@@ -833,13 +845,13 @@ static int vidioc_querycap(struct file *file, void *priv,
833 return 0; 845 return 0;
834} 846}
835 847
836static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv, 848static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
837 struct v4l2_fmtdesc *f) 849 struct v4l2_fmtdesc *f)
838{ 850{
839 if (unlikely(f->index >= ARRAY_SIZE(formats))) 851 if (unlikely(f->index >= ARRAY_SIZE(formats)))
840 return -EINVAL; 852 return -EINVAL;
841 853
842 strlcpy(f->description,formats[f->index].name,sizeof(f->description)); 854 strlcpy(f->description, formats[f->index].name, sizeof(f->description));
843 f->pixelformat = formats[f->index].fourcc; 855 f->pixelformat = formats[f->index].fourcc;
844 856
845 return 0; 857 return 0;
@@ -863,45 +875,46 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id tvnorms)
863} 875}
864 876
865/* only one input in this sample driver */ 877/* only one input in this sample driver */
866int cx88_enum_input (struct cx88_core *core,struct v4l2_input *i) 878int cx88_enum_input(struct cx88_core *core, struct v4l2_input *i)
867{ 879{
868 static const char * const iname[] = { 880 static const char * const iname[] = {
869 [ CX88_VMUX_COMPOSITE1 ] = "Composite1", 881 [CX88_VMUX_COMPOSITE1] = "Composite1",
870 [ CX88_VMUX_COMPOSITE2 ] = "Composite2", 882 [CX88_VMUX_COMPOSITE2] = "Composite2",
871 [ CX88_VMUX_COMPOSITE3 ] = "Composite3", 883 [CX88_VMUX_COMPOSITE3] = "Composite3",
872 [ CX88_VMUX_COMPOSITE4 ] = "Composite4", 884 [CX88_VMUX_COMPOSITE4] = "Composite4",
873 [ CX88_VMUX_SVIDEO ] = "S-Video", 885 [CX88_VMUX_SVIDEO] = "S-Video",
874 [ CX88_VMUX_TELEVISION ] = "Television", 886 [CX88_VMUX_TELEVISION] = "Television",
875 [ CX88_VMUX_CABLE ] = "Cable TV", 887 [CX88_VMUX_CABLE] = "Cable TV",
876 [ CX88_VMUX_DVB ] = "DVB", 888 [CX88_VMUX_DVB] = "DVB",
877 [ CX88_VMUX_DEBUG ] = "for debug only", 889 [CX88_VMUX_DEBUG] = "for debug only",
878 }; 890 };
879 unsigned int n = i->index; 891 unsigned int n = i->index;
880 892
881 if (n >= 4) 893 if (n >= 4)
882 return -EINVAL; 894 return -EINVAL;
883 if (0 == INPUT(n).type) 895 if (!INPUT(n).type)
884 return -EINVAL; 896 return -EINVAL;
885 i->type = V4L2_INPUT_TYPE_CAMERA; 897 i->type = V4L2_INPUT_TYPE_CAMERA;
886 strcpy(i->name,iname[INPUT(n).type]); 898 strcpy(i->name, iname[INPUT(n).type]);
887 if ((CX88_VMUX_TELEVISION == INPUT(n).type) || 899 if ((INPUT(n).type == CX88_VMUX_TELEVISION) ||
888 (CX88_VMUX_CABLE == INPUT(n).type)) { 900 (INPUT(n).type == CX88_VMUX_CABLE))
889 i->type = V4L2_INPUT_TYPE_TUNER; 901 i->type = V4L2_INPUT_TYPE_TUNER;
890 } 902
891 i->std = CX88_NORMS; 903 i->std = CX88_NORMS;
892 return 0; 904 return 0;
893} 905}
894EXPORT_SYMBOL(cx88_enum_input); 906EXPORT_SYMBOL(cx88_enum_input);
895 907
896static int vidioc_enum_input (struct file *file, void *priv, 908static int vidioc_enum_input(struct file *file, void *priv,
897 struct v4l2_input *i) 909 struct v4l2_input *i)
898{ 910{
899 struct cx8800_dev *dev = video_drvdata(file); 911 struct cx8800_dev *dev = video_drvdata(file);
900 struct cx88_core *core = dev->core; 912 struct cx88_core *core = dev->core;
901 return cx88_enum_input (core,i); 913
914 return cx88_enum_input(core, i);
902} 915}
903 916
904static int vidioc_g_input (struct file *file, void *priv, unsigned int *i) 917static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
905{ 918{
906 struct cx8800_dev *dev = video_drvdata(file); 919 struct cx8800_dev *dev = video_drvdata(file);
907 struct cx88_core *core = dev->core; 920 struct cx88_core *core = dev->core;
@@ -910,31 +923,31 @@ static int vidioc_g_input (struct file *file, void *priv, unsigned int *i)
910 return 0; 923 return 0;
911} 924}
912 925
913static int vidioc_s_input (struct file *file, void *priv, unsigned int i) 926static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
914{ 927{
915 struct cx8800_dev *dev = video_drvdata(file); 928 struct cx8800_dev *dev = video_drvdata(file);
916 struct cx88_core *core = dev->core; 929 struct cx88_core *core = dev->core;
917 930
918 if (i >= 4) 931 if (i >= 4)
919 return -EINVAL; 932 return -EINVAL;
920 if (0 == INPUT(i).type) 933 if (!INPUT(i).type)
921 return -EINVAL; 934 return -EINVAL;
922 935
923 cx88_newstation(core); 936 cx88_newstation(core);
924 cx88_video_mux(core,i); 937 cx88_video_mux(core, i);
925 return 0; 938 return 0;
926} 939}
927 940
928static int vidioc_g_tuner (struct file *file, void *priv, 941static int vidioc_g_tuner(struct file *file, void *priv,
929 struct v4l2_tuner *t) 942 struct v4l2_tuner *t)
930{ 943{
931 struct cx8800_dev *dev = video_drvdata(file); 944 struct cx8800_dev *dev = video_drvdata(file);
932 struct cx88_core *core = dev->core; 945 struct cx88_core *core = dev->core;
933 u32 reg; 946 u32 reg;
934 947
935 if (unlikely(UNSET == core->board.tuner_type)) 948 if (unlikely(core->board.tuner_type == UNSET))
936 return -EINVAL; 949 return -EINVAL;
937 if (0 != t->index) 950 if (t->index != 0)
938 return -EINVAL; 951 return -EINVAL;
939 952
940 strcpy(t->name, "Television"); 953 strcpy(t->name, "Television");
@@ -942,34 +955,34 @@ static int vidioc_g_tuner (struct file *file, void *priv,
942 t->rangehigh = 0xffffffffUL; 955 t->rangehigh = 0xffffffffUL;
943 call_all(core, tuner, g_tuner, t); 956 call_all(core, tuner, g_tuner, t);
944 957
945 cx88_get_stereo(core ,t); 958 cx88_get_stereo(core, t);
946 reg = cx_read(MO_DEVICE_STATUS); 959 reg = cx_read(MO_DEVICE_STATUS);
947 t->signal = (reg & (1<<5)) ? 0xffff : 0x0000; 960 t->signal = (reg & (1 << 5)) ? 0xffff : 0x0000;
948 return 0; 961 return 0;
949} 962}
950 963
951static int vidioc_s_tuner (struct file *file, void *priv, 964static int vidioc_s_tuner(struct file *file, void *priv,
952 const struct v4l2_tuner *t) 965 const struct v4l2_tuner *t)
953{ 966{
954 struct cx8800_dev *dev = video_drvdata(file); 967 struct cx8800_dev *dev = video_drvdata(file);
955 struct cx88_core *core = dev->core; 968 struct cx88_core *core = dev->core;
956 969
957 if (UNSET == core->board.tuner_type) 970 if (core->board.tuner_type == UNSET)
958 return -EINVAL; 971 return -EINVAL;
959 if (0 != t->index) 972 if (t->index != 0)
960 return -EINVAL; 973 return -EINVAL;
961 974
962 cx88_set_stereo(core, t->audmode, 1); 975 cx88_set_stereo(core, t->audmode, 1);
963 return 0; 976 return 0;
964} 977}
965 978
966static int vidioc_g_frequency (struct file *file, void *priv, 979static int vidioc_g_frequency(struct file *file, void *priv,
967 struct v4l2_frequency *f) 980 struct v4l2_frequency *f)
968{ 981{
969 struct cx8800_dev *dev = video_drvdata(file); 982 struct cx8800_dev *dev = video_drvdata(file);
970 struct cx88_core *core = dev->core; 983 struct cx88_core *core = dev->core;
971 984
972 if (unlikely(UNSET == core->board.tuner_type)) 985 if (unlikely(core->board.tuner_type == UNSET))
973 return -EINVAL; 986 return -EINVAL;
974 if (f->tuner) 987 if (f->tuner)
975 return -EINVAL; 988 return -EINVAL;
@@ -981,12 +994,12 @@ static int vidioc_g_frequency (struct file *file, void *priv,
981 return 0; 994 return 0;
982} 995}
983 996
984int cx88_set_freq (struct cx88_core *core, 997int cx88_set_freq(struct cx88_core *core,
985 const struct v4l2_frequency *f) 998 const struct v4l2_frequency *f)
986{ 999{
987 struct v4l2_frequency new_freq = *f; 1000 struct v4l2_frequency new_freq = *f;
988 1001
989 if (unlikely(UNSET == core->board.tuner_type)) 1002 if (unlikely(core->board.tuner_type == UNSET))
990 return -EINVAL; 1003 return -EINVAL;
991 if (unlikely(f->tuner != 0)) 1004 if (unlikely(f->tuner != 0))
992 return -EINVAL; 1005 return -EINVAL;
@@ -997,15 +1010,15 @@ int cx88_set_freq (struct cx88_core *core,
997 core->freq = new_freq.frequency; 1010 core->freq = new_freq.frequency;
998 1011
999 /* When changing channels it is required to reset TVAUDIO */ 1012 /* When changing channels it is required to reset TVAUDIO */
1000 msleep (10); 1013 usleep_range(10000, 20000);
1001 cx88_set_tvaudio(core); 1014 cx88_set_tvaudio(core);
1002 1015
1003 return 0; 1016 return 0;
1004} 1017}
1005EXPORT_SYMBOL(cx88_set_freq); 1018EXPORT_SYMBOL(cx88_set_freq);
1006 1019
1007static int vidioc_s_frequency (struct file *file, void *priv, 1020static int vidioc_s_frequency(struct file *file, void *priv,
1008 const struct v4l2_frequency *f) 1021 const struct v4l2_frequency *f)
1009{ 1022{
1010 struct cx8800_dev *dev = video_drvdata(file); 1023 struct cx8800_dev *dev = video_drvdata(file);
1011 struct cx88_core *core = dev->core; 1024 struct cx88_core *core = dev->core;
@@ -1014,8 +1027,8 @@ static int vidioc_s_frequency (struct file *file, void *priv,
1014} 1027}
1015 1028
1016#ifdef CONFIG_VIDEO_ADV_DEBUG 1029#ifdef CONFIG_VIDEO_ADV_DEBUG
1017static int vidioc_g_register (struct file *file, void *fh, 1030static int vidioc_g_register(struct file *file, void *fh,
1018 struct v4l2_dbg_register *reg) 1031 struct v4l2_dbg_register *reg)
1019{ 1032{
1020 struct cx8800_dev *dev = video_drvdata(file); 1033 struct cx8800_dev *dev = video_drvdata(file);
1021 struct cx88_core *core = dev->core; 1034 struct cx88_core *core = dev->core;
@@ -1026,8 +1039,8 @@ static int vidioc_g_register (struct file *file, void *fh,
1026 return 0; 1039 return 0;
1027} 1040}
1028 1041
1029static int vidioc_s_register (struct file *file, void *fh, 1042static int vidioc_s_register(struct file *file, void *fh,
1030 const struct v4l2_dbg_register *reg) 1043 const struct v4l2_dbg_register *reg)
1031{ 1044{
1032 struct cx8800_dev *dev = video_drvdata(file); 1045 struct cx8800_dev *dev = video_drvdata(file);
1033 struct cx88_core *core = dev->core; 1046 struct cx88_core *core = dev->core;
@@ -1041,8 +1054,8 @@ static int vidioc_s_register (struct file *file, void *fh,
1041/* RADIO ESPECIFIC IOCTLS */ 1054/* RADIO ESPECIFIC IOCTLS */
1042/* ----------------------------------------------------------- */ 1055/* ----------------------------------------------------------- */
1043 1056
1044static int radio_g_tuner (struct file *file, void *priv, 1057static int radio_g_tuner(struct file *file, void *priv,
1045 struct v4l2_tuner *t) 1058 struct v4l2_tuner *t)
1046{ 1059{
1047 struct cx8800_dev *dev = video_drvdata(file); 1060 struct cx8800_dev *dev = video_drvdata(file);
1048 struct cx88_core *core = dev->core; 1061 struct cx88_core *core = dev->core;
@@ -1056,13 +1069,13 @@ static int radio_g_tuner (struct file *file, void *priv,
1056 return 0; 1069 return 0;
1057} 1070}
1058 1071
1059static int radio_s_tuner (struct file *file, void *priv, 1072static int radio_s_tuner(struct file *file, void *priv,
1060 const struct v4l2_tuner *t) 1073 const struct v4l2_tuner *t)
1061{ 1074{
1062 struct cx8800_dev *dev = video_drvdata(file); 1075 struct cx8800_dev *dev = video_drvdata(file);
1063 struct cx88_core *core = dev->core; 1076 struct cx88_core *core = dev->core;
1064 1077
1065 if (0 != t->index) 1078 if (t->index != 0)
1066 return -EINVAL; 1079 return -EINVAL;
1067 1080
1068 call_all(core, tuner, s_tuner, t); 1081 call_all(core, tuner, s_tuner, t);
@@ -1090,13 +1103,13 @@ static void cx8800_vid_irq(struct cx8800_dev *dev)
1090 return; 1103 return;
1091 cx_write(MO_VID_INTSTAT, status); 1104 cx_write(MO_VID_INTSTAT, status);
1092 if (irq_debug || (status & mask & ~0xff)) 1105 if (irq_debug || (status & mask & ~0xff))
1093 cx88_print_irqbits(core->name, "irq vid", 1106 cx88_print_irqbits("irq vid",
1094 cx88_vid_irqs, ARRAY_SIZE(cx88_vid_irqs), 1107 cx88_vid_irqs, ARRAY_SIZE(cx88_vid_irqs),
1095 status, mask); 1108 status, mask);
1096 1109
1097 /* risc op code error */ 1110 /* risc op code error */
1098 if (status & (1 << 16)) { 1111 if (status & (1 << 16)) {
1099 printk(KERN_WARNING "%s/0: video risc op code error\n",core->name); 1112 pr_warn("video risc op code error\n");
1100 cx_clear(MO_VID_DMACNTRL, 0x11); 1113 cx_clear(MO_VID_DMACNTRL, 0x11);
1101 cx_clear(VID_CAPTURE_CONTROL, 0x06); 1114 cx_clear(VID_CAPTURE_CONTROL, 0x06);
1102 cx88_sram_channel_dump(core, &cx88_sram_channels[SRAM_CH21]); 1115 cx88_sram_channel_dump(core, &cx88_sram_channels[SRAM_CH21]);
@@ -1129,20 +1142,19 @@ static irqreturn_t cx8800_irq(int irq, void *dev_id)
1129 for (loop = 0; loop < 10; loop++) { 1142 for (loop = 0; loop < 10; loop++) {
1130 status = cx_read(MO_PCI_INTSTAT) & 1143 status = cx_read(MO_PCI_INTSTAT) &
1131 (core->pci_irqmask | PCI_INT_VIDINT); 1144 (core->pci_irqmask | PCI_INT_VIDINT);
1132 if (0 == status) 1145 if (status == 0)
1133 goto out; 1146 goto out;
1134 cx_write(MO_PCI_INTSTAT, status); 1147 cx_write(MO_PCI_INTSTAT, status);
1135 handled = 1; 1148 handled = 1;
1136 1149
1137 if (status & core->pci_irqmask) 1150 if (status & core->pci_irqmask)
1138 cx88_core_irq(core,status); 1151 cx88_core_irq(core, status);
1139 if (status & PCI_INT_VIDINT) 1152 if (status & PCI_INT_VIDINT)
1140 cx8800_vid_irq(dev); 1153 cx8800_vid_irq(dev);
1141 } 1154 }
1142 if (10 == loop) { 1155 if (loop == 10) {
1143 printk(KERN_WARNING "%s/0: irq loop -- clearing mask\n", 1156 pr_warn("irq loop -- clearing mask\n");
1144 core->name); 1157 cx_write(MO_PCI_INTMSK, 0);
1145 cx_write(MO_PCI_INTMSK,0);
1146 } 1158 }
1147 1159
1148 out: 1160 out:
@@ -1152,8 +1164,7 @@ static irqreturn_t cx8800_irq(int irq, void *dev_id)
1152/* ----------------------------------------------------------- */ 1164/* ----------------------------------------------------------- */
1153/* exported stuff */ 1165/* exported stuff */
1154 1166
1155static const struct v4l2_file_operations video_fops = 1167static const struct v4l2_file_operations video_fops = {
1156{
1157 .owner = THIS_MODULE, 1168 .owner = THIS_MODULE,
1158 .open = v4l2_fh_open, 1169 .open = v4l2_fh_open,
1159 .release = vb2_fop_release, 1170 .release = vb2_fop_release,
@@ -1195,7 +1206,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
1195static const struct video_device cx8800_video_template = { 1206static const struct video_device cx8800_video_template = {
1196 .name = "cx8800-video", 1207 .name = "cx8800-video",
1197 .fops = &video_fops, 1208 .fops = &video_fops,
1198 .ioctl_ops = &video_ioctl_ops, 1209 .ioctl_ops = &video_ioctl_ops,
1199 .tvnorms = CX88_NORMS, 1210 .tvnorms = CX88_NORMS,
1200}; 1211};
1201 1212
@@ -1232,8 +1243,7 @@ static const struct video_device cx8800_vbi_template = {
1232 .tvnorms = CX88_NORMS, 1243 .tvnorms = CX88_NORMS,
1233}; 1244};
1234 1245
1235static const struct v4l2_file_operations radio_fops = 1246static const struct v4l2_file_operations radio_fops = {
1236{
1237 .owner = THIS_MODULE, 1247 .owner = THIS_MODULE,
1238 .open = radio_open, 1248 .open = radio_open,
1239 .poll = v4l2_ctrl_poll, 1249 .poll = v4l2_ctrl_poll,
@@ -1258,7 +1268,7 @@ static const struct v4l2_ioctl_ops radio_ioctl_ops = {
1258static const struct video_device cx8800_radio_template = { 1268static const struct video_device cx8800_radio_template = {
1259 .name = "cx8800-radio", 1269 .name = "cx8800-radio",
1260 .fops = &radio_fops, 1270 .fops = &radio_fops,
1261 .ioctl_ops = &radio_ioctl_ops, 1271 .ioctl_ops = &radio_ioctl_ops,
1262}; 1272};
1263 1273
1264static const struct v4l2_ctrl_ops cx8800_ctrl_vid_ops = { 1274static const struct v4l2_ctrl_ops cx8800_ctrl_vid_ops = {
@@ -1287,8 +1297,8 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
1287 int err; 1297 int err;
1288 int i; 1298 int i;
1289 1299
1290 dev = kzalloc(sizeof(*dev),GFP_KERNEL); 1300 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1291 if (NULL == dev) 1301 if (!dev)
1292 return -ENOMEM; 1302 return -ENOMEM;
1293 1303
1294 /* pci init */ 1304 /* pci init */
@@ -1298,7 +1308,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
1298 goto fail_free; 1308 goto fail_free;
1299 } 1309 }
1300 core = cx88_core_get(dev->pci); 1310 core = cx88_core_get(dev->pci);
1301 if (NULL == core) { 1311 if (!core) {
1302 err = -EINVAL; 1312 err = -EINVAL;
1303 goto fail_free; 1313 goto fail_free;
1304 } 1314 }
@@ -1307,15 +1317,15 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
1307 /* print pci info */ 1317 /* print pci info */
1308 dev->pci_rev = pci_dev->revision; 1318 dev->pci_rev = pci_dev->revision;
1309 pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat); 1319 pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat);
1310 printk(KERN_INFO "%s/0: found at %s, rev: %d, irq: %d, " 1320 pr_info("found at %s, rev: %d, irq: %d, latency: %d, mmio: 0x%llx\n",
1311 "latency: %d, mmio: 0x%llx\n", core->name, 1321 pci_name(pci_dev), dev->pci_rev, pci_dev->irq,
1312 pci_name(pci_dev), dev->pci_rev, pci_dev->irq, 1322 dev->pci_lat,
1313 dev->pci_lat,(unsigned long long)pci_resource_start(pci_dev,0)); 1323 (unsigned long long)pci_resource_start(pci_dev, 0));
1314 1324
1315 pci_set_master(pci_dev); 1325 pci_set_master(pci_dev);
1316 err = pci_set_dma_mask(pci_dev,DMA_BIT_MASK(32)); 1326 err = pci_set_dma_mask(pci_dev, DMA_BIT_MASK(32));
1317 if (err) { 1327 if (err) {
1318 printk("%s/0: Oops: no 32bit PCI DMA ???\n",core->name); 1328 pr_err("Oops: no 32bit PCI DMA ???\n");
1319 goto fail_core; 1329 goto fail_core;
1320 } 1330 }
1321 1331
@@ -1332,8 +1342,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
1332 err = request_irq(pci_dev->irq, cx8800_irq, 1342 err = request_irq(pci_dev->irq, cx8800_irq,
1333 IRQF_SHARED, core->name, dev); 1343 IRQF_SHARED, core->name, dev);
1334 if (err < 0) { 1344 if (err < 0) {
1335 printk(KERN_ERR "%s/0: can't get IRQ %d\n", 1345 pr_err("can't get IRQ %d\n", pci_dev->irq);
1336 core->name,pci_dev->irq);
1337 goto fail_core; 1346 goto fail_core;
1338 } 1347 }
1339 cx_set(MO_PCI_INTMSK, core->pci_irqmask); 1348 cx_set(MO_PCI_INTMSK, core->pci_irqmask);
@@ -1343,8 +1352,9 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
1343 struct v4l2_ctrl *vc; 1352 struct v4l2_ctrl *vc;
1344 1353
1345 vc = v4l2_ctrl_new_std(&core->audio_hdl, &cx8800_ctrl_aud_ops, 1354 vc = v4l2_ctrl_new_std(&core->audio_hdl, &cx8800_ctrl_aud_ops,
1346 cc->id, cc->minimum, cc->maximum, cc->step, cc->default_value); 1355 cc->id, cc->minimum, cc->maximum,
1347 if (vc == NULL) { 1356 cc->step, cc->default_value);
1357 if (!vc) {
1348 err = core->audio_hdl.error; 1358 err = core->audio_hdl.error;
1349 goto fail_core; 1359 goto fail_core;
1350 } 1360 }
@@ -1356,8 +1366,9 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
1356 struct v4l2_ctrl *vc; 1366 struct v4l2_ctrl *vc;
1357 1367
1358 vc = v4l2_ctrl_new_std(&core->video_hdl, &cx8800_ctrl_vid_ops, 1368 vc = v4l2_ctrl_new_std(&core->video_hdl, &cx8800_ctrl_vid_ops,
1359 cc->id, cc->minimum, cc->maximum, cc->step, cc->default_value); 1369 cc->id, cc->minimum, cc->maximum,
1360 if (vc == NULL) { 1370 cc->step, cc->default_value);
1371 if (!vc) {
1361 err = core->video_hdl.error; 1372 err = core->video_hdl.error;
1362 goto fail_core; 1373 goto fail_core;
1363 } 1374 }
@@ -1383,18 +1394,20 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
1383 core->wm8775_data.is_nova_s = false; 1394 core->wm8775_data.is_nova_s = false;
1384 1395
1385 sd = v4l2_i2c_new_subdev_board(&core->v4l2_dev, &core->i2c_adap, 1396 sd = v4l2_i2c_new_subdev_board(&core->v4l2_dev, &core->i2c_adap,
1386 &wm8775_info, NULL); 1397 &wm8775_info, NULL);
1387 if (sd != NULL) { 1398 if (sd) {
1388 core->sd_wm8775 = sd; 1399 core->sd_wm8775 = sd;
1389 sd->grp_id = WM8775_GID; 1400 sd->grp_id = WM8775_GID;
1390 } 1401 }
1391 } 1402 }
1392 1403
1393 if (core->board.audio_chip == CX88_AUDIO_TVAUDIO) { 1404 if (core->board.audio_chip == CX88_AUDIO_TVAUDIO) {
1394 /* This probes for a tda9874 as is used on some 1405 /*
1395 Pixelview Ultra boards. */ 1406 * This probes for a tda9874 as is used on some
1407 * Pixelview Ultra boards.
1408 */
1396 v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap, 1409 v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap,
1397 "tvaudio", 0, I2C_ADDRS(0xb0 >> 1)); 1410 "tvaudio", 0, I2C_ADDRS(0xb0 >> 1));
1398 } 1411 }
1399 1412
1400 switch (core->boardnr) { 1413 switch (core->boardnr) {
@@ -1470,12 +1483,11 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
1470 err = video_register_device(&dev->video_dev, VFL_TYPE_GRABBER, 1483 err = video_register_device(&dev->video_dev, VFL_TYPE_GRABBER,
1471 video_nr[core->nr]); 1484 video_nr[core->nr]);
1472 if (err < 0) { 1485 if (err < 0) {
1473 printk(KERN_ERR "%s/0: can't register video device\n", 1486 pr_err("can't register video device\n");
1474 core->name);
1475 goto fail_unreg; 1487 goto fail_unreg;
1476 } 1488 }
1477 printk(KERN_INFO "%s/0: registered device %s [v4l2]\n", 1489 pr_info("registered device %s [v4l2]\n",
1478 core->name, video_device_node_name(&dev->video_dev)); 1490 video_device_node_name(&dev->video_dev));
1479 1491
1480 cx88_vdev_init(core, dev->pci, &dev->vbi_dev, 1492 cx88_vdev_init(core, dev->pci, &dev->vbi_dev,
1481 &cx8800_vbi_template, "vbi"); 1493 &cx8800_vbi_template, "vbi");
@@ -1484,12 +1496,11 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
1484 err = video_register_device(&dev->vbi_dev, VFL_TYPE_VBI, 1496 err = video_register_device(&dev->vbi_dev, VFL_TYPE_VBI,
1485 vbi_nr[core->nr]); 1497 vbi_nr[core->nr]);
1486 if (err < 0) { 1498 if (err < 0) {
1487 printk(KERN_ERR "%s/0: can't register vbi device\n", 1499 pr_err("can't register vbi device\n");
1488 core->name);
1489 goto fail_unreg; 1500 goto fail_unreg;
1490 } 1501 }
1491 printk(KERN_INFO "%s/0: registered device %s\n", 1502 pr_info("registered device %s\n",
1492 core->name, video_device_node_name(&dev->vbi_dev)); 1503 video_device_node_name(&dev->vbi_dev));
1493 1504
1494 if (core->board.radio.type == CX88_RADIO) { 1505 if (core->board.radio.type == CX88_RADIO) {
1495 cx88_vdev_init(core, dev->pci, &dev->radio_dev, 1506 cx88_vdev_init(core, dev->pci, &dev->radio_dev,
@@ -1499,21 +1510,21 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
1499 err = video_register_device(&dev->radio_dev, VFL_TYPE_RADIO, 1510 err = video_register_device(&dev->radio_dev, VFL_TYPE_RADIO,
1500 radio_nr[core->nr]); 1511 radio_nr[core->nr]);
1501 if (err < 0) { 1512 if (err < 0) {
1502 printk(KERN_ERR "%s/0: can't register radio device\n", 1513 pr_err("can't register radio device\n");
1503 core->name);
1504 goto fail_unreg; 1514 goto fail_unreg;
1505 } 1515 }
1506 printk(KERN_INFO "%s/0: registered device %s\n", 1516 pr_info("registered device %s\n",
1507 core->name, video_device_node_name(&dev->radio_dev)); 1517 video_device_node_name(&dev->radio_dev));
1508 } 1518 }
1509 1519
1510 /* start tvaudio thread */ 1520 /* start tvaudio thread */
1511 if (core->board.tuner_type != UNSET) { 1521 if (core->board.tuner_type != UNSET) {
1512 core->kthread = kthread_run(cx88_audio_thread, core, "cx88 tvaudio"); 1522 core->kthread = kthread_run(cx88_audio_thread,
1523 core, "cx88 tvaudio");
1513 if (IS_ERR(core->kthread)) { 1524 if (IS_ERR(core->kthread)) {
1514 err = PTR_ERR(core->kthread); 1525 err = PTR_ERR(core->kthread);
1515 printk(KERN_ERR "%s/0: failed to create cx88 audio thread, err=%d\n", 1526 pr_err("failed to create cx88 audio thread, err=%d\n",
1516 core->name, err); 1527 err);
1517 } 1528 }
1518 } 1529 }
1519 mutex_unlock(&core->lock); 1530 mutex_unlock(&core->lock);
@@ -1526,7 +1537,7 @@ fail_unreg:
1526 mutex_unlock(&core->lock); 1537 mutex_unlock(&core->lock);
1527fail_core: 1538fail_core:
1528 core->v4ldev = NULL; 1539 core->v4ldev = NULL;
1529 cx88_core_put(core,dev->pci); 1540 cx88_core_put(core, dev->pci);
1530fail_free: 1541fail_free:
1531 kfree(dev); 1542 kfree(dev);
1532 return err; 1543 return err;
@@ -1557,7 +1568,7 @@ static void cx8800_finidev(struct pci_dev *pci_dev)
1557 core->v4ldev = NULL; 1568 core->v4ldev = NULL;
1558 1569
1559 /* free memory */ 1570 /* free memory */
1560 cx88_core_put(core,dev->pci); 1571 cx88_core_put(core, dev->pci);
1561 kfree(dev); 1572 kfree(dev);
1562} 1573}
1563 1574
@@ -1571,11 +1582,11 @@ static int cx8800_suspend(struct pci_dev *pci_dev, pm_message_t state)
1571 /* stop video+vbi capture */ 1582 /* stop video+vbi capture */
1572 spin_lock_irqsave(&dev->slock, flags); 1583 spin_lock_irqsave(&dev->slock, flags);
1573 if (!list_empty(&dev->vidq.active)) { 1584 if (!list_empty(&dev->vidq.active)) {
1574 printk("%s/0: suspend video\n", core->name); 1585 pr_info("suspend video\n");
1575 stop_video_dma(dev); 1586 stop_video_dma(dev);
1576 } 1587 }
1577 if (!list_empty(&dev->vbiq.active)) { 1588 if (!list_empty(&dev->vbiq.active)) {
1578 printk("%s/0: suspend vbi\n", core->name); 1589 pr_info("suspend vbi\n");
1579 cx8800_stop_vbi_dma(dev); 1590 cx8800_stop_vbi_dma(dev);
1580 } 1591 }
1581 spin_unlock_irqrestore(&dev->slock, flags); 1592 spin_unlock_irqrestore(&dev->slock, flags);
@@ -1586,7 +1597,8 @@ static int cx8800_suspend(struct pci_dev *pci_dev, pm_message_t state)
1586 cx88_shutdown(core); 1597 cx88_shutdown(core);
1587 1598
1588 pci_save_state(pci_dev); 1599 pci_save_state(pci_dev);
1589 if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) { 1600 if (pci_set_power_state(pci_dev,
1601 pci_choose_state(pci_dev, state)) != 0) {
1590 pci_disable_device(pci_dev); 1602 pci_disable_device(pci_dev);
1591 dev->state.disabled = 1; 1603 dev->state.disabled = 1;
1592 } 1604 }
@@ -1601,18 +1613,17 @@ static int cx8800_resume(struct pci_dev *pci_dev)
1601 int err; 1613 int err;
1602 1614
1603 if (dev->state.disabled) { 1615 if (dev->state.disabled) {
1604 err=pci_enable_device(pci_dev); 1616 err = pci_enable_device(pci_dev);
1605 if (err) { 1617 if (err) {
1606 printk(KERN_ERR "%s/0: can't enable device\n", 1618 pr_err("can't enable device\n");
1607 core->name);
1608 return err; 1619 return err;
1609 } 1620 }
1610 1621
1611 dev->state.disabled = 0; 1622 dev->state.disabled = 0;
1612 } 1623 }
1613 err= pci_set_power_state(pci_dev, PCI_D0); 1624 err = pci_set_power_state(pci_dev, PCI_D0);
1614 if (err) { 1625 if (err) {
1615 printk(KERN_ERR "%s/0: can't set power state\n", core->name); 1626 pr_err("can't set power state\n");
1616 pci_disable_device(pci_dev); 1627 pci_disable_device(pci_dev);
1617 dev->state.disabled = 1; 1628 dev->state.disabled = 1;
1618 1629
@@ -1630,12 +1641,12 @@ static int cx8800_resume(struct pci_dev *pci_dev)
1630 /* restart video+vbi capture */ 1641 /* restart video+vbi capture */
1631 spin_lock_irqsave(&dev->slock, flags); 1642 spin_lock_irqsave(&dev->slock, flags);
1632 if (!list_empty(&dev->vidq.active)) { 1643 if (!list_empty(&dev->vidq.active)) {
1633 printk("%s/0: resume video\n", core->name); 1644 pr_info("resume video\n");
1634 restart_video_queue(dev,&dev->vidq); 1645 restart_video_queue(dev, &dev->vidq);
1635 } 1646 }
1636 if (!list_empty(&dev->vbiq.active)) { 1647 if (!list_empty(&dev->vbiq.active)) {
1637 printk("%s/0: resume vbi\n", core->name); 1648 pr_info("resume vbi\n");
1638 cx8800_restart_vbi_queue(dev,&dev->vbiq); 1649 cx8800_restart_vbi_queue(dev, &dev->vbiq);
1639 } 1650 }
1640 spin_unlock_irqrestore(&dev->slock, flags); 1651 spin_unlock_irqrestore(&dev->slock, flags);
1641 1652
@@ -1651,7 +1662,7 @@ static const struct pci_device_id cx8800_pci_tbl[] = {
1651 .device = 0x8800, 1662 .device = 0x8800,
1652 .subvendor = PCI_ANY_ID, 1663 .subvendor = PCI_ANY_ID,
1653 .subdevice = PCI_ANY_ID, 1664 .subdevice = PCI_ANY_ID,
1654 },{ 1665 }, {
1655 /* --- end of list --- */ 1666 /* --- end of list --- */
1656 } 1667 }
1657}; 1668};
diff --git a/drivers/media/pci/cx88/cx88-vp3054-i2c.c b/drivers/media/pci/cx88/cx88-vp3054-i2c.c
index deede6e25d94..92876de3841c 100644
--- a/drivers/media/pci/cx88/cx88-vp3054-i2c.c
+++ b/drivers/media/pci/cx88/cx88-vp3054-i2c.c
@@ -1,35 +1,28 @@
1/* 1/*
2 * cx88-vp3054-i2c.c -- support for the secondary I2C bus of the
3 * DNTV Live! DVB-T Pro (VP-3054), wired as:
4 * GPIO[0] -> SCL, GPIO[1] -> SDA
5 *
6 * (c) 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>
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 */
2 18
3 cx88-vp3054-i2c.c -- support for the secondary I2C bus of the 19#include "cx88.h"
4 DNTV Live! DVB-T Pro (VP-3054), wired as: 20#include "cx88-vp3054-i2c.h"
5 GPIO[0] -> SCL, GPIO[1] -> SDA
6
7 (c) 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>
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., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23*/
24 21
25#include <linux/module.h> 22#include <linux/module.h>
26#include <linux/slab.h> 23#include <linux/slab.h>
27#include <linux/init.h> 24#include <linux/init.h>
28 25#include <linux/io.h>
29#include <asm/io.h>
30
31#include "cx88.h"
32#include "cx88-vp3054-i2c.h"
33 26
34MODULE_DESCRIPTION("driver for cx2388x VP3054 design"); 27MODULE_DESCRIPTION("driver for cx2388x VP3054 design");
35MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>"); 28MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
@@ -114,7 +107,7 @@ int vp3054_i2c_probe(struct cx8802_dev *dev)
114 return 0; 107 return 0;
115 108
116 vp3054_i2c = kzalloc(sizeof(*vp3054_i2c), GFP_KERNEL); 109 vp3054_i2c = kzalloc(sizeof(*vp3054_i2c), GFP_KERNEL);
117 if (vp3054_i2c == NULL) 110 if (!vp3054_i2c)
118 return -ENOMEM; 111 return -ENOMEM;
119 dev->vp3054 = vp3054_i2c; 112 dev->vp3054 = vp3054_i2c;
120 113
@@ -128,12 +121,12 @@ int vp3054_i2c_probe(struct cx8802_dev *dev)
128 i2c_set_adapdata(&vp3054_i2c->adap, dev); 121 i2c_set_adapdata(&vp3054_i2c->adap, dev);
129 vp3054_i2c->adap.algo_data = &vp3054_i2c->algo; 122 vp3054_i2c->adap.algo_data = &vp3054_i2c->algo;
130 123
131 vp3054_bit_setscl(dev,1); 124 vp3054_bit_setscl(dev, 1);
132 vp3054_bit_setsda(dev,1); 125 vp3054_bit_setsda(dev, 1);
133 126
134 rc = i2c_bit_add_bus(&vp3054_i2c->adap); 127 rc = i2c_bit_add_bus(&vp3054_i2c->adap);
135 if (0 != rc) { 128 if (rc != 0) {
136 printk("%s: vp3054_i2c register FAILED\n", core->name); 129 pr_err("vp3054_i2c register FAILED\n");
137 130
138 kfree(dev->vp3054); 131 kfree(dev->vp3054);
139 dev->vp3054 = NULL; 132 dev->vp3054 = NULL;
@@ -141,18 +134,17 @@ int vp3054_i2c_probe(struct cx8802_dev *dev)
141 134
142 return rc; 135 return rc;
143} 136}
137EXPORT_SYMBOL(vp3054_i2c_probe);
144 138
145void vp3054_i2c_remove(struct cx8802_dev *dev) 139void vp3054_i2c_remove(struct cx8802_dev *dev)
146{ 140{
147 struct vp3054_i2c_state *vp3054_i2c = dev->vp3054; 141 struct vp3054_i2c_state *vp3054_i2c = dev->vp3054;
148 142
149 if (vp3054_i2c == NULL || 143 if (!vp3054_i2c ||
150 dev->core->boardnr != CX88_BOARD_DNTV_LIVE_DVB_T_PRO) 144 dev->core->boardnr != CX88_BOARD_DNTV_LIVE_DVB_T_PRO)
151 return; 145 return;
152 146
153 i2c_del_adapter(&vp3054_i2c->adap); 147 i2c_del_adapter(&vp3054_i2c->adap);
154 kfree(vp3054_i2c); 148 kfree(vp3054_i2c);
155} 149}
156
157EXPORT_SYMBOL(vp3054_i2c_probe);
158EXPORT_SYMBOL(vp3054_i2c_remove); 150EXPORT_SYMBOL(vp3054_i2c_remove);
diff --git a/drivers/media/pci/cx88/cx88-vp3054-i2c.h b/drivers/media/pci/cx88/cx88-vp3054-i2c.h
index 95d0c60a35e1..ec19bea8f1e2 100644
--- a/drivers/media/pci/cx88/cx88-vp3054-i2c.h
+++ b/drivers/media/pci/cx88/cx88-vp3054-i2c.h
@@ -1,26 +1,20 @@
1/* 1/*
2 2 * cx88-vp3054-i2c.h -- support for the secondary I2C bus of the
3 cx88-vp3054-i2c.h -- support for the secondary I2C bus of the 3 * DNTV Live! DVB-T Pro (VP-3054), wired as:
4 DNTV Live! DVB-T Pro (VP-3054), wired as: 4 * GPIO[0] -> SCL, GPIO[1] -> SDA
5 GPIO[0] -> SCL, GPIO[1] -> SDA 5 *
6 6 * (c) 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>
7 (c) 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au> 7 *
8 8 * This program is free software; you can redistribute it and/or modify
9 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 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 the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version.
12 (at your option) any later version. 12 *
13 13 * This program is distributed in the hope that it will be useful,
14 This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details.
17 GNU General Public License for more details. 17 */
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*/
24 18
25/* ----------------------------------------------------------------------- */ 19/* ----------------------------------------------------------------------- */
26struct vp3054_i2c_state { 20struct vp3054_i2c_state {
diff --git a/drivers/media/pci/cx88/cx88.h b/drivers/media/pci/cx88/cx88.h
index ecd4b7bece99..115414cf520f 100644
--- a/drivers/media/pci/cx88/cx88.h
+++ b/drivers/media/pci/cx88/cx88.h
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * v4l2 device driver for cx2388x based TV cards 2 * v4l2 device driver for cx2388x based TV cards
4 * 3 *
5 * (c) 2003,04 Gerd Knorr <kraxel@bytesex.org> [SUSE Labs] 4 * (c) 2003,04 Gerd Knorr <kraxel@bytesex.org> [SUSE Labs]
@@ -13,12 +12,13 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 14 * 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 */ 15 */
21 16
17#ifndef CX88_H
18#define CX88_H
19
20#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
21
22#include <linux/pci.h> 22#include <linux/pci.h>
23#include <linux/i2c.h> 23#include <linux/i2c.h>
24#include <linux/i2c-algo-bit.h> 24#include <linux/i2c-algo-bit.h>
@@ -53,7 +53,7 @@
53/* defines and enums */ 53/* defines and enums */
54 54
55/* Currently unsupported by the driver: PAL/H, NTSC/Kr, SECAM/LC */ 55/* Currently unsupported by the driver: PAL/H, NTSC/Kr, SECAM/LC */
56#define CX88_NORMS (V4L2_STD_ALL \ 56#define CX88_NORMS (V4L2_STD_ALL \
57 & ~V4L2_STD_PAL_H \ 57 & ~V4L2_STD_PAL_H \
58 & ~V4L2_STD_NTSC_M_KR \ 58 & ~V4L2_STD_NTSC_M_KR \
59 & ~V4L2_STD_SECAM_LC) 59 & ~V4L2_STD_SECAM_LC)
@@ -98,7 +98,6 @@ static inline unsigned int norm_maxw(v4l2_std_id norm)
98 return 720; 98 return 720;
99} 99}
100 100
101
102static inline unsigned int norm_maxh(v4l2_std_id norm) 101static inline unsigned int norm_maxh(v4l2_std_id norm)
103{ 102{
104 return (norm & V4L2_STD_525_60) ? 480 : 576; 103 return (norm & V4L2_STD_525_60) ? 480 : 576;
@@ -140,6 +139,7 @@ struct sram_channel {
140 u32 cnt1_reg; 139 u32 cnt1_reg;
141 u32 cnt2_reg; 140 u32 cnt2_reg;
142}; 141};
142
143extern const struct sram_channel cx88_sram_channels[]; 143extern const struct sram_channel cx88_sram_channels[];
144 144
145/* ----------------------------------------------------------- */ 145/* ----------------------------------------------------------- */
@@ -361,12 +361,12 @@ struct cx88_core {
361 u32 i2c_state, i2c_rc; 361 u32 i2c_state, i2c_rc;
362 362
363 /* config info -- analog */ 363 /* config info -- analog */
364 struct v4l2_device v4l2_dev; 364 struct v4l2_device v4l2_dev;
365 struct v4l2_ctrl_handler video_hdl; 365 struct v4l2_ctrl_handler video_hdl;
366 struct v4l2_ctrl *chroma_agc; 366 struct v4l2_ctrl *chroma_agc;
367 struct v4l2_ctrl_handler audio_hdl; 367 struct v4l2_ctrl_handler audio_hdl;
368 struct v4l2_subdev *sd_wm8775; 368 struct v4l2_subdev *sd_wm8775;
369 struct i2c_client *i2c_rtc; 369 struct i2c_client *i2c_rtc;
370 unsigned int boardnr; 370 unsigned int boardnr;
371 struct cx88_board board; 371 struct cx88_board board;
372 372
@@ -383,8 +383,8 @@ struct cx88_core {
383 /* state info */ 383 /* state info */
384 struct task_struct *kthread; 384 struct task_struct *kthread;
385 v4l2_std_id tvnorm; 385 v4l2_std_id tvnorm;
386 unsigned width, height; 386 unsigned int width, height;
387 unsigned field; 387 unsigned int field;
388 enum cx88_tvaudio tvaudio; 388 enum cx88_tvaudio tvaudio;
389 u32 audiomode_manual; 389 u32 audiomode_manual;
390 u32 audiomode_current; 390 u32 audiomode_current;
@@ -427,7 +427,8 @@ static inline struct cx88_core *to_core(struct v4l2_device *v4l2_dev)
427 if (!core->i2c_rc) { \ 427 if (!core->i2c_rc) { \
428 if (core->gate_ctrl) \ 428 if (core->gate_ctrl) \
429 core->gate_ctrl(core, 1); \ 429 core->gate_ctrl(core, 1); \
430 v4l2_device_call_all(&core->v4l2_dev, grpid, o, f, ##args); \ 430 v4l2_device_call_all(&core->v4l2_dev, \
431 grpid, o, f, ##args); \
431 if (core->gate_ctrl) \ 432 if (core->gate_ctrl) \
432 core->gate_ctrl(core, 0); \ 433 core->gate_ctrl(core, 0); \
433 } \ 434 } \
@@ -438,31 +439,31 @@ static inline struct cx88_core *to_core(struct v4l2_device *v4l2_dev)
438#define WM8775_GID (1 << 0) 439#define WM8775_GID (1 << 0)
439 440
440#define wm8775_s_ctrl(core, id, val) \ 441#define wm8775_s_ctrl(core, id, val) \
441 do { \ 442 do { \
442 struct v4l2_ctrl *ctrl_ = \ 443 struct v4l2_ctrl *ctrl_ = \
443 v4l2_ctrl_find(core->sd_wm8775->ctrl_handler, id); \ 444 v4l2_ctrl_find(core->sd_wm8775->ctrl_handler, id);\
444 if (ctrl_ && !core->i2c_rc) { \ 445 if (ctrl_ && !core->i2c_rc) { \
445 if (core->gate_ctrl) \ 446 if (core->gate_ctrl) \
446 core->gate_ctrl(core, 1); \ 447 core->gate_ctrl(core, 1); \
447 v4l2_ctrl_s_ctrl(ctrl_, val); \ 448 v4l2_ctrl_s_ctrl(ctrl_, val); \
448 if (core->gate_ctrl) \ 449 if (core->gate_ctrl) \
449 core->gate_ctrl(core, 0); \ 450 core->gate_ctrl(core, 0); \
450 } \ 451 } \
451 } while (0) 452 } while (0)
452 453
453#define wm8775_g_ctrl(core, id) \ 454#define wm8775_g_ctrl(core, id) \
454 ({ \ 455 ({ \
455 struct v4l2_ctrl *ctrl_ = \ 456 struct v4l2_ctrl *ctrl_ = \
456 v4l2_ctrl_find(core->sd_wm8775->ctrl_handler, id); \ 457 v4l2_ctrl_find(core->sd_wm8775->ctrl_handler, id);\
457 s32 val = 0; \ 458 s32 val = 0; \
458 if (ctrl_ && !core->i2c_rc) { \ 459 if (ctrl_ && !core->i2c_rc) { \
459 if (core->gate_ctrl) \ 460 if (core->gate_ctrl) \
460 core->gate_ctrl(core, 1); \ 461 core->gate_ctrl(core, 1); \
461 val = v4l2_ctrl_g_ctrl(ctrl_); \ 462 val = v4l2_ctrl_g_ctrl(ctrl_); \
462 if (core->gate_ctrl) \ 463 if (core->gate_ctrl) \
463 core->gate_ctrl(core, 0); \ 464 core->gate_ctrl(core, 0); \
464 } \ 465 } \
465 val; \ 466 val; \
466 }) 467 })
467 468
468/* ----------------------------------------------------------- */ 469/* ----------------------------------------------------------- */
@@ -484,7 +485,7 @@ struct cx8800_dev {
484 485
485 /* pci i/o */ 486 /* pci i/o */
486 struct pci_dev *pci; 487 struct pci_dev *pci;
487 unsigned char pci_rev,pci_lat; 488 unsigned char pci_rev, pci_lat;
488 489
489 const struct cx8800_fmt *fmt; 490 const struct cx8800_fmt *fmt;
490 491
@@ -504,7 +505,6 @@ struct cx8800_dev {
504/* function 1: audio/alsa stuff */ 505/* function 1: audio/alsa stuff */
505/* =============> moved to cx88-alsa.c <====================== */ 506/* =============> moved to cx88-alsa.c <====================== */
506 507
507
508/* ----------------------------------------------------------- */ 508/* ----------------------------------------------------------- */
509/* function 2: mpeg stuff */ 509/* function 2: mpeg stuff */
510 510
@@ -547,7 +547,7 @@ struct cx8802_dev {
547 547
548 /* pci i/o */ 548 /* pci i/o */
549 struct pci_dev *pci; 549 struct pci_dev *pci;
550 unsigned char pci_rev,pci_lat; 550 unsigned char pci_rev, pci_lat;
551 551
552 /* dma queues */ 552 /* dma queues */
553 struct cx88_dmaqueue mpegq; 553 struct cx88_dmaqueue mpegq;
@@ -566,6 +566,7 @@ struct cx8802_dev {
566 566
567 /* mpeg params */ 567 /* mpeg params */
568 struct cx2341x_handler cxhdl; 568 struct cx2341x_handler cxhdl;
569
569#endif 570#endif
570 571
571#if IS_ENABLED(CONFIG_VIDEO_CX88_DVB) 572#if IS_ENABLED(CONFIG_VIDEO_CX88_DVB)
@@ -588,40 +589,42 @@ struct cx8802_dev {
588 589
589/* ----------------------------------------------------------- */ 590/* ----------------------------------------------------------- */
590 591
591#define cx_read(reg) readl(core->lmmio + ((reg)>>2)) 592#define cx_read(reg) readl(core->lmmio + ((reg) >> 2))
592#define cx_write(reg,value) writel((value), core->lmmio + ((reg)>>2)) 593#define cx_write(reg, value) writel((value), core->lmmio + ((reg) >> 2))
593#define cx_writeb(reg,value) writeb((value), core->bmmio + (reg)) 594#define cx_writeb(reg, value) writeb((value), core->bmmio + (reg))
594 595
595#define cx_andor(reg,mask,value) \ 596#define cx_andor(reg, mask, value) \
596 writel((readl(core->lmmio+((reg)>>2)) & ~(mask)) |\ 597 writel((readl(core->lmmio + ((reg) >> 2)) & ~(mask)) |\
597 ((value) & (mask)), core->lmmio+((reg)>>2)) 598 ((value) & (mask)), core->lmmio + ((reg) >> 2))
598#define cx_set(reg,bit) cx_andor((reg),(bit),(bit)) 599#define cx_set(reg, bit) cx_andor((reg), (bit), (bit))
599#define cx_clear(reg,bit) cx_andor((reg),(bit),0) 600#define cx_clear(reg, bit) cx_andor((reg), (bit), 0)
600 601
601#define cx_wait(d) { if (need_resched()) schedule(); else udelay(d); } 602#define cx_wait(d) { if (need_resched()) schedule(); else udelay(d); }
602 603
603/* shadow registers */ 604/* shadow registers */
604#define cx_sread(sreg) (core->shadow[sreg]) 605#define cx_sread(sreg) (core->shadow[sreg])
605#define cx_swrite(sreg,reg,value) \ 606#define cx_swrite(sreg, reg, value) \
606 (core->shadow[sreg] = value, \ 607 (core->shadow[sreg] = value, \
607 writel(core->shadow[sreg], core->lmmio + ((reg)>>2))) 608 writel(core->shadow[sreg], core->lmmio + ((reg) >> 2)))
608#define cx_sandor(sreg,reg,mask,value) \ 609#define cx_sandor(sreg, reg, mask, value) \
609 (core->shadow[sreg] = (core->shadow[sreg] & ~(mask)) | ((value) & (mask)), \ 610 (core->shadow[sreg] = (core->shadow[sreg] & ~(mask)) | \
610 writel(core->shadow[sreg], core->lmmio + ((reg)>>2))) 611 ((value) & (mask)), \
612 writel(core->shadow[sreg], \
613 core->lmmio + ((reg) >> 2)))
611 614
612/* ----------------------------------------------------------- */ 615/* ----------------------------------------------------------- */
613/* cx88-core.c */ 616/* cx88-core.c */
614 617
615extern unsigned int cx88_core_debug; 618extern unsigned int cx88_core_debug;
616 619
617extern void cx88_print_irqbits(const char *name, const char *tag, const char *strings[], 620void cx88_print_irqbits(const char *tag, const char *strings[],
618 int len, u32 bits, u32 mask); 621 int len, u32 bits, u32 mask);
619 622
620extern int cx88_core_irq(struct cx88_core *core, u32 status); 623int cx88_core_irq(struct cx88_core *core, u32 status);
621extern void cx88_wakeup(struct cx88_core *core, 624void cx88_wakeup(struct cx88_core *core,
622 struct cx88_dmaqueue *q, u32 count); 625 struct cx88_dmaqueue *q, u32 count);
623extern void cx88_shutdown(struct cx88_core *core); 626void cx88_shutdown(struct cx88_core *core);
624extern int cx88_reset(struct cx88_core *core); 627int cx88_reset(struct cx88_core *core);
625 628
626extern int 629extern int
627cx88_risc_buffer(struct pci_dev *pci, struct cx88_riscmem *risc, 630cx88_risc_buffer(struct pci_dev *pci, struct cx88_riscmem *risc,
@@ -633,43 +636,37 @@ cx88_risc_databuffer(struct pci_dev *pci, struct cx88_riscmem *risc,
633 struct scatterlist *sglist, unsigned int bpl, 636 struct scatterlist *sglist, unsigned int bpl,
634 unsigned int lines, unsigned int lpi); 637 unsigned int lines, unsigned int lpi);
635 638
636extern void cx88_risc_disasm(struct cx88_core *core, 639void cx88_risc_disasm(struct cx88_core *core,
637 struct cx88_riscmem *risc); 640 struct cx88_riscmem *risc);
638extern int cx88_sram_channel_setup(struct cx88_core *core, 641int cx88_sram_channel_setup(struct cx88_core *core,
639 const struct sram_channel *ch, 642 const struct sram_channel *ch,
640 unsigned int bpl, u32 risc); 643 unsigned int bpl, u32 risc);
641extern void cx88_sram_channel_dump(struct cx88_core *core, 644void cx88_sram_channel_dump(struct cx88_core *core,
642 const struct sram_channel *ch); 645 const struct sram_channel *ch);
643 646
644extern int cx88_set_scale(struct cx88_core *core, unsigned int width, 647int cx88_set_scale(struct cx88_core *core, unsigned int width,
645 unsigned int height, enum v4l2_field field); 648 unsigned int height, enum v4l2_field field);
646extern int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm); 649int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm);
647 650
648extern void cx88_vdev_init(struct cx88_core *core, 651void cx88_vdev_init(struct cx88_core *core,
649 struct pci_dev *pci, 652 struct pci_dev *pci,
650 struct video_device *vfd, 653 struct video_device *vfd,
651 const struct video_device *template_, 654 const struct video_device *template_,
652 const char *type); 655 const char *type);
653extern struct cx88_core *cx88_core_get(struct pci_dev *pci); 656struct cx88_core *cx88_core_get(struct pci_dev *pci);
654extern void cx88_core_put(struct cx88_core *core, 657void cx88_core_put(struct cx88_core *core,
655 struct pci_dev *pci); 658 struct pci_dev *pci);
656 659
657extern int cx88_start_audio_dma(struct cx88_core *core); 660int cx88_start_audio_dma(struct cx88_core *core);
658extern int cx88_stop_audio_dma(struct cx88_core *core); 661int cx88_stop_audio_dma(struct cx88_core *core);
659
660 662
661/* ----------------------------------------------------------- */ 663/* ----------------------------------------------------------- */
662/* cx88-vbi.c */ 664/* cx88-vbi.c */
663 665
664/* Can be used as g_vbi_fmt, try_vbi_fmt and s_vbi_fmt */ 666/* Can be used as g_vbi_fmt, try_vbi_fmt and s_vbi_fmt */
665int cx8800_vbi_fmt (struct file *file, void *priv, 667int cx8800_vbi_fmt(struct file *file, void *priv,
666 struct v4l2_format *f); 668 struct v4l2_format *f);
667 669
668/*
669int cx8800_start_vbi_dma(struct cx8800_dev *dev,
670 struct cx88_dmaqueue *q,
671 struct cx88_buffer *buf);
672*/
673void cx8800_stop_vbi_dma(struct cx8800_dev *dev); 670void cx8800_stop_vbi_dma(struct cx8800_dev *dev);
674int cx8800_restart_vbi_queue(struct cx8800_dev *dev, struct cx88_dmaqueue *q); 671int cx8800_restart_vbi_queue(struct cx8800_dev *dev, struct cx88_dmaqueue *q);
675 672
@@ -678,17 +675,16 @@ extern const struct vb2_ops cx8800_vbi_qops;
678/* ----------------------------------------------------------- */ 675/* ----------------------------------------------------------- */
679/* cx88-i2c.c */ 676/* cx88-i2c.c */
680 677
681extern int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci); 678int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci);
682
683 679
684/* ----------------------------------------------------------- */ 680/* ----------------------------------------------------------- */
685/* cx88-cards.c */ 681/* cx88-cards.c */
686 682
687extern int cx88_tuner_callback(void *dev, int component, int command, int arg); 683int cx88_tuner_callback(void *dev, int component, int command, int arg);
688extern int cx88_get_resources(const struct cx88_core *core, 684int cx88_get_resources(const struct cx88_core *core,
689 struct pci_dev *pci); 685 struct pci_dev *pci);
690extern struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr); 686struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr);
691extern void cx88_setup_xc3028(struct cx88_core *core, struct xc2028_ctrl *ctl); 687void cx88_setup_xc3028(struct cx88_core *core, struct xc2028_ctrl *ctl);
692 688
693/* ----------------------------------------------------------- */ 689/* ----------------------------------------------------------- */
694/* cx88-tvaudio.c */ 690/* cx88-tvaudio.c */
@@ -703,7 +699,8 @@ int cx8802_register_driver(struct cx8802_driver *drv);
703int cx8802_unregister_driver(struct cx8802_driver *drv); 699int cx8802_unregister_driver(struct cx8802_driver *drv);
704 700
705/* Caller must hold core->lock */ 701/* Caller must hold core->lock */
706struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype); 702struct cx8802_driver *cx8802_get_driver(struct cx8802_dev *dev,
703 enum cx88_board_type btype);
707 704
708/* ----------------------------------------------------------- */ 705/* ----------------------------------------------------------- */
709/* cx88-dsp.c */ 706/* cx88-dsp.c */
@@ -718,18 +715,18 @@ int cx88_ir_fini(struct cx88_core *core);
718void cx88_ir_irq(struct cx88_core *core); 715void cx88_ir_irq(struct cx88_core *core);
719int cx88_ir_start(struct cx88_core *core); 716int cx88_ir_start(struct cx88_core *core);
720void cx88_ir_stop(struct cx88_core *core); 717void cx88_ir_stop(struct cx88_core *core);
721extern void cx88_i2c_init_ir(struct cx88_core *core); 718void cx88_i2c_init_ir(struct cx88_core *core);
722 719
723/* ----------------------------------------------------------- */ 720/* ----------------------------------------------------------- */
724/* cx88-mpeg.c */ 721/* cx88-mpeg.c */
725 722
726int cx8802_buf_prepare(struct vb2_queue *q, struct cx8802_dev *dev, 723int cx8802_buf_prepare(struct vb2_queue *q, struct cx8802_dev *dev,
727 struct cx88_buffer *buf); 724 struct cx88_buffer *buf);
728void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf); 725void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf);
729void cx8802_cancel_buffers(struct cx8802_dev *dev); 726void cx8802_cancel_buffers(struct cx8802_dev *dev);
730int cx8802_start_dma(struct cx8802_dev *dev, 727int cx8802_start_dma(struct cx8802_dev *dev,
731 struct cx88_dmaqueue *q, 728 struct cx88_dmaqueue *q,
732 struct cx88_buffer *buf); 729 struct cx88_buffer *buf);
733 730
734/* ----------------------------------------------------------- */ 731/* ----------------------------------------------------------- */
735/* cx88-video.c*/ 732/* cx88-video.c*/
@@ -737,4 +734,6 @@ int cx88_enum_input(struct cx88_core *core, struct v4l2_input *i);
737int cx88_set_freq(struct cx88_core *core, const struct v4l2_frequency *f); 734int cx88_set_freq(struct cx88_core *core, const struct v4l2_frequency *f);
738int cx88_video_mux(struct cx88_core *core, unsigned int input); 735int cx88_video_mux(struct cx88_core *core, unsigned int input);
739void cx88_querycap(struct file *file, struct cx88_core *core, 736void cx88_querycap(struct file *file, struct cx88_core *core,
740 struct v4l2_capability *cap); 737 struct v4l2_capability *cap);
738
739#endif
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c
index 18e3a4deee64..a6c9fe235974 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -824,8 +824,7 @@ static int dvb_input_attach(struct ddb_input *input)
824 &input->port->dev->pdev->dev, 824 &input->port->dev->pdev->dev,
825 adapter_nr); 825 adapter_nr);
826 if (ret < 0) { 826 if (ret < 0) {
827 printk(KERN_ERR "ddbridge: Could not register adapter." 827 printk(KERN_ERR "ddbridge: Could not register adapter.Check if you enabled enough adapters in dvb-core!\n");
828 "Check if you enabled enough adapters in dvb-core!\n");
829 return ret; 828 return ret;
830 } 829 }
831 input->attached = 1; 830 input->attached = 1;
@@ -1730,8 +1729,7 @@ static __init int module_init_ddbridge(void)
1730{ 1729{
1731 int ret; 1730 int ret;
1732 1731
1733 printk(KERN_INFO "Digital Devices PCIE bridge driver, " 1732 printk(KERN_INFO "Digital Devices PCIE bridge driver, Copyright (C) 2010-11 Digital Devices GmbH\n");
1734 "Copyright (C) 2010-11 Digital Devices GmbH\n");
1735 1733
1736 ret = ddb_class_create(); 1734 ret = ddb_class_create();
1737 if (ret < 0) 1735 if (ret < 0)
diff --git a/drivers/media/pci/dm1105/dm1105.c b/drivers/media/pci/dm1105/dm1105.c
index 5dd504741b12..a589aa78d1d9 100644
--- a/drivers/media/pci/dm1105/dm1105.c
+++ b/drivers/media/pci/dm1105/dm1105.c
@@ -315,8 +315,7 @@ static void dm1105_card_list(struct pci_dev *pci)
315 "dm1105: Updating to the latest version might help\n" 315 "dm1105: Updating to the latest version might help\n"
316 "dm1105: as well.\n"); 316 "dm1105: as well.\n");
317 } 317 }
318 printk(KERN_ERR "Here is a list of valid choices for the card=<n> " 318 printk(KERN_ERR "Here is a list of valid choices for the card=<n> insmod option:\n");
319 "insmod option:\n");
320 for (i = 0; i < ARRAY_SIZE(dm1105_boards); i++) 319 for (i = 0; i < ARRAY_SIZE(dm1105_boards); i++)
321 printk(KERN_ERR "dm1105: card=%d -> %s\n", 320 printk(KERN_ERR "dm1105: card=%d -> %s\n",
322 i, dm1105_boards[i].name); 321 i, dm1105_boards[i].name);
diff --git a/drivers/media/pci/ivtv/ivtv-alsa-main.c b/drivers/media/pci/ivtv/ivtv-alsa-main.c
index 8a86b61a896d..374f45f81ab3 100644
--- a/drivers/media/pci/ivtv/ivtv-alsa-main.c
+++ b/drivers/media/pci/ivtv/ivtv-alsa-main.c
@@ -177,8 +177,8 @@ static int snd_ivtv_init(struct v4l2_device *v4l2_dev)
177#if 0 177#if 0
178 ret = snd_ivtv_mixer_create(itvsc); 178 ret = snd_ivtv_mixer_create(itvsc);
179 if (ret) { 179 if (ret) {
180 IVTV_ALSA_WARN("%s: snd_ivtv_mixer_create() failed with err %d:" 180 IVTV_ALSA_WARN("%s: snd_ivtv_mixer_create() failed with err %d: proceeding anyway\n",
181 " proceeding anyway\n", __func__, ret); 181 __func__, ret);
182 } 182 }
183#endif 183#endif
184 184
@@ -235,8 +235,8 @@ static int ivtv_alsa_load(struct ivtv *itv)
235 235
236 s = &itv->streams[IVTV_ENC_STREAM_TYPE_PCM]; 236 s = &itv->streams[IVTV_ENC_STREAM_TYPE_PCM];
237 if (s->vdev.v4l2_dev == NULL) { 237 if (s->vdev.v4l2_dev == NULL) {
238 IVTV_DEBUG_ALSA_INFO("%s: PCM stream for card is disabled - " 238 IVTV_DEBUG_ALSA_INFO("%s: PCM stream for card is disabled - skipping\n",
239 "skipping\n", __func__); 239 __func__);
240 return 0; 240 return 0;
241 } 241 }
242 242
@@ -250,8 +250,8 @@ static int ivtv_alsa_load(struct ivtv *itv)
250 IVTV_ALSA_ERR("%s: failed to create struct snd_ivtv_card\n", 250 IVTV_ALSA_ERR("%s: failed to create struct snd_ivtv_card\n",
251 __func__); 251 __func__);
252 } else { 252 } else {
253 IVTV_DEBUG_ALSA_INFO("%s: created ivtv ALSA interface instance " 253 IVTV_DEBUG_ALSA_INFO("%s: created ivtv ALSA interface instance \n",
254 "\n", __func__); 254 __func__);
255 } 255 }
256 return 0; 256 return 0;
257} 257}
diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
index ee48c3e09de4..0a3b80a4bd69 100644
--- a/drivers/media/pci/ivtv/ivtv-driver.c
+++ b/drivers/media/pci/ivtv/ivtv-driver.c
@@ -885,8 +885,8 @@ static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *pdev,
885 pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &pci_latency); 885 pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &pci_latency);
886 886
887 if (pci_latency < 64 && ivtv_pci_latency) { 887 if (pci_latency < 64 && ivtv_pci_latency) {
888 IVTV_INFO("Unreasonably low latency timer, " 888 IVTV_INFO("Unreasonably low latency timer, setting to 64 (was %d)\n",
889 "setting to 64 (was %d)\n", pci_latency); 889 pci_latency);
890 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64); 890 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64);
891 pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &pci_latency); 891 pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &pci_latency);
892 } 892 }
@@ -896,8 +896,7 @@ static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *pdev,
896 these problems. */ 896 these problems. */
897 pci_write_config_dword(pdev, 0x40, 0xffff); 897 pci_write_config_dword(pdev, 0x40, 0xffff);
898 898
899 IVTV_DEBUG_INFO("%d (rev %d) at %02x:%02x.%x, " 899 IVTV_DEBUG_INFO("%d (rev %d) at %02x:%02x.%x, irq: %d, latency: %d, memory: 0x%llx\n",
900 "irq: %d, latency: %d, memory: 0x%llx\n",
901 pdev->device, pdev->revision, pdev->bus->number, 900 pdev->device, pdev->revision, pdev->bus->number,
902 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), 901 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn),
903 pdev->irq, pci_latency, (u64)itv->base_addr); 902 pdev->irq, pci_latency, (u64)itv->base_addr);
@@ -1047,13 +1046,10 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
1047 itv->enc_mem = ioremap_nocache(itv->base_addr + IVTV_ENCODER_OFFSET, 1046 itv->enc_mem = ioremap_nocache(itv->base_addr + IVTV_ENCODER_OFFSET,
1048 IVTV_ENCODER_SIZE); 1047 IVTV_ENCODER_SIZE);
1049 if (!itv->enc_mem) { 1048 if (!itv->enc_mem) {
1050 IVTV_ERR("ioremap failed. Can't get a window into CX23415/6 " 1049 IVTV_ERR("ioremap failed. Can't get a window into CX23415/6 encoder memory\n");
1051 "encoder memory\n"); 1050 IVTV_ERR("Each capture card with a CX23415/6 needs 8 MB of vmalloc address space for this window\n");
1052 IVTV_ERR("Each capture card with a CX23415/6 needs 8 MB of "
1053 "vmalloc address space for this window\n");
1054 IVTV_ERR("Check the output of 'grep Vmalloc /proc/meminfo'\n"); 1051 IVTV_ERR("Check the output of 'grep Vmalloc /proc/meminfo'\n");
1055 IVTV_ERR("Use the vmalloc= kernel command line option to set " 1052 IVTV_ERR("Use the vmalloc= kernel command line option to set VmallocTotal to a larger value\n");
1056 "VmallocTotal to a larger value\n");
1057 retval = -ENOMEM; 1053 retval = -ENOMEM;
1058 goto free_mem; 1054 goto free_mem;
1059 } 1055 }
@@ -1064,14 +1060,10 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
1064 itv->dec_mem = ioremap_nocache(itv->base_addr + IVTV_DECODER_OFFSET, 1060 itv->dec_mem = ioremap_nocache(itv->base_addr + IVTV_DECODER_OFFSET,
1065 IVTV_DECODER_SIZE); 1061 IVTV_DECODER_SIZE);
1066 if (!itv->dec_mem) { 1062 if (!itv->dec_mem) {
1067 IVTV_ERR("ioremap failed. Can't get a window into " 1063 IVTV_ERR("ioremap failed. Can't get a window into CX23415 decoder memory\n");
1068 "CX23415 decoder memory\n"); 1064 IVTV_ERR("Each capture card with a CX23415 needs 8 MB of vmalloc address space for this window\n");
1069 IVTV_ERR("Each capture card with a CX23415 needs 8 MB " 1065 IVTV_ERR("Check the output of 'grep Vmalloc /proc/meminfo'\n");
1070 "of vmalloc address space for this window\n"); 1066 IVTV_ERR("Use the vmalloc= kernel command line option to set VmallocTotal to a larger value\n");
1071 IVTV_ERR("Check the output of 'grep Vmalloc "
1072 "/proc/meminfo'\n");
1073 IVTV_ERR("Use the vmalloc= kernel command line option "
1074 "to set VmallocTotal to a larger value\n");
1075 retval = -ENOMEM; 1067 retval = -ENOMEM;
1076 goto free_mem; 1068 goto free_mem;
1077 } 1069 }
@@ -1086,13 +1078,10 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
1086 itv->reg_mem = 1078 itv->reg_mem =
1087 ioremap_nocache(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); 1079 ioremap_nocache(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE);
1088 if (!itv->reg_mem) { 1080 if (!itv->reg_mem) {
1089 IVTV_ERR("ioremap failed. Can't get a window into CX23415/6 " 1081 IVTV_ERR("ioremap failed. Can't get a window into CX23415/6 register space\n");
1090 "register space\n"); 1082 IVTV_ERR("Each capture card with a CX23415/6 needs 64 kB of vmalloc address space for this window\n");
1091 IVTV_ERR("Each capture card with a CX23415/6 needs 64 kB of "
1092 "vmalloc address space for this window\n");
1093 IVTV_ERR("Check the output of 'grep Vmalloc /proc/meminfo'\n"); 1083 IVTV_ERR("Check the output of 'grep Vmalloc /proc/meminfo'\n");
1094 IVTV_ERR("Use the vmalloc= kernel command line option to set " 1084 IVTV_ERR("Use the vmalloc= kernel command line option to set VmallocTotal to a larger value\n");
1095 "VmallocTotal to a larger value\n");
1096 retval = -ENOMEM; 1085 retval = -ENOMEM;
1097 goto free_io; 1086 goto free_io;
1098 } 1087 }
diff --git a/drivers/media/pci/ivtv/ivtv-firmware.c b/drivers/media/pci/ivtv/ivtv-firmware.c
index 5b3095f65dce..ba279fdb3df8 100644
--- a/drivers/media/pci/ivtv/ivtv-firmware.c
+++ b/drivers/media/pci/ivtv/ivtv-firmware.c
@@ -376,8 +376,8 @@ int ivtv_firmware_check(struct ivtv *itv, char *where)
376 /* If something failed & currently idle, try to reload */ 376 /* If something failed & currently idle, try to reload */
377 if (res && !atomic_read(&itv->capturing) && 377 if (res && !atomic_read(&itv->capturing) &&
378 !atomic_read(&itv->decoding)) { 378 !atomic_read(&itv->decoding)) {
379 IVTV_INFO("Detected in %s that firmware had failed - " 379 IVTV_INFO("Detected in %s that firmware had failed - Reloading\n",
380 "Reloading\n", where); 380 where);
381 res = ivtv_firmware_restart(itv); 381 res = ivtv_firmware_restart(itv);
382 /* 382 /*
383 * Even if restarted ok, still signal a problem had occurred. 383 * Even if restarted ok, still signal a problem had occurred.
diff --git a/drivers/media/pci/ivtv/ivtv-yuv.c b/drivers/media/pci/ivtv/ivtv-yuv.c
index f7299d3d8244..44936d6d7c39 100644
--- a/drivers/media/pci/ivtv/ivtv-yuv.c
+++ b/drivers/media/pci/ivtv/ivtv-yuv.c
@@ -89,8 +89,8 @@ static int ivtv_yuv_prep_user_dma(struct ivtv *itv, struct ivtv_user_dma *dma,
89 89
90 if (y_pages == y_dma.page_count) { 90 if (y_pages == y_dma.page_count) {
91 IVTV_DEBUG_WARN 91 IVTV_DEBUG_WARN
92 ("failed to map uv user pages, returned %d " 92 ("failed to map uv user pages, returned %d expecting %d\n",
93 "expecting %d\n", uv_pages, uv_dma.page_count); 93 uv_pages, uv_dma.page_count);
94 94
95 if (uv_pages >= 0) { 95 if (uv_pages >= 0) {
96 for (i = 0; i < uv_pages; i++) 96 for (i = 0; i < uv_pages; i++)
@@ -101,8 +101,8 @@ static int ivtv_yuv_prep_user_dma(struct ivtv *itv, struct ivtv_user_dma *dma,
101 } 101 }
102 } else { 102 } else {
103 IVTV_DEBUG_WARN 103 IVTV_DEBUG_WARN
104 ("failed to map y user pages, returned %d " 104 ("failed to map y user pages, returned %d expecting %d\n",
105 "expecting %d\n", y_pages, y_dma.page_count); 105 y_pages, y_dma.page_count);
106 } 106 }
107 if (y_pages >= 0) { 107 if (y_pages >= 0) {
108 for (i = 0; i < y_pages; i++) 108 for (i = 0; i < y_pages; i++)
diff --git a/drivers/media/pci/ivtv/ivtvfb.c b/drivers/media/pci/ivtv/ivtvfb.c
index 8b95eefb610b..612a8402cf4d 100644
--- a/drivers/media/pci/ivtv/ivtvfb.c
+++ b/drivers/media/pci/ivtv/ivtvfb.c
@@ -293,8 +293,7 @@ static int ivtvfb_prep_dec_dma_to_device(struct ivtv *itv,
293 /* Map User DMA */ 293 /* Map User DMA */
294 if (ivtv_udma_setup(itv, ivtv_dest_addr, userbuf, size_in_bytes) <= 0) { 294 if (ivtv_udma_setup(itv, ivtv_dest_addr, userbuf, size_in_bytes) <= 0) {
295 mutex_unlock(&itv->udma.lock); 295 mutex_unlock(&itv->udma.lock);
296 IVTVFB_WARN("ivtvfb_prep_dec_dma_to_device, " 296 IVTVFB_WARN("ivtvfb_prep_dec_dma_to_device, Error with get_user_pages: %d bytes, %d pages returned\n",
297 "Error with get_user_pages: %d bytes, %d pages returned\n",
298 size_in_bytes, itv->udma.page_count); 297 size_in_bytes, itv->udma.page_count);
299 298
300 /* get_user_pages must have failed completely */ 299 /* get_user_pages must have failed completely */
diff --git a/drivers/media/pci/meye/meye.c b/drivers/media/pci/meye/meye.c
index ba887e8e1b17..e825bc93ea7a 100644
--- a/drivers/media/pci/meye/meye.c
+++ b/drivers/media/pci/meye/meye.c
@@ -60,8 +60,7 @@ MODULE_PARM_DESC(gbuffers, "number of capture buffers, default is 2 (32 max)");
60/* size of a grab buffer */ 60/* size of a grab buffer */
61static unsigned int gbufsize = MEYE_MAX_BUFSIZE; 61static unsigned int gbufsize = MEYE_MAX_BUFSIZE;
62module_param(gbufsize, int, 0444); 62module_param(gbufsize, int, 0444);
63MODULE_PARM_DESC(gbufsize, "size of the capture buffers, default is 614400" 63MODULE_PARM_DESC(gbufsize, "size of the capture buffers, default is 614400 (will be rounded up to a page multiple)");
64 " (will be rounded up to a page multiple)");
65 64
66/* /dev/videoX registration number */ 65/* /dev/videoX registration number */
67static int video_nr = -1; 66static int video_nr = -1;
@@ -587,10 +586,7 @@ static void mchip_hic_stop(void)
587/* get the next ready frame from the dma engine */ 586/* get the next ready frame from the dma engine */
588static u32 mchip_get_frame(void) 587static u32 mchip_get_frame(void)
589{ 588{
590 u32 v; 589 return mchip_read(MCHIP_MM_FIR(meye.mchip_fnum));
591
592 v = mchip_read(MCHIP_MM_FIR(meye.mchip_fnum));
593 return v;
594} 590}
595 591
596/* frees the current frame from the dma engine */ 592/* frees the current frame from the dma engine */
@@ -1261,8 +1257,7 @@ static int vidioc_reqbufs(struct file *file, void *fh,
1261 meye.grab_fbuffer = rvmalloc(gbuffers * gbufsize); 1257 meye.grab_fbuffer = rvmalloc(gbuffers * gbufsize);
1262 1258
1263 if (!meye.grab_fbuffer) { 1259 if (!meye.grab_fbuffer) {
1264 printk(KERN_ERR "meye: v4l framebuffer allocation" 1260 printk(KERN_ERR "meye: v4l framebuffer allocation failed\n");
1265 " failed\n");
1266 mutex_unlock(&meye.lock); 1261 mutex_unlock(&meye.lock);
1267 return -ENOMEM; 1262 return -ENOMEM;
1268 } 1263 }
@@ -1659,8 +1654,7 @@ static int meye_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
1659 ret = -EIO; 1654 ret = -EIO;
1660 if ((ret = sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 1))) { 1655 if ((ret = sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 1))) {
1661 v4l2_err(v4l2_dev, "meye: unable to power on the camera\n"); 1656 v4l2_err(v4l2_dev, "meye: unable to power on the camera\n");
1662 v4l2_err(v4l2_dev, "meye: did you enable the camera in " 1657 v4l2_err(v4l2_dev, "meye: did you enable the camera in sonypi using the module options ?\n");
1663 "sonypi using the module options ?\n");
1664 goto outsonypienable; 1658 goto outsonypienable;
1665 } 1659 }
1666 1660
@@ -1834,8 +1828,7 @@ static int __init meye_init(void)
1834 if (gbufsize > MEYE_MAX_BUFSIZE) 1828 if (gbufsize > MEYE_MAX_BUFSIZE)
1835 gbufsize = MEYE_MAX_BUFSIZE; 1829 gbufsize = MEYE_MAX_BUFSIZE;
1836 gbufsize = PAGE_ALIGN(gbufsize); 1830 gbufsize = PAGE_ALIGN(gbufsize);
1837 printk(KERN_INFO "meye: using %d buffers with %dk (%dk total) " 1831 printk(KERN_INFO "meye: using %d buffers with %dk (%dk total) for capture\n",
1838 "for capture\n",
1839 gbuffers, 1832 gbuffers,
1840 gbufsize / 1024, gbuffers * gbufsize / 1024); 1833 gbufsize / 1024, gbuffers * gbufsize / 1024);
1841 return pci_register_driver(&meye_driver); 1834 return pci_register_driver(&meye_driver);
diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
index b078ac2a682c..191bd8299dc3 100644
--- a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
+++ b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
@@ -1030,15 +1030,4 @@ static struct pci_driver netup_unidvb_pci_driver = {
1030 .resume = NULL, 1030 .resume = NULL,
1031}; 1031};
1032 1032
1033static int __init netup_unidvb_init(void) 1033module_pci_driver(netup_unidvb_pci_driver);
1034{
1035 return pci_register_driver(&netup_unidvb_pci_driver);
1036}
1037
1038static void __exit netup_unidvb_fini(void)
1039{
1040 pci_unregister_driver(&netup_unidvb_pci_driver);
1041}
1042
1043module_init(netup_unidvb_init);
1044module_exit(netup_unidvb_fini);
diff --git a/drivers/media/pci/pluto2/pluto2.c b/drivers/media/pci/pluto2/pluto2.c
index 655d6854a8d7..65afb71ff79f 100644
--- a/drivers/media/pci/pluto2/pluto2.c
+++ b/drivers/media/pci/pluto2/pluto2.c
@@ -577,12 +577,12 @@ static int pluto_read_serial(struct pluto *pluto)
577 for (j = 0; j < 32; j += 8) { 577 for (j = 0; j < 32; j += 8) {
578 if ((val & 0xff) == 0xff) 578 if ((val & 0xff) == 0xff)
579 goto out; 579 goto out;
580 printk("%c", val & 0xff); 580 printk(KERN_CONT "%c", val & 0xff);
581 val >>= 8; 581 val >>= 8;
582 } 582 }
583 } 583 }
584out: 584out:
585 printk("\n"); 585 printk(KERN_CONT "\n");
586 pci_iounmap(pdev, cis); 586 pci_iounmap(pdev, cis);
587 587
588 return 0; 588 return 0;
diff --git a/drivers/media/pci/pt1/pt1.c b/drivers/media/pci/pt1/pt1.c
index e7e4428109c3..d5ee82aee9e8 100644
--- a/drivers/media/pci/pt1/pt1.c
+++ b/drivers/media/pci/pt1/pt1.c
@@ -282,13 +282,12 @@ static int pt1_filter(struct pt1 *pt1, struct pt1_buffer_page *page)
282 continue; 282 continue;
283 283
284 if (upacket >> 24 & 1) 284 if (upacket >> 24 & 1)
285 printk_ratelimited(KERN_INFO "earth-pt1: device " 285 printk_ratelimited(KERN_INFO "earth-pt1: device buffer overflowing. table[%d] buf[%d]\n",
286 "buffer overflowing. table[%d] buf[%d]\n",
287 pt1->table_index, pt1->buf_index); 286 pt1->table_index, pt1->buf_index);
288 sc = upacket >> 26 & 0x7; 287 sc = upacket >> 26 & 0x7;
289 if (adap->st_count != -1 && sc != ((adap->st_count + 1) & 0x7)) 288 if (adap->st_count != -1 && sc != ((adap->st_count + 1) & 0x7))
290 printk_ratelimited(KERN_INFO "earth-pt1: data loss" 289 printk_ratelimited(KERN_INFO "earth-pt1: data loss in streamID(adapter)[%d]\n",
291 " in streamID(adapter)[%d]\n", index); 290 index);
292 adap->st_count = sc; 291 adap->st_count = sc;
293 292
294 buf = adap->buf; 293 buf = adap->buf;
diff --git a/drivers/media/pci/pt1/va1j5jf8007s.c b/drivers/media/pci/pt1/va1j5jf8007s.c
index d0e70dc0e16f..249273b2e0f2 100644
--- a/drivers/media/pci/pt1/va1j5jf8007s.c
+++ b/drivers/media/pci/pt1/va1j5jf8007s.c
@@ -578,7 +578,7 @@ static void va1j5jf8007s_release(struct dvb_frontend *fe)
578 kfree(state); 578 kfree(state);
579} 579}
580 580
581static struct dvb_frontend_ops va1j5jf8007s_ops = { 581static const struct dvb_frontend_ops va1j5jf8007s_ops = {
582 .delsys = { SYS_ISDBS }, 582 .delsys = { SYS_ISDBS },
583 .info = { 583 .info = {
584 .name = "VA1J5JF8007/VA1J5JF8011 ISDB-S", 584 .name = "VA1J5JF8007/VA1J5JF8011 ISDB-S",
diff --git a/drivers/media/pci/pt1/va1j5jf8007t.c b/drivers/media/pci/pt1/va1j5jf8007t.c
index 0268f20b8097..e0766e69a370 100644
--- a/drivers/media/pci/pt1/va1j5jf8007t.c
+++ b/drivers/media/pci/pt1/va1j5jf8007t.c
@@ -427,7 +427,7 @@ static void va1j5jf8007t_release(struct dvb_frontend *fe)
427 kfree(state); 427 kfree(state);
428} 428}
429 429
430static struct dvb_frontend_ops va1j5jf8007t_ops = { 430static const struct dvb_frontend_ops va1j5jf8007t_ops = {
431 .delsys = { SYS_ISDBT }, 431 .delsys = { SYS_ISDBT },
432 .info = { 432 .info = {
433 .name = "VA1J5JF8007/VA1J5JF8011 ISDB-T", 433 .name = "VA1J5JF8007/VA1J5JF8011 ISDB-T",
diff --git a/drivers/media/pci/saa7134/saa7134-alsa.c b/drivers/media/pci/saa7134/saa7134-alsa.c
index dc0e2fc5f68b..8a35ecfb75e3 100644
--- a/drivers/media/pci/saa7134/saa7134-alsa.c
+++ b/drivers/media/pci/saa7134/saa7134-alsa.c
@@ -813,8 +813,7 @@ static int snd_card_saa7134_capture_open(struct snd_pcm_substream * substream)
813 int amux, err; 813 int amux, err;
814 814
815 if (!saa7134) { 815 if (!saa7134) {
816 pr_err("BUG: saa7134 can't find device struct." 816 pr_err("BUG: saa7134 can't find device struct. Can't proceed with open\n");
817 " Can't proceed with open\n");
818 return -ENODEV; 817 return -ENODEV;
819 } 818 }
820 dev = saa7134->dev; 819 dev = saa7134->dev;
diff --git a/drivers/media/pci/saa7134/saa7134-cards.c b/drivers/media/pci/saa7134/saa7134-cards.c
index c480a7e87593..2b60af493de4 100644
--- a/drivers/media/pci/saa7134/saa7134-cards.c
+++ b/drivers/media/pci/saa7134/saa7134-cards.c
@@ -7341,8 +7341,8 @@ static void hauppauge_eeprom(struct saa7134_dev *dev, u8 *eeprom_data)
7341 case 67659: /* WinTV-HVR1110 (OEM, no IR, hybrid, FM, SVid/Comp, RCA aud) */ 7341 case 67659: /* WinTV-HVR1110 (OEM, no IR, hybrid, FM, SVid/Comp, RCA aud) */
7342 break; 7342 break;
7343 default: 7343 default:
7344 pr_warn("%s: warning: " 7344 pr_warn("%s: warning: unknown hauppauge model #%d\n",
7345 "unknown hauppauge model #%d\n", dev->name, tv.model); 7345 dev->name, tv.model);
7346 break; 7346 break;
7347 } 7347 }
7348 7348
@@ -7920,8 +7920,8 @@ int saa7134_board_init2(struct saa7134_dev *dev)
7920 msg.addr = 0x0b; 7920 msg.addr = 0x0b;
7921 msg.len = 1; 7921 msg.len = 1;
7922 if (1 != i2c_transfer(&dev->i2c_adap, &msg, 1)) { 7922 if (1 != i2c_transfer(&dev->i2c_adap, &msg, 1)) {
7923 pr_warn("%s: send wake up byte to pic16C505" 7923 pr_warn("%s: send wake up byte to pic16C505(IR chip) failed\n",
7924 "(IR chip) failed\n", dev->name); 7924 dev->name);
7925 } else { 7925 } else {
7926 msg.flags = I2C_M_RD; 7926 msg.flags = I2C_M_RD;
7927 rc = i2c_transfer(&dev->i2c_adap, &msg, 1); 7927 rc = i2c_transfer(&dev->i2c_adap, &msg, 1);
diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c
index ffb66a9ae23e..7d6bb5c9343f 100644
--- a/drivers/media/pci/saa7134/saa7134-core.c
+++ b/drivers/media/pci/saa7134/saa7134-core.c
@@ -66,8 +66,7 @@ MODULE_PARM_DESC(latency,"pci latency timer");
66 66
67int saa7134_no_overlay=-1; 67int saa7134_no_overlay=-1;
68module_param_named(no_overlay, saa7134_no_overlay, int, 0444); 68module_param_named(no_overlay, saa7134_no_overlay, int, 0444);
69MODULE_PARM_DESC(no_overlay,"allow override overlay default (0 disables, 1 enables)" 69MODULE_PARM_DESC(no_overlay, "allow override overlay default (0 disables, 1 enables) [some VIA/SIS chipsets are known to have problem with overlay]");
70 " [some VIA/SIS chipsets are known to have problem with overlay]");
71 70
72bool saa7134_userptr; 71bool saa7134_userptr;
73module_param(saa7134_userptr, bool, 0644); 72module_param(saa7134_userptr, bool, 0644);
@@ -619,25 +618,25 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id)
619 print_irqstatus(dev,loop,report,status); 618 print_irqstatus(dev,loop,report,status);
620 if (report & SAA7134_IRQ_REPORT_PE) { 619 if (report & SAA7134_IRQ_REPORT_PE) {
621 /* disable all parity error */ 620 /* disable all parity error */
622 pr_warn("%s/irq: looping -- " 621 pr_warn("%s/irq: looping -- clearing PE (parity error!) enable bit\n",
623 "clearing PE (parity error!) enable bit\n",dev->name); 622 dev->name);
624 saa_clearl(SAA7134_IRQ2,SAA7134_IRQ2_INTE_PE); 623 saa_clearl(SAA7134_IRQ2,SAA7134_IRQ2_INTE_PE);
625 } else if (report & SAA7134_IRQ_REPORT_GPIO16) { 624 } else if (report & SAA7134_IRQ_REPORT_GPIO16) {
626 /* disable gpio16 IRQ */ 625 /* disable gpio16 IRQ */
627 pr_warn("%s/irq: looping -- " 626 pr_warn("%s/irq: looping -- clearing GPIO16 enable bit\n",
628 "clearing GPIO16 enable bit\n",dev->name); 627 dev->name);
629 saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO16_P); 628 saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO16_P);
630 saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO16_N); 629 saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO16_N);
631 } else if (report & SAA7134_IRQ_REPORT_GPIO18) { 630 } else if (report & SAA7134_IRQ_REPORT_GPIO18) {
632 /* disable gpio18 IRQs */ 631 /* disable gpio18 IRQs */
633 pr_warn("%s/irq: looping -- " 632 pr_warn("%s/irq: looping -- clearing GPIO18 enable bit\n",
634 "clearing GPIO18 enable bit\n",dev->name); 633 dev->name);
635 saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18_P); 634 saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18_P);
636 saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18_N); 635 saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18_N);
637 } else { 636 } else {
638 /* disable all irqs */ 637 /* disable all irqs */
639 pr_warn("%s/irq: looping -- " 638 pr_warn("%s/irq: looping -- clearing all enable bits\n",
640 "clearing all enable bits\n",dev->name); 639 dev->name);
641 saa_writel(SAA7134_IRQ1,0); 640 saa_writel(SAA7134_IRQ1,0);
642 saa_writel(SAA7134_IRQ2,0); 641 saa_writel(SAA7134_IRQ2,0);
643 } 642 }
@@ -1081,18 +1080,14 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
1081 } 1080 }
1082#endif 1081#endif
1083 if (pci_pci_problems & (PCIPCI_FAIL|PCIAGP_FAIL)) { 1082 if (pci_pci_problems & (PCIPCI_FAIL|PCIAGP_FAIL)) {
1084 pr_info("%s: quirk: this driver and your " 1083 pr_info("%s: quirk: this driver and your chipset may not work together in overlay mode.\n",
1085 "chipset may not work together" 1084 dev->name);
1086 " in overlay mode.\n",dev->name);
1087 if (!saa7134_no_overlay) { 1085 if (!saa7134_no_overlay) {
1088 pr_info("%s: quirk: overlay " 1086 pr_info("%s: quirk: overlay mode will be disabled.\n",
1089 "mode will be disabled.\n",
1090 dev->name); 1087 dev->name);
1091 saa7134_no_overlay = 1; 1088 saa7134_no_overlay = 1;
1092 } else { 1089 } else {
1093 pr_info("%s: quirk: overlay " 1090 pr_info("%s: quirk: overlay mode will be forced. Use this option at your own risk.\n",
1094 "mode will be forced. Use this"
1095 " option at your own risk.\n",
1096 dev->name); 1091 dev->name);
1097 } 1092 }
1098 } 1093 }
@@ -1106,10 +1101,10 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
1106 /* print pci info */ 1101 /* print pci info */
1107 dev->pci_rev = pci_dev->revision; 1102 dev->pci_rev = pci_dev->revision;
1108 pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat); 1103 pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat);
1109 pr_info("%s: found at %s, rev: %d, irq: %d, " 1104 pr_info("%s: found at %s, rev: %d, irq: %d, latency: %d, mmio: 0x%llx\n",
1110 "latency: %d, mmio: 0x%llx\n", dev->name, 1105 dev->name, pci_name(pci_dev), dev->pci_rev, pci_dev->irq,
1111 pci_name(pci_dev), dev->pci_rev, pci_dev->irq, 1106 dev->pci_lat,
1112 dev->pci_lat,(unsigned long long)pci_resource_start(pci_dev,0)); 1107 (unsigned long long)pci_resource_start(pci_dev, 0));
1113 pci_set_master(pci_dev); 1108 pci_set_master(pci_dev);
1114 err = pci_set_dma_mask(pci_dev, DMA_BIT_MASK(32)); 1109 err = pci_set_dma_mask(pci_dev, DMA_BIT_MASK(32));
1115 if (err) { 1110 if (err) {
diff --git a/drivers/media/pci/saa7134/saa7134-dvb.c b/drivers/media/pci/saa7134/saa7134-dvb.c
index 59a4b5f7724e..598b8bbfe726 100644
--- a/drivers/media/pci/saa7134/saa7134-dvb.c
+++ b/drivers/media/pci/saa7134/saa7134-dvb.c
@@ -1449,8 +1449,8 @@ static int dvb_init(struct saa7134_dev *dev)
1449 1449
1450 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 1450 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
1451 0x60, &dev->i2c_adap, 0) == NULL) { 1451 0x60, &dev->i2c_adap, 0) == NULL) {
1452 pr_warn("%s: Medion Quadro, no tda826x " 1452 pr_warn("%s: Medion Quadro, no tda826x found !\n",
1453 "found !\n", __func__); 1453 __func__);
1454 goto detach_frontend; 1454 goto detach_frontend;
1455 } 1455 }
1456 if (dev_id != 0x08) { 1456 if (dev_id != 0x08) {
@@ -1458,8 +1458,8 @@ static int dvb_init(struct saa7134_dev *dev)
1458 fe->ops.i2c_gate_ctrl(fe, 1); 1458 fe->ops.i2c_gate_ctrl(fe, 1);
1459 if (dvb_attach(isl6405_attach, fe, 1459 if (dvb_attach(isl6405_attach, fe,
1460 &dev->i2c_adap, 0x08, 0, 0) == NULL) { 1460 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1461 pr_warn("%s: Medion Quadro, no ISL6405 " 1461 pr_warn("%s: Medion Quadro, no ISL6405 found !\n",
1462 "found !\n", __func__); 1462 __func__);
1463 goto detach_frontend; 1463 goto detach_frontend;
1464 } 1464 }
1465 if (dev_id == 0x07) { 1465 if (dev_id == 0x07) {
@@ -1629,8 +1629,8 @@ static int dvb_init(struct saa7134_dev *dev)
1629 struct dvb_frontend *fe; 1629 struct dvb_frontend *fe;
1630 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60, 1630 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
1631 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) { 1631 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
1632 pr_warn("%s: MD7134 DVB-S, no SD1878 " 1632 pr_warn("%s: MD7134 DVB-S, no SD1878 found !\n",
1633 "found !\n", __func__); 1633 __func__);
1634 goto detach_frontend; 1634 goto detach_frontend;
1635 } 1635 }
1636 /* we need to open the i2c gate (we know it exists) */ 1636 /* we need to open the i2c gate (we know it exists) */
@@ -1638,8 +1638,8 @@ static int dvb_init(struct saa7134_dev *dev)
1638 fe->ops.i2c_gate_ctrl(fe, 1); 1638 fe->ops.i2c_gate_ctrl(fe, 1);
1639 if (dvb_attach(isl6405_attach, fe, 1639 if (dvb_attach(isl6405_attach, fe,
1640 &dev->i2c_adap, 0x08, 0, 0) == NULL) { 1640 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1641 pr_warn("%s: MD7134 DVB-S, no ISL6405 " 1641 pr_warn("%s: MD7134 DVB-S, no ISL6405 found !\n",
1642 "found !\n", __func__); 1642 __func__);
1643 goto detach_frontend; 1643 goto detach_frontend;
1644 } 1644 }
1645 fe->ops.i2c_gate_ctrl(fe, 0); 1645 fe->ops.i2c_gate_ctrl(fe, 0);
@@ -1670,14 +1670,14 @@ static int dvb_init(struct saa7134_dev *dev)
1670 if (dvb_attach(tda826x_attach, 1670 if (dvb_attach(tda826x_attach,
1671 fe0->dvb.frontend, 0x60, 1671 fe0->dvb.frontend, 0x60,
1672 &dev->i2c_adap, 0) == NULL) { 1672 &dev->i2c_adap, 0) == NULL) {
1673 pr_warn("%s: Asus Tiger 3in1, no " 1673 pr_warn("%s: Asus Tiger 3in1, no tda826x found!\n",
1674 "tda826x found!\n", __func__); 1674 __func__);
1675 goto detach_frontend; 1675 goto detach_frontend;
1676 } 1676 }
1677 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend, 1677 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1678 &dev->i2c_adap, 0, 0) == NULL) { 1678 &dev->i2c_adap, 0, 0) == NULL) {
1679 pr_warn("%s: Asus Tiger 3in1, no lnbp21" 1679 pr_warn("%s: Asus Tiger 3in1, no lnbp21 found!\n",
1680 " found!\n", __func__); 1680 __func__);
1681 goto detach_frontend; 1681 goto detach_frontend;
1682 } 1682 }
1683 } 1683 }
@@ -1695,14 +1695,14 @@ static int dvb_init(struct saa7134_dev *dev)
1695 if (dvb_attach(tda826x_attach, 1695 if (dvb_attach(tda826x_attach,
1696 fe0->dvb.frontend, 0x60, 1696 fe0->dvb.frontend, 0x60,
1697 &dev->i2c_adap, 0) == NULL) { 1697 &dev->i2c_adap, 0) == NULL) {
1698 pr_warn("%s: Asus My Cinema PS3-100, no " 1698 pr_warn("%s: Asus My Cinema PS3-100, no tda826x found!\n",
1699 "tda826x found!\n", __func__); 1699 __func__);
1700 goto detach_frontend; 1700 goto detach_frontend;
1701 } 1701 }
1702 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend, 1702 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1703 &dev->i2c_adap, 0, 0) == NULL) { 1703 &dev->i2c_adap, 0, 0) == NULL) {
1704 pr_warn("%s: Asus My Cinema PS3-100, no lnbp21" 1704 pr_warn("%s: Asus My Cinema PS3-100, no lnbp21 found!\n",
1705 " found!\n", __func__); 1705 __func__);
1706 goto detach_frontend; 1706 goto detach_frontend;
1707 } 1707 }
1708 } 1708 }
diff --git a/drivers/media/pci/saa7134/saa7134-i2c.c b/drivers/media/pci/saa7134/saa7134-i2c.c
index 2dac48fa1386..dca0592c5f47 100644
--- a/drivers/media/pci/saa7134/saa7134-i2c.c
+++ b/drivers/media/pci/saa7134/saa7134-i2c.c
@@ -355,12 +355,43 @@ static struct i2c_client saa7134_client_template = {
355 355
356/* ----------------------------------------------------------- */ 356/* ----------------------------------------------------------- */
357 357
358/* On Medion 7134 reading EEPROM needs DVB-T demod i2c gate open */
359static void saa7134_i2c_eeprom_md7134_gate(struct saa7134_dev *dev)
360{
361 u8 subaddr = 0x7, dmdregval;
362 u8 data[2];
363 int ret;
364 struct i2c_msg i2cgatemsg_r[] = { {.addr = 0x08, .flags = 0,
365 .buf = &subaddr, .len = 1},
366 {.addr = 0x08,
367 .flags = I2C_M_RD,
368 .buf = &dmdregval, .len = 1}
369 };
370 struct i2c_msg i2cgatemsg_w[] = { {.addr = 0x08, .flags = 0,
371 .buf = data, .len = 2} };
372
373 ret = i2c_transfer(&dev->i2c_adap, i2cgatemsg_r, 2);
374 if ((ret == 2) && (dmdregval & 0x2)) {
375 pr_debug("%s: DVB-T demod i2c gate was left closed\n",
376 dev->name);
377
378 data[0] = subaddr;
379 data[1] = (dmdregval & ~0x2);
380 if (i2c_transfer(&dev->i2c_adap, i2cgatemsg_w, 1) != 1)
381 pr_err("%s: EEPROM i2c gate open failure\n",
382 dev->name);
383 }
384}
385
358static int 386static int
359saa7134_i2c_eeprom(struct saa7134_dev *dev, unsigned char *eedata, int len) 387saa7134_i2c_eeprom(struct saa7134_dev *dev, unsigned char *eedata, int len)
360{ 388{
361 unsigned char buf; 389 unsigned char buf;
362 int i,err; 390 int i,err;
363 391
392 if (dev->board == SAA7134_BOARD_MD7134)
393 saa7134_i2c_eeprom_md7134_gate(dev);
394
364 dev->i2c_client.addr = 0xa0 >> 1; 395 dev->i2c_client.addr = 0xa0 >> 1;
365 buf = 0; 396 buf = 0;
366 if (1 != (err = i2c_master_send(&dev->i2c_client,&buf,1))) { 397 if (1 != (err = i2c_master_send(&dev->i2c_client,&buf,1))) {
diff --git a/drivers/media/pci/saa7134/saa7134-input.c b/drivers/media/pci/saa7134/saa7134-input.c
index eff52bbbfd66..823b75ed47e1 100644
--- a/drivers/media/pci/saa7134/saa7134-input.c
+++ b/drivers/media/pci/saa7134/saa7134-input.c
@@ -123,8 +123,7 @@ static int get_key_flydvb_trio(struct IR_i2c *ir, enum rc_type *protocol,
123 struct saa7134_dev *dev = ir->c->adapter->algo_data; 123 struct saa7134_dev *dev = ir->c->adapter->algo_data;
124 124
125 if (dev == NULL) { 125 if (dev == NULL) {
126 ir_dbg(ir, "get_key_flydvb_trio: " 126 ir_dbg(ir, "get_key_flydvb_trio: ir->c->adapter->algo_data is NULL!\n");
127 "ir->c->adapter->algo_data is NULL!\n");
128 return -EIO; 127 return -EIO;
129 } 128 }
130 129
@@ -150,8 +149,8 @@ static int get_key_flydvb_trio(struct IR_i2c *ir, enum rc_type *protocol,
150 msleep(10); 149 msleep(10);
151 continue; 150 continue;
152 } 151 }
153 ir_dbg(ir, "send wake up byte to pic16C505 (IR chip)" 152 ir_dbg(ir, "send wake up byte to pic16C505 (IR chip)failed %dx\n",
154 "failed %dx\n", attempt); 153 attempt);
155 return -EIO; 154 return -EIO;
156 } 155 }
157 if (1 != i2c_master_recv(ir->c, &b, 1)) { 156 if (1 != i2c_master_recv(ir->c, &b, 1)) {
@@ -174,8 +173,7 @@ static int get_key_msi_tvanywhere_plus(struct IR_i2c *ir, enum rc_type *protocol
174 /* <dev> is needed to access GPIO. Used by the saa_readl macro. */ 173 /* <dev> is needed to access GPIO. Used by the saa_readl macro. */
175 struct saa7134_dev *dev = ir->c->adapter->algo_data; 174 struct saa7134_dev *dev = ir->c->adapter->algo_data;
176 if (dev == NULL) { 175 if (dev == NULL) {
177 ir_dbg(ir, "get_key_msi_tvanywhere_plus: " 176 ir_dbg(ir, "get_key_msi_tvanywhere_plus: ir->c->adapter->algo_data is NULL!\n");
178 "ir->c->adapter->algo_data is NULL!\n");
179 return -EIO; 177 return -EIO;
180 } 178 }
181 179
@@ -223,8 +221,7 @@ static int get_key_kworld_pc150u(struct IR_i2c *ir, enum rc_type *protocol,
223 /* <dev> is needed to access GPIO. Used by the saa_readl macro. */ 221 /* <dev> is needed to access GPIO. Used by the saa_readl macro. */
224 struct saa7134_dev *dev = ir->c->adapter->algo_data; 222 struct saa7134_dev *dev = ir->c->adapter->algo_data;
225 if (dev == NULL) { 223 if (dev == NULL) {
226 ir_dbg(ir, "get_key_kworld_pc150u: " 224 ir_dbg(ir, "get_key_kworld_pc150u: ir->c->adapter->algo_data is NULL!\n");
227 "ir->c->adapter->algo_data is NULL!\n");
228 return -EIO; 225 return -EIO;
229 } 226 }
230 227
diff --git a/drivers/media/pci/saa7164/saa7164-buffer.c b/drivers/media/pci/saa7164/saa7164-buffer.c
index f30758e24f5d..62c34504199d 100644
--- a/drivers/media/pci/saa7164/saa7164-buffer.c
+++ b/drivers/media/pci/saa7164/saa7164-buffer.c
@@ -218,8 +218,7 @@ int saa7164_buffer_activate(struct saa7164_buffer *buf, int i)
218 saa7164_writel(port->bufptr32h + ((sizeof(u32) * 2) * i), buf->pt_dma); 218 saa7164_writel(port->bufptr32h + ((sizeof(u32) * 2) * i), buf->pt_dma);
219 saa7164_writel(port->bufptr32l + ((sizeof(u32) * 2) * i), 0); 219 saa7164_writel(port->bufptr32l + ((sizeof(u32) * 2) * i), 0);
220 220
221 dprintk(DBGLVL_BUF, " buf[%d] offset 0x%llx (0x%x) " 221 dprintk(DBGLVL_BUF, " buf[%d] offset 0x%llx (0x%x) buf 0x%llx/%llx (0x%x/%x) nr=%d\n",
222 "buf 0x%llx/%llx (0x%x/%x) nr=%d\n",
223 buf->idx, 222 buf->idx,
224 (u64)port->bufoffset + (i * sizeof(u32)), 223 (u64)port->bufoffset + (i * sizeof(u32)),
225 saa7164_readl(port->bufoffset + (sizeof(u32) * i)), 224 saa7164_readl(port->bufoffset + (sizeof(u32) * i)),
diff --git a/drivers/media/pci/saa7164/saa7164-bus.c b/drivers/media/pci/saa7164/saa7164-bus.c
index a18fe5d47238..e305c02f9dc9 100644
--- a/drivers/media/pci/saa7164/saa7164-bus.c
+++ b/drivers/media/pci/saa7164/saa7164-bus.c
@@ -427,8 +427,8 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
427 write_distance = curr_gwp + bus->m_dwSizeGetRing - curr_grp; 427 write_distance = curr_gwp + bus->m_dwSizeGetRing - curr_grp;
428 428
429 if (bytes_to_read > write_distance) { 429 if (bytes_to_read > write_distance) {
430 printk(KERN_ERR "%s() Invalid bus state, missing msg " 430 printk(KERN_ERR "%s() Invalid bus state, missing msg or mangled ring, faulty H/W / bad code?\n",
431 "or mangled ring, faulty H/W / bad code?\n", __func__); 431 __func__);
432 ret = SAA_ERR_INVALID_COMMAND; 432 ret = SAA_ERR_INVALID_COMMAND;
433 goto out; 433 goto out;
434 } 434 }
diff --git a/drivers/media/pci/saa7164/saa7164-cards.c b/drivers/media/pci/saa7164/saa7164-cards.c
index c2b738227f58..15a98c638c55 100644
--- a/drivers/media/pci/saa7164/saa7164-cards.c
+++ b/drivers/media/pci/saa7164/saa7164-cards.c
@@ -726,8 +726,8 @@ void saa7164_card_list(struct saa7164_dev *dev)
726 dev->name, dev->name, dev->name, dev->name); 726 dev->name, dev->name, dev->name, dev->name);
727 } 727 }
728 728
729 printk(KERN_ERR "%s: Here are valid choices for the card=<n> insmod " 729 printk(KERN_ERR "%s: Here are valid choices for the card=<n> insmod option:\n",
730 "option:\n", dev->name); 730 dev->name);
731 731
732 for (i = 0; i < saa7164_bcount; i++) 732 for (i = 0; i < saa7164_bcount; i++)
733 printk(KERN_ERR "%s: card=%d -> %s\n", 733 printk(KERN_ERR "%s: card=%d -> %s\n",
diff --git a/drivers/media/pci/saa7164/saa7164-cmd.c b/drivers/media/pci/saa7164/saa7164-cmd.c
index 3285c37b4583..45951b3cc251 100644
--- a/drivers/media/pci/saa7164/saa7164-cmd.c
+++ b/drivers/media/pci/saa7164/saa7164-cmd.c
@@ -301,8 +301,8 @@ static int saa7164_cmd_wait(struct saa7164_dev *dev, u8 seqno)
301 else 301 else
302 saa7164_cmd_timeout_seqno(dev, seqno); 302 saa7164_cmd_timeout_seqno(dev, seqno);
303 303
304 dprintk(DBGLVL_CMD, "%s(seqno=%d) Waiting res = %d " 304 dprintk(DBGLVL_CMD, "%s(seqno=%d) Waiting res = %d (signalled=%d)\n",
305 "(signalled=%d)\n", __func__, seqno, r, 305 __func__, seqno, r,
306 dev->cmds[seqno].signalled); 306 dev->cmds[seqno].signalled);
307 } else 307 } else
308 ret = SAA_OK; 308 ret = SAA_OK;
@@ -353,8 +353,8 @@ int saa7164_cmd_send(struct saa7164_dev *dev, u8 id, enum tmComResCmd command,
353 int ret; 353 int ret;
354 int safety = 0; 354 int safety = 0;
355 355
356 dprintk(DBGLVL_CMD, "%s(unitid = %s (%d) , command = 0x%x, " 356 dprintk(DBGLVL_CMD, "%s(unitid = %s (%d) , command = 0x%x, sel = 0x%x)\n",
357 "sel = 0x%x)\n", __func__, saa7164_unitid_name(dev, id), id, 357 __func__, saa7164_unitid_name(dev, id), id,
358 command, controlselector); 358 command, controlselector);
359 359
360 if ((size == 0) || (buf == NULL)) { 360 if ((size == 0) || (buf == NULL)) {
@@ -452,9 +452,7 @@ int saa7164_cmd_send(struct saa7164_dev *dev, u8 id, enum tmComResCmd command,
452 if (presponse_t->seqno != pcommand_t->seqno) { 452 if (presponse_t->seqno != pcommand_t->seqno) {
453 453
454 dprintk(DBGLVL_CMD, 454 dprintk(DBGLVL_CMD,
455 "wrong event: seqno = %d, " 455 "wrong event: seqno = %d, expected seqno = %d, will dequeue regardless\n",
456 "expected seqno = %d, "
457 "will dequeue regardless\n",
458 presponse_t->seqno, pcommand_t->seqno); 456 presponse_t->seqno, pcommand_t->seqno);
459 457
460 ret = saa7164_cmd_dequeue(dev); 458 ret = saa7164_cmd_dequeue(dev);
diff --git a/drivers/media/pci/saa7164/saa7164-core.c b/drivers/media/pci/saa7164/saa7164-core.c
index 8bbd092fbe1d..03a1511a92be 100644
--- a/drivers/media/pci/saa7164/saa7164-core.c
+++ b/drivers/media/pci/saa7164/saa7164-core.c
@@ -710,9 +710,7 @@ static irqreturn_t saa7164_irq(int irq, void *dev_id)
710 } else { 710 } else {
711 /* Find the function */ 711 /* Find the function */
712 dprintk(DBGLVL_IRQ, 712 dprintk(DBGLVL_IRQ,
713 "%s() unhandled interrupt " 713 "%s() unhandled interrupt reg 0x%x bit 0x%x intid = 0x%x\n",
714 "reg 0x%x bit 0x%x "
715 "intid = 0x%x\n",
716 __func__, i, bit, intid); 714 __func__, i, bit, intid);
717 } 715 }
718 } 716 }
@@ -767,13 +765,11 @@ void saa7164_dumpregs(struct saa7164_dev *dev, u32 addr)
767{ 765{
768 int i; 766 int i;
769 767
770 dprintk(1, "--------------------> " 768 dprintk(1, "--------------------> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\n");
771 "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\n");
772 769
773 for (i = 0; i < 0x100; i += 16) 770 for (i = 0; i < 0x100; i += 16)
774 dprintk(1, "region0[0x%08x] = " 771 dprintk(1, "region0[0x%08x] = %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
775 "%02x %02x %02x %02x %02x %02x %02x %02x" 772 i,
776 " %02x %02x %02x %02x %02x %02x %02x %02x\n", i,
777 (u8)saa7164_readb(addr + i + 0), 773 (u8)saa7164_readb(addr + i + 0),
778 (u8)saa7164_readb(addr + i + 1), 774 (u8)saa7164_readb(addr + i + 1),
779 (u8)saa7164_readb(addr + i + 2), 775 (u8)saa7164_readb(addr + i + 2),
@@ -825,8 +821,7 @@ static void saa7164_dump_hwdesc(struct saa7164_dev *dev)
825 821
826static void saa7164_dump_intfdesc(struct saa7164_dev *dev) 822static void saa7164_dump_intfdesc(struct saa7164_dev *dev)
827{ 823{
828 dprintk(1, "@0x%p intfdesc " 824 dprintk(1, "@0x%p intfdesc sizeof(struct tmComResInterfaceDescr) = %d bytes\n",
829 "sizeof(struct tmComResInterfaceDescr) = %d bytes\n",
830 &dev->intfdesc, (u32)sizeof(struct tmComResInterfaceDescr)); 825 &dev->intfdesc, (u32)sizeof(struct tmComResInterfaceDescr));
831 826
832 dprintk(1, " .bLength = 0x%x\n", dev->intfdesc.bLength); 827 dprintk(1, " .bLength = 0x%x\n", dev->intfdesc.bLength);
@@ -1011,8 +1006,7 @@ static int saa7164_dev_setup(struct saa7164_dev *dev)
1011 saa7164_port_init(dev, SAA7164_PORT_VBI2); 1006 saa7164_port_init(dev, SAA7164_PORT_VBI2);
1012 1007
1013 if (get_resources(dev) < 0) { 1008 if (get_resources(dev) < 0) {
1014 printk(KERN_ERR "CORE %s No more PCIe resources for " 1009 printk(KERN_ERR "CORE %s No more PCIe resources for subsystem: %04x:%04x\n",
1015 "subsystem: %04x:%04x\n",
1016 dev->name, dev->pci->subsystem_vendor, 1010 dev->name, dev->pci->subsystem_vendor,
1017 dev->pci->subsystem_device); 1011 dev->pci->subsystem_device);
1018 1012
@@ -1204,8 +1198,8 @@ static bool saa7164_enable_msi(struct pci_dev *pci_dev, struct saa7164_dev *dev)
1204 err = pci_enable_msi(pci_dev); 1198 err = pci_enable_msi(pci_dev);
1205 1199
1206 if (err) { 1200 if (err) {
1207 printk(KERN_ERR "%s() Failed to enable MSI interrupt." 1201 printk(KERN_ERR "%s() Failed to enable MSI interrupt. Falling back to a shared IRQ\n",
1208 " Falling back to a shared IRQ\n", __func__); 1202 __func__);
1209 return false; 1203 return false;
1210 } 1204 }
1211 1205
@@ -1215,8 +1209,8 @@ static bool saa7164_enable_msi(struct pci_dev *pci_dev, struct saa7164_dev *dev)
1215 1209
1216 if (err) { 1210 if (err) {
1217 /* fall back to legacy interrupt */ 1211 /* fall back to legacy interrupt */
1218 printk(KERN_ERR "%s() Failed to get an MSI interrupt." 1212 printk(KERN_ERR "%s() Failed to get an MSI interrupt. Falling back to a shared IRQ\n",
1219 " Falling back to a shared IRQ\n", __func__); 1213 __func__);
1220 pci_disable_msi(pci_dev); 1214 pci_disable_msi(pci_dev);
1221 return false; 1215 return false;
1222 } 1216 }
@@ -1256,8 +1250,8 @@ static int saa7164_initdev(struct pci_dev *pci_dev,
1256 /* print pci info */ 1250 /* print pci info */
1257 dev->pci_rev = pci_dev->revision; 1251 dev->pci_rev = pci_dev->revision;
1258 pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat); 1252 pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat);
1259 printk(KERN_INFO "%s/0: found at %s, rev: %d, irq: %d, " 1253 printk(KERN_INFO "%s/0: found at %s, rev: %d, irq: %d, latency: %d, mmio: 0x%llx\n",
1260 "latency: %d, mmio: 0x%llx\n", dev->name, 1254 dev->name,
1261 pci_name(pci_dev), dev->pci_rev, pci_dev->irq, 1255 pci_name(pci_dev), dev->pci_rev, pci_dev->irq,
1262 dev->pci_lat, 1256 dev->pci_lat,
1263 (unsigned long long)pci_resource_start(pci_dev, 0)); 1257 (unsigned long long)pci_resource_start(pci_dev, 0));
@@ -1307,8 +1301,7 @@ static int saa7164_initdev(struct pci_dev *pci_dev,
1307 err = saa7164_downloadfirmware(dev); 1301 err = saa7164_downloadfirmware(dev);
1308 if (err < 0) { 1302 if (err < 0) {
1309 printk(KERN_ERR 1303 printk(KERN_ERR
1310 "Failed to boot firmware, no features " 1304 "Failed to boot firmware, no features registered\n");
1311 "registered\n");
1312 goto fail_fw; 1305 goto fail_fw;
1313 } 1306 }
1314 1307
@@ -1327,8 +1320,7 @@ static int saa7164_initdev(struct pci_dev *pci_dev,
1327 */ 1320 */
1328 version = 0; 1321 version = 0;
1329 if (saa7164_api_get_fw_version(dev, &version) == SAA_OK) 1322 if (saa7164_api_get_fw_version(dev, &version) == SAA_OK)
1330 dprintk(1, "Bus is operating correctly using " 1323 dprintk(1, "Bus is operating correctly using version %d.%d.%d.%d (0x%x)\n",
1331 "version %d.%d.%d.%d (0x%x)\n",
1332 (version & 0x0000fc00) >> 10, 1324 (version & 0x0000fc00) >> 10,
1333 (version & 0x000003e0) >> 5, 1325 (version & 0x000003e0) >> 5,
1334 (version & 0x0000001f), 1326 (version & 0x0000001f),
@@ -1356,45 +1348,43 @@ static int saa7164_initdev(struct pci_dev *pci_dev,
1356 /* Begin to create the video sub-systems and register funcs */ 1348 /* Begin to create the video sub-systems and register funcs */
1357 if (saa7164_boards[dev->board].porta == SAA7164_MPEG_DVB) { 1349 if (saa7164_boards[dev->board].porta == SAA7164_MPEG_DVB) {
1358 if (saa7164_dvb_register(&dev->ports[SAA7164_PORT_TS1]) < 0) { 1350 if (saa7164_dvb_register(&dev->ports[SAA7164_PORT_TS1]) < 0) {
1359 printk(KERN_ERR "%s() Failed to register " 1351 printk(KERN_ERR "%s() Failed to register dvb adapters on porta\n",
1360 "dvb adapters on porta\n",
1361 __func__); 1352 __func__);
1362 } 1353 }
1363 } 1354 }
1364 1355
1365 if (saa7164_boards[dev->board].portb == SAA7164_MPEG_DVB) { 1356 if (saa7164_boards[dev->board].portb == SAA7164_MPEG_DVB) {
1366 if (saa7164_dvb_register(&dev->ports[SAA7164_PORT_TS2]) < 0) { 1357 if (saa7164_dvb_register(&dev->ports[SAA7164_PORT_TS2]) < 0) {
1367 printk(KERN_ERR"%s() Failed to register " 1358 printk(KERN_ERR"%s() Failed to register dvb adapters on portb\n",
1368 "dvb adapters on portb\n",
1369 __func__); 1359 __func__);
1370 } 1360 }
1371 } 1361 }
1372 1362
1373 if (saa7164_boards[dev->board].portc == SAA7164_MPEG_ENCODER) { 1363 if (saa7164_boards[dev->board].portc == SAA7164_MPEG_ENCODER) {
1374 if (saa7164_encoder_register(&dev->ports[SAA7164_PORT_ENC1]) < 0) { 1364 if (saa7164_encoder_register(&dev->ports[SAA7164_PORT_ENC1]) < 0) {
1375 printk(KERN_ERR"%s() Failed to register " 1365 printk(KERN_ERR"%s() Failed to register mpeg encoder\n",
1376 "mpeg encoder\n", __func__); 1366 __func__);
1377 } 1367 }
1378 } 1368 }
1379 1369
1380 if (saa7164_boards[dev->board].portd == SAA7164_MPEG_ENCODER) { 1370 if (saa7164_boards[dev->board].portd == SAA7164_MPEG_ENCODER) {
1381 if (saa7164_encoder_register(&dev->ports[SAA7164_PORT_ENC2]) < 0) { 1371 if (saa7164_encoder_register(&dev->ports[SAA7164_PORT_ENC2]) < 0) {
1382 printk(KERN_ERR"%s() Failed to register " 1372 printk(KERN_ERR"%s() Failed to register mpeg encoder\n",
1383 "mpeg encoder\n", __func__); 1373 __func__);
1384 } 1374 }
1385 } 1375 }
1386 1376
1387 if (saa7164_boards[dev->board].porte == SAA7164_MPEG_VBI) { 1377 if (saa7164_boards[dev->board].porte == SAA7164_MPEG_VBI) {
1388 if (saa7164_vbi_register(&dev->ports[SAA7164_PORT_VBI1]) < 0) { 1378 if (saa7164_vbi_register(&dev->ports[SAA7164_PORT_VBI1]) < 0) {
1389 printk(KERN_ERR"%s() Failed to register " 1379 printk(KERN_ERR"%s() Failed to register vbi device\n",
1390 "vbi device\n", __func__); 1380 __func__);
1391 } 1381 }
1392 } 1382 }
1393 1383
1394 if (saa7164_boards[dev->board].portf == SAA7164_MPEG_VBI) { 1384 if (saa7164_boards[dev->board].portf == SAA7164_MPEG_VBI) {
1395 if (saa7164_vbi_register(&dev->ports[SAA7164_PORT_VBI2]) < 0) { 1385 if (saa7164_vbi_register(&dev->ports[SAA7164_PORT_VBI2]) < 0) {
1396 printk(KERN_ERR"%s() Failed to register " 1386 printk(KERN_ERR"%s() Failed to register vbi device\n",
1397 "vbi device\n", __func__); 1387 __func__);
1398 } 1388 }
1399 } 1389 }
1400 saa7164_api_set_debug(dev, fw_debug); 1390 saa7164_api_set_debug(dev, fw_debug);
@@ -1404,15 +1394,15 @@ static int saa7164_initdev(struct pci_dev *pci_dev,
1404 "saa7164 debug"); 1394 "saa7164 debug");
1405 if (IS_ERR(dev->kthread)) { 1395 if (IS_ERR(dev->kthread)) {
1406 dev->kthread = NULL; 1396 dev->kthread = NULL;
1407 printk(KERN_ERR "%s() Failed to create " 1397 printk(KERN_ERR "%s() Failed to create debug kernel thread\n",
1408 "debug kernel thread\n", __func__); 1398 __func__);
1409 } 1399 }
1410 } 1400 }
1411 1401
1412 } /* != BOARD_UNKNOWN */ 1402 } /* != BOARD_UNKNOWN */
1413 else 1403 else
1414 printk(KERN_ERR "%s() Unsupported board detected, " 1404 printk(KERN_ERR "%s() Unsupported board detected, registering without firmware\n",
1415 "registering without firmware\n", __func__); 1405 __func__);
1416 1406
1417 dprintk(1, "%s() parameter debug = %d\n", __func__, saa_debug); 1407 dprintk(1, "%s() parameter debug = %d\n", __func__, saa_debug);
1418 dprintk(1, "%s() parameter waitsecs = %d\n", __func__, waitsecs); 1408 dprintk(1, "%s() parameter waitsecs = %d\n", __func__, waitsecs);
diff --git a/drivers/media/pci/saa7164/saa7164-dvb.c b/drivers/media/pci/saa7164/saa7164-dvb.c
index e9a783b71b45..cd3eeda5250b 100644
--- a/drivers/media/pci/saa7164/saa7164-dvb.c
+++ b/drivers/media/pci/saa7164/saa7164-dvb.c
@@ -244,8 +244,8 @@ static int saa7164_dvb_start_port(struct saa7164_port *port)
244 /* Stop the hardware, regardless */ 244 /* Stop the hardware, regardless */
245 result = saa7164_api_transition_port(port, SAA_DMASTATE_STOP); 245 result = saa7164_api_transition_port(port, SAA_DMASTATE_STOP);
246 if ((result != SAA_OK) && (result != SAA_ERR_ALREADY_STOPPED)) { 246 if ((result != SAA_OK) && (result != SAA_ERR_ALREADY_STOPPED)) {
247 printk(KERN_ERR "%s() acquire/forced stop transition " 247 printk(KERN_ERR "%s() acquire/forced stop transition failed, res = 0x%x\n",
248 "failed, res = 0x%x\n", __func__, result); 248 __func__, result);
249 } 249 }
250 ret = -EIO; 250 ret = -EIO;
251 goto out; 251 goto out;
@@ -261,8 +261,8 @@ static int saa7164_dvb_start_port(struct saa7164_port *port)
261 /* Stop the hardware, regardless */ 261 /* Stop the hardware, regardless */
262 result = saa7164_api_transition_port(port, SAA_DMASTATE_STOP); 262 result = saa7164_api_transition_port(port, SAA_DMASTATE_STOP);
263 if ((result != SAA_OK) && (result != SAA_ERR_ALREADY_STOPPED)) { 263 if ((result != SAA_OK) && (result != SAA_ERR_ALREADY_STOPPED)) {
264 printk(KERN_ERR "%s() pause/forced stop transition " 264 printk(KERN_ERR "%s() pause/forced stop transition failed, res = 0x%x\n",
265 "failed, res = 0x%x\n", __func__, result); 265 __func__, result);
266 } 266 }
267 267
268 ret = -EIO; 268 ret = -EIO;
@@ -279,8 +279,8 @@ static int saa7164_dvb_start_port(struct saa7164_port *port)
279 /* Stop the hardware, regardless */ 279 /* Stop the hardware, regardless */
280 result = saa7164_api_transition_port(port, SAA_DMASTATE_STOP); 280 result = saa7164_api_transition_port(port, SAA_DMASTATE_STOP);
281 if ((result != SAA_OK) && (result != SAA_ERR_ALREADY_STOPPED)) { 281 if ((result != SAA_OK) && (result != SAA_ERR_ALREADY_STOPPED)) {
282 printk(KERN_ERR "%s() run/forced stop transition " 282 printk(KERN_ERR "%s() run/forced stop transition failed, res = 0x%x\n",
283 "failed, res = 0x%x\n", __func__, result); 283 __func__, result);
284 } 284 }
285 285
286 ret = -EIO; 286 ret = -EIO;
@@ -357,8 +357,7 @@ static int dvb_register(struct saa7164_port *port)
357 /* Sanity check that the PCI configuration space is active */ 357 /* Sanity check that the PCI configuration space is active */
358 if (port->hwcfg.BARLocation == 0) { 358 if (port->hwcfg.BARLocation == 0) {
359 result = -ENOMEM; 359 result = -ENOMEM;
360 printk(KERN_ERR "%s: dvb_register_adapter failed " 360 printk(KERN_ERR "%s: dvb_register_adapter failed (errno = %d), NO PCI configuration\n",
361 "(errno = %d), NO PCI configuration\n",
362 DRIVER_NAME, result); 361 DRIVER_NAME, result);
363 goto fail_adapter; 362 goto fail_adapter;
364 } 363 }
@@ -386,8 +385,7 @@ static int dvb_register(struct saa7164_port *port)
386 385
387 if (!buf) { 386 if (!buf) {
388 result = -ENOMEM; 387 result = -ENOMEM;
389 printk(KERN_ERR "%s: dvb_register_adapter failed " 388 printk(KERN_ERR "%s: dvb_register_adapter failed (errno = %d), unable to allocate buffers\n",
390 "(errno = %d), unable to allocate buffers\n",
391 DRIVER_NAME, result); 389 DRIVER_NAME, result);
392 goto fail_adapter; 390 goto fail_adapter;
393 } 391 }
@@ -401,8 +399,8 @@ static int dvb_register(struct saa7164_port *port)
401 result = dvb_register_adapter(&dvb->adapter, DRIVER_NAME, THIS_MODULE, 399 result = dvb_register_adapter(&dvb->adapter, DRIVER_NAME, THIS_MODULE,
402 &dev->pci->dev, adapter_nr); 400 &dev->pci->dev, adapter_nr);
403 if (result < 0) { 401 if (result < 0) {
404 printk(KERN_ERR "%s: dvb_register_adapter failed " 402 printk(KERN_ERR "%s: dvb_register_adapter failed (errno = %d)\n",
405 "(errno = %d)\n", DRIVER_NAME, result); 403 DRIVER_NAME, result);
406 goto fail_adapter; 404 goto fail_adapter;
407 } 405 }
408 dvb->adapter.priv = port; 406 dvb->adapter.priv = port;
@@ -410,8 +408,8 @@ static int dvb_register(struct saa7164_port *port)
410 /* register frontend */ 408 /* register frontend */
411 result = dvb_register_frontend(&dvb->adapter, dvb->frontend); 409 result = dvb_register_frontend(&dvb->adapter, dvb->frontend);
412 if (result < 0) { 410 if (result < 0) {
413 printk(KERN_ERR "%s: dvb_register_frontend failed " 411 printk(KERN_ERR "%s: dvb_register_frontend failed (errno = %d)\n",
414 "(errno = %d)\n", DRIVER_NAME, result); 412 DRIVER_NAME, result);
415 goto fail_frontend; 413 goto fail_frontend;
416 } 414 }
417 415
@@ -444,16 +442,16 @@ static int dvb_register(struct saa7164_port *port)
444 dvb->fe_hw.source = DMX_FRONTEND_0; 442 dvb->fe_hw.source = DMX_FRONTEND_0;
445 result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw); 443 result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw);
446 if (result < 0) { 444 if (result < 0) {
447 printk(KERN_ERR "%s: add_frontend failed " 445 printk(KERN_ERR "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n",
448 "(DMX_FRONTEND_0, errno = %d)\n", DRIVER_NAME, result); 446 DRIVER_NAME, result);
449 goto fail_fe_hw; 447 goto fail_fe_hw;
450 } 448 }
451 449
452 dvb->fe_mem.source = DMX_MEMORY_FE; 450 dvb->fe_mem.source = DMX_MEMORY_FE;
453 result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem); 451 result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem);
454 if (result < 0) { 452 if (result < 0) {
455 printk(KERN_ERR "%s: add_frontend failed " 453 printk(KERN_ERR "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n",
456 "(DMX_MEMORY_FE, errno = %d)\n", DRIVER_NAME, result); 454 DRIVER_NAME, result);
457 goto fail_fe_mem; 455 goto fail_fe_mem;
458 } 456 }
459 457
diff --git a/drivers/media/pci/saa7164/saa7164-encoder.c b/drivers/media/pci/saa7164/saa7164-encoder.c
index 32a353d162e7..68124ce7ebc3 100644
--- a/drivers/media/pci/saa7164/saa7164-encoder.c
+++ b/drivers/media/pci/saa7164/saa7164-encoder.c
@@ -157,8 +157,7 @@ static int saa7164_encoder_buffers_alloc(struct saa7164_port *port)
157 params->pitch); 157 params->pitch);
158 158
159 if (!buf) { 159 if (!buf) {
160 printk(KERN_ERR "%s() failed " 160 printk(KERN_ERR "%s() failed (errno = %d), unable to allocate buffer\n",
161 "(errno = %d), unable to allocate buffer\n",
162 __func__, result); 161 __func__, result);
163 result = -ENOMEM; 162 result = -ENOMEM;
164 goto failed; 163 goto failed;
@@ -681,8 +680,8 @@ static int saa7164_encoder_start_streaming(struct saa7164_port *port)
681 /* Stop the hardware, regardless */ 680 /* Stop the hardware, regardless */
682 result = saa7164_api_transition_port(port, SAA_DMASTATE_STOP); 681 result = saa7164_api_transition_port(port, SAA_DMASTATE_STOP);
683 if ((result != SAA_OK) && (result != SAA_ERR_ALREADY_STOPPED)) { 682 if ((result != SAA_OK) && (result != SAA_ERR_ALREADY_STOPPED)) {
684 printk(KERN_ERR "%s() acquire/forced stop transition " 683 printk(KERN_ERR "%s() acquire/forced stop transition failed, res = 0x%x\n",
685 "failed, res = 0x%x\n", __func__, result); 684 __func__, result);
686 } 685 }
687 ret = -EIO; 686 ret = -EIO;
688 goto out; 687 goto out;
@@ -698,8 +697,8 @@ static int saa7164_encoder_start_streaming(struct saa7164_port *port)
698 /* Stop the hardware, regardless */ 697 /* Stop the hardware, regardless */
699 result = saa7164_api_transition_port(port, SAA_DMASTATE_STOP); 698 result = saa7164_api_transition_port(port, SAA_DMASTATE_STOP);
700 if ((result != SAA_OK) && (result != SAA_ERR_ALREADY_STOPPED)) { 699 if ((result != SAA_OK) && (result != SAA_ERR_ALREADY_STOPPED)) {
701 printk(KERN_ERR "%s() pause/forced stop transition " 700 printk(KERN_ERR "%s() pause/forced stop transition failed, res = 0x%x\n",
702 "failed, res = 0x%x\n", __func__, result); 701 __func__, result);
703 } 702 }
704 703
705 ret = -EIO; 704 ret = -EIO;
@@ -716,8 +715,8 @@ static int saa7164_encoder_start_streaming(struct saa7164_port *port)
716 /* Stop the hardware, regardless */ 715 /* Stop the hardware, regardless */
717 result = saa7164_api_transition_port(port, SAA_DMASTATE_STOP); 716 result = saa7164_api_transition_port(port, SAA_DMASTATE_STOP);
718 if ((result != SAA_OK) && (result != SAA_ERR_ALREADY_STOPPED)) { 717 if ((result != SAA_OK) && (result != SAA_ERR_ALREADY_STOPPED)) {
719 printk(KERN_ERR "%s() run/forced stop transition " 718 printk(KERN_ERR "%s() run/forced stop transition failed, res = 0x%x\n",
720 "failed, res = 0x%x\n", __func__, result); 719 __func__, result);
721 } 720 }
722 721
723 ret = -EIO; 722 ret = -EIO;
@@ -1026,8 +1025,7 @@ int saa7164_encoder_register(struct saa7164_port *port)
1026 1025
1027 /* Sanity check that the PCI configuration space is active */ 1026 /* Sanity check that the PCI configuration space is active */
1028 if (port->hwcfg.BARLocation == 0) { 1027 if (port->hwcfg.BARLocation == 0) {
1029 printk(KERN_ERR "%s() failed " 1028 printk(KERN_ERR "%s() failed (errno = %d), NO PCI configuration\n",
1030 "(errno = %d), NO PCI configuration\n",
1031 __func__, result); 1029 __func__, result);
1032 result = -ENOMEM; 1030 result = -ENOMEM;
1033 goto failed; 1031 goto failed;
diff --git a/drivers/media/pci/saa7164/saa7164-fw.c b/drivers/media/pci/saa7164/saa7164-fw.c
index 269e0782c7b6..8568adfd7ece 100644
--- a/drivers/media/pci/saa7164/saa7164-fw.c
+++ b/drivers/media/pci/saa7164/saa7164-fw.c
@@ -421,8 +421,8 @@ int saa7164_downloadfirmware(struct saa7164_dev *dev)
421 421
422 ret = request_firmware(&fw, fwname, &dev->pci->dev); 422 ret = request_firmware(&fw, fwname, &dev->pci->dev);
423 if (ret) { 423 if (ret) {
424 printk(KERN_ERR "%s() Upload failed. " 424 printk(KERN_ERR "%s() Upload failed. (file not found?)\n",
425 "(file not found?)\n", __func__); 425 __func__);
426 return -ENOMEM; 426 return -ENOMEM;
427 } 427 }
428 428
@@ -478,15 +478,13 @@ int saa7164_downloadfirmware(struct saa7164_dev *dev)
478 0x03) && (saa7164_readl(SAA_DATAREADY_FLAG_ACK) 478 0x03) && (saa7164_readl(SAA_DATAREADY_FLAG_ACK)
479 == 0x00) && (version == 0x00)) { 479 == 0x00) && (version == 0x00)) {
480 480
481 dprintk(DBGLVL_FW, "BootLoader version in " 481 dprintk(DBGLVL_FW, "BootLoader version in rom %d.%d.%d.%d\n",
482 "rom %d.%d.%d.%d\n",
483 (bootloaderversion & 0x0000fc00) >> 10, 482 (bootloaderversion & 0x0000fc00) >> 10,
484 (bootloaderversion & 0x000003e0) >> 5, 483 (bootloaderversion & 0x000003e0) >> 5,
485 (bootloaderversion & 0x0000001f), 484 (bootloaderversion & 0x0000001f),
486 (bootloaderversion & 0xffff0000) >> 16 485 (bootloaderversion & 0xffff0000) >> 16
487 ); 486 );
488 dprintk(DBGLVL_FW, "BootLoader version " 487 dprintk(DBGLVL_FW, "BootLoader version in file %d.%d.%d.%d\n",
489 "in file %d.%d.%d.%d\n",
490 (boothdr->version & 0x0000fc00) >> 10, 488 (boothdr->version & 0x0000fc00) >> 10,
491 (boothdr->version & 0x000003e0) >> 5, 489 (boothdr->version & 0x000003e0) >> 5,
492 (boothdr->version & 0x0000001f), 490 (boothdr->version & 0x0000001f),
diff --git a/drivers/media/pci/saa7164/saa7164-vbi.c b/drivers/media/pci/saa7164/saa7164-vbi.c
index ee54491459a6..e5dcb81029d3 100644
--- a/drivers/media/pci/saa7164/saa7164-vbi.c
+++ b/drivers/media/pci/saa7164/saa7164-vbi.c
@@ -110,8 +110,7 @@ static int saa7164_vbi_buffers_alloc(struct saa7164_port *port)
110 params->pitch); 110 params->pitch);
111 111
112 if (!buf) { 112 if (!buf) {
113 printk(KERN_ERR "%s() failed " 113 printk(KERN_ERR "%s() failed (errno = %d), unable to allocate buffer\n",
114 "(errno = %d), unable to allocate buffer\n",
115 __func__, result); 114 __func__, result);
116 result = -ENOMEM; 115 result = -ENOMEM;
117 goto failed; 116 goto failed;
@@ -384,8 +383,8 @@ static int saa7164_vbi_start_streaming(struct saa7164_port *port)
384 /* Stop the hardware, regardless */ 383 /* Stop the hardware, regardless */
385 result = saa7164_vbi_stop_port(port); 384 result = saa7164_vbi_stop_port(port);
386 if (result != SAA_OK) { 385 if (result != SAA_OK) {
387 printk(KERN_ERR "%s() pause/forced stop transition " 386 printk(KERN_ERR "%s() pause/forced stop transition failed, res = 0x%x\n",
388 "failed, res = 0x%x\n", __func__, result); 387 __func__, result);
389 } 388 }
390 389
391 ret = -EIO; 390 ret = -EIO;
@@ -403,8 +402,8 @@ static int saa7164_vbi_start_streaming(struct saa7164_port *port)
403 result = saa7164_vbi_acquire_port(port); 402 result = saa7164_vbi_acquire_port(port);
404 result = saa7164_vbi_stop_port(port); 403 result = saa7164_vbi_stop_port(port);
405 if (result != SAA_OK) { 404 if (result != SAA_OK) {
406 printk(KERN_ERR "%s() run/forced stop transition " 405 printk(KERN_ERR "%s() run/forced stop transition failed, res = 0x%x\n",
407 "failed, res = 0x%x\n", __func__, result); 406 __func__, result);
408 } 407 }
409 408
410 ret = -EIO; 409 ret = -EIO;
@@ -728,8 +727,7 @@ int saa7164_vbi_register(struct saa7164_port *port)
728 727
729 /* Sanity check that the PCI configuration space is active */ 728 /* Sanity check that the PCI configuration space is active */
730 if (port->hwcfg.BARLocation == 0) { 729 if (port->hwcfg.BARLocation == 0) {
731 printk(KERN_ERR "%s() failed " 730 printk(KERN_ERR "%s() failed (errno = %d), NO PCI configuration\n",
732 "(errno = %d), NO PCI configuration\n",
733 __func__, result); 731 __func__, result);
734 result = -ENOMEM; 732 result = -ENOMEM;
735 goto failed; 733 goto failed;
diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2.c b/drivers/media/pci/solo6x10/solo6x10-v4l2.c
index b4be47969b6b..896bec6627aa 100644
--- a/drivers/media/pci/solo6x10/solo6x10-v4l2.c
+++ b/drivers/media/pci/solo6x10/solo6x10-v4l2.c
@@ -702,8 +702,8 @@ int solo_v4l2_init(struct solo_dev *solo_dev, unsigned nr)
702 snprintf(solo_dev->vfd->name, sizeof(solo_dev->vfd->name), "%s (%i)", 702 snprintf(solo_dev->vfd->name, sizeof(solo_dev->vfd->name), "%s (%i)",
703 SOLO6X10_NAME, solo_dev->vfd->num); 703 SOLO6X10_NAME, solo_dev->vfd->num);
704 704
705 dev_info(&solo_dev->pdev->dev, "Display as /dev/video%d with " 705 dev_info(&solo_dev->pdev->dev, "Display as /dev/video%d with %d inputs (%d extended)\n",
706 "%d inputs (%d extended)\n", solo_dev->vfd->num, 706 solo_dev->vfd->num,
707 solo_dev->nr_chans, solo_dev->nr_ext); 707 solo_dev->nr_chans, solo_dev->nr_ext);
708 708
709 return 0; 709 return 0;
diff --git a/drivers/media/pci/solo6x10/solo6x10.h b/drivers/media/pci/solo6x10/solo6x10.h
index 5bd498735a66..3f8da5e8c430 100644
--- a/drivers/media/pci/solo6x10/solo6x10.h
+++ b/drivers/media/pci/solo6x10/solo6x10.h
@@ -284,7 +284,10 @@ static inline u32 solo_reg_read(struct solo_dev *solo_dev, int reg)
284static inline void solo_reg_write(struct solo_dev *solo_dev, int reg, 284static inline void solo_reg_write(struct solo_dev *solo_dev, int reg,
285 u32 data) 285 u32 data)
286{ 286{
287 u16 val;
288
287 writel(data, solo_dev->reg_base + reg); 289 writel(data, solo_dev->reg_base + reg);
290 pci_read_config_word(solo_dev->pdev, PCI_STATUS, &val);
288} 291}
289 292
290static inline void solo_irq_on(struct solo_dev *dev, u32 mask) 293static inline void solo_irq_on(struct solo_dev *dev, u32 mask)
diff --git a/drivers/media/pci/ttpci/Makefile b/drivers/media/pci/ttpci/Makefile
index 49f71b1eaf14..3cf617737f7c 100644
--- a/drivers/media/pci/ttpci/Makefile
+++ b/drivers/media/pci/ttpci/Makefile
@@ -3,7 +3,7 @@
3# and the AV7110 DVB device driver 3# and the AV7110 DVB device driver
4# 4#
5 5
6dvb-ttpci-objs := av7110_hw.o av7110_v4l.o av7110_av.o av7110_ca.o av7110.o av7110_ipack.o 6dvb-ttpci-objs := av7110_hw.o av7110_v4l.o av7110_av.o av7110_ca.o av7110.o av7110_ipack.o dvb_filter.o
7 7
8ifdef CONFIG_DVB_AV7110_IR 8ifdef CONFIG_DVB_AV7110_IR
9dvb-ttpci-objs += av7110_ir.o 9dvb-ttpci-objs += av7110_ir.o
diff --git a/drivers/media/pci/ttpci/av7110.c b/drivers/media/pci/ttpci/av7110.c
index 382caf200ba1..6e63949d6ad0 100644
--- a/drivers/media/pci/ttpci/av7110.c
+++ b/drivers/media/pci/ttpci/av7110.c
@@ -100,8 +100,7 @@ MODULE_PARM_DESC(adac,"audio DAC type: 0 TI, 1 CRYSTAL, 2 MSP (use if autodetect
100module_param(hw_sections, int, 0444); 100module_param(hw_sections, int, 0444);
101MODULE_PARM_DESC(hw_sections, "0 use software section filter, 1 use hardware"); 101MODULE_PARM_DESC(hw_sections, "0 use software section filter, 1 use hardware");
102module_param(rgb_on, int, 0444); 102module_param(rgb_on, int, 0444);
103MODULE_PARM_DESC(rgb_on, "For Siemens DVB-C cards only: Enable RGB control" 103MODULE_PARM_DESC(rgb_on, "For Siemens DVB-C cards only: Enable RGB control signal on SCART pin 16 to switch SCART video mode from CVBS to RGB");
104 " signal on SCART pin 16 to switch SCART video mode from CVBS to RGB");
105module_param(volume, int, 0444); 104module_param(volume, int, 0444);
106MODULE_PARM_DESC(volume, "initial volume: default 255 (range 0-255)"); 105MODULE_PARM_DESC(volume, "initial volume: default 255 (range 0-255)");
107module_param(budgetpatch, int, 0444); 106module_param(budgetpatch, int, 0444);
@@ -444,21 +443,6 @@ static void debiirq(unsigned long cookie)
444 443
445 case DATA_COMMON_INTERFACE: 444 case DATA_COMMON_INTERFACE:
446 CI_handle(av7110, (u8 *)av7110->debi_virt, av7110->debilen); 445 CI_handle(av7110, (u8 *)av7110->debi_virt, av7110->debilen);
447#if 0
448 {
449 int i;
450
451 printk("av7110%d: ", av7110->num);
452 printk("%02x ", *(u8 *)av7110->debi_virt);
453 printk("%02x ", *(1+(u8 *)av7110->debi_virt));
454 for (i = 2; i < av7110->debilen; i++)
455 printk("%02x ", (*(i+(unsigned char *)av7110->debi_virt)));
456 for (i = 2; i < av7110->debilen; i++)
457 printk("%c", chtrans(*(i+(unsigned char *)av7110->debi_virt)));
458
459 printk("\n");
460 }
461#endif
462 xfer = RX_BUFF; 446 xfer = RX_BUFF;
463 break; 447 break;
464 448
@@ -833,8 +817,7 @@ static int StartHWFilter(struct dvb_demux_filter *dvbdmxfilter)
833 817
834 ret = av7110_fw_request(av7110, buf, 20, &handle, 1); 818 ret = av7110_fw_request(av7110, buf, 20, &handle, 1);
835 if (ret != 0 || handle >= 32) { 819 if (ret != 0 || handle >= 32) {
836 printk("dvb-ttpci: %s error buf %04x %04x %04x %04x " 820 printk(KERN_ERR "dvb-ttpci: %s error buf %04x %04x %04x %04x ret %d handle %04x\n",
837 "ret %d handle %04x\n",
838 __func__, buf[0], buf[1], buf[2], buf[3], 821 __func__, buf[0], buf[1], buf[2], buf[3],
839 ret, handle); 822 ret, handle);
840 dvbdmxfilter->hw_handle = 0xffff; 823 dvbdmxfilter->hw_handle = 0xffff;
@@ -876,8 +859,7 @@ static int StopHWFilter(struct dvb_demux_filter *dvbdmxfilter)
876 buf[2] = handle; 859 buf[2] = handle;
877 ret = av7110_fw_request(av7110, buf, 3, answ, 2); 860 ret = av7110_fw_request(av7110, buf, 3, answ, 2);
878 if (ret != 0 || answ[1] != handle) { 861 if (ret != 0 || answ[1] != handle) {
879 printk("dvb-ttpci: %s error cmd %04x %04x %04x ret %x " 862 printk(KERN_ERR "dvb-ttpci: %s error cmd %04x %04x %04x ret %x resp %04x %04x pid %d\n",
880 "resp %04x %04x pid %d\n",
881 __func__, buf[0], buf[1], buf[2], ret, 863 __func__, buf[0], buf[1], buf[2], ret,
882 answ[0], answ[1], dvbdmxfilter->feed->pid); 864 answ[0], answ[1], dvbdmxfilter->feed->pid);
883 if (!ret) 865 if (!ret)
@@ -1532,15 +1514,12 @@ static int get_firmware(struct av7110* av7110)
1532 ret = request_firmware(&fw, "dvb-ttpci-01.fw", &av7110->dev->pci->dev); 1514 ret = request_firmware(&fw, "dvb-ttpci-01.fw", &av7110->dev->pci->dev);
1533 if (ret) { 1515 if (ret) {
1534 if (ret == -ENOENT) { 1516 if (ret == -ENOENT) {
1535 printk(KERN_ERR "dvb-ttpci: could not load firmware," 1517 printk(KERN_ERR "dvb-ttpci: could not load firmware, file not found: dvb-ttpci-01.fw\n");
1536 " file not found: dvb-ttpci-01.fw\n"); 1518 printk(KERN_ERR "dvb-ttpci: usually this should be in /usr/lib/hotplug/firmware or /lib/firmware\n");
1537 printk(KERN_ERR "dvb-ttpci: usually this should be in " 1519 printk(KERN_ERR "dvb-ttpci: and can be downloaded from https://linuxtv.org/download/dvb/firmware/\n");
1538 "/usr/lib/hotplug/firmware or /lib/firmware\n");
1539 printk(KERN_ERR "dvb-ttpci: and can be downloaded from"
1540 " https://linuxtv.org/download/dvb/firmware/\n");
1541 } else 1520 } else
1542 printk(KERN_ERR "dvb-ttpci: cannot request firmware" 1521 printk(KERN_ERR "dvb-ttpci: cannot request firmware (error %i)\n",
1543 " (error %i)\n", ret); 1522 ret);
1544 return -EINVAL; 1523 return -EINVAL;
1545 } 1524 }
1546 1525
@@ -2700,8 +2679,9 @@ static int av7110_attach(struct saa7146_dev* dev,
2700 goto err_stop_arm_9; 2679 goto err_stop_arm_9;
2701 2680
2702 if (FW_VERSION(av7110->arm_app)<0x2501) 2681 if (FW_VERSION(av7110->arm_app)<0x2501)
2703 printk ("dvb-ttpci: Warning, firmware version 0x%04x is too old. " 2682 printk(KERN_WARNING
2704 "System might be unstable!\n", FW_VERSION(av7110->arm_app)); 2683 "dvb-ttpci: Warning, firmware version 0x%04x is too old. System might be unstable!\n",
2684 FW_VERSION(av7110->arm_app));
2705 2685
2706 thread = kthread_run(arm_thread, (void *) av7110, "arm_mon"); 2686 thread = kthread_run(arm_thread, (void *) av7110, "arm_mon");
2707 if (IS_ERR(thread)) { 2687 if (IS_ERR(thread)) {
@@ -2930,9 +2910,7 @@ static struct saa7146_extension av7110_extension_driver = {
2930 2910
2931static int __init av7110_init(void) 2911static int __init av7110_init(void)
2932{ 2912{
2933 int retval; 2913 return saa7146_register_extension(&av7110_extension_driver);
2934 retval = saa7146_register_extension(&av7110_extension_driver);
2935 return retval;
2936} 2914}
2937 2915
2938 2916
@@ -2944,7 +2922,6 @@ static void __exit av7110_exit(void)
2944module_init(av7110_init); 2922module_init(av7110_init);
2945module_exit(av7110_exit); 2923module_exit(av7110_exit);
2946 2924
2947MODULE_DESCRIPTION("driver for the SAA7146 based AV110 PCI DVB cards by " 2925MODULE_DESCRIPTION("driver for the SAA7146 based AV110 PCI DVB cards by Siemens, Technotrend, Hauppauge");
2948 "Siemens, Technotrend, Hauppauge");
2949MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, others"); 2926MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, others");
2950MODULE_LICENSE("GPL"); 2927MODULE_LICENSE("GPL");
diff --git a/drivers/media/pci/ttpci/av7110.h b/drivers/media/pci/ttpci/av7110.h
index 3707ccd02732..824c1e262fbb 100644
--- a/drivers/media/pci/ttpci/av7110.h
+++ b/drivers/media/pci/ttpci/av7110.h
@@ -40,8 +40,11 @@
40 40
41extern int av7110_debug; 41extern int av7110_debug;
42 42
43#define dprintk(level,args...) \ 43#define dprintk(level, fmt, arg...) do { \
44 do { if ((av7110_debug & level)) { printk("dvb-ttpci: %s(): ", __func__); printk(args); } } while (0) 44 if (level & av7110_debug) \
45 printk(KERN_DEBUG KBUILD_MODNAME ": %s(): " fmt, \
46 __func__, ##arg); \
47} while (0)
45 48
46#define MAXFILT 32 49#define MAXFILT 32
47 50
diff --git a/drivers/media/pci/ttpci/av7110_hw.c b/drivers/media/pci/ttpci/av7110_hw.c
index 0583d56ef5ef..520414cbe087 100644
--- a/drivers/media/pci/ttpci/av7110_hw.c
+++ b/drivers/media/pci/ttpci/av7110_hw.c
@@ -235,8 +235,7 @@ int av7110_bootarm(struct av7110 *av7110)
235 iwdebi(av7110, DEBISWAP, DPRAM_BASE, 0x76543210, 4); 235 iwdebi(av7110, DEBISWAP, DPRAM_BASE, 0x76543210, 4);
236 236
237 if ((ret=irdebi(av7110, DEBINOSWAP, DPRAM_BASE, 0, 4)) != 0x10325476) { 237 if ((ret=irdebi(av7110, DEBINOSWAP, DPRAM_BASE, 0, 4)) != 0x10325476) {
238 printk(KERN_ERR "dvb-ttpci: debi test in av7110_bootarm() failed: " 238 printk(KERN_ERR "dvb-ttpci: debi test in av7110_bootarm() failed: %08x != %08x (check your BIOS 'Plug&Play OS' settings)\n",
239 "%08x != %08x (check your BIOS 'Plug&Play OS' settings)\n",
240 ret, 0x10325476); 239 ret, 0x10325476);
241 return -1; 240 return -1;
242 } 241 }
@@ -262,8 +261,7 @@ int av7110_bootarm(struct av7110 *av7110)
262 iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2); 261 iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2);
263 262
264 if (saa7146_wait_for_debi_done(av7110->dev, 1)) { 263 if (saa7146_wait_for_debi_done(av7110->dev, 1)) {
265 printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): " 264 printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): saa7146_wait_for_debi_done() timed out\n");
266 "saa7146_wait_for_debi_done() timed out\n");
267 return -ETIMEDOUT; 265 return -ETIMEDOUT;
268 } 266 }
269 saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI); 267 saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI);
@@ -271,8 +269,7 @@ int av7110_bootarm(struct av7110 *av7110)
271 269
272 dprintk(1, "load dram code\n"); 270 dprintk(1, "load dram code\n");
273 if (load_dram(av7110, (u32 *)av7110->bin_root, av7110->size_root) < 0) { 271 if (load_dram(av7110, (u32 *)av7110->bin_root, av7110->size_root) < 0) {
274 printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): " 272 printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): load_dram() failed\n");
275 "load_dram() failed\n");
276 return -1; 273 return -1;
277 } 274 }
278 275
@@ -283,8 +280,7 @@ int av7110_bootarm(struct av7110 *av7110)
283 mwdebi(av7110, DEBISWAB, DPRAM_BASE, av7110->bin_dpram, av7110->size_dpram); 280 mwdebi(av7110, DEBISWAB, DPRAM_BASE, av7110->bin_dpram, av7110->size_dpram);
284 281
285 if (saa7146_wait_for_debi_done(av7110->dev, 1)) { 282 if (saa7146_wait_for_debi_done(av7110->dev, 1)) {
286 printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): " 283 printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): saa7146_wait_for_debi_done() timed out after loading DRAM\n");
287 "saa7146_wait_for_debi_done() timed out after loading DRAM\n");
288 return -ETIMEDOUT; 284 return -ETIMEDOUT;
289 } 285 }
290 saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI); 286 saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI);
diff --git a/drivers/media/pci/ttpci/budget-av.c b/drivers/media/pci/ttpci/budget-av.c
index 6f0d0161970e..896c66d4b3ae 100644
--- a/drivers/media/pci/ttpci/budget-av.c
+++ b/drivers/media/pci/ttpci/budget-av.c
@@ -1636,5 +1636,4 @@ module_exit(budget_av_exit);
1636 1636
1637MODULE_LICENSE("GPL"); 1637MODULE_LICENSE("GPL");
1638MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, Michael Hunold, others"); 1638MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, Michael Hunold, others");
1639MODULE_DESCRIPTION("driver for the SAA7146 based so-called " 1639MODULE_DESCRIPTION("driver for the SAA7146 based so-called budget PCI DVB w/ analog input and CI-module (e.g. the KNC cards)");
1640 "budget PCI DVB w/ analog input and CI-module (e.g. the KNC cards)");
diff --git a/drivers/media/pci/ttpci/budget-ci.c b/drivers/media/pci/ttpci/budget-ci.c
index 7b27af4d9658..20ad93bf0f54 100644
--- a/drivers/media/pci/ttpci/budget-ci.c
+++ b/drivers/media/pci/ttpci/budget-ci.c
@@ -1586,6 +1586,4 @@ module_exit(budget_ci_exit);
1586 1586
1587MODULE_LICENSE("GPL"); 1587MODULE_LICENSE("GPL");
1588MODULE_AUTHOR("Michael Hunold, Jack Thomasson, Andrew de Quincey, others"); 1588MODULE_AUTHOR("Michael Hunold, Jack Thomasson, Andrew de Quincey, others");
1589MODULE_DESCRIPTION("driver for the SAA7146 based so-called " 1589MODULE_DESCRIPTION("driver for the SAA7146 based so-called budget PCI DVB cards w/ CI-module produced by Siemens, Technotrend, Hauppauge");
1590 "budget PCI DVB cards w/ CI-module produced by "
1591 "Siemens, Technotrend, Hauppauge");
diff --git a/drivers/media/pci/ttpci/budget-patch.c b/drivers/media/pci/ttpci/budget-patch.c
index 591dbdfa2a13..f152eda0123a 100644
--- a/drivers/media/pci/ttpci/budget-patch.c
+++ b/drivers/media/pci/ttpci/budget-patch.c
@@ -679,5 +679,4 @@ module_exit(budget_patch_exit);
679 679
680MODULE_LICENSE("GPL"); 680MODULE_LICENSE("GPL");
681MODULE_AUTHOR("Emard, Roberto Deza, Holger Waechtler, Michael Hunold, others"); 681MODULE_AUTHOR("Emard, Roberto Deza, Holger Waechtler, Michael Hunold, others");
682MODULE_DESCRIPTION("Driver for full TS modified DVB-S SAA7146+AV7110 " 682MODULE_DESCRIPTION("Driver for full TS modified DVB-S SAA7146+AV7110 based so-called Budget Patch cards");
683 "based so-called Budget Patch cards");
diff --git a/drivers/media/pci/ttpci/budget.c b/drivers/media/pci/ttpci/budget.c
index fb8ede5a1531..3091b480ce22 100644
--- a/drivers/media/pci/ttpci/budget.c
+++ b/drivers/media/pci/ttpci/budget.c
@@ -897,5 +897,4 @@ module_exit(budget_exit);
897 897
898MODULE_LICENSE("GPL"); 898MODULE_LICENSE("GPL");
899MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, Michael Hunold, others"); 899MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, Michael Hunold, others");
900MODULE_DESCRIPTION("driver for the SAA7146 based so-called " 900MODULE_DESCRIPTION("driver for the SAA7146 based so-called budget PCI DVB cards by Siemens, Technotrend, Hauppauge");
901 "budget PCI DVB cards by Siemens, Technotrend, Hauppauge");
diff --git a/drivers/media/pci/ttpci/budget.h b/drivers/media/pci/ttpci/budget.h
index 655eef5236ca..d5ae4438153e 100644
--- a/drivers/media/pci/ttpci/budget.h
+++ b/drivers/media/pci/ttpci/budget.h
@@ -21,8 +21,12 @@ extern int budget_debug;
21#undef dprintk 21#undef dprintk
22#endif 22#endif
23 23
24#define dprintk(level,args...) \ 24#define dprintk(level, fmt, arg...) do { \
25 do { if ((budget_debug & level)) { printk("%s: %s(): ", KBUILD_MODNAME, __func__); printk(args); } } while (0) 25 if (level & budget_debug) \
26 printk(KERN_DEBUG KBUILD_MODNAME ": %s(): " fmt, \
27 __func__, ##arg); \
28} while (0)
29
26 30
27struct budget_info { 31struct budget_info {
28 char *name; 32 char *name;
diff --git a/drivers/media/pci/ttpci/dvb_filter.c b/drivers/media/pci/ttpci/dvb_filter.c
new file mode 100644
index 000000000000..b67127b67d4e
--- /dev/null
+++ b/drivers/media/pci/ttpci/dvb_filter.c
@@ -0,0 +1,114 @@
1#include <linux/kernel.h>
2#include <linux/module.h>
3#include <linux/string.h>
4#include "dvb_filter.h"
5
6static u32 freq[4] = {480, 441, 320, 0};
7
8static unsigned int ac3_bitrates[32] =
9 {32,40,48,56,64,80,96,112,128,160,192,224,256,320,384,448,512,576,640,
10 0,0,0,0,0,0,0,0,0,0,0,0,0};
11
12static u32 ac3_frames[3][32] =
13 {{64,80,96,112,128,160,192,224,256,320,384,448,512,640,768,896,1024,
14 1152,1280,0,0,0,0,0,0,0,0,0,0,0,0,0},
15 {69,87,104,121,139,174,208,243,278,348,417,487,557,696,835,975,1114,
16 1253,1393,0,0,0,0,0,0,0,0,0,0,0,0,0},
17 {96,120,144,168,192,240,288,336,384,480,576,672,768,960,1152,1344,
18 1536,1728,1920,0,0,0,0,0,0,0,0,0,0,0,0,0}};
19
20int dvb_filter_get_ac3info(u8 *mbuf, int count, struct dvb_audio_info *ai, int pr)
21{
22 u8 *headr;
23 int found = 0;
24 int c = 0;
25 u8 frame = 0;
26 int fr = 0;
27
28 while ( !found && c < count){
29 u8 *b = mbuf+c;
30
31 if ( b[0] == 0x0b && b[1] == 0x77 )
32 found = 1;
33 else {
34 c++;
35 }
36 }
37
38 if (!found) return -1;
39 if (pr)
40 printk(KERN_DEBUG "Audiostream: AC3");
41
42 ai->off = c;
43 if (c+5 >= count) return -1;
44
45 ai->layer = 0; // 0 for AC3
46 headr = mbuf+c+2;
47
48 frame = (headr[2]&0x3f);
49 ai->bit_rate = ac3_bitrates[frame >> 1]*1000;
50
51 if (pr)
52 printk(KERN_CONT " BRate: %d kb/s", (int) ai->bit_rate/1000);
53
54 ai->frequency = (headr[2] & 0xc0 ) >> 6;
55 fr = (headr[2] & 0xc0 ) >> 6;
56 ai->frequency = freq[fr]*100;
57 if (pr)
58 printk(KERN_CONT " Freq: %d Hz\n", (int) ai->frequency);
59
60 ai->framesize = ac3_frames[fr][frame >> 1];
61 if ((frame & 1) && (fr == 1)) ai->framesize++;
62 ai->framesize = ai->framesize << 1;
63 if (pr)
64 printk(KERN_DEBUG " Framesize %d\n", (int) ai->framesize);
65
66 return 0;
67}
68
69void dvb_filter_pes2ts_init(struct dvb_filter_pes2ts *p2ts, unsigned short pid,
70 dvb_filter_pes2ts_cb_t *cb, void *priv)
71{
72 unsigned char *buf=p2ts->buf;
73
74 buf[0]=0x47;
75 buf[1]=(pid>>8);
76 buf[2]=pid&0xff;
77 p2ts->cc=0;
78 p2ts->cb=cb;
79 p2ts->priv=priv;
80}
81
82int dvb_filter_pes2ts(struct dvb_filter_pes2ts *p2ts, unsigned char *pes,
83 int len, int payload_start)
84{
85 unsigned char *buf=p2ts->buf;
86 int ret=0, rest;
87
88 //len=6+((pes[4]<<8)|pes[5]);
89
90 if (payload_start)
91 buf[1]|=0x40;
92 else
93 buf[1]&=~0x40;
94 while (len>=184) {
95 buf[3]=0x10|((p2ts->cc++)&0x0f);
96 memcpy(buf+4, pes, 184);
97 if ((ret=p2ts->cb(p2ts->priv, buf)))
98 return ret;
99 len-=184; pes+=184;
100 buf[1]&=~0x40;
101 }
102 if (!len)
103 return 0;
104 buf[3]=0x30|((p2ts->cc++)&0x0f);
105 rest=183-len;
106 if (rest) {
107 buf[5]=0x00;
108 if (rest-1)
109 memset(buf+6, 0xff, rest-1);
110 }
111 buf[4]=rest;
112 memcpy(buf+5+rest, pes, len);
113 return p2ts->cb(p2ts->priv, buf);
114}
diff --git a/drivers/media/dvb-core/dvb_filter.h b/drivers/media/pci/ttpci/dvb_filter.h
index 375e3be184b1..375e3be184b1 100644
--- a/drivers/media/dvb-core/dvb_filter.h
+++ b/drivers/media/pci/ttpci/dvb_filter.h
diff --git a/drivers/media/pci/ttpci/ttpci-eeprom.c b/drivers/media/pci/ttpci/ttpci-eeprom.c
index 079ee098b7e3..9534f29c1ffd 100644
--- a/drivers/media/pci/ttpci/ttpci-eeprom.c
+++ b/drivers/media/pci/ttpci/ttpci-eeprom.c
@@ -171,5 +171,4 @@ EXPORT_SYMBOL(ttpci_eeprom_parse_mac);
171 171
172MODULE_LICENSE("GPL"); 172MODULE_LICENSE("GPL");
173MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, others"); 173MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, others");
174MODULE_DESCRIPTION("Decode dvb_net MAC address from EEPROM of PCI DVB cards " 174MODULE_DESCRIPTION("Decode dvb_net MAC address from EEPROM of PCI DVB cards made by Siemens, Technotrend, Hauppauge");
175 "made by Siemens, Technotrend, Hauppauge");
diff --git a/drivers/media/pci/tw5864/tw5864-reg.h b/drivers/media/pci/tw5864/tw5864-reg.h
index 92a1b077ef8a..30ac14210e91 100644
--- a/drivers/media/pci/tw5864/tw5864-reg.h
+++ b/drivers/media/pci/tw5864/tw5864-reg.h
@@ -1879,6 +1879,14 @@
1879#define TW5864_INDIR_IN_PIC_HEIGHT(channel) (0x201 + 4 * channel) 1879#define TW5864_INDIR_IN_PIC_HEIGHT(channel) (0x201 + 4 * channel)
1880#define TW5864_INDIR_OUT_PIC_WIDTH(channel) (0x202 + 4 * channel) 1880#define TW5864_INDIR_OUT_PIC_WIDTH(channel) (0x202 + 4 * channel)
1881#define TW5864_INDIR_OUT_PIC_HEIGHT(channel) (0x203 + 4 * channel) 1881#define TW5864_INDIR_OUT_PIC_HEIGHT(channel) (0x203 + 4 * channel)
1882
1883/* Some registers skipped */
1884
1885#define TW5864_INDIR_CROP_ETC 0x260
1886/* Define controls in register TW5864_INDIR_CROP_ETC */
1887/* Enable cropping from 720 to 704 */
1888#define TW5864_INDIR_CROP_ETC_CROP_EN 0x4
1889
1882/* 1890/*
1883 * Interrupt status register from the front-end. Write "1" to each bit to clear 1891 * Interrupt status register from the front-end. Write "1" to each bit to clear
1884 * the interrupt 1892 * the interrupt
diff --git a/drivers/media/pci/tw5864/tw5864-video.c b/drivers/media/pci/tw5864/tw5864-video.c
index 652a059b2e0a..9421216bb942 100644
--- a/drivers/media/pci/tw5864/tw5864-video.c
+++ b/drivers/media/pci/tw5864/tw5864-video.c
@@ -330,6 +330,15 @@ static int tw5864_enable_input(struct tw5864_input *input)
330 tw_indir_writeb(TW5864_INDIR_OUT_PIC_WIDTH(nr), input->width / 4); 330 tw_indir_writeb(TW5864_INDIR_OUT_PIC_WIDTH(nr), input->width / 4);
331 tw_indir_writeb(TW5864_INDIR_OUT_PIC_HEIGHT(nr), input->height / 4); 331 tw_indir_writeb(TW5864_INDIR_OUT_PIC_HEIGHT(nr), input->height / 4);
332 332
333 /*
334 * Crop width from 720 to 704.
335 * Above register settings need value 720 involved.
336 */
337 input->width = 704;
338 tw_indir_writeb(TW5864_INDIR_CROP_ETC,
339 tw_indir_readb(TW5864_INDIR_CROP_ETC) |
340 TW5864_INDIR_CROP_ETC_CROP_EN);
341
333 tw_writel(TW5864_DSP_PIC_MAX_MB, 342 tw_writel(TW5864_DSP_PIC_MAX_MB,
334 ((input->width / 16) << 8) | (input->height / 16)); 343 ((input->width / 16) << 8) | (input->height / 16));
335 344
@@ -532,7 +541,7 @@ static int tw5864_fmt_vid_cap(struct file *file, void *priv,
532{ 541{
533 struct tw5864_input *input = video_drvdata(file); 542 struct tw5864_input *input = video_drvdata(file);
534 543
535 f->fmt.pix.width = 720; 544 f->fmt.pix.width = 704;
536 switch (input->std) { 545 switch (input->std) {
537 default: 546 default:
538 WARN_ON_ONCE(1); 547 WARN_ON_ONCE(1);
@@ -738,7 +747,7 @@ static int tw5864_enum_framesizes(struct file *file, void *priv,
738 return -EINVAL; 747 return -EINVAL;
739 748
740 fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; 749 fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
741 fsize->discrete.width = 720; 750 fsize->discrete.width = 704;
742 fsize->discrete.height = input->std == STD_NTSC ? 480 : 576; 751 fsize->discrete.height = input->std == STD_NTSC ? 480 : 576;
743 752
744 return 0; 753 return 0;
diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c
index a45e02367321..58c4dd75bfa1 100644
--- a/drivers/media/pci/tw68/tw68-video.c
+++ b/drivers/media/pci/tw68/tw68-video.c
@@ -279,9 +279,8 @@ static int tw68_set_scale(struct tw68_dev *dev, unsigned int width,
279 height /= 2; /* we must set for 1-frame */ 279 height /= 2; /* we must set for 1-frame */
280 280
281 pr_debug("%s: width=%d, height=%d, both=%d\n" 281 pr_debug("%s: width=%d, height=%d, both=%d\n"
282 " tvnorm h_delay=%d, h_start=%d, h_stop=%d, " 282 " tvnorm h_delay=%d, h_start=%d, h_stop=%d, v_delay=%d, v_start=%d, v_stop=%d\n",
283 "v_delay=%d, v_start=%d, v_stop=%d\n" , __func__, 283 __func__, width, height, V4L2_FIELD_HAS_BOTH(field),
284 width, height, V4L2_FIELD_HAS_BOTH(field),
285 norm->h_delay, norm->h_start, norm->h_stop, 284 norm->h_delay, norm->h_start, norm->h_stop,
286 norm->v_delay, norm->video_v_start, 285 norm->v_delay, norm->video_v_start,
287 norm->video_v_stop); 286 norm->video_v_stop);
@@ -309,16 +308,15 @@ static int tw68_set_scale(struct tw68_dev *dev, unsigned int width,
309 V4L2_FIELD_HAS_TOP(field) ? "T" : "", 308 V4L2_FIELD_HAS_TOP(field) ? "T" : "",
310 V4L2_FIELD_HAS_BOTTOM(field) ? "B" : "", 309 V4L2_FIELD_HAS_BOTTOM(field) ? "B" : "",
311 v4l2_norm_to_name(dev->tvnorm->id)); 310 v4l2_norm_to_name(dev->tvnorm->id));
312 pr_debug("%s: hactive=%d, hdelay=%d, hscale=%d; " 311 pr_debug("%s: hactive=%d, hdelay=%d, hscale=%d; vactive=%d, vdelay=%d, vscale=%d\n",
313 "vactive=%d, vdelay=%d, vscale=%d\n", __func__, 312 __func__,
314 hactive, hdelay, hscale, vactive, vdelay, vscale); 313 hactive, hdelay, hscale, vactive, vdelay, vscale);
315 314
316 comb = ((vdelay & 0x300) >> 2) | 315 comb = ((vdelay & 0x300) >> 2) |
317 ((vactive & 0x300) >> 4) | 316 ((vactive & 0x300) >> 4) |
318 ((hdelay & 0x300) >> 6) | 317 ((hdelay & 0x300) >> 6) |
319 ((hactive & 0x300) >> 8); 318 ((hactive & 0x300) >> 8);
320 pr_debug("%s: setting CROP_HI=%02x, VDELAY_LO=%02x, " 319 pr_debug("%s: setting CROP_HI=%02x, VDELAY_LO=%02x, VACTIVE_LO=%02x, HDELAY_LO=%02x, HACTIVE_LO=%02x\n",
321 "VACTIVE_LO=%02x, HDELAY_LO=%02x, HACTIVE_LO=%02x\n",
322 __func__, comb, vdelay, vactive, hdelay, hactive); 320 __func__, comb, vdelay, vactive, hdelay, hactive);
323 tw_writeb(TW68_CROP_HI, comb); 321 tw_writeb(TW68_CROP_HI, comb);
324 tw_writeb(TW68_VDELAY_LO, vdelay & 0xff); 322 tw_writeb(TW68_VDELAY_LO, vdelay & 0xff);
@@ -327,8 +325,8 @@ static int tw68_set_scale(struct tw68_dev *dev, unsigned int width,
327 tw_writeb(TW68_HACTIVE_LO, hactive & 0xff); 325 tw_writeb(TW68_HACTIVE_LO, hactive & 0xff);
328 326
329 comb = ((vscale & 0xf00) >> 4) | ((hscale & 0xf00) >> 8); 327 comb = ((vscale & 0xf00) >> 4) | ((hscale & 0xf00) >> 8);
330 pr_debug("%s: setting SCALE_HI=%02x, VSCALE_LO=%02x, " 328 pr_debug("%s: setting SCALE_HI=%02x, VSCALE_LO=%02x, HSCALE_LO=%02x\n",
331 "HSCALE_LO=%02x\n", __func__, comb, vscale, hscale); 329 __func__, comb, vscale, hscale);
332 tw_writeb(TW68_SCALE_HI, comb); 330 tw_writeb(TW68_SCALE_HI, comb);
333 tw_writeb(TW68_VSCALE_LO, vscale); 331 tw_writeb(TW68_VSCALE_LO, vscale);
334 tw_writeb(TW68_HSCALE_LO, hscale); 332 tw_writeb(TW68_HSCALE_LO, hscale);
diff --git a/drivers/media/pci/zoran/zoran_device.c b/drivers/media/pci/zoran/zoran_device.c
index 4d47ddac97dc..35b552c178da 100644
--- a/drivers/media/pci/zoran/zoran_device.c
+++ b/drivers/media/pci/zoran/zoran_device.c
@@ -173,12 +173,8 @@ dump_guests (struct zoran *zr)
173 guest[i] = post_office_read(zr, i, 0); 173 guest[i] = post_office_read(zr, i, 0);
174 } 174 }
175 175
176 printk(KERN_INFO "%s: Guests:", ZR_DEVNAME(zr)); 176 printk(KERN_INFO "%s: Guests: %*ph\n",
177 177 ZR_DEVNAME(zr), 8, guest);
178 for (i = 1; i < 8; i++) {
179 printk(" 0x%02x", guest[i]);
180 }
181 printk("\n");
182 } 178 }
183} 179}
184 180
@@ -216,12 +212,9 @@ detect_guest_activity (struct zoran *zr)
216 if (j >= 8) 212 if (j >= 8)
217 break; 213 break;
218 } 214 }
219 printk(KERN_INFO "%s: Guests:", ZR_DEVNAME(zr));
220 215
221 for (i = 1; i < 8; i++) { 216 printk(KERN_INFO "%s: Guests: %*ph\n", ZR_DEVNAME(zr), 8, guest0);
222 printk(" 0x%02x", guest0[i]); 217
223 }
224 printk("\n");
225 if (j == 0) { 218 if (j == 0) {
226 printk(KERN_INFO "%s: No activity detected.\n", ZR_DEVNAME(zr)); 219 printk(KERN_INFO "%s: No activity detected.\n", ZR_DEVNAME(zr));
227 return; 220 return;
@@ -822,39 +815,39 @@ print_interrupts (struct zoran *zr)
822 815
823 printk(KERN_INFO "%s: interrupts received:", ZR_DEVNAME(zr)); 816 printk(KERN_INFO "%s: interrupts received:", ZR_DEVNAME(zr));
824 if ((res = zr->field_counter) < -1 || res > 1) { 817 if ((res = zr->field_counter) < -1 || res > 1) {
825 printk(" FD:%d", res); 818 printk(KERN_CONT " FD:%d", res);
826 } 819 }
827 if ((res = zr->intr_counter_GIRQ1) != 0) { 820 if ((res = zr->intr_counter_GIRQ1) != 0) {
828 printk(" GIRQ1:%d", res); 821 printk(KERN_CONT " GIRQ1:%d", res);
829 noerr++; 822 noerr++;
830 } 823 }
831 if ((res = zr->intr_counter_GIRQ0) != 0) { 824 if ((res = zr->intr_counter_GIRQ0) != 0) {
832 printk(" GIRQ0:%d", res); 825 printk(KERN_CONT " GIRQ0:%d", res);
833 noerr++; 826 noerr++;
834 } 827 }
835 if ((res = zr->intr_counter_CodRepIRQ) != 0) { 828 if ((res = zr->intr_counter_CodRepIRQ) != 0) {
836 printk(" CodRepIRQ:%d", res); 829 printk(KERN_CONT " CodRepIRQ:%d", res);
837 noerr++; 830 noerr++;
838 } 831 }
839 if ((res = zr->intr_counter_JPEGRepIRQ) != 0) { 832 if ((res = zr->intr_counter_JPEGRepIRQ) != 0) {
840 printk(" JPEGRepIRQ:%d", res); 833 printk(KERN_CONT " JPEGRepIRQ:%d", res);
841 noerr++; 834 noerr++;
842 } 835 }
843 if (zr->JPEG_max_missed) { 836 if (zr->JPEG_max_missed) {
844 printk(" JPEG delays: max=%d min=%d", zr->JPEG_max_missed, 837 printk(KERN_CONT " JPEG delays: max=%d min=%d", zr->JPEG_max_missed,
845 zr->JPEG_min_missed); 838 zr->JPEG_min_missed);
846 } 839 }
847 if (zr->END_event_missed) { 840 if (zr->END_event_missed) {
848 printk(" ENDs missed: %d", zr->END_event_missed); 841 printk(KERN_CONT " ENDs missed: %d", zr->END_event_missed);
849 } 842 }
850 //if (zr->jpg_queued_num) { 843 //if (zr->jpg_queued_num) {
851 printk(" queue_state=%ld/%ld/%ld/%ld", zr->jpg_que_tail, 844 printk(KERN_CONT " queue_state=%ld/%ld/%ld/%ld", zr->jpg_que_tail,
852 zr->jpg_dma_tail, zr->jpg_dma_head, zr->jpg_que_head); 845 zr->jpg_dma_tail, zr->jpg_dma_head, zr->jpg_que_head);
853 //} 846 //}
854 if (!noerr) { 847 if (!noerr) {
855 printk(": no interrupts detected."); 848 printk(KERN_CONT ": no interrupts detected.");
856 } 849 }
857 printk("\n"); 850 printk(KERN_CONT "\n");
858} 851}
859 852
860void 853void
diff --git a/drivers/media/pci/zoran/zoran_driver.c b/drivers/media/pci/zoran/zoran_driver.c
index d6b631add216..2170e174c335 100644
--- a/drivers/media/pci/zoran/zoran_driver.c
+++ b/drivers/media/pci/zoran/zoran_driver.c
@@ -1488,7 +1488,7 @@ zoran_set_input (struct zoran *zr,
1488 if (input < 0 || input >= zr->card.inputs) { 1488 if (input < 0 || input >= zr->card.inputs) {
1489 dprintk(1, 1489 dprintk(1,
1490 KERN_ERR 1490 KERN_ERR
1491 "%s: %s - unnsupported input %d\n", 1491 "%s: %s - unsupported input %d\n",
1492 ZR_DEVNAME(zr), __func__, input); 1492 ZR_DEVNAME(zr), __func__, input);
1493 return -EINVAL; 1493 return -EINVAL;
1494 } 1494 }
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index ce4a96fccc43..d944421e392d 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -93,7 +93,7 @@ config VIDEO_OMAP3_DEBUG
93 93
94config VIDEO_PXA27x 94config VIDEO_PXA27x
95 tristate "PXA27x Quick Capture Interface driver" 95 tristate "PXA27x Quick Capture Interface driver"
96 depends on VIDEO_DEV && HAS_DMA 96 depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
97 depends on PXA27x || COMPILE_TEST 97 depends on PXA27x || COMPILE_TEST
98 select VIDEOBUF2_DMA_SG 98 select VIDEOBUF2_DMA_SG
99 select SG_SPLIT 99 select SG_SPLIT
@@ -175,6 +175,23 @@ config VIDEO_MEDIATEK_VPU
175 To compile this driver as a module, choose M here: the 175 To compile this driver as a module, choose M here: the
176 module will be called mtk-vpu. 176 module will be called mtk-vpu.
177 177
178config VIDEO_MEDIATEK_MDP
179 tristate "Mediatek MDP driver"
180 depends on MTK_IOMMU || COMPILE_TEST
181 depends on VIDEO_DEV && VIDEO_V4L2
182 depends on ARCH_MEDIATEK || COMPILE_TEST
183 depends on HAS_DMA
184 select VIDEOBUF2_DMA_CONTIG
185 select V4L2_MEM2MEM_DEV
186 select VIDEO_MEDIATEK_VPU
187 default n
188 ---help---
189 It is a v4l2 driver and present in Mediatek MT8173 SoCs.
190 The driver supports for scaling and color space conversion.
191
192 To compile this driver as a module, choose M here: the
193 module will be called mtk-mdp.
194
178config VIDEO_MEDIATEK_VCODEC 195config VIDEO_MEDIATEK_VCODEC
179 tristate "Mediatek Video Codec driver" 196 tristate "Mediatek Video Codec driver"
180 depends on MTK_IOMMU || COMPILE_TEST 197 depends on MTK_IOMMU || COMPILE_TEST
@@ -249,7 +266,7 @@ config VIDEO_MX2_EMMAPRP
249config VIDEO_SAMSUNG_EXYNOS_GSC 266config VIDEO_SAMSUNG_EXYNOS_GSC
250 tristate "Samsung Exynos G-Scaler driver" 267 tristate "Samsung Exynos G-Scaler driver"
251 depends on VIDEO_DEV && VIDEO_V4L2 268 depends on VIDEO_DEV && VIDEO_V4L2
252 depends on ARCH_EXYNOS5 || COMPILE_TEST 269 depends on ARCH_EXYNOS || COMPILE_TEST
253 depends on HAS_DMA 270 depends on HAS_DMA
254 select VIDEOBUF2_DMA_CONTIG 271 select VIDEOBUF2_DMA_CONTIG
255 select V4L2_MEM2MEM_DEV 272 select V4L2_MEM2MEM_DEV
@@ -290,6 +307,20 @@ config VIDEO_SH_VEU
290 Support for the Video Engine Unit (VEU) on SuperH and 307 Support for the Video Engine Unit (VEU) on SuperH and
291 SH-Mobile SoCs. 308 SH-Mobile SoCs.
292 309
310config VIDEO_RENESAS_FDP1
311 tristate "Renesas Fine Display Processor"
312 depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
313 depends on ARCH_SHMOBILE || COMPILE_TEST
314 depends on (!ARCH_RENESAS && !VIDEO_RENESAS_FCP) || VIDEO_RENESAS_FCP
315 select VIDEOBUF2_DMA_CONTIG
316 select V4L2_MEM2MEM_DEV
317 ---help---
318 This is a V4L2 driver for the Renesas Fine Display Processor
319 providing colour space conversion, and de-interlacing features.
320
321 To compile this driver as a module, choose M here: the module
322 will be called rcar_fdp1.
323
293config VIDEO_RENESAS_JPU 324config VIDEO_RENESAS_JPU
294 tristate "Renesas JPEG Processing Unit" 325 tristate "Renesas JPEG Processing Unit"
295 depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA 326 depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
@@ -334,6 +365,9 @@ config VIDEO_TI_VPE
334 depends on HAS_DMA 365 depends on HAS_DMA
335 select VIDEOBUF2_DMA_CONTIG 366 select VIDEOBUF2_DMA_CONTIG
336 select V4L2_MEM2MEM_DEV 367 select V4L2_MEM2MEM_DEV
368 select VIDEO_TI_VPDMA
369 select VIDEO_TI_SC
370 select VIDEO_TI_CSC
337 default n 371 default n
338 ---help--- 372 ---help---
339 Support for the TI VPE(Video Processing Engine) block 373 Support for the TI VPE(Video Processing Engine) block
@@ -347,6 +381,17 @@ config VIDEO_TI_VPE_DEBUG
347 381
348endif # V4L_MEM2MEM_DRIVERS 382endif # V4L_MEM2MEM_DRIVERS
349 383
384# TI VIDEO PORT Helper Modules
385# These will be selected by VPE and VIP
386config VIDEO_TI_VPDMA
387 tristate
388
389config VIDEO_TI_SC
390 tristate
391
392config VIDEO_TI_CSC
393 tristate
394
350menuconfig V4L_TEST_DRIVERS 395menuconfig V4L_TEST_DRIVERS
351 bool "Media test drivers" 396 bool "Media test drivers"
352 depends on MEDIA_CAMERA_SUPPORT 397 depends on MEDIA_CAMERA_SUPPORT
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 40b18d12726e..5b3cb271d2b8 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -48,6 +48,7 @@ obj-$(CONFIG_VIDEO_SH_VOU) += sh_vou.o
48obj-$(CONFIG_SOC_CAMERA) += soc_camera/ 48obj-$(CONFIG_SOC_CAMERA) += soc_camera/
49 49
50obj-$(CONFIG_VIDEO_RENESAS_FCP) += rcar-fcp.o 50obj-$(CONFIG_VIDEO_RENESAS_FCP) += rcar-fcp.o
51obj-$(CONFIG_VIDEO_RENESAS_FDP1) += rcar_fdp1.o
51obj-$(CONFIG_VIDEO_RENESAS_JPU) += rcar_jpu.o 52obj-$(CONFIG_VIDEO_RENESAS_JPU) += rcar_jpu.o
52obj-$(CONFIG_VIDEO_RENESAS_VSP1) += vsp1/ 53obj-$(CONFIG_VIDEO_RENESAS_VSP1) += vsp1/
53 54
@@ -66,3 +67,5 @@ ccflags-y += -I$(srctree)/drivers/media/i2c
66obj-$(CONFIG_VIDEO_MEDIATEK_VPU) += mtk-vpu/ 67obj-$(CONFIG_VIDEO_MEDIATEK_VPU) += mtk-vpu/
67 68
68obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec/ 69obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec/
70
71obj-$(CONFIG_VIDEO_MEDIATEK_MDP) += mtk-mdp/
diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c
index ccfe13b7d3f8..fa68fe912c95 100644
--- a/drivers/media/platform/atmel/atmel-isc.c
+++ b/drivers/media/platform/atmel/atmel-isc.c
@@ -617,7 +617,13 @@ static void isc_buffer_queue(struct vb2_buffer *vb)
617 unsigned long flags; 617 unsigned long flags;
618 618
619 spin_lock_irqsave(&isc->dma_queue_lock, flags); 619 spin_lock_irqsave(&isc->dma_queue_lock, flags);
620 list_add_tail(&buf->list, &isc->dma_queue); 620 if (!isc->cur_frm && list_empty(&isc->dma_queue) &&
621 vb2_is_streaming(vb->vb2_queue)) {
622 isc->cur_frm = buf;
623 isc_start_dma(isc->regmap, isc->cur_frm,
624 isc->current_fmt->reg_dctrl_dview);
625 } else
626 list_add_tail(&buf->list, &isc->dma_queue);
621 spin_unlock_irqrestore(&isc->dma_queue_lock, flags); 627 spin_unlock_irqrestore(&isc->dma_queue_lock, flags);
622} 628}
623 629
@@ -1418,6 +1424,7 @@ static int atmel_isc_probe(struct platform_device *pdev)
1418 1424
1419 if (list_empty(&isc->subdev_entities)) { 1425 if (list_empty(&isc->subdev_entities)) {
1420 dev_err(dev, "no subdev found\n"); 1426 dev_err(dev, "no subdev found\n");
1427 ret = -ENODEV;
1421 goto unregister_v4l2_device; 1428 goto unregister_v4l2_device;
1422 } 1429 }
1423 1430
diff --git a/drivers/media/platform/blackfin/bfin_capture.c b/drivers/media/platform/blackfin/bfin_capture.c
index 8eb03397d736..2e6edc09b58f 100644
--- a/drivers/media/platform/blackfin/bfin_capture.c
+++ b/drivers/media/platform/blackfin/bfin_capture.c
@@ -169,7 +169,7 @@ static int bcap_init_sensor_formats(struct bcap_device *bcap_dev)
169 if (!num_formats) 169 if (!num_formats)
170 return -ENXIO; 170 return -ENXIO;
171 171
172 sf = kzalloc(num_formats * sizeof(*sf), GFP_KERNEL); 172 sf = kcalloc(num_formats, sizeof(*sf), GFP_KERNEL);
173 if (!sf) 173 if (!sf)
174 return -ENOMEM; 174 return -ENOMEM;
175 175
@@ -802,10 +802,8 @@ static int bcap_probe(struct platform_device *pdev)
802 } 802 }
803 803
804 bcap_dev = kzalloc(sizeof(*bcap_dev), GFP_KERNEL); 804 bcap_dev = kzalloc(sizeof(*bcap_dev), GFP_KERNEL);
805 if (!bcap_dev) { 805 if (!bcap_dev)
806 v4l2_err(pdev->dev.driver, "Unable to alloc bcap_dev\n");
807 return -ENOMEM; 806 return -ENOMEM;
808 }
809 807
810 bcap_dev->cfg = config; 808 bcap_dev->cfg = config;
811 809
diff --git a/drivers/media/platform/blackfin/ppi.c b/drivers/media/platform/blackfin/ppi.c
index cff63e511e6d..b8f3d9fa66e9 100644
--- a/drivers/media/platform/blackfin/ppi.c
+++ b/drivers/media/platform/blackfin/ppi.c
@@ -214,6 +214,8 @@ static int ppi_set_params(struct ppi_if *ppi, struct ppi_params *params)
214 if (params->dlen > 24 || params->dlen <= 0) 214 if (params->dlen > 24 || params->dlen <= 0)
215 return -EINVAL; 215 return -EINVAL;
216 pctrl = devm_pinctrl_get(ppi->dev); 216 pctrl = devm_pinctrl_get(ppi->dev);
217 if (IS_ERR(pctrl))
218 return PTR_ERR(pctrl);
217 pstate = pinctrl_lookup_state(pctrl, 219 pstate = pinctrl_lookup_state(pctrl,
218 pin_state[(params->dlen + 7) / 8 - 1]); 220 pin_state[(params->dlen + 7) / 8 - 1]);
219 if (pinctrl_select_state(pctrl, pstate)) 221 if (pinctrl_select_state(pctrl, pstate))
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index c39718a63e5e..9e6bdafa16f5 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -2295,8 +2295,13 @@ static int coda_probe(struct platform_device *pdev)
2295 pm_runtime_set_active(&pdev->dev); 2295 pm_runtime_set_active(&pdev->dev);
2296 pm_runtime_enable(&pdev->dev); 2296 pm_runtime_enable(&pdev->dev);
2297 2297
2298 return coda_firmware_request(dev); 2298 ret = coda_firmware_request(dev);
2299 if (ret)
2300 goto err_alloc_workqueue;
2301 return 0;
2299 2302
2303err_alloc_workqueue:
2304 destroy_workqueue(dev->workqueue);
2300err_v4l2_register: 2305err_v4l2_register:
2301 v4l2_device_unregister(&dev->v4l2_dev); 2306 v4l2_device_unregister(&dev->v4l2_dev);
2302 return ret; 2307 return ret;
diff --git a/drivers/media/platform/coda/coda-h264.c b/drivers/media/platform/coda/coda-h264.c
index 456773af1f1d..09dfcca7cc50 100644
--- a/drivers/media/platform/coda/coda-h264.c
+++ b/drivers/media/platform/coda/coda-h264.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/string.h> 15#include <linux/string.h>
16#include <coda.h>
16 17
17static const u8 coda_filler_nal[14] = { 0x00, 0x00, 0x00, 0x01, 0x0c, 0xff, 18static const u8 coda_filler_nal[14] = { 0x00, 0x00, 0x00, 0x01, 0x0c, 0xff,
18 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80 }; 19 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80 };
diff --git a/drivers/media/platform/davinci/dm355_ccdc.c b/drivers/media/platform/davinci/dm355_ccdc.c
index c90b9a4f0c24..65c2973167c6 100644
--- a/drivers/media/platform/davinci/dm355_ccdc.c
+++ b/drivers/media/platform/davinci/dm355_ccdc.c
@@ -334,8 +334,8 @@ static int ccdc_set_params(void __user *params)
334 334
335 x = copy_from_user(&ccdc_raw_params, params, sizeof(ccdc_raw_params)); 335 x = copy_from_user(&ccdc_raw_params, params, sizeof(ccdc_raw_params));
336 if (x) { 336 if (x) {
337 dev_dbg(ccdc_cfg.dev, "ccdc_set_params: error in copying ccdc" 337 dev_dbg(ccdc_cfg.dev, "ccdc_set_params: error in copying ccdcparams, %d\n",
338 "params, %d\n", x); 338 x);
339 return -EFAULT; 339 return -EFAULT;
340 } 340 }
341 341
diff --git a/drivers/media/platform/davinci/dm644x_ccdc.c b/drivers/media/platform/davinci/dm644x_ccdc.c
index 6fba32bec974..c7523a7e0594 100644
--- a/drivers/media/platform/davinci/dm644x_ccdc.c
+++ b/drivers/media/platform/davinci/dm644x_ccdc.c
@@ -354,8 +354,8 @@ static int ccdc_set_params(void __user *params)
354 354
355 x = copy_from_user(&ccdc_raw_params, params, sizeof(ccdc_raw_params)); 355 x = copy_from_user(&ccdc_raw_params, params, sizeof(ccdc_raw_params));
356 if (x) { 356 if (x) {
357 dev_dbg(ccdc_cfg.dev, "ccdc_set_params: error in copying" 357 dev_dbg(ccdc_cfg.dev, "ccdc_set_params: error in copyingccdc params, %d\n",
358 "ccdc params, %d\n", x); 358 x);
359 return -EFAULT; 359 return -EFAULT;
360 } 360 }
361 361
diff --git a/drivers/media/platform/davinci/vpbe.c b/drivers/media/platform/davinci/vpbe.c
index 9a6c2cc38acb..8c8cbeb7d90f 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -107,7 +107,7 @@ static int vpbe_find_encoder_sd_index(struct vpbe_config *cfg,
107static int vpbe_g_cropcap(struct vpbe_device *vpbe_dev, 107static int vpbe_g_cropcap(struct vpbe_device *vpbe_dev,
108 struct v4l2_cropcap *cropcap) 108 struct v4l2_cropcap *cropcap)
109{ 109{
110 if (NULL == cropcap) 110 if (!cropcap)
111 return -EINVAL; 111 return -EINVAL;
112 cropcap->bounds.left = 0; 112 cropcap->bounds.left = 0;
113 cropcap->bounds.top = 0; 113 cropcap->bounds.top = 0;
@@ -149,7 +149,7 @@ static int vpbe_get_mode_info(struct vpbe_device *vpbe_dev, char *mode,
149 int curr_output = output_index; 149 int curr_output = output_index;
150 int i; 150 int i;
151 151
152 if (NULL == mode) 152 if (!mode)
153 return -EINVAL; 153 return -EINVAL;
154 154
155 for (i = 0; i < cfg->outputs[curr_output].num_modes; i++) { 155 for (i = 0; i < cfg->outputs[curr_output].num_modes; i++) {
@@ -166,7 +166,7 @@ static int vpbe_get_mode_info(struct vpbe_device *vpbe_dev, char *mode,
166static int vpbe_get_current_mode_info(struct vpbe_device *vpbe_dev, 166static int vpbe_get_current_mode_info(struct vpbe_device *vpbe_dev,
167 struct vpbe_enc_mode_info *mode_info) 167 struct vpbe_enc_mode_info *mode_info)
168{ 168{
169 if (NULL == mode_info) 169 if (!mode_info)
170 return -EINVAL; 170 return -EINVAL;
171 171
172 *mode_info = vpbe_dev->current_timings; 172 *mode_info = vpbe_dev->current_timings;
@@ -227,10 +227,9 @@ static int vpbe_set_output(struct vpbe_device *vpbe_dev, int index)
227 vpbe_current_encoder_info(vpbe_dev); 227 vpbe_current_encoder_info(vpbe_dev);
228 struct vpbe_config *cfg = vpbe_dev->cfg; 228 struct vpbe_config *cfg = vpbe_dev->cfg;
229 struct venc_platform_data *venc_device = vpbe_dev->venc_device; 229 struct venc_platform_data *venc_device = vpbe_dev->venc_device;
230 u32 if_params;
231 int enc_out_index; 230 int enc_out_index;
232 int sd_index; 231 int sd_index;
233 int ret = 0; 232 int ret;
234 233
235 if (index >= cfg->num_outputs) 234 if (index >= cfg->num_outputs)
236 return -EINVAL; 235 return -EINVAL;
@@ -254,20 +253,19 @@ static int vpbe_set_output(struct vpbe_device *vpbe_dev, int index)
254 sd_index = vpbe_find_encoder_sd_index(cfg, index); 253 sd_index = vpbe_find_encoder_sd_index(cfg, index);
255 if (sd_index < 0) { 254 if (sd_index < 0) {
256 ret = -EINVAL; 255 ret = -EINVAL;
257 goto out; 256 goto unlock;
258 } 257 }
259 258
260 if_params = cfg->outputs[index].if_params; 259 ret = venc_device->setup_if_config(cfg->outputs[index].if_params);
261 venc_device->setup_if_config(if_params);
262 if (ret) 260 if (ret)
263 goto out; 261 goto unlock;
264 } 262 }
265 263
266 /* Set output at the encoder */ 264 /* Set output at the encoder */
267 ret = v4l2_subdev_call(vpbe_dev->encoders[sd_index], video, 265 ret = v4l2_subdev_call(vpbe_dev->encoders[sd_index], video,
268 s_routing, 0, enc_out_index, 0); 266 s_routing, 0, enc_out_index, 0);
269 if (ret) 267 if (ret)
270 goto out; 268 goto unlock;
271 269
272 /* 270 /*
273 * It is assumed that venc or extenal encoder will set a default 271 * It is assumed that venc or extenal encoder will set a default
@@ -289,7 +287,7 @@ static int vpbe_set_output(struct vpbe_device *vpbe_dev, int index)
289 vpbe_dev->current_sd_index = sd_index; 287 vpbe_dev->current_sd_index = sd_index;
290 vpbe_dev->current_out_index = index; 288 vpbe_dev->current_out_index = index;
291 } 289 }
292out: 290unlock:
293 mutex_unlock(&vpbe_dev->lock); 291 mutex_unlock(&vpbe_dev->lock);
294 return ret; 292 return ret;
295} 293}
@@ -297,19 +295,19 @@ out:
297static int vpbe_set_default_output(struct vpbe_device *vpbe_dev) 295static int vpbe_set_default_output(struct vpbe_device *vpbe_dev)
298{ 296{
299 struct vpbe_config *cfg = vpbe_dev->cfg; 297 struct vpbe_config *cfg = vpbe_dev->cfg;
300 int ret = 0;
301 int i; 298 int i;
302 299
303 for (i = 0; i < cfg->num_outputs; i++) { 300 for (i = 0; i < cfg->num_outputs; i++) {
304 if (!strcmp(def_output, 301 if (!strcmp(def_output,
305 cfg->outputs[i].output.name)) { 302 cfg->outputs[i].output.name)) {
306 ret = vpbe_set_output(vpbe_dev, i); 303 int ret = vpbe_set_output(vpbe_dev, i);
304
307 if (!ret) 305 if (!ret)
308 vpbe_dev->current_out_index = i; 306 vpbe_dev->current_out_index = i;
309 return ret; 307 return ret;
310 } 308 }
311 } 309 }
312 return ret; 310 return 0;
313} 311}
314 312
315/** 313/**
@@ -356,7 +354,7 @@ static int vpbe_s_dv_timings(struct vpbe_device *vpbe_dev,
356 354
357 ret = v4l2_subdev_call(vpbe_dev->encoders[sd_index], video, 355 ret = v4l2_subdev_call(vpbe_dev->encoders[sd_index], video,
358 s_dv_timings, dv_timings); 356 s_dv_timings, dv_timings);
359 if (!ret && (vpbe_dev->amp != NULL)) { 357 if (!ret && vpbe_dev->amp) {
360 /* Call amplifier subdevice */ 358 /* Call amplifier subdevice */
361 ret = v4l2_subdev_call(vpbe_dev->amp, video, 359 ret = v4l2_subdev_call(vpbe_dev->amp, video,
362 s_dv_timings, dv_timings); 360 s_dv_timings, dv_timings);
@@ -509,10 +507,9 @@ static int vpbe_set_mode(struct vpbe_device *vpbe_dev,
509 struct v4l2_dv_timings dv_timings; 507 struct v4l2_dv_timings dv_timings;
510 struct osd_state *osd_device; 508 struct osd_state *osd_device;
511 int out_index = vpbe_dev->current_out_index; 509 int out_index = vpbe_dev->current_out_index;
512 int ret = 0;
513 int i; 510 int i;
514 511
515 if ((NULL == mode_info) || (NULL == mode_info->name)) 512 if (!mode_info || !mode_info->name)
516 return -EINVAL; 513 return -EINVAL;
517 514
518 for (i = 0; i < cfg->outputs[out_index].num_modes; i++) { 515 for (i = 0; i < cfg->outputs[out_index].num_modes; i++) {
@@ -536,7 +533,7 @@ static int vpbe_set_mode(struct vpbe_device *vpbe_dev,
536 } 533 }
537 534
538 /* Only custom timing should reach here */ 535 /* Only custom timing should reach here */
539 if (preset_mode == NULL) 536 if (!preset_mode)
540 return -EINVAL; 537 return -EINVAL;
541 538
542 mutex_lock(&vpbe_dev->lock); 539 mutex_lock(&vpbe_dev->lock);
@@ -549,8 +546,7 @@ static int vpbe_set_mode(struct vpbe_device *vpbe_dev,
549 vpbe_dev->current_timings.upper_margin); 546 vpbe_dev->current_timings.upper_margin);
550 547
551 mutex_unlock(&vpbe_dev->lock); 548 mutex_unlock(&vpbe_dev->lock);
552 549 return 0;
553 return ret;
554} 550}
555 551
556static int vpbe_set_default_mode(struct vpbe_device *vpbe_dev) 552static int vpbe_set_default_mode(struct vpbe_device *vpbe_dev)
@@ -570,9 +566,9 @@ static int platform_device_get(struct device *dev, void *data)
570 struct platform_device *pdev = to_platform_device(dev); 566 struct platform_device *pdev = to_platform_device(dev);
571 struct vpbe_device *vpbe_dev = data; 567 struct vpbe_device *vpbe_dev = data;
572 568
573 if (strstr(pdev->name, "vpbe-osd") != NULL) 569 if (strstr(pdev->name, "vpbe-osd"))
574 vpbe_dev->osd_device = platform_get_drvdata(pdev); 570 vpbe_dev->osd_device = platform_get_drvdata(pdev);
575 if (strstr(pdev->name, "vpbe-venc") != NULL) 571 if (strstr(pdev->name, "vpbe-venc"))
576 vpbe_dev->venc_device = dev_get_platdata(&pdev->dev); 572 vpbe_dev->venc_device = dev_get_platdata(&pdev->dev);
577 573
578 return 0; 574 return 0;
@@ -606,7 +602,7 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
606 * from the platform device by iteration of platform drivers and 602 * from the platform device by iteration of platform drivers and
607 * matching with device name 603 * matching with device name
608 */ 604 */
609 if (NULL == vpbe_dev || NULL == dev) { 605 if (!vpbe_dev || !dev) {
610 printk(KERN_ERR "Null device pointers.\n"); 606 printk(KERN_ERR "Null device pointers.\n");
611 return -ENODEV; 607 return -ENODEV;
612 } 608 }
@@ -652,7 +648,7 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
652 vpbe_dev->venc = venc_sub_dev_init(&vpbe_dev->v4l2_dev, 648 vpbe_dev->venc = venc_sub_dev_init(&vpbe_dev->v4l2_dev,
653 vpbe_dev->cfg->venc.module_name); 649 vpbe_dev->cfg->venc.module_name);
654 /* register venc sub device */ 650 /* register venc sub device */
655 if (vpbe_dev->venc == NULL) { 651 if (!vpbe_dev->venc) {
656 v4l2_err(&vpbe_dev->v4l2_dev, 652 v4l2_err(&vpbe_dev->v4l2_dev,
657 "vpbe unable to init venc sub device\n"); 653 "vpbe unable to init venc sub device\n");
658 ret = -ENODEV; 654 ret = -ENODEV;
@@ -660,8 +656,7 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
660 } 656 }
661 /* initialize osd device */ 657 /* initialize osd device */
662 osd_device = vpbe_dev->osd_device; 658 osd_device = vpbe_dev->osd_device;
663 659 if (osd_device->ops.initialize) {
664 if (NULL != osd_device->ops.initialize) {
665 err = osd_device->ops.initialize(osd_device); 660 err = osd_device->ops.initialize(osd_device);
666 if (err) { 661 if (err) {
667 v4l2_err(&vpbe_dev->v4l2_dev, 662 v4l2_err(&vpbe_dev->v4l2_dev,
@@ -676,12 +671,10 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
676 * store venc sd index. 671 * store venc sd index.
677 */ 672 */
678 num_encoders = vpbe_dev->cfg->num_ext_encoders + 1; 673 num_encoders = vpbe_dev->cfg->num_ext_encoders + 1;
679 vpbe_dev->encoders = kmalloc( 674 vpbe_dev->encoders = kmalloc_array(num_encoders,
680 sizeof(struct v4l2_subdev *)*num_encoders, 675 sizeof(*vpbe_dev->encoders),
681 GFP_KERNEL); 676 GFP_KERNEL);
682 if (NULL == vpbe_dev->encoders) { 677 if (!vpbe_dev->encoders) {
683 v4l2_err(&vpbe_dev->v4l2_dev,
684 "unable to allocate memory for encoders sub devices");
685 ret = -ENOMEM; 678 ret = -ENOMEM;
686 goto fail_dev_unregister; 679 goto fail_dev_unregister;
687 } 680 }
@@ -705,19 +698,17 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
705 "v4l2 sub device %s registered\n", 698 "v4l2 sub device %s registered\n",
706 enc_info->module_name); 699 enc_info->module_name);
707 else { 700 else {
708 v4l2_err(&vpbe_dev->v4l2_dev, "encoder %s" 701 v4l2_err(&vpbe_dev->v4l2_dev, "encoder %s failed to register",
709 " failed to register",
710 enc_info->module_name); 702 enc_info->module_name);
711 ret = -ENODEV; 703 ret = -ENODEV;
712 goto fail_kfree_encoders; 704 goto fail_kfree_encoders;
713 } 705 }
714 } else 706 } else
715 v4l2_warn(&vpbe_dev->v4l2_dev, "non-i2c encoders" 707 v4l2_warn(&vpbe_dev->v4l2_dev, "non-i2c encoders currently not supported");
716 " currently not supported");
717 } 708 }
718 /* Add amplifier subdevice for dm365 */ 709 /* Add amplifier subdevice for dm365 */
719 if ((strcmp(vpbe_dev->cfg->module_name, "dm365-vpbe-display") == 0) && 710 if ((strcmp(vpbe_dev->cfg->module_name, "dm365-vpbe-display") == 0) &&
720 vpbe_dev->cfg->amp != NULL) { 711 vpbe_dev->cfg->amp) {
721 amp_info = vpbe_dev->cfg->amp; 712 amp_info = vpbe_dev->cfg->amp;
722 if (amp_info->is_i2c) { 713 if (amp_info->is_i2c) {
723 vpbe_dev->amp = v4l2_i2c_new_subdev_board( 714 vpbe_dev->amp = v4l2_i2c_new_subdev_board(
@@ -735,8 +726,7 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
735 amp_info->module_name); 726 amp_info->module_name);
736 } else { 727 } else {
737 vpbe_dev->amp = NULL; 728 vpbe_dev->amp = NULL;
738 v4l2_warn(&vpbe_dev->v4l2_dev, "non-i2c amplifiers" 729 v4l2_warn(&vpbe_dev->v4l2_dev, "non-i2c amplifiers currently not supported");
739 " currently not supported");
740 } 730 }
741 } else { 731 } else {
742 vpbe_dev->amp = NULL; 732 vpbe_dev->amp = NULL;
@@ -824,9 +814,8 @@ static int vpbe_probe(struct platform_device *pdev)
824{ 814{
825 struct vpbe_device *vpbe_dev; 815 struct vpbe_device *vpbe_dev;
826 struct vpbe_config *cfg; 816 struct vpbe_config *cfg;
827 int ret = -EINVAL;
828 817
829 if (pdev->dev.platform_data == NULL) { 818 if (!pdev->dev.platform_data) {
830 v4l2_err(pdev->dev.driver, "No platform data\n"); 819 v4l2_err(pdev->dev.driver, "No platform data\n");
831 return -ENODEV; 820 return -ENODEV;
832 } 821 }
@@ -835,17 +824,14 @@ static int vpbe_probe(struct platform_device *pdev)
835 if (!cfg->module_name[0] || 824 if (!cfg->module_name[0] ||
836 !cfg->osd.module_name[0] || 825 !cfg->osd.module_name[0] ||
837 !cfg->venc.module_name[0]) { 826 !cfg->venc.module_name[0]) {
838 v4l2_err(pdev->dev.driver, "vpbe display module names not" 827 v4l2_err(pdev->dev.driver, "vpbe display module names not defined\n");
839 " defined\n"); 828 return -EINVAL;
840 return ret;
841 } 829 }
842 830
843 vpbe_dev = kzalloc(sizeof(*vpbe_dev), GFP_KERNEL); 831 vpbe_dev = kzalloc(sizeof(*vpbe_dev), GFP_KERNEL);
844 if (vpbe_dev == NULL) { 832 if (!vpbe_dev)
845 v4l2_err(pdev->dev.driver, "Unable to allocate memory"
846 " for vpbe_device\n");
847 return -ENOMEM; 833 return -ENOMEM;
848 } 834
849 vpbe_dev->cfg = cfg; 835 vpbe_dev->cfg = cfg;
850 vpbe_dev->ops = vpbe_dev_ops; 836 vpbe_dev->ops = vpbe_dev_ops;
851 vpbe_dev->pdev = &pdev->dev; 837 vpbe_dev->pdev = &pdev->dev;
diff --git a/drivers/media/platform/davinci/vpfe_capture.c b/drivers/media/platform/davinci/vpfe_capture.c
index 6efb2f1631c4..ee1cd79739c8 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -229,7 +229,7 @@ int vpfe_register_ccdc_device(struct ccdc_hw_device *dev)
229 BUG_ON(!dev->hw_ops.getfid); 229 BUG_ON(!dev->hw_ops.getfid);
230 230
231 mutex_lock(&ccdc_lock); 231 mutex_lock(&ccdc_lock);
232 if (NULL == ccdc_cfg) { 232 if (!ccdc_cfg) {
233 /* 233 /*
234 * TODO. Will this ever happen? if so, we need to fix it. 234 * TODO. Will this ever happen? if so, we need to fix it.
235 * Proabably we need to add the request to a linked list and 235 * Proabably we need to add the request to a linked list and
@@ -265,7 +265,7 @@ EXPORT_SYMBOL(vpfe_register_ccdc_device);
265 */ 265 */
266void vpfe_unregister_ccdc_device(struct ccdc_hw_device *dev) 266void vpfe_unregister_ccdc_device(struct ccdc_hw_device *dev)
267{ 267{
268 if (NULL == dev) { 268 if (!dev) {
269 printk(KERN_ERR "invalid ccdc device ptr\n"); 269 printk(KERN_ERR "invalid ccdc device ptr\n");
270 return; 270 return;
271 } 271 }
@@ -281,7 +281,6 @@ void vpfe_unregister_ccdc_device(struct ccdc_hw_device *dev)
281 mutex_lock(&ccdc_lock); 281 mutex_lock(&ccdc_lock);
282 ccdc_dev = NULL; 282 ccdc_dev = NULL;
283 mutex_unlock(&ccdc_lock); 283 mutex_unlock(&ccdc_lock);
284 return;
285} 284}
286EXPORT_SYMBOL(vpfe_unregister_ccdc_device); 285EXPORT_SYMBOL(vpfe_unregister_ccdc_device);
287 286
@@ -384,7 +383,7 @@ static int vpfe_config_image_format(struct vpfe_device *vpfe_dev,
384 }; 383 };
385 struct v4l2_mbus_framefmt *mbus_fmt = &fmt.format; 384 struct v4l2_mbus_framefmt *mbus_fmt = &fmt.format;
386 struct v4l2_pix_format *pix = &vpfe_dev->fmt.fmt.pix; 385 struct v4l2_pix_format *pix = &vpfe_dev->fmt.fmt.pix;
387 int i, ret = 0; 386 int i, ret;
388 387
389 for (i = 0; i < ARRAY_SIZE(vpfe_standards); i++) { 388 for (i = 0; i < ARRAY_SIZE(vpfe_standards); i++) {
390 if (vpfe_standards[i].std_id & std_id) { 389 if (vpfe_standards[i].std_id & std_id) {
@@ -453,7 +452,7 @@ static int vpfe_config_image_format(struct vpfe_device *vpfe_dev,
453 452
454static int vpfe_initialize_device(struct vpfe_device *vpfe_dev) 453static int vpfe_initialize_device(struct vpfe_device *vpfe_dev)
455{ 454{
456 int ret = 0; 455 int ret;
457 456
458 /* set first input of current subdevice as the current input */ 457 /* set first input of current subdevice as the current input */
459 vpfe_dev->current_input = 0; 458 vpfe_dev->current_input = 0;
@@ -469,7 +468,7 @@ static int vpfe_initialize_device(struct vpfe_device *vpfe_dev)
469 468
470 /* now open the ccdc device to initialize it */ 469 /* now open the ccdc device to initialize it */
471 mutex_lock(&ccdc_lock); 470 mutex_lock(&ccdc_lock);
472 if (NULL == ccdc_dev) { 471 if (!ccdc_dev) {
473 v4l2_err(&vpfe_dev->v4l2_dev, "ccdc device not registered\n"); 472 v4l2_err(&vpfe_dev->v4l2_dev, "ccdc device not registered\n");
474 ret = -ENODEV; 473 ret = -ENODEV;
475 goto unlock; 474 goto unlock;
@@ -511,12 +510,10 @@ static int vpfe_open(struct file *file)
511 } 510 }
512 511
513 /* Allocate memory for the file handle object */ 512 /* Allocate memory for the file handle object */
514 fh = kmalloc(sizeof(struct vpfe_fh), GFP_KERNEL); 513 fh = kmalloc(sizeof(*fh), GFP_KERNEL);
515 if (NULL == fh) { 514 if (!fh)
516 v4l2_err(&vpfe_dev->v4l2_dev,
517 "unable to allocate memory for file handle object\n");
518 return -ENOMEM; 515 return -ENOMEM;
519 } 516
520 /* store pointer to fh in private_data member of file */ 517 /* store pointer to fh in private_data member of file */
521 file->private_data = fh; 518 file->private_data = fh;
522 fh->vpfe_dev = vpfe_dev; 519 fh->vpfe_dev = vpfe_dev;
@@ -584,7 +581,7 @@ static irqreturn_t vpfe_isr(int irq, void *dev_id)
584 goto clear_intr; 581 goto clear_intr;
585 582
586 /* only for 6446 this will be applicable */ 583 /* only for 6446 this will be applicable */
587 if (NULL != ccdc_dev->hw_ops.reset) 584 if (ccdc_dev->hw_ops.reset)
588 ccdc_dev->hw_ops.reset(); 585 ccdc_dev->hw_ops.reset();
589 586
590 if (field == V4L2_FIELD_NONE) { 587 if (field == V4L2_FIELD_NONE) {
@@ -617,9 +614,8 @@ static irqreturn_t vpfe_isr(int irq, void *dev_id)
617 * interleavely or separately in memory, reconfigure 614 * interleavely or separately in memory, reconfigure
618 * the CCDC memory address 615 * the CCDC memory address
619 */ 616 */
620 if (field == V4L2_FIELD_SEQ_TB) { 617 if (field == V4L2_FIELD_SEQ_TB)
621 vpfe_schedule_bottom_field(vpfe_dev); 618 vpfe_schedule_bottom_field(vpfe_dev);
622 }
623 goto clear_intr; 619 goto clear_intr;
624 } 620 }
625 /* 621 /*
@@ -824,7 +820,7 @@ static const struct vpfe_pixel_format *
824 int temp, found; 820 int temp, found;
825 821
826 vpfe_pix_fmt = vpfe_lookup_pix_format(pixfmt->pixelformat); 822 vpfe_pix_fmt = vpfe_lookup_pix_format(pixfmt->pixelformat);
827 if (NULL == vpfe_pix_fmt) { 823 if (!vpfe_pix_fmt) {
828 /* 824 /*
829 * use current pixel format in the vpfe device. We 825 * use current pixel format in the vpfe device. We
830 * will find this pix format in the table 826 * will find this pix format in the table
@@ -919,8 +915,7 @@ static const struct vpfe_pixel_format *
919 else 915 else
920 pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; 916 pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height;
921 917
922 v4l2_info(&vpfe_dev->v4l2_dev, "adjusted width = %d, height =" 918 v4l2_info(&vpfe_dev->v4l2_dev, "adjusted width = %d, height = %d, bpp = %d, bytesperline = %d, sizeimage = %d\n",
923 " %d, bpp = %d, bytesperline = %d, sizeimage = %d\n",
924 pixfmt->width, pixfmt->height, vpfe_pix_fmt->bpp, 919 pixfmt->width, pixfmt->height, vpfe_pix_fmt->bpp,
925 pixfmt->bytesperline, pixfmt->sizeimage); 920 pixfmt->bytesperline, pixfmt->sizeimage);
926 return vpfe_pix_fmt; 921 return vpfe_pix_fmt;
@@ -967,7 +962,7 @@ static int vpfe_enum_fmt_vid_cap(struct file *file, void *priv,
967 962
968 /* Fill in the information about format */ 963 /* Fill in the information about format */
969 pix_fmt = vpfe_lookup_pix_format(pix); 964 pix_fmt = vpfe_lookup_pix_format(pix);
970 if (NULL != pix_fmt) { 965 if (pix_fmt) {
971 temp_index = fmt->index; 966 temp_index = fmt->index;
972 *fmt = pix_fmt->fmtdesc; 967 *fmt = pix_fmt->fmtdesc;
973 fmt->index = temp_index; 968 fmt->index = temp_index;
@@ -981,7 +976,7 @@ static int vpfe_s_fmt_vid_cap(struct file *file, void *priv,
981{ 976{
982 struct vpfe_device *vpfe_dev = video_drvdata(file); 977 struct vpfe_device *vpfe_dev = video_drvdata(file);
983 const struct vpfe_pixel_format *pix_fmts; 978 const struct vpfe_pixel_format *pix_fmts;
984 int ret = 0; 979 int ret;
985 980
986 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_fmt_vid_cap\n"); 981 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_fmt_vid_cap\n");
987 982
@@ -993,8 +988,7 @@ static int vpfe_s_fmt_vid_cap(struct file *file, void *priv,
993 988
994 /* Check for valid frame format */ 989 /* Check for valid frame format */
995 pix_fmts = vpfe_check_format(vpfe_dev, &fmt->fmt.pix); 990 pix_fmts = vpfe_check_format(vpfe_dev, &fmt->fmt.pix);
996 991 if (!pix_fmts)
997 if (NULL == pix_fmts)
998 return -EINVAL; 992 return -EINVAL;
999 993
1000 /* store the pixel format in the device object */ 994 /* store the pixel format in the device object */
@@ -1020,7 +1014,7 @@ static int vpfe_try_fmt_vid_cap(struct file *file, void *priv,
1020 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_try_fmt_vid_cap\n"); 1014 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_try_fmt_vid_cap\n");
1021 1015
1022 pix_fmts = vpfe_check_format(vpfe_dev, &f->fmt.pix); 1016 pix_fmts = vpfe_check_format(vpfe_dev, &f->fmt.pix);
1023 if (NULL == pix_fmts) 1017 if (!pix_fmts)
1024 return -EINVAL; 1018 return -EINVAL;
1025 return 0; 1019 return 0;
1026} 1020}
@@ -1088,12 +1082,11 @@ static int vpfe_enum_input(struct file *file, void *priv,
1088 &subdev, 1082 &subdev,
1089 &index, 1083 &index,
1090 inp->index) < 0) { 1084 inp->index) < 0) {
1091 v4l2_err(&vpfe_dev->v4l2_dev, "input information not found" 1085 v4l2_err(&vpfe_dev->v4l2_dev, "input information not found for the subdev\n");
1092 " for the subdev\n");
1093 return -EINVAL; 1086 return -EINVAL;
1094 } 1087 }
1095 sdinfo = &vpfe_dev->cfg->sub_devs[subdev]; 1088 sdinfo = &vpfe_dev->cfg->sub_devs[subdev];
1096 memcpy(inp, &sdinfo->inputs[index], sizeof(struct v4l2_input)); 1089 *inp = sdinfo->inputs[index];
1097 return 0; 1090 return 0;
1098} 1091}
1099 1092
@@ -1114,8 +1107,8 @@ static int vpfe_s_input(struct file *file, void *priv, unsigned int index)
1114 struct vpfe_subdev_info *sdinfo; 1107 struct vpfe_subdev_info *sdinfo;
1115 int subdev_index, inp_index; 1108 int subdev_index, inp_index;
1116 struct vpfe_route *route; 1109 struct vpfe_route *route;
1117 u32 input = 0, output = 0; 1110 u32 input, output;
1118 int ret = -EINVAL; 1111 int ret;
1119 1112
1120 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_input\n"); 1113 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_input\n");
1121 1114
@@ -1147,6 +1140,9 @@ static int vpfe_s_input(struct file *file, void *priv, unsigned int index)
1147 if (route && sdinfo->can_route) { 1140 if (route && sdinfo->can_route) {
1148 input = route->input; 1141 input = route->input;
1149 output = route->output; 1142 output = route->output;
1143 } else {
1144 input = 0;
1145 output = 0;
1150 } 1146 }
1151 1147
1152 if (sd) 1148 if (sd)
@@ -1181,7 +1177,7 @@ static int vpfe_querystd(struct file *file, void *priv, v4l2_std_id *std_id)
1181{ 1177{
1182 struct vpfe_device *vpfe_dev = video_drvdata(file); 1178 struct vpfe_device *vpfe_dev = video_drvdata(file);
1183 struct vpfe_subdev_info *sdinfo; 1179 struct vpfe_subdev_info *sdinfo;
1184 int ret = 0; 1180 int ret;
1185 1181
1186 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_querystd\n"); 1182 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_querystd\n");
1187 1183
@@ -1200,7 +1196,7 @@ static int vpfe_s_std(struct file *file, void *priv, v4l2_std_id std_id)
1200{ 1196{
1201 struct vpfe_device *vpfe_dev = video_drvdata(file); 1197 struct vpfe_device *vpfe_dev = video_drvdata(file);
1202 struct vpfe_subdev_info *sdinfo; 1198 struct vpfe_subdev_info *sdinfo;
1203 int ret = 0; 1199 int ret;
1204 1200
1205 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_std\n"); 1201 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_std\n");
1206 1202
@@ -1349,7 +1345,7 @@ static int vpfe_reqbufs(struct file *file, void *priv,
1349{ 1345{
1350 struct vpfe_device *vpfe_dev = video_drvdata(file); 1346 struct vpfe_device *vpfe_dev = video_drvdata(file);
1351 struct vpfe_fh *fh = file->private_data; 1347 struct vpfe_fh *fh = file->private_data;
1352 int ret = 0; 1348 int ret;
1353 1349
1354 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_reqbufs\n"); 1350 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_reqbufs\n");
1355 1351
@@ -1481,7 +1477,7 @@ static int vpfe_streamon(struct file *file, void *priv,
1481 struct vpfe_fh *fh = file->private_data; 1477 struct vpfe_fh *fh = file->private_data;
1482 struct vpfe_subdev_info *sdinfo; 1478 struct vpfe_subdev_info *sdinfo;
1483 unsigned long addr; 1479 unsigned long addr;
1484 int ret = 0; 1480 int ret;
1485 1481
1486 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_streamon\n"); 1482 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_streamon\n");
1487 1483
@@ -1564,7 +1560,7 @@ static int vpfe_streamoff(struct file *file, void *priv,
1564 struct vpfe_device *vpfe_dev = video_drvdata(file); 1560 struct vpfe_device *vpfe_dev = video_drvdata(file);
1565 struct vpfe_fh *fh = file->private_data; 1561 struct vpfe_fh *fh = file->private_data;
1566 struct vpfe_subdev_info *sdinfo; 1562 struct vpfe_subdev_info *sdinfo;
1567 int ret = 0; 1563 int ret;
1568 1564
1569 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_streamoff\n"); 1565 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_streamoff\n");
1570 1566
@@ -1650,7 +1646,7 @@ static int vpfe_s_selection(struct file *file, void *priv,
1650{ 1646{
1651 struct vpfe_device *vpfe_dev = video_drvdata(file); 1647 struct vpfe_device *vpfe_dev = video_drvdata(file);
1652 struct v4l2_rect rect = sel->r; 1648 struct v4l2_rect rect = sel->r;
1653 int ret = 0; 1649 int ret;
1654 1650
1655 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_selection\n"); 1651 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_selection\n");
1656 1652
@@ -1708,7 +1704,7 @@ static long vpfe_param_handler(struct file *file, void *priv,
1708 bool valid_prio, unsigned int cmd, void *param) 1704 bool valid_prio, unsigned int cmd, void *param)
1709{ 1705{
1710 struct vpfe_device *vpfe_dev = video_drvdata(file); 1706 struct vpfe_device *vpfe_dev = video_drvdata(file);
1711 int ret = 0; 1707 int ret;
1712 1708
1713 v4l2_dbg(2, debug, &vpfe_dev->v4l2_dev, "vpfe_param_handler\n"); 1709 v4l2_dbg(2, debug, &vpfe_dev->v4l2_dev, "vpfe_param_handler\n");
1714 1710
@@ -1821,7 +1817,7 @@ static int vpfe_probe(struct platform_device *pdev)
1821 struct vpfe_device *vpfe_dev; 1817 struct vpfe_device *vpfe_dev;
1822 struct i2c_adapter *i2c_adap; 1818 struct i2c_adapter *i2c_adap;
1823 struct video_device *vfd; 1819 struct video_device *vfd;
1824 int ret = -ENOMEM, i, j; 1820 int ret, i, j;
1825 int num_subdevs = 0; 1821 int num_subdevs = 0;
1826 1822
1827 /* Get the pointer to the device object */ 1823 /* Get the pointer to the device object */
@@ -1830,12 +1826,12 @@ static int vpfe_probe(struct platform_device *pdev)
1830 if (!vpfe_dev) { 1826 if (!vpfe_dev) {
1831 v4l2_err(pdev->dev.driver, 1827 v4l2_err(pdev->dev.driver,
1832 "Failed to allocate memory for vpfe_dev\n"); 1828 "Failed to allocate memory for vpfe_dev\n");
1833 return ret; 1829 return -ENOMEM;
1834 } 1830 }
1835 1831
1836 vpfe_dev->pdev = &pdev->dev; 1832 vpfe_dev->pdev = &pdev->dev;
1837 1833
1838 if (NULL == pdev->dev.platform_data) { 1834 if (!pdev->dev.platform_data) {
1839 v4l2_err(pdev->dev.driver, "Unable to get vpfe config\n"); 1835 v4l2_err(pdev->dev.driver, "Unable to get vpfe config\n");
1840 ret = -ENODEV; 1836 ret = -ENODEV;
1841 goto probe_free_dev_mem; 1837 goto probe_free_dev_mem;
@@ -1843,19 +1839,16 @@ static int vpfe_probe(struct platform_device *pdev)
1843 1839
1844 vpfe_cfg = pdev->dev.platform_data; 1840 vpfe_cfg = pdev->dev.platform_data;
1845 vpfe_dev->cfg = vpfe_cfg; 1841 vpfe_dev->cfg = vpfe_cfg;
1846 if (NULL == vpfe_cfg->ccdc || 1842 if (!vpfe_cfg->ccdc || !vpfe_cfg->card_name || !vpfe_cfg->sub_devs) {
1847 NULL == vpfe_cfg->card_name ||
1848 NULL == vpfe_cfg->sub_devs) {
1849 v4l2_err(pdev->dev.driver, "null ptr in vpfe_cfg\n"); 1843 v4l2_err(pdev->dev.driver, "null ptr in vpfe_cfg\n");
1850 ret = -ENOENT; 1844 ret = -ENOENT;
1851 goto probe_free_dev_mem; 1845 goto probe_free_dev_mem;
1852 } 1846 }
1853 1847
1854 /* Allocate memory for ccdc configuration */ 1848 /* Allocate memory for ccdc configuration */
1855 ccdc_cfg = kmalloc(sizeof(struct ccdc_config), GFP_KERNEL); 1849 ccdc_cfg = kmalloc(sizeof(*ccdc_cfg), GFP_KERNEL);
1856 if (NULL == ccdc_cfg) { 1850 if (!ccdc_cfg) {
1857 v4l2_err(pdev->dev.driver, 1851 ret = -ENOMEM;
1858 "Memory allocation failed for ccdc_cfg\n");
1859 goto probe_free_dev_mem; 1852 goto probe_free_dev_mem;
1860 } 1853 }
1861 1854
@@ -1940,11 +1933,10 @@ static int vpfe_probe(struct platform_device *pdev)
1940 video_set_drvdata(&vpfe_dev->video_dev, vpfe_dev); 1933 video_set_drvdata(&vpfe_dev->video_dev, vpfe_dev);
1941 i2c_adap = i2c_get_adapter(vpfe_cfg->i2c_adapter_id); 1934 i2c_adap = i2c_get_adapter(vpfe_cfg->i2c_adapter_id);
1942 num_subdevs = vpfe_cfg->num_subdevs; 1935 num_subdevs = vpfe_cfg->num_subdevs;
1943 vpfe_dev->sd = kmalloc(sizeof(struct v4l2_subdev *) * num_subdevs, 1936 vpfe_dev->sd = kmalloc_array(num_subdevs,
1944 GFP_KERNEL); 1937 sizeof(*vpfe_dev->sd),
1945 if (NULL == vpfe_dev->sd) { 1938 GFP_KERNEL);
1946 v4l2_err(&vpfe_dev->v4l2_dev, 1939 if (!vpfe_dev->sd) {
1947 "unable to allocate memory for subdevice pointers\n");
1948 ret = -ENOMEM; 1940 ret = -ENOMEM;
1949 goto probe_out_video_unregister; 1941 goto probe_out_video_unregister;
1950 } 1942 }
@@ -1974,6 +1966,7 @@ static int vpfe_probe(struct platform_device *pdev)
1974 v4l2_info(&vpfe_dev->v4l2_dev, 1966 v4l2_info(&vpfe_dev->v4l2_dev,
1975 "v4l2 sub device %s register fails\n", 1967 "v4l2 sub device %s register fails\n",
1976 sdinfo->name); 1968 sdinfo->name);
1969 ret = -ENXIO;
1977 goto probe_sd_out; 1970 goto probe_sd_out;
1978 } 1971 }
1979 } 1972 }
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
index 5104cc0ee40e..f791f5c402bf 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -291,10 +291,10 @@ static void vpif_stop_streaming(struct vb2_queue *vq)
291 vb2_buffer_done(&common->cur_frm->vb.vb2_buf, 291 vb2_buffer_done(&common->cur_frm->vb.vb2_buf,
292 VB2_BUF_STATE_ERROR); 292 VB2_BUF_STATE_ERROR);
293 } else { 293 } else {
294 if (common->cur_frm != NULL) 294 if (common->cur_frm)
295 vb2_buffer_done(&common->cur_frm->vb.vb2_buf, 295 vb2_buffer_done(&common->cur_frm->vb.vb2_buf,
296 VB2_BUF_STATE_ERROR); 296 VB2_BUF_STATE_ERROR);
297 if (common->next_frm != NULL) 297 if (common->next_frm)
298 vb2_buffer_done(&common->next_frm->vb.vb2_buf, 298 vb2_buffer_done(&common->next_frm->vb.vb2_buf,
299 VB2_BUF_STATE_ERROR); 299 VB2_BUF_STATE_ERROR);
300 } 300 }
@@ -375,7 +375,7 @@ static irqreturn_t vpif_channel_isr(int irq, void *dev_id)
375 struct vpif_device *dev = &vpif_obj; 375 struct vpif_device *dev = &vpif_obj;
376 struct common_obj *common; 376 struct common_obj *common;
377 struct channel_obj *ch; 377 struct channel_obj *ch;
378 int channel_id = 0; 378 int channel_id;
379 int fid = -1, i; 379 int fid = -1, i;
380 380
381 channel_id = *(int *)(dev_id); 381 channel_id = *(int *)(dev_id);
@@ -648,7 +648,7 @@ static int vpif_input_to_subdev(
648 vpif_dbg(2, debug, "vpif_input_to_subdev\n"); 648 vpif_dbg(2, debug, "vpif_input_to_subdev\n");
649 649
650 subdev_name = chan_cfg->inputs[input_index].subdev_name; 650 subdev_name = chan_cfg->inputs[input_index].subdev_name;
651 if (subdev_name == NULL) 651 if (!subdev_name)
652 return -1; 652 return -1;
653 653
654 /* loop through the sub device list to get the sub device info */ 654 /* loop through the sub device list to get the sub device info */
@@ -731,7 +731,7 @@ static int vpif_querystd(struct file *file, void *priv, v4l2_std_id *std_id)
731{ 731{
732 struct video_device *vdev = video_devdata(file); 732 struct video_device *vdev = video_devdata(file);
733 struct channel_obj *ch = video_get_drvdata(vdev); 733 struct channel_obj *ch = video_get_drvdata(vdev);
734 int ret = 0; 734 int ret;
735 735
736 vpif_dbg(2, debug, "vpif_querystd\n"); 736 vpif_dbg(2, debug, "vpif_querystd\n");
737 737
@@ -764,7 +764,7 @@ static int vpif_g_std(struct file *file, void *priv, v4l2_std_id *std)
764 764
765 vpif_dbg(2, debug, "vpif_g_std\n"); 765 vpif_dbg(2, debug, "vpif_g_std\n");
766 766
767 if (config->chan_config[ch->channel_id].inputs == NULL) 767 if (!config->chan_config[ch->channel_id].inputs)
768 return -ENODATA; 768 return -ENODATA;
769 769
770 chan_cfg = &config->chan_config[ch->channel_id]; 770 chan_cfg = &config->chan_config[ch->channel_id];
@@ -794,7 +794,7 @@ static int vpif_s_std(struct file *file, void *priv, v4l2_std_id std_id)
794 794
795 vpif_dbg(2, debug, "vpif_s_std\n"); 795 vpif_dbg(2, debug, "vpif_s_std\n");
796 796
797 if (config->chan_config[ch->channel_id].inputs == NULL) 797 if (!config->chan_config[ch->channel_id].inputs)
798 return -ENODATA; 798 return -ENODATA;
799 799
800 chan_cfg = &config->chan_config[ch->channel_id]; 800 chan_cfg = &config->chan_config[ch->channel_id];
@@ -1050,7 +1050,7 @@ vpif_enum_dv_timings(struct file *file, void *priv,
1050 struct v4l2_input input; 1050 struct v4l2_input input;
1051 int ret; 1051 int ret;
1052 1052
1053 if (config->chan_config[ch->channel_id].inputs == NULL) 1053 if (!config->chan_config[ch->channel_id].inputs)
1054 return -ENODATA; 1054 return -ENODATA;
1055 1055
1056 chan_cfg = &config->chan_config[ch->channel_id]; 1056 chan_cfg = &config->chan_config[ch->channel_id];
@@ -1084,7 +1084,7 @@ vpif_query_dv_timings(struct file *file, void *priv,
1084 struct v4l2_input input; 1084 struct v4l2_input input;
1085 int ret; 1085 int ret;
1086 1086
1087 if (config->chan_config[ch->channel_id].inputs == NULL) 1087 if (!config->chan_config[ch->channel_id].inputs)
1088 return -ENODATA; 1088 return -ENODATA;
1089 1089
1090 chan_cfg = &config->chan_config[ch->channel_id]; 1090 chan_cfg = &config->chan_config[ch->channel_id];
@@ -1120,7 +1120,7 @@ static int vpif_s_dv_timings(struct file *file, void *priv,
1120 struct v4l2_input input; 1120 struct v4l2_input input;
1121 int ret; 1121 int ret;
1122 1122
1123 if (config->chan_config[ch->channel_id].inputs == NULL) 1123 if (!config->chan_config[ch->channel_id].inputs)
1124 return -ENODATA; 1124 return -ENODATA;
1125 1125
1126 chan_cfg = &config->chan_config[ch->channel_id]; 1126 chan_cfg = &config->chan_config[ch->channel_id];
@@ -1152,11 +1152,7 @@ static int vpif_s_dv_timings(struct file *file, void *priv,
1152 timings->bt.vfrontporch && 1152 timings->bt.vfrontporch &&
1153 (timings->bt.vbackporch || 1153 (timings->bt.vbackporch ||
1154 timings->bt.vsync))) { 1154 timings->bt.vsync))) {
1155 vpif_dbg(2, debug, "Timings for width, height, " 1155 vpif_dbg(2, debug, "Timings for width, height, horizontal back porch, horizontal sync, horizontal front porch, vertical back porch, vertical sync and vertical back porch must be defined\n");
1156 "horizontal back porch, horizontal sync, "
1157 "horizontal front porch, vertical back porch, "
1158 "vertical sync and vertical back porch "
1159 "must be defined\n");
1160 return -EINVAL; 1156 return -EINVAL;
1161 } 1157 }
1162 1158
@@ -1181,8 +1177,7 @@ static int vpif_s_dv_timings(struct file *file, void *priv,
1181 std_info->l11 = std_info->vsize - 1177 std_info->l11 = std_info->vsize -
1182 (bt->il_vfrontporch - 1); 1178 (bt->il_vfrontporch - 1);
1183 } else { 1179 } else {
1184 vpif_dbg(2, debug, "Required timing values for " 1180 vpif_dbg(2, debug, "Required timing values for interlaced BT format missing\n");
1185 "interlaced BT format missing\n");
1186 return -EINVAL; 1181 return -EINVAL;
1187 } 1182 }
1188 } else { 1183 } else {
@@ -1218,7 +1213,7 @@ static int vpif_g_dv_timings(struct file *file, void *priv,
1218 struct vpif_capture_chan_config *chan_cfg; 1213 struct vpif_capture_chan_config *chan_cfg;
1219 struct v4l2_input input; 1214 struct v4l2_input input;
1220 1215
1221 if (config->chan_config[ch->channel_id].inputs == NULL) 1216 if (!config->chan_config[ch->channel_id].inputs)
1222 return -ENODATA; 1217 return -ENODATA;
1223 1218
1224 chan_cfg = &config->chan_config[ch->channel_id]; 1219 chan_cfg = &config->chan_config[ch->channel_id];
@@ -1464,10 +1459,8 @@ static __init int vpif_probe(struct platform_device *pdev)
1464 vpif_obj.config = pdev->dev.platform_data; 1459 vpif_obj.config = pdev->dev.platform_data;
1465 1460
1466 subdev_count = vpif_obj.config->subdev_count; 1461 subdev_count = vpif_obj.config->subdev_count;
1467 vpif_obj.sd = kzalloc(sizeof(struct v4l2_subdev *) * subdev_count, 1462 vpif_obj.sd = kcalloc(subdev_count, sizeof(*vpif_obj.sd), GFP_KERNEL);
1468 GFP_KERNEL); 1463 if (!vpif_obj.sd) {
1469 if (vpif_obj.sd == NULL) {
1470 vpif_err("unable to allocate memory for subdevice pointers\n");
1471 err = -ENOMEM; 1464 err = -ENOMEM;
1472 goto vpif_unregister; 1465 goto vpif_unregister;
1473 } 1466 }
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
index 75b27233ec2f..e5f18448dbf7 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -271,10 +271,10 @@ static void vpif_stop_streaming(struct vb2_queue *vq)
271 vb2_buffer_done(&common->cur_frm->vb.vb2_buf, 271 vb2_buffer_done(&common->cur_frm->vb.vb2_buf,
272 VB2_BUF_STATE_ERROR); 272 VB2_BUF_STATE_ERROR);
273 } else { 273 } else {
274 if (common->cur_frm != NULL) 274 if (common->cur_frm)
275 vb2_buffer_done(&common->cur_frm->vb.vb2_buf, 275 vb2_buffer_done(&common->cur_frm->vb.vb2_buf,
276 VB2_BUF_STATE_ERROR); 276 VB2_BUF_STATE_ERROR);
277 if (common->next_frm != NULL) 277 if (common->next_frm)
278 vb2_buffer_done(&common->next_frm->vb.vb2_buf, 278 vb2_buffer_done(&common->next_frm->vb.vb2_buf,
279 VB2_BUF_STATE_ERROR); 279 VB2_BUF_STATE_ERROR);
280 } 280 }
@@ -301,7 +301,7 @@ static struct vb2_ops video_qops = {
301 301
302static void process_progressive_mode(struct common_obj *common) 302static void process_progressive_mode(struct common_obj *common)
303{ 303{
304 unsigned long addr = 0; 304 unsigned long addr;
305 305
306 spin_lock(&common->irqlock); 306 spin_lock(&common->irqlock);
307 /* Get the next buffer from buffer queue */ 307 /* Get the next buffer from buffer queue */
@@ -363,7 +363,7 @@ static irqreturn_t vpif_channel_isr(int irq, void *dev_id)
363 struct channel_obj *ch; 363 struct channel_obj *ch;
364 struct common_obj *common; 364 struct common_obj *common;
365 int fid = -1, i; 365 int fid = -1, i;
366 int channel_id = 0; 366 int channel_id;
367 367
368 channel_id = *(int *)(dev_id); 368 channel_id = *(int *)(dev_id);
369 if (!vpif_intr_status(channel_id + 2)) 369 if (!vpif_intr_status(channel_id + 2))
@@ -686,7 +686,7 @@ static int vpif_s_std(struct file *file, void *priv, v4l2_std_id std_id)
686 struct v4l2_output output; 686 struct v4l2_output output;
687 int ret; 687 int ret;
688 688
689 if (config->chan_config[ch->channel_id].outputs == NULL) 689 if (!config->chan_config[ch->channel_id].outputs)
690 return -ENODATA; 690 return -ENODATA;
691 691
692 chan_cfg = &config->chan_config[ch->channel_id]; 692 chan_cfg = &config->chan_config[ch->channel_id];
@@ -732,7 +732,7 @@ static int vpif_g_std(struct file *file, void *priv, v4l2_std_id *std)
732 struct vpif_display_chan_config *chan_cfg; 732 struct vpif_display_chan_config *chan_cfg;
733 struct v4l2_output output; 733 struct v4l2_output output;
734 734
735 if (config->chan_config[ch->channel_id].outputs == NULL) 735 if (!config->chan_config[ch->channel_id].outputs)
736 return -ENODATA; 736 return -ENODATA;
737 737
738 chan_cfg = &config->chan_config[ch->channel_id]; 738 chan_cfg = &config->chan_config[ch->channel_id];
@@ -783,11 +783,11 @@ vpif_output_to_subdev(struct vpif_display_config *vpif_cfg,
783 783
784 vpif_dbg(2, debug, "vpif_output_to_subdev\n"); 784 vpif_dbg(2, debug, "vpif_output_to_subdev\n");
785 785
786 if (chan_cfg->outputs == NULL) 786 if (!chan_cfg->outputs)
787 return -1; 787 return -1;
788 788
789 subdev_name = chan_cfg->outputs[index].subdev_name; 789 subdev_name = chan_cfg->outputs[index].subdev_name;
790 if (subdev_name == NULL) 790 if (!subdev_name)
791 return -1; 791 return -1;
792 792
793 /* loop through the sub device list to get the sub device info */ 793 /* loop through the sub device list to get the sub device info */
@@ -833,7 +833,7 @@ static int vpif_set_output(struct vpif_display_config *vpif_cfg,
833 } 833 }
834 ch->output_idx = index; 834 ch->output_idx = index;
835 ch->sd = sd; 835 ch->sd = sd;
836 if (chan_cfg->outputs != NULL) 836 if (chan_cfg->outputs)
837 /* update tvnorms from the sub device output info */ 837 /* update tvnorms from the sub device output info */
838 ch->video_dev.tvnorms = chan_cfg->outputs[index].output.std; 838 ch->video_dev.tvnorms = chan_cfg->outputs[index].output.std;
839 return 0; 839 return 0;
@@ -885,7 +885,7 @@ vpif_enum_dv_timings(struct file *file, void *priv,
885 struct v4l2_output output; 885 struct v4l2_output output;
886 int ret; 886 int ret;
887 887
888 if (config->chan_config[ch->channel_id].outputs == NULL) 888 if (!config->chan_config[ch->channel_id].outputs)
889 return -ENODATA; 889 return -ENODATA;
890 890
891 chan_cfg = &config->chan_config[ch->channel_id]; 891 chan_cfg = &config->chan_config[ch->channel_id];
@@ -922,7 +922,7 @@ static int vpif_s_dv_timings(struct file *file, void *priv,
922 struct v4l2_output output; 922 struct v4l2_output output;
923 int ret; 923 int ret;
924 924
925 if (config->chan_config[ch->channel_id].outputs == NULL) 925 if (!config->chan_config[ch->channel_id].outputs)
926 return -ENODATA; 926 return -ENODATA;
927 927
928 chan_cfg = &config->chan_config[ch->channel_id]; 928 chan_cfg = &config->chan_config[ch->channel_id];
@@ -954,11 +954,7 @@ static int vpif_s_dv_timings(struct file *file, void *priv,
954 timings->bt.vfrontporch && 954 timings->bt.vfrontporch &&
955 (timings->bt.vbackporch || 955 (timings->bt.vbackporch ||
956 timings->bt.vsync))) { 956 timings->bt.vsync))) {
957 vpif_dbg(2, debug, "Timings for width, height, " 957 vpif_dbg(2, debug, "Timings for width, height, horizontal back porch, horizontal sync, horizontal front porch, vertical back porch, vertical sync and vertical back porch must be defined\n");
958 "horizontal back porch, horizontal sync, "
959 "horizontal front porch, vertical back porch, "
960 "vertical sync and vertical back porch "
961 "must be defined\n");
962 return -EINVAL; 958 return -EINVAL;
963 } 959 }
964 960
@@ -983,8 +979,7 @@ static int vpif_s_dv_timings(struct file *file, void *priv,
983 std_info->l11 = std_info->vsize - 979 std_info->l11 = std_info->vsize -
984 (bt->il_vfrontporch - 1); 980 (bt->il_vfrontporch - 1);
985 } else { 981 } else {
986 vpif_dbg(2, debug, "Required timing values for " 982 vpif_dbg(2, debug, "Required timing values for interlaced BT format missing\n");
987 "interlaced BT format missing\n");
988 return -EINVAL; 983 return -EINVAL;
989 } 984 }
990 } else { 985 } else {
@@ -1021,7 +1016,7 @@ static int vpif_g_dv_timings(struct file *file, void *priv,
1021 struct video_obj *vid_ch = &ch->video; 1016 struct video_obj *vid_ch = &ch->video;
1022 struct v4l2_output output; 1017 struct v4l2_output output;
1023 1018
1024 if (config->chan_config[ch->channel_id].outputs == NULL) 1019 if (!config->chan_config[ch->channel_id].outputs)
1025 goto error; 1020 goto error;
1026 1021
1027 chan_cfg = &config->chan_config[ch->channel_id]; 1022 chan_cfg = &config->chan_config[ch->channel_id];
@@ -1279,10 +1274,8 @@ static __init int vpif_probe(struct platform_device *pdev)
1279 vpif_obj.config = pdev->dev.platform_data; 1274 vpif_obj.config = pdev->dev.platform_data;
1280 subdev_count = vpif_obj.config->subdev_count; 1275 subdev_count = vpif_obj.config->subdev_count;
1281 subdevdata = vpif_obj.config->subdevinfo; 1276 subdevdata = vpif_obj.config->subdevinfo;
1282 vpif_obj.sd = kzalloc(sizeof(struct v4l2_subdev *) * subdev_count, 1277 vpif_obj.sd = kcalloc(subdev_count, sizeof(*vpif_obj.sd), GFP_KERNEL);
1283 GFP_KERNEL); 1278 if (!vpif_obj.sd) {
1284 if (vpif_obj.sd == NULL) {
1285 vpif_err("unable to allocate memory for subdevice pointers\n");
1286 err = -ENOMEM; 1279 err = -ENOMEM;
1287 goto vpif_unregister; 1280 goto vpif_unregister;
1288 } 1281 }
diff --git a/drivers/media/platform/davinci/vpss.c b/drivers/media/platform/davinci/vpss.c
index fce86f17dffc..373b796132f2 100644
--- a/drivers/media/platform/davinci/vpss.c
+++ b/drivers/media/platform/davinci/vpss.c
@@ -261,8 +261,8 @@ static int dm355_enable_clock(enum vpss_clock_sel clock_sel, int en)
261 shift = 6; 261 shift = 6;
262 break; 262 break;
263 default: 263 default:
264 printk(KERN_ERR "dm355_enable_clock:" 264 printk(KERN_ERR "dm355_enable_clock: Invalid selector: %d\n",
265 " Invalid selector: %d\n", clock_sel); 265 clock_sel);
266 return -EINVAL; 266 return -EINVAL;
267 } 267 }
268 268
@@ -421,8 +421,7 @@ static int vpss_probe(struct platform_device *pdev)
421 else if (!strcmp(platform_name, "dm644x_vpss")) 421 else if (!strcmp(platform_name, "dm644x_vpss"))
422 oper_cfg.platform = DM644X; 422 oper_cfg.platform = DM644X;
423 else { 423 else {
424 dev_err(&pdev->dev, "vpss driver not supported on" 424 dev_err(&pdev->dev, "vpss driver not supported on this platform\n");
425 " this platform\n");
426 return -ENODEV; 425 return -ENODEV;
427 } 426 }
428 427
diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c b/drivers/media/platform/exynos-gsc/gsc-core.c
index 787bd16c19e5..cbf75b6194b4 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.c
+++ b/drivers/media/platform/exynos-gsc/gsc-core.c
@@ -24,12 +24,11 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/clk.h> 25#include <linux/clk.h>
26#include <linux/of.h> 26#include <linux/of.h>
27#include <linux/of_device.h>
27#include <media/v4l2-ioctl.h> 28#include <media/v4l2-ioctl.h>
28 29
29#include "gsc-core.h" 30#include "gsc-core.h"
30 31
31#define GSC_CLOCK_GATE_NAME "gscl"
32
33static const struct gsc_fmt gsc_formats[] = { 32static const struct gsc_fmt gsc_formats[] = {
34 { 33 {
35 .name = "RGB565", 34 .name = "RGB565",
@@ -39,8 +38,8 @@ static const struct gsc_fmt gsc_formats[] = {
39 .num_planes = 1, 38 .num_planes = 1,
40 .num_comp = 1, 39 .num_comp = 1,
41 }, { 40 }, {
42 .name = "XRGB-8-8-8-8, 32 bpp", 41 .name = "BGRX-8-8-8-8, 32 bpp",
43 .pixelformat = V4L2_PIX_FMT_RGB32, 42 .pixelformat = V4L2_PIX_FMT_BGR32,
44 .depth = { 32 }, 43 .depth = { 32 },
45 .color = GSC_RGB, 44 .color = GSC_RGB,
46 .num_planes = 1, 45 .num_planes = 1,
@@ -441,7 +440,7 @@ int gsc_try_fmt_mplane(struct gsc_ctx *ctx, struct v4l2_format *f)
441 v4l_bound_align_image(&pix_mp->width, min_w, max_w, mod_x, 440 v4l_bound_align_image(&pix_mp->width, min_w, max_w, mod_x,
442 &pix_mp->height, min_h, max_h, mod_y, 0); 441 &pix_mp->height, min_h, max_h, mod_y, 0);
443 if (tmp_w != pix_mp->width || tmp_h != pix_mp->height) 442 if (tmp_w != pix_mp->width || tmp_h != pix_mp->height)
444 pr_info("Image size has been modified from %dx%d to %dx%d", 443 pr_debug("Image size has been modified from %dx%d to %dx%d\n",
445 tmp_w, tmp_h, pix_mp->width, pix_mp->height); 444 tmp_w, tmp_h, pix_mp->width, pix_mp->height);
446 445
447 pix_mp->num_planes = fmt->num_planes; 446 pix_mp->num_planes = fmt->num_planes;
@@ -451,12 +450,25 @@ int gsc_try_fmt_mplane(struct gsc_ctx *ctx, struct v4l2_format *f)
451 else /* SD */ 450 else /* SD */
452 pix_mp->colorspace = V4L2_COLORSPACE_SMPTE170M; 451 pix_mp->colorspace = V4L2_COLORSPACE_SMPTE170M;
453 452
454
455 for (i = 0; i < pix_mp->num_planes; ++i) { 453 for (i = 0; i < pix_mp->num_planes; ++i) {
456 int bpl = (pix_mp->width * fmt->depth[i]) >> 3; 454 struct v4l2_plane_pix_format *plane_fmt = &pix_mp->plane_fmt[i];
457 pix_mp->plane_fmt[i].bytesperline = bpl; 455 u32 bpl = plane_fmt->bytesperline;
458 pix_mp->plane_fmt[i].sizeimage = bpl * pix_mp->height; 456
457 if (fmt->num_comp == 1 && /* Packed */
458 (bpl == 0 || (bpl * 8 / fmt->depth[i]) < pix_mp->width))
459 bpl = pix_mp->width * fmt->depth[i] / 8;
460
461 if (fmt->num_comp > 1 && /* Planar */
462 (bpl == 0 || bpl < pix_mp->width))
463 bpl = pix_mp->width;
464
465 if (i != 0 && fmt->num_comp == 3)
466 bpl /= 2;
459 467
468 plane_fmt->bytesperline = bpl;
469 plane_fmt->sizeimage = max(pix_mp->width * pix_mp->height *
470 fmt->depth[i] / 8,
471 plane_fmt->sizeimage);
460 pr_debug("[%d]: bpl: %d, sizeimage: %d", 472 pr_debug("[%d]: bpl: %d, sizeimage: %d",
461 i, bpl, pix_mp->plane_fmt[i].sizeimage); 473 i, bpl, pix_mp->plane_fmt[i].sizeimage);
462 } 474 }
@@ -964,7 +976,19 @@ static struct gsc_driverdata gsc_v_100_drvdata = {
964 [3] = &gsc_v_100_variant, 976 [3] = &gsc_v_100_variant,
965 }, 977 },
966 .num_entities = 4, 978 .num_entities = 4,
967 .lclk_frequency = 266000000UL, 979 .clk_names = { "gscl" },
980 .num_clocks = 1,
981};
982
983static struct gsc_driverdata gsc_5433_drvdata = {
984 .variant = {
985 [0] = &gsc_v_100_variant,
986 [1] = &gsc_v_100_variant,
987 [2] = &gsc_v_100_variant,
988 },
989 .num_entities = 3,
990 .clk_names = { "pclk", "aclk", "aclk_xiu", "aclk_gsclbend" },
991 .num_clocks = 4,
968}; 992};
969 993
970static const struct of_device_id exynos_gsc_match[] = { 994static const struct of_device_id exynos_gsc_match[] = {
@@ -972,98 +996,22 @@ static const struct of_device_id exynos_gsc_match[] = {
972 .compatible = "samsung,exynos5-gsc", 996 .compatible = "samsung,exynos5-gsc",
973 .data = &gsc_v_100_drvdata, 997 .data = &gsc_v_100_drvdata,
974 }, 998 },
999 {
1000 .compatible = "samsung,exynos5433-gsc",
1001 .data = &gsc_5433_drvdata,
1002 },
975 {}, 1003 {},
976}; 1004};
977MODULE_DEVICE_TABLE(of, exynos_gsc_match); 1005MODULE_DEVICE_TABLE(of, exynos_gsc_match);
978 1006
979static void *gsc_get_drv_data(struct platform_device *pdev)
980{
981 struct gsc_driverdata *driver_data = NULL;
982 const struct of_device_id *match;
983
984 match = of_match_node(exynos_gsc_match, pdev->dev.of_node);
985 if (match)
986 driver_data = (struct gsc_driverdata *)match->data;
987
988 return driver_data;
989}
990
991static void gsc_clk_put(struct gsc_dev *gsc)
992{
993 if (!IS_ERR(gsc->clock))
994 clk_unprepare(gsc->clock);
995}
996
997static int gsc_clk_get(struct gsc_dev *gsc)
998{
999 int ret;
1000
1001 dev_dbg(&gsc->pdev->dev, "gsc_clk_get Called\n");
1002
1003 gsc->clock = devm_clk_get(&gsc->pdev->dev, GSC_CLOCK_GATE_NAME);
1004 if (IS_ERR(gsc->clock)) {
1005 dev_err(&gsc->pdev->dev, "failed to get clock~~~: %s\n",
1006 GSC_CLOCK_GATE_NAME);
1007 return PTR_ERR(gsc->clock);
1008 }
1009
1010 ret = clk_prepare(gsc->clock);
1011 if (ret < 0) {
1012 dev_err(&gsc->pdev->dev, "clock prepare failed for clock: %s\n",
1013 GSC_CLOCK_GATE_NAME);
1014 gsc->clock = ERR_PTR(-EINVAL);
1015 return ret;
1016 }
1017
1018 return 0;
1019}
1020
1021static int gsc_m2m_suspend(struct gsc_dev *gsc)
1022{
1023 unsigned long flags;
1024 int timeout;
1025
1026 spin_lock_irqsave(&gsc->slock, flags);
1027 if (!gsc_m2m_pending(gsc)) {
1028 spin_unlock_irqrestore(&gsc->slock, flags);
1029 return 0;
1030 }
1031 clear_bit(ST_M2M_SUSPENDED, &gsc->state);
1032 set_bit(ST_M2M_SUSPENDING, &gsc->state);
1033 spin_unlock_irqrestore(&gsc->slock, flags);
1034
1035 timeout = wait_event_timeout(gsc->irq_queue,
1036 test_bit(ST_M2M_SUSPENDED, &gsc->state),
1037 GSC_SHUTDOWN_TIMEOUT);
1038
1039 clear_bit(ST_M2M_SUSPENDING, &gsc->state);
1040 return timeout == 0 ? -EAGAIN : 0;
1041}
1042
1043static int gsc_m2m_resume(struct gsc_dev *gsc)
1044{
1045 struct gsc_ctx *ctx;
1046 unsigned long flags;
1047
1048 spin_lock_irqsave(&gsc->slock, flags);
1049 /* Clear for full H/W setup in first run after resume */
1050 ctx = gsc->m2m.ctx;
1051 gsc->m2m.ctx = NULL;
1052 spin_unlock_irqrestore(&gsc->slock, flags);
1053
1054 if (test_and_clear_bit(ST_M2M_SUSPENDED, &gsc->state))
1055 gsc_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
1056
1057 return 0;
1058}
1059
1060static int gsc_probe(struct platform_device *pdev) 1007static int gsc_probe(struct platform_device *pdev)
1061{ 1008{
1062 struct gsc_dev *gsc; 1009 struct gsc_dev *gsc;
1063 struct resource *res; 1010 struct resource *res;
1064 struct gsc_driverdata *drv_data = gsc_get_drv_data(pdev);
1065 struct device *dev = &pdev->dev; 1011 struct device *dev = &pdev->dev;
1012 const struct gsc_driverdata *drv_data = of_device_get_match_data(dev);
1066 int ret; 1013 int ret;
1014 int i;
1067 1015
1068 gsc = devm_kzalloc(dev, sizeof(struct gsc_dev), GFP_KERNEL); 1016 gsc = devm_kzalloc(dev, sizeof(struct gsc_dev), GFP_KERNEL);
1069 if (!gsc) 1017 if (!gsc)
@@ -1079,13 +1027,13 @@ static int gsc_probe(struct platform_device *pdev)
1079 return -EINVAL; 1027 return -EINVAL;
1080 } 1028 }
1081 1029
1030 gsc->num_clocks = drv_data->num_clocks;
1082 gsc->variant = drv_data->variant[gsc->id]; 1031 gsc->variant = drv_data->variant[gsc->id];
1083 gsc->pdev = pdev; 1032 gsc->pdev = pdev;
1084 1033
1085 init_waitqueue_head(&gsc->irq_queue); 1034 init_waitqueue_head(&gsc->irq_queue);
1086 spin_lock_init(&gsc->slock); 1035 spin_lock_init(&gsc->slock);
1087 mutex_init(&gsc->lock); 1036 mutex_init(&gsc->lock);
1088 gsc->clock = ERR_PTR(-EINVAL);
1089 1037
1090 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1038 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1091 gsc->regs = devm_ioremap_resource(dev, res); 1039 gsc->regs = devm_ioremap_resource(dev, res);
@@ -1098,9 +1046,25 @@ static int gsc_probe(struct platform_device *pdev)
1098 return -ENXIO; 1046 return -ENXIO;
1099 } 1047 }
1100 1048
1101 ret = gsc_clk_get(gsc); 1049 for (i = 0; i < gsc->num_clocks; i++) {
1102 if (ret) 1050 gsc->clock[i] = devm_clk_get(dev, drv_data->clk_names[i]);
1103 return ret; 1051 if (IS_ERR(gsc->clock[i])) {
1052 dev_err(dev, "failed to get clock: %s\n",
1053 drv_data->clk_names[i]);
1054 return PTR_ERR(gsc->clock[i]);
1055 }
1056 }
1057
1058 for (i = 0; i < gsc->num_clocks; i++) {
1059 ret = clk_prepare_enable(gsc->clock[i]);
1060 if (ret) {
1061 dev_err(dev, "clock prepare failed for clock: %s\n",
1062 drv_data->clk_names[i]);
1063 while (--i >= 0)
1064 clk_disable_unprepare(gsc->clock[i]);
1065 return ret;
1066 }
1067 }
1104 1068
1105 ret = devm_request_irq(dev, res->start, gsc_irq_handler, 1069 ret = devm_request_irq(dev, res->start, gsc_irq_handler,
1106 0, pdev->name, gsc); 1070 0, pdev->name, gsc);
@@ -1118,114 +1082,131 @@ static int gsc_probe(struct platform_device *pdev)
1118 goto err_v4l2; 1082 goto err_v4l2;
1119 1083
1120 platform_set_drvdata(pdev, gsc); 1084 platform_set_drvdata(pdev, gsc);
1121 pm_runtime_enable(dev); 1085
1122 ret = pm_runtime_get_sync(&pdev->dev); 1086 gsc_hw_set_sw_reset(gsc);
1123 if (ret < 0) 1087 gsc_wait_reset(gsc);
1124 goto err_m2m;
1125 1088
1126 vb2_dma_contig_set_max_seg_size(dev, DMA_BIT_MASK(32)); 1089 vb2_dma_contig_set_max_seg_size(dev, DMA_BIT_MASK(32));
1127 1090
1128 dev_dbg(dev, "gsc-%d registered successfully\n", gsc->id); 1091 dev_dbg(dev, "gsc-%d registered successfully\n", gsc->id);
1129 1092
1130 pm_runtime_put(dev); 1093 pm_runtime_set_active(dev);
1094 pm_runtime_enable(dev);
1095
1131 return 0; 1096 return 0;
1132 1097
1133err_m2m:
1134 gsc_unregister_m2m_device(gsc);
1135err_v4l2: 1098err_v4l2:
1136 v4l2_device_unregister(&gsc->v4l2_dev); 1099 v4l2_device_unregister(&gsc->v4l2_dev);
1137err_clk: 1100err_clk:
1138 gsc_clk_put(gsc); 1101 for (i = gsc->num_clocks - 1; i >= 0; i--)
1102 clk_disable_unprepare(gsc->clock[i]);
1139 return ret; 1103 return ret;
1140} 1104}
1141 1105
1142static int gsc_remove(struct platform_device *pdev) 1106static int gsc_remove(struct platform_device *pdev)
1143{ 1107{
1144 struct gsc_dev *gsc = platform_get_drvdata(pdev); 1108 struct gsc_dev *gsc = platform_get_drvdata(pdev);
1109 int i;
1110
1111 pm_runtime_get_sync(&pdev->dev);
1145 1112
1146 gsc_unregister_m2m_device(gsc); 1113 gsc_unregister_m2m_device(gsc);
1147 v4l2_device_unregister(&gsc->v4l2_dev); 1114 v4l2_device_unregister(&gsc->v4l2_dev);
1148 1115
1149 vb2_dma_contig_clear_max_seg_size(&pdev->dev); 1116 vb2_dma_contig_clear_max_seg_size(&pdev->dev);
1150 pm_runtime_disable(&pdev->dev); 1117 for (i = 0; i < gsc->num_clocks; i++)
1151 gsc_clk_put(gsc); 1118 clk_disable_unprepare(gsc->clock[i]);
1119
1120 pm_runtime_put_noidle(&pdev->dev);
1152 1121
1153 dev_dbg(&pdev->dev, "%s driver unloaded\n", pdev->name); 1122 dev_dbg(&pdev->dev, "%s driver unloaded\n", pdev->name);
1154 return 0; 1123 return 0;
1155} 1124}
1156 1125
1157static int gsc_runtime_resume(struct device *dev) 1126#ifdef CONFIG_PM
1127static int gsc_m2m_suspend(struct gsc_dev *gsc)
1158{ 1128{
1159 struct gsc_dev *gsc = dev_get_drvdata(dev); 1129 unsigned long flags;
1160 int ret = 0; 1130 int timeout;
1161
1162 pr_debug("gsc%d: state: 0x%lx", gsc->id, gsc->state);
1163 1131
1164 ret = clk_enable(gsc->clock); 1132 spin_lock_irqsave(&gsc->slock, flags);
1165 if (ret) 1133 if (!gsc_m2m_pending(gsc)) {
1166 return ret; 1134 spin_unlock_irqrestore(&gsc->slock, flags);
1135 return 0;
1136 }
1137 clear_bit(ST_M2M_SUSPENDED, &gsc->state);
1138 set_bit(ST_M2M_SUSPENDING, &gsc->state);
1139 spin_unlock_irqrestore(&gsc->slock, flags);
1167 1140
1168 gsc_hw_set_sw_reset(gsc); 1141 timeout = wait_event_timeout(gsc->irq_queue,
1169 gsc_wait_reset(gsc); 1142 test_bit(ST_M2M_SUSPENDED, &gsc->state),
1143 GSC_SHUTDOWN_TIMEOUT);
1170 1144
1171 return gsc_m2m_resume(gsc); 1145 clear_bit(ST_M2M_SUSPENDING, &gsc->state);
1146 return timeout == 0 ? -EAGAIN : 0;
1172} 1147}
1173 1148
1174static int gsc_runtime_suspend(struct device *dev) 1149static void gsc_m2m_resume(struct gsc_dev *gsc)
1175{ 1150{
1176 struct gsc_dev *gsc = dev_get_drvdata(dev); 1151 struct gsc_ctx *ctx;
1177 int ret = 0; 1152 unsigned long flags;
1178 1153
1179 ret = gsc_m2m_suspend(gsc); 1154 spin_lock_irqsave(&gsc->slock, flags);
1180 if (!ret) 1155 /* Clear for full H/W setup in first run after resume */
1181 clk_disable(gsc->clock); 1156 ctx = gsc->m2m.ctx;
1157 gsc->m2m.ctx = NULL;
1158 spin_unlock_irqrestore(&gsc->slock, flags);
1182 1159
1183 pr_debug("gsc%d: state: 0x%lx", gsc->id, gsc->state); 1160 if (test_and_clear_bit(ST_M2M_SUSPENDED, &gsc->state))
1184 return ret; 1161 gsc_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
1185} 1162}
1186 1163
1187static int gsc_resume(struct device *dev) 1164static int gsc_runtime_resume(struct device *dev)
1188{ 1165{
1189 struct gsc_dev *gsc = dev_get_drvdata(dev); 1166 struct gsc_dev *gsc = dev_get_drvdata(dev);
1190 unsigned long flags; 1167 int ret = 0;
1168 int i;
1191 1169
1192 pr_debug("gsc%d: state: 0x%lx", gsc->id, gsc->state); 1170 pr_debug("gsc%d: state: 0x%lx\n", gsc->id, gsc->state);
1193 1171
1194 /* Do not resume if the device was idle before system suspend */ 1172 for (i = 0; i < gsc->num_clocks; i++) {
1195 spin_lock_irqsave(&gsc->slock, flags); 1173 ret = clk_prepare_enable(gsc->clock[i]);
1196 if (!test_and_clear_bit(ST_SUSPEND, &gsc->state) || 1174 if (ret) {
1197 !gsc_m2m_opened(gsc)) { 1175 while (--i >= 0)
1198 spin_unlock_irqrestore(&gsc->slock, flags); 1176 clk_disable_unprepare(gsc->clock[i]);
1199 return 0; 1177 return ret;
1178 }
1200 } 1179 }
1201 spin_unlock_irqrestore(&gsc->slock, flags);
1202 1180
1203 if (!pm_runtime_suspended(dev)) 1181 gsc_hw_set_sw_reset(gsc);
1204 return gsc_runtime_resume(dev); 1182 gsc_wait_reset(gsc);
1183 gsc_m2m_resume(gsc);
1205 1184
1206 return 0; 1185 return 0;
1207} 1186}
1208 1187
1209static int gsc_suspend(struct device *dev) 1188static int gsc_runtime_suspend(struct device *dev)
1210{ 1189{
1211 struct gsc_dev *gsc = dev_get_drvdata(dev); 1190 struct gsc_dev *gsc = dev_get_drvdata(dev);
1191 int ret = 0;
1192 int i;
1212 1193
1213 pr_debug("gsc%d: state: 0x%lx", gsc->id, gsc->state); 1194 ret = gsc_m2m_suspend(gsc);
1214 1195 if (ret)
1215 if (test_and_set_bit(ST_SUSPEND, &gsc->state)) 1196 return ret;
1216 return 0;
1217 1197
1218 if (!pm_runtime_suspended(dev)) 1198 for (i = gsc->num_clocks - 1; i >= 0; i--)
1219 return gsc_runtime_suspend(dev); 1199 clk_disable_unprepare(gsc->clock[i]);
1220 1200
1221 return 0; 1201 pr_debug("gsc%d: state: 0x%lx\n", gsc->id, gsc->state);
1202 return ret;
1222} 1203}
1204#endif
1223 1205
1224static const struct dev_pm_ops gsc_pm_ops = { 1206static const struct dev_pm_ops gsc_pm_ops = {
1225 .suspend = gsc_suspend, 1207 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
1226 .resume = gsc_resume, 1208 pm_runtime_force_resume)
1227 .runtime_suspend = gsc_runtime_suspend, 1209 SET_RUNTIME_PM_OPS(gsc_runtime_suspend, gsc_runtime_resume, NULL)
1228 .runtime_resume = gsc_runtime_resume,
1229}; 1210};
1230 1211
1231static struct platform_driver gsc_driver = { 1212static struct platform_driver gsc_driver = {
diff --git a/drivers/media/platform/exynos-gsc/gsc-core.h b/drivers/media/platform/exynos-gsc/gsc-core.h
index 7ad7b9dc2243..696217e9af66 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.h
+++ b/drivers/media/platform/exynos-gsc/gsc-core.h
@@ -33,6 +33,7 @@
33 33
34#define GSC_SHUTDOWN_TIMEOUT ((100*HZ)/1000) 34#define GSC_SHUTDOWN_TIMEOUT ((100*HZ)/1000)
35#define GSC_MAX_DEVS 4 35#define GSC_MAX_DEVS 4
36#define GSC_MAX_CLOCKS 4
36#define GSC_M2M_BUF_NUM 0 37#define GSC_M2M_BUF_NUM 0
37#define GSC_MAX_CTRL_NUM 10 38#define GSC_MAX_CTRL_NUM 10
38#define GSC_SC_ALIGN_4 4 39#define GSC_SC_ALIGN_4 4
@@ -48,9 +49,6 @@
48#define GSC_CTX_ABORT (1 << 7) 49#define GSC_CTX_ABORT (1 << 7)
49 50
50enum gsc_dev_flags { 51enum gsc_dev_flags {
51 /* for global */
52 ST_SUSPEND,
53
54 /* for m2m node */ 52 /* for m2m node */
55 ST_M2M_OPEN, 53 ST_M2M_OPEN,
56 ST_M2M_RUN, 54 ST_M2M_RUN,
@@ -306,12 +304,12 @@ struct gsc_variant {
306 * struct gsc_driverdata - per device type driver data for init time. 304 * struct gsc_driverdata - per device type driver data for init time.
307 * 305 *
308 * @variant: the variant information for this driver. 306 * @variant: the variant information for this driver.
309 * @lclk_frequency: G-Scaler clock frequency
310 * @num_entities: the number of g-scalers 307 * @num_entities: the number of g-scalers
311 */ 308 */
312struct gsc_driverdata { 309struct gsc_driverdata {
313 struct gsc_variant *variant[GSC_MAX_DEVS]; 310 struct gsc_variant *variant[GSC_MAX_DEVS];
314 unsigned long lclk_frequency; 311 const char *clk_names[GSC_MAX_CLOCKS];
312 int num_clocks;
315 int num_entities; 313 int num_entities;
316}; 314};
317 315
@@ -335,7 +333,8 @@ struct gsc_dev {
335 struct platform_device *pdev; 333 struct platform_device *pdev;
336 struct gsc_variant *variant; 334 struct gsc_variant *variant;
337 u16 id; 335 u16 id;
338 struct clk *clock; 336 int num_clocks;
337 struct clk *clock[GSC_MAX_CLOCKS];
339 void __iomem *regs; 338 void __iomem *regs;
340 wait_queue_head_t irq_queue; 339 wait_queue_head_t irq_queue;
341 struct gsc_m2m_device m2m; 340 struct gsc_m2m_device m2m;
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index 9f03b791b711..f49f24b4462a 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -66,12 +66,29 @@ static int gsc_m2m_start_streaming(struct vb2_queue *q, unsigned int count)
66 return ret > 0 ? 0 : ret; 66 return ret > 0 ? 0 : ret;
67} 67}
68 68
69static void __gsc_m2m_cleanup_queue(struct gsc_ctx *ctx)
70{
71 struct vb2_v4l2_buffer *src_vb, *dst_vb;
72
73 while (v4l2_m2m_num_src_bufs_ready(ctx->m2m_ctx) > 0) {
74 src_vb = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
75 v4l2_m2m_buf_done(src_vb, VB2_BUF_STATE_ERROR);
76 }
77
78 while (v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx) > 0) {
79 dst_vb = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
80 v4l2_m2m_buf_done(dst_vb, VB2_BUF_STATE_ERROR);
81 }
82}
83
69static void gsc_m2m_stop_streaming(struct vb2_queue *q) 84static void gsc_m2m_stop_streaming(struct vb2_queue *q)
70{ 85{
71 struct gsc_ctx *ctx = q->drv_priv; 86 struct gsc_ctx *ctx = q->drv_priv;
72 87
73 __gsc_m2m_job_abort(ctx); 88 __gsc_m2m_job_abort(ctx);
74 89
90 __gsc_m2m_cleanup_queue(ctx);
91
75 pm_runtime_put(&ctx->gsc_dev->pdev->dev); 92 pm_runtime_put(&ctx->gsc_dev->pdev->dev);
76} 93}
77 94
@@ -365,14 +382,8 @@ static int gsc_m2m_reqbufs(struct file *file, void *fh,
365 382
366 max_cnt = (reqbufs->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) ? 383 max_cnt = (reqbufs->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) ?
367 gsc->variant->in_buf_cnt : gsc->variant->out_buf_cnt; 384 gsc->variant->in_buf_cnt : gsc->variant->out_buf_cnt;
368 if (reqbufs->count > max_cnt) { 385 if (reqbufs->count > max_cnt)
369 return -EINVAL; 386 return -EINVAL;
370 } else if (reqbufs->count == 0) {
371 if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
372 gsc_ctx_state_lock_clear(GSC_SRC_FMT, ctx);
373 else
374 gsc_ctx_state_lock_clear(GSC_DST_FMT, ctx);
375 }
376 387
377 return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs); 388 return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
378} 389}
@@ -766,30 +777,29 @@ int gsc_register_m2m_device(struct gsc_dev *gsc)
766 gsc->m2m.m2m_dev = v4l2_m2m_init(&gsc_m2m_ops); 777 gsc->m2m.m2m_dev = v4l2_m2m_init(&gsc_m2m_ops);
767 if (IS_ERR(gsc->m2m.m2m_dev)) { 778 if (IS_ERR(gsc->m2m.m2m_dev)) {
768 dev_err(&pdev->dev, "failed to initialize v4l2-m2m device\n"); 779 dev_err(&pdev->dev, "failed to initialize v4l2-m2m device\n");
769 ret = PTR_ERR(gsc->m2m.m2m_dev); 780 return PTR_ERR(gsc->m2m.m2m_dev);
770 goto err_m2m_r1;
771 } 781 }
772 782
773 ret = video_register_device(&gsc->vdev, VFL_TYPE_GRABBER, -1); 783 ret = video_register_device(&gsc->vdev, VFL_TYPE_GRABBER, -1);
774 if (ret) { 784 if (ret) {
775 dev_err(&pdev->dev, 785 dev_err(&pdev->dev,
776 "%s(): failed to register video device\n", __func__); 786 "%s(): failed to register video device\n", __func__);
777 goto err_m2m_r2; 787 goto err_m2m_release;
778 } 788 }
779 789
780 pr_debug("gsc m2m driver registered as /dev/video%d", gsc->vdev.num); 790 pr_debug("gsc m2m driver registered as /dev/video%d", gsc->vdev.num);
781 return 0; 791 return 0;
782 792
783err_m2m_r2: 793err_m2m_release:
784 v4l2_m2m_release(gsc->m2m.m2m_dev); 794 v4l2_m2m_release(gsc->m2m.m2m_dev);
785err_m2m_r1:
786 video_device_release(gsc->m2m.vfd);
787 795
788 return ret; 796 return ret;
789} 797}
790 798
791void gsc_unregister_m2m_device(struct gsc_dev *gsc) 799void gsc_unregister_m2m_device(struct gsc_dev *gsc)
792{ 800{
793 if (gsc) 801 if (gsc) {
794 v4l2_m2m_release(gsc->m2m.m2m_dev); 802 v4l2_m2m_release(gsc->m2m.m2m_dev);
803 video_unregister_device(&gsc->vdev);
804 }
795} 805}
diff --git a/drivers/media/platform/exynos4-is/fimc-core.c b/drivers/media/platform/exynos4-is/fimc-core.c
index 8f89ca21b631..099c735a39b7 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.c
+++ b/drivers/media/platform/exynos4-is/fimc-core.c
@@ -736,6 +736,7 @@ void fimc_adjust_mplane_format(struct fimc_fmt *fmt, u32 width, u32 height,
736 for (i = 0; i < pix->num_planes; ++i) { 736 for (i = 0; i < pix->num_planes; ++i) {
737 struct v4l2_plane_pix_format *plane_fmt = &pix->plane_fmt[i]; 737 struct v4l2_plane_pix_format *plane_fmt = &pix->plane_fmt[i];
738 u32 bpl = plane_fmt->bytesperline; 738 u32 bpl = plane_fmt->bytesperline;
739 u32 sizeimage;
739 740
740 if (fmt->colplanes > 1 && (bpl == 0 || bpl < pix->width)) 741 if (fmt->colplanes > 1 && (bpl == 0 || bpl < pix->width))
741 bpl = pix->width; /* Planar */ 742 bpl = pix->width; /* Planar */
@@ -755,8 +756,17 @@ void fimc_adjust_mplane_format(struct fimc_fmt *fmt, u32 width, u32 height,
755 bytesperline /= 2; 756 bytesperline /= 2;
756 757
757 plane_fmt->bytesperline = bytesperline; 758 plane_fmt->bytesperline = bytesperline;
758 plane_fmt->sizeimage = max((pix->width * pix->height * 759 sizeimage = pix->width * pix->height * fmt->depth[i] / 8;
759 fmt->depth[i]) / 8, plane_fmt->sizeimage); 760
761 /* Ensure full last row for tiled formats */
762 if (tiled_fmt(fmt)) {
763 /* 64 * 32 * plane_fmt->bytesperline / 64 */
764 u32 row_size = plane_fmt->bytesperline * 32;
765
766 sizeimage = roundup(sizeimage, row_size);
767 }
768
769 plane_fmt->sizeimage = max(sizeimage, plane_fmt->sizeimage);
760 } 770 }
761} 771}
762 772
diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index 1a1154a9dfa4..e3a8709138fa 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -938,8 +938,7 @@ static int fimc_md_create_links(struct fimc_md *fmd)
938 938
939 csis = fmd->csis[pdata->mux_id].sd; 939 csis = fmd->csis[pdata->mux_id].sd;
940 if (WARN(csis == NULL, 940 if (WARN(csis == NULL,
941 "MIPI-CSI interface specified " 941 "MIPI-CSI interface specified but s5p-csis module is not loaded!\n"))
942 "but s5p-csis module is not loaded!\n"))
943 return -EINVAL; 942 return -EINVAL;
944 943
945 pad = sensor->entity.num_pads - 1; 944 pad = sensor->entity.num_pads - 1;
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index af59bf4dca2d..a8bda6679422 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -49,24 +49,17 @@
49static bool alloc_bufs_at_read; 49static bool alloc_bufs_at_read;
50module_param(alloc_bufs_at_read, bool, 0444); 50module_param(alloc_bufs_at_read, bool, 0444);
51MODULE_PARM_DESC(alloc_bufs_at_read, 51MODULE_PARM_DESC(alloc_bufs_at_read,
52 "Non-zero value causes DMA buffers to be allocated when the " 52 "Non-zero value causes DMA buffers to be allocated when the video capture device is read, rather than at module load time. This saves memory, but decreases the chances of successfully getting those buffers. This parameter is only used in the vmalloc buffer mode");
53 "video capture device is read, rather than at module load "
54 "time. This saves memory, but decreases the chances of "
55 "successfully getting those buffers. This parameter is "
56 "only used in the vmalloc buffer mode");
57 53
58static int n_dma_bufs = 3; 54static int n_dma_bufs = 3;
59module_param(n_dma_bufs, uint, 0644); 55module_param(n_dma_bufs, uint, 0644);
60MODULE_PARM_DESC(n_dma_bufs, 56MODULE_PARM_DESC(n_dma_bufs,
61 "The number of DMA buffers to allocate. Can be either two " 57 "The number of DMA buffers to allocate. Can be either two (saves memory, makes timing tighter) or three.");
62 "(saves memory, makes timing tighter) or three.");
63 58
64static int dma_buf_size = VGA_WIDTH * VGA_HEIGHT * 2; /* Worst case */ 59static int dma_buf_size = VGA_WIDTH * VGA_HEIGHT * 2; /* Worst case */
65module_param(dma_buf_size, uint, 0444); 60module_param(dma_buf_size, uint, 0444);
66MODULE_PARM_DESC(dma_buf_size, 61MODULE_PARM_DESC(dma_buf_size,
67 "The size of the allocated DMA buffers. If actual operating " 62 "The size of the allocated DMA buffers. If actual operating parameters require larger buffers, an attempt to reallocate will be made.");
68 "parameters require larger buffers, an attempt to reallocate "
69 "will be made.");
70#else /* MCAM_MODE_VMALLOC */ 63#else /* MCAM_MODE_VMALLOC */
71static const bool alloc_bufs_at_read; 64static const bool alloc_bufs_at_read;
72static const int n_dma_bufs = 3; /* Used by S/G_PARM */ 65static const int n_dma_bufs = 3; /* Used by S/G_PARM */
@@ -75,15 +68,12 @@ static const int n_dma_bufs = 3; /* Used by S/G_PARM */
75static bool flip; 68static bool flip;
76module_param(flip, bool, 0444); 69module_param(flip, bool, 0444);
77MODULE_PARM_DESC(flip, 70MODULE_PARM_DESC(flip,
78 "If set, the sensor will be instructed to flip the image " 71 "If set, the sensor will be instructed to flip the image vertically.");
79 "vertically.");
80 72
81static int buffer_mode = -1; 73static int buffer_mode = -1;
82module_param(buffer_mode, int, 0444); 74module_param(buffer_mode, int, 0444);
83MODULE_PARM_DESC(buffer_mode, 75MODULE_PARM_DESC(buffer_mode,
84 "Set the buffer mode to be used; default is to go with what " 76 "Set the buffer mode to be used; default is to go with what the platform driver asks for. Set to 0 for vmalloc, 1 for DMA contiguous.");
85 "the platform driver asks for. Set to 0 for vmalloc, 1 for "
86 "DMA contiguous.");
87 77
88/* 78/*
89 * Status flags. Always manipulated with bit operations. 79 * Status flags. Always manipulated with bit operations.
@@ -1759,8 +1749,7 @@ int mccic_register(struct mcam_camera *cam)
1759 cam->buffer_mode = buffer_mode; 1749 cam->buffer_mode = buffer_mode;
1760 if (cam->buffer_mode == B_DMA_sg && 1750 if (cam->buffer_mode == B_DMA_sg &&
1761 cam->chip_id == MCAM_CAFE) { 1751 cam->chip_id == MCAM_CAFE) {
1762 printk(KERN_ERR "marvell-cam: Cafe can't do S/G I/O, " 1752 printk(KERN_ERR "marvell-cam: Cafe can't do S/G I/O, attempting vmalloc mode instead\n");
1763 "attempting vmalloc mode instead\n");
1764 cam->buffer_mode = B_vmalloc; 1753 cam->buffer_mode = B_vmalloc;
1765 } 1754 }
1766 if (!mcam_buffer_mode_supported(cam->buffer_mode)) { 1755 if (!mcam_buffer_mode_supported(cam->buffer_mode)) {
@@ -1828,8 +1817,7 @@ int mccic_register(struct mcam_camera *cam)
1828 */ 1817 */
1829 if (cam->buffer_mode == B_vmalloc && !alloc_bufs_at_read) { 1818 if (cam->buffer_mode == B_vmalloc && !alloc_bufs_at_read) {
1830 if (mcam_alloc_dma_bufs(cam, 1)) 1819 if (mcam_alloc_dma_bufs(cam, 1))
1831 cam_warn(cam, "Unable to alloc DMA buffers at load" 1820 cam_warn(cam, "Unable to alloc DMA buffers at load will try again later.");
1832 " will try again later.");
1833 } 1821 }
1834 1822
1835 mutex_unlock(&cam->s_mutex); 1823 mutex_unlock(&cam->s_mutex);
diff --git a/drivers/media/platform/mtk-mdp/Makefile b/drivers/media/platform/mtk-mdp/Makefile
new file mode 100644
index 000000000000..f8025699af99
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/Makefile
@@ -0,0 +1,9 @@
1mtk-mdp-y += mtk_mdp_core.o
2mtk-mdp-y += mtk_mdp_comp.o
3mtk-mdp-y += mtk_mdp_m2m.o
4mtk-mdp-y += mtk_mdp_regs.o
5mtk-mdp-y += mtk_mdp_vpu.o
6
7obj-$(CONFIG_VIDEO_MEDIATEK_MDP) += mtk-mdp.o
8
9ccflags-y += -I$(srctree)/drivers/media/platform/mtk-vpu
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
new file mode 100644
index 000000000000..aa8f9fd1f1a2
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
@@ -0,0 +1,159 @@
1/*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: Ming Hsiu Tsai <minghsiu.tsai@mediatek.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 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#include <linux/clk.h>
16#include <linux/device.h>
17#include <linux/of.h>
18#include <linux/of_address.h>
19#include <linux/of_platform.h>
20#include <soc/mediatek/smi.h>
21
22#include "mtk_mdp_comp.h"
23
24
25static const char * const mtk_mdp_comp_stem[MTK_MDP_COMP_TYPE_MAX] = {
26 "mdp_rdma",
27 "mdp_rsz",
28 "mdp_wdma",
29 "mdp_wrot",
30};
31
32struct mtk_mdp_comp_match {
33 enum mtk_mdp_comp_type type;
34 int alias_id;
35};
36
37static const struct mtk_mdp_comp_match mtk_mdp_matches[MTK_MDP_COMP_ID_MAX] = {
38 { MTK_MDP_RDMA, 0 },
39 { MTK_MDP_RDMA, 1 },
40 { MTK_MDP_RSZ, 0 },
41 { MTK_MDP_RSZ, 1 },
42 { MTK_MDP_RSZ, 2 },
43 { MTK_MDP_WDMA, 0 },
44 { MTK_MDP_WROT, 0 },
45 { MTK_MDP_WROT, 1 },
46};
47
48int mtk_mdp_comp_get_id(struct device *dev, struct device_node *node,
49 enum mtk_mdp_comp_type comp_type)
50{
51 int id = of_alias_get_id(node, mtk_mdp_comp_stem[comp_type]);
52 int i;
53
54 for (i = 0; i < ARRAY_SIZE(mtk_mdp_matches); i++) {
55 if (comp_type == mtk_mdp_matches[i].type &&
56 id == mtk_mdp_matches[i].alias_id)
57 return i;
58 }
59
60 dev_err(dev, "Failed to get id. type: %d, id: %d\n", comp_type, id);
61
62 return -EINVAL;
63}
64
65void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp)
66{
67 int i, err;
68
69 if (comp->larb_dev) {
70 err = mtk_smi_larb_get(comp->larb_dev);
71 if (err)
72 dev_err(dev,
73 "failed to get larb, err %d. type:%d id:%d\n",
74 err, comp->type, comp->id);
75 }
76
77 for (i = 0; i < ARRAY_SIZE(comp->clk); i++) {
78 if (!comp->clk[i])
79 continue;
80 err = clk_prepare_enable(comp->clk[i]);
81 if (err)
82 dev_err(dev,
83 "failed to enable clock, err %d. type:%d id:%d i:%d\n",
84 err, comp->type, comp->id, i);
85 }
86}
87
88void mtk_mdp_comp_clock_off(struct device *dev, struct mtk_mdp_comp *comp)
89{
90 int i;
91
92 for (i = 0; i < ARRAY_SIZE(comp->clk); i++) {
93 if (!comp->clk[i])
94 continue;
95 clk_disable_unprepare(comp->clk[i]);
96 }
97
98 if (comp->larb_dev)
99 mtk_smi_larb_put(comp->larb_dev);
100}
101
102int mtk_mdp_comp_init(struct device *dev, struct device_node *node,
103 struct mtk_mdp_comp *comp, enum mtk_mdp_comp_id comp_id)
104{
105 struct device_node *larb_node;
106 struct platform_device *larb_pdev;
107 int i;
108
109 if (comp_id < 0 || comp_id >= MTK_MDP_COMP_ID_MAX) {
110 dev_err(dev, "Invalid comp_id %d\n", comp_id);
111 return -EINVAL;
112 }
113
114 comp->dev_node = of_node_get(node);
115 comp->id = comp_id;
116 comp->type = mtk_mdp_matches[comp_id].type;
117 comp->regs = of_iomap(node, 0);
118
119 for (i = 0; i < ARRAY_SIZE(comp->clk); i++) {
120 comp->clk[i] = of_clk_get(node, i);
121
122 /* Only RDMA needs two clocks */
123 if (comp->type != MTK_MDP_RDMA)
124 break;
125 }
126
127 /* Only DMA capable components need the LARB property */
128 comp->larb_dev = NULL;
129 if (comp->type != MTK_MDP_RDMA &&
130 comp->type != MTK_MDP_WDMA &&
131 comp->type != MTK_MDP_WROT)
132 return 0;
133
134 larb_node = of_parse_phandle(node, "mediatek,larb", 0);
135 if (!larb_node) {
136 dev_err(dev,
137 "Missing mediadek,larb phandle in %s node\n",
138 node->full_name);
139 return -EINVAL;
140 }
141
142 larb_pdev = of_find_device_by_node(larb_node);
143 if (!larb_pdev) {
144 dev_warn(dev, "Waiting for larb device %s\n",
145 larb_node->full_name);
146 of_node_put(larb_node);
147 return -EPROBE_DEFER;
148 }
149 of_node_put(larb_node);
150
151 comp->larb_dev = &larb_pdev->dev;
152
153 return 0;
154}
155
156void mtk_mdp_comp_deinit(struct device *dev, struct mtk_mdp_comp *comp)
157{
158 of_node_put(comp->dev_node);
159}
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h
new file mode 100644
index 000000000000..63b3983ef1a4
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h
@@ -0,0 +1,72 @@
1/*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: Ming Hsiu Tsai <minghsiu.tsai@mediatek.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 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#ifndef __MTK_MDP_COMP_H__
16#define __MTK_MDP_COMP_H__
17
18/**
19 * enum mtk_mdp_comp_type - the MDP component
20 * @MTK_MDP_RDMA: Read DMA
21 * @MTK_MDP_RSZ: Riszer
22 * @MTK_MDP_WDMA: Write DMA
23 * @MTK_MDP_WROT: Write DMA with rotation
24 */
25enum mtk_mdp_comp_type {
26 MTK_MDP_RDMA,
27 MTK_MDP_RSZ,
28 MTK_MDP_WDMA,
29 MTK_MDP_WROT,
30 MTK_MDP_COMP_TYPE_MAX,
31};
32
33enum mtk_mdp_comp_id {
34 MTK_MDP_COMP_RDMA0,
35 MTK_MDP_COMP_RDMA1,
36 MTK_MDP_COMP_RSZ0,
37 MTK_MDP_COMP_RSZ1,
38 MTK_MDP_COMP_RSZ2,
39 MTK_MDP_COMP_WDMA,
40 MTK_MDP_COMP_WROT0,
41 MTK_MDP_COMP_WROT1,
42 MTK_MDP_COMP_ID_MAX,
43};
44
45/**
46 * struct mtk_mdp_comp - the MDP's function component data
47 * @dev_node: component device node
48 * @clk: clocks required for component
49 * @regs: Mapped address of component registers.
50 * @larb_dev: SMI device required for component
51 * @type: component type
52 * @id: component ID
53 */
54struct mtk_mdp_comp {
55 struct device_node *dev_node;
56 struct clk *clk[2];
57 void __iomem *regs;
58 struct device *larb_dev;
59 enum mtk_mdp_comp_type type;
60 enum mtk_mdp_comp_id id;
61};
62
63int mtk_mdp_comp_init(struct device *dev, struct device_node *node,
64 struct mtk_mdp_comp *comp, enum mtk_mdp_comp_id comp_id);
65void mtk_mdp_comp_deinit(struct device *dev, struct mtk_mdp_comp *comp);
66int mtk_mdp_comp_get_id(struct device *dev, struct device_node *node,
67 enum mtk_mdp_comp_type comp_type);
68void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp);
69void mtk_mdp_comp_clock_off(struct device *dev, struct mtk_mdp_comp *comp);
70
71
72#endif /* __MTK_MDP_COMP_H__ */
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
new file mode 100644
index 000000000000..9e4eb7dcc424
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
@@ -0,0 +1,290 @@
1/*
2 * Copyright (c) 2015-2016 MediaTek Inc.
3 * Author: Houlong Wei <houlong.wei@mediatek.com>
4 * Ming Hsiu Tsai <minghsiu.tsai@mediatek.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 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/clk.h>
17#include <linux/device.h>
18#include <linux/errno.h>
19#include <linux/interrupt.h>
20#include <linux/kernel.h>
21#include <linux/module.h>
22#include <linux/of.h>
23#include <linux/of_address.h>
24#include <linux/of_platform.h>
25#include <linux/platform_device.h>
26#include <linux/pm_runtime.h>
27#include <linux/workqueue.h>
28#include <soc/mediatek/smi.h>
29
30#include "mtk_mdp_core.h"
31#include "mtk_mdp_m2m.h"
32#include "mtk_vpu.h"
33
34/* MDP debug log level (0-3). 3 shows all the logs. */
35int mtk_mdp_dbg_level;
36EXPORT_SYMBOL(mtk_mdp_dbg_level);
37
38module_param(mtk_mdp_dbg_level, int, 0644);
39
40static const struct of_device_id mtk_mdp_comp_dt_ids[] = {
41 {
42 .compatible = "mediatek,mt8173-mdp-rdma",
43 .data = (void *)MTK_MDP_RDMA
44 }, {
45 .compatible = "mediatek,mt8173-mdp-rsz",
46 .data = (void *)MTK_MDP_RSZ
47 }, {
48 .compatible = "mediatek,mt8173-mdp-wdma",
49 .data = (void *)MTK_MDP_WDMA
50 }, {
51 .compatible = "mediatek,mt8173-mdp-wrot",
52 .data = (void *)MTK_MDP_WROT
53 },
54 { },
55};
56
57static const struct of_device_id mtk_mdp_of_ids[] = {
58 { .compatible = "mediatek,mt8173-mdp", },
59 { },
60};
61MODULE_DEVICE_TABLE(of, mtk_mdp_of_ids);
62
63static void mtk_mdp_clock_on(struct mtk_mdp_dev *mdp)
64{
65 struct device *dev = &mdp->pdev->dev;
66 int i;
67
68 for (i = 0; i < ARRAY_SIZE(mdp->comp); i++)
69 mtk_mdp_comp_clock_on(dev, mdp->comp[i]);
70}
71
72static void mtk_mdp_clock_off(struct mtk_mdp_dev *mdp)
73{
74 struct device *dev = &mdp->pdev->dev;
75 int i;
76
77 for (i = 0; i < ARRAY_SIZE(mdp->comp); i++)
78 mtk_mdp_comp_clock_off(dev, mdp->comp[i]);
79}
80
81static void mtk_mdp_wdt_worker(struct work_struct *work)
82{
83 struct mtk_mdp_dev *mdp =
84 container_of(work, struct mtk_mdp_dev, wdt_work);
85 struct mtk_mdp_ctx *ctx;
86
87 mtk_mdp_err("Watchdog timeout");
88
89 list_for_each_entry(ctx, &mdp->ctx_list, list) {
90 mtk_mdp_dbg(0, "[%d] Change as state error", ctx->id);
91 mtk_mdp_ctx_state_lock_set(ctx, MTK_MDP_CTX_ERROR);
92 }
93}
94
95static void mtk_mdp_reset_handler(void *priv)
96{
97 struct mtk_mdp_dev *mdp = priv;
98
99 queue_work(mdp->wdt_wq, &mdp->wdt_work);
100}
101
102static int mtk_mdp_probe(struct platform_device *pdev)
103{
104 struct mtk_mdp_dev *mdp;
105 struct device *dev = &pdev->dev;
106 struct device_node *node;
107 int i, ret = 0;
108
109 mdp = devm_kzalloc(dev, sizeof(*mdp), GFP_KERNEL);
110 if (!mdp)
111 return -ENOMEM;
112
113 mdp->id = pdev->id;
114 mdp->pdev = pdev;
115 INIT_LIST_HEAD(&mdp->ctx_list);
116
117 mutex_init(&mdp->lock);
118 mutex_init(&mdp->vpulock);
119
120 /* Iterate over sibling MDP function blocks */
121 for_each_child_of_node(dev->of_node, node) {
122 const struct of_device_id *of_id;
123 enum mtk_mdp_comp_type comp_type;
124 int comp_id;
125 struct mtk_mdp_comp *comp;
126
127 of_id = of_match_node(mtk_mdp_comp_dt_ids, node);
128 if (!of_id)
129 continue;
130
131 if (!of_device_is_available(node)) {
132 dev_err(dev, "Skipping disabled component %s\n",
133 node->full_name);
134 continue;
135 }
136
137 comp_type = (enum mtk_mdp_comp_type)of_id->data;
138 comp_id = mtk_mdp_comp_get_id(dev, node, comp_type);
139 if (comp_id < 0) {
140 dev_warn(dev, "Skipping unknown component %s\n",
141 node->full_name);
142 continue;
143 }
144
145 comp = devm_kzalloc(dev, sizeof(*comp), GFP_KERNEL);
146 if (!comp) {
147 ret = -ENOMEM;
148 goto err_comp;
149 }
150 mdp->comp[comp_id] = comp;
151
152 ret = mtk_mdp_comp_init(dev, node, comp, comp_id);
153 if (ret)
154 goto err_comp;
155 }
156
157 mdp->job_wq = create_singlethread_workqueue(MTK_MDP_MODULE_NAME);
158 if (!mdp->job_wq) {
159 dev_err(&pdev->dev, "unable to alloc job workqueue\n");
160 ret = -ENOMEM;
161 goto err_alloc_job_wq;
162 }
163
164 mdp->wdt_wq = create_singlethread_workqueue("mdp_wdt_wq");
165 if (!mdp->wdt_wq) {
166 dev_err(&pdev->dev, "unable to alloc wdt workqueue\n");
167 ret = -ENOMEM;
168 goto err_alloc_wdt_wq;
169 }
170 INIT_WORK(&mdp->wdt_work, mtk_mdp_wdt_worker);
171
172 ret = v4l2_device_register(dev, &mdp->v4l2_dev);
173 if (ret) {
174 dev_err(&pdev->dev, "Failed to register v4l2 device\n");
175 ret = -EINVAL;
176 goto err_dev_register;
177 }
178
179 ret = mtk_mdp_register_m2m_device(mdp);
180 if (ret) {
181 v4l2_err(&mdp->v4l2_dev, "Failed to init mem2mem device\n");
182 goto err_m2m_register;
183 }
184
185 mdp->vpu_dev = vpu_get_plat_device(pdev);
186 vpu_wdt_reg_handler(mdp->vpu_dev, mtk_mdp_reset_handler, mdp,
187 VPU_RST_MDP);
188
189 platform_set_drvdata(pdev, mdp);
190
191 vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32));
192
193 pm_runtime_enable(dev);
194 dev_dbg(dev, "mdp-%d registered successfully\n", mdp->id);
195
196 return 0;
197
198err_m2m_register:
199 v4l2_device_unregister(&mdp->v4l2_dev);
200
201err_dev_register:
202 destroy_workqueue(mdp->wdt_wq);
203
204err_alloc_wdt_wq:
205 destroy_workqueue(mdp->job_wq);
206
207err_alloc_job_wq:
208
209err_comp:
210 for (i = 0; i < ARRAY_SIZE(mdp->comp); i++)
211 mtk_mdp_comp_deinit(dev, mdp->comp[i]);
212
213 dev_dbg(dev, "err %d\n", ret);
214 return ret;
215}
216
217static int mtk_mdp_remove(struct platform_device *pdev)
218{
219 struct mtk_mdp_dev *mdp = platform_get_drvdata(pdev);
220 int i;
221
222 pm_runtime_disable(&pdev->dev);
223 vb2_dma_contig_clear_max_seg_size(&pdev->dev);
224 mtk_mdp_unregister_m2m_device(mdp);
225 v4l2_device_unregister(&mdp->v4l2_dev);
226
227 flush_workqueue(mdp->job_wq);
228 destroy_workqueue(mdp->job_wq);
229
230 for (i = 0; i < ARRAY_SIZE(mdp->comp); i++)
231 mtk_mdp_comp_deinit(&pdev->dev, mdp->comp[i]);
232
233 dev_dbg(&pdev->dev, "%s driver unloaded\n", pdev->name);
234 return 0;
235}
236
237static int __maybe_unused mtk_mdp_pm_suspend(struct device *dev)
238{
239 struct mtk_mdp_dev *mdp = dev_get_drvdata(dev);
240
241 mtk_mdp_clock_off(mdp);
242
243 return 0;
244}
245
246static int __maybe_unused mtk_mdp_pm_resume(struct device *dev)
247{
248 struct mtk_mdp_dev *mdp = dev_get_drvdata(dev);
249
250 mtk_mdp_clock_on(mdp);
251
252 return 0;
253}
254
255static int __maybe_unused mtk_mdp_suspend(struct device *dev)
256{
257 if (pm_runtime_suspended(dev))
258 return 0;
259
260 return mtk_mdp_pm_suspend(dev);
261}
262
263static int __maybe_unused mtk_mdp_resume(struct device *dev)
264{
265 if (pm_runtime_suspended(dev))
266 return 0;
267
268 return mtk_mdp_pm_resume(dev);
269}
270
271static const struct dev_pm_ops mtk_mdp_pm_ops = {
272 SET_SYSTEM_SLEEP_PM_OPS(mtk_mdp_suspend, mtk_mdp_resume)
273 SET_RUNTIME_PM_OPS(mtk_mdp_pm_suspend, mtk_mdp_pm_resume, NULL)
274};
275
276static struct platform_driver mtk_mdp_driver = {
277 .probe = mtk_mdp_probe,
278 .remove = mtk_mdp_remove,
279 .driver = {
280 .name = MTK_MDP_MODULE_NAME,
281 .pm = &mtk_mdp_pm_ops,
282 .of_match_table = mtk_mdp_of_ids,
283 }
284};
285
286module_platform_driver(mtk_mdp_driver);
287
288MODULE_AUTHOR("Houlong Wei <houlong.wei@mediatek.com>");
289MODULE_DESCRIPTION("Mediatek image processor driver");
290MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.h b/drivers/media/platform/mtk-mdp/mtk_mdp_core.h
new file mode 100644
index 000000000000..ad1cff306efd
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.h
@@ -0,0 +1,260 @@
1/*
2 * Copyright (c) 2015-2016 MediaTek Inc.
3 * Author: Houlong Wei <houlong.wei@mediatek.com>
4 * Ming Hsiu Tsai <minghsiu.tsai@mediatek.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 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef __MTK_MDP_CORE_H__
17#define __MTK_MDP_CORE_H__
18
19#include <linux/videodev2.h>
20#include <media/v4l2-ctrls.h>
21#include <media/v4l2-device.h>
22#include <media/v4l2-mem2mem.h>
23#include <media/videobuf2-core.h>
24#include <media/videobuf2-dma-contig.h>
25
26#include "mtk_mdp_vpu.h"
27#include "mtk_mdp_comp.h"
28
29
30#define MTK_MDP_MODULE_NAME "mtk-mdp"
31
32#define MTK_MDP_SHUTDOWN_TIMEOUT ((100*HZ)/1000) /* 100ms */
33#define MTK_MDP_MAX_CTRL_NUM 10
34
35#define MTK_MDP_FMT_FLAG_OUTPUT BIT(0)
36#define MTK_MDP_FMT_FLAG_CAPTURE BIT(1)
37
38#define MTK_MDP_VPU_INIT BIT(0)
39#define MTK_MDP_SRC_FMT BIT(1)
40#define MTK_MDP_DST_FMT BIT(2)
41#define MTK_MDP_CTX_ERROR BIT(5)
42
43/**
44 * struct mtk_mdp_pix_align - alignement of image
45 * @org_w: source alignment of width
46 * @org_h: source alignment of height
47 * @target_w: dst alignment of width
48 * @target_h: dst alignment of height
49 */
50struct mtk_mdp_pix_align {
51 u16 org_w;
52 u16 org_h;
53 u16 target_w;
54 u16 target_h;
55};
56
57/**
58 * struct mtk_mdp_fmt - the driver's internal color format data
59 * @pixelformat: the fourcc code for this format, 0 if not applicable
60 * @num_planes: number of physically non-contiguous data planes
61 * @num_comp: number of logical data planes
62 * @depth: per plane driver's private 'number of bits per pixel'
63 * @row_depth: per plane driver's private 'number of bits per pixel per row'
64 * @flags: flags indicating which operation mode format applies to
65 MTK_MDP_FMT_FLAG_OUTPUT is used in OUTPUT stream
66 MTK_MDP_FMT_FLAG_CAPTURE is used in CAPTURE stream
67 * @align: pointer to a pixel alignment struct, NULL if using default value
68 */
69struct mtk_mdp_fmt {
70 u32 pixelformat;
71 u16 num_planes;
72 u16 num_comp;
73 u8 depth[VIDEO_MAX_PLANES];
74 u8 row_depth[VIDEO_MAX_PLANES];
75 u32 flags;
76 struct mtk_mdp_pix_align *align;
77};
78
79/**
80 * struct mtk_mdp_addr - the image processor physical address set
81 * @addr: address of planes
82 */
83struct mtk_mdp_addr {
84 dma_addr_t addr[MTK_MDP_MAX_NUM_PLANE];
85};
86
87/* struct mtk_mdp_ctrls - the image processor control set
88 * @rotate: rotation degree
89 * @hflip: horizontal flip
90 * @vflip: vertical flip
91 * @global_alpha: the alpha value of current frame
92 */
93struct mtk_mdp_ctrls {
94 struct v4l2_ctrl *rotate;
95 struct v4l2_ctrl *hflip;
96 struct v4l2_ctrl *vflip;
97 struct v4l2_ctrl *global_alpha;
98};
99
100/**
101 * struct mtk_mdp_frame - source/target frame properties
102 * @width: SRC : SRCIMG_WIDTH, DST : OUTPUTDMA_WHOLE_IMG_WIDTH
103 * @height: SRC : SRCIMG_HEIGHT, DST : OUTPUTDMA_WHOLE_IMG_HEIGHT
104 * @crop: cropped(source)/scaled(destination) size
105 * @payload: image size in bytes (w x h x bpp)
106 * @pitch: bytes per line of image in memory
107 * @addr: image frame buffer physical addresses
108 * @fmt: color format pointer
109 * @alpha: frame's alpha value
110 */
111struct mtk_mdp_frame {
112 u32 width;
113 u32 height;
114 struct v4l2_rect crop;
115 unsigned long payload[VIDEO_MAX_PLANES];
116 unsigned int pitch[VIDEO_MAX_PLANES];
117 struct mtk_mdp_addr addr;
118 const struct mtk_mdp_fmt *fmt;
119 u8 alpha;
120};
121
122/**
123 * struct mtk_mdp_variant - image processor variant information
124 * @pix_max: maximum limit of image size
125 * @pix_min: minimun limit of image size
126 * @pix_align: alignement of image
127 * @h_scale_up_max: maximum scale-up in horizontal
128 * @v_scale_up_max: maximum scale-up in vertical
129 * @h_scale_down_max: maximum scale-down in horizontal
130 * @v_scale_down_max: maximum scale-down in vertical
131 */
132struct mtk_mdp_variant {
133 struct mtk_mdp_pix_limit *pix_max;
134 struct mtk_mdp_pix_limit *pix_min;
135 struct mtk_mdp_pix_align *pix_align;
136 u16 h_scale_up_max;
137 u16 v_scale_up_max;
138 u16 h_scale_down_max;
139 u16 v_scale_down_max;
140};
141
142/**
143 * struct mtk_mdp_dev - abstraction for image processor entity
144 * @lock: the mutex protecting this data structure
145 * @vpulock: the mutex protecting the communication with VPU
146 * @pdev: pointer to the image processor platform device
147 * @variant: the IP variant information
148 * @id: image processor device index (0..MTK_MDP_MAX_DEVS)
149 * @comp: MDP function components
150 * @m2m_dev: v4l2 memory-to-memory device data
151 * @ctx_list: list of struct mtk_mdp_ctx
152 * @vdev: video device for image processor driver
153 * @v4l2_dev: V4L2 device to register video devices for.
154 * @job_wq: processor work queue
155 * @vpu_dev: VPU platform device
156 * @ctx_num: counter of active MTK MDP context
157 * @id_counter: An integer id given to the next opened context
158 * @wdt_wq: work queue for VPU watchdog
159 * @wdt_work: worker for VPU watchdog
160 */
161struct mtk_mdp_dev {
162 struct mutex lock;
163 struct mutex vpulock;
164 struct platform_device *pdev;
165 struct mtk_mdp_variant *variant;
166 u16 id;
167 struct mtk_mdp_comp *comp[MTK_MDP_COMP_ID_MAX];
168 struct v4l2_m2m_dev *m2m_dev;
169 struct list_head ctx_list;
170 struct video_device *vdev;
171 struct v4l2_device v4l2_dev;
172 struct workqueue_struct *job_wq;
173 struct platform_device *vpu_dev;
174 int ctx_num;
175 unsigned long id_counter;
176 struct workqueue_struct *wdt_wq;
177 struct work_struct wdt_work;
178};
179
180/**
181 * mtk_mdp_ctx - the device context data
182 * @list: link to ctx_list of mtk_mdp_dev
183 * @s_frame: source frame properties
184 * @d_frame: destination frame properties
185 * @id: index of the context that this structure describes
186 * @flags: additional flags for image conversion
187 * @state: flags to keep track of user configuration
188 Protected by slock
189 * @rotation: rotates the image by specified angle
190 * @hflip: mirror the picture horizontally
191 * @vflip: mirror the picture vertically
192 * @mdp_dev: the image processor device this context applies to
193 * @m2m_ctx: memory-to-memory device context
194 * @fh: v4l2 file handle
195 * @ctrl_handler: v4l2 controls handler
196 * @ctrls image processor control set
197 * @ctrls_rdy: true if the control handler is initialized
198 * @colorspace: enum v4l2_colorspace; supplemental to pixelformat
199 * @ycbcr_enc: enum v4l2_ycbcr_encoding, Y'CbCr encoding
200 * @xfer_func: enum v4l2_xfer_func, colorspace transfer function
201 * @quant: enum v4l2_quantization, colorspace quantization
202 * @vpu: VPU instance
203 * @slock: the mutex protecting mtp_mdp_ctx.state
204 * @work: worker for image processing
205 */
206struct mtk_mdp_ctx {
207 struct list_head list;
208 struct mtk_mdp_frame s_frame;
209 struct mtk_mdp_frame d_frame;
210 u32 flags;
211 u32 state;
212 int id;
213 int rotation;
214 u32 hflip:1;
215 u32 vflip:1;
216 struct mtk_mdp_dev *mdp_dev;
217 struct v4l2_m2m_ctx *m2m_ctx;
218 struct v4l2_fh fh;
219 struct v4l2_ctrl_handler ctrl_handler;
220 struct mtk_mdp_ctrls ctrls;
221 bool ctrls_rdy;
222 enum v4l2_colorspace colorspace;
223 enum v4l2_ycbcr_encoding ycbcr_enc;
224 enum v4l2_xfer_func xfer_func;
225 enum v4l2_quantization quant;
226
227 struct mtk_mdp_vpu vpu;
228 struct mutex slock;
229 struct work_struct work;
230};
231
232extern int mtk_mdp_dbg_level;
233
234#if defined(DEBUG)
235
236#define mtk_mdp_dbg(level, fmt, args...) \
237 do { \
238 if (mtk_mdp_dbg_level >= level) \
239 pr_info("[MTK_MDP] level=%d %s(),%d: " fmt "\n", \
240 level, __func__, __LINE__, ##args); \
241 } while (0)
242
243#define mtk_mdp_err(fmt, args...) \
244 pr_err("[MTK_MDP][ERROR] %s:%d: " fmt "\n", __func__, __LINE__, \
245 ##args)
246
247
248#define mtk_mdp_dbg_enter() mtk_mdp_dbg(3, "+")
249#define mtk_mdp_dbg_leave() mtk_mdp_dbg(3, "-")
250
251#else
252
253#define mtk_mdp_dbg(level, fmt, args...) {}
254#define mtk_mdp_err(fmt, args...)
255#define mtk_mdp_dbg_enter()
256#define mtk_mdp_dbg_leave()
257
258#endif
259
260#endif /* __MTK_MDP_CORE_H__ */
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h b/drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h
new file mode 100644
index 000000000000..78e2cc0dead1
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h
@@ -0,0 +1,126 @@
1/*
2 * Copyright (c) 2015-2016 MediaTek Inc.
3 * Author: Houlong Wei <houlong.wei@mediatek.com>
4 * Ming Hsiu Tsai <minghsiu.tsai@mediatek.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 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef __MTK_MDP_IPI_H__
17#define __MTK_MDP_IPI_H__
18
19#define MTK_MDP_MAX_NUM_PLANE 3
20
21enum mdp_ipi_msgid {
22 AP_MDP_INIT = 0xd000,
23 AP_MDP_DEINIT = 0xd001,
24 AP_MDP_PROCESS = 0xd002,
25
26 VPU_MDP_INIT_ACK = 0xe000,
27 VPU_MDP_DEINIT_ACK = 0xe001,
28 VPU_MDP_PROCESS_ACK = 0xe002
29};
30
31#pragma pack(push, 4)
32
33/**
34 * struct mdp_ipi_init - for AP_MDP_INIT
35 * @msg_id : AP_MDP_INIT
36 * @ipi_id : IPI_MDP
37 * @ap_inst : AP mtk_mdp_vpu address
38 */
39struct mdp_ipi_init {
40 uint32_t msg_id;
41 uint32_t ipi_id;
42 uint64_t ap_inst;
43};
44
45/**
46 * struct mdp_ipi_comm - for AP_MDP_PROCESS, AP_MDP_DEINIT
47 * @msg_id : AP_MDP_PROCESS, AP_MDP_DEINIT
48 * @ipi_id : IPI_MDP
49 * @ap_inst : AP mtk_mdp_vpu address
50 * @vpu_inst_addr : VPU MDP instance address
51 */
52struct mdp_ipi_comm {
53 uint32_t msg_id;
54 uint32_t ipi_id;
55 uint64_t ap_inst;
56 uint32_t vpu_inst_addr;
57};
58
59/**
60 * struct mdp_ipi_comm_ack - for VPU_MDP_DEINIT_ACK, VPU_MDP_PROCESS_ACK
61 * @msg_id : VPU_MDP_DEINIT_ACK, VPU_MDP_PROCESS_ACK
62 * @ipi_id : IPI_MDP
63 * @ap_inst : AP mtk_mdp_vpu address
64 * @vpu_inst_addr : VPU MDP instance address
65 * @status : VPU exeuction result
66 */
67struct mdp_ipi_comm_ack {
68 uint32_t msg_id;
69 uint32_t ipi_id;
70 uint64_t ap_inst;
71 uint32_t vpu_inst_addr;
72 int32_t status;
73};
74
75/**
76 * struct mdp_config - configured for source/destination image
77 * @x : left
78 * @y : top
79 * @w : width
80 * @h : height
81 * @w_stride : bytes in horizontal
82 * @h_stride : bytes in vertical
83 * @crop_x : cropped left
84 * @crop_y : cropped top
85 * @crop_w : cropped width
86 * @crop_h : cropped height
87 * @format : color format
88 */
89struct mdp_config {
90 int32_t x;
91 int32_t y;
92 int32_t w;
93 int32_t h;
94 int32_t w_stride;
95 int32_t h_stride;
96 int32_t crop_x;
97 int32_t crop_y;
98 int32_t crop_w;
99 int32_t crop_h;
100 int32_t format;
101};
102
103struct mdp_buffer {
104 uint64_t addr_mva[MTK_MDP_MAX_NUM_PLANE];
105 int32_t plane_size[MTK_MDP_MAX_NUM_PLANE];
106 int32_t plane_num;
107};
108
109struct mdp_config_misc {
110 int32_t orientation; /* 0, 90, 180, 270 */
111 int32_t hflip; /* 1 will enable the flip */
112 int32_t vflip; /* 1 will enable the flip */
113 int32_t alpha; /* global alpha */
114};
115
116struct mdp_process_vsi {
117 struct mdp_config src_config;
118 struct mdp_buffer src_buffer;
119 struct mdp_config dst_config;
120 struct mdp_buffer dst_buffer;
121 struct mdp_config_misc misc;
122};
123
124#pragma pack(pop)
125
126#endif /* __MTK_MDP_IPI_H__ */
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
new file mode 100644
index 000000000000..13afe48b9dc5
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
@@ -0,0 +1,1286 @@
1/*
2 * Copyright (c) 2015-2016 MediaTek Inc.
3 * Author: Houlong Wei <houlong.wei@mediatek.com>
4 * Ming Hsiu Tsai <minghsiu.tsai@mediatek.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 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/device.h>
17#include <linux/errno.h>
18#include <linux/kernel.h>
19#include <linux/pm_runtime.h>
20#include <linux/slab.h>
21#include <linux/workqueue.h>
22#include <media/v4l2-event.h>
23#include <media/v4l2-ioctl.h>
24
25#include "mtk_mdp_core.h"
26#include "mtk_mdp_m2m.h"
27#include "mtk_mdp_regs.h"
28#include "mtk_vpu.h"
29
30
31/**
32 * struct mtk_mdp_pix_limit - image pixel size limits
33 * @org_w: source pixel width
34 * @org_h: source pixel height
35 * @target_rot_dis_w: pixel dst scaled width with the rotator is off
36 * @target_rot_dis_h: pixel dst scaled height with the rotator is off
37 * @target_rot_en_w: pixel dst scaled width with the rotator is on
38 * @target_rot_en_h: pixel dst scaled height with the rotator is on
39 */
40struct mtk_mdp_pix_limit {
41 u16 org_w;
42 u16 org_h;
43 u16 target_rot_dis_w;
44 u16 target_rot_dis_h;
45 u16 target_rot_en_w;
46 u16 target_rot_en_h;
47};
48
49static struct mtk_mdp_pix_align mtk_mdp_size_align = {
50 .org_w = 16,
51 .org_h = 16,
52 .target_w = 2,
53 .target_h = 2,
54};
55
56static const struct mtk_mdp_fmt mtk_mdp_formats[] = {
57 {
58 .pixelformat = V4L2_PIX_FMT_MT21C,
59 .depth = { 8, 4 },
60 .row_depth = { 8, 8 },
61 .num_planes = 2,
62 .num_comp = 2,
63 .align = &mtk_mdp_size_align,
64 .flags = MTK_MDP_FMT_FLAG_OUTPUT,
65 }, {
66 .pixelformat = V4L2_PIX_FMT_NV12M,
67 .depth = { 8, 4 },
68 .row_depth = { 8, 8 },
69 .num_planes = 2,
70 .num_comp = 2,
71 .flags = MTK_MDP_FMT_FLAG_OUTPUT |
72 MTK_MDP_FMT_FLAG_CAPTURE,
73 }, {
74 .pixelformat = V4L2_PIX_FMT_YUV420M,
75 .depth = { 8, 2, 2 },
76 .row_depth = { 8, 4, 4 },
77 .num_planes = 3,
78 .num_comp = 3,
79 .flags = MTK_MDP_FMT_FLAG_OUTPUT |
80 MTK_MDP_FMT_FLAG_CAPTURE,
81 }, {
82 .pixelformat = V4L2_PIX_FMT_YVU420,
83 .depth = { 12 },
84 .row_depth = { 8 },
85 .num_planes = 1,
86 .num_comp = 3,
87 .flags = MTK_MDP_FMT_FLAG_OUTPUT |
88 MTK_MDP_FMT_FLAG_CAPTURE,
89 }
90};
91
92static struct mtk_mdp_pix_limit mtk_mdp_size_max = {
93 .target_rot_dis_w = 4096,
94 .target_rot_dis_h = 4096,
95 .target_rot_en_w = 4096,
96 .target_rot_en_h = 4096,
97};
98
99static struct mtk_mdp_pix_limit mtk_mdp_size_min = {
100 .org_w = 16,
101 .org_h = 16,
102 .target_rot_dis_w = 16,
103 .target_rot_dis_h = 16,
104 .target_rot_en_w = 16,
105 .target_rot_en_h = 16,
106};
107
108/* align size for normal raster scan pixel format */
109static struct mtk_mdp_pix_align mtk_mdp_rs_align = {
110 .org_w = 2,
111 .org_h = 2,
112 .target_w = 2,
113 .target_h = 2,
114};
115
116static struct mtk_mdp_variant mtk_mdp_default_variant = {
117 .pix_max = &mtk_mdp_size_max,
118 .pix_min = &mtk_mdp_size_min,
119 .pix_align = &mtk_mdp_rs_align,
120 .h_scale_up_max = 32,
121 .v_scale_up_max = 32,
122 .h_scale_down_max = 32,
123 .v_scale_down_max = 128,
124};
125
126static const struct mtk_mdp_fmt *mtk_mdp_find_fmt(u32 pixelformat, u32 type)
127{
128 u32 i, flag;
129
130 flag = V4L2_TYPE_IS_OUTPUT(type) ? MTK_MDP_FMT_FLAG_OUTPUT :
131 MTK_MDP_FMT_FLAG_CAPTURE;
132
133 for (i = 0; i < ARRAY_SIZE(mtk_mdp_formats); ++i) {
134 if (!(mtk_mdp_formats[i].flags & flag))
135 continue;
136 if (mtk_mdp_formats[i].pixelformat == pixelformat)
137 return &mtk_mdp_formats[i];
138 }
139 return NULL;
140}
141
142static const struct mtk_mdp_fmt *mtk_mdp_find_fmt_by_index(u32 index, u32 type)
143{
144 u32 i, flag, num = 0;
145
146 flag = V4L2_TYPE_IS_OUTPUT(type) ? MTK_MDP_FMT_FLAG_OUTPUT :
147 MTK_MDP_FMT_FLAG_CAPTURE;
148
149 for (i = 0; i < ARRAY_SIZE(mtk_mdp_formats); ++i) {
150 if (!(mtk_mdp_formats[i].flags & flag))
151 continue;
152 if (index == num)
153 return &mtk_mdp_formats[i];
154 num++;
155 }
156 return NULL;
157}
158
159static void mtk_mdp_bound_align_image(u32 *w, unsigned int wmin,
160 unsigned int wmax, unsigned int align_w,
161 u32 *h, unsigned int hmin,
162 unsigned int hmax, unsigned int align_h)
163{
164 int org_w, org_h, step_w, step_h;
165 int walign, halign;
166
167 org_w = *w;
168 org_h = *h;
169 walign = ffs(align_w) - 1;
170 halign = ffs(align_h) - 1;
171 v4l_bound_align_image(w, wmin, wmax, walign, h, hmin, hmax, halign, 0);
172
173 step_w = 1 << walign;
174 step_h = 1 << halign;
175 if (*w < org_w && (*w + step_w) <= wmax)
176 *w += step_w;
177 if (*h < org_h && (*h + step_h) <= hmax)
178 *h += step_h;
179}
180
181static const struct mtk_mdp_fmt *mtk_mdp_try_fmt_mplane(struct mtk_mdp_ctx *ctx,
182 struct v4l2_format *f)
183{
184 struct mtk_mdp_dev *mdp = ctx->mdp_dev;
185 struct mtk_mdp_variant *variant = mdp->variant;
186 struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
187 const struct mtk_mdp_fmt *fmt;
188 u32 max_w, max_h, align_w, align_h;
189 u32 min_w, min_h, org_w, org_h;
190 int i;
191
192 fmt = mtk_mdp_find_fmt(pix_mp->pixelformat, f->type);
193 if (!fmt)
194 fmt = mtk_mdp_find_fmt_by_index(0, f->type);
195 if (!fmt) {
196 dev_dbg(&ctx->mdp_dev->pdev->dev,
197 "pixelformat format 0x%X invalid\n",
198 pix_mp->pixelformat);
199 return NULL;
200 }
201
202 pix_mp->field = V4L2_FIELD_NONE;
203 pix_mp->pixelformat = fmt->pixelformat;
204 if (!V4L2_TYPE_IS_OUTPUT(f->type)) {
205 pix_mp->colorspace = ctx->colorspace;
206 pix_mp->xfer_func = ctx->xfer_func;
207 pix_mp->ycbcr_enc = ctx->ycbcr_enc;
208 pix_mp->quantization = ctx->quant;
209 }
210 memset(pix_mp->reserved, 0, sizeof(pix_mp->reserved));
211
212 max_w = variant->pix_max->target_rot_dis_w;
213 max_h = variant->pix_max->target_rot_dis_h;
214
215 if (fmt->align == NULL) {
216 /* use default alignment */
217 align_w = variant->pix_align->org_w;
218 align_h = variant->pix_align->org_h;
219 } else {
220 align_w = fmt->align->org_w;
221 align_h = fmt->align->org_h;
222 }
223
224 if (V4L2_TYPE_IS_OUTPUT(f->type)) {
225 min_w = variant->pix_min->org_w;
226 min_h = variant->pix_min->org_h;
227 } else {
228 min_w = variant->pix_min->target_rot_dis_w;
229 min_h = variant->pix_min->target_rot_dis_h;
230 }
231
232 mtk_mdp_dbg(2, "[%d] type:%d, wxh:%ux%u, align:%ux%u, max:%ux%u",
233 ctx->id, f->type, pix_mp->width, pix_mp->height,
234 align_w, align_h, max_w, max_h);
235 /*
236 * To check if image size is modified to adjust parameter against
237 * hardware abilities
238 */
239 org_w = pix_mp->width;
240 org_h = pix_mp->height;
241
242 mtk_mdp_bound_align_image(&pix_mp->width, min_w, max_w, align_w,
243 &pix_mp->height, min_h, max_h, align_h);
244
245 if (org_w != pix_mp->width || org_h != pix_mp->height)
246 mtk_mdp_dbg(1, "[%d] size change:%ux%u to %ux%u", ctx->id,
247 org_w, org_h, pix_mp->width, pix_mp->height);
248 pix_mp->num_planes = fmt->num_planes;
249
250 for (i = 0; i < pix_mp->num_planes; ++i) {
251 int bpl = (pix_mp->width * fmt->row_depth[i]) / 8;
252 int sizeimage = (pix_mp->width * pix_mp->height *
253 fmt->depth[i]) / 8;
254
255 pix_mp->plane_fmt[i].bytesperline = bpl;
256 if (pix_mp->plane_fmt[i].sizeimage < sizeimage)
257 pix_mp->plane_fmt[i].sizeimage = sizeimage;
258 memset(pix_mp->plane_fmt[i].reserved, 0,
259 sizeof(pix_mp->plane_fmt[i].reserved));
260 mtk_mdp_dbg(2, "[%d] p%d, bpl:%d, sizeimage:%u (%u)", ctx->id,
261 i, bpl, pix_mp->plane_fmt[i].sizeimage, sizeimage);
262 }
263
264 return fmt;
265}
266
267static struct mtk_mdp_frame *mtk_mdp_ctx_get_frame(struct mtk_mdp_ctx *ctx,
268 enum v4l2_buf_type type)
269{
270 if (V4L2_TYPE_IS_OUTPUT(type))
271 return &ctx->s_frame;
272 return &ctx->d_frame;
273}
274
275static void mtk_mdp_check_crop_change(u32 new_w, u32 new_h, u32 *w, u32 *h)
276{
277 if (new_w != *w || new_h != *h) {
278 mtk_mdp_dbg(1, "size change:%dx%d to %dx%d",
279 *w, *h, new_w, new_h);
280
281 *w = new_w;
282 *h = new_h;
283 }
284}
285
286static int mtk_mdp_try_crop(struct mtk_mdp_ctx *ctx, u32 type,
287 struct v4l2_rect *r)
288{
289 struct mtk_mdp_frame *frame;
290 struct mtk_mdp_dev *mdp = ctx->mdp_dev;
291 struct mtk_mdp_variant *variant = mdp->variant;
292 u32 align_w, align_h, new_w, new_h;
293 u32 min_w, min_h, max_w, max_h;
294
295 if (r->top < 0 || r->left < 0) {
296 dev_err(&ctx->mdp_dev->pdev->dev,
297 "doesn't support negative values for top & left\n");
298 return -EINVAL;
299 }
300
301 mtk_mdp_dbg(2, "[%d] type:%d, set wxh:%dx%d", ctx->id, type,
302 r->width, r->height);
303
304 frame = mtk_mdp_ctx_get_frame(ctx, type);
305 max_w = frame->width;
306 max_h = frame->height;
307 new_w = r->width;
308 new_h = r->height;
309
310 if (V4L2_TYPE_IS_OUTPUT(type)) {
311 align_w = 1;
312 align_h = 1;
313 min_w = 64;
314 min_h = 32;
315 } else {
316 align_w = variant->pix_align->target_w;
317 align_h = variant->pix_align->target_h;
318 if (ctx->ctrls.rotate->val == 90 ||
319 ctx->ctrls.rotate->val == 270) {
320 max_w = frame->height;
321 max_h = frame->width;
322 min_w = variant->pix_min->target_rot_en_w;
323 min_h = variant->pix_min->target_rot_en_h;
324 new_w = r->height;
325 new_h = r->width;
326 } else {
327 min_w = variant->pix_min->target_rot_dis_w;
328 min_h = variant->pix_min->target_rot_dis_h;
329 }
330 }
331
332 mtk_mdp_dbg(2, "[%d] align:%dx%d, min:%dx%d, new:%dx%d", ctx->id,
333 align_w, align_h, min_w, min_h, new_w, new_h);
334
335 mtk_mdp_bound_align_image(&new_w, min_w, max_w, align_w,
336 &new_h, min_h, max_h, align_h);
337
338 if (!V4L2_TYPE_IS_OUTPUT(type) &&
339 (ctx->ctrls.rotate->val == 90 ||
340 ctx->ctrls.rotate->val == 270))
341 mtk_mdp_check_crop_change(new_h, new_w,
342 &r->width, &r->height);
343 else
344 mtk_mdp_check_crop_change(new_w, new_h,
345 &r->width, &r->height);
346
347 /* adjust left/top if cropping rectangle is out of bounds */
348 /* Need to add code to algin left value with 2's multiple */
349 if (r->left + new_w > max_w)
350 r->left = max_w - new_w;
351 if (r->top + new_h > max_h)
352 r->top = max_h - new_h;
353
354 if (r->left & 1)
355 r->left -= 1;
356
357 mtk_mdp_dbg(2, "[%d] crop l,t,w,h:%d,%d,%d,%d, max:%dx%d", ctx->id,
358 r->left, r->top, r->width,
359 r->height, max_w, max_h);
360 return 0;
361}
362
363static inline struct mtk_mdp_ctx *fh_to_ctx(struct v4l2_fh *fh)
364{
365 return container_of(fh, struct mtk_mdp_ctx, fh);
366}
367
368static inline struct mtk_mdp_ctx *ctrl_to_ctx(struct v4l2_ctrl *ctrl)
369{
370 return container_of(ctrl->handler, struct mtk_mdp_ctx, ctrl_handler);
371}
372
373void mtk_mdp_ctx_state_lock_set(struct mtk_mdp_ctx *ctx, u32 state)
374{
375 mutex_lock(&ctx->slock);
376 ctx->state |= state;
377 mutex_unlock(&ctx->slock);
378}
379
380static void mtk_mdp_ctx_state_lock_clear(struct mtk_mdp_ctx *ctx, u32 state)
381{
382 mutex_lock(&ctx->slock);
383 ctx->state &= ~state;
384 mutex_unlock(&ctx->slock);
385}
386
387static bool mtk_mdp_ctx_state_is_set(struct mtk_mdp_ctx *ctx, u32 mask)
388{
389 bool ret;
390
391 mutex_lock(&ctx->slock);
392 ret = (ctx->state & mask) == mask;
393 mutex_unlock(&ctx->slock);
394 return ret;
395}
396
397static void mtk_mdp_ctx_lock(struct vb2_queue *vq)
398{
399 struct mtk_mdp_ctx *ctx = vb2_get_drv_priv(vq);
400
401 mutex_lock(&ctx->mdp_dev->lock);
402}
403
404static void mtk_mdp_ctx_unlock(struct vb2_queue *vq)
405{
406 struct mtk_mdp_ctx *ctx = vb2_get_drv_priv(vq);
407
408 mutex_unlock(&ctx->mdp_dev->lock);
409}
410
411static void mtk_mdp_set_frame_size(struct mtk_mdp_frame *frame, int width,
412 int height)
413{
414 frame->width = width;
415 frame->height = height;
416 frame->crop.width = width;
417 frame->crop.height = height;
418 frame->crop.left = 0;
419 frame->crop.top = 0;
420}
421
422static int mtk_mdp_m2m_start_streaming(struct vb2_queue *q, unsigned int count)
423{
424 struct mtk_mdp_ctx *ctx = q->drv_priv;
425 int ret;
426
427 ret = pm_runtime_get_sync(&ctx->mdp_dev->pdev->dev);
428 if (ret < 0)
429 mtk_mdp_dbg(1, "[%d] pm_runtime_get_sync failed:%d",
430 ctx->id, ret);
431
432 return 0;
433}
434
435static void *mtk_mdp_m2m_buf_remove(struct mtk_mdp_ctx *ctx,
436 enum v4l2_buf_type type)
437{
438 if (V4L2_TYPE_IS_OUTPUT(type))
439 return v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
440 else
441 return v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
442}
443
444static void mtk_mdp_m2m_stop_streaming(struct vb2_queue *q)
445{
446 struct mtk_mdp_ctx *ctx = q->drv_priv;
447 struct vb2_buffer *vb;
448
449 vb = mtk_mdp_m2m_buf_remove(ctx, q->type);
450 while (vb != NULL) {
451 v4l2_m2m_buf_done(to_vb2_v4l2_buffer(vb), VB2_BUF_STATE_ERROR);
452 vb = mtk_mdp_m2m_buf_remove(ctx, q->type);
453 }
454
455 pm_runtime_put(&ctx->mdp_dev->pdev->dev);
456}
457
458static void mtk_mdp_m2m_job_abort(void *priv)
459{
460}
461
462/* The color format (num_planes) must be already configured. */
463static void mtk_mdp_prepare_addr(struct mtk_mdp_ctx *ctx,
464 struct vb2_buffer *vb,
465 struct mtk_mdp_frame *frame,
466 struct mtk_mdp_addr *addr)
467{
468 u32 pix_size, planes, i;
469
470 pix_size = frame->width * frame->height;
471 planes = min_t(u32, frame->fmt->num_planes, ARRAY_SIZE(addr->addr));
472 for (i = 0; i < planes; i++)
473 addr->addr[i] = vb2_dma_contig_plane_dma_addr(vb, i);
474
475 if (planes == 1) {
476 if (frame->fmt->pixelformat == V4L2_PIX_FMT_YVU420) {
477 addr->addr[1] = (dma_addr_t)(addr->addr[0] + pix_size);
478 addr->addr[2] = (dma_addr_t)(addr->addr[1] +
479 (pix_size >> 2));
480 } else {
481 dev_err(&ctx->mdp_dev->pdev->dev,
482 "Invalid pixelformat:0x%x\n",
483 frame->fmt->pixelformat);
484 }
485 }
486 mtk_mdp_dbg(3, "[%d] planes:%d, size:%d, addr:%p,%p,%p",
487 ctx->id, planes, pix_size, (void *)addr->addr[0],
488 (void *)addr->addr[1], (void *)addr->addr[2]);
489}
490
491static void mtk_mdp_m2m_get_bufs(struct mtk_mdp_ctx *ctx)
492{
493 struct mtk_mdp_frame *s_frame, *d_frame;
494 struct vb2_buffer *src_vb, *dst_vb;
495 struct vb2_v4l2_buffer *src_vbuf, *dst_vbuf;
496
497 s_frame = &ctx->s_frame;
498 d_frame = &ctx->d_frame;
499
500 src_vb = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
501 mtk_mdp_prepare_addr(ctx, src_vb, s_frame, &s_frame->addr);
502
503 dst_vb = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
504 mtk_mdp_prepare_addr(ctx, dst_vb, d_frame, &d_frame->addr);
505
506 src_vbuf = to_vb2_v4l2_buffer(src_vb);
507 dst_vbuf = to_vb2_v4l2_buffer(dst_vb);
508 dst_vbuf->vb2_buf.timestamp = src_vbuf->vb2_buf.timestamp;
509}
510
511static void mtk_mdp_process_done(void *priv, int vb_state)
512{
513 struct mtk_mdp_dev *mdp = priv;
514 struct mtk_mdp_ctx *ctx;
515 struct vb2_buffer *src_vb, *dst_vb;
516 struct vb2_v4l2_buffer *src_vbuf = NULL, *dst_vbuf = NULL;
517
518 ctx = v4l2_m2m_get_curr_priv(mdp->m2m_dev);
519 if (!ctx)
520 return;
521
522 src_vb = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
523 src_vbuf = to_vb2_v4l2_buffer(src_vb);
524 dst_vb = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
525 dst_vbuf = to_vb2_v4l2_buffer(dst_vb);
526
527 dst_vbuf->vb2_buf.timestamp = src_vbuf->vb2_buf.timestamp;
528 dst_vbuf->timecode = src_vbuf->timecode;
529 dst_vbuf->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
530 dst_vbuf->flags |= src_vbuf->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
531
532 v4l2_m2m_buf_done(src_vbuf, vb_state);
533 v4l2_m2m_buf_done(dst_vbuf, vb_state);
534 v4l2_m2m_job_finish(ctx->mdp_dev->m2m_dev, ctx->m2m_ctx);
535}
536
537static void mtk_mdp_m2m_worker(struct work_struct *work)
538{
539 struct mtk_mdp_ctx *ctx =
540 container_of(work, struct mtk_mdp_ctx, work);
541 struct mtk_mdp_dev *mdp = ctx->mdp_dev;
542 enum vb2_buffer_state buf_state = VB2_BUF_STATE_ERROR;
543 int ret;
544
545 if (mtk_mdp_ctx_state_is_set(ctx, MTK_MDP_CTX_ERROR)) {
546 dev_err(&mdp->pdev->dev, "ctx is in error state");
547 goto worker_end;
548 }
549
550 mtk_mdp_m2m_get_bufs(ctx);
551
552 mtk_mdp_hw_set_input_addr(ctx, &ctx->s_frame.addr);
553 mtk_mdp_hw_set_output_addr(ctx, &ctx->d_frame.addr);
554
555 mtk_mdp_hw_set_in_size(ctx);
556 mtk_mdp_hw_set_in_image_format(ctx);
557
558 mtk_mdp_hw_set_out_size(ctx);
559 mtk_mdp_hw_set_out_image_format(ctx);
560
561 mtk_mdp_hw_set_rotation(ctx);
562 mtk_mdp_hw_set_global_alpha(ctx);
563
564 ret = mtk_mdp_vpu_process(&ctx->vpu);
565 if (ret) {
566 dev_err(&mdp->pdev->dev, "processing failed: %d", ret);
567 goto worker_end;
568 }
569
570 buf_state = VB2_BUF_STATE_DONE;
571
572worker_end:
573 mtk_mdp_process_done(mdp, buf_state);
574}
575
576static void mtk_mdp_m2m_device_run(void *priv)
577{
578 struct mtk_mdp_ctx *ctx = priv;
579
580 queue_work(ctx->mdp_dev->job_wq, &ctx->work);
581}
582
583static int mtk_mdp_m2m_queue_setup(struct vb2_queue *vq,
584 unsigned int *num_buffers, unsigned int *num_planes,
585 unsigned int sizes[], struct device *alloc_devs[])
586{
587 struct mtk_mdp_ctx *ctx = vb2_get_drv_priv(vq);
588 struct mtk_mdp_frame *frame;
589 int i;
590
591 frame = mtk_mdp_ctx_get_frame(ctx, vq->type);
592 *num_planes = frame->fmt->num_planes;
593 for (i = 0; i < frame->fmt->num_planes; i++)
594 sizes[i] = frame->payload[i];
595 mtk_mdp_dbg(2, "[%d] type:%d, planes:%d, buffers:%d, size:%u,%u",
596 ctx->id, vq->type, *num_planes, *num_buffers,
597 sizes[0], sizes[1]);
598 return 0;
599}
600
601static int mtk_mdp_m2m_buf_prepare(struct vb2_buffer *vb)
602{
603 struct mtk_mdp_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
604 struct mtk_mdp_frame *frame;
605 int i;
606
607 frame = mtk_mdp_ctx_get_frame(ctx, vb->vb2_queue->type);
608
609 if (!V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) {
610 for (i = 0; i < frame->fmt->num_planes; i++)
611 vb2_set_plane_payload(vb, i, frame->payload[i]);
612 }
613
614 return 0;
615}
616
617static void mtk_mdp_m2m_buf_queue(struct vb2_buffer *vb)
618{
619 struct mtk_mdp_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
620
621 v4l2_m2m_buf_queue(ctx->m2m_ctx, to_vb2_v4l2_buffer(vb));
622}
623
624static struct vb2_ops mtk_mdp_m2m_qops = {
625 .queue_setup = mtk_mdp_m2m_queue_setup,
626 .buf_prepare = mtk_mdp_m2m_buf_prepare,
627 .buf_queue = mtk_mdp_m2m_buf_queue,
628 .wait_prepare = mtk_mdp_ctx_unlock,
629 .wait_finish = mtk_mdp_ctx_lock,
630 .stop_streaming = mtk_mdp_m2m_stop_streaming,
631 .start_streaming = mtk_mdp_m2m_start_streaming,
632};
633
634static int mtk_mdp_m2m_querycap(struct file *file, void *fh,
635 struct v4l2_capability *cap)
636{
637 struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
638 struct mtk_mdp_dev *mdp = ctx->mdp_dev;
639
640 strlcpy(cap->driver, MTK_MDP_MODULE_NAME, sizeof(cap->driver));
641 strlcpy(cap->card, mdp->pdev->name, sizeof(cap->card));
642 strlcpy(cap->bus_info, "platform:mt8173", sizeof(cap->bus_info));
643
644 return 0;
645}
646
647static int mtk_mdp_enum_fmt_mplane(struct v4l2_fmtdesc *f, u32 type)
648{
649 const struct mtk_mdp_fmt *fmt;
650
651 fmt = mtk_mdp_find_fmt_by_index(f->index, type);
652 if (!fmt)
653 return -EINVAL;
654
655 f->pixelformat = fmt->pixelformat;
656
657 return 0;
658}
659
660static int mtk_mdp_m2m_enum_fmt_mplane_vid_cap(struct file *file, void *priv,
661 struct v4l2_fmtdesc *f)
662{
663 return mtk_mdp_enum_fmt_mplane(f, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
664}
665
666static int mtk_mdp_m2m_enum_fmt_mplane_vid_out(struct file *file, void *priv,
667 struct v4l2_fmtdesc *f)
668{
669 return mtk_mdp_enum_fmt_mplane(f, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
670}
671
672static int mtk_mdp_m2m_g_fmt_mplane(struct file *file, void *fh,
673 struct v4l2_format *f)
674{
675 struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
676 struct mtk_mdp_frame *frame;
677 struct v4l2_pix_format_mplane *pix_mp;
678 int i;
679
680 mtk_mdp_dbg(2, "[%d] type:%d", ctx->id, f->type);
681
682 frame = mtk_mdp_ctx_get_frame(ctx, f->type);
683 pix_mp = &f->fmt.pix_mp;
684
685 pix_mp->width = frame->width;
686 pix_mp->height = frame->height;
687 pix_mp->field = V4L2_FIELD_NONE;
688 pix_mp->pixelformat = frame->fmt->pixelformat;
689 pix_mp->num_planes = frame->fmt->num_planes;
690 pix_mp->colorspace = ctx->colorspace;
691 pix_mp->xfer_func = ctx->xfer_func;
692 pix_mp->ycbcr_enc = ctx->ycbcr_enc;
693 pix_mp->quantization = ctx->quant;
694 mtk_mdp_dbg(2, "[%d] wxh:%dx%d", ctx->id,
695 pix_mp->width, pix_mp->height);
696
697 for (i = 0; i < pix_mp->num_planes; ++i) {
698 pix_mp->plane_fmt[i].bytesperline = (frame->width *
699 frame->fmt->row_depth[i]) / 8;
700 pix_mp->plane_fmt[i].sizeimage = (frame->width *
701 frame->height * frame->fmt->depth[i]) / 8;
702
703 mtk_mdp_dbg(2, "[%d] p%d, bpl:%d, sizeimage:%d", ctx->id, i,
704 pix_mp->plane_fmt[i].bytesperline,
705 pix_mp->plane_fmt[i].sizeimage);
706 }
707
708 return 0;
709}
710
711static int mtk_mdp_m2m_try_fmt_mplane(struct file *file, void *fh,
712 struct v4l2_format *f)
713{
714 struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
715
716 if (!mtk_mdp_try_fmt_mplane(ctx, f))
717 return -EINVAL;
718 return 0;
719}
720
721static int mtk_mdp_m2m_s_fmt_mplane(struct file *file, void *fh,
722 struct v4l2_format *f)
723{
724 struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
725 struct vb2_queue *vq;
726 struct mtk_mdp_frame *frame;
727 struct v4l2_pix_format_mplane *pix_mp;
728 const struct mtk_mdp_fmt *fmt;
729 int i;
730
731 mtk_mdp_dbg(2, "[%d] type:%d", ctx->id, f->type);
732
733 frame = mtk_mdp_ctx_get_frame(ctx, f->type);
734 fmt = mtk_mdp_try_fmt_mplane(ctx, f);
735 if (!fmt) {
736 mtk_mdp_err("[%d] try_fmt failed, type:%d", ctx->id, f->type);
737 return -EINVAL;
738 }
739 frame->fmt = fmt;
740
741 vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
742 if (vb2_is_streaming(vq)) {
743 dev_info(&ctx->mdp_dev->pdev->dev, "queue %d busy", f->type);
744 return -EBUSY;
745 }
746
747 pix_mp = &f->fmt.pix_mp;
748 for (i = 0; i < frame->fmt->num_planes; i++) {
749 frame->payload[i] = pix_mp->plane_fmt[i].sizeimage;
750 frame->pitch[i] = pix_mp->plane_fmt[i].bytesperline;
751 }
752
753 mtk_mdp_set_frame_size(frame, pix_mp->width, pix_mp->height);
754 if (V4L2_TYPE_IS_OUTPUT(f->type)) {
755 ctx->colorspace = pix_mp->colorspace;
756 ctx->xfer_func = pix_mp->xfer_func;
757 ctx->ycbcr_enc = pix_mp->ycbcr_enc;
758 ctx->quant = pix_mp->quantization;
759 }
760
761 if (V4L2_TYPE_IS_OUTPUT(f->type))
762 mtk_mdp_ctx_state_lock_set(ctx, MTK_MDP_SRC_FMT);
763 else
764 mtk_mdp_ctx_state_lock_set(ctx, MTK_MDP_DST_FMT);
765
766 mtk_mdp_dbg(2, "[%d] type:%d, frame:%dx%d", ctx->id, f->type,
767 frame->width, frame->height);
768
769 return 0;
770}
771
772static int mtk_mdp_m2m_reqbufs(struct file *file, void *fh,
773 struct v4l2_requestbuffers *reqbufs)
774{
775 struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
776
777 if (reqbufs->count == 0) {
778 if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
779 mtk_mdp_ctx_state_lock_clear(ctx, MTK_MDP_SRC_FMT);
780 else
781 mtk_mdp_ctx_state_lock_clear(ctx, MTK_MDP_DST_FMT);
782 }
783
784 return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
785}
786
787static int mtk_mdp_m2m_streamon(struct file *file, void *fh,
788 enum v4l2_buf_type type)
789{
790 struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
791 int ret;
792
793 /* The source and target color format need to be set */
794 if (V4L2_TYPE_IS_OUTPUT(type)) {
795 if (!mtk_mdp_ctx_state_is_set(ctx, MTK_MDP_SRC_FMT))
796 return -EINVAL;
797 } else if (!mtk_mdp_ctx_state_is_set(ctx, MTK_MDP_DST_FMT)) {
798 return -EINVAL;
799 }
800
801 if (!mtk_mdp_ctx_state_is_set(ctx, MTK_MDP_VPU_INIT)) {
802 ret = mtk_mdp_vpu_init(&ctx->vpu);
803 if (ret < 0) {
804 dev_err(&ctx->mdp_dev->pdev->dev,
805 "vpu init failed %d\n",
806 ret);
807 return -EINVAL;
808 }
809 mtk_mdp_ctx_state_lock_set(ctx, MTK_MDP_VPU_INIT);
810 }
811
812 return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
813}
814
815static inline bool mtk_mdp_is_target_compose(u32 target)
816{
817 if (target == V4L2_SEL_TGT_COMPOSE_DEFAULT
818 || target == V4L2_SEL_TGT_COMPOSE_BOUNDS
819 || target == V4L2_SEL_TGT_COMPOSE)
820 return true;
821 return false;
822}
823
824static inline bool mtk_mdp_is_target_crop(u32 target)
825{
826 if (target == V4L2_SEL_TGT_CROP_DEFAULT
827 || target == V4L2_SEL_TGT_CROP_BOUNDS
828 || target == V4L2_SEL_TGT_CROP)
829 return true;
830 return false;
831}
832
833static int mtk_mdp_m2m_g_selection(struct file *file, void *fh,
834 struct v4l2_selection *s)
835{
836 struct mtk_mdp_frame *frame;
837 struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
838 bool valid = false;
839
840 if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
841 if (mtk_mdp_is_target_compose(s->target))
842 valid = true;
843 } else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
844 if (mtk_mdp_is_target_crop(s->target))
845 valid = true;
846 }
847 if (!valid) {
848 mtk_mdp_dbg(1, "[%d] invalid type:%d,%u", ctx->id, s->type,
849 s->target);
850 return -EINVAL;
851 }
852
853 frame = mtk_mdp_ctx_get_frame(ctx, s->type);
854
855 switch (s->target) {
856 case V4L2_SEL_TGT_COMPOSE_DEFAULT:
857 case V4L2_SEL_TGT_COMPOSE_BOUNDS:
858 case V4L2_SEL_TGT_CROP_BOUNDS:
859 case V4L2_SEL_TGT_CROP_DEFAULT:
860 s->r.left = 0;
861 s->r.top = 0;
862 s->r.width = frame->width;
863 s->r.height = frame->height;
864 return 0;
865
866 case V4L2_SEL_TGT_COMPOSE:
867 case V4L2_SEL_TGT_CROP:
868 s->r.left = frame->crop.left;
869 s->r.top = frame->crop.top;
870 s->r.width = frame->crop.width;
871 s->r.height = frame->crop.height;
872 return 0;
873 }
874
875 return -EINVAL;
876}
877
878static int mtk_mdp_check_scaler_ratio(struct mtk_mdp_variant *var, int src_w,
879 int src_h, int dst_w, int dst_h, int rot)
880{
881 int tmp_w, tmp_h;
882
883 if (rot == 90 || rot == 270) {
884 tmp_w = dst_h;
885 tmp_h = dst_w;
886 } else {
887 tmp_w = dst_w;
888 tmp_h = dst_h;
889 }
890
891 if ((src_w / tmp_w) > var->h_scale_down_max ||
892 (src_h / tmp_h) > var->v_scale_down_max ||
893 (tmp_w / src_w) > var->h_scale_up_max ||
894 (tmp_h / src_h) > var->v_scale_up_max)
895 return -EINVAL;
896
897 return 0;
898}
899
900static int mtk_mdp_m2m_s_selection(struct file *file, void *fh,
901 struct v4l2_selection *s)
902{
903 struct mtk_mdp_frame *frame;
904 struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
905 struct v4l2_rect new_r;
906 struct mtk_mdp_variant *variant = ctx->mdp_dev->variant;
907 int ret;
908 bool valid = false;
909
910 if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
911 if (s->target == V4L2_SEL_TGT_COMPOSE)
912 valid = true;
913 } else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
914 if (s->target == V4L2_SEL_TGT_CROP)
915 valid = true;
916 }
917 if (!valid) {
918 mtk_mdp_dbg(1, "[%d] invalid type:%d,%u", ctx->id, s->type,
919 s->target);
920 return -EINVAL;
921 }
922
923 new_r = s->r;
924 ret = mtk_mdp_try_crop(ctx, s->type, &new_r);
925 if (ret)
926 return ret;
927
928 if (mtk_mdp_is_target_crop(s->target))
929 frame = &ctx->s_frame;
930 else
931 frame = &ctx->d_frame;
932
933 /* Check to see if scaling ratio is within supported range */
934 if (mtk_mdp_ctx_state_is_set(ctx, MTK_MDP_DST_FMT | MTK_MDP_SRC_FMT)) {
935 if (V4L2_TYPE_IS_OUTPUT(s->type)) {
936 ret = mtk_mdp_check_scaler_ratio(variant, new_r.width,
937 new_r.height, ctx->d_frame.crop.width,
938 ctx->d_frame.crop.height,
939 ctx->ctrls.rotate->val);
940 } else {
941 ret = mtk_mdp_check_scaler_ratio(variant,
942 ctx->s_frame.crop.width,
943 ctx->s_frame.crop.height, new_r.width,
944 new_r.height, ctx->ctrls.rotate->val);
945 }
946
947 if (ret) {
948 dev_info(&ctx->mdp_dev->pdev->dev,
949 "Out of scaler range");
950 return -EINVAL;
951 }
952 }
953
954 s->r = new_r;
955 frame->crop = new_r;
956
957 return 0;
958}
959
960static const struct v4l2_ioctl_ops mtk_mdp_m2m_ioctl_ops = {
961 .vidioc_querycap = mtk_mdp_m2m_querycap,
962 .vidioc_enum_fmt_vid_cap_mplane = mtk_mdp_m2m_enum_fmt_mplane_vid_cap,
963 .vidioc_enum_fmt_vid_out_mplane = mtk_mdp_m2m_enum_fmt_mplane_vid_out,
964 .vidioc_g_fmt_vid_cap_mplane = mtk_mdp_m2m_g_fmt_mplane,
965 .vidioc_g_fmt_vid_out_mplane = mtk_mdp_m2m_g_fmt_mplane,
966 .vidioc_try_fmt_vid_cap_mplane = mtk_mdp_m2m_try_fmt_mplane,
967 .vidioc_try_fmt_vid_out_mplane = mtk_mdp_m2m_try_fmt_mplane,
968 .vidioc_s_fmt_vid_cap_mplane = mtk_mdp_m2m_s_fmt_mplane,
969 .vidioc_s_fmt_vid_out_mplane = mtk_mdp_m2m_s_fmt_mplane,
970 .vidioc_reqbufs = mtk_mdp_m2m_reqbufs,
971 .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
972 .vidioc_expbuf = v4l2_m2m_ioctl_expbuf,
973 .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
974 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
975 .vidioc_querybuf = v4l2_m2m_ioctl_querybuf,
976 .vidioc_qbuf = v4l2_m2m_ioctl_qbuf,
977 .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf,
978 .vidioc_streamon = mtk_mdp_m2m_streamon,
979 .vidioc_streamoff = v4l2_m2m_ioctl_streamoff,
980 .vidioc_g_selection = mtk_mdp_m2m_g_selection,
981 .vidioc_s_selection = mtk_mdp_m2m_s_selection
982};
983
984static int mtk_mdp_m2m_queue_init(void *priv, struct vb2_queue *src_vq,
985 struct vb2_queue *dst_vq)
986{
987 struct mtk_mdp_ctx *ctx = priv;
988 int ret;
989
990 memset(src_vq, 0, sizeof(*src_vq));
991 src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
992 src_vq->io_modes = VB2_MMAP | VB2_DMABUF;
993 src_vq->drv_priv = ctx;
994 src_vq->ops = &mtk_mdp_m2m_qops;
995 src_vq->mem_ops = &vb2_dma_contig_memops;
996 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
997 src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
998 src_vq->dev = &ctx->mdp_dev->pdev->dev;
999
1000 ret = vb2_queue_init(src_vq);
1001 if (ret)
1002 return ret;
1003
1004 memset(dst_vq, 0, sizeof(*dst_vq));
1005 dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
1006 dst_vq->io_modes = VB2_MMAP | VB2_DMABUF;
1007 dst_vq->drv_priv = ctx;
1008 dst_vq->ops = &mtk_mdp_m2m_qops;
1009 dst_vq->mem_ops = &vb2_dma_contig_memops;
1010 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
1011 dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
1012 dst_vq->dev = &ctx->mdp_dev->pdev->dev;
1013
1014 return vb2_queue_init(dst_vq);
1015}
1016
1017static int mtk_mdp_s_ctrl(struct v4l2_ctrl *ctrl)
1018{
1019 struct mtk_mdp_ctx *ctx = ctrl_to_ctx(ctrl);
1020 struct mtk_mdp_dev *mdp = ctx->mdp_dev;
1021 struct mtk_mdp_variant *variant = mdp->variant;
1022 u32 state = MTK_MDP_DST_FMT | MTK_MDP_SRC_FMT;
1023 int ret = 0;
1024
1025 if (ctrl->flags & V4L2_CTRL_FLAG_INACTIVE)
1026 return 0;
1027
1028 switch (ctrl->id) {
1029 case V4L2_CID_HFLIP:
1030 ctx->hflip = ctrl->val;
1031 break;
1032 case V4L2_CID_VFLIP:
1033 ctx->vflip = ctrl->val;
1034 break;
1035 case V4L2_CID_ROTATE:
1036 if (mtk_mdp_ctx_state_is_set(ctx, state)) {
1037 ret = mtk_mdp_check_scaler_ratio(variant,
1038 ctx->s_frame.crop.width,
1039 ctx->s_frame.crop.height,
1040 ctx->d_frame.crop.width,
1041 ctx->d_frame.crop.height,
1042 ctx->ctrls.rotate->val);
1043
1044 if (ret)
1045 return -EINVAL;
1046 }
1047
1048 ctx->rotation = ctrl->val;
1049 break;
1050 case V4L2_CID_ALPHA_COMPONENT:
1051 ctx->d_frame.alpha = ctrl->val;
1052 break;
1053 }
1054
1055 return 0;
1056}
1057
1058static const struct v4l2_ctrl_ops mtk_mdp_ctrl_ops = {
1059 .s_ctrl = mtk_mdp_s_ctrl,
1060};
1061
1062static int mtk_mdp_ctrls_create(struct mtk_mdp_ctx *ctx)
1063{
1064 v4l2_ctrl_handler_init(&ctx->ctrl_handler, MTK_MDP_MAX_CTRL_NUM);
1065
1066 ctx->ctrls.rotate = v4l2_ctrl_new_std(&ctx->ctrl_handler,
1067 &mtk_mdp_ctrl_ops, V4L2_CID_ROTATE, 0, 270, 90, 0);
1068 ctx->ctrls.hflip = v4l2_ctrl_new_std(&ctx->ctrl_handler,
1069 &mtk_mdp_ctrl_ops,
1070 V4L2_CID_HFLIP,
1071 0, 1, 1, 0);
1072 ctx->ctrls.vflip = v4l2_ctrl_new_std(&ctx->ctrl_handler,
1073 &mtk_mdp_ctrl_ops,
1074 V4L2_CID_VFLIP,
1075 0, 1, 1, 0);
1076 ctx->ctrls.global_alpha = v4l2_ctrl_new_std(&ctx->ctrl_handler,
1077 &mtk_mdp_ctrl_ops,
1078 V4L2_CID_ALPHA_COMPONENT,
1079 0, 255, 1, 0);
1080 ctx->ctrls_rdy = ctx->ctrl_handler.error == 0;
1081
1082 if (ctx->ctrl_handler.error) {
1083 int err = ctx->ctrl_handler.error;
1084
1085 v4l2_ctrl_handler_free(&ctx->ctrl_handler);
1086 dev_err(&ctx->mdp_dev->pdev->dev,
1087 "Failed to create control handlers\n");
1088 return err;
1089 }
1090
1091 return 0;
1092}
1093
1094static void mtk_mdp_set_default_params(struct mtk_mdp_ctx *ctx)
1095{
1096 struct mtk_mdp_dev *mdp = ctx->mdp_dev;
1097 struct mtk_mdp_frame *frame;
1098
1099 frame = mtk_mdp_ctx_get_frame(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
1100 frame->fmt = mtk_mdp_find_fmt_by_index(0,
1101 V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
1102 frame->width = mdp->variant->pix_min->org_w;
1103 frame->height = mdp->variant->pix_min->org_h;
1104 frame->payload[0] = frame->width * frame->height;
1105 frame->payload[1] = frame->payload[0] / 2;
1106
1107 frame = mtk_mdp_ctx_get_frame(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
1108 frame->fmt = mtk_mdp_find_fmt_by_index(0,
1109 V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
1110 frame->width = mdp->variant->pix_min->target_rot_dis_w;
1111 frame->height = mdp->variant->pix_min->target_rot_dis_h;
1112 frame->payload[0] = frame->width * frame->height;
1113 frame->payload[1] = frame->payload[0] / 2;
1114
1115}
1116
1117static int mtk_mdp_m2m_open(struct file *file)
1118{
1119 struct mtk_mdp_dev *mdp = video_drvdata(file);
1120 struct video_device *vfd = video_devdata(file);
1121 struct mtk_mdp_ctx *ctx = NULL;
1122 int ret;
1123
1124 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
1125 if (!ctx)
1126 return -ENOMEM;
1127
1128 if (mutex_lock_interruptible(&mdp->lock)) {
1129 ret = -ERESTARTSYS;
1130 goto err_lock;
1131 }
1132
1133 mutex_init(&ctx->slock);
1134 ctx->id = mdp->id_counter++;
1135 v4l2_fh_init(&ctx->fh, vfd);
1136 file->private_data = &ctx->fh;
1137 ret = mtk_mdp_ctrls_create(ctx);
1138 if (ret)
1139 goto error_ctrls;
1140
1141 /* Use separate control handler per file handle */
1142 ctx->fh.ctrl_handler = &ctx->ctrl_handler;
1143 v4l2_fh_add(&ctx->fh);
1144 INIT_LIST_HEAD(&ctx->list);
1145
1146 ctx->mdp_dev = mdp;
1147 mtk_mdp_set_default_params(ctx);
1148
1149 INIT_WORK(&ctx->work, mtk_mdp_m2m_worker);
1150 ctx->m2m_ctx = v4l2_m2m_ctx_init(mdp->m2m_dev, ctx,
1151 mtk_mdp_m2m_queue_init);
1152 if (IS_ERR(ctx->m2m_ctx)) {
1153 dev_err(&mdp->pdev->dev, "Failed to initialize m2m context");
1154 ret = PTR_ERR(ctx->m2m_ctx);
1155 goto error_m2m_ctx;
1156 }
1157 ctx->fh.m2m_ctx = ctx->m2m_ctx;
1158 if (mdp->ctx_num++ == 0) {
1159 ret = vpu_load_firmware(mdp->vpu_dev);
1160 if (ret < 0) {
1161 dev_err(&mdp->pdev->dev,
1162 "vpu_load_firmware failed %d\n", ret);
1163 goto err_load_vpu;
1164 }
1165
1166 ret = mtk_mdp_vpu_register(mdp->pdev);
1167 if (ret < 0) {
1168 dev_err(&mdp->pdev->dev,
1169 "mdp_vpu register failed %d\n", ret);
1170 goto err_load_vpu;
1171 }
1172 }
1173
1174 list_add(&ctx->list, &mdp->ctx_list);
1175 mutex_unlock(&mdp->lock);
1176
1177 mtk_mdp_dbg(0, "%s [%d]", dev_name(&mdp->pdev->dev), ctx->id);
1178
1179 return 0;
1180
1181err_load_vpu:
1182 mdp->ctx_num--;
1183 v4l2_m2m_ctx_release(ctx->m2m_ctx);
1184error_m2m_ctx:
1185 v4l2_ctrl_handler_free(&ctx->ctrl_handler);
1186error_ctrls:
1187 v4l2_fh_del(&ctx->fh);
1188 v4l2_fh_exit(&ctx->fh);
1189 mutex_unlock(&mdp->lock);
1190err_lock:
1191 kfree(ctx);
1192
1193 return ret;
1194}
1195
1196static int mtk_mdp_m2m_release(struct file *file)
1197{
1198 struct mtk_mdp_ctx *ctx = fh_to_ctx(file->private_data);
1199 struct mtk_mdp_dev *mdp = ctx->mdp_dev;
1200
1201 flush_workqueue(mdp->job_wq);
1202 mutex_lock(&mdp->lock);
1203 v4l2_m2m_ctx_release(ctx->m2m_ctx);
1204 v4l2_ctrl_handler_free(&ctx->ctrl_handler);
1205 v4l2_fh_del(&ctx->fh);
1206 v4l2_fh_exit(&ctx->fh);
1207 mtk_mdp_vpu_deinit(&ctx->vpu);
1208 mdp->ctx_num--;
1209 list_del_init(&ctx->list);
1210
1211 mtk_mdp_dbg(0, "%s [%d]", dev_name(&mdp->pdev->dev), ctx->id);
1212
1213 mutex_unlock(&mdp->lock);
1214 kfree(ctx);
1215
1216 return 0;
1217}
1218
1219static const struct v4l2_file_operations mtk_mdp_m2m_fops = {
1220 .owner = THIS_MODULE,
1221 .open = mtk_mdp_m2m_open,
1222 .release = mtk_mdp_m2m_release,
1223 .poll = v4l2_m2m_fop_poll,
1224 .unlocked_ioctl = video_ioctl2,
1225 .mmap = v4l2_m2m_fop_mmap,
1226};
1227
1228static struct v4l2_m2m_ops mtk_mdp_m2m_ops = {
1229 .device_run = mtk_mdp_m2m_device_run,
1230 .job_abort = mtk_mdp_m2m_job_abort,
1231};
1232
1233int mtk_mdp_register_m2m_device(struct mtk_mdp_dev *mdp)
1234{
1235 struct device *dev = &mdp->pdev->dev;
1236 int ret;
1237
1238 mdp->variant = &mtk_mdp_default_variant;
1239 mdp->vdev = video_device_alloc();
1240 if (!mdp->vdev) {
1241 dev_err(dev, "failed to allocate video device\n");
1242 ret = -ENOMEM;
1243 goto err_video_alloc;
1244 }
1245 mdp->vdev->device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING;
1246 mdp->vdev->fops = &mtk_mdp_m2m_fops;
1247 mdp->vdev->ioctl_ops = &mtk_mdp_m2m_ioctl_ops;
1248 mdp->vdev->release = video_device_release;
1249 mdp->vdev->lock = &mdp->lock;
1250 mdp->vdev->vfl_dir = VFL_DIR_M2M;
1251 mdp->vdev->v4l2_dev = &mdp->v4l2_dev;
1252 snprintf(mdp->vdev->name, sizeof(mdp->vdev->name), "%s:m2m",
1253 MTK_MDP_MODULE_NAME);
1254 video_set_drvdata(mdp->vdev, mdp);
1255
1256 mdp->m2m_dev = v4l2_m2m_init(&mtk_mdp_m2m_ops);
1257 if (IS_ERR(mdp->m2m_dev)) {
1258 dev_err(dev, "failed to initialize v4l2-m2m device\n");
1259 ret = PTR_ERR(mdp->m2m_dev);
1260 goto err_m2m_init;
1261 }
1262
1263 ret = video_register_device(mdp->vdev, VFL_TYPE_GRABBER, 2);
1264 if (ret) {
1265 dev_err(dev, "failed to register video device\n");
1266 goto err_vdev_register;
1267 }
1268
1269 v4l2_info(&mdp->v4l2_dev, "driver registered as /dev/video%d",
1270 mdp->vdev->num);
1271 return 0;
1272
1273err_vdev_register:
1274 v4l2_m2m_release(mdp->m2m_dev);
1275err_m2m_init:
1276 video_device_release(mdp->vdev);
1277err_video_alloc:
1278
1279 return ret;
1280}
1281
1282void mtk_mdp_unregister_m2m_device(struct mtk_mdp_dev *mdp)
1283{
1284 video_unregister_device(mdp->vdev);
1285 v4l2_m2m_release(mdp->m2m_dev);
1286}
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h
new file mode 100644
index 000000000000..45afd3655817
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h
@@ -0,0 +1,22 @@
1/*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: Ming Hsiu Tsai <minghsiu.tsai@mediatek.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 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#ifndef __MTK_MDP_M2M_H__
16#define __MTK_MDP_M2M_H__
17
18void mtk_mdp_ctx_state_lock_set(struct mtk_mdp_ctx *ctx, u32 state);
19int mtk_mdp_register_m2m_device(struct mtk_mdp_dev *mdp);
20void mtk_mdp_unregister_m2m_device(struct mtk_mdp_dev *mdp);
21
22#endif /* __MTK_MDP_M2M_H__ */
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_regs.c b/drivers/media/platform/mtk-mdp/mtk_mdp_regs.c
new file mode 100644
index 000000000000..86d57f380c97
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_regs.c
@@ -0,0 +1,156 @@
1/*
2 * Copyright (c) 2015-2016 MediaTek Inc.
3 * Author: Houlong Wei <houlong.wei@mediatek.com>
4 * Ming Hsiu Tsai <minghsiu.tsai@mediatek.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 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/platform_device.h>
17
18#include "mtk_mdp_core.h"
19#include "mtk_mdp_regs.h"
20
21
22#define MDP_COLORFMT_PACK(VIDEO, PLANE, COPLANE, HF, VF, BITS, GROUP, SWAP, ID)\
23 (((VIDEO) << 27) | ((PLANE) << 24) | ((COPLANE) << 22) |\
24 ((HF) << 20) | ((VF) << 18) | ((BITS) << 8) | ((GROUP) << 6) |\
25 ((SWAP) << 5) | ((ID) << 0))
26
27enum MDP_COLOR_ENUM {
28 MDP_COLOR_UNKNOWN = 0,
29 MDP_COLOR_NV12 = MDP_COLORFMT_PACK(0, 2, 1, 1, 1, 8, 1, 0, 12),
30 MDP_COLOR_I420 = MDP_COLORFMT_PACK(0, 3, 0, 1, 1, 8, 1, 0, 8),
31 MDP_COLOR_YV12 = MDP_COLORFMT_PACK(0, 3, 0, 1, 1, 8, 1, 1, 8),
32 /* Mediatek proprietary format */
33 MDP_COLOR_420_MT21 = MDP_COLORFMT_PACK(5, 2, 1, 1, 1, 256, 1, 0, 12),
34};
35
36static int32_t mtk_mdp_map_color_format(int v4l2_format)
37{
38 switch (v4l2_format) {
39 case V4L2_PIX_FMT_NV12M:
40 case V4L2_PIX_FMT_NV12:
41 return MDP_COLOR_NV12;
42 case V4L2_PIX_FMT_MT21C:
43 return MDP_COLOR_420_MT21;
44 case V4L2_PIX_FMT_YUV420M:
45 case V4L2_PIX_FMT_YUV420:
46 return MDP_COLOR_I420;
47 case V4L2_PIX_FMT_YVU420:
48 return MDP_COLOR_YV12;
49 }
50
51 mtk_mdp_err("Unknown format 0x%x", v4l2_format);
52
53 return MDP_COLOR_UNKNOWN;
54}
55
56void mtk_mdp_hw_set_input_addr(struct mtk_mdp_ctx *ctx,
57 struct mtk_mdp_addr *addr)
58{
59 struct mdp_buffer *src_buf = &ctx->vpu.vsi->src_buffer;
60 int i;
61
62 for (i = 0; i < ARRAY_SIZE(addr->addr); i++)
63 src_buf->addr_mva[i] = (uint64_t)addr->addr[i];
64}
65
66void mtk_mdp_hw_set_output_addr(struct mtk_mdp_ctx *ctx,
67 struct mtk_mdp_addr *addr)
68{
69 struct mdp_buffer *dst_buf = &ctx->vpu.vsi->dst_buffer;
70 int i;
71
72 for (i = 0; i < ARRAY_SIZE(addr->addr); i++)
73 dst_buf->addr_mva[i] = (uint64_t)addr->addr[i];
74}
75
76void mtk_mdp_hw_set_in_size(struct mtk_mdp_ctx *ctx)
77{
78 struct mtk_mdp_frame *frame = &ctx->s_frame;
79 struct mdp_config *config = &ctx->vpu.vsi->src_config;
80
81 /* Set input pixel offset */
82 config->crop_x = frame->crop.left;
83 config->crop_y = frame->crop.top;
84
85 /* Set input cropped size */
86 config->crop_w = frame->crop.width;
87 config->crop_h = frame->crop.height;
88
89 /* Set input original size */
90 config->x = 0;
91 config->y = 0;
92 config->w = frame->width;
93 config->h = frame->height;
94}
95
96void mtk_mdp_hw_set_in_image_format(struct mtk_mdp_ctx *ctx)
97{
98 unsigned int i;
99 struct mtk_mdp_frame *frame = &ctx->s_frame;
100 struct mdp_config *config = &ctx->vpu.vsi->src_config;
101 struct mdp_buffer *src_buf = &ctx->vpu.vsi->src_buffer;
102
103 src_buf->plane_num = frame->fmt->num_comp;
104 config->format = mtk_mdp_map_color_format(frame->fmt->pixelformat);
105 config->w_stride = 0; /* MDP will calculate it by color format. */
106 config->h_stride = 0; /* MDP will calculate it by color format. */
107
108 for (i = 0; i < src_buf->plane_num; i++)
109 src_buf->plane_size[i] = frame->payload[i];
110}
111
112void mtk_mdp_hw_set_out_size(struct mtk_mdp_ctx *ctx)
113{
114 struct mtk_mdp_frame *frame = &ctx->d_frame;
115 struct mdp_config *config = &ctx->vpu.vsi->dst_config;
116
117 config->crop_x = frame->crop.left;
118 config->crop_y = frame->crop.top;
119 config->crop_w = frame->crop.width;
120 config->crop_h = frame->crop.height;
121 config->x = 0;
122 config->y = 0;
123 config->w = frame->width;
124 config->h = frame->height;
125}
126
127void mtk_mdp_hw_set_out_image_format(struct mtk_mdp_ctx *ctx)
128{
129 unsigned int i;
130 struct mtk_mdp_frame *frame = &ctx->d_frame;
131 struct mdp_config *config = &ctx->vpu.vsi->dst_config;
132 struct mdp_buffer *dst_buf = &ctx->vpu.vsi->dst_buffer;
133
134 dst_buf->plane_num = frame->fmt->num_comp;
135 config->format = mtk_mdp_map_color_format(frame->fmt->pixelformat);
136 config->w_stride = 0; /* MDP will calculate it by color format. */
137 config->h_stride = 0; /* MDP will calculate it by color format. */
138 for (i = 0; i < dst_buf->plane_num; i++)
139 dst_buf->plane_size[i] = frame->payload[i];
140}
141
142void mtk_mdp_hw_set_rotation(struct mtk_mdp_ctx *ctx)
143{
144 struct mdp_config_misc *misc = &ctx->vpu.vsi->misc;
145
146 misc->orientation = ctx->ctrls.rotate->val;
147 misc->hflip = ctx->ctrls.hflip->val;
148 misc->vflip = ctx->ctrls.vflip->val;
149}
150
151void mtk_mdp_hw_set_global_alpha(struct mtk_mdp_ctx *ctx)
152{
153 struct mdp_config_misc *misc = &ctx->vpu.vsi->misc;
154
155 misc->alpha = ctx->ctrls.global_alpha->val;
156}
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_regs.h b/drivers/media/platform/mtk-mdp/mtk_mdp_regs.h
new file mode 100644
index 000000000000..42bd057e76cc
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_regs.h
@@ -0,0 +1,31 @@
1/*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: Ming Hsiu Tsai <minghsiu.tsai@mediatek.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 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#ifndef __MTK_MDP_REGS_H__
16#define __MTK_MDP_REGS_H__
17
18
19void mtk_mdp_hw_set_input_addr(struct mtk_mdp_ctx *ctx,
20 struct mtk_mdp_addr *addr);
21void mtk_mdp_hw_set_output_addr(struct mtk_mdp_ctx *ctx,
22 struct mtk_mdp_addr *addr);
23void mtk_mdp_hw_set_in_size(struct mtk_mdp_ctx *ctx);
24void mtk_mdp_hw_set_in_image_format(struct mtk_mdp_ctx *ctx);
25void mtk_mdp_hw_set_out_size(struct mtk_mdp_ctx *ctx);
26void mtk_mdp_hw_set_out_image_format(struct mtk_mdp_ctx *ctx);
27void mtk_mdp_hw_set_rotation(struct mtk_mdp_ctx *ctx);
28void mtk_mdp_hw_set_global_alpha(struct mtk_mdp_ctx *ctx);
29
30
31#endif /* __MTK_MDP_REGS_H__ */
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c b/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
new file mode 100644
index 000000000000..4893825aa5dd
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
@@ -0,0 +1,145 @@
1/*
2 * Copyright (c) 2015-2016 MediaTek Inc.
3 * Author: Houlong Wei <houlong.wei@mediatek.com>
4 * Ming Hsiu Tsai <minghsiu.tsai@mediatek.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 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include "mtk_mdp_core.h"
17#include "mtk_mdp_vpu.h"
18#include "mtk_vpu.h"
19
20
21static inline struct mtk_mdp_ctx *vpu_to_ctx(struct mtk_mdp_vpu *vpu)
22{
23 return container_of(vpu, struct mtk_mdp_ctx, vpu);
24}
25
26static void mtk_mdp_vpu_handle_init_ack(struct mdp_ipi_comm_ack *msg)
27{
28 struct mtk_mdp_vpu *vpu = (struct mtk_mdp_vpu *)
29 (unsigned long)msg->ap_inst;
30
31 /* mapping VPU address to kernel virtual address */
32 vpu->vsi = (struct mdp_process_vsi *)
33 vpu_mapping_dm_addr(vpu->pdev, msg->vpu_inst_addr);
34 vpu->inst_addr = msg->vpu_inst_addr;
35}
36
37static void mtk_mdp_vpu_ipi_handler(void *data, unsigned int len, void *priv)
38{
39 unsigned int msg_id = *(unsigned int *)data;
40 struct mdp_ipi_comm_ack *msg = (struct mdp_ipi_comm_ack *)data;
41 struct mtk_mdp_vpu *vpu = (struct mtk_mdp_vpu *)
42 (unsigned long)msg->ap_inst;
43 struct mtk_mdp_ctx *ctx;
44
45 vpu->failure = msg->status;
46 if (!vpu->failure) {
47 switch (msg_id) {
48 case VPU_MDP_INIT_ACK:
49 mtk_mdp_vpu_handle_init_ack(data);
50 break;
51 case VPU_MDP_DEINIT_ACK:
52 case VPU_MDP_PROCESS_ACK:
53 break;
54 default:
55 ctx = vpu_to_ctx(vpu);
56 dev_err(&ctx->mdp_dev->pdev->dev,
57 "handle unknown ipi msg:0x%x\n",
58 msg_id);
59 break;
60 }
61 } else {
62 ctx = vpu_to_ctx(vpu);
63 mtk_mdp_dbg(0, "[%d]:msg 0x%x, failure:%d", ctx->id,
64 msg_id, vpu->failure);
65 }
66}
67
68int mtk_mdp_vpu_register(struct platform_device *pdev)
69{
70 struct mtk_mdp_dev *mdp = platform_get_drvdata(pdev);
71 int err;
72
73 err = vpu_ipi_register(mdp->vpu_dev, IPI_MDP,
74 mtk_mdp_vpu_ipi_handler, "mdp_vpu", NULL);
75 if (err)
76 dev_err(&mdp->pdev->dev,
77 "vpu_ipi_registration fail status=%d\n", err);
78
79 return err;
80}
81
82static int mtk_mdp_vpu_send_msg(void *msg, int len, struct mtk_mdp_vpu *vpu,
83 int id)
84{
85 struct mtk_mdp_ctx *ctx = vpu_to_ctx(vpu);
86 int err;
87
88 if (!vpu->pdev) {
89 mtk_mdp_dbg(1, "[%d]:vpu pdev is NULL", ctx->id);
90 return -EINVAL;
91 }
92
93 mutex_lock(&ctx->mdp_dev->vpulock);
94 err = vpu_ipi_send(vpu->pdev, (enum ipi_id)id, msg, len);
95 if (err)
96 dev_err(&ctx->mdp_dev->pdev->dev,
97 "vpu_ipi_send fail status %d\n", err);
98 mutex_unlock(&ctx->mdp_dev->vpulock);
99
100 return err;
101}
102
103static int mtk_mdp_vpu_send_ap_ipi(struct mtk_mdp_vpu *vpu, uint32_t msg_id)
104{
105 int err;
106 struct mdp_ipi_comm msg;
107
108 msg.msg_id = msg_id;
109 msg.ipi_id = IPI_MDP;
110 msg.vpu_inst_addr = vpu->inst_addr;
111 msg.ap_inst = (unsigned long)vpu;
112 err = mtk_mdp_vpu_send_msg((void *)&msg, sizeof(msg), vpu, IPI_MDP);
113 if (!err && vpu->failure)
114 err = -EINVAL;
115
116 return err;
117}
118
119int mtk_mdp_vpu_init(struct mtk_mdp_vpu *vpu)
120{
121 int err;
122 struct mdp_ipi_init msg;
123 struct mtk_mdp_ctx *ctx = vpu_to_ctx(vpu);
124
125 vpu->pdev = ctx->mdp_dev->vpu_dev;
126
127 msg.msg_id = AP_MDP_INIT;
128 msg.ipi_id = IPI_MDP;
129 msg.ap_inst = (unsigned long)vpu;
130 err = mtk_mdp_vpu_send_msg((void *)&msg, sizeof(msg), vpu, IPI_MDP);
131 if (!err && vpu->failure)
132 err = -EINVAL;
133
134 return err;
135}
136
137int mtk_mdp_vpu_deinit(struct mtk_mdp_vpu *vpu)
138{
139 return mtk_mdp_vpu_send_ap_ipi(vpu, AP_MDP_DEINIT);
140}
141
142int mtk_mdp_vpu_process(struct mtk_mdp_vpu *vpu)
143{
144 return mtk_mdp_vpu_send_ap_ipi(vpu, AP_MDP_PROCESS);
145}
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h b/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h
new file mode 100644
index 000000000000..df4bddaa438e
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h
@@ -0,0 +1,41 @@
1/*
2 * Copyright (c) 2015-2016 MediaTek Inc.
3 * Author: Houlong Wei <houlong.wei@mediatek.com>
4 * Ming Hsiu Tsai <minghsiu.tsai@mediatek.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 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef __MTK_MDP_VPU_H__
17#define __MTK_MDP_VPU_H__
18
19#include "mtk_mdp_ipi.h"
20
21
22/**
23 * struct mtk_mdp_vpu - VPU instance for MDP
24 * @pdev : pointer to the VPU platform device
25 * @inst_addr : VPU MDP instance address
26 * @failure : VPU execution result status
27 * @vsi : VPU shared information
28 */
29struct mtk_mdp_vpu {
30 struct platform_device *pdev;
31 uint32_t inst_addr;
32 int32_t failure;
33 struct mdp_process_vsi *vsi;
34};
35
36int mtk_mdp_vpu_register(struct platform_device *pdev);
37int mtk_mdp_vpu_init(struct mtk_mdp_vpu *vpu);
38int mtk_mdp_vpu_deinit(struct mtk_mdp_vpu *vpu);
39int mtk_mdp_vpu_process(struct mtk_mdp_vpu *vpu);
40
41#endif /* __MTK_MDP_VPU_H__ */
diff --git a/drivers/media/platform/mtk-vcodec/Makefile b/drivers/media/platform/mtk-vcodec/Makefile
index dc5cb006d600..852d9697ccfa 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -1,7 +1,16 @@
1 1
2 2obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-dec.o \
3obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-enc.o mtk-vcodec-common.o 3 mtk-vcodec-enc.o \
4 4 mtk-vcodec-common.o
5
6mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
7 vdec/vdec_vp8_if.o \
8 vdec/vdec_vp9_if.o \
9 mtk_vcodec_dec_drv.o \
10 vdec_drv_if.o \
11 vdec_vpu_if.o \
12 mtk_vcodec_dec.o \
13 mtk_vcodec_dec_pm.o \
5 14
6 15
7mtk-vcodec-enc-y := venc/venc_vp8_if.o \ 16mtk-vcodec-enc-y := venc/venc_vp8_if.o \
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
new file mode 100644
index 000000000000..074659227864
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -0,0 +1,1451 @@
1/*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: PC Chen <pc.chen@mediatek.com>
4 * Tiffany Lin <tiffany.lin@mediatek.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 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <media/v4l2-event.h>
17#include <media/v4l2-mem2mem.h>
18#include <media/videobuf2-dma-contig.h>
19
20#include "mtk_vcodec_drv.h"
21#include "mtk_vcodec_dec.h"
22#include "mtk_vcodec_intr.h"
23#include "mtk_vcodec_util.h"
24#include "vdec_drv_if.h"
25#include "mtk_vcodec_dec_pm.h"
26
27#define OUT_FMT_IDX 0
28#define CAP_FMT_IDX 3
29
30#define MTK_VDEC_MIN_W 64U
31#define MTK_VDEC_MIN_H 64U
32#define DFT_CFG_WIDTH MTK_VDEC_MIN_W
33#define DFT_CFG_HEIGHT MTK_VDEC_MIN_H
34
35static struct mtk_video_fmt mtk_video_formats[] = {
36 {
37 .fourcc = V4L2_PIX_FMT_H264,
38 .type = MTK_FMT_DEC,
39 .num_planes = 1,
40 },
41 {
42 .fourcc = V4L2_PIX_FMT_VP8,
43 .type = MTK_FMT_DEC,
44 .num_planes = 1,
45 },
46 {
47 .fourcc = V4L2_PIX_FMT_VP9,
48 .type = MTK_FMT_DEC,
49 .num_planes = 1,
50 },
51 {
52 .fourcc = V4L2_PIX_FMT_MT21C,
53 .type = MTK_FMT_FRAME,
54 .num_planes = 2,
55 },
56};
57
58static const struct mtk_codec_framesizes mtk_vdec_framesizes[] = {
59 {
60 .fourcc = V4L2_PIX_FMT_H264,
61 .stepwise = { MTK_VDEC_MIN_W, MTK_VDEC_MAX_W, 16,
62 MTK_VDEC_MIN_H, MTK_VDEC_MAX_H, 16 },
63 },
64 {
65 .fourcc = V4L2_PIX_FMT_VP8,
66 .stepwise = { MTK_VDEC_MIN_W, MTK_VDEC_MAX_W, 16,
67 MTK_VDEC_MIN_H, MTK_VDEC_MAX_H, 16 },
68 },
69 {
70 .fourcc = V4L2_PIX_FMT_VP9,
71 .stepwise = { MTK_VDEC_MIN_W, MTK_VDEC_MAX_W, 16,
72 MTK_VDEC_MIN_H, MTK_VDEC_MAX_H, 16 },
73 },
74};
75
76#define NUM_SUPPORTED_FRAMESIZE ARRAY_SIZE(mtk_vdec_framesizes)
77#define NUM_FORMATS ARRAY_SIZE(mtk_video_formats)
78
79static struct mtk_video_fmt *mtk_vdec_find_format(struct v4l2_format *f)
80{
81 struct mtk_video_fmt *fmt;
82 unsigned int k;
83
84 for (k = 0; k < NUM_FORMATS; k++) {
85 fmt = &mtk_video_formats[k];
86 if (fmt->fourcc == f->fmt.pix_mp.pixelformat)
87 return fmt;
88 }
89
90 return NULL;
91}
92
93static struct mtk_q_data *mtk_vdec_get_q_data(struct mtk_vcodec_ctx *ctx,
94 enum v4l2_buf_type type)
95{
96 if (V4L2_TYPE_IS_OUTPUT(type))
97 return &ctx->q_data[MTK_Q_DATA_SRC];
98
99 return &ctx->q_data[MTK_Q_DATA_DST];
100}
101
102/*
103 * This function tries to clean all display buffers, the buffers will return
104 * in display order.
105 * Note the buffers returned from codec driver may still be in driver's
106 * reference list.
107 */
108static struct vb2_buffer *get_display_buffer(struct mtk_vcodec_ctx *ctx)
109{
110 struct vdec_fb *disp_frame_buffer = NULL;
111 struct mtk_video_dec_buf *dstbuf;
112
113 mtk_v4l2_debug(3, "[%d]", ctx->id);
114 if (vdec_if_get_param(ctx,
115 GET_PARAM_DISP_FRAME_BUFFER,
116 &disp_frame_buffer)) {
117 mtk_v4l2_err("[%d]Cannot get param : GET_PARAM_DISP_FRAME_BUFFER",
118 ctx->id);
119 return NULL;
120 }
121
122 if (disp_frame_buffer == NULL) {
123 mtk_v4l2_debug(3, "No display frame buffer");
124 return NULL;
125 }
126
127 dstbuf = container_of(disp_frame_buffer, struct mtk_video_dec_buf,
128 frame_buffer);
129 mutex_lock(&ctx->lock);
130 if (dstbuf->used) {
131 vb2_set_plane_payload(&dstbuf->vb.vb2_buf, 0,
132 ctx->picinfo.y_bs_sz);
133 vb2_set_plane_payload(&dstbuf->vb.vb2_buf, 1,
134 ctx->picinfo.c_bs_sz);
135
136 dstbuf->ready_to_display = true;
137
138 mtk_v4l2_debug(2,
139 "[%d]status=%x queue id=%d to done_list %d",
140 ctx->id, disp_frame_buffer->status,
141 dstbuf->vb.vb2_buf.index,
142 dstbuf->queued_in_vb2);
143
144 v4l2_m2m_buf_done(&dstbuf->vb, VB2_BUF_STATE_DONE);
145 ctx->decoded_frame_cnt++;
146 }
147 mutex_unlock(&ctx->lock);
148 return &dstbuf->vb.vb2_buf;
149}
150
151/*
152 * This function tries to clean all capture buffers that are not used as
153 * reference buffers by codec driver any more
154 * In this case, we need re-queue buffer to vb2 buffer if user space
155 * already returns this buffer to v4l2 or this buffer is just the output of
156 * previous sps/pps/resolution change decode, or do nothing if user
157 * space still owns this buffer
158 */
159static struct vb2_buffer *get_free_buffer(struct mtk_vcodec_ctx *ctx)
160{
161 struct mtk_video_dec_buf *dstbuf;
162 struct vdec_fb *free_frame_buffer = NULL;
163
164 if (vdec_if_get_param(ctx,
165 GET_PARAM_FREE_FRAME_BUFFER,
166 &free_frame_buffer)) {
167 mtk_v4l2_err("[%d] Error!! Cannot get param", ctx->id);
168 return NULL;
169 }
170 if (free_frame_buffer == NULL) {
171 mtk_v4l2_debug(3, " No free frame buffer");
172 return NULL;
173 }
174
175 mtk_v4l2_debug(3, "[%d] tmp_frame_addr = 0x%p",
176 ctx->id, free_frame_buffer);
177
178 dstbuf = container_of(free_frame_buffer, struct mtk_video_dec_buf,
179 frame_buffer);
180
181 mutex_lock(&ctx->lock);
182 if (dstbuf->used) {
183 if ((dstbuf->queued_in_vb2) &&
184 (dstbuf->queued_in_v4l2) &&
185 (free_frame_buffer->status == FB_ST_FREE)) {
186 /*
187 * After decode sps/pps or non-display buffer, we don't
188 * need to return capture buffer to user space, but
189 * just re-queue this capture buffer to vb2 queue.
190 * This reduce overheads that dq/q unused capture
191 * buffer. In this case, queued_in_vb2 = true.
192 */
193 mtk_v4l2_debug(2,
194 "[%d]status=%x queue id=%d to rdy_queue %d",
195 ctx->id, free_frame_buffer->status,
196 dstbuf->vb.vb2_buf.index,
197 dstbuf->queued_in_vb2);
198 v4l2_m2m_buf_queue(ctx->m2m_ctx, &dstbuf->vb);
199 } else if ((dstbuf->queued_in_vb2 == false) &&
200 (dstbuf->queued_in_v4l2 == true)) {
201 /*
202 * If buffer in v4l2 driver but not in vb2 queue yet,
203 * and we get this buffer from free_list, it means
204 * that codec driver do not use this buffer as
205 * reference buffer anymore. We should q buffer to vb2
206 * queue, so later work thread could get this buffer
207 * for decode. In this case, queued_in_vb2 = false
208 * means this buffer is not from previous decode
209 * output.
210 */
211 mtk_v4l2_debug(2,
212 "[%d]status=%x queue id=%d to rdy_queue",
213 ctx->id, free_frame_buffer->status,
214 dstbuf->vb.vb2_buf.index);
215 v4l2_m2m_buf_queue(ctx->m2m_ctx, &dstbuf->vb);
216 dstbuf->queued_in_vb2 = true;
217 } else {
218 /*
219 * Codec driver do not need to reference this capture
220 * buffer and this buffer is not in v4l2 driver.
221 * Then we don't need to do any thing, just add log when
222 * we need to debug buffer flow.
223 * When this buffer q from user space, it could
224 * directly q to vb2 buffer
225 */
226 mtk_v4l2_debug(3, "[%d]status=%x err queue id=%d %d %d",
227 ctx->id, free_frame_buffer->status,
228 dstbuf->vb.vb2_buf.index,
229 dstbuf->queued_in_vb2,
230 dstbuf->queued_in_v4l2);
231 }
232 dstbuf->used = false;
233 }
234 mutex_unlock(&ctx->lock);
235 return &dstbuf->vb.vb2_buf;
236}
237
238static void clean_display_buffer(struct mtk_vcodec_ctx *ctx)
239{
240 struct vb2_buffer *framptr;
241
242 do {
243 framptr = get_display_buffer(ctx);
244 } while (framptr);
245}
246
247static void clean_free_buffer(struct mtk_vcodec_ctx *ctx)
248{
249 struct vb2_buffer *framptr;
250
251 do {
252 framptr = get_free_buffer(ctx);
253 } while (framptr);
254}
255
256static void mtk_vdec_queue_res_chg_event(struct mtk_vcodec_ctx *ctx)
257{
258 static const struct v4l2_event ev_src_ch = {
259 .type = V4L2_EVENT_SOURCE_CHANGE,
260 .u.src_change.changes =
261 V4L2_EVENT_SRC_CH_RESOLUTION,
262 };
263
264 mtk_v4l2_debug(1, "[%d]", ctx->id);
265 v4l2_event_queue_fh(&ctx->fh, &ev_src_ch);
266}
267
268static void mtk_vdec_flush_decoder(struct mtk_vcodec_ctx *ctx)
269{
270 bool res_chg;
271 int ret = 0;
272
273 ret = vdec_if_decode(ctx, NULL, NULL, &res_chg);
274 if (ret)
275 mtk_v4l2_err("DecodeFinal failed, ret=%d", ret);
276
277 clean_display_buffer(ctx);
278 clean_free_buffer(ctx);
279}
280
281static void mtk_vdec_pic_info_update(struct mtk_vcodec_ctx *ctx)
282{
283 unsigned int dpbsize = 0;
284 int ret;
285
286 if (vdec_if_get_param(ctx,
287 GET_PARAM_PIC_INFO,
288 &ctx->last_decoded_picinfo)) {
289 mtk_v4l2_err("[%d]Error!! Cannot get param : GET_PARAM_PICTURE_INFO ERR",
290 ctx->id);
291 return;
292 }
293
294 if (ctx->last_decoded_picinfo.pic_w == 0 ||
295 ctx->last_decoded_picinfo.pic_h == 0 ||
296 ctx->last_decoded_picinfo.buf_w == 0 ||
297 ctx->last_decoded_picinfo.buf_h == 0) {
298 mtk_v4l2_err("Cannot get correct pic info");
299 return;
300 }
301
302 if ((ctx->last_decoded_picinfo.pic_w == ctx->picinfo.pic_w) ||
303 (ctx->last_decoded_picinfo.pic_h == ctx->picinfo.pic_h))
304 return;
305
306 mtk_v4l2_debug(1,
307 "[%d]-> new(%d,%d), old(%d,%d), real(%d,%d)",
308 ctx->id, ctx->last_decoded_picinfo.pic_w,
309 ctx->last_decoded_picinfo.pic_h,
310 ctx->picinfo.pic_w, ctx->picinfo.pic_h,
311 ctx->last_decoded_picinfo.buf_w,
312 ctx->last_decoded_picinfo.buf_h);
313
314 ret = vdec_if_get_param(ctx, GET_PARAM_DPB_SIZE, &dpbsize);
315 if (dpbsize == 0)
316 mtk_v4l2_err("Incorrect dpb size, ret=%d", ret);
317
318 ctx->dpb_size = dpbsize;
319}
320
321static void mtk_vdec_worker(struct work_struct *work)
322{
323 struct mtk_vcodec_ctx *ctx = container_of(work, struct mtk_vcodec_ctx,
324 decode_work);
325 struct mtk_vcodec_dev *dev = ctx->dev;
326 struct vb2_buffer *src_buf, *dst_buf;
327 struct mtk_vcodec_mem buf;
328 struct vdec_fb *pfb;
329 bool res_chg = false;
330 int ret;
331 struct mtk_video_dec_buf *dst_buf_info, *src_buf_info;
332 struct vb2_v4l2_buffer *dst_vb2_v4l2, *src_vb2_v4l2;
333
334 src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
335 if (src_buf == NULL) {
336 v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
337 mtk_v4l2_debug(1, "[%d] src_buf empty!!", ctx->id);
338 return;
339 }
340
341 dst_buf = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
342 if (dst_buf == NULL) {
343 v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
344 mtk_v4l2_debug(1, "[%d] dst_buf empty!!", ctx->id);
345 return;
346 }
347
348 src_vb2_v4l2 = container_of(src_buf, struct vb2_v4l2_buffer, vb2_buf);
349 src_buf_info = container_of(src_vb2_v4l2, struct mtk_video_dec_buf, vb);
350
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);
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;
365 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);
367 pfb->base_y.size = ctx->picinfo.y_bs_sz + ctx->picinfo.y_len_sz;
368
369 pfb->base_c.va = vb2_plane_vaddr(dst_buf, 1);
370 pfb->base_c.dma_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 1);
371 pfb->base_c.size = ctx->picinfo.c_bs_sz + ctx->picinfo.c_len_sz;
372 pfb->status = 0;
373 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
377 mtk_v4l2_debug(3,
378 "id=%d Framebuf pfb=%p VA=%p Y_DMA=%pad C_DMA=%pad Size=%zx",
379 dst_buf->index, pfb,
380 pfb->base_y.va, &pfb->base_y.dma_addr,
381 &pfb->base_c.dma_addr, pfb->base_y.size);
382
383 if (src_buf_info->lastframe) {
384 /* update src buf status */
385 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
389 /* update dst buf status */
390 dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
391 dst_buf_info->used = false;
392
393 vdec_if_decode(ctx, NULL, NULL, &res_chg);
394 clean_display_buffer(ctx);
395 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);
397 v4l2_m2m_buf_done(&dst_buf_info->vb, VB2_BUF_STATE_DONE);
398 clean_free_buffer(ctx);
399 v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
400 return;
401 }
402 dst_buf_info->vb.vb2_buf.timestamp
403 = src_buf_info->vb.vb2_buf.timestamp;
404 dst_buf_info->vb.timecode
405 = src_buf_info->vb.timecode;
406 mutex_lock(&ctx->lock);
407 dst_buf_info->used = true;
408 mutex_unlock(&ctx->lock);
409 src_buf_info->used = true;
410
411 ret = vdec_if_decode(ctx, &buf, pfb, &res_chg);
412
413 if (ret) {
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===>",
416 ctx->id,
417 src_buf->index,
418 src_buf_info->lastframe,
419 buf.size,
420 src_buf_info->vb.vb2_buf.timestamp,
421 dst_buf->index,
422 ret, res_chg);
423 src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
424 v4l2_m2m_buf_done(&src_buf_info->vb, VB2_BUF_STATE_ERROR);
425 } else if (res_chg == false) {
426 /*
427 * we only return src buffer with VB2_BUF_STATE_DONE
428 * when decode success without resolution change
429 */
430 src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
431 v4l2_m2m_buf_done(&src_buf_info->vb, VB2_BUF_STATE_DONE);
432 }
433
434 dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
435 clean_display_buffer(ctx);
436 clean_free_buffer(ctx);
437
438 if (!ret && res_chg) {
439 mtk_vdec_pic_info_update(ctx);
440 /*
441 * On encountering a resolution change in the stream.
442 * The driver must first process and decode all
443 * remaining buffers from before the resolution change
444 * point, so call flush decode here
445 */
446 mtk_vdec_flush_decoder(ctx);
447 /*
448 * After all buffers containing decoded frames from
449 * before the resolution change point ready to be
450 * dequeued on the CAPTURE queue, the driver sends a
451 * V4L2_EVENT_SOURCE_CHANGE event for source change
452 * type V4L2_EVENT_SRC_CH_RESOLUTION
453 */
454 mtk_vdec_queue_res_chg_event(ctx);
455 }
456 v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
457}
458
459void mtk_vdec_unlock(struct mtk_vcodec_ctx *ctx)
460{
461 mutex_unlock(&ctx->dev->dec_mutex);
462}
463
464void mtk_vdec_lock(struct mtk_vcodec_ctx *ctx)
465{
466 mutex_lock(&ctx->dev->dec_mutex);
467}
468
469void mtk_vcodec_dec_release(struct mtk_vcodec_ctx *ctx)
470{
471 vdec_if_deinit(ctx);
472 ctx->state = MTK_STATE_FREE;
473}
474
475void mtk_vcodec_dec_set_default_params(struct mtk_vcodec_ctx *ctx)
476{
477 struct mtk_q_data *q_data;
478
479 ctx->m2m_ctx->q_lock = &ctx->dev->dev_mutex;
480 ctx->fh.m2m_ctx = ctx->m2m_ctx;
481 ctx->fh.ctrl_handler = &ctx->ctrl_hdl;
482 INIT_WORK(&ctx->decode_work, mtk_vdec_worker);
483 ctx->colorspace = V4L2_COLORSPACE_REC709;
484 ctx->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
485 ctx->quantization = V4L2_QUANTIZATION_DEFAULT;
486 ctx->xfer_func = V4L2_XFER_FUNC_DEFAULT;
487
488 q_data = &ctx->q_data[MTK_Q_DATA_SRC];
489 memset(q_data, 0, sizeof(struct mtk_q_data));
490 q_data->visible_width = DFT_CFG_WIDTH;
491 q_data->visible_height = DFT_CFG_HEIGHT;
492 q_data->fmt = &mtk_video_formats[OUT_FMT_IDX];
493 q_data->field = V4L2_FIELD_NONE;
494
495 q_data->sizeimage[0] = DFT_CFG_WIDTH * DFT_CFG_HEIGHT;
496 q_data->bytesperline[0] = 0;
497
498 q_data = &ctx->q_data[MTK_Q_DATA_DST];
499 memset(q_data, 0, sizeof(struct mtk_q_data));
500 q_data->visible_width = DFT_CFG_WIDTH;
501 q_data->visible_height = DFT_CFG_HEIGHT;
502 q_data->coded_width = DFT_CFG_WIDTH;
503 q_data->coded_height = DFT_CFG_HEIGHT;
504 q_data->fmt = &mtk_video_formats[CAP_FMT_IDX];
505 q_data->field = V4L2_FIELD_NONE;
506
507 v4l_bound_align_image(&q_data->coded_width,
508 MTK_VDEC_MIN_W,
509 MTK_VDEC_MAX_W, 4,
510 &q_data->coded_height,
511 MTK_VDEC_MIN_H,
512 MTK_VDEC_MAX_H, 5, 6);
513
514 q_data->sizeimage[0] = q_data->coded_width * q_data->coded_height;
515 q_data->bytesperline[0] = q_data->coded_width;
516 q_data->sizeimage[1] = q_data->sizeimage[0] / 2;
517 q_data->bytesperline[1] = q_data->coded_width;
518}
519
520static int vidioc_vdec_qbuf(struct file *file, void *priv,
521 struct v4l2_buffer *buf)
522{
523 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
529 if (ctx->state == MTK_STATE_ABORT) {
530 mtk_v4l2_err("[%d] Call on QBUF after unrecoverable error",
531 ctx->id);
532 return -EIO;
533 }
534
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);
555}
556
557static int vidioc_vdec_dqbuf(struct file *file, void *priv,
558 struct v4l2_buffer *buf)
559{
560 struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
561
562 if (ctx->state == MTK_STATE_ABORT) {
563 mtk_v4l2_err("[%d] Call on DQBUF after unrecoverable error",
564 ctx->id);
565 return -EIO;
566 }
567
568 return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
569}
570
571static int vidioc_vdec_querycap(struct file *file, void *priv,
572 struct v4l2_capability *cap)
573{
574 strlcpy(cap->driver, MTK_VCODEC_DEC_NAME, sizeof(cap->driver));
575 strlcpy(cap->bus_info, MTK_PLATFORM_STR, sizeof(cap->bus_info));
576 strlcpy(cap->card, MTK_PLATFORM_STR, sizeof(cap->card));
577
578 return 0;
579}
580
581static int vidioc_vdec_subscribe_evt(struct v4l2_fh *fh,
582 const struct v4l2_event_subscription *sub)
583{
584 switch (sub->type) {
585 case V4L2_EVENT_EOS:
586 return v4l2_event_subscribe(fh, sub, 2, NULL);
587 case V4L2_EVENT_SOURCE_CHANGE:
588 return v4l2_src_change_event_subscribe(fh, sub);
589 default:
590 return v4l2_ctrl_subscribe_event(fh, sub);
591 }
592}
593
594static int vidioc_try_fmt(struct v4l2_format *f, struct mtk_video_fmt *fmt)
595{
596 struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
597 int i;
598
599 pix_fmt_mp->field = V4L2_FIELD_NONE;
600
601 if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
602 pix_fmt_mp->num_planes = 1;
603 pix_fmt_mp->plane_fmt[0].bytesperline = 0;
604 } else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
605 int tmp_w, tmp_h;
606
607 pix_fmt_mp->height = clamp(pix_fmt_mp->height,
608 MTK_VDEC_MIN_H,
609 MTK_VDEC_MAX_H);
610 pix_fmt_mp->width = clamp(pix_fmt_mp->width,
611 MTK_VDEC_MIN_W,
612 MTK_VDEC_MAX_W);
613
614 /*
615 * Find next closer width align 64, heign align 64, size align
616 * 64 rectangle
617 * Note: This only get default value, the real HW needed value
618 * only available when ctx in MTK_STATE_HEADER state
619 */
620 tmp_w = pix_fmt_mp->width;
621 tmp_h = pix_fmt_mp->height;
622 v4l_bound_align_image(&pix_fmt_mp->width,
623 MTK_VDEC_MIN_W,
624 MTK_VDEC_MAX_W, 6,
625 &pix_fmt_mp->height,
626 MTK_VDEC_MIN_H,
627 MTK_VDEC_MAX_H, 6, 9);
628
629 if (pix_fmt_mp->width < tmp_w &&
630 (pix_fmt_mp->width + 64) <= MTK_VDEC_MAX_W)
631 pix_fmt_mp->width += 64;
632 if (pix_fmt_mp->height < tmp_h &&
633 (pix_fmt_mp->height + 64) <= MTK_VDEC_MAX_H)
634 pix_fmt_mp->height += 64;
635
636 mtk_v4l2_debug(0,
637 "before resize width=%d, height=%d, after resize width=%d, height=%d, sizeimage=%d",
638 tmp_w, tmp_h, pix_fmt_mp->width,
639 pix_fmt_mp->height,
640 pix_fmt_mp->width * pix_fmt_mp->height);
641
642 pix_fmt_mp->num_planes = fmt->num_planes;
643 pix_fmt_mp->plane_fmt[0].sizeimage =
644 pix_fmt_mp->width * pix_fmt_mp->height;
645 pix_fmt_mp->plane_fmt[0].bytesperline = pix_fmt_mp->width;
646
647 if (pix_fmt_mp->num_planes == 2) {
648 pix_fmt_mp->plane_fmt[1].sizeimage =
649 (pix_fmt_mp->width * pix_fmt_mp->height) / 2;
650 pix_fmt_mp->plane_fmt[1].bytesperline =
651 pix_fmt_mp->width;
652 }
653 }
654
655 for (i = 0; i < pix_fmt_mp->num_planes; i++)
656 memset(&(pix_fmt_mp->plane_fmt[i].reserved[0]), 0x0,
657 sizeof(pix_fmt_mp->plane_fmt[0].reserved));
658
659 pix_fmt_mp->flags = 0;
660 memset(&pix_fmt_mp->reserved, 0x0, sizeof(pix_fmt_mp->reserved));
661 return 0;
662}
663
664static int vidioc_try_fmt_vid_cap_mplane(struct file *file, void *priv,
665 struct v4l2_format *f)
666{
667 struct mtk_video_fmt *fmt;
668
669 fmt = mtk_vdec_find_format(f);
670 if (!fmt) {
671 f->fmt.pix.pixelformat = mtk_video_formats[CAP_FMT_IDX].fourcc;
672 fmt = mtk_vdec_find_format(f);
673 }
674
675 return vidioc_try_fmt(f, fmt);
676}
677
678static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv,
679 struct v4l2_format *f)
680{
681 struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
682 struct mtk_video_fmt *fmt;
683
684 fmt = mtk_vdec_find_format(f);
685 if (!fmt) {
686 f->fmt.pix.pixelformat = mtk_video_formats[OUT_FMT_IDX].fourcc;
687 fmt = mtk_vdec_find_format(f);
688 }
689
690 if (pix_fmt_mp->plane_fmt[0].sizeimage == 0) {
691 mtk_v4l2_err("sizeimage of output format must be given");
692 return -EINVAL;
693 }
694
695 return vidioc_try_fmt(f, fmt);
696}
697
698static int vidioc_vdec_g_selection(struct file *file, void *priv,
699 struct v4l2_selection *s)
700{
701 struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
702 struct mtk_q_data *q_data;
703
704 if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
705 return -EINVAL;
706
707 q_data = &ctx->q_data[MTK_Q_DATA_DST];
708
709 switch (s->target) {
710 case V4L2_SEL_TGT_COMPOSE_DEFAULT:
711 s->r.left = 0;
712 s->r.top = 0;
713 s->r.width = ctx->picinfo.pic_w;
714 s->r.height = ctx->picinfo.pic_h;
715 break;
716 case V4L2_SEL_TGT_COMPOSE_BOUNDS:
717 s->r.left = 0;
718 s->r.top = 0;
719 s->r.width = ctx->picinfo.buf_w;
720 s->r.height = ctx->picinfo.buf_h;
721 break;
722 case V4L2_SEL_TGT_COMPOSE:
723 if (vdec_if_get_param(ctx, GET_PARAM_CROP_INFO, &(s->r))) {
724 /* set to default value if header info not ready yet*/
725 s->r.left = 0;
726 s->r.top = 0;
727 s->r.width = q_data->visible_width;
728 s->r.height = q_data->visible_height;
729 }
730 break;
731 default:
732 return -EINVAL;
733 }
734
735 if (ctx->state < MTK_STATE_HEADER) {
736 /* set to default value if header info not ready yet*/
737 s->r.left = 0;
738 s->r.top = 0;
739 s->r.width = q_data->visible_width;
740 s->r.height = q_data->visible_height;
741 return 0;
742 }
743
744 return 0;
745}
746
747static int vidioc_vdec_s_selection(struct file *file, void *priv,
748 struct v4l2_selection *s)
749{
750 struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
751
752 if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
753 return -EINVAL;
754
755 switch (s->target) {
756 case V4L2_SEL_TGT_COMPOSE:
757 s->r.left = 0;
758 s->r.top = 0;
759 s->r.width = ctx->picinfo.pic_w;
760 s->r.height = ctx->picinfo.pic_h;
761 break;
762 default:
763 return -EINVAL;
764 }
765
766 return 0;
767}
768
769static int vidioc_vdec_s_fmt(struct file *file, void *priv,
770 struct v4l2_format *f)
771{
772 struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
773 struct v4l2_pix_format_mplane *pix_mp;
774 struct mtk_q_data *q_data;
775 int ret = 0;
776 struct mtk_video_fmt *fmt;
777
778 mtk_v4l2_debug(3, "[%d]", ctx->id);
779
780 q_data = mtk_vdec_get_q_data(ctx, f->type);
781 if (!q_data)
782 return -EINVAL;
783
784 pix_mp = &f->fmt.pix_mp;
785 if ((f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) &&
786 vb2_is_busy(&ctx->m2m_ctx->out_q_ctx.q)) {
787 mtk_v4l2_err("out_q_ctx buffers already requested");
788 ret = -EBUSY;
789 }
790
791 if ((f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) &&
792 vb2_is_busy(&ctx->m2m_ctx->cap_q_ctx.q)) {
793 mtk_v4l2_err("cap_q_ctx buffers already requested");
794 ret = -EBUSY;
795 }
796
797 fmt = mtk_vdec_find_format(f);
798 if (fmt == NULL) {
799 if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
800 f->fmt.pix.pixelformat =
801 mtk_video_formats[OUT_FMT_IDX].fourcc;
802 fmt = mtk_vdec_find_format(f);
803 } else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
804 f->fmt.pix.pixelformat =
805 mtk_video_formats[CAP_FMT_IDX].fourcc;
806 fmt = mtk_vdec_find_format(f);
807 }
808 }
809
810 q_data->fmt = fmt;
811 vidioc_try_fmt(f, q_data->fmt);
812 if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
813 q_data->sizeimage[0] = pix_mp->plane_fmt[0].sizeimage;
814 q_data->coded_width = pix_mp->width;
815 q_data->coded_height = pix_mp->height;
816
817 ctx->colorspace = f->fmt.pix_mp.colorspace;
818 ctx->ycbcr_enc = f->fmt.pix_mp.ycbcr_enc;
819 ctx->quantization = f->fmt.pix_mp.quantization;
820 ctx->xfer_func = f->fmt.pix_mp.xfer_func;
821
822 if (ctx->state == MTK_STATE_FREE) {
823 ret = vdec_if_init(ctx, q_data->fmt->fourcc);
824 if (ret) {
825 mtk_v4l2_err("[%d]: vdec_if_init() fail ret=%d",
826 ctx->id, ret);
827 return -EINVAL;
828 }
829 ctx->state = MTK_STATE_INIT;
830 }
831 }
832
833 return 0;
834}
835
836static int vidioc_enum_framesizes(struct file *file, void *priv,
837 struct v4l2_frmsizeenum *fsize)
838{
839 int i = 0;
840 struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
841
842 if (fsize->index != 0)
843 return -EINVAL;
844
845 for (i = 0; i < NUM_SUPPORTED_FRAMESIZE; ++i) {
846 if (fsize->pixel_format != mtk_vdec_framesizes[i].fourcc)
847 continue;
848
849 fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
850 fsize->stepwise = mtk_vdec_framesizes[i].stepwise;
851 if (!(ctx->dev->dec_capability &
852 VCODEC_CAPABILITY_4K_DISABLED)) {
853 mtk_v4l2_debug(3, "4K is enabled");
854 fsize->stepwise.max_width =
855 VCODEC_DEC_4K_CODED_WIDTH;
856 fsize->stepwise.max_height =
857 VCODEC_DEC_4K_CODED_HEIGHT;
858 }
859 mtk_v4l2_debug(1, "%x, %d %d %d %d %d %d",
860 ctx->dev->dec_capability,
861 fsize->stepwise.min_width,
862 fsize->stepwise.max_width,
863 fsize->stepwise.step_width,
864 fsize->stepwise.min_height,
865 fsize->stepwise.max_height,
866 fsize->stepwise.step_height);
867 return 0;
868 }
869
870 return -EINVAL;
871}
872
873static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, bool output_queue)
874{
875 struct mtk_video_fmt *fmt;
876 int i, j = 0;
877
878 for (i = 0; i < NUM_FORMATS; i++) {
879 if (output_queue && (mtk_video_formats[i].type != MTK_FMT_DEC))
880 continue;
881 if (!output_queue &&
882 (mtk_video_formats[i].type != MTK_FMT_FRAME))
883 continue;
884
885 if (j == f->index)
886 break;
887 ++j;
888 }
889
890 if (i == NUM_FORMATS)
891 return -EINVAL;
892
893 fmt = &mtk_video_formats[i];
894 f->pixelformat = fmt->fourcc;
895
896 return 0;
897}
898
899static int vidioc_vdec_enum_fmt_vid_cap_mplane(struct file *file, void *pirv,
900 struct v4l2_fmtdesc *f)
901{
902 return vidioc_enum_fmt(f, false);
903}
904
905static int vidioc_vdec_enum_fmt_vid_out_mplane(struct file *file, void *priv,
906 struct v4l2_fmtdesc *f)
907{
908 return vidioc_enum_fmt(f, true);
909}
910
911static int vidioc_vdec_g_fmt(struct file *file, void *priv,
912 struct v4l2_format *f)
913{
914 struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
915 struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
916 struct vb2_queue *vq;
917 struct mtk_q_data *q_data;
918
919 vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
920 if (!vq) {
921 mtk_v4l2_err("no vb2 queue for type=%d", f->type);
922 return -EINVAL;
923 }
924
925 q_data = mtk_vdec_get_q_data(ctx, f->type);
926
927 pix_mp->field = V4L2_FIELD_NONE;
928 pix_mp->colorspace = ctx->colorspace;
929 pix_mp->ycbcr_enc = ctx->ycbcr_enc;
930 pix_mp->quantization = ctx->quantization;
931 pix_mp->xfer_func = ctx->xfer_func;
932
933 if ((f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) &&
934 (ctx->state >= MTK_STATE_HEADER)) {
935 /* Until STREAMOFF is called on the CAPTURE queue
936 * (acknowledging the event), the driver operates as if
937 * the resolution hasn't changed yet.
938 * So we just return picinfo yet, and update picinfo in
939 * stop_streaming hook function
940 */
941 q_data->sizeimage[0] = ctx->picinfo.y_bs_sz +
942 ctx->picinfo.y_len_sz;
943 q_data->sizeimage[1] = ctx->picinfo.c_bs_sz +
944 ctx->picinfo.c_len_sz;
945 q_data->bytesperline[0] = ctx->last_decoded_picinfo.buf_w;
946 q_data->bytesperline[1] = ctx->last_decoded_picinfo.buf_w;
947 q_data->coded_width = ctx->picinfo.buf_w;
948 q_data->coded_height = ctx->picinfo.buf_h;
949
950 /*
951 * Width and height are set to the dimensions
952 * of the movie, the buffer is bigger and
953 * further processing stages should crop to this
954 * rectangle.
955 */
956 pix_mp->width = q_data->coded_width;
957 pix_mp->height = q_data->coded_height;
958
959 /*
960 * Set pixelformat to the format in which mt vcodec
961 * outputs the decoded frame
962 */
963 pix_mp->num_planes = q_data->fmt->num_planes;
964 pix_mp->pixelformat = q_data->fmt->fourcc;
965 pix_mp->plane_fmt[0].bytesperline = q_data->bytesperline[0];
966 pix_mp->plane_fmt[0].sizeimage = q_data->sizeimage[0];
967 pix_mp->plane_fmt[1].bytesperline = q_data->bytesperline[1];
968 pix_mp->plane_fmt[1].sizeimage = q_data->sizeimage[1];
969
970 } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
971 /*
972 * This is run on OUTPUT
973 * The buffer contains compressed image
974 * so width and height have no meaning.
975 * Assign value here to pass v4l2-compliance test
976 */
977 pix_mp->width = q_data->visible_width;
978 pix_mp->height = q_data->visible_height;
979 pix_mp->plane_fmt[0].bytesperline = q_data->bytesperline[0];
980 pix_mp->plane_fmt[0].sizeimage = q_data->sizeimage[0];
981 pix_mp->pixelformat = q_data->fmt->fourcc;
982 pix_mp->num_planes = q_data->fmt->num_planes;
983 } else {
984 pix_mp->width = q_data->coded_width;
985 pix_mp->height = q_data->coded_height;
986 pix_mp->num_planes = q_data->fmt->num_planes;
987 pix_mp->pixelformat = q_data->fmt->fourcc;
988 pix_mp->plane_fmt[0].bytesperline = q_data->bytesperline[0];
989 pix_mp->plane_fmt[0].sizeimage = q_data->sizeimage[0];
990 pix_mp->plane_fmt[1].bytesperline = q_data->bytesperline[1];
991 pix_mp->plane_fmt[1].sizeimage = q_data->sizeimage[1];
992
993 mtk_v4l2_debug(1, "[%d] type=%d state=%d Format information could not be read, not ready yet!",
994 ctx->id, f->type, ctx->state);
995 }
996
997 return 0;
998}
999
1000static int vb2ops_vdec_queue_setup(struct vb2_queue *vq,
1001 unsigned int *nbuffers,
1002 unsigned int *nplanes,
1003 unsigned int sizes[],
1004 struct device *alloc_devs[])
1005{
1006 struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(vq);
1007 struct mtk_q_data *q_data;
1008 unsigned int i;
1009
1010 q_data = mtk_vdec_get_q_data(ctx, vq->type);
1011
1012 if (q_data == NULL) {
1013 mtk_v4l2_err("vq->type=%d err\n", vq->type);
1014 return -EINVAL;
1015 }
1016
1017 if (*nplanes) {
1018 for (i = 0; i < *nplanes; i++) {
1019 if (sizes[i] < q_data->sizeimage[i])
1020 return -EINVAL;
1021 }
1022 } else {
1023 if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
1024 *nplanes = 2;
1025 else
1026 *nplanes = 1;
1027
1028 for (i = 0; i < *nplanes; i++)
1029 sizes[i] = q_data->sizeimage[i];
1030 }
1031
1032 mtk_v4l2_debug(1,
1033 "[%d]\t type = %d, get %d plane(s), %d buffer(s) of size 0x%x 0x%x ",
1034 ctx->id, vq->type, *nplanes, *nbuffers,
1035 sizes[0], sizes[1]);
1036
1037 return 0;
1038}
1039
1040static int vb2ops_vdec_buf_prepare(struct vb2_buffer *vb)
1041{
1042 struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
1043 struct mtk_q_data *q_data;
1044 int i;
1045
1046 mtk_v4l2_debug(3, "[%d] (%d) id=%d",
1047 ctx->id, vb->vb2_queue->type, vb->index);
1048
1049 q_data = mtk_vdec_get_q_data(ctx, vb->vb2_queue->type);
1050
1051 for (i = 0; i < q_data->fmt->num_planes; i++) {
1052 if (vb2_plane_size(vb, i) < q_data->sizeimage[i]) {
1053 mtk_v4l2_err("data will not fit into plane %d (%lu < %d)",
1054 i, vb2_plane_size(vb, i),
1055 q_data->sizeimage[i]);
1056 }
1057 }
1058
1059 return 0;
1060}
1061
1062static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb)
1063{
1064 struct vb2_buffer *src_buf;
1065 struct mtk_vcodec_mem src_mem;
1066 bool res_chg = false;
1067 int ret = 0;
1068 unsigned int dpbsize = 1;
1069 struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
1070 struct vb2_v4l2_buffer *vb2_v4l2 = container_of(vb,
1071 struct vb2_v4l2_buffer, vb2_buf);
1072 struct mtk_video_dec_buf *buf = container_of(vb2_v4l2,
1073 struct mtk_video_dec_buf, vb);
1074
1075 mtk_v4l2_debug(3, "[%d] (%d) id=%d, vb=%p",
1076 ctx->id, vb->vb2_queue->type,
1077 vb->index, vb);
1078 /*
1079 * check if this buffer is ready to be used after decode
1080 */
1081 if (vb->vb2_queue->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
1082 mutex_lock(&ctx->lock);
1083 if (buf->used == false) {
1084 v4l2_m2m_buf_queue(ctx->m2m_ctx,
1085 to_vb2_v4l2_buffer(vb));
1086 buf->queued_in_vb2 = true;
1087 buf->queued_in_v4l2 = true;
1088 buf->ready_to_display = false;
1089 } else {
1090 buf->queued_in_vb2 = false;
1091 buf->queued_in_v4l2 = true;
1092 buf->ready_to_display = false;
1093 }
1094 mutex_unlock(&ctx->lock);
1095 return;
1096 }
1097
1098 v4l2_m2m_buf_queue(ctx->m2m_ctx, vb2_v4l2);
1099
1100 if (ctx->state != MTK_STATE_INIT) {
1101 mtk_v4l2_debug(3, "[%d] already init driver %d",
1102 ctx->id, ctx->state);
1103 return;
1104 }
1105
1106 src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
1107 if (!src_buf) {
1108 mtk_v4l2_err("No src buffer");
1109 return;
1110 }
1111
1112 src_mem.va = vb2_plane_vaddr(src_buf, 0);
1113 src_mem.dma_addr = vb2_dma_contig_plane_dma_addr(src_buf, 0);
1114 src_mem.size = (size_t)src_buf->planes[0].bytesused;
1115 mtk_v4l2_debug(2,
1116 "[%d] buf id=%d va=%p dma=%pad size=%zx",
1117 ctx->id, src_buf->index,
1118 src_mem.va, &src_mem.dma_addr,
1119 src_mem.size);
1120
1121 ret = vdec_if_decode(ctx, &src_mem, NULL, &res_chg);
1122 if (ret || !res_chg) {
1123 /*
1124 * fb == NULL menas to parse SPS/PPS header or
1125 * resolution info in src_mem. Decode can fail
1126 * if there is no SPS header or picture info
1127 * in bs
1128 */
1129 int log_level = ret ? 0 : 1;
1130
1131 src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
1132 v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
1133 VB2_BUF_STATE_DONE);
1134 mtk_v4l2_debug(log_level,
1135 "[%d] vdec_if_decode() src_buf=%d, size=%zu, fail=%d, res_chg=%d",
1136 ctx->id, src_buf->index,
1137 src_mem.size, ret, res_chg);
1138 return;
1139 }
1140
1141 if (vdec_if_get_param(ctx, GET_PARAM_PIC_INFO, &ctx->picinfo)) {
1142 mtk_v4l2_err("[%d]Error!! Cannot get param : GET_PARAM_PICTURE_INFO ERR",
1143 ctx->id);
1144 return;
1145 }
1146
1147 ctx->last_decoded_picinfo = ctx->picinfo;
1148 ctx->q_data[MTK_Q_DATA_DST].sizeimage[0] =
1149 ctx->picinfo.y_bs_sz +
1150 ctx->picinfo.y_len_sz;
1151 ctx->q_data[MTK_Q_DATA_DST].bytesperline[0] =
1152 ctx->picinfo.buf_w;
1153 ctx->q_data[MTK_Q_DATA_DST].sizeimage[1] =
1154 ctx->picinfo.c_bs_sz +
1155 ctx->picinfo.c_len_sz;
1156 ctx->q_data[MTK_Q_DATA_DST].bytesperline[1] = ctx->picinfo.buf_w;
1157 mtk_v4l2_debug(2, "[%d] vdec_if_init() OK wxh=%dx%d pic wxh=%dx%d sz[0]=0x%x sz[1]=0x%x",
1158 ctx->id,
1159 ctx->picinfo.buf_w, ctx->picinfo.buf_h,
1160 ctx->picinfo.pic_w, ctx->picinfo.pic_h,
1161 ctx->q_data[MTK_Q_DATA_DST].sizeimage[0],
1162 ctx->q_data[MTK_Q_DATA_DST].sizeimage[1]);
1163
1164 ret = vdec_if_get_param(ctx, GET_PARAM_DPB_SIZE, &dpbsize);
1165 if (dpbsize == 0)
1166 mtk_v4l2_err("[%d] GET_PARAM_DPB_SIZE fail=%d", ctx->id, ret);
1167
1168 ctx->dpb_size = dpbsize;
1169 ctx->state = MTK_STATE_HEADER;
1170 mtk_v4l2_debug(1, "[%d] dpbsize=%d", ctx->id, ctx->dpb_size);
1171}
1172
1173static void vb2ops_vdec_buf_finish(struct vb2_buffer *vb)
1174{
1175 struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
1176 struct vb2_v4l2_buffer *vb2_v4l2;
1177 struct mtk_video_dec_buf *buf;
1178
1179 if (vb->vb2_queue->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
1180 return;
1181
1182 vb2_v4l2 = container_of(vb, struct vb2_v4l2_buffer, vb2_buf);
1183 buf = container_of(vb2_v4l2, struct mtk_video_dec_buf, vb);
1184 mutex_lock(&ctx->lock);
1185 buf->queued_in_v4l2 = false;
1186 buf->queued_in_vb2 = false;
1187 mutex_unlock(&ctx->lock);
1188}
1189
1190static int vb2ops_vdec_buf_init(struct vb2_buffer *vb)
1191{
1192 struct vb2_v4l2_buffer *vb2_v4l2 = container_of(vb,
1193 struct vb2_v4l2_buffer, vb2_buf);
1194 struct mtk_video_dec_buf *buf = container_of(vb2_v4l2,
1195 struct mtk_video_dec_buf, vb);
1196
1197 if (vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
1198 buf->used = false;
1199 buf->ready_to_display = false;
1200 buf->queued_in_v4l2 = false;
1201 } else {
1202 buf->lastframe = false;
1203 }
1204
1205 return 0;
1206}
1207
1208static int vb2ops_vdec_start_streaming(struct vb2_queue *q, unsigned int count)
1209{
1210 struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(q);
1211
1212 if (ctx->state == MTK_STATE_FLUSH)
1213 ctx->state = MTK_STATE_HEADER;
1214
1215 return 0;
1216}
1217
1218static void vb2ops_vdec_stop_streaming(struct vb2_queue *q)
1219{
1220 struct vb2_buffer *src_buf = NULL, *dst_buf = NULL;
1221 struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(q);
1222
1223 mtk_v4l2_debug(3, "[%d] (%d) state=(%x) ctx->decoded_frame_cnt=%d",
1224 ctx->id, q->type, ctx->state, ctx->decoded_frame_cnt);
1225
1226 if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
1227 while ((src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx)))
1228 v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
1229 VB2_BUF_STATE_ERROR);
1230 return;
1231 }
1232
1233 if (ctx->state >= MTK_STATE_HEADER) {
1234
1235 /* Until STREAMOFF is called on the CAPTURE queue
1236 * (acknowledging the event), the driver operates
1237 * as if the resolution hasn't changed yet, i.e.
1238 * VIDIOC_G_FMT< etc. return previous resolution.
1239 * So we update picinfo here
1240 */
1241 ctx->picinfo = ctx->last_decoded_picinfo;
1242
1243 mtk_v4l2_debug(2,
1244 "[%d]-> new(%d,%d), old(%d,%d), real(%d,%d)",
1245 ctx->id, ctx->last_decoded_picinfo.pic_w,
1246 ctx->last_decoded_picinfo.pic_h,
1247 ctx->picinfo.pic_w, ctx->picinfo.pic_h,
1248 ctx->last_decoded_picinfo.buf_w,
1249 ctx->last_decoded_picinfo.buf_h);
1250
1251 mtk_vdec_flush_decoder(ctx);
1252 }
1253 ctx->state = MTK_STATE_FLUSH;
1254
1255 while ((dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx))) {
1256 vb2_set_plane_payload(dst_buf, 0, 0);
1257 vb2_set_plane_payload(dst_buf, 1, 0);
1258 v4l2_m2m_buf_done(to_vb2_v4l2_buffer(dst_buf),
1259 VB2_BUF_STATE_ERROR);
1260 }
1261
1262}
1263
1264static void m2mops_vdec_device_run(void *priv)
1265{
1266 struct mtk_vcodec_ctx *ctx = priv;
1267 struct mtk_vcodec_dev *dev = ctx->dev;
1268
1269 queue_work(dev->decode_workqueue, &ctx->decode_work);
1270}
1271
1272static int m2mops_vdec_job_ready(void *m2m_priv)
1273{
1274 struct mtk_vcodec_ctx *ctx = m2m_priv;
1275
1276 mtk_v4l2_debug(3, "[%d]", ctx->id);
1277
1278 if (ctx->state == MTK_STATE_ABORT)
1279 return 0;
1280
1281 if ((ctx->last_decoded_picinfo.pic_w != ctx->picinfo.pic_w) ||
1282 (ctx->last_decoded_picinfo.pic_h != ctx->picinfo.pic_h))
1283 return 0;
1284
1285 if (ctx->state != MTK_STATE_HEADER)
1286 return 0;
1287
1288 return 1;
1289}
1290
1291static void m2mops_vdec_job_abort(void *priv)
1292{
1293 struct mtk_vcodec_ctx *ctx = priv;
1294
1295 ctx->state = MTK_STATE_ABORT;
1296}
1297
1298static int mtk_vdec_g_v_ctrl(struct v4l2_ctrl *ctrl)
1299{
1300 struct mtk_vcodec_ctx *ctx = ctrl_to_ctx(ctrl);
1301 int ret = 0;
1302
1303 switch (ctrl->id) {
1304 case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE:
1305 if (ctx->state >= MTK_STATE_HEADER) {
1306 ctrl->val = ctx->dpb_size;
1307 } else {
1308 mtk_v4l2_debug(0, "Seqinfo not ready");
1309 ctrl->val = 0;
1310 }
1311 break;
1312 default:
1313 ret = -EINVAL;
1314 }
1315 return ret;
1316}
1317
1318static const struct v4l2_ctrl_ops mtk_vcodec_dec_ctrl_ops = {
1319 .g_volatile_ctrl = mtk_vdec_g_v_ctrl,
1320};
1321
1322int mtk_vcodec_dec_ctrls_setup(struct mtk_vcodec_ctx *ctx)
1323{
1324 struct v4l2_ctrl *ctrl;
1325
1326 v4l2_ctrl_handler_init(&ctx->ctrl_hdl, 1);
1327
1328 ctrl = v4l2_ctrl_new_std(&ctx->ctrl_hdl,
1329 &mtk_vcodec_dec_ctrl_ops,
1330 V4L2_CID_MIN_BUFFERS_FOR_CAPTURE,
1331 0, 32, 1, 1);
1332 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
1333
1334 if (ctx->ctrl_hdl.error) {
1335 mtk_v4l2_err("Adding control failed %d",
1336 ctx->ctrl_hdl.error);
1337 return ctx->ctrl_hdl.error;
1338 }
1339
1340 v4l2_ctrl_handler_setup(&ctx->ctrl_hdl);
1341 return 0;
1342}
1343
1344static void m2mops_vdec_lock(void *m2m_priv)
1345{
1346 struct mtk_vcodec_ctx *ctx = m2m_priv;
1347
1348 mtk_v4l2_debug(3, "[%d]", ctx->id);
1349 mutex_lock(&ctx->dev->dev_mutex);
1350}
1351
1352static void m2mops_vdec_unlock(void *m2m_priv)
1353{
1354 struct mtk_vcodec_ctx *ctx = m2m_priv;
1355
1356 mtk_v4l2_debug(3, "[%d]", ctx->id);
1357 mutex_unlock(&ctx->dev->dev_mutex);
1358}
1359
1360const struct v4l2_m2m_ops mtk_vdec_m2m_ops = {
1361 .device_run = m2mops_vdec_device_run,
1362 .job_ready = m2mops_vdec_job_ready,
1363 .job_abort = m2mops_vdec_job_abort,
1364 .lock = m2mops_vdec_lock,
1365 .unlock = m2mops_vdec_unlock,
1366};
1367
1368static const struct vb2_ops mtk_vdec_vb2_ops = {
1369 .queue_setup = vb2ops_vdec_queue_setup,
1370 .buf_prepare = vb2ops_vdec_buf_prepare,
1371 .buf_queue = vb2ops_vdec_buf_queue,
1372 .wait_prepare = vb2_ops_wait_prepare,
1373 .wait_finish = vb2_ops_wait_finish,
1374 .buf_init = vb2ops_vdec_buf_init,
1375 .buf_finish = vb2ops_vdec_buf_finish,
1376 .start_streaming = vb2ops_vdec_start_streaming,
1377 .stop_streaming = vb2ops_vdec_stop_streaming,
1378};
1379
1380const struct v4l2_ioctl_ops mtk_vdec_ioctl_ops = {
1381 .vidioc_streamon = v4l2_m2m_ioctl_streamon,
1382 .vidioc_streamoff = v4l2_m2m_ioctl_streamoff,
1383 .vidioc_reqbufs = v4l2_m2m_ioctl_reqbufs,
1384 .vidioc_querybuf = v4l2_m2m_ioctl_querybuf,
1385 .vidioc_expbuf = v4l2_m2m_ioctl_expbuf,
1386
1387 .vidioc_qbuf = vidioc_vdec_qbuf,
1388 .vidioc_dqbuf = vidioc_vdec_dqbuf,
1389
1390 .vidioc_try_fmt_vid_cap_mplane = vidioc_try_fmt_vid_cap_mplane,
1391 .vidioc_try_fmt_vid_out_mplane = vidioc_try_fmt_vid_out_mplane,
1392
1393 .vidioc_s_fmt_vid_cap_mplane = vidioc_vdec_s_fmt,
1394 .vidioc_s_fmt_vid_out_mplane = vidioc_vdec_s_fmt,
1395 .vidioc_g_fmt_vid_cap_mplane = vidioc_vdec_g_fmt,
1396 .vidioc_g_fmt_vid_out_mplane = vidioc_vdec_g_fmt,
1397
1398 .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
1399
1400 .vidioc_enum_fmt_vid_cap_mplane = vidioc_vdec_enum_fmt_vid_cap_mplane,
1401 .vidioc_enum_fmt_vid_out_mplane = vidioc_vdec_enum_fmt_vid_out_mplane,
1402 .vidioc_enum_framesizes = vidioc_enum_framesizes,
1403
1404 .vidioc_querycap = vidioc_vdec_querycap,
1405 .vidioc_subscribe_event = vidioc_vdec_subscribe_evt,
1406 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
1407 .vidioc_g_selection = vidioc_vdec_g_selection,
1408 .vidioc_s_selection = vidioc_vdec_s_selection,
1409};
1410
1411int mtk_vcodec_dec_queue_init(void *priv, struct vb2_queue *src_vq,
1412 struct vb2_queue *dst_vq)
1413{
1414 struct mtk_vcodec_ctx *ctx = priv;
1415 int ret = 0;
1416
1417 mtk_v4l2_debug(3, "[%d]", ctx->id);
1418
1419 src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
1420 src_vq->io_modes = VB2_DMABUF | VB2_MMAP;
1421 src_vq->drv_priv = ctx;
1422 src_vq->buf_struct_size = sizeof(struct mtk_video_dec_buf);
1423 src_vq->ops = &mtk_vdec_vb2_ops;
1424 src_vq->mem_ops = &vb2_dma_contig_memops;
1425 src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
1426 src_vq->lock = &ctx->dev->dev_mutex;
1427 src_vq->dev = &ctx->dev->plat_dev->dev;
1428
1429 ret = vb2_queue_init(src_vq);
1430 if (ret) {
1431 mtk_v4l2_err("Failed to initialize videobuf2 queue(output)");
1432 return ret;
1433 }
1434 dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
1435 dst_vq->io_modes = VB2_DMABUF | VB2_MMAP;
1436 dst_vq->drv_priv = ctx;
1437 dst_vq->buf_struct_size = sizeof(struct mtk_video_dec_buf);
1438 dst_vq->ops = &mtk_vdec_vb2_ops;
1439 dst_vq->mem_ops = &vb2_dma_contig_memops;
1440 dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
1441 dst_vq->lock = &ctx->dev->dev_mutex;
1442 dst_vq->dev = &ctx->dev->plat_dev->dev;
1443
1444 ret = vb2_queue_init(dst_vq);
1445 if (ret) {
1446 vb2_queue_release(src_vq);
1447 mtk_v4l2_err("Failed to initialize videobuf2 queue(capture)");
1448 }
1449
1450 return ret;
1451}
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
new file mode 100644
index 000000000000..362f5a85762e
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
@@ -0,0 +1,88 @@
1/*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: PC Chen <pc.chen@mediatek.com>
4 * Tiffany Lin <tiffany.lin@mediatek.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 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef _MTK_VCODEC_DEC_H_
17#define _MTK_VCODEC_DEC_H_
18
19#include <media/videobuf2-core.h>
20#include <media/videobuf2-v4l2.h>
21
22#define VCODEC_CAPABILITY_4K_DISABLED 0x10
23#define VCODEC_DEC_4K_CODED_WIDTH 4096U
24#define VCODEC_DEC_4K_CODED_HEIGHT 2304U
25#define MTK_VDEC_MAX_W 2048U
26#define MTK_VDEC_MAX_H 1088U
27
28#define MTK_VDEC_IRQ_STATUS_DEC_SUCCESS 0x10000
29
30/**
31 * struct vdec_fb - decoder frame buffer
32 * @base_y : Y plane memory info
33 * @base_c : C plane memory info
34 * @status : frame buffer status (vdec_fb_status)
35 */
36struct vdec_fb {
37 struct mtk_vcodec_mem base_y;
38 struct mtk_vcodec_mem base_c;
39 unsigned int status;
40};
41
42/**
43 * struct mtk_video_dec_buf - Private data related to each VB2 buffer.
44 * @b: VB2 buffer
45 * @list: link list
46 * @used: Capture buffer contain decoded frame data and keep in
47 * codec data structure
48 * @ready_to_display: Capture buffer not display yet
49 * @queued_in_vb2: Capture buffer is queue in vb2
50 * @queued_in_v4l2: Capture buffer is in v4l2 driver, but not in vb2
51 * queue yet
52 * @lastframe: Intput buffer is last buffer - EOS
53 * @frame_buffer: Decode status, and buffer information of Capture buffer
54 *
55 * Note : These status information help us track and debug buffer state
56 */
57struct mtk_video_dec_buf {
58 struct vb2_v4l2_buffer vb;
59 struct list_head list;
60
61 bool used;
62 bool ready_to_display;
63 bool queued_in_vb2;
64 bool queued_in_v4l2;
65 bool lastframe;
66 struct vdec_fb frame_buffer;
67};
68
69extern const struct v4l2_ioctl_ops mtk_vdec_ioctl_ops;
70extern const struct v4l2_m2m_ops mtk_vdec_m2m_ops;
71
72
73/*
74 * mtk_vdec_lock/mtk_vdec_unlock are for ctx instance to
75 * get/release lock before/after access decoder hw.
76 * mtk_vdec_lock get decoder hw lock and set curr_ctx
77 * to ctx instance that get lock
78 */
79void mtk_vdec_unlock(struct mtk_vcodec_ctx *ctx);
80void mtk_vdec_lock(struct mtk_vcodec_ctx *ctx);
81int mtk_vcodec_dec_queue_init(void *priv, struct vb2_queue *src_vq,
82 struct vb2_queue *dst_vq);
83void mtk_vcodec_dec_set_default_params(struct mtk_vcodec_ctx *ctx);
84void mtk_vcodec_dec_release(struct mtk_vcodec_ctx *ctx);
85int mtk_vcodec_dec_ctrls_setup(struct mtk_vcodec_ctx *ctx);
86
87
88#endif /* _MTK_VCODEC_DEC_H_ */
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
new file mode 100644
index 000000000000..d48287c727f4
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -0,0 +1,394 @@
1/*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: PC Chen <pc.chen@mediatek.com>
4 * Tiffany Lin <tiffany.lin@mediatek.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 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/slab.h>
17#include <linux/interrupt.h>
18#include <linux/irq.h>
19#include <linux/module.h>
20#include <linux/of_device.h>
21#include <linux/of.h>
22#include <media/v4l2-event.h>
23#include <media/v4l2-mem2mem.h>
24#include <media/videobuf2-dma-contig.h>
25
26#include "mtk_vcodec_drv.h"
27#include "mtk_vcodec_dec.h"
28#include "mtk_vcodec_dec_pm.h"
29#include "mtk_vcodec_intr.h"
30#include "mtk_vcodec_util.h"
31#include "mtk_vpu.h"
32
33#define VDEC_HW_ACTIVE 0x10
34#define VDEC_IRQ_CFG 0x11
35#define VDEC_IRQ_CLR 0x10
36#define VDEC_IRQ_CFG_REG 0xa4
37
38module_param(mtk_v4l2_dbg_level, int, 0644);
39module_param(mtk_vcodec_dbg, bool, 0644);
40
41/* Wake up context wait_queue */
42static void wake_up_ctx(struct mtk_vcodec_ctx *ctx)
43{
44 ctx->int_cond = 1;
45 wake_up_interruptible(&ctx->queue);
46}
47
48static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void *priv)
49{
50 struct mtk_vcodec_dev *dev = priv;
51 struct mtk_vcodec_ctx *ctx;
52 u32 cg_status = 0;
53 unsigned int dec_done_status = 0;
54 void __iomem *vdec_misc_addr = dev->reg_base[VDEC_MISC] +
55 VDEC_IRQ_CFG_REG;
56
57 ctx = mtk_vcodec_get_curr_ctx(dev);
58
59 /* check if HW active or not */
60 cg_status = readl(dev->reg_base[0]);
61 if ((cg_status & VDEC_HW_ACTIVE) != 0) {
62 mtk_v4l2_err("DEC ISR, VDEC active is not 0x0 (0x%08x)",
63 cg_status);
64 return IRQ_HANDLED;
65 }
66
67 dec_done_status = readl(vdec_misc_addr);
68 ctx->irq_status = dec_done_status;
69 if ((dec_done_status & MTK_VDEC_IRQ_STATUS_DEC_SUCCESS) !=
70 MTK_VDEC_IRQ_STATUS_DEC_SUCCESS)
71 return IRQ_HANDLED;
72
73 /* clear interrupt */
74 writel((readl(vdec_misc_addr) | VDEC_IRQ_CFG),
75 dev->reg_base[VDEC_MISC] + VDEC_IRQ_CFG_REG);
76 writel((readl(vdec_misc_addr) & ~VDEC_IRQ_CLR),
77 dev->reg_base[VDEC_MISC] + VDEC_IRQ_CFG_REG);
78
79 wake_up_ctx(ctx);
80
81 mtk_v4l2_debug(3,
82 "mtk_vcodec_dec_irq_handler :wake up ctx %d, dec_done_status=%x",
83 ctx->id, dec_done_status);
84
85 return IRQ_HANDLED;
86}
87
88static void mtk_vcodec_dec_reset_handler(void *priv)
89{
90 struct mtk_vcodec_dev *dev = priv;
91 struct mtk_vcodec_ctx *ctx;
92
93 mtk_v4l2_err("Watchdog timeout!!");
94
95 mutex_lock(&dev->dev_mutex);
96 list_for_each_entry(ctx, &dev->ctx_list, list) {
97 ctx->state = MTK_STATE_ABORT;
98 mtk_v4l2_debug(0, "[%d] Change to state MTK_STATE_ERROR",
99 ctx->id);
100 }
101 mutex_unlock(&dev->dev_mutex);
102}
103
104static int fops_vcodec_open(struct file *file)
105{
106 struct mtk_vcodec_dev *dev = video_drvdata(file);
107 struct mtk_vcodec_ctx *ctx = NULL;
108 int ret = 0;
109
110 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
111 if (!ctx)
112 return -ENOMEM;
113
114 mutex_lock(&dev->dev_mutex);
115 ctx->id = dev->id_counter++;
116 v4l2_fh_init(&ctx->fh, video_devdata(file));
117 file->private_data = &ctx->fh;
118 v4l2_fh_add(&ctx->fh);
119 INIT_LIST_HEAD(&ctx->list);
120 ctx->dev = dev;
121 init_waitqueue_head(&ctx->queue);
122 mutex_init(&ctx->lock);
123
124 ctx->type = MTK_INST_DECODER;
125 ret = mtk_vcodec_dec_ctrls_setup(ctx);
126 if (ret) {
127 mtk_v4l2_err("Failed to setup mt vcodec controls");
128 goto err_ctrls_setup;
129 }
130 ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev_dec, ctx,
131 &mtk_vcodec_dec_queue_init);
132 if (IS_ERR((__force void *)ctx->m2m_ctx)) {
133 ret = PTR_ERR((__force void *)ctx->m2m_ctx);
134 mtk_v4l2_err("Failed to v4l2_m2m_ctx_init() (%d)",
135 ret);
136 goto err_m2m_ctx_init;
137 }
138 mtk_vcodec_dec_set_default_params(ctx);
139
140 if (v4l2_fh_is_singular(&ctx->fh)) {
141 mtk_vcodec_dec_pw_on(&dev->pm);
142 /*
143 * vpu_load_firmware checks if it was loaded already and
144 * does nothing in that case
145 */
146 ret = vpu_load_firmware(dev->vpu_plat_dev);
147 if (ret < 0) {
148 /*
149 * Return 0 if downloading firmware successfully,
150 * otherwise it is failed
151 */
152 mtk_v4l2_err("vpu_load_firmware failed!");
153 goto err_load_fw;
154 }
155
156 dev->dec_capability =
157 vpu_get_vdec_hw_capa(dev->vpu_plat_dev);
158 mtk_v4l2_debug(0, "decoder capability %x", dev->dec_capability);
159 }
160
161 list_add(&ctx->list, &dev->ctx_list);
162
163 mutex_unlock(&dev->dev_mutex);
164 mtk_v4l2_debug(0, "%s decoder [%d]", dev_name(&dev->plat_dev->dev),
165 ctx->id);
166 return ret;
167
168 /* Deinit when failure occurred */
169err_load_fw:
170 v4l2_m2m_ctx_release(ctx->m2m_ctx);
171err_m2m_ctx_init:
172 v4l2_ctrl_handler_free(&ctx->ctrl_hdl);
173err_ctrls_setup:
174 v4l2_fh_del(&ctx->fh);
175 v4l2_fh_exit(&ctx->fh);
176 kfree(ctx);
177 mutex_unlock(&dev->dev_mutex);
178
179 return ret;
180}
181
182static int fops_vcodec_release(struct file *file)
183{
184 struct mtk_vcodec_dev *dev = video_drvdata(file);
185 struct mtk_vcodec_ctx *ctx = fh_to_ctx(file->private_data);
186
187 mtk_v4l2_debug(0, "[%d] decoder", ctx->id);
188 mutex_lock(&dev->dev_mutex);
189
190 /*
191 * Call v4l2_m2m_ctx_release before mtk_vcodec_dec_release. First, it
192 * makes sure the worker thread is not running after vdec_if_deinit.
193 * Second, the decoder will be flushed and all the buffers will be
194 * returned in stop_streaming.
195 */
196 v4l2_m2m_ctx_release(ctx->m2m_ctx);
197 mtk_vcodec_dec_release(ctx);
198
199 if (v4l2_fh_is_singular(&ctx->fh))
200 mtk_vcodec_dec_pw_off(&dev->pm);
201 v4l2_fh_del(&ctx->fh);
202 v4l2_fh_exit(&ctx->fh);
203 v4l2_ctrl_handler_free(&ctx->ctrl_hdl);
204
205 list_del_init(&ctx->list);
206 kfree(ctx);
207 mutex_unlock(&dev->dev_mutex);
208 return 0;
209}
210
211static const struct v4l2_file_operations mtk_vcodec_fops = {
212 .owner = THIS_MODULE,
213 .open = fops_vcodec_open,
214 .release = fops_vcodec_release,
215 .poll = v4l2_m2m_fop_poll,
216 .unlocked_ioctl = video_ioctl2,
217 .mmap = v4l2_m2m_fop_mmap,
218};
219
220static int mtk_vcodec_probe(struct platform_device *pdev)
221{
222 struct mtk_vcodec_dev *dev;
223 struct video_device *vfd_dec;
224 struct resource *res;
225 int i, ret;
226
227 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
228 if (!dev)
229 return -ENOMEM;
230
231 INIT_LIST_HEAD(&dev->ctx_list);
232 dev->plat_dev = pdev;
233
234 dev->vpu_plat_dev = vpu_get_plat_device(dev->plat_dev);
235 if (dev->vpu_plat_dev == NULL) {
236 mtk_v4l2_err("[VPU] vpu device in not ready");
237 return -EPROBE_DEFER;
238 }
239
240 vpu_wdt_reg_handler(dev->vpu_plat_dev, mtk_vcodec_dec_reset_handler,
241 dev, VPU_RST_DEC);
242
243 ret = mtk_vcodec_init_dec_pm(dev);
244 if (ret < 0) {
245 dev_err(&pdev->dev, "Failed to get mt vcodec clock source");
246 return ret;
247 }
248
249 for (i = 0; i < NUM_MAX_VDEC_REG_BASE; i++) {
250 res = platform_get_resource(pdev, IORESOURCE_MEM, i);
251 if (res == NULL) {
252 dev_err(&pdev->dev, "get memory resource failed.");
253 ret = -ENXIO;
254 goto err_res;
255 }
256 dev->reg_base[i] = devm_ioremap_resource(&pdev->dev, res);
257 if (IS_ERR((__force void *)dev->reg_base[i])) {
258 ret = PTR_ERR((__force void *)dev->reg_base[i]);
259 goto err_res;
260 }
261 mtk_v4l2_debug(2, "reg[%d] base=%p", i, dev->reg_base[i]);
262 }
263
264 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
265 if (res == NULL) {
266 dev_err(&pdev->dev, "failed to get irq resource");
267 ret = -ENOENT;
268 goto err_res;
269 }
270
271 dev->dec_irq = platform_get_irq(pdev, 0);
272 ret = devm_request_irq(&pdev->dev, dev->dec_irq,
273 mtk_vcodec_dec_irq_handler, 0, pdev->name, dev);
274 if (ret) {
275 dev_err(&pdev->dev, "Failed to install dev->dec_irq %d (%d)",
276 dev->dec_irq,
277 ret);
278 goto err_res;
279 }
280
281 disable_irq(dev->dec_irq);
282 mutex_init(&dev->dec_mutex);
283 mutex_init(&dev->dev_mutex);
284 spin_lock_init(&dev->irqlock);
285
286 snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), "%s",
287 "[/MTK_V4L2_VDEC]");
288
289 ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev);
290 if (ret) {
291 mtk_v4l2_err("v4l2_device_register err=%d", ret);
292 goto err_res;
293 }
294
295 init_waitqueue_head(&dev->queue);
296
297 vfd_dec = video_device_alloc();
298 if (!vfd_dec) {
299 mtk_v4l2_err("Failed to allocate video device");
300 ret = -ENOMEM;
301 goto err_dec_alloc;
302 }
303 vfd_dec->fops = &mtk_vcodec_fops;
304 vfd_dec->ioctl_ops = &mtk_vdec_ioctl_ops;
305 vfd_dec->release = video_device_release;
306 vfd_dec->lock = &dev->dev_mutex;
307 vfd_dec->v4l2_dev = &dev->v4l2_dev;
308 vfd_dec->vfl_dir = VFL_DIR_M2M;
309 vfd_dec->device_caps = V4L2_CAP_VIDEO_M2M_MPLANE |
310 V4L2_CAP_STREAMING;
311
312 snprintf(vfd_dec->name, sizeof(vfd_dec->name), "%s",
313 MTK_VCODEC_DEC_NAME);
314 video_set_drvdata(vfd_dec, dev);
315 dev->vfd_dec = vfd_dec;
316 platform_set_drvdata(pdev, dev);
317
318 dev->m2m_dev_dec = v4l2_m2m_init(&mtk_vdec_m2m_ops);
319 if (IS_ERR((__force void *)dev->m2m_dev_dec)) {
320 mtk_v4l2_err("Failed to init mem2mem dec device");
321 ret = PTR_ERR((__force void *)dev->m2m_dev_dec);
322 goto err_dec_mem_init;
323 }
324
325 dev->decode_workqueue =
326 alloc_ordered_workqueue(MTK_VCODEC_DEC_NAME,
327 WQ_MEM_RECLAIM | WQ_FREEZABLE);
328 if (!dev->decode_workqueue) {
329 mtk_v4l2_err("Failed to create decode workqueue");
330 ret = -EINVAL;
331 goto err_event_workq;
332 }
333
334 ret = video_register_device(vfd_dec, VFL_TYPE_GRABBER, 0);
335 if (ret) {
336 mtk_v4l2_err("Failed to register video device");
337 goto err_dec_reg;
338 }
339
340 mtk_v4l2_debug(0, "decoder registered as /dev/video%d",
341 vfd_dec->num);
342
343 return 0;
344
345err_dec_reg:
346 destroy_workqueue(dev->decode_workqueue);
347err_event_workq:
348 v4l2_m2m_release(dev->m2m_dev_dec);
349err_dec_mem_init:
350 video_unregister_device(vfd_dec);
351err_dec_alloc:
352 v4l2_device_unregister(&dev->v4l2_dev);
353err_res:
354 mtk_vcodec_release_dec_pm(dev);
355 return ret;
356}
357
358static const struct of_device_id mtk_vcodec_match[] = {
359 {.compatible = "mediatek,mt8173-vcodec-dec",},
360 {},
361};
362
363MODULE_DEVICE_TABLE(of, mtk_vcodec_match);
364
365static int mtk_vcodec_dec_remove(struct platform_device *pdev)
366{
367 struct mtk_vcodec_dev *dev = platform_get_drvdata(pdev);
368
369 flush_workqueue(dev->decode_workqueue);
370 destroy_workqueue(dev->decode_workqueue);
371 if (dev->m2m_dev_dec)
372 v4l2_m2m_release(dev->m2m_dev_dec);
373
374 if (dev->vfd_dec)
375 video_unregister_device(dev->vfd_dec);
376
377 v4l2_device_unregister(&dev->v4l2_dev);
378 mtk_vcodec_release_dec_pm(dev);
379 return 0;
380}
381
382static struct platform_driver mtk_vcodec_dec_driver = {
383 .probe = mtk_vcodec_probe,
384 .remove = mtk_vcodec_dec_remove,
385 .driver = {
386 .name = MTK_VCODEC_DEC_NAME,
387 .of_match_table = mtk_vcodec_match,
388 },
389};
390
391module_platform_driver(mtk_vcodec_dec_driver);
392
393MODULE_LICENSE("GPL v2");
394MODULE_DESCRIPTION("Mediatek video codec V4L2 decoder driver");
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
new file mode 100644
index 000000000000..79ca03ac449c
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
@@ -0,0 +1,202 @@
1/*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: Tiffany Lin <tiffany.lin@mediatek.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 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#include <linux/clk.h>
16#include <linux/of_address.h>
17#include <linux/of_platform.h>
18#include <linux/pm_runtime.h>
19#include <soc/mediatek/smi.h>
20
21#include "mtk_vcodec_dec_pm.h"
22#include "mtk_vcodec_util.h"
23#include "mtk_vpu.h"
24
25int mtk_vcodec_init_dec_pm(struct mtk_vcodec_dev *mtkdev)
26{
27 struct device_node *node;
28 struct platform_device *pdev;
29 struct mtk_vcodec_pm *pm;
30 int ret = 0;
31
32 pdev = mtkdev->plat_dev;
33 pm = &mtkdev->pm;
34 pm->mtkdev = mtkdev;
35 node = of_parse_phandle(pdev->dev.of_node, "mediatek,larb", 0);
36 if (!node) {
37 mtk_v4l2_err("of_parse_phandle mediatek,larb fail!");
38 return -1;
39 }
40
41 pdev = of_find_device_by_node(node);
42 if (WARN_ON(!pdev)) {
43 of_node_put(node);
44 return -1;
45 }
46 pm->larbvdec = &pdev->dev;
47 pdev = mtkdev->plat_dev;
48 pm->dev = &pdev->dev;
49
50 pm->vcodecpll = devm_clk_get(&pdev->dev, "vcodecpll");
51 if (IS_ERR(pm->vcodecpll)) {
52 mtk_v4l2_err("devm_clk_get vcodecpll fail");
53 ret = PTR_ERR(pm->vcodecpll);
54 }
55
56 pm->univpll_d2 = devm_clk_get(&pdev->dev, "univpll_d2");
57 if (IS_ERR(pm->univpll_d2)) {
58 mtk_v4l2_err("devm_clk_get univpll_d2 fail");
59 ret = PTR_ERR(pm->univpll_d2);
60 }
61
62 pm->clk_cci400_sel = devm_clk_get(&pdev->dev, "clk_cci400_sel");
63 if (IS_ERR(pm->clk_cci400_sel)) {
64 mtk_v4l2_err("devm_clk_get clk_cci400_sel fail");
65 ret = PTR_ERR(pm->clk_cci400_sel);
66 }
67
68 pm->vdec_sel = devm_clk_get(&pdev->dev, "vdec_sel");
69 if (IS_ERR(pm->vdec_sel)) {
70 mtk_v4l2_err("devm_clk_get vdec_sel fail");
71 ret = PTR_ERR(pm->vdec_sel);
72 }
73
74 pm->vdecpll = devm_clk_get(&pdev->dev, "vdecpll");
75 if (IS_ERR(pm->vdecpll)) {
76 mtk_v4l2_err("devm_clk_get vdecpll fail");
77 ret = PTR_ERR(pm->vdecpll);
78 }
79
80 pm->vencpll = devm_clk_get(&pdev->dev, "vencpll");
81 if (IS_ERR(pm->vencpll)) {
82 mtk_v4l2_err("devm_clk_get vencpll fail");
83 ret = PTR_ERR(pm->vencpll);
84 }
85
86 pm->venc_lt_sel = devm_clk_get(&pdev->dev, "venc_lt_sel");
87 if (IS_ERR(pm->venc_lt_sel)) {
88 mtk_v4l2_err("devm_clk_get venc_lt_sel fail");
89 ret = PTR_ERR(pm->venc_lt_sel);
90 }
91
92 pm->vdec_bus_clk_src = devm_clk_get(&pdev->dev, "vdec_bus_clk_src");
93 if (IS_ERR(pm->vdec_bus_clk_src)) {
94 mtk_v4l2_err("devm_clk_get vdec_bus_clk_src");
95 ret = PTR_ERR(pm->vdec_bus_clk_src);
96 }
97
98 pm_runtime_enable(&pdev->dev);
99
100 return ret;
101}
102
103void mtk_vcodec_release_dec_pm(struct mtk_vcodec_dev *dev)
104{
105 pm_runtime_disable(dev->pm.dev);
106}
107
108void mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm)
109{
110 int ret;
111
112 ret = pm_runtime_get_sync(pm->dev);
113 if (ret)
114 mtk_v4l2_err("pm_runtime_get_sync fail %d", ret);
115}
116
117void mtk_vcodec_dec_pw_off(struct mtk_vcodec_pm *pm)
118{
119 int ret;
120
121 ret = pm_runtime_put_sync(pm->dev);
122 if (ret)
123 mtk_v4l2_err("pm_runtime_put_sync fail %d", ret);
124}
125
126void mtk_vcodec_dec_clock_on(struct mtk_vcodec_pm *pm)
127{
128 int ret;
129
130 ret = clk_set_rate(pm->vcodecpll, 1482 * 1000000);
131 if (ret)
132 mtk_v4l2_err("clk_set_rate vcodecpll fail %d", ret);
133
134 ret = clk_set_rate(pm->vencpll, 800 * 1000000);
135 if (ret)
136 mtk_v4l2_err("clk_set_rate vencpll fail %d", ret);
137
138 ret = clk_prepare_enable(pm->vcodecpll);
139 if (ret)
140 mtk_v4l2_err("clk_prepare_enable vcodecpll fail %d", ret);
141
142 ret = clk_prepare_enable(pm->vencpll);
143 if (ret)
144 mtk_v4l2_err("clk_prepare_enable vencpll fail %d", ret);
145
146 ret = clk_prepare_enable(pm->vdec_bus_clk_src);
147 if (ret)
148 mtk_v4l2_err("clk_prepare_enable vdec_bus_clk_src fail %d",
149 ret);
150
151 ret = clk_prepare_enable(pm->venc_lt_sel);
152 if (ret)
153 mtk_v4l2_err("clk_prepare_enable venc_lt_sel fail %d", ret);
154
155 ret = clk_set_parent(pm->venc_lt_sel, pm->vdec_bus_clk_src);
156 if (ret)
157 mtk_v4l2_err("clk_set_parent venc_lt_sel vdec_bus_clk_src fail %d",
158 ret);
159
160 ret = clk_prepare_enable(pm->univpll_d2);
161 if (ret)
162 mtk_v4l2_err("clk_prepare_enable univpll_d2 fail %d", ret);
163
164 ret = clk_prepare_enable(pm->clk_cci400_sel);
165 if (ret)
166 mtk_v4l2_err("clk_prepare_enable clk_cci400_sel fail %d", ret);
167
168 ret = clk_set_parent(pm->clk_cci400_sel, pm->univpll_d2);
169 if (ret)
170 mtk_v4l2_err("clk_set_parent clk_cci400_sel univpll_d2 fail %d",
171 ret);
172
173 ret = clk_prepare_enable(pm->vdecpll);
174 if (ret)
175 mtk_v4l2_err("clk_prepare_enable vdecpll fail %d", ret);
176
177 ret = clk_prepare_enable(pm->vdec_sel);
178 if (ret)
179 mtk_v4l2_err("clk_prepare_enable vdec_sel fail %d", ret);
180
181 ret = clk_set_parent(pm->vdec_sel, pm->vdecpll);
182 if (ret)
183 mtk_v4l2_err("clk_set_parent vdec_sel vdecpll fail %d", ret);
184
185 ret = mtk_smi_larb_get(pm->larbvdec);
186 if (ret)
187 mtk_v4l2_err("mtk_smi_larb_get larbvdec fail %d", ret);
188
189}
190
191void mtk_vcodec_dec_clock_off(struct mtk_vcodec_pm *pm)
192{
193 mtk_smi_larb_put(pm->larbvdec);
194 clk_disable_unprepare(pm->vdec_sel);
195 clk_disable_unprepare(pm->vdecpll);
196 clk_disable_unprepare(pm->univpll_d2);
197 clk_disable_unprepare(pm->clk_cci400_sel);
198 clk_disable_unprepare(pm->venc_lt_sel);
199 clk_disable_unprepare(pm->vdec_bus_clk_src);
200 clk_disable_unprepare(pm->vencpll);
201 clk_disable_unprepare(pm->vcodecpll);
202}
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
new file mode 100644
index 000000000000..86a7825353e3
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
@@ -0,0 +1,28 @@
1/*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: Tiffany Lin <tiffany.lin@mediatek.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 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#ifndef _MTK_VCODEC_DEC_PM_H_
16#define _MTK_VCODEC_DEC_PM_H_
17
18#include "mtk_vcodec_drv.h"
19
20int mtk_vcodec_init_dec_pm(struct mtk_vcodec_dev *dev);
21void mtk_vcodec_release_dec_pm(struct mtk_vcodec_dev *dev);
22
23void mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm);
24void mtk_vcodec_dec_pw_off(struct mtk_vcodec_pm *pm);
25void mtk_vcodec_dec_clock_on(struct mtk_vcodec_pm *pm);
26void mtk_vcodec_dec_clock_off(struct mtk_vcodec_pm *pm);
27
28#endif /* _MTK_VCODEC_DEC_PM_H_ */
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index c8eaa41c00e6..d7eb8ef855d2 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -22,13 +22,13 @@
22#include <media/v4l2-device.h> 22#include <media/v4l2-device.h>
23#include <media/v4l2-ioctl.h> 23#include <media/v4l2-ioctl.h>
24#include <media/videobuf2-core.h> 24#include <media/videobuf2-core.h>
25 25#include "mtk_vcodec_util.h"
26 26
27#define MTK_VCODEC_DRV_NAME "mtk_vcodec_drv" 27#define MTK_VCODEC_DRV_NAME "mtk_vcodec_drv"
28#define MTK_VCODEC_DEC_NAME "mtk-vcodec-dec"
28#define MTK_VCODEC_ENC_NAME "mtk-vcodec-enc" 29#define MTK_VCODEC_ENC_NAME "mtk-vcodec-enc"
29#define MTK_PLATFORM_STR "platform:mt8173" 30#define MTK_PLATFORM_STR "platform:mt8173"
30 31
31
32#define MTK_VCODEC_MAX_PLANES 3 32#define MTK_VCODEC_MAX_PLANES 3
33#define MTK_V4L2_BENCHMARK 0 33#define MTK_V4L2_BENCHMARK 0
34#define WAIT_INTR_TIMEOUT_MS 1000 34#define WAIT_INTR_TIMEOUT_MS 1000
@@ -179,6 +179,9 @@ struct mtk_enc_params {
179 * struct mtk_vcodec_pm - Power management data structure 179 * struct mtk_vcodec_pm - Power management data structure
180 */ 180 */
181struct mtk_vcodec_pm { 181struct mtk_vcodec_pm {
182 struct clk *vdec_bus_clk_src;
183 struct clk *vencpll;
184
182 struct clk *vcodecpll; 185 struct clk *vcodecpll;
183 struct clk *univpll_d2; 186 struct clk *univpll_d2;
184 struct clk *clk_cci400_sel; 187 struct clk *clk_cci400_sel;
@@ -196,6 +199,32 @@ struct mtk_vcodec_pm {
196}; 199};
197 200
198/** 201/**
202 * struct vdec_pic_info - picture size information
203 * @pic_w: picture width
204 * @pic_h: picture height
205 * @buf_w: picture buffer width (64 aligned up from pic_w)
206 * @buf_h: picture buffer heiht (64 aligned up from pic_h)
207 * @y_bs_sz: Y bitstream size
208 * @c_bs_sz: CbCr bitstream size
209 * @y_len_sz: additional size required to store decompress information for y
210 * plane
211 * @c_len_sz: additional size required to store decompress information for cbcr
212 * plane
213 * E.g. suppose picture size is 176x144,
214 * buffer size will be aligned to 176x160.
215 */
216struct vdec_pic_info {
217 unsigned int pic_w;
218 unsigned int pic_h;
219 unsigned int buf_w;
220 unsigned int buf_h;
221 unsigned int y_bs_sz;
222 unsigned int c_bs_sz;
223 unsigned int y_len_sz;
224 unsigned int c_len_sz;
225};
226
227/**
199 * struct mtk_vcodec_ctx - Context (instance) private data. 228 * struct mtk_vcodec_ctx - Context (instance) private data.
200 * 229 *
201 * @type: type of the instance - decoder or encoder 230 * @type: type of the instance - decoder or encoder
@@ -209,9 +238,12 @@ struct mtk_vcodec_pm {
209 * @state: state of the context 238 * @state: state of the context
210 * @param_change: indicate encode parameter type 239 * @param_change: indicate encode parameter type
211 * @enc_params: encoding parameters 240 * @enc_params: encoding parameters
241 * @dec_if: hooked decoder driver interface
212 * @enc_if: hoooked encoder driver interface 242 * @enc_if: hoooked encoder driver interface
213 * @drv_handle: driver handle for specific decode/encode instance 243 * @drv_handle: driver handle for specific decode/encode instance
214 * 244 *
245 * @picinfo: store picture info after header parsing
246 * @dpb_size: store dpb count after header parsing
215 * @int_cond: variable used by the waitqueue 247 * @int_cond: variable used by the waitqueue
216 * @int_type: type of the last interrupt 248 * @int_type: type of the last interrupt
217 * @queue: waitqueue that can be used to wait for this context to 249 * @queue: waitqueue that can be used to wait for this context to
@@ -219,12 +251,16 @@ struct mtk_vcodec_pm {
219 * @irq_status: irq status 251 * @irq_status: irq status
220 * 252 *
221 * @ctrl_hdl: handler for v4l2 framework 253 * @ctrl_hdl: handler for v4l2 framework
254 * @decode_work: worker for the decoding
222 * @encode_work: worker for the encoding 255 * @encode_work: worker for the encoding
256 * @last_decoded_picinfo: pic information get from latest decode
223 * 257 *
224 * @colorspace: enum v4l2_colorspace; supplemental to pixelformat 258 * @colorspace: enum v4l2_colorspace; supplemental to pixelformat
225 * @ycbcr_enc: enum v4l2_ycbcr_encoding, Y'CbCr encoding 259 * @ycbcr_enc: enum v4l2_ycbcr_encoding, Y'CbCr encoding
226 * @quantization: enum v4l2_quantization, colorspace quantization 260 * @quantization: enum v4l2_quantization, colorspace quantization
227 * @xfer_func: enum v4l2_xfer_func, colorspace transfer function 261 * @xfer_func: enum v4l2_xfer_func, colorspace transfer function
262 * @lock: protect variables accessed by V4L2 threads and worker thread such as
263 * mtk_video_dec_buf.
228 */ 264 */
229struct mtk_vcodec_ctx { 265struct mtk_vcodec_ctx {
230 enum mtk_instance_type type; 266 enum mtk_instance_type type;
@@ -239,28 +275,40 @@ struct mtk_vcodec_ctx {
239 enum mtk_encode_param param_change; 275 enum mtk_encode_param param_change;
240 struct mtk_enc_params enc_params; 276 struct mtk_enc_params enc_params;
241 277
278 const struct vdec_common_if *dec_if;
242 const struct venc_common_if *enc_if; 279 const struct venc_common_if *enc_if;
243 unsigned long drv_handle; 280 unsigned long drv_handle;
244 281
282 struct vdec_pic_info picinfo;
283 int dpb_size;
284
245 int int_cond; 285 int int_cond;
246 int int_type; 286 int int_type;
247 wait_queue_head_t queue; 287 wait_queue_head_t queue;
248 unsigned int irq_status; 288 unsigned int irq_status;
249 289
250 struct v4l2_ctrl_handler ctrl_hdl; 290 struct v4l2_ctrl_handler ctrl_hdl;
291 struct work_struct decode_work;
251 struct work_struct encode_work; 292 struct work_struct encode_work;
293 struct vdec_pic_info last_decoded_picinfo;
252 294
253 enum v4l2_colorspace colorspace; 295 enum v4l2_colorspace colorspace;
254 enum v4l2_ycbcr_encoding ycbcr_enc; 296 enum v4l2_ycbcr_encoding ycbcr_enc;
255 enum v4l2_quantization quantization; 297 enum v4l2_quantization quantization;
256 enum v4l2_xfer_func xfer_func; 298 enum v4l2_xfer_func xfer_func;
299
300 int decoded_frame_cnt;
301 struct mutex lock;
302
257}; 303};
258 304
259/** 305/**
260 * struct mtk_vcodec_dev - driver data 306 * struct mtk_vcodec_dev - driver data
261 * @v4l2_dev: V4L2 device to register video devices for. 307 * @v4l2_dev: V4L2 device to register video devices for.
308 * @vfd_dec: Video device for decoder
262 * @vfd_enc: Video device for encoder. 309 * @vfd_enc: Video device for encoder.
263 * 310 *
311 * @m2m_dev_dec: m2m device for decoder
264 * @m2m_dev_enc: m2m device for encoder. 312 * @m2m_dev_enc: m2m device for encoder.
265 * @plat_dev: platform device 313 * @plat_dev: platform device
266 * @vpu_plat_dev: mtk vpu platform device 314 * @vpu_plat_dev: mtk vpu platform device
@@ -271,7 +319,6 @@ struct mtk_vcodec_ctx {
271 * @reg_base: Mapped address of MTK Vcodec registers. 319 * @reg_base: Mapped address of MTK Vcodec registers.
272 * 320 *
273 * @id_counter: used to identify current opened instance 321 * @id_counter: used to identify current opened instance
274 * @num_instances: counter of active MTK Vcodec instances
275 * 322 *
276 * @encode_workqueue: encode work queue 323 * @encode_workqueue: encode work queue
277 * 324 *
@@ -280,9 +327,11 @@ struct mtk_vcodec_ctx {
280 * @dev_mutex: video_device lock 327 * @dev_mutex: video_device lock
281 * @queue: waitqueue for waiting for completion of device commands 328 * @queue: waitqueue for waiting for completion of device commands
282 * 329 *
330 * @dec_irq: decoder irq resource
283 * @enc_irq: h264 encoder irq resource 331 * @enc_irq: h264 encoder irq resource
284 * @enc_lt_irq: vp8 encoder irq resource 332 * @enc_lt_irq: vp8 encoder irq resource
285 * 333 *
334 * @dec_mutex: decoder hardware lock
286 * @enc_mutex: encoder hardware lock. 335 * @enc_mutex: encoder hardware lock.
287 * 336 *
288 * @pm: power management control 337 * @pm: power management control
@@ -291,8 +340,10 @@ struct mtk_vcodec_ctx {
291 */ 340 */
292struct mtk_vcodec_dev { 341struct mtk_vcodec_dev {
293 struct v4l2_device v4l2_dev; 342 struct v4l2_device v4l2_dev;
343 struct video_device *vfd_dec;
294 struct video_device *vfd_enc; 344 struct video_device *vfd_enc;
295 345
346 struct v4l2_m2m_dev *m2m_dev_dec;
296 struct v4l2_m2m_dev *m2m_dev_enc; 347 struct v4l2_m2m_dev *m2m_dev_enc;
297 struct platform_device *plat_dev; 348 struct platform_device *plat_dev;
298 struct platform_device *vpu_plat_dev; 349 struct platform_device *vpu_plat_dev;
@@ -302,18 +353,19 @@ struct mtk_vcodec_dev {
302 void __iomem *reg_base[NUM_MAX_VCODEC_REG_BASE]; 353 void __iomem *reg_base[NUM_MAX_VCODEC_REG_BASE];
303 354
304 unsigned long id_counter; 355 unsigned long id_counter;
305 int num_instances;
306 356
357 struct workqueue_struct *decode_workqueue;
307 struct workqueue_struct *encode_workqueue; 358 struct workqueue_struct *encode_workqueue;
308
309 int int_cond; 359 int int_cond;
310 int int_type; 360 int int_type;
311 struct mutex dev_mutex; 361 struct mutex dev_mutex;
312 wait_queue_head_t queue; 362 wait_queue_head_t queue;
313 363
364 int dec_irq;
314 int enc_irq; 365 int enc_irq;
315 int enc_lt_irq; 366 int enc_lt_irq;
316 367
368 struct mutex dec_mutex;
317 struct mutex enc_mutex; 369 struct mutex enc_mutex;
318 370
319 struct mtk_vcodec_pm pm; 371 struct mtk_vcodec_pm pm;
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
index 5cd2151431bf..aa81f3ce9463 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
@@ -188,7 +188,6 @@ static int fops_vcodec_open(struct file *file)
188 mtk_v4l2_debug(2, "Create instance [%d]@%p m2m_ctx=%p ", 188 mtk_v4l2_debug(2, "Create instance [%d]@%p m2m_ctx=%p ",
189 ctx->id, ctx, ctx->m2m_ctx); 189 ctx->id, ctx, ctx->m2m_ctx);
190 190
191 dev->num_instances++;
192 list_add(&ctx->list, &dev->ctx_list); 191 list_add(&ctx->list, &dev->ctx_list);
193 192
194 mutex_unlock(&dev->dev_mutex); 193 mutex_unlock(&dev->dev_mutex);
@@ -218,18 +217,13 @@ static int fops_vcodec_release(struct file *file)
218 mtk_v4l2_debug(1, "[%d] encoder", ctx->id); 217 mtk_v4l2_debug(1, "[%d] encoder", ctx->id);
219 mutex_lock(&dev->dev_mutex); 218 mutex_lock(&dev->dev_mutex);
220 219
221 /*
222 * Call v4l2_m2m_ctx_release to make sure the worker thread is not
223 * running after venc_if_deinit.
224 */
225 v4l2_m2m_ctx_release(ctx->m2m_ctx);
226 mtk_vcodec_enc_release(ctx); 220 mtk_vcodec_enc_release(ctx);
227 v4l2_fh_del(&ctx->fh); 221 v4l2_fh_del(&ctx->fh);
228 v4l2_fh_exit(&ctx->fh); 222 v4l2_fh_exit(&ctx->fh);
229 v4l2_ctrl_handler_free(&ctx->ctrl_hdl); 223 v4l2_ctrl_handler_free(&ctx->ctrl_hdl);
224 v4l2_m2m_ctx_release(ctx->m2m_ctx);
230 225
231 list_del_init(&ctx->list); 226 list_del_init(&ctx->list);
232 dev->num_instances--;
233 kfree(ctx); 227 kfree(ctx);
234 mutex_unlock(&dev->dev_mutex); 228 mutex_unlock(&dev->dev_mutex);
235 return 0; 229 return 0;
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.c
index 52e7e5c9afa0..113b2097f061 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.c
@@ -30,8 +30,7 @@ int mtk_vcodec_wait_for_done_ctx(struct mtk_vcodec_ctx *ctx, int command,
30 timeout_jiff = msecs_to_jiffies(timeout_ms); 30 timeout_jiff = msecs_to_jiffies(timeout_ms);
31 31
32 ret = wait_event_interruptible_timeout(*waitqueue, 32 ret = wait_event_interruptible_timeout(*waitqueue,
33 (ctx->int_cond && 33 ctx->int_cond,
34 (ctx->int_type == command)),
35 timeout_jiff); 34 timeout_jiff);
36 35
37 if (!ret) { 36 if (!ret) {
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c
index 5e3651372a3c..46768c056193 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c
@@ -81,14 +81,37 @@ void mtk_vcodec_mem_free(struct mtk_vcodec_ctx *data,
81 return; 81 return;
82 } 82 }
83 83
84 dma_free_coherent(dev, size, mem->va, mem->dma_addr);
85 mem->va = NULL;
86 mem->dma_addr = 0;
87 mem->size = 0;
88
89 mtk_v4l2_debug(3, "[%d] - va = %p", ctx->id, mem->va); 84 mtk_v4l2_debug(3, "[%d] - va = %p", ctx->id, mem->va);
90 mtk_v4l2_debug(3, "[%d] - dma = 0x%lx", ctx->id, 85 mtk_v4l2_debug(3, "[%d] - dma = 0x%lx", ctx->id,
91 (unsigned long)mem->dma_addr); 86 (unsigned long)mem->dma_addr);
92 mtk_v4l2_debug(3, "[%d] size = 0x%lx", ctx->id, size); 87 mtk_v4l2_debug(3, "[%d] size = 0x%lx", ctx->id, size);
88
89 dma_free_coherent(dev, size, mem->va, mem->dma_addr);
90 mem->va = NULL;
91 mem->dma_addr = 0;
92 mem->size = 0;
93} 93}
94EXPORT_SYMBOL(mtk_vcodec_mem_free); 94EXPORT_SYMBOL(mtk_vcodec_mem_free);
95
96void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dev *dev,
97 struct mtk_vcodec_ctx *ctx)
98{
99 unsigned long flags;
100
101 spin_lock_irqsave(&dev->irqlock, flags);
102 dev->curr_ctx = ctx;
103 spin_unlock_irqrestore(&dev->irqlock, flags);
104}
105EXPORT_SYMBOL(mtk_vcodec_set_curr_ctx);
106
107struct mtk_vcodec_ctx *mtk_vcodec_get_curr_ctx(struct mtk_vcodec_dev *dev)
108{
109 unsigned long flags;
110 struct mtk_vcodec_ctx *ctx;
111
112 spin_lock_irqsave(&dev->irqlock, flags);
113 ctx = dev->curr_ctx;
114 spin_unlock_irqrestore(&dev->irqlock, flags);
115 return ctx;
116}
117EXPORT_SYMBOL(mtk_vcodec_get_curr_ctx);
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
index d6345fc04840..7d55975d3185 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
@@ -26,6 +26,7 @@ struct mtk_vcodec_mem {
26}; 26};
27 27
28struct mtk_vcodec_ctx; 28struct mtk_vcodec_ctx;
29struct mtk_vcodec_dev;
29 30
30extern int mtk_v4l2_dbg_level; 31extern int mtk_v4l2_dbg_level;
31extern bool mtk_vcodec_dbg; 32extern bool mtk_vcodec_dbg;
@@ -84,4 +85,8 @@ int mtk_vcodec_mem_alloc(struct mtk_vcodec_ctx *data,
84 struct mtk_vcodec_mem *mem); 85 struct mtk_vcodec_mem *mem);
85void mtk_vcodec_mem_free(struct mtk_vcodec_ctx *data, 86void mtk_vcodec_mem_free(struct mtk_vcodec_ctx *data,
86 struct mtk_vcodec_mem *mem); 87 struct mtk_vcodec_mem *mem);
88void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dev *dev,
89 struct mtk_vcodec_ctx *ctx);
90struct mtk_vcodec_ctx *mtk_vcodec_get_curr_ctx(struct mtk_vcodec_dev *dev);
91
87#endif /* _MTK_VCODEC_UTIL_H_ */ 92#endif /* _MTK_VCODEC_UTIL_H_ */
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
new file mode 100644
index 000000000000..57a842ff3097
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
@@ -0,0 +1,507 @@
1/*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: PC Chen <pc.chen@mediatek.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 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#include <linux/module.h>
16#include <linux/slab.h>
17
18#include "../vdec_drv_if.h"
19#include "../mtk_vcodec_util.h"
20#include "../mtk_vcodec_dec.h"
21#include "../mtk_vcodec_intr.h"
22#include "../vdec_vpu_if.h"
23#include "../vdec_drv_base.h"
24
25#define NAL_NON_IDR_SLICE 0x01
26#define NAL_IDR_SLICE 0x05
27#define NAL_H264_PPS 0x08
28#define NAL_TYPE(value) ((value) & 0x1F)
29
30#define BUF_PREDICTION_SZ (32 * 1024)
31
32#define MB_UNIT_LEN 16
33
34/* motion vector size (bytes) for every macro block */
35#define HW_MB_STORE_SZ 64
36
37#define H264_MAX_FB_NUM 17
38#define HDR_PARSING_BUF_SZ 1024
39
40/**
41 * struct h264_fb - h264 decode frame buffer information
42 * @vdec_fb_va : virtual address of struct vdec_fb
43 * @y_fb_dma : dma address of Y frame buffer (luma)
44 * @c_fb_dma : dma address of C frame buffer (chroma)
45 * @poc : picture order count of frame buffer
46 * @reserved : for 8 bytes alignment
47 */
48struct h264_fb {
49 uint64_t vdec_fb_va;
50 uint64_t y_fb_dma;
51 uint64_t c_fb_dma;
52 int32_t poc;
53 uint32_t reserved;
54};
55
56/**
57 * struct h264_ring_fb_list - ring frame buffer list
58 * @fb_list : frame buffer arrary
59 * @read_idx : read index
60 * @write_idx : write index
61 * @count : buffer count in list
62 */
63struct h264_ring_fb_list {
64 struct h264_fb fb_list[H264_MAX_FB_NUM];
65 unsigned int read_idx;
66 unsigned int write_idx;
67 unsigned int count;
68 unsigned int reserved;
69};
70
71/**
72 * struct vdec_h264_dec_info - decode information
73 * @dpb_sz : decoding picture buffer size
74 * @resolution_changed : resoltion change happen
75 * @realloc_mv_buf : flag to notify driver to re-allocate mv buffer
76 * @reserved : for 8 bytes alignment
77 * @bs_dma : Input bit-stream buffer dma address
78 * @y_fb_dma : Y frame buffer dma address
79 * @c_fb_dma : C frame buffer dma address
80 * @vdec_fb_va : VDEC frame buffer struct virtual address
81 */
82struct vdec_h264_dec_info {
83 uint32_t dpb_sz;
84 uint32_t resolution_changed;
85 uint32_t realloc_mv_buf;
86 uint32_t reserved;
87 uint64_t bs_dma;
88 uint64_t y_fb_dma;
89 uint64_t c_fb_dma;
90 uint64_t vdec_fb_va;
91};
92
93/**
94 * struct vdec_h264_vsi - shared memory for decode information exchange
95 * between VPU and Host.
96 * The memory is allocated by VPU then mapping to Host
97 * in vpu_dec_init() and freed in vpu_dec_deinit()
98 * by VPU.
99 * AP-W/R : AP is writer/reader on this item
100 * VPU-W/R: VPU is write/reader on this item
101 * @hdr_buf : Header parsing buffer (AP-W, VPU-R)
102 * @pred_buf_dma : HW working predication buffer dma address (AP-W, VPU-R)
103 * @mv_buf_dma : HW working motion vector buffer dma address (AP-W, VPU-R)
104 * @list_free : free frame buffer ring list (AP-W/R, VPU-W)
105 * @list_disp : display frame buffer ring list (AP-R, VPU-W)
106 * @dec : decode information (AP-R, VPU-W)
107 * @pic : picture information (AP-R, VPU-W)
108 * @crop : crop information (AP-R, VPU-W)
109 */
110struct vdec_h264_vsi {
111 unsigned char hdr_buf[HDR_PARSING_BUF_SZ];
112 uint64_t pred_buf_dma;
113 uint64_t mv_buf_dma[H264_MAX_FB_NUM];
114 struct h264_ring_fb_list list_free;
115 struct h264_ring_fb_list list_disp;
116 struct vdec_h264_dec_info dec;
117 struct vdec_pic_info pic;
118 struct v4l2_rect crop;
119};
120
121/**
122 * struct vdec_h264_inst - h264 decoder instance
123 * @num_nalu : how many nalus be decoded
124 * @ctx : point to mtk_vcodec_ctx
125 * @pred_buf : HW working predication buffer
126 * @mv_buf : HW working motion vector buffer
127 * @vpu : VPU instance
128 * @vsi : VPU shared information
129 */
130struct vdec_h264_inst {
131 unsigned int num_nalu;
132 struct mtk_vcodec_ctx *ctx;
133 struct mtk_vcodec_mem pred_buf;
134 struct mtk_vcodec_mem mv_buf[H264_MAX_FB_NUM];
135 struct vdec_vpu_inst vpu;
136 struct vdec_h264_vsi *vsi;
137};
138
139static unsigned int get_mv_buf_size(unsigned int width, unsigned int height)
140{
141 return HW_MB_STORE_SZ * (width/MB_UNIT_LEN) * (height/MB_UNIT_LEN);
142}
143
144static int allocate_predication_buf(struct vdec_h264_inst *inst)
145{
146 int err = 0;
147
148 inst->pred_buf.size = BUF_PREDICTION_SZ;
149 err = mtk_vcodec_mem_alloc(inst->ctx, &inst->pred_buf);
150 if (err) {
151 mtk_vcodec_err(inst, "failed to allocate ppl buf");
152 return err;
153 }
154
155 inst->vsi->pred_buf_dma = inst->pred_buf.dma_addr;
156 return 0;
157}
158
159static void free_predication_buf(struct vdec_h264_inst *inst)
160{
161 struct mtk_vcodec_mem *mem = NULL;
162
163 mtk_vcodec_debug_enter(inst);
164
165 inst->vsi->pred_buf_dma = 0;
166 mem = &inst->pred_buf;
167 if (mem->va)
168 mtk_vcodec_mem_free(inst->ctx, mem);
169}
170
171static int alloc_mv_buf(struct vdec_h264_inst *inst, struct vdec_pic_info *pic)
172{
173 int i;
174 int err;
175 struct mtk_vcodec_mem *mem = NULL;
176 unsigned int buf_sz = get_mv_buf_size(pic->buf_w, pic->buf_h);
177
178 for (i = 0; i < H264_MAX_FB_NUM; i++) {
179 mem = &inst->mv_buf[i];
180 if (mem->va)
181 mtk_vcodec_mem_free(inst->ctx, mem);
182 mem->size = buf_sz;
183 err = mtk_vcodec_mem_alloc(inst->ctx, mem);
184 if (err) {
185 mtk_vcodec_err(inst, "failed to allocate mv buf");
186 return err;
187 }
188 inst->vsi->mv_buf_dma[i] = mem->dma_addr;
189 }
190
191 return 0;
192}
193
194static void free_mv_buf(struct vdec_h264_inst *inst)
195{
196 int i;
197 struct mtk_vcodec_mem *mem = NULL;
198
199 for (i = 0; i < H264_MAX_FB_NUM; i++) {
200 inst->vsi->mv_buf_dma[i] = 0;
201 mem = &inst->mv_buf[i];
202 if (mem->va)
203 mtk_vcodec_mem_free(inst->ctx, mem);
204 }
205}
206
207static int check_list_validity(struct vdec_h264_inst *inst, bool disp_list)
208{
209 struct h264_ring_fb_list *list;
210
211 list = disp_list ? &inst->vsi->list_disp : &inst->vsi->list_free;
212
213 if (list->count > H264_MAX_FB_NUM ||
214 list->read_idx >= H264_MAX_FB_NUM ||
215 list->write_idx >= H264_MAX_FB_NUM) {
216 mtk_vcodec_err(inst, "%s list err: cnt=%d r_idx=%d w_idx=%d",
217 disp_list ? "disp" : "free", list->count,
218 list->read_idx, list->write_idx);
219 return -EINVAL;
220 }
221
222 return 0;
223}
224
225static void put_fb_to_free(struct vdec_h264_inst *inst, struct vdec_fb *fb)
226{
227 struct h264_ring_fb_list *list;
228
229 if (fb) {
230 if (check_list_validity(inst, false))
231 return;
232
233 list = &inst->vsi->list_free;
234 if (list->count == H264_MAX_FB_NUM) {
235 mtk_vcodec_err(inst, "[FB] put fb free_list full");
236 return;
237 }
238
239 mtk_vcodec_debug(inst, "[FB] put fb into free_list @(%p, %llx)",
240 fb->base_y.va, (u64)fb->base_y.dma_addr);
241
242 list->fb_list[list->write_idx].vdec_fb_va = (u64)(uintptr_t)fb;
243 list->write_idx = (list->write_idx == H264_MAX_FB_NUM - 1) ?
244 0 : list->write_idx + 1;
245 list->count++;
246 }
247}
248
249static void get_pic_info(struct vdec_h264_inst *inst,
250 struct vdec_pic_info *pic)
251{
252 *pic = inst->vsi->pic;
253 mtk_vcodec_debug(inst, "pic(%d, %d), buf(%d, %d)",
254 pic->pic_w, pic->pic_h, pic->buf_w, pic->buf_h);
255 mtk_vcodec_debug(inst, "Y(%d, %d), C(%d, %d)", pic->y_bs_sz,
256 pic->y_len_sz, pic->c_bs_sz, pic->c_len_sz);
257}
258
259static void get_crop_info(struct vdec_h264_inst *inst, struct v4l2_rect *cr)
260{
261 cr->left = inst->vsi->crop.left;
262 cr->top = inst->vsi->crop.top;
263 cr->width = inst->vsi->crop.width;
264 cr->height = inst->vsi->crop.height;
265
266 mtk_vcodec_debug(inst, "l=%d, t=%d, w=%d, h=%d",
267 cr->left, cr->top, cr->width, cr->height);
268}
269
270static void get_dpb_size(struct vdec_h264_inst *inst, unsigned int *dpb_sz)
271{
272 *dpb_sz = inst->vsi->dec.dpb_sz;
273 mtk_vcodec_debug(inst, "sz=%d", *dpb_sz);
274}
275
276static int vdec_h264_init(struct mtk_vcodec_ctx *ctx, unsigned long *h_vdec)
277{
278 struct vdec_h264_inst *inst = NULL;
279 int err;
280
281 inst = kzalloc(sizeof(*inst), GFP_KERNEL);
282 if (!inst)
283 return -ENOMEM;
284
285 inst->ctx = ctx;
286
287 inst->vpu.id = IPI_VDEC_H264;
288 inst->vpu.dev = ctx->dev->vpu_plat_dev;
289 inst->vpu.ctx = ctx;
290 inst->vpu.handler = vpu_dec_ipi_handler;
291
292 err = vpu_dec_init(&inst->vpu);
293 if (err) {
294 mtk_vcodec_err(inst, "vdec_h264 init err=%d", err);
295 goto error_free_inst;
296 }
297
298 inst->vsi = (struct vdec_h264_vsi *)inst->vpu.vsi;
299 err = allocate_predication_buf(inst);
300 if (err)
301 goto error_deinit;
302
303 mtk_vcodec_debug(inst, "H264 Instance >> %p", inst);
304
305 *h_vdec = (unsigned long)inst;
306 return 0;
307
308error_deinit:
309 vpu_dec_deinit(&inst->vpu);
310
311error_free_inst:
312 kfree(inst);
313 return err;
314}
315
316static void vdec_h264_deinit(unsigned long h_vdec)
317{
318 struct vdec_h264_inst *inst = (struct vdec_h264_inst *)h_vdec;
319
320 mtk_vcodec_debug_enter(inst);
321
322 vpu_dec_deinit(&inst->vpu);
323 free_predication_buf(inst);
324 free_mv_buf(inst);
325
326 kfree(inst);
327}
328
329static int find_start_code(unsigned char *data, unsigned int data_sz)
330{
331 if (data_sz > 3 && data[0] == 0 && data[1] == 0 && data[2] == 1)
332 return 3;
333
334 if (data_sz > 4 && data[0] == 0 && data[1] == 0 && data[2] == 0 &&
335 data[3] == 1)
336 return 4;
337
338 return -1;
339}
340
341static int vdec_h264_decode(unsigned long h_vdec, struct mtk_vcodec_mem *bs,
342 struct vdec_fb *fb, bool *res_chg)
343{
344 struct vdec_h264_inst *inst = (struct vdec_h264_inst *)h_vdec;
345 struct vdec_vpu_inst *vpu = &inst->vpu;
346 int nal_start_idx = 0;
347 int err = 0;
348 unsigned int nal_start;
349 unsigned int nal_type;
350 unsigned char *buf;
351 unsigned int buf_sz;
352 unsigned int data[2];
353 uint64_t vdec_fb_va = (u64)(uintptr_t)fb;
354 uint64_t y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0;
355 uint64_t c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0;
356
357 mtk_vcodec_debug(inst, "+ [%d] FB y_dma=%llx c_dma=%llx va=%p",
358 ++inst->num_nalu, y_fb_dma, c_fb_dma, fb);
359
360 /* bs NULL means flush decoder */
361 if (bs == NULL)
362 return vpu_dec_reset(vpu);
363
364 buf = (unsigned char *)bs->va;
365 buf_sz = bs->size;
366 nal_start_idx = find_start_code(buf, buf_sz);
367 if (nal_start_idx < 0)
368 goto err_free_fb_out;
369
370 nal_start = buf[nal_start_idx];
371 nal_type = NAL_TYPE(buf[nal_start_idx]);
372 mtk_vcodec_debug(inst, "\n + NALU[%d] type %d +\n", inst->num_nalu,
373 nal_type);
374
375 if (nal_type == NAL_H264_PPS) {
376 buf_sz -= nal_start_idx;
377 if (buf_sz > HDR_PARSING_BUF_SZ) {
378 err = -EILSEQ;
379 goto err_free_fb_out;
380 }
381 memcpy(inst->vsi->hdr_buf, buf + nal_start_idx, buf_sz);
382 }
383
384 inst->vsi->dec.bs_dma = (uint64_t)bs->dma_addr;
385 inst->vsi->dec.y_fb_dma = y_fb_dma;
386 inst->vsi->dec.c_fb_dma = c_fb_dma;
387 inst->vsi->dec.vdec_fb_va = vdec_fb_va;
388
389 data[0] = buf_sz;
390 data[1] = nal_start;
391 err = vpu_dec_start(vpu, data, 2);
392 if (err)
393 goto err_free_fb_out;
394
395 *res_chg = inst->vsi->dec.resolution_changed;
396 if (*res_chg) {
397 struct vdec_pic_info pic;
398
399 mtk_vcodec_debug(inst, "- resolution changed -");
400 get_pic_info(inst, &pic);
401
402 if (inst->vsi->dec.realloc_mv_buf) {
403 err = alloc_mv_buf(inst, &pic);
404 if (err)
405 goto err_free_fb_out;
406 }
407 }
408
409 if (nal_type == NAL_NON_IDR_SLICE || nal_type == NAL_IDR_SLICE) {
410 /* wait decoder done interrupt */
411 err = mtk_vcodec_wait_for_done_ctx(inst->ctx,
412 MTK_INST_IRQ_RECEIVED,
413 WAIT_INTR_TIMEOUT_MS);
414 if (err)
415 goto err_free_fb_out;
416
417 vpu_dec_end(vpu);
418 }
419
420 mtk_vcodec_debug(inst, "\n - NALU[%d] type=%d -\n", inst->num_nalu,
421 nal_type);
422 return 0;
423
424err_free_fb_out:
425 put_fb_to_free(inst, fb);
426 mtk_vcodec_err(inst, "\n - NALU[%d] err=%d -\n", inst->num_nalu, err);
427 return err;
428}
429
430static void vdec_h264_get_fb(struct vdec_h264_inst *inst,
431 struct h264_ring_fb_list *list,
432 bool disp_list, struct vdec_fb **out_fb)
433{
434 struct vdec_fb *fb;
435
436 if (check_list_validity(inst, disp_list))
437 return;
438
439 if (list->count == 0) {
440 mtk_vcodec_debug(inst, "[FB] there is no %s fb",
441 disp_list ? "disp" : "free");
442 *out_fb = NULL;
443 return;
444 }
445
446 fb = (struct vdec_fb *)
447 (uintptr_t)list->fb_list[list->read_idx].vdec_fb_va;
448 fb->status |= (disp_list ? FB_ST_DISPLAY : FB_ST_FREE);
449
450 *out_fb = fb;
451 mtk_vcodec_debug(inst, "[FB] get %s fb st=%d poc=%d %llx",
452 disp_list ? "disp" : "free",
453 fb->status, list->fb_list[list->read_idx].poc,
454 list->fb_list[list->read_idx].vdec_fb_va);
455
456 list->read_idx = (list->read_idx == H264_MAX_FB_NUM - 1) ?
457 0 : list->read_idx + 1;
458 list->count--;
459}
460
461static int vdec_h264_get_param(unsigned long h_vdec,
462 enum vdec_get_param_type type, void *out)
463{
464 struct vdec_h264_inst *inst = (struct vdec_h264_inst *)h_vdec;
465
466 switch (type) {
467 case GET_PARAM_DISP_FRAME_BUFFER:
468 vdec_h264_get_fb(inst, &inst->vsi->list_disp, true, out);
469 break;
470
471 case GET_PARAM_FREE_FRAME_BUFFER:
472 vdec_h264_get_fb(inst, &inst->vsi->list_free, false, out);
473 break;
474
475 case GET_PARAM_PIC_INFO:
476 get_pic_info(inst, out);
477 break;
478
479 case GET_PARAM_DPB_SIZE:
480 get_dpb_size(inst, out);
481 break;
482
483 case GET_PARAM_CROP_INFO:
484 get_crop_info(inst, out);
485 break;
486
487 default:
488 mtk_vcodec_err(inst, "invalid get parameter type=%d", type);
489 return -EINVAL;
490 }
491
492 return 0;
493}
494
495static struct vdec_common_if vdec_h264_if = {
496 vdec_h264_init,
497 vdec_h264_decode,
498 vdec_h264_get_param,
499 vdec_h264_deinit,
500};
501
502struct vdec_common_if *get_h264_dec_comm_if(void);
503
504struct vdec_common_if *get_h264_dec_comm_if(void)
505{
506 return &vdec_h264_if;
507}
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
new file mode 100644
index 000000000000..6e7a62ae0842
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
@@ -0,0 +1,634 @@
1/*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: Jungchang Tsao <jungchang.tsao@mediatek.com>
4 * PC Chen <pc.chen@mediatek.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 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/slab.h>
17#include "../vdec_drv_if.h"
18#include "../mtk_vcodec_util.h"
19#include "../mtk_vcodec_dec.h"
20#include "../mtk_vcodec_intr.h"
21#include "../vdec_vpu_if.h"
22#include "../vdec_drv_base.h"
23
24/* Decoding picture buffer size (3 reference frames plus current frame) */
25#define VP8_DPB_SIZE 4
26
27/* HW working buffer size (bytes) */
28#define VP8_WORKING_BUF_SZ (45 * 4096)
29
30/* HW control register address */
31#define VP8_SEGID_DRAM_ADDR 0x3c
32#define VP8_HW_VLD_ADDR 0x93C
33#define VP8_HW_VLD_VALUE 0x940
34#define VP8_BSASET 0x100
35#define VP8_BSDSET 0x104
36#define VP8_RW_CKEN_SET 0x0
37#define VP8_RW_DCM_CON 0x18
38#define VP8_WO_VLD_SRST 0x108
39#define VP8_RW_MISC_SYS_SEL 0x84
40#define VP8_RW_MISC_SPEC_CON 0xC8
41#define VP8_WO_VLD_SRST 0x108
42#define VP8_RW_VP8_CTRL 0xA4
43#define VP8_RW_MISC_DCM_CON 0xEC
44#define VP8_RW_MISC_SRST 0xF4
45#define VP8_RW_MISC_FUNC_CON 0xCC
46
47#define VP8_MAX_FRM_BUF_NUM 5
48#define VP8_MAX_FRM_BUF_NODE_NUM (VP8_MAX_FRM_BUF_NUM * 2)
49
50/* required buffer size (bytes) to store decode information */
51#define VP8_HW_SEGMENT_DATA_SZ 272
52#define VP8_HW_SEGMENT_UINT 4
53
54#define VP8_DEC_TABLE_PROC_LOOP 96
55#define VP8_DEC_TABLE_UNIT 3
56#define VP8_DEC_TABLE_SZ 300
57#define VP8_DEC_TABLE_OFFSET 2
58#define VP8_DEC_TABLE_RW_UNIT 4
59
60/**
61 * struct vdec_vp8_dec_info - decode misc information
62 * @working_buf_dma : working buffer dma address
63 * @prev_y_dma : previous decoded frame buffer Y plane address
64 * @cur_y_fb_dma : current plane Y frame buffer dma address
65 * @cur_c_fb_dma : current plane C frame buffer dma address
66 * @bs_dma : bitstream dma address
67 * @bs_sz : bitstream size
68 * @resolution_changed: resolution change flag 1 - changed, 0 - not change
69 * @show_frame : display this frame or not
70 * @wait_key_frame : wait key frame coming
71 */
72struct vdec_vp8_dec_info {
73 uint64_t working_buf_dma;
74 uint64_t prev_y_dma;
75 uint64_t cur_y_fb_dma;
76 uint64_t cur_c_fb_dma;
77 uint64_t bs_dma;
78 uint32_t bs_sz;
79 uint32_t resolution_changed;
80 uint32_t show_frame;
81 uint32_t wait_key_frame;
82};
83
84/**
85 * struct vdec_vp8_vsi - VPU shared information
86 * @dec : decoding information
87 * @pic : picture information
88 * @dec_table : decoder coefficient table
89 * @segment_buf : segmentation buffer
90 * @load_data : flag to indicate reload decode data
91 */
92struct vdec_vp8_vsi {
93 struct vdec_vp8_dec_info dec;
94 struct vdec_pic_info pic;
95 uint32_t dec_table[VP8_DEC_TABLE_SZ];
96 uint32_t segment_buf[VP8_HW_SEGMENT_DATA_SZ][VP8_HW_SEGMENT_UINT];
97 uint32_t load_data;
98};
99
100/**
101 * struct vdec_vp8_hw_reg_base - HW register base
102 * @sys : base address for sys
103 * @misc : base address for misc
104 * @ld : base address for ld
105 * @top : base address for top
106 * @cm : base address for cm
107 * @hwd : base address for hwd
108 * @hwb : base address for hwb
109 */
110struct vdec_vp8_hw_reg_base {
111 void __iomem *sys;
112 void __iomem *misc;
113 void __iomem *ld;
114 void __iomem *top;
115 void __iomem *cm;
116 void __iomem *hwd;
117 void __iomem *hwb;
118};
119
120/**
121 * struct vdec_vp8_vpu_inst - VPU instance for VP8 decode
122 * @wq_hd : Wait queue to wait VPU message ack
123 * @signaled : 1 - Host has received ack message from VPU, 0 - not recevie
124 * @failure : VPU execution result status 0 - success, others - fail
125 * @inst_addr : VPU decoder instance address
126 */
127struct vdec_vp8_vpu_inst {
128 wait_queue_head_t wq_hd;
129 int signaled;
130 int failure;
131 uint32_t inst_addr;
132};
133
134/* frame buffer (fb) list
135 * [available_fb_node_list] - decode fb are initialized to 0 and populated in
136 * [fb_use_list] - fb is set after decode and is moved to this list
137 * [fb_free_list] - fb is not needed for reference will be moved from
138 * [fb_use_list] to [fb_free_list] and
139 * once user remove fb from [fb_free_list],
140 * it is circulated back to [available_fb_node_list]
141 * [fb_disp_list] - fb is set after decode and is moved to this list
142 * once user remove fb from [fb_disp_list] it is
143 * circulated back to [available_fb_node_list]
144 */
145
146/**
147 * struct vdec_vp8_inst - VP8 decoder instance
148 * @cur_fb : current frame buffer
149 * @dec_fb : decode frame buffer node
150 * @available_fb_node_list : list to store available frame buffer node
151 * @fb_use_list : list to store frame buffer in use
152 * @fb_free_list : list to store free frame buffer
153 * @fb_disp_list : list to store display ready frame buffer
154 * @working_buf : HW decoder working buffer
155 * @reg_base : HW register base address
156 * @frm_cnt : decode frame count
157 * @ctx : V4L2 context
158 * @dev : platform device
159 * @vpu : VPU instance for decoder
160 * @vsi : VPU share information
161 */
162struct vdec_vp8_inst {
163 struct vdec_fb *cur_fb;
164 struct vdec_fb_node dec_fb[VP8_MAX_FRM_BUF_NODE_NUM];
165 struct list_head available_fb_node_list;
166 struct list_head fb_use_list;
167 struct list_head fb_free_list;
168 struct list_head fb_disp_list;
169 struct mtk_vcodec_mem working_buf;
170 struct vdec_vp8_hw_reg_base reg_base;
171 unsigned int frm_cnt;
172 struct mtk_vcodec_ctx *ctx;
173 struct vdec_vpu_inst vpu;
174 struct vdec_vp8_vsi *vsi;
175};
176
177static void get_hw_reg_base(struct vdec_vp8_inst *inst)
178{
179 inst->reg_base.top = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_TOP);
180 inst->reg_base.cm = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_CM);
181 inst->reg_base.hwd = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_HWD);
182 inst->reg_base.sys = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_SYS);
183 inst->reg_base.misc = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_MISC);
184 inst->reg_base.ld = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_LD);
185 inst->reg_base.hwb = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_HWB);
186}
187
188static void write_hw_segmentation_data(struct vdec_vp8_inst *inst)
189{
190 int i, j;
191 u32 seg_id_addr;
192 u32 val;
193 void __iomem *cm = inst->reg_base.cm;
194 struct vdec_vp8_vsi *vsi = inst->vsi;
195
196 seg_id_addr = readl(inst->reg_base.top + VP8_SEGID_DRAM_ADDR) >> 4;
197
198 for (i = 0; i < ARRAY_SIZE(vsi->segment_buf); i++) {
199 for (j = ARRAY_SIZE(vsi->segment_buf[i]) - 1; j >= 0; j--) {
200 val = (1 << 16) + ((seg_id_addr + i) << 2) + j;
201 writel(val, cm + VP8_HW_VLD_ADDR);
202
203 val = vsi->segment_buf[i][j];
204 writel(val, cm + VP8_HW_VLD_VALUE);
205 }
206 }
207}
208
209static void read_hw_segmentation_data(struct vdec_vp8_inst *inst)
210{
211 int i, j;
212 u32 seg_id_addr;
213 u32 val;
214 void __iomem *cm = inst->reg_base.cm;
215 struct vdec_vp8_vsi *vsi = inst->vsi;
216
217 seg_id_addr = readl(inst->reg_base.top + VP8_SEGID_DRAM_ADDR) >> 4;
218
219 for (i = 0; i < ARRAY_SIZE(vsi->segment_buf); i++) {
220 for (j = ARRAY_SIZE(vsi->segment_buf[i]) - 1; j >= 0; j--) {
221 val = ((seg_id_addr + i) << 2) + j;
222 writel(val, cm + VP8_HW_VLD_ADDR);
223
224 val = readl(cm + VP8_HW_VLD_VALUE);
225 vsi->segment_buf[i][j] = val;
226 }
227 }
228}
229
230/* reset HW and enable HW read/write data function */
231static void enable_hw_rw_function(struct vdec_vp8_inst *inst)
232{
233 u32 val = 0;
234 void __iomem *sys = inst->reg_base.sys;
235 void __iomem *misc = inst->reg_base.misc;
236 void __iomem *ld = inst->reg_base.ld;
237 void __iomem *hwb = inst->reg_base.hwb;
238 void __iomem *hwd = inst->reg_base.hwd;
239
240 writel(0x1, sys + VP8_RW_CKEN_SET);
241 writel(0x101, ld + VP8_WO_VLD_SRST);
242 writel(0x101, hwb + VP8_WO_VLD_SRST);
243
244 writel(1, sys);
245 val = readl(misc + VP8_RW_MISC_SRST);
246 writel((val & 0xFFFFFFFE), misc + VP8_RW_MISC_SRST);
247
248 writel(0x1, misc + VP8_RW_MISC_SYS_SEL);
249 writel(0x17F, misc + VP8_RW_MISC_SPEC_CON);
250 writel(0x71201100, misc + VP8_RW_MISC_FUNC_CON);
251 writel(0x0, ld + VP8_WO_VLD_SRST);
252 writel(0x0, hwb + VP8_WO_VLD_SRST);
253 writel(0x1, sys + VP8_RW_DCM_CON);
254 writel(0x1, misc + VP8_RW_MISC_DCM_CON);
255 writel(0x1, hwd + VP8_RW_VP8_CTRL);
256}
257
258static void store_dec_table(struct vdec_vp8_inst *inst)
259{
260 int i, j;
261 u32 addr = 0, val = 0;
262 void __iomem *hwd = inst->reg_base.hwd;
263 u32 *p = &inst->vsi->dec_table[VP8_DEC_TABLE_OFFSET];
264
265 for (i = 0; i < VP8_DEC_TABLE_PROC_LOOP; i++) {
266 writel(addr, hwd + VP8_BSASET);
267 for (j = 0; j < VP8_DEC_TABLE_UNIT ; j++) {
268 val = *p++;
269 writel(val, hwd + VP8_BSDSET);
270 }
271 addr += VP8_DEC_TABLE_RW_UNIT;
272 }
273}
274
275static void load_dec_table(struct vdec_vp8_inst *inst)
276{
277 int i;
278 u32 addr = 0;
279 u32 *p = &inst->vsi->dec_table[VP8_DEC_TABLE_OFFSET];
280 void __iomem *hwd = inst->reg_base.hwd;
281
282 for (i = 0; i < VP8_DEC_TABLE_PROC_LOOP; i++) {
283 writel(addr, hwd + VP8_BSASET);
284 /* read total 11 bytes */
285 *p++ = readl(hwd + VP8_BSDSET);
286 *p++ = readl(hwd + VP8_BSDSET);
287 *p++ = readl(hwd + VP8_BSDSET) & 0xFFFFFF;
288 addr += VP8_DEC_TABLE_RW_UNIT;
289 }
290}
291
292static void get_pic_info(struct vdec_vp8_inst *inst, struct vdec_pic_info *pic)
293{
294 *pic = inst->vsi->pic;
295
296 mtk_vcodec_debug(inst, "pic(%d, %d), buf(%d, %d)",
297 pic->pic_w, pic->pic_h, pic->buf_w, pic->buf_h);
298 mtk_vcodec_debug(inst, "Y(%d, %d), C(%d, %d)", pic->y_bs_sz,
299 pic->y_len_sz, pic->c_bs_sz, pic->c_len_sz);
300}
301
302static void vp8_dec_finish(struct vdec_vp8_inst *inst)
303{
304 struct vdec_fb_node *node;
305 uint64_t prev_y_dma = inst->vsi->dec.prev_y_dma;
306
307 mtk_vcodec_debug(inst, "prev fb base dma=%llx", prev_y_dma);
308
309 /* put last decode ok frame to fb_free_list */
310 if (prev_y_dma != 0) {
311 list_for_each_entry(node, &inst->fb_use_list, list) {
312 struct vdec_fb *fb = (struct vdec_fb *)node->fb;
313
314 if (prev_y_dma == (uint64_t)fb->base_y.dma_addr) {
315 list_move_tail(&node->list,
316 &inst->fb_free_list);
317 break;
318 }
319 }
320 }
321
322 /* available_fb_node_list -> fb_use_list */
323 node = list_first_entry(&inst->available_fb_node_list,
324 struct vdec_fb_node, list);
325 node->fb = inst->cur_fb;
326 list_move_tail(&node->list, &inst->fb_use_list);
327
328 /* available_fb_node_list -> fb_disp_list */
329 if (inst->vsi->dec.show_frame) {
330 node = list_first_entry(&inst->available_fb_node_list,
331 struct vdec_fb_node, list);
332 node->fb = inst->cur_fb;
333 list_move_tail(&node->list, &inst->fb_disp_list);
334 }
335}
336
337static void move_fb_list_use_to_free(struct vdec_vp8_inst *inst)
338{
339 struct vdec_fb_node *node, *tmp;
340
341 list_for_each_entry_safe(node, tmp, &inst->fb_use_list, list)
342 list_move_tail(&node->list, &inst->fb_free_list);
343}
344
345static void init_list(struct vdec_vp8_inst *inst)
346{
347 int i;
348
349 INIT_LIST_HEAD(&inst->available_fb_node_list);
350 INIT_LIST_HEAD(&inst->fb_use_list);
351 INIT_LIST_HEAD(&inst->fb_free_list);
352 INIT_LIST_HEAD(&inst->fb_disp_list);
353
354 for (i = 0; i < ARRAY_SIZE(inst->dec_fb); i++) {
355 INIT_LIST_HEAD(&inst->dec_fb[i].list);
356 inst->dec_fb[i].fb = NULL;
357 list_add_tail(&inst->dec_fb[i].list,
358 &inst->available_fb_node_list);
359 }
360}
361
362static void add_fb_to_free_list(struct vdec_vp8_inst *inst, void *fb)
363{
364 struct vdec_fb_node *node;
365
366 if (fb) {
367 node = list_first_entry(&inst->available_fb_node_list,
368 struct vdec_fb_node, list);
369 node->fb = fb;
370 list_move_tail(&node->list, &inst->fb_free_list);
371 }
372}
373
374static int alloc_working_buf(struct vdec_vp8_inst *inst)
375{
376 int err;
377 struct mtk_vcodec_mem *mem = &inst->working_buf;
378
379 mem->size = VP8_WORKING_BUF_SZ;
380 err = mtk_vcodec_mem_alloc(inst->ctx, mem);
381 if (err) {
382 mtk_vcodec_err(inst, "Cannot allocate working buffer");
383 return err;
384 }
385
386 inst->vsi->dec.working_buf_dma = (uint64_t)mem->dma_addr;
387 return 0;
388}
389
390static void free_working_buf(struct vdec_vp8_inst *inst)
391{
392 struct mtk_vcodec_mem *mem = &inst->working_buf;
393
394 if (mem->va)
395 mtk_vcodec_mem_free(inst->ctx, mem);
396
397 inst->vsi->dec.working_buf_dma = 0;
398}
399
400static int vdec_vp8_init(struct mtk_vcodec_ctx *ctx, unsigned long *h_vdec)
401{
402 struct vdec_vp8_inst *inst;
403 int err;
404
405 inst = kzalloc(sizeof(*inst), GFP_KERNEL);
406 if (!inst)
407 return -ENOMEM;
408
409 inst->ctx = ctx;
410
411 inst->vpu.id = IPI_VDEC_VP8;
412 inst->vpu.dev = ctx->dev->vpu_plat_dev;
413 inst->vpu.ctx = ctx;
414 inst->vpu.handler = vpu_dec_ipi_handler;
415
416 err = vpu_dec_init(&inst->vpu);
417 if (err) {
418 mtk_vcodec_err(inst, "vdec_vp8 init err=%d", err);
419 goto error_free_inst;
420 }
421
422 inst->vsi = (struct vdec_vp8_vsi *)inst->vpu.vsi;
423 init_list(inst);
424 err = alloc_working_buf(inst);
425 if (err)
426 goto error_deinit;
427
428 get_hw_reg_base(inst);
429 mtk_vcodec_debug(inst, "VP8 Instance >> %p", inst);
430
431 *h_vdec = (unsigned long)inst;
432 return 0;
433
434error_deinit:
435 vpu_dec_deinit(&inst->vpu);
436error_free_inst:
437 kfree(inst);
438 return err;
439}
440
441static int vdec_vp8_decode(unsigned long h_vdec, struct mtk_vcodec_mem *bs,
442 struct vdec_fb *fb, bool *res_chg)
443{
444 struct vdec_vp8_inst *inst = (struct vdec_vp8_inst *)h_vdec;
445 struct vdec_vp8_dec_info *dec = &inst->vsi->dec;
446 struct vdec_vpu_inst *vpu = &inst->vpu;
447 unsigned char *bs_va;
448 unsigned int data;
449 int err = 0;
450 uint64_t y_fb_dma;
451 uint64_t c_fb_dma;
452
453 /* bs NULL means flush decoder */
454 if (bs == NULL) {
455 move_fb_list_use_to_free(inst);
456 return vpu_dec_reset(vpu);
457 }
458
459 y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0;
460 c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0;
461
462 mtk_vcodec_debug(inst, "+ [%d] FB y_dma=%llx c_dma=%llx fb=%p",
463 inst->frm_cnt, y_fb_dma, c_fb_dma, fb);
464
465 inst->cur_fb = fb;
466 dec->bs_dma = (unsigned long)bs->dma_addr;
467 dec->bs_sz = bs->size;
468 dec->cur_y_fb_dma = y_fb_dma;
469 dec->cur_c_fb_dma = c_fb_dma;
470
471 mtk_vcodec_debug(inst, "\n + FRAME[%d] +\n", inst->frm_cnt);
472
473 write_hw_segmentation_data(inst);
474 enable_hw_rw_function(inst);
475 store_dec_table(inst);
476
477 bs_va = (unsigned char *)bs->va;
478
479 /* retrieve width/hight and scale info from header */
480 data = (*(bs_va + 9) << 24) | (*(bs_va + 8) << 16) |
481 (*(bs_va + 7) << 8) | *(bs_va + 6);
482 err = vpu_dec_start(vpu, &data, 1);
483 if (err) {
484 add_fb_to_free_list(inst, fb);
485 if (dec->wait_key_frame) {
486 mtk_vcodec_debug(inst, "wait key frame !");
487 return 0;
488 }
489
490 goto error;
491 }
492
493 if (dec->resolution_changed) {
494 mtk_vcodec_debug(inst, "- resolution_changed -");
495 *res_chg = true;
496 add_fb_to_free_list(inst, fb);
497 return 0;
498 }
499
500 /* wait decoder done interrupt */
501 mtk_vcodec_wait_for_done_ctx(inst->ctx, MTK_INST_IRQ_RECEIVED,
502 WAIT_INTR_TIMEOUT_MS);
503
504 if (inst->vsi->load_data)
505 load_dec_table(inst);
506
507 vp8_dec_finish(inst);
508 read_hw_segmentation_data(inst);
509
510 err = vpu_dec_end(vpu);
511 if (err)
512 goto error;
513
514 mtk_vcodec_debug(inst, "\n - FRAME[%d] - show=%d\n", inst->frm_cnt,
515 dec->show_frame);
516 inst->frm_cnt++;
517 *res_chg = false;
518 return 0;
519
520error:
521 mtk_vcodec_err(inst, "\n - FRAME[%d] - err=%d\n", inst->frm_cnt, err);
522 return err;
523}
524
525static void get_disp_fb(struct vdec_vp8_inst *inst, struct vdec_fb **out_fb)
526{
527 struct vdec_fb_node *node;
528 struct vdec_fb *fb;
529
530 node = list_first_entry_or_null(&inst->fb_disp_list,
531 struct vdec_fb_node, list);
532 if (node) {
533 list_move_tail(&node->list, &inst->available_fb_node_list);
534 fb = (struct vdec_fb *)node->fb;
535 fb->status |= FB_ST_DISPLAY;
536 mtk_vcodec_debug(inst, "[FB] get disp fb %p st=%d",
537 node->fb, fb->status);
538 } else {
539 fb = NULL;
540 mtk_vcodec_debug(inst, "[FB] there is no disp fb");
541 }
542
543 *out_fb = fb;
544}
545
546static void get_free_fb(struct vdec_vp8_inst *inst, struct vdec_fb **out_fb)
547{
548 struct vdec_fb_node *node;
549 struct vdec_fb *fb;
550
551 node = list_first_entry_or_null(&inst->fb_free_list,
552 struct vdec_fb_node, list);
553 if (node) {
554 list_move_tail(&node->list, &inst->available_fb_node_list);
555 fb = (struct vdec_fb *)node->fb;
556 fb->status |= FB_ST_FREE;
557 mtk_vcodec_debug(inst, "[FB] get free fb %p st=%d",
558 node->fb, fb->status);
559 } else {
560 fb = NULL;
561 mtk_vcodec_debug(inst, "[FB] there is no free fb");
562 }
563
564 *out_fb = fb;
565}
566
567static void get_crop_info(struct vdec_vp8_inst *inst, struct v4l2_rect *cr)
568{
569 cr->left = 0;
570 cr->top = 0;
571 cr->width = inst->vsi->pic.pic_w;
572 cr->height = inst->vsi->pic.pic_h;
573 mtk_vcodec_debug(inst, "get crop info l=%d, t=%d, w=%d, h=%d",
574 cr->left, cr->top, cr->width, cr->height);
575}
576
577static int vdec_vp8_get_param(unsigned long h_vdec,
578 enum vdec_get_param_type type, void *out)
579{
580 struct vdec_vp8_inst *inst = (struct vdec_vp8_inst *)h_vdec;
581
582 switch (type) {
583 case GET_PARAM_DISP_FRAME_BUFFER:
584 get_disp_fb(inst, out);
585 break;
586
587 case GET_PARAM_FREE_FRAME_BUFFER:
588 get_free_fb(inst, out);
589 break;
590
591 case GET_PARAM_PIC_INFO:
592 get_pic_info(inst, out);
593 break;
594
595 case GET_PARAM_CROP_INFO:
596 get_crop_info(inst, out);
597 break;
598
599 case GET_PARAM_DPB_SIZE:
600 *((unsigned int *)out) = VP8_DPB_SIZE;
601 break;
602
603 default:
604 mtk_vcodec_err(inst, "invalid get parameter type=%d", type);
605 return -EINVAL;
606 }
607
608 return 0;
609}
610
611static void vdec_vp8_deinit(unsigned long h_vdec)
612{
613 struct vdec_vp8_inst *inst = (struct vdec_vp8_inst *)h_vdec;
614
615 mtk_vcodec_debug_enter(inst);
616
617 vpu_dec_deinit(&inst->vpu);
618 free_working_buf(inst);
619 kfree(inst);
620}
621
622static struct vdec_common_if vdec_vp8_if = {
623 vdec_vp8_init,
624 vdec_vp8_decode,
625 vdec_vp8_get_param,
626 vdec_vp8_deinit,
627};
628
629struct vdec_common_if *get_vp8_dec_comm_if(void);
630
631struct vdec_common_if *get_vp8_dec_comm_if(void)
632{
633 return &vdec_vp8_if;
634}
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
new file mode 100644
index 000000000000..e91a3b425b0c
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
@@ -0,0 +1,967 @@
1/*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: Daniel Hsiao <daniel.hsiao@mediatek.com>
4 * Kai-Sean Yang <kai-sean.yang@mediatek.com>
5 * Tiffany Lin <tiffany.lin@mediatek.com>
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/fs.h>
18#include <linux/slab.h>
19#include <linux/syscalls.h>
20#include <linux/delay.h>
21#include <linux/time.h>
22
23#include "../mtk_vcodec_intr.h"
24#include "../vdec_drv_base.h"
25#include "../vdec_vpu_if.h"
26
27#define VP9_SUPER_FRAME_BS_SZ 64
28#define MAX_VP9_DPB_SIZE 9
29
30#define REFS_PER_FRAME 3
31#define MAX_NUM_REF_FRAMES 8
32#define VP9_MAX_FRM_BUF_NUM 9
33#define VP9_MAX_FRM_BUF_NODE_NUM (VP9_MAX_FRM_BUF_NUM * 2)
34
35/**
36 * struct vp9_dram_buf - contains buffer info for vpu
37 * @va : cpu address
38 * @pa : iova address
39 * @sz : buffer size
40 * @padding : for 64 bytes alignment
41 */
42struct vp9_dram_buf {
43 unsigned long va;
44 unsigned long pa;
45 unsigned int sz;
46 unsigned int padding;
47};
48
49/**
50 * struct vp9_fb_info - contains frame buffer info
51 * @fb : frmae buffer
52 * @reserved : reserved field used by vpu
53 */
54struct vp9_fb_info {
55 struct vdec_fb *fb;
56 unsigned int reserved[32];
57};
58
59/**
60 * struct vp9_ref_cnt_buf - contains reference buffer information
61 * @buf : referenced frame buffer
62 * @ref_cnt : referenced frame buffer's reference count.
63 * When reference count=0, remove it from reference list
64 */
65struct vp9_ref_cnt_buf {
66 struct vp9_fb_info buf;
67 unsigned int ref_cnt;
68};
69
70/**
71 * struct vp9_fb_info - contains current frame's reference buffer information
72 * @buf : reference buffer
73 * @idx : reference buffer index to frm_bufs
74 * @reserved : reserved field used by vpu
75 */
76struct vp9_ref_buf {
77 struct vp9_fb_info *buf;
78 unsigned int idx;
79 unsigned int reserved[6];
80};
81
82/**
83 * struct vp9_fb_info - contains frame buffer info
84 * @fb : super frame reference frame buffer
85 * @used : this reference frame info entry is used
86 * @padding : for 64 bytes size align
87 */
88struct vp9_sf_ref_fb {
89 struct vdec_fb fb;
90 int used;
91 int padding;
92};
93
94/*
95 * struct vdec_vp9_vsi - shared buffer between host and VPU firmware
96 * AP-W/R : AP is writer/reader on this item
97 * VPU-W/R: VPU is write/reader on this item
98 * @sf_bs_buf : super frame backup buffer (AP-W, VPU-R)
99 * @sf_ref_fb : record supoer frame reference buffer information
100 * (AP-R/W, VPU-R/W)
101 * @sf_next_ref_fb_idx : next available super frame (AP-W, VPU-R)
102 * @sf_frm_cnt : super frame count, filled by vpu (AP-R, VPU-W)
103 * @sf_frm_offset : super frame offset, filled by vpu (AP-R, VPU-W)
104 * @sf_frm_sz : super frame size, filled by vpu (AP-R, VPU-W)
105 * @sf_frm_idx : current super frame (AP-R, VPU-W)
106 * @sf_init : inform super frame info already parsed by vpu (AP-R, VPU-W)
107 * @fb : capture buffer (AP-W, VPU-R)
108 * @bs : bs buffer (AP-W, VPU-R)
109 * @cur_fb : current show capture buffer (AP-R/W, VPU-R/W)
110 * @pic_w : picture width (AP-R, VPU-W)
111 * @pic_h : picture height (AP-R, VPU-W)
112 * @buf_w : codec width (AP-R, VPU-W)
113 * @buf_h : coded height (AP-R, VPU-W)
114 * @buf_sz_y_bs : ufo compressed y plane size (AP-R, VPU-W)
115 * @buf_sz_c_bs : ufo compressed cbcr plane size (AP-R, VPU-W)
116 * @buf_len_sz_y : size used to store y plane ufo info (AP-R, VPU-W)
117 * @buf_len_sz_c : size used to store cbcr plane ufo info (AP-R, VPU-W)
118
119 * @profile : profile sparsed from vpu (AP-R, VPU-W)
120 * @show_frame : display this frame or not (AP-R, VPU-W)
121 * @show_existing_frame : inform this frame is show existing frame
122 * (AP-R, VPU-W)
123 * @frm_to_show_idx : index to show frame (AP-R, VPU-W)
124
125 * @refresh_frm_flags : indicate when frame need to refine reference count
126 * (AP-R, VPU-W)
127 * @resolution_changed : resolution change in this frame (AP-R, VPU-W)
128
129 * @frm_bufs : maintain reference buffer info (AP-R/W, VPU-R/W)
130 * @ref_frm_map : maintain reference buffer map info (AP-R/W, VPU-R/W)
131 * @new_fb_idx : index to frm_bufs array (AP-R, VPU-W)
132 * @frm_num : decoded frame number, include sub-frame count (AP-R, VPU-W)
133 * @mv_buf : motion vector working buffer (AP-W, VPU-R)
134 * @frm_refs : maintain three reference buffer info (AP-R/W, VPU-R/W)
135 */
136struct vdec_vp9_vsi {
137 unsigned char sf_bs_buf[VP9_SUPER_FRAME_BS_SZ];
138 struct vp9_sf_ref_fb sf_ref_fb[VP9_MAX_FRM_BUF_NUM-1];
139 int sf_next_ref_fb_idx;
140 unsigned int sf_frm_cnt;
141 unsigned int sf_frm_offset[VP9_MAX_FRM_BUF_NUM-1];
142 unsigned int sf_frm_sz[VP9_MAX_FRM_BUF_NUM-1];
143 unsigned int sf_frm_idx;
144 unsigned int sf_init;
145 struct vdec_fb fb;
146 struct mtk_vcodec_mem bs;
147 struct vdec_fb cur_fb;
148 unsigned int pic_w;
149 unsigned int pic_h;
150 unsigned int buf_w;
151 unsigned int buf_h;
152 unsigned int buf_sz_y_bs;
153 unsigned int buf_sz_c_bs;
154 unsigned int buf_len_sz_y;
155 unsigned int buf_len_sz_c;
156 unsigned int profile;
157 unsigned int show_frame;
158 unsigned int show_existing_frame;
159 unsigned int frm_to_show_idx;
160 unsigned int refresh_frm_flags;
161 unsigned int resolution_changed;
162
163 struct vp9_ref_cnt_buf frm_bufs[VP9_MAX_FRM_BUF_NUM];
164 int ref_frm_map[MAX_NUM_REF_FRAMES];
165 unsigned int new_fb_idx;
166 unsigned int frm_num;
167 struct vp9_dram_buf mv_buf;
168
169 struct vp9_ref_buf frm_refs[REFS_PER_FRAME];
170};
171
172/*
173 * struct vdec_vp9_inst - vp9 decode instance
174 * @mv_buf : working buffer for mv
175 * @dec_fb : vdec_fb node to link fb to different fb_xxx_list
176 * @available_fb_node_list : current available vdec_fb node
177 * @fb_use_list : current used or referenced vdec_fb
178 * @fb_free_list : current available to free vdec_fb
179 * @fb_disp_list : current available to display vdec_fb
180 * @cur_fb : current frame buffer
181 * @ctx : current decode context
182 * @vpu : vpu instance information
183 * @vsi : shared buffer between host and VPU firmware
184 * @total_frm_cnt : total frame count, it do not include sub-frames in super
185 * frame
186 * @mem : instance memory information
187 */
188struct vdec_vp9_inst {
189 struct mtk_vcodec_mem mv_buf;
190
191 struct vdec_fb_node dec_fb[VP9_MAX_FRM_BUF_NODE_NUM];
192 struct list_head available_fb_node_list;
193 struct list_head fb_use_list;
194 struct list_head fb_free_list;
195 struct list_head fb_disp_list;
196 struct vdec_fb *cur_fb;
197 struct mtk_vcodec_ctx *ctx;
198 struct vdec_vpu_inst vpu;
199 struct vdec_vp9_vsi *vsi;
200 unsigned int total_frm_cnt;
201 struct mtk_vcodec_mem mem;
202};
203
204static bool vp9_is_sf_ref_fb(struct vdec_vp9_inst *inst, struct vdec_fb *fb)
205{
206 int i;
207 struct vdec_vp9_vsi *vsi = inst->vsi;
208
209 for (i = 0; i < ARRAY_SIZE(vsi->sf_ref_fb); i++) {
210 if (fb == &vsi->sf_ref_fb[i].fb)
211 return true;
212 }
213 return false;
214}
215
216static struct vdec_fb *vp9_rm_from_fb_use_list(struct vdec_vp9_inst
217 *inst, void *addr)
218{
219 struct vdec_fb *fb = NULL;
220 struct vdec_fb_node *node;
221
222 list_for_each_entry(node, &inst->fb_use_list, list) {
223 fb = (struct vdec_fb *)node->fb;
224 if (fb->base_y.va == addr) {
225 list_move_tail(&node->list,
226 &inst->available_fb_node_list);
227 break;
228 }
229 }
230 return fb;
231}
232
233static void vp9_add_to_fb_free_list(struct vdec_vp9_inst *inst,
234 struct vdec_fb *fb)
235{
236 struct vdec_fb_node *node;
237
238 if (fb) {
239 node = list_first_entry_or_null(&inst->available_fb_node_list,
240 struct vdec_fb_node, list);
241
242 if (node) {
243 node->fb = fb;
244 list_move_tail(&node->list, &inst->fb_free_list);
245 }
246 } else {
247 mtk_vcodec_debug(inst, "No free fb node");
248 }
249}
250
251static void vp9_free_sf_ref_fb(struct vdec_fb *fb)
252{
253 struct vp9_sf_ref_fb *sf_ref_fb =
254 container_of(fb, struct vp9_sf_ref_fb, fb);
255
256 sf_ref_fb->used = 0;
257}
258
259static void vp9_ref_cnt_fb(struct vdec_vp9_inst *inst, int *idx,
260 int new_idx)
261{
262 struct vdec_vp9_vsi *vsi = inst->vsi;
263 int ref_idx = *idx;
264
265 if (ref_idx >= 0 && vsi->frm_bufs[ref_idx].ref_cnt > 0) {
266 vsi->frm_bufs[ref_idx].ref_cnt--;
267
268 if (vsi->frm_bufs[ref_idx].ref_cnt == 0) {
269 if (!vp9_is_sf_ref_fb(inst,
270 vsi->frm_bufs[ref_idx].buf.fb)) {
271 struct vdec_fb *fb;
272
273 fb = vp9_rm_from_fb_use_list(inst,
274 vsi->frm_bufs[ref_idx].buf.fb->base_y.va);
275 vp9_add_to_fb_free_list(inst, fb);
276 } else
277 vp9_free_sf_ref_fb(
278 vsi->frm_bufs[ref_idx].buf.fb);
279 }
280 }
281
282 *idx = new_idx;
283 vsi->frm_bufs[new_idx].ref_cnt++;
284}
285
286static void vp9_free_all_sf_ref_fb(struct vdec_vp9_inst *inst)
287{
288 int i;
289 struct vdec_vp9_vsi *vsi = inst->vsi;
290
291 for (i = 0; i < ARRAY_SIZE(vsi->sf_ref_fb); i++) {
292 if (vsi->sf_ref_fb[i].fb.base_y.va) {
293 mtk_vcodec_mem_free(inst->ctx,
294 &vsi->sf_ref_fb[i].fb.base_y);
295 mtk_vcodec_mem_free(inst->ctx,
296 &vsi->sf_ref_fb[i].fb.base_c);
297 vsi->sf_ref_fb[i].used = 0;
298 }
299 }
300}
301
302/* For each sub-frame except the last one, the driver will dynamically
303 * allocate reference buffer by calling vp9_get_sf_ref_fb()
304 * The last sub-frame will use the original fb provided by the
305 * vp9_dec_decode() interface
306 */
307static int vp9_get_sf_ref_fb(struct vdec_vp9_inst *inst)
308{
309 int idx;
310 struct mtk_vcodec_mem *mem_basy_y;
311 struct mtk_vcodec_mem *mem_basy_c;
312 struct vdec_vp9_vsi *vsi = inst->vsi;
313
314 for (idx = 0;
315 idx < ARRAY_SIZE(vsi->sf_ref_fb);
316 idx++) {
317 if (vsi->sf_ref_fb[idx].fb.base_y.va &&
318 vsi->sf_ref_fb[idx].used == 0) {
319 return idx;
320 }
321 }
322
323 for (idx = 0;
324 idx < ARRAY_SIZE(vsi->sf_ref_fb);
325 idx++) {
326 if (vsi->sf_ref_fb[idx].fb.base_y.va == NULL)
327 break;
328 }
329
330 if (idx == ARRAY_SIZE(vsi->sf_ref_fb)) {
331 mtk_vcodec_err(inst, "List Full");
332 return -1;
333 }
334
335 mem_basy_y = &vsi->sf_ref_fb[idx].fb.base_y;
336 mem_basy_y->size = vsi->buf_sz_y_bs +
337 vsi->buf_len_sz_y;
338
339 if (mtk_vcodec_mem_alloc(inst->ctx, mem_basy_y)) {
340 mtk_vcodec_err(inst, "Cannot allocate sf_ref_buf y_buf");
341 return -1;
342 }
343
344 mem_basy_c = &vsi->sf_ref_fb[idx].fb.base_c;
345 mem_basy_c->size = vsi->buf_sz_c_bs +
346 vsi->buf_len_sz_c;
347
348 if (mtk_vcodec_mem_alloc(inst->ctx, mem_basy_c)) {
349 mtk_vcodec_err(inst, "Cannot allocate sf_ref_fb c_buf");
350 return -1;
351 }
352 vsi->sf_ref_fb[idx].used = 0;
353
354 return idx;
355}
356
357static bool vp9_alloc_work_buf(struct vdec_vp9_inst *inst)
358{
359 struct vdec_vp9_vsi *vsi = inst->vsi;
360 int result;
361 struct mtk_vcodec_mem *mem;
362
363 unsigned int max_pic_w;
364 unsigned int max_pic_h;
365
366
367 if (!(inst->ctx->dev->dec_capability &
368 VCODEC_CAPABILITY_4K_DISABLED)) {
369 max_pic_w = VCODEC_DEC_4K_CODED_WIDTH;
370 max_pic_h = VCODEC_DEC_4K_CODED_HEIGHT;
371 } else {
372 max_pic_w = MTK_VDEC_MAX_W;
373 max_pic_h = MTK_VDEC_MAX_H;
374 }
375
376 if ((vsi->pic_w > max_pic_w) ||
377 (vsi->pic_h > max_pic_h)) {
378 mtk_vcodec_err(inst, "Invalid w/h %d/%d",
379 vsi->pic_w, vsi->pic_h);
380 return false;
381 }
382
383 mtk_vcodec_debug(inst, "BUF CHG(%d): w/h/sb_w/sb_h=%d/%d/%d/%d",
384 vsi->resolution_changed,
385 vsi->pic_w,
386 vsi->pic_h,
387 vsi->buf_w,
388 vsi->buf_h);
389
390 mem = &inst->mv_buf;
391
392 if (mem->va)
393 mtk_vcodec_mem_free(inst->ctx, mem);
394
395 mem->size = ((vsi->buf_w / 64) *
396 (vsi->buf_h / 64) + 2) * 36 * 16;
397
398 result = mtk_vcodec_mem_alloc(inst->ctx, mem);
399 if (result) {
400 mem->size = 0;
401 mtk_vcodec_err(inst, "Cannot allocate mv_buf");
402 return false;
403 }
404 /* Set the va again */
405 vsi->mv_buf.va = (unsigned long)mem->va;
406 vsi->mv_buf.pa = (unsigned long)mem->dma_addr;
407 vsi->mv_buf.sz = (unsigned int)mem->size;
408
409 vp9_free_all_sf_ref_fb(inst);
410 vsi->sf_next_ref_fb_idx = vp9_get_sf_ref_fb(inst);
411
412 return true;
413}
414
415static bool vp9_add_to_fb_disp_list(struct vdec_vp9_inst *inst,
416 struct vdec_fb *fb)
417{
418 struct vdec_fb_node *node;
419
420 if (!fb) {
421 mtk_vcodec_err(inst, "fb == NULL");
422 return false;
423 }
424
425 node = list_first_entry_or_null(&inst->available_fb_node_list,
426 struct vdec_fb_node, list);
427 if (node) {
428 node->fb = fb;
429 list_move_tail(&node->list, &inst->fb_disp_list);
430 } else {
431 mtk_vcodec_err(inst, "No available fb node");
432 return false;
433 }
434
435 return true;
436}
437
438/* If any buffer updating is signaled it should be done here. */
439static void vp9_swap_frm_bufs(struct vdec_vp9_inst *inst)
440{
441 struct vdec_vp9_vsi *vsi = inst->vsi;
442 struct vp9_fb_info *frm_to_show;
443 int ref_index = 0, mask;
444
445 for (mask = vsi->refresh_frm_flags; mask; mask >>= 1) {
446 if (mask & 1)
447 vp9_ref_cnt_fb(inst, &vsi->ref_frm_map[ref_index],
448 vsi->new_fb_idx);
449 ++ref_index;
450 }
451
452 frm_to_show = &vsi->frm_bufs[vsi->new_fb_idx].buf;
453 vsi->frm_bufs[vsi->new_fb_idx].ref_cnt--;
454
455 if (frm_to_show->fb != inst->cur_fb) {
456 /* This frame is show exist frame and no decode output
457 * copy frame data from frm_to_show to current CAPTURE
458 * buffer
459 */
460 if ((frm_to_show->fb != NULL) &&
461 (inst->cur_fb->base_y.size >=
462 frm_to_show->fb->base_y.size)) {
463 memcpy((void *)inst->cur_fb->base_y.va,
464 (void *)frm_to_show->fb->base_y.va,
465 vsi->buf_w *
466 vsi->buf_h);
467 memcpy((void *)inst->cur_fb->base_c.va,
468 (void *)frm_to_show->fb->base_c.va,
469 vsi->buf_w *
470 vsi->buf_h / 2);
471 } else {
472 /* After resolution change case, current CAPTURE buffer
473 * may have less buffer size than frm_to_show buffer
474 * size
475 */
476 if (frm_to_show->fb != NULL)
477 mtk_vcodec_err(inst,
478 "inst->cur_fb->base_y.size=%zu, frm_to_show->fb.base_y.size=%zu",
479 inst->cur_fb->base_y.size,
480 frm_to_show->fb->base_y.size);
481 }
482 if (!vp9_is_sf_ref_fb(inst, inst->cur_fb)) {
483 if (vsi->show_frame)
484 vp9_add_to_fb_disp_list(inst, inst->cur_fb);
485 }
486 } else {
487 if (!vp9_is_sf_ref_fb(inst, inst->cur_fb)) {
488 if (vsi->show_frame)
489 vp9_add_to_fb_disp_list(inst, frm_to_show->fb);
490 }
491 }
492
493 /* when ref_cnt ==0, move this fb to fb_free_list. v4l2 driver will
494 * clean fb_free_list
495 */
496 if (vsi->frm_bufs[vsi->new_fb_idx].ref_cnt == 0) {
497 if (!vp9_is_sf_ref_fb(
498 inst, vsi->frm_bufs[vsi->new_fb_idx].buf.fb)) {
499 struct vdec_fb *fb;
500
501 fb = vp9_rm_from_fb_use_list(inst,
502 vsi->frm_bufs[vsi->new_fb_idx].buf.fb->base_y.va);
503
504 vp9_add_to_fb_free_list(inst, fb);
505 } else {
506 vp9_free_sf_ref_fb(
507 vsi->frm_bufs[vsi->new_fb_idx].buf.fb);
508 }
509 }
510
511 /* if this super frame and it is not last sub-frame, get next fb for
512 * sub-frame decode
513 */
514 if (vsi->sf_frm_cnt > 0 && vsi->sf_frm_idx != vsi->sf_frm_cnt - 1)
515 vsi->sf_next_ref_fb_idx = vp9_get_sf_ref_fb(inst);
516}
517
518static bool vp9_wait_dec_end(struct vdec_vp9_inst *inst)
519{
520 struct mtk_vcodec_ctx *ctx = inst->ctx;
521
522 mtk_vcodec_wait_for_done_ctx(inst->ctx,
523 MTK_INST_IRQ_RECEIVED,
524 WAIT_INTR_TIMEOUT_MS);
525
526 if (ctx->irq_status & MTK_VDEC_IRQ_STATUS_DEC_SUCCESS)
527 return true;
528 else
529 return false;
530}
531
532static struct vdec_vp9_inst *vp9_alloc_inst(struct mtk_vcodec_ctx *ctx)
533{
534 int result;
535 struct mtk_vcodec_mem mem;
536 struct vdec_vp9_inst *inst;
537
538 memset(&mem, 0, sizeof(mem));
539 mem.size = sizeof(struct vdec_vp9_inst);
540 result = mtk_vcodec_mem_alloc(ctx, &mem);
541 if (result)
542 return NULL;
543
544 inst = mem.va;
545 inst->mem = mem;
546
547 return inst;
548}
549
550static void vp9_free_inst(struct vdec_vp9_inst *inst)
551{
552 struct mtk_vcodec_mem mem;
553
554 mem = inst->mem;
555 if (mem.va)
556 mtk_vcodec_mem_free(inst->ctx, &mem);
557}
558
559static bool vp9_decode_end_proc(struct vdec_vp9_inst *inst)
560{
561 struct vdec_vp9_vsi *vsi = inst->vsi;
562 bool ret = false;
563
564 if (!vsi->show_existing_frame) {
565 ret = vp9_wait_dec_end(inst);
566 if (!ret) {
567 mtk_vcodec_err(inst, "Decode failed, Decode Timeout @[%d]",
568 vsi->frm_num);
569 return false;
570 }
571
572 if (vpu_dec_end(&inst->vpu)) {
573 mtk_vcodec_err(inst, "vp9_dec_vpu_end failed");
574 return false;
575 }
576 mtk_vcodec_debug(inst, "Decode Ok @%d (%d/%d)", vsi->frm_num,
577 vsi->pic_w, vsi->pic_h);
578 } else {
579 mtk_vcodec_debug(inst, "Decode Ok @%d (show_existing_frame)",
580 vsi->frm_num);
581 }
582
583 vp9_swap_frm_bufs(inst);
584 vsi->frm_num++;
585 return true;
586}
587
588static bool vp9_is_last_sub_frm(struct vdec_vp9_inst *inst)
589{
590 struct vdec_vp9_vsi *vsi = inst->vsi;
591
592 if (vsi->sf_frm_cnt <= 0 || vsi->sf_frm_idx == vsi->sf_frm_cnt)
593 return true;
594
595 return false;
596}
597
598static struct vdec_fb *vp9_rm_from_fb_disp_list(struct vdec_vp9_inst *inst)
599{
600 struct vdec_fb_node *node;
601 struct vdec_fb *fb = NULL;
602
603 node = list_first_entry_or_null(&inst->fb_disp_list,
604 struct vdec_fb_node, list);
605 if (node) {
606 fb = (struct vdec_fb *)node->fb;
607 fb->status |= FB_ST_DISPLAY;
608 list_move_tail(&node->list, &inst->available_fb_node_list);
609 mtk_vcodec_debug(inst, "[FB] get disp fb %p st=%d",
610 node->fb, fb->status);
611 } else
612 mtk_vcodec_debug(inst, "[FB] there is no disp fb");
613
614 return fb;
615}
616
617static bool vp9_add_to_fb_use_list(struct vdec_vp9_inst *inst,
618 struct vdec_fb *fb)
619{
620 struct vdec_fb_node *node;
621
622 if (!fb) {
623 mtk_vcodec_debug(inst, "fb == NULL");
624 return false;
625 }
626
627 node = list_first_entry_or_null(&inst->available_fb_node_list,
628 struct vdec_fb_node, list);
629 if (node) {
630 node->fb = fb;
631 list_move_tail(&node->list, &inst->fb_use_list);
632 } else {
633 mtk_vcodec_err(inst, "No free fb node");
634 return false;
635 }
636 return true;
637}
638
639static void vp9_reset(struct vdec_vp9_inst *inst)
640{
641 struct vdec_fb_node *node, *tmp;
642
643 list_for_each_entry_safe(node, tmp, &inst->fb_use_list, list)
644 list_move_tail(&node->list, &inst->fb_free_list);
645
646 vp9_free_all_sf_ref_fb(inst);
647 inst->vsi->sf_next_ref_fb_idx = vp9_get_sf_ref_fb(inst);
648
649 if (vpu_dec_reset(&inst->vpu))
650 mtk_vcodec_err(inst, "vp9_dec_vpu_reset failed");
651
652 /* Set the va again, since vpu_dec_reset will clear mv_buf in vpu */
653 inst->vsi->mv_buf.va = (unsigned long)inst->mv_buf.va;
654 inst->vsi->mv_buf.pa = (unsigned long)inst->mv_buf.dma_addr;
655 inst->vsi->mv_buf.sz = (unsigned long)inst->mv_buf.size;
656}
657
658static void init_all_fb_lists(struct vdec_vp9_inst *inst)
659{
660 int i;
661
662 INIT_LIST_HEAD(&inst->available_fb_node_list);
663 INIT_LIST_HEAD(&inst->fb_use_list);
664 INIT_LIST_HEAD(&inst->fb_free_list);
665 INIT_LIST_HEAD(&inst->fb_disp_list);
666
667 for (i = 0; i < ARRAY_SIZE(inst->dec_fb); i++) {
668 INIT_LIST_HEAD(&inst->dec_fb[i].list);
669 inst->dec_fb[i].fb = NULL;
670 list_add_tail(&inst->dec_fb[i].list,
671 &inst->available_fb_node_list);
672 }
673}
674
675static void get_pic_info(struct vdec_vp9_inst *inst, struct vdec_pic_info *pic)
676{
677 pic->y_bs_sz = inst->vsi->buf_sz_y_bs;
678 pic->c_bs_sz = inst->vsi->buf_sz_c_bs;
679 pic->y_len_sz = inst->vsi->buf_len_sz_y;
680 pic->c_len_sz = inst->vsi->buf_len_sz_c;
681
682 pic->pic_w = inst->vsi->pic_w;
683 pic->pic_h = inst->vsi->pic_h;
684 pic->buf_w = inst->vsi->buf_w;
685 pic->buf_h = inst->vsi->buf_h;
686
687 mtk_vcodec_debug(inst, "pic(%d, %d), buf(%d, %d)",
688 pic->pic_w, pic->pic_h, pic->buf_w, pic->buf_h);
689 mtk_vcodec_debug(inst, "Y(%d, %d), C(%d, %d)", pic->y_bs_sz,
690 pic->y_len_sz, pic->c_bs_sz, pic->c_len_sz);
691}
692
693static void get_disp_fb(struct vdec_vp9_inst *inst, struct vdec_fb **out_fb)
694{
695
696 *out_fb = vp9_rm_from_fb_disp_list(inst);
697 if (*out_fb)
698 (*out_fb)->status |= FB_ST_DISPLAY;
699}
700
701static void get_free_fb(struct vdec_vp9_inst *inst, struct vdec_fb **out_fb)
702{
703 struct vdec_fb_node *node;
704 struct vdec_fb *fb = NULL;
705
706 node = list_first_entry_or_null(&inst->fb_free_list,
707 struct vdec_fb_node, list);
708 if (node) {
709 list_move_tail(&node->list, &inst->available_fb_node_list);
710 fb = (struct vdec_fb *)node->fb;
711 fb->status |= FB_ST_FREE;
712 mtk_vcodec_debug(inst, "[FB] get free fb %p st=%d",
713 node->fb, fb->status);
714 } else {
715 mtk_vcodec_debug(inst, "[FB] there is no free fb");
716 }
717
718 *out_fb = fb;
719}
720
721static void vdec_vp9_deinit(unsigned long h_vdec)
722{
723 struct vdec_vp9_inst *inst = (struct vdec_vp9_inst *)h_vdec;
724 struct mtk_vcodec_mem *mem;
725 int ret = 0;
726
727 ret = vpu_dec_deinit(&inst->vpu);
728 if (ret)
729 mtk_vcodec_err(inst, "vpu_dec_deinit failed");
730
731 mem = &inst->mv_buf;
732 if (mem->va)
733 mtk_vcodec_mem_free(inst->ctx, mem);
734
735 vp9_free_all_sf_ref_fb(inst);
736 vp9_free_inst(inst);
737}
738
739static int vdec_vp9_init(struct mtk_vcodec_ctx *ctx, unsigned long *h_vdec)
740{
741 struct vdec_vp9_inst *inst;
742
743 inst = vp9_alloc_inst(ctx);
744 if (!inst)
745 return -ENOMEM;
746
747 inst->total_frm_cnt = 0;
748 inst->ctx = ctx;
749
750 inst->vpu.id = IPI_VDEC_VP9;
751 inst->vpu.dev = ctx->dev->vpu_plat_dev;
752 inst->vpu.ctx = ctx;
753 inst->vpu.handler = vpu_dec_ipi_handler;
754
755 if (vpu_dec_init(&inst->vpu)) {
756 mtk_vcodec_err(inst, "vp9_dec_vpu_init failed");
757 goto err_deinit_inst;
758 }
759
760 inst->vsi = (struct vdec_vp9_vsi *)inst->vpu.vsi;
761 init_all_fb_lists(inst);
762
763 (*h_vdec) = (unsigned long)inst;
764 return 0;
765
766err_deinit_inst:
767 vp9_free_inst(inst);
768
769 return -EINVAL;
770}
771
772static int vdec_vp9_decode(unsigned long h_vdec, struct mtk_vcodec_mem *bs,
773 struct vdec_fb *fb, bool *res_chg)
774{
775 int ret = 0;
776 struct vdec_vp9_inst *inst = (struct vdec_vp9_inst *)h_vdec;
777 struct vdec_vp9_vsi *vsi = inst->vsi;
778 u32 data[3];
779 int i;
780
781 *res_chg = false;
782
783 if ((bs == NULL) && (fb == NULL)) {
784 mtk_vcodec_debug(inst, "[EOS]");
785 vp9_reset(inst);
786 return ret;
787 }
788
789 if (bs == NULL) {
790 mtk_vcodec_err(inst, "bs == NULL");
791 return -EINVAL;
792 }
793
794 mtk_vcodec_debug(inst, "Input BS Size = %zu", bs->size);
795
796 while (1) {
797 struct vdec_fb *cur_fb = NULL;
798
799 data[0] = *((unsigned int *)bs->va);
800 data[1] = *((unsigned int *)(bs->va + 4));
801 data[2] = *((unsigned int *)(bs->va + 8));
802
803 vsi->bs = *bs;
804
805 if (fb)
806 vsi->fb = *fb;
807
808 if (!vsi->sf_init) {
809 unsigned int sf_bs_sz;
810 unsigned int sf_bs_off;
811 unsigned char *sf_bs_src;
812 unsigned char *sf_bs_dst;
813
814 sf_bs_sz = bs->size > VP9_SUPER_FRAME_BS_SZ ?
815 VP9_SUPER_FRAME_BS_SZ : bs->size;
816 sf_bs_off = VP9_SUPER_FRAME_BS_SZ - sf_bs_sz;
817 sf_bs_src = bs->va + bs->size - sf_bs_sz;
818 sf_bs_dst = vsi->sf_bs_buf + sf_bs_off;
819 memcpy(sf_bs_dst, sf_bs_src, sf_bs_sz);
820 } else {
821 if ((vsi->sf_frm_cnt > 0) &&
822 (vsi->sf_frm_idx < vsi->sf_frm_cnt)) {
823 unsigned int idx = vsi->sf_frm_idx;
824
825 memcpy((void *)bs->va,
826 (void *)(bs->va +
827 vsi->sf_frm_offset[idx]),
828 vsi->sf_frm_sz[idx]);
829 }
830 }
831 ret = vpu_dec_start(&inst->vpu, data, 3);
832 if (ret) {
833 mtk_vcodec_err(inst, "vpu_dec_start failed");
834 goto DECODE_ERROR;
835 }
836
837 if (vsi->resolution_changed) {
838 if (!vp9_alloc_work_buf(inst)) {
839 ret = -EINVAL;
840 goto DECODE_ERROR;
841 }
842 }
843
844 if (vsi->sf_frm_cnt > 0) {
845 cur_fb = &vsi->sf_ref_fb[vsi->sf_next_ref_fb_idx].fb;
846
847 if (vsi->sf_frm_idx < vsi->sf_frm_cnt)
848 inst->cur_fb = cur_fb;
849 else
850 inst->cur_fb = fb;
851 } else {
852 inst->cur_fb = fb;
853 }
854
855 vsi->frm_bufs[vsi->new_fb_idx].buf.fb = inst->cur_fb;
856 if (!vp9_is_sf_ref_fb(inst, inst->cur_fb))
857 vp9_add_to_fb_use_list(inst, inst->cur_fb);
858
859 mtk_vcodec_debug(inst, "[#pic %d]", vsi->frm_num);
860
861 if (vsi->show_existing_frame)
862 mtk_vcodec_debug(inst,
863 "drv->new_fb_idx=%d, drv->frm_to_show_idx=%d",
864 vsi->new_fb_idx, vsi->frm_to_show_idx);
865
866 if (vsi->show_existing_frame && (vsi->frm_to_show_idx <
867 VP9_MAX_FRM_BUF_NUM)) {
868 mtk_vcodec_err(inst,
869 "Skip Decode drv->new_fb_idx=%d, drv->frm_to_show_idx=%d",
870 vsi->new_fb_idx, vsi->frm_to_show_idx);
871
872 vp9_ref_cnt_fb(inst, &vsi->new_fb_idx,
873 vsi->frm_to_show_idx);
874 ret = -EINVAL;
875 goto DECODE_ERROR;
876 }
877
878 /* VPU assign the buffer pointer in its address space,
879 * reassign here
880 */
881 for (i = 0; i < ARRAY_SIZE(vsi->frm_refs); i++) {
882 unsigned int idx = vsi->frm_refs[i].idx;
883
884 vsi->frm_refs[i].buf = &vsi->frm_bufs[idx].buf;
885 }
886
887 if (vsi->resolution_changed) {
888 *res_chg = true;
889 mtk_vcodec_debug(inst, "VDEC_ST_RESOLUTION_CHANGED");
890
891 ret = 0;
892 goto DECODE_ERROR;
893 }
894
895 if (vp9_decode_end_proc(inst) != true) {
896 mtk_vcodec_err(inst, "vp9_decode_end_proc");
897 ret = -EINVAL;
898 goto DECODE_ERROR;
899 }
900
901 if (vp9_is_last_sub_frm(inst))
902 break;
903
904 }
905 inst->total_frm_cnt++;
906
907DECODE_ERROR:
908 if (ret < 0)
909 vp9_add_to_fb_free_list(inst, fb);
910
911 return ret;
912}
913
914static void get_crop_info(struct vdec_vp9_inst *inst, struct v4l2_rect *cr)
915{
916 cr->left = 0;
917 cr->top = 0;
918 cr->width = inst->vsi->pic_w;
919 cr->height = inst->vsi->pic_h;
920 mtk_vcodec_debug(inst, "get crop info l=%d, t=%d, w=%d, h=%d\n",
921 cr->left, cr->top, cr->width, cr->height);
922}
923
924static int vdec_vp9_get_param(unsigned long h_vdec,
925 enum vdec_get_param_type type, void *out)
926{
927 struct vdec_vp9_inst *inst = (struct vdec_vp9_inst *)h_vdec;
928 int ret = 0;
929
930 switch (type) {
931 case GET_PARAM_DISP_FRAME_BUFFER:
932 get_disp_fb(inst, out);
933 break;
934 case GET_PARAM_FREE_FRAME_BUFFER:
935 get_free_fb(inst, out);
936 break;
937 case GET_PARAM_PIC_INFO:
938 get_pic_info(inst, out);
939 break;
940 case GET_PARAM_DPB_SIZE:
941 *((unsigned int *)out) = MAX_VP9_DPB_SIZE;
942 break;
943 case GET_PARAM_CROP_INFO:
944 get_crop_info(inst, out);
945 break;
946 default:
947 mtk_vcodec_err(inst, "not supported param type %d", type);
948 ret = -EINVAL;
949 break;
950 }
951
952 return ret;
953}
954
955static struct vdec_common_if vdec_vp9_if = {
956 vdec_vp9_init,
957 vdec_vp9_decode,
958 vdec_vp9_get_param,
959 vdec_vp9_deinit,
960};
961
962struct vdec_common_if *get_vp9_dec_comm_if(void);
963
964struct vdec_common_if *get_vp9_dec_comm_if(void)
965{
966 return &vdec_vp9_if;
967}
diff --git a/drivers/media/platform/mtk-vcodec/vdec_drv_base.h b/drivers/media/platform/mtk-vcodec/vdec_drv_base.h
new file mode 100644
index 000000000000..7e4c1a92bbd8
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vdec_drv_base.h
@@ -0,0 +1,56 @@
1/*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: PC Chen <pc.chen@mediatek.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 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#ifndef _VDEC_DRV_BASE_
16#define _VDEC_DRV_BASE_
17
18#include "mtk_vcodec_drv.h"
19
20#include "vdec_drv_if.h"
21
22struct vdec_common_if {
23 /**
24 * (*init)() - initialize decode driver
25 * @ctx : [in] mtk v4l2 context
26 * @h_vdec : [out] driver handle
27 */
28 int (*init)(struct mtk_vcodec_ctx *ctx, unsigned long *h_vdec);
29
30 /**
31 * (*decode)() - trigger decode
32 * @h_vdec : [in] driver handle
33 * @bs : [in] input bitstream
34 * @fb : [in] frame buffer to store decoded frame
35 * @res_chg : [out] resolution change happen
36 */
37 int (*decode)(unsigned long h_vdec, struct mtk_vcodec_mem *bs,
38 struct vdec_fb *fb, bool *res_chg);
39
40 /**
41 * (*get_param)() - get driver's parameter
42 * @h_vdec : [in] driver handle
43 * @type : [in] input parameter type
44 * @out : [out] buffer to store query result
45 */
46 int (*get_param)(unsigned long h_vdec, enum vdec_get_param_type type,
47 void *out);
48
49 /**
50 * (*deinit)() - deinitialize driver.
51 * @h_vdec : [in] driver handle to be deinit
52 */
53 void (*deinit)(unsigned long h_vdec);
54};
55
56#endif
diff --git a/drivers/media/platform/mtk-vcodec/vdec_drv_if.c b/drivers/media/platform/mtk-vcodec/vdec_drv_if.c
new file mode 100644
index 000000000000..5ffc468dd910
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vdec_drv_if.c
@@ -0,0 +1,122 @@
1/*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: PC Chen <pc.chen@mediatek.com>
4 * Tiffany Lin <tiffany.lin@mediatek.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 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/interrupt.h>
17#include <linux/kernel.h>
18#include <linux/slab.h>
19
20#include "vdec_drv_if.h"
21#include "mtk_vcodec_dec.h"
22#include "vdec_drv_base.h"
23#include "mtk_vcodec_dec_pm.h"
24#include "mtk_vpu.h"
25
26const struct vdec_common_if *get_h264_dec_comm_if(void);
27const struct vdec_common_if *get_vp8_dec_comm_if(void);
28const struct vdec_common_if *get_vp9_dec_comm_if(void);
29
30int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
31{
32 int ret = 0;
33
34 switch (fourcc) {
35 case V4L2_PIX_FMT_H264:
36 ctx->dec_if = get_h264_dec_comm_if();
37 break;
38 case V4L2_PIX_FMT_VP8:
39 ctx->dec_if = get_vp8_dec_comm_if();
40 break;
41 case V4L2_PIX_FMT_VP9:
42 ctx->dec_if = get_vp9_dec_comm_if();
43 break;
44 default:
45 return -EINVAL;
46 }
47
48 mtk_vdec_lock(ctx);
49 mtk_vcodec_dec_clock_on(&ctx->dev->pm);
50 ret = ctx->dec_if->init(ctx, &ctx->drv_handle);
51 mtk_vcodec_dec_clock_off(&ctx->dev->pm);
52 mtk_vdec_unlock(ctx);
53
54 return ret;
55}
56
57int vdec_if_decode(struct mtk_vcodec_ctx *ctx, struct mtk_vcodec_mem *bs,
58 struct vdec_fb *fb, bool *res_chg)
59{
60 int ret = 0;
61
62 if (bs) {
63 if ((bs->dma_addr & 63) != 0) {
64 mtk_v4l2_err("bs dma_addr should 64 byte align");
65 return -EINVAL;
66 }
67 }
68
69 if (fb) {
70 if (((fb->base_y.dma_addr & 511) != 0) ||
71 ((fb->base_c.dma_addr & 511) != 0)) {
72 mtk_v4l2_err("frame buffer dma_addr should 512 byte align");
73 return -EINVAL;
74 }
75 }
76
77 if (ctx->drv_handle == 0)
78 return -EIO;
79
80 mtk_vdec_lock(ctx);
81
82 mtk_vcodec_set_curr_ctx(ctx->dev, ctx);
83 mtk_vcodec_dec_clock_on(&ctx->dev->pm);
84 enable_irq(ctx->dev->dec_irq);
85 ret = ctx->dec_if->decode(ctx->drv_handle, bs, fb, res_chg);
86 disable_irq(ctx->dev->dec_irq);
87 mtk_vcodec_dec_clock_off(&ctx->dev->pm);
88 mtk_vcodec_set_curr_ctx(ctx->dev, NULL);
89
90 mtk_vdec_unlock(ctx);
91
92 return ret;
93}
94
95int vdec_if_get_param(struct mtk_vcodec_ctx *ctx, enum vdec_get_param_type type,
96 void *out)
97{
98 int ret = 0;
99
100 if (ctx->drv_handle == 0)
101 return -EIO;
102
103 mtk_vdec_lock(ctx);
104 ret = ctx->dec_if->get_param(ctx->drv_handle, type, out);
105 mtk_vdec_unlock(ctx);
106
107 return ret;
108}
109
110void vdec_if_deinit(struct mtk_vcodec_ctx *ctx)
111{
112 if (ctx->drv_handle == 0)
113 return;
114
115 mtk_vdec_lock(ctx);
116 mtk_vcodec_dec_clock_on(&ctx->dev->pm);
117 ctx->dec_if->deinit(ctx->drv_handle);
118 mtk_vcodec_dec_clock_off(&ctx->dev->pm);
119 mtk_vdec_unlock(ctx);
120
121 ctx->drv_handle = 0;
122}
diff --git a/drivers/media/platform/mtk-vcodec/vdec_drv_if.h b/drivers/media/platform/mtk-vcodec/vdec_drv_if.h
new file mode 100644
index 000000000000..db6b5205ffb1
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vdec_drv_if.h
@@ -0,0 +1,101 @@
1/*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: PC Chen <pc.chen@mediatek.com>
4 * Tiffany Lin <tiffany.lin@mediatek.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 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef _VDEC_DRV_IF_H_
17#define _VDEC_DRV_IF_H_
18
19#include "mtk_vcodec_drv.h"
20#include "mtk_vcodec_dec.h"
21#include "mtk_vcodec_util.h"
22
23
24/**
25 * struct vdec_fb_status - decoder frame buffer status
26 * @FB_ST_NORMAL : initial state
27 * @FB_ST_DISPLAY : frmae buffer is ready to be displayed
28 * @FB_ST_FREE : frame buffer is not used by decoder any more
29 */
30enum vdec_fb_status {
31 FB_ST_NORMAL = 0,
32 FB_ST_DISPLAY = (1 << 0),
33 FB_ST_FREE = (1 << 1)
34};
35
36/* For GET_PARAM_DISP_FRAME_BUFFER and GET_PARAM_FREE_FRAME_BUFFER,
37 * the caller does not own the returned buffer. The buffer will not be
38 * released before vdec_if_deinit.
39 * GET_PARAM_DISP_FRAME_BUFFER : get next displayable frame buffer,
40 * struct vdec_fb**
41 * GET_PARAM_FREE_FRAME_BUFFER : get non-referenced framebuffer, vdec_fb**
42 * GET_PARAM_PIC_INFO : get picture info, struct vdec_pic_info*
43 * GET_PARAM_CROP_INFO : get crop info, struct v4l2_crop*
44 * GET_PARAM_DPB_SIZE : get dpb size, unsigned int*
45 */
46enum vdec_get_param_type {
47 GET_PARAM_DISP_FRAME_BUFFER,
48 GET_PARAM_FREE_FRAME_BUFFER,
49 GET_PARAM_PIC_INFO,
50 GET_PARAM_CROP_INFO,
51 GET_PARAM_DPB_SIZE
52};
53
54/**
55 * struct vdec_fb_node - decoder frame buffer node
56 * @list : list to hold this node
57 * @fb : point to frame buffer (vdec_fb), fb could point to frame buffer and
58 * working buffer this is for maintain buffers in different state
59 */
60struct vdec_fb_node {
61 struct list_head list;
62 struct vdec_fb *fb;
63};
64
65/**
66 * vdec_if_init() - initialize decode driver
67 * @ctx : [in] v4l2 context
68 * @fourcc : [in] video format fourcc, V4L2_PIX_FMT_H264/VP8/VP9..
69 */
70int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc);
71
72/**
73 * vdec_if_deinit() - deinitialize decode driver
74 * @ctx : [in] v4l2 context
75 *
76 */
77void vdec_if_deinit(struct mtk_vcodec_ctx *ctx);
78
79/**
80 * vdec_if_decode() - trigger decode
81 * @ctx : [in] v4l2 context
82 * @bs : [in] input bitstream
83 * @fb : [in] frame buffer to store decoded frame, when null menas parse
84 * header only
85 * @res_chg : [out] resolution change happens if current bs have different
86 * picture width/height
87 * Note: To flush the decoder when reaching EOF, set input bitstream as NULL.
88 */
89int vdec_if_decode(struct mtk_vcodec_ctx *ctx, struct mtk_vcodec_mem *bs,
90 struct vdec_fb *fb, bool *res_chg);
91
92/**
93 * vdec_if_get_param() - get driver's parameter
94 * @ctx : [in] v4l2 context
95 * @type : [in] input parameter type
96 * @out : [out] buffer to store query result
97 */
98int vdec_if_get_param(struct mtk_vcodec_ctx *ctx, enum vdec_get_param_type type,
99 void *out);
100
101#endif
diff --git a/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h b/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
new file mode 100644
index 000000000000..5a8a629f4ac9
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
@@ -0,0 +1,103 @@
1/*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: PC Chen <pc.chen@mediatek.com>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef _VDEC_IPI_MSG_H_
17#define _VDEC_IPI_MSG_H_
18
19/**
20 * enum vdec_ipi_msgid - message id between AP and VPU
21 * @AP_IPIMSG_XXX : AP to VPU cmd message id
22 * @VPU_IPIMSG_XXX_ACK : VPU ack AP cmd message id
23 */
24enum vdec_ipi_msgid {
25 AP_IPIMSG_DEC_INIT = 0xA000,
26 AP_IPIMSG_DEC_START = 0xA001,
27 AP_IPIMSG_DEC_END = 0xA002,
28 AP_IPIMSG_DEC_DEINIT = 0xA003,
29 AP_IPIMSG_DEC_RESET = 0xA004,
30
31 VPU_IPIMSG_DEC_INIT_ACK = 0xB000,
32 VPU_IPIMSG_DEC_START_ACK = 0xB001,
33 VPU_IPIMSG_DEC_END_ACK = 0xB002,
34 VPU_IPIMSG_DEC_DEINIT_ACK = 0xB003,
35 VPU_IPIMSG_DEC_RESET_ACK = 0xB004,
36};
37
38/**
39 * struct vdec_ap_ipi_cmd - generic AP to VPU ipi command format
40 * @msg_id : vdec_ipi_msgid
41 * @vpu_inst_addr : VPU decoder instance address
42 */
43struct vdec_ap_ipi_cmd {
44 uint32_t msg_id;
45 uint32_t vpu_inst_addr;
46};
47
48/**
49 * struct vdec_vpu_ipi_ack - generic VPU to AP ipi command format
50 * @msg_id : vdec_ipi_msgid
51 * @status : VPU exeuction result
52 * @ap_inst_addr : AP video decoder instance address
53 */
54struct vdec_vpu_ipi_ack {
55 uint32_t msg_id;
56 int32_t status;
57 uint64_t ap_inst_addr;
58};
59
60/**
61 * struct vdec_ap_ipi_init - for AP_IPIMSG_DEC_INIT
62 * @msg_id : AP_IPIMSG_DEC_INIT
63 * @reserved : Reserved field
64 * @ap_inst_addr : AP video decoder instance address
65 */
66struct vdec_ap_ipi_init {
67 uint32_t msg_id;
68 uint32_t reserved;
69 uint64_t ap_inst_addr;
70};
71
72/**
73 * struct vdec_ap_ipi_dec_start - for AP_IPIMSG_DEC_START
74 * @msg_id : AP_IPIMSG_DEC_START
75 * @vpu_inst_addr : VPU decoder instance address
76 * @data : Header info
77 * H264 decoder [0]:buf_sz [1]:nal_start
78 * VP8 decoder [0]:width/height
79 * VP9 decoder [0]:profile, [1][2] width/height
80 * @reserved : Reserved field
81 */
82struct vdec_ap_ipi_dec_start {
83 uint32_t msg_id;
84 uint32_t vpu_inst_addr;
85 uint32_t data[3];
86 uint32_t reserved;
87};
88
89/**
90 * struct vdec_vpu_ipi_init_ack - for VPU_IPIMSG_DEC_INIT_ACK
91 * @msg_id : VPU_IPIMSG_DEC_INIT_ACK
92 * @status : VPU exeuction result
93 * @ap_inst_addr : AP vcodec_vpu_inst instance address
94 * @vpu_inst_addr : VPU decoder instance address
95 */
96struct vdec_vpu_ipi_init_ack {
97 uint32_t msg_id;
98 int32_t status;
99 uint64_t ap_inst_addr;
100 uint32_t vpu_inst_addr;
101};
102
103#endif
diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
new file mode 100644
index 000000000000..5a24c51aebb7
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
@@ -0,0 +1,170 @@
1/*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: PC Chen <pc.chen@mediatek.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 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#include "mtk_vcodec_drv.h"
16#include "mtk_vcodec_util.h"
17#include "vdec_ipi_msg.h"
18#include "vdec_vpu_if.h"
19
20static void handle_init_ack_msg(struct vdec_vpu_ipi_init_ack *msg)
21{
22 struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *)
23 (unsigned long)msg->ap_inst_addr;
24
25 mtk_vcodec_debug(vpu, "+ ap_inst_addr = 0x%llx", msg->ap_inst_addr);
26
27 /* mapping VPU address to kernel virtual address */
28 /* the content in vsi is initialized to 0 in VPU */
29 vpu->vsi = vpu_mapping_dm_addr(vpu->dev, msg->vpu_inst_addr);
30 vpu->inst_addr = msg->vpu_inst_addr;
31
32 mtk_vcodec_debug(vpu, "- vpu_inst_addr = 0x%x", vpu->inst_addr);
33}
34
35/*
36 * This function runs in interrupt context and it means there's an IPI MSG
37 * from VPU.
38 */
39void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv)
40{
41 struct vdec_vpu_ipi_ack *msg = data;
42 struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *)
43 (unsigned long)msg->ap_inst_addr;
44
45 mtk_vcodec_debug(vpu, "+ id=%X", msg->msg_id);
46
47 if (msg->status == 0) {
48 switch (msg->msg_id) {
49 case VPU_IPIMSG_DEC_INIT_ACK:
50 handle_init_ack_msg(data);
51 break;
52
53 case VPU_IPIMSG_DEC_START_ACK:
54 case VPU_IPIMSG_DEC_END_ACK:
55 case VPU_IPIMSG_DEC_DEINIT_ACK:
56 case VPU_IPIMSG_DEC_RESET_ACK:
57 break;
58
59 default:
60 mtk_vcodec_err(vpu, "invalid msg=%X", msg->msg_id);
61 break;
62 }
63 }
64
65 mtk_vcodec_debug(vpu, "- id=%X", msg->msg_id);
66 vpu->failure = msg->status;
67 vpu->signaled = 1;
68}
69
70static int vcodec_vpu_send_msg(struct vdec_vpu_inst *vpu, void *msg, int len)
71{
72 int err;
73 uint32_t msg_id = *(uint32_t *)msg;
74
75 mtk_vcodec_debug(vpu, "id=%X", msg_id);
76
77 vpu->failure = 0;
78 vpu->signaled = 0;
79
80 err = vpu_ipi_send(vpu->dev, vpu->id, msg, len);
81 if (err) {
82 mtk_vcodec_err(vpu, "send fail vpu_id=%d msg_id=%X status=%d",
83 vpu->id, msg_id, err);
84 return err;
85 }
86
87 return vpu->failure;
88}
89
90static int vcodec_send_ap_ipi(struct vdec_vpu_inst *vpu, unsigned int msg_id)
91{
92 struct vdec_ap_ipi_cmd msg;
93 int err = 0;
94
95 mtk_vcodec_debug(vpu, "+ id=%X", msg_id);
96
97 memset(&msg, 0, sizeof(msg));
98 msg.msg_id = msg_id;
99 msg.vpu_inst_addr = vpu->inst_addr;
100
101 err = vcodec_vpu_send_msg(vpu, &msg, sizeof(msg));
102 mtk_vcodec_debug(vpu, "- id=%X ret=%d", msg_id, err);
103 return err;
104}
105
106int vpu_dec_init(struct vdec_vpu_inst *vpu)
107{
108 struct vdec_ap_ipi_init msg;
109 int err;
110
111 mtk_vcodec_debug_enter(vpu);
112
113 init_waitqueue_head(&vpu->wq);
114
115 err = vpu_ipi_register(vpu->dev, vpu->id, vpu->handler, "vdec", NULL);
116 if (err != 0) {
117 mtk_vcodec_err(vpu, "vpu_ipi_register fail status=%d", err);
118 return err;
119 }
120
121 memset(&msg, 0, sizeof(msg));
122 msg.msg_id = AP_IPIMSG_DEC_INIT;
123 msg.ap_inst_addr = (unsigned long)vpu;
124
125 mtk_vcodec_debug(vpu, "vdec_inst=%p", vpu);
126
127 err = vcodec_vpu_send_msg(vpu, (void *)&msg, sizeof(msg));
128 mtk_vcodec_debug(vpu, "- ret=%d", err);
129 return err;
130}
131
132int vpu_dec_start(struct vdec_vpu_inst *vpu, uint32_t *data, unsigned int len)
133{
134 struct vdec_ap_ipi_dec_start msg;
135 int i;
136 int err = 0;
137
138 mtk_vcodec_debug_enter(vpu);
139
140 if (len > ARRAY_SIZE(msg.data)) {
141 mtk_vcodec_err(vpu, "invalid len = %d\n", len);
142 return -EINVAL;
143 }
144
145 memset(&msg, 0, sizeof(msg));
146 msg.msg_id = AP_IPIMSG_DEC_START;
147 msg.vpu_inst_addr = vpu->inst_addr;
148
149 for (i = 0; i < len; i++)
150 msg.data[i] = data[i];
151
152 err = vcodec_vpu_send_msg(vpu, (void *)&msg, sizeof(msg));
153 mtk_vcodec_debug(vpu, "- ret=%d", err);
154 return err;
155}
156
157int vpu_dec_end(struct vdec_vpu_inst *vpu)
158{
159 return vcodec_send_ap_ipi(vpu, AP_IPIMSG_DEC_END);
160}
161
162int vpu_dec_deinit(struct vdec_vpu_inst *vpu)
163{
164 return vcodec_send_ap_ipi(vpu, AP_IPIMSG_DEC_DEINIT);
165}
166
167int vpu_dec_reset(struct vdec_vpu_inst *vpu)
168{
169 return vcodec_send_ap_ipi(vpu, AP_IPIMSG_DEC_RESET);
170}
diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h
new file mode 100644
index 000000000000..0dc9ed01fffe
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h
@@ -0,0 +1,96 @@
1/*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: PC Chen <pc.chen@mediatek.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 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#ifndef _VDEC_VPU_IF_H_
16#define _VDEC_VPU_IF_H_
17
18#include "mtk_vpu.h"
19
20/**
21 * struct vdec_vpu_inst - VPU instance for video codec
22 * @ipi_id : ipi id for each decoder
23 * @vsi : driver structure allocated by VPU side and shared to AP side
24 * for control and info share
25 * @failure : VPU execution result status, 0: success, others: fail
26 * @inst_addr : VPU decoder instance address
27 * @signaled : 1 - Host has received ack message from VPU, 0 - not received
28 * @ctx : context for v4l2 layer integration
29 * @dev : platform device of VPU
30 * @wq : wait queue to wait VPU message ack
31 * @handler : ipi handler for each decoder
32 */
33struct vdec_vpu_inst {
34 enum ipi_id id;
35 void *vsi;
36 int32_t failure;
37 uint32_t inst_addr;
38 unsigned int signaled;
39 struct mtk_vcodec_ctx *ctx;
40 struct platform_device *dev;
41 wait_queue_head_t wq;
42 ipi_handler_t handler;
43};
44
45/**
46 * vpu_dec_init - init decoder instance and allocate required resource in VPU.
47 *
48 * @vpu: instance for vdec_vpu_inst
49 */
50int vpu_dec_init(struct vdec_vpu_inst *vpu);
51
52/**
53 * vpu_dec_start - start decoding, basically the function will be invoked once
54 * every frame.
55 *
56 * @vpu : instance for vdec_vpu_inst
57 * @data: meta data to pass bitstream info to VPU decoder
58 * @len : meta data length
59 */
60int vpu_dec_start(struct vdec_vpu_inst *vpu, uint32_t *data, unsigned int len);
61
62/**
63 * vpu_dec_end - end decoding, basically the function will be invoked once
64 * when HW decoding done interrupt received successfully. The
65 * decoder in VPU will continute to do referene frame management
66 * and check if there is a new decoded frame available to display.
67 *
68 * @vpu : instance for vdec_vpu_inst
69 */
70int vpu_dec_end(struct vdec_vpu_inst *vpu);
71
72/**
73 * vpu_dec_deinit - deinit decoder instance and resource freed in VPU.
74 *
75 * @vpu: instance for vdec_vpu_inst
76 */
77int vpu_dec_deinit(struct vdec_vpu_inst *vpu);
78
79/**
80 * vpu_dec_reset - reset decoder, use for flush decoder when end of stream or
81 * seek. Remainig non displayed frame will be pushed to display.
82 *
83 * @vpu: instance for vdec_vpu_inst
84 */
85int vpu_dec_reset(struct vdec_vpu_inst *vpu);
86
87/**
88 * vpu_dec_ipi_handler - Handler for VPU ipi message.
89 *
90 * @data: ipi message
91 * @len : length of ipi message
92 * @priv: callback private data which is passed by decoder when register.
93 */
94void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv);
95
96#endif
diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.c b/drivers/media/platform/mtk-vpu/mtk_vpu.c
index c9bf58c97878..463b69c934be 100644
--- a/drivers/media/platform/mtk-vpu/mtk_vpu.c
+++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
@@ -134,6 +134,8 @@ struct vpu_wdt {
134 * 134 *
135 * @signaled: the signal of vpu initialization completed 135 * @signaled: the signal of vpu initialization completed
136 * @fw_ver: VPU firmware version 136 * @fw_ver: VPU firmware version
137 * @dec_capability: decoder capability which is not used for now and
138 * the value is reserved for future use
137 * @enc_capability: encoder capability which is not used for now and 139 * @enc_capability: encoder capability which is not used for now and
138 * the value is reserved for future use 140 * the value is reserved for future use
139 * @wq: wait queue for VPU initialization status 141 * @wq: wait queue for VPU initialization status
@@ -141,6 +143,7 @@ struct vpu_wdt {
141struct vpu_run { 143struct vpu_run {
142 u32 signaled; 144 u32 signaled;
143 char fw_ver[VPU_FW_VER_LEN]; 145 char fw_ver[VPU_FW_VER_LEN];
146 unsigned int dec_capability;
144 unsigned int enc_capability; 147 unsigned int enc_capability;
145 wait_queue_head_t wq; 148 wait_queue_head_t wq;
146}; 149};
@@ -415,6 +418,14 @@ int vpu_wdt_reg_handler(struct platform_device *pdev,
415} 418}
416EXPORT_SYMBOL_GPL(vpu_wdt_reg_handler); 419EXPORT_SYMBOL_GPL(vpu_wdt_reg_handler);
417 420
421unsigned int vpu_get_vdec_hw_capa(struct platform_device *pdev)
422{
423 struct mtk_vpu *vpu = platform_get_drvdata(pdev);
424
425 return vpu->run.dec_capability;
426}
427EXPORT_SYMBOL_GPL(vpu_get_vdec_hw_capa);
428
418unsigned int vpu_get_venc_hw_capa(struct platform_device *pdev) 429unsigned int vpu_get_venc_hw_capa(struct platform_device *pdev)
419{ 430{
420 struct mtk_vpu *vpu = platform_get_drvdata(pdev); 431 struct mtk_vpu *vpu = platform_get_drvdata(pdev);
@@ -523,9 +534,9 @@ static int load_requested_vpu(struct mtk_vpu *vpu,
523 534
524int vpu_load_firmware(struct platform_device *pdev) 535int vpu_load_firmware(struct platform_device *pdev)
525{ 536{
526 struct mtk_vpu *vpu = platform_get_drvdata(pdev); 537 struct mtk_vpu *vpu;
527 struct device *dev = &pdev->dev; 538 struct device *dev = &pdev->dev;
528 struct vpu_run *run = &vpu->run; 539 struct vpu_run *run;
529 const struct firmware *vpu_fw = NULL; 540 const struct firmware *vpu_fw = NULL;
530 int ret; 541 int ret;
531 542
@@ -534,6 +545,9 @@ int vpu_load_firmware(struct platform_device *pdev)
534 return -EINVAL; 545 return -EINVAL;
535 } 546 }
536 547
548 vpu = platform_get_drvdata(pdev);
549 run = &vpu->run;
550
537 mutex_lock(&vpu->vpu_mutex); 551 mutex_lock(&vpu->vpu_mutex);
538 if (vpu->fw_loaded) { 552 if (vpu->fw_loaded) {
539 mutex_unlock(&vpu->vpu_mutex); 553 mutex_unlock(&vpu->vpu_mutex);
@@ -600,6 +614,7 @@ static void vpu_init_ipi_handler(void *data, unsigned int len, void *priv)
600 614
601 vpu->run.signaled = run->signaled; 615 vpu->run.signaled = run->signaled;
602 strncpy(vpu->run.fw_ver, run->fw_ver, VPU_FW_VER_LEN); 616 strncpy(vpu->run.fw_ver, run->fw_ver, VPU_FW_VER_LEN);
617 vpu->run.dec_capability = run->dec_capability;
603 vpu->run.enc_capability = run->enc_capability; 618 vpu->run.enc_capability = run->enc_capability;
604 wake_up_interruptible(&vpu->run.wq); 619 wake_up_interruptible(&vpu->run.wq);
605} 620}
@@ -674,7 +689,7 @@ static int vpu_alloc_ext_mem(struct mtk_vpu *vpu, u32 fw_type)
674 GFP_KERNEL); 689 GFP_KERNEL);
675 if (!vpu->extmem[fw_type].va) { 690 if (!vpu->extmem[fw_type].va) {
676 dev_err(dev, "Failed to allocate the extended program memory\n"); 691 dev_err(dev, "Failed to allocate the extended program memory\n");
677 return PTR_ERR(vpu->extmem[fw_type].va); 692 return -ENOMEM;
678 } 693 }
679 694
680 /* Disable extend0. Enable extend1 */ 695 /* Disable extend0. Enable extend1 */
diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.h b/drivers/media/platform/mtk-vpu/mtk_vpu.h
index 5ab37f04bdfd..aec0268be3d0 100644
--- a/drivers/media/platform/mtk-vpu/mtk_vpu.h
+++ b/drivers/media/platform/mtk-vpu/mtk_vpu.h
@@ -31,23 +31,41 @@ typedef void (*ipi_handler_t) (void *data,
31 * enum ipi_id - the id of inter-processor interrupt 31 * enum ipi_id - the id of inter-processor interrupt
32 * 32 *
33 * @IPI_VPU_INIT: The interrupt from vpu is to notfiy kernel 33 * @IPI_VPU_INIT: The interrupt from vpu is to notfiy kernel
34 VPU initialization completed. 34 * VPU initialization completed.
35 IPI_VPU_INIT is sent from VPU when firmware is 35 * IPI_VPU_INIT is sent from VPU when firmware is
36 loaded. AP doesn't need to send IPI_VPU_INIT 36 * loaded. AP doesn't need to send IPI_VPU_INIT
37 command to VPU. 37 * command to VPU.
38 For other IPI below, AP should send the request 38 * For other IPI below, AP should send the request
39 to VPU to trigger the interrupt. 39 * to VPU to trigger the interrupt.
40 * @IPI_VDEC_H264: The interrupt from vpu is to notify kernel to
41 * handle H264 vidoe decoder job, and vice versa.
42 * Decode output format is always MT21 no matter what
43 * the input format is.
44 * @IPI_VDEC_VP8: The interrupt from is to notify kernel to
45 * handle VP8 video decoder job, and vice versa.
46 * Decode output format is always MT21 no matter what
47 * the input format is.
48 * @IPI_VDEC_VP9: The interrupt from vpu is to notify kernel to
49 * handle VP9 video decoder job, and vice versa.
50 * Decode output format is always MT21 no matter what
51 * the input format is.
40 * @IPI_VENC_H264: The interrupt from vpu is to notify kernel to 52 * @IPI_VENC_H264: The interrupt from vpu is to notify kernel to
41 handle H264 video encoder job, and vice versa. 53 * handle H264 video encoder job, and vice versa.
42 * @IPI_VENC_VP8: The interrupt fro vpu is to notify kernel to 54 * @IPI_VENC_VP8: The interrupt fro vpu is to notify kernel to
43 handle VP8 video encoder job,, and vice versa. 55 * handle VP8 video encoder job,, and vice versa.
56 * @IPI_MDP: The interrupt from vpu is to notify kernel to
57 * handle MDP (Media Data Path) job, and vice versa.
44 * @IPI_MAX: The maximum IPI number 58 * @IPI_MAX: The maximum IPI number
45 */ 59 */
46 60
47enum ipi_id { 61enum ipi_id {
48 IPI_VPU_INIT = 0, 62 IPI_VPU_INIT = 0,
63 IPI_VDEC_H264,
64 IPI_VDEC_VP8,
65 IPI_VDEC_VP9,
49 IPI_VENC_H264, 66 IPI_VENC_H264,
50 IPI_VENC_VP8, 67 IPI_VENC_VP8,
68 IPI_MDP,
51 IPI_MAX, 69 IPI_MAX,
52}; 70};
53 71
@@ -55,10 +73,14 @@ enum ipi_id {
55 * enum rst_id - reset id to register reset function for VPU watchdog timeout 73 * enum rst_id - reset id to register reset function for VPU watchdog timeout
56 * 74 *
57 * @VPU_RST_ENC: encoder reset id 75 * @VPU_RST_ENC: encoder reset id
76 * @VPU_RST_DEC: decoder reset id
77 * @VPU_RST_MDP: MDP (Media Data Path) reset id
58 * @VPU_RST_MAX: maximum reset id 78 * @VPU_RST_MAX: maximum reset id
59 */ 79 */
60enum rst_id { 80enum rst_id {
61 VPU_RST_ENC, 81 VPU_RST_ENC,
82 VPU_RST_DEC,
83 VPU_RST_MDP,
62 VPU_RST_MAX, 84 VPU_RST_MAX,
63}; 85};
64 86
@@ -125,6 +147,16 @@ struct platform_device *vpu_get_plat_device(struct platform_device *pdev);
125int vpu_wdt_reg_handler(struct platform_device *pdev, 147int vpu_wdt_reg_handler(struct platform_device *pdev,
126 void vpu_wdt_reset_func(void *), 148 void vpu_wdt_reset_func(void *),
127 void *priv, enum rst_id id); 149 void *priv, enum rst_id id);
150
151/**
152 * vpu_get_vdec_hw_capa - get video decoder hardware capability
153 *
154 * @pdev: VPU platform device
155 *
156 * Return: video decoder hardware capability
157 **/
158unsigned int vpu_get_vdec_hw_capa(struct platform_device *pdev);
159
128/** 160/**
129 * vpu_get_venc_hw_capa - get video encoder hardware capability 161 * vpu_get_venc_hw_capa - get video encoder hardware capability
130 * 162 *
diff --git a/drivers/media/platform/mx2_emmaprp.c b/drivers/media/platform/mx2_emmaprp.c
index e68d271b10af..03e47e0f778d 100644
--- a/drivers/media/platform/mx2_emmaprp.c
+++ b/drivers/media/platform/mx2_emmaprp.c
@@ -724,10 +724,10 @@ static int emmaprp_buf_prepare(struct vb2_buffer *vb)
724 q_data = get_q_data(ctx, vb->vb2_queue->type); 724 q_data = get_q_data(ctx, vb->vb2_queue->type);
725 725
726 if (vb2_plane_size(vb, 0) < q_data->sizeimage) { 726 if (vb2_plane_size(vb, 0) < q_data->sizeimage) {
727 dprintk(ctx->dev, "%s data will not fit into plane" 727 dprintk(ctx->dev,
728 "(%lu < %lu)\n", __func__, 728 "%s data will not fit into plane(%lu < %lu)\n",
729 vb2_plane_size(vb, 0), 729 __func__, vb2_plane_size(vb, 0),
730 (long)q_data->sizeimage); 730 (long)q_data->sizeimage);
731 return -EINVAL; 731 return -EINVAL;
732 } 732 }
733 733
@@ -937,7 +937,7 @@ static int emmaprp_probe(struct platform_device *pdev)
937 snprintf(vfd->name, sizeof(vfd->name), "%s", emmaprp_videodev.name); 937 snprintf(vfd->name, sizeof(vfd->name), "%s", emmaprp_videodev.name);
938 pcdev->vfd = vfd; 938 pcdev->vfd = vfd;
939 v4l2_info(&pcdev->v4l2_dev, EMMAPRP_MODULE_NAME 939 v4l2_info(&pcdev->v4l2_dev, EMMAPRP_MODULE_NAME
940 " Device registered as /dev/video%d\n", vfd->num); 940 " Device registered as /dev/video%d\n", vfd->num);
941 941
942 platform_set_drvdata(pdev, pcdev); 942 platform_set_drvdata(pdev, pcdev);
943 943
diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
index a31b95cb3b09..4d29860d27b4 100644
--- a/drivers/media/platform/omap/omap_vout.c
+++ b/drivers/media/platform/omap/omap_vout.c
@@ -408,8 +408,8 @@ static int omapvid_setup_overlay(struct omap_vout_device *vout,
408 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, 408 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev,
409 "%s enable=%d addr=%pad width=%d\n height=%d color_mode=%d\n" 409 "%s enable=%d addr=%pad width=%d\n height=%d color_mode=%d\n"
410 "rotation=%d mirror=%d posx=%d posy=%d out_width = %d \n" 410 "rotation=%d mirror=%d posx=%d posy=%d out_width = %d \n"
411 "out_height=%d rotation_type=%d screen_width=%d\n", 411 "out_height=%d rotation_type=%d screen_width=%d\n", __func__,
412 __func__, ovl->is_enabled(ovl), &info.paddr, info.width, info.height, 412 ovl->is_enabled(ovl), &info.paddr, info.width, info.height,
413 info.color_mode, info.rotation, info.mirror, info.pos_x, 413 info.color_mode, info.rotation, info.mirror, info.pos_x,
414 info.pos_y, info.out_width, info.out_height, info.rotation_type, 414 info.pos_y, info.out_width, info.out_height, info.rotation_type,
415 info.screen_width); 415 info.screen_width);
@@ -791,7 +791,8 @@ static int omap_vout_buffer_prepare(struct videobuf_queue *q,
791 dma_addr = dma_map_single(vout->vid_dev->v4l2_dev.dev, (void *) addr, 791 dma_addr = dma_map_single(vout->vid_dev->v4l2_dev.dev, (void *) addr,
792 size, DMA_TO_DEVICE); 792 size, DMA_TO_DEVICE);
793 if (dma_mapping_error(vout->vid_dev->v4l2_dev.dev, dma_addr)) 793 if (dma_mapping_error(vout->vid_dev->v4l2_dev.dev, dma_addr))
794 v4l2_err(&vout->vid_dev->v4l2_dev, "dma_map_single failed\n"); 794 v4l2_err(&vout->vid_dev->v4l2_dev,
795 "dma_map_single failed\n");
795 796
796 vout->queued_buf_addr[vb->i] = (u8 *)vout->buf_phy_addr[vb->i]; 797 vout->queued_buf_addr[vb->i] = (u8 *)vout->buf_phy_addr[vb->i];
797 } 798 }
@@ -1657,8 +1658,8 @@ static int vidioc_streamoff(struct file *file, void *fh, enum v4l2_buf_type i)
1657 /* Turn of the pipeline */ 1658 /* Turn of the pipeline */
1658 ret = omapvid_apply_changes(vout); 1659 ret = omapvid_apply_changes(vout);
1659 if (ret) 1660 if (ret)
1660 v4l2_err(&vout->vid_dev->v4l2_dev, "failed to change mode in" 1661 v4l2_err(&vout->vid_dev->v4l2_dev,
1661 " streamoff\n"); 1662 "failed to change mode in streamoff\n");
1662 1663
1663 INIT_LIST_HEAD(&vout->dma_queue); 1664 INIT_LIST_HEAD(&vout->dma_queue);
1664 ret = videobuf_streamoff(&vout->vbq); 1665 ret = videobuf_streamoff(&vout->vbq);
@@ -1858,8 +1859,8 @@ static int __init omap_vout_setup_video_data(struct omap_vout_device *vout)
1858 vfd = vout->vfd = video_device_alloc(); 1859 vfd = vout->vfd = video_device_alloc();
1859 1860
1860 if (!vfd) { 1861 if (!vfd) {
1861 printk(KERN_ERR VOUT_NAME ": could not allocate" 1862 printk(KERN_ERR VOUT_NAME
1862 " video device struct\n"); 1863 ": could not allocate video device struct\n");
1863 v4l2_ctrl_handler_free(hdl); 1864 v4l2_ctrl_handler_free(hdl);
1864 return -ENOMEM; 1865 return -ENOMEM;
1865 } 1866 }
@@ -1984,16 +1985,17 @@ static int __init omap_vout_create_video_devices(struct platform_device *pdev)
1984 */ 1985 */
1985 vfd = vout->vfd; 1986 vfd = vout->vfd;
1986 if (video_register_device(vfd, VFL_TYPE_GRABBER, -1) < 0) { 1987 if (video_register_device(vfd, VFL_TYPE_GRABBER, -1) < 0) {
1987 dev_err(&pdev->dev, ": Could not register " 1988 dev_err(&pdev->dev,
1988 "Video for Linux device\n"); 1989 ": Could not register Video for Linux device\n");
1989 vfd->minor = -1; 1990 vfd->minor = -1;
1990 ret = -ENODEV; 1991 ret = -ENODEV;
1991 goto error2; 1992 goto error2;
1992 } 1993 }
1993 video_set_drvdata(vfd, vout); 1994 video_set_drvdata(vfd, vout);
1994 1995
1995 dev_info(&pdev->dev, ": registered and initialized" 1996 dev_info(&pdev->dev,
1996 " video device %d\n", vfd->minor); 1997 ": registered and initialized video device %d\n",
1998 vfd->minor);
1997 if (k == (pdev->num_resources - 1)) 1999 if (k == (pdev->num_resources - 1))
1998 return 0; 2000 return 0;
1999 2001
diff --git a/drivers/media/platform/omap/omap_vout_vrfb.c b/drivers/media/platform/omap/omap_vout_vrfb.c
index b8638e4e1627..92c4e1826356 100644
--- a/drivers/media/platform/omap/omap_vout_vrfb.c
+++ b/drivers/media/platform/omap/omap_vout_vrfb.c
@@ -139,8 +139,9 @@ int omap_vout_setup_vrfb_bufs(struct platform_device *pdev, int vid_num,
139 (void *) &vout->vrfb_dma_tx, &vout->vrfb_dma_tx.dma_ch); 139 (void *) &vout->vrfb_dma_tx, &vout->vrfb_dma_tx.dma_ch);
140 if (ret < 0) { 140 if (ret < 0) {
141 vout->vrfb_dma_tx.req_status = DMA_CHAN_NOT_ALLOTED; 141 vout->vrfb_dma_tx.req_status = DMA_CHAN_NOT_ALLOTED;
142 dev_info(&pdev->dev, ": failed to allocate DMA Channel for" 142 dev_info(&pdev->dev,
143 " video%d\n", vfd->minor); 143 ": failed to allocate DMA Channel for video%d\n",
144 vfd->minor);
144 } 145 }
145 init_waitqueue_head(&vout->vrfb_dma_tx.wait); 146 init_waitqueue_head(&vout->vrfb_dma_tx.wait);
146 147
diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
index 0321d84addc7..084ecf4aa9a4 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -480,8 +480,8 @@ void omap3isp_hist_dma_done(struct isp_device *isp)
480 omap3isp_stat_pcr_busy(&isp->isp_hist)) { 480 omap3isp_stat_pcr_busy(&isp->isp_hist)) {
481 /* Histogram cannot be enabled in this frame anymore */ 481 /* Histogram cannot be enabled in this frame anymore */
482 atomic_set(&isp->isp_hist.buf_err, 1); 482 atomic_set(&isp->isp_hist.buf_err, 1);
483 dev_dbg(isp->dev, "hist: Out of synchronization with " 483 dev_dbg(isp->dev,
484 "CCDC. Ignoring next buffer.\n"); 484 "hist: Out of synchronization with CCDC. Ignoring next buffer.\n");
485 } 485 }
486} 486}
487 487
@@ -2117,23 +2117,18 @@ static int isp_of_parse_nodes(struct device *dev,
2117 struct isp_async_subdev *isd; 2117 struct isp_async_subdev *isd;
2118 2118
2119 isd = devm_kzalloc(dev, sizeof(*isd), GFP_KERNEL); 2119 isd = devm_kzalloc(dev, sizeof(*isd), GFP_KERNEL);
2120 if (!isd) { 2120 if (!isd)
2121 of_node_put(node); 2121 goto error;
2122 return -ENOMEM;
2123 }
2124 2122
2125 notifier->subdevs[notifier->num_subdevs] = &isd->asd; 2123 notifier->subdevs[notifier->num_subdevs] = &isd->asd;
2126 2124
2127 if (isp_of_parse_node(dev, node, isd)) { 2125 if (isp_of_parse_node(dev, node, isd))
2128 of_node_put(node); 2126 goto error;
2129 return -EINVAL;
2130 }
2131 2127
2132 isd->asd.match.of.node = of_graph_get_remote_port_parent(node); 2128 isd->asd.match.of.node = of_graph_get_remote_port_parent(node);
2133 of_node_put(node);
2134 if (!isd->asd.match.of.node) { 2129 if (!isd->asd.match.of.node) {
2135 dev_warn(dev, "bad remote port parent\n"); 2130 dev_warn(dev, "bad remote port parent\n");
2136 return -EINVAL; 2131 goto error;
2137 } 2132 }
2138 2133
2139 isd->asd.match_type = V4L2_ASYNC_MATCH_OF; 2134 isd->asd.match_type = V4L2_ASYNC_MATCH_OF;
@@ -2141,6 +2136,10 @@ static int isp_of_parse_nodes(struct device *dev,
2141 } 2136 }
2142 2137
2143 return notifier->num_subdevs; 2138 return notifier->num_subdevs;
2139
2140error:
2141 of_node_put(node);
2142 return -EINVAL;
2144} 2143}
2145 2144
2146static int isp_subdev_notifier_bound(struct v4l2_async_notifier *async, 2145static int isp_subdev_notifier_bound(struct v4l2_async_notifier *async,
diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c
index 882310eb45cc..7207558d722c 100644
--- a/drivers/media/platform/omap3isp/ispccdc.c
+++ b/drivers/media/platform/omap3isp/ispccdc.c
@@ -151,8 +151,8 @@ static int ccdc_lsc_validate_config(struct isp_ccdc_device *ccdc,
151 } 151 }
152 152
153 if (lsc_cfg->offset & 3) { 153 if (lsc_cfg->offset & 3) {
154 dev_dbg(isp->dev, "CCDC: LSC: Offset must be a multiple of " 154 dev_dbg(isp->dev,
155 "4\n"); 155 "CCDC: LSC: Offset must be a multiple of 4\n");
156 return -EINVAL; 156 return -EINVAL;
157 } 157 }
158 158
@@ -416,8 +416,9 @@ static int ccdc_lsc_config(struct isp_ccdc_device *ccdc,
416 return 0; 416 return 0;
417 417
418 if (update != (OMAP3ISP_CCDC_CONFIG_LSC | OMAP3ISP_CCDC_TBL_LSC)) { 418 if (update != (OMAP3ISP_CCDC_CONFIG_LSC | OMAP3ISP_CCDC_TBL_LSC)) {
419 dev_dbg(to_device(ccdc), "%s: Both LSC configuration and table " 419 dev_dbg(to_device(ccdc),
420 "need to be supplied\n", __func__); 420 "%s: Both LSC configuration and table need to be supplied\n",
421 __func__);
421 return -EINVAL; 422 return -EINVAL;
422 } 423 }
423 424
diff --git a/drivers/media/platform/omap3isp/ispcsi2.c b/drivers/media/platform/omap3isp/ispcsi2.c
index f75a1be29d84..7dae2fe0d42d 100644
--- a/drivers/media/platform/omap3isp/ispcsi2.c
+++ b/drivers/media/platform/omap3isp/ispcsi2.c
@@ -753,8 +753,8 @@ void omap3isp_csi2_isr(struct isp_csi2_device *csi2)
753 ISPCSI2_PHY_IRQSTATUS); 753 ISPCSI2_PHY_IRQSTATUS);
754 isp_reg_writel(isp, cpxio1_irqstatus, 754 isp_reg_writel(isp, cpxio1_irqstatus,
755 csi2->regs1, ISPCSI2_PHY_IRQSTATUS); 755 csi2->regs1, ISPCSI2_PHY_IRQSTATUS);
756 dev_dbg(isp->dev, "CSI2: ComplexIO Error IRQ " 756 dev_dbg(isp->dev, "CSI2: ComplexIO Error IRQ %x\n",
757 "%x\n", cpxio1_irqstatus); 757 cpxio1_irqstatus);
758 pipe->error = true; 758 pipe->error = true;
759 } 759 }
760 760
@@ -763,13 +763,8 @@ void omap3isp_csi2_isr(struct isp_csi2_device *csi2)
763 ISPCSI2_IRQSTATUS_ECC_NO_CORRECTION_IRQ | 763 ISPCSI2_IRQSTATUS_ECC_NO_CORRECTION_IRQ |
764 ISPCSI2_IRQSTATUS_COMPLEXIO2_ERR_IRQ | 764 ISPCSI2_IRQSTATUS_COMPLEXIO2_ERR_IRQ |
765 ISPCSI2_IRQSTATUS_FIFO_OVF_IRQ)) { 765 ISPCSI2_IRQSTATUS_FIFO_OVF_IRQ)) {
766 dev_dbg(isp->dev, "CSI2 Err:" 766 dev_dbg(isp->dev,
767 " OCP:%d," 767 "CSI2 Err: OCP:%d, Short_pack:%d, ECC:%d, CPXIO2:%d, FIFO_OVF:%d,\n",
768 " Short_pack:%d,"
769 " ECC:%d,"
770 " CPXIO2:%d,"
771 " FIFO_OVF:%d,"
772 "\n",
773 (csi2_irqstatus & 768 (csi2_irqstatus &
774 ISPCSI2_IRQSTATUS_OCP_ERR_IRQ) ? 1 : 0, 769 ISPCSI2_IRQSTATUS_OCP_ERR_IRQ) ? 1 : 0,
775 (csi2_irqstatus & 770 (csi2_irqstatus &
diff --git a/drivers/media/platform/omap3isp/ispcsiphy.c b/drivers/media/platform/omap3isp/ispcsiphy.c
index 495447d66cfd..871d4fe09c7f 100644
--- a/drivers/media/platform/omap3isp/ispcsiphy.c
+++ b/drivers/media/platform/omap3isp/ispcsiphy.c
@@ -267,8 +267,8 @@ int omap3isp_csiphy_acquire(struct isp_csiphy *phy)
267 int rval; 267 int rval;
268 268
269 if (phy->vdd == NULL) { 269 if (phy->vdd == NULL) {
270 dev_err(phy->isp->dev, "Power regulator for CSI PHY not " 270 dev_err(phy->isp->dev,
271 "available\n"); 271 "Power regulator for CSI PHY not available\n");
272 return -ENODEV; 272 return -ENODEV;
273 } 273 }
274 274
diff --git a/drivers/media/platform/omap3isp/isph3a_aewb.c b/drivers/media/platform/omap3isp/isph3a_aewb.c
index ccaf92f39236..d44626f20ac6 100644
--- a/drivers/media/platform/omap3isp/isph3a_aewb.c
+++ b/drivers/media/platform/omap3isp/isph3a_aewb.c
@@ -304,8 +304,8 @@ int omap3isp_h3a_aewb_init(struct isp_device *isp)
304 aewb_recover_cfg = devm_kzalloc(isp->dev, sizeof(*aewb_recover_cfg), 304 aewb_recover_cfg = devm_kzalloc(isp->dev, sizeof(*aewb_recover_cfg),
305 GFP_KERNEL); 305 GFP_KERNEL);
306 if (!aewb_recover_cfg) { 306 if (!aewb_recover_cfg) {
307 dev_err(aewb->isp->dev, "AEWB: cannot allocate memory for " 307 dev_err(aewb->isp->dev,
308 "recover configuration.\n"); 308 "AEWB: cannot allocate memory for recover configuration.\n");
309 return -ENOMEM; 309 return -ENOMEM;
310 } 310 }
311 311
@@ -321,8 +321,8 @@ int omap3isp_h3a_aewb_init(struct isp_device *isp)
321 aewb_recover_cfg->subsample_hor_inc = OMAP3ISP_AEWB_MIN_SUB_INC; 321 aewb_recover_cfg->subsample_hor_inc = OMAP3ISP_AEWB_MIN_SUB_INC;
322 322
323 if (h3a_aewb_validate_params(aewb, aewb_recover_cfg)) { 323 if (h3a_aewb_validate_params(aewb, aewb_recover_cfg)) {
324 dev_err(aewb->isp->dev, "AEWB: recover configuration is " 324 dev_err(aewb->isp->dev,
325 "invalid.\n"); 325 "AEWB: recover configuration is invalid.\n");
326 return -EINVAL; 326 return -EINVAL;
327 } 327 }
328 328
diff --git a/drivers/media/platform/omap3isp/isph3a_af.c b/drivers/media/platform/omap3isp/isph3a_af.c
index 92937f7eecef..99bd6cc21d86 100644
--- a/drivers/media/platform/omap3isp/isph3a_af.c
+++ b/drivers/media/platform/omap3isp/isph3a_af.c
@@ -367,8 +367,8 @@ int omap3isp_h3a_af_init(struct isp_device *isp)
367 af_recover_cfg = devm_kzalloc(isp->dev, sizeof(*af_recover_cfg), 367 af_recover_cfg = devm_kzalloc(isp->dev, sizeof(*af_recover_cfg),
368 GFP_KERNEL); 368 GFP_KERNEL);
369 if (!af_recover_cfg) { 369 if (!af_recover_cfg) {
370 dev_err(af->isp->dev, "AF: cannot allocate memory for recover " 370 dev_err(af->isp->dev,
371 "configuration.\n"); 371 "AF: cannot allocate memory for recover configuration.\n");
372 return -ENOMEM; 372 return -ENOMEM;
373 } 373 }
374 374
@@ -379,8 +379,8 @@ int omap3isp_h3a_af_init(struct isp_device *isp)
379 af_recover_cfg->paxel.v_cnt = OMAP3ISP_AF_PAXEL_VERTICAL_COUNT_MIN; 379 af_recover_cfg->paxel.v_cnt = OMAP3ISP_AF_PAXEL_VERTICAL_COUNT_MIN;
380 af_recover_cfg->paxel.line_inc = OMAP3ISP_AF_PAXEL_INCREMENT_MIN; 380 af_recover_cfg->paxel.line_inc = OMAP3ISP_AF_PAXEL_INCREMENT_MIN;
381 if (h3a_af_validate_params(af, af_recover_cfg)) { 381 if (h3a_af_validate_params(af, af_recover_cfg)) {
382 dev_err(af->isp->dev, "AF: recover configuration is " 382 dev_err(af->isp->dev,
383 "invalid.\n"); 383 "AF: recover configuration is invalid.\n");
384 return -EINVAL; 384 return -EINVAL;
385 } 385 }
386 386
diff --git a/drivers/media/platform/omap3isp/isphist.c b/drivers/media/platform/omap3isp/isphist.c
index 7138b043a4aa..a4ed5d140d48 100644
--- a/drivers/media/platform/omap3isp/isphist.c
+++ b/drivers/media/platform/omap3isp/isphist.c
@@ -18,7 +18,6 @@
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/device.h> 19#include <linux/device.h>
20#include <linux/dmaengine.h> 20#include <linux/dmaengine.h>
21#include <linux/omap-dmaengine.h>
22#include <linux/slab.h> 21#include <linux/slab.h>
23#include <linux/uaccess.h> 22#include <linux/uaccess.h>
24 23
@@ -486,27 +485,30 @@ int omap3isp_hist_init(struct isp_device *isp)
486 hist->isp = isp; 485 hist->isp = isp;
487 486
488 if (HIST_CONFIG_DMA) { 487 if (HIST_CONFIG_DMA) {
489 struct platform_device *pdev = to_platform_device(isp->dev);
490 struct resource *res;
491 unsigned int sig = 0;
492 dma_cap_mask_t mask; 488 dma_cap_mask_t mask;
493 489
490 /*
491 * We need slave capable channel without DMA request line for
492 * reading out the data.
493 * For this we can use dma_request_chan_by_mask() as we are
494 * happy with any channel as long as it is capable of slave
495 * configuration.
496 */
494 dma_cap_zero(mask); 497 dma_cap_zero(mask);
495 dma_cap_set(DMA_SLAVE, mask); 498 dma_cap_set(DMA_SLAVE, mask);
499 hist->dma_ch = dma_request_chan_by_mask(&mask);
500 if (IS_ERR(hist->dma_ch)) {
501 ret = PTR_ERR(hist->dma_ch);
502 if (ret == -EPROBE_DEFER)
503 return ret;
496 504
497 res = platform_get_resource_byname(pdev, IORESOURCE_DMA, 505 hist->dma_ch = NULL;
498 "hist");
499 if (res)
500 sig = res->start;
501
502 hist->dma_ch = dma_request_slave_channel_compat(mask,
503 omap_dma_filter_fn, &sig, isp->dev, "hist");
504 if (!hist->dma_ch)
505 dev_warn(isp->dev, 506 dev_warn(isp->dev,
506 "hist: DMA channel request failed, using PIO\n"); 507 "hist: DMA channel request failed, using PIO\n");
507 else 508 } else {
508 dev_dbg(isp->dev, "hist: using DMA channel %s\n", 509 dev_dbg(isp->dev, "hist: using DMA channel %s\n",
509 dma_chan_name(hist->dma_ch)); 510 dma_chan_name(hist->dma_ch));
511 }
510 } 512 }
511 513
512 hist->ops = &hist_ops; 514 hist->ops = &hist_ops;
diff --git a/drivers/media/platform/omap3isp/ispstat.c b/drivers/media/platform/omap3isp/ispstat.c
index 1b9217d3b1b6..47cbc7e3d825 100644
--- a/drivers/media/platform/omap3isp/ispstat.c
+++ b/drivers/media/platform/omap3isp/ispstat.c
@@ -113,8 +113,9 @@ static int isp_stat_buf_check_magic(struct ispstat *stat,
113 ret = 0; 113 ret = 0;
114 114
115 if (ret) { 115 if (ret) {
116 dev_dbg(stat->isp->dev, "%s: beginning magic check does not " 116 dev_dbg(stat->isp->dev,
117 "match.\n", stat->subdev.name); 117 "%s: beginning magic check does not match.\n",
118 stat->subdev.name);
118 return ret; 119 return ret;
119 } 120 }
120 121
@@ -122,8 +123,9 @@ static int isp_stat_buf_check_magic(struct ispstat *stat,
122 for (w = buf->virt_addr + buf_size, end = w + MAGIC_SIZE; 123 for (w = buf->virt_addr + buf_size, end = w + MAGIC_SIZE;
123 w < end; w++) { 124 w < end; w++) {
124 if (unlikely(*w != MAGIC_NUM)) { 125 if (unlikely(*w != MAGIC_NUM)) {
125 dev_dbg(stat->isp->dev, "%s: ending magic check does " 126 dev_dbg(stat->isp->dev,
126 "not match.\n", stat->subdev.name); 127 "%s: ending magic check does not match.\n",
128 stat->subdev.name);
127 return -EINVAL; 129 return -EINVAL;
128 } 130 }
129 } 131 }
@@ -256,9 +258,9 @@ static void isp_stat_buf_next(struct ispstat *stat)
256{ 258{
257 if (unlikely(stat->active_buf)) 259 if (unlikely(stat->active_buf))
258 /* Overwriting unused active buffer */ 260 /* Overwriting unused active buffer */
259 dev_dbg(stat->isp->dev, "%s: new buffer requested without " 261 dev_dbg(stat->isp->dev,
260 "queuing active one.\n", 262 "%s: new buffer requested without queuing active one.\n",
261 stat->subdev.name); 263 stat->subdev.name);
262 else 264 else
263 stat->active_buf = isp_stat_buf_find_oldest_or_empty(stat); 265 stat->active_buf = isp_stat_buf_find_oldest_or_empty(stat);
264} 266}
@@ -292,8 +294,9 @@ static struct ispstat_buffer *isp_stat_buf_get(struct ispstat *stat,
292 return ERR_PTR(-EBUSY); 294 return ERR_PTR(-EBUSY);
293 } 295 }
294 if (isp_stat_buf_check_magic(stat, buf)) { 296 if (isp_stat_buf_check_magic(stat, buf)) {
295 dev_dbg(stat->isp->dev, "%s: current buffer has " 297 dev_dbg(stat->isp->dev,
296 "corrupted data\n.", stat->subdev.name); 298 "%s: current buffer has corrupted data\n.",
299 stat->subdev.name);
297 /* Mark empty because it doesn't have valid data. */ 300 /* Mark empty because it doesn't have valid data. */
298 buf->empty = 1; 301 buf->empty = 1;
299 } else { 302 } else {
@@ -307,8 +310,9 @@ static struct ispstat_buffer *isp_stat_buf_get(struct ispstat *stat,
307 spin_unlock_irqrestore(&stat->isp->stat_lock, flags); 310 spin_unlock_irqrestore(&stat->isp->stat_lock, flags);
308 311
309 if (buf->buf_size > data->buf_size) { 312 if (buf->buf_size > data->buf_size) {
310 dev_warn(stat->isp->dev, "%s: userspace's buffer size is " 313 dev_warn(stat->isp->dev,
311 "not enough.\n", stat->subdev.name); 314 "%s: userspace's buffer size is not enough.\n",
315 stat->subdev.name);
312 isp_stat_buf_release(stat); 316 isp_stat_buf_release(stat);
313 return ERR_PTR(-EINVAL); 317 return ERR_PTR(-EINVAL);
314 } 318 }
@@ -531,20 +535,22 @@ int omap3isp_stat_config(struct ispstat *stat, void *new_conf)
531 535
532 mutex_lock(&stat->ioctl_lock); 536 mutex_lock(&stat->ioctl_lock);
533 537
534 dev_dbg(stat->isp->dev, "%s: configuring module with buffer " 538 dev_dbg(stat->isp->dev,
535 "size=0x%08lx\n", stat->subdev.name, (unsigned long)buf_size); 539 "%s: configuring module with buffer size=0x%08lx\n",
540 stat->subdev.name, (unsigned long)buf_size);
536 541
537 ret = stat->ops->validate_params(stat, new_conf); 542 ret = stat->ops->validate_params(stat, new_conf);
538 if (ret) { 543 if (ret) {
539 mutex_unlock(&stat->ioctl_lock); 544 mutex_unlock(&stat->ioctl_lock);
540 dev_dbg(stat->isp->dev, "%s: configuration values are " 545 dev_dbg(stat->isp->dev, "%s: configuration values are invalid.\n",
541 "invalid.\n", stat->subdev.name); 546 stat->subdev.name);
542 return ret; 547 return ret;
543 } 548 }
544 549
545 if (buf_size != user_cfg->buf_size) 550 if (buf_size != user_cfg->buf_size)
546 dev_dbg(stat->isp->dev, "%s: driver has corrected buffer size " 551 dev_dbg(stat->isp->dev,
547 "request to 0x%08lx\n", stat->subdev.name, 552 "%s: driver has corrected buffer size request to 0x%08lx\n",
553 stat->subdev.name,
548 (unsigned long)user_cfg->buf_size); 554 (unsigned long)user_cfg->buf_size);
549 555
550 /* 556 /*
@@ -595,8 +601,9 @@ int omap3isp_stat_config(struct ispstat *stat, void *new_conf)
595 601
596 /* Module has a valid configuration. */ 602 /* Module has a valid configuration. */
597 stat->configured = 1; 603 stat->configured = 1;
598 dev_dbg(stat->isp->dev, "%s: module has been successfully " 604 dev_dbg(stat->isp->dev,
599 "configured.\n", stat->subdev.name); 605 "%s: module has been successfully configured.\n",
606 stat->subdev.name);
600 607
601 mutex_unlock(&stat->ioctl_lock); 608 mutex_unlock(&stat->ioctl_lock);
602 609
@@ -762,8 +769,8 @@ int omap3isp_stat_enable(struct ispstat *stat, u8 enable)
762 if (!stat->configured && enable) { 769 if (!stat->configured && enable) {
763 spin_unlock_irqrestore(&stat->isp->stat_lock, irqflags); 770 spin_unlock_irqrestore(&stat->isp->stat_lock, irqflags);
764 mutex_unlock(&stat->ioctl_lock); 771 mutex_unlock(&stat->ioctl_lock);
765 dev_dbg(stat->isp->dev, "%s: cannot enable module as it's " 772 dev_dbg(stat->isp->dev,
766 "never been successfully configured so far.\n", 773 "%s: cannot enable module as it's never been successfully configured so far.\n",
767 stat->subdev.name); 774 stat->subdev.name);
768 return -EINVAL; 775 return -EINVAL;
769 } 776 }
@@ -859,8 +866,8 @@ static void __stat_isr(struct ispstat *stat, int from_dma)
859 if (stat->state == ISPSTAT_ENABLED) { 866 if (stat->state == ISPSTAT_ENABLED) {
860 spin_unlock_irqrestore(&stat->isp->stat_lock, irqflags); 867 spin_unlock_irqrestore(&stat->isp->stat_lock, irqflags);
861 dev_err(stat->isp->dev, 868 dev_err(stat->isp->dev,
862 "%s: interrupt occurred when module was still " 869 "%s: interrupt occurred when module was still processing a buffer.\n",
863 "processing a buffer.\n", stat->subdev.name); 870 stat->subdev.name);
864 ret = STAT_NO_BUF; 871 ret = STAT_NO_BUF;
865 goto out; 872 goto out;
866 } else { 873 } else {
@@ -964,8 +971,9 @@ static void __stat_isr(struct ispstat *stat, int from_dma)
964 atomic_set(&stat->buf_err, 1); 971 atomic_set(&stat->buf_err, 1);
965 972
966 ret = STAT_NO_BUF; 973 ret = STAT_NO_BUF;
967 dev_dbg(stat->isp->dev, "%s: cannot process buffer, " 974 dev_dbg(stat->isp->dev,
968 "device is busy.\n", stat->subdev.name); 975 "%s: cannot process buffer, device is busy.\n",
976 stat->subdev.name);
969 } 977 }
970 978
971out: 979out:
diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c
index c12209c701d3..929006f65cc7 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -2125,17 +2125,22 @@ static int pxa_camera_sensor_bound(struct v4l2_async_notifier *notifier,
2125 pix->bytesperline, pix->height); 2125 pix->bytesperline, pix->height);
2126 pix->pixelformat = pcdev->current_fmt->host_fmt->fourcc; 2126 pix->pixelformat = pcdev->current_fmt->host_fmt->fourcc;
2127 v4l2_fill_mbus_format(mf, pix, pcdev->current_fmt->code); 2127 v4l2_fill_mbus_format(mf, pix, pcdev->current_fmt->code);
2128 err = sensor_call(pcdev, pad, set_fmt, NULL, &format); 2128
2129 err = sensor_call(pcdev, core, s_power, 1);
2129 if (err) 2130 if (err)
2130 goto out; 2131 goto out;
2131 2132
2133 err = sensor_call(pcdev, pad, set_fmt, NULL, &format);
2134 if (err)
2135 goto out_sensor_poweroff;
2136
2132 v4l2_fill_pix_format(pix, mf); 2137 v4l2_fill_pix_format(pix, mf);
2133 pr_info("%s(): colorspace=0x%x pixfmt=0x%x\n", 2138 pr_info("%s(): colorspace=0x%x pixfmt=0x%x\n",
2134 __func__, pix->colorspace, pix->pixelformat); 2139 __func__, pix->colorspace, pix->pixelformat);
2135 2140
2136 err = pxa_camera_init_videobuf2(pcdev); 2141 err = pxa_camera_init_videobuf2(pcdev);
2137 if (err) 2142 if (err)
2138 goto out; 2143 goto out_sensor_poweroff;
2139 2144
2140 err = video_register_device(&pcdev->vdev, VFL_TYPE_GRABBER, -1); 2145 err = video_register_device(&pcdev->vdev, VFL_TYPE_GRABBER, -1);
2141 if (err) { 2146 if (err) {
@@ -2146,6 +2151,9 @@ static int pxa_camera_sensor_bound(struct v4l2_async_notifier *notifier,
2146 "PXA Camera driver attached to camera %s\n", 2151 "PXA Camera driver attached to camera %s\n",
2147 subdev->name); 2152 subdev->name);
2148 } 2153 }
2154
2155out_sensor_poweroff:
2156 err = sensor_call(pcdev, core, s_power, 0);
2149out: 2157out:
2150 mutex_unlock(&pcdev->mlock); 2158 mutex_unlock(&pcdev->mlock);
2151 return err; 2159 return err;
@@ -2347,8 +2355,7 @@ static int pxa_camera_probe(struct platform_device *pdev)
2347 * Platform hasn't set available data widths. This is bad. 2355 * Platform hasn't set available data widths. This is bad.
2348 * Warn and use a default. 2356 * Warn and use a default.
2349 */ 2357 */
2350 dev_warn(&pdev->dev, "WARNING! Platform hasn't set available " 2358 dev_warn(&pdev->dev, "WARNING! Platform hasn't set available data widths, using default 10 bit\n");
2351 "data widths, using default 10 bit\n");
2352 pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_10; 2359 pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_10;
2353 } 2360 }
2354 if (pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_8) 2361 if (pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_8)
@@ -2359,8 +2366,7 @@ static int pxa_camera_probe(struct platform_device *pdev)
2359 pcdev->width_flags |= 1 << 9; 2366 pcdev->width_flags |= 1 << 9;
2360 if (!pcdev->mclk) { 2367 if (!pcdev->mclk) {
2361 dev_warn(&pdev->dev, 2368 dev_warn(&pdev->dev,
2362 "mclk == 0! Please, fix your platform data. " 2369 "mclk == 0! Please, fix your platform data. Using default 20MHz\n");
2363 "Using default 20MHz\n");
2364 pcdev->mclk = 20000000; 2370 pcdev->mclk = 20000000;
2365 } 2371 }
2366 2372
diff --git a/drivers/media/platform/rcar-fcp.c b/drivers/media/platform/rcar-fcp.c
index f3a3f31cdfa9..7146fc5ef168 100644
--- a/drivers/media/platform/rcar-fcp.c
+++ b/drivers/media/platform/rcar-fcp.c
@@ -169,6 +169,7 @@ static const struct of_device_id rcar_fcp_of_match[] = {
169 { .compatible = "renesas,fcpv" }, 169 { .compatible = "renesas,fcpv" },
170 { }, 170 { },
171}; 171};
172MODULE_DEVICE_TABLE(of, rcar_fcp_of_match);
172 173
173static struct platform_driver rcar_fcp_platform_driver = { 174static struct platform_driver rcar_fcp_platform_driver = {
174 .probe = rcar_fcp_probe, 175 .probe = rcar_fcp_probe,
diff --git a/drivers/media/platform/rcar_fdp1.c b/drivers/media/platform/rcar_fdp1.c
new file mode 100644
index 000000000000..674cc1309b43
--- /dev/null
+++ b/drivers/media/platform/rcar_fdp1.c
@@ -0,0 +1,2445 @@
1/*
2 * Renesas RCar Fine Display Processor
3 *
4 * Video format converter and frame deinterlacer device.
5 *
6 * Author: Kieran Bingham, <kieran@bingham.xyz>
7 * Copyright (c) 2016 Renesas Electronics Corporation.
8 *
9 * This code is developed and inspired from the vim2m, rcar_jpu,
10 * m2m-deinterlace, and vsp1 drivers.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version
16 */
17
18#include <linux/clk.h>
19#include <linux/delay.h>
20#include <linux/dma-mapping.h>
21#include <linux/fs.h>
22#include <linux/interrupt.h>
23#include <linux/module.h>
24#include <linux/of.h>
25#include <linux/of_device.h>
26#include <linux/platform_device.h>
27#include <linux/pm_runtime.h>
28#include <linux/sched.h>
29#include <linux/slab.h>
30#include <linux/timer.h>
31#include <media/rcar-fcp.h>
32#include <media/v4l2-ctrls.h>
33#include <media/v4l2-device.h>
34#include <media/v4l2-event.h>
35#include <media/v4l2-ioctl.h>
36#include <media/v4l2-mem2mem.h>
37#include <media/videobuf2-dma-contig.h>
38
39static unsigned int debug;
40module_param(debug, uint, 0644);
41MODULE_PARM_DESC(debug, "activate debug info");
42
43/* Minimum and maximum frame width/height */
44#define FDP1_MIN_W 80U
45#define FDP1_MIN_H 80U
46
47#define FDP1_MAX_W 3840U
48#define FDP1_MAX_H 2160U
49
50#define FDP1_MAX_PLANES 3U
51#define FDP1_MAX_STRIDE 8190U
52
53/* Flags that indicate a format can be used for capture/output */
54#define FDP1_CAPTURE BIT(0)
55#define FDP1_OUTPUT BIT(1)
56
57#define DRIVER_NAME "rcar_fdp1"
58
59/* Number of Job's to have available on the processing queue */
60#define FDP1_NUMBER_JOBS 8
61
62#define dprintk(fdp1, fmt, arg...) \
63 v4l2_dbg(1, debug, &fdp1->v4l2_dev, "%s: " fmt, __func__, ## arg)
64
65/*
66 * FDP1 registers and bits
67 */
68
69/* FDP1 start register - Imm */
70#define FD1_CTL_CMD 0x0000
71#define FD1_CTL_CMD_STRCMD BIT(0)
72
73/* Sync generator register - Imm */
74#define FD1_CTL_SGCMD 0x0004
75#define FD1_CTL_SGCMD_SGEN BIT(0)
76
77/* Register set end register - Imm */
78#define FD1_CTL_REGEND 0x0008
79#define FD1_CTL_REGEND_REGEND BIT(0)
80
81/* Channel activation register - Vupdt */
82#define FD1_CTL_CHACT 0x000c
83#define FD1_CTL_CHACT_SMW BIT(9)
84#define FD1_CTL_CHACT_WR BIT(8)
85#define FD1_CTL_CHACT_SMR BIT(3)
86#define FD1_CTL_CHACT_RD2 BIT(2)
87#define FD1_CTL_CHACT_RD1 BIT(1)
88#define FD1_CTL_CHACT_RD0 BIT(0)
89
90/* Operation Mode Register - Vupdt */
91#define FD1_CTL_OPMODE 0x0010
92#define FD1_CTL_OPMODE_PRG BIT(4)
93#define FD1_CTL_OPMODE_VIMD_INTERRUPT (0 << 0)
94#define FD1_CTL_OPMODE_VIMD_BESTEFFORT (1 << 0)
95#define FD1_CTL_OPMODE_VIMD_NOINTERRUPT (2 << 0)
96
97#define FD1_CTL_VPERIOD 0x0014
98#define FD1_CTL_CLKCTRL 0x0018
99#define FD1_CTL_CLKCTRL_CSTP_N BIT(0)
100
101/* Software reset register */
102#define FD1_CTL_SRESET 0x001c
103#define FD1_CTL_SRESET_SRST BIT(0)
104
105/* Control status register (V-update-status) */
106#define FD1_CTL_STATUS 0x0024
107#define FD1_CTL_STATUS_VINT_CNT_MASK GENMASK(31, 16)
108#define FD1_CTL_STATUS_VINT_CNT_SHIFT 16
109#define FD1_CTL_STATUS_SGREGSET BIT(10)
110#define FD1_CTL_STATUS_SGVERR BIT(9)
111#define FD1_CTL_STATUS_SGFREND BIT(8)
112#define FD1_CTL_STATUS_BSY BIT(0)
113
114#define FD1_CTL_VCYCLE_STAT 0x0028
115
116/* Interrupt enable register */
117#define FD1_CTL_IRQENB 0x0038
118/* Interrupt status register */
119#define FD1_CTL_IRQSTA 0x003c
120/* Interrupt control register */
121#define FD1_CTL_IRQFSET 0x0040
122
123/* Common IRQ Bit settings */
124#define FD1_CTL_IRQ_VERE BIT(16)
125#define FD1_CTL_IRQ_VINTE BIT(4)
126#define FD1_CTL_IRQ_FREE BIT(0)
127#define FD1_CTL_IRQ_MASK (FD1_CTL_IRQ_VERE | \
128 FD1_CTL_IRQ_VINTE | \
129 FD1_CTL_IRQ_FREE)
130
131/* RPF */
132#define FD1_RPF_SIZE 0x0060
133#define FD1_RPF_SIZE_MASK GENMASK(12, 0)
134#define FD1_RPF_SIZE_H_SHIFT 16
135#define FD1_RPF_SIZE_V_SHIFT 0
136
137#define FD1_RPF_FORMAT 0x0064
138#define FD1_RPF_FORMAT_CIPM BIT(16)
139#define FD1_RPF_FORMAT_RSPYCS BIT(13)
140#define FD1_RPF_FORMAT_RSPUVS BIT(12)
141#define FD1_RPF_FORMAT_CF BIT(8)
142
143#define FD1_RPF_PSTRIDE 0x0068
144#define FD1_RPF_PSTRIDE_Y_SHIFT 16
145#define FD1_RPF_PSTRIDE_C_SHIFT 0
146
147/* RPF0 Source Component Y Address register */
148#define FD1_RPF0_ADDR_Y 0x006c
149
150/* RPF1 Current Picture Registers */
151#define FD1_RPF1_ADDR_Y 0x0078
152#define FD1_RPF1_ADDR_C0 0x007c
153#define FD1_RPF1_ADDR_C1 0x0080
154
155/* RPF2 next picture register */
156#define FD1_RPF2_ADDR_Y 0x0084
157
158#define FD1_RPF_SMSK_ADDR 0x0090
159#define FD1_RPF_SWAP 0x0094
160
161/* WPF */
162#define FD1_WPF_FORMAT 0x00c0
163#define FD1_WPF_FORMAT_PDV_SHIFT 24
164#define FD1_WPF_FORMAT_FCNL BIT(20)
165#define FD1_WPF_FORMAT_WSPYCS BIT(15)
166#define FD1_WPF_FORMAT_WSPUVS BIT(14)
167#define FD1_WPF_FORMAT_WRTM_601_16 (0 << 9)
168#define FD1_WPF_FORMAT_WRTM_601_0 (1 << 9)
169#define FD1_WPF_FORMAT_WRTM_709_16 (2 << 9)
170#define FD1_WPF_FORMAT_CSC BIT(8)
171
172#define FD1_WPF_RNDCTL 0x00c4
173#define FD1_WPF_RNDCTL_CBRM BIT(28)
174#define FD1_WPF_RNDCTL_CLMD_NOCLIP (0 << 12)
175#define FD1_WPF_RNDCTL_CLMD_CLIP_16_235 (1 << 12)
176#define FD1_WPF_RNDCTL_CLMD_CLIP_1_254 (2 << 12)
177
178#define FD1_WPF_PSTRIDE 0x00c8
179#define FD1_WPF_PSTRIDE_Y_SHIFT 16
180#define FD1_WPF_PSTRIDE_C_SHIFT 0
181
182/* WPF Destination picture */
183#define FD1_WPF_ADDR_Y 0x00cc
184#define FD1_WPF_ADDR_C0 0x00d0
185#define FD1_WPF_ADDR_C1 0x00d4
186#define FD1_WPF_SWAP 0x00d8
187#define FD1_WPF_SWAP_OSWAP_SHIFT 0
188#define FD1_WPF_SWAP_SSWAP_SHIFT 4
189
190/* WPF/RPF Common */
191#define FD1_RWPF_SWAP_BYTE BIT(0)
192#define FD1_RWPF_SWAP_WORD BIT(1)
193#define FD1_RWPF_SWAP_LWRD BIT(2)
194#define FD1_RWPF_SWAP_LLWD BIT(3)
195
196/* IPC */
197#define FD1_IPC_MODE 0x0100
198#define FD1_IPC_MODE_DLI BIT(8)
199#define FD1_IPC_MODE_DIM_ADAPT2D3D (0 << 0)
200#define FD1_IPC_MODE_DIM_FIXED2D (1 << 0)
201#define FD1_IPC_MODE_DIM_FIXED3D (2 << 0)
202#define FD1_IPC_MODE_DIM_PREVFIELD (3 << 0)
203#define FD1_IPC_MODE_DIM_NEXTFIELD (4 << 0)
204
205#define FD1_IPC_SMSK_THRESH 0x0104
206#define FD1_IPC_SMSK_THRESH_CONST 0x00010002
207
208#define FD1_IPC_COMB_DET 0x0108
209#define FD1_IPC_COMB_DET_CONST 0x00200040
210
211#define FD1_IPC_MOTDEC 0x010c
212#define FD1_IPC_MOTDEC_CONST 0x00008020
213
214/* DLI registers */
215#define FD1_IPC_DLI_BLEND 0x0120
216#define FD1_IPC_DLI_BLEND_CONST 0x0080ff02
217
218#define FD1_IPC_DLI_HGAIN 0x0124
219#define FD1_IPC_DLI_HGAIN_CONST 0x001000ff
220
221#define FD1_IPC_DLI_SPRS 0x0128
222#define FD1_IPC_DLI_SPRS_CONST 0x009004ff
223
224#define FD1_IPC_DLI_ANGLE 0x012c
225#define FD1_IPC_DLI_ANGLE_CONST 0x0004080c
226
227#define FD1_IPC_DLI_ISOPIX0 0x0130
228#define FD1_IPC_DLI_ISOPIX0_CONST 0xff10ff10
229
230#define FD1_IPC_DLI_ISOPIX1 0x0134
231#define FD1_IPC_DLI_ISOPIX1_CONST 0x0000ff10
232
233/* Sensor registers */
234#define FD1_IPC_SENSOR_TH0 0x0140
235#define FD1_IPC_SENSOR_TH0_CONST 0x20208080
236
237#define FD1_IPC_SENSOR_TH1 0x0144
238#define FD1_IPC_SENSOR_TH1_CONST 0
239
240#define FD1_IPC_SENSOR_CTL0 0x0170
241#define FD1_IPC_SENSOR_CTL0_CONST 0x00002201
242
243#define FD1_IPC_SENSOR_CTL1 0x0174
244#define FD1_IPC_SENSOR_CTL1_CONST 0
245
246#define FD1_IPC_SENSOR_CTL2 0x0178
247#define FD1_IPC_SENSOR_CTL2_X_SHIFT 16
248#define FD1_IPC_SENSOR_CTL2_Y_SHIFT 0
249
250#define FD1_IPC_SENSOR_CTL3 0x017c
251#define FD1_IPC_SENSOR_CTL3_0_SHIFT 16
252#define FD1_IPC_SENSOR_CTL3_1_SHIFT 0
253
254/* Line memory pixel number register */
255#define FD1_IPC_LMEM 0x01e0
256#define FD1_IPC_LMEM_LINEAR 1024
257#define FD1_IPC_LMEM_TILE 960
258
259/* Internal Data (HW Version) */
260#define FD1_IP_INTDATA 0x0800
261#define FD1_IP_H3 0x02010101
262#define FD1_IP_M3W 0x02010202
263
264/* LUTs */
265#define FD1_LUT_DIF_ADJ 0x1000
266#define FD1_LUT_SAD_ADJ 0x1400
267#define FD1_LUT_BLD_GAIN 0x1800
268#define FD1_LUT_DIF_GAIN 0x1c00
269#define FD1_LUT_MDET 0x2000
270
271/**
272 * struct fdp1_fmt - The FDP1 internal format data
273 * @fourcc: the fourcc code, to match the V4L2 API
274 * @bpp: bits per pixel per plane
275 * @num_planes: number of planes
276 * @hsub: horizontal subsampling factor
277 * @vsub: vertical subsampling factor
278 * @fmt: 7-bit format code for the fdp1 hardware
279 * @swap_yc: the Y and C components are swapped (Y comes before C)
280 * @swap_uv: the U and V components are swapped (V comes before U)
281 * @swap: swap register control
282 * @types: types of queue this format is applicable to
283 */
284struct fdp1_fmt {
285 u32 fourcc;
286 u8 bpp[3];
287 u8 num_planes;
288 u8 hsub;
289 u8 vsub;
290 u8 fmt;
291 bool swap_yc;
292 bool swap_uv;
293 u8 swap;
294 u8 types;
295};
296
297static const struct fdp1_fmt fdp1_formats[] = {
298 /* RGB formats are only supported by the Write Pixel Formatter */
299
300 { V4L2_PIX_FMT_RGB332, { 8, 0, 0 }, 1, 1, 1, 0x00, false, false,
301 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
302 FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
303 FDP1_CAPTURE },
304 { V4L2_PIX_FMT_XRGB444, { 16, 0, 0 }, 1, 1, 1, 0x01, false, false,
305 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
306 FD1_RWPF_SWAP_WORD,
307 FDP1_CAPTURE },
308 { V4L2_PIX_FMT_XRGB555, { 16, 0, 0 }, 1, 1, 1, 0x04, false, false,
309 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
310 FD1_RWPF_SWAP_WORD,
311 FDP1_CAPTURE },
312 { V4L2_PIX_FMT_RGB565, { 16, 0, 0 }, 1, 1, 1, 0x06, false, false,
313 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
314 FD1_RWPF_SWAP_WORD,
315 FDP1_CAPTURE },
316 { V4L2_PIX_FMT_ABGR32, { 32, 0, 0 }, 1, 1, 1, 0x13, false, false,
317 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD,
318 FDP1_CAPTURE },
319 { V4L2_PIX_FMT_XBGR32, { 32, 0, 0 }, 1, 1, 1, 0x13, false, false,
320 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD,
321 FDP1_CAPTURE },
322 { V4L2_PIX_FMT_ARGB32, { 32, 0, 0 }, 1, 1, 1, 0x13, false, false,
323 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
324 FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
325 FDP1_CAPTURE },
326 { V4L2_PIX_FMT_XRGB32, { 32, 0, 0 }, 1, 1, 1, 0x13, false, false,
327 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
328 FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
329 FDP1_CAPTURE },
330 { V4L2_PIX_FMT_RGB24, { 24, 0, 0 }, 1, 1, 1, 0x15, false, false,
331 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
332 FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
333 FDP1_CAPTURE },
334 { V4L2_PIX_FMT_BGR24, { 24, 0, 0 }, 1, 1, 1, 0x18, false, false,
335 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
336 FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
337 FDP1_CAPTURE },
338 { V4L2_PIX_FMT_ARGB444, { 16, 0, 0 }, 1, 1, 1, 0x19, false, false,
339 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
340 FD1_RWPF_SWAP_WORD,
341 FDP1_CAPTURE },
342 { V4L2_PIX_FMT_ARGB555, { 16, 0, 0 }, 1, 1, 1, 0x1b, false, false,
343 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
344 FD1_RWPF_SWAP_WORD,
345 FDP1_CAPTURE },
346
347 /* YUV Formats are supported by Read and Write Pixel Formatters */
348
349 { V4L2_PIX_FMT_NV16M, { 8, 16, 0 }, 2, 2, 1, 0x41, false, false,
350 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
351 FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
352 FDP1_CAPTURE | FDP1_OUTPUT },
353 { V4L2_PIX_FMT_NV61M, { 8, 16, 0 }, 2, 2, 1, 0x41, false, true,
354 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
355 FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
356 FDP1_CAPTURE | FDP1_OUTPUT },
357 { V4L2_PIX_FMT_NV12M, { 8, 16, 0 }, 2, 2, 2, 0x42, false, false,
358 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
359 FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
360 FDP1_CAPTURE | FDP1_OUTPUT },
361 { V4L2_PIX_FMT_NV21M, { 8, 16, 0 }, 2, 2, 2, 0x42, false, true,
362 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
363 FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
364 FDP1_CAPTURE | FDP1_OUTPUT },
365 { V4L2_PIX_FMT_UYVY, { 16, 0, 0 }, 1, 2, 1, 0x47, false, false,
366 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
367 FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
368 FDP1_CAPTURE | FDP1_OUTPUT },
369 { V4L2_PIX_FMT_VYUY, { 16, 0, 0 }, 1, 2, 1, 0x47, false, true,
370 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
371 FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
372 FDP1_CAPTURE | FDP1_OUTPUT },
373 { V4L2_PIX_FMT_YUYV, { 16, 0, 0 }, 1, 2, 1, 0x47, true, false,
374 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
375 FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
376 FDP1_CAPTURE | FDP1_OUTPUT },
377 { V4L2_PIX_FMT_YVYU, { 16, 0, 0 }, 1, 2, 1, 0x47, true, true,
378 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
379 FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
380 FDP1_CAPTURE | FDP1_OUTPUT },
381 { V4L2_PIX_FMT_YUV444M, { 8, 8, 8 }, 3, 1, 1, 0x4a, false, false,
382 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
383 FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
384 FDP1_CAPTURE | FDP1_OUTPUT },
385 { V4L2_PIX_FMT_YVU444M, { 8, 8, 8 }, 3, 1, 1, 0x4a, false, true,
386 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
387 FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
388 FDP1_CAPTURE | FDP1_OUTPUT },
389 { V4L2_PIX_FMT_YUV422M, { 8, 8, 8 }, 3, 2, 1, 0x4b, false, false,
390 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
391 FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
392 FDP1_CAPTURE | FDP1_OUTPUT },
393 { V4L2_PIX_FMT_YVU422M, { 8, 8, 8 }, 3, 2, 1, 0x4b, false, true,
394 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
395 FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
396 FDP1_CAPTURE | FDP1_OUTPUT },
397 { V4L2_PIX_FMT_YUV420M, { 8, 8, 8 }, 3, 2, 2, 0x4c, false, false,
398 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
399 FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
400 FDP1_CAPTURE | FDP1_OUTPUT },
401 { V4L2_PIX_FMT_YVU420M, { 8, 8, 8 }, 3, 2, 2, 0x4c, false, true,
402 FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
403 FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
404 FDP1_CAPTURE | FDP1_OUTPUT },
405};
406
407static int fdp1_fmt_is_rgb(const struct fdp1_fmt *fmt)
408{
409 return fmt->fmt <= 0x1b; /* Last RGB code */
410}
411
412/*
413 * FDP1 Lookup tables range from 0...255 only
414 *
415 * Each table must be less than 256 entries, and all tables
416 * are padded out to 256 entries by duplicating the last value.
417 */
418static const u8 fdp1_diff_adj[] = {
419 0x00, 0x24, 0x43, 0x5e, 0x76, 0x8c, 0x9e, 0xaf,
420 0xbd, 0xc9, 0xd4, 0xdd, 0xe4, 0xea, 0xef, 0xf3,
421 0xf6, 0xf9, 0xfb, 0xfc, 0xfd, 0xfe, 0xfe, 0xff,
422};
423
424static const u8 fdp1_sad_adj[] = {
425 0x00, 0x24, 0x43, 0x5e, 0x76, 0x8c, 0x9e, 0xaf,
426 0xbd, 0xc9, 0xd4, 0xdd, 0xe4, 0xea, 0xef, 0xf3,
427 0xf6, 0xf9, 0xfb, 0xfc, 0xfd, 0xfe, 0xfe, 0xff,
428};
429
430static const u8 fdp1_bld_gain[] = {
431 0x80,
432};
433
434static const u8 fdp1_dif_gain[] = {
435 0x80,
436};
437
438static const u8 fdp1_mdet[] = {
439 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
440 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
441 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
442 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
443 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
444 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
445 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
446 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
447 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
448 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
449 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
450 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
451 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
452 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
453 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
454 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
455 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
456 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
457 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
458 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
459 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
460 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
461 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
462 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
463 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
464 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
465 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
466 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
467 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
468 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
469 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
470 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
471};
472
473/* Per-queue, driver-specific private data */
474struct fdp1_q_data {
475 const struct fdp1_fmt *fmt;
476 struct v4l2_pix_format_mplane format;
477
478 unsigned int vsize;
479 unsigned int stride_y;
480 unsigned int stride_c;
481};
482
483static const struct fdp1_fmt *fdp1_find_format(u32 pixelformat)
484{
485 const struct fdp1_fmt *fmt;
486 unsigned int i;
487
488 for (i = 0; i < ARRAY_SIZE(fdp1_formats); i++) {
489 fmt = &fdp1_formats[i];
490 if (fmt->fourcc == pixelformat)
491 return fmt;
492 }
493
494 return NULL;
495}
496
497enum fdp1_deint_mode {
498 FDP1_PROGRESSIVE = 0, /* Must be zero when !deinterlacing */
499 FDP1_ADAPT2D3D,
500 FDP1_FIXED2D,
501 FDP1_FIXED3D,
502 FDP1_PREVFIELD,
503 FDP1_NEXTFIELD,
504};
505
506#define FDP1_DEINT_MODE_USES_NEXT(mode) \
507 (mode == FDP1_ADAPT2D3D || \
508 mode == FDP1_FIXED3D || \
509 mode == FDP1_NEXTFIELD)
510
511#define FDP1_DEINT_MODE_USES_PREV(mode) \
512 (mode == FDP1_ADAPT2D3D || \
513 mode == FDP1_FIXED3D || \
514 mode == FDP1_PREVFIELD)
515
516/*
517 * FDP1 operates on potentially 3 fields, which are tracked
518 * from the VB buffers using this context structure.
519 * Will always be a field or a full frame, never two fields.
520 */
521struct fdp1_field_buffer {
522 struct vb2_v4l2_buffer *vb;
523 dma_addr_t addrs[3];
524
525 /* Should be NONE:TOP:BOTTOM only */
526 enum v4l2_field field;
527
528 /* Flag to indicate this is the last field in the vb */
529 bool last_field;
530
531 /* Buffer queue lists */
532 struct list_head list;
533};
534
535struct fdp1_buffer {
536 struct v4l2_m2m_buffer m2m_buf;
537 struct fdp1_field_buffer fields[2];
538 unsigned int num_fields;
539};
540
541static inline struct fdp1_buffer *to_fdp1_buffer(struct vb2_v4l2_buffer *vb)
542{
543 return container_of(vb, struct fdp1_buffer, m2m_buf.vb);
544}
545
546struct fdp1_job {
547 struct fdp1_field_buffer *previous;
548 struct fdp1_field_buffer *active;
549 struct fdp1_field_buffer *next;
550 struct fdp1_field_buffer *dst;
551
552 /* A job can only be on one list at a time */
553 struct list_head list;
554};
555
556struct fdp1_dev {
557 struct v4l2_device v4l2_dev;
558 struct video_device vfd;
559
560 struct mutex dev_mutex;
561 spinlock_t irqlock;
562 spinlock_t device_process_lock;
563
564 void __iomem *regs;
565 unsigned int irq;
566 struct device *dev;
567
568 /* Job Queues */
569 struct fdp1_job jobs[FDP1_NUMBER_JOBS];
570 struct list_head free_job_list;
571 struct list_head queued_job_list;
572 struct list_head hw_job_list;
573
574 unsigned int clk_rate;
575
576 struct rcar_fcp_device *fcp;
577 struct v4l2_m2m_dev *m2m_dev;
578};
579
580struct fdp1_ctx {
581 struct v4l2_fh fh;
582 struct fdp1_dev *fdp1;
583
584 struct v4l2_ctrl_handler hdl;
585 unsigned int sequence;
586
587 /* Processed buffers in this transaction */
588 u8 num_processed;
589
590 /* Transaction length (i.e. how many buffers per transaction) */
591 u32 translen;
592
593 /* Abort requested by m2m */
594 int aborting;
595
596 /* Deinterlace processing mode */
597 enum fdp1_deint_mode deint_mode;
598
599 /*
600 * Adaptive 2D/3D mode uses a shared mask
601 * This is allocated at streamon, if the ADAPT2D3D mode
602 * is requested
603 */
604 unsigned int smsk_size;
605 dma_addr_t smsk_addr[2];
606 void *smsk_cpu;
607
608 /* Capture pipeline, can specify an alpha value
609 * for supported formats. 0-255 only
610 */
611 unsigned char alpha;
612
613 /* Source and destination queue data */
614 struct fdp1_q_data out_q; /* HW Source */
615 struct fdp1_q_data cap_q; /* HW Destination */
616
617 /*
618 * Field Queues
619 * Interlaced fields are used on 3 occasions, and tracked in this list.
620 *
621 * V4L2 Buffers are tracked inside the fdp1_buffer
622 * and released when the last 'field' completes
623 */
624 struct list_head fields_queue;
625 unsigned int buffers_queued;
626
627 /*
628 * For de-interlacing we need to track our previous buffer
629 * while preparing our job lists.
630 */
631 struct fdp1_field_buffer *previous;
632};
633
634static inline struct fdp1_ctx *fh_to_ctx(struct v4l2_fh *fh)
635{
636 return container_of(fh, struct fdp1_ctx, fh);
637}
638
639static struct fdp1_q_data *get_q_data(struct fdp1_ctx *ctx,
640 enum v4l2_buf_type type)
641{
642 if (V4L2_TYPE_IS_OUTPUT(type))
643 return &ctx->out_q;
644 else
645 return &ctx->cap_q;
646}
647
648/*
649 * list_remove_job: Take the first item off the specified job list
650 *
651 * Returns: pointer to a job, or NULL if the list is empty.
652 */
653static struct fdp1_job *list_remove_job(struct fdp1_dev *fdp1,
654 struct list_head *list)
655{
656 struct fdp1_job *job;
657 unsigned long flags;
658
659 spin_lock_irqsave(&fdp1->irqlock, flags);
660 job = list_first_entry_or_null(list, struct fdp1_job, list);
661 if (job)
662 list_del(&job->list);
663 spin_unlock_irqrestore(&fdp1->irqlock, flags);
664
665 return job;
666}
667
668/*
669 * list_add_job: Add a job to the specified job list
670 *
671 * Returns: void - always succeeds
672 */
673static void list_add_job(struct fdp1_dev *fdp1,
674 struct list_head *list,
675 struct fdp1_job *job)
676{
677 unsigned long flags;
678
679 spin_lock_irqsave(&fdp1->irqlock, flags);
680 list_add_tail(&job->list, list);
681 spin_unlock_irqrestore(&fdp1->irqlock, flags);
682}
683
684static struct fdp1_job *fdp1_job_alloc(struct fdp1_dev *fdp1)
685{
686 return list_remove_job(fdp1, &fdp1->free_job_list);
687}
688
689static void fdp1_job_free(struct fdp1_dev *fdp1, struct fdp1_job *job)
690{
691 /* Ensure that all residue from previous jobs is gone */
692 memset(job, 0, sizeof(struct fdp1_job));
693
694 list_add_job(fdp1, &fdp1->free_job_list, job);
695}
696
697static void queue_job(struct fdp1_dev *fdp1, struct fdp1_job *job)
698{
699 list_add_job(fdp1, &fdp1->queued_job_list, job);
700}
701
702static struct fdp1_job *get_queued_job(struct fdp1_dev *fdp1)
703{
704 return list_remove_job(fdp1, &fdp1->queued_job_list);
705}
706
707static void queue_hw_job(struct fdp1_dev *fdp1, struct fdp1_job *job)
708{
709 list_add_job(fdp1, &fdp1->hw_job_list, job);
710}
711
712static struct fdp1_job *get_hw_queued_job(struct fdp1_dev *fdp1)
713{
714 return list_remove_job(fdp1, &fdp1->hw_job_list);
715}
716
717/*
718 * Buffer lists handling
719 */
720static void fdp1_field_complete(struct fdp1_ctx *ctx,
721 struct fdp1_field_buffer *fbuf)
722{
723 /* job->previous may be on the first field */
724 if (!fbuf)
725 return;
726
727 if (fbuf->last_field)
728 v4l2_m2m_buf_done(fbuf->vb, VB2_BUF_STATE_DONE);
729}
730
731static void fdp1_queue_field(struct fdp1_ctx *ctx,
732 struct fdp1_field_buffer *fbuf)
733{
734 unsigned long flags;
735
736 spin_lock_irqsave(&ctx->fdp1->irqlock, flags);
737 list_add_tail(&fbuf->list, &ctx->fields_queue);
738 spin_unlock_irqrestore(&ctx->fdp1->irqlock, flags);
739
740 ctx->buffers_queued++;
741}
742
743static struct fdp1_field_buffer *fdp1_dequeue_field(struct fdp1_ctx *ctx)
744{
745 struct fdp1_field_buffer *fbuf;
746 unsigned long flags;
747
748 ctx->buffers_queued--;
749
750 spin_lock_irqsave(&ctx->fdp1->irqlock, flags);
751 fbuf = list_first_entry_or_null(&ctx->fields_queue,
752 struct fdp1_field_buffer, list);
753 if (fbuf)
754 list_del(&fbuf->list);
755 spin_unlock_irqrestore(&ctx->fdp1->irqlock, flags);
756
757 return fbuf;
758}
759
760/*
761 * Return the next field in the queue - or NULL,
762 * without removing the item from the list
763 */
764static struct fdp1_field_buffer *fdp1_peek_queued_field(struct fdp1_ctx *ctx)
765{
766 struct fdp1_field_buffer *fbuf;
767 unsigned long flags;
768
769 spin_lock_irqsave(&ctx->fdp1->irqlock, flags);
770 fbuf = list_first_entry_or_null(&ctx->fields_queue,
771 struct fdp1_field_buffer, list);
772 spin_unlock_irqrestore(&ctx->fdp1->irqlock, flags);
773
774 return fbuf;
775}
776
777static u32 fdp1_read(struct fdp1_dev *fdp1, unsigned int reg)
778{
779 u32 value = ioread32(fdp1->regs + reg);
780
781 if (debug >= 2)
782 dprintk(fdp1, "Read 0x%08x from 0x%04x\n", value, reg);
783
784 return value;
785}
786
787static void fdp1_write(struct fdp1_dev *fdp1, u32 val, unsigned int reg)
788{
789 if (debug >= 2)
790 dprintk(fdp1, "Write 0x%08x to 0x%04x\n", val, reg);
791
792 iowrite32(val, fdp1->regs + reg);
793}
794
795/* IPC registers are to be programmed with constant values */
796static void fdp1_set_ipc_dli(struct fdp1_ctx *ctx)
797{
798 struct fdp1_dev *fdp1 = ctx->fdp1;
799
800 fdp1_write(fdp1, FD1_IPC_SMSK_THRESH_CONST, FD1_IPC_SMSK_THRESH);
801 fdp1_write(fdp1, FD1_IPC_COMB_DET_CONST, FD1_IPC_COMB_DET);
802 fdp1_write(fdp1, FD1_IPC_MOTDEC_CONST, FD1_IPC_MOTDEC);
803
804 fdp1_write(fdp1, FD1_IPC_DLI_BLEND_CONST, FD1_IPC_DLI_BLEND);
805 fdp1_write(fdp1, FD1_IPC_DLI_HGAIN_CONST, FD1_IPC_DLI_HGAIN);
806 fdp1_write(fdp1, FD1_IPC_DLI_SPRS_CONST, FD1_IPC_DLI_SPRS);
807 fdp1_write(fdp1, FD1_IPC_DLI_ANGLE_CONST, FD1_IPC_DLI_ANGLE);
808 fdp1_write(fdp1, FD1_IPC_DLI_ISOPIX0_CONST, FD1_IPC_DLI_ISOPIX0);
809 fdp1_write(fdp1, FD1_IPC_DLI_ISOPIX1_CONST, FD1_IPC_DLI_ISOPIX1);
810}
811
812
813static void fdp1_set_ipc_sensor(struct fdp1_ctx *ctx)
814{
815 struct fdp1_dev *fdp1 = ctx->fdp1;
816 struct fdp1_q_data *src_q_data = &ctx->out_q;
817 unsigned int x0, x1;
818 unsigned int hsize = src_q_data->format.width;
819 unsigned int vsize = src_q_data->format.height;
820
821 x0 = hsize / 3;
822 x1 = 2 * hsize / 3;
823
824 fdp1_write(fdp1, FD1_IPC_SENSOR_TH0_CONST, FD1_IPC_SENSOR_TH0);
825 fdp1_write(fdp1, FD1_IPC_SENSOR_TH1_CONST, FD1_IPC_SENSOR_TH1);
826 fdp1_write(fdp1, FD1_IPC_SENSOR_CTL0_CONST, FD1_IPC_SENSOR_CTL0);
827 fdp1_write(fdp1, FD1_IPC_SENSOR_CTL1_CONST, FD1_IPC_SENSOR_CTL1);
828
829 fdp1_write(fdp1, ((hsize - 1) << FD1_IPC_SENSOR_CTL2_X_SHIFT) |
830 ((vsize - 1) << FD1_IPC_SENSOR_CTL2_Y_SHIFT),
831 FD1_IPC_SENSOR_CTL2);
832
833 fdp1_write(fdp1, (x0 << FD1_IPC_SENSOR_CTL3_0_SHIFT) |
834 (x1 << FD1_IPC_SENSOR_CTL3_1_SHIFT),
835 FD1_IPC_SENSOR_CTL3);
836}
837
838/*
839 * fdp1_write_lut: Write a padded LUT to the hw
840 *
841 * FDP1 uses constant data for de-interlacing processing,
842 * with large tables. These hardware tables are all 256 bytes
843 * long, however they often contain repeated data at the end.
844 *
845 * The last byte of the table is written to all remaining entries.
846 */
847static void fdp1_write_lut(struct fdp1_dev *fdp1, const u8 *lut,
848 unsigned int len, unsigned int base)
849{
850 unsigned int i;
851 u8 pad;
852
853 /* Tables larger than the hw are clipped */
854 len = min(len, 256u);
855
856 for (i = 0; i < len; i++)
857 fdp1_write(fdp1, lut[i], base + (i*4));
858
859 /* Tables are padded with the last entry */
860 pad = lut[i-1];
861
862 for (; i < 256; i++)
863 fdp1_write(fdp1, pad, base + (i*4));
864}
865
866static void fdp1_set_lut(struct fdp1_dev *fdp1)
867{
868 fdp1_write_lut(fdp1, fdp1_diff_adj, ARRAY_SIZE(fdp1_diff_adj),
869 FD1_LUT_DIF_ADJ);
870 fdp1_write_lut(fdp1, fdp1_sad_adj, ARRAY_SIZE(fdp1_sad_adj),
871 FD1_LUT_SAD_ADJ);
872 fdp1_write_lut(fdp1, fdp1_bld_gain, ARRAY_SIZE(fdp1_bld_gain),
873 FD1_LUT_BLD_GAIN);
874 fdp1_write_lut(fdp1, fdp1_dif_gain, ARRAY_SIZE(fdp1_dif_gain),
875 FD1_LUT_DIF_GAIN);
876 fdp1_write_lut(fdp1, fdp1_mdet, ARRAY_SIZE(fdp1_mdet),
877 FD1_LUT_MDET);
878}
879
880static void fdp1_configure_rpf(struct fdp1_ctx *ctx,
881 struct fdp1_job *job)
882{
883 struct fdp1_dev *fdp1 = ctx->fdp1;
884 u32 picture_size;
885 u32 pstride;
886 u32 format;
887 u32 smsk_addr;
888
889 struct fdp1_q_data *q_data = &ctx->out_q;
890
891 /* Picture size is common to Source and Destination frames */
892 picture_size = (q_data->format.width << FD1_RPF_SIZE_H_SHIFT)
893 | (q_data->vsize << FD1_RPF_SIZE_V_SHIFT);
894
895 /* Strides */
896 pstride = q_data->stride_y << FD1_RPF_PSTRIDE_Y_SHIFT;
897 if (q_data->format.num_planes > 1)
898 pstride |= q_data->stride_c << FD1_RPF_PSTRIDE_C_SHIFT;
899
900 /* Format control */
901 format = q_data->fmt->fmt;
902 if (q_data->fmt->swap_yc)
903 format |= FD1_RPF_FORMAT_RSPYCS;
904
905 if (q_data->fmt->swap_uv)
906 format |= FD1_RPF_FORMAT_RSPUVS;
907
908 if (job->active->field == V4L2_FIELD_BOTTOM) {
909 format |= FD1_RPF_FORMAT_CF; /* Set for Bottom field */
910 smsk_addr = ctx->smsk_addr[0];
911 } else {
912 smsk_addr = ctx->smsk_addr[1];
913 }
914
915 /* Deint mode is non-zero when deinterlacing */
916 if (ctx->deint_mode)
917 format |= FD1_RPF_FORMAT_CIPM;
918
919 fdp1_write(fdp1, format, FD1_RPF_FORMAT);
920 fdp1_write(fdp1, q_data->fmt->swap, FD1_RPF_SWAP);
921 fdp1_write(fdp1, picture_size, FD1_RPF_SIZE);
922 fdp1_write(fdp1, pstride, FD1_RPF_PSTRIDE);
923 fdp1_write(fdp1, smsk_addr, FD1_RPF_SMSK_ADDR);
924
925 /* Previous Field Channel (CH0) */
926 if (job->previous)
927 fdp1_write(fdp1, job->previous->addrs[0], FD1_RPF0_ADDR_Y);
928
929 /* Current Field Channel (CH1) */
930 fdp1_write(fdp1, job->active->addrs[0], FD1_RPF1_ADDR_Y);
931 fdp1_write(fdp1, job->active->addrs[1], FD1_RPF1_ADDR_C0);
932 fdp1_write(fdp1, job->active->addrs[2], FD1_RPF1_ADDR_C1);
933
934 /* Next Field Channel (CH2) */
935 if (job->next)
936 fdp1_write(fdp1, job->next->addrs[0], FD1_RPF2_ADDR_Y);
937}
938
939static void fdp1_configure_wpf(struct fdp1_ctx *ctx,
940 struct fdp1_job *job)
941{
942 struct fdp1_dev *fdp1 = ctx->fdp1;
943 struct fdp1_q_data *src_q_data = &ctx->out_q;
944 struct fdp1_q_data *q_data = &ctx->cap_q;
945 u32 pstride;
946 u32 format;
947 u32 swap;
948 u32 rndctl;
949
950 pstride = q_data->format.plane_fmt[0].bytesperline
951 << FD1_WPF_PSTRIDE_Y_SHIFT;
952
953 if (q_data->format.num_planes > 1)
954 pstride |= q_data->format.plane_fmt[1].bytesperline
955 << FD1_WPF_PSTRIDE_C_SHIFT;
956
957 format = q_data->fmt->fmt; /* Output Format Code */
958
959 if (q_data->fmt->swap_yc)
960 format |= FD1_WPF_FORMAT_WSPYCS;
961
962 if (q_data->fmt->swap_uv)
963 format |= FD1_WPF_FORMAT_WSPUVS;
964
965 if (fdp1_fmt_is_rgb(q_data->fmt)) {
966 /* Enable Colour Space conversion */
967 format |= FD1_WPF_FORMAT_CSC;
968
969 /* Set WRTM */
970 if (src_q_data->format.ycbcr_enc == V4L2_YCBCR_ENC_709)
971 format |= FD1_WPF_FORMAT_WRTM_709_16;
972 else if (src_q_data->format.quantization ==
973 V4L2_QUANTIZATION_FULL_RANGE)
974 format |= FD1_WPF_FORMAT_WRTM_601_0;
975 else
976 format |= FD1_WPF_FORMAT_WRTM_601_16;
977 }
978
979 /* Set an alpha value into the Pad Value */
980 format |= ctx->alpha << FD1_WPF_FORMAT_PDV_SHIFT;
981
982 /* Determine picture rounding and clipping */
983 rndctl = FD1_WPF_RNDCTL_CBRM; /* Rounding Off */
984 rndctl |= FD1_WPF_RNDCTL_CLMD_NOCLIP;
985
986 /* WPF Swap needs both ISWAP and OSWAP setting */
987 swap = q_data->fmt->swap << FD1_WPF_SWAP_OSWAP_SHIFT;
988 swap |= src_q_data->fmt->swap << FD1_WPF_SWAP_SSWAP_SHIFT;
989
990 fdp1_write(fdp1, format, FD1_WPF_FORMAT);
991 fdp1_write(fdp1, rndctl, FD1_WPF_RNDCTL);
992 fdp1_write(fdp1, swap, FD1_WPF_SWAP);
993 fdp1_write(fdp1, pstride, FD1_WPF_PSTRIDE);
994
995 fdp1_write(fdp1, job->dst->addrs[0], FD1_WPF_ADDR_Y);
996 fdp1_write(fdp1, job->dst->addrs[1], FD1_WPF_ADDR_C0);
997 fdp1_write(fdp1, job->dst->addrs[2], FD1_WPF_ADDR_C1);
998}
999
1000static void fdp1_configure_deint_mode(struct fdp1_ctx *ctx,
1001 struct fdp1_job *job)
1002{
1003 struct fdp1_dev *fdp1 = ctx->fdp1;
1004 u32 opmode = FD1_CTL_OPMODE_VIMD_NOINTERRUPT;
1005 u32 ipcmode = FD1_IPC_MODE_DLI; /* Always set */
1006 u32 channels = FD1_CTL_CHACT_WR | FD1_CTL_CHACT_RD1; /* Always on */
1007
1008 /* De-interlacing Mode */
1009 switch (ctx->deint_mode) {
1010 default:
1011 case FDP1_PROGRESSIVE:
1012 dprintk(fdp1, "Progressive Mode\n");
1013 opmode |= FD1_CTL_OPMODE_PRG;
1014 ipcmode |= FD1_IPC_MODE_DIM_FIXED2D;
1015 break;
1016 case FDP1_ADAPT2D3D:
1017 dprintk(fdp1, "Adapt2D3D Mode\n");
1018 if (ctx->sequence == 0 || ctx->aborting)
1019 ipcmode |= FD1_IPC_MODE_DIM_FIXED2D;
1020 else
1021 ipcmode |= FD1_IPC_MODE_DIM_ADAPT2D3D;
1022
1023 if (ctx->sequence > 1) {
1024 channels |= FD1_CTL_CHACT_SMW;
1025 channels |= FD1_CTL_CHACT_RD0 | FD1_CTL_CHACT_RD2;
1026 }
1027
1028 if (ctx->sequence > 2)
1029 channels |= FD1_CTL_CHACT_SMR;
1030
1031 break;
1032 case FDP1_FIXED3D:
1033 dprintk(fdp1, "Fixed 3D Mode\n");
1034 ipcmode |= FD1_IPC_MODE_DIM_FIXED3D;
1035 /* Except for first and last frame, enable all channels */
1036 if (!(ctx->sequence == 0 || ctx->aborting))
1037 channels |= FD1_CTL_CHACT_RD0 | FD1_CTL_CHACT_RD2;
1038 break;
1039 case FDP1_FIXED2D:
1040 dprintk(fdp1, "Fixed 2D Mode\n");
1041 ipcmode |= FD1_IPC_MODE_DIM_FIXED2D;
1042 /* No extra channels enabled */
1043 break;
1044 case FDP1_PREVFIELD:
1045 dprintk(fdp1, "Previous Field Mode\n");
1046 ipcmode |= FD1_IPC_MODE_DIM_PREVFIELD;
1047 channels |= FD1_CTL_CHACT_RD0; /* Previous */
1048 break;
1049 case FDP1_NEXTFIELD:
1050 dprintk(fdp1, "Next Field Mode\n");
1051 ipcmode |= FD1_IPC_MODE_DIM_NEXTFIELD;
1052 channels |= FD1_CTL_CHACT_RD2; /* Next */
1053 break;
1054 }
1055
1056 fdp1_write(fdp1, channels, FD1_CTL_CHACT);
1057 fdp1_write(fdp1, opmode, FD1_CTL_OPMODE);
1058 fdp1_write(fdp1, ipcmode, FD1_IPC_MODE);
1059}
1060
1061/*
1062 * fdp1_device_process() - Run the hardware
1063 *
1064 * Configure and start the hardware to generate a single frame
1065 * of output given our input parameters.
1066 */
1067static int fdp1_device_process(struct fdp1_ctx *ctx)
1068
1069{
1070 struct fdp1_dev *fdp1 = ctx->fdp1;
1071 struct fdp1_job *job;
1072 unsigned long flags;
1073
1074 spin_lock_irqsave(&fdp1->device_process_lock, flags);
1075
1076 /* Get a job to process */
1077 job = get_queued_job(fdp1);
1078 if (!job) {
1079 /*
1080 * VINT can call us to see if we can queue another job.
1081 * If we have no work to do, we simply return.
1082 */
1083 spin_unlock_irqrestore(&fdp1->device_process_lock, flags);
1084 return 0;
1085 }
1086
1087 /* First Frame only? ... */
1088 fdp1_write(fdp1, FD1_CTL_CLKCTRL_CSTP_N, FD1_CTL_CLKCTRL);
1089
1090 /* Set the mode, and configuration */
1091 fdp1_configure_deint_mode(ctx, job);
1092
1093 /* DLI Static Configuration */
1094 fdp1_set_ipc_dli(ctx);
1095
1096 /* Sensor Configuration */
1097 fdp1_set_ipc_sensor(ctx);
1098
1099 /* Setup the source picture */
1100 fdp1_configure_rpf(ctx, job);
1101
1102 /* Setup the destination picture */
1103 fdp1_configure_wpf(ctx, job);
1104
1105 /* Line Memory Pixel Number Register for linear access */
1106 fdp1_write(fdp1, FD1_IPC_LMEM_LINEAR, FD1_IPC_LMEM);
1107
1108 /* Enable Interrupts */
1109 fdp1_write(fdp1, FD1_CTL_IRQ_MASK, FD1_CTL_IRQENB);
1110
1111 /* Finally, the Immediate Registers */
1112
1113 /* This job is now in the HW queue */
1114 queue_hw_job(fdp1, job);
1115
1116 /* Start the command */
1117 fdp1_write(fdp1, FD1_CTL_CMD_STRCMD, FD1_CTL_CMD);
1118
1119 /* Registers will update to HW at next VINT */
1120 fdp1_write(fdp1, FD1_CTL_REGEND_REGEND, FD1_CTL_REGEND);
1121
1122 /* Enable VINT Generator */
1123 fdp1_write(fdp1, FD1_CTL_SGCMD_SGEN, FD1_CTL_SGCMD);
1124
1125 spin_unlock_irqrestore(&fdp1->device_process_lock, flags);
1126
1127 return 0;
1128}
1129
1130/*
1131 * mem2mem callbacks
1132 */
1133
1134/**
1135 * job_ready() - check whether an instance is ready to be scheduled to run
1136 */
1137static int fdp1_m2m_job_ready(void *priv)
1138{
1139 struct fdp1_ctx *ctx = priv;
1140 struct fdp1_q_data *src_q_data = &ctx->out_q;
1141 int srcbufs = 1;
1142 int dstbufs = 1;
1143
1144 dprintk(ctx->fdp1, "+ Src: %d : Dst: %d\n",
1145 v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx),
1146 v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx));
1147
1148 /* One output buffer is required for each field */
1149 if (V4L2_FIELD_HAS_BOTH(src_q_data->format.field))
1150 dstbufs = 2;
1151
1152 if (v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx) < srcbufs
1153 || v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx) < dstbufs) {
1154 dprintk(ctx->fdp1, "Not enough buffers available\n");
1155 return 0;
1156 }
1157
1158 return 1;
1159}
1160
1161static void fdp1_m2m_job_abort(void *priv)
1162{
1163 struct fdp1_ctx *ctx = priv;
1164
1165 dprintk(ctx->fdp1, "+\n");
1166
1167 /* Will cancel the transaction in the next interrupt handler */
1168 ctx->aborting = 1;
1169
1170 /* Immediate abort sequence */
1171 fdp1_write(ctx->fdp1, 0, FD1_CTL_SGCMD);
1172 fdp1_write(ctx->fdp1, FD1_CTL_SRESET_SRST, FD1_CTL_SRESET);
1173}
1174
1175/*
1176 * fdp1_prepare_job: Prepare and queue a new job for a single action of work
1177 *
1178 * Prepare the next field, (or frame in progressive) and an output
1179 * buffer for the hardware to perform a single operation.
1180 */
1181static struct fdp1_job *fdp1_prepare_job(struct fdp1_ctx *ctx)
1182{
1183 struct vb2_v4l2_buffer *vbuf;
1184 struct fdp1_buffer *fbuf;
1185 struct fdp1_dev *fdp1 = ctx->fdp1;
1186 struct fdp1_job *job;
1187 unsigned int buffers_required = 1;
1188
1189 dprintk(fdp1, "+\n");
1190
1191 if (FDP1_DEINT_MODE_USES_NEXT(ctx->deint_mode))
1192 buffers_required = 2;
1193
1194 if (ctx->buffers_queued < buffers_required)
1195 return NULL;
1196
1197 job = fdp1_job_alloc(fdp1);
1198 if (!job) {
1199 dprintk(fdp1, "No free jobs currently available\n");
1200 return NULL;
1201 }
1202
1203 job->active = fdp1_dequeue_field(ctx);
1204 if (!job->active) {
1205 /* Buffer check should prevent this ever happening */
1206 dprintk(fdp1, "No input buffers currently available\n");
1207
1208 fdp1_job_free(fdp1, job);
1209 return NULL;
1210 }
1211
1212 dprintk(fdp1, "+ Buffer en-route...\n");
1213
1214 /* Source buffers have been prepared on our buffer_queue
1215 * Prepare our Output buffer
1216 */
1217 vbuf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
1218 fbuf = to_fdp1_buffer(vbuf);
1219 job->dst = &fbuf->fields[0];
1220
1221 job->active->vb->sequence = ctx->sequence;
1222 job->dst->vb->sequence = ctx->sequence;
1223 ctx->sequence++;
1224
1225 if (FDP1_DEINT_MODE_USES_PREV(ctx->deint_mode)) {
1226 job->previous = ctx->previous;
1227
1228 /* Active buffer becomes the next job's previous buffer */
1229 ctx->previous = job->active;
1230 }
1231
1232 if (FDP1_DEINT_MODE_USES_NEXT(ctx->deint_mode)) {
1233 /* Must be called after 'active' is dequeued */
1234 job->next = fdp1_peek_queued_field(ctx);
1235 }
1236
1237 /* Transfer timestamps and flags from src->dst */
1238
1239 job->dst->vb->vb2_buf.timestamp = job->active->vb->vb2_buf.timestamp;
1240
1241 job->dst->vb->flags = job->active->vb->flags &
1242 V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
1243
1244 /* Ideally, the frame-end function will just 'check' to see
1245 * if there are more jobs instead
1246 */
1247 ctx->translen++;
1248
1249 /* Finally, Put this job on the processing queue */
1250 queue_job(fdp1, job);
1251
1252 dprintk(fdp1, "Job Queued translen = %d\n", ctx->translen);
1253
1254 return job;
1255}
1256
1257/* fdp1_m2m_device_run() - prepares and starts the device for an M2M task
1258 *
1259 * A single input buffer is taken and serialised into our fdp1_buffer
1260 * queue. The queue is then processed to create as many jobs as possible
1261 * from our available input.
1262 */
1263static void fdp1_m2m_device_run(void *priv)
1264{
1265 struct fdp1_ctx *ctx = priv;
1266 struct fdp1_dev *fdp1 = ctx->fdp1;
1267 struct vb2_v4l2_buffer *src_vb;
1268 struct fdp1_buffer *buf;
1269 unsigned int i;
1270
1271 dprintk(fdp1, "+\n");
1272
1273 ctx->translen = 0;
1274
1275 /* Get our incoming buffer of either one or two fields, or one frame */
1276 src_vb = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
1277 buf = to_fdp1_buffer(src_vb);
1278
1279 for (i = 0; i < buf->num_fields; i++) {
1280 struct fdp1_field_buffer *fbuf = &buf->fields[i];
1281
1282 fdp1_queue_field(ctx, fbuf);
1283 dprintk(fdp1, "Queued Buffer [%d] last_field:%d\n",
1284 i, fbuf->last_field);
1285 }
1286
1287 /* Queue as many jobs as our data provides for */
1288 while (fdp1_prepare_job(ctx))
1289 ;
1290
1291 if (ctx->translen == 0) {
1292 dprintk(fdp1, "No jobs were processed. M2M action complete\n");
1293 v4l2_m2m_job_finish(fdp1->m2m_dev, ctx->fh.m2m_ctx);
1294 return;
1295 }
1296
1297 /* Kick the job processing action */
1298 fdp1_device_process(ctx);
1299}
1300
1301/*
1302 * device_frame_end:
1303 *
1304 * Handles the M2M level after a buffer completion event.
1305 */
1306static void device_frame_end(struct fdp1_dev *fdp1,
1307 enum vb2_buffer_state state)
1308{
1309 struct fdp1_ctx *ctx;
1310 unsigned long flags;
1311 struct fdp1_job *job = get_hw_queued_job(fdp1);
1312
1313 dprintk(fdp1, "+\n");
1314
1315 ctx = v4l2_m2m_get_curr_priv(fdp1->m2m_dev);
1316
1317 if (ctx == NULL) {
1318 v4l2_err(&fdp1->v4l2_dev,
1319 "Instance released before the end of transaction\n");
1320 return;
1321 }
1322
1323 ctx->num_processed++;
1324
1325 /*
1326 * fdp1_field_complete will call buf_done only when the last vb2_buffer
1327 * reference is complete
1328 */
1329 if (FDP1_DEINT_MODE_USES_PREV(ctx->deint_mode))
1330 fdp1_field_complete(ctx, job->previous);
1331 else
1332 fdp1_field_complete(ctx, job->active);
1333
1334 spin_lock_irqsave(&fdp1->irqlock, flags);
1335 v4l2_m2m_buf_done(job->dst->vb, state);
1336 job->dst = NULL;
1337 spin_unlock_irqrestore(&fdp1->irqlock, flags);
1338
1339 /* Move this job back to the free job list */
1340 fdp1_job_free(fdp1, job);
1341
1342 dprintk(fdp1, "curr_ctx->num_processed %d curr_ctx->translen %d\n",
1343 ctx->num_processed, ctx->translen);
1344
1345 if (ctx->num_processed == ctx->translen ||
1346 ctx->aborting) {
1347 dprintk(ctx->fdp1, "Finishing transaction\n");
1348 ctx->num_processed = 0;
1349 v4l2_m2m_job_finish(fdp1->m2m_dev, ctx->fh.m2m_ctx);
1350 } else {
1351 /*
1352 * For pipelined performance support, this would
1353 * be called from a VINT handler
1354 */
1355 fdp1_device_process(ctx);
1356 }
1357}
1358
1359/*
1360 * video ioctls
1361 */
1362static int fdp1_vidioc_querycap(struct file *file, void *priv,
1363 struct v4l2_capability *cap)
1364{
1365 strlcpy(cap->driver, DRIVER_NAME, sizeof(cap->driver));
1366 strlcpy(cap->card, DRIVER_NAME, sizeof(cap->card));
1367 snprintf(cap->bus_info, sizeof(cap->bus_info),
1368 "platform:%s", DRIVER_NAME);
1369 return 0;
1370}
1371
1372static int fdp1_enum_fmt(struct v4l2_fmtdesc *f, u32 type)
1373{
1374 unsigned int i, num;
1375
1376 num = 0;
1377
1378 for (i = 0; i < ARRAY_SIZE(fdp1_formats); ++i) {
1379 if (fdp1_formats[i].types & type) {
1380 if (num == f->index)
1381 break;
1382 ++num;
1383 }
1384 }
1385
1386 /* Format not found */
1387 if (i >= ARRAY_SIZE(fdp1_formats))
1388 return -EINVAL;
1389
1390 /* Format found */
1391 f->pixelformat = fdp1_formats[i].fourcc;
1392
1393 return 0;
1394}
1395
1396static int fdp1_enum_fmt_vid_cap(struct file *file, void *priv,
1397 struct v4l2_fmtdesc *f)
1398{
1399 return fdp1_enum_fmt(f, FDP1_CAPTURE);
1400}
1401
1402static int fdp1_enum_fmt_vid_out(struct file *file, void *priv,
1403 struct v4l2_fmtdesc *f)
1404{
1405 return fdp1_enum_fmt(f, FDP1_OUTPUT);
1406}
1407
1408static int fdp1_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
1409{
1410 struct fdp1_q_data *q_data;
1411 struct fdp1_ctx *ctx = fh_to_ctx(priv);
1412
1413 if (!v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type))
1414 return -EINVAL;
1415
1416 q_data = get_q_data(ctx, f->type);
1417 f->fmt.pix_mp = q_data->format;
1418
1419 return 0;
1420}
1421
1422static void fdp1_compute_stride(struct v4l2_pix_format_mplane *pix,
1423 const struct fdp1_fmt *fmt)
1424{
1425 unsigned int i;
1426
1427 /* Compute and clamp the stride and image size. */
1428 for (i = 0; i < min_t(unsigned int, fmt->num_planes, 2U); ++i) {
1429 unsigned int hsub = i > 0 ? fmt->hsub : 1;
1430 unsigned int vsub = i > 0 ? fmt->vsub : 1;
1431 /* From VSP : TODO: Confirm alignment limits for FDP1 */
1432 unsigned int align = 128;
1433 unsigned int bpl;
1434
1435 bpl = clamp_t(unsigned int, pix->plane_fmt[i].bytesperline,
1436 pix->width / hsub * fmt->bpp[i] / 8,
1437 round_down(FDP1_MAX_STRIDE, align));
1438
1439 pix->plane_fmt[i].bytesperline = round_up(bpl, align);
1440 pix->plane_fmt[i].sizeimage = pix->plane_fmt[i].bytesperline
1441 * pix->height / vsub;
1442
1443 memset(pix->plane_fmt[i].reserved, 0,
1444 sizeof(pix->plane_fmt[i].reserved));
1445 }
1446
1447 if (fmt->num_planes == 3) {
1448 /* The two chroma planes must have the same stride. */
1449 pix->plane_fmt[2].bytesperline = pix->plane_fmt[1].bytesperline;
1450 pix->plane_fmt[2].sizeimage = pix->plane_fmt[1].sizeimage;
1451
1452 memset(pix->plane_fmt[2].reserved, 0,
1453 sizeof(pix->plane_fmt[2].reserved));
1454 }
1455}
1456
1457static void fdp1_try_fmt_output(struct fdp1_ctx *ctx,
1458 const struct fdp1_fmt **fmtinfo,
1459 struct v4l2_pix_format_mplane *pix)
1460{
1461 const struct fdp1_fmt *fmt;
1462 unsigned int width;
1463 unsigned int height;
1464
1465 /* Validate the pixel format to ensure the output queue supports it. */
1466 fmt = fdp1_find_format(pix->pixelformat);
1467 if (!fmt || !(fmt->types & FDP1_OUTPUT))
1468 fmt = fdp1_find_format(V4L2_PIX_FMT_YUYV);
1469
1470 if (fmtinfo)
1471 *fmtinfo = fmt;
1472
1473 pix->pixelformat = fmt->fourcc;
1474 pix->num_planes = fmt->num_planes;
1475
1476 /*
1477 * Progressive video and all interlaced field orders are acceptable.
1478 * Default to V4L2_FIELD_INTERLACED.
1479 */
1480 if (pix->field != V4L2_FIELD_NONE &&
1481 pix->field != V4L2_FIELD_ALTERNATE &&
1482 !V4L2_FIELD_HAS_BOTH(pix->field))
1483 pix->field = V4L2_FIELD_INTERLACED;
1484
1485 /*
1486 * The deinterlacer doesn't care about the colorspace, accept all values
1487 * and default to V4L2_COLORSPACE_SMPTE170M. The YUV to RGB conversion
1488 * at the output of the deinterlacer supports a subset of encodings and
1489 * quantization methods and will only be available when the colorspace
1490 * allows it.
1491 */
1492 if (pix->colorspace == V4L2_COLORSPACE_DEFAULT)
1493 pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
1494
1495 /*
1496 * Align the width and height for YUV 4:2:2 and 4:2:0 formats and clamp
1497 * them to the supported frame size range. The height boundary are
1498 * related to the full frame, divide them by two when the format passes
1499 * fields in separate buffers.
1500 */
1501 width = round_down(pix->width, fmt->hsub);
1502 pix->width = clamp(width, FDP1_MIN_W, FDP1_MAX_W);
1503
1504 height = round_down(pix->height, fmt->vsub);
1505 if (pix->field == V4L2_FIELD_ALTERNATE)
1506 pix->height = clamp(height, FDP1_MIN_H / 2, FDP1_MAX_H / 2);
1507 else
1508 pix->height = clamp(height, FDP1_MIN_H, FDP1_MAX_H);
1509
1510 fdp1_compute_stride(pix, fmt);
1511}
1512
1513static void fdp1_try_fmt_capture(struct fdp1_ctx *ctx,
1514 const struct fdp1_fmt **fmtinfo,
1515 struct v4l2_pix_format_mplane *pix)
1516{
1517 struct fdp1_q_data *src_data = &ctx->out_q;
1518 enum v4l2_colorspace colorspace;
1519 enum v4l2_ycbcr_encoding ycbcr_enc;
1520 enum v4l2_quantization quantization;
1521 const struct fdp1_fmt *fmt;
1522 bool allow_rgb;
1523
1524 /*
1525 * Validate the pixel format. We can only accept RGB output formats if
1526 * the input encoding and quantization are compatible with the format
1527 * conversions supported by the hardware. The supported combinations are
1528 *
1529 * V4L2_YCBCR_ENC_601 + V4L2_QUANTIZATION_LIM_RANGE
1530 * V4L2_YCBCR_ENC_601 + V4L2_QUANTIZATION_FULL_RANGE
1531 * V4L2_YCBCR_ENC_709 + V4L2_QUANTIZATION_LIM_RANGE
1532 */
1533 colorspace = src_data->format.colorspace;
1534
1535 ycbcr_enc = src_data->format.ycbcr_enc;
1536 if (ycbcr_enc == V4L2_YCBCR_ENC_DEFAULT)
1537 ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(colorspace);
1538
1539 quantization = src_data->format.quantization;
1540 if (quantization == V4L2_QUANTIZATION_DEFAULT)
1541 quantization = V4L2_MAP_QUANTIZATION_DEFAULT(false, colorspace,
1542 ycbcr_enc);
1543
1544 allow_rgb = ycbcr_enc == V4L2_YCBCR_ENC_601 ||
1545 (ycbcr_enc == V4L2_YCBCR_ENC_709 &&
1546 quantization == V4L2_QUANTIZATION_LIM_RANGE);
1547
1548 fmt = fdp1_find_format(pix->pixelformat);
1549 if (!fmt || (!allow_rgb && fdp1_fmt_is_rgb(fmt)))
1550 fmt = fdp1_find_format(V4L2_PIX_FMT_YUYV);
1551
1552 if (fmtinfo)
1553 *fmtinfo = fmt;
1554
1555 pix->pixelformat = fmt->fourcc;
1556 pix->num_planes = fmt->num_planes;
1557 pix->field = V4L2_FIELD_NONE;
1558
1559 /*
1560 * The colorspace on the capture queue is copied from the output queue
1561 * as the hardware can't change the colorspace. It can convert YCbCr to
1562 * RGB though, in which case the encoding and quantization are set to
1563 * default values as anything else wouldn't make sense.
1564 */
1565 pix->colorspace = src_data->format.colorspace;
1566 pix->xfer_func = src_data->format.xfer_func;
1567
1568 if (fdp1_fmt_is_rgb(fmt)) {
1569 pix->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
1570 pix->quantization = V4L2_QUANTIZATION_DEFAULT;
1571 } else {
1572 pix->ycbcr_enc = src_data->format.ycbcr_enc;
1573 pix->quantization = src_data->format.quantization;
1574 }
1575
1576 /*
1577 * The frame width is identical to the output queue, and the height is
1578 * either doubled or identical depending on whether the output queue
1579 * field order contains one or two fields per frame.
1580 */
1581 pix->width = src_data->format.width;
1582 if (src_data->format.field == V4L2_FIELD_ALTERNATE)
1583 pix->height = 2 * src_data->format.height;
1584 else
1585 pix->height = src_data->format.height;
1586
1587 fdp1_compute_stride(pix, fmt);
1588}
1589
1590static int fdp1_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
1591{
1592 struct fdp1_ctx *ctx = fh_to_ctx(priv);
1593
1594 if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
1595 fdp1_try_fmt_output(ctx, NULL, &f->fmt.pix_mp);
1596 else
1597 fdp1_try_fmt_capture(ctx, NULL, &f->fmt.pix_mp);
1598
1599 dprintk(ctx->fdp1, "Try %s format: %4s (0x%08x) %ux%u field %u\n",
1600 V4L2_TYPE_IS_OUTPUT(f->type) ? "output" : "capture",
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);
1603
1604 return 0;
1605}
1606
1607static void fdp1_set_format(struct fdp1_ctx *ctx,
1608 struct v4l2_pix_format_mplane *pix,
1609 enum v4l2_buf_type type)
1610{
1611 struct fdp1_q_data *q_data = get_q_data(ctx, type);
1612 const struct fdp1_fmt *fmtinfo;
1613
1614 if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
1615 fdp1_try_fmt_output(ctx, &fmtinfo, pix);
1616 else
1617 fdp1_try_fmt_capture(ctx, &fmtinfo, pix);
1618
1619 q_data->fmt = fmtinfo;
1620 q_data->format = *pix;
1621
1622 q_data->vsize = pix->height;
1623 if (pix->field != V4L2_FIELD_NONE)
1624 q_data->vsize /= 2;
1625
1626 q_data->stride_y = pix->plane_fmt[0].bytesperline;
1627 q_data->stride_c = pix->plane_fmt[1].bytesperline;
1628
1629 /* Adjust strides for interleaved buffers */
1630 if (pix->field == V4L2_FIELD_INTERLACED ||
1631 pix->field == V4L2_FIELD_INTERLACED_TB ||
1632 pix->field == V4L2_FIELD_INTERLACED_BT) {
1633 q_data->stride_y *= 2;
1634 q_data->stride_c *= 2;
1635 }
1636
1637 /* Propagate the format from the output node to the capture node. */
1638 if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
1639 struct fdp1_q_data *dst_data = &ctx->cap_q;
1640
1641 /*
1642 * Copy the format, clear the per-plane bytes per line and image
1643 * size, override the field and double the height if needed.
1644 */
1645 dst_data->format = q_data->format;
1646 memset(dst_data->format.plane_fmt, 0,
1647 sizeof(dst_data->format.plane_fmt));
1648
1649 dst_data->format.field = V4L2_FIELD_NONE;
1650 if (pix->field == V4L2_FIELD_ALTERNATE)
1651 dst_data->format.height *= 2;
1652
1653 fdp1_try_fmt_capture(ctx, &dst_data->fmt, &dst_data->format);
1654
1655 dst_data->vsize = dst_data->format.height;
1656 dst_data->stride_y = dst_data->format.plane_fmt[0].bytesperline;
1657 dst_data->stride_c = dst_data->format.plane_fmt[1].bytesperline;
1658 }
1659}
1660
1661static int fdp1_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
1662{
1663 struct fdp1_ctx *ctx = fh_to_ctx(priv);
1664 struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx;
1665 struct vb2_queue *vq = v4l2_m2m_get_vq(m2m_ctx, f->type);
1666
1667 if (vb2_is_busy(vq)) {
1668 v4l2_err(&ctx->fdp1->v4l2_dev, "%s queue busy\n", __func__);
1669 return -EBUSY;
1670 }
1671
1672 fdp1_set_format(ctx, &f->fmt.pix_mp, f->type);
1673
1674 dprintk(ctx->fdp1, "Set %s format: %4s (0x%08x) %ux%u field %u\n",
1675 V4L2_TYPE_IS_OUTPUT(f->type) ? "output" : "capture",
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);
1678
1679 return 0;
1680}
1681
1682static int fdp1_g_ctrl(struct v4l2_ctrl *ctrl)
1683{
1684 struct fdp1_ctx *ctx =
1685 container_of(ctrl->handler, struct fdp1_ctx, hdl);
1686 struct fdp1_q_data *src_q_data = &ctx->out_q;
1687
1688 switch (ctrl->id) {
1689 case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE:
1690 if (V4L2_FIELD_HAS_BOTH(src_q_data->format.field))
1691 ctrl->val = 2;
1692 else
1693 ctrl->val = 1;
1694 return 0;
1695 }
1696
1697 return 1;
1698}
1699
1700static int fdp1_s_ctrl(struct v4l2_ctrl *ctrl)
1701{
1702 struct fdp1_ctx *ctx =
1703 container_of(ctrl->handler, struct fdp1_ctx, hdl);
1704
1705 switch (ctrl->id) {
1706 case V4L2_CID_ALPHA_COMPONENT:
1707 ctx->alpha = ctrl->val;
1708 break;
1709
1710 case V4L2_CID_DEINTERLACING_MODE:
1711 ctx->deint_mode = ctrl->val;
1712 break;
1713 }
1714
1715 return 0;
1716}
1717
1718static const struct v4l2_ctrl_ops fdp1_ctrl_ops = {
1719 .s_ctrl = fdp1_s_ctrl,
1720 .g_volatile_ctrl = fdp1_g_ctrl,
1721};
1722
1723static const char * const fdp1_ctrl_deint_menu[] = {
1724 "Progressive",
1725 "Adaptive 2D/3D",
1726 "Fixed 2D",
1727 "Fixed 3D",
1728 "Previous field",
1729 "Next field",
1730 NULL
1731};
1732
1733static const struct v4l2_ioctl_ops fdp1_ioctl_ops = {
1734 .vidioc_querycap = fdp1_vidioc_querycap,
1735
1736 .vidioc_enum_fmt_vid_cap_mplane = fdp1_enum_fmt_vid_cap,
1737 .vidioc_enum_fmt_vid_out_mplane = fdp1_enum_fmt_vid_out,
1738 .vidioc_g_fmt_vid_cap_mplane = fdp1_g_fmt,
1739 .vidioc_g_fmt_vid_out_mplane = fdp1_g_fmt,
1740 .vidioc_try_fmt_vid_cap_mplane = fdp1_try_fmt,
1741 .vidioc_try_fmt_vid_out_mplane = fdp1_try_fmt,
1742 .vidioc_s_fmt_vid_cap_mplane = fdp1_s_fmt,
1743 .vidioc_s_fmt_vid_out_mplane = fdp1_s_fmt,
1744
1745 .vidioc_reqbufs = v4l2_m2m_ioctl_reqbufs,
1746 .vidioc_querybuf = v4l2_m2m_ioctl_querybuf,
1747 .vidioc_qbuf = v4l2_m2m_ioctl_qbuf,
1748 .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf,
1749 .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf,
1750 .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
1751 .vidioc_expbuf = v4l2_m2m_ioctl_expbuf,
1752
1753 .vidioc_streamon = v4l2_m2m_ioctl_streamon,
1754 .vidioc_streamoff = v4l2_m2m_ioctl_streamoff,
1755
1756 .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
1757 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
1758};
1759
1760/*
1761 * Queue operations
1762 */
1763
1764static int fdp1_queue_setup(struct vb2_queue *vq,
1765 unsigned int *nbuffers, unsigned int *nplanes,
1766 unsigned int sizes[],
1767 struct device *alloc_ctxs[])
1768{
1769 struct fdp1_ctx *ctx = vb2_get_drv_priv(vq);
1770 struct fdp1_q_data *q_data;
1771 unsigned int i;
1772
1773 q_data = get_q_data(ctx, vq->type);
1774
1775 if (*nplanes) {
1776 if (*nplanes > FDP1_MAX_PLANES)
1777 return -EINVAL;
1778
1779 return 0;
1780 }
1781
1782 *nplanes = q_data->format.num_planes;
1783
1784 for (i = 0; i < *nplanes; i++)
1785 sizes[i] = q_data->format.plane_fmt[i].sizeimage;
1786
1787 return 0;
1788}
1789
1790static void fdp1_buf_prepare_field(struct fdp1_q_data *q_data,
1791 struct vb2_v4l2_buffer *vbuf,
1792 unsigned int field_num)
1793{
1794 struct fdp1_buffer *buf = to_fdp1_buffer(vbuf);
1795 struct fdp1_field_buffer *fbuf = &buf->fields[field_num];
1796 unsigned int num_fields;
1797 unsigned int i;
1798
1799 num_fields = V4L2_FIELD_HAS_BOTH(vbuf->field) ? 2 : 1;
1800
1801 fbuf->vb = vbuf;
1802 fbuf->last_field = (field_num + 1) == num_fields;
1803
1804 for (i = 0; i < vbuf->vb2_buf.num_planes; ++i)
1805 fbuf->addrs[i] = vb2_dma_contig_plane_dma_addr(&vbuf->vb2_buf, i);
1806
1807 switch (vbuf->field) {
1808 case V4L2_FIELD_INTERLACED:
1809 /*
1810 * Interlaced means bottom-top for 60Hz TV standards (NTSC) and
1811 * top-bottom for 50Hz. As TV standards are not applicable to
1812 * the mem-to-mem API, use the height as a heuristic.
1813 */
1814 fbuf->field = (q_data->format.height < 576) == field_num
1815 ? V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM;
1816 break;
1817 case V4L2_FIELD_INTERLACED_TB:
1818 case V4L2_FIELD_SEQ_TB:
1819 fbuf->field = field_num ? V4L2_FIELD_BOTTOM : V4L2_FIELD_TOP;
1820 break;
1821 case V4L2_FIELD_INTERLACED_BT:
1822 case V4L2_FIELD_SEQ_BT:
1823 fbuf->field = field_num ? V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM;
1824 break;
1825 default:
1826 fbuf->field = vbuf->field;
1827 break;
1828 }
1829
1830 /* Buffer is completed */
1831 if (!field_num)
1832 return;
1833
1834 /* Adjust buffer addresses for second field */
1835 switch (vbuf->field) {
1836 case V4L2_FIELD_INTERLACED:
1837 case V4L2_FIELD_INTERLACED_TB:
1838 case V4L2_FIELD_INTERLACED_BT:
1839 for (i = 0; i < vbuf->vb2_buf.num_planes; i++)
1840 fbuf->addrs[i] +=
1841 (i == 0 ? q_data->stride_y : q_data->stride_c);
1842 break;
1843 case V4L2_FIELD_SEQ_TB:
1844 case V4L2_FIELD_SEQ_BT:
1845 for (i = 0; i < vbuf->vb2_buf.num_planes; i++)
1846 fbuf->addrs[i] += q_data->vsize *
1847 (i == 0 ? q_data->stride_y : q_data->stride_c);
1848 break;
1849 }
1850}
1851
1852static int fdp1_buf_prepare(struct vb2_buffer *vb)
1853{
1854 struct fdp1_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
1855 struct fdp1_q_data *q_data = get_q_data(ctx, vb->vb2_queue->type);
1856 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
1857 struct fdp1_buffer *buf = to_fdp1_buffer(vbuf);
1858 unsigned int i;
1859
1860 if (V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) {
1861 bool field_valid = true;
1862
1863 /* Validate the buffer field. */
1864 switch (q_data->format.field) {
1865 case V4L2_FIELD_NONE:
1866 if (vbuf->field != V4L2_FIELD_NONE)
1867 field_valid = false;
1868 break;
1869
1870 case V4L2_FIELD_ALTERNATE:
1871 if (vbuf->field != V4L2_FIELD_TOP &&
1872 vbuf->field != V4L2_FIELD_BOTTOM)
1873 field_valid = false;
1874 break;
1875
1876 case V4L2_FIELD_INTERLACED:
1877 case V4L2_FIELD_SEQ_TB:
1878 case V4L2_FIELD_SEQ_BT:
1879 case V4L2_FIELD_INTERLACED_TB:
1880 case V4L2_FIELD_INTERLACED_BT:
1881 if (vbuf->field != q_data->format.field)
1882 field_valid = false;
1883 break;
1884 }
1885
1886 if (!field_valid) {
1887 dprintk(ctx->fdp1,
1888 "buffer field %u invalid for format field %u\n",
1889 vbuf->field, q_data->format.field);
1890 return -EINVAL;
1891 }
1892 } else {
1893 vbuf->field = V4L2_FIELD_NONE;
1894 }
1895
1896 /* Validate the planes sizes. */
1897 for (i = 0; i < q_data->format.num_planes; i++) {
1898 unsigned long size = q_data->format.plane_fmt[i].sizeimage;
1899
1900 if (vb2_plane_size(vb, i) < size) {
1901 dprintk(ctx->fdp1,
1902 "data will not fit into plane [%u/%u] (%lu < %lu)\n",
1903 i, q_data->format.num_planes,
1904 vb2_plane_size(vb, i), size);
1905 return -EINVAL;
1906 }
1907
1908 /* We have known size formats all around */
1909 vb2_set_plane_payload(vb, i, size);
1910 }
1911
1912 buf->num_fields = V4L2_FIELD_HAS_BOTH(vbuf->field) ? 2 : 1;
1913 for (i = 0; i < buf->num_fields; ++i)
1914 fdp1_buf_prepare_field(q_data, vbuf, i);
1915
1916 return 0;
1917}
1918
1919static void fdp1_buf_queue(struct vb2_buffer *vb)
1920{
1921 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
1922 struct fdp1_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
1923
1924 v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf);
1925}
1926
1927static int fdp1_start_streaming(struct vb2_queue *q, unsigned int count)
1928{
1929 struct fdp1_ctx *ctx = vb2_get_drv_priv(q);
1930 struct fdp1_q_data *q_data = get_q_data(ctx, q->type);
1931
1932 if (V4L2_TYPE_IS_OUTPUT(q->type)) {
1933 /*
1934 * Force our deint_mode when we are progressive,
1935 * ignoring any setting on the device from the user,
1936 * Otherwise, lock in the requested de-interlace mode.
1937 */
1938 if (q_data->format.field == V4L2_FIELD_NONE)
1939 ctx->deint_mode = FDP1_PROGRESSIVE;
1940
1941 if (ctx->deint_mode == FDP1_ADAPT2D3D) {
1942 u32 stride;
1943 dma_addr_t smsk_base;
1944 const u32 bpp = 2; /* bytes per pixel */
1945
1946 stride = round_up(q_data->format.width, 8);
1947
1948 ctx->smsk_size = bpp * stride * q_data->vsize;
1949
1950 ctx->smsk_cpu = dma_alloc_coherent(ctx->fdp1->dev,
1951 ctx->smsk_size, &smsk_base, GFP_KERNEL);
1952
1953 if (ctx->smsk_cpu == NULL) {
1954 dprintk(ctx->fdp1, "Failed to alloc smsk\n");
1955 return -ENOMEM;
1956 }
1957
1958 ctx->smsk_addr[0] = smsk_base;
1959 ctx->smsk_addr[1] = smsk_base + (ctx->smsk_size/2);
1960 }
1961 }
1962
1963 return 0;
1964}
1965
1966static void fdp1_stop_streaming(struct vb2_queue *q)
1967{
1968 struct fdp1_ctx *ctx = vb2_get_drv_priv(q);
1969 struct vb2_v4l2_buffer *vbuf;
1970 unsigned long flags;
1971
1972 while (1) {
1973 if (V4L2_TYPE_IS_OUTPUT(q->type))
1974 vbuf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
1975 else
1976 vbuf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
1977 if (vbuf == NULL)
1978 break;
1979 spin_lock_irqsave(&ctx->fdp1->irqlock, flags);
1980 v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
1981 spin_unlock_irqrestore(&ctx->fdp1->irqlock, flags);
1982 }
1983
1984 /* Empty Output queues */
1985 if (V4L2_TYPE_IS_OUTPUT(q->type)) {
1986 /* Empty our internal queues */
1987 struct fdp1_field_buffer *fbuf;
1988
1989 /* Free any queued buffers */
1990 fbuf = fdp1_dequeue_field(ctx);
1991 while (fbuf != NULL) {
1992 fdp1_field_complete(ctx, fbuf);
1993 fbuf = fdp1_dequeue_field(ctx);
1994 }
1995
1996 /* Free smsk_data */
1997 if (ctx->smsk_cpu) {
1998 dma_free_coherent(ctx->fdp1->dev, ctx->smsk_size,
1999 ctx->smsk_cpu, ctx->smsk_addr[0]);
2000 ctx->smsk_addr[0] = ctx->smsk_addr[1] = 0;
2001 ctx->smsk_cpu = NULL;
2002 }
2003
2004 WARN(!list_empty(&ctx->fields_queue),
2005 "Buffer queue not empty");
2006 } else {
2007 /* Empty Capture queues (Jobs) */
2008 struct fdp1_job *job;
2009
2010 job = get_queued_job(ctx->fdp1);
2011 while (job) {
2012 if (FDP1_DEINT_MODE_USES_PREV(ctx->deint_mode))
2013 fdp1_field_complete(ctx, job->previous);
2014 else
2015 fdp1_field_complete(ctx, job->active);
2016
2017 v4l2_m2m_buf_done(job->dst->vb, VB2_BUF_STATE_ERROR);
2018 job->dst = NULL;
2019
2020 job = get_queued_job(ctx->fdp1);
2021 }
2022
2023 /* Free any held buffer in the ctx */
2024 fdp1_field_complete(ctx, ctx->previous);
2025
2026 WARN(!list_empty(&ctx->fdp1->queued_job_list),
2027 "Queued Job List not empty");
2028
2029 WARN(!list_empty(&ctx->fdp1->hw_job_list),
2030 "HW Job list not empty");
2031 }
2032}
2033
2034static struct vb2_ops fdp1_qops = {
2035 .queue_setup = fdp1_queue_setup,
2036 .buf_prepare = fdp1_buf_prepare,
2037 .buf_queue = fdp1_buf_queue,
2038 .start_streaming = fdp1_start_streaming,
2039 .stop_streaming = fdp1_stop_streaming,
2040 .wait_prepare = vb2_ops_wait_prepare,
2041 .wait_finish = vb2_ops_wait_finish,
2042};
2043
2044static int queue_init(void *priv, struct vb2_queue *src_vq,
2045 struct vb2_queue *dst_vq)
2046{
2047 struct fdp1_ctx *ctx = priv;
2048 int ret;
2049
2050 src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
2051 src_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
2052 src_vq->drv_priv = ctx;
2053 src_vq->buf_struct_size = sizeof(struct fdp1_buffer);
2054 src_vq->ops = &fdp1_qops;
2055 src_vq->mem_ops = &vb2_dma_contig_memops;
2056 src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
2057 src_vq->lock = &ctx->fdp1->dev_mutex;
2058 src_vq->dev = ctx->fdp1->dev;
2059
2060 ret = vb2_queue_init(src_vq);
2061 if (ret)
2062 return ret;
2063
2064 dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
2065 dst_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
2066 dst_vq->drv_priv = ctx;
2067 dst_vq->buf_struct_size = sizeof(struct fdp1_buffer);
2068 dst_vq->ops = &fdp1_qops;
2069 dst_vq->mem_ops = &vb2_dma_contig_memops;
2070 dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
2071 dst_vq->lock = &ctx->fdp1->dev_mutex;
2072 dst_vq->dev = ctx->fdp1->dev;
2073
2074 return vb2_queue_init(dst_vq);
2075}
2076
2077/*
2078 * File operations
2079 */
2080static int fdp1_open(struct file *file)
2081{
2082 struct fdp1_dev *fdp1 = video_drvdata(file);
2083 struct v4l2_pix_format_mplane format;
2084 struct fdp1_ctx *ctx = NULL;
2085 struct v4l2_ctrl *ctrl;
2086 int ret = 0;
2087
2088 if (mutex_lock_interruptible(&fdp1->dev_mutex))
2089 return -ERESTARTSYS;
2090
2091 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
2092 if (!ctx) {
2093 ret = -ENOMEM;
2094 goto done;
2095 }
2096
2097 v4l2_fh_init(&ctx->fh, video_devdata(file));
2098 file->private_data = &ctx->fh;
2099 ctx->fdp1 = fdp1;
2100
2101 /* Initialise Queues */
2102 INIT_LIST_HEAD(&ctx->fields_queue);
2103
2104 ctx->translen = 1;
2105 ctx->sequence = 0;
2106
2107 /* Initialise controls */
2108
2109 v4l2_ctrl_handler_init(&ctx->hdl, 3);
2110 v4l2_ctrl_new_std_menu_items(&ctx->hdl, &fdp1_ctrl_ops,
2111 V4L2_CID_DEINTERLACING_MODE,
2112 FDP1_NEXTFIELD, BIT(0), FDP1_FIXED3D,
2113 fdp1_ctrl_deint_menu);
2114
2115 ctrl = v4l2_ctrl_new_std(&ctx->hdl, &fdp1_ctrl_ops,
2116 V4L2_CID_MIN_BUFFERS_FOR_CAPTURE, 1, 2, 1, 1);
2117 if (ctrl)
2118 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
2119
2120 v4l2_ctrl_new_std(&ctx->hdl, &fdp1_ctrl_ops,
2121 V4L2_CID_ALPHA_COMPONENT, 0, 255, 1, 255);
2122
2123 if (ctx->hdl.error) {
2124 ret = ctx->hdl.error;
2125 v4l2_ctrl_handler_free(&ctx->hdl);
2126 goto done;
2127 }
2128
2129 ctx->fh.ctrl_handler = &ctx->hdl;
2130 v4l2_ctrl_handler_setup(&ctx->hdl);
2131
2132 /* Configure default parameters. */
2133 memset(&format, 0, sizeof(format));
2134 fdp1_set_format(ctx, &format, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
2135
2136 ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(fdp1->m2m_dev, ctx, &queue_init);
2137
2138 if (IS_ERR(ctx->fh.m2m_ctx)) {
2139 ret = PTR_ERR(ctx->fh.m2m_ctx);
2140
2141 v4l2_ctrl_handler_free(&ctx->hdl);
2142 kfree(ctx);
2143 goto done;
2144 }
2145
2146 /* Perform any power management required */
2147 pm_runtime_get_sync(fdp1->dev);
2148
2149 v4l2_fh_add(&ctx->fh);
2150
2151 dprintk(fdp1, "Created instance: %p, m2m_ctx: %p\n",
2152 ctx, ctx->fh.m2m_ctx);
2153
2154done:
2155 mutex_unlock(&fdp1->dev_mutex);
2156 return ret;
2157}
2158
2159static int fdp1_release(struct file *file)
2160{
2161 struct fdp1_dev *fdp1 = video_drvdata(file);
2162 struct fdp1_ctx *ctx = fh_to_ctx(file->private_data);
2163
2164 dprintk(fdp1, "Releasing instance %p\n", ctx);
2165
2166 v4l2_fh_del(&ctx->fh);
2167 v4l2_fh_exit(&ctx->fh);
2168 v4l2_ctrl_handler_free(&ctx->hdl);
2169 mutex_lock(&fdp1->dev_mutex);
2170 v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
2171 mutex_unlock(&fdp1->dev_mutex);
2172 kfree(ctx);
2173
2174 pm_runtime_put(fdp1->dev);
2175
2176 return 0;
2177}
2178
2179static const struct v4l2_file_operations fdp1_fops = {
2180 .owner = THIS_MODULE,
2181 .open = fdp1_open,
2182 .release = fdp1_release,
2183 .poll = v4l2_m2m_fop_poll,
2184 .unlocked_ioctl = video_ioctl2,
2185 .mmap = v4l2_m2m_fop_mmap,
2186};
2187
2188static const struct video_device fdp1_videodev = {
2189 .name = DRIVER_NAME,
2190 .vfl_dir = VFL_DIR_M2M,
2191 .fops = &fdp1_fops,
2192 .device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING,
2193 .ioctl_ops = &fdp1_ioctl_ops,
2194 .minor = -1,
2195 .release = video_device_release_empty,
2196};
2197
2198static const struct v4l2_m2m_ops m2m_ops = {
2199 .device_run = fdp1_m2m_device_run,
2200 .job_ready = fdp1_m2m_job_ready,
2201 .job_abort = fdp1_m2m_job_abort,
2202};
2203
2204static irqreturn_t fdp1_irq_handler(int irq, void *dev_id)
2205{
2206 struct fdp1_dev *fdp1 = dev_id;
2207 u32 int_status;
2208 u32 ctl_status;
2209 u32 vint_cnt;
2210 u32 cycles;
2211
2212 int_status = fdp1_read(fdp1, FD1_CTL_IRQSTA);
2213 cycles = fdp1_read(fdp1, FD1_CTL_VCYCLE_STAT);
2214 ctl_status = fdp1_read(fdp1, FD1_CTL_STATUS);
2215 vint_cnt = (ctl_status & FD1_CTL_STATUS_VINT_CNT_MASK) >>
2216 FD1_CTL_STATUS_VINT_CNT_SHIFT;
2217
2218 /* Clear interrupts */
2219 fdp1_write(fdp1, ~(int_status) & FD1_CTL_IRQ_MASK, FD1_CTL_IRQSTA);
2220
2221 if (debug >= 2) {
2222 dprintk(fdp1, "IRQ: 0x%x %s%s%s\n", int_status,
2223 int_status & FD1_CTL_IRQ_VERE ? "[Error]" : "[!E]",
2224 int_status & FD1_CTL_IRQ_VINTE ? "[VSync]" : "[!V]",
2225 int_status & FD1_CTL_IRQ_FREE ? "[FrameEnd]" : "[!F]");
2226
2227 dprintk(fdp1, "CycleStatus = %d (%dms)\n",
2228 cycles, cycles/(fdp1->clk_rate/1000));
2229
2230 dprintk(fdp1,
2231 "Control Status = 0x%08x : VINT_CNT = %d %s:%s:%s:%s\n",
2232 ctl_status, vint_cnt,
2233 ctl_status & FD1_CTL_STATUS_SGREGSET ? "RegSet" : "",
2234 ctl_status & FD1_CTL_STATUS_SGVERR ? "Vsync Error" : "",
2235 ctl_status & FD1_CTL_STATUS_SGFREND ? "FrameEnd" : "",
2236 ctl_status & FD1_CTL_STATUS_BSY ? "Busy" : "");
2237 dprintk(fdp1, "***********************************\n");
2238 }
2239
2240 /* Spurious interrupt */
2241 if (!(FD1_CTL_IRQ_MASK & int_status))
2242 return IRQ_NONE;
2243
2244 /* Work completed, release the frame */
2245 if (FD1_CTL_IRQ_VERE & int_status)
2246 device_frame_end(fdp1, VB2_BUF_STATE_ERROR);
2247 else if (FD1_CTL_IRQ_FREE & int_status)
2248 device_frame_end(fdp1, VB2_BUF_STATE_DONE);
2249
2250 return IRQ_HANDLED;
2251}
2252
2253static int fdp1_probe(struct platform_device *pdev)
2254{
2255 struct fdp1_dev *fdp1;
2256 struct video_device *vfd;
2257 struct device_node *fcp_node;
2258 struct resource *res;
2259 struct clk *clk;
2260 unsigned int i;
2261
2262 int ret;
2263 int hw_version;
2264
2265 fdp1 = devm_kzalloc(&pdev->dev, sizeof(*fdp1), GFP_KERNEL);
2266 if (!fdp1)
2267 return -ENOMEM;
2268
2269 INIT_LIST_HEAD(&fdp1->free_job_list);
2270 INIT_LIST_HEAD(&fdp1->queued_job_list);
2271 INIT_LIST_HEAD(&fdp1->hw_job_list);
2272
2273 /* Initialise the jobs on the free list */
2274 for (i = 0; i < ARRAY_SIZE(fdp1->jobs); i++)
2275 list_add(&fdp1->jobs[i].list, &fdp1->free_job_list);
2276
2277 mutex_init(&fdp1->dev_mutex);
2278
2279 spin_lock_init(&fdp1->irqlock);
2280 spin_lock_init(&fdp1->device_process_lock);
2281 fdp1->dev = &pdev->dev;
2282 platform_set_drvdata(pdev, fdp1);
2283
2284 /* Memory-mapped registers */
2285 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2286 fdp1->regs = devm_ioremap_resource(&pdev->dev, res);
2287 if (IS_ERR(fdp1->regs))
2288 return PTR_ERR(fdp1->regs);
2289
2290 /* Interrupt service routine registration */
2291 fdp1->irq = ret = platform_get_irq(pdev, 0);
2292 if (ret < 0) {
2293 dev_err(&pdev->dev, "cannot find IRQ\n");
2294 return ret;
2295 }
2296
2297 ret = devm_request_irq(&pdev->dev, fdp1->irq, fdp1_irq_handler, 0,
2298 dev_name(&pdev->dev), fdp1);
2299 if (ret) {
2300 dev_err(&pdev->dev, "cannot claim IRQ %d\n", fdp1->irq);
2301 return ret;
2302 }
2303
2304 /* FCP */
2305 fcp_node = of_parse_phandle(pdev->dev.of_node, "renesas,fcp", 0);
2306 if (fcp_node) {
2307 fdp1->fcp = rcar_fcp_get(fcp_node);
2308 of_node_put(fcp_node);
2309 if (IS_ERR(fdp1->fcp)) {
2310 dev_err(&pdev->dev, "FCP not found (%ld)\n",
2311 PTR_ERR(fdp1->fcp));
2312 return PTR_ERR(fdp1->fcp);
2313 }
2314 }
2315
2316 /* Determine our clock rate */
2317 clk = clk_get(&pdev->dev, NULL);
2318 if (IS_ERR(clk))
2319 return PTR_ERR(clk);
2320
2321 fdp1->clk_rate = clk_get_rate(clk);
2322 clk_put(clk);
2323
2324 /* V4L2 device registration */
2325 ret = v4l2_device_register(&pdev->dev, &fdp1->v4l2_dev);
2326 if (ret) {
2327 v4l2_err(&fdp1->v4l2_dev, "Failed to register video device\n");
2328 return ret;
2329 }
2330
2331 /* M2M registration */
2332 fdp1->m2m_dev = v4l2_m2m_init(&m2m_ops);
2333 if (IS_ERR(fdp1->m2m_dev)) {
2334 v4l2_err(&fdp1->v4l2_dev, "Failed to init mem2mem device\n");
2335 ret = PTR_ERR(fdp1->m2m_dev);
2336 goto unreg_dev;
2337 }
2338
2339 /* Video registration */
2340 fdp1->vfd = fdp1_videodev;
2341 vfd = &fdp1->vfd;
2342 vfd->lock = &fdp1->dev_mutex;
2343 vfd->v4l2_dev = &fdp1->v4l2_dev;
2344 video_set_drvdata(vfd, fdp1);
2345 strlcpy(vfd->name, fdp1_videodev.name, sizeof(vfd->name));
2346
2347 ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
2348 if (ret) {
2349 v4l2_err(&fdp1->v4l2_dev, "Failed to register video device\n");
2350 goto release_m2m;
2351 }
2352
2353 v4l2_info(&fdp1->v4l2_dev,
2354 "Device registered as /dev/video%d\n", vfd->num);
2355
2356 /* Power up the cells to read HW */
2357 pm_runtime_enable(&pdev->dev);
2358 pm_runtime_get_sync(fdp1->dev);
2359
2360 hw_version = fdp1_read(fdp1, FD1_IP_INTDATA);
2361 switch (hw_version) {
2362 case FD1_IP_H3:
2363 dprintk(fdp1, "FDP1 Version R-Car H3\n");
2364 break;
2365 case FD1_IP_M3W:
2366 dprintk(fdp1, "FDP1 Version R-Car M3-W\n");
2367 break;
2368 default:
2369 dev_err(fdp1->dev, "FDP1 Unidentifiable (0x%08x)\n",
2370 hw_version);
2371 }
2372
2373 /* Allow the hw to sleep until an open call puts it to use */
2374 pm_runtime_put(fdp1->dev);
2375
2376 return 0;
2377
2378release_m2m:
2379 v4l2_m2m_release(fdp1->m2m_dev);
2380
2381unreg_dev:
2382 v4l2_device_unregister(&fdp1->v4l2_dev);
2383
2384 return ret;
2385}
2386
2387static int fdp1_remove(struct platform_device *pdev)
2388{
2389 struct fdp1_dev *fdp1 = platform_get_drvdata(pdev);
2390
2391 v4l2_m2m_release(fdp1->m2m_dev);
2392 video_unregister_device(&fdp1->vfd);
2393 v4l2_device_unregister(&fdp1->v4l2_dev);
2394 pm_runtime_disable(&pdev->dev);
2395
2396 return 0;
2397}
2398
2399static int __maybe_unused fdp1_pm_runtime_suspend(struct device *dev)
2400{
2401 struct fdp1_dev *fdp1 = dev_get_drvdata(dev);
2402
2403 rcar_fcp_disable(fdp1->fcp);
2404
2405 return 0;
2406}
2407
2408static int __maybe_unused fdp1_pm_runtime_resume(struct device *dev)
2409{
2410 struct fdp1_dev *fdp1 = dev_get_drvdata(dev);
2411
2412 /* Program in the static LUTs */
2413 fdp1_set_lut(fdp1);
2414
2415 return rcar_fcp_enable(fdp1->fcp);
2416}
2417
2418static const struct dev_pm_ops fdp1_pm_ops = {
2419 SET_RUNTIME_PM_OPS(fdp1_pm_runtime_suspend,
2420 fdp1_pm_runtime_resume,
2421 NULL)
2422};
2423
2424static const struct of_device_id fdp1_dt_ids[] = {
2425 { .compatible = "renesas,fdp1" },
2426 { },
2427};
2428MODULE_DEVICE_TABLE(of, fdp1_dt_ids);
2429
2430static struct platform_driver fdp1_pdrv = {
2431 .probe = fdp1_probe,
2432 .remove = fdp1_remove,
2433 .driver = {
2434 .name = DRIVER_NAME,
2435 .of_match_table = fdp1_dt_ids,
2436 .pm = &fdp1_pm_ops,
2437 },
2438};
2439
2440module_platform_driver(fdp1_pdrv);
2441
2442MODULE_DESCRIPTION("Renesas R-Car Fine Display Processor Driver");
2443MODULE_AUTHOR("Kieran Bingham <kieran@bingham.xyz>");
2444MODULE_LICENSE("GPL");
2445MODULE_ALIAS("platform:" DRIVER_NAME);
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c b/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c
index 0912d0a892e2..a1d823ab0c63 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c
@@ -178,20 +178,12 @@ void exynos4_jpeg_set_interrupt(void __iomem *base, unsigned int version)
178 178
179unsigned int exynos4_jpeg_get_int_status(void __iomem *base) 179unsigned int exynos4_jpeg_get_int_status(void __iomem *base)
180{ 180{
181 unsigned int int_status; 181 return readl(base + EXYNOS4_INT_STATUS_REG);
182
183 int_status = readl(base + EXYNOS4_INT_STATUS_REG);
184
185 return int_status;
186} 182}
187 183
188unsigned int exynos4_jpeg_get_fifo_status(void __iomem *base) 184unsigned int exynos4_jpeg_get_fifo_status(void __iomem *base)
189{ 185{
190 unsigned int fifo_status; 186 return readl(base + EXYNOS4_FIFO_STATUS_REG);
191
192 fifo_status = readl(base + EXYNOS4_FIFO_STATUS_REG);
193
194 return fifo_status;
195} 187}
196 188
197void exynos4_jpeg_set_huf_table_enable(void __iomem *base, int value) 189void exynos4_jpeg_set_huf_table_enable(void __iomem *base, int value)
@@ -296,10 +288,7 @@ void exynos4_jpeg_set_encode_hoff_cnt(void __iomem *base, unsigned int fmt)
296 288
297unsigned int exynos4_jpeg_get_stream_size(void __iomem *base) 289unsigned int exynos4_jpeg_get_stream_size(void __iomem *base)
298{ 290{
299 unsigned int size; 291 return readl(base + EXYNOS4_BITSTREAM_SIZE_REG);
300
301 size = readl(base + EXYNOS4_BITSTREAM_SIZE_REG);
302 return size;
303} 292}
304 293
305void exynos4_jpeg_set_dec_bitstream_size(void __iomem *base, unsigned int size) 294void exynos4_jpeg_set_dec_bitstream_size(void __iomem *base, unsigned int size)
diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
index 83e01f3466e9..d2cd35916dc5 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
@@ -386,7 +386,8 @@
386 ((w) * 144 + 8192 * (h) + 49216 + 1048576) 386 ((w) * 144 + 8192 * (h) + 49216 + 1048576)
387#define S5P_FIMV_SCRATCH_BUF_SIZE_VC1_DEC_V6(w, h) \ 387#define S5P_FIMV_SCRATCH_BUF_SIZE_VC1_DEC_V6(w, h) \
388 (2096 * ((w) + (h) + 1)) 388 (2096 * ((w) + (h) + 1))
389#define S5P_FIMV_SCRATCH_BUF_SIZE_H263_DEC_V6(w, h) ((w) * 400) 389#define S5P_FIMV_SCRATCH_BUF_SIZE_H263_DEC_V6(w, h) \
390 S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_DEC_V6(w, h)
390#define S5P_FIMV_SCRATCH_BUF_SIZE_VP8_DEC_V6(w, h) \ 391#define S5P_FIMV_SCRATCH_BUF_SIZE_VP8_DEC_V6(w, h) \
391 ((w) * 32 + (h) * 128 + (((w) + 1) / 2) * 64 + 2112) 392 ((w) * 32 + (h) * 128 + (((w) + 1) / 2) * 64 + 2112)
392#define S5P_FIMV_SCRATCH_BUF_SIZE_H264_ENC_V6(w, h) \ 393#define S5P_FIMV_SCRATCH_BUF_SIZE_H264_ENC_V6(w, h) \
diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v8.h b/drivers/media/platform/s5p-mfc/regs-mfc-v8.h
index cc7cbec51b5e..4d1c3750eb5e 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v8.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v8.h
@@ -90,7 +90,7 @@
90#define S5P_FIMV_E_H264_OPTIONS_V8 0xfb54 90#define S5P_FIMV_E_H264_OPTIONS_V8 0xfb54
91 91
92/* MFCv8 Context buffer sizes */ 92/* MFCv8 Context buffer sizes */
93#define MFC_CTX_BUF_SIZE_V8 (30 * SZ_1K) /* 30KB */ 93#define MFC_CTX_BUF_SIZE_V8 (36 * SZ_1K) /* 36KB */
94#define MFC_H264_DEC_CTX_BUF_SIZE_V8 (2 * SZ_1M) /* 2MB */ 94#define MFC_H264_DEC_CTX_BUF_SIZE_V8 (2 * SZ_1M) /* 2MB */
95#define MFC_OTHER_DEC_CTX_BUF_SIZE_V8 (20 * SZ_1K) /* 20KB */ 95#define MFC_OTHER_DEC_CTX_BUF_SIZE_V8 (20 * SZ_1K) /* 20KB */
96#define MFC_H264_ENC_CTX_BUF_SIZE_V8 (100 * SZ_1K) /* 100KB */ 96#define MFC_H264_ENC_CTX_BUF_SIZE_V8 (100 * SZ_1K) /* 100KB */
diff --git a/drivers/media/platform/s5p-mfc/regs-mfc.h b/drivers/media/platform/s5p-mfc/regs-mfc.h
index 6ccc3f8c122a..57b7e0be0596 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc.h
@@ -393,6 +393,9 @@
393#define S5P_FIMV_REG_CLEAR_COUNT 0 393#define S5P_FIMV_REG_CLEAR_COUNT 0
394 394
395/* Error handling defines */ 395/* Error handling defines */
396#define S5P_FIMV_ERR_NO_VALID_SEQ_HDR 67
397#define S5P_FIMV_ERR_INCOMPLETE_FRAME 124
398#define S5P_FIMV_ERR_TIMEOUT 140
396#define S5P_FIMV_ERR_WARNINGS_START 145 399#define S5P_FIMV_ERR_WARNINGS_START 145
397#define S5P_FIMV_ERR_DEC_MASK 0xFFFF 400#define S5P_FIMV_ERR_DEC_MASK 0xFFFF
398#define S5P_FIMV_ERR_DEC_SHIFT 0 401#define S5P_FIMV_ERR_DEC_SHIFT 0
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 0a5b8f5e011e..bb0a5887c9a9 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -641,8 +641,11 @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv)
641 case S5P_MFC_R2H_CMD_ERR_RET: 641 case S5P_MFC_R2H_CMD_ERR_RET:
642 /* An error has occurred */ 642 /* An error has occurred */
643 if (ctx->state == MFCINST_RUNNING && 643 if (ctx->state == MFCINST_RUNNING &&
644 s5p_mfc_hw_call(dev->mfc_ops, err_dec, err) >= 644 (s5p_mfc_hw_call(dev->mfc_ops, err_dec, err) >=
645 dev->warn_start) 645 dev->warn_start ||
646 err == S5P_FIMV_ERR_NO_VALID_SEQ_HDR ||
647 err == S5P_FIMV_ERR_INCOMPLETE_FRAME ||
648 err == S5P_FIMV_ERR_TIMEOUT))
646 s5p_mfc_handle_frame(ctx, reason, err); 649 s5p_mfc_handle_frame(ctx, reason, err);
647 else 650 else
648 s5p_mfc_handle_error(dev, ctx, reason, err); 651 s5p_mfc_handle_error(dev, ctx, reason, err);
@@ -848,6 +851,11 @@ static int s5p_mfc_open(struct file *file)
848 ret = -ENOENT; 851 ret = -ENOENT;
849 goto err_queue_init; 852 goto err_queue_init;
850 } 853 }
854 /*
855 * We'll do mostly sequential access, so sacrifice TLB efficiency for
856 * faster allocation.
857 */
858 q->dma_attrs = DMA_ATTR_ALLOC_SINGLE_PAGES;
851 q->mem_ops = &vb2_dma_contig_memops; 859 q->mem_ops = &vb2_dma_contig_memops;
852 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; 860 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
853 ret = vb2_queue_init(q); 861 ret = vb2_queue_init(q);
@@ -878,6 +886,12 @@ static int s5p_mfc_open(struct file *file)
878 * will keep the value of bytesused intact. 886 * will keep the value of bytesused intact.
879 */ 887 */
880 q->allow_zero_bytesused = 1; 888 q->allow_zero_bytesused = 1;
889
890 /*
891 * We'll do mostly sequential access, so sacrifice TLB efficiency for
892 * faster allocation.
893 */
894 q->dma_attrs = DMA_ATTR_ALLOC_SINGLE_PAGES;
881 q->mem_ops = &vb2_dma_contig_memops; 895 q->mem_ops = &vb2_dma_contig_memops;
882 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; 896 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
883 ret = vb2_queue_init(q); 897 ret = vb2_queue_init(q);
@@ -926,10 +940,11 @@ static int s5p_mfc_release(struct file *file)
926 mfc_debug_enter(); 940 mfc_debug_enter();
927 if (dev) 941 if (dev)
928 mutex_lock(&dev->mfc_mutex); 942 mutex_lock(&dev->mfc_mutex);
929 s5p_mfc_clock_on();
930 vb2_queue_release(&ctx->vq_src); 943 vb2_queue_release(&ctx->vq_src);
931 vb2_queue_release(&ctx->vq_dst); 944 vb2_queue_release(&ctx->vq_dst);
932 if (dev) { 945 if (dev) {
946 s5p_mfc_clock_on();
947
933 /* Mark context as idle */ 948 /* Mark context as idle */
934 clear_work_bit_irqsave(ctx); 949 clear_work_bit_irqsave(ctx);
935 /* 950 /*
@@ -948,12 +963,14 @@ static int s5p_mfc_release(struct file *file)
948 mfc_debug(2, "Last instance\n"); 963 mfc_debug(2, "Last instance\n");
949 s5p_mfc_deinit_hw(dev); 964 s5p_mfc_deinit_hw(dev);
950 del_timer_sync(&dev->watchdog_timer); 965 del_timer_sync(&dev->watchdog_timer);
966 s5p_mfc_clock_off();
951 if (s5p_mfc_power_off() < 0) 967 if (s5p_mfc_power_off() < 0)
952 mfc_err("Power off failed\n"); 968 mfc_err("Power off failed\n");
969 } else {
970 mfc_debug(2, "Shutting down clock\n");
971 s5p_mfc_clock_off();
953 } 972 }
954 } 973 }
955 mfc_debug(2, "Shutting down clock\n");
956 s5p_mfc_clock_off();
957 if (dev) 974 if (dev)
958 dev->ctx[ctx->num] = NULL; 975 dev->ctx[ctx->num] = NULL;
959 s5p_mfc_dec_ctrls_delete(ctx); 976 s5p_mfc_dec_ctrls_delete(ctx);
@@ -1082,6 +1099,7 @@ static struct device *s5p_mfc_alloc_memdev(struct device *dev,
1082 idx); 1099 idx);
1083 if (ret == 0) 1100 if (ret == 0)
1084 return child; 1101 return child;
1102 device_del(child);
1085 } 1103 }
1086 1104
1087 put_device(child); 1105 put_device(child);
@@ -1387,31 +1405,9 @@ static int s5p_mfc_resume(struct device *dev)
1387} 1405}
1388#endif 1406#endif
1389 1407
1390#ifdef CONFIG_PM
1391static int s5p_mfc_runtime_suspend(struct device *dev)
1392{
1393 struct platform_device *pdev = to_platform_device(dev);
1394 struct s5p_mfc_dev *m_dev = platform_get_drvdata(pdev);
1395
1396 atomic_set(&m_dev->pm.power, 0);
1397 return 0;
1398}
1399
1400static int s5p_mfc_runtime_resume(struct device *dev)
1401{
1402 struct platform_device *pdev = to_platform_device(dev);
1403 struct s5p_mfc_dev *m_dev = platform_get_drvdata(pdev);
1404
1405 atomic_set(&m_dev->pm.power, 1);
1406 return 0;
1407}
1408#endif
1409
1410/* Power management */ 1408/* Power management */
1411static const struct dev_pm_ops s5p_mfc_pm_ops = { 1409static const struct dev_pm_ops s5p_mfc_pm_ops = {
1412 SET_SYSTEM_SLEEP_PM_OPS(s5p_mfc_suspend, s5p_mfc_resume) 1410 SET_SYSTEM_SLEEP_PM_OPS(s5p_mfc_suspend, s5p_mfc_resume)
1413 SET_RUNTIME_PM_OPS(s5p_mfc_runtime_suspend, s5p_mfc_runtime_resume,
1414 NULL)
1415}; 1411};
1416 1412
1417static struct s5p_mfc_buf_size_v5 mfc_buf_size_v5 = { 1413static struct s5p_mfc_buf_size_v5 mfc_buf_size_v5 = {
@@ -1438,6 +1434,9 @@ static struct s5p_mfc_variant mfc_drvdata_v5 = {
1438 .buf_size = &buf_size_v5, 1434 .buf_size = &buf_size_v5,
1439 .buf_align = &mfc_buf_align_v5, 1435 .buf_align = &mfc_buf_align_v5,
1440 .fw_name[0] = "s5p-mfc.fw", 1436 .fw_name[0] = "s5p-mfc.fw",
1437 .clk_names = {"mfc", "sclk_mfc"},
1438 .num_clocks = 2,
1439 .use_clock_gating = true,
1441}; 1440};
1442 1441
1443static struct s5p_mfc_buf_size_v6 mfc_buf_size_v6 = { 1442static struct s5p_mfc_buf_size_v6 mfc_buf_size_v6 = {
@@ -1470,6 +1469,8 @@ static struct s5p_mfc_variant mfc_drvdata_v6 = {
1470 * for init buffer command 1469 * for init buffer command
1471 */ 1470 */
1472 .fw_name[1] = "s5p-mfc-v6-v2.fw", 1471 .fw_name[1] = "s5p-mfc-v6-v2.fw",
1472 .clk_names = {"mfc"},
1473 .num_clocks = 1,
1473}; 1474};
1474 1475
1475static struct s5p_mfc_buf_size_v6 mfc_buf_size_v7 = { 1476static struct s5p_mfc_buf_size_v6 mfc_buf_size_v7 = {
@@ -1497,6 +1498,8 @@ static struct s5p_mfc_variant mfc_drvdata_v7 = {
1497 .buf_size = &buf_size_v7, 1498 .buf_size = &buf_size_v7,
1498 .buf_align = &mfc_buf_align_v7, 1499 .buf_align = &mfc_buf_align_v7,
1499 .fw_name[0] = "s5p-mfc-v7.fw", 1500 .fw_name[0] = "s5p-mfc-v7.fw",
1501 .clk_names = {"mfc", "sclk_mfc"},
1502 .num_clocks = 2,
1500}; 1503};
1501 1504
1502static struct s5p_mfc_buf_size_v6 mfc_buf_size_v8 = { 1505static struct s5p_mfc_buf_size_v6 mfc_buf_size_v8 = {
@@ -1524,6 +1527,19 @@ static struct s5p_mfc_variant mfc_drvdata_v8 = {
1524 .buf_size = &buf_size_v8, 1527 .buf_size = &buf_size_v8,
1525 .buf_align = &mfc_buf_align_v8, 1528 .buf_align = &mfc_buf_align_v8,
1526 .fw_name[0] = "s5p-mfc-v8.fw", 1529 .fw_name[0] = "s5p-mfc-v8.fw",
1530 .clk_names = {"mfc"},
1531 .num_clocks = 1,
1532};
1533
1534static struct s5p_mfc_variant mfc_drvdata_v8_5433 = {
1535 .version = MFC_VERSION_V8,
1536 .version_bit = MFC_V8_BIT,
1537 .port_num = MFC_NUM_PORTS_V8,
1538 .buf_size = &buf_size_v8,
1539 .buf_align = &mfc_buf_align_v8,
1540 .fw_name[0] = "s5p-mfc-v8.fw",
1541 .clk_names = {"pclk", "aclk", "aclk_xiu"},
1542 .num_clocks = 3,
1527}; 1543};
1528 1544
1529static const struct of_device_id exynos_mfc_match[] = { 1545static const struct of_device_id exynos_mfc_match[] = {
@@ -1539,6 +1555,9 @@ static const struct of_device_id exynos_mfc_match[] = {
1539 }, { 1555 }, {
1540 .compatible = "samsung,mfc-v8", 1556 .compatible = "samsung,mfc-v8",
1541 .data = &mfc_drvdata_v8, 1557 .data = &mfc_drvdata_v8,
1558 }, {
1559 .compatible = "samsung,exynos5433-mfc",
1560 .data = &mfc_drvdata_v8_5433,
1542 }, 1561 },
1543 {}, 1562 {},
1544}; 1563};
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index 46b99f28cbd7..ab23236aa942 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -104,6 +104,8 @@ static inline dma_addr_t s5p_mfc_mem_cookie(void *a, void *b)
104#define S5P_MFC_R2H_CMD_ENC_BUFFER_FUL_RET 16 104#define S5P_MFC_R2H_CMD_ENC_BUFFER_FUL_RET 16
105#define S5P_MFC_R2H_CMD_ERR_RET 32 105#define S5P_MFC_R2H_CMD_ERR_RET 32
106 106
107#define MFC_MAX_CLOCKS 4
108
107#define mfc_read(dev, offset) readl(dev->regs_base + (offset)) 109#define mfc_read(dev, offset) readl(dev->regs_base + (offset))
108#define mfc_write(dev, data, offset) writel((data), dev->regs_base + \ 110#define mfc_write(dev, data, offset) writel((data), dev->regs_base + \
109 (offset)) 111 (offset))
@@ -197,9 +199,12 @@ struct s5p_mfc_buf {
197 * struct s5p_mfc_pm - power management data structure 199 * struct s5p_mfc_pm - power management data structure
198 */ 200 */
199struct s5p_mfc_pm { 201struct s5p_mfc_pm {
200 struct clk *clock;
201 struct clk *clock_gate; 202 struct clk *clock_gate;
202 atomic_t power; 203 const char **clk_names;
204 struct clk *clocks[MFC_MAX_CLOCKS];
205 int num_clocks;
206 bool use_clock_gating;
207
203 struct device *device; 208 struct device *device;
204}; 209};
205 210
@@ -235,6 +240,9 @@ struct s5p_mfc_variant {
235 struct s5p_mfc_buf_size *buf_size; 240 struct s5p_mfc_buf_size *buf_size;
236 struct s5p_mfc_buf_align *buf_align; 241 struct s5p_mfc_buf_align *buf_align;
237 char *fw_name[MFC_FW_MAX_VERSIONS]; 242 char *fw_name[MFC_FW_MAX_VERSIONS];
243 const char *clk_names[MFC_MAX_CLOCKS];
244 int num_clocks;
245 bool use_clock_gating;
238}; 246};
239 247
240/** 248/**
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_debug.h b/drivers/media/platform/s5p-mfc/s5p_mfc_debug.h
index 5936923c631c..1936a5b868f5 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_debug.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_debug.h
@@ -39,6 +39,12 @@ extern int mfc_debug_level;
39 __func__, __LINE__, ##args); \ 39 __func__, __LINE__, ##args); \
40 } while (0) 40 } while (0)
41 41
42#define mfc_err_limited(fmt, args...) \
43 do { \
44 printk_ratelimited(KERN_ERR "%s:%d: " fmt, \
45 __func__, __LINE__, ##args); \
46 } while (0)
47
42#define mfc_info(fmt, args...) \ 48#define mfc_info(fmt, args...) \
43 do { \ 49 do { \
44 printk(KERN_INFO "%s:%d: " fmt, \ 50 printk(KERN_INFO "%s:%d: " fmt, \
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index 52081ddc9bf2..367ef8e8dbf0 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -642,7 +642,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
642 int ret; 642 int ret;
643 643
644 if (ctx->state == MFCINST_ERROR) { 644 if (ctx->state == MFCINST_ERROR) {
645 mfc_err("Call on DQBUF after unrecoverable error\n"); 645 mfc_err_limited("Call on DQBUF after unrecoverable error\n");
646 return -EIO; 646 return -EIO;
647 } 647 }
648 648
@@ -793,18 +793,17 @@ static int vidioc_g_crop(struct file *file, void *priv,
793 cr->c.top = top; 793 cr->c.top = top;
794 cr->c.width = ctx->img_width - left - right; 794 cr->c.width = ctx->img_width - left - right;
795 cr->c.height = ctx->img_height - top - bottom; 795 cr->c.height = ctx->img_height - top - bottom;
796 mfc_debug(2, "Cropping info [h264]: l=%d t=%d " 796 mfc_debug(2, "Cropping info [h264]: l=%d t=%d w=%d h=%d (r=%d b=%d fw=%d fh=%d\n",
797 "w=%d h=%d (r=%d b=%d fw=%d fh=%d\n", left, top, 797 left, top, cr->c.width, cr->c.height, right, bottom,
798 cr->c.width, cr->c.height, right, bottom, 798 ctx->buf_width, ctx->buf_height);
799 ctx->buf_width, ctx->buf_height);
800 } else { 799 } else {
801 cr->c.left = 0; 800 cr->c.left = 0;
802 cr->c.top = 0; 801 cr->c.top = 0;
803 cr->c.width = ctx->img_width; 802 cr->c.width = ctx->img_width;
804 cr->c.height = ctx->img_height; 803 cr->c.height = ctx->img_height;
805 mfc_debug(2, "Cropping info: w=%d h=%d fw=%d " 804 mfc_debug(2, "Cropping info: w=%d h=%d fw=%d fh=%d\n",
806 "fh=%d\n", cr->c.width, cr->c.height, ctx->buf_width, 805 cr->c.width, cr->c.height, ctx->buf_width,
807 ctx->buf_height); 806 ctx->buf_height);
808 } 807 }
809 return 0; 808 return 0;
810} 809}
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index fcc2e054c61f..e39d9e06e299 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -1268,7 +1268,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
1268 int ret; 1268 int ret;
1269 1269
1270 if (ctx->state == MFCINST_ERROR) { 1270 if (ctx->state == MFCINST_ERROR) {
1271 mfc_err("Call on DQBUF after unrecoverable error\n"); 1271 mfc_err_limited("Call on DQBUF after unrecoverable error\n");
1272 return -EIO; 1272 return -EIO;
1273 } 1273 }
1274 if (buf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { 1274 if (buf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr.c b/drivers/media/platform/s5p-mfc/s5p_mfc_opr.c
index 1e7250260a9a..99f65a92a6be 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr.c
@@ -45,13 +45,13 @@ int s5p_mfc_alloc_priv_buf(struct device *dev, dma_addr_t base,
45 b->virt = dma_alloc_coherent(dev, b->size, &b->dma, GFP_KERNEL); 45 b->virt = dma_alloc_coherent(dev, b->size, &b->dma, GFP_KERNEL);
46 46
47 if (!b->virt) { 47 if (!b->virt) {
48 mfc_err("Allocating private buffer failed\n"); 48 mfc_err("Allocating private buffer of size %zu failed\n",
49 b->size);
49 return -ENOMEM; 50 return -ENOMEM;
50 } 51 }
51 52
52 if (b->dma < base) { 53 if (b->dma < base) {
53 mfc_err("Invaling memory configuration!\n"); 54 mfc_err("Invalid memory configuration - buffer (%pad) is below base memory address(%pad)\n",
54 mfc_err("Allocated buffer (%pad) is lower than memory base address (%pad)\n",
55 &b->dma, &base); 55 &b->dma, &base);
56 dma_free_coherent(dev, b->size, b->virt, b->dma); 56 dma_free_coherent(dev, b->size, b->virt, b->dma);
57 return -ENOMEM; 57 return -ENOMEM;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
index 81e1e4ce6c24..f4301d5bbd32 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
@@ -1293,14 +1293,11 @@ static int s5p_mfc_run_init_dec_buffers(struct s5p_mfc_ctx *ctx)
1293 * First set the output frame buffers 1293 * First set the output frame buffers
1294 */ 1294 */
1295 if (ctx->capture_state != QUEUE_BUFS_MMAPED) { 1295 if (ctx->capture_state != QUEUE_BUFS_MMAPED) {
1296 mfc_err("It seems that not all destionation buffers were " 1296 mfc_err("It seems that not all destionation buffers were mmaped\nMFC requires that all destination are mmaped before starting processing\n");
1297 "mmaped\nMFC requires that all destination are mmaped "
1298 "before starting processing\n");
1299 return -EAGAIN; 1297 return -EAGAIN;
1300 } 1298 }
1301 if (list_empty(&ctx->src_queue)) { 1299 if (list_empty(&ctx->src_queue)) {
1302 mfc_err("Header has been deallocated in the middle of" 1300 mfc_err("Header has been deallocated in the middle of initialization\n");
1303 " initialization\n");
1304 return -EIO; 1301 return -EIO;
1305 } 1302 }
1306 temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); 1303 temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
index 930dc2dddae6..eb85cedc5ef3 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
@@ -18,129 +18,101 @@
18#include "s5p_mfc_debug.h" 18#include "s5p_mfc_debug.h"
19#include "s5p_mfc_pm.h" 19#include "s5p_mfc_pm.h"
20 20
21#define MFC_GATE_CLK_NAME "mfc"
22#define MFC_SCLK_NAME "sclk_mfc"
23#define MFC_SCLK_RATE (200 * 1000000)
24
25#define CLK_DEBUG
26
27static struct s5p_mfc_pm *pm; 21static struct s5p_mfc_pm *pm;
28static struct s5p_mfc_dev *p_dev; 22static struct s5p_mfc_dev *p_dev;
29
30#ifdef CLK_DEBUG
31static atomic_t clk_ref; 23static atomic_t clk_ref;
32#endif
33 24
34int s5p_mfc_init_pm(struct s5p_mfc_dev *dev) 25int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
35{ 26{
36 int ret = 0; 27 int i;
37 28
38 pm = &dev->pm; 29 pm = &dev->pm;
39 p_dev = dev; 30 p_dev = dev;
40 pm->clock_gate = clk_get(&dev->plat_dev->dev, MFC_GATE_CLK_NAME);
41 if (IS_ERR(pm->clock_gate)) {
42 mfc_err("Failed to get clock-gating control\n");
43 ret = PTR_ERR(pm->clock_gate);
44 goto err_g_ip_clk;
45 }
46 31
47 ret = clk_prepare(pm->clock_gate); 32 pm->num_clocks = dev->variant->num_clocks;
48 if (ret) { 33 pm->clk_names = dev->variant->clk_names;
49 mfc_err("Failed to prepare clock-gating control\n"); 34 pm->device = &dev->plat_dev->dev;
50 goto err_p_ip_clk; 35 pm->clock_gate = NULL;
51 }
52 36
53 if (dev->variant->version != MFC_VERSION_V6) { 37 /* clock control */
54 pm->clock = clk_get(&dev->plat_dev->dev, MFC_SCLK_NAME); 38 for (i = 0; i < pm->num_clocks; i++) {
55 if (IS_ERR(pm->clock)) { 39 pm->clocks[i] = devm_clk_get(pm->device, pm->clk_names[i]);
56 mfc_info("Failed to get MFC special clock control\n"); 40 if (IS_ERR(pm->clocks[i])) {
57 pm->clock = NULL; 41 mfc_err("Failed to get clock: %s\n",
58 } else { 42 pm->clk_names[i]);
59 clk_set_rate(pm->clock, MFC_SCLK_RATE); 43 return PTR_ERR(pm->clocks[i]);
60 ret = clk_prepare_enable(pm->clock);
61 if (ret) {
62 mfc_err("Failed to enable MFC special clock\n");
63 goto err_s_clk;
64 }
65 } 44 }
66 } 45 }
67 46
68 atomic_set(&pm->power, 0); 47 if (dev->variant->use_clock_gating)
69#ifdef CONFIG_PM 48 pm->clock_gate = pm->clocks[0];
70 pm->device = &dev->plat_dev->dev; 49
71 pm_runtime_enable(pm->device); 50 pm_runtime_enable(pm->device);
72#endif
73#ifdef CLK_DEBUG
74 atomic_set(&clk_ref, 0); 51 atomic_set(&clk_ref, 0);
75#endif
76 return 0; 52 return 0;
77
78err_s_clk:
79 clk_put(pm->clock);
80 pm->clock = NULL;
81err_p_ip_clk:
82 clk_put(pm->clock_gate);
83 pm->clock_gate = NULL;
84err_g_ip_clk:
85 return ret;
86} 53}
87 54
88void s5p_mfc_final_pm(struct s5p_mfc_dev *dev) 55void s5p_mfc_final_pm(struct s5p_mfc_dev *dev)
89{ 56{
90 if (dev->variant->version != MFC_VERSION_V6 &&
91 pm->clock) {
92 clk_disable_unprepare(pm->clock);
93 clk_put(pm->clock);
94 pm->clock = NULL;
95 }
96 clk_unprepare(pm->clock_gate);
97 clk_put(pm->clock_gate);
98 pm->clock_gate = NULL;
99#ifdef CONFIG_PM
100 pm_runtime_disable(pm->device); 57 pm_runtime_disable(pm->device);
101#endif
102} 58}
103 59
104int s5p_mfc_clock_on(void) 60int s5p_mfc_clock_on(void)
105{ 61{
106 int ret = 0;
107#ifdef CLK_DEBUG
108 atomic_inc(&clk_ref); 62 atomic_inc(&clk_ref);
109 mfc_debug(3, "+ %d\n", atomic_read(&clk_ref)); 63 mfc_debug(3, "+ %d\n", atomic_read(&clk_ref));
110#endif 64
111 if (!IS_ERR_OR_NULL(pm->clock_gate)) 65 return clk_enable(pm->clock_gate);
112 ret = clk_enable(pm->clock_gate);
113 return ret;
114} 66}
115 67
116void s5p_mfc_clock_off(void) 68void s5p_mfc_clock_off(void)
117{ 69{
118#ifdef CLK_DEBUG
119 atomic_dec(&clk_ref); 70 atomic_dec(&clk_ref);
120 mfc_debug(3, "- %d\n", atomic_read(&clk_ref)); 71 mfc_debug(3, "- %d\n", atomic_read(&clk_ref));
121#endif 72
122 if (!IS_ERR_OR_NULL(pm->clock_gate)) 73 clk_disable(pm->clock_gate);
123 clk_disable(pm->clock_gate);
124} 74}
125 75
126int s5p_mfc_power_on(void) 76int s5p_mfc_power_on(void)
127{ 77{
128#ifdef CONFIG_PM 78 int i, ret = 0;
129 return pm_runtime_get_sync(pm->device); 79
130#else 80 ret = pm_runtime_get_sync(pm->device);
131 atomic_set(&pm->power, 1); 81 if (ret < 0)
82 return ret;
83
84 /* clock control */
85 for (i = 0; i < pm->num_clocks; i++) {
86 ret = clk_prepare_enable(pm->clocks[i]);
87 if (ret < 0) {
88 mfc_err("clock prepare failed for clock: %s\n",
89 pm->clk_names[i]);
90 i++;
91 goto err;
92 }
93 }
94
95 /* prepare for software clock gating */
96 clk_disable(pm->clock_gate);
97
132 return 0; 98 return 0;
133#endif 99err:
100 while (--i > 0)
101 clk_disable_unprepare(pm->clocks[i]);
102 pm_runtime_put(pm->device);
103 return ret;
134} 104}
135 105
136int s5p_mfc_power_off(void) 106int s5p_mfc_power_off(void)
137{ 107{
138#ifdef CONFIG_PM 108 int i;
109
110 /* finish software clock gating */
111 clk_enable(pm->clock_gate);
112
113 for (i = 0; i < pm->num_clocks; i++)
114 clk_disable_unprepare(pm->clocks[i]);
115
139 return pm_runtime_put_sync(pm->device); 116 return pm_runtime_put_sync(pm->device);
140#else
141 atomic_set(&pm->power, 0);
142 return 0;
143#endif
144} 117}
145 118
146
diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
index 45f82b5ddd77..823608112d89 100644
--- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
+++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
@@ -1337,6 +1337,7 @@ static int bdisp_probe(struct platform_device *pdev)
1337 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 1337 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1338 if (!res) { 1338 if (!res) {
1339 dev_err(dev, "failed to get IRQ resource\n"); 1339 dev_err(dev, "failed to get IRQ resource\n");
1340 ret = -EINVAL;
1340 goto err_clk; 1341 goto err_clk;
1341 } 1342 }
1342 1343
diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
index 30c148b9d65e..7652ce2ec1dc 100644
--- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
+++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
@@ -112,8 +112,7 @@ static void channel_swdemux_tsklet(unsigned long data)
112 buf = (u8 *) channel->back_buffer_aligned; 112 buf = (u8 *) channel->back_buffer_aligned;
113 113
114 dev_dbg(fei->dev, 114 dev_dbg(fei->dev,
115 "chan=%d channel=%p num_packets = %d, buf = %p, pos = 0x%x\n\t" 115 "chan=%d channel=%p num_packets = %d, buf = %p, pos = 0x%x\n\trp=0x%lx, wp=0x%lx\n",
116 "rp=0x%lx, wp=0x%lx\n",
117 channel->tsin_id, channel, num_packets, buf, pos, rp, wp); 116 channel->tsin_id, channel, num_packets, buf, pos, rp, wp);
118 117
119 for (n = 0; n < num_packets; n++) { 118 for (n = 0; n < num_packets; n++) {
@@ -789,8 +788,7 @@ static int c8sectpfe_probe(struct platform_device *pdev)
789 /* sanity check value */ 788 /* sanity check value */
790 if (tsin->tsin_id > fei->hw_stats.num_ib) { 789 if (tsin->tsin_id > fei->hw_stats.num_ib) {
791 dev_err(&pdev->dev, 790 dev_err(&pdev->dev,
792 "tsin-num %d specified greater than number\n\t" 791 "tsin-num %d specified greater than number\n\tof input block hw in SoC! (%d)",
793 "of input block hw in SoC! (%d)",
794 tsin->tsin_id, fei->hw_stats.num_ib); 792 tsin->tsin_id, fei->hw_stats.num_ib);
795 ret = -EINVAL; 793 ret = -EINVAL;
796 goto err_clk_disable; 794 goto err_clk_disable;
@@ -815,6 +813,7 @@ static int c8sectpfe_probe(struct platform_device *pdev)
815 i2c_bus = of_parse_phandle(child, "i2c-bus", 0); 813 i2c_bus = of_parse_phandle(child, "i2c-bus", 0);
816 if (!i2c_bus) { 814 if (!i2c_bus) {
817 dev_err(&pdev->dev, "No i2c-bus found\n"); 815 dev_err(&pdev->dev, "No i2c-bus found\n");
816 ret = -ENODEV;
818 goto err_clk_disable; 817 goto err_clk_disable;
819 } 818 }
820 tsin->i2c_adapter = 819 tsin->i2c_adapter =
@@ -822,6 +821,7 @@ static int c8sectpfe_probe(struct platform_device *pdev)
822 if (!tsin->i2c_adapter) { 821 if (!tsin->i2c_adapter) {
823 dev_err(&pdev->dev, "No i2c adapter found\n"); 822 dev_err(&pdev->dev, "No i2c adapter found\n");
824 of_node_put(i2c_bus); 823 of_node_put(i2c_bus);
824 ret = -ENODEV;
825 goto err_clk_disable; 825 goto err_clk_disable;
826 } 826 }
827 of_node_put(i2c_bus); 827 of_node_put(i2c_bus);
@@ -855,8 +855,7 @@ static int c8sectpfe_probe(struct platform_device *pdev)
855 tsin->demux_mapping = index; 855 tsin->demux_mapping = index;
856 856
857 dev_dbg(fei->dev, 857 dev_dbg(fei->dev,
858 "channel=%p n=%d tsin_num=%d, invert-ts-clk=%d\n\t" 858 "channel=%p n=%d tsin_num=%d, invert-ts-clk=%d\n\tserial-not-parallel=%d pkt-clk-valid=%d dvb-card=%d\n",
859 "serial-not-parallel=%d pkt-clk-valid=%d dvb-card=%d\n",
860 fei->channel_data[index], index, 859 fei->channel_data[index], index,
861 tsin->tsin_id, tsin->invert_ts_clk, 860 tsin->tsin_id, tsin->invert_ts_clk,
862 tsin->serial_not_parallel, tsin->async_not_sync, 861 tsin->serial_not_parallel, tsin->async_not_sync,
@@ -888,8 +887,7 @@ static int c8sectpfe_probe(struct platform_device *pdev)
888 return 0; 887 return 0;
889 888
890err_clk_disable: 889err_clk_disable:
891 /* TODO uncomment when upstream has taken a reference on this clk */ 890 clk_disable_unprepare(fei->c8sectpfeclk);
892 /*clk_disable_unprepare(fei->c8sectpfeclk);*/
893 return ret; 891 return ret;
894} 892}
895 893
@@ -924,11 +922,8 @@ static int c8sectpfe_remove(struct platform_device *pdev)
924 if (readl(fei->io + SYS_OTHER_CLKEN)) 922 if (readl(fei->io + SYS_OTHER_CLKEN))
925 writel(0, fei->io + SYS_OTHER_CLKEN); 923 writel(0, fei->io + SYS_OTHER_CLKEN);
926 924
927 /* TODO uncomment when upstream has taken a reference on this clk */
928 /*
929 if (fei->c8sectpfeclk) 925 if (fei->c8sectpfeclk)
930 clk_disable_unprepare(fei->c8sectpfeclk); 926 clk_disable_unprepare(fei->c8sectpfeclk);
931 */
932 927
933 return 0; 928 return 0;
934} 929}
@@ -1045,8 +1040,8 @@ static void load_imem_segment(struct c8sectpfei *fei, Elf32_Phdr *phdr,
1045 */ 1040 */
1046 1041
1047 dev_dbg(fei->dev, 1042 dev_dbg(fei->dev,
1048 "Loading IMEM segment %d 0x%08x\n\t" 1043 "Loading IMEM segment %d 0x%08x\n\t (0x%x bytes) -> 0x%p (0x%x bytes)\n",
1049 " (0x%x bytes) -> 0x%p (0x%x bytes)\n", seg_num, 1044seg_num,
1050 phdr->p_paddr, phdr->p_filesz, 1045 phdr->p_paddr, phdr->p_filesz,
1051 dest, phdr->p_memsz + phdr->p_memsz / 3); 1046 dest, phdr->p_memsz + phdr->p_memsz / 3);
1052 1047
@@ -1075,8 +1070,7 @@ static void load_dmem_segment(struct c8sectpfei *fei, Elf32_Phdr *phdr,
1075 */ 1070 */
1076 1071
1077 dev_dbg(fei->dev, 1072 dev_dbg(fei->dev,
1078 "Loading DMEM segment %d 0x%08x\n\t" 1073 "Loading DMEM segment %d 0x%08x\n\t(0x%x bytes) -> 0x%p (0x%x bytes)\n",
1079 "(0x%x bytes) -> 0x%p (0x%x bytes)\n",
1080 seg_num, phdr->p_paddr, phdr->p_filesz, 1074 seg_num, phdr->p_paddr, phdr->p_filesz,
1081 dst, phdr->p_memsz); 1075 dst, phdr->p_memsz);
1082 1076
diff --git a/drivers/media/platform/sti/hva/hva-hw.c b/drivers/media/platform/sti/hva/hva-hw.c
index d341d4994528..68d625b412b6 100644
--- a/drivers/media/platform/sti/hva/hva-hw.c
+++ b/drivers/media/platform/sti/hva/hva-hw.c
@@ -245,7 +245,7 @@ static irqreturn_t hva_hw_err_irq_thread(int irq, void *arg)
245 ctx->hw_err = true; 245 ctx->hw_err = true;
246 } 246 }
247 247
248 if (hva->lmi_err_reg) { 248 if (hva->emi_err_reg) {
249 dev_err(dev, "%s external memory interface error: 0x%08x\n", 249 dev_err(dev, "%s external memory interface error: 0x%08x\n",
250 ctx->name, hva->emi_err_reg); 250 ctx->name, hva->emi_err_reg);
251 ctx->hw_err = true; 251 ctx->hw_err = true;
@@ -305,16 +305,16 @@ int hva_hw_probe(struct platform_device *pdev, struct hva_dev *hva)
305 /* get memory for registers */ 305 /* get memory for registers */
306 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 306 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
307 hva->regs = devm_ioremap_resource(dev, regs); 307 hva->regs = devm_ioremap_resource(dev, regs);
308 if (IS_ERR_OR_NULL(hva->regs)) { 308 if (IS_ERR(hva->regs)) {
309 dev_err(dev, "%s failed to get regs\n", HVA_PREFIX); 309 dev_err(dev, "%s failed to get regs\n", HVA_PREFIX);
310 return PTR_ERR(hva->regs); 310 return PTR_ERR(hva->regs);
311 } 311 }
312 312
313 /* get memory for esram */ 313 /* get memory for esram */
314 esram = platform_get_resource(pdev, IORESOURCE_MEM, 1); 314 esram = platform_get_resource(pdev, IORESOURCE_MEM, 1);
315 if (IS_ERR_OR_NULL(esram)) { 315 if (!esram) {
316 dev_err(dev, "%s failed to get esram\n", HVA_PREFIX); 316 dev_err(dev, "%s failed to get esram\n", HVA_PREFIX);
317 return PTR_ERR(esram); 317 return -ENODEV;
318 } 318 }
319 hva->esram_addr = esram->start; 319 hva->esram_addr = esram->start;
320 hva->esram_size = resource_size(esram); 320 hva->esram_size = resource_size(esram);
diff --git a/drivers/media/platform/ti-vpe/Makefile b/drivers/media/platform/ti-vpe/Makefile
index e236059a60ad..32504b724b5d 100644
--- a/drivers/media/platform/ti-vpe/Makefile
+++ b/drivers/media/platform/ti-vpe/Makefile
@@ -1,6 +1,12 @@
1obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe.o 1obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe.o
2 2obj-$(CONFIG_VIDEO_TI_VPDMA) += ti-vpdma.o
3ti-vpe-y := vpe.o sc.o csc.o vpdma.o 3obj-$(CONFIG_VIDEO_TI_SC) += ti-sc.o
4obj-$(CONFIG_VIDEO_TI_CSC) += ti-csc.o
5
6ti-vpe-y := vpe.o
7ti-vpdma-y := vpdma.o
8ti-sc-y := sc.o
9ti-csc-y := csc.o
4 10
5ccflags-$(CONFIG_VIDEO_TI_VPE_DEBUG) += -DDEBUG 11ccflags-$(CONFIG_VIDEO_TI_VPE_DEBUG) += -DDEBUG
6 12
diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
index 44323cb5d287..7a058b6e03d0 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -483,11 +483,7 @@ static void cal_get_hwinfo(struct cal_dev *dev)
483 483
484static inline int cal_runtime_get(struct cal_dev *dev) 484static inline int cal_runtime_get(struct cal_dev *dev)
485{ 485{
486 int r; 486 return pm_runtime_get_sync(&dev->pdev->dev);
487
488 r = pm_runtime_get_sync(&dev->pdev->dev);
489
490 return r;
491} 487}
492 488
493static inline void cal_runtime_put(struct cal_dev *dev) 489static inline void cal_runtime_put(struct cal_dev *dev)
@@ -1749,13 +1745,13 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
1749 } 1745 }
1750 1746
1751cleanup_exit: 1747cleanup_exit:
1752 if (!remote_ep) 1748 if (remote_ep)
1753 of_node_put(remote_ep); 1749 of_node_put(remote_ep);
1754 if (!sensor_node) 1750 if (sensor_node)
1755 of_node_put(sensor_node); 1751 of_node_put(sensor_node);
1756 if (!ep_node) 1752 if (ep_node)
1757 of_node_put(ep_node); 1753 of_node_put(ep_node);
1758 if (!port) 1754 if (port)
1759 of_node_put(port); 1755 of_node_put(port);
1760 1756
1761 return ret; 1757 return ret;
diff --git a/drivers/media/platform/ti-vpe/csc.c b/drivers/media/platform/ti-vpe/csc.c
index bec674994752..44b8465cf101 100644
--- a/drivers/media/platform/ti-vpe/csc.c
+++ b/drivers/media/platform/ti-vpe/csc.c
@@ -14,6 +14,7 @@
14 14
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/module.h>
17#include <linux/platform_device.h> 18#include <linux/platform_device.h>
18#include <linux/slab.h> 19#include <linux/slab.h>
19#include <linux/videodev2.h> 20#include <linux/videodev2.h>
@@ -96,6 +97,8 @@ void csc_dump_regs(struct csc_data *csc)
96#define DUMPREG(r) dev_dbg(dev, "%-35s %08x\n", #r, \ 97#define DUMPREG(r) dev_dbg(dev, "%-35s %08x\n", #r, \
97 ioread32(csc->base + CSC_##r)) 98 ioread32(csc->base + CSC_##r))
98 99
100 dev_dbg(dev, "CSC Registers @ %pa:\n", &csc->res->start);
101
99 DUMPREG(CSC00); 102 DUMPREG(CSC00);
100 DUMPREG(CSC01); 103 DUMPREG(CSC01);
101 DUMPREG(CSC02); 104 DUMPREG(CSC02);
@@ -105,11 +108,13 @@ void csc_dump_regs(struct csc_data *csc)
105 108
106#undef DUMPREG 109#undef DUMPREG
107} 110}
111EXPORT_SYMBOL(csc_dump_regs);
108 112
109void csc_set_coeff_bypass(struct csc_data *csc, u32 *csc_reg5) 113void csc_set_coeff_bypass(struct csc_data *csc, u32 *csc_reg5)
110{ 114{
111 *csc_reg5 |= CSC_BYPASS; 115 *csc_reg5 |= CSC_BYPASS;
112} 116}
117EXPORT_SYMBOL(csc_set_coeff_bypass);
113 118
114/* 119/*
115 * set the color space converter coefficient shadow register values 120 * set the color space converter coefficient shadow register values
@@ -160,8 +165,9 @@ void csc_set_coeff(struct csc_data *csc, u32 *csc_reg0,
160 for (; coeff < end_coeff; coeff += 2) 165 for (; coeff < end_coeff; coeff += 2)
161 *shadow_csc++ = (*(coeff + 1) << 16) | *coeff; 166 *shadow_csc++ = (*(coeff + 1) << 16) | *coeff;
162} 167}
168EXPORT_SYMBOL(csc_set_coeff);
163 169
164struct csc_data *csc_create(struct platform_device *pdev) 170struct csc_data *csc_create(struct platform_device *pdev, const char *res_name)
165{ 171{
166 struct csc_data *csc; 172 struct csc_data *csc;
167 173
@@ -176,9 +182,10 @@ struct csc_data *csc_create(struct platform_device *pdev)
176 csc->pdev = pdev; 182 csc->pdev = pdev;
177 183
178 csc->res = platform_get_resource_byname(pdev, IORESOURCE_MEM, 184 csc->res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
179 "csc"); 185 res_name);
180 if (csc->res == NULL) { 186 if (csc->res == NULL) {
181 dev_err(&pdev->dev, "missing platform resources data\n"); 187 dev_err(&pdev->dev, "missing '%s' platform resources data\n",
188 res_name);
182 return ERR_PTR(-ENODEV); 189 return ERR_PTR(-ENODEV);
183 } 190 }
184 191
@@ -190,3 +197,8 @@ struct csc_data *csc_create(struct platform_device *pdev)
190 197
191 return csc; 198 return csc;
192} 199}
200EXPORT_SYMBOL(csc_create);
201
202MODULE_DESCRIPTION("TI VIP/VPE Color Space Converter");
203MODULE_AUTHOR("Texas Instruments Inc.");
204MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/ti-vpe/csc.h b/drivers/media/platform/ti-vpe/csc.h
index 1ad2b6dad561..024700b15152 100644
--- a/drivers/media/platform/ti-vpe/csc.h
+++ b/drivers/media/platform/ti-vpe/csc.h
@@ -63,6 +63,6 @@ void csc_set_coeff_bypass(struct csc_data *csc, u32 *csc_reg5);
63void csc_set_coeff(struct csc_data *csc, u32 *csc_reg0, 63void csc_set_coeff(struct csc_data *csc, u32 *csc_reg0,
64 enum v4l2_colorspace src_colorspace, 64 enum v4l2_colorspace src_colorspace,
65 enum v4l2_colorspace dst_colorspace); 65 enum v4l2_colorspace dst_colorspace);
66struct csc_data *csc_create(struct platform_device *pdev); 66struct csc_data *csc_create(struct platform_device *pdev, const char *res_name);
67 67
68#endif 68#endif
diff --git a/drivers/media/platform/ti-vpe/sc.c b/drivers/media/platform/ti-vpe/sc.c
index f82d1c7f667f..e9273b713782 100644
--- a/drivers/media/platform/ti-vpe/sc.c
+++ b/drivers/media/platform/ti-vpe/sc.c
@@ -14,6 +14,7 @@
14 14
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/module.h>
17#include <linux/platform_device.h> 18#include <linux/platform_device.h>
18#include <linux/slab.h> 19#include <linux/slab.h>
19 20
@@ -27,6 +28,8 @@ void sc_dump_regs(struct sc_data *sc)
27#define DUMPREG(r) dev_dbg(dev, "%-35s %08x\n", #r, \ 28#define DUMPREG(r) dev_dbg(dev, "%-35s %08x\n", #r, \
28 ioread32(sc->base + CFG_##r)) 29 ioread32(sc->base + CFG_##r))
29 30
31 dev_dbg(dev, "SC Registers @ %pa:\n", &sc->res->start);
32
30 DUMPREG(SC0); 33 DUMPREG(SC0);
31 DUMPREG(SC1); 34 DUMPREG(SC1);
32 DUMPREG(SC2); 35 DUMPREG(SC2);
@@ -52,6 +55,7 @@ void sc_dump_regs(struct sc_data *sc)
52 55
53#undef DUMPREG 56#undef DUMPREG
54} 57}
58EXPORT_SYMBOL(sc_dump_regs);
55 59
56/* 60/*
57 * set the horizontal scaler coefficients according to the ratio of output to 61 * set the horizontal scaler coefficients according to the ratio of output to
@@ -84,9 +88,6 @@ void sc_set_hs_coeffs(struct sc_data *sc, void *addr, unsigned int src_w,
84 } 88 }
85 } 89 }
86 90
87 if (idx == sc->hs_index)
88 return;
89
90 cp = scaler_hs_coeffs[idx]; 91 cp = scaler_hs_coeffs[idx];
91 92
92 for (i = 0; i < SC_NUM_PHASES * 2; i++) { 93 for (i = 0; i < SC_NUM_PHASES * 2; i++) {
@@ -101,10 +102,9 @@ void sc_set_hs_coeffs(struct sc_data *sc, void *addr, unsigned int src_w,
101 coeff_h += SC_NUM_TAPS_MEM_ALIGN - SC_H_NUM_TAPS; 102 coeff_h += SC_NUM_TAPS_MEM_ALIGN - SC_H_NUM_TAPS;
102 } 103 }
103 104
104 sc->hs_index = idx;
105
106 sc->load_coeff_h = true; 105 sc->load_coeff_h = true;
107} 106}
107EXPORT_SYMBOL(sc_set_hs_coeffs);
108 108
109/* 109/*
110 * set the vertical scaler coefficients according to the ratio of output to 110 * set the vertical scaler coefficients according to the ratio of output to
@@ -130,9 +130,6 @@ void sc_set_vs_coeffs(struct sc_data *sc, void *addr, unsigned int src_h,
130 idx = VS_LT_9_16_SCALE + sixteenths - 8; 130 idx = VS_LT_9_16_SCALE + sixteenths - 8;
131 } 131 }
132 132
133 if (idx == sc->vs_index)
134 return;
135
136 cp = scaler_vs_coeffs[idx]; 133 cp = scaler_vs_coeffs[idx];
137 134
138 for (i = 0; i < SC_NUM_PHASES * 2; i++) { 135 for (i = 0; i < SC_NUM_PHASES * 2; i++) {
@@ -146,9 +143,9 @@ void sc_set_vs_coeffs(struct sc_data *sc, void *addr, unsigned int src_h,
146 coeff_v += SC_NUM_TAPS_MEM_ALIGN - SC_V_NUM_TAPS; 143 coeff_v += SC_NUM_TAPS_MEM_ALIGN - SC_V_NUM_TAPS;
147 } 144 }
148 145
149 sc->vs_index = idx;
150 sc->load_coeff_v = true; 146 sc->load_coeff_v = true;
151} 147}
148EXPORT_SYMBOL(sc_set_vs_coeffs);
152 149
153void sc_config_scaler(struct sc_data *sc, u32 *sc_reg0, u32 *sc_reg8, 150void sc_config_scaler(struct sc_data *sc, u32 *sc_reg0, u32 *sc_reg8,
154 u32 *sc_reg17, unsigned int src_w, unsigned int src_h, 151 u32 *sc_reg17, unsigned int src_w, unsigned int src_h,
@@ -276,8 +273,9 @@ void sc_config_scaler(struct sc_data *sc, u32 *sc_reg0, u32 *sc_reg8,
276 273
277 *sc_reg24 = (src_w << CFG_ORG_W_SHIFT) | (src_h << CFG_ORG_H_SHIFT); 274 *sc_reg24 = (src_w << CFG_ORG_W_SHIFT) | (src_h << CFG_ORG_H_SHIFT);
278} 275}
276EXPORT_SYMBOL(sc_config_scaler);
279 277
280struct sc_data *sc_create(struct platform_device *pdev) 278struct sc_data *sc_create(struct platform_device *pdev, const char *res_name)
281{ 279{
282 struct sc_data *sc; 280 struct sc_data *sc;
283 281
@@ -291,9 +289,10 @@ struct sc_data *sc_create(struct platform_device *pdev)
291 289
292 sc->pdev = pdev; 290 sc->pdev = pdev;
293 291
294 sc->res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sc"); 292 sc->res = platform_get_resource_byname(pdev, IORESOURCE_MEM, res_name);
295 if (!sc->res) { 293 if (!sc->res) {
296 dev_err(&pdev->dev, "missing platform resources data\n"); 294 dev_err(&pdev->dev, "missing '%s' platform resources data\n",
295 res_name);
297 return ERR_PTR(-ENODEV); 296 return ERR_PTR(-ENODEV);
298 } 297 }
299 298
@@ -305,3 +304,8 @@ struct sc_data *sc_create(struct platform_device *pdev)
305 304
306 return sc; 305 return sc;
307} 306}
307EXPORT_SYMBOL(sc_create);
308
309MODULE_DESCRIPTION("TI VIP/VPE Scaler");
310MODULE_AUTHOR("Texas Instruments Inc.");
311MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/ti-vpe/sc.h b/drivers/media/platform/ti-vpe/sc.h
index 60e411e05c30..f1fe80b38c9f 100644
--- a/drivers/media/platform/ti-vpe/sc.h
+++ b/drivers/media/platform/ti-vpe/sc.h
@@ -173,6 +173,12 @@
173/* number of taps expected by the scaler in it's coefficient memory */ 173/* number of taps expected by the scaler in it's coefficient memory */
174#define SC_NUM_TAPS_MEM_ALIGN 8 174#define SC_NUM_TAPS_MEM_ALIGN 8
175 175
176/* Maximum frame width the scaler can handle (in pixels) */
177#define SC_MAX_PIXEL_WIDTH 2047
178
179/* Maximum frame height the scaler can handle (in lines) */
180#define SC_MAX_PIXEL_HEIGHT 2047
181
176/* 182/*
177 * coefficient memory size in bytes: 183 * coefficient memory size in bytes:
178 * num phases x num sets(luma and chroma) x num taps(aligned) x coeff size 184 * num phases x num sets(luma and chroma) x num taps(aligned) x coeff size
@@ -189,9 +195,6 @@ struct sc_data {
189 bool load_coeff_h; /* have new h SC coeffs */ 195 bool load_coeff_h; /* have new h SC coeffs */
190 bool load_coeff_v; /* have new v SC coeffs */ 196 bool load_coeff_v; /* have new v SC coeffs */
191 197
192 unsigned int hs_index; /* h SC coeffs selector */
193 unsigned int vs_index; /* v SC coeffs selector */
194
195 struct platform_device *pdev; 198 struct platform_device *pdev;
196}; 199};
197 200
@@ -203,6 +206,6 @@ void sc_set_vs_coeffs(struct sc_data *sc, void *addr, unsigned int src_h,
203void sc_config_scaler(struct sc_data *sc, u32 *sc_reg0, u32 *sc_reg8, 206void sc_config_scaler(struct sc_data *sc, u32 *sc_reg0, u32 *sc_reg8,
204 u32 *sc_reg17, unsigned int src_w, unsigned int src_h, 207 u32 *sc_reg17, unsigned int src_w, unsigned int src_h,
205 unsigned int dst_w, unsigned int dst_h); 208 unsigned int dst_w, unsigned int dst_h);
206struct sc_data *sc_create(struct platform_device *pdev); 209struct sc_data *sc_create(struct platform_device *pdev, const char *res_name);
207 210
208#endif 211#endif
diff --git a/drivers/media/platform/ti-vpe/vpdma.c b/drivers/media/platform/ti-vpe/vpdma.c
index 3e2e3a33e6ed..13bfd7184160 100644
--- a/drivers/media/platform/ti-vpe/vpdma.c
+++ b/drivers/media/platform/ti-vpe/vpdma.c
@@ -59,9 +59,9 @@ const struct vpdma_data_format vpdma_yuv_fmts[] = {
59 .data_type = DATA_TYPE_C420, 59 .data_type = DATA_TYPE_C420,
60 .depth = 4, 60 .depth = 4,
61 }, 61 },
62 [VPDMA_DATA_FMT_YC422] = { 62 [VPDMA_DATA_FMT_YCR422] = {
63 .type = VPDMA_DATA_FMT_TYPE_YUV, 63 .type = VPDMA_DATA_FMT_TYPE_YUV,
64 .data_type = DATA_TYPE_YC422, 64 .data_type = DATA_TYPE_YCR422,
65 .depth = 16, 65 .depth = 16,
66 }, 66 },
67 [VPDMA_DATA_FMT_YC444] = { 67 [VPDMA_DATA_FMT_YC444] = {
@@ -69,12 +69,23 @@ const struct vpdma_data_format vpdma_yuv_fmts[] = {
69 .data_type = DATA_TYPE_YC444, 69 .data_type = DATA_TYPE_YC444,
70 .depth = 24, 70 .depth = 24,
71 }, 71 },
72 [VPDMA_DATA_FMT_CY422] = { 72 [VPDMA_DATA_FMT_CRY422] = {
73 .type = VPDMA_DATA_FMT_TYPE_YUV, 73 .type = VPDMA_DATA_FMT_TYPE_YUV,
74 .data_type = DATA_TYPE_CY422, 74 .data_type = DATA_TYPE_CRY422,
75 .depth = 16,
76 },
77 [VPDMA_DATA_FMT_CBY422] = {
78 .type = VPDMA_DATA_FMT_TYPE_YUV,
79 .data_type = DATA_TYPE_CBY422,
80 .depth = 16,
81 },
82 [VPDMA_DATA_FMT_YCB422] = {
83 .type = VPDMA_DATA_FMT_TYPE_YUV,
84 .data_type = DATA_TYPE_YCB422,
75 .depth = 16, 85 .depth = 16,
76 }, 86 },
77}; 87};
88EXPORT_SYMBOL(vpdma_yuv_fmts);
78 89
79const struct vpdma_data_format vpdma_rgb_fmts[] = { 90const struct vpdma_data_format vpdma_rgb_fmts[] = {
80 [VPDMA_DATA_FMT_RGB565] = { 91 [VPDMA_DATA_FMT_RGB565] = {
@@ -178,6 +189,30 @@ const struct vpdma_data_format vpdma_rgb_fmts[] = {
178 .depth = 32, 189 .depth = 32,
179 }, 190 },
180}; 191};
192EXPORT_SYMBOL(vpdma_rgb_fmts);
193
194/*
195 * To handle RAW format we are re-using the CBY422
196 * vpdma data type so that we use the vpdma to re-order
197 * the incoming bytes, as the parser assumes that the
198 * first byte presented on the bus is the MSB of a 2
199 * bytes value.
200 * RAW8 handles from 1 to 8 bits
201 * RAW16 handles from 9 to 16 bits
202 */
203const struct vpdma_data_format vpdma_raw_fmts[] = {
204 [VPDMA_DATA_FMT_RAW8] = {
205 .type = VPDMA_DATA_FMT_TYPE_YUV,
206 .data_type = DATA_TYPE_CBY422,
207 .depth = 8,
208 },
209 [VPDMA_DATA_FMT_RAW16] = {
210 .type = VPDMA_DATA_FMT_TYPE_YUV,
211 .data_type = DATA_TYPE_CBY422,
212 .depth = 16,
213 },
214};
215EXPORT_SYMBOL(vpdma_raw_fmts);
181 216
182const struct vpdma_data_format vpdma_misc_fmts[] = { 217const struct vpdma_data_format vpdma_misc_fmts[] = {
183 [VPDMA_DATA_FMT_MV] = { 218 [VPDMA_DATA_FMT_MV] = {
@@ -186,6 +221,7 @@ const struct vpdma_data_format vpdma_misc_fmts[] = {
186 .depth = 4, 221 .depth = 4,
187 }, 222 },
188}; 223};
224EXPORT_SYMBOL(vpdma_misc_fmts);
189 225
190struct vpdma_channel_info { 226struct vpdma_channel_info {
191 int num; /* VPDMA channel number */ 227 int num; /* VPDMA channel number */
@@ -317,6 +353,7 @@ void vpdma_dump_regs(struct vpdma_data *vpdma)
317 DUMPREG(VIP_UP_UV_CSTAT); 353 DUMPREG(VIP_UP_UV_CSTAT);
318 DUMPREG(VPI_CTL_CSTAT); 354 DUMPREG(VPI_CTL_CSTAT);
319} 355}
356EXPORT_SYMBOL(vpdma_dump_regs);
320 357
321/* 358/*
322 * Allocate a DMA buffer 359 * Allocate a DMA buffer
@@ -333,6 +370,7 @@ int vpdma_alloc_desc_buf(struct vpdma_buf *buf, size_t size)
333 370
334 return 0; 371 return 0;
335} 372}
373EXPORT_SYMBOL(vpdma_alloc_desc_buf);
336 374
337void vpdma_free_desc_buf(struct vpdma_buf *buf) 375void vpdma_free_desc_buf(struct vpdma_buf *buf)
338{ 376{
@@ -341,6 +379,7 @@ void vpdma_free_desc_buf(struct vpdma_buf *buf)
341 buf->addr = NULL; 379 buf->addr = NULL;
342 buf->size = 0; 380 buf->size = 0;
343} 381}
382EXPORT_SYMBOL(vpdma_free_desc_buf);
344 383
345/* 384/*
346 * map descriptor/payload DMA buffer, enabling DMA access 385 * map descriptor/payload DMA buffer, enabling DMA access
@@ -351,7 +390,7 @@ int vpdma_map_desc_buf(struct vpdma_data *vpdma, struct vpdma_buf *buf)
351 390
352 WARN_ON(buf->mapped); 391 WARN_ON(buf->mapped);
353 buf->dma_addr = dma_map_single(dev, buf->addr, buf->size, 392 buf->dma_addr = dma_map_single(dev, buf->addr, buf->size,
354 DMA_TO_DEVICE); 393 DMA_BIDIRECTIONAL);
355 if (dma_mapping_error(dev, buf->dma_addr)) { 394 if (dma_mapping_error(dev, buf->dma_addr)) {
356 dev_err(dev, "failed to map buffer\n"); 395 dev_err(dev, "failed to map buffer\n");
357 return -EINVAL; 396 return -EINVAL;
@@ -361,6 +400,7 @@ int vpdma_map_desc_buf(struct vpdma_data *vpdma, struct vpdma_buf *buf)
361 400
362 return 0; 401 return 0;
363} 402}
403EXPORT_SYMBOL(vpdma_map_desc_buf);
364 404
365/* 405/*
366 * unmap descriptor/payload DMA buffer, disabling DMA access and 406 * unmap descriptor/payload DMA buffer, disabling DMA access and
@@ -371,10 +411,62 @@ void vpdma_unmap_desc_buf(struct vpdma_data *vpdma, struct vpdma_buf *buf)
371 struct device *dev = &vpdma->pdev->dev; 411 struct device *dev = &vpdma->pdev->dev;
372 412
373 if (buf->mapped) 413 if (buf->mapped)
374 dma_unmap_single(dev, buf->dma_addr, buf->size, DMA_TO_DEVICE); 414 dma_unmap_single(dev, buf->dma_addr, buf->size,
415 DMA_BIDIRECTIONAL);
375 416
376 buf->mapped = false; 417 buf->mapped = false;
377} 418}
419EXPORT_SYMBOL(vpdma_unmap_desc_buf);
420
421/*
422 * Cleanup all pending descriptors of a list
423 * First, stop the current list being processed.
424 * If the VPDMA was busy, this step makes vpdma to accept post lists.
425 * To cleanup the internal FSM, post abort list descriptor for all the
426 * channels from @channels array of size @size.
427 */
428int vpdma_list_cleanup(struct vpdma_data *vpdma, int list_num,
429 int *channels, int size)
430{
431 struct vpdma_desc_list abort_list;
432 int i, ret, timeout = 500;
433
434 write_reg(vpdma, VPDMA_LIST_ATTR,
435 (list_num << VPDMA_LIST_NUM_SHFT) |
436 (1 << VPDMA_LIST_STOP_SHFT));
437
438 if (size <= 0 || !channels)
439 return 0;
440
441 ret = vpdma_create_desc_list(&abort_list,
442 size * sizeof(struct vpdma_dtd), VPDMA_LIST_TYPE_NORMAL);
443 if (ret)
444 return ret;
445
446 for (i = 0; i < size; i++)
447 vpdma_add_abort_channel_ctd(&abort_list, channels[i]);
448
449 ret = vpdma_map_desc_buf(vpdma, &abort_list.buf);
450 if (ret)
451 return ret;
452 ret = vpdma_submit_descs(vpdma, &abort_list, list_num);
453 if (ret)
454 return ret;
455
456 while (vpdma_list_busy(vpdma, list_num) && timeout--)
457 ;
458
459 if (timeout == 0) {
460 dev_err(&vpdma->pdev->dev, "Timed out cleaning up VPDMA list\n");
461 return -EBUSY;
462 }
463
464 vpdma_unmap_desc_buf(vpdma, &abort_list.buf);
465 vpdma_free_desc_buf(&abort_list.buf);
466
467 return 0;
468}
469EXPORT_SYMBOL(vpdma_list_cleanup);
378 470
379/* 471/*
380 * create a descriptor list, the user of this list will append configuration, 472 * create a descriptor list, the user of this list will append configuration,
@@ -396,6 +488,7 @@ int vpdma_create_desc_list(struct vpdma_desc_list *list, size_t size, int type)
396 488
397 return 0; 489 return 0;
398} 490}
491EXPORT_SYMBOL(vpdma_create_desc_list);
399 492
400/* 493/*
401 * once a descriptor list is parsed by VPDMA, we reset the list by emptying it, 494 * once a descriptor list is parsed by VPDMA, we reset the list by emptying it,
@@ -405,6 +498,7 @@ void vpdma_reset_desc_list(struct vpdma_desc_list *list)
405{ 498{
406 list->next = list->buf.addr; 499 list->next = list->buf.addr;
407} 500}
501EXPORT_SYMBOL(vpdma_reset_desc_list);
408 502
409/* 503/*
410 * free the buffer allocated fot the VPDMA descriptor list, this should be 504 * free the buffer allocated fot the VPDMA descriptor list, this should be
@@ -416,20 +510,22 @@ void vpdma_free_desc_list(struct vpdma_desc_list *list)
416 510
417 list->next = NULL; 511 list->next = NULL;
418} 512}
513EXPORT_SYMBOL(vpdma_free_desc_list);
419 514
420static bool vpdma_list_busy(struct vpdma_data *vpdma, int list_num) 515bool vpdma_list_busy(struct vpdma_data *vpdma, int list_num)
421{ 516{
422 return read_reg(vpdma, VPDMA_LIST_STAT_SYNC) & BIT(list_num + 16); 517 return read_reg(vpdma, VPDMA_LIST_STAT_SYNC) & BIT(list_num + 16);
423} 518}
519EXPORT_SYMBOL(vpdma_list_busy);
424 520
425/* 521/*
426 * submit a list of DMA descriptors to the VPE VPDMA, do not wait for completion 522 * submit a list of DMA descriptors to the VPE VPDMA, do not wait for completion
427 */ 523 */
428int vpdma_submit_descs(struct vpdma_data *vpdma, struct vpdma_desc_list *list) 524int vpdma_submit_descs(struct vpdma_data *vpdma,
525 struct vpdma_desc_list *list, int list_num)
429{ 526{
430 /* we always use the first list */
431 int list_num = 0;
432 int list_size; 527 int list_size;
528 unsigned long flags;
433 529
434 if (vpdma_list_busy(vpdma, list_num)) 530 if (vpdma_list_busy(vpdma, list_num))
435 return -EBUSY; 531 return -EBUSY;
@@ -437,15 +533,68 @@ int vpdma_submit_descs(struct vpdma_data *vpdma, struct vpdma_desc_list *list)
437 /* 16-byte granularity */ 533 /* 16-byte granularity */
438 list_size = (list->next - list->buf.addr) >> 4; 534 list_size = (list->next - list->buf.addr) >> 4;
439 535
536 spin_lock_irqsave(&vpdma->lock, flags);
440 write_reg(vpdma, VPDMA_LIST_ADDR, (u32) list->buf.dma_addr); 537 write_reg(vpdma, VPDMA_LIST_ADDR, (u32) list->buf.dma_addr);
441 538
442 write_reg(vpdma, VPDMA_LIST_ATTR, 539 write_reg(vpdma, VPDMA_LIST_ATTR,
443 (list_num << VPDMA_LIST_NUM_SHFT) | 540 (list_num << VPDMA_LIST_NUM_SHFT) |
444 (list->type << VPDMA_LIST_TYPE_SHFT) | 541 (list->type << VPDMA_LIST_TYPE_SHFT) |
445 list_size); 542 list_size);
543 spin_unlock_irqrestore(&vpdma->lock, flags);
446 544
447 return 0; 545 return 0;
448} 546}
547EXPORT_SYMBOL(vpdma_submit_descs);
548
549static void dump_dtd(struct vpdma_dtd *dtd);
550
551void vpdma_update_dma_addr(struct vpdma_data *vpdma,
552 struct vpdma_desc_list *list, dma_addr_t dma_addr,
553 void *write_dtd, int drop, int idx)
554{
555 struct vpdma_dtd *dtd = list->buf.addr;
556 dma_addr_t write_desc_addr;
557 int offset;
558
559 dtd += idx;
560 vpdma_unmap_desc_buf(vpdma, &list->buf);
561
562 dtd->start_addr = dma_addr;
563
564 /* Calculate write address from the offset of write_dtd from start
565 * of the list->buf
566 */
567 offset = (void *)write_dtd - list->buf.addr;
568 write_desc_addr = list->buf.dma_addr + offset;
569
570 if (drop)
571 dtd->desc_write_addr = dtd_desc_write_addr(write_desc_addr,
572 1, 1, 0);
573 else
574 dtd->desc_write_addr = dtd_desc_write_addr(write_desc_addr,
575 1, 0, 0);
576
577 vpdma_map_desc_buf(vpdma, &list->buf);
578
579 dump_dtd(dtd);
580}
581EXPORT_SYMBOL(vpdma_update_dma_addr);
582
583void vpdma_set_max_size(struct vpdma_data *vpdma, int reg_addr,
584 u32 width, u32 height)
585{
586 if (reg_addr != VPDMA_MAX_SIZE1 && reg_addr != VPDMA_MAX_SIZE2 &&
587 reg_addr != VPDMA_MAX_SIZE3)
588 reg_addr = VPDMA_MAX_SIZE1;
589
590 write_field_reg(vpdma, reg_addr, width - 1,
591 VPDMA_MAX_SIZE_WIDTH_MASK, VPDMA_MAX_SIZE_WIDTH_SHFT);
592
593 write_field_reg(vpdma, reg_addr, height - 1,
594 VPDMA_MAX_SIZE_HEIGHT_MASK, VPDMA_MAX_SIZE_HEIGHT_SHFT);
595
596}
597EXPORT_SYMBOL(vpdma_set_max_size);
449 598
450static void dump_cfd(struct vpdma_cfd *cfd) 599static void dump_cfd(struct vpdma_cfd *cfd)
451{ 600{
@@ -466,10 +615,10 @@ static void dump_cfd(struct vpdma_cfd *cfd)
466 615
467 pr_debug("word2: payload_addr = 0x%08x\n", cfd->payload_addr); 616 pr_debug("word2: payload_addr = 0x%08x\n", cfd->payload_addr);
468 617
469 pr_debug("word3: pkt_type = %d, direct = %d, class = %d, dest = %d, " 618 pr_debug("word3: pkt_type = %d, direct = %d, class = %d, dest = %d, payload_len = %d\n",
470 "payload_len = %d\n", cfd_get_pkt_type(cfd), 619 cfd_get_pkt_type(cfd),
471 cfd_get_direct(cfd), class, cfd_get_dest(cfd), 620 cfd_get_direct(cfd), class, cfd_get_dest(cfd),
472 cfd_get_payload_len(cfd)); 621 cfd_get_payload_len(cfd));
473} 622}
474 623
475/* 624/*
@@ -498,6 +647,7 @@ void vpdma_add_cfd_block(struct vpdma_desc_list *list, int client,
498 647
499 dump_cfd(cfd); 648 dump_cfd(cfd);
500} 649}
650EXPORT_SYMBOL(vpdma_add_cfd_block);
501 651
502/* 652/*
503 * append a configuration descriptor to the given descriptor list, where the 653 * append a configuration descriptor to the given descriptor list, where the
@@ -526,6 +676,7 @@ void vpdma_add_cfd_adb(struct vpdma_desc_list *list, int client,
526 676
527 dump_cfd(cfd); 677 dump_cfd(cfd);
528}; 678};
679EXPORT_SYMBOL(vpdma_add_cfd_adb);
529 680
530/* 681/*
531 * control descriptor format change based on what type of control descriptor it 682 * control descriptor format change based on what type of control descriptor it
@@ -563,6 +714,32 @@ void vpdma_add_sync_on_channel_ctd(struct vpdma_desc_list *list,
563 714
564 dump_ctd(ctd); 715 dump_ctd(ctd);
565} 716}
717EXPORT_SYMBOL(vpdma_add_sync_on_channel_ctd);
718
719/*
720 * append an 'abort_channel' type control descriptor to the given descriptor
721 * list, this descriptor aborts any DMA transaction happening using the
722 * specified channel
723 */
724void vpdma_add_abort_channel_ctd(struct vpdma_desc_list *list,
725 int chan_num)
726{
727 struct vpdma_ctd *ctd;
728
729 ctd = list->next;
730 WARN_ON((void *)(ctd + 1) > (list->buf.addr + list->buf.size));
731
732 ctd->w0 = 0;
733 ctd->w1 = 0;
734 ctd->w2 = 0;
735 ctd->type_source_ctl = ctd_type_source_ctl(chan_num,
736 CTD_TYPE_ABORT_CHANNEL);
737
738 list->next = ctd + 1;
739
740 dump_ctd(ctd);
741}
742EXPORT_SYMBOL(vpdma_add_abort_channel_ctd);
566 743
567static void dump_dtd(struct vpdma_dtd *dtd) 744static void dump_dtd(struct vpdma_dtd *dtd)
568{ 745{
@@ -574,8 +751,7 @@ static void dump_dtd(struct vpdma_dtd *dtd)
574 pr_debug("%s data transfer descriptor for channel %d\n", 751 pr_debug("%s data transfer descriptor for channel %d\n",
575 dir == DTD_DIR_OUT ? "outbound" : "inbound", chan); 752 dir == DTD_DIR_OUT ? "outbound" : "inbound", chan);
576 753
577 pr_debug("word0: data_type = %d, notify = %d, field = %d, 1D = %d, " 754 pr_debug("word0: data_type = %d, notify = %d, field = %d, 1D = %d, even_ln_skp = %d, odd_ln_skp = %d, line_stride = %d\n",
578 "even_ln_skp = %d, odd_ln_skp = %d, line_stride = %d\n",
579 dtd_get_data_type(dtd), dtd_get_notify(dtd), dtd_get_field(dtd), 755 dtd_get_data_type(dtd), dtd_get_notify(dtd), dtd_get_field(dtd),
580 dtd_get_1d(dtd), dtd_get_even_line_skip(dtd), 756 dtd_get_1d(dtd), dtd_get_even_line_skip(dtd),
581 dtd_get_odd_line_skip(dtd), dtd_get_line_stride(dtd)); 757 dtd_get_odd_line_skip(dtd), dtd_get_line_stride(dtd));
@@ -586,17 +762,16 @@ static void dump_dtd(struct vpdma_dtd *dtd)
586 762
587 pr_debug("word2: start_addr = %pad\n", &dtd->start_addr); 763 pr_debug("word2: start_addr = %pad\n", &dtd->start_addr);
588 764
589 pr_debug("word3: pkt_type = %d, mode = %d, dir = %d, chan = %d, " 765 pr_debug("word3: pkt_type = %d, mode = %d, dir = %d, chan = %d, pri = %d, next_chan = %d\n",
590 "pri = %d, next_chan = %d\n", dtd_get_pkt_type(dtd), 766 dtd_get_pkt_type(dtd),
591 dtd_get_mode(dtd), dir, chan, dtd_get_priority(dtd), 767 dtd_get_mode(dtd), dir, chan, dtd_get_priority(dtd),
592 dtd_get_next_chan(dtd)); 768 dtd_get_next_chan(dtd));
593 769
594 if (dir == DTD_DIR_IN) 770 if (dir == DTD_DIR_IN)
595 pr_debug("word4: frame_width = %d, frame_height = %d\n", 771 pr_debug("word4: frame_width = %d, frame_height = %d\n",
596 dtd_get_frame_width(dtd), dtd_get_frame_height(dtd)); 772 dtd_get_frame_width(dtd), dtd_get_frame_height(dtd));
597 else 773 else
598 pr_debug("word4: desc_write_addr = 0x%08x, write_desc = %d, " 774 pr_debug("word4: desc_write_addr = 0x%08x, write_desc = %d, drp_data = %d, use_desc_reg = %d\n",
599 "drp_data = %d, use_desc_reg = %d\n",
600 dtd_get_desc_write_addr(dtd), dtd_get_write_desc(dtd), 775 dtd_get_desc_write_addr(dtd), dtd_get_write_desc(dtd),
601 dtd_get_drop_data(dtd), dtd_get_use_desc(dtd)); 776 dtd_get_drop_data(dtd), dtd_get_use_desc(dtd));
602 777
@@ -620,13 +795,25 @@ static void dump_dtd(struct vpdma_dtd *dtd)
620 * @c_rect: compose params of output image 795 * @c_rect: compose params of output image
621 * @fmt: vpdma data format of the buffer 796 * @fmt: vpdma data format of the buffer
622 * dma_addr: dma address as seen by VPDMA 797 * dma_addr: dma address as seen by VPDMA
798 * max_width: enum for maximum width of data transfer
799 * max_height: enum for maximum height of data transfer
623 * chan: VPDMA channel 800 * chan: VPDMA channel
624 * flags: VPDMA flags to configure some descriptor fileds 801 * flags: VPDMA flags to configure some descriptor fileds
625 */ 802 */
626void vpdma_add_out_dtd(struct vpdma_desc_list *list, int width, 803void vpdma_add_out_dtd(struct vpdma_desc_list *list, int width,
627 const struct v4l2_rect *c_rect, 804 const struct v4l2_rect *c_rect,
628 const struct vpdma_data_format *fmt, dma_addr_t dma_addr, 805 const struct vpdma_data_format *fmt, dma_addr_t dma_addr,
629 enum vpdma_channel chan, u32 flags) 806 int max_w, int max_h, enum vpdma_channel chan, u32 flags)
807{
808 vpdma_rawchan_add_out_dtd(list, width, c_rect, fmt, dma_addr,
809 max_w, max_h, chan_info[chan].num, flags);
810}
811EXPORT_SYMBOL(vpdma_add_out_dtd);
812
813void vpdma_rawchan_add_out_dtd(struct vpdma_desc_list *list, int width,
814 const struct v4l2_rect *c_rect,
815 const struct vpdma_data_format *fmt, dma_addr_t dma_addr,
816 int max_w, int max_h, int raw_vpdma_chan, u32 flags)
630{ 817{
631 int priority = 0; 818 int priority = 0;
632 int field = 0; 819 int field = 0;
@@ -637,7 +824,7 @@ void vpdma_add_out_dtd(struct vpdma_desc_list *list, int width,
637 int stride; 824 int stride;
638 struct vpdma_dtd *dtd; 825 struct vpdma_dtd *dtd;
639 826
640 channel = next_chan = chan_info[chan].num; 827 channel = next_chan = raw_vpdma_chan;
641 828
642 if (fmt->type == VPDMA_DATA_FMT_TYPE_YUV && 829 if (fmt->type == VPDMA_DATA_FMT_TYPE_YUV &&
643 fmt->data_type == DATA_TYPE_C420) { 830 fmt->data_type == DATA_TYPE_C420) {
@@ -665,8 +852,7 @@ void vpdma_add_out_dtd(struct vpdma_desc_list *list, int width,
665 dtd->pkt_ctl = dtd_pkt_ctl(!!(flags & VPDMA_DATA_MODE_TILED), 852 dtd->pkt_ctl = dtd_pkt_ctl(!!(flags & VPDMA_DATA_MODE_TILED),
666 DTD_DIR_OUT, channel, priority, next_chan); 853 DTD_DIR_OUT, channel, priority, next_chan);
667 dtd->desc_write_addr = dtd_desc_write_addr(0, 0, 0, 0); 854 dtd->desc_write_addr = dtd_desc_write_addr(0, 0, 0, 0);
668 dtd->max_width_height = dtd_max_width_height(MAX_OUT_WIDTH_1920, 855 dtd->max_width_height = dtd_max_width_height(max_w, max_h);
669 MAX_OUT_HEIGHT_1080);
670 dtd->client_attr0 = 0; 856 dtd->client_attr0 = 0;
671 dtd->client_attr1 = 0; 857 dtd->client_attr1 = 0;
672 858
@@ -674,6 +860,7 @@ void vpdma_add_out_dtd(struct vpdma_desc_list *list, int width,
674 860
675 dump_dtd(dtd); 861 dump_dtd(dtd);
676} 862}
863EXPORT_SYMBOL(vpdma_rawchan_add_out_dtd);
677 864
678/* 865/*
679 * append an inbound data transfer descriptor to the given descriptor list, 866 * append an inbound data transfer descriptor to the given descriptor list,
@@ -747,27 +934,105 @@ void vpdma_add_in_dtd(struct vpdma_desc_list *list, int width,
747 934
748 dump_dtd(dtd); 935 dump_dtd(dtd);
749} 936}
937EXPORT_SYMBOL(vpdma_add_in_dtd);
938
939int vpdma_hwlist_alloc(struct vpdma_data *vpdma, void *priv)
940{
941 int i, list_num = -1;
942 unsigned long flags;
943
944 spin_lock_irqsave(&vpdma->lock, flags);
945 for (i = 0; i < VPDMA_MAX_NUM_LIST &&
946 vpdma->hwlist_used[i] == true; i++)
947 ;
948
949 if (i < VPDMA_MAX_NUM_LIST) {
950 list_num = i;
951 vpdma->hwlist_used[i] = true;
952 vpdma->hwlist_priv[i] = priv;
953 }
954 spin_unlock_irqrestore(&vpdma->lock, flags);
955
956 return list_num;
957}
958EXPORT_SYMBOL(vpdma_hwlist_alloc);
959
960void *vpdma_hwlist_get_priv(struct vpdma_data *vpdma, int list_num)
961{
962 if (!vpdma || list_num >= VPDMA_MAX_NUM_LIST)
963 return NULL;
964
965 return vpdma->hwlist_priv[list_num];
966}
967EXPORT_SYMBOL(vpdma_hwlist_get_priv);
968
969void *vpdma_hwlist_release(struct vpdma_data *vpdma, int list_num)
970{
971 void *priv;
972 unsigned long flags;
973
974 spin_lock_irqsave(&vpdma->lock, flags);
975 vpdma->hwlist_used[list_num] = false;
976 priv = vpdma->hwlist_priv;
977 spin_unlock_irqrestore(&vpdma->lock, flags);
978
979 return priv;
980}
981EXPORT_SYMBOL(vpdma_hwlist_release);
750 982
751/* set or clear the mask for list complete interrupt */ 983/* set or clear the mask for list complete interrupt */
752void vpdma_enable_list_complete_irq(struct vpdma_data *vpdma, int list_num, 984void vpdma_enable_list_complete_irq(struct vpdma_data *vpdma, int irq_num,
753 bool enable) 985 int list_num, bool enable)
754{ 986{
987 u32 reg_addr = VPDMA_INT_LIST0_MASK + VPDMA_INTX_OFFSET * irq_num;
755 u32 val; 988 u32 val;
756 989
757 val = read_reg(vpdma, VPDMA_INT_LIST0_MASK); 990 val = read_reg(vpdma, reg_addr);
758 if (enable) 991 if (enable)
759 val |= (1 << (list_num * 2)); 992 val |= (1 << (list_num * 2));
760 else 993 else
761 val &= ~(1 << (list_num * 2)); 994 val &= ~(1 << (list_num * 2));
762 write_reg(vpdma, VPDMA_INT_LIST0_MASK, val); 995 write_reg(vpdma, reg_addr, val);
763} 996}
997EXPORT_SYMBOL(vpdma_enable_list_complete_irq);
998
999/* get the LIST_STAT register */
1000unsigned int vpdma_get_list_stat(struct vpdma_data *vpdma, int irq_num)
1001{
1002 u32 reg_addr = VPDMA_INT_LIST0_STAT + VPDMA_INTX_OFFSET * irq_num;
1003
1004 return read_reg(vpdma, reg_addr);
1005}
1006EXPORT_SYMBOL(vpdma_get_list_stat);
1007
1008/* get the LIST_MASK register */
1009unsigned int vpdma_get_list_mask(struct vpdma_data *vpdma, int irq_num)
1010{
1011 u32 reg_addr = VPDMA_INT_LIST0_MASK + VPDMA_INTX_OFFSET * irq_num;
1012
1013 return read_reg(vpdma, reg_addr);
1014}
1015EXPORT_SYMBOL(vpdma_get_list_mask);
764 1016
765/* clear previosuly occured list intterupts in the LIST_STAT register */ 1017/* clear previosuly occured list intterupts in the LIST_STAT register */
766void vpdma_clear_list_stat(struct vpdma_data *vpdma) 1018void vpdma_clear_list_stat(struct vpdma_data *vpdma, int irq_num,
1019 int list_num)
1020{
1021 u32 reg_addr = VPDMA_INT_LIST0_STAT + VPDMA_INTX_OFFSET * irq_num;
1022
1023 write_reg(vpdma, reg_addr, 3 << (list_num * 2));
1024}
1025EXPORT_SYMBOL(vpdma_clear_list_stat);
1026
1027void vpdma_set_bg_color(struct vpdma_data *vpdma,
1028 struct vpdma_data_format *fmt, u32 color)
767{ 1029{
768 write_reg(vpdma, VPDMA_INT_LIST0_STAT, 1030 if (fmt->type == VPDMA_DATA_FMT_TYPE_RGB)
769 read_reg(vpdma, VPDMA_INT_LIST0_STAT)); 1031 write_reg(vpdma, VPDMA_BG_RGB, color);
1032 else if (fmt->type == VPDMA_DATA_FMT_TYPE_YUV)
1033 write_reg(vpdma, VPDMA_BG_YUV, color);
770} 1034}
1035EXPORT_SYMBOL(vpdma_set_bg_color);
771 1036
772/* 1037/*
773 * configures the output mode of the line buffer for the given client, the 1038 * configures the output mode of the line buffer for the given client, the
@@ -782,6 +1047,7 @@ void vpdma_set_line_mode(struct vpdma_data *vpdma, int line_mode,
782 write_field_reg(vpdma, client_cstat, line_mode, 1047 write_field_reg(vpdma, client_cstat, line_mode,
783 VPDMA_CSTAT_LINE_MODE_MASK, VPDMA_CSTAT_LINE_MODE_SHIFT); 1048 VPDMA_CSTAT_LINE_MODE_MASK, VPDMA_CSTAT_LINE_MODE_SHIFT);
784} 1049}
1050EXPORT_SYMBOL(vpdma_set_line_mode);
785 1051
786/* 1052/*
787 * configures the event which should trigger VPDMA transfer for the given 1053 * configures the event which should trigger VPDMA transfer for the given
@@ -796,6 +1062,7 @@ void vpdma_set_frame_start_event(struct vpdma_data *vpdma,
796 write_field_reg(vpdma, client_cstat, fs_event, 1062 write_field_reg(vpdma, client_cstat, fs_event,
797 VPDMA_CSTAT_FRAME_START_MASK, VPDMA_CSTAT_FRAME_START_SHIFT); 1063 VPDMA_CSTAT_FRAME_START_MASK, VPDMA_CSTAT_FRAME_START_SHIFT);
798} 1064}
1065EXPORT_SYMBOL(vpdma_set_frame_start_event);
799 1066
800static void vpdma_firmware_cb(const struct firmware *f, void *context) 1067static void vpdma_firmware_cb(const struct firmware *f, void *context)
801{ 1068{
@@ -871,42 +1138,40 @@ static int vpdma_load_firmware(struct vpdma_data *vpdma)
871 return 0; 1138 return 0;
872} 1139}
873 1140
874struct vpdma_data *vpdma_create(struct platform_device *pdev, 1141int vpdma_create(struct platform_device *pdev, struct vpdma_data *vpdma,
875 void (*cb)(struct platform_device *pdev)) 1142 void (*cb)(struct platform_device *pdev))
876{ 1143{
877 struct resource *res; 1144 struct resource *res;
878 struct vpdma_data *vpdma;
879 int r; 1145 int r;
880 1146
881 dev_dbg(&pdev->dev, "vpdma_create\n"); 1147 dev_dbg(&pdev->dev, "vpdma_create\n");
882 1148
883 vpdma = devm_kzalloc(&pdev->dev, sizeof(*vpdma), GFP_KERNEL);
884 if (!vpdma) {
885 dev_err(&pdev->dev, "couldn't alloc vpdma_dev\n");
886 return ERR_PTR(-ENOMEM);
887 }
888
889 vpdma->pdev = pdev; 1149 vpdma->pdev = pdev;
890 vpdma->cb = cb; 1150 vpdma->cb = cb;
1151 spin_lock_init(&vpdma->lock);
891 1152
892 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "vpdma"); 1153 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "vpdma");
893 if (res == NULL) { 1154 if (res == NULL) {
894 dev_err(&pdev->dev, "missing platform resources data\n"); 1155 dev_err(&pdev->dev, "missing platform resources data\n");
895 return ERR_PTR(-ENODEV); 1156 return -ENODEV;
896 } 1157 }
897 1158
898 vpdma->base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); 1159 vpdma->base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
899 if (!vpdma->base) { 1160 if (!vpdma->base) {
900 dev_err(&pdev->dev, "failed to ioremap\n"); 1161 dev_err(&pdev->dev, "failed to ioremap\n");
901 return ERR_PTR(-ENOMEM); 1162 return -ENOMEM;
902 } 1163 }
903 1164
904 r = vpdma_load_firmware(vpdma); 1165 r = vpdma_load_firmware(vpdma);
905 if (r) { 1166 if (r) {
906 pr_err("failed to load firmware %s\n", VPDMA_FIRMWARE); 1167 pr_err("failed to load firmware %s\n", VPDMA_FIRMWARE);
907 return ERR_PTR(r); 1168 return r;
908 } 1169 }
909 1170
910 return vpdma; 1171 return 0;
911} 1172}
1173EXPORT_SYMBOL(vpdma_create);
1174
1175MODULE_AUTHOR("Texas Instruments Inc.");
912MODULE_FIRMWARE(VPDMA_FIRMWARE); 1176MODULE_FIRMWARE(VPDMA_FIRMWARE);
1177MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/ti-vpe/vpdma.h b/drivers/media/platform/ti-vpe/vpdma.h
index 2bd8fb050381..131700c112b2 100644
--- a/drivers/media/platform/ti-vpe/vpdma.h
+++ b/drivers/media/platform/ti-vpe/vpdma.h
@@ -13,6 +13,7 @@
13#ifndef __TI_VPDMA_H_ 13#ifndef __TI_VPDMA_H_
14#define __TI_VPDMA_H_ 14#define __TI_VPDMA_H_
15 15
16#define VPDMA_MAX_NUM_LIST 8
16/* 17/*
17 * A vpdma_buf tracks the size, DMA address and mapping status of each 18 * A vpdma_buf tracks the size, DMA address and mapping status of each
18 * driver DMA area. 19 * driver DMA area.
@@ -35,6 +36,9 @@ struct vpdma_data {
35 36
36 struct platform_device *pdev; 37 struct platform_device *pdev;
37 38
39 spinlock_t lock;
40 bool hwlist_used[VPDMA_MAX_NUM_LIST];
41 void *hwlist_priv[VPDMA_MAX_NUM_LIST];
38 /* callback to VPE driver when the firmware is loaded */ 42 /* callback to VPE driver when the firmware is loaded */
39 void (*cb)(struct platform_device *pdev); 43 void (*cb)(struct platform_device *pdev);
40}; 44};
@@ -70,9 +74,11 @@ enum vpdma_yuv_formats {
70 VPDMA_DATA_FMT_C444, 74 VPDMA_DATA_FMT_C444,
71 VPDMA_DATA_FMT_C422, 75 VPDMA_DATA_FMT_C422,
72 VPDMA_DATA_FMT_C420, 76 VPDMA_DATA_FMT_C420,
73 VPDMA_DATA_FMT_YC422, 77 VPDMA_DATA_FMT_YCR422,
74 VPDMA_DATA_FMT_YC444, 78 VPDMA_DATA_FMT_YC444,
75 VPDMA_DATA_FMT_CY422, 79 VPDMA_DATA_FMT_CRY422,
80 VPDMA_DATA_FMT_CBY422,
81 VPDMA_DATA_FMT_YCB422,
76}; 82};
77 83
78enum vpdma_rgb_formats { 84enum vpdma_rgb_formats {
@@ -98,12 +104,18 @@ enum vpdma_rgb_formats {
98 VPDMA_DATA_FMT_BGRA32, 104 VPDMA_DATA_FMT_BGRA32,
99}; 105};
100 106
107enum vpdma_raw_formats {
108 VPDMA_DATA_FMT_RAW8 = 0,
109 VPDMA_DATA_FMT_RAW16,
110};
111
101enum vpdma_misc_formats { 112enum vpdma_misc_formats {
102 VPDMA_DATA_FMT_MV = 0, 113 VPDMA_DATA_FMT_MV = 0,
103}; 114};
104 115
105extern const struct vpdma_data_format vpdma_yuv_fmts[]; 116extern const struct vpdma_data_format vpdma_yuv_fmts[];
106extern const struct vpdma_data_format vpdma_rgb_fmts[]; 117extern const struct vpdma_data_format vpdma_rgb_fmts[];
118extern const struct vpdma_data_format vpdma_raw_fmts[];
107extern const struct vpdma_data_format vpdma_misc_fmts[]; 119extern const struct vpdma_data_format vpdma_misc_fmts[];
108 120
109enum vpdma_frame_start_event { 121enum vpdma_frame_start_event {
@@ -117,6 +129,30 @@ enum vpdma_frame_start_event {
117 VPDMA_FSEVENT_CHANNEL_ACTIVE, 129 VPDMA_FSEVENT_CHANNEL_ACTIVE,
118}; 130};
119 131
132/* max width configurations */
133enum vpdma_max_width {
134 MAX_OUT_WIDTH_UNLIMITED = 0,
135 MAX_OUT_WIDTH_REG1,
136 MAX_OUT_WIDTH_REG2,
137 MAX_OUT_WIDTH_REG3,
138 MAX_OUT_WIDTH_352,
139 MAX_OUT_WIDTH_768,
140 MAX_OUT_WIDTH_1280,
141 MAX_OUT_WIDTH_1920,
142};
143
144/* max height configurations */
145enum vpdma_max_height {
146 MAX_OUT_HEIGHT_UNLIMITED = 0,
147 MAX_OUT_HEIGHT_REG1,
148 MAX_OUT_HEIGHT_REG2,
149 MAX_OUT_HEIGHT_REG3,
150 MAX_OUT_HEIGHT_288,
151 MAX_OUT_HEIGHT_576,
152 MAX_OUT_HEIGHT_720,
153 MAX_OUT_HEIGHT_1080,
154};
155
120/* 156/*
121 * VPDMA channel numbers 157 * VPDMA channel numbers
122 */ 158 */
@@ -134,6 +170,13 @@ enum vpdma_channel {
134 VPE_CHAN_RGB_OUT, 170 VPE_CHAN_RGB_OUT,
135}; 171};
136 172
173#define VIP_CHAN_VIP2_OFFSET 70
174#define VIP_CHAN_MULT_PORTB_OFFSET 16
175#define VIP_CHAN_YUV_PORTB_OFFSET 2
176#define VIP_CHAN_RGB_PORTB_OFFSET 1
177
178#define VPDMA_MAX_CHANNELS 256
179
137/* flags for VPDMA data descriptors */ 180/* flags for VPDMA data descriptors */
138#define VPDMA_DATA_ODD_LINE_SKIP (1 << 0) 181#define VPDMA_DATA_ODD_LINE_SKIP (1 << 0)
139#define VPDMA_DATA_EVEN_LINE_SKIP (1 << 1) 182#define VPDMA_DATA_EVEN_LINE_SKIP (1 << 1)
@@ -177,7 +220,17 @@ void vpdma_unmap_desc_buf(struct vpdma_data *vpdma, struct vpdma_buf *buf);
177int vpdma_create_desc_list(struct vpdma_desc_list *list, size_t size, int type); 220int vpdma_create_desc_list(struct vpdma_desc_list *list, size_t size, int type);
178void vpdma_reset_desc_list(struct vpdma_desc_list *list); 221void vpdma_reset_desc_list(struct vpdma_desc_list *list);
179void vpdma_free_desc_list(struct vpdma_desc_list *list); 222void vpdma_free_desc_list(struct vpdma_desc_list *list);
180int vpdma_submit_descs(struct vpdma_data *vpdma, struct vpdma_desc_list *list); 223int vpdma_submit_descs(struct vpdma_data *vpdma, struct vpdma_desc_list *list,
224 int list_num);
225bool vpdma_list_busy(struct vpdma_data *vpdma, int list_num);
226void vpdma_update_dma_addr(struct vpdma_data *vpdma,
227 struct vpdma_desc_list *list, dma_addr_t dma_addr,
228 void *write_dtd, int drop, int idx);
229
230/* VPDMA hardware list funcs */
231int vpdma_hwlist_alloc(struct vpdma_data *vpdma, void *priv);
232void *vpdma_hwlist_get_priv(struct vpdma_data *vpdma, int list_num);
233void *vpdma_hwlist_release(struct vpdma_data *vpdma, int list_num);
181 234
182/* helpers for creating vpdma descriptors */ 235/* helpers for creating vpdma descriptors */
183void vpdma_add_cfd_block(struct vpdma_desc_list *list, int client, 236void vpdma_add_cfd_block(struct vpdma_desc_list *list, int client,
@@ -186,31 +239,47 @@ void vpdma_add_cfd_adb(struct vpdma_desc_list *list, int client,
186 struct vpdma_buf *adb); 239 struct vpdma_buf *adb);
187void vpdma_add_sync_on_channel_ctd(struct vpdma_desc_list *list, 240void vpdma_add_sync_on_channel_ctd(struct vpdma_desc_list *list,
188 enum vpdma_channel chan); 241 enum vpdma_channel chan);
242void vpdma_add_abort_channel_ctd(struct vpdma_desc_list *list,
243 int chan_num);
189void vpdma_add_out_dtd(struct vpdma_desc_list *list, int width, 244void vpdma_add_out_dtd(struct vpdma_desc_list *list, int width,
190 const struct v4l2_rect *c_rect, 245 const struct v4l2_rect *c_rect,
191 const struct vpdma_data_format *fmt, dma_addr_t dma_addr, 246 const struct vpdma_data_format *fmt, dma_addr_t dma_addr,
192 enum vpdma_channel chan, u32 flags); 247 int max_w, int max_h, enum vpdma_channel chan, u32 flags);
248void vpdma_rawchan_add_out_dtd(struct vpdma_desc_list *list, int width,
249 const struct v4l2_rect *c_rect,
250 const struct vpdma_data_format *fmt, dma_addr_t dma_addr,
251 int max_w, int max_h, int raw_vpdma_chan, u32 flags);
252
193void vpdma_add_in_dtd(struct vpdma_desc_list *list, int width, 253void vpdma_add_in_dtd(struct vpdma_desc_list *list, int width,
194 const struct v4l2_rect *c_rect, 254 const struct v4l2_rect *c_rect,
195 const struct vpdma_data_format *fmt, dma_addr_t dma_addr, 255 const struct vpdma_data_format *fmt, dma_addr_t dma_addr,
196 enum vpdma_channel chan, int field, u32 flags, int frame_width, 256 enum vpdma_channel chan, int field, u32 flags, int frame_width,
197 int frame_height, int start_h, int start_v); 257 int frame_height, int start_h, int start_v);
258int vpdma_list_cleanup(struct vpdma_data *vpdma, int list_num,
259 int *channels, int size);
198 260
199/* vpdma list interrupt management */ 261/* vpdma list interrupt management */
200void vpdma_enable_list_complete_irq(struct vpdma_data *vpdma, int list_num, 262void vpdma_enable_list_complete_irq(struct vpdma_data *vpdma, int irq_num,
201 bool enable); 263 int list_num, bool enable);
202void vpdma_clear_list_stat(struct vpdma_data *vpdma); 264void vpdma_clear_list_stat(struct vpdma_data *vpdma, int irq_num,
265 int list_num);
266unsigned int vpdma_get_list_stat(struct vpdma_data *vpdma, int irq_num);
267unsigned int vpdma_get_list_mask(struct vpdma_data *vpdma, int irq_num);
203 268
204/* vpdma client configuration */ 269/* vpdma client configuration */
205void vpdma_set_line_mode(struct vpdma_data *vpdma, int line_mode, 270void vpdma_set_line_mode(struct vpdma_data *vpdma, int line_mode,
206 enum vpdma_channel chan); 271 enum vpdma_channel chan);
207void vpdma_set_frame_start_event(struct vpdma_data *vpdma, 272void vpdma_set_frame_start_event(struct vpdma_data *vpdma,
208 enum vpdma_frame_start_event fs_event, enum vpdma_channel chan); 273 enum vpdma_frame_start_event fs_event, enum vpdma_channel chan);
274void vpdma_set_max_size(struct vpdma_data *vpdma, int reg_addr,
275 u32 width, u32 height);
209 276
277void vpdma_set_bg_color(struct vpdma_data *vpdma,
278 struct vpdma_data_format *fmt, u32 color);
210void vpdma_dump_regs(struct vpdma_data *vpdma); 279void vpdma_dump_regs(struct vpdma_data *vpdma);
211 280
212/* initialize vpdma, passed with VPE's platform device pointer */ 281/* initialize vpdma, passed with VPE's platform device pointer */
213struct vpdma_data *vpdma_create(struct platform_device *pdev, 282int vpdma_create(struct platform_device *pdev, struct vpdma_data *vpdma,
214 void (*cb)(struct platform_device *pdev)); 283 void (*cb)(struct platform_device *pdev));
215 284
216#endif 285#endif
diff --git a/drivers/media/platform/ti-vpe/vpdma_priv.h b/drivers/media/platform/ti-vpe/vpdma_priv.h
index c1a6ce1884f3..72c7f13b4a9d 100644
--- a/drivers/media/platform/ti-vpe/vpdma_priv.h
+++ b/drivers/media/platform/ti-vpe/vpdma_priv.h
@@ -28,6 +28,10 @@
28#define VPDMA_MAX_SIZE1 0x34 28#define VPDMA_MAX_SIZE1 0x34
29#define VPDMA_MAX_SIZE2 0x38 29#define VPDMA_MAX_SIZE2 0x38
30#define VPDMA_MAX_SIZE3 0x3c 30#define VPDMA_MAX_SIZE3 0x3c
31#define VPDMA_MAX_SIZE_WIDTH_MASK 0xffff
32#define VPDMA_MAX_SIZE_WIDTH_SHFT 16
33#define VPDMA_MAX_SIZE_HEIGHT_MASK 0xffff
34#define VPDMA_MAX_SIZE_HEIGHT_SHFT 0
31 35
32/* Interrupts */ 36/* Interrupts */
33#define VPDMA_INT_CHAN_STAT(grp) (0x40 + grp * 8) 37#define VPDMA_INT_CHAN_STAT(grp) (0x40 + grp * 8)
@@ -39,9 +43,11 @@
39#define VPDMA_INT_LIST0_STAT 0x88 43#define VPDMA_INT_LIST0_STAT 0x88
40#define VPDMA_INT_LIST0_MASK 0x8c 44#define VPDMA_INT_LIST0_MASK 0x8c
41 45
46#define VPDMA_INTX_OFFSET 0x50
47
42#define VPDMA_PERFMON(i) (0x200 + i * 4) 48#define VPDMA_PERFMON(i) (0x200 + i * 4)
43 49
44/* VPE specific client registers */ 50/* VIP/VPE client registers */
45#define VPDMA_DEI_CHROMA1_CSTAT 0x0300 51#define VPDMA_DEI_CHROMA1_CSTAT 0x0300
46#define VPDMA_DEI_LUMA1_CSTAT 0x0304 52#define VPDMA_DEI_LUMA1_CSTAT 0x0304
47#define VPDMA_DEI_LUMA2_CSTAT 0x0308 53#define VPDMA_DEI_LUMA2_CSTAT 0x0308
@@ -50,6 +56,8 @@
50#define VPDMA_DEI_CHROMA3_CSTAT 0x0314 56#define VPDMA_DEI_CHROMA3_CSTAT 0x0314
51#define VPDMA_DEI_MV_IN_CSTAT 0x0330 57#define VPDMA_DEI_MV_IN_CSTAT 0x0330
52#define VPDMA_DEI_MV_OUT_CSTAT 0x033c 58#define VPDMA_DEI_MV_OUT_CSTAT 0x033c
59#define VPDMA_VIP_LO_Y_CSTAT 0x0388
60#define VPDMA_VIP_LO_UV_CSTAT 0x038c
53#define VPDMA_VIP_UP_Y_CSTAT 0x0390 61#define VPDMA_VIP_UP_Y_CSTAT 0x0390
54#define VPDMA_VIP_UP_UV_CSTAT 0x0394 62#define VPDMA_VIP_UP_UV_CSTAT 0x0394
55#define VPDMA_VPI_CTL_CSTAT 0x03d0 63#define VPDMA_VPI_CTL_CSTAT 0x03d0
@@ -69,41 +77,63 @@
69#define VPDMA_LIST_TYPE_SHFT 16 77#define VPDMA_LIST_TYPE_SHFT 16
70#define VPDMA_LIST_SIZE_MASK 0xffff 78#define VPDMA_LIST_SIZE_MASK 0xffff
71 79
72/* VPDMA data type values for data formats */ 80/*
81 * The YUV data type definition below are taken from
82 * both the TRM and i839 Errata information.
83 * Use the correct data type considering byte
84 * reordering of components.
85 *
86 * Also since the single use of "C" in the 422 case
87 * to mean "Cr" (i.e. V component). It was decided
88 * to explicitly label them CR to remove any confusion.
89 * Bear in mind that the type label refer to the memory
90 * packed order (LSB - MSB).
91 */
73#define DATA_TYPE_Y444 0x0 92#define DATA_TYPE_Y444 0x0
74#define DATA_TYPE_Y422 0x1 93#define DATA_TYPE_Y422 0x1
75#define DATA_TYPE_Y420 0x2 94#define DATA_TYPE_Y420 0x2
76#define DATA_TYPE_C444 0x4 95#define DATA_TYPE_C444 0x4
77#define DATA_TYPE_C422 0x5 96#define DATA_TYPE_C422 0x5
78#define DATA_TYPE_C420 0x6 97#define DATA_TYPE_C420 0x6
79#define DATA_TYPE_YC422 0x7
80#define DATA_TYPE_YC444 0x8 98#define DATA_TYPE_YC444 0x8
81#define DATA_TYPE_CY422 0x27 99#define DATA_TYPE_YCB422 0x7
82 100#define DATA_TYPE_YCR422 0x17
83#define DATA_TYPE_RGB16_565 0x0 101#define DATA_TYPE_CBY422 0x27
84#define DATA_TYPE_ARGB_1555 0x1 102#define DATA_TYPE_CRY422 0x37
85#define DATA_TYPE_ARGB_4444 0x2 103
86#define DATA_TYPE_RGBA_5551 0x3 104/*
87#define DATA_TYPE_RGBA_4444 0x4 105 * The RGB data type definition below are defined
88#define DATA_TYPE_ARGB24_6666 0x5 106 * to follow Errata i819.
89#define DATA_TYPE_RGB24_888 0x6 107 * The initial values were taken from:
90#define DATA_TYPE_ARGB32_8888 0x7 108 * VPDMA_data_type_mapping_v0.2vayu_c.pdf
91#define DATA_TYPE_RGBA24_6666 0x8 109 * But some of the ARGB definition appeared to be wrong
92#define DATA_TYPE_RGBA32_8888 0x9 110 * in the document also. As they would yield RGBA instead.
93#define DATA_TYPE_BGR16_565 0x10 111 * They have been corrected based on experimentation.
94#define DATA_TYPE_ABGR_1555 0x11 112 */
95#define DATA_TYPE_ABGR_4444 0x12 113#define DATA_TYPE_RGB16_565 0x10
96#define DATA_TYPE_BGRA_5551 0x13 114#define DATA_TYPE_ARGB_1555 0x13
97#define DATA_TYPE_BGRA_4444 0x14 115#define DATA_TYPE_ARGB_4444 0x14
98#define DATA_TYPE_ABGR24_6666 0x15 116#define DATA_TYPE_RGBA_5551 0x11
99#define DATA_TYPE_BGR24_888 0x16 117#define DATA_TYPE_RGBA_4444 0x12
100#define DATA_TYPE_ABGR32_8888 0x17 118#define DATA_TYPE_ARGB24_6666 0x18
101#define DATA_TYPE_BGRA24_6666 0x18 119#define DATA_TYPE_RGB24_888 0x16
102#define DATA_TYPE_BGRA32_8888 0x19 120#define DATA_TYPE_ARGB32_8888 0x17
121#define DATA_TYPE_RGBA24_6666 0x15
122#define DATA_TYPE_RGBA32_8888 0x19
123#define DATA_TYPE_BGR16_565 0x0
124#define DATA_TYPE_ABGR_1555 0x3
125#define DATA_TYPE_ABGR_4444 0x4
126#define DATA_TYPE_BGRA_5551 0x1
127#define DATA_TYPE_BGRA_4444 0x2
128#define DATA_TYPE_ABGR24_6666 0x8
129#define DATA_TYPE_BGR24_888 0x6
130#define DATA_TYPE_ABGR32_8888 0x7
131#define DATA_TYPE_BGRA24_6666 0x5
132#define DATA_TYPE_BGRA32_8888 0x9
103 133
104#define DATA_TYPE_MV 0x3 134#define DATA_TYPE_MV 0x3
105 135
106/* VPDMA channel numbers(only VPE channels for now) */ 136/* VPDMA channel numbers, some are common between VIP/VPE and appear twice */
107#define VPE_CHAN_NUM_LUMA1_IN 0 137#define VPE_CHAN_NUM_LUMA1_IN 0
108#define VPE_CHAN_NUM_CHROMA1_IN 1 138#define VPE_CHAN_NUM_CHROMA1_IN 1
109#define VPE_CHAN_NUM_LUMA2_IN 2 139#define VPE_CHAN_NUM_LUMA2_IN 2
@@ -112,10 +142,15 @@
112#define VPE_CHAN_NUM_CHROMA3_IN 5 142#define VPE_CHAN_NUM_CHROMA3_IN 5
113#define VPE_CHAN_NUM_MV_IN 12 143#define VPE_CHAN_NUM_MV_IN 12
114#define VPE_CHAN_NUM_MV_OUT 15 144#define VPE_CHAN_NUM_MV_OUT 15
145#define VIP1_CHAN_NUM_MULT_PORT_A_SRC0 38
146#define VIP1_CHAN_NUM_MULT_ANC_A_SRC0 70
115#define VPE_CHAN_NUM_LUMA_OUT 102 147#define VPE_CHAN_NUM_LUMA_OUT 102
116#define VPE_CHAN_NUM_CHROMA_OUT 103 148#define VPE_CHAN_NUM_CHROMA_OUT 103
149#define VIP1_CHAN_NUM_PORT_A_LUMA 102
150#define VIP1_CHAN_NUM_PORT_A_CHROMA 103
117#define VPE_CHAN_NUM_RGB_OUT 106 151#define VPE_CHAN_NUM_RGB_OUT 106
118 152#define VIP1_CHAN_NUM_PORT_A_RGB 106
153#define VIP1_CHAN_NUM_PORT_B_RGB 107
119/* 154/*
120 * a VPDMA address data block payload for a configuration descriptor needs to 155 * a VPDMA address data block payload for a configuration descriptor needs to
121 * have each sub block length as a multiple of 16 bytes. Therefore, the overall 156 * have each sub block length as a multiple of 16 bytes. Therefore, the overall
@@ -203,6 +238,7 @@ struct vpdma_dtd {
203#define DTD_V_START_MASK 0xffff 238#define DTD_V_START_MASK 0xffff
204#define DTD_V_START_SHFT 0 239#define DTD_V_START_SHFT 0
205 240
241#define DTD_DESC_START_MASK 0xffffffe0
206#define DTD_DESC_START_SHIFT 5 242#define DTD_DESC_START_SHIFT 5
207#define DTD_WRITE_DESC_MASK 0x01 243#define DTD_WRITE_DESC_MASK 0x01
208#define DTD_WRITE_DESC_SHIFT 2 244#define DTD_WRITE_DESC_SHIFT 2
@@ -217,42 +253,6 @@ struct vpdma_dtd {
217#define DTD_MAX_HEIGHT_MASK 0x07 253#define DTD_MAX_HEIGHT_MASK 0x07
218#define DTD_MAX_HEIGHT_SHFT 0 254#define DTD_MAX_HEIGHT_SHFT 0
219 255
220/* max width configurations */
221 /* unlimited width */
222#define MAX_OUT_WIDTH_UNLIMITED 0
223/* as specified in max_size1 reg */
224#define MAX_OUT_WIDTH_REG1 1
225/* as specified in max_size2 reg */
226#define MAX_OUT_WIDTH_REG2 2
227/* as specified in max_size3 reg */
228#define MAX_OUT_WIDTH_REG3 3
229/* maximum of 352 pixels as width */
230#define MAX_OUT_WIDTH_352 4
231/* maximum of 768 pixels as width */
232#define MAX_OUT_WIDTH_768 5
233/* maximum of 1280 pixels width */
234#define MAX_OUT_WIDTH_1280 6
235/* maximum of 1920 pixels as width */
236#define MAX_OUT_WIDTH_1920 7
237
238/* max height configurations */
239 /* unlimited height */
240#define MAX_OUT_HEIGHT_UNLIMITED 0
241/* as specified in max_size1 reg */
242#define MAX_OUT_HEIGHT_REG1 1
243/* as specified in max_size2 reg */
244#define MAX_OUT_HEIGHT_REG2 2
245/* as specified in max_size3 reg */
246#define MAX_OUT_HEIGHT_REG3 3
247/* maximum of 288 lines as height */
248#define MAX_OUT_HEIGHT_288 4
249/* maximum of 576 lines as height */
250#define MAX_OUT_HEIGHT_576 5
251/* maximum of 720 lines as height */
252#define MAX_OUT_HEIGHT_720 6
253/* maximum of 1080 lines as height */
254#define MAX_OUT_HEIGHT_1080 7
255
256static inline u32 dtd_type_ctl_stride(int type, bool notify, int field, 256static inline u32 dtd_type_ctl_stride(int type, bool notify, int field,
257 bool one_d, bool even_line_skip, bool odd_line_skip, 257 bool one_d, bool even_line_skip, bool odd_line_skip,
258 int line_stride) 258 int line_stride)
@@ -285,7 +285,7 @@ static inline u32 dtd_frame_width_height(int width, int height)
285static inline u32 dtd_desc_write_addr(unsigned int addr, bool write_desc, 285static inline u32 dtd_desc_write_addr(unsigned int addr, bool write_desc,
286 bool drop_data, bool use_desc) 286 bool drop_data, bool use_desc)
287{ 287{
288 return (addr << DTD_DESC_START_SHIFT) | 288 return (addr & DTD_DESC_START_MASK) |
289 (write_desc << DTD_WRITE_DESC_SHIFT) | 289 (write_desc << DTD_WRITE_DESC_SHIFT) |
290 (drop_data << DTD_DROP_DATA_SHIFT) | 290 (drop_data << DTD_DROP_DATA_SHIFT) |
291 use_desc; 291 use_desc;
@@ -390,7 +390,7 @@ static inline int dtd_get_frame_height(struct vpdma_dtd *dtd)
390 390
391static inline int dtd_get_desc_write_addr(struct vpdma_dtd *dtd) 391static inline int dtd_get_desc_write_addr(struct vpdma_dtd *dtd)
392{ 392{
393 return dtd->desc_write_addr >> DTD_DESC_START_SHIFT; 393 return dtd->desc_write_addr & DTD_DESC_START_MASK;
394} 394}
395 395
396static inline bool dtd_get_write_desc(struct vpdma_dtd *dtd) 396static inline bool dtd_get_write_desc(struct vpdma_dtd *dtd)
diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c
index 0189f7f7cb03..f0156b7759e9 100644
--- a/drivers/media/platform/ti-vpe/vpe.c
+++ b/drivers/media/platform/ti-vpe/vpe.c
@@ -44,6 +44,7 @@
44#include <media/videobuf2-dma-contig.h> 44#include <media/videobuf2-dma-contig.h>
45 45
46#include "vpdma.h" 46#include "vpdma.h"
47#include "vpdma_priv.h"
47#include "vpe_regs.h" 48#include "vpe_regs.h"
48#include "sc.h" 49#include "sc.h"
49#include "csc.h" 50#include "csc.h"
@@ -53,8 +54,8 @@
53/* minimum and maximum frame sizes */ 54/* minimum and maximum frame sizes */
54#define MIN_W 32 55#define MIN_W 32
55#define MIN_H 32 56#define MIN_H 32
56#define MAX_W 1920 57#define MAX_W 2048
57#define MAX_H 1080 58#define MAX_H 1184
58 59
59/* required alignments */ 60/* required alignments */
60#define S_ALIGN 0 /* multiple of 1 */ 61#define S_ALIGN 0 /* multiple of 1 */
@@ -141,7 +142,7 @@ struct vpe_dei_regs {
141 */ 142 */
142static const struct vpe_dei_regs dei_regs = { 143static const struct vpe_dei_regs dei_regs = {
143 .mdt_spacial_freq_thr_reg = 0x020C0804u, 144 .mdt_spacial_freq_thr_reg = 0x020C0804u,
144 .edi_config_reg = 0x0118100Fu, 145 .edi_config_reg = 0x0118100Cu,
145 .edi_lut_reg0 = 0x08040200u, 146 .edi_lut_reg0 = 0x08040200u,
146 .edi_lut_reg1 = 0x1010100Cu, 147 .edi_lut_reg1 = 0x1010100Cu,
147 .edi_lut_reg2 = 0x10101010u, 148 .edi_lut_reg2 = 0x10101010u,
@@ -236,7 +237,7 @@ struct vpe_fmt {
236 237
237static struct vpe_fmt vpe_formats[] = { 238static struct vpe_fmt vpe_formats[] = {
238 { 239 {
239 .name = "YUV 422 co-planar", 240 .name = "NV16 YUV 422 co-planar",
240 .fourcc = V4L2_PIX_FMT_NV16, 241 .fourcc = V4L2_PIX_FMT_NV16,
241 .types = VPE_FMT_TYPE_CAPTURE | VPE_FMT_TYPE_OUTPUT, 242 .types = VPE_FMT_TYPE_CAPTURE | VPE_FMT_TYPE_OUTPUT,
242 .coplanar = 1, 243 .coplanar = 1,
@@ -245,7 +246,7 @@ static struct vpe_fmt vpe_formats[] = {
245 }, 246 },
246 }, 247 },
247 { 248 {
248 .name = "YUV 420 co-planar", 249 .name = "NV12 YUV 420 co-planar",
249 .fourcc = V4L2_PIX_FMT_NV12, 250 .fourcc = V4L2_PIX_FMT_NV12,
250 .types = VPE_FMT_TYPE_CAPTURE | VPE_FMT_TYPE_OUTPUT, 251 .types = VPE_FMT_TYPE_CAPTURE | VPE_FMT_TYPE_OUTPUT,
251 .coplanar = 1, 252 .coplanar = 1,
@@ -258,7 +259,7 @@ static struct vpe_fmt vpe_formats[] = {
258 .fourcc = V4L2_PIX_FMT_YUYV, 259 .fourcc = V4L2_PIX_FMT_YUYV,
259 .types = VPE_FMT_TYPE_CAPTURE | VPE_FMT_TYPE_OUTPUT, 260 .types = VPE_FMT_TYPE_CAPTURE | VPE_FMT_TYPE_OUTPUT,
260 .coplanar = 0, 261 .coplanar = 0,
261 .vpdma_fmt = { &vpdma_yuv_fmts[VPDMA_DATA_FMT_YC422], 262 .vpdma_fmt = { &vpdma_yuv_fmts[VPDMA_DATA_FMT_YCB422],
262 }, 263 },
263 }, 264 },
264 { 265 {
@@ -266,7 +267,7 @@ static struct vpe_fmt vpe_formats[] = {
266 .fourcc = V4L2_PIX_FMT_UYVY, 267 .fourcc = V4L2_PIX_FMT_UYVY,
267 .types = VPE_FMT_TYPE_CAPTURE | VPE_FMT_TYPE_OUTPUT, 268 .types = VPE_FMT_TYPE_CAPTURE | VPE_FMT_TYPE_OUTPUT,
268 .coplanar = 0, 269 .coplanar = 0,
269 .vpdma_fmt = { &vpdma_yuv_fmts[VPDMA_DATA_FMT_CY422], 270 .vpdma_fmt = { &vpdma_yuv_fmts[VPDMA_DATA_FMT_CBY422],
270 }, 271 },
271 }, 272 },
272 { 273 {
@@ -301,6 +302,22 @@ static struct vpe_fmt vpe_formats[] = {
301 .vpdma_fmt = { &vpdma_rgb_fmts[VPDMA_DATA_FMT_ABGR32], 302 .vpdma_fmt = { &vpdma_rgb_fmts[VPDMA_DATA_FMT_ABGR32],
302 }, 303 },
303 }, 304 },
305 {
306 .name = "RGB565",
307 .fourcc = V4L2_PIX_FMT_RGB565,
308 .types = VPE_FMT_TYPE_CAPTURE,
309 .coplanar = 0,
310 .vpdma_fmt = { &vpdma_rgb_fmts[VPDMA_DATA_FMT_RGB565],
311 },
312 },
313 {
314 .name = "RGB5551",
315 .fourcc = V4L2_PIX_FMT_RGB555,
316 .types = VPE_FMT_TYPE_CAPTURE,
317 .coplanar = 0,
318 .vpdma_fmt = { &vpdma_rgb_fmts[VPDMA_DATA_FMT_RGBA16_5551],
319 },
320 },
304}; 321};
305 322
306/* 323/*
@@ -310,6 +327,7 @@ static struct vpe_fmt vpe_formats[] = {
310struct vpe_q_data { 327struct vpe_q_data {
311 unsigned int width; /* frame width */ 328 unsigned int width; /* frame width */
312 unsigned int height; /* frame height */ 329 unsigned int height; /* frame height */
330 unsigned int nplanes; /* Current number of planes */
313 unsigned int bytesperline[VPE_MAX_PLANES]; /* bytes per line in memory */ 331 unsigned int bytesperline[VPE_MAX_PLANES]; /* bytes per line in memory */
314 enum v4l2_colorspace colorspace; 332 enum v4l2_colorspace colorspace;
315 enum v4l2_field field; /* supported field value */ 333 enum v4l2_field field; /* supported field value */
@@ -320,9 +338,13 @@ struct vpe_q_data {
320}; 338};
321 339
322/* vpe_q_data flag bits */ 340/* vpe_q_data flag bits */
323#define Q_DATA_FRAME_1D (1 << 0) 341#define Q_DATA_FRAME_1D BIT(0)
324#define Q_DATA_MODE_TILED (1 << 1) 342#define Q_DATA_MODE_TILED BIT(1)
325#define Q_DATA_INTERLACED (1 << 2) 343#define Q_DATA_INTERLACED_ALTERNATE BIT(2)
344#define Q_DATA_INTERLACED_SEQ_TB BIT(3)
345
346#define Q_IS_INTERLACED (Q_DATA_INTERLACED_ALTERNATE | \
347 Q_DATA_INTERLACED_SEQ_TB)
326 348
327enum { 349enum {
328 Q_DATA_SRC = 0, 350 Q_DATA_SRC = 0,
@@ -362,6 +384,7 @@ struct vpe_dev {
362 void __iomem *base; 384 void __iomem *base;
363 struct resource *res; 385 struct resource *res;
364 386
387 struct vpdma_data vpdma_data;
365 struct vpdma_data *vpdma; /* vpdma data handle */ 388 struct vpdma_data *vpdma; /* vpdma data handle */
366 struct sc_data *sc; /* scaler data handle */ 389 struct sc_data *sc; /* scaler data handle */
367 struct csc_data *csc; /* csc data handle */ 390 struct csc_data *csc; /* csc data handle */
@@ -416,7 +439,7 @@ static struct vpe_q_data *get_q_data(struct vpe_ctx *ctx,
416 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 439 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
417 return &ctx->q_data[Q_DATA_DST]; 440 return &ctx->q_data[Q_DATA_DST];
418 default: 441 default:
419 BUG(); 442 return NULL;
420 } 443 }
421 return NULL; 444 return NULL;
422} 445}
@@ -584,7 +607,10 @@ static void free_vbs(struct vpe_ctx *ctx)
584 spin_lock_irqsave(&dev->lock, flags); 607 spin_lock_irqsave(&dev->lock, flags);
585 if (ctx->src_vbs[2]) { 608 if (ctx->src_vbs[2]) {
586 v4l2_m2m_buf_done(ctx->src_vbs[2], VB2_BUF_STATE_DONE); 609 v4l2_m2m_buf_done(ctx->src_vbs[2], VB2_BUF_STATE_DONE);
587 v4l2_m2m_buf_done(ctx->src_vbs[1], VB2_BUF_STATE_DONE); 610 if (ctx->src_vbs[1] && (ctx->src_vbs[1] != ctx->src_vbs[2]))
611 v4l2_m2m_buf_done(ctx->src_vbs[1], VB2_BUF_STATE_DONE);
612 ctx->src_vbs[2] = NULL;
613 ctx->src_vbs[1] = NULL;
588 } 614 }
589 spin_unlock_irqrestore(&dev->lock, flags); 615 spin_unlock_irqrestore(&dev->lock, flags);
590} 616}
@@ -638,7 +664,7 @@ static void set_us_coefficients(struct vpe_ctx *ctx)
638 664
639 cp = &us_coeffs[0].anchor_fid0_c0; 665 cp = &us_coeffs[0].anchor_fid0_c0;
640 666
641 if (s_q_data->flags & Q_DATA_INTERLACED) /* interlaced */ 667 if (s_q_data->flags & Q_IS_INTERLACED) /* interlaced */
642 cp += sizeof(us_coeffs[0]) / sizeof(*cp); 668 cp += sizeof(us_coeffs[0]) / sizeof(*cp);
643 669
644 end_cp = cp + sizeof(us_coeffs[0]) / sizeof(*cp); 670 end_cp = cp + sizeof(us_coeffs[0]) / sizeof(*cp);
@@ -655,14 +681,13 @@ static void set_us_coefficients(struct vpe_ctx *ctx)
655/* 681/*
656 * Set the upsampler config mode and the VPDMA line mode in the shadow MMRs. 682 * Set the upsampler config mode and the VPDMA line mode in the shadow MMRs.
657 */ 683 */
658static void set_cfg_and_line_modes(struct vpe_ctx *ctx) 684static void set_cfg_modes(struct vpe_ctx *ctx)
659{ 685{
660 struct vpe_fmt *fmt = ctx->q_data[Q_DATA_SRC].fmt; 686 struct vpe_fmt *fmt = ctx->q_data[Q_DATA_SRC].fmt;
661 struct vpe_mmr_adb *mmr_adb = ctx->mmr_adb.addr; 687 struct vpe_mmr_adb *mmr_adb = ctx->mmr_adb.addr;
662 u32 *us1_reg0 = &mmr_adb->us1_regs[0]; 688 u32 *us1_reg0 = &mmr_adb->us1_regs[0];
663 u32 *us2_reg0 = &mmr_adb->us2_regs[0]; 689 u32 *us2_reg0 = &mmr_adb->us2_regs[0];
664 u32 *us3_reg0 = &mmr_adb->us3_regs[0]; 690 u32 *us3_reg0 = &mmr_adb->us3_regs[0];
665 int line_mode = 1;
666 int cfg_mode = 1; 691 int cfg_mode = 1;
667 692
668 /* 693 /*
@@ -670,15 +695,24 @@ static void set_cfg_and_line_modes(struct vpe_ctx *ctx)
670 * Cfg Mode 1: YUV422 source, disable upsampler, DEI is de-interlacing. 695 * Cfg Mode 1: YUV422 source, disable upsampler, DEI is de-interlacing.
671 */ 696 */
672 697
673 if (fmt->fourcc == V4L2_PIX_FMT_NV12) { 698 if (fmt->fourcc == V4L2_PIX_FMT_NV12)
674 cfg_mode = 0; 699 cfg_mode = 0;
675 line_mode = 0; /* double lines to line buffer */
676 }
677 700
678 write_field(us1_reg0, cfg_mode, VPE_US_MODE_MASK, VPE_US_MODE_SHIFT); 701 write_field(us1_reg0, cfg_mode, VPE_US_MODE_MASK, VPE_US_MODE_SHIFT);
679 write_field(us2_reg0, cfg_mode, VPE_US_MODE_MASK, VPE_US_MODE_SHIFT); 702 write_field(us2_reg0, cfg_mode, VPE_US_MODE_MASK, VPE_US_MODE_SHIFT);
680 write_field(us3_reg0, cfg_mode, VPE_US_MODE_MASK, VPE_US_MODE_SHIFT); 703 write_field(us3_reg0, cfg_mode, VPE_US_MODE_MASK, VPE_US_MODE_SHIFT);
681 704
705 ctx->load_mmrs = true;
706}
707
708static void set_line_modes(struct vpe_ctx *ctx)
709{
710 struct vpe_fmt *fmt = ctx->q_data[Q_DATA_SRC].fmt;
711 int line_mode = 1;
712
713 if (fmt->fourcc == V4L2_PIX_FMT_NV12)
714 line_mode = 0; /* double lines to line buffer */
715
682 /* regs for now */ 716 /* regs for now */
683 vpdma_set_line_mode(ctx->dev->vpdma, line_mode, VPE_CHAN_CHROMA1_IN); 717 vpdma_set_line_mode(ctx->dev->vpdma, line_mode, VPE_CHAN_CHROMA1_IN);
684 vpdma_set_line_mode(ctx->dev->vpdma, line_mode, VPE_CHAN_CHROMA2_IN); 718 vpdma_set_line_mode(ctx->dev->vpdma, line_mode, VPE_CHAN_CHROMA2_IN);
@@ -703,8 +737,6 @@ static void set_cfg_and_line_modes(struct vpe_ctx *ctx)
703 /* frame start for MV in client */ 737 /* frame start for MV in client */
704 vpdma_set_frame_start_event(ctx->dev->vpdma, VPDMA_FSEVENT_CHANNEL_ACTIVE, 738 vpdma_set_frame_start_event(ctx->dev->vpdma, VPDMA_FSEVENT_CHANNEL_ACTIVE,
705 VPE_CHAN_MV_IN); 739 VPE_CHAN_MV_IN);
706
707 ctx->load_mmrs = true;
708} 740}
709 741
710/* 742/*
@@ -727,9 +759,11 @@ static void set_dst_registers(struct vpe_ctx *ctx)
727 struct vpe_fmt *fmt = ctx->q_data[Q_DATA_DST].fmt; 759 struct vpe_fmt *fmt = ctx->q_data[Q_DATA_DST].fmt;
728 u32 val = 0; 760 u32 val = 0;
729 761
730 if (clrspc == V4L2_COLORSPACE_SRGB) 762 if (clrspc == V4L2_COLORSPACE_SRGB) {
731 val |= VPE_RGB_OUT_SELECT; 763 val |= VPE_RGB_OUT_SELECT;
732 else if (fmt->fourcc == V4L2_PIX_FMT_NV16) 764 vpdma_set_bg_color(ctx->dev->vpdma,
765 (struct vpdma_data_format *)fmt->vpdma_fmt[0], 0xff);
766 } else if (fmt->fourcc == V4L2_PIX_FMT_NV16)
733 val |= VPE_COLOR_SEPARATE_422; 767 val |= VPE_COLOR_SEPARATE_422;
734 768
735 /* 769 /*
@@ -765,8 +799,7 @@ static void set_dei_regs(struct vpe_ctx *ctx)
765 * for both progressive and interlace content in interlace bypass mode. 799 * for both progressive and interlace content in interlace bypass mode.
766 * It has been recommended not to use progressive bypass mode. 800 * It has been recommended not to use progressive bypass mode.
767 */ 801 */
768 if ((!ctx->deinterlacing && (s_q_data->flags & Q_DATA_INTERLACED)) || 802 if (!(s_q_data->flags & Q_IS_INTERLACED) || !ctx->deinterlacing) {
769 !(s_q_data->flags & Q_DATA_INTERLACED)) {
770 deinterlace = false; 803 deinterlace = false;
771 val = VPE_DEI_INTERLACE_BYPASS; 804 val = VPE_DEI_INTERLACE_BYPASS;
772 } 805 }
@@ -798,6 +831,23 @@ static void set_dei_shadow_registers(struct vpe_ctx *ctx)
798 ctx->load_mmrs = true; 831 ctx->load_mmrs = true;
799} 832}
800 833
834static void config_edi_input_mode(struct vpe_ctx *ctx, int mode)
835{
836 struct vpe_mmr_adb *mmr_adb = ctx->mmr_adb.addr;
837 u32 *edi_config_reg = &mmr_adb->dei_regs[3];
838
839 if (mode & 0x2)
840 write_field(edi_config_reg, 1, 1, 2); /* EDI_ENABLE_3D */
841
842 if (mode & 0x3)
843 write_field(edi_config_reg, 1, 1, 3); /* EDI_CHROMA_3D */
844
845 write_field(edi_config_reg, mode, VPE_EDI_INP_MODE_MASK,
846 VPE_EDI_INP_MODE_SHIFT);
847
848 ctx->load_mmrs = true;
849}
850
801/* 851/*
802 * Set the shadow registers whose values are modified when either the 852 * Set the shadow registers whose values are modified when either the
803 * source or destination format is changed. 853 * source or destination format is changed.
@@ -817,8 +867,8 @@ static int set_srcdst_params(struct vpe_ctx *ctx)
817 ctx->sequence = 0; 867 ctx->sequence = 0;
818 ctx->field = V4L2_FIELD_TOP; 868 ctx->field = V4L2_FIELD_TOP;
819 869
820 if ((s_q_data->flags & Q_DATA_INTERLACED) && 870 if ((s_q_data->flags & Q_IS_INTERLACED) &&
821 !(d_q_data->flags & Q_DATA_INTERLACED)) { 871 !(d_q_data->flags & Q_IS_INTERLACED)) {
822 int bytes_per_line; 872 int bytes_per_line;
823 const struct vpdma_data_format *mv = 873 const struct vpdma_data_format *mv =
824 &vpdma_misc_fmts[VPDMA_DATA_FMT_MV]; 874 &vpdma_misc_fmts[VPDMA_DATA_FMT_MV];
@@ -842,12 +892,13 @@ static int set_srcdst_params(struct vpe_ctx *ctx)
842 } 892 }
843 893
844 free_vbs(ctx); 894 free_vbs(ctx);
895 ctx->src_vbs[2] = ctx->src_vbs[1] = ctx->src_vbs[0] = NULL;
845 896
846 ret = realloc_mv_buffers(ctx, mv_buf_size); 897 ret = realloc_mv_buffers(ctx, mv_buf_size);
847 if (ret) 898 if (ret)
848 return ret; 899 return ret;
849 900
850 set_cfg_and_line_modes(ctx); 901 set_cfg_modes(ctx);
851 set_dei_regs(ctx); 902 set_dei_regs(ctx);
852 903
853 csc_set_coeff(ctx->dev->csc, &mmr_adb->csc_regs[0], 904 csc_set_coeff(ctx->dev->csc, &mmr_adb->csc_regs[0],
@@ -881,15 +932,14 @@ static struct vpe_ctx *file2ctx(struct file *file)
881static int job_ready(void *priv) 932static int job_ready(void *priv)
882{ 933{
883 struct vpe_ctx *ctx = priv; 934 struct vpe_ctx *ctx = priv;
884 int needed = ctx->bufs_per_job;
885
886 if (ctx->deinterlacing && ctx->src_vbs[2] == NULL)
887 needed += 2; /* need additional two most recent fields */
888
889 if (v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx) < needed)
890 return 0;
891 935
892 if (v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx) < needed) 936 /*
937 * This check is needed as this might be called directly from driver
938 * When called by m2m framework, this will always satisfy, but when
939 * called from vpe_irq, this might fail. (src stream with zero buffers)
940 */
941 if (v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx) <= 0 ||
942 v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx) <= 0)
893 return 0; 943 return 0;
894 944
895 return 1; 945 return 1;
@@ -993,22 +1043,38 @@ static void add_out_dtd(struct vpe_ctx *ctx, int port)
993 int mv_buf_selector = !ctx->src_mv_buf_selector; 1043 int mv_buf_selector = !ctx->src_mv_buf_selector;
994 dma_addr_t dma_addr; 1044 dma_addr_t dma_addr;
995 u32 flags = 0; 1045 u32 flags = 0;
1046 u32 offset = 0;
996 1047
997 if (port == VPE_PORT_MV_OUT) { 1048 if (port == VPE_PORT_MV_OUT) {
998 vpdma_fmt = &vpdma_misc_fmts[VPDMA_DATA_FMT_MV]; 1049 vpdma_fmt = &vpdma_misc_fmts[VPDMA_DATA_FMT_MV];
999 dma_addr = ctx->mv_buf_dma[mv_buf_selector]; 1050 dma_addr = ctx->mv_buf_dma[mv_buf_selector];
1051 q_data = &ctx->q_data[Q_DATA_SRC];
1000 } else { 1052 } else {
1001 /* to incorporate interleaved formats */ 1053 /* to incorporate interleaved formats */
1002 int plane = fmt->coplanar ? p_data->vb_part : 0; 1054 int plane = fmt->coplanar ? p_data->vb_part : 0;
1003 1055
1004 vpdma_fmt = fmt->vpdma_fmt[plane]; 1056 vpdma_fmt = fmt->vpdma_fmt[plane];
1005 dma_addr = vb2_dma_contig_plane_dma_addr(vb, plane); 1057 /*
1058 * If we are using a single plane buffer and
1059 * we need to set a separate vpdma chroma channel.
1060 */
1061 if (q_data->nplanes == 1 && plane) {
1062 dma_addr = vb2_dma_contig_plane_dma_addr(vb, 0);
1063 /* Compute required offset */
1064 offset = q_data->bytesperline[0] * q_data->height;
1065 } else {
1066 dma_addr = vb2_dma_contig_plane_dma_addr(vb, plane);
1067 /* Use address as is, no offset */
1068 offset = 0;
1069 }
1006 if (!dma_addr) { 1070 if (!dma_addr) {
1007 vpe_err(ctx->dev, 1071 vpe_err(ctx->dev,
1008 "acquiring output buffer(%d) dma_addr failed\n", 1072 "acquiring output buffer(%d) dma_addr failed\n",
1009 port); 1073 port);
1010 return; 1074 return;
1011 } 1075 }
1076 /* Apply the offset */
1077 dma_addr += offset;
1012 } 1078 }
1013 1079
1014 if (q_data->flags & Q_DATA_FRAME_1D) 1080 if (q_data->flags & Q_DATA_FRAME_1D)
@@ -1016,8 +1082,12 @@ static void add_out_dtd(struct vpe_ctx *ctx, int port)
1016 if (q_data->flags & Q_DATA_MODE_TILED) 1082 if (q_data->flags & Q_DATA_MODE_TILED)
1017 flags |= VPDMA_DATA_MODE_TILED; 1083 flags |= VPDMA_DATA_MODE_TILED;
1018 1084
1085 vpdma_set_max_size(ctx->dev->vpdma, VPDMA_MAX_SIZE1,
1086 MAX_W, MAX_H);
1087
1019 vpdma_add_out_dtd(&ctx->desc_list, q_data->width, &q_data->c_rect, 1088 vpdma_add_out_dtd(&ctx->desc_list, q_data->width, &q_data->c_rect,
1020 vpdma_fmt, dma_addr, p_data->channel, flags); 1089 vpdma_fmt, dma_addr, MAX_OUT_WIDTH_REG1,
1090 MAX_OUT_HEIGHT_REG1, p_data->channel, flags);
1021} 1091}
1022 1092
1023static void add_in_dtd(struct vpe_ctx *ctx, int port) 1093static void add_in_dtd(struct vpe_ctx *ctx, int port)
@@ -1033,6 +1103,7 @@ static void add_in_dtd(struct vpe_ctx *ctx, int port)
1033 int frame_width, frame_height; 1103 int frame_width, frame_height;
1034 dma_addr_t dma_addr; 1104 dma_addr_t dma_addr;
1035 u32 flags = 0; 1105 u32 flags = 0;
1106 u32 offset = 0;
1036 1107
1037 if (port == VPE_PORT_MV_IN) { 1108 if (port == VPE_PORT_MV_IN) {
1038 vpdma_fmt = &vpdma_misc_fmts[VPDMA_DATA_FMT_MV]; 1109 vpdma_fmt = &vpdma_misc_fmts[VPDMA_DATA_FMT_MV];
@@ -1042,14 +1113,49 @@ static void add_in_dtd(struct vpe_ctx *ctx, int port)
1042 int plane = fmt->coplanar ? p_data->vb_part : 0; 1113 int plane = fmt->coplanar ? p_data->vb_part : 0;
1043 1114
1044 vpdma_fmt = fmt->vpdma_fmt[plane]; 1115 vpdma_fmt = fmt->vpdma_fmt[plane];
1045 1116 /*
1046 dma_addr = vb2_dma_contig_plane_dma_addr(vb, plane); 1117 * If we are using a single plane buffer and
1118 * we need to set a separate vpdma chroma channel.
1119 */
1120 if (q_data->nplanes == 1 && plane) {
1121 dma_addr = vb2_dma_contig_plane_dma_addr(vb, 0);
1122 /* Compute required offset */
1123 offset = q_data->bytesperline[0] * q_data->height;
1124 } else {
1125 dma_addr = vb2_dma_contig_plane_dma_addr(vb, plane);
1126 /* Use address as is, no offset */
1127 offset = 0;
1128 }
1047 if (!dma_addr) { 1129 if (!dma_addr) {
1048 vpe_err(ctx->dev, 1130 vpe_err(ctx->dev,
1049 "acquiring input buffer(%d) dma_addr failed\n", 1131 "acquiring output buffer(%d) dma_addr failed\n",
1050 port); 1132 port);
1051 return; 1133 return;
1052 } 1134 }
1135 /* Apply the offset */
1136 dma_addr += offset;
1137
1138 if (q_data->flags & Q_DATA_INTERLACED_SEQ_TB) {
1139 /*
1140 * Use top or bottom field from same vb alternately
1141 * f,f-1,f-2 = TBT when seq is even
1142 * f,f-1,f-2 = BTB when seq is odd
1143 */
1144 field = (p_data->vb_index + (ctx->sequence % 2)) % 2;
1145
1146 if (field) {
1147 /*
1148 * bottom field of a SEQ_TB buffer
1149 * Skip the top field data by
1150 */
1151 int height = q_data->height / 2;
1152 int bpp = fmt->fourcc == V4L2_PIX_FMT_NV12 ?
1153 1 : (vpdma_fmt->depth >> 3);
1154 if (plane)
1155 height /= 2;
1156 dma_addr += q_data->width * height * bpp;
1157 }
1158 }
1053 } 1159 }
1054 1160
1055 if (q_data->flags & Q_DATA_FRAME_1D) 1161 if (q_data->flags & Q_DATA_FRAME_1D)
@@ -1077,7 +1183,7 @@ static void enable_irqs(struct vpe_ctx *ctx)
1077 write_reg(ctx->dev, VPE_INT0_ENABLE1_SET, VPE_DEI_ERROR_INT | 1183 write_reg(ctx->dev, VPE_INT0_ENABLE1_SET, VPE_DEI_ERROR_INT |
1078 VPE_DS1_UV_ERROR_INT); 1184 VPE_DS1_UV_ERROR_INT);
1079 1185
1080 vpdma_enable_list_complete_irq(ctx->dev->vpdma, 0, true); 1186 vpdma_enable_list_complete_irq(ctx->dev->vpdma, 0, 0, true);
1081} 1187}
1082 1188
1083static void disable_irqs(struct vpe_ctx *ctx) 1189static void disable_irqs(struct vpe_ctx *ctx)
@@ -1085,7 +1191,7 @@ static void disable_irqs(struct vpe_ctx *ctx)
1085 write_reg(ctx->dev, VPE_INT0_ENABLE0_CLR, 0xffffffff); 1191 write_reg(ctx->dev, VPE_INT0_ENABLE0_CLR, 0xffffffff);
1086 write_reg(ctx->dev, VPE_INT0_ENABLE1_CLR, 0xffffffff); 1192 write_reg(ctx->dev, VPE_INT0_ENABLE1_CLR, 0xffffffff);
1087 1193
1088 vpdma_enable_list_complete_irq(ctx->dev->vpdma, 0, false); 1194 vpdma_enable_list_complete_irq(ctx->dev->vpdma, 0, 0, false);
1089} 1195}
1090 1196
1091/* device_run() - prepares and starts the device 1197/* device_run() - prepares and starts the device
@@ -1098,23 +1204,49 @@ static void device_run(void *priv)
1098 struct vpe_ctx *ctx = priv; 1204 struct vpe_ctx *ctx = priv;
1099 struct sc_data *sc = ctx->dev->sc; 1205 struct sc_data *sc = ctx->dev->sc;
1100 struct vpe_q_data *d_q_data = &ctx->q_data[Q_DATA_DST]; 1206 struct vpe_q_data *d_q_data = &ctx->q_data[Q_DATA_DST];
1207 struct vpe_q_data *s_q_data = &ctx->q_data[Q_DATA_SRC];
1101 1208
1102 if (ctx->deinterlacing && ctx->src_vbs[2] == NULL) { 1209 if (ctx->deinterlacing && s_q_data->flags & Q_DATA_INTERLACED_SEQ_TB &&
1103 ctx->src_vbs[2] = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); 1210 ctx->sequence % 2 == 0) {
1104 WARN_ON(ctx->src_vbs[2] == NULL); 1211 /* When using SEQ_TB buffers, When using it first time,
1105 ctx->src_vbs[1] = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); 1212 * No need to remove the buffer as the next field is present
1106 WARN_ON(ctx->src_vbs[1] == NULL); 1213 * in the same buffer. (so that job_ready won't fail)
1214 * It will be removed when using bottom field
1215 */
1216 ctx->src_vbs[0] = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
1217 WARN_ON(ctx->src_vbs[0] == NULL);
1218 } else {
1219 ctx->src_vbs[0] = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
1220 WARN_ON(ctx->src_vbs[0] == NULL);
1107 } 1221 }
1108 1222
1109 ctx->src_vbs[0] = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
1110 WARN_ON(ctx->src_vbs[0] == NULL);
1111 ctx->dst_vb = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); 1223 ctx->dst_vb = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
1112 WARN_ON(ctx->dst_vb == NULL); 1224 WARN_ON(ctx->dst_vb == NULL);
1113 1225
1226 if (ctx->deinterlacing) {
1227
1228 if (ctx->src_vbs[2] == NULL) {
1229 ctx->src_vbs[2] = ctx->src_vbs[0];
1230 WARN_ON(ctx->src_vbs[2] == NULL);
1231 ctx->src_vbs[1] = ctx->src_vbs[0];
1232 WARN_ON(ctx->src_vbs[1] == NULL);
1233 }
1234
1235 /*
1236 * we have output the first 2 frames through line average, we
1237 * now switch to EDI de-interlacer
1238 */
1239 if (ctx->sequence == 2)
1240 config_edi_input_mode(ctx, 0x3); /* EDI (Y + UV) */
1241 }
1242
1114 /* config descriptors */ 1243 /* config descriptors */
1115 if (ctx->dev->loaded_mmrs != ctx->mmr_adb.dma_addr || ctx->load_mmrs) { 1244 if (ctx->dev->loaded_mmrs != ctx->mmr_adb.dma_addr || ctx->load_mmrs) {
1116 vpdma_map_desc_buf(ctx->dev->vpdma, &ctx->mmr_adb); 1245 vpdma_map_desc_buf(ctx->dev->vpdma, &ctx->mmr_adb);
1117 vpdma_add_cfd_adb(&ctx->desc_list, CFD_MMR_CLIENT, &ctx->mmr_adb); 1246 vpdma_add_cfd_adb(&ctx->desc_list, CFD_MMR_CLIENT, &ctx->mmr_adb);
1247
1248 set_line_modes(ctx);
1249
1118 ctx->dev->loaded_mmrs = ctx->mmr_adb.dma_addr; 1250 ctx->dev->loaded_mmrs = ctx->mmr_adb.dma_addr;
1119 ctx->load_mmrs = false; 1251 ctx->load_mmrs = false;
1120 } 1252 }
@@ -1202,7 +1334,7 @@ static void device_run(void *priv)
1202 enable_irqs(ctx); 1334 enable_irqs(ctx);
1203 1335
1204 vpdma_map_desc_buf(ctx->dev->vpdma, &ctx->desc_list.buf); 1336 vpdma_map_desc_buf(ctx->dev->vpdma, &ctx->desc_list.buf);
1205 vpdma_submit_descs(ctx->dev->vpdma, &ctx->desc_list); 1337 vpdma_submit_descs(ctx->dev->vpdma, &ctx->desc_list, 0);
1206} 1338}
1207 1339
1208static void dei_error(struct vpe_ctx *ctx) 1340static void dei_error(struct vpe_ctx *ctx)
@@ -1225,6 +1357,7 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
1225 struct vb2_v4l2_buffer *s_vb, *d_vb; 1357 struct vb2_v4l2_buffer *s_vb, *d_vb;
1226 unsigned long flags; 1358 unsigned long flags;
1227 u32 irqst0, irqst1; 1359 u32 irqst0, irqst1;
1360 bool list_complete = false;
1228 1361
1229 irqst0 = read_reg(dev, VPE_INT0_STATUS0); 1362 irqst0 = read_reg(dev, VPE_INT0_STATUS0);
1230 if (irqst0) { 1363 if (irqst0) {
@@ -1257,17 +1390,24 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
1257 1390
1258 if (irqst0) { 1391 if (irqst0) {
1259 if (irqst0 & VPE_INT0_LIST0_COMPLETE) 1392 if (irqst0 & VPE_INT0_LIST0_COMPLETE)
1260 vpdma_clear_list_stat(ctx->dev->vpdma); 1393 vpdma_clear_list_stat(ctx->dev->vpdma, 0, 0);
1261 1394
1262 irqst0 &= ~(VPE_INT0_LIST0_COMPLETE); 1395 irqst0 &= ~(VPE_INT0_LIST0_COMPLETE);
1396 list_complete = true;
1263 } 1397 }
1264 1398
1265 if (irqst0 | irqst1) { 1399 if (irqst0 | irqst1) {
1266 dev_warn(dev->v4l2_dev.dev, "Unexpected interrupt: " 1400 dev_warn(dev->v4l2_dev.dev, "Unexpected interrupt: INT0_STATUS0 = 0x%08x, INT0_STATUS1 = 0x%08x\n",
1267 "INT0_STATUS0 = 0x%08x, INT0_STATUS1 = 0x%08x\n",
1268 irqst0, irqst1); 1401 irqst0, irqst1);
1269 } 1402 }
1270 1403
1404 /*
1405 * Setup next operation only when list complete IRQ occurs
1406 * otherwise, skip the following code
1407 */
1408 if (!list_complete)
1409 goto handled;
1410
1271 disable_irqs(ctx); 1411 disable_irqs(ctx);
1272 1412
1273 vpdma_unmap_desc_buf(dev->vpdma, &ctx->desc_list.buf); 1413 vpdma_unmap_desc_buf(dev->vpdma, &ctx->desc_list.buf);
@@ -1295,7 +1435,7 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
1295 d_vb->sequence = ctx->sequence; 1435 d_vb->sequence = ctx->sequence;
1296 1436
1297 d_q_data = &ctx->q_data[Q_DATA_DST]; 1437 d_q_data = &ctx->q_data[Q_DATA_DST];
1298 if (d_q_data->flags & Q_DATA_INTERLACED) { 1438 if (d_q_data->flags & Q_IS_INTERLACED) {
1299 d_vb->field = ctx->field; 1439 d_vb->field = ctx->field;
1300 if (ctx->field == V4L2_FIELD_BOTTOM) { 1440 if (ctx->field == V4L2_FIELD_BOTTOM) {
1301 ctx->sequence++; 1441 ctx->sequence++;
@@ -1309,12 +1449,28 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
1309 ctx->sequence++; 1449 ctx->sequence++;
1310 } 1450 }
1311 1451
1312 if (ctx->deinterlacing) 1452 if (ctx->deinterlacing) {
1313 s_vb = ctx->src_vbs[2]; 1453 /*
1454 * Allow source buffer to be dequeued only if it won't be used
1455 * in the next iteration. All vbs are initialized to first
1456 * buffer and we are shifting buffers every iteration, for the
1457 * first two iterations, no buffer will be dequeued.
1458 * This ensures that driver will keep (n-2)th (n-1)th and (n)th
1459 * field when deinterlacing is enabled
1460 */
1461 if (ctx->src_vbs[2] != ctx->src_vbs[1])
1462 s_vb = ctx->src_vbs[2];
1463 else
1464 s_vb = NULL;
1465 }
1314 1466
1315 spin_lock_irqsave(&dev->lock, flags); 1467 spin_lock_irqsave(&dev->lock, flags);
1316 v4l2_m2m_buf_done(s_vb, VB2_BUF_STATE_DONE); 1468
1469 if (s_vb)
1470 v4l2_m2m_buf_done(s_vb, VB2_BUF_STATE_DONE);
1471
1317 v4l2_m2m_buf_done(d_vb, VB2_BUF_STATE_DONE); 1472 v4l2_m2m_buf_done(d_vb, VB2_BUF_STATE_DONE);
1473
1318 spin_unlock_irqrestore(&dev->lock, flags); 1474 spin_unlock_irqrestore(&dev->lock, flags);
1319 1475
1320 if (ctx->deinterlacing) { 1476 if (ctx->deinterlacing) {
@@ -1322,8 +1478,16 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
1322 ctx->src_vbs[1] = ctx->src_vbs[0]; 1478 ctx->src_vbs[1] = ctx->src_vbs[0];
1323 } 1479 }
1324 1480
1481 /*
1482 * Since the vb2_buf_done has already been called fir therse
1483 * buffer we can now NULL them out so that we won't try
1484 * to clean out stray pointer later on.
1485 */
1486 ctx->src_vbs[0] = NULL;
1487 ctx->dst_vb = NULL;
1488
1325 ctx->bufs_completed++; 1489 ctx->bufs_completed++;
1326 if (ctx->bufs_completed < ctx->bufs_per_job) { 1490 if (ctx->bufs_completed < ctx->bufs_per_job && job_ready(ctx)) {
1327 device_run(ctx); 1491 device_run(ctx);
1328 goto handled; 1492 goto handled;
1329 } 1493 }
@@ -1414,7 +1578,7 @@ static int vpe_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
1414 pix->colorspace = s_q_data->colorspace; 1578 pix->colorspace = s_q_data->colorspace;
1415 } 1579 }
1416 1580
1417 pix->num_planes = q_data->fmt->coplanar ? 2 : 1; 1581 pix->num_planes = q_data->nplanes;
1418 1582
1419 for (i = 0; i < pix->num_planes; i++) { 1583 for (i = 0; i < pix->num_planes; i++) {
1420 pix->plane_fmt[i].bytesperline = q_data->bytesperline[i]; 1584 pix->plane_fmt[i].bytesperline = q_data->bytesperline[i];
@@ -1430,7 +1594,7 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
1430 struct v4l2_pix_format_mplane *pix = &f->fmt.pix_mp; 1594 struct v4l2_pix_format_mplane *pix = &f->fmt.pix_mp;
1431 struct v4l2_plane_pix_format *plane_fmt; 1595 struct v4l2_plane_pix_format *plane_fmt;
1432 unsigned int w_align; 1596 unsigned int w_align;
1433 int i, depth, depth_bytes; 1597 int i, depth, depth_bytes, height;
1434 1598
1435 if (!fmt || !(fmt->types & type)) { 1599 if (!fmt || !(fmt->types & type)) {
1436 vpe_err(ctx->dev, "Fourcc format (0x%08x) invalid.\n", 1600 vpe_err(ctx->dev, "Fourcc format (0x%08x) invalid.\n",
@@ -1438,7 +1602,8 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
1438 return -EINVAL; 1602 return -EINVAL;
1439 } 1603 }
1440 1604
1441 if (pix->field != V4L2_FIELD_NONE && pix->field != V4L2_FIELD_ALTERNATE) 1605 if (pix->field != V4L2_FIELD_NONE && pix->field != V4L2_FIELD_ALTERNATE
1606 && pix->field != V4L2_FIELD_SEQ_TB)
1442 pix->field = V4L2_FIELD_NONE; 1607 pix->field = V4L2_FIELD_NONE;
1443 1608
1444 depth = fmt->vpdma_fmt[VPE_LUMA]->depth; 1609 depth = fmt->vpdma_fmt[VPE_LUMA]->depth;
@@ -1450,28 +1615,53 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
1450 */ 1615 */
1451 depth_bytes = depth >> 3; 1616 depth_bytes = depth >> 3;
1452 1617
1453 if (depth_bytes == 3) 1618 if (depth_bytes == 3) {
1454 /* 1619 /*
1455 * if bpp is 3(as in some RGB formats), the pixel width doesn't 1620 * if bpp is 3(as in some RGB formats), the pixel width doesn't
1456 * really help in ensuring line stride is 16 byte aligned 1621 * really help in ensuring line stride is 16 byte aligned
1457 */ 1622 */
1458 w_align = 4; 1623 w_align = 4;
1459 else 1624 } else {
1460 /* 1625 /*
1461 * for the remainder bpp(4, 2 and 1), the pixel width alignment 1626 * for the remainder bpp(4, 2 and 1), the pixel width alignment
1462 * can ensure a line stride alignment of 16 bytes. For example, 1627 * can ensure a line stride alignment of 16 bytes. For example,
1463 * if bpp is 2, then the line stride can be 16 byte aligned if 1628 * if bpp is 2, then the line stride can be 16 byte aligned if
1464 * the width is 8 byte aligned 1629 * the width is 8 byte aligned
1465 */ 1630 */
1466 w_align = order_base_2(VPDMA_DESC_ALIGN / depth_bytes); 1631
1632 /*
1633 * HACK: using order_base_2() here causes lots of asm output
1634 * errors with smatch, on i386:
1635 * ./arch/x86/include/asm/bitops.h:457:22:
1636 * warning: asm output is not an lvalue
1637 * Perhaps some gcc optimization is doing the wrong thing
1638 * there.
1639 * Let's get rid of them by doing the calculus on two steps
1640 */
1641 w_align = roundup_pow_of_two(VPDMA_DESC_ALIGN / depth_bytes);
1642 w_align = ilog2(w_align);
1643 }
1467 1644
1468 v4l_bound_align_image(&pix->width, MIN_W, MAX_W, w_align, 1645 v4l_bound_align_image(&pix->width, MIN_W, MAX_W, w_align,
1469 &pix->height, MIN_H, MAX_H, H_ALIGN, 1646 &pix->height, MIN_H, MAX_H, H_ALIGN,
1470 S_ALIGN); 1647 S_ALIGN);
1471 1648
1472 pix->num_planes = fmt->coplanar ? 2 : 1; 1649 if (!pix->num_planes)
1650 pix->num_planes = fmt->coplanar ? 2 : 1;
1651 else if (pix->num_planes > 1 && !fmt->coplanar)
1652 pix->num_planes = 1;
1653
1473 pix->pixelformat = fmt->fourcc; 1654 pix->pixelformat = fmt->fourcc;
1474 1655
1656 /*
1657 * For the actual image parameters, we need to consider the field
1658 * height of the image for SEQ_TB buffers.
1659 */
1660 if (pix->field == V4L2_FIELD_SEQ_TB)
1661 height = pix->height / 2;
1662 else
1663 height = pix->height;
1664
1475 if (!pix->colorspace) { 1665 if (!pix->colorspace) {
1476 if (fmt->fourcc == V4L2_PIX_FMT_RGB24 || 1666 if (fmt->fourcc == V4L2_PIX_FMT_RGB24 ||
1477 fmt->fourcc == V4L2_PIX_FMT_BGR24 || 1667 fmt->fourcc == V4L2_PIX_FMT_BGR24 ||
@@ -1479,7 +1669,7 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
1479 fmt->fourcc == V4L2_PIX_FMT_BGR32) { 1669 fmt->fourcc == V4L2_PIX_FMT_BGR32) {
1480 pix->colorspace = V4L2_COLORSPACE_SRGB; 1670 pix->colorspace = V4L2_COLORSPACE_SRGB;
1481 } else { 1671 } else {
1482 if (pix->height > 1280) /* HD */ 1672 if (height > 1280) /* HD */
1483 pix->colorspace = V4L2_COLORSPACE_REC709; 1673 pix->colorspace = V4L2_COLORSPACE_REC709;
1484 else /* SD */ 1674 else /* SD */
1485 pix->colorspace = V4L2_COLORSPACE_SMPTE170M; 1675 pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
@@ -1496,6 +1686,8 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
1496 else 1686 else
1497 plane_fmt->bytesperline = pix->width; 1687 plane_fmt->bytesperline = pix->width;
1498 1688
1689 if (pix->num_planes == 1 && fmt->coplanar)
1690 depth += fmt->vpdma_fmt[VPE_CHROMA]->depth;
1499 plane_fmt->sizeimage = 1691 plane_fmt->sizeimage =
1500 (pix->height * pix->width * depth) >> 3; 1692 (pix->height * pix->width * depth) >> 3;
1501 1693
@@ -1542,6 +1734,7 @@ static int __vpe_s_fmt(struct vpe_ctx *ctx, struct v4l2_format *f)
1542 q_data->height = pix->height; 1734 q_data->height = pix->height;
1543 q_data->colorspace = pix->colorspace; 1735 q_data->colorspace = pix->colorspace;
1544 q_data->field = pix->field; 1736 q_data->field = pix->field;
1737 q_data->nplanes = pix->num_planes;
1545 1738
1546 for (i = 0; i < pix->num_planes; i++) { 1739 for (i = 0; i < pix->num_planes; i++) {
1547 plane_fmt = &pix->plane_fmt[i]; 1740 plane_fmt = &pix->plane_fmt[i];
@@ -1556,14 +1749,20 @@ static int __vpe_s_fmt(struct vpe_ctx *ctx, struct v4l2_format *f)
1556 q_data->c_rect.height = q_data->height; 1749 q_data->c_rect.height = q_data->height;
1557 1750
1558 if (q_data->field == V4L2_FIELD_ALTERNATE) 1751 if (q_data->field == V4L2_FIELD_ALTERNATE)
1559 q_data->flags |= Q_DATA_INTERLACED; 1752 q_data->flags |= Q_DATA_INTERLACED_ALTERNATE;
1753 else if (q_data->field == V4L2_FIELD_SEQ_TB)
1754 q_data->flags |= Q_DATA_INTERLACED_SEQ_TB;
1560 else 1755 else
1561 q_data->flags &= ~Q_DATA_INTERLACED; 1756 q_data->flags &= ~Q_IS_INTERLACED;
1757
1758 /* the crop height is halved for the case of SEQ_TB buffers */
1759 if (q_data->flags & Q_DATA_INTERLACED_SEQ_TB)
1760 q_data->c_rect.height /= 2;
1562 1761
1563 vpe_dbg(ctx->dev, "Setting format for type %d, wxh: %dx%d, fmt: %d bpl_y %d", 1762 vpe_dbg(ctx->dev, "Setting format for type %d, wxh: %dx%d, fmt: %d bpl_y %d",
1564 f->type, q_data->width, q_data->height, q_data->fmt->fourcc, 1763 f->type, q_data->width, q_data->height, q_data->fmt->fourcc,
1565 q_data->bytesperline[VPE_LUMA]); 1764 q_data->bytesperline[VPE_LUMA]);
1566 if (q_data->fmt->coplanar) 1765 if (q_data->nplanes == 2)
1567 vpe_dbg(ctx->dev, " bpl_uv %d\n", 1766 vpe_dbg(ctx->dev, " bpl_uv %d\n",
1568 q_data->bytesperline[VPE_CHROMA]); 1767 q_data->bytesperline[VPE_CHROMA]);
1569 1768
@@ -1594,6 +1793,7 @@ static int vpe_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
1594static int __vpe_try_selection(struct vpe_ctx *ctx, struct v4l2_selection *s) 1793static int __vpe_try_selection(struct vpe_ctx *ctx, struct v4l2_selection *s)
1595{ 1794{
1596 struct vpe_q_data *q_data; 1795 struct vpe_q_data *q_data;
1796 int height;
1597 1797
1598 if ((s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) && 1798 if ((s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
1599 (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)) 1799 (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT))
@@ -1628,13 +1828,22 @@ static int __vpe_try_selection(struct vpe_ctx *ctx, struct v4l2_selection *s)
1628 return -EINVAL; 1828 return -EINVAL;
1629 } 1829 }
1630 1830
1831 /*
1832 * For SEQ_TB buffers, crop height should be less than the height of
1833 * the field height, not the buffer height
1834 */
1835 if (q_data->flags & Q_DATA_INTERLACED_SEQ_TB)
1836 height = q_data->height / 2;
1837 else
1838 height = q_data->height;
1839
1631 if (s->r.top < 0 || s->r.left < 0) { 1840 if (s->r.top < 0 || s->r.left < 0) {
1632 vpe_err(ctx->dev, "negative values for top and left\n"); 1841 vpe_err(ctx->dev, "negative values for top and left\n");
1633 s->r.top = s->r.left = 0; 1842 s->r.top = s->r.left = 0;
1634 } 1843 }
1635 1844
1636 v4l_bound_align_image(&s->r.width, MIN_W, q_data->width, 1, 1845 v4l_bound_align_image(&s->r.width, MIN_W, q_data->width, 1,
1637 &s->r.height, MIN_H, q_data->height, H_ALIGN, S_ALIGN); 1846 &s->r.height, MIN_H, height, H_ALIGN, S_ALIGN);
1638 1847
1639 /* adjust left/top if cropping rectangle is out of bounds */ 1848 /* adjust left/top if cropping rectangle is out of bounds */
1640 if (s->r.left + s->r.width > q_data->width) 1849 if (s->r.left + s->r.width > q_data->width)
@@ -1784,6 +1993,7 @@ static const struct v4l2_ioctl_ops vpe_ioctl_ops = {
1784 .vidioc_querybuf = v4l2_m2m_ioctl_querybuf, 1993 .vidioc_querybuf = v4l2_m2m_ioctl_querybuf,
1785 .vidioc_qbuf = v4l2_m2m_ioctl_qbuf, 1994 .vidioc_qbuf = v4l2_m2m_ioctl_qbuf,
1786 .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf, 1995 .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf,
1996 .vidioc_expbuf = v4l2_m2m_ioctl_expbuf,
1787 .vidioc_streamon = v4l2_m2m_ioctl_streamon, 1997 .vidioc_streamon = v4l2_m2m_ioctl_streamon,
1788 .vidioc_streamoff = v4l2_m2m_ioctl_streamoff, 1998 .vidioc_streamoff = v4l2_m2m_ioctl_streamoff,
1789 1999
@@ -1804,14 +2014,14 @@ static int vpe_queue_setup(struct vb2_queue *vq,
1804 2014
1805 q_data = get_q_data(ctx, vq->type); 2015 q_data = get_q_data(ctx, vq->type);
1806 2016
1807 *nplanes = q_data->fmt->coplanar ? 2 : 1; 2017 *nplanes = q_data->nplanes;
1808 2018
1809 for (i = 0; i < *nplanes; i++) 2019 for (i = 0; i < *nplanes; i++)
1810 sizes[i] = q_data->sizeimage[i]; 2020 sizes[i] = q_data->sizeimage[i];
1811 2021
1812 vpe_dbg(ctx->dev, "get %d buffer(s) of size %d", *nbuffers, 2022 vpe_dbg(ctx->dev, "get %d buffer(s) of size %d", *nbuffers,
1813 sizes[VPE_LUMA]); 2023 sizes[VPE_LUMA]);
1814 if (q_data->fmt->coplanar) 2024 if (q_data->nplanes == 2)
1815 vpe_dbg(ctx->dev, " and %d\n", sizes[VPE_CHROMA]); 2025 vpe_dbg(ctx->dev, " and %d\n", sizes[VPE_CHROMA]);
1816 2026
1817 return 0; 2027 return 0;
@@ -1827,14 +2037,15 @@ static int vpe_buf_prepare(struct vb2_buffer *vb)
1827 vpe_dbg(ctx->dev, "type: %d\n", vb->vb2_queue->type); 2037 vpe_dbg(ctx->dev, "type: %d\n", vb->vb2_queue->type);
1828 2038
1829 q_data = get_q_data(ctx, vb->vb2_queue->type); 2039 q_data = get_q_data(ctx, vb->vb2_queue->type);
1830 num_planes = q_data->fmt->coplanar ? 2 : 1; 2040 num_planes = q_data->nplanes;
1831 2041
1832 if (vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { 2042 if (vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
1833 if (!(q_data->flags & Q_DATA_INTERLACED)) { 2043 if (!(q_data->flags & Q_IS_INTERLACED)) {
1834 vbuf->field = V4L2_FIELD_NONE; 2044 vbuf->field = V4L2_FIELD_NONE;
1835 } else { 2045 } else {
1836 if (vbuf->field != V4L2_FIELD_TOP && 2046 if (vbuf->field != V4L2_FIELD_TOP &&
1837 vbuf->field != V4L2_FIELD_BOTTOM) 2047 vbuf->field != V4L2_FIELD_BOTTOM &&
2048 vbuf->field != V4L2_FIELD_SEQ_TB)
1838 return -EINVAL; 2049 return -EINVAL;
1839 } 2050 }
1840 } 2051 }
@@ -1863,9 +2074,98 @@ static void vpe_buf_queue(struct vb2_buffer *vb)
1863 v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf); 2074 v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf);
1864} 2075}
1865 2076
2077static int check_srcdst_sizes(struct vpe_ctx *ctx)
2078{
2079 struct vpe_q_data *s_q_data = &ctx->q_data[Q_DATA_SRC];
2080 struct vpe_q_data *d_q_data = &ctx->q_data[Q_DATA_DST];
2081 unsigned int src_w = s_q_data->c_rect.width;
2082 unsigned int src_h = s_q_data->c_rect.height;
2083 unsigned int dst_w = d_q_data->c_rect.width;
2084 unsigned int dst_h = d_q_data->c_rect.height;
2085
2086 if (src_w == dst_w && src_h == dst_h)
2087 return 0;
2088
2089 if (src_h <= SC_MAX_PIXEL_HEIGHT &&
2090 src_w <= SC_MAX_PIXEL_WIDTH &&
2091 dst_h <= SC_MAX_PIXEL_HEIGHT &&
2092 dst_w <= SC_MAX_PIXEL_WIDTH)
2093 return 0;
2094
2095 return -1;
2096}
2097
2098static void vpe_return_all_buffers(struct vpe_ctx *ctx, struct vb2_queue *q,
2099 enum vb2_buffer_state state)
2100{
2101 struct vb2_v4l2_buffer *vb;
2102 unsigned long flags;
2103
2104 for (;;) {
2105 if (V4L2_TYPE_IS_OUTPUT(q->type))
2106 vb = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
2107 else
2108 vb = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
2109 if (!vb)
2110 break;
2111 spin_lock_irqsave(&ctx->dev->lock, flags);
2112 v4l2_m2m_buf_done(vb, state);
2113 spin_unlock_irqrestore(&ctx->dev->lock, flags);
2114 }
2115
2116 /*
2117 * Cleanup the in-transit vb2 buffers that have been
2118 * removed from their respective queue already but for
2119 * which procecessing has not been completed yet.
2120 */
2121 if (V4L2_TYPE_IS_OUTPUT(q->type)) {
2122 spin_lock_irqsave(&ctx->dev->lock, flags);
2123
2124 if (ctx->src_vbs[2])
2125 v4l2_m2m_buf_done(ctx->src_vbs[2], state);
2126
2127 if (ctx->src_vbs[1] && (ctx->src_vbs[1] != ctx->src_vbs[2]))
2128 v4l2_m2m_buf_done(ctx->src_vbs[1], state);
2129
2130 if (ctx->src_vbs[0] &&
2131 (ctx->src_vbs[0] != ctx->src_vbs[1]) &&
2132 (ctx->src_vbs[0] != ctx->src_vbs[2]))
2133 v4l2_m2m_buf_done(ctx->src_vbs[0], state);
2134
2135 ctx->src_vbs[2] = NULL;
2136 ctx->src_vbs[1] = NULL;
2137 ctx->src_vbs[0] = NULL;
2138
2139 spin_unlock_irqrestore(&ctx->dev->lock, flags);
2140 } else {
2141 if (ctx->dst_vb) {
2142 spin_lock_irqsave(&ctx->dev->lock, flags);
2143
2144 v4l2_m2m_buf_done(ctx->dst_vb, state);
2145 ctx->dst_vb = NULL;
2146 spin_unlock_irqrestore(&ctx->dev->lock, flags);
2147 }
2148 }
2149}
2150
1866static int vpe_start_streaming(struct vb2_queue *q, unsigned int count) 2151static int vpe_start_streaming(struct vb2_queue *q, unsigned int count)
1867{ 2152{
1868 /* currently we do nothing here */ 2153 struct vpe_ctx *ctx = vb2_get_drv_priv(q);
2154
2155 /* Check any of the size exceed maximum scaling sizes */
2156 if (check_srcdst_sizes(ctx)) {
2157 vpe_err(ctx->dev,
2158 "Conversion setup failed, check source and destination parameters\n"
2159 );
2160 vpe_return_all_buffers(ctx, q, VB2_BUF_STATE_QUEUED);
2161 return -EINVAL;
2162 }
2163
2164 if (ctx->deinterlacing)
2165 config_edi_input_mode(ctx, 0x0);
2166
2167 if (ctx->sequence != 0)
2168 set_srcdst_params(ctx);
1869 2169
1870 return 0; 2170 return 0;
1871} 2171}
@@ -1876,6 +2176,8 @@ static void vpe_stop_streaming(struct vb2_queue *q)
1876 2176
1877 vpe_dump_regs(ctx->dev); 2177 vpe_dump_regs(ctx->dev);
1878 vpdma_dump_regs(ctx->dev->vpdma); 2178 vpdma_dump_regs(ctx->dev->vpdma);
2179
2180 vpe_return_all_buffers(ctx, q, VB2_BUF_STATE_ERROR);
1879} 2181}
1880 2182
1881static const struct vb2_ops vpe_qops = { 2183static const struct vb2_ops vpe_qops = {
@@ -1995,6 +2297,7 @@ static int vpe_open(struct file *file)
1995 s_q_data->fmt = &vpe_formats[2]; 2297 s_q_data->fmt = &vpe_formats[2];
1996 s_q_data->width = 1920; 2298 s_q_data->width = 1920;
1997 s_q_data->height = 1080; 2299 s_q_data->height = 1080;
2300 s_q_data->nplanes = 1;
1998 s_q_data->bytesperline[VPE_LUMA] = (s_q_data->width * 2301 s_q_data->bytesperline[VPE_LUMA] = (s_q_data->width *
1999 s_q_data->fmt->vpdma_fmt[VPE_LUMA]->depth) >> 3; 2302 s_q_data->fmt->vpdma_fmt[VPE_LUMA]->depth) >> 3;
2000 s_q_data->sizeimage[VPE_LUMA] = (s_q_data->bytesperline[VPE_LUMA] * 2303 s_q_data->sizeimage[VPE_LUMA] = (s_q_data->bytesperline[VPE_LUMA] *
@@ -2068,11 +2371,13 @@ static int vpe_release(struct file *file)
2068 vpe_dbg(dev, "releasing instance %p\n", ctx); 2371 vpe_dbg(dev, "releasing instance %p\n", ctx);
2069 2372
2070 mutex_lock(&dev->dev_mutex); 2373 mutex_lock(&dev->dev_mutex);
2071 free_vbs(ctx);
2072 free_mv_buffers(ctx); 2374 free_mv_buffers(ctx);
2073 vpdma_free_desc_list(&ctx->desc_list); 2375 vpdma_free_desc_list(&ctx->desc_list);
2074 vpdma_free_desc_buf(&ctx->mmr_adb); 2376 vpdma_free_desc_buf(&ctx->mmr_adb);
2075 2377
2378 vpdma_free_desc_buf(&ctx->sc_coeff_v);
2379 vpdma_free_desc_buf(&ctx->sc_coeff_h);
2380
2076 v4l2_fh_del(&ctx->fh); 2381 v4l2_fh_del(&ctx->fh);
2077 v4l2_fh_exit(&ctx->fh); 2382 v4l2_fh_exit(&ctx->fh);
2078 v4l2_ctrl_handler_free(&ctx->hdl); 2383 v4l2_ctrl_handler_free(&ctx->hdl);
@@ -2235,23 +2540,22 @@ static int vpe_probe(struct platform_device *pdev)
2235 2540
2236 vpe_top_vpdma_reset(dev); 2541 vpe_top_vpdma_reset(dev);
2237 2542
2238 dev->sc = sc_create(pdev); 2543 dev->sc = sc_create(pdev, "sc");
2239 if (IS_ERR(dev->sc)) { 2544 if (IS_ERR(dev->sc)) {
2240 ret = PTR_ERR(dev->sc); 2545 ret = PTR_ERR(dev->sc);
2241 goto runtime_put; 2546 goto runtime_put;
2242 } 2547 }
2243 2548
2244 dev->csc = csc_create(pdev); 2549 dev->csc = csc_create(pdev, "csc");
2245 if (IS_ERR(dev->csc)) { 2550 if (IS_ERR(dev->csc)) {
2246 ret = PTR_ERR(dev->csc); 2551 ret = PTR_ERR(dev->csc);
2247 goto runtime_put; 2552 goto runtime_put;
2248 } 2553 }
2249 2554
2250 dev->vpdma = vpdma_create(pdev, vpe_fw_cb); 2555 dev->vpdma = &dev->vpdma_data;
2251 if (IS_ERR(dev->vpdma)) { 2556 ret = vpdma_create(pdev, dev->vpdma, vpe_fw_cb);
2252 ret = PTR_ERR(dev->vpdma); 2557 if (ret)
2253 goto runtime_put; 2558 goto runtime_put;
2254 }
2255 2559
2256 return 0; 2560 return 0;
2257 2561
@@ -2290,6 +2594,7 @@ static const struct of_device_id vpe_of_match[] = {
2290 }, 2594 },
2291 {}, 2595 {},
2292}; 2596};
2597MODULE_DEVICE_TABLE(of, vpe_of_match);
2293#endif 2598#endif
2294 2599
2295static struct platform_driver vpe_pdrv = { 2600static struct platform_driver vpe_pdrv = {
diff --git a/drivers/media/platform/via-camera.c b/drivers/media/platform/via-camera.c
index 7ca12deba89c..e16f70a5df1d 100644
--- a/drivers/media/platform/via-camera.c
+++ b/drivers/media/platform/via-camera.c
@@ -39,15 +39,12 @@ MODULE_LICENSE("GPL");
39static bool flip_image; 39static bool flip_image;
40module_param(flip_image, bool, 0444); 40module_param(flip_image, bool, 0444);
41MODULE_PARM_DESC(flip_image, 41MODULE_PARM_DESC(flip_image,
42 "If set, the sensor will be instructed to flip the image " 42 "If set, the sensor will be instructed to flip the image vertically.");
43 "vertically.");
44 43
45static bool override_serial; 44static bool override_serial;
46module_param(override_serial, bool, 0444); 45module_param(override_serial, bool, 0444);
47MODULE_PARM_DESC(override_serial, 46MODULE_PARM_DESC(override_serial,
48 "The camera driver will normally refuse to load if " 47 "The camera driver will normally refuse to load if the XO 1.5 serial port is enabled. Set this option to force-enable the camera.");
49 "the XO 1.5 serial port is enabled. Set this option "
50 "to force-enable the camera.");
51 48
52/* 49/*
53 * The structure describing our camera. 50 * The structure describing our camera.
diff --git a/drivers/media/platform/vivid/Kconfig b/drivers/media/platform/vivid/Kconfig
index 8e6918c5c87c..db0dd19d227a 100644
--- a/drivers/media/platform/vivid/Kconfig
+++ b/drivers/media/platform/vivid/Kconfig
@@ -25,7 +25,7 @@ config VIDEO_VIVID
25 25
26config VIDEO_VIVID_CEC 26config VIDEO_VIVID_CEC
27 bool "Enable CEC emulation support" 27 bool "Enable CEC emulation support"
28 depends on VIDEO_VIVID && MEDIA_CEC 28 depends on VIDEO_VIVID && MEDIA_CEC_SUPPORT
29 ---help--- 29 ---help---
30 When selected the vivid module will emulate the optional 30 When selected the vivid module will emulate the optional
31 HDMI CEC feature. 31 HDMI CEC feature.
diff --git a/drivers/media/platform/vivid/vivid-cec.c b/drivers/media/platform/vivid/vivid-cec.c
index f9f878b8e0a7..cb4933592a3c 100644
--- a/drivers/media/platform/vivid/vivid-cec.c
+++ b/drivers/media/platform/vivid/vivid-cec.c
@@ -216,7 +216,6 @@ static const struct cec_adap_ops vivid_cec_adap_ops = {
216 216
217struct cec_adapter *vivid_cec_alloc_adap(struct vivid_dev *dev, 217struct cec_adapter *vivid_cec_alloc_adap(struct vivid_dev *dev,
218 unsigned int idx, 218 unsigned int idx,
219 struct device *parent,
220 bool is_source) 219 bool is_source)
221{ 220{
222 char name[sizeof(dev->vid_out_dev.name) + 2]; 221 char name[sizeof(dev->vid_out_dev.name) + 2];
@@ -227,5 +226,5 @@ struct cec_adapter *vivid_cec_alloc_adap(struct vivid_dev *dev,
227 is_source ? dev->vid_out_dev.name : dev->vid_cap_dev.name, 226 is_source ? dev->vid_out_dev.name : dev->vid_cap_dev.name,
228 idx); 227 idx);
229 return cec_allocate_adapter(&vivid_cec_adap_ops, dev, 228 return cec_allocate_adapter(&vivid_cec_adap_ops, dev,
230 name, caps, 1, parent); 229 name, caps, 1);
231} 230}
diff --git a/drivers/media/platform/vivid/vivid-cec.h b/drivers/media/platform/vivid/vivid-cec.h
index 97892afa6b3b..3926b1422777 100644
--- a/drivers/media/platform/vivid/vivid-cec.h
+++ b/drivers/media/platform/vivid/vivid-cec.h
@@ -20,7 +20,6 @@
20#ifdef CONFIG_VIDEO_VIVID_CEC 20#ifdef CONFIG_VIDEO_VIVID_CEC
21struct cec_adapter *vivid_cec_alloc_adap(struct vivid_dev *dev, 21struct cec_adapter *vivid_cec_alloc_adap(struct vivid_dev *dev,
22 unsigned int idx, 22 unsigned int idx,
23 struct device *parent,
24 bool is_source); 23 bool is_source);
25void vivid_cec_bus_free_work(struct vivid_dev *dev); 24void vivid_cec_bus_free_work(struct vivid_dev *dev);
26 25
diff --git a/drivers/media/platform/vivid/vivid-core.c b/drivers/media/platform/vivid/vivid-core.c
index 5464fefbaab9..51e37812ec98 100644
--- a/drivers/media/platform/vivid/vivid-core.c
+++ b/drivers/media/platform/vivid/vivid-core.c
@@ -183,7 +183,7 @@ static const u8 vivid_hdmi_edid[256] = {
183 0x5e, 0x5d, 0x10, 0x1f, 0x04, 0x13, 0x22, 0x21, 183 0x5e, 0x5d, 0x10, 0x1f, 0x04, 0x13, 0x22, 0x21,
184 0x20, 0x05, 0x14, 0x02, 0x11, 0x01, 0x23, 0x09, 184 0x20, 0x05, 0x14, 0x02, 0x11, 0x01, 0x23, 0x09,
185 0x07, 0x07, 0x83, 0x01, 0x00, 0x00, 0x6d, 0x03, 185 0x07, 0x07, 0x83, 0x01, 0x00, 0x00, 0x6d, 0x03,
186 0x0c, 0x00, 0x10, 0x00, 0x00, 0x78, 0x21, 0x00, 186 0x0c, 0x00, 0x10, 0x00, 0x00, 0x3c, 0x21, 0x00,
187 0x60, 0x01, 0x02, 0x03, 0x67, 0xd8, 0x5d, 0xc4, 187 0x60, 0x01, 0x02, 0x03, 0x67, 0xd8, 0x5d, 0xc4,
188 0x01, 0x78, 0x00, 0x00, 0xe2, 0x00, 0xea, 0xe3, 188 0x01, 0x78, 0x00, 0x00, 0xe2, 0x00, 0xea, 0xe3,
189 0x05, 0x00, 0x00, 0xe3, 0x06, 0x01, 0x00, 0x4d, 189 0x05, 0x00, 0x00, 0xe3, 0x06, 0x01, 0x00, 0x4d,
@@ -194,7 +194,7 @@ static const u8 vivid_hdmi_edid[256] = {
194 0x00, 0x00, 0x1a, 0x1a, 0x1d, 0x00, 0x80, 0x51, 194 0x00, 0x00, 0x1a, 0x1a, 0x1d, 0x00, 0x80, 0x51,
195 0xd0, 0x1c, 0x20, 0x40, 0x80, 0x35, 0x00, 0xc0, 195 0xd0, 0x1c, 0x20, 0x40, 0x80, 0x35, 0x00, 0xc0,
196 0x1c, 0x32, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 196 0x1c, 0x32, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00,
197 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27, 197 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63,
198}; 198};
199 199
200static int vidioc_querycap(struct file *file, void *priv, 200static int vidioc_querycap(struct file *file, void *priv,
@@ -1167,12 +1167,12 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
1167 if (in_type_counter[HDMI]) { 1167 if (in_type_counter[HDMI]) {
1168 struct cec_adapter *adap; 1168 struct cec_adapter *adap;
1169 1169
1170 adap = vivid_cec_alloc_adap(dev, 0, &pdev->dev, false); 1170 adap = vivid_cec_alloc_adap(dev, 0, false);
1171 ret = PTR_ERR_OR_ZERO(adap); 1171 ret = PTR_ERR_OR_ZERO(adap);
1172 if (ret < 0) 1172 if (ret < 0)
1173 goto unreg_dev; 1173 goto unreg_dev;
1174 dev->cec_rx_adap = adap; 1174 dev->cec_rx_adap = adap;
1175 ret = cec_register_adapter(adap); 1175 ret = cec_register_adapter(adap, &pdev->dev);
1176 if (ret < 0) { 1176 if (ret < 0) {
1177 cec_delete_adapter(adap); 1177 cec_delete_adapter(adap);
1178 dev->cec_rx_adap = NULL; 1178 dev->cec_rx_adap = NULL;
@@ -1222,13 +1222,12 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
1222 if (dev->output_type[i] != HDMI) 1222 if (dev->output_type[i] != HDMI)
1223 continue; 1223 continue;
1224 dev->cec_output2bus_map[i] = bus_cnt; 1224 dev->cec_output2bus_map[i] = bus_cnt;
1225 adap = vivid_cec_alloc_adap(dev, bus_cnt, 1225 adap = vivid_cec_alloc_adap(dev, bus_cnt, true);
1226 &pdev->dev, true);
1227 ret = PTR_ERR_OR_ZERO(adap); 1226 ret = PTR_ERR_OR_ZERO(adap);
1228 if (ret < 0) 1227 if (ret < 0)
1229 goto unreg_dev; 1228 goto unreg_dev;
1230 dev->cec_tx_adap[bus_cnt] = adap; 1229 dev->cec_tx_adap[bus_cnt] = adap;
1231 ret = cec_register_adapter(adap); 1230 ret = cec_register_adapter(adap, &pdev->dev);
1232 if (ret < 0) { 1231 if (ret < 0) {
1233 cec_delete_adapter(adap); 1232 cec_delete_adapter(adap);
1234 dev->cec_tx_adap[bus_cnt] = NULL; 1233 dev->cec_tx_adap[bus_cnt] = NULL;
diff --git a/drivers/media/platform/vivid/vivid-core.h b/drivers/media/platform/vivid/vivid-core.h
index a7daa40d0a49..5cdf95bdc4d1 100644
--- a/drivers/media/platform/vivid/vivid-core.h
+++ b/drivers/media/platform/vivid/vivid-core.h
@@ -80,7 +80,7 @@ extern unsigned vivid_debug;
80 80
81struct vivid_fmt { 81struct vivid_fmt {
82 u32 fourcc; /* v4l2 format id */ 82 u32 fourcc; /* v4l2 format id */
83 bool is_yuv; 83 enum tgp_color_enc color_enc;
84 bool can_do_overlay; 84 bool can_do_overlay;
85 u8 vdownsampling[TPG_MAX_PLANES]; 85 u8 vdownsampling[TPG_MAX_PLANES];
86 u32 alpha_mask; 86 u32 alpha_mask;
@@ -346,6 +346,7 @@ struct vivid_dev {
346 struct v4l2_dv_timings dv_timings_out; 346 struct v4l2_dv_timings dv_timings_out;
347 u32 colorspace_out; 347 u32 colorspace_out;
348 u32 ycbcr_enc_out; 348 u32 ycbcr_enc_out;
349 u32 hsv_enc_out;
349 u32 quantization_out; 350 u32 quantization_out;
350 u32 xfer_func_out; 351 u32 xfer_func_out;
351 u32 service_set_out; 352 u32 service_set_out;
diff --git a/drivers/media/platform/vivid/vivid-ctrls.c b/drivers/media/platform/vivid/vivid-ctrls.c
index aceb38d9f7e7..34731f71cc00 100644
--- a/drivers/media/platform/vivid/vivid-ctrls.c
+++ b/drivers/media/platform/vivid/vivid-ctrls.c
@@ -79,6 +79,7 @@
79#define VIVID_CID_MAX_EDID_BLOCKS (VIVID_CID_VIVID_BASE + 40) 79#define VIVID_CID_MAX_EDID_BLOCKS (VIVID_CID_VIVID_BASE + 40)
80#define VIVID_CID_PERCENTAGE_FILL (VIVID_CID_VIVID_BASE + 41) 80#define VIVID_CID_PERCENTAGE_FILL (VIVID_CID_VIVID_BASE + 41)
81#define VIVID_CID_REDUCED_FPS (VIVID_CID_VIVID_BASE + 42) 81#define VIVID_CID_REDUCED_FPS (VIVID_CID_VIVID_BASE + 42)
82#define VIVID_CID_HSV_ENC (VIVID_CID_VIVID_BASE + 43)
82 83
83#define VIVID_CID_STD_SIGNAL_MODE (VIVID_CID_VIVID_BASE + 60) 84#define VIVID_CID_STD_SIGNAL_MODE (VIVID_CID_VIVID_BASE + 60)
84#define VIVID_CID_STANDARD (VIVID_CID_VIVID_BASE + 61) 85#define VIVID_CID_STANDARD (VIVID_CID_VIVID_BASE + 61)
@@ -378,6 +379,14 @@ static int vivid_vid_cap_s_ctrl(struct v4l2_ctrl *ctrl)
378 vivid_send_source_change(dev, HDMI); 379 vivid_send_source_change(dev, HDMI);
379 vivid_send_source_change(dev, WEBCAM); 380 vivid_send_source_change(dev, WEBCAM);
380 break; 381 break;
382 case VIVID_CID_HSV_ENC:
383 tpg_s_hsv_enc(&dev->tpg, ctrl->val ? V4L2_HSV_ENC_256 :
384 V4L2_HSV_ENC_180);
385 vivid_send_source_change(dev, TV);
386 vivid_send_source_change(dev, SVID);
387 vivid_send_source_change(dev, HDMI);
388 vivid_send_source_change(dev, WEBCAM);
389 break;
381 case VIVID_CID_QUANTIZATION: 390 case VIVID_CID_QUANTIZATION:
382 tpg_s_quantization(&dev->tpg, ctrl->val); 391 tpg_s_quantization(&dev->tpg, ctrl->val);
383 vivid_send_source_change(dev, TV); 392 vivid_send_source_change(dev, TV);
@@ -778,6 +787,21 @@ static const struct v4l2_ctrl_config vivid_ctrl_ycbcr_enc = {
778 .qmenu = vivid_ctrl_ycbcr_enc_strings, 787 .qmenu = vivid_ctrl_ycbcr_enc_strings,
779}; 788};
780 789
790static const char * const vivid_ctrl_hsv_enc_strings[] = {
791 "Hue 0-179",
792 "Hue 0-256",
793 NULL,
794};
795
796static const struct v4l2_ctrl_config vivid_ctrl_hsv_enc = {
797 .ops = &vivid_vid_cap_ctrl_ops,
798 .id = VIVID_CID_HSV_ENC,
799 .name = "HSV Encoding",
800 .type = V4L2_CTRL_TYPE_MENU,
801 .max = ARRAY_SIZE(vivid_ctrl_hsv_enc_strings) - 2,
802 .qmenu = vivid_ctrl_hsv_enc_strings,
803};
804
781static const char * const vivid_ctrl_quantization_strings[] = { 805static const char * const vivid_ctrl_quantization_strings[] = {
782 "Default", 806 "Default",
783 "Full Range", 807 "Full Range",
@@ -1454,6 +1478,7 @@ int vivid_create_controls(struct vivid_dev *dev, bool show_ccs_cap,
1454 &vivid_ctrl_colorspace, NULL); 1478 &vivid_ctrl_colorspace, NULL);
1455 v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_xfer_func, NULL); 1479 v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_xfer_func, NULL);
1456 v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_ycbcr_enc, NULL); 1480 v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_ycbcr_enc, NULL);
1481 v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_hsv_enc, NULL);
1457 v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_quantization, NULL); 1482 v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_quantization, NULL);
1458 v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_alpha_mode, NULL); 1483 v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_alpha_mode, NULL);
1459 } 1484 }
diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c b/drivers/media/platform/vivid/vivid-vid-cap.c
index d5c84ecf2027..c52dd8787794 100644
--- a/drivers/media/platform/vivid/vivid-vid-cap.c
+++ b/drivers/media/platform/vivid/vivid-vid-cap.c
@@ -510,6 +510,13 @@ static unsigned vivid_ycbcr_enc_cap(struct vivid_dev *dev)
510 return dev->ycbcr_enc_out; 510 return dev->ycbcr_enc_out;
511} 511}
512 512
513static unsigned int vivid_hsv_enc_cap(struct vivid_dev *dev)
514{
515 if (!dev->loop_video || vivid_is_webcam(dev) || vivid_is_tv_cap(dev))
516 return tpg_g_hsv_enc(&dev->tpg);
517 return dev->hsv_enc_out;
518}
519
513static unsigned vivid_quantization_cap(struct vivid_dev *dev) 520static unsigned vivid_quantization_cap(struct vivid_dev *dev)
514{ 521{
515 if (!dev->loop_video || vivid_is_webcam(dev) || vivid_is_tv_cap(dev)) 522 if (!dev->loop_video || vivid_is_webcam(dev) || vivid_is_tv_cap(dev))
@@ -530,7 +537,10 @@ int vivid_g_fmt_vid_cap(struct file *file, void *priv,
530 mp->pixelformat = dev->fmt_cap->fourcc; 537 mp->pixelformat = dev->fmt_cap->fourcc;
531 mp->colorspace = vivid_colorspace_cap(dev); 538 mp->colorspace = vivid_colorspace_cap(dev);
532 mp->xfer_func = vivid_xfer_func_cap(dev); 539 mp->xfer_func = vivid_xfer_func_cap(dev);
533 mp->ycbcr_enc = vivid_ycbcr_enc_cap(dev); 540 if (dev->fmt_cap->color_enc == TGP_COLOR_ENC_HSV)
541 mp->hsv_enc = vivid_hsv_enc_cap(dev);
542 else
543 mp->ycbcr_enc = vivid_ycbcr_enc_cap(dev);
534 mp->quantization = vivid_quantization_cap(dev); 544 mp->quantization = vivid_quantization_cap(dev);
535 mp->num_planes = dev->fmt_cap->buffers; 545 mp->num_planes = dev->fmt_cap->buffers;
536 for (p = 0; p < mp->num_planes; p++) { 546 for (p = 0; p < mp->num_planes; p++) {
@@ -618,7 +628,10 @@ int vivid_try_fmt_vid_cap(struct file *file, void *priv,
618 memset(pfmt[p].reserved, 0, sizeof(pfmt[p].reserved)); 628 memset(pfmt[p].reserved, 0, sizeof(pfmt[p].reserved));
619 } 629 }
620 mp->colorspace = vivid_colorspace_cap(dev); 630 mp->colorspace = vivid_colorspace_cap(dev);
621 mp->ycbcr_enc = vivid_ycbcr_enc_cap(dev); 631 if (fmt->color_enc == TGP_COLOR_ENC_HSV)
632 mp->hsv_enc = vivid_hsv_enc_cap(dev);
633 else
634 mp->ycbcr_enc = vivid_ycbcr_enc_cap(dev);
622 mp->xfer_func = vivid_xfer_func_cap(dev); 635 mp->xfer_func = vivid_xfer_func_cap(dev);
623 mp->quantization = vivid_quantization_cap(dev); 636 mp->quantization = vivid_quantization_cap(dev);
624 memset(mp->reserved, 0, sizeof(mp->reserved)); 637 memset(mp->reserved, 0, sizeof(mp->reserved));
diff --git a/drivers/media/platform/vivid/vivid-vid-common.c b/drivers/media/platform/vivid/vivid-vid-common.c
index fcda3ae4e6b0..5fc010f6ce67 100644
--- a/drivers/media/platform/vivid/vivid-vid-common.c
+++ b/drivers/media/platform/vivid/vivid-vid-common.c
@@ -48,7 +48,7 @@ struct vivid_fmt vivid_formats[] = {
48 .fourcc = V4L2_PIX_FMT_YUYV, 48 .fourcc = V4L2_PIX_FMT_YUYV,
49 .vdownsampling = { 1 }, 49 .vdownsampling = { 1 },
50 .bit_depth = { 16 }, 50 .bit_depth = { 16 },
51 .is_yuv = true, 51 .color_enc = TGP_COLOR_ENC_YCBCR,
52 .planes = 1, 52 .planes = 1,
53 .buffers = 1, 53 .buffers = 1,
54 .data_offset = { PLANE0_DATA_OFFSET }, 54 .data_offset = { PLANE0_DATA_OFFSET },
@@ -57,7 +57,7 @@ struct vivid_fmt vivid_formats[] = {
57 .fourcc = V4L2_PIX_FMT_UYVY, 57 .fourcc = V4L2_PIX_FMT_UYVY,
58 .vdownsampling = { 1 }, 58 .vdownsampling = { 1 },
59 .bit_depth = { 16 }, 59 .bit_depth = { 16 },
60 .is_yuv = true, 60 .color_enc = TGP_COLOR_ENC_YCBCR,
61 .planes = 1, 61 .planes = 1,
62 .buffers = 1, 62 .buffers = 1,
63 }, 63 },
@@ -65,7 +65,7 @@ struct vivid_fmt vivid_formats[] = {
65 .fourcc = V4L2_PIX_FMT_YVYU, 65 .fourcc = V4L2_PIX_FMT_YVYU,
66 .vdownsampling = { 1 }, 66 .vdownsampling = { 1 },
67 .bit_depth = { 16 }, 67 .bit_depth = { 16 },
68 .is_yuv = true, 68 .color_enc = TGP_COLOR_ENC_YCBCR,
69 .planes = 1, 69 .planes = 1,
70 .buffers = 1, 70 .buffers = 1,
71 }, 71 },
@@ -73,7 +73,7 @@ struct vivid_fmt vivid_formats[] = {
73 .fourcc = V4L2_PIX_FMT_VYUY, 73 .fourcc = V4L2_PIX_FMT_VYUY,
74 .vdownsampling = { 1 }, 74 .vdownsampling = { 1 },
75 .bit_depth = { 16 }, 75 .bit_depth = { 16 },
76 .is_yuv = true, 76 .color_enc = TGP_COLOR_ENC_YCBCR,
77 .planes = 1, 77 .planes = 1,
78 .buffers = 1, 78 .buffers = 1,
79 }, 79 },
@@ -81,7 +81,7 @@ struct vivid_fmt vivid_formats[] = {
81 .fourcc = V4L2_PIX_FMT_YUV422P, 81 .fourcc = V4L2_PIX_FMT_YUV422P,
82 .vdownsampling = { 1, 1, 1 }, 82 .vdownsampling = { 1, 1, 1 },
83 .bit_depth = { 8, 4, 4 }, 83 .bit_depth = { 8, 4, 4 },
84 .is_yuv = true, 84 .color_enc = TGP_COLOR_ENC_YCBCR,
85 .planes = 3, 85 .planes = 3,
86 .buffers = 1, 86 .buffers = 1,
87 }, 87 },
@@ -89,7 +89,7 @@ struct vivid_fmt vivid_formats[] = {
89 .fourcc = V4L2_PIX_FMT_YUV420, 89 .fourcc = V4L2_PIX_FMT_YUV420,
90 .vdownsampling = { 1, 2, 2 }, 90 .vdownsampling = { 1, 2, 2 },
91 .bit_depth = { 8, 4, 4 }, 91 .bit_depth = { 8, 4, 4 },
92 .is_yuv = true, 92 .color_enc = TGP_COLOR_ENC_YCBCR,
93 .planes = 3, 93 .planes = 3,
94 .buffers = 1, 94 .buffers = 1,
95 }, 95 },
@@ -97,7 +97,7 @@ struct vivid_fmt vivid_formats[] = {
97 .fourcc = V4L2_PIX_FMT_YVU420, 97 .fourcc = V4L2_PIX_FMT_YVU420,
98 .vdownsampling = { 1, 2, 2 }, 98 .vdownsampling = { 1, 2, 2 },
99 .bit_depth = { 8, 4, 4 }, 99 .bit_depth = { 8, 4, 4 },
100 .is_yuv = true, 100 .color_enc = TGP_COLOR_ENC_YCBCR,
101 .planes = 3, 101 .planes = 3,
102 .buffers = 1, 102 .buffers = 1,
103 }, 103 },
@@ -105,7 +105,7 @@ struct vivid_fmt vivid_formats[] = {
105 .fourcc = V4L2_PIX_FMT_NV12, 105 .fourcc = V4L2_PIX_FMT_NV12,
106 .vdownsampling = { 1, 2 }, 106 .vdownsampling = { 1, 2 },
107 .bit_depth = { 8, 8 }, 107 .bit_depth = { 8, 8 },
108 .is_yuv = true, 108 .color_enc = TGP_COLOR_ENC_YCBCR,
109 .planes = 2, 109 .planes = 2,
110 .buffers = 1, 110 .buffers = 1,
111 }, 111 },
@@ -113,7 +113,7 @@ struct vivid_fmt vivid_formats[] = {
113 .fourcc = V4L2_PIX_FMT_NV21, 113 .fourcc = V4L2_PIX_FMT_NV21,
114 .vdownsampling = { 1, 2 }, 114 .vdownsampling = { 1, 2 },
115 .bit_depth = { 8, 8 }, 115 .bit_depth = { 8, 8 },
116 .is_yuv = true, 116 .color_enc = TGP_COLOR_ENC_YCBCR,
117 .planes = 2, 117 .planes = 2,
118 .buffers = 1, 118 .buffers = 1,
119 }, 119 },
@@ -121,7 +121,7 @@ struct vivid_fmt vivid_formats[] = {
121 .fourcc = V4L2_PIX_FMT_NV16, 121 .fourcc = V4L2_PIX_FMT_NV16,
122 .vdownsampling = { 1, 1 }, 122 .vdownsampling = { 1, 1 },
123 .bit_depth = { 8, 8 }, 123 .bit_depth = { 8, 8 },
124 .is_yuv = true, 124 .color_enc = TGP_COLOR_ENC_YCBCR,
125 .planes = 2, 125 .planes = 2,
126 .buffers = 1, 126 .buffers = 1,
127 }, 127 },
@@ -129,7 +129,7 @@ struct vivid_fmt vivid_formats[] = {
129 .fourcc = V4L2_PIX_FMT_NV61, 129 .fourcc = V4L2_PIX_FMT_NV61,
130 .vdownsampling = { 1, 1 }, 130 .vdownsampling = { 1, 1 },
131 .bit_depth = { 8, 8 }, 131 .bit_depth = { 8, 8 },
132 .is_yuv = true, 132 .color_enc = TGP_COLOR_ENC_YCBCR,
133 .planes = 2, 133 .planes = 2,
134 .buffers = 1, 134 .buffers = 1,
135 }, 135 },
@@ -137,7 +137,7 @@ struct vivid_fmt vivid_formats[] = {
137 .fourcc = V4L2_PIX_FMT_NV24, 137 .fourcc = V4L2_PIX_FMT_NV24,
138 .vdownsampling = { 1, 1 }, 138 .vdownsampling = { 1, 1 },
139 .bit_depth = { 8, 16 }, 139 .bit_depth = { 8, 16 },
140 .is_yuv = true, 140 .color_enc = TGP_COLOR_ENC_YCBCR,
141 .planes = 2, 141 .planes = 2,
142 .buffers = 1, 142 .buffers = 1,
143 }, 143 },
@@ -145,7 +145,7 @@ struct vivid_fmt vivid_formats[] = {
145 .fourcc = V4L2_PIX_FMT_NV42, 145 .fourcc = V4L2_PIX_FMT_NV42,
146 .vdownsampling = { 1, 1 }, 146 .vdownsampling = { 1, 1 },
147 .bit_depth = { 8, 16 }, 147 .bit_depth = { 8, 16 },
148 .is_yuv = true, 148 .color_enc = TGP_COLOR_ENC_YCBCR,
149 .planes = 2, 149 .planes = 2,
150 .buffers = 1, 150 .buffers = 1,
151 }, 151 },
@@ -184,7 +184,7 @@ struct vivid_fmt vivid_formats[] = {
184 .fourcc = V4L2_PIX_FMT_GREY, 184 .fourcc = V4L2_PIX_FMT_GREY,
185 .vdownsampling = { 1 }, 185 .vdownsampling = { 1 },
186 .bit_depth = { 8 }, 186 .bit_depth = { 8 },
187 .is_yuv = true, 187 .color_enc = TGP_COLOR_ENC_LUMA,
188 .planes = 1, 188 .planes = 1,
189 .buffers = 1, 189 .buffers = 1,
190 }, 190 },
@@ -192,7 +192,7 @@ struct vivid_fmt vivid_formats[] = {
192 .fourcc = V4L2_PIX_FMT_Y16, 192 .fourcc = V4L2_PIX_FMT_Y16,
193 .vdownsampling = { 1 }, 193 .vdownsampling = { 1 },
194 .bit_depth = { 16 }, 194 .bit_depth = { 16 },
195 .is_yuv = true, 195 .color_enc = TGP_COLOR_ENC_LUMA,
196 .planes = 1, 196 .planes = 1,
197 .buffers = 1, 197 .buffers = 1,
198 }, 198 },
@@ -200,7 +200,7 @@ struct vivid_fmt vivid_formats[] = {
200 .fourcc = V4L2_PIX_FMT_Y16_BE, 200 .fourcc = V4L2_PIX_FMT_Y16_BE,
201 .vdownsampling = { 1 }, 201 .vdownsampling = { 1 },
202 .bit_depth = { 16 }, 202 .bit_depth = { 16 },
203 .is_yuv = true, 203 .color_enc = TGP_COLOR_ENC_LUMA,
204 .planes = 1, 204 .planes = 1,
205 .buffers = 1, 205 .buffers = 1,
206 }, 206 },
@@ -445,6 +445,22 @@ struct vivid_fmt vivid_formats[] = {
445 .planes = 1, 445 .planes = 1,
446 .buffers = 1, 446 .buffers = 1,
447 }, 447 },
448 {
449 .fourcc = V4L2_PIX_FMT_HSV24, /* HSV 24bits */
450 .color_enc = TGP_COLOR_ENC_HSV,
451 .vdownsampling = { 1 },
452 .bit_depth = { 24 },
453 .planes = 1,
454 .buffers = 1,
455 },
456 {
457 .fourcc = V4L2_PIX_FMT_HSV32, /* HSV 32bits */
458 .color_enc = TGP_COLOR_ENC_HSV,
459 .vdownsampling = { 1 },
460 .bit_depth = { 32 },
461 .planes = 1,
462 .buffers = 1,
463 },
448 464
449 /* Multiplanar formats */ 465 /* Multiplanar formats */
450 466
@@ -452,7 +468,7 @@ struct vivid_fmt vivid_formats[] = {
452 .fourcc = V4L2_PIX_FMT_NV16M, 468 .fourcc = V4L2_PIX_FMT_NV16M,
453 .vdownsampling = { 1, 1 }, 469 .vdownsampling = { 1, 1 },
454 .bit_depth = { 8, 8 }, 470 .bit_depth = { 8, 8 },
455 .is_yuv = true, 471 .color_enc = TGP_COLOR_ENC_YCBCR,
456 .planes = 2, 472 .planes = 2,
457 .buffers = 2, 473 .buffers = 2,
458 .data_offset = { PLANE0_DATA_OFFSET, 0 }, 474 .data_offset = { PLANE0_DATA_OFFSET, 0 },
@@ -461,7 +477,7 @@ struct vivid_fmt vivid_formats[] = {
461 .fourcc = V4L2_PIX_FMT_NV61M, 477 .fourcc = V4L2_PIX_FMT_NV61M,
462 .vdownsampling = { 1, 1 }, 478 .vdownsampling = { 1, 1 },
463 .bit_depth = { 8, 8 }, 479 .bit_depth = { 8, 8 },
464 .is_yuv = true, 480 .color_enc = TGP_COLOR_ENC_YCBCR,
465 .planes = 2, 481 .planes = 2,
466 .buffers = 2, 482 .buffers = 2,
467 .data_offset = { 0, PLANE0_DATA_OFFSET }, 483 .data_offset = { 0, PLANE0_DATA_OFFSET },
@@ -470,7 +486,7 @@ struct vivid_fmt vivid_formats[] = {
470 .fourcc = V4L2_PIX_FMT_YUV420M, 486 .fourcc = V4L2_PIX_FMT_YUV420M,
471 .vdownsampling = { 1, 2, 2 }, 487 .vdownsampling = { 1, 2, 2 },
472 .bit_depth = { 8, 4, 4 }, 488 .bit_depth = { 8, 4, 4 },
473 .is_yuv = true, 489 .color_enc = TGP_COLOR_ENC_YCBCR,
474 .planes = 3, 490 .planes = 3,
475 .buffers = 3, 491 .buffers = 3,
476 }, 492 },
@@ -478,7 +494,7 @@ struct vivid_fmt vivid_formats[] = {
478 .fourcc = V4L2_PIX_FMT_YVU420M, 494 .fourcc = V4L2_PIX_FMT_YVU420M,
479 .vdownsampling = { 1, 2, 2 }, 495 .vdownsampling = { 1, 2, 2 },
480 .bit_depth = { 8, 4, 4 }, 496 .bit_depth = { 8, 4, 4 },
481 .is_yuv = true, 497 .color_enc = TGP_COLOR_ENC_YCBCR,
482 .planes = 3, 498 .planes = 3,
483 .buffers = 3, 499 .buffers = 3,
484 }, 500 },
@@ -486,7 +502,7 @@ struct vivid_fmt vivid_formats[] = {
486 .fourcc = V4L2_PIX_FMT_NV12M, 502 .fourcc = V4L2_PIX_FMT_NV12M,
487 .vdownsampling = { 1, 2 }, 503 .vdownsampling = { 1, 2 },
488 .bit_depth = { 8, 8 }, 504 .bit_depth = { 8, 8 },
489 .is_yuv = true, 505 .color_enc = TGP_COLOR_ENC_YCBCR,
490 .planes = 2, 506 .planes = 2,
491 .buffers = 2, 507 .buffers = 2,
492 }, 508 },
@@ -494,7 +510,7 @@ struct vivid_fmt vivid_formats[] = {
494 .fourcc = V4L2_PIX_FMT_NV21M, 510 .fourcc = V4L2_PIX_FMT_NV21M,
495 .vdownsampling = { 1, 2 }, 511 .vdownsampling = { 1, 2 },
496 .bit_depth = { 8, 8 }, 512 .bit_depth = { 8, 8 },
497 .is_yuv = true, 513 .color_enc = TGP_COLOR_ENC_YCBCR,
498 .planes = 2, 514 .planes = 2,
499 .buffers = 2, 515 .buffers = 2,
500 }, 516 },
@@ -502,7 +518,7 @@ struct vivid_fmt vivid_formats[] = {
502 .fourcc = V4L2_PIX_FMT_YUV422M, 518 .fourcc = V4L2_PIX_FMT_YUV422M,
503 .vdownsampling = { 1, 1, 1 }, 519 .vdownsampling = { 1, 1, 1 },
504 .bit_depth = { 8, 4, 4 }, 520 .bit_depth = { 8, 4, 4 },
505 .is_yuv = true, 521 .color_enc = TGP_COLOR_ENC_YCBCR,
506 .planes = 3, 522 .planes = 3,
507 .buffers = 3, 523 .buffers = 3,
508 }, 524 },
@@ -510,7 +526,7 @@ struct vivid_fmt vivid_formats[] = {
510 .fourcc = V4L2_PIX_FMT_YVU422M, 526 .fourcc = V4L2_PIX_FMT_YVU422M,
511 .vdownsampling = { 1, 1, 1 }, 527 .vdownsampling = { 1, 1, 1 },
512 .bit_depth = { 8, 4, 4 }, 528 .bit_depth = { 8, 4, 4 },
513 .is_yuv = true, 529 .color_enc = TGP_COLOR_ENC_YCBCR,
514 .planes = 3, 530 .planes = 3,
515 .buffers = 3, 531 .buffers = 3,
516 }, 532 },
@@ -518,7 +534,7 @@ struct vivid_fmt vivid_formats[] = {
518 .fourcc = V4L2_PIX_FMT_YUV444M, 534 .fourcc = V4L2_PIX_FMT_YUV444M,
519 .vdownsampling = { 1, 1, 1 }, 535 .vdownsampling = { 1, 1, 1 },
520 .bit_depth = { 8, 8, 8 }, 536 .bit_depth = { 8, 8, 8 },
521 .is_yuv = true, 537 .color_enc = TGP_COLOR_ENC_YCBCR,
522 .planes = 3, 538 .planes = 3,
523 .buffers = 3, 539 .buffers = 3,
524 }, 540 },
@@ -526,7 +542,7 @@ struct vivid_fmt vivid_formats[] = {
526 .fourcc = V4L2_PIX_FMT_YVU444M, 542 .fourcc = V4L2_PIX_FMT_YVU444M,
527 .vdownsampling = { 1, 1, 1 }, 543 .vdownsampling = { 1, 1, 1 },
528 .bit_depth = { 8, 8, 8 }, 544 .bit_depth = { 8, 8, 8 },
529 .is_yuv = true, 545 .color_enc = TGP_COLOR_ENC_YCBCR,
530 .planes = 3, 546 .planes = 3,
531 .buffers = 3, 547 .buffers = 3,
532 }, 548 },
@@ -616,6 +632,7 @@ void fmt_sp2mp(const struct v4l2_format *sp_fmt, struct v4l2_format *mp_fmt)
616 mp->field = pix->field; 632 mp->field = pix->field;
617 mp->colorspace = pix->colorspace; 633 mp->colorspace = pix->colorspace;
618 mp->xfer_func = pix->xfer_func; 634 mp->xfer_func = pix->xfer_func;
635 /* Also copies hsv_enc */
619 mp->ycbcr_enc = pix->ycbcr_enc; 636 mp->ycbcr_enc = pix->ycbcr_enc;
620 mp->quantization = pix->quantization; 637 mp->quantization = pix->quantization;
621 mp->num_planes = 1; 638 mp->num_planes = 1;
@@ -645,6 +662,7 @@ int fmt_sp2mp_func(struct file *file, void *priv,
645 pix->field = mp->field; 662 pix->field = mp->field;
646 pix->colorspace = mp->colorspace; 663 pix->colorspace = mp->colorspace;
647 pix->xfer_func = mp->xfer_func; 664 pix->xfer_func = mp->xfer_func;
665 /* Also copies hsv_enc */
648 pix->ycbcr_enc = mp->ycbcr_enc; 666 pix->ycbcr_enc = mp->ycbcr_enc;
649 pix->quantization = mp->quantization; 667 pix->quantization = mp->quantization;
650 pix->sizeimage = ppix->sizeimage; 668 pix->sizeimage = ppix->sizeimage;
diff --git a/drivers/media/platform/vivid/vivid-vid-out.c b/drivers/media/platform/vivid/vivid-vid-out.c
index dd609eea4753..7ba52ee98371 100644
--- a/drivers/media/platform/vivid/vivid-vid-out.c
+++ b/drivers/media/platform/vivid/vivid-vid-out.c
@@ -256,6 +256,7 @@ void vivid_update_format_out(struct vivid_dev *dev)
256 } 256 }
257 dev->xfer_func_out = V4L2_XFER_FUNC_DEFAULT; 257 dev->xfer_func_out = V4L2_XFER_FUNC_DEFAULT;
258 dev->ycbcr_enc_out = V4L2_YCBCR_ENC_DEFAULT; 258 dev->ycbcr_enc_out = V4L2_YCBCR_ENC_DEFAULT;
259 dev->hsv_enc_out = V4L2_HSV_ENC_180;
259 dev->quantization_out = V4L2_QUANTIZATION_DEFAULT; 260 dev->quantization_out = V4L2_QUANTIZATION_DEFAULT;
260 dev->compose_out = dev->sink_rect; 261 dev->compose_out = dev->sink_rect;
261 dev->compose_bounds_out = dev->sink_rect; 262 dev->compose_bounds_out = dev->sink_rect;
diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c
index 57c713a4e1df..aa237b48ad55 100644
--- a/drivers/media/platform/vsp1/vsp1_drv.c
+++ b/drivers/media/platform/vsp1/vsp1_drv.c
@@ -770,6 +770,7 @@ static const struct of_device_id vsp1_of_match[] = {
770 { .compatible = "renesas,vsp2" }, 770 { .compatible = "renesas,vsp2" },
771 { }, 771 { },
772}; 772};
773MODULE_DEVICE_TABLE(of, vsp1_of_match);
773 774
774static struct platform_driver vsp1_platform_driver = { 775static struct platform_driver vsp1_platform_driver = {
775 .probe = vsp1_probe, 776 .probe = vsp1_probe,
diff --git a/drivers/media/platform/vsp1/vsp1_pipe.c b/drivers/media/platform/vsp1/vsp1_pipe.c
index 756ca4ea7668..280ba0804699 100644
--- a/drivers/media/platform/vsp1/vsp1_pipe.c
+++ b/drivers/media/platform/vsp1/vsp1_pipe.c
@@ -78,6 +78,14 @@ static const struct vsp1_format_info vsp1_video_formats[] = {
78 VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 78 VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
79 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 79 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
80 1, { 32, 0, 0 }, false, false, 1, 1, false }, 80 1, { 32, 0, 0 }, false, false, 1, 1, false },
81 { V4L2_PIX_FMT_HSV24, MEDIA_BUS_FMT_AHSV8888_1X32,
82 VI6_FMT_RGB_888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
83 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
84 1, { 24, 0, 0 }, false, false, 1, 1, false },
85 { V4L2_PIX_FMT_HSV32, MEDIA_BUS_FMT_AHSV8888_1X32,
86 VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
87 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
88 1, { 32, 0, 0 }, false, false, 1, 1, false },
81 { V4L2_PIX_FMT_UYVY, MEDIA_BUS_FMT_AYUV8_1X32, 89 { V4L2_PIX_FMT_UYVY, MEDIA_BUS_FMT_AYUV8_1X32,
82 VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 90 VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
83 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 91 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
diff --git a/drivers/media/platform/vsp1/vsp1_rwpf.c b/drivers/media/platform/vsp1/vsp1_rwpf.c
index 66e4d7ea31d6..04104ef28fb5 100644
--- a/drivers/media/platform/vsp1/vsp1_rwpf.c
+++ b/drivers/media/platform/vsp1/vsp1_rwpf.c
@@ -37,6 +37,7 @@ static int vsp1_rwpf_enum_mbus_code(struct v4l2_subdev *subdev,
37{ 37{
38 static const unsigned int codes[] = { 38 static const unsigned int codes[] = {
39 MEDIA_BUS_FMT_ARGB8888_1X32, 39 MEDIA_BUS_FMT_ARGB8888_1X32,
40 MEDIA_BUS_FMT_AHSV8888_1X32,
40 MEDIA_BUS_FMT_AYUV8_1X32, 41 MEDIA_BUS_FMT_AYUV8_1X32,
41 }; 42 };
42 43
@@ -78,6 +79,7 @@ static int vsp1_rwpf_set_format(struct v4l2_subdev *subdev,
78 79
79 /* Default to YUV if the requested format is not supported. */ 80 /* Default to YUV if the requested format is not supported. */
80 if (fmt->format.code != MEDIA_BUS_FMT_ARGB8888_1X32 && 81 if (fmt->format.code != MEDIA_BUS_FMT_ARGB8888_1X32 &&
82 fmt->format.code != MEDIA_BUS_FMT_AHSV8888_1X32 &&
81 fmt->format.code != MEDIA_BUS_FMT_AYUV8_1X32) 83 fmt->format.code != MEDIA_BUS_FMT_AYUV8_1X32)
82 fmt->format.code = MEDIA_BUS_FMT_AYUV8_1X32; 84 fmt->format.code = MEDIA_BUS_FMT_AYUV8_1X32;
83 85
diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c
index d351b9c768d2..41e8b096dab8 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -124,6 +124,11 @@ static int __vsp1_video_try_format(struct vsp1_video *video,
124 pix->pixelformat = info->fourcc; 124 pix->pixelformat = info->fourcc;
125 pix->colorspace = V4L2_COLORSPACE_SRGB; 125 pix->colorspace = V4L2_COLORSPACE_SRGB;
126 pix->field = V4L2_FIELD_NONE; 126 pix->field = V4L2_FIELD_NONE;
127
128 if (info->fourcc == V4L2_PIX_FMT_HSV24 ||
129 info->fourcc == V4L2_PIX_FMT_HSV32)
130 pix->hsv_enc = V4L2_HSV_ENC_256;
131
127 memset(pix->reserved, 0, sizeof(pix->reserved)); 132 memset(pix->reserved, 0, sizeof(pix->reserved));
128 133
129 /* Align the width and height for YUV 4:2:2 and 4:2:0 formats. */ 134 /* Align the width and height for YUV 4:2:2 and 4:2:0 formats. */
diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c
index cff1eb144a5c..ca051ccbc3e4 100644
--- a/drivers/media/radio/radio-gemtek.c
+++ b/drivers/media/radio/radio-gemtek.c
@@ -67,14 +67,10 @@ module_param(probe, bool, 0444);
67MODULE_PARM_DESC(probe, "Enable automatic device probing."); 67MODULE_PARM_DESC(probe, "Enable automatic device probing.");
68 68
69module_param(hardmute, bool, 0644); 69module_param(hardmute, bool, 0644);
70MODULE_PARM_DESC(hardmute, "Enable 'hard muting' by shutting down PLL, may " 70MODULE_PARM_DESC(hardmute, "Enable 'hard muting' by shutting down PLL, may reduce static noise.");
71 "reduce static noise.");
72 71
73module_param_array(io, int, NULL, 0444); 72module_param_array(io, int, NULL, 0444);
74MODULE_PARM_DESC(io, "Force I/O ports for the GemTek Radio card if automatic " 73MODULE_PARM_DESC(io, "Force I/O ports for the GemTek Radio card if automatic probing is disabled or fails. The most common I/O ports are: 0x20c 0x30c, 0x24c or 0x34c (0x20c, 0x248 and 0x28c have been reported to work for the combined sound/radiocard).");
75 "probing is disabled or fails. The most common I/O ports are: 0x20c "
76 "0x30c, 0x24c or 0x34c (0x20c, 0x248 and 0x28c have been reported to "
77 "work for the combined sound/radiocard).");
78 74
79module_param_array(radio_nr, int, NULL, 0444); 75module_param_array(radio_nr, int, NULL, 0444);
80MODULE_PARM_DESC(radio_nr, "Radio device numbers"); 76MODULE_PARM_DESC(radio_nr, "Radio device numbers");
diff --git a/drivers/media/radio/radio-wl1273.c b/drivers/media/radio/radio-wl1273.c
index a93f681aa9d6..9ce4b12299b4 100644
--- a/drivers/media/radio/radio-wl1273.c
+++ b/drivers/media/radio/radio-wl1273.c
@@ -2068,8 +2068,7 @@ static int wl1273_fm_radio_probe(struct platform_device *pdev)
2068 goto err_request_irq; 2068 goto err_request_irq;
2069 } 2069 }
2070 } else { 2070 } else {
2071 dev_err(radio->dev, WL1273_FM_DRIVER_NAME ": Core WL1273 IRQ" 2071 dev_err(radio->dev, WL1273_FM_DRIVER_NAME ": Core WL1273 IRQ not configured");
2072 " not configured");
2073 r = -EINVAL; 2072 r = -EINVAL;
2074 goto pdata_err; 2073 goto pdata_err;
2075 } 2074 }
diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c b/drivers/media/radio/si470x/radio-si470x-i2c.c
index ee0470a3196b..9b81969d76b5 100644
--- a/drivers/media/radio/si470x/radio-si470x-i2c.c
+++ b/drivers/media/radio/si470x/radio-si470x-i2c.c
@@ -387,8 +387,8 @@ static int si470x_i2c_probe(struct i2c_client *client,
387 radio->registers[DEVICEID], radio->registers[SI_CHIPID]); 387 radio->registers[DEVICEID], radio->registers[SI_CHIPID]);
388 if ((radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE) < RADIO_FW_VERSION) { 388 if ((radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE) < RADIO_FW_VERSION) {
389 dev_warn(&client->dev, 389 dev_warn(&client->dev,
390 "This driver is known to work with " 390 "This driver is known to work with firmware version %hu,\n",
391 "firmware version %hu,\n", RADIO_FW_VERSION); 391 RADIO_FW_VERSION);
392 dev_warn(&client->dev, 392 dev_warn(&client->dev,
393 "but the device has firmware version %hu.\n", 393 "but the device has firmware version %hu.\n",
394 radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE); 394 radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE);
@@ -400,8 +400,7 @@ static int si470x_i2c_probe(struct i2c_client *client,
400 dev_warn(&client->dev, 400 dev_warn(&client->dev,
401 "If you have some trouble using this driver,\n"); 401 "If you have some trouble using this driver,\n");
402 dev_warn(&client->dev, 402 dev_warn(&client->dev,
403 "please report to V4L ML at " 403 "please report to V4L ML at linux-media@vger.kernel.org\n");
404 "linux-media@vger.kernel.org\n");
405 } 404 }
406 405
407 /* set initial frequency */ 406 /* set initial frequency */
diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c b/drivers/media/radio/si470x/radio-si470x-usb.c
index 4b132c29f290..1add136d37a3 100644
--- a/drivers/media/radio/si470x/radio-si470x-usb.c
+++ b/drivers/media/radio/si470x/radio-si470x-usb.c
@@ -351,8 +351,8 @@ static int si470x_get_scratch_page_versions(struct si470x_device *radio)
351 retval = si470x_get_report(radio, radio->usb_buf, SCRATCH_REPORT_SIZE); 351 retval = si470x_get_report(radio, radio->usb_buf, SCRATCH_REPORT_SIZE);
352 352
353 if (retval < 0) 353 if (retval < 0)
354 dev_warn(&radio->intf->dev, "si470x_get_scratch: " 354 dev_warn(&radio->intf->dev, "si470x_get_scratch: si470x_get_report returned %d\n",
355 "si470x_get_report returned %d\n", retval); 355 retval);
356 else { 356 else {
357 radio->software_version = radio->usb_buf[1]; 357 radio->software_version = radio->usb_buf[1];
358 radio->hardware_version = radio->usb_buf[2]; 358 radio->hardware_version = radio->usb_buf[2];
@@ -688,8 +688,8 @@ static int si470x_usb_driver_probe(struct usb_interface *intf,
688 radio->registers[DEVICEID], radio->registers[SI_CHIPID]); 688 radio->registers[DEVICEID], radio->registers[SI_CHIPID]);
689 if ((radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE) < RADIO_FW_VERSION) { 689 if ((radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE) < RADIO_FW_VERSION) {
690 dev_warn(&intf->dev, 690 dev_warn(&intf->dev,
691 "This driver is known to work with " 691 "This driver is known to work with firmware version %hu,\n",
692 "firmware version %hu,\n", RADIO_FW_VERSION); 692 RADIO_FW_VERSION);
693 dev_warn(&intf->dev, 693 dev_warn(&intf->dev,
694 "but the device has firmware version %hu.\n", 694 "but the device has firmware version %hu.\n",
695 radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE); 695 radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE);
@@ -705,8 +705,8 @@ static int si470x_usb_driver_probe(struct usb_interface *intf,
705 radio->software_version, radio->hardware_version); 705 radio->software_version, radio->hardware_version);
706 if (radio->hardware_version < RADIO_HW_VERSION) { 706 if (radio->hardware_version < RADIO_HW_VERSION) {
707 dev_warn(&intf->dev, 707 dev_warn(&intf->dev,
708 "This driver is known to work with " 708 "This driver is known to work with hardware version %hu,\n",
709 "hardware version %hu,\n", RADIO_HW_VERSION); 709 RADIO_HW_VERSION);
710 dev_warn(&intf->dev, 710 dev_warn(&intf->dev,
711 "but the device has hardware version %hu.\n", 711 "but the device has hardware version %hu.\n",
712 radio->hardware_version); 712 radio->hardware_version);
@@ -718,8 +718,7 @@ static int si470x_usb_driver_probe(struct usb_interface *intf,
718 dev_warn(&intf->dev, 718 dev_warn(&intf->dev,
719 "If you have some trouble using this driver,\n"); 719 "If you have some trouble using this driver,\n");
720 dev_warn(&intf->dev, 720 dev_warn(&intf->dev,
721 "please report to V4L ML at " 721 "please report to V4L ML at linux-media@vger.kernel.org\n");
722 "linux-media@vger.kernel.org\n");
723 } 722 }
724 723
725 /* set led to connect state */ 724 /* set led to connect state */
diff --git a/drivers/media/radio/si4713/si4713.c b/drivers/media/radio/si4713/si4713.c
index 0b04b56571da..bc2a8b5442ae 100644
--- a/drivers/media/radio/si4713/si4713.c
+++ b/drivers/media/radio/si4713/si4713.c
@@ -716,9 +716,9 @@ static int si4713_tx_tune_status(struct si4713_device *sdev, u8 intack,
716 *power = val[5]; 716 *power = val[5];
717 *antcap = val[6]; 717 *antcap = val[6];
718 *noise = val[7]; 718 *noise = val[7];
719 v4l2_dbg(1, debug, &sdev->sd, "%s: response: %d x 10 kHz " 719 v4l2_dbg(1, debug, &sdev->sd,
720 "(power %d, antcap %d, rnl %d)\n", __func__, 720 "%s: response: %d x 10 kHz (power %d, antcap %d, rnl %d)\n",
721 *frequency, *power, *antcap, *noise); 721 __func__, *frequency, *power, *antcap, *noise);
722 } 722 }
723 723
724 return err; 724 return err;
@@ -758,10 +758,9 @@ static int si4713_tx_rds_buff(struct si4713_device *sdev, u8 mode, u16 rdsb,
758 v4l2_dbg(1, debug, &sdev->sd, 758 v4l2_dbg(1, debug, &sdev->sd,
759 "%s: status=0x%02x\n", __func__, val[0]); 759 "%s: status=0x%02x\n", __func__, val[0]);
760 *cbleft = (s8)val[2] - val[3]; 760 *cbleft = (s8)val[2] - val[3];
761 v4l2_dbg(1, debug, &sdev->sd, "%s: response: interrupts" 761 v4l2_dbg(1, debug, &sdev->sd,
762 " 0x%02x cb avail: %d cb used %d fifo avail" 762 "%s: response: interrupts 0x%02x cb avail: %d cb used %d fifo avail %d fifo used %d\n",
763 " %d fifo used %d\n", __func__, val[1], 763 __func__, val[1], val[2], val[3], val[4], val[5]);
764 val[2], val[3], val[4], val[5]);
765 } 764 }
766 765
767 return err; 766 return err;
diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
index 642b89c66bcb..4be07656fbc0 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -212,14 +212,14 @@ inline void dump_tx_skb_data(struct sk_buff *skb)
212 212
213 len_org = skb->len - FM_CMD_MSG_HDR_SIZE; 213 len_org = skb->len - FM_CMD_MSG_HDR_SIZE;
214 if (len_org > 0) { 214 if (len_org > 0) {
215 printk("\n data(%d): ", cmd_hdr->dlen); 215 printk(KERN_CONT "\n data(%d): ", cmd_hdr->dlen);
216 len = min(len_org, 14); 216 len = min(len_org, 14);
217 for (index = 0; index < len; index++) 217 for (index = 0; index < len; index++)
218 printk("%x ", 218 printk(KERN_CONT "%x ",
219 skb->data[FM_CMD_MSG_HDR_SIZE + index]); 219 skb->data[FM_CMD_MSG_HDR_SIZE + index]);
220 printk("%s", (len_org > 14) ? ".." : ""); 220 printk(KERN_CONT "%s", (len_org > 14) ? ".." : "");
221 } 221 }
222 printk("\n"); 222 printk(KERN_CONT "\n");
223} 223}
224 224
225 /* To dump incoming FM Channel-8 packets */ 225 /* To dump incoming FM Channel-8 packets */
@@ -230,21 +230,21 @@ inline void dump_rx_skb_data(struct sk_buff *skb)
230 struct fm_event_msg_hdr *evt_hdr; 230 struct fm_event_msg_hdr *evt_hdr;
231 231
232 evt_hdr = (struct fm_event_msg_hdr *)skb->data; 232 evt_hdr = (struct fm_event_msg_hdr *)skb->data;
233 printk(KERN_INFO ">> hdr:%02x len:%02x sts:%02x numhci:%02x " 233 printk(KERN_INFO ">> hdr:%02x len:%02x sts:%02x numhci:%02x opcode:%02x type:%s dlen:%02x",
234 "opcode:%02x type:%s dlen:%02x", evt_hdr->hdr, evt_hdr->len, 234 evt_hdr->hdr, evt_hdr->len,
235 evt_hdr->status, evt_hdr->num_fm_hci_cmds, evt_hdr->op, 235 evt_hdr->status, evt_hdr->num_fm_hci_cmds, evt_hdr->op,
236 (evt_hdr->rd_wr) ? "RD" : "WR", evt_hdr->dlen); 236 (evt_hdr->rd_wr) ? "RD" : "WR", evt_hdr->dlen);
237 237
238 len_org = skb->len - FM_EVT_MSG_HDR_SIZE; 238 len_org = skb->len - FM_EVT_MSG_HDR_SIZE;
239 if (len_org > 0) { 239 if (len_org > 0) {
240 printk("\n data(%d): ", evt_hdr->dlen); 240 printk(KERN_CONT "\n data(%d): ", evt_hdr->dlen);
241 len = min(len_org, 14); 241 len = min(len_org, 14);
242 for (index = 0; index < len; index++) 242 for (index = 0; index < len; index++)
243 printk("%x ", 243 printk(KERN_CONT "%x ",
244 skb->data[FM_EVT_MSG_HDR_SIZE + index]); 244 skb->data[FM_EVT_MSG_HDR_SIZE + index]);
245 printk("%s", (len_org > 14) ? ".." : ""); 245 printk(KERN_CONT "%s", (len_org > 14) ? ".." : "");
246 } 246 }
247 printk("\n"); 247 printk(KERN_CONT "\n");
248} 248}
249#endif 249#endif
250 250
@@ -271,9 +271,9 @@ static void recv_tasklet(unsigned long arg)
271 /* Process all packets in the RX queue */ 271 /* Process all packets in the RX queue */
272 while ((skb = skb_dequeue(&fmdev->rx_q))) { 272 while ((skb = skb_dequeue(&fmdev->rx_q))) {
273 if (skb->len < sizeof(struct fm_event_msg_hdr)) { 273 if (skb->len < sizeof(struct fm_event_msg_hdr)) {
274 fmerr("skb(%p) has only %d bytes, " 274 fmerr("skb(%p) has only %d bytes, at least need %zu bytes to decode\n",
275 "at least need %zu bytes to decode\n", skb, 275 skb,
276 skb->len, sizeof(struct fm_event_msg_hdr)); 276 skb->len, sizeof(struct fm_event_msg_hdr));
277 kfree_skb(skb); 277 kfree_skb(skb);
278 continue; 278 continue;
279 } 279 }
@@ -472,8 +472,7 @@ int fmc_send_cmd(struct fmdev *fmdev, u8 fm_op, u16 type, void *payload,
472 472
473 if (!wait_for_completion_timeout(&fmdev->maintask_comp, 473 if (!wait_for_completion_timeout(&fmdev->maintask_comp,
474 FM_DRV_TX_TIMEOUT)) { 474 FM_DRV_TX_TIMEOUT)) {
475 fmerr("Timeout(%d sec),didn't get reg" 475 fmerr("Timeout(%d sec),didn't get regcompletion signal from RX tasklet\n",
476 "completion signal from RX tasklet\n",
477 jiffies_to_msecs(FM_DRV_TX_TIMEOUT) / 1000); 476 jiffies_to_msecs(FM_DRV_TX_TIMEOUT) / 1000);
478 return -ETIMEDOUT; 477 return -ETIMEDOUT;
479 } 478 }
@@ -523,8 +522,7 @@ static inline int check_cmdresp_status(struct fmdev *fmdev,
523 522
524 fm_evt_hdr = (void *)(*skb)->data; 523 fm_evt_hdr = (void *)(*skb)->data;
525 if (fm_evt_hdr->status != 0) { 524 if (fm_evt_hdr->status != 0) {
526 fmerr("irq: opcode %x response status is not zero " 525 fmerr("irq: opcode %x response status is not zero Initiating irq recovery process\n",
527 "Initiating irq recovery process\n",
528 fm_evt_hdr->op); 526 fm_evt_hdr->op);
529 527
530 mod_timer(&fmdev->irq_info.timer, jiffies + FM_DRV_TX_TIMEOUT); 528 mod_timer(&fmdev->irq_info.timer, jiffies + FM_DRV_TX_TIMEOUT);
@@ -564,8 +562,7 @@ static void int_timeout_handler(unsigned long data)
564 * reset stage index & retry count values */ 562 * reset stage index & retry count values */
565 fmirq->stage = 0; 563 fmirq->stage = 0;
566 fmirq->retry = 0; 564 fmirq->retry = 0;
567 fmerr("Recovery action failed during" 565 fmerr("Recovery action failed duringirq processing, max retry reached\n");
568 "irq processing, max retry reached\n");
569 return; 566 return;
570 } 567 }
571 fm_irq_call_stage(fmdev, FM_SEND_INTMSK_CMD_IDX); 568 fm_irq_call_stage(fmdev, FM_SEND_INTMSK_CMD_IDX);
@@ -1516,14 +1513,13 @@ int fmc_prepare(struct fmdev *fmdev)
1516 1513
1517 if (!wait_for_completion_timeout(&wait_for_fmdrv_reg_comp, 1514 if (!wait_for_completion_timeout(&wait_for_fmdrv_reg_comp,
1518 FM_ST_REG_TIMEOUT)) { 1515 FM_ST_REG_TIMEOUT)) {
1519 fmerr("Timeout(%d sec), didn't get reg " 1516 fmerr("Timeout(%d sec), didn't get reg completion signal from ST\n",
1520 "completion signal from ST\n",
1521 jiffies_to_msecs(FM_ST_REG_TIMEOUT) / 1000); 1517 jiffies_to_msecs(FM_ST_REG_TIMEOUT) / 1000);
1522 return -ETIMEDOUT; 1518 return -ETIMEDOUT;
1523 } 1519 }
1524 if (fmdev->streg_cbdata != 0) { 1520 if (fmdev->streg_cbdata != 0) {
1525 fmerr("ST reg comp CB called with error " 1521 fmerr("ST reg comp CB called with error status %d\n",
1526 "status %d\n", fmdev->streg_cbdata); 1522 fmdev->streg_cbdata);
1527 return -EAGAIN; 1523 return -EAGAIN;
1528 } 1524 }
1529 1525
diff --git a/drivers/media/radio/wl128x/fmdrv_rx.c b/drivers/media/radio/wl128x/fmdrv_rx.c
index cfaeb2417fbb..e7455f82fadc 100644
--- a/drivers/media/radio/wl128x/fmdrv_rx.c
+++ b/drivers/media/radio/wl128x/fmdrv_rx.c
@@ -120,8 +120,8 @@ int fm_rx_set_freq(struct fmdev *fmdev, u32 freq)
120 curr_frq_in_khz = (fmdev->rx.region.bot_freq + ((u32)curr_frq * FM_FREQ_MUL)); 120 curr_frq_in_khz = (fmdev->rx.region.bot_freq + ((u32)curr_frq * FM_FREQ_MUL));
121 121
122 if (curr_frq_in_khz != freq) { 122 if (curr_frq_in_khz != freq) {
123 pr_info("Frequency is set to (%d) but " 123 pr_info("Frequency is set to (%d) but requested freq is (%d)\n",
124 "requested freq is (%d)\n", curr_frq_in_khz, freq); 124 curr_frq_in_khz, freq);
125 } 125 }
126 126
127 /* Update local cache */ 127 /* Update local cache */
@@ -390,8 +390,8 @@ int fm_rx_set_region(struct fmdev *fmdev, u8 region_to_set)
390 new_frq = fmdev->rx.region.top_freq; 390 new_frq = fmdev->rx.region.top_freq;
391 391
392 if (new_frq) { 392 if (new_frq) {
393 fmdbg("Current freq is not within band limit boundary," 393 fmdbg("Current freq is not within band limit boundary,switching to %d KHz\n",
394 "switching to %d KHz\n", new_frq); 394 new_frq);
395 /* Current RX frequency is not in range. So, update it */ 395 /* Current RX frequency is not in range. So, update it */
396 ret = fm_rx_set_freq(fmdev, new_frq); 396 ret = fm_rx_set_freq(fmdev, new_frq);
397 } 397 }
diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
index 370e16e07867..629e8ca15ab3 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -389,4 +389,21 @@ config IR_SUNXI
389 To compile this driver as a module, choose M here: the module will 389 To compile this driver as a module, choose M here: the module will
390 be called sunxi-ir. 390 be called sunxi-ir.
391 391
392config IR_SERIAL
393 tristate "Homebrew Serial Port Receiver"
394 depends on RC_CORE
395 ---help---
396 Say Y if you want to use Homebrew Serial Port Receivers and
397 Transceivers.
398
399 To compile this driver as a module, choose M here: the module will
400 be called serial-ir.
401
402config IR_SERIAL_TRANSMITTER
403 bool "Serial Port Transmitter"
404 default y
405 depends on IR_SERIAL
406 ---help---
407 Serial Port Transmitter support
408
392endif #RC_DEVICES 409endif #RC_DEVICES
diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile
index 379a5c0f1379..3a984ee301e2 100644
--- a/drivers/media/rc/Makefile
+++ b/drivers/media/rc/Makefile
@@ -37,3 +37,4 @@ obj-$(CONFIG_IR_TTUSBIR) += ttusbir.o
37obj-$(CONFIG_RC_ST) += st_rc.o 37obj-$(CONFIG_RC_ST) += st_rc.o
38obj-$(CONFIG_IR_SUNXI) += sunxi-cir.o 38obj-$(CONFIG_IR_SUNXI) += sunxi-cir.o
39obj-$(CONFIG_IR_IMG) += img-ir/ 39obj-$(CONFIG_IR_IMG) += img-ir/
40obj-$(CONFIG_IR_SERIAL) += serial_ir.o
diff --git a/drivers/media/rc/ati_remote.c b/drivers/media/rc/ati_remote.c
index 9f5b59706741..0884b7dc0e71 100644
--- a/drivers/media/rc/ati_remote.c
+++ b/drivers/media/rc/ati_remote.c
@@ -527,8 +527,7 @@ static void ati_remote_input_report(struct urb *urb)
527 remote_num = (data[3] >> 4) & 0x0f; 527 remote_num = (data[3] >> 4) & 0x0f;
528 if (channel_mask & (1 << (remote_num + 1))) { 528 if (channel_mask & (1 << (remote_num + 1))) {
529 dbginfo(&ati_remote->interface->dev, 529 dbginfo(&ati_remote->interface->dev,
530 "Masked input from channel 0x%02x: data %02x, " 530 "Masked input from channel 0x%02x: data %02x, mask= 0x%02lx\n",
531 "mask= 0x%02lx\n",
532 remote_num, data[2], channel_mask); 531 remote_num, data[2], channel_mask);
533 return; 532 return;
534 } 533 }
diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c
index d1c61cd035f6..bd5512e64aea 100644
--- a/drivers/media/rc/ene_ir.c
+++ b/drivers/media/rc/ene_ir.c
@@ -1210,8 +1210,7 @@ MODULE_PARM_DESC(txsim,
1210 1210
1211MODULE_DEVICE_TABLE(pnp, ene_ids); 1211MODULE_DEVICE_TABLE(pnp, ene_ids);
1212MODULE_DESCRIPTION 1212MODULE_DESCRIPTION
1213 ("Infrared input driver for KB3926B/C/D/E/F " 1213 ("Infrared input driver for KB3926B/C/D/E/F (aka ENE0100/ENE0200/ENE0201/ENE0202) CIR port");
1214 "(aka ENE0100/ENE0200/ENE0201/ENE0202) CIR port");
1215 1214
1216MODULE_AUTHOR("Maxim Levitsky"); 1215MODULE_AUTHOR("Maxim Levitsky");
1217MODULE_LICENSE("GPL"); 1216MODULE_LICENSE("GPL");
diff --git a/drivers/media/rc/fintek-cir.c b/drivers/media/rc/fintek-cir.c
index bd7b3bdb1a88..ecab69ea3d51 100644
--- a/drivers/media/rc/fintek-cir.c
+++ b/drivers/media/rc/fintek-cir.c
@@ -104,11 +104,7 @@ static inline void fintek_cir_reg_write(struct fintek_dev *fintek, u8 val, u8 of
104/* read val from cir config register */ 104/* read val from cir config register */
105static u8 fintek_cir_reg_read(struct fintek_dev *fintek, u8 offset) 105static u8 fintek_cir_reg_read(struct fintek_dev *fintek, u8 offset)
106{ 106{
107 u8 val; 107 return inb(fintek->cir_addr + offset);
108
109 val = inb(fintek->cir_addr + offset);
110
111 return val;
112} 108}
113 109
114/* dump current cir register contents */ 110/* dump current cir register contents */
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 86cc70fe2534..0785a24af8fc 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -441,13 +441,11 @@ MODULE_PARM_DESC(debug, "Debug messages: 0=no, 1=yes (default: no)");
441/* lcd, vfd, vga or none? should be auto-detected, but can be overridden... */ 441/* lcd, vfd, vga or none? should be auto-detected, but can be overridden... */
442static int display_type; 442static int display_type;
443module_param(display_type, int, S_IRUGO); 443module_param(display_type, int, S_IRUGO);
444MODULE_PARM_DESC(display_type, "Type of attached display. 0=autodetect, " 444MODULE_PARM_DESC(display_type, "Type of attached display. 0=autodetect, 1=vfd, 2=lcd, 3=vga, 4=none (default: autodetect)");
445 "1=vfd, 2=lcd, 3=vga, 4=none (default: autodetect)");
446 445
447static int pad_stabilize = 1; 446static int pad_stabilize = 1;
448module_param(pad_stabilize, int, S_IRUGO | S_IWUSR); 447module_param(pad_stabilize, int, S_IRUGO | S_IWUSR);
449MODULE_PARM_DESC(pad_stabilize, "Apply stabilization algorithm to iMON PAD " 448MODULE_PARM_DESC(pad_stabilize, "Apply stabilization algorithm to iMON PAD presses in arrow key mode. 0=disable, 1=enable (default).");
450 "presses in arrow key mode. 0=disable, 1=enable (default).");
451 449
452/* 450/*
453 * In certain use cases, mouse mode isn't really helpful, and could actually 451 * In certain use cases, mouse mode isn't really helpful, and could actually
@@ -455,14 +453,12 @@ MODULE_PARM_DESC(pad_stabilize, "Apply stabilization algorithm to iMON PAD "
455 */ 453 */
456static bool nomouse; 454static bool nomouse;
457module_param(nomouse, bool, S_IRUGO | S_IWUSR); 455module_param(nomouse, bool, S_IRUGO | S_IWUSR);
458MODULE_PARM_DESC(nomouse, "Disable mouse input device mode when IR device is " 456MODULE_PARM_DESC(nomouse, "Disable mouse input device mode when IR device is open. 0=don't disable, 1=disable. (default: don't disable)");
459 "open. 0=don't disable, 1=disable. (default: don't disable)");
460 457
461/* threshold at which a pad push registers as an arrow key in kbd mode */ 458/* threshold at which a pad push registers as an arrow key in kbd mode */
462static int pad_thresh; 459static int pad_thresh;
463module_param(pad_thresh, int, S_IRUGO | S_IWUSR); 460module_param(pad_thresh, int, S_IRUGO | S_IWUSR);
464MODULE_PARM_DESC(pad_thresh, "Threshold at which a pad push registers as an " 461MODULE_PARM_DESC(pad_thresh, "Threshold at which a pad push registers as an arrow key in kbd mode (default: 28)");
465 "arrow key in kbd mode (default: 28)");
466 462
467 463
468static void free_imon_context(struct imon_context *ictx) 464static void free_imon_context(struct imon_context *ictx)
@@ -611,7 +607,7 @@ static int send_packet(struct imon_context *ictx)
611 ictx->tx_urb->actual_length = 0; 607 ictx->tx_urb->actual_length = 0;
612 } 608 }
613 609
614 init_completion(&ictx->tx.finished); 610 reinit_completion(&ictx->tx.finished);
615 ictx->tx.busy = true; 611 ictx->tx.busy = true;
616 smp_rmb(); /* ensure later readers know we're busy */ 612 smp_rmb(); /* ensure later readers know we're busy */
617 613
@@ -785,9 +781,7 @@ static ssize_t show_associate_remote(struct device *d,
785 else 781 else
786 strcpy(buf, "closed\n"); 782 strcpy(buf, "closed\n");
787 783
788 dev_info(d, "Visit http://www.lirc.org/html/imon-24g.html for " 784 dev_info(d, "Visit http://www.lirc.org/html/imon-24g.html for instructions on how to associate your iMON 2.4G DT/LT remote\n");
789 "instructions on how to associate your iMON 2.4G DT/LT "
790 "remote\n");
791 mutex_unlock(&ictx->lock); 785 mutex_unlock(&ictx->lock);
792 return strlen(buf); 786 return strlen(buf);
793} 787}
@@ -1115,8 +1109,7 @@ static int imon_ir_change_protocol(struct rc_dev *rc, u64 *rc_type)
1115 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 }; 1109 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 };
1116 1110
1117 if (*rc_type && !(*rc_type & rc->allowed_protocols)) 1111 if (*rc_type && !(*rc_type & rc->allowed_protocols))
1118 dev_warn(dev, "Looks like you're trying to use an IR protocol " 1112 dev_warn(dev, "Looks like you're trying to use an IR protocol this device does not support\n");
1119 "this device does not support\n");
1120 1113
1121 if (*rc_type & RC_BIT_RC6_MCE) { 1114 if (*rc_type & RC_BIT_RC6_MCE) {
1122 dev_dbg(dev, "Configuring IR receiver for MCE protocol\n"); 1115 dev_dbg(dev, "Configuring IR receiver for MCE protocol\n");
@@ -1129,8 +1122,7 @@ static int imon_ir_change_protocol(struct rc_dev *rc, u64 *rc_type)
1129 /* ir_proto_packet[0] = 0x00; // already the default */ 1122 /* ir_proto_packet[0] = 0x00; // already the default */
1130 *rc_type = RC_BIT_OTHER; 1123 *rc_type = RC_BIT_OTHER;
1131 } else { 1124 } else {
1132 dev_warn(dev, "Unsupported IR protocol specified, overriding " 1125 dev_warn(dev, "Unsupported IR protocol specified, overriding to iMON IR protocol\n");
1133 "to iMON IR protocol\n");
1134 if (!pad_stabilize) 1126 if (!pad_stabilize)
1135 dev_dbg(dev, "PAD stabilize functionality disabled\n"); 1127 dev_dbg(dev, "PAD stabilize functionality disabled\n");
1136 /* ir_proto_packet[0] = 0x00; // already the default */ 1128 /* ir_proto_packet[0] = 0x00; // already the default */
@@ -1593,7 +1585,6 @@ static void imon_incoming_packet(struct imon_context *ictx,
1593 struct device *dev = ictx->dev; 1585 struct device *dev = ictx->dev;
1594 unsigned long flags; 1586 unsigned long flags;
1595 u32 kc; 1587 u32 kc;
1596 int i;
1597 u64 scancode; 1588 u64 scancode;
1598 int press_type = 0; 1589 int press_type = 0;
1599 int msec; 1590 int msec;
@@ -1664,10 +1655,8 @@ static void imon_incoming_packet(struct imon_context *ictx,
1664 } 1655 }
1665 1656
1666 if (debug) { 1657 if (debug) {
1667 printk(KERN_INFO "intf%d decoded packet: ", intf); 1658 printk(KERN_INFO "intf%d decoded packet: %*ph\n",
1668 for (i = 0; i < len; ++i) 1659 intf, len, buf);
1669 printk("%02x ", buf[i]);
1670 printk("\n");
1671 } 1660 }
1672 1661
1673 press_type = imon_parse_press_type(ictx, buf, ktype); 1662 press_type = imon_parse_press_type(ictx, buf, ktype);
@@ -1722,8 +1711,8 @@ static void imon_incoming_packet(struct imon_context *ictx,
1722 1711
1723not_input_data: 1712not_input_data:
1724 if (len != 8) { 1713 if (len != 8) {
1725 dev_warn(dev, "imon %s: invalid incoming packet " 1714 dev_warn(dev, "imon %s: invalid incoming packet size (len = %d, intf%d)\n",
1726 "size (len = %d, intf%d)\n", __func__, len, intf); 1715 __func__, len, intf);
1727 return; 1716 return;
1728 } 1717 }
1729 1718
@@ -1879,8 +1868,7 @@ static void imon_get_ffdc_type(struct imon_context *ictx)
1879 allowed_protos = RC_BIT_RC6_MCE; 1868 allowed_protos = RC_BIT_RC6_MCE;
1880 break; 1869 break;
1881 default: 1870 default:
1882 dev_info(ictx->dev, "Unknown 0xffdc device, " 1871 dev_info(ictx->dev, "Unknown 0xffdc device, defaulting to VFD and iMON IR");
1883 "defaulting to VFD and iMON IR");
1884 detected_display_type = IMON_DISPLAY_TYPE_VFD; 1872 detected_display_type = IMON_DISPLAY_TYPE_VFD;
1885 /* We don't know which one it is, allow user to set the 1873 /* We don't know which one it is, allow user to set the
1886 * RC6 one from userspace if OTHER wasn't correct. */ 1874 * RC6 one from userspace if OTHER wasn't correct. */
@@ -1937,8 +1925,8 @@ static void imon_set_display_type(struct imon_context *ictx)
1937 ictx->display_supported = false; 1925 ictx->display_supported = false;
1938 else 1926 else
1939 ictx->display_supported = true; 1927 ictx->display_supported = true;
1940 dev_info(ictx->dev, "%s: overriding display type to %d via " 1928 dev_info(ictx->dev, "%s: overriding display type to %d via modparam\n",
1941 "modparam\n", __func__, display_type); 1929 __func__, display_type);
1942 } 1930 }
1943 1931
1944 ictx->display_type = configured_display_type; 1932 ictx->display_type = configured_display_type;
@@ -2159,8 +2147,8 @@ static bool imon_find_endpoints(struct imon_context *ictx,
2159 if (!display_ep_found) { 2147 if (!display_ep_found) {
2160 tx_control = true; 2148 tx_control = true;
2161 display_ep_found = true; 2149 display_ep_found = true;
2162 dev_dbg(ictx->dev, "%s: device uses control endpoint, not " 2150 dev_dbg(ictx->dev, "%s: device uses control endpoint, not interface OUT endpoint\n",
2163 "interface OUT endpoint\n", __func__); 2151 __func__);
2164 } 2152 }
2165 2153
2166 /* 2154 /*
@@ -2228,6 +2216,8 @@ static struct imon_context *imon_init_intf0(struct usb_interface *intf,
2228 ictx->tx_urb = tx_urb; 2216 ictx->tx_urb = tx_urb;
2229 ictx->rf_device = false; 2217 ictx->rf_device = false;
2230 2218
2219 init_completion(&ictx->tx.finished);
2220
2231 ictx->vendor = le16_to_cpu(ictx->usbdev_intf0->descriptor.idVendor); 2221 ictx->vendor = le16_to_cpu(ictx->usbdev_intf0->descriptor.idVendor);
2232 ictx->product = le16_to_cpu(ictx->usbdev_intf0->descriptor.idProduct); 2222 ictx->product = le16_to_cpu(ictx->usbdev_intf0->descriptor.idProduct);
2233 2223
@@ -2369,8 +2359,8 @@ static void imon_init_display(struct imon_context *ictx,
2369 /* set up sysfs entry for built-in clock */ 2359 /* set up sysfs entry for built-in clock */
2370 ret = sysfs_create_group(&intf->dev.kobj, &imon_display_attr_group); 2360 ret = sysfs_create_group(&intf->dev.kobj, &imon_display_attr_group);
2371 if (ret) 2361 if (ret)
2372 dev_err(ictx->dev, "Could not create display sysfs " 2362 dev_err(ictx->dev, "Could not create display sysfs entries(%d)",
2373 "entries(%d)", ret); 2363 ret);
2374 2364
2375 if (ictx->display_type == IMON_DISPLAY_TYPE_LCD) 2365 if (ictx->display_type == IMON_DISPLAY_TYPE_LCD)
2376 ret = usb_register_dev(intf, &imon_lcd_class); 2366 ret = usb_register_dev(intf, &imon_lcd_class);
@@ -2378,8 +2368,7 @@ static void imon_init_display(struct imon_context *ictx,
2378 ret = usb_register_dev(intf, &imon_vfd_class); 2368 ret = usb_register_dev(intf, &imon_vfd_class);
2379 if (ret) 2369 if (ret)
2380 /* Not a fatal error, so ignore */ 2370 /* Not a fatal error, so ignore */
2381 dev_info(ictx->dev, "could not get a minor number for " 2371 dev_info(ictx->dev, "could not get a minor number for display\n");
2382 "display\n");
2383 2372
2384} 2373}
2385 2374
@@ -2459,8 +2448,8 @@ static int imon_probe(struct usb_interface *interface,
2459 mutex_unlock(&ictx->lock); 2448 mutex_unlock(&ictx->lock);
2460 } 2449 }
2461 2450
2462 dev_info(dev, "iMON device (%04x:%04x, intf%d) on " 2451 dev_info(dev, "iMON device (%04x:%04x, intf%d) on usb<%d:%d> initialized\n",
2463 "usb<%d:%d> initialized\n", vendor, product, ifnum, 2452 vendor, product, ifnum,
2464 usbdev->bus->busnum, usbdev->devnum); 2453 usbdev->bus->busnum, usbdev->devnum);
2465 2454
2466 mutex_unlock(&driver_lock); 2455 mutex_unlock(&driver_lock);
@@ -2504,7 +2493,7 @@ static void imon_disconnect(struct usb_interface *interface)
2504 /* Abort ongoing write */ 2493 /* Abort ongoing write */
2505 if (ictx->tx.busy) { 2494 if (ictx->tx.busy) {
2506 usb_kill_urb(ictx->tx_urb); 2495 usb_kill_urb(ictx->tx_urb);
2507 complete_all(&ictx->tx.finished); 2496 complete(&ictx->tx.finished);
2508 } 2497 }
2509 2498
2510 if (ifnum == 0) { 2499 if (ifnum == 0) {
diff --git a/drivers/media/rc/ir-hix5hd2.c b/drivers/media/rc/ir-hix5hd2.c
index d0549fba711c..d26907e684dc 100644
--- a/drivers/media/rc/ir-hix5hd2.c
+++ b/drivers/media/rc/ir-hix5hd2.c
@@ -75,15 +75,22 @@ static void hix5hd2_ir_enable(struct hix5hd2_ir_priv *dev, bool on)
75{ 75{
76 u32 val; 76 u32 val;
77 77
78 regmap_read(dev->regmap, IR_CLK, &val); 78 if (dev->regmap) {
79 if (on) { 79 regmap_read(dev->regmap, IR_CLK, &val);
80 val &= ~IR_CLK_RESET; 80 if (on) {
81 val |= IR_CLK_ENABLE; 81 val &= ~IR_CLK_RESET;
82 val |= IR_CLK_ENABLE;
83 } else {
84 val &= ~IR_CLK_ENABLE;
85 val |= IR_CLK_RESET;
86 }
87 regmap_write(dev->regmap, IR_CLK, val);
82 } else { 88 } else {
83 val &= ~IR_CLK_ENABLE; 89 if (on)
84 val |= IR_CLK_RESET; 90 clk_prepare_enable(dev->clock);
91 else
92 clk_disable_unprepare(dev->clock);
85 } 93 }
86 regmap_write(dev->regmap, IR_CLK, val);
87} 94}
88 95
89static int hix5hd2_ir_config(struct hix5hd2_ir_priv *priv) 96static int hix5hd2_ir_config(struct hix5hd2_ir_priv *priv)
@@ -207,8 +214,8 @@ static int hix5hd2_ir_probe(struct platform_device *pdev)
207 priv->regmap = syscon_regmap_lookup_by_phandle(node, 214 priv->regmap = syscon_regmap_lookup_by_phandle(node,
208 "hisilicon,power-syscon"); 215 "hisilicon,power-syscon");
209 if (IS_ERR(priv->regmap)) { 216 if (IS_ERR(priv->regmap)) {
210 dev_err(dev, "no power-reg\n"); 217 dev_info(dev, "no power-reg\n");
211 return -EINVAL; 218 priv->regmap = NULL;
212 } 219 }
213 220
214 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 221 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/drivers/media/rc/ir-sanyo-decoder.c b/drivers/media/rc/ir-sanyo-decoder.c
index 7331e5e7c497..b07d9caebeb1 100644
--- a/drivers/media/rc/ir-sanyo-decoder.c
+++ b/drivers/media/rc/ir-sanyo-decoder.c
@@ -56,7 +56,8 @@ static int ir_sanyo_decode(struct rc_dev *dev, struct ir_raw_event ev)
56{ 56{
57 struct sanyo_dec *data = &dev->raw->sanyo; 57 struct sanyo_dec *data = &dev->raw->sanyo;
58 u32 scancode; 58 u32 scancode;
59 u8 address, command, not_command; 59 u16 address;
60 u8 command, not_command;
60 61
61 if (!is_timing_event(ev)) { 62 if (!is_timing_event(ev)) {
62 if (ev.reset) { 63 if (ev.reset) {
diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c
index 0f301903aa6f..367b28bed627 100644
--- a/drivers/media/rc/ite-cir.c
+++ b/drivers/media/rc/ite-cir.c
@@ -55,14 +55,12 @@ MODULE_PARM_DESC(debug, "Enable debugging output");
55/* low limit for RX carrier freq, Hz, 0 for no RX demodulation */ 55/* low limit for RX carrier freq, Hz, 0 for no RX demodulation */
56static int rx_low_carrier_freq; 56static int rx_low_carrier_freq;
57module_param(rx_low_carrier_freq, int, S_IRUGO | S_IWUSR); 57module_param(rx_low_carrier_freq, int, S_IRUGO | S_IWUSR);
58MODULE_PARM_DESC(rx_low_carrier_freq, "Override low RX carrier frequency, Hz, " 58MODULE_PARM_DESC(rx_low_carrier_freq, "Override low RX carrier frequency, Hz, 0 for no RX demodulation");
59 "0 for no RX demodulation");
60 59
61/* high limit for RX carrier freq, Hz, 0 for no RX demodulation */ 60/* high limit for RX carrier freq, Hz, 0 for no RX demodulation */
62static int rx_high_carrier_freq; 61static int rx_high_carrier_freq;
63module_param(rx_high_carrier_freq, int, S_IRUGO | S_IWUSR); 62module_param(rx_high_carrier_freq, int, S_IRUGO | S_IWUSR);
64MODULE_PARM_DESC(rx_high_carrier_freq, "Override high RX carrier frequency, " 63MODULE_PARM_DESC(rx_high_carrier_freq, "Override high RX carrier frequency, Hz, 0 for no RX demodulation");
65 "Hz, 0 for no RX demodulation");
66 64
67/* override tx carrier frequency */ 65/* override tx carrier frequency */
68static int tx_carrier_freq; 66static int tx_carrier_freq;
@@ -263,6 +261,8 @@ static void ite_set_carrier_params(struct ite_dev *dev)
263 261
264 if (allowance > ITE_RXDCR_MAX) 262 if (allowance > ITE_RXDCR_MAX)
265 allowance = ITE_RXDCR_MAX; 263 allowance = ITE_RXDCR_MAX;
264
265 use_demodulator = true;
266 } 266 }
267 } 267 }
268 268
@@ -1484,8 +1484,7 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
1484 1484
1485 if (model_number >= 0 && model_number < ARRAY_SIZE(ite_dev_descs)) { 1485 if (model_number >= 0 && model_number < ARRAY_SIZE(ite_dev_descs)) {
1486 model_no = model_number; 1486 model_no = model_number;
1487 ite_pr(KERN_NOTICE, "The model has been fixed by a module " 1487 ite_pr(KERN_NOTICE, "The model has been fixed by a module parameter.");
1488 "parameter.");
1489 } 1488 }
1490 1489
1491 ite_pr(KERN_NOTICE, "Using model: %s\n", ite_dev_descs[model_no].model); 1490 ite_pr(KERN_NOTICE, "Using model: %s\n", ite_dev_descs[model_no].model);
diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
index 91f9bb87ce68..3854809e8531 100644
--- a/drivers/media/rc/lirc_dev.c
+++ b/drivers/media/rc/lirc_dev.c
@@ -150,9 +150,6 @@ static const struct file_operations lirc_dev_fops = {
150 .write = lirc_dev_fop_write, 150 .write = lirc_dev_fop_write,
151 .poll = lirc_dev_fop_poll, 151 .poll = lirc_dev_fop_poll,
152 .unlocked_ioctl = lirc_dev_fop_ioctl, 152 .unlocked_ioctl = lirc_dev_fop_ioctl,
153#ifdef CONFIG_COMPAT
154 .compat_ioctl = lirc_dev_fop_ioctl,
155#endif
156 .open = lirc_dev_fop_open, 153 .open = lirc_dev_fop_open,
157 .release = lirc_dev_fop_close, 154 .release = lirc_dev_fop_close,
158 .llseek = noop_llseek, 155 .llseek = noop_llseek,
@@ -160,19 +157,19 @@ static const struct file_operations lirc_dev_fops = {
160 157
161static int lirc_cdev_add(struct irctl *ir) 158static int lirc_cdev_add(struct irctl *ir)
162{ 159{
163 int retval = -ENOMEM;
164 struct lirc_driver *d = &ir->d; 160 struct lirc_driver *d = &ir->d;
165 struct cdev *cdev; 161 struct cdev *cdev;
162 int retval;
166 163
167 cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); 164 cdev = cdev_alloc();
168 if (!cdev) 165 if (!cdev)
169 goto err_out; 166 return -ENOMEM;
170 167
171 if (d->fops) { 168 if (d->fops) {
172 cdev_init(cdev, d->fops); 169 cdev->ops = d->fops;
173 cdev->owner = d->owner; 170 cdev->owner = d->owner;
174 } else { 171 } else {
175 cdev_init(cdev, &lirc_dev_fops); 172 cdev->ops = &lirc_dev_fops;
176 cdev->owner = THIS_MODULE; 173 cdev->owner = THIS_MODULE;
177 } 174 }
178 retval = kobject_set_name(&cdev->kobj, "lirc%d", d->minor); 175 retval = kobject_set_name(&cdev->kobj, "lirc%d", d->minor);
@@ -180,17 +177,15 @@ static int lirc_cdev_add(struct irctl *ir)
180 goto err_out; 177 goto err_out;
181 178
182 retval = cdev_add(cdev, MKDEV(MAJOR(lirc_base_dev), d->minor), 1); 179 retval = cdev_add(cdev, MKDEV(MAJOR(lirc_base_dev), d->minor), 1);
183 if (retval) { 180 if (retval)
184 kobject_put(&cdev->kobj);
185 goto err_out; 181 goto err_out;
186 }
187 182
188 ir->cdev = cdev; 183 ir->cdev = cdev;
189 184
190 return 0; 185 return 0;
191 186
192err_out: 187err_out:
193 kfree(cdev); 188 cdev_del(cdev);
194 return retval; 189 return retval;
195} 190}
196 191
@@ -420,7 +415,6 @@ int lirc_unregister_driver(int minor)
420 } else { 415 } else {
421 lirc_irctl_cleanup(ir); 416 lirc_irctl_cleanup(ir);
422 cdev_del(cdev); 417 cdev_del(cdev);
423 kfree(cdev);
424 kfree(ir); 418 kfree(ir);
425 irctls[minor] = NULL; 419 irctls[minor] = NULL;
426 } 420 }
@@ -521,7 +515,6 @@ int lirc_dev_fop_close(struct inode *inode, struct file *file)
521 lirc_irctl_cleanup(ir); 515 lirc_irctl_cleanup(ir);
522 cdev_del(cdev); 516 cdev_del(cdev);
523 irctls[ir->d.minor] = NULL; 517 irctls[ir->d.minor] = NULL;
524 kfree(cdev);
525 kfree(ir); 518 kfree(ir);
526 } 519 }
527 520
@@ -684,7 +677,6 @@ ssize_t lirc_dev_fop_read(struct file *file,
684 * between while condition checking and scheduling) 677 * between while condition checking and scheduling)
685 */ 678 */
686 add_wait_queue(&ir->buf->wait_poll, &wait); 679 add_wait_queue(&ir->buf->wait_poll, &wait);
687 set_current_state(TASK_INTERRUPTIBLE);
688 680
689 /* 681 /*
690 * while we didn't provide 'length' bytes, device is opened in blocking 682 * while we didn't provide 'length' bytes, device is opened in blocking
@@ -709,19 +701,19 @@ ssize_t lirc_dev_fop_read(struct file *file,
709 } 701 }
710 702
711 mutex_unlock(&ir->irctl_lock); 703 mutex_unlock(&ir->irctl_lock);
712 schedule();
713 set_current_state(TASK_INTERRUPTIBLE); 704 set_current_state(TASK_INTERRUPTIBLE);
705 schedule();
706 set_current_state(TASK_RUNNING);
714 707
715 if (mutex_lock_interruptible(&ir->irctl_lock)) { 708 if (mutex_lock_interruptible(&ir->irctl_lock)) {
716 ret = -ERESTARTSYS; 709 ret = -ERESTARTSYS;
717 remove_wait_queue(&ir->buf->wait_poll, &wait); 710 remove_wait_queue(&ir->buf->wait_poll, &wait);
718 set_current_state(TASK_RUNNING);
719 goto out_unlocked; 711 goto out_unlocked;
720 } 712 }
721 713
722 if (!ir->attached) { 714 if (!ir->attached) {
723 ret = -ENODEV; 715 ret = -ENODEV;
724 break; 716 goto out_locked;
725 } 717 }
726 } else { 718 } else {
727 lirc_buffer_read(ir->buf, buf); 719 lirc_buffer_read(ir->buf, buf);
@@ -735,7 +727,6 @@ ssize_t lirc_dev_fop_read(struct file *file,
735 } 727 }
736 728
737 remove_wait_queue(&ir->buf->wait_poll, &wait); 729 remove_wait_queue(&ir->buf->wait_poll, &wait);
738 set_current_state(TASK_RUNNING);
739 730
740out_locked: 731out_locked:
741 mutex_unlock(&ir->irctl_lock); 732 mutex_unlock(&ir->irctl_lock);
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index 4f8c7effdcee..9bf69179eee0 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -153,15 +153,6 @@
153#define MCE_COMMAND_IRDATA 0x80 153#define MCE_COMMAND_IRDATA 0x80
154#define MCE_PACKET_LENGTH_MASK 0x1f /* Packet length mask */ 154#define MCE_PACKET_LENGTH_MASK 0x1f /* Packet length mask */
155 155
156/* general constants */
157#define SEND_FLAG_IN_PROGRESS 1
158#define SEND_FLAG_COMPLETE 2
159#define RECV_FLAG_IN_PROGRESS 3
160#define RECV_FLAG_COMPLETE 4
161
162#define MCEUSB_RX 1
163#define MCEUSB_TX 2
164
165#define VENDOR_PHILIPS 0x0471 156#define VENDOR_PHILIPS 0x0471
166#define VENDOR_SMK 0x0609 157#define VENDOR_SMK 0x0609
167#define VENDOR_TATUNG 0x1460 158#define VENDOR_TATUNG 0x1460
@@ -422,7 +413,6 @@ struct mceusb_dev {
422 struct rc_dev *rc; 413 struct rc_dev *rc;
423 414
424 /* optional features we can enable */ 415 /* optional features we can enable */
425 bool carrier_report_enabled;
426 bool learning_enabled; 416 bool learning_enabled;
427 417
428 /* core device bits */ 418 /* core device bits */
@@ -455,7 +445,6 @@ struct mceusb_dev {
455 } flags; 445 } flags;
456 446
457 /* transmit support */ 447 /* transmit support */
458 int send_flags;
459 u32 carrier; 448 u32 carrier;
460 unsigned char tx_mask; 449 unsigned char tx_mask;
461 450
@@ -604,9 +593,7 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf,
604 break; 593 break;
605 case MCE_RSP_EQWAKEVERSION: 594 case MCE_RSP_EQWAKEVERSION:
606 if (!out) 595 if (!out)
607 dev_dbg(dev, "Wake version, proto: 0x%02x, " 596 dev_dbg(dev, "Wake version, proto: 0x%02x, payload: 0x%02x, address: 0x%02x, version: 0x%02x",
608 "payload: 0x%02x, address: 0x%02x, "
609 "version: 0x%02x",
610 data1, data2, data3, data4); 597 data1, data2, data3, data4);
611 break; 598 break;
612 case MCE_RSP_GETPORTSTATUS: 599 case MCE_RSP_GETPORTSTATUS:
@@ -740,52 +727,40 @@ static void mce_async_callback(struct urb *urb)
740 727
741/* request incoming or send outgoing usb packet - used to initialize remote */ 728/* request incoming or send outgoing usb packet - used to initialize remote */
742static void mce_request_packet(struct mceusb_dev *ir, unsigned char *data, 729static void mce_request_packet(struct mceusb_dev *ir, unsigned char *data,
743 int size, int urb_type) 730 int size)
744{ 731{
745 int res, pipe; 732 int res, pipe;
746 struct urb *async_urb; 733 struct urb *async_urb;
747 struct device *dev = ir->dev; 734 struct device *dev = ir->dev;
748 unsigned char *async_buf; 735 unsigned char *async_buf;
749 736
750 if (urb_type == MCEUSB_TX) { 737 async_urb = usb_alloc_urb(0, GFP_KERNEL);
751 async_urb = usb_alloc_urb(0, GFP_KERNEL); 738 if (unlikely(!async_urb)) {
752 if (unlikely(!async_urb)) { 739 dev_err(dev, "Error, couldn't allocate urb!\n");
753 dev_err(dev, "Error, couldn't allocate urb!\n"); 740 return;
754 return; 741 }
755 }
756
757 async_buf = kzalloc(size, GFP_KERNEL);
758 if (!async_buf) {
759 dev_err(dev, "Error, couldn't allocate buf!\n");
760 usb_free_urb(async_urb);
761 return;
762 }
763
764 /* outbound data */
765 if (usb_endpoint_xfer_int(ir->usb_ep_out)) {
766 pipe = usb_sndintpipe(ir->usbdev,
767 ir->usb_ep_out->bEndpointAddress);
768 usb_fill_int_urb(async_urb, ir->usbdev, pipe, async_buf,
769 size, mce_async_callback, ir,
770 ir->usb_ep_out->bInterval);
771 } else {
772 pipe = usb_sndbulkpipe(ir->usbdev,
773 ir->usb_ep_out->bEndpointAddress);
774 usb_fill_bulk_urb(async_urb, ir->usbdev, pipe,
775 async_buf, size, mce_async_callback,
776 ir);
777 }
778 memcpy(async_buf, data, size);
779 742
780 } else if (urb_type == MCEUSB_RX) { 743 async_buf = kmalloc(size, GFP_KERNEL);
781 /* standard request */ 744 if (!async_buf) {
782 async_urb = ir->urb_in; 745 usb_free_urb(async_urb);
783 ir->send_flags = RECV_FLAG_IN_PROGRESS; 746 return;
747 }
784 748
749 /* outbound data */
750 if (usb_endpoint_xfer_int(ir->usb_ep_out)) {
751 pipe = usb_sndintpipe(ir->usbdev,
752 ir->usb_ep_out->bEndpointAddress);
753 usb_fill_int_urb(async_urb, ir->usbdev, pipe, async_buf,
754 size, mce_async_callback, ir,
755 ir->usb_ep_out->bInterval);
785 } else { 756 } else {
786 dev_err(dev, "Error! Unknown urb type %d\n", urb_type); 757 pipe = usb_sndbulkpipe(ir->usbdev,
787 return; 758 ir->usb_ep_out->bEndpointAddress);
759 usb_fill_bulk_urb(async_urb, ir->usbdev, pipe,
760 async_buf, size, mce_async_callback,
761 ir);
788 } 762 }
763 memcpy(async_buf, data, size);
789 764
790 dev_dbg(dev, "receive request called (size=%#x)", size); 765 dev_dbg(dev, "receive request called (size=%#x)", size);
791 766
@@ -806,19 +781,14 @@ static void mce_async_out(struct mceusb_dev *ir, unsigned char *data, int size)
806 781
807 if (ir->need_reset) { 782 if (ir->need_reset) {
808 ir->need_reset = false; 783 ir->need_reset = false;
809 mce_request_packet(ir, DEVICE_RESUME, rsize, MCEUSB_TX); 784 mce_request_packet(ir, DEVICE_RESUME, rsize);
810 msleep(10); 785 msleep(10);
811 } 786 }
812 787
813 mce_request_packet(ir, data, size, MCEUSB_TX); 788 mce_request_packet(ir, data, size);
814 msleep(10); 789 msleep(10);
815} 790}
816 791
817static void mce_flush_rx_buffer(struct mceusb_dev *ir, int size)
818{
819 mce_request_packet(ir, NULL, size, MCEUSB_RX);
820}
821
822/* Send data out the IR blaster port(s) */ 792/* Send data out the IR blaster port(s) */
823static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count) 793static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count)
824{ 794{
@@ -1062,7 +1032,6 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)
1062static void mceusb_dev_recv(struct urb *urb) 1032static void mceusb_dev_recv(struct urb *urb)
1063{ 1033{
1064 struct mceusb_dev *ir; 1034 struct mceusb_dev *ir;
1065 int buf_len;
1066 1035
1067 if (!urb) 1036 if (!urb)
1068 return; 1037 return;
@@ -1073,18 +1042,10 @@ static void mceusb_dev_recv(struct urb *urb)
1073 return; 1042 return;
1074 } 1043 }
1075 1044
1076 buf_len = urb->actual_length;
1077
1078 if (ir->send_flags == RECV_FLAG_IN_PROGRESS) {
1079 ir->send_flags = SEND_FLAG_COMPLETE;
1080 dev_dbg(ir->dev, "setup answer received %d bytes\n",
1081 buf_len);
1082 }
1083
1084 switch (urb->status) { 1045 switch (urb->status) {
1085 /* success */ 1046 /* success */
1086 case 0: 1047 case 0:
1087 mceusb_process_ir_data(ir, buf_len); 1048 mceusb_process_ir_data(ir, urb->actual_length);
1088 break; 1049 break;
1089 1050
1090 case -ECONNRESET: 1051 case -ECONNRESET:
@@ -1285,7 +1246,7 @@ static int mceusb_dev_probe(struct usb_interface *intf,
1285 struct usb_endpoint_descriptor *ep_in = NULL; 1246 struct usb_endpoint_descriptor *ep_in = NULL;
1286 struct usb_endpoint_descriptor *ep_out = NULL; 1247 struct usb_endpoint_descriptor *ep_out = NULL;
1287 struct mceusb_dev *ir = NULL; 1248 struct mceusb_dev *ir = NULL;
1288 int pipe, maxp, i; 1249 int pipe, maxp, i, res;
1289 char buf[63], name[128] = ""; 1250 char buf[63], name[128] = "";
1290 enum mceusb_model_type model = id->driver_info; 1251 enum mceusb_model_type model = id->driver_info;
1291 bool is_gen3; 1252 bool is_gen3;
@@ -1388,7 +1349,9 @@ static int mceusb_dev_probe(struct usb_interface *intf,
1388 1349
1389 /* flush buffers on the device */ 1350 /* flush buffers on the device */
1390 dev_dbg(&intf->dev, "Flushing receive buffers\n"); 1351 dev_dbg(&intf->dev, "Flushing receive buffers\n");
1391 mce_flush_rx_buffer(ir, maxp); 1352 res = usb_submit_urb(ir->urb_in, GFP_KERNEL);
1353 if (res)
1354 dev_err(&intf->dev, "failed to flush buffers: %d\n", res);
1392 1355
1393 /* figure out which firmware/emulator version this hardware has */ 1356 /* figure out which firmware/emulator version this hardware has */
1394 mceusb_get_emulator_version(ir); 1357 mceusb_get_emulator_version(ir);
@@ -1423,6 +1386,7 @@ static int mceusb_dev_probe(struct usb_interface *intf,
1423 /* Error-handling path */ 1386 /* Error-handling path */
1424rc_dev_fail: 1387rc_dev_fail:
1425 usb_put_dev(ir->usbdev); 1388 usb_put_dev(ir->usbdev);
1389 usb_kill_urb(ir->urb_in);
1426 usb_free_urb(ir->urb_in); 1390 usb_free_urb(ir->urb_in);
1427urb_in_alloc_fail: 1391urb_in_alloc_fail:
1428 usb_free_coherent(dev, maxp, ir->buf_in, ir->dma_in); 1392 usb_free_coherent(dev, maxp, ir->buf_in, ir->dma_in);
diff --git a/drivers/media/rc/meson-ir.c b/drivers/media/rc/meson-ir.c
index 003fff07ade2..7eb3f4f1ddcd 100644
--- a/drivers/media/rc/meson-ir.c
+++ b/drivers/media/rc/meson-ir.c
@@ -218,6 +218,7 @@ static const struct of_device_id meson_ir_match[] = {
218 { .compatible = "amlogic,meson-gxbb-ir" }, 218 { .compatible = "amlogic,meson-gxbb-ir" },
219 { }, 219 { },
220}; 220};
221MODULE_DEVICE_TABLE(of, meson_ir_match);
221 222
222static struct platform_driver meson_ir_driver = { 223static struct platform_driver meson_ir_driver = {
223 .probe = meson_ir_probe, 224 .probe = meson_ir_probe,
diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
index 04fedaa75612..4b78c891eb77 100644
--- a/drivers/media/rc/nuvoton-cir.c
+++ b/drivers/media/rc/nuvoton-cir.c
@@ -48,6 +48,11 @@ static const struct nvt_chip nvt_chips[] = {
48 { "NCT6779D", NVT_6779D }, 48 { "NCT6779D", NVT_6779D },
49}; 49};
50 50
51static inline struct device *nvt_get_dev(const struct nvt_dev *nvt)
52{
53 return nvt->rdev->dev.parent;
54}
55
51static inline bool is_w83667hg(struct nvt_dev *nvt) 56static inline bool is_w83667hg(struct nvt_dev *nvt)
52{ 57{
53 return nvt->chip_ver == NVT_W83667HG; 58 return nvt->chip_ver == NVT_W83667HG;
@@ -182,7 +187,7 @@ static ssize_t wakeup_data_show(struct device *dev,
182 ssize_t buf_len = 0; 187 ssize_t buf_len = 0;
183 int i; 188 int i;
184 189
185 spin_lock_irqsave(&nvt->nvt_lock, flags); 190 spin_lock_irqsave(&nvt->lock, flags);
186 191
187 fifo_len = nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFO_COUNT); 192 fifo_len = nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFO_COUNT);
188 fifo_len = min(fifo_len, WAKEUP_MAX_SIZE); 193 fifo_len = min(fifo_len, WAKEUP_MAX_SIZE);
@@ -199,7 +204,7 @@ static ssize_t wakeup_data_show(struct device *dev,
199 } 204 }
200 buf_len += snprintf(buf + buf_len, PAGE_SIZE - buf_len, "\n"); 205 buf_len += snprintf(buf + buf_len, PAGE_SIZE - buf_len, "\n");
201 206
202 spin_unlock_irqrestore(&nvt->nvt_lock, flags); 207 spin_unlock_irqrestore(&nvt->lock, flags);
203 208
204 return buf_len; 209 return buf_len;
205} 210}
@@ -243,7 +248,7 @@ static ssize_t wakeup_data_store(struct device *dev,
243 /* hardcode the tolerance to 10% */ 248 /* hardcode the tolerance to 10% */
244 tolerance = DIV_ROUND_UP(count, 10); 249 tolerance = DIV_ROUND_UP(count, 10);
245 250
246 spin_lock_irqsave(&nvt->nvt_lock, flags); 251 spin_lock_irqsave(&nvt->lock, flags);
247 252
248 nvt_clear_cir_wake_fifo(nvt); 253 nvt_clear_cir_wake_fifo(nvt);
249 nvt_cir_wake_reg_write(nvt, count, CIR_WAKE_FIFO_CMP_DEEP); 254 nvt_cir_wake_reg_write(nvt, count, CIR_WAKE_FIFO_CMP_DEEP);
@@ -260,7 +265,7 @@ static ssize_t wakeup_data_store(struct device *dev,
260 265
261 nvt_cir_wake_reg_write(nvt, config, CIR_WAKE_IRCON); 266 nvt_cir_wake_reg_write(nvt, config, CIR_WAKE_IRCON);
262 267
263 spin_unlock_irqrestore(&nvt->nvt_lock, flags); 268 spin_unlock_irqrestore(&nvt->lock, flags);
264 269
265 ret = len; 270 ret = len;
266out: 271out:
@@ -385,6 +390,7 @@ static inline const char *nvt_find_chip(struct nvt_dev *nvt, int id)
385/* detect hardware features */ 390/* detect hardware features */
386static int nvt_hw_detect(struct nvt_dev *nvt) 391static int nvt_hw_detect(struct nvt_dev *nvt)
387{ 392{
393 struct device *dev = nvt_get_dev(nvt);
388 const char *chip_name; 394 const char *chip_name;
389 int chip_id; 395 int chip_id;
390 396
@@ -405,8 +411,7 @@ static int nvt_hw_detect(struct nvt_dev *nvt)
405 411
406 chip_id = nvt->chip_major << 8 | nvt->chip_minor; 412 chip_id = nvt->chip_major << 8 | nvt->chip_minor;
407 if (chip_id == NVT_INVALID) { 413 if (chip_id == NVT_INVALID) {
408 dev_err(&nvt->pdev->dev, 414 dev_err(dev, "No device found on either EFM port\n");
409 "No device found on either EFM port\n");
410 return -ENODEV; 415 return -ENODEV;
411 } 416 }
412 417
@@ -414,12 +419,11 @@ static int nvt_hw_detect(struct nvt_dev *nvt)
414 419
415 /* warn, but still let the driver load, if we don't know this chip */ 420 /* warn, but still let the driver load, if we don't know this chip */
416 if (!chip_name) 421 if (!chip_name)
417 dev_warn(&nvt->pdev->dev, 422 dev_warn(dev,
418 "unknown chip, id: 0x%02x 0x%02x, it may not work...", 423 "unknown chip, id: 0x%02x 0x%02x, it may not work...",
419 nvt->chip_major, nvt->chip_minor); 424 nvt->chip_major, nvt->chip_minor);
420 else 425 else
421 dev_info(&nvt->pdev->dev, 426 dev_info(dev, "found %s or compatible: chip id: 0x%02x 0x%02x",
422 "found %s or compatible: chip id: 0x%02x 0x%02x",
423 chip_name, nvt->chip_major, nvt->chip_minor); 427 chip_name, nvt->chip_major, nvt->chip_minor);
424 428
425 return 0; 429 return 0;
@@ -586,7 +590,7 @@ static void nvt_enable_wake(struct nvt_dev *nvt)
586 590
587 nvt_efm_disable(nvt); 591 nvt_efm_disable(nvt);
588 592
589 spin_lock_irqsave(&nvt->nvt_lock, flags); 593 spin_lock_irqsave(&nvt->lock, flags);
590 594
591 nvt_cir_wake_reg_write(nvt, CIR_WAKE_IRCON_MODE0 | CIR_WAKE_IRCON_RXEN | 595 nvt_cir_wake_reg_write(nvt, CIR_WAKE_IRCON_MODE0 | CIR_WAKE_IRCON_RXEN |
592 CIR_WAKE_IRCON_R | CIR_WAKE_IRCON_RXINV | 596 CIR_WAKE_IRCON_R | CIR_WAKE_IRCON_RXINV |
@@ -595,11 +599,11 @@ static void nvt_enable_wake(struct nvt_dev *nvt)
595 nvt_cir_wake_reg_write(nvt, 0xff, CIR_WAKE_IRSTS); 599 nvt_cir_wake_reg_write(nvt, 0xff, CIR_WAKE_IRSTS);
596 nvt_cir_wake_reg_write(nvt, 0, CIR_WAKE_IREN); 600 nvt_cir_wake_reg_write(nvt, 0, CIR_WAKE_IREN);
597 601
598 spin_unlock_irqrestore(&nvt->nvt_lock, flags); 602 spin_unlock_irqrestore(&nvt->lock, flags);
599} 603}
600 604
601#if 0 /* Currently unused */ 605#if 0 /* Currently unused */
602/* rx carrier detect only works in learning mode, must be called w/nvt_lock */ 606/* rx carrier detect only works in learning mode, must be called w/lock */
603static u32 nvt_rx_carrier_detect(struct nvt_dev *nvt) 607static u32 nvt_rx_carrier_detect(struct nvt_dev *nvt)
604{ 608{
605 u32 count, carrier, duration = 0; 609 u32 count, carrier, duration = 0;
@@ -616,7 +620,7 @@ static u32 nvt_rx_carrier_detect(struct nvt_dev *nvt)
616 duration *= SAMPLE_PERIOD; 620 duration *= SAMPLE_PERIOD;
617 621
618 if (!count || !duration) { 622 if (!count || !duration) {
619 dev_notice(&nvt->pdev->dev, 623 dev_notice(nvt_get_dev(nvt),
620 "Unable to determine carrier! (c:%u, d:%u)", 624 "Unable to determine carrier! (c:%u, d:%u)",
621 count, duration); 625 count, duration);
622 return 0; 626 return 0;
@@ -684,7 +688,7 @@ static int nvt_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned n)
684 u8 iren; 688 u8 iren;
685 int ret; 689 int ret;
686 690
687 spin_lock_irqsave(&nvt->tx.lock, flags); 691 spin_lock_irqsave(&nvt->lock, flags);
688 692
689 ret = min((unsigned)(TX_BUF_LEN / sizeof(unsigned)), n); 693 ret = min((unsigned)(TX_BUF_LEN / sizeof(unsigned)), n);
690 nvt->tx.buf_count = (ret * sizeof(unsigned)); 694 nvt->tx.buf_count = (ret * sizeof(unsigned));
@@ -708,13 +712,13 @@ static int nvt_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned n)
708 for (i = 0; i < 9; i++) 712 for (i = 0; i < 9; i++)
709 nvt_cir_reg_write(nvt, 0x01, CIR_STXFIFO); 713 nvt_cir_reg_write(nvt, 0x01, CIR_STXFIFO);
710 714
711 spin_unlock_irqrestore(&nvt->tx.lock, flags); 715 spin_unlock_irqrestore(&nvt->lock, flags);
712 716
713 wait_event(nvt->tx.queue, nvt->tx.tx_state == ST_TX_REQUEST); 717 wait_event(nvt->tx.queue, nvt->tx.tx_state == ST_TX_REQUEST);
714 718
715 spin_lock_irqsave(&nvt->tx.lock, flags); 719 spin_lock_irqsave(&nvt->lock, flags);
716 nvt->tx.tx_state = ST_TX_NONE; 720 nvt->tx.tx_state = ST_TX_NONE;
717 spin_unlock_irqrestore(&nvt->tx.lock, flags); 721 spin_unlock_irqrestore(&nvt->lock, flags);
718 722
719 /* restore enabled interrupts to prior state */ 723 /* restore enabled interrupts to prior state */
720 nvt_cir_reg_write(nvt, iren, CIR_IREN); 724 nvt_cir_reg_write(nvt, iren, CIR_IREN);
@@ -781,7 +785,7 @@ static void nvt_process_rx_ir_data(struct nvt_dev *nvt)
781 785
782static void nvt_handle_rx_fifo_overrun(struct nvt_dev *nvt) 786static void nvt_handle_rx_fifo_overrun(struct nvt_dev *nvt)
783{ 787{
784 dev_warn(&nvt->pdev->dev, "RX FIFO overrun detected, flushing data!"); 788 dev_warn(nvt_get_dev(nvt), "RX FIFO overrun detected, flushing data!");
785 789
786 nvt->pkts = 0; 790 nvt->pkts = 0;
787 nvt_clear_cir_fifo(nvt); 791 nvt_clear_cir_fifo(nvt);
@@ -828,14 +832,7 @@ static void nvt_cir_log_irqs(u8 status, u8 iren)
828 832
829static bool nvt_cir_tx_inactive(struct nvt_dev *nvt) 833static bool nvt_cir_tx_inactive(struct nvt_dev *nvt)
830{ 834{
831 unsigned long flags; 835 return nvt->tx.tx_state == ST_TX_NONE;
832 u8 tx_state;
833
834 spin_lock_irqsave(&nvt->tx.lock, flags);
835 tx_state = nvt->tx.tx_state;
836 spin_unlock_irqrestore(&nvt->tx.lock, flags);
837
838 return tx_state == ST_TX_NONE;
839} 836}
840 837
841/* interrupt service routine for incoming and outgoing CIR data */ 838/* interrupt service routine for incoming and outgoing CIR data */
@@ -843,11 +840,10 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
843{ 840{
844 struct nvt_dev *nvt = data; 841 struct nvt_dev *nvt = data;
845 u8 status, iren; 842 u8 status, iren;
846 unsigned long flags;
847 843
848 nvt_dbg_verbose("%s firing", __func__); 844 nvt_dbg_verbose("%s firing", __func__);
849 845
850 spin_lock_irqsave(&nvt->nvt_lock, flags); 846 spin_lock(&nvt->lock);
851 847
852 /* 848 /*
853 * Get IR Status register contents. Write 1 to ack/clear 849 * Get IR Status register contents. Write 1 to ack/clear
@@ -869,7 +865,7 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
869 * logical device is being disabled. 865 * logical device is being disabled.
870 */ 866 */
871 if (status == 0xff && iren == 0xff) { 867 if (status == 0xff && iren == 0xff) {
872 spin_unlock_irqrestore(&nvt->nvt_lock, flags); 868 spin_unlock(&nvt->lock);
873 nvt_dbg_verbose("Spurious interrupt detected"); 869 nvt_dbg_verbose("Spurious interrupt detected");
874 return IRQ_HANDLED; 870 return IRQ_HANDLED;
875 } 871 }
@@ -878,7 +874,7 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
878 * status bit whether the related interrupt source is enabled 874 * status bit whether the related interrupt source is enabled
879 */ 875 */
880 if (!(status & iren)) { 876 if (!(status & iren)) {
881 spin_unlock_irqrestore(&nvt->nvt_lock, flags); 877 spin_unlock(&nvt->lock);
882 nvt_dbg_verbose("%s exiting, IRSTS 0x0", __func__); 878 nvt_dbg_verbose("%s exiting, IRSTS 0x0", __func__);
883 return IRQ_NONE; 879 return IRQ_NONE;
884 } 880 }
@@ -898,8 +894,6 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
898 nvt_get_rx_ir_data(nvt); 894 nvt_get_rx_ir_data(nvt);
899 } 895 }
900 896
901 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
902
903 if (status & CIR_IRSTS_TE) 897 if (status & CIR_IRSTS_TE)
904 nvt_clear_tx_fifo(nvt); 898 nvt_clear_tx_fifo(nvt);
905 899
@@ -907,8 +901,6 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
907 unsigned int pos, count; 901 unsigned int pos, count;
908 u8 tmp; 902 u8 tmp;
909 903
910 spin_lock_irqsave(&nvt->tx.lock, flags);
911
912 pos = nvt->tx.cur_buf_num; 904 pos = nvt->tx.cur_buf_num;
913 count = nvt->tx.buf_count; 905 count = nvt->tx.buf_count;
914 906
@@ -921,20 +913,17 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
921 tmp = nvt_cir_reg_read(nvt, CIR_IREN); 913 tmp = nvt_cir_reg_read(nvt, CIR_IREN);
922 nvt_cir_reg_write(nvt, tmp & ~CIR_IREN_TTR, CIR_IREN); 914 nvt_cir_reg_write(nvt, tmp & ~CIR_IREN_TTR, CIR_IREN);
923 } 915 }
924
925 spin_unlock_irqrestore(&nvt->tx.lock, flags);
926
927 } 916 }
928 917
929 if (status & CIR_IRSTS_TFU) { 918 if (status & CIR_IRSTS_TFU) {
930 spin_lock_irqsave(&nvt->tx.lock, flags);
931 if (nvt->tx.tx_state == ST_TX_REPLY) { 919 if (nvt->tx.tx_state == ST_TX_REPLY) {
932 nvt->tx.tx_state = ST_TX_REQUEST; 920 nvt->tx.tx_state = ST_TX_REQUEST;
933 wake_up(&nvt->tx.queue); 921 wake_up(&nvt->tx.queue);
934 } 922 }
935 spin_unlock_irqrestore(&nvt->tx.lock, flags);
936 } 923 }
937 924
925 spin_unlock(&nvt->lock);
926
938 nvt_dbg_verbose("%s done", __func__); 927 nvt_dbg_verbose("%s done", __func__);
939 return IRQ_HANDLED; 928 return IRQ_HANDLED;
940} 929}
@@ -943,7 +932,7 @@ static void nvt_disable_cir(struct nvt_dev *nvt)
943{ 932{
944 unsigned long flags; 933 unsigned long flags;
945 934
946 spin_lock_irqsave(&nvt->nvt_lock, flags); 935 spin_lock_irqsave(&nvt->lock, flags);
947 936
948 /* disable CIR interrupts */ 937 /* disable CIR interrupts */
949 nvt_cir_reg_write(nvt, 0, CIR_IREN); 938 nvt_cir_reg_write(nvt, 0, CIR_IREN);
@@ -958,7 +947,7 @@ static void nvt_disable_cir(struct nvt_dev *nvt)
958 nvt_clear_cir_fifo(nvt); 947 nvt_clear_cir_fifo(nvt);
959 nvt_clear_tx_fifo(nvt); 948 nvt_clear_tx_fifo(nvt);
960 949
961 spin_unlock_irqrestore(&nvt->nvt_lock, flags); 950 spin_unlock_irqrestore(&nvt->lock, flags);
962 951
963 /* disable the CIR logical device */ 952 /* disable the CIR logical device */
964 nvt_disable_logical_dev(nvt, LOGICAL_DEV_CIR); 953 nvt_disable_logical_dev(nvt, LOGICAL_DEV_CIR);
@@ -969,7 +958,7 @@ static int nvt_open(struct rc_dev *dev)
969 struct nvt_dev *nvt = dev->priv; 958 struct nvt_dev *nvt = dev->priv;
970 unsigned long flags; 959 unsigned long flags;
971 960
972 spin_lock_irqsave(&nvt->nvt_lock, flags); 961 spin_lock_irqsave(&nvt->lock, flags);
973 962
974 /* set function enable flags */ 963 /* set function enable flags */
975 nvt_cir_reg_write(nvt, CIR_IRCON_TXEN | CIR_IRCON_RXEN | 964 nvt_cir_reg_write(nvt, CIR_IRCON_TXEN | CIR_IRCON_RXEN |
@@ -982,7 +971,7 @@ static int nvt_open(struct rc_dev *dev)
982 /* enable interrupts */ 971 /* enable interrupts */
983 nvt_set_cir_iren(nvt); 972 nvt_set_cir_iren(nvt);
984 973
985 spin_unlock_irqrestore(&nvt->nvt_lock, flags); 974 spin_unlock_irqrestore(&nvt->lock, flags);
986 975
987 /* enable the CIR logical device */ 976 /* enable the CIR logical device */
988 nvt_enable_logical_dev(nvt, LOGICAL_DEV_CIR); 977 nvt_enable_logical_dev(nvt, LOGICAL_DEV_CIR);
@@ -1002,40 +991,41 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1002{ 991{
1003 struct nvt_dev *nvt; 992 struct nvt_dev *nvt;
1004 struct rc_dev *rdev; 993 struct rc_dev *rdev;
1005 int ret = -ENOMEM; 994 int ret;
1006 995
1007 nvt = devm_kzalloc(&pdev->dev, sizeof(struct nvt_dev), GFP_KERNEL); 996 nvt = devm_kzalloc(&pdev->dev, sizeof(struct nvt_dev), GFP_KERNEL);
1008 if (!nvt) 997 if (!nvt)
1009 return ret; 998 return -ENOMEM;
1010 999
1011 /* input device for IR remote (and tx) */ 1000 /* input device for IR remote (and tx) */
1012 rdev = rc_allocate_device(); 1001 nvt->rdev = devm_rc_allocate_device(&pdev->dev);
1013 if (!rdev) 1002 if (!nvt->rdev)
1014 goto exit_free_dev_rdev; 1003 return -ENOMEM;
1004 rdev = nvt->rdev;
1015 1005
1016 ret = -ENODEV;
1017 /* activate pnp device */ 1006 /* activate pnp device */
1018 if (pnp_activate_dev(pdev) < 0) { 1007 ret = pnp_activate_dev(pdev);
1008 if (ret) {
1019 dev_err(&pdev->dev, "Could not activate PNP device!\n"); 1009 dev_err(&pdev->dev, "Could not activate PNP device!\n");
1020 goto exit_free_dev_rdev; 1010 return ret;
1021 } 1011 }
1022 1012
1023 /* validate pnp resources */ 1013 /* validate pnp resources */
1024 if (!pnp_port_valid(pdev, 0) || 1014 if (!pnp_port_valid(pdev, 0) ||
1025 pnp_port_len(pdev, 0) < CIR_IOREG_LENGTH) { 1015 pnp_port_len(pdev, 0) < CIR_IOREG_LENGTH) {
1026 dev_err(&pdev->dev, "IR PNP Port not valid!\n"); 1016 dev_err(&pdev->dev, "IR PNP Port not valid!\n");
1027 goto exit_free_dev_rdev; 1017 return -EINVAL;
1028 } 1018 }
1029 1019
1030 if (!pnp_irq_valid(pdev, 0)) { 1020 if (!pnp_irq_valid(pdev, 0)) {
1031 dev_err(&pdev->dev, "PNP IRQ not valid!\n"); 1021 dev_err(&pdev->dev, "PNP IRQ not valid!\n");
1032 goto exit_free_dev_rdev; 1022 return -EINVAL;
1033 } 1023 }
1034 1024
1035 if (!pnp_port_valid(pdev, 1) || 1025 if (!pnp_port_valid(pdev, 1) ||
1036 pnp_port_len(pdev, 1) < CIR_IOREG_LENGTH) { 1026 pnp_port_len(pdev, 1) < CIR_IOREG_LENGTH) {
1037 dev_err(&pdev->dev, "Wake PNP Port not valid!\n"); 1027 dev_err(&pdev->dev, "Wake PNP Port not valid!\n");
1038 goto exit_free_dev_rdev; 1028 return -EINVAL;
1039 } 1029 }
1040 1030
1041 nvt->cir_addr = pnp_port_start(pdev, 0); 1031 nvt->cir_addr = pnp_port_start(pdev, 0);
@@ -1046,17 +1036,15 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1046 nvt->cr_efir = CR_EFIR; 1036 nvt->cr_efir = CR_EFIR;
1047 nvt->cr_efdr = CR_EFDR; 1037 nvt->cr_efdr = CR_EFDR;
1048 1038
1049 spin_lock_init(&nvt->nvt_lock); 1039 spin_lock_init(&nvt->lock);
1050 spin_lock_init(&nvt->tx.lock);
1051 1040
1052 pnp_set_drvdata(pdev, nvt); 1041 pnp_set_drvdata(pdev, nvt);
1053 nvt->pdev = pdev;
1054 1042
1055 init_waitqueue_head(&nvt->tx.queue); 1043 init_waitqueue_head(&nvt->tx.queue);
1056 1044
1057 ret = nvt_hw_detect(nvt); 1045 ret = nvt_hw_detect(nvt);
1058 if (ret) 1046 if (ret)
1059 goto exit_free_dev_rdev; 1047 return ret;
1060 1048
1061 /* Initialize CIR & CIR Wake Logical Devices */ 1049 /* Initialize CIR & CIR Wake Logical Devices */
1062 nvt_efm_enable(nvt); 1050 nvt_efm_enable(nvt);
@@ -1085,7 +1073,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1085 rdev->input_id.vendor = PCI_VENDOR_ID_WINBOND2; 1073 rdev->input_id.vendor = PCI_VENDOR_ID_WINBOND2;
1086 rdev->input_id.product = nvt->chip_major; 1074 rdev->input_id.product = nvt->chip_major;
1087 rdev->input_id.version = nvt->chip_minor; 1075 rdev->input_id.version = nvt->chip_minor;
1088 rdev->dev.parent = &pdev->dev;
1089 rdev->driver_name = NVT_DRIVER_NAME; 1076 rdev->driver_name = NVT_DRIVER_NAME;
1090 rdev->map_name = RC_MAP_RC6_MCE; 1077 rdev->map_name = RC_MAP_RC6_MCE;
1091 rdev->timeout = MS_TO_NS(100); 1078 rdev->timeout = MS_TO_NS(100);
@@ -1097,29 +1084,27 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1097 /* tx bits */ 1084 /* tx bits */
1098 rdev->tx_resolution = XYZ; 1085 rdev->tx_resolution = XYZ;
1099#endif 1086#endif
1100 nvt->rdev = rdev; 1087 ret = devm_rc_register_device(&pdev->dev, rdev);
1101
1102 ret = rc_register_device(rdev);
1103 if (ret) 1088 if (ret)
1104 goto exit_free_dev_rdev; 1089 return ret;
1105 1090
1106 ret = -EBUSY;
1107 /* now claim resources */ 1091 /* now claim resources */
1108 if (!devm_request_region(&pdev->dev, nvt->cir_addr, 1092 if (!devm_request_region(&pdev->dev, nvt->cir_addr,
1109 CIR_IOREG_LENGTH, NVT_DRIVER_NAME)) 1093 CIR_IOREG_LENGTH, NVT_DRIVER_NAME))
1110 goto exit_unregister_device; 1094 return -EBUSY;
1111 1095
1112 if (devm_request_irq(&pdev->dev, nvt->cir_irq, nvt_cir_isr, 1096 ret = devm_request_irq(&pdev->dev, nvt->cir_irq, nvt_cir_isr,
1113 IRQF_SHARED, NVT_DRIVER_NAME, (void *)nvt)) 1097 IRQF_SHARED, NVT_DRIVER_NAME, nvt);
1114 goto exit_unregister_device; 1098 if (ret)
1099 return ret;
1115 1100
1116 if (!devm_request_region(&pdev->dev, nvt->cir_wake_addr, 1101 if (!devm_request_region(&pdev->dev, nvt->cir_wake_addr,
1117 CIR_IOREG_LENGTH, NVT_DRIVER_NAME "-wake")) 1102 CIR_IOREG_LENGTH, NVT_DRIVER_NAME "-wake"))
1118 goto exit_unregister_device; 1103 return -EBUSY;
1119 1104
1120 ret = device_create_file(&rdev->dev, &dev_attr_wakeup_data); 1105 ret = device_create_file(&rdev->dev, &dev_attr_wakeup_data);
1121 if (ret) 1106 if (ret)
1122 goto exit_unregister_device; 1107 return ret;
1123 1108
1124 device_init_wakeup(&pdev->dev, true); 1109 device_init_wakeup(&pdev->dev, true);
1125 1110
@@ -1130,14 +1115,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1130 } 1115 }
1131 1116
1132 return 0; 1117 return 0;
1133
1134exit_unregister_device:
1135 rc_unregister_device(rdev);
1136 rdev = NULL;
1137exit_free_dev_rdev:
1138 rc_free_device(rdev);
1139
1140 return ret;
1141} 1118}
1142 1119
1143static void nvt_remove(struct pnp_dev *pdev) 1120static void nvt_remove(struct pnp_dev *pdev)
@@ -1150,8 +1127,6 @@ static void nvt_remove(struct pnp_dev *pdev)
1150 1127
1151 /* enable CIR Wake (for IR power-on) */ 1128 /* enable CIR Wake (for IR power-on) */
1152 nvt_enable_wake(nvt); 1129 nvt_enable_wake(nvt);
1153
1154 rc_unregister_device(nvt->rdev);
1155} 1130}
1156 1131
1157static int nvt_suspend(struct pnp_dev *pdev, pm_message_t state) 1132static int nvt_suspend(struct pnp_dev *pdev, pm_message_t state)
@@ -1161,16 +1136,14 @@ static int nvt_suspend(struct pnp_dev *pdev, pm_message_t state)
1161 1136
1162 nvt_dbg("%s called", __func__); 1137 nvt_dbg("%s called", __func__);
1163 1138
1164 spin_lock_irqsave(&nvt->tx.lock, flags); 1139 spin_lock_irqsave(&nvt->lock, flags);
1165 nvt->tx.tx_state = ST_TX_NONE;
1166 spin_unlock_irqrestore(&nvt->tx.lock, flags);
1167 1140
1168 spin_lock_irqsave(&nvt->nvt_lock, flags); 1141 nvt->tx.tx_state = ST_TX_NONE;
1169 1142
1170 /* disable all CIR interrupts */ 1143 /* disable all CIR interrupts */
1171 nvt_cir_reg_write(nvt, 0, CIR_IREN); 1144 nvt_cir_reg_write(nvt, 0, CIR_IREN);
1172 1145
1173 spin_unlock_irqrestore(&nvt->nvt_lock, flags); 1146 spin_unlock_irqrestore(&nvt->lock, flags);
1174 1147
1175 /* disable cir logical dev */ 1148 /* disable cir logical dev */
1176 nvt_disable_logical_dev(nvt, LOGICAL_DEV_CIR); 1149 nvt_disable_logical_dev(nvt, LOGICAL_DEV_CIR);
diff --git a/drivers/media/rc/nuvoton-cir.h b/drivers/media/rc/nuvoton-cir.h
index acf735fc7170..c41c5765e1d2 100644
--- a/drivers/media/rc/nuvoton-cir.h
+++ b/drivers/media/rc/nuvoton-cir.h
@@ -78,17 +78,15 @@ struct nvt_chip {
78}; 78};
79 79
80struct nvt_dev { 80struct nvt_dev {
81 struct pnp_dev *pdev;
82 struct rc_dev *rdev; 81 struct rc_dev *rdev;
83 82
84 spinlock_t nvt_lock; 83 spinlock_t lock;
85 84
86 /* for rx */ 85 /* for rx */
87 u8 buf[RX_BUF_LEN]; 86 u8 buf[RX_BUF_LEN];
88 unsigned int pkts; 87 unsigned int pkts;
89 88
90 struct { 89 struct {
91 spinlock_t lock;
92 u8 buf[TX_BUF_LEN]; 90 u8 buf[TX_BUF_LEN];
93 unsigned int buf_count; 91 unsigned int buf_count;
94 unsigned int cur_buf_num; 92 unsigned int cur_buf_num;
diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c
index 205ecc602e34..1c42a9f2f290 100644
--- a/drivers/media/rc/rc-ir-raw.c
+++ b/drivers/media/rc/rc-ir-raw.c
@@ -26,8 +26,7 @@ static LIST_HEAD(ir_raw_client_list);
26/* Used to handle IR raw handler extensions */ 26/* Used to handle IR raw handler extensions */
27static DEFINE_MUTEX(ir_raw_handler_lock); 27static DEFINE_MUTEX(ir_raw_handler_lock);
28static LIST_HEAD(ir_raw_handler_list); 28static LIST_HEAD(ir_raw_handler_list);
29static DEFINE_MUTEX(available_protocols_lock); 29static atomic64_t available_protocols = ATOMIC64_INIT(0);
30static u64 available_protocols;
31 30
32static int ir_raw_event_thread(void *data) 31static int ir_raw_event_thread(void *data)
33{ 32{
@@ -234,11 +233,7 @@ EXPORT_SYMBOL_GPL(ir_raw_event_handle);
234u64 233u64
235ir_raw_get_allowed_protocols(void) 234ir_raw_get_allowed_protocols(void)
236{ 235{
237 u64 protocols; 236 return atomic64_read(&available_protocols);
238 mutex_lock(&available_protocols_lock);
239 protocols = available_protocols;
240 mutex_unlock(&available_protocols_lock);
241 return protocols;
242} 237}
243 238
244static int change_protocol(struct rc_dev *dev, u64 *rc_type) 239static int change_protocol(struct rc_dev *dev, u64 *rc_type)
@@ -331,9 +326,7 @@ int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler)
331 if (ir_raw_handler->raw_register) 326 if (ir_raw_handler->raw_register)
332 list_for_each_entry(raw, &ir_raw_client_list, list) 327 list_for_each_entry(raw, &ir_raw_client_list, list)
333 ir_raw_handler->raw_register(raw->dev); 328 ir_raw_handler->raw_register(raw->dev);
334 mutex_lock(&available_protocols_lock); 329 atomic64_or(ir_raw_handler->protocols, &available_protocols);
335 available_protocols |= ir_raw_handler->protocols;
336 mutex_unlock(&available_protocols_lock);
337 mutex_unlock(&ir_raw_handler_lock); 330 mutex_unlock(&ir_raw_handler_lock);
338 331
339 return 0; 332 return 0;
@@ -352,9 +345,7 @@ void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler)
352 if (ir_raw_handler->raw_unregister) 345 if (ir_raw_handler->raw_unregister)
353 ir_raw_handler->raw_unregister(raw->dev); 346 ir_raw_handler->raw_unregister(raw->dev);
354 } 347 }
355 mutex_lock(&available_protocols_lock); 348 atomic64_andnot(protocols, &available_protocols);
356 available_protocols &= ~protocols;
357 mutex_unlock(&available_protocols_lock);
358 mutex_unlock(&ir_raw_handler_lock); 349 mutex_unlock(&ir_raw_handler_lock);
359} 350}
360EXPORT_SYMBOL(ir_raw_handler_unregister); 351EXPORT_SYMBOL(ir_raw_handler_unregister);
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index d9c1f2ff7119..dedaf38c5ff6 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -12,6 +12,8 @@
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 */ 13 */
14 14
15#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
16
15#include <media/rc-core.h> 17#include <media/rc-core.h>
16#include <linux/atomic.h> 18#include <linux/atomic.h>
17#include <linux/spinlock.h> 19#include <linux/spinlock.h>
@@ -66,7 +68,7 @@ struct rc_map *rc_map_get(const char *name)
66 if (!map) { 68 if (!map) {
67 int rc = request_module("%s", name); 69 int rc = request_module("%s", name);
68 if (rc < 0) { 70 if (rc < 0) {
69 printk(KERN_ERR "Couldn't load IR keymap %s\n", name); 71 pr_err("Couldn't load IR keymap %s\n", name);
70 return NULL; 72 return NULL;
71 } 73 }
72 msleep(20); /* Give some time for IR to register */ 74 msleep(20); /* Give some time for IR to register */
@@ -75,7 +77,7 @@ struct rc_map *rc_map_get(const char *name)
75 } 77 }
76#endif 78#endif
77 if (!map) { 79 if (!map) {
78 printk(KERN_ERR "IR keymap %s not found\n", name); 80 pr_err("IR keymap %s not found\n", name);
79 return NULL; 81 return NULL;
80 } 82 }
81 83
@@ -159,6 +161,7 @@ static void ir_free_table(struct rc_map *rc_map)
159{ 161{
160 rc_map->size = 0; 162 rc_map->size = 0;
161 kfree(rc_map->name); 163 kfree(rc_map->name);
164 rc_map->name = NULL;
162 kfree(rc_map->scan); 165 kfree(rc_map->scan);
163 rc_map->scan = NULL; 166 rc_map->scan = NULL;
164} 167}
@@ -660,8 +663,7 @@ static void ir_do_keydown(struct rc_dev *dev, enum rc_type protocol,
660 dev->last_toggle = toggle; 663 dev->last_toggle = toggle;
661 dev->last_keycode = keycode; 664 dev->last_keycode = keycode;
662 665
663 IR_dprintk(1, "%s: key down event, " 666 IR_dprintk(1, "%s: key down event, key 0x%04x, protocol 0x%04x, scancode 0x%08x\n",
664 "key 0x%04x, protocol 0x%04x, scancode 0x%08x\n",
665 dev->input_name, keycode, protocol, scancode); 667 dev->input_name, keycode, protocol, scancode);
666 input_report_key(dev->input_dev, keycode, 1); 668 input_report_key(dev->input_dev, keycode, 1);
667 669
@@ -1403,6 +1405,34 @@ void rc_free_device(struct rc_dev *dev)
1403} 1405}
1404EXPORT_SYMBOL_GPL(rc_free_device); 1406EXPORT_SYMBOL_GPL(rc_free_device);
1405 1407
1408static void devm_rc_alloc_release(struct device *dev, void *res)
1409{
1410 rc_free_device(*(struct rc_dev **)res);
1411}
1412
1413struct rc_dev *devm_rc_allocate_device(struct device *dev)
1414{
1415 struct rc_dev **dr, *rc;
1416
1417 dr = devres_alloc(devm_rc_alloc_release, sizeof(*dr), GFP_KERNEL);
1418 if (!dr)
1419 return NULL;
1420
1421 rc = rc_allocate_device();
1422 if (!rc) {
1423 devres_free(dr);
1424 return NULL;
1425 }
1426
1427 rc->dev.parent = dev;
1428 rc->managed_alloc = true;
1429 *dr = rc;
1430 devres_add(dev, dr);
1431
1432 return rc;
1433}
1434EXPORT_SYMBOL_GPL(devm_rc_allocate_device);
1435
1406int rc_register_device(struct rc_dev *dev) 1436int rc_register_device(struct rc_dev *dev)
1407{ 1437{
1408 static bool raw_init = false; /* raw decoders loaded? */ 1438 static bool raw_init = false; /* raw decoders loaded? */
@@ -1531,6 +1561,33 @@ out_unlock:
1531} 1561}
1532EXPORT_SYMBOL_GPL(rc_register_device); 1562EXPORT_SYMBOL_GPL(rc_register_device);
1533 1563
1564static void devm_rc_release(struct device *dev, void *res)
1565{
1566 rc_unregister_device(*(struct rc_dev **)res);
1567}
1568
1569int devm_rc_register_device(struct device *parent, struct rc_dev *dev)
1570{
1571 struct rc_dev **dr;
1572 int ret;
1573
1574 dr = devres_alloc(devm_rc_release, sizeof(*dr), GFP_KERNEL);
1575 if (!dr)
1576 return -ENOMEM;
1577
1578 ret = rc_register_device(dev);
1579 if (ret) {
1580 devres_free(dr);
1581 return ret;
1582 }
1583
1584 *dr = dev;
1585 devres_add(parent, dr);
1586
1587 return 0;
1588}
1589EXPORT_SYMBOL_GPL(devm_rc_register_device);
1590
1534void rc_unregister_device(struct rc_dev *dev) 1591void rc_unregister_device(struct rc_dev *dev)
1535{ 1592{
1536 if (!dev) 1593 if (!dev)
@@ -1552,7 +1609,8 @@ void rc_unregister_device(struct rc_dev *dev)
1552 1609
1553 ida_simple_remove(&rc_ida, dev->minor); 1610 ida_simple_remove(&rc_ida, dev->minor);
1554 1611
1555 rc_free_device(dev); 1612 if (!dev->managed_alloc)
1613 rc_free_device(dev);
1556} 1614}
1557 1615
1558EXPORT_SYMBOL_GPL(rc_unregister_device); 1616EXPORT_SYMBOL_GPL(rc_unregister_device);
@@ -1565,7 +1623,7 @@ static int __init rc_core_init(void)
1565{ 1623{
1566 int rc = class_register(&rc_class); 1624 int rc = class_register(&rc_class);
1567 if (rc) { 1625 if (rc) {
1568 printk(KERN_ERR "rc_core: unable to register rc class\n"); 1626 pr_err("rc_core: unable to register rc class\n");
1569 return rc; 1627 return rc;
1570 } 1628 }
1571 1629
diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index 05ba47bc0b61..2784f5dae398 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -81,6 +81,8 @@
81#define RR3_RC_DET_ENABLE 0xbb 81#define RR3_RC_DET_ENABLE 0xbb
82/* Stop capture with the RC receiver */ 82/* Stop capture with the RC receiver */
83#define RR3_RC_DET_DISABLE 0xbc 83#define RR3_RC_DET_DISABLE 0xbc
84/* Start capture with the wideband receiver */
85#define RR3_MODSIG_CAPTURE 0xb2
84/* Return the status of RC detector capture */ 86/* Return the status of RC detector capture */
85#define RR3_RC_DET_STATUS 0xbd 87#define RR3_RC_DET_STATUS 0xbd
86/* Reset redrat */ 88/* Reset redrat */
@@ -105,11 +107,13 @@
105#define RR3_CLK_PER_COUNT 12 107#define RR3_CLK_PER_COUNT 12
106/* (RR3_CLK / RR3_CLK_PER_COUNT) */ 108/* (RR3_CLK / RR3_CLK_PER_COUNT) */
107#define RR3_CLK_CONV_FACTOR 2000000 109#define RR3_CLK_CONV_FACTOR 2000000
108/* USB bulk-in IR data endpoint address */ 110/* USB bulk-in wideband IR data endpoint address */
109#define RR3_BULK_IN_EP_ADDR 0x82 111#define RR3_WIDE_IN_EP_ADDR 0x81
112/* USB bulk-in narrowband IR data endpoint address */
113#define RR3_NARROW_IN_EP_ADDR 0x82
110 114
111/* Size of the fixed-length portion of the signal */ 115/* Size of the fixed-length portion of the signal */
112#define RR3_DRIVER_MAXLENS 128 116#define RR3_DRIVER_MAXLENS 255
113#define RR3_MAX_SIG_SIZE 512 117#define RR3_MAX_SIG_SIZE 512
114#define RR3_TIME_UNIT 50 118#define RR3_TIME_UNIT 50
115#define RR3_END_OF_SIGNAL 0x7f 119#define RR3_END_OF_SIGNAL 0x7f
@@ -207,15 +211,22 @@ struct redrat3_dev {
207 struct urb *flash_urb; 211 struct urb *flash_urb;
208 u8 flash_in_buf; 212 u8 flash_in_buf;
209 213
214 /* learning */
215 bool wideband;
216 struct usb_ctrlrequest learn_control;
217 struct urb *learn_urb;
218 u8 learn_buf;
219
210 /* save off the usb device pointer */ 220 /* save off the usb device pointer */
211 struct usb_device *udev; 221 struct usb_device *udev;
212 222
213 /* the receive endpoint */ 223 /* the receive endpoint */
214 struct usb_endpoint_descriptor *ep_in; 224 struct usb_endpoint_descriptor *ep_narrow;
215 /* the buffer to receive data */ 225 /* the buffer to receive data */
216 void *bulk_in_buf; 226 void *bulk_in_buf;
217 /* urb used to read ir data */ 227 /* urb used to read ir data */
218 struct urb *read_urb; 228 struct urb *narrow_urb;
229 struct urb *wide_urb;
219 230
220 /* the send endpoint */ 231 /* the send endpoint */
221 struct usb_endpoint_descriptor *ep_out; 232 struct usb_endpoint_descriptor *ep_out;
@@ -236,23 +247,6 @@ struct redrat3_dev {
236 char phys[64]; 247 char phys[64];
237}; 248};
238 249
239/*
240 * redrat3_issue_async
241 *
242 * Issues an async read to the ir data in port..
243 * sets the callback to be redrat3_handle_async
244 */
245static void redrat3_issue_async(struct redrat3_dev *rr3)
246{
247 int res;
248
249 res = usb_submit_urb(rr3->read_urb, GFP_ATOMIC);
250 if (res)
251 dev_dbg(rr3->dev,
252 "%s: receive request FAILED! (res %d, len %d)\n",
253 __func__, res, rr3->read_urb->transfer_buffer_length);
254}
255
256static void redrat3_dump_fw_error(struct redrat3_dev *rr3, int code) 250static void redrat3_dump_fw_error(struct redrat3_dev *rr3, int code)
257{ 251{
258 if (!rr3->transmitting && (code != 0x40)) 252 if (!rr3->transmitting && (code != 0x40))
@@ -265,8 +259,7 @@ static void redrat3_dump_fw_error(struct redrat3_dev *rr3, int code)
265 259
266 /* Codes 0x20 through 0x2f are IR Firmware Errors */ 260 /* Codes 0x20 through 0x2f are IR Firmware Errors */
267 case 0x20: 261 case 0x20:
268 pr_cont("Initial signal pulse not long enough " 262 pr_cont("Initial signal pulse not long enough to measure carrier frequency\n");
269 "to measure carrier frequency\n");
270 break; 263 break;
271 case 0x21: 264 case 0x21:
272 pr_cont("Not enough length values allocated for signal\n"); 265 pr_cont("Not enough length values allocated for signal\n");
@@ -278,18 +271,15 @@ static void redrat3_dump_fw_error(struct redrat3_dev *rr3, int code)
278 pr_cont("Too many signal repeats\n"); 271 pr_cont("Too many signal repeats\n");
279 break; 272 break;
280 case 0x28: 273 case 0x28:
281 pr_cont("Insufficient memory available for IR signal " 274 pr_cont("Insufficient memory available for IR signal data memory allocation\n");
282 "data memory allocation\n");
283 break; 275 break;
284 case 0x29: 276 case 0x29:
285 pr_cont("Insufficient memory available " 277 pr_cont("Insufficient memory available for IrDa signal data memory allocation\n");
286 "for IrDa signal data memory allocation\n");
287 break; 278 break;
288 279
289 /* Codes 0x30 through 0x3f are USB Firmware Errors */ 280 /* Codes 0x30 through 0x3f are USB Firmware Errors */
290 case 0x30: 281 case 0x30:
291 pr_cont("Insufficient memory available for bulk " 282 pr_cont("Insufficient memory available for bulk transfer structure\n");
292 "transfer structure\n");
293 break; 283 break;
294 284
295 /* 285 /*
@@ -301,8 +291,7 @@ static void redrat3_dump_fw_error(struct redrat3_dev *rr3, int code)
301 pr_cont("Signal capture has been terminated\n"); 291 pr_cont("Signal capture has been terminated\n");
302 break; 292 break;
303 case 0x41: 293 case 0x41:
304 pr_cont("Attempt to set/get and unknown signal I/O " 294 pr_cont("Attempt to set/get and unknown signal I/O algorithm parameter\n");
305 "algorithm parameter\n");
306 break; 295 break;
307 case 0x42: 296 case 0x42:
308 pr_cont("Signal capture already started\n"); 297 pr_cont("Signal capture already started\n");
@@ -368,15 +357,18 @@ static void redrat3_process_ir_data(struct redrat3_dev *rr3)
368 unsigned int i, sig_size, single_len, offset, val; 357 unsigned int i, sig_size, single_len, offset, val;
369 u32 mod_freq; 358 u32 mod_freq;
370 359
371 if (!rr3) {
372 pr_err("%s called with no context!\n", __func__);
373 return;
374 }
375
376 dev = rr3->dev; 360 dev = rr3->dev;
377 361
378 mod_freq = redrat3_val_to_mod_freq(&rr3->irdata); 362 mod_freq = redrat3_val_to_mod_freq(&rr3->irdata);
379 dev_dbg(dev, "Got mod_freq of %u\n", mod_freq); 363 dev_dbg(dev, "Got mod_freq of %u\n", mod_freq);
364 if (mod_freq && rr3->wideband) {
365 DEFINE_IR_RAW_EVENT(ev);
366
367 ev.carrier_report = 1;
368 ev.carrier = mod_freq;
369
370 ir_raw_event_store(rr3->rc, &ev);
371 }
380 372
381 /* process each rr3 encoded byte into an int */ 373 /* process each rr3 encoded byte into an int */
382 sig_size = be16_to_cpu(rr3->irdata.sig_size); 374 sig_size = be16_to_cpu(rr3->irdata.sig_size);
@@ -459,19 +451,31 @@ static int redrat3_enable_detector(struct redrat3_dev *rr3)
459 return -EIO; 451 return -EIO;
460 } 452 }
461 453
462 redrat3_issue_async(rr3); 454 ret = usb_submit_urb(rr3->narrow_urb, GFP_KERNEL);
455 if (ret) {
456 dev_err(rr3->dev, "narrow band urb failed: %d", ret);
457 return ret;
458 }
459
460 ret = usb_submit_urb(rr3->wide_urb, GFP_KERNEL);
461 if (ret)
462 dev_err(rr3->dev, "wide band urb failed: %d", ret);
463 463
464 return 0; 464 return ret;
465} 465}
466 466
467static inline void redrat3_delete(struct redrat3_dev *rr3, 467static inline void redrat3_delete(struct redrat3_dev *rr3,
468 struct usb_device *udev) 468 struct usb_device *udev)
469{ 469{
470 usb_kill_urb(rr3->read_urb); 470 usb_kill_urb(rr3->narrow_urb);
471 usb_kill_urb(rr3->wide_urb);
471 usb_kill_urb(rr3->flash_urb); 472 usb_kill_urb(rr3->flash_urb);
472 usb_free_urb(rr3->read_urb); 473 usb_kill_urb(rr3->learn_urb);
474 usb_free_urb(rr3->narrow_urb);
475 usb_free_urb(rr3->wide_urb);
473 usb_free_urb(rr3->flash_urb); 476 usb_free_urb(rr3->flash_urb);
474 usb_free_coherent(udev, le16_to_cpu(rr3->ep_in->wMaxPacketSize), 477 usb_free_urb(rr3->learn_urb);
478 usb_free_coherent(udev, le16_to_cpu(rr3->ep_narrow->wMaxPacketSize),
475 rr3->bulk_in_buf, rr3->dma_in); 479 rr3->bulk_in_buf, rr3->dma_in);
476 480
477 kfree(rr3); 481 kfree(rr3);
@@ -485,10 +489,8 @@ static u32 redrat3_get_timeout(struct redrat3_dev *rr3)
485 489
486 len = sizeof(*tmp); 490 len = sizeof(*tmp);
487 tmp = kzalloc(len, GFP_KERNEL); 491 tmp = kzalloc(len, GFP_KERNEL);
488 if (!tmp) { 492 if (!tmp)
489 dev_warn(rr3->dev, "Memory allocation faillure\n");
490 return timeout; 493 return timeout;
491 }
492 494
493 pipe = usb_rcvctrlpipe(rr3->udev, 0); 495 pipe = usb_rcvctrlpipe(rr3->udev, 0);
494 ret = usb_control_msg(rr3->udev, pipe, RR3_GET_IR_PARAM, 496 ret = usb_control_msg(rr3->udev, pipe, RR3_GET_IR_PARAM,
@@ -543,16 +545,14 @@ static void redrat3_reset(struct redrat3_dev *rr3)
543 struct device *dev = rr3->dev; 545 struct device *dev = rr3->dev;
544 int rc, rxpipe, txpipe; 546 int rc, rxpipe, txpipe;
545 u8 *val; 547 u8 *val;
546 int len = sizeof(u8); 548 size_t const len = sizeof(*val);
547 549
548 rxpipe = usb_rcvctrlpipe(udev, 0); 550 rxpipe = usb_rcvctrlpipe(udev, 0);
549 txpipe = usb_sndctrlpipe(udev, 0); 551 txpipe = usb_sndctrlpipe(udev, 0);
550 552
551 val = kmalloc(len, GFP_KERNEL); 553 val = kmalloc(len, GFP_KERNEL);
552 if (!val) { 554 if (!val)
553 dev_err(dev, "Memory allocation failure\n");
554 return; 555 return;
555 }
556 556
557 *val = 0x01; 557 *val = 0x01;
558 rc = usb_control_msg(udev, rxpipe, RR3_RESET, 558 rc = usb_control_msg(udev, rxpipe, RR3_RESET,
@@ -590,14 +590,12 @@ static void redrat3_reset(struct redrat3_dev *rr3)
590 590
591static void redrat3_get_firmware_rev(struct redrat3_dev *rr3) 591static void redrat3_get_firmware_rev(struct redrat3_dev *rr3)
592{ 592{
593 int rc = 0; 593 int rc;
594 char *buffer; 594 char *buffer;
595 595
596 buffer = kzalloc(sizeof(char) * (RR3_FW_VERSION_LEN + 1), GFP_KERNEL); 596 buffer = kcalloc(RR3_FW_VERSION_LEN + 1, sizeof(*buffer), GFP_KERNEL);
597 if (!buffer) { 597 if (!buffer)
598 dev_err(rr3->dev, "Memory allocation failure\n");
599 return; 598 return;
600 }
601 599
602 rc = usb_control_msg(rr3->udev, usb_rcvctrlpipe(rr3->udev, 0), 600 rc = usb_control_msg(rr3->udev, usb_rcvctrlpipe(rr3->udev, 0),
603 RR3_FW_VERSION, 601 RR3_FW_VERSION,
@@ -704,25 +702,25 @@ out:
704/* callback function from USB when async USB request has completed */ 702/* callback function from USB when async USB request has completed */
705static void redrat3_handle_async(struct urb *urb) 703static void redrat3_handle_async(struct urb *urb)
706{ 704{
707 struct redrat3_dev *rr3; 705 struct redrat3_dev *rr3 = urb->context;
708 int ret; 706 int ret;
709 707
710 if (!urb)
711 return;
712
713 rr3 = urb->context;
714 if (!rr3) {
715 pr_err("%s called with invalid context!\n", __func__);
716 usb_unlink_urb(urb);
717 return;
718 }
719
720 switch (urb->status) { 708 switch (urb->status) {
721 case 0: 709 case 0:
722 ret = redrat3_get_ir_data(rr3, urb->actual_length); 710 ret = redrat3_get_ir_data(rr3, urb->actual_length);
711 if (!ret && rr3->wideband && !rr3->learn_urb->hcpriv) {
712 ret = usb_submit_urb(rr3->learn_urb, GFP_ATOMIC);
713 if (ret)
714 dev_err(rr3->dev, "Failed to submit learning urb: %d",
715 ret);
716 }
717
723 if (!ret) { 718 if (!ret) {
724 /* no error, prepare to read more */ 719 /* no error, prepare to read more */
725 redrat3_issue_async(rr3); 720 ret = usb_submit_urb(urb, GFP_ATOMIC);
721 if (ret)
722 dev_err(rr3->dev, "Failed to resubmit urb: %d",
723 ret);
726 } 724 }
727 break; 725 break;
728 726
@@ -785,11 +783,11 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf,
785 /* rr3 will disable rc detector on transmit */ 783 /* rr3 will disable rc detector on transmit */
786 rr3->transmitting = true; 784 rr3->transmitting = true;
787 785
788 sample_lens = kzalloc(sizeof(int) * RR3_DRIVER_MAXLENS, GFP_KERNEL); 786 sample_lens = kcalloc(RR3_DRIVER_MAXLENS,
789 if (!sample_lens) { 787 sizeof(*sample_lens),
790 ret = -ENOMEM; 788 GFP_KERNEL);
791 goto out; 789 if (!sample_lens)
792 } 790 return -ENOMEM;
793 791
794 irdata = kzalloc(sizeof(*irdata), GFP_KERNEL); 792 irdata = kzalloc(sizeof(*irdata), GFP_KERNEL);
795 if (!irdata) { 793 if (!irdata) {
@@ -857,8 +855,8 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf,
857 ret = count; 855 ret = count;
858 856
859out: 857out:
860 kfree(sample_lens);
861 kfree(irdata); 858 kfree(irdata);
859 kfree(sample_lens);
862 860
863 rr3->transmitting = false; 861 rr3->transmitting = false;
864 /* rr3 re-enables rc detector because it was enabled before */ 862 /* rr3 re-enables rc detector because it was enabled before */
@@ -882,6 +880,42 @@ static void redrat3_brightness_set(struct led_classdev *led_dev, enum
882 } 880 }
883} 881}
884 882
883static int redrat3_wideband_receiver(struct rc_dev *rcdev, int enable)
884{
885 struct redrat3_dev *rr3 = rcdev->priv;
886 int ret = 0;
887
888 rr3->wideband = enable != 0;
889
890 if (enable) {
891 ret = usb_submit_urb(rr3->learn_urb, GFP_KERNEL);
892 if (ret)
893 dev_err(rr3->dev, "Failed to submit learning urb: %d",
894 ret);
895 }
896
897 return ret;
898}
899
900static void redrat3_learn_complete(struct urb *urb)
901{
902 struct redrat3_dev *rr3 = urb->context;
903
904 switch (urb->status) {
905 case 0:
906 break;
907 case -ECONNRESET:
908 case -ENOENT:
909 case -ESHUTDOWN:
910 usb_unlink_urb(urb);
911 return;
912 case -EPIPE:
913 default:
914 dev_err(rr3->dev, "Error: learn urb status = %d", urb->status);
915 break;
916 }
917}
918
885static void redrat3_led_complete(struct urb *urb) 919static void redrat3_led_complete(struct urb *urb)
886{ 920{
887 struct redrat3_dev *rr3 = urb->context; 921 struct redrat3_dev *rr3 = urb->context;
@@ -908,19 +942,16 @@ static struct rc_dev *redrat3_init_rc_dev(struct redrat3_dev *rr3)
908{ 942{
909 struct device *dev = rr3->dev; 943 struct device *dev = rr3->dev;
910 struct rc_dev *rc; 944 struct rc_dev *rc;
911 int ret = -ENODEV; 945 int ret;
912 u16 prod = le16_to_cpu(rr3->udev->descriptor.idProduct); 946 u16 prod = le16_to_cpu(rr3->udev->descriptor.idProduct);
913 947
914 rc = rc_allocate_device(); 948 rc = rc_allocate_device();
915 if (!rc) { 949 if (!rc)
916 dev_err(dev, "remote input dev allocation failed\n"); 950 return NULL;
917 goto out;
918 }
919 951
920 snprintf(rr3->name, sizeof(rr3->name), "RedRat3%s " 952 snprintf(rr3->name, sizeof(rr3->name),
921 "Infrared Remote Transceiver (%04x:%04x)", 953 "RedRat3%s Infrared Remote Transceiver",
922 prod == USB_RR3IIUSB_PRODUCT_ID ? "-II" : "", 954 prod == USB_RR3IIUSB_PRODUCT_ID ? "-II" : "");
923 le16_to_cpu(rr3->udev->descriptor.idVendor), prod);
924 955
925 usb_make_path(rr3->udev, rr3->phys, sizeof(rr3->phys)); 956 usb_make_path(rr3->udev, rr3->phys, sizeof(rr3->phys));
926 957
@@ -937,6 +968,7 @@ static struct rc_dev *redrat3_init_rc_dev(struct redrat3_dev *rr3)
937 rc->s_timeout = redrat3_set_timeout; 968 rc->s_timeout = redrat3_set_timeout;
938 rc->tx_ir = redrat3_transmit_ir; 969 rc->tx_ir = redrat3_transmit_ir;
939 rc->s_tx_carrier = redrat3_set_tx_carrier; 970 rc->s_tx_carrier = redrat3_set_tx_carrier;
971 rc->s_carrier_report = redrat3_wideband_receiver;
940 rc->driver_name = DRIVER_NAME; 972 rc->driver_name = DRIVER_NAME;
941 rc->rx_resolution = US_TO_NS(2); 973 rc->rx_resolution = US_TO_NS(2);
942 rc->map_name = RC_MAP_HAUPPAUGE; 974 rc->map_name = RC_MAP_HAUPPAUGE;
@@ -962,7 +994,8 @@ static int redrat3_dev_probe(struct usb_interface *intf,
962 struct usb_host_interface *uhi; 994 struct usb_host_interface *uhi;
963 struct redrat3_dev *rr3; 995 struct redrat3_dev *rr3;
964 struct usb_endpoint_descriptor *ep; 996 struct usb_endpoint_descriptor *ep;
965 struct usb_endpoint_descriptor *ep_in = NULL; 997 struct usb_endpoint_descriptor *ep_narrow = NULL;
998 struct usb_endpoint_descriptor *ep_wide = NULL;
966 struct usb_endpoint_descriptor *ep_out = NULL; 999 struct usb_endpoint_descriptor *ep_out = NULL;
967 u8 addr, attrs; 1000 u8 addr, attrs;
968 int pipe, i; 1001 int pipe, i;
@@ -976,15 +1009,16 @@ static int redrat3_dev_probe(struct usb_interface *intf,
976 addr = ep->bEndpointAddress; 1009 addr = ep->bEndpointAddress;
977 attrs = ep->bmAttributes; 1010 attrs = ep->bmAttributes;
978 1011
979 if ((ep_in == NULL) && 1012 if (((addr & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) &&
980 ((addr & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) &&
981 ((attrs & USB_ENDPOINT_XFERTYPE_MASK) == 1013 ((attrs & USB_ENDPOINT_XFERTYPE_MASK) ==
982 USB_ENDPOINT_XFER_BULK)) { 1014 USB_ENDPOINT_XFER_BULK)) {
983 dev_dbg(dev, "found bulk-in endpoint at 0x%02x\n", 1015 dev_dbg(dev, "found bulk-in endpoint at 0x%02x\n",
984 ep->bEndpointAddress); 1016 ep->bEndpointAddress);
985 /* data comes in on 0x82, 0x81 is for other data... */ 1017 /* data comes in on 0x82, 0x81 is for learning */
986 if (ep->bEndpointAddress == RR3_BULK_IN_EP_ADDR) 1018 if (ep->bEndpointAddress == RR3_NARROW_IN_EP_ADDR)
987 ep_in = ep; 1019 ep_narrow = ep;
1020 if (ep->bEndpointAddress == RR3_WIDE_IN_EP_ADDR)
1021 ep_wide = ep;
988 } 1022 }
989 1023
990 if ((ep_out == NULL) && 1024 if ((ep_out == NULL) &&
@@ -997,68 +1031,76 @@ static int redrat3_dev_probe(struct usb_interface *intf,
997 } 1031 }
998 } 1032 }
999 1033
1000 if (!ep_in || !ep_out) { 1034 if (!ep_narrow || !ep_out || !ep_wide) {
1001 dev_err(dev, "Couldn't find both in and out endpoints\n"); 1035 dev_err(dev, "Couldn't find all endpoints\n");
1002 retval = -ENODEV; 1036 retval = -ENODEV;
1003 goto no_endpoints; 1037 goto no_endpoints;
1004 } 1038 }
1005 1039
1006 /* allocate memory for our device state and initialize it */ 1040 /* allocate memory for our device state and initialize it */
1007 rr3 = kzalloc(sizeof(*rr3), GFP_KERNEL); 1041 rr3 = kzalloc(sizeof(*rr3), GFP_KERNEL);
1008 if (rr3 == NULL) { 1042 if (!rr3)
1009 dev_err(dev, "Memory allocation failure\n");
1010 goto no_endpoints; 1043 goto no_endpoints;
1011 }
1012 1044
1013 rr3->dev = &intf->dev; 1045 rr3->dev = &intf->dev;
1046 rr3->ep_narrow = ep_narrow;
1047 rr3->ep_out = ep_out;
1048 rr3->udev = udev;
1014 1049
1015 /* set up bulk-in endpoint */ 1050 /* set up bulk-in endpoint */
1016 rr3->read_urb = usb_alloc_urb(0, GFP_KERNEL); 1051 rr3->narrow_urb = usb_alloc_urb(0, GFP_KERNEL);
1017 if (!rr3->read_urb) 1052 if (!rr3->narrow_urb)
1018 goto error; 1053 goto redrat_free;
1019 1054
1020 rr3->ep_in = ep_in; 1055 rr3->wide_urb = usb_alloc_urb(0, GFP_KERNEL);
1021 rr3->bulk_in_buf = usb_alloc_coherent(udev, 1056 if (!rr3->wide_urb)
1022 le16_to_cpu(ep_in->wMaxPacketSize), GFP_KERNEL, &rr3->dma_in); 1057 goto redrat_free;
1023 if (!rr3->bulk_in_buf) {
1024 dev_err(dev, "Read buffer allocation failure\n");
1025 goto error;
1026 }
1027
1028 pipe = usb_rcvbulkpipe(udev, ep_in->bEndpointAddress);
1029 usb_fill_bulk_urb(rr3->read_urb, udev, pipe, rr3->bulk_in_buf,
1030 le16_to_cpu(ep_in->wMaxPacketSize), redrat3_handle_async, rr3);
1031 rr3->read_urb->transfer_dma = rr3->dma_in;
1032 rr3->read_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1033 1058
1034 rr3->ep_out = ep_out; 1059 rr3->bulk_in_buf = usb_alloc_coherent(udev,
1035 rr3->udev = udev; 1060 le16_to_cpu(ep_narrow->wMaxPacketSize),
1061 GFP_KERNEL, &rr3->dma_in);
1062 if (!rr3->bulk_in_buf)
1063 goto redrat_free;
1064
1065 pipe = usb_rcvbulkpipe(udev, ep_narrow->bEndpointAddress);
1066 usb_fill_bulk_urb(rr3->narrow_urb, udev, pipe, rr3->bulk_in_buf,
1067 le16_to_cpu(ep_narrow->wMaxPacketSize),
1068 redrat3_handle_async, rr3);
1069 rr3->narrow_urb->transfer_dma = rr3->dma_in;
1070 rr3->narrow_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1071
1072 pipe = usb_rcvbulkpipe(udev, ep_wide->bEndpointAddress);
1073 usb_fill_bulk_urb(rr3->wide_urb, udev, pipe, rr3->bulk_in_buf,
1074 le16_to_cpu(ep_narrow->wMaxPacketSize),
1075 redrat3_handle_async, rr3);
1076 rr3->wide_urb->transfer_dma = rr3->dma_in;
1077 rr3->wide_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1036 1078
1037 redrat3_reset(rr3); 1079 redrat3_reset(rr3);
1038 redrat3_get_firmware_rev(rr3); 1080 redrat3_get_firmware_rev(rr3);
1039 1081
1040 /* might be all we need to do? */
1041 retval = redrat3_enable_detector(rr3);
1042 if (retval < 0)
1043 goto error;
1044
1045 /* default.. will get overridden by any sends with a freq defined */ 1082 /* default.. will get overridden by any sends with a freq defined */
1046 rr3->carrier = 38000; 1083 rr3->carrier = 38000;
1047 1084
1048 /* led control */
1049 rr3->led.name = "redrat3:red:feedback";
1050 rr3->led.default_trigger = "rc-feedback";
1051 rr3->led.brightness_set = redrat3_brightness_set;
1052 retval = led_classdev_register(&intf->dev, &rr3->led);
1053 if (retval)
1054 goto error;
1055
1056 atomic_set(&rr3->flash, 0); 1085 atomic_set(&rr3->flash, 0);
1057 rr3->flash_urb = usb_alloc_urb(0, GFP_KERNEL); 1086 rr3->flash_urb = usb_alloc_urb(0, GFP_KERNEL);
1058 if (!rr3->flash_urb) { 1087 if (!rr3->flash_urb)
1059 retval = -ENOMEM; 1088 goto redrat_free;
1060 goto led_free_error; 1089
1061 } 1090 /* learn urb */
1091 rr3->learn_urb = usb_alloc_urb(0, GFP_KERNEL);
1092 if (!rr3->learn_urb)
1093 goto redrat_free;
1094
1095 /* setup packet is 'c0 b2 0000 0000 0001' */
1096 rr3->learn_control.bRequestType = 0xc0;
1097 rr3->learn_control.bRequest = RR3_MODSIG_CAPTURE;
1098 rr3->learn_control.wLength = cpu_to_le16(1);
1099
1100 usb_fill_control_urb(rr3->learn_urb, udev, usb_rcvctrlpipe(udev, 0),
1101 (unsigned char *)&rr3->learn_control,
1102 &rr3->learn_buf, sizeof(rr3->learn_buf),
1103 redrat3_learn_complete, rr3);
1062 1104
1063 /* setup packet is 'c0 b9 0000 0000 0001' */ 1105 /* setup packet is 'c0 b9 0000 0000 0001' */
1064 rr3->flash_control.bRequestType = 0xc0; 1106 rr3->flash_control.bRequestType = 0xc0;
@@ -1070,25 +1112,36 @@ static int redrat3_dev_probe(struct usb_interface *intf,
1070 &rr3->flash_in_buf, sizeof(rr3->flash_in_buf), 1112 &rr3->flash_in_buf, sizeof(rr3->flash_in_buf),
1071 redrat3_led_complete, rr3); 1113 redrat3_led_complete, rr3);
1072 1114
1115 /* led control */
1116 rr3->led.name = "redrat3:red:feedback";
1117 rr3->led.default_trigger = "rc-feedback";
1118 rr3->led.brightness_set = redrat3_brightness_set;
1119 retval = led_classdev_register(&intf->dev, &rr3->led);
1120 if (retval)
1121 goto redrat_free;
1122
1073 rr3->rc = redrat3_init_rc_dev(rr3); 1123 rr3->rc = redrat3_init_rc_dev(rr3);
1074 if (!rr3->rc) { 1124 if (!rr3->rc) {
1075 retval = -ENOMEM; 1125 retval = -ENOMEM;
1076 goto led_free_error; 1126 goto led_free;
1077 } 1127 }
1078 1128
1129 /* might be all we need to do? */
1130 retval = redrat3_enable_detector(rr3);
1131 if (retval < 0)
1132 goto led_free;
1133
1079 /* we can register the device now, as it is ready */ 1134 /* we can register the device now, as it is ready */
1080 usb_set_intfdata(intf, rr3); 1135 usb_set_intfdata(intf, rr3);
1081 1136
1082 return 0; 1137 return 0;
1083 1138
1084led_free_error: 1139led_free:
1085 led_classdev_unregister(&rr3->led); 1140 led_classdev_unregister(&rr3->led);
1086error: 1141redrat_free:
1087 redrat3_delete(rr3, rr3->udev); 1142 redrat3_delete(rr3, rr3->udev);
1088 1143
1089no_endpoints: 1144no_endpoints:
1090 dev_err(dev, "%s: retval = %x", __func__, retval);
1091
1092 return retval; 1145 return retval;
1093} 1146}
1094 1147
@@ -1097,9 +1150,6 @@ static void redrat3_dev_disconnect(struct usb_interface *intf)
1097 struct usb_device *udev = interface_to_usbdev(intf); 1150 struct usb_device *udev = interface_to_usbdev(intf);
1098 struct redrat3_dev *rr3 = usb_get_intfdata(intf); 1151 struct redrat3_dev *rr3 = usb_get_intfdata(intf);
1099 1152
1100 if (!rr3)
1101 return;
1102
1103 usb_set_intfdata(intf, NULL); 1153 usb_set_intfdata(intf, NULL);
1104 rc_unregister_device(rr3->rc); 1154 rc_unregister_device(rr3->rc);
1105 led_classdev_unregister(&rr3->led); 1155 led_classdev_unregister(&rr3->led);
@@ -1111,7 +1161,8 @@ static int redrat3_dev_suspend(struct usb_interface *intf, pm_message_t message)
1111 struct redrat3_dev *rr3 = usb_get_intfdata(intf); 1161 struct redrat3_dev *rr3 = usb_get_intfdata(intf);
1112 1162
1113 led_classdev_suspend(&rr3->led); 1163 led_classdev_suspend(&rr3->led);
1114 usb_kill_urb(rr3->read_urb); 1164 usb_kill_urb(rr3->narrow_urb);
1165 usb_kill_urb(rr3->wide_urb);
1115 usb_kill_urb(rr3->flash_urb); 1166 usb_kill_urb(rr3->flash_urb);
1116 return 0; 1167 return 0;
1117} 1168}
@@ -1120,7 +1171,9 @@ static int redrat3_dev_resume(struct usb_interface *intf)
1120{ 1171{
1121 struct redrat3_dev *rr3 = usb_get_intfdata(intf); 1172 struct redrat3_dev *rr3 = usb_get_intfdata(intf);
1122 1173
1123 if (usb_submit_urb(rr3->read_urb, GFP_ATOMIC)) 1174 if (usb_submit_urb(rr3->narrow_urb, GFP_ATOMIC))
1175 return -EIO;
1176 if (usb_submit_urb(rr3->wide_urb, GFP_ATOMIC))
1124 return -EIO; 1177 return -EIO;
1125 led_classdev_resume(&rr3->led); 1178 led_classdev_resume(&rr3->led);
1126 return 0; 1179 return 0;
diff --git a/drivers/media/rc/serial_ir.c b/drivers/media/rc/serial_ir.c
new file mode 100644
index 000000000000..436bd58b5f05
--- /dev/null
+++ b/drivers/media/rc/serial_ir.c
@@ -0,0 +1,844 @@
1/*
2 * serial_ir.c
3 *
4 * serial_ir - Device driver that records pulse- and pause-lengths
5 * (space-lengths) between DDCD event on a serial port.
6 *
7 * Copyright (C) 1996,97 Ralph Metzler <rjkm@thp.uni-koeln.de>
8 * Copyright (C) 1998 Trent Piepho <xyzzy@u.washington.edu>
9 * Copyright (C) 1998 Ben Pfaff <blp@gnu.org>
10 * Copyright (C) 1999 Christoph Bartelmus <lirc@bartelmus.de>
11 * Copyright (C) 2007 Andrei Tanas <andrei@tanas.ca> (suspend/resume support)
12 * Copyright (C) 2016 Sean Young <sean@mess.org> (port to rc-core)
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 */
23
24#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25
26#include <linux/module.h>
27#include <linux/errno.h>
28#include <linux/interrupt.h>
29#include <linux/kernel.h>
30#include <linux/serial_reg.h>
31#include <linux/types.h>
32#include <linux/delay.h>
33#include <linux/platform_device.h>
34#include <linux/spinlock.h>
35#include <media/rc-core.h>
36
37struct serial_ir_hw {
38 int signal_pin;
39 int signal_pin_change;
40 u8 on;
41 u8 off;
42 unsigned set_send_carrier:1;
43 unsigned set_duty_cycle:1;
44 void (*send_pulse)(unsigned int length, ktime_t edge);
45 void (*send_space)(void);
46 spinlock_t lock;
47};
48
49#define IR_HOMEBREW 0
50#define IR_IRDEO 1
51#define IR_IRDEO_REMOTE 2
52#define IR_ANIMAX 3
53#define IR_IGOR 4
54
55/* module parameters */
56static int type;
57static int io;
58static int irq;
59static bool iommap;
60static int ioshift;
61static bool softcarrier = true;
62static bool share_irq;
63static int sense = -1; /* -1 = auto, 0 = active high, 1 = active low */
64static bool txsense; /* 0 = active high, 1 = active low */
65
66/* forward declarations */
67static void send_pulse_irdeo(unsigned int length, ktime_t edge);
68static void send_space_irdeo(void);
69#ifdef CONFIG_IR_SERIAL_TRANSMITTER
70static void send_pulse_homebrew(unsigned int length, ktime_t edge);
71static void send_space_homebrew(void);
72#endif
73
74static struct serial_ir_hw hardware[] = {
75 [IR_HOMEBREW] = {
76 .lock = __SPIN_LOCK_UNLOCKED(hardware[IR_HOMEBREW].lock),
77 .signal_pin = UART_MSR_DCD,
78 .signal_pin_change = UART_MSR_DDCD,
79 .on = (UART_MCR_RTS | UART_MCR_OUT2 | UART_MCR_DTR),
80 .off = (UART_MCR_RTS | UART_MCR_OUT2),
81#ifdef CONFIG_IR_SERIAL_TRANSMITTER
82 .send_pulse = send_pulse_homebrew,
83 .send_space = send_space_homebrew,
84 .set_send_carrier = true,
85 .set_duty_cycle = true,
86#endif
87 },
88
89 [IR_IRDEO] = {
90 .lock = __SPIN_LOCK_UNLOCKED(hardware[IR_IRDEO].lock),
91 .signal_pin = UART_MSR_DSR,
92 .signal_pin_change = UART_MSR_DDSR,
93 .on = UART_MCR_OUT2,
94 .off = (UART_MCR_RTS | UART_MCR_DTR | UART_MCR_OUT2),
95 .send_pulse = send_pulse_irdeo,
96 .send_space = send_space_irdeo,
97 .set_duty_cycle = true,
98 },
99
100 [IR_IRDEO_REMOTE] = {
101 .lock = __SPIN_LOCK_UNLOCKED(hardware[IR_IRDEO_REMOTE].lock),
102 .signal_pin = UART_MSR_DSR,
103 .signal_pin_change = UART_MSR_DDSR,
104 .on = (UART_MCR_RTS | UART_MCR_DTR | UART_MCR_OUT2),
105 .off = (UART_MCR_RTS | UART_MCR_DTR | UART_MCR_OUT2),
106 .send_pulse = send_pulse_irdeo,
107 .send_space = send_space_irdeo,
108 .set_duty_cycle = true,
109 },
110
111 [IR_ANIMAX] = {
112 .lock = __SPIN_LOCK_UNLOCKED(hardware[IR_ANIMAX].lock),
113 .signal_pin = UART_MSR_DCD,
114 .signal_pin_change = UART_MSR_DDCD,
115 .on = 0,
116 .off = (UART_MCR_RTS | UART_MCR_DTR | UART_MCR_OUT2),
117 },
118
119 [IR_IGOR] = {
120 .lock = __SPIN_LOCK_UNLOCKED(hardware[IR_IGOR].lock),
121 .signal_pin = UART_MSR_DSR,
122 .signal_pin_change = UART_MSR_DDSR,
123 .on = (UART_MCR_RTS | UART_MCR_OUT2 | UART_MCR_DTR),
124 .off = (UART_MCR_RTS | UART_MCR_OUT2),
125#ifdef CONFIG_IR_SERIAL_TRANSMITTER
126 .send_pulse = send_pulse_homebrew,
127 .send_space = send_space_homebrew,
128 .set_send_carrier = true,
129 .set_duty_cycle = true,
130#endif
131 },
132};
133
134#define RS_ISR_PASS_LIMIT 256
135
136struct serial_ir {
137 ktime_t lastkt;
138 struct rc_dev *rcdev;
139 struct platform_device *pdev;
140
141 unsigned int freq;
142 unsigned int duty_cycle;
143
144 unsigned int pulse_width, space_width;
145};
146
147static struct serial_ir serial_ir;
148
149/* fetch serial input packet (1 byte) from register offset */
150static u8 sinp(int offset)
151{
152 if (iommap)
153 /* the register is memory-mapped */
154 offset <<= ioshift;
155
156 return inb(io + offset);
157}
158
159/* write serial output packet (1 byte) of value to register offset */
160static void soutp(int offset, u8 value)
161{
162 if (iommap)
163 /* the register is memory-mapped */
164 offset <<= ioshift;
165
166 outb(value, io + offset);
167}
168
169static void on(void)
170{
171 if (txsense)
172 soutp(UART_MCR, hardware[type].off);
173 else
174 soutp(UART_MCR, hardware[type].on);
175}
176
177static void off(void)
178{
179 if (txsense)
180 soutp(UART_MCR, hardware[type].on);
181 else
182 soutp(UART_MCR, hardware[type].off);
183}
184
185static void init_timing_params(unsigned int new_duty_cycle,
186 unsigned int new_freq)
187{
188 serial_ir.duty_cycle = new_duty_cycle;
189 serial_ir.freq = new_freq;
190
191 serial_ir.pulse_width = DIV_ROUND_CLOSEST(
192 new_duty_cycle * NSEC_PER_SEC, new_freq * 100l);
193 serial_ir.space_width = DIV_ROUND_CLOSEST(
194 (100l - new_duty_cycle) * NSEC_PER_SEC, new_freq * 100l);
195}
196
197static void send_pulse_irdeo(unsigned int length, ktime_t target)
198{
199 long rawbits;
200 int i;
201 unsigned char output;
202 unsigned char chunk, shifted;
203
204 /* how many bits have to be sent ? */
205 rawbits = length * 1152 / 10000;
206 if (serial_ir.duty_cycle > 50)
207 chunk = 3;
208 else
209 chunk = 1;
210 for (i = 0, output = 0x7f; rawbits > 0; rawbits -= 3) {
211 shifted = chunk << (i * 3);
212 shifted >>= 1;
213 output &= (~shifted);
214 i++;
215 if (i == 3) {
216 soutp(UART_TX, output);
217 while (!(sinp(UART_LSR) & UART_LSR_THRE))
218 ;
219 output = 0x7f;
220 i = 0;
221 }
222 }
223 if (i != 0) {
224 soutp(UART_TX, output);
225 while (!(sinp(UART_LSR) & UART_LSR_TEMT))
226 ;
227 }
228}
229
230static void send_space_irdeo(void)
231{
232}
233
234#ifdef CONFIG_IR_SERIAL_TRANSMITTER
235static void send_pulse_homebrew_softcarrier(unsigned int length, ktime_t edge)
236{
237 ktime_t now, target = ktime_add_us(edge, length);
238 /*
239 * delta should never exceed 4 seconds and on m68k
240 * ndelay(s64) does not compile; so use s32 rather than s64.
241 */
242 s32 delta;
243
244 for (;;) {
245 now = ktime_get();
246 if (ktime_compare(now, target) >= 0)
247 break;
248 on();
249 edge = ktime_add_ns(edge, serial_ir.pulse_width);
250 delta = ktime_to_ns(ktime_sub(edge, now));
251 if (delta > 0)
252 ndelay(delta);
253 now = ktime_get();
254 off();
255 if (ktime_compare(now, target) >= 0)
256 break;
257 edge = ktime_add_ns(edge, serial_ir.space_width);
258 delta = ktime_to_ns(ktime_sub(edge, now));
259 if (delta > 0)
260 ndelay(delta);
261 }
262}
263
264static void send_pulse_homebrew(unsigned int length, ktime_t edge)
265{
266 if (softcarrier)
267 send_pulse_homebrew_softcarrier(length, edge);
268 else
269 on();
270}
271
272static void send_space_homebrew(void)
273{
274 off();
275}
276#endif
277
278static void frbwrite(unsigned int l, bool is_pulse)
279{
280 /* simple noise filter */
281 static unsigned int ptr, pulse, space;
282 DEFINE_IR_RAW_EVENT(ev);
283
284 if (ptr > 0 && is_pulse) {
285 pulse += l;
286 if (pulse > 250000) {
287 ev.duration = space;
288 ev.pulse = false;
289 ir_raw_event_store_with_filter(serial_ir.rcdev, &ev);
290 ev.duration = pulse;
291 ev.pulse = true;
292 ir_raw_event_store_with_filter(serial_ir.rcdev, &ev);
293 ptr = 0;
294 pulse = 0;
295 }
296 return;
297 }
298 if (!is_pulse) {
299 if (ptr == 0) {
300 if (l > 20000000) {
301 space = l;
302 ptr++;
303 return;
304 }
305 } else {
306 if (l > 20000000) {
307 space += pulse;
308 if (space > IR_MAX_DURATION)
309 space = IR_MAX_DURATION;
310 space += l;
311 if (space > IR_MAX_DURATION)
312 space = IR_MAX_DURATION;
313 pulse = 0;
314 return;
315 }
316
317 ev.duration = space;
318 ev.pulse = false;
319 ir_raw_event_store_with_filter(serial_ir.rcdev, &ev);
320 ev.duration = pulse;
321 ev.pulse = true;
322 ir_raw_event_store_with_filter(serial_ir.rcdev, &ev);
323 ptr = 0;
324 pulse = 0;
325 }
326 }
327
328 ev.duration = l;
329 ev.pulse = is_pulse;
330 ir_raw_event_store_with_filter(serial_ir.rcdev, &ev);
331}
332
333static irqreturn_t serial_ir_irq_handler(int i, void *blah)
334{
335 ktime_t kt;
336 int counter, dcd;
337 u8 status;
338 ktime_t delkt;
339 unsigned int data;
340 static int last_dcd = -1;
341
342 if ((sinp(UART_IIR) & UART_IIR_NO_INT)) {
343 /* not our interrupt */
344 return IRQ_NONE;
345 }
346
347 counter = 0;
348 do {
349 counter++;
350 status = sinp(UART_MSR);
351 if (counter > RS_ISR_PASS_LIMIT) {
352 dev_err(&serial_ir.pdev->dev, "Trapped in interrupt");
353 break;
354 }
355 if ((status & hardware[type].signal_pin_change) &&
356 sense != -1) {
357 /* get current time */
358 kt = ktime_get();
359
360 /*
361 * The driver needs to know if your receiver is
362 * active high or active low, or the space/pulse
363 * sense could be inverted.
364 */
365
366 /* calc time since last interrupt in nanoseconds */
367 dcd = (status & hardware[type].signal_pin) ? 1 : 0;
368
369 if (dcd == last_dcd) {
370 dev_err(&serial_ir.pdev->dev,
371 "ignoring spike: %d %d %lldns %lldns\n",
372 dcd, sense, ktime_to_ns(kt),
373 ktime_to_ns(serial_ir.lastkt));
374 continue;
375 }
376
377 delkt = ktime_sub(kt, serial_ir.lastkt);
378 if (ktime_compare(delkt, ktime_set(15, 0)) > 0) {
379 data = IR_MAX_DURATION; /* really long time */
380 if (!(dcd ^ sense)) {
381 /* sanity check */
382 dev_err(&serial_ir.pdev->dev,
383 "dcd unexpected: %d %d %lldns %lldns\n",
384 dcd, sense, ktime_to_ns(kt),
385 ktime_to_ns(serial_ir.lastkt));
386 /*
387 * detecting pulse while this
388 * MUST be a space!
389 */
390 sense = sense ? 0 : 1;
391 }
392 } else {
393 data = ktime_to_ns(delkt);
394 }
395 frbwrite(data, !(dcd ^ sense));
396 serial_ir.lastkt = kt;
397 last_dcd = dcd;
398 ir_raw_event_handle(serial_ir.rcdev);
399 }
400 } while (!(sinp(UART_IIR) & UART_IIR_NO_INT)); /* still pending ? */
401 return IRQ_HANDLED;
402}
403
404static int hardware_init_port(void)
405{
406 u8 scratch, scratch2, scratch3;
407
408 /*
409 * This is a simple port existence test, borrowed from the autoconfig
410 * function in drivers/tty/serial/8250/8250_port.c
411 */
412 scratch = sinp(UART_IER);
413 soutp(UART_IER, 0);
414#ifdef __i386__
415 outb(0xff, 0x080);
416#endif
417 scratch2 = sinp(UART_IER) & 0x0f;
418 soutp(UART_IER, 0x0f);
419#ifdef __i386__
420 outb(0x00, 0x080);
421#endif
422 scratch3 = sinp(UART_IER) & 0x0f;
423 soutp(UART_IER, scratch);
424 if (scratch2 != 0 || scratch3 != 0x0f) {
425 /* we fail, there's nothing here */
426 pr_err("port existence test failed, cannot continue\n");
427 return -ENODEV;
428 }
429
430 /* Set DLAB 0. */
431 soutp(UART_LCR, sinp(UART_LCR) & (~UART_LCR_DLAB));
432
433 /* First of all, disable all interrupts */
434 soutp(UART_IER, sinp(UART_IER) &
435 (~(UART_IER_MSI | UART_IER_RLSI | UART_IER_THRI | UART_IER_RDI)));
436
437 /* Clear registers. */
438 sinp(UART_LSR);
439 sinp(UART_RX);
440 sinp(UART_IIR);
441 sinp(UART_MSR);
442
443 /* Set line for power source */
444 off();
445
446 /* Clear registers again to be sure. */
447 sinp(UART_LSR);
448 sinp(UART_RX);
449 sinp(UART_IIR);
450 sinp(UART_MSR);
451
452 switch (type) {
453 case IR_IRDEO:
454 case IR_IRDEO_REMOTE:
455 /* setup port to 7N1 @ 115200 Baud */
456 /* 7N1+start = 9 bits at 115200 ~ 3 bits at 38kHz */
457
458 /* Set DLAB 1. */
459 soutp(UART_LCR, sinp(UART_LCR) | UART_LCR_DLAB);
460 /* Set divisor to 1 => 115200 Baud */
461 soutp(UART_DLM, 0);
462 soutp(UART_DLL, 1);
463 /* Set DLAB 0 + 7N1 */
464 soutp(UART_LCR, UART_LCR_WLEN7);
465 /* THR interrupt already disabled at this point */
466 break;
467 default:
468 break;
469 }
470
471 return 0;
472}
473
474static int serial_ir_probe(struct platform_device *dev)
475{
476 int i, nlow, nhigh, result;
477
478 result = devm_request_irq(&dev->dev, irq, serial_ir_irq_handler,
479 share_irq ? IRQF_SHARED : 0,
480 KBUILD_MODNAME, &hardware);
481 if (result < 0) {
482 if (result == -EBUSY)
483 dev_err(&dev->dev, "IRQ %d busy\n", irq);
484 else if (result == -EINVAL)
485 dev_err(&dev->dev, "Bad irq number or handler\n");
486 return result;
487 }
488
489 /* Reserve io region. */
490 if ((iommap &&
491 (devm_request_mem_region(&dev->dev, iommap, 8 << ioshift,
492 KBUILD_MODNAME) == NULL)) ||
493 (!iommap && (devm_request_region(&dev->dev, io, 8,
494 KBUILD_MODNAME) == NULL))) {
495 dev_err(&dev->dev, "port %04x already in use\n", io);
496 dev_warn(&dev->dev, "use 'setserial /dev/ttySX uart none'\n");
497 dev_warn(&dev->dev,
498 "or compile the serial port driver as module and\n");
499 dev_warn(&dev->dev, "make sure this module is loaded first\n");
500 return -EBUSY;
501 }
502
503 result = hardware_init_port();
504 if (result < 0)
505 return result;
506
507 /* Initialize pulse/space widths */
508 init_timing_params(50, 38000);
509
510 /* If pin is high, then this must be an active low receiver. */
511 if (sense == -1) {
512 /* wait 1/2 sec for the power supply */
513 msleep(500);
514
515 /*
516 * probe 9 times every 0.04s, collect "votes" for
517 * active high/low
518 */
519 nlow = 0;
520 nhigh = 0;
521 for (i = 0; i < 9; i++) {
522 if (sinp(UART_MSR) & hardware[type].signal_pin)
523 nlow++;
524 else
525 nhigh++;
526 msleep(40);
527 }
528 sense = nlow >= nhigh ? 1 : 0;
529 dev_info(&dev->dev, "auto-detected active %s receiver\n",
530 sense ? "low" : "high");
531 } else
532 dev_info(&dev->dev, "Manually using active %s receiver\n",
533 sense ? "low" : "high");
534
535 dev_dbg(&dev->dev, "Interrupt %d, port %04x obtained\n", irq, io);
536 return 0;
537}
538
539static int serial_ir_open(struct rc_dev *rcdev)
540{
541 unsigned long flags;
542
543 /* initialize timestamp */
544 serial_ir.lastkt = ktime_get();
545
546 spin_lock_irqsave(&hardware[type].lock, flags);
547
548 /* Set DLAB 0. */
549 soutp(UART_LCR, sinp(UART_LCR) & (~UART_LCR_DLAB));
550
551 soutp(UART_IER, sinp(UART_IER) | UART_IER_MSI);
552
553 spin_unlock_irqrestore(&hardware[type].lock, flags);
554
555 return 0;
556}
557
558static void serial_ir_close(struct rc_dev *rcdev)
559{
560 unsigned long flags;
561
562 spin_lock_irqsave(&hardware[type].lock, flags);
563
564 /* Set DLAB 0. */
565 soutp(UART_LCR, sinp(UART_LCR) & (~UART_LCR_DLAB));
566
567 /* First of all, disable all interrupts */
568 soutp(UART_IER, sinp(UART_IER) &
569 (~(UART_IER_MSI | UART_IER_RLSI | UART_IER_THRI | UART_IER_RDI)));
570 spin_unlock_irqrestore(&hardware[type].lock, flags);
571}
572
573static int serial_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
574 unsigned int count)
575{
576 unsigned long flags;
577 ktime_t edge;
578 s64 delta;
579 int i;
580
581 spin_lock_irqsave(&hardware[type].lock, flags);
582 if (type == IR_IRDEO) {
583 /* DTR, RTS down */
584 on();
585 }
586
587 edge = ktime_get();
588 for (i = 0; i < count; i++) {
589 if (i % 2)
590 hardware[type].send_space();
591 else
592 hardware[type].send_pulse(txbuf[i], edge);
593
594 edge = ktime_add_us(edge, txbuf[i]);
595 delta = ktime_us_delta(edge, ktime_get());
596 if (delta > 25) {
597 spin_unlock_irqrestore(&hardware[type].lock, flags);
598 usleep_range(delta - 25, delta + 25);
599 spin_lock_irqsave(&hardware[type].lock, flags);
600 } else if (delta > 0) {
601 udelay(delta);
602 }
603 }
604 off();
605 spin_unlock_irqrestore(&hardware[type].lock, flags);
606 return count;
607}
608
609static int serial_ir_tx_duty_cycle(struct rc_dev *dev, u32 cycle)
610{
611 init_timing_params(cycle, serial_ir.freq);
612 return 0;
613}
614
615static int serial_ir_tx_carrier(struct rc_dev *dev, u32 carrier)
616{
617 if (carrier > 500000 || carrier < 20000)
618 return -EINVAL;
619
620 init_timing_params(serial_ir.duty_cycle, carrier);
621 return 0;
622}
623
624static int serial_ir_suspend(struct platform_device *dev,
625 pm_message_t state)
626{
627 /* Set DLAB 0. */
628 soutp(UART_LCR, sinp(UART_LCR) & (~UART_LCR_DLAB));
629
630 /* Disable all interrupts */
631 soutp(UART_IER, sinp(UART_IER) &
632 (~(UART_IER_MSI | UART_IER_RLSI | UART_IER_THRI | UART_IER_RDI)));
633
634 /* Clear registers. */
635 sinp(UART_LSR);
636 sinp(UART_RX);
637 sinp(UART_IIR);
638 sinp(UART_MSR);
639
640 return 0;
641}
642
643static int serial_ir_resume(struct platform_device *dev)
644{
645 unsigned long flags;
646 int result;
647
648 result = hardware_init_port();
649 if (result < 0)
650 return result;
651
652 spin_lock_irqsave(&hardware[type].lock, flags);
653 /* Enable Interrupt */
654 serial_ir.lastkt = ktime_get();
655 soutp(UART_IER, sinp(UART_IER) | UART_IER_MSI);
656 off();
657
658 spin_unlock_irqrestore(&hardware[type].lock, flags);
659
660 return 0;
661}
662
663static struct platform_driver serial_ir_driver = {
664 .probe = serial_ir_probe,
665 .suspend = serial_ir_suspend,
666 .resume = serial_ir_resume,
667 .driver = {
668 .name = "serial_ir",
669 },
670};
671
672static int __init serial_ir_init(void)
673{
674 int result;
675
676 result = platform_driver_register(&serial_ir_driver);
677 if (result)
678 return result;
679
680 serial_ir.pdev = platform_device_alloc("serial_ir", 0);
681 if (!serial_ir.pdev) {
682 result = -ENOMEM;
683 goto exit_driver_unregister;
684 }
685
686 result = platform_device_add(serial_ir.pdev);
687 if (result)
688 goto exit_device_put;
689
690 return 0;
691
692exit_device_put:
693 platform_device_put(serial_ir.pdev);
694exit_driver_unregister:
695 platform_driver_unregister(&serial_ir_driver);
696 return result;
697}
698
699static void serial_ir_exit(void)
700{
701 platform_device_unregister(serial_ir.pdev);
702 platform_driver_unregister(&serial_ir_driver);
703}
704
705static int __init serial_ir_init_module(void)
706{
707 struct rc_dev *rcdev;
708 int result;
709
710 switch (type) {
711 case IR_HOMEBREW:
712 case IR_IRDEO:
713 case IR_IRDEO_REMOTE:
714 case IR_ANIMAX:
715 case IR_IGOR:
716 /* if nothing specified, use ttyS0/com1 and irq 4 */
717 io = io ? io : 0x3f8;
718 irq = irq ? irq : 4;
719 break;
720 default:
721 return -EINVAL;
722 }
723 if (!softcarrier) {
724 switch (type) {
725 case IR_HOMEBREW:
726 case IR_IGOR:
727 hardware[type].set_send_carrier = false;
728 hardware[type].set_duty_cycle = false;
729 break;
730 }
731 }
732
733 /* make sure sense is either -1, 0, or 1 */
734 if (sense != -1)
735 sense = !!sense;
736
737 result = serial_ir_init();
738 if (result)
739 return result;
740
741 rcdev = devm_rc_allocate_device(&serial_ir.pdev->dev);
742 if (!rcdev) {
743 result = -ENOMEM;
744 goto serial_cleanup;
745 }
746
747 if (hardware[type].send_pulse && hardware[type].send_space)
748 rcdev->tx_ir = serial_ir_tx;
749 if (hardware[type].set_send_carrier)
750 rcdev->s_tx_carrier = serial_ir_tx_carrier;
751 if (hardware[type].set_duty_cycle)
752 rcdev->s_tx_duty_cycle = serial_ir_tx_duty_cycle;
753
754 switch (type) {
755 case IR_HOMEBREW:
756 rcdev->input_name = "Serial IR type home-brew";
757 break;
758 case IR_IRDEO:
759 rcdev->input_name = "Serial IR type IRdeo";
760 break;
761 case IR_IRDEO_REMOTE:
762 rcdev->input_name = "Serial IR type IRdeo remote";
763 break;
764 case IR_ANIMAX:
765 rcdev->input_name = "Serial IR type AnimaX";
766 break;
767 case IR_IGOR:
768 rcdev->input_name = "Serial IR type IgorPlug";
769 break;
770 }
771
772 rcdev->input_phys = KBUILD_MODNAME "/input0";
773 rcdev->input_id.bustype = BUS_HOST;
774 rcdev->input_id.vendor = 0x0001;
775 rcdev->input_id.product = 0x0001;
776 rcdev->input_id.version = 0x0100;
777 rcdev->open = serial_ir_open;
778 rcdev->close = serial_ir_close;
779 rcdev->dev.parent = &serial_ir.pdev->dev;
780 rcdev->driver_type = RC_DRIVER_IR_RAW;
781 rcdev->allowed_protocols = RC_BIT_ALL;
782 rcdev->driver_name = KBUILD_MODNAME;
783 rcdev->map_name = RC_MAP_RC6_MCE;
784 rcdev->timeout = IR_DEFAULT_TIMEOUT;
785 rcdev->rx_resolution = 250000;
786
787 serial_ir.rcdev = rcdev;
788
789 result = rc_register_device(rcdev);
790
791 if (!result)
792 return 0;
793serial_cleanup:
794 serial_ir_exit();
795 return result;
796}
797
798static void __exit serial_ir_exit_module(void)
799{
800 rc_unregister_device(serial_ir.rcdev);
801 serial_ir_exit();
802}
803
804module_init(serial_ir_init_module);
805module_exit(serial_ir_exit_module);
806
807MODULE_DESCRIPTION("Infra-red receiver driver for serial ports.");
808MODULE_AUTHOR("Ralph Metzler, Trent Piepho, Ben Pfaff, Christoph Bartelmus, Andrei Tanas");
809MODULE_LICENSE("GPL");
810
811module_param(type, int, 0444);
812MODULE_PARM_DESC(type, "Hardware type (0 = home-brew, 1 = IRdeo, 2 = IRdeo Remote, 3 = AnimaX, 4 = IgorPlug");
813
814module_param(io, int, 0444);
815MODULE_PARM_DESC(io, "I/O address base (0x3f8 or 0x2f8)");
816
817/* some architectures (e.g. intel xscale) have memory mapped registers */
818module_param(iommap, bool, 0444);
819MODULE_PARM_DESC(iommap, "physical base for memory mapped I/O (0 = no memory mapped io)");
820
821/*
822 * some architectures (e.g. intel xscale) align the 8bit serial registers
823 * on 32bit word boundaries.
824 * See linux-kernel/drivers/tty/serial/8250/8250.c serial_in()/out()
825 */
826module_param(ioshift, int, 0444);
827MODULE_PARM_DESC(ioshift, "shift I/O register offset (0 = no shift)");
828
829module_param(irq, int, 0444);
830MODULE_PARM_DESC(irq, "Interrupt (4 or 3)");
831
832module_param(share_irq, bool, 0444);
833MODULE_PARM_DESC(share_irq, "Share interrupts (0 = off, 1 = on)");
834
835module_param(sense, int, 0444);
836MODULE_PARM_DESC(sense, "Override autodetection of IR receiver circuit (0 = active high, 1 = active low )");
837
838#ifdef CONFIG_IR_SERIAL_TRANSMITTER
839module_param(txsense, bool, 0444);
840MODULE_PARM_DESC(txsense, "Sense of transmitter circuit (0 = active high, 1 = active low )");
841#endif
842
843module_param(softcarrier, bool, 0444);
844MODULE_PARM_DESC(softcarrier, "Software carrier (0 = off, 1 = on, default on)");
diff --git a/drivers/media/rc/streamzap.c b/drivers/media/rc/streamzap.c
index 4004260a7c69..53f9b0af358a 100644
--- a/drivers/media/rc/streamzap.c
+++ b/drivers/media/rc/streamzap.c
@@ -297,8 +297,7 @@ static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz)
297 goto out; 297 goto out;
298 } 298 }
299 299
300 snprintf(sz->name, sizeof(sz->name), "Streamzap PC Remote Infrared " 300 snprintf(sz->name, sizeof(sz->name), "Streamzap PC Remote Infrared Receiver (%04x:%04x)",
301 "Receiver (%04x:%04x)",
302 le16_to_cpu(sz->usbdev->descriptor.idVendor), 301 le16_to_cpu(sz->usbdev->descriptor.idVendor),
303 le16_to_cpu(sz->usbdev->descriptor.idProduct)); 302 le16_to_cpu(sz->usbdev->descriptor.idProduct));
304 usb_make_path(sz->usbdev, sz->phys, sizeof(sz->phys)); 303 usb_make_path(sz->usbdev, sz->phys, sizeof(sz->phys));
@@ -364,15 +363,15 @@ static int streamzap_probe(struct usb_interface *intf,
364 363
365 sz->endpoint = &(iface_host->endpoint[0].desc); 364 sz->endpoint = &(iface_host->endpoint[0].desc);
366 if (!usb_endpoint_dir_in(sz->endpoint)) { 365 if (!usb_endpoint_dir_in(sz->endpoint)) {
367 dev_err(&intf->dev, "%s: endpoint doesn't match input device " 366 dev_err(&intf->dev, "%s: endpoint doesn't match input device 02%02x\n",
368 "02%02x\n", __func__, sz->endpoint->bEndpointAddress); 367 __func__, sz->endpoint->bEndpointAddress);
369 retval = -ENODEV; 368 retval = -ENODEV;
370 goto free_sz; 369 goto free_sz;
371 } 370 }
372 371
373 if (!usb_endpoint_xfer_int(sz->endpoint)) { 372 if (!usb_endpoint_xfer_int(sz->endpoint)) {
374 dev_err(&intf->dev, "%s: endpoint attributes don't match xfer " 373 dev_err(&intf->dev, "%s: endpoint attributes don't match xfer 02%02x\n",
375 "02%02x\n", __func__, sz->endpoint->bmAttributes); 374 __func__, sz->endpoint->bmAttributes);
376 retval = -ENODEV; 375 retval = -ENODEV;
377 goto free_sz; 376 goto free_sz;
378 } 377 }
diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c
index 95ae60e659a1..78491ed48d92 100644
--- a/drivers/media/rc/winbond-cir.c
+++ b/drivers/media/rc/winbond-cir.c
@@ -227,8 +227,7 @@ struct wbcir_data {
227 227
228static enum wbcir_protocol protocol = IR_PROTOCOL_RC6; 228static enum wbcir_protocol protocol = IR_PROTOCOL_RC6;
229module_param(protocol, uint, 0444); 229module_param(protocol, uint, 0444);
230MODULE_PARM_DESC(protocol, "IR protocol to use for the power-on command " 230MODULE_PARM_DESC(protocol, "IR protocol to use for the power-on command (0 = RC5, 1 = NEC, 2 = RC6A, default)");
231 "(0 = RC5, 1 = NEC, 2 = RC6A, default)");
232 231
233static bool invert; /* default = 0 */ 232static bool invert; /* default = 0 */
234module_param(invert, bool, 0444); 233module_param(invert, bool, 0444);
@@ -244,8 +243,7 @@ MODULE_PARM_DESC(wake_sc, "Scancode of the power-on IR command");
244 243
245static unsigned int wake_rc6mode = 6; 244static unsigned int wake_rc6mode = 6;
246module_param(wake_rc6mode, uint, 0644); 245module_param(wake_rc6mode, uint, 0644);
247MODULE_PARM_DESC(wake_rc6mode, "RC6 mode for the power-on command " 246MODULE_PARM_DESC(wake_rc6mode, "RC6 mode for the power-on command (0 = 0, 6 = 6A, default)");
248 "(0 = 0, 6 = 6A, default)");
249 247
250 248
251 249
@@ -660,7 +658,7 @@ wbcir_tx(struct rc_dev *dev, unsigned *b, unsigned count)
660 unsigned i; 658 unsigned i;
661 unsigned long flags; 659 unsigned long flags;
662 660
663 buf = kmalloc(count * sizeof(*b), GFP_KERNEL); 661 buf = kmalloc_array(count, sizeof(*b), GFP_KERNEL);
664 if (!buf) 662 if (!buf)
665 return -ENOMEM; 663 return -ENOMEM;
666 664
@@ -1050,8 +1048,7 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
1050 goto exit_free_data; 1048 goto exit_free_data;
1051 } 1049 }
1052 1050
1053 dev_dbg(&device->dev, "Found device " 1051 dev_dbg(&device->dev, "Found device (w: 0x%lX, e: 0x%lX, s: 0x%lX, i: %u)\n",
1054 "(w: 0x%lX, e: 0x%lX, s: 0x%lX, i: %u)\n",
1055 data->wbase, data->ebase, data->sbase, data->irq); 1052 data->wbase, data->ebase, data->sbase, data->irq);
1056 1053
1057 data->led.name = "cir::activity"; 1054 data->led.name = "cir::activity";
@@ -1188,7 +1185,7 @@ static const struct pnp_device_id wbcir_ids[] = {
1188MODULE_DEVICE_TABLE(pnp, wbcir_ids); 1185MODULE_DEVICE_TABLE(pnp, wbcir_ids);
1189 1186
1190static struct pnp_driver wbcir_driver = { 1187static struct pnp_driver wbcir_driver = {
1191 .name = WBCIR_NAME, 1188 .name = DRVNAME,
1192 .id_table = wbcir_ids, 1189 .id_table = wbcir_ids,
1193 .probe = wbcir_probe, 1190 .probe = wbcir_probe,
1194 .remove = wbcir_remove, 1191 .remove = wbcir_remove,
diff --git a/drivers/media/spi/gs1662.c b/drivers/media/spi/gs1662.c
index d76f36233f43..330dcb2b2e44 100644
--- a/drivers/media/spi/gs1662.c
+++ b/drivers/media/spi/gs1662.c
@@ -453,17 +453,15 @@ static int gs_probe(struct spi_device *spi)
453static int gs_remove(struct spi_device *spi) 453static int gs_remove(struct spi_device *spi)
454{ 454{
455 struct v4l2_subdev *sd = spi_get_drvdata(spi); 455 struct v4l2_subdev *sd = spi_get_drvdata(spi);
456 struct gs *gs = to_gs(sd);
457 456
458 v4l2_device_unregister_subdev(sd); 457 v4l2_device_unregister_subdev(sd);
459 kfree(gs); 458
460 return 0; 459 return 0;
461} 460}
462 461
463static struct spi_driver gs_driver = { 462static struct spi_driver gs_driver = {
464 .driver = { 463 .driver = {
465 .name = "gs1662", 464 .name = "gs1662",
466 .owner = THIS_MODULE,
467 }, 465 },
468 466
469 .probe = gs_probe, 467 .probe = gs_probe,
diff --git a/drivers/media/tuners/fc0011.c b/drivers/media/tuners/fc0011.c
index 3932aa81e18c..00489a9df4e4 100644
--- a/drivers/media/tuners/fc0011.c
+++ b/drivers/media/tuners/fc0011.c
@@ -112,12 +112,10 @@ static int fc0011_readreg(struct fc0011_priv *priv, u8 reg, u8 *val)
112 return 0; 112 return 0;
113} 113}
114 114
115static int fc0011_release(struct dvb_frontend *fe) 115static void fc0011_release(struct dvb_frontend *fe)
116{ 116{
117 kfree(fe->tuner_priv); 117 kfree(fe->tuner_priv);
118 fe->tuner_priv = NULL; 118 fe->tuner_priv = NULL;
119
120 return 0;
121} 119}
122 120
123static int fc0011_init(struct dvb_frontend *fe) 121static int fc0011_init(struct dvb_frontend *fe)
@@ -262,8 +260,7 @@ static int fc0011_set_params(struct dvb_frontend *fe)
262 regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_BW7M; 260 regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_BW7M;
263 break; 261 break;
264 default: 262 default:
265 dev_warn(&priv->i2c->dev, "Unsupported bandwidth %u kHz. " 263 dev_warn(&priv->i2c->dev, "Unsupported bandwidth %u kHz. Using 6000 kHz.\n",
266 "Using 6000 kHz.\n",
267 bandwidth); 264 bandwidth);
268 bandwidth = 6000; 265 bandwidth = 6000;
269 /* fallthrough */ 266 /* fallthrough */
@@ -435,9 +432,7 @@ static int fc0011_set_params(struct dvb_frontend *fe)
435 if (err) 432 if (err)
436 return err; 433 return err;
437 434
438 dev_dbg(&priv->i2c->dev, "Tuned to " 435 dev_dbg(&priv->i2c->dev, "Tuned to fa=%02X fp=%02X xin=%02X%02X vco=%02X vcosel=%02X vcocal=%02X(%u) bw=%u\n",
439 "fa=%02X fp=%02X xin=%02X%02X vco=%02X vcosel=%02X "
440 "vcocal=%02X(%u) bw=%u\n",
441 (unsigned int)regs[FC11_REG_FA], 436 (unsigned int)regs[FC11_REG_FA],
442 (unsigned int)regs[FC11_REG_FP], 437 (unsigned int)regs[FC11_REG_FP],
443 (unsigned int)regs[FC11_REG_XINHI], 438 (unsigned int)regs[FC11_REG_XINHI],
diff --git a/drivers/media/tuners/fc0012.c b/drivers/media/tuners/fc0012.c
index d74e92056810..30508f44e5f9 100644
--- a/drivers/media/tuners/fc0012.c
+++ b/drivers/media/tuners/fc0012.c
@@ -55,11 +55,10 @@ static int fc0012_readreg(struct fc0012_priv *priv, u8 reg, u8 *val)
55 return 0; 55 return 0;
56} 56}
57 57
58static int fc0012_release(struct dvb_frontend *fe) 58static void fc0012_release(struct dvb_frontend *fe)
59{ 59{
60 kfree(fe->tuner_priv); 60 kfree(fe->tuner_priv);
61 fe->tuner_priv = NULL; 61 fe->tuner_priv = NULL;
62 return 0;
63} 62}
64 63
65static int fc0012_init(struct dvb_frontend *fe) 64static int fc0012_init(struct dvb_frontend *fe)
diff --git a/drivers/media/tuners/fc0013.c b/drivers/media/tuners/fc0013.c
index 522690d97b42..f7cf0e9e7c99 100644
--- a/drivers/media/tuners/fc0013.c
+++ b/drivers/media/tuners/fc0013.c
@@ -52,11 +52,10 @@ static int fc0013_readreg(struct fc0013_priv *priv, u8 reg, u8 *val)
52 return 0; 52 return 0;
53} 53}
54 54
55static int fc0013_release(struct dvb_frontend *fe) 55static void fc0013_release(struct dvb_frontend *fe)
56{ 56{
57 kfree(fe->tuner_priv); 57 kfree(fe->tuner_priv);
58 fe->tuner_priv = NULL; 58 fe->tuner_priv = NULL;
59 return 0;
60} 59}
61 60
62static int fc0013_init(struct dvb_frontend *fe) 61static int fc0013_init(struct dvb_frontend *fe)
diff --git a/drivers/media/tuners/max2165.c b/drivers/media/tuners/max2165.c
index 353b178becf6..c3f10925b0d4 100644
--- a/drivers/media/tuners/max2165.c
+++ b/drivers/media/tuners/max2165.c
@@ -370,15 +370,13 @@ static int max2165_init(struct dvb_frontend *fe)
370 return 0; 370 return 0;
371} 371}
372 372
373static int max2165_release(struct dvb_frontend *fe) 373static void max2165_release(struct dvb_frontend *fe)
374{ 374{
375 struct max2165_priv *priv = fe->tuner_priv; 375 struct max2165_priv *priv = fe->tuner_priv;
376 dprintk("%s()\n", __func__); 376 dprintk("%s()\n", __func__);
377 377
378 kfree(priv); 378 kfree(priv);
379 fe->tuner_priv = NULL; 379 fe->tuner_priv = NULL;
380
381 return 0;
382} 380}
383 381
384static const struct dvb_tuner_ops max2165_tuner_ops = { 382static const struct dvb_tuner_ops max2165_tuner_ops = {
diff --git a/drivers/media/tuners/mc44s803.c b/drivers/media/tuners/mc44s803.c
index f1b764074661..aba580b4ac2c 100644
--- a/drivers/media/tuners/mc44s803.c
+++ b/drivers/media/tuners/mc44s803.c
@@ -80,14 +80,12 @@ static int mc44s803_readreg(struct mc44s803_priv *priv, u8 reg, u32 *val)
80 return 0; 80 return 0;
81} 81}
82 82
83static int mc44s803_release(struct dvb_frontend *fe) 83static void mc44s803_release(struct dvb_frontend *fe)
84{ 84{
85 struct mc44s803_priv *priv = fe->tuner_priv; 85 struct mc44s803_priv *priv = fe->tuner_priv;
86 86
87 fe->tuner_priv = NULL; 87 fe->tuner_priv = NULL;
88 kfree(priv); 88 kfree(priv);
89
90 return 0;
91} 89}
92 90
93static int mc44s803_init(struct dvb_frontend *fe) 91static int mc44s803_init(struct dvb_frontend *fe)
@@ -349,8 +347,8 @@ struct dvb_frontend *mc44s803_attach(struct dvb_frontend *fe,
349 id = MC44S803_REG_MS(reg, MC44S803_ID); 347 id = MC44S803_REG_MS(reg, MC44S803_ID);
350 348
351 if (id != 0x14) { 349 if (id != 0x14) {
352 mc_printk(KERN_ERR, "unsupported ID " 350 mc_printk(KERN_ERR, "unsupported ID (%x should be 0x14)\n",
353 "(%x should be 0x14)\n", id); 351 id);
354 goto error; 352 goto error;
355 } 353 }
356 354
diff --git a/drivers/media/tuners/mt2060.c b/drivers/media/tuners/mt2060.c
index b87b2549d58d..94077ea78dde 100644
--- a/drivers/media/tuners/mt2060.c
+++ b/drivers/media/tuners/mt2060.c
@@ -332,11 +332,10 @@ static int mt2060_sleep(struct dvb_frontend *fe)
332 return ret; 332 return ret;
333} 333}
334 334
335static int mt2060_release(struct dvb_frontend *fe) 335static void mt2060_release(struct dvb_frontend *fe)
336{ 336{
337 kfree(fe->tuner_priv); 337 kfree(fe->tuner_priv);
338 fe->tuner_priv = NULL; 338 fe->tuner_priv = NULL;
339 return 0;
340} 339}
341 340
342static const struct dvb_tuner_ops mt2060_tuner_ops = { 341static const struct dvb_tuner_ops mt2060_tuner_ops = {
diff --git a/drivers/media/tuners/mt2063.c b/drivers/media/tuners/mt2063.c
index dfec23743afe..8b39d8dc97a0 100644
--- a/drivers/media/tuners/mt2063.c
+++ b/drivers/media/tuners/mt2063.c
@@ -2019,7 +2019,7 @@ static int mt2063_get_status(struct dvb_frontend *fe, u32 *tuner_status)
2019 return 0; 2019 return 0;
2020} 2020}
2021 2021
2022static int mt2063_release(struct dvb_frontend *fe) 2022static void mt2063_release(struct dvb_frontend *fe)
2023{ 2023{
2024 struct mt2063_state *state = fe->tuner_priv; 2024 struct mt2063_state *state = fe->tuner_priv;
2025 2025
@@ -2027,8 +2027,6 @@ static int mt2063_release(struct dvb_frontend *fe)
2027 2027
2028 fe->tuner_priv = NULL; 2028 fe->tuner_priv = NULL;
2029 kfree(state); 2029 kfree(state);
2030
2031 return 0;
2032} 2030}
2033 2031
2034static int mt2063_set_analog_params(struct dvb_frontend *fe, 2032static int mt2063_set_analog_params(struct dvb_frontend *fe,
diff --git a/drivers/media/tuners/mt20xx.c b/drivers/media/tuners/mt20xx.c
index 52da4671b0e0..129bf8e1aff8 100644
--- a/drivers/media/tuners/mt20xx.c
+++ b/drivers/media/tuners/mt20xx.c
@@ -49,12 +49,10 @@ struct microtune_priv {
49 u32 frequency; 49 u32 frequency;
50}; 50};
51 51
52static int microtune_release(struct dvb_frontend *fe) 52static void microtune_release(struct dvb_frontend *fe)
53{ 53{
54 kfree(fe->tuner_priv); 54 kfree(fe->tuner_priv);
55 fe->tuner_priv = NULL; 55 fe->tuner_priv = NULL;
56
57 return 0;
58} 56}
59 57
60static int microtune_get_frequency(struct dvb_frontend *fe, u32 *frequency) 58static int microtune_get_frequency(struct dvb_frontend *fe, u32 *frequency)
@@ -487,13 +485,8 @@ static void mt2050_set_if_freq(struct dvb_frontend *fe,unsigned int freq, unsign
487 buf[5]=div2a; 485 buf[5]=div2a;
488 if(num2!=0) buf[5]=buf[5]|0x40; 486 if(num2!=0) buf[5]=buf[5]|0x40;
489 487
490 if (debug > 1) { 488 if (debug > 1)
491 int i; 489 tuner_dbg("bufs is: %*ph\n", 6, buf);
492 tuner_dbg("bufs is: ");
493 for(i=0;i<6;i++)
494 printk("%x ",buf[i]);
495 printk("\n");
496 }
497 490
498 ret=tuner_i2c_xfer_send(&priv->i2c_props,buf,6); 491 ret=tuner_i2c_xfer_send(&priv->i2c_props,buf,6);
499 if (ret!=6) 492 if (ret!=6)
@@ -619,15 +612,9 @@ struct dvb_frontend *microtune_attach(struct dvb_frontend *fe,
619 612
620 tuner_i2c_xfer_send(&priv->i2c_props,buf,1); 613 tuner_i2c_xfer_send(&priv->i2c_props,buf,1);
621 tuner_i2c_xfer_recv(&priv->i2c_props,buf,21); 614 tuner_i2c_xfer_recv(&priv->i2c_props,buf,21);
622 if (debug) { 615 if (debug)
623 int i; 616 tuner_dbg("MT20xx hexdump: %*ph\n", 21, buf);
624 tuner_dbg("MT20xx hexdump:"); 617
625 for(i=0;i<21;i++) {
626 printk(" %02x",buf[i]);
627 if(((i+1)%8)==0) printk(" ");
628 }
629 printk("\n");
630 }
631 company_code = buf[0x11] << 8 | buf[0x12]; 618 company_code = buf[0x11] << 8 | buf[0x12];
632 tuner_info("microtune: companycode=%04x part=%02x rev=%02x\n", 619 tuner_info("microtune: companycode=%04x part=%02x rev=%02x\n",
633 company_code,buf[0x13],buf[0x14]); 620 company_code,buf[0x13],buf[0x14]);
diff --git a/drivers/media/tuners/mt2131.c b/drivers/media/tuners/mt2131.c
index 6e2cdd2b6175..e7790e4afcfe 100644
--- a/drivers/media/tuners/mt2131.c
+++ b/drivers/media/tuners/mt2131.c
@@ -230,12 +230,11 @@ static int mt2131_init(struct dvb_frontend *fe)
230 return ret; 230 return ret;
231} 231}
232 232
233static int mt2131_release(struct dvb_frontend *fe) 233static void mt2131_release(struct dvb_frontend *fe)
234{ 234{
235 dprintk(1, "%s()\n", __func__); 235 dprintk(1, "%s()\n", __func__);
236 kfree(fe->tuner_priv); 236 kfree(fe->tuner_priv);
237 fe->tuner_priv = NULL; 237 fe->tuner_priv = NULL;
238 return 0;
239} 238}
240 239
241static const struct dvb_tuner_ops mt2131_tuner_ops = { 240static const struct dvb_tuner_ops mt2131_tuner_ops = {
diff --git a/drivers/media/tuners/mt2266.c b/drivers/media/tuners/mt2266.c
index bca4d75e42d4..88edcc031e3c 100644
--- a/drivers/media/tuners/mt2266.c
+++ b/drivers/media/tuners/mt2266.c
@@ -296,11 +296,10 @@ static int mt2266_sleep(struct dvb_frontend *fe)
296 return 0; 296 return 0;
297} 297}
298 298
299static int mt2266_release(struct dvb_frontend *fe) 299static void mt2266_release(struct dvb_frontend *fe)
300{ 300{
301 kfree(fe->tuner_priv); 301 kfree(fe->tuner_priv);
302 fe->tuner_priv = NULL; 302 fe->tuner_priv = NULL;
303 return 0;
304} 303}
305 304
306static const struct dvb_tuner_ops mt2266_tuner_ops = { 305static const struct dvb_tuner_ops mt2266_tuner_ops = {
diff --git a/drivers/media/tuners/mxl5005s.c b/drivers/media/tuners/mxl5005s.c
index 92a3be4fde87..353744fee053 100644
--- a/drivers/media/tuners/mxl5005s.c
+++ b/drivers/media/tuners/mxl5005s.c
@@ -4063,12 +4063,11 @@ static int mxl5005s_get_if_frequency(struct dvb_frontend *fe, u32 *frequency)
4063 return 0; 4063 return 0;
4064} 4064}
4065 4065
4066static int mxl5005s_release(struct dvb_frontend *fe) 4066static void mxl5005s_release(struct dvb_frontend *fe)
4067{ 4067{
4068 dprintk(1, "%s()\n", __func__); 4068 dprintk(1, "%s()\n", __func__);
4069 kfree(fe->tuner_priv); 4069 kfree(fe->tuner_priv);
4070 fe->tuner_priv = NULL; 4070 fe->tuner_priv = NULL;
4071 return 0;
4072} 4071}
4073 4072
4074static const struct dvb_tuner_ops mxl5005s_tuner_ops = { 4073static const struct dvb_tuner_ops mxl5005s_tuner_ops = {
diff --git a/drivers/media/tuners/mxl5007t.c b/drivers/media/tuners/mxl5007t.c
index 42569c6811e6..b16dfa5e85fb 100644
--- a/drivers/media/tuners/mxl5007t.c
+++ b/drivers/media/tuners/mxl5007t.c
@@ -776,7 +776,7 @@ static int mxl5007t_get_if_frequency(struct dvb_frontend *fe, u32 *frequency)
776 return 0; 776 return 0;
777} 777}
778 778
779static int mxl5007t_release(struct dvb_frontend *fe) 779static void mxl5007t_release(struct dvb_frontend *fe)
780{ 780{
781 struct mxl5007t_state *state = fe->tuner_priv; 781 struct mxl5007t_state *state = fe->tuner_priv;
782 782
@@ -788,8 +788,6 @@ static int mxl5007t_release(struct dvb_frontend *fe)
788 mutex_unlock(&mxl5007t_list_mutex); 788 mutex_unlock(&mxl5007t_list_mutex);
789 789
790 fe->tuner_priv = NULL; 790 fe->tuner_priv = NULL;
791
792 return 0;
793} 791}
794 792
795/* ------------------------------------------------------------------------- */ 793/* ------------------------------------------------------------------------- */
diff --git a/drivers/media/tuners/qt1010.c b/drivers/media/tuners/qt1010.c
index ae8cbece6d2b..a2c6cd1c3923 100644
--- a/drivers/media/tuners/qt1010.c
+++ b/drivers/media/tuners/qt1010.c
@@ -377,11 +377,10 @@ static int qt1010_init(struct dvb_frontend *fe)
377 return qt1010_set_params(fe); 377 return qt1010_set_params(fe);
378} 378}
379 379
380static int qt1010_release(struct dvb_frontend *fe) 380static void qt1010_release(struct dvb_frontend *fe)
381{ 381{
382 kfree(fe->tuner_priv); 382 kfree(fe->tuner_priv);
383 fe->tuner_priv = NULL; 383 fe->tuner_priv = NULL;
384 return 0;
385} 384}
386 385
387static int qt1010_get_frequency(struct dvb_frontend *fe, u32 *frequency) 386static int qt1010_get_frequency(struct dvb_frontend *fe, u32 *frequency)
diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
index 08dca40356d2..ba80376a3b86 100644
--- a/drivers/media/tuners/r820t.c
+++ b/drivers/media/tuners/r820t.c
@@ -2286,7 +2286,7 @@ static int r820t_get_if_frequency(struct dvb_frontend *fe, u32 *frequency)
2286 return 0; 2286 return 0;
2287} 2287}
2288 2288
2289static int r820t_release(struct dvb_frontend *fe) 2289static void r820t_release(struct dvb_frontend *fe)
2290{ 2290{
2291 struct r820t_priv *priv = fe->tuner_priv; 2291 struct r820t_priv *priv = fe->tuner_priv;
2292 2292
@@ -2300,8 +2300,6 @@ static int r820t_release(struct dvb_frontend *fe)
2300 mutex_unlock(&r820t_list_mutex); 2300 mutex_unlock(&r820t_list_mutex);
2301 2301
2302 fe->tuner_priv = NULL; 2302 fe->tuner_priv = NULL;
2303
2304 return 0;
2305} 2303}
2306 2304
2307static const struct dvb_tuner_ops r820t_tuner_ops = { 2305static const struct dvb_tuner_ops r820t_tuner_ops = {
diff --git a/drivers/media/tuners/tda18218.c b/drivers/media/tuners/tda18218.c
index 9300e9361e3b..8357a3c08a70 100644
--- a/drivers/media/tuners/tda18218.c
+++ b/drivers/media/tuners/tda18218.c
@@ -265,11 +265,10 @@ static int tda18218_init(struct dvb_frontend *fe)
265 return ret; 265 return ret;
266} 266}
267 267
268static int tda18218_release(struct dvb_frontend *fe) 268static void tda18218_release(struct dvb_frontend *fe)
269{ 269{
270 kfree(fe->tuner_priv); 270 kfree(fe->tuner_priv);
271 fe->tuner_priv = NULL; 271 fe->tuner_priv = NULL;
272 return 0;
273} 272}
274 273
275static const struct dvb_tuner_ops tda18218_tuner_ops = { 274static const struct dvb_tuner_ops tda18218_tuner_ops = {
diff --git a/drivers/media/tuners/tda18271-common.c b/drivers/media/tuners/tda18271-common.c
index a26bb33102b8..7e81cd887c13 100644
--- a/drivers/media/tuners/tda18271-common.c
+++ b/drivers/media/tuners/tda18271-common.c
@@ -251,8 +251,8 @@ static int __tda18271_write_regs(struct dvb_frontend *fe, int idx, int len,
251 } 251 }
252 252
253 if (ret != 1) 253 if (ret != 1)
254 tda_err("ERROR: idx = 0x%x, len = %d, " 254 tda_err("ERROR: idx = 0x%x, len = %d, i2c_transfer returned: %d\n",
255 "i2c_transfer returned: %d\n", idx, max, ret); 255 idx, max, ret);
256 256
257 return (ret == 1 ? 0 : ret); 257 return (ret == 1 ? 0 : ret);
258} 258}
diff --git a/drivers/media/tuners/tda18271-fe.c b/drivers/media/tuners/tda18271-fe.c
index 2d50e8b1dce1..b4e5fa2ff5e5 100644
--- a/drivers/media/tuners/tda18271-fe.c
+++ b/drivers/media/tuners/tda18271-fe.c
@@ -26,8 +26,7 @@
26 26
27int tda18271_debug; 27int tda18271_debug;
28module_param_named(debug, tda18271_debug, int, 0644); 28module_param_named(debug, tda18271_debug, int, 0644);
29MODULE_PARM_DESC(debug, "set debug level " 29MODULE_PARM_DESC(debug, "set debug level (info=1, map=2, reg=4, adv=8, cal=16 (or-able))");
30 "(info=1, map=2, reg=4, adv=8, cal=16 (or-able))");
31 30
32static int tda18271_cal_on_startup = -1; 31static int tda18271_cal_on_startup = -1;
33module_param_named(cal, tda18271_cal_on_startup, int, 0644); 32module_param_named(cal, tda18271_cal_on_startup, int, 0644);
@@ -1049,7 +1048,7 @@ fail:
1049 return ret; 1048 return ret;
1050} 1049}
1051 1050
1052static int tda18271_release(struct dvb_frontend *fe) 1051static void tda18271_release(struct dvb_frontend *fe)
1053{ 1052{
1054 struct tda18271_priv *priv = fe->tuner_priv; 1053 struct tda18271_priv *priv = fe->tuner_priv;
1055 1054
@@ -1061,8 +1060,6 @@ static int tda18271_release(struct dvb_frontend *fe)
1061 mutex_unlock(&tda18271_list_mutex); 1060 mutex_unlock(&tda18271_list_mutex);
1062 1061
1063 fe->tuner_priv = NULL; 1062 fe->tuner_priv = NULL;
1064
1065 return 0;
1066} 1063}
1067 1064
1068static int tda18271_get_frequency(struct dvb_frontend *fe, u32 *frequency) 1065static int tda18271_get_frequency(struct dvb_frontend *fe, u32 *frequency)
diff --git a/drivers/media/tuners/tda18271-maps.c b/drivers/media/tuners/tda18271-maps.c
index 1e89dd93c4bb..7d114677b4ca 100644
--- a/drivers/media/tuners/tda18271-maps.c
+++ b/drivers/media/tuners/tda18271-maps.c
@@ -1024,11 +1024,7 @@ int tda18271_lookup_rf_band(struct dvb_frontend *fe, u32 *freq, u8 *rf_band)
1024 1024
1025 while ((map[i].rfmax * 1000) < *freq) { 1025 while ((map[i].rfmax * 1000) < *freq) {
1026 if (tda18271_debug & DBG_ADV) 1026 if (tda18271_debug & DBG_ADV)
1027 tda_map("(%d) rfmax = %d < freq = %d, " 1027 tda_map("(%d) rfmax = %d < freq = %d, rf1_def = %d, rf2_def = %d, rf3_def = %d, rf1 = %d, rf2 = %d, rf3 = %d, rf_a1 = %d, rf_a2 = %d, rf_b1 = %d, rf_b2 = %d\n",
1028 "rf1_def = %d, rf2_def = %d, rf3_def = %d, "
1029 "rf1 = %d, rf2 = %d, rf3 = %d, "
1030 "rf_a1 = %d, rf_a2 = %d, "
1031 "rf_b1 = %d, rf_b2 = %d\n",
1032 i, map[i].rfmax * 1000, *freq, 1028 i, map[i].rfmax * 1000, *freq,
1033 map[i].rf1_def, map[i].rf2_def, map[i].rf3_def, 1029 map[i].rf1_def, map[i].rf2_def, map[i].rf3_def,
1034 map[i].rf1, map[i].rf2, map[i].rf3, 1030 map[i].rf1, map[i].rf2, map[i].rf3,
diff --git a/drivers/media/tuners/tda827x.c b/drivers/media/tuners/tda827x.c
index 5050ce9be423..2137eadf30f1 100644
--- a/drivers/media/tuners/tda827x.c
+++ b/drivers/media/tuners/tda827x.c
@@ -767,11 +767,10 @@ static void tda827xa_agcf(struct dvb_frontend *fe)
767 767
768/* ------------------------------------------------------------------ */ 768/* ------------------------------------------------------------------ */
769 769
770static int tda827x_release(struct dvb_frontend *fe) 770static void tda827x_release(struct dvb_frontend *fe)
771{ 771{
772 kfree(fe->tuner_priv); 772 kfree(fe->tuner_priv);
773 fe->tuner_priv = NULL; 773 fe->tuner_priv = NULL;
774 return 0;
775} 774}
776 775
777static int tda827x_get_frequency(struct dvb_frontend *fe, u32 *frequency) 776static int tda827x_get_frequency(struct dvb_frontend *fe, u32 *frequency)
diff --git a/drivers/media/tuners/tda8290.c b/drivers/media/tuners/tda8290.c
index 998e82bba9c0..a59c567c55d6 100644
--- a/drivers/media/tuners/tda8290.c
+++ b/drivers/media/tuners/tda8290.c
@@ -617,8 +617,8 @@ static int tda829x_find_tuner(struct dvb_frontend *fe)
617 617
618 if (tuner_addrs == 0) { 618 if (tuner_addrs == 0) {
619 tuner_addrs = 0x60; 619 tuner_addrs = 0x60;
620 tuner_info("could not clearly identify tuner address, " 620 tuner_info("could not clearly identify tuner address, defaulting to %x\n",
621 "defaulting to %x\n", tuner_addrs); 621 tuner_addrs);
622 } else { 622 } else {
623 tuner_addrs = tuner_addrs & 0xff; 623 tuner_addrs = tuner_addrs & 0xff;
624 tuner_info("setting tuner address to %x\n", tuner_addrs); 624 tuner_info("setting tuner address to %x\n", tuner_addrs);
@@ -721,7 +721,7 @@ static int tda8295_probe(struct tuner_i2c_props *i2c_props)
721 return -ENODEV; 721 return -ENODEV;
722} 722}
723 723
724static struct analog_demod_ops tda8290_ops = { 724static const struct analog_demod_ops tda8290_ops = {
725 .set_params = tda8290_set_params, 725 .set_params = tda8290_set_params,
726 .has_signal = tda8290_has_signal, 726 .has_signal = tda8290_has_signal,
727 .standby = tda8290_standby, 727 .standby = tda8290_standby,
@@ -729,7 +729,7 @@ static struct analog_demod_ops tda8290_ops = {
729 .i2c_gate_ctrl = tda8290_i2c_bridge, 729 .i2c_gate_ctrl = tda8290_i2c_bridge,
730}; 730};
731 731
732static struct analog_demod_ops tda8295_ops = { 732static const struct analog_demod_ops tda8295_ops = {
733 .set_params = tda8295_set_params, 733 .set_params = tda8295_set_params,
734 .has_signal = tda8295_has_signal, 734 .has_signal = tda8295_has_signal,
735 .standby = tda8295_standby, 735 .standby = tda8295_standby,
diff --git a/drivers/media/tuners/tda9887.c b/drivers/media/tuners/tda9887.c
index 56be6c29399b..c0e815f8b951 100644
--- a/drivers/media/tuners/tda9887.c
+++ b/drivers/media/tuners/tda9887.c
@@ -659,7 +659,7 @@ static void tda9887_release(struct dvb_frontend *fe)
659 fe->analog_demod_priv = NULL; 659 fe->analog_demod_priv = NULL;
660} 660}
661 661
662static struct analog_demod_ops tda9887_ops = { 662static const struct analog_demod_ops tda9887_ops = {
663 .info = { 663 .info = {
664 .name = "tda9887", 664 .name = "tda9887",
665 }, 665 },
diff --git a/drivers/media/tuners/tea5761.c b/drivers/media/tuners/tea5761.c
index 36b0b1e1d05b..a9b1bb134409 100644
--- a/drivers/media/tuners/tea5761.c
+++ b/drivers/media/tuners/tea5761.c
@@ -274,24 +274,20 @@ int tea5761_autodetection(struct i2c_adapter* i2c_adap, u8 i2c_addr)
274 } 274 }
275 275
276 if ((buffer[13] != 0x2b) || (buffer[14] != 0x57) || (buffer[15] != 0x061)) { 276 if ((buffer[13] != 0x2b) || (buffer[14] != 0x57) || (buffer[15] != 0x061)) {
277 printk(KERN_WARNING "Manufacturer ID= 0x%02x, Chip ID = %02x%02x." 277 printk(KERN_WARNING "Manufacturer ID= 0x%02x, Chip ID = %02x%02x. It is not a TEA5761\n",
278 " It is not a TEA5761\n",
279 buffer[13], buffer[14], buffer[15]); 278 buffer[13], buffer[14], buffer[15]);
280 return -EINVAL; 279 return -EINVAL;
281 } 280 }
282 printk(KERN_WARNING "tea5761: TEA%02x%02x detected. " 281 printk(KERN_WARNING "tea5761: TEA%02x%02x detected. Manufacturer ID= 0x%02x\n",
283 "Manufacturer ID= 0x%02x\n",
284 buffer[14], buffer[15], buffer[13]); 282 buffer[14], buffer[15], buffer[13]);
285 283
286 return 0; 284 return 0;
287} 285}
288 286
289static int tea5761_release(struct dvb_frontend *fe) 287static void tea5761_release(struct dvb_frontend *fe)
290{ 288{
291 kfree(fe->tuner_priv); 289 kfree(fe->tuner_priv);
292 fe->tuner_priv = NULL; 290 fe->tuner_priv = NULL;
293
294 return 0;
295} 291}
296 292
297static int tea5761_get_frequency(struct dvb_frontend *fe, u32 *frequency) 293static int tea5761_get_frequency(struct dvb_frontend *fe, u32 *frequency)
diff --git a/drivers/media/tuners/tea5767.c b/drivers/media/tuners/tea5767.c
index d62a6d6b1f42..525b7ab90c80 100644
--- a/drivers/media/tuners/tea5767.c
+++ b/drivers/media/tuners/tea5767.c
@@ -401,12 +401,10 @@ int tea5767_autodetection(struct i2c_adapter* i2c_adap, u8 i2c_addr)
401 return 0; 401 return 0;
402} 402}
403 403
404static int tea5767_release(struct dvb_frontend *fe) 404static void tea5767_release(struct dvb_frontend *fe)
405{ 405{
406 kfree(fe->tuner_priv); 406 kfree(fe->tuner_priv);
407 fe->tuner_priv = NULL; 407 fe->tuner_priv = NULL;
408
409 return 0;
410} 408}
411 409
412static int tea5767_get_frequency(struct dvb_frontend *fe, u32 *frequency) 410static int tea5767_get_frequency(struct dvb_frontend *fe, u32 *frequency)
diff --git a/drivers/media/tuners/tuner-simple.c b/drivers/media/tuners/tuner-simple.c
index 9ba9582e7765..3339b13dd3f5 100644
--- a/drivers/media/tuners/tuner-simple.c
+++ b/drivers/media/tuners/tuner-simple.c
@@ -275,8 +275,7 @@ static int simple_config_lookup(struct dvb_frontend *fe,
275 *config = t_params->ranges[i].config; 275 *config = t_params->ranges[i].config;
276 *cb = t_params->ranges[i].cb; 276 *cb = t_params->ranges[i].cb;
277 277
278 tuner_dbg("freq = %d.%02d (%d), range = %d, " 278 tuner_dbg("freq = %d.%02d (%d), range = %d, config = 0x%02x, cb = 0x%02x\n",
279 "config = 0x%02x, cb = 0x%02x\n",
280 *frequency / 16, *frequency % 16 * 100 / 16, *frequency, 279 *frequency / 16, *frequency % 16 * 100 / 16, *frequency,
281 i, *config, *cb); 280 i, *config, *cb);
282 281
@@ -404,12 +403,12 @@ static int simple_std_setup(struct dvb_frontend *fe,
404 i2c.addr = 0x0a; 403 i2c.addr = 0x0a;
405 rc = tuner_i2c_xfer_send(&i2c, &buffer[0], 2); 404 rc = tuner_i2c_xfer_send(&i2c, &buffer[0], 2);
406 if (2 != rc) 405 if (2 != rc)
407 tuner_warn("i2c i/o error: rc == %d " 406 tuner_warn("i2c i/o error: rc == %d (should be 2)\n",
408 "(should be 2)\n", rc); 407 rc);
409 rc = tuner_i2c_xfer_send(&i2c, &buffer[2], 2); 408 rc = tuner_i2c_xfer_send(&i2c, &buffer[2], 2);
410 if (2 != rc) 409 if (2 != rc)
411 tuner_warn("i2c i/o error: rc == %d " 410 tuner_warn("i2c i/o error: rc == %d (should be 2)\n",
412 "(should be 2)\n", rc); 411 rc);
413 break; 412 break;
414 } 413 }
415 } 414 }
@@ -463,8 +462,8 @@ static int simple_post_tune(struct dvb_frontend *fe, u8 *buffer,
463 rc = tuner_i2c_xfer_recv(&priv->i2c_props, 462 rc = tuner_i2c_xfer_recv(&priv->i2c_props,
464 &status_byte, 1); 463 &status_byte, 1);
465 if (1 != rc) { 464 if (1 != rc) {
466 tuner_warn("i2c i/o read error: rc == %d " 465 tuner_warn("i2c i/o read error: rc == %d (should be 1)\n",
467 "(should be 1)\n", rc); 466 rc);
468 break; 467 break;
469 } 468 }
470 if (status_byte & TUNER_PLL_LOCKED) 469 if (status_byte & TUNER_PLL_LOCKED)
@@ -483,8 +482,8 @@ static int simple_post_tune(struct dvb_frontend *fe, u8 *buffer,
483 482
484 rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 4); 483 rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 4);
485 if (4 != rc) 484 if (4 != rc)
486 tuner_warn("i2c i/o error: rc == %d " 485 tuner_warn("i2c i/o error: rc == %d (should be 4)\n",
487 "(should be 4)\n", rc); 486 rc);
488 break; 487 break;
489 } 488 }
490 } 489 }
@@ -499,8 +498,7 @@ static int simple_radio_bandswitch(struct dvb_frontend *fe, u8 *buffer)
499 switch (priv->type) { 498 switch (priv->type) {
500 case TUNER_TENA_9533_DI: 499 case TUNER_TENA_9533_DI:
501 case TUNER_YMEC_TVF_5533MF: 500 case TUNER_YMEC_TVF_5533MF:
502 tuner_dbg("This tuner doesn't have FM. " 501 tuner_dbg("This tuner doesn't have FM. Most cards have a TEA5767 for FM\n");
503 "Most cards have a TEA5767 for FM\n");
504 return 0; 502 return 0;
505 case TUNER_PHILIPS_FM1216ME_MK3: 503 case TUNER_PHILIPS_FM1216ME_MK3:
506 case TUNER_PHILIPS_FM1236_MK3: 504 case TUNER_PHILIPS_FM1236_MK3:
@@ -586,8 +584,7 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,
586 584
587 div = params->frequency + IFPCoff + offset; 585 div = params->frequency + IFPCoff + offset;
588 586
589 tuner_dbg("Freq= %d.%02d MHz, V_IF=%d.%02d MHz, " 587 tuner_dbg("Freq= %d.%02d MHz, V_IF=%d.%02d MHz, Offset=%d.%02d MHz, div=%0d\n",
590 "Offset=%d.%02d MHz, div=%0d\n",
591 params->frequency / 16, params->frequency % 16 * 100 / 16, 588 params->frequency / 16, params->frequency % 16 * 100 / 16,
592 IFPCoff / 16, IFPCoff % 16 * 100 / 16, 589 IFPCoff / 16, IFPCoff % 16 * 100 / 16,
593 offset / 16, offset % 16 * 100 / 16, div); 590 offset / 16, offset % 16 * 100 / 16, div);
@@ -858,8 +855,7 @@ static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf,
858 if (!tun->stepsize) { 855 if (!tun->stepsize) {
859 /* tuner-core was loaded before the digital tuner was 856 /* tuner-core was loaded before the digital tuner was
860 * configured and somehow picked the wrong tuner type */ 857 * configured and somehow picked the wrong tuner type */
861 tuner_err("attempt to treat tuner %d (%s) as digital tuner " 858 tuner_err("attempt to treat tuner %d (%s) as digital tuner without stepsize defined.\n",
862 "without stepsize defined.\n",
863 priv->type, priv->tun->name); 859 priv->type, priv->tun->name);
864 return 0; /* failure */ 860 return 0; /* failure */
865 } 861 }
@@ -1005,7 +1001,7 @@ static int simple_sleep(struct dvb_frontend *fe)
1005 return 0; 1001 return 0;
1006} 1002}
1007 1003
1008static int simple_release(struct dvb_frontend *fe) 1004static void simple_release(struct dvb_frontend *fe)
1009{ 1005{
1010 struct tuner_simple_priv *priv = fe->tuner_priv; 1006 struct tuner_simple_priv *priv = fe->tuner_priv;
1011 1007
@@ -1017,8 +1013,6 @@ static int simple_release(struct dvb_frontend *fe)
1017 mutex_unlock(&tuner_simple_list_mutex); 1013 mutex_unlock(&tuner_simple_list_mutex);
1018 1014
1019 fe->tuner_priv = NULL; 1015 fe->tuner_priv = NULL;
1020
1021 return 0;
1022} 1016}
1023 1017
1024static int simple_get_frequency(struct dvb_frontend *fe, u32 *frequency) 1018static int simple_get_frequency(struct dvb_frontend *fe, u32 *frequency)
@@ -1077,8 +1071,7 @@ struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe,
1077 fe->ops.i2c_gate_ctrl(fe, 1); 1071 fe->ops.i2c_gate_ctrl(fe, 1);
1078 1072
1079 if (1 != i2c_transfer(i2c_adap, &msg, 1)) 1073 if (1 != i2c_transfer(i2c_adap, &msg, 1))
1080 printk(KERN_WARNING "tuner-simple %d-%04x: " 1074 printk(KERN_WARNING "tuner-simple %d-%04x: unable to probe %s, proceeding anyway.",
1081 "unable to probe %s, proceeding anyway.",
1082 i2c_adapter_id(i2c_adap), i2c_addr, 1075 i2c_adapter_id(i2c_adap), i2c_addr,
1083 tuners[type].name); 1076 tuners[type].name);
1084 1077
@@ -1123,18 +1116,16 @@ struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe,
1123 if ((debug) || ((atv_input[priv->nr] > 0) || 1116 if ((debug) || ((atv_input[priv->nr] > 0) ||
1124 (dtv_input[priv->nr] > 0))) { 1117 (dtv_input[priv->nr] > 0))) {
1125 if (0 == atv_input[priv->nr]) 1118 if (0 == atv_input[priv->nr])
1126 tuner_info("tuner %d atv rf input will be " 1119 tuner_info("tuner %d atv rf input will be autoselected\n",
1127 "autoselected\n", priv->nr); 1120 priv->nr);
1128 else 1121 else
1129 tuner_info("tuner %d atv rf input will be " 1122 tuner_info("tuner %d atv rf input will be set to input %d (insmod option)\n",
1130 "set to input %d (insmod option)\n",
1131 priv->nr, atv_input[priv->nr]); 1123 priv->nr, atv_input[priv->nr]);
1132 if (0 == dtv_input[priv->nr]) 1124 if (0 == dtv_input[priv->nr])
1133 tuner_info("tuner %d dtv rf input will be " 1125 tuner_info("tuner %d dtv rf input will be autoselected\n",
1134 "autoselected\n", priv->nr); 1126 priv->nr);
1135 else 1127 else
1136 tuner_info("tuner %d dtv rf input will be " 1128 tuner_info("tuner %d dtv rf input will be set to input %d (insmod option)\n",
1137 "set to input %d (insmod option)\n",
1138 priv->nr, dtv_input[priv->nr]); 1129 priv->nr, dtv_input[priv->nr]);
1139 } 1130 }
1140 1131
diff --git a/drivers/media/tuners/tuner-xc2028.c b/drivers/media/tuners/tuner-xc2028.c
index 8d96a22647b3..b5b62b08159e 100644
--- a/drivers/media/tuners/tuner-xc2028.c
+++ b/drivers/media/tuners/tuner-xc2028.c
@@ -56,8 +56,7 @@ MODULE_PARM_DESC(no_poweroff, "0 (default) powers device off when not used.\n"
56static char audio_std[8]; 56static char audio_std[8];
57module_param_string(audio_std, audio_std, sizeof(audio_std), 0); 57module_param_string(audio_std, audio_std, sizeof(audio_std), 0);
58MODULE_PARM_DESC(audio_std, 58MODULE_PARM_DESC(audio_std,
59 "Audio standard. XC3028 audio decoder explicitly " 59 "Audio standard. XC3028 audio decoder explicitly needs to know what audio\n"
60 "needs to know what audio\n"
61 "standard is needed for some video standards with audio A2 or NICAM.\n" 60 "standard is needed for some video standards with audio A2 or NICAM.\n"
62 "The valid values are:\n" 61 "The valid values are:\n"
63 "A2\n" 62 "A2\n"
@@ -69,8 +68,8 @@ MODULE_PARM_DESC(audio_std,
69 68
70static char firmware_name[30]; 69static char firmware_name[30];
71module_param_string(firmware_name, firmware_name, sizeof(firmware_name), 0); 70module_param_string(firmware_name, firmware_name, sizeof(firmware_name), 0);
72MODULE_PARM_DESC(firmware_name, "Firmware file name. Allows overriding the " 71MODULE_PARM_DESC(firmware_name,
73 "default firmware name\n"); 72 "Firmware file name. Allows overriding the default firmware name\n");
74 73
75static LIST_HEAD(hybrid_tuner_instance_list); 74static LIST_HEAD(hybrid_tuner_instance_list);
76static DEFINE_MUTEX(xc2028_list_mutex); 75static DEFINE_MUTEX(xc2028_list_mutex);
@@ -179,67 +178,67 @@ static int xc2028_get_reg(struct xc2028_data *priv, u16 reg, u16 *val)
179static void dump_firm_type_and_int_freq(unsigned int type, u16 int_freq) 178static void dump_firm_type_and_int_freq(unsigned int type, u16 int_freq)
180{ 179{
181 if (type & BASE) 180 if (type & BASE)
182 printk("BASE "); 181 printk(KERN_CONT "BASE ");
183 if (type & INIT1) 182 if (type & INIT1)
184 printk("INIT1 "); 183 printk(KERN_CONT "INIT1 ");
185 if (type & F8MHZ) 184 if (type & F8MHZ)
186 printk("F8MHZ "); 185 printk(KERN_CONT "F8MHZ ");
187 if (type & MTS) 186 if (type & MTS)
188 printk("MTS "); 187 printk(KERN_CONT "MTS ");
189 if (type & D2620) 188 if (type & D2620)
190 printk("D2620 "); 189 printk(KERN_CONT "D2620 ");
191 if (type & D2633) 190 if (type & D2633)
192 printk("D2633 "); 191 printk(KERN_CONT "D2633 ");
193 if (type & DTV6) 192 if (type & DTV6)
194 printk("DTV6 "); 193 printk(KERN_CONT "DTV6 ");
195 if (type & QAM) 194 if (type & QAM)
196 printk("QAM "); 195 printk(KERN_CONT "QAM ");
197 if (type & DTV7) 196 if (type & DTV7)
198 printk("DTV7 "); 197 printk(KERN_CONT "DTV7 ");
199 if (type & DTV78) 198 if (type & DTV78)
200 printk("DTV78 "); 199 printk(KERN_CONT "DTV78 ");
201 if (type & DTV8) 200 if (type & DTV8)
202 printk("DTV8 "); 201 printk(KERN_CONT "DTV8 ");
203 if (type & FM) 202 if (type & FM)
204 printk("FM "); 203 printk(KERN_CONT "FM ");
205 if (type & INPUT1) 204 if (type & INPUT1)
206 printk("INPUT1 "); 205 printk(KERN_CONT "INPUT1 ");
207 if (type & LCD) 206 if (type & LCD)
208 printk("LCD "); 207 printk(KERN_CONT "LCD ");
209 if (type & NOGD) 208 if (type & NOGD)
210 printk("NOGD "); 209 printk(KERN_CONT "NOGD ");
211 if (type & MONO) 210 if (type & MONO)
212 printk("MONO "); 211 printk(KERN_CONT "MONO ");
213 if (type & ATSC) 212 if (type & ATSC)
214 printk("ATSC "); 213 printk(KERN_CONT "ATSC ");
215 if (type & IF) 214 if (type & IF)
216 printk("IF "); 215 printk(KERN_CONT "IF ");
217 if (type & LG60) 216 if (type & LG60)
218 printk("LG60 "); 217 printk(KERN_CONT "LG60 ");
219 if (type & ATI638) 218 if (type & ATI638)
220 printk("ATI638 "); 219 printk(KERN_CONT "ATI638 ");
221 if (type & OREN538) 220 if (type & OREN538)
222 printk("OREN538 "); 221 printk(KERN_CONT "OREN538 ");
223 if (type & OREN36) 222 if (type & OREN36)
224 printk("OREN36 "); 223 printk(KERN_CONT "OREN36 ");
225 if (type & TOYOTA388) 224 if (type & TOYOTA388)
226 printk("TOYOTA388 "); 225 printk(KERN_CONT "TOYOTA388 ");
227 if (type & TOYOTA794) 226 if (type & TOYOTA794)
228 printk("TOYOTA794 "); 227 printk(KERN_CONT "TOYOTA794 ");
229 if (type & DIBCOM52) 228 if (type & DIBCOM52)
230 printk("DIBCOM52 "); 229 printk(KERN_CONT "DIBCOM52 ");
231 if (type & ZARLINK456) 230 if (type & ZARLINK456)
232 printk("ZARLINK456 "); 231 printk(KERN_CONT "ZARLINK456 ");
233 if (type & CHINA) 232 if (type & CHINA)
234 printk("CHINA "); 233 printk(KERN_CONT "CHINA ");
235 if (type & F6MHZ) 234 if (type & F6MHZ)
236 printk("F6MHZ "); 235 printk(KERN_CONT "F6MHZ ");
237 if (type & INPUT2) 236 if (type & INPUT2)
238 printk("INPUT2 "); 237 printk(KERN_CONT "INPUT2 ");
239 if (type & SCODE) 238 if (type & SCODE)
240 printk("SCODE "); 239 printk(KERN_CONT "SCODE ");
241 if (type & HAS_IF) 240 if (type & HAS_IF)
242 printk("HAS_IF_%d ", int_freq); 241 printk(KERN_CONT "HAS_IF_%d ", int_freq);
243} 242}
244 243
245static v4l2_std_id parse_audio_std_option(void) 244static v4l2_std_id parse_audio_std_option(void)
@@ -351,8 +350,7 @@ static int load_all_firmwares(struct dvb_frontend *fe,
351 350
352 n++; 351 n++;
353 if (n >= n_array) { 352 if (n >= n_array) {
354 tuner_err("More firmware images in file than " 353 tuner_err("More firmware images in file than were expected!\n");
355 "were expected!\n");
356 goto corrupt; 354 goto corrupt;
357 } 355 }
358 356
@@ -379,8 +377,8 @@ static int load_all_firmwares(struct dvb_frontend *fe,
379 if (!size || size > endp - p) { 377 if (!size || size > endp - p) {
380 tuner_err("Firmware type "); 378 tuner_err("Firmware type ");
381 dump_firm_type(type); 379 dump_firm_type(type);
382 printk("(%x), id %llx is corrupted " 380 printk(KERN_CONT
383 "(size=%d, expected %d)\n", 381 "(%x), id %llx is corrupted (size=%d, expected %d)\n",
384 type, (unsigned long long)id, 382 type, (unsigned long long)id,
385 (unsigned)(endp - p), size); 383 (unsigned)(endp - p), size);
386 goto corrupt; 384 goto corrupt;
@@ -395,7 +393,7 @@ static int load_all_firmwares(struct dvb_frontend *fe,
395 tuner_dbg("Reading firmware type "); 393 tuner_dbg("Reading firmware type ");
396 if (debug) { 394 if (debug) {
397 dump_firm_type_and_int_freq(type, int_freq); 395 dump_firm_type_and_int_freq(type, int_freq);
398 printk("(%x), id %llx, size=%d.\n", 396 printk(KERN_CONT "(%x), id %llx, size=%d.\n",
399 type, (unsigned long long)id, size); 397 type, (unsigned long long)id, size);
400 } 398 }
401 399
@@ -444,7 +442,8 @@ static int seek_firmware(struct dvb_frontend *fe, unsigned int type,
444 tuner_dbg("%s called, want type=", __func__); 442 tuner_dbg("%s called, want type=", __func__);
445 if (debug) { 443 if (debug) {
446 dump_firm_type(type); 444 dump_firm_type(type);
447 printk("(%x), id %016llx.\n", type, (unsigned long long)*id); 445 printk(KERN_CONT "(%x), id %016llx.\n",
446 type, (unsigned long long)*id);
448 } 447 }
449 448
450 if (!priv->firm) { 449 if (!priv->firm) {
@@ -500,10 +499,11 @@ static int seek_firmware(struct dvb_frontend *fe, unsigned int type,
500 } 499 }
501 500
502 if (best_nr_matches > 0) { 501 if (best_nr_matches > 0) {
503 tuner_dbg("Selecting best matching firmware (%d bits) for " 502 tuner_dbg("Selecting best matching firmware (%d bits) for type=",
504 "type=", best_nr_matches); 503 best_nr_matches);
505 dump_firm_type(type); 504 dump_firm_type(type);
506 printk("(%x), id %016llx:\n", type, (unsigned long long)*id); 505 printk(KERN_CONT
506 "(%x), id %016llx:\n", type, (unsigned long long)*id);
507 i = best_i; 507 i = best_i;
508 goto found; 508 goto found;
509 } 509 }
@@ -520,7 +520,8 @@ ret:
520 tuner_dbg("%s firmware for type=", (i < 0) ? "Can't find" : "Found"); 520 tuner_dbg("%s firmware for type=", (i < 0) ? "Can't find" : "Found");
521 if (debug) { 521 if (debug) {
522 dump_firm_type(type); 522 dump_firm_type(type);
523 printk("(%x), id %016llx.\n", type, (unsigned long long)*id); 523 printk(KERN_CONT "(%x), id %016llx.\n",
524 type, (unsigned long long)*id);
524 } 525 }
525 return i; 526 return i;
526} 527}
@@ -560,8 +561,8 @@ static int load_firmware(struct dvb_frontend *fe, unsigned int type,
560 561
561 tuner_info("Loading firmware for type="); 562 tuner_info("Loading firmware for type=");
562 dump_firm_type(priv->firm[pos].type); 563 dump_firm_type(priv->firm[pos].type);
563 printk("(%x), id %016llx.\n", priv->firm[pos].type, 564 printk(KERN_CONT "(%x), id %016llx.\n",
564 (unsigned long long)*id); 565 priv->firm[pos].type, (unsigned long long)*id);
565 566
566 p = priv->firm[pos].ptr; 567 p = priv->firm[pos].ptr;
567 endp = p + priv->firm[pos].size; 568 endp = p + priv->firm[pos].size;
@@ -694,7 +695,7 @@ static int load_scode(struct dvb_frontend *fe, unsigned int type,
694 tuner_info("Loading SCODE for type="); 695 tuner_info("Loading SCODE for type=");
695 dump_firm_type_and_int_freq(priv->firm[pos].type, 696 dump_firm_type_and_int_freq(priv->firm[pos].type,
696 priv->firm[pos].int_freq); 697 priv->firm[pos].int_freq);
697 printk("(%x), id %016llx.\n", priv->firm[pos].type, 698 printk(KERN_CONT "(%x), id %016llx.\n", priv->firm[pos].type,
698 (unsigned long long)*id); 699 (unsigned long long)*id);
699 700
700 if (priv->firm_version < 0x0202) 701 if (priv->firm_version < 0x0202)
@@ -746,15 +747,15 @@ retry:
746 tuner_dbg("checking firmware, user requested type="); 747 tuner_dbg("checking firmware, user requested type=");
747 if (debug) { 748 if (debug) {
748 dump_firm_type(new_fw.type); 749 dump_firm_type(new_fw.type);
749 printk("(%x), id %016llx, ", new_fw.type, 750 printk(KERN_CONT "(%x), id %016llx, ", new_fw.type,
750 (unsigned long long)new_fw.std_req); 751 (unsigned long long)new_fw.std_req);
751 if (!int_freq) { 752 if (!int_freq) {
752 printk("scode_tbl "); 753 printk(KERN_CONT "scode_tbl ");
753 dump_firm_type(priv->ctrl.scode_table); 754 dump_firm_type(priv->ctrl.scode_table);
754 printk("(%x), ", priv->ctrl.scode_table); 755 printk(KERN_CONT "(%x), ", priv->ctrl.scode_table);
755 } else 756 } else
756 printk("int_freq %d, ", new_fw.int_freq); 757 printk(KERN_CONT "int_freq %d, ", new_fw.int_freq);
757 printk("scode_nr %d\n", new_fw.scode_nr); 758 printk(KERN_CONT "scode_nr %d\n", new_fw.scode_nr);
758 } 759 }
759 760
760 /* 761 /*
@@ -842,8 +843,7 @@ check_device:
842 goto fail; 843 goto fail;
843 } 844 }
844 845
845 tuner_dbg("Device is Xceive %d version %d.%d, " 846 tuner_dbg("Device is Xceive %d version %d.%d, firmware version %d.%d\n",
846 "firmware version %d.%d\n",
847 hwmodel, (version & 0xf000) >> 12, (version & 0xf00) >> 8, 847 hwmodel, (version & 0xf000) >> 12, (version & 0xf00) >> 8,
848 (version & 0xf0) >> 4, version & 0xf); 848 (version & 0xf0) >> 4, version & 0xf);
849 849
@@ -857,8 +857,7 @@ check_device:
857 tuner_err("Incorrect readback of firmware version.\n"); 857 tuner_err("Incorrect readback of firmware version.\n");
858 goto fail; 858 goto fail;
859 } else { 859 } else {
860 tuner_err("Returned an incorrect version. However, " 860 tuner_err("Returned an incorrect version. However, read is not reliable enough. Ignoring it.\n");
861 "read is not reliable enough. Ignoring it.\n");
862 hwmodel = 3028; 861 hwmodel = 3028;
863 } 862 }
864 } 863 }
@@ -869,8 +868,7 @@ check_device:
869 priv->hwvers = version & 0xff00; 868 priv->hwvers = version & 0xff00;
870 } else if (priv->hwmodel == 0 || priv->hwmodel != hwmodel || 869 } else if (priv->hwmodel == 0 || priv->hwmodel != hwmodel ||
871 priv->hwvers != (version & 0xff00)) { 870 priv->hwvers != (version & 0xff00)) {
872 tuner_err("Read invalid device hardware information - tuner " 871 tuner_err("Read invalid device hardware information - tuner hung?\n");
873 "hung?\n");
874 goto fail; 872 goto fail;
875 } 873 }
876 874
@@ -1327,7 +1325,7 @@ static int xc2028_sleep(struct dvb_frontend *fe)
1327 return rc; 1325 return rc;
1328} 1326}
1329 1327
1330static int xc2028_dvb_release(struct dvb_frontend *fe) 1328static void xc2028_dvb_release(struct dvb_frontend *fe)
1331{ 1329{
1332 struct xc2028_data *priv = fe->tuner_priv; 1330 struct xc2028_data *priv = fe->tuner_priv;
1333 1331
@@ -1345,8 +1343,6 @@ static int xc2028_dvb_release(struct dvb_frontend *fe)
1345 mutex_unlock(&xc2028_list_mutex); 1343 mutex_unlock(&xc2028_list_mutex);
1346 1344
1347 fe->tuner_priv = NULL; 1345 fe->tuner_priv = NULL;
1348
1349 return 0;
1350} 1346}
1351 1347
1352static int xc2028_get_frequency(struct dvb_frontend *fe, u32 *frequency) 1348static int xc2028_get_frequency(struct dvb_frontend *fe, u32 *frequency)
diff --git a/drivers/media/tuners/xc4000.c b/drivers/media/tuners/xc4000.c
index d95c7e082ccf..03eef9b87a24 100644
--- a/drivers/media/tuners/xc4000.c
+++ b/drivers/media/tuners/xc4000.c
@@ -43,14 +43,11 @@ MODULE_PARM_DESC(debug, "Debugging level (0 to 2, default: 0 (off)).");
43 43
44static int no_poweroff; 44static int no_poweroff;
45module_param(no_poweroff, int, 0644); 45module_param(no_poweroff, int, 0644);
46MODULE_PARM_DESC(no_poweroff, "Power management (1: disabled, 2: enabled, " 46MODULE_PARM_DESC(no_poweroff, "Power management (1: disabled, 2: enabled, 0 (default): use device-specific default mode).");
47 "0 (default): use device-specific default mode).");
48 47
49static int audio_std; 48static int audio_std;
50module_param(audio_std, int, 0644); 49module_param(audio_std, int, 0644);
51MODULE_PARM_DESC(audio_std, "Audio standard. XC4000 audio decoder explicitly " 50MODULE_PARM_DESC(audio_std, "Audio standard. XC4000 audio decoder explicitly needs to know what audio standard is needed for some video standards with audio A2 or NICAM. The valid settings are a sum of:\n"
52 "needs to know what audio standard is needed for some video standards "
53 "with audio A2 or NICAM. The valid settings are a sum of:\n"
54 " 1: use NICAM/B or A2/B instead of NICAM/A or A2/A\n" 51 " 1: use NICAM/B or A2/B instead of NICAM/A or A2/A\n"
55 " 2: use A2 instead of NICAM or BTSC\n" 52 " 2: use A2 instead of NICAM or BTSC\n"
56 " 4: use SECAM/K3 instead of K1\n" 53 " 4: use SECAM/K3 instead of K1\n"
@@ -60,8 +57,7 @@ MODULE_PARM_DESC(audio_std, "Audio standard. XC4000 audio decoder explicitly "
60 57
61static char firmware_name[30]; 58static char firmware_name[30];
62module_param_string(firmware_name, firmware_name, sizeof(firmware_name), 0); 59module_param_string(firmware_name, firmware_name, sizeof(firmware_name), 0);
63MODULE_PARM_DESC(firmware_name, "Firmware file name. Allows overriding the " 60MODULE_PARM_DESC(firmware_name, "Firmware file name. Allows overriding the default firmware name.");
64 "default firmware name.");
65 61
66static DEFINE_MUTEX(xc4000_list_mutex); 62static DEFINE_MUTEX(xc4000_list_mutex);
67static LIST_HEAD(hybrid_tuner_instance_list); 63static LIST_HEAD(hybrid_tuner_instance_list);
@@ -290,8 +286,7 @@ static int xc4000_tuner_reset(struct dvb_frontend *fe)
290 return -EREMOTEIO; 286 return -EREMOTEIO;
291 } 287 }
292 } else { 288 } else {
293 printk(KERN_ERR "xc4000: no tuner reset callback function, " 289 printk(KERN_ERR "xc4000: no tuner reset callback function, fatal\n");
294 "fatal\n");
295 return -EINVAL; 290 return -EINVAL;
296 } 291 }
297 return 0; 292 return 0;
@@ -679,8 +674,7 @@ static int seek_firmware(struct dvb_frontend *fe, unsigned int type,
679 674
680 if (best_nr_diffs > 0U) { 675 if (best_nr_diffs > 0U) {
681 printk(KERN_WARNING 676 printk(KERN_WARNING
682 "Selecting best matching firmware (%u bits differ) for " 677 "Selecting best matching firmware (%u bits differ) for type=(%x), id %016llx:\n",
683 "type=(%x), id %016llx:\n",
684 best_nr_diffs, type, (unsigned long long)*id); 678 best_nr_diffs, type, (unsigned long long)*id);
685 i = best_i; 679 i = best_i;
686 } 680 }
@@ -800,8 +794,7 @@ static int xc4000_fwupload(struct dvb_frontend *fe)
800 794
801 n++; 795 n++;
802 if (n >= n_array) { 796 if (n >= n_array) {
803 printk(KERN_ERR "More firmware images in file than " 797 printk(KERN_ERR "More firmware images in file than were expected!\n");
804 "were expected!\n");
805 goto corrupt; 798 goto corrupt;
806 } 799 }
807 800
@@ -1055,8 +1048,7 @@ check_device:
1055 goto fail; 1048 goto fail;
1056 } 1049 }
1057 1050
1058 dprintk(1, "Device is Xceive %d version %d.%d, " 1051 dprintk(1, "Device is Xceive %d version %d.%d, firmware version %d.%d\n",
1059 "firmware version %d.%d\n",
1060 hwmodel, hw_major, hw_minor, fw_major, fw_minor); 1052 hwmodel, hw_major, hw_minor, fw_major, fw_minor);
1061 1053
1062 /* Check firmware version against what we downloaded. */ 1054 /* Check firmware version against what we downloaded. */
@@ -1076,8 +1068,7 @@ check_device:
1076 } else if (priv->hwmodel == 0 || priv->hwmodel != hwmodel || 1068 } else if (priv->hwmodel == 0 || priv->hwmodel != hwmodel ||
1077 priv->hwvers != ((hw_major << 8) | hw_minor)) { 1069 priv->hwvers != ((hw_major << 8) | hw_minor)) {
1078 printk(KERN_WARNING 1070 printk(KERN_WARNING
1079 "Read invalid device hardware information - tuner " 1071 "Read invalid device hardware information - tuner hung?\n");
1080 "hung?\n");
1081 goto fail; 1072 goto fail;
1082 } 1073 }
1083 1074
@@ -1627,7 +1618,7 @@ static int xc4000_init(struct dvb_frontend *fe)
1627 return 0; 1618 return 0;
1628} 1619}
1629 1620
1630static int xc4000_release(struct dvb_frontend *fe) 1621static void xc4000_release(struct dvb_frontend *fe)
1631{ 1622{
1632 struct xc4000_priv *priv = fe->tuner_priv; 1623 struct xc4000_priv *priv = fe->tuner_priv;
1633 1624
@@ -1641,8 +1632,6 @@ static int xc4000_release(struct dvb_frontend *fe)
1641 mutex_unlock(&xc4000_list_mutex); 1632 mutex_unlock(&xc4000_list_mutex);
1642 1633
1643 fe->tuner_priv = NULL; 1634 fe->tuner_priv = NULL;
1644
1645 return 0;
1646} 1635}
1647 1636
1648static const struct dvb_tuner_ops xc4000_tuner_ops = { 1637static const struct dvb_tuner_ops xc4000_tuner_ops = {
diff --git a/drivers/media/tuners/xc5000.c b/drivers/media/tuners/xc5000.c
index e6e5e90d8d95..796e7638b3b2 100644
--- a/drivers/media/tuners/xc5000.c
+++ b/drivers/media/tuners/xc5000.c
@@ -1326,7 +1326,7 @@ static int xc5000_init(struct dvb_frontend *fe)
1326 return 0; 1326 return 0;
1327} 1327}
1328 1328
1329static int xc5000_release(struct dvb_frontend *fe) 1329static void xc5000_release(struct dvb_frontend *fe)
1330{ 1330{
1331 struct xc5000_priv *priv = fe->tuner_priv; 1331 struct xc5000_priv *priv = fe->tuner_priv;
1332 1332
@@ -1346,8 +1346,6 @@ static int xc5000_release(struct dvb_frontend *fe)
1346 mutex_unlock(&xc5000_list_mutex); 1346 mutex_unlock(&xc5000_list_mutex);
1347 1347
1348 fe->tuner_priv = NULL; 1348 fe->tuner_priv = NULL;
1349
1350 return 0;
1351} 1349}
1352 1350
1353static int xc5000_set_config(struct dvb_frontend *fe, void *priv_cfg) 1351static int xc5000_set_config(struct dvb_frontend *fe, void *priv_cfg)
diff --git a/drivers/media/usb/Kconfig b/drivers/media/usb/Kconfig
index 7496f332f3f5..c9644b62f91a 100644
--- a/drivers/media/usb/Kconfig
+++ b/drivers/media/usb/Kconfig
@@ -60,5 +60,10 @@ source "drivers/media/usb/hackrf/Kconfig"
60source "drivers/media/usb/msi2500/Kconfig" 60source "drivers/media/usb/msi2500/Kconfig"
61endif 61endif
62 62
63if MEDIA_CEC_SUPPORT
64 comment "USB HDMI CEC adapters"
65source "drivers/media/usb/pulse8-cec/Kconfig"
66endif
67
63endif #MEDIA_USB_SUPPORT 68endif #MEDIA_USB_SUPPORT
64endif #USB 69endif #USB
diff --git a/drivers/media/usb/Makefile b/drivers/media/usb/Makefile
index 8874ba774a34..0f15e3351ddc 100644
--- a/drivers/media/usb/Makefile
+++ b/drivers/media/usb/Makefile
@@ -24,3 +24,4 @@ obj-$(CONFIG_VIDEO_EM28XX) += em28xx/
24obj-$(CONFIG_VIDEO_USBTV) += usbtv/ 24obj-$(CONFIG_VIDEO_USBTV) += usbtv/
25obj-$(CONFIG_VIDEO_GO7007) += go7007/ 25obj-$(CONFIG_VIDEO_GO7007) += go7007/
26obj-$(CONFIG_DVB_AS102) += as102/ 26obj-$(CONFIG_DVB_AS102) += as102/
27obj-$(CONFIG_USB_PULSE8_CEC) += pulse8-cec/
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 85dd9a8e83ff..7a10eaa38f67 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -253,8 +253,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
253 dev->isoc_ctl.transfer_buffer[i] = usb_alloc_coherent(dev->usbdev, 253 dev->isoc_ctl.transfer_buffer[i] = usb_alloc_coherent(dev->usbdev,
254 sb_size, GFP_KERNEL, &urb->transfer_dma); 254 sb_size, GFP_KERNEL, &urb->transfer_dma);
255 if (!dev->isoc_ctl.transfer_buffer[i]) { 255 if (!dev->isoc_ctl.transfer_buffer[i]) {
256 printk("unable to allocate %i bytes for transfer" 256 printk("unable to allocate %i bytes for transfer buffer %i%s\n",
257 " buffer %i%s\n",
258 sb_size, i, 257 sb_size, i,
259 in_interrupt() ? " while in int" : ""); 258 in_interrupt() ? " while in int" : "");
260 au0828_uninit_isoc(dev); 259 au0828_uninit_isoc(dev);
diff --git a/drivers/media/usb/b2c2/flexcop-usb.c b/drivers/media/usb/b2c2/flexcop-usb.c
index 52bc42da8a4c..788c73803138 100644
--- a/drivers/media/usb/b2c2/flexcop-usb.c
+++ b/drivers/media/usb/b2c2/flexcop-usb.c
@@ -33,8 +33,7 @@
33 33
34static int debug; 34static int debug;
35module_param(debug, int, 0644); 35module_param(debug, int, 0644);
36MODULE_PARM_DESC(debug, "set debugging level (1=info,ts=2," 36MODULE_PARM_DESC(debug, "set debugging level (1=info,ts=2,ctrl=4,i2c=8,v8mem=16 (or-able))." DEBSTATUS);
37 "ctrl=4,i2c=8,v8mem=16 (or-able))." DEBSTATUS);
38#undef DEBSTATUS 37#undef DEBSTATUS
39 38
40#define deb_info(args...) dprintk(0x01, args) 39#define deb_info(args...) dprintk(0x01, args)
@@ -433,8 +432,8 @@ static int flexcop_usb_transfer_init(struct flexcop_usb *fc_usb)
433 frame_size, i, j, ret; 432 frame_size, i, j, ret;
434 int buffer_offset = 0; 433 int buffer_offset = 0;
435 434
436 deb_ts("creating %d iso-urbs with %d frames " 435 deb_ts("creating %d iso-urbs with %d frames each of %d bytes size = %d.\n",
437 "each of %d bytes size = %d.\n", B2C2_USB_NUM_ISO_URB, 436 B2C2_USB_NUM_ISO_URB,
438 B2C2_USB_FRAMES_PER_ISO, frame_size, bufsize); 437 B2C2_USB_FRAMES_PER_ISO, frame_size, bufsize);
439 438
440 fc_usb->iso_buffer = usb_alloc_coherent(fc_usb->udev, 439 fc_usb->iso_buffer = usb_alloc_coherent(fc_usb->udev,
@@ -459,8 +458,8 @@ static int flexcop_usb_transfer_init(struct flexcop_usb *fc_usb)
459 for (i = 0; i < B2C2_USB_NUM_ISO_URB; i++) { 458 for (i = 0; i < B2C2_USB_NUM_ISO_URB; i++) {
460 int frame_offset = 0; 459 int frame_offset = 0;
461 struct urb *urb = fc_usb->iso_urb[i]; 460 struct urb *urb = fc_usb->iso_urb[i];
462 deb_ts("initializing and submitting urb no. %d " 461 deb_ts("initializing and submitting urb no. %d (buf_offset: %d).\n",
463 "(buf_offset: %d).\n", i, buffer_offset); 462 i, buffer_offset);
464 463
465 urb->dev = fc_usb->udev; 464 urb->dev = fc_usb->udev;
466 urb->context = fc_usb; 465 urb->context = fc_usb;
diff --git a/drivers/media/usb/cpia2/cpia2_usb.c b/drivers/media/usb/cpia2/cpia2_usb.c
index e9100a235831..37f9b30b0abc 100644
--- a/drivers/media/usb/cpia2/cpia2_usb.c
+++ b/drivers/media/usb/cpia2/cpia2_usb.c
@@ -759,9 +759,7 @@ int cpia2_usb_stream_start(struct camera_data *cam, unsigned int alternate)
759 cam->params.camera_state.stream_mode = old_alt; 759 cam->params.camera_state.stream_mode = old_alt;
760 ret2 = set_alternate(cam, USBIF_CMDONLY); 760 ret2 = set_alternate(cam, USBIF_CMDONLY);
761 if (ret2 < 0) { 761 if (ret2 < 0) {
762 ERR("cpia2_usb_change_streaming_alternate(%d) =%d has already " 762 ERR("cpia2_usb_change_streaming_alternate(%d) =%d has already failed. Then tried to call set_alternate(USBIF_CMDONLY) = %d.\n",
763 "failed. Then tried to call "
764 "set_alternate(USBIF_CMDONLY) = %d.\n",
765 alternate, ret, ret2); 763 alternate, ret, ret2);
766 } 764 }
767 } else { 765 } else {
diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c b/drivers/media/usb/cx231xx/cx231xx-core.c
index 8b099fe1d592..550ec932f931 100644
--- a/drivers/media/usb/cx231xx/cx231xx-core.c
+++ b/drivers/media/usb/cx231xx/cx231xx-core.c
@@ -241,8 +241,7 @@ static int __usb_control_msg(struct cx231xx *dev, unsigned int pipe,
241 int rc, i; 241 int rc, i;
242 242
243 if (reg_debug) { 243 if (reg_debug) {
244 printk(KERN_DEBUG "%s: (pipe 0x%08x): " 244 printk(KERN_DEBUG "%s: (pipe 0x%08x): %s: %02x %02x %02x %02x %02x %02x %02x %02x ",
245 "%s: %02x %02x %02x %02x %02x %02x %02x %02x ",
246 dev->name, 245 dev->name,
247 pipe, 246 pipe,
248 (requesttype & USB_DIR_IN) ? "IN" : "OUT", 247 (requesttype & USB_DIR_IN) ? "IN" : "OUT",
@@ -441,8 +440,7 @@ int cx231xx_write_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, char *buf,
441 if (reg_debug) { 440 if (reg_debug) {
442 int byte; 441 int byte;
443 442
444 cx231xx_isocdbg("(pipe 0x%08x): " 443 cx231xx_isocdbg("(pipe 0x%08x): OUT: %02x %02x %02x %02x %02x %02x %02x %02x >>>",
445 "OUT: %02x %02x %02x %02x %02x %02x %02x %02x >>>",
446 pipe, 444 pipe,
447 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 445 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
448 req, 0, val, reg & 0xff, 446 req, 0, val, reg & 0xff,
@@ -600,8 +598,8 @@ int cx231xx_set_alt_setting(struct cx231xx *dev, u8 index, u8 alt)
600 return -1; 598 return -1;
601 } 599 }
602 600
603 cx231xx_coredbg("setting alternate %d with wMaxPacketSize=%u," 601 cx231xx_coredbg("setting alternate %d with wMaxPacketSize=%u,Interface = %d\n",
604 "Interface = %d\n", alt, max_pkt_size, 602 alt, max_pkt_size,
605 usb_interface_index); 603 usb_interface_index);
606 604
607 if (usb_interface_index > 0) { 605 if (usb_interface_index > 0) {
diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
index 1417515d30eb..2868546999ca 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
@@ -377,8 +377,8 @@ static int attach_xc5000(u8 addr, struct cx231xx *dev)
377 cfg.i2c_addr = addr; 377 cfg.i2c_addr = addr;
378 378
379 if (!dev->dvb->frontend) { 379 if (!dev->dvb->frontend) {
380 dev_err(dev->dev, "%s/2: dvb frontend not attached. " 380 dev_err(dev->dev, "%s/2: dvb frontend not attached. Can't attach xc5000\n",
381 "Can't attach xc5000\n", dev->name); 381 dev->name);
382 return -EINVAL; 382 return -EINVAL;
383 } 383 }
384 384
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
index 8961dd732522..c673726d9b70 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -2095,6 +2095,8 @@ static const struct usb_device_id af9035_id_table[] = {
2095 &af9035_props, "TerraTec Cinergy T Stick (rev. 2)", NULL) }, 2095 &af9035_props, "TerraTec Cinergy T Stick (rev. 2)", NULL) },
2096 { DVB_USB_DEVICE(USB_VID_AVERMEDIA, 0x0337, 2096 { DVB_USB_DEVICE(USB_VID_AVERMEDIA, 0x0337,
2097 &af9035_props, "AVerMedia HD Volar (A867)", NULL) }, 2097 &af9035_props, "AVerMedia HD Volar (A867)", NULL) },
2098 { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_EVOLVEO_XTRATV_STICK,
2099 &af9035_props, "EVOLVEO XtraTV stick", NULL) },
2098 2100
2099 /* IT9135 devices */ 2101 /* IT9135 devices */
2100 { DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9135, 2102 { DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9135,
diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c b/drivers/media/usb/dvb-usb-v2/dvbsky.c
index 02dbc6c45423..0636eac37bbb 100644
--- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -851,6 +851,10 @@ static const struct usb_device_id dvbsky_id_table[] = {
851 USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI_2, 851 USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI_2,
852 &dvbsky_t680c_props, "TechnoTrend TT-connect CT2-4650 CI v1.1", 852 &dvbsky_t680c_props, "TechnoTrend TT-connect CT2-4650 CI v1.1",
853 RC_MAP_TT_1500) }, 853 RC_MAP_TT_1500) },
854 { DVB_USB_DEVICE(USB_VID_TECHNOTREND,
855 USB_PID_TECHNOTREND_CONNECT_S2_4650_CI,
856 &dvbsky_s960c_props, "TechnoTrend TT-connect S2-4650 CI",
857 RC_MAP_TT_1500) },
854 { DVB_USB_DEVICE(USB_VID_TERRATEC, 858 { DVB_USB_DEVICE(USB_VID_TERRATEC,
855 USB_PID_TERRATEC_H7_3, 859 USB_PID_TERRATEC_H7_3,
856 &dvbsky_t680c_props, "Terratec H7 Rev.4", 860 &dvbsky_t680c_props, "Terratec H7 Rev.4",
diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c
index 0e8fb89896c4..5fea02672685 100644
--- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
+++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
@@ -156,21 +156,19 @@ struct lme2510_state {
156static int lme2510_bulk_write(struct usb_device *dev, 156static int lme2510_bulk_write(struct usb_device *dev,
157 u8 *snd, int len, u8 pipe) 157 u8 *snd, int len, u8 pipe)
158{ 158{
159 int ret, actual_l; 159 int actual_l;
160 160
161 ret = usb_bulk_msg(dev, usb_sndbulkpipe(dev, pipe), 161 return usb_bulk_msg(dev, usb_sndbulkpipe(dev, pipe),
162 snd, len , &actual_l, 100); 162 snd, len, &actual_l, 100);
163 return ret;
164} 163}
165 164
166static int lme2510_bulk_read(struct usb_device *dev, 165static int lme2510_bulk_read(struct usb_device *dev,
167 u8 *rev, int len, u8 pipe) 166 u8 *rev, int len, u8 pipe)
168{ 167{
169 int ret, actual_l; 168 int actual_l;
170 169
171 ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, pipe), 170 return usb_bulk_msg(dev, usb_rcvbulkpipe(dev, pipe),
172 rev, len , &actual_l, 200); 171 rev, len, &actual_l, 200);
173 return ret;
174} 172}
175 173
176static int lme2510_usb_talk(struct dvb_usb_device *d, 174static int lme2510_usb_talk(struct dvb_usb_device *d,
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c b/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c
index 047a32fe43ea..639e156e0c1b 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c
@@ -549,7 +549,7 @@ static void mxl111sf_demod_release(struct dvb_frontend *fe)
549 fe->demodulator_priv = NULL; 549 fe->demodulator_priv = NULL;
550} 550}
551 551
552static struct dvb_frontend_ops mxl111sf_demod_ops = { 552static const struct dvb_frontend_ops mxl111sf_demod_ops = {
553 .delsys = { SYS_DVBT }, 553 .delsys = { SYS_DVBT },
554 .info = { 554 .info = {
555 .name = "MaxLinear MxL111SF DVB-T demodulator", 555 .name = "MaxLinear MxL111SF DVB-T demodulator",
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c b/drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c
index 283495c84ba3..6427137a09ef 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c
@@ -666,8 +666,8 @@ static int mxl111sf_i2c_hw_xfer_msg(struct mxl111sf_state *state,
666 666
667 if (rd_status[i] == 0x04) { 667 if (rd_status[i] == 0x04) {
668 if (i < 7) { 668 if (i < 7) {
669 mxl_i2c("i2c fifo empty!" 669 mxl_i2c("i2c fifo empty! @ %d",
670 " @ %d", i); 670 i);
671 msg->buf[(index*8)+i] = 671 msg->buf[(index*8)+i] =
672 i2c_r_data[(i*3)+1]; 672 i2c_r_data[(i*3)+1];
673 /* read again */ 673 /* read again */
@@ -692,8 +692,7 @@ static int mxl111sf_i2c_hw_xfer_msg(struct mxl111sf_state *state,
692 } 692 }
693 goto stop_copy; 693 goto stop_copy;
694 } else { 694 } else {
695 mxl_i2c("readagain " 695 mxl_i2c("readagain ERROR!");
696 "ERROR!");
697 } 696 }
698 } else { 697 } else {
699 msg->buf[(index*8)+i] = 698 msg->buf[(index*8)+i] =
@@ -827,9 +826,8 @@ int mxl111sf_i2c_xfer(struct i2c_adapter *adap,
827 mxl111sf_i2c_hw_xfer_msg(state, &msg[i]) : 826 mxl111sf_i2c_hw_xfer_msg(state, &msg[i]) :
828 mxl111sf_i2c_sw_xfer_msg(state, &msg[i]); 827 mxl111sf_i2c_sw_xfer_msg(state, &msg[i]);
829 if (mxl_fail(ret)) { 828 if (mxl_fail(ret)) {
830 mxl_debug_adv("failed with error %d on i2c " 829 mxl_debug_adv("failed with error %d on i2c transaction %d of %d, %sing %d bytes to/from 0x%02x",
831 "transaction %d of %d, %sing %d bytes " 830 ret, i+1, num,
832 "to/from 0x%02x", ret, i+1, num,
833 (msg[i].flags & I2C_M_RD) ? 831 (msg[i].flags & I2C_M_RD) ?
834 "read" : "writ", 832 "read" : "writ",
835 msg[i].len, msg[i].addr); 833 msg[i].len, msg[i].addr);
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c b/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c
index f141dcc55cc9..f84bef6034dc 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c
@@ -455,13 +455,12 @@ static int mxl111sf_tuner_get_if_frequency(struct dvb_frontend *fe,
455 return 0; 455 return 0;
456} 456}
457 457
458static int mxl111sf_tuner_release(struct dvb_frontend *fe) 458static void mxl111sf_tuner_release(struct dvb_frontend *fe)
459{ 459{
460 struct mxl111sf_tuner_state *state = fe->tuner_priv; 460 struct mxl111sf_tuner_state *state = fe->tuner_priv;
461 mxl_dbg("()"); 461 mxl_dbg("()");
462 kfree(state); 462 kfree(state);
463 fe->tuner_priv = NULL; 463 fe->tuner_priv = NULL;
464 return 0;
465} 464}
466 465
467/* ------------------------------------------------------------------------- */ 466/* ------------------------------------------------------------------------- */
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf.c b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
index 5d676b533a3a..80c635980526 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
@@ -29,8 +29,7 @@
29 29
30int dvb_usb_mxl111sf_debug; 30int dvb_usb_mxl111sf_debug;
31module_param_named(debug, dvb_usb_mxl111sf_debug, int, 0644); 31module_param_named(debug, dvb_usb_mxl111sf_debug, int, 0644);
32MODULE_PARM_DESC(debug, "set debugging level " 32MODULE_PARM_DESC(debug, "set debugging level (1=info, 2=xfer, 4=i2c, 8=reg, 16=adv (or-able)).");
33 "(1=info, 2=xfer, 4=i2c, 8=reg, 16=adv (or-able)).");
34 33
35static int dvb_usb_mxl111sf_isoc; 34static int dvb_usb_mxl111sf_isoc;
36module_param_named(isoc, dvb_usb_mxl111sf_isoc, int, 0644); 35module_param_named(isoc, dvb_usb_mxl111sf_isoc, int, 0644);
@@ -137,8 +136,8 @@ int mxl111sf_write_reg_mask(struct mxl111sf_state *state,
137#if 1 136#if 1
138 /* dont know why this usually errors out on the first try */ 137 /* dont know why this usually errors out on the first try */
139 if (mxl_fail(ret)) 138 if (mxl_fail(ret))
140 pr_err("error writing addr: 0x%02x, mask: 0x%02x, " 139 pr_err("error writing addr: 0x%02x, mask: 0x%02x, data: 0x%02x, retrying...",
141 "data: 0x%02x, retrying...", addr, mask, data); 140 addr, mask, data);
142 141
143 ret = mxl111sf_read_reg(state, addr, &val); 142 ret = mxl111sf_read_reg(state, addr, &val);
144#endif 143#endif
@@ -946,8 +945,7 @@ static int mxl111sf_init(struct dvb_usb_device *d)
946 case 138001: 945 case 138001:
947 break; 946 break;
948 default: 947 default:
949 printk(KERN_WARNING "%s: warning: " 948 printk(KERN_WARNING "%s: warning: unknown hauppauge model #%d\n",
950 "unknown hauppauge model #%d\n",
951 __func__, state->tv.model); 949 __func__, state->tv.model);
952 } 950 }
953#endif 951#endif
diff --git a/drivers/media/usb/dvb-usb/af9005-fe.c b/drivers/media/usb/dvb-usb/af9005-fe.c
index 09db3d02bd82..9862d3e6b8e8 100644
--- a/drivers/media/usb/dvb-usb/af9005-fe.c
+++ b/drivers/media/usb/dvb-usb/af9005-fe.c
@@ -1430,7 +1430,7 @@ static void af9005_fe_release(struct dvb_frontend *fe)
1430 kfree(state); 1430 kfree(state);
1431} 1431}
1432 1432
1433static struct dvb_frontend_ops af9005_fe_ops; 1433static const struct dvb_frontend_ops af9005_fe_ops;
1434 1434
1435struct dvb_frontend *af9005_fe_attach(struct dvb_usb_device *d) 1435struct dvb_frontend *af9005_fe_attach(struct dvb_usb_device *d)
1436{ 1436{
@@ -1455,7 +1455,7 @@ struct dvb_frontend *af9005_fe_attach(struct dvb_usb_device *d)
1455 return NULL; 1455 return NULL;
1456} 1456}
1457 1457
1458static struct dvb_frontend_ops af9005_fe_ops = { 1458static const struct dvb_frontend_ops af9005_fe_ops = {
1459 .delsys = { SYS_DVBT }, 1459 .delsys = { SYS_DVBT },
1460 .info = { 1460 .info = {
1461 .name = "AF9005 USB DVB-T", 1461 .name = "AF9005 USB DVB-T",
diff --git a/drivers/media/usb/dvb-usb/af9005.c b/drivers/media/usb/dvb-usb/af9005.c
index 7853261906b1..f5f476841aea 100644
--- a/drivers/media/usb/dvb-usb/af9005.c
+++ b/drivers/media/usb/dvb-usb/af9005.c
@@ -826,7 +826,6 @@ static int af9005_frontend_attach(struct dvb_usb_adapter *adap)
826 printk("EEPROM DUMP\n"); 826 printk("EEPROM DUMP\n");
827 for (i = 0; i < 255; i += 8) { 827 for (i = 0; i < 255; i += 8) {
828 af9005_read_eeprom(adap->dev, i, buf, 8); 828 af9005_read_eeprom(adap->dev, i, buf, 8);
829 printk("ADDR %x ", i);
830 debug_dump(buf, 8, printk); 829 debug_dump(buf, 8, printk);
831 } 830 }
832 } 831 }
diff --git a/drivers/media/usb/dvb-usb/cinergyT2-core.c b/drivers/media/usb/dvb-usb/cinergyT2-core.c
index 290275bc7fde..6404205560eb 100644
--- a/drivers/media/usb/dvb-usb/cinergyT2-core.c
+++ b/drivers/media/usb/dvb-usb/cinergyT2-core.c
@@ -34,8 +34,7 @@
34int dvb_usb_cinergyt2_debug; 34int dvb_usb_cinergyt2_debug;
35 35
36module_param_named(debug, dvb_usb_cinergyt2_debug, int, 0644); 36module_param_named(debug, dvb_usb_cinergyt2_debug, int, 0644);
37MODULE_PARM_DESC(debug, "set debugging level (1=info, xfer=2, rc=4 " 37MODULE_PARM_DESC(debug, "set debugging level (1=info, xfer=2, rc=4 (or-able)).");
38 "(or-able)).");
39 38
40DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 39DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
41 40
@@ -93,8 +92,7 @@ static int cinergyt2_frontend_attach(struct dvb_usb_adapter *adap)
93 92
94 ret = dvb_usb_generic_rw(d, st->data, 1, st->data, 3, 0); 93 ret = dvb_usb_generic_rw(d, st->data, 1, st->data, 3, 0);
95 if (ret < 0) { 94 if (ret < 0) {
96 deb_rc("cinergyt2_power_ctrl() Failed to retrieve sleep " 95 deb_rc("cinergyt2_power_ctrl() Failed to retrieve sleep state info\n");
97 "state info\n");
98 } 96 }
99 mutex_unlock(&d->data_mutex); 97 mutex_unlock(&d->data_mutex);
100 98
diff --git a/drivers/media/usb/dvb-usb/cinergyT2-fe.c b/drivers/media/usb/dvb-usb/cinergyT2-fe.c
index 2d29b4174dba..bbb10fab65bc 100644
--- a/drivers/media/usb/dvb-usb/cinergyT2-fe.c
+++ b/drivers/media/usb/dvb-usb/cinergyT2-fe.c
@@ -278,7 +278,7 @@ static void cinergyt2_fe_release(struct dvb_frontend *fe)
278 kfree(state); 278 kfree(state);
279} 279}
280 280
281static struct dvb_frontend_ops cinergyt2_fe_ops; 281static const struct dvb_frontend_ops cinergyt2_fe_ops;
282 282
283struct dvb_frontend *cinergyt2_fe_attach(struct dvb_usb_device *d) 283struct dvb_frontend *cinergyt2_fe_attach(struct dvb_usb_device *d)
284{ 284{
@@ -295,7 +295,7 @@ struct dvb_frontend *cinergyt2_fe_attach(struct dvb_usb_device *d)
295} 295}
296 296
297 297
298static struct dvb_frontend_ops cinergyt2_fe_ops = { 298static const struct dvb_frontend_ops cinergyt2_fe_ops = {
299 .delsys = { SYS_DVBT }, 299 .delsys = { SYS_DVBT },
300 .info = { 300 .info = {
301 .name = DRIVER_NAME, 301 .name = DRIVER_NAME,
diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
index 243403081fa5..9b8771eb31d4 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -369,6 +369,26 @@ static int cxusb_aver_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
369 return 0; 369 return 0;
370} 370}
371 371
372static int cxusb_read_status(struct dvb_frontend *fe,
373 enum fe_status *status)
374{
375 struct dvb_usb_adapter *adap = (struct dvb_usb_adapter *)fe->dvb->priv;
376 struct cxusb_state *state = (struct cxusb_state *)adap->dev->priv;
377 int ret;
378
379 ret = state->fe_read_status(fe, status);
380
381 /* it need resync slave fifo when signal change from unlock to lock.*/
382 if ((*status & FE_HAS_LOCK) && (!state->last_lock)) {
383 mutex_lock(&state->stream_mutex);
384 cxusb_streaming_ctrl(adap, 1);
385 mutex_unlock(&state->stream_mutex);
386 }
387
388 state->last_lock = (*status & FE_HAS_LOCK) ? 1 : 0;
389 return ret;
390}
391
372static void cxusb_d680_dmb_drain_message(struct dvb_usb_device *d) 392static void cxusb_d680_dmb_drain_message(struct dvb_usb_device *d)
373{ 393{
374 int ep = d->props.generic_bulk_ctrl_endpoint; 394 int ep = d->props.generic_bulk_ctrl_endpoint;
@@ -1372,6 +1392,12 @@ static int cxusb_mygica_t230_frontend_attach(struct dvb_usb_adapter *adap)
1372 1392
1373 st->i2c_client_tuner = client_tuner; 1393 st->i2c_client_tuner = client_tuner;
1374 1394
1395 /* hook fe: need to resync the slave fifo when signal locks. */
1396 mutex_init(&st->stream_mutex);
1397 st->last_lock = 0;
1398 st->fe_read_status = adap->fe_adap[0].fe->ops.read_status;
1399 adap->fe_adap[0].fe->ops.read_status = cxusb_read_status;
1400
1375 return 0; 1401 return 0;
1376} 1402}
1377 1403
diff --git a/drivers/media/usb/dvb-usb/cxusb.h b/drivers/media/usb/dvb-usb/cxusb.h
index 18acda19527a..66429d7f69b5 100644
--- a/drivers/media/usb/dvb-usb/cxusb.h
+++ b/drivers/media/usb/dvb-usb/cxusb.h
@@ -37,6 +37,11 @@ struct cxusb_state {
37 struct i2c_client *i2c_client_tuner; 37 struct i2c_client *i2c_client_tuner;
38 38
39 unsigned char data[MAX_XFER_SIZE]; 39 unsigned char data[MAX_XFER_SIZE];
40
41 struct mutex stream_mutex;
42 u8 last_lock;
43 int (*fe_read_status)(struct dvb_frontend *fe,
44 enum fe_status *status);
40}; 45};
41 46
42#endif 47#endif
diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c b/drivers/media/usb/dvb-usb/dib0700_core.c
index 47ce9d5de4c6..dd5edd3a17ee 100644
--- a/drivers/media/usb/dvb-usb/dib0700_core.c
+++ b/drivers/media/usb/dvb-usb/dib0700_core.c
@@ -16,10 +16,7 @@ MODULE_PARM_DESC(debug, "set debugging level (1=info,2=fw,4=fwdata,8=data (or-ab
16static int nb_packet_buffer_size = 21; 16static int nb_packet_buffer_size = 21;
17module_param(nb_packet_buffer_size, int, 0644); 17module_param(nb_packet_buffer_size, int, 0644);
18MODULE_PARM_DESC(nb_packet_buffer_size, 18MODULE_PARM_DESC(nb_packet_buffer_size,
19 "Set the dib0700 driver data buffer size. This parameter " 19 "Set the dib0700 driver data buffer size. This parameter corresponds to the number of TS packets. The actual size of the data buffer corresponds to this parameter multiplied by 188 (default: 21)");
20 "corresponds to the number of TS packets. The actual size of "
21 "the data buffer corresponds to this parameter "
22 "multiplied by 188 (default: 21)");
23 20
24DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 21DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
25 22
diff --git a/drivers/media/usb/dvb-usb/dib0700_devices.c b/drivers/media/usb/dvb-usb/dib0700_devices.c
index ef1b8ee75c57..b29d4894c2f1 100644
--- a/drivers/media/usb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/usb/dvb-usb/dib0700_devices.c
@@ -26,8 +26,7 @@
26 26
27static int force_lna_activation; 27static int force_lna_activation;
28module_param(force_lna_activation, int, 0644); 28module_param(force_lna_activation, int, 0644);
29MODULE_PARM_DESC(force_lna_activation, "force the activation of Low-Noise-Amplifyer(s) (LNA), " 29MODULE_PARM_DESC(force_lna_activation, "force the activation of Low-Noise-Amplifyer(s) (LNA), if applicable for the device (default: 0=automatic/off).");
30 "if applicable for the device (default: 0=automatic/off).");
31 30
32struct dib0700_adapter_state { 31struct dib0700_adapter_state {
33 int (*set_param_save) (struct dvb_frontend *); 32 int (*set_param_save) (struct dvb_frontend *);
diff --git a/drivers/media/usb/dvb-usb/dibusb-common.c b/drivers/media/usb/dvb-usb/dibusb-common.c
index de3ee2547479..8207e6900656 100644
--- a/drivers/media/usb/dvb-usb/dibusb-common.c
+++ b/drivers/media/usb/dvb-usb/dibusb-common.c
@@ -382,9 +382,9 @@ int dibusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
382 if (buf[0] != 0) 382 if (buf[0] != 0)
383 deb_info("key: %*ph\n", 5, buf); 383 deb_info("key: %*ph\n", 5, buf);
384 384
385ret:
385 kfree(buf); 386 kfree(buf);
386 387
387ret:
388 return ret; 388 return ret;
389} 389}
390EXPORT_SYMBOL(dibusb_rc_query); 390EXPORT_SYMBOL(dibusb_rc_query);
diff --git a/drivers/media/usb/dvb-usb/dibusb-mc-common.c b/drivers/media/usb/dvb-usb/dibusb-mc-common.c
index d66f56cc46a5..c989cac9343d 100644
--- a/drivers/media/usb/dvb-usb/dibusb-mc-common.c
+++ b/drivers/media/usb/dvb-usb/dibusb-mc-common.c
@@ -9,7 +9,6 @@
9 * see Documentation/dvb/README.dvb-usb for more information 9 * see Documentation/dvb/README.dvb-usb for more information
10 */ 10 */
11 11
12#include <linux/kconfig.h>
13#include "dibusb.h" 12#include "dibusb.h"
14 13
15/* 3000MC/P stuff */ 14/* 3000MC/P stuff */
diff --git a/drivers/media/usb/dvb-usb/dtt200u-fe.c b/drivers/media/usb/dvb-usb/dtt200u-fe.c
index f5c042baa254..00f565fe7cc2 100644
--- a/drivers/media/usb/dvb-usb/dtt200u-fe.c
+++ b/drivers/media/usb/dvb-usb/dtt200u-fe.c
@@ -202,7 +202,7 @@ static void dtt200u_fe_release(struct dvb_frontend* fe)
202 kfree(state); 202 kfree(state);
203} 203}
204 204
205static struct dvb_frontend_ops dtt200u_fe_ops; 205static const struct dvb_frontend_ops dtt200u_fe_ops;
206 206
207struct dvb_frontend* dtt200u_fe_attach(struct dvb_usb_device *d) 207struct dvb_frontend* dtt200u_fe_attach(struct dvb_usb_device *d)
208{ 208{
@@ -226,7 +226,7 @@ error:
226 return NULL; 226 return NULL;
227} 227}
228 228
229static struct dvb_frontend_ops dtt200u_fe_ops = { 229static const struct dvb_frontend_ops dtt200u_fe_ops = {
230 .delsys = { SYS_DVBT }, 230 .delsys = { SYS_DVBT },
231 .info = { 231 .info = {
232 .name = "WideView USB DVB-T", 232 .name = "WideView USB DVB-T",
diff --git a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
index a04c0a250625..e5675da286cb 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
+++ b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
@@ -277,8 +277,7 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap)
277 for (i = 0; i < adap->props.num_frontends; i++) { 277 for (i = 0; i < adap->props.num_frontends; i++) {
278 278
279 if (adap->props.fe[i].frontend_attach == NULL) { 279 if (adap->props.fe[i].frontend_attach == NULL) {
280 err("strange: '%s' #%d,%d " 280 err("strange: '%s' #%d,%d doesn't want to attach a frontend.",
281 "doesn't want to attach a frontend.",
282 adap->dev->desc->name, adap->id, i); 281 adap->dev->desc->name, adap->id, i);
283 282
284 return 0; 283 return 0;
diff --git a/drivers/media/usb/dvb-usb/dvb-usb-firmware.c b/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
index dd048a7c461c..f0023dbb7276 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
+++ b/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
@@ -49,8 +49,7 @@ int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw
49 ret = usb_cypress_writemem(udev,hx.addr,hx.data,hx.len); 49 ret = usb_cypress_writemem(udev,hx.addr,hx.data,hx.len);
50 50
51 if (ret != hx.len) { 51 if (ret != hx.len) {
52 err("error while transferring firmware " 52 err("error while transferring firmware (transferred size: %d, block size: %d)",
53 "(transferred size: %d, block size: %d)",
54 ret,hx.len); 53 ret,hx.len);
55 ret = -EINVAL; 54 ret = -EINVAL;
56 break; 55 break;
@@ -81,8 +80,7 @@ int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_device_pro
81 const struct firmware *fw = NULL; 80 const struct firmware *fw = NULL;
82 81
83 if ((ret = request_firmware(&fw, props->firmware, &udev->dev)) != 0) { 82 if ((ret = request_firmware(&fw, props->firmware, &udev->dev)) != 0) {
84 err("did not find the firmware file. (%s) " 83 err("did not find the firmware file. (%s) Please see linux/Documentation/dvb/ for more details on firmware-problems. (%d)",
85 "Please see linux/Documentation/dvb/ for more details on firmware-problems. (%d)",
86 props->firmware,ret); 84 props->firmware,ret);
87 return ret; 85 return ret;
88 } 86 }
diff --git a/drivers/media/usb/dvb-usb/dvb-usb.h b/drivers/media/usb/dvb-usb/dvb-usb.h
index 107255b08b2b..67f898b6f6d0 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb.h
+++ b/drivers/media/usb/dvb-usb/dvb-usb.h
@@ -467,8 +467,10 @@ extern int dvb_usb_device_init(struct usb_interface *,
467extern void dvb_usb_device_exit(struct usb_interface *); 467extern void dvb_usb_device_exit(struct usb_interface *);
468 468
469/* the generic read/write method for device control */ 469/* the generic read/write method for device control */
470extern int dvb_usb_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16,int); 470extern int __must_check
471extern int dvb_usb_generic_write(struct dvb_usb_device *, u8 *, u16); 471dvb_usb_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16, int);
472extern int __must_check
473dvb_usb_generic_write(struct dvb_usb_device *, u8 *, u16);
472 474
473/* commonly used remote control parsing */ 475/* commonly used remote control parsing */
474extern int dvb_usb_nec_rc_key_to_event(struct dvb_usb_device *, u8[], u32 *, int *); 476extern int dvb_usb_nec_rc_key_to_event(struct dvb_usb_device *, u8[], u32 *, int *);
diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
index 2c720cb2fb00..6ca502d834b4 100644
--- a/drivers/media/usb/dvb-usb/dw2102.c
+++ b/drivers/media/usb/dvb-usb/dw2102.c
@@ -86,8 +86,7 @@ MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))."
86/* demod probe */ 86/* demod probe */
87static int demod_probe = 1; 87static int demod_probe = 1;
88module_param_named(demod, demod_probe, int, 0644); 88module_param_named(demod, demod_probe, int, 0644);
89MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 " 89MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 4=stv0903+stb6100(or-able)).");
90 "4=stv0903+stb6100(or-able)).");
91 90
92DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 91DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
93 92
@@ -1642,6 +1641,7 @@ enum dw2102_table_entry {
1642 TEVII_S632, 1641 TEVII_S632,
1643 TERRATEC_CINERGY_S2_R2, 1642 TERRATEC_CINERGY_S2_R2,
1644 TERRATEC_CINERGY_S2_R3, 1643 TERRATEC_CINERGY_S2_R3,
1644 TERRATEC_CINERGY_S2_R4,
1645 GOTVIEW_SAT_HD, 1645 GOTVIEW_SAT_HD,
1646 GENIATECH_T220, 1646 GENIATECH_T220,
1647 TECHNOTREND_S2_4600, 1647 TECHNOTREND_S2_4600,
@@ -1671,6 +1671,7 @@ static struct usb_device_id dw2102_table[] = {
1671 [TEVII_S632] = {USB_DEVICE(0x9022, USB_PID_TEVII_S632)}, 1671 [TEVII_S632] = {USB_DEVICE(0x9022, USB_PID_TEVII_S632)},
1672 [TERRATEC_CINERGY_S2_R2] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R2)}, 1672 [TERRATEC_CINERGY_S2_R2] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R2)},
1673 [TERRATEC_CINERGY_S2_R3] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R3)}, 1673 [TERRATEC_CINERGY_S2_R3] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R3)},
1674 [TERRATEC_CINERGY_S2_R4] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R4)},
1674 [GOTVIEW_SAT_HD] = {USB_DEVICE(0x1FE1, USB_PID_GOTVIEW_SAT_HD)}, 1675 [GOTVIEW_SAT_HD] = {USB_DEVICE(0x1FE1, USB_PID_GOTVIEW_SAT_HD)},
1675 [GENIATECH_T220] = {USB_DEVICE(0x1f4d, 0xD220)}, 1676 [GENIATECH_T220] = {USB_DEVICE(0x1f4d, 0xD220)},
1676 [TECHNOTREND_S2_4600] = {USB_DEVICE(USB_VID_TECHNOTREND, 1677 [TECHNOTREND_S2_4600] = {USB_DEVICE(USB_VID_TECHNOTREND,
@@ -2343,12 +2344,7 @@ static struct usb_driver dw2102_driver = {
2343module_usb_driver(dw2102_driver); 2344module_usb_driver(dw2102_driver);
2344 2345
2345MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by"); 2346MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
2346MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104," 2347MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101 USB2.0, TeVii S421, S480, S482, S600, S630, S632, S650, TeVii S660, S662, Prof 1100, 7500 USB2.0, Geniatech SU3000, T220, TechnoTrend S2-4600, Terratec Cinergy S2 devices");
2347 " DVB-C 3101 USB2.0,"
2348 " TeVii S421, S480, S482, S600, S630, S632, S650,"
2349 " TeVii S660, S662, Prof 1100, 7500 USB2.0,"
2350 " Geniatech SU3000, T220,"
2351 " TechnoTrend S2-4600, Terratec Cinergy S2 devices");
2352MODULE_VERSION("0.1"); 2348MODULE_VERSION("0.1");
2353MODULE_LICENSE("GPL"); 2349MODULE_LICENSE("GPL");
2354MODULE_FIRMWARE(DW2101_FIRMWARE); 2350MODULE_FIRMWARE(DW2101_FIRMWARE);
diff --git a/drivers/media/usb/dvb-usb/friio-fe.c b/drivers/media/usb/dvb-usb/friio-fe.c
index 979f05b4b87c..0251a4e91d47 100644
--- a/drivers/media/usb/dvb-usb/friio-fe.c
+++ b/drivers/media/usb/dvb-usb/friio-fe.c
@@ -401,7 +401,7 @@ static void jdvbt90502_release(struct dvb_frontend *fe)
401} 401}
402 402
403 403
404static struct dvb_frontend_ops jdvbt90502_ops; 404static const struct dvb_frontend_ops jdvbt90502_ops;
405 405
406struct dvb_frontend *jdvbt90502_attach(struct dvb_usb_device *d) 406struct dvb_frontend *jdvbt90502_attach(struct dvb_usb_device *d)
407{ 407{
@@ -432,7 +432,7 @@ error:
432 return NULL; 432 return NULL;
433} 433}
434 434
435static struct dvb_frontend_ops jdvbt90502_ops = { 435static const struct dvb_frontend_ops jdvbt90502_ops = {
436 .delsys = { SYS_ISDBT }, 436 .delsys = { SYS_ISDBT },
437 .info = { 437 .info = {
438 .name = "Comtech JDVBT90502 ISDB-T", 438 .name = "Comtech JDVBT90502 ISDB-T",
diff --git a/drivers/media/usb/dvb-usb/friio.c b/drivers/media/usb/dvb-usb/friio.c
index 474a17e4db0c..62abe6c43a32 100644
--- a/drivers/media/usb/dvb-usb/friio.c
+++ b/drivers/media/usb/dvb-usb/friio.c
@@ -320,8 +320,8 @@ restart:
320 */ 320 */
321 if (rbuf[0] & 0x80) { /* still in PowerOnReset state? */ 321 if (rbuf[0] & 0x80) { /* still in PowerOnReset state? */
322 if (++retry > 3) { 322 if (++retry > 3) {
323 deb_info("failed to get the correct" 323 deb_info("failed to get the correct FE demod status:0x%02x\n",
324 " FE demod status:0x%02x\n", rbuf[0]); 324 rbuf[0]);
325 goto error; 325 goto error;
326 } 326 }
327 msleep(100); 327 msleep(100);
diff --git a/drivers/media/usb/dvb-usb/gp8psk.c b/drivers/media/usb/dvb-usb/gp8psk.c
index 993bb7a72985..2360e7e32b06 100644
--- a/drivers/media/usb/dvb-usb/gp8psk.c
+++ b/drivers/media/usb/dvb-usb/gp8psk.c
@@ -135,8 +135,7 @@ static int gp8psk_load_bcm4500fw(struct dvb_usb_device *d)
135 u8 *buf; 135 u8 *buf;
136 if ((ret = request_firmware(&fw, bcm4500_firmware, 136 if ((ret = request_firmware(&fw, bcm4500_firmware,
137 &d->udev->dev)) != 0) { 137 &d->udev->dev)) != 0) {
138 err("did not find the bcm4500 firmware file. (%s) " 138 err("did not find the bcm4500 firmware file. (%s) Please see linux/Documentation/dvb/ for more details on firmware-problems. (%d)",
139 "Please see linux/Documentation/dvb/ for more details on firmware-problems. (%d)",
140 bcm4500_firmware,ret); 139 bcm4500_firmware,ret);
141 return ret; 140 return ret;
142 } 141 }
diff --git a/drivers/media/usb/dvb-usb/m920x.c b/drivers/media/usb/dvb-usb/m920x.c
index eafc5c82467f..70672e1e5ec7 100644
--- a/drivers/media/usb/dvb-usb/m920x.c
+++ b/drivers/media/usb/dvb-usb/m920x.c
@@ -55,13 +55,9 @@ static inline int m920x_read(struct usb_device *udev, u8 request, u16 value,
55static inline int m920x_write(struct usb_device *udev, u8 request, 55static inline int m920x_write(struct usb_device *udev, u8 request,
56 u16 value, u16 index) 56 u16 value, u16 index)
57{ 57{
58 int ret; 58 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), request,
59 59 USB_TYPE_VENDOR | USB_DIR_OUT, value, index,
60 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 60 NULL, 0, 2000);
61 request, USB_TYPE_VENDOR | USB_DIR_OUT,
62 value, index, NULL, 0, 2000);
63
64 return ret;
65} 61}
66 62
67static inline int m920x_write_seq(struct usb_device *udev, u8 request, 63static inline int m920x_write_seq(struct usb_device *udev, u8 request,
diff --git a/drivers/media/usb/dvb-usb/opera1.c b/drivers/media/usb/dvb-usb/opera1.c
index 2566d2f1c2ad..946a5ccc8f1a 100644
--- a/drivers/media/usb/dvb-usb/opera1.c
+++ b/drivers/media/usb/dvb-usb/opera1.c
@@ -453,8 +453,7 @@ static int opera1_xilinx_load_firmware(struct usb_device *dev,
453 info("start downloading fpga firmware %s",filename); 453 info("start downloading fpga firmware %s",filename);
454 454
455 if ((ret = request_firmware(&fw, filename, &dev->dev)) != 0) { 455 if ((ret = request_firmware(&fw, filename, &dev->dev)) != 0) {
456 err("did not find the firmware file. (%s) " 456 err("did not find the firmware file. (%s) Please see linux/Documentation/dvb/ for more details on firmware-problems.",
457 "Please see linux/Documentation/dvb/ for more details on firmware-problems.",
458 filename); 457 filename);
459 return ret; 458 return ret;
460 } else { 459 } else {
diff --git a/drivers/media/usb/dvb-usb/technisat-usb2.c b/drivers/media/usb/dvb-usb/technisat-usb2.c
index 4706628a3ed5..02c3bee6f83b 100644
--- a/drivers/media/usb/dvb-usb/technisat-usb2.c
+++ b/drivers/media/usb/dvb-usb/technisat-usb2.c
@@ -50,8 +50,7 @@ MODULE_PARM_DESC(debug,
50static int disable_led_control; 50static int disable_led_control;
51module_param(disable_led_control, int, 0444); 51module_param(disable_led_control, int, 0444);
52MODULE_PARM_DESC(disable_led_control, 52MODULE_PARM_DESC(disable_led_control,
53 "disable LED control of the device " 53 "disable LED control of the device (default: 0 - LED control is active).");
54 "(default: 0 - LED control is active).");
55 54
56/* device private data */ 55/* device private data */
57struct technisat_usb2_state { 56struct technisat_usb2_state {
diff --git a/drivers/media/usb/dvb-usb/vp702x-fe.c b/drivers/media/usb/dvb-usb/vp702x-fe.c
index 27398c08c69d..7ff31baa3682 100644
--- a/drivers/media/usb/dvb-usb/vp702x-fe.c
+++ b/drivers/media/usb/dvb-usb/vp702x-fe.c
@@ -323,7 +323,7 @@ static void vp702x_fe_release(struct dvb_frontend* fe)
323 kfree(st); 323 kfree(st);
324} 324}
325 325
326static struct dvb_frontend_ops vp702x_fe_ops; 326static const struct dvb_frontend_ops vp702x_fe_ops;
327 327
328struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d) 328struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d)
329{ 329{
@@ -345,7 +345,7 @@ error:
345} 345}
346 346
347 347
348static struct dvb_frontend_ops vp702x_fe_ops = { 348static const struct dvb_frontend_ops vp702x_fe_ops = {
349 .delsys = { SYS_DVBS }, 349 .delsys = { SYS_DVBS },
350 .info = { 350 .info = {
351 .name = "Twinhan DST-like frontend (VP7021/VP7020) DVB-S", 351 .name = "Twinhan DST-like frontend (VP7021/VP7020) DVB-S",
diff --git a/drivers/media/usb/dvb-usb/vp7045-fe.c b/drivers/media/usb/dvb-usb/vp7045-fe.c
index 7765602ea658..4520ad9c2014 100644
--- a/drivers/media/usb/dvb-usb/vp7045-fe.c
+++ b/drivers/media/usb/dvb-usb/vp7045-fe.c
@@ -140,7 +140,7 @@ static void vp7045_fe_release(struct dvb_frontend* fe)
140 kfree(state); 140 kfree(state);
141} 141}
142 142
143static struct dvb_frontend_ops vp7045_fe_ops; 143static const struct dvb_frontend_ops vp7045_fe_ops;
144 144
145struct dvb_frontend * vp7045_fe_attach(struct dvb_usb_device *d) 145struct dvb_frontend * vp7045_fe_attach(struct dvb_usb_device *d)
146{ 146{
@@ -158,7 +158,7 @@ error:
158} 158}
159 159
160 160
161static struct dvb_frontend_ops vp7045_fe_ops = { 161static const struct dvb_frontend_ops vp7045_fe_ops = {
162 .delsys = { SYS_DVBT }, 162 .delsys = { SYS_DVBT },
163 .info = { 163 .info = {
164 .name = "Twinhan VP7045/46 USB DVB-T", 164 .name = "Twinhan VP7045/46 USB DVB-T",
diff --git a/drivers/media/usb/em28xx/Kconfig b/drivers/media/usb/em28xx/Kconfig
index d917b0a2beb1..aa131cf9989b 100644
--- a/drivers/media/usb/em28xx/Kconfig
+++ b/drivers/media/usb/em28xx/Kconfig
@@ -11,7 +11,7 @@ config VIDEO_EM28XX_V4L2
11 select VIDEO_SAA711X if MEDIA_SUBDRV_AUTOSELECT 11 select VIDEO_SAA711X if MEDIA_SUBDRV_AUTOSELECT
12 select VIDEO_TVP5150 if MEDIA_SUBDRV_AUTOSELECT 12 select VIDEO_TVP5150 if MEDIA_SUBDRV_AUTOSELECT
13 select VIDEO_MSP3400 if MEDIA_SUBDRV_AUTOSELECT 13 select VIDEO_MSP3400 if MEDIA_SUBDRV_AUTOSELECT
14 select VIDEO_MT9V011 if MEDIA_SUBDRV_AUTOSELECT 14 select VIDEO_MT9V011 if MEDIA_SUBDRV_AUTOSELECT && MEDIA_CAMERA_SUPPORT
15 15
16 ---help--- 16 ---help---
17 This is a video4linux driver for Empia 28xx based TV cards. 17 This is a video4linux driver for Empia 28xx based TV cards.
diff --git a/drivers/media/usb/em28xx/em28xx-audio.c b/drivers/media/usb/em28xx/em28xx-audio.c
index e11fe46a547c..7969ddb9e2dd 100644
--- a/drivers/media/usb/em28xx/em28xx-audio.c
+++ b/drivers/media/usb/em28xx/em28xx-audio.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2006 Markus Rechberger <mrechberger@gmail.com> 4 * Copyright (C) 2006 Markus Rechberger <mrechberger@gmail.com>
5 * 5 *
6 * Copyright (C) 2007-2014 Mauro Carvalho Chehab 6 * Copyright (C) 2007-2016 Mauro Carvalho Chehab
7 * - Port to work with the in-kernel driver 7 * - Port to work with the in-kernel driver
8 * - Cleanups, fixes, alsa-controls, etc. 8 * - Cleanups, fixes, alsa-controls, etc.
9 * 9 *
@@ -25,6 +25,8 @@
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 */ 26 */
27 27
28#include "em28xx.h"
29
28#include <linux/kernel.h> 30#include <linux/kernel.h>
29#include <linux/usb.h> 31#include <linux/usb.h>
30#include <linux/init.h> 32#include <linux/init.h>
@@ -44,7 +46,6 @@
44#include <sound/tlv.h> 46#include <sound/tlv.h>
45#include <sound/ac97_codec.h> 47#include <sound/ac97_codec.h>
46#include <media/v4l2-common.h> 48#include <media/v4l2-common.h>
47#include "em28xx.h"
48 49
49static int debug; 50static int debug;
50module_param(debug, int, 0644); 51module_param(debug, int, 0644);
@@ -54,10 +55,10 @@ MODULE_PARM_DESC(debug, "activates debug info");
54#define EM28XX_MIN_AUDIO_PACKETS 64 55#define EM28XX_MIN_AUDIO_PACKETS 64
55 56
56#define dprintk(fmt, arg...) do { \ 57#define dprintk(fmt, arg...) do { \
57 if (debug) \ 58 if (debug) \
58 printk(KERN_INFO "em28xx-audio %s: " fmt, \ 59 dev_printk(KERN_DEBUG, &dev->intf->dev, \
59 __func__, ##arg); \ 60 "video: %s: " fmt, __func__, ## arg); \
60 } while (0) 61} while (0)
61 62
62static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 63static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
63 64
@@ -91,7 +92,8 @@ static void em28xx_audio_isocirq(struct urb *urb)
91 struct snd_pcm_runtime *runtime; 92 struct snd_pcm_runtime *runtime;
92 93
93 if (dev->disconnected) { 94 if (dev->disconnected) {
94 dprintk("device disconnected while streaming. URB status=%d.\n", urb->status); 95 dprintk("device disconnected while streaming. URB status=%d.\n",
96 urb->status);
95 atomic_set(&dev->adev.stream_started, 0); 97 atomic_set(&dev->adev.stream_started, 0);
96 return; 98 return;
97 } 99 }
@@ -164,8 +166,9 @@ static void em28xx_audio_isocirq(struct urb *urb)
164 166
165 status = usb_submit_urb(urb, GFP_ATOMIC); 167 status = usb_submit_urb(urb, GFP_ATOMIC);
166 if (status < 0) 168 if (status < 0)
167 em28xx_errdev("resubmit of audio urb failed (error=%i)\n", 169 dev_err(&dev->intf->dev,
168 status); 170 "resubmit of audio urb failed (error=%i)\n",
171 status);
169 return; 172 return;
170} 173}
171 174
@@ -182,8 +185,9 @@ static int em28xx_init_audio_isoc(struct em28xx *dev)
182 185
183 errCode = usb_submit_urb(dev->adev.urb[i], GFP_ATOMIC); 186 errCode = usb_submit_urb(dev->adev.urb[i], GFP_ATOMIC);
184 if (errCode) { 187 if (errCode) {
185 em28xx_errdev("submit of audio urb failed (error=%i)\n", 188 dev_err(&dev->intf->dev,
186 errCode); 189 "submit of audio urb failed (error=%i)\n",
190 errCode);
187 em28xx_deinit_isoc_audio(dev); 191 em28xx_deinit_isoc_audio(dev);
188 atomic_set(&dev->adev.stream_started, 0); 192 atomic_set(&dev->adev.stream_started, 0);
189 return errCode; 193 return errCode;
@@ -197,6 +201,7 @@ static int em28xx_init_audio_isoc(struct em28xx *dev)
197static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, 201static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs,
198 size_t size) 202 size_t size)
199{ 203{
204 struct em28xx *dev = snd_pcm_substream_chip(subs);
200 struct snd_pcm_runtime *runtime = subs->runtime; 205 struct snd_pcm_runtime *runtime = subs->runtime;
201 206
202 dprintk("Allocating vbuffer\n"); 207 dprintk("Allocating vbuffer\n");
@@ -254,8 +259,7 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
254 int nonblock, ret = 0; 259 int nonblock, ret = 0;
255 260
256 if (!dev) { 261 if (!dev) {
257 em28xx_err("BUG: em28xx can't find device struct." 262 pr_err("em28xx-audio: BUG: em28xx can't find device struct. Can't proceed with open\n");
258 " Can't proceed with open\n");
259 return -ENODEV; 263 return -ENODEV;
260 } 264 }
261 265
@@ -275,6 +279,8 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
275 279
276 if (dev->adev.users == 0) { 280 if (dev->adev.users == 0) {
277 if (dev->alt == 0 || dev->is_audio_only) { 281 if (dev->alt == 0 || dev->is_audio_only) {
282 struct usb_device *udev = interface_to_usbdev(dev->intf);
283
278 if (dev->is_audio_only) 284 if (dev->is_audio_only)
279 /* audio is on a separate interface */ 285 /* audio is on a separate interface */
280 dev->alt = 1; 286 dev->alt = 1;
@@ -292,7 +298,7 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
292 */ 298 */
293 dprintk("changing alternate number on interface %d to %d\n", 299 dprintk("changing alternate number on interface %d to %d\n",
294 dev->ifnum, dev->alt); 300 dev->ifnum, dev->alt);
295 usb_set_interface(dev->udev, dev->ifnum, dev->alt); 301 usb_set_interface(udev, dev->ifnum, dev->alt);
296 } 302 }
297 303
298 /* Sets volume, mute, etc */ 304 /* Sets volume, mute, etc */
@@ -318,7 +324,8 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
318err: 324err:
319 mutex_unlock(&dev->lock); 325 mutex_unlock(&dev->lock);
320 326
321 em28xx_err("Error while configuring em28xx mixer\n"); 327 dev_err(&dev->intf->dev,
328 "Error while configuring em28xx mixer\n");
322 return ret; 329 return ret;
323} 330}
324 331
@@ -709,6 +716,7 @@ static const struct snd_pcm_ops snd_em28xx_pcm_capture = {
709 716
710static void em28xx_audio_free_urb(struct em28xx *dev) 717static void em28xx_audio_free_urb(struct em28xx *dev)
711{ 718{
719 struct usb_device *udev = interface_to_usbdev(dev->intf);
712 int i; 720 int i;
713 721
714 for (i = 0; i < dev->adev.num_urb; i++) { 722 for (i = 0; i < dev->adev.num_urb; i++) {
@@ -717,7 +725,7 @@ static void em28xx_audio_free_urb(struct em28xx *dev)
717 if (!urb) 725 if (!urb)
718 continue; 726 continue;
719 727
720 usb_free_coherent(dev->udev, urb->transfer_buffer_length, 728 usb_free_coherent(udev, urb->transfer_buffer_length,
721 dev->adev.transfer_buffer[i], 729 dev->adev.transfer_buffer[i],
722 urb->transfer_dma); 730 urb->transfer_dma);
723 731
@@ -744,6 +752,7 @@ static int em28xx_audio_urb_init(struct em28xx *dev)
744{ 752{
745 struct usb_interface *intf; 753 struct usb_interface *intf;
746 struct usb_endpoint_descriptor *e, *ep = NULL; 754 struct usb_endpoint_descriptor *e, *ep = NULL;
755 struct usb_device *udev = interface_to_usbdev(dev->intf);
747 int i, ep_size, interval, num_urb, npackets; 756 int i, ep_size, interval, num_urb, npackets;
748 int urb_size, bytes_per_transfer; 757 int urb_size, bytes_per_transfer;
749 u8 alt; 758 u8 alt;
@@ -753,10 +762,10 @@ static int em28xx_audio_urb_init(struct em28xx *dev)
753 else 762 else
754 alt = 7; 763 alt = 7;
755 764
756 intf = usb_ifnum_to_if(dev->udev, dev->ifnum); 765 intf = usb_ifnum_to_if(udev, dev->ifnum);
757 766
758 if (intf->num_altsetting <= alt) { 767 if (intf->num_altsetting <= alt) {
759 em28xx_errdev("alt %d doesn't exist on interface %d\n", 768 dev_err(&dev->intf->dev, "alt %d doesn't exist on interface %d\n",
760 dev->ifnum, alt); 769 dev->ifnum, alt);
761 return -ENODEV; 770 return -ENODEV;
762 } 771 }
@@ -772,18 +781,17 @@ static int em28xx_audio_urb_init(struct em28xx *dev)
772 } 781 }
773 782
774 if (!ep) { 783 if (!ep) {
775 em28xx_errdev("Couldn't find an audio endpoint"); 784 dev_err(&dev->intf->dev, "Couldn't find an audio endpoint");
776 return -ENODEV; 785 return -ENODEV;
777 } 786 }
778 787
779 ep_size = em28xx_audio_ep_packet_size(dev->udev, ep); 788 ep_size = em28xx_audio_ep_packet_size(udev, ep);
780 interval = 1 << (ep->bInterval - 1); 789 interval = 1 << (ep->bInterval - 1);
781 790
782 em28xx_info("Endpoint 0x%02x %s on intf %d alt %d interval = %d, size %d\n", 791 dev_info(&dev->intf->dev,
783 EM28XX_EP_AUDIO, usb_speed_string(dev->udev->speed), 792 "Endpoint 0x%02x %s on intf %d alt %d interval = %d, size %d\n",
784 dev->ifnum, alt, 793 EM28XX_EP_AUDIO, usb_speed_string(udev->speed),
785 interval, 794 dev->ifnum, alt, interval, ep_size);
786 ep_size);
787 795
788 /* Calculate the number and size of URBs to better fit the audio samples */ 796 /* Calculate the number and size of URBs to better fit the audio samples */
789 797
@@ -820,8 +828,9 @@ static int em28xx_audio_urb_init(struct em28xx *dev)
820 if (urb_size > ep_size * npackets) 828 if (urb_size > ep_size * npackets)
821 npackets = DIV_ROUND_UP(urb_size, ep_size); 829 npackets = DIV_ROUND_UP(urb_size, ep_size);
822 830
823 em28xx_info("Number of URBs: %d, with %d packets and %d size\n", 831 dev_info(&dev->intf->dev,
824 num_urb, npackets, urb_size); 832 "Number of URBs: %d, with %d packets and %d size\n",
833 num_urb, npackets, urb_size);
825 834
826 /* Estimate the bytes per period */ 835 /* Estimate the bytes per period */
827 dev->adev.period = urb_size * npackets; 836 dev->adev.period = urb_size * npackets;
@@ -855,18 +864,19 @@ static int em28xx_audio_urb_init(struct em28xx *dev)
855 } 864 }
856 dev->adev.urb[i] = urb; 865 dev->adev.urb[i] = urb;
857 866
858 buf = usb_alloc_coherent(dev->udev, npackets * ep_size, GFP_ATOMIC, 867 buf = usb_alloc_coherent(udev, npackets * ep_size, GFP_ATOMIC,
859 &urb->transfer_dma); 868 &urb->transfer_dma);
860 if (!buf) { 869 if (!buf) {
861 em28xx_errdev("usb_alloc_coherent failed!\n"); 870 dev_err(&dev->intf->dev,
871 "usb_alloc_coherent failed!\n");
862 em28xx_audio_free_urb(dev); 872 em28xx_audio_free_urb(dev);
863 return -ENOMEM; 873 return -ENOMEM;
864 } 874 }
865 dev->adev.transfer_buffer[i] = buf; 875 dev->adev.transfer_buffer[i] = buf;
866 876
867 urb->dev = dev->udev; 877 urb->dev = udev;
868 urb->context = dev; 878 urb->context = dev;
869 urb->pipe = usb_rcvisocpipe(dev->udev, EM28XX_EP_AUDIO); 879 urb->pipe = usb_rcvisocpipe(udev, EM28XX_EP_AUDIO);
870 urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; 880 urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
871 urb->transfer_buffer = buf; 881 urb->transfer_buffer = buf;
872 urb->interval = interval; 882 urb->interval = interval;
@@ -886,6 +896,7 @@ static int em28xx_audio_urb_init(struct em28xx *dev)
886static int em28xx_audio_init(struct em28xx *dev) 896static int em28xx_audio_init(struct em28xx *dev)
887{ 897{
888 struct em28xx_audio *adev = &dev->adev; 898 struct em28xx_audio *adev = &dev->adev;
899 struct usb_device *udev = interface_to_usbdev(dev->intf);
889 struct snd_pcm *pcm; 900 struct snd_pcm *pcm;
890 struct snd_card *card; 901 struct snd_card *card;
891 static int devnr; 902 static int devnr;
@@ -898,23 +909,23 @@ static int em28xx_audio_init(struct em28xx *dev)
898 return 0; 909 return 0;
899 } 910 }
900 911
901 em28xx_info("Binding audio extension\n"); 912 dev_info(&dev->intf->dev, "Binding audio extension\n");
902 913
903 kref_get(&dev->ref); 914 kref_get(&dev->ref);
904 915
905 printk(KERN_INFO "em28xx-audio.c: Copyright (C) 2006 Markus " 916 dev_info(&dev->intf->dev,
906 "Rechberger\n"); 917 "em28xx-audio.c: Copyright (C) 2006 Markus Rechberger\n");
907 printk(KERN_INFO 918 dev_info(&dev->intf->dev,
908 "em28xx-audio.c: Copyright (C) 2007-2014 Mauro Carvalho Chehab\n"); 919 "em28xx-audio.c: Copyright (C) 2007-2016 Mauro Carvalho Chehab\n");
909 920
910 err = snd_card_new(&dev->udev->dev, index[devnr], "Em28xx Audio", 921 err = snd_card_new(&dev->intf->dev, index[devnr], "Em28xx Audio",
911 THIS_MODULE, 0, &card); 922 THIS_MODULE, 0, &card);
912 if (err < 0) 923 if (err < 0)
913 return err; 924 return err;
914 925
915 spin_lock_init(&adev->slock); 926 spin_lock_init(&adev->slock);
916 adev->sndcard = card; 927 adev->sndcard = card;
917 adev->udev = dev->udev; 928 adev->udev = udev;
918 929
919 err = snd_pcm_new(card, "Em28xx Audio", 0, 0, 1, &pcm); 930 err = snd_pcm_new(card, "Em28xx Audio", 0, 0, 1, &pcm);
920 if (err < 0) 931 if (err < 0)
@@ -955,7 +966,7 @@ static int em28xx_audio_init(struct em28xx *dev)
955 if (err < 0) 966 if (err < 0)
956 goto urb_free; 967 goto urb_free;
957 968
958 em28xx_info("Audio extension successfully initialized\n"); 969 dev_info(&dev->intf->dev, "Audio extension successfully initialized\n");
959 return 0; 970 return 0;
960 971
961urb_free: 972urb_free:
@@ -980,7 +991,7 @@ static int em28xx_audio_fini(struct em28xx *dev)
980 return 0; 991 return 0;
981 } 992 }
982 993
983 em28xx_info("Closing audio extension\n"); 994 dev_info(&dev->intf->dev, "Closing audio extension\n");
984 995
985 if (dev->adev.sndcard) { 996 if (dev->adev.sndcard) {
986 snd_card_disconnect(dev->adev.sndcard); 997 snd_card_disconnect(dev->adev.sndcard);
@@ -1004,7 +1015,7 @@ static int em28xx_audio_suspend(struct em28xx *dev)
1004 if (dev->usb_audio_type != EM28XX_USB_AUDIO_VENDOR) 1015 if (dev->usb_audio_type != EM28XX_USB_AUDIO_VENDOR)
1005 return 0; 1016 return 0;
1006 1017
1007 em28xx_info("Suspending audio extension\n"); 1018 dev_info(&dev->intf->dev, "Suspending audio extension\n");
1008 em28xx_deinit_isoc_audio(dev); 1019 em28xx_deinit_isoc_audio(dev);
1009 atomic_set(&dev->adev.stream_started, 0); 1020 atomic_set(&dev->adev.stream_started, 0);
1010 return 0; 1021 return 0;
@@ -1018,7 +1029,7 @@ static int em28xx_audio_resume(struct em28xx *dev)
1018 if (dev->usb_audio_type != EM28XX_USB_AUDIO_VENDOR) 1029 if (dev->usb_audio_type != EM28XX_USB_AUDIO_VENDOR)
1019 return 0; 1030 return 0;
1020 1031
1021 em28xx_info("Resuming audio extension\n"); 1032 dev_info(&dev->intf->dev, "Resuming audio extension\n");
1022 /* Nothing to do other than schedule_work() ?? */ 1033 /* Nothing to do other than schedule_work() ?? */
1023 schedule_work(&dev->adev.wq_trigger); 1034 schedule_work(&dev->adev.wq_trigger);
1024 return 0; 1035 return 0;
diff --git a/drivers/media/usb/em28xx/em28xx-camera.c b/drivers/media/usb/em28xx/em28xx-camera.c
index 72f3f4d50253..89c890ba7dd6 100644
--- a/drivers/media/usb/em28xx/em28xx-camera.c
+++ b/drivers/media/usb/em28xx/em28xx-camera.c
@@ -19,14 +19,15 @@
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/ 20*/
21 21
22#include "em28xx.h"
23
22#include <linux/i2c.h> 24#include <linux/i2c.h>
25#include <linux/usb.h>
23#include <media/soc_camera.h> 26#include <media/soc_camera.h>
24#include <media/i2c/mt9v011.h> 27#include <media/i2c/mt9v011.h>
25#include <media/v4l2-clk.h> 28#include <media/v4l2-clk.h>
26#include <media/v4l2-common.h> 29#include <media/v4l2-common.h>
27 30
28#include "em28xx.h"
29
30/* Possible i2c addresses of Micron sensors */ 31/* Possible i2c addresses of Micron sensors */
31static unsigned short micron_sensor_addrs[] = { 32static unsigned short micron_sensor_addrs[] = {
32 0xb8 >> 1, /* MT9V111, MT9V403 */ 33 0xb8 >> 1, /* MT9V111, MT9V403 */
@@ -120,14 +121,16 @@ static int em28xx_probe_sensor_micron(struct em28xx *dev)
120 ret = i2c_master_send(&client, &reg, 1); 121 ret = i2c_master_send(&client, &reg, 1);
121 if (ret < 0) { 122 if (ret < 0) {
122 if (ret != -ENXIO) 123 if (ret != -ENXIO)
123 em28xx_errdev("couldn't read from i2c device 0x%02x: error %i\n", 124 dev_err(&dev->intf->dev,
124 client.addr << 1, ret); 125 "couldn't read from i2c device 0x%02x: error %i\n",
126 client.addr << 1, ret);
125 continue; 127 continue;
126 } 128 }
127 ret = i2c_master_recv(&client, (u8 *)&id_be, 2); 129 ret = i2c_master_recv(&client, (u8 *)&id_be, 2);
128 if (ret < 0) { 130 if (ret < 0) {
129 em28xx_errdev("couldn't read from i2c device 0x%02x: error %i\n", 131 dev_err(&dev->intf->dev,
130 client.addr << 1, ret); 132 "couldn't read from i2c device 0x%02x: error %i\n",
133 client.addr << 1, ret);
131 continue; 134 continue;
132 } 135 }
133 id = be16_to_cpu(id_be); 136 id = be16_to_cpu(id_be);
@@ -135,14 +138,16 @@ static int em28xx_probe_sensor_micron(struct em28xx *dev)
135 reg = 0xff; 138 reg = 0xff;
136 ret = i2c_master_send(&client, &reg, 1); 139 ret = i2c_master_send(&client, &reg, 1);
137 if (ret < 0) { 140 if (ret < 0) {
138 em28xx_errdev("couldn't read from i2c device 0x%02x: error %i\n", 141 dev_err(&dev->intf->dev,
139 client.addr << 1, ret); 142 "couldn't read from i2c device 0x%02x: error %i\n",
143 client.addr << 1, ret);
140 continue; 144 continue;
141 } 145 }
142 ret = i2c_master_recv(&client, (u8 *)&id_be, 2); 146 ret = i2c_master_recv(&client, (u8 *)&id_be, 2);
143 if (ret < 0) { 147 if (ret < 0) {
144 em28xx_errdev("couldn't read from i2c device 0x%02x: error %i\n", 148 dev_err(&dev->intf->dev,
145 client.addr << 1, ret); 149 "couldn't read from i2c device 0x%02x: error %i\n",
150 client.addr << 1, ret);
146 continue; 151 continue;
147 } 152 }
148 /* Validate chip ID to be sure we have a Micron device */ 153 /* Validate chip ID to be sure we have a Micron device */
@@ -180,15 +185,17 @@ static int em28xx_probe_sensor_micron(struct em28xx *dev)
180 dev->em28xx_sensor = EM28XX_MT9M001; 185 dev->em28xx_sensor = EM28XX_MT9M001;
181 break; 186 break;
182 default: 187 default:
183 em28xx_info("unknown Micron sensor detected: 0x%04x\n", 188 dev_info(&dev->intf->dev,
184 id); 189 "unknown Micron sensor detected: 0x%04x\n", id);
185 return 0; 190 return 0;
186 } 191 }
187 192
188 if (dev->em28xx_sensor == EM28XX_NOSENSOR) 193 if (dev->em28xx_sensor == EM28XX_NOSENSOR)
189 em28xx_info("unsupported sensor detected: %s\n", name); 194 dev_info(&dev->intf->dev,
195 "unsupported sensor detected: %s\n", name);
190 else 196 else
191 em28xx_info("sensor %s detected\n", name); 197 dev_info(&dev->intf->dev,
198 "sensor %s detected\n", name);
192 199
193 dev->i2c_client[dev->def_i2c_bus].addr = client.addr; 200 dev->i2c_client[dev->def_i2c_bus].addr = client.addr;
194 return 0; 201 return 0;
@@ -218,16 +225,18 @@ static int em28xx_probe_sensor_omnivision(struct em28xx *dev)
218 ret = i2c_smbus_read_byte_data(&client, reg); 225 ret = i2c_smbus_read_byte_data(&client, reg);
219 if (ret < 0) { 226 if (ret < 0) {
220 if (ret != -ENXIO) 227 if (ret != -ENXIO)
221 em28xx_errdev("couldn't read from i2c device 0x%02x: error %i\n", 228 dev_err(&dev->intf->dev,
222 client.addr << 1, ret); 229 "couldn't read from i2c device 0x%02x: error %i\n",
230 client.addr << 1, ret);
223 continue; 231 continue;
224 } 232 }
225 id = ret << 8; 233 id = ret << 8;
226 reg = 0x1d; 234 reg = 0x1d;
227 ret = i2c_smbus_read_byte_data(&client, reg); 235 ret = i2c_smbus_read_byte_data(&client, reg);
228 if (ret < 0) { 236 if (ret < 0) {
229 em28xx_errdev("couldn't read from i2c device 0x%02x: error %i\n", 237 dev_err(&dev->intf->dev,
230 client.addr << 1, ret); 238 "couldn't read from i2c device 0x%02x: error %i\n",
239 client.addr << 1, ret);
231 continue; 240 continue;
232 } 241 }
233 id += ret; 242 id += ret;
@@ -238,16 +247,18 @@ static int em28xx_probe_sensor_omnivision(struct em28xx *dev)
238 reg = 0x0a; 247 reg = 0x0a;
239 ret = i2c_smbus_read_byte_data(&client, reg); 248 ret = i2c_smbus_read_byte_data(&client, reg);
240 if (ret < 0) { 249 if (ret < 0) {
241 em28xx_errdev("couldn't read from i2c device 0x%02x: error %i\n", 250 dev_err(&dev->intf->dev,
242 client.addr << 1, ret); 251 "couldn't read from i2c device 0x%02x: error %i\n",
252 client.addr << 1, ret);
243 continue; 253 continue;
244 } 254 }
245 id = ret << 8; 255 id = ret << 8;
246 reg = 0x0b; 256 reg = 0x0b;
247 ret = i2c_smbus_read_byte_data(&client, reg); 257 ret = i2c_smbus_read_byte_data(&client, reg);
248 if (ret < 0) { 258 if (ret < 0) {
249 em28xx_errdev("couldn't read from i2c device 0x%02x: error %i\n", 259 dev_err(&dev->intf->dev,
250 client.addr << 1, ret); 260 "couldn't read from i2c device 0x%02x: error %i\n",
261 client.addr << 1, ret);
251 continue; 262 continue;
252 } 263 }
253 id += ret; 264 id += ret;
@@ -285,15 +296,18 @@ static int em28xx_probe_sensor_omnivision(struct em28xx *dev)
285 name = "OV9655"; 296 name = "OV9655";
286 break; 297 break;
287 default: 298 default:
288 em28xx_info("unknown OmniVision sensor detected: 0x%04x\n", 299 dev_info(&dev->intf->dev,
289 id); 300 "unknown OmniVision sensor detected: 0x%04x\n",
301 id);
290 return 0; 302 return 0;
291 } 303 }
292 304
293 if (dev->em28xx_sensor == EM28XX_NOSENSOR) 305 if (dev->em28xx_sensor == EM28XX_NOSENSOR)
294 em28xx_info("unsupported sensor detected: %s\n", name); 306 dev_info(&dev->intf->dev,
307 "unsupported sensor detected: %s\n", name);
295 else 308 else
296 em28xx_info("sensor %s detected\n", name); 309 dev_info(&dev->intf->dev,
310 "sensor %s detected\n", name);
297 311
298 dev->i2c_client[dev->def_i2c_bus].addr = client.addr; 312 dev->i2c_client[dev->def_i2c_bus].addr = client.addr;
299 return 0; 313 return 0;
@@ -317,7 +331,8 @@ int em28xx_detect_sensor(struct em28xx *dev)
317 */ 331 */
318 332
319 if (dev->em28xx_sensor == EM28XX_NOSENSOR && ret < 0) { 333 if (dev->em28xx_sensor == EM28XX_NOSENSOR && ret < 0) {
320 em28xx_info("No sensor detected\n"); 334 dev_info(&dev->intf->dev,
335 "No sensor detected\n");
321 return -ENODEV; 336 return -ENODEV;
322 } 337 }
323 338
diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c
index e397f544f108..23c67494762d 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -23,6 +23,8 @@
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 24 */
25 25
26#include "em28xx.h"
27
26#include <linux/init.h> 28#include <linux/init.h>
27#include <linux/module.h> 29#include <linux/module.h>
28#include <linux/slab.h> 30#include <linux/slab.h>
@@ -39,7 +41,6 @@
39#include <media/v4l2-common.h> 41#include <media/v4l2-common.h>
40#include <sound/ac97_codec.h> 42#include <sound/ac97_codec.h>
41 43
42#include "em28xx.h"
43 44
44#define DRIVER_NAME "em28xx" 45#define DRIVER_NAME "em28xx"
45 46
@@ -1560,8 +1561,7 @@ struct em28xx_board em28xx_boards[] = {
1560 } }, 1561 } },
1561 }, 1562 },
1562 [EM2820_BOARD_PINNACLE_DVC_90] = { 1563 [EM2820_BOARD_PINNACLE_DVC_90] = {
1563 .name = "Pinnacle Dazzle DVC 90/100/101/107 / Kaiser Baas Video to DVD maker " 1564 .name = "Pinnacle Dazzle DVC 90/100/101/107 / Kaiser Baas Video to DVD maker / Kworld DVD Maker 2 / Plextor ConvertX PX-AV100U",
1564 "/ Kworld DVD Maker 2 / Plextor ConvertX PX-AV100U",
1565 .tuner_type = TUNER_ABSENT, /* capture only board */ 1565 .tuner_type = TUNER_ABSENT, /* capture only board */
1566 .decoder = EM28XX_SAA711X, 1566 .decoder = EM28XX_SAA711X,
1567 .input = { { 1567 .input = { {
@@ -2677,7 +2677,7 @@ static int em28xx_wait_until_ac97_features_equals(struct em28xx *dev,
2677 msleep(50); 2677 msleep(50);
2678 } 2678 }
2679 2679
2680 em28xx_warn("AC97 registers access is not reliable !\n"); 2680 dev_warn(&dev->intf->dev, "AC97 registers access is not reliable !\n");
2681 return -ETIMEDOUT; 2681 return -ETIMEDOUT;
2682} 2682}
2683 2683
@@ -2831,16 +2831,14 @@ static int em28xx_hint_board(struct em28xx *dev)
2831 dev->model = em28xx_eeprom_hash[i].model; 2831 dev->model = em28xx_eeprom_hash[i].model;
2832 dev->tuner_type = em28xx_eeprom_hash[i].tuner; 2832 dev->tuner_type = em28xx_eeprom_hash[i].tuner;
2833 2833
2834 em28xx_errdev("Your board has no unique USB ID.\n"); 2834 dev_err(&dev->intf->dev,
2835 em28xx_errdev("A hint were successfully done, " 2835 "Your board has no unique USB ID.\n"
2836 "based on eeprom hash.\n"); 2836 "A hint were successfully done, based on eeprom hash.\n"
2837 em28xx_errdev("This method is not 100%% failproof.\n"); 2837 "This method is not 100%% failproof.\n"
2838 em28xx_errdev("If the board were missdetected, " 2838 "If the board were missdetected, please email this log to:\n"
2839 "please email this log to:\n"); 2839 "\tV4L Mailing List <linux-media@vger.kernel.org>\n"
2840 em28xx_errdev("\tV4L Mailing List " 2840 "Board detected as %s\n",
2841 " <linux-media@vger.kernel.org>\n"); 2841 em28xx_boards[dev->model].name);
2842 em28xx_errdev("Board detected as %s\n",
2843 em28xx_boards[dev->model].name);
2844 2842
2845 return 0; 2843 return 0;
2846 } 2844 }
@@ -2863,35 +2861,33 @@ static int em28xx_hint_board(struct em28xx *dev)
2863 if (dev->i2c_hash == em28xx_i2c_hash[i].hash) { 2861 if (dev->i2c_hash == em28xx_i2c_hash[i].hash) {
2864 dev->model = em28xx_i2c_hash[i].model; 2862 dev->model = em28xx_i2c_hash[i].model;
2865 dev->tuner_type = em28xx_i2c_hash[i].tuner; 2863 dev->tuner_type = em28xx_i2c_hash[i].tuner;
2866 em28xx_errdev("Your board has no unique USB ID.\n"); 2864 dev_err(&dev->intf->dev,
2867 em28xx_errdev("A hint were successfully done, " 2865 "Your board has no unique USB ID.\n"
2868 "based on i2c devicelist hash.\n"); 2866 "A hint were successfully done, based on i2c devicelist hash.\n"
2869 em28xx_errdev("This method is not 100%% failproof.\n"); 2867 "This method is not 100%% failproof.\n"
2870 em28xx_errdev("If the board were missdetected, " 2868 "If the board were missdetected, please email this log to:\n"
2871 "please email this log to:\n"); 2869 "\tV4L Mailing List <linux-media@vger.kernel.org>\n"
2872 em28xx_errdev("\tV4L Mailing List " 2870 "Board detected as %s\n",
2873 " <linux-media@vger.kernel.org>\n"); 2871 em28xx_boards[dev->model].name);
2874 em28xx_errdev("Board detected as %s\n",
2875 em28xx_boards[dev->model].name);
2876 2872
2877 return 0; 2873 return 0;
2878 } 2874 }
2879 } 2875 }
2880 2876
2881 em28xx_errdev("Your board has no unique USB ID and thus need a " 2877 dev_err(&dev->intf->dev,
2882 "hint to be detected.\n"); 2878 "Your board has no unique USB ID and thus need a hint to be detected.\n"
2883 em28xx_errdev("You may try to use card=<n> insmod option to " 2879 "You may try to use card=<n> insmod option to workaround that.\n"
2884 "workaround that.\n"); 2880 "Please send an email with this log to:\n"
2885 em28xx_errdev("Please send an email with this log to:\n"); 2881 "\tV4L Mailing List <linux-media@vger.kernel.org>\n"
2886 em28xx_errdev("\tV4L Mailing List <linux-media@vger.kernel.org>\n"); 2882 "Board eeprom hash is 0x%08lx\n"
2887 em28xx_errdev("Board eeprom hash is 0x%08lx\n", dev->hash); 2883 "Board i2c devicelist hash is 0x%08lx\n",
2888 em28xx_errdev("Board i2c devicelist hash is 0x%08lx\n", dev->i2c_hash); 2884 dev->hash, dev->i2c_hash);
2889 2885
2890 em28xx_errdev("Here is a list of valid choices for the card=<n>" 2886 dev_err(&dev->intf->dev,
2891 " insmod option:\n"); 2887 "Here is a list of valid choices for the card=<n> insmod option:\n");
2892 for (i = 0; i < em28xx_bcount; i++) { 2888 for (i = 0; i < em28xx_bcount; i++) {
2893 em28xx_errdev(" card=%d -> %s\n", 2889 dev_err(&dev->intf->dev,
2894 i, em28xx_boards[i].name); 2890 " card=%d -> %s\n", i, em28xx_boards[i].name);
2895 } 2891 }
2896 return -1; 2892 return -1;
2897} 2893}
@@ -2925,7 +2921,7 @@ static void em28xx_card_setup(struct em28xx *dev)
2925 * hash identities which has not been determined as yet. 2921 * hash identities which has not been determined as yet.
2926 */ 2922 */
2927 if (em28xx_hint_board(dev) < 0) 2923 if (em28xx_hint_board(dev) < 0)
2928 em28xx_errdev("Board not discovered\n"); 2924 dev_err(&dev->intf->dev, "Board not discovered\n");
2929 else { 2925 else {
2930 em28xx_set_model(dev); 2926 em28xx_set_model(dev);
2931 em28xx_pre_card_setup(dev); 2927 em28xx_pre_card_setup(dev);
@@ -2935,8 +2931,8 @@ static void em28xx_card_setup(struct em28xx *dev)
2935 em28xx_set_model(dev); 2931 em28xx_set_model(dev);
2936 } 2932 }
2937 2933
2938 em28xx_info("Identified as %s (card=%d)\n", 2934 dev_info(&dev->intf->dev, "Identified as %s (card=%d)\n",
2939 dev->board.name, dev->model); 2935 dev->board.name, dev->model);
2940 2936
2941 dev->tuner_type = em28xx_boards[dev->model].tuner_type; 2937 dev->tuner_type = em28xx_boards[dev->model].tuner_type;
2942 2938
@@ -3034,12 +3030,11 @@ static void em28xx_card_setup(struct em28xx *dev)
3034 } 3030 }
3035 3031
3036 if (dev->board.valid == EM28XX_BOARD_NOT_VALIDATED) { 3032 if (dev->board.valid == EM28XX_BOARD_NOT_VALIDATED) {
3037 em28xx_errdev("\n\n"); 3033 dev_err(&dev->intf->dev,
3038 em28xx_errdev("The support for this board weren't " 3034 "\n\n"
3039 "valid yet.\n"); 3035 "The support for this board weren't valid yet.\n"
3040 em28xx_errdev("Please send a report of having this working\n"); 3036 "Please send a report of having this working\n"
3041 em28xx_errdev("not to V4L mailing list (and/or to other " 3037 "not to V4L mailing list (and/or to other addresses)\n\n");
3042 "addresses)\n\n");
3043 } 3038 }
3044 3039
3045 /* Free eeprom data memory */ 3040 /* Free eeprom data memory */
@@ -3166,7 +3161,7 @@ static int em28xx_media_device_init(struct em28xx *dev,
3166 else if (udev->manufacturer) 3161 else if (udev->manufacturer)
3167 media_device_usb_init(mdev, udev, udev->manufacturer); 3162 media_device_usb_init(mdev, udev, udev->manufacturer);
3168 else 3163 else
3169 media_device_usb_init(mdev, udev, dev->name); 3164 media_device_usb_init(mdev, udev, dev_name(&dev->intf->dev));
3170 3165
3171 dev->media_dev = mdev; 3166 dev->media_dev = mdev;
3172#endif 3167#endif
@@ -3193,6 +3188,8 @@ static void em28xx_unregister_media_device(struct em28xx *dev)
3193*/ 3188*/
3194static void em28xx_release_resources(struct em28xx *dev) 3189static void em28xx_release_resources(struct em28xx *dev)
3195{ 3190{
3191 struct usb_device *udev = interface_to_usbdev(dev->intf);
3192
3196 /*FIXME: I2C IR should be disconnected */ 3193 /*FIXME: I2C IR should be disconnected */
3197 3194
3198 mutex_lock(&dev->lock); 3195 mutex_lock(&dev->lock);
@@ -3203,7 +3200,7 @@ static void em28xx_release_resources(struct em28xx *dev)
3203 em28xx_i2c_unregister(dev, 1); 3200 em28xx_i2c_unregister(dev, 1);
3204 em28xx_i2c_unregister(dev, 0); 3201 em28xx_i2c_unregister(dev, 0);
3205 3202
3206 usb_put_dev(dev->udev); 3203 usb_put_dev(udev);
3207 3204
3208 /* Mark device as unused */ 3205 /* Mark device as unused */
3209 clear_bit(dev->devno, em28xx_devused); 3206 clear_bit(dev->devno, em28xx_devused);
@@ -3222,7 +3219,7 @@ void em28xx_free_device(struct kref *ref)
3222{ 3219{
3223 struct em28xx *dev = kref_to_dev(ref); 3220 struct em28xx *dev = kref_to_dev(ref);
3224 3221
3225 em28xx_info("Freeing device\n"); 3222 dev_info(&dev->intf->dev, "Freeing device\n");
3226 3223
3227 if (!dev->disconnected) 3224 if (!dev->disconnected)
3228 em28xx_release_resources(dev); 3225 em28xx_release_resources(dev);
@@ -3241,10 +3238,9 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
3241 int minor) 3238 int minor)
3242{ 3239{
3243 int retval; 3240 int retval;
3244 static const char *default_chip_name = "em28xx"; 3241 const char *chip_name = NULL;
3245 const char *chip_name = default_chip_name;
3246 3242
3247 dev->udev = udev; 3243 dev->intf = interface;
3248 mutex_init(&dev->ctrl_urb_lock); 3244 mutex_init(&dev->ctrl_urb_lock);
3249 spin_lock_init(&dev->slock); 3245 spin_lock_init(&dev->slock);
3250 3246
@@ -3282,9 +3278,8 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
3282 break; 3278 break;
3283 case CHIP_ID_EM2820: 3279 case CHIP_ID_EM2820:
3284 chip_name = "em2710/2820"; 3280 chip_name = "em2710/2820";
3285 if (le16_to_cpu(dev->udev->descriptor.idVendor) 3281 if (le16_to_cpu(udev->descriptor.idVendor) == 0xeb1a) {
3286 == 0xeb1a) { 3282 __le16 idProd = udev->descriptor.idProduct;
3287 __le16 idProd = dev->udev->descriptor.idProduct;
3288 3283
3289 if (le16_to_cpu(idProd) == 0x2710) 3284 if (le16_to_cpu(idProd) == 0x2710)
3290 chip_name = "em2710"; 3285 chip_name = "em2710";
@@ -3327,21 +3322,13 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
3327 dev->wait_after_write = 0; 3322 dev->wait_after_write = 0;
3328 dev->eeprom_addrwidth_16bit = 1; 3323 dev->eeprom_addrwidth_16bit = 1;
3329 break; 3324 break;
3330 default:
3331 printk(KERN_INFO DRIVER_NAME
3332 ": unknown em28xx chip ID (%d)\n", dev->chip_id);
3333 } 3325 }
3334 } 3326 }
3335 3327 if (!chip_name)
3336 if (chip_name != default_chip_name) 3328 dev_info(&dev->intf->dev,
3337 printk(KERN_INFO DRIVER_NAME 3329 "unknown em28xx chip ID (%d)\n", dev->chip_id);
3338 ": chip ID is %s\n", chip_name); 3330 else
3339 3331 dev_info(&dev->intf->dev, "chip ID is %s\n", chip_name);
3340 /*
3341 * For em2820/em2710, the name may change latter, after checking
3342 * if the device has a sensor (so, it is em2710) or not.
3343 */
3344 snprintf(dev->name, sizeof(dev->name), "%s #%d", chip_name, dev->devno);
3345 3332
3346 em28xx_media_device_init(dev, udev); 3333 em28xx_media_device_init(dev, udev);
3347 3334
@@ -3360,9 +3347,9 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
3360 /* Resets I2C speed */ 3347 /* Resets I2C speed */
3361 retval = em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, dev->board.i2c_speed); 3348 retval = em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, dev->board.i2c_speed);
3362 if (retval < 0) { 3349 if (retval < 0) {
3363 em28xx_errdev("%s: em28xx_write_reg failed!" 3350 dev_err(&dev->intf->dev,
3364 " retval [%d]\n", 3351 "%s: em28xx_write_reg failed! retval [%d]\n",
3365 __func__, retval); 3352 __func__, retval);
3366 return retval; 3353 return retval;
3367 } 3354 }
3368 } 3355 }
@@ -3375,8 +3362,9 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
3375 else 3362 else
3376 retval = em28xx_i2c_register(dev, 0, EM28XX_I2C_ALGO_EM28XX); 3363 retval = em28xx_i2c_register(dev, 0, EM28XX_I2C_ALGO_EM28XX);
3377 if (retval < 0) { 3364 if (retval < 0) {
3378 em28xx_errdev("%s: em28xx_i2c_register bus 0 - error [%d]!\n", 3365 dev_err(&dev->intf->dev,
3379 __func__, retval); 3366 "%s: em28xx_i2c_register bus 0 - error [%d]!\n",
3367 __func__, retval);
3380 return retval; 3368 return retval;
3381 } 3369 }
3382 3370
@@ -3389,8 +3377,9 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
3389 retval = em28xx_i2c_register(dev, 1, 3377 retval = em28xx_i2c_register(dev, 1,
3390 EM28XX_I2C_ALGO_EM28XX); 3378 EM28XX_I2C_ALGO_EM28XX);
3391 if (retval < 0) { 3379 if (retval < 0) {
3392 em28xx_errdev("%s: em28xx_i2c_register bus 1 - error [%d]!\n", 3380 dev_err(&dev->intf->dev,
3393 __func__, retval); 3381 "%s: em28xx_i2c_register bus 1 - error [%d]!\n",
3382 __func__, retval);
3394 3383
3395 em28xx_i2c_unregister(dev, 0); 3384 em28xx_i2c_unregister(dev, 0);
3396 3385
@@ -3429,7 +3418,8 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3429 nr = find_first_zero_bit(em28xx_devused, EM28XX_MAXBOARDS); 3418 nr = find_first_zero_bit(em28xx_devused, EM28XX_MAXBOARDS);
3430 if (nr >= EM28XX_MAXBOARDS) { 3419 if (nr >= EM28XX_MAXBOARDS) {
3431 /* No free device slots */ 3420 /* No free device slots */
3432 printk(DRIVER_NAME ": Supports only %i em28xx boards.\n", 3421 dev_err(&interface->dev,
3422 "Driver supports up to %i em28xx boards.\n",
3433 EM28XX_MAXBOARDS); 3423 EM28XX_MAXBOARDS);
3434 retval = -ENOMEM; 3424 retval = -ENOMEM;
3435 goto err_no_slot; 3425 goto err_no_slot;
@@ -3438,8 +3428,8 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3438 3428
3439 /* Don't register audio interfaces */ 3429 /* Don't register audio interfaces */
3440 if (interface->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) { 3430 if (interface->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
3441 em28xx_err(DRIVER_NAME " audio device (%04x:%04x): " 3431 dev_err(&interface->dev,
3442 "interface %i, class %i\n", 3432 "audio device (%04x:%04x): interface %i, class %i\n",
3443 le16_to_cpu(udev->descriptor.idVendor), 3433 le16_to_cpu(udev->descriptor.idVendor),
3444 le16_to_cpu(udev->descriptor.idProduct), 3434 le16_to_cpu(udev->descriptor.idProduct),
3445 ifnum, 3435 ifnum,
@@ -3452,7 +3442,6 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3452 /* allocate memory for our device state and initialize it */ 3442 /* allocate memory for our device state and initialize it */
3453 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 3443 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
3454 if (dev == NULL) { 3444 if (dev == NULL) {
3455 em28xx_err(DRIVER_NAME ": out of memory!\n");
3456 retval = -ENOMEM; 3445 retval = -ENOMEM;
3457 goto err; 3446 goto err;
3458 } 3447 }
@@ -3462,7 +3451,6 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3462 kmalloc(sizeof(dev->alt_max_pkt_size_isoc[0]) * 3451 kmalloc(sizeof(dev->alt_max_pkt_size_isoc[0]) *
3463 interface->num_altsetting, GFP_KERNEL); 3452 interface->num_altsetting, GFP_KERNEL);
3464 if (dev->alt_max_pkt_size_isoc == NULL) { 3453 if (dev->alt_max_pkt_size_isoc == NULL) {
3465 em28xx_errdev("out of memory!\n");
3466 kfree(dev); 3454 kfree(dev);
3467 retval = -ENOMEM; 3455 retval = -ENOMEM;
3468 goto err; 3456 goto err;
@@ -3501,8 +3489,8 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3501 if (usb_endpoint_xfer_isoc(e)) { 3489 if (usb_endpoint_xfer_isoc(e)) {
3502 has_vendor_audio = true; 3490 has_vendor_audio = true;
3503 } else { 3491 } else {
3504 printk(KERN_INFO DRIVER_NAME 3492 dev_err(&interface->dev,
3505 ": error: skipping audio endpoint 0x83, because it uses bulk transfers !\n"); 3493 "error: skipping audio endpoint 0x83, because it uses bulk transfers !\n");
3506 } 3494 }
3507 break; 3495 break;
3508 case 0x84: 3496 case 0x84:
@@ -3575,9 +3563,8 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3575 speed = "unknown"; 3563 speed = "unknown";
3576 } 3564 }
3577 3565
3578 printk(KERN_INFO DRIVER_NAME 3566 dev_err(&interface->dev,
3579 ": New device %s %s @ %s Mbps " 3567 "New device %s %s @ %s Mbps (%04x:%04x, interface %d, class %d)\n",
3580 "(%04x:%04x, interface %d, class %d)\n",
3581 udev->manufacturer ? udev->manufacturer : "", 3568 udev->manufacturer ? udev->manufacturer : "",
3582 udev->product ? udev->product : "", 3569 udev->product ? udev->product : "",
3583 speed, 3570 speed,
@@ -3592,9 +3579,9 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3592 * not enough even for most Digital TV streams. 3579 * not enough even for most Digital TV streams.
3593 */ 3580 */
3594 if (udev->speed != USB_SPEED_HIGH && disable_usb_speed_check == 0) { 3581 if (udev->speed != USB_SPEED_HIGH && disable_usb_speed_check == 0) {
3595 printk(DRIVER_NAME ": Device initialization failed.\n"); 3582 dev_err(&interface->dev, "Device initialization failed.\n");
3596 printk(DRIVER_NAME ": Device must be connected to a high-speed" 3583 dev_err(&interface->dev,
3597 " USB 2.0 port.\n"); 3584 "Device must be connected to a high-speed USB 2.0 port.\n");
3598 retval = -ENODEV; 3585 retval = -ENODEV;
3599 goto err_free; 3586 goto err_free;
3600 } 3587 }
@@ -3607,8 +3594,8 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3607 dev->ifnum = ifnum; 3594 dev->ifnum = ifnum;
3608 3595
3609 if (has_vendor_audio) { 3596 if (has_vendor_audio) {
3610 printk(KERN_INFO DRIVER_NAME ": Audio interface %i found %s\n", 3597 dev_err(&interface->dev,
3611 ifnum, "(Vendor Class)"); 3598 "Audio interface %i found (Vendor Class)\n", ifnum);
3612 dev->usb_audio_type = EM28XX_USB_AUDIO_VENDOR; 3599 dev->usb_audio_type = EM28XX_USB_AUDIO_VENDOR;
3613 } 3600 }
3614 /* Checks if audio is provided by a USB Audio Class interface */ 3601 /* Checks if audio is provided by a USB Audio Class interface */
@@ -3617,25 +3604,24 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3617 3604
3618 if (uif->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) { 3605 if (uif->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
3619 if (has_vendor_audio) 3606 if (has_vendor_audio)
3620 em28xx_err("em28xx: device seems to have vendor AND usb audio class interfaces !\n" 3607 dev_err(&interface->dev,
3621 "\t\tThe vendor interface will be ignored. Please contact the developers <linux-media@vger.kernel.org>\n"); 3608 "em28xx: device seems to have vendor AND usb audio class interfaces !\n"
3609 "\t\tThe vendor interface will be ignored. Please contact the developers <linux-media@vger.kernel.org>\n");
3622 dev->usb_audio_type = EM28XX_USB_AUDIO_CLASS; 3610 dev->usb_audio_type = EM28XX_USB_AUDIO_CLASS;
3623 break; 3611 break;
3624 } 3612 }
3625 } 3613 }
3626 3614
3627 if (has_video) 3615 if (has_video)
3628 printk(KERN_INFO DRIVER_NAME 3616 dev_err(&interface->dev, "Video interface %i found:%s%s\n",
3629 ": Video interface %i found:%s%s\n", 3617 ifnum,
3630 ifnum, 3618 dev->analog_ep_bulk ? " bulk" : "",
3631 dev->analog_ep_bulk ? " bulk" : "", 3619 dev->analog_ep_isoc ? " isoc" : "");
3632 dev->analog_ep_isoc ? " isoc" : "");
3633 if (has_dvb) 3620 if (has_dvb)
3634 printk(KERN_INFO DRIVER_NAME 3621 dev_err(&interface->dev, "DVB interface %i found:%s%s\n",
3635 ": DVB interface %i found:%s%s\n", 3622 ifnum,
3636 ifnum, 3623 dev->dvb_ep_bulk ? " bulk" : "",
3637 dev->dvb_ep_bulk ? " bulk" : "", 3624 dev->dvb_ep_isoc ? " isoc" : "");
3638 dev->dvb_ep_isoc ? " isoc" : "");
3639 3625
3640 dev->num_alt = interface->num_altsetting; 3626 dev->num_alt = interface->num_altsetting;
3641 3627
@@ -3664,8 +3650,8 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3664 /* Disable V4L2 if the device doesn't have a decoder */ 3650 /* Disable V4L2 if the device doesn't have a decoder */
3665 if (has_video && 3651 if (has_video &&
3666 dev->board.decoder == EM28XX_NODECODER && !dev->board.is_webcam) { 3652 dev->board.decoder == EM28XX_NODECODER && !dev->board.is_webcam) {
3667 printk(DRIVER_NAME 3653 dev_err(&interface->dev,
3668 ": Currently, V4L2 is not supported on this model\n"); 3654 "Currently, V4L2 is not supported on this model\n");
3669 has_video = false; 3655 has_video = false;
3670 dev->has_video = false; 3656 dev->has_video = false;
3671 } 3657 }
@@ -3674,14 +3660,14 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3674 if (has_video) { 3660 if (has_video) {
3675 if (!dev->analog_ep_isoc || (try_bulk && dev->analog_ep_bulk)) 3661 if (!dev->analog_ep_isoc || (try_bulk && dev->analog_ep_bulk))
3676 dev->analog_xfer_bulk = 1; 3662 dev->analog_xfer_bulk = 1;
3677 em28xx_info("analog set to %s mode.\n", 3663 dev_err(&interface->dev, "analog set to %s mode.\n",
3678 dev->analog_xfer_bulk ? "bulk" : "isoc"); 3664 dev->analog_xfer_bulk ? "bulk" : "isoc");
3679 } 3665 }
3680 if (has_dvb) { 3666 if (has_dvb) {
3681 if (!dev->dvb_ep_isoc || (try_bulk && dev->dvb_ep_bulk)) 3667 if (!dev->dvb_ep_isoc || (try_bulk && dev->dvb_ep_bulk))
3682 dev->dvb_xfer_bulk = 1; 3668 dev->dvb_xfer_bulk = 1;
3683 em28xx_info("dvb set to %s mode.\n", 3669 dev_err(&interface->dev, "dvb set to %s mode.\n",
3684 dev->dvb_xfer_bulk ? "bulk" : "isoc"); 3670 dev->dvb_xfer_bulk ? "bulk" : "isoc");
3685 } 3671 }
3686 3672
3687 kref_init(&dev->ref); 3673 kref_init(&dev->ref);
@@ -3728,7 +3714,7 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
3728 3714
3729 dev->disconnected = 1; 3715 dev->disconnected = 1;
3730 3716
3731 em28xx_info("Disconnecting %s\n", dev->name); 3717 dev_err(&dev->intf->dev, "Disconnecting\n");
3732 3718
3733 flush_request_modules(dev); 3719 flush_request_modules(dev);
3734 3720
diff --git a/drivers/media/usb/em28xx/em28xx-core.c b/drivers/media/usb/em28xx/em28xx-core.c
index eebd5d7088d0..19ccff41c7eb 100644
--- a/drivers/media/usb/em28xx/em28xx-core.c
+++ b/drivers/media/usb/em28xx/em28xx-core.c
@@ -22,6 +22,8 @@
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */ 23 */
24 24
25#include "em28xx.h"
26
25#include <linux/init.h> 27#include <linux/init.h>
26#include <linux/jiffies.h> 28#include <linux/jiffies.h>
27#include <linux/list.h> 29#include <linux/list.h>
@@ -32,8 +34,6 @@
32#include <sound/ac97_codec.h> 34#include <sound/ac97_codec.h>
33#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
34 36
35#include "em28xx.h"
36
37#define DRIVER_AUTHOR "Ludovico Cavedon <cavedon@sssup.it>, " \ 37#define DRIVER_AUTHOR "Ludovico Cavedon <cavedon@sssup.it>, " \
38 "Markus Rechberger <mrechberger@gmail.com>, " \ 38 "Markus Rechberger <mrechberger@gmail.com>, " \
39 "Mauro Carvalho Chehab <mchehab@infradead.org>, " \ 39 "Mauro Carvalho Chehab <mchehab@infradead.org>, " \
@@ -48,27 +48,31 @@ MODULE_VERSION(EM28XX_VERSION);
48 48
49static unsigned int core_debug; 49static unsigned int core_debug;
50module_param(core_debug, int, 0644); 50module_param(core_debug, int, 0644);
51MODULE_PARM_DESC(core_debug, "enable debug messages [core]"); 51MODULE_PARM_DESC(core_debug, "enable debug messages [core and isoc]");
52 52
53#define em28xx_coredbg(fmt, arg...) do {\ 53#define em28xx_coredbg(fmt, arg...) do { \
54 if (core_debug) \ 54 if (core_debug) \
55 printk(KERN_INFO "%s %s :"fmt, \ 55 dev_printk(KERN_DEBUG, &dev->intf->dev, \
56 dev->name, __func__ , ##arg); } while (0) 56 "core: %s: " fmt, __func__, ## arg); \
57} while (0)
57 58
58static unsigned int reg_debug; 59static unsigned int reg_debug;
59module_param(reg_debug, int, 0644); 60module_param(reg_debug, int, 0644);
60MODULE_PARM_DESC(reg_debug, "enable debug messages [URB reg]"); 61MODULE_PARM_DESC(reg_debug, "enable debug messages [URB reg]");
61 62
62#define em28xx_regdbg(fmt, arg...) do {\
63 if (reg_debug) \
64 printk(KERN_INFO "%s %s :"fmt, \
65 dev->name, __func__ , ##arg); } while (0)
66 63
67/* FIXME */ 64#define em28xx_regdbg(fmt, arg...) do { \
68#define em28xx_isocdbg(fmt, arg...) do {\ 65 if (reg_debug) \
69 if (core_debug) \ 66 dev_printk(KERN_DEBUG, &dev->intf->dev, \
70 printk(KERN_INFO "%s %s :"fmt, \ 67 "reg: %s: " fmt, __func__, ## arg); \
71 dev->name, __func__ , ##arg); } while (0) 68} while (0)
69
70/* FIXME: don't abuse core_debug */
71#define em28xx_isocdbg(fmt, arg...) do { \
72 if (core_debug) \
73 dev_printk(KERN_DEBUG, &dev->intf->dev, \
74 "core: %s: " fmt, __func__, ## arg); \
75} while (0)
72 76
73/* 77/*
74 * em28xx_read_reg_req() 78 * em28xx_read_reg_req()
@@ -78,7 +82,8 @@ int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg,
78 char *buf, int len) 82 char *buf, int len)
79{ 83{
80 int ret; 84 int ret;
81 int pipe = usb_rcvctrlpipe(dev->udev, 0); 85 struct usb_device *udev = interface_to_usbdev(dev->intf);
86 int pipe = usb_rcvctrlpipe(udev, 0);
82 87
83 if (dev->disconnected) 88 if (dev->disconnected)
84 return -ENODEV; 89 return -ENODEV;
@@ -86,23 +91,22 @@ int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg,
86 if (len > URB_MAX_CTRL_SIZE) 91 if (len > URB_MAX_CTRL_SIZE)
87 return -EINVAL; 92 return -EINVAL;
88 93
89 if (reg_debug) { 94 em28xx_regdbg("(pipe 0x%08x): IN: %02x %02x %02x %02x %02x %02x %02x %02x ",
90 printk(KERN_DEBUG "(pipe 0x%08x): " 95 pipe, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
91 "IN: %02x %02x %02x %02x %02x %02x %02x %02x ", 96 req, 0, 0,
92 pipe, 97 reg & 0xff, reg >> 8,
93 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 98 len & 0xff, len >> 8);
94 req, 0, 0,
95 reg & 0xff, reg >> 8,
96 len & 0xff, len >> 8);
97 }
98 99
99 mutex_lock(&dev->ctrl_urb_lock); 100 mutex_lock(&dev->ctrl_urb_lock);
100 ret = usb_control_msg(dev->udev, pipe, req, 101 ret = usb_control_msg(udev, pipe, req,
101 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 102 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
102 0x0000, reg, dev->urb_buf, len, HZ); 103 0x0000, reg, dev->urb_buf, len, HZ);
103 if (ret < 0) { 104 if (ret < 0) {
104 if (reg_debug) 105 em28xx_regdbg("(pipe 0x%08x): IN: %02x %02x %02x %02x %02x %02x %02x %02x failed\n",
105 printk(" failed!\n"); 106 pipe, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
107 req, 0, 0,
108 reg & 0xff, reg >> 8,
109 len & 0xff, len >> 8);
106 mutex_unlock(&dev->ctrl_urb_lock); 110 mutex_unlock(&dev->ctrl_urb_lock);
107 return usb_translate_errors(ret); 111 return usb_translate_errors(ret);
108 } 112 }
@@ -112,14 +116,11 @@ int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg,
112 116
113 mutex_unlock(&dev->ctrl_urb_lock); 117 mutex_unlock(&dev->ctrl_urb_lock);
114 118
115 if (reg_debug) { 119 em28xx_regdbg("(pipe 0x%08x): IN: %02x %02x %02x %02x %02x %02x %02x %02x failed <<< %*ph\n",
116 int byte; 120 pipe, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
117 121 req, 0, 0,
118 printk("<<<"); 122 reg & 0xff, reg >> 8,
119 for (byte = 0; byte < len; byte++) 123 len & 0xff, len >> 8, len, buf);
120 printk(" %02x", (unsigned char)buf[byte]);
121 printk("\n");
122 }
123 124
124 return ret; 125 return ret;
125} 126}
@@ -154,7 +155,8 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
154 int len) 155 int len)
155{ 156{
156 int ret; 157 int ret;
157 int pipe = usb_sndctrlpipe(dev->udev, 0); 158 struct usb_device *udev = interface_to_usbdev(dev->intf);
159 int pipe = usb_sndctrlpipe(udev, 0);
158 160
159 if (dev->disconnected) 161 if (dev->disconnected)
160 return -ENODEV; 162 return -ENODEV;
@@ -162,25 +164,16 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
162 if ((len < 1) || (len > URB_MAX_CTRL_SIZE)) 164 if ((len < 1) || (len > URB_MAX_CTRL_SIZE))
163 return -EINVAL; 165 return -EINVAL;
164 166
165 if (reg_debug) { 167 em28xx_regdbg("(pipe 0x%08x): OUT: %02x %02x %02x %02x %02x %02x %02x %02x >>> %*ph\n",
166 int byte; 168 pipe,
167 169 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
168 printk(KERN_DEBUG "(pipe 0x%08x): " 170 req, 0, 0,
169 "OUT: %02x %02x %02x %02x %02x %02x %02x %02x >>>", 171 reg & 0xff, reg >> 8,
170 pipe, 172 len & 0xff, len >> 8, len, buf);
171 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
172 req, 0, 0,
173 reg & 0xff, reg >> 8,
174 len & 0xff, len >> 8);
175
176 for (byte = 0; byte < len; byte++)
177 printk(" %02x", (unsigned char)buf[byte]);
178 printk("\n");
179 }
180 173
181 mutex_lock(&dev->ctrl_urb_lock); 174 mutex_lock(&dev->ctrl_urb_lock);
182 memcpy(dev->urb_buf, buf, len); 175 memcpy(dev->urb_buf, buf, len);
183 ret = usb_control_msg(dev->udev, pipe, req, 176 ret = usb_control_msg(udev, pipe, req,
184 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 177 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
185 0x0000, reg, dev->urb_buf, len, HZ); 178 0x0000, reg, dev->urb_buf, len, HZ);
186 mutex_unlock(&dev->ctrl_urb_lock); 179 mutex_unlock(&dev->ctrl_urb_lock);
@@ -267,7 +260,8 @@ static int em28xx_is_ac97_ready(struct em28xx *dev)
267 msleep(5); 260 msleep(5);
268 } 261 }
269 262
270 em28xx_warn("AC97 command still being executed: not handled properly!\n"); 263 dev_warn(&dev->intf->dev,
264 "AC97 command still being executed: not handled properly!\n");
271 return -EBUSY; 265 return -EBUSY;
272} 266}
273 267
@@ -360,8 +354,9 @@ static int set_ac97_input(struct em28xx *dev)
360 ret = em28xx_write_ac97(dev, inputs[i].reg, 0x8000); 354 ret = em28xx_write_ac97(dev, inputs[i].reg, 0x8000);
361 355
362 if (ret < 0) 356 if (ret < 0)
363 em28xx_warn("couldn't setup AC97 register %d\n", 357 dev_warn(&dev->intf->dev,
364 inputs[i].reg); 358 "couldn't setup AC97 register %d\n",
359 inputs[i].reg);
365 } 360 }
366 return 0; 361 return 0;
367} 362}
@@ -444,8 +439,9 @@ int em28xx_audio_analog_set(struct em28xx *dev)
444 for (i = 0; i < ARRAY_SIZE(outputs); i++) { 439 for (i = 0; i < ARRAY_SIZE(outputs); i++) {
445 ret = em28xx_write_ac97(dev, outputs[i].reg, 0x8000); 440 ret = em28xx_write_ac97(dev, outputs[i].reg, 0x8000);
446 if (ret < 0) 441 if (ret < 0)
447 em28xx_warn("couldn't setup AC97 register %d\n", 442 dev_warn(&dev->intf->dev,
448 outputs[i].reg); 443 "couldn't setup AC97 register %d\n",
444 outputs[i].reg);
449 } 445 }
450 } 446 }
451 447
@@ -482,8 +478,9 @@ int em28xx_audio_analog_set(struct em28xx *dev)
482 ret = em28xx_write_ac97(dev, outputs[i].reg, 478 ret = em28xx_write_ac97(dev, outputs[i].reg,
483 vol); 479 vol);
484 if (ret < 0) 480 if (ret < 0)
485 em28xx_warn("couldn't setup AC97 register %d\n", 481 dev_warn(&dev->intf->dev,
486 outputs[i].reg); 482 "couldn't setup AC97 register %d\n",
483 outputs[i].reg);
487 } 484 }
488 485
489 if (dev->ctl_aoutput & EM28XX_AOUT_PCM_IN) { 486 if (dev->ctl_aoutput & EM28XX_AOUT_PCM_IN) {
@@ -519,7 +516,7 @@ int em28xx_audio_setup(struct em28xx *dev)
519 516
520 /* See how this device is configured */ 517 /* See how this device is configured */
521 cfg = em28xx_read_reg(dev, EM28XX_R00_CHIPCFG); 518 cfg = em28xx_read_reg(dev, EM28XX_R00_CHIPCFG);
522 em28xx_info("Config register raw data: 0x%02x\n", cfg); 519 dev_info(&dev->intf->dev, "Config register raw data: 0x%02x\n", cfg);
523 if (cfg < 0) { /* Register read error */ 520 if (cfg < 0) { /* Register read error */
524 /* Be conservative */ 521 /* Be conservative */
525 dev->int_audio_type = EM28XX_INT_AUDIO_AC97; 522 dev->int_audio_type = EM28XX_INT_AUDIO_AC97;
@@ -540,8 +537,8 @@ int em28xx_audio_setup(struct em28xx *dev)
540 i2s_samplerates = 5; 537 i2s_samplerates = 5;
541 else 538 else
542 i2s_samplerates = 3; 539 i2s_samplerates = 3;
543 em28xx_info("I2S Audio (%d sample rate(s))\n", 540 dev_info(&dev->intf->dev, "I2S Audio (%d sample rate(s))\n",
544 i2s_samplerates); 541 i2s_samplerates);
545 /* Skip the code that does AC97 vendor detection */ 542 /* Skip the code that does AC97 vendor detection */
546 dev->audio_mode.ac97 = EM28XX_NO_AC97; 543 dev->audio_mode.ac97 = EM28XX_NO_AC97;
547 goto init_audio; 544 goto init_audio;
@@ -558,7 +555,8 @@ int em28xx_audio_setup(struct em28xx *dev)
558 * Note: (some) em2800 devices without eeprom reports 0x91 on 555 * Note: (some) em2800 devices without eeprom reports 0x91 on
559 * CHIPCFG register, even not having an AC97 chip 556 * CHIPCFG register, even not having an AC97 chip
560 */ 557 */
561 em28xx_warn("AC97 chip type couldn't be determined\n"); 558 dev_warn(&dev->intf->dev,
559 "AC97 chip type couldn't be determined\n");
562 dev->audio_mode.ac97 = EM28XX_NO_AC97; 560 dev->audio_mode.ac97 = EM28XX_NO_AC97;
563 if (dev->usb_audio_type == EM28XX_USB_AUDIO_VENDOR) 561 if (dev->usb_audio_type == EM28XX_USB_AUDIO_VENDOR)
564 dev->usb_audio_type = EM28XX_USB_AUDIO_NONE; 562 dev->usb_audio_type = EM28XX_USB_AUDIO_NONE;
@@ -571,13 +569,13 @@ int em28xx_audio_setup(struct em28xx *dev)
571 goto init_audio; 569 goto init_audio;
572 570
573 vid = vid1 << 16 | vid2; 571 vid = vid1 << 16 | vid2;
574 em28xx_warn("AC97 vendor ID = 0x%08x\n", vid); 572 dev_warn(&dev->intf->dev, "AC97 vendor ID = 0x%08x\n", vid);
575 573
576 feat = em28xx_read_ac97(dev, AC97_RESET); 574 feat = em28xx_read_ac97(dev, AC97_RESET);
577 if (feat < 0) 575 if (feat < 0)
578 goto init_audio; 576 goto init_audio;
579 577
580 em28xx_warn("AC97 features = 0x%04x\n", feat); 578 dev_warn(&dev->intf->dev, "AC97 features = 0x%04x\n", feat);
581 579
582 /* Try to identify what audio processor we have */ 580 /* Try to identify what audio processor we have */
583 if (((vid == 0xffffffff) || (vid == 0x83847650)) && (feat == 0x6a90)) 581 if (((vid == 0xffffffff) || (vid == 0x83847650)) && (feat == 0x6a90))
@@ -589,17 +587,20 @@ init_audio:
589 /* Reports detected AC97 processor */ 587 /* Reports detected AC97 processor */
590 switch (dev->audio_mode.ac97) { 588 switch (dev->audio_mode.ac97) {
591 case EM28XX_NO_AC97: 589 case EM28XX_NO_AC97:
592 em28xx_info("No AC97 audio processor\n"); 590 dev_info(&dev->intf->dev, "No AC97 audio processor\n");
593 break; 591 break;
594 case EM28XX_AC97_EM202: 592 case EM28XX_AC97_EM202:
595 em28xx_info("Empia 202 AC97 audio processor detected\n"); 593 dev_info(&dev->intf->dev,
594 "Empia 202 AC97 audio processor detected\n");
596 break; 595 break;
597 case EM28XX_AC97_SIGMATEL: 596 case EM28XX_AC97_SIGMATEL:
598 em28xx_info("Sigmatel audio processor detected (stac 97%02x)\n", 597 dev_info(&dev->intf->dev,
599 vid & 0xff); 598 "Sigmatel audio processor detected (stac 97%02x)\n",
599 vid & 0xff);
600 break; 600 break;
601 case EM28XX_AC97_OTHER: 601 case EM28XX_AC97_OTHER:
602 em28xx_warn("Unknown AC97 audio processor detected!\n"); 602 dev_warn(&dev->intf->dev,
603 "Unknown AC97 audio processor detected!\n");
603 break; 604 break;
604 default: 605 default:
605 break; 606 break;
@@ -798,6 +799,7 @@ void em28xx_uninit_usb_xfer(struct em28xx *dev, enum em28xx_mode mode)
798{ 799{
799 struct urb *urb; 800 struct urb *urb;
800 struct em28xx_usb_bufs *usb_bufs; 801 struct em28xx_usb_bufs *usb_bufs;
802 struct usb_device *udev = interface_to_usbdev(dev->intf);
801 int i; 803 int i;
802 804
803 em28xx_isocdbg("em28xx: called em28xx_uninit_usb_xfer in mode %d\n", 805 em28xx_isocdbg("em28xx: called em28xx_uninit_usb_xfer in mode %d\n",
@@ -817,7 +819,7 @@ void em28xx_uninit_usb_xfer(struct em28xx *dev, enum em28xx_mode mode)
817 usb_unlink_urb(urb); 819 usb_unlink_urb(urb);
818 820
819 if (usb_bufs->transfer_buffer[i]) { 821 if (usb_bufs->transfer_buffer[i]) {
820 usb_free_coherent(dev->udev, 822 usb_free_coherent(udev,
821 urb->transfer_buffer_length, 823 urb->transfer_buffer_length,
822 usb_bufs->transfer_buffer[i], 824 usb_bufs->transfer_buffer[i],
823 urb->transfer_dma); 825 urb->transfer_dma);
@@ -871,9 +873,10 @@ int em28xx_alloc_urbs(struct em28xx *dev, enum em28xx_mode mode, int xfer_bulk,
871 int num_bufs, int max_pkt_size, int packet_multiplier) 873 int num_bufs, int max_pkt_size, int packet_multiplier)
872{ 874{
873 struct em28xx_usb_bufs *usb_bufs; 875 struct em28xx_usb_bufs *usb_bufs;
876 struct urb *urb;
877 struct usb_device *udev = interface_to_usbdev(dev->intf);
874 int i; 878 int i;
875 int sb_size, pipe; 879 int sb_size, pipe;
876 struct urb *urb;
877 int j, k; 880 int j, k;
878 881
879 em28xx_isocdbg("em28xx: called em28xx_alloc_isoc in mode %d\n", mode); 882 em28xx_isocdbg("em28xx: called em28xx_alloc_isoc in mode %d\n", mode);
@@ -883,21 +886,23 @@ int em28xx_alloc_urbs(struct em28xx *dev, enum em28xx_mode mode, int xfer_bulk,
883 if (mode == EM28XX_DIGITAL_MODE) { 886 if (mode == EM28XX_DIGITAL_MODE) {
884 if ((xfer_bulk && !dev->dvb_ep_bulk) || 887 if ((xfer_bulk && !dev->dvb_ep_bulk) ||
885 (!xfer_bulk && !dev->dvb_ep_isoc)) { 888 (!xfer_bulk && !dev->dvb_ep_isoc)) {
886 em28xx_errdev("no endpoint for DVB mode and transfer type %d\n", 889 dev_err(&dev->intf->dev,
887 xfer_bulk > 0); 890 "no endpoint for DVB mode and transfer type %d\n",
891 xfer_bulk > 0);
888 return -EINVAL; 892 return -EINVAL;
889 } 893 }
890 usb_bufs = &dev->usb_ctl.digital_bufs; 894 usb_bufs = &dev->usb_ctl.digital_bufs;
891 } else if (mode == EM28XX_ANALOG_MODE) { 895 } else if (mode == EM28XX_ANALOG_MODE) {
892 if ((xfer_bulk && !dev->analog_ep_bulk) || 896 if ((xfer_bulk && !dev->analog_ep_bulk) ||
893 (!xfer_bulk && !dev->analog_ep_isoc)) { 897 (!xfer_bulk && !dev->analog_ep_isoc)) {
894 em28xx_errdev("no endpoint for analog mode and transfer type %d\n", 898 dev_err(&dev->intf->dev,
895 xfer_bulk > 0); 899 "no endpoint for analog mode and transfer type %d\n",
900 xfer_bulk > 0);
896 return -EINVAL; 901 return -EINVAL;
897 } 902 }
898 usb_bufs = &dev->usb_ctl.analog_bufs; 903 usb_bufs = &dev->usb_ctl.analog_bufs;
899 } else { 904 } else {
900 em28xx_errdev("invalid mode selected\n"); 905 dev_err(&dev->intf->dev, "invalid mode selected\n");
901 return -EINVAL; 906 return -EINVAL;
902 } 907 }
903 908
@@ -907,15 +912,12 @@ int em28xx_alloc_urbs(struct em28xx *dev, enum em28xx_mode mode, int xfer_bulk,
907 usb_bufs->num_bufs = num_bufs; 912 usb_bufs->num_bufs = num_bufs;
908 913
909 usb_bufs->urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL); 914 usb_bufs->urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL);
910 if (!usb_bufs->urb) { 915 if (!usb_bufs->urb)
911 em28xx_errdev("cannot alloc memory for usb buffers\n");
912 return -ENOMEM; 916 return -ENOMEM;
913 }
914 917
915 usb_bufs->transfer_buffer = kzalloc(sizeof(void *)*num_bufs, 918 usb_bufs->transfer_buffer = kzalloc(sizeof(void *)*num_bufs,
916 GFP_KERNEL); 919 GFP_KERNEL);
917 if (!usb_bufs->transfer_buffer) { 920 if (!usb_bufs->transfer_buffer) {
918 em28xx_errdev("cannot allocate memory for usb transfer\n");
919 kfree(usb_bufs->urb); 921 kfree(usb_bufs->urb);
920 return -ENOMEM; 922 return -ENOMEM;
921 } 923 }
@@ -939,33 +941,33 @@ int em28xx_alloc_urbs(struct em28xx *dev, enum em28xx_mode mode, int xfer_bulk,
939 } 941 }
940 usb_bufs->urb[i] = urb; 942 usb_bufs->urb[i] = urb;
941 943
942 usb_bufs->transfer_buffer[i] = usb_alloc_coherent(dev->udev, 944 usb_bufs->transfer_buffer[i] = usb_alloc_coherent(udev,
943 sb_size, GFP_KERNEL, &urb->transfer_dma); 945 sb_size, GFP_KERNEL, &urb->transfer_dma);
944 if (!usb_bufs->transfer_buffer[i]) { 946 if (!usb_bufs->transfer_buffer[i]) {
945 em28xx_err("unable to allocate %i bytes for transfer" 947 dev_err(&dev->intf->dev,
946 " buffer %i%s\n", 948 "unable to allocate %i bytes for transfer buffer %i%s\n",
947 sb_size, i, 949 sb_size, i,
948 in_interrupt() ? " while in int" : ""); 950 in_interrupt() ? " while in int" : "");
949 em28xx_uninit_usb_xfer(dev, mode); 951 em28xx_uninit_usb_xfer(dev, mode);
950 return -ENOMEM; 952 return -ENOMEM;
951 } 953 }
952 memset(usb_bufs->transfer_buffer[i], 0, sb_size); 954 memset(usb_bufs->transfer_buffer[i], 0, sb_size);
953 955
954 if (xfer_bulk) { /* bulk */ 956 if (xfer_bulk) { /* bulk */
955 pipe = usb_rcvbulkpipe(dev->udev, 957 pipe = usb_rcvbulkpipe(udev,
956 mode == EM28XX_ANALOG_MODE ? 958 mode == EM28XX_ANALOG_MODE ?
957 dev->analog_ep_bulk : 959 dev->analog_ep_bulk :
958 dev->dvb_ep_bulk); 960 dev->dvb_ep_bulk);
959 usb_fill_bulk_urb(urb, dev->udev, pipe, 961 usb_fill_bulk_urb(urb, udev, pipe,
960 usb_bufs->transfer_buffer[i], sb_size, 962 usb_bufs->transfer_buffer[i], sb_size,
961 em28xx_irq_callback, dev); 963 em28xx_irq_callback, dev);
962 urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; 964 urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
963 } else { /* isoc */ 965 } else { /* isoc */
964 pipe = usb_rcvisocpipe(dev->udev, 966 pipe = usb_rcvisocpipe(udev,
965 mode == EM28XX_ANALOG_MODE ? 967 mode == EM28XX_ANALOG_MODE ?
966 dev->analog_ep_isoc : 968 dev->analog_ep_isoc :
967 dev->dvb_ep_isoc); 969 dev->dvb_ep_isoc);
968 usb_fill_int_urb(urb, dev->udev, pipe, 970 usb_fill_int_urb(urb, udev, pipe,
969 usb_bufs->transfer_buffer[i], sb_size, 971 usb_bufs->transfer_buffer[i], sb_size,
970 em28xx_irq_callback, dev, 1); 972 em28xx_irq_callback, dev, 1);
971 urb->transfer_flags = URB_ISO_ASAP | 973 urb->transfer_flags = URB_ISO_ASAP |
@@ -997,6 +999,7 @@ int em28xx_init_usb_xfer(struct em28xx *dev, enum em28xx_mode mode,
997 struct em28xx_dmaqueue *dma_q = &dev->vidq; 999 struct em28xx_dmaqueue *dma_q = &dev->vidq;
998 struct em28xx_dmaqueue *vbi_dma_q = &dev->vbiq; 1000 struct em28xx_dmaqueue *vbi_dma_q = &dev->vbiq;
999 struct em28xx_usb_bufs *usb_bufs; 1001 struct em28xx_usb_bufs *usb_bufs;
1002 struct usb_device *udev = interface_to_usbdev(dev->intf);
1000 int i; 1003 int i;
1001 int rc; 1004 int rc;
1002 int alloc; 1005 int alloc;
@@ -1023,10 +1026,11 @@ int em28xx_init_usb_xfer(struct em28xx *dev, enum em28xx_mode mode,
1023 } 1026 }
1024 1027
1025 if (xfer_bulk) { 1028 if (xfer_bulk) {
1026 rc = usb_clear_halt(dev->udev, usb_bufs->urb[0]->pipe); 1029 rc = usb_clear_halt(udev, usb_bufs->urb[0]->pipe);
1027 if (rc < 0) { 1030 if (rc < 0) {
1028 em28xx_err("failed to clear USB bulk endpoint stall/halt condition (error=%i)\n", 1031 dev_err(&dev->intf->dev,
1029 rc); 1032 "failed to clear USB bulk endpoint stall/halt condition (error=%i)\n",
1033 rc);
1030 em28xx_uninit_usb_xfer(dev, mode); 1034 em28xx_uninit_usb_xfer(dev, mode);
1031 return rc; 1035 return rc;
1032 } 1036 }
@@ -1041,8 +1045,8 @@ int em28xx_init_usb_xfer(struct em28xx *dev, enum em28xx_mode mode,
1041 for (i = 0; i < usb_bufs->num_bufs; i++) { 1045 for (i = 0; i < usb_bufs->num_bufs; i++) {
1042 rc = usb_submit_urb(usb_bufs->urb[i], GFP_ATOMIC); 1046 rc = usb_submit_urb(usb_bufs->urb[i], GFP_ATOMIC);
1043 if (rc) { 1047 if (rc) {
1044 em28xx_err("submit of urb %i failed (error=%i)\n", i, 1048 dev_err(&dev->intf->dev,
1045 rc); 1049 "submit of urb %i failed (error=%i)\n", i, rc);
1046 em28xx_uninit_usb_xfer(dev, mode); 1050 em28xx_uninit_usb_xfer(dev, mode);
1047 return rc; 1051 return rc;
1048 } 1052 }
@@ -1075,7 +1079,7 @@ int em28xx_register_extension(struct em28xx_ops *ops)
1075 ops->init(dev); 1079 ops->init(dev);
1076 } 1080 }
1077 mutex_unlock(&em28xx_devlist_mutex); 1081 mutex_unlock(&em28xx_devlist_mutex);
1078 printk(KERN_INFO "em28xx: Registered (%s) extension\n", ops->name); 1082 pr_info("em28xx: Registered (%s) extension\n", ops->name);
1079 return 0; 1083 return 0;
1080} 1084}
1081EXPORT_SYMBOL(em28xx_register_extension); 1085EXPORT_SYMBOL(em28xx_register_extension);
@@ -1090,7 +1094,7 @@ void em28xx_unregister_extension(struct em28xx_ops *ops)
1090 } 1094 }
1091 list_del(&ops->next); 1095 list_del(&ops->next);
1092 mutex_unlock(&em28xx_devlist_mutex); 1096 mutex_unlock(&em28xx_devlist_mutex);
1093 printk(KERN_INFO "Em28xx: Removed (%s) extension\n", ops->name); 1097 pr_info("em28xx: Removed (%s) extension\n", ops->name);
1094} 1098}
1095EXPORT_SYMBOL(em28xx_unregister_extension); 1099EXPORT_SYMBOL(em28xx_unregister_extension);
1096 1100
@@ -1124,7 +1128,7 @@ int em28xx_suspend_extension(struct em28xx *dev)
1124{ 1128{
1125 const struct em28xx_ops *ops = NULL; 1129 const struct em28xx_ops *ops = NULL;
1126 1130
1127 em28xx_info("Suspending extensions\n"); 1131 dev_info(&dev->intf->dev, "Suspending extensions\n");
1128 mutex_lock(&em28xx_devlist_mutex); 1132 mutex_lock(&em28xx_devlist_mutex);
1129 list_for_each_entry(ops, &em28xx_extension_devlist, next) { 1133 list_for_each_entry(ops, &em28xx_extension_devlist, next) {
1130 if (ops->suspend) 1134 if (ops->suspend)
@@ -1138,7 +1142,7 @@ int em28xx_resume_extension(struct em28xx *dev)
1138{ 1142{
1139 const struct em28xx_ops *ops = NULL; 1143 const struct em28xx_ops *ops = NULL;
1140 1144
1141 em28xx_info("Resuming extensions\n"); 1145 dev_info(&dev->intf->dev, "Resuming extensions\n");
1142 mutex_lock(&em28xx_devlist_mutex); 1146 mutex_lock(&em28xx_devlist_mutex);
1143 list_for_each_entry(ops, &em28xx_extension_devlist, next) { 1147 list_for_each_entry(ops, &em28xx_extension_devlist, next) {
1144 if (ops->resume) 1148 if (ops->resume)
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
index 8cedef0daae4..75a75dab2e8e 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -21,11 +21,12 @@
21 the Free Software Foundation; either version 2 of the License. 21 the Free Software Foundation; either version 2 of the License.
22 */ 22 */
23 23
24#include "em28xx.h"
25
24#include <linux/kernel.h> 26#include <linux/kernel.h>
25#include <linux/slab.h> 27#include <linux/slab.h>
26#include <linux/usb.h> 28#include <linux/usb.h>
27 29
28#include "em28xx.h"
29#include <media/v4l2-common.h> 30#include <media/v4l2-common.h>
30#include <dvb_demux.h> 31#include <dvb_demux.h>
31#include <dvb_net.h> 32#include <dvb_net.h>
@@ -72,9 +73,10 @@ MODULE_PARM_DESC(debug, "enable debug messages [dvb]");
72 73
73DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 74DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
74 75
75#define dprintk(level, fmt, arg...) do { \ 76#define dprintk(level, fmt, arg...) do { \
76if (debug >= level) \ 77 if (debug >= level) \
77 printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->name, ## arg); \ 78 dev_printk(KERN_DEBUG, &dev->intf->dev, \
79 "dvb: " fmt, ## arg); \
78} while (0) 80} while (0)
79 81
80struct em28xx_dvb { 82struct em28xx_dvb {
@@ -196,6 +198,7 @@ static int em28xx_start_streaming(struct em28xx_dvb *dvb)
196 int rc; 198 int rc;
197 struct em28xx_i2c_bus *i2c_bus = dvb->adapter.priv; 199 struct em28xx_i2c_bus *i2c_bus = dvb->adapter.priv;
198 struct em28xx *dev = i2c_bus->dev; 200 struct em28xx *dev = i2c_bus->dev;
201 struct usb_device *udev = interface_to_usbdev(dev->intf);
199 int dvb_max_packet_size, packet_multiplier, dvb_alt; 202 int dvb_max_packet_size, packet_multiplier, dvb_alt;
200 203
201 if (dev->dvb_xfer_bulk) { 204 if (dev->dvb_xfer_bulk) {
@@ -214,7 +217,7 @@ static int em28xx_start_streaming(struct em28xx_dvb *dvb)
214 dvb_alt = dev->dvb_alt_isoc; 217 dvb_alt = dev->dvb_alt_isoc;
215 } 218 }
216 219
217 usb_set_interface(dev->udev, dev->ifnum, dvb_alt); 220 usb_set_interface(udev, dev->ifnum, dvb_alt);
218 rc = em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); 221 rc = em28xx_set_mode(dev, EM28XX_DIGITAL_MODE);
219 if (rc < 0) 222 if (rc < 0)
220 return rc; 223 return rc;
@@ -734,13 +737,13 @@ static int em28xx_pctv_290e_set_lna(struct dvb_frontend *fe)
734 737
735 ret = gpio_request_one(dvb->lna_gpio, flags, NULL); 738 ret = gpio_request_one(dvb->lna_gpio, flags, NULL);
736 if (ret) 739 if (ret)
737 em28xx_errdev("gpio request failed %d\n", ret); 740 dev_err(&dev->intf->dev, "gpio request failed %d\n", ret);
738 else 741 else
739 gpio_free(dvb->lna_gpio); 742 gpio_free(dvb->lna_gpio);
740 743
741 return ret; 744 return ret;
742#else 745#else
743 dev_warn(&dev->udev->dev, "%s: LNA control is disabled (lna=%u)\n", 746 dev_warn(&dev->intf->dev, "%s: LNA control is disabled (lna=%u)\n",
744 KBUILD_MODNAME, c->lna); 747 KBUILD_MODNAME, c->lna);
745 return 0; 748 return 0;
746#endif 749#endif
@@ -934,20 +937,20 @@ static int em28xx_attach_xc3028(u8 addr, struct em28xx *dev)
934 cfg.ctrl = &ctl; 937 cfg.ctrl = &ctl;
935 938
936 if (!dev->dvb->fe[0]) { 939 if (!dev->dvb->fe[0]) {
937 em28xx_errdev("/2: dvb frontend not attached. " 940 dev_err(&dev->intf->dev,
938 "Can't attach xc3028\n"); 941 "dvb frontend not attached. Can't attach xc3028\n");
939 return -EINVAL; 942 return -EINVAL;
940 } 943 }
941 944
942 fe = dvb_attach(xc2028_attach, dev->dvb->fe[0], &cfg); 945 fe = dvb_attach(xc2028_attach, dev->dvb->fe[0], &cfg);
943 if (!fe) { 946 if (!fe) {
944 em28xx_errdev("/2: xc3028 attach failed\n"); 947 dev_err(&dev->intf->dev, "xc3028 attach failed\n");
945 dvb_frontend_detach(dev->dvb->fe[0]); 948 dvb_frontend_detach(dev->dvb->fe[0]);
946 dev->dvb->fe[0] = NULL; 949 dev->dvb->fe[0] = NULL;
947 return -EINVAL; 950 return -EINVAL;
948 } 951 }
949 952
950 em28xx_info("%s/2: xc3028 attached\n", dev->name); 953 dev_info(&dev->intf->dev, "xc3028 attached\n");
951 954
952 return 0; 955 return 0;
953} 956}
@@ -963,11 +966,13 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module,
963 mutex_init(&dvb->lock); 966 mutex_init(&dvb->lock);
964 967
965 /* register adapter */ 968 /* register adapter */
966 result = dvb_register_adapter(&dvb->adapter, dev->name, module, device, 969 result = dvb_register_adapter(&dvb->adapter,
967 adapter_nr); 970 dev_name(&dev->intf->dev), module,
971 device, adapter_nr);
968 if (result < 0) { 972 if (result < 0) {
969 printk(KERN_WARNING "%s: dvb_register_adapter failed (errno = %d)\n", 973 dev_warn(&dev->intf->dev,
970 dev->name, result); 974 "dvb_register_adapter failed (errno = %d)\n",
975 result);
971 goto fail_adapter; 976 goto fail_adapter;
972 } 977 }
973#ifdef CONFIG_MEDIA_CONTROLLER_DVB 978#ifdef CONFIG_MEDIA_CONTROLLER_DVB
@@ -984,8 +989,9 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module,
984 /* register frontend */ 989 /* register frontend */
985 result = dvb_register_frontend(&dvb->adapter, dvb->fe[0]); 990 result = dvb_register_frontend(&dvb->adapter, dvb->fe[0]);
986 if (result < 0) { 991 if (result < 0) {
987 printk(KERN_WARNING "%s: dvb_register_frontend failed (errno = %d)\n", 992 dev_warn(&dev->intf->dev,
988 dev->name, result); 993 "dvb_register_frontend failed (errno = %d)\n",
994 result);
989 goto fail_frontend0; 995 goto fail_frontend0;
990 } 996 }
991 997
@@ -993,8 +999,9 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module,
993 if (dvb->fe[1]) { 999 if (dvb->fe[1]) {
994 result = dvb_register_frontend(&dvb->adapter, dvb->fe[1]); 1000 result = dvb_register_frontend(&dvb->adapter, dvb->fe[1]);
995 if (result < 0) { 1001 if (result < 0) {
996 printk(KERN_WARNING "%s: 2nd dvb_register_frontend failed (errno = %d)\n", 1002 dev_warn(&dev->intf->dev,
997 dev->name, result); 1003 "2nd dvb_register_frontend failed (errno = %d)\n",
1004 result);
998 goto fail_frontend1; 1005 goto fail_frontend1;
999 } 1006 }
1000 } 1007 }
@@ -1011,8 +1018,9 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module,
1011 1018
1012 result = dvb_dmx_init(&dvb->demux); 1019 result = dvb_dmx_init(&dvb->demux);
1013 if (result < 0) { 1020 if (result < 0) {
1014 printk(KERN_WARNING "%s: dvb_dmx_init failed (errno = %d)\n", 1021 dev_warn(&dev->intf->dev,
1015 dev->name, result); 1022 "dvb_dmx_init failed (errno = %d)\n",
1023 result);
1016 goto fail_dmx; 1024 goto fail_dmx;
1017 } 1025 }
1018 1026
@@ -1021,31 +1029,35 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module,
1021 dvb->dmxdev.capabilities = 0; 1029 dvb->dmxdev.capabilities = 0;
1022 result = dvb_dmxdev_init(&dvb->dmxdev, &dvb->adapter); 1030 result = dvb_dmxdev_init(&dvb->dmxdev, &dvb->adapter);
1023 if (result < 0) { 1031 if (result < 0) {
1024 printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n", 1032 dev_warn(&dev->intf->dev,
1025 dev->name, result); 1033 "dvb_dmxdev_init failed (errno = %d)\n",
1034 result);
1026 goto fail_dmxdev; 1035 goto fail_dmxdev;
1027 } 1036 }
1028 1037
1029 dvb->fe_hw.source = DMX_FRONTEND_0; 1038 dvb->fe_hw.source = DMX_FRONTEND_0;
1030 result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw); 1039 result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw);
1031 if (result < 0) { 1040 if (result < 0) {
1032 printk(KERN_WARNING "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n", 1041 dev_warn(&dev->intf->dev,
1033 dev->name, result); 1042 "add_frontend failed (DMX_FRONTEND_0, errno = %d)\n",
1043 result);
1034 goto fail_fe_hw; 1044 goto fail_fe_hw;
1035 } 1045 }
1036 1046
1037 dvb->fe_mem.source = DMX_MEMORY_FE; 1047 dvb->fe_mem.source = DMX_MEMORY_FE;
1038 result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem); 1048 result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem);
1039 if (result < 0) { 1049 if (result < 0) {
1040 printk(KERN_WARNING "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n", 1050 dev_warn(&dev->intf->dev,
1041 dev->name, result); 1051 "add_frontend failed (DMX_MEMORY_FE, errno = %d)\n",
1052 result);
1042 goto fail_fe_mem; 1053 goto fail_fe_mem;
1043 } 1054 }
1044 1055
1045 result = dvb->demux.dmx.connect_frontend(&dvb->demux.dmx, &dvb->fe_hw); 1056 result = dvb->demux.dmx.connect_frontend(&dvb->demux.dmx, &dvb->fe_hw);
1046 if (result < 0) { 1057 if (result < 0) {
1047 printk(KERN_WARNING "%s: connect_frontend failed (errno = %d)\n", 1058 dev_warn(&dev->intf->dev,
1048 dev->name, result); 1059 "connect_frontend failed (errno = %d)\n",
1060 result);
1049 goto fail_fe_conn; 1061 goto fail_fe_conn;
1050 } 1062 }
1051 1063
@@ -1117,13 +1129,12 @@ static int em28xx_dvb_init(struct em28xx *dev)
1117 return 0; 1129 return 0;
1118 } 1130 }
1119 1131
1120 em28xx_info("Binding DVB extension\n"); 1132 dev_info(&dev->intf->dev, "Binding DVB extension\n");
1121 1133
1122 dvb = kzalloc(sizeof(struct em28xx_dvb), GFP_KERNEL); 1134 dvb = kzalloc(sizeof(struct em28xx_dvb), GFP_KERNEL);
1123 if (dvb == NULL) { 1135 if (!dvb)
1124 em28xx_info("em28xx_dvb: memory allocation failed\n");
1125 return -ENOMEM; 1136 return -ENOMEM;
1126 } 1137
1127 dev->dvb = dvb; 1138 dev->dvb = dvb;
1128 dvb->fe[0] = dvb->fe[1] = NULL; 1139 dvb->fe[0] = dvb->fe[1] = NULL;
1129 1140
@@ -1142,7 +1153,8 @@ static int em28xx_dvb_init(struct em28xx *dev)
1142 EM28XX_DVB_NUM_ISOC_PACKETS); 1153 EM28XX_DVB_NUM_ISOC_PACKETS);
1143 } 1154 }
1144 if (result) { 1155 if (result) {
1145 em28xx_errdev("em28xx_dvb: failed to pre-allocate USB transfer buffers for DVB.\n"); 1156 dev_err(&dev->intf->dev,
1157 "failed to pre-allocate USB transfer buffers for DVB.\n");
1146 kfree(dvb); 1158 kfree(dvb);
1147 dev->dvb = NULL; 1159 dev->dvb = NULL;
1148 return result; 1160 return result;
@@ -1259,7 +1271,8 @@ static int em28xx_dvb_init(struct em28xx *dev)
1259 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2: 1271 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
1260 case EM2882_BOARD_PINNACLE_HYBRID_PRO_330E: 1272 case EM2882_BOARD_PINNACLE_HYBRID_PRO_330E:
1261 dvb->fe[0] = dvb_attach(drxd_attach, &em28xx_drxd, NULL, 1273 dvb->fe[0] = dvb_attach(drxd_attach, &em28xx_drxd, NULL,
1262 &dev->i2c_adap[dev->def_i2c_bus], &dev->udev->dev); 1274 &dev->i2c_adap[dev->def_i2c_bus],
1275 &dev->intf->dev);
1263 if (em28xx_attach_xc3028(0x61, dev) < 0) { 1276 if (em28xx_attach_xc3028(0x61, dev) < 0) {
1264 result = -EINVAL; 1277 result = -EINVAL;
1265 goto out_free; 1278 goto out_free;
@@ -1321,8 +1334,9 @@ static int em28xx_dvb_init(struct em28xx *dev)
1321 result = gpio_request_one(dvb->lna_gpio, 1334 result = gpio_request_one(dvb->lna_gpio,
1322 GPIOF_OUT_INIT_LOW, NULL); 1335 GPIOF_OUT_INIT_LOW, NULL);
1323 if (result) 1336 if (result)
1324 em28xx_errdev("gpio request failed %d\n", 1337 dev_err(&dev->intf->dev,
1325 result); 1338 "gpio request failed %d\n",
1339 result);
1326 else 1340 else
1327 gpio_free(dvb->lna_gpio); 1341 gpio_free(dvb->lna_gpio);
1328 1342
@@ -1937,12 +1951,12 @@ static int em28xx_dvb_init(struct em28xx *dev)
1937 } 1951 }
1938 break; 1952 break;
1939 default: 1953 default:
1940 em28xx_errdev("/2: The frontend of your DVB/ATSC card" 1954 dev_err(&dev->intf->dev,
1941 " isn't supported yet\n"); 1955 "The frontend of your DVB/ATSC card isn't supported yet\n");
1942 break; 1956 break;
1943 } 1957 }
1944 if (NULL == dvb->fe[0]) { 1958 if (NULL == dvb->fe[0]) {
1945 em28xx_errdev("/2: frontend initialization failed\n"); 1959 dev_err(&dev->intf->dev, "frontend initialization failed\n");
1946 result = -EINVAL; 1960 result = -EINVAL;
1947 goto out_free; 1961 goto out_free;
1948 } 1962 }
@@ -1952,12 +1966,12 @@ static int em28xx_dvb_init(struct em28xx *dev)
1952 dvb->fe[1]->callback = em28xx_tuner_callback; 1966 dvb->fe[1]->callback = em28xx_tuner_callback;
1953 1967
1954 /* register everything */ 1968 /* register everything */
1955 result = em28xx_register_dvb(dvb, THIS_MODULE, dev, &dev->udev->dev); 1969 result = em28xx_register_dvb(dvb, THIS_MODULE, dev, &dev->intf->dev);
1956 1970
1957 if (result < 0) 1971 if (result < 0)
1958 goto out_free; 1972 goto out_free;
1959 1973
1960 em28xx_info("DVB extension successfully initialized\n"); 1974 dev_info(&dev->intf->dev, "DVB extension successfully initialized\n");
1961 1975
1962 kref_get(&dev->ref); 1976 kref_get(&dev->ref);
1963 1977
@@ -1997,7 +2011,7 @@ static int em28xx_dvb_fini(struct em28xx *dev)
1997 if (!dev->dvb) 2011 if (!dev->dvb)
1998 return 0; 2012 return 0;
1999 2013
2000 em28xx_info("Closing DVB extension\n"); 2014 dev_info(&dev->intf->dev, "Closing DVB extension\n");
2001 2015
2002 dvb = dev->dvb; 2016 dvb = dev->dvb;
2003 2017
@@ -2055,17 +2069,17 @@ static int em28xx_dvb_suspend(struct em28xx *dev)
2055 if (!dev->board.has_dvb) 2069 if (!dev->board.has_dvb)
2056 return 0; 2070 return 0;
2057 2071
2058 em28xx_info("Suspending DVB extension\n"); 2072 dev_info(&dev->intf->dev, "Suspending DVB extension\n");
2059 if (dev->dvb) { 2073 if (dev->dvb) {
2060 struct em28xx_dvb *dvb = dev->dvb; 2074 struct em28xx_dvb *dvb = dev->dvb;
2061 2075
2062 if (dvb->fe[0]) { 2076 if (dvb->fe[0]) {
2063 ret = dvb_frontend_suspend(dvb->fe[0]); 2077 ret = dvb_frontend_suspend(dvb->fe[0]);
2064 em28xx_info("fe0 suspend %d\n", ret); 2078 dev_info(&dev->intf->dev, "fe0 suspend %d\n", ret);
2065 } 2079 }
2066 if (dvb->fe[1]) { 2080 if (dvb->fe[1]) {
2067 dvb_frontend_suspend(dvb->fe[1]); 2081 dvb_frontend_suspend(dvb->fe[1]);
2068 em28xx_info("fe1 suspend %d\n", ret); 2082 dev_info(&dev->intf->dev, "fe1 suspend %d\n", ret);
2069 } 2083 }
2070 } 2084 }
2071 2085
@@ -2082,18 +2096,18 @@ static int em28xx_dvb_resume(struct em28xx *dev)
2082 if (!dev->board.has_dvb) 2096 if (!dev->board.has_dvb)
2083 return 0; 2097 return 0;
2084 2098
2085 em28xx_info("Resuming DVB extension\n"); 2099 dev_info(&dev->intf->dev, "Resuming DVB extension\n");
2086 if (dev->dvb) { 2100 if (dev->dvb) {
2087 struct em28xx_dvb *dvb = dev->dvb; 2101 struct em28xx_dvb *dvb = dev->dvb;
2088 2102
2089 if (dvb->fe[0]) { 2103 if (dvb->fe[0]) {
2090 ret = dvb_frontend_resume(dvb->fe[0]); 2104 ret = dvb_frontend_resume(dvb->fe[0]);
2091 em28xx_info("fe0 resume %d\n", ret); 2105 dev_info(&dev->intf->dev, "fe0 resume %d\n", ret);
2092 } 2106 }
2093 2107
2094 if (dvb->fe[1]) { 2108 if (dvb->fe[1]) {
2095 ret = dvb_frontend_resume(dvb->fe[1]); 2109 ret = dvb_frontend_resume(dvb->fe[1]);
2096 em28xx_info("fe1 resume %d\n", ret); 2110 dev_info(&dev->intf->dev, "fe1 resume %d\n", ret);
2097 } 2111 }
2098 } 2112 }
2099 2113
diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c b/drivers/media/usb/em28xx/em28xx-i2c.c
index 8b690ac908a4..8c472d5adb50 100644
--- a/drivers/media/usb/em28xx/em28xx-i2c.c
+++ b/drivers/media/usb/em28xx/em28xx-i2c.c
@@ -22,13 +22,14 @@
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */ 23 */
24 24
25#include "em28xx.h"
26
25#include <linux/module.h> 27#include <linux/module.h>
26#include <linux/kernel.h> 28#include <linux/kernel.h>
27#include <linux/usb.h> 29#include <linux/usb.h>
28#include <linux/i2c.h> 30#include <linux/i2c.h>
29#include <linux/jiffies.h> 31#include <linux/jiffies.h>
30 32
31#include "em28xx.h"
32#include "tuner-xc2028.h" 33#include "tuner-xc2028.h"
33#include <media/v4l2-common.h> 34#include <media/v4l2-common.h>
34#include <media/tuner.h> 35#include <media/tuner.h>
@@ -43,6 +44,13 @@ static unsigned int i2c_debug;
43module_param(i2c_debug, int, 0644); 44module_param(i2c_debug, int, 0644);
44MODULE_PARM_DESC(i2c_debug, "i2c debug message level (1: normal debug, 2: show I2C transfers)"); 45MODULE_PARM_DESC(i2c_debug, "i2c debug message level (1: normal debug, 2: show I2C transfers)");
45 46
47#define dprintk(level, fmt, arg...) do { \
48 if (i2c_debug > level) \
49 dev_printk(KERN_DEBUG, &dev->intf->dev, \
50 "i2c: %s: " fmt, __func__, ## arg); \
51} while (0)
52
53
46/* 54/*
47 * em2800_i2c_send_bytes() 55 * em2800_i2c_send_bytes()
48 * send up to 4 bytes to the em2800 i2c device 56 * send up to 4 bytes to the em2800 i2c device
@@ -70,7 +78,8 @@ static int em2800_i2c_send_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len)
70 /* trigger write */ 78 /* trigger write */
71 ret = dev->em28xx_write_regs(dev, 4 - len, &b2[4 - len], 2 + len); 79 ret = dev->em28xx_write_regs(dev, 4 - len, &b2[4 - len], 2 + len);
72 if (ret != 2 + len) { 80 if (ret != 2 + len) {
73 em28xx_warn("failed to trigger write to i2c address 0x%x (error=%i)\n", 81 dev_warn(&dev->intf->dev,
82 "failed to trigger write to i2c address 0x%x (error=%i)\n",
74 addr, ret); 83 addr, ret);
75 return (ret < 0) ? ret : -EIO; 84 return (ret < 0) ? ret : -EIO;
76 } 85 }
@@ -80,20 +89,18 @@ static int em2800_i2c_send_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len)
80 if (ret == 0x80 + len - 1) 89 if (ret == 0x80 + len - 1)
81 return len; 90 return len;
82 if (ret == 0x94 + len - 1) { 91 if (ret == 0x94 + len - 1) {
83 if (i2c_debug == 1) 92 dprintk(1, "R05 returned 0x%02x: I2C ACK error\n", ret);
84 em28xx_warn("R05 returned 0x%02x: I2C ACK error\n",
85 ret);
86 return -ENXIO; 93 return -ENXIO;
87 } 94 }
88 if (ret < 0) { 95 if (ret < 0) {
89 em28xx_warn("failed to get i2c transfer status from bridge register (error=%i)\n", 96 dev_warn(&dev->intf->dev,
90 ret); 97 "failed to get i2c transfer status from bridge register (error=%i)\n",
98 ret);
91 return ret; 99 return ret;
92 } 100 }
93 msleep(5); 101 msleep(5);
94 } 102 }
95 if (i2c_debug) 103 dprintk(0, "write to i2c device at 0x%x timed out\n", addr);
96 em28xx_warn("write to i2c device at 0x%x timed out\n", addr);
97 return -ETIMEDOUT; 104 return -ETIMEDOUT;
98} 105}
99 106
@@ -116,8 +123,9 @@ static int em2800_i2c_recv_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len)
116 buf2[0] = addr; 123 buf2[0] = addr;
117 ret = dev->em28xx_write_regs(dev, 0x04, buf2, 2); 124 ret = dev->em28xx_write_regs(dev, 0x04, buf2, 2);
118 if (ret != 2) { 125 if (ret != 2) {
119 em28xx_warn("failed to trigger read from i2c address 0x%x (error=%i)\n", 126 dev_warn(&dev->intf->dev,
120 addr, ret); 127 "failed to trigger read from i2c address 0x%x (error=%i)\n",
128 addr, ret);
121 return (ret < 0) ? ret : -EIO; 129 return (ret < 0) ? ret : -EIO;
122 } 130 }
123 131
@@ -127,29 +135,28 @@ static int em2800_i2c_recv_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len)
127 if (ret == 0x84 + len - 1) 135 if (ret == 0x84 + len - 1)
128 break; 136 break;
129 if (ret == 0x94 + len - 1) { 137 if (ret == 0x94 + len - 1) {
130 if (i2c_debug == 1) 138 dprintk(1, "R05 returned 0x%02x: I2C ACK error\n",
131 em28xx_warn("R05 returned 0x%02x: I2C ACK error\n", 139 ret);
132 ret);
133 return -ENXIO; 140 return -ENXIO;
134 } 141 }
135 if (ret < 0) { 142 if (ret < 0) {
136 em28xx_warn("failed to get i2c transfer status from bridge register (error=%i)\n", 143 dev_warn(&dev->intf->dev,
137 ret); 144 "failed to get i2c transfer status from bridge register (error=%i)\n",
145 ret);
138 return ret; 146 return ret;
139 } 147 }
140 msleep(5); 148 msleep(5);
141 } 149 }
142 if (ret != 0x84 + len - 1) { 150 if (ret != 0x84 + len - 1) {
143 if (i2c_debug) 151 dprintk(0, "read from i2c device at 0x%x timed out\n", addr);
144 em28xx_warn("read from i2c device at 0x%x timed out\n",
145 addr);
146 } 152 }
147 153
148 /* get the received message */ 154 /* get the received message */
149 ret = dev->em28xx_read_reg_req_len(dev, 0x00, 4-len, buf2, len); 155 ret = dev->em28xx_read_reg_req_len(dev, 0x00, 4-len, buf2, len);
150 if (ret != len) { 156 if (ret != len) {
151 em28xx_warn("reading from i2c device at 0x%x failed: couldn't get the received message from the bridge (error=%i)\n", 157 dev_warn(&dev->intf->dev,
152 addr, ret); 158 "reading from i2c device at 0x%x failed: couldn't get the received message from the bridge (error=%i)\n",
159 addr, ret);
153 return (ret < 0) ? ret : -EIO; 160 return (ret < 0) ? ret : -EIO;
154 } 161 }
155 for (i = 0; i < len; i++) 162 for (i = 0; i < len; i++)
@@ -193,12 +200,14 @@ static int em28xx_i2c_send_bytes(struct em28xx *dev, u16 addr, u8 *buf,
193 ret = dev->em28xx_write_regs_req(dev, stop ? 2 : 3, addr, buf, len); 200 ret = dev->em28xx_write_regs_req(dev, stop ? 2 : 3, addr, buf, len);
194 if (ret != len) { 201 if (ret != len) {
195 if (ret < 0) { 202 if (ret < 0) {
196 em28xx_warn("writing to i2c device at 0x%x failed (error=%i)\n", 203 dev_warn(&dev->intf->dev,
197 addr, ret); 204 "writing to i2c device at 0x%x failed (error=%i)\n",
205 addr, ret);
198 return ret; 206 return ret;
199 } else { 207 } else {
200 em28xx_warn("%i bytes write to i2c device at 0x%x requested, but %i bytes written\n", 208 dev_warn(&dev->intf->dev,
201 len, addr, ret); 209 "%i bytes write to i2c device at 0x%x requested, but %i bytes written\n",
210 len, addr, ret);
202 return -EIO; 211 return -EIO;
203 } 212 }
204 } 213 }
@@ -209,14 +218,14 @@ static int em28xx_i2c_send_bytes(struct em28xx *dev, u16 addr, u8 *buf,
209 if (ret == 0) /* success */ 218 if (ret == 0) /* success */
210 return len; 219 return len;
211 if (ret == 0x10) { 220 if (ret == 0x10) {
212 if (i2c_debug == 1) 221 dprintk(1, "I2C ACK error on writing to addr 0x%02x\n",
213 em28xx_warn("I2C ACK error on writing to addr 0x%02x\n", 222 addr);
214 addr);
215 return -ENXIO; 223 return -ENXIO;
216 } 224 }
217 if (ret < 0) { 225 if (ret < 0) {
218 em28xx_warn("failed to get i2c transfer status from bridge register (error=%i)\n", 226 dev_warn(&dev->intf->dev,
219 ret); 227 "failed to get i2c transfer status from bridge register (error=%i)\n",
228 ret);
220 return ret; 229 return ret;
221 } 230 }
222 msleep(5); 231 msleep(5);
@@ -229,14 +238,15 @@ static int em28xx_i2c_send_bytes(struct em28xx *dev, u16 addr, u8 *buf,
229 238
230 if (ret == 0x02 || ret == 0x04) { 239 if (ret == 0x02 || ret == 0x04) {
231 /* NOTE: these errors seem to be related to clock stretching */ 240 /* NOTE: these errors seem to be related to clock stretching */
232 if (i2c_debug) 241 dprintk(0,
233 em28xx_warn("write to i2c device at 0x%x timed out (status=%i)\n", 242 "write to i2c device at 0x%x timed out (status=%i)\n",
234 addr, ret); 243 addr, ret);
235 return -ETIMEDOUT; 244 return -ETIMEDOUT;
236 } 245 }
237 246
238 em28xx_warn("write to i2c device at 0x%x failed with unknown error (status=%i)\n", 247 dev_warn(&dev->intf->dev,
239 addr, ret); 248 "write to i2c device at 0x%x failed with unknown error (status=%i)\n",
249 addr, ret);
240 return -EIO; 250 return -EIO;
241} 251}
242 252
@@ -258,8 +268,9 @@ static int em28xx_i2c_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, u16 len)
258 /* Read data from i2c device */ 268 /* Read data from i2c device */
259 ret = dev->em28xx_read_reg_req_len(dev, 2, addr, buf, len); 269 ret = dev->em28xx_read_reg_req_len(dev, 2, addr, buf, len);
260 if (ret < 0) { 270 if (ret < 0) {
261 em28xx_warn("reading from i2c device at 0x%x failed (error=%i)\n", 271 dev_warn(&dev->intf->dev,
262 addr, ret); 272 "reading from i2c device at 0x%x failed (error=%i)\n",
273 addr, ret);
263 return ret; 274 return ret;
264 } 275 }
265 /* 276 /*
@@ -276,27 +287,28 @@ static int em28xx_i2c_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, u16 len)
276 if (ret == 0) /* success */ 287 if (ret == 0) /* success */
277 return len; 288 return len;
278 if (ret < 0) { 289 if (ret < 0) {
279 em28xx_warn("failed to get i2c transfer status from bridge register (error=%i)\n", 290 dev_warn(&dev->intf->dev,
280 ret); 291 "failed to get i2c transfer status from bridge register (error=%i)\n",
292 ret);
281 return ret; 293 return ret;
282 } 294 }
283 if (ret == 0x10) { 295 if (ret == 0x10) {
284 if (i2c_debug == 1) 296 dprintk(1, "I2C ACK error on writing to addr 0x%02x\n",
285 em28xx_warn("I2C ACK error on writing to addr 0x%02x\n", 297 addr);
286 addr);
287 return -ENXIO; 298 return -ENXIO;
288 } 299 }
289 300
290 if (ret == 0x02 || ret == 0x04) { 301 if (ret == 0x02 || ret == 0x04) {
291 /* NOTE: these errors seem to be related to clock stretching */ 302 /* NOTE: these errors seem to be related to clock stretching */
292 if (i2c_debug) 303 dprintk(0,
293 em28xx_warn("write to i2c device at 0x%x timed out (status=%i)\n", 304 "write to i2c device at 0x%x timed out (status=%i)\n",
294 addr, ret); 305 addr, ret);
295 return -ETIMEDOUT; 306 return -ETIMEDOUT;
296 } 307 }
297 308
298 em28xx_warn("write to i2c device at 0x%x failed with unknown error (status=%i)\n", 309 dev_warn(&dev->intf->dev,
299 addr, ret); 310 "write to i2c device at 0x%x failed with unknown error (status=%i)\n",
311 addr, ret);
300 return -EIO; 312 return -EIO;
301} 313}
302 314
@@ -335,12 +347,14 @@ static int em25xx_bus_B_send_bytes(struct em28xx *dev, u16 addr, u8 *buf,
335 ret = dev->em28xx_write_regs_req(dev, 0x06, addr, buf, len); 347 ret = dev->em28xx_write_regs_req(dev, 0x06, addr, buf, len);
336 if (ret != len) { 348 if (ret != len) {
337 if (ret < 0) { 349 if (ret < 0) {
338 em28xx_warn("writing to i2c device at 0x%x failed (error=%i)\n", 350 dev_warn(&dev->intf->dev,
339 addr, ret); 351 "writing to i2c device at 0x%x failed (error=%i)\n",
352 addr, ret);
340 return ret; 353 return ret;
341 } else { 354 } else {
342 em28xx_warn("%i bytes write to i2c device at 0x%x requested, but %i bytes written\n", 355 dev_warn(&dev->intf->dev,
343 len, addr, ret); 356 "%i bytes write to i2c device at 0x%x requested, but %i bytes written\n",
357 len, addr, ret);
344 return -EIO; 358 return -EIO;
345 } 359 }
346 } 360 }
@@ -353,9 +367,7 @@ static int em25xx_bus_B_send_bytes(struct em28xx *dev, u16 addr, u8 *buf,
353 if (!ret) 367 if (!ret)
354 return len; 368 return len;
355 else if (ret > 0) { 369 else if (ret > 0) {
356 if (i2c_debug == 1) 370 dprintk(1, "Bus B R08 returned 0x%02x: I2C ACK error\n", ret);
357 em28xx_warn("Bus B R08 returned 0x%02x: I2C ACK error\n",
358 ret);
359 return -ENXIO; 371 return -ENXIO;
360 } 372 }
361 373
@@ -386,8 +398,9 @@ static int em25xx_bus_B_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf,
386 /* Read value */ 398 /* Read value */
387 ret = dev->em28xx_read_reg_req_len(dev, 0x06, addr, buf, len); 399 ret = dev->em28xx_read_reg_req_len(dev, 0x06, addr, buf, len);
388 if (ret < 0) { 400 if (ret < 0) {
389 em28xx_warn("reading from i2c device at 0x%x failed (error=%i)\n", 401 dev_warn(&dev->intf->dev,
390 addr, ret); 402 "reading from i2c device at 0x%x failed (error=%i)\n",
403 addr, ret);
391 return ret; 404 return ret;
392 } 405 }
393 /* 406 /*
@@ -408,9 +421,7 @@ static int em25xx_bus_B_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf,
408 if (!ret) 421 if (!ret)
409 return len; 422 return len;
410 else if (ret > 0) { 423 else if (ret > 0) {
411 if (i2c_debug == 1) 424 dprintk(1, "Bus B R08 returned 0x%02x: I2C ACK error\n", ret);
412 em28xx_warn("Bus B R08 returned 0x%02x: I2C ACK error\n",
413 ret);
414 return -ENXIO; 425 return -ENXIO;
415 } 426 }
416 427
@@ -528,57 +539,46 @@ static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap,
528 } 539 }
529 for (i = 0; i < num; i++) { 540 for (i = 0; i < num; i++) {
530 addr = msgs[i].addr << 1; 541 addr = msgs[i].addr << 1;
531 if (i2c_debug > 1)
532 printk(KERN_DEBUG "%s at %s: %s %s addr=%02x len=%d:",
533 dev->name, __func__ ,
534 (msgs[i].flags & I2C_M_RD) ? "read" : "write",
535 i == num - 1 ? "stop" : "nonstop",
536 addr, msgs[i].len);
537 if (!msgs[i].len) { 542 if (!msgs[i].len) {
538 /* 543 /*
539 * no len: check only for device presence 544 * no len: check only for device presence
540 * This code is only called during device probe. 545 * This code is only called during device probe.
541 */ 546 */
542 rc = i2c_check_for_device(i2c_bus, addr); 547 rc = i2c_check_for_device(i2c_bus, addr);
543 if (rc < 0) { 548
544 if (rc == -ENXIO) { 549 if (rc == -ENXIO)
545 if (i2c_debug > 1) 550 rc = -ENODEV;
546 printk(KERN_CONT " no device\n");
547 rc = -ENODEV;
548 } else {
549 if (i2c_debug > 1)
550 printk(KERN_CONT " ERROR: %i\n", rc);
551 }
552 rt_mutex_unlock(&dev->i2c_bus_lock);
553 return rc;
554 }
555 } else if (msgs[i].flags & I2C_M_RD) { 551 } else if (msgs[i].flags & I2C_M_RD) {
556 /* read bytes */ 552 /* read bytes */
557 rc = i2c_recv_bytes(i2c_bus, msgs[i]); 553 rc = i2c_recv_bytes(i2c_bus, msgs[i]);
558
559 if (i2c_debug > 1 && rc >= 0)
560 printk(KERN_CONT " %*ph",
561 msgs[i].len, msgs[i].buf);
562 } else { 554 } else {
563 if (i2c_debug > 1)
564 printk(KERN_CONT " %*ph",
565 msgs[i].len, msgs[i].buf);
566
567 /* write bytes */ 555 /* write bytes */
568 rc = i2c_send_bytes(i2c_bus, msgs[i], i == num - 1); 556 rc = i2c_send_bytes(i2c_bus, msgs[i], i == num - 1);
569 } 557 }
570 if (rc < 0) { 558
571 if (i2c_debug > 1) 559 if (rc < 0)
572 printk(KERN_CONT " ERROR: %i\n", rc); 560 goto error;
573 rt_mutex_unlock(&dev->i2c_bus_lock); 561
574 return rc; 562 dprintk(2, "%s %s addr=%02x len=%d: %*ph\n",
575 } 563 (msgs[i].flags & I2C_M_RD) ? "read" : "write",
576 if (i2c_debug > 1) 564 i == num - 1 ? "stop" : "nonstop",
577 printk(KERN_CONT "\n"); 565 addr, msgs[i].len,
566 msgs[i].len, msgs[i].buf);
578 } 567 }
579 568
580 rt_mutex_unlock(&dev->i2c_bus_lock); 569 rt_mutex_unlock(&dev->i2c_bus_lock);
581 return num; 570 return num;
571
572error:
573 dprintk(2, "%s %s addr=%02x len=%d: %sERROR: %i\n",
574 (msgs[i].flags & I2C_M_RD) ? "read" : "write",
575 i == num - 1 ? "stop" : "nonstop",
576 addr, msgs[i].len,
577 (rc == -ENODEV) ? "no device " : "",
578 rc);
579
580 rt_mutex_unlock(&dev->i2c_bus_lock);
581 return rc;
582} 582}
583 583
584/* 584/*
@@ -672,7 +672,7 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned bus,
672 /* Check if board has eeprom */ 672 /* Check if board has eeprom */
673 err = i2c_master_recv(&dev->i2c_client[bus], &buf, 0); 673 err = i2c_master_recv(&dev->i2c_client[bus], &buf, 0);
674 if (err < 0) { 674 if (err < 0) {
675 em28xx_info("board has no eeprom\n"); 675 dev_info(&dev->intf->dev, "board has no eeprom\n");
676 return -ENODEV; 676 return -ENODEV;
677 } 677 }
678 678
@@ -685,17 +685,19 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned bus,
685 dev->eeprom_addrwidth_16bit, 685 dev->eeprom_addrwidth_16bit,
686 len, data); 686 len, data);
687 if (err != len) { 687 if (err != len) {
688 em28xx_errdev("failed to read eeprom (err=%d)\n", err); 688 dev_err(&dev->intf->dev,
689 "failed to read eeprom (err=%d)\n", err);
689 goto error; 690 goto error;
690 } 691 }
691 692
692 if (i2c_debug) { 693 if (i2c_debug) {
693 /* Display eeprom content */ 694 /* Display eeprom content */
694 print_hex_dump(KERN_INFO, "eeprom ", DUMP_PREFIX_OFFSET, 695 print_hex_dump(KERN_DEBUG, "em28xx eeprom ", DUMP_PREFIX_OFFSET,
695 16, 1, data, len, true); 696 16, 1, data, len, true);
696 697
697 if (dev->eeprom_addrwidth_16bit) 698 if (dev->eeprom_addrwidth_16bit)
698 em28xx_info("eeprom %06x: ... (skipped)\n", 256); 699 dev_info(&dev->intf->dev,
700 "eeprom %06x: ... (skipped)\n", 256);
699 } 701 }
700 702
701 if (dev->eeprom_addrwidth_16bit && 703 if (dev->eeprom_addrwidth_16bit &&
@@ -707,11 +709,14 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned bus,
707 dev->hash = em28xx_hash_mem(data, len, 32); 709 dev->hash = em28xx_hash_mem(data, len, 32);
708 mc_start = (data[1] << 8) + 4; /* usually 0x0004 */ 710 mc_start = (data[1] << 8) + 4; /* usually 0x0004 */
709 711
710 em28xx_info("EEPROM ID = %02x %02x %02x %02x, EEPROM hash = 0x%08lx\n", 712 dev_info(&dev->intf->dev,
711 data[0], data[1], data[2], data[3], dev->hash); 713 "EEPROM ID = %02x %02x %02x %02x, EEPROM hash = 0x%08lx\n",
712 em28xx_info("EEPROM info:\n"); 714 data[0], data[1], data[2], data[3], dev->hash);
713 em28xx_info("\tmicrocode start address = 0x%04x, boot configuration = 0x%02x\n", 715 dev_info(&dev->intf->dev,
714 mc_start, data[2]); 716 "EEPROM info:\n");
717 dev_info(&dev->intf->dev,
718 "\tmicrocode start address = 0x%04x, boot configuration = 0x%02x\n",
719 mc_start, data[2]);
715 /* 720 /*
716 * boot configuration (address 0x0002): 721 * boot configuration (address 0x0002):
717 * [0] microcode download speed: 1 = 400 kHz; 0 = 100 kHz 722 * [0] microcode download speed: 1 = 400 kHz; 0 = 100 kHz
@@ -729,8 +734,9 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned bus,
729 err = em28xx_i2c_read_block(dev, bus, mc_start + 46, 1, 2, 734 err = em28xx_i2c_read_block(dev, bus, mc_start + 46, 1, 2,
730 data); 735 data);
731 if (err != 2) { 736 if (err != 2) {
732 em28xx_errdev("failed to read hardware configuration data from eeprom (err=%d)\n", 737 dev_err(&dev->intf->dev,
733 err); 738 "failed to read hardware configuration data from eeprom (err=%d)\n",
739 err);
734 goto error; 740 goto error;
735 } 741 }
736 742
@@ -747,8 +753,9 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned bus,
747 err = em28xx_i2c_read_block(dev, bus, hwconf_offset, 1, len, 753 err = em28xx_i2c_read_block(dev, bus, hwconf_offset, 1, len,
748 data); 754 data);
749 if (err != len) { 755 if (err != len) {
750 em28xx_errdev("failed to read hardware configuration data from eeprom (err=%d)\n", 756 dev_err(&dev->intf->dev,
751 err); 757 "failed to read hardware configuration data from eeprom (err=%d)\n",
758 err);
752 goto error; 759 goto error;
753 } 760 }
754 761
@@ -756,7 +763,8 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned bus,
756 /* NOTE: not all devices provide this type of dataset */ 763 /* NOTE: not all devices provide this type of dataset */
757 if (data[0] != 0x1a || data[1] != 0xeb || 764 if (data[0] != 0x1a || data[1] != 0xeb ||
758 data[2] != 0x67 || data[3] != 0x95) { 765 data[2] != 0x67 || data[3] != 0x95) {
759 em28xx_info("\tno hardware configuration dataset found in eeprom\n"); 766 dev_info(&dev->intf->dev,
767 "\tno hardware configuration dataset found in eeprom\n");
760 kfree(data); 768 kfree(data);
761 return 0; 769 return 0;
762 } 770 }
@@ -767,11 +775,14 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned bus,
767 data[0] == 0x1a && data[1] == 0xeb && 775 data[0] == 0x1a && data[1] == 0xeb &&
768 data[2] == 0x67 && data[3] == 0x95) { 776 data[2] == 0x67 && data[3] == 0x95) {
769 dev->hash = em28xx_hash_mem(data, len, 32); 777 dev->hash = em28xx_hash_mem(data, len, 32);
770 em28xx_info("EEPROM ID = %02x %02x %02x %02x, EEPROM hash = 0x%08lx\n", 778 dev_info(&dev->intf->dev,
771 data[0], data[1], data[2], data[3], dev->hash); 779 "EEPROM ID = %02x %02x %02x %02x, EEPROM hash = 0x%08lx\n",
772 em28xx_info("EEPROM info:\n"); 780 data[0], data[1], data[2], data[3], dev->hash);
781 dev_info(&dev->intf->dev,
782 "EEPROM info:\n");
773 } else { 783 } else {
774 em28xx_info("unknown eeprom format or eeprom corrupted !\n"); 784 dev_info(&dev->intf->dev,
785 "unknown eeprom format or eeprom corrupted !\n");
775 err = -ENODEV; 786 err = -ENODEV;
776 goto error; 787 goto error;
777 } 788 }
@@ -782,50 +793,55 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned bus,
782 793
783 switch (le16_to_cpu(dev_config->chip_conf) >> 4 & 0x3) { 794 switch (le16_to_cpu(dev_config->chip_conf) >> 4 & 0x3) {
784 case 0: 795 case 0:
785 em28xx_info("\tNo audio on board.\n"); 796 dev_info(&dev->intf->dev, "\tNo audio on board.\n");
786 break; 797 break;
787 case 1: 798 case 1:
788 em28xx_info("\tAC97 audio (5 sample rates)\n"); 799 dev_info(&dev->intf->dev, "\tAC97 audio (5 sample rates)\n");
789 break; 800 break;
790 case 2: 801 case 2:
791 if (dev->chip_id < CHIP_ID_EM2860) 802 if (dev->chip_id < CHIP_ID_EM2860)
792 em28xx_info("\tI2S audio, sample rate=32k\n"); 803 dev_info(&dev->intf->dev,
804 "\tI2S audio, sample rate=32k\n");
793 else 805 else
794 em28xx_info("\tI2S audio, 3 sample rates\n"); 806 dev_info(&dev->intf->dev,
807 "\tI2S audio, 3 sample rates\n");
795 break; 808 break;
796 case 3: 809 case 3:
797 if (dev->chip_id < CHIP_ID_EM2860) 810 if (dev->chip_id < CHIP_ID_EM2860)
798 em28xx_info("\tI2S audio, 3 sample rates\n"); 811 dev_info(&dev->intf->dev,
812 "\tI2S audio, 3 sample rates\n");
799 else 813 else
800 em28xx_info("\tI2S audio, 5 sample rates\n"); 814 dev_info(&dev->intf->dev,
815 "\tI2S audio, 5 sample rates\n");
801 break; 816 break;
802 } 817 }
803 818
804 if (le16_to_cpu(dev_config->chip_conf) & 1 << 3) 819 if (le16_to_cpu(dev_config->chip_conf) & 1 << 3)
805 em28xx_info("\tUSB Remote wakeup capable\n"); 820 dev_info(&dev->intf->dev, "\tUSB Remote wakeup capable\n");
806 821
807 if (le16_to_cpu(dev_config->chip_conf) & 1 << 2) 822 if (le16_to_cpu(dev_config->chip_conf) & 1 << 2)
808 em28xx_info("\tUSB Self power capable\n"); 823 dev_info(&dev->intf->dev, "\tUSB Self power capable\n");
809 824
810 switch (le16_to_cpu(dev_config->chip_conf) & 0x3) { 825 switch (le16_to_cpu(dev_config->chip_conf) & 0x3) {
811 case 0: 826 case 0:
812 em28xx_info("\t500mA max power\n"); 827 dev_info(&dev->intf->dev, "\t500mA max power\n");
813 break; 828 break;
814 case 1: 829 case 1:
815 em28xx_info("\t400mA max power\n"); 830 dev_info(&dev->intf->dev, "\t400mA max power\n");
816 break; 831 break;
817 case 2: 832 case 2:
818 em28xx_info("\t300mA max power\n"); 833 dev_info(&dev->intf->dev, "\t300mA max power\n");
819 break; 834 break;
820 case 3: 835 case 3:
821 em28xx_info("\t200mA max power\n"); 836 dev_info(&dev->intf->dev, "\t200mA max power\n");
822 break; 837 break;
823 } 838 }
824 em28xx_info("\tTable at offset 0x%02x, strings=0x%04x, 0x%04x, 0x%04x\n", 839 dev_info(&dev->intf->dev,
825 dev_config->string_idx_table, 840 "\tTable at offset 0x%02x, strings=0x%04x, 0x%04x, 0x%04x\n",
826 le16_to_cpu(dev_config->string1), 841 dev_config->string_idx_table,
827 le16_to_cpu(dev_config->string2), 842 le16_to_cpu(dev_config->string1),
828 le16_to_cpu(dev_config->string3)); 843 le16_to_cpu(dev_config->string2),
844 le16_to_cpu(dev_config->string3));
829 845
830 return 0; 846 return 0;
831 847
@@ -914,8 +930,9 @@ void em28xx_do_i2c_scan(struct em28xx *dev, unsigned bus)
914 if (rc < 0) 930 if (rc < 0)
915 continue; 931 continue;
916 i2c_devicelist[i] = i; 932 i2c_devicelist[i] = i;
917 em28xx_info("found i2c device @ 0x%x on bus %d [%s]\n", 933 dev_info(&dev->intf->dev,
918 i << 1, bus, i2c_devs[i] ? i2c_devs[i] : "???"); 934 "found i2c device @ 0x%x on bus %d [%s]\n",
935 i << 1, bus, i2c_devs[i] ? i2c_devs[i] : "???");
919 } 936 }
920 937
921 if (bus == dev->def_i2c_bus) 938 if (bus == dev->def_i2c_bus)
@@ -939,8 +956,8 @@ int em28xx_i2c_register(struct em28xx *dev, unsigned bus,
939 return -ENODEV; 956 return -ENODEV;
940 957
941 dev->i2c_adap[bus] = em28xx_adap_template; 958 dev->i2c_adap[bus] = em28xx_adap_template;
942 dev->i2c_adap[bus].dev.parent = &dev->udev->dev; 959 dev->i2c_adap[bus].dev.parent = &dev->intf->dev;
943 strcpy(dev->i2c_adap[bus].name, dev->name); 960 strcpy(dev->i2c_adap[bus].name, dev_name(&dev->intf->dev));
944 961
945 dev->i2c_bus[bus].bus = bus; 962 dev->i2c_bus[bus].bus = bus;
946 dev->i2c_bus[bus].algo_type = algo_type; 963 dev->i2c_bus[bus].algo_type = algo_type;
@@ -949,8 +966,9 @@ int em28xx_i2c_register(struct em28xx *dev, unsigned bus,
949 966
950 retval = i2c_add_adapter(&dev->i2c_adap[bus]); 967 retval = i2c_add_adapter(&dev->i2c_adap[bus]);
951 if (retval < 0) { 968 if (retval < 0) {
952 em28xx_errdev("%s: i2c_add_adapter failed! retval [%d]\n", 969 dev_err(&dev->intf->dev,
953 __func__, retval); 970 "%s: i2c_add_adapter failed! retval [%d]\n",
971 __func__, retval);
954 return retval; 972 return retval;
955 } 973 }
956 974
@@ -961,8 +979,9 @@ int em28xx_i2c_register(struct em28xx *dev, unsigned bus,
961 if (!bus) { 979 if (!bus) {
962 retval = em28xx_i2c_eeprom(dev, bus, &dev->eedata, &dev->eedata_len); 980 retval = em28xx_i2c_eeprom(dev, bus, &dev->eedata, &dev->eedata_len);
963 if ((retval < 0) && (retval != -ENODEV)) { 981 if ((retval < 0) && (retval != -ENODEV)) {
964 em28xx_errdev("%s: em28xx_i2_eeprom failed! retval [%d]\n", 982 dev_err(&dev->intf->dev,
965 __func__, retval); 983 "%s: em28xx_i2_eeprom failed! retval [%d]\n",
984 __func__, retval);
966 985
967 return retval; 986 return retval;
968 } 987 }
diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c
index 4007356d991d..782ce095c8c5 100644
--- a/drivers/media/usb/em28xx/em28xx-input.c
+++ b/drivers/media/usb/em28xx/em28xx-input.c
@@ -21,6 +21,8 @@
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 22 */
23 23
24#include "em28xx.h"
25
24#include <linux/module.h> 26#include <linux/module.h>
25#include <linux/init.h> 27#include <linux/init.h>
26#include <linux/delay.h> 28#include <linux/delay.h>
@@ -29,8 +31,6 @@
29#include <linux/slab.h> 31#include <linux/slab.h>
30#include <linux/bitrev.h> 32#include <linux/bitrev.h>
31 33
32#include "em28xx.h"
33
34#define EM28XX_SNAPSHOT_KEY KEY_CAMERA 34#define EM28XX_SNAPSHOT_KEY KEY_CAMERA
35#define EM28XX_BUTTONS_DEBOUNCED_QUERY_INTERVAL 500 /* [ms] */ 35#define EM28XX_BUTTONS_DEBOUNCED_QUERY_INTERVAL 500 /* [ms] */
36#define EM28XX_BUTTONS_VOLATILE_QUERY_INTERVAL 100 /* [ms] */ 36#define EM28XX_BUTTONS_VOLATILE_QUERY_INTERVAL 100 /* [ms] */
@@ -41,10 +41,11 @@ MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]");
41 41
42#define MODULE_NAME "em28xx" 42#define MODULE_NAME "em28xx"
43 43
44#define dprintk(fmt, arg...) \ 44#define dprintk( fmt, arg...) do { \
45 if (ir_debug) { \ 45 if (ir_debug) \
46 printk(KERN_DEBUG "%s/ir: " fmt, ir->name , ## arg); \ 46 dev_printk(KERN_DEBUG, &ir->dev->intf->dev, \
47 } 47 "input: %s: " fmt, __func__, ## arg); \
48} while (0)
48 49
49/********************************************************** 50/**********************************************************
50 Polling structure used by em28xx IR's 51 Polling structure used by em28xx IR's
@@ -458,8 +459,9 @@ static int em28xx_ir_change_protocol(struct rc_dev *rc_dev, u64 *rc_type)
458 case CHIP_ID_EM28178: 459 case CHIP_ID_EM28178:
459 return em2874_ir_change_protocol(rc_dev, rc_type); 460 return em2874_ir_change_protocol(rc_dev, rc_type);
460 default: 461 default:
461 printk("Unrecognized em28xx chip id 0x%02x: IR not supported\n", 462 dev_err(&ir->dev->intf->dev,
462 dev->chip_id); 463 "Unrecognized em28xx chip id 0x%02x: IR not supported\n",
464 dev->chip_id);
463 return -EINVAL; 465 return -EINVAL;
464 } 466 }
465} 467}
@@ -564,15 +566,16 @@ static void em28xx_query_buttons(struct work_struct *work)
564 566
565static int em28xx_register_snapshot_button(struct em28xx *dev) 567static int em28xx_register_snapshot_button(struct em28xx *dev)
566{ 568{
569 struct usb_device *udev = interface_to_usbdev(dev->intf);
567 struct input_dev *input_dev; 570 struct input_dev *input_dev;
568 int err; 571 int err;
569 572
570 em28xx_info("Registering snapshot button...\n"); 573 dev_info(&dev->intf->dev, "Registering snapshot button...\n");
571 input_dev = input_allocate_device(); 574 input_dev = input_allocate_device();
572 if (!input_dev) 575 if (!input_dev)
573 return -ENOMEM; 576 return -ENOMEM;
574 577
575 usb_make_path(dev->udev, dev->snapshot_button_path, 578 usb_make_path(udev, dev->snapshot_button_path,
576 sizeof(dev->snapshot_button_path)); 579 sizeof(dev->snapshot_button_path));
577 strlcat(dev->snapshot_button_path, "/sbutton", 580 strlcat(dev->snapshot_button_path, "/sbutton",
578 sizeof(dev->snapshot_button_path)); 581 sizeof(dev->snapshot_button_path));
@@ -584,14 +587,14 @@ static int em28xx_register_snapshot_button(struct em28xx *dev)
584 input_dev->keycodesize = 0; 587 input_dev->keycodesize = 0;
585 input_dev->keycodemax = 0; 588 input_dev->keycodemax = 0;
586 input_dev->id.bustype = BUS_USB; 589 input_dev->id.bustype = BUS_USB;
587 input_dev->id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor); 590 input_dev->id.vendor = le16_to_cpu(udev->descriptor.idVendor);
588 input_dev->id.product = le16_to_cpu(dev->udev->descriptor.idProduct); 591 input_dev->id.product = le16_to_cpu(udev->descriptor.idProduct);
589 input_dev->id.version = 1; 592 input_dev->id.version = 1;
590 input_dev->dev.parent = &dev->udev->dev; 593 input_dev->dev.parent = &dev->intf->dev;
591 594
592 err = input_register_device(input_dev); 595 err = input_register_device(input_dev);
593 if (err) { 596 if (err) {
594 em28xx_errdev("input_register_device failed\n"); 597 dev_err(&dev->intf->dev, "input_register_device failed\n");
595 input_free_device(input_dev); 598 input_free_device(input_dev);
596 return err; 599 return err;
597 } 600 }
@@ -631,7 +634,8 @@ static void em28xx_init_buttons(struct em28xx *dev)
631 } else if (button->role == EM28XX_BUTTON_ILLUMINATION) { 634 } else if (button->role == EM28XX_BUTTON_ILLUMINATION) {
632 /* Check sanity */ 635 /* Check sanity */
633 if (!em28xx_find_led(dev, EM28XX_LED_ILLUMINATION)) { 636 if (!em28xx_find_led(dev, EM28XX_LED_ILLUMINATION)) {
634 em28xx_errdev("BUG: illumination button defined, but no illumination LED.\n"); 637 dev_err(&dev->intf->dev,
638 "BUG: illumination button defined, but no illumination LED.\n");
635 goto next_button; 639 goto next_button;
636 } 640 }
637 } 641 }
@@ -667,7 +671,7 @@ static void em28xx_shutdown_buttons(struct em28xx *dev)
667 dev->num_button_polling_addresses = 0; 671 dev->num_button_polling_addresses = 0;
668 /* Deregister input devices */ 672 /* Deregister input devices */
669 if (dev->sbutton_input_dev != NULL) { 673 if (dev->sbutton_input_dev != NULL) {
670 em28xx_info("Deregistering snapshot button\n"); 674 dev_info(&dev->intf->dev, "Deregistering snapshot button\n");
671 input_unregister_device(dev->sbutton_input_dev); 675 input_unregister_device(dev->sbutton_input_dev);
672 dev->sbutton_input_dev = NULL; 676 dev->sbutton_input_dev = NULL;
673 } 677 }
@@ -675,6 +679,7 @@ static void em28xx_shutdown_buttons(struct em28xx *dev)
675 679
676static int em28xx_ir_init(struct em28xx *dev) 680static int em28xx_ir_init(struct em28xx *dev)
677{ 681{
682 struct usb_device *udev = interface_to_usbdev(dev->intf);
678 struct em28xx_IR *ir; 683 struct em28xx_IR *ir;
679 struct rc_dev *rc; 684 struct rc_dev *rc;
680 int err = -ENOMEM; 685 int err = -ENOMEM;
@@ -696,19 +701,20 @@ static int em28xx_ir_init(struct em28xx *dev)
696 i2c_rc_dev_addr = em28xx_probe_i2c_ir(dev); 701 i2c_rc_dev_addr = em28xx_probe_i2c_ir(dev);
697 if (!i2c_rc_dev_addr) { 702 if (!i2c_rc_dev_addr) {
698 dev->board.has_ir_i2c = 0; 703 dev->board.has_ir_i2c = 0;
699 em28xx_warn("No i2c IR remote control device found.\n"); 704 dev_warn(&dev->intf->dev,
705 "No i2c IR remote control device found.\n");
700 return -ENODEV; 706 return -ENODEV;
701 } 707 }
702 } 708 }
703 709
704 if (dev->board.ir_codes == NULL && !dev->board.has_ir_i2c) { 710 if (dev->board.ir_codes == NULL && !dev->board.has_ir_i2c) {
705 /* No remote control support */ 711 /* No remote control support */
706 em28xx_warn("Remote control support is not available for " 712 dev_warn(&dev->intf->dev,
707 "this card.\n"); 713 "Remote control support is not available for this card.\n");
708 return 0; 714 return 0;
709 } 715 }
710 716
711 em28xx_info("Registering input extension\n"); 717 dev_info(&dev->intf->dev, "Registering input extension\n");
712 718
713 ir = kzalloc(sizeof(*ir), GFP_KERNEL); 719 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
714 if (!ir) 720 if (!ir)
@@ -792,18 +798,19 @@ static int em28xx_ir_init(struct em28xx *dev)
792 ir->polling = 100; /* ms */ 798 ir->polling = 100; /* ms */
793 799
794 /* init input device */ 800 /* init input device */
795 snprintf(ir->name, sizeof(ir->name), "em28xx IR (%s)", dev->name); 801 snprintf(ir->name, sizeof(ir->name), "%s IR",
802 dev_name(&dev->intf->dev));
796 803
797 usb_make_path(dev->udev, ir->phys, sizeof(ir->phys)); 804 usb_make_path(udev, ir->phys, sizeof(ir->phys));
798 strlcat(ir->phys, "/input0", sizeof(ir->phys)); 805 strlcat(ir->phys, "/input0", sizeof(ir->phys));
799 806
800 rc->input_name = ir->name; 807 rc->input_name = ir->name;
801 rc->input_phys = ir->phys; 808 rc->input_phys = ir->phys;
802 rc->input_id.bustype = BUS_USB; 809 rc->input_id.bustype = BUS_USB;
803 rc->input_id.version = 1; 810 rc->input_id.version = 1;
804 rc->input_id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor); 811 rc->input_id.vendor = le16_to_cpu(udev->descriptor.idVendor);
805 rc->input_id.product = le16_to_cpu(dev->udev->descriptor.idProduct); 812 rc->input_id.product = le16_to_cpu(udev->descriptor.idProduct);
806 rc->dev.parent = &dev->udev->dev; 813 rc->dev.parent = &dev->intf->dev;
807 rc->driver_name = MODULE_NAME; 814 rc->driver_name = MODULE_NAME;
808 815
809 /* all done */ 816 /* all done */
@@ -811,7 +818,7 @@ static int em28xx_ir_init(struct em28xx *dev)
811 if (err) 818 if (err)
812 goto error; 819 goto error;
813 820
814 em28xx_info("Input extension successfully initalized\n"); 821 dev_info(&dev->intf->dev, "Input extension successfully initalized\n");
815 822
816 return 0; 823 return 0;
817 824
@@ -832,7 +839,7 @@ static int em28xx_ir_fini(struct em28xx *dev)
832 return 0; 839 return 0;
833 } 840 }
834 841
835 em28xx_info("Closing input extension\n"); 842 dev_info(&dev->intf->dev, "Closing input extension\n");
836 843
837 em28xx_shutdown_buttons(dev); 844 em28xx_shutdown_buttons(dev);
838 845
@@ -861,7 +868,7 @@ static int em28xx_ir_suspend(struct em28xx *dev)
861 if (dev->is_audio_only) 868 if (dev->is_audio_only)
862 return 0; 869 return 0;
863 870
864 em28xx_info("Suspending input extension\n"); 871 dev_info(&dev->intf->dev, "Suspending input extension\n");
865 if (ir) 872 if (ir)
866 cancel_delayed_work_sync(&ir->work); 873 cancel_delayed_work_sync(&ir->work);
867 cancel_delayed_work_sync(&dev->buttons_query_work); 874 cancel_delayed_work_sync(&dev->buttons_query_work);
@@ -878,7 +885,7 @@ static int em28xx_ir_resume(struct em28xx *dev)
878 if (dev->is_audio_only) 885 if (dev->is_audio_only)
879 return 0; 886 return 0;
880 887
881 em28xx_info("Resuming input extension\n"); 888 dev_info(&dev->intf->dev, "Resuming input extension\n");
882 /* if suspend calls ir_raw_event_unregister(), the should call 889 /* if suspend calls ir_raw_event_unregister(), the should call
883 ir_raw_event_register() */ 890 ir_raw_event_register() */
884 if (ir) 891 if (ir)
diff --git a/drivers/media/usb/em28xx/em28xx-vbi.c b/drivers/media/usb/em28xx/em28xx-vbi.c
index 836c6b53b16c..0bac552bbe87 100644
--- a/drivers/media/usb/em28xx/em28xx-vbi.c
+++ b/drivers/media/usb/em28xx/em28xx-vbi.c
@@ -21,12 +21,14 @@
21 02110-1301, USA. 21 02110-1301, USA.
22 */ 22 */
23 23
24#include "em28xx.h"
25
24#include <linux/kernel.h> 26#include <linux/kernel.h>
25#include <linux/module.h> 27#include <linux/module.h>
26#include <linux/hardirq.h> 28#include <linux/hardirq.h>
27#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/usb.h>
28 31
29#include "em28xx.h"
30#include "em28xx-v4l.h" 32#include "em28xx-v4l.h"
31 33
32/* ------------------------------------------------------------------ */ 34/* ------------------------------------------------------------------ */
@@ -63,8 +65,9 @@ static int vbi_buffer_prepare(struct vb2_buffer *vb)
63 size = v4l2->vbi_width * v4l2->vbi_height * 2; 65 size = v4l2->vbi_width * v4l2->vbi_height * 2;
64 66
65 if (vb2_plane_size(vb, 0) < size) { 67 if (vb2_plane_size(vb, 0) < size) {
66 printk(KERN_INFO "%s data will not fit into plane (%lu < %lu)\n", 68 dev_info(&dev->intf->dev,
67 __func__, vb2_plane_size(vb, 0), size); 69 "%s data will not fit into plane (%lu < %lu)\n",
70 __func__, vb2_plane_size(vb, 0), size);
68 return -EINVAL; 71 return -EINVAL;
69 } 72 }
70 vb2_set_plane_payload(vb, 0, size); 73 vb2_set_plane_payload(vb, 0, size);
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index 1f7fa059eb34..8d93100334ea 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -26,6 +26,8 @@
26 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 */ 27 */
28 28
29#include "em28xx.h"
30
29#include <linux/init.h> 31#include <linux/init.h>
30#include <linux/list.h> 32#include <linux/list.h>
31#include <linux/module.h> 33#include <linux/module.h>
@@ -37,7 +39,6 @@
37#include <linux/mutex.h> 39#include <linux/mutex.h>
38#include <linux/slab.h> 40#include <linux/slab.h>
39 41
40#include "em28xx.h"
41#include "em28xx-v4l.h" 42#include "em28xx-v4l.h"
42#include <media/v4l2-common.h> 43#include <media/v4l2-common.h>
43#include <media/v4l2-ioctl.h> 44#include <media/v4l2-ioctl.h>
@@ -63,18 +64,17 @@ static int alt;
63module_param(alt, int, 0644); 64module_param(alt, int, 0644);
64MODULE_PARM_DESC(alt, "alternate setting to use for video endpoint"); 65MODULE_PARM_DESC(alt, "alternate setting to use for video endpoint");
65 66
66#define em28xx_videodbg(fmt, arg...) do {\ 67#define em28xx_videodbg(fmt, arg...) do { \
67 if (video_debug) \ 68 if (video_debug) \
68 printk(KERN_INFO "%s %s :"fmt, \ 69 dev_printk(KERN_DEBUG, &dev->intf->dev, \
69 dev->name, __func__ , ##arg); } while (0) 70 "video: %s: " fmt, __func__, ## arg); \
71} while (0)
70 72
71#define em28xx_isocdbg(fmt, arg...) \ 73#define em28xx_isocdbg(fmt, arg...) do {\
72do {\ 74 if (isoc_debug) \
73 if (isoc_debug) { \ 75 dev_printk(KERN_DEBUG, &dev->intf->dev, \
74 printk(KERN_INFO "%s %s :"fmt, \ 76 "isoc: %s: " fmt, __func__, ## arg); \
75 dev->name, __func__ , ##arg); \ 77} while (0)
76 } \
77 } while (0)
78 78
79MODULE_AUTHOR(DRIVER_AUTHOR); 79MODULE_AUTHOR(DRIVER_AUTHOR);
80MODULE_DESCRIPTION(DRIVER_DESC " - v4l2 interface"); 80MODULE_DESCRIPTION(DRIVER_DESC " - v4l2 interface");
@@ -360,6 +360,7 @@ static int em28xx_resolution_set(struct em28xx *dev)
360static int em28xx_set_alternate(struct em28xx *dev) 360static int em28xx_set_alternate(struct em28xx *dev)
361{ 361{
362 struct em28xx_v4l2 *v4l2 = dev->v4l2; 362 struct em28xx_v4l2 *v4l2 = dev->v4l2;
363 struct usb_device *udev = interface_to_usbdev(dev->intf);
363 int errCode; 364 int errCode;
364 int i; 365 int i;
365 unsigned int min_pkt_size = v4l2->width * 2 + 4; 366 unsigned int min_pkt_size = v4l2->width * 2 + 4;
@@ -411,10 +412,11 @@ set_alt:
411 } 412 }
412 em28xx_videodbg("setting alternate %d with wMaxPacketSize=%u\n", 413 em28xx_videodbg("setting alternate %d with wMaxPacketSize=%u\n",
413 dev->alt, dev->max_pkt_size); 414 dev->alt, dev->max_pkt_size);
414 errCode = usb_set_interface(dev->udev, dev->ifnum, dev->alt); 415 errCode = usb_set_interface(udev, dev->ifnum, dev->alt);
415 if (errCode < 0) { 416 if (errCode < 0) {
416 em28xx_errdev("cannot change alternate number to %d (error=%i)\n", 417 dev_err(&dev->intf->dev,
417 dev->alt, errCode); 418 "cannot change alternate number to %d (error=%i)\n",
419 dev->alt, errCode);
418 return errCode; 420 return errCode;
419 } 421 }
420 return 0; 422 return 0;
@@ -505,8 +507,7 @@ static void em28xx_copy_video(struct em28xx *dev,
505 507
506 if ((char *)startwrite + lencopy > (char *)buf->vb_buf + 508 if ((char *)startwrite + lencopy > (char *)buf->vb_buf +
507 buf->length) { 509 buf->length) {
508 em28xx_isocdbg("Overflow of %zu bytes past buffer end" 510 em28xx_isocdbg("Overflow of %zu bytes past buffer end(2)\n",
509 "(2)\n",
510 ((char *)startwrite + lencopy) - 511 ((char *)startwrite + lencopy) -
511 ((char *)buf->vb_buf + buf->length)); 512 ((char *)buf->vb_buf + buf->length));
512 lencopy = remain = (char *)buf->vb_buf + buf->length - 513 lencopy = remain = (char *)buf->vb_buf + buf->length -
@@ -926,10 +927,11 @@ static int em28xx_enable_analog_tuner(struct em28xx *dev)
926 927
927 ret = media_entity_setup_link(link, flags); 928 ret = media_entity_setup_link(link, flags);
928 if (ret) { 929 if (ret) {
929 pr_err("Couldn't change link %s->%s to %s. Error %d\n", 930 dev_err(&dev->intf->dev,
930 source->name, sink->name, 931 "Couldn't change link %s->%s to %s. Error %d\n",
931 flags ? "enabled" : "disabled", 932 source->name, sink->name,
932 ret); 933 flags ? "enabled" : "disabled",
934 ret);
933 return ret; 935 return ret;
934 } else 936 } else
935 em28xx_videodbg("link %s->%s was %s\n", 937 em28xx_videodbg("link %s->%s was %s\n",
@@ -957,14 +959,16 @@ static void em28xx_v4l2_create_entities(struct em28xx *dev)
957 v4l2->video_pad.flags = MEDIA_PAD_FL_SINK; 959 v4l2->video_pad.flags = MEDIA_PAD_FL_SINK;
958 ret = media_entity_pads_init(&v4l2->vdev.entity, 1, &v4l2->video_pad); 960 ret = media_entity_pads_init(&v4l2->vdev.entity, 1, &v4l2->video_pad);
959 if (ret < 0) 961 if (ret < 0)
960 pr_err("failed to initialize video media entity!\n"); 962 dev_err(&dev->intf->dev,
963 "failed to initialize video media entity!\n");
961 964
962 if (em28xx_vbi_supported(dev)) { 965 if (em28xx_vbi_supported(dev)) {
963 v4l2->vbi_pad.flags = MEDIA_PAD_FL_SINK; 966 v4l2->vbi_pad.flags = MEDIA_PAD_FL_SINK;
964 ret = media_entity_pads_init(&v4l2->vbi_dev.entity, 1, 967 ret = media_entity_pads_init(&v4l2->vbi_dev.entity, 1,
965 &v4l2->vbi_pad); 968 &v4l2->vbi_pad);
966 if (ret < 0) 969 if (ret < 0)
967 pr_err("failed to initialize vbi media entity!\n"); 970 dev_err(&dev->intf->dev,
971 "failed to initialize vbi media entity!\n");
968 } 972 }
969 973
970 /* Webcams don't have input connectors */ 974 /* Webcams don't have input connectors */
@@ -997,11 +1001,13 @@ static void em28xx_v4l2_create_entities(struct em28xx *dev)
997 1001
998 ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]); 1002 ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]);
999 if (ret < 0) 1003 if (ret < 0)
1000 pr_err("failed to initialize input pad[%d]!\n", i); 1004 dev_err(&dev->intf->dev,
1005 "failed to initialize input pad[%d]!\n", i);
1001 1006
1002 ret = media_device_register_entity(dev->media_dev, ent); 1007 ret = media_device_register_entity(dev->media_dev, ent);
1003 if (ret < 0) 1008 if (ret < 0)
1004 pr_err("failed to register input entity %d!\n", i); 1009 dev_err(&dev->intf->dev,
1010 "failed to register input entity %d!\n", i);
1005 } 1011 }
1006#endif 1012#endif
1007} 1013}
@@ -1854,10 +1860,11 @@ static int vidioc_querycap(struct file *file, void *priv,
1854 struct video_device *vdev = video_devdata(file); 1860 struct video_device *vdev = video_devdata(file);
1855 struct em28xx *dev = video_drvdata(file); 1861 struct em28xx *dev = video_drvdata(file);
1856 struct em28xx_v4l2 *v4l2 = dev->v4l2; 1862 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1863 struct usb_device *udev = interface_to_usbdev(dev->intf);
1857 1864
1858 strlcpy(cap->driver, "em28xx", sizeof(cap->driver)); 1865 strlcpy(cap->driver, "em28xx", sizeof(cap->driver));
1859 strlcpy(cap->card, em28xx_boards[dev->model].name, sizeof(cap->card)); 1866 strlcpy(cap->card, em28xx_boards[dev->model].name, sizeof(cap->card));
1860 usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)); 1867 usb_make_path(udev, cap->bus_info, sizeof(cap->bus_info));
1861 1868
1862 if (vdev->vfl_type == VFL_TYPE_GRABBER) 1869 if (vdev->vfl_type == VFL_TYPE_GRABBER)
1863 cap->device_caps = V4L2_CAP_READWRITE | 1870 cap->device_caps = V4L2_CAP_READWRITE |
@@ -2048,8 +2055,9 @@ static int em28xx_v4l2_open(struct file *filp)
2048 2055
2049 ret = v4l2_fh_open(filp); 2056 ret = v4l2_fh_open(filp);
2050 if (ret) { 2057 if (ret) {
2051 em28xx_errdev("%s: v4l2_fh_open() returned error %d\n", 2058 dev_err(&dev->intf->dev,
2052 __func__, ret); 2059 "%s: v4l2_fh_open() returned error %d\n",
2060 __func__, ret);
2053 mutex_unlock(&dev->lock); 2061 mutex_unlock(&dev->lock);
2054 return ret; 2062 return ret;
2055 } 2063 }
@@ -2103,7 +2111,7 @@ static int em28xx_v4l2_fini(struct em28xx *dev)
2103 if (v4l2 == NULL) 2111 if (v4l2 == NULL)
2104 return 0; 2112 return 0;
2105 2113
2106 em28xx_info("Closing video extension\n"); 2114 dev_info(&dev->intf->dev, "Closing video extension\n");
2107 2115
2108 mutex_lock(&dev->lock); 2116 mutex_lock(&dev->lock);
2109 2117
@@ -2114,18 +2122,18 @@ static int em28xx_v4l2_fini(struct em28xx *dev)
2114 em28xx_v4l2_media_release(dev); 2122 em28xx_v4l2_media_release(dev);
2115 2123
2116 if (video_is_registered(&v4l2->radio_dev)) { 2124 if (video_is_registered(&v4l2->radio_dev)) {
2117 em28xx_info("V4L2 device %s deregistered\n", 2125 dev_info(&dev->intf->dev, "V4L2 device %s deregistered\n",
2118 video_device_node_name(&v4l2->radio_dev)); 2126 video_device_node_name(&v4l2->radio_dev));
2119 video_unregister_device(&v4l2->radio_dev); 2127 video_unregister_device(&v4l2->radio_dev);
2120 } 2128 }
2121 if (video_is_registered(&v4l2->vbi_dev)) { 2129 if (video_is_registered(&v4l2->vbi_dev)) {
2122 em28xx_info("V4L2 device %s deregistered\n", 2130 dev_info(&dev->intf->dev, "V4L2 device %s deregistered\n",
2123 video_device_node_name(&v4l2->vbi_dev)); 2131 video_device_node_name(&v4l2->vbi_dev));
2124 video_unregister_device(&v4l2->vbi_dev); 2132 video_unregister_device(&v4l2->vbi_dev);
2125 } 2133 }
2126 if (video_is_registered(&v4l2->vdev)) { 2134 if (video_is_registered(&v4l2->vdev)) {
2127 em28xx_info("V4L2 device %s deregistered\n", 2135 dev_info(&dev->intf->dev, "V4L2 device %s deregistered\n",
2128 video_device_node_name(&v4l2->vdev)); 2136 video_device_node_name(&v4l2->vdev));
2129 video_unregister_device(&v4l2->vdev); 2137 video_unregister_device(&v4l2->vdev);
2130 } 2138 }
2131 2139
@@ -2154,7 +2162,7 @@ static int em28xx_v4l2_suspend(struct em28xx *dev)
2154 if (!dev->has_video) 2162 if (!dev->has_video)
2155 return 0; 2163 return 0;
2156 2164
2157 em28xx_info("Suspending video extension\n"); 2165 dev_info(&dev->intf->dev, "Suspending video extension\n");
2158 em28xx_stop_urbs(dev); 2166 em28xx_stop_urbs(dev);
2159 return 0; 2167 return 0;
2160} 2168}
@@ -2167,7 +2175,7 @@ static int em28xx_v4l2_resume(struct em28xx *dev)
2167 if (!dev->has_video) 2175 if (!dev->has_video)
2168 return 0; 2176 return 0;
2169 2177
2170 em28xx_info("Resuming video extension\n"); 2178 dev_info(&dev->intf->dev, "Resuming video extension\n");
2171 /* what do we do here */ 2179 /* what do we do here */
2172 return 0; 2180 return 0;
2173} 2181}
@@ -2181,6 +2189,7 @@ static int em28xx_v4l2_close(struct file *filp)
2181{ 2189{
2182 struct em28xx *dev = video_drvdata(filp); 2190 struct em28xx *dev = video_drvdata(filp);
2183 struct em28xx_v4l2 *v4l2 = dev->v4l2; 2191 struct em28xx_v4l2 *v4l2 = dev->v4l2;
2192 struct usb_device *udev = interface_to_usbdev(dev->intf);
2184 int errCode; 2193 int errCode;
2185 2194
2186 em28xx_videodbg("users=%d\n", v4l2->users); 2195 em28xx_videodbg("users=%d\n", v4l2->users);
@@ -2202,10 +2211,11 @@ static int em28xx_v4l2_close(struct file *filp)
2202 /* set alternate 0 */ 2211 /* set alternate 0 */
2203 dev->alt = 0; 2212 dev->alt = 0;
2204 em28xx_videodbg("setting alternate 0\n"); 2213 em28xx_videodbg("setting alternate 0\n");
2205 errCode = usb_set_interface(dev->udev, 0, 0); 2214 errCode = usb_set_interface(udev, 0, 0);
2206 if (errCode < 0) { 2215 if (errCode < 0) {
2207 em28xx_errdev("cannot change alternate number to " 2216 dev_err(&dev->intf->dev,
2208 "0 (error=%i)\n", errCode); 2217 "cannot change alternate number to 0 (error=%i)\n",
2218 errCode);
2209 } 2219 }
2210 } 2220 }
2211 2221
@@ -2338,7 +2348,7 @@ static void em28xx_vdev_init(struct em28xx *dev,
2338 vfd->tvnorms = 0; 2348 vfd->tvnorms = 0;
2339 2349
2340 snprintf(vfd->name, sizeof(vfd->name), "%s %s", 2350 snprintf(vfd->name, sizeof(vfd->name), "%s %s",
2341 dev->name, type_name); 2351 dev_name(&dev->intf->dev), type_name);
2342 2352
2343 video_set_drvdata(vfd, dev); 2353 video_set_drvdata(vfd, dev);
2344} 2354}
@@ -2422,13 +2432,12 @@ static int em28xx_v4l2_init(struct em28xx *dev)
2422 return 0; 2432 return 0;
2423 } 2433 }
2424 2434
2425 em28xx_info("Registering V4L2 extension\n"); 2435 dev_info(&dev->intf->dev, "Registering V4L2 extension\n");
2426 2436
2427 mutex_lock(&dev->lock); 2437 mutex_lock(&dev->lock);
2428 2438
2429 v4l2 = kzalloc(sizeof(struct em28xx_v4l2), GFP_KERNEL); 2439 v4l2 = kzalloc(sizeof(struct em28xx_v4l2), GFP_KERNEL);
2430 if (v4l2 == NULL) { 2440 if (!v4l2) {
2431 em28xx_info("em28xx_v4l: memory allocation failed\n");
2432 mutex_unlock(&dev->lock); 2441 mutex_unlock(&dev->lock);
2433 return -ENOMEM; 2442 return -ENOMEM;
2434 } 2443 }
@@ -2439,9 +2448,10 @@ static int em28xx_v4l2_init(struct em28xx *dev)
2439#ifdef CONFIG_MEDIA_CONTROLLER 2448#ifdef CONFIG_MEDIA_CONTROLLER
2440 v4l2->v4l2_dev.mdev = dev->media_dev; 2449 v4l2->v4l2_dev.mdev = dev->media_dev;
2441#endif 2450#endif
2442 ret = v4l2_device_register(&dev->udev->dev, &v4l2->v4l2_dev); 2451 ret = v4l2_device_register(&dev->intf->dev, &v4l2->v4l2_dev);
2443 if (ret < 0) { 2452 if (ret < 0) {
2444 em28xx_errdev("Call to v4l2_device_register() failed!\n"); 2453 dev_err(&dev->intf->dev,
2454 "Call to v4l2_device_register() failed!\n");
2445 goto err; 2455 goto err;
2446 } 2456 }
2447 2457
@@ -2525,8 +2535,9 @@ static int em28xx_v4l2_init(struct em28xx *dev)
2525 /* Configure audio */ 2535 /* Configure audio */
2526 ret = em28xx_audio_setup(dev); 2536 ret = em28xx_audio_setup(dev);
2527 if (ret < 0) { 2537 if (ret < 0) {
2528 em28xx_errdev("%s: Error while setting audio - error [%d]!\n", 2538 dev_err(&dev->intf->dev,
2529 __func__, ret); 2539 "%s: Error while setting audio - error [%d]!\n",
2540 __func__, ret);
2530 goto unregister_dev; 2541 goto unregister_dev;
2531 } 2542 }
2532 if (dev->audio_mode.ac97 != EM28XX_NO_AC97) { 2543 if (dev->audio_mode.ac97 != EM28XX_NO_AC97) {
@@ -2553,16 +2564,18 @@ static int em28xx_v4l2_init(struct em28xx *dev)
2553 /* Send a reset to other chips via gpio */ 2564 /* Send a reset to other chips via gpio */
2554 ret = em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xf7); 2565 ret = em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xf7);
2555 if (ret < 0) { 2566 if (ret < 0) {
2556 em28xx_errdev("%s: em28xx_write_reg - msp34xx(1) failed! error [%d]\n", 2567 dev_err(&dev->intf->dev,
2557 __func__, ret); 2568 "%s: em28xx_write_reg - msp34xx(1) failed! error [%d]\n",
2569 __func__, ret);
2558 goto unregister_dev; 2570 goto unregister_dev;
2559 } 2571 }
2560 msleep(3); 2572 msleep(3);
2561 2573
2562 ret = em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xff); 2574 ret = em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xff);
2563 if (ret < 0) { 2575 if (ret < 0) {
2564 em28xx_errdev("%s: em28xx_write_reg - msp34xx(2) failed! error [%d]\n", 2576 dev_err(&dev->intf->dev,
2565 __func__, ret); 2577 "%s: em28xx_write_reg - msp34xx(2) failed! error [%d]\n",
2578 __func__, ret);
2566 goto unregister_dev; 2579 goto unregister_dev;
2567 } 2580 }
2568 msleep(3); 2581 msleep(3);
@@ -2663,8 +2676,8 @@ static int em28xx_v4l2_init(struct em28xx *dev)
2663 ret = video_register_device(&v4l2->vdev, VFL_TYPE_GRABBER, 2676 ret = video_register_device(&v4l2->vdev, VFL_TYPE_GRABBER,
2664 video_nr[dev->devno]); 2677 video_nr[dev->devno]);
2665 if (ret) { 2678 if (ret) {
2666 em28xx_errdev("unable to register video device (error=%i).\n", 2679 dev_err(&dev->intf->dev,
2667 ret); 2680 "unable to register video device (error=%i).\n", ret);
2668 goto unregister_dev; 2681 goto unregister_dev;
2669 } 2682 }
2670 2683
@@ -2693,7 +2706,8 @@ static int em28xx_v4l2_init(struct em28xx *dev)
2693 ret = video_register_device(&v4l2->vbi_dev, VFL_TYPE_VBI, 2706 ret = video_register_device(&v4l2->vbi_dev, VFL_TYPE_VBI,
2694 vbi_nr[dev->devno]); 2707 vbi_nr[dev->devno]);
2695 if (ret < 0) { 2708 if (ret < 0) {
2696 em28xx_errdev("unable to register vbi device\n"); 2709 dev_err(&dev->intf->dev,
2710 "unable to register vbi device\n");
2697 goto unregister_dev; 2711 goto unregister_dev;
2698 } 2712 }
2699 } 2713 }
@@ -2704,11 +2718,13 @@ static int em28xx_v4l2_init(struct em28xx *dev)
2704 ret = video_register_device(&v4l2->radio_dev, VFL_TYPE_RADIO, 2718 ret = video_register_device(&v4l2->radio_dev, VFL_TYPE_RADIO,
2705 radio_nr[dev->devno]); 2719 radio_nr[dev->devno]);
2706 if (ret < 0) { 2720 if (ret < 0) {
2707 em28xx_errdev("can't register radio device\n"); 2721 dev_err(&dev->intf->dev,
2722 "can't register radio device\n");
2708 goto unregister_dev; 2723 goto unregister_dev;
2709 } 2724 }
2710 em28xx_info("Registered radio device as %s\n", 2725 dev_info(&dev->intf->dev,
2711 video_device_node_name(&v4l2->radio_dev)); 2726 "Registered radio device as %s\n",
2727 video_device_node_name(&v4l2->radio_dev));
2712 } 2728 }
2713 2729
2714 /* Init entities at the Media Controller */ 2730 /* Init entities at the Media Controller */
@@ -2717,18 +2733,21 @@ static int em28xx_v4l2_init(struct em28xx *dev)
2717#ifdef CONFIG_MEDIA_CONTROLLER 2733#ifdef CONFIG_MEDIA_CONTROLLER
2718 ret = v4l2_mc_create_media_graph(dev->media_dev); 2734 ret = v4l2_mc_create_media_graph(dev->media_dev);
2719 if (ret) { 2735 if (ret) {
2720 em28xx_errdev("failed to create media graph\n"); 2736 dev_err(&dev->intf->dev,
2737 "failed to create media graph\n");
2721 em28xx_v4l2_media_release(dev); 2738 em28xx_v4l2_media_release(dev);
2722 goto unregister_dev; 2739 goto unregister_dev;
2723 } 2740 }
2724#endif 2741#endif
2725 2742
2726 em28xx_info("V4L2 video device registered as %s\n", 2743 dev_info(&dev->intf->dev,
2727 video_device_node_name(&v4l2->vdev)); 2744 "V4L2 video device registered as %s\n",
2745 video_device_node_name(&v4l2->vdev));
2728 2746
2729 if (video_is_registered(&v4l2->vbi_dev)) 2747 if (video_is_registered(&v4l2->vbi_dev))
2730 em28xx_info("V4L2 VBI device registered as %s\n", 2748 dev_info(&dev->intf->dev,
2731 video_device_node_name(&v4l2->vbi_dev)); 2749 "V4L2 VBI device registered as %s\n",
2750 video_device_node_name(&v4l2->vbi_dev));
2732 2751
2733 /* Save some power by putting tuner to sleep */ 2752 /* Save some power by putting tuner to sleep */
2734 v4l2_device_call_all(&v4l2->v4l2_dev, 0, core, s_power, 0); 2753 v4l2_device_call_all(&v4l2->v4l2_dev, 0, core, s_power, 0);
@@ -2736,7 +2755,8 @@ static int em28xx_v4l2_init(struct em28xx *dev)
2736 /* initialize videobuf2 stuff */ 2755 /* initialize videobuf2 stuff */
2737 em28xx_vb2_setup(dev); 2756 em28xx_vb2_setup(dev);
2738 2757
2739 em28xx_info("V4L2 extension successfully initialized\n"); 2758 dev_info(&dev->intf->dev,
2759 "V4L2 extension successfully initialized\n");
2740 2760
2741 kref_get(&dev->ref); 2761 kref_get(&dev->ref);
2742 2762
@@ -2745,18 +2765,21 @@ static int em28xx_v4l2_init(struct em28xx *dev)
2745 2765
2746unregister_dev: 2766unregister_dev:
2747 if (video_is_registered(&v4l2->radio_dev)) { 2767 if (video_is_registered(&v4l2->radio_dev)) {
2748 em28xx_info("V4L2 device %s deregistered\n", 2768 dev_info(&dev->intf->dev,
2749 video_device_node_name(&v4l2->radio_dev)); 2769 "V4L2 device %s deregistered\n",
2770 video_device_node_name(&v4l2->radio_dev));
2750 video_unregister_device(&v4l2->radio_dev); 2771 video_unregister_device(&v4l2->radio_dev);
2751 } 2772 }
2752 if (video_is_registered(&v4l2->vbi_dev)) { 2773 if (video_is_registered(&v4l2->vbi_dev)) {
2753 em28xx_info("V4L2 device %s deregistered\n", 2774 dev_info(&dev->intf->dev,
2754 video_device_node_name(&v4l2->vbi_dev)); 2775 "V4L2 device %s deregistered\n",
2776 video_device_node_name(&v4l2->vbi_dev));
2755 video_unregister_device(&v4l2->vbi_dev); 2777 video_unregister_device(&v4l2->vbi_dev);
2756 } 2778 }
2757 if (video_is_registered(&v4l2->vdev)) { 2779 if (video_is_registered(&v4l2->vdev)) {
2758 em28xx_info("V4L2 device %s deregistered\n", 2780 dev_info(&dev->intf->dev,
2759 video_device_node_name(&v4l2->vdev)); 2781 "V4L2 device %s deregistered\n",
2782 video_device_node_name(&v4l2->vdev));
2760 video_unregister_device(&v4l2->vdev); 2783 video_unregister_device(&v4l2->vdev);
2761 } 2784 }
2762 2785
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h
index d148463b22c1..ca59e2d4fccf 100644
--- a/drivers/media/usb/em28xx/em28xx.h
+++ b/drivers/media/usb/em28xx/em28xx.h
@@ -610,7 +610,6 @@ struct em28xx {
610 struct em28xx_IR *ir; 610 struct em28xx_IR *ir;
611 611
612 /* generic device properties */ 612 /* generic device properties */
613 char name[30]; /* name (including minor) of the device */
614 int model; /* index in the device_data struct */ 613 int model; /* index in the device_data struct */
615 int devno; /* marks the number of this device */ 614 int devno; /* marks the number of this device */
616 enum em28xx_chip_id chip_id; 615 enum em28xx_chip_id chip_id;
@@ -678,7 +677,7 @@ struct em28xx {
678 spinlock_t slock; 677 spinlock_t slock;
679 678
680 /* usb transfer */ 679 /* usb transfer */
681 struct usb_device *udev; /* the usb device */ 680 struct usb_interface *intf; /* the usb interface */
682 u8 ifnum; /* number of the assigned usb interface */ 681 u8 ifnum; /* number of the assigned usb interface */
683 u8 analog_ep_isoc; /* address of isoc endpoint for analog */ 682 u8 analog_ep_isoc; /* address of isoc endpoint for analog */
684 u8 analog_ep_bulk; /* address of bulk endpoint for analog */ 683 u8 analog_ep_bulk; /* address of bulk endpoint for analog */
@@ -797,20 +796,4 @@ void em28xx_free_device(struct kref *ref);
797int em28xx_detect_sensor(struct em28xx *dev); 796int em28xx_detect_sensor(struct em28xx *dev);
798int em28xx_init_camera(struct em28xx *dev); 797int em28xx_init_camera(struct em28xx *dev);
799 798
800/* printk macros */
801
802#define em28xx_err(fmt, arg...) do {\
803 printk(KERN_ERR fmt , ##arg); } while (0)
804
805#define em28xx_errdev(fmt, arg...) do {\
806 printk(KERN_ERR "%s: "fmt,\
807 dev->name , ##arg); } while (0)
808
809#define em28xx_info(fmt, arg...) do {\
810 printk(KERN_INFO "%s: "fmt,\
811 dev->name , ##arg); } while (0)
812#define em28xx_warn(fmt, arg...) do {\
813 printk(KERN_WARNING "%s: "fmt,\
814 dev->name , ##arg); } while (0)
815
816#endif 799#endif
diff --git a/drivers/media/usb/go7007/Kconfig b/drivers/media/usb/go7007/Kconfig
index 95a3af644a92..af1d02430931 100644
--- a/drivers/media/usb/go7007/Kconfig
+++ b/drivers/media/usb/go7007/Kconfig
@@ -11,7 +11,7 @@ config VIDEO_GO7007
11 select VIDEO_TW2804 if MEDIA_SUBDRV_AUTOSELECT 11 select VIDEO_TW2804 if MEDIA_SUBDRV_AUTOSELECT
12 select VIDEO_TW9903 if MEDIA_SUBDRV_AUTOSELECT 12 select VIDEO_TW9903 if MEDIA_SUBDRV_AUTOSELECT
13 select VIDEO_TW9906 if MEDIA_SUBDRV_AUTOSELECT 13 select VIDEO_TW9906 if MEDIA_SUBDRV_AUTOSELECT
14 select VIDEO_OV7640 if MEDIA_SUBDRV_AUTOSELECT 14 select VIDEO_OV7640 if MEDIA_SUBDRV_AUTOSELECT && MEDIA_CAMERA_SUPPORT
15 select VIDEO_UDA1342 if MEDIA_SUBDRV_AUTOSELECT 15 select VIDEO_UDA1342 if MEDIA_SUBDRV_AUTOSELECT
16 ---help--- 16 ---help---
17 This is a video4linux driver for the WIS GO7007 MPEG 17 This is a video4linux driver for the WIS GO7007 MPEG
diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index af2395a76d8b..fa2cbb981905 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -201,8 +201,7 @@ static int alloc_and_submit_int_urb(struct gspca_dev *gspca_dev,
201 201
202 buffer_len = le16_to_cpu(ep->wMaxPacketSize); 202 buffer_len = le16_to_cpu(ep->wMaxPacketSize);
203 interval = ep->bInterval; 203 interval = ep->bInterval;
204 PDEBUG(D_CONF, "found int in endpoint: 0x%x, " 204 PDEBUG(D_CONF, "found int in endpoint: 0x%x, buffer_len=%u, interval=%u",
205 "buffer_len=%u, interval=%u",
206 ep->bEndpointAddress, buffer_len, interval); 205 ep->bEndpointAddress, buffer_len, interval);
207 206
208 dev = gspca_dev->dev; 207 dev = gspca_dev->dev;
diff --git a/drivers/media/usb/gspca/jl2005bcd.c b/drivers/media/usb/gspca/jl2005bcd.c
index ac295f04bd18..b12ecb72df4c 100644
--- a/drivers/media/usb/gspca/jl2005bcd.c
+++ b/drivers/media/usb/gspca/jl2005bcd.c
@@ -299,10 +299,7 @@ static int jl2005c_stream_start_cif_small(struct gspca_dev *gspca_dev)
299 299
300static int jl2005c_stop(struct gspca_dev *gspca_dev) 300static int jl2005c_stop(struct gspca_dev *gspca_dev)
301{ 301{
302 int retval; 302 return jl2005c_write_reg(gspca_dev, 0x07, 0x00);
303
304 retval = jl2005c_write_reg(gspca_dev, 0x07, 0x00);
305 return retval;
306} 303}
307 304
308/* 305/*
diff --git a/drivers/media/usb/gspca/m5602/m5602_core.c b/drivers/media/usb/gspca/m5602/m5602_core.c
index e4a0658e3f83..f1dcd9021983 100644
--- a/drivers/media/usb/gspca/m5602/m5602_core.c
+++ b/drivers/media/usb/gspca/m5602/m5602_core.c
@@ -154,8 +154,8 @@ int m5602_read_sensor(struct sd *sd, const u8 address,
154 154
155 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 155 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i]));
156 156
157 PDEBUG(D_CONF, "Reading sensor register " 157 PDEBUG(D_CONF, "Reading sensor register 0x%x containing 0x%x ",
158 "0x%x containing 0x%x ", address, *i2c_data); 158 address, *i2c_data);
159 } 159 }
160 return err; 160 return err;
161} 161}
@@ -441,13 +441,10 @@ MODULE_DESCRIPTION(DRIVER_DESC);
441MODULE_LICENSE("GPL"); 441MODULE_LICENSE("GPL");
442module_param(force_sensor, int, S_IRUGO | S_IWUSR); 442module_param(force_sensor, int, S_IRUGO | S_IWUSR);
443MODULE_PARM_DESC(force_sensor, 443MODULE_PARM_DESC(force_sensor,
444 "forces detection of a sensor, " 444 "forces detection of a sensor, 1 = OV9650, 2 = S5K83A, 3 = S5K4AA, 4 = MT9M111, 5 = PO1030, 6 = OV7660");
445 "1 = OV9650, 2 = S5K83A, 3 = S5K4AA, "
446 "4 = MT9M111, 5 = PO1030, 6 = OV7660");
447 445
448module_param(dump_bridge, bool, S_IRUGO | S_IWUSR); 446module_param(dump_bridge, bool, S_IRUGO | S_IWUSR);
449MODULE_PARM_DESC(dump_bridge, "Dumps all usb bridge registers at startup"); 447MODULE_PARM_DESC(dump_bridge, "Dumps all usb bridge registers at startup");
450 448
451module_param(dump_sensor, bool, S_IRUGO | S_IWUSR); 449module_param(dump_sensor, bool, S_IRUGO | S_IWUSR);
452MODULE_PARM_DESC(dump_sensor, "Dumps all usb sensor registers " 450MODULE_PARM_DESC(dump_sensor, "Dumps all usb sensor registers at startup providing a sensor is found");
453 "at startup providing a sensor is found");
diff --git a/drivers/media/usb/gspca/mr97310a.c b/drivers/media/usb/gspca/mr97310a.c
index f006e29ca019..6dfb364094ec 100644
--- a/drivers/media/usb/gspca/mr97310a.c
+++ b/drivers/media/usb/gspca/mr97310a.c
@@ -72,8 +72,7 @@
72#define MR97310A_MIN_CLOCKDIV_MAX 8 72#define MR97310A_MIN_CLOCKDIV_MAX 8
73#define MR97310A_MIN_CLOCKDIV_DEFAULT 3 73#define MR97310A_MIN_CLOCKDIV_DEFAULT 3
74 74
75MODULE_AUTHOR("Kyle Guinn <elyk03@gmail.com>," 75MODULE_AUTHOR("Kyle Guinn <elyk03@gmail.com>,Theodore Kilgore <kilgota@auburn.edu>");
76 "Theodore Kilgore <kilgota@auburn.edu>");
77MODULE_DESCRIPTION("GSPCA/Mars-Semi MR97310A USB Camera Driver"); 76MODULE_DESCRIPTION("GSPCA/Mars-Semi MR97310A USB Camera Driver");
78MODULE_LICENSE("GPL"); 77MODULE_LICENSE("GPL");
79 78
diff --git a/drivers/media/usb/gspca/ov519.c b/drivers/media/usb/gspca/ov519.c
index 965372a5ff2f..4dbca54cf2a8 100644
--- a/drivers/media/usb/gspca/ov519.c
+++ b/drivers/media/usb/gspca/ov519.c
@@ -4326,8 +4326,7 @@ static void ov511_pkt_scan(struct gspca_dev *gspca_dev,
4326 /* Frame end */ 4326 /* Frame end */
4327 if ((in[9] + 1) * 8 != gspca_dev->pixfmt.width || 4327 if ((in[9] + 1) * 8 != gspca_dev->pixfmt.width ||
4328 (in[10] + 1) * 8 != gspca_dev->pixfmt.height) { 4328 (in[10] + 1) * 8 != gspca_dev->pixfmt.height) {
4329 PERR("Invalid frame size, got: %dx%d," 4329 PERR("Invalid frame size, got: %dx%d, requested: %dx%d\n",
4330 " requested: %dx%d\n",
4331 (in[9] + 1) * 8, (in[10] + 1) * 8, 4330 (in[9] + 1) * 8, (in[10] + 1) * 8,
4332 gspca_dev->pixfmt.width, 4331 gspca_dev->pixfmt.width,
4333 gspca_dev->pixfmt.height); 4332 gspca_dev->pixfmt.height);
diff --git a/drivers/media/usb/gspca/pac207.c b/drivers/media/usb/gspca/pac207.c
index 07529e5a0c56..51e11248bbb8 100644
--- a/drivers/media/usb/gspca/pac207.c
+++ b/drivers/media/usb/gspca/pac207.c
@@ -179,8 +179,8 @@ static int sd_config(struct gspca_dev *gspca_dev,
179 } 179 }
180 180
181 PDEBUG(D_PROBE, 181 PDEBUG(D_PROBE,
182 "Pixart PAC207BCA Image Processor and Control Chip detected" 182 "Pixart PAC207BCA Image Processor and Control Chip detected (vid/pid 0x%04X:0x%04X)",
183 " (vid/pid 0x%04X:0x%04X)", id->idVendor, id->idProduct); 183 id->idVendor, id->idProduct);
184 184
185 cam = &gspca_dev->cam; 185 cam = &gspca_dev->cam;
186 cam->cam_mode = sif_mode; 186 cam->cam_mode = sif_mode;
diff --git a/drivers/media/usb/gspca/pac7302.c b/drivers/media/usb/gspca/pac7302.c
index 8b08bd0172f4..be07a24c4518 100644
--- a/drivers/media/usb/gspca/pac7302.c
+++ b/drivers/media/usb/gspca/pac7302.c
@@ -105,8 +105,7 @@
105#define PAC7302_EXPOSURE_DEFAULT 66 /* 33 ms / 30 fps */ 105#define PAC7302_EXPOSURE_DEFAULT 66 /* 33 ms / 30 fps */
106#define PAC7302_EXPOSURE_KNEE 133 /* 66 ms / 15 fps */ 106#define PAC7302_EXPOSURE_KNEE 133 /* 66 ms / 15 fps */
107 107
108MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>, " 108MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>, Thomas Kaiser thomas@kaiser-linux.li");
109 "Thomas Kaiser thomas@kaiser-linux.li");
110MODULE_DESCRIPTION("Pixart PAC7302"); 109MODULE_DESCRIPTION("Pixart PAC7302");
111MODULE_LICENSE("GPL"); 110MODULE_LICENSE("GPL");
112 111
diff --git a/drivers/media/usb/gspca/sn9c20x.c b/drivers/media/usb/gspca/sn9c20x.c
index 10269dad9d20..e7430b06526a 100644
--- a/drivers/media/usb/gspca/sn9c20x.c
+++ b/drivers/media/usb/gspca/sn9c20x.c
@@ -29,8 +29,7 @@
29 29
30#include <linux/dmi.h> 30#include <linux/dmi.h>
31 31
32MODULE_AUTHOR("Brian Johnson <brijohn@gmail.com>, " 32MODULE_AUTHOR("Brian Johnson <brijohn@gmail.com>, microdia project <microdia@googlegroups.com>");
33 "microdia project <microdia@googlegroups.com>");
34MODULE_DESCRIPTION("GSPCA/SN9C20X USB Camera Driver"); 33MODULE_DESCRIPTION("GSPCA/SN9C20X USB Camera Driver");
35MODULE_LICENSE("GPL"); 34MODULE_LICENSE("GPL");
36 35
@@ -1948,8 +1947,7 @@ static int sd_isoc_init(struct gspca_dev *gspca_dev)
1948 intf = usb_ifnum_to_if(gspca_dev->dev, gspca_dev->iface); 1947 intf = usb_ifnum_to_if(gspca_dev->dev, gspca_dev->iface);
1949 1948
1950 if (intf->num_altsetting != 9) { 1949 if (intf->num_altsetting != 9) {
1951 pr_warn("sn9c20x camera with unknown number of alt " 1950 pr_warn("sn9c20x camera with unknown number of alt settings (%d), please report!\n",
1952 "settings (%d), please report!\n",
1953 intf->num_altsetting); 1951 intf->num_altsetting);
1954 gspca_dev->alt = intf->num_altsetting; 1952 gspca_dev->alt = intf->num_altsetting;
1955 return 0; 1953 return 0;
diff --git a/drivers/media/usb/gspca/spca506.c b/drivers/media/usb/gspca/spca506.c
index bcd2c04c770e..ee84863d27d4 100644
--- a/drivers/media/usb/gspca/spca506.c
+++ b/drivers/media/usb/gspca/spca506.c
@@ -581,8 +581,7 @@ static const struct sd_desc sd_desc = {
581/* -- module initialisation -- */ 581/* -- module initialisation -- */
582static const struct usb_device_id device_table[] = { 582static const struct usb_device_id device_table[] = {
583 {USB_DEVICE(0x06e1, 0xa190)}, 583 {USB_DEVICE(0x06e1, 0xa190)},
584/*fixme: may be IntelPCCameraPro BRIDGE_SPCA505 584/* {USB_DEVICE(0x0733, 0x0430)}, FIXME: may be IntelPCCameraPro BRIDGE_SPCA505 */
585 {USB_DEVICE(0x0733, 0x0430)}, */
586 {USB_DEVICE(0x0734, 0x043b)}, 585 {USB_DEVICE(0x0734, 0x043b)},
587 {USB_DEVICE(0x99fa, 0x8988)}, 586 {USB_DEVICE(0x99fa, 0x8988)},
588 {} 587 {}
diff --git a/drivers/media/usb/gspca/sq905.c b/drivers/media/usb/gspca/sq905.c
index a7ae0ec9fa91..9424c33f0ddb 100644
--- a/drivers/media/usb/gspca/sq905.c
+++ b/drivers/media/usb/gspca/sq905.c
@@ -41,8 +41,7 @@
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include "gspca.h" 42#include "gspca.h"
43 43
44MODULE_AUTHOR("Adam Baker <linux@baker-net.org.uk>, " 44MODULE_AUTHOR("Adam Baker <linux@baker-net.org.uk>, Theodore Kilgore <kilgota@auburn.edu>");
45 "Theodore Kilgore <kilgota@auburn.edu>");
46MODULE_DESCRIPTION("GSPCA/SQ905 USB Camera Driver"); 45MODULE_DESCRIPTION("GSPCA/SQ905 USB Camera Driver");
47MODULE_LICENSE("GPL"); 46MODULE_LICENSE("GPL");
48 47
diff --git a/drivers/media/usb/gspca/sq905c.c b/drivers/media/usb/gspca/sq905c.c
index aa21edc9502d..6c45dcc44eb0 100644
--- a/drivers/media/usb/gspca/sq905c.c
+++ b/drivers/media/usb/gspca/sq905c.c
@@ -210,8 +210,8 @@ static int sd_config(struct gspca_dev *gspca_dev,
210 int ret; 210 int ret;
211 211
212 PDEBUG(D_PROBE, 212 PDEBUG(D_PROBE,
213 "SQ9050 camera detected" 213 "SQ9050 camera detected (vid/pid 0x%04X:0x%04X)",
214 " (vid/pid 0x%04X:0x%04X)", id->idVendor, id->idProduct); 214 id->idVendor, id->idProduct);
215 215
216 ret = sq905c_command(gspca_dev, SQ905C_GET_ID, 0); 216 ret = sq905c_command(gspca_dev, SQ905C_GET_ID, 0);
217 if (ret < 0) { 217 if (ret < 0) {
@@ -257,11 +257,8 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
257/* this function is called at probe and resume time */ 257/* this function is called at probe and resume time */
258static int sd_init(struct gspca_dev *gspca_dev) 258static int sd_init(struct gspca_dev *gspca_dev)
259{ 259{
260 int ret;
261
262 /* connect to the camera and reset it. */ 260 /* connect to the camera and reset it. */
263 ret = sq905c_command(gspca_dev, SQ905C_CLEAR, 0); 261 return sq905c_command(gspca_dev, SQ905C_CLEAR, 0);
264 return ret;
265} 262}
266 263
267/* Set up for getting frames. */ 264/* Set up for getting frames. */
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx.c b/drivers/media/usb/gspca/stv06xx/stv06xx.c
index 6ac93d8db427..fef7a784b879 100644
--- a/drivers/media/usb/gspca/stv06xx/stv06xx.c
+++ b/drivers/media/usb/gspca/stv06xx/stv06xx.c
@@ -412,8 +412,7 @@ static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev,
412 len -= 4; 412 len -= 4;
413 413
414 if (len < chunk_len) { 414 if (len < chunk_len) {
415 PERR("URB packet length is smaller" 415 PERR("URB packet length is smaller than the specified chunk length");
416 " than the specified chunk length");
417 gspca_dev->last_packet_type = DISCARD_PACKET; 416 gspca_dev->last_packet_type = DISCARD_PACKET;
418 return; 417 return;
419 } 418 }
@@ -455,8 +454,7 @@ frame_data:
455 sd->to_skip = gspca_dev->pixfmt.width * 4; 454 sd->to_skip = gspca_dev->pixfmt.width * 4;
456 455
457 if (chunk_len) 456 if (chunk_len)
458 PERR("Chunk length is " 457 PERR("Chunk length is non-zero on a SOF");
459 "non-zero on a SOF");
460 break; 458 break;
461 459
462 case 0x8002: 460 case 0x8002:
@@ -469,8 +467,7 @@ frame_data:
469 NULL, 0); 467 NULL, 0);
470 468
471 if (chunk_len) 469 if (chunk_len)
472 PERR("Chunk length is " 470 PERR("Chunk length is non-zero on a EOF");
473 "non-zero on a EOF");
474 break; 471 break;
475 472
476 case 0x0005: 473 case 0x0005:
@@ -582,18 +579,12 @@ static int stv06xx_config(struct gspca_dev *gspca_dev,
582 579
583/* -- module initialisation -- */ 580/* -- module initialisation -- */
584static const struct usb_device_id device_table[] = { 581static const struct usb_device_id device_table[] = {
585 /* QuickCam Express */ 582 {USB_DEVICE(0x046d, 0x0840), .driver_info = BRIDGE_STV600 }, /* QuickCam Express */
586 {USB_DEVICE(0x046d, 0x0840), .driver_info = BRIDGE_STV600 }, 583 {USB_DEVICE(0x046d, 0x0850), .driver_info = BRIDGE_STV610 }, /* LEGO cam / QuickCam Web */
587 /* LEGO cam / QuickCam Web */ 584 {USB_DEVICE(0x046d, 0x0870), .driver_info = BRIDGE_STV602 }, /* Dexxa WebCam USB */
588 {USB_DEVICE(0x046d, 0x0850), .driver_info = BRIDGE_STV610 }, 585 {USB_DEVICE(0x046D, 0x08F0), .driver_info = BRIDGE_ST6422 }, /* QuickCam Messenger */
589 /* Dexxa WebCam USB */ 586 {USB_DEVICE(0x046D, 0x08F5), .driver_info = BRIDGE_ST6422 }, /* QuickCam Communicate */
590 {USB_DEVICE(0x046d, 0x0870), .driver_info = BRIDGE_STV602 }, 587 {USB_DEVICE(0x046D, 0x08F6), .driver_info = BRIDGE_ST6422 }, /* QuickCam Messenger (new) */
591 /* QuickCam Messenger */
592 {USB_DEVICE(0x046D, 0x08F0), .driver_info = BRIDGE_ST6422 },
593 /* QuickCam Communicate */
594 {USB_DEVICE(0x046D, 0x08F5), .driver_info = BRIDGE_ST6422 },
595 /* QuickCam Messenger (new) */
596 {USB_DEVICE(0x046D, 0x08F6), .driver_info = BRIDGE_ST6422 },
597 {} 588 {}
598}; 589};
599MODULE_DEVICE_TABLE(usb, device_table); 590MODULE_DEVICE_TABLE(usb, device_table);
diff --git a/drivers/media/usb/gspca/sunplus.c b/drivers/media/usb/gspca/sunplus.c
index 46c9f2229a18..38dc9e7aa313 100644
--- a/drivers/media/usb/gspca/sunplus.c
+++ b/drivers/media/usb/gspca/sunplus.c
@@ -368,8 +368,7 @@ static void spca504_read_info(struct gspca_dev *gspca_dev)
368 info[i] = gspca_dev->usb_buf[0]; 368 info[i] = gspca_dev->usb_buf[0];
369 } 369 }
370 PDEBUG(D_STREAM, 370 PDEBUG(D_STREAM,
371 "Read info: %d %d %d %d %d %d." 371 "Read info: %d %d %d %d %d %d. Should be 1,0,2,2,0,0",
372 " Should be 1,0,2,2,0,0",
373 info[0], info[1], info[2], 372 info[0], info[1], info[2],
374 info[3], info[4], info[5]); 373 info[3], info[4], info[5]);
375} 374}
diff --git a/drivers/media/usb/gspca/topro.c b/drivers/media/usb/gspca/topro.c
index 15eb069ab60b..983fc6b500af 100644
--- a/drivers/media/usb/gspca/topro.c
+++ b/drivers/media/usb/gspca/topro.c
@@ -24,8 +24,7 @@
24#include "gspca.h" 24#include "gspca.h"
25 25
26MODULE_DESCRIPTION("Topro TP6800/6810 gspca webcam driver"); 26MODULE_DESCRIPTION("Topro TP6800/6810 gspca webcam driver");
27MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>, " 27MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>, Anders Blomdell <anders.blomdell@control.lth.se>");
28 "Anders Blomdell <anders.blomdell@control.lth.se>");
29MODULE_LICENSE("GPL"); 28MODULE_LICENSE("GPL");
30 29
31static int force_sensor = -1; 30static int force_sensor = -1;
diff --git a/drivers/media/usb/gspca/zc3xx.c b/drivers/media/usb/gspca/zc3xx.c
index 5f7254d2bc9a..d5d8c7e81762 100644
--- a/drivers/media/usb/gspca/zc3xx.c
+++ b/drivers/media/usb/gspca/zc3xx.c
@@ -25,8 +25,7 @@
25#include "gspca.h" 25#include "gspca.h"
26#include "jpeg.h" 26#include "jpeg.h"
27 27
28MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>, " 28MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>, Serge A. Suchkov <Serge.A.S@tochka.ru>");
29 "Serge A. Suchkov <Serge.A.S@tochka.ru>");
30MODULE_DESCRIPTION("GSPCA ZC03xx/VC3xx USB Camera Driver"); 29MODULE_DESCRIPTION("GSPCA ZC03xx/VC3xx USB Camera Driver");
31MODULE_LICENSE("GPL"); 30MODULE_LICENSE("GPL");
32 31
diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c b/drivers/media/usb/hdpvr/hdpvr-core.c
index a61d8fd63c12..15f016ad5b89 100644
--- a/drivers/media/usb/hdpvr/hdpvr-core.c
+++ b/drivers/media/usb/hdpvr/hdpvr-core.c
@@ -41,13 +41,11 @@ MODULE_PARM_DESC(hdpvr_debug, "enable debugging output");
41 41
42static uint default_video_input = HDPVR_VIDEO_INPUTS; 42static uint default_video_input = HDPVR_VIDEO_INPUTS;
43module_param(default_video_input, uint, S_IRUGO|S_IWUSR); 43module_param(default_video_input, uint, S_IRUGO|S_IWUSR);
44MODULE_PARM_DESC(default_video_input, "default video input: 0=Component / " 44MODULE_PARM_DESC(default_video_input, "default video input: 0=Component / 1=S-Video / 2=Composite");
45 "1=S-Video / 2=Composite");
46 45
47static uint default_audio_input = HDPVR_AUDIO_INPUTS; 46static uint default_audio_input = HDPVR_AUDIO_INPUTS;
48module_param(default_audio_input, uint, S_IRUGO|S_IWUSR); 47module_param(default_audio_input, uint, S_IRUGO|S_IWUSR);
49MODULE_PARM_DESC(default_audio_input, "default audio input: 0=RCA back / " 48MODULE_PARM_DESC(default_audio_input, "default audio input: 0=RCA back / 1=RCA front / 2=S/PDIF");
50 "1=RCA front / 2=S/PDIF");
51 49
52static bool boost_audio; 50static bool boost_audio;
53module_param(boost_audio, bool, S_IRUGO|S_IWUSR); 51module_param(boost_audio, bool, S_IRUGO|S_IWUSR);
@@ -165,8 +163,7 @@ static int device_authorization(struct hdpvr_device *dev)
165 dev->flags |= HDPVR_FLAG_AC3_CAP; 163 dev->flags |= HDPVR_FLAG_AC3_CAP;
166 break; 164 break;
167 default: 165 default:
168 v4l2_info(&dev->v4l2_dev, "untested firmware, the driver might" 166 v4l2_info(&dev->v4l2_dev, "untested firmware, the driver might not work.\n");
169 " not work.\n");
170 if (dev->fw_ver >= HDPVR_FIRMWARE_VERSION_AC3) 167 if (dev->fw_ver >= HDPVR_FIRMWARE_VERSION_AC3)
171 dev->flags |= HDPVR_FLAG_AC3_CAP; 168 dev->flags |= HDPVR_FLAG_AC3_CAP;
172 else 169 else
diff --git a/drivers/media/usb/hdpvr/hdpvr-i2c.c b/drivers/media/usb/hdpvr/hdpvr-i2c.c
index 9b641c4d4431..fcab55038d99 100644
--- a/drivers/media/usb/hdpvr/hdpvr-i2c.c
+++ b/drivers/media/usb/hdpvr/hdpvr-i2c.c
@@ -145,15 +145,14 @@ static int hdpvr_transfer(struct i2c_adapter *i2c_adapter, struct i2c_msg *msgs,
145 msgs[0].len); 145 msgs[0].len);
146 } else if (num == 2) { 146 } else if (num == 2) {
147 if (msgs[0].addr != msgs[1].addr) { 147 if (msgs[0].addr != msgs[1].addr) {
148 v4l2_warn(&dev->v4l2_dev, "refusing 2-phase i2c xfer " 148 v4l2_warn(&dev->v4l2_dev, "refusing 2-phase i2c xfer with conflicting target addresses\n");
149 "with conflicting target addresses\n");
150 retval = -EINVAL; 149 retval = -EINVAL;
151 goto out; 150 goto out;
152 } 151 }
153 152
154 if ((msgs[0].flags & I2C_M_RD) || !(msgs[1].flags & I2C_M_RD)) { 153 if ((msgs[0].flags & I2C_M_RD) || !(msgs[1].flags & I2C_M_RD)) {
155 v4l2_warn(&dev->v4l2_dev, "refusing complex xfer with " 154 v4l2_warn(&dev->v4l2_dev, "refusing complex xfer with r0=%d, r1=%d\n",
156 "r0=%d, r1=%d\n", msgs[0].flags & I2C_M_RD, 155 msgs[0].flags & I2C_M_RD,
157 msgs[1].flags & I2C_M_RD); 156 msgs[1].flags & I2C_M_RD);
158 retval = -EINVAL; 157 retval = -EINVAL;
159 goto out; 158 goto out;
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
index 474c11e1d495..7fb036d6a86e 100644
--- a/drivers/media/usb/hdpvr/hdpvr-video.c
+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
@@ -336,9 +336,7 @@ static int hdpvr_stop_streaming(struct hdpvr_device *dev)
336 336
337 buf = kmalloc(dev->bulk_in_size, GFP_KERNEL); 337 buf = kmalloc(dev->bulk_in_size, GFP_KERNEL);
338 if (!buf) 338 if (!buf)
339 v4l2_err(&dev->v4l2_dev, "failed to allocate temporary buffer " 339 v4l2_err(&dev->v4l2_dev, "failed to allocate temporary buffer for emptying the internal device buffer. Next capture start will be slow\n");
340 "for emptying the internal device buffer. "
341 "Next capture start will be slow\n");
342 340
343 dev->status = STATUS_SHUTTING_DOWN; 341 dev->status = STATUS_SHUTTING_DOWN;
344 hdpvr_config_call(dev, CTRL_STOP_STREAMING_VALUE, 0x00); 342 hdpvr_config_call(dev, CTRL_STOP_STREAMING_VALUE, 0x00);
@@ -451,6 +449,7 @@ static ssize_t hdpvr_read(struct file *file, char __user *buffer, size_t count,
451 449
452 if (buf->status != BUFSTAT_READY && 450 if (buf->status != BUFSTAT_READY &&
453 dev->status != STATUS_DISCONNECTED) { 451 dev->status != STATUS_DISCONNECTED) {
452 int err;
454 /* return nonblocking */ 453 /* return nonblocking */
455 if (file->f_flags & O_NONBLOCK) { 454 if (file->f_flags & O_NONBLOCK) {
456 if (!ret) 455 if (!ret)
@@ -458,9 +457,24 @@ static ssize_t hdpvr_read(struct file *file, char __user *buffer, size_t count,
458 goto err; 457 goto err;
459 } 458 }
460 459
461 if (wait_event_interruptible(dev->wait_data, 460 err = wait_event_interruptible_timeout(dev->wait_data,
462 buf->status == BUFSTAT_READY)) 461 buf->status == BUFSTAT_READY,
463 return -ERESTARTSYS; 462 msecs_to_jiffies(1000));
463 if (err < 0) {
464 ret = err;
465 goto err;
466 }
467 if (!err) {
468 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev,
469 "timeout: restart streaming\n");
470 hdpvr_stop_streaming(dev);
471 msecs_to_jiffies(4000);
472 err = hdpvr_start_streaming(dev);
473 if (err) {
474 ret = err;
475 goto err;
476 }
477 }
464 } 478 }
465 479
466 if (buf->status != BUFSTAT_READY) 480 if (buf->status != BUFSTAT_READY)
diff --git a/drivers/staging/media/pulse8-cec/Kconfig b/drivers/media/usb/pulse8-cec/Kconfig
index c6aa2d1c9df0..6ffc407de62f 100644
--- a/drivers/staging/media/pulse8-cec/Kconfig
+++ b/drivers/media/usb/pulse8-cec/Kconfig
@@ -1,6 +1,6 @@
1config USB_PULSE8_CEC 1config USB_PULSE8_CEC
2 tristate "Pulse Eight HDMI CEC" 2 tristate "Pulse Eight HDMI CEC"
3 depends on USB_ACM && MEDIA_CEC 3 depends on USB_ACM && MEDIA_CEC_SUPPORT
4 select SERIO 4 select SERIO
5 select SERIO_SERPORT 5 select SERIO_SERPORT
6 ---help--- 6 ---help---
diff --git a/drivers/staging/media/pulse8-cec/Makefile b/drivers/media/usb/pulse8-cec/Makefile
index 9800690bc25a..9800690bc25a 100644
--- a/drivers/staging/media/pulse8-cec/Makefile
+++ b/drivers/media/usb/pulse8-cec/Makefile
diff --git a/drivers/staging/media/pulse8-cec/pulse8-cec.c b/drivers/media/usb/pulse8-cec/pulse8-cec.c
index 1732c3857b8e..7c18daeb0ade 100644
--- a/drivers/staging/media/pulse8-cec/pulse8-cec.c
+++ b/drivers/media/usb/pulse8-cec/pulse8-cec.c
@@ -375,27 +375,35 @@ static int pulse8_setup(struct pulse8 *pulse8, struct serio *serio,
375 switch (log_addrs->primary_device_type[0]) { 375 switch (log_addrs->primary_device_type[0]) {
376 case CEC_OP_PRIM_DEVTYPE_TV: 376 case CEC_OP_PRIM_DEVTYPE_TV:
377 log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_TV; 377 log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_TV;
378 log_addrs->all_device_types[0] = CEC_OP_ALL_DEVTYPE_TV;
378 break; 379 break;
379 case CEC_OP_PRIM_DEVTYPE_RECORD: 380 case CEC_OP_PRIM_DEVTYPE_RECORD:
380 log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_RECORD; 381 log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_RECORD;
382 log_addrs->all_device_types[0] = CEC_OP_ALL_DEVTYPE_RECORD;
381 break; 383 break;
382 case CEC_OP_PRIM_DEVTYPE_TUNER: 384 case CEC_OP_PRIM_DEVTYPE_TUNER:
383 log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_TUNER; 385 log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_TUNER;
386 log_addrs->all_device_types[0] = CEC_OP_ALL_DEVTYPE_TUNER;
384 break; 387 break;
385 case CEC_OP_PRIM_DEVTYPE_PLAYBACK: 388 case CEC_OP_PRIM_DEVTYPE_PLAYBACK:
386 log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_PLAYBACK; 389 log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_PLAYBACK;
390 log_addrs->all_device_types[0] = CEC_OP_ALL_DEVTYPE_PLAYBACK;
387 break; 391 break;
388 case CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM: 392 case CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM:
389 log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_PLAYBACK; 393 log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_PLAYBACK;
394 log_addrs->all_device_types[0] = CEC_OP_ALL_DEVTYPE_AUDIOSYSTEM;
390 break; 395 break;
391 case CEC_OP_PRIM_DEVTYPE_SWITCH: 396 case CEC_OP_PRIM_DEVTYPE_SWITCH:
392 log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_UNREGISTERED; 397 log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_UNREGISTERED;
398 log_addrs->all_device_types[0] = CEC_OP_ALL_DEVTYPE_SWITCH;
393 break; 399 break;
394 case CEC_OP_PRIM_DEVTYPE_PROCESSOR: 400 case CEC_OP_PRIM_DEVTYPE_PROCESSOR:
395 log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_SPECIFIC; 401 log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_SPECIFIC;
402 log_addrs->all_device_types[0] = CEC_OP_ALL_DEVTYPE_SWITCH;
396 break; 403 break;
397 default: 404 default:
398 log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_UNREGISTERED; 405 log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_UNREGISTERED;
406 log_addrs->all_device_types[0] = CEC_OP_ALL_DEVTYPE_SWITCH;
399 dev_info(pulse8->dev, "Unknown Primary Device Type: %d\n", 407 dev_info(pulse8->dev, "Unknown Primary Device Type: %d\n",
400 log_addrs->primary_device_type[0]); 408 log_addrs->primary_device_type[0]);
401 break; 409 break;
@@ -651,7 +659,7 @@ static int pulse8_connect(struct serio *serio, struct serio_driver *drv)
651 659
652 pulse8->serio = serio; 660 pulse8->serio = serio;
653 pulse8->adap = cec_allocate_adapter(&pulse8_cec_adap_ops, pulse8, 661 pulse8->adap = cec_allocate_adapter(&pulse8_cec_adap_ops, pulse8,
654 "HDMI CEC", caps, 1, &serio->dev); 662 "HDMI CEC", caps, 1);
655 err = PTR_ERR_OR_ZERO(pulse8->adap); 663 err = PTR_ERR_OR_ZERO(pulse8->adap);
656 if (err < 0) 664 if (err < 0)
657 goto free_device; 665 goto free_device;
@@ -671,7 +679,7 @@ static int pulse8_connect(struct serio *serio, struct serio_driver *drv)
671 if (err) 679 if (err)
672 goto close_serio; 680 goto close_serio;
673 681
674 err = cec_register_adapter(pulse8->adap); 682 err = cec_register_adapter(pulse8->adap, &serio->dev);
675 if (err < 0) 683 if (err < 0)
676 goto close_serio; 684 goto close_serio;
677 685
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-audio.c b/drivers/media/usb/pvrusb2/pvrusb2-audio.c
index 5f953d837bf1..3bac50a248d4 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-audio.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-audio.c
@@ -74,9 +74,7 @@ void pvr2_msp3400_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
74 input = sp->def[hdw->input_val]; 74 input = sp->def[hdw->input_val];
75 } else { 75 } else {
76 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 76 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
77 "*** WARNING *** subdev msp3400 set_input:" 77 "*** WARNING *** subdev msp3400 set_input: Invalid routing scheme (%u) and/or input (%d)",
78 " Invalid routing scheme (%u)"
79 " and/or input (%d)",
80 sid, hdw->input_val); 78 sid, hdw->input_val);
81 return; 79 return;
82 } 80 }
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-cs53l32a.c b/drivers/media/usb/pvrusb2/pvrusb2-cs53l32a.c
index f82f0f0f2c04..7f29a0464f36 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-cs53l32a.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-cs53l32a.c
@@ -72,9 +72,7 @@ void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
72 (hdw->input_val < 0) || 72 (hdw->input_val < 0) ||
73 (hdw->input_val >= sp->cnt)) { 73 (hdw->input_val >= sp->cnt)) {
74 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 74 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
75 "*** WARNING *** subdev v4l2 set_input:" 75 "*** WARNING *** subdev v4l2 set_input: Invalid routing scheme (%u) and/or input (%d)",
76 " Invalid routing scheme (%u)"
77 " and/or input (%d)",
78 sid, hdw->input_val); 76 sid, hdw->input_val);
79 return; 77 return;
80 } 78 }
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-cx2584x-v4l.c b/drivers/media/usb/pvrusb2/pvrusb2-cx2584x-v4l.c
index 7d675fae1846..30eef97ef2ef 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-cx2584x-v4l.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-cx2584x-v4l.c
@@ -137,9 +137,7 @@ void pvr2_cx25840_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
137 (hdw->input_val < 0) || 137 (hdw->input_val < 0) ||
138 (hdw->input_val >= sp->cnt)) { 138 (hdw->input_val >= sp->cnt)) {
139 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 139 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
140 "*** WARNING *** subdev cx2584x set_input:" 140 "*** WARNING *** subdev cx2584x set_input: Invalid routing scheme (%u) and/or input (%d)",
141 " Invalid routing scheme (%u)"
142 " and/or input (%d)",
143 sid, hdw->input_val); 141 sid, hdw->input_val);
144 return; 142 return;
145 } 143 }
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-debugifc.c b/drivers/media/usb/pvrusb2/pvrusb2-debugifc.c
index e4022bcb155b..58ec706ebdb3 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-debugifc.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-debugifc.c
@@ -176,9 +176,7 @@ int pvr2_debugifc_print_status(struct pvr2_hdw *hdw,
176 pvr2_stream_get_stats(sp, &stats, 0); 176 pvr2_stream_get_stats(sp, &stats, 0);
177 ccnt = scnprintf( 177 ccnt = scnprintf(
178 buf,acnt, 178 buf,acnt,
179 "Bytes streamed=%u" 179 "Bytes streamed=%u URBs: queued=%u idle=%u ready=%u processed=%u failed=%u\n",
180 " URBs: queued=%u idle=%u ready=%u"
181 " processed=%u failed=%u\n",
182 stats.bytes_processed, 180 stats.bytes_processed,
183 stats.buffers_in_queue, 181 stats.buffers_in_queue,
184 stats.buffers_in_idle, 182 stats.buffers_in_idle,
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-eeprom.c b/drivers/media/usb/pvrusb2/pvrusb2-eeprom.c
index e1907cd0c3b7..276b17fb9aad 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-eeprom.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-eeprom.c
@@ -56,8 +56,7 @@ static u8 *pvr2_eeprom_fetch(struct pvr2_hdw *hdw)
56 eeprom = kmalloc(EEPROM_SIZE,GFP_KERNEL); 56 eeprom = kmalloc(EEPROM_SIZE,GFP_KERNEL);
57 if (!eeprom) { 57 if (!eeprom) {
58 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 58 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
59 "Failed to allocate memory" 59 "Failed to allocate memory required to read eeprom");
60 " required to read eeprom");
61 return NULL; 60 return NULL;
62 } 61 }
63 62
@@ -74,8 +73,8 @@ static u8 *pvr2_eeprom_fetch(struct pvr2_hdw *hdw)
74 strange but it's what they do) */ 73 strange but it's what they do) */
75 mode16 = (addr & 1); 74 mode16 = (addr & 1);
76 eepromSize = (mode16 ? 4096 : 256); 75 eepromSize = (mode16 ? 4096 : 256);
77 trace_eeprom("Examining %d byte eeprom at location 0x%x" 76 trace_eeprom("Examining %d byte eeprom at location 0x%x using %d bit addressing",
78 " using %d bit addressing",eepromSize,addr, 77 eepromSize, addr,
79 mode16 ? 16 : 8); 78 mode16 ? 16 : 8);
80 79
81 msg[0].addr = addr; 80 msg[0].addr = addr;
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-encoder.c b/drivers/media/usb/pvrusb2/pvrusb2-encoder.c
index 593b3e9b6bfd..f0483621d2a3 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-encoder.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-encoder.c
@@ -188,9 +188,7 @@ static int pvr2_encoder_cmd(void *ctxt,
188 if (arg_cnt_send > (ARRAY_SIZE(wrData) - 4)) { 188 if (arg_cnt_send > (ARRAY_SIZE(wrData) - 4)) {
189 pvr2_trace( 189 pvr2_trace(
190 PVR2_TRACE_ERROR_LEGS, 190 PVR2_TRACE_ERROR_LEGS,
191 "Failed to write cx23416 command" 191 "Failed to write cx23416 command - too many input arguments (was given %u limit %lu)",
192 " - too many input arguments"
193 " (was given %u limit %lu)",
194 arg_cnt_send, (long unsigned) ARRAY_SIZE(wrData) - 4); 192 arg_cnt_send, (long unsigned) ARRAY_SIZE(wrData) - 4);
195 return -EINVAL; 193 return -EINVAL;
196 } 194 }
@@ -198,9 +196,7 @@ static int pvr2_encoder_cmd(void *ctxt,
198 if (arg_cnt_recv > (ARRAY_SIZE(rdData) - 4)) { 196 if (arg_cnt_recv > (ARRAY_SIZE(rdData) - 4)) {
199 pvr2_trace( 197 pvr2_trace(
200 PVR2_TRACE_ERROR_LEGS, 198 PVR2_TRACE_ERROR_LEGS,
201 "Failed to write cx23416 command" 199 "Failed to write cx23416 command - too many return arguments (was given %u limit %lu)",
202 " - too many return arguments"
203 " (was given %u limit %lu)",
204 arg_cnt_recv, (long unsigned) ARRAY_SIZE(rdData) - 4); 200 arg_cnt_recv, (long unsigned) ARRAY_SIZE(rdData) - 4);
205 return -EINVAL; 201 return -EINVAL;
206 } 202 }
@@ -248,14 +244,12 @@ static int pvr2_encoder_cmd(void *ctxt,
248 retry_flag = !0; 244 retry_flag = !0;
249 pvr2_trace( 245 pvr2_trace(
250 PVR2_TRACE_ERROR_LEGS, 246 PVR2_TRACE_ERROR_LEGS,
251 "Encoder timed out waiting for us" 247 "Encoder timed out waiting for us; arranging to retry");
252 "; arranging to retry");
253 } else { 248 } else {
254 pvr2_trace( 249 pvr2_trace(
255 PVR2_TRACE_ERROR_LEGS, 250 PVR2_TRACE_ERROR_LEGS,
256 "***WARNING*** device's encoder" 251 "***WARNING*** device's encoder appears to be stuck (status=0x%08x)",
257 " appears to be stuck" 252rdData[0]);
258 " (status=0x%08x)",rdData[0]);
259 } 253 }
260 pvr2_trace( 254 pvr2_trace(
261 PVR2_TRACE_ERROR_LEGS, 255 PVR2_TRACE_ERROR_LEGS,
@@ -293,11 +287,7 @@ static int pvr2_encoder_cmd(void *ctxt,
293 } 287 }
294 pvr2_trace( 288 pvr2_trace(
295 PVR2_TRACE_ERROR_LEGS, 289 PVR2_TRACE_ERROR_LEGS,
296 "Giving up on command." 290 "Giving up on command. This is normally recovered via a firmware reload and re-initialization; concern is only warranted if this happens repeatedly and rapidly.");
297 " This is normally recovered via a firmware"
298 " reload and re-initialization; concern"
299 " is only warranted if this happens repeatedly"
300 " and rapidly.");
301 break; 291 break;
302 } 292 }
303 wrData[0] = 0x7; 293 wrData[0] = 0x7;
@@ -325,9 +315,7 @@ static int pvr2_encoder_vcmd(struct pvr2_hdw *hdw, int cmd,
325 if (args > ARRAY_SIZE(data)) { 315 if (args > ARRAY_SIZE(data)) {
326 pvr2_trace( 316 pvr2_trace(
327 PVR2_TRACE_ERROR_LEGS, 317 PVR2_TRACE_ERROR_LEGS,
328 "Failed to write cx23416 command" 318 "Failed to write cx23416 command - too many arguments (was given %u limit %lu)",
329 " - too many arguments"
330 " (was given %u limit %lu)",
331 args, (long unsigned) ARRAY_SIZE(data)); 319 args, (long unsigned) ARRAY_SIZE(data));
332 return -EINVAL; 320 return -EINVAL;
333 } 321 }
@@ -433,8 +421,7 @@ int pvr2_encoder_configure(struct pvr2_hdw *hdw)
433{ 421{
434 int ret; 422 int ret;
435 int val; 423 int val;
436 pvr2_trace(PVR2_TRACE_ENCODER,"pvr2_encoder_configure" 424 pvr2_trace(PVR2_TRACE_ENCODER, "pvr2_encoder_configure (cx2341x module)");
437 " (cx2341x module)");
438 hdw->enc_ctl_state.port = CX2341X_PORT_STREAMING; 425 hdw->enc_ctl_state.port = CX2341X_PORT_STREAMING;
439 hdw->enc_ctl_state.width = hdw->res_hor_val; 426 hdw->enc_ctl_state.width = hdw->res_hor_val;
440 hdw->enc_ctl_state.height = hdw->res_ver_val; 427 hdw->enc_ctl_state.height = hdw->res_ver_val;
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
index 1eb4f7ba2967..e3ed8ffee9f7 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
@@ -1371,8 +1371,7 @@ static int pvr2_locate_firmware(struct pvr2_hdw *hdw,
1371 fwnames[idx], 1371 fwnames[idx],
1372 &hdw->usb_dev->dev); 1372 &hdw->usb_dev->dev);
1373 if (!ret) { 1373 if (!ret) {
1374 trace_firmware("Located %s firmware: %s;" 1374 trace_firmware("Located %s firmware: %s; uploading...",
1375 " uploading...",
1376 fwtypename, 1375 fwtypename,
1377 fwnames[idx]); 1376 fwnames[idx]);
1378 return idx; 1377 return idx;
@@ -1383,21 +1382,17 @@ static int pvr2_locate_firmware(struct pvr2_hdw *hdw,
1383 return ret; 1382 return ret;
1384 } 1383 }
1385 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 1384 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1386 "***WARNING***" 1385 "***WARNING*** Device %s firmware seems to be missing.",
1387 " Device %s firmware"
1388 " seems to be missing.",
1389 fwtypename); 1386 fwtypename);
1390 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 1387 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1391 "Did you install the pvrusb2 firmware files" 1388 "Did you install the pvrusb2 firmware files in their proper location?");
1392 " in their proper location?");
1393 if (fwcount == 1) { 1389 if (fwcount == 1) {
1394 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 1390 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1395 "request_firmware unable to locate %s file %s", 1391 "request_firmware unable to locate %s file %s",
1396 fwtypename,fwnames[0]); 1392 fwtypename,fwnames[0]);
1397 } else { 1393 } else {
1398 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 1394 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1399 "request_firmware unable to locate" 1395 "request_firmware unable to locate one of the following %s files:",
1400 " one of the following %s files:",
1401 fwtypename); 1396 fwtypename);
1402 for (idx = 0; idx < fwcount; idx++) { 1397 for (idx = 0; idx < fwcount; idx++) {
1403 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 1398 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
@@ -1431,8 +1426,7 @@ static int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
1431 if (!hdw->hdw_desc->fx2_firmware.cnt) { 1426 if (!hdw->hdw_desc->fx2_firmware.cnt) {
1432 hdw->fw1_state = FW1_STATE_OK; 1427 hdw->fw1_state = FW1_STATE_OK;
1433 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 1428 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1434 "Connected device type defines" 1429 "Connected device type defines no firmware to upload; ignoring firmware");
1435 " no firmware to upload; ignoring firmware");
1436 return -ENOTTY; 1430 return -ENOTTY;
1437 } 1431 }
1438 1432
@@ -1457,13 +1451,11 @@ static int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
1457 (!(hdw->hdw_desc->flag_fx2_16kb && (fwsize == 0x4000)))) { 1451 (!(hdw->hdw_desc->flag_fx2_16kb && (fwsize == 0x4000)))) {
1458 if (hdw->hdw_desc->flag_fx2_16kb) { 1452 if (hdw->hdw_desc->flag_fx2_16kb) {
1459 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 1453 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1460 "Wrong fx2 firmware size" 1454 "Wrong fx2 firmware size (expected 8192 or 16384, got %u)",
1461 " (expected 8192 or 16384, got %u)",
1462 fwsize); 1455 fwsize);
1463 } else { 1456 } else {
1464 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 1457 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1465 "Wrong fx2 firmware size" 1458 "Wrong fx2 firmware size (expected 8192, got %u)",
1466 " (expected 8192, got %u)",
1467 fwsize); 1459 fwsize);
1468 } 1460 }
1469 release_firmware(fw_entry); 1461 release_firmware(fw_entry);
@@ -1585,8 +1577,7 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
1585 1577
1586 if (fw_len % sizeof(u32)) { 1578 if (fw_len % sizeof(u32)) {
1587 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 1579 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1588 "size of %s firmware" 1580 "size of %s firmware must be a multiple of %zu bytes",
1589 " must be a multiple of %zu bytes",
1590 fw_files[fwidx],sizeof(u32)); 1581 fw_files[fwidx],sizeof(u32));
1591 release_firmware(fw_entry); 1582 release_firmware(fw_entry);
1592 ret = -EINVAL; 1583 ret = -EINVAL;
@@ -1887,8 +1878,7 @@ static void pvr2_hdw_setup_std(struct pvr2_hdw *hdw)
1887 1878
1888 bcnt = pvr2_std_id_to_str(buf,sizeof(buf),hdw->std_mask_eeprom); 1879 bcnt = pvr2_std_id_to_str(buf,sizeof(buf),hdw->std_mask_eeprom);
1889 pvr2_trace(PVR2_TRACE_STD, 1880 pvr2_trace(PVR2_TRACE_STD,
1890 "Supported video standard(s) reported available" 1881 "Supported video standard(s) reported available in hardware: %.*s",
1891 " in hardware: %.*s",
1892 bcnt,buf); 1882 bcnt,buf);
1893 1883
1894 hdw->std_mask_avail = hdw->std_mask_eeprom; 1884 hdw->std_mask_avail = hdw->std_mask_eeprom;
@@ -1897,8 +1887,7 @@ static void pvr2_hdw_setup_std(struct pvr2_hdw *hdw)
1897 if (std2) { 1887 if (std2) {
1898 bcnt = pvr2_std_id_to_str(buf,sizeof(buf),std2); 1888 bcnt = pvr2_std_id_to_str(buf,sizeof(buf),std2);
1899 pvr2_trace(PVR2_TRACE_STD, 1889 pvr2_trace(PVR2_TRACE_STD,
1900 "Expanding supported video standards" 1890 "Expanding supported video standards to include: %.*s",
1901 " to include: %.*s",
1902 bcnt,buf); 1891 bcnt,buf);
1903 hdw->std_mask_avail |= std2; 1892 hdw->std_mask_avail |= std2;
1904 } 1893 }
@@ -1917,8 +1906,8 @@ static void pvr2_hdw_setup_std(struct pvr2_hdw *hdw)
1917 if (std3) { 1906 if (std3) {
1918 bcnt = pvr2_std_id_to_str(buf,sizeof(buf),std3); 1907 bcnt = pvr2_std_id_to_str(buf,sizeof(buf),std3);
1919 pvr2_trace(PVR2_TRACE_STD, 1908 pvr2_trace(PVR2_TRACE_STD,
1920 "Initial video standard" 1909 "Initial video standard (determined by device type): %.*s",
1921 " (determined by device type): %.*s",bcnt,buf); 1910 bcnt, buf);
1922 hdw->std_mask_cur = std3; 1911 hdw->std_mask_cur = std3;
1923 hdw->std_dirty = !0; 1912 hdw->std_dirty = !0;
1924 return; 1913 return;
@@ -1980,8 +1969,7 @@ static void pvr2_hdw_cx25840_vbi_hack(struct pvr2_hdw *hdw)
1980 } 1969 }
1981 1970
1982 pvr2_trace(PVR2_TRACE_INIT, 1971 pvr2_trace(PVR2_TRACE_INIT,
1983 "Module ID %u:" 1972 "Module ID %u: Executing cx25840 VBI hack",
1984 " Executing cx25840 VBI hack",
1985 hdw->decoder_client_id); 1973 hdw->decoder_client_id);
1986 memset(&fmt, 0, sizeof(fmt)); 1974 memset(&fmt, 0, sizeof(fmt));
1987 fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; 1975 fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
@@ -2007,8 +1995,7 @@ static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw,
2007 fname = (mid < ARRAY_SIZE(module_names)) ? module_names[mid] : NULL; 1995 fname = (mid < ARRAY_SIZE(module_names)) ? module_names[mid] : NULL;
2008 if (!fname) { 1996 if (!fname) {
2009 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 1997 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
2010 "Module ID %u for device %s has no name?" 1998 "Module ID %u for device %s has no name? The driver might have a configuration problem.",
2011 " The driver might have a configuration problem.",
2012 mid, 1999 mid,
2013 hdw->hdw_desc->description); 2000 hdw->hdw_desc->description);
2014 return -EINVAL; 2001 return -EINVAL;
@@ -2027,32 +2014,27 @@ static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw,
2027 ARRAY_SIZE(i2caddr)); 2014 ARRAY_SIZE(i2caddr));
2028 if (i2ccnt) { 2015 if (i2ccnt) {
2029 pvr2_trace(PVR2_TRACE_INIT, 2016 pvr2_trace(PVR2_TRACE_INIT,
2030 "Module ID %u:" 2017 "Module ID %u: Using default i2c address list",
2031 " Using default i2c address list",
2032 mid); 2018 mid);
2033 } 2019 }
2034 } 2020 }
2035 2021
2036 if (!i2ccnt) { 2022 if (!i2ccnt) {
2037 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 2023 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
2038 "Module ID %u (%s) for device %s:" 2024 "Module ID %u (%s) for device %s: No i2c addresses. The driver might have a configuration problem.",
2039 " No i2c addresses."
2040 " The driver might have a configuration problem.",
2041 mid, fname, hdw->hdw_desc->description); 2025 mid, fname, hdw->hdw_desc->description);
2042 return -EINVAL; 2026 return -EINVAL;
2043 } 2027 }
2044 2028
2045 if (i2ccnt == 1) { 2029 if (i2ccnt == 1) {
2046 pvr2_trace(PVR2_TRACE_INIT, 2030 pvr2_trace(PVR2_TRACE_INIT,
2047 "Module ID %u:" 2031 "Module ID %u: Setting up with specified i2c address 0x%x",
2048 " Setting up with specified i2c address 0x%x",
2049 mid, i2caddr[0]); 2032 mid, i2caddr[0]);
2050 sd = v4l2_i2c_new_subdev(&hdw->v4l2_dev, &hdw->i2c_adap, 2033 sd = v4l2_i2c_new_subdev(&hdw->v4l2_dev, &hdw->i2c_adap,
2051 fname, i2caddr[0], NULL); 2034 fname, i2caddr[0], NULL);
2052 } else { 2035 } else {
2053 pvr2_trace(PVR2_TRACE_INIT, 2036 pvr2_trace(PVR2_TRACE_INIT,
2054 "Module ID %u:" 2037 "Module ID %u: Setting up with address probe list",
2055 " Setting up with address probe list",
2056 mid); 2038 mid);
2057 sd = v4l2_i2c_new_subdev(&hdw->v4l2_dev, &hdw->i2c_adap, 2039 sd = v4l2_i2c_new_subdev(&hdw->v4l2_dev, &hdw->i2c_adap,
2058 fname, 0, i2caddr); 2040 fname, 0, i2caddr);
@@ -2060,9 +2042,7 @@ static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw,
2060 2042
2061 if (!sd) { 2043 if (!sd) {
2062 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 2044 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
2063 "Module ID %u (%s) for device %s failed to load." 2045 "Module ID %u (%s) for device %s failed to load. Possible missing sub-device kernel module or initialization failure within module.",
2064 " Possible missing sub-device kernel module or"
2065 " initialization failure within module.",
2066 mid, fname, hdw->hdw_desc->description); 2046 mid, fname, hdw->hdw_desc->description);
2067 return -EIO; 2047 return -EIO;
2068 } 2048 }
@@ -2124,18 +2104,14 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
2124 == 0); 2104 == 0);
2125 if (reloadFl) { 2105 if (reloadFl) {
2126 pvr2_trace(PVR2_TRACE_INIT, 2106 pvr2_trace(PVR2_TRACE_INIT,
2127 "USB endpoint config looks strange" 2107 "USB endpoint config looks strange; possibly firmware needs to be loaded");
2128 "; possibly firmware needs to be"
2129 " loaded");
2130 } 2108 }
2131 } 2109 }
2132 if (!reloadFl) { 2110 if (!reloadFl) {
2133 reloadFl = !pvr2_hdw_check_firmware(hdw); 2111 reloadFl = !pvr2_hdw_check_firmware(hdw);
2134 if (reloadFl) { 2112 if (reloadFl) {
2135 pvr2_trace(PVR2_TRACE_INIT, 2113 pvr2_trace(PVR2_TRACE_INIT,
2136 "Check for FX2 firmware failed" 2114 "Check for FX2 firmware failed; possibly firmware needs to be loaded");
2137 "; possibly firmware needs to be"
2138 " loaded");
2139 } 2115 }
2140 } 2116 }
2141 if (reloadFl) { 2117 if (reloadFl) {
@@ -2200,8 +2176,7 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
2200 if (!pvr2_hdw_dev_ok(hdw)) return; 2176 if (!pvr2_hdw_dev_ok(hdw)) return;
2201 if (ret < 0) { 2177 if (ret < 0) {
2202 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 2178 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
2203 "Unable to determine location of eeprom," 2179 "Unable to determine location of eeprom, skipping");
2204 " skipping");
2205 } else { 2180 } else {
2206 hdw->eeprom_addr = ret; 2181 hdw->eeprom_addr = ret;
2207 pvr2_eeprom_analyze(hdw); 2182 pvr2_eeprom_analyze(hdw);
@@ -2254,8 +2229,7 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
2254 idx = get_default_error_tolerance(hdw); 2229 idx = get_default_error_tolerance(hdw);
2255 if (idx) { 2230 if (idx) {
2256 pvr2_trace(PVR2_TRACE_INIT, 2231 pvr2_trace(PVR2_TRACE_INIT,
2257 "pvr2_hdw_setup: video stream %p" 2232 "pvr2_hdw_setup: video stream %p setting tolerance %u",
2258 " setting tolerance %u",
2259 hdw->vid_stream,idx); 2233 hdw->vid_stream,idx);
2260 } 2234 }
2261 pvr2_stream_setup(hdw->vid_stream,hdw->usb_dev, 2235 pvr2_stream_setup(hdw->vid_stream,hdw->usb_dev,
@@ -2285,16 +2259,13 @@ static void pvr2_hdw_setup(struct pvr2_hdw *hdw)
2285 if (hdw->flag_init_ok) { 2259 if (hdw->flag_init_ok) {
2286 pvr2_trace( 2260 pvr2_trace(
2287 PVR2_TRACE_INFO, 2261 PVR2_TRACE_INFO,
2288 "Device initialization" 2262 "Device initialization completed successfully.");
2289 " completed successfully.");
2290 break; 2263 break;
2291 } 2264 }
2292 if (hdw->fw1_state == FW1_STATE_RELOAD) { 2265 if (hdw->fw1_state == FW1_STATE_RELOAD) {
2293 pvr2_trace( 2266 pvr2_trace(
2294 PVR2_TRACE_INFO, 2267 PVR2_TRACE_INFO,
2295 "Device microcontroller firmware" 2268 "Device microcontroller firmware (re)loaded; it should now reset and reconnect.");
2296 " (re)loaded; it should now reset"
2297 " and reconnect.");
2298 break; 2269 break;
2299 } 2270 }
2300 pvr2_trace( 2271 pvr2_trace(
@@ -2303,48 +2274,35 @@ static void pvr2_hdw_setup(struct pvr2_hdw *hdw)
2303 if (hdw->fw1_state == FW1_STATE_MISSING) { 2274 if (hdw->fw1_state == FW1_STATE_MISSING) {
2304 pvr2_trace( 2275 pvr2_trace(
2305 PVR2_TRACE_ERROR_LEGS, 2276 PVR2_TRACE_ERROR_LEGS,
2306 "Giving up since device" 2277 "Giving up since device microcontroller firmware appears to be missing.");
2307 " microcontroller firmware"
2308 " appears to be missing.");
2309 break; 2278 break;
2310 } 2279 }
2311 } 2280 }
2312 if (hdw->flag_modulefail) { 2281 if (hdw->flag_modulefail) {
2313 pvr2_trace( 2282 pvr2_trace(
2314 PVR2_TRACE_ERROR_LEGS, 2283 PVR2_TRACE_ERROR_LEGS,
2315 "***WARNING*** pvrusb2 driver initialization" 2284 "***WARNING*** pvrusb2 driver initialization failed due to the failure of one or more sub-device kernel modules.");
2316 " failed due to the failure of one or more"
2317 " sub-device kernel modules.");
2318 pvr2_trace( 2285 pvr2_trace(
2319 PVR2_TRACE_ERROR_LEGS, 2286 PVR2_TRACE_ERROR_LEGS,
2320 "You need to resolve the failing condition" 2287 "You need to resolve the failing condition before this driver can function. There should be some earlier messages giving more information about the problem.");
2321 " before this driver can function. There"
2322 " should be some earlier messages giving more"
2323 " information about the problem.");
2324 break; 2288 break;
2325 } 2289 }
2326 if (procreload) { 2290 if (procreload) {
2327 pvr2_trace( 2291 pvr2_trace(
2328 PVR2_TRACE_ERROR_LEGS, 2292 PVR2_TRACE_ERROR_LEGS,
2329 "Attempting pvrusb2 recovery by reloading" 2293 "Attempting pvrusb2 recovery by reloading primary firmware.");
2330 " primary firmware.");
2331 pvr2_trace( 2294 pvr2_trace(
2332 PVR2_TRACE_ERROR_LEGS, 2295 PVR2_TRACE_ERROR_LEGS,
2333 "If this works, device should disconnect" 2296 "If this works, device should disconnect and reconnect in a sane state.");
2334 " and reconnect in a sane state.");
2335 hdw->fw1_state = FW1_STATE_UNKNOWN; 2297 hdw->fw1_state = FW1_STATE_UNKNOWN;
2336 pvr2_upload_firmware1(hdw); 2298 pvr2_upload_firmware1(hdw);
2337 } else { 2299 } else {
2338 pvr2_trace( 2300 pvr2_trace(
2339 PVR2_TRACE_ERROR_LEGS, 2301 PVR2_TRACE_ERROR_LEGS,
2340 "***WARNING*** pvrusb2 device hardware" 2302 "***WARNING*** pvrusb2 device hardware appears to be jammed and I can't clear it.");
2341 " appears to be jammed"
2342 " and I can't clear it.");
2343 pvr2_trace( 2303 pvr2_trace(
2344 PVR2_TRACE_ERROR_LEGS, 2304 PVR2_TRACE_ERROR_LEGS,
2345 "You might need to power cycle" 2305 "You might need to power cycle the pvrusb2 device in order to recover.");
2346 " the pvrusb2 device"
2347 " in order to recover.");
2348 } 2306 }
2349 } while (0); 2307 } while (0);
2350 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_setup(hdw=%p) end",hdw); 2308 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_setup(hdw=%p) end",hdw);
@@ -2396,12 +2354,8 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
2396 hdw_desc = (const struct pvr2_device_desc *)(devid->driver_info); 2354 hdw_desc = (const struct pvr2_device_desc *)(devid->driver_info);
2397 2355
2398 if (hdw_desc == NULL) { 2356 if (hdw_desc == NULL) {
2399 pvr2_trace(PVR2_TRACE_INIT, "pvr2_hdw_create:" 2357 pvr2_trace(PVR2_TRACE_INIT, "pvr2_hdw_create: No device description pointer, unable to continue.");
2400 " No device description pointer," 2358 pvr2_trace(PVR2_TRACE_INIT, "If you have a new device type, please contact Mike Isely <isely@pobox.com> to get it included in the driver\n");
2401 " unable to continue.");
2402 pvr2_trace(PVR2_TRACE_INIT, "If you have a new device type,"
2403 " please contact Mike Isely <isely@pobox.com>"
2404 " to get it included in the driver\n");
2405 goto fail; 2359 goto fail;
2406 } 2360 }
2407 2361
@@ -2413,14 +2367,12 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
2413 if (hdw_desc->flag_is_experimental) { 2367 if (hdw_desc->flag_is_experimental) {
2414 pvr2_trace(PVR2_TRACE_INFO, "**********"); 2368 pvr2_trace(PVR2_TRACE_INFO, "**********");
2415 pvr2_trace(PVR2_TRACE_INFO, 2369 pvr2_trace(PVR2_TRACE_INFO,
2416 "WARNING: Support for this device (%s) is" 2370 "WARNING: Support for this device (%s) is experimental.",
2417 " experimental.", hdw_desc->description); 2371 hdw_desc->description);
2418 pvr2_trace(PVR2_TRACE_INFO, 2372 pvr2_trace(PVR2_TRACE_INFO,
2419 "Important functionality might not be" 2373 "Important functionality might not be entirely working.");
2420 " entirely working.");
2421 pvr2_trace(PVR2_TRACE_INFO, 2374 pvr2_trace(PVR2_TRACE_INFO,
2422 "Please consider contacting the driver author to" 2375 "Please consider contacting the driver author to help with further stabilization of the driver.");
2423 " help with further stabilization of the driver.");
2424 pvr2_trace(PVR2_TRACE_INFO, "**********"); 2376 pvr2_trace(PVR2_TRACE_INFO, "**********");
2425 } 2377 }
2426 if (!hdw) goto fail; 2378 if (!hdw) goto fail;
@@ -3375,8 +3327,7 @@ static u8 *pvr2_full_eeprom_fetch(struct pvr2_hdw *hdw)
3375 eeprom = kmalloc(EEPROM_SIZE,GFP_KERNEL); 3327 eeprom = kmalloc(EEPROM_SIZE,GFP_KERNEL);
3376 if (!eeprom) { 3328 if (!eeprom) {
3377 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 3329 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
3378 "Failed to allocate memory" 3330 "Failed to allocate memory required to read eeprom");
3379 " required to read eeprom");
3380 return NULL; 3331 return NULL;
3381 } 3332 }
3382 3333
@@ -3393,8 +3344,8 @@ static u8 *pvr2_full_eeprom_fetch(struct pvr2_hdw *hdw)
3393 strange but it's what they do) */ 3344 strange but it's what they do) */
3394 mode16 = (addr & 1); 3345 mode16 = (addr & 1);
3395 eepromSize = (mode16 ? EEPROM_SIZE : 256); 3346 eepromSize = (mode16 ? EEPROM_SIZE : 256);
3396 trace_eeprom("Examining %d byte eeprom at location 0x%x" 3347 trace_eeprom("Examining %d byte eeprom at location 0x%x using %d bit addressing",
3397 " using %d bit addressing",eepromSize,addr, 3348 eepromSize, addr,
3398 mode16 ? 16 : 8); 3349 mode16 ? 16 : 8);
3399 3350
3400 msg[0].addr = addr; 3351 msg[0].addr = addr;
@@ -3461,8 +3412,8 @@ void pvr2_hdw_cpufw_set_enabled(struct pvr2_hdw *hdw,
3461 if (hdw->fw_cpu_flag) { 3412 if (hdw->fw_cpu_flag) {
3462 hdw->fw_size = (mode == 1) ? 0x4000 : 0x2000; 3413 hdw->fw_size = (mode == 1) ? 0x4000 : 0x2000;
3463 pvr2_trace(PVR2_TRACE_FIRMWARE, 3414 pvr2_trace(PVR2_TRACE_FIRMWARE,
3464 "Preparing to suck out CPU firmware" 3415 "Preparing to suck out CPU firmware (size=%u)",
3465 " (size=%u)", hdw->fw_size); 3416 hdw->fw_size);
3466 hdw->fw_buffer = kzalloc(hdw->fw_size,GFP_KERNEL); 3417 hdw->fw_buffer = kzalloc(hdw->fw_size,GFP_KERNEL);
3467 if (!hdw->fw_buffer) { 3418 if (!hdw->fw_buffer) {
3468 hdw->fw_size = 0; 3419 hdw->fw_size = 0;
@@ -3620,21 +3571,18 @@ static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
3620 struct timer_list timer; 3571 struct timer_list timer;
3621 if (!hdw->ctl_lock_held) { 3572 if (!hdw->ctl_lock_held) {
3622 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 3573 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
3623 "Attempted to execute control transfer" 3574 "Attempted to execute control transfer without lock!!");
3624 " without lock!!");
3625 return -EDEADLK; 3575 return -EDEADLK;
3626 } 3576 }
3627 if (!hdw->flag_ok && !probe_fl) { 3577 if (!hdw->flag_ok && !probe_fl) {
3628 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 3578 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
3629 "Attempted to execute control transfer" 3579 "Attempted to execute control transfer when device not ok");
3630 " when device not ok");
3631 return -EIO; 3580 return -EIO;
3632 } 3581 }
3633 if (!(hdw->ctl_read_urb && hdw->ctl_write_urb)) { 3582 if (!(hdw->ctl_read_urb && hdw->ctl_write_urb)) {
3634 if (!probe_fl) { 3583 if (!probe_fl) {
3635 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 3584 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
3636 "Attempted to execute control transfer" 3585 "Attempted to execute control transfer when USB is disconnected");
3637 " when USB is disconnected");
3638 } 3586 }
3639 return -ENOTTY; 3587 return -ENOTTY;
3640 } 3588 }
@@ -3645,16 +3593,14 @@ static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
3645 if (write_len > PVR2_CTL_BUFFSIZE) { 3593 if (write_len > PVR2_CTL_BUFFSIZE) {
3646 pvr2_trace( 3594 pvr2_trace(
3647 PVR2_TRACE_ERROR_LEGS, 3595 PVR2_TRACE_ERROR_LEGS,
3648 "Attempted to execute %d byte" 3596 "Attempted to execute %d byte control-write transfer (limit=%d)",
3649 " control-write transfer (limit=%d)",
3650 write_len,PVR2_CTL_BUFFSIZE); 3597 write_len,PVR2_CTL_BUFFSIZE);
3651 return -EINVAL; 3598 return -EINVAL;
3652 } 3599 }
3653 if (read_len > PVR2_CTL_BUFFSIZE) { 3600 if (read_len > PVR2_CTL_BUFFSIZE) {
3654 pvr2_trace( 3601 pvr2_trace(
3655 PVR2_TRACE_ERROR_LEGS, 3602 PVR2_TRACE_ERROR_LEGS,
3656 "Attempted to execute %d byte" 3603 "Attempted to execute %d byte control-read transfer (limit=%d)",
3657 " control-read transfer (limit=%d)",
3658 write_len,PVR2_CTL_BUFFSIZE); 3604 write_len,PVR2_CTL_BUFFSIZE);
3659 return -EINVAL; 3605 return -EINVAL;
3660 } 3606 }
@@ -3703,8 +3649,8 @@ static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
3703 status = usb_submit_urb(hdw->ctl_write_urb,GFP_KERNEL); 3649 status = usb_submit_urb(hdw->ctl_write_urb,GFP_KERNEL);
3704 if (status < 0) { 3650 if (status < 0) {
3705 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 3651 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
3706 "Failed to submit write-control" 3652 "Failed to submit write-control URB status=%d",
3707 " URB status=%d",status); 3653status);
3708 hdw->ctl_write_pend_flag = 0; 3654 hdw->ctl_write_pend_flag = 0;
3709 goto done; 3655 goto done;
3710 } 3656 }
@@ -3727,8 +3673,8 @@ static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
3727 status = usb_submit_urb(hdw->ctl_read_urb,GFP_KERNEL); 3673 status = usb_submit_urb(hdw->ctl_read_urb,GFP_KERNEL);
3728 if (status < 0) { 3674 if (status < 0) {
3729 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 3675 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
3730 "Failed to submit read-control" 3676 "Failed to submit read-control URB status=%d",
3731 " URB status=%d",status); 3677status);
3732 hdw->ctl_read_pend_flag = 0; 3678 hdw->ctl_read_pend_flag = 0;
3733 goto done; 3679 goto done;
3734 } 3680 }
@@ -3770,8 +3716,7 @@ static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
3770 status = hdw->ctl_write_urb->status; 3716 status = hdw->ctl_write_urb->status;
3771 if (!probe_fl) { 3717 if (!probe_fl) {
3772 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 3718 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
3773 "control-write URB failure," 3719 "control-write URB failure, status=%d",
3774 " status=%d",
3775 status); 3720 status);
3776 } 3721 }
3777 goto done; 3722 goto done;
@@ -3781,8 +3726,7 @@ static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
3781 status = -EIO; 3726 status = -EIO;
3782 if (!probe_fl) { 3727 if (!probe_fl) {
3783 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 3728 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
3784 "control-write URB short," 3729 "control-write URB short, expected=%d got=%d",
3785 " expected=%d got=%d",
3786 write_len, 3730 write_len,
3787 hdw->ctl_write_urb->actual_length); 3731 hdw->ctl_write_urb->actual_length);
3788 } 3732 }
@@ -3800,8 +3744,7 @@ static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
3800 status = hdw->ctl_read_urb->status; 3744 status = hdw->ctl_read_urb->status;
3801 if (!probe_fl) { 3745 if (!probe_fl) {
3802 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 3746 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
3803 "control-read URB failure," 3747 "control-read URB failure, status=%d",
3804 " status=%d",
3805 status); 3748 status);
3806 } 3749 }
3807 goto done; 3750 goto done;
@@ -3811,8 +3754,7 @@ static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
3811 status = -EIO; 3754 status = -EIO;
3812 if (!probe_fl) { 3755 if (!probe_fl) {
3813 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 3756 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
3814 "control-read URB short," 3757 "control-read URB short, expected=%d got=%d",
3815 " expected=%d got=%d",
3816 read_len, 3758 read_len,
3817 hdw->ctl_read_urb->actual_length); 3759 hdw->ctl_read_urb->actual_length);
3818 } 3760 }
@@ -4799,9 +4741,7 @@ static unsigned int pvr2_hdw_report_unlocked(struct pvr2_hdw *hdw,int which,
4799 0); 4741 0);
4800 return scnprintf( 4742 return scnprintf(
4801 buf,acnt, 4743 buf,acnt,
4802 "Bytes streamed=%u" 4744 "Bytes streamed=%u URBs: queued=%u idle=%u ready=%u processed=%u failed=%u",
4803 " URBs: queued=%u idle=%u ready=%u"
4804 " processed=%u failed=%u",
4805 stats.bytes_processed, 4745 stats.bytes_processed,
4806 stats.buffers_in_queue, 4746 stats.buffers_in_queue,
4807 stats.buffers_in_idle, 4747 stats.buffers_in_idle,
@@ -5013,8 +4953,7 @@ int pvr2_hdw_gpio_chg_dir(struct pvr2_hdw *hdw,u32 msk,u32 val)
5013 if (ret) return ret; 4953 if (ret) return ret;
5014 nval = (cval & ~msk) | (val & msk); 4954 nval = (cval & ~msk) | (val & msk);
5015 pvr2_trace(PVR2_TRACE_GPIO, 4955 pvr2_trace(PVR2_TRACE_GPIO,
5016 "GPIO direction changing 0x%x:0x%x" 4956 "GPIO direction changing 0x%x:0x%x from 0x%x to 0x%x",
5017 " from 0x%x to 0x%x",
5018 msk,val,cval,nval); 4957 msk,val,cval,nval);
5019 } else { 4958 } else {
5020 nval = val; 4959 nval = val;
@@ -5057,9 +4996,7 @@ void pvr2_hdw_status_poll(struct pvr2_hdw *hdw)
5057 now. (Of course, no sub-drivers seem to implement it either. 4996 now. (Of course, no sub-drivers seem to implement it either.
5058 But now it's a a chicken and egg problem...) */ 4997 But now it's a a chicken and egg problem...) */
5059 v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, g_tuner, vtp); 4998 v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, g_tuner, vtp);
5060 pvr2_trace(PVR2_TRACE_CHIPS, "subdev status poll" 4999 pvr2_trace(PVR2_TRACE_CHIPS, "subdev status poll type=%u strength=%u audio=0x%x cap=0x%x low=%u hi=%u",
5061 " type=%u strength=%u audio=0x%x cap=0x%x"
5062 " low=%u hi=%u",
5063 vtp->type, 5000 vtp->type,
5064 vtp->signal, vtp->rxsubchans, vtp->capability, 5001 vtp->signal, vtp->rxsubchans, vtp->capability,
5065 vtp->rangelow, vtp->rangehigh); 5002 vtp->rangelow, vtp->rangehigh);
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
index 6da5fb544817..cc63e5f4c26c 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
@@ -62,8 +62,7 @@ static int pvr2_i2c_write(struct pvr2_hdw *hdw, /* Context */
62 if (!data) length = 0; 62 if (!data) length = 0;
63 if (length > (sizeof(hdw->cmd_buffer) - 3)) { 63 if (length > (sizeof(hdw->cmd_buffer) - 3)) {
64 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 64 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
65 "Killing an I2C write to %u that is too large" 65 "Killing an I2C write to %u that is too large (desired=%u limit=%u)",
66 " (desired=%u limit=%u)",
67 i2c_addr, 66 i2c_addr,
68 length,(unsigned int)(sizeof(hdw->cmd_buffer) - 3)); 67 length,(unsigned int)(sizeof(hdw->cmd_buffer) - 3));
69 return -ENOTSUPP; 68 return -ENOTSUPP;
@@ -90,8 +89,7 @@ static int pvr2_i2c_write(struct pvr2_hdw *hdw, /* Context */
90 if (hdw->cmd_buffer[0] != 8) { 89 if (hdw->cmd_buffer[0] != 8) {
91 ret = -EIO; 90 ret = -EIO;
92 if (hdw->cmd_buffer[0] != 7) { 91 if (hdw->cmd_buffer[0] != 7) {
93 trace_i2c("unexpected status" 92 trace_i2c("unexpected status from i2_write[%d]: %d",
94 " from i2_write[%d]: %d",
95 i2c_addr,hdw->cmd_buffer[0]); 93 i2c_addr,hdw->cmd_buffer[0]);
96 } 94 }
97 } 95 }
@@ -116,16 +114,14 @@ static int pvr2_i2c_read(struct pvr2_hdw *hdw, /* Context */
116 if (!data) dlen = 0; 114 if (!data) dlen = 0;
117 if (dlen > (sizeof(hdw->cmd_buffer) - 4)) { 115 if (dlen > (sizeof(hdw->cmd_buffer) - 4)) {
118 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 116 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
119 "Killing an I2C read to %u that has wlen too large" 117 "Killing an I2C read to %u that has wlen too large (desired=%u limit=%u)",
120 " (desired=%u limit=%u)",
121 i2c_addr, 118 i2c_addr,
122 dlen,(unsigned int)(sizeof(hdw->cmd_buffer) - 4)); 119 dlen,(unsigned int)(sizeof(hdw->cmd_buffer) - 4));
123 return -ENOTSUPP; 120 return -ENOTSUPP;
124 } 121 }
125 if (res && (rlen > (sizeof(hdw->cmd_buffer) - 1))) { 122 if (res && (rlen > (sizeof(hdw->cmd_buffer) - 1))) {
126 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 123 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
127 "Killing an I2C read to %u that has rlen too large" 124 "Killing an I2C read to %u that has rlen too large (desired=%u limit=%u)",
128 " (desired=%u limit=%u)",
129 i2c_addr, 125 i2c_addr,
130 rlen,(unsigned int)(sizeof(hdw->cmd_buffer) - 1)); 126 rlen,(unsigned int)(sizeof(hdw->cmd_buffer) - 1));
131 return -ENOTSUPP; 127 return -ENOTSUPP;
@@ -154,8 +150,7 @@ static int pvr2_i2c_read(struct pvr2_hdw *hdw, /* Context */
154 if (hdw->cmd_buffer[0] != 8) { 150 if (hdw->cmd_buffer[0] != 8) {
155 ret = -EIO; 151 ret = -EIO;
156 if (hdw->cmd_buffer[0] != 7) { 152 if (hdw->cmd_buffer[0] != 7) {
157 trace_i2c("unexpected status" 153 trace_i2c("unexpected status from i2_read[%d]: %d",
158 " from i2_read[%d]: %d",
159 i2c_addr,hdw->cmd_buffer[0]); 154 i2c_addr,hdw->cmd_buffer[0]);
160 } 155 }
161 } 156 }
@@ -352,13 +347,11 @@ static int i2c_hack_cx25840(struct pvr2_hdw *hdw,
352 347
353 if ((ret != 0) || (*rdata == 0x04) || (*rdata == 0x0a)) { 348 if ((ret != 0) || (*rdata == 0x04) || (*rdata == 0x0a)) {
354 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 349 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
355 "WARNING: Detected a wedged cx25840 chip;" 350 "WARNING: Detected a wedged cx25840 chip; the device will not work.");
356 " the device will not work.");
357 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 351 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
358 "WARNING: Try power cycling the pvrusb2 device."); 352 "WARNING: Try power cycling the pvrusb2 device.");
359 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 353 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
360 "WARNING: Disabling further access to the device" 354 "WARNING: Disabling further access to the device to prevent other foul-ups.");
361 " to prevent other foul-ups.");
362 // This blocks all further communication with the part. 355 // This blocks all further communication with the part.
363 hdw->i2c_func[0x44] = NULL; 356 hdw->i2c_func[0x44] = NULL;
364 pvr2_hdw_render_useless(hdw); 357 pvr2_hdw_render_useless(hdw);
@@ -444,8 +437,7 @@ static int pvr2_i2c_xfer(struct i2c_adapter *i2c_adap,
444 } 437 }
445 } else if (num == 2) { 438 } else if (num == 2) {
446 if (msgs[0].addr != msgs[1].addr) { 439 if (msgs[0].addr != msgs[1].addr) {
447 trace_i2c("i2c refusing 2 phase transfer with" 440 trace_i2c("i2c refusing 2 phase transfer with conflicting target addresses");
448 " conflicting target addresses");
449 ret = -ENOTSUPP; 441 ret = -ENOTSUPP;
450 goto done; 442 goto done;
451 } 443 }
@@ -477,8 +469,7 @@ static int pvr2_i2c_xfer(struct i2c_adapter *i2c_adap,
477 ret = 2; 469 ret = 2;
478 goto done; 470 goto done;
479 } else { 471 } else {
480 trace_i2c("i2c refusing complex transfer" 472 trace_i2c("i2c refusing complex transfer read0=%d read1=%d",
481 " read0=%d read1=%d",
482 (msgs[0].flags & I2C_M_RD), 473 (msgs[0].flags & I2C_M_RD),
483 (msgs[1].flags & I2C_M_RD)); 474 (msgs[1].flags & I2C_M_RD));
484 } 475 }
@@ -492,8 +483,7 @@ static int pvr2_i2c_xfer(struct i2c_adapter *i2c_adap,
492 for (idx = 0; idx < num; idx++) { 483 for (idx = 0; idx < num; idx++) {
493 cnt = msgs[idx].len; 484 cnt = msgs[idx].len;
494 printk(KERN_INFO 485 printk(KERN_INFO
495 "pvrusb2 i2c xfer %u/%u:" 486 "pvrusb2 i2c xfer %u/%u: addr=0x%x len=%d %s",
496 " addr=0x%x len=%d %s",
497 idx+1,num, 487 idx+1,num,
498 msgs[idx].addr, 488 msgs[idx].addr,
499 cnt, 489 cnt,
@@ -501,18 +491,18 @@ static int pvr2_i2c_xfer(struct i2c_adapter *i2c_adap,
501 "read" : "write")); 491 "read" : "write"));
502 if ((ret > 0) || !(msgs[idx].flags & I2C_M_RD)) { 492 if ((ret > 0) || !(msgs[idx].flags & I2C_M_RD)) {
503 if (cnt > 8) cnt = 8; 493 if (cnt > 8) cnt = 8;
504 printk(" ["); 494 printk(KERN_CONT " [");
505 for (offs = 0; offs < (cnt>8?8:cnt); offs++) { 495 for (offs = 0; offs < (cnt>8?8:cnt); offs++) {
506 if (offs) printk(" "); 496 if (offs) printk(KERN_CONT " ");
507 printk("%02x",msgs[idx].buf[offs]); 497 printk(KERN_CONT "%02x",msgs[idx].buf[offs]);
508 } 498 }
509 if (offs < cnt) printk(" ..."); 499 if (offs < cnt) printk(KERN_CONT " ...");
510 printk("]"); 500 printk(KERN_CONT "]");
511 } 501 }
512 if (idx+1 == num) { 502 if (idx+1 == num) {
513 printk(" result=%d",ret); 503 printk(KERN_CONT " result=%d",ret);
514 } 504 }
515 printk("\n"); 505 printk(KERN_CONT "\n");
516 } 506 }
517 if (!num) { 507 if (!num) {
518 printk(KERN_INFO 508 printk(KERN_INFO
@@ -668,8 +658,7 @@ void pvr2_i2c_core_init(struct pvr2_hdw *hdw)
668 the emulated IR receiver. */ 658 the emulated IR receiver. */
669 if (do_i2c_probe(hdw, 0x71)) { 659 if (do_i2c_probe(hdw, 0x71)) {
670 pvr2_trace(PVR2_TRACE_INFO, 660 pvr2_trace(PVR2_TRACE_INFO,
671 "Device has newer IR hardware;" 661 "Device has newer IR hardware; disabling unneeded virtual IR device");
672 " disabling unneeded virtual IR device");
673 hdw->i2c_func[0x18] = NULL; 662 hdw->i2c_func[0x18] = NULL;
674 /* Remember that this is a different device... */ 663 /* Remember that this is a different device... */
675 hdw->ir_scheme_active = PVR2_IR_SCHEME_24XXX_MCE; 664 hdw->ir_scheme_active = PVR2_IR_SCHEME_24XXX_MCE;
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-io.c b/drivers/media/usb/pvrusb2/pvrusb2-io.c
index e68ce24f27e3..e3103ecd4828 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-io.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-io.c
@@ -113,8 +113,7 @@ static const char *pvr2_buffer_state_decode(enum pvr2_buffer_state st)
113static void pvr2_buffer_describe(struct pvr2_buffer *bp,const char *msg) 113static void pvr2_buffer_describe(struct pvr2_buffer *bp,const char *msg)
114{ 114{
115 pvr2_trace(PVR2_TRACE_INFO, 115 pvr2_trace(PVR2_TRACE_INFO,
116 "buffer%s%s %p state=%s id=%d status=%d" 116 "buffer%s%s %p state=%s id=%d status=%d stream=%p purb=%p sig=0x%x",
117 " stream=%p purb=%p sig=0x%x",
118 (msg ? " " : ""), 117 (msg ? " " : ""),
119 (msg ? msg : ""), 118 (msg ? msg : ""),
120 bp, 119 bp,
@@ -156,8 +155,7 @@ static void pvr2_buffer_remove(struct pvr2_buffer *bp)
156 (*cnt)--; 155 (*cnt)--;
157 (*bcnt) -= ccnt; 156 (*bcnt) -= ccnt;
158 pvr2_trace(PVR2_TRACE_BUF_FLOW, 157 pvr2_trace(PVR2_TRACE_BUF_FLOW,
159 "/*---TRACE_FLOW---*/" 158 "/*---TRACE_FLOW---*/ bufferPool %8s dec cap=%07d cnt=%02d",
160 " bufferPool %8s dec cap=%07d cnt=%02d",
161 pvr2_buffer_state_decode(bp->state),*bcnt,*cnt); 159 pvr2_buffer_state_decode(bp->state),*bcnt,*cnt);
162 bp->state = pvr2_buffer_state_none; 160 bp->state = pvr2_buffer_state_none;
163} 161}
@@ -198,8 +196,7 @@ static int pvr2_buffer_set_ready(struct pvr2_buffer *bp)
198 (sp->r_count)++; 196 (sp->r_count)++;
199 sp->r_bcount += bp->used_count; 197 sp->r_bcount += bp->used_count;
200 pvr2_trace(PVR2_TRACE_BUF_FLOW, 198 pvr2_trace(PVR2_TRACE_BUF_FLOW,
201 "/*---TRACE_FLOW---*/" 199 "/*---TRACE_FLOW---*/ bufferPool %8s inc cap=%07d cnt=%02d",
202 " bufferPool %8s inc cap=%07d cnt=%02d",
203 pvr2_buffer_state_decode(bp->state), 200 pvr2_buffer_state_decode(bp->state),
204 sp->r_bcount,sp->r_count); 201 sp->r_bcount,sp->r_count);
205 spin_unlock_irqrestore(&sp->list_lock,irq_flags); 202 spin_unlock_irqrestore(&sp->list_lock,irq_flags);
@@ -224,8 +221,7 @@ static void pvr2_buffer_set_idle(struct pvr2_buffer *bp)
224 (sp->i_count)++; 221 (sp->i_count)++;
225 sp->i_bcount += bp->max_count; 222 sp->i_bcount += bp->max_count;
226 pvr2_trace(PVR2_TRACE_BUF_FLOW, 223 pvr2_trace(PVR2_TRACE_BUF_FLOW,
227 "/*---TRACE_FLOW---*/" 224 "/*---TRACE_FLOW---*/ bufferPool %8s inc cap=%07d cnt=%02d",
228 " bufferPool %8s inc cap=%07d cnt=%02d",
229 pvr2_buffer_state_decode(bp->state), 225 pvr2_buffer_state_decode(bp->state),
230 sp->i_bcount,sp->i_count); 226 sp->i_bcount,sp->i_count);
231 spin_unlock_irqrestore(&sp->list_lock,irq_flags); 227 spin_unlock_irqrestore(&sp->list_lock,irq_flags);
@@ -249,8 +245,7 @@ static void pvr2_buffer_set_queued(struct pvr2_buffer *bp)
249 (sp->q_count)++; 245 (sp->q_count)++;
250 sp->q_bcount += bp->max_count; 246 sp->q_bcount += bp->max_count;
251 pvr2_trace(PVR2_TRACE_BUF_FLOW, 247 pvr2_trace(PVR2_TRACE_BUF_FLOW,
252 "/*---TRACE_FLOW---*/" 248 "/*---TRACE_FLOW---*/ bufferPool %8s inc cap=%07d cnt=%02d",
253 " bufferPool %8s inc cap=%07d cnt=%02d",
254 pvr2_buffer_state_decode(bp->state), 249 pvr2_buffer_state_decode(bp->state),
255 sp->q_bcount,sp->q_count); 250 sp->q_bcount,sp->q_count);
256 spin_unlock_irqrestore(&sp->list_lock,irq_flags); 251 spin_unlock_irqrestore(&sp->list_lock,irq_flags);
@@ -293,8 +288,8 @@ static void pvr2_buffer_done(struct pvr2_buffer *bp)
293 bp->signature = 0; 288 bp->signature = 0;
294 bp->stream = NULL; 289 bp->stream = NULL;
295 usb_free_urb(bp->purb); 290 usb_free_urb(bp->purb);
296 pvr2_trace(PVR2_TRACE_BUF_POOL,"/*---TRACE_FLOW---*/" 291 pvr2_trace(PVR2_TRACE_BUF_POOL, "/*---TRACE_FLOW---*/ bufferDone %p",
297 " bufferDone %p",bp); 292 bp);
298} 293}
299 294
300static int pvr2_stream_buffer_count(struct pvr2_stream *sp,unsigned int cnt) 295static int pvr2_stream_buffer_count(struct pvr2_stream *sp,unsigned int cnt)
@@ -306,8 +301,7 @@ static int pvr2_stream_buffer_count(struct pvr2_stream *sp,unsigned int cnt)
306 if (cnt == sp->buffer_total_count) return 0; 301 if (cnt == sp->buffer_total_count) return 0;
307 302
308 pvr2_trace(PVR2_TRACE_BUF_POOL, 303 pvr2_trace(PVR2_TRACE_BUF_POOL,
309 "/*---TRACE_FLOW---*/ poolResize " 304 "/*---TRACE_FLOW---*/ poolResize stream=%p cur=%d adj=%+d",
310 " stream=%p cur=%d adj=%+d",
311 sp, 305 sp,
312 sp->buffer_total_count, 306 sp->buffer_total_count,
313 cnt-sp->buffer_total_count); 307 cnt-sp->buffer_total_count);
@@ -374,8 +368,7 @@ static int pvr2_stream_achieve_buffer_count(struct pvr2_stream *sp)
374 if (sp->buffer_total_count == sp->buffer_target_count) return 0; 368 if (sp->buffer_total_count == sp->buffer_target_count) return 0;
375 369
376 pvr2_trace(PVR2_TRACE_BUF_POOL, 370 pvr2_trace(PVR2_TRACE_BUF_POOL,
377 "/*---TRACE_FLOW---*/" 371 "/*---TRACE_FLOW---*/ poolCheck stream=%p cur=%d tgt=%d",
378 " poolCheck stream=%p cur=%d tgt=%d",
379 sp,sp->buffer_total_count,sp->buffer_target_count); 372 sp,sp->buffer_total_count,sp->buffer_target_count);
380 373
381 if (sp->buffer_total_count < sp->buffer_target_count) { 374 if (sp->buffer_total_count < sp->buffer_target_count) {
@@ -454,8 +447,8 @@ static void buffer_complete(struct urb *urb)
454 bp->used_count = urb->actual_length; 447 bp->used_count = urb->actual_length;
455 if (sp->fail_count) { 448 if (sp->fail_count) {
456 pvr2_trace(PVR2_TRACE_TOLERANCE, 449 pvr2_trace(PVR2_TRACE_TOLERANCE,
457 "stream %p transfer ok" 450 "stream %p transfer ok - fail count reset",
458 " - fail count reset",sp); 451 sp);
459 sp->fail_count = 0; 452 sp->fail_count = 0;
460 } 453 }
461 } else if (sp->fail_count < sp->fail_tolerance) { 454 } else if (sp->fail_count < sp->fail_tolerance) {
@@ -464,8 +457,7 @@ static void buffer_complete(struct urb *urb)
464 (sp->fail_count)++; 457 (sp->fail_count)++;
465 (sp->buffers_failed)++; 458 (sp->buffers_failed)++;
466 pvr2_trace(PVR2_TRACE_TOLERANCE, 459 pvr2_trace(PVR2_TRACE_TOLERANCE,
467 "stream %p ignoring error %d" 460 "stream %p ignoring error %d - fail count increased to %u",
468 " - fail count increased to %u",
469 sp,urb->status,sp->fail_count); 461 sp,urb->status,sp->fail_count);
470 } else { 462 } else {
471 (sp->buffers_failed)++; 463 (sp->buffers_failed)++;
@@ -666,8 +658,7 @@ int pvr2_buffer_set_buffer(struct pvr2_buffer *bp,void *ptr,unsigned int cnt)
666 bp->max_count = cnt; 658 bp->max_count = cnt;
667 bp->stream->i_bcount += bp->max_count; 659 bp->stream->i_bcount += bp->max_count;
668 pvr2_trace(PVR2_TRACE_BUF_FLOW, 660 pvr2_trace(PVR2_TRACE_BUF_FLOW,
669 "/*---TRACE_FLOW---*/ bufferPool " 661 "/*---TRACE_FLOW---*/ bufferPool %8s cap cap=%07d cnt=%02d",
670 " %8s cap cap=%07d cnt=%02d",
671 pvr2_buffer_state_decode( 662 pvr2_buffer_state_decode(
672 pvr2_buffer_state_idle), 663 pvr2_buffer_state_idle),
673 bp->stream->i_bcount,bp->stream->i_count); 664 bp->stream->i_bcount,bp->stream->i_count);
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-ioread.c b/drivers/media/usb/pvrusb2/pvrusb2-ioread.c
index 614d55767a4e..70b8a052eb5b 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-ioread.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-ioread.c
@@ -169,9 +169,7 @@ static int pvr2_ioread_start(struct pvr2_ioread *cp)
169 stat = pvr2_buffer_queue(bp); 169 stat = pvr2_buffer_queue(bp);
170 if (stat < 0) { 170 if (stat < 0) {
171 pvr2_trace(PVR2_TRACE_DATA_FLOW, 171 pvr2_trace(PVR2_TRACE_DATA_FLOW,
172 "/*---TRACE_READ---*/" 172 "/*---TRACE_READ---*/ pvr2_ioread_start id=%p error=%d",
173 " pvr2_ioread_start id=%p"
174 " error=%d",
175 cp,stat); 173 cp,stat);
176 pvr2_ioread_stop(cp); 174 pvr2_ioread_stop(cp);
177 return stat; 175 return stat;
@@ -209,8 +207,8 @@ int pvr2_ioread_setup(struct pvr2_ioread *cp,struct pvr2_stream *sp)
209 do { 207 do {
210 if (cp->stream) { 208 if (cp->stream) {
211 pvr2_trace(PVR2_TRACE_START_STOP, 209 pvr2_trace(PVR2_TRACE_START_STOP,
212 "/*---TRACE_READ---*/" 210 "/*---TRACE_READ---*/ pvr2_ioread_setup (tear-down) id=%p",
213 " pvr2_ioread_setup (tear-down) id=%p",cp); 211 cp);
214 pvr2_ioread_stop(cp); 212 pvr2_ioread_stop(cp);
215 pvr2_stream_kill(cp->stream); 213 pvr2_stream_kill(cp->stream);
216 if (pvr2_stream_get_buffer_count(cp->stream)) { 214 if (pvr2_stream_get_buffer_count(cp->stream)) {
@@ -220,8 +218,8 @@ int pvr2_ioread_setup(struct pvr2_ioread *cp,struct pvr2_stream *sp)
220 } 218 }
221 if (sp) { 219 if (sp) {
222 pvr2_trace(PVR2_TRACE_START_STOP, 220 pvr2_trace(PVR2_TRACE_START_STOP,
223 "/*---TRACE_READ---*/" 221 "/*---TRACE_READ---*/ pvr2_ioread_setup (setup) id=%p",
224 " pvr2_ioread_setup (setup) id=%p",cp); 222 cp);
225 pvr2_stream_kill(sp); 223 pvr2_stream_kill(sp);
226 ret = pvr2_stream_set_buffer_count(sp,BUFFER_COUNT); 224 ret = pvr2_stream_set_buffer_count(sp,BUFFER_COUNT);
227 if (ret < 0) { 225 if (ret < 0) {
@@ -270,9 +268,7 @@ static int pvr2_ioread_get_buffer(struct pvr2_ioread *cp)
270 if (stat < 0) { 268 if (stat < 0) {
271 // Streaming error... 269 // Streaming error...
272 pvr2_trace(PVR2_TRACE_DATA_FLOW, 270 pvr2_trace(PVR2_TRACE_DATA_FLOW,
273 "/*---TRACE_READ---*/" 271 "/*---TRACE_READ---*/ pvr2_ioread_read id=%p queue_error=%d",
274 " pvr2_ioread_read id=%p"
275 " queue_error=%d",
276 cp,stat); 272 cp,stat);
277 pvr2_ioread_stop(cp); 273 pvr2_ioread_stop(cp);
278 return 0; 274 return 0;
@@ -292,9 +288,7 @@ static int pvr2_ioread_get_buffer(struct pvr2_ioread *cp)
292 if (stat < 0) { 288 if (stat < 0) {
293 // Streaming error... 289 // Streaming error...
294 pvr2_trace(PVR2_TRACE_DATA_FLOW, 290 pvr2_trace(PVR2_TRACE_DATA_FLOW,
295 "/*---TRACE_READ---*/" 291 "/*---TRACE_READ---*/ pvr2_ioread_read id=%p buffer_error=%d",
296 " pvr2_ioread_read id=%p"
297 " buffer_error=%d",
298 cp,stat); 292 cp,stat);
299 pvr2_ioread_stop(cp); 293 pvr2_ioread_stop(cp);
300 // Give up. 294 // Give up.
@@ -347,8 +341,7 @@ static void pvr2_ioread_filter(struct pvr2_ioread *cp)
347 if (cp->sync_buf_offs >= cp->sync_key_len) { 341 if (cp->sync_buf_offs >= cp->sync_key_len) {
348 cp->sync_trashed_count -= cp->sync_key_len; 342 cp->sync_trashed_count -= cp->sync_key_len;
349 pvr2_trace(PVR2_TRACE_DATA_FLOW, 343 pvr2_trace(PVR2_TRACE_DATA_FLOW,
350 "/*---TRACE_READ---*/" 344 "/*---TRACE_READ---*/ sync_state <== 2 (skipped %u bytes)",
351 " sync_state <== 2 (skipped %u bytes)",
352 cp->sync_trashed_count); 345 cp->sync_trashed_count);
353 cp->sync_state = 2; 346 cp->sync_state = 2;
354 cp->sync_buf_offs = 0; 347 cp->sync_buf_offs = 0;
@@ -358,8 +351,7 @@ static void pvr2_ioread_filter(struct pvr2_ioread *cp)
358 if (cp->c_data_offs < cp->c_data_len) { 351 if (cp->c_data_offs < cp->c_data_len) {
359 // Sanity check - should NEVER get here 352 // Sanity check - should NEVER get here
360 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 353 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
361 "ERROR: pvr2_ioread filter sync problem" 354 "ERROR: pvr2_ioread filter sync problem len=%u offs=%u",
362 " len=%u offs=%u",
363 cp->c_data_len,cp->c_data_offs); 355 cp->c_data_len,cp->c_data_offs);
364 // Get out so we don't get stuck in an infinite 356 // Get out so we don't get stuck in an infinite
365 // loop. 357 // loop.
@@ -418,8 +410,8 @@ int pvr2_ioread_read(struct pvr2_ioread *cp,void __user *buf,unsigned int cnt)
418 410
419 if (!cnt) { 411 if (!cnt) {
420 pvr2_trace(PVR2_TRACE_TRAP, 412 pvr2_trace(PVR2_TRACE_TRAP,
421 "/*---TRACE_READ---*/ pvr2_ioread_read id=%p" 413 "/*---TRACE_READ---*/ pvr2_ioread_read id=%p ZERO Request? Returning zero.",
422 " ZERO Request? Returning zero.",cp); 414cp);
423 return 0; 415 return 0;
424 } 416 }
425 417
@@ -477,8 +469,7 @@ int pvr2_ioread_read(struct pvr2_ioread *cp,void __user *buf,unsigned int cnt)
477 // Consumed entire key; switch mode 469 // Consumed entire key; switch mode
478 // to normal. 470 // to normal.
479 pvr2_trace(PVR2_TRACE_DATA_FLOW, 471 pvr2_trace(PVR2_TRACE_DATA_FLOW,
480 "/*---TRACE_READ---*/" 472 "/*---TRACE_READ---*/ sync_state <== 0");
481 " sync_state <== 0");
482 cp->sync_state = 0; 473 cp->sync_state = 0;
483 } 474 }
484 } else { 475 } else {
@@ -502,8 +493,7 @@ int pvr2_ioread_read(struct pvr2_ioread *cp,void __user *buf,unsigned int cnt)
502 } 493 }
503 494
504 pvr2_trace(PVR2_TRACE_DATA_FLOW, 495 pvr2_trace(PVR2_TRACE_DATA_FLOW,
505 "/*---TRACE_READ---*/ pvr2_ioread_read" 496 "/*---TRACE_READ---*/ pvr2_ioread_read id=%p request=%d result=%d",
506 " id=%p request=%d result=%d",
507 cp,req_cnt,ret); 497 cp,req_cnt,ret);
508 return ret; 498 return ret;
509} 499}
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-std.c b/drivers/media/usb/pvrusb2/pvrusb2-std.c
index 9a596a3a4c27..cd7bc18a1ba2 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-std.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-std.c
@@ -357,8 +357,7 @@ struct v4l2_standard *pvr2_std_create_enum(unsigned int *countptr,
357 bcnt = pvr2_std_id_to_str(buf,sizeof(buf),fmsk); 357 bcnt = pvr2_std_id_to_str(buf,sizeof(buf),fmsk);
358 pvr2_trace( 358 pvr2_trace(
359 PVR2_TRACE_ERROR_LEGS, 359 PVR2_TRACE_ERROR_LEGS,
360 "WARNING:" 360 "WARNING: Failed to classify the following standard(s): %.*s",
361 " Failed to classify the following standard(s): %.*s",
362 bcnt,buf); 361 bcnt,buf);
363 } 362 }
364 363
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c b/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c
index 06fe63ced58c..d977976b8d91 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c
@@ -116,7 +116,6 @@ static ssize_t show_type(struct device *class_dev,
116 } 116 }
117 pvr2_sysfs_trace("pvr2_sysfs(%p) show_type(cid=%d) is %s", 117 pvr2_sysfs_trace("pvr2_sysfs(%p) show_type(cid=%d) is %s",
118 cip->chptr, cip->ctl_id, name); 118 cip->chptr, cip->ctl_id, name);
119 if (!name) return -EINVAL;
120 return scnprintf(buf, PAGE_SIZE, "%s\n", name); 119 return scnprintf(buf, PAGE_SIZE, "%s\n", name);
121} 120}
122 121
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
index 2cc4d2b6f810..bbbe18d5275a 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
@@ -949,8 +949,8 @@ static long pvr2_v4l2_ioctl(struct file *file,
949 if (ret < 0) { 949 if (ret < 0) {
950 if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) { 950 if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) {
951 pvr2_trace(PVR2_TRACE_V4LIOCTL, 951 pvr2_trace(PVR2_TRACE_V4LIOCTL,
952 "pvr2_v4l2_do_ioctl failure, ret=%ld" 952 "pvr2_v4l2_do_ioctl failure, ret=%ld command was:",
953 " command was:", ret); 953ret);
954 v4l_printk_ioctl(pvr2_hdw_get_driver_name(hdw), cmd); 954 v4l_printk_ioctl(pvr2_hdw_get_driver_name(hdw), cmd);
955 } 955 }
956 } else { 956 } else {
@@ -1254,8 +1254,7 @@ static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip,
1254 nr_ptr = video_nr; 1254 nr_ptr = video_nr;
1255 if (!dip->stream) { 1255 if (!dip->stream) {
1256 pr_err(KBUILD_MODNAME 1256 pr_err(KBUILD_MODNAME
1257 ": Failed to set up pvrusb2 v4l video dev" 1257 ": Failed to set up pvrusb2 v4l video dev due to missing stream instance\n");
1258 " due to missing stream instance\n");
1259 return; 1258 return;
1260 } 1259 }
1261 break; 1260 break;
@@ -1272,8 +1271,7 @@ static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip,
1272 break; 1271 break;
1273 default: 1272 default:
1274 /* Bail out (this should be impossible) */ 1273 /* Bail out (this should be impossible) */
1275 pr_err(KBUILD_MODNAME ": Failed to set up pvrusb2 v4l dev" 1274 pr_err(KBUILD_MODNAME ": Failed to set up pvrusb2 v4l dev due to unrecognized config\n");
1276 " due to unrecognized config\n");
1277 return; 1275 return;
1278 } 1276 }
1279 1277
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-video-v4l.c b/drivers/media/usb/pvrusb2/pvrusb2-video-v4l.c
index 105123ab36aa..6fee367139aa 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-video-v4l.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-video-v4l.c
@@ -91,9 +91,7 @@ void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
91 (hdw->input_val < 0) || 91 (hdw->input_val < 0) ||
92 (hdw->input_val >= sp->cnt)) { 92 (hdw->input_val >= sp->cnt)) {
93 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 93 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
94 "*** WARNING *** subdev v4l2 set_input:" 94 "*** WARNING *** subdev v4l2 set_input: Invalid routing scheme (%u) and/or input (%d)",
95 " Invalid routing scheme (%u)"
96 " and/or input (%d)",
97 sid, hdw->input_val); 95 sid, hdw->input_val);
98 return; 96 return;
99 } 97 }
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-wm8775.c b/drivers/media/usb/pvrusb2/pvrusb2-wm8775.c
index f1df94a2436f..7993983de5a6 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-wm8775.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-wm8775.c
@@ -49,8 +49,7 @@ void pvr2_wm8775_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
49 input = 2; 49 input = 2;
50 break; 50 break;
51 } 51 }
52 pvr2_trace(PVR2_TRACE_CHIPS, "subdev wm8775" 52 pvr2_trace(PVR2_TRACE_CHIPS, "subdev wm8775 set_input(val=%d route=0x%x)",
53 " set_input(val=%d route=0x%x)",
54 hdw->input_val, input); 53 hdw->input_val, input);
55 54
56 sd->ops->audio->s_routing(sd, input, 0, 0); 55 sd->ops->audio->s_routing(sd, input, 0, 0);
diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c
index ff657644b6b3..22420c14ac98 100644
--- a/drivers/media/usb/pwc/pwc-if.c
+++ b/drivers/media/usb/pwc/pwc-if.c
@@ -238,8 +238,8 @@ static void pwc_frame_complete(struct pwc_device *pdev)
238 } else { 238 } else {
239 /* Check for underflow first */ 239 /* Check for underflow first */
240 if (fbuf->filled < pdev->frame_total_size) { 240 if (fbuf->filled < pdev->frame_total_size) {
241 PWC_DEBUG_FLOW("Frame buffer underflow (%d bytes);" 241 PWC_DEBUG_FLOW("Frame buffer underflow (%d bytes); discarded.\n",
242 " discarded.\n", fbuf->filled); 242 fbuf->filled);
243 } else { 243 } else {
244 fbuf->vb.field = V4L2_FIELD_NONE; 244 fbuf->vb.field = V4L2_FIELD_NONE;
245 fbuf->vb.sequence = pdev->vframe_count; 245 fbuf->vb.sequence = pdev->vframe_count;
diff --git a/drivers/media/usb/pwc/pwc-v4l.c b/drivers/media/usb/pwc/pwc-v4l.c
index 3d987984602f..92f04db6bbae 100644
--- a/drivers/media/usb/pwc/pwc-v4l.c
+++ b/drivers/media/usb/pwc/pwc-v4l.c
@@ -406,8 +406,7 @@ static void pwc_vidioc_fill_fmt(struct v4l2_format *f,
406 f->fmt.pix.bytesperline = f->fmt.pix.width; 406 f->fmt.pix.bytesperline = f->fmt.pix.width;
407 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.width * 3 / 2; 407 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.width * 3 / 2;
408 f->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB; 408 f->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
409 PWC_DEBUG_IOCTL("pwc_vidioc_fill_fmt() " 409 PWC_DEBUG_IOCTL("pwc_vidioc_fill_fmt() width=%d, height=%d, bytesperline=%d, sizeimage=%d, pixelformat=%c%c%c%c\n",
410 "width=%d, height=%d, bytesperline=%d, sizeimage=%d, pixelformat=%c%c%c%c\n",
411 f->fmt.pix.width, 410 f->fmt.pix.width,
412 f->fmt.pix.height, 411 f->fmt.pix.height,
413 f->fmt.pix.bytesperline, 412 f->fmt.pix.bytesperline,
@@ -473,8 +472,7 @@ static int pwc_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f)
473 472
474 pixelformat = f->fmt.pix.pixelformat; 473 pixelformat = f->fmt.pix.pixelformat;
475 474
476 PWC_DEBUG_IOCTL("Trying to set format to: width=%d height=%d fps=%d " 475 PWC_DEBUG_IOCTL("Trying to set format to: width=%d height=%d fps=%d format=%c%c%c%c\n",
477 "format=%c%c%c%c\n",
478 f->fmt.pix.width, f->fmt.pix.height, pdev->vframes, 476 f->fmt.pix.width, f->fmt.pix.height, pdev->vframes,
479 (pixelformat)&255, 477 (pixelformat)&255,
480 (pixelformat>>8)&255, 478 (pixelformat>>8)&255,
diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
index c2e25876e93b..a4dcaec31d02 100644
--- a/drivers/media/usb/siano/smsusb.c
+++ b/drivers/media/usb/siano/smsusb.c
@@ -604,8 +604,8 @@ static int smsusb_resume(struct usb_interface *intf)
604 intf->cur_altsetting->desc. 604 intf->cur_altsetting->desc.
605 bInterfaceNumber, 0); 605 bInterfaceNumber, 0);
606 if (rc < 0) { 606 if (rc < 0) {
607 printk(KERN_INFO "%s usb_set_interface failed, " 607 printk(KERN_INFO "%s usb_set_interface failed, rc %d\n",
608 "rc %d\n", __func__, rc); 608 __func__, rc);
609 return rc; 609 return rc;
610 } 610 }
611 } 611 }
diff --git a/drivers/media/usb/stkwebcam/stk-sensor.c b/drivers/media/usb/stkwebcam/stk-sensor.c
index e546b014d7ad..fbccbb2eed9f 100644
--- a/drivers/media/usb/stkwebcam/stk-sensor.c
+++ b/drivers/media/usb/stkwebcam/stk-sensor.c
@@ -228,7 +228,7 @@
228static int stk_sensor_outb(struct stk_camera *dev, u8 reg, u8 val) 228static int stk_sensor_outb(struct stk_camera *dev, u8 reg, u8 val)
229{ 229{
230 int i = 0; 230 int i = 0;
231 int tmpval = 0; 231 u8 tmpval = 0;
232 232
233 if (stk_camera_write_reg(dev, STK_IIC_TX_INDEX, reg)) 233 if (stk_camera_write_reg(dev, STK_IIC_TX_INDEX, reg))
234 return 1; 234 return 1;
@@ -253,7 +253,7 @@ static int stk_sensor_outb(struct stk_camera *dev, u8 reg, u8 val)
253static int stk_sensor_inb(struct stk_camera *dev, u8 reg, u8 *val) 253static int stk_sensor_inb(struct stk_camera *dev, u8 reg, u8 *val)
254{ 254{
255 int i = 0; 255 int i = 0;
256 int tmpval = 0; 256 u8 tmpval = 0;
257 257
258 if (stk_camera_write_reg(dev, STK_IIC_RX_INDEX, reg)) 258 if (stk_camera_write_reg(dev, STK_IIC_RX_INDEX, reg))
259 return 1; 259 return 1;
@@ -274,7 +274,7 @@ static int stk_sensor_inb(struct stk_camera *dev, u8 reg, u8 *val)
274 if (stk_camera_read_reg(dev, STK_IIC_RX_VALUE, &tmpval)) 274 if (stk_camera_read_reg(dev, STK_IIC_RX_VALUE, &tmpval))
275 return 1; 275 return 1;
276 276
277 *val = (u8) tmpval; 277 *val = tmpval;
278 return 0; 278 return 0;
279} 279}
280 280
@@ -391,8 +391,8 @@ int stk_sensor_init(struct stk_camera *dev)
391 } 391 }
392 stk_sensor_write_regvals(dev, ov_initvals); 392 stk_sensor_write_regvals(dev, ov_initvals);
393 msleep(10); 393 msleep(10);
394 STK_INFO("OmniVision sensor detected, id %02X%02X" 394 STK_INFO("OmniVision sensor detected, id %02X%02X at address %x\n",
395 " at address %x\n", idh, idl, SENSOR_ADDRESS); 395 idh, idl, SENSOR_ADDRESS);
396 return 0; 396 return 0;
397} 397}
398 398
diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c
index 22a9aae16291..a212248bc2a3 100644
--- a/drivers/media/usb/stkwebcam/stk-webcam.c
+++ b/drivers/media/usb/stkwebcam/stk-webcam.c
@@ -144,7 +144,7 @@ int stk_camera_write_reg(struct stk_camera *dev, u16 index, u8 value)
144 return 0; 144 return 0;
145} 145}
146 146
147int stk_camera_read_reg(struct stk_camera *dev, u16 index, int *value) 147int stk_camera_read_reg(struct stk_camera *dev, u16 index, u8 *value)
148{ 148{
149 struct usb_device *udev = dev->udev; 149 struct usb_device *udev = dev->udev;
150 unsigned char *buf; 150 unsigned char *buf;
@@ -163,7 +163,7 @@ int stk_camera_read_reg(struct stk_camera *dev, u16 index, int *value)
163 sizeof(u8), 163 sizeof(u8),
164 500); 164 500);
165 if (ret >= 0) 165 if (ret >= 0)
166 memcpy(value, buf, sizeof(u8)); 166 *value = *buf;
167 167
168 kfree(buf); 168 kfree(buf);
169 return ret; 169 return ret;
@@ -171,9 +171,10 @@ int stk_camera_read_reg(struct stk_camera *dev, u16 index, int *value)
171 171
172static int stk_start_stream(struct stk_camera *dev) 172static int stk_start_stream(struct stk_camera *dev)
173{ 173{
174 int value; 174 u8 value;
175 int i, ret; 175 int i, ret;
176 int value_116, value_117; 176 u8 value_116, value_117;
177
177 178
178 if (!is_present(dev)) 179 if (!is_present(dev))
179 return -ENODEV; 180 return -ENODEV;
@@ -213,7 +214,7 @@ static int stk_start_stream(struct stk_camera *dev)
213 214
214static int stk_stop_stream(struct stk_camera *dev) 215static int stk_stop_stream(struct stk_camera *dev)
215{ 216{
216 int value; 217 u8 value;
217 int i; 218 int i;
218 if (is_present(dev)) { 219 if (is_present(dev)) {
219 stk_camera_read_reg(dev, 0x0100, &value); 220 stk_camera_read_reg(dev, 0x0100, &value);
@@ -372,8 +373,7 @@ static void stk_isoc_handler(struct urb *urb)
372 if (fb->v4lbuf.bytesused != 0 373 if (fb->v4lbuf.bytesused != 0
373 && fb->v4lbuf.bytesused != dev->frame_size) { 374 && fb->v4lbuf.bytesused != dev->frame_size) {
374 (void) (printk_ratelimit() && 375 (void) (printk_ratelimit() &&
375 STK_ERROR("frame %d, " 376 STK_ERROR("frame %d, bytesused=%d, skipping\n",
376 "bytesused=%d, skipping\n",
377 i, fb->v4lbuf.bytesused)); 377 i, fb->v4lbuf.bytesused));
378 fb->v4lbuf.bytesused = 0; 378 fb->v4lbuf.bytesused = 0;
379 fill = fb->buffer; 379 fill = fb->buffer;
diff --git a/drivers/media/usb/stkwebcam/stk-webcam.h b/drivers/media/usb/stkwebcam/stk-webcam.h
index 9bbfa3d9bfdd..92bb48e3c74e 100644
--- a/drivers/media/usb/stkwebcam/stk-webcam.h
+++ b/drivers/media/usb/stkwebcam/stk-webcam.h
@@ -129,7 +129,7 @@ struct stk_camera {
129#define vdev_to_camera(d) container_of(d, struct stk_camera, vdev) 129#define vdev_to_camera(d) container_of(d, struct stk_camera, vdev)
130 130
131int stk_camera_write_reg(struct stk_camera *, u16, u8); 131int stk_camera_write_reg(struct stk_camera *, u16, u8);
132int stk_camera_read_reg(struct stk_camera *, u16, int *); 132int stk_camera_read_reg(struct stk_camera *, u16, u8 *);
133 133
134int stk_sensor_init(struct stk_camera *); 134int stk_sensor_init(struct stk_camera *);
135int stk_sensor_configure(struct stk_camera *); 135int stk_sensor_configure(struct stk_camera *);
diff --git a/drivers/media/usb/tm6000/tm6000-alsa.c b/drivers/media/usb/tm6000/tm6000-alsa.c
index f16fbd1f9f51..422322541af6 100644
--- a/drivers/media/usb/tm6000/tm6000-alsa.c
+++ b/drivers/media/usb/tm6000/tm6000-alsa.c
@@ -58,9 +58,7 @@ MODULE_PARM_DESC(index, "Index value for tm6000x capture interface(s).");
58MODULE_DESCRIPTION("ALSA driver module for tm5600/tm6000/tm6010 based TV cards"); 58MODULE_DESCRIPTION("ALSA driver module for tm5600/tm6000/tm6010 based TV cards");
59MODULE_AUTHOR("Mauro Carvalho Chehab"); 59MODULE_AUTHOR("Mauro Carvalho Chehab");
60MODULE_LICENSE("GPL"); 60MODULE_LICENSE("GPL");
61MODULE_SUPPORTED_DEVICE("{{Trident,tm5600}," 61MODULE_SUPPORTED_DEVICE("{{Trident,tm5600},{{Trident,tm6000},{{Trident,tm6010}");
62 "{{Trident,tm6000},"
63 "{{Trident,tm6010}");
64static unsigned int debug; 62static unsigned int debug;
65module_param(debug, int, 0644); 63module_param(debug, int, 0644);
66MODULE_PARM_DESC(debug, "enable debug messages"); 64MODULE_PARM_DESC(debug, "enable debug messages");
diff --git a/drivers/media/usb/tm6000/tm6000-core.c b/drivers/media/usb/tm6000/tm6000-core.c
index 7c32353c59db..8d104e5c4be3 100644
--- a/drivers/media/usb/tm6000/tm6000-core.c
+++ b/drivers/media/usb/tm6000/tm6000-core.c
@@ -602,8 +602,8 @@ int tm6000_init(struct tm6000_core *dev)
602 for (i = 0; i < size; i++) { 602 for (i = 0; i < size; i++) {
603 rc = tm6000_set_reg(dev, tab[i].req, tab[i].reg, tab[i].val); 603 rc = tm6000_set_reg(dev, tab[i].req, tab[i].reg, tab[i].val);
604 if (rc < 0) { 604 if (rc < 0) {
605 printk(KERN_ERR "Error %i while setting req %d, " 605 printk(KERN_ERR "Error %i while setting req %d, reg %d to value %d\n",
606 "reg %d to value %d\n", rc, 606 rc,
607 tab[i].req, tab[i].reg, tab[i].val); 607 tab[i].req, tab[i].reg, tab[i].val);
608 return rc; 608 return rc;
609 } 609 }
@@ -761,9 +761,8 @@ int tm6000_tvaudio_set_mute(struct tm6000_core *dev, u8 mute)
761 if (dev->dev_type == TM6010) 761 if (dev->dev_type == TM6010)
762 tm6010_set_mute_sif(dev, mute); 762 tm6010_set_mute_sif(dev, mute);
763 else { 763 else {
764 printk(KERN_INFO "ERROR: TM5600 and TM6000 don't has" 764 printk(KERN_INFO "ERROR: TM5600 and TM6000 don't has SIF audio inputs. Please check the %s configuration.\n",
765 " SIF audio inputs. Please check the %s" 765 dev->name);
766 " configuration.\n", dev->name);
767 return -EINVAL; 766 return -EINVAL;
768 } 767 }
769 break; 768 break;
@@ -822,9 +821,8 @@ void tm6000_set_volume(struct tm6000_core *dev, int vol)
822 if (dev->dev_type == TM6010) 821 if (dev->dev_type == TM6010)
823 tm6010_set_volume_sif(dev, vol); 822 tm6010_set_volume_sif(dev, vol);
824 else 823 else
825 printk(KERN_INFO "ERROR: TM5600 and TM6000 don't has" 824 printk(KERN_INFO "ERROR: TM5600 and TM6000 don't has SIF audio inputs. Please check the %s configuration.\n",
826 " SIF audio inputs. Please check the %s" 825 dev->name);
827 " configuration.\n", dev->name);
828 break; 826 break;
829 case TM6000_AMUX_ADC1: 827 case TM6000_AMUX_ADC1:
830 case TM6000_AMUX_ADC2: 828 case TM6000_AMUX_ADC2:
diff --git a/drivers/media/usb/tm6000/tm6000-dvb.c b/drivers/media/usb/tm6000/tm6000-dvb.c
index 0426b210383b..70dbaec1219e 100644
--- a/drivers/media/usb/tm6000/tm6000-dvb.c
+++ b/drivers/media/usb/tm6000/tm6000-dvb.c
@@ -35,9 +35,7 @@ MODULE_DESCRIPTION("DVB driver extension module for tm5600/6000/6010 based TV ca
35MODULE_AUTHOR("Mauro Carvalho Chehab"); 35MODULE_AUTHOR("Mauro Carvalho Chehab");
36MODULE_LICENSE("GPL"); 36MODULE_LICENSE("GPL");
37 37
38MODULE_SUPPORTED_DEVICE("{{Trident, tm5600}," 38MODULE_SUPPORTED_DEVICE("{{Trident, tm5600},{{Trident, tm6000},{{Trident, tm6010}");
39 "{{Trident, tm6000},"
40 "{{Trident, tm6010}");
41 39
42static int debug; 40static int debug;
43 41
@@ -292,13 +290,11 @@ static int register_dvb(struct tm6000_core *dev)
292 } 290 }
293 291
294 if (!dvb_attach(xc2028_attach, dvb->frontend, &cfg)) { 292 if (!dvb_attach(xc2028_attach, dvb->frontend, &cfg)) {
295 printk(KERN_ERR "tm6000: couldn't register " 293 printk(KERN_ERR "tm6000: couldn't register frontend (xc3028)\n");
296 "frontend (xc3028)\n");
297 ret = -EINVAL; 294 ret = -EINVAL;
298 goto frontend_err; 295 goto frontend_err;
299 } 296 }
300 printk(KERN_INFO "tm6000: XC2028/3028 asked to be " 297 printk(KERN_INFO "tm6000: XC2028/3028 asked to be attached to frontend!\n");
301 "attached to frontend!\n");
302 break; 298 break;
303 } 299 }
304 case TUNER_XC5000: { 300 case TUNER_XC5000: {
@@ -315,13 +311,11 @@ static int register_dvb(struct tm6000_core *dev)
315 } 311 }
316 312
317 if (!dvb_attach(xc5000_attach, dvb->frontend, &dev->i2c_adap, &cfg)) { 313 if (!dvb_attach(xc5000_attach, dvb->frontend, &dev->i2c_adap, &cfg)) {
318 printk(KERN_ERR "tm6000: couldn't register " 314 printk(KERN_ERR "tm6000: couldn't register frontend (xc5000)\n");
319 "frontend (xc5000)\n");
320 ret = -EINVAL; 315 ret = -EINVAL;
321 goto frontend_err; 316 goto frontend_err;
322 } 317 }
323 printk(KERN_INFO "tm6000: XC5000 asked to be " 318 printk(KERN_INFO "tm6000: XC5000 asked to be attached to frontend!\n");
324 "attached to frontend!\n");
325 break; 319 break;
326 } 320 }
327 } 321 }
diff --git a/drivers/media/usb/tm6000/tm6000-i2c.c b/drivers/media/usb/tm6000/tm6000-i2c.c
index c7e23e3dd75e..b01d3ee56e77 100644
--- a/drivers/media/usb/tm6000/tm6000-i2c.c
+++ b/drivers/media/usb/tm6000/tm6000-i2c.c
@@ -173,8 +173,7 @@ static int tm6000_i2c_xfer(struct i2c_adapter *i2c_adap,
173 * immediately after a 1 or 2 byte write to select 173 * immediately after a 1 or 2 byte write to select
174 * a register. We cannot fulfil this request. 174 * a register. We cannot fulfil this request.
175 */ 175 */
176 i2c_dprintk(2, " read without preceding write not" 176 i2c_dprintk(2, " read without preceding write not supported");
177 " supported");
178 rc = -EOPNOTSUPP; 177 rc = -EOPNOTSUPP;
179 goto err; 178 goto err;
180 } else if (i + 1 < num && msgs[i].len <= 2 && 179 } else if (i + 1 < num && msgs[i].len <= 2 &&
diff --git a/drivers/media/usb/tm6000/tm6000-stds.c b/drivers/media/usb/tm6000/tm6000-stds.c
index 93a4b2434b6e..4064a5e8fae1 100644
--- a/drivers/media/usb/tm6000/tm6000-stds.c
+++ b/drivers/media/usb/tm6000/tm6000-stds.c
@@ -464,8 +464,7 @@ static int tm6000_load_std(struct tm6000_core *dev, struct tm6000_reg_settings *
464 for (i = 0; set[i].req; i++) { 464 for (i = 0; set[i].req; i++) {
465 rc = tm6000_set_reg(dev, set[i].req, set[i].reg, set[i].value); 465 rc = tm6000_set_reg(dev, set[i].req, set[i].reg, set[i].value);
466 if (rc < 0) { 466 if (rc < 0) {
467 printk(KERN_ERR "Error %i while setting " 467 printk(KERN_ERR "Error %i while setting req %d, reg %d to value %d\n",
468 "req %d, reg %d to value %d\n",
469 rc, set[i].req, set[i].reg, set[i].value); 468 rc, set[i].req, set[i].reg, set[i].value);
470 return rc; 469 return rc;
471 } 470 }
diff --git a/drivers/media/usb/tm6000/tm6000-video.c b/drivers/media/usb/tm6000/tm6000-video.c
index dee7e7d3d47d..d9f3fa5db8dd 100644
--- a/drivers/media/usb/tm6000/tm6000-video.c
+++ b/drivers/media/usb/tm6000/tm6000-video.c
@@ -615,8 +615,7 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev)
615 return -ENOMEM; 615 return -ENOMEM;
616 } 616 }
617 617
618 dprintk(dev, V4L2_DEBUG_QUEUE, "Allocating %d x %d packets" 618 dprintk(dev, V4L2_DEBUG_QUEUE, "Allocating %d x %d packets (%d bytes) of %d bytes each to handle %u size\n",
619 " (%d bytes) of %d bytes each to handle %u size\n",
620 max_packets, num_bufs, sb_size, 619 max_packets, num_bufs, sb_size,
621 dev->isoc_in.maxsize, size); 620 dev->isoc_in.maxsize, size);
622 621
@@ -939,8 +938,8 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
939 938
940 fmt = format_by_fourcc(f->fmt.pix.pixelformat); 939 fmt = format_by_fourcc(f->fmt.pix.pixelformat);
941 if (NULL == fmt) { 940 if (NULL == fmt) {
942 dprintk(dev, 2, "Fourcc format (0x%08x)" 941 dprintk(dev, 2, "Fourcc format (0x%08x) invalid.\n",
943 " invalid.\n", f->fmt.pix.pixelformat); 942 f->fmt.pix.pixelformat);
944 return -EINVAL; 943 return -EINVAL;
945 } 944 }
946 945
@@ -1366,14 +1365,13 @@ static int __tm6000_open(struct file *file)
1366 fh->width = dev->width; 1365 fh->width = dev->width;
1367 fh->height = dev->height; 1366 fh->height = dev->height;
1368 1367
1369 dprintk(dev, V4L2_DEBUG_OPEN, "Open: fh=0x%08lx, dev=0x%08lx, " 1368 dprintk(dev, V4L2_DEBUG_OPEN, "Open: fh=0x%08lx, dev=0x%08lx, dev->vidq=0x%08lx\n",
1370 "dev->vidq=0x%08lx\n",
1371 (unsigned long)fh, (unsigned long)dev, 1369 (unsigned long)fh, (unsigned long)dev,
1372 (unsigned long)&dev->vidq); 1370 (unsigned long)&dev->vidq);
1373 dprintk(dev, V4L2_DEBUG_OPEN, "Open: list_empty " 1371 dprintk(dev, V4L2_DEBUG_OPEN, "Open: list_empty queued=%d\n",
1374 "queued=%d\n", list_empty(&dev->vidq.queued)); 1372 list_empty(&dev->vidq.queued));
1375 dprintk(dev, V4L2_DEBUG_OPEN, "Open: list_empty " 1373 dprintk(dev, V4L2_DEBUG_OPEN, "Open: list_empty active=%d\n",
1376 "active=%d\n", list_empty(&dev->vidq.active)); 1374 list_empty(&dev->vidq.active));
1377 1375
1378 /* initialize hardware on analog mode */ 1376 /* initialize hardware on analog mode */
1379 rc = tm6000_init_analog_mode(dev); 1377 rc = tm6000_init_analog_mode(dev);
diff --git a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c
index d52d4a8d39ad..361e40b56045 100644
--- a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c
+++ b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c
@@ -767,8 +767,7 @@ static void ttusb_iso_irq(struct urb *urb)
767 for (i = 0; i < urb->number_of_packets; ++i) { 767 for (i = 0; i < urb->number_of_packets; ++i) {
768 numpkt++; 768 numpkt++;
769 if (time_after_eq(jiffies, lastj + HZ)) { 769 if (time_after_eq(jiffies, lastj + HZ)) {
770 dprintk("frames/s: %lu (ts: %d, stuff %d, " 770 dprintk("frames/s: %lu (ts: %d, stuff %d, sec: %d, invalid: %d, all: %d)\n",
771 "sec: %d, invalid: %d, all: %d)\n",
772 numpkt * HZ / (jiffies - lastj), 771 numpkt * HZ / (jiffies - lastj),
773 numts, numstuff, numsec, numinvalid, 772 numts, numstuff, numsec, numinvalid,
774 numts + numstuff + numsec + numinvalid); 773 numts + numstuff + numsec + numinvalid);
diff --git a/drivers/media/usb/ttusb-dec/ttusb_dec.c b/drivers/media/usb/ttusb-dec/ttusb_dec.c
index 4e7671a3a1e4..fc0219f1b7df 100644
--- a/drivers/media/usb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/usb/ttusb-dec/ttusb_dec.c
@@ -36,7 +36,6 @@
36 36
37#include "dmxdev.h" 37#include "dmxdev.h"
38#include "dvb_demux.h" 38#include "dvb_demux.h"
39#include "dvb_filter.h"
40#include "dvb_frontend.h" 39#include "dvb_frontend.h"
41#include "dvb_net.h" 40#include "dvb_net.h"
42#include "ttusbdecfe.h" 41#include "ttusbdecfe.h"
@@ -92,6 +91,15 @@ enum ttusb_dec_interface {
92 TTUSB_DEC_INTERFACE_OUT 91 TTUSB_DEC_INTERFACE_OUT
93}; 92};
94 93
94typedef int (dvb_filter_pes2ts_cb_t) (void *, unsigned char *);
95
96struct dvb_filter_pes2ts {
97 unsigned char buf[188];
98 unsigned char cc;
99 dvb_filter_pes2ts_cb_t *cb;
100 void *priv;
101};
102
95struct ttusb_dec { 103struct ttusb_dec {
96 enum ttusb_dec_model model; 104 enum ttusb_dec_model model;
97 char *model_name; 105 char *model_name;
@@ -201,6 +209,54 @@ static u16 rc_keys[] = {
201 KEY_RADIO 209 KEY_RADIO
202}; 210};
203 211
212static void dvb_filter_pes2ts_init(struct dvb_filter_pes2ts *p2ts,
213 unsigned short pid,
214 dvb_filter_pes2ts_cb_t *cb, void *priv)
215{
216 unsigned char *buf=p2ts->buf;
217
218 buf[0]=0x47;
219 buf[1]=(pid>>8);
220 buf[2]=pid&0xff;
221 p2ts->cc=0;
222 p2ts->cb=cb;
223 p2ts->priv=priv;
224}
225
226static int dvb_filter_pes2ts(struct dvb_filter_pes2ts *p2ts,
227 unsigned char *pes, int len, int payload_start)
228{
229 unsigned char *buf=p2ts->buf;
230 int ret=0, rest;
231
232 //len=6+((pes[4]<<8)|pes[5]);
233
234 if (payload_start)
235 buf[1]|=0x40;
236 else
237 buf[1]&=~0x40;
238 while (len>=184) {
239 buf[3]=0x10|((p2ts->cc++)&0x0f);
240 memcpy(buf+4, pes, 184);
241 if ((ret=p2ts->cb(p2ts->priv, buf)))
242 return ret;
243 len-=184; pes+=184;
244 buf[1]&=~0x40;
245 }
246 if (!len)
247 return 0;
248 buf[3]=0x30|((p2ts->cc++)&0x0f);
249 rest=183-len;
250 if (rest) {
251 buf[5]=0x00;
252 if (rest-1)
253 memset(buf+6, 0xff, rest-1);
254 }
255 buf[4]=rest;
256 memcpy(buf+5+rest, pes, len);
257 return p2ts->cb(p2ts->priv, buf);
258}
259
204static void ttusb_dec_set_model(struct ttusb_dec *dec, 260static void ttusb_dec_set_model(struct ttusb_dec *dec,
205 enum ttusb_dec_model model); 261 enum ttusb_dec_model model);
206 262
@@ -273,7 +329,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,
273 int param_length, const u8 params[], 329 int param_length, const u8 params[],
274 int *result_length, u8 cmd_result[]) 330 int *result_length, u8 cmd_result[])
275{ 331{
276 int result, actual_len, i; 332 int result, actual_len;
277 u8 *b; 333 u8 *b;
278 334
279 dprintk("%s\n", __func__); 335 dprintk("%s\n", __func__);
@@ -297,10 +353,8 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,
297 memcpy(&b[4], params, param_length); 353 memcpy(&b[4], params, param_length);
298 354
299 if (debug) { 355 if (debug) {
300 printk("%s: command: ", __func__); 356 printk(KERN_DEBUG "%s: command: %*ph\n",
301 for (i = 0; i < param_length + 4; i++) 357 __func__, param_length, b);
302 printk("0x%02X ", b[i]);
303 printk("\n");
304 } 358 }
305 359
306 result = usb_bulk_msg(dec->udev, dec->command_pipe, b, 360 result = usb_bulk_msg(dec->udev, dec->command_pipe, b,
@@ -325,10 +379,8 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,
325 return result; 379 return result;
326 } else { 380 } else {
327 if (debug) { 381 if (debug) {
328 printk("%s: result: ", __func__); 382 printk(KERN_DEBUG "%s: result: %*ph\n",
329 for (i = 0; i < actual_len; i++) 383 __func__, actual_len, b);
330 printk("0x%02X ", b[i]);
331 printk("\n");
332 } 384 }
333 385
334 if (result_length) 386 if (result_length)
@@ -652,8 +704,8 @@ static void ttusb_dec_process_urb_frame(struct ttusb_dec *dec, u8 *b,
652 dec->packet_payload_length = 2; 704 dec->packet_payload_length = 2;
653 dec->packet_state = 7; 705 dec->packet_state = 7;
654 } else { 706 } else {
655 printk("%s: unknown packet type: " 707 printk("%s: unknown packet type: %02x%02x\n",
656 "%02x%02x\n", __func__, 708 __func__,
657 dec->packet[0], dec->packet[1]); 709 dec->packet[0], dec->packet[1]);
658 dec->packet_state = 0; 710 dec->packet_state = 0;
659 } 711 }
@@ -905,8 +957,8 @@ static int ttusb_dec_start_iso_xfer(struct ttusb_dec *dec)
905 for (i = 0; i < ISO_BUF_COUNT; i++) { 957 for (i = 0; i < ISO_BUF_COUNT; i++) {
906 if ((result = usb_submit_urb(dec->iso_urb[i], 958 if ((result = usb_submit_urb(dec->iso_urb[i],
907 GFP_ATOMIC))) { 959 GFP_ATOMIC))) {
908 printk("%s: failed urb submission %d: " 960 printk("%s: failed urb submission %d: error %d\n",
909 "error %d\n", __func__, i, result); 961 __func__, i, result);
910 962
911 while (i) { 963 while (i) {
912 usb_kill_urb(dec->iso_urb[i - 1]); 964 usb_kill_urb(dec->iso_urb[i - 1]);
@@ -1319,8 +1371,7 @@ static int ttusb_dec_boot_dsp(struct ttusb_dec *dec)
1319 memcpy(&tmp, &firmware[56], 4); 1371 memcpy(&tmp, &firmware[56], 4);
1320 crc32_check = ntohl(tmp); 1372 crc32_check = ntohl(tmp);
1321 if (crc32_csum != crc32_check) { 1373 if (crc32_csum != crc32_check) {
1322 printk("%s: crc32 check of DSP code failed (calculated " 1374 printk("%s: crc32 check of DSP code failed (calculated 0x%08x != 0x%08x in file), file invalid.\n",
1323 "0x%08x != 0x%08x in file), file invalid.\n",
1324 __func__, crc32_csum, crc32_check); 1375 __func__, crc32_csum, crc32_check);
1325 release_firmware(fw_entry); 1376 release_firmware(fw_entry);
1326 return -ENOENT; 1377 return -ENOENT;
@@ -1397,11 +1448,9 @@ static int ttusb_dec_init_stb(struct ttusb_dec *dec)
1397 1448
1398 if (!mode) { 1449 if (!mode) {
1399 if (version == 0xABCDEFAB) 1450 if (version == 0xABCDEFAB)
1400 printk(KERN_INFO "ttusb_dec: no version " 1451 printk(KERN_INFO "ttusb_dec: no version info in Firmware\n");
1401 "info in Firmware\n");
1402 else 1452 else
1403 printk(KERN_INFO "ttusb_dec: Firmware " 1453 printk(KERN_INFO "ttusb_dec: Firmware %x.%02x%c%c\n",
1404 "%x.%02x%c%c\n",
1405 version >> 24, (version >> 16) & 0xff, 1454 version >> 24, (version >> 16) & 0xff,
1406 (version >> 8) & 0xff, version & 0xff); 1455 (version >> 8) & 0xff, version & 0xff);
1407 1456
@@ -1425,8 +1474,7 @@ static int ttusb_dec_init_stb(struct ttusb_dec *dec)
1425 ttusb_dec_set_model(dec, TTUSB_DEC2540T); 1474 ttusb_dec_set_model(dec, TTUSB_DEC2540T);
1426 break; 1475 break;
1427 default: 1476 default:
1428 printk(KERN_ERR "%s: unknown model returned " 1477 printk(KERN_ERR "%s: unknown model returned by firmware (%08x) - please report\n",
1429 "by firmware (%08x) - please report\n",
1430 __func__, model); 1478 __func__, model);
1431 return -ENOENT; 1479 return -ENOENT;
1432 } 1480 }
diff --git a/drivers/media/usb/ttusb-dec/ttusbdecfe.c b/drivers/media/usb/ttusb-dec/ttusbdecfe.c
index 8781335ab92f..2d9444905fdb 100644
--- a/drivers/media/usb/ttusb-dec/ttusbdecfe.c
+++ b/drivers/media/usb/ttusb-dec/ttusbdecfe.c
@@ -205,7 +205,7 @@ static void ttusbdecfe_release(struct dvb_frontend* fe)
205 kfree(state); 205 kfree(state);
206} 206}
207 207
208static struct dvb_frontend_ops ttusbdecfe_dvbt_ops; 208static const struct dvb_frontend_ops ttusbdecfe_dvbt_ops;
209 209
210struct dvb_frontend* ttusbdecfe_dvbt_attach(const struct ttusbdecfe_config* config) 210struct dvb_frontend* ttusbdecfe_dvbt_attach(const struct ttusbdecfe_config* config)
211{ 211{
@@ -225,7 +225,7 @@ struct dvb_frontend* ttusbdecfe_dvbt_attach(const struct ttusbdecfe_config* conf
225 return &state->frontend; 225 return &state->frontend;
226} 226}
227 227
228static struct dvb_frontend_ops ttusbdecfe_dvbs_ops; 228static const struct dvb_frontend_ops ttusbdecfe_dvbs_ops;
229 229
230struct dvb_frontend* ttusbdecfe_dvbs_attach(const struct ttusbdecfe_config* config) 230struct dvb_frontend* ttusbdecfe_dvbs_attach(const struct ttusbdecfe_config* config)
231{ 231{
@@ -247,7 +247,7 @@ struct dvb_frontend* ttusbdecfe_dvbs_attach(const struct ttusbdecfe_config* conf
247 return &state->frontend; 247 return &state->frontend;
248} 248}
249 249
250static struct dvb_frontend_ops ttusbdecfe_dvbt_ops = { 250static const struct dvb_frontend_ops ttusbdecfe_dvbt_ops = {
251 .delsys = { SYS_DVBT }, 251 .delsys = { SYS_DVBT },
252 .info = { 252 .info = {
253 .name = "TechnoTrend/Hauppauge DEC2000-t Frontend", 253 .name = "TechnoTrend/Hauppauge DEC2000-t Frontend",
@@ -270,7 +270,7 @@ static struct dvb_frontend_ops ttusbdecfe_dvbt_ops = {
270 .read_status = ttusbdecfe_dvbt_read_status, 270 .read_status = ttusbdecfe_dvbt_read_status,
271}; 271};
272 272
273static struct dvb_frontend_ops ttusbdecfe_dvbs_ops = { 273static const struct dvb_frontend_ops ttusbdecfe_dvbs_ops = {
274 .delsys = { SYS_DVBS }, 274 .delsys = { SYS_DVBS },
275 .info = { 275 .info = {
276 .name = "TechnoTrend/Hauppauge DEC3000-s Frontend", 276 .name = "TechnoTrend/Hauppauge DEC3000-s Frontend",
diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c
index 6cbe4a245c9f..d3b6d3dfaa09 100644
--- a/drivers/media/usb/usbtv/usbtv-video.c
+++ b/drivers/media/usb/usbtv/usbtv-video.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2013 Lubomir Rintel 2 * Copyright (c) 2013,2016 Lubomir Rintel
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
@@ -259,6 +259,10 @@ static int usbtv_setup_capture(struct usbtv *usbtv)
259 if (ret) 259 if (ret)
260 return ret; 260 return ret;
261 261
262 ret = v4l2_ctrl_handler_setup(&usbtv->ctrl);
263 if (ret)
264 return ret;
265
262 return 0; 266 return 0;
263} 267}
264 268
@@ -696,11 +700,91 @@ static const struct vb2_ops usbtv_vb2_ops = {
696 .stop_streaming = usbtv_stop_streaming, 700 .stop_streaming = usbtv_stop_streaming,
697}; 701};
698 702
703static int usbtv_s_ctrl(struct v4l2_ctrl *ctrl)
704{
705 struct usbtv *usbtv = container_of(ctrl->handler, struct usbtv,
706 ctrl);
707 u8 *data;
708 u16 index, size;
709 int ret;
710
711 data = kmalloc(3, GFP_KERNEL);
712 if (!data)
713 return -ENOMEM;
714
715 /*
716 * Read in the current brightness/contrast registers. We need them
717 * both, because the values are for some reason interleaved.
718 */
719 if (ctrl->id == V4L2_CID_BRIGHTNESS || ctrl->id == V4L2_CID_CONTRAST) {
720 ret = usb_control_msg(usbtv->udev,
721 usb_sndctrlpipe(usbtv->udev, 0), USBTV_CONTROL_REG,
722 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
723 0, USBTV_BASE + 0x0244, (void *)data, 3, 0);
724 if (ret < 0)
725 goto error;
726 }
727
728 switch (ctrl->id) {
729 case V4L2_CID_BRIGHTNESS:
730 index = USBTV_BASE + 0x0244;
731 size = 3;
732 data[0] &= 0xf0;
733 data[0] |= (ctrl->val >> 8) & 0xf;
734 data[2] = ctrl->val & 0xff;
735 break;
736 case V4L2_CID_CONTRAST:
737 index = USBTV_BASE + 0x0244;
738 size = 3;
739 data[0] &= 0x0f;
740 data[0] |= (ctrl->val >> 4) & 0xf0;
741 data[1] = ctrl->val & 0xff;
742 break;
743 case V4L2_CID_SATURATION:
744 index = USBTV_BASE + 0x0242;
745 data[0] = ctrl->val >> 8;
746 data[1] = ctrl->val & 0xff;
747 size = 2;
748 break;
749 case V4L2_CID_HUE:
750 index = USBTV_BASE + 0x0240;
751 size = 2;
752 if (ctrl->val > 0) {
753 data[0] = 0x92 + (ctrl->val >> 8);
754 data[1] = ctrl->val & 0xff;
755 } else {
756 data[0] = 0x82 + (-ctrl->val >> 8);
757 data[1] = -ctrl->val & 0xff;
758 }
759 break;
760 default:
761 kfree(data);
762 return -EINVAL;
763 }
764
765 ret = usb_control_msg(usbtv->udev, usb_sndctrlpipe(usbtv->udev, 0),
766 USBTV_CONTROL_REG,
767 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
768 0, index, (void *)data, size, 0);
769
770error:
771 if (ret < 0)
772 dev_warn(usbtv->dev, "Failed to submit a control request.\n");
773
774 kfree(data);
775 return ret;
776}
777
778static const struct v4l2_ctrl_ops usbtv_ctrl_ops = {
779 .s_ctrl = usbtv_s_ctrl,
780};
781
699static void usbtv_release(struct v4l2_device *v4l2_dev) 782static void usbtv_release(struct v4l2_device *v4l2_dev)
700{ 783{
701 struct usbtv *usbtv = container_of(v4l2_dev, struct usbtv, v4l2_dev); 784 struct usbtv *usbtv = container_of(v4l2_dev, struct usbtv, v4l2_dev);
702 785
703 v4l2_device_unregister(&usbtv->v4l2_dev); 786 v4l2_device_unregister(&usbtv->v4l2_dev);
787 v4l2_ctrl_handler_free(&usbtv->ctrl);
704 vb2_queue_release(&usbtv->vb2q); 788 vb2_queue_release(&usbtv->vb2q);
705 kfree(usbtv); 789 kfree(usbtv);
706} 790}
@@ -731,7 +815,24 @@ int usbtv_video_init(struct usbtv *usbtv)
731 return ret; 815 return ret;
732 } 816 }
733 817
818 /* controls */
819 v4l2_ctrl_handler_init(&usbtv->ctrl, 4);
820 v4l2_ctrl_new_std(&usbtv->ctrl, &usbtv_ctrl_ops,
821 V4L2_CID_CONTRAST, 0, 0x3ff, 1, 0x1d0);
822 v4l2_ctrl_new_std(&usbtv->ctrl, &usbtv_ctrl_ops,
823 V4L2_CID_BRIGHTNESS, 0, 0x3ff, 1, 0x1c0);
824 v4l2_ctrl_new_std(&usbtv->ctrl, &usbtv_ctrl_ops,
825 V4L2_CID_SATURATION, 0, 0x3ff, 1, 0x200);
826 v4l2_ctrl_new_std(&usbtv->ctrl, &usbtv_ctrl_ops,
827 V4L2_CID_HUE, -0xdff, 0xdff, 1, 0x000);
828 ret = usbtv->ctrl.error;
829 if (ret < 0) {
830 dev_warn(usbtv->dev, "Could not initialize controls\n");
831 goto ctrl_fail;
832 }
833
734 /* v4l2 structure */ 834 /* v4l2 structure */
835 usbtv->v4l2_dev.ctrl_handler = &usbtv->ctrl;
735 usbtv->v4l2_dev.release = usbtv_release; 836 usbtv->v4l2_dev.release = usbtv_release;
736 ret = v4l2_device_register(usbtv->dev, &usbtv->v4l2_dev); 837 ret = v4l2_device_register(usbtv->dev, &usbtv->v4l2_dev);
737 if (ret < 0) { 838 if (ret < 0) {
@@ -760,6 +861,8 @@ int usbtv_video_init(struct usbtv *usbtv)
760vdev_fail: 861vdev_fail:
761 v4l2_device_unregister(&usbtv->v4l2_dev); 862 v4l2_device_unregister(&usbtv->v4l2_dev);
762v4l2_fail: 863v4l2_fail:
864ctrl_fail:
865 v4l2_ctrl_handler_free(&usbtv->ctrl);
763 vb2_queue_release(&usbtv->vb2q); 866 vb2_queue_release(&usbtv->vb2q);
764 867
765 return ret; 868 return ret;
diff --git a/drivers/media/usb/usbtv/usbtv.h b/drivers/media/usb/usbtv/usbtv.h
index 011f9fdc77a9..0231e449877e 100644
--- a/drivers/media/usb/usbtv/usbtv.h
+++ b/drivers/media/usb/usbtv/usbtv.h
@@ -38,6 +38,7 @@
38#include <linux/usb.h> 38#include <linux/usb.h>
39 39
40#include <media/v4l2-device.h> 40#include <media/v4l2-device.h>
41#include <media/v4l2-ctrls.h>
41#include <media/videobuf2-v4l2.h> 42#include <media/videobuf2-v4l2.h>
42#include <media/videobuf2-vmalloc.h> 43#include <media/videobuf2-vmalloc.h>
43 44
@@ -45,6 +46,7 @@
45#define USBTV_VIDEO_ENDP 0x81 46#define USBTV_VIDEO_ENDP 0x81
46#define USBTV_AUDIO_ENDP 0x83 47#define USBTV_AUDIO_ENDP 0x83
47#define USBTV_BASE 0xc000 48#define USBTV_BASE 0xc000
49#define USBTV_CONTROL_REG 11
48#define USBTV_REQUEST_REG 12 50#define USBTV_REQUEST_REG 12
49 51
50/* Number of concurrent isochronous urbs submitted. 52/* Number of concurrent isochronous urbs submitted.
@@ -87,6 +89,7 @@ struct usbtv {
87 89
88 /* video */ 90 /* video */
89 struct v4l2_device v4l2_dev; 91 struct v4l2_device v4l2_dev;
92 struct v4l2_ctrl_handler ctrl;
90 struct video_device vdev; 93 struct video_device vdev;
91 struct vb2_queue vb2q; 94 struct vb2_queue vb2q;
92 struct mutex v4l2_lock; 95 struct mutex v4l2_lock;
diff --git a/drivers/media/usb/usbvision/usbvision-core.c b/drivers/media/usb/usbvision/usbvision-core.c
index c23bf73a68ea..bf041a9e69db 100644
--- a/drivers/media/usb/usbvision/usbvision-core.c
+++ b/drivers/media/usb/usbvision/usbvision-core.c
@@ -1656,8 +1656,8 @@ static int usbvision_set_video_format(struct usb_usbvision *usbvision, int forma
1656 (__u16) USBVISION_FILT_CONT, value, 2, HZ); 1656 (__u16) USBVISION_FILT_CONT, value, 2, HZ);
1657 1657
1658 if (rc < 0) { 1658 if (rc < 0) {
1659 printk(KERN_ERR "%s: ERROR=%d. USBVISION stopped - " 1659 printk(KERN_ERR "%s: ERROR=%d. USBVISION stopped - reconnect or reload driver.\n",
1660 "reconnect or reload driver.\n", proc, rc); 1660 proc, rc);
1661 } 1661 }
1662 usbvision->isoc_mode = format; 1662 usbvision->isoc_mode = format;
1663 return rc; 1663 return rc;
@@ -1890,8 +1890,8 @@ static int usbvision_set_compress_params(struct usb_usbvision *usbvision)
1890 (__u16) USBVISION_INTRA_CYC, value, 5, HZ); 1890 (__u16) USBVISION_INTRA_CYC, value, 5, HZ);
1891 1891
1892 if (rc < 0) { 1892 if (rc < 0) {
1893 printk(KERN_ERR "%sERROR=%d. USBVISION stopped - " 1893 printk(KERN_ERR "%sERROR=%d. USBVISION stopped - reconnect or reload driver.\n",
1894 "reconnect or reload driver.\n", proc, rc); 1894 proc, rc);
1895 return rc; 1895 return rc;
1896 } 1896 }
1897 1897
@@ -1921,8 +1921,8 @@ static int usbvision_set_compress_params(struct usb_usbvision *usbvision)
1921 (__u16) USBVISION_PCM_THR1, value, 6, HZ); 1921 (__u16) USBVISION_PCM_THR1, value, 6, HZ);
1922 1922
1923 if (rc < 0) { 1923 if (rc < 0) {
1924 printk(KERN_ERR "%sERROR=%d. USBVISION stopped - " 1924 printk(KERN_ERR "%sERROR=%d. USBVISION stopped - reconnect or reload driver.\n",
1925 "reconnect or reload driver.\n", proc, rc); 1925 proc, rc);
1926 } 1926 }
1927 return rc; 1927 return rc;
1928} 1928}
@@ -1960,8 +1960,8 @@ int usbvision_set_input(struct usb_usbvision *usbvision)
1960 1960
1961 rc = usbvision_write_reg(usbvision, USBVISION_VIN_REG1, value[0]); 1961 rc = usbvision_write_reg(usbvision, USBVISION_VIN_REG1, value[0]);
1962 if (rc < 0) { 1962 if (rc < 0) {
1963 printk(KERN_ERR "%sERROR=%d. USBVISION stopped - " 1963 printk(KERN_ERR "%sERROR=%d. USBVISION stopped - reconnect or reload driver.\n",
1964 "reconnect or reload driver.\n", proc, rc); 1964 proc, rc);
1965 return rc; 1965 return rc;
1966 } 1966 }
1967 1967
@@ -2026,8 +2026,8 @@ int usbvision_set_input(struct usb_usbvision *usbvision)
2026 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT, 0, 2026 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT, 0,
2027 (__u16) USBVISION_LXSIZE_I, value, 8, HZ); 2027 (__u16) USBVISION_LXSIZE_I, value, 8, HZ);
2028 if (rc < 0) { 2028 if (rc < 0) {
2029 printk(KERN_ERR "%sERROR=%d. USBVISION stopped - " 2029 printk(KERN_ERR "%sERROR=%d. USBVISION stopped - reconnect or reload driver.\n",
2030 "reconnect or reload driver.\n", proc, rc); 2030 proc, rc);
2031 return rc; 2031 return rc;
2032 } 2032 }
2033 2033
diff --git a/drivers/media/usb/usbvision/usbvision-video.c b/drivers/media/usb/usbvision/usbvision-video.c
index c8b4eb2ee7a2..a7529196c327 100644
--- a/drivers/media/usb/usbvision/usbvision-video.c
+++ b/drivers/media/usb/usbvision/usbvision-video.c
@@ -1456,8 +1456,8 @@ static int usbvision_probe(struct usb_interface *intf,
1456 } 1456 }
1457 1457
1458 if (interface->desc.bNumEndpoints < 2) { 1458 if (interface->desc.bNumEndpoints < 2) {
1459 dev_err(&intf->dev, "interface %d has %d endpoints, but must" 1459 dev_err(&intf->dev, "interface %d has %d endpoints, but must have minimum 2\n",
1460 " have minimum 2\n", ifnum, interface->desc.bNumEndpoints); 1460 ifnum, interface->desc.bNumEndpoints);
1461 ret = -ENODEV; 1461 ret = -ENODEV;
1462 goto err_usb; 1462 goto err_usb;
1463 } 1463 }
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index 302e284a95eb..04bf35063c4c 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -168,6 +168,26 @@ static struct uvc_format_desc uvc_fmts[] = {
168 .guid = UVC_GUID_FORMAT_RW10, 168 .guid = UVC_GUID_FORMAT_RW10,
169 .fcc = V4L2_PIX_FMT_SRGGB10P, 169 .fcc = V4L2_PIX_FMT_SRGGB10P,
170 }, 170 },
171 {
172 .name = "Bayer 16-bit (SBGGR16)",
173 .guid = UVC_GUID_FORMAT_BG16,
174 .fcc = V4L2_PIX_FMT_SBGGR16,
175 },
176 {
177 .name = "Bayer 16-bit (SGBRG16)",
178 .guid = UVC_GUID_FORMAT_GB16,
179 .fcc = V4L2_PIX_FMT_SGBRG16,
180 },
181 {
182 .name = "Bayer 16-bit (SRGGB16)",
183 .guid = UVC_GUID_FORMAT_RG16,
184 .fcc = V4L2_PIX_FMT_SRGGB16,
185 },
186 {
187 .name = "Bayer 16-bit (SGRBG16)",
188 .guid = UVC_GUID_FORMAT_GR16,
189 .fcc = V4L2_PIX_FMT_SGRBG16,
190 },
171}; 191};
172 192
173/* ------------------------------------------------------------------------ 193/* ------------------------------------------------------------------------
@@ -1309,7 +1329,7 @@ static int uvc_scan_chain_entity(struct uvc_video_chain *chain,
1309 switch (UVC_ENTITY_TYPE(entity)) { 1329 switch (UVC_ENTITY_TYPE(entity)) {
1310 case UVC_VC_EXTENSION_UNIT: 1330 case UVC_VC_EXTENSION_UNIT:
1311 if (uvc_trace_param & UVC_TRACE_PROBE) 1331 if (uvc_trace_param & UVC_TRACE_PROBE)
1312 printk(" <- XU %d", entity->id); 1332 printk(KERN_CONT " <- XU %d", entity->id);
1313 1333
1314 if (entity->bNrInPins != 1) { 1334 if (entity->bNrInPins != 1) {
1315 uvc_trace(UVC_TRACE_DESCR, "Extension unit %d has more " 1335 uvc_trace(UVC_TRACE_DESCR, "Extension unit %d has more "
@@ -1321,7 +1341,7 @@ static int uvc_scan_chain_entity(struct uvc_video_chain *chain,
1321 1341
1322 case UVC_VC_PROCESSING_UNIT: 1342 case UVC_VC_PROCESSING_UNIT:
1323 if (uvc_trace_param & UVC_TRACE_PROBE) 1343 if (uvc_trace_param & UVC_TRACE_PROBE)
1324 printk(" <- PU %d", entity->id); 1344 printk(KERN_CONT " <- PU %d", entity->id);
1325 1345
1326 if (chain->processing != NULL) { 1346 if (chain->processing != NULL) {
1327 uvc_trace(UVC_TRACE_DESCR, "Found multiple " 1347 uvc_trace(UVC_TRACE_DESCR, "Found multiple "
@@ -1334,7 +1354,7 @@ static int uvc_scan_chain_entity(struct uvc_video_chain *chain,
1334 1354
1335 case UVC_VC_SELECTOR_UNIT: 1355 case UVC_VC_SELECTOR_UNIT:
1336 if (uvc_trace_param & UVC_TRACE_PROBE) 1356 if (uvc_trace_param & UVC_TRACE_PROBE)
1337 printk(" <- SU %d", entity->id); 1357 printk(KERN_CONT " <- SU %d", entity->id);
1338 1358
1339 /* Single-input selector units are ignored. */ 1359 /* Single-input selector units are ignored. */
1340 if (entity->bNrInPins == 1) 1360 if (entity->bNrInPins == 1)
@@ -1353,7 +1373,7 @@ static int uvc_scan_chain_entity(struct uvc_video_chain *chain,
1353 case UVC_ITT_CAMERA: 1373 case UVC_ITT_CAMERA:
1354 case UVC_ITT_MEDIA_TRANSPORT_INPUT: 1374 case UVC_ITT_MEDIA_TRANSPORT_INPUT:
1355 if (uvc_trace_param & UVC_TRACE_PROBE) 1375 if (uvc_trace_param & UVC_TRACE_PROBE)
1356 printk(" <- IT %d\n", entity->id); 1376 printk(KERN_CONT " <- IT %d\n", entity->id);
1357 1377
1358 break; 1378 break;
1359 1379
@@ -1361,17 +1381,17 @@ static int uvc_scan_chain_entity(struct uvc_video_chain *chain,
1361 case UVC_OTT_DISPLAY: 1381 case UVC_OTT_DISPLAY:
1362 case UVC_OTT_MEDIA_TRANSPORT_OUTPUT: 1382 case UVC_OTT_MEDIA_TRANSPORT_OUTPUT:
1363 if (uvc_trace_param & UVC_TRACE_PROBE) 1383 if (uvc_trace_param & UVC_TRACE_PROBE)
1364 printk(" OT %d", entity->id); 1384 printk(KERN_CONT " OT %d", entity->id);
1365 1385
1366 break; 1386 break;
1367 1387
1368 case UVC_TT_STREAMING: 1388 case UVC_TT_STREAMING:
1369 if (UVC_ENTITY_IS_ITERM(entity)) { 1389 if (UVC_ENTITY_IS_ITERM(entity)) {
1370 if (uvc_trace_param & UVC_TRACE_PROBE) 1390 if (uvc_trace_param & UVC_TRACE_PROBE)
1371 printk(" <- IT %d\n", entity->id); 1391 printk(KERN_CONT " <- IT %d\n", entity->id);
1372 } else { 1392 } else {
1373 if (uvc_trace_param & UVC_TRACE_PROBE) 1393 if (uvc_trace_param & UVC_TRACE_PROBE)
1374 printk(" OT %d", entity->id); 1394 printk(KERN_CONT " OT %d", entity->id);
1375 } 1395 }
1376 1396
1377 break; 1397 break;
@@ -1416,9 +1436,9 @@ static int uvc_scan_chain_forward(struct uvc_video_chain *chain,
1416 list_add_tail(&forward->chain, &chain->entities); 1436 list_add_tail(&forward->chain, &chain->entities);
1417 if (uvc_trace_param & UVC_TRACE_PROBE) { 1437 if (uvc_trace_param & UVC_TRACE_PROBE) {
1418 if (!found) 1438 if (!found)
1419 printk(" (->"); 1439 printk(KERN_CONT " (->");
1420 1440
1421 printk(" XU %d", forward->id); 1441 printk(KERN_CONT " XU %d", forward->id);
1422 found = 1; 1442 found = 1;
1423 } 1443 }
1424 break; 1444 break;
@@ -1436,16 +1456,16 @@ static int uvc_scan_chain_forward(struct uvc_video_chain *chain,
1436 list_add_tail(&forward->chain, &chain->entities); 1456 list_add_tail(&forward->chain, &chain->entities);
1437 if (uvc_trace_param & UVC_TRACE_PROBE) { 1457 if (uvc_trace_param & UVC_TRACE_PROBE) {
1438 if (!found) 1458 if (!found)
1439 printk(" (->"); 1459 printk(KERN_CONT " (->");
1440 1460
1441 printk(" OT %d", forward->id); 1461 printk(KERN_CONT " OT %d", forward->id);
1442 found = 1; 1462 found = 1;
1443 } 1463 }
1444 break; 1464 break;
1445 } 1465 }
1446 } 1466 }
1447 if (found) 1467 if (found)
1448 printk(")"); 1468 printk(KERN_CONT ")");
1449 1469
1450 return 0; 1470 return 0;
1451} 1471}
@@ -1471,7 +1491,7 @@ static int uvc_scan_chain_backward(struct uvc_video_chain *chain,
1471 } 1491 }
1472 1492
1473 if (uvc_trace_param & UVC_TRACE_PROBE) 1493 if (uvc_trace_param & UVC_TRACE_PROBE)
1474 printk(" <- IT"); 1494 printk(KERN_CONT " <- IT");
1475 1495
1476 chain->selector = entity; 1496 chain->selector = entity;
1477 for (i = 0; i < entity->bNrInPins; ++i) { 1497 for (i = 0; i < entity->bNrInPins; ++i) {
@@ -1485,14 +1505,14 @@ static int uvc_scan_chain_backward(struct uvc_video_chain *chain,
1485 } 1505 }
1486 1506
1487 if (uvc_trace_param & UVC_TRACE_PROBE) 1507 if (uvc_trace_param & UVC_TRACE_PROBE)
1488 printk(" %d", term->id); 1508 printk(KERN_CONT " %d", term->id);
1489 1509
1490 list_add_tail(&term->chain, &chain->entities); 1510 list_add_tail(&term->chain, &chain->entities);
1491 uvc_scan_chain_forward(chain, term, entity); 1511 uvc_scan_chain_forward(chain, term, entity);
1492 } 1512 }
1493 1513
1494 if (uvc_trace_param & UVC_TRACE_PROBE) 1514 if (uvc_trace_param & UVC_TRACE_PROBE)
1495 printk("\n"); 1515 printk(KERN_CONT "\n");
1496 1516
1497 id = 0; 1517 id = 0;
1498 break; 1518 break;
@@ -1595,6 +1615,114 @@ static const char *uvc_print_chain(struct uvc_video_chain *chain)
1595 return buffer; 1615 return buffer;
1596} 1616}
1597 1617
1618static struct uvc_video_chain *uvc_alloc_chain(struct uvc_device *dev)
1619{
1620 struct uvc_video_chain *chain;
1621
1622 chain = kzalloc(sizeof(*chain), GFP_KERNEL);
1623 if (chain == NULL)
1624 return NULL;
1625
1626 INIT_LIST_HEAD(&chain->entities);
1627 mutex_init(&chain->ctrl_mutex);
1628 chain->dev = dev;
1629 v4l2_prio_init(&chain->prio);
1630
1631 return chain;
1632}
1633
1634/*
1635 * Fallback heuristic for devices that don't connect units and terminals in a
1636 * valid chain.
1637 *
1638 * Some devices have invalid baSourceID references, causing uvc_scan_chain()
1639 * to fail, but if we just take the entities we can find and put them together
1640 * in the most sensible chain we can think of, turns out they do work anyway.
1641 * Note: This heuristic assumes there is a single chain.
1642 *
1643 * At the time of writing, devices known to have such a broken chain are
1644 * - Acer Integrated Camera (5986:055a)
1645 * - Realtek rtl157a7 (0bda:57a7)
1646 */
1647static int uvc_scan_fallback(struct uvc_device *dev)
1648{
1649 struct uvc_video_chain *chain;
1650 struct uvc_entity *iterm = NULL;
1651 struct uvc_entity *oterm = NULL;
1652 struct uvc_entity *entity;
1653 struct uvc_entity *prev;
1654
1655 /*
1656 * Start by locating the input and output terminals. We only support
1657 * devices with exactly one of each for now.
1658 */
1659 list_for_each_entry(entity, &dev->entities, list) {
1660 if (UVC_ENTITY_IS_ITERM(entity)) {
1661 if (iterm)
1662 return -EINVAL;
1663 iterm = entity;
1664 }
1665
1666 if (UVC_ENTITY_IS_OTERM(entity)) {
1667 if (oterm)
1668 return -EINVAL;
1669 oterm = entity;
1670 }
1671 }
1672
1673 if (iterm == NULL || oterm == NULL)
1674 return -EINVAL;
1675
1676 /* Allocate the chain and fill it. */
1677 chain = uvc_alloc_chain(dev);
1678 if (chain == NULL)
1679 return -ENOMEM;
1680
1681 if (uvc_scan_chain_entity(chain, oterm) < 0)
1682 goto error;
1683
1684 prev = oterm;
1685
1686 /*
1687 * Add all Processing and Extension Units with two pads. The order
1688 * doesn't matter much, use reverse list traversal to connect units in
1689 * UVC descriptor order as we build the chain from output to input. This
1690 * leads to units appearing in the order meant by the manufacturer for
1691 * the cameras known to require this heuristic.
1692 */
1693 list_for_each_entry_reverse(entity, &dev->entities, list) {
1694 if (entity->type != UVC_VC_PROCESSING_UNIT &&
1695 entity->type != UVC_VC_EXTENSION_UNIT)
1696 continue;
1697
1698 if (entity->num_pads != 2)
1699 continue;
1700
1701 if (uvc_scan_chain_entity(chain, entity) < 0)
1702 goto error;
1703
1704 prev->baSourceID[0] = entity->id;
1705 prev = entity;
1706 }
1707
1708 if (uvc_scan_chain_entity(chain, iterm) < 0)
1709 goto error;
1710
1711 prev->baSourceID[0] = iterm->id;
1712
1713 list_add_tail(&chain->list, &dev->chains);
1714
1715 uvc_trace(UVC_TRACE_PROBE,
1716 "Found a video chain by fallback heuristic (%s).\n",
1717 uvc_print_chain(chain));
1718
1719 return 0;
1720
1721error:
1722 kfree(chain);
1723 return -EINVAL;
1724}
1725
1598/* 1726/*
1599 * Scan the device for video chains and register video devices. 1727 * Scan the device for video chains and register video devices.
1600 * 1728 *
@@ -1617,15 +1745,10 @@ static int uvc_scan_device(struct uvc_device *dev)
1617 if (term->chain.next || term->chain.prev) 1745 if (term->chain.next || term->chain.prev)
1618 continue; 1746 continue;
1619 1747
1620 chain = kzalloc(sizeof(*chain), GFP_KERNEL); 1748 chain = uvc_alloc_chain(dev);
1621 if (chain == NULL) 1749 if (chain == NULL)
1622 return -ENOMEM; 1750 return -ENOMEM;
1623 1751
1624 INIT_LIST_HEAD(&chain->entities);
1625 mutex_init(&chain->ctrl_mutex);
1626 chain->dev = dev;
1627 v4l2_prio_init(&chain->prio);
1628
1629 term->flags |= UVC_ENTITY_FLAG_DEFAULT; 1752 term->flags |= UVC_ENTITY_FLAG_DEFAULT;
1630 1753
1631 if (uvc_scan_chain(chain, term) < 0) { 1754 if (uvc_scan_chain(chain, term) < 0) {
@@ -1639,6 +1762,9 @@ static int uvc_scan_device(struct uvc_device *dev)
1639 list_add_tail(&chain->list, &dev->chains); 1762 list_add_tail(&chain->list, &dev->chains);
1640 } 1763 }
1641 1764
1765 if (list_empty(&dev->chains))
1766 uvc_scan_fallback(dev);
1767
1642 if (list_empty(&dev->chains)) { 1768 if (list_empty(&dev->chains)) {
1643 uvc_printk(KERN_INFO, "No valid video chain found.\n"); 1769 uvc_printk(KERN_INFO, "No valid video chain found.\n");
1644 return -1; 1770 return -1;
@@ -2564,6 +2690,15 @@ static struct usb_device_id uvc_ids[] = {
2564 .bInterfaceSubClass = 1, 2690 .bInterfaceSubClass = 1,
2565 .bInterfaceProtocol = 0, 2691 .bInterfaceProtocol = 0,
2566 .driver_info = UVC_QUIRK_FORCE_Y8 }, 2692 .driver_info = UVC_QUIRK_FORCE_Y8 },
2693 /* Oculus VR Rift Sensor */
2694 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2695 | USB_DEVICE_ID_MATCH_INT_INFO,
2696 .idVendor = 0x2833,
2697 .idProduct = 0x0211,
2698 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2699 .bInterfaceSubClass = 1,
2700 .bInterfaceProtocol = 0,
2701 .driver_info = UVC_QUIRK_FORCE_Y8 },
2567 /* Generic USB Video Class */ 2702 /* Generic USB Video Class */
2568 { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, UVC_PC_PROTOCOL_UNDEFINED) }, 2703 { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, UVC_PC_PROTOCOL_UNDEFINED) },
2569 { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, UVC_PC_PROTOCOL_15) }, 2704 { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, UVC_PC_PROTOCOL_15) },
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 05eed4be25df..3e7e283a44a8 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -66,19 +66,14 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,
66 if (xmap->menu_count == 0 || 66 if (xmap->menu_count == 0 ||
67 xmap->menu_count > UVC_MAX_CONTROL_MENU_ENTRIES) { 67 xmap->menu_count > UVC_MAX_CONTROL_MENU_ENTRIES) {
68 ret = -EINVAL; 68 ret = -EINVAL;
69 goto done; 69 goto free_map;
70 } 70 }
71 71
72 size = xmap->menu_count * sizeof(*map->menu_info); 72 size = xmap->menu_count * sizeof(*map->menu_info);
73 map->menu_info = kmalloc(size, GFP_KERNEL); 73 map->menu_info = memdup_user(xmap->menu_info, size);
74 if (map->menu_info == NULL) { 74 if (IS_ERR(map->menu_info)) {
75 ret = -ENOMEM; 75 ret = PTR_ERR(map->menu_info);
76 goto done; 76 goto free_map;
77 }
78
79 if (copy_from_user(map->menu_info, xmap->menu_info, size)) {
80 ret = -EFAULT;
81 goto done;
82 } 77 }
83 78
84 map->menu_count = xmap->menu_count; 79 map->menu_count = xmap->menu_count;
@@ -88,13 +83,13 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,
88 uvc_trace(UVC_TRACE_CONTROL, "Unsupported V4L2 control type " 83 uvc_trace(UVC_TRACE_CONTROL, "Unsupported V4L2 control type "
89 "%u.\n", xmap->v4l2_type); 84 "%u.\n", xmap->v4l2_type);
90 ret = -ENOTTY; 85 ret = -ENOTTY;
91 goto done; 86 goto free_map;
92 } 87 }
93 88
94 ret = uvc_ctrl_add_mapping(chain, map); 89 ret = uvc_ctrl_add_mapping(chain, map);
95 90
96done:
97 kfree(map->menu_info); 91 kfree(map->menu_info);
92free_map:
98 kfree(map); 93 kfree(map);
99 94
100 return ret; 95 return ret;
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 7e4d3eea371b..3d6cc62f3cd2 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -106,6 +106,18 @@
106#define UVC_GUID_FORMAT_RGGB \ 106#define UVC_GUID_FORMAT_RGGB \
107 { 'R', 'G', 'G', 'B', 0x00, 0x00, 0x10, 0x00, \ 107 { 'R', 'G', 'G', 'B', 0x00, 0x00, 0x10, 0x00, \
108 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} 108 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
109#define UVC_GUID_FORMAT_BG16 \
110 { 'B', 'G', '1', '6', 0x00, 0x00, 0x10, 0x00, \
111 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
112#define UVC_GUID_FORMAT_GB16 \
113 { 'G', 'B', '1', '6', 0x00, 0x00, 0x10, 0x00, \
114 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
115#define UVC_GUID_FORMAT_RG16 \
116 { 'R', 'G', '1', '6', 0x00, 0x00, 0x10, 0x00, \
117 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
118#define UVC_GUID_FORMAT_GR16 \
119 { 'G', 'R', '1', '6', 0x00, 0x00, 0x10, 0x00, \
120 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
109#define UVC_GUID_FORMAT_RGBP \ 121#define UVC_GUID_FORMAT_RGBP \
110 { 'R', 'G', 'B', 'P', 0x00, 0x00, 0x10, 0x00, \ 122 { 'R', 'G', 'B', 'P', 0x00, 0x00, 0x10, 0x00, \
111 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} 123 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
diff --git a/drivers/media/usb/zr364xx/zr364xx.c b/drivers/media/usb/zr364xx/zr364xx.c
index cc128db85723..3950708cbb32 100644
--- a/drivers/media/usb/zr364xx/zr364xx.c
+++ b/drivers/media/usb/zr364xx/zr364xx.c
@@ -633,8 +633,7 @@ static int zr364xx_read_video_callback(struct zr364xx_camera *cam,
633 } else { 633 } else {
634 if (frm->cur_size + purb->actual_length > MAX_FRAME_SIZE) { 634 if (frm->cur_size + purb->actual_length > MAX_FRAME_SIZE) {
635 dev_info(&cam->udev->dev, 635 dev_info(&cam->udev->dev,
636 "%s: buffer (%d bytes) too small to hold " 636 "%s: buffer (%d bytes) too small to hold frame data. Discarding frame data.\n",
637 "frame data. Discarding frame data.\n",
638 __func__, MAX_FRAME_SIZE); 637 __func__, MAX_FRAME_SIZE);
639 } else { 638 } else {
640 pdest += frm->cur_size; 639 pdest += frm->cur_size;
@@ -1373,8 +1372,7 @@ static int zr364xx_board_init(struct zr364xx_camera *cam)
1373 &cam->buffer.frame[i], i, 1372 &cam->buffer.frame[i], i,
1374 cam->buffer.frame[i].lpvbits); 1373 cam->buffer.frame[i].lpvbits);
1375 if (cam->buffer.frame[i].lpvbits == NULL) { 1374 if (cam->buffer.frame[i].lpvbits == NULL) {
1376 printk(KERN_INFO KBUILD_MODNAME ": out of memory. " 1375 printk(KERN_INFO KBUILD_MODNAME ": out of memory. Using less frames\n");
1377 "Using less frames\n");
1378 break; 1376 break;
1379 } 1377 }
1380 } 1378 }
diff --git a/drivers/media/v4l2-core/Kconfig b/drivers/media/v4l2-core/Kconfig
index 367523a3c774..6b1b78ff1417 100644
--- a/drivers/media/v4l2-core/Kconfig
+++ b/drivers/media/v4l2-core/Kconfig
@@ -6,6 +6,7 @@
6config VIDEO_V4L2 6config VIDEO_V4L2
7 tristate 7 tristate
8 depends on (I2C || I2C=n) && VIDEO_DEV 8 depends on (I2C || I2C=n) && VIDEO_DEV
9 select RATIONAL
9 default (I2C || I2C=n) && VIDEO_DEV 10 default (I2C || I2C=n) && VIDEO_DEV
10 11
11config VIDEO_ADV_DEBUG 12config VIDEO_ADV_DEBUG
diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
index 731487be5baa..05b5c6652cfa 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -84,30 +84,16 @@ static const struct v4l2_subdev_ops tuner_ops;
84 * Debug macros 84 * Debug macros
85 */ 85 */
86 86
87#define tuner_warn(fmt, arg...) do { \ 87#undef pr_fmt
88 printk(KERN_WARNING "%s %d-%04x: " fmt, PREFIX, \ 88
89 i2c_adapter_id(t->i2c->adapter), \ 89#define pr_fmt(fmt) KBUILD_MODNAME ": %d-%04x: " fmt, \
90 t->i2c->addr, ##arg); \ 90 i2c_adapter_id(t->i2c->adapter), t->i2c->addr
91 } while (0) 91
92 92
93#define tuner_info(fmt, arg...) do { \ 93#define dprintk(fmt, arg...) do { \
94 printk(KERN_INFO "%s %d-%04x: " fmt, PREFIX, \ 94 if (tuner_debug) \
95 i2c_adapter_id(t->i2c->adapter), \ 95 printk(KERN_DEBUG pr_fmt("%s: " fmt), __func__, ##arg); \
96 t->i2c->addr, ##arg); \ 96} while (0)
97 } while (0)
98
99#define tuner_err(fmt, arg...) do { \
100 printk(KERN_ERR "%s %d-%04x: " fmt, PREFIX, \
101 i2c_adapter_id(t->i2c->adapter), \
102 t->i2c->addr, ##arg); \
103 } while (0)
104
105#define tuner_dbg(fmt, arg...) do { \
106 if (tuner_debug) \
107 printk(KERN_DEBUG "%s %d-%04x: " fmt, PREFIX, \
108 i2c_adapter_id(t->i2c->adapter), \
109 t->i2c->addr, ##arg); \
110 } while (0)
111 97
112/* 98/*
113 * Internal struct used inside the driver 99 * Internal struct used inside the driver
@@ -208,7 +194,7 @@ static void fe_set_params(struct dvb_frontend *fe,
208 struct tuner *t = fe->analog_demod_priv; 194 struct tuner *t = fe->analog_demod_priv;
209 195
210 if (NULL == fe_tuner_ops->set_analog_params) { 196 if (NULL == fe_tuner_ops->set_analog_params) {
211 tuner_warn("Tuner frontend module has no way to set freq\n"); 197 pr_warn("Tuner frontend module has no way to set freq\n");
212 return; 198 return;
213 } 199 }
214 fe_tuner_ops->set_analog_params(fe, params); 200 fe_tuner_ops->set_analog_params(fe, params);
@@ -230,7 +216,7 @@ static int fe_set_config(struct dvb_frontend *fe, void *priv_cfg)
230 if (fe_tuner_ops->set_config) 216 if (fe_tuner_ops->set_config)
231 return fe_tuner_ops->set_config(fe, priv_cfg); 217 return fe_tuner_ops->set_config(fe, priv_cfg);
232 218
233 tuner_warn("Tuner frontend module has no way to set config\n"); 219 pr_warn("Tuner frontend module has no way to set config\n");
234 220
235 return 0; 221 return 0;
236} 222}
@@ -273,14 +259,14 @@ static void set_type(struct i2c_client *c, unsigned int type,
273 int tune_now = 1; 259 int tune_now = 1;
274 260
275 if (type == UNSET || type == TUNER_ABSENT) { 261 if (type == UNSET || type == TUNER_ABSENT) {
276 tuner_dbg("tuner 0x%02x: Tuner type absent\n", c->addr); 262 dprintk("tuner 0x%02x: Tuner type absent\n", c->addr);
277 return; 263 return;
278 } 264 }
279 265
280 t->type = type; 266 t->type = type;
281 t->config = new_config; 267 t->config = new_config;
282 if (tuner_callback != NULL) { 268 if (tuner_callback != NULL) {
283 tuner_dbg("defining GPIO callback\n"); 269 dprintk("defining GPIO callback\n");
284 t->fe.callback = tuner_callback; 270 t->fe.callback = tuner_callback;
285 } 271 }
286 272
@@ -442,7 +428,7 @@ static void set_type(struct i2c_client *c, unsigned int type,
442 t->sd.entity.name = t->name; 428 t->sd.entity.name = t->name;
443#endif 429#endif
444 430
445 tuner_dbg("type set to %s\n", t->name); 431 dprintk("type set to %s\n", t->name);
446 432
447 t->mode_mask = new_mode_mask; 433 t->mode_mask = new_mode_mask;
448 434
@@ -459,13 +445,13 @@ static void set_type(struct i2c_client *c, unsigned int type,
459 set_tv_freq(c, t->tv_freq); 445 set_tv_freq(c, t->tv_freq);
460 } 446 }
461 447
462 tuner_dbg("%s %s I2C addr 0x%02x with type %d used for 0x%02x\n", 448 dprintk("%s %s I2C addr 0x%02x with type %d used for 0x%02x\n",
463 c->adapter->name, c->dev.driver->name, c->addr << 1, type, 449 c->adapter->name, c->dev.driver->name, c->addr << 1, type,
464 t->mode_mask); 450 t->mode_mask);
465 return; 451 return;
466 452
467attach_failed: 453attach_failed:
468 tuner_dbg("Tuner attach for type = %d failed.\n", t->type); 454 dprintk("Tuner attach for type = %d failed.\n", t->type);
469 t->type = TUNER_ABSENT; 455 t->type = TUNER_ABSENT;
470 456
471 return; 457 return;
@@ -491,7 +477,7 @@ static int tuner_s_type_addr(struct v4l2_subdev *sd,
491 struct tuner *t = to_tuner(sd); 477 struct tuner *t = to_tuner(sd);
492 struct i2c_client *c = v4l2_get_subdevdata(sd); 478 struct i2c_client *c = v4l2_get_subdevdata(sd);
493 479
494 tuner_dbg("Calling set_type_addr for type=%d, addr=0x%02x, mode=0x%02x, config=%p\n", 480 dprintk("Calling set_type_addr for type=%d, addr=0x%02x, mode=0x%02x, config=%p\n",
495 tun_setup->type, 481 tun_setup->type,
496 tun_setup->addr, 482 tun_setup->addr,
497 tun_setup->mode_mask, 483 tun_setup->mode_mask,
@@ -503,8 +489,7 @@ static int tuner_s_type_addr(struct v4l2_subdev *sd,
503 set_type(c, tun_setup->type, tun_setup->mode_mask, 489 set_type(c, tun_setup->type, tun_setup->mode_mask,
504 tun_setup->config, tun_setup->tuner_callback); 490 tun_setup->config, tun_setup->tuner_callback);
505 } else 491 } else
506 tuner_dbg("set addr discarded for type %i, mask %x. " 492 dprintk("set addr discarded for type %i, mask %x. Asked to change tuner at addr 0x%02x, with mask %x\n",
507 "Asked to change tuner at addr 0x%02x, with mask %x\n",
508 t->type, t->mode_mask, 493 t->type, t->mode_mask,
509 tun_setup->addr, tun_setup->mode_mask); 494 tun_setup->addr, tun_setup->mode_mask);
510 495
@@ -534,7 +519,7 @@ static int tuner_s_config(struct v4l2_subdev *sd,
534 return 0; 519 return 0;
535 } 520 }
536 521
537 tuner_dbg("Tuner frontend module has no way to set config\n"); 522 dprintk("Tuner frontend module has no way to set config\n");
538 return 0; 523 return 0;
539} 524}
540 525
@@ -618,14 +603,12 @@ static int tuner_probe(struct i2c_client *client,
618 603
619 if (show_i2c) { 604 if (show_i2c) {
620 unsigned char buffer[16]; 605 unsigned char buffer[16];
621 int i, rc; 606 int rc;
622 607
623 memset(buffer, 0, sizeof(buffer)); 608 memset(buffer, 0, sizeof(buffer));
624 rc = i2c_master_recv(client, buffer, sizeof(buffer)); 609 rc = i2c_master_recv(client, buffer, sizeof(buffer));
625 tuner_info("I2C RECV = "); 610 if (rc >= 0)
626 for (i = 0; i < rc; i++) 611 pr_info("I2C RECV = %*ph\n", rc, buffer);
627 printk(KERN_CONT "%02x ", buffer[i]);
628 printk("\n");
629 } 612 }
630 613
631 /* autodetection code based on the i2c addr */ 614 /* autodetection code based on the i2c addr */
@@ -653,7 +636,7 @@ static int tuner_probe(struct i2c_client *client,
653 since it can be tda9887*/ 636 since it can be tda9887*/
654 if (tuner_symbol_probe(tda829x_probe, t->i2c->adapter, 637 if (tuner_symbol_probe(tda829x_probe, t->i2c->adapter,
655 t->i2c->addr) >= 0) { 638 t->i2c->addr) >= 0) {
656 tuner_dbg("tda829x detected\n"); 639 dprintk("tda829x detected\n");
657 } else { 640 } else {
658 /* Default is being tda9887 */ 641 /* Default is being tda9887 */
659 t->type = TUNER_TDA9887; 642 t->type = TUNER_TDA9887;
@@ -690,7 +673,7 @@ static int tuner_probe(struct i2c_client *client,
690 t->mode_mask = T_ANALOG_TV; 673 t->mode_mask = T_ANALOG_TV;
691 if (radio == NULL) 674 if (radio == NULL)
692 t->mode_mask |= T_RADIO; 675 t->mode_mask |= T_RADIO;
693 tuner_dbg("Setting mode_mask to 0x%02x\n", t->mode_mask); 676 dprintk("Setting mode_mask to 0x%02x\n", t->mode_mask);
694 } 677 }
695 678
696 /* Should be just before return */ 679 /* Should be just before return */
@@ -719,7 +702,7 @@ register_client:
719 } 702 }
720 703
721 if (ret < 0) { 704 if (ret < 0) {
722 tuner_err("failed to initialize media entity!\n"); 705 pr_err("failed to initialize media entity!\n");
723 kfree(t); 706 kfree(t);
724 return ret; 707 return ret;
725 } 708 }
@@ -732,7 +715,7 @@ register_client:
732 set_type(client, t->type, t->mode_mask, t->config, t->fe.callback); 715 set_type(client, t->type, t->mode_mask, t->config, t->fe.callback);
733 list_add_tail(&t->list, &tuner_list); 716 list_add_tail(&t->list, &tuner_list);
734 717
735 tuner_info("Tuner %d found with type(s)%s%s.\n", 718 pr_info("Tuner %d found with type(s)%s%s.\n",
736 t->type, 719 t->type,
737 t->mode_mask & T_RADIO ? " Radio" : "", 720 t->mode_mask & T_RADIO ? " Radio" : "",
738 t->mode_mask & T_ANALOG_TV ? " TV" : ""); 721 t->mode_mask & T_ANALOG_TV ? " TV" : "");
@@ -809,15 +792,15 @@ static int set_mode(struct tuner *t, enum v4l2_tuner_type mode)
809 792
810 if (mode != t->mode) { 793 if (mode != t->mode) {
811 if (check_mode(t, mode) == -EINVAL) { 794 if (check_mode(t, mode) == -EINVAL) {
812 tuner_dbg("Tuner doesn't support mode %d. " 795 dprintk("Tuner doesn't support mode %d. Putting tuner to sleep\n",
813 "Putting tuner to sleep\n", mode); 796 mode);
814 t->standby = true; 797 t->standby = true;
815 if (analog_ops->standby) 798 if (analog_ops->standby)
816 analog_ops->standby(&t->fe); 799 analog_ops->standby(&t->fe);
817 return -EINVAL; 800 return -EINVAL;
818 } 801 }
819 t->mode = mode; 802 t->mode = mode;
820 tuner_dbg("Changing to mode %d\n", mode); 803 dprintk("Changing to mode %d\n", mode);
821 } 804 }
822 return 0; 805 return 0;
823} 806}
@@ -864,15 +847,15 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
864 }; 847 };
865 848
866 if (t->type == UNSET) { 849 if (t->type == UNSET) {
867 tuner_warn("tuner type not set\n"); 850 pr_warn("tuner type not set\n");
868 return; 851 return;
869 } 852 }
870 if (NULL == analog_ops->set_params) { 853 if (NULL == analog_ops->set_params) {
871 tuner_warn("Tuner has no way to set tv freq\n"); 854 pr_warn("Tuner has no way to set tv freq\n");
872 return; 855 return;
873 } 856 }
874 if (freq < tv_range[0] * 16 || freq > tv_range[1] * 16) { 857 if (freq < tv_range[0] * 16 || freq > tv_range[1] * 16) {
875 tuner_dbg("TV freq (%d.%02d) out of range (%d-%d)\n", 858 dprintk("TV freq (%d.%02d) out of range (%d-%d)\n",
876 freq / 16, freq % 16 * 100 / 16, tv_range[0], 859 freq / 16, freq % 16 * 100 / 16, tv_range[0],
877 tv_range[1]); 860 tv_range[1]);
878 /* V4L2 spec: if the freq is not possible then the closest 861 /* V4L2 spec: if the freq is not possible then the closest
@@ -883,7 +866,7 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
883 freq = tv_range[1] * 16; 866 freq = tv_range[1] * 16;
884 } 867 }
885 params.frequency = freq; 868 params.frequency = freq;
886 tuner_dbg("tv freq set to %d.%02d\n", 869 dprintk("tv freq set to %d.%02d\n",
887 freq / 16, freq % 16 * 100 / 16); 870 freq / 16, freq % 16 * 100 / 16);
888 t->tv_freq = freq; 871 t->tv_freq = freq;
889 t->standby = false; 872 t->standby = false;
@@ -933,7 +916,7 @@ static v4l2_std_id tuner_fixup_std(struct tuner *t, v4l2_std_id std)
933 return V4L2_STD_PAL_Nc; 916 return V4L2_STD_PAL_Nc;
934 return V4L2_STD_PAL_N; 917 return V4L2_STD_PAL_N;
935 default: 918 default:
936 tuner_warn("pal= argument not recognised\n"); 919 pr_warn("pal= argument not recognised\n");
937 break; 920 break;
938 } 921 }
939 } 922 }
@@ -959,7 +942,7 @@ static v4l2_std_id tuner_fixup_std(struct tuner *t, v4l2_std_id std)
959 return V4L2_STD_SECAM_LC; 942 return V4L2_STD_SECAM_LC;
960 return V4L2_STD_SECAM_L; 943 return V4L2_STD_SECAM_L;
961 default: 944 default:
962 tuner_warn("secam= argument not recognised\n"); 945 pr_warn("secam= argument not recognised\n");
963 break; 946 break;
964 } 947 }
965 } 948 }
@@ -976,7 +959,7 @@ static v4l2_std_id tuner_fixup_std(struct tuner *t, v4l2_std_id std)
976 case 'K': 959 case 'K':
977 return V4L2_STD_NTSC_M_KR; 960 return V4L2_STD_NTSC_M_KR;
978 default: 961 default:
979 tuner_info("ntsc= argument not recognised\n"); 962 pr_info("ntsc= argument not recognised\n");
980 break; 963 break;
981 } 964 }
982 } 965 }
@@ -1005,15 +988,15 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq)
1005 }; 988 };
1006 989
1007 if (t->type == UNSET) { 990 if (t->type == UNSET) {
1008 tuner_warn("tuner type not set\n"); 991 pr_warn("tuner type not set\n");
1009 return; 992 return;
1010 } 993 }
1011 if (NULL == analog_ops->set_params) { 994 if (NULL == analog_ops->set_params) {
1012 tuner_warn("tuner has no way to set radio frequency\n"); 995 pr_warn("tuner has no way to set radio frequency\n");
1013 return; 996 return;
1014 } 997 }
1015 if (freq < radio_range[0] * 16000 || freq > radio_range[1] * 16000) { 998 if (freq < radio_range[0] * 16000 || freq > radio_range[1] * 16000) {
1016 tuner_dbg("radio freq (%d.%02d) out of range (%d-%d)\n", 999 dprintk("radio freq (%d.%02d) out of range (%d-%d)\n",
1017 freq / 16000, freq % 16000 * 100 / 16000, 1000 freq / 16000, freq % 16000 * 100 / 16000,
1018 radio_range[0], radio_range[1]); 1001 radio_range[0], radio_range[1]);
1019 /* V4L2 spec: if the freq is not possible then the closest 1002 /* V4L2 spec: if the freq is not possible then the closest
@@ -1024,7 +1007,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq)
1024 freq = radio_range[1] * 16000; 1007 freq = radio_range[1] * 16000;
1025 } 1008 }
1026 params.frequency = freq; 1009 params.frequency = freq;
1027 tuner_dbg("radio freq set to %d.%02d\n", 1010 dprintk("radio freq set to %d.%02d\n",
1028 freq / 16000, freq % 16000 * 100 / 16000); 1011 freq / 16000, freq % 16000 * 100 / 16000);
1029 t->radio_freq = freq; 1012 t->radio_freq = freq;
1030 t->standby = false; 1013 t->standby = false;
@@ -1075,10 +1058,10 @@ static void tuner_status(struct dvb_frontend *fe)
1075 freq = t->tv_freq / 16; 1058 freq = t->tv_freq / 16;
1076 freq_fraction = (t->tv_freq % 16) * 100 / 16; 1059 freq_fraction = (t->tv_freq % 16) * 100 / 16;
1077 } 1060 }
1078 tuner_info("Tuner mode: %s%s\n", p, 1061 pr_info("Tuner mode: %s%s\n", p,
1079 t->standby ? " on standby mode" : ""); 1062 t->standby ? " on standby mode" : "");
1080 tuner_info("Frequency: %lu.%02lu MHz\n", freq, freq_fraction); 1063 pr_info("Frequency: %lu.%02lu MHz\n", freq, freq_fraction);
1081 tuner_info("Standard: 0x%08lx\n", (unsigned long)t->std); 1064 pr_info("Standard: 0x%08lx\n", (unsigned long)t->std);
1082 if (t->mode != V4L2_TUNER_RADIO) 1065 if (t->mode != V4L2_TUNER_RADIO)
1083 return; 1066 return;
1084 if (fe_tuner_ops->get_status) { 1067 if (fe_tuner_ops->get_status) {
@@ -1086,15 +1069,15 @@ static void tuner_status(struct dvb_frontend *fe)
1086 1069
1087 fe_tuner_ops->get_status(&t->fe, &tuner_status); 1070 fe_tuner_ops->get_status(&t->fe, &tuner_status);
1088 if (tuner_status & TUNER_STATUS_LOCKED) 1071 if (tuner_status & TUNER_STATUS_LOCKED)
1089 tuner_info("Tuner is locked.\n"); 1072 pr_info("Tuner is locked.\n");
1090 if (tuner_status & TUNER_STATUS_STEREO) 1073 if (tuner_status & TUNER_STATUS_STEREO)
1091 tuner_info("Stereo: yes\n"); 1074 pr_info("Stereo: yes\n");
1092 } 1075 }
1093 if (analog_ops->has_signal) { 1076 if (analog_ops->has_signal) {
1094 u16 signal; 1077 u16 signal;
1095 1078
1096 if (!analog_ops->has_signal(fe, &signal)) 1079 if (!analog_ops->has_signal(fe, &signal))
1097 tuner_info("Signal strength: %hu\n", signal); 1080 pr_info("Signal strength: %hu\n", signal);
1098 } 1081 }
1099} 1082}
1100 1083
@@ -1127,13 +1110,13 @@ static int tuner_s_power(struct v4l2_subdev *sd, int on)
1127 1110
1128 if (on) { 1111 if (on) {
1129 if (t->standby && set_mode(t, t->mode) == 0) { 1112 if (t->standby && set_mode(t, t->mode) == 0) {
1130 tuner_dbg("Waking up tuner\n"); 1113 dprintk("Waking up tuner\n");
1131 set_freq(t, 0); 1114 set_freq(t, 0);
1132 } 1115 }
1133 return 0; 1116 return 0;
1134 } 1117 }
1135 1118
1136 tuner_dbg("Putting tuner to sleep\n"); 1119 dprintk("Putting tuner to sleep\n");
1137 t->standby = true; 1120 t->standby = true;
1138 if (analog_ops->standby) 1121 if (analog_ops->standby)
1139 analog_ops->standby(&t->fe); 1122 analog_ops->standby(&t->fe);
@@ -1149,7 +1132,7 @@ static int tuner_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
1149 1132
1150 t->std = tuner_fixup_std(t, std); 1133 t->std = tuner_fixup_std(t, std);
1151 if (t->std != std) 1134 if (t->std != std)
1152 tuner_dbg("Fixup standard %llx to %llx\n", std, t->std); 1135 dprintk("Fixup standard %llx to %llx\n", std, t->std);
1153 set_freq(t, 0); 1136 set_freq(t, 0);
1154 return 0; 1137 return 0;
1155} 1138}
@@ -1298,7 +1281,7 @@ static int tuner_suspend(struct device *dev)
1298 struct tuner *t = to_tuner(i2c_get_clientdata(c)); 1281 struct tuner *t = to_tuner(i2c_get_clientdata(c));
1299 struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; 1282 struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops;
1300 1283
1301 tuner_dbg("suspend\n"); 1284 dprintk("suspend\n");
1302 1285
1303 if (t->fe.ops.tuner_ops.suspend) 1286 if (t->fe.ops.tuner_ops.suspend)
1304 t->fe.ops.tuner_ops.suspend(&t->fe); 1287 t->fe.ops.tuner_ops.suspend(&t->fe);
@@ -1313,7 +1296,7 @@ static int tuner_resume(struct device *dev)
1313 struct i2c_client *c = to_i2c_client(dev); 1296 struct i2c_client *c = to_i2c_client(dev);
1314 struct tuner *t = to_tuner(i2c_get_clientdata(c)); 1297 struct tuner *t = to_tuner(i2c_get_clientdata(c));
1315 1298
1316 tuner_dbg("resume\n"); 1299 dprintk("resume\n");
1317 1300
1318 if (t->fe.ops.tuner_ops.resume) 1301 if (t->fe.ops.tuner_ops.resume)
1319 t->fe.ops.tuner_ops.resume(&t->fe); 1302 t->fe.ops.tuner_ops.resume(&t->fe);
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
index bacecbd68a6d..eac9565dc3d8 100644
--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
@@ -409,7 +409,6 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
409 struct v4l2_plane32 __user *uplane32; 409 struct v4l2_plane32 __user *uplane32;
410 struct v4l2_plane __user *uplane; 410 struct v4l2_plane __user *uplane;
411 compat_caddr_t p; 411 compat_caddr_t p;
412 int num_planes;
413 int ret; 412 int ret;
414 413
415 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_buffer32)) || 414 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_buffer32)) ||
@@ -429,12 +428,15 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
429 return -EFAULT; 428 return -EFAULT;
430 429
431 if (V4L2_TYPE_IS_MULTIPLANAR(kp->type)) { 430 if (V4L2_TYPE_IS_MULTIPLANAR(kp->type)) {
432 num_planes = kp->length; 431 unsigned int num_planes;
433 if (num_planes == 0) { 432
433 if (kp->length == 0) {
434 kp->m.planes = NULL; 434 kp->m.planes = NULL;
435 /* num_planes == 0 is legal, e.g. when userspace doesn't 435 /* num_planes == 0 is legal, e.g. when userspace doesn't
436 * need planes array on DQBUF*/ 436 * need planes array on DQBUF*/
437 return 0; 437 return 0;
438 } else if (kp->length > VIDEO_MAX_PLANES) {
439 return -EINVAL;
438 } 440 }
439 441
440 if (get_user(p, &up->m.planes)) 442 if (get_user(p, &up->m.planes))
@@ -442,16 +444,16 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
442 444
443 uplane32 = compat_ptr(p); 445 uplane32 = compat_ptr(p);
444 if (!access_ok(VERIFY_READ, uplane32, 446 if (!access_ok(VERIFY_READ, uplane32,
445 num_planes * sizeof(struct v4l2_plane32))) 447 kp->length * sizeof(struct v4l2_plane32)))
446 return -EFAULT; 448 return -EFAULT;
447 449
448 /* We don't really care if userspace decides to kill itself 450 /* We don't really care if userspace decides to kill itself
449 * by passing a very big num_planes value */ 451 * by passing a very big num_planes value */
450 uplane = compat_alloc_user_space(num_planes * 452 uplane = compat_alloc_user_space(kp->length *
451 sizeof(struct v4l2_plane)); 453 sizeof(struct v4l2_plane));
452 kp->m.planes = (__force struct v4l2_plane *)uplane; 454 kp->m.planes = (__force struct v4l2_plane *)uplane;
453 455
454 while (--num_planes >= 0) { 456 for (num_planes = 0; num_planes < kp->length; num_planes++) {
455 ret = get_v4l2_plane32(uplane, uplane32, kp->memory); 457 ret = get_v4l2_plane32(uplane, uplane32, kp->memory);
456 if (ret) 458 if (ret)
457 return ret; 459 return ret;
@@ -665,7 +667,7 @@ static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext
665{ 667{
666 struct v4l2_ext_control32 __user *ucontrols; 668 struct v4l2_ext_control32 __user *ucontrols;
667 struct v4l2_ext_control __user *kcontrols; 669 struct v4l2_ext_control __user *kcontrols;
668 int n; 670 unsigned int n;
669 compat_caddr_t p; 671 compat_caddr_t p;
670 672
671 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_ext_controls32)) || 673 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_ext_controls32)) ||
@@ -675,20 +677,22 @@ static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext
675 copy_from_user(kp->reserved, up->reserved, 677 copy_from_user(kp->reserved, up->reserved,
676 sizeof(kp->reserved))) 678 sizeof(kp->reserved)))
677 return -EFAULT; 679 return -EFAULT;
678 n = kp->count; 680 if (kp->count == 0) {
679 if (n == 0) {
680 kp->controls = NULL; 681 kp->controls = NULL;
681 return 0; 682 return 0;
683 } else if (kp->count > V4L2_CID_MAX_CTRLS) {
684 return -EINVAL;
682 } 685 }
683 if (get_user(p, &up->controls)) 686 if (get_user(p, &up->controls))
684 return -EFAULT; 687 return -EFAULT;
685 ucontrols = compat_ptr(p); 688 ucontrols = compat_ptr(p);
686 if (!access_ok(VERIFY_READ, ucontrols, 689 if (!access_ok(VERIFY_READ, ucontrols,
687 n * sizeof(struct v4l2_ext_control32))) 690 kp->count * sizeof(struct v4l2_ext_control32)))
688 return -EFAULT; 691 return -EFAULT;
689 kcontrols = compat_alloc_user_space(n * sizeof(struct v4l2_ext_control)); 692 kcontrols = compat_alloc_user_space(kp->count *
693 sizeof(struct v4l2_ext_control));
690 kp->controls = (__force struct v4l2_ext_control *)kcontrols; 694 kp->controls = (__force struct v4l2_ext_control *)kcontrols;
691 while (--n >= 0) { 695 for (n = 0; n < kp->count; n++) {
692 u32 id; 696 u32 id;
693 697
694 if (copy_in_user(kcontrols, ucontrols, sizeof(*ucontrols))) 698 if (copy_in_user(kcontrols, ucontrols, sizeof(*ucontrols)))
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index adc2147fcff7..47001e25fd9e 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -885,6 +885,7 @@ const char *v4l2_ctrl_get_name(u32 id)
885 case V4L2_CID_LINK_FREQ: return "Link Frequency"; 885 case V4L2_CID_LINK_FREQ: return "Link Frequency";
886 case V4L2_CID_PIXEL_RATE: return "Pixel Rate"; 886 case V4L2_CID_PIXEL_RATE: return "Pixel Rate";
887 case V4L2_CID_TEST_PATTERN: return "Test Pattern"; 887 case V4L2_CID_TEST_PATTERN: return "Test Pattern";
888 case V4L2_CID_DEINTERLACING_MODE: return "Deinterlacing Mode";
888 889
889 /* DV controls */ 890 /* DV controls */
890 /* Keep the order of the 'case's the same as in v4l2-controls.h! */ 891 /* Keep the order of the 'case's the same as in v4l2-controls.h! */
@@ -1058,6 +1059,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
1058 case V4L2_CID_DV_RX_RGB_RANGE: 1059 case V4L2_CID_DV_RX_RGB_RANGE:
1059 case V4L2_CID_DV_RX_IT_CONTENT_TYPE: 1060 case V4L2_CID_DV_RX_IT_CONTENT_TYPE:
1060 case V4L2_CID_TEST_PATTERN: 1061 case V4L2_CID_TEST_PATTERN:
1062 case V4L2_CID_DEINTERLACING_MODE:
1061 case V4L2_CID_TUNE_DEEMPHASIS: 1063 case V4L2_CID_TUNE_DEEMPHASIS:
1062 case V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL: 1064 case V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL:
1063 case V4L2_CID_DETECT_MD_MODE: 1065 case V4L2_CID_DETECT_MD_MODE:
diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c b/drivers/media/v4l2-core/v4l2-dv-timings.c
index 730a7c392c1d..5c8c49d240d1 100644
--- a/drivers/media/v4l2-core/v4l2-dv-timings.c
+++ b/drivers/media/v4l2-core/v4l2-dv-timings.c
@@ -22,6 +22,7 @@
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/rational.h>
25#include <linux/videodev2.h> 26#include <linux/videodev2.h>
26#include <linux/v4l2-dv-timings.h> 27#include <linux/v4l2-dv-timings.h>
27#include <media/v4l2-dv-timings.h> 28#include <media/v4l2-dv-timings.h>
@@ -224,6 +225,24 @@ bool v4l2_find_dv_timings_cap(struct v4l2_dv_timings *t,
224} 225}
225EXPORT_SYMBOL_GPL(v4l2_find_dv_timings_cap); 226EXPORT_SYMBOL_GPL(v4l2_find_dv_timings_cap);
226 227
228bool v4l2_find_dv_timings_cea861_vic(struct v4l2_dv_timings *t, u8 vic)
229{
230 unsigned int i;
231
232 for (i = 0; i < v4l2_dv_timings_presets[i].bt.width; i++) {
233 const struct v4l2_bt_timings *bt =
234 &v4l2_dv_timings_presets[i].bt;
235
236 if ((bt->flags & V4L2_DV_FL_HAS_CEA861_VIC) &&
237 bt->cea861_vic == vic) {
238 *t = v4l2_dv_timings_presets[i];
239 return true;
240 }
241 }
242 return false;
243}
244EXPORT_SYMBOL_GPL(v4l2_find_dv_timings_cea861_vic);
245
227/** 246/**
228 * v4l2_match_dv_timings - check if two timings match 247 * v4l2_match_dv_timings - check if two timings match
229 * @t1 - compare this v4l2_dv_timings struct... 248 * @t1 - compare this v4l2_dv_timings struct...
@@ -306,7 +325,8 @@ void v4l2_print_dv_timings(const char *dev_prefix, const char *prefix,
306 (bt->polarities & V4L2_DV_VSYNC_POS_POL) ? "+" : "-", 325 (bt->polarities & V4L2_DV_VSYNC_POS_POL) ? "+" : "-",
307 bt->il_vsync, bt->il_vbackporch); 326 bt->il_vsync, bt->il_vbackporch);
308 pr_info("%s: pixelclock: %llu\n", dev_prefix, bt->pixelclock); 327 pr_info("%s: pixelclock: %llu\n", dev_prefix, bt->pixelclock);
309 pr_info("%s: flags (0x%x):%s%s%s%s%s%s%s\n", dev_prefix, bt->flags, 328 pr_info("%s: flags (0x%x):%s%s%s%s%s%s%s%s%s%s\n",
329 dev_prefix, bt->flags,
310 (bt->flags & V4L2_DV_FL_REDUCED_BLANKING) ? 330 (bt->flags & V4L2_DV_FL_REDUCED_BLANKING) ?
311 " REDUCED_BLANKING" : "", 331 " REDUCED_BLANKING" : "",
312 ((bt->flags & V4L2_DV_FL_REDUCED_BLANKING) && 332 ((bt->flags & V4L2_DV_FL_REDUCED_BLANKING) &&
@@ -320,16 +340,51 @@ void v4l2_print_dv_timings(const char *dev_prefix, const char *prefix,
320 (bt->flags & V4L2_DV_FL_IS_CE_VIDEO) ? 340 (bt->flags & V4L2_DV_FL_IS_CE_VIDEO) ?
321 " CE_VIDEO" : "", 341 " CE_VIDEO" : "",
322 (bt->flags & V4L2_DV_FL_FIRST_FIELD_EXTRA_LINE) ? 342 (bt->flags & V4L2_DV_FL_FIRST_FIELD_EXTRA_LINE) ?
323 " FIRST_FIELD_EXTRA_LINE" : ""); 343 " FIRST_FIELD_EXTRA_LINE" : "",
344 (bt->flags & V4L2_DV_FL_HAS_PICTURE_ASPECT) ?
345 " HAS_PICTURE_ASPECT" : "",
346 (bt->flags & V4L2_DV_FL_HAS_CEA861_VIC) ?
347 " HAS_CEA861_VIC" : "",
348 (bt->flags & V4L2_DV_FL_HAS_HDMI_VIC) ?
349 " HAS_HDMI_VIC" : "");
324 pr_info("%s: standards (0x%x):%s%s%s%s%s\n", dev_prefix, bt->standards, 350 pr_info("%s: standards (0x%x):%s%s%s%s%s\n", dev_prefix, bt->standards,
325 (bt->standards & V4L2_DV_BT_STD_CEA861) ? " CEA" : "", 351 (bt->standards & V4L2_DV_BT_STD_CEA861) ? " CEA" : "",
326 (bt->standards & V4L2_DV_BT_STD_DMT) ? " DMT" : "", 352 (bt->standards & V4L2_DV_BT_STD_DMT) ? " DMT" : "",
327 (bt->standards & V4L2_DV_BT_STD_CVT) ? " CVT" : "", 353 (bt->standards & V4L2_DV_BT_STD_CVT) ? " CVT" : "",
328 (bt->standards & V4L2_DV_BT_STD_GTF) ? " GTF" : "", 354 (bt->standards & V4L2_DV_BT_STD_GTF) ? " GTF" : "",
329 (bt->standards & V4L2_DV_BT_STD_SDI) ? " SDI" : ""); 355 (bt->standards & V4L2_DV_BT_STD_SDI) ? " SDI" : "");
356 if (bt->flags & V4L2_DV_FL_HAS_PICTURE_ASPECT)
357 pr_info("%s: picture aspect (hor:vert): %u:%u\n", dev_prefix,
358 bt->picture_aspect.numerator,
359 bt->picture_aspect.denominator);
360 if (bt->flags & V4L2_DV_FL_HAS_CEA861_VIC)
361 pr_info("%s: CEA-861 VIC: %u\n", dev_prefix, bt->cea861_vic);
362 if (bt->flags & V4L2_DV_FL_HAS_HDMI_VIC)
363 pr_info("%s: HDMI VIC: %u\n", dev_prefix, bt->hdmi_vic);
330} 364}
331EXPORT_SYMBOL_GPL(v4l2_print_dv_timings); 365EXPORT_SYMBOL_GPL(v4l2_print_dv_timings);
332 366
367struct v4l2_fract v4l2_dv_timings_aspect_ratio(const struct v4l2_dv_timings *t)
368{
369 struct v4l2_fract ratio = { 1, 1 };
370 unsigned long n, d;
371
372 if (t->type != V4L2_DV_BT_656_1120)
373 return ratio;
374 if (!(t->bt.flags & V4L2_DV_FL_HAS_PICTURE_ASPECT))
375 return ratio;
376
377 ratio.numerator = t->bt.width * t->bt.picture_aspect.denominator;
378 ratio.denominator = t->bt.height * t->bt.picture_aspect.numerator;
379
380 rational_best_approximation(ratio.numerator, ratio.denominator,
381 ratio.numerator, ratio.denominator, &n, &d);
382 ratio.numerator = n;
383 ratio.denominator = d;
384 return ratio;
385}
386EXPORT_SYMBOL_GPL(v4l2_dv_timings_aspect_ratio);
387
333/* 388/*
334 * CVT defines 389 * CVT defines
335 * Based on Coordinated Video Timings Standard 390 * Based on Coordinated Video Timings Standard
diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c
index ae7544d5469a..794e563f24f8 100644
--- a/drivers/media/v4l2-core/v4l2-flash-led-class.c
+++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c
@@ -638,7 +638,7 @@ struct v4l2_flash *v4l2_flash_init(
638 v4l2_flash->iled_cdev = iled_cdev; 638 v4l2_flash->iled_cdev = iled_cdev;
639 v4l2_flash->ops = ops; 639 v4l2_flash->ops = ops;
640 sd->dev = dev; 640 sd->dev = dev;
641 sd->of_node = of_node; 641 sd->of_node = of_node ? of_node : led_cdev->dev->of_node;
642 v4l2_subdev_init(sd, &v4l2_flash_subdev_ops); 642 v4l2_subdev_init(sd, &v4l2_flash_subdev_ops);
643 sd->internal_ops = &v4l2_flash_subdev_internal_ops; 643 sd->internal_ops = &v4l2_flash_subdev_internal_ops;
644 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; 644 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
@@ -654,10 +654,7 @@ struct v4l2_flash *v4l2_flash_init(
654 if (ret < 0) 654 if (ret < 0)
655 goto err_init_controls; 655 goto err_init_controls;
656 656
657 if (sd->of_node) 657 of_node_get(sd->of_node);
658 of_node_get(sd->of_node);
659 else
660 of_node_get(led_cdev->dev->of_node);
661 658
662 ret = v4l2_async_register_subdev(sd); 659 ret = v4l2_async_register_subdev(sd);
663 if (ret < 0) 660 if (ret < 0)
@@ -666,7 +663,7 @@ struct v4l2_flash *v4l2_flash_init(
666 return v4l2_flash; 663 return v4l2_flash;
667 664
668err_async_register_sd: 665err_async_register_sd:
669 of_node_put(led_cdev->dev->of_node); 666 of_node_put(sd->of_node);
670 v4l2_ctrl_handler_free(sd->ctrl_handler); 667 v4l2_ctrl_handler_free(sd->ctrl_handler);
671err_init_controls: 668err_init_controls:
672 media_entity_cleanup(&sd->entity); 669 media_entity_cleanup(&sd->entity);
@@ -678,20 +675,15 @@ EXPORT_SYMBOL_GPL(v4l2_flash_init);
678void v4l2_flash_release(struct v4l2_flash *v4l2_flash) 675void v4l2_flash_release(struct v4l2_flash *v4l2_flash)
679{ 676{
680 struct v4l2_subdev *sd; 677 struct v4l2_subdev *sd;
681 struct led_classdev *led_cdev;
682 678
683 if (IS_ERR_OR_NULL(v4l2_flash)) 679 if (IS_ERR_OR_NULL(v4l2_flash))
684 return; 680 return;
685 681
686 sd = &v4l2_flash->sd; 682 sd = &v4l2_flash->sd;
687 led_cdev = &v4l2_flash->fled_cdev->led_cdev;
688 683
689 v4l2_async_unregister_subdev(sd); 684 v4l2_async_unregister_subdev(sd);
690 685
691 if (sd->of_node) 686 of_node_put(sd->of_node);
692 of_node_put(sd->of_node);
693 else
694 of_node_put(led_cdev->dev->of_node);
695 687
696 v4l2_ctrl_handler_free(sd->ctrl_handler); 688 v4l2_ctrl_handler_free(sd->ctrl_handler);
697 media_entity_cleanup(&sd->entity); 689 media_entity_cleanup(&sd->entity);
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index c52d94c018bb..0c3f238a2e76 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -174,8 +174,7 @@ static void v4l_print_querycap(const void *arg, bool write_only)
174{ 174{
175 const struct v4l2_capability *p = arg; 175 const struct v4l2_capability *p = arg;
176 176
177 pr_cont("driver=%.*s, card=%.*s, bus=%.*s, version=0x%08x, " 177 pr_cont("driver=%.*s, card=%.*s, bus=%.*s, version=0x%08x, capabilities=0x%08x, device_caps=0x%08x\n",
178 "capabilities=0x%08x, device_caps=0x%08x\n",
179 (int)sizeof(p->driver), p->driver, 178 (int)sizeof(p->driver), p->driver,
180 (int)sizeof(p->card), p->card, 179 (int)sizeof(p->card), p->card,
181 (int)sizeof(p->bus_info), p->bus_info, 180 (int)sizeof(p->bus_info), p->bus_info,
@@ -186,8 +185,7 @@ static void v4l_print_enuminput(const void *arg, bool write_only)
186{ 185{
187 const struct v4l2_input *p = arg; 186 const struct v4l2_input *p = arg;
188 187
189 pr_cont("index=%u, name=%.*s, type=%u, audioset=0x%x, tuner=%u, " 188 pr_cont("index=%u, name=%.*s, type=%u, audioset=0x%x, tuner=%u, std=0x%08Lx, status=0x%x, capabilities=0x%x\n",
190 "std=0x%08Lx, status=0x%x, capabilities=0x%x\n",
191 p->index, (int)sizeof(p->name), p->name, p->type, p->audioset, 189 p->index, (int)sizeof(p->name), p->name, p->type, p->audioset,
192 p->tuner, (unsigned long long)p->std, p->status, 190 p->tuner, (unsigned long long)p->std, p->status,
193 p->capabilities); 191 p->capabilities);
@@ -197,8 +195,7 @@ static void v4l_print_enumoutput(const void *arg, bool write_only)
197{ 195{
198 const struct v4l2_output *p = arg; 196 const struct v4l2_output *p = arg;
199 197
200 pr_cont("index=%u, name=%.*s, type=%u, audioset=0x%x, " 198 pr_cont("index=%u, name=%.*s, type=%u, audioset=0x%x, modulator=%u, std=0x%08Lx, capabilities=0x%x\n",
201 "modulator=%u, std=0x%08Lx, capabilities=0x%x\n",
202 p->index, (int)sizeof(p->name), p->name, p->type, p->audioset, 199 p->index, (int)sizeof(p->name), p->name, p->type, p->audioset,
203 p->modulator, (unsigned long long)p->std, p->capabilities); 200 p->modulator, (unsigned long long)p->std, p->capabilities);
204} 201}
@@ -256,11 +253,7 @@ static void v4l_print_format(const void *arg, bool write_only)
256 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 253 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
257 case V4L2_BUF_TYPE_VIDEO_OUTPUT: 254 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
258 pix = &p->fmt.pix; 255 pix = &p->fmt.pix;
259 pr_cont(", width=%u, height=%u, " 256 pr_cont(", width=%u, height=%u, pixelformat=%c%c%c%c, field=%s, bytesperline=%u, sizeimage=%u, colorspace=%d, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n",
260 "pixelformat=%c%c%c%c, field=%s, "
261 "bytesperline=%u, sizeimage=%u, colorspace=%d, "
262 "flags=0x%x, ycbcr_enc=%u, quantization=%u, "
263 "xfer_func=%u\n",
264 pix->width, pix->height, 257 pix->width, pix->height,
265 (pix->pixelformat & 0xff), 258 (pix->pixelformat & 0xff),
266 (pix->pixelformat >> 8) & 0xff, 259 (pix->pixelformat >> 8) & 0xff,
@@ -274,10 +267,7 @@ static void v4l_print_format(const void *arg, bool write_only)
274 case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: 267 case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
275 case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: 268 case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
276 mp = &p->fmt.pix_mp; 269 mp = &p->fmt.pix_mp;
277 pr_cont(", width=%u, height=%u, " 270 pr_cont(", width=%u, height=%u, format=%c%c%c%c, field=%s, colorspace=%d, num_planes=%u, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n",
278 "format=%c%c%c%c, field=%s, "
279 "colorspace=%d, num_planes=%u, flags=0x%x, "
280 "ycbcr_enc=%u, quantization=%u, xfer_func=%u\n",
281 mp->width, mp->height, 271 mp->width, mp->height,
282 (mp->pixelformat & 0xff), 272 (mp->pixelformat & 0xff),
283 (mp->pixelformat >> 8) & 0xff, 273 (mp->pixelformat >> 8) & 0xff,
@@ -306,8 +296,7 @@ static void v4l_print_format(const void *arg, bool write_only)
306 case V4L2_BUF_TYPE_VBI_CAPTURE: 296 case V4L2_BUF_TYPE_VBI_CAPTURE:
307 case V4L2_BUF_TYPE_VBI_OUTPUT: 297 case V4L2_BUF_TYPE_VBI_OUTPUT:
308 vbi = &p->fmt.vbi; 298 vbi = &p->fmt.vbi;
309 pr_cont(", sampling_rate=%u, offset=%u, samples_per_line=%u, " 299 pr_cont(", sampling_rate=%u, offset=%u, samples_per_line=%u, sample_format=%c%c%c%c, start=%u,%u, count=%u,%u\n",
310 "sample_format=%c%c%c%c, start=%u,%u, count=%u,%u\n",
311 vbi->sampling_rate, vbi->offset, 300 vbi->sampling_rate, vbi->offset,
312 vbi->samples_per_line, 301 vbi->samples_per_line,
313 (vbi->sample_format & 0xff), 302 (vbi->sample_format & 0xff),
@@ -343,9 +332,7 @@ static void v4l_print_framebuffer(const void *arg, bool write_only)
343{ 332{
344 const struct v4l2_framebuffer *p = arg; 333 const struct v4l2_framebuffer *p = arg;
345 334
346 pr_cont("capability=0x%x, flags=0x%x, base=0x%p, width=%u, " 335 pr_cont("capability=0x%x, flags=0x%x, base=0x%p, width=%u, height=%u, pixelformat=%c%c%c%c, bytesperline=%u, sizeimage=%u, colorspace=%d\n",
347 "height=%u, pixelformat=%c%c%c%c, "
348 "bytesperline=%u, sizeimage=%u, colorspace=%d\n",
349 p->capability, p->flags, p->base, 336 p->capability, p->flags, p->base,
350 p->fmt.width, p->fmt.height, 337 p->fmt.width, p->fmt.height,
351 (p->fmt.pixelformat & 0xff), 338 (p->fmt.pixelformat & 0xff),
@@ -368,8 +355,7 @@ static void v4l_print_modulator(const void *arg, bool write_only)
368 if (write_only) 355 if (write_only)
369 pr_cont("index=%u, txsubchans=0x%x\n", p->index, p->txsubchans); 356 pr_cont("index=%u, txsubchans=0x%x\n", p->index, p->txsubchans);
370 else 357 else
371 pr_cont("index=%u, name=%.*s, capability=0x%x, " 358 pr_cont("index=%u, name=%.*s, capability=0x%x, rangelow=%u, rangehigh=%u, txsubchans=0x%x\n",
372 "rangelow=%u, rangehigh=%u, txsubchans=0x%x\n",
373 p->index, (int)sizeof(p->name), p->name, p->capability, 359 p->index, (int)sizeof(p->name), p->name, p->capability,
374 p->rangelow, p->rangehigh, p->txsubchans); 360 p->rangelow, p->rangehigh, p->txsubchans);
375} 361}
@@ -381,9 +367,7 @@ static void v4l_print_tuner(const void *arg, bool write_only)
381 if (write_only) 367 if (write_only)
382 pr_cont("index=%u, audmode=%u\n", p->index, p->audmode); 368 pr_cont("index=%u, audmode=%u\n", p->index, p->audmode);
383 else 369 else
384 pr_cont("index=%u, name=%.*s, type=%u, capability=0x%x, " 370 pr_cont("index=%u, name=%.*s, type=%u, capability=0x%x, rangelow=%u, rangehigh=%u, signal=%u, afc=%d, rxsubchans=0x%x, audmode=%u\n",
385 "rangelow=%u, rangehigh=%u, signal=%u, afc=%d, "
386 "rxsubchans=0x%x, audmode=%u\n",
387 p->index, (int)sizeof(p->name), p->name, p->type, 371 p->index, (int)sizeof(p->name), p->name, p->type,
388 p->capability, p->rangelow, 372 p->capability, p->rangelow,
389 p->rangehigh, p->signal, p->afc, 373 p->rangehigh, p->signal, p->afc,
@@ -402,8 +386,8 @@ static void v4l_print_standard(const void *arg, bool write_only)
402{ 386{
403 const struct v4l2_standard *p = arg; 387 const struct v4l2_standard *p = arg;
404 388
405 pr_cont("index=%u, id=0x%Lx, name=%.*s, fps=%u/%u, " 389 pr_cont("index=%u, id=0x%Lx, name=%.*s, fps=%u/%u, framelines=%u\n",
406 "framelines=%u\n", p->index, 390 p->index,
407 (unsigned long long)p->id, (int)sizeof(p->name), p->name, 391 (unsigned long long)p->id, (int)sizeof(p->name), p->name,
408 p->frameperiod.numerator, 392 p->frameperiod.numerator,
409 p->frameperiod.denominator, 393 p->frameperiod.denominator,
@@ -419,8 +403,7 @@ static void v4l_print_hw_freq_seek(const void *arg, bool write_only)
419{ 403{
420 const struct v4l2_hw_freq_seek *p = arg; 404 const struct v4l2_hw_freq_seek *p = arg;
421 405
422 pr_cont("tuner=%u, type=%u, seek_upward=%u, wrap_around=%u, spacing=%u, " 406 pr_cont("tuner=%u, type=%u, seek_upward=%u, wrap_around=%u, spacing=%u, rangelow=%u, rangehigh=%u\n",
423 "rangelow=%u, rangehigh=%u\n",
424 p->tuner, p->type, p->seek_upward, p->wrap_around, p->spacing, 407 p->tuner, p->type, p->seek_upward, p->wrap_around, p->spacing,
425 p->rangelow, p->rangehigh); 408 p->rangelow, p->rangehigh);
426} 409}
@@ -442,8 +425,7 @@ static void v4l_print_buffer(const void *arg, bool write_only)
442 const struct v4l2_plane *plane; 425 const struct v4l2_plane *plane;
443 int i; 426 int i;
444 427
445 pr_cont("%02ld:%02d:%02d.%08ld index=%d, type=%s, " 428 pr_cont("%02ld:%02d:%02d.%08ld index=%d, type=%s, flags=0x%08x, field=%s, sequence=%d, memory=%s",
446 "flags=0x%08x, field=%s, sequence=%d, memory=%s",
447 p->timestamp.tv_sec / 3600, 429 p->timestamp.tv_sec / 3600,
448 (int)(p->timestamp.tv_sec / 60) % 60, 430 (int)(p->timestamp.tv_sec / 60) % 60,
449 (int)(p->timestamp.tv_sec % 60), 431 (int)(p->timestamp.tv_sec % 60),
@@ -458,8 +440,7 @@ static void v4l_print_buffer(const void *arg, bool write_only)
458 for (i = 0; i < p->length; ++i) { 440 for (i = 0; i < p->length; ++i) {
459 plane = &p->m.planes[i]; 441 plane = &p->m.planes[i];
460 printk(KERN_DEBUG 442 printk(KERN_DEBUG
461 "plane %d: bytesused=%d, data_offset=0x%08x, " 443 "plane %d: bytesused=%d, data_offset=0x%08x, offset/userptr=0x%lx, length=%d\n",
462 "offset/userptr=0x%lx, length=%d\n",
463 i, plane->bytesused, plane->data_offset, 444 i, plane->bytesused, plane->data_offset,
464 plane->m.userptr, plane->length); 445 plane->m.userptr, plane->length);
465 } 446 }
@@ -468,8 +449,7 @@ static void v4l_print_buffer(const void *arg, bool write_only)
468 p->bytesused, p->m.userptr, p->length); 449 p->bytesused, p->m.userptr, p->length);
469 } 450 }
470 451
471 printk(KERN_DEBUG "timecode=%02d:%02d:%02d type=%d, " 452 printk(KERN_DEBUG "timecode=%02d:%02d:%02d type=%d, flags=0x%08x, frames=%d, userbits=0x%08x\n",
472 "flags=0x%08x, frames=%d, userbits=0x%08x\n",
473 tc->hours, tc->minutes, tc->seconds, 453 tc->hours, tc->minutes, tc->seconds,
474 tc->type, tc->flags, tc->frames, *(__u32 *)tc->userbits); 454 tc->type, tc->flags, tc->frames, *(__u32 *)tc->userbits);
475} 455}
@@ -503,8 +483,7 @@ static void v4l_print_streamparm(const void *arg, bool write_only)
503 p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { 483 p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
504 const struct v4l2_captureparm *c = &p->parm.capture; 484 const struct v4l2_captureparm *c = &p->parm.capture;
505 485
506 pr_cont(", capability=0x%x, capturemode=0x%x, timeperframe=%d/%d, " 486 pr_cont(", capability=0x%x, capturemode=0x%x, timeperframe=%d/%d, extendedmode=%d, readbuffers=%d\n",
507 "extendedmode=%d, readbuffers=%d\n",
508 c->capability, c->capturemode, 487 c->capability, c->capturemode,
509 c->timeperframe.numerator, c->timeperframe.denominator, 488 c->timeperframe.numerator, c->timeperframe.denominator,
510 c->extendedmode, c->readbuffers); 489 c->extendedmode, c->readbuffers);
@@ -512,8 +491,7 @@ static void v4l_print_streamparm(const void *arg, bool write_only)
512 p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { 491 p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
513 const struct v4l2_outputparm *c = &p->parm.output; 492 const struct v4l2_outputparm *c = &p->parm.output;
514 493
515 pr_cont(", capability=0x%x, outputmode=0x%x, timeperframe=%d/%d, " 494 pr_cont(", capability=0x%x, outputmode=0x%x, timeperframe=%d/%d, extendedmode=%d, writebuffers=%d\n",
516 "extendedmode=%d, writebuffers=%d\n",
517 c->capability, c->outputmode, 495 c->capability, c->outputmode,
518 c->timeperframe.numerator, c->timeperframe.denominator, 496 c->timeperframe.numerator, c->timeperframe.denominator,
519 c->extendedmode, c->writebuffers); 497 c->extendedmode, c->writebuffers);
@@ -526,8 +504,7 @@ static void v4l_print_queryctrl(const void *arg, bool write_only)
526{ 504{
527 const struct v4l2_queryctrl *p = arg; 505 const struct v4l2_queryctrl *p = arg;
528 506
529 pr_cont("id=0x%x, type=%d, name=%.*s, min/max=%d/%d, " 507 pr_cont("id=0x%x, type=%d, name=%.*s, min/max=%d/%d, step=%d, default=%d, flags=0x%08x\n",
530 "step=%d, default=%d, flags=0x%08x\n",
531 p->id, p->type, (int)sizeof(p->name), p->name, 508 p->id, p->type, (int)sizeof(p->name), p->name,
532 p->minimum, p->maximum, 509 p->minimum, p->maximum,
533 p->step, p->default_value, p->flags); 510 p->step, p->default_value, p->flags);
@@ -537,9 +514,7 @@ static void v4l_print_query_ext_ctrl(const void *arg, bool write_only)
537{ 514{
538 const struct v4l2_query_ext_ctrl *p = arg; 515 const struct v4l2_query_ext_ctrl *p = arg;
539 516
540 pr_cont("id=0x%x, type=%d, name=%.*s, min/max=%lld/%lld, " 517 pr_cont("id=0x%x, type=%d, name=%.*s, min/max=%lld/%lld, step=%lld, default=%lld, flags=0x%08x, elem_size=%u, elems=%u, nr_of_dims=%u, dims=%u,%u,%u,%u\n",
541 "step=%lld, default=%lld, flags=0x%08x, elem_size=%u, elems=%u, "
542 "nr_of_dims=%u, dims=%u,%u,%u,%u\n",
543 p->id, p->type, (int)sizeof(p->name), p->name, 518 p->id, p->type, (int)sizeof(p->name), p->name,
544 p->minimum, p->maximum, 519 p->minimum, p->maximum,
545 p->step, p->default_value, p->flags, 520 p->step, p->default_value, p->flags,
@@ -583,9 +558,7 @@ static void v4l_print_cropcap(const void *arg, bool write_only)
583{ 558{
584 const struct v4l2_cropcap *p = arg; 559 const struct v4l2_cropcap *p = arg;
585 560
586 pr_cont("type=%s, bounds wxh=%dx%d, x,y=%d,%d, " 561 pr_cont("type=%s, bounds wxh=%dx%d, x,y=%d,%d, defrect wxh=%dx%d, x,y=%d,%d, pixelaspect %d/%d\n",
587 "defrect wxh=%dx%d, x,y=%d,%d, "
588 "pixelaspect %d/%d\n",
589 prt_names(p->type, v4l2_type_names), 562 prt_names(p->type, v4l2_type_names),
590 p->bounds.width, p->bounds.height, 563 p->bounds.width, p->bounds.height,
591 p->bounds.left, p->bounds.top, 564 p->bounds.left, p->bounds.top,
@@ -618,8 +591,7 @@ static void v4l_print_jpegcompression(const void *arg, bool write_only)
618{ 591{
619 const struct v4l2_jpegcompression *p = arg; 592 const struct v4l2_jpegcompression *p = arg;
620 593
621 pr_cont("quality=%d, APPn=%d, APP_len=%d, " 594 pr_cont("quality=%d, APPn=%d, APP_len=%d, COM_len=%d, jpeg_markers=0x%x\n",
622 "COM_len=%d, jpeg_markers=0x%x\n",
623 p->quality, p->APPn, p->APP_len, 595 p->quality, p->APPn, p->APP_len,
624 p->COM_len, p->jpeg_markers); 596 p->COM_len, p->jpeg_markers);
625} 597}
@@ -686,14 +658,7 @@ static void v4l_print_dv_timings(const void *arg, bool write_only)
686 658
687 switch (p->type) { 659 switch (p->type) {
688 case V4L2_DV_BT_656_1120: 660 case V4L2_DV_BT_656_1120:
689 pr_cont("type=bt-656/1120, interlaced=%u, " 661 pr_cont("type=bt-656/1120, interlaced=%u, pixelclock=%llu, width=%u, height=%u, polarities=0x%x, hfrontporch=%u, hsync=%u, hbackporch=%u, vfrontporch=%u, vsync=%u, vbackporch=%u, il_vfrontporch=%u, il_vsync=%u, il_vbackporch=%u, standards=0x%x, flags=0x%x\n",
690 "pixelclock=%llu, "
691 "width=%u, height=%u, polarities=0x%x, "
692 "hfrontporch=%u, hsync=%u, "
693 "hbackporch=%u, vfrontporch=%u, "
694 "vsync=%u, vbackporch=%u, "
695 "il_vfrontporch=%u, il_vsync=%u, "
696 "il_vbackporch=%u, standards=0x%x, flags=0x%x\n",
697 p->bt.interlaced, p->bt.pixelclock, 662 p->bt.interlaced, p->bt.pixelclock,
698 p->bt.width, p->bt.height, 663 p->bt.width, p->bt.height,
699 p->bt.polarities, p->bt.hfrontporch, 664 p->bt.polarities, p->bt.hfrontporch,
@@ -723,8 +688,7 @@ static void v4l_print_dv_timings_cap(const void *arg, bool write_only)
723 688
724 switch (p->type) { 689 switch (p->type) {
725 case V4L2_DV_BT_656_1120: 690 case V4L2_DV_BT_656_1120:
726 pr_cont("type=bt-656/1120, width=%u-%u, height=%u-%u, " 691 pr_cont("type=bt-656/1120, width=%u-%u, height=%u-%u, pixelclock=%llu-%llu, standards=0x%x, capabilities=0x%x\n",
727 "pixelclock=%llu-%llu, standards=0x%x, capabilities=0x%x\n",
728 p->bt.min_width, p->bt.max_width, 692 p->bt.min_width, p->bt.max_width,
729 p->bt.min_height, p->bt.max_height, 693 p->bt.min_height, p->bt.max_height,
730 p->bt.min_pixelclock, p->bt.max_pixelclock, 694 p->bt.min_pixelclock, p->bt.max_pixelclock,
@@ -805,8 +769,7 @@ static void v4l_print_event(const void *arg, bool write_only)
805 const struct v4l2_event *p = arg; 769 const struct v4l2_event *p = arg;
806 const struct v4l2_event_ctrl *c; 770 const struct v4l2_event_ctrl *c;
807 771
808 pr_cont("type=0x%x, pending=%u, sequence=%u, id=%u, " 772 pr_cont("type=0x%x, pending=%u, sequence=%u, id=%u, timestamp=%lu.%9.9lu\n",
809 "timestamp=%lu.%9.9lu\n",
810 p->type, p->pending, p->sequence, p->id, 773 p->type, p->pending, p->sequence, p->id,
811 p->timestamp.tv_sec, p->timestamp.tv_nsec); 774 p->timestamp.tv_sec, p->timestamp.tv_nsec);
812 switch (p->type) { 775 switch (p->type) {
@@ -822,8 +785,7 @@ static void v4l_print_event(const void *arg, bool write_only)
822 pr_cont("value64=%lld, ", c->value64); 785 pr_cont("value64=%lld, ", c->value64);
823 else 786 else
824 pr_cont("value=%d, ", c->value); 787 pr_cont("value=%d, ", c->value);
825 pr_cont("flags=0x%x, minimum=%d, maximum=%d, step=%d, " 788 pr_cont("flags=0x%x, minimum=%d, maximum=%d, step=%d, default_value=%d\n",
826 "default_value=%d\n",
827 c->flags, c->minimum, c->maximum, 789 c->flags, c->minimum, c->maximum,
828 c->step, c->default_value); 790 c->step, c->default_value);
829 break; 791 break;
@@ -859,8 +821,7 @@ static void v4l_print_freq_band(const void *arg, bool write_only)
859{ 821{
860 const struct v4l2_frequency_band *p = arg; 822 const struct v4l2_frequency_band *p = arg;
861 823
862 pr_cont("tuner=%u, type=%u, index=%u, capability=0x%x, " 824 pr_cont("tuner=%u, type=%u, index=%u, capability=0x%x, rangelow=%u, rangehigh=%u, modulation=0x%x\n",
863 "rangelow=%u, rangehigh=%u, modulation=0x%x\n",
864 p->tuner, p->type, p->index, 825 p->tuner, p->type, p->index,
865 p->capability, p->rangelow, 826 p->capability, p->rangelow,
866 p->rangehigh, p->modulation); 827 p->rangehigh, p->modulation);
@@ -1167,6 +1128,9 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
1167 case V4L2_PIX_FMT_Y16: descr = "16-bit Greyscale"; break; 1128 case V4L2_PIX_FMT_Y16: descr = "16-bit Greyscale"; break;
1168 case V4L2_PIX_FMT_Y16_BE: descr = "16-bit Greyscale BE"; break; 1129 case V4L2_PIX_FMT_Y16_BE: descr = "16-bit Greyscale BE"; break;
1169 case V4L2_PIX_FMT_Y10BPACK: descr = "10-bit Greyscale (Packed)"; break; 1130 case V4L2_PIX_FMT_Y10BPACK: descr = "10-bit Greyscale (Packed)"; break;
1131 case V4L2_PIX_FMT_Y8I: descr = "Interleaved 8-bit Greyscale"; break;
1132 case V4L2_PIX_FMT_Y12I: descr = "Interleaved 12-bit Greyscale"; break;
1133 case V4L2_PIX_FMT_Z16: descr = "16-bit Depth"; break;
1170 case V4L2_PIX_FMT_PAL8: descr = "8-bit Palette"; break; 1134 case V4L2_PIX_FMT_PAL8: descr = "8-bit Palette"; break;
1171 case V4L2_PIX_FMT_UV8: descr = "8-bit Chrominance UV 4-4"; break; 1135 case V4L2_PIX_FMT_UV8: descr = "8-bit Chrominance UV 4-4"; break;
1172 case V4L2_PIX_FMT_YVU410: descr = "Planar YVU 4:1:0"; break; 1136 case V4L2_PIX_FMT_YVU410: descr = "Planar YVU 4:1:0"; break;
@@ -1230,7 +1194,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
1230 case V4L2_PIX_FMT_SGBRG10DPCM8: descr = "8-bit Bayer GBGB/RGRG (DPCM)"; break; 1194 case V4L2_PIX_FMT_SGBRG10DPCM8: descr = "8-bit Bayer GBGB/RGRG (DPCM)"; break;
1231 case V4L2_PIX_FMT_SGRBG10DPCM8: descr = "8-bit Bayer GRGR/BGBG (DPCM)"; break; 1195 case V4L2_PIX_FMT_SGRBG10DPCM8: descr = "8-bit Bayer GRGR/BGBG (DPCM)"; break;
1232 case V4L2_PIX_FMT_SRGGB10DPCM8: descr = "8-bit Bayer RGRG/GBGB (DPCM)"; break; 1196 case V4L2_PIX_FMT_SRGGB10DPCM8: descr = "8-bit Bayer RGRG/GBGB (DPCM)"; break;
1233 case V4L2_PIX_FMT_SBGGR16: descr = "16-bit Bayer BGBG/GRGR (Exp.)"; break; 1197 case V4L2_PIX_FMT_SBGGR16: descr = "16-bit Bayer BGBG/GRGR"; break;
1198 case V4L2_PIX_FMT_SGBRG16: descr = "16-bit Bayer GBGB/RGRG"; break;
1199 case V4L2_PIX_FMT_SGRBG16: descr = "16-bit Bayer GRGR/BGBG"; break;
1200 case V4L2_PIX_FMT_SRGGB16: descr = "16-bit Bayer RGRG/GBGB"; break;
1234 case V4L2_PIX_FMT_SN9C20X_I420: descr = "GSPCA SN9C20X I420"; break; 1201 case V4L2_PIX_FMT_SN9C20X_I420: descr = "GSPCA SN9C20X I420"; break;
1235 case V4L2_PIX_FMT_SPCA501: descr = "GSPCA SPCA501"; break; 1202 case V4L2_PIX_FMT_SPCA501: descr = "GSPCA SPCA501"; break;
1236 case V4L2_PIX_FMT_SPCA505: descr = "GSPCA SPCA505"; break; 1203 case V4L2_PIX_FMT_SPCA505: descr = "GSPCA SPCA505"; break;
@@ -1239,6 +1206,8 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
1239 case V4L2_PIX_FMT_TM6000: descr = "A/V + VBI Mux Packet"; break; 1206 case V4L2_PIX_FMT_TM6000: descr = "A/V + VBI Mux Packet"; break;
1240 case V4L2_PIX_FMT_CIT_YYVYUY: descr = "GSPCA CIT YYVYUY"; break; 1207 case V4L2_PIX_FMT_CIT_YYVYUY: descr = "GSPCA CIT YYVYUY"; break;
1241 case V4L2_PIX_FMT_KONICA420: descr = "GSPCA KONICA420"; break; 1208 case V4L2_PIX_FMT_KONICA420: descr = "GSPCA KONICA420"; break;
1209 case V4L2_PIX_FMT_HSV24: descr = "24-bit HSV 8-8-8"; break;
1210 case V4L2_PIX_FMT_HSV32: descr = "32-bit XHSV 8-8-8-8"; break;
1242 case V4L2_SDR_FMT_CU8: descr = "Complex U8"; break; 1211 case V4L2_SDR_FMT_CU8: descr = "Complex U8"; break;
1243 case V4L2_SDR_FMT_CU16LE: descr = "Complex U16LE"; break; 1212 case V4L2_SDR_FMT_CU16LE: descr = "Complex U16LE"; break;
1244 case V4L2_SDR_FMT_CS8: descr = "Complex S8"; break; 1213 case V4L2_SDR_FMT_CS8: descr = "Complex S8"; break;
@@ -1269,6 +1238,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
1269 case V4L2_PIX_FMT_VC1_ANNEX_G: descr = "VC-1 (SMPTE 412M Annex G)"; break; 1238 case V4L2_PIX_FMT_VC1_ANNEX_G: descr = "VC-1 (SMPTE 412M Annex G)"; break;
1270 case V4L2_PIX_FMT_VC1_ANNEX_L: descr = "VC-1 (SMPTE 412M Annex L)"; break; 1239 case V4L2_PIX_FMT_VC1_ANNEX_L: descr = "VC-1 (SMPTE 412M Annex L)"; break;
1271 case V4L2_PIX_FMT_VP8: descr = "VP8"; break; 1240 case V4L2_PIX_FMT_VP8: descr = "VP8"; break;
1241 case V4L2_PIX_FMT_VP9: descr = "VP9"; break;
1272 case V4L2_PIX_FMT_CPIA1: descr = "GSPCA CPiA YUV"; break; 1242 case V4L2_PIX_FMT_CPIA1: descr = "GSPCA CPiA YUV"; break;
1273 case V4L2_PIX_FMT_WNVA: descr = "WNVA"; break; 1243 case V4L2_PIX_FMT_WNVA: descr = "WNVA"; break;
1274 case V4L2_PIX_FMT_SN9C10X: descr = "GSPCA SN9C10X"; break; 1244 case V4L2_PIX_FMT_SN9C10X: descr = "GSPCA SN9C10X"; break;
@@ -1287,6 +1257,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
1287 case V4L2_PIX_FMT_JPGL: descr = "JPEG Lite"; break; 1257 case V4L2_PIX_FMT_JPGL: descr = "JPEG Lite"; break;
1288 case V4L2_PIX_FMT_SE401: descr = "GSPCA SE401"; break; 1258 case V4L2_PIX_FMT_SE401: descr = "GSPCA SE401"; break;
1289 case V4L2_PIX_FMT_S5C_UYVY_JPG: descr = "S5C73MX interleaved UYVY/JPEG"; break; 1259 case V4L2_PIX_FMT_S5C_UYVY_JPG: descr = "S5C73MX interleaved UYVY/JPEG"; break;
1260 case V4L2_PIX_FMT_MT21C: descr = "Mediatek Compressed Format"; break;
1290 default: 1261 default:
1291 WARN(1, "Unknown pixelformat 0x%08x\n", fmt->pixelformat); 1262 WARN(1, "Unknown pixelformat 0x%08x\n", fmt->pixelformat);
1292 if (fmt->description[0]) 1263 if (fmt->description[0])
diff --git a/drivers/media/v4l2-core/videobuf-core.c b/drivers/media/v4l2-core/videobuf-core.c
index def84753c4c3..1dbf6f7785bb 100644
--- a/drivers/media/v4l2-core/videobuf-core.c
+++ b/drivers/media/v4l2-core/videobuf-core.c
@@ -572,8 +572,7 @@ int videobuf_qbuf(struct videobuf_queue *q, struct v4l2_buffer *b)
572 switch (b->memory) { 572 switch (b->memory) {
573 case V4L2_MEMORY_MMAP: 573 case V4L2_MEMORY_MMAP:
574 if (0 == buf->baddr) { 574 if (0 == buf->baddr) {
575 dprintk(1, "qbuf: mmap requested " 575 dprintk(1, "qbuf: mmap requested but buffer addr is zero!\n");
576 "but buffer addr is zero!\n");
577 goto done; 576 goto done;
578 } 577 }
579 if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT 578 if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 21900202ff83..7c1d390ea438 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -358,8 +358,8 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
358 if (memory == VB2_MEMORY_MMAP) { 358 if (memory == VB2_MEMORY_MMAP) {
359 ret = __vb2_buf_mem_alloc(vb); 359 ret = __vb2_buf_mem_alloc(vb);
360 if (ret) { 360 if (ret) {
361 dprintk(1, "failed allocating memory for " 361 dprintk(1, "failed allocating memory for buffer %d\n",
362 "buffer %d\n", buffer); 362 buffer);
363 q->bufs[vb->index] = NULL; 363 q->bufs[vb->index] = NULL;
364 kfree(vb); 364 kfree(vb);
365 break; 365 break;
@@ -372,8 +372,8 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
372 */ 372 */
373 ret = call_vb_qop(vb, buf_init, vb); 373 ret = call_vb_qop(vb, buf_init, vb);
374 if (ret) { 374 if (ret) {
375 dprintk(1, "buffer %d %p initialization" 375 dprintk(1, "buffer %d %p initialization failed\n",
376 " failed\n", buffer, vb); 376 buffer, vb);
377 __vb2_buf_mem_free(vb); 377 __vb2_buf_mem_free(vb);
378 q->bufs[vb->index] = NULL; 378 q->bufs[vb->index] = NULL;
379 kfree(vb); 379 kfree(vb);
@@ -997,13 +997,12 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const void *pb)
997 && vb->planes[plane].length == planes[plane].length) 997 && vb->planes[plane].length == planes[plane].length)
998 continue; 998 continue;
999 999
1000 dprintk(3, "userspace address for plane %d changed, " 1000 dprintk(3, "userspace address for plane %d changed, reacquiring memory\n",
1001 "reacquiring memory\n", plane); 1001 plane);
1002 1002
1003 /* Check if the provided plane buffer is large enough */ 1003 /* Check if the provided plane buffer is large enough */
1004 if (planes[plane].length < vb->planes[plane].min_length) { 1004 if (planes[plane].length < vb->planes[plane].min_length) {
1005 dprintk(1, "provided buffer size %u is less than " 1005 dprintk(1, "provided buffer size %u is less than setup size %u for plane %d\n",
1006 "setup size %u for plane %d\n",
1007 planes[plane].length, 1006 planes[plane].length,
1008 vb->planes[plane].min_length, 1007 vb->planes[plane].min_length,
1009 plane); 1008 plane);
@@ -1032,8 +1031,8 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const void *pb)
1032 planes[plane].m.userptr, 1031 planes[plane].m.userptr,
1033 planes[plane].length, dma_dir); 1032 planes[plane].length, dma_dir);
1034 if (IS_ERR(mem_priv)) { 1033 if (IS_ERR(mem_priv)) {
1035 dprintk(1, "failed acquiring userspace " 1034 dprintk(1, "failed acquiring userspace memory for plane %d\n",
1036 "memory for plane %d\n", plane); 1035 plane);
1037 ret = PTR_ERR(mem_priv); 1036 ret = PTR_ERR(mem_priv);
1038 goto err; 1037 goto err;
1039 } 1038 }
@@ -1123,8 +1122,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const void *pb)
1123 planes[plane].length = dbuf->size; 1122 planes[plane].length = dbuf->size;
1124 1123
1125 if (planes[plane].length < vb->planes[plane].min_length) { 1124 if (planes[plane].length < vb->planes[plane].min_length) {
1126 dprintk(1, "invalid dmabuf length %u for plane %d, " 1125 dprintk(1, "invalid dmabuf length %u for plane %d, minimum length %u\n",
1127 "minimum length %u\n",
1128 planes[plane].length, plane, 1126 planes[plane].length, plane,
1129 vb->planes[plane].min_length); 1127 vb->planes[plane].min_length);
1130 dma_buf_put(dbuf); 1128 dma_buf_put(dbuf);
@@ -1472,8 +1470,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
1472 } 1470 }
1473 1471
1474 if (nonblocking) { 1472 if (nonblocking) {
1475 dprintk(1, "nonblocking and no buffers to dequeue, " 1473 dprintk(1, "nonblocking and no buffers to dequeue, will not wait\n");
1476 "will not wait\n");
1477 return -EAGAIN; 1474 return -EAGAIN;
1478 } 1475 }
1479 1476
diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c b/drivers/media/v4l2-core/videobuf2-v4l2.c
index 52ef8833f6b6..3529849d2218 100644
--- a/drivers/media/v4l2-core/videobuf2-v4l2.c
+++ b/drivers/media/v4l2-core/videobuf2-v4l2.c
@@ -60,14 +60,13 @@ static int __verify_planes_array(struct vb2_buffer *vb, const struct v4l2_buffer
60 60
61 /* Is memory for copying plane information present? */ 61 /* Is memory for copying plane information present? */
62 if (b->m.planes == NULL) { 62 if (b->m.planes == NULL) {
63 dprintk(1, "multi-planar buffer passed but " 63 dprintk(1, "multi-planar buffer passed but planes array not provided\n");
64 "planes array not provided\n");
65 return -EINVAL; 64 return -EINVAL;
66 } 65 }
67 66
68 if (b->length < vb->num_planes || b->length > VB2_MAX_PLANES) { 67 if (b->length < vb->num_planes || b->length > VB2_MAX_PLANES) {
69 dprintk(1, "incorrect planes array length, " 68 dprintk(1, "incorrect planes array length, expected %d, got %d\n",
70 "expected %d, got %d\n", vb->num_planes, b->length); 69 vb->num_planes, b->length);
71 return -EINVAL; 70 return -EINVAL;
72 } 71 }
73 72
@@ -316,8 +315,7 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb,
316 * that just says that it is either a top or a bottom field, 315 * that just says that it is either a top or a bottom field,
317 * but not which of the two it is. 316 * but not which of the two it is.
318 */ 317 */
319 dprintk(1, "the field is incorrectly set to ALTERNATE " 318 dprintk(1, "the field is incorrectly set to ALTERNATE for an output buffer\n");
320 "for an output buffer\n");
321 return -EINVAL; 319 return -EINVAL;
322 } 320 }
323 vb->timestamp = 0; 321 vb->timestamp = 0;
diff --git a/drivers/media/v4l2-core/videobuf2-vmalloc.c b/drivers/media/v4l2-core/videobuf2-vmalloc.c
index ab3227b75c84..3f778147cdef 100644
--- a/drivers/media/v4l2-core/videobuf2-vmalloc.c
+++ b/drivers/media/v4l2-core/videobuf2-vmalloc.c
@@ -151,8 +151,7 @@ static void *vb2_vmalloc_vaddr(void *buf_priv)
151 struct vb2_vmalloc_buf *buf = buf_priv; 151 struct vb2_vmalloc_buf *buf = buf_priv;
152 152
153 if (!buf->vaddr) { 153 if (!buf->vaddr) {
154 pr_err("Address of an unallocated plane requested " 154 pr_err("Address of an unallocated plane requested or cannot map user pointer\n");
155 "or cannot map user pointer\n");
156 return NULL; 155 return NULL;
157 } 156 }
158 157
diff --git a/drivers/staging/media/Kconfig b/drivers/staging/media/Kconfig
index 6620d96ee44d..ffb8fa72c3da 100644
--- a/drivers/staging/media/Kconfig
+++ b/drivers/staging/media/Kconfig
@@ -21,16 +21,12 @@ if STAGING_MEDIA && MEDIA_SUPPORT
21# Please keep them in alphabetic order 21# Please keep them in alphabetic order
22source "drivers/staging/media/bcm2048/Kconfig" 22source "drivers/staging/media/bcm2048/Kconfig"
23 23
24source "drivers/staging/media/cec/Kconfig"
25
26source "drivers/staging/media/cxd2099/Kconfig" 24source "drivers/staging/media/cxd2099/Kconfig"
27 25
28source "drivers/staging/media/davinci_vpfe/Kconfig" 26source "drivers/staging/media/davinci_vpfe/Kconfig"
29 27
30source "drivers/staging/media/omap4iss/Kconfig" 28source "drivers/staging/media/omap4iss/Kconfig"
31 29
32source "drivers/staging/media/pulse8-cec/Kconfig"
33
34source "drivers/staging/media/s5p-cec/Kconfig" 30source "drivers/staging/media/s5p-cec/Kconfig"
35 31
36# Keep LIRC at the end, as it has sub-menus 32# Keep LIRC at the end, as it has sub-menus
diff --git a/drivers/staging/media/Makefile b/drivers/staging/media/Makefile
index 906257e94dda..a28e82cf6447 100644
--- a/drivers/staging/media/Makefile
+++ b/drivers/staging/media/Makefile
@@ -1,9 +1,7 @@
1obj-$(CONFIG_I2C_BCM2048) += bcm2048/ 1obj-$(CONFIG_I2C_BCM2048) += bcm2048/
2obj-$(CONFIG_MEDIA_CEC) += cec/
3obj-$(CONFIG_VIDEO_SAMSUNG_S5P_CEC) += s5p-cec/ 2obj-$(CONFIG_VIDEO_SAMSUNG_S5P_CEC) += s5p-cec/
4obj-$(CONFIG_DVB_CXD2099) += cxd2099/ 3obj-$(CONFIG_DVB_CXD2099) += cxd2099/
5obj-$(CONFIG_LIRC_STAGING) += lirc/ 4obj-$(CONFIG_LIRC_STAGING) += lirc/
6obj-$(CONFIG_VIDEO_DM365_VPFE) += davinci_vpfe/ 5obj-$(CONFIG_VIDEO_DM365_VPFE) += davinci_vpfe/
7obj-$(CONFIG_VIDEO_OMAP4) += omap4iss/ 6obj-$(CONFIG_VIDEO_OMAP4) += omap4iss/
8obj-$(CONFIG_USB_PULSE8_CEC) += pulse8-cec/
9obj-$(CONFIG_VIDEO_STI_HDMI_CEC) += st-cec/ 7obj-$(CONFIG_VIDEO_STI_HDMI_CEC) += st-cec/
diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c
index 4d9bd02ede47..0a9f8589ecfb 100644
--- a/drivers/staging/media/bcm2048/radio-bcm2048.c
+++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
@@ -17,10 +17,6 @@
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 * 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 */ 20 */
25 21
26/* 22/*
@@ -999,7 +995,7 @@ static int bcm2048_set_fm_search_tune_mode(struct bcm2048_device *bdev,
999 timeout = BCM2048_AUTO_SEARCH_TIMEOUT; 995 timeout = BCM2048_AUTO_SEARCH_TIMEOUT;
1000 996
1001 if (!wait_for_completion_timeout(&bdev->compl, 997 if (!wait_for_completion_timeout(&bdev->compl,
1002 msecs_to_jiffies(timeout))) 998 msecs_to_jiffies(timeout)))
1003 dev_err(&bdev->client->dev, "IRQ timeout.\n"); 999 dev_err(&bdev->client->dev, "IRQ timeout.\n");
1004 1000
1005 if (value) 1001 if (value)
@@ -2059,67 +2055,67 @@ property_signed_read(fm_rssi, int, "%d")
2059DEFINE_SYSFS_PROPERTY(region, unsigned, int, "%u", 0) 2055DEFINE_SYSFS_PROPERTY(region, unsigned, int, "%u", 0)
2060 2056
2061static struct device_attribute attrs[] = { 2057static struct device_attribute attrs[] = {
2062 __ATTR(power_state, S_IRUGO | S_IWUSR, bcm2048_power_state_read, 2058 __ATTR(power_state, 0644, bcm2048_power_state_read,
2063 bcm2048_power_state_write), 2059 bcm2048_power_state_write),
2064 __ATTR(mute, S_IRUGO | S_IWUSR, bcm2048_mute_read, 2060 __ATTR(mute, 0644, bcm2048_mute_read,
2065 bcm2048_mute_write), 2061 bcm2048_mute_write),
2066 __ATTR(audio_route, S_IRUGO | S_IWUSR, bcm2048_audio_route_read, 2062 __ATTR(audio_route, 0644, bcm2048_audio_route_read,
2067 bcm2048_audio_route_write), 2063 bcm2048_audio_route_write),
2068 __ATTR(dac_output, S_IRUGO | S_IWUSR, bcm2048_dac_output_read, 2064 __ATTR(dac_output, 0644, bcm2048_dac_output_read,
2069 bcm2048_dac_output_write), 2065 bcm2048_dac_output_write),
2070 __ATTR(fm_hi_lo_injection, S_IRUGO | S_IWUSR, 2066 __ATTR(fm_hi_lo_injection, 0644,
2071 bcm2048_fm_hi_lo_injection_read, 2067 bcm2048_fm_hi_lo_injection_read,
2072 bcm2048_fm_hi_lo_injection_write), 2068 bcm2048_fm_hi_lo_injection_write),
2073 __ATTR(fm_frequency, S_IRUGO | S_IWUSR, bcm2048_fm_frequency_read, 2069 __ATTR(fm_frequency, 0644, bcm2048_fm_frequency_read,
2074 bcm2048_fm_frequency_write), 2070 bcm2048_fm_frequency_write),
2075 __ATTR(fm_af_frequency, S_IRUGO | S_IWUSR, 2071 __ATTR(fm_af_frequency, 0644,
2076 bcm2048_fm_af_frequency_read, 2072 bcm2048_fm_af_frequency_read,
2077 bcm2048_fm_af_frequency_write), 2073 bcm2048_fm_af_frequency_write),
2078 __ATTR(fm_deemphasis, S_IRUGO | S_IWUSR, bcm2048_fm_deemphasis_read, 2074 __ATTR(fm_deemphasis, 0644, bcm2048_fm_deemphasis_read,
2079 bcm2048_fm_deemphasis_write), 2075 bcm2048_fm_deemphasis_write),
2080 __ATTR(fm_rds_mask, S_IRUGO | S_IWUSR, bcm2048_fm_rds_mask_read, 2076 __ATTR(fm_rds_mask, 0644, bcm2048_fm_rds_mask_read,
2081 bcm2048_fm_rds_mask_write), 2077 bcm2048_fm_rds_mask_write),
2082 __ATTR(fm_best_tune_mode, S_IRUGO | S_IWUSR, 2078 __ATTR(fm_best_tune_mode, 0644,
2083 bcm2048_fm_best_tune_mode_read, 2079 bcm2048_fm_best_tune_mode_read,
2084 bcm2048_fm_best_tune_mode_write), 2080 bcm2048_fm_best_tune_mode_write),
2085 __ATTR(fm_search_rssi_threshold, S_IRUGO | S_IWUSR, 2081 __ATTR(fm_search_rssi_threshold, 0644,
2086 bcm2048_fm_search_rssi_threshold_read, 2082 bcm2048_fm_search_rssi_threshold_read,
2087 bcm2048_fm_search_rssi_threshold_write), 2083 bcm2048_fm_search_rssi_threshold_write),
2088 __ATTR(fm_search_mode_direction, S_IRUGO | S_IWUSR, 2084 __ATTR(fm_search_mode_direction, 0644,
2089 bcm2048_fm_search_mode_direction_read, 2085 bcm2048_fm_search_mode_direction_read,
2090 bcm2048_fm_search_mode_direction_write), 2086 bcm2048_fm_search_mode_direction_write),
2091 __ATTR(fm_search_tune_mode, S_IRUGO | S_IWUSR, 2087 __ATTR(fm_search_tune_mode, 0644,
2092 bcm2048_fm_search_tune_mode_read, 2088 bcm2048_fm_search_tune_mode_read,
2093 bcm2048_fm_search_tune_mode_write), 2089 bcm2048_fm_search_tune_mode_write),
2094 __ATTR(rds, S_IRUGO | S_IWUSR, bcm2048_rds_read, 2090 __ATTR(rds, 0644, bcm2048_rds_read,
2095 bcm2048_rds_write), 2091 bcm2048_rds_write),
2096 __ATTR(rds_b_block_mask, S_IRUGO | S_IWUSR, 2092 __ATTR(rds_b_block_mask, 0644,
2097 bcm2048_rds_b_block_mask_read, 2093 bcm2048_rds_b_block_mask_read,
2098 bcm2048_rds_b_block_mask_write), 2094 bcm2048_rds_b_block_mask_write),
2099 __ATTR(rds_b_block_match, S_IRUGO | S_IWUSR, 2095 __ATTR(rds_b_block_match, 0644,
2100 bcm2048_rds_b_block_match_read, 2096 bcm2048_rds_b_block_match_read,
2101 bcm2048_rds_b_block_match_write), 2097 bcm2048_rds_b_block_match_write),
2102 __ATTR(rds_pi_mask, S_IRUGO | S_IWUSR, bcm2048_rds_pi_mask_read, 2098 __ATTR(rds_pi_mask, 0644, bcm2048_rds_pi_mask_read,
2103 bcm2048_rds_pi_mask_write), 2099 bcm2048_rds_pi_mask_write),
2104 __ATTR(rds_pi_match, S_IRUGO | S_IWUSR, bcm2048_rds_pi_match_read, 2100 __ATTR(rds_pi_match, 0644, bcm2048_rds_pi_match_read,
2105 bcm2048_rds_pi_match_write), 2101 bcm2048_rds_pi_match_write),
2106 __ATTR(rds_wline, S_IRUGO | S_IWUSR, bcm2048_rds_wline_read, 2102 __ATTR(rds_wline, 0644, bcm2048_rds_wline_read,
2107 bcm2048_rds_wline_write), 2103 bcm2048_rds_wline_write),
2108 __ATTR(rds_pi, S_IRUGO, bcm2048_rds_pi_read, NULL), 2104 __ATTR(rds_pi, 0444, bcm2048_rds_pi_read, NULL),
2109 __ATTR(rds_rt, S_IRUGO, bcm2048_rds_rt_read, NULL), 2105 __ATTR(rds_rt, 0444, bcm2048_rds_rt_read, NULL),
2110 __ATTR(rds_ps, S_IRUGO, bcm2048_rds_ps_read, NULL), 2106 __ATTR(rds_ps, 0444, bcm2048_rds_ps_read, NULL),
2111 __ATTR(fm_rds_flags, S_IRUGO, bcm2048_fm_rds_flags_read, NULL), 2107 __ATTR(fm_rds_flags, 0444, bcm2048_fm_rds_flags_read, NULL),
2112 __ATTR(region_bottom_frequency, S_IRUGO, 2108 __ATTR(region_bottom_frequency, 0444,
2113 bcm2048_region_bottom_frequency_read, NULL), 2109 bcm2048_region_bottom_frequency_read, NULL),
2114 __ATTR(region_top_frequency, S_IRUGO, 2110 __ATTR(region_top_frequency, 0444,
2115 bcm2048_region_top_frequency_read, NULL), 2111 bcm2048_region_top_frequency_read, NULL),
2116 __ATTR(fm_carrier_error, S_IRUGO, 2112 __ATTR(fm_carrier_error, 0444,
2117 bcm2048_fm_carrier_error_read, NULL), 2113 bcm2048_fm_carrier_error_read, NULL),
2118 __ATTR(fm_rssi, S_IRUGO, 2114 __ATTR(fm_rssi, 0444,
2119 bcm2048_fm_rssi_read, NULL), 2115 bcm2048_fm_rssi_read, NULL),
2120 __ATTR(region, S_IRUGO | S_IWUSR, bcm2048_region_read, 2116 __ATTR(region, 0644, bcm2048_region_read,
2121 bcm2048_region_write), 2117 bcm2048_region_write),
2122 __ATTR(rds_data, S_IRUGO, bcm2048_rds_data_read, NULL), 2118 __ATTR(rds_data, 0444, bcm2048_rds_data_read, NULL),
2123}; 2119};
2124 2120
2125static int bcm2048_sysfs_unregister_properties(struct bcm2048_device *bdev, 2121static int bcm2048_sysfs_unregister_properties(struct bcm2048_device *bdev,
@@ -2204,7 +2200,7 @@ static ssize_t bcm2048_fops_read(struct file *file, char __user *buf,
2204 } 2200 }
2205 /* interruptible_sleep_on(&bdev->read_queue); */ 2201 /* interruptible_sleep_on(&bdev->read_queue); */
2206 if (wait_event_interruptible(bdev->read_queue, 2202 if (wait_event_interruptible(bdev->read_queue,
2207 bdev->rds_data_available) < 0) { 2203 bdev->rds_data_available) < 0) {
2208 retval = -EINTR; 2204 retval = -EINTR;
2209 goto done; 2205 goto done;
2210 } 2206 }
diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.h b/drivers/staging/media/bcm2048/radio-bcm2048.h
index 4c90a32db795..4d950c1e2e8b 100644
--- a/drivers/staging/media/bcm2048/radio-bcm2048.h
+++ b/drivers/staging/media/bcm2048/radio-bcm2048.h
@@ -14,11 +14,6 @@
14 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * WITHOUT ANY WARRANTY; without even the implied warranty of
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 *
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 */ 17 */
23 18
24#ifndef BCM2048_H 19#ifndef BCM2048_H
diff --git a/drivers/staging/media/cec/Kconfig b/drivers/staging/media/cec/Kconfig
deleted file mode 100644
index 6e12d41b1f86..000000000000
--- a/drivers/staging/media/cec/Kconfig
+++ /dev/null
@@ -1,12 +0,0 @@
1config MEDIA_CEC
2 bool "CEC API (EXPERIMENTAL)"
3 depends on MEDIA_SUPPORT
4 select MEDIA_CEC_EDID
5 ---help---
6 Enable the CEC API.
7
8config MEDIA_CEC_DEBUG
9 bool "CEC debugfs interface (EXPERIMENTAL)"
10 depends on MEDIA_CEC && DEBUG_FS
11 ---help---
12 Turns on the DebugFS interface for CEC devices.
diff --git a/drivers/staging/media/cec/TODO b/drivers/staging/media/cec/TODO
deleted file mode 100644
index 13224694a8ae..000000000000
--- a/drivers/staging/media/cec/TODO
+++ /dev/null
@@ -1,32 +0,0 @@
1The reason why cec.c is still in staging is that I would like
2to have a bit more confidence in the uABI. The kABI is fine,
3no problem there, but I would like to let the public API mature
4a bit.
5
6Once I'm confident that I didn't miss anything then the cec.c source
7can move to drivers/media and the linux/cec.h and linux/cec-funcs.h
8headers can move to uapi/linux and added to uapi/linux/Kbuild to make
9them public.
10
11Hopefully this will happen later in 2016.
12
13Other TODOs:
14
15- There are two possible replies to CEC_MSG_INITIATE_ARC. How to handle that?
16- Add a flag to inhibit passing CEC RC messages to the rc subsystem.
17 Applications should be able to choose this when calling S_LOG_ADDRS.
18- If the reply field of cec_msg is set then when the reply arrives it
19 is only sent to the filehandle that transmitted the original message
20 and not to any followers. Should this behavior change or perhaps
21 controlled through a cec_msg flag?
22- Should CEC_LOG_ADDR_TYPE_SPECIFIC be replaced by TYPE_2ND_TV and TYPE_PROCESSOR?
23 And also TYPE_SWITCH and TYPE_CDC_ONLY in addition to the TYPE_UNREGISTERED?
24 This should give the framework more information about the device type
25 since SPECIFIC and UNREGISTERED give no useful information.
26- Once this is out of staging this should no longer be a separate
27 config option, instead it should be selected by drivers that want it.
28- Revisit the IS_REACHABLE(RC_CORE): perhaps the RC_CORE support should
29 be enabled through a separate config option in drivers/media/Kconfig
30 or rc/Kconfig?
31
32Hans Verkuil <hans.verkuil@cisco.com>
diff --git a/drivers/staging/media/davinci_vpfe/Makefile b/drivers/staging/media/davinci_vpfe/Makefile
index c64515c644cd..3019c9ecd548 100644
--- a/drivers/staging/media/davinci_vpfe/Makefile
+++ b/drivers/staging/media/davinci_vpfe/Makefile
@@ -1,3 +1,5 @@
1obj-$(CONFIG_VIDEO_DM365_VPFE) += \ 1obj-$(CONFIG_VIDEO_DM365_VPFE) += davinci-vfpe.o
2
3davinci-vfpe-objs := \
2 dm365_isif.o dm365_ipipe_hw.o dm365_ipipe.o \ 4 dm365_isif.o dm365_ipipe_hw.o dm365_ipipe.o \
3 dm365_resizer.o dm365_ipipeif.o vpfe_mc_capture.o vpfe_video.o 5 dm365_resizer.o dm365_ipipeif.o vpfe_mc_capture.o vpfe_video.o
diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c b/drivers/staging/media/davinci_vpfe/dm365_resizer.c
index 128662623ea8..5fbc2d447ff2 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c
@@ -237,9 +237,8 @@ resizer_calculate_resize_ratios(struct vpfe_resizer_device *resizer, int index)
237 ((informat->width) * 256) / (outformat->width); 237 ((informat->width) * 256) / (outformat->width);
238} 238}
239 239
240void 240static void resizer_enable_422_420_conversion(struct resizer_params *param,
241static resizer_enable_422_420_conversion(struct resizer_params *param, 241 int index, bool en)
242 int index, bool en)
243{ 242{
244 param->rsz_rsc_param[index].cen = en; 243 param->rsz_rsc_param[index].cen = en;
245 param->rsz_rsc_param[index].yen = en; 244 param->rsz_rsc_param[index].yen = en;
@@ -490,7 +489,7 @@ resizer_configure_in_continious_mode(struct vpfe_resizer_device *resizer)
490 int line_len; 489 int line_len;
491 int ret; 490 int ret;
492 491
493 if (resizer->resizer_a.output != RESIZER_OUPUT_MEMORY) { 492 if (resizer->resizer_a.output != RESIZER_OUTPUT_MEMORY) {
494 dev_err(dev, "enable resizer - Resizer-A\n"); 493 dev_err(dev, "enable resizer - Resizer-A\n");
495 return -EINVAL; 494 return -EINVAL;
496 } 495 }
@@ -502,7 +501,7 @@ resizer_configure_in_continious_mode(struct vpfe_resizer_device *resizer)
502 param->rsz_en[RSZ_B] = DISABLE; 501 param->rsz_en[RSZ_B] = DISABLE;
503 param->oper_mode = RESIZER_MODE_CONTINIOUS; 502 param->oper_mode = RESIZER_MODE_CONTINIOUS;
504 503
505 if (resizer->resizer_b.output == RESIZER_OUPUT_MEMORY) { 504 if (resizer->resizer_b.output == RESIZER_OUTPUT_MEMORY) {
506 struct v4l2_mbus_framefmt *outformat2; 505 struct v4l2_mbus_framefmt *outformat2;
507 506
508 param->rsz_en[RSZ_B] = ENABLE; 507 param->rsz_en[RSZ_B] = ENABLE;
@@ -825,7 +824,7 @@ resizer_set_defualt_configuration(struct vpfe_resizer_device *resizer)
825 .o_hsz = WIDTH_O - 1, 824 .o_hsz = WIDTH_O - 1,
826 .v_dif = 256, 825 .v_dif = 256,
827 .v_typ_y = VPFE_RSZ_INTP_CUBIC, 826 .v_typ_y = VPFE_RSZ_INTP_CUBIC,
828 .h_typ_c = VPFE_RSZ_INTP_CUBIC, 827 .v_typ_c = VPFE_RSZ_INTP_CUBIC,
829 .h_dif = 256, 828 .h_dif = 256,
830 .h_typ_y = VPFE_RSZ_INTP_CUBIC, 829 .h_typ_y = VPFE_RSZ_INTP_CUBIC,
831 .h_typ_c = VPFE_RSZ_INTP_CUBIC, 830 .h_typ_c = VPFE_RSZ_INTP_CUBIC,
@@ -843,7 +842,7 @@ resizer_set_defualt_configuration(struct vpfe_resizer_device *resizer)
843 .o_hsz = WIDTH_O - 1, 842 .o_hsz = WIDTH_O - 1,
844 .v_dif = 256, 843 .v_dif = 256,
845 .v_typ_y = VPFE_RSZ_INTP_CUBIC, 844 .v_typ_y = VPFE_RSZ_INTP_CUBIC,
846 .h_typ_c = VPFE_RSZ_INTP_CUBIC, 845 .v_typ_c = VPFE_RSZ_INTP_CUBIC,
847 .h_dif = 256, 846 .h_dif = 256,
848 .h_typ_y = VPFE_RSZ_INTP_CUBIC, 847 .h_typ_y = VPFE_RSZ_INTP_CUBIC,
849 .h_typ_c = VPFE_RSZ_INTP_CUBIC, 848 .h_typ_c = VPFE_RSZ_INTP_CUBIC,
@@ -1043,13 +1042,13 @@ static void resizer_ss_isr(struct vpfe_resizer_device *resizer)
1043 if (ipipeif_sink != IPIPEIF_INPUT_MEMORY) 1042 if (ipipeif_sink != IPIPEIF_INPUT_MEMORY)
1044 return; 1043 return;
1045 1044
1046 if (resizer->resizer_a.output == RESIZER_OUPUT_MEMORY) { 1045 if (resizer->resizer_a.output == RESIZER_OUTPUT_MEMORY) {
1047 val = vpss_dma_complete_interrupt(); 1046 val = vpss_dma_complete_interrupt();
1048 if (val != 0 && val != 2) 1047 if (val != 0 && val != 2)
1049 return; 1048 return;
1050 } 1049 }
1051 1050
1052 if (resizer->resizer_a.output == RESIZER_OUPUT_MEMORY) { 1051 if (resizer->resizer_a.output == RESIZER_OUTPUT_MEMORY) {
1053 spin_lock(&video_out->dma_queue_lock); 1052 spin_lock(&video_out->dma_queue_lock);
1054 vpfe_video_process_buffer_complete(video_out); 1053 vpfe_video_process_buffer_complete(video_out);
1055 video_out->state = VPFE_VIDEO_BUFFER_NOT_QUEUED; 1054 video_out->state = VPFE_VIDEO_BUFFER_NOT_QUEUED;
@@ -1059,7 +1058,7 @@ static void resizer_ss_isr(struct vpfe_resizer_device *resizer)
1059 1058
1060 /* If resizer B is enabled */ 1059 /* If resizer B is enabled */
1061 if (pipe->output_num > 1 && resizer->resizer_b.output == 1060 if (pipe->output_num > 1 && resizer->resizer_b.output ==
1062 RESIZER_OUPUT_MEMORY) { 1061 RESIZER_OUTPUT_MEMORY) {
1063 spin_lock(&video_out->dma_queue_lock); 1062 spin_lock(&video_out->dma_queue_lock);
1064 vpfe_video_process_buffer_complete(video_out2); 1063 vpfe_video_process_buffer_complete(video_out2);
1065 video_out2->state = VPFE_VIDEO_BUFFER_NOT_QUEUED; 1064 video_out2->state = VPFE_VIDEO_BUFFER_NOT_QUEUED;
@@ -1069,7 +1068,7 @@ static void resizer_ss_isr(struct vpfe_resizer_device *resizer)
1069 1068
1070 /* start HW if buffers are queued */ 1069 /* start HW if buffers are queued */
1071 if (vpfe_video_is_pipe_ready(pipe) && 1070 if (vpfe_video_is_pipe_ready(pipe) &&
1072 resizer->resizer_a.output == RESIZER_OUPUT_MEMORY) { 1071 resizer->resizer_a.output == RESIZER_OUTPUT_MEMORY) {
1073 resizer_enable(resizer, 1); 1072 resizer_enable(resizer, 1);
1074 vpfe_ipipe_enable(vpfe_dev, 1); 1073 vpfe_ipipe_enable(vpfe_dev, 1);
1075 vpfe_ipipeif_enable(vpfe_dev); 1074 vpfe_ipipeif_enable(vpfe_dev);
@@ -1237,8 +1236,8 @@ static int resizer_do_hw_setup(struct vpfe_resizer_device *resizer)
1237 struct resizer_params *param = &resizer->config; 1236 struct resizer_params *param = &resizer->config;
1238 int ret = 0; 1237 int ret = 0;
1239 1238
1240 if (resizer->resizer_a.output == RESIZER_OUPUT_MEMORY || 1239 if (resizer->resizer_a.output == RESIZER_OUTPUT_MEMORY ||
1241 resizer->resizer_b.output == RESIZER_OUPUT_MEMORY) { 1240 resizer->resizer_b.output == RESIZER_OUTPUT_MEMORY) {
1242 if (ipipeif_sink == IPIPEIF_INPUT_MEMORY && 1241 if (ipipeif_sink == IPIPEIF_INPUT_MEMORY &&
1243 ipipeif_source == IPIPEIF_OUTPUT_RESIZER) 1242 ipipeif_source == IPIPEIF_OUTPUT_RESIZER)
1244 ret = resizer_configure_in_single_shot_mode(resizer); 1243 ret = resizer_configure_in_single_shot_mode(resizer);
@@ -1263,7 +1262,7 @@ static int resizer_set_stream(struct v4l2_subdev *sd, int enable)
1263 if (&resizer->crop_resizer.subdev != sd) 1262 if (&resizer->crop_resizer.subdev != sd)
1264 return 0; 1263 return 0;
1265 1264
1266 if (resizer->resizer_a.output != RESIZER_OUPUT_MEMORY) 1265 if (resizer->resizer_a.output != RESIZER_OUTPUT_MEMORY)
1267 return 0; 1266 return 0;
1268 1267
1269 switch (enable) { 1268 switch (enable) {
@@ -1724,7 +1723,7 @@ static int resizer_link_setup(struct media_entity *entity,
1724 } 1723 }
1725 if (resizer->resizer_a.output != RESIZER_OUTPUT_NONE) 1724 if (resizer->resizer_a.output != RESIZER_OUTPUT_NONE)
1726 return -EBUSY; 1725 return -EBUSY;
1727 resizer->resizer_a.output = RESIZER_OUPUT_MEMORY; 1726 resizer->resizer_a.output = RESIZER_OUTPUT_MEMORY;
1728 break; 1727 break;
1729 1728
1730 default: 1729 default:
@@ -1749,7 +1748,7 @@ static int resizer_link_setup(struct media_entity *entity,
1749 } 1748 }
1750 if (resizer->resizer_b.output != RESIZER_OUTPUT_NONE) 1749 if (resizer->resizer_b.output != RESIZER_OUTPUT_NONE)
1751 return -EBUSY; 1750 return -EBUSY;
1752 resizer->resizer_b.output = RESIZER_OUPUT_MEMORY; 1751 resizer->resizer_b.output = RESIZER_OUTPUT_MEMORY;
1753 break; 1752 break;
1754 1753
1755 default: 1754 default:
diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.h b/drivers/staging/media/davinci_vpfe/dm365_resizer.h
index 93b0f44030aa..00e64b0d0295 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_resizer.h
+++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.h
@@ -210,7 +210,7 @@ enum resizer_input_entity {
210 210
211enum resizer_output_entity { 211enum resizer_output_entity {
212 RESIZER_OUTPUT_NONE = 0, 212 RESIZER_OUTPUT_NONE = 0,
213 RESIZER_OUPUT_MEMORY = 1, 213 RESIZER_OUTPUT_MEMORY = 1,
214}; 214};
215 215
216struct dm365_resizer_device { 216struct dm365_resizer_device {
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c
index 8be9f854510f..c27d7e9a1bdb 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c
@@ -198,7 +198,7 @@ static int vpfe_update_pipe_state(struct vpfe_video_device *video)
198 return 0; 198 return 0;
199} 199}
200 200
201/* checks wether pipeline is ready for enabling */ 201/* checks whether pipeline is ready for enabling */
202int vpfe_video_is_pipe_ready(struct vpfe_pipeline *pipe) 202int vpfe_video_is_pipe_ready(struct vpfe_pipeline *pipe)
203{ 203{
204 int i; 204 int i;
@@ -1143,8 +1143,8 @@ static int vpfe_buffer_prepare(struct vb2_buffer *vb)
1143 /* Initialize buffer */ 1143 /* Initialize buffer */
1144 vb2_set_plane_payload(vb, 0, video->fmt.fmt.pix.sizeimage); 1144 vb2_set_plane_payload(vb, 0, video->fmt.fmt.pix.sizeimage);
1145 if (vb2_plane_vaddr(vb, 0) && 1145 if (vb2_plane_vaddr(vb, 0) &&
1146 vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) 1146 vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0))
1147 return -EINVAL; 1147 return -EINVAL;
1148 1148
1149 addr = vb2_dma_contig_plane_dma_addr(vb, 0); 1149 addr = vb2_dma_contig_plane_dma_addr(vb, 0);
1150 /* Make sure user addresses are aligned to 32 bytes */ 1150 /* Make sure user addresses are aligned to 32 bytes */
@@ -1362,7 +1362,7 @@ static int vpfe_reqbufs(struct file *file, void *priv,
1362 ret = vb2_queue_init(q); 1362 ret = vb2_queue_init(q);
1363 if (ret) { 1363 if (ret) {
1364 v4l2_err(&vpfe_dev->v4l2_dev, "vb2_queue_init() failed\n"); 1364 v4l2_err(&vpfe_dev->v4l2_dev, "vb2_queue_init() failed\n");
1365 return ret; 1365 goto unlock_out;
1366 } 1366 }
1367 1367
1368 fh->io_allowed = 1; 1368 fh->io_allowed = 1;
diff --git a/drivers/staging/media/lirc/Kconfig b/drivers/staging/media/lirc/Kconfig
index 6879c4651b46..25b7e7ccf554 100644
--- a/drivers/staging/media/lirc/Kconfig
+++ b/drivers/staging/media/lirc/Kconfig
@@ -38,19 +38,6 @@ config LIRC_SASEM
38 help 38 help
39 Driver for the Sasem OnAir Remocon-V or Dign HV5 HTPC IR/VFD Module 39 Driver for the Sasem OnAir Remocon-V or Dign HV5 HTPC IR/VFD Module
40 40
41config LIRC_SERIAL
42 tristate "Homebrew Serial Port Receiver"
43 depends on LIRC
44 help
45 Driver for Homebrew Serial Port Receivers
46
47config LIRC_SERIAL_TRANSMITTER
48 bool "Serial Port Transmitter"
49 default y
50 depends on LIRC_SERIAL
51 help
52 Serial Port Transmitter support
53
54config LIRC_SIR 41config LIRC_SIR
55 tristate "Built-in SIR IrDA port" 42 tristate "Built-in SIR IrDA port"
56 depends on LIRC 43 depends on LIRC
diff --git a/drivers/staging/media/lirc/Makefile b/drivers/staging/media/lirc/Makefile
index 5430adf0475d..7f919eab1989 100644
--- a/drivers/staging/media/lirc/Makefile
+++ b/drivers/staging/media/lirc/Makefile
@@ -7,6 +7,5 @@ obj-$(CONFIG_LIRC_BT829) += lirc_bt829.o
7obj-$(CONFIG_LIRC_IMON) += lirc_imon.o 7obj-$(CONFIG_LIRC_IMON) += lirc_imon.o
8obj-$(CONFIG_LIRC_PARALLEL) += lirc_parallel.o 8obj-$(CONFIG_LIRC_PARALLEL) += lirc_parallel.o
9obj-$(CONFIG_LIRC_SASEM) += lirc_sasem.o 9obj-$(CONFIG_LIRC_SASEM) += lirc_sasem.o
10obj-$(CONFIG_LIRC_SERIAL) += lirc_serial.o
11obj-$(CONFIG_LIRC_SIR) += lirc_sir.o 10obj-$(CONFIG_LIRC_SIR) += lirc_sir.o
12obj-$(CONFIG_LIRC_ZILOG) += lirc_zilog.o 11obj-$(CONFIG_LIRC_ZILOG) += lirc_zilog.o
diff --git a/drivers/staging/media/lirc/lirc_imon.c b/drivers/staging/media/lirc/lirc_imon.c
index 198a8057f2f1..1e650fba4a92 100644
--- a/drivers/staging/media/lirc/lirc_imon.c
+++ b/drivers/staging/media/lirc/lirc_imon.c
@@ -334,7 +334,7 @@ static int send_packet(struct imon_context *context)
334 334
335 context->tx_urb->actual_length = 0; 335 context->tx_urb->actual_length = 0;
336 336
337 init_completion(&context->tx.finished); 337 reinit_completion(&context->tx.finished);
338 atomic_set(&context->tx.busy, 1); 338 atomic_set(&context->tx.busy, 1);
339 339
340 retval = usb_submit_urb(context->tx_urb, GFP_KERNEL); 340 retval = usb_submit_urb(context->tx_urb, GFP_KERNEL);
@@ -408,9 +408,8 @@ static ssize_t vfd_write(struct file *file, const char __user *buf,
408 408
409 data_buf = memdup_user(buf, n_bytes); 409 data_buf = memdup_user(buf, n_bytes);
410 if (IS_ERR(data_buf)) { 410 if (IS_ERR(data_buf)) {
411 retval = PTR_ERR(data_buf); 411 mutex_unlock(&context->ctx_lock);
412 data_buf = NULL; 412 return PTR_ERR(data_buf);
413 goto exit;
414 } 413 }
415 414
416 memcpy(context->tx.data_buf, data_buf, n_bytes); 415 memcpy(context->tx.data_buf, data_buf, n_bytes);
@@ -497,6 +496,8 @@ static int ir_open(void *data)
497 context->rx.initial_space = 1; 496 context->rx.initial_space = 1;
498 context->rx.prev_bit = 0; 497 context->rx.prev_bit = 0;
499 498
499 init_completion(&context->tx.finished);
500
500 context->ir_isopen = 1; 501 context->ir_isopen = 1;
501 dev_info(context->driver->dev, "IR port opened\n"); 502 dev_info(context->driver->dev, "IR port opened\n");
502 503
@@ -930,7 +931,7 @@ static void imon_disconnect(struct usb_interface *interface)
930 /* Abort ongoing write */ 931 /* Abort ongoing write */
931 if (atomic_read(&context->tx.busy)) { 932 if (atomic_read(&context->tx.busy)) {
932 usb_kill_urb(context->tx_urb); 933 usb_kill_urb(context->tx_urb);
933 complete_all(&context->tx.finished); 934 complete(&context->tx.finished);
934 } 935 }
935 936
936 context->dev_present = 0; 937 context->dev_present = 0;
diff --git a/drivers/staging/media/lirc/lirc_sasem.c b/drivers/staging/media/lirc/lirc_sasem.c
index 4678ae10b030..4fd810bc46de 100644
--- a/drivers/staging/media/lirc/lirc_sasem.c
+++ b/drivers/staging/media/lirc/lirc_sasem.c
@@ -384,9 +384,8 @@ static ssize_t vfd_write(struct file *file, const char __user *buf,
384 384
385 data_buf = memdup_user(buf, n_bytes); 385 data_buf = memdup_user(buf, n_bytes);
386 if (IS_ERR(data_buf)) { 386 if (IS_ERR(data_buf)) {
387 retval = PTR_ERR(data_buf); 387 mutex_unlock(&context->ctx_lock);
388 data_buf = NULL; 388 return PTR_ERR(data_buf);
389 goto exit;
390 } 389 }
391 390
392 memcpy(context->tx.data_buf, data_buf, n_bytes); 391 memcpy(context->tx.data_buf, data_buf, n_bytes);
diff --git a/drivers/staging/media/lirc/lirc_serial.c b/drivers/staging/media/lirc/lirc_serial.c
deleted file mode 100644
index b798b311d32c..000000000000
--- a/drivers/staging/media/lirc/lirc_serial.c
+++ /dev/null
@@ -1,1130 +0,0 @@
1/*
2 * lirc_serial.c
3 *
4 * lirc_serial - Device driver that records pulse- and pause-lengths
5 * (space-lengths) between DDCD event on a serial port.
6 *
7 * Copyright (C) 1996,97 Ralph Metzler <rjkm@thp.uni-koeln.de>
8 * Copyright (C) 1998 Trent Piepho <xyzzy@u.washington.edu>
9 * Copyright (C) 1998 Ben Pfaff <blp@gnu.org>
10 * Copyright (C) 1999 Christoph Bartelmus <lirc@bartelmus.de>
11 * Copyright (C) 2007 Andrei Tanas <andrei@tanas.ca> (suspend/resume support)
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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 *
26 */
27
28/*
29 * Steve's changes to improve transmission fidelity:
30 * - for systems with the rdtsc instruction and the clock counter, a
31 * send_pule that times the pulses directly using the counter.
32 * This means that the LIRC_SERIAL_TRANSMITTER_LATENCY fudge is
33 * not needed. Measurement shows very stable waveform, even where
34 * PCI activity slows the access to the UART, which trips up other
35 * versions.
36 * - For other system, non-integer-microsecond pulse/space lengths,
37 * done using fixed point binary. So, much more accurate carrier
38 * frequency.
39 * - fine tuned transmitter latency, taking advantage of fractional
40 * microseconds in previous change
41 * - Fixed bug in the way transmitter latency was accounted for by
42 * tuning the pulse lengths down - the send_pulse routine ignored
43 * this overhead as it timed the overall pulse length - so the
44 * pulse frequency was right but overall pulse length was too
45 * long. Fixed by accounting for latency on each pulse/space
46 * iteration.
47 *
48 * Steve Davies <steve@daviesfam.org> July 2001
49 */
50
51#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
52
53#include <linux/module.h>
54#include <linux/errno.h>
55#include <linux/signal.h>
56#include <linux/sched.h>
57#include <linux/fs.h>
58#include <linux/interrupt.h>
59#include <linux/ioport.h>
60#include <linux/kernel.h>
61#include <linux/serial_reg.h>
62#include <linux/ktime.h>
63#include <linux/string.h>
64#include <linux/types.h>
65#include <linux/wait.h>
66#include <linux/mm.h>
67#include <linux/delay.h>
68#include <linux/poll.h>
69#include <linux/platform_device.h>
70#include <linux/gpio.h>
71#include <linux/io.h>
72#include <linux/irq.h>
73#include <linux/fcntl.h>
74#include <linux/spinlock.h>
75
76/* From Intel IXP42X Developer's Manual (#252480-005): */
77/* ftp://download.intel.com/design/network/manuals/25248005.pdf */
78#define UART_IE_IXP42X_UUE 0x40 /* IXP42X UART Unit enable */
79#define UART_IE_IXP42X_RTOIE 0x10 /* IXP42X Receiver Data Timeout int.enable */
80
81#include <media/lirc.h>
82#include <media/lirc_dev.h>
83
84#define LIRC_DRIVER_NAME "lirc_serial"
85
86struct lirc_serial {
87 int signal_pin;
88 int signal_pin_change;
89 u8 on;
90 u8 off;
91 long (*send_pulse)(unsigned long length);
92 void (*send_space)(long length);
93 int features;
94 spinlock_t lock;
95};
96
97#define LIRC_HOMEBREW 0
98#define LIRC_IRDEO 1
99#define LIRC_IRDEO_REMOTE 2
100#define LIRC_ANIMAX 3
101#define LIRC_IGOR 4
102#define LIRC_NSLU2 5
103
104/*** module parameters ***/
105static int type;
106static int io;
107static int irq;
108static bool iommap;
109static int ioshift;
110static bool softcarrier = true;
111static bool share_irq;
112static int sense = -1; /* -1 = auto, 0 = active high, 1 = active low */
113static bool txsense; /* 0 = active high, 1 = active low */
114
115/* forward declarations */
116static long send_pulse_irdeo(unsigned long length);
117static long send_pulse_homebrew(unsigned long length);
118static void send_space_irdeo(long length);
119static void send_space_homebrew(long length);
120
121static struct lirc_serial hardware[] = {
122 [LIRC_HOMEBREW] = {
123 .lock = __SPIN_LOCK_UNLOCKED(hardware[LIRC_HOMEBREW].lock),
124 .signal_pin = UART_MSR_DCD,
125 .signal_pin_change = UART_MSR_DDCD,
126 .on = (UART_MCR_RTS | UART_MCR_OUT2 | UART_MCR_DTR),
127 .off = (UART_MCR_RTS | UART_MCR_OUT2),
128 .send_pulse = send_pulse_homebrew,
129 .send_space = send_space_homebrew,
130#ifdef CONFIG_LIRC_SERIAL_TRANSMITTER
131 .features = (LIRC_CAN_SET_SEND_DUTY_CYCLE |
132 LIRC_CAN_SET_SEND_CARRIER |
133 LIRC_CAN_SEND_PULSE | LIRC_CAN_REC_MODE2)
134#else
135 .features = LIRC_CAN_REC_MODE2
136#endif
137 },
138
139 [LIRC_IRDEO] = {
140 .lock = __SPIN_LOCK_UNLOCKED(hardware[LIRC_IRDEO].lock),
141 .signal_pin = UART_MSR_DSR,
142 .signal_pin_change = UART_MSR_DDSR,
143 .on = UART_MCR_OUT2,
144 .off = (UART_MCR_RTS | UART_MCR_DTR | UART_MCR_OUT2),
145 .send_pulse = send_pulse_irdeo,
146 .send_space = send_space_irdeo,
147 .features = (LIRC_CAN_SET_SEND_DUTY_CYCLE |
148 LIRC_CAN_SEND_PULSE | LIRC_CAN_REC_MODE2)
149 },
150
151 [LIRC_IRDEO_REMOTE] = {
152 .lock = __SPIN_LOCK_UNLOCKED(hardware[LIRC_IRDEO_REMOTE].lock),
153 .signal_pin = UART_MSR_DSR,
154 .signal_pin_change = UART_MSR_DDSR,
155 .on = (UART_MCR_RTS | UART_MCR_DTR | UART_MCR_OUT2),
156 .off = (UART_MCR_RTS | UART_MCR_DTR | UART_MCR_OUT2),
157 .send_pulse = send_pulse_irdeo,
158 .send_space = send_space_irdeo,
159 .features = (LIRC_CAN_SET_SEND_DUTY_CYCLE |
160 LIRC_CAN_SEND_PULSE | LIRC_CAN_REC_MODE2)
161 },
162
163 [LIRC_ANIMAX] = {
164 .lock = __SPIN_LOCK_UNLOCKED(hardware[LIRC_ANIMAX].lock),
165 .signal_pin = UART_MSR_DCD,
166 .signal_pin_change = UART_MSR_DDCD,
167 .on = 0,
168 .off = (UART_MCR_RTS | UART_MCR_DTR | UART_MCR_OUT2),
169 .send_pulse = NULL,
170 .send_space = NULL,
171 .features = LIRC_CAN_REC_MODE2
172 },
173
174 [LIRC_IGOR] = {
175 .lock = __SPIN_LOCK_UNLOCKED(hardware[LIRC_IGOR].lock),
176 .signal_pin = UART_MSR_DSR,
177 .signal_pin_change = UART_MSR_DDSR,
178 .on = (UART_MCR_RTS | UART_MCR_OUT2 | UART_MCR_DTR),
179 .off = (UART_MCR_RTS | UART_MCR_OUT2),
180 .send_pulse = send_pulse_homebrew,
181 .send_space = send_space_homebrew,
182#ifdef CONFIG_LIRC_SERIAL_TRANSMITTER
183 .features = (LIRC_CAN_SET_SEND_DUTY_CYCLE |
184 LIRC_CAN_SET_SEND_CARRIER |
185 LIRC_CAN_SEND_PULSE | LIRC_CAN_REC_MODE2)
186#else
187 .features = LIRC_CAN_REC_MODE2
188#endif
189 },
190};
191
192#define RS_ISR_PASS_LIMIT 256
193
194/*
195 * A long pulse code from a remote might take up to 300 bytes. The
196 * daemon should read the bytes as soon as they are generated, so take
197 * the number of keys you think you can push before the daemon runs
198 * and multiply by 300. The driver will warn you if you overrun this
199 * buffer. If you have a slow computer or non-busmastering IDE disks,
200 * maybe you will need to increase this.
201 */
202
203/* This MUST be a power of two! It has to be larger than 1 as well. */
204
205#define RBUF_LEN 256
206
207static ktime_t lastkt;
208
209static struct lirc_buffer rbuf;
210
211static unsigned int freq = 38000;
212static unsigned int duty_cycle = 50;
213
214/* Initialized in init_timing_params() */
215static unsigned long period;
216static unsigned long pulse_width;
217static unsigned long space_width;
218
219#if defined(__i386__)
220/*
221 * From:
222 * Linux I/O port programming mini-HOWTO
223 * Author: Riku Saikkonen <Riku.Saikkonen@hut.fi>
224 * v, 28 December 1997
225 *
226 * [...]
227 * Actually, a port I/O instruction on most ports in the 0-0x3ff range
228 * takes almost exactly 1 microsecond, so if you're, for example, using
229 * the parallel port directly, just do additional inb()s from that port
230 * to delay.
231 * [...]
232 */
233/* transmitter latency 1.5625us 0x1.90 - this figure arrived at from
234 * comment above plus trimming to match actual measured frequency.
235 * This will be sensitive to cpu speed, though hopefully most of the 1.5us
236 * is spent in the uart access. Still - for reference test machine was a
237 * 1.13GHz Athlon system - Steve
238 */
239
240/*
241 * changed from 400 to 450 as this works better on slower machines;
242 * faster machines will use the rdtsc code anyway
243 */
244#define LIRC_SERIAL_TRANSMITTER_LATENCY 450
245
246#else
247
248/* does anybody have information on other platforms ? */
249/* 256 = 1<<8 */
250#define LIRC_SERIAL_TRANSMITTER_LATENCY 256
251
252#endif /* __i386__ */
253/*
254 * FIXME: should we be using hrtimers instead of this
255 * LIRC_SERIAL_TRANSMITTER_LATENCY nonsense?
256 */
257
258/* fetch serial input packet (1 byte) from register offset */
259static u8 sinp(int offset)
260{
261 if (iommap)
262 /* the register is memory-mapped */
263 offset <<= ioshift;
264
265 return inb(io + offset);
266}
267
268/* write serial output packet (1 byte) of value to register offset */
269static void soutp(int offset, u8 value)
270{
271 if (iommap)
272 /* the register is memory-mapped */
273 offset <<= ioshift;
274
275 outb(value, io + offset);
276}
277
278static void on(void)
279{
280 if (txsense)
281 soutp(UART_MCR, hardware[type].off);
282 else
283 soutp(UART_MCR, hardware[type].on);
284}
285
286static void off(void)
287{
288 if (txsense)
289 soutp(UART_MCR, hardware[type].on);
290 else
291 soutp(UART_MCR, hardware[type].off);
292}
293
294#ifndef MAX_UDELAY_MS
295#define MAX_UDELAY_US 5000
296#else
297#define MAX_UDELAY_US (MAX_UDELAY_MS*1000)
298#endif
299
300static void safe_udelay(unsigned long usecs)
301{
302 while (usecs > MAX_UDELAY_US) {
303 udelay(MAX_UDELAY_US);
304 usecs -= MAX_UDELAY_US;
305 }
306 udelay(usecs);
307}
308
309#ifdef USE_RDTSC
310/*
311 * This is an overflow/precision juggle, complicated in that we can't
312 * do long long divide in the kernel
313 */
314
315/*
316 * When we use the rdtsc instruction to measure clocks, we keep the
317 * pulse and space widths as clock cycles. As this is CPU speed
318 * dependent, the widths must be calculated in init_port and ioctl
319 * time
320 */
321
322static int init_timing_params(unsigned int new_duty_cycle,
323 unsigned int new_freq)
324{
325 __u64 loops_per_sec, work;
326
327 duty_cycle = new_duty_cycle;
328 freq = new_freq;
329
330 loops_per_sec = __this_cpu_read(cpu.info.loops_per_jiffy);
331 loops_per_sec *= HZ;
332
333 /* How many clocks in a microsecond?, avoiding long long divide */
334 work = loops_per_sec;
335 work *= 4295; /* 4295 = 2^32 / 1e6 */
336
337 /*
338 * Carrier period in clocks, approach good up to 32GHz clock,
339 * gets carrier frequency within 8Hz
340 */
341 period = loops_per_sec >> 3;
342 period /= (freq >> 3);
343
344 /* Derive pulse and space from the period */
345 pulse_width = period * duty_cycle / 100;
346 space_width = period - pulse_width;
347 pr_debug("in init_timing_params, freq=%d, duty_cycle=%d, clk/jiffy=%ld, pulse=%ld, space=%ld, conv_us_to_clocks=%ld\n",
348 freq, duty_cycle, __this_cpu_read(cpu_info.loops_per_jiffy),
349 pulse_width, space_width, conv_us_to_clocks);
350 return 0;
351}
352#else /* ! USE_RDTSC */
353static int init_timing_params(unsigned int new_duty_cycle,
354 unsigned int new_freq)
355{
356/*
357 * period, pulse/space width are kept with 8 binary places -
358 * IE multiplied by 256.
359 */
360 if (256 * 1000000L / new_freq * new_duty_cycle / 100 <=
361 LIRC_SERIAL_TRANSMITTER_LATENCY)
362 return -EINVAL;
363 if (256 * 1000000L / new_freq * (100 - new_duty_cycle) / 100 <=
364 LIRC_SERIAL_TRANSMITTER_LATENCY)
365 return -EINVAL;
366 duty_cycle = new_duty_cycle;
367 freq = new_freq;
368 period = 256 * 1000000L / freq;
369 pulse_width = period * duty_cycle / 100;
370 space_width = period - pulse_width;
371 pr_debug("in init_timing_params, freq=%d pulse=%ld, space=%ld\n",
372 freq, pulse_width, space_width);
373 return 0;
374}
375#endif /* USE_RDTSC */
376
377
378/* return value: space length delta */
379
380static long send_pulse_irdeo(unsigned long length)
381{
382 long rawbits, ret;
383 int i;
384 unsigned char output;
385 unsigned char chunk, shifted;
386
387 /* how many bits have to be sent ? */
388 rawbits = length * 1152 / 10000;
389 if (duty_cycle > 50)
390 chunk = 3;
391 else
392 chunk = 1;
393 for (i = 0, output = 0x7f; rawbits > 0; rawbits -= 3) {
394 shifted = chunk << (i * 3);
395 shifted >>= 1;
396 output &= (~shifted);
397 i++;
398 if (i == 3) {
399 soutp(UART_TX, output);
400 while (!(sinp(UART_LSR) & UART_LSR_THRE))
401 ;
402 output = 0x7f;
403 i = 0;
404 }
405 }
406 if (i != 0) {
407 soutp(UART_TX, output);
408 while (!(sinp(UART_LSR) & UART_LSR_TEMT))
409 ;
410 }
411
412 if (i == 0)
413 ret = (-rawbits) * 10000 / 1152;
414 else
415 ret = (3 - i) * 3 * 10000 / 1152 + (-rawbits) * 10000 / 1152;
416
417 return ret;
418}
419
420/* Version using udelay() */
421
422/*
423 * here we use fixed point arithmetic, with 8
424 * fractional bits. that gets us within 0.1% or so of the right average
425 * frequency, albeit with some jitter in pulse length - Steve
426 *
427 * This should use ndelay instead.
428 */
429
430/* To match 8 fractional bits used for pulse/space length */
431
432static long send_pulse_homebrew_softcarrier(unsigned long length)
433{
434 int flag;
435 unsigned long actual, target, d;
436
437 length <<= 8;
438
439 actual = 0; target = 0; flag = 0;
440 while (actual < length) {
441 if (flag) {
442 off();
443 target += space_width;
444 } else {
445 on();
446 target += pulse_width;
447 }
448 d = (target - actual -
449 LIRC_SERIAL_TRANSMITTER_LATENCY + 128) >> 8;
450 /*
451 * Note - we've checked in ioctl that the pulse/space
452 * widths are big enough so that d is > 0
453 */
454 udelay(d);
455 actual += (d << 8) + LIRC_SERIAL_TRANSMITTER_LATENCY;
456 flag = !flag;
457 }
458 return (actual-length) >> 8;
459}
460
461static long send_pulse_homebrew(unsigned long length)
462{
463 if (length <= 0)
464 return 0;
465
466 if (softcarrier)
467 return send_pulse_homebrew_softcarrier(length);
468
469 on();
470 safe_udelay(length);
471 return 0;
472}
473
474static void send_space_irdeo(long length)
475{
476 if (length <= 0)
477 return;
478
479 safe_udelay(length);
480}
481
482static void send_space_homebrew(long length)
483{
484 off();
485 if (length <= 0)
486 return;
487 safe_udelay(length);
488}
489
490static void rbwrite(int l)
491{
492 if (lirc_buffer_full(&rbuf)) {
493 /* no new signals will be accepted */
494 pr_debug("Buffer overrun\n");
495 return;
496 }
497 lirc_buffer_write(&rbuf, (void *)&l);
498}
499
500static void frbwrite(int l)
501{
502 /* simple noise filter */
503 static int pulse, space;
504 static unsigned int ptr;
505
506 if (ptr > 0 && (l & PULSE_BIT)) {
507 pulse += l & PULSE_MASK;
508 if (pulse > 250) {
509 rbwrite(space);
510 rbwrite(pulse | PULSE_BIT);
511 ptr = 0;
512 pulse = 0;
513 }
514 return;
515 }
516 if (!(l & PULSE_BIT)) {
517 if (ptr == 0) {
518 if (l > 20000) {
519 space = l;
520 ptr++;
521 return;
522 }
523 } else {
524 if (l > 20000) {
525 space += pulse;
526 if (space > PULSE_MASK)
527 space = PULSE_MASK;
528 space += l;
529 if (space > PULSE_MASK)
530 space = PULSE_MASK;
531 pulse = 0;
532 return;
533 }
534 rbwrite(space);
535 rbwrite(pulse | PULSE_BIT);
536 ptr = 0;
537 pulse = 0;
538 }
539 }
540 rbwrite(l);
541}
542
543static irqreturn_t lirc_irq_handler(int i, void *blah)
544{
545 ktime_t kt;
546 int counter, dcd;
547 u8 status;
548 ktime_t delkt;
549 int data;
550 static int last_dcd = -1;
551
552 if ((sinp(UART_IIR) & UART_IIR_NO_INT)) {
553 /* not our interrupt */
554 return IRQ_NONE;
555 }
556
557 counter = 0;
558 do {
559 counter++;
560 status = sinp(UART_MSR);
561 if (counter > RS_ISR_PASS_LIMIT) {
562 pr_warn("AIEEEE: We're caught!\n");
563 break;
564 }
565 if ((status & hardware[type].signal_pin_change)
566 && sense != -1) {
567 /* get current time */
568 kt = ktime_get();
569
570 /* New mode, written by Trent Piepho
571 <xyzzy@u.washington.edu>. */
572
573 /*
574 * The old format was not very portable.
575 * We now use an int to pass pulses
576 * and spaces to user space.
577 *
578 * If PULSE_BIT is set a pulse has been
579 * received, otherwise a space has been
580 * received. The driver needs to know if your
581 * receiver is active high or active low, or
582 * the space/pulse sense could be
583 * inverted. The bits denoted by PULSE_MASK are
584 * the length in microseconds. Lengths greater
585 * than or equal to 16 seconds are clamped to
586 * PULSE_MASK. All other bits are unused.
587 * This is a much simpler interface for user
588 * programs, as well as eliminating "out of
589 * phase" errors with space/pulse
590 * autodetection.
591 */
592
593 /* calc time since last interrupt in microseconds */
594 dcd = (status & hardware[type].signal_pin) ? 1 : 0;
595
596 if (dcd == last_dcd) {
597 pr_warn("ignoring spike: %d %d %llx %llx\n",
598 dcd, sense, ktime_to_us(kt),
599 ktime_to_us(lastkt));
600 continue;
601 }
602
603 delkt = ktime_sub(kt, lastkt);
604 if (ktime_compare(delkt, ktime_set(15, 0)) > 0) {
605 data = PULSE_MASK; /* really long time */
606 if (!(dcd^sense)) {
607 /* sanity check */
608 pr_warn("AIEEEE: %d %d %llx %llx\n",
609 dcd, sense, ktime_to_us(kt),
610 ktime_to_us(lastkt));
611 /*
612 * detecting pulse while this
613 * MUST be a space!
614 */
615 sense = sense ? 0 : 1;
616 }
617 } else
618 data = (int) ktime_to_us(delkt);
619 frbwrite(dcd^sense ? data : (data|PULSE_BIT));
620 lastkt = kt;
621 last_dcd = dcd;
622 wake_up_interruptible(&rbuf.wait_poll);
623 }
624 } while (!(sinp(UART_IIR) & UART_IIR_NO_INT)); /* still pending ? */
625 return IRQ_HANDLED;
626}
627
628
629static int hardware_init_port(void)
630{
631 u8 scratch, scratch2, scratch3;
632
633 /*
634 * This is a simple port existence test, borrowed from the autoconfig
635 * function in drivers/serial/8250.c
636 */
637 scratch = sinp(UART_IER);
638 soutp(UART_IER, 0);
639#ifdef __i386__
640 outb(0xff, 0x080);
641#endif
642 scratch2 = sinp(UART_IER) & 0x0f;
643 soutp(UART_IER, 0x0f);
644#ifdef __i386__
645 outb(0x00, 0x080);
646#endif
647 scratch3 = sinp(UART_IER) & 0x0f;
648 soutp(UART_IER, scratch);
649 if (scratch2 != 0 || scratch3 != 0x0f) {
650 /* we fail, there's nothing here */
651 pr_err("port existence test failed, cannot continue\n");
652 return -ENODEV;
653 }
654
655
656
657 /* Set DLAB 0. */
658 soutp(UART_LCR, sinp(UART_LCR) & (~UART_LCR_DLAB));
659
660 /* First of all, disable all interrupts */
661 soutp(UART_IER, sinp(UART_IER) &
662 (~(UART_IER_MSI|UART_IER_RLSI|UART_IER_THRI|UART_IER_RDI)));
663
664 /* Clear registers. */
665 sinp(UART_LSR);
666 sinp(UART_RX);
667 sinp(UART_IIR);
668 sinp(UART_MSR);
669
670 /* Set line for power source */
671 off();
672
673 /* Clear registers again to be sure. */
674 sinp(UART_LSR);
675 sinp(UART_RX);
676 sinp(UART_IIR);
677 sinp(UART_MSR);
678
679 switch (type) {
680 case LIRC_IRDEO:
681 case LIRC_IRDEO_REMOTE:
682 /* setup port to 7N1 @ 115200 Baud */
683 /* 7N1+start = 9 bits at 115200 ~ 3 bits at 38kHz */
684
685 /* Set DLAB 1. */
686 soutp(UART_LCR, sinp(UART_LCR) | UART_LCR_DLAB);
687 /* Set divisor to 1 => 115200 Baud */
688 soutp(UART_DLM, 0);
689 soutp(UART_DLL, 1);
690 /* Set DLAB 0 + 7N1 */
691 soutp(UART_LCR, UART_LCR_WLEN7);
692 /* THR interrupt already disabled at this point */
693 break;
694 default:
695 break;
696 }
697
698 return 0;
699}
700
701static int lirc_serial_probe(struct platform_device *dev)
702{
703 int i, nlow, nhigh, result;
704
705 result = devm_request_irq(&dev->dev, irq, lirc_irq_handler,
706 (share_irq ? IRQF_SHARED : 0),
707 LIRC_DRIVER_NAME, &hardware);
708 if (result < 0) {
709 if (result == -EBUSY)
710 dev_err(&dev->dev, "IRQ %d busy\n", irq);
711 else if (result == -EINVAL)
712 dev_err(&dev->dev, "Bad irq number or handler\n");
713 return result;
714 }
715
716 /* Reserve io region. */
717 /*
718 * Future MMAP-Developers: Attention!
719 * For memory mapped I/O you *might* need to use ioremap() first,
720 * for the NSLU2 it's done in boot code.
721 */
722 if (((iommap)
723 && (devm_request_mem_region(&dev->dev, iommap, 8 << ioshift,
724 LIRC_DRIVER_NAME) == NULL))
725 || ((!iommap)
726 && (devm_request_region(&dev->dev, io, 8,
727 LIRC_DRIVER_NAME) == NULL))) {
728 dev_err(&dev->dev, "port %04x already in use\n", io);
729 dev_warn(&dev->dev, "use 'setserial /dev/ttySX uart none'\n");
730 dev_warn(&dev->dev,
731 "or compile the serial port driver as module and\n");
732 dev_warn(&dev->dev, "make sure this module is loaded first\n");
733 return -EBUSY;
734 }
735
736 result = hardware_init_port();
737 if (result < 0)
738 return result;
739
740 /* Initialize pulse/space widths */
741 init_timing_params(duty_cycle, freq);
742
743 /* If pin is high, then this must be an active low receiver. */
744 if (sense == -1) {
745 /* wait 1/2 sec for the power supply */
746 msleep(500);
747
748 /*
749 * probe 9 times every 0.04s, collect "votes" for
750 * active high/low
751 */
752 nlow = 0;
753 nhigh = 0;
754 for (i = 0; i < 9; i++) {
755 if (sinp(UART_MSR) & hardware[type].signal_pin)
756 nlow++;
757 else
758 nhigh++;
759 msleep(40);
760 }
761 sense = nlow >= nhigh ? 1 : 0;
762 dev_info(&dev->dev, "auto-detected active %s receiver\n",
763 sense ? "low" : "high");
764 } else
765 dev_info(&dev->dev, "Manually using active %s receiver\n",
766 sense ? "low" : "high");
767
768 dev_dbg(&dev->dev, "Interrupt %d, port %04x obtained\n", irq, io);
769 return 0;
770}
771
772static int set_use_inc(void *data)
773{
774 unsigned long flags;
775
776 /* initialize timestamp */
777 lastkt = ktime_get();
778
779 spin_lock_irqsave(&hardware[type].lock, flags);
780
781 /* Set DLAB 0. */
782 soutp(UART_LCR, sinp(UART_LCR) & (~UART_LCR_DLAB));
783
784 soutp(UART_IER, sinp(UART_IER)|UART_IER_MSI);
785
786 spin_unlock_irqrestore(&hardware[type].lock, flags);
787
788 return 0;
789}
790
791static void set_use_dec(void *data)
792{ unsigned long flags;
793
794 spin_lock_irqsave(&hardware[type].lock, flags);
795
796 /* Set DLAB 0. */
797 soutp(UART_LCR, sinp(UART_LCR) & (~UART_LCR_DLAB));
798
799 /* First of all, disable all interrupts */
800 soutp(UART_IER, sinp(UART_IER) &
801 (~(UART_IER_MSI|UART_IER_RLSI|UART_IER_THRI|UART_IER_RDI)));
802 spin_unlock_irqrestore(&hardware[type].lock, flags);
803}
804
805static ssize_t lirc_write(struct file *file, const char __user *buf,
806 size_t n, loff_t *ppos)
807{
808 int i, count;
809 unsigned long flags;
810 long delta = 0;
811 int *wbuf;
812
813 if (!(hardware[type].features & LIRC_CAN_SEND_PULSE))
814 return -EPERM;
815
816 count = n / sizeof(int);
817 if (n % sizeof(int) || count % 2 == 0)
818 return -EINVAL;
819 wbuf = memdup_user(buf, n);
820 if (IS_ERR(wbuf))
821 return PTR_ERR(wbuf);
822 spin_lock_irqsave(&hardware[type].lock, flags);
823 if (type == LIRC_IRDEO) {
824 /* DTR, RTS down */
825 on();
826 }
827 for (i = 0; i < count; i++) {
828 if (i%2)
829 hardware[type].send_space(wbuf[i] - delta);
830 else
831 delta = hardware[type].send_pulse(wbuf[i]);
832 }
833 off();
834 spin_unlock_irqrestore(&hardware[type].lock, flags);
835 kfree(wbuf);
836 return n;
837}
838
839static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
840{
841 int result;
842 u32 __user *uptr = (u32 __user *)arg;
843 u32 value;
844
845 switch (cmd) {
846 case LIRC_GET_SEND_MODE:
847 if (!(hardware[type].features&LIRC_CAN_SEND_MASK))
848 return -ENOIOCTLCMD;
849
850 result = put_user(LIRC_SEND2MODE
851 (hardware[type].features&LIRC_CAN_SEND_MASK),
852 uptr);
853 if (result)
854 return result;
855 break;
856
857 case LIRC_SET_SEND_MODE:
858 if (!(hardware[type].features&LIRC_CAN_SEND_MASK))
859 return -ENOIOCTLCMD;
860
861 result = get_user(value, uptr);
862 if (result)
863 return result;
864 /* only LIRC_MODE_PULSE supported */
865 if (value != LIRC_MODE_PULSE)
866 return -EINVAL;
867 break;
868
869 case LIRC_GET_LENGTH:
870 return -ENOIOCTLCMD;
871
872 case LIRC_SET_SEND_DUTY_CYCLE:
873 pr_debug("SET_SEND_DUTY_CYCLE\n");
874 if (!(hardware[type].features&LIRC_CAN_SET_SEND_DUTY_CYCLE))
875 return -ENOIOCTLCMD;
876
877 result = get_user(value, uptr);
878 if (result)
879 return result;
880 if (value <= 0 || value > 100)
881 return -EINVAL;
882 return init_timing_params(value, freq);
883
884 case LIRC_SET_SEND_CARRIER:
885 pr_debug("SET_SEND_CARRIER\n");
886 if (!(hardware[type].features&LIRC_CAN_SET_SEND_CARRIER))
887 return -ENOIOCTLCMD;
888
889 result = get_user(value, uptr);
890 if (result)
891 return result;
892 if (value > 500000 || value < 20000)
893 return -EINVAL;
894 return init_timing_params(duty_cycle, value);
895
896 default:
897 return lirc_dev_fop_ioctl(filep, cmd, arg);
898 }
899 return 0;
900}
901
902static const struct file_operations lirc_fops = {
903 .owner = THIS_MODULE,
904 .write = lirc_write,
905 .unlocked_ioctl = lirc_ioctl,
906#ifdef CONFIG_COMPAT
907 .compat_ioctl = lirc_ioctl,
908#endif
909 .read = lirc_dev_fop_read,
910 .poll = lirc_dev_fop_poll,
911 .open = lirc_dev_fop_open,
912 .release = lirc_dev_fop_close,
913 .llseek = no_llseek,
914};
915
916static struct lirc_driver driver = {
917 .name = LIRC_DRIVER_NAME,
918 .minor = -1,
919 .code_length = 1,
920 .sample_rate = 0,
921 .data = NULL,
922 .add_to_buf = NULL,
923 .rbuf = &rbuf,
924 .set_use_inc = set_use_inc,
925 .set_use_dec = set_use_dec,
926 .fops = &lirc_fops,
927 .dev = NULL,
928 .owner = THIS_MODULE,
929};
930
931static struct platform_device *lirc_serial_dev;
932
933static int lirc_serial_suspend(struct platform_device *dev,
934 pm_message_t state)
935{
936 /* Set DLAB 0. */
937 soutp(UART_LCR, sinp(UART_LCR) & (~UART_LCR_DLAB));
938
939 /* Disable all interrupts */
940 soutp(UART_IER, sinp(UART_IER) &
941 (~(UART_IER_MSI|UART_IER_RLSI|UART_IER_THRI|UART_IER_RDI)));
942
943 /* Clear registers. */
944 sinp(UART_LSR);
945 sinp(UART_RX);
946 sinp(UART_IIR);
947 sinp(UART_MSR);
948
949 return 0;
950}
951
952/* twisty maze... need a forward-declaration here... */
953static void lirc_serial_exit(void);
954
955static int lirc_serial_resume(struct platform_device *dev)
956{
957 unsigned long flags;
958 int result;
959
960 result = hardware_init_port();
961 if (result < 0)
962 return result;
963
964 spin_lock_irqsave(&hardware[type].lock, flags);
965 /* Enable Interrupt */
966 lastkt = ktime_get();
967 soutp(UART_IER, sinp(UART_IER)|UART_IER_MSI);
968 off();
969
970 lirc_buffer_clear(&rbuf);
971
972 spin_unlock_irqrestore(&hardware[type].lock, flags);
973
974 return 0;
975}
976
977static struct platform_driver lirc_serial_driver = {
978 .probe = lirc_serial_probe,
979 .suspend = lirc_serial_suspend,
980 .resume = lirc_serial_resume,
981 .driver = {
982 .name = "lirc_serial",
983 },
984};
985
986static int __init lirc_serial_init(void)
987{
988 int result;
989
990 /* Init read buffer. */
991 result = lirc_buffer_init(&rbuf, sizeof(int), RBUF_LEN);
992 if (result < 0)
993 return result;
994
995 result = platform_driver_register(&lirc_serial_driver);
996 if (result) {
997 printk("lirc register returned %d\n", result);
998 goto exit_buffer_free;
999 }
1000
1001 lirc_serial_dev = platform_device_alloc("lirc_serial", 0);
1002 if (!lirc_serial_dev) {
1003 result = -ENOMEM;
1004 goto exit_driver_unregister;
1005 }
1006
1007 result = platform_device_add(lirc_serial_dev);
1008 if (result)
1009 goto exit_device_put;
1010
1011 return 0;
1012
1013exit_device_put:
1014 platform_device_put(lirc_serial_dev);
1015exit_driver_unregister:
1016 platform_driver_unregister(&lirc_serial_driver);
1017exit_buffer_free:
1018 lirc_buffer_free(&rbuf);
1019 return result;
1020}
1021
1022static void lirc_serial_exit(void)
1023{
1024 platform_device_unregister(lirc_serial_dev);
1025 platform_driver_unregister(&lirc_serial_driver);
1026 lirc_buffer_free(&rbuf);
1027}
1028
1029static int __init lirc_serial_init_module(void)
1030{
1031 int result;
1032
1033 switch (type) {
1034 case LIRC_HOMEBREW:
1035 case LIRC_IRDEO:
1036 case LIRC_IRDEO_REMOTE:
1037 case LIRC_ANIMAX:
1038 case LIRC_IGOR:
1039 /* if nothing specified, use ttyS0/com1 and irq 4 */
1040 io = io ? io : 0x3f8;
1041 irq = irq ? irq : 4;
1042 break;
1043 default:
1044 return -EINVAL;
1045 }
1046 if (!softcarrier) {
1047 switch (type) {
1048 case LIRC_HOMEBREW:
1049 case LIRC_IGOR:
1050 hardware[type].features &=
1051 ~(LIRC_CAN_SET_SEND_DUTY_CYCLE|
1052 LIRC_CAN_SET_SEND_CARRIER);
1053 break;
1054 }
1055 }
1056
1057 /* make sure sense is either -1, 0, or 1 */
1058 if (sense != -1)
1059 sense = !!sense;
1060
1061 result = lirc_serial_init();
1062 if (result)
1063 return result;
1064
1065 driver.features = hardware[type].features;
1066 driver.dev = &lirc_serial_dev->dev;
1067 driver.minor = lirc_register_driver(&driver);
1068 if (driver.minor < 0) {
1069 pr_err("register_chrdev failed!\n");
1070 lirc_serial_exit();
1071 return driver.minor;
1072 }
1073 return 0;
1074}
1075
1076static void __exit lirc_serial_exit_module(void)
1077{
1078 lirc_unregister_driver(driver.minor);
1079 lirc_serial_exit();
1080 pr_debug("cleaned up module\n");
1081}
1082
1083
1084module_init(lirc_serial_init_module);
1085module_exit(lirc_serial_exit_module);
1086
1087MODULE_DESCRIPTION("Infra-red receiver driver for serial ports.");
1088MODULE_AUTHOR("Ralph Metzler, Trent Piepho, Ben Pfaff, "
1089 "Christoph Bartelmus, Andrei Tanas");
1090MODULE_LICENSE("GPL");
1091
1092module_param(type, int, S_IRUGO);
1093MODULE_PARM_DESC(type, "Hardware type (0 = home-brew, 1 = IRdeo,"
1094 " 2 = IRdeo Remote, 3 = AnimaX, 4 = IgorPlug,"
1095 " 5 = NSLU2 RX:CTS2/TX:GreenLED)");
1096
1097module_param(io, int, S_IRUGO);
1098MODULE_PARM_DESC(io, "I/O address base (0x3f8 or 0x2f8)");
1099
1100/* some architectures (e.g. intel xscale) have memory mapped registers */
1101module_param(iommap, bool, S_IRUGO);
1102MODULE_PARM_DESC(iommap, "physical base for memory mapped I/O"
1103 " (0 = no memory mapped io)");
1104
1105/*
1106 * some architectures (e.g. intel xscale) align the 8bit serial registers
1107 * on 32bit word boundaries.
1108 * See linux-kernel/drivers/tty/serial/8250/8250.c serial_in()/out()
1109 */
1110module_param(ioshift, int, S_IRUGO);
1111MODULE_PARM_DESC(ioshift, "shift I/O register offset (0 = no shift)");
1112
1113module_param(irq, int, S_IRUGO);
1114MODULE_PARM_DESC(irq, "Interrupt (4 or 3)");
1115
1116module_param(share_irq, bool, S_IRUGO);
1117MODULE_PARM_DESC(share_irq, "Share interrupts (0 = off, 1 = on)");
1118
1119module_param(sense, int, S_IRUGO);
1120MODULE_PARM_DESC(sense, "Override autodetection of IR receiver circuit"
1121 " (0 = active high, 1 = active low )");
1122
1123#ifdef CONFIG_LIRC_SERIAL_TRANSMITTER
1124module_param(txsense, bool, S_IRUGO);
1125MODULE_PARM_DESC(txsense, "Sense of transmitter circuit"
1126 " (0 = active high, 1 = active low )");
1127#endif
1128
1129module_param(softcarrier, bool, S_IRUGO);
1130MODULE_PARM_DESC(softcarrier, "Software carrier (0 = off, 1 = on, default on)");
diff --git a/drivers/staging/media/pulse8-cec/TODO b/drivers/staging/media/pulse8-cec/TODO
deleted file mode 100644
index fa6660245e5f..000000000000
--- a/drivers/staging/media/pulse8-cec/TODO
+++ /dev/null
@@ -1,52 +0,0 @@
1This driver needs to mature a bit more and another round of
2code cleanups.
3
4Otherwise it looks to be in good shape. And of course the fact
5that the CEC framework is in staging at the moment also prevents
6this driver from being mainlined.
7
8Some notes:
9
101) Regarding the "autonomous" mode of the Pulse-Eight: currently this
11is disabled, but the idea is that this allows basic functionality
12when the PC is off, and it can wake-up the PC through USB.
13
14To prevent the device to go into autonomous mode the driver would
15have to send MSGCODE_SET_CONTROLLED 1 and then send a ping every
1630 seconds (in practice once every 15 seconds would be good). When
17powering off or going to standby send MSGCODE_SET_CONTROLLED 0 to
18turn the autonomous mode back on.
19
20This needs to be implemented in the driver. Autonomous mode was
21added in firmware v2.
22
232) Writing to the EEPROM can only be done once every 10 seconds.
24
253) To use this driver you also need to patch the inputattach utility,
26this patch will be submitted once this driver is moved out of staging.
27
28diff -urN linuxconsoletools-1.4.9/utils/inputattach.c linuxconsoletools-1.4.9.new/utils/inputattach.c
29--- linuxconsoletools-1.4.9/utils/inputattach.c 2016-01-09 16:27:02.000000000 +0100
30+++ linuxconsoletools-1.4.9.new/utils/inputattach.c 2016-03-20 11:35:31.707788967 +0100
31@@ -861,6 +861,9 @@
32 { "--wacom_iv", "-wacom_iv", "Wacom protocol IV tablet",
33 B9600, CS8 | CRTSCTS,
34 SERIO_WACOM_IV, 0x00, 0x00, 0, wacom_iv_init },
35+{ "--pulse8-cec", "-pulse8-cec", "Pulse Eight HDMI CEC dongle",
36+ B9600, CS8,
37+ SERIO_PULSE8_CEC, 0x00, 0x00, 0, NULL },
38 { NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, NULL }
39 };
40
41diff -urN linuxconsoletools-1.4.9/utils/serio-ids.h linuxconsoletools-1.4.9.new/utils/serio-ids.h
42--- linuxconsoletools-1.4.9/utils/serio-ids.h 2015-04-26 18:29:42.000000000 +0200
43+++ linuxconsoletools-1.4.9.new/utils/serio-ids.h 2016-03-20 11:41:00.153558539 +0100
44@@ -131,5 +131,8 @@
45 #ifndef SERIO_EASYPEN
46 # define SERIO_EASYPEN 0x3f
47 #endif
48+#ifndef SERIO_PULSE8_CEC
49+# define SERIO_PULSE8_CEC 0x40
50+#endif
51
52 #endif
diff --git a/drivers/staging/media/s5p-cec/Kconfig b/drivers/staging/media/s5p-cec/Kconfig
index 0315fd7ad0f1..ddfd955da0d4 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 && (PLAT_S5P || ARCH_EXYNOS || COMPILE_TEST) 3 depends on VIDEO_DEV && MEDIA_CEC_SUPPORT && (PLAT_S5P || 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/TODO b/drivers/staging/media/s5p-cec/TODO
index f51d5268ac40..64f21bab38f5 100644
--- a/drivers/staging/media/s5p-cec/TODO
+++ b/drivers/staging/media/s5p-cec/TODO
@@ -1,7 +1,7 @@
1This driver depends on the CEC framework, which is currently in 1This driver requires that userspace sets the physical address.
2staging, so therefor this driver is in staging as well. 2However, this should be passed on from the corresponding
3Samsung HDMI driver.
3 4
4In addition, this driver requires that userspace sets the physical 5We have to wait until the HDMI notifier framework has been merged
5address. However, this should be passed on from the corresponding 6in order to handle this gracefully, until that time this driver
6samsung HDMI driver. It is very annoying if userspace has to do this, 7has to remain in staging.
7and other than USB CEC adapters this must be handled automatically.
diff --git a/drivers/staging/media/s5p-cec/s5p_cec.c b/drivers/staging/media/s5p-cec/s5p_cec.c
index 1780a08b73c9..2a07968b5ac6 100644
--- a/drivers/staging/media/s5p-cec/s5p_cec.c
+++ b/drivers/staging/media/s5p-cec/s5p_cec.c
@@ -22,7 +22,6 @@
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/pm_runtime.h> 23#include <linux/pm_runtime.h>
24#include <linux/timer.h> 24#include <linux/timer.h>
25#include <linux/version.h>
26#include <linux/workqueue.h> 25#include <linux/workqueue.h>
27#include <media/cec.h> 26#include <media/cec.h>
28 27
@@ -204,12 +203,11 @@ static int s5p_cec_probe(struct platform_device *pdev)
204 cec->adap = cec_allocate_adapter(&s5p_cec_adap_ops, cec, 203 cec->adap = cec_allocate_adapter(&s5p_cec_adap_ops, cec,
205 CEC_NAME, 204 CEC_NAME,
206 CEC_CAP_PHYS_ADDR | CEC_CAP_LOG_ADDRS | CEC_CAP_TRANSMIT | 205 CEC_CAP_PHYS_ADDR | CEC_CAP_LOG_ADDRS | CEC_CAP_TRANSMIT |
207 CEC_CAP_PASSTHROUGH | CEC_CAP_RC, 206 CEC_CAP_PASSTHROUGH | CEC_CAP_RC, 1);
208 1, &pdev->dev);
209 ret = PTR_ERR_OR_ZERO(cec->adap); 207 ret = PTR_ERR_OR_ZERO(cec->adap);
210 if (ret) 208 if (ret)
211 return ret; 209 return ret;
212 ret = cec_register_adapter(cec->adap); 210 ret = cec_register_adapter(cec->adap, &pdev->dev);
213 if (ret) { 211 if (ret) {
214 cec_delete_adapter(cec->adap); 212 cec_delete_adapter(cec->adap);
215 return ret; 213 return ret;
@@ -231,7 +229,7 @@ static int s5p_cec_remove(struct platform_device *pdev)
231 return 0; 229 return 0;
232} 230}
233 231
234static int s5p_cec_runtime_suspend(struct device *dev) 232static int __maybe_unused s5p_cec_runtime_suspend(struct device *dev)
235{ 233{
236 struct s5p_cec_dev *cec = dev_get_drvdata(dev); 234 struct s5p_cec_dev *cec = dev_get_drvdata(dev);
237 235
@@ -239,7 +237,7 @@ static int s5p_cec_runtime_suspend(struct device *dev)
239 return 0; 237 return 0;
240} 238}
241 239
242static int s5p_cec_runtime_resume(struct device *dev) 240static int __maybe_unused s5p_cec_runtime_resume(struct device *dev)
243{ 241{
244 struct s5p_cec_dev *cec = dev_get_drvdata(dev); 242 struct s5p_cec_dev *cec = dev_get_drvdata(dev);
245 int ret; 243 int ret;
@@ -263,6 +261,7 @@ static const struct of_device_id s5p_cec_match[] = {
263 }, 261 },
264 {}, 262 {},
265}; 263};
264MODULE_DEVICE_TABLE(of, s5p_cec_match);
266 265
267static struct platform_driver s5p_cec_pdrv = { 266static struct platform_driver s5p_cec_pdrv = {
268 .probe = s5p_cec_probe, 267 .probe = s5p_cec_probe,
diff --git a/drivers/staging/media/st-cec/Kconfig b/drivers/staging/media/st-cec/Kconfig
index 784d2c600aca..c04283db58d6 100644
--- a/drivers/staging/media/st-cec/Kconfig
+++ b/drivers/staging/media/st-cec/Kconfig
@@ -1,6 +1,6 @@
1config VIDEO_STI_HDMI_CEC 1config VIDEO_STI_HDMI_CEC
2 tristate "STMicroelectronics STiH4xx HDMI CEC driver" 2 tristate "STMicroelectronics STiH4xx HDMI CEC driver"
3 depends on VIDEO_DEV && MEDIA_CEC && (ARCH_STI || COMPILE_TEST) 3 depends on VIDEO_DEV && MEDIA_CEC_SUPPORT && (ARCH_STI || COMPILE_TEST)
4 ---help--- 4 ---help---
5 This is a driver for STIH4xx HDMI CEC interface. It uses the 5 This is a driver for STIH4xx HDMI CEC interface. It uses the
6 generic CEC framework interface. 6 generic CEC framework interface.
diff --git a/drivers/staging/media/st-cec/TODO b/drivers/staging/media/st-cec/TODO
new file mode 100644
index 000000000000..c61289742c5c
--- /dev/null
+++ b/drivers/staging/media/st-cec/TODO
@@ -0,0 +1,7 @@
1This driver requires that userspace sets the physical address.
2However, this should be passed on from the corresponding
3ST HDMI driver.
4
5We have to wait until the HDMI notifier framework has been merged
6in order to handle this gracefully, until that time this driver
7has to remain in staging.
diff --git a/drivers/staging/media/st-cec/stih-cec.c b/drivers/staging/media/st-cec/stih-cec.c
index 214344866a6b..3c25638a9610 100644
--- a/drivers/staging/media/st-cec/stih-cec.c
+++ b/drivers/staging/media/st-cec/stih-cec.c
@@ -16,7 +16,6 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/of.h> 17#include <linux/of.h>
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/version.h>
20 19
21#include <media/cec.h> 20#include <media/cec.h>
22 21
@@ -108,11 +107,11 @@
108 107
109/* Constants for CEC_BIT_TOUT_THRESH register */ 108/* Constants for CEC_BIT_TOUT_THRESH register */
110#define CEC_SBIT_TOUT_47MS BIT(1) 109#define CEC_SBIT_TOUT_47MS BIT(1)
111#define CEC_SBIT_TOUT_48MS BIT(0) | BIT(1) 110#define CEC_SBIT_TOUT_48MS (BIT(0) | BIT(1))
112#define CEC_SBIT_TOUT_50MS BIT(2) 111#define CEC_SBIT_TOUT_50MS BIT(2)
113#define CEC_DBIT_TOUT_27MS BIT(0) 112#define CEC_DBIT_TOUT_27MS BIT(0)
114#define CEC_DBIT_TOUT_28MS BIT(1) 113#define CEC_DBIT_TOUT_28MS BIT(1)
115#define CEC_DBIT_TOUT_29MS BIT(0) | BIT(1) 114#define CEC_DBIT_TOUT_29MS (BIT(0) | BIT(1))
116 115
117/* Constants for CEC_BIT_PULSE_THRESH register */ 116/* Constants for CEC_BIT_PULSE_THRESH register */
118#define CEC_BIT_LPULSE_03MS BIT(1) 117#define CEC_BIT_LPULSE_03MS BIT(1)
@@ -336,13 +335,12 @@ static int stih_cec_probe(struct platform_device *pdev)
336 cec->adap = cec_allocate_adapter(&sti_cec_adap_ops, cec, 335 cec->adap = cec_allocate_adapter(&sti_cec_adap_ops, cec,
337 CEC_NAME, 336 CEC_NAME,
338 CEC_CAP_LOG_ADDRS | CEC_CAP_PASSTHROUGH | 337 CEC_CAP_LOG_ADDRS | CEC_CAP_PASSTHROUGH |
339 CEC_CAP_PHYS_ADDR | CEC_CAP_TRANSMIT, 338 CEC_CAP_PHYS_ADDR | CEC_CAP_TRANSMIT, 1);
340 1, &pdev->dev);
341 ret = PTR_ERR_OR_ZERO(cec->adap); 339 ret = PTR_ERR_OR_ZERO(cec->adap);
342 if (ret) 340 if (ret)
343 return ret; 341 return ret;
344 342
345 ret = cec_register_adapter(cec->adap); 343 ret = cec_register_adapter(cec->adap, &pdev->dev);
346 if (ret) { 344 if (ret) {
347 cec_delete_adapter(cec->adap); 345 cec_delete_adapter(cec->adap);
348 return ret; 346 return ret;
@@ -363,6 +361,7 @@ static const struct of_device_id stih_cec_match[] = {
363 }, 361 },
364 {}, 362 {},
365}; 363};
364MODULE_DEVICE_TABLE(of, stih_cec_match);
366 365
367static struct platform_driver stih_cec_pdrv = { 366static struct platform_driver stih_cec_pdrv = {
368 .probe = stih_cec_probe, 367 .probe = stih_cec_probe,
diff --git a/include/media/cec.h b/include/media/cec.h
index fdb5d600e4bb..96a0aa770d61 100644
--- a/include/media/cec.h
+++ b/include/media/cec.h
@@ -35,7 +35,6 @@
35 * struct cec_devnode - cec device node 35 * struct cec_devnode - cec device node
36 * @dev: cec device 36 * @dev: cec device
37 * @cdev: cec character device 37 * @cdev: cec character device
38 * @parent: parent device
39 * @minor: device node minor number 38 * @minor: device node minor number
40 * @registered: the device was correctly registered 39 * @registered: the device was correctly registered
41 * @unregistered: the device was unregistered 40 * @unregistered: the device was unregistered
@@ -51,7 +50,6 @@ struct cec_devnode {
51 /* sysfs */ 50 /* sysfs */
52 struct device dev; 51 struct device dev;
53 struct cdev cdev; 52 struct cdev cdev;
54 struct device *parent;
55 53
56 /* device info */ 54 /* device info */
57 int minor; 55 int minor;
@@ -196,11 +194,10 @@ static inline bool cec_is_sink(const struct cec_adapter *adap)
196 return adap->phys_addr == 0; 194 return adap->phys_addr == 0;
197} 195}
198 196
199#if IS_ENABLED(CONFIG_MEDIA_CEC) 197#if IS_ENABLED(CONFIG_MEDIA_CEC_SUPPORT)
200struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops, 198struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops,
201 void *priv, const char *name, u32 caps, u8 available_las, 199 void *priv, const char *name, u32 caps, u8 available_las);
202 struct device *parent); 200int cec_register_adapter(struct cec_adapter *adap, struct device *parent);
203int cec_register_adapter(struct cec_adapter *adap);
204void cec_unregister_adapter(struct cec_adapter *adap); 201void cec_unregister_adapter(struct cec_adapter *adap);
205void cec_delete_adapter(struct cec_adapter *adap); 202void cec_delete_adapter(struct cec_adapter *adap);
206 203
@@ -218,7 +215,8 @@ void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg);
218 215
219#else 216#else
220 217
221static inline int cec_register_adapter(struct cec_adapter *adap) 218static inline int cec_register_adapter(struct cec_adapter *adap,
219 struct device *parent)
222{ 220{
223 return 0; 221 return 0;
224} 222}
diff --git a/include/media/media-device.h b/include/media/media-device.h
index ef93e21335df..c21b4c5f5871 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -39,8 +39,10 @@ struct device;
39 * @notify_data: Input data to invoke the callback 39 * @notify_data: Input data to invoke the callback
40 * @notify: Callback function pointer 40 * @notify: Callback function pointer
41 * 41 *
42 * Drivers may register a callback to take action when 42 * Drivers may register a callback to take action when new entities get
43 * new entities get registered with the media device. 43 * registered with the media device. This handler is intended for creating
44 * links between existing entities and should not create entities and register
45 * them.
44 */ 46 */
45struct media_entity_notify { 47struct media_entity_notify {
46 struct list_head list; 48 struct list_head list;
@@ -373,30 +375,6 @@ int __must_check media_device_register_entity_notify(struct media_device *mdev,
373void media_device_unregister_entity_notify(struct media_device *mdev, 375void media_device_unregister_entity_notify(struct media_device *mdev,
374 struct media_entity_notify *nptr); 376 struct media_entity_notify *nptr);
375 377
376/**
377 * media_device_get_devres() - get media device as device resource
378 * creates if one doesn't exist
379 *
380 * @dev: pointer to struct &device.
381 *
382 * Sometimes, the media controller &media_device needs to be shared by more
383 * than one driver. This function adds support for that, by dynamically
384 * allocating the &media_device and allowing it to be obtained from the
385 * struct &device associated with the common device where all sub-device
386 * components belong. So, for example, on an USB device with multiple
387 * interfaces, each interface may be handled by a separate per-interface
388 * drivers. While each interface have its own &device, they all share a
389 * common &device associated with the hole USB device.
390 */
391struct media_device *media_device_get_devres(struct device *dev);
392
393/**
394 * media_device_find_devres() - find media device as device resource
395 *
396 * @dev: pointer to struct &device.
397 */
398struct media_device *media_device_find_devres(struct device *dev);
399
400/* Iterate over all entities. */ 378/* Iterate over all entities. */
401#define media_device_for_each_entity(entity, mdev) \ 379#define media_device_for_each_entity(entity, mdev) \
402 list_for_each_entry(entity, &(mdev)->entities, graph_obj.list) 380 list_for_each_entry(entity, &(mdev)->entities, graph_obj.list)
@@ -474,14 +452,6 @@ static inline void media_device_unregister_entity_notify(
474 struct media_entity_notify *nptr) 452 struct media_entity_notify *nptr)
475{ 453{
476} 454}
477static inline struct media_device *media_device_get_devres(struct device *dev)
478{
479 return NULL;
480}
481static inline struct media_device *media_device_find_devres(struct device *dev)
482{
483 return NULL;
484}
485 455
486static inline void media_device_pci_init(struct media_device *mdev, 456static inline void media_device_pci_init(struct media_device *mdev,
487 struct pci_dev *pci_dev, 457 struct pci_dev *pci_dev,
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index 40188d362486..55281b92105a 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -68,6 +68,7 @@ enum rc_filter_type {
68 * struct rc_dev - represents a remote control device 68 * struct rc_dev - represents a remote control device
69 * @dev: driver model's view of this device 69 * @dev: driver model's view of this device
70 * @initialized: 1 if the device init has completed, 0 otherwise 70 * @initialized: 1 if the device init has completed, 0 otherwise
71 * @managed_alloc: devm_rc_allocate_device was used to create rc_dev
71 * @sysfs_groups: sysfs attribute groups 72 * @sysfs_groups: sysfs attribute groups
72 * @input_name: name of the input child device 73 * @input_name: name of the input child device
73 * @input_phys: physical path to the input child device 74 * @input_phys: physical path to the input child device
@@ -131,6 +132,7 @@ enum rc_filter_type {
131struct rc_dev { 132struct rc_dev {
132 struct device dev; 133 struct device dev;
133 atomic_t initialized; 134 atomic_t initialized;
135 bool managed_alloc;
134 const struct attribute_group *sysfs_groups[5]; 136 const struct attribute_group *sysfs_groups[5];
135 const char *input_name; 137 const char *input_name;
136 const char *input_phys; 138 const char *input_phys;
@@ -203,6 +205,14 @@ struct rc_dev {
203struct rc_dev *rc_allocate_device(void); 205struct rc_dev *rc_allocate_device(void);
204 206
205/** 207/**
208 * devm_rc_allocate_device - Managed RC device allocation
209 *
210 * @dev: pointer to struct device
211 * returns a pointer to struct rc_dev.
212 */
213struct rc_dev *devm_rc_allocate_device(struct device *dev);
214
215/**
206 * rc_free_device - Frees a RC device 216 * rc_free_device - Frees a RC device
207 * 217 *
208 * @dev: pointer to struct rc_dev. 218 * @dev: pointer to struct rc_dev.
@@ -217,6 +227,14 @@ void rc_free_device(struct rc_dev *dev);
217int rc_register_device(struct rc_dev *dev); 227int rc_register_device(struct rc_dev *dev);
218 228
219/** 229/**
230 * devm_rc_register_device - Manageded registering of a RC device
231 *
232 * @parent: pointer to struct device.
233 * @dev: pointer to struct rc_dev.
234 */
235int devm_rc_register_device(struct device *parent, struct rc_dev *dev);
236
237/**
220 * rc_unregister_device - Unregisters a RC device 238 * rc_unregister_device - Unregisters a RC device
221 * 239 *
222 * @dev: pointer to struct rc_dev. 240 * @dev: pointer to struct rc_dev.
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index 350cbf9fb10e..aac8b7b6e691 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -55,6 +55,13 @@
55 v4l_client_printk(KERN_DEBUG, client, fmt , ## arg); \ 55 v4l_client_printk(KERN_DEBUG, client, fmt , ## arg); \
56 } while (0) 56 } while (0)
57 57
58/* Add a version of v4l_dbg to be used on drivers using dev_foo() macros */
59#define dev_dbg_lvl(__dev, __level, __debug, __fmt, __arg...) \
60 do { \
61 if (__debug >= (__level)) \
62 dev_printk(KERN_DEBUG, __dev, __fmt, ##__arg); \
63 } while (0)
64
58/* ------------------------------------------------------------------------- */ 65/* ------------------------------------------------------------------------- */
59 66
60/* These printk constructs can be used with v4l2_device and v4l2_subdev */ 67/* These printk constructs can be used with v4l2_device and v4l2_subdev */
diff --git a/include/media/v4l2-dv-timings.h b/include/media/v4l2-dv-timings.h
index 0a7d9e1fc8c8..61a18893e004 100644
--- a/include/media/v4l2-dv-timings.h
+++ b/include/media/v4l2-dv-timings.h
@@ -101,12 +101,22 @@ bool v4l2_find_dv_timings_cap(struct v4l2_dv_timings *t,
101 void *fnc_handle); 101 void *fnc_handle);
102 102
103/** 103/**
104 * v4l2_find_dv_timings_cea861_vic() - find timings based on CEA-861 VIC
105 * @t: the timings data.
106 * @vic: CEA-861 VIC code
107 *
108 * On success it will fill in @t with the found timings and it returns true.
109 * On failure it will return false.
110 */
111bool v4l2_find_dv_timings_cea861_vic(struct v4l2_dv_timings *t, u8 vic);
112
113/**
104 * v4l2_match_dv_timings() - do two timings match? 114 * v4l2_match_dv_timings() - do two timings match?
105 * 115 *
106 * @measured: the measured timings data. 116 * @measured: the measured timings data.
107 * @standard: the timings according to the standard. 117 * @standard: the timings according to the standard.
108 * @pclock_delta: maximum delta in Hz between standard->pixelclock and 118 * @pclock_delta: maximum delta in Hz between standard->pixelclock and
109 * the measured timings. 119 * the measured timings.
110 * @match_reduced_fps: if true, then fail if V4L2_DV_FL_REDUCED_FPS does not 120 * @match_reduced_fps: if true, then fail if V4L2_DV_FL_REDUCED_FPS does not
111 * match. 121 * match.
112 * 122 *
@@ -185,6 +195,14 @@ bool v4l2_detect_gtf(unsigned frame_height, unsigned hfreq, unsigned vsync,
185 */ 195 */
186struct v4l2_fract v4l2_calc_aspect_ratio(u8 hor_landscape, u8 vert_portrait); 196struct v4l2_fract v4l2_calc_aspect_ratio(u8 hor_landscape, u8 vert_portrait);
187 197
198/**
199 * v4l2_dv_timings_aspect_ratio - calculate the aspect ratio based on the
200 * v4l2_dv_timings information.
201 *
202 * @t: the timings data.
203 */
204struct v4l2_fract v4l2_dv_timings_aspect_ratio(const struct v4l2_dv_timings *t);
205
188/* 206/*
189 * reduce_fps - check if conditions for reduced fps are true. 207 * reduce_fps - check if conditions for reduced fps are true.
190 * bt - v4l2 timing structure 208 * bt - v4l2 timing structure
diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h
index 1b355344c804..3ccd01bd245e 100644
--- a/include/media/v4l2-mem2mem.h
+++ b/include/media/v4l2-mem2mem.h
@@ -90,6 +90,9 @@ struct v4l2_m2m_queue_ctx {
90 * %TRANS_QUEUED, %TRANS_RUNNING and %TRANS_ABORT. 90 * %TRANS_QUEUED, %TRANS_RUNNING and %TRANS_ABORT.
91 * @finished: Wait queue used to signalize when a job queue finished. 91 * @finished: Wait queue used to signalize when a job queue finished.
92 * @priv: Instance private data 92 * @priv: Instance private data
93 *
94 * The memory to memory context is specific to a file handle, NOT to e.g.
95 * a device.
93 */ 96 */
94struct v4l2_m2m_ctx { 97struct v4l2_m2m_ctx {
95 /* optional cap/out vb2 queues lock */ 98 /* optional cap/out vb2 queues lock */
diff --git a/include/media/v4l2-tpg.h b/include/media/v4l2-tpg.h
index 329bebfa930c..13e49d85cae3 100644
--- a/include/media/v4l2-tpg.h
+++ b/include/media/v4l2-tpg.h
@@ -87,6 +87,13 @@ enum tpg_move_mode {
87 TPG_MOVE_POS_FAST, 87 TPG_MOVE_POS_FAST,
88}; 88};
89 89
90enum tgp_color_enc {
91 TGP_COLOR_ENC_RGB,
92 TGP_COLOR_ENC_YCBCR,
93 TGP_COLOR_ENC_HSV,
94 TGP_COLOR_ENC_LUMA,
95};
96
90extern const char * const tpg_aspect_strings[]; 97extern const char * const tpg_aspect_strings[];
91 98
92#define TPG_MAX_PLANES 3 99#define TPG_MAX_PLANES 3
@@ -119,10 +126,11 @@ struct tpg_data {
119 u8 saturation; 126 u8 saturation;
120 s16 hue; 127 s16 hue;
121 u32 fourcc; 128 u32 fourcc;
122 bool is_yuv; 129 enum tgp_color_enc color_enc;
123 u32 colorspace; 130 u32 colorspace;
124 u32 xfer_func; 131 u32 xfer_func;
125 u32 ycbcr_enc; 132 u32 ycbcr_enc;
133 u32 hsv_enc;
126 /* 134 /*
127 * Stores the actual transfer function, i.e. will never be 135 * Stores the actual transfer function, i.e. will never be
128 * V4L2_XFER_FUNC_DEFAULT. 136 * V4L2_XFER_FUNC_DEFAULT.
@@ -132,6 +140,7 @@ struct tpg_data {
132 * Stores the actual Y'CbCr encoding, i.e. will never be 140 * Stores the actual Y'CbCr encoding, i.e. will never be
133 * V4L2_YCBCR_ENC_DEFAULT. 141 * V4L2_YCBCR_ENC_DEFAULT.
134 */ 142 */
143 u32 real_hsv_enc;
135 u32 real_ycbcr_enc; 144 u32 real_ycbcr_enc;
136 u32 quantization; 145 u32 quantization;
137 /* 146 /*
@@ -334,6 +343,19 @@ static inline u32 tpg_g_ycbcr_enc(const struct tpg_data *tpg)
334 return tpg->ycbcr_enc; 343 return tpg->ycbcr_enc;
335} 344}
336 345
346static inline void tpg_s_hsv_enc(struct tpg_data *tpg, u32 hsv_enc)
347{
348 if (tpg->hsv_enc == hsv_enc)
349 return;
350 tpg->hsv_enc = hsv_enc;
351 tpg->recalc_colors = true;
352}
353
354static inline u32 tpg_g_hsv_enc(const struct tpg_data *tpg)
355{
356 return tpg->hsv_enc;
357}
358
337static inline void tpg_s_xfer_func(struct tpg_data *tpg, u32 xfer_func) 359static inline void tpg_s_xfer_func(struct tpg_data *tpg, u32 xfer_func)
338{ 360{
339 if (tpg->xfer_func == xfer_func) 361 if (tpg->xfer_func == xfer_func)
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index cd2be1c8e9fb..855908e70610 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -83,6 +83,8 @@ header-y += capi.h
83header-y += cciss_defs.h 83header-y += cciss_defs.h
84header-y += cciss_ioctl.h 84header-y += cciss_ioctl.h
85header-y += cdrom.h 85header-y += cdrom.h
86header-y += cec.h
87header-y += cec-funcs.h
86header-y += cgroupstats.h 88header-y += cgroupstats.h
87header-y += chio.h 89header-y += chio.h
88header-y += cm4000_cs.h 90header-y += cm4000_cs.h
diff --git a/include/linux/cec-funcs.h b/include/uapi/linux/cec-funcs.h
index 138bbf721e70..3cbc327801d6 100644
--- a/include/linux/cec-funcs.h
+++ b/include/uapi/linux/cec-funcs.h
@@ -33,12 +33,6 @@
33 * SOFTWARE. 33 * SOFTWARE.
34 */ 34 */
35 35
36/*
37 * Note: this framework is still in staging and it is likely the API
38 * will change before it goes out of staging.
39 *
40 * Once it is moved out of staging this header will move to uapi.
41 */
42#ifndef _CEC_UAPI_FUNCS_H 36#ifndef _CEC_UAPI_FUNCS_H
43#define _CEC_UAPI_FUNCS_H 37#define _CEC_UAPI_FUNCS_H
44 38
@@ -90,7 +84,7 @@ static inline void cec_ops_inactive_source(const struct cec_msg *msg,
90} 84}
91 85
92static inline void cec_msg_request_active_source(struct cec_msg *msg, 86static inline void cec_msg_request_active_source(struct cec_msg *msg,
93 bool reply) 87 int reply)
94{ 88{
95 msg->len = 2; 89 msg->len = 2;
96 msg->msg[0] |= 0xf; /* broadcast */ 90 msg->msg[0] |= 0xf; /* broadcast */
@@ -115,7 +109,7 @@ static inline void cec_ops_routing_information(const struct cec_msg *msg,
115} 109}
116 110
117static inline void cec_msg_routing_change(struct cec_msg *msg, 111static inline void cec_msg_routing_change(struct cec_msg *msg,
118 bool reply, 112 int reply,
119 __u16 orig_phys_addr, 113 __u16 orig_phys_addr,
120 __u16 new_phys_addr) 114 __u16 new_phys_addr)
121{ 115{
@@ -162,7 +156,7 @@ static inline void cec_msg_standby(struct cec_msg *msg)
162 156
163 157
164/* One Touch Record Feature */ 158/* One Touch Record Feature */
165static inline void cec_msg_record_off(struct cec_msg *msg, bool reply) 159static inline void cec_msg_record_off(struct cec_msg *msg, int reply)
166{ 160{
167 msg->len = 2; 161 msg->len = 2;
168 msg->msg[1] = CEC_MSG_RECORD_OFF; 162 msg->msg[1] = CEC_MSG_RECORD_OFF;
@@ -324,7 +318,7 @@ static inline void cec_msg_record_on_phys_addr(struct cec_msg *msg,
324} 318}
325 319
326static inline void cec_msg_record_on(struct cec_msg *msg, 320static inline void cec_msg_record_on(struct cec_msg *msg,
327 bool reply, 321 int reply,
328 const struct cec_op_record_src *rec_src) 322 const struct cec_op_record_src *rec_src)
329{ 323{
330 switch (rec_src->type) { 324 switch (rec_src->type) {
@@ -391,7 +385,7 @@ static inline void cec_ops_record_status(const struct cec_msg *msg,
391} 385}
392 386
393static inline void cec_msg_record_tv_screen(struct cec_msg *msg, 387static inline void cec_msg_record_tv_screen(struct cec_msg *msg,
394 bool reply) 388 int reply)
395{ 389{
396 msg->len = 2; 390 msg->len = 2;
397 msg->msg[1] = CEC_MSG_RECORD_TV_SCREEN; 391 msg->msg[1] = CEC_MSG_RECORD_TV_SCREEN;
@@ -465,7 +459,7 @@ static inline void cec_ops_timer_cleared_status(const struct cec_msg *msg,
465} 459}
466 460
467static inline void cec_msg_clear_analogue_timer(struct cec_msg *msg, 461static inline void cec_msg_clear_analogue_timer(struct cec_msg *msg,
468 bool reply, 462 int reply,
469 __u8 day, 463 __u8 day,
470 __u8 month, 464 __u8 month,
471 __u8 start_hr, 465 __u8 start_hr,
@@ -520,7 +514,7 @@ static inline void cec_ops_clear_analogue_timer(const struct cec_msg *msg,
520} 514}
521 515
522static inline void cec_msg_clear_digital_timer(struct cec_msg *msg, 516static inline void cec_msg_clear_digital_timer(struct cec_msg *msg,
523 bool reply, 517 int reply,
524 __u8 day, 518 __u8 day,
525 __u8 month, 519 __u8 month,
526 __u8 start_hr, 520 __u8 start_hr,
@@ -566,7 +560,7 @@ static inline void cec_ops_clear_digital_timer(const struct cec_msg *msg,
566} 560}
567 561
568static inline void cec_msg_clear_ext_timer(struct cec_msg *msg, 562static inline void cec_msg_clear_ext_timer(struct cec_msg *msg,
569 bool reply, 563 int reply,
570 __u8 day, 564 __u8 day,
571 __u8 month, 565 __u8 month,
572 __u8 start_hr, 566 __u8 start_hr,
@@ -621,7 +615,7 @@ static inline void cec_ops_clear_ext_timer(const struct cec_msg *msg,
621} 615}
622 616
623static inline void cec_msg_set_analogue_timer(struct cec_msg *msg, 617static inline void cec_msg_set_analogue_timer(struct cec_msg *msg,
624 bool reply, 618 int reply,
625 __u8 day, 619 __u8 day,
626 __u8 month, 620 __u8 month,
627 __u8 start_hr, 621 __u8 start_hr,
@@ -676,7 +670,7 @@ static inline void cec_ops_set_analogue_timer(const struct cec_msg *msg,
676} 670}
677 671
678static inline void cec_msg_set_digital_timer(struct cec_msg *msg, 672static inline void cec_msg_set_digital_timer(struct cec_msg *msg,
679 bool reply, 673 int reply,
680 __u8 day, 674 __u8 day,
681 __u8 month, 675 __u8 month,
682 __u8 start_hr, 676 __u8 start_hr,
@@ -722,7 +716,7 @@ static inline void cec_ops_set_digital_timer(const struct cec_msg *msg,
722} 716}
723 717
724static inline void cec_msg_set_ext_timer(struct cec_msg *msg, 718static inline void cec_msg_set_ext_timer(struct cec_msg *msg,
725 bool reply, 719 int reply,
726 __u8 day, 720 __u8 day,
727 __u8 month, 721 __u8 month,
728 __u8 start_hr, 722 __u8 start_hr,
@@ -814,7 +808,7 @@ static inline void cec_ops_cec_version(const struct cec_msg *msg,
814} 808}
815 809
816static inline void cec_msg_get_cec_version(struct cec_msg *msg, 810static inline void cec_msg_get_cec_version(struct cec_msg *msg,
817 bool reply) 811 int reply)
818{ 812{
819 msg->len = 2; 813 msg->len = 2;
820 msg->msg[1] = CEC_MSG_GET_CEC_VERSION; 814 msg->msg[1] = CEC_MSG_GET_CEC_VERSION;
@@ -840,7 +834,7 @@ static inline void cec_ops_report_physical_addr(const struct cec_msg *msg,
840} 834}
841 835
842static inline void cec_msg_give_physical_addr(struct cec_msg *msg, 836static inline void cec_msg_give_physical_addr(struct cec_msg *msg,
843 bool reply) 837 int reply)
844{ 838{
845 msg->len = 2; 839 msg->len = 2;
846 msg->msg[1] = CEC_MSG_GIVE_PHYSICAL_ADDR; 840 msg->msg[1] = CEC_MSG_GIVE_PHYSICAL_ADDR;
@@ -864,7 +858,7 @@ static inline void cec_ops_set_menu_language(const struct cec_msg *msg,
864} 858}
865 859
866static inline void cec_msg_get_menu_language(struct cec_msg *msg, 860static inline void cec_msg_get_menu_language(struct cec_msg *msg,
867 bool reply) 861 int reply)
868{ 862{
869 msg->len = 2; 863 msg->len = 2;
870 msg->msg[1] = CEC_MSG_GET_MENU_LANGUAGE; 864 msg->msg[1] = CEC_MSG_GET_MENU_LANGUAGE;
@@ -913,7 +907,7 @@ static inline void cec_ops_report_features(const struct cec_msg *msg,
913} 907}
914 908
915static inline void cec_msg_give_features(struct cec_msg *msg, 909static inline void cec_msg_give_features(struct cec_msg *msg,
916 bool reply) 910 int reply)
917{ 911{
918 msg->len = 2; 912 msg->len = 2;
919 msg->msg[1] = CEC_MSG_GIVE_FEATURES; 913 msg->msg[1] = CEC_MSG_GIVE_FEATURES;
@@ -950,7 +944,7 @@ static inline void cec_ops_deck_status(const struct cec_msg *msg,
950} 944}
951 945
952static inline void cec_msg_give_deck_status(struct cec_msg *msg, 946static inline void cec_msg_give_deck_status(struct cec_msg *msg,
953 bool reply, 947 int reply,
954 __u8 status_req) 948 __u8 status_req)
955{ 949{
956 msg->len = 3; 950 msg->len = 3;
@@ -984,7 +978,7 @@ static inline void cec_ops_play(const struct cec_msg *msg,
984struct cec_op_tuner_device_info { 978struct cec_op_tuner_device_info {
985 __u8 rec_flag; 979 __u8 rec_flag;
986 __u8 tuner_display_info; 980 __u8 tuner_display_info;
987 bool is_analog; 981 __u8 is_analog;
988 union { 982 union {
989 struct cec_op_digital_service_id digital; 983 struct cec_op_digital_service_id digital;
990 struct { 984 struct {
@@ -1054,7 +1048,7 @@ static inline void cec_ops_tuner_device_status(const struct cec_msg *msg,
1054} 1048}
1055 1049
1056static inline void cec_msg_give_tuner_device_status(struct cec_msg *msg, 1050static inline void cec_msg_give_tuner_device_status(struct cec_msg *msg,
1057 bool reply, 1051 int reply,
1058 __u8 status_req) 1052 __u8 status_req)
1059{ 1053{
1060 msg->len = 3; 1054 msg->len = 3;
@@ -1137,7 +1131,7 @@ static inline void cec_ops_device_vendor_id(const struct cec_msg *msg,
1137} 1131}
1138 1132
1139static inline void cec_msg_give_device_vendor_id(struct cec_msg *msg, 1133static inline void cec_msg_give_device_vendor_id(struct cec_msg *msg,
1140 bool reply) 1134 int reply)
1141{ 1135{
1142 msg->len = 2; 1136 msg->len = 2;
1143 msg->msg[1] = CEC_MSG_GIVE_DEVICE_VENDOR_ID; 1137 msg->msg[1] = CEC_MSG_GIVE_DEVICE_VENDOR_ID;
@@ -1273,7 +1267,7 @@ static inline void cec_ops_set_osd_name(const struct cec_msg *msg,
1273} 1267}
1274 1268
1275static inline void cec_msg_give_osd_name(struct cec_msg *msg, 1269static inline void cec_msg_give_osd_name(struct cec_msg *msg,
1276 bool reply) 1270 int reply)
1277{ 1271{
1278 msg->len = 2; 1272 msg->len = 2;
1279 msg->msg[1] = CEC_MSG_GIVE_OSD_NAME; 1273 msg->msg[1] = CEC_MSG_GIVE_OSD_NAME;
@@ -1297,7 +1291,7 @@ static inline void cec_ops_menu_status(const struct cec_msg *msg,
1297} 1291}
1298 1292
1299static inline void cec_msg_menu_request(struct cec_msg *msg, 1293static inline void cec_msg_menu_request(struct cec_msg *msg,
1300 bool reply, 1294 int reply,
1301 __u8 menu_req) 1295 __u8 menu_req)
1302{ 1296{
1303 msg->len = 3; 1297 msg->len = 3;
@@ -1314,7 +1308,7 @@ static inline void cec_ops_menu_request(const struct cec_msg *msg,
1314 1308
1315struct cec_op_ui_command { 1309struct cec_op_ui_command {
1316 __u8 ui_cmd; 1310 __u8 ui_cmd;
1317 bool has_opt_arg; 1311 __u8 has_opt_arg;
1318 union { 1312 union {
1319 struct cec_op_channel_data channel_identifier; 1313 struct cec_op_channel_data channel_identifier;
1320 __u8 ui_broadcast_type; 1314 __u8 ui_broadcast_type;
@@ -1360,7 +1354,7 @@ static inline void cec_ops_user_control_pressed(const struct cec_msg *msg,
1360 struct cec_op_ui_command *ui_cmd) 1354 struct cec_op_ui_command *ui_cmd)
1361{ 1355{
1362 ui_cmd->ui_cmd = msg->msg[2]; 1356 ui_cmd->ui_cmd = msg->msg[2];
1363 ui_cmd->has_opt_arg = false; 1357 ui_cmd->has_opt_arg = 0;
1364 if (msg->len == 3) 1358 if (msg->len == 3)
1365 return; 1359 return;
1366 switch (ui_cmd->ui_cmd) { 1360 switch (ui_cmd->ui_cmd) {
@@ -1372,12 +1366,12 @@ static inline void cec_ops_user_control_pressed(const struct cec_msg *msg,
1372 case 0x6a: 1366 case 0x6a:
1373 /* The optional operand is one byte for all these ui commands */ 1367 /* The optional operand is one byte for all these ui commands */
1374 ui_cmd->play_mode = msg->msg[3]; 1368 ui_cmd->play_mode = msg->msg[3];
1375 ui_cmd->has_opt_arg = true; 1369 ui_cmd->has_opt_arg = 1;
1376 break; 1370 break;
1377 case 0x67: 1371 case 0x67:
1378 if (msg->len < 7) 1372 if (msg->len < 7)
1379 break; 1373 break;
1380 ui_cmd->has_opt_arg = true; 1374 ui_cmd->has_opt_arg = 1;
1381 ui_cmd->channel_identifier.channel_number_fmt = msg->msg[3] >> 2; 1375 ui_cmd->channel_identifier.channel_number_fmt = msg->msg[3] >> 2;
1382 ui_cmd->channel_identifier.major = ((msg->msg[3] & 3) << 6) | msg->msg[4]; 1376 ui_cmd->channel_identifier.major = ((msg->msg[3] & 3) << 6) | msg->msg[4];
1383 ui_cmd->channel_identifier.minor = (msg->msg[5] << 8) | msg->msg[6]; 1377 ui_cmd->channel_identifier.minor = (msg->msg[5] << 8) | msg->msg[6];
@@ -1409,7 +1403,7 @@ static inline void cec_ops_report_power_status(const struct cec_msg *msg,
1409} 1403}
1410 1404
1411static inline void cec_msg_give_device_power_status(struct cec_msg *msg, 1405static inline void cec_msg_give_device_power_status(struct cec_msg *msg,
1412 bool reply) 1406 int reply)
1413{ 1407{
1414 msg->len = 2; 1408 msg->len = 2;
1415 msg->msg[1] = CEC_MSG_GIVE_DEVICE_POWER_STATUS; 1409 msg->msg[1] = CEC_MSG_GIVE_DEVICE_POWER_STATUS;
@@ -1469,7 +1463,7 @@ static inline void cec_ops_report_audio_status(const struct cec_msg *msg,
1469} 1463}
1470 1464
1471static inline void cec_msg_give_audio_status(struct cec_msg *msg, 1465static inline void cec_msg_give_audio_status(struct cec_msg *msg,
1472 bool reply) 1466 int reply)
1473{ 1467{
1474 msg->len = 2; 1468 msg->len = 2;
1475 msg->msg[1] = CEC_MSG_GIVE_AUDIO_STATUS; 1469 msg->msg[1] = CEC_MSG_GIVE_AUDIO_STATUS;
@@ -1491,7 +1485,7 @@ static inline void cec_ops_set_system_audio_mode(const struct cec_msg *msg,
1491} 1485}
1492 1486
1493static inline void cec_msg_system_audio_mode_request(struct cec_msg *msg, 1487static inline void cec_msg_system_audio_mode_request(struct cec_msg *msg,
1494 bool reply, 1488 int reply,
1495 __u16 phys_addr) 1489 __u16 phys_addr)
1496{ 1490{
1497 msg->len = phys_addr == 0xffff ? 2 : 4; 1491 msg->len = phys_addr == 0xffff ? 2 : 4;
@@ -1526,7 +1520,7 @@ static inline void cec_ops_system_audio_mode_status(const struct cec_msg *msg,
1526} 1520}
1527 1521
1528static inline void cec_msg_give_system_audio_mode_status(struct cec_msg *msg, 1522static inline void cec_msg_give_system_audio_mode_status(struct cec_msg *msg,
1529 bool reply) 1523 int reply)
1530{ 1524{
1531 msg->len = 2; 1525 msg->len = 2;
1532 msg->msg[1] = CEC_MSG_GIVE_SYSTEM_AUDIO_MODE_STATUS; 1526 msg->msg[1] = CEC_MSG_GIVE_SYSTEM_AUDIO_MODE_STATUS;
@@ -1566,7 +1560,7 @@ static inline void cec_ops_report_short_audio_descriptor(const struct cec_msg *m
1566} 1560}
1567 1561
1568static inline void cec_msg_request_short_audio_descriptor(struct cec_msg *msg, 1562static inline void cec_msg_request_short_audio_descriptor(struct cec_msg *msg,
1569 bool reply, 1563 int reply,
1570 __u8 num_descriptors, 1564 __u8 num_descriptors,
1571 const __u8 *audio_format_id, 1565 const __u8 *audio_format_id,
1572 const __u8 *audio_format_code) 1566 const __u8 *audio_format_code)
@@ -1624,7 +1618,7 @@ static inline void cec_msg_report_arc_initiated(struct cec_msg *msg)
1624} 1618}
1625 1619
1626static inline void cec_msg_initiate_arc(struct cec_msg *msg, 1620static inline void cec_msg_initiate_arc(struct cec_msg *msg,
1627 bool reply) 1621 int reply)
1628{ 1622{
1629 msg->len = 2; 1623 msg->len = 2;
1630 msg->msg[1] = CEC_MSG_INITIATE_ARC; 1624 msg->msg[1] = CEC_MSG_INITIATE_ARC;
@@ -1632,7 +1626,7 @@ static inline void cec_msg_initiate_arc(struct cec_msg *msg,
1632} 1626}
1633 1627
1634static inline void cec_msg_request_arc_initiation(struct cec_msg *msg, 1628static inline void cec_msg_request_arc_initiation(struct cec_msg *msg,
1635 bool reply) 1629 int reply)
1636{ 1630{
1637 msg->len = 2; 1631 msg->len = 2;
1638 msg->msg[1] = CEC_MSG_REQUEST_ARC_INITIATION; 1632 msg->msg[1] = CEC_MSG_REQUEST_ARC_INITIATION;
@@ -1646,7 +1640,7 @@ static inline void cec_msg_report_arc_terminated(struct cec_msg *msg)
1646} 1640}
1647 1641
1648static inline void cec_msg_terminate_arc(struct cec_msg *msg, 1642static inline void cec_msg_terminate_arc(struct cec_msg *msg,
1649 bool reply) 1643 int reply)
1650{ 1644{
1651 msg->len = 2; 1645 msg->len = 2;
1652 msg->msg[1] = CEC_MSG_TERMINATE_ARC; 1646 msg->msg[1] = CEC_MSG_TERMINATE_ARC;
@@ -1654,7 +1648,7 @@ static inline void cec_msg_terminate_arc(struct cec_msg *msg,
1654} 1648}
1655 1649
1656static inline void cec_msg_request_arc_termination(struct cec_msg *msg, 1650static inline void cec_msg_request_arc_termination(struct cec_msg *msg,
1657 bool reply) 1651 int reply)
1658{ 1652{
1659 msg->len = 2; 1653 msg->len = 2;
1660 msg->msg[1] = CEC_MSG_REQUEST_ARC_TERMINATION; 1654 msg->msg[1] = CEC_MSG_REQUEST_ARC_TERMINATION;
@@ -1696,7 +1690,7 @@ static inline void cec_ops_report_current_latency(const struct cec_msg *msg,
1696} 1690}
1697 1691
1698static inline void cec_msg_request_current_latency(struct cec_msg *msg, 1692static inline void cec_msg_request_current_latency(struct cec_msg *msg,
1699 bool reply, 1693 int reply,
1700 __u16 phys_addr) 1694 __u16 phys_addr)
1701{ 1695{
1702 msg->len = 4; 1696 msg->len = 4;
diff --git a/include/linux/cec.h b/include/uapi/linux/cec.h
index 851968e803fa..14b6f24b189e 100644
--- a/include/linux/cec.h
+++ b/include/uapi/linux/cec.h
@@ -33,16 +33,11 @@
33 * SOFTWARE. 33 * SOFTWARE.
34 */ 34 */
35 35
36/*
37 * Note: this framework is still in staging and it is likely the API
38 * will change before it goes out of staging.
39 *
40 * Once it is moved out of staging this header will move to uapi.
41 */
42#ifndef _CEC_UAPI_H 36#ifndef _CEC_UAPI_H
43#define _CEC_UAPI_H 37#define _CEC_UAPI_H
44 38
45#include <linux/types.h> 39#include <linux/types.h>
40#include <linux/string.h>
46 41
47#define CEC_MAX_MSG_SIZE 16 42#define CEC_MAX_MSG_SIZE 16
48 43
@@ -135,7 +130,7 @@ static inline int cec_msg_opcode(const struct cec_msg *msg)
135 * cec_msg_is_broadcast - return true if this is a broadcast message. 130 * cec_msg_is_broadcast - return true if this is a broadcast message.
136 * @msg: the message structure 131 * @msg: the message structure
137 */ 132 */
138static inline bool cec_msg_is_broadcast(const struct cec_msg *msg) 133static inline int cec_msg_is_broadcast(const struct cec_msg *msg)
139{ 134{
140 return (msg->msg[0] & 0xf) == 0xf; 135 return (msg->msg[0] & 0xf) == 0xf;
141} 136}
@@ -175,7 +170,10 @@ static inline void cec_msg_set_reply_to(struct cec_msg *msg,
175 msg->reply = msg->timeout = 0; 170 msg->reply = msg->timeout = 0;
176} 171}
177 172
178/* cec status field */ 173/* cec_msg flags field */
174#define CEC_MSG_FL_REPLY_TO_FOLLOWERS (1 << 0)
175
176/* cec_msg tx/rx_status field */
179#define CEC_TX_STATUS_OK (1 << 0) 177#define CEC_TX_STATUS_OK (1 << 0)
180#define CEC_TX_STATUS_ARB_LOST (1 << 1) 178#define CEC_TX_STATUS_ARB_LOST (1 << 1)
181#define CEC_TX_STATUS_NACK (1 << 2) 179#define CEC_TX_STATUS_NACK (1 << 2)
@@ -187,14 +185,14 @@ static inline void cec_msg_set_reply_to(struct cec_msg *msg,
187#define CEC_RX_STATUS_TIMEOUT (1 << 1) 185#define CEC_RX_STATUS_TIMEOUT (1 << 1)
188#define CEC_RX_STATUS_FEATURE_ABORT (1 << 2) 186#define CEC_RX_STATUS_FEATURE_ABORT (1 << 2)
189 187
190static inline bool cec_msg_status_is_ok(const struct cec_msg *msg) 188static inline int cec_msg_status_is_ok(const struct cec_msg *msg)
191{ 189{
192 if (msg->tx_status && !(msg->tx_status & CEC_TX_STATUS_OK)) 190 if (msg->tx_status && !(msg->tx_status & CEC_TX_STATUS_OK))
193 return false; 191 return 0;
194 if (msg->rx_status && !(msg->rx_status & CEC_RX_STATUS_OK)) 192 if (msg->rx_status && !(msg->rx_status & CEC_RX_STATUS_OK))
195 return false; 193 return 0;
196 if (!msg->tx_status && !msg->rx_status) 194 if (!msg->tx_status && !msg->rx_status)
197 return false; 195 return 0;
198 return !(msg->rx_status & CEC_RX_STATUS_FEATURE_ABORT); 196 return !(msg->rx_status & CEC_RX_STATUS_FEATURE_ABORT);
199} 197}
200 198
@@ -257,47 +255,47 @@ static inline bool cec_msg_status_is_ok(const struct cec_msg *msg)
257#define CEC_LOG_ADDR_MASK_SPECIFIC (1 << CEC_LOG_ADDR_SPECIFIC) 255#define CEC_LOG_ADDR_MASK_SPECIFIC (1 << CEC_LOG_ADDR_SPECIFIC)
258#define CEC_LOG_ADDR_MASK_UNREGISTERED (1 << CEC_LOG_ADDR_UNREGISTERED) 256#define CEC_LOG_ADDR_MASK_UNREGISTERED (1 << CEC_LOG_ADDR_UNREGISTERED)
259 257
260static inline bool cec_has_tv(__u16 log_addr_mask) 258static inline int cec_has_tv(__u16 log_addr_mask)
261{ 259{
262 return log_addr_mask & CEC_LOG_ADDR_MASK_TV; 260 return log_addr_mask & CEC_LOG_ADDR_MASK_TV;
263} 261}
264 262
265static inline bool cec_has_record(__u16 log_addr_mask) 263static inline int cec_has_record(__u16 log_addr_mask)
266{ 264{
267 return log_addr_mask & CEC_LOG_ADDR_MASK_RECORD; 265 return log_addr_mask & CEC_LOG_ADDR_MASK_RECORD;
268} 266}
269 267
270static inline bool cec_has_tuner(__u16 log_addr_mask) 268static inline int cec_has_tuner(__u16 log_addr_mask)
271{ 269{
272 return log_addr_mask & CEC_LOG_ADDR_MASK_TUNER; 270 return log_addr_mask & CEC_LOG_ADDR_MASK_TUNER;
273} 271}
274 272
275static inline bool cec_has_playback(__u16 log_addr_mask) 273static inline int cec_has_playback(__u16 log_addr_mask)
276{ 274{
277 return log_addr_mask & CEC_LOG_ADDR_MASK_PLAYBACK; 275 return log_addr_mask & CEC_LOG_ADDR_MASK_PLAYBACK;
278} 276}
279 277
280static inline bool cec_has_audiosystem(__u16 log_addr_mask) 278static inline int cec_has_audiosystem(__u16 log_addr_mask)
281{ 279{
282 return log_addr_mask & CEC_LOG_ADDR_MASK_AUDIOSYSTEM; 280 return log_addr_mask & CEC_LOG_ADDR_MASK_AUDIOSYSTEM;
283} 281}
284 282
285static inline bool cec_has_backup(__u16 log_addr_mask) 283static inline int cec_has_backup(__u16 log_addr_mask)
286{ 284{
287 return log_addr_mask & CEC_LOG_ADDR_MASK_BACKUP; 285 return log_addr_mask & CEC_LOG_ADDR_MASK_BACKUP;
288} 286}
289 287
290static inline bool cec_has_specific(__u16 log_addr_mask) 288static inline int cec_has_specific(__u16 log_addr_mask)
291{ 289{
292 return log_addr_mask & CEC_LOG_ADDR_MASK_SPECIFIC; 290 return log_addr_mask & CEC_LOG_ADDR_MASK_SPECIFIC;
293} 291}
294 292
295static inline bool cec_is_unregistered(__u16 log_addr_mask) 293static inline int cec_is_unregistered(__u16 log_addr_mask)
296{ 294{
297 return log_addr_mask & CEC_LOG_ADDR_MASK_UNREGISTERED; 295 return log_addr_mask & CEC_LOG_ADDR_MASK_UNREGISTERED;
298} 296}
299 297
300static inline bool cec_is_unconfigured(__u16 log_addr_mask) 298static inline int cec_is_unconfigured(__u16 log_addr_mask)
301{ 299{
302 return log_addr_mask == 0; 300 return log_addr_mask == 0;
303} 301}
@@ -391,6 +389,10 @@ struct cec_log_addrs {
391 389
392/* Allow a fallback to unregistered */ 390/* Allow a fallback to unregistered */
393#define CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK (1 << 0) 391#define CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK (1 << 0)
392/* Passthrough RC messages to the input subsystem */
393#define CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU (1 << 1)
394/* CDC-Only device: supports only CDC messages */
395#define CEC_LOG_ADDRS_FL_CDC_ONLY (1 << 2)
394 396
395/* Events */ 397/* Events */
396 398
@@ -1011,4 +1013,54 @@ struct cec_event {
1011#define CEC_OP_HPD_ERROR_OTHER 3 1013#define CEC_OP_HPD_ERROR_OTHER 3
1012#define CEC_OP_HPD_ERROR_NONE_NO_VIDEO 4 1014#define CEC_OP_HPD_ERROR_NONE_NO_VIDEO 4
1013 1015
1016/* End of Messages */
1017
1018/* Helper functions to identify the 'special' CEC devices */
1019
1020static inline int cec_is_2nd_tv(const struct cec_log_addrs *las)
1021{
1022 /*
1023 * It is a second TV if the logical address is 14 or 15 and the
1024 * primary device type is a TV.
1025 */
1026 return las->num_log_addrs &&
1027 las->log_addr[0] >= CEC_LOG_ADDR_SPECIFIC &&
1028 las->primary_device_type[0] == CEC_OP_PRIM_DEVTYPE_TV;
1029}
1030
1031static inline int cec_is_processor(const struct cec_log_addrs *las)
1032{
1033 /*
1034 * It is a processor if the logical address is 12-15 and the
1035 * primary device type is a Processor.
1036 */
1037 return las->num_log_addrs &&
1038 las->log_addr[0] >= CEC_LOG_ADDR_BACKUP_1 &&
1039 las->primary_device_type[0] == CEC_OP_PRIM_DEVTYPE_PROCESSOR;
1040}
1041
1042static inline int cec_is_switch(const struct cec_log_addrs *las)
1043{
1044 /*
1045 * It is a switch if the logical address is 15 and the
1046 * primary device type is a Switch and the CDC-Only flag is not set.
1047 */
1048 return las->num_log_addrs == 1 &&
1049 las->log_addr[0] == CEC_LOG_ADDR_UNREGISTERED &&
1050 las->primary_device_type[0] == CEC_OP_PRIM_DEVTYPE_SWITCH &&
1051 !(las->flags & CEC_LOG_ADDRS_FL_CDC_ONLY);
1052}
1053
1054static inline int cec_is_cdc_only(const struct cec_log_addrs *las)
1055{
1056 /*
1057 * It is a CDC-only device if the logical address is 15 and the
1058 * primary device type is a Switch and the CDC-Only flag is set.
1059 */
1060 return las->num_log_addrs == 1 &&
1061 las->log_addr[0] == CEC_LOG_ADDR_UNREGISTERED &&
1062 las->primary_device_type[0] == CEC_OP_PRIM_DEVTYPE_SWITCH &&
1063 (las->flags & CEC_LOG_ADDRS_FL_CDC_ONLY);
1064}
1065
1014#endif 1066#endif
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index b6a357a5f053..0d2e1e01fbd5 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -892,6 +892,7 @@ enum v4l2_jpeg_chroma_subsampling {
892#define V4L2_CID_LINK_FREQ (V4L2_CID_IMAGE_PROC_CLASS_BASE + 1) 892#define V4L2_CID_LINK_FREQ (V4L2_CID_IMAGE_PROC_CLASS_BASE + 1)
893#define V4L2_CID_PIXEL_RATE (V4L2_CID_IMAGE_PROC_CLASS_BASE + 2) 893#define V4L2_CID_PIXEL_RATE (V4L2_CID_IMAGE_PROC_CLASS_BASE + 2)
894#define V4L2_CID_TEST_PATTERN (V4L2_CID_IMAGE_PROC_CLASS_BASE + 3) 894#define V4L2_CID_TEST_PATTERN (V4L2_CID_IMAGE_PROC_CLASS_BASE + 3)
895#define V4L2_CID_DEINTERLACING_MODE (V4L2_CID_IMAGE_PROC_CLASS_BASE + 4)
895 896
896 897
897/* DV-class control IDs defined by V4L2 */ 898/* DV-class control IDs defined by V4L2 */
diff --git a/include/uapi/linux/v4l2-dv-timings.h b/include/uapi/linux/v4l2-dv-timings.h
index f31957166337..da2955154381 100644
--- a/include/uapi/linux/v4l2-dv-timings.h
+++ b/include/uapi/linux/v4l2-dv-timings.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * V4L2 DV timings header. 2 * V4L2 DV timings header.
3 * 3 *
4 * Copyright (C) 2012 Hans Verkuil <hans.verkuil@cisco.com> 4 * Copyright (C) 2012-2016 Hans Verkuil <hans.verkuil@cisco.com>
5 * 5 *
6 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License 7 * modify it under the terms of the GNU General Public License
@@ -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 _V4L2_DV_TIMINGS_H 16#ifndef _V4L2_DV_TIMINGS_H
@@ -33,13 +28,14 @@
33 .bt = { _width , ## args } 28 .bt = { _width , ## args }
34#endif 29#endif
35 30
36/* CEA-861-E timings (i.e. standard HDTV timings) */ 31/* CEA-861-F timings (i.e. standard HDTV timings) */
37 32
38#define V4L2_DV_BT_CEA_640X480P59_94 { \ 33#define V4L2_DV_BT_CEA_640X480P59_94 { \
39 .type = V4L2_DV_BT_656_1120, \ 34 .type = V4L2_DV_BT_656_1120, \
40 V4L2_INIT_BT_TIMINGS(640, 480, 0, 0, \ 35 V4L2_INIT_BT_TIMINGS(640, 480, 0, 0, \
41 25175000, 16, 96, 48, 10, 2, 33, 0, 0, 0, \ 36 25175000, 16, 96, 48, 10, 2, 33, 0, 0, 0, \
42 V4L2_DV_BT_STD_DMT | V4L2_DV_BT_STD_CEA861, 0) \ 37 V4L2_DV_BT_STD_DMT | V4L2_DV_BT_STD_CEA861, \
38 V4L2_DV_FL_HAS_CEA861_VIC, { 0, 0 }, 1) \
43} 39}
44 40
45/* Note: these are the nominal timings, for HDMI links this format is typically 41/* Note: these are the nominal timings, for HDMI links this format is typically
@@ -49,14 +45,18 @@
49 V4L2_INIT_BT_TIMINGS(720, 480, 1, 0, \ 45 V4L2_INIT_BT_TIMINGS(720, 480, 1, 0, \
50 13500000, 19, 62, 57, 4, 3, 15, 4, 3, 16, \ 46 13500000, 19, 62, 57, 4, 3, 15, 4, 3, 16, \
51 V4L2_DV_BT_STD_CEA861, \ 47 V4L2_DV_BT_STD_CEA861, \
52 V4L2_DV_FL_HALF_LINE | V4L2_DV_FL_IS_CE_VIDEO) \ 48 V4L2_DV_FL_HALF_LINE | V4L2_DV_FL_IS_CE_VIDEO | \
49 V4L2_DV_FL_HAS_PICTURE_ASPECT | V4L2_DV_FL_HAS_CEA861_VIC, \
50 { 4, 3 }, 6) \
53} 51}
54 52
55#define V4L2_DV_BT_CEA_720X480P59_94 { \ 53#define V4L2_DV_BT_CEA_720X480P59_94 { \
56 .type = V4L2_DV_BT_656_1120, \ 54 .type = V4L2_DV_BT_656_1120, \
57 V4L2_INIT_BT_TIMINGS(720, 480, 0, 0, \ 55 V4L2_INIT_BT_TIMINGS(720, 480, 0, 0, \
58 27000000, 16, 62, 60, 9, 6, 30, 0, 0, 0, \ 56 27000000, 16, 62, 60, 9, 6, 30, 0, 0, 0, \
59 V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \ 57 V4L2_DV_BT_STD_CEA861, \
58 V4L2_DV_FL_IS_CE_VIDEO | V4L2_DV_FL_HAS_PICTURE_ASPECT | \
59 V4L2_DV_FL_HAS_CEA861_VIC, { 4, 3 }, 2) \
60} 60}
61 61
62/* Note: these are the nominal timings, for HDMI links this format is typically 62/* Note: these are the nominal timings, for HDMI links this format is typically
@@ -66,14 +66,18 @@
66 V4L2_INIT_BT_TIMINGS(720, 576, 1, 0, \ 66 V4L2_INIT_BT_TIMINGS(720, 576, 1, 0, \
67 13500000, 12, 63, 69, 2, 3, 19, 2, 3, 20, \ 67 13500000, 12, 63, 69, 2, 3, 19, 2, 3, 20, \
68 V4L2_DV_BT_STD_CEA861, \ 68 V4L2_DV_BT_STD_CEA861, \
69 V4L2_DV_FL_HALF_LINE | V4L2_DV_FL_IS_CE_VIDEO) \ 69 V4L2_DV_FL_HALF_LINE | V4L2_DV_FL_IS_CE_VIDEO | \
70 V4L2_DV_FL_HAS_PICTURE_ASPECT | V4L2_DV_FL_HAS_CEA861_VIC, \
71 { 4, 3 }, 21) \
70} 72}
71 73
72#define V4L2_DV_BT_CEA_720X576P50 { \ 74#define V4L2_DV_BT_CEA_720X576P50 { \
73 .type = V4L2_DV_BT_656_1120, \ 75 .type = V4L2_DV_BT_656_1120, \
74 V4L2_INIT_BT_TIMINGS(720, 576, 0, 0, \ 76 V4L2_INIT_BT_TIMINGS(720, 576, 0, 0, \
75 27000000, 12, 64, 68, 5, 5, 39, 0, 0, 0, \ 77 27000000, 12, 64, 68, 5, 5, 39, 0, 0, 0, \
76 V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \ 78 V4L2_DV_BT_STD_CEA861, \
79 V4L2_DV_FL_IS_CE_VIDEO | V4L2_DV_FL_HAS_PICTURE_ASPECT | \
80 V4L2_DV_FL_HAS_CEA861_VIC, { 4, 3 }, 17) \
77} 81}
78 82
79#define V4L2_DV_BT_CEA_1280X720P24 { \ 83#define V4L2_DV_BT_CEA_1280X720P24 { \
@@ -82,7 +86,7 @@
82 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 86 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
83 59400000, 1760, 40, 220, 5, 5, 20, 0, 0, 0, \ 87 59400000, 1760, 40, 220, 5, 5, 20, 0, 0, 0, \
84 V4L2_DV_BT_STD_DMT | V4L2_DV_BT_STD_CEA861, \ 88 V4L2_DV_BT_STD_DMT | V4L2_DV_BT_STD_CEA861, \
85 V4L2_DV_FL_CAN_REDUCE_FPS) \ 89 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_HAS_CEA861_VIC, { 0, 0 }, 60) \
86} 90}
87 91
88#define V4L2_DV_BT_CEA_1280X720P25 { \ 92#define V4L2_DV_BT_CEA_1280X720P25 { \
@@ -90,7 +94,8 @@
90 V4L2_INIT_BT_TIMINGS(1280, 720, 0, \ 94 V4L2_INIT_BT_TIMINGS(1280, 720, 0, \
91 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 95 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
92 74250000, 2420, 40, 220, 5, 5, 20, 0, 0, 0, \ 96 74250000, 2420, 40, 220, 5, 5, 20, 0, 0, 0, \
93 V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \ 97 V4L2_DV_BT_STD_CEA861, \
98 V4L2_DV_FL_IS_CE_VIDEO | V4L2_DV_FL_HAS_CEA861_VIC, { 0, 0 }, 61) \
94} 99}
95 100
96#define V4L2_DV_BT_CEA_1280X720P30 { \ 101#define V4L2_DV_BT_CEA_1280X720P30 { \
@@ -99,7 +104,8 @@
99 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 104 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
100 74250000, 1760, 40, 220, 5, 5, 20, 0, 0, 0, \ 105 74250000, 1760, 40, 220, 5, 5, 20, 0, 0, 0, \
101 V4L2_DV_BT_STD_CEA861, \ 106 V4L2_DV_BT_STD_CEA861, \
102 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \ 107 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO | \
108 V4L2_DV_FL_HAS_CEA861_VIC, { 0, 0 }, 62) \
103} 109}
104 110
105#define V4L2_DV_BT_CEA_1280X720P50 { \ 111#define V4L2_DV_BT_CEA_1280X720P50 { \
@@ -107,7 +113,8 @@
107 V4L2_INIT_BT_TIMINGS(1280, 720, 0, \ 113 V4L2_INIT_BT_TIMINGS(1280, 720, 0, \
108 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 114 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
109 74250000, 440, 40, 220, 5, 5, 20, 0, 0, 0, \ 115 74250000, 440, 40, 220, 5, 5, 20, 0, 0, 0, \
110 V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \ 116 V4L2_DV_BT_STD_CEA861, \
117 V4L2_DV_FL_IS_CE_VIDEO | V4L2_DV_FL_HAS_CEA861_VIC, { 0, 0 }, 19) \
111} 118}
112 119
113#define V4L2_DV_BT_CEA_1280X720P60 { \ 120#define V4L2_DV_BT_CEA_1280X720P60 { \
@@ -116,7 +123,8 @@
116 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 123 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
117 74250000, 110, 40, 220, 5, 5, 20, 0, 0, 0, \ 124 74250000, 110, 40, 220, 5, 5, 20, 0, 0, 0, \
118 V4L2_DV_BT_STD_CEA861, \ 125 V4L2_DV_BT_STD_CEA861, \
119 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \ 126 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO | \
127 V4L2_DV_FL_HAS_CEA861_VIC, { 0, 0 }, 4) \
120} 128}
121 129
122#define V4L2_DV_BT_CEA_1920X1080P24 { \ 130#define V4L2_DV_BT_CEA_1920X1080P24 { \
@@ -125,7 +133,8 @@
125 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 133 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
126 74250000, 638, 44, 148, 4, 5, 36, 0, 0, 0, \ 134 74250000, 638, 44, 148, 4, 5, 36, 0, 0, 0, \
127 V4L2_DV_BT_STD_CEA861, \ 135 V4L2_DV_BT_STD_CEA861, \
128 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \ 136 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO | \
137 V4L2_DV_FL_HAS_CEA861_VIC, { 0, 0 }, 32) \
129} 138}
130 139
131#define V4L2_DV_BT_CEA_1920X1080P25 { \ 140#define V4L2_DV_BT_CEA_1920X1080P25 { \
@@ -133,7 +142,8 @@
133 V4L2_INIT_BT_TIMINGS(1920, 1080, 0, \ 142 V4L2_INIT_BT_TIMINGS(1920, 1080, 0, \
134 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 143 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
135 74250000, 528, 44, 148, 4, 5, 36, 0, 0, 0, \ 144 74250000, 528, 44, 148, 4, 5, 36, 0, 0, 0, \
136 V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \ 145 V4L2_DV_BT_STD_CEA861, \
146 V4L2_DV_FL_IS_CE_VIDEO | V4L2_DV_FL_HAS_CEA861_VIC, { 0, 0 }, 33) \
137} 147}
138 148
139#define V4L2_DV_BT_CEA_1920X1080P30 { \ 149#define V4L2_DV_BT_CEA_1920X1080P30 { \
@@ -142,7 +152,8 @@
142 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 152 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
143 74250000, 88, 44, 148, 4, 5, 36, 0, 0, 0, \ 153 74250000, 88, 44, 148, 4, 5, 36, 0, 0, 0, \
144 V4L2_DV_BT_STD_CEA861, \ 154 V4L2_DV_BT_STD_CEA861, \
145 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \ 155 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO | \
156 V4L2_DV_FL_HAS_CEA861_VIC, { 0, 0 }, 34) \
146} 157}
147 158
148#define V4L2_DV_BT_CEA_1920X1080I50 { \ 159#define V4L2_DV_BT_CEA_1920X1080I50 { \
@@ -151,7 +162,8 @@
151 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 162 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
152 74250000, 528, 44, 148, 2, 5, 15, 2, 5, 16, \ 163 74250000, 528, 44, 148, 2, 5, 15, 2, 5, 16, \
153 V4L2_DV_BT_STD_CEA861, \ 164 V4L2_DV_BT_STD_CEA861, \
154 V4L2_DV_FL_HALF_LINE | V4L2_DV_FL_IS_CE_VIDEO) \ 165 V4L2_DV_FL_HALF_LINE | V4L2_DV_FL_IS_CE_VIDEO | \
166 V4L2_DV_FL_HAS_CEA861_VIC, { 0, 0 }, 20) \
155} 167}
156 168
157#define V4L2_DV_BT_CEA_1920X1080P50 { \ 169#define V4L2_DV_BT_CEA_1920X1080P50 { \
@@ -159,7 +171,8 @@
159 V4L2_INIT_BT_TIMINGS(1920, 1080, 0, \ 171 V4L2_INIT_BT_TIMINGS(1920, 1080, 0, \
160 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 172 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
161 148500000, 528, 44, 148, 4, 5, 36, 0, 0, 0, \ 173 148500000, 528, 44, 148, 4, 5, 36, 0, 0, 0, \
162 V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \ 174 V4L2_DV_BT_STD_CEA861, \
175 V4L2_DV_FL_IS_CE_VIDEO | V4L2_DV_FL_HAS_CEA861_VIC, { 0, 0 }, 31) \
163} 176}
164 177
165#define V4L2_DV_BT_CEA_1920X1080I60 { \ 178#define V4L2_DV_BT_CEA_1920X1080I60 { \
@@ -169,7 +182,8 @@
169 74250000, 88, 44, 148, 2, 5, 15, 2, 5, 16, \ 182 74250000, 88, 44, 148, 2, 5, 15, 2, 5, 16, \
170 V4L2_DV_BT_STD_CEA861, \ 183 V4L2_DV_BT_STD_CEA861, \
171 V4L2_DV_FL_CAN_REDUCE_FPS | \ 184 V4L2_DV_FL_CAN_REDUCE_FPS | \
172 V4L2_DV_FL_HALF_LINE | V4L2_DV_FL_IS_CE_VIDEO) \ 185 V4L2_DV_FL_HALF_LINE | V4L2_DV_FL_IS_CE_VIDEO | \
186 V4L2_DV_FL_HAS_CEA861_VIC, { 0, 0 }, 5) \
173} 187}
174 188
175#define V4L2_DV_BT_CEA_1920X1080P60 { \ 189#define V4L2_DV_BT_CEA_1920X1080P60 { \
@@ -178,7 +192,8 @@
178 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 192 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
179 148500000, 88, 44, 148, 4, 5, 36, 0, 0, 0, \ 193 148500000, 88, 44, 148, 4, 5, 36, 0, 0, 0, \
180 V4L2_DV_BT_STD_DMT | V4L2_DV_BT_STD_CEA861, \ 194 V4L2_DV_BT_STD_DMT | V4L2_DV_BT_STD_CEA861, \
181 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \ 195 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO | \
196 V4L2_DV_FL_HAS_CEA861_VIC, { 0, 0 }, 16) \
182} 197}
183 198
184#define V4L2_DV_BT_CEA_3840X2160P24 { \ 199#define V4L2_DV_BT_CEA_3840X2160P24 { \
@@ -187,7 +202,9 @@
187 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 202 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
188 297000000, 1276, 88, 296, 8, 10, 72, 0, 0, 0, \ 203 297000000, 1276, 88, 296, 8, 10, 72, 0, 0, 0, \
189 V4L2_DV_BT_STD_CEA861, \ 204 V4L2_DV_BT_STD_CEA861, \
190 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \ 205 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO | \
206 V4L2_DV_FL_HAS_CEA861_VIC | V4L2_DV_FL_HAS_HDMI_VIC, \
207 { 0, 0 }, 93, 3) \
191} 208}
192 209
193#define V4L2_DV_BT_CEA_3840X2160P25 { \ 210#define V4L2_DV_BT_CEA_3840X2160P25 { \
@@ -195,7 +212,9 @@
195 V4L2_INIT_BT_TIMINGS(3840, 2160, 0, \ 212 V4L2_INIT_BT_TIMINGS(3840, 2160, 0, \
196 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 213 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
197 297000000, 1056, 88, 296, 8, 10, 72, 0, 0, 0, \ 214 297000000, 1056, 88, 296, 8, 10, 72, 0, 0, 0, \
198 V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \ 215 V4L2_DV_BT_STD_CEA861, \
216 V4L2_DV_FL_IS_CE_VIDEO | V4L2_DV_FL_HAS_CEA861_VIC | \
217 V4L2_DV_FL_HAS_HDMI_VIC, { 0, 0 }, 94, 2) \
199} 218}
200 219
201#define V4L2_DV_BT_CEA_3840X2160P30 { \ 220#define V4L2_DV_BT_CEA_3840X2160P30 { \
@@ -204,7 +223,9 @@
204 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 223 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
205 297000000, 176, 88, 296, 8, 10, 72, 0, 0, 0, \ 224 297000000, 176, 88, 296, 8, 10, 72, 0, 0, 0, \
206 V4L2_DV_BT_STD_CEA861, \ 225 V4L2_DV_BT_STD_CEA861, \
207 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \ 226 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO | \
227 V4L2_DV_FL_HAS_CEA861_VIC | V4L2_DV_FL_HAS_HDMI_VIC, \
228 { 0, 0 }, 95, 1) \
208} 229}
209 230
210#define V4L2_DV_BT_CEA_3840X2160P50 { \ 231#define V4L2_DV_BT_CEA_3840X2160P50 { \
@@ -212,7 +233,8 @@
212 V4L2_INIT_BT_TIMINGS(3840, 2160, 0, \ 233 V4L2_INIT_BT_TIMINGS(3840, 2160, 0, \
213 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 234 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
214 594000000, 1056, 88, 296, 8, 10, 72, 0, 0, 0, \ 235 594000000, 1056, 88, 296, 8, 10, 72, 0, 0, 0, \
215 V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \ 236 V4L2_DV_BT_STD_CEA861, \
237 V4L2_DV_FL_IS_CE_VIDEO | V4L2_DV_FL_HAS_CEA861_VIC, { 0, 0 }, 96) \
216} 238}
217 239
218#define V4L2_DV_BT_CEA_3840X2160P60 { \ 240#define V4L2_DV_BT_CEA_3840X2160P60 { \
@@ -221,7 +243,8 @@
221 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 243 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
222 594000000, 176, 88, 296, 8, 10, 72, 0, 0, 0, \ 244 594000000, 176, 88, 296, 8, 10, 72, 0, 0, 0, \
223 V4L2_DV_BT_STD_CEA861, \ 245 V4L2_DV_BT_STD_CEA861, \
224 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \ 246 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO | \
247 V4L2_DV_FL_HAS_CEA861_VIC, { 0, 0 }, 97) \
225} 248}
226 249
227#define V4L2_DV_BT_CEA_4096X2160P24 { \ 250#define V4L2_DV_BT_CEA_4096X2160P24 { \
@@ -230,7 +253,9 @@
230 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 253 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
231 297000000, 1020, 88, 296, 8, 10, 72, 0, 0, 0, \ 254 297000000, 1020, 88, 296, 8, 10, 72, 0, 0, 0, \
232 V4L2_DV_BT_STD_CEA861, \ 255 V4L2_DV_BT_STD_CEA861, \
233 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \ 256 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO | \
257 V4L2_DV_FL_HAS_CEA861_VIC | V4L2_DV_FL_HAS_HDMI_VIC, \
258 { 0, 0 }, 98, 4) \
234} 259}
235 260
236#define V4L2_DV_BT_CEA_4096X2160P25 { \ 261#define V4L2_DV_BT_CEA_4096X2160P25 { \
@@ -238,7 +263,8 @@
238 V4L2_INIT_BT_TIMINGS(4096, 2160, 0, \ 263 V4L2_INIT_BT_TIMINGS(4096, 2160, 0, \
239 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 264 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
240 297000000, 968, 88, 128, 8, 10, 72, 0, 0, 0, \ 265 297000000, 968, 88, 128, 8, 10, 72, 0, 0, 0, \
241 V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \ 266 V4L2_DV_BT_STD_CEA861, \
267 V4L2_DV_FL_IS_CE_VIDEO | V4L2_DV_FL_HAS_CEA861_VIC, { 0, 0 }, 99) \
242} 268}
243 269
244#define V4L2_DV_BT_CEA_4096X2160P30 { \ 270#define V4L2_DV_BT_CEA_4096X2160P30 { \
@@ -247,7 +273,8 @@
247 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 273 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
248 297000000, 88, 88, 128, 8, 10, 72, 0, 0, 0, \ 274 297000000, 88, 88, 128, 8, 10, 72, 0, 0, 0, \
249 V4L2_DV_BT_STD_CEA861, \ 275 V4L2_DV_BT_STD_CEA861, \
250 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \ 276 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO | \
277 V4L2_DV_FL_HAS_CEA861_VIC, { 0, 0 }, 100) \
251} 278}
252 279
253#define V4L2_DV_BT_CEA_4096X2160P50 { \ 280#define V4L2_DV_BT_CEA_4096X2160P50 { \
@@ -255,7 +282,8 @@
255 V4L2_INIT_BT_TIMINGS(4096, 2160, 0, \ 282 V4L2_INIT_BT_TIMINGS(4096, 2160, 0, \
256 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 283 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
257 594000000, 968, 88, 128, 8, 10, 72, 0, 0, 0, \ 284 594000000, 968, 88, 128, 8, 10, 72, 0, 0, 0, \
258 V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \ 285 V4L2_DV_BT_STD_CEA861, \
286 V4L2_DV_FL_IS_CE_VIDEO | V4L2_DV_FL_HAS_CEA861_VIC, { 0, 0 }, 101) \
259} 287}
260 288
261#define V4L2_DV_BT_CEA_4096X2160P60 { \ 289#define V4L2_DV_BT_CEA_4096X2160P60 { \
@@ -264,7 +292,8 @@
264 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \ 292 V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
265 594000000, 88, 88, 128, 8, 10, 72, 0, 0, 0, \ 293 594000000, 88, 88, 128, 8, 10, 72, 0, 0, 0, \
266 V4L2_DV_BT_STD_CEA861, \ 294 V4L2_DV_BT_STD_CEA861, \
267 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \ 295 V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO | \
296 V4L2_DV_FL_HAS_CEA861_VIC, { 0, 0 }, 102) \
268} 297}
269 298
270 299
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 94f123f3e04e..46e8a2e369f9 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -335,6 +335,19 @@ enum v4l2_ycbcr_encoding {
335}; 335};
336 336
337/* 337/*
338 * enum v4l2_hsv_encoding values should not collide with the ones from
339 * enum v4l2_ycbcr_encoding.
340 */
341enum v4l2_hsv_encoding {
342
343 /* Hue mapped to 0 - 179 */
344 V4L2_HSV_ENC_180 = 128,
345
346 /* Hue mapped to 0-255 */
347 V4L2_HSV_ENC_256 = 129,
348};
349
350/*
338 * Determine how YCBCR_ENC_DEFAULT should map to a proper Y'CbCr encoding. 351 * Determine how YCBCR_ENC_DEFAULT should map to a proper Y'CbCr encoding.
339 * This depends on the colorspace. 352 * This depends on the colorspace.
340 */ 353 */
@@ -362,9 +375,10 @@ enum v4l2_quantization {
362 * This depends on whether the image is RGB or not, the colorspace and the 375 * This depends on whether the image is RGB or not, the colorspace and the
363 * Y'CbCr encoding. 376 * Y'CbCr encoding.
364 */ 377 */
365#define V4L2_MAP_QUANTIZATION_DEFAULT(is_rgb, colsp, ycbcr_enc) \ 378#define V4L2_MAP_QUANTIZATION_DEFAULT(is_rgb_or_hsv, colsp, ycbcr_enc) \
366 (((is_rgb) && (colsp) == V4L2_COLORSPACE_BT2020) ? V4L2_QUANTIZATION_LIM_RANGE : \ 379 (((is_rgb_or_hsv) && (colsp) == V4L2_COLORSPACE_BT2020) ? \
367 (((is_rgb) || (ycbcr_enc) == V4L2_YCBCR_ENC_XV601 || \ 380 V4L2_QUANTIZATION_LIM_RANGE : \
381 (((is_rgb_or_hsv) || (ycbcr_enc) == V4L2_YCBCR_ENC_XV601 || \
368 (ycbcr_enc) == V4L2_YCBCR_ENC_XV709 || (colsp) == V4L2_COLORSPACE_JPEG) || \ 382 (ycbcr_enc) == V4L2_YCBCR_ENC_XV709 || (colsp) == V4L2_COLORSPACE_JPEG) || \
369 (colsp) == V4L2_COLORSPACE_ADOBERGB || (colsp) == V4L2_COLORSPACE_SRGB ? \ 383 (colsp) == V4L2_COLORSPACE_ADOBERGB || (colsp) == V4L2_COLORSPACE_SRGB ? \
370 V4L2_QUANTIZATION_FULL_RANGE : V4L2_QUANTIZATION_LIM_RANGE)) 384 V4L2_QUANTIZATION_FULL_RANGE : V4L2_QUANTIZATION_LIM_RANGE))
@@ -462,7 +476,12 @@ struct v4l2_pix_format {
462 __u32 colorspace; /* enum v4l2_colorspace */ 476 __u32 colorspace; /* enum v4l2_colorspace */
463 __u32 priv; /* private data, depends on pixelformat */ 477 __u32 priv; /* private data, depends on pixelformat */
464 __u32 flags; /* format flags (V4L2_PIX_FMT_FLAG_*) */ 478 __u32 flags; /* format flags (V4L2_PIX_FMT_FLAG_*) */
465 __u32 ycbcr_enc; /* enum v4l2_ycbcr_encoding */ 479 union {
480 /* enum v4l2_ycbcr_encoding */
481 __u32 ycbcr_enc;
482 /* enum v4l2_hsv_encoding */
483 __u32 hsv_enc;
484 };
466 __u32 quantization; /* enum v4l2_quantization */ 485 __u32 quantization; /* enum v4l2_quantization */
467 __u32 xfer_func; /* enum v4l2_xfer_func */ 486 __u32 xfer_func; /* enum v4l2_xfer_func */
468}; 487};
@@ -586,6 +605,13 @@ struct v4l2_pix_format {
586#define V4L2_PIX_FMT_SGRBG12 v4l2_fourcc('B', 'A', '1', '2') /* 12 GRGR.. BGBG.. */ 605#define V4L2_PIX_FMT_SGRBG12 v4l2_fourcc('B', 'A', '1', '2') /* 12 GRGR.. BGBG.. */
587#define V4L2_PIX_FMT_SRGGB12 v4l2_fourcc('R', 'G', '1', '2') /* 12 RGRG.. GBGB.. */ 606#define V4L2_PIX_FMT_SRGGB12 v4l2_fourcc('R', 'G', '1', '2') /* 12 RGRG.. GBGB.. */
588#define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') /* 16 BGBG.. GRGR.. */ 607#define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') /* 16 BGBG.. GRGR.. */
608#define V4L2_PIX_FMT_SGBRG16 v4l2_fourcc('G', 'B', '1', '6') /* 16 GBGB.. RGRG.. */
609#define V4L2_PIX_FMT_SGRBG16 v4l2_fourcc('G', 'R', '1', '6') /* 16 GRGR.. BGBG.. */
610#define V4L2_PIX_FMT_SRGGB16 v4l2_fourcc('R', 'G', '1', '6') /* 16 RGRG.. GBGB.. */
611
612/* HSV formats */
613#define V4L2_PIX_FMT_HSV24 v4l2_fourcc('H', 'S', 'V', '3')
614#define V4L2_PIX_FMT_HSV32 v4l2_fourcc('H', 'S', 'V', '4')
589 615
590/* compressed formats */ 616/* compressed formats */
591#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M', 'J', 'P', 'G') /* Motion-JPEG */ 617#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M', 'J', 'P', 'G') /* Motion-JPEG */
@@ -603,6 +629,7 @@ struct v4l2_pix_format {
603#define V4L2_PIX_FMT_VC1_ANNEX_G v4l2_fourcc('V', 'C', '1', 'G') /* SMPTE 421M Annex G compliant stream */ 629#define V4L2_PIX_FMT_VC1_ANNEX_G v4l2_fourcc('V', 'C', '1', 'G') /* SMPTE 421M Annex G compliant stream */
604#define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L') /* SMPTE 421M Annex L compliant stream */ 630#define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L') /* SMPTE 421M Annex L compliant stream */
605#define V4L2_PIX_FMT_VP8 v4l2_fourcc('V', 'P', '8', '0') /* VP8 */ 631#define V4L2_PIX_FMT_VP8 v4l2_fourcc('V', 'P', '8', '0') /* VP8 */
632#define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0') /* VP9 */
606 633
607/* Vendor-specific formats */ 634/* Vendor-specific formats */
608#define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */ 635#define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */
@@ -634,6 +661,7 @@ struct v4l2_pix_format {
634#define V4L2_PIX_FMT_Y8I v4l2_fourcc('Y', '8', 'I', ' ') /* Greyscale 8-bit L/R interleaved */ 661#define V4L2_PIX_FMT_Y8I v4l2_fourcc('Y', '8', 'I', ' ') /* Greyscale 8-bit L/R interleaved */
635#define V4L2_PIX_FMT_Y12I v4l2_fourcc('Y', '1', '2', 'I') /* Greyscale 12-bit L/R interleaved */ 662#define V4L2_PIX_FMT_Y12I v4l2_fourcc('Y', '1', '2', 'I') /* Greyscale 12-bit L/R interleaved */
636#define V4L2_PIX_FMT_Z16 v4l2_fourcc('Z', '1', '6', ' ') /* Depth data 16-bit */ 663#define V4L2_PIX_FMT_Z16 v4l2_fourcc('Z', '1', '6', ' ') /* Depth data 16-bit */
664#define V4L2_PIX_FMT_MT21C v4l2_fourcc('M', 'T', '2', '1') /* Mediatek compressed block mode */
637 665
638/* SDR formats - used only for Software Defined Radio devices */ 666/* SDR formats - used only for Software Defined Radio devices */
639#define V4L2_SDR_FMT_CU8 v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */ 667#define V4L2_SDR_FMT_CU8 v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */
@@ -1229,6 +1257,9 @@ struct v4l2_standard {
1229 * (aka field 2) of interlaced field formats 1257 * (aka field 2) of interlaced field formats
1230 * @standards: Standards the timing belongs to 1258 * @standards: Standards the timing belongs to
1231 * @flags: Flags 1259 * @flags: Flags
1260 * @picture_aspect: The picture aspect ratio (hor/vert).
1261 * @cea861_vic: VIC code as per the CEA-861 standard.
1262 * @hdmi_vic: VIC code as per the HDMI standard.
1232 * @reserved: Reserved fields, must be zeroed. 1263 * @reserved: Reserved fields, must be zeroed.
1233 * 1264 *
1234 * A note regarding vertical interlaced timings: height refers to the total 1265 * A note regarding vertical interlaced timings: height refers to the total
@@ -1258,7 +1289,10 @@ struct v4l2_bt_timings {
1258 __u32 il_vbackporch; 1289 __u32 il_vbackporch;
1259 __u32 standards; 1290 __u32 standards;
1260 __u32 flags; 1291 __u32 flags;
1261 __u32 reserved[14]; 1292 struct v4l2_fract picture_aspect;
1293 __u8 cea861_vic;
1294 __u8 hdmi_vic;
1295 __u8 reserved[46];
1262} __attribute__ ((packed)); 1296} __attribute__ ((packed));
1263 1297
1264/* Interlaced or progressive format */ 1298/* Interlaced or progressive format */
@@ -1278,39 +1312,66 @@ struct v4l2_bt_timings {
1278 1312
1279/* Flags */ 1313/* Flags */
1280 1314
1281/* CVT/GTF specific: timing uses reduced blanking (CVT) or the 'Secondary 1315/*
1282 GTF' curve (GTF). In both cases the horizontal and/or vertical blanking 1316 * CVT/GTF specific: timing uses reduced blanking (CVT) or the 'Secondary
1283 intervals are reduced, allowing a higher resolution over the same 1317 * GTF' curve (GTF). In both cases the horizontal and/or vertical blanking
1284 bandwidth. This is a read-only flag. */ 1318 * intervals are reduced, allowing a higher resolution over the same
1319 * bandwidth. This is a read-only flag.
1320 */
1285#define V4L2_DV_FL_REDUCED_BLANKING (1 << 0) 1321#define V4L2_DV_FL_REDUCED_BLANKING (1 << 0)
1286/* CEA-861 specific: set for CEA-861 formats with a framerate of a multiple 1322/*
1287 of six. These formats can be optionally played at 1 / 1.001 speed. 1323 * CEA-861 specific: set for CEA-861 formats with a framerate of a multiple
1288 This is a read-only flag. */ 1324 * of six. These formats can be optionally played at 1 / 1.001 speed.
1325 * This is a read-only flag.
1326 */
1289#define V4L2_DV_FL_CAN_REDUCE_FPS (1 << 1) 1327#define V4L2_DV_FL_CAN_REDUCE_FPS (1 << 1)
1290/* CEA-861 specific: only valid for video transmitters, the flag is cleared 1328/*
1291 by receivers. 1329 * CEA-861 specific: only valid for video transmitters, the flag is cleared
1292 If the framerate of the format is a multiple of six, then the pixelclock 1330 * by receivers.
1293 used to set up the transmitter is divided by 1.001 to make it compatible 1331 * If the framerate of the format is a multiple of six, then the pixelclock
1294 with 60 Hz based standards such as NTSC and PAL-M that use a framerate of 1332 * used to set up the transmitter is divided by 1.001 to make it compatible
1295 29.97 Hz. Otherwise this flag is cleared. If the transmitter can't generate 1333 * with 60 Hz based standards such as NTSC and PAL-M that use a framerate of
1296 such frequencies, then the flag will also be cleared. */ 1334 * 29.97 Hz. Otherwise this flag is cleared. If the transmitter can't generate
1335 * such frequencies, then the flag will also be cleared.
1336 */
1297#define V4L2_DV_FL_REDUCED_FPS (1 << 2) 1337#define V4L2_DV_FL_REDUCED_FPS (1 << 2)
1298/* Specific to interlaced formats: if set, then field 1 is really one half-line 1338/*
1299 longer and field 2 is really one half-line shorter, so each field has 1339 * Specific to interlaced formats: if set, then field 1 is really one half-line
1300 exactly the same number of half-lines. Whether half-lines can be detected 1340 * longer and field 2 is really one half-line shorter, so each field has
1301 or used depends on the hardware. */ 1341 * exactly the same number of half-lines. Whether half-lines can be detected
1342 * or used depends on the hardware.
1343 */
1302#define V4L2_DV_FL_HALF_LINE (1 << 3) 1344#define V4L2_DV_FL_HALF_LINE (1 << 3)
1303/* If set, then this is a Consumer Electronics (CE) video format. Such formats 1345/*
1346 * If set, then this is a Consumer Electronics (CE) video format. Such formats
1304 * differ from other formats (commonly called IT formats) in that if RGB 1347 * differ from other formats (commonly called IT formats) in that if RGB
1305 * encoding is used then by default the RGB values use limited range (i.e. 1348 * encoding is used then by default the RGB values use limited range (i.e.
1306 * use the range 16-235) as opposed to 0-255. All formats defined in CEA-861 1349 * use the range 16-235) as opposed to 0-255. All formats defined in CEA-861
1307 * except for the 640x480 format are CE formats. */ 1350 * except for the 640x480 format are CE formats.
1351 */
1308#define V4L2_DV_FL_IS_CE_VIDEO (1 << 4) 1352#define V4L2_DV_FL_IS_CE_VIDEO (1 << 4)
1309/* Some formats like SMPTE-125M have an interlaced signal with a odd 1353/* Some formats like SMPTE-125M have an interlaced signal with a odd
1310 * total height. For these formats, if this flag is set, the first 1354 * total height. For these formats, if this flag is set, the first
1311 * field has the extra line. If not, it is the second field. 1355 * field has the extra line. If not, it is the second field.
1312 */ 1356 */
1313#define V4L2_DV_FL_FIRST_FIELD_EXTRA_LINE (1 << 5) 1357#define V4L2_DV_FL_FIRST_FIELD_EXTRA_LINE (1 << 5)
1358/*
1359 * If set, then the picture_aspect field is valid. Otherwise assume that the
1360 * pixels are square, so the picture aspect ratio is the same as the width to
1361 * height ratio.
1362 */
1363#define V4L2_DV_FL_HAS_PICTURE_ASPECT (1 << 6)
1364/*
1365 * If set, then the cea861_vic field is valid and contains the Video
1366 * Identification Code as per the CEA-861 standard.
1367 */
1368#define V4L2_DV_FL_HAS_CEA861_VIC (1 << 7)
1369/*
1370 * If set, then the hdmi_vic field is valid and contains the Video
1371 * Identification Code as per the HDMI standard (HDMI Vendor Specific
1372 * InfoFrame).
1373 */
1374#define V4L2_DV_FL_HAS_HDMI_VIC (1 << 8)
1314 1375
1315/* A few useful defines to calculate the total blanking and frame sizes */ 1376/* A few useful defines to calculate the total blanking and frame sizes */
1316#define V4L2_DV_BT_BLANKING_WIDTH(bt) \ 1377#define V4L2_DV_BT_BLANKING_WIDTH(bt) \
@@ -2006,7 +2067,10 @@ struct v4l2_pix_format_mplane {
2006 struct v4l2_plane_pix_format plane_fmt[VIDEO_MAX_PLANES]; 2067 struct v4l2_plane_pix_format plane_fmt[VIDEO_MAX_PLANES];
2007 __u8 num_planes; 2068 __u8 num_planes;
2008 __u8 flags; 2069 __u8 flags;
2009 __u8 ycbcr_enc; 2070 union {
2071 __u8 ycbcr_enc;
2072 __u8 hsv_enc;
2073 };
2010 __u8 quantization; 2074 __u8 quantization;
2011 __u8 xfer_func; 2075 __u8 xfer_func;
2012 __u8 reserved[7]; 2076 __u8 reserved[7];