aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/testing/sysfs-class-rc-nuvoton15
-rw-r--r--Documentation/DocBook/device-drivers.tmpl1
-rw-r--r--Documentation/DocBook/media/v4l/controls.xml58
-rw-r--r--Documentation/DocBook/media/v4l/media-ioc-g-topology.xml3
-rw-r--r--Documentation/DocBook/media/v4l/media-types.xml81
-rw-r--r--Documentation/DocBook/media/v4l/pixfmt-y12i.xml49
-rw-r--r--Documentation/DocBook/media/v4l/pixfmt-y8i.xml80
-rw-r--r--Documentation/DocBook/media/v4l/pixfmt-yuv420m.xml26
-rw-r--r--Documentation/DocBook/media/v4l/pixfmt-yuv422m.xml (renamed from Documentation/DocBook/media/v4l/pixfmt-yvu420m.xml)106
-rw-r--r--Documentation/DocBook/media/v4l/pixfmt-yuv444m.xml177
-rw-r--r--Documentation/DocBook/media/v4l/pixfmt-z16.xml81
-rw-r--r--Documentation/DocBook/media/v4l/pixfmt.xml13
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-query-dv-timings.xml14
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-querystd.xml10
-rw-r--r--Documentation/devicetree/bindings/media/i2c/mt9v032.txt2
-rw-r--r--Documentation/devicetree/bindings/media/i2c/tvp5150.txt45
-rw-r--r--Documentation/devicetree/bindings/media/rcar_vin.txt1
-rw-r--r--Documentation/devicetree/bindings/media/renesas,jpu.txt13
-rw-r--r--Documentation/devicetree/bindings/media/renesas,vsp1.txt34
-rw-r--r--Documentation/devicetree/bindings/media/ti-cal.txt72
-rw-r--r--Documentation/dvb/README.dvb-usb2
-rw-r--r--Documentation/video4linux/CARDLIST.saa71341
-rw-r--r--Documentation/video4linux/v4l2-controls.txt1
-rw-r--r--MAINTAINERS12
-rw-r--r--drivers/media/common/b2c2/flexcop-fe-tuner.c4
-rw-r--r--drivers/media/common/b2c2/flexcop.c4
-rw-r--r--drivers/media/common/cypress_firmware.c2
-rw-r--r--drivers/media/common/cypress_firmware.h2
-rw-r--r--drivers/media/common/siano/smscoreapi.c4
-rw-r--r--drivers/media/common/siano/smsdvb-main.c7
-rw-r--r--drivers/media/dvb-core/dvb-usb-ids.h9
-rw-r--r--drivers/media/dvb-core/dvb_frontend.c218
-rw-r--r--drivers/media/dvb-core/dvb_frontend.h3
-rw-r--r--drivers/media/dvb-core/dvbdev.c15
-rw-r--r--drivers/media/dvb-frontends/Kconfig8
-rw-r--r--drivers/media/dvb-frontends/Makefile1
-rw-r--r--drivers/media/dvb-frontends/af9013.c8
-rw-r--r--drivers/media/dvb-frontends/af9033.c7
-rw-r--r--drivers/media/dvb-frontends/as102_fe.c4
-rw-r--r--drivers/media/dvb-frontends/atbm8830.c4
-rw-r--r--drivers/media/dvb-frontends/au8522.h1
-rw-r--r--drivers/media/dvb-frontends/au8522_decoder.c7
-rw-r--r--drivers/media/dvb-frontends/au8522_dig.c4
-rw-r--r--drivers/media/dvb-frontends/au8522_priv.h11
-rw-r--r--drivers/media/dvb-frontends/bcm3510.c4
-rw-r--r--drivers/media/dvb-frontends/bcm3510.h2
-rw-r--r--drivers/media/dvb-frontends/bcm3510_priv.h2
-rw-r--r--drivers/media/dvb-frontends/cx22700.c4
-rw-r--r--drivers/media/dvb-frontends/cx22702.c4
-rw-r--r--drivers/media/dvb-frontends/cx24110.c4
-rw-r--r--drivers/media/dvb-frontends/cx24117.c4
-rw-r--r--drivers/media/dvb-frontends/cx24120.c8
-rw-r--r--drivers/media/dvb-frontends/cx24123.c4
-rw-r--r--drivers/media/dvb-frontends/cxd2820r_c.c4
-rw-r--r--drivers/media/dvb-frontends/cxd2820r_core.c20
-rw-r--r--drivers/media/dvb-frontends/cxd2820r_priv.h9
-rw-r--r--drivers/media/dvb-frontends/cxd2820r_t.c4
-rw-r--r--drivers/media/dvb-frontends/cxd2820r_t2.c6
-rw-r--r--drivers/media/dvb-frontends/cxd2841er.c4
-rw-r--r--drivers/media/dvb-frontends/dib0070.c2
-rw-r--r--drivers/media/dvb-frontends/dib0090.c16
-rw-r--r--drivers/media/dvb-frontends/dib3000.h6
-rw-r--r--drivers/media/dvb-frontends/dib3000mb.c17
-rw-r--r--drivers/media/dvb-frontends/dib3000mb_priv.h2
-rw-r--r--drivers/media/dvb-frontends/dib3000mc.c10
-rw-r--r--drivers/media/dvb-frontends/dib3000mc.h2
-rw-r--r--drivers/media/dvb-frontends/dib7000m.c8
-rw-r--r--drivers/media/dvb-frontends/dib7000p.c10
-rw-r--r--drivers/media/dvb-frontends/dib8000.c77
-rw-r--r--drivers/media/dvb-frontends/dib9000.c31
-rw-r--r--drivers/media/dvb-frontends/dibx000_common.c2
-rw-r--r--drivers/media/dvb-frontends/drx39xyj/drxj.c11
-rw-r--r--drivers/media/dvb-frontends/dvb_dummy_fe.c7
-rw-r--r--drivers/media/dvb-frontends/hd29l2.c4
-rw-r--r--drivers/media/dvb-frontends/l64781.c4
-rw-r--r--drivers/media/dvb-frontends/lg2160.c62
-rw-r--r--drivers/media/dvb-frontends/lgdt3305.c4
-rw-r--r--drivers/media/dvb-frontends/lgdt3306a.c4
-rw-r--r--drivers/media/dvb-frontends/lgdt330x.c5
-rw-r--r--drivers/media/dvb-frontends/lgs8gl5.c5
-rw-r--r--drivers/media/dvb-frontends/lgs8gxx.c13
-rw-r--r--drivers/media/dvb-frontends/m88ds3103.c4
-rw-r--r--drivers/media/dvb-frontends/m88rs2000.c5
-rw-r--r--drivers/media/dvb-frontends/mb86a20s.c11
-rw-r--r--drivers/media/dvb-frontends/mn88473.c (renamed from drivers/staging/media/mn88473/mn88473.c)388
-rw-r--r--drivers/media/dvb-frontends/mn88473.h14
-rw-r--r--drivers/media/dvb-frontends/mn88473_priv.h (renamed from drivers/staging/media/mn88473/mn88473_priv.h)7
-rw-r--r--drivers/media/dvb-frontends/mt312.c4
-rw-r--r--drivers/media/dvb-frontends/mt352.c4
-rw-r--r--drivers/media/dvb-frontends/or51132.c4
-rw-r--r--drivers/media/dvb-frontends/rtl2830.c7
-rw-r--r--drivers/media/dvb-frontends/rtl2832.c155
-rw-r--r--drivers/media/dvb-frontends/rtl2832.h4
-rw-r--r--drivers/media/dvb-frontends/rtl2832_priv.h1
-rw-r--r--drivers/media/dvb-frontends/s5h1409.c4
-rw-r--r--drivers/media/dvb-frontends/s5h1411.c4
-rw-r--r--drivers/media/dvb-frontends/s5h1420.c4
-rw-r--r--drivers/media/dvb-frontends/s921.c4
-rw-r--r--drivers/media/dvb-frontends/si2165.c28
-rw-r--r--drivers/media/dvb-frontends/stb0899_drv.c4
-rw-r--r--drivers/media/dvb-frontends/stb6100.c2
-rw-r--r--drivers/media/dvb-frontends/stv0297.c4
-rw-r--r--drivers/media/dvb-frontends/stv0299.c8
-rw-r--r--drivers/media/dvb-frontends/stv0367.c8
-rw-r--r--drivers/media/dvb-frontends/stv0900_core.c11
-rw-r--r--drivers/media/dvb-frontends/stv6110x.c4
-rw-r--r--drivers/media/dvb-frontends/stv6110x.h4
-rw-r--r--drivers/media/dvb-frontends/stv6110x_priv.h2
-rw-r--r--drivers/media/dvb-frontends/tc90522.c10
-rw-r--r--drivers/media/dvb-frontends/tda10021.c4
-rw-r--r--drivers/media/dvb-frontends/tda10023.c4
-rw-r--r--drivers/media/dvb-frontends/tda10048.c4
-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.c4
-rw-r--r--drivers/media/dvb-frontends/tda8083.c4
-rw-r--r--drivers/media/dvb-frontends/ts2020.c4
-rw-r--r--drivers/media/dvb-frontends/ves1820.c4
-rw-r--r--drivers/media/dvb-frontends/ves1x93.c4
-rw-r--r--drivers/media/dvb-frontends/zl10353.c4
-rw-r--r--drivers/media/i2c/adv7511.c43
-rw-r--r--drivers/media/i2c/adv7604.c230
-rw-r--r--drivers/media/i2c/adv7842.c20
-rw-r--r--drivers/media/i2c/msp3400-driver.c14
-rw-r--r--drivers/media/i2c/msp3400-driver.h5
-rw-r--r--drivers/media/i2c/mt9v011.c15
-rw-r--r--drivers/media/i2c/mt9v032.c28
-rw-r--r--drivers/media/i2c/ov2659.c8
-rw-r--r--drivers/media/i2c/ov9650.c4
-rw-r--r--drivers/media/i2c/s5c73m3/s5c73m3-core.c4
-rw-r--r--drivers/media/i2c/s5c73m3/s5c73m3-spi.c1
-rw-r--r--drivers/media/i2c/s5k5baf.c5
-rw-r--r--drivers/media/i2c/saa7115.c19
-rw-r--r--drivers/media/i2c/soc_camera/mt9m001.c2
-rw-r--r--drivers/media/i2c/soc_camera/mt9t031.c2
-rw-r--r--drivers/media/i2c/soc_camera/mt9v022.c2
-rw-r--r--drivers/media/i2c/tc358743.c55
-rw-r--r--drivers/media/i2c/tvp514x.c6
-rw-r--r--drivers/media/i2c/tvp5150.c452
-rw-r--r--drivers/media/i2c/tvp7002.c6
-rw-r--r--drivers/media/i2c/vpx3220.c2
-rw-r--r--drivers/media/media-device.c145
-rw-r--r--drivers/media/media-devnode.c1
-rw-r--r--drivers/media/media-entity.c94
-rw-r--r--drivers/media/pci/b2c2/flexcop-pci.c2
-rw-r--r--drivers/media/pci/bt8xx/bttv-driver.c53
-rw-r--r--drivers/media/pci/bt8xx/dst.c4
-rw-r--r--drivers/media/pci/bt8xx/dvb-bt8xx.c4
-rw-r--r--drivers/media/pci/cx23885/cx23885-dvb.c19
-rw-r--r--drivers/media/pci/cx88/cx88-dvb.c3
-rw-r--r--drivers/media/pci/ddbridge/ddbridge-core.c2
-rw-r--r--drivers/media/pci/ivtv/ivtv-queue.c2
-rw-r--r--drivers/media/pci/netup_unidvb/netup_unidvb_core.c7
-rw-r--r--drivers/media/pci/ngene/ngene-cards.c2
-rw-r--r--drivers/media/pci/pt3/pt3.c3
-rw-r--r--drivers/media/pci/saa7134/saa7134-cards.c1851
-rw-r--r--drivers/media/pci/saa7134/saa7134-core.c195
-rw-r--r--drivers/media/pci/saa7134/saa7134-dvb.c9
-rw-r--r--drivers/media/pci/saa7134/saa7134-empress.c3
-rw-r--r--drivers/media/pci/saa7134/saa7134-go7007.c2
-rw-r--r--drivers/media/pci/saa7134/saa7134-input.c21
-rw-r--r--drivers/media/pci/saa7134/saa7134-tvaudio.c13
-rw-r--r--drivers/media/pci/saa7134/saa7134-video.c108
-rw-r--r--drivers/media/pci/saa7134/saa7134.h46
-rw-r--r--drivers/media/pci/ttpci/av7110.c15
-rw-r--r--drivers/media/pci/ttpci/budget.c36
-rw-r--r--drivers/media/platform/Kconfig22
-rw-r--r--drivers/media/platform/Makefile3
-rw-r--r--drivers/media/platform/coda/coda-bit.c2
-rw-r--r--drivers/media/platform/coda/coda-common.c106
-rw-r--r--drivers/media/platform/coda/coda.h3
-rw-r--r--drivers/media/platform/davinci/dm644x_ccdc.c2
-rw-r--r--drivers/media/platform/exynos-gsc/gsc-m2m.c2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-lite.c12
-rw-r--r--drivers/media/platform/exynos4-is/media-dev.c20
-rw-r--r--drivers/media/platform/exynos4-is/mipi-csis.c10
-rw-r--r--drivers/media/platform/omap3isp/isp.c226
-rw-r--r--drivers/media/platform/omap3isp/isp.h4
-rw-r--r--drivers/media/platform/omap3isp/ispccdc.c2
-rw-r--r--drivers/media/platform/omap3isp/isppreview.c14
-rw-r--r--drivers/media/platform/omap3isp/ispvideo.c116
-rw-r--r--drivers/media/platform/omap3isp/ispvideo.h1
-rw-r--r--drivers/media/platform/omap3isp/omap3isp.h8
-rw-r--r--drivers/media/platform/rcar_jpu.c1
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_enc.c12
-rw-r--r--drivers/media/platform/soc_camera/Kconfig29
-rw-r--r--drivers/media/platform/soc_camera/Makefile3
-rw-r--r--drivers/media/platform/soc_camera/atmel-isi.c4
-rw-r--r--drivers/media/platform/soc_camera/pxa_camera.c478
-rw-r--r--drivers/media/platform/soc_camera/rcar_vin.c41
-rw-r--r--drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c14
-rw-r--r--drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c2
-rw-r--r--drivers/media/platform/ti-vpe/Makefile4
-rw-r--r--drivers/media/platform/ti-vpe/cal.c1947
-rw-r--r--drivers/media/platform/ti-vpe/cal_regs.h479
-rw-r--r--drivers/media/platform/vim2m.c2
-rw-r--r--drivers/media/platform/vivid/vivid-osd.c2
-rw-r--r--drivers/media/platform/vivid/vivid-tpg.c32
-rw-r--r--drivers/media/platform/vivid/vivid-tpg.h2
-rw-r--r--drivers/media/platform/vivid/vivid-vid-common.c39
-rw-r--r--drivers/media/platform/vsp1/Makefile3
-rw-r--r--drivers/media/platform/vsp1/vsp1.h29
-rw-r--r--drivers/media/platform/vsp1/vsp1_bru.c33
-rw-r--r--drivers/media/platform/vsp1/vsp1_bru.h3
-rw-r--r--drivers/media/platform/vsp1/vsp1_dl.c305
-rw-r--r--drivers/media/platform/vsp1/vsp1_dl.h42
-rw-r--r--drivers/media/platform/vsp1/vsp1_drm.c597
-rw-r--r--drivers/media/platform/vsp1/vsp1_drm.h49
-rw-r--r--drivers/media/platform/vsp1/vsp1_drv.c382
-rw-r--r--drivers/media/platform/vsp1/vsp1_entity.c31
-rw-r--r--drivers/media/platform/vsp1/vsp1_entity.h14
-rw-r--r--drivers/media/platform/vsp1/vsp1_hsit.c2
-rw-r--r--drivers/media/platform/vsp1/vsp1_lif.c11
-rw-r--r--drivers/media/platform/vsp1/vsp1_lut.c7
-rw-r--r--drivers/media/platform/vsp1/vsp1_pipe.c426
-rw-r--r--drivers/media/platform/vsp1/vsp1_pipe.h134
-rw-r--r--drivers/media/platform/vsp1/vsp1_regs.h32
-rw-r--r--drivers/media/platform/vsp1/vsp1_rpf.c88
-rw-r--r--drivers/media/platform/vsp1/vsp1_rwpf.h29
-rw-r--r--drivers/media/platform/vsp1/vsp1_sru.c9
-rw-r--r--drivers/media/platform/vsp1/vsp1_uds.c8
-rw-r--r--drivers/media/platform/vsp1/vsp1_video.c518
-rw-r--r--drivers/media/platform/vsp1/vsp1_video.h111
-rw-r--r--drivers/media/platform/vsp1/vsp1_wpf.c98
-rw-r--r--drivers/media/radio/radio-si476x.c4
-rw-r--r--drivers/media/radio/tea575x.c21
-rw-r--r--drivers/media/radio/wl128x/fmdrv_common.c2
-rw-r--r--drivers/media/rc/ati_remote.c47
-rw-r--r--drivers/media/rc/igorplugusb.c17
-rw-r--r--drivers/media/rc/keymaps/rc-avermedia-rm-ks.c56
-rw-r--r--drivers/media/rc/lirc_dev.c7
-rw-r--r--drivers/media/rc/mceusb.c5
-rw-r--r--drivers/media/rc/nuvoton-cir.c358
-rw-r--r--drivers/media/rc/nuvoton-cir.h15
-rw-r--r--drivers/media/rc/rc-core-priv.h6
-rw-r--r--drivers/media/rc/rc-ir-raw.c23
-rw-r--r--drivers/media/rc/rc-main.c48
-rw-r--r--drivers/media/rc/sunxi-cir.c1
-rw-r--r--drivers/media/tuners/m88rs6000t.c11
-rw-r--r--drivers/media/tuners/r820t.c2
-rw-r--r--drivers/media/tuners/si2157.c39
-rw-r--r--drivers/media/tuners/si2157.h5
-rw-r--r--drivers/media/tuners/si2157_priv.h8
-rw-r--r--drivers/media/tuners/tuner-xc2028.c6
-rw-r--r--drivers/media/tuners/xc4000.c2
-rw-r--r--drivers/media/usb/airspy/airspy.c11
-rw-r--r--drivers/media/usb/as102/as102_drv.h2
-rw-r--r--drivers/media/usb/as102/as102_usb_drv.c2
-rw-r--r--drivers/media/usb/au0828/au0828-core.c456
-rw-r--r--drivers/media/usb/au0828/au0828-dvb.c12
-rw-r--r--drivers/media/usb/au0828/au0828-video.c190
-rw-r--r--drivers/media/usb/au0828/au0828.h27
-rw-r--r--drivers/media/usb/b2c2/flexcop-usb.c2
-rw-r--r--drivers/media/usb/cpia2/cpia2_core.c2
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-417.c2
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-audio.c5
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-cards.c68
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-dvb.c10
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-video.c47
-rw-r--r--drivers/media/usb/cx231xx/cx231xx.h4
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9035.c6
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9035.h3
-rw-r--r--drivers/media/usb/dvb-usb-v2/dvb_usb.h2
-rw-r--r--drivers/media/usb/dvb-usb-v2/dvb_usb_common.h2
-rw-r--r--drivers/media/usb/dvb-usb-v2/dvb_usb_core.c15
-rw-r--r--drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c2
-rw-r--r--drivers/media/usb/dvb-usb-v2/dvbsky.c7
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c6
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.h8
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/rtl28xxu.c32
-rw-r--r--drivers/media/usb/dvb-usb-v2/usb_urb.c2
-rw-r--r--drivers/media/usb/dvb-usb/a800.c4
-rw-r--r--drivers/media/usb/dvb-usb/af9005-fe.c4
-rw-r--r--drivers/media/usb/dvb-usb/cxusb.c4
-rw-r--r--drivers/media/usb/dvb-usb/dib0700_core.c2
-rw-r--r--drivers/media/usb/dvb-usb/dib0700_devices.c77
-rw-r--r--drivers/media/usb/dvb-usb/dibusb-common.c2
-rw-r--r--drivers/media/usb/dvb-usb/dibusb-mb.c6
-rw-r--r--drivers/media/usb/dvb-usb/dibusb-mc.c6
-rw-r--r--drivers/media/usb/dvb-usb/dibusb.h2
-rw-r--r--drivers/media/usb/dvb-usb/digitv.c4
-rw-r--r--drivers/media/usb/dvb-usb/dtt200u-fe.c7
-rw-r--r--drivers/media/usb/dvb-usb/dtt200u.c4
-rw-r--r--drivers/media/usb/dvb-usb/dtt200u.h2
-rw-r--r--drivers/media/usb/dvb-usb/dvb-usb-common.h2
-rw-r--r--drivers/media/usb/dvb-usb/dvb-usb-dvb.c13
-rw-r--r--drivers/media/usb/dvb-usb/dvb-usb-firmware.c2
-rw-r--r--drivers/media/usb/dvb-usb/dvb-usb-i2c.c2
-rw-r--r--drivers/media/usb/dvb-usb/dvb-usb-init.c4
-rw-r--r--drivers/media/usb/dvb-usb/dvb-usb-remote.c2
-rw-r--r--drivers/media/usb/dvb-usb/dvb-usb-urb.c2
-rw-r--r--drivers/media/usb/dvb-usb/dvb-usb.h2
-rw-r--r--drivers/media/usb/dvb-usb/dw2102.c105
-rw-r--r--drivers/media/usb/dvb-usb/friio-fe.c27
-rw-r--r--drivers/media/usb/dvb-usb/nova-t-usb2.c4
-rw-r--r--drivers/media/usb/dvb-usb/technisat-usb2.c43
-rw-r--r--drivers/media/usb/dvb-usb/ttusb2.c2
-rw-r--r--drivers/media/usb/dvb-usb/umt-010.c4
-rw-r--r--drivers/media/usb/dvb-usb/usb-urb.c2
-rw-r--r--drivers/media/usb/dvb-usb/vp702x-fe.c2
-rw-r--r--drivers/media/usb/dvb-usb/vp702x.c4
-rw-r--r--drivers/media/usb/dvb-usb/vp7045-fe.c2
-rw-r--r--drivers/media/usb/dvb-usb/vp7045.c4
-rw-r--r--drivers/media/usb/dvb-usb/vp7045.h2
-rw-r--r--drivers/media/usb/em28xx/em28xx-camera.c4
-rw-r--r--drivers/media/usb/em28xx/em28xx-cards.c246
-rw-r--r--drivers/media/usb/em28xx/em28xx-dvb.c21
-rw-r--r--drivers/media/usb/em28xx/em28xx-video.c213
-rw-r--r--drivers/media/usb/em28xx/em28xx.h21
-rw-r--r--drivers/media/usb/go7007/go7007-priv.h2
-rw-r--r--drivers/media/usb/go7007/go7007-usb.c4
-rw-r--r--drivers/media/usb/gspca/ov519.c43
-rw-r--r--drivers/media/usb/gspca/touptek.c8
-rw-r--r--drivers/media/usb/gspca/w996Xcf.c8
-rw-r--r--drivers/media/usb/hdpvr/hdpvr-core.c2
-rw-r--r--drivers/media/usb/hdpvr/hdpvr-video.c6
-rw-r--r--drivers/media/usb/msi2500/msi2500.c2
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-context.c2
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-hdw.c3
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-io.c2
-rw-r--r--drivers/media/usb/pwc/pwc-if.c6
-rw-r--r--drivers/media/usb/siano/smsusb.c30
-rw-r--r--drivers/media/usb/stk1160/stk1160-video.c1
-rw-r--r--drivers/media/usb/usbtv/usbtv-video.c37
-rw-r--r--drivers/media/usb/usbtv/usbtv.h1
-rw-r--r--drivers/media/usb/usbvision/usbvision-video.c29
-rw-r--r--drivers/media/usb/uvc/uvc_driver.c20
-rw-r--r--drivers/media/usb/uvc/uvcvideo.h12
-rw-r--r--drivers/media/v4l2-core/Kconfig1
-rw-r--r--drivers/media/v4l2-core/Makefile1
-rw-r--r--drivers/media/v4l2-core/tuner-core.c26
-rw-r--r--drivers/media/v4l2-core/v4l2-async.c7
-rw-r--r--drivers/media/v4l2-core/v4l2-compat-ioctl32.c21
-rw-r--r--drivers/media/v4l2-core/v4l2-ctrls.c34
-rw-r--r--drivers/media/v4l2-core/v4l2-dv-timings.c3
-rw-r--r--drivers/media/v4l2-core/v4l2-fh.c2
-rw-r--r--drivers/media/v4l2-core/v4l2-ioctl.c36
-rw-r--r--drivers/media/v4l2-core/v4l2-mc.c403
-rw-r--r--drivers/media/v4l2-core/v4l2-of.c2
-rw-r--r--drivers/media/v4l2-core/videobuf-core.c10
-rw-r--r--drivers/media/v4l2-core/videobuf2-core.c5
-rw-r--r--drivers/media/v4l2-core/videobuf2-dvb.c13
-rw-r--r--drivers/staging/media/Kconfig8
-rw-r--r--drivers/staging/media/Makefile5
-rw-r--r--drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h2
-rw-r--r--drivers/staging/media/lirc/lirc_parallel.c24
-rw-r--r--drivers/staging/media/lirc/lirc_zilog.c4
-rw-r--r--drivers/staging/media/mn88473/Kconfig7
-rw-r--r--drivers/staging/media/mn88473/Makefile5
-rw-r--r--drivers/staging/media/mn88473/TODO21
-rw-r--r--drivers/staging/media/mx2/Kconfig15
-rw-r--r--drivers/staging/media/mx2/Makefile3
-rw-r--r--drivers/staging/media/mx2/TODO10
-rw-r--r--drivers/staging/media/mx2/mx2_camera.c (renamed from drivers/media/platform/soc_camera/mx2_camera.c)0
-rw-r--r--drivers/staging/media/mx3/Kconfig15
-rw-r--r--drivers/staging/media/mx3/Makefile3
-rw-r--r--drivers/staging/media/mx3/TODO10
-rw-r--r--drivers/staging/media/mx3/mx3_camera.c (renamed from drivers/media/platform/soc_camera/mx3_camera.c)12
-rw-r--r--drivers/staging/media/omap1/Kconfig13
-rw-r--r--drivers/staging/media/omap1/Makefile3
-rw-r--r--drivers/staging/media/omap1/TODO8
-rw-r--r--drivers/staging/media/omap1/omap1_camera.c (renamed from drivers/media/platform/soc_camera/omap1_camera.c)0
-rw-r--r--drivers/staging/media/omap4iss/iss.c211
-rw-r--r--drivers/staging/media/omap4iss/iss.h6
-rw-r--r--drivers/staging/media/omap4iss/iss_video.c15
-rw-r--r--drivers/staging/media/omap4iss/iss_video.h1
-rw-r--r--drivers/staging/media/timb/Kconfig11
-rw-r--r--drivers/staging/media/timb/Makefile1
-rw-r--r--drivers/staging/media/timb/timblogiw.c (renamed from drivers/media/platform/timblogiw.c)0
-rw-r--r--drivers/usb/musb/sunxi.c1
-rw-r--r--include/dt-bindings/media/tvp5150.h (renamed from include/media/i2c/tvp5150.h)8
-rw-r--r--include/media/media-device.h149
-rw-r--r--include/media/media-entity.h20
-rw-r--r--include/media/rc-core.h2
-rw-r--r--include/media/tuner.h9
-rw-r--r--include/media/v4l2-ctrls.h12
-rw-r--r--include/media/v4l2-dev.h1
-rw-r--r--include/media/v4l2-mc.h243
-rw-r--r--include/media/v4l2-subdev.h3
-rw-r--r--include/media/videobuf2-dvb.h5
-rw-r--r--include/media/vsp1.h33
-rw-r--r--include/uapi/linux/media.h45
-rw-r--r--include/uapi/linux/v4l2-common.h46
-rw-r--r--include/uapi/linux/v4l2-controls.h11
-rw-r--r--include/uapi/linux/videodev2.h7
-rw-r--r--sound/usb/Kconfig4
-rw-r--r--sound/usb/Makefile2
-rw-r--r--sound/usb/card.c14
-rw-r--r--sound/usb/card.h3
-rw-r--r--sound/usb/media.c318
-rw-r--r--sound/usb/media.h72
-rw-r--r--sound/usb/mixer.h3
-rw-r--r--sound/usb/pcm.c28
-rw-r--r--sound/usb/quirks-table.h1
-rw-r--r--sound/usb/stream.c2
-rw-r--r--sound/usb/usbaudio.h6
398 files changed, 12321 insertions, 4923 deletions
diff --git a/Documentation/ABI/testing/sysfs-class-rc-nuvoton b/Documentation/ABI/testing/sysfs-class-rc-nuvoton
new file mode 100644
index 000000000000..905bcdeedef2
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-rc-nuvoton
@@ -0,0 +1,15 @@
1What: /sys/class/rc/rcN/wakeup_data
2Date: Mar 2016
3KernelVersion: 4.6
4Contact: Mauro Carvalho Chehab <m.chehab@samsung.com>
5Description:
6 Reading this file returns the stored CIR wakeup sequence.
7 It starts with a pulse, followed by a space, pulse etc.
8 All values are in microseconds.
9 The same format can be used to store a wakeup sequence
10 in the Nuvoton chip by writing to this file.
11
12 Note: Some systems reset the stored wakeup sequence to a
13 factory default on each boot. On such systems store the
14 wakeup sequence in a file and set it on boot using e.g.
15 a udev rule.
diff --git a/Documentation/DocBook/device-drivers.tmpl b/Documentation/DocBook/device-drivers.tmpl
index cdd8b24db68d..cc303a2f641c 100644
--- a/Documentation/DocBook/device-drivers.tmpl
+++ b/Documentation/DocBook/device-drivers.tmpl
@@ -229,6 +229,7 @@ X!Isound/sound_firmware.c
229!Iinclude/media/v4l2-dv-timings.h 229!Iinclude/media/v4l2-dv-timings.h
230!Iinclude/media/v4l2-event.h 230!Iinclude/media/v4l2-event.h
231!Iinclude/media/v4l2-flash-led-class.h 231!Iinclude/media/v4l2-flash-led-class.h
232!Iinclude/media/v4l2-mc.h
232!Iinclude/media/v4l2-mediabus.h 233!Iinclude/media/v4l2-mediabus.h
233!Iinclude/media/v4l2-mem2mem.h 234!Iinclude/media/v4l2-mem2mem.h
234!Iinclude/media/v4l2-of.h 235!Iinclude/media/v4l2-of.h
diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml
index f13a429093f1..361040e6b0f4 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -2330,6 +2330,14 @@ vertical search range for motion estimation module in video encoder.</entry>
2330 </row> 2330 </row>
2331 2331
2332 <row><entry></entry></row> 2332 <row><entry></entry></row>
2333 <row id="v4l2-mpeg-video-force-key-frame">
2334 <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME</constant>&nbsp;</entry>
2335 <entry>button</entry>
2336 </row><row><entry spanname="descr">Force a key frame for the next queued buffer. Applicable to encoders.
2337This is a general, codec-agnostic keyframe control.</entry>
2338 </row>
2339
2340 <row><entry></entry></row>
2333 <row> 2341 <row>
2334 <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_H264_CPB_SIZE</constant>&nbsp;</entry> 2342 <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_H264_CPB_SIZE</constant>&nbsp;</entry>
2335 <entry>integer</entry> 2343 <entry>integer</entry>
@@ -5070,6 +5078,46 @@ interface and may change in the future.</para>
5070 </entry> 5078 </entry>
5071 </row> 5079 </row>
5072 <row> 5080 <row>
5081 <entry spanname="id"><constant>V4L2_CID_DV_TX_IT_CONTENT_TYPE</constant></entry>
5082 <entry id="v4l2-dv-content-type">enum v4l2_dv_it_content_type</entry>
5083 </row>
5084 <row><entry spanname="descr">Configures the IT Content Type
5085 of the transmitted video. This information is sent over HDMI and DisplayPort connectors
5086 as part of the AVI InfoFrame. The term 'IT Content' is used for content that originates
5087 from a computer as opposed to content from a TV broadcast or an analog source. The
5088 enum&nbsp;v4l2_dv_it_content_type defines the possible content types:</entry>
5089 </row>
5090 <row>
5091 <entrytbl spanname="descr" cols="2">
5092 <tbody valign="top">
5093 <row>
5094 <entry><constant>V4L2_DV_IT_CONTENT_TYPE_GRAPHICS</constant>&nbsp;</entry>
5095 <entry>Graphics content. Pixel data should be passed unfiltered and without
5096 analog reconstruction.</entry>
5097 </row>
5098 <row>
5099 <entry><constant>V4L2_DV_IT_CONTENT_TYPE_PHOTO</constant>&nbsp;</entry>
5100 <entry>Photo content. The content is derived from digital still pictures.
5101 The content should be passed through with minimal scaling and picture
5102 enhancements.</entry>
5103 </row>
5104 <row>
5105 <entry><constant>V4L2_DV_IT_CONTENT_TYPE_CINEMA</constant>&nbsp;</entry>
5106 <entry>Cinema content.</entry>
5107 </row>
5108 <row>
5109 <entry><constant>V4L2_DV_IT_CONTENT_TYPE_GAME</constant>&nbsp;</entry>
5110 <entry>Game content. Audio and video latency should be minimized.</entry>
5111 </row>
5112 <row>
5113 <entry><constant>V4L2_DV_IT_CONTENT_TYPE_NO_ITC</constant>&nbsp;</entry>
5114 <entry>No IT Content information is available and the ITC bit in the AVI
5115 InfoFrame is set to 0.</entry>
5116 </row>
5117 </tbody>
5118 </entrytbl>
5119 </row>
5120 <row>
5073 <entry spanname="id"><constant>V4L2_CID_DV_RX_POWER_PRESENT</constant></entry> 5121 <entry spanname="id"><constant>V4L2_CID_DV_RX_POWER_PRESENT</constant></entry>
5074 <entry>bitmask</entry> 5122 <entry>bitmask</entry>
5075 </row> 5123 </row>
@@ -5098,6 +5146,16 @@ interface and may change in the future.</para>
5098 This control is applicable to VGA, DVI-A/D, HDMI and DisplayPort connectors. 5146 This control is applicable to VGA, DVI-A/D, HDMI and DisplayPort connectors.
5099 </entry> 5147 </entry>
5100 </row> 5148 </row>
5149 <row>
5150 <entry spanname="id"><constant>V4L2_CID_DV_RX_IT_CONTENT_TYPE</constant></entry>
5151 <entry>enum v4l2_dv_it_content_type</entry>
5152 </row>
5153 <row><entry spanname="descr">Reads the IT Content Type
5154 of the received video. This information is sent over HDMI and DisplayPort connectors
5155 as part of the AVI InfoFrame. The term 'IT Content' is used for content that originates
5156 from a computer as opposed to content from a TV broadcast or an analog source. See
5157 <constant>V4L2_CID_DV_TX_IT_CONTENT_TYPE</constant> for the available content types.</entry>
5158 </row>
5101 <row><entry></entry></row> 5159 <row><entry></entry></row>
5102 </tbody> 5160 </tbody>
5103 </tgroup> 5161 </tgroup>
diff --git a/Documentation/DocBook/media/v4l/media-ioc-g-topology.xml b/Documentation/DocBook/media/v4l/media-ioc-g-topology.xml
index 63152ab9efba..e0d49fa329f0 100644
--- a/Documentation/DocBook/media/v4l/media-ioc-g-topology.xml
+++ b/Documentation/DocBook/media/v4l/media-ioc-g-topology.xml
@@ -48,9 +48,6 @@
48 48
49 <refsect1> 49 <refsect1>
50 <title>Description</title> 50 <title>Description</title>
51
52 <para><emphasis role="bold">NOTE:</emphasis> This new ioctl is programmed to be added on Kernel 4.6. Its definition/arguments may change until its final version.</para>
53
54 <para>The typical usage of this ioctl is to call it twice. 51 <para>The typical usage of this ioctl is to call it twice.
55 On the first call, the structure defined at &media-v2-topology; should 52 On the first call, the structure defined at &media-v2-topology; should
56 be zeroed. At return, if no errors happen, this ioctl will return the 53 be zeroed. At return, if no errors happen, this ioctl will return the
diff --git a/Documentation/DocBook/media/v4l/media-types.xml b/Documentation/DocBook/media/v4l/media-types.xml
index 0ee0f3386cdf..5e3f20fdcf17 100644
--- a/Documentation/DocBook/media/v4l/media-types.xml
+++ b/Documentation/DocBook/media/v4l/media-types.xml
@@ -80,7 +80,46 @@
80 </row> 80 </row>
81 <row> 81 <row>
82 <entry><constant>MEDIA_ENT_F_TUNER</constant></entry> 82 <entry><constant>MEDIA_ENT_F_TUNER</constant></entry>
83 <entry>Digital TV, analog TV, radio and/or software radio tuner.</entry> 83 <entry>Digital TV, analog TV, radio and/or software radio tuner,
84 with consists on a PLL tuning stage that converts radio
85 frequency (RF) signal into an Intermediate Frequency (IF).
86 Modern tuners have internally IF-PLL decoders for audio
87 and video, but older models have those stages implemented
88 on separate entities.
89 </entry>
90 </row>
91 <row>
92 <entry><constant>MEDIA_ENT_F_IF_VID_DECODER</constant></entry>
93 <entry>IF-PLL video decoder. It receives the IF from a PLL
94 and decodes the analog TV video signal. This is commonly
95 found on some very old analog tuners, like Philips MK3
96 designs. They all contain a tda9887 (or some software
97 compatible similar chip, like tda9885). Those devices
98 use a different I2C address than the tuner PLL.
99 </entry>
100 </row>
101 <row>
102 <entry><constant>MEDIA_ENT_F_IF_AUD_DECODER</constant></entry>
103 <entry>IF-PLL sound decoder. It receives the IF from a PLL
104 and decodes the analog TV audio signal. This is commonly
105 found on some very old analog hardware, like Micronas
106 msp3400, Philips tda9840, tda985x, etc. Those devices
107 use a different I2C address than the tuner PLL and
108 should be controlled together with the IF-PLL video
109 decoder.
110 </entry>
111 </row>
112 <row>
113 <entry><constant>MEDIA_ENT_F_AUDIO_CAPTURE</constant></entry>
114 <entry>Audio Capture Function Entity.</entry>
115 </row>
116 <row>
117 <entry><constant>MEDIA_ENT_F_AUDIO_PLAYBACK</constant></entry>
118 <entry>Audio Playback Function Entity.</entry>
119 </row>
120 <row>
121 <entry><constant>MEDIA_ENT_F_AUDIO_MIXER</constant></entry>
122 <entry>Audio Mixer Function Entity.</entry>
84 </row> 123 </row>
85 </tbody> 124 </tbody>
86 </tgroup> 125 </tgroup>
@@ -162,6 +201,46 @@
162 <entry>Device node interface for Software Defined Radio (V4L)</entry> 201 <entry>Device node interface for Software Defined Radio (V4L)</entry>
163 <entry>typically, /dev/swradio?</entry> 202 <entry>typically, /dev/swradio?</entry>
164 </row> 203 </row>
204 <row>
205 <entry><constant>MEDIA_INTF_T_ALSA_PCM_CAPTURE</constant></entry>
206 <entry>Device node interface for ALSA PCM Capture</entry>
207 <entry>typically, /dev/snd/pcmC?D?c</entry>
208 </row>
209 <row>
210 <entry><constant>MEDIA_INTF_T_ALSA_PCM_PLAYBACK</constant></entry>
211 <entry>Device node interface for ALSA PCM Playback</entry>
212 <entry>typically, /dev/snd/pcmC?D?p</entry>
213 </row>
214 <row>
215 <entry><constant>MEDIA_INTF_T_ALSA_CONTROL</constant></entry>
216 <entry>Device node interface for ALSA Control</entry>
217 <entry>typically, /dev/snd/controlC?</entry>
218 </row>
219 <row>
220 <entry><constant>MEDIA_INTF_T_ALSA_COMPRESS</constant></entry>
221 <entry>Device node interface for ALSA Compress</entry>
222 <entry>typically, /dev/snd/compr?</entry>
223 </row>
224 <row>
225 <entry><constant>MEDIA_INTF_T_ALSA_RAWMIDI</constant></entry>
226 <entry>Device node interface for ALSA Raw MIDI</entry>
227 <entry>typically, /dev/snd/midi?</entry>
228 </row>
229 <row>
230 <entry><constant>MEDIA_INTF_T_ALSA_HWDEP</constant></entry>
231 <entry>Device node interface for ALSA Hardware Dependent</entry>
232 <entry>typically, /dev/snd/hwC?D?</entry>
233 </row>
234 <row>
235 <entry><constant>MEDIA_INTF_T_ALSA_SEQUENCER</constant></entry>
236 <entry>Device node interface for ALSA Sequencer</entry>
237 <entry>typically, /dev/snd/seq</entry>
238 </row>
239 <row>
240 <entry><constant>MEDIA_INTF_T_ALSA_TIMER</constant></entry>
241 <entry>Device node interface for ALSA Timer</entry>
242 <entry>typically, /dev/snd/timer</entry>
243 </row>
165 </tbody> 244 </tbody>
166 </tgroup> 245 </tgroup>
167 </table> 246 </table>
diff --git a/Documentation/DocBook/media/v4l/pixfmt-y12i.xml b/Documentation/DocBook/media/v4l/pixfmt-y12i.xml
new file mode 100644
index 000000000000..4a2d1e5f67e4
--- /dev/null
+++ b/Documentation/DocBook/media/v4l/pixfmt-y12i.xml
@@ -0,0 +1,49 @@
1<refentry id="V4L2-PIX-FMT-Y12I">
2 <refmeta>
3 <refentrytitle>V4L2_PIX_FMT_Y12I ('Y12I')</refentrytitle>
4 &manvol;
5 </refmeta>
6 <refnamediv>
7 <refname><constant>V4L2_PIX_FMT_Y12I</constant></refname>
8 <refpurpose>Interleaved grey-scale image, e.g. from a stereo-pair</refpurpose>
9 </refnamediv>
10 <refsect1>
11 <title>Description</title>
12
13 <para>This is a grey-scale image with a depth of 12 bits per pixel, but with
14pixels from 2 sources interleaved and bit-packed. Each pixel is stored in a
1524-bit word in the little-endian order. On a little-endian machine these pixels
16can be deinterlaced using</para>
17
18<para>
19<programlisting>
20__u8 *buf;
21left0 = 0xfff &amp; *(__u16 *)buf;
22right0 = *(__u16 *)(buf + 1) >> 4;
23</programlisting>
24</para>
25
26 <example>
27 <title><constant>V4L2_PIX_FMT_Y12I</constant> 2 pixel data stream taking 3 bytes</title>
28
29 <formalpara>
30 <title>Bit-packed representation</title>
31 <para>pixels cross the byte boundary and have a ratio of 3 bytes for each
32 interleaved pixel.
33 <informaltable frame="all">
34 <tgroup cols="3" align="center">
35 <colspec align="left" colwidth="2*" />
36 <tbody valign="top">
37 <row>
38 <entry>Y'<subscript>0left[7:0]</subscript></entry>
39 <entry>Y'<subscript>0right[3:0]</subscript>Y'<subscript>0left[11:8]</subscript></entry>
40 <entry>Y'<subscript>0right[11:4]</subscript></entry>
41 </row>
42 </tbody>
43 </tgroup>
44 </informaltable>
45 </para>
46 </formalpara>
47 </example>
48 </refsect1>
49</refentry>
diff --git a/Documentation/DocBook/media/v4l/pixfmt-y8i.xml b/Documentation/DocBook/media/v4l/pixfmt-y8i.xml
new file mode 100644
index 000000000000..99f389d4c6c8
--- /dev/null
+++ b/Documentation/DocBook/media/v4l/pixfmt-y8i.xml
@@ -0,0 +1,80 @@
1<refentry id="V4L2-PIX-FMT-Y8I">
2 <refmeta>
3 <refentrytitle>V4L2_PIX_FMT_Y8I ('Y8I ')</refentrytitle>
4 &manvol;
5 </refmeta>
6 <refnamediv>
7 <refname><constant>V4L2_PIX_FMT_Y8I</constant></refname>
8 <refpurpose>Interleaved grey-scale image, e.g. from a stereo-pair</refpurpose>
9 </refnamediv>
10 <refsect1>
11 <title>Description</title>
12
13 <para>This is a grey-scale image with a depth of 8 bits per pixel, but with
14pixels from 2 sources interleaved. Each pixel is stored in a 16-bit word. E.g.
15the R200 RealSense camera stores pixel from the left sensor in lower and from
16the right sensor in the higher 8 bits.</para>
17
18 <example>
19 <title><constant>V4L2_PIX_FMT_Y8I</constant> 4 &times; 4
20pixel image</title>
21
22 <formalpara>
23 <title>Byte Order.</title>
24 <para>Each cell is one byte.
25 <informaltable frame="none">
26 <tgroup cols="9" align="center">
27 <colspec align="left" colwidth="2*" />
28 <tbody valign="top">
29 <row>
30 <entry>start&nbsp;+&nbsp;0:</entry>
31 <entry>Y'<subscript>00left</subscript></entry>
32 <entry>Y'<subscript>00right</subscript></entry>
33 <entry>Y'<subscript>01left</subscript></entry>
34 <entry>Y'<subscript>01right</subscript></entry>
35 <entry>Y'<subscript>02left</subscript></entry>
36 <entry>Y'<subscript>02right</subscript></entry>
37 <entry>Y'<subscript>03left</subscript></entry>
38 <entry>Y'<subscript>03right</subscript></entry>
39 </row>
40 <row>
41 <entry>start&nbsp;+&nbsp;8:</entry>
42 <entry>Y'<subscript>10left</subscript></entry>
43 <entry>Y'<subscript>10right</subscript></entry>
44 <entry>Y'<subscript>11left</subscript></entry>
45 <entry>Y'<subscript>11right</subscript></entry>
46 <entry>Y'<subscript>12left</subscript></entry>
47 <entry>Y'<subscript>12right</subscript></entry>
48 <entry>Y'<subscript>13left</subscript></entry>
49 <entry>Y'<subscript>13right</subscript></entry>
50 </row>
51 <row>
52 <entry>start&nbsp;+&nbsp;16:</entry>
53 <entry>Y'<subscript>20left</subscript></entry>
54 <entry>Y'<subscript>20right</subscript></entry>
55 <entry>Y'<subscript>21left</subscript></entry>
56 <entry>Y'<subscript>21right</subscript></entry>
57 <entry>Y'<subscript>22left</subscript></entry>
58 <entry>Y'<subscript>22right</subscript></entry>
59 <entry>Y'<subscript>23left</subscript></entry>
60 <entry>Y'<subscript>23right</subscript></entry>
61 </row>
62 <row>
63 <entry>start&nbsp;+&nbsp;24:</entry>
64 <entry>Y'<subscript>30left</subscript></entry>
65 <entry>Y'<subscript>30right</subscript></entry>
66 <entry>Y'<subscript>31left</subscript></entry>
67 <entry>Y'<subscript>31right</subscript></entry>
68 <entry>Y'<subscript>32left</subscript></entry>
69 <entry>Y'<subscript>32right</subscript></entry>
70 <entry>Y'<subscript>33left</subscript></entry>
71 <entry>Y'<subscript>33right</subscript></entry>
72 </row>
73 </tbody>
74 </tgroup>
75 </informaltable>
76 </para>
77 </formalpara>
78 </example>
79 </refsect1>
80</refentry>
diff --git a/Documentation/DocBook/media/v4l/pixfmt-yuv420m.xml b/Documentation/DocBook/media/v4l/pixfmt-yuv420m.xml
index e781cc61786c..7d13fe96657d 100644
--- a/Documentation/DocBook/media/v4l/pixfmt-yuv420m.xml
+++ b/Documentation/DocBook/media/v4l/pixfmt-yuv420m.xml
@@ -1,35 +1,43 @@
1 <refentry id="V4L2-PIX-FMT-YUV420M"> 1 <refentry>
2 <refmeta> 2 <refmeta>
3 <refentrytitle>V4L2_PIX_FMT_YUV420M ('YM12')</refentrytitle> 3 <refentrytitle>V4L2_PIX_FMT_YUV420M ('YM12'), V4L2_PIX_FMT_YVU420M ('YM21')</refentrytitle>
4 &manvol; 4 &manvol;
5 </refmeta> 5 </refmeta>
6 <refnamediv> 6 <refnamediv>
7 <refname> <constant>V4L2_PIX_FMT_YUV420M</constant></refname> 7 <refname id="V4L2-PIX-FMT-YUV420M"><constant>V4L2_PIX_FMT_YUV420M</constant></refname>
8 <refpurpose>Variation of <constant>V4L2_PIX_FMT_YUV420</constant> 8 <refname id="V4L2-PIX-FMT-YVU420M"><constant>V4L2_PIX_FMT_YVU420M</constant></refname>
9 with planes non contiguous in memory. </refpurpose> 9 <refpurpose>Variation of <constant>V4L2_PIX_FMT_YUV420</constant> and
10 <constant>V4L2_PIX_FMT_YVU420</constant> with planes non contiguous
11 in memory.</refpurpose>
10 </refnamediv> 12 </refnamediv>
11 13
12 <refsect1> 14 <refsect1>
13 <title>Description</title> 15 <title>Description</title>
14 16
15 <para>This is a multi-planar format, as opposed to a packed format. 17 <para>This is a multi-planar format, as opposed to a packed format.
16The three components are separated into three sub- images or planes. 18The three components are separated into three sub-images or planes.</para>
17 19
18The Y plane is first. The Y plane has one byte per pixel. The Cb data 20 <para>The Y plane is first. The Y plane has one byte per pixel.
21For <constant>V4L2_PIX_FMT_YUV420M</constant> the Cb data
19constitutes the second plane which is half the width and half 22constitutes the second plane which is half the width and half
20the height of the Y plane (and of the image). Each Cb belongs to four 23the height of the Y plane (and of the image). Each Cb belongs to four
21pixels, a two-by-two square of the image. For example, 24pixels, a two-by-two square of the image. For example,
22Cb<subscript>0</subscript> belongs to Y'<subscript>00</subscript>, 25Cb<subscript>0</subscript> belongs to Y'<subscript>00</subscript>,
23Y'<subscript>01</subscript>, Y'<subscript>10</subscript>, and 26Y'<subscript>01</subscript>, Y'<subscript>10</subscript>, and
24Y'<subscript>11</subscript>. The Cr data, just like the Cb plane, is 27Y'<subscript>11</subscript>. The Cr data, just like the Cb plane, is
25in the third plane. </para> 28in the third plane.</para>
29
30 <para><constant>V4L2_PIX_FMT_YVU420M</constant> is the same except
31the Cr data is stored in the second plane and the Cb data in the third plane.
32</para>
26 33
27 <para>If the Y plane has pad bytes after each row, then the Cb 34 <para>If the Y plane has pad bytes after each row, then the Cb
28and Cr planes have half as many pad bytes after their rows. In other 35and Cr planes have half as many pad bytes after their rows. In other
29words, two Cx rows (including padding) is exactly as long as one Y row 36words, two Cx rows (including padding) is exactly as long as one Y row
30(including padding).</para> 37(including padding).</para>
31 38
32 <para><constant>V4L2_PIX_FMT_YUV420M</constant> is intended to be 39 <para><constant>V4L2_PIX_FMT_YUV420M</constant> and
40<constant>V4L2_PIX_FMT_YVU420M</constant> are intended to be
33used only in drivers and applications that support the multi-planar API, 41used only in drivers and applications that support the multi-planar API,
34described in <xref linkend="planar-apis"/>. </para> 42described in <xref linkend="planar-apis"/>. </para>
35 43
diff --git a/Documentation/DocBook/media/v4l/pixfmt-yvu420m.xml b/Documentation/DocBook/media/v4l/pixfmt-yuv422m.xml
index 2330667907c7..dd502802cb75 100644
--- a/Documentation/DocBook/media/v4l/pixfmt-yvu420m.xml
+++ b/Documentation/DocBook/media/v4l/pixfmt-yuv422m.xml
@@ -1,40 +1,45 @@
1 <refentry id="V4L2-PIX-FMT-YVU420M"> 1 <refentry>
2 <refmeta> 2 <refmeta>
3 <refentrytitle>V4L2_PIX_FMT_YVU420M ('YM21')</refentrytitle> 3 <refentrytitle>V4L2_PIX_FMT_YUV422M ('YM16'), V4L2_PIX_FMT_YVU422M ('YM61')</refentrytitle>
4 &manvol; 4 &manvol;
5 </refmeta> 5 </refmeta>
6 <refnamediv> 6 <refnamediv>
7 <refname> <constant>V4L2_PIX_FMT_YVU420M</constant></refname> 7 <refname id="V4L2-PIX-FMT-YUV422M"><constant>V4L2_PIX_FMT_YUV422M</constant></refname>
8 <refpurpose>Variation of <constant>V4L2_PIX_FMT_YVU420</constant> 8 <refname id="V4L2-PIX-FMT-YVU422M"><constant>V4L2_PIX_FMT_YVU422M</constant></refname>
9 with planes non contiguous in memory. </refpurpose> 9 <refpurpose>Planar formats with &frac12; horizontal resolution, also
10 known as YUV and YVU 4:2:2</refpurpose>
10 </refnamediv> 11 </refnamediv>
11 12
12 <refsect1> 13 <refsect1>
13 <title>Description</title> 14 <title>Description</title>
14 15
15 <para>This is a multi-planar format, as opposed to a packed format. 16 <para>This is a multi-planar format, as opposed to a packed format.
16The three components are separated into three sub-images or planes. 17The three components are separated into three sub-images or planes.</para>
17 18
18The Y plane is first. The Y plane has one byte per pixel. The Cr data 19 <para>The Y plane is first. The Y plane has one byte per pixel.
19constitutes the second plane which is half the width and half 20For <constant>V4L2_PIX_FMT_YUV422M</constant> the Cb data
20the height of the Y plane (and of the image). Each Cr belongs to four 21constitutes the second plane which is half the width of the Y plane (and of the
21pixels, a two-by-two square of the image. For example, 22image). Each Cb belongs to two pixels. For example,
22Cr<subscript>0</subscript> belongs to Y'<subscript>00</subscript>, 23Cb<subscript>0</subscript> belongs to Y'<subscript>00</subscript>,
23Y'<subscript>01</subscript>, Y'<subscript>10</subscript>, and 24Y'<subscript>01</subscript>. The Cr data, just like the Cb plane, is
24Y'<subscript>11</subscript>. The Cb data, just like the Cr plane, constitutes 25in the third plane. </para>
25the third plane. </para>
26 26
27 <para>If the Y plane has pad bytes after each row, then the Cr 27 <para><constant>V4L2_PIX_FMT_YVU422M</constant> is the same except
28and Cb planes have half as many pad bytes after their rows. In other 28the Cr data is stored in the second plane and the Cb data in the third plane.
29</para>
30
31 <para>If the Y plane has pad bytes after each row, then the Cb
32and Cr planes have half as many pad bytes after their rows. In other
29words, two Cx rows (including padding) is exactly as long as one Y row 33words, two Cx rows (including padding) is exactly as long as one Y row
30(including padding).</para> 34(including padding).</para>
31 35
32 <para><constant>V4L2_PIX_FMT_YVU420M</constant> is intended to be 36 <para><constant>V4L2_PIX_FMT_YUV422M</constant> and
37<constant>V4L2_PIX_FMT_YVU422M</constant> are intended to be
33used only in drivers and applications that support the multi-planar API, 38used only in drivers and applications that support the multi-planar API,
34described in <xref linkend="planar-apis"/>. </para> 39described in <xref linkend="planar-apis"/>. </para>
35 40
36 <example> 41 <example>
37 <title><constant>V4L2_PIX_FMT_YVU420M</constant> 4 &times; 4 42 <title><constant>V4L2_PIX_FMT_YUV422M</constant> 4 &times; 4
38pixel image</title> 43pixel image</title>
39 44
40 <formalpara> 45 <formalpara>
@@ -75,24 +80,44 @@ pixel image</title>
75 <row><entry></entry></row> 80 <row><entry></entry></row>
76 <row> 81 <row>
77 <entry>start1&nbsp;+&nbsp;0:</entry> 82 <entry>start1&nbsp;+&nbsp;0:</entry>
78 <entry>Cr<subscript>00</subscript></entry> 83 <entry>Cb<subscript>00</subscript></entry>
79 <entry>Cr<subscript>01</subscript></entry> 84 <entry>Cb<subscript>01</subscript></entry>
80 </row> 85 </row>
81 <row> 86 <row>
82 <entry>start1&nbsp;+&nbsp;2:</entry> 87 <entry>start1&nbsp;+&nbsp;2:</entry>
83 <entry>Cr<subscript>10</subscript></entry> 88 <entry>Cb<subscript>10</subscript></entry>
84 <entry>Cr<subscript>11</subscript></entry> 89 <entry>Cb<subscript>11</subscript></entry>
90 </row>
91 <row>
92 <entry>start1&nbsp;+&nbsp;4:</entry>
93 <entry>Cb<subscript>20</subscript></entry>
94 <entry>Cb<subscript>21</subscript></entry>
95 </row>
96 <row>
97 <entry>start1&nbsp;+&nbsp;6:</entry>
98 <entry>Cb<subscript>30</subscript></entry>
99 <entry>Cb<subscript>31</subscript></entry>
85 </row> 100 </row>
86 <row><entry></entry></row> 101 <row><entry></entry></row>
87 <row> 102 <row>
88 <entry>start2&nbsp;+&nbsp;0:</entry> 103 <entry>start2&nbsp;+&nbsp;0:</entry>
89 <entry>Cb<subscript>00</subscript></entry> 104 <entry>Cr<subscript>00</subscript></entry>
90 <entry>Cb<subscript>01</subscript></entry> 105 <entry>Cr<subscript>01</subscript></entry>
91 </row> 106 </row>
92 <row> 107 <row>
93 <entry>start2&nbsp;+&nbsp;2:</entry> 108 <entry>start2&nbsp;+&nbsp;2:</entry>
94 <entry>Cb<subscript>10</subscript></entry> 109 <entry>Cr<subscript>10</subscript></entry>
95 <entry>Cb<subscript>11</subscript></entry> 110 <entry>Cr<subscript>11</subscript></entry>
111 </row>
112 <row>
113 <entry>start2&nbsp;+&nbsp;4:</entry>
114 <entry>Cr<subscript>20</subscript></entry>
115 <entry>Cr<subscript>21</subscript></entry>
116 </row>
117 <row>
118 <entry>start2&nbsp;+&nbsp;6:</entry>
119 <entry>Cr<subscript>30</subscript></entry>
120 <entry>Cr<subscript>31</subscript></entry>
96 </row> 121 </row>
97 </tbody> 122 </tbody>
98 </tgroup> 123 </tgroup>
@@ -113,36 +138,23 @@ pixel image</title>
113 </row> 138 </row>
114 <row> 139 <row>
115 <entry>0</entry> 140 <entry>0</entry>
116 <entry>Y</entry><entry></entry><entry>Y</entry><entry></entry> 141 <entry>Y</entry><entry>C</entry><entry>Y</entry><entry></entry>
117 <entry>Y</entry><entry></entry><entry>Y</entry> 142 <entry>Y</entry><entry>C</entry><entry>Y</entry>
118 </row>
119 <row>
120 <entry></entry>
121 <entry></entry><entry>C</entry><entry></entry><entry></entry>
122 <entry></entry><entry>C</entry><entry></entry>
123 </row> 143 </row>
124 <row> 144 <row>
125 <entry>1</entry> 145 <entry>1</entry>
126 <entry>Y</entry><entry></entry><entry>Y</entry><entry></entry> 146 <entry>Y</entry><entry>C</entry><entry>Y</entry><entry></entry>
127 <entry>Y</entry><entry></entry><entry>Y</entry> 147 <entry>Y</entry><entry>C</entry><entry>Y</entry>
128 </row>
129 <row>
130 <entry></entry>
131 </row> 148 </row>
132 <row> 149 <row>
133 <entry>2</entry> 150 <entry>2</entry>
134 <entry>Y</entry><entry></entry><entry>Y</entry><entry></entry> 151 <entry>Y</entry><entry>C</entry><entry>Y</entry><entry></entry>
135 <entry>Y</entry><entry></entry><entry>Y</entry> 152 <entry>Y</entry><entry>C</entry><entry>Y</entry>
136 </row>
137 <row>
138 <entry></entry>
139 <entry></entry><entry>C</entry><entry></entry><entry></entry>
140 <entry></entry><entry>C</entry><entry></entry>
141 </row> 153 </row>
142 <row> 154 <row>
143 <entry>3</entry> 155 <entry>3</entry>
144 <entry>Y</entry><entry></entry><entry>Y</entry><entry></entry> 156 <entry>Y</entry><entry>C</entry><entry>Y</entry><entry></entry>
145 <entry>Y</entry><entry></entry><entry>Y</entry> 157 <entry>Y</entry><entry>C</entry><entry>Y</entry>
146 </row> 158 </row>
147 </tbody> 159 </tbody>
148 </tgroup> 160 </tgroup>
diff --git a/Documentation/DocBook/media/v4l/pixfmt-yuv444m.xml b/Documentation/DocBook/media/v4l/pixfmt-yuv444m.xml
new file mode 100644
index 000000000000..1b7335940bc7
--- /dev/null
+++ b/Documentation/DocBook/media/v4l/pixfmt-yuv444m.xml
@@ -0,0 +1,177 @@
1 <refentry>
2 <refmeta>
3 <refentrytitle>V4L2_PIX_FMT_YUV444M ('YM24'), V4L2_PIX_FMT_YVU444M ('YM42')</refentrytitle>
4 &manvol;
5 </refmeta>
6 <refnamediv>
7 <refname id="V4L2-PIX-FMT-YUV444M"><constant>V4L2_PIX_FMT_YUV444M</constant></refname>
8 <refname id="V4L2-PIX-FMT-YVU444M"><constant>V4L2_PIX_FMT_YVU444M</constant></refname>
9 <refpurpose>Planar formats with full horizontal resolution, also
10 known as YUV and YVU 4:4:4</refpurpose>
11 </refnamediv>
12
13 <refsect1>
14 <title>Description</title>
15
16 <para>This is a multi-planar format, as opposed to a packed format.
17The three components are separated into three sub-images or planes.</para>
18
19 <para>The Y plane is first. The Y plane has one byte per pixel.
20For <constant>V4L2_PIX_FMT_YUV444M</constant> the Cb data
21constitutes the second plane which is the same width and height as the Y plane
22(and as the image). The Cr data, just like the Cb plane, is in the third plane.
23</para>
24
25 <para><constant>V4L2_PIX_FMT_YVU444M</constant> is the same except
26the Cr data is stored in the second plane and the Cb data in the third plane.
27</para>
28 <para>If the Y plane has pad bytes after each row, then the Cb
29and Cr planes have the same number of pad bytes after their rows.</para>
30
31 <para><constant>V4L2_PIX_FMT_YUV444M</constant> and
32<constant>V4L2_PIX_FMT_YUV444M</constant> are intended to be
33used only in drivers and applications that support the multi-planar API,
34described in <xref linkend="planar-apis"/>. </para>
35
36 <example>
37 <title><constant>V4L2_PIX_FMT_YUV444M</constant> 4 &times; 4
38pixel image</title>
39
40 <formalpara>
41 <title>Byte Order.</title>
42 <para>Each cell is one byte.
43 <informaltable frame="none">
44 <tgroup cols="5" align="center">
45 <colspec align="left" colwidth="2*" />
46 <tbody valign="top">
47 <row>
48 <entry>start0&nbsp;+&nbsp;0:</entry>
49 <entry>Y'<subscript>00</subscript></entry>
50 <entry>Y'<subscript>01</subscript></entry>
51 <entry>Y'<subscript>02</subscript></entry>
52 <entry>Y'<subscript>03</subscript></entry>
53 </row>
54 <row>
55 <entry>start0&nbsp;+&nbsp;4:</entry>
56 <entry>Y'<subscript>10</subscript></entry>
57 <entry>Y'<subscript>11</subscript></entry>
58 <entry>Y'<subscript>12</subscript></entry>
59 <entry>Y'<subscript>13</subscript></entry>
60 </row>
61 <row>
62 <entry>start0&nbsp;+&nbsp;8:</entry>
63 <entry>Y'<subscript>20</subscript></entry>
64 <entry>Y'<subscript>21</subscript></entry>
65 <entry>Y'<subscript>22</subscript></entry>
66 <entry>Y'<subscript>23</subscript></entry>
67 </row>
68 <row>
69 <entry>start0&nbsp;+&nbsp;12:</entry>
70 <entry>Y'<subscript>30</subscript></entry>
71 <entry>Y'<subscript>31</subscript></entry>
72 <entry>Y'<subscript>32</subscript></entry>
73 <entry>Y'<subscript>33</subscript></entry>
74 </row>
75 <row><entry></entry></row>
76 <row>
77 <entry>start1&nbsp;+&nbsp;0:</entry>
78 <entry>Cb<subscript>00</subscript></entry>
79 <entry>Cb<subscript>01</subscript></entry>
80 <entry>Cb<subscript>02</subscript></entry>
81 <entry>Cb<subscript>03</subscript></entry>
82 </row>
83 <row>
84 <entry>start1&nbsp;+&nbsp;4:</entry>
85 <entry>Cb<subscript>10</subscript></entry>
86 <entry>Cb<subscript>11</subscript></entry>
87 <entry>Cb<subscript>12</subscript></entry>
88 <entry>Cb<subscript>13</subscript></entry>
89 </row>
90 <row>
91 <entry>start1&nbsp;+&nbsp;8:</entry>
92 <entry>Cb<subscript>20</subscript></entry>
93 <entry>Cb<subscript>21</subscript></entry>
94 <entry>Cb<subscript>22</subscript></entry>
95 <entry>Cb<subscript>23</subscript></entry>
96 </row>
97 <row>
98 <entry>start1&nbsp;+&nbsp;12:</entry>
99 <entry>Cb<subscript>20</subscript></entry>
100 <entry>Cb<subscript>21</subscript></entry>
101 <entry>Cb<subscript>32</subscript></entry>
102 <entry>Cb<subscript>33</subscript></entry>
103 </row>
104 <row><entry></entry></row>
105 <row>
106 <entry>start2&nbsp;+&nbsp;0:</entry>
107 <entry>Cr<subscript>00</subscript></entry>
108 <entry>Cr<subscript>01</subscript></entry>
109 <entry>Cr<subscript>02</subscript></entry>
110 <entry>Cr<subscript>03</subscript></entry>
111 </row>
112 <row>
113 <entry>start2&nbsp;+&nbsp;4:</entry>
114 <entry>Cr<subscript>10</subscript></entry>
115 <entry>Cr<subscript>11</subscript></entry>
116 <entry>Cr<subscript>12</subscript></entry>
117 <entry>Cr<subscript>13</subscript></entry>
118 </row>
119 <row>
120 <entry>start2&nbsp;+&nbsp;8:</entry>
121 <entry>Cr<subscript>20</subscript></entry>
122 <entry>Cr<subscript>21</subscript></entry>
123 <entry>Cr<subscript>22</subscript></entry>
124 <entry>Cr<subscript>23</subscript></entry>
125 </row>
126 <row>
127 <entry>start2&nbsp;+&nbsp;12:</entry>
128 <entry>Cr<subscript>30</subscript></entry>
129 <entry>Cr<subscript>31</subscript></entry>
130 <entry>Cr<subscript>32</subscript></entry>
131 <entry>Cr<subscript>33</subscript></entry>
132 </row>
133 </tbody>
134 </tgroup>
135 </informaltable>
136 </para>
137 </formalpara>
138
139 <formalpara>
140 <title>Color Sample Location.</title>
141 <para>
142 <informaltable frame="none">
143 <tgroup cols="7" align="center">
144 <tbody valign="top">
145 <row>
146 <entry></entry>
147 <entry>0</entry><entry></entry><entry>1</entry><entry></entry>
148 <entry>2</entry><entry></entry><entry>3</entry>
149 </row>
150 <row>
151 <entry>0</entry>
152 <entry>YC</entry><entry></entry><entry>YC</entry><entry></entry>
153 <entry>YC</entry><entry></entry><entry>YC</entry>
154 </row>
155 <row>
156 <entry>1</entry>
157 <entry>YC</entry><entry></entry><entry>YC</entry><entry></entry>
158 <entry>YC</entry><entry></entry><entry>YC</entry>
159 </row>
160 <row>
161 <entry>2</entry>
162 <entry>YC</entry><entry></entry><entry>YC</entry><entry></entry>
163 <entry>YC</entry><entry></entry><entry>YC</entry>
164 </row>
165 <row>
166 <entry>3</entry>
167 <entry>YC</entry><entry></entry><entry>YC</entry><entry></entry>
168 <entry>YC</entry><entry></entry><entry>YC</entry>
169 </row>
170 </tbody>
171 </tgroup>
172 </informaltable>
173 </para>
174 </formalpara>
175 </example>
176 </refsect1>
177 </refentry>
diff --git a/Documentation/DocBook/media/v4l/pixfmt-z16.xml b/Documentation/DocBook/media/v4l/pixfmt-z16.xml
new file mode 100644
index 000000000000..3d87e4bf87b8
--- /dev/null
+++ b/Documentation/DocBook/media/v4l/pixfmt-z16.xml
@@ -0,0 +1,81 @@
1<refentry id="V4L2-PIX-FMT-Z16">
2 <refmeta>
3 <refentrytitle>V4L2_PIX_FMT_Z16 ('Z16 ')</refentrytitle>
4 &manvol;
5 </refmeta>
6 <refnamediv>
7 <refname><constant>V4L2_PIX_FMT_Z16</constant></refname>
8 <refpurpose>Interleaved grey-scale image, e.g. from a stereo-pair</refpurpose>
9 </refnamediv>
10 <refsect1>
11 <title>Description</title>
12
13 <para>This is a 16-bit format, representing depth data. Each pixel is a
14distance to the respective point in the image coordinates. Distance unit can
15vary and has to be negotiated with the device separately. Each pixel is stored
16in a 16-bit word in the little endian byte order.
17</para>
18
19 <example>
20 <title><constant>V4L2_PIX_FMT_Z16</constant> 4 &times; 4
21pixel image</title>
22
23 <formalpara>
24 <title>Byte Order.</title>
25 <para>Each cell is one byte.
26 <informaltable frame="none">
27 <tgroup cols="9" align="center">
28 <colspec align="left" colwidth="2*" />
29 <tbody valign="top">
30 <row>
31 <entry>start&nbsp;+&nbsp;0:</entry>
32 <entry>Z<subscript>00low</subscript></entry>
33 <entry>Z<subscript>00high</subscript></entry>
34 <entry>Z<subscript>01low</subscript></entry>
35 <entry>Z<subscript>01high</subscript></entry>
36 <entry>Z<subscript>02low</subscript></entry>
37 <entry>Z<subscript>02high</subscript></entry>
38 <entry>Z<subscript>03low</subscript></entry>
39 <entry>Z<subscript>03high</subscript></entry>
40 </row>
41 <row>
42 <entry>start&nbsp;+&nbsp;8:</entry>
43 <entry>Z<subscript>10low</subscript></entry>
44 <entry>Z<subscript>10high</subscript></entry>
45 <entry>Z<subscript>11low</subscript></entry>
46 <entry>Z<subscript>11high</subscript></entry>
47 <entry>Z<subscript>12low</subscript></entry>
48 <entry>Z<subscript>12high</subscript></entry>
49 <entry>Z<subscript>13low</subscript></entry>
50 <entry>Z<subscript>13high</subscript></entry>
51 </row>
52 <row>
53 <entry>start&nbsp;+&nbsp;16:</entry>
54 <entry>Z<subscript>20low</subscript></entry>
55 <entry>Z<subscript>20high</subscript></entry>
56 <entry>Z<subscript>21low</subscript></entry>
57 <entry>Z<subscript>21high</subscript></entry>
58 <entry>Z<subscript>22low</subscript></entry>
59 <entry>Z<subscript>22high</subscript></entry>
60 <entry>Z<subscript>23low</subscript></entry>
61 <entry>Z<subscript>23high</subscript></entry>
62 </row>
63 <row>
64 <entry>start&nbsp;+&nbsp;24:</entry>
65 <entry>Z<subscript>30low</subscript></entry>
66 <entry>Z<subscript>30high</subscript></entry>
67 <entry>Z<subscript>31low</subscript></entry>
68 <entry>Z<subscript>31high</subscript></entry>
69 <entry>Z<subscript>32low</subscript></entry>
70 <entry>Z<subscript>32high</subscript></entry>
71 <entry>Z<subscript>33low</subscript></entry>
72 <entry>Z<subscript>33high</subscript></entry>
73 </row>
74 </tbody>
75 </tgroup>
76 </informaltable>
77 </para>
78 </formalpara>
79 </example>
80 </refsect1>
81</refentry>
diff --git a/Documentation/DocBook/media/v4l/pixfmt.xml b/Documentation/DocBook/media/v4l/pixfmt.xml
index d871245d2973..5a08aeea4360 100644
--- a/Documentation/DocBook/media/v4l/pixfmt.xml
+++ b/Documentation/DocBook/media/v4l/pixfmt.xml
@@ -1620,6 +1620,8 @@ information.</para>
1620 &sub-y10b; 1620 &sub-y10b;
1621 &sub-y16; 1621 &sub-y16;
1622 &sub-y16-be; 1622 &sub-y16-be;
1623 &sub-y8i;
1624 &sub-y12i;
1623 &sub-uv8; 1625 &sub-uv8;
1624 &sub-yuyv; 1626 &sub-yuyv;
1625 &sub-uyvy; 1627 &sub-uyvy;
@@ -1628,7 +1630,8 @@ information.</para>
1628 &sub-y41p; 1630 &sub-y41p;
1629 &sub-yuv420; 1631 &sub-yuv420;
1630 &sub-yuv420m; 1632 &sub-yuv420m;
1631 &sub-yvu420m; 1633 &sub-yuv422m;
1634 &sub-yuv444m;
1632 &sub-yuv410; 1635 &sub-yuv410;
1633 &sub-yuv422p; 1636 &sub-yuv422p;
1634 &sub-yuv411p; 1637 &sub-yuv411p;
@@ -1641,6 +1644,14 @@ information.</para>
1641 &sub-m420; 1644 &sub-m420;
1642 </section> 1645 </section>
1643 1646
1647 <section id="depth-formats">
1648 <title>Depth Formats</title>
1649 <para>Depth data provides distance to points, mapped onto the image plane
1650 </para>
1651
1652 &sub-z16;
1653 </section>
1654
1644 <section> 1655 <section>
1645 <title>Compressed Formats</title> 1656 <title>Compressed Formats</title>
1646 1657
diff --git a/Documentation/DocBook/media/v4l/vidioc-query-dv-timings.xml b/Documentation/DocBook/media/v4l/vidioc-query-dv-timings.xml
index e9c70a8f3476..0c93677d16b4 100644
--- a/Documentation/DocBook/media/v4l/vidioc-query-dv-timings.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-query-dv-timings.xml
@@ -60,9 +60,19 @@ input</refpurpose>
60automatically, similar to sensing the video standard. To do so, applications 60automatically, similar to sensing the video standard. To do so, applications
61call <constant>VIDIOC_QUERY_DV_TIMINGS</constant> with a pointer to a 61call <constant>VIDIOC_QUERY_DV_TIMINGS</constant> with a pointer to a
62&v4l2-dv-timings;. Once the hardware detects the timings, it will fill in the 62&v4l2-dv-timings;. Once the hardware detects the timings, it will fill in the
63timings structure. 63timings structure.</para>
64 64
65If the timings could not be detected because there was no signal, then 65<para>Please note that drivers shall <emphasis>not</emphasis> switch timings automatically
66if new timings are detected. Instead, drivers should send the
67<constant>V4L2_EVENT_SOURCE_CHANGE</constant> event (if they support this) and expect
68that userspace will take action by calling <constant>VIDIOC_QUERY_DV_TIMINGS</constant>.
69The reason is that new timings usually mean different buffer sizes as well, and you
70cannot change buffer sizes on the fly. In general, applications that receive the
71Source Change event will have to call <constant>VIDIOC_QUERY_DV_TIMINGS</constant>,
72and if the detected timings are valid they will have to stop streaming, set the new
73timings, allocate new buffers and start streaming again.</para>
74
75<para>If the timings could not be detected because there was no signal, then
66<errorcode>ENOLINK</errorcode> is returned. If a signal was detected, but 76<errorcode>ENOLINK</errorcode> is returned. If a signal was detected, but
67it was unstable and the receiver could not lock to the signal, then 77it was unstable and the receiver could not lock to the signal, then
68<errorcode>ENOLCK</errorcode> is returned. If the receiver could lock to the signal, 78<errorcode>ENOLCK</errorcode> is returned. If the receiver could lock to the signal,
diff --git a/Documentation/DocBook/media/v4l/vidioc-querystd.xml b/Documentation/DocBook/media/v4l/vidioc-querystd.xml
index 222348542182..3ceae35fab03 100644
--- a/Documentation/DocBook/media/v4l/vidioc-querystd.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-querystd.xml
@@ -59,6 +59,16 @@ then the driver will return V4L2_STD_UNKNOWN. When detection is not
59possible or fails, the set must contain all standards supported by the 59possible or fails, the set must contain all standards supported by the
60current video input or output.</para> 60current video input or output.</para>
61 61
62<para>Please note that drivers shall <emphasis>not</emphasis> switch the video standard
63automatically if a new video standard is detected. Instead, drivers should send the
64<constant>V4L2_EVENT_SOURCE_CHANGE</constant> event (if they support this) and expect
65that userspace will take action by calling <constant>VIDIOC_QUERYSTD</constant>.
66The reason is that a new video standard can mean different buffer sizes as well, and you
67cannot change buffer sizes on the fly. In general, applications that receive the
68Source Change event will have to call <constant>VIDIOC_QUERYSTD</constant>,
69and if the detected video standard is valid they will have to stop streaming, set the new
70standard, allocate new buffers and start streaming again.</para>
71
62 </refsect1> 72 </refsect1>
63 73
64 <refsect1> 74 <refsect1>
diff --git a/Documentation/devicetree/bindings/media/i2c/mt9v032.txt b/Documentation/devicetree/bindings/media/i2c/mt9v032.txt
index 202565313e82..100f0ae43269 100644
--- a/Documentation/devicetree/bindings/media/i2c/mt9v032.txt
+++ b/Documentation/devicetree/bindings/media/i2c/mt9v032.txt
@@ -20,6 +20,8 @@ Optional Properties:
20 20
21- link-frequencies: List of allowed link frequencies in Hz. Each frequency is 21- link-frequencies: List of allowed link frequencies in Hz. Each frequency is
22 expressed as a 64-bit big-endian integer. 22 expressed as a 64-bit big-endian integer.
23- reset-gpios: GPIO handle which is connected to the reset pin of the chip.
24- standby-gpios: GPIO handle which is connected to the standby pin of the chip.
23 25
24For further reading on port node refer to 26For further reading on port node refer to
25Documentation/devicetree/bindings/media/video-interfaces.txt. 27Documentation/devicetree/bindings/media/video-interfaces.txt.
diff --git a/Documentation/devicetree/bindings/media/i2c/tvp5150.txt b/Documentation/devicetree/bindings/media/i2c/tvp5150.txt
new file mode 100644
index 000000000000..8c0fc1a26bf0
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/tvp5150.txt
@@ -0,0 +1,45 @@
1* Texas Instruments TVP5150 and TVP5151 video decoders
2
3The TVP5150 and TVP5151 are video decoders that convert baseband NTSC and PAL
4(and also SECAM in the TVP5151 case) video signals to either 8-bit 4:2:2 YUV
5with discrete syncs or 8-bit ITU-R BT.656 with embedded syncs output formats.
6
7Required Properties:
8- compatible: value must be "ti,tvp5150"
9- reg: I2C slave address
10
11Optional Properties:
12- pdn-gpios: phandle for the GPIO connected to the PDN pin, if any.
13- reset-gpios: phandle for the GPIO connected to the RESETB pin, if any.
14
15The device node must contain one 'port' child node for its digital output
16video port, in accordance with the video interface bindings defined in
17Documentation/devicetree/bindings/media/video-interfaces.txt.
18
19Required Endpoint Properties for parallel synchronization:
20
21- hsync-active: active state of the HSYNC signal. Must be <1> (HIGH).
22- vsync-active: active state of the VSYNC signal. Must be <1> (HIGH).
23- field-even-active: field signal level during the even field data
24 transmission. Must be <0>.
25
26If none of hsync-active, vsync-active and field-even-active is specified,
27the endpoint is assumed to use embedded BT.656 synchronization.
28
29Example:
30
31&i2c2 {
32 ...
33 tvp5150@5c {
34 compatible = "ti,tvp5150";
35 reg = <0x5c>;
36 pdn-gpios = <&gpio4 30 GPIO_ACTIVE_LOW>;
37 reset-gpios = <&gpio6 7 GPIO_ACTIVE_LOW>;
38
39 port {
40 tvp5150_1: endpoint {
41 remote-endpoint = <&ccdc_ep>;
42 };
43 };
44 };
45};
diff --git a/Documentation/devicetree/bindings/media/rcar_vin.txt b/Documentation/devicetree/bindings/media/rcar_vin.txt
index 9dafe6b06cd2..619193ccf7ff 100644
--- a/Documentation/devicetree/bindings/media/rcar_vin.txt
+++ b/Documentation/devicetree/bindings/media/rcar_vin.txt
@@ -6,6 +6,7 @@ family of devices. The current blocks are always slaves and suppot one input
6channel which can be either RGB, YUYV or BT656. 6channel which can be either RGB, YUYV or BT656.
7 7
8 - compatible: Must be one of the following 8 - compatible: Must be one of the following
9 - "renesas,vin-r8a7795" for the R8A7795 device
9 - "renesas,vin-r8a7794" for the R8A7794 device 10 - "renesas,vin-r8a7794" for the R8A7794 device
10 - "renesas,vin-r8a7793" for the R8A7793 device 11 - "renesas,vin-r8a7793" for the R8A7793 device
11 - "renesas,vin-r8a7791" for the R8A7791 device 12 - "renesas,vin-r8a7791" for the R8A7791 device
diff --git a/Documentation/devicetree/bindings/media/renesas,jpu.txt b/Documentation/devicetree/bindings/media/renesas,jpu.txt
index 0cb94201bf92..d3436e5190f9 100644
--- a/Documentation/devicetree/bindings/media/renesas,jpu.txt
+++ b/Documentation/devicetree/bindings/media/renesas,jpu.txt
@@ -5,11 +5,12 @@ and decoding function conforming to the JPEG baseline process, so that the JPU
5can encode image data and decode JPEG data quickly. 5can encode image data and decode JPEG data quickly.
6 6
7Required properties: 7Required properties:
8 - compatible: should containg one of the following: 8- compatible: "renesas,jpu-<soctype>", "renesas,rcar-gen2-jpu" as fallback.
9 - "renesas,jpu-r8a7790" for R-Car H2 9 Examples with soctypes are:
10 - "renesas,jpu-r8a7791" for R-Car M2-W 10 - "renesas,jpu-r8a7790" for R-Car H2
11 - "renesas,jpu-r8a7792" for R-Car V2H 11 - "renesas,jpu-r8a7791" for R-Car M2-W
12 - "renesas,jpu-r8a7793" for R-Car M2-N 12 - "renesas,jpu-r8a7792" for R-Car V2H
13 - "renesas,jpu-r8a7793" for R-Car M2-N
13 14
14 - reg: Base address and length of the registers block for the JPU. 15 - reg: Base address and length of the registers block for the JPU.
15 - interrupts: JPU interrupt specifier. 16 - interrupts: JPU interrupt specifier.
@@ -17,7 +18,7 @@ Required properties:
17 18
18Example: R8A7790 (R-Car H2) JPU node 19Example: R8A7790 (R-Car H2) JPU node
19 jpeg-codec@fe980000 { 20 jpeg-codec@fe980000 {
20 compatible = "renesas,jpu-r8a7790"; 21 compatible = "renesas,jpu-r8a7790", "renesas,rcar-gen2-jpu";
21 reg = <0 0xfe980000 0 0x10300>; 22 reg = <0 0xfe980000 0 0x10300>;
22 interrupts = <0 272 IRQ_TYPE_LEVEL_HIGH>; 23 interrupts = <0 272 IRQ_TYPE_LEVEL_HIGH>;
23 clocks = <&mstp1_clks R8A7790_CLK_JPU>; 24 clocks = <&mstp1_clks R8A7790_CLK_JPU>;
diff --git a/Documentation/devicetree/bindings/media/renesas,vsp1.txt b/Documentation/devicetree/bindings/media/renesas,vsp1.txt
index 87fe08abf36d..627405abd144 100644
--- a/Documentation/devicetree/bindings/media/renesas,vsp1.txt
+++ b/Documentation/devicetree/bindings/media/renesas,vsp1.txt
@@ -1,30 +1,18 @@
1* Renesas VSP1 Video Processing Engine 1* Renesas VSP Video Processing Engine
2 2
3The VSP1 is a video processing engine that supports up-/down-scaling, alpha 3The VSP is a video processing engine that supports up-/down-scaling, alpha
4blending, color space conversion and various other image processing features. 4blending, color space conversion and various other image processing features.
5It can be found in the Renesas R-Car second generation SoCs. 5It can be found in the Renesas R-Car second generation SoCs.
6 6
7Required properties: 7Required properties:
8 8
9 - compatible: Must contain "renesas,vsp1" 9 - compatible: Must contain one of the following values
10 - "renesas,vsp1" for the R-Car Gen2 VSP1
11 - "renesas,vsp2" for the R-Car Gen3 VSP2
10 12
11 - reg: Base address and length of the registers block for the VSP1. 13 - reg: Base address and length of the registers block for the VSP.
12 - interrupts: VSP1 interrupt specifier. 14 - interrupts: VSP interrupt specifier.
13 - clocks: A phandle + clock-specifier pair for the VSP1 functional clock. 15 - clocks: A phandle + clock-specifier pair for the VSP functional clock.
14
15 - renesas,#rpf: Number of Read Pixel Formatter (RPF) modules in the VSP1.
16 - renesas,#uds: Number of Up Down Scaler (UDS) modules in the VSP1.
17 - renesas,#wpf: Number of Write Pixel Formatter (WPF) modules in the VSP1.
18
19
20Optional properties:
21
22 - renesas,has-lif: Boolean, indicates that the LCD Interface (LIF) module is
23 available.
24 - renesas,has-lut: Boolean, indicates that the Look Up Table (LUT) module is
25 available.
26 - renesas,has-sru: Boolean, indicates that the Super Resolution Unit (SRU)
27 module is available.
28 16
29 17
30Example: R8A7790 (R-Car H2) VSP1-S node 18Example: R8A7790 (R-Car H2) VSP1-S node
@@ -34,10 +22,4 @@ Example: R8A7790 (R-Car H2) VSP1-S node
34 reg = <0 0xfe928000 0 0x8000>; 22 reg = <0 0xfe928000 0 0x8000>;
35 interrupts = <0 267 IRQ_TYPE_LEVEL_HIGH>; 23 interrupts = <0 267 IRQ_TYPE_LEVEL_HIGH>;
36 clocks = <&mstp1_clks R8A7790_CLK_VSP1_S>; 24 clocks = <&mstp1_clks R8A7790_CLK_VSP1_S>;
37
38 renesas,has-lut;
39 renesas,has-sru;
40 renesas,#rpf = <5>;
41 renesas,#uds = <3>;
42 renesas,#wpf = <4>;
43 }; 25 };
diff --git a/Documentation/devicetree/bindings/media/ti-cal.txt b/Documentation/devicetree/bindings/media/ti-cal.txt
new file mode 100644
index 000000000000..ae9b52f37576
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/ti-cal.txt
@@ -0,0 +1,72 @@
1Texas Instruments DRA72x CAMERA ADAPTATION LAYER (CAL)
2------------------------------------------------------
3
4The Camera Adaptation Layer (CAL) is a key component for image capture
5applications. The capture module provides the system interface and the
6processing capability to connect CSI2 image-sensor modules to the
7DRA72x device.
8
9Required properties:
10- compatible: must be "ti,dra72-cal"
11- reg: CAL Top level, Receiver Core #0, Receiver Core #1 and Camera RX
12 control address space
13- reg-names: cal_top, cal_rx_core0, cal_rx_core1, and camerrx_control
14 registers
15- interrupts: should contain IRQ line for the CAL;
16
17CAL supports 2 camera port nodes on MIPI bus. Each CSI2 camera port nodes
18should contain a 'port' child node with child 'endpoint' node. Please
19refer to the bindings defined in
20Documentation/devicetree/bindings/media/video-interfaces.txt.
21
22Example:
23 cal: cal@4845b000 {
24 compatible = "ti,dra72-cal";
25 ti,hwmods = "cal";
26 reg = <0x4845B000 0x400>,
27 <0x4845B800 0x40>,
28 <0x4845B900 0x40>,
29 <0x4A002e94 0x4>;
30 reg-names = "cal_top",
31 "cal_rx_core0",
32 "cal_rx_core1",
33 "camerrx_control";
34 interrupts = <GIC_SPI 119 IRQ_TYPE_LEVEL_HIGH>;
35 #address-cells = <1>;
36 #size-cells = <0>;
37
38 ports {
39 #address-cells = <1>;
40 #size-cells = <0>;
41
42 csi2_0: port@0 {
43 reg = <0>;
44 endpoint {
45 slave-mode;
46 remote-endpoint = <&ar0330_1>;
47 };
48 };
49 csi2_1: port@1 {
50 reg = <1>;
51 };
52 };
53 };
54
55 i2c5: i2c@4807c000 {
56 ar0330@10 {
57 compatible = "ti,ar0330";
58 reg = <0x10>;
59
60 port {
61 #address-cells = <1>;
62 #size-cells = <0>;
63
64 ar0330_1: endpoint {
65 reg = <0>;
66 clock-lanes = <1>;
67 data-lanes = <0 2 3 4>;
68 remote-endpoint = <&csi2_0>;
69 };
70 };
71 };
72 };
diff --git a/Documentation/dvb/README.dvb-usb b/Documentation/dvb/README.dvb-usb
index 669dc6ce4330..6f4b12f7b844 100644
--- a/Documentation/dvb/README.dvb-usb
+++ b/Documentation/dvb/README.dvb-usb
@@ -190,7 +190,7 @@ and watch another one.
190Patches, comments and suggestions are very very welcome. 190Patches, comments and suggestions are very very welcome.
191 191
1923. Acknowledgements 1923. Acknowledgements
193 Amaury Demol (ademol@dibcom.fr) and Francois Kanounnikoff from DiBcom for 193 Amaury Demol (Amaury.Demol@parrot.com) and Francois Kanounnikoff from DiBcom for
194 providing specs, code and help, on which the dvb-dibusb, dib3000mb and 194 providing specs, code and help, on which the dvb-dibusb, dib3000mb and
195 dib3000mc are based. 195 dib3000mc are based.
196 196
diff --git a/Documentation/video4linux/CARDLIST.saa7134 b/Documentation/video4linux/CARDLIST.saa7134
index 282102014bb9..335c24338859 100644
--- a/Documentation/video4linux/CARDLIST.saa7134
+++ b/Documentation/video4linux/CARDLIST.saa7134
@@ -194,3 +194,4 @@
194193 -> WIS Voyager or compatible [1905:7007] 194193 -> WIS Voyager or compatible [1905:7007]
195194 -> AverMedia AverTV/505 [1461:a10a] 195194 -> AverMedia AverTV/505 [1461:a10a]
196195 -> Leadtek Winfast TV2100 FM [107d:6f3a] 196195 -> Leadtek Winfast TV2100 FM [107d:6f3a]
197196 -> SnaZio* TVPVR PRO [1779:13cf]
diff --git a/Documentation/video4linux/v4l2-controls.txt b/Documentation/video4linux/v4l2-controls.txt
index 5517db602f37..5e759cab4538 100644
--- a/Documentation/video4linux/v4l2-controls.txt
+++ b/Documentation/video4linux/v4l2-controls.txt
@@ -647,7 +647,6 @@ Or you can add specific controls to a handler:
647 volume = v4l2_ctrl_new_std(&video_ctrl_handler, &ops, V4L2_CID_AUDIO_VOLUME, ...); 647 volume = v4l2_ctrl_new_std(&video_ctrl_handler, &ops, V4L2_CID_AUDIO_VOLUME, ...);
648 v4l2_ctrl_new_std(&video_ctrl_handler, &ops, V4L2_CID_BRIGHTNESS, ...); 648 v4l2_ctrl_new_std(&video_ctrl_handler, &ops, V4L2_CID_BRIGHTNESS, ...);
649 v4l2_ctrl_new_std(&video_ctrl_handler, &ops, V4L2_CID_CONTRAST, ...); 649 v4l2_ctrl_new_std(&video_ctrl_handler, &ops, V4L2_CID_CONTRAST, ...);
650 v4l2_ctrl_add_ctrl(&radio_ctrl_handler, volume);
651 650
652What you should not do is make two identical controls for two handlers. 651What you should not do is make two identical controls for two handlers.
653For example: 652For example:
diff --git a/MAINTAINERS b/MAINTAINERS
index cb2789afd3f8..99bd725affc6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7236,10 +7236,8 @@ L: linux-media@vger.kernel.org
7236W: https://linuxtv.org 7236W: https://linuxtv.org
7237W: http://palosaari.fi/linux/ 7237W: http://palosaari.fi/linux/
7238Q: http://patchwork.linuxtv.org/project/linux-media/list/ 7238Q: http://patchwork.linuxtv.org/project/linux-media/list/
7239T: git git://linuxtv.org/anttip/media_tree.git
7240S: Maintained 7239S: Maintained
7241F: drivers/staging/media/mn88473/ 7240F: drivers/media/dvb-frontends/mn88473*
7242F: drivers/media/dvb-frontends/mn88473.h
7243 7241
7244MODULE SUPPORT 7242MODULE SUPPORT
7245M: Rusty Russell <rusty@rustcorp.com.au> 7243M: Rusty Russell <rusty@rustcorp.com.au>
@@ -10897,6 +10895,14 @@ L: linux-omap@vger.kernel.org
10897S: Maintained 10895S: Maintained
10898F: drivers/thermal/ti-soc-thermal/ 10896F: drivers/thermal/ti-soc-thermal/
10899 10897
10898TI VPE/CAL DRIVERS
10899M: Benoit Parrot <bparrot@ti.com>
10900L: linux-media@vger.kernel.org
10901W: http://linuxtv.org/
10902Q: http://patchwork.linuxtv.org/project/linux-media/list/
10903S: Maintained
10904F: drivers/media/platform/ti-vpe/
10905
10900TI CDCE706 CLOCK DRIVER 10906TI CDCE706 CLOCK DRIVER
10901M: Max Filippov <jcmvbkbc@gmail.com> 10907M: Max Filippov <jcmvbkbc@gmail.com>
10902S: Maintained 10908S: Maintained
diff --git a/drivers/media/common/b2c2/flexcop-fe-tuner.c b/drivers/media/common/b2c2/flexcop-fe-tuner.c
index 9c59f4306883..f5956402fc69 100644
--- a/drivers/media/common/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/common/b2c2/flexcop-fe-tuner.c
@@ -38,7 +38,7 @@ static int flexcop_fe_request_firmware(struct dvb_frontend *fe,
38#endif 38#endif
39 39
40/* lnb control */ 40/* lnb control */
41#if FE_SUPPORTED(MT312) || FE_SUPPORTED(STV0299) 41#if (FE_SUPPORTED(MT312) || FE_SUPPORTED(STV0299)) && FE_SUPPORTED(PLL)
42static int flexcop_set_voltage(struct dvb_frontend *fe, 42static int flexcop_set_voltage(struct dvb_frontend *fe,
43 enum fe_sec_voltage voltage) 43 enum fe_sec_voltage voltage)
44{ 44{
@@ -68,7 +68,7 @@ static int flexcop_set_voltage(struct dvb_frontend *fe,
68#endif 68#endif
69 69
70#if FE_SUPPORTED(S5H1420) || FE_SUPPORTED(STV0299) || FE_SUPPORTED(MT312) 70#if FE_SUPPORTED(S5H1420) || FE_SUPPORTED(STV0299) || FE_SUPPORTED(MT312)
71static int flexcop_sleep(struct dvb_frontend* fe) 71static int __maybe_unused flexcop_sleep(struct dvb_frontend* fe)
72{ 72{
73 struct flexcop_device *fc = fe->dvb->priv; 73 struct flexcop_device *fc = fe->dvb->priv;
74 if (fc->fe_sleep) 74 if (fc->fe_sleep)
diff --git a/drivers/media/common/b2c2/flexcop.c b/drivers/media/common/b2c2/flexcop.c
index 412c5daf2b48..0f5114d406f8 100644
--- a/drivers/media/common/b2c2/flexcop.c
+++ b/drivers/media/common/b2c2/flexcop.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III 2 * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
3 * flexcop.c - main module part 3 * flexcop.c - main module part
4 * Copyright (C) 2004-9 Patrick Boettcher <patrick.boettcher@desy.de> 4 * Copyright (C) 2004-9 Patrick Boettcher <patrick.boettcher@posteo.de>
5 * based on skystar2-driver Copyright (C) 2003 Vadim Catana, skystar@moldova.cc 5 * based on skystar2-driver Copyright (C) 2003 Vadim Catana, skystar@moldova.cc
6 * 6 *
7 * Acknowledgements: 7 * Acknowledgements:
@@ -34,7 +34,7 @@
34#include "flexcop.h" 34#include "flexcop.h"
35 35
36#define DRIVER_NAME "B2C2 FlexcopII/II(b)/III digital TV receiver chip" 36#define DRIVER_NAME "B2C2 FlexcopII/II(b)/III digital TV receiver chip"
37#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@desy.de" 37#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@posteo.de"
38 38
39#ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG 39#ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG
40#define DEBSTATUS "" 40#define DEBSTATUS ""
diff --git a/drivers/media/common/cypress_firmware.c b/drivers/media/common/cypress_firmware.c
index 577e82058fdc..50e3f76d4847 100644
--- a/drivers/media/common/cypress_firmware.c
+++ b/drivers/media/common/cypress_firmware.c
@@ -1,6 +1,6 @@
1/* cypress_firmware.c is part of the DVB USB library. 1/* cypress_firmware.c is part of the DVB USB library.
2 * 2 *
3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) 3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
4 * see dvb-usb-init.c for copyright information. 4 * see dvb-usb-init.c for copyright information.
5 * 5 *
6 * This file contains functions for downloading the firmware to Cypress FX 1 6 * This file contains functions for downloading the firmware to Cypress FX 1
diff --git a/drivers/media/common/cypress_firmware.h b/drivers/media/common/cypress_firmware.h
index e493cbc7a528..1e4f27356205 100644
--- a/drivers/media/common/cypress_firmware.h
+++ b/drivers/media/common/cypress_firmware.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) 2 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
3 * see dvb-usb-init.c for copyright information. 3 * see dvb-usb-init.c for copyright information.
4 * 4 *
5 * This file contains functions for downloading the firmware to Cypress FX 1 5 * This file contains functions for downloading the firmware to Cypress FX 1
diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c
index 2a8d9a36d6f0..f3a42834d7d6 100644
--- a/drivers/media/common/siano/smscoreapi.c
+++ b/drivers/media/common/siano/smscoreapi.c
@@ -1167,8 +1167,8 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
1167 return rc; 1167 return rc;
1168 } 1168 }
1169 pr_debug("read fw %s, buffer size=0x%zx\n", fw_filename, fw->size); 1169 pr_debug("read fw %s, buffer size=0x%zx\n", fw_filename, fw->size);
1170 fw_buf = kmalloc(ALIGN(fw->size, SMS_ALLOC_ALIGNMENT), 1170 fw_buf = kmalloc(ALIGN(fw->size + sizeof(struct sms_firmware),
1171 GFP_KERNEL | GFP_DMA); 1171 SMS_ALLOC_ALIGNMENT), GFP_KERNEL | GFP_DMA);
1172 if (!fw_buf) { 1172 if (!fw_buf) {
1173 pr_err("failed to allocate firmware buffer\n"); 1173 pr_err("failed to allocate firmware buffer\n");
1174 rc = -ENOMEM; 1174 rc = -ENOMEM;
diff --git a/drivers/media/common/siano/smsdvb-main.c b/drivers/media/common/siano/smsdvb-main.c
index d31f468830cf..9148e14c9d07 100644
--- a/drivers/media/common/siano/smsdvb-main.c
+++ b/drivers/media/common/siano/smsdvb-main.c
@@ -1015,12 +1015,6 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe)
1015 } 1015 }
1016} 1016}
1017 1017
1018/* Nothing to do here, as stats are automatically updated */
1019static int smsdvb_get_frontend(struct dvb_frontend *fe)
1020{
1021 return 0;
1022}
1023
1024static int smsdvb_init(struct dvb_frontend *fe) 1018static int smsdvb_init(struct dvb_frontend *fe)
1025{ 1019{
1026 struct smsdvb_client_t *client = 1020 struct smsdvb_client_t *client =
@@ -1069,7 +1063,6 @@ static struct dvb_frontend_ops smsdvb_fe_ops = {
1069 .release = smsdvb_release, 1063 .release = smsdvb_release,
1070 1064
1071 .set_frontend = smsdvb_set_frontend, 1065 .set_frontend = smsdvb_set_frontend,
1072 .get_frontend = smsdvb_get_frontend,
1073 .get_tune_settings = smsdvb_get_tune_settings, 1066 .get_tune_settings = smsdvb_get_tune_settings,
1074 1067
1075 .read_status = smsdvb_read_status, 1068 .read_status = smsdvb_read_status,
diff --git a/drivers/media/dvb-core/dvb-usb-ids.h b/drivers/media/dvb-core/dvb-usb-ids.h
index 1c1c298d2289..0afad395ef97 100644
--- a/drivers/media/dvb-core/dvb-usb-ids.h
+++ b/drivers/media/dvb-core/dvb-usb-ids.h
@@ -1,6 +1,6 @@
1/* dvb-usb-ids.h is part of the DVB USB library. 1/* dvb-usb-ids.h is part of the DVB USB library.
2 * 2 *
3 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) see 3 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de) see
4 * dvb-usb-init.c for copyright information. 4 * dvb-usb-init.c for copyright information.
5 * 5 *
6 * a header file containing define's for the USB device supported by the 6 * a header file containing define's for the USB device supported by the
@@ -118,6 +118,7 @@
118#define USB_PID_DIBCOM_STK807XP 0x1f90 118#define USB_PID_DIBCOM_STK807XP 0x1f90
119#define USB_PID_DIBCOM_STK807XPVR 0x1f98 119#define USB_PID_DIBCOM_STK807XPVR 0x1f98
120#define USB_PID_DIBCOM_STK8096GP 0x1fa0 120#define USB_PID_DIBCOM_STK8096GP 0x1fa0
121#define USB_PID_DIBCOM_STK8096PVR 0x1faa
121#define USB_PID_DIBCOM_NIM8096MD 0x1fa8 122#define USB_PID_DIBCOM_NIM8096MD 0x1fa8
122#define USB_PID_DIBCOM_TFE8096P 0x1f9C 123#define USB_PID_DIBCOM_TFE8096P 0x1f9C
123#define USB_PID_DIBCOM_ANCHOR_2135_COLD 0x2131 124#define USB_PID_DIBCOM_ANCHOR_2135_COLD 0x2131
@@ -241,12 +242,14 @@
241#define USB_PID_AVERMEDIA_1867 0x1867 242#define USB_PID_AVERMEDIA_1867 0x1867
242#define USB_PID_AVERMEDIA_A867 0xa867 243#define USB_PID_AVERMEDIA_A867 0xa867
243#define USB_PID_AVERMEDIA_H335 0x0335 244#define USB_PID_AVERMEDIA_H335 0x0335
245#define USB_PID_AVERMEDIA_TD110 0xa110
244#define USB_PID_AVERMEDIA_TWINSTAR 0x0825 246#define USB_PID_AVERMEDIA_TWINSTAR 0x0825
245#define USB_PID_TECHNOTREND_CONNECT_S2400 0x3006 247#define USB_PID_TECHNOTREND_CONNECT_S2400 0x3006
246#define USB_PID_TECHNOTREND_CONNECT_S2400_8KEEPROM 0x3009 248#define USB_PID_TECHNOTREND_CONNECT_S2400_8KEEPROM 0x3009
247#define USB_PID_TECHNOTREND_CONNECT_CT3650 0x300d 249#define USB_PID_TECHNOTREND_CONNECT_CT3650 0x300d
248#define USB_PID_TECHNOTREND_CONNECT_S2_4600 0x3011 250#define USB_PID_TECHNOTREND_CONNECT_S2_4600 0x3011
249#define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI 0x3012 251#define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI 0x3012
252#define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI_2 0x3015
250#define USB_PID_TECHNOTREND_TVSTICK_CT2_4400 0x3014 253#define USB_PID_TECHNOTREND_TVSTICK_CT2_4400 0x3014
251#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a 254#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a
252#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081 255#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081
@@ -255,6 +258,10 @@
255#define USB_PID_TERRATEC_CINERGY_T_EXPRESS 0x0062 258#define USB_PID_TERRATEC_CINERGY_T_EXPRESS 0x0062
256#define USB_PID_TERRATEC_CINERGY_T_XXS 0x0078 259#define USB_PID_TERRATEC_CINERGY_T_XXS 0x0078
257#define USB_PID_TERRATEC_CINERGY_T_XXS_2 0x00ab 260#define USB_PID_TERRATEC_CINERGY_T_XXS_2 0x00ab
261#define USB_PID_TERRATEC_CINERGY_S2_R1 0x00a8
262#define USB_PID_TERRATEC_CINERGY_S2_R2 0x00b0
263#define USB_PID_TERRATEC_CINERGY_S2_R3 0x0102
264#define USB_PID_TERRATEC_CINERGY_S2_R4 0x0105
258#define USB_PID_TERRATEC_H7 0x10b4 265#define USB_PID_TERRATEC_H7 0x10b4
259#define USB_PID_TERRATEC_H7_2 0x10a3 266#define USB_PID_TERRATEC_H7_2 0x10a3
260#define USB_PID_TERRATEC_H7_3 0x10a5 267#define USB_PID_TERRATEC_H7_3 0x10a5
diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index 40080645341e..c0142614c408 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -134,15 +134,17 @@ struct dvb_frontend_private {
134 134
135#if defined(CONFIG_MEDIA_CONTROLLER_DVB) 135#if defined(CONFIG_MEDIA_CONTROLLER_DVB)
136 struct media_pipeline pipe; 136 struct media_pipeline pipe;
137 struct media_entity *pipe_start_entity;
138#endif 137#endif
139}; 138};
140 139
141static void dvb_frontend_wakeup(struct dvb_frontend *fe); 140static void dvb_frontend_wakeup(struct dvb_frontend *fe);
142static int dtv_get_frontend(struct dvb_frontend *fe, 141static int dtv_get_frontend(struct dvb_frontend *fe,
142 struct dtv_frontend_properties *c,
143 struct dvb_frontend_parameters *p_out); 143 struct dvb_frontend_parameters *p_out);
144static int dtv_property_legacy_params_sync(struct dvb_frontend *fe, 144static int
145 struct dvb_frontend_parameters *p); 145dtv_property_legacy_params_sync(struct dvb_frontend *fe,
146 const struct dtv_frontend_properties *c,
147 struct dvb_frontend_parameters *p);
146 148
147static bool has_get_frontend(struct dvb_frontend *fe) 149static bool has_get_frontend(struct dvb_frontend *fe)
148{ 150{
@@ -202,6 +204,7 @@ static void dvb_frontend_add_event(struct dvb_frontend *fe,
202 enum fe_status status) 204 enum fe_status status)
203{ 205{
204 struct dvb_frontend_private *fepriv = fe->frontend_priv; 206 struct dvb_frontend_private *fepriv = fe->frontend_priv;
207 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
205 struct dvb_fe_events *events = &fepriv->events; 208 struct dvb_fe_events *events = &fepriv->events;
206 struct dvb_frontend_event *e; 209 struct dvb_frontend_event *e;
207 int wp; 210 int wp;
@@ -209,7 +212,7 @@ static void dvb_frontend_add_event(struct dvb_frontend *fe,
209 dev_dbg(fe->dvb->device, "%s:\n", __func__); 212 dev_dbg(fe->dvb->device, "%s:\n", __func__);
210 213
211 if ((status & FE_HAS_LOCK) && has_get_frontend(fe)) 214 if ((status & FE_HAS_LOCK) && has_get_frontend(fe))
212 dtv_get_frontend(fe, &fepriv->parameters_out); 215 dtv_get_frontend(fe, c, &fepriv->parameters_out);
213 216
214 mutex_lock(&events->mtx); 217 mutex_lock(&events->mtx);
215 218
@@ -596,104 +599,13 @@ static void dvb_frontend_wakeup(struct dvb_frontend *fe)
596 wake_up_interruptible(&fepriv->wait_queue); 599 wake_up_interruptible(&fepriv->wait_queue);
597} 600}
598 601
599/**
600 * dvb_enable_media_tuner() - tries to enable the DVB tuner
601 *
602 * @fe: struct dvb_frontend pointer
603 *
604 * This function ensures that just one media tuner is enabled for a given
605 * frontend. It has two different behaviors:
606 * - For trivial devices with just one tuner:
607 * it just enables the existing tuner->fe link
608 * - For devices with more than one tuner:
609 * It is up to the driver to implement the logic that will enable one tuner
610 * and disable the other ones. However, if more than one tuner is enabled for
611 * the same frontend, it will print an error message and return -EINVAL.
612 *
613 * At return, it will return the error code returned by media_entity_setup_link,
614 * or 0 if everything is OK, if no tuner is linked to the frontend or if the
615 * mdev is NULL.
616 */
617#ifdef CONFIG_MEDIA_CONTROLLER_DVB
618static int dvb_enable_media_tuner(struct dvb_frontend *fe)
619{
620 struct dvb_frontend_private *fepriv = fe->frontend_priv;
621 struct dvb_adapter *adapter = fe->dvb;
622 struct media_device *mdev = adapter->mdev;
623 struct media_entity *entity, *source;
624 struct media_link *link, *found_link = NULL;
625 int ret, n_links = 0, active_links = 0;
626
627 fepriv->pipe_start_entity = NULL;
628
629 if (!mdev)
630 return 0;
631
632 entity = fepriv->dvbdev->entity;
633 fepriv->pipe_start_entity = entity;
634
635 list_for_each_entry(link, &entity->links, list) {
636 if (link->sink->entity == entity) {
637 found_link = link;
638 n_links++;
639 if (link->flags & MEDIA_LNK_FL_ENABLED)
640 active_links++;
641 }
642 }
643
644 if (!n_links || active_links == 1 || !found_link)
645 return 0;
646
647 /*
648 * If a frontend has more than one tuner linked, it is up to the driver
649 * to select with one will be the active one, as the frontend core can't
650 * guess. If the driver doesn't do that, it is a bug.
651 */
652 if (n_links > 1 && active_links != 1) {
653 dev_err(fe->dvb->device,
654 "WARNING: there are %d active links among %d tuners. This is a driver's bug!\n",
655 active_links, n_links);
656 return -EINVAL;
657 }
658
659 source = found_link->source->entity;
660 fepriv->pipe_start_entity = source;
661 list_for_each_entry(link, &source->links, list) {
662 struct media_entity *sink;
663 int flags = 0;
664
665 sink = link->sink->entity;
666 if (sink == entity)
667 flags = MEDIA_LNK_FL_ENABLED;
668
669 ret = media_entity_setup_link(link, flags);
670 if (ret) {
671 dev_err(fe->dvb->device,
672 "Couldn't change link %s->%s to %s. Error %d\n",
673 source->name, sink->name,
674 flags ? "enabled" : "disabled",
675 ret);
676 return ret;
677 } else
678 dev_dbg(fe->dvb->device,
679 "link %s->%s was %s\n",
680 source->name, sink->name,
681 flags ? "ENABLED" : "disabled");
682 }
683 return 0;
684}
685#endif
686
687static int dvb_frontend_thread(void *data) 602static int dvb_frontend_thread(void *data)
688{ 603{
689 struct dvb_frontend *fe = data; 604 struct dvb_frontend *fe = data;
605 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
690 struct dvb_frontend_private *fepriv = fe->frontend_priv; 606 struct dvb_frontend_private *fepriv = fe->frontend_priv;
691 enum fe_status s; 607 enum fe_status s;
692 enum dvbfe_algo algo; 608 enum dvbfe_algo algo;
693#ifdef CONFIG_MEDIA_CONTROLLER_DVB
694 int ret;
695#endif
696
697 bool re_tune = false; 609 bool re_tune = false;
698 bool semheld = false; 610 bool semheld = false;
699 611
@@ -706,20 +618,6 @@ static int dvb_frontend_thread(void *data)
706 fepriv->wakeup = 0; 618 fepriv->wakeup = 0;
707 fepriv->reinitialise = 0; 619 fepriv->reinitialise = 0;
708 620
709#ifdef CONFIG_MEDIA_CONTROLLER_DVB
710 ret = dvb_enable_media_tuner(fe);
711 if (ret) {
712 /* FIXME: return an error if it fails */
713 dev_info(fe->dvb->device,
714 "proceeding with FE task\n");
715 } else if (fepriv->pipe_start_entity) {
716 ret = media_entity_pipeline_start(fepriv->pipe_start_entity,
717 &fepriv->pipe);
718 if (ret)
719 return ret;
720 }
721#endif
722
723 dvb_frontend_init(fe); 621 dvb_frontend_init(fe);
724 622
725 set_freezable(); 623 set_freezable();
@@ -807,7 +705,7 @@ restart:
807 fepriv->algo_status |= DVBFE_ALGO_SEARCH_AGAIN; 705 fepriv->algo_status |= DVBFE_ALGO_SEARCH_AGAIN;
808 fepriv->delay = HZ / 2; 706 fepriv->delay = HZ / 2;
809 } 707 }
810 dtv_property_legacy_params_sync(fe, &fepriv->parameters_out); 708 dtv_property_legacy_params_sync(fe, c, &fepriv->parameters_out);
811 fe->ops.read_status(fe, &s); 709 fe->ops.read_status(fe, &s);
812 if (s != fepriv->status) { 710 if (s != fepriv->status) {
813 dvb_frontend_add_event(fe, s); /* update event list */ 711 dvb_frontend_add_event(fe, s); /* update event list */
@@ -829,12 +727,6 @@ restart:
829 } 727 }
830 } 728 }
831 729
832#ifdef CONFIG_MEDIA_CONTROLLER_DVB
833 if (fepriv->pipe_start_entity)
834 media_entity_pipeline_stop(fepriv->pipe_start_entity);
835 fepriv->pipe_start_entity = NULL;
836#endif
837
838 if (dvb_powerdown_on_sleep) { 730 if (dvb_powerdown_on_sleep) {
839 if (fe->ops.set_voltage) 731 if (fe->ops.set_voltage)
840 fe->ops.set_voltage(fe, SEC_VOLTAGE_OFF); 732 fe->ops.set_voltage(fe, SEC_VOLTAGE_OFF);
@@ -899,10 +791,10 @@ void dvb_frontend_sleep_until(ktime_t *waketime, u32 add_usec)
899 s32 delta; 791 s32 delta;
900 792
901 *waketime = ktime_add_us(*waketime, add_usec); 793 *waketime = ktime_add_us(*waketime, add_usec);
902 delta = ktime_us_delta(ktime_get_real(), *waketime); 794 delta = ktime_us_delta(ktime_get_boottime(), *waketime);
903 if (delta > 2500) { 795 if (delta > 2500) {
904 msleep((delta - 1500) / 1000); 796 msleep((delta - 1500) / 1000);
905 delta = ktime_us_delta(ktime_get_real(), *waketime); 797 delta = ktime_us_delta(ktime_get_boottime(), *waketime);
906 } 798 }
907 if (delta > 0) 799 if (delta > 0)
908 udelay(delta); 800 udelay(delta);
@@ -1162,18 +1054,24 @@ static struct dtv_cmds_h dtv_cmds[DTV_MAX_COMMAND + 1] = {
1162 _DTV_CMD(DTV_STAT_TOTAL_BLOCK_COUNT, 0, 0), 1054 _DTV_CMD(DTV_STAT_TOTAL_BLOCK_COUNT, 0, 0),
1163}; 1055};
1164 1056
1165static void dtv_property_dump(struct dvb_frontend *fe, struct dtv_property *tvp) 1057static void dtv_property_dump(struct dvb_frontend *fe,
1058 bool is_set,
1059 struct dtv_property *tvp)
1166{ 1060{
1167 int i; 1061 int i;
1168 1062
1169 if (tvp->cmd <= 0 || tvp->cmd > DTV_MAX_COMMAND) { 1063 if (tvp->cmd <= 0 || tvp->cmd > DTV_MAX_COMMAND) {
1170 dev_warn(fe->dvb->device, "%s: tvp.cmd = 0x%08x undefined\n", 1064 dev_warn(fe->dvb->device, "%s: %s tvp.cmd = 0x%08x undefined\n",
1171 __func__, tvp->cmd); 1065 __func__,
1066 is_set ? "SET" : "GET",
1067 tvp->cmd);
1172 return; 1068 return;
1173 } 1069 }
1174 1070
1175 dev_dbg(fe->dvb->device, "%s: tvp.cmd = 0x%08x (%s)\n", __func__, 1071 dev_dbg(fe->dvb->device, "%s: %s tvp.cmd = 0x%08x (%s)\n", __func__,
1176 tvp->cmd, dtv_cmds[tvp->cmd].name); 1072 is_set ? "SET" : "GET",
1073 tvp->cmd,
1074 dtv_cmds[tvp->cmd].name);
1177 1075
1178 if (dtv_cmds[tvp->cmd].buffer) { 1076 if (dtv_cmds[tvp->cmd].buffer) {
1179 dev_dbg(fe->dvb->device, "%s: tvp.u.buffer.len = 0x%02x\n", 1077 dev_dbg(fe->dvb->device, "%s: tvp.u.buffer.len = 0x%02x\n",
@@ -1268,11 +1166,11 @@ static int dtv_property_cache_sync(struct dvb_frontend *fe,
1268/* Ensure the cached values are set correctly in the frontend 1166/* Ensure the cached values are set correctly in the frontend
1269 * legacy tuning structures, for the advanced tuning API. 1167 * legacy tuning structures, for the advanced tuning API.
1270 */ 1168 */
1271static int dtv_property_legacy_params_sync(struct dvb_frontend *fe, 1169static int
1272 struct dvb_frontend_parameters *p) 1170dtv_property_legacy_params_sync(struct dvb_frontend *fe,
1171 const struct dtv_frontend_properties *c,
1172 struct dvb_frontend_parameters *p)
1273{ 1173{
1274 const struct dtv_frontend_properties *c = &fe->dtv_property_cache;
1275
1276 p->frequency = c->frequency; 1174 p->frequency = c->frequency;
1277 p->inversion = c->inversion; 1175 p->inversion = c->inversion;
1278 1176
@@ -1344,16 +1242,17 @@ static int dtv_property_legacy_params_sync(struct dvb_frontend *fe,
1344 * If p_out is not null, it will update the DVBv3 params pointed by it. 1242 * If p_out is not null, it will update the DVBv3 params pointed by it.
1345 */ 1243 */
1346static int dtv_get_frontend(struct dvb_frontend *fe, 1244static int dtv_get_frontend(struct dvb_frontend *fe,
1245 struct dtv_frontend_properties *c,
1347 struct dvb_frontend_parameters *p_out) 1246 struct dvb_frontend_parameters *p_out)
1348{ 1247{
1349 int r; 1248 int r;
1350 1249
1351 if (fe->ops.get_frontend) { 1250 if (fe->ops.get_frontend) {
1352 r = fe->ops.get_frontend(fe); 1251 r = fe->ops.get_frontend(fe, c);
1353 if (unlikely(r < 0)) 1252 if (unlikely(r < 0))
1354 return r; 1253 return r;
1355 if (p_out) 1254 if (p_out)
1356 dtv_property_legacy_params_sync(fe, p_out); 1255 dtv_property_legacy_params_sync(fe, c, p_out);
1357 return 0; 1256 return 0;
1358 } 1257 }
1359 1258
@@ -1589,7 +1488,7 @@ static int dtv_property_process_get(struct dvb_frontend *fe,
1589 return r; 1488 return r;
1590 } 1489 }
1591 1490
1592 dtv_property_dump(fe, tvp); 1491 dtv_property_dump(fe, false, tvp);
1593 1492
1594 return 0; 1493 return 0;
1595} 1494}
@@ -1830,6 +1729,8 @@ static int dtv_property_process_set(struct dvb_frontend *fe,
1830 return r; 1729 return r;
1831 } 1730 }
1832 1731
1732 dtv_property_dump(fe, true, tvp);
1733
1833 switch(tvp->cmd) { 1734 switch(tvp->cmd) {
1834 case DTV_CLEAR: 1735 case DTV_CLEAR:
1835 /* 1736 /*
@@ -2073,6 +1974,8 @@ static int dvb_frontend_ioctl_properties(struct file *file,
2073 dev_dbg(fe->dvb->device, "%s: Property cache is full, tuning\n", __func__); 1974 dev_dbg(fe->dvb->device, "%s: Property cache is full, tuning\n", __func__);
2074 1975
2075 } else if (cmd == FE_GET_PROPERTY) { 1976 } else if (cmd == FE_GET_PROPERTY) {
1977 struct dtv_frontend_properties getp = fe->dtv_property_cache;
1978
2076 dev_dbg(fe->dvb->device, "%s: properties.num = %d\n", __func__, tvps->num); 1979 dev_dbg(fe->dvb->device, "%s: properties.num = %d\n", __func__, tvps->num);
2077 dev_dbg(fe->dvb->device, "%s: properties.props = %p\n", __func__, tvps->props); 1980 dev_dbg(fe->dvb->device, "%s: properties.props = %p\n", __func__, tvps->props);
2078 1981
@@ -2094,17 +1997,18 @@ static int dvb_frontend_ioctl_properties(struct file *file,
2094 } 1997 }
2095 1998
2096 /* 1999 /*
2097 * Fills the cache out struct with the cache contents, plus 2000 * Let's use our own copy of property cache, in order to
2098 * the data retrieved from get_frontend, if the frontend 2001 * avoid mangling with DTV zigzag logic, as drivers might
2099 * is not idle. Otherwise, returns the cached content 2002 * return crap, if they don't check if the data is available
2003 * before updating the properties cache.
2100 */ 2004 */
2101 if (fepriv->state != FESTATE_IDLE) { 2005 if (fepriv->state != FESTATE_IDLE) {
2102 err = dtv_get_frontend(fe, NULL); 2006 err = dtv_get_frontend(fe, &getp, NULL);
2103 if (err < 0) 2007 if (err < 0)
2104 goto out; 2008 goto out;
2105 } 2009 }
2106 for (i = 0; i < tvps->num; i++) { 2010 for (i = 0; i < tvps->num; i++) {
2107 err = dtv_property_process_get(fe, c, tvp + i, file); 2011 err = dtv_property_process_get(fe, &getp, tvp + i, file);
2108 if (err < 0) 2012 if (err < 0)
2109 goto out; 2013 goto out;
2110 (tvp + i)->result = err; 2014 (tvp + i)->result = err;
@@ -2139,7 +2043,7 @@ static int dtv_set_frontend(struct dvb_frontend *fe)
2139 * the user. FE_SET_FRONTEND triggers an initial frontend event 2043 * the user. FE_SET_FRONTEND triggers an initial frontend event
2140 * with status = 0, which copies output parameters to userspace. 2044 * with status = 0, which copies output parameters to userspace.
2141 */ 2045 */
2142 dtv_property_legacy_params_sync(fe, &fepriv->parameters_out); 2046 dtv_property_legacy_params_sync(fe, c, &fepriv->parameters_out);
2143 2047
2144 /* 2048 /*
2145 * Be sure that the bandwidth will be filled for all 2049 * Be sure that the bandwidth will be filled for all
@@ -2451,7 +2355,7 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
2451 u8 last = 1; 2355 u8 last = 1;
2452 if (dvb_frontend_debug) 2356 if (dvb_frontend_debug)
2453 printk("%s switch command: 0x%04lx\n", __func__, swcmd); 2357 printk("%s switch command: 0x%04lx\n", __func__, swcmd);
2454 nexttime = ktime_get_real(); 2358 nexttime = ktime_get_boottime();
2455 if (dvb_frontend_debug) 2359 if (dvb_frontend_debug)
2456 tv[0] = nexttime; 2360 tv[0] = nexttime;
2457 /* before sending a command, initialize by sending 2361 /* before sending a command, initialize by sending
@@ -2462,7 +2366,7 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
2462 2366
2463 for (i = 0; i < 9; i++) { 2367 for (i = 0; i < 9; i++) {
2464 if (dvb_frontend_debug) 2368 if (dvb_frontend_debug)
2465 tv[i+1] = ktime_get_real(); 2369 tv[i+1] = ktime_get_boottime();
2466 if ((swcmd & 0x01) != last) { 2370 if ((swcmd & 0x01) != last) {
2467 /* set voltage to (last ? 13V : 18V) */ 2371 /* set voltage to (last ? 13V : 18V) */
2468 fe->ops.set_voltage(fe, (last) ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18); 2372 fe->ops.set_voltage(fe, (last) ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18);
@@ -2509,10 +2413,18 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
2509 err = dvb_frontend_get_event (fe, parg, file->f_flags); 2413 err = dvb_frontend_get_event (fe, parg, file->f_flags);
2510 break; 2414 break;
2511 2415
2512 case FE_GET_FRONTEND: 2416 case FE_GET_FRONTEND: {
2513 err = dtv_get_frontend(fe, parg); 2417 struct dtv_frontend_properties getp = fe->dtv_property_cache;
2514 break;
2515 2418
2419 /*
2420 * Let's use our own copy of property cache, in order to
2421 * avoid mangling with DTV zigzag logic, as drivers might
2422 * return crap, if they don't check if the data is available
2423 * before updating the properties cache.
2424 */
2425 err = dtv_get_frontend(fe, &getp, parg);
2426 break;
2427 }
2516 case FE_SET_FRONTEND_TUNE_MODE: 2428 case FE_SET_FRONTEND_TUNE_MODE:
2517 fepriv->tune_mode_flags = (unsigned long) parg; 2429 fepriv->tune_mode_flags = (unsigned long) parg;
2518 err = 0; 2430 err = 0;
@@ -2612,9 +2524,20 @@ static int dvb_frontend_open(struct inode *inode, struct file *file)
2612 fepriv->tone = -1; 2524 fepriv->tone = -1;
2613 fepriv->voltage = -1; 2525 fepriv->voltage = -1;
2614 2526
2527#ifdef CONFIG_MEDIA_CONTROLLER_DVB
2528 if (fe->dvb->mdev && fe->dvb->mdev->enable_source) {
2529 ret = fe->dvb->mdev->enable_source(dvbdev->entity,
2530 &fepriv->pipe);
2531 if (ret) {
2532 dev_err(fe->dvb->device,
2533 "Tuner is busy. Error %d\n", ret);
2534 goto err2;
2535 }
2536 }
2537#endif
2615 ret = dvb_frontend_start (fe); 2538 ret = dvb_frontend_start (fe);
2616 if (ret) 2539 if (ret)
2617 goto err2; 2540 goto err3;
2618 2541
2619 /* empty event queue */ 2542 /* empty event queue */
2620 fepriv->events.eventr = fepriv->events.eventw = 0; 2543 fepriv->events.eventr = fepriv->events.eventw = 0;
@@ -2624,7 +2547,12 @@ static int dvb_frontend_open(struct inode *inode, struct file *file)
2624 mutex_unlock (&adapter->mfe_lock); 2547 mutex_unlock (&adapter->mfe_lock);
2625 return ret; 2548 return ret;
2626 2549
2550err3:
2551#ifdef CONFIG_MEDIA_CONTROLLER_DVB
2552 if (fe->dvb->mdev && fe->dvb->mdev->disable_source)
2553 fe->dvb->mdev->disable_source(dvbdev->entity);
2627err2: 2554err2:
2555#endif
2628 dvb_generic_release(inode, file); 2556 dvb_generic_release(inode, file);
2629err1: 2557err1:
2630 if (dvbdev->users == -1 && fe->ops.ts_bus_ctrl) 2558 if (dvbdev->users == -1 && fe->ops.ts_bus_ctrl)
@@ -2653,6 +2581,10 @@ static int dvb_frontend_release(struct inode *inode, struct file *file)
2653 2581
2654 if (dvbdev->users == -1) { 2582 if (dvbdev->users == -1) {
2655 wake_up(&fepriv->wait_queue); 2583 wake_up(&fepriv->wait_queue);
2584#ifdef CONFIG_MEDIA_CONTROLLER_DVB
2585 if (fe->dvb->mdev && fe->dvb->mdev->disable_source)
2586 fe->dvb->mdev->disable_source(dvbdev->entity);
2587#endif
2656 if (fe->exit != DVB_FE_NO_EXIT) 2588 if (fe->exit != DVB_FE_NO_EXIT)
2657 wake_up(&dvbdev->wait_queue); 2589 wake_up(&dvbdev->wait_queue);
2658 if (fe->ops.ts_bus_ctrl) 2590 if (fe->ops.ts_bus_ctrl)
diff --git a/drivers/media/dvb-core/dvb_frontend.h b/drivers/media/dvb-core/dvb_frontend.h
index 458bcce20e38..9592573a0b41 100644
--- a/drivers/media/dvb-core/dvb_frontend.h
+++ b/drivers/media/dvb-core/dvb_frontend.h
@@ -449,7 +449,8 @@ struct dvb_frontend_ops {
449 int (*set_frontend)(struct dvb_frontend *fe); 449 int (*set_frontend)(struct dvb_frontend *fe);
450 int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings); 450 int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);
451 451
452 int (*get_frontend)(struct dvb_frontend *fe); 452 int (*get_frontend)(struct dvb_frontend *fe,
453 struct dtv_frontend_properties *props);
453 454
454 int (*read_status)(struct dvb_frontend *fe, enum fe_status *status); 455 int (*read_status)(struct dvb_frontend *fe, enum fe_status *status);
455 int (*read_ber)(struct dvb_frontend* fe, u32* ber); 456 int (*read_ber)(struct dvb_frontend* fe, u32* ber);
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 560450a0b32a..e1684c570e2f 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -58,7 +58,7 @@ static const char * const dnames[] = {
58#define DVB_MAX_IDS MAX_DVB_MINORS 58#define DVB_MAX_IDS MAX_DVB_MINORS
59#else 59#else
60#define DVB_MAX_IDS 4 60#define DVB_MAX_IDS 4
61#define nums2minor(num,type,id) ((num << 6) | (id << 4) | type) 61#define nums2minor(num, type, id) ((num << 6) | (id << 4) | type)
62#define MAX_DVB_MINORS (DVB_MAX_ADAPTERS*64) 62#define MAX_DVB_MINORS (DVB_MAX_ADAPTERS*64)
63#endif 63#endif
64 64
@@ -85,7 +85,7 @@ static int dvb_device_open(struct inode *inode, struct file *file)
85 file->private_data = dvbdev; 85 file->private_data = dvbdev;
86 replace_fops(file, new_fops); 86 replace_fops(file, new_fops);
87 if (file->f_op->open) 87 if (file->f_op->open)
88 err = file->f_op->open(inode,file); 88 err = file->f_op->open(inode, file);
89 up_read(&minor_rwsem); 89 up_read(&minor_rwsem);
90 mutex_unlock(&dvbdev_mutex); 90 mutex_unlock(&dvbdev_mutex);
91 return err; 91 return err;
@@ -352,7 +352,7 @@ static int dvb_create_media_entity(struct dvb_device *dvbdev,
352 ret = media_device_register_entity(dvbdev->adapter->mdev, 352 ret = media_device_register_entity(dvbdev->adapter->mdev,
353 dvbdev->entity); 353 dvbdev->entity);
354 if (ret) 354 if (ret)
355 return (ret); 355 return ret;
356 356
357 printk(KERN_DEBUG "%s: media entity '%s' registered.\n", 357 printk(KERN_DEBUG "%s: media entity '%s' registered.\n",
358 __func__, dvbdev->entity->name); 358 __func__, dvbdev->entity->name);
@@ -620,8 +620,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap,
620 return -ENOMEM; 620 return -ENOMEM;
621 adap->conn = conn; 621 adap->conn = conn;
622 622
623 adap->conn_pads = kcalloc(1, sizeof(*adap->conn_pads), 623 adap->conn_pads = kzalloc(sizeof(*adap->conn_pads), GFP_KERNEL);
624 GFP_KERNEL);
625 if (!adap->conn_pads) 624 if (!adap->conn_pads)
626 return -ENOMEM; 625 return -ENOMEM;
627 626
@@ -661,7 +660,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap,
661 if (ntuner && ndemod) { 660 if (ntuner && ndemod) {
662 ret = media_create_pad_links(mdev, 661 ret = media_create_pad_links(mdev,
663 MEDIA_ENT_F_TUNER, 662 MEDIA_ENT_F_TUNER,
664 tuner, TUNER_PAD_IF_OUTPUT, 663 tuner, TUNER_PAD_OUTPUT,
665 MEDIA_ENT_F_DTV_DEMOD, 664 MEDIA_ENT_F_DTV_DEMOD,
666 demod, 0, MEDIA_LNK_FL_ENABLED, 665 demod, 0, MEDIA_LNK_FL_ENABLED,
667 false); 666 false);
@@ -682,7 +681,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap,
682 if (demux && ca) { 681 if (demux && ca) {
683 ret = media_create_pad_link(demux, 1, ca, 682 ret = media_create_pad_link(demux, 1, ca,
684 0, MEDIA_LNK_FL_ENABLED); 683 0, MEDIA_LNK_FL_ENABLED);
685 if (!ret) 684 if (ret)
686 return -ENOMEM; 685 return -ENOMEM;
687 } 686 }
688 687
@@ -868,7 +867,7 @@ int dvb_usercopy(struct file *file,
868 parg = sbuf; 867 parg = sbuf;
869 } else { 868 } else {
870 /* too big to allocate from stack */ 869 /* too big to allocate from stack */
871 mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL); 870 mbuf = kmalloc(_IOC_SIZE(cmd), GFP_KERNEL);
872 if (NULL == mbuf) 871 if (NULL == mbuf)
873 return -ENOMEM; 872 return -ENOMEM;
874 parg = mbuf; 873 parg = mbuf;
diff --git a/drivers/media/dvb-frontends/Kconfig b/drivers/media/dvb-frontends/Kconfig
index 310e4b8beae8..a82f77c49bd5 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -73,6 +73,14 @@ config DVB_SI2165
73 73
74 Say Y when you want to support this frontend. 74 Say Y when you want to support this frontend.
75 75
76config DVB_MN88473
77 tristate "Panasonic MN88473"
78 depends on DVB_CORE && I2C
79 select REGMAP_I2C
80 default m if !MEDIA_SUBDRV_AUTOSELECT
81 help
82 Say Y when you want to support this frontend.
83
76comment "DVB-S (satellite) frontends" 84comment "DVB-S (satellite) frontends"
77 depends on DVB_CORE 85 depends on DVB_CORE
78 86
diff --git a/drivers/media/dvb-frontends/Makefile b/drivers/media/dvb-frontends/Makefile
index 37ef17b5b995..eb7191f4219d 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -95,6 +95,7 @@ obj-$(CONFIG_DVB_STV0900) += stv0900.o
95obj-$(CONFIG_DVB_STV090x) += stv090x.o 95obj-$(CONFIG_DVB_STV090x) += stv090x.o
96obj-$(CONFIG_DVB_STV6110x) += stv6110x.o 96obj-$(CONFIG_DVB_STV6110x) += stv6110x.o
97obj-$(CONFIG_DVB_M88DS3103) += m88ds3103.o 97obj-$(CONFIG_DVB_M88DS3103) += m88ds3103.o
98obj-$(CONFIG_DVB_MN88473) += mn88473.o
98obj-$(CONFIG_DVB_ISL6423) += isl6423.o 99obj-$(CONFIG_DVB_ISL6423) += isl6423.o
99obj-$(CONFIG_DVB_EC100) += ec100.o 100obj-$(CONFIG_DVB_EC100) += ec100.o
100obj-$(CONFIG_DVB_HD29L2) += hd29l2.o 101obj-$(CONFIG_DVB_HD29L2) += hd29l2.o
diff --git a/drivers/media/dvb-frontends/af9013.c b/drivers/media/dvb-frontends/af9013.c
index e23197da84af..8bcde336ffd7 100644
--- a/drivers/media/dvb-frontends/af9013.c
+++ b/drivers/media/dvb-frontends/af9013.c
@@ -866,9 +866,9 @@ err:
866 return ret; 866 return ret;
867} 867}
868 868
869static int af9013_get_frontend(struct dvb_frontend *fe) 869static int af9013_get_frontend(struct dvb_frontend *fe,
870 struct dtv_frontend_properties *c)
870{ 871{
871 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
872 struct af9013_state *state = fe->demodulator_priv; 872 struct af9013_state *state = fe->demodulator_priv;
873 int ret; 873 int ret;
874 u8 buf[3]; 874 u8 buf[3];
@@ -1344,6 +1344,10 @@ err:
1344static void af9013_release(struct dvb_frontend *fe) 1344static void af9013_release(struct dvb_frontend *fe)
1345{ 1345{
1346 struct af9013_state *state = fe->demodulator_priv; 1346 struct af9013_state *state = fe->demodulator_priv;
1347
1348 /* stop statistics polling */
1349 cancel_delayed_work_sync(&state->statistics_work);
1350
1347 kfree(state); 1351 kfree(state);
1348} 1352}
1349 1353
diff --git a/drivers/media/dvb-frontends/af9033.c b/drivers/media/dvb-frontends/af9033.c
index bc35206a0821..efebe5ce2429 100644
--- a/drivers/media/dvb-frontends/af9033.c
+++ b/drivers/media/dvb-frontends/af9033.c
@@ -691,10 +691,10 @@ err:
691 return ret; 691 return ret;
692} 692}
693 693
694static int af9033_get_frontend(struct dvb_frontend *fe) 694static int af9033_get_frontend(struct dvb_frontend *fe,
695 struct dtv_frontend_properties *c)
695{ 696{
696 struct af9033_dev *dev = fe->demodulator_priv; 697 struct af9033_dev *dev = fe->demodulator_priv;
697 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
698 int ret; 698 int ret;
699 u8 buf[8]; 699 u8 buf[8];
700 700
@@ -1372,6 +1372,9 @@ static int af9033_remove(struct i2c_client *client)
1372 1372
1373 dev_dbg(&dev->client->dev, "\n"); 1373 dev_dbg(&dev->client->dev, "\n");
1374 1374
1375 /* stop statistics polling */
1376 cancel_delayed_work_sync(&dev->stat_work);
1377
1375 dev->fe.ops.release = NULL; 1378 dev->fe.ops.release = NULL;
1376 dev->fe.demodulator_priv = NULL; 1379 dev->fe.demodulator_priv = NULL;
1377 kfree(dev); 1380 kfree(dev);
diff --git a/drivers/media/dvb-frontends/as102_fe.c b/drivers/media/dvb-frontends/as102_fe.c
index 544c5f65d19a..9412fcd1bddb 100644
--- a/drivers/media/dvb-frontends/as102_fe.c
+++ b/drivers/media/dvb-frontends/as102_fe.c
@@ -190,10 +190,10 @@ static int as102_fe_set_frontend(struct dvb_frontend *fe)
190 return state->ops->set_tune(state->priv, &tune_args); 190 return state->ops->set_tune(state->priv, &tune_args);
191} 191}
192 192
193static int as102_fe_get_frontend(struct dvb_frontend *fe) 193static int as102_fe_get_frontend(struct dvb_frontend *fe,
194 struct dtv_frontend_properties *c)
194{ 195{
195 struct as102_state *state = fe->demodulator_priv; 196 struct as102_state *state = fe->demodulator_priv;
196 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
197 int ret = 0; 197 int ret = 0;
198 struct as10x_tps tps = { 0 }; 198 struct as10x_tps tps = { 0 };
199 199
diff --git a/drivers/media/dvb-frontends/atbm8830.c b/drivers/media/dvb-frontends/atbm8830.c
index 8fe552e293ed..47248b868e38 100644
--- a/drivers/media/dvb-frontends/atbm8830.c
+++ b/drivers/media/dvb-frontends/atbm8830.c
@@ -297,9 +297,9 @@ static int atbm8830_set_fe(struct dvb_frontend *fe)
297 return 0; 297 return 0;
298} 298}
299 299
300static int atbm8830_get_fe(struct dvb_frontend *fe) 300static int atbm8830_get_fe(struct dvb_frontend *fe,
301 struct dtv_frontend_properties *c)
301{ 302{
302 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
303 dprintk("%s\n", __func__); 303 dprintk("%s\n", __func__);
304 304
305 /* TODO: get real readings from device */ 305 /* TODO: get real readings from device */
diff --git a/drivers/media/dvb-frontends/au8522.h b/drivers/media/dvb-frontends/au8522.h
index dde61582c158..78bf3f73e58d 100644
--- a/drivers/media/dvb-frontends/au8522.h
+++ b/drivers/media/dvb-frontends/au8522.h
@@ -89,5 +89,4 @@ enum au8522_audio_input {
89 AU8522_AUDIO_NONE, 89 AU8522_AUDIO_NONE,
90 AU8522_AUDIO_SIF, 90 AU8522_AUDIO_SIF,
91}; 91};
92
93#endif /* __AU8522_H__ */ 92#endif /* __AU8522_H__ */
diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c
index 73612c5353d1..add246382806 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -763,9 +763,10 @@ static int au8522_probe(struct i2c_client *client,
763 v4l2_i2c_subdev_init(sd, client, &au8522_ops); 763 v4l2_i2c_subdev_init(sd, client, &au8522_ops);
764#if defined(CONFIG_MEDIA_CONTROLLER) 764#if defined(CONFIG_MEDIA_CONTROLLER)
765 765
766 state->pads[AU8522_PAD_INPUT].flags = MEDIA_PAD_FL_SINK; 766 state->pads[DEMOD_PAD_IF_INPUT].flags = MEDIA_PAD_FL_SINK;
767 state->pads[AU8522_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE; 767 state->pads[DEMOD_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
768 state->pads[AU8522_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE; 768 state->pads[DEMOD_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
769 state->pads[DEMOD_PAD_AUDIO_OUT].flags = MEDIA_PAD_FL_SOURCE;
769 sd->entity.function = MEDIA_ENT_F_ATV_DECODER; 770 sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
770 771
771 ret = media_entity_pads_init(&sd->entity, ARRAY_SIZE(state->pads), 772 ret = media_entity_pads_init(&sd->entity, ARRAY_SIZE(state->pads),
diff --git a/drivers/media/dvb-frontends/au8522_dig.c b/drivers/media/dvb-frontends/au8522_dig.c
index 6c1e97640f3f..e676b9461a59 100644
--- a/drivers/media/dvb-frontends/au8522_dig.c
+++ b/drivers/media/dvb-frontends/au8522_dig.c
@@ -816,9 +816,9 @@ static int au8522_read_ber(struct dvb_frontend *fe, u32 *ber)
816 return au8522_read_ucblocks(fe, ber); 816 return au8522_read_ucblocks(fe, ber);
817} 817}
818 818
819static int au8522_get_frontend(struct dvb_frontend *fe) 819static int au8522_get_frontend(struct dvb_frontend *fe,
820 struct dtv_frontend_properties *c)
820{ 821{
821 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
822 struct au8522_state *state = fe->demodulator_priv; 822 struct au8522_state *state = fe->demodulator_priv;
823 823
824 c->frequency = state->current_frequency; 824 c->frequency = state->current_frequency;
diff --git a/drivers/media/dvb-frontends/au8522_priv.h b/drivers/media/dvb-frontends/au8522_priv.h
index 404a0cb0ed8d..f5a9438f6ce5 100644
--- a/drivers/media/dvb-frontends/au8522_priv.h
+++ b/drivers/media/dvb-frontends/au8522_priv.h
@@ -30,6 +30,7 @@
30#include <linux/videodev2.h> 30#include <linux/videodev2.h>
31#include <media/v4l2-device.h> 31#include <media/v4l2-device.h>
32#include <media/v4l2-ctrls.h> 32#include <media/v4l2-ctrls.h>
33#include <media/v4l2-mc.h>
33#include <linux/i2c.h> 34#include <linux/i2c.h>
34#include "dvb_frontend.h" 35#include "dvb_frontend.h"
35#include "au8522.h" 36#include "au8522.h"
@@ -39,14 +40,6 @@
39#define AU8522_DIGITAL_MODE 1 40#define AU8522_DIGITAL_MODE 1
40#define AU8522_SUSPEND_MODE 2 41#define AU8522_SUSPEND_MODE 2
41 42
42enum au8522_media_pads {
43 AU8522_PAD_INPUT,
44 AU8522_PAD_VID_OUT,
45 AU8522_PAD_VBI_OUT,
46
47 AU8522_NUM_PADS
48};
49
50struct au8522_state { 43struct au8522_state {
51 struct i2c_client *c; 44 struct i2c_client *c;
52 struct i2c_adapter *i2c; 45 struct i2c_adapter *i2c;
@@ -78,7 +71,7 @@ struct au8522_state {
78 struct v4l2_ctrl_handler hdl; 71 struct v4l2_ctrl_handler hdl;
79 72
80#ifdef CONFIG_MEDIA_CONTROLLER 73#ifdef CONFIG_MEDIA_CONTROLLER
81 struct media_pad pads[AU8522_NUM_PADS]; 74 struct media_pad pads[DEMOD_NUM_PADS];
82#endif 75#endif
83}; 76};
84 77
diff --git a/drivers/media/dvb-frontends/bcm3510.c b/drivers/media/dvb-frontends/bcm3510.c
index d30275f27644..bb698839e477 100644
--- a/drivers/media/dvb-frontends/bcm3510.c
+++ b/drivers/media/dvb-frontends/bcm3510.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2001-5, B2C2 inc. 4 * Copyright (C) 2001-5, B2C2 inc.
5 * 5 *
6 * GPL/Linux driver written by Patrick Boettcher <patrick.boettcher@desy.de> 6 * GPL/Linux driver written by Patrick Boettcher <patrick.boettcher@posteo.de>
7 * 7 *
8 * This driver is "hard-coded" to be used with the 1st generation of 8 * This driver is "hard-coded" to be used with the 1st generation of
9 * Technisat/B2C2's Air2PC ATSC PCI/USB cards/boxes. The pll-programming 9 * Technisat/B2C2's Air2PC ATSC PCI/USB cards/boxes. The pll-programming
@@ -865,5 +865,5 @@ static struct dvb_frontend_ops bcm3510_ops = {
865}; 865};
866 866
867MODULE_DESCRIPTION("Broadcom BCM3510 ATSC (8VSB/16VSB & ITU J83 AnnexB FEC QAM64/256) demodulator driver"); 867MODULE_DESCRIPTION("Broadcom BCM3510 ATSC (8VSB/16VSB & ITU J83 AnnexB FEC QAM64/256) demodulator driver");
868MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 868MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
869MODULE_LICENSE("GPL"); 869MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/bcm3510.h b/drivers/media/dvb-frontends/bcm3510.h
index ff66492fb940..961c2eb87c68 100644
--- a/drivers/media/dvb-frontends/bcm3510.h
+++ b/drivers/media/dvb-frontends/bcm3510.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2001-5, B2C2 inc. 4 * Copyright (C) 2001-5, B2C2 inc.
5 * 5 *
6 * GPL/Linux driver written by Patrick Boettcher <patrick.boettcher@desy.de> 6 * GPL/Linux driver written by Patrick Boettcher <patrick.boettcher@posteo.de>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 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 9 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/media/dvb-frontends/bcm3510_priv.h b/drivers/media/dvb-frontends/bcm3510_priv.h
index 3bb1bc2a04f0..67f24686c31b 100644
--- a/drivers/media/dvb-frontends/bcm3510_priv.h
+++ b/drivers/media/dvb-frontends/bcm3510_priv.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2001-5, B2C2 inc. 4 * Copyright (C) 2001-5, B2C2 inc.
5 * 5 *
6 * GPL/Linux driver written by Patrick Boettcher <patrick.boettcher@desy.de> 6 * GPL/Linux driver written by Patrick Boettcher <patrick.boettcher@posteo.de>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 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 9 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/media/dvb-frontends/cx22700.c b/drivers/media/dvb-frontends/cx22700.c
index fd033cca6e11..5cad925609e0 100644
--- a/drivers/media/dvb-frontends/cx22700.c
+++ b/drivers/media/dvb-frontends/cx22700.c
@@ -345,9 +345,9 @@ static int cx22700_set_frontend(struct dvb_frontend *fe)
345 return 0; 345 return 0;
346} 346}
347 347
348static int cx22700_get_frontend(struct dvb_frontend *fe) 348static int cx22700_get_frontend(struct dvb_frontend *fe,
349 struct dtv_frontend_properties *c)
349{ 350{
350 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
351 struct cx22700_state* state = fe->demodulator_priv; 351 struct cx22700_state* state = fe->demodulator_priv;
352 u8 reg09 = cx22700_readreg (state, 0x09); 352 u8 reg09 = cx22700_readreg (state, 0x09);
353 353
diff --git a/drivers/media/dvb-frontends/cx22702.c b/drivers/media/dvb-frontends/cx22702.c
index d2d06dcd7683..c0e54c59cccf 100644
--- a/drivers/media/dvb-frontends/cx22702.c
+++ b/drivers/media/dvb-frontends/cx22702.c
@@ -562,9 +562,9 @@ static int cx22702_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
562 return 0; 562 return 0;
563} 563}
564 564
565static int cx22702_get_frontend(struct dvb_frontend *fe) 565static int cx22702_get_frontend(struct dvb_frontend *fe,
566 struct dtv_frontend_properties *c)
566{ 567{
567 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
568 struct cx22702_state *state = fe->demodulator_priv; 568 struct cx22702_state *state = fe->demodulator_priv;
569 569
570 u8 reg0C = cx22702_readreg(state, 0x0C); 570 u8 reg0C = cx22702_readreg(state, 0x0C);
diff --git a/drivers/media/dvb-frontends/cx24110.c b/drivers/media/dvb-frontends/cx24110.c
index cb36475e322b..6cb81ec12847 100644
--- a/drivers/media/dvb-frontends/cx24110.c
+++ b/drivers/media/dvb-frontends/cx24110.c
@@ -550,9 +550,9 @@ static int cx24110_set_frontend(struct dvb_frontend *fe)
550 return 0; 550 return 0;
551} 551}
552 552
553static int cx24110_get_frontend(struct dvb_frontend *fe) 553static int cx24110_get_frontend(struct dvb_frontend *fe,
554 struct dtv_frontend_properties *p)
554{ 555{
555 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
556 struct cx24110_state *state = fe->demodulator_priv; 556 struct cx24110_state *state = fe->demodulator_priv;
557 s32 afc; unsigned sclk; 557 s32 afc; unsigned sclk;
558 558
diff --git a/drivers/media/dvb-frontends/cx24117.c b/drivers/media/dvb-frontends/cx24117.c
index 5f77bc80a896..a3f7eb4e609d 100644
--- a/drivers/media/dvb-frontends/cx24117.c
+++ b/drivers/media/dvb-frontends/cx24117.c
@@ -1560,10 +1560,10 @@ static int cx24117_get_algo(struct dvb_frontend *fe)
1560 return DVBFE_ALGO_HW; 1560 return DVBFE_ALGO_HW;
1561} 1561}
1562 1562
1563static int cx24117_get_frontend(struct dvb_frontend *fe) 1563static int cx24117_get_frontend(struct dvb_frontend *fe,
1564 struct dtv_frontend_properties *c)
1564{ 1565{
1565 struct cx24117_state *state = fe->demodulator_priv; 1566 struct cx24117_state *state = fe->demodulator_priv;
1566 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
1567 struct cx24117_cmd cmd; 1567 struct cx24117_cmd cmd;
1568 u8 reg, st, inv; 1568 u8 reg, st, inv;
1569 int ret, idx; 1569 int ret, idx;
diff --git a/drivers/media/dvb-frontends/cx24120.c b/drivers/media/dvb-frontends/cx24120.c
index 3b0ef52bb834..066ee387bf25 100644
--- a/drivers/media/dvb-frontends/cx24120.c
+++ b/drivers/media/dvb-frontends/cx24120.c
@@ -1502,16 +1502,18 @@ static int cx24120_sleep(struct dvb_frontend *fe)
1502 return 0; 1502 return 0;
1503} 1503}
1504 1504
1505static int cx24120_get_frontend(struct dvb_frontend *fe) 1505static int cx24120_get_frontend(struct dvb_frontend *fe,
1506 struct dtv_frontend_properties *c)
1506{ 1507{
1507 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
1508 struct cx24120_state *state = fe->demodulator_priv; 1508 struct cx24120_state *state = fe->demodulator_priv;
1509 u8 freq1, freq2, freq3; 1509 u8 freq1, freq2, freq3;
1510 int status;
1510 1511
1511 dev_dbg(&state->i2c->dev, "\n"); 1512 dev_dbg(&state->i2c->dev, "\n");
1512 1513
1513 /* don't return empty data if we're not tuned in */ 1514 /* don't return empty data if we're not tuned in */
1514 if ((state->fe_status & FE_HAS_LOCK) == 0) 1515 status = cx24120_readreg(state, CX24120_REG_STATUS);
1516 if (!(status & CX24120_HAS_LOCK))
1515 return 0; 1517 return 0;
1516 1518
1517 /* Get frequency */ 1519 /* Get frequency */
diff --git a/drivers/media/dvb-frontends/cx24123.c b/drivers/media/dvb-frontends/cx24123.c
index 0fe7fb11124b..113b0949408a 100644
--- a/drivers/media/dvb-frontends/cx24123.c
+++ b/drivers/media/dvb-frontends/cx24123.c
@@ -945,9 +945,9 @@ static int cx24123_set_frontend(struct dvb_frontend *fe)
945 return 0; 945 return 0;
946} 946}
947 947
948static int cx24123_get_frontend(struct dvb_frontend *fe) 948static int cx24123_get_frontend(struct dvb_frontend *fe,
949 struct dtv_frontend_properties *p)
949{ 950{
950 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
951 struct cx24123_state *state = fe->demodulator_priv; 951 struct cx24123_state *state = fe->demodulator_priv;
952 952
953 dprintk("\n"); 953 dprintk("\n");
diff --git a/drivers/media/dvb-frontends/cxd2820r_c.c b/drivers/media/dvb-frontends/cxd2820r_c.c
index 42fad6aa3958..a674a6312c38 100644
--- a/drivers/media/dvb-frontends/cxd2820r_c.c
+++ b/drivers/media/dvb-frontends/cxd2820r_c.c
@@ -101,10 +101,10 @@ error:
101 return ret; 101 return ret;
102} 102}
103 103
104int cxd2820r_get_frontend_c(struct dvb_frontend *fe) 104int cxd2820r_get_frontend_c(struct dvb_frontend *fe,
105 struct dtv_frontend_properties *c)
105{ 106{
106 struct cxd2820r_priv *priv = fe->demodulator_priv; 107 struct cxd2820r_priv *priv = fe->demodulator_priv;
107 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
108 int ret; 108 int ret;
109 u8 buf[2]; 109 u8 buf[2];
110 110
diff --git a/drivers/media/dvb-frontends/cxd2820r_core.c b/drivers/media/dvb-frontends/cxd2820r_core.c
index 24a457d9d803..314d3b8c1080 100644
--- a/drivers/media/dvb-frontends/cxd2820r_core.c
+++ b/drivers/media/dvb-frontends/cxd2820r_core.c
@@ -313,7 +313,8 @@ static int cxd2820r_read_status(struct dvb_frontend *fe, enum fe_status *status)
313 return ret; 313 return ret;
314} 314}
315 315
316static int cxd2820r_get_frontend(struct dvb_frontend *fe) 316static int cxd2820r_get_frontend(struct dvb_frontend *fe,
317 struct dtv_frontend_properties *p)
317{ 318{
318 struct cxd2820r_priv *priv = fe->demodulator_priv; 319 struct cxd2820r_priv *priv = fe->demodulator_priv;
319 int ret; 320 int ret;
@@ -326,13 +327,13 @@ static int cxd2820r_get_frontend(struct dvb_frontend *fe)
326 327
327 switch (fe->dtv_property_cache.delivery_system) { 328 switch (fe->dtv_property_cache.delivery_system) {
328 case SYS_DVBT: 329 case SYS_DVBT:
329 ret = cxd2820r_get_frontend_t(fe); 330 ret = cxd2820r_get_frontend_t(fe, p);
330 break; 331 break;
331 case SYS_DVBT2: 332 case SYS_DVBT2:
332 ret = cxd2820r_get_frontend_t2(fe); 333 ret = cxd2820r_get_frontend_t2(fe, p);
333 break; 334 break;
334 case SYS_DVBC_ANNEX_A: 335 case SYS_DVBC_ANNEX_A:
335 ret = cxd2820r_get_frontend_c(fe); 336 ret = cxd2820r_get_frontend_c(fe, p);
336 break; 337 break;
337 default: 338 default:
338 ret = -EINVAL; 339 ret = -EINVAL;
@@ -606,8 +607,7 @@ static int cxd2820r_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
606static int cxd2820r_gpio_direction_output(struct gpio_chip *chip, unsigned nr, 607static int cxd2820r_gpio_direction_output(struct gpio_chip *chip, unsigned nr,
607 int val) 608 int val)
608{ 609{
609 struct cxd2820r_priv *priv = 610 struct cxd2820r_priv *priv = gpiochip_get_data(chip);
610 container_of(chip, struct cxd2820r_priv, gpio_chip);
611 u8 gpio[GPIO_COUNT]; 611 u8 gpio[GPIO_COUNT];
612 612
613 dev_dbg(&priv->i2c->dev, "%s: nr=%d val=%d\n", __func__, nr, val); 613 dev_dbg(&priv->i2c->dev, "%s: nr=%d val=%d\n", __func__, nr, val);
@@ -620,8 +620,7 @@ static int cxd2820r_gpio_direction_output(struct gpio_chip *chip, unsigned nr,
620 620
621static void cxd2820r_gpio_set(struct gpio_chip *chip, unsigned nr, int val) 621static void cxd2820r_gpio_set(struct gpio_chip *chip, unsigned nr, int val)
622{ 622{
623 struct cxd2820r_priv *priv = 623 struct cxd2820r_priv *priv = gpiochip_get_data(chip);
624 container_of(chip, struct cxd2820r_priv, gpio_chip);
625 u8 gpio[GPIO_COUNT]; 624 u8 gpio[GPIO_COUNT];
626 625
627 dev_dbg(&priv->i2c->dev, "%s: nr=%d val=%d\n", __func__, nr, val); 626 dev_dbg(&priv->i2c->dev, "%s: nr=%d val=%d\n", __func__, nr, val);
@@ -636,8 +635,7 @@ static void cxd2820r_gpio_set(struct gpio_chip *chip, unsigned nr, int val)
636 635
637static int cxd2820r_gpio_get(struct gpio_chip *chip, unsigned nr) 636static int cxd2820r_gpio_get(struct gpio_chip *chip, unsigned nr)
638{ 637{
639 struct cxd2820r_priv *priv = 638 struct cxd2820r_priv *priv = gpiochip_get_data(chip);
640 container_of(chip, struct cxd2820r_priv, gpio_chip);
641 639
642 dev_dbg(&priv->i2c->dev, "%s: nr=%d\n", __func__, nr); 640 dev_dbg(&priv->i2c->dev, "%s: nr=%d\n", __func__, nr);
643 641
@@ -731,7 +729,7 @@ struct dvb_frontend *cxd2820r_attach(const struct cxd2820r_config *cfg,
731 priv->gpio_chip.base = -1; /* dynamic allocation */ 729 priv->gpio_chip.base = -1; /* dynamic allocation */
732 priv->gpio_chip.ngpio = GPIO_COUNT; 730 priv->gpio_chip.ngpio = GPIO_COUNT;
733 priv->gpio_chip.can_sleep = 1; 731 priv->gpio_chip.can_sleep = 1;
734 ret = gpiochip_add(&priv->gpio_chip); 732 ret = gpiochip_add_data(&priv->gpio_chip, priv);
735 if (ret) 733 if (ret)
736 goto error; 734 goto error;
737 735
diff --git a/drivers/media/dvb-frontends/cxd2820r_priv.h b/drivers/media/dvb-frontends/cxd2820r_priv.h
index a0d53f01a8bf..e31c48e53097 100644
--- a/drivers/media/dvb-frontends/cxd2820r_priv.h
+++ b/drivers/media/dvb-frontends/cxd2820r_priv.h
@@ -76,7 +76,8 @@ int cxd2820r_rd_reg(struct cxd2820r_priv *priv, u32 reg, u8 *val);
76 76
77/* cxd2820r_c.c */ 77/* cxd2820r_c.c */
78 78
79int cxd2820r_get_frontend_c(struct dvb_frontend *fe); 79int cxd2820r_get_frontend_c(struct dvb_frontend *fe,
80 struct dtv_frontend_properties *p);
80 81
81int cxd2820r_set_frontend_c(struct dvb_frontend *fe); 82int cxd2820r_set_frontend_c(struct dvb_frontend *fe);
82 83
@@ -99,7 +100,8 @@ int cxd2820r_get_tune_settings_c(struct dvb_frontend *fe,
99 100
100/* cxd2820r_t.c */ 101/* cxd2820r_t.c */
101 102
102int cxd2820r_get_frontend_t(struct dvb_frontend *fe); 103int cxd2820r_get_frontend_t(struct dvb_frontend *fe,
104 struct dtv_frontend_properties *p);
103 105
104int cxd2820r_set_frontend_t(struct dvb_frontend *fe); 106int cxd2820r_set_frontend_t(struct dvb_frontend *fe);
105 107
@@ -122,7 +124,8 @@ int cxd2820r_get_tune_settings_t(struct dvb_frontend *fe,
122 124
123/* cxd2820r_t2.c */ 125/* cxd2820r_t2.c */
124 126
125int cxd2820r_get_frontend_t2(struct dvb_frontend *fe); 127int cxd2820r_get_frontend_t2(struct dvb_frontend *fe,
128 struct dtv_frontend_properties *p);
126 129
127int cxd2820r_set_frontend_t2(struct dvb_frontend *fe); 130int cxd2820r_set_frontend_t2(struct dvb_frontend *fe);
128 131
diff --git a/drivers/media/dvb-frontends/cxd2820r_t.c b/drivers/media/dvb-frontends/cxd2820r_t.c
index 21abf1b4ed4d..75ce7d8ded00 100644
--- a/drivers/media/dvb-frontends/cxd2820r_t.c
+++ b/drivers/media/dvb-frontends/cxd2820r_t.c
@@ -138,10 +138,10 @@ error:
138 return ret; 138 return ret;
139} 139}
140 140
141int cxd2820r_get_frontend_t(struct dvb_frontend *fe) 141int cxd2820r_get_frontend_t(struct dvb_frontend *fe,
142 struct dtv_frontend_properties *c)
142{ 143{
143 struct cxd2820r_priv *priv = fe->demodulator_priv; 144 struct cxd2820r_priv *priv = fe->demodulator_priv;
144 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
145 int ret; 145 int ret;
146 u8 buf[2]; 146 u8 buf[2];
147 147
diff --git a/drivers/media/dvb-frontends/cxd2820r_t2.c b/drivers/media/dvb-frontends/cxd2820r_t2.c
index 4e028b41c0d5..704475676234 100644
--- a/drivers/media/dvb-frontends/cxd2820r_t2.c
+++ b/drivers/media/dvb-frontends/cxd2820r_t2.c
@@ -23,8 +23,8 @@
23 23
24int cxd2820r_set_frontend_t2(struct dvb_frontend *fe) 24int cxd2820r_set_frontend_t2(struct dvb_frontend *fe)
25{ 25{
26 struct cxd2820r_priv *priv = fe->demodulator_priv;
27 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 26 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
27 struct cxd2820r_priv *priv = fe->demodulator_priv;
28 int ret, i, bw_i; 28 int ret, i, bw_i;
29 u32 if_freq, if_ctl; 29 u32 if_freq, if_ctl;
30 u64 num; 30 u64 num;
@@ -169,10 +169,10 @@ error:
169 169
170} 170}
171 171
172int cxd2820r_get_frontend_t2(struct dvb_frontend *fe) 172int cxd2820r_get_frontend_t2(struct dvb_frontend *fe,
173 struct dtv_frontend_properties *c)
173{ 174{
174 struct cxd2820r_priv *priv = fe->demodulator_priv; 175 struct cxd2820r_priv *priv = fe->demodulator_priv;
175 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
176 int ret; 176 int ret;
177 u8 buf[2]; 177 u8 buf[2];
178 178
diff --git a/drivers/media/dvb-frontends/cxd2841er.c b/drivers/media/dvb-frontends/cxd2841er.c
index fdffb2f0ded8..900186ba8e62 100644
--- a/drivers/media/dvb-frontends/cxd2841er.c
+++ b/drivers/media/dvb-frontends/cxd2841er.c
@@ -2090,13 +2090,13 @@ static int cxd2841er_sleep_tc_to_active_c(struct cxd2841er_priv *priv,
2090 return 0; 2090 return 0;
2091} 2091}
2092 2092
2093static int cxd2841er_get_frontend(struct dvb_frontend *fe) 2093static int cxd2841er_get_frontend(struct dvb_frontend *fe,
2094 struct dtv_frontend_properties *p)
2094{ 2095{
2095 enum fe_status status = 0; 2096 enum fe_status status = 0;
2096 u16 strength = 0, snr = 0; 2097 u16 strength = 0, snr = 0;
2097 u32 errors = 0, ber = 0; 2098 u32 errors = 0, ber = 0;
2098 struct cxd2841er_priv *priv = fe->demodulator_priv; 2099 struct cxd2841er_priv *priv = fe->demodulator_priv;
2099 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
2100 2100
2101 dev_dbg(&priv->i2c->dev, "%s()\n", __func__); 2101 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
2102 if (priv->state == STATE_ACTIVE_S) 2102 if (priv->state == STATE_ACTIVE_S)
diff --git a/drivers/media/dvb-frontends/dib0070.c b/drivers/media/dvb-frontends/dib0070.c
index 0b8fb5dd1889..ee7d66997ccd 100644
--- a/drivers/media/dvb-frontends/dib0070.c
+++ b/drivers/media/dvb-frontends/dib0070.c
@@ -774,6 +774,6 @@ free_mem:
774} 774}
775EXPORT_SYMBOL(dib0070_attach); 775EXPORT_SYMBOL(dib0070_attach);
776 776
777MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>"); 777MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
778MODULE_DESCRIPTION("Driver for the DiBcom 0070 base-band RF Tuner"); 778MODULE_DESCRIPTION("Driver for the DiBcom 0070 base-band RF Tuner");
779MODULE_LICENSE("GPL"); 779MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/dib0090.c b/drivers/media/dvb-frontends/dib0090.c
index 47cb72243b9d..dc2d41e144fd 100644
--- a/drivers/media/dvb-frontends/dib0090.c
+++ b/drivers/media/dvb-frontends/dib0090.c
@@ -1115,9 +1115,15 @@ void dib0090_pwm_gain_reset(struct dvb_frontend *fe)
1115 dib0090_set_bbramp_pwm(state, bb_ramp); 1115 dib0090_set_bbramp_pwm(state, bb_ramp);
1116 1116
1117 /* activate the ramp generator using PWM control */ 1117 /* activate the ramp generator using PWM control */
1118 dprintk("ramp RF gain = %d BAND = %s version = %d", state->rf_ramp[0], (state->current_band == BAND_CBAND) ? "CBAND" : "NOT CBAND", state->identity.version & 0x1f); 1118 if (state->rf_ramp)
1119 1119 dprintk("ramp RF gain = %d BAND = %s version = %d",
1120 if ((state->rf_ramp[0] == 0) || (state->current_band == BAND_CBAND && (state->identity.version & 0x1f) <= P1D_E_F)) { 1120 state->rf_ramp[0],
1121 (state->current_band == BAND_CBAND) ? "CBAND" : "NOT CBAND",
1122 state->identity.version & 0x1f);
1123
1124 if (rf_ramp && ((state->rf_ramp[0] == 0) ||
1125 (state->current_band == BAND_CBAND &&
1126 (state->identity.version & 0x1f) <= P1D_E_F))) {
1121 dprintk("DE-Engage mux for direct gain reg control"); 1127 dprintk("DE-Engage mux for direct gain reg control");
1122 en_pwm_rf_mux = 0; 1128 en_pwm_rf_mux = 0;
1123 } else 1129 } else
@@ -2669,7 +2675,7 @@ free_mem:
2669} 2675}
2670EXPORT_SYMBOL(dib0090_fw_register); 2676EXPORT_SYMBOL(dib0090_fw_register);
2671 2677
2672MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>"); 2678MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
2673MODULE_AUTHOR("Olivier Grenie <olivier.grenie@dibcom.fr>"); 2679MODULE_AUTHOR("Olivier Grenie <olivier.grenie@parrot.com>");
2674MODULE_DESCRIPTION("Driver for the DiBcom 0090 base-band RF Tuner"); 2680MODULE_DESCRIPTION("Driver for the DiBcom 0090 base-band RF Tuner");
2675MODULE_LICENSE("GPL"); 2681MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
index 6ae9899b5b45..d5dfafb4ef13 100644
--- a/drivers/media/dvb-frontends/dib3000.h
+++ b/drivers/media/dvb-frontends/dib3000.h
@@ -2,11 +2,11 @@
2 * public header file of the frontend drivers for mobile DVB-T demodulators 2 * public header file of the frontend drivers for mobile DVB-T demodulators
3 * DiBcom 3000M-B and DiBcom 3000P/M-C (http://www.dibcom.fr/) 3 * DiBcom 3000M-B and DiBcom 3000P/M-C (http://www.dibcom.fr/)
4 * 4 *
5 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 5 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
6 * 6 *
7 * based on GPL code from DibCom, which has 7 * based on GPL code from DibCom, which has
8 * 8 *
9 * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr) 9 * Copyright (C) 2004 Amaury Demol for DiBcom
10 * 10 *
11 * This program is free software; you can redistribute it and/or 11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as 12 * modify it under the terms of the GNU General Public License as
@@ -14,7 +14,7 @@
14 * 14 *
15 * Acknowledgements 15 * Acknowledgements
16 * 16 *
17 * Amaury Demol (ademol@dibcom.fr) from DiBcom for providing specs and driver 17 * Amaury Demol from DiBcom for providing specs and driver
18 * sources, on which this driver (and the dvb-dibusb) are based. 18 * sources, on which this driver (and the dvb-dibusb) are based.
19 * 19 *
20 * see Documentation/dvb/README.dvb-usb for more information 20 * see Documentation/dvb/README.dvb-usb for more information
diff --git a/drivers/media/dvb-frontends/dib3000mb.c b/drivers/media/dvb-frontends/dib3000mb.c
index 7a61172d0d45..6821ecb53d63 100644
--- a/drivers/media/dvb-frontends/dib3000mb.c
+++ b/drivers/media/dvb-frontends/dib3000mb.c
@@ -2,11 +2,11 @@
2 * Frontend driver for mobile DVB-T demodulator DiBcom 3000M-B 2 * Frontend driver for mobile DVB-T demodulator DiBcom 3000M-B
3 * DiBcom (http://www.dibcom.fr/) 3 * DiBcom (http://www.dibcom.fr/)
4 * 4 *
5 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 5 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
6 * 6 *
7 * based on GPL code from DibCom, which has 7 * based on GPL code from DibCom, which has
8 * 8 *
9 * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr) 9 * Copyright (C) 2004 Amaury Demol for DiBcom
10 * 10 *
11 * This program is free software; you can redistribute it and/or 11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as 12 * modify it under the terms of the GNU General Public License as
@@ -14,7 +14,7 @@
14 * 14 *
15 * Acknowledgements 15 * Acknowledgements
16 * 16 *
17 * Amaury Demol (ademol@dibcom.fr) from DiBcom for providing specs and driver 17 * Amaury Demol from DiBcom for providing specs and driver
18 * sources, on which this driver (and the dvb-dibusb) are based. 18 * sources, on which this driver (and the dvb-dibusb) are based.
19 * 19 *
20 * see Documentation/dvb/README.dvb-usb for more information 20 * see Documentation/dvb/README.dvb-usb for more information
@@ -36,7 +36,7 @@
36/* Version information */ 36/* Version information */
37#define DRIVER_VERSION "0.1" 37#define DRIVER_VERSION "0.1"
38#define DRIVER_DESC "DiBcom 3000M-B DVB-T demodulator" 38#define DRIVER_DESC "DiBcom 3000M-B DVB-T demodulator"
39#define DRIVER_AUTHOR "Patrick Boettcher, patrick.boettcher@desy.de" 39#define DRIVER_AUTHOR "Patrick Boettcher, patrick.boettcher@posteo.de"
40 40
41static int debug; 41static int debug;
42module_param(debug, int, 0644); 42module_param(debug, int, 0644);
@@ -112,7 +112,8 @@ static u16 dib3000_seq[2][2][2] = /* fft,gua, inv */
112 } 112 }
113 }; 113 };
114 114
115static int dib3000mb_get_frontend(struct dvb_frontend* fe); 115static int dib3000mb_get_frontend(struct dvb_frontend* fe,
116 struct dtv_frontend_properties *c);
116 117
117static int dib3000mb_set_frontend(struct dvb_frontend *fe, int tuner) 118static int dib3000mb_set_frontend(struct dvb_frontend *fe, int tuner)
118{ 119{
@@ -359,7 +360,7 @@ static int dib3000mb_set_frontend(struct dvb_frontend *fe, int tuner)
359 deb_setf("search_state after autosearch %d after %d checks\n",search_state,as_count); 360 deb_setf("search_state after autosearch %d after %d checks\n",search_state,as_count);
360 361
361 if (search_state == 1) { 362 if (search_state == 1) {
362 if (dib3000mb_get_frontend(fe) == 0) { 363 if (dib3000mb_get_frontend(fe, c) == 0) {
363 deb_setf("reading tuning data from frontend succeeded.\n"); 364 deb_setf("reading tuning data from frontend succeeded.\n");
364 return dib3000mb_set_frontend(fe, 0); 365 return dib3000mb_set_frontend(fe, 0);
365 } 366 }
@@ -450,9 +451,9 @@ static int dib3000mb_fe_init(struct dvb_frontend* fe, int mobile_mode)
450 return 0; 451 return 0;
451} 452}
452 453
453static int dib3000mb_get_frontend(struct dvb_frontend* fe) 454static int dib3000mb_get_frontend(struct dvb_frontend* fe,
455 struct dtv_frontend_properties *c)
454{ 456{
455 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
456 struct dib3000_state* state = fe->demodulator_priv; 457 struct dib3000_state* state = fe->demodulator_priv;
457 enum fe_code_rate *cr; 458 enum fe_code_rate *cr;
458 u16 tps_val; 459 u16 tps_val;
diff --git a/drivers/media/dvb-frontends/dib3000mb_priv.h b/drivers/media/dvb-frontends/dib3000mb_priv.h
index 9dc235aa44b7..0459d5c84314 100644
--- a/drivers/media/dvb-frontends/dib3000mb_priv.h
+++ b/drivers/media/dvb-frontends/dib3000mb_priv.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * dib3000mb_priv.h 2 * dib3000mb_priv.h
3 * 3 *
4 * Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@desy.de) 4 * Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@posteo.de)
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 as 7 * modify it under the terms of the GNU General Public License as
diff --git a/drivers/media/dvb-frontends/dib3000mc.c b/drivers/media/dvb-frontends/dib3000mc.c
index 583d6b7fabed..da0f1dc5aaf7 100644
--- a/drivers/media/dvb-frontends/dib3000mc.c
+++ b/drivers/media/dvb-frontends/dib3000mc.c
@@ -2,7 +2,7 @@
2 * Driver for DiBcom DiB3000MC/P-demodulator. 2 * Driver for DiBcom DiB3000MC/P-demodulator.
3 * 3 *
4 * Copyright (C) 2004-7 DiBcom (http://www.dibcom.fr/) 4 * Copyright (C) 2004-7 DiBcom (http://www.dibcom.fr/)
5 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 5 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
6 * 6 *
7 * This code is partially based on the previous dib3000mc.c . 7 * This code is partially based on the previous dib3000mc.c .
8 * 8 *
@@ -636,9 +636,9 @@ struct i2c_adapter * dib3000mc_get_tuner_i2c_master(struct dvb_frontend *demod,
636 636
637EXPORT_SYMBOL(dib3000mc_get_tuner_i2c_master); 637EXPORT_SYMBOL(dib3000mc_get_tuner_i2c_master);
638 638
639static int dib3000mc_get_frontend(struct dvb_frontend* fe) 639static int dib3000mc_get_frontend(struct dvb_frontend* fe,
640 struct dtv_frontend_properties *fep)
640{ 641{
641 struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
642 struct dib3000mc_state *state = fe->demodulator_priv; 642 struct dib3000mc_state *state = fe->demodulator_priv;
643 u16 tps = dib3000mc_read_word(state,458); 643 u16 tps = dib3000mc_read_word(state,458);
644 644
@@ -726,7 +726,7 @@ static int dib3000mc_set_frontend(struct dvb_frontend *fe)
726 if (found == 0 || found == 1) 726 if (found == 0 || found == 1)
727 return 0; // no channel found 727 return 0; // no channel found
728 728
729 dib3000mc_get_frontend(fe); 729 dib3000mc_get_frontend(fe, fep);
730 } 730 }
731 731
732 ret = dib3000mc_tune(fe); 732 ret = dib3000mc_tune(fe);
@@ -939,6 +939,6 @@ static struct dvb_frontend_ops dib3000mc_ops = {
939 .read_ucblocks = dib3000mc_read_unc_blocks, 939 .read_ucblocks = dib3000mc_read_unc_blocks,
940}; 940};
941 941
942MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>"); 942MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
943MODULE_DESCRIPTION("Driver for the DiBcom 3000MC/P COFDM demodulator"); 943MODULE_DESCRIPTION("Driver for the DiBcom 3000MC/P COFDM demodulator");
944MODULE_LICENSE("GPL"); 944MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/dib3000mc.h b/drivers/media/dvb-frontends/dib3000mc.h
index 74816f793611..b37e69e6a58c 100644
--- a/drivers/media/dvb-frontends/dib3000mc.h
+++ b/drivers/media/dvb-frontends/dib3000mc.h
@@ -2,7 +2,7 @@
2 * Driver for DiBcom DiB3000MC/P-demodulator. 2 * Driver for DiBcom DiB3000MC/P-demodulator.
3 * 3 *
4 * Copyright (C) 2004-6 DiBcom (http://www.dibcom.fr/) 4 * Copyright (C) 2004-6 DiBcom (http://www.dibcom.fr/)
5 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher\@desy.de) 5 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
6 * 6 *
7 * This code is partially based on the previous dib3000mc.c . 7 * This code is partially based on the previous dib3000mc.c .
8 * 8 *
diff --git a/drivers/media/dvb-frontends/dib7000m.c b/drivers/media/dvb-frontends/dib7000m.c
index 35eb71fe3c2b..b3ddae8885ac 100644
--- a/drivers/media/dvb-frontends/dib7000m.c
+++ b/drivers/media/dvb-frontends/dib7000m.c
@@ -1151,9 +1151,9 @@ static int dib7000m_identify(struct dib7000m_state *state)
1151} 1151}
1152 1152
1153 1153
1154static int dib7000m_get_frontend(struct dvb_frontend* fe) 1154static int dib7000m_get_frontend(struct dvb_frontend* fe,
1155 struct dtv_frontend_properties *fep)
1155{ 1156{
1156 struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
1157 struct dib7000m_state *state = fe->demodulator_priv; 1157 struct dib7000m_state *state = fe->demodulator_priv;
1158 u16 tps = dib7000m_read_word(state,480); 1158 u16 tps = dib7000m_read_word(state,480);
1159 1159
@@ -1246,7 +1246,7 @@ static int dib7000m_set_frontend(struct dvb_frontend *fe)
1246 if (found == 0 || found == 1) 1246 if (found == 0 || found == 1)
1247 return 0; // no channel found 1247 return 0; // no channel found
1248 1248
1249 dib7000m_get_frontend(fe); 1249 dib7000m_get_frontend(fe, fep);
1250 } 1250 }
1251 1251
1252 ret = dib7000m_tune(fe); 1252 ret = dib7000m_tune(fe);
@@ -1465,6 +1465,6 @@ static struct dvb_frontend_ops dib7000m_ops = {
1465 .read_ucblocks = dib7000m_read_unc_blocks, 1465 .read_ucblocks = dib7000m_read_unc_blocks,
1466}; 1466};
1467 1467
1468MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>"); 1468MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
1469MODULE_DESCRIPTION("Driver for the DiBcom 7000MA/MB/PA/PB/MC COFDM demodulator"); 1469MODULE_DESCRIPTION("Driver for the DiBcom 7000MA/MB/PA/PB/MC COFDM demodulator");
1470MODULE_LICENSE("GPL"); 1470MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/dib7000p.c b/drivers/media/dvb-frontends/dib7000p.c
index 33be5d6b9e10..b861d4437f2a 100644
--- a/drivers/media/dvb-frontends/dib7000p.c
+++ b/drivers/media/dvb-frontends/dib7000p.c
@@ -1405,9 +1405,9 @@ static int dib7000p_identify(struct dib7000p_state *st)
1405 return 0; 1405 return 0;
1406} 1406}
1407 1407
1408static int dib7000p_get_frontend(struct dvb_frontend *fe) 1408static int dib7000p_get_frontend(struct dvb_frontend *fe,
1409 struct dtv_frontend_properties *fep)
1409{ 1410{
1410 struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
1411 struct dib7000p_state *state = fe->demodulator_priv; 1411 struct dib7000p_state *state = fe->demodulator_priv;
1412 u16 tps = dib7000p_read_word(state, 463); 1412 u16 tps = dib7000p_read_word(state, 463);
1413 1413
@@ -1540,7 +1540,7 @@ static int dib7000p_set_frontend(struct dvb_frontend *fe)
1540 if (found == 0 || found == 1) 1540 if (found == 0 || found == 1)
1541 return 0; 1541 return 0;
1542 1542
1543 dib7000p_get_frontend(fe); 1543 dib7000p_get_frontend(fe, fep);
1544 } 1544 }
1545 1545
1546 ret = dib7000p_tune(fe); 1546 ret = dib7000p_tune(fe);
@@ -2834,7 +2834,7 @@ static struct dvb_frontend_ops dib7000p_ops = {
2834 .read_ucblocks = dib7000p_read_unc_blocks, 2834 .read_ucblocks = dib7000p_read_unc_blocks,
2835}; 2835};
2836 2836
2837MODULE_AUTHOR("Olivier Grenie <ogrenie@dibcom.fr>"); 2837MODULE_AUTHOR("Olivier Grenie <olivie.grenie@parrot.com>");
2838MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>"); 2838MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
2839MODULE_DESCRIPTION("Driver for the DiBcom 7000PC COFDM demodulator"); 2839MODULE_DESCRIPTION("Driver for the DiBcom 7000PC COFDM demodulator");
2840MODULE_LICENSE("GPL"); 2840MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/dib8000.c b/drivers/media/dvb-frontends/dib8000.c
index 94c26270fff0..ddf9c44877a2 100644
--- a/drivers/media/dvb-frontends/dib8000.c
+++ b/drivers/media/dvb-frontends/dib8000.c
@@ -3382,14 +3382,15 @@ static int dib8000_sleep(struct dvb_frontend *fe)
3382 3382
3383static int dib8000_read_status(struct dvb_frontend *fe, enum fe_status *stat); 3383static int dib8000_read_status(struct dvb_frontend *fe, enum fe_status *stat);
3384 3384
3385static int dib8000_get_frontend(struct dvb_frontend *fe) 3385static int dib8000_get_frontend(struct dvb_frontend *fe,
3386 struct dtv_frontend_properties *c)
3386{ 3387{
3387 struct dib8000_state *state = fe->demodulator_priv; 3388 struct dib8000_state *state = fe->demodulator_priv;
3388 u16 i, val = 0; 3389 u16 i, val = 0;
3389 enum fe_status stat = 0; 3390 enum fe_status stat = 0;
3390 u8 index_frontend, sub_index_frontend; 3391 u8 index_frontend, sub_index_frontend;
3391 3392
3392 fe->dtv_property_cache.bandwidth_hz = 6000000; 3393 c->bandwidth_hz = 6000000;
3393 3394
3394 /* 3395 /*
3395 * If called to early, get_frontend makes dib8000_tune to either 3396 * If called to early, get_frontend makes dib8000_tune to either
@@ -3406,7 +3407,7 @@ static int dib8000_get_frontend(struct dvb_frontend *fe)
3406 if (stat&FE_HAS_SYNC) { 3407 if (stat&FE_HAS_SYNC) {
3407 dprintk("TMCC lock on the slave%i", index_frontend); 3408 dprintk("TMCC lock on the slave%i", index_frontend);
3408 /* synchronize the cache with the other frontends */ 3409 /* synchronize the cache with the other frontends */
3409 state->fe[index_frontend]->ops.get_frontend(state->fe[index_frontend]); 3410 state->fe[index_frontend]->ops.get_frontend(state->fe[index_frontend], c);
3410 for (sub_index_frontend = 0; (sub_index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[sub_index_frontend] != NULL); sub_index_frontend++) { 3411 for (sub_index_frontend = 0; (sub_index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[sub_index_frontend] != NULL); sub_index_frontend++) {
3411 if (sub_index_frontend != index_frontend) { 3412 if (sub_index_frontend != index_frontend) {
3412 state->fe[sub_index_frontend]->dtv_property_cache.isdbt_sb_mode = state->fe[index_frontend]->dtv_property_cache.isdbt_sb_mode; 3413 state->fe[sub_index_frontend]->dtv_property_cache.isdbt_sb_mode = state->fe[index_frontend]->dtv_property_cache.isdbt_sb_mode;
@@ -3426,57 +3427,57 @@ static int dib8000_get_frontend(struct dvb_frontend *fe)
3426 } 3427 }
3427 } 3428 }
3428 3429
3429 fe->dtv_property_cache.isdbt_sb_mode = dib8000_read_word(state, 508) & 0x1; 3430 c->isdbt_sb_mode = dib8000_read_word(state, 508) & 0x1;
3430 3431
3431 if (state->revision == 0x8090) 3432 if (state->revision == 0x8090)
3432 val = dib8000_read_word(state, 572); 3433 val = dib8000_read_word(state, 572);
3433 else 3434 else
3434 val = dib8000_read_word(state, 570); 3435 val = dib8000_read_word(state, 570);
3435 fe->dtv_property_cache.inversion = (val & 0x40) >> 6; 3436 c->inversion = (val & 0x40) >> 6;
3436 switch ((val & 0x30) >> 4) { 3437 switch ((val & 0x30) >> 4) {
3437 case 1: 3438 case 1:
3438 fe->dtv_property_cache.transmission_mode = TRANSMISSION_MODE_2K; 3439 c->transmission_mode = TRANSMISSION_MODE_2K;
3439 dprintk("dib8000_get_frontend: transmission mode 2K"); 3440 dprintk("dib8000_get_frontend: transmission mode 2K");
3440 break; 3441 break;
3441 case 2: 3442 case 2:
3442 fe->dtv_property_cache.transmission_mode = TRANSMISSION_MODE_4K; 3443 c->transmission_mode = TRANSMISSION_MODE_4K;
3443 dprintk("dib8000_get_frontend: transmission mode 4K"); 3444 dprintk("dib8000_get_frontend: transmission mode 4K");
3444 break; 3445 break;
3445 case 3: 3446 case 3:
3446 default: 3447 default:
3447 fe->dtv_property_cache.transmission_mode = TRANSMISSION_MODE_8K; 3448 c->transmission_mode = TRANSMISSION_MODE_8K;
3448 dprintk("dib8000_get_frontend: transmission mode 8K"); 3449 dprintk("dib8000_get_frontend: transmission mode 8K");
3449 break; 3450 break;
3450 } 3451 }
3451 3452
3452 switch (val & 0x3) { 3453 switch (val & 0x3) {
3453 case 0: 3454 case 0:
3454 fe->dtv_property_cache.guard_interval = GUARD_INTERVAL_1_32; 3455 c->guard_interval = GUARD_INTERVAL_1_32;
3455 dprintk("dib8000_get_frontend: Guard Interval = 1/32 "); 3456 dprintk("dib8000_get_frontend: Guard Interval = 1/32 ");
3456 break; 3457 break;
3457 case 1: 3458 case 1:
3458 fe->dtv_property_cache.guard_interval = GUARD_INTERVAL_1_16; 3459 c->guard_interval = GUARD_INTERVAL_1_16;
3459 dprintk("dib8000_get_frontend: Guard Interval = 1/16 "); 3460 dprintk("dib8000_get_frontend: Guard Interval = 1/16 ");
3460 break; 3461 break;
3461 case 2: 3462 case 2:
3462 dprintk("dib8000_get_frontend: Guard Interval = 1/8 "); 3463 dprintk("dib8000_get_frontend: Guard Interval = 1/8 ");
3463 fe->dtv_property_cache.guard_interval = GUARD_INTERVAL_1_8; 3464 c->guard_interval = GUARD_INTERVAL_1_8;
3464 break; 3465 break;
3465 case 3: 3466 case 3:
3466 dprintk("dib8000_get_frontend: Guard Interval = 1/4 "); 3467 dprintk("dib8000_get_frontend: Guard Interval = 1/4 ");
3467 fe->dtv_property_cache.guard_interval = GUARD_INTERVAL_1_4; 3468 c->guard_interval = GUARD_INTERVAL_1_4;
3468 break; 3469 break;
3469 } 3470 }
3470 3471
3471 val = dib8000_read_word(state, 505); 3472 val = dib8000_read_word(state, 505);
3472 fe->dtv_property_cache.isdbt_partial_reception = val & 1; 3473 c->isdbt_partial_reception = val & 1;
3473 dprintk("dib8000_get_frontend: partial_reception = %d ", fe->dtv_property_cache.isdbt_partial_reception); 3474 dprintk("dib8000_get_frontend: partial_reception = %d ", c->isdbt_partial_reception);
3474 3475
3475 for (i = 0; i < 3; i++) { 3476 for (i = 0; i < 3; i++) {
3476 int show; 3477 int show;
3477 3478
3478 val = dib8000_read_word(state, 493 + i) & 0x0f; 3479 val = dib8000_read_word(state, 493 + i) & 0x0f;
3479 fe->dtv_property_cache.layer[i].segment_count = val; 3480 c->layer[i].segment_count = val;
3480 3481
3481 if (val == 0 || val > 13) 3482 if (val == 0 || val > 13)
3482 show = 0; 3483 show = 0;
@@ -3485,41 +3486,41 @@ static int dib8000_get_frontend(struct dvb_frontend *fe)
3485 3486
3486 if (show) 3487 if (show)
3487 dprintk("dib8000_get_frontend: Layer %d segments = %d ", 3488 dprintk("dib8000_get_frontend: Layer %d segments = %d ",
3488 i, fe->dtv_property_cache.layer[i].segment_count); 3489 i, c->layer[i].segment_count);
3489 3490
3490 val = dib8000_read_word(state, 499 + i) & 0x3; 3491 val = dib8000_read_word(state, 499 + i) & 0x3;
3491 /* Interleaving can be 0, 1, 2 or 4 */ 3492 /* Interleaving can be 0, 1, 2 or 4 */
3492 if (val == 3) 3493 if (val == 3)
3493 val = 4; 3494 val = 4;
3494 fe->dtv_property_cache.layer[i].interleaving = val; 3495 c->layer[i].interleaving = val;
3495 if (show) 3496 if (show)
3496 dprintk("dib8000_get_frontend: Layer %d time_intlv = %d ", 3497 dprintk("dib8000_get_frontend: Layer %d time_intlv = %d ",
3497 i, fe->dtv_property_cache.layer[i].interleaving); 3498 i, c->layer[i].interleaving);
3498 3499
3499 val = dib8000_read_word(state, 481 + i); 3500 val = dib8000_read_word(state, 481 + i);
3500 switch (val & 0x7) { 3501 switch (val & 0x7) {
3501 case 1: 3502 case 1:
3502 fe->dtv_property_cache.layer[i].fec = FEC_1_2; 3503 c->layer[i].fec = FEC_1_2;
3503 if (show) 3504 if (show)
3504 dprintk("dib8000_get_frontend: Layer %d Code Rate = 1/2 ", i); 3505 dprintk("dib8000_get_frontend: Layer %d Code Rate = 1/2 ", i);
3505 break; 3506 break;
3506 case 2: 3507 case 2:
3507 fe->dtv_property_cache.layer[i].fec = FEC_2_3; 3508 c->layer[i].fec = FEC_2_3;
3508 if (show) 3509 if (show)
3509 dprintk("dib8000_get_frontend: Layer %d Code Rate = 2/3 ", i); 3510 dprintk("dib8000_get_frontend: Layer %d Code Rate = 2/3 ", i);
3510 break; 3511 break;
3511 case 3: 3512 case 3:
3512 fe->dtv_property_cache.layer[i].fec = FEC_3_4; 3513 c->layer[i].fec = FEC_3_4;
3513 if (show) 3514 if (show)
3514 dprintk("dib8000_get_frontend: Layer %d Code Rate = 3/4 ", i); 3515 dprintk("dib8000_get_frontend: Layer %d Code Rate = 3/4 ", i);
3515 break; 3516 break;
3516 case 5: 3517 case 5:
3517 fe->dtv_property_cache.layer[i].fec = FEC_5_6; 3518 c->layer[i].fec = FEC_5_6;
3518 if (show) 3519 if (show)
3519 dprintk("dib8000_get_frontend: Layer %d Code Rate = 5/6 ", i); 3520 dprintk("dib8000_get_frontend: Layer %d Code Rate = 5/6 ", i);
3520 break; 3521 break;
3521 default: 3522 default:
3522 fe->dtv_property_cache.layer[i].fec = FEC_7_8; 3523 c->layer[i].fec = FEC_7_8;
3523 if (show) 3524 if (show)
3524 dprintk("dib8000_get_frontend: Layer %d Code Rate = 7/8 ", i); 3525 dprintk("dib8000_get_frontend: Layer %d Code Rate = 7/8 ", i);
3525 break; 3526 break;
@@ -3528,23 +3529,23 @@ static int dib8000_get_frontend(struct dvb_frontend *fe)
3528 val = dib8000_read_word(state, 487 + i); 3529 val = dib8000_read_word(state, 487 + i);
3529 switch (val & 0x3) { 3530 switch (val & 0x3) {
3530 case 0: 3531 case 0:
3531 fe->dtv_property_cache.layer[i].modulation = DQPSK; 3532 c->layer[i].modulation = DQPSK;
3532 if (show) 3533 if (show)
3533 dprintk("dib8000_get_frontend: Layer %d DQPSK ", i); 3534 dprintk("dib8000_get_frontend: Layer %d DQPSK ", i);
3534 break; 3535 break;
3535 case 1: 3536 case 1:
3536 fe->dtv_property_cache.layer[i].modulation = QPSK; 3537 c->layer[i].modulation = QPSK;
3537 if (show) 3538 if (show)
3538 dprintk("dib8000_get_frontend: Layer %d QPSK ", i); 3539 dprintk("dib8000_get_frontend: Layer %d QPSK ", i);
3539 break; 3540 break;
3540 case 2: 3541 case 2:
3541 fe->dtv_property_cache.layer[i].modulation = QAM_16; 3542 c->layer[i].modulation = QAM_16;
3542 if (show) 3543 if (show)
3543 dprintk("dib8000_get_frontend: Layer %d QAM16 ", i); 3544 dprintk("dib8000_get_frontend: Layer %d QAM16 ", i);
3544 break; 3545 break;
3545 case 3: 3546 case 3:
3546 default: 3547 default:
3547 fe->dtv_property_cache.layer[i].modulation = QAM_64; 3548 c->layer[i].modulation = QAM_64;
3548 if (show) 3549 if (show)
3549 dprintk("dib8000_get_frontend: Layer %d QAM64 ", i); 3550 dprintk("dib8000_get_frontend: Layer %d QAM64 ", i);
3550 break; 3551 break;
@@ -3553,16 +3554,16 @@ static int dib8000_get_frontend(struct dvb_frontend *fe)
3553 3554
3554 /* synchronize the cache with the other frontends */ 3555 /* synchronize the cache with the other frontends */
3555 for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { 3556 for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) {
3556 state->fe[index_frontend]->dtv_property_cache.isdbt_sb_mode = fe->dtv_property_cache.isdbt_sb_mode; 3557 state->fe[index_frontend]->dtv_property_cache.isdbt_sb_mode = c->isdbt_sb_mode;
3557 state->fe[index_frontend]->dtv_property_cache.inversion = fe->dtv_property_cache.inversion; 3558 state->fe[index_frontend]->dtv_property_cache.inversion = c->inversion;
3558 state->fe[index_frontend]->dtv_property_cache.transmission_mode = fe->dtv_property_cache.transmission_mode; 3559 state->fe[index_frontend]->dtv_property_cache.transmission_mode = c->transmission_mode;
3559 state->fe[index_frontend]->dtv_property_cache.guard_interval = fe->dtv_property_cache.guard_interval; 3560 state->fe[index_frontend]->dtv_property_cache.guard_interval = c->guard_interval;
3560 state->fe[index_frontend]->dtv_property_cache.isdbt_partial_reception = fe->dtv_property_cache.isdbt_partial_reception; 3561 state->fe[index_frontend]->dtv_property_cache.isdbt_partial_reception = c->isdbt_partial_reception;
3561 for (i = 0; i < 3; i++) { 3562 for (i = 0; i < 3; i++) {
3562 state->fe[index_frontend]->dtv_property_cache.layer[i].segment_count = fe->dtv_property_cache.layer[i].segment_count; 3563 state->fe[index_frontend]->dtv_property_cache.layer[i].segment_count = c->layer[i].segment_count;
3563 state->fe[index_frontend]->dtv_property_cache.layer[i].interleaving = fe->dtv_property_cache.layer[i].interleaving; 3564 state->fe[index_frontend]->dtv_property_cache.layer[i].interleaving = c->layer[i].interleaving;
3564 state->fe[index_frontend]->dtv_property_cache.layer[i].fec = fe->dtv_property_cache.layer[i].fec; 3565 state->fe[index_frontend]->dtv_property_cache.layer[i].fec = c->layer[i].fec;
3565 state->fe[index_frontend]->dtv_property_cache.layer[i].modulation = fe->dtv_property_cache.layer[i].modulation; 3566 state->fe[index_frontend]->dtv_property_cache.layer[i].modulation = c->layer[i].modulation;
3566 } 3567 }
3567 } 3568 }
3568 return 0; 3569 return 0;
@@ -3671,7 +3672,7 @@ static int dib8000_set_frontend(struct dvb_frontend *fe)
3671 if (state->channel_parameters_set == 0) { /* searching */ 3672 if (state->channel_parameters_set == 0) { /* searching */
3672 if ((dib8000_get_status(state->fe[index_frontend]) == FE_STATUS_DEMOD_SUCCESS) || (dib8000_get_status(state->fe[index_frontend]) == FE_STATUS_FFT_SUCCESS)) { 3673 if ((dib8000_get_status(state->fe[index_frontend]) == FE_STATUS_DEMOD_SUCCESS) || (dib8000_get_status(state->fe[index_frontend]) == FE_STATUS_FFT_SUCCESS)) {
3673 dprintk("autosearch succeeded on fe%i", index_frontend); 3674 dprintk("autosearch succeeded on fe%i", index_frontend);
3674 dib8000_get_frontend(state->fe[index_frontend]); /* we read the channel parameters from the frontend which was successful */ 3675 dib8000_get_frontend(state->fe[index_frontend], c); /* we read the channel parameters from the frontend which was successful */
3675 state->channel_parameters_set = 1; 3676 state->channel_parameters_set = 1;
3676 3677
3677 for (l = 0; (l < MAX_NUMBER_OF_FRONTENDS) && (state->fe[l] != NULL); l++) { 3678 for (l = 0; (l < MAX_NUMBER_OF_FRONTENDS) && (state->fe[l] != NULL); l++) {
@@ -4516,6 +4517,6 @@ void *dib8000_attach(struct dib8000_ops *ops)
4516} 4517}
4517EXPORT_SYMBOL(dib8000_attach); 4518EXPORT_SYMBOL(dib8000_attach);
4518 4519
4519MODULE_AUTHOR("Olivier Grenie <Olivier.Grenie@dibcom.fr, " "Patrick Boettcher <pboettcher@dibcom.fr>"); 4520MODULE_AUTHOR("Olivier Grenie <Olivier.Grenie@parrot.com, Patrick Boettcher <patrick.boettcher@posteo.de>");
4520MODULE_DESCRIPTION("Driver for the DiBcom 8000 ISDB-T demodulator"); 4521MODULE_DESCRIPTION("Driver for the DiBcom 8000 ISDB-T demodulator");
4521MODULE_LICENSE("GPL"); 4522MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/dib9000.c b/drivers/media/dvb-frontends/dib9000.c
index 8f92aca0b073..5897977d2d00 100644
--- a/drivers/media/dvb-frontends/dib9000.c
+++ b/drivers/media/dvb-frontends/dib9000.c
@@ -225,7 +225,7 @@ static u16 to_fw_output_mode(u16 mode)
225 } 225 }
226} 226}
227 227
228static u16 dib9000_read16_attr(struct dib9000_state *state, u16 reg, u8 * b, u32 len, u16 attribute) 228static int dib9000_read16_attr(struct dib9000_state *state, u16 reg, u8 *b, u32 len, u16 attribute)
229{ 229{
230 u32 chunk_size = 126; 230 u32 chunk_size = 126;
231 u32 l; 231 u32 l;
@@ -309,7 +309,7 @@ static inline u16 dib9000_read_word_attr(struct dib9000_state *state, u16 reg, u
309 309
310#define dib9000_read16_noinc_attr(state, reg, b, len, attribute) dib9000_read16_attr(state, reg, b, len, (attribute) | DATA_BUS_ACCESS_MODE_NO_ADDRESS_INCREMENT) 310#define dib9000_read16_noinc_attr(state, reg, b, len, attribute) dib9000_read16_attr(state, reg, b, len, (attribute) | DATA_BUS_ACCESS_MODE_NO_ADDRESS_INCREMENT)
311 311
312static u16 dib9000_write16_attr(struct dib9000_state *state, u16 reg, const u8 * buf, u32 len, u16 attribute) 312static int dib9000_write16_attr(struct dib9000_state *state, u16 reg, const u8 *buf, u32 len, u16 attribute)
313{ 313{
314 u32 chunk_size = 126; 314 u32 chunk_size = 126;
315 u32 l; 315 u32 l;
@@ -1889,7 +1889,8 @@ static int dib9000_fe_get_tune_settings(struct dvb_frontend *fe, struct dvb_fron
1889 return 0; 1889 return 0;
1890} 1890}
1891 1891
1892static int dib9000_get_frontend(struct dvb_frontend *fe) 1892static int dib9000_get_frontend(struct dvb_frontend *fe,
1893 struct dtv_frontend_properties *c)
1893{ 1894{
1894 struct dib9000_state *state = fe->demodulator_priv; 1895 struct dib9000_state *state = fe->demodulator_priv;
1895 u8 index_frontend, sub_index_frontend; 1896 u8 index_frontend, sub_index_frontend;
@@ -1909,7 +1910,7 @@ static int dib9000_get_frontend(struct dvb_frontend *fe)
1909 dprintk("TPS lock on the slave%i", index_frontend); 1910 dprintk("TPS lock on the slave%i", index_frontend);
1910 1911
1911 /* synchronize the cache with the other frontends */ 1912 /* synchronize the cache with the other frontends */
1912 state->fe[index_frontend]->ops.get_frontend(state->fe[index_frontend]); 1913 state->fe[index_frontend]->ops.get_frontend(state->fe[index_frontend], c);
1913 for (sub_index_frontend = 0; (sub_index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[sub_index_frontend] != NULL); 1914 for (sub_index_frontend = 0; (sub_index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[sub_index_frontend] != NULL);
1914 sub_index_frontend++) { 1915 sub_index_frontend++) {
1915 if (sub_index_frontend != index_frontend) { 1916 if (sub_index_frontend != index_frontend) {
@@ -1943,14 +1944,14 @@ static int dib9000_get_frontend(struct dvb_frontend *fe)
1943 1944
1944 /* synchronize the cache with the other frontends */ 1945 /* synchronize the cache with the other frontends */
1945 for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { 1946 for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) {
1946 state->fe[index_frontend]->dtv_property_cache.inversion = fe->dtv_property_cache.inversion; 1947 state->fe[index_frontend]->dtv_property_cache.inversion = c->inversion;
1947 state->fe[index_frontend]->dtv_property_cache.transmission_mode = fe->dtv_property_cache.transmission_mode; 1948 state->fe[index_frontend]->dtv_property_cache.transmission_mode = c->transmission_mode;
1948 state->fe[index_frontend]->dtv_property_cache.guard_interval = fe->dtv_property_cache.guard_interval; 1949 state->fe[index_frontend]->dtv_property_cache.guard_interval = c->guard_interval;
1949 state->fe[index_frontend]->dtv_property_cache.modulation = fe->dtv_property_cache.modulation; 1950 state->fe[index_frontend]->dtv_property_cache.modulation = c->modulation;
1950 state->fe[index_frontend]->dtv_property_cache.hierarchy = fe->dtv_property_cache.hierarchy; 1951 state->fe[index_frontend]->dtv_property_cache.hierarchy = c->hierarchy;
1951 state->fe[index_frontend]->dtv_property_cache.code_rate_HP = fe->dtv_property_cache.code_rate_HP; 1952 state->fe[index_frontend]->dtv_property_cache.code_rate_HP = c->code_rate_HP;
1952 state->fe[index_frontend]->dtv_property_cache.code_rate_LP = fe->dtv_property_cache.code_rate_LP; 1953 state->fe[index_frontend]->dtv_property_cache.code_rate_LP = c->code_rate_LP;
1953 state->fe[index_frontend]->dtv_property_cache.rolloff = fe->dtv_property_cache.rolloff; 1954 state->fe[index_frontend]->dtv_property_cache.rolloff = c->rolloff;
1954 } 1955 }
1955 ret = 0; 1956 ret = 0;
1956 1957
@@ -2083,7 +2084,7 @@ static int dib9000_set_frontend(struct dvb_frontend *fe)
2083 2084
2084 /* synchronize all the channel cache */ 2085 /* synchronize all the channel cache */
2085 state->get_frontend_internal = 1; 2086 state->get_frontend_internal = 1;
2086 dib9000_get_frontend(state->fe[0]); 2087 dib9000_get_frontend(state->fe[0], &state->fe[0]->dtv_property_cache);
2087 state->get_frontend_internal = 0; 2088 state->get_frontend_internal = 0;
2088 2089
2089 /* retune the other frontends with the found channel */ 2090 /* retune the other frontends with the found channel */
@@ -2589,7 +2590,7 @@ static struct dvb_frontend_ops dib9000_ops = {
2589 .read_ucblocks = dib9000_read_unc_blocks, 2590 .read_ucblocks = dib9000_read_unc_blocks,
2590}; 2591};
2591 2592
2592MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>"); 2593MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
2593MODULE_AUTHOR("Olivier Grenie <ogrenie@dibcom.fr>"); 2594MODULE_AUTHOR("Olivier Grenie <olivier.grenie@parrot.com>");
2594MODULE_DESCRIPTION("Driver for the DiBcom 9000 COFDM demodulator"); 2595MODULE_DESCRIPTION("Driver for the DiBcom 9000 COFDM demodulator");
2595MODULE_LICENSE("GPL"); 2596MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/dibx000_common.c b/drivers/media/dvb-frontends/dibx000_common.c
index 43be7238311e..723358d7ca84 100644
--- a/drivers/media/dvb-frontends/dibx000_common.c
+++ b/drivers/media/dvb-frontends/dibx000_common.c
@@ -510,6 +510,6 @@ u32 systime(void)
510} 510}
511EXPORT_SYMBOL(systime); 511EXPORT_SYMBOL(systime);
512 512
513MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>"); 513MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
514MODULE_DESCRIPTION("Common function the DiBcom demodulator family"); 514MODULE_DESCRIPTION("Common function the DiBcom demodulator family");
515MODULE_LICENSE("GPL"); 515MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c
index b28b5787b39a..e48b741d439e 100644
--- a/drivers/media/dvb-frontends/drx39xyj/drxj.c
+++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
@@ -4131,7 +4131,7 @@ int drxj_dap_scu_atomic_read_write_block(struct i2c_device_addr *dev_addr, u32 a
4131{ 4131{
4132 struct drxjscu_cmd scu_cmd; 4132 struct drxjscu_cmd scu_cmd;
4133 int rc; 4133 int rc;
4134 u16 set_param_parameters[15]; 4134 u16 set_param_parameters[18];
4135 u16 cmd_result[15]; 4135 u16 cmd_result[15];
4136 4136
4137 /* Parameter check */ 4137 /* Parameter check */
@@ -9597,12 +9597,13 @@ ctrl_get_qam_sig_quality(struct drx_demod_instance *demod)
9597 9597
9598 Precision errors still possible. 9598 Precision errors still possible.
9599 */ 9599 */
9600 e = post_bit_err_rs * 742686; 9600 if (!fec_oc_period) {
9601 m = fec_oc_period * 100;
9602 if (fec_oc_period == 0)
9603 qam_post_rs_ber = 0xFFFFFFFF; 9601 qam_post_rs_ber = 0xFFFFFFFF;
9604 else 9602 } else {
9603 e = post_bit_err_rs * 742686;
9604 m = fec_oc_period * 100;
9605 qam_post_rs_ber = e / m; 9605 qam_post_rs_ber = e / m;
9606 }
9606 9607
9607 /* fill signal quality data structure */ 9608 /* fill signal quality data structure */
9608 p->pre_bit_count.stat[0].scale = FE_SCALE_COUNTER; 9609 p->pre_bit_count.stat[0].scale = FE_SCALE_COUNTER;
diff --git a/drivers/media/dvb-frontends/dvb_dummy_fe.c b/drivers/media/dvb-frontends/dvb_dummy_fe.c
index 14e996d45fac..e5bd8c62ad3a 100644
--- a/drivers/media/dvb-frontends/dvb_dummy_fe.c
+++ b/drivers/media/dvb-frontends/dvb_dummy_fe.c
@@ -70,9 +70,12 @@ static int dvb_dummy_fe_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
70} 70}
71 71
72/* 72/*
73 * Only needed if it actually reads something from the hardware 73 * Should only be implemented if it actually reads something from the hardware.
74 * Also, it should check for the locks, in order to avoid report wrong data
75 * to userspace.
74 */ 76 */
75static int dvb_dummy_fe_get_frontend(struct dvb_frontend *fe) 77static int dvb_dummy_fe_get_frontend(struct dvb_frontend *fe,
78 struct dtv_frontend_properties *p)
76{ 79{
77 return 0; 80 return 0;
78} 81}
diff --git a/drivers/media/dvb-frontends/hd29l2.c b/drivers/media/dvb-frontends/hd29l2.c
index 40e359f2d17d..1c7eb477e2cd 100644
--- a/drivers/media/dvb-frontends/hd29l2.c
+++ b/drivers/media/dvb-frontends/hd29l2.c
@@ -560,11 +560,11 @@ static int hd29l2_get_frontend_algo(struct dvb_frontend *fe)
560 return DVBFE_ALGO_CUSTOM; 560 return DVBFE_ALGO_CUSTOM;
561} 561}
562 562
563static int hd29l2_get_frontend(struct dvb_frontend *fe) 563static int hd29l2_get_frontend(struct dvb_frontend *fe,
564 struct dtv_frontend_properties *c)
564{ 565{
565 int ret; 566 int ret;
566 struct hd29l2_priv *priv = fe->demodulator_priv; 567 struct hd29l2_priv *priv = fe->demodulator_priv;
567 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
568 u8 buf[3]; 568 u8 buf[3];
569 u32 if_ctl; 569 u32 if_ctl;
570 char *str_constellation, *str_code_rate, *str_constellation_code_rate, 570 char *str_constellation, *str_code_rate, *str_constellation_code_rate,
diff --git a/drivers/media/dvb-frontends/l64781.c b/drivers/media/dvb-frontends/l64781.c
index 0977871232a2..2f3d0519e19b 100644
--- a/drivers/media/dvb-frontends/l64781.c
+++ b/drivers/media/dvb-frontends/l64781.c
@@ -243,9 +243,9 @@ static int apply_frontend_param(struct dvb_frontend *fe)
243 return 0; 243 return 0;
244} 244}
245 245
246static int get_frontend(struct dvb_frontend *fe) 246static int get_frontend(struct dvb_frontend *fe,
247 struct dtv_frontend_properties *p)
247{ 248{
248 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
249 struct l64781_state* state = fe->demodulator_priv; 249 struct l64781_state* state = fe->demodulator_priv;
250 int tmp; 250 int tmp;
251 251
diff --git a/drivers/media/dvb-frontends/lg2160.c b/drivers/media/dvb-frontends/lg2160.c
index 7880f71ccd8a..f51a3a0b3949 100644
--- a/drivers/media/dvb-frontends/lg2160.c
+++ b/drivers/media/dvb-frontends/lg2160.c
@@ -942,101 +942,102 @@ static int lg216x_read_rs_err_count(struct lg216x_state *state, u16 *err)
942 942
943/* ------------------------------------------------------------------------ */ 943/* ------------------------------------------------------------------------ */
944 944
945static int lg216x_get_frontend(struct dvb_frontend *fe) 945static int lg216x_get_frontend(struct dvb_frontend *fe,
946 struct dtv_frontend_properties *c)
946{ 947{
947 struct lg216x_state *state = fe->demodulator_priv; 948 struct lg216x_state *state = fe->demodulator_priv;
948 int ret; 949 int ret;
949 950
950 lg_dbg("\n"); 951 lg_dbg("\n");
951 952
952 fe->dtv_property_cache.modulation = VSB_8; 953 c->modulation = VSB_8;
953 fe->dtv_property_cache.frequency = state->current_frequency; 954 c->frequency = state->current_frequency;
954 fe->dtv_property_cache.delivery_system = SYS_ATSCMH; 955 c->delivery_system = SYS_ATSCMH;
955 956
956 ret = lg216x_get_fic_version(state, 957 ret = lg216x_get_fic_version(state,
957 &fe->dtv_property_cache.atscmh_fic_ver); 958 &c->atscmh_fic_ver);
958 if (lg_fail(ret)) 959 if (lg_fail(ret))
959 goto fail; 960 goto fail;
960 if (state->fic_ver != fe->dtv_property_cache.atscmh_fic_ver) { 961 if (state->fic_ver != c->atscmh_fic_ver) {
961 state->fic_ver = fe->dtv_property_cache.atscmh_fic_ver; 962 state->fic_ver = c->atscmh_fic_ver;
962 963
963#if 0 964#if 0
964 ret = lg2160_get_parade_id(state, 965 ret = lg2160_get_parade_id(state,
965 &fe->dtv_property_cache.atscmh_parade_id); 966 &c->atscmh_parade_id);
966 if (lg_fail(ret)) 967 if (lg_fail(ret))
967 goto fail; 968 goto fail;
968/* #else */ 969/* #else */
969 fe->dtv_property_cache.atscmh_parade_id = state->parade_id; 970 c->atscmh_parade_id = state->parade_id;
970#endif 971#endif
971 ret = lg216x_get_nog(state, 972 ret = lg216x_get_nog(state,
972 &fe->dtv_property_cache.atscmh_nog); 973 &c->atscmh_nog);
973 if (lg_fail(ret)) 974 if (lg_fail(ret))
974 goto fail; 975 goto fail;
975 ret = lg216x_get_tnog(state, 976 ret = lg216x_get_tnog(state,
976 &fe->dtv_property_cache.atscmh_tnog); 977 &c->atscmh_tnog);
977 if (lg_fail(ret)) 978 if (lg_fail(ret))
978 goto fail; 979 goto fail;
979 ret = lg216x_get_sgn(state, 980 ret = lg216x_get_sgn(state,
980 &fe->dtv_property_cache.atscmh_sgn); 981 &c->atscmh_sgn);
981 if (lg_fail(ret)) 982 if (lg_fail(ret))
982 goto fail; 983 goto fail;
983 ret = lg216x_get_prc(state, 984 ret = lg216x_get_prc(state,
984 &fe->dtv_property_cache.atscmh_prc); 985 &c->atscmh_prc);
985 if (lg_fail(ret)) 986 if (lg_fail(ret))
986 goto fail; 987 goto fail;
987 988
988 ret = lg216x_get_rs_frame_mode(state, 989 ret = lg216x_get_rs_frame_mode(state,
989 (enum atscmh_rs_frame_mode *) 990 (enum atscmh_rs_frame_mode *)
990 &fe->dtv_property_cache.atscmh_rs_frame_mode); 991 &c->atscmh_rs_frame_mode);
991 if (lg_fail(ret)) 992 if (lg_fail(ret))
992 goto fail; 993 goto fail;
993 ret = lg216x_get_rs_frame_ensemble(state, 994 ret = lg216x_get_rs_frame_ensemble(state,
994 (enum atscmh_rs_frame_ensemble *) 995 (enum atscmh_rs_frame_ensemble *)
995 &fe->dtv_property_cache.atscmh_rs_frame_ensemble); 996 &c->atscmh_rs_frame_ensemble);
996 if (lg_fail(ret)) 997 if (lg_fail(ret))
997 goto fail; 998 goto fail;
998 ret = lg216x_get_rs_code_mode(state, 999 ret = lg216x_get_rs_code_mode(state,
999 (enum atscmh_rs_code_mode *) 1000 (enum atscmh_rs_code_mode *)
1000 &fe->dtv_property_cache.atscmh_rs_code_mode_pri, 1001 &c->atscmh_rs_code_mode_pri,
1001 (enum atscmh_rs_code_mode *) 1002 (enum atscmh_rs_code_mode *)
1002 &fe->dtv_property_cache.atscmh_rs_code_mode_sec); 1003 &c->atscmh_rs_code_mode_sec);
1003 if (lg_fail(ret)) 1004 if (lg_fail(ret))
1004 goto fail; 1005 goto fail;
1005 ret = lg216x_get_sccc_block_mode(state, 1006 ret = lg216x_get_sccc_block_mode(state,
1006 (enum atscmh_sccc_block_mode *) 1007 (enum atscmh_sccc_block_mode *)
1007 &fe->dtv_property_cache.atscmh_sccc_block_mode); 1008 &c->atscmh_sccc_block_mode);
1008 if (lg_fail(ret)) 1009 if (lg_fail(ret))
1009 goto fail; 1010 goto fail;
1010 ret = lg216x_get_sccc_code_mode(state, 1011 ret = lg216x_get_sccc_code_mode(state,
1011 (enum atscmh_sccc_code_mode *) 1012 (enum atscmh_sccc_code_mode *)
1012 &fe->dtv_property_cache.atscmh_sccc_code_mode_a, 1013 &c->atscmh_sccc_code_mode_a,
1013 (enum atscmh_sccc_code_mode *) 1014 (enum atscmh_sccc_code_mode *)
1014 &fe->dtv_property_cache.atscmh_sccc_code_mode_b, 1015 &c->atscmh_sccc_code_mode_b,
1015 (enum atscmh_sccc_code_mode *) 1016 (enum atscmh_sccc_code_mode *)
1016 &fe->dtv_property_cache.atscmh_sccc_code_mode_c, 1017 &c->atscmh_sccc_code_mode_c,
1017 (enum atscmh_sccc_code_mode *) 1018 (enum atscmh_sccc_code_mode *)
1018 &fe->dtv_property_cache.atscmh_sccc_code_mode_d); 1019 &c->atscmh_sccc_code_mode_d);
1019 if (lg_fail(ret)) 1020 if (lg_fail(ret))
1020 goto fail; 1021 goto fail;
1021 } 1022 }
1022#if 0 1023#if 0
1023 ret = lg216x_read_fic_err_count(state, 1024 ret = lg216x_read_fic_err_count(state,
1024 (u8 *)&fe->dtv_property_cache.atscmh_fic_err); 1025 (u8 *)&c->atscmh_fic_err);
1025 if (lg_fail(ret)) 1026 if (lg_fail(ret))
1026 goto fail; 1027 goto fail;
1027 ret = lg216x_read_crc_err_count(state, 1028 ret = lg216x_read_crc_err_count(state,
1028 &fe->dtv_property_cache.atscmh_crc_err); 1029 &c->atscmh_crc_err);
1029 if (lg_fail(ret)) 1030 if (lg_fail(ret))
1030 goto fail; 1031 goto fail;
1031 ret = lg216x_read_rs_err_count(state, 1032 ret = lg216x_read_rs_err_count(state,
1032 &fe->dtv_property_cache.atscmh_rs_err); 1033 &c->atscmh_rs_err);
1033 if (lg_fail(ret)) 1034 if (lg_fail(ret))
1034 goto fail; 1035 goto fail;
1035 1036
1036 switch (state->cfg->lg_chip) { 1037 switch (state->cfg->lg_chip) {
1037 case LG2160: 1038 case LG2160:
1038 if (((fe->dtv_property_cache.atscmh_rs_err >= 240) && 1039 if (((c->atscmh_rs_err >= 240) &&
1039 (fe->dtv_property_cache.atscmh_crc_err >= 240)) && 1040 (c->atscmh_crc_err >= 240)) &&
1040 ((jiffies_to_msecs(jiffies) - state->last_reset) > 6000)) 1041 ((jiffies_to_msecs(jiffies) - state->last_reset) > 6000))
1041 ret = lg216x_soft_reset(state); 1042 ret = lg216x_soft_reset(state);
1042 break; 1043 break;
@@ -1054,14 +1055,17 @@ fail:
1054static int lg216x_get_property(struct dvb_frontend *fe, 1055static int lg216x_get_property(struct dvb_frontend *fe,
1055 struct dtv_property *tvp) 1056 struct dtv_property *tvp)
1056{ 1057{
1058 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
1059
1057 return (DTV_ATSCMH_FIC_VER == tvp->cmd) ? 1060 return (DTV_ATSCMH_FIC_VER == tvp->cmd) ?
1058 lg216x_get_frontend(fe) : 0; 1061 lg216x_get_frontend(fe, c) : 0;
1059} 1062}
1060 1063
1061 1064
1062static int lg2160_set_frontend(struct dvb_frontend *fe) 1065static int lg2160_set_frontend(struct dvb_frontend *fe)
1063{ 1066{
1064 struct lg216x_state *state = fe->demodulator_priv; 1067 struct lg216x_state *state = fe->demodulator_priv;
1068 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
1065 int ret; 1069 int ret;
1066 1070
1067 lg_dbg("(%d)\n", fe->dtv_property_cache.frequency); 1071 lg_dbg("(%d)\n", fe->dtv_property_cache.frequency);
@@ -1129,7 +1133,7 @@ static int lg2160_set_frontend(struct dvb_frontend *fe)
1129 ret = lg216x_enable_fic(state, 1); 1133 ret = lg216x_enable_fic(state, 1);
1130 lg_fail(ret); 1134 lg_fail(ret);
1131 1135
1132 lg216x_get_frontend(fe); 1136 lg216x_get_frontend(fe, c);
1133fail: 1137fail:
1134 return ret; 1138 return ret;
1135} 1139}
diff --git a/drivers/media/dvb-frontends/lgdt3305.c b/drivers/media/dvb-frontends/lgdt3305.c
index 47121866163d..4503e8852fd1 100644
--- a/drivers/media/dvb-frontends/lgdt3305.c
+++ b/drivers/media/dvb-frontends/lgdt3305.c
@@ -812,9 +812,9 @@ fail:
812 return ret; 812 return ret;
813} 813}
814 814
815static int lgdt3305_get_frontend(struct dvb_frontend *fe) 815static int lgdt3305_get_frontend(struct dvb_frontend *fe,
816 struct dtv_frontend_properties *p)
816{ 817{
817 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
818 struct lgdt3305_state *state = fe->demodulator_priv; 818 struct lgdt3305_state *state = fe->demodulator_priv;
819 819
820 lg_dbg("\n"); 820 lg_dbg("\n");
diff --git a/drivers/media/dvb-frontends/lgdt3306a.c b/drivers/media/dvb-frontends/lgdt3306a.c
index 721fbc07e9ee..179c26e5eb4e 100644
--- a/drivers/media/dvb-frontends/lgdt3306a.c
+++ b/drivers/media/dvb-frontends/lgdt3306a.c
@@ -1040,10 +1040,10 @@ fail:
1040 return ret; 1040 return ret;
1041} 1041}
1042 1042
1043static int lgdt3306a_get_frontend(struct dvb_frontend *fe) 1043static int lgdt3306a_get_frontend(struct dvb_frontend *fe,
1044 struct dtv_frontend_properties *p)
1044{ 1045{
1045 struct lgdt3306a_state *state = fe->demodulator_priv; 1046 struct lgdt3306a_state *state = fe->demodulator_priv;
1046 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1047 1047
1048 dbg_info("(%u, %d)\n", 1048 dbg_info("(%u, %d)\n",
1049 state->current_frequency, state->current_modulation); 1049 state->current_frequency, state->current_modulation);
diff --git a/drivers/media/dvb-frontends/lgdt330x.c b/drivers/media/dvb-frontends/lgdt330x.c
index cf3cc20510da..96bf254da21e 100644
--- a/drivers/media/dvb-frontends/lgdt330x.c
+++ b/drivers/media/dvb-frontends/lgdt330x.c
@@ -439,10 +439,11 @@ static int lgdt330x_set_parameters(struct dvb_frontend *fe)
439 return 0; 439 return 0;
440} 440}
441 441
442static int lgdt330x_get_frontend(struct dvb_frontend *fe) 442static int lgdt330x_get_frontend(struct dvb_frontend *fe,
443 struct dtv_frontend_properties *p)
443{ 444{
444 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
445 struct lgdt330x_state *state = fe->demodulator_priv; 445 struct lgdt330x_state *state = fe->demodulator_priv;
446
446 p->frequency = state->current_frequency; 447 p->frequency = state->current_frequency;
447 return 0; 448 return 0;
448} 449}
diff --git a/drivers/media/dvb-frontends/lgs8gl5.c b/drivers/media/dvb-frontends/lgs8gl5.c
index 7bbb2c18c2dd..fbfd87b5b803 100644
--- a/drivers/media/dvb-frontends/lgs8gl5.c
+++ b/drivers/media/dvb-frontends/lgs8gl5.c
@@ -336,10 +336,11 @@ lgs8gl5_set_frontend(struct dvb_frontend *fe)
336 336
337 337
338static int 338static int
339lgs8gl5_get_frontend(struct dvb_frontend *fe) 339lgs8gl5_get_frontend(struct dvb_frontend *fe,
340 struct dtv_frontend_properties *p)
340{ 341{
341 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
342 struct lgs8gl5_state *state = fe->demodulator_priv; 342 struct lgs8gl5_state *state = fe->demodulator_priv;
343
343 u8 inv = lgs8gl5_read_reg(state, REG_INVERSION); 344 u8 inv = lgs8gl5_read_reg(state, REG_INVERSION);
344 345
345 p->inversion = (inv & REG_INVERSION_ON) ? INVERSION_ON : INVERSION_OFF; 346 p->inversion = (inv & REG_INVERSION_ON) ? INVERSION_ON : INVERSION_OFF;
diff --git a/drivers/media/dvb-frontends/lgs8gxx.c b/drivers/media/dvb-frontends/lgs8gxx.c
index e2c191c8b196..919daeb96747 100644
--- a/drivers/media/dvb-frontends/lgs8gxx.c
+++ b/drivers/media/dvb-frontends/lgs8gxx.c
@@ -672,7 +672,7 @@ static int lgs8gxx_write(struct dvb_frontend *fe, const u8 buf[], int len)
672 672
673static int lgs8gxx_set_fe(struct dvb_frontend *fe) 673static int lgs8gxx_set_fe(struct dvb_frontend *fe)
674{ 674{
675 675 struct dtv_frontend_properties *fe_params = &fe->dtv_property_cache;
676 struct lgs8gxx_state *priv = fe->demodulator_priv; 676 struct lgs8gxx_state *priv = fe->demodulator_priv;
677 677
678 dprintk("%s\n", __func__); 678 dprintk("%s\n", __func__);
@@ -689,17 +689,7 @@ static int lgs8gxx_set_fe(struct dvb_frontend *fe)
689 689
690 msleep(10); 690 msleep(10);
691 691
692 return 0;
693}
694
695static int lgs8gxx_get_fe(struct dvb_frontend *fe)
696{
697 struct dtv_frontend_properties *fe_params = &fe->dtv_property_cache;
698 dprintk("%s\n", __func__);
699
700 /* TODO: get real readings from device */ 692 /* TODO: get real readings from device */
701 /* inversion status */
702 fe_params->inversion = INVERSION_OFF;
703 693
704 /* bandwidth */ 694 /* bandwidth */
705 fe_params->bandwidth_hz = 8000000; 695 fe_params->bandwidth_hz = 8000000;
@@ -1016,7 +1006,6 @@ static struct dvb_frontend_ops lgs8gxx_ops = {
1016 .i2c_gate_ctrl = lgs8gxx_i2c_gate_ctrl, 1006 .i2c_gate_ctrl = lgs8gxx_i2c_gate_ctrl,
1017 1007
1018 .set_frontend = lgs8gxx_set_fe, 1008 .set_frontend = lgs8gxx_set_fe,
1019 .get_frontend = lgs8gxx_get_fe,
1020 .get_tune_settings = lgs8gxx_get_tune_settings, 1009 .get_tune_settings = lgs8gxx_get_tune_settings,
1021 1010
1022 .read_status = lgs8gxx_read_status, 1011 .read_status = lgs8gxx_read_status,
diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c
index ce73a5ec6036..76883600ec6f 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -791,11 +791,11 @@ err:
791 return ret; 791 return ret;
792} 792}
793 793
794static int m88ds3103_get_frontend(struct dvb_frontend *fe) 794static int m88ds3103_get_frontend(struct dvb_frontend *fe,
795 struct dtv_frontend_properties *c)
795{ 796{
796 struct m88ds3103_dev *dev = fe->demodulator_priv; 797 struct m88ds3103_dev *dev = fe->demodulator_priv;
797 struct i2c_client *client = dev->client; 798 struct i2c_client *client = dev->client;
798 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
799 int ret; 799 int ret;
800 u8 buf[3]; 800 u8 buf[3];
801 801
diff --git a/drivers/media/dvb-frontends/m88rs2000.c b/drivers/media/dvb-frontends/m88rs2000.c
index 9b6f464c48bd..a09b12313a73 100644
--- a/drivers/media/dvb-frontends/m88rs2000.c
+++ b/drivers/media/dvb-frontends/m88rs2000.c
@@ -708,10 +708,11 @@ static int m88rs2000_set_frontend(struct dvb_frontend *fe)
708 return 0; 708 return 0;
709} 709}
710 710
711static int m88rs2000_get_frontend(struct dvb_frontend *fe) 711static int m88rs2000_get_frontend(struct dvb_frontend *fe,
712 struct dtv_frontend_properties *c)
712{ 713{
713 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
714 struct m88rs2000_state *state = fe->demodulator_priv; 714 struct m88rs2000_state *state = fe->demodulator_priv;
715
715 c->fec_inner = state->fec_inner; 716 c->fec_inner = state->fec_inner;
716 c->frequency = state->tuner_frequency; 717 c->frequency = state->tuner_frequency;
717 c->symbol_rate = state->symbol_rate; 718 c->symbol_rate = state->symbol_rate;
diff --git a/drivers/media/dvb-frontends/mb86a20s.c b/drivers/media/dvb-frontends/mb86a20s.c
index cfc005ee11d8..fb88dddaf3a3 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -2028,16 +2028,6 @@ static int mb86a20s_read_signal_strength_from_cache(struct dvb_frontend *fe,
2028 return 0; 2028 return 0;
2029} 2029}
2030 2030
2031static int mb86a20s_get_frontend_dummy(struct dvb_frontend *fe)
2032{
2033 /*
2034 * get_frontend is now handled together with other stats
2035 * retrival, when read_status() is called, as some statistics
2036 * will depend on the layers detection.
2037 */
2038 return 0;
2039};
2040
2041static int mb86a20s_tune(struct dvb_frontend *fe, 2031static int mb86a20s_tune(struct dvb_frontend *fe,
2042 bool re_tune, 2032 bool re_tune,
2043 unsigned int mode_flags, 2033 unsigned int mode_flags,
@@ -2136,7 +2126,6 @@ static struct dvb_frontend_ops mb86a20s_ops = {
2136 2126
2137 .init = mb86a20s_initfe, 2127 .init = mb86a20s_initfe,
2138 .set_frontend = mb86a20s_set_frontend, 2128 .set_frontend = mb86a20s_set_frontend,
2139 .get_frontend = mb86a20s_get_frontend_dummy,
2140 .read_status = mb86a20s_read_status_and_stats, 2129 .read_status = mb86a20s_read_status_and_stats,
2141 .read_signal_strength = mb86a20s_read_signal_strength_from_cache, 2130 .read_signal_strength = mb86a20s_read_signal_strength_from_cache,
2142 .tune = mb86a20s_tune, 2131 .tune = mb86a20s_tune,
diff --git a/drivers/staging/media/mn88473/mn88473.c b/drivers/media/dvb-frontends/mn88473.c
index a222e99935d2..6c5d592161d4 100644
--- a/drivers/staging/media/mn88473/mn88473.c
+++ b/drivers/media/dvb-frontends/mn88473.c
@@ -29,21 +29,17 @@ static int mn88473_set_frontend(struct dvb_frontend *fe)
29 struct mn88473_dev *dev = i2c_get_clientdata(client); 29 struct mn88473_dev *dev = i2c_get_clientdata(client);
30 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 30 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
31 int ret, i; 31 int ret, i;
32 unsigned int uitmp;
32 u32 if_frequency; 33 u32 if_frequency;
33 u64 tmp; 34 u8 delivery_system_val, if_val[3], *conf_val_ptr;
34 u8 delivery_system_val, if_val[3], bw_val[7]; 35 u8 reg_bank2_2d_val, reg_bank0_d2_val;
35 36
36 dev_dbg(&client->dev, 37 dev_dbg(&client->dev,
37 "delivery_system=%u modulation=%u frequency=%u bandwidth_hz=%u symbol_rate=%u inversion=%d stream_id=%d\n", 38 "delivery_system=%u modulation=%u frequency=%u bandwidth_hz=%u symbol_rate=%u inversion=%d stream_id=%d\n",
38 c->delivery_system, 39 c->delivery_system, c->modulation, c->frequency,
39 c->modulation, 40 c->bandwidth_hz, c->symbol_rate, c->inversion, c->stream_id);
40 c->frequency, 41
41 c->bandwidth_hz, 42 if (!dev->active) {
42 c->symbol_rate,
43 c->inversion,
44 c->stream_id);
45
46 if (!dev->warm) {
47 ret = -EAGAIN; 43 ret = -EAGAIN;
48 goto err; 44 goto err;
49 } 45 }
@@ -51,30 +47,50 @@ static int mn88473_set_frontend(struct dvb_frontend *fe)
51 switch (c->delivery_system) { 47 switch (c->delivery_system) {
52 case SYS_DVBT: 48 case SYS_DVBT:
53 delivery_system_val = 0x02; 49 delivery_system_val = 0x02;
50 reg_bank2_2d_val = 0x23;
51 reg_bank0_d2_val = 0x2a;
54 break; 52 break;
55 case SYS_DVBT2: 53 case SYS_DVBT2:
56 delivery_system_val = 0x03; 54 delivery_system_val = 0x03;
55 reg_bank2_2d_val = 0x3b;
56 reg_bank0_d2_val = 0x29;
57 break; 57 break;
58 case SYS_DVBC_ANNEX_A: 58 case SYS_DVBC_ANNEX_A:
59 delivery_system_val = 0x04; 59 delivery_system_val = 0x04;
60 reg_bank2_2d_val = 0x3b;
61 reg_bank0_d2_val = 0x29;
60 break; 62 break;
61 default: 63 default:
62 ret = -EINVAL; 64 ret = -EINVAL;
63 goto err; 65 goto err;
64 } 66 }
65 67
66 if (c->bandwidth_hz <= 6000000) { 68 switch (c->delivery_system) {
67 memcpy(bw_val, "\xe9\x55\x55\x1c\x29\x1c\x29", 7); 69 case SYS_DVBT:
68 } else if (c->bandwidth_hz <= 7000000) { 70 case SYS_DVBT2:
69 memcpy(bw_val, "\xc8\x00\x00\x17\x0a\x17\x0a", 7); 71 switch (c->bandwidth_hz) {
70 } else if (c->bandwidth_hz <= 8000000) { 72 case 6000000:
71 memcpy(bw_val, "\xaf\x00\x00\x11\xec\x11\xec", 7); 73 conf_val_ptr = "\xe9\x55\x55\x1c\x29\x1c\x29";
72 } else { 74 break;
73 ret = -EINVAL; 75 case 7000000:
74 goto err; 76 conf_val_ptr = "\xc8\x00\x00\x17\x0a\x17\x0a";
77 break;
78 case 8000000:
79 conf_val_ptr = "\xaf\x00\x00\x11\xec\x11\xec";
80 break;
81 default:
82 ret = -EINVAL;
83 goto err;
84 }
85 break;
86 case SYS_DVBC_ANNEX_A:
87 conf_val_ptr = "\x10\xab\x0d\xae\x1d\x9d";
88 break;
89 default:
90 break;
75 } 91 }
76 92
77 /* program tuner */ 93 /* Program tuner */
78 if (fe->ops.tuner_ops.set_params) { 94 if (fe->ops.tuner_ops.set_params) {
79 ret = fe->ops.tuner_ops.set_params(fe); 95 ret = fe->ops.tuner_ops.set_params(fe);
80 if (ret) 96 if (ret)
@@ -86,27 +102,45 @@ static int mn88473_set_frontend(struct dvb_frontend *fe)
86 if (ret) 102 if (ret)
87 goto err; 103 goto err;
88 104
89 dev_dbg(&client->dev, "get_if_frequency=%d\n", if_frequency); 105 dev_dbg(&client->dev, "get_if_frequency=%u\n", if_frequency);
90 } else { 106 } else {
91 if_frequency = 0; 107 ret = -EINVAL;
108 goto err;
92 } 109 }
93 110
94 /* Calculate IF registers ( (1<<24)*IF / Xtal ) */ 111 /* Calculate IF registers */
95 tmp = div_u64(if_frequency * (u64)(1<<24) + (dev->xtal / 2), 112 uitmp = DIV_ROUND_CLOSEST_ULL((u64) if_frequency * 0x1000000, dev->clk);
96 dev->xtal); 113 if_val[0] = (uitmp >> 16) & 0xff;
97 if_val[0] = ((tmp >> 16) & 0xff); 114 if_val[1] = (uitmp >> 8) & 0xff;
98 if_val[1] = ((tmp >> 8) & 0xff); 115 if_val[2] = (uitmp >> 0) & 0xff;
99 if_val[2] = ((tmp >> 0) & 0xff);
100 116
101 ret = regmap_write(dev->regmap[2], 0x05, 0x00); 117 ret = regmap_write(dev->regmap[2], 0x05, 0x00);
118 if (ret)
119 goto err;
102 ret = regmap_write(dev->regmap[2], 0xfb, 0x13); 120 ret = regmap_write(dev->regmap[2], 0xfb, 0x13);
121 if (ret)
122 goto err;
103 ret = regmap_write(dev->regmap[2], 0xef, 0x13); 123 ret = regmap_write(dev->regmap[2], 0xef, 0x13);
124 if (ret)
125 goto err;
104 ret = regmap_write(dev->regmap[2], 0xf9, 0x13); 126 ret = regmap_write(dev->regmap[2], 0xf9, 0x13);
127 if (ret)
128 goto err;
105 ret = regmap_write(dev->regmap[2], 0x00, 0x18); 129 ret = regmap_write(dev->regmap[2], 0x00, 0x18);
130 if (ret)
131 goto err;
106 ret = regmap_write(dev->regmap[2], 0x01, 0x01); 132 ret = regmap_write(dev->regmap[2], 0x01, 0x01);
133 if (ret)
134 goto err;
107 ret = regmap_write(dev->regmap[2], 0x02, 0x21); 135 ret = regmap_write(dev->regmap[2], 0x02, 0x21);
136 if (ret)
137 goto err;
108 ret = regmap_write(dev->regmap[2], 0x03, delivery_system_val); 138 ret = regmap_write(dev->regmap[2], 0x03, delivery_system_val);
139 if (ret)
140 goto err;
109 ret = regmap_write(dev->regmap[2], 0x0b, 0x00); 141 ret = regmap_write(dev->regmap[2], 0x0b, 0x00);
142 if (ret)
143 goto err;
110 144
111 for (i = 0; i < sizeof(if_val); i++) { 145 for (i = 0; i < sizeof(if_val); i++) {
112 ret = regmap_write(dev->regmap[2], 0x10 + i, if_val[i]); 146 ret = regmap_write(dev->regmap[2], 0x10 + i, if_val[i]);
@@ -114,52 +148,85 @@ static int mn88473_set_frontend(struct dvb_frontend *fe)
114 goto err; 148 goto err;
115 } 149 }
116 150
117 for (i = 0; i < sizeof(bw_val); i++) { 151 switch (c->delivery_system) {
118 ret = regmap_write(dev->regmap[2], 0x13 + i, bw_val[i]); 152 case SYS_DVBT:
153 case SYS_DVBT2:
154 for (i = 0; i < 7; i++) {
155 ret = regmap_write(dev->regmap[2], 0x13 + i,
156 conf_val_ptr[i]);
157 if (ret)
158 goto err;
159 }
160 break;
161 case SYS_DVBC_ANNEX_A:
162 ret = regmap_bulk_write(dev->regmap[1], 0x10, conf_val_ptr, 6);
119 if (ret) 163 if (ret)
120 goto err; 164 goto err;
165 break;
166 default:
167 break;
121 } 168 }
122 169
123 ret = regmap_write(dev->regmap[2], 0x2d, 0x3b); 170 ret = regmap_write(dev->regmap[2], 0x2d, reg_bank2_2d_val);
171 if (ret)
172 goto err;
124 ret = regmap_write(dev->regmap[2], 0x2e, 0x00); 173 ret = regmap_write(dev->regmap[2], 0x2e, 0x00);
174 if (ret)
175 goto err;
125 ret = regmap_write(dev->regmap[2], 0x56, 0x0d); 176 ret = regmap_write(dev->regmap[2], 0x56, 0x0d);
126 ret = regmap_write(dev->regmap[0], 0x01, 0xba); 177 if (ret)
127 ret = regmap_write(dev->regmap[0], 0x02, 0x13); 178 goto err;
128 ret = regmap_write(dev->regmap[0], 0x03, 0x80); 179 ret = regmap_bulk_write(dev->regmap[0], 0x01,
129 ret = regmap_write(dev->regmap[0], 0x04, 0xba); 180 "\xba\x13\x80\xba\x91\xdd\xe7\x28", 8);
130 ret = regmap_write(dev->regmap[0], 0x05, 0x91); 181 if (ret)
131 ret = regmap_write(dev->regmap[0], 0x07, 0xe7); 182 goto err;
132 ret = regmap_write(dev->regmap[0], 0x08, 0x28);
133 ret = regmap_write(dev->regmap[0], 0x0a, 0x1a); 183 ret = regmap_write(dev->regmap[0], 0x0a, 0x1a);
184 if (ret)
185 goto err;
134 ret = regmap_write(dev->regmap[0], 0x13, 0x1f); 186 ret = regmap_write(dev->regmap[0], 0x13, 0x1f);
187 if (ret)
188 goto err;
135 ret = regmap_write(dev->regmap[0], 0x19, 0x03); 189 ret = regmap_write(dev->regmap[0], 0x19, 0x03);
190 if (ret)
191 goto err;
136 ret = regmap_write(dev->regmap[0], 0x1d, 0xb0); 192 ret = regmap_write(dev->regmap[0], 0x1d, 0xb0);
193 if (ret)
194 goto err;
137 ret = regmap_write(dev->regmap[0], 0x2a, 0x72); 195 ret = regmap_write(dev->regmap[0], 0x2a, 0x72);
196 if (ret)
197 goto err;
138 ret = regmap_write(dev->regmap[0], 0x2d, 0x00); 198 ret = regmap_write(dev->regmap[0], 0x2d, 0x00);
199 if (ret)
200 goto err;
139 ret = regmap_write(dev->regmap[0], 0x3c, 0x00); 201 ret = regmap_write(dev->regmap[0], 0x3c, 0x00);
202 if (ret)
203 goto err;
140 ret = regmap_write(dev->regmap[0], 0x3f, 0xf8); 204 ret = regmap_write(dev->regmap[0], 0x3f, 0xf8);
141 ret = regmap_write(dev->regmap[0], 0x40, 0xf4); 205 if (ret)
142 ret = regmap_write(dev->regmap[0], 0x41, 0x08); 206 goto err;
143 ret = regmap_write(dev->regmap[0], 0xd2, 0x29); 207 ret = regmap_bulk_write(dev->regmap[0], 0x40, "\xf4\x08", 2);
208 if (ret)
209 goto err;
210 ret = regmap_write(dev->regmap[0], 0xd2, reg_bank0_d2_val);
211 if (ret)
212 goto err;
144 ret = regmap_write(dev->regmap[0], 0xd4, 0x55); 213 ret = regmap_write(dev->regmap[0], 0xd4, 0x55);
145 ret = regmap_write(dev->regmap[1], 0x10, 0x10); 214 if (ret)
146 ret = regmap_write(dev->regmap[1], 0x11, 0xab); 215 goto err;
147 ret = regmap_write(dev->regmap[1], 0x12, 0x0d);
148 ret = regmap_write(dev->regmap[1], 0x13, 0xae);
149 ret = regmap_write(dev->regmap[1], 0x14, 0x1d);
150 ret = regmap_write(dev->regmap[1], 0x15, 0x9d);
151 ret = regmap_write(dev->regmap[1], 0xbe, 0x08); 216 ret = regmap_write(dev->regmap[1], 0xbe, 0x08);
152 ret = regmap_write(dev->regmap[2], 0x09, 0x08); 217 if (ret)
153 ret = regmap_write(dev->regmap[2], 0x08, 0x1d); 218 goto err;
154 ret = regmap_write(dev->regmap[0], 0xb2, 0x37); 219 ret = regmap_write(dev->regmap[0], 0xb2, 0x37);
220 if (ret)
221 goto err;
155 ret = regmap_write(dev->regmap[0], 0xd7, 0x04); 222 ret = regmap_write(dev->regmap[0], 0xd7, 0x04);
156 ret = regmap_write(dev->regmap[2], 0x32, 0x80);
157 ret = regmap_write(dev->regmap[2], 0x36, 0x00);
158 ret = regmap_write(dev->regmap[2], 0xf8, 0x9f);
159 if (ret) 223 if (ret)
160 goto err; 224 goto err;
161 225
162 dev->delivery_system = c->delivery_system; 226 /* Reset FSM */
227 ret = regmap_write(dev->regmap[2], 0xf8, 0x9f);
228 if (ret)
229 goto err;
163 230
164 return 0; 231 return 0;
165err: 232err:
@@ -173,51 +240,61 @@ static int mn88473_read_status(struct dvb_frontend *fe, enum fe_status *status)
173 struct mn88473_dev *dev = i2c_get_clientdata(client); 240 struct mn88473_dev *dev = i2c_get_clientdata(client);
174 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 241 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
175 int ret; 242 int ret;
176 unsigned int utmp; 243 unsigned int uitmp;
177 int lock = 0;
178
179 *status = 0;
180 244
181 if (!dev->warm) { 245 if (!dev->active) {
182 ret = -EAGAIN; 246 ret = -EAGAIN;
183 goto err; 247 goto err;
184 } 248 }
185 249
250 *status = 0;
251
186 switch (c->delivery_system) { 252 switch (c->delivery_system) {
187 case SYS_DVBT: 253 case SYS_DVBT:
188 ret = regmap_read(dev->regmap[0], 0x62, &utmp); 254 ret = regmap_read(dev->regmap[0], 0x62, &uitmp);
189 if (ret) 255 if (ret)
190 goto err; 256 goto err;
191 if (!(utmp & 0xA0)) { 257
192 if ((utmp & 0xF) >= 0x03) 258 if (!(uitmp & 0xa0)) {
193 *status |= FE_HAS_SIGNAL; 259 if ((uitmp & 0x0f) >= 0x09)
194 if ((utmp & 0xF) >= 0x09) 260 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER |
195 lock = 1; 261 FE_HAS_VITERBI | FE_HAS_SYNC |
262 FE_HAS_LOCK;
263 else if ((uitmp & 0x0f) >= 0x03)
264 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER;
196 } 265 }
197 break; 266 break;
198 case SYS_DVBT2: 267 case SYS_DVBT2:
199 ret = regmap_read(dev->regmap[2], 0x8B, &utmp); 268 ret = regmap_read(dev->regmap[2], 0x8b, &uitmp);
200 if (ret) 269 if (ret)
201 goto err; 270 goto err;
202 if (!(utmp & 0x40)) { 271
203 if ((utmp & 0xF) >= 0x07) 272 if (!(uitmp & 0x40)) {
204 *status |= FE_HAS_SIGNAL; 273 if ((uitmp & 0x0f) >= 0x0d)
205 if ((utmp & 0xF) >= 0x0a) 274 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER |
206 *status |= FE_HAS_CARRIER; 275 FE_HAS_VITERBI | FE_HAS_SYNC |
207 if ((utmp & 0xF) >= 0x0d) 276 FE_HAS_LOCK;
208 *status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK; 277 else if ((uitmp & 0x0f) >= 0x0a)
278 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER |
279 FE_HAS_VITERBI;
280 else if ((uitmp & 0x0f) >= 0x07)
281 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER;
209 } 282 }
210 break; 283 break;
211 case SYS_DVBC_ANNEX_A: 284 case SYS_DVBC_ANNEX_A:
212 ret = regmap_read(dev->regmap[1], 0x85, &utmp); 285 ret = regmap_read(dev->regmap[1], 0x85, &uitmp);
213 if (ret) 286 if (ret)
214 goto err; 287 goto err;
215 if (!(utmp & 0x40)) { 288
216 ret = regmap_read(dev->regmap[1], 0x89, &utmp); 289 if (!(uitmp & 0x40)) {
290 ret = regmap_read(dev->regmap[1], 0x89, &uitmp);
217 if (ret) 291 if (ret)
218 goto err; 292 goto err;
219 if (utmp & 0x01) 293
220 lock = 1; 294 if (uitmp & 0x01)
295 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER |
296 FE_HAS_VITERBI | FE_HAS_SYNC |
297 FE_HAS_LOCK;
221 } 298 }
222 break; 299 break;
223 default: 300 default:
@@ -225,10 +302,6 @@ static int mn88473_read_status(struct dvb_frontend *fe, enum fe_status *status)
225 goto err; 302 goto err;
226 } 303 }
227 304
228 if (lock)
229 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
230 FE_HAS_SYNC | FE_HAS_LOCK;
231
232 return 0; 305 return 0;
233err: 306err:
234 dev_dbg(&client->dev, "failed=%d\n", ret); 307 dev_dbg(&client->dev, "failed=%d\n", ret);
@@ -239,85 +312,76 @@ static int mn88473_init(struct dvb_frontend *fe)
239{ 312{
240 struct i2c_client *client = fe->demodulator_priv; 313 struct i2c_client *client = fe->demodulator_priv;
241 struct mn88473_dev *dev = i2c_get_clientdata(client); 314 struct mn88473_dev *dev = i2c_get_clientdata(client);
242 int ret, len, remaining; 315 int ret, len, remain;
243 const struct firmware *fw = NULL; 316 unsigned int uitmp;
244 u8 *fw_file = MN88473_FIRMWARE; 317 const struct firmware *fw;
245 unsigned int tmp; 318 const char *name = MN88473_FIRMWARE;
246 319
247 dev_dbg(&client->dev, "\n"); 320 dev_dbg(&client->dev, "\n");
248 321
249 /* set cold state by default */ 322 /* Check if firmware is already running */
250 dev->warm = false; 323 ret = regmap_read(dev->regmap[0], 0xf5, &uitmp);
251
252 /* check if firmware is already running */
253 ret = regmap_read(dev->regmap[0], 0xf5, &tmp);
254 if (ret) 324 if (ret)
255 goto err; 325 goto err;
256 326
257 if (!(tmp & 0x1)) { 327 if (!(uitmp & 0x01))
258 dev_info(&client->dev, "firmware already running\n"); 328 goto warm;
259 dev->warm = true;
260 return 0;
261 }
262 329
263 /* request the firmware, this will block and timeout */ 330 /* Request the firmware, this will block and timeout */
264 ret = request_firmware(&fw, fw_file, &client->dev); 331 ret = request_firmware(&fw, name, &client->dev);
265 if (ret) { 332 if (ret) {
266 dev_err(&client->dev, "firmare file '%s' not found\n", fw_file); 333 dev_err(&client->dev, "firmare file '%s' not found\n", name);
267 goto err_request_firmware; 334 goto err;
268 } 335 }
269 336
270 dev_info(&client->dev, "downloading firmware from file '%s'\n", 337 dev_info(&client->dev, "downloading firmware from file '%s'\n", name);
271 fw_file);
272 338
273 ret = regmap_write(dev->regmap[0], 0xf5, 0x03); 339 ret = regmap_write(dev->regmap[0], 0xf5, 0x03);
274 if (ret) 340 if (ret)
275 goto err; 341 goto err_release_firmware;
276
277 for (remaining = fw->size; remaining > 0;
278 remaining -= (dev->i2c_wr_max - 1)) {
279 len = remaining;
280 if (len > (dev->i2c_wr_max - 1))
281 len = dev->i2c_wr_max - 1;
282 342
343 for (remain = fw->size; remain > 0; remain -= (dev->i2c_wr_max - 1)) {
344 len = min(dev->i2c_wr_max - 1, remain);
283 ret = regmap_bulk_write(dev->regmap[0], 0xf6, 345 ret = regmap_bulk_write(dev->regmap[0], 0xf6,
284 &fw->data[fw->size - remaining], len); 346 &fw->data[fw->size - remain], len);
285 if (ret) { 347 if (ret) {
286 dev_err(&client->dev, "firmware download failed=%d\n", 348 dev_err(&client->dev, "firmware download failed %d\n",
287 ret); 349 ret);
288 goto err; 350 goto err_release_firmware;
289 } 351 }
290 } 352 }
291 353
292 /* parity check of firmware */ 354 release_firmware(fw);
293 ret = regmap_read(dev->regmap[0], 0xf8, &tmp); 355
294 if (ret) { 356 /* Parity check of firmware */
295 dev_err(&client->dev, 357 ret = regmap_read(dev->regmap[0], 0xf8, &uitmp);
296 "parity reg read failed=%d\n", ret); 358 if (ret)
297 goto err; 359 goto err;
298 } 360
299 if (tmp & 0x10) { 361 if (uitmp & 0x10) {
300 dev_err(&client->dev, 362 dev_err(&client->dev, "firmware parity check failed\n");
301 "firmware parity check failed=0x%x\n", tmp); 363 ret = -EINVAL;
302 goto err; 364 goto err;
303 } 365 }
304 dev_err(&client->dev, "firmware parity check succeeded=0x%x\n", tmp);
305 366
306 ret = regmap_write(dev->regmap[0], 0xf5, 0x00); 367 ret = regmap_write(dev->regmap[0], 0xf5, 0x00);
307 if (ret) 368 if (ret)
308 goto err; 369 goto err;
370warm:
371 /* TS config */
372 ret = regmap_write(dev->regmap[2], 0x09, 0x08);
373 if (ret)
374 goto err;
375 ret = regmap_write(dev->regmap[2], 0x08, 0x1d);
376 if (ret)
377 goto err;
309 378
310 release_firmware(fw); 379 dev->active = true;
311 fw = NULL;
312
313 /* warm state */
314 dev->warm = true;
315 380
316 return 0; 381 return 0;
317 382err_release_firmware:
318err:
319 release_firmware(fw); 383 release_firmware(fw);
320err_request_firmware: 384err:
321 dev_dbg(&client->dev, "failed=%d\n", ret); 385 dev_dbg(&client->dev, "failed=%d\n", ret);
322 return ret; 386 return ret;
323} 387}
@@ -330,20 +394,20 @@ static int mn88473_sleep(struct dvb_frontend *fe)
330 394
331 dev_dbg(&client->dev, "\n"); 395 dev_dbg(&client->dev, "\n");
332 396
397 dev->active = false;
398
333 ret = regmap_write(dev->regmap[2], 0x05, 0x3e); 399 ret = regmap_write(dev->regmap[2], 0x05, 0x3e);
334 if (ret) 400 if (ret)
335 goto err; 401 goto err;
336 402
337 dev->delivery_system = SYS_UNDEFINED;
338
339 return 0; 403 return 0;
340err: 404err:
341 dev_dbg(&client->dev, "failed=%d\n", ret); 405 dev_dbg(&client->dev, "failed=%d\n", ret);
342 return ret; 406 return ret;
343} 407}
344 408
345static struct dvb_frontend_ops mn88473_ops = { 409static const struct dvb_frontend_ops mn88473_ops = {
346 .delsys = {SYS_DVBT, SYS_DVBT2, SYS_DVBC_ANNEX_AC}, 410 .delsys = {SYS_DVBT, SYS_DVBT2, SYS_DVBC_ANNEX_A},
347 .info = { 411 .info = {
348 .name = "Panasonic MN88473", 412 .name = "Panasonic MN88473",
349 .symbol_rate_min = 1000000, 413 .symbol_rate_min = 1000000,
@@ -365,8 +429,7 @@ static struct dvb_frontend_ops mn88473_ops = {
365 FE_CAN_GUARD_INTERVAL_AUTO | 429 FE_CAN_GUARD_INTERVAL_AUTO |
366 FE_CAN_HIERARCHY_AUTO | 430 FE_CAN_HIERARCHY_AUTO |
367 FE_CAN_MUTE_TS | 431 FE_CAN_MUTE_TS |
368 FE_CAN_2G_MODULATION | 432 FE_CAN_2G_MODULATION
369 FE_CAN_MULTISTREAM
370 }, 433 },
371 434
372 .get_tune_settings = mn88473_get_tune_settings, 435 .get_tune_settings = mn88473_get_tune_settings,
@@ -385,7 +448,7 @@ static int mn88473_probe(struct i2c_client *client,
385 struct mn88473_config *config = client->dev.platform_data; 448 struct mn88473_config *config = client->dev.platform_data;
386 struct mn88473_dev *dev; 449 struct mn88473_dev *dev;
387 int ret; 450 int ret;
388 unsigned int utmp; 451 unsigned int uitmp;
389 static const struct regmap_config regmap_config = { 452 static const struct regmap_config regmap_config = {
390 .reg_bits = 8, 453 .reg_bits = 8,
391 .val_bits = 8, 454 .val_bits = 8,
@@ -393,7 +456,7 @@ static int mn88473_probe(struct i2c_client *client,
393 456
394 dev_dbg(&client->dev, "\n"); 457 dev_dbg(&client->dev, "\n");
395 458
396 /* Caller really need to provide pointer for frontend we create. */ 459 /* Caller really need to provide pointer for frontend we create */
397 if (config->fe == NULL) { 460 if (config->fe == NULL) {
398 dev_err(&client->dev, "frontend pointer not defined\n"); 461 dev_err(&client->dev, "frontend pointer not defined\n");
399 ret = -EINVAL; 462 ret = -EINVAL;
@@ -406,11 +469,15 @@ static int mn88473_probe(struct i2c_client *client,
406 goto err; 469 goto err;
407 } 470 }
408 471
409 dev->i2c_wr_max = config->i2c_wr_max; 472 if (config->i2c_wr_max)
410 if (!config->xtal) 473 dev->i2c_wr_max = config->i2c_wr_max;
411 dev->xtal = 25000000;
412 else 474 else
413 dev->xtal = config->xtal; 475 dev->i2c_wr_max = ~0;
476
477 if (config->xtal)
478 dev->clk = config->xtal;
479 else
480 dev->clk = 25000000;
414 dev->client[0] = client; 481 dev->client[0] = client;
415 dev->regmap[0] = regmap_init_i2c(dev->client[0], &regmap_config); 482 dev->regmap[0] = regmap_init_i2c(dev->client[0], &regmap_config);
416 if (IS_ERR(dev->regmap[0])) { 483 if (IS_ERR(dev->regmap[0])) {
@@ -418,15 +485,25 @@ static int mn88473_probe(struct i2c_client *client,
418 goto err_kfree; 485 goto err_kfree;
419 } 486 }
420 487
421 /* check demod answers to I2C */ 488 /* Check demod answers with correct chip id */
422 ret = regmap_read(dev->regmap[0], 0x00, &utmp); 489 ret = regmap_read(dev->regmap[0], 0xff, &uitmp);
423 if (ret) 490 if (ret)
424 goto err_regmap_0_regmap_exit; 491 goto err_regmap_0_regmap_exit;
425 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
426 /* 500 /*
427 * Chip has three I2C addresses for different register pages. Used 501 * Chip has three I2C addresses for different register banks. Used
428 * addresses are 0x18, 0x1a and 0x1c. We register two dummy clients, 502 * addresses are 0x18, 0x1a and 0x1c. We register two dummy clients,
429 * 0x1a and 0x1c, in order to get own I2C client for each register page. 503 * 0x1a and 0x1c, in order to get own I2C client for each register bank.
504 *
505 * Also, register bank 2 do not support sequential I/O. Only single
506 * register write or read is allowed to that bank.
430 */ 507 */
431 dev->client[1] = i2c_new_dummy(client->adapter, 0x1a); 508 dev->client[1] = i2c_new_dummy(client->adapter, 0x1a);
432 if (dev->client[1] == NULL) { 509 if (dev->client[1] == NULL) {
@@ -456,13 +533,19 @@ static int mn88473_probe(struct i2c_client *client,
456 } 533 }
457 i2c_set_clientdata(dev->client[2], dev); 534 i2c_set_clientdata(dev->client[2], dev);
458 535
459 /* create dvb_frontend */ 536 /* Sleep because chip is active by default */
460 memcpy(&dev->fe.ops, &mn88473_ops, sizeof(struct dvb_frontend_ops)); 537 ret = regmap_write(dev->regmap[2], 0x05, 0x3e);
461 dev->fe.demodulator_priv = client; 538 if (ret)
462 *config->fe = &dev->fe; 539 goto err_client_2_i2c_unregister_device;
540
541 /* Create dvb frontend */
542 memcpy(&dev->frontend.ops, &mn88473_ops, sizeof(dev->frontend.ops));
543 dev->frontend.demodulator_priv = client;
544 *config->fe = &dev->frontend;
463 i2c_set_clientdata(client, dev); 545 i2c_set_clientdata(client, dev);
464 546
465 dev_info(&dev->client[0]->dev, "Panasonic MN88473 successfully attached\n"); 547 dev_info(&client->dev, "Panasonic MN88473 successfully identified\n");
548
466 return 0; 549 return 0;
467 550
468err_client_2_i2c_unregister_device: 551err_client_2_i2c_unregister_device:
@@ -507,7 +590,8 @@ MODULE_DEVICE_TABLE(i2c, mn88473_id_table);
507 590
508static struct i2c_driver mn88473_driver = { 591static struct i2c_driver mn88473_driver = {
509 .driver = { 592 .driver = {
510 .name = "mn88473", 593 .name = "mn88473",
594 .suppress_bind_attrs = true,
511 }, 595 },
512 .probe = mn88473_probe, 596 .probe = mn88473_probe,
513 .remove = mn88473_remove, 597 .remove = mn88473_remove,
diff --git a/drivers/media/dvb-frontends/mn88473.h b/drivers/media/dvb-frontends/mn88473.h
index c717ebed0e03..2aa5181f3033 100644
--- a/drivers/media/dvb-frontends/mn88473.h
+++ b/drivers/media/dvb-frontends/mn88473.h
@@ -22,10 +22,16 @@
22struct mn88473_config { 22struct mn88473_config {
23 /* 23 /*
24 * Max num of bytes given I2C adapter could write at once. 24 * Max num of bytes given I2C adapter could write at once.
25 * Default: none 25 * Default: unlimited
26 */ 26 */
27 u16 i2c_wr_max; 27 u16 i2c_wr_max;
28 28
29 /*
30 * Xtal frequency Hz.
31 * Default: 25000000
32 */
33 u32 xtal;
34
29 35
30 /* Everything after that is returned by the driver. */ 36 /* Everything after that is returned by the driver. */
31 37
@@ -33,12 +39,6 @@ struct mn88473_config {
33 * DVB frontend. 39 * DVB frontend.
34 */ 40 */
35 struct dvb_frontend **fe; 41 struct dvb_frontend **fe;
36
37 /*
38 * Xtal frequency.
39 * Hz
40 */
41 u32 xtal;
42}; 42};
43 43
44#endif 44#endif
diff --git a/drivers/staging/media/mn88473/mn88473_priv.h b/drivers/media/dvb-frontends/mn88473_priv.h
index 54beb4241ccf..e6c65893e451 100644
--- a/drivers/staging/media/mn88473/mn88473_priv.h
+++ b/drivers/media/dvb-frontends/mn88473_priv.h
@@ -27,11 +27,10 @@
27struct mn88473_dev { 27struct mn88473_dev {
28 struct i2c_client *client[3]; 28 struct i2c_client *client[3];
29 struct regmap *regmap[3]; 29 struct regmap *regmap[3];
30 struct dvb_frontend fe; 30 struct dvb_frontend frontend;
31 u16 i2c_wr_max; 31 u16 i2c_wr_max;
32 enum fe_delivery_system delivery_system; 32 bool active;
33 bool warm; /* FW running */ 33 u32 clk;
34 u32 xtal;
35}; 34};
36 35
37#endif 36#endif
diff --git a/drivers/media/dvb-frontends/mt312.c b/drivers/media/dvb-frontends/mt312.c
index c36e6764eead..fc08429c99b7 100644
--- a/drivers/media/dvb-frontends/mt312.c
+++ b/drivers/media/dvb-frontends/mt312.c
@@ -647,9 +647,9 @@ static int mt312_set_frontend(struct dvb_frontend *fe)
647 return 0; 647 return 0;
648} 648}
649 649
650static int mt312_get_frontend(struct dvb_frontend *fe) 650static int mt312_get_frontend(struct dvb_frontend *fe,
651 struct dtv_frontend_properties *p)
651{ 652{
652 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
653 struct mt312_state *state = fe->demodulator_priv; 653 struct mt312_state *state = fe->demodulator_priv;
654 int ret; 654 int ret;
655 655
diff --git a/drivers/media/dvb-frontends/mt352.c b/drivers/media/dvb-frontends/mt352.c
index 123bb2f8e4b6..c0bb6328956b 100644
--- a/drivers/media/dvb-frontends/mt352.c
+++ b/drivers/media/dvb-frontends/mt352.c
@@ -311,9 +311,9 @@ static int mt352_set_parameters(struct dvb_frontend *fe)
311 return 0; 311 return 0;
312} 312}
313 313
314static int mt352_get_parameters(struct dvb_frontend* fe) 314static int mt352_get_parameters(struct dvb_frontend* fe,
315 struct dtv_frontend_properties *op)
315{ 316{
316 struct dtv_frontend_properties *op = &fe->dtv_property_cache;
317 struct mt352_state* state = fe->demodulator_priv; 317 struct mt352_state* state = fe->demodulator_priv;
318 u16 tps; 318 u16 tps;
319 u16 div; 319 u16 div;
diff --git a/drivers/media/dvb-frontends/or51132.c b/drivers/media/dvb-frontends/or51132.c
index 35b1053b3640..a165af990672 100644
--- a/drivers/media/dvb-frontends/or51132.c
+++ b/drivers/media/dvb-frontends/or51132.c
@@ -375,9 +375,9 @@ static int or51132_set_parameters(struct dvb_frontend *fe)
375 return 0; 375 return 0;
376} 376}
377 377
378static int or51132_get_parameters(struct dvb_frontend* fe) 378static int or51132_get_parameters(struct dvb_frontend* fe,
379 struct dtv_frontend_properties *p)
379{ 380{
380 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
381 struct or51132_state* state = fe->demodulator_priv; 381 struct or51132_state* state = fe->demodulator_priv;
382 int status; 382 int status;
383 int retry = 1; 383 int retry = 1;
diff --git a/drivers/media/dvb-frontends/rtl2830.c b/drivers/media/dvb-frontends/rtl2830.c
index b792f305cf15..3f96429af0e5 100644
--- a/drivers/media/dvb-frontends/rtl2830.c
+++ b/drivers/media/dvb-frontends/rtl2830.c
@@ -279,11 +279,11 @@ err:
279 return ret; 279 return ret;
280} 280}
281 281
282static int rtl2830_get_frontend(struct dvb_frontend *fe) 282static int rtl2830_get_frontend(struct dvb_frontend *fe,
283 struct dtv_frontend_properties *c)
283{ 284{
284 struct i2c_client *client = fe->demodulator_priv; 285 struct i2c_client *client = fe->demodulator_priv;
285 struct rtl2830_dev *dev = i2c_get_clientdata(client); 286 struct rtl2830_dev *dev = i2c_get_clientdata(client);
286 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
287 int ret; 287 int ret;
288 u8 buf[3]; 288 u8 buf[3];
289 289
@@ -900,6 +900,9 @@ static int rtl2830_remove(struct i2c_client *client)
900 900
901 dev_dbg(&client->dev, "\n"); 901 dev_dbg(&client->dev, "\n");
902 902
903 /* stop statistics polling */
904 cancel_delayed_work_sync(&dev->stat_work);
905
903 i2c_del_mux_adapter(dev->adapter); 906 i2c_del_mux_adapter(dev->adapter);
904 regmap_exit(dev->regmap); 907 regmap_exit(dev->regmap);
905 kfree(dev); 908 kfree(dev);
diff --git a/drivers/media/dvb-frontends/rtl2832.c b/drivers/media/dvb-frontends/rtl2832.c
index 10f2119935da..7c96f7679669 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -347,6 +347,10 @@ static int rtl2832_init(struct dvb_frontend *fe)
347 347
348 dev_dbg(&client->dev, "\n"); 348 dev_dbg(&client->dev, "\n");
349 349
350 ret = rtl2832_wr_demod_reg(dev, DVBT_SOFT_RST, 0x0);
351 if (ret)
352 goto err;
353
350 for (i = 0; i < ARRAY_SIZE(rtl2832_initial_regs); i++) { 354 for (i = 0; i < ARRAY_SIZE(rtl2832_initial_regs); i++) {
351 ret = rtl2832_wr_demod_reg(dev, rtl2832_initial_regs[i].reg, 355 ret = rtl2832_wr_demod_reg(dev, rtl2832_initial_regs[i].reg,
352 rtl2832_initial_regs[i].value); 356 rtl2832_initial_regs[i].value);
@@ -404,8 +408,6 @@ static int rtl2832_init(struct dvb_frontend *fe)
404 c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; 408 c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
405 c->post_bit_count.len = 1; 409 c->post_bit_count.len = 1;
406 c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; 410 c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
407 /* start statistics polling */
408 schedule_delayed_work(&dev->stat_work, msecs_to_jiffies(2000));
409 dev->sleeping = false; 411 dev->sleeping = false;
410 412
411 return 0; 413 return 0;
@@ -423,8 +425,6 @@ static int rtl2832_sleep(struct dvb_frontend *fe)
423 dev_dbg(&client->dev, "\n"); 425 dev_dbg(&client->dev, "\n");
424 426
425 dev->sleeping = true; 427 dev->sleeping = true;
426 /* stop statistics polling */
427 cancel_delayed_work_sync(&dev->stat_work);
428 dev->fe_status = 0; 428 dev->fe_status = 0;
429 429
430 ret = rtl2832_wr_demod_reg(dev, DVBT_SOFT_RST, 0x1); 430 ret = rtl2832_wr_demod_reg(dev, DVBT_SOFT_RST, 0x1);
@@ -491,11 +491,6 @@ static int rtl2832_set_frontend(struct dvb_frontend *fe)
491 if (fe->ops.tuner_ops.set_params) 491 if (fe->ops.tuner_ops.set_params)
492 fe->ops.tuner_ops.set_params(fe); 492 fe->ops.tuner_ops.set_params(fe);
493 493
494 /* PIP mode related */
495 ret = rtl2832_bulk_write(client, 0x192, "\x00\x0f\xff", 3);
496 if (ret)
497 goto err;
498
499 /* If the frontend has get_if_frequency(), use it */ 494 /* If the frontend has get_if_frequency(), use it */
500 if (fe->ops.tuner_ops.get_if_frequency) { 495 if (fe->ops.tuner_ops.get_if_frequency) {
501 u32 if_freq; 496 u32 if_freq;
@@ -575,11 +570,11 @@ err:
575 return ret; 570 return ret;
576} 571}
577 572
578static int rtl2832_get_frontend(struct dvb_frontend *fe) 573static int rtl2832_get_frontend(struct dvb_frontend *fe,
574 struct dtv_frontend_properties *c)
579{ 575{
580 struct rtl2832_dev *dev = fe->demodulator_priv; 576 struct rtl2832_dev *dev = fe->demodulator_priv;
581 struct i2c_client *client = dev->client; 577 struct i2c_client *client = dev->client;
582 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
583 int ret; 578 int ret;
584 u8 buf[3]; 579 u8 buf[3];
585 580
@@ -692,8 +687,11 @@ static int rtl2832_read_status(struct dvb_frontend *fe, enum fe_status *status)
692{ 687{
693 struct rtl2832_dev *dev = fe->demodulator_priv; 688 struct rtl2832_dev *dev = fe->demodulator_priv;
694 struct i2c_client *client = dev->client; 689 struct i2c_client *client = dev->client;
690 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
695 int ret; 691 int ret;
696 u32 uninitialized_var(tmp); 692 u32 uninitialized_var(tmp);
693 u8 u8tmp, buf[2];
694 u16 u16tmp;
697 695
698 dev_dbg(&client->dev, "\n"); 696 dev_dbg(&client->dev, "\n");
699 697
@@ -714,45 +712,6 @@ static int rtl2832_read_status(struct dvb_frontend *fe, enum fe_status *status)
714 } 712 }
715 713
716 dev->fe_status = *status; 714 dev->fe_status = *status;
717 return 0;
718err:
719 dev_dbg(&client->dev, "failed=%d\n", ret);
720 return ret;
721}
722
723static int rtl2832_read_snr(struct dvb_frontend *fe, u16 *snr)
724{
725 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
726
727 /* report SNR in resolution of 0.1 dB */
728 if (c->cnr.stat[0].scale == FE_SCALE_DECIBEL)
729 *snr = div_s64(c->cnr.stat[0].svalue, 100);
730 else
731 *snr = 0;
732
733 return 0;
734}
735
736static int rtl2832_read_ber(struct dvb_frontend *fe, u32 *ber)
737{
738 struct rtl2832_dev *dev = fe->demodulator_priv;
739
740 *ber = (dev->post_bit_error - dev->post_bit_error_prev);
741 dev->post_bit_error_prev = dev->post_bit_error;
742
743 return 0;
744}
745
746static void rtl2832_stat_work(struct work_struct *work)
747{
748 struct rtl2832_dev *dev = container_of(work, struct rtl2832_dev, stat_work.work);
749 struct i2c_client *client = dev->client;
750 struct dtv_frontend_properties *c = &dev->fe.dtv_property_cache;
751 int ret, tmp;
752 u8 u8tmp, buf[2];
753 u16 u16tmp;
754
755 dev_dbg(&client->dev, "\n");
756 715
757 /* signal strength */ 716 /* signal strength */
758 if (dev->fe_status & FE_HAS_SIGNAL) { 717 if (dev->fe_status & FE_HAS_SIGNAL) {
@@ -789,11 +748,11 @@ static void rtl2832_stat_work(struct work_struct *work)
789 748
790 constellation = (u8tmp >> 2) & 0x03; /* [3:2] */ 749 constellation = (u8tmp >> 2) & 0x03; /* [3:2] */
791 if (constellation > CONSTELLATION_NUM - 1) 750 if (constellation > CONSTELLATION_NUM - 1)
792 goto err_schedule_delayed_work; 751 goto err;
793 752
794 hierarchy = (u8tmp >> 4) & 0x07; /* [6:4] */ 753 hierarchy = (u8tmp >> 4) & 0x07; /* [6:4] */
795 if (hierarchy > HIERARCHY_NUM - 1) 754 if (hierarchy > HIERARCHY_NUM - 1)
796 goto err_schedule_delayed_work; 755 goto err;
797 756
798 ret = rtl2832_bulk_read(client, 0x40c, buf, 2); 757 ret = rtl2832_bulk_read(client, 0x40c, buf, 2);
799 if (ret) 758 if (ret)
@@ -835,11 +794,33 @@ static void rtl2832_stat_work(struct work_struct *work)
835 c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; 794 c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
836 } 795 }
837 796
838err_schedule_delayed_work: 797 return 0;
839 schedule_delayed_work(&dev->stat_work, msecs_to_jiffies(2000));
840 return;
841err: 798err:
842 dev_dbg(&client->dev, "failed=%d\n", ret); 799 dev_dbg(&client->dev, "failed=%d\n", ret);
800 return ret;
801}
802
803static int rtl2832_read_snr(struct dvb_frontend *fe, u16 *snr)
804{
805 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
806
807 /* report SNR in resolution of 0.1 dB */
808 if (c->cnr.stat[0].scale == FE_SCALE_DECIBEL)
809 *snr = div_s64(c->cnr.stat[0].svalue, 100);
810 else
811 *snr = 0;
812
813 return 0;
814}
815
816static int rtl2832_read_ber(struct dvb_frontend *fe, u32 *ber)
817{
818 struct rtl2832_dev *dev = fe->demodulator_priv;
819
820 *ber = (dev->post_bit_error - dev->post_bit_error_prev);
821 dev->post_bit_error_prev = dev->post_bit_error;
822
823 return 0;
843} 824}
844 825
845/* 826/*
@@ -1081,37 +1062,46 @@ static struct i2c_adapter *rtl2832_get_i2c_adapter(struct i2c_client *client)
1081 return dev->i2c_adapter_tuner; 1062 return dev->i2c_adapter_tuner;
1082} 1063}
1083 1064
1084static int rtl2832_enable_slave_ts(struct i2c_client *client) 1065static int rtl2832_slave_ts_ctrl(struct i2c_client *client, bool enable)
1085{ 1066{
1086 struct rtl2832_dev *dev = i2c_get_clientdata(client); 1067 struct rtl2832_dev *dev = i2c_get_clientdata(client);
1087 int ret; 1068 int ret;
1088 1069
1089 dev_dbg(&client->dev, "\n"); 1070 dev_dbg(&client->dev, "enable=%d\n", enable);
1090
1091 ret = rtl2832_bulk_write(client, 0x10c, "\x5f\xff", 2);
1092 if (ret)
1093 goto err;
1094
1095 ret = rtl2832_wr_demod_reg(dev, DVBT_PIP_ON, 0x1);
1096 if (ret)
1097 goto err;
1098 1071
1099 ret = rtl2832_bulk_write(client, 0x0bc, "\x18", 1); 1072 if (enable) {
1100 if (ret) 1073 ret = rtl2832_wr_demod_reg(dev, DVBT_SOFT_RST, 0x0);
1101 goto err; 1074 if (ret)
1102 1075 goto err;
1103 ret = rtl2832_bulk_write(client, 0x192, "\x7f\xf7\xff", 3); 1076 ret = rtl2832_bulk_write(client, 0x10c, "\x5f\xff", 2);
1104 if (ret) 1077 if (ret)
1105 goto err; 1078 goto err;
1106 1079 ret = rtl2832_wr_demod_reg(dev, DVBT_PIP_ON, 0x1);
1107 /* soft reset */ 1080 if (ret)
1108 ret = rtl2832_wr_demod_reg(dev, DVBT_SOFT_RST, 0x1); 1081 goto err;
1109 if (ret) 1082 ret = rtl2832_bulk_write(client, 0x0bc, "\x18", 1);
1110 goto err; 1083 if (ret)
1111 1084 goto err;
1112 ret = rtl2832_wr_demod_reg(dev, DVBT_SOFT_RST, 0x0); 1085 ret = rtl2832_bulk_write(client, 0x192, "\x7f\xf7\xff", 3);
1113 if (ret) 1086 if (ret)
1114 goto err; 1087 goto err;
1088 } else {
1089 ret = rtl2832_bulk_write(client, 0x192, "\x00\x0f\xff", 3);
1090 if (ret)
1091 goto err;
1092 ret = rtl2832_bulk_write(client, 0x0bc, "\x08", 1);
1093 if (ret)
1094 goto err;
1095 ret = rtl2832_wr_demod_reg(dev, DVBT_PIP_ON, 0x0);
1096 if (ret)
1097 goto err;
1098 ret = rtl2832_bulk_write(client, 0x10c, "\x00\x00", 2);
1099 if (ret)
1100 goto err;
1101 ret = rtl2832_wr_demod_reg(dev, DVBT_SOFT_RST, 0x1);
1102 if (ret)
1103 goto err;
1104 }
1115 1105
1116 return 0; 1106 return 0;
1117err: 1107err:
@@ -1227,7 +1217,6 @@ static int rtl2832_probe(struct i2c_client *client,
1227 dev->pdata = client->dev.platform_data; 1217 dev->pdata = client->dev.platform_data;
1228 dev->sleeping = true; 1218 dev->sleeping = true;
1229 INIT_DELAYED_WORK(&dev->i2c_gate_work, rtl2832_i2c_gate_work); 1219 INIT_DELAYED_WORK(&dev->i2c_gate_work, rtl2832_i2c_gate_work);
1230 INIT_DELAYED_WORK(&dev->stat_work, rtl2832_stat_work);
1231 /* create regmap */ 1220 /* create regmap */
1232 mutex_init(&dev->regmap_mutex); 1221 mutex_init(&dev->regmap_mutex);
1233 dev->regmap_config.reg_bits = 8, 1222 dev->regmap_config.reg_bits = 8,
@@ -1267,7 +1256,7 @@ static int rtl2832_probe(struct i2c_client *client,
1267 /* setup callbacks */ 1256 /* setup callbacks */
1268 pdata->get_dvb_frontend = rtl2832_get_dvb_frontend; 1257 pdata->get_dvb_frontend = rtl2832_get_dvb_frontend;
1269 pdata->get_i2c_adapter = rtl2832_get_i2c_adapter; 1258 pdata->get_i2c_adapter = rtl2832_get_i2c_adapter;
1270 pdata->enable_slave_ts = rtl2832_enable_slave_ts; 1259 pdata->slave_ts_ctrl = rtl2832_slave_ts_ctrl;
1271 pdata->pid_filter = rtl2832_pid_filter; 1260 pdata->pid_filter = rtl2832_pid_filter;
1272 pdata->pid_filter_ctrl = rtl2832_pid_filter_ctrl; 1261 pdata->pid_filter_ctrl = rtl2832_pid_filter_ctrl;
1273 pdata->bulk_read = rtl2832_bulk_read; 1262 pdata->bulk_read = rtl2832_bulk_read;
diff --git a/drivers/media/dvb-frontends/rtl2832.h b/drivers/media/dvb-frontends/rtl2832.h
index c29a4c2bf71a..6390af64cf45 100644
--- a/drivers/media/dvb-frontends/rtl2832.h
+++ b/drivers/media/dvb-frontends/rtl2832.h
@@ -31,7 +31,7 @@
31 * @tuner: Used tuner model. 31 * @tuner: Used tuner model.
32 * @get_dvb_frontend: Get DVB frontend. 32 * @get_dvb_frontend: Get DVB frontend.
33 * @get_i2c_adapter: Get I2C adapter. 33 * @get_i2c_adapter: Get I2C adapter.
34 * @enable_slave_ts: Enable slave TS IF. 34 * @slave_ts_ctrl: Control slave TS interface.
35 * @pid_filter: Set PID to PID filter. 35 * @pid_filter: Set PID to PID filter.
36 * @pid_filter_ctrl: Control PID filter. 36 * @pid_filter_ctrl: Control PID filter.
37 */ 37 */
@@ -53,7 +53,7 @@ struct rtl2832_platform_data {
53 53
54 struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *); 54 struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *);
55 struct i2c_adapter* (*get_i2c_adapter)(struct i2c_client *); 55 struct i2c_adapter* (*get_i2c_adapter)(struct i2c_client *);
56 int (*enable_slave_ts)(struct i2c_client *); 56 int (*slave_ts_ctrl)(struct i2c_client *, bool);
57 int (*pid_filter)(struct dvb_frontend *, u8, u16, int); 57 int (*pid_filter)(struct dvb_frontend *, u8, u16, int);
58 int (*pid_filter_ctrl)(struct dvb_frontend *, int); 58 int (*pid_filter_ctrl)(struct dvb_frontend *, int);
59/* private: Register access for SDR module use only */ 59/* private: Register access for SDR module use only */
diff --git a/drivers/media/dvb-frontends/rtl2832_priv.h b/drivers/media/dvb-frontends/rtl2832_priv.h
index 5dcd3a41d23f..6b875f462f8b 100644
--- a/drivers/media/dvb-frontends/rtl2832_priv.h
+++ b/drivers/media/dvb-frontends/rtl2832_priv.h
@@ -38,7 +38,6 @@ struct rtl2832_dev {
38 struct regmap *regmap; 38 struct regmap *regmap;
39 struct i2c_adapter *i2c_adapter_tuner; 39 struct i2c_adapter *i2c_adapter_tuner;
40 struct dvb_frontend fe; 40 struct dvb_frontend fe;
41 struct delayed_work stat_work;
42 enum fe_status fe_status; 41 enum fe_status fe_status;
43 u64 post_bit_error_prev; /* for old DVBv3 read_ber() calculation */ 42 u64 post_bit_error_prev; /* for old DVBv3 read_ber() calculation */
44 u64 post_bit_error; 43 u64 post_bit_error;
diff --git a/drivers/media/dvb-frontends/s5h1409.c b/drivers/media/dvb-frontends/s5h1409.c
index 10964848a2f1..c68965ad97c0 100644
--- a/drivers/media/dvb-frontends/s5h1409.c
+++ b/drivers/media/dvb-frontends/s5h1409.c
@@ -925,9 +925,9 @@ static int s5h1409_read_ber(struct dvb_frontend *fe, u32 *ber)
925 return s5h1409_read_ucblocks(fe, ber); 925 return s5h1409_read_ucblocks(fe, ber);
926} 926}
927 927
928static int s5h1409_get_frontend(struct dvb_frontend *fe) 928static int s5h1409_get_frontend(struct dvb_frontend *fe,
929 struct dtv_frontend_properties *p)
929{ 930{
930 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
931 struct s5h1409_state *state = fe->demodulator_priv; 931 struct s5h1409_state *state = fe->demodulator_priv;
932 932
933 p->frequency = state->current_frequency; 933 p->frequency = state->current_frequency;
diff --git a/drivers/media/dvb-frontends/s5h1411.c b/drivers/media/dvb-frontends/s5h1411.c
index 9afc3f42290e..90f86e82b087 100644
--- a/drivers/media/dvb-frontends/s5h1411.c
+++ b/drivers/media/dvb-frontends/s5h1411.c
@@ -840,9 +840,9 @@ static int s5h1411_read_ber(struct dvb_frontend *fe, u32 *ber)
840 return s5h1411_read_ucblocks(fe, ber); 840 return s5h1411_read_ucblocks(fe, ber);
841} 841}
842 842
843static int s5h1411_get_frontend(struct dvb_frontend *fe) 843static int s5h1411_get_frontend(struct dvb_frontend *fe,
844 struct dtv_frontend_properties *p)
844{ 845{
845 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
846 struct s5h1411_state *state = fe->demodulator_priv; 846 struct s5h1411_state *state = fe->demodulator_priv;
847 847
848 p->frequency = state->current_frequency; 848 p->frequency = state->current_frequency;
diff --git a/drivers/media/dvb-frontends/s5h1420.c b/drivers/media/dvb-frontends/s5h1420.c
index 9c22a4c70d87..d7d0b7d57ad7 100644
--- a/drivers/media/dvb-frontends/s5h1420.c
+++ b/drivers/media/dvb-frontends/s5h1420.c
@@ -756,9 +756,9 @@ static int s5h1420_set_frontend(struct dvb_frontend *fe)
756 return 0; 756 return 0;
757} 757}
758 758
759static int s5h1420_get_frontend(struct dvb_frontend* fe) 759static int s5h1420_get_frontend(struct dvb_frontend* fe,
760 struct dtv_frontend_properties *p)
760{ 761{
761 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
762 struct s5h1420_state* state = fe->demodulator_priv; 762 struct s5h1420_state* state = fe->demodulator_priv;
763 763
764 p->frequency = state->tunedfreq + s5h1420_getfreqoffset(state); 764 p->frequency = state->tunedfreq + s5h1420_getfreqoffset(state);
diff --git a/drivers/media/dvb-frontends/s921.c b/drivers/media/dvb-frontends/s921.c
index d6a8fa63040b..b5e3d90eba5e 100644
--- a/drivers/media/dvb-frontends/s921.c
+++ b/drivers/media/dvb-frontends/s921.c
@@ -433,9 +433,9 @@ static int s921_set_frontend(struct dvb_frontend *fe)
433 return 0; 433 return 0;
434} 434}
435 435
436static int s921_get_frontend(struct dvb_frontend *fe) 436static int s921_get_frontend(struct dvb_frontend *fe,
437 struct dtv_frontend_properties *p)
437{ 438{
438 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
439 struct s921_state *state = fe->demodulator_priv; 439 struct s921_state *state = fe->demodulator_priv;
440 440
441 /* FIXME: Probably it is possible to get it from regs f1 and f2 */ 441 /* FIXME: Probably it is possible to get it from regs f1 and f2 */
diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index 2b93241d4bc1..8bf716a8ea58 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -225,22 +225,18 @@ static int si2165_writereg32(struct si2165_state *state, const u16 reg, u32 val)
225static int si2165_writereg_mask8(struct si2165_state *state, const u16 reg, 225static int si2165_writereg_mask8(struct si2165_state *state, const u16 reg,
226 u8 val, u8 mask) 226 u8 val, u8 mask)
227{ 227{
228 int ret;
229 u8 tmp;
230
231 if (mask != 0xff) { 228 if (mask != 0xff) {
232 ret = si2165_readreg8(state, reg, &tmp); 229 u8 tmp;
230 int ret = si2165_readreg8(state, reg, &tmp);
231
233 if (ret < 0) 232 if (ret < 0)
234 goto err; 233 return ret;
235 234
236 val &= mask; 235 val &= mask;
237 tmp &= ~mask; 236 tmp &= ~mask;
238 val |= tmp; 237 val |= tmp;
239 } 238 }
240 239 return si2165_writereg8(state, reg, val);
241 ret = si2165_writereg8(state, reg, val);
242err:
243 return ret;
244} 240}
245 241
246#define REG16(reg, val) { (reg), (val) & 0xff }, { (reg)+1, (val)>>8 & 0xff } 242#define REG16(reg, val) { (reg), (val) & 0xff }, { (reg)+1, (val)>>8 & 0xff }
@@ -825,19 +821,19 @@ static int si2165_set_frontend_dvbt(struct dvb_frontend *fe)
825 struct si2165_state *state = fe->demodulator_priv; 821 struct si2165_state *state = fe->demodulator_priv;
826 u32 dvb_rate = 0; 822 u32 dvb_rate = 0;
827 u16 bw10k; 823 u16 bw10k;
824 u32 bw_hz = p->bandwidth_hz;
828 825
829 dprintk("%s: called\n", __func__); 826 dprintk("%s: called\n", __func__);
830 827
831 if (!state->has_dvbt) 828 if (!state->has_dvbt)
832 return -EINVAL; 829 return -EINVAL;
833 830
834 if (p->bandwidth_hz > 0) { 831 /* no bandwidth auto-detection */
835 dvb_rate = p->bandwidth_hz * 8 / 7; 832 if (bw_hz == 0)
836 bw10k = p->bandwidth_hz / 10000; 833 return -EINVAL;
837 } else { 834
838 dvb_rate = 8 * 8 / 7; 835 dvb_rate = bw_hz * 8 / 7;
839 bw10k = 800; 836 bw10k = bw_hz / 10000;
840 }
841 837
842 ret = si2165_adjust_pll_divl(state, 12); 838 ret = si2165_adjust_pll_divl(state, 12);
843 if (ret < 0) 839 if (ret < 0)
diff --git a/drivers/media/dvb-frontends/stb0899_drv.c b/drivers/media/dvb-frontends/stb0899_drv.c
index 756650f154ab..3d171b0e00c2 100644
--- a/drivers/media/dvb-frontends/stb0899_drv.c
+++ b/drivers/media/dvb-frontends/stb0899_drv.c
@@ -1568,9 +1568,9 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe)
1568 return DVBFE_ALGO_SEARCH_ERROR; 1568 return DVBFE_ALGO_SEARCH_ERROR;
1569} 1569}
1570 1570
1571static int stb0899_get_frontend(struct dvb_frontend *fe) 1571static int stb0899_get_frontend(struct dvb_frontend *fe,
1572 struct dtv_frontend_properties *p)
1572{ 1573{
1573 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1574 struct stb0899_state *state = fe->demodulator_priv; 1574 struct stb0899_state *state = fe->demodulator_priv;
1575 struct stb0899_internal *internal = &state->internal; 1575 struct stb0899_internal *internal = &state->internal;
1576 1576
diff --git a/drivers/media/dvb-frontends/stb6100.c b/drivers/media/dvb-frontends/stb6100.c
index c978c801c7aa..b9c2511bf019 100644
--- a/drivers/media/dvb-frontends/stb6100.c
+++ b/drivers/media/dvb-frontends/stb6100.c
@@ -346,7 +346,7 @@ static int stb6100_set_frequency(struct dvb_frontend *fe, u32 frequency)
346 346
347 if (fe->ops.get_frontend) { 347 if (fe->ops.get_frontend) {
348 dprintk(verbose, FE_DEBUG, 1, "Get frontend parameters"); 348 dprintk(verbose, FE_DEBUG, 1, "Get frontend parameters");
349 fe->ops.get_frontend(fe); 349 fe->ops.get_frontend(fe, p);
350 } 350 }
351 srate = p->symbol_rate; 351 srate = p->symbol_rate;
352 352
diff --git a/drivers/media/dvb-frontends/stv0297.c b/drivers/media/dvb-frontends/stv0297.c
index 75b4d8b25657..81b27b7c0c96 100644
--- a/drivers/media/dvb-frontends/stv0297.c
+++ b/drivers/media/dvb-frontends/stv0297.c
@@ -615,9 +615,9 @@ timeout:
615 return 0; 615 return 0;
616} 616}
617 617
618static int stv0297_get_frontend(struct dvb_frontend *fe) 618static int stv0297_get_frontend(struct dvb_frontend *fe,
619 struct dtv_frontend_properties *p)
619{ 620{
620 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
621 struct stv0297_state *state = fe->demodulator_priv; 621 struct stv0297_state *state = fe->demodulator_priv;
622 int reg_00, reg_83; 622 int reg_00, reg_83;
623 623
diff --git a/drivers/media/dvb-frontends/stv0299.c b/drivers/media/dvb-frontends/stv0299.c
index a8177807fb65..7927fa925f2f 100644
--- a/drivers/media/dvb-frontends/stv0299.c
+++ b/drivers/media/dvb-frontends/stv0299.c
@@ -422,7 +422,7 @@ static int stv0299_send_legacy_dish_cmd (struct dvb_frontend* fe, unsigned long
422 if (debug_legacy_dish_switch) 422 if (debug_legacy_dish_switch)
423 printk ("%s switch command: 0x%04lx\n",__func__, cmd); 423 printk ("%s switch command: 0x%04lx\n",__func__, cmd);
424 424
425 nexttime = ktime_get_real(); 425 nexttime = ktime_get_boottime();
426 if (debug_legacy_dish_switch) 426 if (debug_legacy_dish_switch)
427 tv[0] = nexttime; 427 tv[0] = nexttime;
428 stv0299_writeregI (state, 0x0c, reg0x0c | 0x50); /* set LNB to 18V */ 428 stv0299_writeregI (state, 0x0c, reg0x0c | 0x50); /* set LNB to 18V */
@@ -431,7 +431,7 @@ static int stv0299_send_legacy_dish_cmd (struct dvb_frontend* fe, unsigned long
431 431
432 for (i=0; i<9; i++) { 432 for (i=0; i<9; i++) {
433 if (debug_legacy_dish_switch) 433 if (debug_legacy_dish_switch)
434 tv[i+1] = ktime_get_real(); 434 tv[i+1] = ktime_get_boottime();
435 if((cmd & 0x01) != last) { 435 if((cmd & 0x01) != last) {
436 /* set voltage to (last ? 13V : 18V) */ 436 /* set voltage to (last ? 13V : 18V) */
437 stv0299_writeregI (state, 0x0c, reg0x0c | (last ? lv_mask : 0x50)); 437 stv0299_writeregI (state, 0x0c, reg0x0c | (last ? lv_mask : 0x50));
@@ -602,9 +602,9 @@ static int stv0299_set_frontend(struct dvb_frontend *fe)
602 return 0; 602 return 0;
603} 603}
604 604
605static int stv0299_get_frontend(struct dvb_frontend *fe) 605static int stv0299_get_frontend(struct dvb_frontend *fe,
606 struct dtv_frontend_properties *p)
606{ 607{
607 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
608 struct stv0299_state* state = fe->demodulator_priv; 608 struct stv0299_state* state = fe->demodulator_priv;
609 s32 derot_freq; 609 s32 derot_freq;
610 int invval; 610 int invval;
diff --git a/drivers/media/dvb-frontends/stv0367.c b/drivers/media/dvb-frontends/stv0367.c
index 44cb73f68af6..abc379aea713 100644
--- a/drivers/media/dvb-frontends/stv0367.c
+++ b/drivers/media/dvb-frontends/stv0367.c
@@ -1938,9 +1938,9 @@ static int stv0367ter_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
1938 return 0; 1938 return 0;
1939} 1939}
1940 1940
1941static int stv0367ter_get_frontend(struct dvb_frontend *fe) 1941static int stv0367ter_get_frontend(struct dvb_frontend *fe,
1942 struct dtv_frontend_properties *p)
1942{ 1943{
1943 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1944 struct stv0367_state *state = fe->demodulator_priv; 1944 struct stv0367_state *state = fe->demodulator_priv;
1945 struct stv0367ter_state *ter_state = state->ter_state; 1945 struct stv0367ter_state *ter_state = state->ter_state;
1946 enum stv0367_ter_mode mode; 1946 enum stv0367_ter_mode mode;
@@ -3146,9 +3146,9 @@ static int stv0367cab_set_frontend(struct dvb_frontend *fe)
3146 return 0; 3146 return 0;
3147} 3147}
3148 3148
3149static int stv0367cab_get_frontend(struct dvb_frontend *fe) 3149static int stv0367cab_get_frontend(struct dvb_frontend *fe,
3150 struct dtv_frontend_properties *p)
3150{ 3151{
3151 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
3152 struct stv0367_state *state = fe->demodulator_priv; 3152 struct stv0367_state *state = fe->demodulator_priv;
3153 struct stv0367cab_state *cab_state = state->cab_state; 3153 struct stv0367cab_state *cab_state = state->cab_state;
3154 3154
diff --git a/drivers/media/dvb-frontends/stv0900_core.c b/drivers/media/dvb-frontends/stv0900_core.c
index fe31dd541955..f667005a6661 100644
--- a/drivers/media/dvb-frontends/stv0900_core.c
+++ b/drivers/media/dvb-frontends/stv0900_core.c
@@ -1087,7 +1087,7 @@ u8 stv0900_get_optim_carr_loop(s32 srate, enum fe_stv0900_modcode modcode,
1087 s32 pilot, u8 chip_id) 1087 s32 pilot, u8 chip_id)
1088{ 1088{
1089 u8 aclc_value = 0x29; 1089 u8 aclc_value = 0x29;
1090 s32 i; 1090 s32 i, cllas2_size;
1091 const struct stv0900_car_loop_optim *cls2, *cllqs2, *cllas2; 1091 const struct stv0900_car_loop_optim *cls2, *cllqs2, *cllas2;
1092 1092
1093 dprintk("%s\n", __func__); 1093 dprintk("%s\n", __func__);
@@ -1096,14 +1096,17 @@ u8 stv0900_get_optim_carr_loop(s32 srate, enum fe_stv0900_modcode modcode,
1096 cls2 = FE_STV0900_S2CarLoop; 1096 cls2 = FE_STV0900_S2CarLoop;
1097 cllqs2 = FE_STV0900_S2LowQPCarLoopCut30; 1097 cllqs2 = FE_STV0900_S2LowQPCarLoopCut30;
1098 cllas2 = FE_STV0900_S2APSKCarLoopCut30; 1098 cllas2 = FE_STV0900_S2APSKCarLoopCut30;
1099 cllas2_size = ARRAY_SIZE(FE_STV0900_S2APSKCarLoopCut30);
1099 } else if (chip_id == 0x20) { 1100 } else if (chip_id == 0x20) {
1100 cls2 = FE_STV0900_S2CarLoopCut20; 1101 cls2 = FE_STV0900_S2CarLoopCut20;
1101 cllqs2 = FE_STV0900_S2LowQPCarLoopCut20; 1102 cllqs2 = FE_STV0900_S2LowQPCarLoopCut20;
1102 cllas2 = FE_STV0900_S2APSKCarLoopCut20; 1103 cllas2 = FE_STV0900_S2APSKCarLoopCut20;
1104 cllas2_size = ARRAY_SIZE(FE_STV0900_S2APSKCarLoopCut20);
1103 } else { 1105 } else {
1104 cls2 = FE_STV0900_S2CarLoopCut30; 1106 cls2 = FE_STV0900_S2CarLoopCut30;
1105 cllqs2 = FE_STV0900_S2LowQPCarLoopCut30; 1107 cllqs2 = FE_STV0900_S2LowQPCarLoopCut30;
1106 cllas2 = FE_STV0900_S2APSKCarLoopCut30; 1108 cllas2 = FE_STV0900_S2APSKCarLoopCut30;
1109 cllas2_size = ARRAY_SIZE(FE_STV0900_S2APSKCarLoopCut30);
1107 } 1110 }
1108 1111
1109 if (modcode < STV0900_QPSK_12) { 1112 if (modcode < STV0900_QPSK_12) {
@@ -1178,7 +1181,7 @@ u8 stv0900_get_optim_carr_loop(s32 srate, enum fe_stv0900_modcode modcode,
1178 aclc_value = cls2[i].car_loop_pilots_off_30; 1181 aclc_value = cls2[i].car_loop_pilots_off_30;
1179 } 1182 }
1180 1183
1181 } else { 1184 } else if (i < cllas2_size) {
1182 if (srate <= 3000000) 1185 if (srate <= 3000000)
1183 aclc_value = cllas2[i].car_loop_pilots_on_2; 1186 aclc_value = cllas2[i].car_loop_pilots_on_2;
1184 else if (srate <= 7000000) 1187 else if (srate <= 7000000)
@@ -1859,9 +1862,9 @@ static int stv0900_sleep(struct dvb_frontend *fe)
1859 return 0; 1862 return 0;
1860} 1863}
1861 1864
1862static int stv0900_get_frontend(struct dvb_frontend *fe) 1865static int stv0900_get_frontend(struct dvb_frontend *fe,
1866 struct dtv_frontend_properties *p)
1863{ 1867{
1864 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1865 struct stv0900_state *state = fe->demodulator_priv; 1868 struct stv0900_state *state = fe->demodulator_priv;
1866 struct stv0900_internal *intp = state->internal; 1869 struct stv0900_internal *intp = state->internal;
1867 enum fe_stv0900_demod_num demod = state->demod; 1870 enum fe_stv0900_demod_num demod = state->demod;
diff --git a/drivers/media/dvb-frontends/stv6110x.c b/drivers/media/dvb-frontends/stv6110x.c
index e66154e5c1d7..a62c01e454f5 100644
--- a/drivers/media/dvb-frontends/stv6110x.c
+++ b/drivers/media/dvb-frontends/stv6110x.c
@@ -355,7 +355,7 @@ static struct dvb_tuner_ops stv6110x_ops = {
355 .release = stv6110x_release 355 .release = stv6110x_release
356}; 356};
357 357
358static struct stv6110x_devctl stv6110x_ctl = { 358static const struct stv6110x_devctl stv6110x_ctl = {
359 .tuner_init = stv6110x_init, 359 .tuner_init = stv6110x_init,
360 .tuner_sleep = stv6110x_sleep, 360 .tuner_sleep = stv6110x_sleep,
361 .tuner_set_mode = stv6110x_set_mode, 361 .tuner_set_mode = stv6110x_set_mode,
@@ -369,7 +369,7 @@ static struct stv6110x_devctl stv6110x_ctl = {
369 .tuner_get_status = stv6110x_get_status, 369 .tuner_get_status = stv6110x_get_status,
370}; 370};
371 371
372struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe, 372const struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
373 const struct stv6110x_config *config, 373 const struct stv6110x_config *config,
374 struct i2c_adapter *i2c) 374 struct i2c_adapter *i2c)
375{ 375{
diff --git a/drivers/media/dvb-frontends/stv6110x.h b/drivers/media/dvb-frontends/stv6110x.h
index 9f7eb251aec3..696b6e5b9e7b 100644
--- a/drivers/media/dvb-frontends/stv6110x.h
+++ b/drivers/media/dvb-frontends/stv6110x.h
@@ -55,12 +55,12 @@ struct stv6110x_devctl {
55 55
56#if IS_REACHABLE(CONFIG_DVB_STV6110x) 56#if IS_REACHABLE(CONFIG_DVB_STV6110x)
57 57
58extern struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe, 58extern const struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
59 const struct stv6110x_config *config, 59 const struct stv6110x_config *config,
60 struct i2c_adapter *i2c); 60 struct i2c_adapter *i2c);
61 61
62#else 62#else
63static inline struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe, 63static inline const struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
64 const struct stv6110x_config *config, 64 const struct stv6110x_config *config,
65 struct i2c_adapter *i2c) 65 struct i2c_adapter *i2c)
66{ 66{
diff --git a/drivers/media/dvb-frontends/stv6110x_priv.h b/drivers/media/dvb-frontends/stv6110x_priv.h
index 0ec936a660a7..a993aba27b7e 100644
--- a/drivers/media/dvb-frontends/stv6110x_priv.h
+++ b/drivers/media/dvb-frontends/stv6110x_priv.h
@@ -70,7 +70,7 @@ struct stv6110x_state {
70 const struct stv6110x_config *config; 70 const struct stv6110x_config *config;
71 u8 regs[8]; 71 u8 regs[8];
72 72
73 struct stv6110x_devctl *devctl; 73 const struct stv6110x_devctl *devctl;
74}; 74};
75 75
76#endif /* __STV6110x_PRIV_H */ 76#endif /* __STV6110x_PRIV_H */
diff --git a/drivers/media/dvb-frontends/tc90522.c b/drivers/media/dvb-frontends/tc90522.c
index 456cdc7fb1e7..31cd32532387 100644
--- a/drivers/media/dvb-frontends/tc90522.c
+++ b/drivers/media/dvb-frontends/tc90522.c
@@ -201,10 +201,10 @@ static const enum fe_code_rate fec_conv_sat[] = {
201 FEC_2_3, /* for 8PSK. (trellis code) */ 201 FEC_2_3, /* for 8PSK. (trellis code) */
202}; 202};
203 203
204static int tc90522s_get_frontend(struct dvb_frontend *fe) 204static int tc90522s_get_frontend(struct dvb_frontend *fe,
205 struct dtv_frontend_properties *c)
205{ 206{
206 struct tc90522_state *state; 207 struct tc90522_state *state;
207 struct dtv_frontend_properties *c;
208 struct dtv_fe_stats *stats; 208 struct dtv_fe_stats *stats;
209 int ret, i; 209 int ret, i;
210 int layers; 210 int layers;
@@ -212,7 +212,6 @@ static int tc90522s_get_frontend(struct dvb_frontend *fe)
212 u32 cndat; 212 u32 cndat;
213 213
214 state = fe->demodulator_priv; 214 state = fe->demodulator_priv;
215 c = &fe->dtv_property_cache;
216 c->delivery_system = SYS_ISDBS; 215 c->delivery_system = SYS_ISDBS;
217 c->symbol_rate = 28860000; 216 c->symbol_rate = 28860000;
218 217
@@ -337,10 +336,10 @@ static const enum fe_modulation mod_conv[] = {
337 DQPSK, QPSK, QAM_16, QAM_64, 0, 0, 0, 0 336 DQPSK, QPSK, QAM_16, QAM_64, 0, 0, 0, 0
338}; 337};
339 338
340static int tc90522t_get_frontend(struct dvb_frontend *fe) 339static int tc90522t_get_frontend(struct dvb_frontend *fe,
340 struct dtv_frontend_properties *c)
341{ 341{
342 struct tc90522_state *state; 342 struct tc90522_state *state;
343 struct dtv_frontend_properties *c;
344 struct dtv_fe_stats *stats; 343 struct dtv_fe_stats *stats;
345 int ret, i; 344 int ret, i;
346 int layers; 345 int layers;
@@ -348,7 +347,6 @@ static int tc90522t_get_frontend(struct dvb_frontend *fe)
348 u32 cndat; 347 u32 cndat;
349 348
350 state = fe->demodulator_priv; 349 state = fe->demodulator_priv;
351 c = &fe->dtv_property_cache;
352 c->delivery_system = SYS_ISDBT; 350 c->delivery_system = SYS_ISDBT;
353 c->bandwidth_hz = 6000000; 351 c->bandwidth_hz = 6000000;
354 mode = 1; 352 mode = 1;
diff --git a/drivers/media/dvb-frontends/tda10021.c b/drivers/media/dvb-frontends/tda10021.c
index a684424e665a..806c56691ca5 100644
--- a/drivers/media/dvb-frontends/tda10021.c
+++ b/drivers/media/dvb-frontends/tda10021.c
@@ -387,9 +387,9 @@ static int tda10021_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
387 return 0; 387 return 0;
388} 388}
389 389
390static int tda10021_get_frontend(struct dvb_frontend *fe) 390static int tda10021_get_frontend(struct dvb_frontend *fe,
391 struct dtv_frontend_properties *p)
391{ 392{
392 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
393 struct tda10021_state* state = fe->demodulator_priv; 393 struct tda10021_state* state = fe->demodulator_priv;
394 int sync; 394 int sync;
395 s8 afc = 0; 395 s8 afc = 0;
diff --git a/drivers/media/dvb-frontends/tda10023.c b/drivers/media/dvb-frontends/tda10023.c
index 44a55656093f..3b8c7e499d0d 100644
--- a/drivers/media/dvb-frontends/tda10023.c
+++ b/drivers/media/dvb-frontends/tda10023.c
@@ -457,9 +457,9 @@ static int tda10023_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
457 return 0; 457 return 0;
458} 458}
459 459
460static int tda10023_get_frontend(struct dvb_frontend *fe) 460static int tda10023_get_frontend(struct dvb_frontend *fe,
461 struct dtv_frontend_properties *p)
461{ 462{
462 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
463 struct tda10023_state* state = fe->demodulator_priv; 463 struct tda10023_state* state = fe->demodulator_priv;
464 int sync,inv; 464 int sync,inv;
465 s8 afc = 0; 465 s8 afc = 0;
diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c
index 8451086c563f..c2bf89d0b0b0 100644
--- a/drivers/media/dvb-frontends/tda10048.c
+++ b/drivers/media/dvb-frontends/tda10048.c
@@ -1028,9 +1028,9 @@ static int tda10048_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
1028 return 0; 1028 return 0;
1029} 1029}
1030 1030
1031static int tda10048_get_frontend(struct dvb_frontend *fe) 1031static int tda10048_get_frontend(struct dvb_frontend *fe,
1032 struct dtv_frontend_properties *p)
1032{ 1033{
1033 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1034 struct tda10048_state *state = fe->demodulator_priv; 1034 struct tda10048_state *state = fe->demodulator_priv;
1035 1035
1036 dprintk(1, "%s()\n", __func__); 1036 dprintk(1, "%s()\n", __func__);
diff --git a/drivers/media/dvb-frontends/tda1004x.c b/drivers/media/dvb-frontends/tda1004x.c
index c6abeb4fba9d..b89848313fb9 100644
--- a/drivers/media/dvb-frontends/tda1004x.c
+++ b/drivers/media/dvb-frontends/tda1004x.c
@@ -899,9 +899,9 @@ static int tda1004x_set_fe(struct dvb_frontend *fe)
899 return 0; 899 return 0;
900} 900}
901 901
902static int tda1004x_get_fe(struct dvb_frontend *fe) 902static int tda1004x_get_fe(struct dvb_frontend *fe,
903 struct dtv_frontend_properties *fe_params)
903{ 904{
904 struct dtv_frontend_properties *fe_params = &fe->dtv_property_cache;
905 struct tda1004x_state* state = fe->demodulator_priv; 905 struct tda1004x_state* state = fe->demodulator_priv;
906 int status; 906 int status;
907 907
diff --git a/drivers/media/dvb-frontends/tda10071.c b/drivers/media/dvb-frontends/tda10071.c
index 119d47596ac8..37ebeef2bbd0 100644
--- a/drivers/media/dvb-frontends/tda10071.c
+++ b/drivers/media/dvb-frontends/tda10071.c
@@ -701,11 +701,11 @@ error:
701 return ret; 701 return ret;
702} 702}
703 703
704static int tda10071_get_frontend(struct dvb_frontend *fe) 704static int tda10071_get_frontend(struct dvb_frontend *fe,
705 struct dtv_frontend_properties *c)
705{ 706{
706 struct tda10071_dev *dev = fe->demodulator_priv; 707 struct tda10071_dev *dev = fe->demodulator_priv;
707 struct i2c_client *client = dev->client; 708 struct i2c_client *client = dev->client;
708 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
709 int ret, i; 709 int ret, i;
710 u8 buf[5], tmp; 710 u8 buf[5], tmp;
711 711
diff --git a/drivers/media/dvb-frontends/tda10086.c b/drivers/media/dvb-frontends/tda10086.c
index 95a33e187f8e..31d0acb54fe8 100644
--- a/drivers/media/dvb-frontends/tda10086.c
+++ b/drivers/media/dvb-frontends/tda10086.c
@@ -459,9 +459,9 @@ static int tda10086_set_frontend(struct dvb_frontend *fe)
459 return 0; 459 return 0;
460} 460}
461 461
462static int tda10086_get_frontend(struct dvb_frontend *fe) 462static int tda10086_get_frontend(struct dvb_frontend *fe,
463 struct dtv_frontend_properties *fe_params)
463{ 464{
464 struct dtv_frontend_properties *fe_params = &fe->dtv_property_cache;
465 struct tda10086_state* state = fe->demodulator_priv; 465 struct tda10086_state* state = fe->demodulator_priv;
466 u8 val; 466 u8 val;
467 int tmp; 467 int tmp;
diff --git a/drivers/media/dvb-frontends/tda8083.c b/drivers/media/dvb-frontends/tda8083.c
index 796543fa2c8d..9072d6463094 100644
--- a/drivers/media/dvb-frontends/tda8083.c
+++ b/drivers/media/dvb-frontends/tda8083.c
@@ -342,9 +342,9 @@ static int tda8083_set_frontend(struct dvb_frontend *fe)
342 return 0; 342 return 0;
343} 343}
344 344
345static int tda8083_get_frontend(struct dvb_frontend *fe) 345static int tda8083_get_frontend(struct dvb_frontend *fe,
346 struct dtv_frontend_properties *p)
346{ 347{
347 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
348 struct tda8083_state* state = fe->demodulator_priv; 348 struct tda8083_state* state = fe->demodulator_priv;
349 349
350 /* FIXME: get symbolrate & frequency offset...*/ 350 /* FIXME: get symbolrate & frequency offset...*/
diff --git a/drivers/media/dvb-frontends/ts2020.c b/drivers/media/dvb-frontends/ts2020.c
index 7979e5d6498b..14b410ffe612 100644
--- a/drivers/media/dvb-frontends/ts2020.c
+++ b/drivers/media/dvb-frontends/ts2020.c
@@ -712,6 +712,10 @@ static int ts2020_remove(struct i2c_client *client)
712 712
713 dev_dbg(&client->dev, "\n"); 713 dev_dbg(&client->dev, "\n");
714 714
715 /* stop statistics polling */
716 if (!dev->dont_poll)
717 cancel_delayed_work_sync(&dev->stat_work);
718
715 regmap_exit(dev->regmap); 719 regmap_exit(dev->regmap);
716 kfree(dev); 720 kfree(dev);
717 return 0; 721 return 0;
diff --git a/drivers/media/dvb-frontends/ves1820.c b/drivers/media/dvb-frontends/ves1820.c
index aacfdda3e005..b09fe88c40f8 100644
--- a/drivers/media/dvb-frontends/ves1820.c
+++ b/drivers/media/dvb-frontends/ves1820.c
@@ -312,9 +312,9 @@ static int ves1820_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
312 return 0; 312 return 0;
313} 313}
314 314
315static int ves1820_get_frontend(struct dvb_frontend *fe) 315static int ves1820_get_frontend(struct dvb_frontend *fe,
316 struct dtv_frontend_properties *p)
316{ 317{
317 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
318 struct ves1820_state* state = fe->demodulator_priv; 318 struct ves1820_state* state = fe->demodulator_priv;
319 int sync; 319 int sync;
320 s8 afc = 0; 320 s8 afc = 0;
diff --git a/drivers/media/dvb-frontends/ves1x93.c b/drivers/media/dvb-frontends/ves1x93.c
index 526952396422..ed113e216e14 100644
--- a/drivers/media/dvb-frontends/ves1x93.c
+++ b/drivers/media/dvb-frontends/ves1x93.c
@@ -406,9 +406,9 @@ static int ves1x93_set_frontend(struct dvb_frontend *fe)
406 return 0; 406 return 0;
407} 407}
408 408
409static int ves1x93_get_frontend(struct dvb_frontend *fe) 409static int ves1x93_get_frontend(struct dvb_frontend *fe,
410 struct dtv_frontend_properties *p)
410{ 411{
411 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
412 struct ves1x93_state* state = fe->demodulator_priv; 412 struct ves1x93_state* state = fe->demodulator_priv;
413 int afc; 413 int afc;
414 414
diff --git a/drivers/media/dvb-frontends/zl10353.c b/drivers/media/dvb-frontends/zl10353.c
index ef9764a02d4c..1832c2f7695c 100644
--- a/drivers/media/dvb-frontends/zl10353.c
+++ b/drivers/media/dvb-frontends/zl10353.c
@@ -371,9 +371,9 @@ static int zl10353_set_parameters(struct dvb_frontend *fe)
371 return 0; 371 return 0;
372} 372}
373 373
374static int zl10353_get_parameters(struct dvb_frontend *fe) 374static int zl10353_get_parameters(struct dvb_frontend *fe,
375 struct dtv_frontend_properties *c)
375{ 376{
376 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
377 struct zl10353_state *state = fe->demodulator_priv; 377 struct zl10353_state *state = fe->demodulator_priv;
378 int s6, s9; 378 int s6, s9;
379 u16 tps; 379 u16 tps;
diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index 471fd23b5c5c..bd822f032b08 100644
--- a/drivers/media/i2c/adv7511.c
+++ b/drivers/media/i2c/adv7511.c
@@ -103,12 +103,14 @@ struct adv7511_state {
103 u32 ycbcr_enc; 103 u32 ycbcr_enc;
104 u32 quantization; 104 u32 quantization;
105 u32 xfer_func; 105 u32 xfer_func;
106 u32 content_type;
106 /* controls */ 107 /* controls */
107 struct v4l2_ctrl *hdmi_mode_ctrl; 108 struct v4l2_ctrl *hdmi_mode_ctrl;
108 struct v4l2_ctrl *hotplug_ctrl; 109 struct v4l2_ctrl *hotplug_ctrl;
109 struct v4l2_ctrl *rx_sense_ctrl; 110 struct v4l2_ctrl *rx_sense_ctrl;
110 struct v4l2_ctrl *have_edid0_ctrl; 111 struct v4l2_ctrl *have_edid0_ctrl;
111 struct v4l2_ctrl *rgb_quantization_range_ctrl; 112 struct v4l2_ctrl *rgb_quantization_range_ctrl;
113 struct v4l2_ctrl *content_type_ctrl;
112 struct i2c_client *i2c_edid; 114 struct i2c_client *i2c_edid;
113 struct i2c_client *i2c_pktmem; 115 struct i2c_client *i2c_pktmem;
114 struct adv7511_state_edid edid; 116 struct adv7511_state_edid edid;
@@ -400,6 +402,16 @@ static int adv7511_s_ctrl(struct v4l2_ctrl *ctrl)
400 } 402 }
401 if (state->rgb_quantization_range_ctrl == ctrl) 403 if (state->rgb_quantization_range_ctrl == ctrl)
402 return adv7511_set_rgb_quantization_mode(sd, ctrl); 404 return adv7511_set_rgb_quantization_mode(sd, ctrl);
405 if (state->content_type_ctrl == ctrl) {
406 u8 itc, cn;
407
408 state->content_type = ctrl->val;
409 itc = state->content_type != V4L2_DV_IT_CONTENT_TYPE_NO_ITC;
410 cn = itc ? state->content_type : V4L2_DV_IT_CONTENT_TYPE_GRAPHICS;
411 adv7511_wr_and_or(sd, 0x57, 0x7f, itc << 7);
412 adv7511_wr_and_or(sd, 0x59, 0xcf, cn << 4);
413 return 0;
414 }
403 415
404 return -EINVAL; 416 return -EINVAL;
405} 417}
@@ -1002,6 +1014,8 @@ static int adv7511_set_fmt(struct v4l2_subdev *sd,
1002 u8 y = HDMI_COLORSPACE_RGB; 1014 u8 y = HDMI_COLORSPACE_RGB;
1003 u8 q = HDMI_QUANTIZATION_RANGE_DEFAULT; 1015 u8 q = HDMI_QUANTIZATION_RANGE_DEFAULT;
1004 u8 yq = HDMI_YCC_QUANTIZATION_RANGE_LIMITED; 1016 u8 yq = HDMI_YCC_QUANTIZATION_RANGE_LIMITED;
1017 u8 itc = state->content_type != V4L2_DV_IT_CONTENT_TYPE_NO_ITC;
1018 u8 cn = itc ? state->content_type : V4L2_DV_IT_CONTENT_TYPE_GRAPHICS;
1005 1019
1006 if (format->pad != 0) 1020 if (format->pad != 0)
1007 return -EINVAL; 1021 return -EINVAL;
@@ -1115,8 +1129,8 @@ static int adv7511_set_fmt(struct v4l2_subdev *sd,
1115 adv7511_wr_and_or(sd, 0x4a, 0xbf, 0); 1129 adv7511_wr_and_or(sd, 0x4a, 0xbf, 0);
1116 adv7511_wr_and_or(sd, 0x55, 0x9f, y << 5); 1130 adv7511_wr_and_or(sd, 0x55, 0x9f, y << 5);
1117 adv7511_wr_and_or(sd, 0x56, 0x3f, c << 6); 1131 adv7511_wr_and_or(sd, 0x56, 0x3f, c << 6);
1118 adv7511_wr_and_or(sd, 0x57, 0x83, (ec << 4) | (q << 2)); 1132 adv7511_wr_and_or(sd, 0x57, 0x83, (ec << 4) | (q << 2) | (itc << 7));
1119 adv7511_wr_and_or(sd, 0x59, 0x3f, yq << 6); 1133 adv7511_wr_and_or(sd, 0x59, 0x0f, (yq << 6) | (cn << 4));
1120 adv7511_wr_and_or(sd, 0x4a, 0xff, 1); 1134 adv7511_wr_and_or(sd, 0x4a, 0xff, 1);
1121 1135
1122 return 0; 1136 return 0;
@@ -1161,12 +1175,23 @@ static void adv7511_dbg_dump_edid(int lvl, int debug, struct v4l2_subdev *sd, in
1161 } 1175 }
1162} 1176}
1163 1177
1178static void adv7511_notify_no_edid(struct v4l2_subdev *sd)
1179{
1180 struct adv7511_state *state = get_adv7511_state(sd);
1181 struct adv7511_edid_detect ed;
1182
1183 /* We failed to read the EDID, so send an event for this. */
1184 ed.present = false;
1185 ed.segment = adv7511_rd(sd, 0xc4);
1186 v4l2_subdev_notify(sd, ADV7511_EDID_DETECT, (void *)&ed);
1187 v4l2_ctrl_s_ctrl(state->have_edid0_ctrl, 0x0);
1188}
1189
1164static void adv7511_edid_handler(struct work_struct *work) 1190static void adv7511_edid_handler(struct work_struct *work)
1165{ 1191{
1166 struct delayed_work *dwork = to_delayed_work(work); 1192 struct delayed_work *dwork = to_delayed_work(work);
1167 struct adv7511_state *state = container_of(dwork, struct adv7511_state, edid_handler); 1193 struct adv7511_state *state = container_of(dwork, struct adv7511_state, edid_handler);
1168 struct v4l2_subdev *sd = &state->sd; 1194 struct v4l2_subdev *sd = &state->sd;
1169 struct adv7511_edid_detect ed;
1170 1195
1171 v4l2_dbg(1, debug, sd, "%s:\n", __func__); 1196 v4l2_dbg(1, debug, sd, "%s:\n", __func__);
1172 1197
@@ -1191,9 +1216,7 @@ static void adv7511_edid_handler(struct work_struct *work)
1191 } 1216 }
1192 1217
1193 /* We failed to read the EDID, so send an event for this. */ 1218 /* We failed to read the EDID, so send an event for this. */
1194 ed.present = false; 1219 adv7511_notify_no_edid(sd);
1195 ed.segment = adv7511_rd(sd, 0xc4);
1196 v4l2_subdev_notify(sd, ADV7511_EDID_DETECT, (void *)&ed);
1197 v4l2_dbg(1, debug, sd, "%s: no edid found\n", __func__); 1220 v4l2_dbg(1, debug, sd, "%s: no edid found\n", __func__);
1198} 1221}
1199 1222
@@ -1264,7 +1287,6 @@ static void adv7511_check_monitor_present_status(struct v4l2_subdev *sd)
1264 /* update read only ctrls */ 1287 /* update read only ctrls */
1265 v4l2_ctrl_s_ctrl(state->hotplug_ctrl, adv7511_have_hotplug(sd) ? 0x1 : 0x0); 1288 v4l2_ctrl_s_ctrl(state->hotplug_ctrl, adv7511_have_hotplug(sd) ? 0x1 : 0x0);
1266 v4l2_ctrl_s_ctrl(state->rx_sense_ctrl, adv7511_have_rx_sense(sd) ? 0x1 : 0x0); 1289 v4l2_ctrl_s_ctrl(state->rx_sense_ctrl, adv7511_have_rx_sense(sd) ? 0x1 : 0x0);
1267 v4l2_ctrl_s_ctrl(state->have_edid0_ctrl, state->edid.segments ? 0x1 : 0x0);
1268 1290
1269 if ((status & MASK_ADV7511_HPD_DETECT) && ((status & MASK_ADV7511_MSEN_DETECT) || state->edid.segments)) { 1291 if ((status & MASK_ADV7511_HPD_DETECT) && ((status & MASK_ADV7511_MSEN_DETECT) || state->edid.segments)) {
1270 v4l2_dbg(1, debug, sd, "%s: hotplug and (rx-sense or edid)\n", __func__); 1292 v4l2_dbg(1, debug, sd, "%s: hotplug and (rx-sense or edid)\n", __func__);
@@ -1294,6 +1316,7 @@ static void adv7511_check_monitor_present_status(struct v4l2_subdev *sd)
1294 } 1316 }
1295 adv7511_s_power(sd, false); 1317 adv7511_s_power(sd, false);
1296 memset(&state->edid, 0, sizeof(struct adv7511_state_edid)); 1318 memset(&state->edid, 0, sizeof(struct adv7511_state_edid));
1319 adv7511_notify_no_edid(sd);
1297 } 1320 }
1298} 1321}
1299 1322
@@ -1370,6 +1393,7 @@ static bool adv7511_check_edid_status(struct v4l2_subdev *sd)
1370 } 1393 }
1371 /* one more segment read ok */ 1394 /* one more segment read ok */
1372 state->edid.segments = segment + 1; 1395 state->edid.segments = segment + 1;
1396 v4l2_ctrl_s_ctrl(state->have_edid0_ctrl, 0x1);
1373 if (((state->edid.data[0x7e] >> 1) + 1) > state->edid.segments) { 1397 if (((state->edid.data[0x7e] >> 1) + 1) > state->edid.segments) {
1374 /* Request next EDID segment */ 1398 /* Request next EDID segment */
1375 v4l2_dbg(1, debug, sd, "%s: request segment %d\n", __func__, state->edid.segments); 1399 v4l2_dbg(1, debug, sd, "%s: request segment %d\n", __func__, state->edid.segments);
@@ -1389,7 +1413,6 @@ static bool adv7511_check_edid_status(struct v4l2_subdev *sd)
1389 ed.present = true; 1413 ed.present = true;
1390 ed.segment = 0; 1414 ed.segment = 0;
1391 state->edid_detect_counter++; 1415 state->edid_detect_counter++;
1392 v4l2_ctrl_s_ctrl(state->have_edid0_ctrl, state->edid.segments ? 0x1 : 0x0);
1393 v4l2_subdev_notify(sd, ADV7511_EDID_DETECT, (void *)&ed); 1416 v4l2_subdev_notify(sd, ADV7511_EDID_DETECT, (void *)&ed);
1394 return ed.present; 1417 return ed.present;
1395 } 1418 }
@@ -1470,6 +1493,10 @@ static int adv7511_probe(struct i2c_client *client, const struct i2c_device_id *
1470 v4l2_ctrl_new_std_menu(hdl, &adv7511_ctrl_ops, 1493 v4l2_ctrl_new_std_menu(hdl, &adv7511_ctrl_ops,
1471 V4L2_CID_DV_TX_RGB_RANGE, V4L2_DV_RGB_RANGE_FULL, 1494 V4L2_CID_DV_TX_RGB_RANGE, V4L2_DV_RGB_RANGE_FULL,
1472 0, V4L2_DV_RGB_RANGE_AUTO); 1495 0, V4L2_DV_RGB_RANGE_AUTO);
1496 state->content_type_ctrl =
1497 v4l2_ctrl_new_std_menu(hdl, &adv7511_ctrl_ops,
1498 V4L2_CID_DV_TX_IT_CONTENT_TYPE, V4L2_DV_IT_CONTENT_TYPE_NO_ITC,
1499 0, V4L2_DV_IT_CONTENT_TYPE_NO_ITC);
1473 sd->ctrl_handler = hdl; 1500 sd->ctrl_handler = hdl;
1474 if (hdl->error) { 1501 if (hdl->error) {
1475 err = hdl->error; 1502 err = hdl->error;
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index e1719ffdfb3d..41a1bfc5eaa7 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -207,71 +207,22 @@ static bool adv76xx_has_afe(struct adv76xx_state *state)
207 return state->info->has_afe; 207 return state->info->has_afe;
208} 208}
209 209
210/* Supported CEA and DMT timings */ 210/* Unsupported timings. This device cannot support 720p30. */
211static const struct v4l2_dv_timings adv76xx_timings[] = { 211static const struct v4l2_dv_timings adv76xx_timings_exceptions[] = {
212 V4L2_DV_BT_CEA_720X480P59_94, 212 V4L2_DV_BT_CEA_1280X720P30,
213 V4L2_DV_BT_CEA_720X576P50, 213 { }
214 V4L2_DV_BT_CEA_1280X720P24,
215 V4L2_DV_BT_CEA_1280X720P25,
216 V4L2_DV_BT_CEA_1280X720P50,
217 V4L2_DV_BT_CEA_1280X720P60,
218 V4L2_DV_BT_CEA_1920X1080P24,
219 V4L2_DV_BT_CEA_1920X1080P25,
220 V4L2_DV_BT_CEA_1920X1080P30,
221 V4L2_DV_BT_CEA_1920X1080P50,
222 V4L2_DV_BT_CEA_1920X1080P60,
223
224 /* sorted by DMT ID */
225 V4L2_DV_BT_DMT_640X350P85,
226 V4L2_DV_BT_DMT_640X400P85,
227 V4L2_DV_BT_DMT_720X400P85,
228 V4L2_DV_BT_DMT_640X480P60,
229 V4L2_DV_BT_DMT_640X480P72,
230 V4L2_DV_BT_DMT_640X480P75,
231 V4L2_DV_BT_DMT_640X480P85,
232 V4L2_DV_BT_DMT_800X600P56,
233 V4L2_DV_BT_DMT_800X600P60,
234 V4L2_DV_BT_DMT_800X600P72,
235 V4L2_DV_BT_DMT_800X600P75,
236 V4L2_DV_BT_DMT_800X600P85,
237 V4L2_DV_BT_DMT_848X480P60,
238 V4L2_DV_BT_DMT_1024X768P60,
239 V4L2_DV_BT_DMT_1024X768P70,
240 V4L2_DV_BT_DMT_1024X768P75,
241 V4L2_DV_BT_DMT_1024X768P85,
242 V4L2_DV_BT_DMT_1152X864P75,
243 V4L2_DV_BT_DMT_1280X768P60_RB,
244 V4L2_DV_BT_DMT_1280X768P60,
245 V4L2_DV_BT_DMT_1280X768P75,
246 V4L2_DV_BT_DMT_1280X768P85,
247 V4L2_DV_BT_DMT_1280X800P60_RB,
248 V4L2_DV_BT_DMT_1280X800P60,
249 V4L2_DV_BT_DMT_1280X800P75,
250 V4L2_DV_BT_DMT_1280X800P85,
251 V4L2_DV_BT_DMT_1280X960P60,
252 V4L2_DV_BT_DMT_1280X960P85,
253 V4L2_DV_BT_DMT_1280X1024P60,
254 V4L2_DV_BT_DMT_1280X1024P75,
255 V4L2_DV_BT_DMT_1280X1024P85,
256 V4L2_DV_BT_DMT_1360X768P60,
257 V4L2_DV_BT_DMT_1400X1050P60_RB,
258 V4L2_DV_BT_DMT_1400X1050P60,
259 V4L2_DV_BT_DMT_1400X1050P75,
260 V4L2_DV_BT_DMT_1400X1050P85,
261 V4L2_DV_BT_DMT_1440X900P60_RB,
262 V4L2_DV_BT_DMT_1440X900P60,
263 V4L2_DV_BT_DMT_1600X1200P60,
264 V4L2_DV_BT_DMT_1680X1050P60_RB,
265 V4L2_DV_BT_DMT_1680X1050P60,
266 V4L2_DV_BT_DMT_1792X1344P60,
267 V4L2_DV_BT_DMT_1856X1392P60,
268 V4L2_DV_BT_DMT_1920X1200P60_RB,
269 V4L2_DV_BT_DMT_1366X768P60_RB,
270 V4L2_DV_BT_DMT_1366X768P60,
271 V4L2_DV_BT_DMT_1920X1080P60,
272 { },
273}; 214};
274 215
216static bool adv76xx_check_dv_timings(const struct v4l2_dv_timings *t, void *hdl)
217{
218 int i;
219
220 for (i = 0; adv76xx_timings_exceptions[i].bt.width; i++)
221 if (v4l2_match_dv_timings(t, adv76xx_timings_exceptions + i, 0, false))
222 return false;
223 return true;
224}
225
275struct adv76xx_video_standards { 226struct adv76xx_video_standards {
276 struct v4l2_dv_timings timings; 227 struct v4l2_dv_timings timings;
277 u8 vid_std; 228 u8 vid_std;
@@ -806,6 +757,36 @@ static inline bool is_digital_input(struct v4l2_subdev *sd)
806 state->selected_input == ADV7604_PAD_HDMI_PORT_D; 757 state->selected_input == ADV7604_PAD_HDMI_PORT_D;
807} 758}
808 759
760static const struct v4l2_dv_timings_cap adv7604_timings_cap_analog = {
761 .type = V4L2_DV_BT_656_1120,
762 /* keep this initialization for compatibility with GCC < 4.4.6 */
763 .reserved = { 0 },
764 V4L2_INIT_BT_TIMINGS(0, 1920, 0, 1200, 25000000, 170000000,
765 V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT |
766 V4L2_DV_BT_STD_GTF | V4L2_DV_BT_STD_CVT,
767 V4L2_DV_BT_CAP_PROGRESSIVE | V4L2_DV_BT_CAP_REDUCED_BLANKING |
768 V4L2_DV_BT_CAP_CUSTOM)
769};
770
771static const struct v4l2_dv_timings_cap adv76xx_timings_cap_digital = {
772 .type = V4L2_DV_BT_656_1120,
773 /* keep this initialization for compatibility with GCC < 4.4.6 */
774 .reserved = { 0 },
775 V4L2_INIT_BT_TIMINGS(0, 1920, 0, 1200, 25000000, 225000000,
776 V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT |
777 V4L2_DV_BT_STD_GTF | V4L2_DV_BT_STD_CVT,
778 V4L2_DV_BT_CAP_PROGRESSIVE | V4L2_DV_BT_CAP_REDUCED_BLANKING |
779 V4L2_DV_BT_CAP_CUSTOM)
780};
781
782static inline const struct v4l2_dv_timings_cap *
783adv76xx_get_dv_timings_cap(struct v4l2_subdev *sd)
784{
785 return is_digital_input(sd) ? &adv76xx_timings_cap_digital :
786 &adv7604_timings_cap_analog;
787}
788
789
809/* ----------------------------------------------------------------------- */ 790/* ----------------------------------------------------------------------- */
810 791
811#ifdef CONFIG_VIDEO_ADV_DEBUG 792#ifdef CONFIG_VIDEO_ADV_DEBUG
@@ -1216,6 +1197,20 @@ static int adv76xx_s_ctrl(struct v4l2_ctrl *ctrl)
1216 return -EINVAL; 1197 return -EINVAL;
1217} 1198}
1218 1199
1200static int adv76xx_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
1201{
1202 struct v4l2_subdev *sd =
1203 &container_of(ctrl->handler, struct adv76xx_state, hdl)->sd;
1204
1205 if (ctrl->id == V4L2_CID_DV_RX_IT_CONTENT_TYPE) {
1206 ctrl->val = V4L2_DV_IT_CONTENT_TYPE_NO_ITC;
1207 if ((io_read(sd, 0x60) & 1) && (infoframe_read(sd, 0x03) & 0x80))
1208 ctrl->val = (infoframe_read(sd, 0x05) >> 4) & 3;
1209 return 0;
1210 }
1211 return -EINVAL;
1212}
1213
1219/* ----------------------------------------------------------------------- */ 1214/* ----------------------------------------------------------------------- */
1220 1215
1221static inline bool no_power(struct v4l2_subdev *sd) 1216static inline bool no_power(struct v4l2_subdev *sd)
@@ -1330,17 +1325,23 @@ static int stdi2dv_timings(struct v4l2_subdev *sd,
1330 u32 pix_clk; 1325 u32 pix_clk;
1331 int i; 1326 int i;
1332 1327
1333 for (i = 0; adv76xx_timings[i].bt.height; i++) { 1328 for (i = 0; v4l2_dv_timings_presets[i].bt.width; i++) {
1334 if (vtotal(&adv76xx_timings[i].bt) != stdi->lcf + 1) 1329 const struct v4l2_bt_timings *bt = &v4l2_dv_timings_presets[i].bt;
1330
1331 if (!v4l2_valid_dv_timings(&v4l2_dv_timings_presets[i],
1332 adv76xx_get_dv_timings_cap(sd),
1333 adv76xx_check_dv_timings, NULL))
1334 continue;
1335 if (vtotal(bt) != stdi->lcf + 1)
1335 continue; 1336 continue;
1336 if (adv76xx_timings[i].bt.vsync != stdi->lcvs) 1337 if (bt->vsync != stdi->lcvs)
1337 continue; 1338 continue;
1338 1339
1339 pix_clk = hfreq * htotal(&adv76xx_timings[i].bt); 1340 pix_clk = hfreq * htotal(bt);
1340 1341
1341 if ((pix_clk < adv76xx_timings[i].bt.pixelclock + 1000000) && 1342 if ((pix_clk < bt->pixelclock + 1000000) &&
1342 (pix_clk > adv76xx_timings[i].bt.pixelclock - 1000000)) { 1343 (pix_clk > bt->pixelclock - 1000000)) {
1343 *timings = adv76xx_timings[i]; 1344 *timings = v4l2_dv_timings_presets[i];
1344 return 0; 1345 return 0;
1345 } 1346 }
1346 } 1347 }
@@ -1425,15 +1426,11 @@ static int adv76xx_enum_dv_timings(struct v4l2_subdev *sd,
1425{ 1426{
1426 struct adv76xx_state *state = to_state(sd); 1427 struct adv76xx_state *state = to_state(sd);
1427 1428
1428 if (timings->index >= ARRAY_SIZE(adv76xx_timings) - 1)
1429 return -EINVAL;
1430
1431 if (timings->pad >= state->source_pad) 1429 if (timings->pad >= state->source_pad)
1432 return -EINVAL; 1430 return -EINVAL;
1433 1431
1434 memset(timings->reserved, 0, sizeof(timings->reserved)); 1432 return v4l2_enum_dv_timings_cap(timings,
1435 timings->timings = adv76xx_timings[timings->index]; 1433 adv76xx_get_dv_timings_cap(sd), adv76xx_check_dv_timings, NULL);
1436 return 0;
1437} 1434}
1438 1435
1439static int adv76xx_dv_timings_cap(struct v4l2_subdev *sd, 1436static int adv76xx_dv_timings_cap(struct v4l2_subdev *sd,
@@ -1444,29 +1441,7 @@ static int adv76xx_dv_timings_cap(struct v4l2_subdev *sd,
1444 if (cap->pad >= state->source_pad) 1441 if (cap->pad >= state->source_pad)
1445 return -EINVAL; 1442 return -EINVAL;
1446 1443
1447 cap->type = V4L2_DV_BT_656_1120; 1444 *cap = *adv76xx_get_dv_timings_cap(sd);
1448 cap->bt.max_width = 1920;
1449 cap->bt.max_height = 1200;
1450 cap->bt.min_pixelclock = 25000000;
1451
1452 switch (cap->pad) {
1453 case ADV76XX_PAD_HDMI_PORT_A:
1454 case ADV7604_PAD_HDMI_PORT_B:
1455 case ADV7604_PAD_HDMI_PORT_C:
1456 case ADV7604_PAD_HDMI_PORT_D:
1457 cap->bt.max_pixelclock = 225000000;
1458 break;
1459 case ADV7604_PAD_VGA_RGB:
1460 case ADV7604_PAD_VGA_COMP:
1461 default:
1462 cap->bt.max_pixelclock = 170000000;
1463 break;
1464 }
1465
1466 cap->bt.standards = V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT |
1467 V4L2_DV_BT_STD_GTF | V4L2_DV_BT_STD_CVT;
1468 cap->bt.capabilities = V4L2_DV_BT_CAP_PROGRESSIVE |
1469 V4L2_DV_BT_CAP_REDUCED_BLANKING | V4L2_DV_BT_CAP_CUSTOM;
1470 return 0; 1445 return 0;
1471} 1446}
1472 1447
@@ -1475,15 +1450,9 @@ static int adv76xx_dv_timings_cap(struct v4l2_subdev *sd,
1475static void adv76xx_fill_optional_dv_timings_fields(struct v4l2_subdev *sd, 1450static void adv76xx_fill_optional_dv_timings_fields(struct v4l2_subdev *sd,
1476 struct v4l2_dv_timings *timings) 1451 struct v4l2_dv_timings *timings)
1477{ 1452{
1478 int i; 1453 v4l2_find_dv_timings_cap(timings, adv76xx_get_dv_timings_cap(sd),
1479 1454 is_digital_input(sd) ? 250000 : 1000000,
1480 for (i = 0; adv76xx_timings[i].bt.width; i++) { 1455 adv76xx_check_dv_timings, NULL);
1481 if (v4l2_match_dv_timings(timings, &adv76xx_timings[i],
1482 is_digital_input(sd) ? 250000 : 1000000, false)) {
1483 *timings = adv76xx_timings[i];
1484 break;
1485 }
1486 }
1487} 1456}
1488 1457
1489static unsigned int adv7604_read_hdmi_pixelclock(struct v4l2_subdev *sd) 1458static unsigned int adv7604_read_hdmi_pixelclock(struct v4l2_subdev *sd)
@@ -1651,12 +1620,9 @@ static int adv76xx_s_dv_timings(struct v4l2_subdev *sd,
1651 1620
1652 bt = &timings->bt; 1621 bt = &timings->bt;
1653 1622
1654 if ((is_analog_input(sd) && bt->pixelclock > 170000000) || 1623 if (!v4l2_valid_dv_timings(timings, adv76xx_get_dv_timings_cap(sd),
1655 (is_digital_input(sd) && bt->pixelclock > 225000000)) { 1624 adv76xx_check_dv_timings, NULL))
1656 v4l2_dbg(1, debug, sd, "%s: pixelclock out of range %d\n",
1657 __func__, (u32)bt->pixelclock);
1658 return -ERANGE; 1625 return -ERANGE;
1659 }
1660 1626
1661 adv76xx_fill_optional_dv_timings_fields(sd, timings); 1627 adv76xx_fill_optional_dv_timings_fields(sd, timings);
1662 1628
@@ -1884,6 +1850,26 @@ static int adv76xx_get_format(struct v4l2_subdev *sd,
1884 return 0; 1850 return 0;
1885} 1851}
1886 1852
1853static int adv76xx_get_selection(struct v4l2_subdev *sd,
1854 struct v4l2_subdev_pad_config *cfg,
1855 struct v4l2_subdev_selection *sel)
1856{
1857 struct adv76xx_state *state = to_state(sd);
1858
1859 if (sel->which != V4L2_SUBDEV_FORMAT_ACTIVE)
1860 return -EINVAL;
1861 /* Only CROP, CROP_DEFAULT and CROP_BOUNDS are supported */
1862 if (sel->target > V4L2_SEL_TGT_CROP_BOUNDS)
1863 return -EINVAL;
1864
1865 sel->r.left = 0;
1866 sel->r.top = 0;
1867 sel->r.width = state->timings.bt.width;
1868 sel->r.height = state->timings.bt.height;
1869
1870 return 0;
1871}
1872
1887static int adv76xx_set_format(struct v4l2_subdev *sd, 1873static int adv76xx_set_format(struct v4l2_subdev *sd,
1888 struct v4l2_subdev_pad_config *cfg, 1874 struct v4l2_subdev_pad_config *cfg,
1889 struct v4l2_subdev_format *format) 1875 struct v4l2_subdev_format *format)
@@ -2109,7 +2095,8 @@ static int adv76xx_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
2109 rep_write(sd, 0x76, spa_loc & 0xff); 2095 rep_write(sd, 0x76, spa_loc & 0xff);
2110 rep_write_clr_set(sd, 0x77, 0x40, (spa_loc & 0x100) >> 2); 2096 rep_write_clr_set(sd, 0x77, 0x40, (spa_loc & 0x100) >> 2);
2111 } else { 2097 } else {
2112 /* FIXME: Where is the SPA location LSB register ? */ 2098 /* ADV7612 Software Manual Rev. A, p. 15 */
2099 rep_write(sd, 0x70, spa_loc & 0xff);
2113 rep_write_clr_set(sd, 0x71, 0x01, (spa_loc & 0x100) >> 8); 2100 rep_write_clr_set(sd, 0x71, 0x01, (spa_loc & 0x100) >> 8);
2114 } 2101 }
2115 2102
@@ -2380,6 +2367,7 @@ static int adv76xx_subscribe_event(struct v4l2_subdev *sd,
2380 2367
2381static const struct v4l2_ctrl_ops adv76xx_ctrl_ops = { 2368static const struct v4l2_ctrl_ops adv76xx_ctrl_ops = {
2382 .s_ctrl = adv76xx_s_ctrl, 2369 .s_ctrl = adv76xx_s_ctrl,
2370 .g_volatile_ctrl = adv76xx_g_volatile_ctrl,
2383}; 2371};
2384 2372
2385static const struct v4l2_subdev_core_ops adv76xx_core_ops = { 2373static const struct v4l2_subdev_core_ops adv76xx_core_ops = {
@@ -2403,6 +2391,7 @@ static const struct v4l2_subdev_video_ops adv76xx_video_ops = {
2403 2391
2404static const struct v4l2_subdev_pad_ops adv76xx_pad_ops = { 2392static const struct v4l2_subdev_pad_ops adv76xx_pad_ops = {
2405 .enum_mbus_code = adv76xx_enum_mbus_code, 2393 .enum_mbus_code = adv76xx_enum_mbus_code,
2394 .get_selection = adv76xx_get_selection,
2406 .get_fmt = adv76xx_get_format, 2395 .get_fmt = adv76xx_get_format,
2407 .set_fmt = adv76xx_set_format, 2396 .set_fmt = adv76xx_set_format,
2408 .get_edid = adv76xx_get_edid, 2397 .get_edid = adv76xx_get_edid,
@@ -2798,6 +2787,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
2798 struct device_node *endpoint; 2787 struct device_node *endpoint;
2799 struct device_node *np; 2788 struct device_node *np;
2800 unsigned int flags; 2789 unsigned int flags;
2790 int ret;
2801 u32 v; 2791 u32 v;
2802 2792
2803 np = state->i2c_clients[ADV76XX_PAGE_IO]->dev.of_node; 2793 np = state->i2c_clients[ADV76XX_PAGE_IO]->dev.of_node;
@@ -2807,7 +2797,11 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
2807 if (!endpoint) 2797 if (!endpoint)
2808 return -EINVAL; 2798 return -EINVAL;
2809 2799
2810 v4l2_of_parse_endpoint(endpoint, &bus_cfg); 2800 ret = v4l2_of_parse_endpoint(endpoint, &bus_cfg);
2801 if (ret) {
2802 of_node_put(endpoint);
2803 return ret;
2804 }
2811 2805
2812 if (!of_property_read_u32(endpoint, "default-input", &v)) 2806 if (!of_property_read_u32(endpoint, "default-input", &v))
2813 state->pdata.default_input = v; 2807 state->pdata.default_input = v;
@@ -3009,6 +3003,7 @@ static int adv76xx_probe(struct i2c_client *client,
3009 V4L2_DV_BT_CEA_640X480P59_94; 3003 V4L2_DV_BT_CEA_640X480P59_94;
3010 struct adv76xx_state *state; 3004 struct adv76xx_state *state;
3011 struct v4l2_ctrl_handler *hdl; 3005 struct v4l2_ctrl_handler *hdl;
3006 struct v4l2_ctrl *ctrl;
3012 struct v4l2_subdev *sd; 3007 struct v4l2_subdev *sd;
3013 unsigned int i; 3008 unsigned int i;
3014 unsigned int val, val2; 3009 unsigned int val, val2;
@@ -3140,6 +3135,11 @@ static int adv76xx_probe(struct i2c_client *client,
3140 V4L2_CID_SATURATION, 0, 255, 1, 128); 3135 V4L2_CID_SATURATION, 0, 255, 1, 128);
3141 v4l2_ctrl_new_std(hdl, &adv76xx_ctrl_ops, 3136 v4l2_ctrl_new_std(hdl, &adv76xx_ctrl_ops,
3142 V4L2_CID_HUE, 0, 128, 1, 0); 3137 V4L2_CID_HUE, 0, 128, 1, 0);
3138 ctrl = v4l2_ctrl_new_std_menu(hdl, &adv76xx_ctrl_ops,
3139 V4L2_CID_DV_RX_IT_CONTENT_TYPE, V4L2_DV_IT_CONTENT_TYPE_NO_ITC,
3140 0, V4L2_DV_IT_CONTENT_TYPE_NO_ITC);
3141 if (ctrl)
3142 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
3143 3143
3144 /* private controls */ 3144 /* private controls */
3145 state->detect_tx_5v_ctrl = v4l2_ctrl_new_std(hdl, NULL, 3145 state->detect_tx_5v_ctrl = v4l2_ctrl_new_std(hdl, NULL,
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 5fbb788e7b59..7ccb85d45224 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -1359,6 +1359,19 @@ static int adv7842_s_ctrl(struct v4l2_ctrl *ctrl)
1359 return -EINVAL; 1359 return -EINVAL;
1360} 1360}
1361 1361
1362static int adv7842_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
1363{
1364 struct v4l2_subdev *sd = to_sd(ctrl);
1365
1366 if (ctrl->id == V4L2_CID_DV_RX_IT_CONTENT_TYPE) {
1367 ctrl->val = V4L2_DV_IT_CONTENT_TYPE_NO_ITC;
1368 if ((io_read(sd, 0x60) & 1) && (infoframe_read(sd, 0x03) & 0x80))
1369 ctrl->val = (infoframe_read(sd, 0x05) >> 4) & 3;
1370 return 0;
1371 }
1372 return -EINVAL;
1373}
1374
1362static inline bool no_power(struct v4l2_subdev *sd) 1375static inline bool no_power(struct v4l2_subdev *sd)
1363{ 1376{
1364 return io_read(sd, 0x0c) & 0x24; 1377 return io_read(sd, 0x0c) & 0x24;
@@ -3022,6 +3035,7 @@ static int adv7842_subscribe_event(struct v4l2_subdev *sd,
3022 3035
3023static const struct v4l2_ctrl_ops adv7842_ctrl_ops = { 3036static const struct v4l2_ctrl_ops adv7842_ctrl_ops = {
3024 .s_ctrl = adv7842_s_ctrl, 3037 .s_ctrl = adv7842_s_ctrl,
3038 .g_volatile_ctrl = adv7842_g_volatile_ctrl,
3025}; 3039};
3026 3040
3027static const struct v4l2_subdev_core_ops adv7842_core_ops = { 3041static const struct v4l2_subdev_core_ops adv7842_core_ops = {
@@ -3196,6 +3210,7 @@ static int adv7842_probe(struct i2c_client *client,
3196 V4L2_DV_BT_CEA_640X480P59_94; 3210 V4L2_DV_BT_CEA_640X480P59_94;
3197 struct adv7842_platform_data *pdata = client->dev.platform_data; 3211 struct adv7842_platform_data *pdata = client->dev.platform_data;
3198 struct v4l2_ctrl_handler *hdl; 3212 struct v4l2_ctrl_handler *hdl;
3213 struct v4l2_ctrl *ctrl;
3199 struct v4l2_subdev *sd; 3214 struct v4l2_subdev *sd;
3200 u16 rev; 3215 u16 rev;
3201 int err; 3216 int err;
@@ -3261,6 +3276,11 @@ static int adv7842_probe(struct i2c_client *client,
3261 V4L2_CID_SATURATION, 0, 255, 1, 128); 3276 V4L2_CID_SATURATION, 0, 255, 1, 128);
3262 v4l2_ctrl_new_std(hdl, &adv7842_ctrl_ops, 3277 v4l2_ctrl_new_std(hdl, &adv7842_ctrl_ops,
3263 V4L2_CID_HUE, 0, 128, 1, 0); 3278 V4L2_CID_HUE, 0, 128, 1, 0);
3279 ctrl = v4l2_ctrl_new_std_menu(hdl, &adv7842_ctrl_ops,
3280 V4L2_CID_DV_RX_IT_CONTENT_TYPE, V4L2_DV_IT_CONTENT_TYPE_NO_ITC,
3281 0, V4L2_DV_IT_CONTENT_TYPE_NO_ITC);
3282 if (ctrl)
3283 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
3264 3284
3265 /* custom controls */ 3285 /* custom controls */
3266 state->detect_tx_5v_ctrl = v4l2_ctrl_new_std(hdl, NULL, 3286 state->detect_tx_5v_ctrl = v4l2_ctrl_new_std(hdl, NULL,
diff --git a/drivers/media/i2c/msp3400-driver.c b/drivers/media/i2c/msp3400-driver.c
index a84561d0d4a8..e016626ebf89 100644
--- a/drivers/media/i2c/msp3400-driver.c
+++ b/drivers/media/i2c/msp3400-driver.c
@@ -688,6 +688,9 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
688 int msp_revision; 688 int msp_revision;
689 int msp_product, msp_prod_hi, msp_prod_lo; 689 int msp_product, msp_prod_hi, msp_prod_lo;
690 int msp_rom; 690 int msp_rom;
691#if defined(CONFIG_MEDIA_CONTROLLER)
692 int ret;
693#endif
691 694
692 if (!id) 695 if (!id)
693 strlcpy(client->name, "msp3400", sizeof(client->name)); 696 strlcpy(client->name, "msp3400", sizeof(client->name));
@@ -704,6 +707,17 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
704 sd = &state->sd; 707 sd = &state->sd;
705 v4l2_i2c_subdev_init(sd, client, &msp_ops); 708 v4l2_i2c_subdev_init(sd, client, &msp_ops);
706 709
710#if defined(CONFIG_MEDIA_CONTROLLER)
711 state->pads[IF_AUD_DEC_PAD_IF_INPUT].flags = MEDIA_PAD_FL_SINK;
712 state->pads[IF_AUD_DEC_PAD_OUT].flags = MEDIA_PAD_FL_SOURCE;
713
714 sd->entity.function = MEDIA_ENT_F_IF_AUD_DECODER;
715
716 ret = media_entity_pads_init(&sd->entity, 2, state->pads);
717 if (ret < 0)
718 return ret;
719#endif
720
707 state->v4l2_std = V4L2_STD_NTSC; 721 state->v4l2_std = V4L2_STD_NTSC;
708 state->detected_std = V4L2_STD_ALL; 722 state->detected_std = V4L2_STD_ALL;
709 state->audmode = V4L2_TUNER_MODE_STEREO; 723 state->audmode = V4L2_TUNER_MODE_STEREO;
diff --git a/drivers/media/i2c/msp3400-driver.h b/drivers/media/i2c/msp3400-driver.h
index 6cae21366ed5..a8702aca187a 100644
--- a/drivers/media/i2c/msp3400-driver.h
+++ b/drivers/media/i2c/msp3400-driver.h
@@ -7,6 +7,7 @@
7#include <media/drv-intf/msp3400.h> 7#include <media/drv-intf/msp3400.h>
8#include <media/v4l2-device.h> 8#include <media/v4l2-device.h>
9#include <media/v4l2-ctrls.h> 9#include <media/v4l2-ctrls.h>
10#include <media/v4l2-mc.h>
10 11
11/* ---------------------------------------------------------------------- */ 12/* ---------------------------------------------------------------------- */
12 13
@@ -102,6 +103,10 @@ struct msp_state {
102 wait_queue_head_t wq; 103 wait_queue_head_t wq;
103 unsigned int restart:1; 104 unsigned int restart:1;
104 unsigned int watch_stereo:1; 105 unsigned int watch_stereo:1;
106
107#if IS_ENABLED(CONFIG_MEDIA_CONTROLLER)
108 struct media_pad pads[IF_AUD_DEC_PAD_NUM_PADS];
109#endif
105}; 110};
106 111
107static inline struct msp_state *to_state(struct v4l2_subdev *sd) 112static inline struct msp_state *to_state(struct v4l2_subdev *sd)
diff --git a/drivers/media/i2c/mt9v011.c b/drivers/media/i2c/mt9v011.c
index b9fea11d6b0b..9ed1b26b6549 100644
--- a/drivers/media/i2c/mt9v011.c
+++ b/drivers/media/i2c/mt9v011.c
@@ -50,6 +50,9 @@ MODULE_PARM_DESC(debug, "Debug level (0-2)");
50 50
51struct mt9v011 { 51struct mt9v011 {
52 struct v4l2_subdev sd; 52 struct v4l2_subdev sd;
53#ifdef CONFIG_MEDIA_CONTROLLER
54 struct media_pad pad;
55#endif
53 struct v4l2_ctrl_handler ctrls; 56 struct v4l2_ctrl_handler ctrls;
54 unsigned width, height; 57 unsigned width, height;
55 unsigned xtal; 58 unsigned xtal;
@@ -493,6 +496,9 @@ static int mt9v011_probe(struct i2c_client *c,
493 u16 version; 496 u16 version;
494 struct mt9v011 *core; 497 struct mt9v011 *core;
495 struct v4l2_subdev *sd; 498 struct v4l2_subdev *sd;
499#ifdef CONFIG_MEDIA_CONTROLLER
500 int ret;
501#endif
496 502
497 /* Check if the adapter supports the needed features */ 503 /* Check if the adapter supports the needed features */
498 if (!i2c_check_functionality(c->adapter, 504 if (!i2c_check_functionality(c->adapter,
@@ -506,6 +512,15 @@ static int mt9v011_probe(struct i2c_client *c,
506 sd = &core->sd; 512 sd = &core->sd;
507 v4l2_i2c_subdev_init(sd, c, &mt9v011_ops); 513 v4l2_i2c_subdev_init(sd, c, &mt9v011_ops);
508 514
515#ifdef CONFIG_MEDIA_CONTROLLER
516 core->pad.flags = MEDIA_PAD_FL_SOURCE;
517 sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
518
519 ret = media_entity_pads_init(&sd->entity, 1, &core->pad);
520 if (ret < 0)
521 return ret;
522#endif
523
509 /* Check if the sensor is really a MT9V011 */ 524 /* Check if the sensor is really a MT9V011 */
510 version = mt9v011_read(sd, R00_MT9V011_CHIP_VERSION); 525 version = mt9v011_read(sd, R00_MT9V011_CHIP_VERSION);
511 if ((version != MT9V011_VERSION) && 526 if ((version != MT9V011_VERSION) &&
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 2e1d116a64e7..501b37039449 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -14,6 +14,7 @@
14 14
15#include <linux/clk.h> 15#include <linux/clk.h>
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/gpio/consumer.h>
17#include <linux/i2c.h> 18#include <linux/i2c.h>
18#include <linux/log2.h> 19#include <linux/log2.h>
19#include <linux/mutex.h> 20#include <linux/mutex.h>
@@ -251,6 +252,8 @@ struct mt9v032 {
251 252
252 struct regmap *regmap; 253 struct regmap *regmap;
253 struct clk *clk; 254 struct clk *clk;
255 struct gpio_desc *reset_gpio;
256 struct gpio_desc *standby_gpio;
254 257
255 struct mt9v032_platform_data *pdata; 258 struct mt9v032_platform_data *pdata;
256 const struct mt9v032_model_info *model; 259 const struct mt9v032_model_info *model;
@@ -312,16 +315,31 @@ static int mt9v032_power_on(struct mt9v032 *mt9v032)
312 struct regmap *map = mt9v032->regmap; 315 struct regmap *map = mt9v032->regmap;
313 int ret; 316 int ret;
314 317
318 if (mt9v032->reset_gpio)
319 gpiod_set_value_cansleep(mt9v032->reset_gpio, 1);
320
315 ret = clk_set_rate(mt9v032->clk, mt9v032->sysclk); 321 ret = clk_set_rate(mt9v032->clk, mt9v032->sysclk);
316 if (ret < 0) 322 if (ret < 0)
317 return ret; 323 return ret;
318 324
325 /* System clock has to be enabled before releasing the reset */
319 ret = clk_prepare_enable(mt9v032->clk); 326 ret = clk_prepare_enable(mt9v032->clk);
320 if (ret) 327 if (ret)
321 return ret; 328 return ret;
322 329
323 udelay(1); 330 udelay(1);
324 331
332 if (mt9v032->reset_gpio) {
333 gpiod_set_value_cansleep(mt9v032->reset_gpio, 0);
334
335 /* After releasing reset we need to wait 10 clock cycles
336 * before accessing the sensor over I2C. As the minimum SYSCLK
337 * frequency is 13MHz, waiting 1µs will be enough in the worst
338 * case.
339 */
340 udelay(1);
341 }
342
325 /* Reset the chip and stop data read out */ 343 /* Reset the chip and stop data read out */
326 ret = regmap_write(map, MT9V032_RESET, 1); 344 ret = regmap_write(map, MT9V032_RESET, 1);
327 if (ret < 0) 345 if (ret < 0)
@@ -954,6 +972,16 @@ static int mt9v032_probe(struct i2c_client *client,
954 if (IS_ERR(mt9v032->clk)) 972 if (IS_ERR(mt9v032->clk))
955 return PTR_ERR(mt9v032->clk); 973 return PTR_ERR(mt9v032->clk);
956 974
975 mt9v032->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset",
976 GPIOD_OUT_HIGH);
977 if (IS_ERR(mt9v032->reset_gpio))
978 return PTR_ERR(mt9v032->reset_gpio);
979
980 mt9v032->standby_gpio = devm_gpiod_get_optional(&client->dev, "standby",
981 GPIOD_OUT_LOW);
982 if (IS_ERR(mt9v032->standby_gpio))
983 return PTR_ERR(mt9v032->standby_gpio);
984
957 mutex_init(&mt9v032->power_lock); 985 mutex_init(&mt9v032->power_lock);
958 mt9v032->pdata = pdata; 986 mt9v032->pdata = pdata;
959 mt9v032->model = (const void *)did->driver_data; 987 mt9v032->model = (const void *)did->driver_data;
diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 02b9a3440557..1f999e9c0118 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1321,10 +1321,6 @@ static int ov2659_detect(struct v4l2_subdev *sd)
1321 } 1321 }
1322 usleep_range(1000, 2000); 1322 usleep_range(1000, 2000);
1323 1323
1324 ret = ov2659_init(sd, 0);
1325 if (ret < 0)
1326 return ret;
1327
1328 /* Check sensor revision */ 1324 /* Check sensor revision */
1329 ret = ov2659_read(client, REG_SC_CHIP_ID_H, &pid); 1325 ret = ov2659_read(client, REG_SC_CHIP_ID_H, &pid);
1330 if (!ret) 1326 if (!ret)
@@ -1338,8 +1334,10 @@ static int ov2659_detect(struct v4l2_subdev *sd)
1338 dev_err(&client->dev, 1334 dev_err(&client->dev,
1339 "Sensor detection failed (%04X, %d)\n", 1335 "Sensor detection failed (%04X, %d)\n",
1340 id, ret); 1336 id, ret);
1341 else 1337 else {
1342 dev_info(&client->dev, "Found OV%04X sensor\n", id); 1338 dev_info(&client->dev, "Found OV%04X sensor\n", id);
1339 ret = ov2659_init(sd, 0);
1340 }
1343 } 1341 }
1344 1342
1345 return ret; 1343 return ret;
diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
index a0b3c9bde53d..be5a7fd4f076 100644
--- a/drivers/media/i2c/ov9650.c
+++ b/drivers/media/i2c/ov9650.c
@@ -1046,8 +1046,8 @@ static int ov965x_initialize_controls(struct ov965x *ov965x)
1046 ctrls->exposure->flags |= V4L2_CTRL_FLAG_VOLATILE; 1046 ctrls->exposure->flags |= V4L2_CTRL_FLAG_VOLATILE;
1047 1047
1048 v4l2_ctrl_auto_cluster(3, &ctrls->auto_wb, 0, false); 1048 v4l2_ctrl_auto_cluster(3, &ctrls->auto_wb, 0, false);
1049 v4l2_ctrl_auto_cluster(3, &ctrls->auto_gain, 0, true); 1049 v4l2_ctrl_auto_cluster(2, &ctrls->auto_gain, 0, true);
1050 v4l2_ctrl_auto_cluster(3, &ctrls->auto_exp, 1, true); 1050 v4l2_ctrl_auto_cluster(2, &ctrls->auto_exp, 1, true);
1051 v4l2_ctrl_cluster(2, &ctrls->hflip); 1051 v4l2_ctrl_cluster(2, &ctrls->hflip);
1052 1052
1053 ov965x->sd.ctrl_handler = hdl; 1053 ov965x->sd.ctrl_handler = hdl;
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index 57b3d27993a4..08af58fb8e7d 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -1639,8 +1639,10 @@ static int s5c73m3_get_platform_data(struct s5c73m3 *state)
1639 return 0; 1639 return 0;
1640 } 1640 }
1641 1641
1642 v4l2_of_parse_endpoint(node_ep, &ep); 1642 ret = v4l2_of_parse_endpoint(node_ep, &ep);
1643 of_node_put(node_ep); 1643 of_node_put(node_ep);
1644 if (ret)
1645 return ret;
1644 1646
1645 if (ep.bus_type != V4L2_MBUS_CSI2) { 1647 if (ep.bus_type != V4L2_MBUS_CSI2) {
1646 dev_err(dev, "unsupported bus type\n"); 1648 dev_err(dev, "unsupported bus type\n");
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-spi.c b/drivers/media/i2c/s5c73m3/s5c73m3-spi.c
index 7d65b36434b1..72ef9f936e6c 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-spi.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-spi.c
@@ -37,7 +37,6 @@ enum spi_direction {
37 SPI_DIR_RX, 37 SPI_DIR_RX,
38 SPI_DIR_TX 38 SPI_DIR_TX
39}; 39};
40MODULE_DEVICE_TABLE(of, s5c73m3_spi_ids);
41 40
42static int spi_xmit(struct spi_device *spi_dev, void *addr, const int len, 41static int spi_xmit(struct spi_device *spi_dev, void *addr, const int len,
43 enum spi_direction dir) 42 enum spi_direction dir)
diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index fc3a5a8e6c9c..db82ed05792e 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -1868,8 +1868,11 @@ static int s5k5baf_parse_device_node(struct s5k5baf *state, struct device *dev)
1868 return -EINVAL; 1868 return -EINVAL;
1869 } 1869 }
1870 1870
1871 v4l2_of_parse_endpoint(node_ep, &ep); 1871 ret = v4l2_of_parse_endpoint(node_ep, &ep);
1872 of_node_put(node_ep); 1872 of_node_put(node_ep);
1873 if (ret)
1874 return ret;
1875
1873 state->bus_type = ep.bus_type; 1876 state->bus_type = ep.bus_type;
1874 1877
1875 switch (state->bus_type) { 1878 switch (state->bus_type) {
diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c
index 24d2b76dbe97..d2a1ce2bc7f5 100644
--- a/drivers/media/i2c/saa7115.c
+++ b/drivers/media/i2c/saa7115.c
@@ -46,6 +46,7 @@
46#include <linux/videodev2.h> 46#include <linux/videodev2.h>
47#include <media/v4l2-device.h> 47#include <media/v4l2-device.h>
48#include <media/v4l2-ctrls.h> 48#include <media/v4l2-ctrls.h>
49#include <media/v4l2-mc.h>
49#include <media/i2c/saa7115.h> 50#include <media/i2c/saa7115.h>
50#include <asm/div64.h> 51#include <asm/div64.h>
51 52
@@ -74,6 +75,9 @@ enum saa711x_model {
74 75
75struct saa711x_state { 76struct saa711x_state {
76 struct v4l2_subdev sd; 77 struct v4l2_subdev sd;
78#ifdef CONFIG_MEDIA_CONTROLLER
79 struct media_pad pads[DEMOD_NUM_PADS];
80#endif
77 struct v4l2_ctrl_handler hdl; 81 struct v4l2_ctrl_handler hdl;
78 82
79 struct { 83 struct {
@@ -1809,6 +1813,9 @@ static int saa711x_probe(struct i2c_client *client,
1809 struct saa7115_platform_data *pdata; 1813 struct saa7115_platform_data *pdata;
1810 int ident; 1814 int ident;
1811 char name[CHIP_VER_SIZE + 1]; 1815 char name[CHIP_VER_SIZE + 1];
1816#if defined(CONFIG_MEDIA_CONTROLLER)
1817 int ret;
1818#endif
1812 1819
1813 /* Check if the adapter supports the needed features */ 1820 /* Check if the adapter supports the needed features */
1814 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 1821 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
@@ -1832,6 +1839,18 @@ static int saa711x_probe(struct i2c_client *client,
1832 sd = &state->sd; 1839 sd = &state->sd;
1833 v4l2_i2c_subdev_init(sd, client, &saa711x_ops); 1840 v4l2_i2c_subdev_init(sd, client, &saa711x_ops);
1834 1841
1842#if defined(CONFIG_MEDIA_CONTROLLER)
1843 state->pads[DEMOD_PAD_IF_INPUT].flags = MEDIA_PAD_FL_SINK;
1844 state->pads[DEMOD_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
1845 state->pads[DEMOD_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
1846
1847 sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
1848
1849 ret = media_entity_pads_init(&sd->entity, DEMOD_NUM_PADS, state->pads);
1850 if (ret < 0)
1851 return ret;
1852#endif
1853
1835 v4l_info(client, "%s found @ 0x%x (%s)\n", name, 1854 v4l_info(client, "%s found @ 0x%x (%s)\n", name,
1836 client->addr << 1, client->adapter->name); 1855 client->addr << 1, client->adapter->name);
1837 hdl = &state->hdl; 1856 hdl = &state->hdl;
diff --git a/drivers/media/i2c/soc_camera/mt9m001.c b/drivers/media/i2c/soc_camera/mt9m001.c
index 2e14e52ba2e0..69becc358659 100644
--- a/drivers/media/i2c/soc_camera/mt9m001.c
+++ b/drivers/media/i2c/soc_camera/mt9m001.c
@@ -632,7 +632,7 @@ static struct v4l2_subdev_video_ops mt9m001_subdev_video_ops = {
632 .s_mbus_config = mt9m001_s_mbus_config, 632 .s_mbus_config = mt9m001_s_mbus_config,
633}; 633};
634 634
635static struct v4l2_subdev_sensor_ops mt9m001_subdev_sensor_ops = { 635static const struct v4l2_subdev_sensor_ops mt9m001_subdev_sensor_ops = {
636 .g_skip_top_lines = mt9m001_g_skip_top_lines, 636 .g_skip_top_lines = mt9m001_g_skip_top_lines,
637}; 637};
638 638
diff --git a/drivers/media/i2c/soc_camera/mt9t031.c b/drivers/media/i2c/soc_camera/mt9t031.c
index 3b6eeed2e2b9..5c8e3ffe3b27 100644
--- a/drivers/media/i2c/soc_camera/mt9t031.c
+++ b/drivers/media/i2c/soc_camera/mt9t031.c
@@ -728,7 +728,7 @@ static struct v4l2_subdev_video_ops mt9t031_subdev_video_ops = {
728 .s_mbus_config = mt9t031_s_mbus_config, 728 .s_mbus_config = mt9t031_s_mbus_config,
729}; 729};
730 730
731static struct v4l2_subdev_sensor_ops mt9t031_subdev_sensor_ops = { 731static const struct v4l2_subdev_sensor_ops mt9t031_subdev_sensor_ops = {
732 .g_skip_top_lines = mt9t031_g_skip_top_lines, 732 .g_skip_top_lines = mt9t031_g_skip_top_lines,
733}; 733};
734 734
diff --git a/drivers/media/i2c/soc_camera/mt9v022.c b/drivers/media/i2c/soc_camera/mt9v022.c
index c2ba1fb3694d..2721e583bfa0 100644
--- a/drivers/media/i2c/soc_camera/mt9v022.c
+++ b/drivers/media/i2c/soc_camera/mt9v022.c
@@ -860,7 +860,7 @@ static struct v4l2_subdev_video_ops mt9v022_subdev_video_ops = {
860 .s_mbus_config = mt9v022_s_mbus_config, 860 .s_mbus_config = mt9v022_s_mbus_config,
861}; 861};
862 862
863static struct v4l2_subdev_sensor_ops mt9v022_subdev_sensor_ops = { 863static const struct v4l2_subdev_sensor_ops mt9v022_subdev_sensor_ops = {
864 .g_skip_top_lines = mt9v022_g_skip_top_lines, 864 .g_skip_top_lines = mt9v022_g_skip_top_lines,
865}; 865};
866 866
diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index 3397eb99c67b..972e0d47259d 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -59,8 +59,7 @@ MODULE_LICENSE("GPL");
59#define EDID_NUM_BLOCKS_MAX 8 59#define EDID_NUM_BLOCKS_MAX 8
60#define EDID_BLOCK_SIZE 128 60#define EDID_BLOCK_SIZE 128
61 61
62/* Max transfer size done by I2C transfer functions */ 62#define I2C_MAX_XFER_SIZE (EDID_BLOCK_SIZE + 2)
63#define MAX_XFER_SIZE (EDID_NUM_BLOCKS_MAX * EDID_BLOCK_SIZE + 2)
64 63
65static const struct v4l2_dv_timings_cap tc358743_timings_cap = { 64static const struct v4l2_dv_timings_cap tc358743_timings_cap = {
66 .type = V4L2_DV_BT_656_1120, 65 .type = V4L2_DV_BT_656_1120,
@@ -97,9 +96,6 @@ struct tc358743_state {
97 /* edid */ 96 /* edid */
98 u8 edid_blocks_written; 97 u8 edid_blocks_written;
99 98
100 /* used by i2c_wr() */
101 u8 wr_data[MAX_XFER_SIZE];
102
103 struct v4l2_dv_timings timings; 99 struct v4l2_dv_timings timings;
104 u32 mbus_fmt_code; 100 u32 mbus_fmt_code;
105 101
@@ -149,13 +145,15 @@ static void i2c_wr(struct v4l2_subdev *sd, u16 reg, u8 *values, u32 n)
149{ 145{
150 struct tc358743_state *state = to_state(sd); 146 struct tc358743_state *state = to_state(sd);
151 struct i2c_client *client = state->i2c_client; 147 struct i2c_client *client = state->i2c_client;
152 u8 *data = state->wr_data;
153 int err, i; 148 int err, i;
154 struct i2c_msg msg; 149 struct i2c_msg msg;
150 u8 data[I2C_MAX_XFER_SIZE];
155 151
156 if ((2 + n) > sizeof(state->wr_data)) 152 if ((2 + n) > I2C_MAX_XFER_SIZE) {
153 n = I2C_MAX_XFER_SIZE - 2;
157 v4l2_warn(sd, "i2c wr reg=%04x: len=%d is too big!\n", 154 v4l2_warn(sd, "i2c wr reg=%04x: len=%d is too big!\n",
158 reg, 2 + n); 155 reg, 2 + n);
156 }
159 157
160 msg.addr = client->addr; 158 msg.addr = client->addr;
161 msg.buf = data; 159 msg.buf = data;
@@ -859,15 +857,16 @@ static void tc358743_format_change(struct v4l2_subdev *sd)
859 if (tc358743_get_detected_timings(sd, &timings)) { 857 if (tc358743_get_detected_timings(sd, &timings)) {
860 enable_stream(sd, false); 858 enable_stream(sd, false);
861 859
862 v4l2_dbg(1, debug, sd, "%s: Format changed. No signal\n", 860 v4l2_dbg(1, debug, sd, "%s: No signal\n",
863 __func__); 861 __func__);
864 } else { 862 } else {
865 if (!v4l2_match_dv_timings(&state->timings, &timings, 0, false)) 863 if (!v4l2_match_dv_timings(&state->timings, &timings, 0, false))
866 enable_stream(sd, false); 864 enable_stream(sd, false);
867 865
868 v4l2_print_dv_timings(sd->name, 866 if (debug)
869 "tc358743_format_change: Format changed. New format: ", 867 v4l2_print_dv_timings(sd->name,
870 &timings, false); 868 "tc358743_format_change: New format: ",
869 &timings, false);
871 } 870 }
872 871
873 if (sd->devnode) 872 if (sd->devnode)
@@ -1199,21 +1198,21 @@ static int tc358743_log_status(struct v4l2_subdev *sd)
1199#ifdef CONFIG_VIDEO_ADV_DEBUG 1198#ifdef CONFIG_VIDEO_ADV_DEBUG
1200static void tc358743_print_register_map(struct v4l2_subdev *sd) 1199static void tc358743_print_register_map(struct v4l2_subdev *sd)
1201{ 1200{
1202 v4l2_info(sd, "0x0000–0x00FF: Global Control Register\n"); 1201 v4l2_info(sd, "0x0000-0x00FF: Global Control Register\n");
1203 v4l2_info(sd, "0x0100–0x01FF: CSI2-TX PHY Register\n"); 1202 v4l2_info(sd, "0x0100-0x01FF: CSI2-TX PHY Register\n");
1204 v4l2_info(sd, "0x0200–0x03FF: CSI2-TX PPI Register\n"); 1203 v4l2_info(sd, "0x0200-0x03FF: CSI2-TX PPI Register\n");
1205 v4l2_info(sd, "0x0400–0x05FF: Reserved\n"); 1204 v4l2_info(sd, "0x0400-0x05FF: Reserved\n");
1206 v4l2_info(sd, "0x0600–0x06FF: CEC Register\n"); 1205 v4l2_info(sd, "0x0600-0x06FF: CEC Register\n");
1207 v4l2_info(sd, "0x0700–0x84FF: Reserved\n"); 1206 v4l2_info(sd, "0x0700-0x84FF: Reserved\n");
1208 v4l2_info(sd, "0x8500–0x85FF: HDMIRX System Control Register\n"); 1207 v4l2_info(sd, "0x8500-0x85FF: HDMIRX System Control Register\n");
1209 v4l2_info(sd, "0x8600–0x86FF: HDMIRX Audio Control Register\n"); 1208 v4l2_info(sd, "0x8600-0x86FF: HDMIRX Audio Control Register\n");
1210 v4l2_info(sd, "0x8700–0x87FF: HDMIRX InfoFrame packet data Register\n"); 1209 v4l2_info(sd, "0x8700-0x87FF: HDMIRX InfoFrame packet data Register\n");
1211 v4l2_info(sd, "0x8800–0x88FF: HDMIRX HDCP Port Register\n"); 1210 v4l2_info(sd, "0x8800-0x88FF: HDMIRX HDCP Port Register\n");
1212 v4l2_info(sd, "0x8900–0x89FF: HDMIRX Video Output Port & 3D Register\n"); 1211 v4l2_info(sd, "0x8900-0x89FF: HDMIRX Video Output Port & 3D Register\n");
1213 v4l2_info(sd, "0x8A00–0x8BFF: Reserved\n"); 1212 v4l2_info(sd, "0x8A00-0x8BFF: Reserved\n");
1214 v4l2_info(sd, "0x8C00–0x8FFF: HDMIRX EDID-RAM (1024bytes)\n"); 1213 v4l2_info(sd, "0x8C00-0x8FFF: HDMIRX EDID-RAM (1024bytes)\n");
1215 v4l2_info(sd, "0x9000–0x90FF: HDMIRX GBD Extraction Control\n"); 1214 v4l2_info(sd, "0x9000-0x90FF: HDMIRX GBD Extraction Control\n");
1216 v4l2_info(sd, "0x9100–0x92FF: HDMIRX GBD RAM read\n"); 1215 v4l2_info(sd, "0x9100-0x92FF: HDMIRX GBD RAM read\n");
1217 v4l2_info(sd, "0x9300- : Reserved\n"); 1216 v4l2_info(sd, "0x9300- : Reserved\n");
1218} 1217}
1219 1218
@@ -1581,6 +1580,7 @@ static int tc358743_s_edid(struct v4l2_subdev *sd,
1581{ 1580{
1582 struct tc358743_state *state = to_state(sd); 1581 struct tc358743_state *state = to_state(sd);
1583 u16 edid_len = edid->blocks * EDID_BLOCK_SIZE; 1582 u16 edid_len = edid->blocks * EDID_BLOCK_SIZE;
1583 int i;
1584 1584
1585 v4l2_dbg(2, debug, sd, "%s, pad %d, start block %d, blocks %d\n", 1585 v4l2_dbg(2, debug, sd, "%s, pad %d, start block %d, blocks %d\n",
1586 __func__, edid->pad, edid->start_block, edid->blocks); 1586 __func__, edid->pad, edid->start_block, edid->blocks);
@@ -1606,7 +1606,8 @@ static int tc358743_s_edid(struct v4l2_subdev *sd,
1606 return 0; 1606 return 0;
1607 } 1607 }
1608 1608
1609 i2c_wr(sd, EDID_RAM, edid->edid, edid_len); 1609 for (i = 0; i < edid_len; i += EDID_BLOCK_SIZE)
1610 i2c_wr(sd, EDID_RAM + i, edid->edid + i, EDID_BLOCK_SIZE);
1610 1611
1611 state->edid_blocks_written = edid->blocks; 1612 state->edid_blocks_written = edid->blocks;
1612 1613
diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
index 7fa5f1e4fe37..7cdd94842938 100644
--- a/drivers/media/i2c/tvp514x.c
+++ b/drivers/media/i2c/tvp514x.c
@@ -1001,7 +1001,7 @@ static struct tvp514x_decoder tvp514x_dev = {
1001static struct tvp514x_platform_data * 1001static struct tvp514x_platform_data *
1002tvp514x_get_pdata(struct i2c_client *client) 1002tvp514x_get_pdata(struct i2c_client *client)
1003{ 1003{
1004 struct tvp514x_platform_data *pdata; 1004 struct tvp514x_platform_data *pdata = NULL;
1005 struct v4l2_of_endpoint bus_cfg; 1005 struct v4l2_of_endpoint bus_cfg;
1006 struct device_node *endpoint; 1006 struct device_node *endpoint;
1007 unsigned int flags; 1007 unsigned int flags;
@@ -1013,11 +1013,13 @@ tvp514x_get_pdata(struct i2c_client *client)
1013 if (!endpoint) 1013 if (!endpoint)
1014 return NULL; 1014 return NULL;
1015 1015
1016 if (v4l2_of_parse_endpoint(endpoint, &bus_cfg))
1017 goto done;
1018
1016 pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); 1019 pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
1017 if (!pdata) 1020 if (!pdata)
1018 goto done; 1021 goto done;
1019 1022
1020 v4l2_of_parse_endpoint(endpoint, &bus_cfg);
1021 flags = bus_cfg.bus.parallel.flags; 1023 flags = bus_cfg.bus.parallel.flags;
1022 1024
1023 if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) 1025 if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 6c3769d44b75..ff18444e19e4 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -1,19 +1,22 @@
1/* 1/*
2 * tvp5150 - Texas Instruments TVP5150A/AM1 video decoder driver 2 * tvp5150 - Texas Instruments TVP5150A/AM1 and TVP5151 video decoder driver
3 * 3 *
4 * Copyright (c) 2005,2006 Mauro Carvalho Chehab (mchehab@infradead.org) 4 * Copyright (c) 2005,2006 Mauro Carvalho Chehab (mchehab@infradead.org)
5 * This code is placed under the terms of the GNU General Public License v2 5 * This code is placed under the terms of the GNU General Public License v2
6 */ 6 */
7 7
8#include <dt-bindings/media/tvp5150.h>
8#include <linux/i2c.h> 9#include <linux/i2c.h>
9#include <linux/slab.h> 10#include <linux/slab.h>
10#include <linux/videodev2.h> 11#include <linux/videodev2.h>
11#include <linux/delay.h> 12#include <linux/delay.h>
13#include <linux/gpio/consumer.h>
12#include <linux/module.h> 14#include <linux/module.h>
13#include <media/v4l2-async.h> 15#include <media/v4l2-async.h>
14#include <media/v4l2-device.h> 16#include <media/v4l2-device.h>
15#include <media/i2c/tvp5150.h>
16#include <media/v4l2-ctrls.h> 17#include <media/v4l2-ctrls.h>
18#include <media/v4l2-of.h>
19#include <media/v4l2-mc.h>
17 20
18#include "tvp5150_reg.h" 21#include "tvp5150_reg.h"
19 22
@@ -24,7 +27,7 @@
24#define TVP5150_MAX_CROP_TOP 127 27#define TVP5150_MAX_CROP_TOP 127
25#define TVP5150_CROP_SHIFT 2 28#define TVP5150_CROP_SHIFT 2
26 29
27MODULE_DESCRIPTION("Texas Instruments TVP5150A video decoder driver"); 30MODULE_DESCRIPTION("Texas Instruments TVP5150A/TVP5150AM1/TVP5151 video decoder driver");
28MODULE_AUTHOR("Mauro Carvalho Chehab"); 31MODULE_AUTHOR("Mauro Carvalho Chehab");
29MODULE_LICENSE("GPL"); 32MODULE_LICENSE("GPL");
30 33
@@ -35,6 +38,11 @@ MODULE_PARM_DESC(debug, "Debug level (0-2)");
35 38
36struct tvp5150 { 39struct tvp5150 {
37 struct v4l2_subdev sd; 40 struct v4l2_subdev sd;
41#ifdef CONFIG_MEDIA_CONTROLLER
42 struct media_pad pads[DEMOD_NUM_PADS];
43 struct media_entity input_ent[TVP5150_INPUT_NUM];
44 struct media_pad input_pad[TVP5150_INPUT_NUM];
45#endif
38 struct v4l2_ctrl_handler hdl; 46 struct v4l2_ctrl_handler hdl;
39 struct v4l2_rect rect; 47 struct v4l2_rect rect;
40 48
@@ -42,6 +50,11 @@ struct tvp5150 {
42 u32 input; 50 u32 input;
43 u32 output; 51 u32 output;
44 int enable; 52 int enable;
53
54 u16 dev_id;
55 u16 rom_ver;
56
57 enum v4l2_mbus_type mbus_type;
45}; 58};
46 59
47static inline struct tvp5150 *to_tvp5150(struct v4l2_subdev *sd) 60static inline struct tvp5150 *to_tvp5150(struct v4l2_subdev *sd)
@@ -246,8 +259,12 @@ static inline void tvp5150_selmux(struct v4l2_subdev *sd)
246 int input = 0; 259 int input = 0;
247 int val; 260 int val;
248 261
249 if ((decoder->output & TVP5150_BLACK_SCREEN) || !decoder->enable) 262 /* Only tvp5150am1 and tvp5151 have signal generator support */
250 input = 8; 263 if ((decoder->dev_id == 0x5150 && decoder->rom_ver == 0x0400) ||
264 (decoder->dev_id == 0x5151 && decoder->rom_ver == 0x0100)) {
265 if (!decoder->enable)
266 input = 8;
267 }
251 268
252 switch (decoder->input) { 269 switch (decoder->input) {
253 case TVP5150_COMPOSITE1: 270 case TVP5150_COMPOSITE1:
@@ -772,12 +789,17 @@ static int tvp5150_reset(struct v4l2_subdev *sd, u32 val)
772 v4l2_ctrl_handler_setup(&decoder->hdl); 789 v4l2_ctrl_handler_setup(&decoder->hdl);
773 790
774 tvp5150_set_std(sd, decoder->norm); 791 tvp5150_set_std(sd, decoder->norm);
792
793 if (decoder->mbus_type == V4L2_MBUS_PARALLEL)
794 tvp5150_write(sd, TVP5150_DATA_RATE_SEL, 0x40);
795
775 return 0; 796 return 0;
776}; 797};
777 798
778static int tvp5150_s_ctrl(struct v4l2_ctrl *ctrl) 799static int tvp5150_s_ctrl(struct v4l2_ctrl *ctrl)
779{ 800{
780 struct v4l2_subdev *sd = to_sd(ctrl); 801 struct v4l2_subdev *sd = to_sd(ctrl);
802 struct tvp5150 *decoder = to_tvp5150(sd);
781 803
782 switch (ctrl->id) { 804 switch (ctrl->id) {
783 case V4L2_CID_BRIGHTNESS: 805 case V4L2_CID_BRIGHTNESS:
@@ -791,6 +813,9 @@ static int tvp5150_s_ctrl(struct v4l2_ctrl *ctrl)
791 return 0; 813 return 0;
792 case V4L2_CID_HUE: 814 case V4L2_CID_HUE:
793 tvp5150_write(sd, TVP5150_HUE_CTL, ctrl->val); 815 tvp5150_write(sd, TVP5150_HUE_CTL, ctrl->val);
816 case V4L2_CID_TEST_PATTERN:
817 decoder->enable = ctrl->val ? false : true;
818 tvp5150_selmux(sd);
794 return 0; 819 return 0;
795 } 820 }
796 return -EINVAL; 821 return -EINVAL;
@@ -818,17 +843,6 @@ static v4l2_std_id tvp5150_read_std(struct v4l2_subdev *sd)
818 } 843 }
819} 844}
820 845
821static int tvp5150_enum_mbus_code(struct v4l2_subdev *sd,
822 struct v4l2_subdev_pad_config *cfg,
823 struct v4l2_subdev_mbus_code_enum *code)
824{
825 if (code->pad || code->index)
826 return -EINVAL;
827
828 code->code = MEDIA_BUS_FMT_UYVY8_2X8;
829 return 0;
830}
831
832static int tvp5150_fill_fmt(struct v4l2_subdev *sd, 846static int tvp5150_fill_fmt(struct v4l2_subdev *sd,
833 struct v4l2_subdev_pad_config *cfg, 847 struct v4l2_subdev_pad_config *cfg,
834 struct v4l2_subdev_format *format) 848 struct v4l2_subdev_format *format)
@@ -844,10 +858,10 @@ static int tvp5150_fill_fmt(struct v4l2_subdev *sd,
844 tvp5150_reset(sd, 0); 858 tvp5150_reset(sd, 0);
845 859
846 f->width = decoder->rect.width; 860 f->width = decoder->rect.width;
847 f->height = decoder->rect.height; 861 f->height = decoder->rect.height / 2;
848 862
849 f->code = MEDIA_BUS_FMT_UYVY8_2X8; 863 f->code = MEDIA_BUS_FMT_UYVY8_2X8;
850 f->field = V4L2_FIELD_SEQ_TB; 864 f->field = V4L2_FIELD_ALTERNATE;
851 f->colorspace = V4L2_COLORSPACE_SMPTE170M; 865 f->colorspace = V4L2_COLORSPACE_SMPTE170M;
852 866
853 v4l2_dbg(1, debug, sd, "width = %d, height = %d\n", f->width, 867 v4l2_dbg(1, debug, sd, "width = %d, height = %d\n", f->width,
@@ -948,10 +962,110 @@ static int tvp5150_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
948 return 0; 962 return 0;
949} 963}
950 964
965static int tvp5150_g_mbus_config(struct v4l2_subdev *sd,
966 struct v4l2_mbus_config *cfg)
967{
968 struct tvp5150 *decoder = to_tvp5150(sd);
969
970 cfg->type = decoder->mbus_type;
971 cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING
972 | V4L2_MBUS_FIELD_EVEN_LOW | V4L2_MBUS_DATA_ACTIVE_HIGH;
973
974 return 0;
975}
976
977/****************************************************************************
978 V4L2 subdev pad ops
979 ****************************************************************************/
980static int tvp5150_enum_mbus_code(struct v4l2_subdev *sd,
981 struct v4l2_subdev_pad_config *cfg,
982 struct v4l2_subdev_mbus_code_enum *code)
983{
984 if (code->pad || code->index)
985 return -EINVAL;
986
987 code->code = MEDIA_BUS_FMT_UYVY8_2X8;
988 return 0;
989}
990
991static int tvp5150_enum_frame_size(struct v4l2_subdev *sd,
992 struct v4l2_subdev_pad_config *cfg,
993 struct v4l2_subdev_frame_size_enum *fse)
994{
995 struct tvp5150 *decoder = to_tvp5150(sd);
996
997 if (fse->index >= 8 || fse->code != MEDIA_BUS_FMT_UYVY8_2X8)
998 return -EINVAL;
999
1000 fse->code = MEDIA_BUS_FMT_UYVY8_2X8;
1001 fse->min_width = decoder->rect.width;
1002 fse->max_width = decoder->rect.width;
1003 fse->min_height = decoder->rect.height / 2;
1004 fse->max_height = decoder->rect.height / 2;
1005
1006 return 0;
1007}
1008
1009/****************************************************************************
1010 Media entity ops
1011 ****************************************************************************/
1012
1013static int tvp5150_link_setup(struct media_entity *entity,
1014 const struct media_pad *local,
1015 const struct media_pad *remote, u32 flags)
1016{
1017#ifdef CONFIG_MEDIA_CONTROLLER
1018 struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
1019 struct tvp5150 *decoder = to_tvp5150(sd);
1020 int i;
1021
1022 for (i = 0; i < TVP5150_INPUT_NUM; i++) {
1023 if (remote->entity == &decoder->input_ent[i])
1024 break;
1025 }
1026
1027 /* Do nothing for entities that are not input connectors */
1028 if (i == TVP5150_INPUT_NUM)
1029 return 0;
1030
1031 decoder->input = i;
1032
1033 tvp5150_selmux(sd);
1034#endif
1035
1036 return 0;
1037}
1038
1039static const struct media_entity_operations tvp5150_sd_media_ops = {
1040 .link_setup = tvp5150_link_setup,
1041};
1042
951/**************************************************************************** 1043/****************************************************************************
952 I2C Command 1044 I2C Command
953 ****************************************************************************/ 1045 ****************************************************************************/
954 1046
1047static int tvp5150_s_stream(struct v4l2_subdev *sd, int enable)
1048{
1049 struct tvp5150 *decoder = to_tvp5150(sd);
1050 /* Output format: 8-bit ITU-R BT.656 with embedded syncs */
1051 int val = 0x09;
1052
1053 /* Output format: 8-bit 4:2:2 YUV with discrete sync */
1054 if (decoder->mbus_type == V4L2_MBUS_PARALLEL)
1055 val = 0x0d;
1056
1057 /* Initializes TVP5150 to its default values */
1058 /* # set PCLK (27MHz) */
1059 tvp5150_write(sd, TVP5150_CONF_SHARED_PIN, 0x00);
1060
1061 if (enable)
1062 tvp5150_write(sd, TVP5150_MISC_CTL, val);
1063 else
1064 tvp5150_write(sd, TVP5150_MISC_CTL, 0x00);
1065
1066 return 0;
1067}
1068
955static int tvp5150_s_routing(struct v4l2_subdev *sd, 1069static int tvp5150_s_routing(struct v4l2_subdev *sd,
956 u32 input, u32 output, u32 config) 1070 u32 input, u32 output, u32 config)
957{ 1071{
@@ -959,6 +1073,12 @@ static int tvp5150_s_routing(struct v4l2_subdev *sd,
959 1073
960 decoder->input = input; 1074 decoder->input = input;
961 decoder->output = output; 1075 decoder->output = output;
1076
1077 if (output == TVP5150_BLACK_SCREEN)
1078 decoder->enable = false;
1079 else
1080 decoder->enable = true;
1081
962 tvp5150_selmux(sd); 1082 tvp5150_selmux(sd);
963 return 0; 1083 return 0;
964} 1084}
@@ -1052,6 +1172,42 @@ static int tvp5150_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
1052 return 0; 1172 return 0;
1053} 1173}
1054 1174
1175static int tvp5150_registered_async(struct v4l2_subdev *sd)
1176{
1177#ifdef CONFIG_MEDIA_CONTROLLER
1178 struct tvp5150 *decoder = to_tvp5150(sd);
1179 int ret = 0;
1180 int i;
1181
1182 for (i = 0; i < TVP5150_INPUT_NUM; i++) {
1183 struct media_entity *input = &decoder->input_ent[i];
1184 struct media_pad *pad = &decoder->input_pad[i];
1185
1186 if (!input->name)
1187 continue;
1188
1189 decoder->input_pad[i].flags = MEDIA_PAD_FL_SOURCE;
1190
1191 ret = media_entity_pads_init(input, 1, pad);
1192 if (ret < 0)
1193 return ret;
1194
1195 ret = media_device_register_entity(sd->v4l2_dev->mdev, input);
1196 if (ret < 0)
1197 return ret;
1198
1199 ret = media_create_pad_link(input, 0, &sd->entity,
1200 DEMOD_PAD_IF_INPUT, 0);
1201 if (ret < 0) {
1202 media_device_unregister_entity(input);
1203 return ret;
1204 }
1205 }
1206#endif
1207
1208 return 0;
1209}
1210
1055/* ----------------------------------------------------------------------- */ 1211/* ----------------------------------------------------------------------- */
1056 1212
1057static const struct v4l2_ctrl_ops tvp5150_ctrl_ops = { 1213static const struct v4l2_ctrl_ops tvp5150_ctrl_ops = {
@@ -1065,6 +1221,7 @@ static const struct v4l2_subdev_core_ops tvp5150_core_ops = {
1065 .g_register = tvp5150_g_register, 1221 .g_register = tvp5150_g_register,
1066 .s_register = tvp5150_s_register, 1222 .s_register = tvp5150_s_register,
1067#endif 1223#endif
1224 .registered_async = tvp5150_registered_async,
1068}; 1225};
1069 1226
1070static const struct v4l2_subdev_tuner_ops tvp5150_tuner_ops = { 1227static const struct v4l2_subdev_tuner_ops tvp5150_tuner_ops = {
@@ -1073,10 +1230,12 @@ static const struct v4l2_subdev_tuner_ops tvp5150_tuner_ops = {
1073 1230
1074static const struct v4l2_subdev_video_ops tvp5150_video_ops = { 1231static const struct v4l2_subdev_video_ops tvp5150_video_ops = {
1075 .s_std = tvp5150_s_std, 1232 .s_std = tvp5150_s_std,
1233 .s_stream = tvp5150_s_stream,
1076 .s_routing = tvp5150_s_routing, 1234 .s_routing = tvp5150_s_routing,
1077 .s_crop = tvp5150_s_crop, 1235 .s_crop = tvp5150_s_crop,
1078 .g_crop = tvp5150_g_crop, 1236 .g_crop = tvp5150_g_crop,
1079 .cropcap = tvp5150_cropcap, 1237 .cropcap = tvp5150_cropcap,
1238 .g_mbus_config = tvp5150_g_mbus_config,
1080}; 1239};
1081 1240
1082static const struct v4l2_subdev_vbi_ops tvp5150_vbi_ops = { 1241static const struct v4l2_subdev_vbi_ops tvp5150_vbi_ops = {
@@ -1088,6 +1247,7 @@ static const struct v4l2_subdev_vbi_ops tvp5150_vbi_ops = {
1088 1247
1089static const struct v4l2_subdev_pad_ops tvp5150_pad_ops = { 1248static const struct v4l2_subdev_pad_ops tvp5150_pad_ops = {
1090 .enum_mbus_code = tvp5150_enum_mbus_code, 1249 .enum_mbus_code = tvp5150_enum_mbus_code,
1250 .enum_frame_size = tvp5150_enum_frame_size,
1091 .set_fmt = tvp5150_fill_fmt, 1251 .set_fmt = tvp5150_fill_fmt,
1092 .get_fmt = tvp5150_fill_fmt, 1252 .get_fmt = tvp5150_fill_fmt,
1093}; 1253};
@@ -1105,63 +1265,239 @@ static const struct v4l2_subdev_ops tvp5150_ops = {
1105 I2C Client & Driver 1265 I2C Client & Driver
1106 ****************************************************************************/ 1266 ****************************************************************************/
1107 1267
1268static int tvp5150_detect_version(struct tvp5150 *core)
1269{
1270 struct v4l2_subdev *sd = &core->sd;
1271 struct i2c_client *c = v4l2_get_subdevdata(sd);
1272 unsigned int i;
1273 u8 regs[4];
1274 int res;
1275
1276 /*
1277 * Read consequent registers - TVP5150_MSB_DEV_ID, TVP5150_LSB_DEV_ID,
1278 * TVP5150_ROM_MAJOR_VER, TVP5150_ROM_MINOR_VER
1279 */
1280 for (i = 0; i < 4; i++) {
1281 res = tvp5150_read(sd, TVP5150_MSB_DEV_ID + i);
1282 if (res < 0)
1283 return res;
1284 regs[i] = res;
1285 }
1286
1287 core->dev_id = (regs[0] << 8) | regs[1];
1288 core->rom_ver = (regs[2] << 8) | regs[3];
1289
1290 v4l2_info(sd, "tvp%04x (%u.%u) chip found @ 0x%02x (%s)\n",
1291 core->dev_id, regs[2], regs[3], c->addr << 1,
1292 c->adapter->name);
1293
1294 if (core->dev_id == 0x5150 && core->rom_ver == 0x0321) {
1295 v4l2_info(sd, "tvp5150a detected.\n");
1296 } else if (core->dev_id == 0x5150 && core->rom_ver == 0x0400) {
1297 v4l2_info(sd, "tvp5150am1 detected.\n");
1298
1299 /* ITU-T BT.656.4 timing */
1300 tvp5150_write(sd, TVP5150_REV_SELECT, 0);
1301 } else if (core->dev_id == 0x5151 && core->rom_ver == 0x0100) {
1302 v4l2_info(sd, "tvp5151 detected.\n");
1303 } else {
1304 v4l2_info(sd, "*** unknown tvp%04x chip detected.\n",
1305 core->dev_id);
1306 }
1307
1308 return 0;
1309}
1310
1311static int tvp5150_init(struct i2c_client *c)
1312{
1313 struct gpio_desc *pdn_gpio;
1314 struct gpio_desc *reset_gpio;
1315
1316 pdn_gpio = devm_gpiod_get_optional(&c->dev, "pdn", GPIOD_OUT_HIGH);
1317 if (IS_ERR(pdn_gpio))
1318 return PTR_ERR(pdn_gpio);
1319
1320 if (pdn_gpio) {
1321 gpiod_set_value_cansleep(pdn_gpio, 0);
1322 /* Delay time between power supplies active and reset */
1323 msleep(20);
1324 }
1325
1326 reset_gpio = devm_gpiod_get_optional(&c->dev, "reset", GPIOD_OUT_HIGH);
1327 if (IS_ERR(reset_gpio))
1328 return PTR_ERR(reset_gpio);
1329
1330 if (reset_gpio) {
1331 /* RESETB pulse duration */
1332 ndelay(500);
1333 gpiod_set_value_cansleep(reset_gpio, 0);
1334 /* Delay time between end of reset to I2C active */
1335 usleep_range(200, 250);
1336 }
1337
1338 return 0;
1339}
1340
1341static int tvp5150_parse_dt(struct tvp5150 *decoder, struct device_node *np)
1342{
1343 struct v4l2_of_endpoint bus_cfg;
1344 struct device_node *ep;
1345#ifdef CONFIG_MEDIA_CONTROLLER
1346 struct device_node *connectors, *child;
1347 struct media_entity *input;
1348 const char *name;
1349 u32 input_type;
1350#endif
1351 unsigned int flags;
1352 int ret = 0;
1353
1354 ep = of_graph_get_next_endpoint(np, NULL);
1355 if (!ep)
1356 return -EINVAL;
1357
1358 ret = v4l2_of_parse_endpoint(ep, &bus_cfg);
1359 if (ret)
1360 goto err;
1361
1362 flags = bus_cfg.bus.parallel.flags;
1363
1364 if (bus_cfg.bus_type == V4L2_MBUS_PARALLEL &&
1365 !(flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH &&
1366 flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH &&
1367 flags & V4L2_MBUS_FIELD_EVEN_LOW)) {
1368 ret = -EINVAL;
1369 goto err;
1370 }
1371
1372 decoder->mbus_type = bus_cfg.bus_type;
1373
1374#ifdef CONFIG_MEDIA_CONTROLLER
1375 connectors = of_get_child_by_name(np, "connectors");
1376
1377 if (!connectors)
1378 goto err;
1379
1380 for_each_available_child_of_node(connectors, child) {
1381 ret = of_property_read_u32(child, "input", &input_type);
1382 if (ret) {
1383 v4l2_err(&decoder->sd,
1384 "missing type property in node %s\n",
1385 child->name);
1386 goto err_connector;
1387 }
1388
1389 if (input_type >= TVP5150_INPUT_NUM) {
1390 ret = -EINVAL;
1391 goto err_connector;
1392 }
1393
1394 input = &decoder->input_ent[input_type];
1395
1396 /* Each input connector can only be defined once */
1397 if (input->name) {
1398 v4l2_err(&decoder->sd,
1399 "input %s with same type already exists\n",
1400 input->name);
1401 ret = -EINVAL;
1402 goto err_connector;
1403 }
1404
1405 switch (input_type) {
1406 case TVP5150_COMPOSITE0:
1407 case TVP5150_COMPOSITE1:
1408 input->function = MEDIA_ENT_F_CONN_COMPOSITE;
1409 break;
1410 case TVP5150_SVIDEO:
1411 input->function = MEDIA_ENT_F_CONN_SVIDEO;
1412 break;
1413 }
1414
1415 input->flags = MEDIA_ENT_FL_CONNECTOR;
1416
1417 ret = of_property_read_string(child, "label", &name);
1418 if (ret < 0) {
1419 v4l2_err(&decoder->sd,
1420 "missing label property in node %s\n",
1421 child->name);
1422 goto err_connector;
1423 }
1424
1425 input->name = name;
1426 }
1427
1428err_connector:
1429 of_node_put(connectors);
1430#endif
1431err:
1432 of_node_put(ep);
1433 return ret;
1434}
1435
1436static const char * const tvp5150_test_patterns[2] = {
1437 "Disabled",
1438 "Black screen"
1439};
1440
1108static int tvp5150_probe(struct i2c_client *c, 1441static int tvp5150_probe(struct i2c_client *c,
1109 const struct i2c_device_id *id) 1442 const struct i2c_device_id *id)
1110{ 1443{
1111 struct tvp5150 *core; 1444 struct tvp5150 *core;
1112 struct v4l2_subdev *sd; 1445 struct v4l2_subdev *sd;
1113 int tvp5150_id[4]; 1446 struct device_node *np = c->dev.of_node;
1114 int i, res; 1447 int res;
1115 1448
1116 /* Check if the adapter supports the needed features */ 1449 /* Check if the adapter supports the needed features */
1117 if (!i2c_check_functionality(c->adapter, 1450 if (!i2c_check_functionality(c->adapter,
1118 I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) 1451 I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
1119 return -EIO; 1452 return -EIO;
1120 1453
1454 res = tvp5150_init(c);
1455 if (res)
1456 return res;
1457
1121 core = devm_kzalloc(&c->dev, sizeof(*core), GFP_KERNEL); 1458 core = devm_kzalloc(&c->dev, sizeof(*core), GFP_KERNEL);
1122 if (!core) 1459 if (!core)
1123 return -ENOMEM; 1460 return -ENOMEM;
1461
1124 sd = &core->sd; 1462 sd = &core->sd;
1125 v4l2_i2c_subdev_init(sd, c, &tvp5150_ops);
1126 1463
1127 /* 1464 if (IS_ENABLED(CONFIG_OF) && np) {
1128 * Read consequent registers - TVP5150_MSB_DEV_ID, TVP5150_LSB_DEV_ID, 1465 res = tvp5150_parse_dt(core, np);
1129 * TVP5150_ROM_MAJOR_VER, TVP5150_ROM_MINOR_VER 1466 if (res) {
1130 */ 1467 v4l2_err(sd, "DT parsing error: %d\n", res);
1131 for (i = 0; i < 4; i++) {
1132 res = tvp5150_read(sd, TVP5150_MSB_DEV_ID + i);
1133 if (res < 0)
1134 return res; 1468 return res;
1135 tvp5150_id[i] = res; 1469 }
1470 } else {
1471 /* Default to BT.656 embedded sync */
1472 core->mbus_type = V4L2_MBUS_BT656;
1136 } 1473 }
1137 1474
1138 v4l_info(c, "chip found @ 0x%02x (%s)\n", 1475 v4l2_i2c_subdev_init(sd, c, &tvp5150_ops);
1139 c->addr << 1, c->adapter->name); 1476 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
1140 1477
1141 if (tvp5150_id[2] == 4 && tvp5150_id[3] == 0) { /* Is TVP5150AM1 */ 1478#if defined(CONFIG_MEDIA_CONTROLLER)
1142 v4l2_info(sd, "tvp%02x%02xam1 detected.\n", 1479 core->pads[DEMOD_PAD_IF_INPUT].flags = MEDIA_PAD_FL_SINK;
1143 tvp5150_id[0], tvp5150_id[1]); 1480 core->pads[DEMOD_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
1481 core->pads[DEMOD_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
1144 1482
1145 /* ITU-T BT.656.4 timing */ 1483 sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
1146 tvp5150_write(sd, TVP5150_REV_SELECT, 0); 1484
1147 } else { 1485 res = media_entity_pads_init(&sd->entity, DEMOD_NUM_PADS, core->pads);
1148 /* Is TVP5150A */ 1486 if (res < 0)
1149 if (tvp5150_id[2] == 3 || tvp5150_id[3] == 0x21) { 1487 return res;
1150 v4l2_info(sd, "tvp%02x%02xa detected.\n", 1488
1151 tvp5150_id[0], tvp5150_id[1]); 1489 sd->entity.ops = &tvp5150_sd_media_ops;
1152 } else { 1490#endif
1153 v4l2_info(sd, "*** unknown tvp%02x%02x chip detected.\n", 1491
1154 tvp5150_id[0], tvp5150_id[1]); 1492 res = tvp5150_detect_version(core);
1155 v4l2_info(sd, "*** Rom ver is %d.%d\n", 1493 if (res < 0)
1156 tvp5150_id[2], tvp5150_id[3]); 1494 return res;
1157 }
1158 }
1159 1495
1160 core->norm = V4L2_STD_ALL; /* Default is autodetect */ 1496 core->norm = V4L2_STD_ALL; /* Default is autodetect */
1161 core->input = TVP5150_COMPOSITE1; 1497 core->input = TVP5150_COMPOSITE1;
1162 core->enable = 1; 1498 core->enable = true;
1163 1499
1164 v4l2_ctrl_handler_init(&core->hdl, 4); 1500 v4l2_ctrl_handler_init(&core->hdl, 5);
1165 v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops, 1501 v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
1166 V4L2_CID_BRIGHTNESS, 0, 255, 1, 128); 1502 V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
1167 v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops, 1503 v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
@@ -1170,6 +1506,13 @@ static int tvp5150_probe(struct i2c_client *c,
1170 V4L2_CID_SATURATION, 0, 255, 1, 128); 1506 V4L2_CID_SATURATION, 0, 255, 1, 128);
1171 v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops, 1507 v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
1172 V4L2_CID_HUE, -128, 127, 1, 0); 1508 V4L2_CID_HUE, -128, 127, 1, 0);
1509 v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
1510 V4L2_CID_PIXEL_RATE, 27000000,
1511 27000000, 1, 27000000);
1512 v4l2_ctrl_new_std_menu_items(&core->hdl, &tvp5150_ctrl_ops,
1513 V4L2_CID_TEST_PATTERN,
1514 ARRAY_SIZE(tvp5150_test_patterns),
1515 0, 0, tvp5150_test_patterns);
1173 sd->ctrl_handler = &core->hdl; 1516 sd->ctrl_handler = &core->hdl;
1174 if (core->hdl.error) { 1517 if (core->hdl.error) {
1175 res = core->hdl.error; 1518 res = core->hdl.error;
@@ -1221,8 +1564,17 @@ static const struct i2c_device_id tvp5150_id[] = {
1221}; 1564};
1222MODULE_DEVICE_TABLE(i2c, tvp5150_id); 1565MODULE_DEVICE_TABLE(i2c, tvp5150_id);
1223 1566
1567#if IS_ENABLED(CONFIG_OF)
1568static const struct of_device_id tvp5150_of_match[] = {
1569 { .compatible = "ti,tvp5150", },
1570 { /* sentinel */ },
1571};
1572MODULE_DEVICE_TABLE(of, tvp5150_of_match);
1573#endif
1574
1224static struct i2c_driver tvp5150_driver = { 1575static struct i2c_driver tvp5150_driver = {
1225 .driver = { 1576 .driver = {
1577 .of_match_table = of_match_ptr(tvp5150_of_match),
1226 .name = "tvp5150", 1578 .name = "tvp5150",
1227 }, 1579 },
1228 .probe = tvp5150_probe, 1580 .probe = tvp5150_probe,
diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c
index 83c79fa5f61d..4df640c3aa40 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -894,7 +894,7 @@ static struct tvp7002_config *
894tvp7002_get_pdata(struct i2c_client *client) 894tvp7002_get_pdata(struct i2c_client *client)
895{ 895{
896 struct v4l2_of_endpoint bus_cfg; 896 struct v4l2_of_endpoint bus_cfg;
897 struct tvp7002_config *pdata; 897 struct tvp7002_config *pdata = NULL;
898 struct device_node *endpoint; 898 struct device_node *endpoint;
899 unsigned int flags; 899 unsigned int flags;
900 900
@@ -905,11 +905,13 @@ tvp7002_get_pdata(struct i2c_client *client)
905 if (!endpoint) 905 if (!endpoint)
906 return NULL; 906 return NULL;
907 907
908 if (v4l2_of_parse_endpoint(endpoint, &bus_cfg))
909 goto done;
910
908 pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); 911 pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
909 if (!pdata) 912 if (!pdata)
910 goto done; 913 goto done;
911 914
912 v4l2_of_parse_endpoint(endpoint, &bus_cfg);
913 flags = bus_cfg.bus.parallel.flags; 915 flags = bus_cfg.bus.parallel.flags;
914 916
915 if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) 917 if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
diff --git a/drivers/media/i2c/vpx3220.c b/drivers/media/i2c/vpx3220.c
index 4b564f17f618..90b693f4e2ab 100644
--- a/drivers/media/i2c/vpx3220.c
+++ b/drivers/media/i2c/vpx3220.c
@@ -124,7 +124,7 @@ static int vpx3220_fp_write(struct v4l2_subdev *sd, u8 fpaddr, u16 data)
124 return 0; 124 return 0;
125} 125}
126 126
127static u16 vpx3220_fp_read(struct v4l2_subdev *sd, u16 fpaddr) 127static int vpx3220_fp_read(struct v4l2_subdev *sd, u16 fpaddr)
128{ 128{
129 struct i2c_client *client = v4l2_get_subdevdata(sd); 129 struct i2c_client *client = v4l2_get_subdevdata(sd);
130 s16 data; 130 s16 data;
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index e9219f528d7e..6e43c95629ea 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -30,6 +30,8 @@
30#include <linux/media.h> 30#include <linux/media.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/pci.h>
34#include <linux/usb.h>
33 35
34#include <media/media-device.h> 36#include <media/media-device.h>
35#include <media/media-devnode.h> 37#include <media/media-devnode.h>
@@ -41,6 +43,11 @@
41 * Userspace API 43 * Userspace API
42 */ 44 */
43 45
46static inline void __user *media_get_uptr(__u64 arg)
47{
48 return (void __user *)(uintptr_t)arg;
49}
50
44static int media_device_open(struct file *filp) 51static int media_device_open(struct file *filp)
45{ 52{
46 return 0; 53 return 0;
@@ -58,7 +65,11 @@ static int media_device_get_info(struct media_device *dev,
58 65
59 memset(&info, 0, sizeof(info)); 66 memset(&info, 0, sizeof(info));
60 67
61 strlcpy(info.driver, dev->dev->driver->name, sizeof(info.driver)); 68 if (dev->driver_name[0])
69 strlcpy(info.driver, dev->driver_name, sizeof(info.driver));
70 else
71 strlcpy(info.driver, dev->dev->driver->name, sizeof(info.driver));
72
62 strlcpy(info.model, dev->model, sizeof(info.model)); 73 strlcpy(info.model, dev->model, sizeof(info.model));
63 strlcpy(info.serial, dev->serial, sizeof(info.serial)); 74 strlcpy(info.serial, dev->serial, sizeof(info.serial));
64 strlcpy(info.bus_info, dev->bus_info, sizeof(info.bus_info)); 75 strlcpy(info.bus_info, dev->bus_info, sizeof(info.bus_info));
@@ -257,7 +268,6 @@ static long media_device_setup_link(struct media_device *mdev,
257 return ret; 268 return ret;
258} 269}
259 270
260#if 0 /* Let's postpone it to Kernel 4.6 */
261static long __media_device_get_topology(struct media_device *mdev, 271static long __media_device_get_topology(struct media_device *mdev,
262 struct media_v2_topology *topo) 272 struct media_v2_topology *topo)
263{ 273{
@@ -265,10 +275,10 @@ static long __media_device_get_topology(struct media_device *mdev,
265 struct media_interface *intf; 275 struct media_interface *intf;
266 struct media_pad *pad; 276 struct media_pad *pad;
267 struct media_link *link; 277 struct media_link *link;
268 struct media_v2_entity kentity, *uentity; 278 struct media_v2_entity kentity, __user *uentity;
269 struct media_v2_interface kintf, *uintf; 279 struct media_v2_interface kintf, __user *uintf;
270 struct media_v2_pad kpad, *upad; 280 struct media_v2_pad kpad, __user *upad;
271 struct media_v2_link klink, *ulink; 281 struct media_v2_link klink, __user *ulink;
272 unsigned int i; 282 unsigned int i;
273 int ret = 0; 283 int ret = 0;
274 284
@@ -413,7 +423,6 @@ static long media_device_get_topology(struct media_device *mdev,
413 423
414 return 0; 424 return 0;
415} 425}
416#endif
417 426
418static long media_device_ioctl(struct file *filp, unsigned int cmd, 427static long media_device_ioctl(struct file *filp, unsigned int cmd,
419 unsigned long arg) 428 unsigned long arg)
@@ -447,14 +456,13 @@ static long media_device_ioctl(struct file *filp, unsigned int cmd,
447 mutex_unlock(&dev->graph_mutex); 456 mutex_unlock(&dev->graph_mutex);
448 break; 457 break;
449 458
450#if 0 /* Let's postpone it to Kernel 4.6 */
451 case MEDIA_IOC_G_TOPOLOGY: 459 case MEDIA_IOC_G_TOPOLOGY:
452 mutex_lock(&dev->graph_mutex); 460 mutex_lock(&dev->graph_mutex);
453 ret = media_device_get_topology(dev, 461 ret = media_device_get_topology(dev,
454 (struct media_v2_topology __user *)arg); 462 (struct media_v2_topology __user *)arg);
455 mutex_unlock(&dev->graph_mutex); 463 mutex_unlock(&dev->graph_mutex);
456 break; 464 break;
457#endif 465
458 default: 466 default:
459 ret = -ENOIOCTLCMD; 467 ret = -ENOIOCTLCMD;
460 } 468 }
@@ -503,9 +511,7 @@ static long media_device_compat_ioctl(struct file *filp, unsigned int cmd,
503 case MEDIA_IOC_DEVICE_INFO: 511 case MEDIA_IOC_DEVICE_INFO:
504 case MEDIA_IOC_ENUM_ENTITIES: 512 case MEDIA_IOC_ENUM_ENTITIES:
505 case MEDIA_IOC_SETUP_LINK: 513 case MEDIA_IOC_SETUP_LINK:
506#if 0 /* Let's postpone it to Kernel 4.6 */
507 case MEDIA_IOC_G_TOPOLOGY: 514 case MEDIA_IOC_G_TOPOLOGY:
508#endif
509 return media_device_ioctl(filp, cmd, arg); 515 return media_device_ioctl(filp, cmd, arg);
510 516
511 case MEDIA_IOC_ENUM_LINKS32: 517 case MEDIA_IOC_ENUM_LINKS32:
@@ -564,6 +570,7 @@ static void media_device_release(struct media_devnode *mdev)
564int __must_check media_device_register_entity(struct media_device *mdev, 570int __must_check media_device_register_entity(struct media_device *mdev,
565 struct media_entity *entity) 571 struct media_entity *entity)
566{ 572{
573 struct media_entity_notify *notify, *next;
567 unsigned int i; 574 unsigned int i;
568 int ret; 575 int ret;
569 576
@@ -603,8 +610,33 @@ int __must_check media_device_register_entity(struct media_device *mdev,
603 media_gobj_create(mdev, MEDIA_GRAPH_PAD, 610 media_gobj_create(mdev, MEDIA_GRAPH_PAD,
604 &entity->pads[i].graph_obj); 611 &entity->pads[i].graph_obj);
605 612
613 /* invoke entity_notify callbacks */
614 list_for_each_entry_safe(notify, next, &mdev->entity_notify, list) {
615 (notify)->notify(entity, notify->notify_data);
616 }
617
606 spin_unlock(&mdev->lock); 618 spin_unlock(&mdev->lock);
607 619
620 mutex_lock(&mdev->graph_mutex);
621 if (mdev->entity_internal_idx_max
622 >= mdev->pm_count_walk.ent_enum.idx_max) {
623 struct media_entity_graph new = { .top = 0 };
624
625 /*
626 * Initialise the new graph walk before cleaning up
627 * the old one in order not to spoil the graph walk
628 * object of the media device if graph walk init fails.
629 */
630 ret = media_entity_graph_walk_init(&new, mdev);
631 if (ret) {
632 mutex_unlock(&mdev->graph_mutex);
633 return ret;
634 }
635 media_entity_graph_walk_cleanup(&mdev->pm_count_walk);
636 mdev->pm_count_walk = new;
637 }
638 mutex_unlock(&mdev->graph_mutex);
639
608 return 0; 640 return 0;
609} 641}
610EXPORT_SYMBOL_GPL(media_device_register_entity); 642EXPORT_SYMBOL_GPL(media_device_register_entity);
@@ -636,6 +668,8 @@ static void __media_device_unregister_entity(struct media_entity *entity)
636 /* Remove the entity */ 668 /* Remove the entity */
637 media_gobj_destroy(&entity->graph_obj); 669 media_gobj_destroy(&entity->graph_obj);
638 670
671 /* invoke entity_notify callbacks to handle entity removal?? */
672
639 entity->graph_obj.mdev = NULL; 673 entity->graph_obj.mdev = NULL;
640} 674}
641 675
@@ -668,6 +702,7 @@ void media_device_init(struct media_device *mdev)
668 INIT_LIST_HEAD(&mdev->interfaces); 702 INIT_LIST_HEAD(&mdev->interfaces);
669 INIT_LIST_HEAD(&mdev->pads); 703 INIT_LIST_HEAD(&mdev->pads);
670 INIT_LIST_HEAD(&mdev->links); 704 INIT_LIST_HEAD(&mdev->links);
705 INIT_LIST_HEAD(&mdev->entity_notify);
671 spin_lock_init(&mdev->lock); 706 spin_lock_init(&mdev->lock);
672 mutex_init(&mdev->graph_mutex); 707 mutex_init(&mdev->graph_mutex);
673 ida_init(&mdev->entity_internal_idx); 708 ida_init(&mdev->entity_internal_idx);
@@ -680,6 +715,7 @@ void media_device_cleanup(struct media_device *mdev)
680{ 715{
681 ida_destroy(&mdev->entity_internal_idx); 716 ida_destroy(&mdev->entity_internal_idx);
682 mdev->entity_internal_idx_max = 0; 717 mdev->entity_internal_idx_max = 0;
718 media_entity_graph_walk_cleanup(&mdev->pm_count_walk);
683 mutex_destroy(&mdev->graph_mutex); 719 mutex_destroy(&mdev->graph_mutex);
684} 720}
685EXPORT_SYMBOL_GPL(media_device_cleanup); 721EXPORT_SYMBOL_GPL(media_device_cleanup);
@@ -713,11 +749,40 @@ int __must_check __media_device_register(struct media_device *mdev,
713} 749}
714EXPORT_SYMBOL_GPL(__media_device_register); 750EXPORT_SYMBOL_GPL(__media_device_register);
715 751
752int __must_check media_device_register_entity_notify(struct media_device *mdev,
753 struct media_entity_notify *nptr)
754{
755 spin_lock(&mdev->lock);
756 list_add_tail(&nptr->list, &mdev->entity_notify);
757 spin_unlock(&mdev->lock);
758 return 0;
759}
760EXPORT_SYMBOL_GPL(media_device_register_entity_notify);
761
762/*
763 * Note: Should be called with mdev->lock held.
764 */
765static void __media_device_unregister_entity_notify(struct media_device *mdev,
766 struct media_entity_notify *nptr)
767{
768 list_del(&nptr->list);
769}
770
771void media_device_unregister_entity_notify(struct media_device *mdev,
772 struct media_entity_notify *nptr)
773{
774 spin_lock(&mdev->lock);
775 __media_device_unregister_entity_notify(mdev, nptr);
776 spin_unlock(&mdev->lock);
777}
778EXPORT_SYMBOL_GPL(media_device_unregister_entity_notify);
779
716void media_device_unregister(struct media_device *mdev) 780void media_device_unregister(struct media_device *mdev)
717{ 781{
718 struct media_entity *entity; 782 struct media_entity *entity;
719 struct media_entity *next; 783 struct media_entity *next;
720 struct media_interface *intf, *tmp_intf; 784 struct media_interface *intf, *tmp_intf;
785 struct media_entity_notify *notify, *nextp;
721 786
722 if (mdev == NULL) 787 if (mdev == NULL)
723 return; 788 return;
@@ -734,6 +799,10 @@ void media_device_unregister(struct media_device *mdev)
734 list_for_each_entry_safe(entity, next, &mdev->entities, graph_obj.list) 799 list_for_each_entry_safe(entity, next, &mdev->entities, graph_obj.list)
735 __media_device_unregister_entity(entity); 800 __media_device_unregister_entity(entity);
736 801
802 /* Remove all entity_notify callbacks from the media device */
803 list_for_each_entry_safe(notify, nextp, &mdev->entity_notify, list)
804 __media_device_unregister_entity_notify(mdev, notify);
805
737 /* Remove all interfaces from the media device */ 806 /* Remove all interfaces from the media device */
738 list_for_each_entry_safe(intf, tmp_intf, &mdev->interfaces, 807 list_for_each_entry_safe(intf, tmp_intf, &mdev->interfaces,
739 graph_obj.list) { 808 graph_obj.list) {
@@ -777,4 +846,58 @@ struct media_device *media_device_find_devres(struct device *dev)
777} 846}
778EXPORT_SYMBOL_GPL(media_device_find_devres); 847EXPORT_SYMBOL_GPL(media_device_find_devres);
779 848
849void media_device_pci_init(struct media_device *mdev,
850 struct pci_dev *pci_dev,
851 const char *name)
852{
853#ifdef CONFIG_PCI
854 mdev->dev = &pci_dev->dev;
855
856 if (name)
857 strlcpy(mdev->model, name, sizeof(mdev->model));
858 else
859 strlcpy(mdev->model, pci_name(pci_dev), sizeof(mdev->model));
860
861 sprintf(mdev->bus_info, "PCI:%s", pci_name(pci_dev));
862
863 mdev->hw_revision = (pci_dev->subsystem_vendor << 16)
864 | pci_dev->subsystem_device;
865
866 mdev->driver_version = LINUX_VERSION_CODE;
867
868 media_device_init(mdev);
869#endif
870}
871EXPORT_SYMBOL_GPL(media_device_pci_init);
872
873void __media_device_usb_init(struct media_device *mdev,
874 struct usb_device *udev,
875 const char *board_name,
876 const char *driver_name)
877{
878#ifdef CONFIG_USB
879 mdev->dev = &udev->dev;
880
881 if (driver_name)
882 strlcpy(mdev->driver_name, driver_name,
883 sizeof(mdev->driver_name));
884
885 if (board_name)
886 strlcpy(mdev->model, board_name, sizeof(mdev->model));
887 else if (udev->product)
888 strlcpy(mdev->model, udev->product, sizeof(mdev->model));
889 else
890 strlcpy(mdev->model, "unknown model", sizeof(mdev->model));
891 if (udev->serial)
892 strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial));
893 usb_make_path(udev, mdev->bus_info, sizeof(mdev->bus_info));
894 mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
895 mdev->driver_version = LINUX_VERSION_CODE;
896
897 media_device_init(mdev);
898#endif
899}
900EXPORT_SYMBOL_GPL(__media_device_usb_init);
901
902
780#endif /* CONFIG_MEDIA_CONTROLLER */ 903#endif /* CONFIG_MEDIA_CONTROLLER */
diff --git a/drivers/media/media-devnode.c b/drivers/media/media-devnode.c
index cea35bf20011..29409f440f1c 100644
--- a/drivers/media/media-devnode.c
+++ b/drivers/media/media-devnode.c
@@ -181,6 +181,7 @@ static int media_open(struct inode *inode, struct file *filp)
181 ret = mdev->fops->open(filp); 181 ret = mdev->fops->open(filp);
182 if (ret) { 182 if (ret) {
183 put_device(&mdev->dev); 183 put_device(&mdev->dev);
184 filp->private_data = NULL;
184 return ret; 185 return ret;
185 } 186 }
186 } 187 }
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index e89d85a7d31b..e95070b3a3d4 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -46,25 +46,41 @@ static inline const char *intf_type(struct media_interface *intf)
46{ 46{
47 switch (intf->type) { 47 switch (intf->type) {
48 case MEDIA_INTF_T_DVB_FE: 48 case MEDIA_INTF_T_DVB_FE:
49 return "frontend"; 49 return "dvb-frontend";
50 case MEDIA_INTF_T_DVB_DEMUX: 50 case MEDIA_INTF_T_DVB_DEMUX:
51 return "demux"; 51 return "dvb-demux";
52 case MEDIA_INTF_T_DVB_DVR: 52 case MEDIA_INTF_T_DVB_DVR:
53 return "DVR"; 53 return "dvb-dvr";
54 case MEDIA_INTF_T_DVB_CA: 54 case MEDIA_INTF_T_DVB_CA:
55 return "CA"; 55 return "dvb-ca";
56 case MEDIA_INTF_T_DVB_NET: 56 case MEDIA_INTF_T_DVB_NET:
57 return "dvbnet"; 57 return "dvb-net";
58 case MEDIA_INTF_T_V4L_VIDEO: 58 case MEDIA_INTF_T_V4L_VIDEO:
59 return "video"; 59 return "v4l-video";
60 case MEDIA_INTF_T_V4L_VBI: 60 case MEDIA_INTF_T_V4L_VBI:
61 return "vbi"; 61 return "v4l-vbi";
62 case MEDIA_INTF_T_V4L_RADIO: 62 case MEDIA_INTF_T_V4L_RADIO:
63 return "radio"; 63 return "v4l-radio";
64 case MEDIA_INTF_T_V4L_SUBDEV: 64 case MEDIA_INTF_T_V4L_SUBDEV:
65 return "v4l2-subdev"; 65 return "v4l-subdev";
66 case MEDIA_INTF_T_V4L_SWRADIO: 66 case MEDIA_INTF_T_V4L_SWRADIO:
67 return "swradio"; 67 return "v4l-swradio";
68 case MEDIA_INTF_T_ALSA_PCM_CAPTURE:
69 return "alsa-pcm-capture";
70 case MEDIA_INTF_T_ALSA_PCM_PLAYBACK:
71 return "alsa-pcm-playback";
72 case MEDIA_INTF_T_ALSA_CONTROL:
73 return "alsa-control";
74 case MEDIA_INTF_T_ALSA_COMPRESS:
75 return "alsa-compress";
76 case MEDIA_INTF_T_ALSA_RAWMIDI:
77 return "alsa-rawmidi";
78 case MEDIA_INTF_T_ALSA_HWDEP:
79 return "alsa-hwdep";
80 case MEDIA_INTF_T_ALSA_SEQUENCER:
81 return "alsa-sequencer";
82 case MEDIA_INTF_T_ALSA_TIMER:
83 return "alsa-timer";
68 default: 84 default:
69 return "unknown-intf"; 85 return "unknown-intf";
70 } 86 }
@@ -73,8 +89,9 @@ static inline const char *intf_type(struct media_interface *intf)
73__must_check int __media_entity_enum_init(struct media_entity_enum *ent_enum, 89__must_check int __media_entity_enum_init(struct media_entity_enum *ent_enum,
74 int idx_max) 90 int idx_max)
75{ 91{
76 ent_enum->bmap = kcalloc(DIV_ROUND_UP(idx_max, BITS_PER_LONG), 92 idx_max = ALIGN(idx_max, BITS_PER_LONG);
77 sizeof(long), GFP_KERNEL); 93 ent_enum->bmap = kcalloc(idx_max / BITS_PER_LONG, sizeof(long),
94 GFP_KERNEL);
78 if (!ent_enum->bmap) 95 if (!ent_enum->bmap)
79 return -ENOMEM; 96 return -ENOMEM;
80 97
@@ -349,8 +366,8 @@ EXPORT_SYMBOL_GPL(media_entity_graph_walk_next);
349 * Pipeline management 366 * Pipeline management
350 */ 367 */
351 368
352__must_check int media_entity_pipeline_start(struct media_entity *entity, 369__must_check int __media_entity_pipeline_start(struct media_entity *entity,
353 struct media_pipeline *pipe) 370 struct media_pipeline *pipe)
354{ 371{
355 struct media_device *mdev = entity->graph_obj.mdev; 372 struct media_device *mdev = entity->graph_obj.mdev;
356 struct media_entity_graph *graph = &pipe->graph; 373 struct media_entity_graph *graph = &pipe->graph;
@@ -358,8 +375,6 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,
358 struct media_link *link; 375 struct media_link *link;
359 int ret; 376 int ret;
360 377
361 mutex_lock(&mdev->graph_mutex);
362
363 if (!pipe->streaming_count++) { 378 if (!pipe->streaming_count++) {
364 ret = media_entity_graph_walk_init(&pipe->graph, mdev); 379 ret = media_entity_graph_walk_init(&pipe->graph, mdev);
365 if (ret) 380 if (ret)
@@ -440,8 +455,6 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,
440 } 455 }
441 } 456 }
442 457
443 mutex_unlock(&mdev->graph_mutex);
444
445 return 0; 458 return 0;
446 459
447error: 460error:
@@ -452,9 +465,12 @@ error:
452 media_entity_graph_walk_start(graph, entity_err); 465 media_entity_graph_walk_start(graph, entity_err);
453 466
454 while ((entity_err = media_entity_graph_walk_next(graph))) { 467 while ((entity_err = media_entity_graph_walk_next(graph))) {
455 entity_err->stream_count--; 468 /* don't let the stream_count go negative */
456 if (entity_err->stream_count == 0) 469 if (entity->stream_count > 0) {
457 entity_err->pipe = NULL; 470 entity_err->stream_count--;
471 if (entity_err->stream_count == 0)
472 entity_err->pipe = NULL;
473 }
458 474
459 /* 475 /*
460 * We haven't increased stream_count further than this 476 * We haven't increased stream_count further than this
@@ -468,32 +484,53 @@ error_graph_walk_start:
468 if (!--pipe->streaming_count) 484 if (!--pipe->streaming_count)
469 media_entity_graph_walk_cleanup(graph); 485 media_entity_graph_walk_cleanup(graph);
470 486
471 mutex_unlock(&mdev->graph_mutex); 487 return ret;
488}
489EXPORT_SYMBOL_GPL(__media_entity_pipeline_start);
472 490
491__must_check int media_entity_pipeline_start(struct media_entity *entity,
492 struct media_pipeline *pipe)
493{
494 struct media_device *mdev = entity->graph_obj.mdev;
495 int ret;
496
497 mutex_lock(&mdev->graph_mutex);
498 ret = __media_entity_pipeline_start(entity, pipe);
499 mutex_unlock(&mdev->graph_mutex);
473 return ret; 500 return ret;
474} 501}
475EXPORT_SYMBOL_GPL(media_entity_pipeline_start); 502EXPORT_SYMBOL_GPL(media_entity_pipeline_start);
476 503
477void media_entity_pipeline_stop(struct media_entity *entity) 504void __media_entity_pipeline_stop(struct media_entity *entity)
478{ 505{
479 struct media_device *mdev = entity->graph_obj.mdev;
480 struct media_entity_graph *graph = &entity->pipe->graph; 506 struct media_entity_graph *graph = &entity->pipe->graph;
481 struct media_pipeline *pipe = entity->pipe; 507 struct media_pipeline *pipe = entity->pipe;
482 508
483 mutex_lock(&mdev->graph_mutex);
484 509
485 WARN_ON(!pipe->streaming_count); 510 WARN_ON(!pipe->streaming_count);
486 media_entity_graph_walk_start(graph, entity); 511 media_entity_graph_walk_start(graph, entity);
487 512
488 while ((entity = media_entity_graph_walk_next(graph))) { 513 while ((entity = media_entity_graph_walk_next(graph))) {
489 entity->stream_count--; 514 /* don't let the stream_count go negative */
490 if (entity->stream_count == 0) 515 if (entity->stream_count > 0) {
491 entity->pipe = NULL; 516 entity->stream_count--;
517 if (entity->stream_count == 0)
518 entity->pipe = NULL;
519 }
492 } 520 }
493 521
494 if (!--pipe->streaming_count) 522 if (!--pipe->streaming_count)
495 media_entity_graph_walk_cleanup(graph); 523 media_entity_graph_walk_cleanup(graph);
496 524
525}
526EXPORT_SYMBOL_GPL(__media_entity_pipeline_stop);
527
528void media_entity_pipeline_stop(struct media_entity *entity)
529{
530 struct media_device *mdev = entity->graph_obj.mdev;
531
532 mutex_lock(&mdev->graph_mutex);
533 __media_entity_pipeline_stop(entity);
497 mutex_unlock(&mdev->graph_mutex); 534 mutex_unlock(&mdev->graph_mutex);
498} 535}
499EXPORT_SYMBOL_GPL(media_entity_pipeline_stop); 536EXPORT_SYMBOL_GPL(media_entity_pipeline_stop);
@@ -783,6 +820,7 @@ int __media_entity_setup_link(struct media_link *link, u32 flags)
783 820
784 return ret; 821 return ret;
785} 822}
823EXPORT_SYMBOL_GPL(__media_entity_setup_link);
786 824
787int media_entity_setup_link(struct media_link *link, u32 flags) 825int media_entity_setup_link(struct media_link *link, u32 flags)
788{ 826{
diff --git a/drivers/media/pci/b2c2/flexcop-pci.c b/drivers/media/pci/b2c2/flexcop-pci.c
index 8b5e0b3a92a0..4cac1fc233f2 100644
--- a/drivers/media/pci/b2c2/flexcop-pci.c
+++ b/drivers/media/pci/b2c2/flexcop-pci.c
@@ -39,7 +39,7 @@ MODULE_PARM_DESC(debug,
39 39
40#define DRIVER_VERSION "0.1" 40#define DRIVER_VERSION "0.1"
41#define DRIVER_NAME "flexcop-pci" 41#define DRIVER_NAME "flexcop-pci"
42#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@desy.de>" 42#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@posteo.de>"
43 43
44struct flexcop_pci { 44struct flexcop_pci {
45 struct pci_dev *pdev; 45 struct pci_dev *pdev;
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 9400e996087b..df54e17ef864 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -186,7 +186,7 @@ MODULE_VERSION(BTTV_VERSION);
186static ssize_t show_card(struct device *cd, 186static ssize_t show_card(struct device *cd,
187 struct device_attribute *attr, char *buf) 187 struct device_attribute *attr, char *buf)
188{ 188{
189 struct video_device *vfd = container_of(cd, struct video_device, dev); 189 struct video_device *vfd = to_video_device(cd);
190 struct bttv *btv = video_get_drvdata(vfd); 190 struct bttv *btv = video_get_drvdata(vfd);
191 return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET); 191 return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET);
192} 192}
@@ -1726,22 +1726,15 @@ static int bttv_s_std(struct file *file, void *priv, v4l2_std_id id)
1726 struct bttv_fh *fh = priv; 1726 struct bttv_fh *fh = priv;
1727 struct bttv *btv = fh->btv; 1727 struct bttv *btv = fh->btv;
1728 unsigned int i; 1728 unsigned int i;
1729 int err = 0;
1730 1729
1731 for (i = 0; i < BTTV_TVNORMS; i++) 1730 for (i = 0; i < BTTV_TVNORMS; i++)
1732 if (id & bttv_tvnorms[i].v4l2_id) 1731 if (id & bttv_tvnorms[i].v4l2_id)
1733 break; 1732 break;
1734 if (i == BTTV_TVNORMS) { 1733 if (i == BTTV_TVNORMS)
1735 err = -EINVAL; 1734 return -EINVAL;
1736 goto err;
1737 }
1738
1739 btv->std = id; 1735 btv->std = id;
1740 set_tvnorm(btv, i); 1736 set_tvnorm(btv, i);
1741 1737 return 0;
1742err:
1743
1744 return err;
1745} 1738}
1746 1739
1747static int bttv_g_std(struct file *file, void *priv, v4l2_std_id *id) 1740static int bttv_g_std(struct file *file, void *priv, v4l2_std_id *id)
@@ -1770,12 +1763,9 @@ static int bttv_enum_input(struct file *file, void *priv,
1770{ 1763{
1771 struct bttv_fh *fh = priv; 1764 struct bttv_fh *fh = priv;
1772 struct bttv *btv = fh->btv; 1765 struct bttv *btv = fh->btv;
1773 int rc = 0;
1774 1766
1775 if (i->index >= bttv_tvcards[btv->c.type].video_inputs) { 1767 if (i->index >= bttv_tvcards[btv->c.type].video_inputs)
1776 rc = -EINVAL; 1768 return -EINVAL;
1777 goto err;
1778 }
1779 1769
1780 i->type = V4L2_INPUT_TYPE_CAMERA; 1770 i->type = V4L2_INPUT_TYPE_CAMERA;
1781 i->audioset = 0; 1771 i->audioset = 0;
@@ -1799,10 +1789,7 @@ static int bttv_enum_input(struct file *file, void *priv,
1799 } 1789 }
1800 1790
1801 i->std = BTTV_NORMS; 1791 i->std = BTTV_NORMS;
1802 1792 return 0;
1803err:
1804
1805 return rc;
1806} 1793}
1807 1794
1808static int bttv_g_input(struct file *file, void *priv, unsigned int *i) 1795static int bttv_g_input(struct file *file, void *priv, unsigned int *i)
@@ -2334,6 +2321,19 @@ static int bttv_g_fmt_vid_overlay(struct file *file, void *priv,
2334 return 0; 2321 return 0;
2335} 2322}
2336 2323
2324static void bttv_get_width_mask_vid_cap(const struct bttv_format *fmt,
2325 unsigned int *width_mask,
2326 unsigned int *width_bias)
2327{
2328 if (fmt->flags & FORMAT_FLAGS_PLANAR) {
2329 *width_mask = ~15; /* width must be a multiple of 16 pixels */
2330 *width_bias = 8; /* nearest */
2331 } else {
2332 *width_mask = ~3; /* width must be a multiple of 4 pixels */
2333 *width_bias = 2; /* nearest */
2334 }
2335}
2336
2337static int bttv_try_fmt_vid_cap(struct file *file, void *priv, 2337static int bttv_try_fmt_vid_cap(struct file *file, void *priv,
2338 struct v4l2_format *f) 2338 struct v4l2_format *f)
2339{ 2339{
@@ -2343,6 +2343,7 @@ static int bttv_try_fmt_vid_cap(struct file *file, void *priv,
2343 enum v4l2_field field; 2343 enum v4l2_field field;
2344 __s32 width, height; 2344 __s32 width, height;
2345 __s32 height2; 2345 __s32 height2;
2346 unsigned int width_mask, width_bias;
2346 int rc; 2347 int rc;
2347 2348
2348 fmt = format_by_fourcc(f->fmt.pix.pixelformat); 2349 fmt = format_by_fourcc(f->fmt.pix.pixelformat);
@@ -2375,9 +2376,9 @@ static int bttv_try_fmt_vid_cap(struct file *file, void *priv,
2375 width = f->fmt.pix.width; 2376 width = f->fmt.pix.width;
2376 height = f->fmt.pix.height; 2377 height = f->fmt.pix.height;
2377 2378
2379 bttv_get_width_mask_vid_cap(fmt, &width_mask, &width_bias);
2378 rc = limit_scaled_size_lock(fh, &width, &height, field, 2380 rc = limit_scaled_size_lock(fh, &width, &height, field,
2379 /* width_mask: 4 pixels */ ~3, 2381 width_mask, width_bias,
2380 /* width_bias: nearest */ 2,
2381 /* adjust_size */ 1, 2382 /* adjust_size */ 1,
2382 /* adjust_crop */ 0); 2383 /* adjust_crop */ 0);
2383 if (0 != rc) 2384 if (0 != rc)
@@ -2410,6 +2411,7 @@ static int bttv_s_fmt_vid_cap(struct file *file, void *priv,
2410 struct bttv_fh *fh = priv; 2411 struct bttv_fh *fh = priv;
2411 struct bttv *btv = fh->btv; 2412 struct bttv *btv = fh->btv;
2412 __s32 width, height; 2413 __s32 width, height;
2414 unsigned int width_mask, width_bias;
2413 enum v4l2_field field; 2415 enum v4l2_field field;
2414 2416
2415 retval = bttv_switch_type(fh, f->type); 2417 retval = bttv_switch_type(fh, f->type);
@@ -2424,9 +2426,10 @@ static int bttv_s_fmt_vid_cap(struct file *file, void *priv,
2424 height = f->fmt.pix.height; 2426 height = f->fmt.pix.height;
2425 field = f->fmt.pix.field; 2427 field = f->fmt.pix.field;
2426 2428
2429 fmt = format_by_fourcc(f->fmt.pix.pixelformat);
2430 bttv_get_width_mask_vid_cap(fmt, &width_mask, &width_bias);
2427 retval = limit_scaled_size_lock(fh, &width, &height, f->fmt.pix.field, 2431 retval = limit_scaled_size_lock(fh, &width, &height, f->fmt.pix.field,
2428 /* width_mask: 4 pixels */ ~3, 2432 width_mask, width_bias,
2429 /* width_bias: nearest */ 2,
2430 /* adjust_size */ 1, 2433 /* adjust_size */ 1,
2431 /* adjust_crop */ 1); 2434 /* adjust_crop */ 1);
2432 if (0 != retval) 2435 if (0 != retval)
@@ -2434,8 +2437,6 @@ static int bttv_s_fmt_vid_cap(struct file *file, void *priv,
2434 2437
2435 f->fmt.pix.field = field; 2438 f->fmt.pix.field = field;
2436 2439
2437 fmt = format_by_fourcc(f->fmt.pix.pixelformat);
2438
2439 /* update our state informations */ 2440 /* update our state informations */
2440 fh->fmt = fmt; 2441 fh->fmt = fmt;
2441 fh->cap.field = f->fmt.pix.field; 2442 fh->cap.field = f->fmt.pix.field;
diff --git a/drivers/media/pci/bt8xx/dst.c b/drivers/media/pci/bt8xx/dst.c
index 4a90eee5e3bb..35bc9b2287b4 100644
--- a/drivers/media/pci/bt8xx/dst.c
+++ b/drivers/media/pci/bt8xx/dst.c
@@ -1688,9 +1688,9 @@ static int dst_get_tuning_algo(struct dvb_frontend *fe)
1688 return dst_algo ? DVBFE_ALGO_HW : DVBFE_ALGO_SW; 1688 return dst_algo ? DVBFE_ALGO_HW : DVBFE_ALGO_SW;
1689} 1689}
1690 1690
1691static int dst_get_frontend(struct dvb_frontend *fe) 1691static int dst_get_frontend(struct dvb_frontend *fe,
1692 struct dtv_frontend_properties *p)
1692{ 1693{
1693 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1694 struct dst_state *state = fe->demodulator_priv; 1694 struct dst_state *state = fe->demodulator_priv;
1695 1695
1696 p->frequency = state->decode_freq; 1696 p->frequency = state->decode_freq;
diff --git a/drivers/media/pci/bt8xx/dvb-bt8xx.c b/drivers/media/pci/bt8xx/dvb-bt8xx.c
index d407244fd1bc..e69d338ab9be 100644
--- a/drivers/media/pci/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/pci/bt8xx/dvb-bt8xx.c
@@ -318,7 +318,7 @@ static int microtune_mt7202dtf_request_firmware(struct dvb_frontend* fe, const s
318 return request_firmware(fw, name, &bt->bt->dev->dev); 318 return request_firmware(fw, name, &bt->bt->dev->dev);
319} 319}
320 320
321static struct sp887x_config microtune_mt7202dtf_config = { 321static const struct sp887x_config microtune_mt7202dtf_config = {
322 .demod_address = 0x70, 322 .demod_address = 0x70,
323 .request_firmware = microtune_mt7202dtf_request_firmware, 323 .request_firmware = microtune_mt7202dtf_request_firmware,
324}; 324};
@@ -458,7 +458,7 @@ static void or51211_sleep(struct dvb_frontend * fe)
458 bttv_write_gpio(bt->bttv_nr, 0x0001, 0x0000); 458 bttv_write_gpio(bt->bttv_nr, 0x0001, 0x0000);
459} 459}
460 460
461static struct or51211_config or51211_config = { 461static const struct or51211_config or51211_config = {
462 .demod_address = 0x15, 462 .demod_address = 0x15,
463 .request_firmware = or51211_request_firmware, 463 .request_firmware = or51211_request_firmware,
464 .setmode = or51211_setmode, 464 .setmode = or51211_setmode,
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
index 80319bb73d94..f041b6931ba8 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -1139,7 +1139,7 @@ static int dvb_register_ci_mac(struct cx23885_tsport *port)
1139 u8 eeprom[256]; /* 24C02 i2c eeprom */ 1139 u8 eeprom[256]; /* 24C02 i2c eeprom */
1140 struct sp2_config sp2_config; 1140 struct sp2_config sp2_config;
1141 struct i2c_board_info info; 1141 struct i2c_board_info info;
1142 struct cx23885_i2c *i2c_bus2 = &dev->i2c_bus[1]; 1142 struct cx23885_i2c *i2c_bus = &dev->i2c_bus[0];
1143 1143
1144 /* attach CI */ 1144 /* attach CI */
1145 memset(&sp2_config, 0, sizeof(sp2_config)); 1145 memset(&sp2_config, 0, sizeof(sp2_config));
@@ -1151,7 +1151,7 @@ static int dvb_register_ci_mac(struct cx23885_tsport *port)
1151 info.addr = 0x40; 1151 info.addr = 0x40;
1152 info.platform_data = &sp2_config; 1152 info.platform_data = &sp2_config;
1153 request_module(info.type); 1153 request_module(info.type);
1154 client_ci = i2c_new_device(&i2c_bus2->i2c_adap, &info); 1154 client_ci = i2c_new_device(&i2c_bus->i2c_adap, &info);
1155 if (client_ci == NULL || client_ci->dev.driver == NULL) 1155 if (client_ci == NULL || client_ci->dev.driver == NULL)
1156 return -ENODEV; 1156 return -ENODEV;
1157 if (!try_module_get(client_ci->dev.driver->owner)) { 1157 if (!try_module_get(client_ci->dev.driver->owner)) {
@@ -1988,8 +1988,8 @@ static int dvb_register(struct cx23885_tsport *port)
1988 break; 1988 break;
1989 case CX23885_BOARD_DVBSKY_T980C: 1989 case CX23885_BOARD_DVBSKY_T980C:
1990 case CX23885_BOARD_TT_CT2_4500_CI: 1990 case CX23885_BOARD_TT_CT2_4500_CI:
1991 i2c_bus = &dev->i2c_bus[1]; 1991 i2c_bus = &dev->i2c_bus[0];
1992 i2c_bus2 = &dev->i2c_bus[0]; 1992 i2c_bus2 = &dev->i2c_bus[1];
1993 1993
1994 /* attach frontend */ 1994 /* attach frontend */
1995 memset(&si2168_config, 0, sizeof(si2168_config)); 1995 memset(&si2168_config, 0, sizeof(si2168_config));
@@ -2001,7 +2001,7 @@ static int dvb_register(struct cx23885_tsport *port)
2001 info.addr = 0x64; 2001 info.addr = 0x64;
2002 info.platform_data = &si2168_config; 2002 info.platform_data = &si2168_config;
2003 request_module(info.type); 2003 request_module(info.type);
2004 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info); 2004 client_demod = i2c_new_device(&i2c_bus2->i2c_adap, &info);
2005 if (client_demod == NULL || client_demod->dev.driver == NULL) 2005 if (client_demod == NULL || client_demod->dev.driver == NULL)
2006 goto frontend_detach; 2006 goto frontend_detach;
2007 if (!try_module_get(client_demod->dev.driver->owner)) { 2007 if (!try_module_get(client_demod->dev.driver->owner)) {
@@ -2030,13 +2030,13 @@ static int dvb_register(struct cx23885_tsport *port)
2030 port->i2c_client_tuner = client_tuner; 2030 port->i2c_client_tuner = client_tuner;
2031 break; 2031 break;
2032 case CX23885_BOARD_DVBSKY_S950C: 2032 case CX23885_BOARD_DVBSKY_S950C:
2033 i2c_bus = &dev->i2c_bus[1]; 2033 i2c_bus = &dev->i2c_bus[0];
2034 i2c_bus2 = &dev->i2c_bus[0]; 2034 i2c_bus2 = &dev->i2c_bus[1];
2035 2035
2036 /* attach frontend */ 2036 /* attach frontend */
2037 fe0->dvb.frontend = dvb_attach(m88ds3103_attach, 2037 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
2038 &dvbsky_s950c_m88ds3103_config, 2038 &dvbsky_s950c_m88ds3103_config,
2039 &i2c_bus->i2c_adap, &adapter); 2039 &i2c_bus2->i2c_adap, &adapter);
2040 if (fe0->dvb.frontend == NULL) 2040 if (fe0->dvb.frontend == NULL)
2041 break; 2041 break;
2042 2042
@@ -2301,7 +2301,8 @@ static int dvb_register(struct cx23885_tsport *port)
2301 2301
2302 /* register everything */ 2302 /* register everything */
2303 ret = vb2_dvb_register_bus(&port->frontends, THIS_MODULE, port, 2303 ret = vb2_dvb_register_bus(&port->frontends, THIS_MODULE, port,
2304 &dev->pci->dev, adapter_nr, mfe_shared); 2304 &dev->pci->dev, NULL,
2305 adapter_nr, mfe_shared);
2305 if (ret) 2306 if (ret)
2306 goto frontend_detach; 2307 goto frontend_detach;
2307 2308
diff --git a/drivers/media/pci/cx88/cx88-dvb.c b/drivers/media/pci/cx88/cx88-dvb.c
index afb20756d7a5..851d2a9caed3 100644
--- a/drivers/media/pci/cx88/cx88-dvb.c
+++ b/drivers/media/pci/cx88/cx88-dvb.c
@@ -1642,7 +1642,8 @@ static int dvb_register(struct cx8802_dev *dev)
1642 1642
1643 /* register everything */ 1643 /* register everything */
1644 res = vb2_dvb_register_bus(&dev->frontends, THIS_MODULE, dev, 1644 res = vb2_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
1645 &dev->pci->dev, adapter_nr, mfe_shared); 1645 &dev->pci->dev, NULL, adapter_nr,
1646 mfe_shared);
1646 if (res) 1647 if (res)
1647 goto frontend_detach; 1648 goto frontend_detach;
1648 return res; 1649 return res;
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c
index 9d5b314142f1..6e995ef8c37e 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -690,7 +690,7 @@ static int tuner_attach_stv6110(struct ddb_input *input, int type)
690 struct stv090x_config *feconf = type ? &stv0900_aa : &stv0900; 690 struct stv090x_config *feconf = type ? &stv0900_aa : &stv0900;
691 struct stv6110x_config *tunerconf = (input->nr & 1) ? 691 struct stv6110x_config *tunerconf = (input->nr & 1) ?
692 &stv6110b : &stv6110a; 692 &stv6110b : &stv6110a;
693 struct stv6110x_devctl *ctl; 693 const struct stv6110x_devctl *ctl;
694 694
695 ctl = dvb_attach(stv6110x_attach, input->fe, tunerconf, i2c); 695 ctl = dvb_attach(stv6110x_attach, input->fe, tunerconf, i2c);
696 if (!ctl) { 696 if (!ctl) {
diff --git a/drivers/media/pci/ivtv/ivtv-queue.c b/drivers/media/pci/ivtv/ivtv-queue.c
index 7fde36e6d227..2128c2a8d7fd 100644
--- a/drivers/media/pci/ivtv/ivtv-queue.c
+++ b/drivers/media/pci/ivtv/ivtv-queue.c
@@ -141,7 +141,7 @@ int ivtv_queue_move(struct ivtv_stream *s, struct ivtv_queue *from, struct ivtv_
141 spin_unlock_irqrestore(&s->qlock, flags); 141 spin_unlock_irqrestore(&s->qlock, flags);
142 return -ENOMEM; 142 return -ENOMEM;
143 } 143 }
144 while (bytes_available < needed_bytes) { 144 while (steal && bytes_available < needed_bytes) {
145 struct ivtv_buffer *buf = list_entry(steal->list.prev, struct ivtv_buffer, list); 145 struct ivtv_buffer *buf = list_entry(steal->list.prev, struct ivtv_buffer, list);
146 u16 dma_xfer_cnt = buf->dma_xfer_cnt; 146 u16 dma_xfer_cnt = buf->dma_xfer_cnt;
147 147
diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
index 525ebfefeee8..2b667b315913 100644
--- a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
+++ b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
@@ -462,8 +462,8 @@ static int netup_unidvb_dvb_init(struct netup_unidvb_dev *ndev,
462 } 462 }
463 463
464 if (vb2_dvb_register_bus(&ndev->frontends[num], 464 if (vb2_dvb_register_bus(&ndev->frontends[num],
465 THIS_MODULE, NULL, 465 THIS_MODULE, NULL,
466 &ndev->pci_dev->dev, adapter_nr, 1)) { 466 &ndev->pci_dev->dev, NULL, adapter_nr, 1)) {
467 dev_dbg(&ndev->pci_dev->dev, 467 dev_dbg(&ndev->pci_dev->dev,
468 "%s(): unable to register DVB bus %d\n", 468 "%s(): unable to register DVB bus %d\n",
469 __func__, num); 469 __func__, num);
@@ -771,10 +771,9 @@ static int netup_unidvb_initdev(struct pci_dev *pci_dev,
771 771
772 /* allocate device context */ 772 /* allocate device context */
773 ndev = kzalloc(sizeof(*ndev), GFP_KERNEL); 773 ndev = kzalloc(sizeof(*ndev), GFP_KERNEL);
774
775 if (!ndev) 774 if (!ndev)
776 goto dev_alloc_err; 775 goto dev_alloc_err;
777 memset(ndev, 0, sizeof(*ndev)); 776
778 ndev->old_fw = old_firmware; 777 ndev->old_fw = old_firmware;
779 ndev->wq = create_singlethread_workqueue(NETUP_UNIDVB_NAME); 778 ndev->wq = create_singlethread_workqueue(NETUP_UNIDVB_NAME);
780 if (!ndev->wq) { 779 if (!ndev->wq) {
diff --git a/drivers/media/pci/ngene/ngene-cards.c b/drivers/media/pci/ngene/ngene-cards.c
index 039bed3cc919..4e783a68bf4a 100644
--- a/drivers/media/pci/ngene/ngene-cards.c
+++ b/drivers/media/pci/ngene/ngene-cards.c
@@ -57,7 +57,7 @@ static int tuner_attach_stv6110(struct ngene_channel *chan)
57 chan->dev->card_info->fe_config[chan->number]; 57 chan->dev->card_info->fe_config[chan->number];
58 struct stv6110x_config *tunerconf = (struct stv6110x_config *) 58 struct stv6110x_config *tunerconf = (struct stv6110x_config *)
59 chan->dev->card_info->tuner_config[chan->number]; 59 chan->dev->card_info->tuner_config[chan->number];
60 struct stv6110x_devctl *ctl; 60 const struct stv6110x_devctl *ctl;
61 61
62 /* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */ 62 /* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */
63 if (chan->number < 2) 63 if (chan->number < 2)
diff --git a/drivers/media/pci/pt3/pt3.c b/drivers/media/pci/pt3/pt3.c
index 0d2e2b217121..eff5e9f51ace 100644
--- a/drivers/media/pci/pt3/pt3.c
+++ b/drivers/media/pci/pt3/pt3.c
@@ -395,7 +395,8 @@ static int pt3_attach_fe(struct pt3_board *pt3, int i)
395 if (!try_module_get(cl->dev.driver->owner)) 395 if (!try_module_get(cl->dev.driver->owner))
396 goto err_demod_i2c_unregister_device; 396 goto err_demod_i2c_unregister_device;
397 397
398 if (!strncmp(cl->name, TC90522_I2C_DEV_SAT, sizeof(cl->name))) { 398 if (!strncmp(cl->name, TC90522_I2C_DEV_SAT,
399 strlen(TC90522_I2C_DEV_SAT))) {
399 struct qm1d1c0042_config tcfg; 400 struct qm1d1c0042_config tcfg;
400 401
401 tcfg = adap_conf[i].tuner_cfg.qm1d1c0042; 402 tcfg = adap_conf[i].tuner_cfg.qm1d1c0042;
diff --git a/drivers/media/pci/saa7134/saa7134-cards.c b/drivers/media/pci/saa7134/saa7134-cards.c
index 29d2094c42a0..c480a7e87593 100644
--- a/drivers/media/pci/saa7134/saa7134-cards.c
+++ b/drivers/media/pci/saa7134/saa7134-cards.c
@@ -36,17 +36,23 @@
36#include "xc5000.h" 36#include "xc5000.h"
37#include "s5h1411.h" 37#include "s5h1411.h"
38 38
39/* commly used strings */ 39/* Input names */
40static char name_mute[] = "mute"; 40const char * const saa7134_input_name[] = {
41static char name_radio[] = "Radio"; 41 [SAA7134_INPUT_MUTE] = "mute",
42static char name_tv[] = "Television"; 42 [SAA7134_INPUT_RADIO] = "Radio",
43static char name_tv_mono[] = "TV (mono only)"; 43 [SAA7134_INPUT_TV] = "Television",
44static char name_comp[] = "Composite"; 44 [SAA7134_INPUT_TV_MONO] = "TV (mono only)",
45static char name_comp1[] = "Composite1"; 45 [SAA7134_INPUT_COMPOSITE] = "Composite",
46static char name_comp2[] = "Composite2"; 46 [SAA7134_INPUT_COMPOSITE0] = "Composite0",
47static char name_comp3[] = "Composite3"; 47 [SAA7134_INPUT_COMPOSITE1] = "Composite1",
48static char name_comp4[] = "Composite4"; 48 [SAA7134_INPUT_COMPOSITE2] = "Composite2",
49static char name_svideo[] = "S-Video"; 49 [SAA7134_INPUT_COMPOSITE3] = "Composite3",
50 [SAA7134_INPUT_COMPOSITE4] = "Composite4",
51 [SAA7134_INPUT_SVIDEO] = "S-Video",
52 [SAA7134_INPUT_SVIDEO0] = "S-Video0",
53 [SAA7134_INPUT_SVIDEO1] = "S-Video1",
54 [SAA7134_INPUT_COMPOSITE_OVER_SVIDEO] = "Composite over S-Video",
55};
50 56
51/* ------------------------------------------------------------------ */ 57/* ------------------------------------------------------------------ */
52/* board config info */ 58/* board config info */
@@ -69,7 +75,7 @@ struct saa7134_board saa7134_boards[] = {
69 .radio_addr = ADDR_UNSET, 75 .radio_addr = ADDR_UNSET,
70 76
71 .inputs = {{ 77 .inputs = {{
72 .name = "default", 78 .type = SAA7134_INPUT_COMPOSITE,
73 .vmux = 0, 79 .vmux = 0,
74 .amux = LINE1, 80 .amux = LINE1,
75 }}, 81 }},
@@ -84,22 +90,20 @@ struct saa7134_board saa7134_boards[] = {
84 .radio_addr = ADDR_UNSET, 90 .radio_addr = ADDR_UNSET,
85 91
86 .inputs = {{ 92 .inputs = {{
87 .name = name_comp1, 93 .type = SAA7134_INPUT_COMPOSITE1,
88 .vmux = 0, 94 .vmux = 0,
89 .amux = LINE1, 95 .amux = LINE1,
90 },{ 96 },{
91 .name = name_tv, 97 .type = SAA7134_INPUT_TV,
92 .vmux = 1, 98 .vmux = 1,
93 .amux = TV, 99 .amux = TV,
94 .tv = 1,
95 },{ 100 },{
96 .name = name_tv_mono, 101 .type = SAA7134_INPUT_TV_MONO,
97 .vmux = 1, 102 .vmux = 1,
98 .amux = LINE2, 103 .amux = LINE2,
99 .tv = 1,
100 }}, 104 }},
101 .radio = { 105 .radio = {
102 .name = name_radio, 106 .type = SAA7134_INPUT_RADIO,
103 .amux = LINE2, 107 .amux = LINE2,
104 }, 108 },
105 }, 109 },
@@ -114,40 +118,38 @@ struct saa7134_board saa7134_boards[] = {
114 118
115 .gpiomask = 0xe000, 119 .gpiomask = 0xe000,
116 .inputs = {{ 120 .inputs = {{
117 .name = name_tv, 121 .type = SAA7134_INPUT_TV,
118 .vmux = 1, 122 .vmux = 1,
119 .amux = TV, 123 .amux = TV,
120 .gpio = 0x8000, 124 .gpio = 0x8000,
121 .tv = 1,
122 },{ 125 },{
123 .name = name_tv_mono, 126 .type = SAA7134_INPUT_TV_MONO,
124 .vmux = 1, 127 .vmux = 1,
125 .amux = LINE2, 128 .amux = LINE2,
126 .gpio = 0x0000, 129 .gpio = 0x0000,
127 .tv = 1,
128 },{ 130 },{
129 .name = name_comp1, 131 .type = SAA7134_INPUT_COMPOSITE1,
130 .vmux = 0, 132 .vmux = 0,
131 .amux = LINE2, 133 .amux = LINE2,
132 .gpio = 0x4000, 134 .gpio = 0x4000,
133 },{ 135 },{
134 .name = name_comp2, 136 .type = SAA7134_INPUT_COMPOSITE2,
135 .vmux = 3, 137 .vmux = 3,
136 .amux = LINE2, 138 .amux = LINE2,
137 .gpio = 0x4000, 139 .gpio = 0x4000,
138 },{ 140 },{
139 .name = name_svideo, 141 .type = SAA7134_INPUT_SVIDEO,
140 .vmux = 8, 142 .vmux = 8,
141 .amux = LINE2, 143 .amux = LINE2,
142 .gpio = 0x4000, 144 .gpio = 0x4000,
143 }}, 145 }},
144 .radio = { 146 .radio = {
145 .name = name_radio, 147 .type = SAA7134_INPUT_RADIO,
146 .amux = LINE2, 148 .amux = LINE2,
147 .gpio = 0x2000, 149 .gpio = 0x2000,
148 }, 150 },
149 .mute = { 151 .mute = {
150 .name = name_mute, 152 .type = SAA7134_INPUT_MUTE,
151 .amux = TV, 153 .amux = TV,
152 .gpio = 0x8000, 154 .gpio = 0x8000,
153 }, 155 },
@@ -163,34 +165,33 @@ struct saa7134_board saa7134_boards[] = {
163 165
164 .gpiomask = 0xe000, 166 .gpiomask = 0xe000,
165 .inputs = {{ 167 .inputs = {{
166 .name = name_tv, 168 .type = SAA7134_INPUT_TV,
167 .vmux = 1, 169 .vmux = 1,
168 .amux = LINE2, 170 .amux = LINE2,
169 .gpio = 0x0000, 171 .gpio = 0x0000,
170 .tv = 1,
171 },{ 172 },{
172 .name = name_comp1, 173 .type = SAA7134_INPUT_COMPOSITE1,
173 .vmux = 0, 174 .vmux = 0,
174 .amux = LINE2, 175 .amux = LINE2,
175 .gpio = 0x4000, 176 .gpio = 0x4000,
176 },{ 177 },{
177 .name = name_comp2, 178 .type = SAA7134_INPUT_COMPOSITE2,
178 .vmux = 3, 179 .vmux = 3,
179 .amux = LINE2, 180 .amux = LINE2,
180 .gpio = 0x4000, 181 .gpio = 0x4000,
181 },{ 182 },{
182 .name = name_svideo, 183 .type = SAA7134_INPUT_SVIDEO,
183 .vmux = 8, 184 .vmux = 8,
184 .amux = LINE2, 185 .amux = LINE2,
185 .gpio = 0x4000, 186 .gpio = 0x4000,
186 }}, 187 }},
187 .radio = { 188 .radio = {
188 .name = name_radio, 189 .type = SAA7134_INPUT_RADIO,
189 .amux = LINE2, 190 .amux = LINE2,
190 .gpio = 0x2000, 191 .gpio = 0x2000,
191 }, 192 },
192 .mute = { 193 .mute = {
193 .name = name_mute, 194 .type = SAA7134_INPUT_MUTE,
194 .amux = LINE2, 195 .amux = LINE2,
195 .gpio = 0x8000, 196 .gpio = 0x8000,
196 }, 197 },
@@ -205,20 +206,19 @@ struct saa7134_board saa7134_boards[] = {
205 .radio_addr = ADDR_UNSET, 206 .radio_addr = ADDR_UNSET,
206 207
207 .inputs = {{ 208 .inputs = {{
208 .name = name_tv, 209 .type = SAA7134_INPUT_TV,
209 .vmux = 1, 210 .vmux = 1,
210 .amux = TV, 211 .amux = TV,
211 .tv = 1,
212 },{ 212 },{
213 .name = name_comp1, /* Composite signal on S-Video input */ 213 .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
214 .vmux = 0, 214 .vmux = 0,
215 .amux = LINE2, 215 .amux = LINE2,
216 },{ 216 },{
217 .name = name_comp2, /* Composite input */ 217 .type = SAA7134_INPUT_COMPOSITE,
218 .vmux = 3, 218 .vmux = 3,
219 .amux = LINE2, 219 .amux = LINE2,
220 },{ 220 },{
221 .name = name_svideo, 221 .type = SAA7134_INPUT_SVIDEO,
222 .vmux = 8, 222 .vmux = 8,
223 .amux = LINE2, 223 .amux = LINE2,
224 }}, 224 }},
@@ -235,40 +235,38 @@ struct saa7134_board saa7134_boards[] = {
235 235
236 .gpiomask = 0x1E000, /* Set GP16 and unused 15,14,13 to Output */ 236 .gpiomask = 0x1E000, /* Set GP16 and unused 15,14,13 to Output */
237 .inputs = {{ 237 .inputs = {{
238 .name = name_tv, 238 .type = SAA7134_INPUT_TV,
239 .vmux = 1, 239 .vmux = 1,
240 .amux = TV, 240 .amux = TV,
241 .gpio = 0x10000, /* GP16=1 selects TV input */ 241 .gpio = 0x10000, /* GP16=1 selects TV input */
242 .tv = 1,
243 },{ 242 },{
244/* .name = name_tv_mono, 243/* .type = SAA7134_INPUT_TV_MONO,
245 .vmux = 1, 244 .vmux = 1,
246 .amux = LINE2, 245 .amux = LINE2,
247 .gpio = 0x0000, 246 .gpio = 0x0000,
248 .tv = 1,
249 },{ 247 },{
250*/ .name = name_comp1, /* Composite signal on S-Video input */ 248*/ .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
251 .vmux = 0, 249 .vmux = 0,
252 .amux = LINE2, 250 .amux = LINE2,
253/* .gpio = 0x4000, */ 251/* .gpio = 0x4000, */
254 },{ 252 },{
255 .name = name_comp2, /* Composite input */ 253 .type = SAA7134_INPUT_COMPOSITE,
256 .vmux = 3, 254 .vmux = 3,
257 .amux = LINE2, 255 .amux = LINE2,
258/* .gpio = 0x4000, */ 256/* .gpio = 0x4000, */
259 },{ 257 },{
260 .name = name_svideo, /* S-Video signal on S-Video input */ 258 .type = SAA7134_INPUT_SVIDEO,
261 .vmux = 8, 259 .vmux = 8,
262 .amux = LINE2, 260 .amux = LINE2,
263/* .gpio = 0x4000, */ 261/* .gpio = 0x4000, */
264 }}, 262 }},
265 .radio = { 263 .radio = {
266 .name = name_radio, 264 .type = SAA7134_INPUT_RADIO,
267 .amux = TV, 265 .amux = TV,
268 .gpio = 0x00000, /* GP16=0 selects FM radio antenna */ 266 .gpio = 0x00000, /* GP16=0 selects FM radio antenna */
269 }, 267 },
270 .mute = { 268 .mute = {
271 .name = name_mute, 269 .type = SAA7134_INPUT_MUTE,
272 .amux = TV, 270 .amux = TV,
273 .gpio = 0x10000, 271 .gpio = 0x10000,
274 }, 272 },
@@ -285,40 +283,38 @@ struct saa7134_board saa7134_boards[] = {
285 .tda9887_conf = TDA9887_PRESENT, 283 .tda9887_conf = TDA9887_PRESENT,
286 .gpiomask = 0xe000, 284 .gpiomask = 0xe000,
287 .inputs = { { 285 .inputs = { {
288 .name = name_tv, 286 .type = SAA7134_INPUT_TV,
289 .vmux = 1, 287 .vmux = 1,
290 .amux = TV, 288 .amux = TV,
291 .gpio = 0x8000, 289 .gpio = 0x8000,
292 .tv = 1,
293 }, { 290 }, {
294 .name = name_tv_mono, 291 .type = SAA7134_INPUT_TV_MONO,
295 .vmux = 1, 292 .vmux = 1,
296 .amux = LINE2, 293 .amux = LINE2,
297 .gpio = 0x0000, 294 .gpio = 0x0000,
298 .tv = 1,
299 }, { 295 }, {
300 .name = name_comp1, 296 .type = SAA7134_INPUT_COMPOSITE1,
301 .vmux = 0, 297 .vmux = 0,
302 .amux = LINE2, 298 .amux = LINE2,
303 .gpio = 0x4000, 299 .gpio = 0x4000,
304 }, { 300 }, {
305 .name = name_comp2, 301 .type = SAA7134_INPUT_COMPOSITE2,
306 .vmux = 3, 302 .vmux = 3,
307 .amux = LINE2, 303 .amux = LINE2,
308 .gpio = 0x4000, 304 .gpio = 0x4000,
309 }, { 305 }, {
310 .name = name_svideo, 306 .type = SAA7134_INPUT_SVIDEO,
311 .vmux = 8, 307 .vmux = 8,
312 .amux = LINE2, 308 .amux = LINE2,
313 .gpio = 0x4000, 309 .gpio = 0x4000,
314 } }, 310 } },
315 .radio = { 311 .radio = {
316 .name = name_radio, 312 .type = SAA7134_INPUT_RADIO,
317 .amux = LINE2, 313 .amux = LINE2,
318 .gpio = 0x2000, 314 .gpio = 0x2000,
319 }, 315 },
320 .mute = { 316 .mute = {
321 .name = name_mute, 317 .type = SAA7134_INPUT_MUTE,
322 .amux = TV, 318 .amux = TV,
323 .gpio = 0x8000, 319 .gpio = 0x8000,
324 }, 320 },
@@ -334,21 +330,20 @@ struct saa7134_board saa7134_boards[] = {
334 .empress_addr = 0x20, 330 .empress_addr = 0x20,
335 331
336 .inputs = {{ 332 .inputs = {{
337 .name = name_comp1, 333 .type = SAA7134_INPUT_COMPOSITE1,
338 .vmux = 0, 334 .vmux = 0,
339 .amux = LINE1, 335 .amux = LINE1,
340 },{ 336 },{
341 .name = name_svideo, 337 .type = SAA7134_INPUT_SVIDEO,
342 .vmux = 8, 338 .vmux = 8,
343 .amux = LINE1, 339 .amux = LINE1,
344 },{ 340 },{
345 .name = name_tv, 341 .type = SAA7134_INPUT_TV,
346 .vmux = 1, 342 .vmux = 1,
347 .amux = LINE2, 343 .amux = LINE2,
348 .tv = 1,
349 }}, 344 }},
350 .radio = { 345 .radio = {
351 .name = name_radio, 346 .type = SAA7134_INPUT_RADIO,
352 .amux = LINE2, 347 .amux = LINE2,
353 }, 348 },
354 .mpeg = SAA7134_MPEG_EMPRESS, 349 .mpeg = SAA7134_MPEG_EMPRESS,
@@ -364,21 +359,20 @@ struct saa7134_board saa7134_boards[] = {
364 .radio_addr = ADDR_UNSET, 359 .radio_addr = ADDR_UNSET,
365 360
366 .inputs = {{ 361 .inputs = {{
367 .name = name_tv, 362 .type = SAA7134_INPUT_TV,
368 .vmux = 1, 363 .vmux = 1,
369 .amux = TV, 364 .amux = TV,
370 .tv = 1,
371 },{ 365 },{
372 .name = name_comp1, 366 .type = SAA7134_INPUT_COMPOSITE1,
373 .vmux = 0, 367 .vmux = 0,
374 .amux = LINE1, 368 .amux = LINE1,
375 },{ 369 },{
376 .name = name_svideo, 370 .type = SAA7134_INPUT_SVIDEO,
377 .vmux = 8, 371 .vmux = 8,
378 .amux = LINE1, 372 .amux = LINE1,
379 }}, 373 }},
380 .radio = { 374 .radio = {
381 .name = name_radio, 375 .type = SAA7134_INPUT_RADIO,
382 .amux = LINE2, 376 .amux = LINE2,
383 }, 377 },
384 }, 378 },
@@ -390,35 +384,33 @@ struct saa7134_board saa7134_boards[] = {
390 .tuner_addr = ADDR_UNSET, 384 .tuner_addr = ADDR_UNSET,
391 .radio_addr = ADDR_UNSET, 385 .radio_addr = ADDR_UNSET,
392 .inputs = {{ 386 .inputs = {{
393 .name = name_tv, 387 .type = SAA7134_INPUT_TV,
394 .vmux = 1, 388 .vmux = 1,
395 .amux = TV, 389 .amux = TV,
396 .tv = 1,
397 },{ 390 },{
398 /* workaround for problems with normal TV sound */ 391 /* workaround for problems with normal TV sound */
399 .name = name_tv_mono, 392 .type = SAA7134_INPUT_TV_MONO,
400 .vmux = 1, 393 .vmux = 1,
401 .amux = LINE2, 394 .amux = LINE2,
402 .tv = 1,
403 },{ 395 },{
404 .name = name_comp1, 396 .type = SAA7134_INPUT_COMPOSITE1,
405 .vmux = 0, 397 .vmux = 0,
406 .amux = LINE1, 398 .amux = LINE1,
407 },{ 399 },{
408 .name = name_comp2, 400 .type = SAA7134_INPUT_COMPOSITE2,
409 .vmux = 3, 401 .vmux = 3,
410 .amux = LINE1, 402 .amux = LINE1,
411 },{ 403 },{
412 .name = name_svideo, 404 .type = SAA7134_INPUT_SVIDEO,
413 .vmux = 8, 405 .vmux = 8,
414 .amux = LINE1, 406 .amux = LINE1,
415 }}, 407 }},
416 .radio = { 408 .radio = {
417 .name = name_radio, 409 .type = SAA7134_INPUT_RADIO,
418 .amux = LINE2, 410 .amux = LINE2,
419 }, 411 },
420 .mute = { 412 .mute = {
421 .name = name_mute, 413 .type = SAA7134_INPUT_MUTE,
422 .amux = TV, 414 .amux = TV,
423 }, 415 },
424 }, 416 },
@@ -432,32 +424,30 @@ struct saa7134_board saa7134_boards[] = {
432 .radio_addr = ADDR_UNSET, 424 .radio_addr = ADDR_UNSET,
433 .tda9887_conf = TDA9887_PRESENT, 425 .tda9887_conf = TDA9887_PRESENT,
434 .inputs = {{ 426 .inputs = {{
435 .name = name_tv, 427 .type = SAA7134_INPUT_TV,
436 .vmux = 1, 428 .vmux = 1,
437 .amux = TV, 429 .amux = TV,
438 .tv = 1,
439 },{ 430 },{
440 .name = name_tv_mono, 431 .type = SAA7134_INPUT_TV_MONO,
441 .vmux = 1, 432 .vmux = 1,
442 .amux = LINE2, 433 .amux = LINE2,
443 .tv = 1,
444 },{ 434 },{
445 435
446 .name = name_svideo, 436 .type = SAA7134_INPUT_SVIDEO,
447 .vmux = 8, 437 .vmux = 8,
448 .amux = LINE1, 438 .amux = LINE1,
449 },{ 439 },{
450 .name = name_comp1, 440 .type = SAA7134_INPUT_COMPOSITE1,
451 .vmux = 3, 441 .vmux = 3,
452 .amux = LINE1, 442 .amux = LINE1,
453 },{ 443 },{
454 444
455 .name = "CVid over SVid", 445 .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
456 .vmux = 0, 446 .vmux = 0,
457 .amux = LINE1, 447 .amux = LINE1,
458 }}, 448 }},
459 .radio = { 449 .radio = {
460 .name = name_radio, 450 .type = SAA7134_INPUT_RADIO,
461 .amux = LINE2, 451 .amux = LINE2,
462 }, 452 },
463 }, 453 },
@@ -472,24 +462,23 @@ struct saa7134_board saa7134_boards[] = {
472 .tda9887_conf = TDA9887_PRESENT, 462 .tda9887_conf = TDA9887_PRESENT,
473 .gpiomask = 0x820000, 463 .gpiomask = 0x820000,
474 .inputs = {{ 464 .inputs = {{
475 .name = name_tv, 465 .type = SAA7134_INPUT_TV,
476 .vmux = 1, 466 .vmux = 1,
477 .amux = TV, 467 .amux = TV,
478 .tv = 1,
479 .gpio = 0x20000, 468 .gpio = 0x20000,
480 },{ 469 },{
481 .name = name_svideo, 470 .type = SAA7134_INPUT_SVIDEO,
482 .vmux = 8, 471 .vmux = 8,
483 .amux = LINE1, 472 .amux = LINE1,
484 .gpio = 0x20000, 473 .gpio = 0x20000,
485 },{ 474 },{
486 .name = name_comp1, 475 .type = SAA7134_INPUT_COMPOSITE1,
487 .vmux = 3, 476 .vmux = 3,
488 .amux = LINE1, 477 .amux = LINE1,
489 .gpio = 0x20000, 478 .gpio = 0x20000,
490 }}, 479 }},
491 .radio = { 480 .radio = {
492 .name = name_radio, 481 .type = SAA7134_INPUT_RADIO,
493 .amux = LINE2, 482 .amux = LINE2,
494 .gpio = 0x20000, 483 .gpio = 0x20000,
495 }, 484 },
@@ -504,20 +493,19 @@ struct saa7134_board saa7134_boards[] = {
504 .tuner_addr = ADDR_UNSET, 493 .tuner_addr = ADDR_UNSET,
505 .radio_addr = ADDR_UNSET, 494 .radio_addr = ADDR_UNSET,
506 .inputs = {{ 495 .inputs = {{
507 .name = name_tv, 496 .type = SAA7134_INPUT_TV,
508 .vmux = 1, 497 .vmux = 1,
509 .amux = TV, 498 .amux = TV,
510 .tv = 1,
511 },{ 499 },{
512 .name = name_comp1, 500 .type = SAA7134_INPUT_COMPOSITE,
513 .vmux = 4, 501 .vmux = 4,
514 .amux = LINE1, 502 .amux = LINE1,
515 },{ 503 },{
516 .name = name_svideo, 504 .type = SAA7134_INPUT_SVIDEO,
517 .vmux = 8, 505 .vmux = 8,
518 .amux = LINE1, 506 .amux = LINE1,
519 },{ 507 },{
520 .name = name_comp2, /* CVideo over SVideo Connector */ 508 .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
521 .vmux = 0, 509 .vmux = 0,
522 .amux = LINE1, 510 .amux = LINE1,
523 }} 511 }}
@@ -531,31 +519,29 @@ struct saa7134_board saa7134_boards[] = {
531 .radio_addr = ADDR_UNSET, 519 .radio_addr = ADDR_UNSET,
532 .tda9887_conf = TDA9887_PRESENT, 520 .tda9887_conf = TDA9887_PRESENT,
533 .inputs = {{ 521 .inputs = {{
534 .name = name_tv, 522 .type = SAA7134_INPUT_TV,
535 .vmux = 1, 523 .vmux = 1,
536 .amux = TV, 524 .amux = TV,
537 .tv = 1,
538 },{ 525 },{
539 /* workaround for problems with normal TV sound */ 526 /* workaround for problems with normal TV sound */
540 .name = name_tv_mono, 527 .type = SAA7134_INPUT_TV_MONO,
541 .vmux = 1, 528 .vmux = 1,
542 .amux = LINE2, 529 .amux = LINE2,
543 .tv = 1,
544 },{ 530 },{
545 .name = name_comp1, 531 .type = SAA7134_INPUT_COMPOSITE1,
546 .vmux = 0, 532 .vmux = 0,
547 .amux = LINE2, 533 .amux = LINE2,
548 },{ 534 },{
549 .name = name_comp2, 535 .type = SAA7134_INPUT_COMPOSITE2,
550 .vmux = 3, 536 .vmux = 3,
551 .amux = LINE2, 537 .amux = LINE2,
552 },{ 538 },{
553 .name = name_svideo, 539 .type = SAA7134_INPUT_SVIDEO,
554 .vmux = 8, 540 .vmux = 8,
555 .amux = LINE2, 541 .amux = LINE2,
556 }}, 542 }},
557 .radio = { 543 .radio = {
558 .name = name_radio, 544 .type = SAA7134_INPUT_RADIO,
559 .amux = LINE2, 545 .amux = LINE2,
560 }, 546 },
561 }, 547 },
@@ -567,18 +553,17 @@ struct saa7134_board saa7134_boards[] = {
567 .tuner_addr = ADDR_UNSET, 553 .tuner_addr = ADDR_UNSET,
568 .radio_addr = ADDR_UNSET, 554 .radio_addr = ADDR_UNSET,
569 .inputs = {{ 555 .inputs = {{
570 .name = name_svideo, 556 .type = SAA7134_INPUT_SVIDEO,
571 .vmux = 8, 557 .vmux = 8,
572 .amux = LINE1, 558 .amux = LINE1,
573 },{ 559 },{
574 .name = name_comp1, 560 .type = SAA7134_INPUT_COMPOSITE1,
575 .vmux = 3, 561 .vmux = 3,
576 .amux = LINE1, 562 .amux = LINE1,
577 },{ 563 },{
578 .name = name_tv, 564 .type = SAA7134_INPUT_TV,
579 .vmux = 1, 565 .vmux = 1,
580 .amux = LINE2, 566 .amux = LINE2,
581 .tv = 1,
582 }}, 567 }},
583 }, 568 },
584 [SAA7134_BOARD_CINERGY600] = { 569 [SAA7134_BOARD_CINERGY600] = {
@@ -590,25 +575,24 @@ struct saa7134_board saa7134_boards[] = {
590 .radio_addr = ADDR_UNSET, 575 .radio_addr = ADDR_UNSET,
591 .tda9887_conf = TDA9887_PRESENT, 576 .tda9887_conf = TDA9887_PRESENT,
592 .inputs = {{ 577 .inputs = {{
593 .name = name_tv, 578 .type = SAA7134_INPUT_TV,
594 .vmux = 1, 579 .vmux = 1,
595 .amux = TV, 580 .amux = TV,
596 .tv = 1,
597 },{ 581 },{
598 .name = name_comp1, 582 .type = SAA7134_INPUT_COMPOSITE1,
599 .vmux = 4, 583 .vmux = 4,
600 .amux = LINE1, 584 .amux = LINE1,
601 },{ 585 },{
602 .name = name_svideo, 586 .type = SAA7134_INPUT_SVIDEO,
603 .vmux = 8, 587 .vmux = 8,
604 .amux = LINE1, 588 .amux = LINE1,
605 },{ 589 },{
606 .name = name_comp2, /* CVideo over SVideo Connector */ 590 .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
607 .vmux = 0, 591 .vmux = 0,
608 .amux = LINE1, 592 .amux = LINE1,
609 }}, 593 }},
610 .radio = { 594 .radio = {
611 .name = name_radio, 595 .type = SAA7134_INPUT_RADIO,
612 .amux = LINE2, 596 .amux = LINE2,
613 }, 597 },
614 }, 598 },
@@ -622,25 +606,24 @@ struct saa7134_board saa7134_boards[] = {
622 .tda9887_conf = TDA9887_PRESENT, 606 .tda9887_conf = TDA9887_PRESENT,
623 .mpeg = SAA7134_MPEG_DVB, 607 .mpeg = SAA7134_MPEG_DVB,
624 .inputs = {{ 608 .inputs = {{
625 .name = name_tv, 609 .type = SAA7134_INPUT_TV,
626 .vmux = 1, 610 .vmux = 1,
627 .amux = TV, 611 .amux = TV,
628 .tv = 1,
629 },{ 612 },{
630 .name = name_comp1, 613 .type = SAA7134_INPUT_COMPOSITE1,
631 .vmux = 0, 614 .vmux = 0,
632 .amux = LINE1, 615 .amux = LINE1,
633 },{ 616 },{
634 .name = name_svideo, 617 .type = SAA7134_INPUT_SVIDEO,
635 .vmux = 8, 618 .vmux = 8,
636 .amux = LINE1, 619 .amux = LINE1,
637 }}, 620 }},
638 .radio = { 621 .radio = {
639 .name = name_radio, 622 .type = SAA7134_INPUT_RADIO,
640 .amux = LINE2, 623 .amux = LINE2,
641 }, 624 },
642 .mute = { 625 .mute = {
643 .name = name_mute, 626 .type = SAA7134_INPUT_MUTE,
644 .amux = TV, 627 .amux = TV,
645 }, 628 },
646 }, 629 },
@@ -655,21 +638,20 @@ struct saa7134_board saa7134_boards[] = {
655 .radio_addr = ADDR_UNSET, 638 .radio_addr = ADDR_UNSET,
656 .tda9887_conf = TDA9887_PRESENT, 639 .tda9887_conf = TDA9887_PRESENT,
657 .inputs = {{ 640 .inputs = {{
658 .name = name_tv, 641 .type = SAA7134_INPUT_TV,
659 .vmux = 1, 642 .vmux = 1,
660 .amux = TV, 643 .amux = TV,
661 .tv = 1,
662 },{ 644 },{
663 .name = name_comp1, 645 .type = SAA7134_INPUT_COMPOSITE1,
664 .vmux = 3, 646 .vmux = 3,
665 .amux = LINE1, 647 .amux = LINE1,
666 },{ 648 },{
667 .name = name_svideo, 649 .type = SAA7134_INPUT_SVIDEO,
668 .vmux = 8, 650 .vmux = 8,
669 .amux = LINE1, 651 .amux = LINE1,
670 }}, 652 }},
671 .radio = { 653 .radio = {
672 .name = name_radio, 654 .type = SAA7134_INPUT_RADIO,
673 .amux = LINE2, 655 .amux = LINE2,
674 }, 656 },
675 }, 657 },
@@ -681,18 +663,17 @@ struct saa7134_board saa7134_boards[] = {
681 .tuner_addr = ADDR_UNSET, 663 .tuner_addr = ADDR_UNSET,
682 .radio_addr = ADDR_UNSET, 664 .radio_addr = ADDR_UNSET,
683 .inputs = {{ 665 .inputs = {{
684 .name = name_svideo, 666 .type = SAA7134_INPUT_SVIDEO,
685 .vmux = 8, 667 .vmux = 8,
686 .amux = LINE1, 668 .amux = LINE1,
687 },{ 669 },{
688 .name = name_comp1, 670 .type = SAA7134_INPUT_COMPOSITE1,
689 .vmux = 0, 671 .vmux = 0,
690 .amux = LINE1, 672 .amux = LINE1,
691 },{ 673 },{
692 .name = name_tv, 674 .type = SAA7134_INPUT_TV,
693 .vmux = 4, 675 .vmux = 4,
694 .amux = LINE2, 676 .amux = LINE2,
695 .tv = 1,
696 }}, 677 }},
697 }, 678 },
698 [SAA7134_BOARD_ELSA_500TV] = { 679 [SAA7134_BOARD_ELSA_500TV] = {
@@ -703,19 +684,17 @@ struct saa7134_board saa7134_boards[] = {
703 .tuner_addr = ADDR_UNSET, 684 .tuner_addr = ADDR_UNSET,
704 .radio_addr = ADDR_UNSET, 685 .radio_addr = ADDR_UNSET,
705 .inputs = {{ 686 .inputs = {{
706 .name = name_svideo, 687 .type = SAA7134_INPUT_SVIDEO,
707 .vmux = 7, 688 .vmux = 7,
708 .amux = LINE1, 689 .amux = LINE1,
709 },{ 690 },{
710 .name = name_tv, 691 .type = SAA7134_INPUT_TV,
711 .vmux = 8, 692 .vmux = 8,
712 .amux = TV, 693 .amux = TV,
713 .tv = 1,
714 },{ 694 },{
715 .name = name_tv_mono, 695 .type = SAA7134_INPUT_TV_MONO,
716 .vmux = 8, 696 .vmux = 8,
717 .amux = LINE2, 697 .amux = LINE2,
718 .tv = 1,
719 }}, 698 }},
720 }, 699 },
721 [SAA7134_BOARD_ELSA_700TV] = { 700 [SAA7134_BOARD_ELSA_700TV] = {
@@ -726,21 +705,20 @@ struct saa7134_board saa7134_boards[] = {
726 .tuner_addr = ADDR_UNSET, 705 .tuner_addr = ADDR_UNSET,
727 .radio_addr = ADDR_UNSET, 706 .radio_addr = ADDR_UNSET,
728 .inputs = {{ 707 .inputs = {{
729 .name = name_tv, 708 .type = SAA7134_INPUT_TV,
730 .vmux = 4, 709 .vmux = 4,
731 .amux = LINE2, 710 .amux = LINE2,
732 .tv = 1,
733 },{ 711 },{
734 .name = name_comp1, 712 .type = SAA7134_INPUT_COMPOSITE1,
735 .vmux = 6, 713 .vmux = 6,
736 .amux = LINE1, 714 .amux = LINE1,
737 },{ 715 },{
738 .name = name_svideo, 716 .type = SAA7134_INPUT_SVIDEO,
739 .vmux = 7, 717 .vmux = 7,
740 .amux = LINE1, 718 .amux = LINE1,
741 }}, 719 }},
742 .mute = { 720 .mute = {
743 .name = name_mute, 721 .type = SAA7134_INPUT_MUTE,
744 .amux = TV, 722 .amux = TV,
745 }, 723 },
746 }, 724 },
@@ -753,21 +731,20 @@ struct saa7134_board saa7134_boards[] = {
753 .radio_addr = ADDR_UNSET, 731 .radio_addr = ADDR_UNSET,
754 .tda9887_conf = TDA9887_PRESENT, 732 .tda9887_conf = TDA9887_PRESENT,
755 .inputs = {{ 733 .inputs = {{
756 .name = name_tv, 734 .type = SAA7134_INPUT_TV,
757 .vmux = 1, 735 .vmux = 1,
758 .amux = TV, 736 .amux = TV,
759 .tv = 1,
760 },{ 737 },{
761 .name = name_comp1, 738 .type = SAA7134_INPUT_COMPOSITE1,
762 .vmux = 4, 739 .vmux = 4,
763 .amux = LINE2, 740 .amux = LINE2,
764 },{ 741 },{
765 .name = name_svideo, 742 .type = SAA7134_INPUT_SVIDEO,
766 .vmux = 6, 743 .vmux = 6,
767 .amux = LINE2, 744 .amux = LINE2,
768 }}, 745 }},
769 .radio = { 746 .radio = {
770 .name = name_radio, 747 .type = SAA7134_INPUT_RADIO,
771 .amux = LINE1, 748 .amux = LINE1,
772 }, 749 },
773 }, 750 },
@@ -780,29 +757,28 @@ struct saa7134_board saa7134_boards[] = {
780 .radio_addr = ADDR_UNSET, 757 .radio_addr = ADDR_UNSET,
781 .gpiomask = 0x200000, 758 .gpiomask = 0x200000,
782 .inputs = {{ 759 .inputs = {{
783 .name = name_tv, 760 .type = SAA7134_INPUT_TV,
784 .vmux = 1, 761 .vmux = 1,
785 .amux = TV, 762 .amux = TV,
786 .gpio = 0x0000, 763 .gpio = 0x0000,
787 .tv = 1,
788 },{ 764 },{
789 .name = name_comp1, 765 .type = SAA7134_INPUT_COMPOSITE1,
790 .vmux = 4, 766 .vmux = 4,
791 .amux = LINE2, 767 .amux = LINE2,
792 .gpio = 0x0000, 768 .gpio = 0x0000,
793 },{ 769 },{
794 .name = name_svideo, 770 .type = SAA7134_INPUT_SVIDEO,
795 .vmux = 6, 771 .vmux = 6,
796 .amux = LINE2, 772 .amux = LINE2,
797 .gpio = 0x0000, 773 .gpio = 0x0000,
798 }}, 774 }},
799 .radio = { 775 .radio = {
800 .name = name_radio, 776 .type = SAA7134_INPUT_RADIO,
801 .amux = TV, 777 .amux = TV,
802 .gpio = 0x200000, 778 .gpio = 0x200000,
803 }, 779 },
804 .mute = { 780 .mute = {
805 .name = name_mute, 781 .type = SAA7134_INPUT_MUTE,
806 .gpio = 0x0000, 782 .gpio = 0x0000,
807 }, 783 },
808 784
@@ -815,18 +791,17 @@ struct saa7134_board saa7134_boards[] = {
815 .tuner_addr = ADDR_UNSET, 791 .tuner_addr = ADDR_UNSET,
816 .radio_addr = ADDR_UNSET, 792 .radio_addr = ADDR_UNSET,
817 .inputs = {{ 793 .inputs = {{
818 .name = name_svideo, 794 .type = SAA7134_INPUT_SVIDEO,
819 .vmux = 8, 795 .vmux = 8,
820 .amux = LINE1, 796 .amux = LINE1,
821 },{ 797 },{
822 .name = name_comp1, 798 .type = SAA7134_INPUT_COMPOSITE1,
823 .vmux = 3, 799 .vmux = 3,
824 .amux = LINE1, 800 .amux = LINE1,
825 },{ 801 },{
826 .name = name_tv, 802 .type = SAA7134_INPUT_TV,
827 .vmux = 1, 803 .vmux = 1,
828 .amux = LINE2, 804 .amux = LINE2,
829 .tv = 1,
830 }}, 805 }},
831 }, 806 },
832 [SAA7134_BOARD_10MOONSTVMASTER] = { 807 [SAA7134_BOARD_10MOONSTVMASTER] = {
@@ -839,34 +814,33 @@ struct saa7134_board saa7134_boards[] = {
839 .radio_addr = ADDR_UNSET, 814 .radio_addr = ADDR_UNSET,
840 .gpiomask = 0xe000, 815 .gpiomask = 0xe000,
841 .inputs = {{ 816 .inputs = {{
842 .name = name_tv, 817 .type = SAA7134_INPUT_TV,
843 .vmux = 1, 818 .vmux = 1,
844 .amux = LINE2, 819 .amux = LINE2,
845 .gpio = 0x0000, 820 .gpio = 0x0000,
846 .tv = 1,
847 },{ 821 },{
848 .name = name_comp1, 822 .type = SAA7134_INPUT_COMPOSITE1,
849 .vmux = 0, 823 .vmux = 0,
850 .amux = LINE2, 824 .amux = LINE2,
851 .gpio = 0x4000, 825 .gpio = 0x4000,
852 },{ 826 },{
853 .name = name_comp2, 827 .type = SAA7134_INPUT_COMPOSITE2,
854 .vmux = 3, 828 .vmux = 3,
855 .amux = LINE2, 829 .amux = LINE2,
856 .gpio = 0x4000, 830 .gpio = 0x4000,
857 },{ 831 },{
858 .name = name_svideo, 832 .type = SAA7134_INPUT_SVIDEO,
859 .vmux = 8, 833 .vmux = 8,
860 .amux = LINE2, 834 .amux = LINE2,
861 .gpio = 0x4000, 835 .gpio = 0x4000,
862 }}, 836 }},
863 .radio = { 837 .radio = {
864 .name = name_radio, 838 .type = SAA7134_INPUT_RADIO,
865 .amux = LINE2, 839 .amux = LINE2,
866 .gpio = 0x2000, 840 .gpio = 0x2000,
867 }, 841 },
868 .mute = { 842 .mute = {
869 .name = name_mute, 843 .type = SAA7134_INPUT_MUTE,
870 .amux = LINE2, 844 .amux = LINE2,
871 .gpio = 0x8000, 845 .gpio = 0x8000,
872 }, 846 },
@@ -881,23 +855,23 @@ struct saa7134_board saa7134_boards[] = {
881 .radio_addr = ADDR_UNSET, 855 .radio_addr = ADDR_UNSET,
882 .empress_addr = 0x20, 856 .empress_addr = 0x20,
883 .inputs = {{ 857 .inputs = {{
884 .name = name_comp1, 858 .type = SAA7134_INPUT_COMPOSITE1,
885 .vmux = 4, 859 .vmux = 4,
886 .amux = LINE1, 860 .amux = LINE1,
887 },{ 861 },{
888 .name = name_comp2, 862 .type = SAA7134_INPUT_COMPOSITE2,
889 .vmux = 3, 863 .vmux = 3,
890 .amux = LINE1, 864 .amux = LINE1,
891 },{ 865 },{
892 .name = name_comp3, 866 .type = SAA7134_INPUT_COMPOSITE3,
893 .vmux = 0, 867 .vmux = 0,
894 .amux = LINE1, 868 .amux = LINE1,
895 },{ 869 },{
896 .name = name_comp4, 870 .type = SAA7134_INPUT_COMPOSITE4,
897 .vmux = 1, 871 .vmux = 1,
898 .amux = LINE1, 872 .amux = LINE1,
899 },{ 873 },{
900 .name = name_svideo, 874 .type = SAA7134_INPUT_SVIDEO,
901 .vmux = 8, 875 .vmux = 8,
902 .amux = LINE1, 876 .amux = LINE1,
903 }}, 877 }},
@@ -912,18 +886,17 @@ struct saa7134_board saa7134_boards[] = {
912 .tuner_addr = ADDR_UNSET, 886 .tuner_addr = ADDR_UNSET,
913 .radio_addr = ADDR_UNSET, 887 .radio_addr = ADDR_UNSET,
914 .inputs = {{ 888 .inputs = {{
915 .name = name_svideo, 889 .type = SAA7134_INPUT_SVIDEO,
916 .vmux = 8, 890 .vmux = 8,
917 .amux = LINE1, 891 .amux = LINE1,
918 },{ 892 },{
919 .name = name_comp1, 893 .type = SAA7134_INPUT_COMPOSITE1,
920 .vmux = 3, 894 .vmux = 3,
921 .amux = LINE1, 895 .amux = LINE1,
922 },{ 896 },{
923 .name = name_tv, 897 .type = SAA7134_INPUT_TV,
924 .vmux = 1, 898 .vmux = 1,
925 .amux = LINE2, 899 .amux = LINE2,
926 .tv = 1,
927 }}, 900 }},
928 }, 901 },
929 [SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUS] = { 902 [SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUS] = {
@@ -935,21 +908,20 @@ struct saa7134_board saa7134_boards[] = {
935 .tuner_addr = ADDR_UNSET, 908 .tuner_addr = ADDR_UNSET,
936 .radio_addr = ADDR_UNSET, 909 .radio_addr = ADDR_UNSET,
937 .inputs = {{ 910 .inputs = {{
938 .name = name_svideo, 911 .type = SAA7134_INPUT_SVIDEO,
939 .vmux = 8, 912 .vmux = 8,
940 .amux = LINE1, 913 .amux = LINE1,
941 .gpio = 0x06c00012, 914 .gpio = 0x06c00012,
942 },{ 915 },{
943 .name = name_comp1, 916 .type = SAA7134_INPUT_COMPOSITE1,
944 .vmux = 3, 917 .vmux = 3,
945 .amux = LINE1, 918 .amux = LINE1,
946 .gpio = 0x0ac20012, 919 .gpio = 0x0ac20012,
947 },{ 920 },{
948 .name = name_tv, 921 .type = SAA7134_INPUT_TV,
949 .vmux = 1, 922 .vmux = 1,
950 .amux = LINE2, 923 .amux = LINE2,
951 .gpio = 0x08c20012, 924 .gpio = 0x08c20012,
952 .tv = 1,
953 }}, /* radio and probably mute is missing */ 925 }}, /* radio and probably mute is missing */
954 }, 926 },
955 [SAA7134_BOARD_CRONOS_PLUS] = { 927 [SAA7134_BOARD_CRONOS_PLUS] = {
@@ -968,23 +940,23 @@ struct saa7134_board saa7134_boards[] = {
968 .radio_addr = ADDR_UNSET, 940 .radio_addr = ADDR_UNSET,
969 .gpiomask = 0xcf00, 941 .gpiomask = 0xcf00,
970 .inputs = {{ 942 .inputs = {{
971 .name = name_comp1, 943 .type = SAA7134_INPUT_COMPOSITE1,
972 .vmux = 0, 944 .vmux = 0,
973 .gpio = 2 << 14, 945 .gpio = 2 << 14,
974 },{ 946 },{
975 .name = name_comp2, 947 .type = SAA7134_INPUT_COMPOSITE2,
976 .vmux = 0, 948 .vmux = 0,
977 .gpio = 1 << 14, 949 .gpio = 1 << 14,
978 },{ 950 },{
979 .name = name_comp3, 951 .type = SAA7134_INPUT_COMPOSITE3,
980 .vmux = 0, 952 .vmux = 0,
981 .gpio = 0 << 14, 953 .gpio = 0 << 14,
982 },{ 954 },{
983 .name = name_comp4, 955 .type = SAA7134_INPUT_COMPOSITE4,
984 .vmux = 0, 956 .vmux = 0,
985 .gpio = 3 << 14, 957 .gpio = 3 << 14,
986 },{ 958 },{
987 .name = name_svideo, 959 .type = SAA7134_INPUT_SVIDEO,
988 .vmux = 8, 960 .vmux = 8,
989 .gpio = 2 << 14, 961 .gpio = 2 << 14,
990 }}, 962 }},
@@ -999,34 +971,33 @@ struct saa7134_board saa7134_boards[] = {
999 .tda9887_conf = TDA9887_PRESENT, 971 .tda9887_conf = TDA9887_PRESENT,
1000 .gpiomask = 0x03, 972 .gpiomask = 0x03,
1001 .inputs = {{ 973 .inputs = {{
1002 .name = name_tv, 974 .type = SAA7134_INPUT_TV,
1003 .vmux = 1, 975 .vmux = 1,
1004 .amux = TV, 976 .amux = TV,
1005 .tv = 1,
1006 .gpio = 0x00, 977 .gpio = 0x00,
1007 }, { 978 }, {
1008 .name = name_comp1, 979 .type = SAA7134_INPUT_COMPOSITE1,
1009 .vmux = 3, 980 .vmux = 3,
1010 .amux = LINE1, 981 .amux = LINE1,
1011 .gpio = 0x02, 982 .gpio = 0x02,
1012 }, { 983 }, {
1013 .name = name_comp2, 984 .type = SAA7134_INPUT_COMPOSITE2,
1014 .vmux = 0, 985 .vmux = 0,
1015 .amux = LINE1, 986 .amux = LINE1,
1016 .gpio = 0x02, 987 .gpio = 0x02,
1017 }, { 988 }, {
1018 .name = name_svideo, 989 .type = SAA7134_INPUT_SVIDEO,
1019 .vmux = 8, 990 .vmux = 8,
1020 .amux = LINE1, 991 .amux = LINE1,
1021 .gpio = 0x02, 992 .gpio = 0x02,
1022 } }, 993 } },
1023 .radio = { 994 .radio = {
1024 .name = name_radio, 995 .type = SAA7134_INPUT_RADIO,
1025 .amux = LINE1, 996 .amux = LINE1,
1026 .gpio = 0x01, 997 .gpio = 0x01,
1027 }, 998 },
1028 .mute = { 999 .mute = {
1029 .name = name_mute, 1000 .type = SAA7134_INPUT_MUTE,
1030 .amux = TV, 1001 .amux = TV,
1031 .gpio = 0x00, 1002 .gpio = 0x00,
1032 }, 1003 },
@@ -1041,18 +1012,17 @@ struct saa7134_board saa7134_boards[] = {
1041 .radio_addr = ADDR_UNSET, 1012 .radio_addr = ADDR_UNSET,
1042 .empress_addr = 0x20, 1013 .empress_addr = 0x20,
1043 .inputs = {{ 1014 .inputs = {{
1044 .name = name_comp1, 1015 .type = SAA7134_INPUT_COMPOSITE1,
1045 .vmux = 1, 1016 .vmux = 1,
1046 .amux = LINE1, 1017 .amux = LINE1,
1047 },{ 1018 },{
1048 .name = name_svideo, 1019 .type = SAA7134_INPUT_SVIDEO,
1049 .vmux = 8, 1020 .vmux = 8,
1050 .amux = LINE1, 1021 .amux = LINE1,
1051 },{ 1022 },{
1052 .name = name_tv, 1023 .type = SAA7134_INPUT_TV,
1053 .vmux = 3, 1024 .vmux = 3,
1054 .amux = TV, 1025 .amux = TV,
1055 .tv = 1,
1056 }}, 1026 }},
1057 .mpeg = SAA7134_MPEG_EMPRESS, 1027 .mpeg = SAA7134_MPEG_EMPRESS,
1058 .video_out = CCIR656, 1028 .video_out = CCIR656,
@@ -1068,22 +1038,21 @@ struct saa7134_board saa7134_boards[] = {
1068 .radio_addr = ADDR_UNSET, 1038 .radio_addr = ADDR_UNSET,
1069 .tda9887_conf = TDA9887_PRESENT, 1039 .tda9887_conf = TDA9887_PRESENT,
1070 .inputs = {{ 1040 .inputs = {{
1071 .name = name_tv, 1041 .type = SAA7134_INPUT_TV,
1072 .vmux = 1, 1042 .vmux = 1,
1073 .amux = TV, 1043 .amux = TV,
1074 .tv = 1,
1075 1044
1076 },{ 1045 },{
1077 .name = name_comp1, 1046 .type = SAA7134_INPUT_COMPOSITE1,
1078 .vmux = 4, 1047 .vmux = 4,
1079 .amux = LINE2, 1048 .amux = LINE2,
1080 },{ 1049 },{
1081 .name = name_svideo, 1050 .type = SAA7134_INPUT_SVIDEO,
1082 .vmux = 6, 1051 .vmux = 6,
1083 .amux = LINE2, 1052 .amux = LINE2,
1084 }}, 1053 }},
1085 .radio = { 1054 .radio = {
1086 .name = name_radio, 1055 .type = SAA7134_INPUT_RADIO,
1087 .amux = LINE1, 1056 .amux = LINE1,
1088 }, 1057 },
1089 }, 1058 },
@@ -1096,20 +1065,19 @@ struct saa7134_board saa7134_boards[] = {
1096 .radio_addr = ADDR_UNSET, 1065 .radio_addr = ADDR_UNSET,
1097 .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER | TDA9887_PORT2_INACTIVE, 1066 .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER | TDA9887_PORT2_INACTIVE,
1098 .inputs = {{ 1067 .inputs = {{
1099 .name = name_tv, 1068 .type = SAA7134_INPUT_TV,
1100 .vmux = 3, 1069 .vmux = 3,
1101 .amux = TV, 1070 .amux = TV,
1102 .tv = 1,
1103 },{ 1071 },{
1104 .name = name_comp1, 1072 .type = SAA7134_INPUT_COMPOSITE1,
1105 .vmux = 0, 1073 .vmux = 0,
1106 .amux = LINE2, 1074 .amux = LINE2,
1107 },{ 1075 },{
1108 .name = name_comp2, 1076 .type = SAA7134_INPUT_COMPOSITE2,
1109 .vmux = 1, 1077 .vmux = 1,
1110 .amux = LINE2, 1078 .amux = LINE2,
1111 },{ 1079 },{
1112 .name = name_svideo, 1080 .type = SAA7134_INPUT_SVIDEO,
1113 .vmux = 8, 1081 .vmux = 8,
1114 .amux = LINE2, 1082 .amux = LINE2,
1115 }}, 1083 }},
@@ -1123,21 +1091,20 @@ struct saa7134_board saa7134_boards[] = {
1123 .tuner_addr = ADDR_UNSET, 1091 .tuner_addr = ADDR_UNSET,
1124 .radio_addr = ADDR_UNSET, 1092 .radio_addr = ADDR_UNSET,
1125 .inputs = {{ 1093 .inputs = {{
1126 .name = name_svideo, 1094 .type = SAA7134_INPUT_SVIDEO,
1127 .vmux = 8, 1095 .vmux = 8,
1128 .amux = LINE1, 1096 .amux = LINE1,
1129 },{ 1097 },{
1130 .name = name_comp1, 1098 .type = SAA7134_INPUT_COMPOSITE1,
1131 .vmux = 1, 1099 .vmux = 1,
1132 .amux = LINE1, 1100 .amux = LINE1,
1133 },{ 1101 },{
1134 .name = name_tv, 1102 .type = SAA7134_INPUT_TV,
1135 .vmux = 3, 1103 .vmux = 3,
1136 .amux = LINE2, 1104 .amux = LINE2,
1137 .tv = 1,
1138 }}, 1105 }},
1139 .radio = { 1106 .radio = {
1140 .name = name_radio, 1107 .type = SAA7134_INPUT_RADIO,
1141 .amux = LINE2, 1108 .amux = LINE2,
1142 }, 1109 },
1143 }, 1110 },
@@ -1150,21 +1117,20 @@ struct saa7134_board saa7134_boards[] = {
1150 .tuner_addr = ADDR_UNSET, 1117 .tuner_addr = ADDR_UNSET,
1151 .radio_addr = ADDR_UNSET, 1118 .radio_addr = ADDR_UNSET,
1152 .inputs = {{ 1119 .inputs = {{
1153 .name = name_svideo, 1120 .type = SAA7134_INPUT_SVIDEO,
1154 .vmux = 8, 1121 .vmux = 8,
1155 .amux = LINE1, 1122 .amux = LINE1,
1156 },{ 1123 },{
1157 .name = name_comp1, 1124 .type = SAA7134_INPUT_COMPOSITE1,
1158 .vmux = 1, 1125 .vmux = 1,
1159 .amux = LINE1, 1126 .amux = LINE1,
1160 },{ 1127 },{
1161 .name = name_tv, 1128 .type = SAA7134_INPUT_TV,
1162 .vmux = 3, 1129 .vmux = 3,
1163 .amux = LINE2, 1130 .amux = LINE2,
1164 .tv = 1,
1165 }}, 1131 }},
1166 .mute = { 1132 .mute = {
1167 .name = name_mute, 1133 .type = SAA7134_INPUT_MUTE,
1168 .amux = LINE1, 1134 .amux = LINE1,
1169 }, 1135 },
1170 }, 1136 },
@@ -1177,16 +1143,15 @@ struct saa7134_board saa7134_boards[] = {
1177 .tuner_addr = ADDR_UNSET, 1143 .tuner_addr = ADDR_UNSET,
1178 .radio_addr = ADDR_UNSET, 1144 .radio_addr = ADDR_UNSET,
1179 .inputs = {{ 1145 .inputs = {{
1180 .name = name_tv, 1146 .type = SAA7134_INPUT_TV,
1181 .vmux = 1, 1147 .vmux = 1,
1182 .amux = LINE2, 1148 .amux = LINE2,
1183 .tv = 1,
1184 },{ 1149 },{
1185 .name = name_comp1, 1150 .type = SAA7134_INPUT_COMPOSITE1,
1186 .vmux = 3, 1151 .vmux = 3,
1187 .amux = LINE2, 1152 .amux = LINE2,
1188 },{ 1153 },{
1189 .name = name_svideo, 1154 .type = SAA7134_INPUT_SVIDEO,
1190 .vmux = 8, 1155 .vmux = 8,
1191 .amux = LINE2, 1156 .amux = LINE2,
1192 }}, 1157 }},
@@ -1199,30 +1164,28 @@ struct saa7134_board saa7134_boards[] = {
1199 .tuner_addr = ADDR_UNSET, 1164 .tuner_addr = ADDR_UNSET,
1200 .radio_addr = ADDR_UNSET, 1165 .radio_addr = ADDR_UNSET,
1201 .inputs = {{ 1166 .inputs = {{
1202 .name = name_tv, 1167 .type = SAA7134_INPUT_TV,
1203 .vmux = 1, 1168 .vmux = 1,
1204 .amux = TV, 1169 .amux = TV,
1205 .tv = 1,
1206 },{ 1170 },{
1207 .name = name_tv_mono, 1171 .type = SAA7134_INPUT_TV_MONO,
1208 .vmux = 1, 1172 .vmux = 1,
1209 .amux = LINE2, 1173 .amux = LINE2,
1210 .tv = 1,
1211 },{ 1174 },{
1212 .name = name_comp1, 1175 .type = SAA7134_INPUT_COMPOSITE1,
1213 .vmux = 3, 1176 .vmux = 3,
1214 .amux = LINE1, 1177 .amux = LINE1,
1215 },{ 1178 },{
1216 .name = name_svideo, 1179 .type = SAA7134_INPUT_SVIDEO,
1217 .vmux = 8, 1180 .vmux = 8,
1218 .amux = LINE1, 1181 .amux = LINE1,
1219 },{ 1182 },{
1220 .name = "CVid over SVid", 1183 .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
1221 .vmux = 0, 1184 .vmux = 0,
1222 .amux = LINE1, 1185 .amux = LINE1,
1223 }}, 1186 }},
1224 .radio = { 1187 .radio = {
1225 .name = name_radio, 1188 .type = SAA7134_INPUT_RADIO,
1226 .amux = LINE2, 1189 .amux = LINE2,
1227 }, 1190 },
1228 }, 1191 },
@@ -1234,30 +1197,28 @@ struct saa7134_board saa7134_boards[] = {
1234 .tuner_addr = ADDR_UNSET, 1197 .tuner_addr = ADDR_UNSET,
1235 .radio_addr = ADDR_UNSET, 1198 .radio_addr = ADDR_UNSET,
1236 .inputs = {{ 1199 .inputs = {{
1237 .name = name_tv, 1200 .type = SAA7134_INPUT_TV,
1238 .vmux = 1, 1201 .vmux = 1,
1239 .amux = TV, 1202 .amux = TV,
1240 .tv = 1,
1241 },{ 1203 },{
1242 .name = name_tv_mono, 1204 .type = SAA7134_INPUT_TV_MONO,
1243 .vmux = 1, 1205 .vmux = 1,
1244 .amux = LINE2, 1206 .amux = LINE2,
1245 .tv = 1,
1246 },{ 1207 },{
1247 .name = name_comp1, 1208 .type = SAA7134_INPUT_COMPOSITE1,
1248 .vmux = 3, 1209 .vmux = 3,
1249 .amux = LINE1, 1210 .amux = LINE1,
1250 },{ 1211 },{
1251 .name = name_svideo, 1212 .type = SAA7134_INPUT_SVIDEO,
1252 .vmux = 8, 1213 .vmux = 8,
1253 .amux = LINE1, 1214 .amux = LINE1,
1254 },{ 1215 },{
1255 .name = "CVid over SVid", 1216 .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
1256 .vmux = 0, 1217 .vmux = 0,
1257 .amux = LINE1, 1218 .amux = LINE1,
1258 }}, 1219 }},
1259 .radio = { 1220 .radio = {
1260 .name = name_radio, 1221 .type = SAA7134_INPUT_RADIO,
1261 .amux = LINE2, 1222 .amux = LINE2,
1262 }, 1223 },
1263 }, 1224 },
@@ -1270,30 +1231,28 @@ struct saa7134_board saa7134_boards[] = {
1270 .tuner_addr = ADDR_UNSET, 1231 .tuner_addr = ADDR_UNSET,
1271 .radio_addr = ADDR_UNSET, 1232 .radio_addr = ADDR_UNSET,
1272 .inputs = {{ 1233 .inputs = {{
1273 .name = name_tv, 1234 .type = SAA7134_INPUT_TV,
1274 .vmux = 1, 1235 .vmux = 1,
1275 .amux = TV, 1236 .amux = TV,
1276 .tv = 1,
1277 },{ 1237 },{
1278 .name = name_tv_mono, 1238 .type = SAA7134_INPUT_TV_MONO,
1279 .vmux = 1, 1239 .vmux = 1,
1280 .amux = LINE2, 1240 .amux = LINE2,
1281 .tv = 1,
1282 },{ 1241 },{
1283 .name = name_comp1, 1242 .type = SAA7134_INPUT_COMPOSITE1,
1284 .vmux = 3, 1243 .vmux = 3,
1285 .amux = LINE1, 1244 .amux = LINE1,
1286 },{ 1245 },{
1287 .name = name_svideo, 1246 .type = SAA7134_INPUT_SVIDEO,
1288 .vmux = 8, 1247 .vmux = 8,
1289 .amux = LINE1, 1248 .amux = LINE1,
1290 },{ 1249 },{
1291 .name = "CVid over SVid", 1250 .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
1292 .vmux = 0, 1251 .vmux = 0,
1293 .amux = LINE1, 1252 .amux = LINE1,
1294 }}, 1253 }},
1295 .radio = { 1254 .radio = {
1296 .name = name_radio, 1255 .type = SAA7134_INPUT_RADIO,
1297 .amux = LINE2, 1256 .amux = LINE2,
1298 }, 1257 },
1299 }, 1258 },
@@ -1306,30 +1265,28 @@ struct saa7134_board saa7134_boards[] = {
1306 .tuner_addr = ADDR_UNSET, 1265 .tuner_addr = ADDR_UNSET,
1307 .radio_addr = ADDR_UNSET, 1266 .radio_addr = ADDR_UNSET,
1308 .inputs = {{ 1267 .inputs = {{
1309 .name = name_tv, 1268 .type = SAA7134_INPUT_TV,
1310 .vmux = 1, 1269 .vmux = 1,
1311 .amux = TV, 1270 .amux = TV,
1312 .tv = 1,
1313 },{ 1271 },{
1314 .name = name_tv_mono, 1272 .type = SAA7134_INPUT_TV_MONO,
1315 .vmux = 1, 1273 .vmux = 1,
1316 .amux = LINE2, 1274 .amux = LINE2,
1317 .tv = 1,
1318 },{ 1275 },{
1319 .name = name_comp1, 1276 .type = SAA7134_INPUT_COMPOSITE1,
1320 .vmux = 0, 1277 .vmux = 0,
1321 .amux = LINE2, 1278 .amux = LINE2,
1322 },{ 1279 },{
1323 .name = name_comp2, 1280 .type = SAA7134_INPUT_COMPOSITE2,
1324 .vmux = 3, 1281 .vmux = 3,
1325 .amux = LINE2, 1282 .amux = LINE2,
1326 },{ 1283 },{
1327 .name = name_svideo, 1284 .type = SAA7134_INPUT_SVIDEO,
1328 .vmux = 8, 1285 .vmux = 8,
1329 .amux = LINE2, 1286 .amux = LINE2,
1330 }}, 1287 }},
1331 .radio = { 1288 .radio = {
1332 .name = name_radio, 1289 .type = SAA7134_INPUT_RADIO,
1333 .amux = LINE2, 1290 .amux = LINE2,
1334 .gpio = 0x200000, 1291 .gpio = 0x200000,
1335 }, 1292 },
@@ -1343,10 +1300,10 @@ struct saa7134_board saa7134_boards[] = {
1343 .tuner_addr = ADDR_UNSET, 1300 .tuner_addr = ADDR_UNSET,
1344 .radio_addr = ADDR_UNSET, 1301 .radio_addr = ADDR_UNSET,
1345 .inputs = {{ 1302 .inputs = {{
1346 .name = name_comp1, 1303 .type = SAA7134_INPUT_COMPOSITE1,
1347 .vmux = 3, 1304 .vmux = 3,
1348 },{ 1305 },{
1349 .name = name_svideo, 1306 .type = SAA7134_INPUT_SVIDEO,
1350 .vmux = 8, 1307 .vmux = 8,
1351 }}, 1308 }},
1352 }, 1309 },
@@ -1360,10 +1317,9 @@ struct saa7134_board saa7134_boards[] = {
1360 .radio_addr = ADDR_UNSET, 1317 .radio_addr = ADDR_UNSET,
1361 .mpeg = SAA7134_MPEG_DVB, 1318 .mpeg = SAA7134_MPEG_DVB,
1362 .inputs = {{ 1319 .inputs = {{
1363 .name = name_tv, 1320 .type = SAA7134_INPUT_TV,
1364 .vmux = 1, 1321 .vmux = 1,
1365 .amux = TV, 1322 .amux = TV,
1366 .tv = 1,
1367 } }, 1323 } },
1368 }, 1324 },
1369 [SAA7134_BOARD_NOVAC_PRIMETV7133] = { 1325 [SAA7134_BOARD_NOVAC_PRIMETV7133] = {
@@ -1375,15 +1331,14 @@ struct saa7134_board saa7134_boards[] = {
1375 .tuner_addr = ADDR_UNSET, 1331 .tuner_addr = ADDR_UNSET,
1376 .radio_addr = ADDR_UNSET, 1332 .radio_addr = ADDR_UNSET,
1377 .inputs = {{ 1333 .inputs = {{
1378 .name = name_comp1, 1334 .type = SAA7134_INPUT_COMPOSITE1,
1379 .vmux = 3, 1335 .vmux = 3,
1380 },{ 1336 },{
1381 .name = name_tv, 1337 .type = SAA7134_INPUT_TV,
1382 .vmux = 1, 1338 .vmux = 1,
1383 .amux = TV, 1339 .amux = TV,
1384 .tv = 1,
1385 },{ 1340 },{
1386 .name = name_svideo, 1341 .type = SAA7134_INPUT_SVIDEO,
1387 .vmux = 8, 1342 .vmux = 8,
1388 }}, 1343 }},
1389 }, 1344 },
@@ -1396,29 +1351,28 @@ struct saa7134_board saa7134_boards[] = {
1396 .radio_addr = ADDR_UNSET, 1351 .radio_addr = ADDR_UNSET,
1397 .tda9887_conf = TDA9887_PRESENT, 1352 .tda9887_conf = TDA9887_PRESENT,
1398 .inputs = {{ 1353 .inputs = {{
1399 .name = name_tv, 1354 .type = SAA7134_INPUT_TV,
1400 .vmux = 1, 1355 .vmux = 1,
1401 .amux = LINE2, 1356 .amux = LINE2,
1402 .tv = 1,
1403 },{ 1357 },{
1404 .name = name_comp1, 1358 .type = SAA7134_INPUT_COMPOSITE1,
1405 .vmux = 0, 1359 .vmux = 0,
1406 .amux = LINE2, 1360 .amux = LINE2,
1407 },{ 1361 },{
1408 .name = name_comp2, 1362 .type = SAA7134_INPUT_COMPOSITE2,
1409 .vmux = 3, 1363 .vmux = 3,
1410 .amux = LINE2, 1364 .amux = LINE2,
1411 },{ 1365 },{
1412 .name = name_svideo, 1366 .type = SAA7134_INPUT_SVIDEO,
1413 .vmux = 8, 1367 .vmux = 8,
1414 .amux = LINE2, 1368 .amux = LINE2,
1415 }}, 1369 }},
1416 .radio = { 1370 .radio = {
1417 .name = name_radio, 1371 .type = SAA7134_INPUT_RADIO,
1418 .amux = LINE2, 1372 .amux = LINE2,
1419 }, 1373 },
1420 .mute = { 1374 .mute = {
1421 .name = name_mute, 1375 .type = SAA7134_INPUT_MUTE,
1422 .amux = LINE1, 1376 .amux = LINE1,
1423 }, 1377 },
1424 }, 1378 },
@@ -1432,29 +1386,28 @@ struct saa7134_board saa7134_boards[] = {
1432 .radio_addr = ADDR_UNSET, 1386 .radio_addr = ADDR_UNSET,
1433 .tda9887_conf = TDA9887_PRESENT, 1387 .tda9887_conf = TDA9887_PRESENT,
1434 .inputs = { { 1388 .inputs = { {
1435 .name = name_tv, 1389 .type = SAA7134_INPUT_TV,
1436 .vmux = 1, 1390 .vmux = 1,
1437 .amux = LINE2, 1391 .amux = LINE2,
1438 .tv = 1,
1439 }, { 1392 }, {
1440 .name = name_comp1, 1393 .type = SAA7134_INPUT_COMPOSITE1,
1441 .vmux = 0, 1394 .vmux = 0,
1442 .amux = LINE2, 1395 .amux = LINE2,
1443 }, { 1396 }, {
1444 .name = name_comp2, 1397 .type = SAA7134_INPUT_COMPOSITE2,
1445 .vmux = 3, 1398 .vmux = 3,
1446 .amux = LINE2, 1399 .amux = LINE2,
1447 },{ 1400 },{
1448 .name = name_svideo, 1401 .type = SAA7134_INPUT_SVIDEO,
1449 .vmux = 8, 1402 .vmux = 8,
1450 .amux = LINE2, 1403 .amux = LINE2,
1451 } }, 1404 } },
1452 .radio = { 1405 .radio = {
1453 .name = name_radio, 1406 .type = SAA7134_INPUT_RADIO,
1454 .amux = LINE2, 1407 .amux = LINE2,
1455 }, 1408 },
1456 .mute = { 1409 .mute = {
1457 .name = name_mute, 1410 .type = SAA7134_INPUT_MUTE,
1458 .amux = LINE1, 1411 .amux = LINE1,
1459 }, 1412 },
1460 }, 1413 },
@@ -1467,12 +1420,11 @@ struct saa7134_board saa7134_boards[] = {
1467 .radio_addr = ADDR_UNSET, 1420 .radio_addr = ADDR_UNSET,
1468 .tda9887_conf = TDA9887_PRESENT, 1421 .tda9887_conf = TDA9887_PRESENT,
1469 .inputs = {{ 1422 .inputs = {{
1470 .name = name_tv, 1423 .type = SAA7134_INPUT_TV,
1471 .vmux = 7, 1424 .vmux = 7,
1472 .amux = TV, 1425 .amux = TV,
1473 .tv = 1,
1474 },{ 1426 },{
1475 .name = name_svideo, 1427 .type = SAA7134_INPUT_SVIDEO,
1476 .vmux = 7, 1428 .vmux = 7,
1477 .amux = LINE1, 1429 .amux = LINE1,
1478 }}, 1430 }},
@@ -1486,21 +1438,20 @@ struct saa7134_board saa7134_boards[] = {
1486 .tuner_addr = ADDR_UNSET, 1438 .tuner_addr = ADDR_UNSET,
1487 .radio_addr = ADDR_UNSET, 1439 .radio_addr = ADDR_UNSET,
1488 .inputs = {{ 1440 .inputs = {{
1489 .name = name_tv, 1441 .type = SAA7134_INPUT_TV,
1490 .vmux = 3, 1442 .vmux = 3,
1491 .amux = TV, 1443 .amux = TV,
1492 .tv = 1,
1493 },{ 1444 },{
1494 .name = name_comp1, 1445 .type = SAA7134_INPUT_COMPOSITE1,
1495 .vmux = 1, 1446 .vmux = 1,
1496 .amux = LINE1, 1447 .amux = LINE1,
1497 },{ 1448 },{
1498 .name = name_svideo, 1449 .type = SAA7134_INPUT_SVIDEO,
1499 .vmux = 8, 1450 .vmux = 8,
1500 .amux = LINE1, 1451 .amux = LINE1,
1501 }}, 1452 }},
1502 .radio = { 1453 .radio = {
1503 .name = name_radio, 1454 .type = SAA7134_INPUT_RADIO,
1504 .amux = LINE2, 1455 .amux = LINE2,
1505 }, 1456 },
1506 }, 1457 },
@@ -1512,25 +1463,24 @@ struct saa7134_board saa7134_boards[] = {
1512 .tuner_addr = ADDR_UNSET, 1463 .tuner_addr = ADDR_UNSET,
1513 .radio_addr = ADDR_UNSET, 1464 .radio_addr = ADDR_UNSET,
1514 .inputs = {{ 1465 .inputs = {{
1515 .name = name_tv, 1466 .type = SAA7134_INPUT_TV,
1516 .vmux = 1, 1467 .vmux = 1,
1517 .amux = LINE2, 1468 .amux = LINE2,
1518 .tv = 1,
1519 },{ 1469 },{
1520 .name = name_comp1, 1470 .type = SAA7134_INPUT_COMPOSITE1,
1521 .vmux = 4, 1471 .vmux = 4,
1522 .amux = LINE1, 1472 .amux = LINE1,
1523 },{ 1473 },{
1524 .name = name_svideo, 1474 .type = SAA7134_INPUT_SVIDEO,
1525 .vmux = 8, 1475 .vmux = 8,
1526 .amux = LINE1, 1476 .amux = LINE1,
1527 },{ 1477 },{
1528 .name = name_comp2, /* CVideo over SVideo Connector */ 1478 .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
1529 .vmux = 0, 1479 .vmux = 0,
1530 .amux = LINE1, 1480 .amux = LINE1,
1531 }}, 1481 }},
1532 .mute = { 1482 .mute = {
1533 .name = name_mute, 1483 .type = SAA7134_INPUT_MUTE,
1534 .amux = LINE2, 1484 .amux = LINE2,
1535 }, 1485 },
1536 }, 1486 },
@@ -1544,29 +1494,28 @@ struct saa7134_board saa7134_boards[] = {
1544 .radio_addr = ADDR_UNSET, 1494 .radio_addr = ADDR_UNSET,
1545 .gpiomask = 0x808c0080, 1495 .gpiomask = 0x808c0080,
1546 .inputs = {{ 1496 .inputs = {{
1547 .name = name_svideo, 1497 .type = SAA7134_INPUT_SVIDEO,
1548 .vmux = 8, 1498 .vmux = 8,
1549 .amux = LINE1, 1499 .amux = LINE1,
1550 .gpio = 0x00080, 1500 .gpio = 0x00080,
1551 },{ 1501 },{
1552 .name = name_comp1, 1502 .type = SAA7134_INPUT_COMPOSITE1,
1553 .vmux = 3, 1503 .vmux = 3,
1554 .amux = LINE1, 1504 .amux = LINE1,
1555 .gpio = 0x00080, 1505 .gpio = 0x00080,
1556 },{ 1506 },{
1557 .name = name_tv, 1507 .type = SAA7134_INPUT_TV,
1558 .vmux = 1, 1508 .vmux = 1,
1559 .amux = LINE2_LEFT, 1509 .amux = LINE2_LEFT,
1560 .tv = 1,
1561 .gpio = 0x00080, 1510 .gpio = 0x00080,
1562 }}, 1511 }},
1563 .radio = { 1512 .radio = {
1564 .name = name_radio, 1513 .type = SAA7134_INPUT_RADIO,
1565 .amux = LINE2, 1514 .amux = LINE2,
1566 .gpio = 0x80000, 1515 .gpio = 0x80000,
1567 }, 1516 },
1568 .mute = { 1517 .mute = {
1569 .name = name_mute, 1518 .type = SAA7134_INPUT_MUTE,
1570 .amux = LINE2, 1519 .amux = LINE2,
1571 .gpio = 0x40000, 1520 .gpio = 0x40000,
1572 }, 1521 },
@@ -1580,21 +1529,20 @@ struct saa7134_board saa7134_boards[] = {
1580 .tuner_addr = ADDR_UNSET, 1529 .tuner_addr = ADDR_UNSET,
1581 .radio_addr = ADDR_UNSET, 1530 .radio_addr = ADDR_UNSET,
1582 .inputs = {{ 1531 .inputs = {{
1583 .name = name_comp1, 1532 .type = SAA7134_INPUT_COMPOSITE1,
1584 .vmux = 1, 1533 .vmux = 1,
1585 .amux = LINE1, 1534 .amux = LINE1,
1586 },{ 1535 },{
1587 .name = name_tv, 1536 .type = SAA7134_INPUT_TV,
1588 .vmux = 3, 1537 .vmux = 3,
1589 .amux = LINE2, 1538 .amux = LINE2,
1590 .tv = 1,
1591 },{ 1539 },{
1592 .name = name_svideo, 1540 .type = SAA7134_INPUT_SVIDEO,
1593 .vmux = 8, 1541 .vmux = 8,
1594 .amux = LINE1, 1542 .amux = LINE1,
1595 }}, 1543 }},
1596 .radio = { 1544 .radio = {
1597 .name = name_radio, 1545 .type = SAA7134_INPUT_RADIO,
1598 .amux = LINE2, 1546 .amux = LINE2,
1599 }, 1547 },
1600 }, 1548 },
@@ -1607,18 +1555,17 @@ struct saa7134_board saa7134_boards[] = {
1607 .tuner_addr = ADDR_UNSET, 1555 .tuner_addr = ADDR_UNSET,
1608 .radio_addr = ADDR_UNSET, 1556 .radio_addr = ADDR_UNSET,
1609 .inputs = {{ 1557 .inputs = {{
1610 .name = name_svideo, 1558 .type = SAA7134_INPUT_SVIDEO,
1611 .vmux = 8, 1559 .vmux = 8,
1612 .amux = LINE1, 1560 .amux = LINE1,
1613 },{ 1561 },{
1614 .name = name_comp1, 1562 .type = SAA7134_INPUT_COMPOSITE1,
1615 .vmux = 3, 1563 .vmux = 3,
1616 .amux = LINE1, 1564 .amux = LINE1,
1617 },{ 1565 },{
1618 .name = name_tv, 1566 .type = SAA7134_INPUT_TV,
1619 .vmux = 1, 1567 .vmux = 1,
1620 .amux = LINE2, 1568 .amux = LINE2,
1621 .tv = 1,
1622 }}, 1569 }},
1623 }, 1570 },
1624 [SAA7134_BOARD_EMPIRE_PCI_TV_RADIO_LE] = { 1571 [SAA7134_BOARD_EMPIRE_PCI_TV_RADIO_LE] = {
@@ -1631,29 +1578,28 @@ struct saa7134_board saa7134_boards[] = {
1631 .radio_addr = ADDR_UNSET, 1578 .radio_addr = ADDR_UNSET,
1632 .gpiomask = 0x4000, 1579 .gpiomask = 0x4000,
1633 .inputs = {{ 1580 .inputs = {{
1634 .name = name_tv_mono, 1581 .type = SAA7134_INPUT_TV_MONO,
1635 .vmux = 1, 1582 .vmux = 1,
1636 .amux = LINE2, 1583 .amux = LINE2,
1637 .gpio = 0x8000, 1584 .gpio = 0x8000,
1638 .tv = 1,
1639 },{ 1585 },{
1640 .name = name_comp1, 1586 .type = SAA7134_INPUT_COMPOSITE1,
1641 .vmux = 3, 1587 .vmux = 3,
1642 .amux = LINE1, 1588 .amux = LINE1,
1643 .gpio = 0x8000, 1589 .gpio = 0x8000,
1644 },{ 1590 },{
1645 .name = name_svideo, 1591 .type = SAA7134_INPUT_SVIDEO,
1646 .vmux = 6, 1592 .vmux = 6,
1647 .amux = LINE1, 1593 .amux = LINE1,
1648 .gpio = 0x8000, 1594 .gpio = 0x8000,
1649 }}, 1595 }},
1650 .radio = { 1596 .radio = {
1651 .name = name_radio, 1597 .type = SAA7134_INPUT_RADIO,
1652 .amux = LINE1, 1598 .amux = LINE1,
1653 .gpio = 0x8000, 1599 .gpio = 0x8000,
1654 }, 1600 },
1655 .mute = { 1601 .mute = {
1656 .name = name_mute, 1602 .type = SAA7134_INPUT_MUTE,
1657 .amux = TV, 1603 .amux = TV,
1658 .gpio =0x8000, 1604 .gpio =0x8000,
1659 } 1605 }
@@ -1672,29 +1618,28 @@ struct saa7134_board saa7134_boards[] = {
1672 .tda9887_conf = TDA9887_PRESENT, 1618 .tda9887_conf = TDA9887_PRESENT,
1673 .gpiomask = 0x03, 1619 .gpiomask = 0x03,
1674 .inputs = {{ 1620 .inputs = {{
1675 .name = name_tv, 1621 .type = SAA7134_INPUT_TV,
1676 .vmux = 1, 1622 .vmux = 1,
1677 .amux = TV, 1623 .amux = TV,
1678 .tv = 1,
1679 .gpio = 0x00, 1624 .gpio = 0x00,
1680 },{ 1625 },{
1681 .name = name_comp, 1626 .type = SAA7134_INPUT_COMPOSITE,
1682 .vmux = 3, 1627 .vmux = 3,
1683 .amux = LINE1, 1628 .amux = LINE1,
1684 .gpio = 0x02, 1629 .gpio = 0x02,
1685 },{ 1630 },{
1686 .name = name_svideo, 1631 .type = SAA7134_INPUT_SVIDEO,
1687 .vmux = 8, 1632 .vmux = 8,
1688 .amux = LINE1, 1633 .amux = LINE1,
1689 .gpio = 0x02, 1634 .gpio = 0x02,
1690 }}, 1635 }},
1691 .radio = { 1636 .radio = {
1692 .name = name_radio, 1637 .type = SAA7134_INPUT_RADIO,
1693 .amux = LINE1, 1638 .amux = LINE1,
1694 .gpio = 0x01, 1639 .gpio = 0x01,
1695 }, 1640 },
1696 .mute = { 1641 .mute = {
1697 .name = name_mute, 1642 .type = SAA7134_INPUT_MUTE,
1698 .amux = LINE1, 1643 .amux = LINE1,
1699 .gpio = 0x00, 1644 .gpio = 0x00,
1700 }, 1645 },
@@ -1709,29 +1654,28 @@ struct saa7134_board saa7134_boards[] = {
1709 .gpiomask = 0x00300003, 1654 .gpiomask = 0x00300003,
1710 /* .gpiomask = 0x8c240003, */ 1655 /* .gpiomask = 0x8c240003, */
1711 .inputs = {{ 1656 .inputs = {{
1712 .name = name_tv, 1657 .type = SAA7134_INPUT_TV,
1713 .vmux = 1, 1658 .vmux = 1,
1714 .amux = TV, 1659 .amux = TV,
1715 .tv = 1,
1716 .gpio = 0x01, 1660 .gpio = 0x01,
1717 },{ 1661 },{
1718 .name = name_comp1, 1662 .type = SAA7134_INPUT_COMPOSITE1,
1719 .vmux = 0, 1663 .vmux = 0,
1720 .amux = LINE1, 1664 .amux = LINE1,
1721 .gpio = 0x02, 1665 .gpio = 0x02,
1722 },{ 1666 },{
1723 .name = name_svideo, 1667 .type = SAA7134_INPUT_SVIDEO,
1724 .vmux = 6, 1668 .vmux = 6,
1725 .amux = LINE1, 1669 .amux = LINE1,
1726 .gpio = 0x02, 1670 .gpio = 0x02,
1727 }}, 1671 }},
1728 .radio = { 1672 .radio = {
1729 .name = name_radio, 1673 .type = SAA7134_INPUT_RADIO,
1730 .amux = TV, 1674 .amux = TV,
1731 .gpio = 0x00300001, 1675 .gpio = 0x00300001,
1732 }, 1676 },
1733 .mute = { 1677 .mute = {
1734 .name = name_mute, 1678 .type = SAA7134_INPUT_MUTE,
1735 .amux = TV, 1679 .amux = TV,
1736 .gpio = 0x01, 1680 .gpio = 0x01,
1737 }, 1681 },
@@ -1745,21 +1689,20 @@ struct saa7134_board saa7134_boards[] = {
1745 .tuner_addr = ADDR_UNSET, 1689 .tuner_addr = ADDR_UNSET,
1746 .radio_addr = ADDR_UNSET, 1690 .radio_addr = ADDR_UNSET,
1747 .inputs = {{ 1691 .inputs = {{
1748 .name = name_tv, 1692 .type = SAA7134_INPUT_TV,
1749 .vmux = 1, 1693 .vmux = 1,
1750 .amux = TV, 1694 .amux = TV,
1751 .tv = 1,
1752 },{ 1695 },{
1753 .name = name_comp1, 1696 .type = SAA7134_INPUT_COMPOSITE1,
1754 .vmux = 3, 1697 .vmux = 3,
1755 .amux = LINE2, 1698 .amux = LINE2,
1756 },{ 1699 },{
1757 .name = name_svideo, 1700 .type = SAA7134_INPUT_SVIDEO,
1758 .vmux = 8, 1701 .vmux = 8,
1759 .amux = LINE1, 1702 .amux = LINE1,
1760 }}, 1703 }},
1761 .radio = { 1704 .radio = {
1762 .name = name_radio, 1705 .type = SAA7134_INPUT_RADIO,
1763 .amux = LINE1, 1706 .amux = LINE1,
1764 }, 1707 },
1765 }, 1708 },
@@ -1774,24 +1717,23 @@ struct saa7134_board saa7134_boards[] = {
1774 .tda9887_conf = TDA9887_PRESENT, 1717 .tda9887_conf = TDA9887_PRESENT,
1775 .gpiomask = 0x08000000, 1718 .gpiomask = 0x08000000,
1776 .inputs = { { 1719 .inputs = { {
1777 .name = name_tv, 1720 .type = SAA7134_INPUT_TV,
1778 .vmux = 1, 1721 .vmux = 1,
1779 .amux = TV, 1722 .amux = TV,
1780 .tv = 1,
1781 .gpio = 0x08000000, 1723 .gpio = 0x08000000,
1782 }, { 1724 }, {
1783 .name = name_comp1, 1725 .type = SAA7134_INPUT_COMPOSITE1,
1784 .vmux = 3, 1726 .vmux = 3,
1785 .amux = LINE1, 1727 .amux = LINE1,
1786 .gpio = 0x08000000, 1728 .gpio = 0x08000000,
1787 }, { 1729 }, {
1788 .name = name_svideo, 1730 .type = SAA7134_INPUT_SVIDEO,
1789 .vmux = 8, 1731 .vmux = 8,
1790 .amux = LINE1, 1732 .amux = LINE1,
1791 .gpio = 0x08000000, 1733 .gpio = 0x08000000,
1792 } }, 1734 } },
1793 .radio = { 1735 .radio = {
1794 .name = name_radio, 1736 .type = SAA7134_INPUT_RADIO,
1795 .amux = LINE2, 1737 .amux = LINE2,
1796 .gpio = 0x00000000, 1738 .gpio = 0x00000000,
1797 }, 1739 },
@@ -1805,21 +1747,19 @@ struct saa7134_board saa7134_boards[] = {
1805 .radio_addr = ADDR_UNSET, 1747 .radio_addr = ADDR_UNSET,
1806 .tda9887_conf = TDA9887_PRESENT, 1748 .tda9887_conf = TDA9887_PRESENT,
1807 .inputs = {{ 1749 .inputs = {{
1808 .name = name_tv, 1750 .type = SAA7134_INPUT_TV,
1809 .vmux = 1, 1751 .vmux = 1,
1810 .amux = TV, 1752 .amux = TV,
1811 .tv = 1,
1812 },{ 1753 },{
1813 .name = name_tv_mono, 1754 .type = SAA7134_INPUT_TV_MONO,
1814 .vmux = 1, 1755 .vmux = 1,
1815 .amux = LINE2, 1756 .amux = LINE2,
1816 .tv = 1,
1817 },{ 1757 },{
1818 .name = name_comp1, 1758 .type = SAA7134_INPUT_COMPOSITE1,
1819 .vmux = 3, 1759 .vmux = 3,
1820 .amux = LINE1, 1760 .amux = LINE1,
1821 },{ 1761 },{
1822 .name = name_svideo, 1762 .type = SAA7134_INPUT_SVIDEO,
1823 .vmux = 8, 1763 .vmux = 8,
1824 .amux = LINE1, 1764 .amux = LINE1,
1825 }}, 1765 }},
@@ -1834,25 +1774,24 @@ struct saa7134_board saa7134_boards[] = {
1834 .rds_addr = 0x10, 1774 .rds_addr = 0x10,
1835 .tda9887_conf = TDA9887_PRESENT, 1775 .tda9887_conf = TDA9887_PRESENT,
1836 .inputs = {{ 1776 .inputs = {{
1837 .name = name_tv, 1777 .type = SAA7134_INPUT_TV,
1838 .vmux = 1, 1778 .vmux = 1,
1839 .amux = TV, 1779 .amux = TV,
1840 .tv = 1,
1841 },{ 1780 },{
1842 .name = name_comp1, 1781 .type = SAA7134_INPUT_COMPOSITE1,
1843 .vmux = 4, 1782 .vmux = 4,
1844 .amux = LINE1, 1783 .amux = LINE1,
1845 },{ 1784 },{
1846 .name = name_svideo, 1785 .type = SAA7134_INPUT_SVIDEO,
1847 .vmux = 8, 1786 .vmux = 8,
1848 .amux = LINE1, 1787 .amux = LINE1,
1849 },{ 1788 },{
1850 .name = name_comp2, /* CVideo over SVideo Connector */ 1789 .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
1851 .vmux = 0, 1790 .vmux = 0,
1852 .amux = LINE1, 1791 .amux = LINE1,
1853 }}, 1792 }},
1854 .radio = { 1793 .radio = {
1855 .name = name_radio, 1794 .type = SAA7134_INPUT_RADIO,
1856 .amux = LINE2, 1795 .amux = LINE2,
1857 }, 1796 },
1858 }, 1797 },
@@ -1866,29 +1805,28 @@ struct saa7134_board saa7134_boards[] = {
1866 .radio_addr = ADDR_UNSET, 1805 .radio_addr = ADDR_UNSET,
1867 .gpiomask = 0x1ce780, 1806 .gpiomask = 0x1ce780,
1868 .inputs = {{ 1807 .inputs = {{
1869 .name = name_svideo, 1808 .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
1870 .vmux = 0, /* CVideo over SVideo Connector - ok? */ 1809 .vmux = 0,
1871 .amux = LINE1, 1810 .amux = LINE1,
1872 .gpio = 0x008080, 1811 .gpio = 0x008080,
1873 },{ 1812 },{
1874 .name = name_comp1, 1813 .type = SAA7134_INPUT_COMPOSITE1,
1875 .vmux = 3, 1814 .vmux = 3,
1876 .amux = LINE1, 1815 .amux = LINE1,
1877 .gpio = 0x008080, 1816 .gpio = 0x008080,
1878 },{ 1817 },{
1879 .name = name_tv, 1818 .type = SAA7134_INPUT_TV,
1880 .vmux = 1, 1819 .vmux = 1,
1881 .amux = TV, 1820 .amux = TV,
1882 .tv = 1,
1883 .gpio = 0x008080, 1821 .gpio = 0x008080,
1884 }}, 1822 }},
1885 .radio = { 1823 .radio = {
1886 .name = name_radio, 1824 .type = SAA7134_INPUT_RADIO,
1887 .amux = LINE2, 1825 .amux = LINE2,
1888 .gpio = 0x80000, 1826 .gpio = 0x80000,
1889 }, 1827 },
1890 .mute = { 1828 .mute = {
1891 .name = name_mute, 1829 .type = SAA7134_INPUT_MUTE,
1892 .amux = LINE2, 1830 .amux = LINE2,
1893 .gpio = 0x0c8000, 1831 .gpio = 0x0c8000,
1894 }, 1832 },
@@ -1903,20 +1841,19 @@ struct saa7134_board saa7134_boards[] = {
1903 .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER | TDA9887_PORT2_INACTIVE, 1841 .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER | TDA9887_PORT2_INACTIVE,
1904 .mpeg = SAA7134_MPEG_DVB, 1842 .mpeg = SAA7134_MPEG_DVB,
1905 .inputs = {{ 1843 .inputs = {{
1906 .name = name_tv, 1844 .type = SAA7134_INPUT_TV,
1907 .vmux = 3, 1845 .vmux = 3,
1908 .amux = TV, 1846 .amux = TV,
1909 .tv = 1,
1910 },{ 1847 },{
1911 .name = name_comp1, 1848 .type = SAA7134_INPUT_COMPOSITE1,
1912 .vmux = 0, 1849 .vmux = 0,
1913 .amux = LINE2, 1850 .amux = LINE2,
1914 },{ 1851 },{
1915 .name = name_comp2, 1852 .type = SAA7134_INPUT_COMPOSITE2,
1916 .vmux = 1, 1853 .vmux = 1,
1917 .amux = LINE2, 1854 .amux = LINE2,
1918 },{ 1855 },{
1919 .name = name_svideo, 1856 .type = SAA7134_INPUT_SVIDEO,
1920 .vmux = 8, 1857 .vmux = 8,
1921 .amux = LINE2, 1858 .amux = LINE2,
1922 }}, 1859 }},
@@ -1931,22 +1868,20 @@ struct saa7134_board saa7134_boards[] = {
1931 .radio_addr = ADDR_UNSET, 1868 .radio_addr = ADDR_UNSET,
1932 .tda9887_conf = TDA9887_PRESENT, 1869 .tda9887_conf = TDA9887_PRESENT,
1933 .inputs = {{ 1870 .inputs = {{
1934 .name = name_comp1, 1871 .type = SAA7134_INPUT_COMPOSITE1,
1935 .vmux = 0, 1872 .vmux = 0,
1936 .amux = LINE1, 1873 .amux = LINE1,
1937 },{ 1874 },{
1938 .name = name_tv, 1875 .type = SAA7134_INPUT_TV,
1939 .vmux = 1, 1876 .vmux = 1,
1940 .amux = TV, 1877 .amux = TV,
1941 .tv = 1,
1942 },{ 1878 },{
1943 .name = name_tv_mono, 1879 .type = SAA7134_INPUT_TV_MONO,
1944 .vmux = 1, 1880 .vmux = 1,
1945 .amux = LINE2, 1881 .amux = LINE2,
1946 .tv = 1,
1947 }}, 1882 }},
1948 .radio = { 1883 .radio = {
1949 .name = name_radio, 1884 .type = SAA7134_INPUT_RADIO,
1950 .amux = LINE2, 1885 .amux = LINE2,
1951 }, 1886 },
1952 }, 1887 },
@@ -1961,25 +1896,24 @@ struct saa7134_board saa7134_boards[] = {
1961 .radio_addr = ADDR_UNSET, 1896 .radio_addr = ADDR_UNSET,
1962 .tda9887_conf = TDA9887_PRESENT, 1897 .tda9887_conf = TDA9887_PRESENT,
1963 .inputs = {{ 1898 .inputs = {{
1964 .name = name_tv, 1899 .type = SAA7134_INPUT_TV,
1965 .vmux = 1, 1900 .vmux = 1,
1966 .amux = LINE2, 1901 .amux = LINE2,
1967 .tv = 1,
1968 },{ 1902 },{
1969 .name = name_comp1, 1903 .type = SAA7134_INPUT_COMPOSITE1,
1970 .vmux = 0, 1904 .vmux = 0,
1971 .amux = LINE2, 1905 .amux = LINE2,
1972 },{ 1906 },{
1973 .name = name_comp2, 1907 .type = SAA7134_INPUT_COMPOSITE2,
1974 .vmux = 3, 1908 .vmux = 3,
1975 .amux = LINE2, 1909 .amux = LINE2,
1976 },{ 1910 },{
1977 .name = name_svideo, 1911 .type = SAA7134_INPUT_SVIDEO,
1978 .vmux = 8, 1912 .vmux = 8,
1979 .amux = LINE2, 1913 .amux = LINE2,
1980 }}, 1914 }},
1981 .mute = { 1915 .mute = {
1982 .name = name_mute, 1916 .type = SAA7134_INPUT_MUTE,
1983 .amux = LINE1, 1917 .amux = LINE1,
1984 }, 1918 },
1985 }, 1919 },
@@ -1995,26 +1929,25 @@ struct saa7134_board saa7134_boards[] = {
1995 .gpiomask = 0x00200000, 1929 .gpiomask = 0x00200000,
1996 .mpeg = SAA7134_MPEG_DVB, 1930 .mpeg = SAA7134_MPEG_DVB,
1997 .inputs = {{ 1931 .inputs = {{
1998 .name = name_tv, 1932 .type = SAA7134_INPUT_TV,
1999 .vmux = 1, 1933 .vmux = 1,
2000 .amux = TV, 1934 .amux = TV,
2001 .gpio = 0x200000, /* GPIO21=High for TV input */ 1935 .gpio = 0x200000, /* GPIO21=High for TV input */
2002 .tv = 1,
2003 },{ 1936 },{
2004 .name = name_comp1, /* Composite signal on S-Video input */ 1937 .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
2005 .vmux = 0, 1938 .vmux = 0,
2006 .amux = LINE2, 1939 .amux = LINE2,
2007 },{ 1940 },{
2008 .name = name_comp2, /* Composite input */ 1941 .type = SAA7134_INPUT_COMPOSITE,
2009 .vmux = 3, 1942 .vmux = 3,
2010 .amux = LINE2, 1943 .amux = LINE2,
2011 },{ 1944 },{
2012 .name = name_svideo, /* S-Video signal on S-Video input */ 1945 .type = SAA7134_INPUT_SVIDEO,
2013 .vmux = 8, 1946 .vmux = 8,
2014 .amux = LINE2, 1947 .amux = LINE2,
2015 }}, 1948 }},
2016 .radio = { 1949 .radio = {
2017 .name = name_radio, 1950 .type = SAA7134_INPUT_RADIO,
2018 .amux = TV, 1951 .amux = TV,
2019 .gpio = 0x000000, /* GPIO21=Low for FM radio antenna */ 1952 .gpio = 0x000000, /* GPIO21=Low for FM radio antenna */
2020 }, 1953 },
@@ -2028,11 +1961,11 @@ struct saa7134_board saa7134_boards[] = {
2028 .radio_addr = ADDR_UNSET, 1961 .radio_addr = ADDR_UNSET,
2029 .mpeg = SAA7134_MPEG_DVB, 1962 .mpeg = SAA7134_MPEG_DVB,
2030 .inputs = {{ 1963 .inputs = {{
2031 .name = name_comp1, 1964 .type = SAA7134_INPUT_COMPOSITE1,
2032 .vmux = 0, 1965 .vmux = 0,
2033 .amux = LINE1, 1966 .amux = LINE1,
2034 },{ 1967 },{
2035 .name = name_svideo, 1968 .type = SAA7134_INPUT_SVIDEO,
2036 .vmux = 8, 1969 .vmux = 8,
2037 .amux = LINE1, 1970 .amux = LINE1,
2038 }}, 1971 }},
@@ -2049,20 +1982,19 @@ struct saa7134_board saa7134_boards[] = {
2049 .radio_addr = ADDR_UNSET, 1982 .radio_addr = ADDR_UNSET,
2050 .tda9887_conf = TDA9887_PRESENT, 1983 .tda9887_conf = TDA9887_PRESENT,
2051 .inputs = {{ 1984 .inputs = {{
2052 .name = name_tv, 1985 .type = SAA7134_INPUT_TV,
2053 .vmux = 1, 1986 .vmux = 1,
2054 .amux = TV, 1987 .amux = TV,
2055 .tv = 1,
2056 },{ 1988 },{
2057 .name = name_comp1, 1989 .type = SAA7134_INPUT_COMPOSITE1,
2058 .vmux = 0, 1990 .vmux = 0,
2059 .amux = LINE1, 1991 .amux = LINE1,
2060 },{ 1992 },{
2061 .name = name_comp2, 1993 .type = SAA7134_INPUT_COMPOSITE2,
2062 .vmux = 3, 1994 .vmux = 3,
2063 .amux = LINE1, 1995 .amux = LINE1,
2064 },{ 1996 },{
2065 .name = name_svideo, 1997 .type = SAA7134_INPUT_SVIDEO,
2066 .vmux = 8, 1998 .vmux = 8,
2067 .amux = LINE1, 1999 .amux = LINE1,
2068 }}, 2000 }},
@@ -2075,16 +2007,15 @@ struct saa7134_board saa7134_boards[] = {
2075 .tuner_addr = ADDR_UNSET, 2007 .tuner_addr = ADDR_UNSET,
2076 .radio_addr = ADDR_UNSET, 2008 .radio_addr = ADDR_UNSET,
2077 .inputs = {{ 2009 .inputs = {{
2078 .name = name_tv, 2010 .type = SAA7134_INPUT_TV,
2079 .vmux = 1, 2011 .vmux = 1,
2080 .amux = TV, 2012 .amux = TV,
2081 .tv = 1,
2082 },{ 2013 },{
2083 .name = name_comp1, 2014 .type = SAA7134_INPUT_COMPOSITE1,
2084 .vmux = 3, 2015 .vmux = 3,
2085 .amux = LINE2, 2016 .amux = LINE2,
2086 },{ 2017 },{
2087 .name = name_svideo, 2018 .type = SAA7134_INPUT_SVIDEO,
2088 .vmux = 8, 2019 .vmux = 8,
2089 .amux = LINE2, 2020 .amux = LINE2,
2090 }}, 2021 }},
@@ -2098,29 +2029,28 @@ struct saa7134_board saa7134_boards[] = {
2098 .radio_addr = ADDR_UNSET, 2029 .radio_addr = ADDR_UNSET,
2099 .gpiomask = 0x0700, 2030 .gpiomask = 0x0700,
2100 .inputs = {{ 2031 .inputs = {{
2101 .name = name_tv, 2032 .type = SAA7134_INPUT_TV,
2102 .vmux = 1, 2033 .vmux = 1,
2103 .amux = TV, 2034 .amux = TV,
2104 .tv = 1,
2105 .gpio = 0x000, 2035 .gpio = 0x000,
2106 },{ 2036 },{
2107 .name = name_comp1, 2037 .type = SAA7134_INPUT_COMPOSITE1,
2108 .vmux = 3, 2038 .vmux = 3,
2109 .amux = LINE1, 2039 .amux = LINE1,
2110 .gpio = 0x200, /* gpio by DScaler */ 2040 .gpio = 0x200, /* gpio by DScaler */
2111 },{ 2041 },{
2112 .name = name_svideo, 2042 .type = SAA7134_INPUT_SVIDEO,
2113 .vmux = 0, 2043 .vmux = 0,
2114 .amux = LINE1, 2044 .amux = LINE1,
2115 .gpio = 0x200, 2045 .gpio = 0x200,
2116 }}, 2046 }},
2117 .radio = { 2047 .radio = {
2118 .name = name_radio, 2048 .type = SAA7134_INPUT_RADIO,
2119 .amux = LINE1, 2049 .amux = LINE1,
2120 .gpio = 0x100, 2050 .gpio = 0x100,
2121 }, 2051 },
2122 .mute = { 2052 .mute = {
2123 .name = name_mute, 2053 .type = SAA7134_INPUT_MUTE,
2124 .amux = TV, 2054 .amux = TV,
2125 .gpio = 0x000, 2055 .gpio = 0x000,
2126 }, 2056 },
@@ -2135,26 +2065,25 @@ struct saa7134_board saa7134_boards[] = {
2135 .mpeg = SAA7134_MPEG_DVB, 2065 .mpeg = SAA7134_MPEG_DVB,
2136 .gpiomask = 0x00200000, 2066 .gpiomask = 0x00200000,
2137 .inputs = {{ 2067 .inputs = {{
2138 .name = name_tv, 2068 .type = SAA7134_INPUT_TV,
2139 .vmux = 1, 2069 .vmux = 1,
2140 .amux = TV, 2070 .amux = TV,
2141 .gpio = 0x200000, /* GPIO21=High for TV input */ 2071 .gpio = 0x200000, /* GPIO21=High for TV input */
2142 .tv = 1,
2143 },{ 2072 },{
2144 .name = name_svideo, /* S-Video signal on S-Video input */ 2073 .type = SAA7134_INPUT_SVIDEO,
2145 .vmux = 8, 2074 .vmux = 8,
2146 .amux = LINE2, 2075 .amux = LINE2,
2147 },{ 2076 },{
2148 .name = name_comp1, /* Composite signal on S-Video input */ 2077 .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
2149 .vmux = 0, 2078 .vmux = 0,
2150 .amux = LINE2, 2079 .amux = LINE2,
2151 },{ 2080 },{
2152 .name = name_comp2, /* Composite input */ 2081 .type = SAA7134_INPUT_COMPOSITE2,
2153 .vmux = 3, 2082 .vmux = 3,
2154 .amux = LINE2, 2083 .amux = LINE2,
2155 }}, 2084 }},
2156 .radio = { 2085 .radio = {
2157 .name = name_radio, 2086 .type = SAA7134_INPUT_RADIO,
2158 .amux = TV, 2087 .amux = TV,
2159 .gpio = 0x000000, /* GPIO21=Low for FM radio antenna */ 2088 .gpio = 0x000000, /* GPIO21=Low for FM radio antenna */
2160 }, 2089 },
@@ -2168,29 +2097,28 @@ struct saa7134_board saa7134_boards[] = {
2168 .radio_addr = 0x60, 2097 .radio_addr = 0x60,
2169 .gpiomask = 0x8c1880, 2098 .gpiomask = 0x8c1880,
2170 .inputs = {{ 2099 .inputs = {{
2171 .name = name_svideo, 2100 .type = SAA7134_INPUT_SVIDEO,
2172 .vmux = 0, 2101 .vmux = 0,
2173 .amux = LINE1, 2102 .amux = LINE1,
2174 .gpio = 0x800800, 2103 .gpio = 0x800800,
2175 },{ 2104 },{
2176 .name = name_comp1, 2105 .type = SAA7134_INPUT_COMPOSITE1,
2177 .vmux = 3, 2106 .vmux = 3,
2178 .amux = LINE1, 2107 .amux = LINE1,
2179 .gpio = 0x801000, 2108 .gpio = 0x801000,
2180 },{ 2109 },{
2181 .name = name_tv, 2110 .type = SAA7134_INPUT_TV,
2182 .vmux = 1, 2111 .vmux = 1,
2183 .amux = TV, 2112 .amux = TV,
2184 .tv = 1,
2185 .gpio = 0x800000, 2113 .gpio = 0x800000,
2186 }}, 2114 }},
2187 .radio = { 2115 .radio = {
2188 .name = name_radio, 2116 .type = SAA7134_INPUT_RADIO,
2189 .amux = TV, 2117 .amux = TV,
2190 .gpio = 0x880000, 2118 .gpio = 0x880000,
2191 }, 2119 },
2192 .mute = { 2120 .mute = {
2193 .name = name_mute, 2121 .type = SAA7134_INPUT_MUTE,
2194 .amux = LINE2, 2122 .amux = LINE2,
2195 .gpio = 0x840000, 2123 .gpio = 0x840000,
2196 }, 2124 },
@@ -2213,29 +2141,28 @@ struct saa7134_board saa7134_boards[] = {
2213 .radio_addr = 0x60, 2141 .radio_addr = 0x60,
2214 .gpiomask = 0x0700, 2142 .gpiomask = 0x0700,
2215 .inputs = {{ 2143 .inputs = {{
2216 .name = name_tv, 2144 .type = SAA7134_INPUT_TV,
2217 .vmux = 1, 2145 .vmux = 1,
2218 .amux = TV, 2146 .amux = TV,
2219 .tv = 1,
2220 .gpio = 0x000, 2147 .gpio = 0x000,
2221 },{ 2148 },{
2222 .name = name_comp1, 2149 .type = SAA7134_INPUT_COMPOSITE1,
2223 .vmux = 3, 2150 .vmux = 3,
2224 .amux = LINE1, 2151 .amux = LINE1,
2225 .gpio = 0x200, /* gpio by DScaler */ 2152 .gpio = 0x200, /* gpio by DScaler */
2226 },{ 2153 },{
2227 .name = name_svideo, 2154 .type = SAA7134_INPUT_SVIDEO,
2228 .vmux = 0, 2155 .vmux = 0,
2229 .amux = LINE1, 2156 .amux = LINE1,
2230 .gpio = 0x200, 2157 .gpio = 0x200,
2231 }}, 2158 }},
2232 .radio = { 2159 .radio = {
2233 .name = name_radio, 2160 .type = SAA7134_INPUT_RADIO,
2234 .amux = LINE1, 2161 .amux = LINE1,
2235 .gpio = 0x100, 2162 .gpio = 0x100,
2236 }, 2163 },
2237 .mute = { 2164 .mute = {
2238 .name = name_mute, 2165 .type = SAA7134_INPUT_MUTE,
2239 .amux = TV, 2166 .amux = TV,
2240 .gpio = 0x000, 2167 .gpio = 0x000,
2241 }, 2168 },
@@ -2248,30 +2175,28 @@ struct saa7134_board saa7134_boards[] = {
2248 .tuner_addr = ADDR_UNSET, 2175 .tuner_addr = ADDR_UNSET,
2249 .radio_addr = ADDR_UNSET, 2176 .radio_addr = ADDR_UNSET,
2250 .inputs = {{ 2177 .inputs = {{
2251 .name = name_tv, 2178 .type = SAA7134_INPUT_TV,
2252 .vmux = 1, 2179 .vmux = 1,
2253 .amux = TV, 2180 .amux = TV,
2254 .tv = 1,
2255 },{ 2181 },{
2256 .name = name_tv_mono, 2182 .type = SAA7134_INPUT_TV_MONO,
2257 .vmux = 1, 2183 .vmux = 1,
2258 .amux = LINE2, 2184 .amux = LINE2,
2259 .tv = 1,
2260 },{ 2185 },{
2261 .name = name_comp1, 2186 .type = SAA7134_INPUT_COMPOSITE1,
2262 .vmux = 0, 2187 .vmux = 0,
2263 .amux = LINE2, 2188 .amux = LINE2,
2264 },{ 2189 },{
2265 .name = name_comp2, 2190 .type = SAA7134_INPUT_COMPOSITE2,
2266 .vmux = 3, 2191 .vmux = 3,
2267 .amux = LINE2, 2192 .amux = LINE2,
2268 },{ 2193 },{
2269 .name = name_svideo, 2194 .type = SAA7134_INPUT_SVIDEO,
2270 .vmux = 8, 2195 .vmux = 8,
2271 .amux = LINE2, 2196 .amux = LINE2,
2272 }}, 2197 }},
2273 .radio = { 2198 .radio = {
2274 .name = name_radio, /* radio unconfirmed */ 2199 .type = SAA7134_INPUT_RADIO, /* radio unconfirmed */
2275 .amux = LINE2, 2200 .amux = LINE2,
2276 }, 2201 },
2277 }, 2202 },
@@ -2286,24 +2211,23 @@ struct saa7134_board saa7134_boards[] = {
2286 .radio_addr = ADDR_UNSET, 2211 .radio_addr = ADDR_UNSET,
2287 .gpiomask = 1 << 21, 2212 .gpiomask = 1 << 21,
2288 .inputs = {{ 2213 .inputs = {{
2289 .name = name_tv, 2214 .type = SAA7134_INPUT_TV,
2290 .vmux = 1, 2215 .vmux = 1,
2291 .amux = TV, 2216 .amux = TV,
2292 .gpio = 0x0000000, 2217 .gpio = 0x0000000,
2293 .tv = 1,
2294 },{ 2218 },{
2295 .name = name_comp1, /* Composite input */ 2219 .type = SAA7134_INPUT_COMPOSITE1,
2296 .vmux = 3, 2220 .vmux = 3,
2297 .amux = LINE2, 2221 .amux = LINE2,
2298 .gpio = 0x0000000, 2222 .gpio = 0x0000000,
2299 },{ 2223 },{
2300 .name = name_svideo, /* S-Video input */ 2224 .type = SAA7134_INPUT_SVIDEO,
2301 .vmux = 8, 2225 .vmux = 8,
2302 .amux = LINE2, 2226 .amux = LINE2,
2303 .gpio = 0x0000000, 2227 .gpio = 0x0000000,
2304 }}, 2228 }},
2305 .radio = { 2229 .radio = {
2306 .name = name_radio, 2230 .type = SAA7134_INPUT_RADIO,
2307 .amux = TV, 2231 .amux = TV,
2308 .gpio = 0x0200000, 2232 .gpio = 0x0200000,
2309 }, 2233 },
@@ -2322,29 +2246,28 @@ struct saa7134_board saa7134_boards[] = {
2322 .radio_addr= ADDR_UNSET, 2246 .radio_addr= ADDR_UNSET,
2323 .gpiomask = 0x00010003, 2247 .gpiomask = 0x00010003,
2324 .inputs = {{ 2248 .inputs = {{
2325 .name = name_tv, 2249 .type = SAA7134_INPUT_TV,
2326 .vmux = 1, 2250 .vmux = 1,
2327 .amux = TV, 2251 .amux = TV,
2328 .tv = 1,
2329 .gpio = 0x01, 2252 .gpio = 0x01,
2330 },{ 2253 },{
2331 .name = name_comp1, 2254 .type = SAA7134_INPUT_COMPOSITE1,
2332 .vmux = 0, 2255 .vmux = 0,
2333 .amux = LINE2, 2256 .amux = LINE2,
2334 .gpio = 0x02, 2257 .gpio = 0x02,
2335 },{ 2258 },{
2336 .name = name_svideo, 2259 .type = SAA7134_INPUT_SVIDEO,
2337 .vmux = 6, 2260 .vmux = 6,
2338 .amux = LINE2, 2261 .amux = LINE2,
2339 .gpio = 0x02, 2262 .gpio = 0x02,
2340 }}, 2263 }},
2341 .radio = { 2264 .radio = {
2342 .name = name_radio, 2265 .type = SAA7134_INPUT_RADIO,
2343 .amux = LINE1, 2266 .amux = LINE1,
2344 .gpio = 0x00010003, 2267 .gpio = 0x00010003,
2345 }, 2268 },
2346 .mute = { 2269 .mute = {
2347 .name = name_mute, 2270 .type = SAA7134_INPUT_MUTE,
2348 .amux = TV, 2271 .amux = TV,
2349 .gpio = 0x01, 2272 .gpio = 0x01,
2350 }, 2273 },
@@ -2362,21 +2285,20 @@ struct saa7134_board saa7134_boards[] = {
2362 .tda9887_conf = TDA9887_PRESENT, 2285 .tda9887_conf = TDA9887_PRESENT,
2363 .gpiomask = 0x00008000, 2286 .gpiomask = 0x00008000,
2364 .inputs = {{ 2287 .inputs = {{
2365 .name = name_tv, 2288 .type = SAA7134_INPUT_TV,
2366 .vmux = 3, 2289 .vmux = 3,
2367 .amux = TV, 2290 .amux = TV,
2368 .tv = 1,
2369 },{ 2291 },{
2370 .name = name_comp1, 2292 .type = SAA7134_INPUT_COMPOSITE1,
2371 .vmux = 1, 2293 .vmux = 1,
2372 .amux = LINE1, 2294 .amux = LINE1,
2373 },{ 2295 },{
2374 .name = name_svideo, 2296 .type = SAA7134_INPUT_SVIDEO,
2375 .vmux = 8, 2297 .vmux = 8,
2376 .amux = LINE1, 2298 .amux = LINE1,
2377 }}, 2299 }},
2378 .radio = { 2300 .radio = {
2379 .name = name_radio, 2301 .type = SAA7134_INPUT_RADIO,
2380 .amux = LINE2, 2302 .amux = LINE2,
2381 }, 2303 },
2382 }, 2304 },
@@ -2392,34 +2314,33 @@ struct saa7134_board saa7134_boards[] = {
2392 .tda9887_conf = TDA9887_PRESENT, 2314 .tda9887_conf = TDA9887_PRESENT,
2393 .gpiomask = 0x00200003, 2315 .gpiomask = 0x00200003,
2394 .inputs = {{ 2316 .inputs = {{
2395 .name = name_tv, 2317 .type = SAA7134_INPUT_TV,
2396 .vmux = 1, 2318 .vmux = 1,
2397 .amux = TV, 2319 .amux = TV,
2398 .tv = 1,
2399 .gpio = 0x00200003, 2320 .gpio = 0x00200003,
2400 },{ 2321 },{
2401 .name = name_tv_mono, 2322 .type = SAA7134_INPUT_TV_MONO,
2402 .vmux = 1, 2323 .vmux = 1,
2403 .amux = LINE2, 2324 .amux = LINE2,
2404 .gpio = 0x00200003, 2325 .gpio = 0x00200003,
2405 },{ 2326 },{
2406 .name = name_comp1, 2327 .type = SAA7134_INPUT_COMPOSITE1,
2407 .vmux = 3, 2328 .vmux = 3,
2408 .amux = LINE1, 2329 .amux = LINE1,
2409 .gpio = 0x00200003, 2330 .gpio = 0x00200003,
2410 },{ 2331 },{
2411 .name = name_svideo, 2332 .type = SAA7134_INPUT_SVIDEO,
2412 .vmux = 8, 2333 .vmux = 8,
2413 .amux = LINE1, 2334 .amux = LINE1,
2414 .gpio = 0x00200003, 2335 .gpio = 0x00200003,
2415 }}, 2336 }},
2416 .radio = { 2337 .radio = {
2417 .name = name_radio, 2338 .type = SAA7134_INPUT_RADIO,
2418 .amux = LINE2, 2339 .amux = LINE2,
2419 .gpio = 0x00200003, 2340 .gpio = 0x00200003,
2420 }, 2341 },
2421 .mute = { 2342 .mute = {
2422 .name = name_mute, 2343 .type = SAA7134_INPUT_MUTE,
2423 .amux = TV, 2344 .amux = TV,
2424 .gpio = 0x00200003, 2345 .gpio = 0x00200003,
2425 }, 2346 },
@@ -2434,16 +2355,15 @@ struct saa7134_board saa7134_boards[] = {
2434 .tda9887_conf = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE, 2355 .tda9887_conf = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE,
2435 .mpeg = SAA7134_MPEG_DVB, 2356 .mpeg = SAA7134_MPEG_DVB,
2436 .inputs = {{ 2357 .inputs = {{
2437 .name = name_tv, 2358 .type = SAA7134_INPUT_TV,
2438 .vmux = 3, 2359 .vmux = 3,
2439 .amux = TV, 2360 .amux = TV,
2440 .tv = 1,
2441 },{ 2361 },{
2442 .name = name_comp1, 2362 .type = SAA7134_INPUT_COMPOSITE1,
2443 .vmux = 0, 2363 .vmux = 0,
2444 .amux = LINE2, 2364 .amux = LINE2,
2445 },{ 2365 },{
2446 .name = name_svideo, 2366 .type = SAA7134_INPUT_SVIDEO,
2447 .vmux = 8, 2367 .vmux = 8,
2448 .amux = LINE2, 2368 .amux = LINE2,
2449 }}, 2369 }},
@@ -2458,16 +2378,15 @@ struct saa7134_board saa7134_boards[] = {
2458 .tda9887_conf = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE, 2378 .tda9887_conf = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE,
2459 .mpeg = SAA7134_MPEG_DVB, 2379 .mpeg = SAA7134_MPEG_DVB,
2460 .inputs = {{ 2380 .inputs = {{
2461 .name = name_tv, 2381 .type = SAA7134_INPUT_TV,
2462 .vmux = 3, 2382 .vmux = 3,
2463 .amux = TV, 2383 .amux = TV,
2464 .tv = 1,
2465 },{ 2384 },{
2466 .name = name_comp1, 2385 .type = SAA7134_INPUT_COMPOSITE1,
2467 .vmux = 1, 2386 .vmux = 1,
2468 .amux = LINE2, 2387 .amux = LINE2,
2469 },{ 2388 },{
2470 .name = name_svideo, 2389 .type = SAA7134_INPUT_SVIDEO,
2471 .vmux = 8, 2390 .vmux = 8,
2472 .amux = LINE2, 2391 .amux = LINE2,
2473 }}, 2392 }},
@@ -2481,11 +2400,11 @@ struct saa7134_board saa7134_boards[] = {
2481 .radio_addr = ADDR_UNSET, 2400 .radio_addr = ADDR_UNSET,
2482 .mpeg = SAA7134_MPEG_DVB, 2401 .mpeg = SAA7134_MPEG_DVB,
2483 .inputs = {{ 2402 .inputs = {{
2484 .name = name_comp1, 2403 .type = SAA7134_INPUT_COMPOSITE1,
2485 .vmux = 0, 2404 .vmux = 0,
2486 .amux = LINE1, 2405 .amux = LINE1,
2487 },{ 2406 },{
2488 .name = name_svideo, 2407 .type = SAA7134_INPUT_SVIDEO,
2489 .vmux = 8, 2408 .vmux = 8,
2490 .amux = LINE1, 2409 .amux = LINE1,
2491 }}, 2410 }},
@@ -2499,27 +2418,28 @@ struct saa7134_board saa7134_boards[] = {
2499 .radio_addr = ADDR_UNSET, 2418 .radio_addr = ADDR_UNSET,
2500 .empress_addr = 0x21, 2419 .empress_addr = 0x21,
2501 .inputs = {{ 2420 .inputs = {{
2502 .name = "Composite 0", 2421 .type = SAA7134_INPUT_COMPOSITE0,
2503 .vmux = 0, 2422 .vmux = 0,
2504 .amux = LINE1, 2423 .amux = LINE1,
2505 },{ 2424 },{
2506 .name = "Composite 1", 2425 .type = SAA7134_INPUT_COMPOSITE1,
2507 .vmux = 1, 2426 .vmux = 1,
2508 .amux = LINE2, 2427 .amux = LINE2,
2509 },{ 2428 },{
2510 .name = "Composite 2", 2429 .type = SAA7134_INPUT_COMPOSITE2,
2511 .vmux = 2, 2430 .vmux = 2,
2512 .amux = LINE1, 2431 .amux = LINE1,
2513 },{ 2432 },{
2514 .name = "Composite 3", 2433 .type = SAA7134_INPUT_COMPOSITE3,
2515 .vmux = 3, 2434 .vmux = 3,
2516 .amux = LINE2, 2435 .amux = LINE2,
2517 },{ 2436 },{
2518 .name = "S-Video 0", 2437 .type = SAA7134_INPUT_SVIDEO0,
2438
2519 .vmux = 8, 2439 .vmux = 8,
2520 .amux = LINE1, 2440 .amux = LINE1,
2521 },{ 2441 },{
2522 .name = "S-Video 1", 2442 .type = SAA7134_INPUT_SVIDEO1,
2523 .vmux = 9, 2443 .vmux = 9,
2524 .amux = LINE2, 2444 .amux = LINE2,
2525 }}, 2445 }},
@@ -2538,27 +2458,27 @@ struct saa7134_board saa7134_boards[] = {
2538 .tuner_addr = ADDR_UNSET, 2458 .tuner_addr = ADDR_UNSET,
2539 .radio_addr = ADDR_UNSET, 2459 .radio_addr = ADDR_UNSET,
2540 .inputs = {{ 2460 .inputs = {{
2541 .name = "Composite 0", 2461 .type = SAA7134_INPUT_COMPOSITE0,
2542 .vmux = 0, 2462 .vmux = 0,
2543 .amux = LINE1, 2463 .amux = LINE1,
2544 },{ 2464 },{
2545 .name = "Composite 1", 2465 .type = SAA7134_INPUT_COMPOSITE1,
2546 .vmux = 1, 2466 .vmux = 1,
2547 .amux = LINE2, 2467 .amux = LINE2,
2548 },{ 2468 },{
2549 .name = "Composite 2", 2469 .type = SAA7134_INPUT_COMPOSITE2,
2550 .vmux = 2, 2470 .vmux = 2,
2551 .amux = LINE1, 2471 .amux = LINE1,
2552 },{ 2472 },{
2553 .name = "Composite 3", 2473 .type = SAA7134_INPUT_COMPOSITE3,
2554 .vmux = 3, 2474 .vmux = 3,
2555 .amux = LINE2, 2475 .amux = LINE2,
2556 },{ 2476 },{
2557 .name = "S-Video 0", 2477 .type = SAA7134_INPUT_SVIDEO0,
2558 .vmux = 8, 2478 .vmux = 8,
2559 .amux = LINE1, 2479 .amux = LINE1,
2560 },{ 2480 },{
2561 .name = "S-Video 1", 2481 .type = SAA7134_INPUT_SVIDEO1,
2562 .vmux = 9, 2482 .vmux = 9,
2563 .amux = LINE2, 2483 .amux = LINE2,
2564 }}, 2484 }},
@@ -2572,20 +2492,19 @@ struct saa7134_board saa7134_boards[] = {
2572 .radio_addr = ADDR_UNSET, 2492 .radio_addr = ADDR_UNSET,
2573 2493
2574 .inputs = {{ 2494 .inputs = {{
2575 .name = name_tv, 2495 .type = SAA7134_INPUT_TV,
2576 .vmux = 1, 2496 .vmux = 1,
2577 .amux = TV, 2497 .amux = TV,
2578 .tv = 1,
2579 },{ 2498 },{
2580 .name = name_comp1, /* Composite signal on S-Video input */ 2499 .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
2581 .vmux = 0, 2500 .vmux = 0,
2582 .amux = LINE2, 2501 .amux = LINE2,
2583 },{ 2502 },{
2584 .name = name_comp2, /* Composite input */ 2503 .type = SAA7134_INPUT_COMPOSITE,
2585 .vmux = 3, 2504 .vmux = 3,
2586 .amux = LINE2, 2505 .amux = LINE2,
2587 },{ 2506 },{
2588 .name = name_svideo, 2507 .type = SAA7134_INPUT_SVIDEO,
2589 .vmux = 8, 2508 .vmux = 8,
2590 .amux = LINE2, 2509 .amux = LINE2,
2591 }}, 2510 }},
@@ -2604,11 +2523,11 @@ struct saa7134_board saa7134_boards[] = {
2604 .radio_addr = ADDR_UNSET, 2523 .radio_addr = ADDR_UNSET,
2605 .mpeg = SAA7134_MPEG_DVB, 2524 .mpeg = SAA7134_MPEG_DVB,
2606 .inputs = {{ 2525 .inputs = {{
2607 .name = name_comp1, 2526 .type = SAA7134_INPUT_COMPOSITE1,
2608 .vmux = 3, 2527 .vmux = 3,
2609 .amux = LINE2, 2528 .amux = LINE2,
2610 },{ 2529 },{
2611 .name = name_svideo, 2530 .type = SAA7134_INPUT_SVIDEO,
2612 .vmux = 8, 2531 .vmux = 8,
2613 .amux = LINE2, 2532 .amux = LINE2,
2614 }}, 2533 }},
@@ -2622,16 +2541,15 @@ struct saa7134_board saa7134_boards[] = {
2622 .radio_addr = ADDR_UNSET, 2541 .radio_addr = ADDR_UNSET,
2623 2542
2624 .inputs = {{ 2543 .inputs = {{
2625 .name = name_tv, 2544 .type = SAA7134_INPUT_TV,
2626 .vmux = 1, 2545 .vmux = 1,
2627 .amux = TV, 2546 .amux = TV,
2628 .tv = 1,
2629 },{ 2547 },{
2630 .name = name_comp1, 2548 .type = SAA7134_INPUT_COMPOSITE1,
2631 .vmux = 3, 2549 .vmux = 3,
2632 .amux = LINE1, 2550 .amux = LINE1,
2633 },{ 2551 },{
2634 .name = name_svideo, 2552 .type = SAA7134_INPUT_SVIDEO,
2635 .vmux = 6, 2553 .vmux = 6,
2636 .amux = LINE1, 2554 .amux = LINE1,
2637 }}, 2555 }},
@@ -2645,25 +2563,24 @@ struct saa7134_board saa7134_boards[] = {
2645 .radio_addr = ADDR_UNSET, 2563 .radio_addr = ADDR_UNSET,
2646 .gpiomask = 0x080200000, 2564 .gpiomask = 0x080200000,
2647 .inputs = { { 2565 .inputs = { {
2648 .name = name_tv, 2566 .type = SAA7134_INPUT_TV,
2649 .vmux = 4, 2567 .vmux = 4,
2650 .amux = TV, 2568 .amux = TV,
2651 .tv = 1,
2652 }, { 2569 }, {
2653 .name = name_comp1, 2570 .type = SAA7134_INPUT_COMPOSITE1,
2654 .vmux = 1, 2571 .vmux = 1,
2655 .amux = LINE2, 2572 .amux = LINE2,
2656 }, { 2573 }, {
2657 .name = name_comp2, 2574 .type = SAA7134_INPUT_COMPOSITE2,
2658 .vmux = 0, 2575 .vmux = 0,
2659 .amux = LINE2, 2576 .amux = LINE2,
2660 }, { 2577 }, {
2661 .name = name_svideo, 2578 .type = SAA7134_INPUT_SVIDEO,
2662 .vmux = 8, 2579 .vmux = 8,
2663 .amux = LINE2, 2580 .amux = LINE2,
2664 } }, 2581 } },
2665 .radio = { 2582 .radio = {
2666 .name = name_radio, 2583 .type = SAA7134_INPUT_RADIO,
2667 .amux = TV, 2584 .amux = TV,
2668 .gpio = 0x0200000, 2585 .gpio = 0x0200000,
2669 }, 2586 },
@@ -2678,29 +2595,28 @@ struct saa7134_board saa7134_boards[] = {
2678 .gpiomask = 1 << 21, 2595 .gpiomask = 1 << 21,
2679 .mpeg = SAA7134_MPEG_DVB, 2596 .mpeg = SAA7134_MPEG_DVB,
2680 .inputs = {{ 2597 .inputs = {{
2681 .name = name_tv, 2598 .type = SAA7134_INPUT_TV,
2682 .vmux = 1, 2599 .vmux = 1,
2683 .amux = TV, 2600 .amux = TV,
2684 .tv = 1,
2685 .gpio = 0x0000000, 2601 .gpio = 0x0000000,
2686 },{ 2602 },{
2687 .name = name_comp1, 2603 .type = SAA7134_INPUT_COMPOSITE1,
2688 .vmux = 3, 2604 .vmux = 3,
2689 .amux = LINE2, 2605 .amux = LINE2,
2690 .gpio = 0x0200000, 2606 .gpio = 0x0200000,
2691 },{ 2607 },{
2692 .name = name_comp2, 2608 .type = SAA7134_INPUT_COMPOSITE2,
2693 .vmux = 0, 2609 .vmux = 0,
2694 .amux = LINE2, 2610 .amux = LINE2,
2695 .gpio = 0x0200000, 2611 .gpio = 0x0200000,
2696 },{ 2612 },{
2697 .name = name_svideo, 2613 .type = SAA7134_INPUT_SVIDEO,
2698 .vmux = 8, 2614 .vmux = 8,
2699 .amux = LINE2, 2615 .amux = LINE2,
2700 .gpio = 0x0200000, 2616 .gpio = 0x0200000,
2701 }}, 2617 }},
2702 .radio = { 2618 .radio = {
2703 .name = name_radio, 2619 .type = SAA7134_INPUT_RADIO,
2704 .amux = TV, 2620 .amux = TV,
2705 .gpio = 0x0200000, 2621 .gpio = 0x0200000,
2706 }, 2622 },
@@ -2717,21 +2633,20 @@ struct saa7134_board saa7134_boards[] = {
2717 .radio_addr = ADDR_UNSET, 2633 .radio_addr = ADDR_UNSET,
2718 .gpiomask = 0xe880c0, 2634 .gpiomask = 0xe880c0,
2719 .inputs = {{ 2635 .inputs = {{
2720 .name = name_tv, 2636 .type = SAA7134_INPUT_TV,
2721 .vmux = 3, 2637 .vmux = 3,
2722 .amux = TV, 2638 .amux = TV,
2723 .tv = 1,
2724 },{ 2639 },{
2725 .name = name_comp1, 2640 .type = SAA7134_INPUT_COMPOSITE1,
2726 .vmux = 1, 2641 .vmux = 1,
2727 .amux = LINE1, 2642 .amux = LINE1,
2728 },{ 2643 },{
2729 .name = name_svideo, 2644 .type = SAA7134_INPUT_SVIDEO,
2730 .vmux = 6, 2645 .vmux = 6,
2731 .amux = LINE1, 2646 .amux = LINE1,
2732 }}, 2647 }},
2733 .radio = { 2648 .radio = {
2734 .name = name_radio, 2649 .type = SAA7134_INPUT_RADIO,
2735 .amux = LINE2, 2650 .amux = LINE2,
2736 }, 2651 },
2737 }, 2652 },
@@ -2745,16 +2660,15 @@ struct saa7134_board saa7134_boards[] = {
2745 .tuner_addr = ADDR_UNSET, 2660 .tuner_addr = ADDR_UNSET,
2746 .radio_addr = ADDR_UNSET, 2661 .radio_addr = ADDR_UNSET,
2747 .inputs = {{ 2662 .inputs = {{
2748 .name = name_tv, 2663 .type = SAA7134_INPUT_TV,
2749 .vmux = 1, 2664 .vmux = 1,
2750 .amux = TV, 2665 .amux = TV,
2751 .tv = 1,
2752 },{ 2666 },{
2753 .name = name_comp1, 2667 .type = SAA7134_INPUT_COMPOSITE1,
2754 .vmux = 3, 2668 .vmux = 3,
2755 .amux = LINE1, 2669 .amux = LINE1,
2756 },{ 2670 },{
2757 .name = name_svideo, 2671 .type = SAA7134_INPUT_SVIDEO,
2758 .vmux = 8, 2672 .vmux = 8,
2759 .amux = LINE1, 2673 .amux = LINE1,
2760 }}, 2674 }},
@@ -2770,21 +2684,20 @@ struct saa7134_board saa7134_boards[] = {
2770 .mpeg = SAA7134_MPEG_DVB, 2684 .mpeg = SAA7134_MPEG_DVB,
2771 .gpiomask = 0x0200000, 2685 .gpiomask = 0x0200000,
2772 .inputs = {{ 2686 .inputs = {{
2773 .name = name_tv, 2687 .type = SAA7134_INPUT_TV,
2774 .vmux = 1, 2688 .vmux = 1,
2775 .amux = TV, 2689 .amux = TV,
2776 .tv = 1,
2777 },{ 2690 },{
2778 .name = name_comp1, 2691 .type = SAA7134_INPUT_COMPOSITE1,
2779 .vmux = 3, 2692 .vmux = 3,
2780 .amux = LINE1, 2693 .amux = LINE1,
2781 },{ 2694 },{
2782 .name = name_svideo, 2695 .type = SAA7134_INPUT_SVIDEO,
2783 .vmux = 8, 2696 .vmux = 8,
2784 .amux = LINE1, 2697 .amux = LINE1,
2785 }}, 2698 }},
2786 .radio = { 2699 .radio = {
2787 .name = name_radio, 2700 .type = SAA7134_INPUT_RADIO,
2788 .amux = TV, 2701 .amux = TV,
2789 .gpio = 0x0200000, 2702 .gpio = 0x0200000,
2790 }, 2703 },
@@ -2798,25 +2711,24 @@ struct saa7134_board saa7134_boards[] = {
2798 .radio_addr = ADDR_UNSET, 2711 .radio_addr = ADDR_UNSET,
2799 .gpiomask = 1 << 21, 2712 .gpiomask = 1 << 21,
2800 .inputs = {{ 2713 .inputs = {{
2801 .name = name_tv, 2714 .type = SAA7134_INPUT_TV,
2802 .vmux = 1, 2715 .vmux = 1,
2803 .amux = TV, 2716 .amux = TV,
2804 .tv = 1,
2805 },{ 2717 },{
2806 .name = name_comp1, 2718 .type = SAA7134_INPUT_COMPOSITE,
2807 .vmux = 3, 2719 .vmux = 3,
2808 .amux = LINE2, /* unconfirmed, taken from Philips driver */ 2720 .amux = LINE2, /* unconfirmed, taken from Philips driver */
2809 },{ 2721 },{
2810 .name = name_comp2, 2722 .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
2811 .vmux = 0, /* untested, Composite over S-Video */ 2723 .vmux = 0, /* untested */
2812 .amux = LINE2, 2724 .amux = LINE2,
2813 },{ 2725 },{
2814 .name = name_svideo, 2726 .type = SAA7134_INPUT_SVIDEO,
2815 .vmux = 8, 2727 .vmux = 8,
2816 .amux = LINE2, 2728 .amux = LINE2,
2817 }}, 2729 }},
2818 .radio = { 2730 .radio = {
2819 .name = name_radio, 2731 .type = SAA7134_INPUT_RADIO,
2820 .amux = TV, 2732 .amux = TV,
2821 .gpio = 0x0200000, 2733 .gpio = 0x0200000,
2822 }, 2734 },
@@ -2834,17 +2746,16 @@ struct saa7134_board saa7134_boards[] = {
2834 .radio_addr = ADDR_UNSET, 2746 .radio_addr = ADDR_UNSET,
2835 .gpiomask = 0x80200000, 2747 .gpiomask = 0x80200000,
2836 .inputs = {{ 2748 .inputs = {{
2837 .name = name_tv, 2749 .type = SAA7134_INPUT_TV,
2838 .vmux = 1, 2750 .vmux = 1,
2839 .amux = TV, 2751 .amux = TV,
2840 .tv = 1,
2841 },{ 2752 },{
2842 .name = name_svideo, /* NOT tested */ 2753 .type = SAA7134_INPUT_SVIDEO, /* NOT tested */
2843 .vmux = 8, 2754 .vmux = 8,
2844 .amux = LINE1, 2755 .amux = LINE1,
2845 }}, 2756 }},
2846 .radio = { 2757 .radio = {
2847 .name = name_radio, 2758 .type = SAA7134_INPUT_RADIO,
2848 .amux = TV, 2759 .amux = TV,
2849 .gpio = 0x0200000, 2760 .gpio = 0x0200000,
2850 }, 2761 },
@@ -2861,26 +2772,25 @@ struct saa7134_board saa7134_boards[] = {
2861 .gpiomask = 0x00200000, 2772 .gpiomask = 0x00200000,
2862 .mpeg = SAA7134_MPEG_DVB, 2773 .mpeg = SAA7134_MPEG_DVB,
2863 .inputs = {{ 2774 .inputs = {{
2864 .name = name_tv, /* Analog broadcast/cable TV */ 2775 .type = SAA7134_INPUT_TV, /* Analog broadcast/cable TV */
2865 .vmux = 1, 2776 .vmux = 1,
2866 .amux = TV, 2777 .amux = TV,
2867 .gpio = 0x200000, /* GPIO21=High for TV input */ 2778 .gpio = 0x200000, /* GPIO21=High for TV input */
2868 .tv = 1,
2869 },{ 2779 },{
2870 .name = name_svideo, /* S-Video signal on S-Video input */ 2780 .type = SAA7134_INPUT_SVIDEO,
2871 .vmux = 8, 2781 .vmux = 8,
2872 .amux = LINE2, 2782 .amux = LINE2,
2873 },{ 2783 },{
2874 .name = name_comp1, /* Composite signal on S-Video input */ 2784 .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
2875 .vmux = 0, 2785 .vmux = 0,
2876 .amux = LINE2, 2786 .amux = LINE2,
2877 },{ 2787 },{
2878 .name = name_comp2, /* Composite input */ 2788 .type = SAA7134_INPUT_COMPOSITE2,
2879 .vmux = 3, 2789 .vmux = 3,
2880 .amux = LINE2, 2790 .amux = LINE2,
2881 }}, 2791 }},
2882 .radio = { 2792 .radio = {
2883 .name = name_radio, 2793 .type = SAA7134_INPUT_RADIO,
2884 .amux = TV, 2794 .amux = TV,
2885 .gpio = 0x000000, /* GPIO21=Low for FM radio antenna */ 2795 .gpio = 0x000000, /* GPIO21=Low for FM radio antenna */
2886 }, 2796 },
@@ -2894,11 +2804,11 @@ struct saa7134_board saa7134_boards[] = {
2894 .radio_addr = ADDR_UNSET, 2804 .radio_addr = ADDR_UNSET,
2895 .mpeg = SAA7134_MPEG_DVB, 2805 .mpeg = SAA7134_MPEG_DVB,
2896 .inputs = {{ 2806 .inputs = {{
2897 .name = name_comp1, 2807 .type = SAA7134_INPUT_COMPOSITE1,
2898 .vmux = 1, 2808 .vmux = 1,
2899 .amux = LINE1, 2809 .amux = LINE1,
2900 },{ 2810 },{
2901 .name = name_svideo, 2811 .type = SAA7134_INPUT_SVIDEO,
2902 .vmux = 8, 2812 .vmux = 8,
2903 .amux = LINE1, 2813 .amux = LINE1,
2904 }}, 2814 }},
@@ -2914,11 +2824,11 @@ struct saa7134_board saa7134_boards[] = {
2914 .radio_addr = ADDR_UNSET, 2824 .radio_addr = ADDR_UNSET,
2915 .mpeg = SAA7134_MPEG_DVB, 2825 .mpeg = SAA7134_MPEG_DVB,
2916 .inputs = {{ 2826 .inputs = {{
2917 .name = name_comp1, /* Composite input */ 2827 .type = SAA7134_INPUT_COMPOSITE1,
2918 .vmux = 3, 2828 .vmux = 3,
2919 .amux = LINE2, 2829 .amux = LINE2,
2920 },{ 2830 },{
2921 .name = name_svideo, /* S-Video signal on S-Video input */ 2831 .type = SAA7134_INPUT_SVIDEO,
2922 .vmux = 8, 2832 .vmux = 8,
2923 .amux = LINE2, 2833 .amux = LINE2,
2924 }}, 2834 }},
@@ -2933,10 +2843,9 @@ struct saa7134_board saa7134_boards[] = {
2933 .mpeg = SAA7134_MPEG_DVB, 2843 .mpeg = SAA7134_MPEG_DVB,
2934 .gpiomask = 0x00600000, /* Bit 21 0=Radio, Bit 22 0=TV */ 2844 .gpiomask = 0x00600000, /* Bit 21 0=Radio, Bit 22 0=TV */
2935 .inputs = {{ 2845 .inputs = {{
2936 .name = name_tv, 2846 .type = SAA7134_INPUT_TV,
2937 .vmux = 1, 2847 .vmux = 1,
2938 .amux = TV, 2848 .amux = TV,
2939 .tv = 1,
2940 .gpio = 0x00200000, 2849 .gpio = 0x00200000,
2941 }}, 2850 }},
2942 }, 2851 },
@@ -2950,25 +2859,24 @@ struct saa7134_board saa7134_boards[] = {
2950 .mpeg = SAA7134_MPEG_DVB, 2859 .mpeg = SAA7134_MPEG_DVB,
2951 .gpiomask = 1 << 21, 2860 .gpiomask = 1 << 21,
2952 .inputs = {{ 2861 .inputs = {{
2953 .name = name_tv, 2862 .type = SAA7134_INPUT_TV,
2954 .vmux = 1, 2863 .vmux = 1,
2955 .amux = TV, 2864 .amux = TV,
2956 .tv = 1,
2957 },{ 2865 },{
2958 .name = name_comp1, 2866 .type = SAA7134_INPUT_COMPOSITE1,
2959 .vmux = 3, 2867 .vmux = 3,
2960 .amux = LINE1, 2868 .amux = LINE1,
2961 },{ 2869 },{
2962 .name = name_comp2, 2870 .type = SAA7134_INPUT_COMPOSITE2,
2963 .vmux = 0, 2871 .vmux = 0,
2964 .amux = LINE1, 2872 .amux = LINE1,
2965 },{ 2873 },{
2966 .name = name_svideo, 2874 .type = SAA7134_INPUT_SVIDEO,
2967 .vmux = 8, 2875 .vmux = 8,
2968 .amux = LINE1, 2876 .amux = LINE1,
2969 }}, 2877 }},
2970 .radio = { 2878 .radio = {
2971 .name = name_radio, 2879 .type = SAA7134_INPUT_RADIO,
2972 .amux = TV, 2880 .amux = TV,
2973 .gpio = 0x0200000, 2881 .gpio = 0x0200000,
2974 }, 2882 },
@@ -2983,21 +2891,20 @@ struct saa7134_board saa7134_boards[] = {
2983 .mpeg = SAA7134_MPEG_DVB, 2891 .mpeg = SAA7134_MPEG_DVB,
2984 .gpiomask = 1 << 21, 2892 .gpiomask = 1 << 21,
2985 .inputs = {{ 2893 .inputs = {{
2986 .name = name_tv, 2894 .type = SAA7134_INPUT_TV,
2987 .vmux = 1, 2895 .vmux = 1,
2988 .amux = TV, 2896 .amux = TV,
2989 .tv = 1,
2990 },{ 2897 },{
2991 .name = name_comp1, 2898 .type = SAA7134_INPUT_COMPOSITE1,
2992 .vmux = 3, 2899 .vmux = 3,
2993 .amux = LINE1, 2900 .amux = LINE1,
2994 },{ 2901 },{
2995 .name = name_svideo, 2902 .type = SAA7134_INPUT_SVIDEO,
2996 .vmux = 8, 2903 .vmux = 8,
2997 .amux = LINE1, 2904 .amux = LINE1,
2998 }}, 2905 }},
2999 .radio = { 2906 .radio = {
3000 .name = name_radio, 2907 .type = SAA7134_INPUT_RADIO,
3001 .amux = TV, 2908 .amux = TV,
3002 .gpio = 0x0200000, 2909 .gpio = 0x0200000,
3003 }, 2910 },
@@ -3012,16 +2919,15 @@ struct saa7134_board saa7134_boards[] = {
3012 .tda9887_conf = TDA9887_PRESENT, 2919 .tda9887_conf = TDA9887_PRESENT,
3013 .mpeg = SAA7134_MPEG_DVB, 2920 .mpeg = SAA7134_MPEG_DVB,
3014 .inputs = {{ 2921 .inputs = {{
3015 .name = name_tv, 2922 .type = SAA7134_INPUT_TV,
3016 .vmux = 1, 2923 .vmux = 1,
3017 .amux = TV, 2924 .amux = TV,
3018 .tv = 1,
3019 },{ 2925 },{
3020 .name = name_comp1, 2926 .type = SAA7134_INPUT_COMPOSITE1,
3021 .vmux = 3, 2927 .vmux = 3,
3022 .amux = LINE2, 2928 .amux = LINE2,
3023 },{ 2929 },{
3024 .name = name_svideo, 2930 .type = SAA7134_INPUT_SVIDEO,
3025 .vmux = 8, 2931 .vmux = 8,
3026 .amux = LINE2, 2932 .amux = LINE2,
3027 }}, 2933 }},
@@ -3052,17 +2958,16 @@ struct saa7134_board saa7134_boards[] = {
3052 .tda9887_conf = TDA9887_PRESENT, 2958 .tda9887_conf = TDA9887_PRESENT,
3053 .gpiomask = 0xca60000, 2959 .gpiomask = 0xca60000,
3054 .inputs = {{ 2960 .inputs = {{
3055 .name = name_tv, 2961 .type = SAA7134_INPUT_TV,
3056 .vmux = 4, 2962 .vmux = 4,
3057 .amux = TV, 2963 .amux = TV,
3058 .tv = 1,
3059 .gpio = 0x04a61000, 2964 .gpio = 0x04a61000,
3060 },{ 2965 },{
3061 .name = name_comp2, /* Composite SVIDEO (B/W if signal is carried with SVIDEO) */ 2966 .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
3062 .vmux = 1, 2967 .vmux = 1,
3063 .amux = LINE2, 2968 .amux = LINE2,
3064 },{ 2969 },{
3065 .name = name_svideo, 2970 .type = SAA7134_INPUT_SVIDEO,
3066 .vmux = 9, /* 9 is correct as S-VIDEO1 according to a169.inf! */ 2971 .vmux = 9, /* 9 is correct as S-VIDEO1 according to a169.inf! */
3067 .amux = LINE1, 2972 .amux = LINE1,
3068 }}, 2973 }},
@@ -3086,26 +2991,25 @@ struct saa7134_board saa7134_boards[] = {
3086 .mpeg = SAA7134_MPEG_DVB, 2991 .mpeg = SAA7134_MPEG_DVB,
3087 .gpiomask = 0x00600000, /* Bit 21 0=Radio, Bit 22 0=TV */ 2992 .gpiomask = 0x00600000, /* Bit 21 0=Radio, Bit 22 0=TV */
3088 .inputs = {{ 2993 .inputs = {{
3089 .name = name_tv, 2994 .type = SAA7134_INPUT_TV,
3090 .vmux = 1, 2995 .vmux = 1,
3091 .amux = TV, 2996 .amux = TV,
3092 .gpio = 0x200000, /* GPIO21=High for TV input */ 2997 .gpio = 0x200000, /* GPIO21=High for TV input */
3093 .tv = 1,
3094 },{ 2998 },{
3095 .name = name_svideo, /* S-Video signal on S-Video input */ 2999 .type = SAA7134_INPUT_SVIDEO,
3096 .vmux = 8, 3000 .vmux = 8,
3097 .amux = LINE2, 3001 .amux = LINE2,
3098 },{ 3002 },{
3099 .name = name_comp1, /* Composite signal on S-Video input */ 3003 .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
3100 .vmux = 0, 3004 .vmux = 0,
3101 .amux = LINE2, 3005 .amux = LINE2,
3102 },{ 3006 },{
3103 .name = name_comp2, /* Composite input */ 3007 .type = SAA7134_INPUT_COMPOSITE,
3104 .vmux = 3, 3008 .vmux = 3,
3105 .amux = LINE2, 3009 .amux = LINE2,
3106 }}, 3010 }},
3107 .radio = { 3011 .radio = {
3108 .name = name_radio, 3012 .type = SAA7134_INPUT_RADIO,
3109 .amux = TV, 3013 .amux = TV,
3110 .gpio = 0x000000, /* GPIO21=Low for FM radio antenna */ 3014 .gpio = 0x000000, /* GPIO21=Low for FM radio antenna */
3111 }, 3015 },
@@ -3121,40 +3025,38 @@ struct saa7134_board saa7134_boards[] = {
3121 3025
3122 .gpiomask = 0xe000, 3026 .gpiomask = 0xe000,
3123 .inputs = {{ 3027 .inputs = {{
3124 .name = name_tv, 3028 .type = SAA7134_INPUT_TV,
3125 .vmux = 1, 3029 .vmux = 1,
3126 .amux = TV, 3030 .amux = TV,
3127 .gpio = 0x8000, 3031 .gpio = 0x8000,
3128 .tv = 1,
3129 },{ 3032 },{
3130 .name = name_tv_mono, 3033 .type = SAA7134_INPUT_TV_MONO,
3131 .vmux = 1, 3034 .vmux = 1,
3132 .amux = LINE2, 3035 .amux = LINE2,
3133 .gpio = 0x0000, 3036 .gpio = 0x0000,
3134 .tv = 1,
3135 },{ 3037 },{
3136 .name = name_comp1, 3038 .type = SAA7134_INPUT_COMPOSITE1,
3137 .vmux = 0, 3039 .vmux = 0,
3138 .amux = LINE2, 3040 .amux = LINE2,
3139 .gpio = 0x4000, 3041 .gpio = 0x4000,
3140 },{ 3042 },{
3141 .name = name_comp2, 3043 .type = SAA7134_INPUT_COMPOSITE2,
3142 .vmux = 3, 3044 .vmux = 3,
3143 .amux = LINE2, 3045 .amux = LINE2,
3144 .gpio = 0x4000, 3046 .gpio = 0x4000,
3145 },{ 3047 },{
3146 .name = name_svideo, 3048 .type = SAA7134_INPUT_SVIDEO,
3147 .vmux = 8, 3049 .vmux = 8,
3148 .amux = LINE2, 3050 .amux = LINE2,
3149 .gpio = 0x4000, 3051 .gpio = 0x4000,
3150 }}, 3052 }},
3151 .radio = { 3053 .radio = {
3152 .name = name_radio, 3054 .type = SAA7134_INPUT_RADIO,
3153 .amux = LINE2, 3055 .amux = LINE2,
3154 .gpio = 0x2000, 3056 .gpio = 0x2000,
3155 }, 3057 },
3156 .mute = { 3058 .mute = {
3157 .name = name_mute, 3059 .type = SAA7134_INPUT_MUTE,
3158 .amux = TV, 3060 .amux = TV,
3159 .gpio = 0x8000, 3061 .gpio = 0x8000,
3160 }, 3062 },
@@ -3168,16 +3070,15 @@ struct saa7134_board saa7134_boards[] = {
3168 .radio_addr = ADDR_UNSET, 3070 .radio_addr = ADDR_UNSET,
3169 .mpeg = SAA7134_MPEG_DVB, 3071 .mpeg = SAA7134_MPEG_DVB,
3170 .inputs = {{ 3072 .inputs = {{
3171 .name = name_tv, 3073 .type = SAA7134_INPUT_TV,
3172 .vmux = 1, 3074 .vmux = 1,
3173 .amux = TV, 3075 .amux = TV,
3174 .tv = 1,
3175 },{ 3076 },{
3176 .name = name_comp1, 3077 .type = SAA7134_INPUT_COMPOSITE1,
3177 .vmux = 0, 3078 .vmux = 0,
3178 .amux = LINE1, 3079 .amux = LINE1,
3179 },{ 3080 },{
3180 .name = name_svideo, 3081 .type = SAA7134_INPUT_SVIDEO,
3181 .vmux = 8, 3082 .vmux = 8,
3182 .amux = LINE1, 3083 .amux = LINE1,
3183 }}, 3084 }},
@@ -3193,11 +3094,11 @@ struct saa7134_board saa7134_boards[] = {
3193 .radio_addr = ADDR_UNSET, 3094 .radio_addr = ADDR_UNSET,
3194 .mpeg = SAA7134_MPEG_DVB, 3095 .mpeg = SAA7134_MPEG_DVB,
3195 .inputs = {{ 3096 .inputs = {{
3196 .name = name_comp1, /* Composite input */ 3097 .type = SAA7134_INPUT_COMPOSITE1,
3197 .vmux = 3, 3098 .vmux = 3,
3198 .amux = LINE1, 3099 .amux = LINE1,
3199 },{ 3100 },{
3200 .name = name_svideo, /* S-Video signal on S-Video input */ 3101 .type = SAA7134_INPUT_SVIDEO,
3201 .vmux = 8, 3102 .vmux = 8,
3202 .amux = LINE1, 3103 .amux = LINE1,
3203 }}, 3104 }},
@@ -3211,25 +3112,24 @@ struct saa7134_board saa7134_boards[] = {
3211 .radio_addr = ADDR_UNSET, 3112 .radio_addr = ADDR_UNSET,
3212 .tda9887_conf = TDA9887_PRESENT, 3113 .tda9887_conf = TDA9887_PRESENT,
3213 .inputs = {{ 3114 .inputs = {{
3214 .name = name_tv, 3115 .type = SAA7134_INPUT_TV,
3215 .vmux = 1, 3116 .vmux = 1,
3216 .amux = LINE2, 3117 .amux = LINE2,
3217 .tv = 1,
3218 },{ 3118 },{
3219 .name = name_comp1, 3119 .type = SAA7134_INPUT_COMPOSITE1,
3220 .vmux = 0, 3120 .vmux = 0,
3221 .amux = LINE2, 3121 .amux = LINE2,
3222 },{ 3122 },{
3223 .name = name_comp2, 3123 .type = SAA7134_INPUT_COMPOSITE2,
3224 .vmux = 3, 3124 .vmux = 3,
3225 .amux = LINE2, 3125 .amux = LINE2,
3226 },{ 3126 },{
3227 .name = name_svideo, 3127 .type = SAA7134_INPUT_SVIDEO,
3228 .vmux = 8, 3128 .vmux = 8,
3229 .amux = LINE2, 3129 .amux = LINE2,
3230 }}, 3130 }},
3231 .mute = { 3131 .mute = {
3232 .name = name_mute, 3132 .type = SAA7134_INPUT_MUTE,
3233 .amux = LINE1, 3133 .amux = LINE1,
3234 }, 3134 },
3235 }, 3135 },
@@ -3244,21 +3144,20 @@ struct saa7134_board saa7134_boards[] = {
3244 .tda9887_conf = TDA9887_PRESENT, 3144 .tda9887_conf = TDA9887_PRESENT,
3245 .mpeg = SAA7134_MPEG_DVB, 3145 .mpeg = SAA7134_MPEG_DVB,
3246 .inputs = {{ 3146 .inputs = {{
3247 .name = name_tv, 3147 .type = SAA7134_INPUT_TV,
3248 .vmux = 1, 3148 .vmux = 1,
3249 .amux = TV, 3149 .amux = TV,
3250 .tv = 1,
3251 },{ 3150 },{
3252 .name = name_comp1, 3151 .type = SAA7134_INPUT_COMPOSITE1,
3253 .vmux = 3, 3152 .vmux = 3,
3254 .amux = LINE2, 3153 .amux = LINE2,
3255 },{ 3154 },{
3256 .name = name_svideo, 3155 .type = SAA7134_INPUT_SVIDEO,
3257 .vmux = 8, 3156 .vmux = 8,
3258 .amux = LINE1, 3157 .amux = LINE1,
3259 }}, 3158 }},
3260 .radio = { 3159 .radio = {
3261 .name = name_radio, 3160 .type = SAA7134_INPUT_RADIO,
3262 .amux = LINE1, 3161 .amux = LINE1,
3263 }, 3162 },
3264 }, 3163 },
@@ -3272,21 +3171,20 @@ struct saa7134_board saa7134_boards[] = {
3272 .tda9887_conf = TDA9887_PRESENT| TDA9887_PORT1_ACTIVE | TDA9887_PORT2_ACTIVE, 3171 .tda9887_conf = TDA9887_PRESENT| TDA9887_PORT1_ACTIVE | TDA9887_PORT2_ACTIVE,
3273 .mpeg = SAA7134_MPEG_DVB, 3172 .mpeg = SAA7134_MPEG_DVB,
3274 .inputs = {{ 3173 .inputs = {{
3275 .name = name_tv, 3174 .type = SAA7134_INPUT_TV,
3276 .vmux = 3, 3175 .vmux = 3,
3277 .amux = TV, 3176 .amux = TV,
3278 .tv = 1,
3279 },{ 3177 },{
3280 .name = name_comp1, 3178 .type = SAA7134_INPUT_COMPOSITE1,
3281 .vmux = 4, 3179 .vmux = 4,
3282 .amux = LINE2, 3180 .amux = LINE2,
3283 },{ 3181 },{
3284 .name = name_svideo, 3182 .type = SAA7134_INPUT_SVIDEO,
3285 .vmux = 8, 3183 .vmux = 8,
3286 .amux = LINE2, 3184 .amux = LINE2,
3287 }}, 3185 }},
3288 .radio = { 3186 .radio = {
3289 .name = name_radio, 3187 .type = SAA7134_INPUT_RADIO,
3290 .amux = LINE1, 3188 .amux = LINE1,
3291 }, 3189 },
3292 }, 3190 },
@@ -3301,25 +3199,24 @@ struct saa7134_board saa7134_boards[] = {
3301 .mpeg = SAA7134_MPEG_DVB, 3199 .mpeg = SAA7134_MPEG_DVB,
3302 .gpiomask = 0x000200000, 3200 .gpiomask = 0x000200000,
3303 .inputs = {{ 3201 .inputs = {{
3304 .name = name_tv, 3202 .type = SAA7134_INPUT_TV,
3305 .vmux = 4, 3203 .vmux = 4,
3306 .amux = TV, 3204 .amux = TV,
3307 .tv = 1,
3308 },{ 3205 },{
3309 .name = name_comp1, 3206 .type = SAA7134_INPUT_COMPOSITE1,
3310 .vmux = 1, 3207 .vmux = 1,
3311 .amux = LINE2, 3208 .amux = LINE2,
3312 },{ 3209 },{
3313 .name = name_comp2, 3210 .type = SAA7134_INPUT_COMPOSITE2,
3314 .vmux = 0, 3211 .vmux = 0,
3315 .amux = LINE2, 3212 .amux = LINE2,
3316 },{ 3213 },{
3317 .name = name_svideo, 3214 .type = SAA7134_INPUT_SVIDEO,
3318 .vmux = 8, 3215 .vmux = 8,
3319 .amux = LINE2, 3216 .amux = LINE2,
3320 }}, 3217 }},
3321 .radio = { 3218 .radio = {
3322 .name = name_radio, 3219 .type = SAA7134_INPUT_RADIO,
3323 .amux = TV, 3220 .amux = TV,
3324 .gpio = 0x0200000, 3221 .gpio = 0x0200000,
3325 }, 3222 },
@@ -3335,34 +3232,33 @@ struct saa7134_board saa7134_boards[] = {
3335 .tda9887_conf = TDA9887_PRESENT, 3232 .tda9887_conf = TDA9887_PRESENT,
3336 .gpiomask = 0x03, 3233 .gpiomask = 0x03,
3337 .inputs = {{ 3234 .inputs = {{
3338 .name = name_tv, 3235 .type = SAA7134_INPUT_TV,
3339 .vmux = 1, 3236 .vmux = 1,
3340 .amux = TV, 3237 .amux = TV,
3341 .tv = 1,
3342 .gpio = 0x00, 3238 .gpio = 0x00,
3343 },{ 3239 },{
3344 .name = name_comp1, 3240 .type = SAA7134_INPUT_COMPOSITE1,
3345 .vmux = 0, 3241 .vmux = 0,
3346 .amux = LINE2, 3242 .amux = LINE2,
3347 .gpio = 0x00, 3243 .gpio = 0x00,
3348 },{ 3244 },{
3349 .name = name_comp2, 3245 .type = SAA7134_INPUT_COMPOSITE2,
3350 .vmux = 3, 3246 .vmux = 3,
3351 .amux = LINE2, 3247 .amux = LINE2,
3352 .gpio = 0x00, 3248 .gpio = 0x00,
3353 },{ 3249 },{
3354 .name = name_svideo, 3250 .type = SAA7134_INPUT_SVIDEO,
3355 .vmux = 8, 3251 .vmux = 8,
3356 .amux = LINE2, 3252 .amux = LINE2,
3357 .gpio = 0x00, 3253 .gpio = 0x00,
3358 }}, 3254 }},
3359 .radio = { 3255 .radio = {
3360 .name = name_radio, 3256 .type = SAA7134_INPUT_RADIO,
3361 .amux = LINE2, 3257 .amux = LINE2,
3362 .gpio = 0x01, 3258 .gpio = 0x01,
3363 }, 3259 },
3364 .mute = { 3260 .mute = {
3365 .name = name_mute, 3261 .type = SAA7134_INPUT_MUTE,
3366 .amux = LINE1, 3262 .amux = LINE1,
3367 .gpio = 0x00, 3263 .gpio = 0x00,
3368 }, 3264 },
@@ -3378,16 +3274,15 @@ struct saa7134_board saa7134_boards[] = {
3378 .tda9887_conf = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE, 3274 .tda9887_conf = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE,
3379 .mpeg = SAA7134_MPEG_DVB, 3275 .mpeg = SAA7134_MPEG_DVB,
3380 .inputs = {{ 3276 .inputs = {{
3381 .name = name_tv, 3277 .type = SAA7134_INPUT_TV,
3382 .vmux = 3, 3278 .vmux = 3,
3383 .amux = TV, 3279 .amux = TV,
3384 .tv = 1,
3385 },{ 3280 },{
3386 .name = name_comp1, 3281 .type = SAA7134_INPUT_COMPOSITE1,
3387 .vmux = 1, 3282 .vmux = 1,
3388 .amux = LINE2, 3283 .amux = LINE2,
3389 },{ 3284 },{
3390 .name = name_svideo, 3285 .type = SAA7134_INPUT_SVIDEO,
3391 .vmux = 8, 3286 .vmux = 8,
3392 .amux = LINE2, 3287 .amux = LINE2,
3393 }}, 3288 }},
@@ -3405,22 +3300,21 @@ struct saa7134_board saa7134_boards[] = {
3405 .mpeg = SAA7134_MPEG_DVB, 3300 .mpeg = SAA7134_MPEG_DVB,
3406 .gpiomask = 0x0200100, 3301 .gpiomask = 0x0200100,
3407 .inputs = {{ 3302 .inputs = {{
3408 .name = name_tv, 3303 .type = SAA7134_INPUT_TV,
3409 .vmux = 1, 3304 .vmux = 1,
3410 .amux = TV, 3305 .amux = TV,
3411 .tv = 1,
3412 .gpio = 0x0000100, 3306 .gpio = 0x0000100,
3413 }, { 3307 }, {
3414 .name = name_comp1, 3308 .type = SAA7134_INPUT_COMPOSITE1,
3415 .vmux = 3, 3309 .vmux = 3,
3416 .amux = LINE1, 3310 .amux = LINE1,
3417 }, { 3311 }, {
3418 .name = name_svideo, 3312 .type = SAA7134_INPUT_SVIDEO,
3419 .vmux = 8, 3313 .vmux = 8,
3420 .amux = LINE1, 3314 .amux = LINE1,
3421 } }, 3315 } },
3422 .radio = { 3316 .radio = {
3423 .name = name_radio, 3317 .type = SAA7134_INPUT_RADIO,
3424 .amux = TV, 3318 .amux = TV,
3425 .gpio = 0x0200100, 3319 .gpio = 0x0200100,
3426 }, 3320 },
@@ -3438,22 +3332,21 @@ struct saa7134_board saa7134_boards[] = {
3438 .ts_force_val = 1, 3332 .ts_force_val = 1,
3439 .gpiomask = 0x0800100, /* GPIO 21 is an INPUT */ 3333 .gpiomask = 0x0800100, /* GPIO 21 is an INPUT */
3440 .inputs = {{ 3334 .inputs = {{
3441 .name = name_tv, 3335 .type = SAA7134_INPUT_TV,
3442 .vmux = 1, 3336 .vmux = 1,
3443 .amux = TV, 3337 .amux = TV,
3444 .tv = 1,
3445 .gpio = 0x0000100, 3338 .gpio = 0x0000100,
3446 }, { 3339 }, {
3447 .name = name_comp1, 3340 .type = SAA7134_INPUT_COMPOSITE1,
3448 .vmux = 3, 3341 .vmux = 3,
3449 .amux = LINE1, 3342 .amux = LINE1,
3450 }, { 3343 }, {
3451 .name = name_svideo, 3344 .type = SAA7134_INPUT_SVIDEO,
3452 .vmux = 8, 3345 .vmux = 8,
3453 .amux = LINE1, 3346 .amux = LINE1,
3454 } }, 3347 } },
3455 .radio = { 3348 .radio = {
3456 .name = name_radio, 3349 .type = SAA7134_INPUT_RADIO,
3457 .amux = TV, 3350 .amux = TV,
3458 .gpio = 0x0800100, /* GPIO 23 HI for FM */ 3351 .gpio = 0x0800100, /* GPIO 23 HI for FM */
3459 }, 3352 },
@@ -3470,22 +3363,21 @@ struct saa7134_board saa7134_boards[] = {
3470 .ts_type = SAA7134_MPEG_TS_SERIAL, 3363 .ts_type = SAA7134_MPEG_TS_SERIAL,
3471 .gpiomask = 0x0800100, /* GPIO 21 is an INPUT */ 3364 .gpiomask = 0x0800100, /* GPIO 21 is an INPUT */
3472 .inputs = {{ 3365 .inputs = {{
3473 .name = name_tv, 3366 .type = SAA7134_INPUT_TV,
3474 .vmux = 1, 3367 .vmux = 1,
3475 .amux = TV, 3368 .amux = TV,
3476 .tv = 1,
3477 .gpio = 0x0000100, 3369 .gpio = 0x0000100,
3478 }, { 3370 }, {
3479 .name = name_comp1, 3371 .type = SAA7134_INPUT_COMPOSITE1,
3480 .vmux = 3, 3372 .vmux = 3,
3481 .amux = LINE1, 3373 .amux = LINE1,
3482 }, { 3374 }, {
3483 .name = name_svideo, 3375 .type = SAA7134_INPUT_SVIDEO,
3484 .vmux = 8, 3376 .vmux = 8,
3485 .amux = LINE1, 3377 .amux = LINE1,
3486 } }, 3378 } },
3487 .radio = { 3379 .radio = {
3488 .name = name_radio, 3380 .type = SAA7134_INPUT_RADIO,
3489 .amux = TV, 3381 .amux = TV,
3490 .gpio = 0x0800100, /* GPIO 23 HI for FM */ 3382 .gpio = 0x0800100, /* GPIO 23 HI for FM */
3491 }, 3383 },
@@ -3499,16 +3391,15 @@ struct saa7134_board saa7134_boards[] = {
3499 .radio_addr = ADDR_UNSET, 3391 .radio_addr = ADDR_UNSET,
3500 .mpeg = SAA7134_MPEG_DVB, 3392 .mpeg = SAA7134_MPEG_DVB,
3501 .inputs = {{ 3393 .inputs = {{
3502 .name = name_tv, 3394 .type = SAA7134_INPUT_TV,
3503 .vmux = 1, 3395 .vmux = 1,
3504 .amux = TV, 3396 .amux = TV,
3505 .tv = 1,
3506 },{ 3397 },{
3507 .name = name_comp1, 3398 .type = SAA7134_INPUT_COMPOSITE1,
3508 .vmux = 0, 3399 .vmux = 0,
3509 .amux = LINE1, 3400 .amux = LINE1,
3510 },{ 3401 },{
3511 .name = name_svideo, 3402 .type = SAA7134_INPUT_SVIDEO,
3512 .vmux = 6, 3403 .vmux = 6,
3513 .amux = LINE1, 3404 .amux = LINE1,
3514 }}, 3405 }},
@@ -3523,33 +3414,31 @@ struct saa7134_board saa7134_boards[] = {
3523 .tuner_addr = ADDR_UNSET, 3414 .tuner_addr = ADDR_UNSET,
3524 .radio_addr = ADDR_UNSET, 3415 .radio_addr = ADDR_UNSET,
3525 .inputs = {{ 3416 .inputs = {{
3526 .name = name_tv, 3417 .type = SAA7134_INPUT_TV,
3527 .vmux = 1, 3418 .vmux = 1,
3528 .amux = 3, 3419 .amux = 3,
3529 .tv = 1,
3530 },{ 3420 },{
3531 .name = name_tv_mono, 3421 .type = SAA7134_INPUT_TV_MONO,
3532 .vmux = 7, 3422 .vmux = 7,
3533 .amux = 4, 3423 .amux = 4,
3534 .tv = 1,
3535 },{ 3424 },{
3536 .name = name_comp1, 3425 .type = SAA7134_INPUT_COMPOSITE1,
3537 .vmux = 3, 3426 .vmux = 3,
3538 .amux = 2, 3427 .amux = 2,
3539 },{ 3428 },{
3540 .name = name_svideo, 3429 .type = SAA7134_INPUT_SVIDEO,
3541 .vmux = 0, 3430 .vmux = 0,
3542 .amux = 2, 3431 .amux = 2,
3543 }}, 3432 }},
3544 .radio = { 3433 .radio = {
3545 .name = name_radio, 3434 .type = SAA7134_INPUT_RADIO,
3546 .amux = LINE2, 3435 .amux = LINE2,
3547/* .gpio = 0x00300001,*/ 3436/* .gpio = 0x00300001,*/
3548 .gpio = 0x20000, 3437 .gpio = 0x20000,
3549 3438
3550 }, 3439 },
3551 .mute = { 3440 .mute = {
3552 .name = name_mute, 3441 .type = SAA7134_INPUT_MUTE,
3553 .amux = 0, 3442 .amux = 0,
3554 }, 3443 },
3555 }, 3444 },
@@ -3562,32 +3451,30 @@ struct saa7134_board saa7134_boards[] = {
3562 .tuner_addr = ADDR_UNSET, 3451 .tuner_addr = ADDR_UNSET,
3563 .radio_addr = ADDR_UNSET, 3452 .radio_addr = ADDR_UNSET,
3564 .inputs = {{ 3453 .inputs = {{
3565 .name = name_tv, 3454 .type = SAA7134_INPUT_TV,
3566 .vmux = 1, 3455 .vmux = 1,
3567 .amux = 3, 3456 .amux = 3,
3568 .tv = 1,
3569 },{ 3457 },{
3570 .name = name_tv_mono, 3458 .type = SAA7134_INPUT_TV_MONO,
3571 .vmux = 7, 3459 .vmux = 7,
3572 .amux = 4, 3460 .amux = 4,
3573 .tv = 1,
3574 },{ 3461 },{
3575 .name = name_comp1, 3462 .type = SAA7134_INPUT_COMPOSITE1,
3576 .vmux = 3, 3463 .vmux = 3,
3577 .amux = 2, 3464 .amux = 2,
3578 },{ 3465 },{
3579 .name = name_svideo, 3466 .type = SAA7134_INPUT_SVIDEO,
3580 .vmux = 0, 3467 .vmux = 0,
3581 .amux = 2, 3468 .amux = 2,
3582 }}, 3469 }},
3583 .radio = { 3470 .radio = {
3584 .name = name_radio, 3471 .type = SAA7134_INPUT_RADIO,
3585 .amux = LINE2, 3472 .amux = LINE2,
3586 .gpio = 0x20000, 3473 .gpio = 0x20000,
3587 3474
3588 }, 3475 },
3589 .mute = { 3476 .mute = {
3590 .name = name_mute, 3477 .type = SAA7134_INPUT_MUTE,
3591 .amux = 0, 3478 .amux = 0,
3592 }, 3479 },
3593 }, 3480 },
@@ -3600,29 +3487,28 @@ struct saa7134_board saa7134_boards[] = {
3600 .radio_addr = ADDR_UNSET, 3487 .radio_addr = ADDR_UNSET,
3601 .gpiomask = 0x7000, 3488 .gpiomask = 0x7000,
3602 .inputs = { { 3489 .inputs = { {
3603 .name = name_tv, 3490 .type = SAA7134_INPUT_TV,
3604 .vmux = 1, 3491 .vmux = 1,
3605 .amux = 1, 3492 .amux = 1,
3606 .tv = 1,
3607 .gpio = 0x50000, 3493 .gpio = 0x50000,
3608 }, { 3494 }, {
3609 .name = name_comp1, 3495 .type = SAA7134_INPUT_COMPOSITE1,
3610 .vmux = 3, 3496 .vmux = 3,
3611 .amux = 2, 3497 .amux = 2,
3612 .gpio = 0x2000, 3498 .gpio = 0x2000,
3613 }, { 3499 }, {
3614 .name = name_svideo, 3500 .type = SAA7134_INPUT_SVIDEO,
3615 .vmux = 8, 3501 .vmux = 8,
3616 .amux = 2, 3502 .amux = 2,
3617 .gpio = 0x2000, 3503 .gpio = 0x2000,
3618 } }, 3504 } },
3619 .radio = { 3505 .radio = {
3620 .name = name_radio, 3506 .type = SAA7134_INPUT_RADIO,
3621 .vmux = 1, 3507 .vmux = 1,
3622 .amux = 1, 3508 .amux = 1,
3623 }, 3509 },
3624 .mute = { 3510 .mute = {
3625 .name = name_mute, 3511 .type = SAA7134_INPUT_MUTE,
3626 .gpio = 0xf000, 3512 .gpio = 0xf000,
3627 .amux = 0, 3513 .amux = 0,
3628 }, 3514 },
@@ -3635,26 +3521,25 @@ struct saa7134_board saa7134_boards[] = {
3635 .tuner_addr = 0x61, 3521 .tuner_addr = 0x61,
3636 .radio_addr = 0x60, 3522 .radio_addr = 0x60,
3637 .inputs = { { 3523 .inputs = { {
3638 .name = name_tv, 3524 .type = SAA7134_INPUT_TV,
3639 .vmux = 1, 3525 .vmux = 1,
3640 .amux = LINE2, 3526 .amux = LINE2,
3641 .tv = 1,
3642 }, { 3527 }, {
3643 .name = name_comp1, 3528 .type = SAA7134_INPUT_COMPOSITE1,
3644 .vmux = 3, 3529 .vmux = 3,
3645 .amux = LINE1, 3530 .amux = LINE1,
3646 }, { 3531 }, {
3647 .name = name_svideo, 3532 .type = SAA7134_INPUT_SVIDEO,
3648 .vmux = 8, 3533 .vmux = 8,
3649 .amux = LINE1, 3534 .amux = LINE1,
3650 } }, 3535 } },
3651 .radio = { 3536 .radio = {
3652 .name = name_radio, 3537 .type = SAA7134_INPUT_RADIO,
3653 .vmux = 1, 3538 .vmux = 1,
3654 .amux = LINE1, 3539 .amux = LINE1,
3655 }, 3540 },
3656 .mute = { 3541 .mute = {
3657 .name = name_mute, 3542 .type = SAA7134_INPUT_MUTE,
3658 .amux = LINE1, 3543 .amux = LINE1,
3659 .gpio = 0x43000, 3544 .gpio = 0x43000,
3660 }, 3545 },
@@ -3668,16 +3553,15 @@ struct saa7134_board saa7134_boards[] = {
3668 .radio_addr = ADDR_UNSET, 3553 .radio_addr = ADDR_UNSET,
3669 .mpeg = SAA7134_MPEG_DVB, 3554 .mpeg = SAA7134_MPEG_DVB,
3670 .inputs = {{ 3555 .inputs = {{
3671 .name = name_tv, 3556 .type = SAA7134_INPUT_TV,
3672 .vmux = 1, 3557 .vmux = 1,
3673 .amux = TV, 3558 .amux = TV,
3674 .tv = 1,
3675 },{ 3559 },{
3676 .name = name_comp1, 3560 .type = SAA7134_INPUT_COMPOSITE1,
3677 .vmux = 0, 3561 .vmux = 0,
3678 .amux = LINE1, 3562 .amux = LINE1,
3679 },{ 3563 },{
3680 .name = name_svideo, 3564 .type = SAA7134_INPUT_SVIDEO,
3681 .vmux = 6, 3565 .vmux = 6,
3682 .amux = LINE1, 3566 .amux = LINE1,
3683 }}, 3567 }},
@@ -3693,21 +3577,20 @@ struct saa7134_board saa7134_boards[] = {
3693 .mpeg = SAA7134_MPEG_DVB, 3577 .mpeg = SAA7134_MPEG_DVB,
3694 .gpiomask = 0x0200000, 3578 .gpiomask = 0x0200000,
3695 .inputs = {{ 3579 .inputs = {{
3696 .name = name_tv, 3580 .type = SAA7134_INPUT_TV,
3697 .vmux = 1, 3581 .vmux = 1,
3698 .amux = TV, 3582 .amux = TV,
3699 .tv = 1,
3700 },{ 3583 },{
3701 .name = name_comp1, 3584 .type = SAA7134_INPUT_COMPOSITE1,
3702 .vmux = 3, 3585 .vmux = 3,
3703 .amux = LINE1, 3586 .amux = LINE1,
3704 },{ 3587 },{
3705 .name = name_svideo, 3588 .type = SAA7134_INPUT_SVIDEO,
3706 .vmux = 8, 3589 .vmux = 8,
3707 .amux = LINE1, 3590 .amux = LINE1,
3708 }}, 3591 }},
3709 .radio = { 3592 .radio = {
3710 .name = name_radio, 3593 .type = SAA7134_INPUT_RADIO,
3711 .amux = TV, 3594 .amux = TV,
3712 .gpio = 0x0200000, 3595 .gpio = 0x0200000,
3713 }, 3596 },
@@ -3721,16 +3604,15 @@ struct saa7134_board saa7134_boards[] = {
3721 .radio_addr = ADDR_UNSET, 3604 .radio_addr = ADDR_UNSET,
3722 .gpiomask = 1<<21, 3605 .gpiomask = 1<<21,
3723 .inputs = {{ 3606 .inputs = {{
3724 .name = name_tv, 3607 .type = SAA7134_INPUT_TV,
3725 .vmux = 1, 3608 .vmux = 1,
3726 .amux = TV, 3609 .amux = TV,
3727 .tv = 1,
3728 },{ 3610 },{
3729 .name = name_comp1, 3611 .type = SAA7134_INPUT_COMPOSITE1,
3730 .vmux = 0, 3612 .vmux = 0,
3731 .amux = LINE2, 3613 .amux = LINE2,
3732 },{ 3614 },{
3733 .name = name_svideo, 3615 .type = SAA7134_INPUT_SVIDEO,
3734 .vmux = 6, 3616 .vmux = 6,
3735 .amux = LINE2, 3617 .amux = LINE2,
3736 }}, 3618 }},
@@ -3746,10 +3628,9 @@ struct saa7134_board saa7134_boards[] = {
3746 .mpeg = SAA7134_MPEG_DVB, 3628 .mpeg = SAA7134_MPEG_DVB,
3747 .gpiomask = 0x0200000, 3629 .gpiomask = 0x0200000,
3748 .inputs = {{ 3630 .inputs = {{
3749 .name = name_tv, 3631 .type = SAA7134_INPUT_TV,
3750 .vmux = 1, 3632 .vmux = 1,
3751 .amux = TV, 3633 .amux = TV,
3752 .tv = 1,
3753 .gpio = 0x0200000, 3634 .gpio = 0x0200000,
3754 }}, 3635 }},
3755 }, 3636 },
@@ -3764,29 +3645,28 @@ struct saa7134_board saa7134_boards[] = {
3764 .gpiomask = 1 << 21, 3645 .gpiomask = 1 << 21,
3765 .mpeg = SAA7134_MPEG_DVB, 3646 .mpeg = SAA7134_MPEG_DVB,
3766 .inputs = {{ 3647 .inputs = {{
3767 .name = name_tv, 3648 .type = SAA7134_INPUT_TV,
3768 .vmux = 1, 3649 .vmux = 1,
3769 .amux = TV, 3650 .amux = TV,
3770 .tv = 1,
3771 .gpio = 0x0000000, 3651 .gpio = 0x0000000,
3772 },{ 3652 },{
3773 .name = name_comp1, 3653 .type = SAA7134_INPUT_COMPOSITE1,
3774 .vmux = 3, 3654 .vmux = 3,
3775 .amux = LINE2, 3655 .amux = LINE2,
3776 .gpio = 0x0200000, 3656 .gpio = 0x0200000,
3777 },{ 3657 },{
3778 .name = name_comp2, 3658 .type = SAA7134_INPUT_COMPOSITE2,
3779 .vmux = 0, 3659 .vmux = 0,
3780 .amux = LINE2, 3660 .amux = LINE2,
3781 .gpio = 0x0200000, 3661 .gpio = 0x0200000,
3782 },{ 3662 },{
3783 .name = name_svideo, 3663 .type = SAA7134_INPUT_SVIDEO,
3784 .vmux = 8, 3664 .vmux = 8,
3785 .amux = LINE2, 3665 .amux = LINE2,
3786 .gpio = 0x0200000, 3666 .gpio = 0x0200000,
3787 }}, 3667 }},
3788 .radio = { 3668 .radio = {
3789 .name = name_radio, 3669 .type = SAA7134_INPUT_RADIO,
3790 .amux = TV, 3670 .amux = TV,
3791 .gpio = 0x0200000, 3671 .gpio = 0x0200000,
3792 }, 3672 },
@@ -3800,26 +3680,25 @@ struct saa7134_board saa7134_boards[] = {
3800 .radio_addr = ADDR_UNSET, 3680 .radio_addr = ADDR_UNSET,
3801 .gpiomask = 1 << 21, 3681 .gpiomask = 1 << 21,
3802 .inputs = {{ 3682 .inputs = {{
3803 .name = name_tv, 3683 .type = SAA7134_INPUT_TV,
3804 .vmux = 1, 3684 .vmux = 1,
3805 .amux = TV, 3685 .amux = TV,
3806 .tv = 1,
3807 .gpio = 0x0000000, 3686 .gpio = 0x0000000,
3808 }, { 3687 }, {
3809 .name = name_comp1, 3688 .type = SAA7134_INPUT_COMPOSITE1,
3810 .vmux = 3, 3689 .vmux = 3,
3811 .amux = LINE2, 3690 .amux = LINE2,
3812 }, { 3691 }, {
3813 .name = name_comp2, 3692 .type = SAA7134_INPUT_COMPOSITE2,
3814 .vmux = 0, 3693 .vmux = 0,
3815 .amux = LINE2, 3694 .amux = LINE2,
3816 }, { 3695 }, {
3817 .name = name_svideo, 3696 .type = SAA7134_INPUT_SVIDEO,
3818 .vmux = 8, 3697 .vmux = 8,
3819 .amux = LINE2, 3698 .amux = LINE2,
3820 } }, 3699 } },
3821 .radio = { 3700 .radio = {
3822 .name = name_radio, 3701 .type = SAA7134_INPUT_RADIO,
3823 .amux = TV, 3702 .amux = TV,
3824 .gpio = 0x0200000, 3703 .gpio = 0x0200000,
3825 }, 3704 },
@@ -3832,25 +3711,24 @@ struct saa7134_board saa7134_boards[] = {
3832 .tuner_addr = ADDR_UNSET, 3711 .tuner_addr = ADDR_UNSET,
3833 .radio_addr = ADDR_UNSET, 3712 .radio_addr = ADDR_UNSET,
3834 .inputs = {{ 3713 .inputs = {{
3835 .name = name_tv, 3714 .type = SAA7134_INPUT_TV,
3836 .vmux = 1, 3715 .vmux = 1,
3837 .amux = TV, 3716 .amux = TV,
3838 .tv = 1,
3839 },{ 3717 },{
3840 .name = name_comp1, 3718 .type = SAA7134_INPUT_COMPOSITE1,
3841 .vmux = 3, 3719 .vmux = 3,
3842 .amux = LINE1, 3720 .amux = LINE1,
3843 },{ 3721 },{
3844 .name = name_comp2, 3722 .type = SAA7134_INPUT_COMPOSITE2,
3845 .vmux = 0, 3723 .vmux = 0,
3846 .amux = LINE1, 3724 .amux = LINE1,
3847 },{ 3725 },{
3848 .name = name_svideo, 3726 .type = SAA7134_INPUT_SVIDEO,
3849 .vmux = 8, 3727 .vmux = 8,
3850 .amux = LINE1, 3728 .amux = LINE1,
3851 }}, 3729 }},
3852 .mute = { 3730 .mute = {
3853 .name = name_mute, 3731 .type = SAA7134_INPUT_MUTE,
3854 .amux = TV, 3732 .amux = TV,
3855 }, 3733 },
3856 }, 3734 },
@@ -3864,24 +3742,23 @@ struct saa7134_board saa7134_boards[] = {
3864 .radio_addr = ADDR_UNSET, 3742 .radio_addr = ADDR_UNSET,
3865 .gpiomask = 0x7000, 3743 .gpiomask = 0x7000,
3866 .inputs = {{ 3744 .inputs = {{
3867 .name = name_tv, 3745 .type = SAA7134_INPUT_TV,
3868 .vmux = 1, 3746 .vmux = 1,
3869 .amux = LINE2, 3747 .amux = LINE2,
3870 .gpio = 0x0000, 3748 .gpio = 0x0000,
3871 .tv = 1,
3872 },{ 3749 },{
3873 .name = name_comp1, 3750 .type = SAA7134_INPUT_COMPOSITE1,
3874 .vmux = 3, 3751 .vmux = 3,
3875 .amux = LINE1, 3752 .amux = LINE1,
3876 .gpio = 0x2000, 3753 .gpio = 0x2000,
3877 },{ 3754 },{
3878 .name = name_svideo, 3755 .type = SAA7134_INPUT_SVIDEO,
3879 .vmux = 8, 3756 .vmux = 8,
3880 .amux = LINE1, 3757 .amux = LINE1,
3881 .gpio = 0x2000, 3758 .gpio = 0x2000,
3882 }}, 3759 }},
3883 .mute = { 3760 .mute = {
3884 .name = name_mute, 3761 .type = SAA7134_INPUT_MUTE,
3885 .amux = LINE2, 3762 .amux = LINE2,
3886 .gpio = 0x3000, 3763 .gpio = 0x3000,
3887 }, 3764 },
@@ -3896,10 +3773,9 @@ struct saa7134_board saa7134_boards[] = {
3896 .tda829x_conf = { .lna_cfg = TDA8290_LNA_OFF }, 3773 .tda829x_conf = { .lna_cfg = TDA8290_LNA_OFF },
3897 .mpeg = SAA7134_MPEG_DVB, 3774 .mpeg = SAA7134_MPEG_DVB,
3898 .inputs = {{ 3775 .inputs = {{
3899 .name = name_tv, /* FIXME: analog tv untested */ 3776 .type = SAA7134_INPUT_TV, /* FIXME: analog tv untested */
3900 .vmux = 1, 3777 .vmux = 1,
3901 .amux = TV, 3778 .amux = TV,
3902 .tv = 1,
3903 }}, 3779 }},
3904 }, 3780 },
3905 [SAA7134_BOARD_AVERMEDIA_M135A] = { 3781 [SAA7134_BOARD_AVERMEDIA_M135A] = {
@@ -3912,26 +3788,25 @@ struct saa7134_board saa7134_boards[] = {
3912 .tda829x_conf = { .lna_cfg = TDA8290_LNA_GP0_HIGH_OFF }, 3788 .tda829x_conf = { .lna_cfg = TDA8290_LNA_GP0_HIGH_OFF },
3913 .gpiomask = 0x020200000, 3789 .gpiomask = 0x020200000,
3914 .inputs = {{ 3790 .inputs = {{
3915 .name = name_tv, 3791 .type = SAA7134_INPUT_TV,
3916 .vmux = 1, 3792 .vmux = 1,
3917 .amux = TV, 3793 .amux = TV,
3918 .tv = 1,
3919 }, { 3794 }, {
3920 .name = name_comp1, 3795 .type = SAA7134_INPUT_COMPOSITE1,
3921 .vmux = 3, 3796 .vmux = 3,
3922 .amux = LINE1, 3797 .amux = LINE1,
3923 }, { 3798 }, {
3924 .name = name_svideo, 3799 .type = SAA7134_INPUT_SVIDEO,
3925 .vmux = 8, 3800 .vmux = 8,
3926 .amux = LINE1, 3801 .amux = LINE1,
3927 } }, 3802 } },
3928 .radio = { 3803 .radio = {
3929 .name = name_radio, 3804 .type = SAA7134_INPUT_RADIO,
3930 .amux = TV, 3805 .amux = TV,
3931 .gpio = 0x00200000, 3806 .gpio = 0x00200000,
3932 }, 3807 },
3933 .mute = { 3808 .mute = {
3934 .name = name_mute, 3809 .type = SAA7134_INPUT_MUTE,
3935 .amux = TV, 3810 .amux = TV,
3936 .gpio = 0x01, 3811 .gpio = 0x01,
3937 }, 3812 },
@@ -3946,26 +3821,25 @@ struct saa7134_board saa7134_boards[] = {
3946 .tda829x_conf = { .lna_cfg = TDA8290_LNA_OFF }, 3821 .tda829x_conf = { .lna_cfg = TDA8290_LNA_OFF },
3947 .gpiomask = 0x020200000, 3822 .gpiomask = 0x020200000,
3948 .inputs = {{ 3823 .inputs = {{
3949 .name = name_tv, 3824 .type = SAA7134_INPUT_TV,
3950 .vmux = 1, 3825 .vmux = 1,
3951 .amux = TV, 3826 .amux = TV,
3952 .tv = 1,
3953 }, { 3827 }, {
3954 .name = name_comp1, 3828 .type = SAA7134_INPUT_COMPOSITE1,
3955 .vmux = 3, 3829 .vmux = 3,
3956 .amux = LINE1, 3830 .amux = LINE1,
3957 }, { 3831 }, {
3958 .name = name_svideo, 3832 .type = SAA7134_INPUT_SVIDEO,
3959 .vmux = 8, 3833 .vmux = 8,
3960 .amux = LINE1, 3834 .amux = LINE1,
3961 } }, 3835 } },
3962 .radio = { 3836 .radio = {
3963 .name = name_radio, 3837 .type = SAA7134_INPUT_RADIO,
3964 .amux = TV, 3838 .amux = TV,
3965 .gpio = 0x00200000, 3839 .gpio = 0x00200000,
3966 }, 3840 },
3967 .mute = { 3841 .mute = {
3968 .name = name_mute, 3842 .type = SAA7134_INPUT_MUTE,
3969 .amux = TV, 3843 .amux = TV,
3970 .gpio = 0x01, 3844 .gpio = 0x01,
3971 }, 3845 },
@@ -3981,21 +3855,20 @@ struct saa7134_board saa7134_boards[] = {
3981 .radio_addr = ADDR_UNSET, 3855 .radio_addr = ADDR_UNSET,
3982 .gpiomask = 0x00008000, 3856 .gpiomask = 0x00008000,
3983 .inputs = {{ 3857 .inputs = {{
3984 .name = name_svideo, 3858 .type = SAA7134_INPUT_SVIDEO,
3985 .vmux = 8, 3859 .vmux = 8,
3986 .amux = LINE1, 3860 .amux = LINE1,
3987 },{ 3861 },{
3988 .name = name_comp1, 3862 .type = SAA7134_INPUT_COMPOSITE1,
3989 .vmux = 1, 3863 .vmux = 1,
3990 .amux = LINE1, 3864 .amux = LINE1,
3991 },{ 3865 },{
3992 .name = name_tv, 3866 .type = SAA7134_INPUT_TV,
3993 .vmux = 3, 3867 .vmux = 3,
3994 .amux = LINE2, 3868 .amux = LINE2,
3995 .tv = 1,
3996 }}, 3869 }},
3997 .mute = { 3870 .mute = {
3998 .name = name_mute, 3871 .type = SAA7134_INPUT_MUTE,
3999 .amux = LINE1, 3872 .amux = LINE1,
4000 }, 3873 },
4001 }, 3874 },
@@ -4010,18 +3883,17 @@ struct saa7134_board saa7134_boards[] = {
4010 .radio_addr = ADDR_UNSET, 3883 .radio_addr = ADDR_UNSET,
4011 .gpiomask = 0x00008000, 3884 .gpiomask = 0x00008000,
4012 .inputs = {{ 3885 .inputs = {{
4013 .name = name_svideo, 3886 .type = SAA7134_INPUT_SVIDEO,
4014 .vmux = 8, 3887 .vmux = 8,
4015 .amux = LINE1, 3888 .amux = LINE1,
4016 },{ 3889 },{
4017 .name = name_comp1, 3890 .type = SAA7134_INPUT_COMPOSITE1,
4018 .vmux = 1, 3891 .vmux = 1,
4019 .amux = LINE1, 3892 .amux = LINE1,
4020 },{ 3893 },{
4021 .name = name_tv, 3894 .type = SAA7134_INPUT_TV,
4022 .vmux = 3, 3895 .vmux = 3,
4023 .amux = LINE2, 3896 .amux = LINE2,
4024 .tv = 1,
4025 }}, 3897 }},
4026 }, 3898 },
4027 [SAA7134_BOARD_BEHOLD_403FM] = { 3899 [SAA7134_BOARD_BEHOLD_403FM] = {
@@ -4035,21 +3907,20 @@ struct saa7134_board saa7134_boards[] = {
4035 .radio_addr = ADDR_UNSET, 3907 .radio_addr = ADDR_UNSET,
4036 .gpiomask = 0x00008000, 3908 .gpiomask = 0x00008000,
4037 .inputs = {{ 3909 .inputs = {{
4038 .name = name_svideo, 3910 .type = SAA7134_INPUT_SVIDEO,
4039 .vmux = 8, 3911 .vmux = 8,
4040 .amux = LINE1, 3912 .amux = LINE1,
4041 },{ 3913 },{
4042 .name = name_comp1, 3914 .type = SAA7134_INPUT_COMPOSITE1,
4043 .vmux = 1, 3915 .vmux = 1,
4044 .amux = LINE1, 3916 .amux = LINE1,
4045 },{ 3917 },{
4046 .name = name_tv, 3918 .type = SAA7134_INPUT_TV,
4047 .vmux = 3, 3919 .vmux = 3,
4048 .amux = LINE2, 3920 .amux = LINE2,
4049 .tv = 1,
4050 }}, 3921 }},
4051 .radio = { 3922 .radio = {
4052 .name = name_radio, 3923 .type = SAA7134_INPUT_RADIO,
4053 .amux = LINE2, 3924 .amux = LINE2,
4054 }, 3925 },
4055 }, 3926 },
@@ -4065,18 +3936,17 @@ struct saa7134_board saa7134_boards[] = {
4065 .tda9887_conf = TDA9887_PRESENT, 3936 .tda9887_conf = TDA9887_PRESENT,
4066 .gpiomask = 0x00008000, 3937 .gpiomask = 0x00008000,
4067 .inputs = {{ 3938 .inputs = {{
4068 .name = name_svideo, 3939 .type = SAA7134_INPUT_SVIDEO,
4069 .vmux = 8, 3940 .vmux = 8,
4070 .amux = LINE1, 3941 .amux = LINE1,
4071 },{ 3942 },{
4072 .name = name_comp1, 3943 .type = SAA7134_INPUT_COMPOSITE1,
4073 .vmux = 3, 3944 .vmux = 3,
4074 .amux = LINE1, 3945 .amux = LINE1,
4075 },{ 3946 },{
4076 .name = name_tv, 3947 .type = SAA7134_INPUT_TV,
4077 .vmux = 3, 3948 .vmux = 3,
4078 .amux = LINE2, 3949 .amux = LINE2,
4079 .tv = 1,
4080 }}, 3950 }},
4081 }, 3951 },
4082 [SAA7134_BOARD_BEHOLD_405FM] = { 3952 [SAA7134_BOARD_BEHOLD_405FM] = {
@@ -4092,21 +3962,20 @@ struct saa7134_board saa7134_boards[] = {
4092 .tda9887_conf = TDA9887_PRESENT, 3962 .tda9887_conf = TDA9887_PRESENT,
4093 .gpiomask = 0x00008000, 3963 .gpiomask = 0x00008000,
4094 .inputs = {{ 3964 .inputs = {{
4095 .name = name_svideo, 3965 .type = SAA7134_INPUT_SVIDEO,
4096 .vmux = 8, 3966 .vmux = 8,
4097 .amux = LINE1, 3967 .amux = LINE1,
4098 },{ 3968 },{
4099 .name = name_comp1, 3969 .type = SAA7134_INPUT_COMPOSITE1,
4100 .vmux = 3, 3970 .vmux = 3,
4101 .amux = LINE1, 3971 .amux = LINE1,
4102 },{ 3972 },{
4103 .name = name_tv, 3973 .type = SAA7134_INPUT_TV,
4104 .vmux = 3, 3974 .vmux = 3,
4105 .amux = LINE2, 3975 .amux = LINE2,
4106 .tv = 1,
4107 }}, 3976 }},
4108 .radio = { 3977 .radio = {
4109 .name = name_radio, 3978 .type = SAA7134_INPUT_RADIO,
4110 .amux = LINE2, 3979 .amux = LINE2,
4111 }, 3980 },
4112 }, 3981 },
@@ -4122,20 +3991,19 @@ struct saa7134_board saa7134_boards[] = {
4122 .tda9887_conf = TDA9887_PRESENT, 3991 .tda9887_conf = TDA9887_PRESENT,
4123 .gpiomask = 0x00008000, 3992 .gpiomask = 0x00008000,
4124 .inputs = {{ 3993 .inputs = {{
4125 .name = name_svideo, 3994 .type = SAA7134_INPUT_SVIDEO,
4126 .vmux = 8, 3995 .vmux = 8,
4127 .amux = LINE1, 3996 .amux = LINE1,
4128 .gpio = 0xc0c000, 3997 .gpio = 0xc0c000,
4129 },{ 3998 },{
4130 .name = name_comp1, 3999 .type = SAA7134_INPUT_COMPOSITE1,
4131 .vmux = 1, 4000 .vmux = 1,
4132 .amux = LINE1, 4001 .amux = LINE1,
4133 .gpio = 0xc0c000, 4002 .gpio = 0xc0c000,
4134 },{ 4003 },{
4135 .name = name_tv, 4004 .type = SAA7134_INPUT_TV,
4136 .vmux = 3, 4005 .vmux = 3,
4137 .amux = TV, 4006 .amux = TV,
4138 .tv = 1,
4139 .gpio = 0xc0c000, 4007 .gpio = 0xc0c000,
4140 }}, 4008 }},
4141 }, 4009 },
@@ -4151,24 +4019,23 @@ struct saa7134_board saa7134_boards[] = {
4151 .tda9887_conf = TDA9887_PRESENT, 4019 .tda9887_conf = TDA9887_PRESENT,
4152 .gpiomask = 0x00008000, 4020 .gpiomask = 0x00008000,
4153 .inputs = {{ 4021 .inputs = {{
4154 .name = name_svideo, 4022 .type = SAA7134_INPUT_SVIDEO,
4155 .vmux = 8, 4023 .vmux = 8,
4156 .amux = LINE1, 4024 .amux = LINE1,
4157 .gpio = 0xc0c000, 4025 .gpio = 0xc0c000,
4158 },{ 4026 },{
4159 .name = name_comp1, 4027 .type = SAA7134_INPUT_COMPOSITE1,
4160 .vmux = 1, 4028 .vmux = 1,
4161 .amux = LINE1, 4029 .amux = LINE1,
4162 .gpio = 0xc0c000, 4030 .gpio = 0xc0c000,
4163 },{ 4031 },{
4164 .name = name_tv, 4032 .type = SAA7134_INPUT_TV,
4165 .vmux = 3, 4033 .vmux = 3,
4166 .amux = TV, 4034 .amux = TV,
4167 .tv = 1,
4168 .gpio = 0xc0c000, 4035 .gpio = 0xc0c000,
4169 }}, 4036 }},
4170 .radio = { 4037 .radio = {
4171 .name = name_radio, 4038 .type = SAA7134_INPUT_RADIO,
4172 .amux = LINE2, 4039 .amux = LINE2,
4173 .gpio = 0xc0c000, 4040 .gpio = 0xc0c000,
4174 }, 4041 },
@@ -4185,16 +4052,15 @@ struct saa7134_board saa7134_boards[] = {
4185 .tda9887_conf = TDA9887_PRESENT, 4052 .tda9887_conf = TDA9887_PRESENT,
4186 .gpiomask = 0x00008000, 4053 .gpiomask = 0x00008000,
4187 .inputs = {{ 4054 .inputs = {{
4188 .name = name_tv, 4055 .type = SAA7134_INPUT_TV,
4189 .vmux = 3, 4056 .vmux = 3,
4190 .amux = TV, 4057 .amux = TV,
4191 .tv = 1,
4192 },{ 4058 },{
4193 .name = name_comp1, 4059 .type = SAA7134_INPUT_COMPOSITE1,
4194 .vmux = 1, 4060 .vmux = 1,
4195 .amux = LINE1, 4061 .amux = LINE1,
4196 },{ 4062 },{
4197 .name = name_svideo, 4063 .type = SAA7134_INPUT_SVIDEO,
4198 .vmux = 8, 4064 .vmux = 8,
4199 .amux = LINE1, 4065 .amux = LINE1,
4200 }}, 4066 }},
@@ -4211,25 +4077,24 @@ struct saa7134_board saa7134_boards[] = {
4211 .tda9887_conf = TDA9887_PRESENT, 4077 .tda9887_conf = TDA9887_PRESENT,
4212 .gpiomask = 0x00008000, 4078 .gpiomask = 0x00008000,
4213 .inputs = {{ 4079 .inputs = {{
4214 .name = name_tv, 4080 .type = SAA7134_INPUT_TV,
4215 .vmux = 3, 4081 .vmux = 3,
4216 .amux = LINE2, 4082 .amux = LINE2,
4217 .tv = 1,
4218 }, { 4083 }, {
4219 .name = name_comp1, 4084 .type = SAA7134_INPUT_COMPOSITE1,
4220 .vmux = 1, 4085 .vmux = 1,
4221 .amux = LINE1, 4086 .amux = LINE1,
4222 }, { 4087 }, {
4223 .name = name_svideo, 4088 .type = SAA7134_INPUT_SVIDEO,
4224 .vmux = 8, 4089 .vmux = 8,
4225 .amux = LINE1, 4090 .amux = LINE1,
4226 } }, 4091 } },
4227 .mute = { 4092 .mute = {
4228 .name = name_mute, 4093 .type = SAA7134_INPUT_MUTE,
4229 .amux = LINE1, 4094 .amux = LINE1,
4230 }, 4095 },
4231 .radio = { 4096 .radio = {
4232 .name = name_radio, 4097 .type = SAA7134_INPUT_RADIO,
4233 .amux = LINE2, 4098 .amux = LINE2,
4234 }, 4099 },
4235 }, 4100 },
@@ -4246,25 +4111,24 @@ struct saa7134_board saa7134_boards[] = {
4246 .tda9887_conf = TDA9887_PRESENT, 4111 .tda9887_conf = TDA9887_PRESENT,
4247 .gpiomask = 0x00008000, 4112 .gpiomask = 0x00008000,
4248 .inputs = {{ 4113 .inputs = {{
4249 .name = name_tv, 4114 .type = SAA7134_INPUT_TV,
4250 .vmux = 3, 4115 .vmux = 3,
4251 .amux = LINE2, 4116 .amux = LINE2,
4252 .tv = 1,
4253 },{ 4117 },{
4254 .name = name_comp1, 4118 .type = SAA7134_INPUT_COMPOSITE1,
4255 .vmux = 1, 4119 .vmux = 1,
4256 .amux = LINE1, 4120 .amux = LINE1,
4257 },{ 4121 },{
4258 .name = name_svideo, 4122 .type = SAA7134_INPUT_SVIDEO,
4259 .vmux = 8, 4123 .vmux = 8,
4260 .amux = LINE1, 4124 .amux = LINE1,
4261 }}, 4125 }},
4262 .mute = { 4126 .mute = {
4263 .name = name_mute, 4127 .type = SAA7134_INPUT_MUTE,
4264 .amux = LINE1, 4128 .amux = LINE1,
4265 }, 4129 },
4266 .radio = { 4130 .radio = {
4267 .name = name_radio, 4131 .type = SAA7134_INPUT_RADIO,
4268 .amux = LINE2, 4132 .amux = LINE2,
4269 }, 4133 },
4270 }, 4134 },
@@ -4280,21 +4144,20 @@ struct saa7134_board saa7134_boards[] = {
4280 .tda9887_conf = TDA9887_PRESENT, 4144 .tda9887_conf = TDA9887_PRESENT,
4281 .gpiomask = 0x00008000, 4145 .gpiomask = 0x00008000,
4282 .inputs = {{ 4146 .inputs = {{
4283 .name = name_tv, 4147 .type = SAA7134_INPUT_TV,
4284 .vmux = 3, 4148 .vmux = 3,
4285 .amux = TV, 4149 .amux = TV,
4286 .tv = 1,
4287 },{ 4150 },{
4288 .name = name_comp1, 4151 .type = SAA7134_INPUT_COMPOSITE1,
4289 .vmux = 1, 4152 .vmux = 1,
4290 .amux = LINE1, 4153 .amux = LINE1,
4291 },{ 4154 },{
4292 .name = name_svideo, 4155 .type = SAA7134_INPUT_SVIDEO,
4293 .vmux = 8, 4156 .vmux = 8,
4294 .amux = LINE1, 4157 .amux = LINE1,
4295 }}, 4158 }},
4296 .radio = { 4159 .radio = {
4297 .name = name_radio, 4160 .type = SAA7134_INPUT_RADIO,
4298 .amux = LINE2, 4161 .amux = LINE2,
4299 }, 4162 },
4300 }, 4163 },
@@ -4311,21 +4174,20 @@ struct saa7134_board saa7134_boards[] = {
4311 .tda9887_conf = TDA9887_PRESENT, 4174 .tda9887_conf = TDA9887_PRESENT,
4312 .gpiomask = 0x00008000, 4175 .gpiomask = 0x00008000,
4313 .inputs = {{ 4176 .inputs = {{
4314 .name = name_tv, 4177 .type = SAA7134_INPUT_TV,
4315 .vmux = 3, 4178 .vmux = 3,
4316 .amux = TV, 4179 .amux = TV,
4317 .tv = 1,
4318 }, { 4180 }, {
4319 .name = name_comp1, 4181 .type = SAA7134_INPUT_COMPOSITE1,
4320 .vmux = 1, 4182 .vmux = 1,
4321 .amux = LINE1, 4183 .amux = LINE1,
4322 }, { 4184 }, {
4323 .name = name_svideo, 4185 .type = SAA7134_INPUT_SVIDEO,
4324 .vmux = 8, 4186 .vmux = 8,
4325 .amux = LINE1, 4187 .amux = LINE1,
4326 } }, 4188 } },
4327 .radio = { 4189 .radio = {
4328 .name = name_radio, 4190 .type = SAA7134_INPUT_RADIO,
4329 .amux = LINE2, 4191 .amux = LINE2,
4330 }, 4192 },
4331 }, 4193 },
@@ -4342,21 +4204,20 @@ struct saa7134_board saa7134_boards[] = {
4342 .tda9887_conf = TDA9887_PRESENT, 4204 .tda9887_conf = TDA9887_PRESENT,
4343 .gpiomask = 0x00008000, 4205 .gpiomask = 0x00008000,
4344 .inputs = {{ 4206 .inputs = {{
4345 .name = name_tv, 4207 .type = SAA7134_INPUT_TV,
4346 .vmux = 3, 4208 .vmux = 3,
4347 .amux = TV, 4209 .amux = TV,
4348 .tv = 1,
4349 }, { 4210 }, {
4350 .name = name_comp1, 4211 .type = SAA7134_INPUT_COMPOSITE1,
4351 .vmux = 1, 4212 .vmux = 1,
4352 .amux = LINE1, 4213 .amux = LINE1,
4353 }, { 4214 }, {
4354 .name = name_svideo, 4215 .type = SAA7134_INPUT_SVIDEO,
4355 .vmux = 8, 4216 .vmux = 8,
4356 .amux = LINE1, 4217 .amux = LINE1,
4357 } }, 4218 } },
4358 .radio = { 4219 .radio = {
4359 .name = name_radio, 4220 .type = SAA7134_INPUT_RADIO,
4360 .amux = LINE2, 4221 .amux = LINE2,
4361 }, 4222 },
4362 }, 4223 },
@@ -4372,24 +4233,23 @@ struct saa7134_board saa7134_boards[] = {
4372 .tda9887_conf = TDA9887_PRESENT, 4233 .tda9887_conf = TDA9887_PRESENT,
4373 .gpiomask = 0x000A8004, 4234 .gpiomask = 0x000A8004,
4374 .inputs = {{ 4235 .inputs = {{
4375 .name = name_tv, 4236 .type = SAA7134_INPUT_TV,
4376 .vmux = 3, 4237 .vmux = 3,
4377 .amux = TV, 4238 .amux = TV,
4378 .tv = 1,
4379 .gpio = 0x000A8004, 4239 .gpio = 0x000A8004,
4380 }, { 4240 }, {
4381 .name = name_comp1, 4241 .type = SAA7134_INPUT_COMPOSITE1,
4382 .vmux = 1, 4242 .vmux = 1,
4383 .amux = LINE1, 4243 .amux = LINE1,
4384 .gpio = 0x000A8000, 4244 .gpio = 0x000A8000,
4385 }, { 4245 }, {
4386 .name = name_svideo, 4246 .type = SAA7134_INPUT_SVIDEO,
4387 .vmux = 8, 4247 .vmux = 8,
4388 .amux = LINE1, 4248 .amux = LINE1,
4389 .gpio = 0x000A8000, 4249 .gpio = 0x000A8000,
4390 } }, 4250 } },
4391 .radio = { 4251 .radio = {
4392 .name = name_radio, 4252 .type = SAA7134_INPUT_RADIO,
4393 .amux = LINE2, 4253 .amux = LINE2,
4394 .gpio = 0x000A8000, 4254 .gpio = 0x000A8000,
4395 }, 4255 },
@@ -4404,21 +4264,20 @@ struct saa7134_board saa7134_boards[] = {
4404 .radio_addr = ADDR_UNSET, 4264 .radio_addr = ADDR_UNSET,
4405 .tda9887_conf = TDA9887_PRESENT, 4265 .tda9887_conf = TDA9887_PRESENT,
4406 .inputs = {{ 4266 .inputs = {{
4407 .name = name_tv, 4267 .type = SAA7134_INPUT_TV,
4408 .vmux = 3, 4268 .vmux = 3,
4409 .amux = TV, 4269 .amux = TV,
4410 .tv = 1,
4411 }, { 4270 }, {
4412 .name = name_comp1, 4271 .type = SAA7134_INPUT_COMPOSITE1,
4413 .vmux = 1, 4272 .vmux = 1,
4414 .amux = LINE1, 4273 .amux = LINE1,
4415 }, { 4274 }, {
4416 .name = name_svideo, 4275 .type = SAA7134_INPUT_SVIDEO,
4417 .vmux = 8, 4276 .vmux = 8,
4418 .amux = LINE1, 4277 .amux = LINE1,
4419 } }, 4278 } },
4420 .radio = { 4279 .radio = {
4421 .name = name_radio, 4280 .type = SAA7134_INPUT_RADIO,
4422 .amux = LINE2, 4281 .amux = LINE2,
4423 }, 4282 },
4424 }, 4283 },
@@ -4432,21 +4291,20 @@ struct saa7134_board saa7134_boards[] = {
4432 .radio_addr = ADDR_UNSET, 4291 .radio_addr = ADDR_UNSET,
4433 .tda9887_conf = TDA9887_PRESENT, 4292 .tda9887_conf = TDA9887_PRESENT,
4434 .inputs = {{ 4293 .inputs = {{
4435 .name = name_tv, 4294 .type = SAA7134_INPUT_TV,
4436 .vmux = 3, 4295 .vmux = 3,
4437 .amux = TV, 4296 .amux = TV,
4438 .tv = 1,
4439 }, { 4297 }, {
4440 .name = name_comp1, 4298 .type = SAA7134_INPUT_COMPOSITE1,
4441 .vmux = 1, 4299 .vmux = 1,
4442 .amux = LINE1, 4300 .amux = LINE1,
4443 }, { 4301 }, {
4444 .name = name_svideo, 4302 .type = SAA7134_INPUT_SVIDEO,
4445 .vmux = 8, 4303 .vmux = 8,
4446 .amux = LINE1, 4304 .amux = LINE1,
4447 } }, 4305 } },
4448 .radio = { 4306 .radio = {
4449 .name = name_radio, 4307 .type = SAA7134_INPUT_RADIO,
4450 .amux = LINE2, 4308 .amux = LINE2,
4451 }, 4309 },
4452 }, 4310 },
@@ -4460,21 +4318,20 @@ struct saa7134_board saa7134_boards[] = {
4460 .radio_addr = ADDR_UNSET, 4318 .radio_addr = ADDR_UNSET,
4461 .tda9887_conf = TDA9887_PRESENT, 4319 .tda9887_conf = TDA9887_PRESENT,
4462 .inputs = {{ 4320 .inputs = {{
4463 .name = name_tv, 4321 .type = SAA7134_INPUT_TV,
4464 .vmux = 3, 4322 .vmux = 3,
4465 .amux = TV, 4323 .amux = TV,
4466 .tv = 1,
4467 }, { 4324 }, {
4468 .name = name_comp1, 4325 .type = SAA7134_INPUT_COMPOSITE1,
4469 .vmux = 1, 4326 .vmux = 1,
4470 .amux = LINE1, 4327 .amux = LINE1,
4471 }, { 4328 }, {
4472 .name = name_svideo, 4329 .type = SAA7134_INPUT_SVIDEO,
4473 .vmux = 8, 4330 .vmux = 8,
4474 .amux = LINE1, 4331 .amux = LINE1,
4475 } }, 4332 } },
4476 .radio = { 4333 .radio = {
4477 .name = name_radio, 4334 .type = SAA7134_INPUT_RADIO,
4478 .amux = LINE2, 4335 .amux = LINE2,
4479 }, 4336 },
4480 }, 4337 },
@@ -4488,21 +4345,20 @@ struct saa7134_board saa7134_boards[] = {
4488 .radio_addr = ADDR_UNSET, 4345 .radio_addr = ADDR_UNSET,
4489 .tda9887_conf = TDA9887_PRESENT, 4346 .tda9887_conf = TDA9887_PRESENT,
4490 .inputs = {{ 4347 .inputs = {{
4491 .name = name_tv, 4348 .type = SAA7134_INPUT_TV,
4492 .vmux = 3, 4349 .vmux = 3,
4493 .amux = TV, 4350 .amux = TV,
4494 .tv = 1,
4495 }, { 4351 }, {
4496 .name = name_comp1, 4352 .type = SAA7134_INPUT_COMPOSITE1,
4497 .vmux = 1, 4353 .vmux = 1,
4498 .amux = LINE1, 4354 .amux = LINE1,
4499 }, { 4355 }, {
4500 .name = name_svideo, 4356 .type = SAA7134_INPUT_SVIDEO,
4501 .vmux = 8, 4357 .vmux = 8,
4502 .amux = LINE1, 4358 .amux = LINE1,
4503 } }, 4359 } },
4504 .radio = { 4360 .radio = {
4505 .name = name_radio, 4361 .type = SAA7134_INPUT_RADIO,
4506 .amux = LINE2, 4362 .amux = LINE2,
4507 }, 4363 },
4508 }, 4364 },
@@ -4517,21 +4373,20 @@ struct saa7134_board saa7134_boards[] = {
4517 .rds_addr = 0x10, 4373 .rds_addr = 0x10,
4518 .tda9887_conf = TDA9887_PRESENT, 4374 .tda9887_conf = TDA9887_PRESENT,
4519 .inputs = {{ 4375 .inputs = {{
4520 .name = name_tv, 4376 .type = SAA7134_INPUT_TV,
4521 .vmux = 3, 4377 .vmux = 3,
4522 .amux = TV, 4378 .amux = TV,
4523 .tv = 1,
4524 }, { 4379 }, {
4525 .name = name_comp1, 4380 .type = SAA7134_INPUT_COMPOSITE1,
4526 .vmux = 1, 4381 .vmux = 1,
4527 .amux = LINE1, 4382 .amux = LINE1,
4528 }, { 4383 }, {
4529 .name = name_svideo, 4384 .type = SAA7134_INPUT_SVIDEO,
4530 .vmux = 8, 4385 .vmux = 8,
4531 .amux = LINE1, 4386 .amux = LINE1,
4532 } }, 4387 } },
4533 .radio = { 4388 .radio = {
4534 .name = name_radio, 4389 .type = SAA7134_INPUT_RADIO,
4535 .amux = LINE2, 4390 .amux = LINE2,
4536 }, 4391 },
4537 }, 4392 },
@@ -4546,21 +4401,20 @@ struct saa7134_board saa7134_boards[] = {
4546 .rds_addr = 0x10, 4401 .rds_addr = 0x10,
4547 .tda9887_conf = TDA9887_PRESENT, 4402 .tda9887_conf = TDA9887_PRESENT,
4548 .inputs = {{ 4403 .inputs = {{
4549 .name = name_tv, 4404 .type = SAA7134_INPUT_TV,
4550 .vmux = 3, 4405 .vmux = 3,
4551 .amux = TV, 4406 .amux = TV,
4552 .tv = 1,
4553 }, { 4407 }, {
4554 .name = name_comp1, 4408 .type = SAA7134_INPUT_COMPOSITE1,
4555 .vmux = 1, 4409 .vmux = 1,
4556 .amux = LINE1, 4410 .amux = LINE1,
4557 }, { 4411 }, {
4558 .name = name_svideo, 4412 .type = SAA7134_INPUT_SVIDEO,
4559 .vmux = 8, 4413 .vmux = 8,
4560 .amux = LINE1, 4414 .amux = LINE1,
4561 } }, 4415 } },
4562 .radio = { 4416 .radio = {
4563 .name = name_radio, 4417 .type = SAA7134_INPUT_RADIO,
4564 .amux = LINE2, 4418 .amux = LINE2,
4565 }, 4419 },
4566 }, 4420 },
@@ -4575,21 +4429,20 @@ struct saa7134_board saa7134_boards[] = {
4575 .rds_addr = 0x10, 4429 .rds_addr = 0x10,
4576 .tda9887_conf = TDA9887_PRESENT, 4430 .tda9887_conf = TDA9887_PRESENT,
4577 .inputs = {{ 4431 .inputs = {{
4578 .name = name_tv, 4432 .type = SAA7134_INPUT_TV,
4579 .vmux = 3, 4433 .vmux = 3,
4580 .amux = TV, 4434 .amux = TV,
4581 .tv = 1,
4582 }, { 4435 }, {
4583 .name = name_comp1, 4436 .type = SAA7134_INPUT_COMPOSITE1,
4584 .vmux = 1, 4437 .vmux = 1,
4585 .amux = LINE1, 4438 .amux = LINE1,
4586 }, { 4439 }, {
4587 .name = name_svideo, 4440 .type = SAA7134_INPUT_SVIDEO,
4588 .vmux = 8, 4441 .vmux = 8,
4589 .amux = LINE1, 4442 .amux = LINE1,
4590 } }, 4443 } },
4591 .radio = { 4444 .radio = {
4592 .name = name_radio, 4445 .type = SAA7134_INPUT_RADIO,
4593 .amux = LINE2, 4446 .amux = LINE2,
4594 }, 4447 },
4595 }, 4448 },
@@ -4604,21 +4457,20 @@ struct saa7134_board saa7134_boards[] = {
4604 .rds_addr = 0x10, 4457 .rds_addr = 0x10,
4605 .tda9887_conf = TDA9887_PRESENT, 4458 .tda9887_conf = TDA9887_PRESENT,
4606 .inputs = {{ 4459 .inputs = {{
4607 .name = name_tv, 4460 .type = SAA7134_INPUT_TV,
4608 .vmux = 3, 4461 .vmux = 3,
4609 .amux = TV, 4462 .amux = TV,
4610 .tv = 1,
4611 },{ 4463 },{
4612 .name = name_comp1, 4464 .type = SAA7134_INPUT_COMPOSITE1,
4613 .vmux = 1, 4465 .vmux = 1,
4614 .amux = LINE1, 4466 .amux = LINE1,
4615 },{ 4467 },{
4616 .name = name_svideo, 4468 .type = SAA7134_INPUT_SVIDEO,
4617 .vmux = 8, 4469 .vmux = 8,
4618 .amux = LINE1, 4470 .amux = LINE1,
4619 }}, 4471 }},
4620 .radio = { 4472 .radio = {
4621 .name = name_radio, 4473 .type = SAA7134_INPUT_RADIO,
4622 .amux = LINE2, 4474 .amux = LINE2,
4623 }, 4475 },
4624 }, 4476 },
@@ -4636,21 +4488,20 @@ struct saa7134_board saa7134_boards[] = {
4636 .empress_addr = 0x20, 4488 .empress_addr = 0x20,
4637 .tda9887_conf = TDA9887_PRESENT, 4489 .tda9887_conf = TDA9887_PRESENT,
4638 .inputs = { { 4490 .inputs = { {
4639 .name = name_tv, 4491 .type = SAA7134_INPUT_TV,
4640 .vmux = 3, 4492 .vmux = 3,
4641 .amux = TV, 4493 .amux = TV,
4642 .tv = 1,
4643 }, { 4494 }, {
4644 .name = name_comp1, 4495 .type = SAA7134_INPUT_COMPOSITE1,
4645 .vmux = 1, 4496 .vmux = 1,
4646 .amux = LINE1, 4497 .amux = LINE1,
4647 }, { 4498 }, {
4648 .name = name_svideo, 4499 .type = SAA7134_INPUT_SVIDEO,
4649 .vmux = 8, 4500 .vmux = 8,
4650 .amux = LINE1, 4501 .amux = LINE1,
4651 } }, 4502 } },
4652 .radio = { 4503 .radio = {
4653 .name = name_radio, 4504 .type = SAA7134_INPUT_RADIO,
4654 .amux = LINE2, 4505 .amux = LINE2,
4655 }, 4506 },
4656 .mpeg = SAA7134_MPEG_EMPRESS, 4507 .mpeg = SAA7134_MPEG_EMPRESS,
@@ -4673,21 +4524,20 @@ struct saa7134_board saa7134_boards[] = {
4673 .empress_addr = 0x20, 4524 .empress_addr = 0x20,
4674 .tda9887_conf = TDA9887_PRESENT, 4525 .tda9887_conf = TDA9887_PRESENT,
4675 .inputs = { { 4526 .inputs = { {
4676 .name = name_tv, 4527 .type = SAA7134_INPUT_TV,
4677 .vmux = 3, 4528 .vmux = 3,
4678 .amux = TV, 4529 .amux = TV,
4679 .tv = 1,
4680 }, { 4530 }, {
4681 .name = name_comp1, 4531 .type = SAA7134_INPUT_COMPOSITE1,
4682 .vmux = 1, 4532 .vmux = 1,
4683 .amux = LINE1, 4533 .amux = LINE1,
4684 }, { 4534 }, {
4685 .name = name_svideo, 4535 .type = SAA7134_INPUT_SVIDEO,
4686 .vmux = 8, 4536 .vmux = 8,
4687 .amux = LINE1, 4537 .amux = LINE1,
4688 } }, 4538 } },
4689 .radio = { 4539 .radio = {
4690 .name = name_radio, 4540 .type = SAA7134_INPUT_RADIO,
4691 .amux = LINE2, 4541 .amux = LINE2,
4692 }, 4542 },
4693 .mpeg = SAA7134_MPEG_EMPRESS, 4543 .mpeg = SAA7134_MPEG_EMPRESS,
@@ -4712,21 +4562,20 @@ struct saa7134_board saa7134_boards[] = {
4712 .empress_addr = 0x20, 4562 .empress_addr = 0x20,
4713 .tda9887_conf = TDA9887_PRESENT, 4563 .tda9887_conf = TDA9887_PRESENT,
4714 .inputs = { { 4564 .inputs = { {
4715 .name = name_tv, 4565 .type = SAA7134_INPUT_TV,
4716 .vmux = 3, 4566 .vmux = 3,
4717 .amux = TV, 4567 .amux = TV,
4718 .tv = 1,
4719 }, { 4568 }, {
4720 .name = name_comp1, 4569 .type = SAA7134_INPUT_COMPOSITE1,
4721 .vmux = 1, 4570 .vmux = 1,
4722 .amux = LINE1, 4571 .amux = LINE1,
4723 }, { 4572 }, {
4724 .name = name_svideo, 4573 .type = SAA7134_INPUT_SVIDEO,
4725 .vmux = 8, 4574 .vmux = 8,
4726 .amux = LINE1, 4575 .amux = LINE1,
4727 } }, 4576 } },
4728 .radio = { 4577 .radio = {
4729 .name = name_radio, 4578 .type = SAA7134_INPUT_RADIO,
4730 .amux = LINE2, 4579 .amux = LINE2,
4731 }, 4580 },
4732 .mpeg = SAA7134_MPEG_EMPRESS, 4581 .mpeg = SAA7134_MPEG_EMPRESS,
@@ -4747,21 +4596,20 @@ struct saa7134_board saa7134_boards[] = {
4747 .mpeg = SAA7134_MPEG_DVB, 4596 .mpeg = SAA7134_MPEG_DVB,
4748 .gpiomask = 0x0200000, 4597 .gpiomask = 0x0200000,
4749 .inputs = {{ 4598 .inputs = {{
4750 .name = name_tv, 4599 .type = SAA7134_INPUT_TV,
4751 .vmux = 1, 4600 .vmux = 1,
4752 .amux = TV, 4601 .amux = TV,
4753 .tv = 1,
4754 }, { 4602 }, {
4755 .name = name_comp1, 4603 .type = SAA7134_INPUT_COMPOSITE1,
4756 .vmux = 3, 4604 .vmux = 3,
4757 .amux = LINE1, 4605 .amux = LINE1,
4758 }, { 4606 }, {
4759 .name = name_svideo, 4607 .type = SAA7134_INPUT_SVIDEO,
4760 .vmux = 8, /* untested */ 4608 .vmux = 8, /* untested */
4761 .amux = LINE1, 4609 .amux = LINE1,
4762 } }, 4610 } },
4763 .radio = { 4611 .radio = {
4764 .name = name_radio, 4612 .type = SAA7134_INPUT_RADIO,
4765 .amux = TV, 4613 .amux = TV,
4766 .gpio = 0x0200000, 4614 .gpio = 0x0200000,
4767 }, 4615 },
@@ -4776,30 +4624,28 @@ struct saa7134_board saa7134_boards[] = {
4776 .radio_addr = ADDR_UNSET, 4624 .radio_addr = ADDR_UNSET,
4777 .gpiomask = 0xf000, 4625 .gpiomask = 0xf000,
4778 .inputs = {{ 4626 .inputs = {{
4779 .name = name_tv_mono, 4627 .type = SAA7134_INPUT_TV_MONO,
4780 .vmux = 1, 4628 .vmux = 1,
4781 .amux = LINE2, 4629 .amux = LINE2,
4782 .gpio = 0x0000, 4630 .gpio = 0x0000,
4783 .tv = 1,
4784 }, { 4631 }, {
4785 .name = name_comp1, 4632 .type = SAA7134_INPUT_COMPOSITE1,
4786 .vmux = 3, 4633 .vmux = 3,
4787 .amux = LINE1, 4634 .amux = LINE1,
4788 .gpio = 0x2000, 4635 .gpio = 0x2000,
4789 .tv = 1
4790 }, { 4636 }, {
4791 .name = name_svideo, 4637 .type = SAA7134_INPUT_SVIDEO,
4792 .vmux = 8, 4638 .vmux = 8,
4793 .amux = LINE1, 4639 .amux = LINE1,
4794 .gpio = 0x2000, 4640 .gpio = 0x2000,
4795 } }, 4641 } },
4796 .radio = { 4642 .radio = {
4797 .name = name_radio, 4643 .type = SAA7134_INPUT_RADIO,
4798 .amux = LINE2, 4644 .amux = LINE2,
4799 .gpio = 0x1000, 4645 .gpio = 0x1000,
4800 }, 4646 },
4801 .mute = { 4647 .mute = {
4802 .name = name_mute, 4648 .type = SAA7134_INPUT_MUTE,
4803 .amux = LINE2, 4649 .amux = LINE2,
4804 .gpio = 0x6000, 4650 .gpio = 0x6000,
4805 }, 4651 },
@@ -4813,11 +4659,11 @@ struct saa7134_board saa7134_boards[] = {
4813 .radio_addr = ADDR_UNSET, 4659 .radio_addr = ADDR_UNSET,
4814 .mpeg = SAA7134_MPEG_DVB, 4660 .mpeg = SAA7134_MPEG_DVB,
4815 .inputs = {{ 4661 .inputs = {{
4816 .name = name_comp1, 4662 .type = SAA7134_INPUT_COMPOSITE1,
4817 .vmux = 3, 4663 .vmux = 3,
4818 .amux = LINE1, 4664 .amux = LINE1,
4819 }, { 4665 }, {
4820 .name = name_svideo, 4666 .type = SAA7134_INPUT_SVIDEO,
4821 .vmux = 8, 4667 .vmux = 8,
4822 .amux = LINE1, 4668 .amux = LINE1,
4823 } }, 4669 } },
@@ -4832,16 +4678,15 @@ struct saa7134_board saa7134_boards[] = {
4832 .tda829x_conf = { .lna_cfg = TDA8290_LNA_OFF }, 4678 .tda829x_conf = { .lna_cfg = TDA8290_LNA_OFF },
4833 .mpeg = SAA7134_MPEG_DVB, 4679 .mpeg = SAA7134_MPEG_DVB,
4834 .inputs = {{ 4680 .inputs = {{
4835 .name = name_tv, 4681 .type = SAA7134_INPUT_TV,
4836 .vmux = 1, 4682 .vmux = 1,
4837 .amux = TV, 4683 .amux = TV,
4838 .tv = 1,
4839 }, { 4684 }, {
4840 .name = name_comp1, 4685 .type = SAA7134_INPUT_COMPOSITE1,
4841 .vmux = 0, 4686 .vmux = 0,
4842 .amux = LINE1, 4687 .amux = LINE1,
4843 }, { 4688 }, {
4844 .name = name_svideo, 4689 .type = SAA7134_INPUT_SVIDEO,
4845 .vmux = 8, 4690 .vmux = 8,
4846 .amux = LINE1, 4691 .amux = LINE1,
4847 } }, 4692 } },
@@ -4857,21 +4702,20 @@ struct saa7134_board saa7134_boards[] = {
4857 .mpeg = SAA7134_MPEG_DVB, 4702 .mpeg = SAA7134_MPEG_DVB,
4858 .gpiomask = 0x0200000, 4703 .gpiomask = 0x0200000,
4859 .inputs = { { 4704 .inputs = { {
4860 .name = name_tv, 4705 .type = SAA7134_INPUT_TV,
4861 .vmux = 1, 4706 .vmux = 1,
4862 .amux = TV, 4707 .amux = TV,
4863 .tv = 1,
4864 }, { 4708 }, {
4865 .name = name_comp1, 4709 .type = SAA7134_INPUT_COMPOSITE1,
4866 .vmux = 3, 4710 .vmux = 3,
4867 .amux = LINE1, 4711 .amux = LINE1,
4868 }, { 4712 }, {
4869 .name = name_svideo, 4713 .type = SAA7134_INPUT_SVIDEO,
4870 .vmux = 8, 4714 .vmux = 8,
4871 .amux = LINE1, 4715 .amux = LINE1,
4872 } }, 4716 } },
4873 .radio = { 4717 .radio = {
4874 .name = name_radio, 4718 .type = SAA7134_INPUT_RADIO,
4875 .amux = TV, 4719 .amux = TV,
4876 .gpio = 0x0200000, 4720 .gpio = 0x0200000,
4877 }, 4721 },
@@ -4885,21 +4729,20 @@ struct saa7134_board saa7134_boards[] = {
4885 .radio_addr = ADDR_UNSET, 4729 .radio_addr = ADDR_UNSET,
4886 .mpeg = SAA7134_MPEG_DVB, 4730 .mpeg = SAA7134_MPEG_DVB,
4887 .inputs = {{ 4731 .inputs = {{
4888 .name = name_tv, 4732 .type = SAA7134_INPUT_TV,
4889 .vmux = 1, 4733 .vmux = 1,
4890 .amux = TV, 4734 .amux = TV,
4891 .tv = 1,
4892 }, { 4735 }, {
4893 .name = name_comp1, 4736 .type = SAA7134_INPUT_COMPOSITE1,
4894 .vmux = 3, 4737 .vmux = 3,
4895 .amux = LINE1, 4738 .amux = LINE1,
4896 }, { 4739 }, {
4897 .name = name_svideo, 4740 .type = SAA7134_INPUT_SVIDEO,
4898 .vmux = 8, 4741 .vmux = 8,
4899 .amux = LINE2, 4742 .amux = LINE2,
4900 } }, 4743 } },
4901 .radio = { 4744 .radio = {
4902 .name = name_radio, 4745 .type = SAA7134_INPUT_RADIO,
4903 .amux = TV, 4746 .amux = TV,
4904 }, 4747 },
4905 }, 4748 },
@@ -4912,21 +4755,20 @@ struct saa7134_board saa7134_boards[] = {
4912 .radio_addr = ADDR_UNSET, 4755 .radio_addr = ADDR_UNSET,
4913 .mpeg = SAA7134_MPEG_DVB, 4756 .mpeg = SAA7134_MPEG_DVB,
4914 .inputs = {{ 4757 .inputs = {{
4915 .name = name_tv, 4758 .type = SAA7134_INPUT_TV,
4916 .vmux = 1, 4759 .vmux = 1,
4917 .amux = TV, 4760 .amux = TV,
4918 .tv = 1,
4919 }, { 4761 }, {
4920 .name = name_svideo, 4762 .type = SAA7134_INPUT_SVIDEO,
4921 .vmux = 8, 4763 .vmux = 8,
4922 .amux = LINE1, 4764 .amux = LINE1,
4923 }, { 4765 }, {
4924 .name = name_comp, 4766 .type = SAA7134_INPUT_COMPOSITE,
4925 .vmux = 0, 4767 .vmux = 0,
4926 .amux = LINE1, 4768 .amux = LINE1,
4927 } }, 4769 } },
4928 .radio = { 4770 .radio = {
4929 .name = name_radio, 4771 .type = SAA7134_INPUT_RADIO,
4930 .amux = TV, 4772 .amux = TV,
4931 }, 4773 },
4932 }, 4774 },
@@ -4938,16 +4780,15 @@ struct saa7134_board saa7134_boards[] = {
4938 .tuner_addr = ADDR_UNSET, 4780 .tuner_addr = ADDR_UNSET,
4939 .radio_addr = ADDR_UNSET, 4781 .radio_addr = ADDR_UNSET,
4940 .inputs = {{ 4782 .inputs = {{
4941 .name = name_tv, 4783 .type = SAA7134_INPUT_TV,
4942 .vmux = 1, 4784 .vmux = 1,
4943 .amux = TV, 4785 .amux = TV,
4944 .tv = 1,
4945 }, { 4786 }, {
4946 .name = name_comp1, 4787 .type = SAA7134_INPUT_COMPOSITE1,
4947 .vmux = 3, 4788 .vmux = 3,
4948 .amux = LINE1, 4789 .amux = LINE1,
4949 }, { 4790 }, {
4950 .name = name_svideo, 4791 .type = SAA7134_INPUT_SVIDEO,
4951 .vmux = 8, 4792 .vmux = 8,
4952 .amux = LINE2, 4793 .amux = LINE2,
4953 } }, 4794 } },
@@ -4962,21 +4803,20 @@ struct saa7134_board saa7134_boards[] = {
4962 .radio_addr = ADDR_UNSET, 4803 .radio_addr = ADDR_UNSET,
4963 .mpeg = SAA7134_MPEG_DVB, 4804 .mpeg = SAA7134_MPEG_DVB,
4964 .inputs = {{ 4805 .inputs = {{
4965 .name = name_tv, 4806 .type = SAA7134_INPUT_TV,
4966 .vmux = 3, 4807 .vmux = 3,
4967 .amux = TV, 4808 .amux = TV,
4968 .tv = 1,
4969 }, { 4809 }, {
4970 .name = name_comp1, 4810 .type = SAA7134_INPUT_COMPOSITE1,
4971 .vmux = 1, 4811 .vmux = 1,
4972 .amux = LINE2, 4812 .amux = LINE2,
4973 }, { 4813 }, {
4974 .name = name_svideo, 4814 .type = SAA7134_INPUT_SVIDEO,
4975 .vmux = 8, 4815 .vmux = 8,
4976 .amux = LINE2, 4816 .amux = LINE2,
4977 } }, 4817 } },
4978 .radio = { 4818 .radio = {
4979 .name = name_radio, 4819 .type = SAA7134_INPUT_RADIO,
4980 .amux = TV, 4820 .amux = TV,
4981 } 4821 }
4982 }, 4822 },
@@ -4990,11 +4830,11 @@ struct saa7134_board saa7134_boards[] = {
4990 .radio_addr = ADDR_UNSET, 4830 .radio_addr = ADDR_UNSET,
4991 .mpeg = SAA7134_MPEG_DVB, 4831 .mpeg = SAA7134_MPEG_DVB,
4992 .inputs = { { 4832 .inputs = { {
4993 .name = name_comp, 4833 .type = SAA7134_INPUT_COMPOSITE,
4994 .vmux = 1, 4834 .vmux = 1,
4995 .amux = LINE1, 4835 .amux = LINE1,
4996 }, { 4836 }, {
4997 .name = name_svideo, 4837 .type = SAA7134_INPUT_SVIDEO,
4998 .vmux = 6, 4838 .vmux = 6,
4999 .amux = LINE1, 4839 .amux = LINE1,
5000 } }, 4840 } },
@@ -5009,21 +4849,20 @@ struct saa7134_board saa7134_boards[] = {
5009 .radio_addr = ADDR_UNSET, 4849 .radio_addr = ADDR_UNSET,
5010 .mpeg = SAA7134_MPEG_DVB, 4850 .mpeg = SAA7134_MPEG_DVB,
5011 .inputs = { { 4851 .inputs = { {
5012 .name = name_tv, 4852 .type = SAA7134_INPUT_TV,
5013 .vmux = 4, 4853 .vmux = 4,
5014 .amux = TV, 4854 .amux = TV,
5015 .tv = 1,
5016 }, { 4855 }, {
5017 .name = name_comp, 4856 .type = SAA7134_INPUT_COMPOSITE,
5018 .vmux = 1, 4857 .vmux = 1,
5019 .amux = LINE1, 4858 .amux = LINE1,
5020 }, { 4859 }, {
5021 .name = name_svideo, 4860 .type = SAA7134_INPUT_SVIDEO,
5022 .vmux = 6, 4861 .vmux = 6,
5023 .amux = LINE1, 4862 .amux = LINE1,
5024 } }, 4863 } },
5025 .radio = { 4864 .radio = {
5026 .name = name_radio, 4865 .type = SAA7134_INPUT_RADIO,
5027 .amux = TV, 4866 .amux = TV,
5028 }, 4867 },
5029 }, 4868 },
@@ -5038,21 +4877,20 @@ struct saa7134_board saa7134_boards[] = {
5038 .tda9887_conf = TDA9887_PRESENT, 4877 .tda9887_conf = TDA9887_PRESENT,
5039 .mpeg = SAA7134_MPEG_DVB, 4878 .mpeg = SAA7134_MPEG_DVB,
5040 .inputs = {{ 4879 .inputs = {{
5041 .name = name_tv, 4880 .type = SAA7134_INPUT_TV,
5042 .vmux = 3, 4881 .vmux = 3,
5043 .amux = TV, 4882 .amux = TV,
5044 .tv = 1,
5045 }, { 4883 }, {
5046 .name = name_comp1, 4884 .type = SAA7134_INPUT_COMPOSITE1,
5047 .vmux = 1, 4885 .vmux = 1,
5048 .amux = LINE1, 4886 .amux = LINE1,
5049 }, { 4887 }, {
5050 .name = name_svideo, 4888 .type = SAA7134_INPUT_SVIDEO,
5051 .vmux = 8, 4889 .vmux = 8,
5052 .amux = LINE1, 4890 .amux = LINE1,
5053 } }, 4891 } },
5054 .radio = { 4892 .radio = {
5055 .name = name_radio, 4893 .type = SAA7134_INPUT_RADIO,
5056 .amux = LINE2, 4894 .amux = LINE2,
5057 }, 4895 },
5058 }, 4896 },
@@ -5067,21 +4905,20 @@ struct saa7134_board saa7134_boards[] = {
5067 .gpiomask = 1 << 21, 4905 .gpiomask = 1 << 21,
5068 .mpeg = SAA7134_MPEG_DVB, 4906 .mpeg = SAA7134_MPEG_DVB,
5069 .inputs = {{ 4907 .inputs = {{
5070 .name = name_tv, 4908 .type = SAA7134_INPUT_TV,
5071 .vmux = 1, 4909 .vmux = 1,
5072 .amux = TV, 4910 .amux = TV,
5073 .tv = 1,
5074 }, { 4911 }, {
5075 .name = name_comp, 4912 .type = SAA7134_INPUT_COMPOSITE,
5076 .vmux = 0, 4913 .vmux = 0,
5077 .amux = LINE2, 4914 .amux = LINE2,
5078 }, { 4915 }, {
5079 .name = name_svideo, 4916 .type = SAA7134_INPUT_SVIDEO,
5080 .vmux = 8, 4917 .vmux = 8,
5081 .amux = LINE2, 4918 .amux = LINE2,
5082 } }, 4919 } },
5083 .radio = { 4920 .radio = {
5084 .name = name_radio, 4921 .type = SAA7134_INPUT_RADIO,
5085 .amux = TV, 4922 .amux = TV,
5086 .gpio = 0x0200000, 4923 .gpio = 0x0200000,
5087 }, 4924 },
@@ -5097,21 +4934,20 @@ struct saa7134_board saa7134_boards[] = {
5097 .gpiomask = 1 << 21, 4934 .gpiomask = 1 << 21,
5098 .mpeg = SAA7134_MPEG_DVB, 4935 .mpeg = SAA7134_MPEG_DVB,
5099 .inputs = {{ 4936 .inputs = {{
5100 .name = name_tv, 4937 .type = SAA7134_INPUT_TV,
5101 .vmux = 1, 4938 .vmux = 1,
5102 .amux = TV, 4939 .amux = TV,
5103 .tv = 1,
5104 }, { 4940 }, {
5105 .name = name_comp, 4941 .type = SAA7134_INPUT_COMPOSITE,
5106 .vmux = 0, 4942 .vmux = 0,
5107 .amux = LINE2, 4943 .amux = LINE2,
5108 }, { 4944 }, {
5109 .name = name_svideo, 4945 .type = SAA7134_INPUT_SVIDEO,
5110 .vmux = 8, 4946 .vmux = 8,
5111 .amux = LINE2, 4947 .amux = LINE2,
5112 } }, 4948 } },
5113 .radio = { 4949 .radio = {
5114 .name = name_radio, 4950 .type = SAA7134_INPUT_RADIO,
5115 .amux = TV, 4951 .amux = TV,
5116 .gpio = 0x0200000, 4952 .gpio = 0x0200000,
5117 }, 4953 },
@@ -5125,29 +4961,28 @@ struct saa7134_board saa7134_boards[] = {
5125 .radio_addr = ADDR_UNSET, 4961 .radio_addr = ADDR_UNSET,
5126 .gpiomask = 0x801a8087, 4962 .gpiomask = 0x801a8087,
5127 .inputs = { { 4963 .inputs = { {
5128 .name = name_tv, 4964 .type = SAA7134_INPUT_TV,
5129 .vmux = 3, 4965 .vmux = 3,
5130 .amux = LINE2, 4966 .amux = LINE2,
5131 .tv = 1,
5132 .gpio = 0x624000, 4967 .gpio = 0x624000,
5133 }, { 4968 }, {
5134 .name = name_comp1, 4969 .type = SAA7134_INPUT_COMPOSITE1,
5135 .vmux = 1, 4970 .vmux = 1,
5136 .amux = LINE1, 4971 .amux = LINE1,
5137 .gpio = 0x624000, 4972 .gpio = 0x624000,
5138 }, { 4973 }, {
5139 .name = name_svideo, 4974 .type = SAA7134_INPUT_SVIDEO,
5140 .vmux = 1, 4975 .vmux = 1,
5141 .amux = LINE1, 4976 .amux = LINE1,
5142 .gpio = 0x624000, 4977 .gpio = 0x624000,
5143 } }, 4978 } },
5144 .radio = { 4979 .radio = {
5145 .name = name_radio, 4980 .type = SAA7134_INPUT_RADIO,
5146 .amux = LINE2, 4981 .amux = LINE2,
5147 .gpio = 0x624001, 4982 .gpio = 0x624001,
5148 }, 4983 },
5149 .mute = { 4984 .mute = {
5150 .name = name_mute, 4985 .type = SAA7134_INPUT_MUTE,
5151 .amux = TV, 4986 .amux = TV,
5152 }, 4987 },
5153 }, 4988 },
@@ -5161,16 +4996,15 @@ struct saa7134_board saa7134_boards[] = {
5161 .tda9887_conf = TDA9887_PRESENT, 4996 .tda9887_conf = TDA9887_PRESENT,
5162 .mpeg = SAA7134_MPEG_DVB, 4997 .mpeg = SAA7134_MPEG_DVB,
5163 .inputs = { { 4998 .inputs = { {
5164 .name = name_tv, 4999 .type = SAA7134_INPUT_TV,
5165 .vmux = 1, 5000 .vmux = 1,
5166 .amux = TV, 5001 .amux = TV,
5167 .tv = 1,
5168 }, { 5002 }, {
5169 .name = name_comp, 5003 .type = SAA7134_INPUT_COMPOSITE,
5170 .vmux = 4, 5004 .vmux = 4,
5171 .amux = LINE1, 5005 .amux = LINE1,
5172 }, { 5006 }, {
5173 .name = name_svideo, 5007 .type = SAA7134_INPUT_SVIDEO,
5174 .vmux = 8, 5008 .vmux = 8,
5175 .amux = LINE1, 5009 .amux = LINE1,
5176 } }, 5010 } },
@@ -5186,25 +5020,24 @@ struct saa7134_board saa7134_boards[] = {
5186 .mpeg = SAA7134_MPEG_DVB, 5020 .mpeg = SAA7134_MPEG_DVB,
5187 .gpiomask = 0x0200000, 5021 .gpiomask = 0x0200000,
5188 .inputs = { { 5022 .inputs = { {
5189 .name = name_tv, 5023 .type = SAA7134_INPUT_TV,
5190 .vmux = 1, 5024 .vmux = 1,
5191 .amux = TV, 5025 .amux = TV,
5192 .tv = 1,
5193 }, { 5026 }, {
5194 .name = name_comp1, 5027 .type = SAA7134_INPUT_COMPOSITE1,
5195 .vmux = 3, 5028 .vmux = 3,
5196 .amux = LINE2, 5029 .amux = LINE2,
5197 }, { 5030 }, {
5198 .name = name_comp2, 5031 .type = SAA7134_INPUT_COMPOSITE2,
5199 .vmux = 0, 5032 .vmux = 0,
5200 .amux = LINE2, 5033 .amux = LINE2,
5201 }, { 5034 }, {
5202 .name = name_svideo, 5035 .type = SAA7134_INPUT_SVIDEO,
5203 .vmux = 8, 5036 .vmux = 8,
5204 .amux = LINE2, 5037 .amux = LINE2,
5205 } }, 5038 } },
5206 .radio = { 5039 .radio = {
5207 .name = name_radio, 5040 .type = SAA7134_INPUT_RADIO,
5208 .amux = TV, 5041 .amux = TV,
5209 .gpio = 0x0200000, 5042 .gpio = 0x0200000,
5210 }, 5043 },
@@ -5218,30 +5051,29 @@ struct saa7134_board saa7134_boards[] = {
5218 .radio_addr = 0x60, 5051 .radio_addr = 0x60,
5219 .gpiomask = 0x80000700, 5052 .gpiomask = 0x80000700,
5220 .inputs = { { 5053 .inputs = { {
5221 .name = name_tv, 5054 .type = SAA7134_INPUT_TV,
5222 .vmux = 1, 5055 .vmux = 1,
5223 .amux = LINE2, 5056 .amux = LINE2,
5224 .tv = 1,
5225 .gpio = 0x100, 5057 .gpio = 0x100,
5226 }, { 5058 }, {
5227 .name = name_comp1, 5059 .type = SAA7134_INPUT_COMPOSITE1,
5228 .vmux = 3, 5060 .vmux = 3,
5229 .amux = LINE1, 5061 .amux = LINE1,
5230 .gpio = 0x200, 5062 .gpio = 0x200,
5231 }, { 5063 }, {
5232 .name = name_svideo, 5064 .type = SAA7134_INPUT_SVIDEO,
5233 .vmux = 8, 5065 .vmux = 8,
5234 .amux = LINE1, 5066 .amux = LINE1,
5235 .gpio = 0x200, 5067 .gpio = 0x200,
5236 } }, 5068 } },
5237 .radio = { 5069 .radio = {
5238 .name = name_radio, 5070 .type = SAA7134_INPUT_RADIO,
5239 .vmux = 1, 5071 .vmux = 1,
5240 .amux = LINE1, 5072 .amux = LINE1,
5241 .gpio = 0x100, 5073 .gpio = 0x100,
5242 }, 5074 },
5243 .mute = { 5075 .mute = {
5244 .name = name_mute, 5076 .type = SAA7134_INPUT_MUTE,
5245 .vmux = 8, 5077 .vmux = 8,
5246 .amux = 2, 5078 .amux = 2,
5247 }, 5079 },
@@ -5257,18 +5089,17 @@ struct saa7134_board saa7134_boards[] = {
5257 .mpeg = SAA7134_MPEG_DVB, 5089 .mpeg = SAA7134_MPEG_DVB,
5258 .ts_type = SAA7134_MPEG_TS_PARALLEL, 5090 .ts_type = SAA7134_MPEG_TS_PARALLEL,
5259 .inputs = { { 5091 .inputs = { {
5260 .name = name_tv, 5092 .type = SAA7134_INPUT_TV,
5261 .vmux = 1, 5093 .vmux = 1,
5262 .amux = TV, 5094 .amux = TV,
5263 .tv = 1,
5264#if 0 /* FIXME */ 5095#if 0 /* FIXME */
5265 }, { 5096 }, {
5266 .name = name_comp1, 5097 .type = SAA7134_INPUT_COMPOSITE1,
5267 .vmux = 3, 5098 .vmux = 3,
5268 .amux = LINE1, 5099 .amux = LINE1,
5269 .gpio = 0x200, 5100 .gpio = 0x200,
5270 }, { 5101 }, {
5271 .name = name_svideo, 5102 .type = SAA7134_INPUT_SVIDEO,
5272 .vmux = 8, 5103 .vmux = 8,
5273 .amux = LINE1, 5104 .amux = LINE1,
5274 .gpio = 0x200, 5105 .gpio = 0x200,
@@ -5276,14 +5107,14 @@ struct saa7134_board saa7134_boards[] = {
5276 } }, 5107 } },
5277#if 0 5108#if 0
5278 .radio = { 5109 .radio = {
5279 .name = name_radio, 5110 .type = SAA7134_INPUT_RADIO,
5280 .vmux = 1, 5111 .vmux = 1,
5281 .amux = LINE1, 5112 .amux = LINE1,
5282 .gpio = 0x100, 5113 .gpio = 0x100,
5283 }, 5114 },
5284#endif 5115#endif
5285 .mute = { 5116 .mute = {
5286 .name = name_mute, 5117 .type = SAA7134_INPUT_MUTE,
5287 .vmux = 0, 5118 .vmux = 0,
5288 .amux = TV, 5119 .amux = TV,
5289 }, 5120 },
@@ -5298,24 +5129,23 @@ struct saa7134_board saa7134_boards[] = {
5298 .gpiomask = 0x00300003, 5129 .gpiomask = 0x00300003,
5299 /* .gpiomask = 0x8c240003, */ 5130 /* .gpiomask = 0x8c240003, */
5300 .inputs = { { 5131 .inputs = { {
5301 .name = name_tv, 5132 .type = SAA7134_INPUT_TV,
5302 .vmux = 1, 5133 .vmux = 1,
5303 .amux = TV, 5134 .amux = TV,
5304 .tv = 1,
5305 .gpio = 0x01, 5135 .gpio = 0x01,
5306 }, { 5136 }, {
5307 .name = name_svideo, 5137 .type = SAA7134_INPUT_SVIDEO,
5308 .vmux = 6, 5138 .vmux = 6,
5309 .amux = LINE1, 5139 .amux = LINE1,
5310 .gpio = 0x02, 5140 .gpio = 0x02,
5311 } }, 5141 } },
5312 .radio = { 5142 .radio = {
5313 .name = name_radio, 5143 .type = SAA7134_INPUT_RADIO,
5314 .amux = TV, 5144 .amux = TV,
5315 .gpio = 0x00300001, 5145 .gpio = 0x00300001,
5316 }, 5146 },
5317 .mute = { 5147 .mute = {
5318 .name = name_mute, 5148 .type = SAA7134_INPUT_MUTE,
5319 .amux = TV, 5149 .amux = TV,
5320 .gpio = 0x01, 5150 .gpio = 0x01,
5321 }, 5151 },
@@ -5331,29 +5161,28 @@ struct saa7134_board saa7134_boards[] = {
5331 .tda9887_conf = TDA9887_PRESENT, 5161 .tda9887_conf = TDA9887_PRESENT,
5332 .gpiomask = 0x03, 5162 .gpiomask = 0x03,
5333 .inputs = { { 5163 .inputs = { {
5334 .name = name_tv, 5164 .type = SAA7134_INPUT_TV,
5335 .vmux = 1, 5165 .vmux = 1,
5336 .amux = TV, 5166 .amux = TV,
5337 .tv = 1,
5338 .gpio = 0x00, 5167 .gpio = 0x00,
5339 }, { 5168 }, {
5340 .name = name_comp1, 5169 .type = SAA7134_INPUT_COMPOSITE1,
5341 .vmux = 3, 5170 .vmux = 3,
5342 .amux = LINE1, 5171 .amux = LINE1,
5343 .gpio = 0x00, 5172 .gpio = 0x00,
5344 }, { 5173 }, {
5345 .name = name_svideo, 5174 .type = SAA7134_INPUT_SVIDEO,
5346 .vmux = 8, 5175 .vmux = 8,
5347 .amux = LINE1, 5176 .amux = LINE1,
5348 .gpio = 0x00, 5177 .gpio = 0x00,
5349 } }, 5178 } },
5350 .radio = { 5179 .radio = {
5351 .name = name_radio, 5180 .type = SAA7134_INPUT_RADIO,
5352 .amux = LINE2, 5181 .amux = LINE2,
5353 .gpio = 0x01, 5182 .gpio = 0x01,
5354 }, 5183 },
5355 .mute = { 5184 .mute = {
5356 .name = name_mute, 5185 .type = SAA7134_INPUT_MUTE,
5357 .amux = LINE1, 5186 .amux = LINE1,
5358 .gpio = 0x00, 5187 .gpio = 0x00,
5359 }, 5188 },
@@ -5368,11 +5197,11 @@ struct saa7134_board saa7134_boards[] = {
5368 .radio_addr = ADDR_UNSET, 5197 .radio_addr = ADDR_UNSET,
5369 .mpeg = SAA7134_MPEG_DVB, 5198 .mpeg = SAA7134_MPEG_DVB,
5370 .inputs = { { 5199 .inputs = { {
5371 .name = name_comp1, 5200 .type = SAA7134_INPUT_COMPOSITE1,
5372 .vmux = 0, 5201 .vmux = 0,
5373 .amux = LINE1, 5202 .amux = LINE1,
5374 }, { 5203 }, {
5375 .name = name_svideo, 5204 .type = SAA7134_INPUT_SVIDEO,
5376 .vmux = 8, /* Not tested */ 5205 .vmux = 8, /* Not tested */
5377 .amux = LINE1 5206 .amux = LINE1
5378 } }, 5207 } },
@@ -5387,21 +5216,20 @@ struct saa7134_board saa7134_boards[] = {
5387 .radio_addr = ADDR_UNSET, 5216 .radio_addr = ADDR_UNSET,
5388 .mpeg = SAA7134_MPEG_DVB, 5217 .mpeg = SAA7134_MPEG_DVB,
5389 .inputs = { { 5218 .inputs = { {
5390 .name = name_tv, 5219 .type = SAA7134_INPUT_TV,
5391 .vmux = 2, 5220 .vmux = 2,
5392 .amux = TV, 5221 .amux = TV,
5393 .tv = 1,
5394 }, { 5222 }, {
5395 .name = name_comp1, 5223 .type = SAA7134_INPUT_COMPOSITE1,
5396 .vmux = 0, 5224 .vmux = 0,
5397 .amux = LINE1, 5225 .amux = LINE1,
5398 }, { 5226 }, {
5399 .name = name_svideo, 5227 .type = SAA7134_INPUT_SVIDEO,
5400 .vmux = 9, 5228 .vmux = 9,
5401 .amux = LINE1, 5229 .amux = LINE1,
5402 } }, 5230 } },
5403 .radio = { 5231 .radio = {
5404 .name = name_radio, 5232 .type = SAA7134_INPUT_RADIO,
5405 .amux = TV, 5233 .amux = TV,
5406 }, 5234 },
5407 }, 5235 },
@@ -5416,13 +5244,12 @@ struct saa7134_board saa7134_boards[] = {
5416 .mpeg = SAA7134_MPEG_DVB, 5244 .mpeg = SAA7134_MPEG_DVB,
5417 .ts_type = SAA7134_MPEG_TS_PARALLEL, 5245 .ts_type = SAA7134_MPEG_TS_PARALLEL,
5418 .inputs = {{ 5246 .inputs = {{
5419 .name = name_tv, 5247 .type = SAA7134_INPUT_TV,
5420 .vmux = 1, 5248 .vmux = 1,
5421 .amux = TV, 5249 .amux = TV,
5422 .tv = 1,
5423 } }, 5250 } },
5424 .radio = { /* untested */ 5251 .radio = { /* untested */
5425 .name = name_radio, 5252 .type = SAA7134_INPUT_RADIO,
5426 .amux = TV, 5253 .amux = TV,
5427 }, 5254 },
5428 }, 5255 },
@@ -5436,16 +5263,15 @@ struct saa7134_board saa7134_boards[] = {
5436 .tda9887_conf = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE, 5263 .tda9887_conf = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE,
5437 .mpeg = SAA7134_MPEG_DVB, 5264 .mpeg = SAA7134_MPEG_DVB,
5438 .inputs = { { 5265 .inputs = { {
5439 .name = name_tv, 5266 .type = SAA7134_INPUT_TV,
5440 .vmux = 3, 5267 .vmux = 3,
5441 .amux = TV, 5268 .amux = TV,
5442 .tv = 1,
5443 }, { 5269 }, {
5444 .name = name_comp1, 5270 .type = SAA7134_INPUT_COMPOSITE1,
5445 .vmux = 4, 5271 .vmux = 4,
5446 .amux = LINE2, 5272 .amux = LINE2,
5447 }, { 5273 }, {
5448 .name = name_svideo, 5274 .type = SAA7134_INPUT_SVIDEO,
5449 .vmux = 8, 5275 .vmux = 8,
5450 .amux = LINE2, 5276 .amux = LINE2,
5451 } }, 5277 } },
@@ -5459,10 +5285,10 @@ struct saa7134_board saa7134_boards[] = {
5459 .radio_addr = ADDR_UNSET, 5285 .radio_addr = ADDR_UNSET,
5460 .mpeg = SAA7134_MPEG_DVB, 5286 .mpeg = SAA7134_MPEG_DVB,
5461 .inputs = { { 5287 .inputs = { {
5462 .name = name_comp1, 5288 .type = SAA7134_INPUT_COMPOSITE1,
5463 .vmux = 3, 5289 .vmux = 3,
5464 }, { 5290 }, {
5465 .name = name_svideo, 5291 .type = SAA7134_INPUT_SVIDEO,
5466 .vmux = 8, 5292 .vmux = 8,
5467 } }, 5293 } },
5468 }, 5294 },
@@ -5479,25 +5305,24 @@ struct saa7134_board saa7134_boards[] = {
5479 .tda9887_conf = TDA9887_PRESENT, 5305 .tda9887_conf = TDA9887_PRESENT,
5480 .gpiomask = 0x00008000, 5306 .gpiomask = 0x00008000,
5481 .inputs = {{ 5307 .inputs = {{
5482 .name = name_tv, 5308 .type = SAA7134_INPUT_TV,
5483 .vmux = 3, 5309 .vmux = 3,
5484 .amux = LINE2, 5310 .amux = LINE2,
5485 .tv = 1,
5486 }, { 5311 }, {
5487 .name = name_comp1, 5312 .type = SAA7134_INPUT_COMPOSITE1,
5488 .vmux = 1, 5313 .vmux = 1,
5489 .amux = LINE1, 5314 .amux = LINE1,
5490 }, { 5315 }, {
5491 .name = name_svideo, 5316 .type = SAA7134_INPUT_SVIDEO,
5492 .vmux = 8, 5317 .vmux = 8,
5493 .amux = LINE1, 5318 .amux = LINE1,
5494 } }, 5319 } },
5495 .mute = { 5320 .mute = {
5496 .name = name_mute, 5321 .type = SAA7134_INPUT_MUTE,
5497 .amux = LINE1, 5322 .amux = LINE1,
5498 }, 5323 },
5499 .radio = { 5324 .radio = {
5500 .name = name_radio, 5325 .type = SAA7134_INPUT_RADIO,
5501 .amux = LINE2, 5326 .amux = LINE2,
5502 }, 5327 },
5503 }, 5328 },
@@ -5512,7 +5337,7 @@ struct saa7134_board saa7134_boards[] = {
5512 .radio_addr = ADDR_UNSET, 5337 .radio_addr = ADDR_UNSET,
5513 .gpiomask = 0x389c00, 5338 .gpiomask = 0x389c00,
5514 .inputs = {{ 5339 .inputs = {{
5515 .name = name_comp1, 5340 .type = SAA7134_INPUT_COMPOSITE1,
5516 .vmux = 3, 5341 .vmux = 3,
5517 .amux = LINE1, 5342 .amux = LINE1,
5518 .gpio = 0x01fc00, 5343 .gpio = 0x01fc00,
@@ -5529,21 +5354,20 @@ struct saa7134_board saa7134_boards[] = {
5529 .mpeg = SAA7134_MPEG_DVB, 5354 .mpeg = SAA7134_MPEG_DVB,
5530 .ts_type = SAA7134_MPEG_TS_PARALLEL, 5355 .ts_type = SAA7134_MPEG_TS_PARALLEL,
5531 .inputs = { { 5356 .inputs = { {
5532 .name = name_tv, 5357 .type = SAA7134_INPUT_TV,
5533 .vmux = 2, 5358 .vmux = 2,
5534 .amux = TV, 5359 .amux = TV,
5535 .tv = 1,
5536 }, { 5360 }, {
5537 .name = name_comp1, 5361 .type = SAA7134_INPUT_COMPOSITE1,
5538 .vmux = 0, 5362 .vmux = 0,
5539 .amux = LINE1, 5363 .amux = LINE1,
5540 }, { 5364 }, {
5541 .name = name_svideo, 5365 .type = SAA7134_INPUT_SVIDEO,
5542 .vmux = 9, 5366 .vmux = 9,
5543 .amux = LINE1, 5367 .amux = LINE1,
5544 } }, 5368 } },
5545 .radio = { 5369 .radio = {
5546 .name = name_radio, 5370 .type = SAA7134_INPUT_RADIO,
5547 .amux = TV, 5371 .amux = TV,
5548 }, 5372 },
5549 }, 5373 },
@@ -5556,21 +5380,20 @@ struct saa7134_board saa7134_boards[] = {
5556 .tuner_addr = ADDR_UNSET, 5380 .tuner_addr = ADDR_UNSET,
5557 .radio_addr = ADDR_UNSET, 5381 .radio_addr = ADDR_UNSET,
5558 .inputs = { { 5382 .inputs = { {
5559 .name = name_tv, 5383 .type = SAA7134_INPUT_TV,
5560 .vmux = 2, 5384 .vmux = 2,
5561 .amux = TV, 5385 .amux = TV,
5562 .tv = 1,
5563 }, { 5386 }, {
5564 .name = name_comp1, 5387 .type = SAA7134_INPUT_COMPOSITE1,
5565 .vmux = 0, 5388 .vmux = 0,
5566 .amux = LINE1, 5389 .amux = LINE1,
5567 }, { 5390 }, {
5568 .name = name_svideo, 5391 .type = SAA7134_INPUT_SVIDEO,
5569 .vmux = 9, 5392 .vmux = 9,
5570 .amux = LINE1, 5393 .amux = LINE1,
5571 } }, 5394 } },
5572 .radio = { 5395 .radio = {
5573 .name = name_radio, 5396 .type = SAA7134_INPUT_RADIO,
5574 .amux = TV, 5397 .amux = TV,
5575 }, 5398 },
5576 }, 5399 },
@@ -5584,16 +5407,15 @@ struct saa7134_board saa7134_boards[] = {
5584 .tda9887_conf = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE, 5407 .tda9887_conf = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE,
5585 .mpeg = SAA7134_MPEG_DVB, 5408 .mpeg = SAA7134_MPEG_DVB,
5586 .inputs = {{ 5409 .inputs = {{
5587 .name = name_tv, 5410 .type = SAA7134_INPUT_TV,
5588 .vmux = 3, 5411 .vmux = 3,
5589 .amux = TV, 5412 .amux = TV,
5590 .tv = 1,
5591 }, { 5413 }, {
5592 .name = name_comp1, 5414 .type = SAA7134_INPUT_COMPOSITE1,
5593 .vmux = 0, 5415 .vmux = 0,
5594 .amux = LINE2, 5416 .amux = LINE2,
5595 }, { 5417 }, {
5596 .name = name_svideo, 5418 .type = SAA7134_INPUT_SVIDEO,
5597 .vmux = 8, 5419 .vmux = 8,
5598 .amux = LINE2, 5420 .amux = LINE2,
5599 } }, 5421 } },
@@ -5607,25 +5429,24 @@ struct saa7134_board saa7134_boards[] = {
5607 .tuner_addr = ADDR_UNSET, 5429 .tuner_addr = ADDR_UNSET,
5608 .radio_addr = 0x60, 5430 .radio_addr = 0x60,
5609 .inputs = { { 5431 .inputs = { {
5610 .name = name_tv, 5432 .type = SAA7134_INPUT_TV,
5611 .vmux = 1, 5433 .vmux = 1,
5612 .amux = TV, 5434 .amux = TV,
5613 .tv = 1,
5614 }, { 5435 }, {
5615 .name = name_comp1, 5436 .type = SAA7134_INPUT_COMPOSITE1,
5616 .vmux = 3, 5437 .vmux = 3,
5617 .amux = LINE2, 5438 .amux = LINE2,
5618 }, { 5439 }, {
5619 .name = name_svideo, 5440 .type = SAA7134_INPUT_SVIDEO,
5620 .vmux = 8, 5441 .vmux = 8,
5621 .amux = LINE2, 5442 .amux = LINE2,
5622 } }, 5443 } },
5623 .radio = { 5444 .radio = {
5624 .name = name_radio, 5445 .type = SAA7134_INPUT_RADIO,
5625 .amux = LINE1, 5446 .amux = LINE1,
5626 }, 5447 },
5627 .mute = { 5448 .mute = {
5628 .name = name_mute, 5449 .type = SAA7134_INPUT_MUTE,
5629 .amux = TV, 5450 .amux = TV,
5630 }, 5451 },
5631 }, 5452 },
@@ -5642,29 +5463,28 @@ struct saa7134_board saa7134_boards[] = {
5642 .mpeg = SAA7134_MPEG_DVB, 5463 .mpeg = SAA7134_MPEG_DVB,
5643 .ts_type = SAA7134_MPEG_TS_PARALLEL, 5464 .ts_type = SAA7134_MPEG_TS_PARALLEL,
5644 .inputs = { { 5465 .inputs = { {
5645 .name = name_tv, 5466 .type = SAA7134_INPUT_TV,
5646 .vmux = 1, 5467 .vmux = 1,
5647 .amux = TV, 5468 .amux = TV,
5648 .tv = 1,
5649 .gpio = 0x00050000, 5469 .gpio = 0x00050000,
5650 }, { 5470 }, {
5651 .name = name_comp1, 5471 .type = SAA7134_INPUT_COMPOSITE1,
5652 .vmux = 3, 5472 .vmux = 3,
5653 .amux = LINE1, 5473 .amux = LINE1,
5654 .gpio = 0x00050000, 5474 .gpio = 0x00050000,
5655 }, { 5475 }, {
5656 .name = name_svideo, 5476 .type = SAA7134_INPUT_SVIDEO,
5657 .vmux = 8, 5477 .vmux = 8,
5658 .amux = LINE1, 5478 .amux = LINE1,
5659 .gpio = 0x00050000, 5479 .gpio = 0x00050000,
5660 } }, 5480 } },
5661 .radio = { 5481 .radio = {
5662 .name = name_radio, 5482 .type = SAA7134_INPUT_RADIO,
5663 .amux = TV, 5483 .amux = TV,
5664 .gpio = 0x00050000, 5484 .gpio = 0x00050000,
5665 }, 5485 },
5666 .mute = { 5486 .mute = {
5667 .name = name_mute, 5487 .type = SAA7134_INPUT_MUTE,
5668 .vmux = 0, 5488 .vmux = 0,
5669 .amux = TV, 5489 .amux = TV,
5670 .gpio = 0x00050000, 5490 .gpio = 0x00050000,
@@ -5681,21 +5501,20 @@ struct saa7134_board saa7134_boards[] = {
5681 .radio_addr = ADDR_UNSET, 5501 .radio_addr = ADDR_UNSET,
5682 .gpiomask = 0x00008000, 5502 .gpiomask = 0x00008000,
5683 .inputs = { { 5503 .inputs = { {
5684 .name = name_tv, 5504 .type = SAA7134_INPUT_TV,
5685 .vmux = 3, 5505 .vmux = 3,
5686 .amux = LINE2, 5506 .amux = LINE2,
5687 .tv = 1,
5688 }, { 5507 }, {
5689 .name = name_comp1, 5508 .type = SAA7134_INPUT_COMPOSITE1,
5690 .vmux = 1, 5509 .vmux = 1,
5691 .amux = LINE1, 5510 .amux = LINE1,
5692 }, { 5511 }, {
5693 .name = name_svideo, 5512 .type = SAA7134_INPUT_SVIDEO,
5694 .vmux = 8, 5513 .vmux = 8,
5695 .amux = LINE1, 5514 .amux = LINE1,
5696 } }, 5515 } },
5697 .mute = { 5516 .mute = {
5698 .name = name_mute, 5517 .type = SAA7134_INPUT_MUTE,
5699 .amux = LINE1, 5518 .amux = LINE1,
5700 }, 5519 },
5701 }, 5520 },
@@ -5710,21 +5529,20 @@ struct saa7134_board saa7134_boards[] = {
5710 .radio_addr = ADDR_UNSET, 5529 .radio_addr = ADDR_UNSET,
5711 .gpiomask = 0x00008000, 5530 .gpiomask = 0x00008000,
5712 .inputs = { { 5531 .inputs = { {
5713 .name = name_tv, 5532 .type = SAA7134_INPUT_TV,
5714 .vmux = 3, 5533 .vmux = 3,
5715 .amux = LINE2, 5534 .amux = LINE2,
5716 .tv = 1,
5717 }, { 5535 }, {
5718 .name = name_comp1, 5536 .type = SAA7134_INPUT_COMPOSITE1,
5719 .vmux = 1, 5537 .vmux = 1,
5720 .amux = LINE1, 5538 .amux = LINE1,
5721 }, { 5539 }, {
5722 .name = name_svideo, 5540 .type = SAA7134_INPUT_SVIDEO,
5723 .vmux = 8, 5541 .vmux = 8,
5724 .amux = LINE1, 5542 .amux = LINE1,
5725 } }, 5543 } },
5726 .mute = { 5544 .mute = {
5727 .name = name_mute, 5545 .type = SAA7134_INPUT_MUTE,
5728 .amux = LINE1, 5546 .amux = LINE1,
5729 }, 5547 },
5730 }, 5548 },
@@ -5736,15 +5554,15 @@ struct saa7134_board saa7134_boards[] = {
5736 .tuner_addr = ADDR_UNSET, 5554 .tuner_addr = ADDR_UNSET,
5737 .radio_addr = ADDR_UNSET, 5555 .radio_addr = ADDR_UNSET,
5738 .inputs = {{ 5556 .inputs = {{
5739 .name = name_comp1, 5557 .type = SAA7134_INPUT_COMPOSITE1,
5740 .vmux = 0, 5558 .vmux = 0,
5741 .amux = LINE1, 5559 .amux = LINE1,
5742 }, { 5560 }, {
5743 .name = name_comp3, 5561 .type = SAA7134_INPUT_COMPOSITE3,
5744 .vmux = 2, 5562 .vmux = 2,
5745 .amux = LINE1, 5563 .amux = LINE1,
5746 }, { 5564 }, {
5747 .name = name_svideo, 5565 .type = SAA7134_INPUT_SVIDEO,
5748 .vmux = 8, 5566 .vmux = 8,
5749 .amux = LINE1, 5567 .amux = LINE1,
5750 } }, 5568 } },
@@ -5760,21 +5578,20 @@ struct saa7134_board saa7134_boards[] = {
5760 .gpiomask = 1 << 21, 5578 .gpiomask = 1 << 21,
5761 .ts_type = SAA7134_MPEG_TS_PARALLEL, 5579 .ts_type = SAA7134_MPEG_TS_PARALLEL,
5762 .inputs = { { 5580 .inputs = { {
5763 .name = name_tv, 5581 .type = SAA7134_INPUT_TV,
5764 .vmux = 1, 5582 .vmux = 1,
5765 .amux = TV, 5583 .amux = TV,
5766 .tv = 1,
5767 }, { 5584 }, {
5768 .name = name_comp, 5585 .type = SAA7134_INPUT_COMPOSITE,
5769 .vmux = 3, 5586 .vmux = 3,
5770 .amux = LINE1, 5587 .amux = LINE1,
5771 }, { 5588 }, {
5772 .name = name_svideo, 5589 .type = SAA7134_INPUT_SVIDEO,
5773 .vmux = 8, 5590 .vmux = 8,
5774 .amux = LINE2, 5591 .amux = LINE2,
5775 } }, 5592 } },
5776 .radio = { 5593 .radio = {
5777 .name = name_radio, 5594 .type = SAA7134_INPUT_RADIO,
5778 .amux = TV, 5595 .amux = TV,
5779 .gpio = 0x0000000, 5596 .gpio = 0x0000000,
5780 }, 5597 },
@@ -5790,7 +5607,7 @@ struct saa7134_board saa7134_boards[] = {
5790 .radio_addr = ADDR_UNSET, 5607 .radio_addr = ADDR_UNSET,
5791 .gpiomask = 0x618E700, 5608 .gpiomask = 0x618E700,
5792 .inputs = {{ 5609 .inputs = {{
5793 .name = name_comp1, 5610 .type = SAA7134_INPUT_COMPOSITE1,
5794 .vmux = 3, 5611 .vmux = 3,
5795 .amux = LINE1, 5612 .amux = LINE1,
5796 .gpio = 0x6010000, 5613 .gpio = 0x6010000,
@@ -5809,21 +5626,20 @@ struct saa7134_board saa7134_boards[] = {
5809 .gpiomask = 1 << 11, 5626 .gpiomask = 1 << 11,
5810 .mpeg = SAA7134_MPEG_DVB, 5627 .mpeg = SAA7134_MPEG_DVB,
5811 .inputs = {{ 5628 .inputs = {{
5812 .name = name_tv, 5629 .type = SAA7134_INPUT_TV,
5813 .vmux = 1, 5630 .vmux = 1,
5814 .amux = TV, 5631 .amux = TV,
5815 .tv = 1,
5816 }, { 5632 }, {
5817 .name = name_comp, 5633 .type = SAA7134_INPUT_COMPOSITE,
5818 .vmux = 4, 5634 .vmux = 4,
5819 .amux = LINE1, 5635 .amux = LINE1,
5820 }, { 5636 }, {
5821 .name = name_svideo, 5637 .type = SAA7134_INPUT_SVIDEO,
5822 .vmux = 8, 5638 .vmux = 8,
5823 .amux = LINE1, 5639 .amux = LINE1,
5824 } }, 5640 } },
5825 .radio = { 5641 .radio = {
5826 .name = name_radio, 5642 .type = SAA7134_INPUT_RADIO,
5827 .amux = TV, 5643 .amux = TV,
5828 .gpio = 0x0000800, 5644 .gpio = 0x0000800,
5829 }, 5645 },
@@ -5837,16 +5653,15 @@ struct saa7134_board saa7134_boards[] = {
5837 .radio_addr = ADDR_UNSET, 5653 .radio_addr = ADDR_UNSET,
5838 .mpeg = SAA7134_MPEG_GO7007, 5654 .mpeg = SAA7134_MPEG_GO7007,
5839 .inputs = { { 5655 .inputs = { {
5840 .name = name_comp1, 5656 .type = SAA7134_INPUT_COMPOSITE1,
5841 .vmux = 0, 5657 .vmux = 0,
5842 .amux = LINE2, 5658 .amux = LINE2,
5843 }, { 5659 }, {
5844 .name = name_tv, 5660 .type = SAA7134_INPUT_TV,
5845 .vmux = 3, 5661 .vmux = 3,
5846 .amux = TV, 5662 .amux = TV,
5847 .tv = 1,
5848 }, { 5663 }, {
5849 .name = name_svideo, 5664 .type = SAA7134_INPUT_SVIDEO,
5850 .vmux = 6, 5665 .vmux = 6,
5851 .amux = LINE1, 5666 .amux = LINE1,
5852 } }, 5667 } },
@@ -5862,25 +5677,24 @@ struct saa7134_board saa7134_boards[] = {
5862 .radio_addr = ADDR_UNSET, 5677 .radio_addr = ADDR_UNSET,
5863 .tda9887_conf = TDA9887_PRESENT, 5678 .tda9887_conf = TDA9887_PRESENT,
5864 .inputs = {{ 5679 .inputs = {{
5865 .name = name_tv, 5680 .type = SAA7134_INPUT_TV,
5866 .vmux = 1, 5681 .vmux = 1,
5867 .amux = LINE2, 5682 .amux = LINE2,
5868 .tv = 1,
5869 }, { 5683 }, {
5870 .name = name_comp1, 5684 .type = SAA7134_INPUT_COMPOSITE1,
5871 .vmux = 0, 5685 .vmux = 0,
5872 .amux = LINE2, 5686 .amux = LINE2,
5873 }, { 5687 }, {
5874 .name = name_comp2, 5688 .type = SAA7134_INPUT_COMPOSITE2,
5875 .vmux = 3, 5689 .vmux = 3,
5876 .amux = LINE2, 5690 .amux = LINE2,
5877 }, { 5691 }, {
5878 .name = name_svideo, 5692 .type = SAA7134_INPUT_SVIDEO,
5879 .vmux = 8, 5693 .vmux = 8,
5880 .amux = LINE2, 5694 .amux = LINE2,
5881 } }, 5695 } },
5882 .mute = { 5696 .mute = {
5883 .name = name_mute, 5697 .type = SAA7134_INPUT_MUTE,
5884 .amux = LINE1, 5698 .amux = LINE1,
5885 }, 5699 },
5886 }, 5700 },
@@ -5893,34 +5707,62 @@ struct saa7134_board saa7134_boards[] = {
5893 .radio_addr = ADDR_UNSET, 5707 .radio_addr = ADDR_UNSET,
5894 .gpiomask = 0x0d, 5708 .gpiomask = 0x0d,
5895 .inputs = {{ 5709 .inputs = {{
5896 .name = name_tv_mono, 5710 .type = SAA7134_INPUT_TV_MONO,
5897 .vmux = 1, 5711 .vmux = 1,
5898 .amux = LINE1, 5712 .amux = LINE1,
5899 .gpio = 0x00, 5713 .gpio = 0x00,
5900 .tv = 1,
5901 }, { 5714 }, {
5902 .name = name_comp1, 5715 .type = SAA7134_INPUT_COMPOSITE1,
5903 .vmux = 3, 5716 .vmux = 3,
5904 .amux = LINE2, 5717 .amux = LINE2,
5905 .gpio = 0x08, 5718 .gpio = 0x08,
5906 }, { 5719 }, {
5907 .name = name_svideo, 5720 .type = SAA7134_INPUT_SVIDEO,
5908 .vmux = 8, 5721 .vmux = 8,
5909 .amux = LINE2, 5722 .amux = LINE2,
5910 .gpio = 0x08, 5723 .gpio = 0x08,
5911 } }, 5724 } },
5912 .radio = { 5725 .radio = {
5913 .name = name_radio, 5726 .type = SAA7134_INPUT_RADIO,
5914 .amux = LINE1, 5727 .amux = LINE1,
5915 .gpio = 0x04, 5728 .gpio = 0x04,
5916 }, 5729 },
5917 .mute = { 5730 .mute = {
5918 .name = name_mute, 5731 .type = SAA7134_INPUT_MUTE,
5919 .amux = LINE1, 5732 .amux = LINE1,
5920 .gpio = 0x08, 5733 .gpio = 0x08,
5921 }, 5734 },
5922 }, 5735 },
5923 5736 [SAA7134_BOARD_SNAZIO_TVPVR_PRO] = {
5737 .name = "SnaZio* TVPVR PRO",
5738 .audio_clock = 0x00187de7,
5739 .tuner_type = TUNER_PHILIPS_TDA8290,
5740 .radio_type = UNSET,
5741 .tuner_addr = ADDR_UNSET,
5742 .radio_addr = ADDR_UNSET,
5743 .gpiomask = 1 << 21,
5744 .inputs = { {
5745 .type = SAA7134_INPUT_TV,
5746 .vmux = 1,
5747 .amux = TV,
5748 .gpio = 0x0000000,
5749 }, {
5750 .type = SAA7134_INPUT_COMPOSITE1,
5751 .vmux = 3,
5752 .amux = LINE2,
5753 .gpio = 0x0000000,
5754 }, {
5755 .type = SAA7134_INPUT_SVIDEO,
5756 .vmux = 8,
5757 .amux = LINE2,
5758 .gpio = 0x0000000,
5759 } },
5760 .radio = {
5761 .type = SAA7134_INPUT_RADIO,
5762 .amux = TV,
5763 .gpio = 0x0200000,
5764 },
5765 },
5924}; 5766};
5925 5767
5926const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); 5768const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);
@@ -7191,6 +7033,12 @@ struct pci_device_id saa7134_pci_tbl[] = {
7191 .subdevice = 0x6f3a, 7033 .subdevice = 0x6f3a,
7192 .driver_data = SAA7134_BOARD_LEADTEK_WINFAST_TV2100_FM, 7034 .driver_data = SAA7134_BOARD_LEADTEK_WINFAST_TV2100_FM,
7193 }, { 7035 }, {
7036 .vendor = PCI_VENDOR_ID_PHILIPS,
7037 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
7038 .subvendor = 0x1779, /* V One Multimedia PTE Ltd */
7039 .subdevice = 0x13cf,
7040 .driver_data = SAA7134_BOARD_SNAZIO_TVPVR_PRO,
7041 }, {
7194 /* --- boards without eeprom + subsystem ID --- */ 7042 /* --- boards without eeprom + subsystem ID --- */
7195 .vendor = PCI_VENDOR_ID_PHILIPS, 7043 .vendor = PCI_VENDOR_ID_PHILIPS,
7196 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 7044 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
@@ -7721,6 +7569,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
7721 case SAA7134_BOARD_BEHOLD_H7: 7569 case SAA7134_BOARD_BEHOLD_H7:
7722 case SAA7134_BOARD_BEHOLD_A7: 7570 case SAA7134_BOARD_BEHOLD_A7:
7723 case SAA7134_BOARD_KWORLD_PC150U: 7571 case SAA7134_BOARD_KWORLD_PC150U:
7572 case SAA7134_BOARD_SNAZIO_TVPVR_PRO:
7724 dev->has_remote = SAA7134_REMOTE_I2C; 7573 dev->has_remote = SAA7134_REMOTE_I2C;
7725 break; 7574 break;
7726 case SAA7134_BOARD_AVERMEDIA_A169_B: 7575 case SAA7134_BOARD_AVERMEDIA_A169_B:
diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c
index e227b02cc122..c0e1780ec831 100644
--- a/drivers/media/pci/saa7134/saa7134-core.c
+++ b/drivers/media/pci/saa7134/saa7134-core.c
@@ -112,7 +112,7 @@ int (*saa7134_dmasound_exit)(struct saa7134_dev *dev);
112 printk(KERN_DEBUG pr_fmt("irq: " fmt), ## arg); \ 112 printk(KERN_DEBUG pr_fmt("irq: " fmt), ## arg); \
113 } while (0) 113 } while (0)
114 114
115void saa7134_track_gpio(struct saa7134_dev *dev, char *msg) 115void saa7134_track_gpio(struct saa7134_dev *dev, const char *msg)
116{ 116{
117 unsigned long mode,status; 117 unsigned long mode,status;
118 118
@@ -806,6 +806,154 @@ static void must_configure_manually(int has_eeprom)
806 } 806 }
807} 807}
808 808
809static void saa7134_unregister_media_device(struct saa7134_dev *dev)
810{
811
812#ifdef CONFIG_MEDIA_CONTROLLER
813 if (!dev->media_dev)
814 return;
815 media_device_unregister(dev->media_dev);
816 media_device_cleanup(dev->media_dev);
817 kfree(dev->media_dev);
818 dev->media_dev = NULL;
819#endif
820}
821
822static void saa7134_media_release(struct saa7134_dev *dev)
823{
824#ifdef CONFIG_MEDIA_CONTROLLER
825 int i;
826
827 for (i = 0; i < SAA7134_INPUT_MAX + 1; i++)
828 media_device_unregister_entity(&dev->input_ent[i]);
829#endif
830}
831
832#if defined(CONFIG_MEDIA_CONTROLLER)
833static void saa7134_create_entities(struct saa7134_dev *dev)
834{
835 int ret, i;
836 struct media_entity *entity;
837 struct media_entity *decoder = NULL;
838
839 /* Check if it is using an external analog TV demod */
840 media_device_for_each_entity(entity, dev->media_dev) {
841 if (entity->function == MEDIA_ENT_F_ATV_DECODER) {
842 decoder = entity;
843 break;
844 }
845 }
846
847 /*
848 * saa713x is not using an external ATV demod.
849 * Register the internal one
850 */
851 if (!decoder) {
852 dev->demod.name = "saa713x";
853 dev->demod_pad[DEMOD_PAD_IF_INPUT].flags = MEDIA_PAD_FL_SINK;
854 dev->demod_pad[DEMOD_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
855 dev->demod_pad[DEMOD_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
856 dev->demod.function = MEDIA_ENT_F_ATV_DECODER;
857
858 ret = media_entity_pads_init(&dev->demod, DEMOD_NUM_PADS,
859 dev->demod_pad);
860 if (ret < 0)
861 pr_err("failed to initialize demod pad!\n");
862
863 ret = media_device_register_entity(dev->media_dev, &dev->demod);
864 if (ret < 0)
865 pr_err("failed to register demod entity!\n");
866
867 dev->decoder = &dev->demod;
868 } else {
869 dev->decoder = decoder;
870 }
871
872 /* Initialize Video, VBI and Radio pads */
873 dev->video_pad.flags = MEDIA_PAD_FL_SINK;
874 ret = media_entity_pads_init(&dev->video_dev->entity, 1,
875 &dev->video_pad);
876 if (ret < 0)
877 pr_err("failed to initialize video media entity!\n");
878
879 dev->vbi_pad.flags = MEDIA_PAD_FL_SINK;
880 ret = media_entity_pads_init(&dev->vbi_dev->entity, 1,
881 &dev->vbi_pad);
882 if (ret < 0)
883 pr_err("failed to initialize vbi media entity!\n");
884
885 /* Create entities for each input connector */
886 for (i = 0; i < SAA7134_INPUT_MAX; i++) {
887 struct media_entity *ent = &dev->input_ent[i];
888 struct saa7134_input *in = &card_in(dev, i);
889
890 if (in->type == SAA7134_NO_INPUT)
891 break;
892
893 /* This input uses the S-Video connector */
894 if (in->type == SAA7134_INPUT_COMPOSITE_OVER_SVIDEO)
895 continue;
896
897 ent->name = saa7134_input_name[in->type];
898 ent->flags = MEDIA_ENT_FL_CONNECTOR;
899 dev->input_pad[i].flags = MEDIA_PAD_FL_SOURCE;
900
901 switch (in->type) {
902 case SAA7134_INPUT_COMPOSITE:
903 case SAA7134_INPUT_COMPOSITE0:
904 case SAA7134_INPUT_COMPOSITE1:
905 case SAA7134_INPUT_COMPOSITE2:
906 case SAA7134_INPUT_COMPOSITE3:
907 case SAA7134_INPUT_COMPOSITE4:
908 ent->function = MEDIA_ENT_F_CONN_COMPOSITE;
909 break;
910 case SAA7134_INPUT_SVIDEO:
911 case SAA7134_INPUT_SVIDEO0:
912 case SAA7134_INPUT_SVIDEO1:
913 ent->function = MEDIA_ENT_F_CONN_SVIDEO;
914 break;
915 default:
916 /*
917 * SAA7134_INPUT_TV and SAA7134_INPUT_TV_MONO.
918 *
919 * Please notice that neither SAA7134_INPUT_MUTE or
920 * SAA7134_INPUT_RADIO are defined at
921 * saa7134_board.input.
922 */
923 ent->function = MEDIA_ENT_F_CONN_RF;
924 break;
925 }
926
927 ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]);
928 if (ret < 0)
929 pr_err("failed to initialize input pad[%d]!\n", i);
930
931 ret = media_device_register_entity(dev->media_dev, ent);
932 if (ret < 0)
933 pr_err("failed to register input entity %d!\n", i);
934 }
935
936 /* Create input for Radio RF connector */
937 if (card_has_radio(dev)) {
938 struct saa7134_input *in = &saa7134_boards[dev->board].radio;
939 struct media_entity *ent = &dev->input_ent[i];
940
941 ent->name = saa7134_input_name[in->type];
942 ent->flags = MEDIA_ENT_FL_CONNECTOR;
943 dev->input_pad[i].flags = MEDIA_PAD_FL_SOURCE;
944 ent->function = MEDIA_ENT_F_CONN_RF;
945
946 ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]);
947 if (ret < 0)
948 pr_err("failed to initialize input pad[%d]!\n", i);
949
950 ret = media_device_register_entity(dev->media_dev, ent);
951 if (ret < 0)
952 pr_err("failed to register input entity %d!\n", i);
953 }
954}
955#endif
956
809static struct video_device *vdev_init(struct saa7134_dev *dev, 957static struct video_device *vdev_init(struct saa7134_dev *dev,
810 struct video_device *template, 958 struct video_device *template,
811 char *type) 959 char *type)
@@ -826,6 +974,8 @@ static struct video_device *vdev_init(struct saa7134_dev *dev,
826 974
827static void saa7134_unregister_video(struct saa7134_dev *dev) 975static void saa7134_unregister_video(struct saa7134_dev *dev)
828{ 976{
977 saa7134_media_release(dev);
978
829 if (dev->video_dev) { 979 if (dev->video_dev) {
830 if (video_is_registered(dev->video_dev)) 980 if (video_is_registered(dev->video_dev))
831 video_unregister_device(dev->video_dev); 981 video_unregister_device(dev->video_dev);
@@ -889,6 +1039,19 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
889 if (NULL == dev) 1039 if (NULL == dev)
890 return -ENOMEM; 1040 return -ENOMEM;
891 1041
1042 dev->nr = saa7134_devcount;
1043 sprintf(dev->name, "saa%x[%d]", pci_dev->device, dev->nr);
1044
1045#ifdef CONFIG_MEDIA_CONTROLLER
1046 dev->media_dev = kzalloc(sizeof(*dev->media_dev), GFP_KERNEL);
1047 if (!dev->media_dev) {
1048 err = -ENOMEM;
1049 goto fail0;
1050 }
1051 media_device_pci_init(dev->media_dev, pci_dev, dev->name);
1052 dev->v4l2_dev.mdev = dev->media_dev;
1053#endif
1054
892 err = v4l2_device_register(&pci_dev->dev, &dev->v4l2_dev); 1055 err = v4l2_device_register(&pci_dev->dev, &dev->v4l2_dev);
893 if (err) 1056 if (err)
894 goto fail0; 1057 goto fail0;
@@ -900,9 +1063,6 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
900 goto fail1; 1063 goto fail1;
901 } 1064 }
902 1065
903 dev->nr = saa7134_devcount;
904 sprintf(dev->name,"saa%x[%d]",pci_dev->device,dev->nr);
905
906 /* pci quirks */ 1066 /* pci quirks */
907 if (pci_pci_problems) { 1067 if (pci_pci_problems) {
908 if (pci_pci_problems & PCIPCI_TRITON) 1068 if (pci_pci_problems & PCIPCI_TRITON)
@@ -1102,6 +1262,15 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
1102 dev->name, video_device_node_name(dev->radio_dev)); 1262 dev->name, video_device_node_name(dev->radio_dev));
1103 } 1263 }
1104 1264
1265#ifdef CONFIG_MEDIA_CONTROLLER
1266 saa7134_create_entities(dev);
1267
1268 err = v4l2_mc_create_media_graph(dev->media_dev);
1269 if (err) {
1270 pr_err("failed to create media graph\n");
1271 goto fail5;
1272 }
1273#endif
1105 /* everything worked */ 1274 /* everything worked */
1106 saa7134_devcount++; 1275 saa7134_devcount++;
1107 1276
@@ -1109,6 +1278,18 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
1109 saa7134_dmasound_init(dev); 1278 saa7134_dmasound_init(dev);
1110 1279
1111 request_submodules(dev); 1280 request_submodules(dev);
1281
1282 /*
1283 * Do it at the end, to reduce dynamic configuration changes during
1284 * the device init. Yet, as request_modules() can be async, the
1285 * topology will likely change after load the saa7134 subdrivers.
1286 */
1287#ifdef CONFIG_MEDIA_CONTROLLER
1288 err = media_device_register(dev->media_dev);
1289 if (err)
1290 goto fail5;
1291#endif
1292
1112 return 0; 1293 return 0;
1113 1294
1114 fail5: 1295 fail5:
@@ -1126,6 +1307,9 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
1126 fail1: 1307 fail1:
1127 v4l2_device_unregister(&dev->v4l2_dev); 1308 v4l2_device_unregister(&dev->v4l2_dev);
1128 fail0: 1309 fail0:
1310#ifdef CONFIG_MEDIA_CONTROLLER
1311 kfree(dev->media_dev);
1312#endif
1129 kfree(dev); 1313 kfree(dev);
1130 return err; 1314 return err;
1131} 1315}
@@ -1188,9 +1372,10 @@ static void saa7134_finidev(struct pci_dev *pci_dev)
1188 release_mem_region(pci_resource_start(pci_dev,0), 1372 release_mem_region(pci_resource_start(pci_dev,0),
1189 pci_resource_len(pci_dev,0)); 1373 pci_resource_len(pci_dev,0));
1190 1374
1191
1192 v4l2_device_unregister(&dev->v4l2_dev); 1375 v4l2_device_unregister(&dev->v4l2_dev);
1193 1376
1377 saa7134_unregister_media_device(dev);
1378
1194 /* free memory */ 1379 /* free memory */
1195 kfree(dev); 1380 kfree(dev);
1196} 1381}
diff --git a/drivers/media/pci/saa7134/saa7134-dvb.c b/drivers/media/pci/saa7134/saa7134-dvb.c
index 101ba8729416..db987e5b93eb 100644
--- a/drivers/media/pci/saa7134/saa7134-dvb.c
+++ b/drivers/media/pci/saa7134/saa7134-dvb.c
@@ -1883,8 +1883,15 @@ static int dvb_init(struct saa7134_dev *dev)
1883 fe0->dvb.frontend->callback = saa7134_tuner_callback; 1883 fe0->dvb.frontend->callback = saa7134_tuner_callback;
1884 1884
1885 /* register everything else */ 1885 /* register everything else */
1886#ifndef CONFIG_MEDIA_CONTROLLER_DVB
1886 ret = vb2_dvb_register_bus(&dev->frontends, THIS_MODULE, dev, 1887 ret = vb2_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
1887 &dev->pci->dev, adapter_nr, 0); 1888 &dev->pci->dev, NULL,
1889 adapter_nr, 0);
1890#else
1891 ret = vb2_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
1892 &dev->pci->dev, dev->media_dev,
1893 adapter_nr, 0);
1894#endif
1888 1895
1889 /* this sequence is necessary to make the tda1004x load its firmware 1896 /* this sequence is necessary to make the tda1004x load its firmware
1890 * and to enter analog mode of hybrid boards 1897 * and to enter analog mode of hybrid boards
diff --git a/drivers/media/pci/saa7134/saa7134-empress.c b/drivers/media/pci/saa7134/saa7134-empress.c
index 56b932c97196..ca417a454d67 100644
--- a/drivers/media/pci/saa7134/saa7134-empress.c
+++ b/drivers/media/pci/saa7134/saa7134-empress.c
@@ -189,6 +189,7 @@ static const struct v4l2_ioctl_ops ts_ioctl_ops = {
189 .vidioc_querybuf = vb2_ioctl_querybuf, 189 .vidioc_querybuf = vb2_ioctl_querybuf,
190 .vidioc_qbuf = vb2_ioctl_qbuf, 190 .vidioc_qbuf = vb2_ioctl_qbuf,
191 .vidioc_dqbuf = vb2_ioctl_dqbuf, 191 .vidioc_dqbuf = vb2_ioctl_dqbuf,
192 .vidioc_expbuf = vb2_ioctl_expbuf,
192 .vidioc_streamon = vb2_ioctl_streamon, 193 .vidioc_streamon = vb2_ioctl_streamon,
193 .vidioc_streamoff = vb2_ioctl_streamoff, 194 .vidioc_streamoff = vb2_ioctl_streamoff,
194 .vidioc_g_frequency = saa7134_g_frequency, 195 .vidioc_g_frequency = saa7134_g_frequency,
@@ -286,7 +287,7 @@ static int empress_init(struct saa7134_dev *dev)
286 * transfers that do not start at the beginning of a page. A USERPTR 287 * transfers that do not start at the beginning of a page. A USERPTR
287 * can start anywhere in a page, so USERPTR support is a no-go. 288 * can start anywhere in a page, so USERPTR support is a no-go.
288 */ 289 */
289 q->io_modes = VB2_MMAP | VB2_READ; 290 q->io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ;
290 q->drv_priv = &dev->ts_q; 291 q->drv_priv = &dev->ts_q;
291 q->ops = &saa7134_empress_qops; 292 q->ops = &saa7134_empress_qops;
292 q->gfp_flags = GFP_DMA32; 293 q->gfp_flags = GFP_DMA32;
diff --git a/drivers/media/pci/saa7134/saa7134-go7007.c b/drivers/media/pci/saa7134/saa7134-go7007.c
index 8a2abb34186b..2799538e2d7e 100644
--- a/drivers/media/pci/saa7134/saa7134-go7007.c
+++ b/drivers/media/pci/saa7134/saa7134-go7007.c
@@ -378,7 +378,7 @@ static int saa7134_go7007_send_firmware(struct go7007 *go, u8 *data, int len)
378 return 0; 378 return 0;
379} 379}
380 380
381static struct go7007_hpi_ops saa7134_go7007_hpi_ops = { 381static const struct go7007_hpi_ops saa7134_go7007_hpi_ops = {
382 .interface_reset = saa7134_go7007_interface_reset, 382 .interface_reset = saa7134_go7007_interface_reset,
383 .write_interrupt = saa7134_go7007_write_interrupt, 383 .write_interrupt = saa7134_go7007_write_interrupt,
384 .read_interrupt = saa7134_go7007_read_interrupt, 384 .read_interrupt = saa7134_go7007_read_interrupt,
diff --git a/drivers/media/pci/saa7134/saa7134-input.c b/drivers/media/pci/saa7134/saa7134-input.c
index 69d32d3fa32c..c8042c3888cd 100644
--- a/drivers/media/pci/saa7134/saa7134-input.c
+++ b/drivers/media/pci/saa7134/saa7134-input.c
@@ -975,6 +975,27 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev)
975 msg_msi.addr, dev->i2c_adap.name, 975 msg_msi.addr, dev->i2c_adap.name,
976 (1 == rc) ? "yes" : "no"); 976 (1 == rc) ? "yes" : "no");
977 break; 977 break;
978 case SAA7134_BOARD_SNAZIO_TVPVR_PRO:
979 dev->init_data.name = "SnaZio* TVPVR PRO";
980 dev->init_data.get_key = get_key_msi_tvanywhere_plus;
981 dev->init_data.ir_codes = RC_MAP_MSI_TVANYWHERE_PLUS;
982 /*
983 * MSI TV@nyware Plus requires more frequent polling
984 * otherwise it will miss some keypresses
985 */
986 dev->init_data.polling_interval = 50;
987 info.addr = 0x30;
988 /*
989 * MSI TV@nywhere Plus controller doesn't seem to
990 * respond to probes unless we read something from
991 * an existing device. Weird...
992 * REVISIT: might no longer be needed
993 */
994 rc = i2c_transfer(&dev->i2c_adap, &msg_msi, 1);
995 input_dbg("probe 0x%02x @ %s: %s\n",
996 msg_msi.addr, dev->i2c_adap.name,
997 (rc == 1) ? "yes" : "no");
998 break;
978 case SAA7134_BOARD_KWORLD_PC150U: 999 case SAA7134_BOARD_KWORLD_PC150U:
979 /* copied and modified from MSI TV@nywhere Plus */ 1000 /* copied and modified from MSI TV@nywhere Plus */
980 dev->init_data.name = "Kworld PC150-U"; 1001 dev->init_data.name = "Kworld PC150-U";
diff --git a/drivers/media/pci/saa7134/saa7134-tvaudio.c b/drivers/media/pci/saa7134/saa7134-tvaudio.c
index 21a579309575..38f94b742e28 100644
--- a/drivers/media/pci/saa7134/saa7134-tvaudio.c
+++ b/drivers/media/pci/saa7134/saa7134-tvaudio.c
@@ -192,7 +192,7 @@ static void mute_input_7134(struct saa7134_dev *dev)
192 in = dev->input; 192 in = dev->input;
193 mute = (dev->ctl_mute || 193 mute = (dev->ctl_mute ||
194 (dev->automute && (&card(dev).radio) != in)); 194 (dev->automute && (&card(dev).radio) != in));
195 if (card(dev).mute.name) { 195 if (card(dev).mute.type) {
196 /* 196 /*
197 * 7130 - we'll mute using some unconnected audio input 197 * 7130 - we'll mute using some unconnected audio input
198 * 7134 - we'll probably should switch external mux with gpio 198 * 7134 - we'll probably should switch external mux with gpio
@@ -204,13 +204,14 @@ static void mute_input_7134(struct saa7134_dev *dev)
204 if (dev->hw_mute == mute && 204 if (dev->hw_mute == mute &&
205 dev->hw_input == in && !dev->insuspend) { 205 dev->hw_input == in && !dev->insuspend) {
206 audio_dbg(1, "mute/input: nothing to do [mute=%d,input=%s]\n", 206 audio_dbg(1, "mute/input: nothing to do [mute=%d,input=%s]\n",
207 mute, in->name); 207 mute, saa7134_input_name[in->type]);
208 return; 208 return;
209 } 209 }
210 210
211 audio_dbg(1, "ctl_mute=%d automute=%d input=%s => mute=%d input=%s\n", 211 audio_dbg(1, "ctl_mute=%d automute=%d input=%s => mute=%d input=%s\n",
212 dev->ctl_mute, dev->automute, 212 dev->ctl_mute, dev->automute,
213 dev->input->name, mute, in->name); 213 saa7134_input_name[dev->input->type], mute,
214 saa7134_input_name[in->type]);
214 dev->hw_mute = mute; 215 dev->hw_mute = mute;
215 dev->hw_input = in; 216 dev->hw_input = in;
216 217
@@ -245,7 +246,7 @@ static void mute_input_7134(struct saa7134_dev *dev)
245 mask = card(dev).gpiomask; 246 mask = card(dev).gpiomask;
246 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask); 247 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask);
247 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, in->gpio); 248 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, in->gpio);
248 saa7134_track_gpio(dev,in->name); 249 saa7134_track_gpio(dev, saa7134_input_name[in->type]);
249} 250}
250 251
251static void tvaudio_setmode(struct saa7134_dev *dev, 252static void tvaudio_setmode(struct saa7134_dev *dev,
@@ -756,14 +757,14 @@ static int mute_input_7133(struct saa7134_dev *dev)
756 if (0 != card(dev).gpiomask) { 757 if (0 != card(dev).gpiomask) {
757 mask = card(dev).gpiomask; 758 mask = card(dev).gpiomask;
758 759
759 if (card(dev).mute.name && dev->ctl_mute) 760 if (card(dev).mute.type && dev->ctl_mute)
760 in = &card(dev).mute; 761 in = &card(dev).mute;
761 else 762 else
762 in = dev->input; 763 in = dev->input;
763 764
764 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask); 765 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask);
765 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, in->gpio); 766 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, in->gpio);
766 saa7134_track_gpio(dev,in->name); 767 saa7134_track_gpio(dev, saa7134_input_name[in->type]);
767 } 768 }
768 769
769 return 0; 770 return 0;
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c
index a63c1366a64e..ffa39543eb65 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -409,7 +409,8 @@ static void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm)
409 409
410static void video_mux(struct saa7134_dev *dev, int input) 410static void video_mux(struct saa7134_dev *dev, int input)
411{ 411{
412 video_dbg("video input = %d [%s]\n", input, card_in(dev, input).name); 412 video_dbg("video input = %d [%s]\n",
413 input, saa7134_input_name[card_in(dev, input).type]);
413 dev->ctl_input = input; 414 dev->ctl_input = input;
414 set_tvnorm(dev, dev->tvnorm); 415 set_tvnorm(dev, dev->tvnorm);
415 saa7134_tvaudio_setinput(dev, &card_in(dev, input)); 416 saa7134_tvaudio_setinput(dev, &card_in(dev, input));
@@ -478,8 +479,7 @@ void saa7134_set_tvnorm_hw(struct saa7134_dev *dev)
478{ 479{
479 saa7134_set_decoder(dev); 480 saa7134_set_decoder(dev);
480 481
481 if (card_in(dev, dev->ctl_input).tv) 482 saa_call_all(dev, video, s_std, dev->tvnorm->id);
482 saa_call_all(dev, video, s_std, dev->tvnorm->id);
483 /* Set the correct norm for the saa6752hs. This function 483 /* Set the correct norm for the saa6752hs. This function
484 does nothing if there is no saa6752hs. */ 484 does nothing if there is no saa6752hs. */
485 saa_call_empress(dev, video, s_std, dev->tvnorm->id); 485 saa_call_empress(dev, video, s_std, dev->tvnorm->id);
@@ -785,6 +785,63 @@ static int stop_preview(struct saa7134_dev *dev)
785 return 0; 785 return 0;
786} 786}
787 787
788/*
789 * Media Controller helper functions
790 */
791
792static int saa7134_enable_analog_tuner(struct saa7134_dev *dev)
793{
794#ifdef CONFIG_MEDIA_CONTROLLER
795 struct media_device *mdev = dev->media_dev;
796 struct media_entity *source;
797 struct media_link *link, *found_link = NULL;
798 int ret, active_links = 0;
799
800 if (!mdev || !dev->decoder)
801 return 0;
802
803 /*
804 * This will find the tuner that is connected into the decoder.
805 * Technically, this is not 100% correct, as the device may be
806 * using an analog input instead of the tuner. However, as we can't
807 * do DVB streaming while the DMA engine is being used for V4L2,
808 * this should be enough for the actual needs.
809 */
810 list_for_each_entry(link, &dev->decoder->links, list) {
811 if (link->sink->entity == dev->decoder) {
812 found_link = link;
813 if (link->flags & MEDIA_LNK_FL_ENABLED)
814 active_links++;
815 break;
816 }
817 }
818
819 if (active_links == 1 || !found_link)
820 return 0;
821
822 source = found_link->source->entity;
823 list_for_each_entry(link, &source->links, list) {
824 struct media_entity *sink;
825 int flags = 0;
826
827 sink = link->sink->entity;
828
829 if (sink == dev->decoder)
830 flags = MEDIA_LNK_FL_ENABLED;
831
832 ret = media_entity_setup_link(link, flags);
833 if (ret) {
834 pr_err("Couldn't change link %s->%s to %s. Error %d\n",
835 source->name, sink->name,
836 flags ? "enabled" : "disabled",
837 ret);
838 return ret;
839 }
840 }
841#endif
842 return 0;
843}
844
788/* ------------------------------------------------------------------ */ 845/* ------------------------------------------------------------------ */
789 846
790static int buffer_activate(struct saa7134_dev *dev, 847static int buffer_activate(struct saa7134_dev *dev,
@@ -924,6 +981,9 @@ static int queue_setup(struct vb2_queue *q,
924 *nplanes = 1; 981 *nplanes = 1;
925 sizes[0] = size; 982 sizes[0] = size;
926 alloc_ctxs[0] = dev->alloc_ctx; 983 alloc_ctxs[0] = dev->alloc_ctx;
984
985 saa7134_enable_analog_tuner(dev);
986
927 return 0; 987 return 0;
928} 988}
929 989
@@ -1219,10 +1279,13 @@ static int saa7134_g_fmt_vid_cap(struct file *file, void *priv,
1219 f->fmt.pix.height = dev->height; 1279 f->fmt.pix.height = dev->height;
1220 f->fmt.pix.field = dev->field; 1280 f->fmt.pix.field = dev->field;
1221 f->fmt.pix.pixelformat = dev->fmt->fourcc; 1281 f->fmt.pix.pixelformat = dev->fmt->fourcc;
1222 f->fmt.pix.bytesperline = 1282 if (dev->fmt->planar)
1223 (f->fmt.pix.width * dev->fmt->depth) >> 3; 1283 f->fmt.pix.bytesperline = f->fmt.pix.width;
1284 else
1285 f->fmt.pix.bytesperline =
1286 (f->fmt.pix.width * dev->fmt->depth) / 8;
1224 f->fmt.pix.sizeimage = 1287 f->fmt.pix.sizeimage =
1225 f->fmt.pix.height * f->fmt.pix.bytesperline; 1288 (f->fmt.pix.height * f->fmt.pix.width * dev->fmt->depth) / 8;
1226 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 1289 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
1227 return 0; 1290 return 0;
1228} 1291}
@@ -1298,10 +1361,13 @@ static int saa7134_try_fmt_vid_cap(struct file *file, void *priv,
1298 if (f->fmt.pix.height > maxh) 1361 if (f->fmt.pix.height > maxh)
1299 f->fmt.pix.height = maxh; 1362 f->fmt.pix.height = maxh;
1300 f->fmt.pix.width &= ~0x03; 1363 f->fmt.pix.width &= ~0x03;
1301 f->fmt.pix.bytesperline = 1364 if (fmt->planar)
1302 (f->fmt.pix.width * fmt->depth) >> 3; 1365 f->fmt.pix.bytesperline = f->fmt.pix.width;
1366 else
1367 f->fmt.pix.bytesperline =
1368 (f->fmt.pix.width * fmt->depth) / 8;
1303 f->fmt.pix.sizeimage = 1369 f->fmt.pix.sizeimage =
1304 f->fmt.pix.height * f->fmt.pix.bytesperline; 1370 (f->fmt.pix.height * f->fmt.pix.width * fmt->depth) / 8;
1305 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 1371 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
1306 1372
1307 return 0; 1373 return 0;
@@ -1381,13 +1447,19 @@ int saa7134_enum_input(struct file *file, void *priv, struct v4l2_input *i)
1381 n = i->index; 1447 n = i->index;
1382 if (n >= SAA7134_INPUT_MAX) 1448 if (n >= SAA7134_INPUT_MAX)
1383 return -EINVAL; 1449 return -EINVAL;
1384 if (NULL == card_in(dev, i->index).name) 1450 if (card_in(dev, i->index).type == SAA7134_NO_INPUT)
1385 return -EINVAL; 1451 return -EINVAL;
1386 i->index = n; 1452 i->index = n;
1387 i->type = V4L2_INPUT_TYPE_CAMERA; 1453 strcpy(i->name, saa7134_input_name[card_in(dev, n).type]);
1388 strcpy(i->name, card_in(dev, n).name); 1454 switch (card_in(dev, n).type) {
1389 if (card_in(dev, n).tv) 1455 case SAA7134_INPUT_TV:
1456 case SAA7134_INPUT_TV_MONO:
1390 i->type = V4L2_INPUT_TYPE_TUNER; 1457 i->type = V4L2_INPUT_TYPE_TUNER;
1458 break;
1459 default:
1460 i->type = V4L2_INPUT_TYPE_CAMERA;
1461 break;
1462 }
1391 if (n == dev->ctl_input) { 1463 if (n == dev->ctl_input) {
1392 int v1 = saa_readb(SAA7134_STATUS_VIDEO1); 1464 int v1 = saa_readb(SAA7134_STATUS_VIDEO1);
1393 int v2 = saa_readb(SAA7134_STATUS_VIDEO2); 1465 int v2 = saa_readb(SAA7134_STATUS_VIDEO2);
@@ -1419,7 +1491,7 @@ int saa7134_s_input(struct file *file, void *priv, unsigned int i)
1419 1491
1420 if (i >= SAA7134_INPUT_MAX) 1492 if (i >= SAA7134_INPUT_MAX)
1421 return -EINVAL; 1493 return -EINVAL;
1422 if (NULL == card_in(dev, i).name) 1494 if (card_in(dev, i).type == SAA7134_NO_INPUT)
1423 return -EINVAL; 1495 return -EINVAL;
1424 video_mux(dev, i); 1496 video_mux(dev, i);
1425 return 0; 1497 return 0;
@@ -1656,12 +1728,13 @@ int saa7134_g_tuner(struct file *file, void *priv,
1656 return -EINVAL; 1728 return -EINVAL;
1657 memset(t, 0, sizeof(*t)); 1729 memset(t, 0, sizeof(*t));
1658 for (n = 0; n < SAA7134_INPUT_MAX; n++) { 1730 for (n = 0; n < SAA7134_INPUT_MAX; n++) {
1659 if (card_in(dev, n).tv) 1731 if (card_in(dev, n).type == SAA7134_INPUT_TV ||
1732 card_in(dev, n).type == SAA7134_INPUT_TV_MONO)
1660 break; 1733 break;
1661 } 1734 }
1662 if (n == SAA7134_INPUT_MAX) 1735 if (n == SAA7134_INPUT_MAX)
1663 return -EINVAL; 1736 return -EINVAL;
1664 if (NULL != card_in(dev, n).name) { 1737 if (card_in(dev, n).type != SAA7134_NO_INPUT) {
1665 strcpy(t->name, "Television"); 1738 strcpy(t->name, "Television");
1666 t->type = V4L2_TUNER_ANALOG_TV; 1739 t->type = V4L2_TUNER_ANALOG_TV;
1667 saa_call_all(dev, tuner, g_tuner, t); 1740 saa_call_all(dev, tuner, g_tuner, t);
@@ -1906,6 +1979,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
1906 .vidioc_querybuf = vb2_ioctl_querybuf, 1979 .vidioc_querybuf = vb2_ioctl_querybuf,
1907 .vidioc_qbuf = vb2_ioctl_qbuf, 1980 .vidioc_qbuf = vb2_ioctl_qbuf,
1908 .vidioc_dqbuf = vb2_ioctl_dqbuf, 1981 .vidioc_dqbuf = vb2_ioctl_dqbuf,
1982 .vidioc_expbuf = vb2_ioctl_expbuf,
1909 .vidioc_s_std = saa7134_s_std, 1983 .vidioc_s_std = saa7134_s_std,
1910 .vidioc_g_std = saa7134_g_std, 1984 .vidioc_g_std = saa7134_g_std,
1911 .vidioc_querystd = saa7134_querystd, 1985 .vidioc_querystd = saa7134_querystd,
@@ -2089,7 +2163,7 @@ int saa7134_video_init1(struct saa7134_dev *dev)
2089 * USERPTR support is a no-go unless the application knows about these 2163 * USERPTR support is a no-go unless the application knows about these
2090 * limitations and has special support for this. 2164 * limitations and has special support for this.
2091 */ 2165 */
2092 q->io_modes = VB2_MMAP | VB2_READ; 2166 q->io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ;
2093 if (saa7134_userptr) 2167 if (saa7134_userptr)
2094 q->io_modes |= VB2_USERPTR; 2168 q->io_modes |= VB2_USERPTR;
2095 q->drv_priv = &dev->video_q; 2169 q->drv_priv = &dev->video_q;
diff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h
index 5938bc781999..69a9bbf22d4d 100644
--- a/drivers/media/pci/saa7134/saa7134.h
+++ b/drivers/media/pci/saa7134/saa7134.h
@@ -343,6 +343,7 @@ struct saa7134_card_ir {
343#define SAA7134_BOARD_WIS_VOYAGER 193 343#define SAA7134_BOARD_WIS_VOYAGER 193
344#define SAA7134_BOARD_AVERMEDIA_505 194 344#define SAA7134_BOARD_AVERMEDIA_505 194
345#define SAA7134_BOARD_LEADTEK_WINFAST_TV2100_FM 195 345#define SAA7134_BOARD_LEADTEK_WINFAST_TV2100_FM 195
346#define SAA7134_BOARD_SNAZIO_TVPVR_PRO 196
346 347
347#define SAA7134_MAXBOARDS 32 348#define SAA7134_MAXBOARDS 32
348#define SAA7134_INPUT_MAX 8 349#define SAA7134_INPUT_MAX 8
@@ -361,12 +362,29 @@ struct saa7134_card_ir {
361#define SET_CLOCK_INVERTED (1 << 2) 362#define SET_CLOCK_INVERTED (1 << 2)
362#define SET_VSYNC_OFF (1 << 3) 363#define SET_VSYNC_OFF (1 << 3)
363 364
365enum saa7134_input_types {
366 SAA7134_NO_INPUT = 0,
367 SAA7134_INPUT_MUTE,
368 SAA7134_INPUT_RADIO,
369 SAA7134_INPUT_TV,
370 SAA7134_INPUT_TV_MONO,
371 SAA7134_INPUT_COMPOSITE,
372 SAA7134_INPUT_COMPOSITE0,
373 SAA7134_INPUT_COMPOSITE1,
374 SAA7134_INPUT_COMPOSITE2,
375 SAA7134_INPUT_COMPOSITE3,
376 SAA7134_INPUT_COMPOSITE4,
377 SAA7134_INPUT_SVIDEO,
378 SAA7134_INPUT_SVIDEO0,
379 SAA7134_INPUT_SVIDEO1,
380 SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
381};
382
364struct saa7134_input { 383struct saa7134_input {
365 char *name; 384 enum saa7134_input_types type;
366 unsigned int vmux; 385 unsigned int vmux;
367 enum saa7134_audio_in amux; 386 enum saa7134_audio_in amux;
368 unsigned int gpio; 387 unsigned int gpio;
369 unsigned int tv:1;
370}; 388};
371 389
372enum saa7134_mpeg_type { 390enum saa7134_mpeg_type {
@@ -410,7 +428,7 @@ struct saa7134_board {
410 unsigned int ts_force_val:1; 428 unsigned int ts_force_val:1;
411}; 429};
412 430
413#define card_has_radio(dev) (NULL != saa7134_boards[dev->board].radio.name) 431#define card_has_radio(dev) (SAA7134_NO_INPUT != saa7134_boards[dev->board].radio.type)
414#define card_is_empress(dev) (SAA7134_MPEG_EMPRESS == saa7134_boards[dev->board].mpeg) 432#define card_is_empress(dev) (SAA7134_MPEG_EMPRESS == saa7134_boards[dev->board].mpeg)
415#define card_is_dvb(dev) (SAA7134_MPEG_DVB == saa7134_boards[dev->board].mpeg) 433#define card_is_dvb(dev) (SAA7134_MPEG_DVB == saa7134_boards[dev->board].mpeg)
416#define card_is_go7007(dev) (SAA7134_MPEG_GO7007 == saa7134_boards[dev->board].mpeg) 434#define card_is_go7007(dev) (SAA7134_MPEG_GO7007 == saa7134_boards[dev->board].mpeg)
@@ -654,6 +672,19 @@ struct saa7134_dev {
654 /* I2C keyboard data */ 672 /* I2C keyboard data */
655 struct IR_i2c_init_data init_data; 673 struct IR_i2c_init_data init_data;
656 674
675#ifdef CONFIG_MEDIA_CONTROLLER
676 struct media_device *media_dev;
677
678 struct media_entity input_ent[SAA7134_INPUT_MAX + 1];
679 struct media_pad input_pad[SAA7134_INPUT_MAX + 1];
680
681 struct media_entity demod;
682 struct media_pad demod_pad[DEMOD_NUM_PADS];
683
684 struct media_pad video_pad, vbi_pad;
685 struct media_entity *decoder;
686#endif
687
657#if IS_ENABLED(CONFIG_VIDEO_SAA7134_DVB) 688#if IS_ENABLED(CONFIG_VIDEO_SAA7134_DVB)
658 /* SAA7134_MPEG_DVB only */ 689 /* SAA7134_MPEG_DVB only */
659 struct vb2_dvb_frontends frontends; 690 struct vb2_dvb_frontends frontends;
@@ -727,7 +758,7 @@ extern struct mutex saa7134_devlist_lock;
727extern int saa7134_no_overlay; 758extern int saa7134_no_overlay;
728extern bool saa7134_userptr; 759extern bool saa7134_userptr;
729 760
730void saa7134_track_gpio(struct saa7134_dev *dev, char *msg); 761void saa7134_track_gpio(struct saa7134_dev *dev, const char *msg);
731void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value); 762void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value);
732 763
733#define SAA7134_PGTABLE_SIZE 4096 764#define SAA7134_PGTABLE_SIZE 4096
@@ -760,6 +791,7 @@ extern int (*saa7134_dmasound_exit)(struct saa7134_dev *dev);
760/* saa7134-cards.c */ 791/* saa7134-cards.c */
761 792
762extern struct saa7134_board saa7134_boards[]; 793extern struct saa7134_board saa7134_boards[];
794extern const char * const saa7134_input_name[];
763extern const unsigned int saa7134_bcount; 795extern const unsigned int saa7134_bcount;
764extern struct pci_device_id saa7134_pci_tbl[]; 796extern struct pci_device_id saa7134_pci_tbl[];
765 797
diff --git a/drivers/media/pci/ttpci/av7110.c b/drivers/media/pci/ttpci/av7110.c
index a69dc6a0752b..382caf200ba1 100644
--- a/drivers/media/pci/ttpci/av7110.c
+++ b/drivers/media/pci/ttpci/av7110.c
@@ -1739,7 +1739,7 @@ static int alps_tdlb7_request_firmware(struct dvb_frontend* fe, const struct fir
1739#endif 1739#endif
1740} 1740}
1741 1741
1742static struct sp8870_config alps_tdlb7_config = { 1742static const struct sp8870_config alps_tdlb7_config = {
1743 1743
1744 .demod_address = 0x71, 1744 .demod_address = 0x71,
1745 .request_firmware = alps_tdlb7_request_firmware, 1745 .request_firmware = alps_tdlb7_request_firmware,
@@ -2198,13 +2198,18 @@ static int frontend_init(struct av7110 *av7110)
2198 break; 2198 break;
2199 2199
2200 case 0x0001: // Hauppauge/TT Nexus-T premium rev1.X 2200 case 0x0001: // Hauppauge/TT Nexus-T premium rev1.X
2201 {
2202 struct dvb_frontend *fe;
2203
2201 // try ALPS TDLB7 first, then Grundig 29504-401 2204 // try ALPS TDLB7 first, then Grundig 29504-401
2202 av7110->fe = dvb_attach(sp8870_attach, &alps_tdlb7_config, &av7110->i2c_adap); 2205 fe = dvb_attach(sp8870_attach, &alps_tdlb7_config, &av7110->i2c_adap);
2203 if (av7110->fe) { 2206 if (fe) {
2204 av7110->fe->ops.tuner_ops.set_params = alps_tdlb7_tuner_set_params; 2207 fe->ops.tuner_ops.set_params = alps_tdlb7_tuner_set_params;
2208 av7110->fe = fe;
2205 break; 2209 break;
2206 } 2210 }
2207 /* fall-thru */ 2211 }
2212 /* fall-thru */
2208 2213
2209 case 0x0008: // Hauppauge/TT DVB-T 2214 case 0x0008: // Hauppauge/TT DVB-T
2210 // Grundig 29504-401 2215 // Grundig 29504-401
diff --git a/drivers/media/pci/ttpci/budget.c b/drivers/media/pci/ttpci/budget.c
index de54310a2660..fb8ede5a1531 100644
--- a/drivers/media/pci/ttpci/budget.c
+++ b/drivers/media/pci/ttpci/budget.c
@@ -615,36 +615,50 @@ static void frontend_init(struct budget *budget)
615 break; 615 break;
616 616
617 case 0x1016: // Hauppauge/TT Nova-S SE (samsung s5h1420/????(tda8260)) 617 case 0x1016: // Hauppauge/TT Nova-S SE (samsung s5h1420/????(tda8260))
618 budget->dvb_frontend = dvb_attach(s5h1420_attach, &s5h1420_config, &budget->i2c_adap); 618 {
619 if (budget->dvb_frontend) { 619 struct dvb_frontend *fe;
620 budget->dvb_frontend->ops.tuner_ops.set_params = s5h1420_tuner_set_params; 620
621 if (dvb_attach(lnbp21_attach, budget->dvb_frontend, &budget->i2c_adap, 0, 0) == NULL) { 621 fe = dvb_attach(s5h1420_attach, &s5h1420_config, &budget->i2c_adap);
622 if (fe) {
623 fe->ops.tuner_ops.set_params = s5h1420_tuner_set_params;
624 budget->dvb_frontend = fe;
625 if (dvb_attach(lnbp21_attach, fe, &budget->i2c_adap,
626 0, 0) == NULL) {
622 printk("%s: No LNBP21 found!\n", __func__); 627 printk("%s: No LNBP21 found!\n", __func__);
623 goto error_out; 628 goto error_out;
624 } 629 }
625 break; 630 break;
626 } 631 }
627 632 }
633 /* fall through */
628 case 0x1018: // TT Budget-S-1401 (philips tda10086/philips tda8262) 634 case 0x1018: // TT Budget-S-1401 (philips tda10086/philips tda8262)
635 {
636 struct dvb_frontend *fe;
637
629 // gpio2 is connected to CLB - reset it + leave it high 638 // gpio2 is connected to CLB - reset it + leave it high
630 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTLO); 639 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTLO);
631 msleep(1); 640 msleep(1);
632 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTHI); 641 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTHI);
633 msleep(1); 642 msleep(1);
634 643
635 budget->dvb_frontend = dvb_attach(tda10086_attach, &tda10086_config, &budget->i2c_adap); 644 fe = dvb_attach(tda10086_attach, &tda10086_config, &budget->i2c_adap);
636 if (budget->dvb_frontend) { 645 if (fe) {
637 if (dvb_attach(tda826x_attach, budget->dvb_frontend, 0x60, &budget->i2c_adap, 0) == NULL) 646 budget->dvb_frontend = fe;
647 if (dvb_attach(tda826x_attach, fe, 0x60,
648 &budget->i2c_adap, 0) == NULL)
638 printk("%s: No tda826x found!\n", __func__); 649 printk("%s: No tda826x found!\n", __func__);
639 if (dvb_attach(lnbp21_attach, budget->dvb_frontend, &budget->i2c_adap, 0, 0) == NULL) { 650 if (dvb_attach(lnbp21_attach, fe,
651 &budget->i2c_adap, 0, 0) == NULL) {
640 printk("%s: No LNBP21 found!\n", __func__); 652 printk("%s: No LNBP21 found!\n", __func__);
641 goto error_out; 653 goto error_out;
642 } 654 }
643 break; 655 break;
644 } 656 }
657 }
658 /* fall through */
645 659
646 case 0x101c: { /* TT S2-1600 */ 660 case 0x101c: { /* TT S2-1600 */
647 struct stv6110x_devctl *ctl; 661 const struct stv6110x_devctl *ctl;
648 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTLO); 662 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTLO);
649 msleep(50); 663 msleep(50);
650 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTHI); 664 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTHI);
@@ -697,7 +711,7 @@ static void frontend_init(struct budget *budget)
697 break; 711 break;
698 712
699 case 0x1020: { /* Omicom S2 */ 713 case 0x1020: { /* Omicom S2 */
700 struct stv6110x_devctl *ctl; 714 const struct stv6110x_devctl *ctl;
701 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTLO); 715 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTLO);
702 msleep(50); 716 msleep(50);
703 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTHI); 717 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTHI);
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 8b89ebe16d94..201f5c296a95 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -54,15 +54,6 @@ config VIDEO_VIU
54 Say Y here if you want to enable VIU device on MPC5121e Rev2+. 54 Say Y here if you want to enable VIU device on MPC5121e Rev2+.
55 In doubt, say N. 55 In doubt, say N.
56 56
57config VIDEO_TIMBERDALE
58 tristate "Support for timberdale Video In/LogiWIN"
59 depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API && HAS_DMA
60 depends on (MFD_TIMBERDALE && TIMB_DMA) || COMPILE_TEST
61 select VIDEO_ADV7180
62 select VIDEOBUF_DMA_CONTIG
63 ---help---
64 Add support for the Video In peripherial of the timberdale FPGA.
65
66config VIDEO_M32R_AR 57config VIDEO_M32R_AR
67 tristate "AR devices" 58 tristate "AR devices"
68 depends on VIDEO_V4L2 59 depends on VIDEO_V4L2
@@ -120,6 +111,19 @@ source "drivers/media/platform/s5p-tv/Kconfig"
120source "drivers/media/platform/am437x/Kconfig" 111source "drivers/media/platform/am437x/Kconfig"
121source "drivers/media/platform/xilinx/Kconfig" 112source "drivers/media/platform/xilinx/Kconfig"
122 113
114config VIDEO_TI_CAL
115 tristate "TI CAL (Camera Adaptation Layer) driver"
116 depends on VIDEO_DEV && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
117 depends on SOC_DRA7XX || COMPILE_TEST
118 depends on HAS_DMA
119 select VIDEOBUF2_DMA_CONTIG
120 default n
121 ---help---
122 Support for the TI CAL (Camera Adaptation Layer) block
123 found on DRA72X SoC.
124 In TI Technical Reference Manual this module is referred as
125 Camera Interface Subsystem (CAMSS).
126
123endif # V4L_PLATFORM_DRIVERS 127endif # V4L_PLATFORM_DRIVERS
124 128
125menuconfig V4L_MEM2MEM_DRIVERS 129menuconfig V4L_MEM2MEM_DRIVERS
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index efa0295af87b..bbb7bd1eb268 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -2,7 +2,6 @@
2# Makefile for the video capture/playback device drivers. 2# Makefile for the video capture/playback device drivers.
3# 3#
4 4
5obj-$(CONFIG_VIDEO_TIMBERDALE) += timblogiw.o
6obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o 5obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o
7 6
8obj-$(CONFIG_VIDEO_VIA_CAMERA) += via-camera.o 7obj-$(CONFIG_VIDEO_VIA_CAMERA) += via-camera.o
@@ -18,6 +17,8 @@ obj-$(CONFIG_VIDEO_VIM2M) += vim2m.o
18 17
19obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe/ 18obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe/
20 19
20obj-$(CONFIG_VIDEO_TI_CAL) += ti-vpe/
21
21obj-$(CONFIG_VIDEO_MX2_EMMAPRP) += mx2_emmaprp.o 22obj-$(CONFIG_VIDEO_MX2_EMMAPRP) += mx2_emmaprp.o
22obj-$(CONFIG_VIDEO_CODA) += coda/ 23obj-$(CONFIG_VIDEO_CODA) += coda/
23 24
diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c
index 38aacc7fc692..b6625047250d 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -1342,7 +1342,7 @@ static void coda_finish_encode(struct coda_ctx *ctx)
1342 1342
1343 /* Calculate bytesused field */ 1343 /* Calculate bytesused field */
1344 if (dst_buf->sequence == 0) { 1344 if (dst_buf->sequence == 0) {
1345 vb2_set_plane_payload(&dst_buf->vb2_buf, 0, 1345 vb2_set_plane_payload(&dst_buf->vb2_buf, 0, wr_ptr - start_ptr +
1346 ctx->vpu_header_size[0] + 1346 ctx->vpu_header_size[0] +
1347 ctx->vpu_header_size[1] + 1347 ctx->vpu_header_size[1] +
1348 ctx->vpu_header_size[2]); 1348 ctx->vpu_header_size[2]);
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index 2d782ce94a67..133ab9f70f85 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -1950,16 +1950,76 @@ static int coda_register_device(struct coda_dev *dev, int i)
1950 return video_register_device(vfd, VFL_TYPE_GRABBER, 0); 1950 return video_register_device(vfd, VFL_TYPE_GRABBER, 0);
1951} 1951}
1952 1952
1953static void coda_copy_firmware(struct coda_dev *dev, const u8 * const buf,
1954 size_t size)
1955{
1956 u32 *src = (u32 *)buf;
1957
1958 /* Check if the firmware has a 16-byte Freescale header, skip it */
1959 if (buf[0] == 'M' && buf[1] == 'X')
1960 src += 4;
1961 /*
1962 * Check whether the firmware is in native order or pre-reordered for
1963 * memory access. The first instruction opcode always is 0xe40e.
1964 */
1965 if (__le16_to_cpup((__le16 *)src) == 0xe40e) {
1966 u32 *dst = dev->codebuf.vaddr;
1967 int i;
1968
1969 /* Firmware in native order, reorder while copying */
1970 if (dev->devtype->product == CODA_DX6) {
1971 for (i = 0; i < (size - 16) / 4; i++)
1972 dst[i] = (src[i] << 16) | (src[i] >> 16);
1973 } else {
1974 for (i = 0; i < (size - 16) / 4; i += 2) {
1975 dst[i] = (src[i + 1] << 16) | (src[i + 1] >> 16);
1976 dst[i + 1] = (src[i] << 16) | (src[i] >> 16);
1977 }
1978 }
1979 } else {
1980 /* Copy the already reordered firmware image */
1981 memcpy(dev->codebuf.vaddr, src, size);
1982 }
1983}
1984
1985static void coda_fw_callback(const struct firmware *fw, void *context);
1986
1987static int coda_firmware_request(struct coda_dev *dev)
1988{
1989 char *fw = dev->devtype->firmware[dev->firmware];
1990
1991 dev_dbg(&dev->plat_dev->dev, "requesting firmware '%s' for %s\n", fw,
1992 coda_product_name(dev->devtype->product));
1993
1994 return request_firmware_nowait(THIS_MODULE, true, fw,
1995 &dev->plat_dev->dev, GFP_KERNEL, dev,
1996 coda_fw_callback);
1997}
1998
1953static void coda_fw_callback(const struct firmware *fw, void *context) 1999static void coda_fw_callback(const struct firmware *fw, void *context)
1954{ 2000{
1955 struct coda_dev *dev = context; 2001 struct coda_dev *dev = context;
1956 struct platform_device *pdev = dev->plat_dev; 2002 struct platform_device *pdev = dev->plat_dev;
1957 int i, ret; 2003 int i, ret;
1958 2004
1959 if (!fw) { 2005 if (!fw && dev->firmware == 1) {
1960 v4l2_err(&dev->v4l2_dev, "firmware request failed\n"); 2006 v4l2_err(&dev->v4l2_dev, "firmware request failed\n");
1961 goto put_pm; 2007 goto put_pm;
1962 } 2008 }
2009 if (!fw) {
2010 dev->firmware = 1;
2011 coda_firmware_request(dev);
2012 return;
2013 }
2014 if (dev->firmware == 1) {
2015 /*
2016 * Since we can't suppress warnings for failed asynchronous
2017 * firmware requests, report that the fallback firmware was
2018 * found.
2019 */
2020 dev_info(&pdev->dev, "Using fallback firmware %s\n",
2021 dev->devtype->firmware[dev->firmware]);
2022 }
1963 2023
1964 /* allocate auxiliary per-device code buffer for the BIT processor */ 2024 /* allocate auxiliary per-device code buffer for the BIT processor */
1965 ret = coda_alloc_aux_buf(dev, &dev->codebuf, fw->size, "codebuf", 2025 ret = coda_alloc_aux_buf(dev, &dev->codebuf, fw->size, "codebuf",
@@ -1967,8 +2027,7 @@ static void coda_fw_callback(const struct firmware *fw, void *context)
1967 if (ret < 0) 2027 if (ret < 0)
1968 goto put_pm; 2028 goto put_pm;
1969 2029
1970 /* Copy the whole firmware image to the code buffer */ 2030 coda_copy_firmware(dev, fw->data, fw->size);
1971 memcpy(dev->codebuf.vaddr, fw->data, fw->size);
1972 release_firmware(fw); 2031 release_firmware(fw);
1973 2032
1974 ret = coda_hw_init(dev); 2033 ret = coda_hw_init(dev);
@@ -2019,17 +2078,6 @@ put_pm:
2019 pm_runtime_put_sync(&pdev->dev); 2078 pm_runtime_put_sync(&pdev->dev);
2020} 2079}
2021 2080
2022static int coda_firmware_request(struct coda_dev *dev)
2023{
2024 char *fw = dev->devtype->firmware;
2025
2026 dev_dbg(&dev->plat_dev->dev, "requesting firmware '%s' for %s\n", fw,
2027 coda_product_name(dev->devtype->product));
2028
2029 return request_firmware_nowait(THIS_MODULE, true,
2030 fw, &dev->plat_dev->dev, GFP_KERNEL, dev, coda_fw_callback);
2031}
2032
2033enum coda_platform { 2081enum coda_platform {
2034 CODA_IMX27, 2082 CODA_IMX27,
2035 CODA_IMX53, 2083 CODA_IMX53,
@@ -2039,7 +2087,10 @@ enum coda_platform {
2039 2087
2040static const struct coda_devtype coda_devdata[] = { 2088static const struct coda_devtype coda_devdata[] = {
2041 [CODA_IMX27] = { 2089 [CODA_IMX27] = {
2042 .firmware = "v4l-codadx6-imx27.bin", 2090 .firmware = {
2091 "vpu_fw_imx27_TO2.bin",
2092 "v4l-codadx6-imx27.bin"
2093 },
2043 .product = CODA_DX6, 2094 .product = CODA_DX6,
2044 .codecs = codadx6_codecs, 2095 .codecs = codadx6_codecs,
2045 .num_codecs = ARRAY_SIZE(codadx6_codecs), 2096 .num_codecs = ARRAY_SIZE(codadx6_codecs),
@@ -2049,7 +2100,10 @@ static const struct coda_devtype coda_devdata[] = {
2049 .iram_size = 0xb000, 2100 .iram_size = 0xb000,
2050 }, 2101 },
2051 [CODA_IMX53] = { 2102 [CODA_IMX53] = {
2052 .firmware = "v4l-coda7541-imx53.bin", 2103 .firmware = {
2104 "vpu_fw_imx53.bin",
2105 "v4l-coda7541-imx53.bin"
2106 },
2053 .product = CODA_7541, 2107 .product = CODA_7541,
2054 .codecs = coda7_codecs, 2108 .codecs = coda7_codecs,
2055 .num_codecs = ARRAY_SIZE(coda7_codecs), 2109 .num_codecs = ARRAY_SIZE(coda7_codecs),
@@ -2060,7 +2114,10 @@ static const struct coda_devtype coda_devdata[] = {
2060 .iram_size = 0x14000, 2114 .iram_size = 0x14000,
2061 }, 2115 },
2062 [CODA_IMX6Q] = { 2116 [CODA_IMX6Q] = {
2063 .firmware = "v4l-coda960-imx6q.bin", 2117 .firmware = {
2118 "vpu_fw_imx6q.bin",
2119 "v4l-coda960-imx6q.bin"
2120 },
2064 .product = CODA_960, 2121 .product = CODA_960,
2065 .codecs = coda9_codecs, 2122 .codecs = coda9_codecs,
2066 .num_codecs = ARRAY_SIZE(coda9_codecs), 2123 .num_codecs = ARRAY_SIZE(coda9_codecs),
@@ -2071,7 +2128,10 @@ static const struct coda_devtype coda_devdata[] = {
2071 .iram_size = 0x21000, 2128 .iram_size = 0x21000,
2072 }, 2129 },
2073 [CODA_IMX6DL] = { 2130 [CODA_IMX6DL] = {
2074 .firmware = "v4l-coda960-imx6dl.bin", 2131 .firmware = {
2132 "vpu_fw_imx6d.bin",
2133 "v4l-coda960-imx6dl.bin"
2134 },
2075 .product = CODA_960, 2135 .product = CODA_960,
2076 .codecs = coda9_codecs, 2136 .codecs = coda9_codecs,
2077 .num_codecs = ARRAY_SIZE(coda9_codecs), 2137 .num_codecs = ARRAY_SIZE(coda9_codecs),
@@ -2118,14 +2178,12 @@ static int coda_probe(struct platform_device *pdev)
2118 2178
2119 pdev_id = of_id ? of_id->data : platform_get_device_id(pdev); 2179 pdev_id = of_id ? of_id->data : platform_get_device_id(pdev);
2120 2180
2121 if (of_id) { 2181 if (of_id)
2122 dev->devtype = of_id->data; 2182 dev->devtype = of_id->data;
2123 } else if (pdev_id) { 2183 else if (pdev_id)
2124 dev->devtype = &coda_devdata[pdev_id->driver_data]; 2184 dev->devtype = &coda_devdata[pdev_id->driver_data];
2125 } else { 2185 else
2126 ret = -EINVAL; 2186 return -EINVAL;
2127 goto err_v4l2_register;
2128 }
2129 2187
2130 spin_lock_init(&dev->irqlock); 2188 spin_lock_init(&dev->irqlock);
2131 INIT_LIST_HEAD(&dev->instances); 2189 INIT_LIST_HEAD(&dev->instances);
diff --git a/drivers/media/platform/coda/coda.h b/drivers/media/platform/coda/coda.h
index d08e9843e9f2..8f2c71e06966 100644
--- a/drivers/media/platform/coda/coda.h
+++ b/drivers/media/platform/coda/coda.h
@@ -50,7 +50,7 @@ enum coda_product {
50struct coda_video_device; 50struct coda_video_device;
51 51
52struct coda_devtype { 52struct coda_devtype {
53 char *firmware; 53 char *firmware[2];
54 enum coda_product product; 54 enum coda_product product;
55 const struct coda_codec *codecs; 55 const struct coda_codec *codecs;
56 unsigned int num_codecs; 56 unsigned int num_codecs;
@@ -74,6 +74,7 @@ struct coda_dev {
74 struct video_device vfd[5]; 74 struct video_device vfd[5];
75 struct platform_device *plat_dev; 75 struct platform_device *plat_dev;
76 const struct coda_devtype *devtype; 76 const struct coda_devtype *devtype;
77 int firmware;
77 78
78 void __iomem *regs_base; 79 void __iomem *regs_base;
79 struct clk *clk_per; 80 struct clk *clk_per;
diff --git a/drivers/media/platform/davinci/dm644x_ccdc.c b/drivers/media/platform/davinci/dm644x_ccdc.c
index ffbefdff6b5e..6fba32bec974 100644
--- a/drivers/media/platform/davinci/dm644x_ccdc.c
+++ b/drivers/media/platform/davinci/dm644x_ccdc.c
@@ -261,7 +261,7 @@ static int ccdc_update_raw_params(struct ccdc_config_params_raw *raw_params)
261 */ 261 */
262 if (raw_params->fault_pxl.fp_num != config_params->fault_pxl.fp_num) { 262 if (raw_params->fault_pxl.fp_num != config_params->fault_pxl.fp_num) {
263 if (fpc_physaddr != NULL) { 263 if (fpc_physaddr != NULL) {
264 free_pages((unsigned long)fpc_physaddr, 264 free_pages((unsigned long)fpc_virtaddr,
265 get_order 265 get_order
266 (config_params->fault_pxl.fp_num * 266 (config_params->fault_pxl.fp_num *
267 FP_NUM_BYTES)); 267 FP_NUM_BYTES));
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index 93782f15b825..a600e32e2543 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -700,7 +700,7 @@ static unsigned int gsc_m2m_poll(struct file *file,
700{ 700{
701 struct gsc_ctx *ctx = fh_to_ctx(file->private_data); 701 struct gsc_ctx *ctx = fh_to_ctx(file->private_data);
702 struct gsc_dev *gsc = ctx->gsc_dev; 702 struct gsc_dev *gsc = ctx->gsc_dev;
703 int ret; 703 unsigned int ret;
704 704
705 if (mutex_lock_interruptible(&gsc->lock)) 705 if (mutex_lock_interruptible(&gsc->lock))
706 return -ERESTARTSYS; 706 return -ERESTARTSYS;
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c
index e85649147dc8..dc1b929f7a33 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -992,10 +992,6 @@ static int fimc_lite_link_setup(struct media_entity *entity,
992 992
993 switch (local->index) { 993 switch (local->index) {
994 case FLITE_SD_PAD_SINK: 994 case FLITE_SD_PAD_SINK:
995 if (!is_media_entity_v4l2_subdev(remote->entity)) {
996 ret = -EINVAL;
997 break;
998 }
999 if (flags & MEDIA_LNK_FL_ENABLED) { 995 if (flags & MEDIA_LNK_FL_ENABLED) {
1000 if (fimc->source_subdev_grp_id == 0) 996 if (fimc->source_subdev_grp_id == 0)
1001 fimc->source_subdev_grp_id = sd->grp_id; 997 fimc->source_subdev_grp_id = sd->grp_id;
@@ -1010,19 +1006,15 @@ static int fimc_lite_link_setup(struct media_entity *entity,
1010 case FLITE_SD_PAD_SOURCE_DMA: 1006 case FLITE_SD_PAD_SOURCE_DMA:
1011 if (!(flags & MEDIA_LNK_FL_ENABLED)) 1007 if (!(flags & MEDIA_LNK_FL_ENABLED))
1012 atomic_set(&fimc->out_path, FIMC_IO_NONE); 1008 atomic_set(&fimc->out_path, FIMC_IO_NONE);
1013 else if (is_media_entity_v4l2_io(remote->entity))
1014 atomic_set(&fimc->out_path, FIMC_IO_DMA);
1015 else 1009 else
1016 ret = -EINVAL; 1010 atomic_set(&fimc->out_path, FIMC_IO_DMA);
1017 break; 1011 break;
1018 1012
1019 case FLITE_SD_PAD_SOURCE_ISP: 1013 case FLITE_SD_PAD_SOURCE_ISP:
1020 if (!(flags & MEDIA_LNK_FL_ENABLED)) 1014 if (!(flags & MEDIA_LNK_FL_ENABLED))
1021 atomic_set(&fimc->out_path, FIMC_IO_NONE); 1015 atomic_set(&fimc->out_path, FIMC_IO_NONE);
1022 else if (is_media_entity_v4l2_subdev(remote->entity))
1023 atomic_set(&fimc->out_path, FIMC_IO_ISP);
1024 else 1016 else
1025 ret = -EINVAL; 1017 atomic_set(&fimc->out_path, FIMC_IO_ISP);
1026 break; 1018 break;
1027 1019
1028 default: 1020 default:
diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index e79ddbb1e14f..feb521f28e14 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -389,13 +389,19 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
389 struct fimc_source_info *pd = &fmd->sensor[index].pdata; 389 struct fimc_source_info *pd = &fmd->sensor[index].pdata;
390 struct device_node *rem, *ep, *np; 390 struct device_node *rem, *ep, *np;
391 struct v4l2_of_endpoint endpoint; 391 struct v4l2_of_endpoint endpoint;
392 int ret;
392 393
393 /* Assume here a port node can have only one endpoint node. */ 394 /* Assume here a port node can have only one endpoint node. */
394 ep = of_get_next_child(port, NULL); 395 ep = of_get_next_child(port, NULL);
395 if (!ep) 396 if (!ep)
396 return 0; 397 return 0;
397 398
398 v4l2_of_parse_endpoint(ep, &endpoint); 399 ret = v4l2_of_parse_endpoint(ep, &endpoint);
400 if (ret) {
401 of_node_put(ep);
402 return ret;
403 }
404
399 if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS) 405 if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS)
400 return -EINVAL; 406 return -EINVAL;
401 407
@@ -486,8 +492,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
486 continue; 492 continue;
487 493
488 ret = fimc_md_parse_port_node(fmd, port, index); 494 ret = fimc_md_parse_port_node(fmd, port, index);
489 if (ret < 0) 495 if (ret < 0) {
496 of_node_put(node);
490 goto rpm_put; 497 goto rpm_put;
498 }
491 index++; 499 index++;
492 } 500 }
493 501
@@ -498,8 +506,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
498 506
499 for_each_child_of_node(ports, node) { 507 for_each_child_of_node(ports, node) {
500 ret = fimc_md_parse_port_node(fmd, node, index); 508 ret = fimc_md_parse_port_node(fmd, node, index);
501 if (ret < 0) 509 if (ret < 0) {
510 of_node_put(node);
502 break; 511 break;
512 }
503 index++; 513 index++;
504 } 514 }
505rpm_put: 515rpm_put:
@@ -707,8 +717,10 @@ static int fimc_md_register_platform_entities(struct fimc_md *fmd,
707 ret = fimc_md_register_platform_entity(fmd, pdev, 717 ret = fimc_md_register_platform_entity(fmd, pdev,
708 plat_entity); 718 plat_entity);
709 put_device(&pdev->dev); 719 put_device(&pdev->dev);
710 if (ret < 0) 720 if (ret < 0) {
721 of_node_put(node);
711 break; 722 break;
723 }
712 } 724 }
713 725
714 return ret; 726 return ret;
diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c
index ac5e50e595be..bd5c46c3d4b7 100644
--- a/drivers/media/platform/exynos4-is/mipi-csis.c
+++ b/drivers/media/platform/exynos4-is/mipi-csis.c
@@ -736,6 +736,7 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
736{ 736{
737 struct device_node *node = pdev->dev.of_node; 737 struct device_node *node = pdev->dev.of_node;
738 struct v4l2_of_endpoint endpoint; 738 struct v4l2_of_endpoint endpoint;
739 int ret;
739 740
740 if (of_property_read_u32(node, "clock-frequency", 741 if (of_property_read_u32(node, "clock-frequency",
741 &state->clk_frequency)) 742 &state->clk_frequency))
@@ -751,7 +752,9 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
751 return -EINVAL; 752 return -EINVAL;
752 } 753 }
753 /* Get port node and validate MIPI-CSI channel id. */ 754 /* Get port node and validate MIPI-CSI channel id. */
754 v4l2_of_parse_endpoint(node, &endpoint); 755 ret = v4l2_of_parse_endpoint(node, &endpoint);
756 if (ret)
757 goto err;
755 758
756 state->index = endpoint.base.port - FIMC_INPUT_MIPI_CSI2_0; 759 state->index = endpoint.base.port - FIMC_INPUT_MIPI_CSI2_0;
757 if (state->index >= CSIS_MAX_ENTITIES) 760 if (state->index >= CSIS_MAX_ENTITIES)
@@ -764,9 +767,10 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
764 "samsung,csis-wclk"); 767 "samsung,csis-wclk");
765 768
766 state->num_lanes = endpoint.bus.mipi_csi2.num_data_lanes; 769 state->num_lanes = endpoint.bus.mipi_csi2.num_data_lanes;
767 of_node_put(node);
768 770
769 return 0; 771err:
772 of_node_put(node);
773 return ret;
770} 774}
771 775
772static int s5pcsis_pm_resume(struct device *dev, bool runtime); 776static int s5pcsis_pm_resume(struct device *dev, bool runtime);
diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
index 0bcfa553c1aa..5d54e2c6c16b 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -64,6 +64,7 @@
64 64
65#include <media/v4l2-common.h> 65#include <media/v4l2-common.h>
66#include <media/v4l2-device.h> 66#include <media/v4l2-device.h>
67#include <media/v4l2-mc.h>
67#include <media/v4l2-of.h> 68#include <media/v4l2-of.h>
68 69
69#include "isp.h" 70#include "isp.h"
@@ -449,7 +450,7 @@ void omap3isp_configure_bridge(struct isp_device *isp,
449 case CCDC_INPUT_PARALLEL: 450 case CCDC_INPUT_PARALLEL:
450 ispctrl_val |= ISPCTRL_PAR_SER_CLK_SEL_PARALLEL; 451 ispctrl_val |= ISPCTRL_PAR_SER_CLK_SEL_PARALLEL;
451 ispctrl_val |= parcfg->clk_pol << ISPCTRL_PAR_CLK_POL_SHIFT; 452 ispctrl_val |= parcfg->clk_pol << ISPCTRL_PAR_CLK_POL_SHIFT;
452 shift += parcfg->data_lane_shift * 2; 453 shift += parcfg->data_lane_shift;
453 break; 454 break;
454 455
455 case CCDC_INPUT_CSI2A: 456 case CCDC_INPUT_CSI2A:
@@ -657,216 +658,6 @@ static irqreturn_t isp_isr(int irq, void *_isp)
657} 658}
658 659
659/* ----------------------------------------------------------------------------- 660/* -----------------------------------------------------------------------------
660 * Pipeline power management
661 *
662 * Entities must be powered up when part of a pipeline that contains at least
663 * one open video device node.
664 *
665 * To achieve this use the entity use_count field to track the number of users.
666 * For entities corresponding to video device nodes the use_count field stores
667 * the users count of the node. For entities corresponding to subdevs the
668 * use_count field stores the total number of users of all video device nodes
669 * in the pipeline.
670 *
671 * The omap3isp_pipeline_pm_use() function must be called in the open() and
672 * close() handlers of video device nodes. It increments or decrements the use
673 * count of all subdev entities in the pipeline.
674 *
675 * To react to link management on powered pipelines, the link setup notification
676 * callback updates the use count of all entities in the source and sink sides
677 * of the link.
678 */
679
680/*
681 * isp_pipeline_pm_use_count - Count the number of users of a pipeline
682 * @entity: The entity
683 *
684 * Return the total number of users of all video device nodes in the pipeline.
685 */
686static int isp_pipeline_pm_use_count(struct media_entity *entity,
687 struct media_entity_graph *graph)
688{
689 int use = 0;
690
691 media_entity_graph_walk_start(graph, entity);
692
693 while ((entity = media_entity_graph_walk_next(graph))) {
694 if (is_media_entity_v4l2_io(entity))
695 use += entity->use_count;
696 }
697
698 return use;
699}
700
701/*
702 * isp_pipeline_pm_power_one - Apply power change to an entity
703 * @entity: The entity
704 * @change: Use count change
705 *
706 * Change the entity use count by @change. If the entity is a subdev update its
707 * power state by calling the core::s_power operation when the use count goes
708 * from 0 to != 0 or from != 0 to 0.
709 *
710 * Return 0 on success or a negative error code on failure.
711 */
712static int isp_pipeline_pm_power_one(struct media_entity *entity, int change)
713{
714 struct v4l2_subdev *subdev;
715 int ret;
716
717 subdev = is_media_entity_v4l2_subdev(entity)
718 ? media_entity_to_v4l2_subdev(entity) : NULL;
719
720 if (entity->use_count == 0 && change > 0 && subdev != NULL) {
721 ret = v4l2_subdev_call(subdev, core, s_power, 1);
722 if (ret < 0 && ret != -ENOIOCTLCMD)
723 return ret;
724 }
725
726 entity->use_count += change;
727 WARN_ON(entity->use_count < 0);
728
729 if (entity->use_count == 0 && change < 0 && subdev != NULL)
730 v4l2_subdev_call(subdev, core, s_power, 0);
731
732 return 0;
733}
734
735/*
736 * isp_pipeline_pm_power - Apply power change to all entities in a pipeline
737 * @entity: The entity
738 * @change: Use count change
739 *
740 * Walk the pipeline to update the use count and the power state of all non-node
741 * entities.
742 *
743 * Return 0 on success or a negative error code on failure.
744 */
745static int isp_pipeline_pm_power(struct media_entity *entity, int change,
746 struct media_entity_graph *graph)
747{
748 struct media_entity *first = entity;
749 int ret = 0;
750
751 if (!change)
752 return 0;
753
754 media_entity_graph_walk_start(graph, entity);
755
756 while (!ret && (entity = media_entity_graph_walk_next(graph)))
757 if (is_media_entity_v4l2_subdev(entity))
758 ret = isp_pipeline_pm_power_one(entity, change);
759
760 if (!ret)
761 return ret;
762
763 media_entity_graph_walk_start(graph, first);
764
765 while ((first = media_entity_graph_walk_next(graph))
766 && first != entity)
767 if (is_media_entity_v4l2_subdev(first))
768 isp_pipeline_pm_power_one(first, -change);
769
770 return ret;
771}
772
773/*
774 * omap3isp_pipeline_pm_use - Update the use count of an entity
775 * @entity: The entity
776 * @use: Use (1) or stop using (0) the entity
777 *
778 * Update the use count of all entities in the pipeline and power entities on or
779 * off accordingly.
780 *
781 * Return 0 on success or a negative error code on failure. Powering entities
782 * off is assumed to never fail. No failure can occur when the use parameter is
783 * set to 0.
784 */
785int omap3isp_pipeline_pm_use(struct media_entity *entity, int use,
786 struct media_entity_graph *graph)
787{
788 int change = use ? 1 : -1;
789 int ret;
790
791 mutex_lock(&entity->graph_obj.mdev->graph_mutex);
792
793 /* Apply use count to node. */
794 entity->use_count += change;
795 WARN_ON(entity->use_count < 0);
796
797 /* Apply power change to connected non-nodes. */
798 ret = isp_pipeline_pm_power(entity, change, graph);
799 if (ret < 0)
800 entity->use_count -= change;
801
802 mutex_unlock(&entity->graph_obj.mdev->graph_mutex);
803
804 return ret;
805}
806
807/*
808 * isp_pipeline_link_notify - Link management notification callback
809 * @link: The link
810 * @flags: New link flags that will be applied
811 * @notification: The link's state change notification type (MEDIA_DEV_NOTIFY_*)
812 *
813 * React to link management on powered pipelines by updating the use count of
814 * all entities in the source and sink sides of the link. Entities are powered
815 * on or off accordingly.
816 *
817 * Return 0 on success or a negative error code on failure. Powering entities
818 * off is assumed to never fail. This function will not fail for disconnection
819 * events.
820 */
821static int isp_pipeline_link_notify(struct media_link *link, u32 flags,
822 unsigned int notification)
823{
824 struct media_entity_graph *graph =
825 &container_of(link->graph_obj.mdev, struct isp_device,
826 media_dev)->pm_count_graph;
827 struct media_entity *source = link->source->entity;
828 struct media_entity *sink = link->sink->entity;
829 int source_use;
830 int sink_use;
831 int ret = 0;
832
833 if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH) {
834 ret = media_entity_graph_walk_init(graph,
835 link->graph_obj.mdev);
836 if (ret)
837 return ret;
838 }
839
840 source_use = isp_pipeline_pm_use_count(source, graph);
841 sink_use = isp_pipeline_pm_use_count(sink, graph);
842
843 if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH &&
844 !(flags & MEDIA_LNK_FL_ENABLED)) {
845 /* Powering off entities is assumed to never fail. */
846 isp_pipeline_pm_power(source, -sink_use, graph);
847 isp_pipeline_pm_power(sink, -source_use, graph);
848 return 0;
849 }
850
851 if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH &&
852 (flags & MEDIA_LNK_FL_ENABLED)) {
853
854 ret = isp_pipeline_pm_power(source, sink_use, graph);
855 if (ret < 0)
856 return ret;
857
858 ret = isp_pipeline_pm_power(sink, source_use, graph);
859 if (ret < 0)
860 isp_pipeline_pm_power(source, -sink_use, graph);
861 }
862
863 if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH)
864 media_entity_graph_walk_cleanup(graph);
865
866 return ret;
867}
868
869/* -----------------------------------------------------------------------------
870 * Pipeline stream management 661 * Pipeline stream management
871 */ 662 */
872 663
@@ -1889,7 +1680,7 @@ static int isp_register_entities(struct isp_device *isp)
1889 strlcpy(isp->media_dev.model, "TI OMAP3 ISP", 1680 strlcpy(isp->media_dev.model, "TI OMAP3 ISP",
1890 sizeof(isp->media_dev.model)); 1681 sizeof(isp->media_dev.model));
1891 isp->media_dev.hw_revision = isp->revision; 1682 isp->media_dev.hw_revision = isp->revision;
1892 isp->media_dev.link_notify = isp_pipeline_link_notify; 1683 isp->media_dev.link_notify = v4l2_pipeline_link_notify;
1893 media_device_init(&isp->media_dev); 1684 media_device_init(&isp->media_dev);
1894 1685
1895 isp->v4l2_dev.mdev = &isp->media_dev; 1686 isp->v4l2_dev.mdev = &isp->media_dev;
@@ -2235,8 +2026,11 @@ static int isp_of_parse_node(struct device *dev, struct device_node *node,
2235 struct isp_bus_cfg *buscfg = &isd->bus; 2026 struct isp_bus_cfg *buscfg = &isd->bus;
2236 struct v4l2_of_endpoint vep; 2027 struct v4l2_of_endpoint vep;
2237 unsigned int i; 2028 unsigned int i;
2029 int ret;
2238 2030
2239 v4l2_of_parse_endpoint(node, &vep); 2031 ret = v4l2_of_parse_endpoint(node, &vep);
2032 if (ret)
2033 return ret;
2240 2034
2241 dev_dbg(dev, "parsing endpoint %s, interface %u\n", node->full_name, 2035 dev_dbg(dev, "parsing endpoint %s, interface %u\n", node->full_name,
2242 vep.base.port); 2036 vep.base.port);
@@ -2528,12 +2322,13 @@ static int isp_probe(struct platform_device *pdev)
2528 } 2322 }
2529 2323
2530 /* Interrupt */ 2324 /* Interrupt */
2531 isp->irq_num = platform_get_irq(pdev, 0); 2325 ret = platform_get_irq(pdev, 0);
2532 if (isp->irq_num <= 0) { 2326 if (ret <= 0) {
2533 dev_err(isp->dev, "No IRQ resource\n"); 2327 dev_err(isp->dev, "No IRQ resource\n");
2534 ret = -ENODEV; 2328 ret = -ENODEV;
2535 goto error_iommu; 2329 goto error_iommu;
2536 } 2330 }
2331 isp->irq_num = ret;
2537 2332
2538 if (devm_request_irq(isp->dev, isp->irq_num, isp_isr, IRQF_SHARED, 2333 if (devm_request_irq(isp->dev, isp->irq_num, isp_isr, IRQF_SHARED,
2539 "OMAP3 ISP", isp)) { 2334 "OMAP3 ISP", isp)) {
@@ -2599,6 +2394,7 @@ static const struct of_device_id omap3isp_of_table[] = {
2599 { .compatible = "ti,omap3-isp" }, 2394 { .compatible = "ti,omap3-isp" },
2600 { }, 2395 { },
2601}; 2396};
2397MODULE_DEVICE_TABLE(of, omap3isp_of_table);
2602 2398
2603static struct platform_driver omap3isp_driver = { 2399static struct platform_driver omap3isp_driver = {
2604 .probe = isp_probe, 2400 .probe = isp_probe,
diff --git a/drivers/media/platform/omap3isp/isp.h b/drivers/media/platform/omap3isp/isp.h
index 49b7f71ac968..7e6f6638433b 100644
--- a/drivers/media/platform/omap3isp/isp.h
+++ b/drivers/media/platform/omap3isp/isp.h
@@ -177,7 +177,6 @@ struct isp_device {
177 struct v4l2_device v4l2_dev; 177 struct v4l2_device v4l2_dev;
178 struct v4l2_async_notifier notifier; 178 struct v4l2_async_notifier notifier;
179 struct media_device media_dev; 179 struct media_device media_dev;
180 struct media_entity_graph pm_count_graph;
181 struct device *dev; 180 struct device *dev;
182 u32 revision; 181 u32 revision;
183 182
@@ -267,9 +266,6 @@ void omap3isp_subclk_enable(struct isp_device *isp,
267void omap3isp_subclk_disable(struct isp_device *isp, 266void omap3isp_subclk_disable(struct isp_device *isp,
268 enum isp_subclk_resource res); 267 enum isp_subclk_resource res);
269 268
270int omap3isp_pipeline_pm_use(struct media_entity *entity, int use,
271 struct media_entity_graph *graph);
272
273int omap3isp_register_entities(struct platform_device *pdev, 269int omap3isp_register_entities(struct platform_device *pdev,
274 struct v4l2_device *v4l2_dev); 270 struct v4l2_device *v4l2_dev);
275void omap3isp_unregister_entities(struct platform_device *pdev); 271void omap3isp_unregister_entities(struct platform_device *pdev);
diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c
index bb3974c98e37..882310eb45cc 100644
--- a/drivers/media/platform/omap3isp/ispccdc.c
+++ b/drivers/media/platform/omap3isp/ispccdc.c
@@ -2421,7 +2421,7 @@ static int ccdc_link_validate(struct v4l2_subdev *sd,
2421 &((struct isp_bus_cfg *) 2421 &((struct isp_bus_cfg *)
2422 media_entity_to_v4l2_subdev(link->source->entity) 2422 media_entity_to_v4l2_subdev(link->source->entity)
2423 ->host_priv)->bus.parallel; 2423 ->host_priv)->bus.parallel;
2424 parallel_shift = parcfg->data_lane_shift * 2; 2424 parallel_shift = parcfg->data_lane_shift;
2425 } else { 2425 } else {
2426 parallel_shift = 0; 2426 parallel_shift = 0;
2427 } 2427 }
diff --git a/drivers/media/platform/omap3isp/isppreview.c b/drivers/media/platform/omap3isp/isppreview.c
index 84a96670e2e7..ac30a0f83780 100644
--- a/drivers/media/platform/omap3isp/isppreview.c
+++ b/drivers/media/platform/omap3isp/isppreview.c
@@ -1480,13 +1480,6 @@ static void preview_isr_buffer(struct isp_prev_device *prev)
1480 struct isp_buffer *buffer; 1480 struct isp_buffer *buffer;
1481 int restart = 0; 1481 int restart = 0;
1482 1482
1483 if (prev->input == PREVIEW_INPUT_MEMORY) {
1484 buffer = omap3isp_video_buffer_next(&prev->video_in);
1485 if (buffer != NULL)
1486 preview_set_inaddr(prev, buffer->dma);
1487 pipe->state |= ISP_PIPELINE_IDLE_INPUT;
1488 }
1489
1490 if (prev->output & PREVIEW_OUTPUT_MEMORY) { 1483 if (prev->output & PREVIEW_OUTPUT_MEMORY) {
1491 buffer = omap3isp_video_buffer_next(&prev->video_out); 1484 buffer = omap3isp_video_buffer_next(&prev->video_out);
1492 if (buffer != NULL) { 1485 if (buffer != NULL) {
@@ -1496,6 +1489,13 @@ static void preview_isr_buffer(struct isp_prev_device *prev)
1496 pipe->state |= ISP_PIPELINE_IDLE_OUTPUT; 1489 pipe->state |= ISP_PIPELINE_IDLE_OUTPUT;
1497 } 1490 }
1498 1491
1492 if (prev->input == PREVIEW_INPUT_MEMORY) {
1493 buffer = omap3isp_video_buffer_next(&prev->video_in);
1494 if (buffer != NULL)
1495 preview_set_inaddr(prev, buffer->dma);
1496 pipe->state |= ISP_PIPELINE_IDLE_INPUT;
1497 }
1498
1499 switch (prev->state) { 1499 switch (prev->state) {
1500 case ISP_PIPELINE_STREAM_SINGLESHOT: 1500 case ISP_PIPELINE_STREAM_SINGLESHOT:
1501 if (isp_pipeline_ready(pipe)) 1501 if (isp_pipeline_ready(pipe))
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c
index 994dfc0813f6..ac76d2901501 100644
--- a/drivers/media/platform/omap3isp/ispvideo.c
+++ b/drivers/media/platform/omap3isp/ispvideo.c
@@ -22,8 +22,10 @@
22#include <linux/sched.h> 22#include <linux/sched.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/vmalloc.h> 24#include <linux/vmalloc.h>
25
25#include <media/v4l2-dev.h> 26#include <media/v4l2-dev.h>
26#include <media/v4l2-ioctl.h> 27#include <media/v4l2-ioctl.h>
28#include <media/v4l2-mc.h>
27#include <media/videobuf2-dma-contig.h> 29#include <media/videobuf2-dma-contig.h>
28 30
29#include "ispvideo.h" 31#include "ispvideo.h"
@@ -434,10 +436,68 @@ static void isp_video_buffer_queue(struct vb2_buffer *buf)
434 } 436 }
435} 437}
436 438
439/*
440 * omap3isp_video_return_buffers - Return all queued buffers to videobuf2
441 * @video: ISP video object
442 * @state: new state for the returned buffers
443 *
444 * Return all buffers queued on the video node to videobuf2 in the given state.
445 * The buffer state should be VB2_BUF_STATE_QUEUED if called due to an error
446 * when starting the stream, or VB2_BUF_STATE_ERROR otherwise.
447 *
448 * The function must be called with the video irqlock held.
449 */
450static void omap3isp_video_return_buffers(struct isp_video *video,
451 enum vb2_buffer_state state)
452{
453 while (!list_empty(&video->dmaqueue)) {
454 struct isp_buffer *buf;
455
456 buf = list_first_entry(&video->dmaqueue,
457 struct isp_buffer, irqlist);
458 list_del(&buf->irqlist);
459 vb2_buffer_done(&buf->vb.vb2_buf, state);
460 }
461}
462
463static int isp_video_start_streaming(struct vb2_queue *queue,
464 unsigned int count)
465{
466 struct isp_video_fh *vfh = vb2_get_drv_priv(queue);
467 struct isp_video *video = vfh->video;
468 struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity);
469 unsigned long flags;
470 int ret;
471
472 /* In sensor-to-memory mode, the stream can be started synchronously
473 * to the stream on command. In memory-to-memory mode, it will be
474 * started when buffers are queued on both the input and output.
475 */
476 if (pipe->input)
477 return 0;
478
479 ret = omap3isp_pipeline_set_stream(pipe,
480 ISP_PIPELINE_STREAM_CONTINUOUS);
481 if (ret < 0) {
482 spin_lock_irqsave(&video->irqlock, flags);
483 omap3isp_video_return_buffers(video, VB2_BUF_STATE_QUEUED);
484 spin_unlock_irqrestore(&video->irqlock, flags);
485 return ret;
486 }
487
488 spin_lock_irqsave(&video->irqlock, flags);
489 if (list_empty(&video->dmaqueue))
490 video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_UNDERRUN;
491 spin_unlock_irqrestore(&video->irqlock, flags);
492
493 return 0;
494}
495
437static const struct vb2_ops isp_video_queue_ops = { 496static const struct vb2_ops isp_video_queue_ops = {
438 .queue_setup = isp_video_queue_setup, 497 .queue_setup = isp_video_queue_setup,
439 .buf_prepare = isp_video_buffer_prepare, 498 .buf_prepare = isp_video_buffer_prepare,
440 .buf_queue = isp_video_buffer_queue, 499 .buf_queue = isp_video_buffer_queue,
500 .start_streaming = isp_video_start_streaming,
441}; 501};
442 502
443/* 503/*
@@ -459,7 +519,7 @@ static const struct vb2_ops isp_video_queue_ops = {
459struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video) 519struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video)
460{ 520{
461 struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity); 521 struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity);
462 enum isp_pipeline_state state; 522 enum vb2_buffer_state vb_state;
463 struct isp_buffer *buf; 523 struct isp_buffer *buf;
464 unsigned long flags; 524 unsigned long flags;
465 525
@@ -495,17 +555,19 @@ struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video)
495 555
496 /* Report pipeline errors to userspace on the capture device side. */ 556 /* Report pipeline errors to userspace on the capture device side. */
497 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pipe->error) { 557 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pipe->error) {
498 state = VB2_BUF_STATE_ERROR; 558 vb_state = VB2_BUF_STATE_ERROR;
499 pipe->error = false; 559 pipe->error = false;
500 } else { 560 } else {
501 state = VB2_BUF_STATE_DONE; 561 vb_state = VB2_BUF_STATE_DONE;
502 } 562 }
503 563
504 vb2_buffer_done(&buf->vb.vb2_buf, state); 564 vb2_buffer_done(&buf->vb.vb2_buf, vb_state);
505 565
506 spin_lock_irqsave(&video->irqlock, flags); 566 spin_lock_irqsave(&video->irqlock, flags);
507 567
508 if (list_empty(&video->dmaqueue)) { 568 if (list_empty(&video->dmaqueue)) {
569 enum isp_pipeline_state state;
570
509 spin_unlock_irqrestore(&video->irqlock, flags); 571 spin_unlock_irqrestore(&video->irqlock, flags);
510 572
511 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) 573 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
@@ -541,26 +603,16 @@ struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video)
541 * omap3isp_video_cancel_stream - Cancel stream on a video node 603 * omap3isp_video_cancel_stream - Cancel stream on a video node
542 * @video: ISP video object 604 * @video: ISP video object
543 * 605 *
544 * Cancelling a stream mark all buffers on the video node as erroneous and makes 606 * Cancelling a stream returns all buffers queued on the video node to videobuf2
545 * sure no new buffer can be queued. 607 * in the erroneous state and makes sure no new buffer can be queued.
546 */ 608 */
547void omap3isp_video_cancel_stream(struct isp_video *video) 609void omap3isp_video_cancel_stream(struct isp_video *video)
548{ 610{
549 unsigned long flags; 611 unsigned long flags;
550 612
551 spin_lock_irqsave(&video->irqlock, flags); 613 spin_lock_irqsave(&video->irqlock, flags);
552 614 omap3isp_video_return_buffers(video, VB2_BUF_STATE_ERROR);
553 while (!list_empty(&video->dmaqueue)) {
554 struct isp_buffer *buf;
555
556 buf = list_first_entry(&video->dmaqueue,
557 struct isp_buffer, irqlist);
558 list_del(&buf->irqlist);
559 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
560 }
561
562 video->error = true; 615 video->error = true;
563
564 spin_unlock_irqrestore(&video->irqlock, flags); 616 spin_unlock_irqrestore(&video->irqlock, flags);
565} 617}
566 618
@@ -1087,29 +1139,10 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
1087 if (ret < 0) 1139 if (ret < 0)
1088 goto err_check_format; 1140 goto err_check_format;
1089 1141
1090 /* In sensor-to-memory mode, the stream can be started synchronously
1091 * to the stream on command. In memory-to-memory mode, it will be
1092 * started when buffers are queued on both the input and output.
1093 */
1094 if (pipe->input == NULL) {
1095 ret = omap3isp_pipeline_set_stream(pipe,
1096 ISP_PIPELINE_STREAM_CONTINUOUS);
1097 if (ret < 0)
1098 goto err_set_stream;
1099 spin_lock_irqsave(&video->irqlock, flags);
1100 if (list_empty(&video->dmaqueue))
1101 video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_UNDERRUN;
1102 spin_unlock_irqrestore(&video->irqlock, flags);
1103 }
1104
1105 mutex_unlock(&video->stream_lock); 1142 mutex_unlock(&video->stream_lock);
1106 1143
1107 return 0; 1144 return 0;
1108 1145
1109err_set_stream:
1110 mutex_lock(&video->queue_lock);
1111 vb2_streamoff(&vfh->queue, type);
1112 mutex_unlock(&video->queue_lock);
1113err_check_format: 1146err_check_format:
1114 media_entity_pipeline_stop(&video->video.entity); 1147 media_entity_pipeline_stop(&video->video.entity);
1115err_pipeline_start: 1148err_pipeline_start:
@@ -1261,12 +1294,7 @@ static int isp_video_open(struct file *file)
1261 goto done; 1294 goto done;
1262 } 1295 }
1263 1296
1264 ret = media_entity_graph_walk_init(&handle->graph, 1297 ret = v4l2_pipeline_pm_use(&video->video.entity, 1);
1265 &video->isp->media_dev);
1266 if (ret)
1267 goto done;
1268
1269 ret = omap3isp_pipeline_pm_use(&video->video.entity, 1, &handle->graph);
1270 if (ret < 0) { 1298 if (ret < 0) {
1271 omap3isp_put(video->isp); 1299 omap3isp_put(video->isp);
1272 goto done; 1300 goto done;
@@ -1297,7 +1325,6 @@ static int isp_video_open(struct file *file)
1297done: 1325done:
1298 if (ret < 0) { 1326 if (ret < 0) {
1299 v4l2_fh_del(&handle->vfh); 1327 v4l2_fh_del(&handle->vfh);
1300 media_entity_graph_walk_cleanup(&handle->graph);
1301 kfree(handle); 1328 kfree(handle);
1302 } 1329 }
1303 1330
@@ -1317,8 +1344,7 @@ static int isp_video_release(struct file *file)
1317 vb2_queue_release(&handle->queue); 1344 vb2_queue_release(&handle->queue);
1318 mutex_unlock(&video->queue_lock); 1345 mutex_unlock(&video->queue_lock);
1319 1346
1320 omap3isp_pipeline_pm_use(&video->video.entity, 0, &handle->graph); 1347 v4l2_pipeline_pm_use(&video->video.entity, 0);
1321 media_entity_graph_walk_cleanup(&handle->graph);
1322 1348
1323 /* Release the file handle. */ 1349 /* Release the file handle. */
1324 v4l2_fh_del(vfh); 1350 v4l2_fh_del(vfh);
diff --git a/drivers/media/platform/omap3isp/ispvideo.h b/drivers/media/platform/omap3isp/ispvideo.h
index 156429878d64..6a48d5879c56 100644
--- a/drivers/media/platform/omap3isp/ispvideo.h
+++ b/drivers/media/platform/omap3isp/ispvideo.h
@@ -189,7 +189,6 @@ struct isp_video_fh {
189 struct vb2_queue queue; 189 struct vb2_queue queue;
190 struct v4l2_format format; 190 struct v4l2_format format;
191 struct v4l2_fract timeperframe; 191 struct v4l2_fract timeperframe;
192 struct media_entity_graph graph;
193}; 192};
194 193
195#define to_isp_video_fh(fh) container_of(fh, struct isp_video_fh, vfh) 194#define to_isp_video_fh(fh) container_of(fh, struct isp_video_fh, vfh)
diff --git a/drivers/media/platform/omap3isp/omap3isp.h b/drivers/media/platform/omap3isp/omap3isp.h
index 190e259a6a2d..443e8f7673e2 100644
--- a/drivers/media/platform/omap3isp/omap3isp.h
+++ b/drivers/media/platform/omap3isp/omap3isp.h
@@ -33,9 +33,9 @@ enum isp_interface_type {
33 * struct isp_parallel_cfg - Parallel interface configuration 33 * struct isp_parallel_cfg - Parallel interface configuration
34 * @data_lane_shift: Data lane shifter 34 * @data_lane_shift: Data lane shifter
35 * 0 - CAMEXT[13:0] -> CAM[13:0] 35 * 0 - CAMEXT[13:0] -> CAM[13:0]
36 * 1 - CAMEXT[13:2] -> CAM[11:0] 36 * 2 - CAMEXT[13:2] -> CAM[11:0]
37 * 2 - CAMEXT[13:4] -> CAM[9:0] 37 * 4 - CAMEXT[13:4] -> CAM[9:0]
38 * 3 - CAMEXT[13:6] -> CAM[7:0] 38 * 6 - CAMEXT[13:6] -> CAM[7:0]
39 * @clk_pol: Pixel clock polarity 39 * @clk_pol: Pixel clock polarity
40 * 0 - Sample on rising edge, 1 - Sample on falling edge 40 * 0 - Sample on rising edge, 1 - Sample on falling edge
41 * @hs_pol: Horizontal synchronization polarity 41 * @hs_pol: Horizontal synchronization polarity
@@ -48,7 +48,7 @@ enum isp_interface_type {
48 * 0 - Normal, 1 - One's complement 48 * 0 - Normal, 1 - One's complement
49 */ 49 */
50struct isp_parallel_cfg { 50struct isp_parallel_cfg {
51 unsigned int data_lane_shift:2; 51 unsigned int data_lane_shift:3;
52 unsigned int clk_pol:1; 52 unsigned int clk_pol:1;
53 unsigned int hs_pol:1; 53 unsigned int hs_pol:1;
54 unsigned int vs_pol:1; 54 unsigned int vs_pol:1;
diff --git a/drivers/media/platform/rcar_jpu.c b/drivers/media/platform/rcar_jpu.c
index 485f5259acb0..552789a69c86 100644
--- a/drivers/media/platform/rcar_jpu.c
+++ b/drivers/media/platform/rcar_jpu.c
@@ -1613,6 +1613,7 @@ static const struct of_device_id jpu_dt_ids[] = {
1613 { .compatible = "renesas,jpu-r8a7791" }, /* M2-W */ 1613 { .compatible = "renesas,jpu-r8a7791" }, /* M2-W */
1614 { .compatible = "renesas,jpu-r8a7792" }, /* V2H */ 1614 { .compatible = "renesas,jpu-r8a7792" }, /* V2H */
1615 { .compatible = "renesas,jpu-r8a7793" }, /* M2-N */ 1615 { .compatible = "renesas,jpu-r8a7793" }, /* M2-N */
1616 { .compatible = "renesas,rcar-gen2-jpu" },
1616 { }, 1617 { },
1617}; 1618};
1618MODULE_DEVICE_TABLE(of, jpu_dt_ids); 1619MODULE_DEVICE_TABLE(of, jpu_dt_ids);
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 0434f02a7175..034b5c1d35a1 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -212,6 +212,14 @@ static struct mfc_control controls[] = {
212 .menu_skip_mask = 0, 212 .menu_skip_mask = 0,
213 }, 213 },
214 { 214 {
215 .id = V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME,
216 .type = V4L2_CTRL_TYPE_BUTTON,
217 .minimum = 0,
218 .maximum = 0,
219 .step = 0,
220 .default_value = 0,
221 },
222 {
215 .id = V4L2_CID_MPEG_VIDEO_VBV_SIZE, 223 .id = V4L2_CID_MPEG_VIDEO_VBV_SIZE,
216 .type = V4L2_CTRL_TYPE_INTEGER, 224 .type = V4L2_CTRL_TYPE_INTEGER,
217 .minimum = 0, 225 .minimum = 0,
@@ -1423,6 +1431,10 @@ static int s5p_mfc_enc_s_ctrl(struct v4l2_ctrl *ctrl)
1423 case V4L2_CID_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE: 1431 case V4L2_CID_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE:
1424 ctx->force_frame_type = ctrl->val; 1432 ctx->force_frame_type = ctrl->val;
1425 break; 1433 break;
1434 case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME:
1435 ctx->force_frame_type =
1436 V4L2_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE_I_FRAME;
1437 break;
1426 case V4L2_CID_MPEG_VIDEO_VBV_SIZE: 1438 case V4L2_CID_MPEG_VIDEO_VBV_SIZE:
1427 p->vbv_size = ctrl->val; 1439 p->vbv_size = ctrl->val;
1428 break; 1440 break;
diff --git a/drivers/media/platform/soc_camera/Kconfig b/drivers/media/platform/soc_camera/Kconfig
index f2776cd415ca..355298989dd8 100644
--- a/drivers/media/platform/soc_camera/Kconfig
+++ b/drivers/media/platform/soc_camera/Kconfig
@@ -17,19 +17,11 @@ config SOC_CAMERA_PLATFORM
17 help 17 help
18 This is a generic SoC camera platform driver, useful for testing 18 This is a generic SoC camera platform driver, useful for testing
19 19
20config VIDEO_MX3
21 tristate "i.MX3x Camera Sensor Interface driver"
22 depends on VIDEO_DEV && MX3_IPU && SOC_CAMERA
23 depends on MX3_IPU || COMPILE_TEST
24 depends on HAS_DMA
25 select VIDEOBUF2_DMA_CONTIG
26 ---help---
27 This is a v4l2 driver for the i.MX3x Camera Sensor Interface
28
29config VIDEO_PXA27x 20config VIDEO_PXA27x
30 tristate "PXA27x Quick Capture Interface driver" 21 tristate "PXA27x Quick Capture Interface driver"
31 depends on VIDEO_DEV && PXA27x && SOC_CAMERA 22 depends on VIDEO_DEV && PXA27x && SOC_CAMERA
32 select VIDEOBUF_DMA_SG 23 select VIDEOBUF_DMA_SG
24 select SG_SPLIT
33 ---help--- 25 ---help---
34 This is a v4l2 driver for the PXA27x Quick Capture Interface 26 This is a v4l2 driver for the PXA27x Quick Capture Interface
35 27
@@ -60,25 +52,6 @@ config VIDEO_SH_MOBILE_CEU
60 ---help--- 52 ---help---
61 This is a v4l2 driver for the SuperH Mobile CEU Interface 53 This is a v4l2 driver for the SuperH Mobile CEU Interface
62 54
63config VIDEO_OMAP1
64 tristate "OMAP1 Camera Interface driver"
65 depends on VIDEO_DEV && SOC_CAMERA
66 depends on ARCH_OMAP1
67 depends on HAS_DMA
68 select VIDEOBUF_DMA_CONTIG
69 select VIDEOBUF_DMA_SG
70 ---help---
71 This is a v4l2 driver for the TI OMAP1 camera interface
72
73config VIDEO_MX2
74 tristate "i.MX27 Camera Sensor Interface driver"
75 depends on VIDEO_DEV && SOC_CAMERA
76 depends on SOC_IMX27 || COMPILE_TEST
77 depends on HAS_DMA
78 select VIDEOBUF2_DMA_CONTIG
79 ---help---
80 This is a v4l2 driver for the i.MX27 Camera Sensor Interface
81
82config VIDEO_ATMEL_ISI 55config VIDEO_ATMEL_ISI
83 tristate "ATMEL Image Sensor Interface (ISI) support" 56 tristate "ATMEL Image Sensor Interface (ISI) support"
84 depends on VIDEO_DEV && SOC_CAMERA 57 depends on VIDEO_DEV && SOC_CAMERA
diff --git a/drivers/media/platform/soc_camera/Makefile b/drivers/media/platform/soc_camera/Makefile
index 2826382dc9f8..7ee71ae231c7 100644
--- a/drivers/media/platform/soc_camera/Makefile
+++ b/drivers/media/platform/soc_camera/Makefile
@@ -7,9 +7,6 @@ obj-$(CONFIG_SOC_CAMERA_PLATFORM) += soc_camera_platform.o
7 7
8# soc-camera host drivers have to be linked after camera drivers 8# soc-camera host drivers have to be linked after camera drivers
9obj-$(CONFIG_VIDEO_ATMEL_ISI) += atmel-isi.o 9obj-$(CONFIG_VIDEO_ATMEL_ISI) += atmel-isi.o
10obj-$(CONFIG_VIDEO_MX2) += mx2_camera.o
11obj-$(CONFIG_VIDEO_MX3) += mx3_camera.o
12obj-$(CONFIG_VIDEO_OMAP1) += omap1_camera.o
13obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o 10obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o
14obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o 11obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o
15obj-$(CONFIG_VIDEO_SH_MOBILE_CSI2) += sh_mobile_csi2.o 12obj-$(CONFIG_VIDEO_SH_MOBILE_CSI2) += sh_mobile_csi2.o
diff --git a/drivers/media/platform/soc_camera/atmel-isi.c b/drivers/media/platform/soc_camera/atmel-isi.c
index 1af779ee3c74..ab2d9b9b1f5d 100644
--- a/drivers/media/platform/soc_camera/atmel-isi.c
+++ b/drivers/media/platform/soc_camera/atmel-isi.c
@@ -1026,7 +1026,7 @@ static int atmel_isi_parse_dt(struct atmel_isi *isi,
1026 1026
1027static int atmel_isi_probe(struct platform_device *pdev) 1027static int atmel_isi_probe(struct platform_device *pdev)
1028{ 1028{
1029 unsigned int irq; 1029 int irq;
1030 struct atmel_isi *isi; 1030 struct atmel_isi *isi;
1031 struct resource *regs; 1031 struct resource *regs;
1032 int ret, i; 1032 int ret, i;
@@ -1086,7 +1086,7 @@ static int atmel_isi_probe(struct platform_device *pdev)
1086 isi->width_flags |= 1 << 9; 1086 isi->width_flags |= 1 << 9;
1087 1087
1088 irq = platform_get_irq(pdev, 0); 1088 irq = platform_get_irq(pdev, 0);
1089 if (IS_ERR_VALUE(irq)) { 1089 if (irq < 0) {
1090 ret = irq; 1090 ret = irq;
1091 goto err_req_irq; 1091 goto err_req_irq;
1092 } 1092 }
diff --git a/drivers/media/platform/soc_camera/pxa_camera.c b/drivers/media/platform/soc_camera/pxa_camera.c
index 415f3bda60bf..2aaf4a8f71a0 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -28,6 +28,9 @@
28#include <linux/clk.h> 28#include <linux/clk.h>
29#include <linux/sched.h> 29#include <linux/sched.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/dmaengine.h>
32#include <linux/dma-mapping.h>
33#include <linux/dma/pxa-dma.h>
31 34
32#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
33#include <media/v4l2-dev.h> 36#include <media/v4l2-dev.h>
@@ -38,7 +41,6 @@
38 41
39#include <linux/videodev2.h> 42#include <linux/videodev2.h>
40 43
41#include <mach/dma.h>
42#include <linux/platform_data/media/camera-pxa.h> 44#include <linux/platform_data/media/camera-pxa.h>
43 45
44#define PXA_CAM_VERSION "0.0.6" 46#define PXA_CAM_VERSION "0.0.6"
@@ -175,21 +177,16 @@ enum pxa_camera_active_dma {
175 DMA_V = 0x4, 177 DMA_V = 0x4,
176}; 178};
177 179
178/* descriptor needed for the PXA DMA engine */
179struct pxa_cam_dma {
180 dma_addr_t sg_dma;
181 struct pxa_dma_desc *sg_cpu;
182 size_t sg_size;
183 int sglen;
184};
185
186/* buffer for one video frame */ 180/* buffer for one video frame */
187struct pxa_buffer { 181struct pxa_buffer {
188 /* common v4l buffer stuff -- must be first */ 182 /* common v4l buffer stuff -- must be first */
189 struct videobuf_buffer vb; 183 struct videobuf_buffer vb;
190 u32 code; 184 u32 code;
191 /* our descriptor lists for Y, U and V channels */ 185 /* our descriptor lists for Y, U and V channels */
192 struct pxa_cam_dma dmas[3]; 186 struct dma_async_tx_descriptor *descs[3];
187 dma_cookie_t cookie[3];
188 struct scatterlist *sg[3];
189 int sg_len[3];
193 int inwork; 190 int inwork;
194 enum pxa_camera_active_dma active_dma; 191 enum pxa_camera_active_dma active_dma;
195}; 192};
@@ -207,7 +204,7 @@ struct pxa_camera_dev {
207 void __iomem *base; 204 void __iomem *base;
208 205
209 int channels; 206 int channels;
210 unsigned int dma_chans[3]; 207 struct dma_chan *dma_chans[3];
211 208
212 struct pxacamera_platform_data *pdata; 209 struct pxacamera_platform_data *pdata;
213 struct resource *res; 210 struct resource *res;
@@ -222,7 +219,7 @@ struct pxa_camera_dev {
222 spinlock_t lock; 219 spinlock_t lock;
223 220
224 struct pxa_buffer *active; 221 struct pxa_buffer *active;
225 struct pxa_dma_desc *sg_tail[3]; 222 struct tasklet_struct task_eof;
226 223
227 u32 save_cicr[5]; 224 u32 save_cicr[5];
228}; 225};
@@ -258,7 +255,6 @@ static int pxa_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
258static void free_buffer(struct videobuf_queue *vq, struct pxa_buffer *buf) 255static void free_buffer(struct videobuf_queue *vq, struct pxa_buffer *buf)
259{ 256{
260 struct soc_camera_device *icd = vq->priv_data; 257 struct soc_camera_device *icd = vq->priv_data;
261 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
262 struct videobuf_dmabuf *dma = videobuf_to_dma(&buf->vb); 258 struct videobuf_dmabuf *dma = videobuf_to_dma(&buf->vb);
263 int i; 259 int i;
264 260
@@ -272,42 +268,45 @@ static void free_buffer(struct videobuf_queue *vq, struct pxa_buffer *buf)
272 * longer in STATE_QUEUED or STATE_ACTIVE 268 * longer in STATE_QUEUED or STATE_ACTIVE
273 */ 269 */
274 videobuf_waiton(vq, &buf->vb, 0, 0); 270 videobuf_waiton(vq, &buf->vb, 0, 0);
275 videobuf_dma_unmap(vq->dev, dma);
276 videobuf_dma_free(dma);
277 271
278 for (i = 0; i < ARRAY_SIZE(buf->dmas); i++) { 272 for (i = 0; i < 3 && buf->descs[i]; i++) {
279 if (buf->dmas[i].sg_cpu) 273 dmaengine_desc_free(buf->descs[i]);
280 dma_free_coherent(ici->v4l2_dev.dev, 274 kfree(buf->sg[i]);
281 buf->dmas[i].sg_size, 275 buf->descs[i] = NULL;
282 buf->dmas[i].sg_cpu, 276 buf->sg[i] = NULL;
283 buf->dmas[i].sg_dma); 277 buf->sg_len[i] = 0;
284 buf->dmas[i].sg_cpu = NULL;
285 } 278 }
279 videobuf_dma_unmap(vq->dev, dma);
280 videobuf_dma_free(dma);
286 281
287 buf->vb.state = VIDEOBUF_NEEDS_INIT; 282 buf->vb.state = VIDEOBUF_NEEDS_INIT;
283
284 dev_dbg(icd->parent, "%s end (vb=0x%p) 0x%08lx %d\n", __func__,
285 &buf->vb, buf->vb.baddr, buf->vb.bsize);
288} 286}
289 287
290static int calculate_dma_sglen(struct scatterlist *sglist, int sglen, 288static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
291 int sg_first_ofs, int size) 289 enum pxa_camera_active_dma act_dma);
290
291static void pxa_camera_dma_irq_y(void *data)
292{ 292{
293 int i, offset, dma_len, xfer_len; 293 struct pxa_camera_dev *pcdev = data;
294 struct scatterlist *sg;
295 294
296 offset = sg_first_ofs; 295 pxa_camera_dma_irq(pcdev, DMA_Y);
297 for_each_sg(sglist, sg, sglen, i) { 296}
298 dma_len = sg_dma_len(sg);
299 297
300 /* PXA27x Developer's Manual 27.4.4.1: round up to 8 bytes */ 298static void pxa_camera_dma_irq_u(void *data)
301 xfer_len = roundup(min(dma_len - offset, size), 8); 299{
300 struct pxa_camera_dev *pcdev = data;
302 301
303 size = max(0, size - xfer_len); 302 pxa_camera_dma_irq(pcdev, DMA_U);
304 offset = 0; 303}
305 if (size == 0) 304
306 break; 305static void pxa_camera_dma_irq_v(void *data)
307 } 306{
307 struct pxa_camera_dev *pcdev = data;
308 308
309 BUG_ON(size != 0); 309 pxa_camera_dma_irq(pcdev, DMA_V);
310 return i + 1;
311} 310}
312 311
313/** 312/**
@@ -318,93 +317,53 @@ static int calculate_dma_sglen(struct scatterlist *sglist, int sglen,
318 * @channel: dma channel (0 => 'Y', 1 => 'U', 2 => 'V') 317 * @channel: dma channel (0 => 'Y', 1 => 'U', 2 => 'V')
319 * @cibr: camera Receive Buffer Register 318 * @cibr: camera Receive Buffer Register
320 * @size: bytes to transfer 319 * @size: bytes to transfer
321 * @sg_first: first element of sg_list 320 * @offset: offset in videobuffer of the first byte to transfer
322 * @sg_first_ofs: offset in first element of sg_list
323 * 321 *
324 * Prepares the pxa dma descriptors to transfer one camera channel. 322 * Prepares the pxa dma descriptors to transfer one camera channel.
325 * Beware sg_first and sg_first_ofs are both input and output parameters.
326 * 323 *
327 * Returns 0 or -ENOMEM if no coherent memory is available 324 * Returns 0 if success or -ENOMEM if no memory is available
328 */ 325 */
329static int pxa_init_dma_channel(struct pxa_camera_dev *pcdev, 326static int pxa_init_dma_channel(struct pxa_camera_dev *pcdev,
330 struct pxa_buffer *buf, 327 struct pxa_buffer *buf,
331 struct videobuf_dmabuf *dma, int channel, 328 struct videobuf_dmabuf *dma, int channel,
332 int cibr, int size, 329 int cibr, int size, int offset)
333 struct scatterlist **sg_first, int *sg_first_ofs)
334{ 330{
335 struct pxa_cam_dma *pxa_dma = &buf->dmas[channel]; 331 struct dma_chan *dma_chan = pcdev->dma_chans[channel];
336 struct device *dev = pcdev->soc_host.v4l2_dev.dev; 332 struct scatterlist *sg = buf->sg[channel];
337 struct scatterlist *sg; 333 int sglen = buf->sg_len[channel];
338 int i, offset, sglen; 334 struct dma_async_tx_descriptor *tx;
339 int dma_len = 0, xfer_len = 0; 335
340 336 tx = dmaengine_prep_slave_sg(dma_chan, sg, sglen, DMA_DEV_TO_MEM,
341 if (pxa_dma->sg_cpu) 337 DMA_PREP_INTERRUPT | DMA_CTRL_REUSE);
342 dma_free_coherent(dev, pxa_dma->sg_size, 338 if (!tx) {
343 pxa_dma->sg_cpu, pxa_dma->sg_dma); 339 dev_err(pcdev->soc_host.v4l2_dev.dev,
344 340 "dmaengine_prep_slave_sg failed\n");
345 sglen = calculate_dma_sglen(*sg_first, dma->sglen, 341 goto fail;
346 *sg_first_ofs, size);
347
348 pxa_dma->sg_size = (sglen + 1) * sizeof(struct pxa_dma_desc);
349 pxa_dma->sg_cpu = dma_alloc_coherent(dev, pxa_dma->sg_size,
350 &pxa_dma->sg_dma, GFP_KERNEL);
351 if (!pxa_dma->sg_cpu)
352 return -ENOMEM;
353
354 pxa_dma->sglen = sglen;
355 offset = *sg_first_ofs;
356
357 dev_dbg(dev, "DMA: sg_first=%p, sglen=%d, ofs=%d, dma.desc=%x\n",
358 *sg_first, sglen, *sg_first_ofs, pxa_dma->sg_dma);
359
360
361 for_each_sg(*sg_first, sg, sglen, i) {
362 dma_len = sg_dma_len(sg);
363
364 /* PXA27x Developer's Manual 27.4.4.1: round up to 8 bytes */
365 xfer_len = roundup(min(dma_len - offset, size), 8);
366
367 size = max(0, size - xfer_len);
368
369 pxa_dma->sg_cpu[i].dsadr = pcdev->res->start + cibr;
370 pxa_dma->sg_cpu[i].dtadr = sg_dma_address(sg) + offset;
371 pxa_dma->sg_cpu[i].dcmd =
372 DCMD_FLOWSRC | DCMD_BURST8 | DCMD_INCTRGADDR | xfer_len;
373#ifdef DEBUG
374 if (!i)
375 pxa_dma->sg_cpu[i].dcmd |= DCMD_STARTIRQEN;
376#endif
377 pxa_dma->sg_cpu[i].ddadr =
378 pxa_dma->sg_dma + (i + 1) * sizeof(struct pxa_dma_desc);
379
380 dev_vdbg(dev, "DMA: desc.%08x->@phys=0x%08x, len=%d\n",
381 pxa_dma->sg_dma + i * sizeof(struct pxa_dma_desc),
382 sg_dma_address(sg) + offset, xfer_len);
383 offset = 0;
384
385 if (size == 0)
386 break;
387 } 342 }
388 343
389 pxa_dma->sg_cpu[sglen].ddadr = DDADR_STOP; 344 tx->callback_param = pcdev;
390 pxa_dma->sg_cpu[sglen].dcmd = DCMD_FLOWSRC | DCMD_BURST8 | DCMD_ENDIRQEN; 345 switch (channel) {
391 346 case 0:
392 /* 347 tx->callback = pxa_camera_dma_irq_y;
393 * Handle 1 special case : 348 break;
394 * - in 3 planes (YUV422P format), we might finish with xfer_len equal 349 case 1:
395 * to dma_len (end on PAGE boundary). In this case, the sg element 350 tx->callback = pxa_camera_dma_irq_u;
396 * for next plane should be the next after the last used to store the 351 break;
397 * last scatter gather RAM page 352 case 2:
398 */ 353 tx->callback = pxa_camera_dma_irq_v;
399 if (xfer_len >= dma_len) { 354 break;
400 *sg_first_ofs = xfer_len - dma_len;
401 *sg_first = sg_next(sg);
402 } else {
403 *sg_first_ofs = xfer_len;
404 *sg_first = sg;
405 } 355 }
406 356
357 buf->descs[channel] = tx;
407 return 0; 358 return 0;
359fail:
360 kfree(sg);
361
362 dev_dbg(pcdev->soc_host.v4l2_dev.dev,
363 "%s (vb=0x%p) dma_tx=%p\n",
364 __func__, &buf->vb, tx);
365
366 return -ENOMEM;
408} 367}
409 368
410static void pxa_videobuf_set_actdma(struct pxa_camera_dev *pcdev, 369static void pxa_videobuf_set_actdma(struct pxa_camera_dev *pcdev,
@@ -431,6 +390,7 @@ static int pxa_videobuf_prepare(struct videobuf_queue *vq,
431 struct pxa_buffer *buf = container_of(vb, struct pxa_buffer, vb); 390 struct pxa_buffer *buf = container_of(vb, struct pxa_buffer, vb);
432 int ret; 391 int ret;
433 int size_y, size_u = 0, size_v = 0; 392 int size_y, size_u = 0, size_v = 0;
393 size_t sizes[3];
434 394
435 dev_dbg(dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, 395 dev_dbg(dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
436 vb, vb->baddr, vb->bsize); 396 vb, vb->baddr, vb->bsize);
@@ -473,13 +433,11 @@ static int pxa_videobuf_prepare(struct videobuf_queue *vq,
473 433
474 if (vb->state == VIDEOBUF_NEEDS_INIT) { 434 if (vb->state == VIDEOBUF_NEEDS_INIT) {
475 int size = vb->size; 435 int size = vb->size;
476 int next_ofs = 0;
477 struct videobuf_dmabuf *dma = videobuf_to_dma(vb); 436 struct videobuf_dmabuf *dma = videobuf_to_dma(vb);
478 struct scatterlist *sg;
479 437
480 ret = videobuf_iolock(vq, vb, NULL); 438 ret = videobuf_iolock(vq, vb, NULL);
481 if (ret) 439 if (ret)
482 goto fail; 440 goto out;
483 441
484 if (pcdev->channels == 3) { 442 if (pcdev->channels == 3) {
485 size_y = size / 2; 443 size_y = size / 2;
@@ -488,11 +446,19 @@ static int pxa_videobuf_prepare(struct videobuf_queue *vq,
488 size_y = size; 446 size_y = size;
489 } 447 }
490 448
491 sg = dma->sglist; 449 sizes[0] = size_y;
450 sizes[1] = size_u;
451 sizes[2] = size_v;
452 ret = sg_split(dma->sglist, dma->sglen, 0, pcdev->channels,
453 sizes, buf->sg, buf->sg_len, GFP_KERNEL);
454 if (ret < 0) {
455 dev_err(dev, "sg_split failed: %d\n", ret);
456 goto fail;
457 }
492 458
493 /* init DMA for Y channel */ 459 /* init DMA for Y channel */
494 ret = pxa_init_dma_channel(pcdev, buf, dma, 0, CIBR0, size_y, 460 ret = pxa_init_dma_channel(pcdev, buf, dma, 0, CIBR0,
495 &sg, &next_ofs); 461 size_y, 0);
496 if (ret) { 462 if (ret) {
497 dev_err(dev, "DMA initialization for Y/RGB failed\n"); 463 dev_err(dev, "DMA initialization for Y/RGB failed\n");
498 goto fail; 464 goto fail;
@@ -501,19 +467,19 @@ static int pxa_videobuf_prepare(struct videobuf_queue *vq,
501 /* init DMA for U channel */ 467 /* init DMA for U channel */
502 if (size_u) 468 if (size_u)
503 ret = pxa_init_dma_channel(pcdev, buf, dma, 1, CIBR1, 469 ret = pxa_init_dma_channel(pcdev, buf, dma, 1, CIBR1,
504 size_u, &sg, &next_ofs); 470 size_u, size_y);
505 if (ret) { 471 if (ret) {
506 dev_err(dev, "DMA initialization for U failed\n"); 472 dev_err(dev, "DMA initialization for U failed\n");
507 goto fail_u; 473 goto fail;
508 } 474 }
509 475
510 /* init DMA for V channel */ 476 /* init DMA for V channel */
511 if (size_v) 477 if (size_v)
512 ret = pxa_init_dma_channel(pcdev, buf, dma, 2, CIBR2, 478 ret = pxa_init_dma_channel(pcdev, buf, dma, 2, CIBR2,
513 size_v, &sg, &next_ofs); 479 size_v, size_y + size_u);
514 if (ret) { 480 if (ret) {
515 dev_err(dev, "DMA initialization for V failed\n"); 481 dev_err(dev, "DMA initialization for V failed\n");
516 goto fail_v; 482 goto fail;
517 } 483 }
518 484
519 vb->state = VIDEOBUF_PREPARED; 485 vb->state = VIDEOBUF_PREPARED;
@@ -524,12 +490,6 @@ static int pxa_videobuf_prepare(struct videobuf_queue *vq,
524 490
525 return 0; 491 return 0;
526 492
527fail_v:
528 dma_free_coherent(dev, buf->dmas[1].sg_size,
529 buf->dmas[1].sg_cpu, buf->dmas[1].sg_dma);
530fail_u:
531 dma_free_coherent(dev, buf->dmas[0].sg_size,
532 buf->dmas[0].sg_cpu, buf->dmas[0].sg_dma);
533fail: 493fail:
534 free_buffer(vq, buf); 494 free_buffer(vq, buf);
535out: 495out:
@@ -553,10 +513,8 @@ static void pxa_dma_start_channels(struct pxa_camera_dev *pcdev)
553 513
554 for (i = 0; i < pcdev->channels; i++) { 514 for (i = 0; i < pcdev->channels; i++) {
555 dev_dbg(pcdev->soc_host.v4l2_dev.dev, 515 dev_dbg(pcdev->soc_host.v4l2_dev.dev,
556 "%s (channel=%d) ddadr=%08x\n", __func__, 516 "%s (channel=%d)\n", __func__, i);
557 i, active->dmas[i].sg_dma); 517 dma_async_issue_pending(pcdev->dma_chans[i]);
558 DDADR(pcdev->dma_chans[i]) = active->dmas[i].sg_dma;
559 DCSR(pcdev->dma_chans[i]) = DCSR_RUN;
560 } 518 }
561} 519}
562 520
@@ -567,7 +525,7 @@ static void pxa_dma_stop_channels(struct pxa_camera_dev *pcdev)
567 for (i = 0; i < pcdev->channels; i++) { 525 for (i = 0; i < pcdev->channels; i++) {
568 dev_dbg(pcdev->soc_host.v4l2_dev.dev, 526 dev_dbg(pcdev->soc_host.v4l2_dev.dev,
569 "%s (channel=%d)\n", __func__, i); 527 "%s (channel=%d)\n", __func__, i);
570 DCSR(pcdev->dma_chans[i]) = 0; 528 dmaengine_terminate_all(pcdev->dma_chans[i]);
571 } 529 }
572} 530}
573 531
@@ -575,18 +533,12 @@ static void pxa_dma_add_tail_buf(struct pxa_camera_dev *pcdev,
575 struct pxa_buffer *buf) 533 struct pxa_buffer *buf)
576{ 534{
577 int i; 535 int i;
578 struct pxa_dma_desc *buf_last_desc;
579 536
580 for (i = 0; i < pcdev->channels; i++) { 537 for (i = 0; i < pcdev->channels; i++) {
581 buf_last_desc = buf->dmas[i].sg_cpu + buf->dmas[i].sglen; 538 buf->cookie[i] = dmaengine_submit(buf->descs[i]);
582 buf_last_desc->ddadr = DDADR_STOP; 539 dev_dbg(pcdev->soc_host.v4l2_dev.dev,
583 540 "%s (channel=%d) : submit vb=%p cookie=%d\n",
584 if (pcdev->sg_tail[i]) 541 __func__, i, buf, buf->descs[i]->cookie);
585 /* Link the new buffer to the old tail */
586 pcdev->sg_tail[i]->ddadr = buf->dmas[i].sg_dma;
587
588 /* Update the channel tail */
589 pcdev->sg_tail[i] = buf_last_desc;
590 } 542 }
591} 543}
592 544
@@ -603,6 +555,7 @@ static void pxa_camera_start_capture(struct pxa_camera_dev *pcdev)
603 unsigned long cicr0; 555 unsigned long cicr0;
604 556
605 dev_dbg(pcdev->soc_host.v4l2_dev.dev, "%s\n", __func__); 557 dev_dbg(pcdev->soc_host.v4l2_dev.dev, "%s\n", __func__);
558 __raw_writel(__raw_readl(pcdev->base + CISR), pcdev->base + CISR);
606 /* Enable End-Of-Frame Interrupt */ 559 /* Enable End-Of-Frame Interrupt */
607 cicr0 = __raw_readl(pcdev->base + CICR0) | CICR0_ENB; 560 cicr0 = __raw_readl(pcdev->base + CICR0) | CICR0_ENB;
608 cicr0 &= ~CICR0_EOFM; 561 cicr0 &= ~CICR0_EOFM;
@@ -677,8 +630,6 @@ static void pxa_camera_wakeup(struct pxa_camera_dev *pcdev,
677 struct videobuf_buffer *vb, 630 struct videobuf_buffer *vb,
678 struct pxa_buffer *buf) 631 struct pxa_buffer *buf)
679{ 632{
680 int i;
681
682 /* _init is used to debug races, see comment in pxa_camera_reqbufs() */ 633 /* _init is used to debug races, see comment in pxa_camera_reqbufs() */
683 list_del_init(&vb->queue); 634 list_del_init(&vb->queue);
684 vb->state = VIDEOBUF_DONE; 635 vb->state = VIDEOBUF_DONE;
@@ -690,8 +641,6 @@ static void pxa_camera_wakeup(struct pxa_camera_dev *pcdev,
690 641
691 if (list_empty(&pcdev->capture)) { 642 if (list_empty(&pcdev->capture)) {
692 pxa_camera_stop_capture(pcdev); 643 pxa_camera_stop_capture(pcdev);
693 for (i = 0; i < pcdev->channels; i++)
694 pcdev->sg_tail[i] = NULL;
695 return; 644 return;
696 } 645 }
697 646
@@ -715,50 +664,41 @@ static void pxa_camera_wakeup(struct pxa_camera_dev *pcdev,
715 * 664 *
716 * Context: should only be called within the dma irq handler 665 * Context: should only be called within the dma irq handler
717 */ 666 */
718static void pxa_camera_check_link_miss(struct pxa_camera_dev *pcdev) 667static void pxa_camera_check_link_miss(struct pxa_camera_dev *pcdev,
668 dma_cookie_t last_submitted,
669 dma_cookie_t last_issued)
719{ 670{
720 int i, is_dma_stopped = 1; 671 bool is_dma_stopped = last_submitted != last_issued;
721 672
722 for (i = 0; i < pcdev->channels; i++)
723 if (DDADR(pcdev->dma_chans[i]) != DDADR_STOP)
724 is_dma_stopped = 0;
725 dev_dbg(pcdev->soc_host.v4l2_dev.dev, 673 dev_dbg(pcdev->soc_host.v4l2_dev.dev,
726 "%s : top queued buffer=%p, dma_stopped=%d\n", 674 "%s : top queued buffer=%p, is_dma_stopped=%d\n",
727 __func__, pcdev->active, is_dma_stopped); 675 __func__, pcdev->active, is_dma_stopped);
676
728 if (pcdev->active && is_dma_stopped) 677 if (pcdev->active && is_dma_stopped)
729 pxa_camera_start_capture(pcdev); 678 pxa_camera_start_capture(pcdev);
730} 679}
731 680
732static void pxa_camera_dma_irq(int channel, struct pxa_camera_dev *pcdev, 681static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
733 enum pxa_camera_active_dma act_dma) 682 enum pxa_camera_active_dma act_dma)
734{ 683{
735 struct device *dev = pcdev->soc_host.v4l2_dev.dev; 684 struct device *dev = pcdev->soc_host.v4l2_dev.dev;
736 struct pxa_buffer *buf; 685 struct pxa_buffer *buf, *last_buf;
737 unsigned long flags; 686 unsigned long flags;
738 u32 status, camera_status, overrun; 687 u32 camera_status, overrun;
688 int chan;
739 struct videobuf_buffer *vb; 689 struct videobuf_buffer *vb;
690 enum dma_status last_status;
691 dma_cookie_t last_issued;
740 692
741 spin_lock_irqsave(&pcdev->lock, flags); 693 spin_lock_irqsave(&pcdev->lock, flags);
742 694
743 status = DCSR(channel);
744 DCSR(channel) = status;
745
746 camera_status = __raw_readl(pcdev->base + CISR); 695 camera_status = __raw_readl(pcdev->base + CISR);
696 dev_dbg(dev, "camera dma irq, cisr=0x%x dma=%d\n",
697 camera_status, act_dma);
747 overrun = CISR_IFO_0; 698 overrun = CISR_IFO_0;
748 if (pcdev->channels == 3) 699 if (pcdev->channels == 3)
749 overrun |= CISR_IFO_1 | CISR_IFO_2; 700 overrun |= CISR_IFO_1 | CISR_IFO_2;
750 701
751 if (status & DCSR_BUSERR) {
752 dev_err(dev, "DMA Bus Error IRQ!\n");
753 goto out;
754 }
755
756 if (!(status & (DCSR_ENDINTR | DCSR_STARTINTR))) {
757 dev_err(dev, "Unknown DMA IRQ source, status: 0x%08x\n",
758 status);
759 goto out;
760 }
761
762 /* 702 /*
763 * pcdev->active should not be NULL in DMA irq handler. 703 * pcdev->active should not be NULL in DMA irq handler.
764 * 704 *
@@ -778,52 +718,47 @@ static void pxa_camera_dma_irq(int channel, struct pxa_camera_dev *pcdev,
778 buf = container_of(vb, struct pxa_buffer, vb); 718 buf = container_of(vb, struct pxa_buffer, vb);
779 WARN_ON(buf->inwork || list_empty(&vb->queue)); 719 WARN_ON(buf->inwork || list_empty(&vb->queue));
780 720
781 dev_dbg(dev, "%s channel=%d %s%s(vb=0x%p) dma.desc=%x\n", 721 /*
782 __func__, channel, status & DCSR_STARTINTR ? "SOF " : "", 722 * It's normal if the last frame creates an overrun, as there
783 status & DCSR_ENDINTR ? "EOF " : "", vb, DDADR(channel)); 723 * are no more DMA descriptors to fetch from QCI fifos
784 724 */
785 if (status & DCSR_ENDINTR) { 725 switch (act_dma) {
786 /* 726 case DMA_U:
787 * It's normal if the last frame creates an overrun, as there 727 chan = 1;
788 * are no more DMA descriptors to fetch from QCI fifos 728 break;
789 */ 729 case DMA_V:
790 if (camera_status & overrun && 730 chan = 2;
791 !list_is_last(pcdev->capture.next, &pcdev->capture)) { 731 break;
792 dev_dbg(dev, "FIFO overrun! CISR: %x\n", 732 default:
793 camera_status); 733 chan = 0;
794 pxa_camera_stop_capture(pcdev); 734 break;
795 pxa_camera_start_capture(pcdev); 735 }
796 goto out; 736 last_buf = list_entry(pcdev->capture.prev,
797 } 737 struct pxa_buffer, vb.queue);
798 buf->active_dma &= ~act_dma; 738 last_status = dma_async_is_tx_complete(pcdev->dma_chans[chan],
799 if (!buf->active_dma) { 739 last_buf->cookie[chan],
800 pxa_camera_wakeup(pcdev, vb, buf); 740 NULL, &last_issued);
801 pxa_camera_check_link_miss(pcdev); 741 if (camera_status & overrun &&
802 } 742 last_status != DMA_COMPLETE) {
743 dev_dbg(dev, "FIFO overrun! CISR: %x\n",
744 camera_status);
745 pxa_camera_stop_capture(pcdev);
746 list_for_each_entry(buf, &pcdev->capture, vb.queue)
747 pxa_dma_add_tail_buf(pcdev, buf);
748 pxa_camera_start_capture(pcdev);
749 goto out;
750 }
751 buf->active_dma &= ~act_dma;
752 if (!buf->active_dma) {
753 pxa_camera_wakeup(pcdev, vb, buf);
754 pxa_camera_check_link_miss(pcdev, last_buf->cookie[chan],
755 last_issued);
803 } 756 }
804 757
805out: 758out:
806 spin_unlock_irqrestore(&pcdev->lock, flags); 759 spin_unlock_irqrestore(&pcdev->lock, flags);
807} 760}
808 761
809static void pxa_camera_dma_irq_y(int channel, void *data)
810{
811 struct pxa_camera_dev *pcdev = data;
812 pxa_camera_dma_irq(channel, pcdev, DMA_Y);
813}
814
815static void pxa_camera_dma_irq_u(int channel, void *data)
816{
817 struct pxa_camera_dev *pcdev = data;
818 pxa_camera_dma_irq(channel, pcdev, DMA_U);
819}
820
821static void pxa_camera_dma_irq_v(int channel, void *data)
822{
823 struct pxa_camera_dev *pcdev = data;
824 pxa_camera_dma_irq(channel, pcdev, DMA_V);
825}
826
827static struct videobuf_queue_ops pxa_videobuf_ops = { 762static struct videobuf_queue_ops pxa_videobuf_ops = {
828 .buf_setup = pxa_videobuf_setup, 763 .buf_setup = pxa_videobuf_setup,
829 .buf_prepare = pxa_videobuf_prepare, 764 .buf_prepare = pxa_videobuf_prepare,
@@ -920,13 +855,35 @@ static void pxa_camera_deactivate(struct pxa_camera_dev *pcdev)
920 clk_disable_unprepare(pcdev->clk); 855 clk_disable_unprepare(pcdev->clk);
921} 856}
922 857
923static irqreturn_t pxa_camera_irq(int irq, void *data) 858static void pxa_camera_eof(unsigned long arg)
924{ 859{
925 struct pxa_camera_dev *pcdev = data; 860 struct pxa_camera_dev *pcdev = (struct pxa_camera_dev *)arg;
926 unsigned long status, cifr, cicr0; 861 unsigned long cifr;
927 struct pxa_buffer *buf; 862 struct pxa_buffer *buf;
928 struct videobuf_buffer *vb; 863 struct videobuf_buffer *vb;
929 864
865 dev_dbg(pcdev->soc_host.v4l2_dev.dev,
866 "Camera interrupt status 0x%x\n",
867 __raw_readl(pcdev->base + CISR));
868
869 /* Reset the FIFOs */
870 cifr = __raw_readl(pcdev->base + CIFR) | CIFR_RESET_F;
871 __raw_writel(cifr, pcdev->base + CIFR);
872
873 pcdev->active = list_first_entry(&pcdev->capture,
874 struct pxa_buffer, vb.queue);
875 vb = &pcdev->active->vb;
876 buf = container_of(vb, struct pxa_buffer, vb);
877 pxa_videobuf_set_actdma(pcdev, buf);
878
879 pxa_dma_start_channels(pcdev);
880}
881
882static irqreturn_t pxa_camera_irq(int irq, void *data)
883{
884 struct pxa_camera_dev *pcdev = data;
885 unsigned long status, cicr0;
886
930 status = __raw_readl(pcdev->base + CISR); 887 status = __raw_readl(pcdev->base + CISR);
931 dev_dbg(pcdev->soc_host.v4l2_dev.dev, 888 dev_dbg(pcdev->soc_host.v4l2_dev.dev,
932 "Camera interrupt status 0x%lx\n", status); 889 "Camera interrupt status 0x%lx\n", status);
@@ -937,20 +894,9 @@ static irqreturn_t pxa_camera_irq(int irq, void *data)
937 __raw_writel(status, pcdev->base + CISR); 894 __raw_writel(status, pcdev->base + CISR);
938 895
939 if (status & CISR_EOF) { 896 if (status & CISR_EOF) {
940 /* Reset the FIFOs */
941 cifr = __raw_readl(pcdev->base + CIFR) | CIFR_RESET_F;
942 __raw_writel(cifr, pcdev->base + CIFR);
943
944 pcdev->active = list_first_entry(&pcdev->capture,
945 struct pxa_buffer, vb.queue);
946 vb = &pcdev->active->vb;
947 buf = container_of(vb, struct pxa_buffer, vb);
948 pxa_videobuf_set_actdma(pcdev, buf);
949
950 pxa_dma_start_channels(pcdev);
951
952 cicr0 = __raw_readl(pcdev->base + CICR0) | CICR0_EOFM; 897 cicr0 = __raw_readl(pcdev->base + CICR0) | CICR0_EOFM;
953 __raw_writel(cicr0, pcdev->base + CICR0); 898 __raw_writel(cicr0, pcdev->base + CICR0);
899 tasklet_schedule(&pcdev->task_eof);
954 } 900 }
955 901
956 return IRQ_HANDLED; 902 return IRQ_HANDLED;
@@ -993,10 +939,7 @@ static void pxa_camera_clock_stop(struct soc_camera_host *ici)
993 __raw_writel(0x3ff, pcdev->base + CICR0); 939 __raw_writel(0x3ff, pcdev->base + CICR0);
994 940
995 /* Stop DMA engine */ 941 /* Stop DMA engine */
996 DCSR(pcdev->dma_chans[0]) = 0; 942 pxa_dma_stop_channels(pcdev);
997 DCSR(pcdev->dma_chans[1]) = 0;
998 DCSR(pcdev->dma_chans[2]) = 0;
999
1000 pxa_camera_deactivate(pcdev); 943 pxa_camera_deactivate(pcdev);
1001} 944}
1002 945
@@ -1623,10 +1566,6 @@ static int pxa_camera_resume(struct device *dev)
1623 struct pxa_camera_dev *pcdev = ici->priv; 1566 struct pxa_camera_dev *pcdev = ici->priv;
1624 int i = 0, ret = 0; 1567 int i = 0, ret = 0;
1625 1568
1626 DRCMR(68) = pcdev->dma_chans[0] | DRCMR_MAPVLD;
1627 DRCMR(69) = pcdev->dma_chans[1] | DRCMR_MAPVLD;
1628 DRCMR(70) = pcdev->dma_chans[2] | DRCMR_MAPVLD;
1629
1630 __raw_writel(pcdev->save_cicr[i++] & ~CICR0_ENB, pcdev->base + CICR0); 1569 __raw_writel(pcdev->save_cicr[i++] & ~CICR0_ENB, pcdev->base + CICR0);
1631 __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR1); 1570 __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR1);
1632 __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR2); 1571 __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR2);
@@ -1732,8 +1671,15 @@ static int pxa_camera_probe(struct platform_device *pdev)
1732 struct pxa_camera_dev *pcdev; 1671 struct pxa_camera_dev *pcdev;
1733 struct resource *res; 1672 struct resource *res;
1734 void __iomem *base; 1673 void __iomem *base;
1674 struct dma_slave_config config = {
1675 .src_addr_width = 0,
1676 .src_maxburst = 8,
1677 .direction = DMA_DEV_TO_MEM,
1678 };
1679 dma_cap_mask_t mask;
1680 struct pxad_param params;
1735 int irq; 1681 int irq;
1736 int err = 0; 1682 int err = 0, i;
1737 1683
1738 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1684 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1739 irq = platform_get_irq(pdev, 0); 1685 irq = platform_get_irq(pdev, 0);
@@ -1801,36 +1747,47 @@ static int pxa_camera_probe(struct platform_device *pdev)
1801 pcdev->base = base; 1747 pcdev->base = base;
1802 1748
1803 /* request dma */ 1749 /* request dma */
1804 err = pxa_request_dma("CI_Y", DMA_PRIO_HIGH, 1750 dma_cap_zero(mask);
1805 pxa_camera_dma_irq_y, pcdev); 1751 dma_cap_set(DMA_SLAVE, mask);
1806 if (err < 0) { 1752 dma_cap_set(DMA_PRIVATE, mask);
1753
1754 params.prio = 0;
1755 params.drcmr = 68;
1756 pcdev->dma_chans[0] =
1757 dma_request_slave_channel_compat(mask, pxad_filter_fn,
1758 &params, &pdev->dev, "CI_Y");
1759 if (!pcdev->dma_chans[0]) {
1807 dev_err(&pdev->dev, "Can't request DMA for Y\n"); 1760 dev_err(&pdev->dev, "Can't request DMA for Y\n");
1808 return err; 1761 return -ENODEV;
1809 } 1762 }
1810 pcdev->dma_chans[0] = err;
1811 dev_dbg(&pdev->dev, "got DMA channel %d\n", pcdev->dma_chans[0]);
1812 1763
1813 err = pxa_request_dma("CI_U", DMA_PRIO_HIGH, 1764 params.drcmr = 69;
1814 pxa_camera_dma_irq_u, pcdev); 1765 pcdev->dma_chans[1] =
1815 if (err < 0) { 1766 dma_request_slave_channel_compat(mask, pxad_filter_fn,
1816 dev_err(&pdev->dev, "Can't request DMA for U\n"); 1767 &params, &pdev->dev, "CI_U");
1768 if (!pcdev->dma_chans[1]) {
1769 dev_err(&pdev->dev, "Can't request DMA for Y\n");
1817 goto exit_free_dma_y; 1770 goto exit_free_dma_y;
1818 } 1771 }
1819 pcdev->dma_chans[1] = err;
1820 dev_dbg(&pdev->dev, "got DMA channel (U) %d\n", pcdev->dma_chans[1]);
1821 1772
1822 err = pxa_request_dma("CI_V", DMA_PRIO_HIGH, 1773 params.drcmr = 70;
1823 pxa_camera_dma_irq_v, pcdev); 1774 pcdev->dma_chans[2] =
1824 if (err < 0) { 1775 dma_request_slave_channel_compat(mask, pxad_filter_fn,
1776 &params, &pdev->dev, "CI_V");
1777 if (!pcdev->dma_chans[2]) {
1825 dev_err(&pdev->dev, "Can't request DMA for V\n"); 1778 dev_err(&pdev->dev, "Can't request DMA for V\n");
1826 goto exit_free_dma_u; 1779 goto exit_free_dma_u;
1827 } 1780 }
1828 pcdev->dma_chans[2] = err;
1829 dev_dbg(&pdev->dev, "got DMA channel (V) %d\n", pcdev->dma_chans[2]);
1830 1781
1831 DRCMR(68) = pcdev->dma_chans[0] | DRCMR_MAPVLD; 1782 for (i = 0; i < 3; i++) {
1832 DRCMR(69) = pcdev->dma_chans[1] | DRCMR_MAPVLD; 1783 config.src_addr = pcdev->res->start + CIBR0 + i * 8;
1833 DRCMR(70) = pcdev->dma_chans[2] | DRCMR_MAPVLD; 1784 err = dmaengine_slave_config(pcdev->dma_chans[i], &config);
1785 if (err < 0) {
1786 dev_err(&pdev->dev, "dma slave config failed: %d\n",
1787 err);
1788 goto exit_free_dma;
1789 }
1790 }
1834 1791
1835 /* request irq */ 1792 /* request irq */
1836 err = devm_request_irq(&pdev->dev, pcdev->irq, pxa_camera_irq, 0, 1793 err = devm_request_irq(&pdev->dev, pcdev->irq, pxa_camera_irq, 0,
@@ -1845,6 +1802,7 @@ static int pxa_camera_probe(struct platform_device *pdev)
1845 pcdev->soc_host.priv = pcdev; 1802 pcdev->soc_host.priv = pcdev;
1846 pcdev->soc_host.v4l2_dev.dev = &pdev->dev; 1803 pcdev->soc_host.v4l2_dev.dev = &pdev->dev;
1847 pcdev->soc_host.nr = pdev->id; 1804 pcdev->soc_host.nr = pdev->id;
1805 tasklet_init(&pcdev->task_eof, pxa_camera_eof, (unsigned long)pcdev);
1848 1806
1849 err = soc_camera_host_register(&pcdev->soc_host); 1807 err = soc_camera_host_register(&pcdev->soc_host);
1850 if (err) 1808 if (err)
@@ -1853,11 +1811,11 @@ static int pxa_camera_probe(struct platform_device *pdev)
1853 return 0; 1811 return 0;
1854 1812
1855exit_free_dma: 1813exit_free_dma:
1856 pxa_free_dma(pcdev->dma_chans[2]); 1814 dma_release_channel(pcdev->dma_chans[2]);
1857exit_free_dma_u: 1815exit_free_dma_u:
1858 pxa_free_dma(pcdev->dma_chans[1]); 1816 dma_release_channel(pcdev->dma_chans[1]);
1859exit_free_dma_y: 1817exit_free_dma_y:
1860 pxa_free_dma(pcdev->dma_chans[0]); 1818 dma_release_channel(pcdev->dma_chans[0]);
1861 return err; 1819 return err;
1862} 1820}
1863 1821
@@ -1867,9 +1825,9 @@ static int pxa_camera_remove(struct platform_device *pdev)
1867 struct pxa_camera_dev *pcdev = container_of(soc_host, 1825 struct pxa_camera_dev *pcdev = container_of(soc_host,
1868 struct pxa_camera_dev, soc_host); 1826 struct pxa_camera_dev, soc_host);
1869 1827
1870 pxa_free_dma(pcdev->dma_chans[0]); 1828 dma_release_channel(pcdev->dma_chans[0]);
1871 pxa_free_dma(pcdev->dma_chans[1]); 1829 dma_release_channel(pcdev->dma_chans[1]);
1872 pxa_free_dma(pcdev->dma_chans[2]); 1830 dma_release_channel(pcdev->dma_chans[2]);
1873 1831
1874 soc_camera_host_unregister(soc_host); 1832 soc_camera_host_unregister(soc_host);
1875 1833
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index b7fd695b9ed5..3b8edf458964 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -124,7 +124,7 @@
124#define VNDMR_EXRGB (1 << 8) 124#define VNDMR_EXRGB (1 << 8)
125#define VNDMR_BPSM (1 << 4) 125#define VNDMR_BPSM (1 << 4)
126#define VNDMR_DTMD_YCSEP (1 << 1) 126#define VNDMR_DTMD_YCSEP (1 << 1)
127#define VNDMR_DTMD_ARGB1555 (1 << 0) 127#define VNDMR_DTMD_ARGB (1 << 0)
128 128
129/* Video n Data Mode Register 2 bits */ 129/* Video n Data Mode Register 2 bits */
130#define VNDMR2_VPS (1 << 30) 130#define VNDMR2_VPS (1 << 30)
@@ -143,6 +143,7 @@
143#define RCAR_VIN_BT656 (1 << 3) 143#define RCAR_VIN_BT656 (1 << 3)
144 144
145enum chip_id { 145enum chip_id {
146 RCAR_GEN3,
146 RCAR_GEN2, 147 RCAR_GEN2,
147 RCAR_H1, 148 RCAR_H1,
148 RCAR_M1, 149 RCAR_M1,
@@ -642,21 +643,26 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
642 output_is_yuv = true; 643 output_is_yuv = true;
643 break; 644 break;
644 case V4L2_PIX_FMT_RGB555X: 645 case V4L2_PIX_FMT_RGB555X:
645 dmr = VNDMR_DTMD_ARGB1555; 646 dmr = VNDMR_DTMD_ARGB;
646 break; 647 break;
647 case V4L2_PIX_FMT_RGB565: 648 case V4L2_PIX_FMT_RGB565:
648 dmr = 0; 649 dmr = 0;
649 break; 650 break;
650 case V4L2_PIX_FMT_RGB32: 651 case V4L2_PIX_FMT_RGB32:
651 if (priv->chip == RCAR_GEN2 || priv->chip == RCAR_H1 || 652 if (priv->chip != RCAR_GEN2 && priv->chip != RCAR_H1 &&
652 priv->chip == RCAR_E1) { 653 priv->chip != RCAR_E1)
653 dmr = VNDMR_EXRGB; 654 goto e_format;
654 break; 655
655 } 656 dmr = VNDMR_EXRGB;
657 break;
658 case V4L2_PIX_FMT_ARGB32:
659 if (priv->chip != RCAR_GEN3)
660 goto e_format;
661
662 dmr = VNDMR_EXRGB | VNDMR_DTMD_ARGB;
663 break;
656 default: 664 default:
657 dev_warn(icd->parent, "Invalid fourcc format (0x%x)\n", 665 goto e_format;
658 icd->current_fmt->host_fmt->fourcc);
659 return -EINVAL;
660 } 666 }
661 667
662 /* Always update on field change */ 668 /* Always update on field change */
@@ -678,6 +684,11 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
678 iowrite32(vnmc | VNMC_ME, priv->base + VNMC_REG); 684 iowrite32(vnmc | VNMC_ME, priv->base + VNMC_REG);
679 685
680 return 0; 686 return 0;
687
688e_format:
689 dev_warn(icd->parent, "Invalid fourcc format (0x%x)\n",
690 icd->current_fmt->host_fmt->fourcc);
691 return -EINVAL;
681} 692}
682 693
683static void rcar_vin_capture(struct rcar_vin_priv *priv) 694static void rcar_vin_capture(struct rcar_vin_priv *priv)
@@ -1303,6 +1314,14 @@ static const struct soc_mbus_pixelfmt rcar_vin_formats[] = {
1303 .order = SOC_MBUS_ORDER_LE, 1314 .order = SOC_MBUS_ORDER_LE,
1304 .layout = SOC_MBUS_LAYOUT_PACKED, 1315 .layout = SOC_MBUS_LAYOUT_PACKED,
1305 }, 1316 },
1317 {
1318 .fourcc = V4L2_PIX_FMT_ARGB32,
1319 .name = "ARGB8888",
1320 .bits_per_sample = 32,
1321 .packing = SOC_MBUS_PACKING_NONE,
1322 .order = SOC_MBUS_ORDER_LE,
1323 .layout = SOC_MBUS_LAYOUT_PACKED,
1324 },
1306}; 1325};
1307 1326
1308static int rcar_vin_get_formats(struct soc_camera_device *icd, unsigned int idx, 1327static int rcar_vin_get_formats(struct soc_camera_device *icd, unsigned int idx,
@@ -1610,6 +1629,7 @@ static int rcar_vin_set_fmt(struct soc_camera_device *icd,
1610 case V4L2_PIX_FMT_RGB32: 1629 case V4L2_PIX_FMT_RGB32:
1611 can_scale = priv->chip != RCAR_E1; 1630 can_scale = priv->chip != RCAR_E1;
1612 break; 1631 break;
1632 case V4L2_PIX_FMT_ARGB32:
1613 case V4L2_PIX_FMT_UYVY: 1633 case V4L2_PIX_FMT_UYVY:
1614 case V4L2_PIX_FMT_YUYV: 1634 case V4L2_PIX_FMT_YUYV:
1615 case V4L2_PIX_FMT_RGB565: 1635 case V4L2_PIX_FMT_RGB565:
@@ -1818,6 +1838,7 @@ static struct soc_camera_host_ops rcar_vin_host_ops = {
1818 1838
1819#ifdef CONFIG_OF 1839#ifdef CONFIG_OF
1820static const struct of_device_id rcar_vin_of_table[] = { 1840static const struct of_device_id rcar_vin_of_table[] = {
1841 { .compatible = "renesas,vin-r8a7795", .data = (void *)RCAR_GEN3 },
1821 { .compatible = "renesas,vin-r8a7794", .data = (void *)RCAR_GEN2 }, 1842 { .compatible = "renesas,vin-r8a7794", .data = (void *)RCAR_GEN2 },
1822 { .compatible = "renesas,vin-r8a7793", .data = (void *)RCAR_GEN2 }, 1843 { .compatible = "renesas,vin-r8a7793", .data = (void *)RCAR_GEN2 },
1823 { .compatible = "renesas,vin-r8a7791", .data = (void *)RCAR_GEN2 }, 1844 { .compatible = "renesas,vin-r8a7791", .data = (void *)RCAR_GEN2 },
diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
index 90c87f2b4ec0..b9f369c0fb94 100644
--- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
+++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
@@ -213,8 +213,7 @@ static int sh_mobile_ceu_videobuf_setup(struct vb2_queue *vq,
213 unsigned int *count, unsigned int *num_planes, 213 unsigned int *count, unsigned int *num_planes,
214 unsigned int sizes[], void *alloc_ctxs[]) 214 unsigned int sizes[], void *alloc_ctxs[])
215{ 215{
216 struct soc_camera_device *icd = container_of(vq, 216 struct soc_camera_device *icd = soc_camera_from_vb2q(vq);
217 struct soc_camera_device, vb2_vidq);
218 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); 217 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
219 struct sh_mobile_ceu_dev *pcdev = ici->priv; 218 struct sh_mobile_ceu_dev *pcdev = ici->priv;
220 219
@@ -361,8 +360,7 @@ static int sh_mobile_ceu_videobuf_prepare(struct vb2_buffer *vb)
361static void sh_mobile_ceu_videobuf_queue(struct vb2_buffer *vb) 360static void sh_mobile_ceu_videobuf_queue(struct vb2_buffer *vb)
362{ 361{
363 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); 362 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
364 struct soc_camera_device *icd = container_of(vb->vb2_queue, 363 struct soc_camera_device *icd = soc_camera_from_vb2q(vb->vb2_queue);
365 struct soc_camera_device, vb2_vidq);
366 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); 364 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
367 struct sh_mobile_ceu_dev *pcdev = ici->priv; 365 struct sh_mobile_ceu_dev *pcdev = ici->priv;
368 struct sh_mobile_ceu_buffer *buf = to_ceu_vb(vbuf); 366 struct sh_mobile_ceu_buffer *buf = to_ceu_vb(vbuf);
@@ -413,8 +411,7 @@ error:
413static void sh_mobile_ceu_videobuf_release(struct vb2_buffer *vb) 411static void sh_mobile_ceu_videobuf_release(struct vb2_buffer *vb)
414{ 412{
415 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); 413 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
416 struct soc_camera_device *icd = container_of(vb->vb2_queue, 414 struct soc_camera_device *icd = soc_camera_from_vb2q(vb->vb2_queue);
417 struct soc_camera_device, vb2_vidq);
418 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); 415 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
419 struct sh_mobile_ceu_buffer *buf = to_ceu_vb(vbuf); 416 struct sh_mobile_ceu_buffer *buf = to_ceu_vb(vbuf);
420 struct sh_mobile_ceu_dev *pcdev = ici->priv; 417 struct sh_mobile_ceu_dev *pcdev = ici->priv;
@@ -444,8 +441,7 @@ static void sh_mobile_ceu_videobuf_release(struct vb2_buffer *vb)
444static int sh_mobile_ceu_videobuf_init(struct vb2_buffer *vb) 441static int sh_mobile_ceu_videobuf_init(struct vb2_buffer *vb)
445{ 442{
446 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); 443 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
447 struct soc_camera_device *icd = container_of(vb->vb2_queue, 444 struct soc_camera_device *icd = soc_camera_from_vb2q(vb->vb2_queue);
448 struct soc_camera_device, vb2_vidq);
449 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); 445 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
450 struct sh_mobile_ceu_dev *pcdev = ici->priv; 446 struct sh_mobile_ceu_dev *pcdev = ici->priv;
451 447
@@ -460,7 +456,7 @@ static int sh_mobile_ceu_videobuf_init(struct vb2_buffer *vb)
460 456
461static void sh_mobile_ceu_stop_streaming(struct vb2_queue *q) 457static void sh_mobile_ceu_stop_streaming(struct vb2_queue *q)
462{ 458{
463 struct soc_camera_device *icd = container_of(q, struct soc_camera_device, vb2_vidq); 459 struct soc_camera_device *icd = soc_camera_from_vb2q(q);
464 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); 460 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
465 struct sh_mobile_ceu_dev *pcdev = ici->priv; 461 struct sh_mobile_ceu_dev *pcdev = ici->priv;
466 struct list_head *buf_head, *tmp; 462 struct list_head *buf_head, *tmp;
diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c
index 69d7fe4471c2..2c0015b1264d 100644
--- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c
+++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c
@@ -118,7 +118,7 @@ int c8sectpfe_frontend_attach(struct dvb_frontend **fe,
118 struct channel_info *tsin, int chan_num) 118 struct channel_info *tsin, int chan_num)
119{ 119{
120 struct tda18212_config *tda18212; 120 struct tda18212_config *tda18212;
121 struct stv6110x_devctl *fe2; 121 const struct stv6110x_devctl *fe2;
122 struct i2c_client *client; 122 struct i2c_client *client;
123 struct i2c_board_info tda18212_info = { 123 struct i2c_board_info tda18212_info = {
124 .type = "tda18212", 124 .type = "tda18212",
diff --git a/drivers/media/platform/ti-vpe/Makefile b/drivers/media/platform/ti-vpe/Makefile
index be680f839e77..e236059a60ad 100644
--- a/drivers/media/platform/ti-vpe/Makefile
+++ b/drivers/media/platform/ti-vpe/Makefile
@@ -3,3 +3,7 @@ obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe.o
3ti-vpe-y := vpe.o sc.o csc.o vpdma.o 3ti-vpe-y := vpe.o sc.o csc.o vpdma.o
4 4
5ccflags-$(CONFIG_VIDEO_TI_VPE_DEBUG) += -DDEBUG 5ccflags-$(CONFIG_VIDEO_TI_VPE_DEBUG) += -DDEBUG
6
7obj-$(CONFIG_VIDEO_TI_CAL) += ti-cal.o
8
9ti-cal-y := cal.o
diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
new file mode 100644
index 000000000000..82001e6b5553
--- /dev/null
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -0,0 +1,1947 @@
1/*
2 * TI CAL camera interface driver
3 *
4 * Copyright (c) 2015 Texas Instruments Inc.
5 * Benoit Parrot, <bparrot@ti.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation
10 */
11
12#include <linux/interrupt.h>
13#include <linux/io.h>
14#include <linux/ioctl.h>
15#include <linux/module.h>
16#include <linux/platform_device.h>
17#include <linux/delay.h>
18#include <linux/pm_runtime.h>
19#include <linux/slab.h>
20#include <linux/videodev2.h>
21#include <linux/of_device.h>
22#include <linux/of_graph.h>
23
24#include <media/v4l2-of.h>
25#include <media/v4l2-async.h>
26#include <media/v4l2-common.h>
27#include <media/v4l2-ctrls.h>
28#include <media/v4l2-device.h>
29#include <media/v4l2-event.h>
30#include <media/v4l2-ioctl.h>
31#include <media/v4l2-ctrls.h>
32#include <media/v4l2-fh.h>
33#include <media/v4l2-event.h>
34#include <media/v4l2-common.h>
35#include <media/videobuf2-core.h>
36#include <media/videobuf2-dma-contig.h>
37#include "cal_regs.h"
38
39#define CAL_MODULE_NAME "cal"
40
41#define MAX_WIDTH 1920
42#define MAX_HEIGHT 1200
43
44#define CAL_VERSION "0.1.0"
45
46MODULE_DESCRIPTION("TI CAL driver");
47MODULE_AUTHOR("Benoit Parrot, <bparrot@ti.com>");
48MODULE_LICENSE("GPL v2");
49MODULE_VERSION(CAL_VERSION);
50
51static unsigned video_nr = -1;
52module_param(video_nr, uint, 0644);
53MODULE_PARM_DESC(video_nr, "videoX start number, -1 is autodetect");
54
55static unsigned debug;
56module_param(debug, uint, 0644);
57MODULE_PARM_DESC(debug, "activates debug info");
58
59/* timeperframe: min/max and default */
60static const struct v4l2_fract
61 tpf_default = {.numerator = 1001, .denominator = 30000};
62
63#define cal_dbg(level, caldev, fmt, arg...) \
64 v4l2_dbg(level, debug, &caldev->v4l2_dev, fmt, ##arg)
65#define cal_info(caldev, fmt, arg...) \
66 v4l2_info(&caldev->v4l2_dev, fmt, ##arg)
67#define cal_err(caldev, fmt, arg...) \
68 v4l2_err(&caldev->v4l2_dev, fmt, ##arg)
69
70#define ctx_dbg(level, ctx, fmt, arg...) \
71 v4l2_dbg(level, debug, &ctx->v4l2_dev, fmt, ##arg)
72#define ctx_info(ctx, fmt, arg...) \
73 v4l2_info(&ctx->v4l2_dev, fmt, ##arg)
74#define ctx_err(ctx, fmt, arg...) \
75 v4l2_err(&ctx->v4l2_dev, fmt, ##arg)
76
77#define CAL_NUM_INPUT 1
78#define CAL_NUM_CONTEXT 2
79
80#define bytes_per_line(pixel, bpp) (ALIGN(pixel * bpp, 16))
81
82#define reg_read(dev, offset) ioread32(dev->base + offset)
83#define reg_write(dev, offset, val) iowrite32(val, dev->base + offset)
84
85#define reg_read_field(dev, offset, mask) get_field(reg_read(dev, offset), \
86 mask)
87#define reg_write_field(dev, offset, field, mask) { \
88 u32 val = reg_read(dev, offset); \
89 set_field(&val, field, mask); \
90 reg_write(dev, offset, val); }
91
92/* ------------------------------------------------------------------
93 * Basic structures
94 * ------------------------------------------------------------------
95 */
96
97struct cal_fmt {
98 u32 fourcc;
99 u32 code;
100 u8 depth;
101};
102
103static struct cal_fmt cal_formats[] = {
104 {
105 .fourcc = V4L2_PIX_FMT_YUYV,
106 .code = MEDIA_BUS_FMT_YUYV8_2X8,
107 .depth = 16,
108 }, {
109 .fourcc = V4L2_PIX_FMT_UYVY,
110 .code = MEDIA_BUS_FMT_UYVY8_2X8,
111 .depth = 16,
112 }, {
113 .fourcc = V4L2_PIX_FMT_YVYU,
114 .code = MEDIA_BUS_FMT_YVYU8_2X8,
115 .depth = 16,
116 }, {
117 .fourcc = V4L2_PIX_FMT_VYUY,
118 .code = MEDIA_BUS_FMT_VYUY8_2X8,
119 .depth = 16,
120 }, {
121 .fourcc = V4L2_PIX_FMT_RGB565, /* gggbbbbb rrrrrggg */
122 .code = MEDIA_BUS_FMT_RGB565_2X8_LE,
123 .depth = 16,
124 }, {
125 .fourcc = V4L2_PIX_FMT_RGB565X, /* rrrrrggg gggbbbbb */
126 .code = MEDIA_BUS_FMT_RGB565_2X8_BE,
127 .depth = 16,
128 }, {
129 .fourcc = V4L2_PIX_FMT_RGB555, /* gggbbbbb arrrrrgg */
130 .code = MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE,
131 .depth = 16,
132 }, {
133 .fourcc = V4L2_PIX_FMT_RGB555X, /* arrrrrgg gggbbbbb */
134 .code = MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE,
135 .depth = 16,
136 }, {
137 .fourcc = V4L2_PIX_FMT_RGB24, /* rgb */
138 .code = MEDIA_BUS_FMT_RGB888_2X12_LE,
139 .depth = 24,
140 }, {
141 .fourcc = V4L2_PIX_FMT_BGR24, /* bgr */
142 .code = MEDIA_BUS_FMT_RGB888_2X12_BE,
143 .depth = 24,
144 }, {
145 .fourcc = V4L2_PIX_FMT_RGB32, /* argb */
146 .code = MEDIA_BUS_FMT_ARGB8888_1X32,
147 .depth = 32,
148 }, {
149 .fourcc = V4L2_PIX_FMT_SBGGR8,
150 .code = MEDIA_BUS_FMT_SBGGR8_1X8,
151 .depth = 8,
152 }, {
153 .fourcc = V4L2_PIX_FMT_SGBRG8,
154 .code = MEDIA_BUS_FMT_SGBRG8_1X8,
155 .depth = 8,
156 }, {
157 .fourcc = V4L2_PIX_FMT_SGRBG8,
158 .code = MEDIA_BUS_FMT_SGRBG8_1X8,
159 .depth = 8,
160 }, {
161 .fourcc = V4L2_PIX_FMT_SRGGB8,
162 .code = MEDIA_BUS_FMT_SRGGB8_1X8,
163 .depth = 8,
164 }, {
165 .fourcc = V4L2_PIX_FMT_SBGGR10,
166 .code = MEDIA_BUS_FMT_SBGGR10_1X10,
167 .depth = 16,
168 }, {
169 .fourcc = V4L2_PIX_FMT_SGBRG10,
170 .code = MEDIA_BUS_FMT_SGBRG10_1X10,
171 .depth = 16,
172 }, {
173 .fourcc = V4L2_PIX_FMT_SGRBG10,
174 .code = MEDIA_BUS_FMT_SGRBG10_1X10,
175 .depth = 16,
176 }, {
177 .fourcc = V4L2_PIX_FMT_SRGGB10,
178 .code = MEDIA_BUS_FMT_SRGGB10_1X10,
179 .depth = 16,
180 }, {
181 .fourcc = V4L2_PIX_FMT_SBGGR12,
182 .code = MEDIA_BUS_FMT_SBGGR12_1X12,
183 .depth = 16,
184 }, {
185 .fourcc = V4L2_PIX_FMT_SGBRG12,
186 .code = MEDIA_BUS_FMT_SGBRG12_1X12,
187 .depth = 16,
188 }, {
189 .fourcc = V4L2_PIX_FMT_SGRBG12,
190 .code = MEDIA_BUS_FMT_SGRBG12_1X12,
191 .depth = 16,
192 }, {
193 .fourcc = V4L2_PIX_FMT_SRGGB12,
194 .code = MEDIA_BUS_FMT_SRGGB12_1X12,
195 .depth = 16,
196 },
197};
198
199/* Print Four-character-code (FOURCC) */
200static char *fourcc_to_str(u32 fmt)
201{
202 static char code[5];
203
204 code[0] = (unsigned char)(fmt & 0xff);
205 code[1] = (unsigned char)((fmt >> 8) & 0xff);
206 code[2] = (unsigned char)((fmt >> 16) & 0xff);
207 code[3] = (unsigned char)((fmt >> 24) & 0xff);
208 code[4] = '\0';
209
210 return code;
211}
212
213/* buffer for one video frame */
214struct cal_buffer {
215 /* common v4l buffer stuff -- must be first */
216 struct vb2_v4l2_buffer vb;
217 struct list_head list;
218 const struct cal_fmt *fmt;
219};
220
221struct cal_dmaqueue {
222 struct list_head active;
223
224 /* Counters to control fps rate */
225 int frame;
226 int ini_jiffies;
227};
228
229struct cm_data {
230 void __iomem *base;
231 struct resource *res;
232
233 unsigned int camerrx_control;
234
235 struct platform_device *pdev;
236};
237
238struct cc_data {
239 void __iomem *base;
240 struct resource *res;
241
242 struct platform_device *pdev;
243};
244
245/*
246 * there is one cal_dev structure in the driver, it is shared by
247 * all instances.
248 */
249struct cal_dev {
250 int irq;
251 void __iomem *base;
252 struct resource *res;
253 struct platform_device *pdev;
254 struct v4l2_device v4l2_dev;
255
256 /* Control Module handle */
257 struct cm_data *cm;
258 /* Camera Core Module handle */
259 struct cc_data *cc[CAL_NUM_CSI2_PORTS];
260
261 struct cal_ctx *ctx[CAL_NUM_CONTEXT];
262};
263
264/*
265 * There is one cal_ctx structure for each camera core context.
266 */
267struct cal_ctx {
268 struct v4l2_device v4l2_dev;
269 struct v4l2_ctrl_handler ctrl_handler;
270 struct video_device vdev;
271 struct v4l2_async_notifier notifier;
272 struct v4l2_subdev *sensor;
273 struct v4l2_of_endpoint endpoint;
274
275 struct v4l2_async_subdev asd;
276 struct v4l2_async_subdev *asd_list[1];
277
278 struct v4l2_fh fh;
279 struct cal_dev *dev;
280 struct cc_data *cc;
281
282 /* v4l2_ioctl mutex */
283 struct mutex mutex;
284 /* v4l2 buffers lock */
285 spinlock_t slock;
286
287 /* Several counters */
288 unsigned long jiffies;
289
290 struct vb2_alloc_ctx *alloc_ctx;
291 struct cal_dmaqueue vidq;
292
293 /* Input Number */
294 int input;
295
296 /* video capture */
297 const struct cal_fmt *fmt;
298 /* Used to store current pixel format */
299 struct v4l2_format v_fmt;
300 /* Used to store current mbus frame format */
301 struct v4l2_mbus_framefmt m_fmt;
302
303 /* Current subdev enumerated format */
304 struct cal_fmt *active_fmt[ARRAY_SIZE(cal_formats)];
305 int num_active_fmt;
306
307 struct v4l2_fract timeperframe;
308 unsigned int sequence;
309 unsigned int external_rate;
310 struct vb2_queue vb_vidq;
311 unsigned int seq_count;
312 unsigned int csi2_port;
313 unsigned int virtual_channel;
314
315 /* Pointer pointing to current v4l2_buffer */
316 struct cal_buffer *cur_frm;
317 /* Pointer pointing to next v4l2_buffer */
318 struct cal_buffer *next_frm;
319};
320
321static const struct cal_fmt *find_format_by_pix(struct cal_ctx *ctx,
322 u32 pixelformat)
323{
324 const struct cal_fmt *fmt;
325 unsigned int k;
326
327 for (k = 0; k < ctx->num_active_fmt; k++) {
328 fmt = ctx->active_fmt[k];
329 if (fmt->fourcc == pixelformat)
330 return fmt;
331 }
332
333 return NULL;
334}
335
336static const struct cal_fmt *find_format_by_code(struct cal_ctx *ctx,
337 u32 code)
338{
339 const struct cal_fmt *fmt;
340 unsigned int k;
341
342 for (k = 0; k < ctx->num_active_fmt; k++) {
343 fmt = ctx->active_fmt[k];
344 if (fmt->code == code)
345 return fmt;
346 }
347
348 return NULL;
349}
350
351static inline struct cal_ctx *notifier_to_ctx(struct v4l2_async_notifier *n)
352{
353 return container_of(n, struct cal_ctx, notifier);
354}
355
356static inline int get_field(u32 value, u32 mask)
357{
358 return (value & mask) >> __ffs(mask);
359}
360
361static inline void set_field(u32 *valp, u32 field, u32 mask)
362{
363 u32 val = *valp;
364
365 val &= ~mask;
366 val |= (field << __ffs(mask)) & mask;
367 *valp = val;
368}
369
370/*
371 * Control Module block access
372 */
373static struct cm_data *cm_create(struct cal_dev *dev)
374{
375 struct platform_device *pdev = dev->pdev;
376 struct cm_data *cm;
377
378 cm = devm_kzalloc(&pdev->dev, sizeof(*cm), GFP_KERNEL);
379 if (!cm)
380 return ERR_PTR(-ENOMEM);
381
382 cm->res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
383 "camerrx_control");
384 cm->base = devm_ioremap_resource(&pdev->dev, cm->res);
385 if (IS_ERR(cm->base)) {
386 cal_err(dev, "failed to ioremap\n");
387 return ERR_CAST(cm->base);
388 }
389
390 cal_dbg(1, dev, "ioresource %s at %pa - %pa\n",
391 cm->res->name, &cm->res->start, &cm->res->end);
392
393 return cm;
394}
395
396static void camerarx_phy_enable(struct cal_ctx *ctx)
397{
398 u32 val;
399
400 if (!ctx->dev->cm->base) {
401 ctx_err(ctx, "cm not mapped\n");
402 return;
403 }
404
405 val = reg_read(ctx->dev->cm, CM_CTRL_CORE_CAMERRX_CONTROL);
406 if (ctx->csi2_port == 1) {
407 set_field(&val, 1, CM_CAMERRX_CTRL_CSI0_CTRLCLKEN_MASK);
408 set_field(&val, 0, CM_CAMERRX_CTRL_CSI0_CAMMODE_MASK);
409 /* enable all lanes by default */
410 set_field(&val, 0xf, CM_CAMERRX_CTRL_CSI0_LANEENABLE_MASK);
411 set_field(&val, 1, CM_CAMERRX_CTRL_CSI0_MODE_MASK);
412 } else if (ctx->csi2_port == 2) {
413 set_field(&val, 1, CM_CAMERRX_CTRL_CSI1_CTRLCLKEN_MASK);
414 set_field(&val, 0, CM_CAMERRX_CTRL_CSI1_CAMMODE_MASK);
415 /* enable all lanes by default */
416 set_field(&val, 0x3, CM_CAMERRX_CTRL_CSI1_LANEENABLE_MASK);
417 set_field(&val, 1, CM_CAMERRX_CTRL_CSI1_MODE_MASK);
418 }
419 reg_write(ctx->dev->cm, CM_CTRL_CORE_CAMERRX_CONTROL, val);
420}
421
422static void camerarx_phy_disable(struct cal_ctx *ctx)
423{
424 u32 val;
425
426 if (!ctx->dev->cm->base) {
427 ctx_err(ctx, "cm not mapped\n");
428 return;
429 }
430
431 val = reg_read(ctx->dev->cm, CM_CTRL_CORE_CAMERRX_CONTROL);
432 if (ctx->csi2_port == 1)
433 set_field(&val, 0x0, CM_CAMERRX_CTRL_CSI0_CTRLCLKEN_MASK);
434 else if (ctx->csi2_port == 2)
435 set_field(&val, 0x0, CM_CAMERRX_CTRL_CSI1_CTRLCLKEN_MASK);
436 reg_write(ctx->dev->cm, CM_CTRL_CORE_CAMERRX_CONTROL, val);
437}
438
439/*
440 * Camera Instance access block
441 */
442static struct cc_data *cc_create(struct cal_dev *dev, unsigned int core)
443{
444 struct platform_device *pdev = dev->pdev;
445 struct cc_data *cc;
446
447 cc = devm_kzalloc(&pdev->dev, sizeof(*cc), GFP_KERNEL);
448 if (!cc)
449 return ERR_PTR(-ENOMEM);
450
451 cc->res = platform_get_resource_byname(pdev,
452 IORESOURCE_MEM,
453 (core == 0) ?
454 "cal_rx_core0" :
455 "cal_rx_core1");
456 cc->base = devm_ioremap_resource(&pdev->dev, cc->res);
457 if (IS_ERR(cc->base)) {
458 cal_err(dev, "failed to ioremap\n");
459 return ERR_CAST(cc->base);
460 }
461
462 cal_dbg(1, dev, "ioresource %s at %pa - %pa\n",
463 cc->res->name, &cc->res->start, &cc->res->end);
464
465 return cc;
466}
467
468/*
469 * Get Revision and HW info
470 */
471static void cal_get_hwinfo(struct cal_dev *dev)
472{
473 u32 revision = 0;
474 u32 hwinfo = 0;
475
476 revision = reg_read(dev, CAL_HL_REVISION);
477 cal_dbg(3, dev, "CAL_HL_REVISION = 0x%08x (expecting 0x40000200)\n",
478 revision);
479
480 hwinfo = reg_read(dev, CAL_HL_HWINFO);
481 cal_dbg(3, dev, "CAL_HL_HWINFO = 0x%08x (expecting 0xA3C90469)\n",
482 hwinfo);
483}
484
485static inline int cal_runtime_get(struct cal_dev *dev)
486{
487 int r;
488
489 r = pm_runtime_get_sync(&dev->pdev->dev);
490
491 return r;
492}
493
494static inline void cal_runtime_put(struct cal_dev *dev)
495{
496 pm_runtime_put_sync(&dev->pdev->dev);
497}
498
499static void cal_quickdump_regs(struct cal_dev *dev)
500{
501 cal_info(dev, "CAL Registers @ 0x%pa:\n", &dev->res->start);
502 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 16, 4,
503 (__force const void *)dev->base,
504 resource_size(dev->res), false);
505
506 if (dev->ctx[0]) {
507 cal_info(dev, "CSI2 Core 0 Registers @ %pa:\n",
508 &dev->ctx[0]->cc->res->start);
509 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 16, 4,
510 (__force const void *)dev->ctx[0]->cc->base,
511 resource_size(dev->ctx[0]->cc->res),
512 false);
513 }
514
515 if (dev->ctx[1]) {
516 cal_info(dev, "CSI2 Core 1 Registers @ %pa:\n",
517 &dev->ctx[1]->cc->res->start);
518 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 16, 4,
519 (__force const void *)dev->ctx[1]->cc->base,
520 resource_size(dev->ctx[1]->cc->res),
521 false);
522 }
523
524 cal_info(dev, "CAMERRX_Control Registers @ %pa:\n",
525 &dev->cm->res->start);
526 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 16, 4,
527 (__force const void *)dev->cm->base,
528 resource_size(dev->cm->res), false);
529}
530
531/*
532 * Enable the expected IRQ sources
533 */
534static void enable_irqs(struct cal_ctx *ctx)
535{
536 /* Enable IRQ_WDMA_END 0/1 */
537 reg_write_field(ctx->dev,
538 CAL_HL_IRQENABLE_SET(2),
539 CAL_HL_IRQ_ENABLE,
540 CAL_HL_IRQ_MASK(ctx->csi2_port));
541 /* Enable IRQ_WDMA_START 0/1 */
542 reg_write_field(ctx->dev,
543 CAL_HL_IRQENABLE_SET(3),
544 CAL_HL_IRQ_ENABLE,
545 CAL_HL_IRQ_MASK(ctx->csi2_port));
546 /* Todo: Add VC_IRQ and CSI2_COMPLEXIO_IRQ handling */
547 reg_write(ctx->dev, CAL_CSI2_VC_IRQENABLE(1), 0xFF000000);
548}
549
550static void disable_irqs(struct cal_ctx *ctx)
551{
552 /* Disable IRQ_WDMA_END 0/1 */
553 reg_write_field(ctx->dev,
554 CAL_HL_IRQENABLE_CLR(2),
555 CAL_HL_IRQ_CLEAR,
556 CAL_HL_IRQ_MASK(ctx->csi2_port));
557 /* Disable IRQ_WDMA_START 0/1 */
558 reg_write_field(ctx->dev,
559 CAL_HL_IRQENABLE_CLR(3),
560 CAL_HL_IRQ_CLEAR,
561 CAL_HL_IRQ_MASK(ctx->csi2_port));
562 /* Todo: Add VC_IRQ and CSI2_COMPLEXIO_IRQ handling */
563 reg_write(ctx->dev, CAL_CSI2_VC_IRQENABLE(1), 0);
564}
565
566static void csi2_init(struct cal_ctx *ctx)
567{
568 int i;
569 u32 val;
570
571 val = reg_read(ctx->dev, CAL_CSI2_TIMING(ctx->csi2_port));
572 set_field(&val, CAL_GEN_ENABLE,
573 CAL_CSI2_TIMING_FORCE_RX_MODE_IO1_MASK);
574 set_field(&val, CAL_GEN_ENABLE,
575 CAL_CSI2_TIMING_STOP_STATE_X16_IO1_MASK);
576 set_field(&val, CAL_GEN_DISABLE,
577 CAL_CSI2_TIMING_STOP_STATE_X4_IO1_MASK);
578 set_field(&val, 407, CAL_CSI2_TIMING_STOP_STATE_COUNTER_IO1_MASK);
579 reg_write(ctx->dev, CAL_CSI2_TIMING(ctx->csi2_port), val);
580 ctx_dbg(3, ctx, "CAL_CSI2_TIMING(%d) = 0x%08x\n", ctx->csi2_port,
581 reg_read(ctx->dev, CAL_CSI2_TIMING(ctx->csi2_port)));
582
583 val = reg_read(ctx->dev, CAL_CSI2_COMPLEXIO_CFG(ctx->csi2_port));
584 set_field(&val, CAL_CSI2_COMPLEXIO_CFG_RESET_CTRL_OPERATIONAL,
585 CAL_CSI2_COMPLEXIO_CFG_RESET_CTRL_MASK);
586 set_field(&val, CAL_CSI2_COMPLEXIO_CFG_PWR_CMD_STATE_ON,
587 CAL_CSI2_COMPLEXIO_CFG_PWR_CMD_MASK);
588 reg_write(ctx->dev, CAL_CSI2_COMPLEXIO_CFG(ctx->csi2_port), val);
589 for (i = 0; i < 10; i++) {
590 if (reg_read_field(ctx->dev,
591 CAL_CSI2_COMPLEXIO_CFG(ctx->csi2_port),
592 CAL_CSI2_COMPLEXIO_CFG_PWR_STATUS_MASK) ==
593 CAL_CSI2_COMPLEXIO_CFG_PWR_STATUS_STATE_ON)
594 break;
595 usleep_range(1000, 1100);
596 }
597 ctx_dbg(3, ctx, "CAL_CSI2_COMPLEXIO_CFG(%d) = 0x%08x\n", ctx->csi2_port,
598 reg_read(ctx->dev, CAL_CSI2_COMPLEXIO_CFG(ctx->csi2_port)));
599
600 val = reg_read(ctx->dev, CAL_CTRL);
601 set_field(&val, CAL_CTRL_BURSTSIZE_BURST128, CAL_CTRL_BURSTSIZE_MASK);
602 set_field(&val, 0xF, CAL_CTRL_TAGCNT_MASK);
603 set_field(&val, CAL_CTRL_POSTED_WRITES_NONPOSTED,
604 CAL_CTRL_POSTED_WRITES_MASK);
605 set_field(&val, 0xFF, CAL_CTRL_MFLAGL_MASK);
606 set_field(&val, 0xFF, CAL_CTRL_MFLAGH_MASK);
607 reg_write(ctx->dev, CAL_CTRL, val);
608 ctx_dbg(3, ctx, "CAL_CTRL = 0x%08x\n", reg_read(ctx->dev, CAL_CTRL));
609}
610
611static void csi2_lane_config(struct cal_ctx *ctx)
612{
613 u32 val = reg_read(ctx->dev, CAL_CSI2_COMPLEXIO_CFG(ctx->csi2_port));
614 u32 lane_mask = CAL_CSI2_COMPLEXIO_CFG_CLOCK_POSITION_MASK;
615 u32 polarity_mask = CAL_CSI2_COMPLEXIO_CFG_CLOCK_POL_MASK;
616 struct v4l2_of_bus_mipi_csi2 *mipi_csi2 = &ctx->endpoint.bus.mipi_csi2;
617 int lane;
618
619 set_field(&val, mipi_csi2->clock_lane + 1, lane_mask);
620 set_field(&val, mipi_csi2->lane_polarities[0], polarity_mask);
621 for (lane = 0; lane < mipi_csi2->num_data_lanes; lane++) {
622 /*
623 * Every lane are one nibble apart starting with the
624 * clock followed by the data lanes so shift masks by 4.
625 */
626 lane_mask <<= 4;
627 polarity_mask <<= 4;
628 set_field(&val, mipi_csi2->data_lanes[lane] + 1, lane_mask);
629 set_field(&val, mipi_csi2->lane_polarities[lane + 1],
630 polarity_mask);
631 }
632
633 reg_write(ctx->dev, CAL_CSI2_COMPLEXIO_CFG(ctx->csi2_port), val);
634 ctx_dbg(3, ctx, "CAL_CSI2_COMPLEXIO_CFG(%d) = 0x%08x\n",
635 ctx->csi2_port, val);
636}
637
638static void csi2_ppi_enable(struct cal_ctx *ctx)
639{
640 reg_write_field(ctx->dev, CAL_CSI2_PPI_CTRL(ctx->csi2_port),
641 CAL_GEN_ENABLE, CAL_CSI2_PPI_CTRL_IF_EN_MASK);
642}
643
644static void csi2_ppi_disable(struct cal_ctx *ctx)
645{
646 reg_write_field(ctx->dev, CAL_CSI2_PPI_CTRL(ctx->csi2_port),
647 CAL_GEN_DISABLE, CAL_CSI2_PPI_CTRL_IF_EN_MASK);
648}
649
650static void csi2_ctx_config(struct cal_ctx *ctx)
651{
652 u32 val;
653
654 val = reg_read(ctx->dev, CAL_CSI2_CTX0(ctx->csi2_port));
655 set_field(&val, ctx->csi2_port, CAL_CSI2_CTX_CPORT_MASK);
656 /*
657 * DT type: MIPI CSI-2 Specs
658 * 0x1: All - DT filter is disabled
659 * 0x24: RGB888 1 pixel = 3 bytes
660 * 0x2B: RAW10 4 pixels = 5 bytes
661 * 0x2A: RAW8 1 pixel = 1 byte
662 * 0x1E: YUV422 2 pixels = 4 bytes
663 */
664 set_field(&val, 0x1, CAL_CSI2_CTX_DT_MASK);
665 /* Virtual Channel from the CSI2 sensor usually 0! */
666 set_field(&val, ctx->virtual_channel, CAL_CSI2_CTX_VC_MASK);
667 /* NUM_LINES_PER_FRAME => 0 means auto detect */
668 set_field(&val, 0, CAL_CSI2_CTX_LINES_MASK);
669 set_field(&val, CAL_CSI2_CTX_ATT_PIX, CAL_CSI2_CTX_ATT_MASK);
670 set_field(&val, CAL_CSI2_CTX_PACK_MODE_LINE,
671 CAL_CSI2_CTX_PACK_MODE_MASK);
672 reg_write(ctx->dev, CAL_CSI2_CTX0(ctx->csi2_port), val);
673 ctx_dbg(3, ctx, "CAL_CSI2_CTX0(%d) = 0x%08x\n", ctx->csi2_port,
674 reg_read(ctx->dev, CAL_CSI2_CTX0(ctx->csi2_port)));
675}
676
677static void pix_proc_config(struct cal_ctx *ctx)
678{
679 u32 val;
680
681 val = reg_read(ctx->dev, CAL_PIX_PROC(ctx->csi2_port));
682 set_field(&val, CAL_PIX_PROC_EXTRACT_B8, CAL_PIX_PROC_EXTRACT_MASK);
683 set_field(&val, CAL_PIX_PROC_DPCMD_BYPASS, CAL_PIX_PROC_DPCMD_MASK);
684 set_field(&val, CAL_PIX_PROC_DPCME_BYPASS, CAL_PIX_PROC_DPCME_MASK);
685 set_field(&val, CAL_PIX_PROC_PACK_B8, CAL_PIX_PROC_PACK_MASK);
686 set_field(&val, ctx->csi2_port, CAL_PIX_PROC_CPORT_MASK);
687 set_field(&val, CAL_GEN_ENABLE, CAL_PIX_PROC_EN_MASK);
688 reg_write(ctx->dev, CAL_PIX_PROC(ctx->csi2_port), val);
689 ctx_dbg(3, ctx, "CAL_PIX_PROC(%d) = 0x%08x\n", ctx->csi2_port,
690 reg_read(ctx->dev, CAL_PIX_PROC(ctx->csi2_port)));
691}
692
693static void cal_wr_dma_config(struct cal_ctx *ctx,
694 unsigned int width)
695{
696 u32 val;
697
698 val = reg_read(ctx->dev, CAL_WR_DMA_CTRL(ctx->csi2_port));
699 set_field(&val, ctx->csi2_port, CAL_WR_DMA_CTRL_CPORT_MASK);
700 set_field(&val, CAL_WR_DMA_CTRL_DTAG_PIX_DAT,
701 CAL_WR_DMA_CTRL_DTAG_MASK);
702 set_field(&val, CAL_WR_DMA_CTRL_MODE_CONST,
703 CAL_WR_DMA_CTRL_MODE_MASK);
704 set_field(&val, CAL_WR_DMA_CTRL_PATTERN_LINEAR,
705 CAL_WR_DMA_CTRL_PATTERN_MASK);
706 set_field(&val, CAL_GEN_ENABLE, CAL_WR_DMA_CTRL_STALL_RD_MASK);
707 reg_write(ctx->dev, CAL_WR_DMA_CTRL(ctx->csi2_port), val);
708 ctx_dbg(3, ctx, "CAL_WR_DMA_CTRL(%d) = 0x%08x\n", ctx->csi2_port,
709 reg_read(ctx->dev, CAL_WR_DMA_CTRL(ctx->csi2_port)));
710
711 /*
712 * width/16 not sure but giving it a whirl.
713 * zero does not work right
714 */
715 reg_write_field(ctx->dev,
716 CAL_WR_DMA_OFST(ctx->csi2_port),
717 (width / 16),
718 CAL_WR_DMA_OFST_MASK);
719 ctx_dbg(3, ctx, "CAL_WR_DMA_OFST(%d) = 0x%08x\n", ctx->csi2_port,
720 reg_read(ctx->dev, CAL_WR_DMA_OFST(ctx->csi2_port)));
721
722 val = reg_read(ctx->dev, CAL_WR_DMA_XSIZE(ctx->csi2_port));
723 /* 64 bit word means no skipping */
724 set_field(&val, 0, CAL_WR_DMA_XSIZE_XSKIP_MASK);
725 /*
726 * (width*8)/64 this should be size of an entire line
727 * in 64bit word but 0 means all data until the end
728 * is detected automagically
729 */
730 set_field(&val, (width / 8), CAL_WR_DMA_XSIZE_MASK);
731 reg_write(ctx->dev, CAL_WR_DMA_XSIZE(ctx->csi2_port), val);
732 ctx_dbg(3, ctx, "CAL_WR_DMA_XSIZE(%d) = 0x%08x\n", ctx->csi2_port,
733 reg_read(ctx->dev, CAL_WR_DMA_XSIZE(ctx->csi2_port)));
734}
735
736static void cal_wr_dma_addr(struct cal_ctx *ctx, unsigned int dmaaddr)
737{
738 reg_write(ctx->dev, CAL_WR_DMA_ADDR(ctx->csi2_port), dmaaddr);
739}
740
741/*
742 * TCLK values are OK at their reset values
743 */
744#define TCLK_TERM 0
745#define TCLK_MISS 1
746#define TCLK_SETTLE 14
747#define THS_SETTLE 15
748
749static void csi2_phy_config(struct cal_ctx *ctx)
750{
751 unsigned int reg0, reg1;
752 unsigned int ths_term, ths_settle;
753 unsigned int ddrclkperiod_us;
754
755 /*
756 * THS_TERM: Programmed value = floor(20 ns/DDRClk period) - 2.
757 */
758 ddrclkperiod_us = ctx->external_rate / 2000000;
759 ddrclkperiod_us = 1000000 / ddrclkperiod_us;
760 ctx_dbg(1, ctx, "ddrclkperiod_us: %d\n", ddrclkperiod_us);
761
762 ths_term = 20000 / ddrclkperiod_us;
763 ths_term = (ths_term >= 2) ? ths_term - 2 : ths_term;
764 ctx_dbg(1, ctx, "ths_term: %d (0x%02x)\n", ths_term, ths_term);
765
766 /*
767 * THS_SETTLE: Programmed value = floor(176.3 ns/CtrlClk period) - 1.
768 * Since CtrlClk is fixed at 96Mhz then we get
769 * ths_settle = floor(176.3 / 10.416) - 1 = 15
770 * If we ever switch to a dynamic clock then this code might be useful
771 *
772 * unsigned int ctrlclkperiod_us;
773 * ctrlclkperiod_us = 96000000 / 1000000;
774 * ctrlclkperiod_us = 1000000 / ctrlclkperiod_us;
775 * ctx_dbg(1, ctx, "ctrlclkperiod_us: %d\n", ctrlclkperiod_us);
776
777 * ths_settle = 176300 / ctrlclkperiod_us;
778 * ths_settle = (ths_settle > 1) ? ths_settle - 1 : ths_settle;
779 */
780
781 ths_settle = THS_SETTLE;
782 ctx_dbg(1, ctx, "ths_settle: %d (0x%02x)\n", ths_settle, ths_settle);
783
784 reg0 = reg_read(ctx->cc, CAL_CSI2_PHY_REG0);
785 set_field(&reg0, CAL_CSI2_PHY_REG0_HSCLOCKCONFIG_DISABLE,
786 CAL_CSI2_PHY_REG0_HSCLOCKCONFIG_MASK);
787 set_field(&reg0, ths_term, CAL_CSI2_PHY_REG0_THS_TERM_MASK);
788 set_field(&reg0, ths_settle, CAL_CSI2_PHY_REG0_THS_SETTLE_MASK);
789
790 ctx_dbg(1, ctx, "CSI2_%d_REG0 = 0x%08x\n", (ctx->csi2_port - 1), reg0);
791 reg_write(ctx->cc, CAL_CSI2_PHY_REG0, reg0);
792
793 reg1 = reg_read(ctx->cc, CAL_CSI2_PHY_REG1);
794 set_field(&reg1, TCLK_TERM, CAL_CSI2_PHY_REG1_TCLK_TERM_MASK);
795 set_field(&reg1, 0xb8, CAL_CSI2_PHY_REG1_DPHY_HS_SYNC_PATTERN_MASK);
796 set_field(&reg1, TCLK_MISS, CAL_CSI2_PHY_REG1_CTRLCLK_DIV_FACTOR_MASK);
797 set_field(&reg1, TCLK_SETTLE, CAL_CSI2_PHY_REG1_TCLK_SETTLE_MASK);
798
799 ctx_dbg(1, ctx, "CSI2_%d_REG1 = 0x%08x\n", (ctx->csi2_port - 1), reg1);
800 reg_write(ctx->cc, CAL_CSI2_PHY_REG1, reg1);
801}
802
803static int cal_get_external_info(struct cal_ctx *ctx)
804{
805 struct v4l2_ctrl *ctrl;
806
807 if (!ctx->sensor)
808 return -ENODEV;
809
810 ctrl = v4l2_ctrl_find(ctx->sensor->ctrl_handler, V4L2_CID_PIXEL_RATE);
811 if (!ctrl) {
812 ctx_err(ctx, "no pixel rate control in subdev: %s\n",
813 ctx->sensor->name);
814 return -EPIPE;
815 }
816
817 ctx->external_rate = v4l2_ctrl_g_ctrl_int64(ctrl);
818 ctx_dbg(3, ctx, "sensor Pixel Rate: %d\n", ctx->external_rate);
819
820 return 0;
821}
822
823static inline void cal_schedule_next_buffer(struct cal_ctx *ctx)
824{
825 struct cal_dmaqueue *dma_q = &ctx->vidq;
826 struct cal_buffer *buf;
827 unsigned long addr;
828
829 buf = list_entry(dma_q->active.next, struct cal_buffer, list);
830 ctx->next_frm = buf;
831 list_del(&buf->list);
832
833 addr = vb2_dma_contig_plane_dma_addr(&buf->vb.vb2_buf, 0);
834 cal_wr_dma_addr(ctx, addr);
835}
836
837static inline void cal_process_buffer_complete(struct cal_ctx *ctx)
838{
839 ctx->cur_frm->vb.vb2_buf.timestamp = ktime_get_ns();
840 ctx->cur_frm->vb.field = ctx->m_fmt.field;
841 ctx->cur_frm->vb.sequence = ctx->sequence++;
842
843 vb2_buffer_done(&ctx->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE);
844 ctx->cur_frm = ctx->next_frm;
845}
846
847#define isvcirqset(irq, vc, ff) (irq & \
848 (CAL_CSI2_VC_IRQENABLE_ ##ff ##_IRQ_##vc ##_MASK))
849
850#define isportirqset(irq, port) (irq & CAL_HL_IRQ_MASK(port))
851
852static irqreturn_t cal_irq(int irq_cal, void *data)
853{
854 struct cal_dev *dev = (struct cal_dev *)data;
855 struct cal_ctx *ctx;
856 struct cal_dmaqueue *dma_q;
857 u32 irqst2, irqst3;
858
859 /* Check which DMA just finished */
860 irqst2 = reg_read(dev, CAL_HL_IRQSTATUS(2));
861 if (irqst2) {
862 /* Clear Interrupt status */
863 reg_write(dev, CAL_HL_IRQSTATUS(2), irqst2);
864
865 /* Need to check both port */
866 if (isportirqset(irqst2, 1)) {
867 ctx = dev->ctx[0];
868
869 if (ctx->cur_frm != ctx->next_frm)
870 cal_process_buffer_complete(ctx);
871 }
872
873 if (isportirqset(irqst2, 2)) {
874 ctx = dev->ctx[1];
875
876 if (ctx->cur_frm != ctx->next_frm)
877 cal_process_buffer_complete(ctx);
878 }
879 }
880
881 /* Check which DMA just started */
882 irqst3 = reg_read(dev, CAL_HL_IRQSTATUS(3));
883 if (irqst3) {
884 /* Clear Interrupt status */
885 reg_write(dev, CAL_HL_IRQSTATUS(3), irqst3);
886
887 /* Need to check both port */
888 if (isportirqset(irqst3, 1)) {
889 ctx = dev->ctx[0];
890 dma_q = &ctx->vidq;
891
892 spin_lock(&ctx->slock);
893 if (!list_empty(&dma_q->active) &&
894 ctx->cur_frm == ctx->next_frm)
895 cal_schedule_next_buffer(ctx);
896 spin_unlock(&ctx->slock);
897 }
898
899 if (isportirqset(irqst3, 2)) {
900 ctx = dev->ctx[1];
901 dma_q = &ctx->vidq;
902
903 spin_lock(&ctx->slock);
904 if (!list_empty(&dma_q->active) &&
905 ctx->cur_frm == ctx->next_frm)
906 cal_schedule_next_buffer(ctx);
907 spin_unlock(&ctx->slock);
908 }
909 }
910
911 return IRQ_HANDLED;
912}
913
914/*
915 * video ioctls
916 */
917static int cal_querycap(struct file *file, void *priv,
918 struct v4l2_capability *cap)
919{
920 struct cal_ctx *ctx = video_drvdata(file);
921
922 strlcpy(cap->driver, CAL_MODULE_NAME, sizeof(cap->driver));
923 strlcpy(cap->card, CAL_MODULE_NAME, sizeof(cap->card));
924
925 snprintf(cap->bus_info, sizeof(cap->bus_info),
926 "platform:%s", ctx->v4l2_dev.name);
927 cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
928 V4L2_CAP_READWRITE;
929 cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
930 return 0;
931}
932
933static int cal_enum_fmt_vid_cap(struct file *file, void *priv,
934 struct v4l2_fmtdesc *f)
935{
936 struct cal_ctx *ctx = video_drvdata(file);
937 const struct cal_fmt *fmt = NULL;
938
939 if (f->index >= ctx->num_active_fmt)
940 return -EINVAL;
941
942 fmt = ctx->active_fmt[f->index];
943
944 f->pixelformat = fmt->fourcc;
945 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
946 return 0;
947}
948
949static int __subdev_get_format(struct cal_ctx *ctx,
950 struct v4l2_mbus_framefmt *fmt)
951{
952 struct v4l2_subdev_format sd_fmt;
953 struct v4l2_mbus_framefmt *mbus_fmt = &sd_fmt.format;
954 int ret;
955
956 sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
957 sd_fmt.pad = 0;
958
959 ret = v4l2_subdev_call(ctx->sensor, pad, get_fmt, NULL, &sd_fmt);
960 if (ret)
961 return ret;
962
963 *fmt = *mbus_fmt;
964
965 ctx_dbg(1, ctx, "%s %dx%d code:%04X\n", __func__,
966 fmt->width, fmt->height, fmt->code);
967
968 return 0;
969}
970
971static int __subdev_set_format(struct cal_ctx *ctx,
972 struct v4l2_mbus_framefmt *fmt)
973{
974 struct v4l2_subdev_format sd_fmt;
975 struct v4l2_mbus_framefmt *mbus_fmt = &sd_fmt.format;
976 int ret;
977
978 sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
979 sd_fmt.pad = 0;
980 *mbus_fmt = *fmt;
981
982 ret = v4l2_subdev_call(ctx->sensor, pad, set_fmt, NULL, &sd_fmt);
983 if (ret)
984 return ret;
985
986 ctx_dbg(1, ctx, "%s %dx%d code:%04X\n", __func__,
987 fmt->width, fmt->height, fmt->code);
988
989 return 0;
990}
991
992static int cal_calc_format_size(struct cal_ctx *ctx,
993 const struct cal_fmt *fmt,
994 struct v4l2_format *f)
995{
996 if (!fmt) {
997 ctx_dbg(3, ctx, "No cal_fmt provided!\n");
998 return -EINVAL;
999 }
1000
1001 v4l_bound_align_image(&f->fmt.pix.width, 48, MAX_WIDTH, 2,
1002 &f->fmt.pix.height, 32, MAX_HEIGHT, 0, 0);
1003 f->fmt.pix.bytesperline = bytes_per_line(f->fmt.pix.width,
1004 fmt->depth >> 3);
1005 f->fmt.pix.sizeimage = f->fmt.pix.height *
1006 f->fmt.pix.bytesperline;
1007
1008 ctx_dbg(3, ctx, "%s: fourcc: %s size: %dx%d bpl:%d img_size:%d\n",
1009 __func__, fourcc_to_str(f->fmt.pix.pixelformat),
1010 f->fmt.pix.width, f->fmt.pix.height,
1011 f->fmt.pix.bytesperline, f->fmt.pix.sizeimage);
1012
1013 return 0;
1014}
1015
1016static int cal_g_fmt_vid_cap(struct file *file, void *priv,
1017 struct v4l2_format *f)
1018{
1019 struct cal_ctx *ctx = video_drvdata(file);
1020
1021 *f = ctx->v_fmt;
1022
1023 return 0;
1024}
1025
1026static int cal_try_fmt_vid_cap(struct file *file, void *priv,
1027 struct v4l2_format *f)
1028{
1029 struct cal_ctx *ctx = video_drvdata(file);
1030 const struct cal_fmt *fmt;
1031 struct v4l2_subdev_frame_size_enum fse;
1032 int ret, found;
1033
1034 fmt = find_format_by_pix(ctx, f->fmt.pix.pixelformat);
1035 if (!fmt) {
1036 ctx_dbg(3, ctx, "Fourcc format (0x%08x) not found.\n",
1037 f->fmt.pix.pixelformat);
1038
1039 /* Just get the first one enumerated */
1040 fmt = ctx->active_fmt[0];
1041 f->fmt.pix.pixelformat = fmt->fourcc;
1042 }
1043
1044 f->fmt.pix.field = ctx->v_fmt.fmt.pix.field;
1045
1046 /* check for/find a valid width/height */
1047 ret = 0;
1048 found = false;
1049 fse.pad = 0;
1050 fse.code = fmt->code;
1051 fse.which = V4L2_SUBDEV_FORMAT_ACTIVE;
1052 for (fse.index = 0; ; fse.index++) {
1053 ret = v4l2_subdev_call(ctx->sensor, pad, enum_frame_size,
1054 NULL, &fse);
1055 if (ret)
1056 break;
1057
1058 if ((f->fmt.pix.width == fse.max_width) &&
1059 (f->fmt.pix.height == fse.max_height)) {
1060 found = true;
1061 break;
1062 } else if ((f->fmt.pix.width >= fse.min_width) &&
1063 (f->fmt.pix.width <= fse.max_width) &&
1064 (f->fmt.pix.height >= fse.min_height) &&
1065 (f->fmt.pix.height <= fse.max_height)) {
1066 found = true;
1067 break;
1068 }
1069 }
1070
1071 if (!found) {
1072 /* use existing values as default */
1073 f->fmt.pix.width = ctx->v_fmt.fmt.pix.width;
1074 f->fmt.pix.height = ctx->v_fmt.fmt.pix.height;
1075 }
1076
1077 /*
1078 * Use current colorspace for now, it will get
1079 * updated properly during s_fmt
1080 */
1081 f->fmt.pix.colorspace = ctx->v_fmt.fmt.pix.colorspace;
1082 return cal_calc_format_size(ctx, fmt, f);
1083}
1084
1085static int cal_s_fmt_vid_cap(struct file *file, void *priv,
1086 struct v4l2_format *f)
1087{
1088 struct cal_ctx *ctx = video_drvdata(file);
1089 struct vb2_queue *q = &ctx->vb_vidq;
1090 const struct cal_fmt *fmt;
1091 struct v4l2_mbus_framefmt mbus_fmt;
1092 int ret;
1093
1094 if (vb2_is_busy(q)) {
1095 ctx_dbg(3, ctx, "%s device busy\n", __func__);
1096 return -EBUSY;
1097 }
1098
1099 ret = cal_try_fmt_vid_cap(file, priv, f);
1100 if (ret < 0)
1101 return ret;
1102
1103 fmt = find_format_by_pix(ctx, f->fmt.pix.pixelformat);
1104
1105 v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, fmt->code);
1106
1107 ret = __subdev_set_format(ctx, &mbus_fmt);
1108 if (ret)
1109 return ret;
1110
1111 /* Just double check nothing has gone wrong */
1112 if (mbus_fmt.code != fmt->code) {
1113 ctx_dbg(3, ctx,
1114 "%s subdev changed format on us, this should not happen\n",
1115 __func__);
1116 return -EINVAL;
1117 }
1118
1119 v4l2_fill_pix_format(&ctx->v_fmt.fmt.pix, &mbus_fmt);
1120 ctx->v_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1121 ctx->v_fmt.fmt.pix.pixelformat = fmt->fourcc;
1122 cal_calc_format_size(ctx, fmt, &ctx->v_fmt);
1123 ctx->fmt = fmt;
1124 ctx->m_fmt = mbus_fmt;
1125 *f = ctx->v_fmt;
1126
1127 return 0;
1128}
1129
1130static int cal_enum_framesizes(struct file *file, void *fh,
1131 struct v4l2_frmsizeenum *fsize)
1132{
1133 struct cal_ctx *ctx = video_drvdata(file);
1134 const struct cal_fmt *fmt;
1135 struct v4l2_subdev_frame_size_enum fse;
1136 int ret;
1137
1138 /* check for valid format */
1139 fmt = find_format_by_pix(ctx, fsize->pixel_format);
1140 if (!fmt) {
1141 ctx_dbg(3, ctx, "Invalid pixel code: %x\n",
1142 fsize->pixel_format);
1143 return -EINVAL;
1144 }
1145
1146 fse.index = fsize->index;
1147 fse.pad = 0;
1148 fse.code = fmt->code;
1149
1150 ret = v4l2_subdev_call(ctx->sensor, pad, enum_frame_size, NULL, &fse);
1151 if (ret)
1152 return ret;
1153
1154 ctx_dbg(1, ctx, "%s: index: %d code: %x W:[%d,%d] H:[%d,%d]\n",
1155 __func__, fse.index, fse.code, fse.min_width, fse.max_width,
1156 fse.min_height, fse.max_height);
1157
1158 fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
1159 fsize->discrete.width = fse.max_width;
1160 fsize->discrete.height = fse.max_height;
1161
1162 return 0;
1163}
1164
1165static int cal_enum_input(struct file *file, void *priv,
1166 struct v4l2_input *inp)
1167{
1168 if (inp->index >= CAL_NUM_INPUT)
1169 return -EINVAL;
1170
1171 inp->type = V4L2_INPUT_TYPE_CAMERA;
1172 sprintf(inp->name, "Camera %u", inp->index);
1173 return 0;
1174}
1175
1176static int cal_g_input(struct file *file, void *priv, unsigned int *i)
1177{
1178 struct cal_ctx *ctx = video_drvdata(file);
1179
1180 *i = ctx->input;
1181 return 0;
1182}
1183
1184static int cal_s_input(struct file *file, void *priv, unsigned int i)
1185{
1186 struct cal_ctx *ctx = video_drvdata(file);
1187
1188 if (i >= CAL_NUM_INPUT)
1189 return -EINVAL;
1190
1191 ctx->input = i;
1192 return 0;
1193}
1194
1195/* timeperframe is arbitrary and continuous */
1196static int cal_enum_frameintervals(struct file *file, void *priv,
1197 struct v4l2_frmivalenum *fival)
1198{
1199 struct cal_ctx *ctx = video_drvdata(file);
1200 const struct cal_fmt *fmt;
1201 struct v4l2_subdev_frame_interval_enum fie = {
1202 .index = fival->index,
1203 .width = fival->width,
1204 .height = fival->height,
1205 .which = V4L2_SUBDEV_FORMAT_ACTIVE,
1206 };
1207 int ret;
1208
1209 fmt = find_format_by_pix(ctx, fival->pixel_format);
1210 if (!fmt)
1211 return -EINVAL;
1212
1213 fie.code = fmt->code;
1214 ret = v4l2_subdev_call(ctx->sensor, pad, enum_frame_interval,
1215 NULL, &fie);
1216 if (ret)
1217 return ret;
1218 fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
1219 fival->discrete = fie.interval;
1220
1221 return 0;
1222}
1223
1224/*
1225 * Videobuf operations
1226 */
1227static int cal_queue_setup(struct vb2_queue *vq,
1228 unsigned int *nbuffers, unsigned int *nplanes,
1229 unsigned int sizes[], void *alloc_ctxs[])
1230{
1231 struct cal_ctx *ctx = vb2_get_drv_priv(vq);
1232 unsigned size = ctx->v_fmt.fmt.pix.sizeimage;
1233
1234 if (vq->num_buffers + *nbuffers < 3)
1235 *nbuffers = 3 - vq->num_buffers;
1236 alloc_ctxs[0] = ctx->alloc_ctx;
1237
1238 if (*nplanes) {
1239 if (sizes[0] < size)
1240 return -EINVAL;
1241 size = sizes[0];
1242 }
1243
1244 *nplanes = 1;
1245 sizes[0] = size;
1246
1247 ctx_dbg(3, ctx, "nbuffers=%d, size=%d\n", *nbuffers, sizes[0]);
1248
1249 return 0;
1250}
1251
1252static int cal_buffer_prepare(struct vb2_buffer *vb)
1253{
1254 struct cal_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
1255 struct cal_buffer *buf = container_of(vb, struct cal_buffer,
1256 vb.vb2_buf);
1257 unsigned long size;
1258
1259 if (WARN_ON(!ctx->fmt))
1260 return -EINVAL;
1261
1262 size = ctx->v_fmt.fmt.pix.sizeimage;
1263 if (vb2_plane_size(vb, 0) < size) {
1264 ctx_err(ctx,
1265 "data will not fit into plane (%lu < %lu)\n",
1266 vb2_plane_size(vb, 0), size);
1267 return -EINVAL;
1268 }
1269
1270 vb2_set_plane_payload(&buf->vb.vb2_buf, 0, size);
1271 return 0;
1272}
1273
1274static void cal_buffer_queue(struct vb2_buffer *vb)
1275{
1276 struct cal_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
1277 struct cal_buffer *buf = container_of(vb, struct cal_buffer,
1278 vb.vb2_buf);
1279 struct cal_dmaqueue *vidq = &ctx->vidq;
1280 unsigned long flags = 0;
1281
1282 /* recheck locking */
1283 spin_lock_irqsave(&ctx->slock, flags);
1284 list_add_tail(&buf->list, &vidq->active);
1285 spin_unlock_irqrestore(&ctx->slock, flags);
1286}
1287
1288static int cal_start_streaming(struct vb2_queue *vq, unsigned int count)
1289{
1290 struct cal_ctx *ctx = vb2_get_drv_priv(vq);
1291 struct cal_dmaqueue *dma_q = &ctx->vidq;
1292 struct cal_buffer *buf, *tmp;
1293 unsigned long addr = 0;
1294 unsigned long flags;
1295 int ret;
1296
1297 spin_lock_irqsave(&ctx->slock, flags);
1298 if (list_empty(&dma_q->active)) {
1299 spin_unlock_irqrestore(&ctx->slock, flags);
1300 ctx_dbg(3, ctx, "buffer queue is empty\n");
1301 return -EIO;
1302 }
1303
1304 buf = list_entry(dma_q->active.next, struct cal_buffer, list);
1305 ctx->cur_frm = buf;
1306 ctx->next_frm = buf;
1307 list_del(&buf->list);
1308 spin_unlock_irqrestore(&ctx->slock, flags);
1309
1310 addr = vb2_dma_contig_plane_dma_addr(&ctx->cur_frm->vb.vb2_buf, 0);
1311 ctx->sequence = 0;
1312
1313 ret = cal_get_external_info(ctx);
1314 if (ret < 0)
1315 goto err;
1316
1317 cal_runtime_get(ctx->dev);
1318
1319 enable_irqs(ctx);
1320 camerarx_phy_enable(ctx);
1321 csi2_init(ctx);
1322 csi2_phy_config(ctx);
1323 csi2_lane_config(ctx);
1324 csi2_ctx_config(ctx);
1325 pix_proc_config(ctx);
1326 cal_wr_dma_config(ctx, ctx->v_fmt.fmt.pix.bytesperline);
1327 cal_wr_dma_addr(ctx, addr);
1328 csi2_ppi_enable(ctx);
1329
1330 ret = v4l2_subdev_call(ctx->sensor, video, s_stream, 1);
1331 if (ret) {
1332 ctx_err(ctx, "stream on failed in subdev\n");
1333 cal_runtime_put(ctx->dev);
1334 goto err;
1335 }
1336
1337 if (debug >= 4)
1338 cal_quickdump_regs(ctx->dev);
1339
1340 return 0;
1341
1342err:
1343 list_for_each_entry_safe(buf, tmp, &dma_q->active, list) {
1344 list_del(&buf->list);
1345 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_QUEUED);
1346 }
1347 return ret;
1348}
1349
1350static void cal_stop_streaming(struct vb2_queue *vq)
1351{
1352 struct cal_ctx *ctx = vb2_get_drv_priv(vq);
1353 struct cal_dmaqueue *dma_q = &ctx->vidq;
1354 struct cal_buffer *buf, *tmp;
1355 unsigned long flags;
1356
1357 if (v4l2_subdev_call(ctx->sensor, video, s_stream, 0))
1358 ctx_err(ctx, "stream off failed in subdev\n");
1359
1360 csi2_ppi_disable(ctx);
1361 disable_irqs(ctx);
1362
1363 /* Release all active buffers */
1364 spin_lock_irqsave(&ctx->slock, flags);
1365 list_for_each_entry_safe(buf, tmp, &dma_q->active, list) {
1366 list_del(&buf->list);
1367 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
1368 }
1369
1370 if (ctx->cur_frm == ctx->next_frm) {
1371 vb2_buffer_done(&ctx->cur_frm->vb.vb2_buf, VB2_BUF_STATE_ERROR);
1372 } else {
1373 vb2_buffer_done(&ctx->cur_frm->vb.vb2_buf, VB2_BUF_STATE_ERROR);
1374 vb2_buffer_done(&ctx->next_frm->vb.vb2_buf,
1375 VB2_BUF_STATE_ERROR);
1376 }
1377 ctx->cur_frm = NULL;
1378 ctx->next_frm = NULL;
1379 spin_unlock_irqrestore(&ctx->slock, flags);
1380
1381 cal_runtime_put(ctx->dev);
1382}
1383
1384static struct vb2_ops cal_video_qops = {
1385 .queue_setup = cal_queue_setup,
1386 .buf_prepare = cal_buffer_prepare,
1387 .buf_queue = cal_buffer_queue,
1388 .start_streaming = cal_start_streaming,
1389 .stop_streaming = cal_stop_streaming,
1390 .wait_prepare = vb2_ops_wait_prepare,
1391 .wait_finish = vb2_ops_wait_finish,
1392};
1393
1394static const struct v4l2_file_operations cal_fops = {
1395 .owner = THIS_MODULE,
1396 .open = v4l2_fh_open,
1397 .release = vb2_fop_release,
1398 .read = vb2_fop_read,
1399 .poll = vb2_fop_poll,
1400 .unlocked_ioctl = video_ioctl2, /* V4L2 ioctl handler */
1401 .mmap = vb2_fop_mmap,
1402};
1403
1404static const struct v4l2_ioctl_ops cal_ioctl_ops = {
1405 .vidioc_querycap = cal_querycap,
1406 .vidioc_enum_fmt_vid_cap = cal_enum_fmt_vid_cap,
1407 .vidioc_g_fmt_vid_cap = cal_g_fmt_vid_cap,
1408 .vidioc_try_fmt_vid_cap = cal_try_fmt_vid_cap,
1409 .vidioc_s_fmt_vid_cap = cal_s_fmt_vid_cap,
1410 .vidioc_enum_framesizes = cal_enum_framesizes,
1411 .vidioc_reqbufs = vb2_ioctl_reqbufs,
1412 .vidioc_create_bufs = vb2_ioctl_create_bufs,
1413 .vidioc_prepare_buf = vb2_ioctl_prepare_buf,
1414 .vidioc_querybuf = vb2_ioctl_querybuf,
1415 .vidioc_qbuf = vb2_ioctl_qbuf,
1416 .vidioc_dqbuf = vb2_ioctl_dqbuf,
1417 .vidioc_enum_input = cal_enum_input,
1418 .vidioc_g_input = cal_g_input,
1419 .vidioc_s_input = cal_s_input,
1420 .vidioc_enum_frameintervals = cal_enum_frameintervals,
1421 .vidioc_streamon = vb2_ioctl_streamon,
1422 .vidioc_streamoff = vb2_ioctl_streamoff,
1423 .vidioc_log_status = v4l2_ctrl_log_status,
1424 .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
1425 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
1426};
1427
1428static struct video_device cal_videodev = {
1429 .name = CAL_MODULE_NAME,
1430 .fops = &cal_fops,
1431 .ioctl_ops = &cal_ioctl_ops,
1432 .minor = -1,
1433 .release = video_device_release_empty,
1434};
1435
1436/* -----------------------------------------------------------------
1437 * Initialization and module stuff
1438 * ------------------------------------------------------------------
1439 */
1440static int cal_complete_ctx(struct cal_ctx *ctx);
1441
1442static int cal_async_bound(struct v4l2_async_notifier *notifier,
1443 struct v4l2_subdev *subdev,
1444 struct v4l2_async_subdev *asd)
1445{
1446 struct cal_ctx *ctx = notifier_to_ctx(notifier);
1447 struct v4l2_subdev_mbus_code_enum mbus_code;
1448 int ret = 0;
1449 int i, j, k;
1450
1451 if (ctx->sensor) {
1452 ctx_info(ctx, "Rejecting subdev %s (Already set!!)",
1453 subdev->name);
1454 return 0;
1455 }
1456
1457 ctx->sensor = subdev;
1458 ctx_dbg(1, ctx, "Using sensor %s for capture\n", subdev->name);
1459
1460 /* Enumerate sub device formats and enable all matching local formats */
1461 ctx->num_active_fmt = 0;
1462 for (j = 0, i = 0; ret != -EINVAL; ++j) {
1463 struct cal_fmt *fmt;
1464
1465 memset(&mbus_code, 0, sizeof(mbus_code));
1466 mbus_code.index = j;
1467 ret = v4l2_subdev_call(subdev, pad, enum_mbus_code,
1468 NULL, &mbus_code);
1469 if (ret)
1470 continue;
1471
1472 ctx_dbg(2, ctx,
1473 "subdev %s: code: %04x idx: %d\n",
1474 subdev->name, mbus_code.code, j);
1475
1476 for (k = 0; k < ARRAY_SIZE(cal_formats); k++) {
1477 fmt = &cal_formats[k];
1478
1479 if (mbus_code.code == fmt->code) {
1480 ctx->active_fmt[i] = fmt;
1481 ctx_dbg(2, ctx,
1482 "matched fourcc: %s: code: %04x idx: %d\n",
1483 fourcc_to_str(fmt->fourcc),
1484 fmt->code, i);
1485 ctx->num_active_fmt = ++i;
1486 }
1487 }
1488 }
1489
1490 if (i == 0) {
1491 ctx_err(ctx, "No suitable format reported by subdev %s\n",
1492 subdev->name);
1493 return -EINVAL;
1494 }
1495
1496 cal_complete_ctx(ctx);
1497
1498 return 0;
1499}
1500
1501static int cal_async_complete(struct v4l2_async_notifier *notifier)
1502{
1503 struct cal_ctx *ctx = notifier_to_ctx(notifier);
1504 const struct cal_fmt *fmt;
1505 struct v4l2_mbus_framefmt mbus_fmt;
1506 int ret;
1507
1508 ret = __subdev_get_format(ctx, &mbus_fmt);
1509 if (ret)
1510 return ret;
1511
1512 fmt = find_format_by_code(ctx, mbus_fmt.code);
1513 if (!fmt) {
1514 ctx_dbg(3, ctx, "mbus code format (0x%08x) not found.\n",
1515 mbus_fmt.code);
1516 return -EINVAL;
1517 }
1518
1519 /* Save current subdev format */
1520 v4l2_fill_pix_format(&ctx->v_fmt.fmt.pix, &mbus_fmt);
1521 ctx->v_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1522 ctx->v_fmt.fmt.pix.pixelformat = fmt->fourcc;
1523 cal_calc_format_size(ctx, fmt, &ctx->v_fmt);
1524 ctx->fmt = fmt;
1525 ctx->m_fmt = mbus_fmt;
1526
1527 return 0;
1528}
1529
1530static int cal_complete_ctx(struct cal_ctx *ctx)
1531{
1532 struct video_device *vfd;
1533 struct vb2_queue *q;
1534 int ret;
1535
1536 ctx->timeperframe = tpf_default;
1537 ctx->external_rate = 192000000;
1538
1539 /* initialize locks */
1540 spin_lock_init(&ctx->slock);
1541 mutex_init(&ctx->mutex);
1542
1543 /* initialize queue */
1544 q = &ctx->vb_vidq;
1545 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1546 q->io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ;
1547 q->drv_priv = ctx;
1548 q->buf_struct_size = sizeof(struct cal_buffer);
1549 q->ops = &cal_video_qops;
1550 q->mem_ops = &vb2_dma_contig_memops;
1551 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1552 q->lock = &ctx->mutex;
1553 q->min_buffers_needed = 3;
1554
1555 ret = vb2_queue_init(q);
1556 if (ret)
1557 return ret;
1558
1559 /* init video dma queues */
1560 INIT_LIST_HEAD(&ctx->vidq.active);
1561
1562 vfd = &ctx->vdev;
1563 *vfd = cal_videodev;
1564 vfd->v4l2_dev = &ctx->v4l2_dev;
1565 vfd->queue = q;
1566
1567 /*
1568 * Provide a mutex to v4l2 core. It will be used to protect
1569 * all fops and v4l2 ioctls.
1570 */
1571 vfd->lock = &ctx->mutex;
1572 video_set_drvdata(vfd, ctx);
1573
1574 ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr);
1575 if (ret < 0)
1576 return ret;
1577
1578 v4l2_info(&ctx->v4l2_dev, "V4L2 device registered as %s\n",
1579 video_device_node_name(vfd));
1580
1581 ctx->alloc_ctx = vb2_dma_contig_init_ctx(vfd->v4l2_dev->dev);
1582 if (IS_ERR(ctx->alloc_ctx)) {
1583 ctx_err(ctx, "Failed to alloc vb2 context\n");
1584 ret = PTR_ERR(ctx->alloc_ctx);
1585 goto vdev_unreg;
1586 }
1587
1588 return 0;
1589
1590vdev_unreg:
1591 video_unregister_device(vfd);
1592 return ret;
1593}
1594
1595static struct device_node *
1596of_get_next_port(const struct device_node *parent,
1597 struct device_node *prev)
1598{
1599 struct device_node *port = NULL;
1600
1601 if (!parent)
1602 return NULL;
1603
1604 if (!prev) {
1605 struct device_node *ports;
1606 /*
1607 * It's the first call, we have to find a port subnode
1608 * within this node or within an optional 'ports' node.
1609 */
1610 ports = of_get_child_by_name(parent, "ports");
1611 if (ports)
1612 parent = ports;
1613
1614 port = of_get_child_by_name(parent, "port");
1615
1616 /* release the 'ports' node */
1617 of_node_put(ports);
1618 } else {
1619 struct device_node *ports;
1620
1621 ports = of_get_parent(prev);
1622 if (!ports)
1623 return NULL;
1624
1625 do {
1626 port = of_get_next_child(ports, prev);
1627 if (!port) {
1628 of_node_put(ports);
1629 return NULL;
1630 }
1631 prev = port;
1632 } while (of_node_cmp(port->name, "port") != 0);
1633 }
1634
1635 return port;
1636}
1637
1638static struct device_node *
1639of_get_next_endpoint(const struct device_node *parent,
1640 struct device_node *prev)
1641{
1642 struct device_node *ep = NULL;
1643
1644 if (!parent)
1645 return NULL;
1646
1647 do {
1648 ep = of_get_next_child(parent, prev);
1649 if (!ep)
1650 return NULL;
1651 prev = ep;
1652 } while (of_node_cmp(ep->name, "endpoint") != 0);
1653
1654 return ep;
1655}
1656
1657static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
1658{
1659 struct platform_device *pdev = ctx->dev->pdev;
1660 struct device_node *ep_node, *port, *remote_ep,
1661 *sensor_node, *parent;
1662 struct v4l2_of_endpoint *endpoint;
1663 struct v4l2_async_subdev *asd;
1664 u32 regval = 0;
1665 int ret, index, found_port = 0, lane;
1666
1667 parent = pdev->dev.of_node;
1668
1669 asd = &ctx->asd;
1670 endpoint = &ctx->endpoint;
1671
1672 ep_node = NULL;
1673 port = NULL;
1674 remote_ep = NULL;
1675 sensor_node = NULL;
1676 ret = -EINVAL;
1677
1678 ctx_dbg(3, ctx, "Scanning Port node for csi2 port: %d\n", inst);
1679 for (index = 0; index < CAL_NUM_CSI2_PORTS; index++) {
1680 port = of_get_next_port(parent, port);
1681 if (!port) {
1682 ctx_dbg(1, ctx, "No port node found for csi2 port:%d\n",
1683 index);
1684 goto cleanup_exit;
1685 }
1686
1687 /* Match the slice number with <REG> */
1688 of_property_read_u32(port, "reg", &regval);
1689 ctx_dbg(3, ctx, "port:%d inst:%d <reg>:%d\n",
1690 index, inst, regval);
1691 if ((regval == inst) && (index == inst)) {
1692 found_port = 1;
1693 break;
1694 }
1695 }
1696
1697 if (!found_port) {
1698 ctx_dbg(1, ctx, "No port node matches csi2 port:%d\n",
1699 inst);
1700 goto cleanup_exit;
1701 }
1702
1703 ctx_dbg(3, ctx, "Scanning sub-device for csi2 port: %d\n",
1704 inst);
1705
1706 ep_node = of_get_next_endpoint(port, ep_node);
1707 if (!ep_node) {
1708 ctx_dbg(3, ctx, "can't get next endpoint\n");
1709 goto cleanup_exit;
1710 }
1711
1712 sensor_node = of_graph_get_remote_port_parent(ep_node);
1713 if (!sensor_node) {
1714 ctx_dbg(3, ctx, "can't get remote parent\n");
1715 goto cleanup_exit;
1716 }
1717 asd->match_type = V4L2_ASYNC_MATCH_OF;
1718 asd->match.of.node = sensor_node;
1719
1720 remote_ep = of_parse_phandle(ep_node, "remote-endpoint", 0);
1721 if (!remote_ep) {
1722 ctx_dbg(3, ctx, "can't get remote-endpoint\n");
1723 goto cleanup_exit;
1724 }
1725 v4l2_of_parse_endpoint(remote_ep, endpoint);
1726
1727 if (endpoint->bus_type != V4L2_MBUS_CSI2) {
1728 ctx_err(ctx, "Port:%d sub-device %s is not a CSI2 device\n",
1729 inst, sensor_node->name);
1730 goto cleanup_exit;
1731 }
1732
1733 /* Store Virtual Channel number */
1734 ctx->virtual_channel = endpoint->base.id;
1735
1736 ctx_dbg(3, ctx, "Port:%d v4l2-endpoint: CSI2\n", inst);
1737 ctx_dbg(3, ctx, "Virtual Channel=%d\n", ctx->virtual_channel);
1738 ctx_dbg(3, ctx, "flags=0x%08x\n", endpoint->bus.mipi_csi2.flags);
1739 ctx_dbg(3, ctx, "clock_lane=%d\n", endpoint->bus.mipi_csi2.clock_lane);
1740 ctx_dbg(3, ctx, "num_data_lanes=%d\n",
1741 endpoint->bus.mipi_csi2.num_data_lanes);
1742 ctx_dbg(3, ctx, "data_lanes= <\n");
1743 for (lane = 0; lane < endpoint->bus.mipi_csi2.num_data_lanes; lane++)
1744 ctx_dbg(3, ctx, "\t%d\n",
1745 endpoint->bus.mipi_csi2.data_lanes[lane]);
1746 ctx_dbg(3, ctx, "\t>\n");
1747
1748 ctx_dbg(1, ctx, "Port: %d found sub-device %s\n",
1749 inst, sensor_node->name);
1750
1751 ctx->asd_list[0] = asd;
1752 ctx->notifier.subdevs = ctx->asd_list;
1753 ctx->notifier.num_subdevs = 1;
1754 ctx->notifier.bound = cal_async_bound;
1755 ctx->notifier.complete = cal_async_complete;
1756 ret = v4l2_async_notifier_register(&ctx->v4l2_dev,
1757 &ctx->notifier);
1758 if (ret) {
1759 ctx_err(ctx, "Error registering async notifier\n");
1760 ret = -EINVAL;
1761 }
1762
1763cleanup_exit:
1764 if (!remote_ep)
1765 of_node_put(remote_ep);
1766 if (!sensor_node)
1767 of_node_put(sensor_node);
1768 if (!ep_node)
1769 of_node_put(ep_node);
1770 if (!port)
1771 of_node_put(port);
1772
1773 return ret;
1774}
1775
1776static struct cal_ctx *cal_create_instance(struct cal_dev *dev, int inst)
1777{
1778 struct cal_ctx *ctx;
1779 struct v4l2_ctrl_handler *hdl;
1780 int ret;
1781
1782 ctx = devm_kzalloc(&dev->pdev->dev, sizeof(*ctx), GFP_KERNEL);
1783 if (!ctx)
1784 return NULL;
1785
1786 /* save the cal_dev * for future ref */
1787 ctx->dev = dev;
1788
1789 snprintf(ctx->v4l2_dev.name, sizeof(ctx->v4l2_dev.name),
1790 "%s-%03d", CAL_MODULE_NAME, inst);
1791 ret = v4l2_device_register(&dev->pdev->dev, &ctx->v4l2_dev);
1792 if (ret)
1793 goto err_exit;
1794
1795 hdl = &ctx->ctrl_handler;
1796 ret = v4l2_ctrl_handler_init(hdl, 11);
1797 if (ret) {
1798 ctx_err(ctx, "Failed to init ctrl handler\n");
1799 goto unreg_dev;
1800 }
1801 ctx->v4l2_dev.ctrl_handler = hdl;
1802
1803 /* Make sure Camera Core H/W register area is available */
1804 ctx->cc = dev->cc[inst];
1805
1806 /* Store the instance id */
1807 ctx->csi2_port = inst + 1;
1808
1809 ret = of_cal_create_instance(ctx, inst);
1810 if (ret) {
1811 ret = -EINVAL;
1812 goto free_hdl;
1813 }
1814 return ctx;
1815
1816free_hdl:
1817 v4l2_ctrl_handler_free(hdl);
1818unreg_dev:
1819 v4l2_device_unregister(&ctx->v4l2_dev);
1820err_exit:
1821 return NULL;
1822}
1823
1824static int cal_probe(struct platform_device *pdev)
1825{
1826 struct cal_dev *dev;
1827 int ret;
1828 int irq;
1829
1830 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
1831 if (!dev)
1832 return -ENOMEM;
1833
1834 /* set pseudo v4l2 device name so we can use v4l2_printk */
1835 strlcpy(dev->v4l2_dev.name, CAL_MODULE_NAME,
1836 sizeof(dev->v4l2_dev.name));
1837
1838 /* save pdev pointer */
1839 dev->pdev = pdev;
1840
1841 dev->res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
1842 "cal_top");
1843 dev->base = devm_ioremap_resource(&pdev->dev, dev->res);
1844 if (IS_ERR(dev->base))
1845 return PTR_ERR(dev->base);
1846
1847 cal_dbg(1, dev, "ioresource %s at %pa - %pa\n",
1848 dev->res->name, &dev->res->start, &dev->res->end);
1849
1850 irq = platform_get_irq(pdev, 0);
1851 cal_dbg(1, dev, "got irq# %d\n", irq);
1852 ret = devm_request_irq(&pdev->dev, irq, cal_irq, 0, CAL_MODULE_NAME,
1853 dev);
1854 if (ret)
1855 return ret;
1856
1857 platform_set_drvdata(pdev, dev);
1858
1859 dev->cm = cm_create(dev);
1860 if (IS_ERR(dev->cm))
1861 return PTR_ERR(dev->cm);
1862
1863 dev->cc[0] = cc_create(dev, 0);
1864 if (IS_ERR(dev->cc[0]))
1865 return PTR_ERR(dev->cc[0]);
1866
1867 dev->cc[1] = cc_create(dev, 1);
1868 if (IS_ERR(dev->cc[1]))
1869 return PTR_ERR(dev->cc[1]);
1870
1871 dev->ctx[0] = NULL;
1872 dev->ctx[1] = NULL;
1873
1874 dev->ctx[0] = cal_create_instance(dev, 0);
1875 dev->ctx[1] = cal_create_instance(dev, 1);
1876 if (!dev->ctx[0] && !dev->ctx[1]) {
1877 cal_err(dev, "Neither port is configured, no point in staying up\n");
1878 return -ENODEV;
1879 }
1880
1881 pm_runtime_enable(&pdev->dev);
1882
1883 ret = cal_runtime_get(dev);
1884 if (ret)
1885 goto runtime_disable;
1886
1887 /* Just check we can actually access the module */
1888 cal_get_hwinfo(dev);
1889
1890 cal_runtime_put(dev);
1891
1892 return 0;
1893
1894runtime_disable:
1895 pm_runtime_disable(&pdev->dev);
1896 return ret;
1897}
1898
1899static int cal_remove(struct platform_device *pdev)
1900{
1901 struct cal_dev *dev =
1902 (struct cal_dev *)platform_get_drvdata(pdev);
1903 struct cal_ctx *ctx;
1904 int i;
1905
1906 cal_dbg(1, dev, "Removing %s\n", CAL_MODULE_NAME);
1907
1908 cal_runtime_get(dev);
1909
1910 for (i = 0; i < CAL_NUM_CONTEXT; i++) {
1911 ctx = dev->ctx[i];
1912 if (ctx) {
1913 ctx_dbg(1, ctx, "unregistering %s\n",
1914 video_device_node_name(&ctx->vdev));
1915 camerarx_phy_disable(ctx);
1916 v4l2_async_notifier_unregister(&ctx->notifier);
1917 vb2_dma_contig_cleanup_ctx(ctx->alloc_ctx);
1918 v4l2_ctrl_handler_free(&ctx->ctrl_handler);
1919 v4l2_device_unregister(&ctx->v4l2_dev);
1920 video_unregister_device(&ctx->vdev);
1921 }
1922 }
1923
1924 cal_runtime_put(dev);
1925 pm_runtime_disable(&pdev->dev);
1926
1927 return 0;
1928}
1929
1930#if defined(CONFIG_OF)
1931static const struct of_device_id cal_of_match[] = {
1932 { .compatible = "ti,dra72-cal", },
1933 {},
1934};
1935MODULE_DEVICE_TABLE(of, cal_of_match);
1936#endif
1937
1938static struct platform_driver cal_pdrv = {
1939 .probe = cal_probe,
1940 .remove = cal_remove,
1941 .driver = {
1942 .name = CAL_MODULE_NAME,
1943 .of_match_table = of_match_ptr(cal_of_match),
1944 },
1945};
1946
1947module_platform_driver(cal_pdrv);
diff --git a/drivers/media/platform/ti-vpe/cal_regs.h b/drivers/media/platform/ti-vpe/cal_regs.h
new file mode 100644
index 000000000000..82b3dcf87128
--- /dev/null
+++ b/drivers/media/platform/ti-vpe/cal_regs.h
@@ -0,0 +1,479 @@
1/*
2 * TI CAL camera interface driver
3 *
4 * Copyright (c) 2015 Texas Instruments Inc.
5 *
6 * Benoit Parrot, <bparrot@ti.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published by
10 * the Free Software Foundation.
11 */
12
13#ifndef __TI_CAL_REGS_H
14#define __TI_CAL_REGS_H
15
16#define CAL_NUM_CSI2_PORTS 2
17
18/* CAL register offsets */
19
20#define CAL_HL_REVISION 0x0000
21#define CAL_HL_HWINFO 0x0004
22#define CAL_HL_SYSCONFIG 0x0010
23#define CAL_HL_IRQ_EOI 0x001c
24#define CAL_HL_IRQSTATUS_RAW(m) (0x20U + ((m-1) * 0x10U))
25#define CAL_HL_IRQSTATUS(m) (0x24U + ((m-1) * 0x10U))
26#define CAL_HL_IRQENABLE_SET(m) (0x28U + ((m-1) * 0x10U))
27#define CAL_HL_IRQENABLE_CLR(m) (0x2cU + ((m-1) * 0x10U))
28#define CAL_PIX_PROC(m) (0xc0U + ((m-1) * 0x4U))
29#define CAL_CTRL 0x100
30#define CAL_CTRL1 0x104
31#define CAL_LINE_NUMBER_EVT 0x108
32#define CAL_VPORT_CTRL1 0x120
33#define CAL_VPORT_CTRL2 0x124
34#define CAL_BYS_CTRL1 0x130
35#define CAL_BYS_CTRL2 0x134
36#define CAL_RD_DMA_CTRL 0x140
37#define CAL_RD_DMA_PIX_ADDR 0x144
38#define CAL_RD_DMA_PIX_OFST 0x148
39#define CAL_RD_DMA_XSIZE 0x14c
40#define CAL_RD_DMA_YSIZE 0x150
41#define CAL_RD_DMA_INIT_ADDR 0x154
42#define CAL_RD_DMA_INIT_OFST 0x168
43#define CAL_RD_DMA_CTRL2 0x16c
44#define CAL_WR_DMA_CTRL(m) (0x200U + ((m-1) * 0x10U))
45#define CAL_WR_DMA_ADDR(m) (0x204U + ((m-1) * 0x10U))
46#define CAL_WR_DMA_OFST(m) (0x208U + ((m-1) * 0x10U))
47#define CAL_WR_DMA_XSIZE(m) (0x20cU + ((m-1) * 0x10U))
48#define CAL_CSI2_PPI_CTRL(m) (0x300U + ((m-1) * 0x80U))
49#define CAL_CSI2_COMPLEXIO_CFG(m) (0x304U + ((m-1) * 0x80U))
50#define CAL_CSI2_COMPLEXIO_IRQSTATUS(m) (0x308U + ((m-1) * 0x80U))
51#define CAL_CSI2_SHORT_PACKET(m) (0x30cU + ((m-1) * 0x80U))
52#define CAL_CSI2_COMPLEXIO_IRQENABLE(m) (0x310U + ((m-1) * 0x80U))
53#define CAL_CSI2_TIMING(m) (0x314U + ((m-1) * 0x80U))
54#define CAL_CSI2_VC_IRQENABLE(m) (0x318U + ((m-1) * 0x80U))
55#define CAL_CSI2_VC_IRQSTATUS(m) (0x328U + ((m-1) * 0x80U))
56#define CAL_CSI2_CTX0(m) (0x330U + ((m-1) * 0x80U))
57#define CAL_CSI2_CTX1(m) (0x334U + ((m-1) * 0x80U))
58#define CAL_CSI2_CTX2(m) (0x338U + ((m-1) * 0x80U))
59#define CAL_CSI2_CTX3(m) (0x33cU + ((m-1) * 0x80U))
60#define CAL_CSI2_CTX4(m) (0x340U + ((m-1) * 0x80U))
61#define CAL_CSI2_CTX5(m) (0x344U + ((m-1) * 0x80U))
62#define CAL_CSI2_CTX6(m) (0x348U + ((m-1) * 0x80U))
63#define CAL_CSI2_CTX7(m) (0x34cU + ((m-1) * 0x80U))
64#define CAL_CSI2_STATUS0(m) (0x350U + ((m-1) * 0x80U))
65#define CAL_CSI2_STATUS1(m) (0x354U + ((m-1) * 0x80U))
66#define CAL_CSI2_STATUS2(m) (0x358U + ((m-1) * 0x80U))
67#define CAL_CSI2_STATUS3(m) (0x35cU + ((m-1) * 0x80U))
68#define CAL_CSI2_STATUS4(m) (0x360U + ((m-1) * 0x80U))
69#define CAL_CSI2_STATUS5(m) (0x364U + ((m-1) * 0x80U))
70#define CAL_CSI2_STATUS6(m) (0x368U + ((m-1) * 0x80U))
71#define CAL_CSI2_STATUS7(m) (0x36cU + ((m-1) * 0x80U))
72
73/* CAL CSI2 PHY register offsets */
74#define CAL_CSI2_PHY_REG0 0x000
75#define CAL_CSI2_PHY_REG1 0x004
76#define CAL_CSI2_PHY_REG2 0x008
77
78/* CAL Control Module Core Camerrx Control register offsets */
79#define CM_CTRL_CORE_CAMERRX_CONTROL 0x000
80
81/*********************************************************************
82* Generic value used in various field below
83*********************************************************************/
84
85#define CAL_GEN_DISABLE 0
86#define CAL_GEN_ENABLE 1
87#define CAL_GEN_FALSE 0
88#define CAL_GEN_TRUE 1
89
90/*********************************************************************
91* Field Definition Macros
92*********************************************************************/
93
94#define CAL_HL_REVISION_MINOR_MASK GENMASK(5, 0)
95#define CAL_HL_REVISION_CUSTOM_MASK GENMASK(7, 6)
96#define CAL_HL_REVISION_MAJOR_MASK GENMASK(10, 8)
97#define CAL_HL_REVISION_RTL_MASK GENMASK(15, 11)
98#define CAL_HL_REVISION_FUNC_MASK GENMASK(27, 16)
99#define CAL_HL_REVISION_SCHEME_MASK GENMASK(31, 30)
100#define CAL_HL_REVISION_SCHEME_H08 1
101#define CAL_HL_REVISION_SCHEME_LEGACY 0
102
103#define CAL_HL_HWINFO_WFIFO_MASK GENMASK(3, 0)
104#define CAL_HL_HWINFO_RFIFO_MASK GENMASK(7, 4)
105#define CAL_HL_HWINFO_PCTX_MASK GENMASK(12, 8)
106#define CAL_HL_HWINFO_WCTX_MASK GENMASK(18, 13)
107#define CAL_HL_HWINFO_VFIFO_MASK GENMASK(22, 19)
108#define CAL_HL_HWINFO_NCPORT_MASK GENMASK(27, 23)
109#define CAL_HL_HWINFO_NPPI_CTXS0_MASK GENMASK(29, 28)
110#define CAL_HL_HWINFO_NPPI_CTXS1_MASK GENMASK(31, 30)
111#define CAL_HL_HWINFO_NPPI_CONTEXTS_ZERO 0
112#define CAL_HL_HWINFO_NPPI_CONTEXTS_FOUR 1
113#define CAL_HL_HWINFO_NPPI_CONTEXTS_EIGHT 2
114#define CAL_HL_HWINFO_NPPI_CONTEXTS_RESERVED 3
115
116#define CAL_HL_SYSCONFIG_SOFTRESET_MASK BIT_MASK(0)
117#define CAL_HL_SYSCONFIG_SOFTRESET_DONE 0x0
118#define CAL_HL_SYSCONFIG_SOFTRESET_PENDING 0x1
119#define CAL_HL_SYSCONFIG_SOFTRESET_NOACTION 0x0
120#define CAL_HL_SYSCONFIG_SOFTRESET_RESET 0x1
121#define CAL_HL_SYSCONFIG_IDLE_MASK GENMASK(3, 2)
122#define CAL_HL_SYSCONFIG_IDLEMODE_FORCE 0
123#define CAL_HL_SYSCONFIG_IDLEMODE_NO 1
124#define CAL_HL_SYSCONFIG_IDLEMODE_SMART1 2
125#define CAL_HL_SYSCONFIG_IDLEMODE_SMART2 3
126
127#define CAL_HL_IRQ_EOI_LINE_NUMBER_MASK BIT_MASK(0)
128#define CAL_HL_IRQ_EOI_LINE_NUMBER_READ0 0
129#define CAL_HL_IRQ_EOI_LINE_NUMBER_EOI0 0
130
131#define CAL_HL_IRQ_MASK(m) BIT_MASK(m-1)
132#define CAL_HL_IRQ_NOACTION 0x0
133#define CAL_HL_IRQ_ENABLE 0x1
134#define CAL_HL_IRQ_CLEAR 0x1
135#define CAL_HL_IRQ_DISABLED 0x0
136#define CAL_HL_IRQ_ENABLED 0x1
137#define CAL_HL_IRQ_PENDING 0x1
138
139#define CAL_PIX_PROC_EN_MASK BIT_MASK(0)
140#define CAL_PIX_PROC_EXTRACT_MASK GENMASK(4, 1)
141#define CAL_PIX_PROC_EXTRACT_B6 0x0
142#define CAL_PIX_PROC_EXTRACT_B7 0x1
143#define CAL_PIX_PROC_EXTRACT_B8 0x2
144#define CAL_PIX_PROC_EXTRACT_B10 0x3
145#define CAL_PIX_PROC_EXTRACT_B10_MIPI 0x4
146#define CAL_PIX_PROC_EXTRACT_B12 0x5
147#define CAL_PIX_PROC_EXTRACT_B12_MIPI 0x6
148#define CAL_PIX_PROC_EXTRACT_B14 0x7
149#define CAL_PIX_PROC_EXTRACT_B14_MIPI 0x8
150#define CAL_PIX_PROC_EXTRACT_B16_BE 0x9
151#define CAL_PIX_PROC_EXTRACT_B16_LE 0xa
152#define CAL_PIX_PROC_DPCMD_MASK GENMASK(9, 5)
153#define CAL_PIX_PROC_DPCMD_BYPASS 0x0
154#define CAL_PIX_PROC_DPCMD_DPCM_10_8_1 0x2
155#define CAL_PIX_PROC_DPCMD_DPCM_12_8_1 0x8
156#define CAL_PIX_PROC_DPCMD_DPCM_10_7_1 0x4
157#define CAL_PIX_PROC_DPCMD_DPCM_10_7_2 0x5
158#define CAL_PIX_PROC_DPCMD_DPCM_10_6_1 0x6
159#define CAL_PIX_PROC_DPCMD_DPCM_10_6_2 0x7
160#define CAL_PIX_PROC_DPCMD_DPCM_12_7_1 0xa
161#define CAL_PIX_PROC_DPCMD_DPCM_12_6_1 0xc
162#define CAL_PIX_PROC_DPCMD_DPCM_14_10 0xe
163#define CAL_PIX_PROC_DPCMD_DPCM_14_8_1 0x10
164#define CAL_PIX_PROC_DPCMD_DPCM_16_12_1 0x12
165#define CAL_PIX_PROC_DPCMD_DPCM_16_10_1 0x14
166#define CAL_PIX_PROC_DPCMD_DPCM_16_8_1 0x16
167#define CAL_PIX_PROC_DPCME_MASK GENMASK(15, 11)
168#define CAL_PIX_PROC_DPCME_BYPASS 0x0
169#define CAL_PIX_PROC_DPCME_DPCM_10_8_1 0x2
170#define CAL_PIX_PROC_DPCME_DPCM_12_8_1 0x8
171#define CAL_PIX_PROC_DPCME_DPCM_14_10 0xe
172#define CAL_PIX_PROC_DPCME_DPCM_14_8_1 0x10
173#define CAL_PIX_PROC_DPCME_DPCM_16_12_1 0x12
174#define CAL_PIX_PROC_DPCME_DPCM_16_10_1 0x14
175#define CAL_PIX_PROC_DPCME_DPCM_16_8_1 0x16
176#define CAL_PIX_PROC_PACK_MASK GENMASK(18, 16)
177#define CAL_PIX_PROC_PACK_B8 0x0
178#define CAL_PIX_PROC_PACK_B10_MIPI 0x2
179#define CAL_PIX_PROC_PACK_B12 0x3
180#define CAL_PIX_PROC_PACK_B12_MIPI 0x4
181#define CAL_PIX_PROC_PACK_B16 0x5
182#define CAL_PIX_PROC_PACK_ARGB 0x6
183#define CAL_PIX_PROC_CPORT_MASK GENMASK(23, 19)
184
185#define CAL_CTRL_POSTED_WRITES_MASK BIT_MASK(0)
186#define CAL_CTRL_POSTED_WRITES_NONPOSTED 0
187#define CAL_CTRL_POSTED_WRITES 1
188#define CAL_CTRL_TAGCNT_MASK GENMASK(4, 1)
189#define CAL_CTRL_BURSTSIZE_MASK GENMASK(6, 5)
190#define CAL_CTRL_BURSTSIZE_BURST16 0x0
191#define CAL_CTRL_BURSTSIZE_BURST32 0x1
192#define CAL_CTRL_BURSTSIZE_BURST64 0x2
193#define CAL_CTRL_BURSTSIZE_BURST128 0x3
194#define CAL_CTRL_LL_FORCE_STATE_MASK GENMASK(12, 7)
195#define CAL_CTRL_MFLAGL_MASK GENMASK(20, 13)
196#define CAL_CTRL_PWRSCPCLK_MASK BIT_MASK(21)
197#define CAL_CTRL_PWRSCPCLK_AUTO 0
198#define CAL_CTRL_PWRSCPCLK_FORCE 1
199#define CAL_CTRL_RD_DMA_STALL_MASK BIT_MASK(22)
200#define CAL_CTRL_MFLAGH_MASK GENMASK(31, 24)
201
202#define CAL_CTRL1_PPI_GROUPING_MASK GENMASK(1, 0)
203#define CAL_CTRL1_PPI_GROUPING_DISABLED 0
204#define CAL_CTRL1_PPI_GROUPING_RESERVED 1
205#define CAL_CTRL1_PPI_GROUPING_0 2
206#define CAL_CTRL1_PPI_GROUPING_1 3
207#define CAL_CTRL1_INTERLEAVE01_MASK GENMASK(3, 2)
208#define CAL_CTRL1_INTERLEAVE01_DISABLED 0
209#define CAL_CTRL1_INTERLEAVE01_PIX1 1
210#define CAL_CTRL1_INTERLEAVE01_PIX4 2
211#define CAL_CTRL1_INTERLEAVE01_RESERVED 3
212#define CAL_CTRL1_INTERLEAVE23_MASK GENMASK(5, 4)
213#define CAL_CTRL1_INTERLEAVE23_DISABLED 0
214#define CAL_CTRL1_INTERLEAVE23_PIX1 1
215#define CAL_CTRL1_INTERLEAVE23_PIX4 2
216#define CAL_CTRL1_INTERLEAVE23_RESERVED 3
217
218#define CAL_LINE_NUMBER_EVT_CPORT_MASK GENMASK(4, 0)
219#define CAL_LINE_NUMBER_EVT_MASK GENMASK(29, 16)
220
221#define CAL_VPORT_CTRL1_PCLK_MASK GENMASK(16, 0)
222#define CAL_VPORT_CTRL1_XBLK_MASK GENMASK(24, 17)
223#define CAL_VPORT_CTRL1_YBLK_MASK GENMASK(30, 25)
224#define CAL_VPORT_CTRL1_WIDTH_MASK BIT_MASK(31)
225#define CAL_VPORT_CTRL1_WIDTH_ONE 0
226#define CAL_VPORT_CTRL1_WIDTH_TWO 1
227
228#define CAL_VPORT_CTRL2_CPORT_MASK GENMASK(4, 0)
229#define CAL_VPORT_CTRL2_FREERUNNING_MASK BIT_MASK(15)
230#define CAL_VPORT_CTRL2_FREERUNNING_GATED 0
231#define CAL_VPORT_CTRL2_FREERUNNING_FREE 1
232#define CAL_VPORT_CTRL2_FS_RESETS_MASK BIT_MASK(16)
233#define CAL_VPORT_CTRL2_FS_RESETS_NO 0
234#define CAL_VPORT_CTRL2_FS_RESETS_YES 1
235#define CAL_VPORT_CTRL2_FSM_RESET_MASK BIT_MASK(17)
236#define CAL_VPORT_CTRL2_FSM_RESET_NOEFFECT 0
237#define CAL_VPORT_CTRL2_FSM_RESET 1
238#define CAL_VPORT_CTRL2_RDY_THR_MASK GENMASK(31, 18)
239
240#define CAL_BYS_CTRL1_PCLK_MASK GENMASK(16, 0)
241#define CAL_BYS_CTRL1_XBLK_MASK GENMASK(24, 17)
242#define CAL_BYS_CTRL1_YBLK_MASK GENMASK(30, 25)
243#define CAL_BYS_CTRL1_BYSINEN_MASK BIT_MASK(31)
244
245#define CAL_BYS_CTRL2_CPORTIN_MASK GENMASK(4, 0)
246#define CAL_BYS_CTRL2_CPORTOUT_MASK GENMASK(9, 5)
247#define CAL_BYS_CTRL2_DUPLICATEDDATA_MASK BIT_MASK(10)
248#define CAL_BYS_CTRL2_DUPLICATEDDATA_NO 0
249#define CAL_BYS_CTRL2_DUPLICATEDDATA_YES 1
250#define CAL_BYS_CTRL2_FREERUNNING_MASK BIT_MASK(11)
251#define CAL_BYS_CTRL2_FREERUNNING_NO 0
252#define CAL_BYS_CTRL2_FREERUNNING_YES 1
253
254#define CAL_RD_DMA_CTRL_GO_MASK BIT_MASK(0)
255#define CAL_RD_DMA_CTRL_GO_DIS 0
256#define CAL_RD_DMA_CTRL_GO_EN 1
257#define CAL_RD_DMA_CTRL_GO_IDLE 0
258#define CAL_RD_DMA_CTRL_GO_BUSY 1
259#define CAL_RD_DMA_CTRL_INIT_MASK BIT_MASK(1)
260#define CAL_RD_DMA_CTRL_BW_LIMITER_MASK GENMASK(10, 2)
261#define CAL_RD_DMA_CTRL_OCP_TAG_CNT_MASK GENMASK(14, 11)
262#define CAL_RD_DMA_CTRL_PCLK_MASK GENMASK(31, 15)
263
264#define CAL_RD_DMA_PIX_ADDR_MASK GENMASK(31, 3)
265
266#define CAL_RD_DMA_PIX_OFST_MASK GENMASK(31, 4)
267
268#define CAL_RD_DMA_XSIZE_MASK GENMASK(31, 19)
269
270#define CAL_RD_DMA_YSIZE_MASK GENMASK(29, 16)
271
272#define CAL_RD_DMA_INIT_ADDR_MASK GENMASK(31, 3)
273
274#define CAL_RD_DMA_INIT_OFST_MASK GENMASK(31, 3)
275
276#define CAL_RD_DMA_CTRL2_CIRC_MODE_MASK GENMASK(2, 0)
277#define CAL_RD_DMA_CTRL2_CIRC_MODE_DIS 0
278#define CAL_RD_DMA_CTRL2_CIRC_MODE_ONE 1
279#define CAL_RD_DMA_CTRL2_CIRC_MODE_FOUR 2
280#define CAL_RD_DMA_CTRL2_CIRC_MODE_SIXTEEN 3
281#define CAL_RD_DMA_CTRL2_CIRC_MODE_SIXTYFOUR 4
282#define CAL_RD_DMA_CTRL2_CIRC_MODE_RESERVED 5
283#define CAL_RD_DMA_CTRL2_ICM_CSTART_MASK BIT_MASK(3)
284#define CAL_RD_DMA_CTRL2_PATTERN_MASK GENMASK(5, 4)
285#define CAL_RD_DMA_CTRL2_PATTERN_LINEAR 0
286#define CAL_RD_DMA_CTRL2_PATTERN_YUV420 1
287#define CAL_RD_DMA_CTRL2_PATTERN_RD2SKIP2 2
288#define CAL_RD_DMA_CTRL2_PATTERN_RD2SKIP4 3
289#define CAL_RD_DMA_CTRL2_BYSOUT_LE_WAIT_MASK BIT_MASK(6)
290#define CAL_RD_DMA_CTRL2_BYSOUT_LE_WAIT_FREERUNNING 0
291#define CAL_RD_DMA_CTRL2_BYSOUT_LE_WAIT_WAITFORBYSOUT 1
292#define CAL_RD_DMA_CTRL2_CIRC_SIZE_MASK GENMASK(29, 16)
293
294#define CAL_WR_DMA_CTRL_MODE_MASK GENMASK(2, 0)
295#define CAL_WR_DMA_CTRL_MODE_DIS 0
296#define CAL_WR_DMA_CTRL_MODE_SHD 1
297#define CAL_WR_DMA_CTRL_MODE_CNT 2
298#define CAL_WR_DMA_CTRL_MODE_CNT_INIT 3
299#define CAL_WR_DMA_CTRL_MODE_CONST 4
300#define CAL_WR_DMA_CTRL_MODE_RESERVED 5
301#define CAL_WR_DMA_CTRL_PATTERN_MASK GENMASK(4, 3)
302#define CAL_WR_DMA_CTRL_PATTERN_LINEAR 0
303#define CAL_WR_DMA_CTRL_PATTERN_WR2SKIP2 2
304#define CAL_WR_DMA_CTRL_PATTERN_WR2SKIP4 3
305#define CAL_WR_DMA_CTRL_PATTERN_RESERVED 1
306#define CAL_WR_DMA_CTRL_ICM_PSTART_MASK BIT_MASK(5)
307#define CAL_WR_DMA_CTRL_DTAG_MASK GENMASK(8, 6)
308#define CAL_WR_DMA_CTRL_DTAG_ATT_HDR 0
309#define CAL_WR_DMA_CTRL_DTAG_ATT_DAT 1
310#define CAL_WR_DMA_CTRL_DTAG 2
311#define CAL_WR_DMA_CTRL_DTAG_PIX_HDR 3
312#define CAL_WR_DMA_CTRL_DTAG_PIX_DAT 4
313#define CAL_WR_DMA_CTRL_DTAG_D5 5
314#define CAL_WR_DMA_CTRL_DTAG_D6 6
315#define CAL_WR_DMA_CTRL_DTAG_D7 7
316#define CAL_WR_DMA_CTRL_CPORT_MASK GENMASK(13, 9)
317#define CAL_WR_DMA_CTRL_STALL_RD_MASK BIT_MASK(14)
318#define CAL_WR_DMA_CTRL_YSIZE_MASK GENMASK(31, 18)
319
320#define CAL_WR_DMA_ADDR_MASK GENMASK(31, 4)
321
322#define CAL_WR_DMA_OFST_MASK GENMASK(18, 4)
323#define CAL_WR_DMA_OFST_CIRC_MODE_MASK GENMASK(23, 22)
324#define CAL_WR_DMA_OFST_CIRC_MODE_ONE 1
325#define CAL_WR_DMA_OFST_CIRC_MODE_FOUR 2
326#define CAL_WR_DMA_OFST_CIRC_MODE_SIXTYFOUR 3
327#define CAL_WR_DMA_OFST_CIRC_MODE_DISABLED 0
328#define CAL_WR_DMA_OFST_CIRC_SIZE_MASK GENMASK(31, 24)
329
330#define CAL_WR_DMA_XSIZE_XSKIP_MASK GENMASK(15, 3)
331#define CAL_WR_DMA_XSIZE_MASK GENMASK(31, 19)
332
333#define CAL_CSI2_PPI_CTRL_IF_EN_MASK BIT_MASK(0)
334#define CAL_CSI2_PPI_CTRL_ECC_EN_MASK BIT_MASK(2)
335#define CAL_CSI2_PPI_CTRL_FRAME_MASK BIT_MASK(3)
336#define CAL_CSI2_PPI_CTRL_FRAME_IMMEDIATE 0
337#define CAL_CSI2_PPI_CTRL_FRAME 1
338
339#define CAL_CSI2_COMPLEXIO_CFG_CLOCK_POSITION_MASK GENMASK(2, 0)
340#define CAL_CSI2_COMPLEXIO_CFG_POSITION_5 5
341#define CAL_CSI2_COMPLEXIO_CFG_POSITION_4 4
342#define CAL_CSI2_COMPLEXIO_CFG_POSITION_3 3
343#define CAL_CSI2_COMPLEXIO_CFG_POSITION_2 2
344#define CAL_CSI2_COMPLEXIO_CFG_POSITION_1 1
345#define CAL_CSI2_COMPLEXIO_CFG_POSITION_NOT_USED 0
346#define CAL_CSI2_COMPLEXIO_CFG_CLOCK_POL_MASK BIT_MASK(3)
347#define CAL_CSI2_COMPLEXIO_CFG_POL_PLUSMINUS 0
348#define CAL_CSI2_COMPLEXIO_CFG_POL_MINUSPLUS 1
349#define CAL_CSI2_COMPLEXIO_CFG_DATA1_POSITION_MASK GENMASK(6, 4)
350#define CAL_CSI2_COMPLEXIO_CFG_DATA1_POL_MASK BIT_MASK(7)
351#define CAL_CSI2_COMPLEXIO_CFG_DATA2_POSITION_MASK GENMASK(10, 8)
352#define CAL_CSI2_COMPLEXIO_CFG_DATA2_POL_MASK BIT_MASK(11)
353#define CAL_CSI2_COMPLEXIO_CFG_DATA3_POSITION_MASK GENMASK(14, 12)
354#define CAL_CSI2_COMPLEXIO_CFG_DATA3_POL_MASK BIT_MASK(15)
355#define CAL_CSI2_COMPLEXIO_CFG_DATA4_POSITION_MASK GENMASK(18, 16)
356#define CAL_CSI2_COMPLEXIO_CFG_DATA4_POL_MASK BIT_MASK(19)
357#define CAL_CSI2_COMPLEXIO_CFG_PWR_AUTO_MASK BIT_MASK(24)
358#define CAL_CSI2_COMPLEXIO_CFG_PWR_STATUS_MASK GENMASK(26, 25)
359#define CAL_CSI2_COMPLEXIO_CFG_PWR_STATUS_STATE_OFF 0
360#define CAL_CSI2_COMPLEXIO_CFG_PWR_STATUS_STATE_ON 1
361#define CAL_CSI2_COMPLEXIO_CFG_PWR_STATUS_STATE_ULP 2
362#define CAL_CSI2_COMPLEXIO_CFG_PWR_CMD_MASK GENMASK(28, 27)
363#define CAL_CSI2_COMPLEXIO_CFG_PWR_CMD_STATE_OFF 0
364#define CAL_CSI2_COMPLEXIO_CFG_PWR_CMD_STATE_ON 1
365#define CAL_CSI2_COMPLEXIO_CFG_PWR_CMD_STATE_ULP 2
366#define CAL_CSI2_COMPLEXIO_CFG_RESET_DONE_MASK BIT_MASK(29)
367#define CAL_CSI2_COMPLEXIO_CFG_RESET_DONE_RESETCOMPLETED 1
368#define CAL_CSI2_COMPLEXIO_CFG_RESET_DONE_RESETONGOING 0
369#define CAL_CSI2_COMPLEXIO_CFG_RESET_CTRL_MASK BIT_MASK(30)
370#define CAL_CSI2_COMPLEXIO_CFG_RESET_CTRL 0
371#define CAL_CSI2_COMPLEXIO_CFG_RESET_CTRL_OPERATIONAL 1
372
373#define CAL_CSI2_SHORT_PACKET_MASK GENMASK(23, 0)
374
375#define CAL_CSI2_COMPLEXIO_IRQ_ERRSOTHS1_MASK BIT_MASK(0)
376#define CAL_CSI2_COMPLEXIO_IRQ_ERRSOTHS2_MASK BIT_MASK(1)
377#define CAL_CSI2_COMPLEXIO_IRQ_ERRSOTHS3_MASK BIT_MASK(2)
378#define CAL_CSI2_COMPLEXIO_IRQ_ERRSOTHS4_MASK BIT_MASK(3)
379#define CAL_CSI2_COMPLEXIO_IRQ_ERRSOTHS5_MASK BIT_MASK(4)
380#define CAL_CSI2_COMPLEXIO_IRQ_ERRSOTSYNCHS1_MASK BIT_MASK(5)
381#define CAL_CSI2_COMPLEXIO_IRQ_ERRSOTSYNCHS2_MASK BIT_MASK(6)
382#define CAL_CSI2_COMPLEXIO_IRQ_ERRSOTSYNCHS3_MASK BIT_MASK(7)
383#define CAL_CSI2_COMPLEXIO_IRQ_ERRSOTSYNCHS4_MASK BIT_MASK(8)
384#define CAL_CSI2_COMPLEXIO_IRQ_ERRSOTSYNCHS5_MASK BIT_MASK(9)
385#define CAL_CSI2_COMPLEXIO_IRQ_ERRESC1_MASK BIT_MASK(10)
386#define CAL_CSI2_COMPLEXIO_IRQ_ERRESC2_MASK BIT_MASK(11)
387#define CAL_CSI2_COMPLEXIO_IRQ_ERRESC3_MASK BIT_MASK(12)
388#define CAL_CSI2_COMPLEXIO_IRQ_ERRESC4_MASK BIT_MASK(13)
389#define CAL_CSI2_COMPLEXIO_IRQ_ERRESC5_MASK BIT_MASK(14)
390#define CAL_CSI2_COMPLEXIO_IRQ_ERRCONTROL1_MASK BIT_MASK(15)
391#define CAL_CSI2_COMPLEXIO_IRQ_ERRCONTROL2_MASK BIT_MASK(16)
392#define CAL_CSI2_COMPLEXIO_IRQ_ERRCONTROL3_MASK BIT_MASK(17)
393#define CAL_CSI2_COMPLEXIO_IRQ_ERRCONTROL4_MASK BIT_MASK(18)
394#define CAL_CSI2_COMPLEXIO_IRQ_ERRCONTROL5_MASK BIT_MASK(19)
395#define CAL_CSI2_COMPLEXIO_IRQ_STATEULPM1_MASK BIT_MASK(20)
396#define CAL_CSI2_COMPLEXIO_IRQ_STATEULPM2_MASK BIT_MASK(21)
397#define CAL_CSI2_COMPLEXIO_IRQ_STATEULPM3_MASK BIT_MASK(22)
398#define CAL_CSI2_COMPLEXIO_IRQ_STATEULPM4_MASK BIT_MASK(23)
399#define CAL_CSI2_COMPLEXIO_IRQ_STATEULPM5_MASK BIT_MASK(24)
400#define CAL_CSI2_COMPLEXIO_IRQ_STATEALLULPMENTER_MASK BIT_MASK(25)
401#define CAL_CSI2_COMPLEXIO_IRQ_STATEALLULPMEXIT_MASK BIT_MASK(26)
402#define CAL_CSI2_COMPLEXIO_IRQ_FIFO_OVR_MASK BIT_MASK(27)
403#define CAL_CSI2_COMPLEXIO_IRQ_SHORT_PACKET_MASK BIT_MASK(28)
404#define CAL_CSI2_COMPLEXIO_IRQ_ECC_NO_CORRECTION_MASK BIT_MASK(30)
405
406#define CAL_CSI2_TIMING_STOP_STATE_COUNTER_IO1_MASK GENMASK(12, 0)
407#define CAL_CSI2_TIMING_STOP_STATE_X4_IO1_MASK BIT_MASK(13)
408#define CAL_CSI2_TIMING_STOP_STATE_X16_IO1_MASK BIT_MASK(14)
409#define CAL_CSI2_TIMING_FORCE_RX_MODE_IO1_MASK BIT_MASK(15)
410
411#define CAL_CSI2_VC_IRQ_FS_IRQ_0_MASK BIT_MASK(0)
412#define CAL_CSI2_VC_IRQ_FE_IRQ_0_MASK BIT_MASK(1)
413#define CAL_CSI2_VC_IRQ_LS_IRQ_0_MASK BIT_MASK(2)
414#define CAL_CSI2_VC_IRQ_LE_IRQ_0_MASK BIT_MASK(3)
415#define CAL_CSI2_VC_IRQ_CS_IRQ_0_MASK BIT_MASK(4)
416#define CAL_CSI2_VC_IRQ_ECC_CORRECTION0_IRQ_0_MASK BIT_MASK(5)
417#define CAL_CSI2_VC_IRQ_FS_IRQ_1_MASK BIT_MASK(8)
418#define CAL_CSI2_VC_IRQ_FE_IRQ_1_MASK BIT_MASK(9)
419#define CAL_CSI2_VC_IRQ_LS_IRQ_1_MASK BIT_MASK(10)
420#define CAL_CSI2_VC_IRQ_LE_IRQ_1_MASK BIT_MASK(11)
421#define CAL_CSI2_VC_IRQ_CS_IRQ_1_MASK BIT_MASK(12)
422#define CAL_CSI2_VC_IRQ_ECC_CORRECTION0_IRQ_1_MASK BIT_MASK(13)
423#define CAL_CSI2_VC_IRQ_FS_IRQ_2_MASK BIT_MASK(16)
424#define CAL_CSI2_VC_IRQ_FE_IRQ_2_MASK BIT_MASK(17)
425#define CAL_CSI2_VC_IRQ_LS_IRQ_2_MASK BIT_MASK(18)
426#define CAL_CSI2_VC_IRQ_LE_IRQ_2_MASK BIT_MASK(19)
427#define CAL_CSI2_VC_IRQ_CS_IRQ_2_MASK BIT_MASK(20)
428#define CAL_CSI2_VC_IRQ_ECC_CORRECTION0_IRQ_2_MASK BIT_MASK(21)
429#define CAL_CSI2_VC_IRQ_FS_IRQ_3_MASK BIT_MASK(24)
430#define CAL_CSI2_VC_IRQ_FE_IRQ_3_MASK BIT_MASK(25)
431#define CAL_CSI2_VC_IRQ_LS_IRQ_3_MASK BIT_MASK(26)
432#define CAL_CSI2_VC_IRQ_LE_IRQ_3_MASK BIT_MASK(27)
433#define CAL_CSI2_VC_IRQ_CS_IRQ_3_MASK BIT_MASK(28)
434#define CAL_CSI2_VC_IRQ_ECC_CORRECTION0_IRQ_3_MASK BIT_MASK(29)
435
436#define CAL_CSI2_CTX_DT_MASK GENMASK(5, 0)
437#define CAL_CSI2_CTX_VC_MASK GENMASK(7, 6)
438#define CAL_CSI2_CTX_CPORT_MASK GENMASK(12, 8)
439#define CAL_CSI2_CTX_ATT_MASK BIT_MASK(13)
440#define CAL_CSI2_CTX_ATT_PIX 0
441#define CAL_CSI2_CTX_ATT 1
442#define CAL_CSI2_CTX_PACK_MODE_MASK BIT_MASK(14)
443#define CAL_CSI2_CTX_PACK_MODE_LINE 0
444#define CAL_CSI2_CTX_PACK_MODE_FRAME 1
445#define CAL_CSI2_CTX_LINES_MASK GENMASK(29, 16)
446
447#define CAL_CSI2_STATUS_FRAME_MASK GENMASK(15, 0)
448
449#define CAL_CSI2_PHY_REG0_THS_SETTLE_MASK GENMASK(7, 0)
450#define CAL_CSI2_PHY_REG0_THS_TERM_MASK GENMASK(15, 8)
451#define CAL_CSI2_PHY_REG0_HSCLOCKCONFIG_MASK BIT_MASK(24)
452#define CAL_CSI2_PHY_REG0_HSCLOCKCONFIG_DISABLE 1
453#define CAL_CSI2_PHY_REG0_HSCLOCKCONFIG_ENABLE 0
454
455#define CAL_CSI2_PHY_REG1_TCLK_SETTLE_MASK GENMASK(7, 0)
456#define CAL_CSI2_PHY_REG1_CTRLCLK_DIV_FACTOR_MASK GENMASK(9, 8)
457#define CAL_CSI2_PHY_REG1_DPHY_HS_SYNC_PATTERN_MASK GENMASK(17, 10)
458#define CAL_CSI2_PHY_REG1_TCLK_TERM_MASK GENMASK(24, 18)
459#define CAL_CSI2_PHY_REG1_CLOCK_MISS_DETECTOR_STATUS_MASK BIT_MASK(25)
460#define CAL_CSI2_PHY_REG1_CLOCK_MISS_DETECTOR_STATUS_ERROR 1
461#define CAL_CSI2_PHY_REG1_CLOCK_MISS_DETECTOR_STATUS_SUCCESS 0
462#define CAL_CSI2_PHY_REG1_RESET_DONE_STATUS_MASK GENMASK(29, 28)
463
464#define CAL_CSI2_PHY_REG2_CCP2_SYNC_PATTERN_MASK GENMASK(23, 0)
465#define CAL_CSI2_PHY_REG2_TRIGGER_CMD_RXTRIGESC3_MASK GENMASK(25, 24)
466#define CAL_CSI2_PHY_REG2_TRIGGER_CMD_RXTRIGESC2_MASK GENMASK(27, 26)
467#define CAL_CSI2_PHY_REG2_TRIGGER_CMD_RXTRIGESC1_MASK GENMASK(29, 28)
468#define CAL_CSI2_PHY_REG2_TRIGGER_CMD_RXTRIGESC0_MASK GENMASK(31, 30)
469
470#define CM_CAMERRX_CTRL_CSI1_CTRLCLKEN_MASK BIT_MASK(0)
471#define CM_CAMERRX_CTRL_CSI1_CAMMODE_MASK GENMASK(2, 1)
472#define CM_CAMERRX_CTRL_CSI1_LANEENABLE_MASK GENMASK(4, 3)
473#define CM_CAMERRX_CTRL_CSI1_MODE_MASK BIT_MASK(5)
474#define CM_CAMERRX_CTRL_CSI0_CTRLCLKEN_MASK BIT_MASK(10)
475#define CM_CAMERRX_CTRL_CSI0_CAMMODE_MASK GENMASK(12, 11)
476#define CM_CAMERRX_CTRL_CSI0_LANEENABLE_MASK GENMASK(16, 13)
477#define CM_CAMERRX_CTRL_CSI0_MODE_MASK BIT_MASK(17)
478
479#endif
diff --git a/drivers/media/platform/vim2m.c b/drivers/media/platform/vim2m.c
index 418113c99801..c4b5fab83666 100644
--- a/drivers/media/platform/vim2m.c
+++ b/drivers/media/platform/vim2m.c
@@ -1074,7 +1074,7 @@ static int __init vim2m_init(void)
1074 if (ret) 1074 if (ret)
1075 platform_device_unregister(&vim2m_pdev); 1075 platform_device_unregister(&vim2m_pdev);
1076 1076
1077 return 0; 1077 return ret;
1078} 1078}
1079 1079
1080module_init(vim2m_init); 1080module_init(vim2m_init);
diff --git a/drivers/media/platform/vivid/vivid-osd.c b/drivers/media/platform/vivid/vivid-osd.c
index e15eef6a94e5..bdc380b14e0c 100644
--- a/drivers/media/platform/vivid/vivid-osd.c
+++ b/drivers/media/platform/vivid/vivid-osd.c
@@ -360,7 +360,7 @@ void vivid_fb_release_buffers(struct vivid_dev *dev)
360 360
361 /* Release pseudo palette */ 361 /* Release pseudo palette */
362 kfree(dev->fb_info.pseudo_palette); 362 kfree(dev->fb_info.pseudo_palette);
363 kfree((void *)dev->video_vbase); 363 kfree(dev->video_vbase);
364} 364}
365 365
366/* Initialize the specified card */ 366/* Initialize the specified card */
diff --git a/drivers/media/platform/vivid/vivid-tpg.c b/drivers/media/platform/vivid/vivid-tpg.c
index 14256141f905..da862bb2e5f8 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -251,6 +251,10 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
251 tpg->planes = 3; 251 tpg->planes = 3;
252 tpg->is_yuv = true; 252 tpg->is_yuv = true;
253 break; 253 break;
254 case V4L2_PIX_FMT_YUV422M:
255 case V4L2_PIX_FMT_YVU422M:
256 tpg->buffers = 3;
257 /* fall through */
254 case V4L2_PIX_FMT_YUV422P: 258 case V4L2_PIX_FMT_YUV422P:
255 tpg->vdownsampling[1] = 1; 259 tpg->vdownsampling[1] = 1;
256 tpg->vdownsampling[2] = 1; 260 tpg->vdownsampling[2] = 1;
@@ -283,6 +287,16 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
283 tpg->planes = 2; 287 tpg->planes = 2;
284 tpg->is_yuv = true; 288 tpg->is_yuv = true;
285 break; 289 break;
290 case V4L2_PIX_FMT_YUV444M:
291 case V4L2_PIX_FMT_YVU444M:
292 tpg->buffers = 3;
293 tpg->planes = 3;
294 tpg->vdownsampling[1] = 1;
295 tpg->vdownsampling[2] = 1;
296 tpg->hdownsampling[1] = 1;
297 tpg->hdownsampling[2] = 1;
298 tpg->is_yuv = true;
299 break;
286 case V4L2_PIX_FMT_NV24: 300 case V4L2_PIX_FMT_NV24:
287 case V4L2_PIX_FMT_NV42: 301 case V4L2_PIX_FMT_NV42:
288 tpg->vdownsampling[1] = 1; 302 tpg->vdownsampling[1] = 1;
@@ -368,6 +382,10 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
368 tpg->twopixelsize[0] = 4; 382 tpg->twopixelsize[0] = 4;
369 tpg->twopixelsize[1] = 4; 383 tpg->twopixelsize[1] = 4;
370 break; 384 break;
385 case V4L2_PIX_FMT_YUV444M:
386 case V4L2_PIX_FMT_YVU444M:
387 case V4L2_PIX_FMT_YUV422M:
388 case V4L2_PIX_FMT_YVU422M:
371 case V4L2_PIX_FMT_YUV422P: 389 case V4L2_PIX_FMT_YUV422P:
372 case V4L2_PIX_FMT_YUV420: 390 case V4L2_PIX_FMT_YUV420:
373 case V4L2_PIX_FMT_YVU420: 391 case V4L2_PIX_FMT_YVU420:
@@ -933,6 +951,7 @@ static void gen_twopix(struct tpg_data *tpg,
933 buf[0][offset] = r_y; 951 buf[0][offset] = r_y;
934 buf[0][offset+1] = r_y == 0xff ? r_y : 0; 952 buf[0][offset+1] = r_y == 0xff ? r_y : 0;
935 break; 953 break;
954 case V4L2_PIX_FMT_YUV422M:
936 case V4L2_PIX_FMT_YUV422P: 955 case V4L2_PIX_FMT_YUV422P:
937 case V4L2_PIX_FMT_YUV420: 956 case V4L2_PIX_FMT_YUV420:
938 case V4L2_PIX_FMT_YUV420M: 957 case V4L2_PIX_FMT_YUV420M:
@@ -947,6 +966,7 @@ static void gen_twopix(struct tpg_data *tpg,
947 buf[1][0] = g_u; 966 buf[1][0] = g_u;
948 buf[2][0] = b_v; 967 buf[2][0] = b_v;
949 break; 968 break;
969 case V4L2_PIX_FMT_YVU422M:
950 case V4L2_PIX_FMT_YVU420: 970 case V4L2_PIX_FMT_YVU420:
951 case V4L2_PIX_FMT_YVU420M: 971 case V4L2_PIX_FMT_YVU420M:
952 buf[0][offset] = r_y; 972 buf[0][offset] = r_y;
@@ -988,6 +1008,18 @@ static void gen_twopix(struct tpg_data *tpg,
988 buf[1][1] = g_u; 1008 buf[1][1] = g_u;
989 break; 1009 break;
990 1010
1011 case V4L2_PIX_FMT_YUV444M:
1012 buf[0][offset] = r_y;
1013 buf[1][offset] = g_u;
1014 buf[2][offset] = b_v;
1015 break;
1016
1017 case V4L2_PIX_FMT_YVU444M:
1018 buf[0][offset] = r_y;
1019 buf[1][offset] = b_v;
1020 buf[2][offset] = g_u;
1021 break;
1022
991 case V4L2_PIX_FMT_NV24: 1023 case V4L2_PIX_FMT_NV24:
992 buf[0][offset] = r_y; 1024 buf[0][offset] = r_y;
993 buf[1][2 * offset] = g_u; 1025 buf[1][2 * offset] = g_u;
diff --git a/drivers/media/platform/vivid/vivid-tpg.h b/drivers/media/platform/vivid/vivid-tpg.h
index 9baed6a10334..93fbaee69675 100644
--- a/drivers/media/platform/vivid/vivid-tpg.h
+++ b/drivers/media/platform/vivid/vivid-tpg.h
@@ -418,6 +418,8 @@ static inline void tpg_s_bytesperline(struct tpg_data *tpg, unsigned plane, unsi
418 418
419 tpg->bytesperline[p] = plane_w / tpg->hdownsampling[p]; 419 tpg->bytesperline[p] = plane_w / tpg->hdownsampling[p];
420 } 420 }
421 if (tpg_g_interleaved(tpg))
422 tpg->bytesperline[1] = tpg->bytesperline[0];
421} 423}
422 424
423 425
diff --git a/drivers/media/platform/vivid/vivid-vid-common.c b/drivers/media/platform/vivid/vivid-vid-common.c
index 1678b730dba2..b0d4e3a0acf0 100644
--- a/drivers/media/platform/vivid/vivid-vid-common.c
+++ b/drivers/media/platform/vivid/vivid-vid-common.c
@@ -445,6 +445,9 @@ struct vivid_fmt vivid_formats[] = {
445 .planes = 1, 445 .planes = 1,
446 .buffers = 1, 446 .buffers = 1,
447 }, 447 },
448
449 /* Multiplanar formats */
450
448 { 451 {
449 .fourcc = V4L2_PIX_FMT_NV16M, 452 .fourcc = V4L2_PIX_FMT_NV16M,
450 .vdownsampling = { 1, 1 }, 453 .vdownsampling = { 1, 1 },
@@ -495,10 +498,42 @@ struct vivid_fmt vivid_formats[] = {
495 .planes = 2, 498 .planes = 2,
496 .buffers = 2, 499 .buffers = 2,
497 }, 500 },
501 {
502 .fourcc = V4L2_PIX_FMT_YUV422M,
503 .vdownsampling = { 1, 1, 1 },
504 .bit_depth = { 8, 4, 4 },
505 .is_yuv = true,
506 .planes = 3,
507 .buffers = 3,
508 },
509 {
510 .fourcc = V4L2_PIX_FMT_YVU422M,
511 .vdownsampling = { 1, 1, 1 },
512 .bit_depth = { 8, 4, 4 },
513 .is_yuv = true,
514 .planes = 3,
515 .buffers = 3,
516 },
517 {
518 .fourcc = V4L2_PIX_FMT_YUV444M,
519 .vdownsampling = { 1, 1, 1 },
520 .bit_depth = { 8, 8, 8 },
521 .is_yuv = true,
522 .planes = 3,
523 .buffers = 3,
524 },
525 {
526 .fourcc = V4L2_PIX_FMT_YVU444M,
527 .vdownsampling = { 1, 1, 1 },
528 .bit_depth = { 8, 8, 8 },
529 .is_yuv = true,
530 .planes = 3,
531 .buffers = 3,
532 },
498}; 533};
499 534
500/* There are 6 multiplanar formats in the list */ 535/* There are this many multiplanar formats in the list */
501#define VIVID_MPLANAR_FORMATS 6 536#define VIVID_MPLANAR_FORMATS 10
502 537
503const struct vivid_fmt *vivid_get_format(struct vivid_dev *dev, u32 pixelformat) 538const struct vivid_fmt *vivid_get_format(struct vivid_dev *dev, u32 pixelformat)
504{ 539{
diff --git a/drivers/media/platform/vsp1/Makefile b/drivers/media/platform/vsp1/Makefile
index 6a93f928dfde..95b3ac2ea7ef 100644
--- a/drivers/media/platform/vsp1/Makefile
+++ b/drivers/media/platform/vsp1/Makefile
@@ -1,4 +1,5 @@
1vsp1-y := vsp1_drv.o vsp1_entity.o vsp1_video.o 1vsp1-y := vsp1_drv.o vsp1_entity.o vsp1_pipe.o
2vsp1-y += vsp1_dl.o vsp1_drm.o vsp1_video.o
2vsp1-y += vsp1_rpf.o vsp1_rwpf.o vsp1_wpf.o 3vsp1-y += vsp1_rpf.o vsp1_rwpf.o vsp1_wpf.o
3vsp1-y += vsp1_hsit.o vsp1_lif.o vsp1_lut.o 4vsp1-y += vsp1_hsit.o vsp1_lif.o vsp1_lut.o
4vsp1-y += vsp1_bru.o vsp1_sru.o vsp1_uds.o 5vsp1-y += vsp1_bru.o vsp1_sru.o vsp1_uds.o
diff --git a/drivers/media/platform/vsp1/vsp1.h b/drivers/media/platform/vsp1/vsp1.h
index 989e96f7e360..910d6b8e8b50 100644
--- a/drivers/media/platform/vsp1/vsp1.h
+++ b/drivers/media/platform/vsp1/vsp1.h
@@ -26,6 +26,9 @@
26struct clk; 26struct clk;
27struct device; 27struct device;
28 28
29struct vsp1_dl;
30struct vsp1_drm;
31struct vsp1_entity;
29struct vsp1_platform_data; 32struct vsp1_platform_data;
30struct vsp1_bru; 33struct vsp1_bru;
31struct vsp1_hsit; 34struct vsp1_hsit;
@@ -42,17 +45,21 @@ struct vsp1_uds;
42#define VSP1_HAS_LIF (1 << 0) 45#define VSP1_HAS_LIF (1 << 0)
43#define VSP1_HAS_LUT (1 << 1) 46#define VSP1_HAS_LUT (1 << 1)
44#define VSP1_HAS_SRU (1 << 2) 47#define VSP1_HAS_SRU (1 << 2)
48#define VSP1_HAS_BRU (1 << 3)
45 49
46struct vsp1_platform_data { 50struct vsp1_device_info {
51 u32 version;
47 unsigned int features; 52 unsigned int features;
48 unsigned int rpf_count; 53 unsigned int rpf_count;
49 unsigned int uds_count; 54 unsigned int uds_count;
50 unsigned int wpf_count; 55 unsigned int wpf_count;
56 unsigned int num_bru_inputs;
57 bool uapi;
51}; 58};
52 59
53struct vsp1_device { 60struct vsp1_device {
54 struct device *dev; 61 struct device *dev;
55 struct vsp1_platform_data pdata; 62 const struct vsp1_device_info *info;
56 63
57 void __iomem *mmio; 64 void __iomem *mmio;
58 struct clk *clock; 65 struct clk *clock;
@@ -71,14 +78,22 @@ struct vsp1_device {
71 struct vsp1_rwpf *wpf[VSP1_MAX_WPF]; 78 struct vsp1_rwpf *wpf[VSP1_MAX_WPF];
72 79
73 struct list_head entities; 80 struct list_head entities;
81 struct list_head videos;
74 82
75 struct v4l2_device v4l2_dev; 83 struct v4l2_device v4l2_dev;
76 struct media_device media_dev; 84 struct media_device media_dev;
85 struct media_entity_operations media_ops;
86
87 struct vsp1_drm *drm;
88
89 bool use_dl;
77}; 90};
78 91
79int vsp1_device_get(struct vsp1_device *vsp1); 92int vsp1_device_get(struct vsp1_device *vsp1);
80void vsp1_device_put(struct vsp1_device *vsp1); 93void vsp1_device_put(struct vsp1_device *vsp1);
81 94
95int vsp1_reset_wpf(struct vsp1_device *vsp1, unsigned int index);
96
82static inline u32 vsp1_read(struct vsp1_device *vsp1, u32 reg) 97static inline u32 vsp1_read(struct vsp1_device *vsp1, u32 reg)
83{ 98{
84 return ioread32(vsp1->mmio + reg); 99 return ioread32(vsp1->mmio + reg);
@@ -89,4 +104,14 @@ static inline void vsp1_write(struct vsp1_device *vsp1, u32 reg, u32 data)
89 iowrite32(data, vsp1->mmio + reg); 104 iowrite32(data, vsp1->mmio + reg);
90} 105}
91 106
107#include "vsp1_dl.h"
108
109static inline void vsp1_mod_write(struct vsp1_entity *e, u32 reg, u32 data)
110{
111 if (e->vsp1->use_dl)
112 vsp1_dl_add(e, reg, data);
113 else
114 vsp1_write(e->vsp1, reg, data);
115}
116
92#endif /* __VSP1_H__ */ 117#endif /* __VSP1_H__ */
diff --git a/drivers/media/platform/vsp1/vsp1_bru.c b/drivers/media/platform/vsp1/vsp1_bru.c
index 7dd763311c0f..cb0dbc15ddad 100644
--- a/drivers/media/platform/vsp1/vsp1_bru.c
+++ b/drivers/media/platform/vsp1/vsp1_bru.c
@@ -19,6 +19,7 @@
19#include "vsp1.h" 19#include "vsp1.h"
20#include "vsp1_bru.h" 20#include "vsp1_bru.h"
21#include "vsp1_rwpf.h" 21#include "vsp1_rwpf.h"
22#include "vsp1_video.h"
22 23
23#define BRU_MIN_SIZE 1U 24#define BRU_MIN_SIZE 1U
24#define BRU_MAX_SIZE 8190U 25#define BRU_MAX_SIZE 8190U
@@ -27,14 +28,9 @@
27 * Device Access 28 * Device Access
28 */ 29 */
29 30
30static inline u32 vsp1_bru_read(struct vsp1_bru *bru, u32 reg)
31{
32 return vsp1_read(bru->entity.vsp1, reg);
33}
34
35static inline void vsp1_bru_write(struct vsp1_bru *bru, u32 reg, u32 data) 31static inline void vsp1_bru_write(struct vsp1_bru *bru, u32 reg, u32 data)
36{ 32{
37 vsp1_write(bru->entity.vsp1, reg, data); 33 vsp1_mod_write(&bru->entity, reg, data);
38} 34}
39 35
40/* ----------------------------------------------------------------------------- 36/* -----------------------------------------------------------------------------
@@ -83,7 +79,7 @@ static int bru_s_stream(struct v4l2_subdev *subdev, int enable)
83 if (!enable) 79 if (!enable)
84 return 0; 80 return 0;
85 81
86 format = &bru->entity.formats[BRU_PAD_SOURCE]; 82 format = &bru->entity.formats[bru->entity.source_pad];
87 83
88 /* The hardware is extremely flexible but we have no userspace API to 84 /* The hardware is extremely flexible but we have no userspace API to
89 * expose all the parameters, nor is it clear whether we would have use 85 * expose all the parameters, nor is it clear whether we would have use
@@ -94,7 +90,7 @@ static int bru_s_stream(struct v4l2_subdev *subdev, int enable)
94 /* Disable dithering and enable color data normalization unless the 90 /* Disable dithering and enable color data normalization unless the
95 * format at the pipeline output is premultiplied. 91 * format at the pipeline output is premultiplied.
96 */ 92 */
97 flags = pipe->output ? pipe->output->video.format.flags : 0; 93 flags = pipe->output ? pipe->output->format.flags : 0;
98 vsp1_bru_write(bru, VI6_BRU_INCTRL, 94 vsp1_bru_write(bru, VI6_BRU_INCTRL,
99 flags & V4L2_PIX_FMT_FLAG_PREMUL_ALPHA ? 95 flags & V4L2_PIX_FMT_FLAG_PREMUL_ALPHA ?
100 0 : VI6_BRU_INCTRL_NRM); 96 0 : VI6_BRU_INCTRL_NRM);
@@ -113,7 +109,7 @@ static int bru_s_stream(struct v4l2_subdev *subdev, int enable)
113 VI6_BRU_ROP_CROP(VI6_ROP_NOP) | 109 VI6_BRU_ROP_CROP(VI6_ROP_NOP) |
114 VI6_BRU_ROP_AROP(VI6_ROP_NOP)); 110 VI6_BRU_ROP_AROP(VI6_ROP_NOP));
115 111
116 for (i = 0; i < 4; ++i) { 112 for (i = 0; i < bru->entity.source_pad; ++i) {
117 bool premultiplied = false; 113 bool premultiplied = false;
118 u32 ctrl = 0; 114 u32 ctrl = 0;
119 115
@@ -125,7 +121,7 @@ static int bru_s_stream(struct v4l2_subdev *subdev, int enable)
125 if (bru->inputs[i].rpf) { 121 if (bru->inputs[i].rpf) {
126 ctrl |= VI6_BRU_CTRL_RBC; 122 ctrl |= VI6_BRU_CTRL_RBC;
127 123
128 premultiplied = bru->inputs[i].rpf->video.format.flags 124 premultiplied = bru->inputs[i].rpf->format.flags
129 & V4L2_PIX_FMT_FLAG_PREMUL_ALPHA; 125 & V4L2_PIX_FMT_FLAG_PREMUL_ALPHA;
130 } else { 126 } else {
131 ctrl |= VI6_BRU_CTRL_CROP(VI6_ROP_NOP) 127 ctrl |= VI6_BRU_CTRL_CROP(VI6_ROP_NOP)
@@ -295,7 +291,7 @@ static int bru_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_con
295 *format = fmt->format; 291 *format = fmt->format;
296 292
297 /* Reset the compose rectangle */ 293 /* Reset the compose rectangle */
298 if (fmt->pad != BRU_PAD_SOURCE) { 294 if (fmt->pad != bru->entity.source_pad) {
299 struct v4l2_rect *compose; 295 struct v4l2_rect *compose;
300 296
301 compose = bru_get_compose(bru, cfg, fmt->pad, fmt->which); 297 compose = bru_get_compose(bru, cfg, fmt->pad, fmt->which);
@@ -309,7 +305,7 @@ static int bru_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_con
309 if (fmt->pad == BRU_PAD_SINK(0)) { 305 if (fmt->pad == BRU_PAD_SINK(0)) {
310 unsigned int i; 306 unsigned int i;
311 307
312 for (i = 0; i <= BRU_PAD_SOURCE; ++i) { 308 for (i = 0; i <= bru->entity.source_pad; ++i) {
313 format = vsp1_entity_get_pad_format(&bru->entity, cfg, 309 format = vsp1_entity_get_pad_format(&bru->entity, cfg,
314 i, fmt->which); 310 i, fmt->which);
315 format->code = fmt->format.code; 311 format->code = fmt->format.code;
@@ -325,7 +321,7 @@ static int bru_get_selection(struct v4l2_subdev *subdev,
325{ 321{
326 struct vsp1_bru *bru = to_bru(subdev); 322 struct vsp1_bru *bru = to_bru(subdev);
327 323
328 if (sel->pad == BRU_PAD_SOURCE) 324 if (sel->pad == bru->entity.source_pad)
329 return -EINVAL; 325 return -EINVAL;
330 326
331 switch (sel->target) { 327 switch (sel->target) {
@@ -353,7 +349,7 @@ static int bru_set_selection(struct v4l2_subdev *subdev,
353 struct v4l2_mbus_framefmt *format; 349 struct v4l2_mbus_framefmt *format;
354 struct v4l2_rect *compose; 350 struct v4l2_rect *compose;
355 351
356 if (sel->pad == BRU_PAD_SOURCE) 352 if (sel->pad == bru->entity.source_pad)
357 return -EINVAL; 353 return -EINVAL;
358 354
359 if (sel->target != V4L2_SEL_TGT_COMPOSE) 355 if (sel->target != V4L2_SEL_TGT_COMPOSE)
@@ -362,8 +358,8 @@ static int bru_set_selection(struct v4l2_subdev *subdev,
362 /* The compose rectangle top left corner must be inside the output 358 /* The compose rectangle top left corner must be inside the output
363 * frame. 359 * frame.
364 */ 360 */
365 format = vsp1_entity_get_pad_format(&bru->entity, cfg, BRU_PAD_SOURCE, 361 format = vsp1_entity_get_pad_format(&bru->entity, cfg,
366 sel->which); 362 bru->entity.source_pad, sel->which);
367 sel->r.left = clamp_t(unsigned int, sel->r.left, 0, format->width - 1); 363 sel->r.left = clamp_t(unsigned int, sel->r.left, 0, format->width - 1);
368 sel->r.top = clamp_t(unsigned int, sel->r.top, 0, format->height - 1); 364 sel->r.top = clamp_t(unsigned int, sel->r.top, 0, format->height - 1);
369 365
@@ -419,7 +415,8 @@ struct vsp1_bru *vsp1_bru_create(struct vsp1_device *vsp1)
419 415
420 bru->entity.type = VSP1_ENTITY_BRU; 416 bru->entity.type = VSP1_ENTITY_BRU;
421 417
422 ret = vsp1_entity_init(vsp1, &bru->entity, 5); 418 ret = vsp1_entity_init(vsp1, &bru->entity,
419 vsp1->info->num_bru_inputs + 1);
423 if (ret < 0) 420 if (ret < 0)
424 return ERR_PTR(ret); 421 return ERR_PTR(ret);
425 422
@@ -427,7 +424,7 @@ struct vsp1_bru *vsp1_bru_create(struct vsp1_device *vsp1)
427 subdev = &bru->entity.subdev; 424 subdev = &bru->entity.subdev;
428 v4l2_subdev_init(subdev, &bru_ops); 425 v4l2_subdev_init(subdev, &bru_ops);
429 426
430 subdev->entity.ops = &vsp1_media_ops; 427 subdev->entity.ops = &vsp1->media_ops;
431 subdev->internal_ops = &vsp1_subdev_internal_ops; 428 subdev->internal_ops = &vsp1_subdev_internal_ops;
432 snprintf(subdev->name, sizeof(subdev->name), "%s bru", 429 snprintf(subdev->name, sizeof(subdev->name), "%s bru",
433 dev_name(vsp1->dev)); 430 dev_name(vsp1->dev));
diff --git a/drivers/media/platform/vsp1/vsp1_bru.h b/drivers/media/platform/vsp1/vsp1_bru.h
index 16b1c6554911..dbac9686ea69 100644
--- a/drivers/media/platform/vsp1/vsp1_bru.h
+++ b/drivers/media/platform/vsp1/vsp1_bru.h
@@ -23,7 +23,6 @@ struct vsp1_device;
23struct vsp1_rwpf; 23struct vsp1_rwpf;
24 24
25#define BRU_PAD_SINK(n) (n) 25#define BRU_PAD_SINK(n) (n)
26#define BRU_PAD_SOURCE 4
27 26
28struct vsp1_bru { 27struct vsp1_bru {
29 struct vsp1_entity entity; 28 struct vsp1_entity entity;
@@ -33,7 +32,7 @@ struct vsp1_bru {
33 struct { 32 struct {
34 struct vsp1_rwpf *rpf; 33 struct vsp1_rwpf *rpf;
35 struct v4l2_rect compose; 34 struct v4l2_rect compose;
36 } inputs[4]; 35 } inputs[VSP1_MAX_RPF];
37}; 36};
38 37
39static inline struct vsp1_bru *to_bru(struct v4l2_subdev *subdev) 38static inline struct vsp1_bru *to_bru(struct v4l2_subdev *subdev)
diff --git a/drivers/media/platform/vsp1/vsp1_dl.c b/drivers/media/platform/vsp1/vsp1_dl.c
new file mode 100644
index 000000000000..7dc27ac6bd02
--- /dev/null
+++ b/drivers/media/platform/vsp1/vsp1_dl.c
@@ -0,0 +1,305 @@
1/*
2 * vsp1_dl.h -- R-Car VSP1 Display List
3 *
4 * Copyright (C) 2015 Renesas Corporation
5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
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
14#include <linux/device.h>
15#include <linux/dma-mapping.h>
16#include <linux/gfp.h>
17#include <linux/slab.h>
18
19#include "vsp1.h"
20#include "vsp1_dl.h"
21#include "vsp1_pipe.h"
22
23/*
24 * Global resources
25 *
26 * - Display-related interrupts (can be used for vblank evasion ?)
27 * - Display-list enable
28 * - Header-less for WPF0
29 * - DL swap
30 */
31
32#define VSP1_DL_BODY_SIZE (2 * 4 * 256)
33#define VSP1_DL_NUM_LISTS 3
34
35struct vsp1_dl_entry {
36 u32 addr;
37 u32 data;
38} __attribute__((__packed__));
39
40struct vsp1_dl_list {
41 size_t size;
42 int reg_count;
43
44 bool in_use;
45
46 struct vsp1_dl_entry *body;
47 dma_addr_t dma;
48};
49
50/**
51 * struct vsp1_dl - Display List manager
52 * @vsp1: the VSP1 device
53 * @lock: protects the active, queued and pending lists
54 * @lists.all: array of all allocate display lists
55 * @lists.active: list currently being processed (loaded) by hardware
56 * @lists.queued: list queued to the hardware (written to the DL registers)
57 * @lists.pending: list waiting to be queued to the hardware
58 * @lists.write: list being written to by software
59 */
60struct vsp1_dl {
61 struct vsp1_device *vsp1;
62
63 spinlock_t lock;
64
65 size_t size;
66 dma_addr_t dma;
67 void *mem;
68
69 struct {
70 struct vsp1_dl_list all[VSP1_DL_NUM_LISTS];
71
72 struct vsp1_dl_list *active;
73 struct vsp1_dl_list *queued;
74 struct vsp1_dl_list *pending;
75 struct vsp1_dl_list *write;
76 } lists;
77};
78
79/* -----------------------------------------------------------------------------
80 * Display List Transaction Management
81 */
82
83static void vsp1_dl_free_list(struct vsp1_dl_list *list)
84{
85 if (!list)
86 return;
87
88 list->in_use = false;
89}
90
91void vsp1_dl_reset(struct vsp1_dl *dl)
92{
93 unsigned int i;
94
95 dl->lists.active = NULL;
96 dl->lists.queued = NULL;
97 dl->lists.pending = NULL;
98 dl->lists.write = NULL;
99
100 for (i = 0; i < ARRAY_SIZE(dl->lists.all); ++i)
101 dl->lists.all[i].in_use = false;
102}
103
104void vsp1_dl_begin(struct vsp1_dl *dl)
105{
106 struct vsp1_dl_list *list = NULL;
107 unsigned long flags;
108 unsigned int i;
109
110 spin_lock_irqsave(&dl->lock, flags);
111
112 for (i = 0; i < ARRAY_SIZE(dl->lists.all); ++i) {
113 if (!dl->lists.all[i].in_use) {
114 list = &dl->lists.all[i];
115 break;
116 }
117 }
118
119 if (!list) {
120 list = dl->lists.pending;
121 dl->lists.pending = NULL;
122 }
123
124 spin_unlock_irqrestore(&dl->lock, flags);
125
126 dl->lists.write = list;
127
128 list->in_use = true;
129 list->reg_count = 0;
130}
131
132void vsp1_dl_add(struct vsp1_entity *e, u32 reg, u32 data)
133{
134 struct vsp1_pipeline *pipe = to_vsp1_pipeline(&e->subdev.entity);
135 struct vsp1_dl *dl = pipe->dl;
136 struct vsp1_dl_list *list = dl->lists.write;
137
138 list->body[list->reg_count].addr = reg;
139 list->body[list->reg_count].data = data;
140 list->reg_count++;
141}
142
143void vsp1_dl_commit(struct vsp1_dl *dl)
144{
145 struct vsp1_device *vsp1 = dl->vsp1;
146 struct vsp1_dl_list *list;
147 unsigned long flags;
148 bool update;
149
150 list = dl->lists.write;
151 dl->lists.write = NULL;
152
153 spin_lock_irqsave(&dl->lock, flags);
154
155 /* Once the UPD bit has been set the hardware can start processing the
156 * display list at any time and we can't touch the address and size
157 * registers. In that case mark the update as pending, it will be
158 * queued up to the hardware by the frame end interrupt handler.
159 */
160 update = !!(vsp1_read(vsp1, VI6_DL_BODY_SIZE) & VI6_DL_BODY_SIZE_UPD);
161 if (update) {
162 vsp1_dl_free_list(dl->lists.pending);
163 dl->lists.pending = list;
164 goto done;
165 }
166
167 /* Program the hardware with the display list body address and size.
168 * The UPD bit will be cleared by the device when the display list is
169 * processed.
170 */
171 vsp1_write(vsp1, VI6_DL_HDR_ADDR(0), list->dma);
172 vsp1_write(vsp1, VI6_DL_BODY_SIZE, VI6_DL_BODY_SIZE_UPD |
173 (list->reg_count * 8));
174
175 vsp1_dl_free_list(dl->lists.queued);
176 dl->lists.queued = list;
177
178done:
179 spin_unlock_irqrestore(&dl->lock, flags);
180}
181
182/* -----------------------------------------------------------------------------
183 * Interrupt Handling
184 */
185
186void vsp1_dl_irq_display_start(struct vsp1_dl *dl)
187{
188 spin_lock(&dl->lock);
189
190 /* The display start interrupt signals the end of the display list
191 * processing by the device. The active display list, if any, won't be
192 * accessed anymore and can be reused.
193 */
194 if (dl->lists.active) {
195 vsp1_dl_free_list(dl->lists.active);
196 dl->lists.active = NULL;
197 }
198
199 spin_unlock(&dl->lock);
200}
201
202void vsp1_dl_irq_frame_end(struct vsp1_dl *dl)
203{
204 struct vsp1_device *vsp1 = dl->vsp1;
205
206 spin_lock(&dl->lock);
207
208 /* The UPD bit set indicates that the commit operation raced with the
209 * interrupt and occurred after the frame end event and UPD clear but
210 * before interrupt processing. The hardware hasn't taken the update
211 * into account yet, we'll thus skip one frame and retry.
212 */
213 if (vsp1_read(vsp1, VI6_DL_BODY_SIZE) & VI6_DL_BODY_SIZE_UPD)
214 goto done;
215
216 /* The device starts processing the queued display list right after the
217 * frame end interrupt. The display list thus becomes active.
218 */
219 if (dl->lists.queued) {
220 WARN_ON(dl->lists.active);
221 dl->lists.active = dl->lists.queued;
222 dl->lists.queued = NULL;
223 }
224
225 /* Now that the UPD bit has been cleared we can queue the next display
226 * list to the hardware if one has been prepared.
227 */
228 if (dl->lists.pending) {
229 struct vsp1_dl_list *list = dl->lists.pending;
230
231 vsp1_write(vsp1, VI6_DL_HDR_ADDR(0), list->dma);
232 vsp1_write(vsp1, VI6_DL_BODY_SIZE, VI6_DL_BODY_SIZE_UPD |
233 (list->reg_count * 8));
234
235 dl->lists.queued = list;
236 dl->lists.pending = NULL;
237 }
238
239done:
240 spin_unlock(&dl->lock);
241}
242
243/* -----------------------------------------------------------------------------
244 * Hardware Setup
245 */
246
247void vsp1_dl_setup(struct vsp1_device *vsp1)
248{
249 u32 ctrl = (256 << VI6_DL_CTRL_AR_WAIT_SHIFT)
250 | VI6_DL_CTRL_DC2 | VI6_DL_CTRL_DC1 | VI6_DL_CTRL_DC0
251 | VI6_DL_CTRL_DLE;
252
253 /* The DRM pipeline operates with header-less display lists in
254 * Continuous Frame Mode.
255 */
256 if (vsp1->drm)
257 ctrl |= VI6_DL_CTRL_CFM0 | VI6_DL_CTRL_NH0;
258
259 vsp1_write(vsp1, VI6_DL_CTRL, ctrl);
260 vsp1_write(vsp1, VI6_DL_SWAP, VI6_DL_SWAP_LWS);
261}
262
263/* -----------------------------------------------------------------------------
264 * Initialization and Cleanup
265 */
266
267struct vsp1_dl *vsp1_dl_create(struct vsp1_device *vsp1)
268{
269 struct vsp1_dl *dl;
270 unsigned int i;
271
272 dl = kzalloc(sizeof(*dl), GFP_KERNEL);
273 if (!dl)
274 return NULL;
275
276 spin_lock_init(&dl->lock);
277
278 dl->vsp1 = vsp1;
279 dl->size = VSP1_DL_BODY_SIZE * ARRAY_SIZE(dl->lists.all);
280
281 dl->mem = dma_alloc_writecombine(vsp1->dev, dl->size, &dl->dma,
282 GFP_KERNEL);
283 if (!dl->mem) {
284 kfree(dl);
285 return NULL;
286 }
287
288 for (i = 0; i < ARRAY_SIZE(dl->lists.all); ++i) {
289 struct vsp1_dl_list *list = &dl->lists.all[i];
290
291 list->size = VSP1_DL_BODY_SIZE;
292 list->reg_count = 0;
293 list->in_use = false;
294 list->dma = dl->dma + VSP1_DL_BODY_SIZE * i;
295 list->body = dl->mem + VSP1_DL_BODY_SIZE * i;
296 }
297
298 return dl;
299}
300
301void vsp1_dl_destroy(struct vsp1_dl *dl)
302{
303 dma_free_writecombine(dl->vsp1->dev, dl->size, dl->mem, dl->dma);
304 kfree(dl);
305}
diff --git a/drivers/media/platform/vsp1/vsp1_dl.h b/drivers/media/platform/vsp1/vsp1_dl.h
new file mode 100644
index 000000000000..448c4250e54c
--- /dev/null
+++ b/drivers/media/platform/vsp1/vsp1_dl.h
@@ -0,0 +1,42 @@
1/*
2 * vsp1_dl.h -- R-Car VSP1 Display List
3 *
4 * Copyright (C) 2015 Renesas Corporation
5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
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#ifndef __VSP1_DL_H__
14#define __VSP1_DL_H__
15
16#include "vsp1_entity.h"
17
18struct vsp1_device;
19struct vsp1_dl;
20
21struct vsp1_dl *vsp1_dl_create(struct vsp1_device *vsp1);
22void vsp1_dl_destroy(struct vsp1_dl *dl);
23
24void vsp1_dl_setup(struct vsp1_device *vsp1);
25
26void vsp1_dl_reset(struct vsp1_dl *dl);
27void vsp1_dl_begin(struct vsp1_dl *dl);
28void vsp1_dl_add(struct vsp1_entity *e, u32 reg, u32 data);
29void vsp1_dl_commit(struct vsp1_dl *dl);
30
31void vsp1_dl_irq_display_start(struct vsp1_dl *dl);
32void vsp1_dl_irq_frame_end(struct vsp1_dl *dl);
33
34static inline void vsp1_dl_mod_write(struct vsp1_entity *e, u32 reg, u32 data)
35{
36 if (e->vsp1->use_dl)
37 vsp1_dl_add(e, reg, data);
38 else
39 vsp1_write(e->vsp1, reg, data);
40}
41
42#endif /* __VSP1_DL_H__ */
diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c
new file mode 100644
index 000000000000..021fe5778cd1
--- /dev/null
+++ b/drivers/media/platform/vsp1/vsp1_drm.c
@@ -0,0 +1,597 @@
1/*
2 * vsp1_drm.c -- R-Car VSP1 DRM API
3 *
4 * Copyright (C) 2015 Renesas Electronics Corporation
5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
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
14#include <linux/device.h>
15#include <linux/slab.h>
16#include <linux/vsp1.h>
17
18#include <media/media-entity.h>
19#include <media/v4l2-subdev.h>
20
21#include "vsp1.h"
22#include "vsp1_bru.h"
23#include "vsp1_dl.h"
24#include "vsp1_drm.h"
25#include "vsp1_lif.h"
26#include "vsp1_pipe.h"
27#include "vsp1_rwpf.h"
28
29/* -----------------------------------------------------------------------------
30 * Runtime Handling
31 */
32
33static void vsp1_drm_pipeline_frame_end(struct vsp1_pipeline *pipe)
34{
35 unsigned long flags;
36
37 spin_lock_irqsave(&pipe->irqlock, flags);
38 if (pipe->num_inputs)
39 vsp1_pipeline_run(pipe);
40 spin_unlock_irqrestore(&pipe->irqlock, flags);
41}
42
43/* -----------------------------------------------------------------------------
44 * DU Driver API
45 */
46
47int vsp1_du_init(struct device *dev)
48{
49 struct vsp1_device *vsp1 = dev_get_drvdata(dev);
50
51 if (!vsp1)
52 return -EPROBE_DEFER;
53
54 return 0;
55}
56EXPORT_SYMBOL_GPL(vsp1_du_init);
57
58/**
59 * vsp1_du_setup_lif - Setup the output part of the VSP pipeline
60 * @dev: the VSP device
61 * @width: output frame width in pixels
62 * @height: output frame height in pixels
63 *
64 * Configure the output part of VSP DRM pipeline for the given frame @width and
65 * @height. This sets up formats on the BRU source pad, the WPF0 sink and source
66 * pads, and the LIF sink pad.
67 *
68 * As the media bus code on the BRU source pad is conditioned by the
69 * configuration of the BRU sink 0 pad, we also set up the formats on all BRU
70 * sinks, even if the configuration will be overwritten later by
71 * vsp1_du_setup_rpf(). This ensures that the BRU configuration is set to a well
72 * defined state.
73 *
74 * Return 0 on success or a negative error code on failure.
75 */
76int vsp1_du_setup_lif(struct device *dev, unsigned int width,
77 unsigned int height)
78{
79 struct vsp1_device *vsp1 = dev_get_drvdata(dev);
80 struct vsp1_pipeline *pipe = &vsp1->drm->pipe;
81 struct vsp1_bru *bru = vsp1->bru;
82 struct v4l2_subdev_format format;
83 unsigned int i;
84 int ret;
85
86 dev_dbg(vsp1->dev, "%s: configuring LIF with format %ux%u\n",
87 __func__, width, height);
88
89 if (width == 0 || height == 0) {
90 /* Zero width or height means the CRTC is being disabled, stop
91 * the pipeline and turn the light off.
92 */
93 ret = vsp1_pipeline_stop(pipe);
94 if (ret == -ETIMEDOUT)
95 dev_err(vsp1->dev, "DRM pipeline stop timeout\n");
96
97 media_entity_pipeline_stop(&pipe->output->entity.subdev.entity);
98
99 for (i = 0; i < bru->entity.source_pad; ++i) {
100 bru->inputs[i].rpf = NULL;
101 pipe->inputs[i] = NULL;
102 }
103
104 pipe->num_inputs = 0;
105
106 vsp1_device_put(vsp1);
107
108 dev_dbg(vsp1->dev, "%s: pipeline disabled\n", __func__);
109
110 return 0;
111 }
112
113 vsp1_dl_reset(vsp1->drm->dl);
114
115 /* Configure the format at the BRU sinks and propagate it through the
116 * pipeline.
117 */
118 memset(&format, 0, sizeof(format));
119 format.which = V4L2_SUBDEV_FORMAT_ACTIVE;
120
121 for (i = 0; i < bru->entity.source_pad; ++i) {
122 format.pad = i;
123
124 format.format.width = width;
125 format.format.height = height;
126 format.format.code = MEDIA_BUS_FMT_ARGB8888_1X32;
127 format.format.field = V4L2_FIELD_NONE;
128
129 ret = v4l2_subdev_call(&bru->entity.subdev, pad,
130 set_fmt, NULL, &format);
131 if (ret < 0)
132 return ret;
133
134 dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on BRU pad %u\n",
135 __func__, format.format.width, format.format.height,
136 format.format.code, i);
137 }
138
139 format.pad = bru->entity.source_pad;
140 format.format.width = width;
141 format.format.height = height;
142 format.format.code = MEDIA_BUS_FMT_ARGB8888_1X32;
143 format.format.field = V4L2_FIELD_NONE;
144
145 ret = v4l2_subdev_call(&bru->entity.subdev, pad, set_fmt, NULL,
146 &format);
147 if (ret < 0)
148 return ret;
149
150 dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on BRU pad %u\n",
151 __func__, format.format.width, format.format.height,
152 format.format.code, i);
153
154 format.pad = RWPF_PAD_SINK;
155 ret = v4l2_subdev_call(&vsp1->wpf[0]->entity.subdev, pad, set_fmt, NULL,
156 &format);
157 if (ret < 0)
158 return ret;
159
160 dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on WPF0 sink\n",
161 __func__, format.format.width, format.format.height,
162 format.format.code);
163
164 format.pad = RWPF_PAD_SOURCE;
165 ret = v4l2_subdev_call(&vsp1->wpf[0]->entity.subdev, pad, get_fmt, NULL,
166 &format);
167 if (ret < 0)
168 return ret;
169
170 dev_dbg(vsp1->dev, "%s: got format %ux%u (%x) on WPF0 source\n",
171 __func__, format.format.width, format.format.height,
172 format.format.code);
173
174 format.pad = LIF_PAD_SINK;
175 ret = v4l2_subdev_call(&vsp1->lif->entity.subdev, pad, set_fmt, NULL,
176 &format);
177 if (ret < 0)
178 return ret;
179
180 dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on LIF sink\n",
181 __func__, format.format.width, format.format.height,
182 format.format.code);
183
184 /* Verify that the format at the output of the pipeline matches the
185 * requested frame size and media bus code.
186 */
187 if (format.format.width != width || format.format.height != height ||
188 format.format.code != MEDIA_BUS_FMT_ARGB8888_1X32) {
189 dev_dbg(vsp1->dev, "%s: format mismatch\n", __func__);
190 return -EPIPE;
191 }
192
193 /* Mark the pipeline as streaming and enable the VSP1. This will store
194 * the pipeline pointer in all entities, which the s_stream handlers
195 * will need. We don't start the entities themselves right at this point
196 * as there's no plane configured yet, so we can't start processing
197 * buffers.
198 */
199 ret = vsp1_device_get(vsp1);
200 if (ret < 0)
201 return ret;
202
203 ret = media_entity_pipeline_start(&pipe->output->entity.subdev.entity,
204 &pipe->pipe);
205 if (ret < 0) {
206 dev_dbg(vsp1->dev, "%s: pipeline start failed\n", __func__);
207 vsp1_device_put(vsp1);
208 return ret;
209 }
210
211 dev_dbg(vsp1->dev, "%s: pipeline enabled\n", __func__);
212
213 return 0;
214}
215EXPORT_SYMBOL_GPL(vsp1_du_setup_lif);
216
217/**
218 * vsp1_du_atomic_begin - Prepare for an atomic update
219 * @dev: the VSP device
220 */
221void vsp1_du_atomic_begin(struct device *dev)
222{
223 struct vsp1_device *vsp1 = dev_get_drvdata(dev);
224 struct vsp1_pipeline *pipe = &vsp1->drm->pipe;
225 unsigned long flags;
226
227 spin_lock_irqsave(&pipe->irqlock, flags);
228
229 vsp1->drm->num_inputs = pipe->num_inputs;
230
231 spin_unlock_irqrestore(&pipe->irqlock, flags);
232
233 /* Prepare the display list. */
234 vsp1_dl_begin(vsp1->drm->dl);
235}
236EXPORT_SYMBOL_GPL(vsp1_du_atomic_begin);
237
238/**
239 * vsp1_du_atomic_update - Setup one RPF input of the VSP pipeline
240 * @dev: the VSP device
241 * @rpf_index: index of the RPF to setup (0-based)
242 * @pixelformat: V4L2 pixel format for the RPF memory input
243 * @pitch: number of bytes per line in the image stored in memory
244 * @mem: DMA addresses of the memory buffers (one per plane)
245 * @src: the source crop rectangle for the RPF
246 * @dst: the destination compose rectangle for the BRU input
247 *
248 * Configure the VSP to perform composition of the image referenced by @mem
249 * through RPF @rpf_index, using the @src crop rectangle and the @dst
250 * composition rectangle. The Z-order is fixed with RPF 0 at the bottom.
251 *
252 * Image format as stored in memory is expressed as a V4L2 @pixelformat value.
253 * As a special case, setting the pixel format to 0 will disable the RPF. The
254 * @pitch, @mem, @src and @dst parameters are ignored in that case. Calling the
255 * function on a disabled RPF is allowed.
256 *
257 * The memory pitch is configurable to allow for padding at end of lines, or
258 * simple for images that extend beyond the crop rectangle boundaries. The
259 * @pitch value is expressed in bytes and applies to all planes for multiplanar
260 * formats.
261 *
262 * The source memory buffer is referenced by the DMA address of its planes in
263 * the @mem array. Up to two planes are supported. The second plane DMA address
264 * is ignored for formats using a single plane.
265 *
266 * This function isn't reentrant, the caller needs to serialize calls.
267 *
268 * TODO: Implement Z-order control by decoupling the RPF index from the BRU
269 * input index.
270 *
271 * Return 0 on success or a negative error code on failure.
272 */
273int vsp1_du_atomic_update(struct device *dev, unsigned int rpf_index,
274 u32 pixelformat, unsigned int pitch,
275 dma_addr_t mem[2], const struct v4l2_rect *src,
276 const struct v4l2_rect *dst)
277{
278 struct vsp1_device *vsp1 = dev_get_drvdata(dev);
279 struct vsp1_pipeline *pipe = &vsp1->drm->pipe;
280 const struct vsp1_format_info *fmtinfo;
281 struct v4l2_subdev_selection sel;
282 struct v4l2_subdev_format format;
283 struct vsp1_rwpf_memory memory;
284 struct vsp1_rwpf *rpf;
285 unsigned long flags;
286 int ret;
287
288 if (rpf_index >= vsp1->info->rpf_count)
289 return -EINVAL;
290
291 rpf = vsp1->rpf[rpf_index];
292
293 if (pixelformat == 0) {
294 dev_dbg(vsp1->dev, "%s: RPF%u: disable requested\n", __func__,
295 rpf_index);
296
297 spin_lock_irqsave(&pipe->irqlock, flags);
298
299 if (pipe->inputs[rpf_index]) {
300 /* Remove the RPF from the pipeline if it was previously
301 * enabled.
302 */
303 vsp1->bru->inputs[rpf_index].rpf = NULL;
304 pipe->inputs[rpf_index] = NULL;
305
306 pipe->num_inputs--;
307 }
308
309 spin_unlock_irqrestore(&pipe->irqlock, flags);
310
311 return 0;
312 }
313
314 dev_dbg(vsp1->dev,
315 "%s: RPF%u: (%u,%u)/%ux%u -> (%u,%u)/%ux%u (%08x), pitch %u dma { %pad, %pad }\n",
316 __func__, rpf_index,
317 src->left, src->top, src->width, src->height,
318 dst->left, dst->top, dst->width, dst->height,
319 pixelformat, pitch, &mem[0], &mem[1]);
320
321 /* Set the stride at the RPF input. */
322 fmtinfo = vsp1_get_format_info(pixelformat);
323 if (!fmtinfo) {
324 dev_dbg(vsp1->dev, "Unsupport pixel format %08x for RPF\n",
325 pixelformat);
326 return -EINVAL;
327 }
328
329 rpf->fmtinfo = fmtinfo;
330 rpf->format.num_planes = fmtinfo->planes;
331 rpf->format.plane_fmt[0].bytesperline = pitch;
332 rpf->format.plane_fmt[1].bytesperline = pitch;
333
334 /* Configure the format on the RPF sink pad and propagate it up to the
335 * BRU sink pad.
336 */
337 memset(&format, 0, sizeof(format));
338 format.which = V4L2_SUBDEV_FORMAT_ACTIVE;
339 format.pad = RWPF_PAD_SINK;
340 format.format.width = src->width + src->left;
341 format.format.height = src->height + src->top;
342 format.format.code = fmtinfo->mbus;
343 format.format.field = V4L2_FIELD_NONE;
344
345 ret = v4l2_subdev_call(&rpf->entity.subdev, pad, set_fmt, NULL,
346 &format);
347 if (ret < 0)
348 return ret;
349
350 dev_dbg(vsp1->dev,
351 "%s: set format %ux%u (%x) on RPF%u sink\n",
352 __func__, format.format.width, format.format.height,
353 format.format.code, rpf->entity.index);
354
355 memset(&sel, 0, sizeof(sel));
356 sel.which = V4L2_SUBDEV_FORMAT_ACTIVE;
357 sel.pad = RWPF_PAD_SINK;
358 sel.target = V4L2_SEL_TGT_CROP;
359 sel.r = *src;
360
361 ret = v4l2_subdev_call(&rpf->entity.subdev, pad, set_selection, NULL,
362 &sel);
363 if (ret < 0)
364 return ret;
365
366 dev_dbg(vsp1->dev,
367 "%s: set selection (%u,%u)/%ux%u on RPF%u sink\n",
368 __func__, sel.r.left, sel.r.top, sel.r.width, sel.r.height,
369 rpf->entity.index);
370
371 /* RPF source, hardcode the format to ARGB8888 to turn on format
372 * conversion if needed.
373 */
374 format.pad = RWPF_PAD_SOURCE;
375
376 ret = v4l2_subdev_call(&rpf->entity.subdev, pad, get_fmt, NULL,
377 &format);
378 if (ret < 0)
379 return ret;
380
381 dev_dbg(vsp1->dev,
382 "%s: got format %ux%u (%x) on RPF%u source\n",
383 __func__, format.format.width, format.format.height,
384 format.format.code, rpf->entity.index);
385
386 format.format.code = MEDIA_BUS_FMT_ARGB8888_1X32;
387
388 ret = v4l2_subdev_call(&rpf->entity.subdev, pad, set_fmt, NULL,
389 &format);
390 if (ret < 0)
391 return ret;
392
393 /* BRU sink, propagate the format from the RPF source. */
394 format.pad = rpf->entity.index;
395
396 ret = v4l2_subdev_call(&vsp1->bru->entity.subdev, pad, set_fmt, NULL,
397 &format);
398 if (ret < 0)
399 return ret;
400
401 dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on BRU pad %u\n",
402 __func__, format.format.width, format.format.height,
403 format.format.code, format.pad);
404
405 sel.pad = rpf->entity.index;
406 sel.target = V4L2_SEL_TGT_COMPOSE;
407 sel.r = *dst;
408
409 ret = v4l2_subdev_call(&vsp1->bru->entity.subdev, pad, set_selection,
410 NULL, &sel);
411 if (ret < 0)
412 return ret;
413
414 dev_dbg(vsp1->dev,
415 "%s: set selection (%u,%u)/%ux%u on BRU pad %u\n",
416 __func__, sel.r.left, sel.r.top, sel.r.width, sel.r.height,
417 sel.pad);
418
419 /* Store the compose rectangle coordinates in the RPF. */
420 rpf->location.left = dst->left;
421 rpf->location.top = dst->top;
422
423 /* Set the memory buffer address. */
424 memory.num_planes = fmtinfo->planes;
425 memory.addr[0] = mem[0];
426 memory.addr[1] = mem[1];
427
428 rpf->ops->set_memory(rpf, &memory);
429
430 spin_lock_irqsave(&pipe->irqlock, flags);
431
432 /* If the RPF was previously stopped set the BRU input to the RPF and
433 * store the RPF in the pipeline inputs array.
434 */
435 if (!pipe->inputs[rpf->entity.index]) {
436 vsp1->bru->inputs[rpf_index].rpf = rpf;
437 pipe->inputs[rpf->entity.index] = rpf;
438 pipe->num_inputs++;
439 }
440
441 spin_unlock_irqrestore(&pipe->irqlock, flags);
442
443 return 0;
444}
445EXPORT_SYMBOL_GPL(vsp1_du_atomic_update);
446
447/**
448 * vsp1_du_atomic_flush - Commit an atomic update
449 * @dev: the VSP device
450 */
451void vsp1_du_atomic_flush(struct device *dev)
452{
453 struct vsp1_device *vsp1 = dev_get_drvdata(dev);
454 struct vsp1_pipeline *pipe = &vsp1->drm->pipe;
455 struct vsp1_entity *entity;
456 unsigned long flags;
457 bool stop = false;
458 int ret;
459
460 list_for_each_entry(entity, &pipe->entities, list_pipe) {
461 /* Disconnect unused RPFs from the pipeline. */
462 if (entity->type == VSP1_ENTITY_RPF) {
463 struct vsp1_rwpf *rpf = to_rwpf(&entity->subdev);
464
465 if (!pipe->inputs[rpf->entity.index]) {
466 vsp1_mod_write(entity, entity->route->reg,
467 VI6_DPR_NODE_UNUSED);
468 continue;
469 }
470 }
471
472 vsp1_entity_route_setup(entity);
473
474 ret = v4l2_subdev_call(&entity->subdev, video,
475 s_stream, 1);
476 if (ret < 0) {
477 dev_err(vsp1->dev,
478 "DRM pipeline start failure on entity %s\n",
479 entity->subdev.name);
480 return;
481 }
482 }
483
484 vsp1_dl_commit(vsp1->drm->dl);
485
486 spin_lock_irqsave(&pipe->irqlock, flags);
487
488 /* Start or stop the pipeline if needed. */
489 if (!vsp1->drm->num_inputs && pipe->num_inputs) {
490 vsp1_write(vsp1, VI6_DISP_IRQ_STA, 0);
491 vsp1_write(vsp1, VI6_DISP_IRQ_ENB, VI6_DISP_IRQ_ENB_DSTE);
492 vsp1_pipeline_run(pipe);
493 } else if (vsp1->drm->num_inputs && !pipe->num_inputs) {
494 stop = true;
495 }
496
497 spin_unlock_irqrestore(&pipe->irqlock, flags);
498
499 if (stop) {
500 vsp1_write(vsp1, VI6_DISP_IRQ_ENB, 0);
501 vsp1_pipeline_stop(pipe);
502 }
503}
504EXPORT_SYMBOL_GPL(vsp1_du_atomic_flush);
505
506/* -----------------------------------------------------------------------------
507 * Initialization
508 */
509
510int vsp1_drm_create_links(struct vsp1_device *vsp1)
511{
512 const u32 flags = MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE;
513 unsigned int i;
514 int ret;
515
516 /* VSPD instances require a BRU to perform composition and a LIF to
517 * output to the DU.
518 */
519 if (!vsp1->bru || !vsp1->lif)
520 return -ENXIO;
521
522 for (i = 0; i < vsp1->info->rpf_count; ++i) {
523 struct vsp1_rwpf *rpf = vsp1->rpf[i];
524
525 ret = media_create_pad_link(&rpf->entity.subdev.entity,
526 RWPF_PAD_SOURCE,
527 &vsp1->bru->entity.subdev.entity,
528 i, flags);
529 if (ret < 0)
530 return ret;
531
532 rpf->entity.sink = &vsp1->bru->entity.subdev.entity;
533 rpf->entity.sink_pad = i;
534 }
535
536 ret = media_create_pad_link(&vsp1->bru->entity.subdev.entity,
537 vsp1->bru->entity.source_pad,
538 &vsp1->wpf[0]->entity.subdev.entity,
539 RWPF_PAD_SINK, flags);
540 if (ret < 0)
541 return ret;
542
543 vsp1->bru->entity.sink = &vsp1->wpf[0]->entity.subdev.entity;
544 vsp1->bru->entity.sink_pad = RWPF_PAD_SINK;
545
546 ret = media_create_pad_link(&vsp1->wpf[0]->entity.subdev.entity,
547 RWPF_PAD_SOURCE,
548 &vsp1->lif->entity.subdev.entity,
549 LIF_PAD_SINK, flags);
550 if (ret < 0)
551 return ret;
552
553 return 0;
554}
555
556int vsp1_drm_init(struct vsp1_device *vsp1)
557{
558 struct vsp1_pipeline *pipe;
559 unsigned int i;
560
561 vsp1->drm = devm_kzalloc(vsp1->dev, sizeof(*vsp1->drm), GFP_KERNEL);
562 if (!vsp1->drm)
563 return -ENOMEM;
564
565 vsp1->drm->dl = vsp1_dl_create(vsp1);
566 if (!vsp1->drm->dl)
567 return -ENOMEM;
568
569 pipe = &vsp1->drm->pipe;
570
571 vsp1_pipeline_init(pipe);
572 pipe->frame_end = vsp1_drm_pipeline_frame_end;
573
574 /* The DRM pipeline is static, add entities manually. */
575 for (i = 0; i < vsp1->info->rpf_count; ++i) {
576 struct vsp1_rwpf *input = vsp1->rpf[i];
577
578 list_add_tail(&input->entity.list_pipe, &pipe->entities);
579 }
580
581 list_add_tail(&vsp1->bru->entity.list_pipe, &pipe->entities);
582 list_add_tail(&vsp1->wpf[0]->entity.list_pipe, &pipe->entities);
583 list_add_tail(&vsp1->lif->entity.list_pipe, &pipe->entities);
584
585 pipe->bru = &vsp1->bru->entity;
586 pipe->lif = &vsp1->lif->entity;
587 pipe->output = vsp1->wpf[0];
588
589 pipe->dl = vsp1->drm->dl;
590
591 return 0;
592}
593
594void vsp1_drm_cleanup(struct vsp1_device *vsp1)
595{
596 vsp1_dl_destroy(vsp1->drm->dl);
597}
diff --git a/drivers/media/platform/vsp1/vsp1_drm.h b/drivers/media/platform/vsp1/vsp1_drm.h
new file mode 100644
index 000000000000..f68056838319
--- /dev/null
+++ b/drivers/media/platform/vsp1/vsp1_drm.h
@@ -0,0 +1,49 @@
1/*
2 * vsp1_drm.h -- R-Car VSP1 DRM/KMS Interface
3 *
4 * Copyright (C) 2015 Renesas Electronics Corporation
5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
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#ifndef __VSP1_DRM_H__
14#define __VSP1_DRM_H__
15
16#include "vsp1_pipe.h"
17
18struct vsp1_dl;
19
20/**
21 * vsp1_drm - State for the API exposed to the DRM driver
22 * @dl: display list for DRM pipeline operation
23 * @pipe: the VSP1 pipeline used for display
24 * @num_inputs: number of active pipeline inputs at the beginning of an update
25 * @update: the pipeline configuration has been updated
26 */
27struct vsp1_drm {
28 struct vsp1_dl *dl;
29 struct vsp1_pipeline pipe;
30 unsigned int num_inputs;
31 bool update;
32};
33
34int vsp1_drm_init(struct vsp1_device *vsp1);
35void vsp1_drm_cleanup(struct vsp1_device *vsp1);
36int vsp1_drm_create_links(struct vsp1_device *vsp1);
37
38int vsp1_du_init(struct device *dev);
39int vsp1_du_setup_lif(struct device *dev, unsigned int width,
40 unsigned int height);
41void vsp1_du_atomic_begin(struct device *dev);
42int vsp1_du_atomic_update(struct device *dev, unsigned int rpf_index,
43 u32 pixelformat, unsigned int pitch,
44 dma_addr_t mem[2], const struct v4l2_rect *src,
45 const struct v4l2_rect *dst);
46void vsp1_du_atomic_flush(struct device *dev);
47
48
49#endif /* __VSP1_DRM_H__ */
diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c
index 533bc796391e..25750a0e4631 100644
--- a/drivers/media/platform/vsp1/vsp1_drv.c
+++ b/drivers/media/platform/vsp1/vsp1_drv.c
@@ -17,17 +17,23 @@
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/of.h> 19#include <linux/of.h>
20#include <linux/of_device.h>
20#include <linux/platform_device.h> 21#include <linux/platform_device.h>
21#include <linux/videodev2.h> 22#include <linux/videodev2.h>
22 23
24#include <media/v4l2-subdev.h>
25
23#include "vsp1.h" 26#include "vsp1.h"
24#include "vsp1_bru.h" 27#include "vsp1_bru.h"
28#include "vsp1_dl.h"
29#include "vsp1_drm.h"
25#include "vsp1_hsit.h" 30#include "vsp1_hsit.h"
26#include "vsp1_lif.h" 31#include "vsp1_lif.h"
27#include "vsp1_lut.h" 32#include "vsp1_lut.h"
28#include "vsp1_rwpf.h" 33#include "vsp1_rwpf.h"
29#include "vsp1_sru.h" 34#include "vsp1_sru.h"
30#include "vsp1_uds.h" 35#include "vsp1_uds.h"
36#include "vsp1_video.h"
31 37
32/* ----------------------------------------------------------------------------- 38/* -----------------------------------------------------------------------------
33 * Interrupt Handling 39 * Interrupt Handling
@@ -39,11 +45,11 @@ static irqreturn_t vsp1_irq_handler(int irq, void *data)
39 struct vsp1_device *vsp1 = data; 45 struct vsp1_device *vsp1 = data;
40 irqreturn_t ret = IRQ_NONE; 46 irqreturn_t ret = IRQ_NONE;
41 unsigned int i; 47 unsigned int i;
48 u32 status;
42 49
43 for (i = 0; i < vsp1->pdata.wpf_count; ++i) { 50 for (i = 0; i < vsp1->info->wpf_count; ++i) {
44 struct vsp1_rwpf *wpf = vsp1->wpf[i]; 51 struct vsp1_rwpf *wpf = vsp1->wpf[i];
45 struct vsp1_pipeline *pipe; 52 struct vsp1_pipeline *pipe;
46 u32 status;
47 53
48 if (wpf == NULL) 54 if (wpf == NULL)
49 continue; 55 continue;
@@ -58,6 +64,21 @@ static irqreturn_t vsp1_irq_handler(int irq, void *data)
58 } 64 }
59 } 65 }
60 66
67 status = vsp1_read(vsp1, VI6_DISP_IRQ_STA);
68 vsp1_write(vsp1, VI6_DISP_IRQ_STA, ~status & VI6_DISP_IRQ_STA_DST);
69
70 if (status & VI6_DISP_IRQ_STA_DST) {
71 struct vsp1_rwpf *wpf = vsp1->wpf[0];
72 struct vsp1_pipeline *pipe;
73
74 if (wpf) {
75 pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity);
76 vsp1_pipeline_display_start(pipe);
77 }
78
79 ret = IRQ_HANDLED;
80 }
81
61 return ret; 82 return ret;
62} 83}
63 84
@@ -66,7 +87,7 @@ static irqreturn_t vsp1_irq_handler(int irq, void *data)
66 */ 87 */
67 88
68/* 89/*
69 * vsp1_create_links - Create links from all sources to the given sink 90 * vsp1_create_sink_links - Create links from all sources to the given sink
70 * 91 *
71 * This function creates media links from all valid sources to the given sink 92 * This function creates media links from all valid sources to the given sink
72 * pad. Links that would be invalid according to the VSP1 hardware capabilities 93 * pad. Links that would be invalid according to the VSP1 hardware capabilities
@@ -75,7 +96,8 @@ static irqreturn_t vsp1_irq_handler(int irq, void *data)
75 * - from a UDS to a UDS (UDS entities can't be chained) 96 * - from a UDS to a UDS (UDS entities can't be chained)
76 * - from an entity to itself (no loops are allowed) 97 * - from an entity to itself (no loops are allowed)
77 */ 98 */
78static int vsp1_create_links(struct vsp1_device *vsp1, struct vsp1_entity *sink) 99static int vsp1_create_sink_links(struct vsp1_device *vsp1,
100 struct vsp1_entity *sink)
79{ 101{
80 struct media_entity *entity = &sink->subdev.entity; 102 struct media_entity *entity = &sink->subdev.entity;
81 struct vsp1_entity *source; 103 struct vsp1_entity *source;
@@ -115,19 +137,86 @@ static int vsp1_create_links(struct vsp1_device *vsp1, struct vsp1_entity *sink)
115 return 0; 137 return 0;
116} 138}
117 139
118static void vsp1_destroy_entities(struct vsp1_device *vsp1) 140static int vsp1_uapi_create_links(struct vsp1_device *vsp1)
119{ 141{
120 struct vsp1_entity *entity; 142 struct vsp1_entity *entity;
121 struct vsp1_entity *next; 143 unsigned int i;
144 int ret;
145
146 list_for_each_entry(entity, &vsp1->entities, list_dev) {
147 if (entity->type == VSP1_ENTITY_LIF ||
148 entity->type == VSP1_ENTITY_RPF)
149 continue;
150
151 ret = vsp1_create_sink_links(vsp1, entity);
152 if (ret < 0)
153 return ret;
154 }
155
156 if (vsp1->info->features & VSP1_HAS_LIF) {
157 ret = media_create_pad_link(&vsp1->wpf[0]->entity.subdev.entity,
158 RWPF_PAD_SOURCE,
159 &vsp1->lif->entity.subdev.entity,
160 LIF_PAD_SINK, 0);
161 if (ret < 0)
162 return ret;
163 }
164
165 for (i = 0; i < vsp1->info->rpf_count; ++i) {
166 struct vsp1_rwpf *rpf = vsp1->rpf[i];
122 167
123 list_for_each_entry_safe(entity, next, &vsp1->entities, list_dev) { 168 ret = media_create_pad_link(&rpf->video->video.entity, 0,
169 &rpf->entity.subdev.entity,
170 RWPF_PAD_SINK,
171 MEDIA_LNK_FL_ENABLED |
172 MEDIA_LNK_FL_IMMUTABLE);
173 if (ret < 0)
174 return ret;
175 }
176
177 for (i = 0; i < vsp1->info->wpf_count; ++i) {
178 /* Connect the video device to the WPF. All connections are
179 * immutable except for the WPF0 source link if a LIF is
180 * present.
181 */
182 struct vsp1_rwpf *wpf = vsp1->wpf[i];
183 unsigned int flags = MEDIA_LNK_FL_ENABLED;
184
185 if (!(vsp1->info->features & VSP1_HAS_LIF) || i != 0)
186 flags |= MEDIA_LNK_FL_IMMUTABLE;
187
188 ret = media_create_pad_link(&wpf->entity.subdev.entity,
189 RWPF_PAD_SOURCE,
190 &wpf->video->video.entity, 0,
191 flags);
192 if (ret < 0)
193 return ret;
194 }
195
196 return 0;
197}
198
199static void vsp1_destroy_entities(struct vsp1_device *vsp1)
200{
201 struct vsp1_entity *entity, *_entity;
202 struct vsp1_video *video, *_video;
203
204 list_for_each_entry_safe(entity, _entity, &vsp1->entities, list_dev) {
124 list_del(&entity->list_dev); 205 list_del(&entity->list_dev);
125 vsp1_entity_destroy(entity); 206 vsp1_entity_destroy(entity);
126 } 207 }
127 208
209 list_for_each_entry_safe(video, _video, &vsp1->videos, list) {
210 list_del(&video->list);
211 vsp1_video_cleanup(video);
212 }
213
128 v4l2_device_unregister(&vsp1->v4l2_dev); 214 v4l2_device_unregister(&vsp1->v4l2_dev);
129 media_device_unregister(&vsp1->media_dev); 215 media_device_unregister(&vsp1->media_dev);
130 media_device_cleanup(&vsp1->media_dev); 216 media_device_cleanup(&vsp1->media_dev);
217
218 if (!vsp1->info->uapi)
219 vsp1_drm_cleanup(vsp1);
131} 220}
132 221
133static int vsp1_create_entities(struct vsp1_device *vsp1) 222static int vsp1_create_entities(struct vsp1_device *vsp1)
@@ -144,6 +233,14 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
144 dev_name(mdev->dev)); 233 dev_name(mdev->dev));
145 media_device_init(mdev); 234 media_device_init(mdev);
146 235
236 vsp1->media_ops.link_setup = vsp1_entity_link_setup;
237 /* Don't perform link validation when the userspace API is disabled as
238 * the pipeline is configured internally by the driver in that case, and
239 * its configuration can thus be trusted.
240 */
241 if (vsp1->info->uapi)
242 vsp1->media_ops.link_validate = v4l2_subdev_link_validate;
243
147 vdev->mdev = mdev; 244 vdev->mdev = mdev;
148 ret = v4l2_device_register(vsp1->dev, vdev); 245 ret = v4l2_device_register(vsp1->dev, vdev);
149 if (ret < 0) { 246 if (ret < 0) {
@@ -153,13 +250,15 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
153 } 250 }
154 251
155 /* Instantiate all the entities. */ 252 /* Instantiate all the entities. */
156 vsp1->bru = vsp1_bru_create(vsp1); 253 if (vsp1->info->features & VSP1_HAS_BRU) {
157 if (IS_ERR(vsp1->bru)) { 254 vsp1->bru = vsp1_bru_create(vsp1);
158 ret = PTR_ERR(vsp1->bru); 255 if (IS_ERR(vsp1->bru)) {
159 goto done; 256 ret = PTR_ERR(vsp1->bru);
160 } 257 goto done;
258 }
161 259
162 list_add_tail(&vsp1->bru->entity.list_dev, &vsp1->entities); 260 list_add_tail(&vsp1->bru->entity.list_dev, &vsp1->entities);
261 }
163 262
164 vsp1->hsi = vsp1_hsit_create(vsp1, true); 263 vsp1->hsi = vsp1_hsit_create(vsp1, true);
165 if (IS_ERR(vsp1->hsi)) { 264 if (IS_ERR(vsp1->hsi)) {
@@ -177,7 +276,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
177 276
178 list_add_tail(&vsp1->hst->entity.list_dev, &vsp1->entities); 277 list_add_tail(&vsp1->hst->entity.list_dev, &vsp1->entities);
179 278
180 if (vsp1->pdata.features & VSP1_HAS_LIF) { 279 if (vsp1->info->features & VSP1_HAS_LIF) {
181 vsp1->lif = vsp1_lif_create(vsp1); 280 vsp1->lif = vsp1_lif_create(vsp1);
182 if (IS_ERR(vsp1->lif)) { 281 if (IS_ERR(vsp1->lif)) {
183 ret = PTR_ERR(vsp1->lif); 282 ret = PTR_ERR(vsp1->lif);
@@ -187,7 +286,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
187 list_add_tail(&vsp1->lif->entity.list_dev, &vsp1->entities); 286 list_add_tail(&vsp1->lif->entity.list_dev, &vsp1->entities);
188 } 287 }
189 288
190 if (vsp1->pdata.features & VSP1_HAS_LUT) { 289 if (vsp1->info->features & VSP1_HAS_LUT) {
191 vsp1->lut = vsp1_lut_create(vsp1); 290 vsp1->lut = vsp1_lut_create(vsp1);
192 if (IS_ERR(vsp1->lut)) { 291 if (IS_ERR(vsp1->lut)) {
193 ret = PTR_ERR(vsp1->lut); 292 ret = PTR_ERR(vsp1->lut);
@@ -197,7 +296,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
197 list_add_tail(&vsp1->lut->entity.list_dev, &vsp1->entities); 296 list_add_tail(&vsp1->lut->entity.list_dev, &vsp1->entities);
198 } 297 }
199 298
200 for (i = 0; i < vsp1->pdata.rpf_count; ++i) { 299 for (i = 0; i < vsp1->info->rpf_count; ++i) {
201 struct vsp1_rwpf *rpf; 300 struct vsp1_rwpf *rpf;
202 301
203 rpf = vsp1_rpf_create(vsp1, i); 302 rpf = vsp1_rpf_create(vsp1, i);
@@ -208,9 +307,20 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
208 307
209 vsp1->rpf[i] = rpf; 308 vsp1->rpf[i] = rpf;
210 list_add_tail(&rpf->entity.list_dev, &vsp1->entities); 309 list_add_tail(&rpf->entity.list_dev, &vsp1->entities);
310
311 if (vsp1->info->uapi) {
312 struct vsp1_video *video = vsp1_video_create(vsp1, rpf);
313
314 if (IS_ERR(video)) {
315 ret = PTR_ERR(video);
316 goto done;
317 }
318
319 list_add_tail(&video->list, &vsp1->videos);
320 }
211 } 321 }
212 322
213 if (vsp1->pdata.features & VSP1_HAS_SRU) { 323 if (vsp1->info->features & VSP1_HAS_SRU) {
214 vsp1->sru = vsp1_sru_create(vsp1); 324 vsp1->sru = vsp1_sru_create(vsp1);
215 if (IS_ERR(vsp1->sru)) { 325 if (IS_ERR(vsp1->sru)) {
216 ret = PTR_ERR(vsp1->sru); 326 ret = PTR_ERR(vsp1->sru);
@@ -220,7 +330,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
220 list_add_tail(&vsp1->sru->entity.list_dev, &vsp1->entities); 330 list_add_tail(&vsp1->sru->entity.list_dev, &vsp1->entities);
221 } 331 }
222 332
223 for (i = 0; i < vsp1->pdata.uds_count; ++i) { 333 for (i = 0; i < vsp1->info->uds_count; ++i) {
224 struct vsp1_uds *uds; 334 struct vsp1_uds *uds;
225 335
226 uds = vsp1_uds_create(vsp1, i); 336 uds = vsp1_uds_create(vsp1, i);
@@ -233,7 +343,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
233 list_add_tail(&uds->entity.list_dev, &vsp1->entities); 343 list_add_tail(&uds->entity.list_dev, &vsp1->entities);
234 } 344 }
235 345
236 for (i = 0; i < vsp1->pdata.wpf_count; ++i) { 346 for (i = 0; i < vsp1->info->wpf_count; ++i) {
237 struct vsp1_rwpf *wpf; 347 struct vsp1_rwpf *wpf;
238 348
239 wpf = vsp1_wpf_create(vsp1, i); 349 wpf = vsp1_wpf_create(vsp1, i);
@@ -244,6 +354,18 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
244 354
245 vsp1->wpf[i] = wpf; 355 vsp1->wpf[i] = wpf;
246 list_add_tail(&wpf->entity.list_dev, &vsp1->entities); 356 list_add_tail(&wpf->entity.list_dev, &vsp1->entities);
357
358 if (vsp1->info->uapi) {
359 struct vsp1_video *video = vsp1_video_create(vsp1, wpf);
360
361 if (IS_ERR(video)) {
362 ret = PTR_ERR(video);
363 goto done;
364 }
365
366 list_add_tail(&video->list, &vsp1->videos);
367 wpf->entity.sink = &video->video.entity;
368 }
247 } 369 }
248 370
249 /* Register all subdevs. */ 371 /* Register all subdevs. */
@@ -255,34 +377,23 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
255 } 377 }
256 378
257 /* Create links. */ 379 /* Create links. */
258 list_for_each_entry(entity, &vsp1->entities, list_dev) { 380 if (vsp1->info->uapi)
259 if (entity->type == VSP1_ENTITY_WPF) { 381 ret = vsp1_uapi_create_links(vsp1);
260 ret = vsp1_wpf_create_links(vsp1, entity); 382 else
261 if (ret < 0) 383 ret = vsp1_drm_create_links(vsp1);
262 goto done; 384 if (ret < 0)
263 } else if (entity->type == VSP1_ENTITY_RPF) { 385 goto done;
264 ret = vsp1_rpf_create_links(vsp1, entity);
265 if (ret < 0)
266 goto done;
267 }
268
269 if (entity->type != VSP1_ENTITY_LIF &&
270 entity->type != VSP1_ENTITY_RPF) {
271 ret = vsp1_create_links(vsp1, entity);
272 if (ret < 0)
273 goto done;
274 }
275 }
276 386
277 if (vsp1->pdata.features & VSP1_HAS_LIF) { 387 /* Register subdev nodes if the userspace API is enabled or initialize
278 ret = media_create_pad_link( 388 * the DRM pipeline otherwise.
279 &vsp1->wpf[0]->entity.subdev.entity, RWPF_PAD_SOURCE, 389 */
280 &vsp1->lif->entity.subdev.entity, LIF_PAD_SINK, 0); 390 if (vsp1->info->uapi) {
281 if (ret < 0) 391 vsp1->use_dl = false;
282 return ret; 392 ret = v4l2_device_register_subdev_nodes(&vsp1->v4l2_dev);
393 } else {
394 vsp1->use_dl = true;
395 ret = vsp1_drm_init(vsp1);
283 } 396 }
284
285 ret = v4l2_device_register_subdev_nodes(&vsp1->v4l2_dev);
286 if (ret < 0) 397 if (ret < 0)
287 goto done; 398 goto done;
288 399
@@ -295,42 +406,51 @@ done:
295 return ret; 406 return ret;
296} 407}
297 408
298static int vsp1_device_init(struct vsp1_device *vsp1) 409int vsp1_reset_wpf(struct vsp1_device *vsp1, unsigned int index)
299{ 410{
300 unsigned int i; 411 unsigned int timeout;
301 u32 status; 412 u32 status;
302 413
303 /* Reset any channel that might be running. */
304 status = vsp1_read(vsp1, VI6_STATUS); 414 status = vsp1_read(vsp1, VI6_STATUS);
415 if (!(status & VI6_STATUS_SYS_ACT(index)))
416 return 0;
305 417
306 for (i = 0; i < vsp1->pdata.wpf_count; ++i) { 418 vsp1_write(vsp1, VI6_SRESET, VI6_SRESET_SRTS(index));
307 unsigned int timeout; 419 for (timeout = 10; timeout > 0; --timeout) {
420 status = vsp1_read(vsp1, VI6_STATUS);
421 if (!(status & VI6_STATUS_SYS_ACT(index)))
422 break;
308 423
309 if (!(status & VI6_STATUS_SYS_ACT(i))) 424 usleep_range(1000, 2000);
310 continue; 425 }
311 426
312 vsp1_write(vsp1, VI6_SRESET, VI6_SRESET_SRTS(i)); 427 if (!timeout) {
313 for (timeout = 10; timeout > 0; --timeout) { 428 dev_err(vsp1->dev, "failed to reset wpf.%u\n", index);
314 status = vsp1_read(vsp1, VI6_STATUS); 429 return -ETIMEDOUT;
315 if (!(status & VI6_STATUS_SYS_ACT(i))) 430 }
316 break;
317 431
318 usleep_range(1000, 2000); 432 return 0;
319 } 433}
320 434
321 if (!timeout) { 435static int vsp1_device_init(struct vsp1_device *vsp1)
322 dev_err(vsp1->dev, "failed to reset wpf.%u\n", i); 436{
323 return -ETIMEDOUT; 437 unsigned int i;
324 } 438 int ret;
439
440 /* Reset any channel that might be running. */
441 for (i = 0; i < vsp1->info->wpf_count; ++i) {
442 ret = vsp1_reset_wpf(vsp1, i);
443 if (ret < 0)
444 return ret;
325 } 445 }
326 446
327 vsp1_write(vsp1, VI6_CLK_DCSWT, (8 << VI6_CLK_DCSWT_CSTPW_SHIFT) | 447 vsp1_write(vsp1, VI6_CLK_DCSWT, (8 << VI6_CLK_DCSWT_CSTPW_SHIFT) |
328 (8 << VI6_CLK_DCSWT_CSTRW_SHIFT)); 448 (8 << VI6_CLK_DCSWT_CSTRW_SHIFT));
329 449
330 for (i = 0; i < vsp1->pdata.rpf_count; ++i) 450 for (i = 0; i < vsp1->info->rpf_count; ++i)
331 vsp1_write(vsp1, VI6_DPR_RPF_ROUTE(i), VI6_DPR_NODE_UNUSED); 451 vsp1_write(vsp1, VI6_DPR_RPF_ROUTE(i), VI6_DPR_NODE_UNUSED);
332 452
333 for (i = 0; i < vsp1->pdata.uds_count; ++i) 453 for (i = 0; i < vsp1->info->uds_count; ++i)
334 vsp1_write(vsp1, VI6_DPR_UDS_ROUTE(i), VI6_DPR_NODE_UNUSED); 454 vsp1_write(vsp1, VI6_DPR_UDS_ROUTE(i), VI6_DPR_NODE_UNUSED);
335 455
336 vsp1_write(vsp1, VI6_DPR_SRU_ROUTE, VI6_DPR_NODE_UNUSED); 456 vsp1_write(vsp1, VI6_DPR_SRU_ROUTE, VI6_DPR_NODE_UNUSED);
@@ -345,6 +465,9 @@ static int vsp1_device_init(struct vsp1_device *vsp1)
345 vsp1_write(vsp1, VI6_DPR_HGT_SMPPT, (7 << VI6_DPR_SMPPT_TGW_SHIFT) | 465 vsp1_write(vsp1, VI6_DPR_HGT_SMPPT, (7 << VI6_DPR_SMPPT_TGW_SHIFT) |
346 (VI6_DPR_NODE_UNUSED << VI6_DPR_SMPPT_PT_SHIFT)); 466 (VI6_DPR_NODE_UNUSED << VI6_DPR_SMPPT_PT_SHIFT));
347 467
468 if (vsp1->use_dl)
469 vsp1_dl_setup(vsp1);
470
348 return 0; 471 return 0;
349} 472}
350 473
@@ -444,48 +567,76 @@ static const struct dev_pm_ops vsp1_pm_ops = {
444 * Platform Driver 567 * Platform Driver
445 */ 568 */
446 569
447static int vsp1_parse_dt(struct vsp1_device *vsp1) 570static const struct vsp1_device_info vsp1_device_infos[] = {
448{ 571 {
449 struct device_node *np = vsp1->dev->of_node; 572 .version = VI6_IP_VERSION_MODEL_VSPS_H2,
450 struct vsp1_platform_data *pdata = &vsp1->pdata; 573 .features = VSP1_HAS_BRU | VSP1_HAS_LUT | VSP1_HAS_SRU,
451 574 .rpf_count = 5,
452 if (of_property_read_bool(np, "renesas,has-lif")) 575 .uds_count = 3,
453 pdata->features |= VSP1_HAS_LIF; 576 .wpf_count = 4,
454 if (of_property_read_bool(np, "renesas,has-lut")) 577 .num_bru_inputs = 4,
455 pdata->features |= VSP1_HAS_LUT; 578 .uapi = true,
456 if (of_property_read_bool(np, "renesas,has-sru")) 579 }, {
457 pdata->features |= VSP1_HAS_SRU; 580 .version = VI6_IP_VERSION_MODEL_VSPR_H2,
458 581 .features = VSP1_HAS_BRU | VSP1_HAS_SRU,
459 of_property_read_u32(np, "renesas,#rpf", &pdata->rpf_count); 582 .rpf_count = 5,
460 of_property_read_u32(np, "renesas,#uds", &pdata->uds_count); 583 .uds_count = 1,
461 of_property_read_u32(np, "renesas,#wpf", &pdata->wpf_count); 584 .wpf_count = 4,
462 585 .num_bru_inputs = 4,
463 if (pdata->rpf_count <= 0 || pdata->rpf_count > VSP1_MAX_RPF) { 586 .uapi = true,
464 dev_err(vsp1->dev, "invalid number of RPF (%u)\n", 587 }, {
465 pdata->rpf_count); 588 .version = VI6_IP_VERSION_MODEL_VSPD_GEN2,
466 return -EINVAL; 589 .features = VSP1_HAS_BRU | VSP1_HAS_LIF | VSP1_HAS_LUT,
467 } 590 .rpf_count = 4,
468 591 .uds_count = 1,
469 if (pdata->uds_count <= 0 || pdata->uds_count > VSP1_MAX_UDS) { 592 .wpf_count = 4,
470 dev_err(vsp1->dev, "invalid number of UDS (%u)\n", 593 .num_bru_inputs = 4,
471 pdata->uds_count); 594 .uapi = true,
472 return -EINVAL; 595 }, {
473 } 596 .version = VI6_IP_VERSION_MODEL_VSPS_M2,
474 597 .features = VSP1_HAS_BRU | VSP1_HAS_LUT | VSP1_HAS_SRU,
475 if (pdata->wpf_count <= 0 || pdata->wpf_count > VSP1_MAX_WPF) { 598 .rpf_count = 5,
476 dev_err(vsp1->dev, "invalid number of WPF (%u)\n", 599 .uds_count = 3,
477 pdata->wpf_count); 600 .wpf_count = 4,
478 return -EINVAL; 601 .num_bru_inputs = 4,
479 } 602 .uapi = true,
480 603 }, {
481 return 0; 604 .version = VI6_IP_VERSION_MODEL_VSPI_GEN3,
482} 605 .features = VSP1_HAS_LUT | VSP1_HAS_SRU,
606 .rpf_count = 1,
607 .uds_count = 1,
608 .wpf_count = 1,
609 .uapi = true,
610 }, {
611 .version = VI6_IP_VERSION_MODEL_VSPBD_GEN3,
612 .features = VSP1_HAS_BRU,
613 .rpf_count = 5,
614 .wpf_count = 1,
615 .num_bru_inputs = 5,
616 .uapi = true,
617 }, {
618 .version = VI6_IP_VERSION_MODEL_VSPBC_GEN3,
619 .features = VSP1_HAS_BRU | VSP1_HAS_LUT,
620 .rpf_count = 5,
621 .wpf_count = 1,
622 .num_bru_inputs = 5,
623 .uapi = true,
624 }, {
625 .version = VI6_IP_VERSION_MODEL_VSPD_GEN3,
626 .features = VSP1_HAS_BRU | VSP1_HAS_LIF | VSP1_HAS_LUT,
627 .rpf_count = 5,
628 .wpf_count = 2,
629 .num_bru_inputs = 5,
630 },
631};
483 632
484static int vsp1_probe(struct platform_device *pdev) 633static int vsp1_probe(struct platform_device *pdev)
485{ 634{
486 struct vsp1_device *vsp1; 635 struct vsp1_device *vsp1;
487 struct resource *irq; 636 struct resource *irq;
488 struct resource *io; 637 struct resource *io;
638 unsigned int i;
639 u32 version;
489 int ret; 640 int ret;
490 641
491 vsp1 = devm_kzalloc(&pdev->dev, sizeof(*vsp1), GFP_KERNEL); 642 vsp1 = devm_kzalloc(&pdev->dev, sizeof(*vsp1), GFP_KERNEL);
@@ -495,10 +646,7 @@ static int vsp1_probe(struct platform_device *pdev)
495 vsp1->dev = &pdev->dev; 646 vsp1->dev = &pdev->dev;
496 mutex_init(&vsp1->lock); 647 mutex_init(&vsp1->lock);
497 INIT_LIST_HEAD(&vsp1->entities); 648 INIT_LIST_HEAD(&vsp1->entities);
498 649 INIT_LIST_HEAD(&vsp1->videos);
499 ret = vsp1_parse_dt(vsp1);
500 if (ret < 0)
501 return ret;
502 650
503 /* I/O, IRQ and clock resources */ 651 /* I/O, IRQ and clock resources */
504 io = platform_get_resource(pdev, IORESOURCE_MEM, 0); 652 io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -525,6 +673,29 @@ static int vsp1_probe(struct platform_device *pdev)
525 return ret; 673 return ret;
526 } 674 }
527 675
676 /* Configure device parameters based on the version register. */
677 ret = clk_prepare_enable(vsp1->clock);
678 if (ret < 0)
679 return ret;
680
681 version = vsp1_read(vsp1, VI6_IP_VERSION);
682 clk_disable_unprepare(vsp1->clock);
683
684 for (i = 0; i < ARRAY_SIZE(vsp1_device_infos); ++i) {
685 if ((version & VI6_IP_VERSION_MODEL_MASK) ==
686 vsp1_device_infos[i].version) {
687 vsp1->info = &vsp1_device_infos[i];
688 break;
689 }
690 }
691
692 if (!vsp1->info) {
693 dev_err(&pdev->dev, "unsupported IP version 0x%08x\n", version);
694 return -ENXIO;
695 }
696
697 dev_dbg(&pdev->dev, "IP version 0x%08x\n", version);
698
528 /* Instanciate entities */ 699 /* Instanciate entities */
529 ret = vsp1_create_entities(vsp1); 700 ret = vsp1_create_entities(vsp1);
530 if (ret < 0) { 701 if (ret < 0) {
@@ -548,6 +719,7 @@ static int vsp1_remove(struct platform_device *pdev)
548 719
549static const struct of_device_id vsp1_of_match[] = { 720static const struct of_device_id vsp1_of_match[] = {
550 { .compatible = "renesas,vsp1" }, 721 { .compatible = "renesas,vsp1" },
722 { .compatible = "renesas,vsp2" },
551 { }, 723 { },
552}; 724};
553 725
diff --git a/drivers/media/platform/vsp1/vsp1_entity.c b/drivers/media/platform/vsp1/vsp1_entity.c
index d7308530952f..20a78fbd3691 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.c
+++ b/drivers/media/platform/vsp1/vsp1_entity.c
@@ -20,7 +20,6 @@
20 20
21#include "vsp1.h" 21#include "vsp1.h"
22#include "vsp1_entity.h" 22#include "vsp1_entity.h"
23#include "vsp1_video.h"
24 23
25bool vsp1_entity_is_streaming(struct vsp1_entity *entity) 24bool vsp1_entity_is_streaming(struct vsp1_entity *entity)
26{ 25{
@@ -46,7 +45,7 @@ int vsp1_entity_set_streaming(struct vsp1_entity *entity, bool streaming)
46 if (!streaming) 45 if (!streaming)
47 return 0; 46 return 0;
48 47
49 if (!entity->subdev.ctrl_handler) 48 if (!entity->vsp1->info->uapi || !entity->subdev.ctrl_handler)
50 return 0; 49 return 0;
51 50
52 ret = v4l2_ctrl_handler_setup(entity->subdev.ctrl_handler); 51 ret = v4l2_ctrl_handler_setup(entity->subdev.ctrl_handler);
@@ -59,6 +58,18 @@ int vsp1_entity_set_streaming(struct vsp1_entity *entity, bool streaming)
59 return ret; 58 return ret;
60} 59}
61 60
61void vsp1_entity_route_setup(struct vsp1_entity *source)
62{
63 struct vsp1_entity *sink;
64
65 if (source->route->reg == 0)
66 return;
67
68 sink = container_of(source->sink, struct vsp1_entity, subdev.entity);
69 vsp1_mod_write(source, source->route->reg,
70 sink->route->inputs[source->sink_pad]);
71}
72
62/* ----------------------------------------------------------------------------- 73/* -----------------------------------------------------------------------------
63 * V4L2 Subdevice Operations 74 * V4L2 Subdevice Operations
64 */ 75 */
@@ -120,9 +131,9 @@ const struct v4l2_subdev_internal_ops vsp1_subdev_internal_ops = {
120 * Media Operations 131 * Media Operations
121 */ 132 */
122 133
123static int vsp1_entity_link_setup(struct media_entity *entity, 134int vsp1_entity_link_setup(struct media_entity *entity,
124 const struct media_pad *local, 135 const struct media_pad *local,
125 const struct media_pad *remote, u32 flags) 136 const struct media_pad *remote, u32 flags)
126{ 137{
127 struct vsp1_entity *source; 138 struct vsp1_entity *source;
128 139
@@ -147,11 +158,6 @@ static int vsp1_entity_link_setup(struct media_entity *entity,
147 return 0; 158 return 0;
148} 159}
149 160
150const struct media_entity_operations vsp1_media_ops = {
151 .link_setup = vsp1_entity_link_setup,
152 .link_validate = v4l2_subdev_link_validate,
153};
154
155/* ----------------------------------------------------------------------------- 161/* -----------------------------------------------------------------------------
156 * Initialization 162 * Initialization
157 */ 163 */
@@ -159,7 +165,8 @@ const struct media_entity_operations vsp1_media_ops = {
159static const struct vsp1_route vsp1_routes[] = { 165static const struct vsp1_route vsp1_routes[] = {
160 { VSP1_ENTITY_BRU, 0, VI6_DPR_BRU_ROUTE, 166 { VSP1_ENTITY_BRU, 0, VI6_DPR_BRU_ROUTE,
161 { VI6_DPR_NODE_BRU_IN(0), VI6_DPR_NODE_BRU_IN(1), 167 { VI6_DPR_NODE_BRU_IN(0), VI6_DPR_NODE_BRU_IN(1),
162 VI6_DPR_NODE_BRU_IN(2), VI6_DPR_NODE_BRU_IN(3), } }, 168 VI6_DPR_NODE_BRU_IN(2), VI6_DPR_NODE_BRU_IN(3),
169 VI6_DPR_NODE_BRU_IN(4) } },
163 { VSP1_ENTITY_HSI, 0, VI6_DPR_HSI_ROUTE, { VI6_DPR_NODE_HSI, } }, 170 { VSP1_ENTITY_HSI, 0, VI6_DPR_HSI_ROUTE, { VI6_DPR_NODE_HSI, } },
164 { VSP1_ENTITY_HST, 0, VI6_DPR_HST_ROUTE, { VI6_DPR_NODE_HST, } }, 171 { VSP1_ENTITY_HST, 0, VI6_DPR_HST_ROUTE, { VI6_DPR_NODE_HST, } },
165 { VSP1_ENTITY_LIF, 0, 0, { VI6_DPR_NODE_LIF, } }, 172 { VSP1_ENTITY_LIF, 0, 0, { VI6_DPR_NODE_LIF, } },
@@ -225,8 +232,6 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
225 232
226void vsp1_entity_destroy(struct vsp1_entity *entity) 233void vsp1_entity_destroy(struct vsp1_entity *entity)
227{ 234{
228 if (entity->video)
229 vsp1_video_cleanup(entity->video);
230 if (entity->subdev.ctrl_handler) 235 if (entity->subdev.ctrl_handler)
231 v4l2_ctrl_handler_free(entity->subdev.ctrl_handler); 236 v4l2_ctrl_handler_free(entity->subdev.ctrl_handler);
232 media_entity_cleanup(&entity->subdev.entity); 237 media_entity_cleanup(&entity->subdev.entity);
diff --git a/drivers/media/platform/vsp1/vsp1_entity.h b/drivers/media/platform/vsp1/vsp1_entity.h
index 8867a5787c28..83570dfde8ec 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.h
+++ b/drivers/media/platform/vsp1/vsp1_entity.h
@@ -19,7 +19,6 @@
19#include <media/v4l2-subdev.h> 19#include <media/v4l2-subdev.h>
20 20
21struct vsp1_device; 21struct vsp1_device;
22struct vsp1_video;
23 22
24enum vsp1_entity_type { 23enum vsp1_entity_type {
25 VSP1_ENTITY_BRU, 24 VSP1_ENTITY_BRU,
@@ -33,6 +32,8 @@ enum vsp1_entity_type {
33 VSP1_ENTITY_WPF, 32 VSP1_ENTITY_WPF,
34}; 33};
35 34
35#define VSP1_ENTITY_MAX_INPUTS 5 /* For the BRU */
36
36/* 37/*
37 * struct vsp1_route - Entity routing configuration 38 * struct vsp1_route - Entity routing configuration
38 * @type: Entity type this routing entry is associated with 39 * @type: Entity type this routing entry is associated with
@@ -49,7 +50,7 @@ struct vsp1_route {
49 enum vsp1_entity_type type; 50 enum vsp1_entity_type type;
50 unsigned int index; 51 unsigned int index;
51 unsigned int reg; 52 unsigned int reg;
52 unsigned int inputs[4]; 53 unsigned int inputs[VSP1_ENTITY_MAX_INPUTS];
53}; 54};
54 55
55struct vsp1_entity { 56struct vsp1_entity {
@@ -71,8 +72,6 @@ struct vsp1_entity {
71 struct v4l2_subdev subdev; 72 struct v4l2_subdev subdev;
72 struct v4l2_mbus_framefmt *formats; 73 struct v4l2_mbus_framefmt *formats;
73 74
74 struct vsp1_video *video;
75
76 spinlock_t lock; /* Protects the streaming field */ 75 spinlock_t lock; /* Protects the streaming field */
77 bool streaming; 76 bool streaming;
78}; 77};
@@ -87,7 +86,10 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
87void vsp1_entity_destroy(struct vsp1_entity *entity); 86void vsp1_entity_destroy(struct vsp1_entity *entity);
88 87
89extern const struct v4l2_subdev_internal_ops vsp1_subdev_internal_ops; 88extern const struct v4l2_subdev_internal_ops vsp1_subdev_internal_ops;
90extern const struct media_entity_operations vsp1_media_ops; 89
90int vsp1_entity_link_setup(struct media_entity *entity,
91 const struct media_pad *local,
92 const struct media_pad *remote, u32 flags);
91 93
92struct v4l2_mbus_framefmt * 94struct v4l2_mbus_framefmt *
93vsp1_entity_get_pad_format(struct vsp1_entity *entity, 95vsp1_entity_get_pad_format(struct vsp1_entity *entity,
@@ -99,4 +101,6 @@ void vsp1_entity_init_formats(struct v4l2_subdev *subdev,
99bool vsp1_entity_is_streaming(struct vsp1_entity *entity); 101bool vsp1_entity_is_streaming(struct vsp1_entity *entity);
100int vsp1_entity_set_streaming(struct vsp1_entity *entity, bool streaming); 102int vsp1_entity_set_streaming(struct vsp1_entity *entity, bool streaming);
101 103
104void vsp1_entity_route_setup(struct vsp1_entity *source);
105
102#endif /* __VSP1_ENTITY_H__ */ 106#endif /* __VSP1_ENTITY_H__ */
diff --git a/drivers/media/platform/vsp1/vsp1_hsit.c b/drivers/media/platform/vsp1/vsp1_hsit.c
index 8ffb817ae525..c1087cff31a0 100644
--- a/drivers/media/platform/vsp1/vsp1_hsit.c
+++ b/drivers/media/platform/vsp1/vsp1_hsit.c
@@ -203,7 +203,7 @@ struct vsp1_hsit *vsp1_hsit_create(struct vsp1_device *vsp1, bool inverse)
203 subdev = &hsit->entity.subdev; 203 subdev = &hsit->entity.subdev;
204 v4l2_subdev_init(subdev, &hsit_ops); 204 v4l2_subdev_init(subdev, &hsit_ops);
205 205
206 subdev->entity.ops = &vsp1_media_ops; 206 subdev->entity.ops = &vsp1->media_ops;
207 subdev->internal_ops = &vsp1_subdev_internal_ops; 207 subdev->internal_ops = &vsp1_subdev_internal_ops;
208 snprintf(subdev->name, sizeof(subdev->name), "%s %s", 208 snprintf(subdev->name, sizeof(subdev->name), "%s %s",
209 dev_name(vsp1->dev), inverse ? "hsi" : "hst"); 209 dev_name(vsp1->dev), inverse ? "hsi" : "hst");
diff --git a/drivers/media/platform/vsp1/vsp1_lif.c b/drivers/media/platform/vsp1/vsp1_lif.c
index 39fa5ef20fbb..433853ce8dbf 100644
--- a/drivers/media/platform/vsp1/vsp1_lif.c
+++ b/drivers/media/platform/vsp1/vsp1_lif.c
@@ -26,14 +26,9 @@
26 * Device Access 26 * Device Access
27 */ 27 */
28 28
29static inline u32 vsp1_lif_read(struct vsp1_lif *lif, u32 reg)
30{
31 return vsp1_read(lif->entity.vsp1, reg);
32}
33
34static inline void vsp1_lif_write(struct vsp1_lif *lif, u32 reg, u32 data) 29static inline void vsp1_lif_write(struct vsp1_lif *lif, u32 reg, u32 data)
35{ 30{
36 vsp1_write(lif->entity.vsp1, reg, data); 31 vsp1_mod_write(&lif->entity, reg, data);
37} 32}
38 33
39/* ----------------------------------------------------------------------------- 34/* -----------------------------------------------------------------------------
@@ -49,7 +44,7 @@ static int lif_s_stream(struct v4l2_subdev *subdev, int enable)
49 unsigned int lbth = 200; 44 unsigned int lbth = 200;
50 45
51 if (!enable) { 46 if (!enable) {
52 vsp1_lif_write(lif, VI6_LIF_CTRL, 0); 47 vsp1_write(lif->entity.vsp1, VI6_LIF_CTRL, 0);
53 return 0; 48 return 0;
54 } 49 }
55 50
@@ -228,7 +223,7 @@ struct vsp1_lif *vsp1_lif_create(struct vsp1_device *vsp1)
228 subdev = &lif->entity.subdev; 223 subdev = &lif->entity.subdev;
229 v4l2_subdev_init(subdev, &lif_ops); 224 v4l2_subdev_init(subdev, &lif_ops);
230 225
231 subdev->entity.ops = &vsp1_media_ops; 226 subdev->entity.ops = &vsp1->media_ops;
232 subdev->internal_ops = &vsp1_subdev_internal_ops; 227 subdev->internal_ops = &vsp1_subdev_internal_ops;
233 snprintf(subdev->name, sizeof(subdev->name), "%s lif", 228 snprintf(subdev->name, sizeof(subdev->name), "%s lif",
234 dev_name(vsp1->dev)); 229 dev_name(vsp1->dev));
diff --git a/drivers/media/platform/vsp1/vsp1_lut.c b/drivers/media/platform/vsp1/vsp1_lut.c
index 656ec272a414..4b89095e7b5f 100644
--- a/drivers/media/platform/vsp1/vsp1_lut.c
+++ b/drivers/media/platform/vsp1/vsp1_lut.c
@@ -27,11 +27,6 @@
27 * Device Access 27 * Device Access
28 */ 28 */
29 29
30static inline u32 vsp1_lut_read(struct vsp1_lut *lut, u32 reg)
31{
32 return vsp1_read(lut->entity.vsp1, reg);
33}
34
35static inline void vsp1_lut_write(struct vsp1_lut *lut, u32 reg, u32 data) 30static inline void vsp1_lut_write(struct vsp1_lut *lut, u32 reg, u32 data)
36{ 31{
37 vsp1_write(lut->entity.vsp1, reg, data); 32 vsp1_write(lut->entity.vsp1, reg, data);
@@ -242,7 +237,7 @@ struct vsp1_lut *vsp1_lut_create(struct vsp1_device *vsp1)
242 subdev = &lut->entity.subdev; 237 subdev = &lut->entity.subdev;
243 v4l2_subdev_init(subdev, &lut_ops); 238 v4l2_subdev_init(subdev, &lut_ops);
244 239
245 subdev->entity.ops = &vsp1_media_ops; 240 subdev->entity.ops = &vsp1->media_ops;
246 subdev->internal_ops = &vsp1_subdev_internal_ops; 241 subdev->internal_ops = &vsp1_subdev_internal_ops;
247 snprintf(subdev->name, sizeof(subdev->name), "%s lut", 242 snprintf(subdev->name, sizeof(subdev->name), "%s lut",
248 dev_name(vsp1->dev)); 243 dev_name(vsp1->dev));
diff --git a/drivers/media/platform/vsp1/vsp1_pipe.c b/drivers/media/platform/vsp1/vsp1_pipe.c
new file mode 100644
index 000000000000..6659f06b1643
--- /dev/null
+++ b/drivers/media/platform/vsp1/vsp1_pipe.c
@@ -0,0 +1,426 @@
1/*
2 * vsp1_pipe.c -- R-Car VSP1 Pipeline
3 *
4 * Copyright (C) 2013-2015 Renesas Electronics Corporation
5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
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
14#include <linux/delay.h>
15#include <linux/list.h>
16#include <linux/sched.h>
17#include <linux/wait.h>
18
19#include <media/media-entity.h>
20#include <media/v4l2-subdev.h>
21
22#include "vsp1.h"
23#include "vsp1_bru.h"
24#include "vsp1_dl.h"
25#include "vsp1_entity.h"
26#include "vsp1_pipe.h"
27#include "vsp1_rwpf.h"
28#include "vsp1_uds.h"
29
30/* -----------------------------------------------------------------------------
31 * Helper Functions
32 */
33
34static const struct vsp1_format_info vsp1_video_formats[] = {
35 { V4L2_PIX_FMT_RGB332, MEDIA_BUS_FMT_ARGB8888_1X32,
36 VI6_FMT_RGB_332, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
37 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
38 1, { 8, 0, 0 }, false, false, 1, 1, false },
39 { V4L2_PIX_FMT_ARGB444, MEDIA_BUS_FMT_ARGB8888_1X32,
40 VI6_FMT_ARGB_4444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
41 VI6_RPF_DSWAP_P_WDS,
42 1, { 16, 0, 0 }, false, false, 1, 1, true },
43 { V4L2_PIX_FMT_XRGB444, MEDIA_BUS_FMT_ARGB8888_1X32,
44 VI6_FMT_XRGB_4444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
45 VI6_RPF_DSWAP_P_WDS,
46 1, { 16, 0, 0 }, false, false, 1, 1, true },
47 { V4L2_PIX_FMT_ARGB555, MEDIA_BUS_FMT_ARGB8888_1X32,
48 VI6_FMT_ARGB_1555, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
49 VI6_RPF_DSWAP_P_WDS,
50 1, { 16, 0, 0 }, false, false, 1, 1, true },
51 { V4L2_PIX_FMT_XRGB555, MEDIA_BUS_FMT_ARGB8888_1X32,
52 VI6_FMT_XRGB_1555, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
53 VI6_RPF_DSWAP_P_WDS,
54 1, { 16, 0, 0 }, false, false, 1, 1, false },
55 { V4L2_PIX_FMT_RGB565, MEDIA_BUS_FMT_ARGB8888_1X32,
56 VI6_FMT_RGB_565, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
57 VI6_RPF_DSWAP_P_WDS,
58 1, { 16, 0, 0 }, false, false, 1, 1, false },
59 { V4L2_PIX_FMT_BGR24, MEDIA_BUS_FMT_ARGB8888_1X32,
60 VI6_FMT_BGR_888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
61 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
62 1, { 24, 0, 0 }, false, false, 1, 1, false },
63 { V4L2_PIX_FMT_RGB24, MEDIA_BUS_FMT_ARGB8888_1X32,
64 VI6_FMT_RGB_888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
65 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
66 1, { 24, 0, 0 }, false, false, 1, 1, false },
67 { V4L2_PIX_FMT_ABGR32, MEDIA_BUS_FMT_ARGB8888_1X32,
68 VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS,
69 1, { 32, 0, 0 }, false, false, 1, 1, true },
70 { V4L2_PIX_FMT_XBGR32, MEDIA_BUS_FMT_ARGB8888_1X32,
71 VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS,
72 1, { 32, 0, 0 }, false, false, 1, 1, false },
73 { V4L2_PIX_FMT_ARGB32, MEDIA_BUS_FMT_ARGB8888_1X32,
74 VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
75 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
76 1, { 32, 0, 0 }, false, false, 1, 1, true },
77 { V4L2_PIX_FMT_XRGB32, MEDIA_BUS_FMT_ARGB8888_1X32,
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,
80 1, { 32, 0, 0 }, false, false, 1, 1, false },
81 { V4L2_PIX_FMT_UYVY, MEDIA_BUS_FMT_AYUV8_1X32,
82 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,
84 1, { 16, 0, 0 }, false, false, 2, 1, false },
85 { V4L2_PIX_FMT_VYUY, MEDIA_BUS_FMT_AYUV8_1X32,
86 VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
87 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
88 1, { 16, 0, 0 }, false, true, 2, 1, false },
89 { V4L2_PIX_FMT_YUYV, MEDIA_BUS_FMT_AYUV8_1X32,
90 VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
91 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
92 1, { 16, 0, 0 }, true, false, 2, 1, false },
93 { V4L2_PIX_FMT_YVYU, MEDIA_BUS_FMT_AYUV8_1X32,
94 VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
95 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
96 1, { 16, 0, 0 }, true, true, 2, 1, false },
97 { V4L2_PIX_FMT_NV12M, MEDIA_BUS_FMT_AYUV8_1X32,
98 VI6_FMT_Y_UV_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
99 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
100 2, { 8, 16, 0 }, false, false, 2, 2, false },
101 { V4L2_PIX_FMT_NV21M, MEDIA_BUS_FMT_AYUV8_1X32,
102 VI6_FMT_Y_UV_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
103 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
104 2, { 8, 16, 0 }, false, true, 2, 2, false },
105 { V4L2_PIX_FMT_NV16M, MEDIA_BUS_FMT_AYUV8_1X32,
106 VI6_FMT_Y_UV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
107 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
108 2, { 8, 16, 0 }, false, false, 2, 1, false },
109 { V4L2_PIX_FMT_NV61M, MEDIA_BUS_FMT_AYUV8_1X32,
110 VI6_FMT_Y_UV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
111 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
112 2, { 8, 16, 0 }, false, true, 2, 1, false },
113 { V4L2_PIX_FMT_YUV420M, MEDIA_BUS_FMT_AYUV8_1X32,
114 VI6_FMT_Y_U_V_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
115 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
116 3, { 8, 8, 8 }, false, false, 2, 2, false },
117 { V4L2_PIX_FMT_YVU420M, MEDIA_BUS_FMT_AYUV8_1X32,
118 VI6_FMT_Y_U_V_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
119 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
120 3, { 8, 8, 8 }, false, true, 2, 2, false },
121 { V4L2_PIX_FMT_YUV422M, MEDIA_BUS_FMT_AYUV8_1X32,
122 VI6_FMT_Y_U_V_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
123 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
124 3, { 8, 8, 8 }, false, false, 2, 1, false },
125 { V4L2_PIX_FMT_YVU422M, MEDIA_BUS_FMT_AYUV8_1X32,
126 VI6_FMT_Y_U_V_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
127 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
128 3, { 8, 8, 8 }, false, true, 2, 1, false },
129 { V4L2_PIX_FMT_YUV444M, MEDIA_BUS_FMT_AYUV8_1X32,
130 VI6_FMT_Y_U_V_444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
131 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
132 3, { 8, 8, 8 }, false, false, 1, 1, false },
133 { V4L2_PIX_FMT_YVU444M, MEDIA_BUS_FMT_AYUV8_1X32,
134 VI6_FMT_Y_U_V_444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
135 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
136 3, { 8, 8, 8 }, false, true, 1, 1, false },
137};
138
139/*
140 * vsp1_get_format_info - Retrieve format information for a 4CC
141 * @fourcc: the format 4CC
142 *
143 * Return a pointer to the format information structure corresponding to the
144 * given V4L2 format 4CC, or NULL if no corresponding format can be found.
145 */
146const struct vsp1_format_info *vsp1_get_format_info(u32 fourcc)
147{
148 unsigned int i;
149
150 for (i = 0; i < ARRAY_SIZE(vsp1_video_formats); ++i) {
151 const struct vsp1_format_info *info = &vsp1_video_formats[i];
152
153 if (info->fourcc == fourcc)
154 return info;
155 }
156
157 return NULL;
158}
159
160/* -----------------------------------------------------------------------------
161 * Pipeline Management
162 */
163
164void vsp1_pipeline_reset(struct vsp1_pipeline *pipe)
165{
166 unsigned int i;
167
168 if (pipe->bru) {
169 struct vsp1_bru *bru = to_bru(&pipe->bru->subdev);
170
171 for (i = 0; i < ARRAY_SIZE(bru->inputs); ++i)
172 bru->inputs[i].rpf = NULL;
173 }
174
175 for (i = 0; i < ARRAY_SIZE(pipe->inputs); ++i)
176 pipe->inputs[i] = NULL;
177
178 INIT_LIST_HEAD(&pipe->entities);
179 pipe->state = VSP1_PIPELINE_STOPPED;
180 pipe->buffers_ready = 0;
181 pipe->num_inputs = 0;
182 pipe->output = NULL;
183 pipe->bru = NULL;
184 pipe->lif = NULL;
185 pipe->uds = NULL;
186}
187
188void vsp1_pipeline_init(struct vsp1_pipeline *pipe)
189{
190 mutex_init(&pipe->lock);
191 spin_lock_init(&pipe->irqlock);
192 init_waitqueue_head(&pipe->wq);
193
194 INIT_LIST_HEAD(&pipe->entities);
195 pipe->state = VSP1_PIPELINE_STOPPED;
196}
197
198void vsp1_pipeline_run(struct vsp1_pipeline *pipe)
199{
200 struct vsp1_device *vsp1 = pipe->output->entity.vsp1;
201
202 if (pipe->state == VSP1_PIPELINE_STOPPED) {
203 vsp1_write(vsp1, VI6_CMD(pipe->output->entity.index),
204 VI6_CMD_STRCMD);
205 pipe->state = VSP1_PIPELINE_RUNNING;
206 }
207
208 pipe->buffers_ready = 0;
209}
210
211bool vsp1_pipeline_stopped(struct vsp1_pipeline *pipe)
212{
213 unsigned long flags;
214 bool stopped;
215
216 spin_lock_irqsave(&pipe->irqlock, flags);
217 stopped = pipe->state == VSP1_PIPELINE_STOPPED;
218 spin_unlock_irqrestore(&pipe->irqlock, flags);
219
220 return stopped;
221}
222
223int vsp1_pipeline_stop(struct vsp1_pipeline *pipe)
224{
225 struct vsp1_entity *entity;
226 unsigned long flags;
227 int ret;
228
229 if (pipe->dl) {
230 /* When using display lists in continuous frame mode the only
231 * way to stop the pipeline is to reset the hardware.
232 */
233 ret = vsp1_reset_wpf(pipe->output->entity.vsp1,
234 pipe->output->entity.index);
235 if (ret == 0) {
236 spin_lock_irqsave(&pipe->irqlock, flags);
237 pipe->state = VSP1_PIPELINE_STOPPED;
238 spin_unlock_irqrestore(&pipe->irqlock, flags);
239 }
240 } else {
241 /* Otherwise just request a stop and wait. */
242 spin_lock_irqsave(&pipe->irqlock, flags);
243 if (pipe->state == VSP1_PIPELINE_RUNNING)
244 pipe->state = VSP1_PIPELINE_STOPPING;
245 spin_unlock_irqrestore(&pipe->irqlock, flags);
246
247 ret = wait_event_timeout(pipe->wq, vsp1_pipeline_stopped(pipe),
248 msecs_to_jiffies(500));
249 ret = ret == 0 ? -ETIMEDOUT : 0;
250 }
251
252 list_for_each_entry(entity, &pipe->entities, list_pipe) {
253 if (entity->route && entity->route->reg)
254 vsp1_write(entity->vsp1, entity->route->reg,
255 VI6_DPR_NODE_UNUSED);
256
257 v4l2_subdev_call(&entity->subdev, video, s_stream, 0);
258 }
259
260 return ret;
261}
262
263bool vsp1_pipeline_ready(struct vsp1_pipeline *pipe)
264{
265 unsigned int mask;
266
267 mask = ((1 << pipe->num_inputs) - 1) << 1;
268 if (!pipe->lif)
269 mask |= 1 << 0;
270
271 return pipe->buffers_ready == mask;
272}
273
274void vsp1_pipeline_display_start(struct vsp1_pipeline *pipe)
275{
276 if (pipe->dl)
277 vsp1_dl_irq_display_start(pipe->dl);
278}
279
280void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe)
281{
282 enum vsp1_pipeline_state state;
283 unsigned long flags;
284
285 if (pipe == NULL)
286 return;
287
288 if (pipe->dl)
289 vsp1_dl_irq_frame_end(pipe->dl);
290
291 /* Signal frame end to the pipeline handler. */
292 pipe->frame_end(pipe);
293
294 spin_lock_irqsave(&pipe->irqlock, flags);
295
296 state = pipe->state;
297
298 /* When using display lists in continuous frame mode the pipeline is
299 * automatically restarted by the hardware.
300 */
301 if (!pipe->dl)
302 pipe->state = VSP1_PIPELINE_STOPPED;
303
304 /* If a stop has been requested, mark the pipeline as stopped and
305 * return.
306 */
307 if (state == VSP1_PIPELINE_STOPPING) {
308 wake_up(&pipe->wq);
309 goto done;
310 }
311
312 /* Restart the pipeline if ready. */
313 if (vsp1_pipeline_ready(pipe))
314 vsp1_pipeline_run(pipe);
315
316done:
317 spin_unlock_irqrestore(&pipe->irqlock, flags);
318}
319
320/*
321 * Propagate the alpha value through the pipeline.
322 *
323 * As the UDS has restricted scaling capabilities when the alpha component needs
324 * to be scaled, we disable alpha scaling when the UDS input has a fixed alpha
325 * value. The UDS then outputs a fixed alpha value which needs to be programmed
326 * from the input RPF alpha.
327 */
328void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe,
329 struct vsp1_entity *input,
330 unsigned int alpha)
331{
332 struct vsp1_entity *entity;
333 struct media_pad *pad;
334
335 pad = media_entity_remote_pad(&input->pads[RWPF_PAD_SOURCE]);
336
337 while (pad) {
338 if (!is_media_entity_v4l2_subdev(pad->entity))
339 break;
340
341 entity = to_vsp1_entity(media_entity_to_v4l2_subdev(pad->entity));
342
343 /* The BRU background color has a fixed alpha value set to 255,
344 * the output alpha value is thus always equal to 255.
345 */
346 if (entity->type == VSP1_ENTITY_BRU)
347 alpha = 255;
348
349 if (entity->type == VSP1_ENTITY_UDS) {
350 struct vsp1_uds *uds = to_uds(&entity->subdev);
351
352 vsp1_uds_set_alpha(uds, alpha);
353 break;
354 }
355
356 pad = &entity->pads[entity->source_pad];
357 pad = media_entity_remote_pad(pad);
358 }
359}
360
361void vsp1_pipelines_suspend(struct vsp1_device *vsp1)
362{
363 unsigned long flags;
364 unsigned int i;
365 int ret;
366
367 /* To avoid increasing the system suspend time needlessly, loop over the
368 * pipelines twice, first to set them all to the stopping state, and
369 * then to wait for the stop to complete.
370 */
371 for (i = 0; i < vsp1->info->wpf_count; ++i) {
372 struct vsp1_rwpf *wpf = vsp1->wpf[i];
373 struct vsp1_pipeline *pipe;
374
375 if (wpf == NULL)
376 continue;
377
378 pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity);
379 if (pipe == NULL)
380 continue;
381
382 spin_lock_irqsave(&pipe->irqlock, flags);
383 if (pipe->state == VSP1_PIPELINE_RUNNING)
384 pipe->state = VSP1_PIPELINE_STOPPING;
385 spin_unlock_irqrestore(&pipe->irqlock, flags);
386 }
387
388 for (i = 0; i < vsp1->info->wpf_count; ++i) {
389 struct vsp1_rwpf *wpf = vsp1->wpf[i];
390 struct vsp1_pipeline *pipe;
391
392 if (wpf == NULL)
393 continue;
394
395 pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity);
396 if (pipe == NULL)
397 continue;
398
399 ret = wait_event_timeout(pipe->wq, vsp1_pipeline_stopped(pipe),
400 msecs_to_jiffies(500));
401 if (ret == 0)
402 dev_warn(vsp1->dev, "pipeline %u stop timeout\n",
403 wpf->entity.index);
404 }
405}
406
407void vsp1_pipelines_resume(struct vsp1_device *vsp1)
408{
409 unsigned int i;
410
411 /* Resume pipeline all running pipelines. */
412 for (i = 0; i < vsp1->info->wpf_count; ++i) {
413 struct vsp1_rwpf *wpf = vsp1->wpf[i];
414 struct vsp1_pipeline *pipe;
415
416 if (wpf == NULL)
417 continue;
418
419 pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity);
420 if (pipe == NULL)
421 continue;
422
423 if (vsp1_pipeline_ready(pipe))
424 vsp1_pipeline_run(pipe);
425 }
426}
diff --git a/drivers/media/platform/vsp1/vsp1_pipe.h b/drivers/media/platform/vsp1/vsp1_pipe.h
new file mode 100644
index 000000000000..b2f3a8a896c9
--- /dev/null
+++ b/drivers/media/platform/vsp1/vsp1_pipe.h
@@ -0,0 +1,134 @@
1/*
2 * vsp1_pipe.h -- R-Car VSP1 Pipeline
3 *
4 * Copyright (C) 2013-2015 Renesas Electronics Corporation
5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
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#ifndef __VSP1_PIPE_H__
14#define __VSP1_PIPE_H__
15
16#include <linux/list.h>
17#include <linux/spinlock.h>
18#include <linux/wait.h>
19
20#include <media/media-entity.h>
21
22struct vsp1_dl;
23struct vsp1_rwpf;
24
25/*
26 * struct vsp1_format_info - VSP1 video format description
27 * @mbus: media bus format code
28 * @fourcc: V4L2 pixel format FCC identifier
29 * @planes: number of planes
30 * @bpp: bits per pixel
31 * @hwfmt: VSP1 hardware format
32 * @swap_yc: the Y and C components are swapped (Y comes before C)
33 * @swap_uv: the U and V components are swapped (V comes before U)
34 * @hsub: horizontal subsampling factor
35 * @vsub: vertical subsampling factor
36 * @alpha: has an alpha channel
37 */
38struct vsp1_format_info {
39 u32 fourcc;
40 unsigned int mbus;
41 unsigned int hwfmt;
42 unsigned int swap;
43 unsigned int planes;
44 unsigned int bpp[3];
45 bool swap_yc;
46 bool swap_uv;
47 unsigned int hsub;
48 unsigned int vsub;
49 bool alpha;
50};
51
52enum vsp1_pipeline_state {
53 VSP1_PIPELINE_STOPPED,
54 VSP1_PIPELINE_RUNNING,
55 VSP1_PIPELINE_STOPPING,
56};
57
58/*
59 * struct vsp1_pipeline - A VSP1 hardware pipeline
60 * @pipe: the media pipeline
61 * @irqlock: protects the pipeline state
62 * @state: current state
63 * @wq: work queue to wait for state change completion
64 * @frame_end: frame end interrupt handler
65 * @lock: protects the pipeline use count and stream count
66 * @use_count: number of video nodes using the pipeline
67 * @stream_count: number of streaming video nodes
68 * @buffers_ready: bitmask of RPFs and WPFs with at least one buffer available
69 * @num_inputs: number of RPFs
70 * @inputs: array of RPFs in the pipeline (indexed by RPF index)
71 * @output: WPF at the output of the pipeline
72 * @bru: BRU entity, if present
73 * @lif: LIF entity, if present
74 * @uds: UDS entity, if present
75 * @uds_input: entity at the input of the UDS, if the UDS is present
76 * @entities: list of entities in the pipeline
77 * @dl: display list associated with the pipeline
78 */
79struct vsp1_pipeline {
80 struct media_pipeline pipe;
81
82 spinlock_t irqlock;
83 enum vsp1_pipeline_state state;
84 wait_queue_head_t wq;
85
86 void (*frame_end)(struct vsp1_pipeline *pipe);
87
88 struct mutex lock;
89 unsigned int use_count;
90 unsigned int stream_count;
91 unsigned int buffers_ready;
92
93 unsigned int num_inputs;
94 struct vsp1_rwpf *inputs[VSP1_MAX_RPF];
95 struct vsp1_rwpf *output;
96 struct vsp1_entity *bru;
97 struct vsp1_entity *lif;
98 struct vsp1_entity *uds;
99 struct vsp1_entity *uds_input;
100
101 struct list_head entities;
102
103 struct vsp1_dl *dl;
104};
105
106static inline struct vsp1_pipeline *to_vsp1_pipeline(struct media_entity *e)
107{
108 if (likely(e->pipe))
109 return container_of(e->pipe, struct vsp1_pipeline, pipe);
110 else
111 return NULL;
112}
113
114void vsp1_pipeline_reset(struct vsp1_pipeline *pipe);
115void vsp1_pipeline_init(struct vsp1_pipeline *pipe);
116
117void vsp1_pipeline_run(struct vsp1_pipeline *pipe);
118bool vsp1_pipeline_stopped(struct vsp1_pipeline *pipe);
119int vsp1_pipeline_stop(struct vsp1_pipeline *pipe);
120bool vsp1_pipeline_ready(struct vsp1_pipeline *pipe);
121
122void vsp1_pipeline_display_start(struct vsp1_pipeline *pipe);
123void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe);
124
125void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe,
126 struct vsp1_entity *input,
127 unsigned int alpha);
128
129void vsp1_pipelines_suspend(struct vsp1_device *vsp1);
130void vsp1_pipelines_resume(struct vsp1_device *vsp1);
131
132const struct vsp1_format_info *vsp1_get_format_info(u32 fourcc);
133
134#endif /* __VSP1_PIPE_H__ */
diff --git a/drivers/media/platform/vsp1/vsp1_regs.h b/drivers/media/platform/vsp1/vsp1_regs.h
index 25b48738b147..069216f0eb44 100644
--- a/drivers/media/platform/vsp1/vsp1_regs.h
+++ b/drivers/media/platform/vsp1/vsp1_regs.h
@@ -46,7 +46,7 @@
46#define VI6_DISP_IRQ_ENB_LNEE(n) (1 << (n)) 46#define VI6_DISP_IRQ_ENB_LNEE(n) (1 << (n))
47 47
48#define VI6_DISP_IRQ_STA 0x007c 48#define VI6_DISP_IRQ_STA 0x007c
49#define VI6_DISP_IRQ_STA_DSE (1 << 8) 49#define VI6_DISP_IRQ_STA_DST (1 << 8)
50#define VI6_DISP_IRQ_STA_MAE (1 << 5) 50#define VI6_DISP_IRQ_STA_MAE (1 << 5)
51#define VI6_DISP_IRQ_STA_LNE(n) (1 << (n)) 51#define VI6_DISP_IRQ_STA_LNE(n) (1 << (n))
52 52
@@ -322,7 +322,7 @@
322#define VI6_DPR_NODE_SRU 16 322#define VI6_DPR_NODE_SRU 16
323#define VI6_DPR_NODE_UDS(n) (17 + (n)) 323#define VI6_DPR_NODE_UDS(n) (17 + (n))
324#define VI6_DPR_NODE_LUT 22 324#define VI6_DPR_NODE_LUT 22
325#define VI6_DPR_NODE_BRU_IN(n) (23 + (n)) 325#define VI6_DPR_NODE_BRU_IN(n) (((n) <= 3) ? 23 + (n) : 49)
326#define VI6_DPR_NODE_BRU_OUT 27 326#define VI6_DPR_NODE_BRU_OUT 27
327#define VI6_DPR_NODE_CLU 29 327#define VI6_DPR_NODE_CLU 29
328#define VI6_DPR_NODE_HST 30 328#define VI6_DPR_NODE_HST 30
@@ -504,12 +504,12 @@
504#define VI6_BRU_VIRRPF_COL_BCB_MASK (0xff << 0) 504#define VI6_BRU_VIRRPF_COL_BCB_MASK (0xff << 0)
505#define VI6_BRU_VIRRPF_COL_BCB_SHIFT 0 505#define VI6_BRU_VIRRPF_COL_BCB_SHIFT 0
506 506
507#define VI6_BRU_CTRL(n) (0x2c10 + (n) * 8) 507#define VI6_BRU_CTRL(n) (0x2c10 + (n) * 8 + ((n) <= 3 ? 0 : 4))
508#define VI6_BRU_CTRL_RBC (1 << 31) 508#define VI6_BRU_CTRL_RBC (1 << 31)
509#define VI6_BRU_CTRL_DSTSEL_BRUIN(n) ((n) << 20) 509#define VI6_BRU_CTRL_DSTSEL_BRUIN(n) (((n) <= 3 ? (n) : (n)+1) << 20)
510#define VI6_BRU_CTRL_DSTSEL_VRPF (4 << 20) 510#define VI6_BRU_CTRL_DSTSEL_VRPF (4 << 20)
511#define VI6_BRU_CTRL_DSTSEL_MASK (7 << 20) 511#define VI6_BRU_CTRL_DSTSEL_MASK (7 << 20)
512#define VI6_BRU_CTRL_SRCSEL_BRUIN(n) ((n) << 16) 512#define VI6_BRU_CTRL_SRCSEL_BRUIN(n) (((n) <= 3 ? (n) : (n)+1) << 16)
513#define VI6_BRU_CTRL_SRCSEL_VRPF (4 << 16) 513#define VI6_BRU_CTRL_SRCSEL_VRPF (4 << 16)
514#define VI6_BRU_CTRL_SRCSEL_MASK (7 << 16) 514#define VI6_BRU_CTRL_SRCSEL_MASK (7 << 16)
515#define VI6_BRU_CTRL_CROP(rop) ((rop) << 4) 515#define VI6_BRU_CTRL_CROP(rop) ((rop) << 4)
@@ -517,7 +517,7 @@
517#define VI6_BRU_CTRL_AROP(rop) ((rop) << 0) 517#define VI6_BRU_CTRL_AROP(rop) ((rop) << 0)
518#define VI6_BRU_CTRL_AROP_MASK (0xf << 0) 518#define VI6_BRU_CTRL_AROP_MASK (0xf << 0)
519 519
520#define VI6_BRU_BLD(n) (0x2c14 + (n) * 8) 520#define VI6_BRU_BLD(n) (0x2c14 + (n) * 8 + ((n) <= 3 ? 0 : 4))
521#define VI6_BRU_BLD_CBES (1 << 31) 521#define VI6_BRU_BLD_CBES (1 << 31)
522#define VI6_BRU_BLD_CCMDX_DST_A (0 << 28) 522#define VI6_BRU_BLD_CCMDX_DST_A (0 << 28)
523#define VI6_BRU_BLD_CCMDX_255_DST_A (1 << 28) 523#define VI6_BRU_BLD_CCMDX_255_DST_A (1 << 28)
@@ -551,7 +551,7 @@
551#define VI6_BRU_BLD_COEFY_SHIFT 0 551#define VI6_BRU_BLD_COEFY_SHIFT 0
552 552
553#define VI6_BRU_ROP 0x2c30 553#define VI6_BRU_ROP 0x2c30
554#define VI6_BRU_ROP_DSTSEL_BRUIN(n) ((n) << 20) 554#define VI6_BRU_ROP_DSTSEL_BRUIN(n) (((n) <= 3 ? (n) : (n)+1) << 20)
555#define VI6_BRU_ROP_DSTSEL_VRPF (4 << 20) 555#define VI6_BRU_ROP_DSTSEL_VRPF (4 << 20)
556#define VI6_BRU_ROP_DSTSEL_MASK (7 << 20) 556#define VI6_BRU_ROP_DSTSEL_MASK (7 << 20)
557#define VI6_BRU_ROP_CROP(rop) ((rop) << 4) 557#define VI6_BRU_ROP_CROP(rop) ((rop) << 4)
@@ -625,6 +625,24 @@
625#define VI6_SECURITY_CTRL1 0x3d04 625#define VI6_SECURITY_CTRL1 0x3d04
626 626
627/* ----------------------------------------------------------------------------- 627/* -----------------------------------------------------------------------------
628 * IP Version Registers
629 */
630
631#define VI6_IP_VERSION 0x3f00
632#define VI6_IP_VERSION_MODEL_MASK (0xff << 8)
633#define VI6_IP_VERSION_MODEL_VSPS_H2 (0x09 << 8)
634#define VI6_IP_VERSION_MODEL_VSPR_H2 (0x0a << 8)
635#define VI6_IP_VERSION_MODEL_VSPD_GEN2 (0x0b << 8)
636#define VI6_IP_VERSION_MODEL_VSPS_M2 (0x0c << 8)
637#define VI6_IP_VERSION_MODEL_VSPI_GEN3 (0x14 << 8)
638#define VI6_IP_VERSION_MODEL_VSPBD_GEN3 (0x15 << 8)
639#define VI6_IP_VERSION_MODEL_VSPBC_GEN3 (0x16 << 8)
640#define VI6_IP_VERSION_MODEL_VSPD_GEN3 (0x17 << 8)
641#define VI6_IP_VERSION_SOC_MASK (0xff << 0)
642#define VI6_IP_VERSION_SOC_H (0x01 << 0)
643#define VI6_IP_VERSION_SOC_M (0x02 << 0)
644
645/* -----------------------------------------------------------------------------
628 * RPF CLUT Registers 646 * RPF CLUT Registers
629 */ 647 */
630 648
diff --git a/drivers/media/platform/vsp1/vsp1_rpf.c b/drivers/media/platform/vsp1/vsp1_rpf.c
index 924538223d3e..5bc1d1574a43 100644
--- a/drivers/media/platform/vsp1/vsp1_rpf.c
+++ b/drivers/media/platform/vsp1/vsp1_rpf.c
@@ -26,16 +26,10 @@
26 * Device Access 26 * Device Access
27 */ 27 */
28 28
29static inline u32 vsp1_rpf_read(struct vsp1_rwpf *rpf, u32 reg)
30{
31 return vsp1_read(rpf->entity.vsp1,
32 reg + rpf->entity.index * VI6_RPF_OFFSET);
33}
34
35static inline void vsp1_rpf_write(struct vsp1_rwpf *rpf, u32 reg, u32 data) 29static inline void vsp1_rpf_write(struct vsp1_rwpf *rpf, u32 reg, u32 data)
36{ 30{
37 vsp1_write(rpf->entity.vsp1, 31 vsp1_mod_write(&rpf->entity, reg + rpf->entity.index * VI6_RPF_OFFSET,
38 reg + rpf->entity.index * VI6_RPF_OFFSET, data); 32 data);
39} 33}
40 34
41/* ----------------------------------------------------------------------------- 35/* -----------------------------------------------------------------------------
@@ -74,9 +68,11 @@ static const struct v4l2_ctrl_ops rpf_ctrl_ops = {
74 68
75static int rpf_s_stream(struct v4l2_subdev *subdev, int enable) 69static int rpf_s_stream(struct v4l2_subdev *subdev, int enable)
76{ 70{
71 struct vsp1_pipeline *pipe = to_vsp1_pipeline(&subdev->entity);
77 struct vsp1_rwpf *rpf = to_rwpf(subdev); 72 struct vsp1_rwpf *rpf = to_rwpf(subdev);
78 const struct vsp1_format_info *fmtinfo = rpf->video.fmtinfo; 73 struct vsp1_device *vsp1 = rpf->entity.vsp1;
79 const struct v4l2_pix_format_mplane *format = &rpf->video.format; 74 const struct vsp1_format_info *fmtinfo = rpf->fmtinfo;
75 const struct v4l2_pix_format_mplane *format = &rpf->format;
80 const struct v4l2_rect *crop = &rpf->crop; 76 const struct v4l2_rect *crop = &rpf->crop;
81 u32 pstride; 77 u32 pstride;
82 u32 infmt; 78 u32 infmt;
@@ -154,6 +150,15 @@ static int rpf_s_stream(struct v4l2_subdev *subdev, int enable)
154 vsp1_rpf_write(rpf, VI6_RPF_ALPH_SEL, VI6_RPF_ALPH_SEL_AEXT_EXT | 150 vsp1_rpf_write(rpf, VI6_RPF_ALPH_SEL, VI6_RPF_ALPH_SEL_AEXT_EXT |
155 (fmtinfo->alpha ? VI6_RPF_ALPH_SEL_ASEL_PACKED 151 (fmtinfo->alpha ? VI6_RPF_ALPH_SEL_ASEL_PACKED
156 : VI6_RPF_ALPH_SEL_ASEL_FIXED)); 152 : VI6_RPF_ALPH_SEL_ASEL_FIXED));
153
154 if (vsp1->info->uapi)
155 mutex_lock(rpf->ctrls.lock);
156 vsp1_rpf_write(rpf, VI6_RPF_VRTCOL_SET,
157 rpf->alpha->cur.val << VI6_RPF_VRTCOL_SET_LAYA_SHIFT);
158 vsp1_pipeline_propagate_alpha(pipe, &rpf->entity, rpf->alpha->cur.val);
159 if (vsp1->info->uapi)
160 mutex_unlock(rpf->ctrls.lock);
161
157 vsp1_rpf_write(rpf, VI6_RPF_MSK_CTRL, 0); 162 vsp1_rpf_write(rpf, VI6_RPF_MSK_CTRL, 0);
158 vsp1_rpf_write(rpf, VI6_RPF_CKEY_CTRL, 0); 163 vsp1_rpf_write(rpf, VI6_RPF_CKEY_CTRL, 0);
159 164
@@ -186,30 +191,28 @@ static struct v4l2_subdev_ops rpf_ops = {
186 * Video Device Operations 191 * Video Device Operations
187 */ 192 */
188 193
189static void rpf_vdev_queue(struct vsp1_video *video, 194static void rpf_set_memory(struct vsp1_rwpf *rpf, struct vsp1_rwpf_memory *mem)
190 struct vsp1_video_buffer *buf)
191{ 195{
192 struct vsp1_rwpf *rpf = container_of(video, struct vsp1_rwpf, video);
193 unsigned int i; 196 unsigned int i;
194 197
195 for (i = 0; i < 3; ++i) 198 for (i = 0; i < 3; ++i)
196 rpf->buf_addr[i] = buf->addr[i]; 199 rpf->buf_addr[i] = mem->addr[i];
197 200
198 if (!vsp1_entity_is_streaming(&rpf->entity)) 201 if (!vsp1_entity_is_streaming(&rpf->entity))
199 return; 202 return;
200 203
201 vsp1_rpf_write(rpf, VI6_RPF_SRCM_ADDR_Y, 204 vsp1_rpf_write(rpf, VI6_RPF_SRCM_ADDR_Y,
202 buf->addr[0] + rpf->offsets[0]); 205 mem->addr[0] + rpf->offsets[0]);
203 if (buf->buf.vb2_buf.num_planes > 1) 206 if (mem->num_planes > 1)
204 vsp1_rpf_write(rpf, VI6_RPF_SRCM_ADDR_C0, 207 vsp1_rpf_write(rpf, VI6_RPF_SRCM_ADDR_C0,
205 buf->addr[1] + rpf->offsets[1]); 208 mem->addr[1] + rpf->offsets[1]);
206 if (buf->buf.vb2_buf.num_planes > 2) 209 if (mem->num_planes > 2)
207 vsp1_rpf_write(rpf, VI6_RPF_SRCM_ADDR_C1, 210 vsp1_rpf_write(rpf, VI6_RPF_SRCM_ADDR_C1,
208 buf->addr[2] + rpf->offsets[1]); 211 mem->addr[2] + rpf->offsets[1]);
209} 212}
210 213
211static const struct vsp1_video_operations rpf_vdev_ops = { 214static const struct vsp1_rwpf_operations rpf_vdev_ops = {
212 .queue = rpf_vdev_queue, 215 .set_memory = rpf_set_memory,
213}; 216};
214 217
215/* ----------------------------------------------------------------------------- 218/* -----------------------------------------------------------------------------
@@ -219,7 +222,6 @@ static const struct vsp1_video_operations rpf_vdev_ops = {
219struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index) 222struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
220{ 223{
221 struct v4l2_subdev *subdev; 224 struct v4l2_subdev *subdev;
222 struct vsp1_video *video;
223 struct vsp1_rwpf *rpf; 225 struct vsp1_rwpf *rpf;
224 int ret; 226 int ret;
225 227
@@ -227,6 +229,8 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
227 if (rpf == NULL) 229 if (rpf == NULL)
228 return ERR_PTR(-ENOMEM); 230 return ERR_PTR(-ENOMEM);
229 231
232 rpf->ops = &rpf_vdev_ops;
233
230 rpf->max_width = RPF_MAX_WIDTH; 234 rpf->max_width = RPF_MAX_WIDTH;
231 rpf->max_height = RPF_MAX_HEIGHT; 235 rpf->max_height = RPF_MAX_HEIGHT;
232 236
@@ -241,7 +245,7 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
241 subdev = &rpf->entity.subdev; 245 subdev = &rpf->entity.subdev;
242 v4l2_subdev_init(subdev, &rpf_ops); 246 v4l2_subdev_init(subdev, &rpf_ops);
243 247
244 subdev->entity.ops = &vsp1_media_ops; 248 subdev->entity.ops = &vsp1->media_ops;
245 subdev->internal_ops = &vsp1_subdev_internal_ops; 249 subdev->internal_ops = &vsp1_subdev_internal_ops;
246 snprintf(subdev->name, sizeof(subdev->name), "%s rpf.%u", 250 snprintf(subdev->name, sizeof(subdev->name), "%s rpf.%u",
247 dev_name(vsp1->dev), index); 251 dev_name(vsp1->dev), index);
@@ -252,8 +256,9 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
252 256
253 /* Initialize the control handler. */ 257 /* Initialize the control handler. */
254 v4l2_ctrl_handler_init(&rpf->ctrls, 1); 258 v4l2_ctrl_handler_init(&rpf->ctrls, 1);
255 v4l2_ctrl_new_std(&rpf->ctrls, &rpf_ctrl_ops, V4L2_CID_ALPHA_COMPONENT, 259 rpf->alpha = v4l2_ctrl_new_std(&rpf->ctrls, &rpf_ctrl_ops,
256 0, 255, 1, 255); 260 V4L2_CID_ALPHA_COMPONENT,
261 0, 255, 1, 255);
257 262
258 rpf->entity.subdev.ctrl_handler = &rpf->ctrls; 263 rpf->entity.subdev.ctrl_handler = &rpf->ctrls;
259 264
@@ -264,42 +269,9 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
264 goto error; 269 goto error;
265 } 270 }
266 271
267 /* Initialize the video device. */
268 video = &rpf->video;
269
270 video->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
271 video->vsp1 = vsp1;
272 video->ops = &rpf_vdev_ops;
273
274 ret = vsp1_video_init(video, &rpf->entity);
275 if (ret < 0)
276 goto error;
277
278 rpf->entity.video = video;
279
280 return rpf; 272 return rpf;
281 273
282error: 274error:
283 vsp1_entity_destroy(&rpf->entity); 275 vsp1_entity_destroy(&rpf->entity);
284 return ERR_PTR(ret); 276 return ERR_PTR(ret);
285} 277}
286
287/*
288 * vsp1_rpf_create_links() - RPF pads links creation
289 * @vsp1: Pointer to VSP1 device
290 * @entity: Pointer to VSP1 entity
291 *
292 * return negative error code or zero on success
293 */
294int vsp1_rpf_create_links(struct vsp1_device *vsp1,
295 struct vsp1_entity *entity)
296{
297 struct vsp1_rwpf *rpf = to_rwpf(&entity->subdev);
298
299 /* Connect the video device to the RPF. */
300 return media_create_pad_link(&rpf->video.video.entity, 0,
301 &rpf->entity.subdev.entity,
302 RWPF_PAD_SINK,
303 MEDIA_LNK_FL_ENABLED |
304 MEDIA_LNK_FL_IMMUTABLE);
305}
diff --git a/drivers/media/platform/vsp1/vsp1_rwpf.h b/drivers/media/platform/vsp1/vsp1_rwpf.h
index 731d36e5258d..8e8235682ada 100644
--- a/drivers/media/platform/vsp1/vsp1_rwpf.h
+++ b/drivers/media/platform/vsp1/vsp1_rwpf.h
@@ -19,19 +19,39 @@
19 19
20#include "vsp1.h" 20#include "vsp1.h"
21#include "vsp1_entity.h" 21#include "vsp1_entity.h"
22#include "vsp1_video.h"
23 22
24#define RWPF_PAD_SINK 0 23#define RWPF_PAD_SINK 0
25#define RWPF_PAD_SOURCE 1 24#define RWPF_PAD_SOURCE 1
26 25
26struct v4l2_ctrl;
27struct vsp1_rwpf;
28struct vsp1_video;
29
30struct vsp1_rwpf_memory {
31 unsigned int num_planes;
32 dma_addr_t addr[3];
33 unsigned int length[3];
34};
35
36struct vsp1_rwpf_operations {
37 void (*set_memory)(struct vsp1_rwpf *rwpf,
38 struct vsp1_rwpf_memory *mem);
39};
40
27struct vsp1_rwpf { 41struct vsp1_rwpf {
28 struct vsp1_entity entity; 42 struct vsp1_entity entity;
29 struct vsp1_video video;
30 struct v4l2_ctrl_handler ctrls; 43 struct v4l2_ctrl_handler ctrls;
44 struct v4l2_ctrl *alpha;
45
46 struct vsp1_video *video;
47
48 const struct vsp1_rwpf_operations *ops;
31 49
32 unsigned int max_width; 50 unsigned int max_width;
33 unsigned int max_height; 51 unsigned int max_height;
34 52
53 struct v4l2_pix_format_mplane format;
54 const struct vsp1_format_info *fmtinfo;
35 struct { 55 struct {
36 unsigned int left; 56 unsigned int left;
37 unsigned int top; 57 unsigned int top;
@@ -50,11 +70,6 @@ static inline struct vsp1_rwpf *to_rwpf(struct v4l2_subdev *subdev)
50struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index); 70struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index);
51struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index); 71struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index);
52 72
53int vsp1_rpf_create_links(struct vsp1_device *vsp1,
54 struct vsp1_entity *entity);
55int vsp1_wpf_create_links(struct vsp1_device *vsp1,
56 struct vsp1_entity *entity);
57
58int vsp1_rwpf_enum_mbus_code(struct v4l2_subdev *subdev, 73int vsp1_rwpf_enum_mbus_code(struct v4l2_subdev *subdev,
59 struct v4l2_subdev_pad_config *cfg, 74 struct v4l2_subdev_pad_config *cfg,
60 struct v4l2_subdev_mbus_code_enum *code); 75 struct v4l2_subdev_mbus_code_enum *code);
diff --git a/drivers/media/platform/vsp1/vsp1_sru.c b/drivers/media/platform/vsp1/vsp1_sru.c
index 6310acab60e7..cc09efbfb24f 100644
--- a/drivers/media/platform/vsp1/vsp1_sru.c
+++ b/drivers/media/platform/vsp1/vsp1_sru.c
@@ -151,10 +151,13 @@ static int sru_s_stream(struct v4l2_subdev *subdev, int enable)
151 /* Take the control handler lock to ensure that the CTRL0 value won't be 151 /* Take the control handler lock to ensure that the CTRL0 value won't be
152 * changed behind our back by a set control operation. 152 * changed behind our back by a set control operation.
153 */ 153 */
154 mutex_lock(sru->ctrls.lock); 154 if (sru->entity.vsp1->info->uapi)
155 mutex_lock(sru->ctrls.lock);
155 ctrl0 |= vsp1_sru_read(sru, VI6_SRU_CTRL0) 156 ctrl0 |= vsp1_sru_read(sru, VI6_SRU_CTRL0)
156 & (VI6_SRU_CTRL0_PARAM0_MASK | VI6_SRU_CTRL0_PARAM1_MASK); 157 & (VI6_SRU_CTRL0_PARAM0_MASK | VI6_SRU_CTRL0_PARAM1_MASK);
157 mutex_unlock(sru->ctrls.lock); 158 vsp1_sru_write(sru, VI6_SRU_CTRL0, ctrl0);
159 if (sru->entity.vsp1->info->uapi)
160 mutex_unlock(sru->ctrls.lock);
158 161
159 vsp1_sru_write(sru, VI6_SRU_CTRL1, VI6_SRU_CTRL1_PARAM5); 162 vsp1_sru_write(sru, VI6_SRU_CTRL1, VI6_SRU_CTRL1_PARAM5);
160 163
@@ -360,7 +363,7 @@ struct vsp1_sru *vsp1_sru_create(struct vsp1_device *vsp1)
360 subdev = &sru->entity.subdev; 363 subdev = &sru->entity.subdev;
361 v4l2_subdev_init(subdev, &sru_ops); 364 v4l2_subdev_init(subdev, &sru_ops);
362 365
363 subdev->entity.ops = &vsp1_media_ops; 366 subdev->entity.ops = &vsp1->media_ops;
364 subdev->internal_ops = &vsp1_subdev_internal_ops; 367 subdev->internal_ops = &vsp1_subdev_internal_ops;
365 snprintf(subdev->name, sizeof(subdev->name), "%s sru", 368 snprintf(subdev->name, sizeof(subdev->name), "%s sru",
366 dev_name(vsp1->dev)); 369 dev_name(vsp1->dev));
diff --git a/drivers/media/platform/vsp1/vsp1_uds.c b/drivers/media/platform/vsp1/vsp1_uds.c
index ccc8243e3493..bba67770cf95 100644
--- a/drivers/media/platform/vsp1/vsp1_uds.c
+++ b/drivers/media/platform/vsp1/vsp1_uds.c
@@ -29,12 +29,6 @@
29 * Device Access 29 * Device Access
30 */ 30 */
31 31
32static inline u32 vsp1_uds_read(struct vsp1_uds *uds, u32 reg)
33{
34 return vsp1_read(uds->entity.vsp1,
35 reg + uds->entity.index * VI6_UDS_OFFSET);
36}
37
38static inline void vsp1_uds_write(struct vsp1_uds *uds, u32 reg, u32 data) 32static inline void vsp1_uds_write(struct vsp1_uds *uds, u32 reg, u32 data)
39{ 33{
40 vsp1_write(uds->entity.vsp1, 34 vsp1_write(uds->entity.vsp1,
@@ -344,7 +338,7 @@ struct vsp1_uds *vsp1_uds_create(struct vsp1_device *vsp1, unsigned int index)
344 subdev = &uds->entity.subdev; 338 subdev = &uds->entity.subdev;
345 v4l2_subdev_init(subdev, &uds_ops); 339 v4l2_subdev_init(subdev, &uds_ops);
346 340
347 subdev->entity.ops = &vsp1_media_ops; 341 subdev->entity.ops = &vsp1->media_ops;
348 subdev->internal_ops = &vsp1_subdev_internal_ops; 342 subdev->internal_ops = &vsp1_subdev_internal_ops;
349 snprintf(subdev->name, sizeof(subdev->name), "%s uds.%u", 343 snprintf(subdev->name, sizeof(subdev->name), "%s uds.%u",
350 dev_name(vsp1->dev), index); 344 dev_name(vsp1->dev), index);
diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c
index b4dca57d1ae3..72cc7d3729f8 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -14,10 +14,10 @@
14#include <linux/list.h> 14#include <linux/list.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/mutex.h> 16#include <linux/mutex.h>
17#include <linux/sched.h>
18#include <linux/slab.h> 17#include <linux/slab.h>
19#include <linux/v4l2-mediabus.h> 18#include <linux/v4l2-mediabus.h>
20#include <linux/videodev2.h> 19#include <linux/videodev2.h>
20#include <linux/wait.h>
21 21
22#include <media/media-entity.h> 22#include <media/media-entity.h>
23#include <media/v4l2-dev.h> 23#include <media/v4l2-dev.h>
@@ -30,6 +30,7 @@
30#include "vsp1.h" 30#include "vsp1.h"
31#include "vsp1_bru.h" 31#include "vsp1_bru.h"
32#include "vsp1_entity.h" 32#include "vsp1_entity.h"
33#include "vsp1_pipe.h"
33#include "vsp1_rwpf.h" 34#include "vsp1_rwpf.h"
34#include "vsp1_uds.h" 35#include "vsp1_uds.h"
35#include "vsp1_video.h" 36#include "vsp1_video.h"
@@ -47,113 +48,6 @@
47 * Helper functions 48 * Helper functions
48 */ 49 */
49 50
50static const struct vsp1_format_info vsp1_video_formats[] = {
51 { V4L2_PIX_FMT_RGB332, MEDIA_BUS_FMT_ARGB8888_1X32,
52 VI6_FMT_RGB_332, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
53 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
54 1, { 8, 0, 0 }, false, false, 1, 1, false },
55 { V4L2_PIX_FMT_ARGB444, MEDIA_BUS_FMT_ARGB8888_1X32,
56 VI6_FMT_ARGB_4444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
57 VI6_RPF_DSWAP_P_WDS,
58 1, { 16, 0, 0 }, false, false, 1, 1, true },
59 { V4L2_PIX_FMT_XRGB444, MEDIA_BUS_FMT_ARGB8888_1X32,
60 VI6_FMT_XRGB_4444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
61 VI6_RPF_DSWAP_P_WDS,
62 1, { 16, 0, 0 }, false, false, 1, 1, true },
63 { V4L2_PIX_FMT_ARGB555, MEDIA_BUS_FMT_ARGB8888_1X32,
64 VI6_FMT_ARGB_1555, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
65 VI6_RPF_DSWAP_P_WDS,
66 1, { 16, 0, 0 }, false, false, 1, 1, true },
67 { V4L2_PIX_FMT_XRGB555, MEDIA_BUS_FMT_ARGB8888_1X32,
68 VI6_FMT_XRGB_1555, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
69 VI6_RPF_DSWAP_P_WDS,
70 1, { 16, 0, 0 }, false, false, 1, 1, false },
71 { V4L2_PIX_FMT_RGB565, MEDIA_BUS_FMT_ARGB8888_1X32,
72 VI6_FMT_RGB_565, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
73 VI6_RPF_DSWAP_P_WDS,
74 1, { 16, 0, 0 }, false, false, 1, 1, false },
75 { V4L2_PIX_FMT_BGR24, MEDIA_BUS_FMT_ARGB8888_1X32,
76 VI6_FMT_BGR_888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
77 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
78 1, { 24, 0, 0 }, false, false, 1, 1, false },
79 { V4L2_PIX_FMT_RGB24, MEDIA_BUS_FMT_ARGB8888_1X32,
80 VI6_FMT_RGB_888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
81 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
82 1, { 24, 0, 0 }, false, false, 1, 1, false },
83 { V4L2_PIX_FMT_ABGR32, MEDIA_BUS_FMT_ARGB8888_1X32,
84 VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS,
85 1, { 32, 0, 0 }, false, false, 1, 1, true },
86 { V4L2_PIX_FMT_XBGR32, MEDIA_BUS_FMT_ARGB8888_1X32,
87 VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS,
88 1, { 32, 0, 0 }, false, false, 1, 1, false },
89 { V4L2_PIX_FMT_ARGB32, MEDIA_BUS_FMT_ARGB8888_1X32,
90 VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
91 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
92 1, { 32, 0, 0 }, false, false, 1, 1, true },
93 { V4L2_PIX_FMT_XRGB32, MEDIA_BUS_FMT_ARGB8888_1X32,
94 VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
95 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
96 1, { 32, 0, 0 }, false, false, 1, 1, false },
97 { V4L2_PIX_FMT_UYVY, MEDIA_BUS_FMT_AYUV8_1X32,
98 VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
99 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
100 1, { 16, 0, 0 }, false, false, 2, 1, false },
101 { V4L2_PIX_FMT_VYUY, MEDIA_BUS_FMT_AYUV8_1X32,
102 VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
103 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
104 1, { 16, 0, 0 }, false, true, 2, 1, false },
105 { V4L2_PIX_FMT_YUYV, MEDIA_BUS_FMT_AYUV8_1X32,
106 VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
107 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
108 1, { 16, 0, 0 }, true, false, 2, 1, false },
109 { V4L2_PIX_FMT_YVYU, MEDIA_BUS_FMT_AYUV8_1X32,
110 VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
111 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
112 1, { 16, 0, 0 }, true, true, 2, 1, false },
113 { V4L2_PIX_FMT_NV12M, MEDIA_BUS_FMT_AYUV8_1X32,
114 VI6_FMT_Y_UV_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
115 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
116 2, { 8, 16, 0 }, false, false, 2, 2, false },
117 { V4L2_PIX_FMT_NV21M, MEDIA_BUS_FMT_AYUV8_1X32,
118 VI6_FMT_Y_UV_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
119 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
120 2, { 8, 16, 0 }, false, true, 2, 2, false },
121 { V4L2_PIX_FMT_NV16M, MEDIA_BUS_FMT_AYUV8_1X32,
122 VI6_FMT_Y_UV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
123 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
124 2, { 8, 16, 0 }, false, false, 2, 1, false },
125 { V4L2_PIX_FMT_NV61M, MEDIA_BUS_FMT_AYUV8_1X32,
126 VI6_FMT_Y_UV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
127 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
128 2, { 8, 16, 0 }, false, true, 2, 1, false },
129 { V4L2_PIX_FMT_YUV420M, MEDIA_BUS_FMT_AYUV8_1X32,
130 VI6_FMT_Y_U_V_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
131 VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
132 3, { 8, 8, 8 }, false, false, 2, 2, false },
133};
134
135/*
136 * vsp1_get_format_info - Retrieve format information for a 4CC
137 * @fourcc: the format 4CC
138 *
139 * Return a pointer to the format information structure corresponding to the
140 * given V4L2 format 4CC, or NULL if no corresponding format can be found.
141 */
142static const struct vsp1_format_info *vsp1_get_format_info(u32 fourcc)
143{
144 unsigned int i;
145
146 for (i = 0; i < ARRAY_SIZE(vsp1_video_formats); ++i) {
147 const struct vsp1_format_info *info = &vsp1_video_formats[i];
148
149 if (info->fourcc == fourcc)
150 return info;
151 }
152
153 return NULL;
154}
155
156
157static struct v4l2_subdev * 51static struct v4l2_subdev *
158vsp1_video_remote_subdev(struct media_pad *local, u32 *pad) 52vsp1_video_remote_subdev(struct media_pad *local, u32 *pad)
159{ 53{
@@ -184,9 +78,9 @@ static int vsp1_video_verify_format(struct vsp1_video *video)
184 if (ret < 0) 78 if (ret < 0)
185 return ret == -ENOIOCTLCMD ? -EINVAL : ret; 79 return ret == -ENOIOCTLCMD ? -EINVAL : ret;
186 80
187 if (video->fmtinfo->mbus != fmt.format.code || 81 if (video->rwpf->fmtinfo->mbus != fmt.format.code ||
188 video->format.height != fmt.format.height || 82 video->rwpf->format.height != fmt.format.height ||
189 video->format.width != fmt.format.width) 83 video->rwpf->format.width != fmt.format.width)
190 return -EINVAL; 84 return -EINVAL;
191 85
192 return 0; 86 return 0;
@@ -277,9 +171,9 @@ static int __vsp1_video_try_format(struct vsp1_video *video,
277 * Pipeline Management 171 * Pipeline Management
278 */ 172 */
279 173
280static int vsp1_pipeline_validate_branch(struct vsp1_pipeline *pipe, 174static int vsp1_video_pipeline_validate_branch(struct vsp1_pipeline *pipe,
281 struct vsp1_rwpf *input, 175 struct vsp1_rwpf *input,
282 struct vsp1_rwpf *output) 176 struct vsp1_rwpf *output)
283{ 177{
284 struct vsp1_entity *entity; 178 struct vsp1_entity *entity;
285 struct media_entity_enum ent_enum; 179 struct media_entity_enum ent_enum;
@@ -370,29 +264,8 @@ out:
370 return rval; 264 return rval;
371} 265}
372 266
373static void __vsp1_pipeline_cleanup(struct vsp1_pipeline *pipe) 267static int vsp1_video_pipeline_validate(struct vsp1_pipeline *pipe,
374{ 268 struct vsp1_video *video)
375 if (pipe->bru) {
376 struct vsp1_bru *bru = to_bru(&pipe->bru->subdev);
377 unsigned int i;
378
379 for (i = 0; i < ARRAY_SIZE(bru->inputs); ++i)
380 bru->inputs[i].rpf = NULL;
381 }
382
383 INIT_LIST_HEAD(&pipe->entities);
384 pipe->state = VSP1_PIPELINE_STOPPED;
385 pipe->buffers_ready = 0;
386 pipe->num_video = 0;
387 pipe->num_inputs = 0;
388 pipe->output = NULL;
389 pipe->bru = NULL;
390 pipe->lif = NULL;
391 pipe->uds = NULL;
392}
393
394static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe,
395 struct vsp1_video *video)
396{ 269{
397 struct media_entity_graph graph; 270 struct media_entity_graph graph;
398 struct media_entity *entity = &video->video.entity; 271 struct media_entity *entity = &video->video.entity;
@@ -416,10 +289,8 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe,
416 struct vsp1_rwpf *rwpf; 289 struct vsp1_rwpf *rwpf;
417 struct vsp1_entity *e; 290 struct vsp1_entity *e;
418 291
419 if (is_media_entity_v4l2_io(entity)) { 292 if (!is_media_entity_v4l2_subdev(entity))
420 pipe->num_video++;
421 continue; 293 continue;
422 }
423 294
424 subdev = media_entity_to_v4l2_subdev(entity); 295 subdev = media_entity_to_v4l2_subdev(entity);
425 e = to_vsp1_entity(subdev); 296 e = to_vsp1_entity(subdev);
@@ -427,12 +298,12 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe,
427 298
428 if (e->type == VSP1_ENTITY_RPF) { 299 if (e->type == VSP1_ENTITY_RPF) {
429 rwpf = to_rwpf(subdev); 300 rwpf = to_rwpf(subdev);
430 pipe->inputs[pipe->num_inputs++] = rwpf; 301 pipe->inputs[rwpf->entity.index] = rwpf;
431 rwpf->video.pipe_index = pipe->num_inputs; 302 rwpf->video->pipe_index = ++pipe->num_inputs;
432 } else if (e->type == VSP1_ENTITY_WPF) { 303 } else if (e->type == VSP1_ENTITY_WPF) {
433 rwpf = to_rwpf(subdev); 304 rwpf = to_rwpf(subdev);
434 pipe->output = to_rwpf(subdev); 305 pipe->output = rwpf;
435 rwpf->video.pipe_index = 0; 306 rwpf->video->pipe_index = 0;
436 } else if (e->type == VSP1_ENTITY_LIF) { 307 } else if (e->type == VSP1_ENTITY_LIF) {
437 pipe->lif = e; 308 pipe->lif = e;
438 } else if (e->type == VSP1_ENTITY_BRU) { 309 } else if (e->type == VSP1_ENTITY_BRU) {
@@ -453,9 +324,12 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe,
453 /* Follow links downstream for each input and make sure the graph 324 /* Follow links downstream for each input and make sure the graph
454 * contains no loop and that all branches end at the output WPF. 325 * contains no loop and that all branches end at the output WPF.
455 */ 326 */
456 for (i = 0; i < pipe->num_inputs; ++i) { 327 for (i = 0; i < video->vsp1->info->rpf_count; ++i) {
457 ret = vsp1_pipeline_validate_branch(pipe, pipe->inputs[i], 328 if (!pipe->inputs[i])
458 pipe->output); 329 continue;
330
331 ret = vsp1_video_pipeline_validate_branch(pipe, pipe->inputs[i],
332 pipe->output);
459 if (ret < 0) 333 if (ret < 0)
460 goto error; 334 goto error;
461 } 335 }
@@ -463,12 +337,12 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe,
463 return 0; 337 return 0;
464 338
465error: 339error:
466 __vsp1_pipeline_cleanup(pipe); 340 vsp1_pipeline_reset(pipe);
467 return ret; 341 return ret;
468} 342}
469 343
470static int vsp1_pipeline_init(struct vsp1_pipeline *pipe, 344static int vsp1_video_pipeline_init(struct vsp1_pipeline *pipe,
471 struct vsp1_video *video) 345 struct vsp1_video *video)
472{ 346{
473 int ret; 347 int ret;
474 348
@@ -476,7 +350,7 @@ static int vsp1_pipeline_init(struct vsp1_pipeline *pipe,
476 350
477 /* If we're the first user validate and initialize the pipeline. */ 351 /* If we're the first user validate and initialize the pipeline. */
478 if (pipe->use_count == 0) { 352 if (pipe->use_count == 0) {
479 ret = vsp1_pipeline_validate(pipe, video); 353 ret = vsp1_video_pipeline_validate(pipe, video);
480 if (ret < 0) 354 if (ret < 0)
481 goto done; 355 goto done;
482 } 356 }
@@ -489,75 +363,17 @@ done:
489 return ret; 363 return ret;
490} 364}
491 365
492static void vsp1_pipeline_cleanup(struct vsp1_pipeline *pipe) 366static void vsp1_video_pipeline_cleanup(struct vsp1_pipeline *pipe)
493{ 367{
494 mutex_lock(&pipe->lock); 368 mutex_lock(&pipe->lock);
495 369
496 /* If we're the last user clean up the pipeline. */ 370 /* If we're the last user clean up the pipeline. */
497 if (--pipe->use_count == 0) 371 if (--pipe->use_count == 0)
498 __vsp1_pipeline_cleanup(pipe); 372 vsp1_pipeline_reset(pipe);
499 373
500 mutex_unlock(&pipe->lock); 374 mutex_unlock(&pipe->lock);
501} 375}
502 376
503static void vsp1_pipeline_run(struct vsp1_pipeline *pipe)
504{
505 struct vsp1_device *vsp1 = pipe->output->entity.vsp1;
506
507 vsp1_write(vsp1, VI6_CMD(pipe->output->entity.index), VI6_CMD_STRCMD);
508 pipe->state = VSP1_PIPELINE_RUNNING;
509 pipe->buffers_ready = 0;
510}
511
512static bool vsp1_pipeline_stopped(struct vsp1_pipeline *pipe)
513{
514 unsigned long flags;
515 bool stopped;
516
517 spin_lock_irqsave(&pipe->irqlock, flags);
518 stopped = pipe->state == VSP1_PIPELINE_STOPPED;
519 spin_unlock_irqrestore(&pipe->irqlock, flags);
520
521 return stopped;
522}
523
524static int vsp1_pipeline_stop(struct vsp1_pipeline *pipe)
525{
526 struct vsp1_entity *entity;
527 unsigned long flags;
528 int ret;
529
530 spin_lock_irqsave(&pipe->irqlock, flags);
531 if (pipe->state == VSP1_PIPELINE_RUNNING)
532 pipe->state = VSP1_PIPELINE_STOPPING;
533 spin_unlock_irqrestore(&pipe->irqlock, flags);
534
535 ret = wait_event_timeout(pipe->wq, vsp1_pipeline_stopped(pipe),
536 msecs_to_jiffies(500));
537 ret = ret == 0 ? -ETIMEDOUT : 0;
538
539 list_for_each_entry(entity, &pipe->entities, list_pipe) {
540 if (entity->route && entity->route->reg)
541 vsp1_write(entity->vsp1, entity->route->reg,
542 VI6_DPR_NODE_UNUSED);
543
544 v4l2_subdev_call(&entity->subdev, video, s_stream, 0);
545 }
546
547 return ret;
548}
549
550static bool vsp1_pipeline_ready(struct vsp1_pipeline *pipe)
551{
552 unsigned int mask;
553
554 mask = ((1 << pipe->num_inputs) - 1) << 1;
555 if (!pipe->lif)
556 mask |= 1 << 0;
557
558 return pipe->buffers_ready == mask;
559}
560
561/* 377/*
562 * vsp1_video_complete_buffer - Complete the current buffer 378 * vsp1_video_complete_buffer - Complete the current buffer
563 * @video: the video node 379 * @video: the video node
@@ -572,12 +388,12 @@ static bool vsp1_pipeline_ready(struct vsp1_pipeline *pipe)
572 * 388 *
573 * Return the next queued buffer or NULL if the queue is empty. 389 * Return the next queued buffer or NULL if the queue is empty.
574 */ 390 */
575static struct vsp1_video_buffer * 391static struct vsp1_vb2_buffer *
576vsp1_video_complete_buffer(struct vsp1_video *video) 392vsp1_video_complete_buffer(struct vsp1_video *video)
577{ 393{
578 struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); 394 struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity);
579 struct vsp1_video_buffer *next = NULL; 395 struct vsp1_vb2_buffer *next = NULL;
580 struct vsp1_video_buffer *done; 396 struct vsp1_vb2_buffer *done;
581 unsigned long flags; 397 unsigned long flags;
582 unsigned int i; 398 unsigned int i;
583 399
@@ -589,7 +405,7 @@ vsp1_video_complete_buffer(struct vsp1_video *video)
589 } 405 }
590 406
591 done = list_first_entry(&video->irqqueue, 407 done = list_first_entry(&video->irqqueue,
592 struct vsp1_video_buffer, queue); 408 struct vsp1_vb2_buffer, queue);
593 409
594 /* In DU output mode reuse the buffer if the list is singular. */ 410 /* In DU output mode reuse the buffer if the list is singular. */
595 if (pipe->lif && list_is_singular(&video->irqqueue)) { 411 if (pipe->lif && list_is_singular(&video->irqqueue)) {
@@ -601,23 +417,25 @@ vsp1_video_complete_buffer(struct vsp1_video *video)
601 417
602 if (!list_empty(&video->irqqueue)) 418 if (!list_empty(&video->irqqueue))
603 next = list_first_entry(&video->irqqueue, 419 next = list_first_entry(&video->irqqueue,
604 struct vsp1_video_buffer, queue); 420 struct vsp1_vb2_buffer, queue);
605 421
606 spin_unlock_irqrestore(&video->irqlock, flags); 422 spin_unlock_irqrestore(&video->irqlock, flags);
607 423
608 done->buf.sequence = video->sequence++; 424 done->buf.sequence = video->sequence++;
609 done->buf.vb2_buf.timestamp = ktime_get_ns(); 425 done->buf.vb2_buf.timestamp = ktime_get_ns();
610 for (i = 0; i < done->buf.vb2_buf.num_planes; ++i) 426 for (i = 0; i < done->buf.vb2_buf.num_planes; ++i)
611 vb2_set_plane_payload(&done->buf.vb2_buf, i, done->length[i]); 427 vb2_set_plane_payload(&done->buf.vb2_buf, i,
428 done->mem.length[i]);
612 vb2_buffer_done(&done->buf.vb2_buf, VB2_BUF_STATE_DONE); 429 vb2_buffer_done(&done->buf.vb2_buf, VB2_BUF_STATE_DONE);
613 430
614 return next; 431 return next;
615} 432}
616 433
617static void vsp1_video_frame_end(struct vsp1_pipeline *pipe, 434static void vsp1_video_frame_end(struct vsp1_pipeline *pipe,
618 struct vsp1_video *video) 435 struct vsp1_rwpf *rwpf)
619{ 436{
620 struct vsp1_video_buffer *buf; 437 struct vsp1_video *video = rwpf->video;
438 struct vsp1_vb2_buffer *buf;
621 unsigned long flags; 439 unsigned long flags;
622 440
623 buf = vsp1_video_complete_buffer(video); 441 buf = vsp1_video_complete_buffer(video);
@@ -626,155 +444,27 @@ static void vsp1_video_frame_end(struct vsp1_pipeline *pipe,
626 444
627 spin_lock_irqsave(&pipe->irqlock, flags); 445 spin_lock_irqsave(&pipe->irqlock, flags);
628 446
629 video->ops->queue(video, buf); 447 video->rwpf->ops->set_memory(video->rwpf, &buf->mem);
630 pipe->buffers_ready |= 1 << video->pipe_index; 448 pipe->buffers_ready |= 1 << video->pipe_index;
631 449
632 spin_unlock_irqrestore(&pipe->irqlock, flags); 450 spin_unlock_irqrestore(&pipe->irqlock, flags);
633} 451}
634 452
635void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe) 453static void vsp1_video_pipeline_frame_end(struct vsp1_pipeline *pipe)
636{ 454{
637 enum vsp1_pipeline_state state; 455 struct vsp1_device *vsp1 = pipe->output->entity.vsp1;
638 unsigned long flags;
639 unsigned int i; 456 unsigned int i;
640 457
641 if (pipe == NULL)
642 return;
643
644 /* Complete buffers on all video nodes. */ 458 /* Complete buffers on all video nodes. */
645 for (i = 0; i < pipe->num_inputs; ++i) 459 for (i = 0; i < vsp1->info->rpf_count; ++i) {
646 vsp1_video_frame_end(pipe, &pipe->inputs[i]->video); 460 if (!pipe->inputs[i])
647
648 if (!pipe->lif)
649 vsp1_video_frame_end(pipe, &pipe->output->video);
650
651 spin_lock_irqsave(&pipe->irqlock, flags);
652
653 state = pipe->state;
654 pipe->state = VSP1_PIPELINE_STOPPED;
655
656 /* If a stop has been requested, mark the pipeline as stopped and
657 * return.
658 */
659 if (state == VSP1_PIPELINE_STOPPING) {
660 wake_up(&pipe->wq);
661 goto done;
662 }
663
664 /* Restart the pipeline if ready. */
665 if (vsp1_pipeline_ready(pipe))
666 vsp1_pipeline_run(pipe);
667
668done:
669 spin_unlock_irqrestore(&pipe->irqlock, flags);
670}
671
672/*
673 * Propagate the alpha value through the pipeline.
674 *
675 * As the UDS has restricted scaling capabilities when the alpha component needs
676 * to be scaled, we disable alpha scaling when the UDS input has a fixed alpha
677 * value. The UDS then outputs a fixed alpha value which needs to be programmed
678 * from the input RPF alpha.
679 */
680void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe,
681 struct vsp1_entity *input,
682 unsigned int alpha)
683{
684 struct vsp1_entity *entity;
685 struct media_pad *pad;
686
687 pad = media_entity_remote_pad(&input->pads[RWPF_PAD_SOURCE]);
688
689 while (pad) {
690 if (!is_media_entity_v4l2_subdev(pad->entity))
691 break;
692
693 entity = to_vsp1_entity(media_entity_to_v4l2_subdev(pad->entity));
694
695 /* The BRU background color has a fixed alpha value set to 255,
696 * the output alpha value is thus always equal to 255.
697 */
698 if (entity->type == VSP1_ENTITY_BRU)
699 alpha = 255;
700
701 if (entity->type == VSP1_ENTITY_UDS) {
702 struct vsp1_uds *uds = to_uds(&entity->subdev);
703
704 vsp1_uds_set_alpha(uds, alpha);
705 break;
706 }
707
708 pad = &entity->pads[entity->source_pad];
709 pad = media_entity_remote_pad(pad);
710 }
711}
712
713void vsp1_pipelines_suspend(struct vsp1_device *vsp1)
714{
715 unsigned long flags;
716 unsigned int i;
717 int ret;
718
719 /* To avoid increasing the system suspend time needlessly, loop over the
720 * pipelines twice, first to set them all to the stopping state, and then
721 * to wait for the stop to complete.
722 */
723 for (i = 0; i < vsp1->pdata.wpf_count; ++i) {
724 struct vsp1_rwpf *wpf = vsp1->wpf[i];
725 struct vsp1_pipeline *pipe;
726
727 if (wpf == NULL)
728 continue;
729
730 pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity);
731 if (pipe == NULL)
732 continue;
733
734 spin_lock_irqsave(&pipe->irqlock, flags);
735 if (pipe->state == VSP1_PIPELINE_RUNNING)
736 pipe->state = VSP1_PIPELINE_STOPPING;
737 spin_unlock_irqrestore(&pipe->irqlock, flags);
738 }
739
740 for (i = 0; i < vsp1->pdata.wpf_count; ++i) {
741 struct vsp1_rwpf *wpf = vsp1->wpf[i];
742 struct vsp1_pipeline *pipe;
743
744 if (wpf == NULL)
745 continue;
746
747 pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity);
748 if (pipe == NULL)
749 continue; 461 continue;
750 462
751 ret = wait_event_timeout(pipe->wq, vsp1_pipeline_stopped(pipe), 463 vsp1_video_frame_end(pipe, pipe->inputs[i]);
752 msecs_to_jiffies(500));
753 if (ret == 0)
754 dev_warn(vsp1->dev, "pipeline %u stop timeout\n",
755 wpf->entity.index);
756 } 464 }
757}
758
759void vsp1_pipelines_resume(struct vsp1_device *vsp1)
760{
761 unsigned int i;
762
763 /* Resume pipeline all running pipelines. */
764 for (i = 0; i < vsp1->pdata.wpf_count; ++i) {
765 struct vsp1_rwpf *wpf = vsp1->wpf[i];
766 struct vsp1_pipeline *pipe;
767 465
768 if (wpf == NULL) 466 if (!pipe->lif)
769 continue; 467 vsp1_video_frame_end(pipe, pipe->output);
770
771 pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity);
772 if (pipe == NULL)
773 continue;
774
775 if (vsp1_pipeline_ready(pipe))
776 vsp1_pipeline_run(pipe);
777 }
778} 468}
779 469
780/* ----------------------------------------------------------------------------- 470/* -----------------------------------------------------------------------------
@@ -787,7 +477,7 @@ vsp1_video_queue_setup(struct vb2_queue *vq,
787 unsigned int sizes[], void *alloc_ctxs[]) 477 unsigned int sizes[], void *alloc_ctxs[])
788{ 478{
789 struct vsp1_video *video = vb2_get_drv_priv(vq); 479 struct vsp1_video *video = vb2_get_drv_priv(vq);
790 const struct v4l2_pix_format_mplane *format = &video->format; 480 const struct v4l2_pix_format_mplane *format = &video->rwpf->format;
791 unsigned int i; 481 unsigned int i;
792 482
793 if (*nplanes) { 483 if (*nplanes) {
@@ -816,18 +506,20 @@ static int vsp1_video_buffer_prepare(struct vb2_buffer *vb)
816{ 506{
817 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); 507 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
818 struct vsp1_video *video = vb2_get_drv_priv(vb->vb2_queue); 508 struct vsp1_video *video = vb2_get_drv_priv(vb->vb2_queue);
819 struct vsp1_video_buffer *buf = to_vsp1_video_buffer(vbuf); 509 struct vsp1_vb2_buffer *buf = to_vsp1_vb2_buffer(vbuf);
820 const struct v4l2_pix_format_mplane *format = &video->format; 510 const struct v4l2_pix_format_mplane *format = &video->rwpf->format;
821 unsigned int i; 511 unsigned int i;
822 512
823 if (vb->num_planes < format->num_planes) 513 if (vb->num_planes < format->num_planes)
824 return -EINVAL; 514 return -EINVAL;
825 515
516 buf->mem.num_planes = vb->num_planes;
517
826 for (i = 0; i < vb->num_planes; ++i) { 518 for (i = 0; i < vb->num_planes; ++i) {
827 buf->addr[i] = vb2_dma_contig_plane_dma_addr(vb, i); 519 buf->mem.addr[i] = vb2_dma_contig_plane_dma_addr(vb, i);
828 buf->length[i] = vb2_plane_size(vb, i); 520 buf->mem.length[i] = vb2_plane_size(vb, i);
829 521
830 if (buf->length[i] < format->plane_fmt[i].sizeimage) 522 if (buf->mem.length[i] < format->plane_fmt[i].sizeimage)
831 return -EINVAL; 523 return -EINVAL;
832 } 524 }
833 525
@@ -839,7 +531,7 @@ static void vsp1_video_buffer_queue(struct vb2_buffer *vb)
839 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); 531 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
840 struct vsp1_video *video = vb2_get_drv_priv(vb->vb2_queue); 532 struct vsp1_video *video = vb2_get_drv_priv(vb->vb2_queue);
841 struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); 533 struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity);
842 struct vsp1_video_buffer *buf = to_vsp1_video_buffer(vbuf); 534 struct vsp1_vb2_buffer *buf = to_vsp1_vb2_buffer(vbuf);
843 unsigned long flags; 535 unsigned long flags;
844 bool empty; 536 bool empty;
845 537
@@ -853,7 +545,7 @@ static void vsp1_video_buffer_queue(struct vb2_buffer *vb)
853 545
854 spin_lock_irqsave(&pipe->irqlock, flags); 546 spin_lock_irqsave(&pipe->irqlock, flags);
855 547
856 video->ops->queue(video, buf); 548 video->rwpf->ops->set_memory(video->rwpf, &buf->mem);
857 pipe->buffers_ready |= 1 << video->pipe_index; 549 pipe->buffers_ready |= 1 << video->pipe_index;
858 550
859 if (vb2_is_streaming(&video->queue) && 551 if (vb2_is_streaming(&video->queue) &&
@@ -863,18 +555,6 @@ static void vsp1_video_buffer_queue(struct vb2_buffer *vb)
863 spin_unlock_irqrestore(&pipe->irqlock, flags); 555 spin_unlock_irqrestore(&pipe->irqlock, flags);
864} 556}
865 557
866static void vsp1_entity_route_setup(struct vsp1_entity *source)
867{
868 struct vsp1_entity *sink;
869
870 if (source->route->reg == 0)
871 return;
872
873 sink = container_of(source->sink, struct vsp1_entity, subdev.entity);
874 vsp1_write(source->vsp1, source->route->reg,
875 sink->route->inputs[source->sink_pad]);
876}
877
878static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count) 558static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count)
879{ 559{
880 struct vsp1_video *video = vb2_get_drv_priv(vq); 560 struct vsp1_video *video = vb2_get_drv_priv(vq);
@@ -884,7 +564,7 @@ static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count)
884 int ret; 564 int ret;
885 565
886 mutex_lock(&pipe->lock); 566 mutex_lock(&pipe->lock);
887 if (pipe->stream_count == pipe->num_video - 1) { 567 if (pipe->stream_count == pipe->num_inputs) {
888 if (pipe->uds) { 568 if (pipe->uds) {
889 struct vsp1_uds *uds = to_uds(&pipe->uds->subdev); 569 struct vsp1_uds *uds = to_uds(&pipe->uds->subdev);
890 570
@@ -900,7 +580,7 @@ static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count)
900 struct vsp1_rwpf *rpf = 580 struct vsp1_rwpf *rpf =
901 to_rwpf(&pipe->uds_input->subdev); 581 to_rwpf(&pipe->uds_input->subdev);
902 582
903 uds->scale_alpha = rpf->video.fmtinfo->alpha; 583 uds->scale_alpha = rpf->fmtinfo->alpha;
904 } 584 }
905 } 585 }
906 586
@@ -931,7 +611,7 @@ static void vsp1_video_stop_streaming(struct vb2_queue *vq)
931{ 611{
932 struct vsp1_video *video = vb2_get_drv_priv(vq); 612 struct vsp1_video *video = vb2_get_drv_priv(vq);
933 struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); 613 struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity);
934 struct vsp1_video_buffer *buffer; 614 struct vsp1_vb2_buffer *buffer;
935 unsigned long flags; 615 unsigned long flags;
936 int ret; 616 int ret;
937 617
@@ -944,7 +624,7 @@ static void vsp1_video_stop_streaming(struct vb2_queue *vq)
944 } 624 }
945 mutex_unlock(&pipe->lock); 625 mutex_unlock(&pipe->lock);
946 626
947 vsp1_pipeline_cleanup(pipe); 627 vsp1_video_pipeline_cleanup(pipe);
948 media_entity_pipeline_stop(&video->video.entity); 628 media_entity_pipeline_stop(&video->video.entity);
949 629
950 /* Remove all buffers from the IRQ queue. */ 630 /* Remove all buffers from the IRQ queue. */
@@ -1004,7 +684,7 @@ vsp1_video_get_format(struct file *file, void *fh, struct v4l2_format *format)
1004 return -EINVAL; 684 return -EINVAL;
1005 685
1006 mutex_lock(&video->lock); 686 mutex_lock(&video->lock);
1007 format->fmt.pix_mp = video->format; 687 format->fmt.pix_mp = video->rwpf->format;
1008 mutex_unlock(&video->lock); 688 mutex_unlock(&video->lock);
1009 689
1010 return 0; 690 return 0;
@@ -1044,8 +724,8 @@ vsp1_video_set_format(struct file *file, void *fh, struct v4l2_format *format)
1044 goto done; 724 goto done;
1045 } 725 }
1046 726
1047 video->format = format->fmt.pix_mp; 727 video->rwpf->format = format->fmt.pix_mp;
1048 video->fmtinfo = info; 728 video->rwpf->fmtinfo = info;
1049 729
1050done: 730done:
1051 mutex_unlock(&video->lock); 731 mutex_unlock(&video->lock);
@@ -1085,7 +765,7 @@ vsp1_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
1085 if (ret < 0) 765 if (ret < 0)
1086 goto err_stop; 766 goto err_stop;
1087 767
1088 ret = vsp1_pipeline_init(pipe, video); 768 ret = vsp1_video_pipeline_init(pipe, video);
1089 if (ret < 0) 769 if (ret < 0)
1090 goto err_stop; 770 goto err_stop;
1091 771
@@ -1097,7 +777,7 @@ vsp1_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
1097 return 0; 777 return 0;
1098 778
1099err_cleanup: 779err_cleanup:
1100 vsp1_pipeline_cleanup(pipe); 780 vsp1_video_pipeline_cleanup(pipe);
1101err_stop: 781err_stop:
1102 media_entity_pipeline_stop(&video->video.entity); 782 media_entity_pipeline_stop(&video->video.entity);
1103 return ret; 783 return ret;
@@ -1183,62 +863,64 @@ static struct v4l2_file_operations vsp1_video_fops = {
1183 * Initialization and Cleanup 863 * Initialization and Cleanup
1184 */ 864 */
1185 865
1186int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf) 866struct vsp1_video *vsp1_video_create(struct vsp1_device *vsp1,
867 struct vsp1_rwpf *rwpf)
1187{ 868{
869 struct vsp1_video *video;
1188 const char *direction; 870 const char *direction;
1189 int ret; 871 int ret;
1190 872
1191 switch (video->type) { 873 video = devm_kzalloc(vsp1->dev, sizeof(*video), GFP_KERNEL);
1192 case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: 874 if (!video)
1193 direction = "output"; 875 return ERR_PTR(-ENOMEM);
1194 video->pad.flags = MEDIA_PAD_FL_SINK; 876
1195 break; 877 rwpf->video = video;
878
879 video->vsp1 = vsp1;
880 video->rwpf = rwpf;
1196 881
1197 case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: 882 if (rwpf->entity.type == VSP1_ENTITY_RPF) {
1198 direction = "input"; 883 direction = "input";
884 video->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
1199 video->pad.flags = MEDIA_PAD_FL_SOURCE; 885 video->pad.flags = MEDIA_PAD_FL_SOURCE;
1200 video->video.vfl_dir = VFL_DIR_TX; 886 video->video.vfl_dir = VFL_DIR_TX;
1201 break; 887 } else {
1202 888 direction = "output";
1203 default: 889 video->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
1204 return -EINVAL; 890 video->pad.flags = MEDIA_PAD_FL_SINK;
891 video->video.vfl_dir = VFL_DIR_RX;
1205 } 892 }
1206 893
1207 video->rwpf = rwpf;
1208
1209 mutex_init(&video->lock); 894 mutex_init(&video->lock);
1210 spin_lock_init(&video->irqlock); 895 spin_lock_init(&video->irqlock);
1211 INIT_LIST_HEAD(&video->irqqueue); 896 INIT_LIST_HEAD(&video->irqqueue);
1212 897
1213 mutex_init(&video->pipe.lock); 898 vsp1_pipeline_init(&video->pipe);
1214 spin_lock_init(&video->pipe.irqlock); 899 video->pipe.frame_end = vsp1_video_pipeline_frame_end;
1215 INIT_LIST_HEAD(&video->pipe.entities);
1216 init_waitqueue_head(&video->pipe.wq);
1217 video->pipe.state = VSP1_PIPELINE_STOPPED;
1218 900
1219 /* Initialize the media entity... */ 901 /* Initialize the media entity... */
1220 ret = media_entity_pads_init(&video->video.entity, 1, &video->pad); 902 ret = media_entity_pads_init(&video->video.entity, 1, &video->pad);
1221 if (ret < 0) 903 if (ret < 0)
1222 return ret; 904 return ERR_PTR(ret);
1223 905
1224 /* ... and the format ... */ 906 /* ... and the format ... */
1225 video->fmtinfo = vsp1_get_format_info(VSP1_VIDEO_DEF_FORMAT); 907 rwpf->fmtinfo = vsp1_get_format_info(VSP1_VIDEO_DEF_FORMAT);
1226 video->format.pixelformat = video->fmtinfo->fourcc; 908 rwpf->format.pixelformat = rwpf->fmtinfo->fourcc;
1227 video->format.colorspace = V4L2_COLORSPACE_SRGB; 909 rwpf->format.colorspace = V4L2_COLORSPACE_SRGB;
1228 video->format.field = V4L2_FIELD_NONE; 910 rwpf->format.field = V4L2_FIELD_NONE;
1229 video->format.width = VSP1_VIDEO_DEF_WIDTH; 911 rwpf->format.width = VSP1_VIDEO_DEF_WIDTH;
1230 video->format.height = VSP1_VIDEO_DEF_HEIGHT; 912 rwpf->format.height = VSP1_VIDEO_DEF_HEIGHT;
1231 video->format.num_planes = 1; 913 rwpf->format.num_planes = 1;
1232 video->format.plane_fmt[0].bytesperline = 914 rwpf->format.plane_fmt[0].bytesperline =
1233 video->format.width * video->fmtinfo->bpp[0] / 8; 915 rwpf->format.width * rwpf->fmtinfo->bpp[0] / 8;
1234 video->format.plane_fmt[0].sizeimage = 916 rwpf->format.plane_fmt[0].sizeimage =
1235 video->format.plane_fmt[0].bytesperline * video->format.height; 917 rwpf->format.plane_fmt[0].bytesperline * rwpf->format.height;
1236 918
1237 /* ... and the video node... */ 919 /* ... and the video node... */
1238 video->video.v4l2_dev = &video->vsp1->v4l2_dev; 920 video->video.v4l2_dev = &video->vsp1->v4l2_dev;
1239 video->video.fops = &vsp1_video_fops; 921 video->video.fops = &vsp1_video_fops;
1240 snprintf(video->video.name, sizeof(video->video.name), "%s %s", 922 snprintf(video->video.name, sizeof(video->video.name), "%s %s",
1241 rwpf->subdev.name, direction); 923 rwpf->entity.subdev.name, direction);
1242 video->video.vfl_type = VFL_TYPE_GRABBER; 924 video->video.vfl_type = VFL_TYPE_GRABBER;
1243 video->video.release = video_device_release_empty; 925 video->video.release = video_device_release_empty;
1244 video->video.ioctl_ops = &vsp1_video_ioctl_ops; 926 video->video.ioctl_ops = &vsp1_video_ioctl_ops;
@@ -1256,7 +938,7 @@ int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf)
1256 video->queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF; 938 video->queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
1257 video->queue.lock = &video->lock; 939 video->queue.lock = &video->lock;
1258 video->queue.drv_priv = video; 940 video->queue.drv_priv = video;
1259 video->queue.buf_struct_size = sizeof(struct vsp1_video_buffer); 941 video->queue.buf_struct_size = sizeof(struct vsp1_vb2_buffer);
1260 video->queue.ops = &vsp1_video_queue_qops; 942 video->queue.ops = &vsp1_video_queue_qops;
1261 video->queue.mem_ops = &vb2_dma_contig_memops; 943 video->queue.mem_ops = &vb2_dma_contig_memops;
1262 video->queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; 944 video->queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
@@ -1274,12 +956,12 @@ int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf)
1274 goto error; 956 goto error;
1275 } 957 }
1276 958
1277 return 0; 959 return video;
1278 960
1279error: 961error:
1280 vb2_dma_contig_cleanup_ctx(video->alloc_ctx); 962 vb2_dma_contig_cleanup_ctx(video->alloc_ctx);
1281 vsp1_video_cleanup(video); 963 vsp1_video_cleanup(video);
1282 return ret; 964 return ERR_PTR(ret);
1283} 965}
1284 966
1285void vsp1_video_cleanup(struct vsp1_video *video) 967void vsp1_video_cleanup(struct vsp1_video *video)
diff --git a/drivers/media/platform/vsp1/vsp1_video.h b/drivers/media/platform/vsp1/vsp1_video.h
index a929aa81cdbf..64abd39ee1e7 100644
--- a/drivers/media/platform/vsp1/vsp1_video.h
+++ b/drivers/media/platform/vsp1/vsp1_video.h
@@ -15,115 +15,34 @@
15 15
16#include <linux/list.h> 16#include <linux/list.h>
17#include <linux/spinlock.h> 17#include <linux/spinlock.h>
18#include <linux/wait.h>
19 18
20#include <media/media-entity.h>
21#include <media/videobuf2-v4l2.h> 19#include <media/videobuf2-v4l2.h>
22 20
23struct vsp1_video; 21#include "vsp1_pipe.h"
22#include "vsp1_rwpf.h"
24 23
25/* 24struct vsp1_vb2_buffer {
26 * struct vsp1_format_info - VSP1 video format description
27 * @mbus: media bus format code
28 * @fourcc: V4L2 pixel format FCC identifier
29 * @planes: number of planes
30 * @bpp: bits per pixel
31 * @hwfmt: VSP1 hardware format
32 * @swap_yc: the Y and C components are swapped (Y comes before C)
33 * @swap_uv: the U and V components are swapped (V comes before U)
34 * @hsub: horizontal subsampling factor
35 * @vsub: vertical subsampling factor
36 * @alpha: has an alpha channel
37 */
38struct vsp1_format_info {
39 u32 fourcc;
40 unsigned int mbus;
41 unsigned int hwfmt;
42 unsigned int swap;
43 unsigned int planes;
44 unsigned int bpp[3];
45 bool swap_yc;
46 bool swap_uv;
47 unsigned int hsub;
48 unsigned int vsub;
49 bool alpha;
50};
51
52enum vsp1_pipeline_state {
53 VSP1_PIPELINE_STOPPED,
54 VSP1_PIPELINE_RUNNING,
55 VSP1_PIPELINE_STOPPING,
56};
57
58/*
59 * struct vsp1_pipeline - A VSP1 hardware pipeline
60 * @media: the media pipeline
61 * @irqlock: protects the pipeline state
62 * @lock: protects the pipeline use count and stream count
63 */
64struct vsp1_pipeline {
65 struct media_pipeline pipe;
66
67 spinlock_t irqlock;
68 enum vsp1_pipeline_state state;
69 wait_queue_head_t wq;
70
71 struct mutex lock;
72 unsigned int use_count;
73 unsigned int stream_count;
74 unsigned int buffers_ready;
75
76 unsigned int num_video;
77 unsigned int num_inputs;
78 struct vsp1_rwpf *inputs[VSP1_MAX_RPF];
79 struct vsp1_rwpf *output;
80 struct vsp1_entity *bru;
81 struct vsp1_entity *lif;
82 struct vsp1_entity *uds;
83 struct vsp1_entity *uds_input;
84
85 struct list_head entities;
86};
87
88static inline struct vsp1_pipeline *to_vsp1_pipeline(struct media_entity *e)
89{
90 if (likely(e->pipe))
91 return container_of(e->pipe, struct vsp1_pipeline, pipe);
92 else
93 return NULL;
94}
95
96struct vsp1_video_buffer {
97 struct vb2_v4l2_buffer buf; 25 struct vb2_v4l2_buffer buf;
98 struct list_head queue; 26 struct list_head queue;
99 27 struct vsp1_rwpf_memory mem;
100 dma_addr_t addr[3];
101 unsigned int length[3];
102}; 28};
103 29
104static inline struct vsp1_video_buffer * 30static inline struct vsp1_vb2_buffer *
105to_vsp1_video_buffer(struct vb2_v4l2_buffer *vbuf) 31to_vsp1_vb2_buffer(struct vb2_v4l2_buffer *vbuf)
106{ 32{
107 return container_of(vbuf, struct vsp1_video_buffer, buf); 33 return container_of(vbuf, struct vsp1_vb2_buffer, buf);
108} 34}
109 35
110struct vsp1_video_operations {
111 void (*queue)(struct vsp1_video *video, struct vsp1_video_buffer *buf);
112};
113
114struct vsp1_video { 36struct vsp1_video {
37 struct list_head list;
115 struct vsp1_device *vsp1; 38 struct vsp1_device *vsp1;
116 struct vsp1_entity *rwpf; 39 struct vsp1_rwpf *rwpf;
117
118 const struct vsp1_video_operations *ops;
119 40
120 struct video_device video; 41 struct video_device video;
121 enum v4l2_buf_type type; 42 enum v4l2_buf_type type;
122 struct media_pad pad; 43 struct media_pad pad;
123 44
124 struct mutex lock; 45 struct mutex lock;
125 struct v4l2_pix_format_mplane format;
126 const struct vsp1_format_info *fmtinfo;
127 46
128 struct vsp1_pipeline pipe; 47 struct vsp1_pipeline pipe;
129 unsigned int pipe_index; 48 unsigned int pipe_index;
@@ -140,16 +59,8 @@ static inline struct vsp1_video *to_vsp1_video(struct video_device *vdev)
140 return container_of(vdev, struct vsp1_video, video); 59 return container_of(vdev, struct vsp1_video, video);
141} 60}
142 61
143int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf); 62struct vsp1_video *vsp1_video_create(struct vsp1_device *vsp1,
63 struct vsp1_rwpf *rwpf);
144void vsp1_video_cleanup(struct vsp1_video *video); 64void vsp1_video_cleanup(struct vsp1_video *video);
145 65
146void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe);
147
148void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe,
149 struct vsp1_entity *input,
150 unsigned int alpha);
151
152void vsp1_pipelines_suspend(struct vsp1_device *vsp1);
153void vsp1_pipelines_resume(struct vsp1_device *vsp1);
154
155#endif /* __VSP1_VIDEO_H__ */ 66#endif /* __VSP1_VIDEO_H__ */
diff --git a/drivers/media/platform/vsp1/vsp1_wpf.c b/drivers/media/platform/vsp1/vsp1_wpf.c
index cbf514a6582d..c78d4af50fcf 100644
--- a/drivers/media/platform/vsp1/vsp1_wpf.c
+++ b/drivers/media/platform/vsp1/vsp1_wpf.c
@@ -34,8 +34,8 @@ static inline u32 vsp1_wpf_read(struct vsp1_rwpf *wpf, u32 reg)
34 34
35static inline void vsp1_wpf_write(struct vsp1_rwpf *wpf, u32 reg, u32 data) 35static inline void vsp1_wpf_write(struct vsp1_rwpf *wpf, u32 reg, u32 data)
36{ 36{
37 vsp1_write(wpf->entity.vsp1, 37 vsp1_mod_write(&wpf->entity,
38 reg + wpf->entity.index * VI6_WPF_OFFSET, data); 38 reg + wpf->entity.index * VI6_WPF_OFFSET, data);
39} 39}
40 40
41/* ----------------------------------------------------------------------------- 41/* -----------------------------------------------------------------------------
@@ -88,7 +88,8 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
88 88
89 if (!enable) { 89 if (!enable) {
90 vsp1_write(vsp1, VI6_WPF_IRQ_ENB(wpf->entity.index), 0); 90 vsp1_write(vsp1, VI6_WPF_IRQ_ENB(wpf->entity.index), 0);
91 vsp1_wpf_write(wpf, VI6_WPF_SRCRPF, 0); 91 vsp1_write(vsp1, wpf->entity.index * VI6_WPF_OFFSET +
92 VI6_WPF_SRCRPF, 0);
92 return 0; 93 return 0;
93 } 94 }
94 95
@@ -97,9 +98,12 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
97 * inputs as sub-layers and select the virtual RPF as the master 98 * inputs as sub-layers and select the virtual RPF as the master
98 * layer. 99 * layer.
99 */ 100 */
100 for (i = 0; i < pipe->num_inputs; ++i) { 101 for (i = 0; i < vsp1->info->rpf_count; ++i) {
101 struct vsp1_rwpf *input = pipe->inputs[i]; 102 struct vsp1_rwpf *input = pipe->inputs[i];
102 103
104 if (!input)
105 continue;
106
103 srcrpf |= (!pipe->bru && pipe->num_inputs == 1) 107 srcrpf |= (!pipe->bru && pipe->num_inputs == 1)
104 ? VI6_WPF_SRCRPF_RPF_ACT_MST(input->entity.index) 108 ? VI6_WPF_SRCRPF_RPF_ACT_MST(input->entity.index)
105 : VI6_WPF_SRCRPF_RPF_ACT_SUB(input->entity.index); 109 : VI6_WPF_SRCRPF_RPF_ACT_SUB(input->entity.index);
@@ -112,7 +116,7 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
112 116
113 /* Destination stride. */ 117 /* Destination stride. */
114 if (!pipe->lif) { 118 if (!pipe->lif) {
115 struct v4l2_pix_format_mplane *format = &wpf->video.format; 119 struct v4l2_pix_format_mplane *format = &wpf->format;
116 120
117 vsp1_wpf_write(wpf, VI6_WPF_DSTM_STRIDE_Y, 121 vsp1_wpf_write(wpf, VI6_WPF_DSTM_STRIDE_Y,
118 format->plane_fmt[0].bytesperline); 122 format->plane_fmt[0].bytesperline);
@@ -130,7 +134,7 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
130 134
131 /* Format */ 135 /* Format */
132 if (!pipe->lif) { 136 if (!pipe->lif) {
133 const struct vsp1_format_info *fmtinfo = wpf->video.fmtinfo; 137 const struct vsp1_format_info *fmtinfo = wpf->fmtinfo;
134 138
135 outfmt = fmtinfo->hwfmt << VI6_WPF_OUTFMT_WRFMT_SHIFT; 139 outfmt = fmtinfo->hwfmt << VI6_WPF_OUTFMT_WRFMT_SHIFT;
136 140
@@ -151,15 +155,17 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
151 /* Take the control handler lock to ensure that the PDV value won't be 155 /* Take the control handler lock to ensure that the PDV value won't be
152 * changed behind our back by a set control operation. 156 * changed behind our back by a set control operation.
153 */ 157 */
154 mutex_lock(wpf->ctrls.lock); 158 if (vsp1->info->uapi)
155 outfmt |= vsp1_wpf_read(wpf, VI6_WPF_OUTFMT) & VI6_WPF_OUTFMT_PDV_MASK; 159 mutex_lock(wpf->ctrls.lock);
160 outfmt |= wpf->alpha->cur.val << VI6_WPF_OUTFMT_PDV_SHIFT;
156 vsp1_wpf_write(wpf, VI6_WPF_OUTFMT, outfmt); 161 vsp1_wpf_write(wpf, VI6_WPF_OUTFMT, outfmt);
157 mutex_unlock(wpf->ctrls.lock); 162 if (vsp1->info->uapi)
163 mutex_unlock(wpf->ctrls.lock);
158 164
159 vsp1_write(vsp1, VI6_DPR_WPF_FPORCH(wpf->entity.index), 165 vsp1_mod_write(&wpf->entity, VI6_DPR_WPF_FPORCH(wpf->entity.index),
160 VI6_DPR_WPF_FPORCH_FP_WPFN); 166 VI6_DPR_WPF_FPORCH_FP_WPFN);
161 167
162 vsp1_write(vsp1, VI6_WPF_WRBCK_CTRL, 0); 168 vsp1_mod_write(&wpf->entity, VI6_WPF_WRBCK_CTRL, 0);
163 169
164 /* Enable interrupts */ 170 /* Enable interrupts */
165 vsp1_write(vsp1, VI6_WPF_IRQ_STA(wpf->entity.index), 0); 171 vsp1_write(vsp1, VI6_WPF_IRQ_STA(wpf->entity.index), 0);
@@ -195,20 +201,17 @@ static struct v4l2_subdev_ops wpf_ops = {
195 * Video Device Operations 201 * Video Device Operations
196 */ 202 */
197 203
198static void wpf_vdev_queue(struct vsp1_video *video, 204static void wpf_set_memory(struct vsp1_rwpf *wpf, struct vsp1_rwpf_memory *mem)
199 struct vsp1_video_buffer *buf)
200{ 205{
201 struct vsp1_rwpf *wpf = container_of(video, struct vsp1_rwpf, video); 206 vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_Y, mem->addr[0]);
202 207 if (mem->num_planes > 1)
203 vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_Y, buf->addr[0]); 208 vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_C0, mem->addr[1]);
204 if (buf->buf.vb2_buf.num_planes > 1) 209 if (mem->num_planes > 2)
205 vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_C0, buf->addr[1]); 210 vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_C1, mem->addr[2]);
206 if (buf->buf.vb2_buf.num_planes > 2)
207 vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_C1, buf->addr[2]);
208} 211}
209 212
210static const struct vsp1_video_operations wpf_vdev_ops = { 213static const struct vsp1_rwpf_operations wpf_vdev_ops = {
211 .queue = wpf_vdev_queue, 214 .set_memory = wpf_set_memory,
212}; 215};
213 216
214/* ----------------------------------------------------------------------------- 217/* -----------------------------------------------------------------------------
@@ -218,7 +221,6 @@ static const struct vsp1_video_operations wpf_vdev_ops = {
218struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index) 221struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
219{ 222{
220 struct v4l2_subdev *subdev; 223 struct v4l2_subdev *subdev;
221 struct vsp1_video *video;
222 struct vsp1_rwpf *wpf; 224 struct vsp1_rwpf *wpf;
223 int ret; 225 int ret;
224 226
@@ -226,6 +228,8 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
226 if (wpf == NULL) 228 if (wpf == NULL)
227 return ERR_PTR(-ENOMEM); 229 return ERR_PTR(-ENOMEM);
228 230
231 wpf->ops = &wpf_vdev_ops;
232
229 wpf->max_width = WPF_MAX_WIDTH; 233 wpf->max_width = WPF_MAX_WIDTH;
230 wpf->max_height = WPF_MAX_HEIGHT; 234 wpf->max_height = WPF_MAX_HEIGHT;
231 235
@@ -240,7 +244,7 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
240 subdev = &wpf->entity.subdev; 244 subdev = &wpf->entity.subdev;
241 v4l2_subdev_init(subdev, &wpf_ops); 245 v4l2_subdev_init(subdev, &wpf_ops);
242 246
243 subdev->entity.ops = &vsp1_media_ops; 247 subdev->entity.ops = &vsp1->media_ops;
244 subdev->internal_ops = &vsp1_subdev_internal_ops; 248 subdev->internal_ops = &vsp1_subdev_internal_ops;
245 snprintf(subdev->name, sizeof(subdev->name), "%s wpf.%u", 249 snprintf(subdev->name, sizeof(subdev->name), "%s wpf.%u",
246 dev_name(vsp1->dev), index); 250 dev_name(vsp1->dev), index);
@@ -251,8 +255,9 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
251 255
252 /* Initialize the control handler. */ 256 /* Initialize the control handler. */
253 v4l2_ctrl_handler_init(&wpf->ctrls, 1); 257 v4l2_ctrl_handler_init(&wpf->ctrls, 1);
254 v4l2_ctrl_new_std(&wpf->ctrls, &wpf_ctrl_ops, V4L2_CID_ALPHA_COMPONENT, 258 wpf->alpha = v4l2_ctrl_new_std(&wpf->ctrls, &wpf_ctrl_ops,
255 0, 255, 1, 255); 259 V4L2_CID_ALPHA_COMPONENT,
260 0, 255, 1, 255);
256 261
257 wpf->entity.subdev.ctrl_handler = &wpf->ctrls; 262 wpf->entity.subdev.ctrl_handler = &wpf->ctrls;
258 263
@@ -263,48 +268,9 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
263 goto error; 268 goto error;
264 } 269 }
265 270
266 /* Initialize the video device. */
267 video = &wpf->video;
268
269 video->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
270 video->vsp1 = vsp1;
271 video->ops = &wpf_vdev_ops;
272
273 ret = vsp1_video_init(video, &wpf->entity);
274 if (ret < 0)
275 goto error;
276
277 wpf->entity.video = video;
278 wpf->entity.sink = &wpf->video.video.entity;
279
280 return wpf; 271 return wpf;
281 272
282error: 273error:
283 vsp1_entity_destroy(&wpf->entity); 274 vsp1_entity_destroy(&wpf->entity);
284 return ERR_PTR(ret); 275 return ERR_PTR(ret);
285} 276}
286
287/*
288 * vsp1_wpf_create_links() - RPF pads links creation
289 * @vsp1: Pointer to VSP1 device
290 * @entity: Pointer to VSP1 entity
291 *
292 * return negative error code or zero on success
293 */
294int vsp1_wpf_create_links(struct vsp1_device *vsp1,
295 struct vsp1_entity *entity)
296{
297 struct vsp1_rwpf *wpf = to_rwpf(&entity->subdev);
298 unsigned int flags;
299
300 /* Connect the video device to the WPF. All connections are immutable
301 * except for the WPF0 source link if a LIF is present.
302 */
303 flags = MEDIA_LNK_FL_ENABLED;
304 if (!(vsp1->pdata.features & VSP1_HAS_LIF) || entity->index != 0)
305 flags |= MEDIA_LNK_FL_IMMUTABLE;
306
307 return media_create_pad_link(&wpf->entity.subdev.entity,
308 RWPF_PAD_SOURCE,
309 &wpf->video.video.entity, 0, flags);
310}
diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
index 859f0c08ee05..271f725b17e8 100644
--- a/drivers/media/radio/radio-si476x.c
+++ b/drivers/media/radio/radio-si476x.c
@@ -1530,11 +1530,11 @@ static int si476x_radio_probe(struct platform_device *pdev)
1530 if (si476x_core_has_diversity(radio->core)) { 1530 if (si476x_core_has_diversity(radio->core)) {
1531 si476x_ctrls[SI476X_IDX_DIVERSITY_MODE].def = 1531 si476x_ctrls[SI476X_IDX_DIVERSITY_MODE].def =
1532 si476x_phase_diversity_mode_to_idx(radio->core->diversity_mode); 1532 si476x_phase_diversity_mode_to_idx(radio->core->diversity_mode);
1533 si476x_radio_add_new_custom(radio, SI476X_IDX_DIVERSITY_MODE); 1533 rval = si476x_radio_add_new_custom(radio, SI476X_IDX_DIVERSITY_MODE);
1534 if (rval < 0) 1534 if (rval < 0)
1535 goto exit; 1535 goto exit;
1536 1536
1537 si476x_radio_add_new_custom(radio, SI476X_IDX_INTERCHIP_LINK); 1537 rval = si476x_radio_add_new_custom(radio, SI476X_IDX_INTERCHIP_LINK);
1538 if (rval < 0) 1538 if (rval < 0)
1539 goto exit; 1539 goto exit;
1540 } 1540 }
diff --git a/drivers/media/radio/tea575x.c b/drivers/media/radio/tea575x.c
index 3e08475af579..4dc2067bce14 100644
--- a/drivers/media/radio/tea575x.c
+++ b/drivers/media/radio/tea575x.c
@@ -14,10 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */ 17 */
22 18
23#include <linux/delay.h> 19#include <linux/delay.h>
@@ -226,6 +222,7 @@ void snd_tea575x_set_freq(struct snd_tea575x *tea)
226 snd_tea575x_write(tea, tea->val); 222 snd_tea575x_write(tea, tea->val);
227 tea->freq = snd_tea575x_val_to_freq(tea, tea->val); 223 tea->freq = snd_tea575x_val_to_freq(tea, tea->val);
228} 224}
225EXPORT_SYMBOL(snd_tea575x_set_freq);
229 226
230/* 227/*
231 * Linux Video interface 228 * Linux Video interface
@@ -582,25 +579,11 @@ int snd_tea575x_init(struct snd_tea575x *tea, struct module *owner)
582 579
583 return 0; 580 return 0;
584} 581}
582EXPORT_SYMBOL(snd_tea575x_init);
585 583
586void snd_tea575x_exit(struct snd_tea575x *tea) 584void snd_tea575x_exit(struct snd_tea575x *tea)
587{ 585{
588 video_unregister_device(&tea->vd); 586 video_unregister_device(&tea->vd);
589 v4l2_ctrl_handler_free(tea->vd.ctrl_handler); 587 v4l2_ctrl_handler_free(tea->vd.ctrl_handler);
590} 588}
591
592static int __init alsa_tea575x_module_init(void)
593{
594 return 0;
595}
596
597static void __exit alsa_tea575x_module_exit(void)
598{
599}
600
601module_init(alsa_tea575x_module_init)
602module_exit(alsa_tea575x_module_exit)
603
604EXPORT_SYMBOL(snd_tea575x_init);
605EXPORT_SYMBOL(snd_tea575x_exit); 589EXPORT_SYMBOL(snd_tea575x_exit);
606EXPORT_SYMBOL(snd_tea575x_set_freq);
diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
index ebc73b034249..3f9e6df7d837 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -68,7 +68,7 @@ MODULE_PARM_DESC(default_radio_region, "Region: 0=Europe/US, 1=Japan");
68/* RDS buffer blocks */ 68/* RDS buffer blocks */
69static u32 default_rds_buf = 300; 69static u32 default_rds_buf = 300;
70module_param(default_rds_buf, uint, 0444); 70module_param(default_rds_buf, uint, 0444);
71MODULE_PARM_DESC(rds_buf, "RDS buffer entries"); 71MODULE_PARM_DESC(default_rds_buf, "RDS buffer entries");
72 72
73/* Radio Nr */ 73/* Radio Nr */
74static u32 radio_nr = -1; 74static u32 radio_nr = -1;
diff --git a/drivers/media/rc/ati_remote.c b/drivers/media/rc/ati_remote.c
index a35631891cc0..3f61d77d4147 100644
--- a/drivers/media/rc/ati_remote.c
+++ b/drivers/media/rc/ati_remote.c
@@ -443,6 +443,21 @@ static int ati_remote_sendpacket(struct ati_remote *ati_remote, u16 cmd,
443 return retval; 443 return retval;
444} 444}
445 445
446struct accel_times {
447 const char value;
448 unsigned int msecs;
449};
450
451static const struct accel_times accel[] = {
452 { 1, 125 },
453 { 2, 250 },
454 { 4, 500 },
455 { 6, 1000 },
456 { 9, 1500 },
457 { 13, 2000 },
458 { 20, 0 },
459};
460
446/* 461/*
447 * ati_remote_compute_accel 462 * ati_remote_compute_accel
448 * 463 *
@@ -454,30 +469,22 @@ static int ati_remote_sendpacket(struct ati_remote *ati_remote, u16 cmd,
454 */ 469 */
455static int ati_remote_compute_accel(struct ati_remote *ati_remote) 470static int ati_remote_compute_accel(struct ati_remote *ati_remote)
456{ 471{
457 static const char accel[] = { 1, 2, 4, 6, 9, 13, 20 }; 472 unsigned long now = jiffies, reset_time;
458 unsigned long now = jiffies; 473 int i;
459 int acc; 474
475 reset_time = msecs_to_jiffies(250);
460 476
461 if (time_after(now, ati_remote->old_jiffies + msecs_to_jiffies(250))) { 477 if (time_after(now, ati_remote->old_jiffies + reset_time)) {
462 acc = 1;
463 ati_remote->acc_jiffies = now; 478 ati_remote->acc_jiffies = now;
479 return 1;
464 } 480 }
465 else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(125))) 481 for (i = 0; i < ARRAY_SIZE(accel) - 1; i++) {
466 acc = accel[0]; 482 unsigned long timeout = msecs_to_jiffies(accel[i].msecs);
467 else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(250)))
468 acc = accel[1];
469 else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(500)))
470 acc = accel[2];
471 else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(1000)))
472 acc = accel[3];
473 else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(1500)))
474 acc = accel[4];
475 else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(2000)))
476 acc = accel[5];
477 else
478 acc = accel[6];
479 483
480 return acc; 484 if (time_before(now, ati_remote->acc_jiffies + timeout))
485 return accel[i].value;
486 }
487 return accel[i].value;
481} 488}
482 489
483/* 490/*
diff --git a/drivers/media/rc/igorplugusb.c b/drivers/media/rc/igorplugusb.c
index b36e51576f8e..e0c531fa01da 100644
--- a/drivers/media/rc/igorplugusb.c
+++ b/drivers/media/rc/igorplugusb.c
@@ -152,7 +152,7 @@ static int igorplugusb_probe(struct usb_interface *intf,
152 struct usb_endpoint_descriptor *ep; 152 struct usb_endpoint_descriptor *ep;
153 struct igorplugusb *ir; 153 struct igorplugusb *ir;
154 struct rc_dev *rc; 154 struct rc_dev *rc;
155 int ret; 155 int ret = -ENOMEM;
156 156
157 udev = interface_to_usbdev(intf); 157 udev = interface_to_usbdev(intf);
158 idesc = intf->cur_altsetting; 158 idesc = intf->cur_altsetting;
@@ -182,7 +182,7 @@ static int igorplugusb_probe(struct usb_interface *intf,
182 182
183 ir->urb = usb_alloc_urb(0, GFP_KERNEL); 183 ir->urb = usb_alloc_urb(0, GFP_KERNEL);
184 if (!ir->urb) 184 if (!ir->urb)
185 return -ENOMEM; 185 goto fail;
186 186
187 usb_fill_control_urb(ir->urb, udev, 187 usb_fill_control_urb(ir->urb, udev,
188 usb_rcvctrlpipe(udev, 0), (uint8_t *)&ir->request, 188 usb_rcvctrlpipe(udev, 0), (uint8_t *)&ir->request,
@@ -191,6 +191,9 @@ static int igorplugusb_probe(struct usb_interface *intf,
191 usb_make_path(udev, ir->phys, sizeof(ir->phys)); 191 usb_make_path(udev, ir->phys, sizeof(ir->phys));
192 192
193 rc = rc_allocate_device(); 193 rc = rc_allocate_device();
194 if (!rc)
195 goto fail;
196
194 rc->input_name = DRIVER_DESC; 197 rc->input_name = DRIVER_DESC;
195 rc->input_phys = ir->phys; 198 rc->input_phys = ir->phys;
196 usb_to_input_id(udev, &rc->input_id); 199 usb_to_input_id(udev, &rc->input_id);
@@ -214,9 +217,7 @@ static int igorplugusb_probe(struct usb_interface *intf,
214 ret = rc_register_device(rc); 217 ret = rc_register_device(rc);
215 if (ret) { 218 if (ret) {
216 dev_err(&intf->dev, "failed to register rc device: %d", ret); 219 dev_err(&intf->dev, "failed to register rc device: %d", ret);
217 rc_free_device(rc); 220 goto fail;
218 usb_free_urb(ir->urb);
219 return ret;
220 } 221 }
221 222
222 usb_set_intfdata(intf, ir); 223 usb_set_intfdata(intf, ir);
@@ -224,6 +225,12 @@ static int igorplugusb_probe(struct usb_interface *intf,
224 igorplugusb_cmd(ir, SET_INFRABUFFER_EMPTY); 225 igorplugusb_cmd(ir, SET_INFRABUFFER_EMPTY);
225 226
226 return 0; 227 return 0;
228fail:
229 rc_free_device(ir->rc);
230 usb_free_urb(ir->urb);
231 del_timer(&ir->timer);
232
233 return ret;
227} 234}
228 235
229static void igorplugusb_disconnect(struct usb_interface *intf) 236static void igorplugusb_disconnect(struct usb_interface *intf)
diff --git a/drivers/media/rc/keymaps/rc-avermedia-rm-ks.c b/drivers/media/rc/keymaps/rc-avermedia-rm-ks.c
index 8344bcc595be..2583400ca1b4 100644
--- a/drivers/media/rc/keymaps/rc-avermedia-rm-ks.c
+++ b/drivers/media/rc/keymaps/rc-avermedia-rm-ks.c
@@ -23,35 +23,35 @@
23 23
24/* Initial keytable is from Jose Alberto Reguero <jareguero@telefonica.net> 24/* Initial keytable is from Jose Alberto Reguero <jareguero@telefonica.net>
25 and Felipe Morales Moreno <felipe.morales.moreno@gmail.com> */ 25 and Felipe Morales Moreno <felipe.morales.moreno@gmail.com> */
26/* FIXME: mappings are not 100% correct? */ 26/* Keytable fixed by Philippe Valembois <lephilousophe@users.sourceforge.net> */
27static struct rc_map_table avermedia_rm_ks[] = { 27static struct rc_map_table avermedia_rm_ks[] = {
28 { 0x0501, KEY_POWER2 }, 28 { 0x0501, KEY_POWER2 }, /* Power (RED POWER BUTTON) */
29 { 0x0502, KEY_CHANNELUP }, 29 { 0x0502, KEY_CHANNELUP }, /* Channel+ */
30 { 0x0503, KEY_CHANNELDOWN }, 30 { 0x0503, KEY_CHANNELDOWN }, /* Channel- */
31 { 0x0504, KEY_VOLUMEUP }, 31 { 0x0504, KEY_VOLUMEUP }, /* Volume+ */
32 { 0x0505, KEY_VOLUMEDOWN }, 32 { 0x0505, KEY_VOLUMEDOWN }, /* Volume- */
33 { 0x0506, KEY_MUTE }, 33 { 0x0506, KEY_MUTE }, /* Mute */
34 { 0x0507, KEY_RIGHT }, 34 { 0x0507, KEY_AGAIN }, /* Recall */
35 { 0x0508, KEY_RED }, 35 { 0x0508, KEY_VIDEO }, /* Source */
36 { 0x0509, KEY_1 }, 36 { 0x0509, KEY_1 }, /* 1 */
37 { 0x050a, KEY_2 }, 37 { 0x050a, KEY_2 }, /* 2 */
38 { 0x050b, KEY_3 }, 38 { 0x050b, KEY_3 }, /* 3 */
39 { 0x050c, KEY_4 }, 39 { 0x050c, KEY_4 }, /* 4 */
40 { 0x050d, KEY_5 }, 40 { 0x050d, KEY_5 }, /* 5 */
41 { 0x050e, KEY_6 }, 41 { 0x050e, KEY_6 }, /* 6 */
42 { 0x050f, KEY_7 }, 42 { 0x050f, KEY_7 }, /* 7 */
43 { 0x0510, KEY_8 }, 43 { 0x0510, KEY_8 }, /* 8 */
44 { 0x0511, KEY_9 }, 44 { 0x0511, KEY_9 }, /* 9 */
45 { 0x0512, KEY_0 }, 45 { 0x0512, KEY_0 }, /* 0 */
46 { 0x0513, KEY_AUDIO }, 46 { 0x0513, KEY_AUDIO }, /* Audio */
47 { 0x0515, KEY_EPG }, 47 { 0x0515, KEY_EPG }, /* EPG */
48 { 0x0516, KEY_PLAY }, 48 { 0x0516, KEY_PLAYPAUSE }, /* Play/Pause */
49 { 0x0517, KEY_RECORD }, 49 { 0x0517, KEY_RECORD }, /* Record */
50 { 0x0518, KEY_STOP }, 50 { 0x0518, KEY_STOP }, /* Stop */
51 { 0x051c, KEY_BACK }, 51 { 0x051c, KEY_BACK }, /* << */
52 { 0x051d, KEY_FORWARD }, 52 { 0x051d, KEY_FORWARD }, /* >> */
53 { 0x054d, KEY_LEFT }, 53 { 0x054d, KEY_INFO }, /* Display information */
54 { 0x0556, KEY_ZOOM }, 54 { 0x0556, KEY_ZOOM }, /* Fullscreen */
55}; 55};
56 56
57static struct rc_map_list avermedia_rm_ks_map = { 57static struct rc_map_list avermedia_rm_ks_map = {
diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
index 4de0e85af805..92ae1903c010 100644
--- a/drivers/media/rc/lirc_dev.c
+++ b/drivers/media/rc/lirc_dev.c
@@ -506,6 +506,7 @@ int lirc_dev_fop_close(struct inode *inode, struct file *file)
506{ 506{
507 struct irctl *ir = irctls[iminor(inode)]; 507 struct irctl *ir = irctls[iminor(inode)];
508 struct cdev *cdev; 508 struct cdev *cdev;
509 int ret;
509 510
510 if (!ir) { 511 if (!ir) {
511 printk(KERN_ERR "%s: called with invalid irctl\n", __func__); 512 printk(KERN_ERR "%s: called with invalid irctl\n", __func__);
@@ -516,7 +517,8 @@ int lirc_dev_fop_close(struct inode *inode, struct file *file)
516 517
517 dev_dbg(ir->d.dev, LOGHEAD "close called\n", ir->d.name, ir->d.minor); 518 dev_dbg(ir->d.dev, LOGHEAD "close called\n", ir->d.name, ir->d.minor);
518 519
519 WARN_ON(mutex_lock_killable(&lirc_dev_lock)); 520 ret = mutex_lock_killable(&lirc_dev_lock);
521 WARN_ON(ret);
520 522
521 rc_close(ir->d.rdev); 523 rc_close(ir->d.rdev);
522 524
@@ -532,7 +534,8 @@ int lirc_dev_fop_close(struct inode *inode, struct file *file)
532 kfree(ir); 534 kfree(ir);
533 } 535 }
534 536
535 mutex_unlock(&lirc_dev_lock); 537 if (!ret)
538 mutex_unlock(&lirc_dev_lock);
536 539
537 return 0; 540 return 0;
538} 541}
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index 2cdb740cde48..35155ae500c7 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -587,9 +587,8 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf,
587 if (len == 2) 587 if (len == 2)
588 dev_dbg(dev, "Get hw/sw rev?"); 588 dev_dbg(dev, "Get hw/sw rev?");
589 else 589 else
590 dev_dbg(dev, "hw/sw rev 0x%02x 0x%02x 0x%02x 0x%02x", 590 dev_dbg(dev, "hw/sw rev %*ph",
591 data1, data2, 591 4, &buf[start + 2]);
592 buf[start + 4], buf[start + 5]);
593 break; 592 break;
594 case MCE_CMD_RESUME: 593 case MCE_CMD_RESUME:
595 dev_dbg(dev, "Device resume requested"); 594 dev_dbg(dev, "Device resume requested");
diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
index 18adf580f502..99b303b702ac 100644
--- a/drivers/media/rc/nuvoton-cir.c
+++ b/drivers/media/rc/nuvoton-cir.c
@@ -39,6 +39,8 @@
39 39
40#include "nuvoton-cir.h" 40#include "nuvoton-cir.h"
41 41
42static void nvt_clear_cir_wake_fifo(struct nvt_dev *nvt);
43
42static const struct nvt_chip nvt_chips[] = { 44static const struct nvt_chip nvt_chips[] = {
43 { "w83667hg", NVT_W83667HG }, 45 { "w83667hg", NVT_W83667HG },
44 { "NCT6775F", NVT_6775F }, 46 { "NCT6775F", NVT_6775F },
@@ -80,17 +82,24 @@ static inline void nvt_clear_reg_bit(struct nvt_dev *nvt, u8 val, u8 reg)
80} 82}
81 83
82/* enter extended function mode */ 84/* enter extended function mode */
83static inline void nvt_efm_enable(struct nvt_dev *nvt) 85static inline int nvt_efm_enable(struct nvt_dev *nvt)
84{ 86{
87 if (!request_muxed_region(nvt->cr_efir, 2, NVT_DRIVER_NAME))
88 return -EBUSY;
89
85 /* Enabling Extended Function Mode explicitly requires writing 2x */ 90 /* Enabling Extended Function Mode explicitly requires writing 2x */
86 outb(EFER_EFM_ENABLE, nvt->cr_efir); 91 outb(EFER_EFM_ENABLE, nvt->cr_efir);
87 outb(EFER_EFM_ENABLE, nvt->cr_efir); 92 outb(EFER_EFM_ENABLE, nvt->cr_efir);
93
94 return 0;
88} 95}
89 96
90/* exit extended function mode */ 97/* exit extended function mode */
91static inline void nvt_efm_disable(struct nvt_dev *nvt) 98static inline void nvt_efm_disable(struct nvt_dev *nvt)
92{ 99{
93 outb(EFER_EFM_DISABLE, nvt->cr_efir); 100 outb(EFER_EFM_DISABLE, nvt->cr_efir);
101
102 release_region(nvt->cr_efir, 2);
94} 103}
95 104
96/* 105/*
@@ -100,8 +109,25 @@ static inline void nvt_efm_disable(struct nvt_dev *nvt)
100 */ 109 */
101static inline void nvt_select_logical_dev(struct nvt_dev *nvt, u8 ldev) 110static inline void nvt_select_logical_dev(struct nvt_dev *nvt, u8 ldev)
102{ 111{
103 outb(CR_LOGICAL_DEV_SEL, nvt->cr_efir); 112 nvt_cr_write(nvt, ldev, CR_LOGICAL_DEV_SEL);
104 outb(ldev, nvt->cr_efdr); 113}
114
115/* select and enable logical device with setting EFM mode*/
116static inline void nvt_enable_logical_dev(struct nvt_dev *nvt, u8 ldev)
117{
118 nvt_efm_enable(nvt);
119 nvt_select_logical_dev(nvt, ldev);
120 nvt_cr_write(nvt, LOGICAL_DEV_ENABLE, CR_LOGICAL_DEV_EN);
121 nvt_efm_disable(nvt);
122}
123
124/* select and disable logical device with setting EFM mode*/
125static inline void nvt_disable_logical_dev(struct nvt_dev *nvt, u8 ldev)
126{
127 nvt_efm_enable(nvt);
128 nvt_select_logical_dev(nvt, ldev);
129 nvt_cr_write(nvt, LOGICAL_DEV_DISABLE, CR_LOGICAL_DEV_EN);
130 nvt_efm_disable(nvt);
105} 131}
106 132
107/* write val to cir config register */ 133/* write val to cir config register */
@@ -137,6 +163,120 @@ static u8 nvt_cir_wake_reg_read(struct nvt_dev *nvt, u8 offset)
137 return val; 163 return val;
138} 164}
139 165
166/* don't override io address if one is set already */
167static void nvt_set_ioaddr(struct nvt_dev *nvt, unsigned long *ioaddr)
168{
169 unsigned long old_addr;
170
171 old_addr = nvt_cr_read(nvt, CR_CIR_BASE_ADDR_HI) << 8;
172 old_addr |= nvt_cr_read(nvt, CR_CIR_BASE_ADDR_LO);
173
174 if (old_addr)
175 *ioaddr = old_addr;
176 else {
177 nvt_cr_write(nvt, *ioaddr >> 8, CR_CIR_BASE_ADDR_HI);
178 nvt_cr_write(nvt, *ioaddr & 0xff, CR_CIR_BASE_ADDR_LO);
179 }
180}
181
182static ssize_t wakeup_data_show(struct device *dev,
183 struct device_attribute *attr,
184 char *buf)
185{
186 struct rc_dev *rc_dev = to_rc_dev(dev);
187 struct nvt_dev *nvt = rc_dev->priv;
188 int fifo_len, duration;
189 unsigned long flags;
190 ssize_t buf_len = 0;
191 int i;
192
193 spin_lock_irqsave(&nvt->nvt_lock, flags);
194
195 fifo_len = nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFO_COUNT);
196 fifo_len = min(fifo_len, WAKEUP_MAX_SIZE);
197
198 /* go to first element to be read */
199 while (nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY_IDX))
200 nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY);
201
202 for (i = 0; i < fifo_len; i++) {
203 duration = nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY);
204 duration = (duration & BUF_LEN_MASK) * SAMPLE_PERIOD;
205 buf_len += snprintf(buf + buf_len, PAGE_SIZE - buf_len,
206 "%d ", duration);
207 }
208 buf_len += snprintf(buf + buf_len, PAGE_SIZE - buf_len, "\n");
209
210 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
211
212 return buf_len;
213}
214
215static ssize_t wakeup_data_store(struct device *dev,
216 struct device_attribute *attr,
217 const char *buf, size_t len)
218{
219 struct rc_dev *rc_dev = to_rc_dev(dev);
220 struct nvt_dev *nvt = rc_dev->priv;
221 unsigned long flags;
222 u8 tolerance, config, wake_buf[WAKEUP_MAX_SIZE];
223 char **argv;
224 int i, count;
225 unsigned int val;
226 ssize_t ret;
227
228 argv = argv_split(GFP_KERNEL, buf, &count);
229 if (!argv)
230 return -ENOMEM;
231 if (!count || count > WAKEUP_MAX_SIZE) {
232 ret = -EINVAL;
233 goto out;
234 }
235
236 for (i = 0; i < count; i++) {
237 ret = kstrtouint(argv[i], 10, &val);
238 if (ret)
239 goto out;
240 val = DIV_ROUND_CLOSEST(val, SAMPLE_PERIOD);
241 if (!val || val > 0x7f) {
242 ret = -EINVAL;
243 goto out;
244 }
245 wake_buf[i] = val;
246 /* sequence must start with a pulse */
247 if (i % 2 == 0)
248 wake_buf[i] |= BUF_PULSE_BIT;
249 }
250
251 /* hardcode the tolerance to 10% */
252 tolerance = DIV_ROUND_UP(count, 10);
253
254 spin_lock_irqsave(&nvt->nvt_lock, flags);
255
256 nvt_clear_cir_wake_fifo(nvt);
257 nvt_cir_wake_reg_write(nvt, count, CIR_WAKE_FIFO_CMP_DEEP);
258 nvt_cir_wake_reg_write(nvt, tolerance, CIR_WAKE_FIFO_CMP_TOL);
259
260 config = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRCON);
261
262 /* enable writes to wake fifo */
263 nvt_cir_wake_reg_write(nvt, config | CIR_WAKE_IRCON_MODE1,
264 CIR_WAKE_IRCON);
265
266 for (i = 0; i < count; i++)
267 nvt_cir_wake_reg_write(nvt, wake_buf[i], CIR_WAKE_WR_FIFO_DATA);
268
269 nvt_cir_wake_reg_write(nvt, config, CIR_WAKE_IRCON);
270
271 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
272
273 ret = len;
274out:
275 argv_free(argv);
276 return ret;
277}
278static DEVICE_ATTR_RW(wakeup_data);
279
140/* dump current cir register contents */ 280/* dump current cir register contents */
141static void cir_dump_regs(struct nvt_dev *nvt) 281static void cir_dump_regs(struct nvt_dev *nvt)
142{ 282{
@@ -251,7 +391,7 @@ static inline const char *nvt_find_chip(struct nvt_dev *nvt, int id)
251 391
252 392
253/* detect hardware features */ 393/* detect hardware features */
254static void nvt_hw_detect(struct nvt_dev *nvt) 394static int nvt_hw_detect(struct nvt_dev *nvt)
255{ 395{
256 const char *chip_name; 396 const char *chip_name;
257 int chip_id; 397 int chip_id;
@@ -266,10 +406,17 @@ static void nvt_hw_detect(struct nvt_dev *nvt)
266 nvt_efm_enable(nvt); 406 nvt_efm_enable(nvt);
267 nvt->chip_major = nvt_cr_read(nvt, CR_CHIP_ID_HI); 407 nvt->chip_major = nvt_cr_read(nvt, CR_CHIP_ID_HI);
268 } 408 }
269
270 nvt->chip_minor = nvt_cr_read(nvt, CR_CHIP_ID_LO); 409 nvt->chip_minor = nvt_cr_read(nvt, CR_CHIP_ID_LO);
271 410
411 nvt_efm_disable(nvt);
412
272 chip_id = nvt->chip_major << 8 | nvt->chip_minor; 413 chip_id = nvt->chip_major << 8 | nvt->chip_minor;
414 if (chip_id == NVT_INVALID) {
415 dev_err(&nvt->pdev->dev,
416 "No device found on either EFM port\n");
417 return -ENODEV;
418 }
419
273 chip_name = nvt_find_chip(nvt, chip_id); 420 chip_name = nvt_find_chip(nvt, chip_id);
274 421
275 /* warn, but still let the driver load, if we don't know this chip */ 422 /* warn, but still let the driver load, if we don't know this chip */
@@ -282,7 +429,7 @@ static void nvt_hw_detect(struct nvt_dev *nvt)
282 "found %s or compatible: chip id: 0x%02x 0x%02x", 429 "found %s or compatible: chip id: 0x%02x 0x%02x",
283 chip_name, nvt->chip_major, nvt->chip_minor); 430 chip_name, nvt->chip_major, nvt->chip_minor);
284 431
285 nvt_efm_disable(nvt); 432 return 0;
286} 433}
287 434
288static void nvt_cir_ldev_init(struct nvt_dev *nvt) 435static void nvt_cir_ldev_init(struct nvt_dev *nvt)
@@ -305,12 +452,10 @@ static void nvt_cir_ldev_init(struct nvt_dev *nvt)
305 val |= psval; 452 val |= psval;
306 nvt_cr_write(nvt, val, psreg); 453 nvt_cr_write(nvt, val, psreg);
307 454
308 /* Select CIR logical device and enable */ 455 /* Select CIR logical device */
309 nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR); 456 nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR);
310 nvt_cr_write(nvt, LOGICAL_DEV_ENABLE, CR_LOGICAL_DEV_EN);
311 457
312 nvt_cr_write(nvt, nvt->cir_addr >> 8, CR_CIR_BASE_ADDR_HI); 458 nvt_set_ioaddr(nvt, &nvt->cir_addr);
313 nvt_cr_write(nvt, nvt->cir_addr & 0xff, CR_CIR_BASE_ADDR_LO);
314 459
315 nvt_cr_write(nvt, nvt->cir_irq, CR_CIR_IRQ_RSRC); 460 nvt_cr_write(nvt, nvt->cir_irq, CR_CIR_IRQ_RSRC);
316 461
@@ -320,7 +465,7 @@ static void nvt_cir_ldev_init(struct nvt_dev *nvt)
320 465
321static void nvt_cir_wake_ldev_init(struct nvt_dev *nvt) 466static void nvt_cir_wake_ldev_init(struct nvt_dev *nvt)
322{ 467{
323 /* Select ACPI logical device, enable it and CIR Wake */ 468 /* Select ACPI logical device and anable it */
324 nvt_select_logical_dev(nvt, LOGICAL_DEV_ACPI); 469 nvt_select_logical_dev(nvt, LOGICAL_DEV_ACPI);
325 nvt_cr_write(nvt, LOGICAL_DEV_ENABLE, CR_LOGICAL_DEV_EN); 470 nvt_cr_write(nvt, LOGICAL_DEV_ENABLE, CR_LOGICAL_DEV_EN);
326 471
@@ -330,12 +475,10 @@ static void nvt_cir_wake_ldev_init(struct nvt_dev *nvt)
330 /* enable pme interrupt of cir wakeup event */ 475 /* enable pme interrupt of cir wakeup event */
331 nvt_set_reg_bit(nvt, PME_INTR_CIR_PASS_BIT, CR_ACPI_IRQ_EVENTS2); 476 nvt_set_reg_bit(nvt, PME_INTR_CIR_PASS_BIT, CR_ACPI_IRQ_EVENTS2);
332 477
333 /* Select CIR Wake logical device and enable */ 478 /* Select CIR Wake logical device */
334 nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR_WAKE); 479 nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR_WAKE);
335 nvt_cr_write(nvt, LOGICAL_DEV_ENABLE, CR_LOGICAL_DEV_EN);
336 480
337 nvt_cr_write(nvt, nvt->cir_wake_addr >> 8, CR_CIR_BASE_ADDR_HI); 481 nvt_set_ioaddr(nvt, &nvt->cir_wake_addr);
338 nvt_cr_write(nvt, nvt->cir_wake_addr & 0xff, CR_CIR_BASE_ADDR_LO);
339 482
340 nvt_cr_write(nvt, nvt->cir_wake_irq, CR_CIR_IRQ_RSRC); 483 nvt_cr_write(nvt, nvt->cir_wake_irq, CR_CIR_IRQ_RSRC);
341 484
@@ -355,11 +498,19 @@ static void nvt_clear_cir_fifo(struct nvt_dev *nvt)
355/* clear out the hardware's cir wake rx fifo */ 498/* clear out the hardware's cir wake rx fifo */
356static void nvt_clear_cir_wake_fifo(struct nvt_dev *nvt) 499static void nvt_clear_cir_wake_fifo(struct nvt_dev *nvt)
357{ 500{
358 u8 val; 501 u8 val, config;
502
503 config = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRCON);
504
505 /* clearing wake fifo works in learning mode only */
506 nvt_cir_wake_reg_write(nvt, config & ~CIR_WAKE_IRCON_MODE0,
507 CIR_WAKE_IRCON);
359 508
360 val = nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFOCON); 509 val = nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFOCON);
361 nvt_cir_wake_reg_write(nvt, val | CIR_WAKE_FIFOCON_RXFIFOCLR, 510 nvt_cir_wake_reg_write(nvt, val | CIR_WAKE_FIFOCON_RXFIFOCLR,
362 CIR_WAKE_FIFOCON); 511 CIR_WAKE_FIFOCON);
512
513 nvt_cir_wake_reg_write(nvt, config, CIR_WAKE_IRCON);
363} 514}
364 515
365/* clear out the hardware's cir tx fifo */ 516/* clear out the hardware's cir tx fifo */
@@ -408,6 +559,9 @@ static void nvt_cir_regs_init(struct nvt_dev *nvt)
408 559
409 /* and finally, enable interrupts */ 560 /* and finally, enable interrupts */
410 nvt_set_cir_iren(nvt); 561 nvt_set_cir_iren(nvt);
562
563 /* enable the CIR logical device */
564 nvt_enable_logical_dev(nvt, LOGICAL_DEV_CIR);
411} 565}
412 566
413static void nvt_cir_wake_regs_init(struct nvt_dev *nvt) 567static void nvt_cir_wake_regs_init(struct nvt_dev *nvt)
@@ -442,10 +596,15 @@ static void nvt_cir_wake_regs_init(struct nvt_dev *nvt)
442 596
443 /* clear any and all stray interrupts */ 597 /* clear any and all stray interrupts */
444 nvt_cir_wake_reg_write(nvt, 0xff, CIR_WAKE_IRSTS); 598 nvt_cir_wake_reg_write(nvt, 0xff, CIR_WAKE_IRSTS);
599
600 /* enable the CIR WAKE logical device */
601 nvt_enable_logical_dev(nvt, LOGICAL_DEV_CIR_WAKE);
445} 602}
446 603
447static void nvt_enable_wake(struct nvt_dev *nvt) 604static void nvt_enable_wake(struct nvt_dev *nvt)
448{ 605{
606 unsigned long flags;
607
449 nvt_efm_enable(nvt); 608 nvt_efm_enable(nvt);
450 609
451 nvt_select_logical_dev(nvt, LOGICAL_DEV_ACPI); 610 nvt_select_logical_dev(nvt, LOGICAL_DEV_ACPI);
@@ -457,12 +616,16 @@ static void nvt_enable_wake(struct nvt_dev *nvt)
457 616
458 nvt_efm_disable(nvt); 617 nvt_efm_disable(nvt);
459 618
619 spin_lock_irqsave(&nvt->nvt_lock, flags);
620
460 nvt_cir_wake_reg_write(nvt, CIR_WAKE_IRCON_MODE0 | CIR_WAKE_IRCON_RXEN | 621 nvt_cir_wake_reg_write(nvt, CIR_WAKE_IRCON_MODE0 | CIR_WAKE_IRCON_RXEN |
461 CIR_WAKE_IRCON_R | CIR_WAKE_IRCON_RXINV | 622 CIR_WAKE_IRCON_R | CIR_WAKE_IRCON_RXINV |
462 CIR_WAKE_IRCON_SAMPLE_PERIOD_SEL, 623 CIR_WAKE_IRCON_SAMPLE_PERIOD_SEL,
463 CIR_WAKE_IRCON); 624 CIR_WAKE_IRCON);
464 nvt_cir_wake_reg_write(nvt, 0xff, CIR_WAKE_IRSTS); 625 nvt_cir_wake_reg_write(nvt, 0xff, CIR_WAKE_IRSTS);
465 nvt_cir_wake_reg_write(nvt, 0, CIR_WAKE_IREN); 626 nvt_cir_wake_reg_write(nvt, 0, CIR_WAKE_IREN);
627
628 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
466} 629}
467 630
468#if 0 /* Currently unused */ 631#if 0 /* Currently unused */
@@ -670,7 +833,6 @@ static void nvt_handle_rx_fifo_overrun(struct nvt_dev *nvt)
670/* copy data from hardware rx fifo into driver buffer */ 833/* copy data from hardware rx fifo into driver buffer */
671static void nvt_get_rx_ir_data(struct nvt_dev *nvt) 834static void nvt_get_rx_ir_data(struct nvt_dev *nvt)
672{ 835{
673 unsigned long flags;
674 u8 fifocount, val; 836 u8 fifocount, val;
675 unsigned int b_idx; 837 unsigned int b_idx;
676 bool overrun = false; 838 bool overrun = false;
@@ -689,8 +851,6 @@ static void nvt_get_rx_ir_data(struct nvt_dev *nvt)
689 851
690 nvt_dbg("attempting to fetch %u bytes from hw rx fifo", fifocount); 852 nvt_dbg("attempting to fetch %u bytes from hw rx fifo", fifocount);
691 853
692 spin_lock_irqsave(&nvt->nvt_lock, flags);
693
694 b_idx = nvt->pkts; 854 b_idx = nvt->pkts;
695 855
696 /* This should never happen, but lets check anyway... */ 856 /* This should never happen, but lets check anyway... */
@@ -712,8 +872,6 @@ static void nvt_get_rx_ir_data(struct nvt_dev *nvt)
712 872
713 if (overrun) 873 if (overrun)
714 nvt_handle_rx_fifo_overrun(nvt); 874 nvt_handle_rx_fifo_overrun(nvt);
715
716 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
717} 875}
718 876
719static void nvt_cir_log_irqs(u8 status, u8 iren) 877static void nvt_cir_log_irqs(u8 status, u8 iren)
@@ -736,16 +894,13 @@ static void nvt_cir_log_irqs(u8 status, u8 iren)
736static bool nvt_cir_tx_inactive(struct nvt_dev *nvt) 894static bool nvt_cir_tx_inactive(struct nvt_dev *nvt)
737{ 895{
738 unsigned long flags; 896 unsigned long flags;
739 bool tx_inactive;
740 u8 tx_state; 897 u8 tx_state;
741 898
742 spin_lock_irqsave(&nvt->tx.lock, flags); 899 spin_lock_irqsave(&nvt->tx.lock, flags);
743 tx_state = nvt->tx.tx_state; 900 tx_state = nvt->tx.tx_state;
744 spin_unlock_irqrestore(&nvt->tx.lock, flags); 901 spin_unlock_irqrestore(&nvt->tx.lock, flags);
745 902
746 tx_inactive = (tx_state == ST_TX_NONE); 903 return tx_state == ST_TX_NONE;
747
748 return tx_inactive;
749} 904}
750 905
751/* interrupt service routine for incoming and outgoing CIR data */ 906/* interrupt service routine for incoming and outgoing CIR data */
@@ -757,9 +912,7 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
757 912
758 nvt_dbg_verbose("%s firing", __func__); 913 nvt_dbg_verbose("%s firing", __func__);
759 914
760 nvt_efm_enable(nvt); 915 spin_lock_irqsave(&nvt->nvt_lock, flags);
761 nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR);
762 nvt_efm_disable(nvt);
763 916
764 /* 917 /*
765 * Get IR Status register contents. Write 1 to ack/clear 918 * Get IR Status register contents. Write 1 to ack/clear
@@ -775,9 +928,14 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
775 * 0: CIR_IRSTS_GH - Min Length Detected 928 * 0: CIR_IRSTS_GH - Min Length Detected
776 */ 929 */
777 status = nvt_cir_reg_read(nvt, CIR_IRSTS); 930 status = nvt_cir_reg_read(nvt, CIR_IRSTS);
778 if (!status) { 931 iren = nvt_cir_reg_read(nvt, CIR_IREN);
932
933 /* IRQ may be shared with CIR WAKE, therefore check for each
934 * status bit whether the related interrupt source is enabled
935 */
936 if (!(status & iren)) {
937 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
779 nvt_dbg_verbose("%s exiting, IRSTS 0x0", __func__); 938 nvt_dbg_verbose("%s exiting, IRSTS 0x0", __func__);
780 nvt_cir_reg_write(nvt, 0xff, CIR_IRSTS);
781 return IRQ_NONE; 939 return IRQ_NONE;
782 } 940 }
783 941
@@ -785,13 +943,6 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
785 nvt_cir_reg_write(nvt, status, CIR_IRSTS); 943 nvt_cir_reg_write(nvt, status, CIR_IRSTS);
786 nvt_cir_reg_write(nvt, 0, CIR_IRSTS); 944 nvt_cir_reg_write(nvt, 0, CIR_IRSTS);
787 945
788 /* Interrupt may be shared with CIR Wake, bail if CIR not enabled */
789 iren = nvt_cir_reg_read(nvt, CIR_IREN);
790 if (!iren) {
791 nvt_dbg_verbose("%s exiting, CIR not enabled", __func__);
792 return IRQ_NONE;
793 }
794
795 nvt_cir_log_irqs(status, iren); 946 nvt_cir_log_irqs(status, iren);
796 947
797 if (status & CIR_IRSTS_RTR) { 948 if (status & CIR_IRSTS_RTR) {
@@ -805,16 +956,14 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
805 if (nvt_cir_tx_inactive(nvt)) 956 if (nvt_cir_tx_inactive(nvt))
806 nvt_get_rx_ir_data(nvt); 957 nvt_get_rx_ir_data(nvt);
807 958
808 spin_lock_irqsave(&nvt->nvt_lock, flags);
809
810 cur_state = nvt->study_state; 959 cur_state = nvt->study_state;
811 960
812 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
813
814 if (cur_state == ST_STUDY_NONE) 961 if (cur_state == ST_STUDY_NONE)
815 nvt_clear_cir_fifo(nvt); 962 nvt_clear_cir_fifo(nvt);
816 } 963 }
817 964
965 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
966
818 if (status & CIR_IRSTS_TE) 967 if (status & CIR_IRSTS_TE)
819 nvt_clear_tx_fifo(nvt); 968 nvt_clear_tx_fifo(nvt);
820 969
@@ -863,9 +1012,18 @@ static irqreturn_t nvt_cir_wake_isr(int irq, void *data)
863 1012
864 nvt_dbg_wake("%s firing", __func__); 1013 nvt_dbg_wake("%s firing", __func__);
865 1014
1015 spin_lock_irqsave(&nvt->nvt_lock, flags);
1016
866 status = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRSTS); 1017 status = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRSTS);
867 if (!status) 1018 iren = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IREN);
1019
1020 /* IRQ may be shared with CIR, therefore check for each
1021 * status bit whether the related interrupt source is enabled
1022 */
1023 if (!(status & iren)) {
1024 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
868 return IRQ_NONE; 1025 return IRQ_NONE;
1026 }
869 1027
870 if (status & CIR_WAKE_IRSTS_IR_PENDING) 1028 if (status & CIR_WAKE_IRSTS_IR_PENDING)
871 nvt_clear_cir_wake_fifo(nvt); 1029 nvt_clear_cir_wake_fifo(nvt);
@@ -873,13 +1031,6 @@ static irqreturn_t nvt_cir_wake_isr(int irq, void *data)
873 nvt_cir_wake_reg_write(nvt, status, CIR_WAKE_IRSTS); 1031 nvt_cir_wake_reg_write(nvt, status, CIR_WAKE_IRSTS);
874 nvt_cir_wake_reg_write(nvt, 0, CIR_WAKE_IRSTS); 1032 nvt_cir_wake_reg_write(nvt, 0, CIR_WAKE_IRSTS);
875 1033
876 /* Interrupt may be shared with CIR, bail if Wake not enabled */
877 iren = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IREN);
878 if (!iren) {
879 nvt_dbg_wake("%s exiting, wake not enabled", __func__);
880 return IRQ_HANDLED;
881 }
882
883 if ((status & CIR_WAKE_IRSTS_PE) && 1034 if ((status & CIR_WAKE_IRSTS_PE) &&
884 (nvt->wake_state == ST_WAKE_START)) { 1035 (nvt->wake_state == ST_WAKE_START)) {
885 while (nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY_IDX)) { 1036 while (nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY_IDX)) {
@@ -888,39 +1039,21 @@ static irqreturn_t nvt_cir_wake_isr(int irq, void *data)
888 } 1039 }
889 1040
890 nvt_cir_wake_reg_write(nvt, 0, CIR_WAKE_IREN); 1041 nvt_cir_wake_reg_write(nvt, 0, CIR_WAKE_IREN);
891 spin_lock_irqsave(&nvt->nvt_lock, flags);
892 nvt->wake_state = ST_WAKE_FINISH; 1042 nvt->wake_state = ST_WAKE_FINISH;
893 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
894 } 1043 }
895 1044
1045 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
1046
896 nvt_dbg_wake("%s done", __func__); 1047 nvt_dbg_wake("%s done", __func__);
897 return IRQ_HANDLED; 1048 return IRQ_HANDLED;
898} 1049}
899 1050
900static void nvt_enable_cir(struct nvt_dev *nvt) 1051static void nvt_disable_cir(struct nvt_dev *nvt)
901{ 1052{
902 /* set function enable flags */ 1053 unsigned long flags;
903 nvt_cir_reg_write(nvt, CIR_IRCON_TXEN | CIR_IRCON_RXEN |
904 CIR_IRCON_RXINV | CIR_IRCON_SAMPLE_PERIOD_SEL,
905 CIR_IRCON);
906
907 nvt_efm_enable(nvt);
908
909 /* enable the CIR logical device */
910 nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR);
911 nvt_cr_write(nvt, LOGICAL_DEV_ENABLE, CR_LOGICAL_DEV_EN);
912
913 nvt_efm_disable(nvt);
914
915 /* clear all pending interrupts */
916 nvt_cir_reg_write(nvt, 0xff, CIR_IRSTS);
917 1054
918 /* enable interrupts */ 1055 spin_lock_irqsave(&nvt->nvt_lock, flags);
919 nvt_set_cir_iren(nvt);
920}
921 1056
922static void nvt_disable_cir(struct nvt_dev *nvt)
923{
924 /* disable CIR interrupts */ 1057 /* disable CIR interrupts */
925 nvt_cir_reg_write(nvt, 0, CIR_IREN); 1058 nvt_cir_reg_write(nvt, 0, CIR_IREN);
926 1059
@@ -934,13 +1067,10 @@ static void nvt_disable_cir(struct nvt_dev *nvt)
934 nvt_clear_cir_fifo(nvt); 1067 nvt_clear_cir_fifo(nvt);
935 nvt_clear_tx_fifo(nvt); 1068 nvt_clear_tx_fifo(nvt);
936 1069
937 nvt_efm_enable(nvt); 1070 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
938 1071
939 /* disable the CIR logical device */ 1072 /* disable the CIR logical device */
940 nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR); 1073 nvt_disable_logical_dev(nvt, LOGICAL_DEV_CIR);
941 nvt_cr_write(nvt, LOGICAL_DEV_DISABLE, CR_LOGICAL_DEV_EN);
942
943 nvt_efm_disable(nvt);
944} 1074}
945 1075
946static int nvt_open(struct rc_dev *dev) 1076static int nvt_open(struct rc_dev *dev)
@@ -949,20 +1079,31 @@ static int nvt_open(struct rc_dev *dev)
949 unsigned long flags; 1079 unsigned long flags;
950 1080
951 spin_lock_irqsave(&nvt->nvt_lock, flags); 1081 spin_lock_irqsave(&nvt->nvt_lock, flags);
952 nvt_enable_cir(nvt); 1082
1083 /* set function enable flags */
1084 nvt_cir_reg_write(nvt, CIR_IRCON_TXEN | CIR_IRCON_RXEN |
1085 CIR_IRCON_RXINV | CIR_IRCON_SAMPLE_PERIOD_SEL,
1086 CIR_IRCON);
1087
1088 /* clear all pending interrupts */
1089 nvt_cir_reg_write(nvt, 0xff, CIR_IRSTS);
1090
1091 /* enable interrupts */
1092 nvt_set_cir_iren(nvt);
1093
953 spin_unlock_irqrestore(&nvt->nvt_lock, flags); 1094 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
954 1095
1096 /* enable the CIR logical device */
1097 nvt_enable_logical_dev(nvt, LOGICAL_DEV_CIR);
1098
955 return 0; 1099 return 0;
956} 1100}
957 1101
958static void nvt_close(struct rc_dev *dev) 1102static void nvt_close(struct rc_dev *dev)
959{ 1103{
960 struct nvt_dev *nvt = dev->priv; 1104 struct nvt_dev *nvt = dev->priv;
961 unsigned long flags;
962 1105
963 spin_lock_irqsave(&nvt->nvt_lock, flags);
964 nvt_disable_cir(nvt); 1106 nvt_disable_cir(nvt);
965 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
966} 1107}
967 1108
968/* Allocate memory, probe hardware, and initialize everything */ 1109/* Allocate memory, probe hardware, and initialize everything */
@@ -1024,7 +1165,9 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1024 1165
1025 init_waitqueue_head(&nvt->tx.queue); 1166 init_waitqueue_head(&nvt->tx.queue);
1026 1167
1027 nvt_hw_detect(nvt); 1168 ret = nvt_hw_detect(nvt);
1169 if (ret)
1170 goto exit_free_dev_rdev;
1028 1171
1029 /* Initialize CIR & CIR Wake Logical Devices */ 1172 /* Initialize CIR & CIR Wake Logical Devices */
1030 nvt_efm_enable(nvt); 1173 nvt_efm_enable(nvt);
@@ -1032,7 +1175,10 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1032 nvt_cir_wake_ldev_init(nvt); 1175 nvt_cir_wake_ldev_init(nvt);
1033 nvt_efm_disable(nvt); 1176 nvt_efm_disable(nvt);
1034 1177
1035 /* Initialize CIR & CIR Wake Config Registers */ 1178 /*
1179 * Initialize CIR & CIR Wake Config Registers
1180 * and enable logical devices
1181 */
1036 nvt_cir_regs_init(nvt); 1182 nvt_cir_regs_init(nvt);
1037 nvt_cir_wake_regs_init(nvt); 1183 nvt_cir_wake_regs_init(nvt);
1038 1184
@@ -1079,12 +1225,16 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1079 goto exit_unregister_device; 1225 goto exit_unregister_device;
1080 1226
1081 if (!devm_request_region(&pdev->dev, nvt->cir_wake_addr, 1227 if (!devm_request_region(&pdev->dev, nvt->cir_wake_addr,
1082 CIR_IOREG_LENGTH, NVT_DRIVER_NAME)) 1228 CIR_IOREG_LENGTH, NVT_DRIVER_NAME "-wake"))
1083 goto exit_unregister_device; 1229 goto exit_unregister_device;
1084 1230
1085 if (devm_request_irq(&pdev->dev, nvt->cir_wake_irq, 1231 if (devm_request_irq(&pdev->dev, nvt->cir_wake_irq,
1086 nvt_cir_wake_isr, IRQF_SHARED, 1232 nvt_cir_wake_isr, IRQF_SHARED,
1087 NVT_DRIVER_NAME, (void *)nvt)) 1233 NVT_DRIVER_NAME "-wake", (void *)nvt))
1234 goto exit_unregister_device;
1235
1236 ret = device_create_file(&rdev->dev, &dev_attr_wakeup_data);
1237 if (ret)
1088 goto exit_unregister_device; 1238 goto exit_unregister_device;
1089 1239
1090 device_init_wakeup(&pdev->dev, true); 1240 device_init_wakeup(&pdev->dev, true);
@@ -1109,15 +1259,13 @@ exit_free_dev_rdev:
1109static void nvt_remove(struct pnp_dev *pdev) 1259static void nvt_remove(struct pnp_dev *pdev)
1110{ 1260{
1111 struct nvt_dev *nvt = pnp_get_drvdata(pdev); 1261 struct nvt_dev *nvt = pnp_get_drvdata(pdev);
1112 unsigned long flags;
1113 1262
1114 spin_lock_irqsave(&nvt->nvt_lock, flags); 1263 device_remove_file(&nvt->rdev->dev, &dev_attr_wakeup_data);
1115 /* disable CIR */ 1264
1116 nvt_cir_reg_write(nvt, 0, CIR_IREN);
1117 nvt_disable_cir(nvt); 1265 nvt_disable_cir(nvt);
1266
1118 /* enable CIR Wake (for IR power-on) */ 1267 /* enable CIR Wake (for IR power-on) */
1119 nvt_enable_wake(nvt); 1268 nvt_enable_wake(nvt);
1120 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
1121 1269
1122 rc_unregister_device(nvt->rdev); 1270 rc_unregister_device(nvt->rdev);
1123} 1271}
@@ -1129,26 +1277,23 @@ static int nvt_suspend(struct pnp_dev *pdev, pm_message_t state)
1129 1277
1130 nvt_dbg("%s called", __func__); 1278 nvt_dbg("%s called", __func__);
1131 1279
1132 /* zero out misc state tracking */
1133 spin_lock_irqsave(&nvt->nvt_lock, flags);
1134 nvt->study_state = ST_STUDY_NONE;
1135 nvt->wake_state = ST_WAKE_NONE;
1136 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
1137
1138 spin_lock_irqsave(&nvt->tx.lock, flags); 1280 spin_lock_irqsave(&nvt->tx.lock, flags);
1139 nvt->tx.tx_state = ST_TX_NONE; 1281 nvt->tx.tx_state = ST_TX_NONE;
1140 spin_unlock_irqrestore(&nvt->tx.lock, flags); 1282 spin_unlock_irqrestore(&nvt->tx.lock, flags);
1141 1283
1284 spin_lock_irqsave(&nvt->nvt_lock, flags);
1285
1286 /* zero out misc state tracking */
1287 nvt->study_state = ST_STUDY_NONE;
1288 nvt->wake_state = ST_WAKE_NONE;
1289
1142 /* disable all CIR interrupts */ 1290 /* disable all CIR interrupts */
1143 nvt_cir_reg_write(nvt, 0, CIR_IREN); 1291 nvt_cir_reg_write(nvt, 0, CIR_IREN);
1144 1292
1145 nvt_efm_enable(nvt); 1293 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
1146 1294
1147 /* disable cir logical dev */ 1295 /* disable cir logical dev */
1148 nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR); 1296 nvt_disable_logical_dev(nvt, LOGICAL_DEV_CIR);
1149 nvt_cr_write(nvt, LOGICAL_DEV_DISABLE, CR_LOGICAL_DEV_EN);
1150
1151 nvt_efm_disable(nvt);
1152 1297
1153 /* make sure wake is enabled */ 1298 /* make sure wake is enabled */
1154 nvt_enable_wake(nvt); 1299 nvt_enable_wake(nvt);
@@ -1162,16 +1307,6 @@ static int nvt_resume(struct pnp_dev *pdev)
1162 1307
1163 nvt_dbg("%s called", __func__); 1308 nvt_dbg("%s called", __func__);
1164 1309
1165 /* open interrupt */
1166 nvt_set_cir_iren(nvt);
1167
1168 /* Enable CIR logical device */
1169 nvt_efm_enable(nvt);
1170 nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR);
1171 nvt_cr_write(nvt, LOGICAL_DEV_ENABLE, CR_LOGICAL_DEV_EN);
1172
1173 nvt_efm_disable(nvt);
1174
1175 nvt_cir_regs_init(nvt); 1310 nvt_cir_regs_init(nvt);
1176 nvt_cir_wake_regs_init(nvt); 1311 nvt_cir_wake_regs_init(nvt);
1177 1312
@@ -1181,6 +1316,7 @@ static int nvt_resume(struct pnp_dev *pdev)
1181static void nvt_shutdown(struct pnp_dev *pdev) 1316static void nvt_shutdown(struct pnp_dev *pdev)
1182{ 1317{
1183 struct nvt_dev *nvt = pnp_get_drvdata(pdev); 1318 struct nvt_dev *nvt = pnp_get_drvdata(pdev);
1319
1184 nvt_enable_wake(nvt); 1320 nvt_enable_wake(nvt);
1185} 1321}
1186 1322
diff --git a/drivers/media/rc/nuvoton-cir.h b/drivers/media/rc/nuvoton-cir.h
index 0ad15d34e9c9..c9c98ebb19ee 100644
--- a/drivers/media/rc/nuvoton-cir.h
+++ b/drivers/media/rc/nuvoton-cir.h
@@ -68,7 +68,8 @@ enum nvt_chip_ver {
68 NVT_W83667HG = 0xa510, 68 NVT_W83667HG = 0xa510,
69 NVT_6775F = 0xb470, 69 NVT_6775F = 0xb470,
70 NVT_6776F = 0xc330, 70 NVT_6776F = 0xc330,
71 NVT_6779D = 0xc560 71 NVT_6779D = 0xc560,
72 NVT_INVALID = 0xffff,
72}; 73};
73 74
74struct nvt_chip { 75struct nvt_chip {
@@ -157,8 +158,8 @@ struct nvt_dev {
157/* total length of CIR and CIR WAKE */ 158/* total length of CIR and CIR WAKE */
158#define CIR_IOREG_LENGTH 0x0f 159#define CIR_IOREG_LENGTH 0x0f
159 160
160/* RX limit length, 8 high bits for SLCH, 8 low bits for SLCL (0x7d0 = 2000) */ 161/* RX limit length, 8 high bits for SLCH, 8 low bits for SLCL */
161#define CIR_RX_LIMIT_COUNT 0x7d0 162#define CIR_RX_LIMIT_COUNT (IR_DEFAULT_TIMEOUT / US_TO_NS(SAMPLE_PERIOD))
162 163
163/* CIR Regs */ 164/* CIR Regs */
164#define CIR_IRCON 0x00 165#define CIR_IRCON 0x00
@@ -292,10 +293,7 @@ struct nvt_dev {
292#define CIR_WAKE_IREN_RTR 0x40 293#define CIR_WAKE_IREN_RTR 0x40
293#define CIR_WAKE_IREN_PE 0x20 294#define CIR_WAKE_IREN_PE 0x20
294#define CIR_WAKE_IREN_RFO 0x10 295#define CIR_WAKE_IREN_RFO 0x10
295#define CIR_WAKE_IREN_TE 0x08 296#define CIR_WAKE_IREN_GH 0x08
296#define CIR_WAKE_IREN_TTR 0x04
297#define CIR_WAKE_IREN_TFU 0x02
298#define CIR_WAKE_IREN_GH 0x01
299 297
300/* CIR WAKE FIFOCON settings */ 298/* CIR WAKE FIFOCON settings */
301#define CIR_WAKE_FIFOCON_RXFIFOCLR 0x08 299#define CIR_WAKE_FIFOCON_RXFIFOCLR 0x08
@@ -419,3 +417,6 @@ struct nvt_dev {
419/* as VISTA MCE definition, valid carrier value */ 417/* as VISTA MCE definition, valid carrier value */
420#define MAX_CARRIER 60000 418#define MAX_CARRIER 60000
421#define MIN_CARRIER 30000 419#define MIN_CARRIER 30000
420
421/* max wakeup sequence length */
422#define WAKEUP_MAX_SIZE 65
diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h
index 7359f3d03b64..585d5e52118d 100644
--- a/drivers/media/rc/rc-core-priv.h
+++ b/drivers/media/rc/rc-core-priv.h
@@ -16,6 +16,9 @@
16#ifndef _RC_CORE_PRIV 16#ifndef _RC_CORE_PRIV
17#define _RC_CORE_PRIV 17#define _RC_CORE_PRIV
18 18
19/* Define the max number of pulse/space transitions to buffer */
20#define MAX_IR_EVENT_SIZE 512
21
19#include <linux/slab.h> 22#include <linux/slab.h>
20#include <linux/spinlock.h> 23#include <linux/spinlock.h>
21#include <media/rc-core.h> 24#include <media/rc-core.h>
@@ -35,7 +38,8 @@ struct ir_raw_event_ctrl {
35 struct list_head list; /* to keep track of raw clients */ 38 struct list_head list; /* to keep track of raw clients */
36 struct task_struct *thread; 39 struct task_struct *thread;
37 spinlock_t lock; 40 spinlock_t lock;
38 struct kfifo_rec_ptr_1 kfifo; /* fifo for the pulse/space durations */ 41 /* fifo for the pulse/space durations */
42 DECLARE_KFIFO(kfifo, struct ir_raw_event, MAX_IR_EVENT_SIZE);
39 ktime_t last_event; /* when last event occurred */ 43 ktime_t last_event; /* when last event occurred */
40 enum raw_event_type last_type; /* last event type */ 44 enum raw_event_type last_type; /* last event type */
41 struct rc_dev *dev; /* pointer to the parent rc_dev */ 45 struct rc_dev *dev; /* pointer to the parent rc_dev */
diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c
index c69807fe2fef..144304c94606 100644
--- a/drivers/media/rc/rc-ir-raw.c
+++ b/drivers/media/rc/rc-ir-raw.c
@@ -20,9 +20,6 @@
20#include <linux/freezer.h> 20#include <linux/freezer.h>
21#include "rc-core-priv.h" 21#include "rc-core-priv.h"
22 22
23/* Define the max number of pulse/space transitions to buffer */
24#define MAX_IR_EVENT_SIZE 512
25
26/* Used to keep track of IR raw clients, protected by ir_raw_handler_lock */ 23/* Used to keep track of IR raw clients, protected by ir_raw_handler_lock */
27static LIST_HEAD(ir_raw_client_list); 24static LIST_HEAD(ir_raw_client_list);
28 25
@@ -36,14 +33,12 @@ static int ir_raw_event_thread(void *data)
36 struct ir_raw_event ev; 33 struct ir_raw_event ev;
37 struct ir_raw_handler *handler; 34 struct ir_raw_handler *handler;
38 struct ir_raw_event_ctrl *raw = (struct ir_raw_event_ctrl *)data; 35 struct ir_raw_event_ctrl *raw = (struct ir_raw_event_ctrl *)data;
39 int retval;
40 36
41 while (!kthread_should_stop()) { 37 while (!kthread_should_stop()) {
42 38
43 spin_lock_irq(&raw->lock); 39 spin_lock_irq(&raw->lock);
44 retval = kfifo_len(&raw->kfifo);
45 40
46 if (retval < sizeof(ev)) { 41 if (!kfifo_len(&raw->kfifo)) {
47 set_current_state(TASK_INTERRUPTIBLE); 42 set_current_state(TASK_INTERRUPTIBLE);
48 43
49 if (kthread_should_stop()) 44 if (kthread_should_stop())
@@ -54,7 +49,8 @@ static int ir_raw_event_thread(void *data)
54 continue; 49 continue;
55 } 50 }
56 51
57 retval = kfifo_out(&raw->kfifo, &ev, sizeof(ev)); 52 if(!kfifo_out(&raw->kfifo, &ev, 1))
53 dev_err(&raw->dev->dev, "IR event FIFO is empty!\n");
58 spin_unlock_irq(&raw->lock); 54 spin_unlock_irq(&raw->lock);
59 55
60 mutex_lock(&ir_raw_handler_lock); 56 mutex_lock(&ir_raw_handler_lock);
@@ -87,8 +83,10 @@ int ir_raw_event_store(struct rc_dev *dev, struct ir_raw_event *ev)
87 IR_dprintk(2, "sample: (%05dus %s)\n", 83 IR_dprintk(2, "sample: (%05dus %s)\n",
88 TO_US(ev->duration), TO_STR(ev->pulse)); 84 TO_US(ev->duration), TO_STR(ev->pulse));
89 85
90 if (kfifo_in(&dev->raw->kfifo, ev, sizeof(*ev)) != sizeof(*ev)) 86 if (!kfifo_put(&dev->raw->kfifo, *ev)) {
91 return -ENOMEM; 87 dev_err(&dev->dev, "IR event FIFO is full!\n");
88 return -ENOSPC;
89 }
92 90
93 return 0; 91 return 0;
94} 92}
@@ -273,11 +271,7 @@ int ir_raw_event_register(struct rc_dev *dev)
273 271
274 dev->raw->dev = dev; 272 dev->raw->dev = dev;
275 dev->change_protocol = change_protocol; 273 dev->change_protocol = change_protocol;
276 rc = kfifo_alloc(&dev->raw->kfifo, 274 INIT_KFIFO(dev->raw->kfifo);
277 sizeof(struct ir_raw_event) * MAX_IR_EVENT_SIZE,
278 GFP_KERNEL);
279 if (rc < 0)
280 goto out;
281 275
282 spin_lock_init(&dev->raw->lock); 276 spin_lock_init(&dev->raw->lock);
283 dev->raw->thread = kthread_run(ir_raw_event_thread, dev->raw, 277 dev->raw->thread = kthread_run(ir_raw_event_thread, dev->raw,
@@ -319,7 +313,6 @@ void ir_raw_event_unregister(struct rc_dev *dev)
319 handler->raw_unregister(dev); 313 handler->raw_unregister(dev);
320 mutex_unlock(&ir_raw_handler_lock); 314 mutex_unlock(&ir_raw_handler_lock);
321 315
322 kfifo_free(&dev->raw->kfifo);
323 kfree(dev->raw); 316 kfree(dev->raw);
324 dev->raw = NULL; 317 dev->raw = NULL;
325} 318}
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 1042fa331a07..4e9bbe735ae9 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -13,6 +13,7 @@
13 */ 13 */
14 14
15#include <media/rc-core.h> 15#include <media/rc-core.h>
16#include <linux/atomic.h>
16#include <linux/spinlock.h> 17#include <linux/spinlock.h>
17#include <linux/delay.h> 18#include <linux/delay.h>
18#include <linux/input.h> 19#include <linux/input.h>
@@ -723,6 +724,7 @@ int rc_open(struct rc_dev *rdev)
723 return -EINVAL; 724 return -EINVAL;
724 725
725 mutex_lock(&rdev->lock); 726 mutex_lock(&rdev->lock);
727
726 if (!rdev->users++ && rdev->open != NULL) 728 if (!rdev->users++ && rdev->open != NULL)
727 rval = rdev->open(rdev); 729 rval = rdev->open(rdev);
728 730
@@ -873,6 +875,9 @@ static ssize_t show_protocols(struct device *device,
873 if (!dev) 875 if (!dev)
874 return -EINVAL; 876 return -EINVAL;
875 877
878 if (!atomic_read(&dev->initialized))
879 return -ERESTARTSYS;
880
876 mutex_lock(&dev->lock); 881 mutex_lock(&dev->lock);
877 882
878 if (fattr->type == RC_FILTER_NORMAL) { 883 if (fattr->type == RC_FILTER_NORMAL) {
@@ -1054,6 +1059,9 @@ static ssize_t store_protocols(struct device *device,
1054 if (!dev) 1059 if (!dev)
1055 return -EINVAL; 1060 return -EINVAL;
1056 1061
1062 if (!atomic_read(&dev->initialized))
1063 return -ERESTARTSYS;
1064
1057 if (fattr->type == RC_FILTER_NORMAL) { 1065 if (fattr->type == RC_FILTER_NORMAL) {
1058 IR_dprintk(1, "Normal protocol change requested\n"); 1066 IR_dprintk(1, "Normal protocol change requested\n");
1059 current_protocols = &dev->enabled_protocols; 1067 current_protocols = &dev->enabled_protocols;
@@ -1154,12 +1162,16 @@ static ssize_t show_filter(struct device *device,
1154 if (!dev) 1162 if (!dev)
1155 return -EINVAL; 1163 return -EINVAL;
1156 1164
1165 if (!atomic_read(&dev->initialized))
1166 return -ERESTARTSYS;
1167
1168 mutex_lock(&dev->lock);
1169
1157 if (fattr->type == RC_FILTER_NORMAL) 1170 if (fattr->type == RC_FILTER_NORMAL)
1158 filter = &dev->scancode_filter; 1171 filter = &dev->scancode_filter;
1159 else 1172 else
1160 filter = &dev->scancode_wakeup_filter; 1173 filter = &dev->scancode_wakeup_filter;
1161 1174
1162 mutex_lock(&dev->lock);
1163 if (fattr->mask) 1175 if (fattr->mask)
1164 val = filter->mask; 1176 val = filter->mask;
1165 else 1177 else
@@ -1204,6 +1216,9 @@ static ssize_t store_filter(struct device *device,
1204 if (!dev) 1216 if (!dev)
1205 return -EINVAL; 1217 return -EINVAL;
1206 1218
1219 if (!atomic_read(&dev->initialized))
1220 return -ERESTARTSYS;
1221
1207 ret = kstrtoul(buf, 0, &val); 1222 ret = kstrtoul(buf, 0, &val);
1208 if (ret < 0) 1223 if (ret < 0)
1209 return ret; 1224 return ret;
@@ -1408,6 +1423,7 @@ int rc_register_device(struct rc_dev *dev)
1408 dev->minor = minor; 1423 dev->minor = minor;
1409 dev_set_name(&dev->dev, "rc%u", dev->minor); 1424 dev_set_name(&dev->dev, "rc%u", dev->minor);
1410 dev_set_drvdata(&dev->dev, dev); 1425 dev_set_drvdata(&dev->dev, dev);
1426 atomic_set(&dev->initialized, 0);
1411 1427
1412 dev->dev.groups = dev->sysfs_groups; 1428 dev->dev.groups = dev->sysfs_groups;
1413 dev->sysfs_groups[attr++] = &rc_dev_protocol_attr_grp; 1429 dev->sysfs_groups[attr++] = &rc_dev_protocol_attr_grp;
@@ -1419,14 +1435,6 @@ int rc_register_device(struct rc_dev *dev)
1419 dev->sysfs_groups[attr++] = &rc_dev_wakeup_protocol_attr_grp; 1435 dev->sysfs_groups[attr++] = &rc_dev_wakeup_protocol_attr_grp;
1420 dev->sysfs_groups[attr++] = NULL; 1436 dev->sysfs_groups[attr++] = NULL;
1421 1437
1422 /*
1423 * Take the lock here, as the device sysfs node will appear
1424 * when device_add() is called, which may trigger an ir-keytable udev
1425 * rule, which will in turn call show_protocols and access
1426 * dev->enabled_protocols before it has been initialized.
1427 */
1428 mutex_lock(&dev->lock);
1429
1430 rc = device_add(&dev->dev); 1438 rc = device_add(&dev->dev);
1431 if (rc) 1439 if (rc)
1432 goto out_unlock; 1440 goto out_unlock;
@@ -1440,16 +1448,6 @@ int rc_register_device(struct rc_dev *dev)
1440 dev->input_dev->phys = dev->input_phys; 1448 dev->input_dev->phys = dev->input_phys;
1441 dev->input_dev->name = dev->input_name; 1449 dev->input_dev->name = dev->input_name;
1442 1450
1443 /* input_register_device can call ir_open, so unlock mutex here */
1444 mutex_unlock(&dev->lock);
1445
1446 rc = input_register_device(dev->input_dev);
1447
1448 mutex_lock(&dev->lock);
1449
1450 if (rc)
1451 goto out_table;
1452
1453 /* 1451 /*
1454 * Default delay of 250ms is too short for some protocols, especially 1452 * Default delay of 250ms is too short for some protocols, especially
1455 * since the timeout is currently set to 250ms. Increase it to 500ms, 1453 * since the timeout is currently set to 250ms. Increase it to 500ms,
@@ -1465,6 +1463,11 @@ int rc_register_device(struct rc_dev *dev)
1465 */ 1463 */
1466 dev->input_dev->rep[REP_PERIOD] = 125; 1464 dev->input_dev->rep[REP_PERIOD] = 125;
1467 1465
1466 /* rc_open will be called here */
1467 rc = input_register_device(dev->input_dev);
1468 if (rc)
1469 goto out_table;
1470
1468 path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL); 1471 path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL);
1469 dev_info(&dev->dev, "%s as %s\n", 1472 dev_info(&dev->dev, "%s as %s\n",
1470 dev->input_name ?: "Unspecified device", path ?: "N/A"); 1473 dev->input_name ?: "Unspecified device", path ?: "N/A");
@@ -1475,10 +1478,7 @@ int rc_register_device(struct rc_dev *dev)
1475 request_module_nowait("ir-lirc-codec"); 1478 request_module_nowait("ir-lirc-codec");
1476 raw_init = true; 1479 raw_init = true;
1477 } 1480 }
1478 /* calls ir_register_device so unlock mutex here*/
1479 mutex_unlock(&dev->lock);
1480 rc = ir_raw_event_register(dev); 1481 rc = ir_raw_event_register(dev);
1481 mutex_lock(&dev->lock);
1482 if (rc < 0) 1482 if (rc < 0)
1483 goto out_input; 1483 goto out_input;
1484 } 1484 }
@@ -1491,6 +1491,9 @@ int rc_register_device(struct rc_dev *dev)
1491 dev->enabled_protocols = rc_type; 1491 dev->enabled_protocols = rc_type;
1492 } 1492 }
1493 1493
1494 /* Allow the RC sysfs nodes to be accessible */
1495 mutex_lock(&dev->lock);
1496 atomic_set(&dev->initialized, 1);
1494 mutex_unlock(&dev->lock); 1497 mutex_unlock(&dev->lock);
1495 1498
1496 IR_dprintk(1, "Registered rc%u (driver: %s, remote: %s, mode %s)\n", 1499 IR_dprintk(1, "Registered rc%u (driver: %s, remote: %s, mode %s)\n",
@@ -1512,7 +1515,6 @@ out_table:
1512out_dev: 1515out_dev:
1513 device_del(&dev->dev); 1516 device_del(&dev->dev);
1514out_unlock: 1517out_unlock:
1515 mutex_unlock(&dev->lock);
1516 ida_simple_remove(&rc_ida, minor); 1518 ida_simple_remove(&rc_ida, minor);
1517 return rc; 1519 return rc;
1518} 1520}
diff --git a/drivers/media/rc/sunxi-cir.c b/drivers/media/rc/sunxi-cir.c
index 40f77685cc4a..eaadc081760a 100644
--- a/drivers/media/rc/sunxi-cir.c
+++ b/drivers/media/rc/sunxi-cir.c
@@ -326,6 +326,7 @@ static const struct of_device_id sunxi_ir_match[] = {
326 { .compatible = "allwinner,sun5i-a13-ir", }, 326 { .compatible = "allwinner,sun5i-a13-ir", },
327 {}, 327 {},
328}; 328};
329MODULE_DEVICE_TABLE(of, sunxi_ir_match);
329 330
330static struct platform_driver sunxi_ir_driver = { 331static struct platform_driver sunxi_ir_driver = {
331 .probe = sunxi_ir_probe, 332 .probe = sunxi_ir_probe,
diff --git a/drivers/media/tuners/m88rs6000t.c b/drivers/media/tuners/m88rs6000t.c
index 504bfbc4027a..9f3e0fd4cad9 100644
--- a/drivers/media/tuners/m88rs6000t.c
+++ b/drivers/media/tuners/m88rs6000t.c
@@ -461,13 +461,12 @@ static int m88rs6000t_sleep(struct dvb_frontend *fe)
461 dev_dbg(&dev->client->dev, "%s:\n", __func__); 461 dev_dbg(&dev->client->dev, "%s:\n", __func__);
462 462
463 ret = regmap_write(dev->regmap, 0x07, 0x6d); 463 ret = regmap_write(dev->regmap, 0x07, 0x6d);
464 if (ret) 464 if (ret) {
465 goto err;
466 usleep_range(5000, 10000);
467err:
468 if (ret)
469 dev_dbg(&dev->client->dev, "failed=%d\n", ret); 465 dev_dbg(&dev->client->dev, "failed=%d\n", ret);
470 return ret; 466 return ret;
467 }
468 usleep_range(5000, 10000);
469 return 0;
471} 470}
472 471
473static int m88rs6000t_get_frequency(struct dvb_frontend *fe, u32 *frequency) 472static int m88rs6000t_get_frequency(struct dvb_frontend *fe, u32 *frequency)
diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
index a7a8452e99d2..6ab35e315fe7 100644
--- a/drivers/media/tuners/r820t.c
+++ b/drivers/media/tuners/r820t.c
@@ -1295,7 +1295,7 @@ static int generic_set_freq(struct dvb_frontend *fe,
1295 v4l2_std_id std, u32 delsys) 1295 v4l2_std_id std, u32 delsys)
1296{ 1296{
1297 struct r820t_priv *priv = fe->tuner_priv; 1297 struct r820t_priv *priv = fe->tuner_priv;
1298 int rc = -EINVAL; 1298 int rc;
1299 u32 lo_freq; 1299 u32 lo_freq;
1300 1300
1301 tuner_dbg("should set frequency to %d kHz, bw %d MHz\n", 1301 tuner_dbg("should set frequency to %d kHz, bw %d MHz\n",
diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index 0e1ca2b00e61..243ac3816028 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -364,8 +364,8 @@ static int si2157_get_if_frequency(struct dvb_frontend *fe, u32 *frequency)
364static const struct dvb_tuner_ops si2157_ops = { 364static const struct dvb_tuner_ops si2157_ops = {
365 .info = { 365 .info = {
366 .name = "Silicon Labs Si2146/2147/2148/2157/2158", 366 .name = "Silicon Labs Si2146/2147/2148/2157/2158",
367 .frequency_min = 55000000, 367 .frequency_min = 42000000,
368 .frequency_max = 862000000, 368 .frequency_max = 870000000,
369 }, 369 },
370 370
371 .init = si2157_init, 371 .init = si2157_init,
@@ -403,7 +403,7 @@ err:
403} 403}
404 404
405static int si2157_probe(struct i2c_client *client, 405static int si2157_probe(struct i2c_client *client,
406 const struct i2c_device_id *id) 406 const struct i2c_device_id *id)
407{ 407{
408 struct si2157_config *cfg = client->dev.platform_data; 408 struct si2157_config *cfg = client->dev.platform_data;
409 struct dvb_frontend *fe = cfg->fe; 409 struct dvb_frontend *fe = cfg->fe;
@@ -438,6 +438,31 @@ static int si2157_probe(struct i2c_client *client,
438 memcpy(&fe->ops.tuner_ops, &si2157_ops, sizeof(struct dvb_tuner_ops)); 438 memcpy(&fe->ops.tuner_ops, &si2157_ops, sizeof(struct dvb_tuner_ops));
439 fe->tuner_priv = client; 439 fe->tuner_priv = client;
440 440
441#ifdef CONFIG_MEDIA_CONTROLLER
442 if (cfg->mdev) {
443 dev->mdev = cfg->mdev;
444
445 dev->ent.name = KBUILD_MODNAME;
446 dev->ent.function = MEDIA_ENT_F_TUNER;
447
448 dev->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
449 dev->pad[TUNER_PAD_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
450 dev->pad[TUNER_PAD_AUD_OUT].flags = MEDIA_PAD_FL_SOURCE;
451
452 ret = media_entity_pads_init(&dev->ent, TUNER_NUM_PADS,
453 &dev->pad[0]);
454
455 if (ret)
456 goto err_kfree;
457
458 ret = media_device_register_entity(cfg->mdev, &dev->ent);
459 if (ret) {
460 media_entity_cleanup(&dev->ent);
461 goto err_kfree;
462 }
463 }
464#endif
465
441 dev_info(&client->dev, "Silicon Labs %s successfully attached\n", 466 dev_info(&client->dev, "Silicon Labs %s successfully attached\n",
442 dev->chiptype == SI2157_CHIPTYPE_SI2146 ? 467 dev->chiptype == SI2157_CHIPTYPE_SI2146 ?
443 "Si2146" : "Si2147/2148/2157/2158"); 468 "Si2146" : "Si2147/2148/2157/2158");
@@ -458,6 +483,14 @@ static int si2157_remove(struct i2c_client *client)
458 483
459 dev_dbg(&client->dev, "\n"); 484 dev_dbg(&client->dev, "\n");
460 485
486 /* stop statistics polling */
487 cancel_delayed_work_sync(&dev->stat_work);
488
489#ifdef CONFIG_MEDIA_CONTROLLER_DVB
490 if (dev->mdev)
491 media_device_unregister_entity(&dev->ent);
492#endif
493
461 memset(&fe->ops.tuner_ops, 0, sizeof(struct dvb_tuner_ops)); 494 memset(&fe->ops.tuner_ops, 0, sizeof(struct dvb_tuner_ops));
462 fe->tuner_priv = NULL; 495 fe->tuner_priv = NULL;
463 kfree(dev); 496 kfree(dev);
diff --git a/drivers/media/tuners/si2157.h b/drivers/media/tuners/si2157.h
index 4db97ab744d6..5f1a60bf7ced 100644
--- a/drivers/media/tuners/si2157.h
+++ b/drivers/media/tuners/si2157.h
@@ -18,6 +18,7 @@
18#define SI2157_H 18#define SI2157_H
19 19
20#include <linux/kconfig.h> 20#include <linux/kconfig.h>
21#include <media/media-device.h>
21#include "dvb_frontend.h" 22#include "dvb_frontend.h"
22 23
23/* 24/*
@@ -30,6 +31,10 @@ struct si2157_config {
30 */ 31 */
31 struct dvb_frontend *fe; 32 struct dvb_frontend *fe;
32 33
34#if defined(CONFIG_MEDIA_CONTROLLER)
35 struct media_device *mdev;
36#endif
37
33 /* 38 /*
34 * Spectral Inversion 39 * Spectral Inversion
35 */ 40 */
diff --git a/drivers/media/tuners/si2157_priv.h b/drivers/media/tuners/si2157_priv.h
index ecc463db8f69..589d558d381c 100644
--- a/drivers/media/tuners/si2157_priv.h
+++ b/drivers/media/tuners/si2157_priv.h
@@ -18,6 +18,7 @@
18#define SI2157_PRIV_H 18#define SI2157_PRIV_H
19 19
20#include <linux/firmware.h> 20#include <linux/firmware.h>
21#include <media/v4l2-mc.h>
21#include "si2157.h" 22#include "si2157.h"
22 23
23/* state struct */ 24/* state struct */
@@ -31,6 +32,13 @@ struct si2157_dev {
31 u8 if_port; 32 u8 if_port;
32 u32 if_frequency; 33 u32 if_frequency;
33 struct delayed_work stat_work; 34 struct delayed_work stat_work;
35
36#if defined(CONFIG_MEDIA_CONTROLLER)
37 struct media_device *mdev;
38 struct media_entity ent;
39 struct media_pad pad[TUNER_NUM_PADS];
40#endif
41
34}; 42};
35 43
36#define SI2157_CHIPTYPE_SI2157 0 44#define SI2157_CHIPTYPE_SI2157 0
diff --git a/drivers/media/tuners/tuner-xc2028.c b/drivers/media/tuners/tuner-xc2028.c
index 4e941f00b600..317ef63ee789 100644
--- a/drivers/media/tuners/tuner-xc2028.c
+++ b/drivers/media/tuners/tuner-xc2028.c
@@ -1403,11 +1403,14 @@ static int xc2028_set_config(struct dvb_frontend *fe, void *priv_cfg)
1403 * in order to avoid troubles during device release. 1403 * in order to avoid troubles during device release.
1404 */ 1404 */
1405 kfree(priv->ctrl.fname); 1405 kfree(priv->ctrl.fname);
1406 priv->ctrl.fname = NULL;
1406 memcpy(&priv->ctrl, p, sizeof(priv->ctrl)); 1407 memcpy(&priv->ctrl, p, sizeof(priv->ctrl));
1407 if (p->fname) { 1408 if (p->fname) {
1408 priv->ctrl.fname = kstrdup(p->fname, GFP_KERNEL); 1409 priv->ctrl.fname = kstrdup(p->fname, GFP_KERNEL);
1409 if (priv->ctrl.fname == NULL) 1410 if (priv->ctrl.fname == NULL) {
1410 rc = -ENOMEM; 1411 rc = -ENOMEM;
1412 goto unlock;
1413 }
1411 } 1414 }
1412 1415
1413 /* 1416 /*
@@ -1439,6 +1442,7 @@ static int xc2028_set_config(struct dvb_frontend *fe, void *priv_cfg)
1439 } else 1442 } else
1440 priv->state = XC2028_WAITING_FIRMWARE; 1443 priv->state = XC2028_WAITING_FIRMWARE;
1441 } 1444 }
1445unlock:
1442 mutex_unlock(&priv->lock); 1446 mutex_unlock(&priv->lock);
1443 1447
1444 return rc; 1448 return rc;
diff --git a/drivers/media/tuners/xc4000.c b/drivers/media/tuners/xc4000.c
index 219ebafae70f..d95c7e082ccf 100644
--- a/drivers/media/tuners/xc4000.c
+++ b/drivers/media/tuners/xc4000.c
@@ -1508,7 +1508,7 @@ static int xc4000_get_signal(struct dvb_frontend *fe, u16 *strength)
1508 if (value >= 0x2000) { 1508 if (value >= 0x2000) {
1509 value = 0; 1509 value = 0;
1510 } else { 1510 } else {
1511 value = ~value << 3; 1511 value = (~value << 3) & 0xffff;
1512 } 1512 }
1513 1513
1514 goto ret; 1514 goto ret;
diff --git a/drivers/media/usb/airspy/airspy.c b/drivers/media/usb/airspy/airspy.c
index 0d4ac5947f3a..87c12930416f 100644
--- a/drivers/media/usb/airspy/airspy.c
+++ b/drivers/media/usb/airspy/airspy.c
@@ -104,9 +104,8 @@ struct airspy_frame_buf {
104}; 104};
105 105
106struct airspy { 106struct airspy {
107#define POWER_ON (1 << 1) 107#define POWER_ON 1
108#define URB_BUF (1 << 2) 108#define USB_STATE_URB_BUF 2
109#define USB_STATE_URB_BUF (1 << 3)
110 unsigned long flags; 109 unsigned long flags;
111 110
112 struct device *dev; 111 struct device *dev;
@@ -359,7 +358,7 @@ static int airspy_submit_urbs(struct airspy *s)
359 358
360static int airspy_free_stream_bufs(struct airspy *s) 359static int airspy_free_stream_bufs(struct airspy *s)
361{ 360{
362 if (s->flags & USB_STATE_URB_BUF) { 361 if (test_bit(USB_STATE_URB_BUF, &s->flags)) {
363 while (s->buf_num) { 362 while (s->buf_num) {
364 s->buf_num--; 363 s->buf_num--;
365 dev_dbg(s->dev, "free buf=%d\n", s->buf_num); 364 dev_dbg(s->dev, "free buf=%d\n", s->buf_num);
@@ -368,7 +367,7 @@ static int airspy_free_stream_bufs(struct airspy *s)
368 s->dma_addr[s->buf_num]); 367 s->dma_addr[s->buf_num]);
369 } 368 }
370 } 369 }
371 s->flags &= ~USB_STATE_URB_BUF; 370 clear_bit(USB_STATE_URB_BUF, &s->flags);
372 371
373 return 0; 372 return 0;
374} 373}
@@ -394,7 +393,7 @@ static int airspy_alloc_stream_bufs(struct airspy *s)
394 dev_dbg(s->dev, "alloc buf=%d %p (dma %llu)\n", s->buf_num, 393 dev_dbg(s->dev, "alloc buf=%d %p (dma %llu)\n", s->buf_num,
395 s->buf_list[s->buf_num], 394 s->buf_list[s->buf_num],
396 (long long)s->dma_addr[s->buf_num]); 395 (long long)s->dma_addr[s->buf_num]);
397 s->flags |= USB_STATE_URB_BUF; 396 set_bit(USB_STATE_URB_BUF, &s->flags);
398 } 397 }
399 398
400 return 0; 399 return 0;
diff --git a/drivers/media/usb/as102/as102_drv.h b/drivers/media/usb/as102/as102_drv.h
index aee2d76e8dfc..8def19d9ab92 100644
--- a/drivers/media/usb/as102/as102_drv.h
+++ b/drivers/media/usb/as102/as102_drv.h
@@ -52,7 +52,7 @@ struct as10x_bus_adapter_t {
52 struct as10x_cmd_t *cmd, *rsp; 52 struct as10x_cmd_t *cmd, *rsp;
53 53
54 /* bus adapter private ops callback */ 54 /* bus adapter private ops callback */
55 struct as102_priv_ops_t *ops; 55 const struct as102_priv_ops_t *ops;
56}; 56};
57 57
58struct as102_dev_t { 58struct as102_dev_t {
diff --git a/drivers/media/usb/as102/as102_usb_drv.c b/drivers/media/usb/as102/as102_usb_drv.c
index 3f669066ccf6..0e8030c071b8 100644
--- a/drivers/media/usb/as102/as102_usb_drv.c
+++ b/drivers/media/usb/as102/as102_usb_drv.c
@@ -189,7 +189,7 @@ static int as102_read_ep2(struct as10x_bus_adapter_t *bus_adap,
189 return actual_len; 189 return actual_len;
190} 190}
191 191
192static struct as102_priv_ops_t as102_priv_ops = { 192static const struct as102_priv_ops_t as102_priv_ops = {
193 .upload_fw_pkt = as102_send_ep1, 193 .upload_fw_pkt = as102_send_ep1,
194 .xfer_cmd = as102_usb_xfer_cmd, 194 .xfer_cmd = as102_usb_xfer_cmd,
195 .as102_read_ep2 = as102_read_ep2, 195 .as102_read_ep2 = as102_read_ep2,
diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index 9e29e70a78d7..5dc82e8c8670 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include "au0828.h" 22#include "au0828.h"
23#include "au8522.h"
23 24
24#include <linux/module.h> 25#include <linux/module.h>
25#include <linux/slab.h> 26#include <linux/slab.h>
@@ -134,16 +135,16 @@ static void au0828_unregister_media_device(struct au0828_dev *dev)
134{ 135{
135 136
136#ifdef CONFIG_MEDIA_CONTROLLER 137#ifdef CONFIG_MEDIA_CONTROLLER
137 if (dev->media_dev) { 138 if (dev->media_dev &&
139 media_devnode_is_registered(&dev->media_dev->devnode)) {
138 media_device_unregister(dev->media_dev); 140 media_device_unregister(dev->media_dev);
139 media_device_cleanup(dev->media_dev); 141 media_device_cleanup(dev->media_dev);
140 kfree(dev->media_dev);
141 dev->media_dev = NULL; 142 dev->media_dev = NULL;
142 } 143 }
143#endif 144#endif
144} 145}
145 146
146static void au0828_usb_release(struct au0828_dev *dev) 147void au0828_usb_release(struct au0828_dev *dev)
147{ 148{
148 au0828_unregister_media_device(dev); 149 au0828_unregister_media_device(dev);
149 150
@@ -153,33 +154,6 @@ static void au0828_usb_release(struct au0828_dev *dev)
153 kfree(dev); 154 kfree(dev);
154} 155}
155 156
156#ifdef CONFIG_VIDEO_AU0828_V4L2
157
158static void au0828_usb_v4l2_media_release(struct au0828_dev *dev)
159{
160#ifdef CONFIG_MEDIA_CONTROLLER
161 int i;
162
163 for (i = 0; i < AU0828_MAX_INPUT; i++) {
164 if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
165 return;
166 media_device_unregister_entity(&dev->input_ent[i]);
167 }
168#endif
169}
170
171static void au0828_usb_v4l2_release(struct v4l2_device *v4l2_dev)
172{
173 struct au0828_dev *dev =
174 container_of(v4l2_dev, struct au0828_dev, v4l2_dev);
175
176 v4l2_ctrl_handler_free(&dev->v4l2_ctrl_hdl);
177 v4l2_device_unregister(&dev->v4l2_dev);
178 au0828_usb_v4l2_media_release(dev);
179 au0828_usb_release(dev);
180}
181#endif
182
183static void au0828_usb_disconnect(struct usb_interface *interface) 157static void au0828_usb_disconnect(struct usb_interface *interface)
184{ 158{
185 struct au0828_dev *dev = usb_get_intfdata(interface); 159 struct au0828_dev *dev = usb_get_intfdata(interface);
@@ -202,18 +176,13 @@ static void au0828_usb_disconnect(struct usb_interface *interface)
202 mutex_lock(&dev->mutex); 176 mutex_lock(&dev->mutex);
203 dev->usbdev = NULL; 177 dev->usbdev = NULL;
204 mutex_unlock(&dev->mutex); 178 mutex_unlock(&dev->mutex);
205#ifdef CONFIG_VIDEO_AU0828_V4L2 179 if (au0828_analog_unregister(dev)) {
206 if (AUVI_INPUT(0).type != AU0828_VMUX_UNDEFINED) {
207 au0828_analog_unregister(dev);
208 v4l2_device_disconnect(&dev->v4l2_dev);
209 v4l2_device_put(&dev->v4l2_dev);
210 /* 180 /*
211 * No need to call au0828_usb_release() if V4L2 is enabled, 181 * No need to call au0828_usb_release() if V4L2 is enabled,
212 * as this is already called via au0828_usb_v4l2_release() 182 * as this is already called via au0828_usb_v4l2_release()
213 */ 183 */
214 return; 184 return;
215 } 185 }
216#endif
217 au0828_usb_release(dev); 186 au0828_usb_release(dev);
218} 187}
219 188
@@ -223,103 +192,334 @@ static int au0828_media_device_init(struct au0828_dev *dev,
223#ifdef CONFIG_MEDIA_CONTROLLER 192#ifdef CONFIG_MEDIA_CONTROLLER
224 struct media_device *mdev; 193 struct media_device *mdev;
225 194
226 mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); 195 mdev = media_device_get_devres(&udev->dev);
227 if (!mdev) 196 if (!mdev)
228 return -ENOMEM; 197 return -ENOMEM;
229 198
230 mdev->dev = &udev->dev; 199 /* check if media device is already initialized */
231 200 if (!mdev->dev)
232 if (!dev->board.name) 201 media_device_usb_init(mdev, udev, udev->product);
233 strlcpy(mdev->model, "unknown au0828", sizeof(mdev->model));
234 else
235 strlcpy(mdev->model, dev->board.name, sizeof(mdev->model));
236 if (udev->serial)
237 strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial));
238 strcpy(mdev->bus_info, udev->devpath);
239 mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
240 mdev->driver_version = LINUX_VERSION_CODE;
241
242 media_device_init(mdev);
243 202
244 dev->media_dev = mdev; 203 dev->media_dev = mdev;
245#endif 204#endif
246 return 0; 205 return 0;
247} 206}
248 207
208#ifdef CONFIG_MEDIA_CONTROLLER
209static void au0828_media_graph_notify(struct media_entity *new,
210 void *notify_data)
211{
212 struct au0828_dev *dev = (struct au0828_dev *) notify_data;
213 int ret;
214 struct media_entity *entity, *mixer = NULL, *decoder = NULL;
215
216 if (!new) {
217 /*
218 * Called during au0828 probe time to connect
219 * entites that were created prior to registering
220 * the notify handler. Find mixer and decoder.
221 */
222 media_device_for_each_entity(entity, dev->media_dev) {
223 if (entity->function == MEDIA_ENT_F_AUDIO_MIXER)
224 mixer = entity;
225 else if (entity->function == MEDIA_ENT_F_ATV_DECODER)
226 decoder = entity;
227 }
228 goto create_link;
229 }
230
231 switch (new->function) {
232 case MEDIA_ENT_F_AUDIO_MIXER:
233 mixer = new;
234 if (dev->decoder)
235 decoder = dev->decoder;
236 break;
237 case MEDIA_ENT_F_ATV_DECODER:
238 /* In case, Mixer is added first, find mixer and create link */
239 media_device_for_each_entity(entity, dev->media_dev) {
240 if (entity->function == MEDIA_ENT_F_AUDIO_MIXER)
241 mixer = entity;
242 }
243 decoder = new;
244 break;
245 default:
246 break;
247 }
248
249create_link:
250 if (decoder && mixer) {
251 ret = media_create_pad_link(decoder,
252 DEMOD_PAD_AUDIO_OUT,
253 mixer, 0,
254 MEDIA_LNK_FL_ENABLED);
255 if (ret)
256 dev_err(&dev->usbdev->dev,
257 "Mixer Pad Link Create Error: %d\n", ret);
258 }
259}
249 260
250static int au0828_create_media_graph(struct au0828_dev *dev) 261static int au0828_enable_source(struct media_entity *entity,
262 struct media_pipeline *pipe)
251{ 263{
252#ifdef CONFIG_MEDIA_CONTROLLER 264 struct media_entity *source, *find_source;
253 struct media_device *mdev = dev->media_dev; 265 struct media_entity *sink;
254 struct media_entity *entity; 266 struct media_link *link, *found_link = NULL;
255 struct media_entity *tuner = NULL, *decoder = NULL; 267 int ret = 0;
256 int i, ret; 268 struct media_device *mdev = entity->graph_obj.mdev;
269 struct au0828_dev *dev;
257 270
258 if (!mdev) 271 if (!mdev)
259 return 0; 272 return -ENODEV;
260 273
261 media_device_for_each_entity(entity, mdev) { 274 mutex_lock(&mdev->graph_mutex);
262 switch (entity->function) { 275
263 case MEDIA_ENT_F_TUNER: 276 dev = mdev->source_priv;
264 tuner = entity; 277
265 break; 278 /*
266 case MEDIA_ENT_F_ATV_DECODER: 279 * For Audio and V4L2 entity, find the link to which decoder
267 decoder = entity; 280 * is the sink. Look for an active link between decoder and
281 * source (tuner/s-video/Composite), if one exists, nothing
282 * to do. If not, look for any active links between source
283 * and any other entity. If one exists, source is busy. If
284 * source is free, setup link and start pipeline from source.
285 * For DVB FE entity, the source for the link is the tuner.
286 * Check if tuner is available and setup link and start
287 * pipeline.
288 */
289 if (entity->function == MEDIA_ENT_F_DTV_DEMOD) {
290 sink = entity;
291 find_source = dev->tuner;
292 } else {
293 /* Analog isn't configured or register failed */
294 if (!dev->decoder) {
295 ret = -ENODEV;
296 goto end;
297 }
298
299 sink = dev->decoder;
300
301 /*
302 * Default input is tuner and default input_type
303 * is AU0828_VMUX_TELEVISION.
304 * FIXME:
305 * There is a problem when s_input is called to
306 * change the default input. s_input will try to
307 * enable_source before attempting to change the
308 * input on the device, and will end up enabling
309 * default source which is tuner.
310 *
311 * Additional logic is necessary in au0828
312 * to detect that the input has changed and
313 * enable the right source.
314 */
315
316 if (dev->input_type == AU0828_VMUX_TELEVISION)
317 find_source = dev->tuner;
318 else if (dev->input_type == AU0828_VMUX_SVIDEO ||
319 dev->input_type == AU0828_VMUX_COMPOSITE)
320 find_source = &dev->input_ent[dev->input_type];
321 else {
322 /* unknown input - let user select input */
323 ret = 0;
324 goto end;
325 }
326 }
327
328 /* Is an active link between sink and source */
329 if (dev->active_link) {
330 /*
331 * If DVB is using the tuner and calling entity is
332 * audio/video, the following check will be false,
333 * since sink is different. Result is Busy.
334 */
335 if (dev->active_link->sink->entity == sink &&
336 dev->active_link->source->entity == find_source) {
337 /*
338 * Either ALSA or Video own tuner. sink is
339 * the same for both. Prevent Video stepping
340 * on ALSA when ALSA owns the source.
341 */
342 if (dev->active_link_owner != entity &&
343 dev->active_link_owner->function ==
344 MEDIA_ENT_F_AUDIO_CAPTURE) {
345 pr_debug("ALSA has the tuner\n");
346 ret = -EBUSY;
347 goto end;
348 }
349 ret = 0;
350 goto end;
351 } else {
352 ret = -EBUSY;
353 goto end;
354 }
355 }
356
357 list_for_each_entry(link, &sink->links, list) {
358 /* Check sink, and source */
359 if (link->sink->entity == sink &&
360 link->source->entity == find_source) {
361 found_link = link;
268 break; 362 break;
269 } 363 }
270 } 364 }
271 365
272 /* Analog setup, using tuner as a link */ 366 if (!found_link) {
367 ret = -ENODEV;
368 goto end;
369 }
273 370
274 /* Something bad happened! */ 371 /* activate link between source and sink and start pipeline */
275 if (!decoder) 372 source = found_link->source->entity;
276 return -EINVAL; 373 ret = __media_entity_setup_link(found_link, MEDIA_LNK_FL_ENABLED);
374 if (ret) {
375 pr_err("Activate tuner link %s->%s. Error %d\n",
376 source->name, sink->name, ret);
377 goto end;
378 }
277 379
278 if (tuner) { 380 ret = __media_entity_pipeline_start(entity, pipe);
279 ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, 381 if (ret) {
280 decoder, 0, 382 pr_err("Start Pipeline: %s->%s Error %d\n",
281 MEDIA_LNK_FL_ENABLED); 383 source->name, entity->name, ret);
384 ret = __media_entity_setup_link(found_link, 0);
385 pr_err("Deactivate link Error %d\n", ret);
386 goto end;
387 }
388 /*
389 * save active link and active link owner to avoid audio
390 * deactivating video owned link from disable_source and
391 * vice versa
392 */
393 dev->active_link = found_link;
394 dev->active_link_owner = entity;
395 dev->active_source = source;
396 dev->active_sink = sink;
397
398 pr_debug("Enabled Source: %s->%s->%s Ret %d\n",
399 dev->active_source->name, dev->active_sink->name,
400 dev->active_link_owner->name, ret);
401end:
402 mutex_unlock(&mdev->graph_mutex);
403 pr_debug("au0828_enable_source() end %s %d %d\n",
404 entity->name, entity->function, ret);
405 return ret;
406}
407
408static void au0828_disable_source(struct media_entity *entity)
409{
410 int ret = 0;
411 struct media_device *mdev = entity->graph_obj.mdev;
412 struct au0828_dev *dev;
413
414 if (!mdev)
415 return;
416
417 mutex_lock(&mdev->graph_mutex);
418 dev = mdev->source_priv;
419
420 if (!dev->active_link) {
421 ret = -ENODEV;
422 goto end;
423 }
424
425 /* link is active - stop pipeline from source (tuner) */
426 if (dev->active_link->sink->entity == dev->active_sink &&
427 dev->active_link->source->entity == dev->active_source) {
428 /*
429 * prevent video from deactivating link when audio
430 * has active pipeline
431 */
432 if (dev->active_link_owner != entity)
433 goto end;
434 __media_entity_pipeline_stop(entity);
435 ret = __media_entity_setup_link(dev->active_link, 0);
282 if (ret) 436 if (ret)
283 return ret; 437 pr_err("Deactivate link Error %d\n", ret);
438
439 pr_debug("Disabled Source: %s->%s->%s Ret %d\n",
440 dev->active_source->name, dev->active_sink->name,
441 dev->active_link_owner->name, ret);
442
443 dev->active_link = NULL;
444 dev->active_link_owner = NULL;
445 dev->active_source = NULL;
446 dev->active_sink = NULL;
284 } 447 }
285 ret = media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
286 MEDIA_LNK_FL_ENABLED);
287 if (ret)
288 return ret;
289 ret = media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0,
290 MEDIA_LNK_FL_ENABLED);
291 if (ret)
292 return ret;
293 448
294 for (i = 0; i < AU0828_MAX_INPUT; i++) { 449end:
295 struct media_entity *ent = &dev->input_ent[i]; 450 mutex_unlock(&mdev->graph_mutex);
451}
452#endif
296 453
297 if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED) 454static int au0828_media_device_register(struct au0828_dev *dev,
298 break; 455 struct usb_device *udev)
456{
457#ifdef CONFIG_MEDIA_CONTROLLER
458 int ret;
459 struct media_entity *entity, *demod = NULL, *tuner = NULL;
299 460
300 switch (AUVI_INPUT(i).type) { 461 if (!dev->media_dev)
301 case AU0828_VMUX_CABLE: 462 return 0;
302 case AU0828_VMUX_TELEVISION: 463
303 case AU0828_VMUX_DVB: 464 if (!media_devnode_is_registered(&dev->media_dev->devnode)) {
304 if (!tuner) 465
305 break; 466 /* register media device */
306 467 ret = media_device_register(dev->media_dev);
307 ret = media_create_pad_link(ent, 0, tuner, 468 if (ret) {
308 TUNER_PAD_RF_INPUT, 469 dev_err(&udev->dev,
309 MEDIA_LNK_FL_ENABLED); 470 "Media Device Register Error: %d\n", ret);
310 if (ret) 471 return ret;
311 return ret; 472 }
312 break; 473 } else {
313 case AU0828_VMUX_COMPOSITE: 474 /*
314 case AU0828_VMUX_SVIDEO: 475 * Call au0828_media_graph_notify() to connect
315 default: /* AU0828_VMUX_DEBUG */ 476 * audio graph to our graph. In this case, audio
316 /* FIXME: fix the decoder PAD */ 477 * driver registered the device and there is no
317 ret = media_create_pad_link(ent, 0, decoder, 0, 0); 478 * entity_notify to be called when new entities
318 if (ret) 479 * are added. Invoke it now.
319 return ret; 480 */
320 break; 481 au0828_media_graph_notify(NULL, (void *) dev);
482 }
483
484 /*
485 * Find tuner and demod to disable the link between
486 * the two to avoid disable step when tuner is requested
487 * by video or audio. Note that this step can't be done
488 * until dvb graph is created during dvb register.
489 */
490 media_device_for_each_entity(entity, dev->media_dev) {
491 if (entity->function == MEDIA_ENT_F_DTV_DEMOD)
492 demod = entity;
493 else if (entity->function == MEDIA_ENT_F_TUNER)
494 tuner = entity;
495 }
496 /* Disable link between tuner and demod */
497 if (tuner && demod) {
498 struct media_link *link;
499
500 list_for_each_entry(link, &demod->links, list) {
501 if (link->sink->entity == demod &&
502 link->source->entity == tuner) {
503 media_entity_setup_link(link, 0);
504 }
321 } 505 }
322 } 506 }
507
508 /* register entity_notify callback */
509 dev->entity_notify.notify_data = (void *) dev;
510 dev->entity_notify.notify = (void *) au0828_media_graph_notify;
511 ret = media_device_register_entity_notify(dev->media_dev,
512 &dev->entity_notify);
513 if (ret) {
514 dev_err(&udev->dev,
515 "Media Device register entity_notify Error: %d\n",
516 ret);
517 return ret;
518 }
519 /* set enable_source */
520 dev->media_dev->source_priv = (void *) dev;
521 dev->media_dev->enable_source = au0828_enable_source;
522 dev->media_dev->disable_source = au0828_disable_source;
323#endif 523#endif
324 return 0; 524 return 0;
325} 525}
@@ -378,32 +578,13 @@ static int au0828_usb_probe(struct usb_interface *interface,
378 return retval; 578 return retval;
379 } 579 }
380 580
381#ifdef CONFIG_VIDEO_AU0828_V4L2 581 retval = au0828_v4l2_device_register(interface, dev);
382 dev->v4l2_dev.release = au0828_usb_v4l2_release;
383
384 /* Create the v4l2_device */
385#ifdef CONFIG_MEDIA_CONTROLLER
386 dev->v4l2_dev.mdev = dev->media_dev;
387#endif
388 retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev);
389 if (retval) { 582 if (retval) {
390 pr_err("%s() v4l2_device_register failed\n", 583 au0828_usb_v4l2_media_release(dev);
391 __func__);
392 mutex_unlock(&dev->lock); 584 mutex_unlock(&dev->lock);
393 kfree(dev); 585 kfree(dev);
394 return retval; 586 return retval;
395 } 587 }
396 /* This control handler will inherit the controls from au8522 */
397 retval = v4l2_ctrl_handler_init(&dev->v4l2_ctrl_hdl, 4);
398 if (retval) {
399 pr_err("%s() v4l2_ctrl_handler_init failed\n",
400 __func__);
401 mutex_unlock(&dev->lock);
402 kfree(dev);
403 return retval;
404 }
405 dev->v4l2_dev.ctrl_handler = &dev->v4l2_ctrl_hdl;
406#endif
407 588
408 /* Power Up the bridge */ 589 /* Power Up the bridge */
409 au0828_write(dev, REG_600, 1 << 4); 590 au0828_write(dev, REG_600, 1 << 4);
@@ -417,11 +598,13 @@ static int au0828_usb_probe(struct usb_interface *interface,
417 /* Setup */ 598 /* Setup */
418 au0828_card_setup(dev); 599 au0828_card_setup(dev);
419 600
420#ifdef CONFIG_VIDEO_AU0828_V4L2
421 /* Analog TV */ 601 /* Analog TV */
422 if (AUVI_INPUT(0).type != AU0828_VMUX_UNDEFINED) 602 retval = au0828_analog_register(dev, interface);
423 au0828_analog_register(dev, interface); 603 if (retval) {
424#endif 604 pr_err("%s() au0282_dev_register failed to register on V4L2\n",
605 __func__);
606 goto done;
607 }
425 608
426 /* Digital TV */ 609 /* Digital TV */
427 retval = au0828_dvb_register(dev); 610 retval = au0828_dvb_register(dev);
@@ -443,16 +626,7 @@ static int au0828_usb_probe(struct usb_interface *interface,
443 626
444 mutex_unlock(&dev->lock); 627 mutex_unlock(&dev->lock);
445 628
446 retval = au0828_create_media_graph(dev); 629 retval = au0828_media_device_register(dev, usbdev);
447 if (retval) {
448 pr_err("%s() au0282_dev_register failed to create graph\n",
449 __func__);
450 goto done;
451 }
452
453#ifdef CONFIG_MEDIA_CONTROLLER
454 retval = media_device_register(dev->media_dev);
455#endif
456 630
457done: 631done:
458 if (retval < 0) 632 if (retval < 0)
diff --git a/drivers/media/usb/au0828/au0828-dvb.c b/drivers/media/usb/au0828/au0828-dvb.c
index 94363a3ba400..0e174e860614 100644
--- a/drivers/media/usb/au0828/au0828-dvb.c
+++ b/drivers/media/usb/au0828/au0828-dvb.c
@@ -181,7 +181,7 @@ static int stop_urb_transfer(struct au0828_dev *dev)
181static int start_urb_transfer(struct au0828_dev *dev) 181static int start_urb_transfer(struct au0828_dev *dev)
182{ 182{
183 struct urb *purb; 183 struct urb *purb;
184 int i, ret = -ENOMEM; 184 int i, ret;
185 185
186 dprintk(2, "%s()\n", __func__); 186 dprintk(2, "%s()\n", __func__);
187 187
@@ -194,7 +194,7 @@ static int start_urb_transfer(struct au0828_dev *dev)
194 194
195 dev->urbs[i] = usb_alloc_urb(0, GFP_KERNEL); 195 dev->urbs[i] = usb_alloc_urb(0, GFP_KERNEL);
196 if (!dev->urbs[i]) 196 if (!dev->urbs[i])
197 goto err; 197 return -ENOMEM;
198 198
199 purb = dev->urbs[i]; 199 purb = dev->urbs[i];
200 200
@@ -207,9 +207,10 @@ static int start_urb_transfer(struct au0828_dev *dev)
207 if (!purb->transfer_buffer) { 207 if (!purb->transfer_buffer) {
208 usb_free_urb(purb); 208 usb_free_urb(purb);
209 dev->urbs[i] = NULL; 209 dev->urbs[i] = NULL;
210 ret = -ENOMEM;
210 pr_err("%s: failed big buffer allocation, err = %d\n", 211 pr_err("%s: failed big buffer allocation, err = %d\n",
211 __func__, ret); 212 __func__, ret);
212 goto err; 213 return ret;
213 } 214 }
214 215
215 purb->status = -EINPROGRESS; 216 purb->status = -EINPROGRESS;
@@ -235,10 +236,7 @@ static int start_urb_transfer(struct au0828_dev *dev)
235 } 236 }
236 237
237 dev->urb_streaming = true; 238 dev->urb_streaming = true;
238 ret = 0; 239 return 0;
239
240err:
241 return ret;
242} 240}
243 241
244static void au0828_start_transport(struct au0828_dev *dev) 242static void au0828_start_transport(struct au0828_dev *dev)
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index a13625722848..13f6dab9ccc2 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -28,12 +28,14 @@
28 */ 28 */
29 29
30#include "au0828.h" 30#include "au0828.h"
31#include "au8522.h"
31 32
32#include <linux/module.h> 33#include <linux/module.h>
33#include <linux/slab.h> 34#include <linux/slab.h>
34#include <linux/init.h> 35#include <linux/init.h>
35#include <linux/device.h> 36#include <linux/device.h>
36#include <media/v4l2-common.h> 37#include <media/v4l2-common.h>
38#include <media/v4l2-mc.h>
37#include <media/v4l2-ioctl.h> 39#include <media/v4l2-ioctl.h>
38#include <media/v4l2-event.h> 40#include <media/v4l2-event.h>
39#include <media/tuner.h> 41#include <media/tuner.h>
@@ -638,61 +640,64 @@ static inline int au0828_isoc_copy(struct au0828_dev *dev, struct urb *urb)
638 return rc; 640 return rc;
639} 641}
640 642
641static int au0828_enable_analog_tuner(struct au0828_dev *dev) 643void au0828_usb_v4l2_media_release(struct au0828_dev *dev)
642{ 644{
643#ifdef CONFIG_MEDIA_CONTROLLER 645#ifdef CONFIG_MEDIA_CONTROLLER
644 struct media_device *mdev = dev->media_dev; 646 int i;
645 struct media_entity *source;
646 struct media_link *link, *found_link = NULL;
647 int ret, active_links = 0;
648
649 if (!mdev || !dev->decoder)
650 return 0;
651 647
652 /* 648 for (i = 0; i < AU0828_MAX_INPUT; i++) {
653 * This will find the tuner that is connected into the decoder. 649 if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
654 * Technically, this is not 100% correct, as the device may be 650 return;
655 * using an analog input instead of the tuner. However, as we can't 651 media_device_unregister_entity(&dev->input_ent[i]);
656 * do DVB streaming while the DMA engine is being used for V4L2,
657 * this should be enough for the actual needs.
658 */
659 list_for_each_entry(link, &dev->decoder->links, list) {
660 if (link->sink->entity == dev->decoder) {
661 found_link = link;
662 if (link->flags & MEDIA_LNK_FL_ENABLED)
663 active_links++;
664 break;
665 }
666 } 652 }
653#endif
654}
667 655
668 if (active_links == 1 || !found_link) 656static void au0828_usb_v4l2_release(struct v4l2_device *v4l2_dev)
669 return 0; 657{
658 struct au0828_dev *dev =
659 container_of(v4l2_dev, struct au0828_dev, v4l2_dev);
660
661 v4l2_ctrl_handler_free(&dev->v4l2_ctrl_hdl);
662 v4l2_device_unregister(&dev->v4l2_dev);
663 au0828_usb_v4l2_media_release(dev);
664 au0828_usb_release(dev);
665}
670 666
671 source = found_link->source->entity; 667int au0828_v4l2_device_register(struct usb_interface *interface,
672 list_for_each_entry(link, &source->links, list) { 668 struct au0828_dev *dev)
673 struct media_entity *sink; 669{
674 int flags = 0; 670 int retval;
675 671
676 sink = link->sink->entity; 672 if (AUVI_INPUT(0).type == AU0828_VMUX_UNDEFINED)
673 return 0;
677 674
678 if (sink == dev->decoder) 675 /* Create the v4l2_device */
679 flags = MEDIA_LNK_FL_ENABLED; 676#ifdef CONFIG_MEDIA_CONTROLLER
677 dev->v4l2_dev.mdev = dev->media_dev;
678#endif
679 retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev);
680 if (retval) {
681 pr_err("%s() v4l2_device_register failed\n",
682 __func__);
683 mutex_unlock(&dev->lock);
684 kfree(dev);
685 return retval;
686 }
680 687
681 ret = media_entity_setup_link(link, flags); 688 dev->v4l2_dev.release = au0828_usb_v4l2_release;
682 if (ret) { 689
683 pr_err( 690 /* This control handler will inherit the controls from au8522 */
684 "Couldn't change link %s->%s to %s. Error %d\n", 691 retval = v4l2_ctrl_handler_init(&dev->v4l2_ctrl_hdl, 4);
685 source->name, sink->name, 692 if (retval) {
686 flags ? "enabled" : "disabled", 693 pr_err("%s() v4l2_ctrl_handler_init failed\n",
687 ret); 694 __func__);
688 return ret; 695 mutex_unlock(&dev->lock);
689 } else 696 kfree(dev);
690 au0828_isocdbg( 697 return retval;
691 "link %s->%s was %s\n",
692 source->name, sink->name,
693 flags ? "ENABLED" : "disabled");
694 } 698 }
695#endif 699 dev->v4l2_dev.ctrl_handler = &dev->v4l2_ctrl_hdl;
700
696 return 0; 701 return 0;
697} 702}
698 703
@@ -707,9 +712,6 @@ static int queue_setup(struct vb2_queue *vq,
707 return sizes[0] < size ? -EINVAL : 0; 712 return sizes[0] < size ? -EINVAL : 0;
708 *nplanes = 1; 713 *nplanes = 1;
709 sizes[0] = size; 714 sizes[0] = size;
710
711 au0828_enable_analog_tuner(dev);
712
713 return 0; 715 return 0;
714} 716}
715 717
@@ -949,13 +951,23 @@ static struct vb2_ops au0828_video_qops = {
949 * au0828_analog_unregister 951 * au0828_analog_unregister
950 * unregister v4l2 devices 952 * unregister v4l2 devices
951 */ 953 */
952void au0828_analog_unregister(struct au0828_dev *dev) 954int au0828_analog_unregister(struct au0828_dev *dev)
953{ 955{
954 dprintk(1, "au0828_analog_unregister called\n"); 956 dprintk(1, "au0828_analog_unregister called\n");
957
958 /* No analog TV */
959 if (AUVI_INPUT(0).type == AU0828_VMUX_UNDEFINED)
960 return 0;
961
955 mutex_lock(&au0828_sysfs_lock); 962 mutex_lock(&au0828_sysfs_lock);
956 video_unregister_device(&dev->vdev); 963 video_unregister_device(&dev->vdev);
957 video_unregister_device(&dev->vbi_dev); 964 video_unregister_device(&dev->vbi_dev);
958 mutex_unlock(&au0828_sysfs_lock); 965 mutex_unlock(&au0828_sysfs_lock);
966
967 v4l2_device_disconnect(&dev->v4l2_dev);
968 v4l2_device_put(&dev->v4l2_dev);
969
970 return 1;
959} 971}
960 972
961/* This function ensures that video frames continue to be delivered even if 973/* This function ensures that video frames continue to be delivered even if
@@ -1067,8 +1079,39 @@ static int au0828_v4l2_close(struct file *filp)
1067 goto end; 1079 goto end;
1068 1080
1069 if (dev->users == 1) { 1081 if (dev->users == 1) {
1070 /* Save some power by putting tuner to sleep */ 1082 /*
1071 v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_power, 0); 1083 * Avoid putting tuner in sleep if DVB or ALSA are
1084 * streaming.
1085 *
1086 * On most USB devices like au0828 the tuner can
1087 * be safely put in sleep stare here if ALSA isn't
1088 * streaming. Exceptions are some very old USB tuner
1089 * models such as em28xx-based WinTV USB2 which have
1090 * a separate audio output jack. The devices that have
1091 * a separate audio output jack have analog tuners,
1092 * like Philips FM1236. Those devices are always on,
1093 * so the s_power callback are silently ignored.
1094 * So, the current logic here does the following:
1095 * Disable (put tuner to sleep) when
1096 * - ALSA and DVB aren't not streaming;
1097 * - the last V4L2 file handler is closed.
1098 *
1099 * FIXME:
1100 *
1101 * Additionally, this logic could be improved to
1102 * disable the media source if the above conditions
1103 * are met and if the device:
1104 * - doesn't have a separate audio out plug (or
1105 * - doesn't use a silicon tuner like xc2028/3028/4000/5000).
1106 *
1107 * Once this additional logic is in place, a callback
1108 * is needed to enable the media source and power on
1109 * the tuner, for radio to work.
1110 */
1111 ret = v4l_enable_media_source(vdev);
1112 if (ret == 0)
1113 v4l2_device_call_all(&dev->v4l2_dev, 0, core,
1114 s_power, 0);
1072 dev->std_set_in_tuner_core = 0; 1115 dev->std_set_in_tuner_core = 0;
1073 1116
1074 /* When close the device, set the usb intf0 into alt0 to free 1117 /* When close the device, set the usb intf0 into alt0 to free
@@ -1312,7 +1355,6 @@ static int vidioc_enum_input(struct file *file, void *priv,
1312 [AU0828_VMUX_CABLE] = "Cable TV", 1355 [AU0828_VMUX_CABLE] = "Cable TV",
1313 [AU0828_VMUX_TELEVISION] = "Television", 1356 [AU0828_VMUX_TELEVISION] = "Television",
1314 [AU0828_VMUX_DVB] = "DVB", 1357 [AU0828_VMUX_DVB] = "DVB",
1315 [AU0828_VMUX_DEBUG] = "tv debug"
1316 }; 1358 };
1317 1359
1318 dprintk(1, "%s called std_set %d dev_state %d\n", __func__, 1360 dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
@@ -1375,9 +1417,11 @@ static void au0828_s_input(struct au0828_dev *dev, int index)
1375 default: 1417 default:
1376 dprintk(1, "unknown input type set [%d]\n", 1418 dprintk(1, "unknown input type set [%d]\n",
1377 AUVI_INPUT(index).type); 1419 AUVI_INPUT(index).type);
1378 break; 1420 return;
1379 } 1421 }
1380 1422
1423 dev->ctrl_input = index;
1424
1381 v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_routing, 1425 v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_routing,
1382 AUVI_INPUT(index).vmux, 0, 0); 1426 AUVI_INPUT(index).vmux, 0, 0);
1383 1427
@@ -1409,6 +1453,7 @@ static void au0828_s_input(struct au0828_dev *dev, int index)
1409static int vidioc_s_input(struct file *file, void *priv, unsigned int index) 1453static int vidioc_s_input(struct file *file, void *priv, unsigned int index)
1410{ 1454{
1411 struct au0828_dev *dev = video_drvdata(file); 1455 struct au0828_dev *dev = video_drvdata(file);
1456 struct video_device *vfd = video_devdata(file);
1412 1457
1413 dprintk(1, "VIDIOC_S_INPUT in function %s, input=%d\n", __func__, 1458 dprintk(1, "VIDIOC_S_INPUT in function %s, input=%d\n", __func__,
1414 index); 1459 index);
@@ -1416,9 +1461,19 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int index)
1416 return -EINVAL; 1461 return -EINVAL;
1417 if (AUVI_INPUT(index).type == 0) 1462 if (AUVI_INPUT(index).type == 0)
1418 return -EINVAL; 1463 return -EINVAL;
1419 dev->ctrl_input = index; 1464
1465 if (dev->ctrl_input == index)
1466 return 0;
1467
1420 au0828_s_input(dev, index); 1468 au0828_s_input(dev, index);
1421 return 0; 1469
1470 /*
1471 * Input has been changed. Disable the media source
1472 * associated with the old input and enable source
1473 * for the newly set input
1474 */
1475 v4l_disable_media_source(vfd);
1476 return v4l_enable_media_source(vfd);
1422} 1477}
1423 1478
1424static int vidioc_enumaudio(struct file *file, void *priv, struct v4l2_audio *a) 1479static int vidioc_enumaudio(struct file *file, void *priv, struct v4l2_audio *a)
@@ -1469,10 +1524,16 @@ static int vidioc_s_audio(struct file *file, void *priv, const struct v4l2_audio
1469static int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t) 1524static int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
1470{ 1525{
1471 struct au0828_dev *dev = video_drvdata(file); 1526 struct au0828_dev *dev = video_drvdata(file);
1527 struct video_device *vfd = video_devdata(file);
1528 int ret;
1472 1529
1473 if (t->index != 0) 1530 if (t->index != 0)
1474 return -EINVAL; 1531 return -EINVAL;
1475 1532
1533 ret = v4l_enable_media_source(vfd);
1534 if (ret)
1535 return ret;
1536
1476 dprintk(1, "%s called std_set %d dev_state %d\n", __func__, 1537 dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
1477 dev->std_set_in_tuner_core, dev->dev_state); 1538 dev->std_set_in_tuner_core, dev->dev_state);
1478 1539
@@ -1804,7 +1865,6 @@ static void au0828_analog_create_entities(struct au0828_dev *dev)
1804 [AU0828_VMUX_CABLE] = "Cable TV", 1865 [AU0828_VMUX_CABLE] = "Cable TV",
1805 [AU0828_VMUX_TELEVISION] = "Television", 1866 [AU0828_VMUX_TELEVISION] = "Television",
1806 [AU0828_VMUX_DVB] = "DVB", 1867 [AU0828_VMUX_DVB] = "DVB",
1807 [AU0828_VMUX_DEBUG] = "tv debug"
1808 }; 1868 };
1809 int ret, i; 1869 int ret, i;
1810 1870
@@ -1840,10 +1900,9 @@ static void au0828_analog_create_entities(struct au0828_dev *dev)
1840 case AU0828_VMUX_CABLE: 1900 case AU0828_VMUX_CABLE:
1841 case AU0828_VMUX_TELEVISION: 1901 case AU0828_VMUX_TELEVISION:
1842 case AU0828_VMUX_DVB: 1902 case AU0828_VMUX_DVB:
1903 default: /* Just to shut up a warning */
1843 ent->function = MEDIA_ENT_F_CONN_RF; 1904 ent->function = MEDIA_ENT_F_CONN_RF;
1844 break; 1905 break;
1845 default: /* AU0828_VMUX_DEBUG */
1846 continue;
1847 } 1906 }
1848 1907
1849 ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]); 1908 ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]);
@@ -1870,6 +1929,10 @@ int au0828_analog_register(struct au0828_dev *dev,
1870 dprintk(1, "au0828_analog_register called for intf#%d!\n", 1929 dprintk(1, "au0828_analog_register called for intf#%d!\n",
1871 interface->cur_altsetting->desc.bInterfaceNumber); 1930 interface->cur_altsetting->desc.bInterfaceNumber);
1872 1931
1932 /* No analog TV */
1933 if (AUVI_INPUT(0).type == AU0828_VMUX_UNDEFINED)
1934 return 0;
1935
1873 /* set au0828 usb interface0 to as5 */ 1936 /* set au0828 usb interface0 to as5 */
1874 retval = usb_set_interface(dev->usbdev, 1937 retval = usb_set_interface(dev->usbdev,
1875 interface->cur_altsetting->desc.bInterfaceNumber, 5); 1938 interface->cur_altsetting->desc.bInterfaceNumber, 5);
@@ -1924,6 +1987,7 @@ int au0828_analog_register(struct au0828_dev *dev,
1924 dev->ctrl_ainput = 0; 1987 dev->ctrl_ainput = 0;
1925 dev->ctrl_freq = 960; 1988 dev->ctrl_freq = 960;
1926 dev->std = V4L2_STD_NTSC_M; 1989 dev->std = V4L2_STD_NTSC_M;
1990 /* Default input is TV Tuner */
1927 au0828_s_input(dev, 0); 1991 au0828_s_input(dev, 0);
1928 1992
1929 mutex_init(&dev->vb_queue_lock); 1993 mutex_init(&dev->vb_queue_lock);
@@ -1976,6 +2040,16 @@ int au0828_analog_register(struct au0828_dev *dev,
1976 goto err_reg_vbi_dev; 2040 goto err_reg_vbi_dev;
1977 } 2041 }
1978 2042
2043#ifdef CONFIG_MEDIA_CONTROLLER
2044 retval = v4l2_mc_create_media_graph(dev->media_dev);
2045 if (retval) {
2046 pr_err("%s() au0282_dev_register failed to create graph\n",
2047 __func__);
2048 ret = -ENODEV;
2049 goto err_reg_vbi_dev;
2050 }
2051#endif
2052
1979 dprintk(1, "%s completed!\n", __func__); 2053 dprintk(1, "%s completed!\n", __func__);
1980 2054
1981 return 0; 2055 return 0;
diff --git a/drivers/media/usb/au0828/au0828.h b/drivers/media/usb/au0828/au0828.h
index 8276072bc55a..ff7f8510fb77 100644
--- a/drivers/media/usb/au0828/au0828.h
+++ b/drivers/media/usb/au0828/au0828.h
@@ -76,7 +76,6 @@ enum au0828_itype {
76 AU0828_VMUX_CABLE, 76 AU0828_VMUX_CABLE,
77 AU0828_VMUX_TELEVISION, 77 AU0828_VMUX_TELEVISION,
78 AU0828_VMUX_DVB, 78 AU0828_VMUX_DVB,
79 AU0828_VMUX_DEBUG
80}; 79};
81 80
82struct au0828_input { 81struct au0828_input {
@@ -283,6 +282,12 @@ struct au0828_dev {
283 struct media_entity *decoder; 282 struct media_entity *decoder;
284 struct media_entity input_ent[AU0828_MAX_INPUT]; 283 struct media_entity input_ent[AU0828_MAX_INPUT];
285 struct media_pad input_pad[AU0828_MAX_INPUT]; 284 struct media_pad input_pad[AU0828_MAX_INPUT];
285 struct media_entity_notify entity_notify;
286 struct media_entity *tuner;
287 struct media_link *active_link;
288 struct media_entity *active_link_owner;
289 struct media_entity *active_source;
290 struct media_entity *active_sink;
286#endif 291#endif
287}; 292};
288 293
@@ -301,6 +306,7 @@ struct au0828_dev {
301/* au0828-core.c */ 306/* au0828-core.c */
302extern u32 au0828_read(struct au0828_dev *dev, u16 reg); 307extern u32 au0828_read(struct au0828_dev *dev, u16 reg);
303extern u32 au0828_write(struct au0828_dev *dev, u16 reg, u32 val); 308extern u32 au0828_write(struct au0828_dev *dev, u16 reg, u32 val);
309extern void au0828_usb_release(struct au0828_dev *dev);
304extern int au0828_debug; 310extern int au0828_debug;
305 311
306/* ----------------------------------------------------------- */ 312/* ----------------------------------------------------------- */
@@ -319,16 +325,29 @@ extern int au0828_i2c_unregister(struct au0828_dev *dev);
319 325
320/* ----------------------------------------------------------- */ 326/* ----------------------------------------------------------- */
321/* au0828-video.c */ 327/* au0828-video.c */
322extern int au0828_analog_register(struct au0828_dev *dev,
323 struct usb_interface *interface);
324extern void au0828_analog_unregister(struct au0828_dev *dev);
325extern int au0828_start_analog_streaming(struct vb2_queue *vq, 328extern int au0828_start_analog_streaming(struct vb2_queue *vq,
326 unsigned int count); 329 unsigned int count);
327extern void au0828_stop_vbi_streaming(struct vb2_queue *vq); 330extern void au0828_stop_vbi_streaming(struct vb2_queue *vq);
328#ifdef CONFIG_VIDEO_AU0828_V4L2 331#ifdef CONFIG_VIDEO_AU0828_V4L2
332extern int au0828_v4l2_device_register(struct usb_interface *interface,
333 struct au0828_dev *dev);
334
335extern int au0828_analog_register(struct au0828_dev *dev,
336 struct usb_interface *interface);
337extern int au0828_analog_unregister(struct au0828_dev *dev);
338extern void au0828_usb_v4l2_media_release(struct au0828_dev *dev);
329extern void au0828_v4l2_suspend(struct au0828_dev *dev); 339extern void au0828_v4l2_suspend(struct au0828_dev *dev);
330extern void au0828_v4l2_resume(struct au0828_dev *dev); 340extern void au0828_v4l2_resume(struct au0828_dev *dev);
331#else 341#else
342static inline int au0828_v4l2_device_register(struct usb_interface *interface,
343 struct au0828_dev *dev)
344{ return 0; };
345static inline int au0828_analog_register(struct au0828_dev *dev,
346 struct usb_interface *interface)
347{ return 0; };
348static inline int au0828_analog_unregister(struct au0828_dev *dev)
349{ return 0; };
350static inline void au0828_usb_v4l2_media_release(struct au0828_dev *dev) { };
332static inline void au0828_v4l2_suspend(struct au0828_dev *dev) { }; 351static inline void au0828_v4l2_suspend(struct au0828_dev *dev) { };
333static inline void au0828_v4l2_resume(struct au0828_dev *dev) { }; 352static inline void au0828_v4l2_resume(struct au0828_dev *dev) { };
334#endif 353#endif
diff --git a/drivers/media/usb/b2c2/flexcop-usb.c b/drivers/media/usb/b2c2/flexcop-usb.c
index 0bd969063392..d4bdba60b0f7 100644
--- a/drivers/media/usb/b2c2/flexcop-usb.c
+++ b/drivers/media/usb/b2c2/flexcop-usb.c
@@ -10,7 +10,7 @@
10/* Version information */ 10/* Version information */
11#define DRIVER_VERSION "0.1" 11#define DRIVER_VERSION "0.1"
12#define DRIVER_NAME "Technisat/B2C2 FlexCop II/IIb/III Digital TV USB Driver" 12#define DRIVER_NAME "Technisat/B2C2 FlexCop II/IIb/III Digital TV USB Driver"
13#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@desy.de>" 13#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@posteo.de>"
14 14
15/* debug */ 15/* debug */
16#ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG 16#ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG
diff --git a/drivers/media/usb/cpia2/cpia2_core.c b/drivers/media/usb/cpia2/cpia2_core.c
index 187012ce444b..0310fd6ed103 100644
--- a/drivers/media/usb/cpia2/cpia2_core.c
+++ b/drivers/media/usb/cpia2/cpia2_core.c
@@ -923,7 +923,7 @@ static int apply_vp_patch(struct camera_data *cam)
923 /* ... followed by the data payload */ 923 /* ... followed by the data payload */
924 for (i = 2; i < fw->size; i += 64) { 924 for (i = 2; i < fw->size; i += 64) {
925 cmd.start = 0x0C; /* Data */ 925 cmd.start = 0x0C; /* Data */
926 cmd.reg_count = min_t(int, 64, fw->size - i); 926 cmd.reg_count = min_t(uint, 64, fw->size - i);
927 memcpy(cmd.buffer.block_data, &fw->data[i], cmd.reg_count); 927 memcpy(cmd.buffer.block_data, &fw->data[i], cmd.reg_count);
928 cpia2_send_command(cam, &cmd); 928 cpia2_send_command(cam, &cmd);
929 } 929 }
diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c
index 48643b94e694..c9320d6c6131 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -1382,6 +1382,8 @@ static int cx231xx_bulk_copy(struct cx231xx *dev, struct urb *urb)
1382 buffer_size = urb->actual_length; 1382 buffer_size = urb->actual_length;
1383 1383
1384 buffer = kmalloc(buffer_size, GFP_ATOMIC); 1384 buffer = kmalloc(buffer_size, GFP_ATOMIC);
1385 if (!buffer)
1386 return -ENOMEM;
1385 1387
1386 memcpy(buffer, dma_q->ps_head, 3); 1388 memcpy(buffer, dma_q->ps_head, 3);
1387 memcpy(buffer+3, p_buffer, buffer_size-3); 1389 memcpy(buffer+3, p_buffer, buffer_size-3);
diff --git a/drivers/media/usb/cx231xx/cx231xx-audio.c b/drivers/media/usb/cx231xx/cx231xx-audio.c
index de4ae5eb4830..a6a9508418f8 100644
--- a/drivers/media/usb/cx231xx/cx231xx-audio.c
+++ b/drivers/media/usb/cx231xx/cx231xx-audio.c
@@ -499,6 +499,11 @@ static int snd_cx231xx_pcm_close(struct snd_pcm_substream *substream)
499 } 499 }
500 500
501 dev->adev.users--; 501 dev->adev.users--;
502 if (substream->runtime->dma_area) {
503 dev_dbg(dev->dev, "freeing\n");
504 vfree(substream->runtime->dma_area);
505 substream->runtime->dma_area = NULL;
506 }
502 mutex_unlock(&dev->lock); 507 mutex_unlock(&dev->lock);
503 508
504 if (dev->adev.users == 0 && dev->adev.shutdown == 1) { 509 if (dev->adev.users == 0 && dev->adev.shutdown == 1) {
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 620b83d03f75..c63248a18823 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1216,66 +1216,13 @@ static int cx231xx_media_device_init(struct cx231xx *dev,
1216 if (!mdev) 1216 if (!mdev)
1217 return -ENOMEM; 1217 return -ENOMEM;
1218 1218
1219 mdev->dev = dev->dev; 1219 media_device_usb_init(mdev, udev, dev->board.name);
1220 strlcpy(mdev->model, dev->board.name, sizeof(mdev->model));
1221 if (udev->serial)
1222 strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial));
1223 strcpy(mdev->bus_info, udev->devpath);
1224 mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
1225 mdev->driver_version = LINUX_VERSION_CODE;
1226
1227 media_device_init(mdev);
1228 1220
1229 dev->media_dev = mdev; 1221 dev->media_dev = mdev;
1230#endif 1222#endif
1231 return 0; 1223 return 0;
1232} 1224}
1233 1225
1234static int cx231xx_create_media_graph(struct cx231xx *dev)
1235{
1236#ifdef CONFIG_MEDIA_CONTROLLER
1237 struct media_device *mdev = dev->media_dev;
1238 struct media_entity *entity;
1239 struct media_entity *tuner = NULL, *decoder = NULL;
1240 int ret;
1241
1242 if (!mdev)
1243 return 0;
1244
1245 media_device_for_each_entity(entity, mdev) {
1246 switch (entity->function) {
1247 case MEDIA_ENT_F_TUNER:
1248 tuner = entity;
1249 break;
1250 case MEDIA_ENT_F_ATV_DECODER:
1251 decoder = entity;
1252 break;
1253 }
1254 }
1255
1256 /* Analog setup, using tuner as a link */
1257
1258 if (!decoder)
1259 return 0;
1260
1261 if (tuner) {
1262 ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0,
1263 MEDIA_LNK_FL_ENABLED);
1264 if (ret < 0)
1265 return ret;
1266 }
1267 ret = media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
1268 MEDIA_LNK_FL_ENABLED);
1269 if (ret < 0)
1270 return ret;
1271 ret = media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0,
1272 MEDIA_LNK_FL_ENABLED);
1273 if (ret < 0)
1274 return ret;
1275#endif
1276 return 0;
1277}
1278
1279/* 1226/*
1280 * cx231xx_init_dev() 1227 * cx231xx_init_dev()
1281 * allocates and inits the device structs, registers i2c bus and v4l device 1228 * allocates and inits the device structs, registers i2c bus and v4l device
@@ -1739,15 +1686,14 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
1739 /* load other modules required */ 1686 /* load other modules required */
1740 request_modules(dev); 1687 request_modules(dev);
1741 1688
1742 retval = cx231xx_create_media_graph(dev);
1743 if (retval < 0)
1744 goto done;
1745
1746#ifdef CONFIG_MEDIA_CONTROLLER 1689#ifdef CONFIG_MEDIA_CONTROLLER
1747 retval = media_device_register(dev->media_dev); 1690 /* Init entities at the Media Controller */
1748#endif 1691 cx231xx_v4l2_create_entities(dev);
1749 1692
1750done: 1693 retval = v4l2_mc_create_media_graph(dev->media_dev);
1694 if (!retval)
1695 retval = media_device_register(dev->media_dev);
1696#endif
1751 if (retval < 0) 1697 if (retval < 0)
1752 cx231xx_release_resources(dev); 1698 cx231xx_release_resources(dev);
1753 return retval; 1699 return retval;
diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
index b8d5b2be9293..ab2fb9fa0cd1 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
@@ -25,6 +25,7 @@
25 25
26#include <media/v4l2-common.h> 26#include <media/v4l2-common.h>
27#include <media/videobuf-vmalloc.h> 27#include <media/videobuf-vmalloc.h>
28#include <media/tuner.h>
28 29
29#include "xc5000.h" 30#include "xc5000.h"
30#include "s5h1432.h" 31#include "s5h1432.h"
@@ -551,7 +552,8 @@ static int register_dvb(struct cx231xx_dvb *dvb,
551 552
552 /* register network adapter */ 553 /* register network adapter */
553 dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx); 554 dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx);
554 result = dvb_create_media_graph(&dvb->adapter, false); 555 result = dvb_create_media_graph(&dvb->adapter,
556 dev->tuner_type == TUNER_ABSENT);
555 if (result < 0) 557 if (result < 0)
556 goto fail_create_graph; 558 goto fail_create_graph;
557 559
@@ -801,6 +803,9 @@ static int dvb_init(struct cx231xx *dev)
801 /* attach tuner */ 803 /* attach tuner */
802 memset(&si2157_config, 0, sizeof(si2157_config)); 804 memset(&si2157_config, 0, sizeof(si2157_config));
803 si2157_config.fe = dev->dvb->frontend; 805 si2157_config.fe = dev->dvb->frontend;
806#ifdef CONFIG_MEDIA_CONTROLLER_DVB
807 si2157_config.mdev = dev->media_dev;
808#endif
804 si2157_config.if_port = 1; 809 si2157_config.if_port = 1;
805 si2157_config.inversion = true; 810 si2157_config.inversion = true;
806 strlcpy(info.type, "si2157", I2C_NAME_SIZE); 811 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
@@ -857,6 +862,9 @@ static int dvb_init(struct cx231xx *dev)
857 /* attach tuner */ 862 /* attach tuner */
858 memset(&si2157_config, 0, sizeof(si2157_config)); 863 memset(&si2157_config, 0, sizeof(si2157_config));
859 si2157_config.fe = dev->dvb->frontend; 864 si2157_config.fe = dev->dvb->frontend;
865#ifdef CONFIG_MEDIA_CONTROLLER_DVB
866 si2157_config.mdev = dev->media_dev;
867#endif
860 si2157_config.if_port = 1; 868 si2157_config.if_port = 1;
861 si2157_config.inversion = true; 869 si2157_config.inversion = true;
862 strlcpy(info.type, "si2157", I2C_NAME_SIZE); 870 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
index 9b88cd8127ac..6414188ffdfa 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -1103,9 +1103,54 @@ static const char *iname[] = {
1103 [CX231XX_VMUX_TELEVISION] = "Television", 1103 [CX231XX_VMUX_TELEVISION] = "Television",
1104 [CX231XX_VMUX_CABLE] = "Cable TV", 1104 [CX231XX_VMUX_CABLE] = "Cable TV",
1105 [CX231XX_VMUX_DVB] = "DVB", 1105 [CX231XX_VMUX_DVB] = "DVB",
1106 [CX231XX_VMUX_DEBUG] = "for debug only",
1107}; 1106};
1108 1107
1108void cx231xx_v4l2_create_entities(struct cx231xx *dev)
1109{
1110#if defined(CONFIG_MEDIA_CONTROLLER)
1111 int ret, i;
1112
1113 /* Create entities for each input connector */
1114 for (i = 0; i < MAX_CX231XX_INPUT; i++) {
1115 struct media_entity *ent = &dev->input_ent[i];
1116
1117 if (!INPUT(i)->type)
1118 break;
1119
1120 ent->name = iname[INPUT(i)->type];
1121 ent->flags = MEDIA_ENT_FL_CONNECTOR;
1122 dev->input_pad[i].flags = MEDIA_PAD_FL_SOURCE;
1123
1124 switch (INPUT(i)->type) {
1125 case CX231XX_VMUX_COMPOSITE1:
1126 ent->function = MEDIA_ENT_F_CONN_COMPOSITE;
1127 break;
1128 case CX231XX_VMUX_SVIDEO:
1129 ent->function = MEDIA_ENT_F_CONN_SVIDEO;
1130 break;
1131 case CX231XX_VMUX_TELEVISION:
1132 case CX231XX_VMUX_CABLE:
1133 case CX231XX_VMUX_DVB:
1134 /* The DVB core will handle it */
1135 if (dev->tuner_type == TUNER_ABSENT)
1136 continue;
1137 /* fall though */
1138 default: /* just to shut up a gcc warning */
1139 ent->function = MEDIA_ENT_F_CONN_RF;
1140 break;
1141 }
1142
1143 ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]);
1144 if (ret < 0)
1145 pr_err("failed to initialize input pad[%d]!\n", i);
1146
1147 ret = media_device_register_entity(dev->media_dev, ent);
1148 if (ret < 0)
1149 pr_err("failed to register input entity %d!\n", i);
1150 }
1151#endif
1152}
1153
1109int cx231xx_enum_input(struct file *file, void *priv, 1154int cx231xx_enum_input(struct file *file, void *priv,
1110 struct v4l2_input *i) 1155 struct v4l2_input *i)
1111{ 1156{
diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
index ec6d3f5bc36d..69f6d20870f5 100644
--- a/drivers/media/usb/cx231xx/cx231xx.h
+++ b/drivers/media/usb/cx231xx/cx231xx.h
@@ -281,7 +281,6 @@ enum cx231xx_itype {
281 CX231XX_VMUX_CABLE, 281 CX231XX_VMUX_CABLE,
282 CX231XX_RADIO, 282 CX231XX_RADIO,
283 CX231XX_VMUX_DVB, 283 CX231XX_VMUX_DVB,
284 CX231XX_VMUX_DEBUG
285}; 284};
286 285
287enum cx231xx_v_input { 286enum cx231xx_v_input {
@@ -663,6 +662,8 @@ struct cx231xx {
663#if defined(CONFIG_MEDIA_CONTROLLER) 662#if defined(CONFIG_MEDIA_CONTROLLER)
664 struct media_device *media_dev; 663 struct media_device *media_dev;
665 struct media_pad video_pad, vbi_pad; 664 struct media_pad video_pad, vbi_pad;
665 struct media_entity input_ent[MAX_CX231XX_INPUT];
666 struct media_pad input_pad[MAX_CX231XX_INPUT];
666#endif 667#endif
667 668
668 unsigned char eedata[256]; 669 unsigned char eedata[256];
@@ -943,6 +944,7 @@ int cx231xx_register_extension(struct cx231xx_ops *dev);
943void cx231xx_unregister_extension(struct cx231xx_ops *dev); 944void cx231xx_unregister_extension(struct cx231xx_ops *dev);
944void cx231xx_init_extension(struct cx231xx *dev); 945void cx231xx_init_extension(struct cx231xx *dev);
945void cx231xx_close_extension(struct cx231xx *dev); 946void cx231xx_close_extension(struct cx231xx *dev);
947void cx231xx_v4l2_create_entities(struct cx231xx *dev);
946int cx231xx_querycap(struct file *file, void *priv, 948int cx231xx_querycap(struct file *file, void *priv,
947 struct v4l2_capability *cap); 949 struct v4l2_capability *cap);
948int cx231xx_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t); 950int cx231xx_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t);
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
index 6e02a15d39ce..2638e3251f2a 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -684,7 +684,7 @@ static int af9035_download_firmware(struct dvb_usb_device *d,
684 if (ret < 0) 684 if (ret < 0)
685 goto err; 685 goto err;
686 686
687 if (tmp == 1 || tmp == 3) { 687 if (tmp == 1 || tmp == 3 || tmp == 5) {
688 /* configure gpioh1, reset & power slave demod */ 688 /* configure gpioh1, reset & power slave demod */
689 ret = af9035_wr_reg_mask(d, 0x00d8b0, 0x01, 0x01); 689 ret = af9035_wr_reg_mask(d, 0x00d8b0, 0x01, 0x01);
690 if (ret < 0) 690 if (ret < 0)
@@ -823,7 +823,7 @@ static int af9035_read_config(struct dvb_usb_device *d)
823 if (ret < 0) 823 if (ret < 0)
824 goto err; 824 goto err;
825 825
826 if (tmp == 1 || tmp == 3) 826 if (tmp == 1 || tmp == 3 || tmp == 5)
827 state->dual_mode = true; 827 state->dual_mode = true;
828 828
829 dev_dbg(&d->udev->dev, "%s: ts mode=%d dual mode=%d\n", __func__, 829 dev_dbg(&d->udev->dev, "%s: ts mode=%d dual mode=%d\n", __func__,
@@ -2053,6 +2053,8 @@ static const struct usb_device_id af9035_id_table[] = {
2053 &af9035_props, "Avermedia A835B(3835)", RC_MAP_IT913X_V2) }, 2053 &af9035_props, "Avermedia A835B(3835)", RC_MAP_IT913X_V2) },
2054 { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_4835, 2054 { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_4835,
2055 &af9035_props, "Avermedia A835B(4835)", RC_MAP_IT913X_V2) }, 2055 &af9035_props, "Avermedia A835B(4835)", RC_MAP_IT913X_V2) },
2056 { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_TD110,
2057 &af9035_props, "Avermedia AverTV Volar HD 2 (TD110)", RC_MAP_AVERMEDIA_RM_KS) },
2056 { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_H335, 2058 { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_H335,
2057 &af9035_props, "Avermedia H335", RC_MAP_IT913X_V2) }, 2059 &af9035_props, "Avermedia H335", RC_MAP_IT913X_V2) },
2058 { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_UB499_2T_T09, 2060 { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_UB499_2T_T09,
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.h b/drivers/media/usb/dvb-usb-v2/af9035.h
index 416a97f05ec8..df22001f9e41 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.h
+++ b/drivers/media/usb/dvb-usb-v2/af9035.h
@@ -112,9 +112,10 @@ static const u32 clock_lut_it9135[] = {
112 * 0 TS 112 * 0 TS
113 * 1 DCA + PIP 113 * 1 DCA + PIP
114 * 3 PIP 114 * 3 PIP
115 * 5 DCA + PIP
115 * n DCA 116 * n DCA
116 * 117 *
117 * Values 0 and 3 are seen to this day. 0 for single TS and 3 for dual TS. 118 * Values 0, 3 and 5 are seen to this day. 0 for single TS and 3/5 for dual TS.
118 */ 119 */
119 120
120#define EEPROM_BASE_AF9035 0x42fd 121#define EEPROM_BASE_AF9035 0x42fd
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb.h b/drivers/media/usb/dvb-usb-v2/dvb_usb.h
index 023d91f7e654..35f27e2e4e28 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb.h
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * DVB USB framework 2 * DVB USB framework
3 * 3 *
4 * Copyright (C) 2004-6 Patrick Boettcher <patrick.boettcher@desy.de> 4 * Copyright (C) 2004-6 Patrick Boettcher <patrick.boettcher@posteo.de>
5 * Copyright (C) 2012 Antti Palosaari <crope@iki.fi> 5 * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_common.h b/drivers/media/usb/dvb-usb-v2/dvb_usb_common.h
index 45f07090d431..a1622bda2a5e 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb_common.h
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_common.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * DVB USB framework 2 * DVB USB framework
3 * 3 *
4 * Copyright (C) 2004-6 Patrick Boettcher <patrick.boettcher@desy.de> 4 * Copyright (C) 2004-6 Patrick Boettcher <patrick.boettcher@posteo.de>
5 * Copyright (C) 2012 Antti Palosaari <crope@iki.fi> 5 * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
index f0565bf3673e..3fbb2cd19f5e 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * DVB USB framework 2 * DVB USB framework
3 * 3 *
4 * Copyright (C) 2004-6 Patrick Boettcher <patrick.boettcher@desy.de> 4 * Copyright (C) 2004-6 Patrick Boettcher <patrick.boettcher@posteo.de>
5 * Copyright (C) 2012 Antti Palosaari <crope@iki.fi> 5 * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include "dvb_usb_common.h" 22#include "dvb_usb_common.h"
23#include <media/media-device.h>
23 24
24static int dvb_usbv2_disable_rc_polling; 25static int dvb_usbv2_disable_rc_polling;
25module_param_named(disable_rc_polling, dvb_usbv2_disable_rc_polling, int, 0644); 26module_param_named(disable_rc_polling, dvb_usbv2_disable_rc_polling, int, 0644);
@@ -411,15 +412,7 @@ static int dvb_usbv2_media_device_init(struct dvb_usb_adapter *adap)
411 if (!mdev) 412 if (!mdev)
412 return -ENOMEM; 413 return -ENOMEM;
413 414
414 mdev->dev = &udev->dev; 415 media_device_usb_init(mdev, udev, d->name);
415 strlcpy(mdev->model, d->name, sizeof(mdev->model));
416 if (udev->serial)
417 strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial));
418 strcpy(mdev->bus_info, udev->devpath);
419 mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
420 mdev->driver_version = LINUX_VERSION_CODE;
421
422 media_device_init(mdev);
423 416
424 dvb_register_media_controller(&adap->dvb_adap, mdev); 417 dvb_register_media_controller(&adap->dvb_adap, mdev);
425 418
@@ -1129,7 +1122,7 @@ int dvb_usbv2_reset_resume(struct usb_interface *intf)
1129EXPORT_SYMBOL(dvb_usbv2_reset_resume); 1122EXPORT_SYMBOL(dvb_usbv2_reset_resume);
1130 1123
1131MODULE_VERSION("2.0"); 1124MODULE_VERSION("2.0");
1132MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 1125MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
1133MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); 1126MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
1134MODULE_DESCRIPTION("DVB USB common"); 1127MODULE_DESCRIPTION("DVB USB common");
1135MODULE_LICENSE("GPL"); 1128MODULE_LICENSE("GPL");
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c
index 22bdce15ecf3..5bafeb6486be 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * DVB USB framework 2 * DVB USB framework
3 * 3 *
4 * Copyright (C) 2004-6 Patrick Boettcher <patrick.boettcher@desy.de> 4 * Copyright (C) 2004-6 Patrick Boettcher <patrick.boettcher@posteo.de>
5 * Copyright (C) 2012 Antti Palosaari <crope@iki.fi> 5 * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c b/drivers/media/usb/dvb-usb-v2/dvbsky.c
index 1dd962535f97..02dbc6c45423 100644
--- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -847,10 +847,17 @@ static const struct usb_device_id dvbsky_id_table[] = {
847 USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI, 847 USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI,
848 &dvbsky_t680c_props, "TechnoTrend TT-connect CT2-4650 CI", 848 &dvbsky_t680c_props, "TechnoTrend TT-connect CT2-4650 CI",
849 RC_MAP_TT_1500) }, 849 RC_MAP_TT_1500) },
850 { DVB_USB_DEVICE(USB_VID_TECHNOTREND,
851 USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI_2,
852 &dvbsky_t680c_props, "TechnoTrend TT-connect CT2-4650 CI v1.1",
853 RC_MAP_TT_1500) },
850 { DVB_USB_DEVICE(USB_VID_TERRATEC, 854 { DVB_USB_DEVICE(USB_VID_TERRATEC,
851 USB_PID_TERRATEC_H7_3, 855 USB_PID_TERRATEC_H7_3,
852 &dvbsky_t680c_props, "Terratec H7 Rev.4", 856 &dvbsky_t680c_props, "Terratec H7 Rev.4",
853 RC_MAP_TT_1500) }, 857 RC_MAP_TT_1500) },
858 { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R4,
859 &dvbsky_s960_props, "Terratec Cinergy S2 Rev.4",
860 RC_MAP_DVBSKY) },
854 { } 861 { }
855}; 862};
856MODULE_DEVICE_TABLE(usb, dvbsky_id_table); 863MODULE_DEVICE_TABLE(usb, dvbsky_id_table);
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c b/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c
index 84f6de6fa07d..047a32fe43ea 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c
@@ -507,9 +507,9 @@ static int mxl111sf_demod_read_signal_strength(struct dvb_frontend *fe,
507 return 0; 507 return 0;
508} 508}
509 509
510static int mxl111sf_demod_get_frontend(struct dvb_frontend *fe) 510static int mxl111sf_demod_get_frontend(struct dvb_frontend *fe,
511 struct dtv_frontend_properties *p)
511{ 512{
512 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
513 struct mxl111sf_demod_state *state = fe->demodulator_priv; 513 struct mxl111sf_demod_state *state = fe->demodulator_priv;
514 514
515 mxl_dbg("()"); 515 mxl_dbg("()");
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c b/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c
index 444579be0b77..7d16252dbb71 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c
@@ -36,7 +36,7 @@ MODULE_PARM_DESC(debug, "set debugging level (1=info (or-able)).");
36struct mxl111sf_tuner_state { 36struct mxl111sf_tuner_state {
37 struct mxl111sf_state *mxl_state; 37 struct mxl111sf_state *mxl_state;
38 38
39 struct mxl111sf_tuner_config *cfg; 39 const struct mxl111sf_tuner_config *cfg;
40 40
41 enum mxl_if_freq if_freq; 41 enum mxl_if_freq if_freq;
42 42
@@ -489,8 +489,8 @@ static struct dvb_tuner_ops mxl111sf_tuner_tuner_ops = {
489}; 489};
490 490
491struct dvb_frontend *mxl111sf_tuner_attach(struct dvb_frontend *fe, 491struct dvb_frontend *mxl111sf_tuner_attach(struct dvb_frontend *fe,
492 struct mxl111sf_state *mxl_state, 492 struct mxl111sf_state *mxl_state,
493 struct mxl111sf_tuner_config *cfg) 493 const struct mxl111sf_tuner_config *cfg)
494{ 494{
495 struct mxl111sf_tuner_state *state = NULL; 495 struct mxl111sf_tuner_state *state = NULL;
496 496
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.h b/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.h
index e6caab21a197..509b55071218 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.h
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.h
@@ -63,13 +63,13 @@ struct mxl111sf_tuner_config {
63#if IS_ENABLED(CONFIG_DVB_USB_MXL111SF) 63#if IS_ENABLED(CONFIG_DVB_USB_MXL111SF)
64extern 64extern
65struct dvb_frontend *mxl111sf_tuner_attach(struct dvb_frontend *fe, 65struct dvb_frontend *mxl111sf_tuner_attach(struct dvb_frontend *fe,
66 struct mxl111sf_state *mxl_state, 66 struct mxl111sf_state *mxl_state,
67 struct mxl111sf_tuner_config *cfg); 67 const struct mxl111sf_tuner_config *cfg);
68#else 68#else
69static inline 69static inline
70struct dvb_frontend *mxl111sf_tuner_attach(struct dvb_frontend *fe, 70struct dvb_frontend *mxl111sf_tuner_attach(struct dvb_frontend *fe,
71 struct mxl111sf_state *mxl_state, 71 struct mxl111sf_state *mxl_state,
72 struct mxl111sf_tuner_config *cfg) 72 const struct mxl111sf_tuner_config *cfg)
73{ 73{
74 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 74 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
75 return NULL; 75 return NULL;
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf.c b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
index b669deccc34c..5d676b533a3a 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
@@ -856,7 +856,7 @@ static int mxl111sf_ant_hunt(struct dvb_frontend *fe)
856 return 0; 856 return 0;
857} 857}
858 858
859static struct mxl111sf_tuner_config mxl_tuner_config = { 859static const struct mxl111sf_tuner_config mxl_tuner_config = {
860 .if_freq = MXL_IF_6_0, /* applies to external IF output, only */ 860 .if_freq = MXL_IF_6_0, /* applies to external IF output, only */
861 .invert_spectrum = 0, 861 .invert_spectrum = 0,
862 .read_reg = mxl111sf_read_reg, 862 .read_reg = mxl111sf_read_reg,
@@ -888,7 +888,7 @@ static int mxl111sf_attach_tuner(struct dvb_usb_adapter *adap)
888 state->tuner.function = MEDIA_ENT_F_TUNER; 888 state->tuner.function = MEDIA_ENT_F_TUNER;
889 state->tuner.name = "mxl111sf tuner"; 889 state->tuner.name = "mxl111sf tuner";
890 state->tuner_pads[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK; 890 state->tuner_pads[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
891 state->tuner_pads[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE; 891 state->tuner_pads[TUNER_PAD_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
892 892
893 ret = media_entity_pads_init(&state->tuner, 893 ret = media_entity_pads_init(&state->tuner,
894 TUNER_NUM_PADS, state->tuner_pads); 894 TUNER_NUM_PADS, state->tuner_pads);
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index eb5787a3191e..fa72642d41f3 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -259,6 +259,10 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
259 ret = -EOPNOTSUPP; 259 ret = -EOPNOTSUPP;
260 } 260 }
261 261
262 /* Retry failed I2C messages */
263 if (ret == -EPIPE)
264 ret = -EAGAIN;
265
262err_mutex_unlock: 266err_mutex_unlock:
263 mutex_unlock(&d->i2c_mutex); 267 mutex_unlock(&d->i2c_mutex);
264 268
@@ -619,6 +623,10 @@ static int rtl28xxu_identify_state(struct dvb_usb_device *d, const char **name)
619 } 623 }
620 dev_dbg(&d->intf->dev, "chip_id=%u\n", dev->chip_id); 624 dev_dbg(&d->intf->dev, "chip_id=%u\n", dev->chip_id);
621 625
626 /* Retry failed I2C messages */
627 d->i2c_adap.retries = 1;
628 d->i2c_adap.timeout = msecs_to_jiffies(10);
629
622 return WARM; 630 return WARM;
623err: 631err:
624 dev_dbg(&d->intf->dev, "failed=%d\n", ret); 632 dev_dbg(&d->intf->dev, "failed=%d\n", ret);
@@ -1563,19 +1571,19 @@ static int rtl28xxu_frontend_ctrl(struct dvb_frontend *fe, int onoff)
1563 if (dev->chip_id == CHIP_ID_RTL2831U) 1571 if (dev->chip_id == CHIP_ID_RTL2831U)
1564 return 0; 1572 return 0;
1565 1573
1566 /* control internal demod ADC */ 1574 if (fe->id == 0) {
1567 if (fe->id == 0 && onoff) 1575 /* control internal demod ADC */
1568 val = 0x48; /* enable ADC */ 1576 if (onoff)
1569 else 1577 val = 0x48; /* enable ADC */
1570 val = 0x00; /* disable ADC */ 1578 else
1571 1579 val = 0x00; /* disable ADC */
1572 ret = rtl28xxu_wr_reg_mask(d, SYS_DEMOD_CTL, val, 0x48);
1573 if (ret)
1574 goto err;
1575 1580
1576 /* bypass slave demod TS through master demod */ 1581 ret = rtl28xxu_wr_reg_mask(d, SYS_DEMOD_CTL, val, 0x48);
1577 if (fe->id == 1 && onoff) { 1582 if (ret)
1578 ret = pdata->enable_slave_ts(dev->i2c_client_demod); 1583 goto err;
1584 } else if (fe->id == 1) {
1585 /* bypass slave demod TS through master demod */
1586 ret = pdata->slave_ts_ctrl(dev->i2c_client_demod, onoff);
1579 if (ret) 1587 if (ret)
1580 goto err; 1588 goto err;
1581 } 1589 }
diff --git a/drivers/media/usb/dvb-usb-v2/usb_urb.c b/drivers/media/usb/dvb-usb-v2/usb_urb.c
index ca8f3c2b1082..55136cde38f5 100644
--- a/drivers/media/usb/dvb-usb-v2/usb_urb.c
+++ b/drivers/media/usb/dvb-usb-v2/usb_urb.c
@@ -1,6 +1,6 @@
1/* usb-urb.c is part of the DVB USB library. 1/* usb-urb.c is part of the DVB USB library.
2 * 2 *
3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) 3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
4 * see dvb-usb-init.c for copyright information. 4 * see dvb-usb-init.c for copyright information.
5 * 5 *
6 * This file keeps functions for initializing and handling the 6 * This file keeps functions for initializing and handling the
diff --git a/drivers/media/usb/dvb-usb/a800.c b/drivers/media/usb/dvb-usb/a800.c
index 83684ed023cd..7ba975bea96a 100644
--- a/drivers/media/usb/dvb-usb/a800.c
+++ b/drivers/media/usb/dvb-usb/a800.c
@@ -1,7 +1,7 @@
1/* DVB USB framework compliant Linux driver for the AVerMedia AverTV DVB-T 1/* DVB USB framework compliant Linux driver for the AVerMedia AverTV DVB-T
2 * USB2.0 (A800) DVB-T receiver. 2 * USB2.0 (A800) DVB-T receiver.
3 * 3 *
4 * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@desy.de) 4 * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@posteo.de)
5 * 5 *
6 * Thanks to 6 * Thanks to
7 * - AVerMedia who kindly provided information and 7 * - AVerMedia who kindly provided information and
@@ -185,7 +185,7 @@ static struct usb_driver a800_driver = {
185 185
186module_usb_driver(a800_driver); 186module_usb_driver(a800_driver);
187 187
188MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 188MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
189MODULE_DESCRIPTION("AVerMedia AverTV DVB-T USB 2.0 (A800)"); 189MODULE_DESCRIPTION("AVerMedia AverTV DVB-T USB 2.0 (A800)");
190MODULE_VERSION("1.0"); 190MODULE_VERSION("1.0");
191MODULE_LICENSE("GPL"); 191MODULE_LICENSE("GPL");
diff --git a/drivers/media/usb/dvb-usb/af9005-fe.c b/drivers/media/usb/dvb-usb/af9005-fe.c
index ac97075d75f7..09db3d02bd82 100644
--- a/drivers/media/usb/dvb-usb/af9005-fe.c
+++ b/drivers/media/usb/dvb-usb/af9005-fe.c
@@ -1227,9 +1227,9 @@ static int af9005_fe_set_frontend(struct dvb_frontend *fe)
1227 return 0; 1227 return 0;
1228} 1228}
1229 1229
1230static int af9005_fe_get_frontend(struct dvb_frontend *fe) 1230static int af9005_fe_get_frontend(struct dvb_frontend *fe,
1231 struct dtv_frontend_properties *fep)
1231{ 1232{
1232 struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
1233 struct af9005_fe_state *state = fe->demodulator_priv; 1233 struct af9005_fe_state *state = fe->demodulator_priv;
1234 int ret; 1234 int ret;
1235 u8 temp; 1235 u8 temp;
diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
index ab7151181728..907ac01ae297 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -13,7 +13,7 @@
13 * 13 *
14 * TODO: Use the cx25840-driver for the analogue part 14 * TODO: Use the cx25840-driver for the analogue part
15 * 15 *
16 * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@desy.de) 16 * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@posteo.de)
17 * Copyright (C) 2006 Michael Krufky (mkrufky@linuxtv.org) 17 * Copyright (C) 2006 Michael Krufky (mkrufky@linuxtv.org)
18 * Copyright (C) 2006, 2007 Chris Pascoe (c.pascoe@itee.uq.edu.au) 18 * Copyright (C) 2006, 2007 Chris Pascoe (c.pascoe@itee.uq.edu.au)
19 * 19 *
@@ -2314,7 +2314,7 @@ static struct usb_driver cxusb_driver = {
2314 2314
2315module_usb_driver(cxusb_driver); 2315module_usb_driver(cxusb_driver);
2316 2316
2317MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 2317MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
2318MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>"); 2318MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
2319MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>"); 2319MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
2320MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design"); 2320MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c b/drivers/media/usb/dvb-usb/dib0700_core.c
index 0d248ce02a9b..c16f999b9d7c 100644
--- a/drivers/media/usb/dvb-usb/dib0700_core.c
+++ b/drivers/media/usb/dvb-usb/dib0700_core.c
@@ -881,7 +881,7 @@ static struct usb_driver dib0700_driver = {
881module_usb_driver(dib0700_driver); 881module_usb_driver(dib0700_driver);
882 882
883MODULE_FIRMWARE("dvb-usb-dib0700-1.20.fw"); 883MODULE_FIRMWARE("dvb-usb-dib0700-1.20.fw");
884MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>"); 884MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
885MODULE_DESCRIPTION("Driver for devices based on DiBcom DiB0700 - USB bridge"); 885MODULE_DESCRIPTION("Driver for devices based on DiBcom DiB0700 - USB bridge");
886MODULE_VERSION("1.0"); 886MODULE_VERSION("1.0");
887MODULE_LICENSE("GPL"); 887MODULE_LICENSE("GPL");
diff --git a/drivers/media/usb/dvb-usb/dib0700_devices.c b/drivers/media/usb/dvb-usb/dib0700_devices.c
index 7ed49646a699..ea0391e32d23 100644
--- a/drivers/media/usb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/usb/dvb-usb/dib0700_devices.c
@@ -1736,8 +1736,13 @@ static int dib809x_tuner_attach(struct dvb_usb_adapter *adap)
1736 struct dib0700_adapter_state *st = adap->priv; 1736 struct dib0700_adapter_state *st = adap->priv;
1737 struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1); 1737 struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
1738 1738
1739 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL) 1739 if (adap->id == 0) {
1740 return -ENODEV; 1740 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
1741 return -ENODEV;
1742 } else {
1743 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
1744 return -ENODEV;
1745 }
1741 1746
1742 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params; 1747 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1743 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override; 1748 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
@@ -1773,6 +1778,20 @@ static int stk809x_frontend_attach(struct dvb_usb_adapter *adap)
1773 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 1778 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
1774} 1779}
1775 1780
1781static int stk809x_frontend1_attach(struct dvb_usb_adapter *adap)
1782{
1783 struct dib0700_adapter_state *state = adap->priv;
1784
1785 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1786 return -ENODEV;
1787
1788 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x82, 0);
1789
1790 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x82, &dib809x_dib8000_config[1]);
1791
1792 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
1793}
1794
1776static int nim8096md_tuner_attach(struct dvb_usb_adapter *adap) 1795static int nim8096md_tuner_attach(struct dvb_usb_adapter *adap)
1777{ 1796{
1778 struct dib0700_adapter_state *st = adap->priv; 1797 struct dib0700_adapter_state *st = adap->priv;
@@ -3794,6 +3813,7 @@ struct usb_device_id dib0700_usb_id_table[] = {
3794/* 80 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_2) }, 3813/* 80 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_2) },
3795 { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E) }, 3814 { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E) },
3796 { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E_SE) }, 3815 { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E_SE) },
3816 { USB_DEVICE(USB_VID_PCTV, USB_PID_DIBCOM_STK8096PVR) },
3797 { 0 } /* Terminating entry */ 3817 { 0 } /* Terminating entry */
3798}; 3818};
3799MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); 3819MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
@@ -4959,6 +4979,59 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4959 RC_BIT_NEC, 4979 RC_BIT_NEC,
4960 .change_protocol = dib0700_change_protocol, 4980 .change_protocol = dib0700_change_protocol,
4961 }, 4981 },
4982 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4983 .num_adapters = 2,
4984 .adapter = {
4985 {
4986 .num_frontends = 1,
4987 .fe = {{
4988 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4989 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4990 .pid_filter_count = 32,
4991 .pid_filter = stk80xx_pid_filter,
4992 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4993 .frontend_attach = stk809x_frontend_attach,
4994 .tuner_attach = dib809x_tuner_attach,
4995
4996 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4997 } },
4998 .size_of_priv =
4999 sizeof(struct dib0700_adapter_state),
5000 }, {
5001 .num_frontends = 1,
5002 .fe = { {
5003 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
5004 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
5005 .pid_filter_count = 32,
5006 .pid_filter = stk80xx_pid_filter,
5007 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
5008 .frontend_attach = stk809x_frontend1_attach,
5009 .tuner_attach = dib809x_tuner_attach,
5010
5011 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
5012 } },
5013 .size_of_priv =
5014 sizeof(struct dib0700_adapter_state),
5015 },
5016 },
5017 .num_device_descs = 1,
5018 .devices = {
5019 { "DiBcom STK8096-PVR reference design",
5020 { &dib0700_usb_id_table[83], NULL },
5021 { NULL },
5022 },
5023 },
5024
5025 .rc.core = {
5026 .rc_interval = DEFAULT_RC_INTERVAL,
5027 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
5028 .module_name = "dib0700",
5029 .rc_query = dib0700_rc_query_old_firmware,
5030 .allowed_protos = RC_BIT_RC5 |
5031 RC_BIT_RC6_MCE |
5032 RC_BIT_NEC,
5033 .change_protocol = dib0700_change_protocol,
5034 },
4962 }, 5035 },
4963}; 5036};
4964 5037
diff --git a/drivers/media/usb/dvb-usb/dibusb-common.c b/drivers/media/usb/dvb-usb/dibusb-common.c
index ef3a8f75f82e..35de6095926d 100644
--- a/drivers/media/usb/dvb-usb/dibusb-common.c
+++ b/drivers/media/usb/dvb-usb/dibusb-common.c
@@ -1,6 +1,6 @@
1/* Common methods for dibusb-based-receivers. 1/* Common methods for dibusb-based-receivers.
2 * 2 *
3 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 3 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free 6 * under the terms of the GNU General Public License as published by the Free
diff --git a/drivers/media/usb/dvb-usb/dibusb-mb.c b/drivers/media/usb/dvb-usb/dibusb-mb.c
index a4ac37e0e98b..a0057641cc86 100644
--- a/drivers/media/usb/dvb-usb/dibusb-mb.c
+++ b/drivers/media/usb/dvb-usb/dibusb-mb.c
@@ -1,10 +1,10 @@
1/* DVB USB compliant linux driver for mobile DVB-T USB devices based on 1/* DVB USB compliant linux driver for mobile DVB-T USB devices based on
2 * reference designs made by DiBcom (http://www.dibcom.fr/) (DiB3000M-B) 2 * reference designs made by DiBcom (http://www.dibcom.fr/) (DiB3000M-B)
3 * 3 *
4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
5 * 5 *
6 * based on GPL code from DiBcom, which has 6 * based on GPL code from DiBcom, which has
7 * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr) 7 * Copyright (C) 2004 Amaury Demol for DiBcom
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify it 9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free 10 * under the terms of the GNU General Public License as published by the Free
@@ -465,7 +465,7 @@ static struct usb_driver dibusb_driver = {
465 465
466module_usb_driver(dibusb_driver); 466module_usb_driver(dibusb_driver);
467 467
468MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 468MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
469MODULE_DESCRIPTION("Driver for DiBcom USB DVB-T devices (DiB3000M-B based)"); 469MODULE_DESCRIPTION("Driver for DiBcom USB DVB-T devices (DiB3000M-B based)");
470MODULE_VERSION("1.0"); 470MODULE_VERSION("1.0");
471MODULE_LICENSE("GPL"); 471MODULE_LICENSE("GPL");
diff --git a/drivers/media/usb/dvb-usb/dibusb-mc.c b/drivers/media/usb/dvb-usb/dibusb-mc.c
index 9d1a59d09c52..08fb8a3f6e0c 100644
--- a/drivers/media/usb/dvb-usb/dibusb-mc.c
+++ b/drivers/media/usb/dvb-usb/dibusb-mc.c
@@ -1,10 +1,10 @@
1/* DVB USB compliant linux driver for mobile DVB-T USB devices based on 1/* DVB USB compliant linux driver for mobile DVB-T USB devices based on
2 * reference designs made by DiBcom (http://www.dibcom.fr/) (DiB3000M-C/P) 2 * reference designs made by DiBcom (http://www.dibcom.fr/) (DiB3000M-C/P)
3 * 3 *
4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
5 * 5 *
6 * based on GPL code from DiBcom, which has 6 * based on GPL code from DiBcom, which has
7 * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr) 7 * Copyright (C) 2004 Amaury Demol for DiBcom
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify it 9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free 10 * under the terms of the GNU General Public License as published by the Free
@@ -143,7 +143,7 @@ static struct usb_driver dibusb_mc_driver = {
143 143
144module_usb_driver(dibusb_mc_driver); 144module_usb_driver(dibusb_mc_driver);
145 145
146MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 146MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
147MODULE_DESCRIPTION("Driver for DiBcom USB2.0 DVB-T (DiB3000M-C/P based) devices"); 147MODULE_DESCRIPTION("Driver for DiBcom USB2.0 DVB-T (DiB3000M-C/P based) devices");
148MODULE_VERSION("1.0"); 148MODULE_VERSION("1.0");
149MODULE_LICENSE("GPL"); 149MODULE_LICENSE("GPL");
diff --git a/drivers/media/usb/dvb-usb/dibusb.h b/drivers/media/usb/dvb-usb/dibusb.h
index 32ab1392313f..3f82163d8ab8 100644
--- a/drivers/media/usb/dvb-usb/dibusb.h
+++ b/drivers/media/usb/dvb-usb/dibusb.h
@@ -1,6 +1,6 @@
1/* Header file for all dibusb-based-receivers. 1/* Header file for all dibusb-based-receivers.
2 * 2 *
3 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 3 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free 6 * under the terms of the GNU General Public License as published by the Free
diff --git a/drivers/media/usb/dvb-usb/digitv.c b/drivers/media/usb/dvb-usb/digitv.c
index 772bde3c5020..63134335c994 100644
--- a/drivers/media/usb/dvb-usb/digitv.c
+++ b/drivers/media/usb/dvb-usb/digitv.c
@@ -1,7 +1,7 @@
1/* DVB USB compliant linux driver for Nebula Electronics uDigiTV DVB-T USB2.0 1/* DVB USB compliant linux driver for Nebula Electronics uDigiTV DVB-T USB2.0
2 * receiver 2 * receiver
3 * 3 *
4 * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@desy.de) 4 * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@posteo.de)
5 * 5 *
6 * partly based on the SDK published by Nebula Electronics 6 * partly based on the SDK published by Nebula Electronics
7 * 7 *
@@ -348,7 +348,7 @@ static struct usb_driver digitv_driver = {
348 348
349module_usb_driver(digitv_driver); 349module_usb_driver(digitv_driver);
350 350
351MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 351MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
352MODULE_DESCRIPTION("Driver for Nebula Electronics uDigiTV DVB-T USB2.0"); 352MODULE_DESCRIPTION("Driver for Nebula Electronics uDigiTV DVB-T USB2.0");
353MODULE_VERSION("1.0-alpha"); 353MODULE_VERSION("1.0-alpha");
354MODULE_LICENSE("GPL"); 354MODULE_LICENSE("GPL");
diff --git a/drivers/media/usb/dvb-usb/dtt200u-fe.c b/drivers/media/usb/dvb-usb/dtt200u-fe.c
index 8637ad1be6be..c09332bd99cb 100644
--- a/drivers/media/usb/dvb-usb/dtt200u-fe.c
+++ b/drivers/media/usb/dvb-usb/dtt200u-fe.c
@@ -1,7 +1,7 @@
1/* Frontend part of the Linux driver for the WideView/ Yakumo/ Hama/ 1/* Frontend part of the Linux driver for the WideView/ Yakumo/ Hama/
2 * Typhoon/ Yuan DVB-T USB2.0 receiver. 2 * Typhoon/ Yuan DVB-T USB2.0 receiver.
3 * 3 *
4 * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@desy.de> 4 * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@posteo.de>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free 7 * under the terms of the GNU General Public License as published by the Free
@@ -140,10 +140,11 @@ static int dtt200u_fe_set_frontend(struct dvb_frontend *fe)
140 return 0; 140 return 0;
141} 141}
142 142
143static int dtt200u_fe_get_frontend(struct dvb_frontend* fe) 143static int dtt200u_fe_get_frontend(struct dvb_frontend* fe,
144 struct dtv_frontend_properties *fep)
144{ 145{
145 struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
146 struct dtt200u_fe_state *state = fe->demodulator_priv; 146 struct dtt200u_fe_state *state = fe->demodulator_priv;
147
147 memcpy(fep, &state->fep, sizeof(struct dtv_frontend_properties)); 148 memcpy(fep, &state->fep, sizeof(struct dtv_frontend_properties));
148 return 0; 149 return 0;
149} 150}
diff --git a/drivers/media/usb/dvb-usb/dtt200u.c b/drivers/media/usb/dvb-usb/dtt200u.c
index c357fb3b0a88..ca3b69aa9688 100644
--- a/drivers/media/usb/dvb-usb/dtt200u.c
+++ b/drivers/media/usb/dvb-usb/dtt200u.c
@@ -1,7 +1,7 @@
1/* DVB USB library compliant Linux driver for the WideView/ Yakumo/ Hama/ 1/* DVB USB library compliant Linux driver for the WideView/ Yakumo/ Hama/
2 * Typhoon/ Yuan/ Miglia DVB-T USB2.0 receiver. 2 * Typhoon/ Yuan/ Miglia DVB-T USB2.0 receiver.
3 * 3 *
4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
5 * 5 *
6 * Thanks to Steve Chang from WideView for providing support for the WT-220U. 6 * Thanks to Steve Chang from WideView for providing support for the WT-220U.
7 * 7 *
@@ -362,7 +362,7 @@ static struct usb_driver dtt200u_usb_driver = {
362 362
363module_usb_driver(dtt200u_usb_driver); 363module_usb_driver(dtt200u_usb_driver);
364 364
365MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 365MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
366MODULE_DESCRIPTION("Driver for the WideView/Yakumo/Hama/Typhoon/Club3D/Miglia DVB-T USB2.0 devices"); 366MODULE_DESCRIPTION("Driver for the WideView/Yakumo/Hama/Typhoon/Club3D/Miglia DVB-T USB2.0 devices");
367MODULE_VERSION("1.0"); 367MODULE_VERSION("1.0");
368MODULE_LICENSE("GPL"); 368MODULE_LICENSE("GPL");
diff --git a/drivers/media/usb/dvb-usb/dtt200u.h b/drivers/media/usb/dvb-usb/dtt200u.h
index 005b0a7df358..efccc399b1cb 100644
--- a/drivers/media/usb/dvb-usb/dtt200u.h
+++ b/drivers/media/usb/dvb-usb/dtt200u.h
@@ -1,7 +1,7 @@
1/* Common header file of Linux driver for the WideView/ Yakumo/ Hama/ 1/* Common header file of Linux driver for the WideView/ Yakumo/ Hama/
2 * Typhoon/ Yuan DVB-T USB2.0 receiver. 2 * Typhoon/ Yuan DVB-T USB2.0 receiver.
3 * 3 *
4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free 7 * under the terms of the GNU General Public License as published by the Free
diff --git a/drivers/media/usb/dvb-usb/dvb-usb-common.h b/drivers/media/usb/dvb-usb/dvb-usb-common.h
index 6b7b2a89242e..7e619d638809 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb-common.h
+++ b/drivers/media/usb/dvb-usb/dvb-usb-common.h
@@ -1,6 +1,6 @@
1/* dvb-usb-common.h is part of the DVB USB library. 1/* dvb-usb-common.h is part of the DVB USB library.
2 * 2 *
3 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 3 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
4 * see dvb-usb-init.c for copyright information. 4 * see dvb-usb-init.c for copyright information.
5 * 5 *
6 * a header file containing prototypes and types for internal use of the dvb-usb-lib 6 * a header file containing prototypes and types for internal use of the dvb-usb-lib
diff --git a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
index 9ddfcab268be..6477b04e95c7 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
+++ b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
@@ -1,12 +1,13 @@
1/* dvb-usb-dvb.c is part of the DVB USB library. 1/* dvb-usb-dvb.c is part of the DVB USB library.
2 * 2 *
3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) 3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
4 * see dvb-usb-init.c for copyright information. 4 * see dvb-usb-init.c for copyright information.
5 * 5 *
6 * This file contains functions for initializing and handling the 6 * This file contains functions for initializing and handling the
7 * linux-dvb API. 7 * linux-dvb API.
8 */ 8 */
9#include "dvb-usb-common.h" 9#include "dvb-usb-common.h"
10#include <media/media-device.h>
10 11
11/* does the complete input transfer handling */ 12/* does the complete input transfer handling */
12static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) 13static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
@@ -106,15 +107,7 @@ static int dvb_usb_media_device_init(struct dvb_usb_adapter *adap)
106 if (!mdev) 107 if (!mdev)
107 return -ENOMEM; 108 return -ENOMEM;
108 109
109 mdev->dev = &udev->dev; 110 media_device_usb_init(mdev, udev, d->desc->name);
110 strlcpy(mdev->model, d->desc->name, sizeof(mdev->model));
111 if (udev->serial)
112 strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial));
113 strcpy(mdev->bus_info, udev->devpath);
114 mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
115 mdev->driver_version = LINUX_VERSION_CODE;
116
117 media_device_init(mdev);
118 111
119 dvb_register_media_controller(&adap->dvb_adap, mdev); 112 dvb_register_media_controller(&adap->dvb_adap, mdev);
120 113
diff --git a/drivers/media/usb/dvb-usb/dvb-usb-firmware.c b/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
index 733a7ff7b207..dd048a7c461c 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
+++ b/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
@@ -1,6 +1,6 @@
1/* dvb-usb-firmware.c is part of the DVB USB library. 1/* dvb-usb-firmware.c is part of the DVB USB library.
2 * 2 *
3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) 3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
4 * see dvb-usb-init.c for copyright information. 4 * see dvb-usb-init.c for copyright information.
5 * 5 *
6 * This file contains functions for downloading the firmware to Cypress FX 1 and 2 based devices. 6 * This file contains functions for downloading the firmware to Cypress FX 1 and 2 based devices.
diff --git a/drivers/media/usb/dvb-usb/dvb-usb-i2c.c b/drivers/media/usb/dvb-usb/dvb-usb-i2c.c
index 88e4a62abc44..4f0b0adce7f5 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb-i2c.c
+++ b/drivers/media/usb/dvb-usb/dvb-usb-i2c.c
@@ -1,6 +1,6 @@
1/* dvb-usb-i2c.c is part of the DVB USB library. 1/* dvb-usb-i2c.c is part of the DVB USB library.
2 * 2 *
3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) 3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
4 * see dvb-usb-init.c for copyright information. 4 * see dvb-usb-init.c for copyright information.
5 * 5 *
6 * This file contains functions for (de-)initializing an I2C adapter. 6 * This file contains functions for (de-)initializing an I2C adapter.
diff --git a/drivers/media/usb/dvb-usb/dvb-usb-init.c b/drivers/media/usb/dvb-usb/dvb-usb-init.c
index 1adf325012f7..3896ba9a4179 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb-init.c
+++ b/drivers/media/usb/dvb-usb/dvb-usb-init.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * dvb-usb-init.c 4 * dvb-usb-init.c
5 * 5 *
6 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) 6 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify it 8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free 9 * under the terms of the GNU General Public License as published by the Free
@@ -299,6 +299,6 @@ void dvb_usb_device_exit(struct usb_interface *intf)
299EXPORT_SYMBOL(dvb_usb_device_exit); 299EXPORT_SYMBOL(dvb_usb_device_exit);
300 300
301MODULE_VERSION("1.0"); 301MODULE_VERSION("1.0");
302MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 302MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
303MODULE_DESCRIPTION("A library module containing commonly used USB and DVB function USB DVB devices"); 303MODULE_DESCRIPTION("A library module containing commonly used USB and DVB function USB DVB devices");
304MODULE_LICENSE("GPL"); 304MODULE_LICENSE("GPL");
diff --git a/drivers/media/usb/dvb-usb/dvb-usb-remote.c b/drivers/media/usb/dvb-usb/dvb-usb-remote.c
index 7b5dae3077f6..c259f9e43542 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb-remote.c
+++ b/drivers/media/usb/dvb-usb/dvb-usb-remote.c
@@ -1,6 +1,6 @@
1/* dvb-usb-remote.c is part of the DVB USB library. 1/* dvb-usb-remote.c is part of the DVB USB library.
2 * 2 *
3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) 3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
4 * see dvb-usb-init.c for copyright information. 4 * see dvb-usb-init.c for copyright information.
5 * 5 *
6 * This file contains functions for initializing the input-device and for handling remote-control-queries. 6 * This file contains functions for initializing the input-device and for handling remote-control-queries.
diff --git a/drivers/media/usb/dvb-usb/dvb-usb-urb.c b/drivers/media/usb/dvb-usb/dvb-usb-urb.c
index 5c8f651344fc..95f9097498cb 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb-urb.c
+++ b/drivers/media/usb/dvb-usb/dvb-usb-urb.c
@@ -1,6 +1,6 @@
1/* dvb-usb-urb.c is part of the DVB USB library. 1/* dvb-usb-urb.c is part of the DVB USB library.
2 * 2 *
3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) 3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
4 * see dvb-usb-init.c for copyright information. 4 * see dvb-usb-init.c for copyright information.
5 * 5 *
6 * This file keeps functions for initializing and handling the 6 * This file keeps functions for initializing and handling the
diff --git a/drivers/media/usb/dvb-usb/dvb-usb.h b/drivers/media/usb/dvb-usb/dvb-usb.h
index ce4c4e3b58bb..639c4678c65b 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb.h
+++ b/drivers/media/usb/dvb-usb/dvb-usb.h
@@ -1,6 +1,6 @@
1/* dvb-usb.h is part of the DVB USB library. 1/* dvb-usb.h is part of the DVB USB library.
2 * 2 *
3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) 3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
4 * see dvb-usb-init.c for copyright information. 4 * see dvb-usb-init.c for copyright information.
5 * 5 *
6 * the headerfile, all dvb-usb-drivers have to include. 6 * the headerfile, all dvb-usb-drivers have to include.
diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
index 14ef25dc6cd3..6d0dd859d684 100644
--- a/drivers/media/usb/dvb-usb/dw2102.c
+++ b/drivers/media/usb/dvb-usb/dw2102.c
@@ -1,9 +1,10 @@
1/* DVB USB framework compliant Linux driver for the 1/* DVB USB framework compliant Linux driver for the
2 * DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101, 2 * DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101,
3 * TeVii S600, S630, S650, S660, S480, S421, S632 3 * TeVii S421, S480, S482, S600, S630, S632, S650, S660, S662,
4 * Prof 1100, 7500, 4 * Prof 1100, 7500,
5 * Geniatech SU3000, T220, 5 * Geniatech SU3000, T220,
6 * TechnoTrend S2-4600 Cards 6 * TechnoTrend S2-4600,
7 * Terratec Cinergy S2 cards
7 * Copyright (C) 2008-2012 Igor M. Liplianin (liplianin@me.by) 8 * Copyright (C) 2008-2012 Igor M. Liplianin (liplianin@me.by)
8 * 9 *
9 * This program is free software; you can redistribute it and/or modify it 10 * This program is free software; you can redistribute it and/or modify it
@@ -33,7 +34,6 @@
33#include "tda18271.h" 34#include "tda18271.h"
34#include "cxd2820r.h" 35#include "cxd2820r.h"
35#include "m88ds3103.h" 36#include "m88ds3103.h"
36#include "ts2020.h"
37 37
38/* Max transfer size done by I2C transfer functions */ 38/* Max transfer size done by I2C transfer functions */
39#define MAX_XFER_SIZE 64 39#define MAX_XFER_SIZE 64
@@ -66,6 +66,10 @@
66#define USB_PID_TEVII_S660 0xd660 66#define USB_PID_TEVII_S660 0xd660
67#endif 67#endif
68 68
69#ifndef USB_PID_TEVII_S662
70#define USB_PID_TEVII_S662 0xd662
71#endif
72
69#ifndef USB_PID_TEVII_S480_1 73#ifndef USB_PID_TEVII_S480_1
70#define USB_PID_TEVII_S480_1 0xd481 74#define USB_PID_TEVII_S480_1 0xd481
71#endif 75#endif
@@ -118,6 +122,7 @@
118struct dw2102_state { 122struct dw2102_state {
119 u8 initialized; 123 u8 initialized;
120 u8 last_lock; 124 u8 last_lock;
125 struct i2c_client *i2c_client_demod;
121 struct i2c_client *i2c_client_tuner; 126 struct i2c_client *i2c_client_tuner;
122 127
123 /* fe hook functions*/ 128 /* fe hook functions*/
@@ -1141,22 +1146,6 @@ static struct tda18271_config tda18271_config = {
1141 .gate = TDA18271_GATE_DIGITAL, 1146 .gate = TDA18271_GATE_DIGITAL,
1142}; 1147};
1143 1148
1144static const struct m88ds3103_config tt_s2_4600_m88ds3103_config = {
1145 .i2c_addr = 0x68,
1146 .clock = 27000000,
1147 .i2c_wr_max = 33,
1148 .ts_mode = M88DS3103_TS_CI,
1149 .ts_clk = 16000,
1150 .ts_clk_pol = 0,
1151 .spec_inv = 0,
1152 .agc_inv = 0,
1153 .clock_out = M88DS3103_CLOCK_OUT_ENABLED,
1154 .envelope_mode = 0,
1155 .agc = 0x99,
1156 .lnb_hv_pol = 1,
1157 .lnb_en_pol = 0,
1158};
1159
1160static u8 m88rs2000_inittab[] = { 1149static u8 m88rs2000_inittab[] = {
1161 DEMOD_WRITE, 0x9a, 0x30, 1150 DEMOD_WRITE, 0x9a, 0x30,
1162 DEMOD_WRITE, 0x00, 0x01, 1151 DEMOD_WRITE, 0x00, 0x01,
@@ -1509,7 +1498,8 @@ static int tt_s2_4600_frontend_attach(struct dvb_usb_adapter *adap)
1509 u8 ibuf[] = { 0 }; 1498 u8 ibuf[] = { 0 };
1510 struct i2c_adapter *i2c_adapter; 1499 struct i2c_adapter *i2c_adapter;
1511 struct i2c_client *client; 1500 struct i2c_client *client;
1512 struct i2c_board_info info; 1501 struct i2c_board_info board_info;
1502 struct m88ds3103_platform_data m88ds3103_pdata = {};
1513 struct ts2020_config ts2020_config = {}; 1503 struct ts2020_config ts2020_config = {};
1514 1504
1515 if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 1, 0) < 0) 1505 if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 1, 0) < 0)
@@ -1542,22 +1532,44 @@ static int tt_s2_4600_frontend_attach(struct dvb_usb_adapter *adap)
1542 if (dvb_usb_generic_rw(d, obuf, 1, ibuf, 1, 0) < 0) 1532 if (dvb_usb_generic_rw(d, obuf, 1, ibuf, 1, 0) < 0)
1543 err("command 0x51 transfer failed."); 1533 err("command 0x51 transfer failed.");
1544 1534
1545 memset(&info, 0, sizeof(struct i2c_board_info)); 1535 /* attach demod */
1546 1536 m88ds3103_pdata.clk = 27000000;
1547 adap->fe_adap[0].fe = dvb_attach(m88ds3103_attach, 1537 m88ds3103_pdata.i2c_wr_max = 33;
1548 &tt_s2_4600_m88ds3103_config, 1538 m88ds3103_pdata.ts_mode = M88DS3103_TS_CI;
1549 &d->i2c_adap, 1539 m88ds3103_pdata.ts_clk = 16000;
1550 &i2c_adapter); 1540 m88ds3103_pdata.ts_clk_pol = 0;
1551 if (adap->fe_adap[0].fe == NULL) 1541 m88ds3103_pdata.spec_inv = 0;
1542 m88ds3103_pdata.agc = 0x99;
1543 m88ds3103_pdata.agc_inv = 0;
1544 m88ds3103_pdata.clk_out = M88DS3103_CLOCK_OUT_ENABLED;
1545 m88ds3103_pdata.envelope_mode = 0;
1546 m88ds3103_pdata.lnb_hv_pol = 1;
1547 m88ds3103_pdata.lnb_en_pol = 0;
1548 memset(&board_info, 0, sizeof(board_info));
1549 strlcpy(board_info.type, "m88ds3103", I2C_NAME_SIZE);
1550 board_info.addr = 0x68;
1551 board_info.platform_data = &m88ds3103_pdata;
1552 request_module("m88ds3103");
1553 client = i2c_new_device(&d->i2c_adap, &board_info);
1554 if (client == NULL || client->dev.driver == NULL)
1552 return -ENODEV; 1555 return -ENODEV;
1556 if (!try_module_get(client->dev.driver->owner)) {
1557 i2c_unregister_device(client);
1558 return -ENODEV;
1559 }
1560 adap->fe_adap[0].fe = m88ds3103_pdata.get_dvb_frontend(client);
1561 i2c_adapter = m88ds3103_pdata.get_i2c_adapter(client);
1562
1563 state->i2c_client_demod = client;
1553 1564
1554 /* attach tuner */ 1565 /* attach tuner */
1555 ts2020_config.fe = adap->fe_adap[0].fe; 1566 ts2020_config.fe = adap->fe_adap[0].fe;
1556 strlcpy(info.type, "ts2022", I2C_NAME_SIZE); 1567 memset(&board_info, 0, sizeof(board_info));
1557 info.addr = 0x60; 1568 strlcpy(board_info.type, "ts2022", I2C_NAME_SIZE);
1558 info.platform_data = &ts2020_config; 1569 board_info.addr = 0x60;
1570 board_info.platform_data = &ts2020_config;
1559 request_module("ts2020"); 1571 request_module("ts2020");
1560 client = i2c_new_device(i2c_adapter, &info); 1572 client = i2c_new_device(i2c_adapter, &board_info);
1561 1573
1562 if (client == NULL || client->dev.driver == NULL) { 1574 if (client == NULL || client->dev.driver == NULL) {
1563 dvb_frontend_detach(adap->fe_adap[0].fe); 1575 dvb_frontend_detach(adap->fe_adap[0].fe);
@@ -1688,6 +1700,8 @@ enum dw2102_table_entry {
1688 TECHNOTREND_S2_4600, 1700 TECHNOTREND_S2_4600,
1689 TEVII_S482_1, 1701 TEVII_S482_1,
1690 TEVII_S482_2, 1702 TEVII_S482_2,
1703 TERRATEC_CINERGY_S2_BOX,
1704 TEVII_S662
1691}; 1705};
1692 1706
1693static struct usb_device_id dw2102_table[] = { 1707static struct usb_device_id dw2102_table[] = {
@@ -1702,19 +1716,21 @@ static struct usb_device_id dw2102_table[] = {
1702 [TEVII_S660] = {USB_DEVICE(0x9022, USB_PID_TEVII_S660)}, 1716 [TEVII_S660] = {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
1703 [PROF_7500] = {USB_DEVICE(0x3034, 0x7500)}, 1717 [PROF_7500] = {USB_DEVICE(0x3034, 0x7500)},
1704 [GENIATECH_SU3000] = {USB_DEVICE(0x1f4d, 0x3000)}, 1718 [GENIATECH_SU3000] = {USB_DEVICE(0x1f4d, 0x3000)},
1705 [TERRATEC_CINERGY_S2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00a8)}, 1719 [TERRATEC_CINERGY_S2] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R1)},
1706 [TEVII_S480_1] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)}, 1720 [TEVII_S480_1] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)},
1707 [TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)}, 1721 [TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)},
1708 [X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)}, 1722 [X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)},
1709 [TEVII_S421] = {USB_DEVICE(0x9022, USB_PID_TEVII_S421)}, 1723 [TEVII_S421] = {USB_DEVICE(0x9022, USB_PID_TEVII_S421)},
1710 [TEVII_S632] = {USB_DEVICE(0x9022, USB_PID_TEVII_S632)}, 1724 [TEVII_S632] = {USB_DEVICE(0x9022, USB_PID_TEVII_S632)},
1711 [TERRATEC_CINERGY_S2_R2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00b0)}, 1725 [TERRATEC_CINERGY_S2_R2] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R2)},
1712 [GOTVIEW_SAT_HD] = {USB_DEVICE(0x1FE1, USB_PID_GOTVIEW_SAT_HD)}, 1726 [GOTVIEW_SAT_HD] = {USB_DEVICE(0x1FE1, USB_PID_GOTVIEW_SAT_HD)},
1713 [GENIATECH_T220] = {USB_DEVICE(0x1f4d, 0xD220)}, 1727 [GENIATECH_T220] = {USB_DEVICE(0x1f4d, 0xD220)},
1714 [TECHNOTREND_S2_4600] = {USB_DEVICE(USB_VID_TECHNOTREND, 1728 [TECHNOTREND_S2_4600] = {USB_DEVICE(USB_VID_TECHNOTREND,
1715 USB_PID_TECHNOTREND_CONNECT_S2_4600)}, 1729 USB_PID_TECHNOTREND_CONNECT_S2_4600)},
1716 [TEVII_S482_1] = {USB_DEVICE(0x9022, 0xd483)}, 1730 [TEVII_S482_1] = {USB_DEVICE(0x9022, 0xd483)},
1717 [TEVII_S482_2] = {USB_DEVICE(0x9022, 0xd484)}, 1731 [TEVII_S482_2] = {USB_DEVICE(0x9022, 0xd484)},
1732 [TERRATEC_CINERGY_S2_BOX] = {USB_DEVICE(USB_VID_TERRATEC, 0x0105)},
1733 [TEVII_S662] = {USB_DEVICE(0x9022, USB_PID_TEVII_S662)},
1718 { } 1734 { }
1719}; 1735};
1720 1736
@@ -2232,7 +2248,7 @@ static struct dvb_usb_device_properties tt_s2_4600_properties = {
2232 } }, 2248 } },
2233 } 2249 }
2234 }, 2250 },
2235 .num_device_descs = 3, 2251 .num_device_descs = 5,
2236 .devices = { 2252 .devices = {
2237 { "TechnoTrend TT-connect S2-4600", 2253 { "TechnoTrend TT-connect S2-4600",
2238 { &dw2102_table[TECHNOTREND_S2_4600], NULL }, 2254 { &dw2102_table[TECHNOTREND_S2_4600], NULL },
@@ -2246,6 +2262,14 @@ static struct dvb_usb_device_properties tt_s2_4600_properties = {
2246 { &dw2102_table[TEVII_S482_2], NULL }, 2262 { &dw2102_table[TEVII_S482_2], NULL },
2247 { NULL }, 2263 { NULL },
2248 }, 2264 },
2265 { "Terratec Cinergy S2 USB BOX",
2266 { &dw2102_table[TERRATEC_CINERGY_S2_BOX], NULL },
2267 { NULL },
2268 },
2269 { "TeVii S662",
2270 { &dw2102_table[TEVII_S662], NULL },
2271 { NULL },
2272 },
2249 } 2273 }
2250}; 2274};
2251 2275
@@ -2344,6 +2368,13 @@ static void dw2102_disconnect(struct usb_interface *intf)
2344 i2c_unregister_device(client); 2368 i2c_unregister_device(client);
2345 } 2369 }
2346 2370
2371 /* remove I2C client for demodulator */
2372 client = st->i2c_client_demod;
2373 if (client) {
2374 module_put(client->dev.driver->owner);
2375 i2c_unregister_device(client);
2376 }
2377
2347 dvb_usb_device_exit(intf); 2378 dvb_usb_device_exit(intf);
2348} 2379}
2349 2380
@@ -2359,10 +2390,10 @@ module_usb_driver(dw2102_driver);
2359MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by"); 2390MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
2360MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104," 2391MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
2361 " DVB-C 3101 USB2.0," 2392 " DVB-C 3101 USB2.0,"
2362 " TeVii S600, S630, S650, S660, S480, S421, S632" 2393 " TeVii S421, S480, S482, S600, S630, S632, S650,"
2363 " Prof 1100, 7500 USB2.0," 2394 " TeVii S660, S662, Prof 1100, 7500 USB2.0,"
2364 " Geniatech SU3000, T220," 2395 " Geniatech SU3000, T220,"
2365 " TechnoTrend S2-4600 devices"); 2396 " TechnoTrend S2-4600, Terratec Cinergy S2 devices");
2366MODULE_VERSION("0.1"); 2397MODULE_VERSION("0.1");
2367MODULE_LICENSE("GPL"); 2398MODULE_LICENSE("GPL");
2368MODULE_FIRMWARE(DW2101_FIRMWARE); 2399MODULE_FIRMWARE(DW2101_FIRMWARE);
diff --git a/drivers/media/usb/dvb-usb/friio-fe.c b/drivers/media/usb/dvb-usb/friio-fe.c
index 8ec92fbeabad..979f05b4b87c 100644
--- a/drivers/media/usb/dvb-usb/friio-fe.c
+++ b/drivers/media/usb/dvb-usb/friio-fe.c
@@ -283,20 +283,6 @@ static int jdvbt90502_set_property(struct dvb_frontend *fe,
283 return r; 283 return r;
284} 284}
285 285
286static int jdvbt90502_get_frontend(struct dvb_frontend *fe)
287{
288 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
289 p->inversion = INVERSION_AUTO;
290 p->bandwidth_hz = 6000000;
291 p->code_rate_HP = FEC_AUTO;
292 p->code_rate_LP = FEC_AUTO;
293 p->modulation = QAM_64;
294 p->transmission_mode = TRANSMISSION_MODE_AUTO;
295 p->guard_interval = GUARD_INTERVAL_AUTO;
296 p->hierarchy = HIERARCHY_AUTO;
297 return 0;
298}
299
300static int jdvbt90502_set_frontend(struct dvb_frontend *fe) 286static int jdvbt90502_set_frontend(struct dvb_frontend *fe)
301{ 287{
302 struct dtv_frontend_properties *p = &fe->dtv_property_cache; 288 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
@@ -312,8 +298,16 @@ static int jdvbt90502_set_frontend(struct dvb_frontend *fe)
312 298
313 deb_fe("%s: Freq:%d\n", __func__, p->frequency); 299 deb_fe("%s: Freq:%d\n", __func__, p->frequency);
314 300
315 /* for recovery from DTV_CLEAN */ 301 /* This driver only works on auto mode */
316 fe->dtv_property_cache.delivery_system = SYS_ISDBT; 302 p->inversion = INVERSION_AUTO;
303 p->bandwidth_hz = 6000000;
304 p->code_rate_HP = FEC_AUTO;
305 p->code_rate_LP = FEC_AUTO;
306 p->modulation = QAM_64;
307 p->transmission_mode = TRANSMISSION_MODE_AUTO;
308 p->guard_interval = GUARD_INTERVAL_AUTO;
309 p->hierarchy = HIERARCHY_AUTO;
310 p->delivery_system = SYS_ISDBT;
317 311
318 ret = jdvbt90502_pll_set_freq(state, p->frequency); 312 ret = jdvbt90502_pll_set_freq(state, p->frequency);
319 if (ret) { 313 if (ret) {
@@ -466,7 +460,6 @@ static struct dvb_frontend_ops jdvbt90502_ops = {
466 .set_property = jdvbt90502_set_property, 460 .set_property = jdvbt90502_set_property,
467 461
468 .set_frontend = jdvbt90502_set_frontend, 462 .set_frontend = jdvbt90502_set_frontend,
469 .get_frontend = jdvbt90502_get_frontend,
470 463
471 .read_status = jdvbt90502_read_status, 464 .read_status = jdvbt90502_read_status,
472 .read_signal_strength = jdvbt90502_read_signal_strength, 465 .read_signal_strength = jdvbt90502_read_signal_strength,
diff --git a/drivers/media/usb/dvb-usb/nova-t-usb2.c b/drivers/media/usb/dvb-usb/nova-t-usb2.c
index 6c55384e2fca..fc7569e2728d 100644
--- a/drivers/media/usb/dvb-usb/nova-t-usb2.c
+++ b/drivers/media/usb/dvb-usb/nova-t-usb2.c
@@ -1,7 +1,7 @@
1/* DVB USB framework compliant Linux driver for the Hauppauge WinTV-NOVA-T usb2 1/* DVB USB framework compliant Linux driver for the Hauppauge WinTV-NOVA-T usb2
2 * DVB-T receiver. 2 * DVB-T receiver.
3 * 3 *
4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free 7 * under the terms of the GNU General Public License as published by the Free
@@ -227,7 +227,7 @@ static struct usb_driver nova_t_driver = {
227 227
228module_usb_driver(nova_t_driver); 228module_usb_driver(nova_t_driver);
229 229
230MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 230MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
231MODULE_DESCRIPTION("Hauppauge WinTV-NOVA-T usb2"); 231MODULE_DESCRIPTION("Hauppauge WinTV-NOVA-T usb2");
232MODULE_VERSION("1.0"); 232MODULE_VERSION("1.0");
233MODULE_LICENSE("GPL"); 233MODULE_LICENSE("GPL");
diff --git a/drivers/media/usb/dvb-usb/technisat-usb2.c b/drivers/media/usb/dvb-usb/technisat-usb2.c
index 6c3c47722955..d9f3262bf071 100644
--- a/drivers/media/usb/dvb-usb/technisat-usb2.c
+++ b/drivers/media/usb/dvb-usb/technisat-usb2.c
@@ -60,6 +60,8 @@ struct technisat_usb2_state {
60 u8 power_state; 60 u8 power_state;
61 61
62 u16 last_scan_code; 62 u16 last_scan_code;
63
64 u8 buf[64];
63}; 65};
64 66
65/* debug print helpers */ 67/* debug print helpers */
@@ -220,19 +222,19 @@ enum technisat_usb2_led_state {
220 TECH_LED_UNDEFINED 222 TECH_LED_UNDEFINED
221}; 223};
222 224
223static int technisat_usb2_set_led(struct dvb_usb_device *d, int red, enum technisat_usb2_led_state state) 225static int technisat_usb2_set_led(struct dvb_usb_device *d, int red,
226 enum technisat_usb2_led_state st)
224{ 227{
228 struct technisat_usb2_state *state = d->priv;
229 u8 *led = state->buf;
225 int ret; 230 int ret;
226 231
227 u8 led[8] = { 232 led[0] = red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST;
228 red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST,
229 0
230 };
231 233
232 if (disable_led_control && state != TECH_LED_OFF) 234 if (disable_led_control && st != TECH_LED_OFF)
233 return 0; 235 return 0;
234 236
235 switch (state) { 237 switch (st) {
236 case TECH_LED_ON: 238 case TECH_LED_ON:
237 led[1] = 0x82; 239 led[1] = 0x82;
238 break; 240 break;
@@ -263,7 +265,7 @@ static int technisat_usb2_set_led(struct dvb_usb_device *d, int red, enum techni
263 red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST, 265 red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST,
264 USB_TYPE_VENDOR | USB_DIR_OUT, 266 USB_TYPE_VENDOR | USB_DIR_OUT,
265 0, 0, 267 0, 0,
266 led, sizeof(led), 500); 268 led, 8, 500);
267 269
268 mutex_unlock(&d->i2c_mutex); 270 mutex_unlock(&d->i2c_mutex);
269 return ret; 271 return ret;
@@ -271,8 +273,11 @@ static int technisat_usb2_set_led(struct dvb_usb_device *d, int red, enum techni
271 273
272static int technisat_usb2_set_led_timer(struct dvb_usb_device *d, u8 red, u8 green) 274static int technisat_usb2_set_led_timer(struct dvb_usb_device *d, u8 red, u8 green)
273{ 275{
276 struct technisat_usb2_state *state = d->priv;
277 u8 *b = state->buf;
274 int ret; 278 int ret;
275 u8 b = 0; 279
280 b[0] = 0;
276 281
277 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 282 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
278 return -EAGAIN; 283 return -EAGAIN;
@@ -281,7 +286,7 @@ static int technisat_usb2_set_led_timer(struct dvb_usb_device *d, u8 red, u8 gre
281 SET_LED_TIMER_DIVIDER_VENDOR_REQUEST, 286 SET_LED_TIMER_DIVIDER_VENDOR_REQUEST,
282 USB_TYPE_VENDOR | USB_DIR_OUT, 287 USB_TYPE_VENDOR | USB_DIR_OUT,
283 (red << 8) | green, 0, 288 (red << 8) | green, 0,
284 &b, 1, 500); 289 b, 1, 500);
285 290
286 mutex_unlock(&d->i2c_mutex); 291 mutex_unlock(&d->i2c_mutex);
287 292
@@ -328,7 +333,11 @@ static int technisat_usb2_identify_state(struct usb_device *udev,
328 struct dvb_usb_device_description **desc, int *cold) 333 struct dvb_usb_device_description **desc, int *cold)
329{ 334{
330 int ret; 335 int ret;
331 u8 version[3]; 336 u8 *version;
337
338 version = kmalloc(3, GFP_KERNEL);
339 if (!version)
340 return -ENOMEM;
332 341
333 /* first select the interface */ 342 /* first select the interface */
334 if (usb_set_interface(udev, 0, 1) != 0) 343 if (usb_set_interface(udev, 0, 1) != 0)
@@ -342,7 +351,7 @@ static int technisat_usb2_identify_state(struct usb_device *udev,
342 GET_VERSION_INFO_VENDOR_REQUEST, 351 GET_VERSION_INFO_VENDOR_REQUEST,
343 USB_TYPE_VENDOR | USB_DIR_IN, 352 USB_TYPE_VENDOR | USB_DIR_IN,
344 0, 0, 353 0, 0,
345 version, sizeof(version), 500); 354 version, 3, 500);
346 355
347 if (ret < 0) 356 if (ret < 0)
348 *cold = 1; 357 *cold = 1;
@@ -351,6 +360,8 @@ static int technisat_usb2_identify_state(struct usb_device *udev,
351 *cold = 0; 360 *cold = 0;
352 } 361 }
353 362
363 kfree(version);
364
354 return 0; 365 return 0;
355} 366}
356 367
@@ -512,7 +523,7 @@ static int technisat_usb2_frontend_attach(struct dvb_usb_adapter *a)
512 &a->dev->i2c_adap, STV090x_DEMODULATOR_0); 523 &a->dev->i2c_adap, STV090x_DEMODULATOR_0);
513 524
514 if (a->fe_adap[0].fe) { 525 if (a->fe_adap[0].fe) {
515 struct stv6110x_devctl *ctl; 526 const struct stv6110x_devctl *ctl;
516 527
517 ctl = dvb_attach(stv6110x_attach, 528 ctl = dvb_attach(stv6110x_attach,
518 a->fe_adap[0].fe, 529 a->fe_adap[0].fe,
@@ -594,7 +605,9 @@ static int technisat_usb2_frontend_attach(struct dvb_usb_adapter *a)
594 605
595static int technisat_usb2_get_ir(struct dvb_usb_device *d) 606static int technisat_usb2_get_ir(struct dvb_usb_device *d)
596{ 607{
597 u8 buf[62], *b; 608 struct technisat_usb2_state *state = d->priv;
609 u8 *buf = state->buf;
610 u8 *b;
598 int ret; 611 int ret;
599 struct ir_raw_event ev; 612 struct ir_raw_event ev;
600 613
@@ -620,7 +633,7 @@ static int technisat_usb2_get_ir(struct dvb_usb_device *d)
620 GET_IR_DATA_VENDOR_REQUEST, 633 GET_IR_DATA_VENDOR_REQUEST,
621 USB_TYPE_VENDOR | USB_DIR_IN, 634 USB_TYPE_VENDOR | USB_DIR_IN,
622 0x8080, 0, 635 0x8080, 0,
623 buf, sizeof(buf), 500); 636 buf, 62, 500);
624 637
625unlock: 638unlock:
626 mutex_unlock(&d->i2c_mutex); 639 mutex_unlock(&d->i2c_mutex);
diff --git a/drivers/media/usb/dvb-usb/ttusb2.c b/drivers/media/usb/dvb-usb/ttusb2.c
index f10717311e05..ecc207fbaf3c 100644
--- a/drivers/media/usb/dvb-usb/ttusb2.c
+++ b/drivers/media/usb/dvb-usb/ttusb2.c
@@ -820,7 +820,7 @@ static struct usb_driver ttusb2_driver = {
820 820
821module_usb_driver(ttusb2_driver); 821module_usb_driver(ttusb2_driver);
822 822
823MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 823MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
824MODULE_DESCRIPTION("Driver for Pinnacle PCTV 400e DVB-S USB2.0"); 824MODULE_DESCRIPTION("Driver for Pinnacle PCTV 400e DVB-S USB2.0");
825MODULE_VERSION("1.0"); 825MODULE_VERSION("1.0");
826MODULE_LICENSE("GPL"); 826MODULE_LICENSE("GPL");
diff --git a/drivers/media/usb/dvb-usb/umt-010.c b/drivers/media/usb/dvb-usb/umt-010.c
index 9b042292e788..58ad5b4f856c 100644
--- a/drivers/media/usb/dvb-usb/umt-010.c
+++ b/drivers/media/usb/dvb-usb/umt-010.c
@@ -1,7 +1,7 @@
1/* DVB USB framework compliant Linux driver for the HanfTek UMT-010 USB2.0 1/* DVB USB framework compliant Linux driver for the HanfTek UMT-010 USB2.0
2 * DVB-T receiver. 2 * DVB-T receiver.
3 * 3 *
4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free 7 * under the terms of the GNU General Public License as published by the Free
@@ -145,7 +145,7 @@ static struct usb_driver umt_driver = {
145 145
146module_usb_driver(umt_driver); 146module_usb_driver(umt_driver);
147 147
148MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 148MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
149MODULE_DESCRIPTION("Driver for HanfTek UMT 010 USB2.0 DVB-T device"); 149MODULE_DESCRIPTION("Driver for HanfTek UMT 010 USB2.0 DVB-T device");
150MODULE_VERSION("1.0"); 150MODULE_VERSION("1.0");
151MODULE_LICENSE("GPL"); 151MODULE_LICENSE("GPL");
diff --git a/drivers/media/usb/dvb-usb/usb-urb.c b/drivers/media/usb/dvb-usb/usb-urb.c
index d62ee0f5a165..89173603be67 100644
--- a/drivers/media/usb/dvb-usb/usb-urb.c
+++ b/drivers/media/usb/dvb-usb/usb-urb.c
@@ -1,6 +1,6 @@
1/* usb-urb.c is part of the DVB USB library. 1/* usb-urb.c is part of the DVB USB library.
2 * 2 *
3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) 3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
4 * see dvb-usb-init.c for copyright information. 4 * see dvb-usb-init.c for copyright information.
5 * 5 *
6 * This file keeps functions for initializing and handling the 6 * This file keeps functions for initializing and handling the
diff --git a/drivers/media/usb/dvb-usb/vp702x-fe.c b/drivers/media/usb/dvb-usb/vp702x-fe.c
index d361a72ca0fa..27398c08c69d 100644
--- a/drivers/media/usb/dvb-usb/vp702x-fe.c
+++ b/drivers/media/usb/dvb-usb/vp702x-fe.c
@@ -4,7 +4,7 @@
4 * Copyright (C) 2005 Ralph Metzler <rjkm@metzlerbros.de> 4 * Copyright (C) 2005 Ralph Metzler <rjkm@metzlerbros.de>
5 * Metzler Brothers Systementwicklung GbR 5 * Metzler Brothers Systementwicklung GbR
6 * 6 *
7 * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@desy.de> 7 * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@posteo.de>
8 * 8 *
9 * Thanks to Twinhan who kindly provided hardware and information. 9 * Thanks to Twinhan who kindly provided hardware and information.
10 * 10 *
diff --git a/drivers/media/usb/dvb-usb/vp702x.c b/drivers/media/usb/dvb-usb/vp702x.c
index ee1e19e36445..40de33de90a7 100644
--- a/drivers/media/usb/dvb-usb/vp702x.c
+++ b/drivers/media/usb/dvb-usb/vp702x.c
@@ -4,7 +4,7 @@
4 * Copyright (C) 2005 Ralph Metzler <rjkm@metzlerbros.de> 4 * Copyright (C) 2005 Ralph Metzler <rjkm@metzlerbros.de>
5 * Metzler Brothers Systementwicklung GbR 5 * Metzler Brothers Systementwicklung GbR
6 * 6 *
7 * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@desy.de> 7 * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@posteo.de>
8 * 8 *
9 * Thanks to Twinhan who kindly provided hardware and information. 9 * Thanks to Twinhan who kindly provided hardware and information.
10 * 10 *
@@ -439,7 +439,7 @@ static struct usb_driver vp702x_usb_driver = {
439 439
440module_usb_driver(vp702x_usb_driver); 440module_usb_driver(vp702x_usb_driver);
441 441
442MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 442MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
443MODULE_DESCRIPTION("Driver for Twinhan StarBox DVB-S USB2.0 and clones"); 443MODULE_DESCRIPTION("Driver for Twinhan StarBox DVB-S USB2.0 and clones");
444MODULE_VERSION("1.0"); 444MODULE_VERSION("1.0");
445MODULE_LICENSE("GPL"); 445MODULE_LICENSE("GPL");
diff --git a/drivers/media/usb/dvb-usb/vp7045-fe.c b/drivers/media/usb/dvb-usb/vp7045-fe.c
index e708afc6a57f..7765602ea658 100644
--- a/drivers/media/usb/dvb-usb/vp7045-fe.c
+++ b/drivers/media/usb/dvb-usb/vp7045-fe.c
@@ -1,7 +1,7 @@
1/* DVB frontend part of the Linux driver for TwinhanDTV Alpha/MagicBoxII USB2.0 1/* DVB frontend part of the Linux driver for TwinhanDTV Alpha/MagicBoxII USB2.0
2 * DVB-T receiver. 2 * DVB-T receiver.
3 * 3 *
4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
5 * 5 *
6 * Thanks to Twinhan who kindly provided hardware and information. 6 * Thanks to Twinhan who kindly provided hardware and information.
7 * 7 *
diff --git a/drivers/media/usb/dvb-usb/vp7045.c b/drivers/media/usb/dvb-usb/vp7045.c
index d750724132ee..13340af0d39c 100644
--- a/drivers/media/usb/dvb-usb/vp7045.c
+++ b/drivers/media/usb/dvb-usb/vp7045.c
@@ -2,7 +2,7 @@
2 * - TwinhanDTV Alpha/MagicBoxII USB2.0 DVB-T receiver 2 * - TwinhanDTV Alpha/MagicBoxII USB2.0 DVB-T receiver
3 * - DigitalNow TinyUSB2 DVB-t receiver 3 * - DigitalNow TinyUSB2 DVB-t receiver
4 * 4 *
5 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 5 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
6 * 6 *
7 * Thanks to Twinhan who kindly provided hardware and information. 7 * Thanks to Twinhan who kindly provided hardware and information.
8 * 8 *
@@ -296,7 +296,7 @@ static struct usb_driver vp7045_usb_driver = {
296 296
297module_usb_driver(vp7045_usb_driver); 297module_usb_driver(vp7045_usb_driver);
298 298
299MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 299MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
300MODULE_DESCRIPTION("Driver for Twinhan MagicBox/Alpha and DNTV tinyUSB2 DVB-T USB2.0"); 300MODULE_DESCRIPTION("Driver for Twinhan MagicBox/Alpha and DNTV tinyUSB2 DVB-T USB2.0");
301MODULE_VERSION("1.0"); 301MODULE_VERSION("1.0");
302MODULE_LICENSE("GPL"); 302MODULE_LICENSE("GPL");
diff --git a/drivers/media/usb/dvb-usb/vp7045.h b/drivers/media/usb/dvb-usb/vp7045.h
index cf5ec46f8bb1..66499932ca76 100644
--- a/drivers/media/usb/dvb-usb/vp7045.h
+++ b/drivers/media/usb/dvb-usb/vp7045.h
@@ -1,7 +1,7 @@
1/* Common header-file of the Linux driver for the TwinhanDTV Alpha/MagicBoxII 1/* Common header-file of the Linux driver for the TwinhanDTV Alpha/MagicBoxII
2 * USB2.0 DVB-T receiver. 2 * USB2.0 DVB-T receiver.
3 * 3 *
4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
5 * 5 *
6 * Thanks to Twinhan who kindly provided hardware and information. 6 * Thanks to Twinhan who kindly provided hardware and information.
7 * 7 *
diff --git a/drivers/media/usb/em28xx/em28xx-camera.c b/drivers/media/usb/em28xx/em28xx-camera.c
index b58acd3fcd99..72f3f4d50253 100644
--- a/drivers/media/usb/em28xx/em28xx-camera.c
+++ b/drivers/media/usb/em28xx/em28xx-camera.c
@@ -64,6 +64,8 @@ static int em28xx_initialize_mt9m111(struct em28xx *dev)
64 i2c_master_send(&dev->i2c_client[dev->def_i2c_bus], 64 i2c_master_send(&dev->i2c_client[dev->def_i2c_bus],
65 &regs[i][0], 3); 65 &regs[i][0], 3);
66 66
67 /* FIXME: This won't be creating a sensor at the media graph */
68
67 return 0; 69 return 0;
68} 70}
69 71
@@ -91,6 +93,8 @@ static int em28xx_initialize_mt9m001(struct em28xx *dev)
91 i2c_master_send(&dev->i2c_client[dev->def_i2c_bus], 93 i2c_master_send(&dev->i2c_client[dev->def_i2c_bus],
92 &regs[i][0], 3); 94 &regs[i][0], 3);
93 95
96 /* FIXME: This won't be creating a sensor at the media graph */
97
94 return 0; 98 return 0;
95} 99}
96 100
diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c
index a1b6ef5894a6..930e3e3fc948 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -32,11 +32,12 @@
32#include <media/tuner.h> 32#include <media/tuner.h>
33#include <media/drv-intf/msp3400.h> 33#include <media/drv-intf/msp3400.h>
34#include <media/i2c/saa7115.h> 34#include <media/i2c/saa7115.h>
35#include <media/i2c/tvp5150.h> 35#include <dt-bindings/media/tvp5150.h>
36#include <media/i2c/tvaudio.h> 36#include <media/i2c/tvaudio.h>
37#include <media/i2c-addr.h> 37#include <media/i2c-addr.h>
38#include <media/tveeprom.h> 38#include <media/tveeprom.h>
39#include <media/v4l2-common.h> 39#include <media/v4l2-common.h>
40#include <sound/ac97_codec.h>
40 41
41#include "em28xx.h" 42#include "em28xx.h"
42 43
@@ -560,6 +561,16 @@ static struct em28xx_led pctv_80e_leds[] = {
560 {-1, 0, 0, 0}, 561 {-1, 0, 0, 0},
561}; 562};
562 563
564static struct em28xx_led terratec_grabby_leds[] = {
565 {
566 .role = EM28XX_LED_ANALOG_CAPTURING,
567 .gpio_reg = EM2820_R08_GPIO_CTRL,
568 .gpio_mask = EM_GPIO_3,
569 .inverted = 1,
570 },
571 {-1, 0, 0, 0},
572};
573
563/* 574/*
564 * Board definitions 575 * Board definitions
565 */ 576 */
@@ -570,7 +581,7 @@ struct em28xx_board em28xx_boards[] = {
570 .tuner_type = TUNER_ABSENT, 581 .tuner_type = TUNER_ABSENT,
571 .is_webcam = 1, 582 .is_webcam = 1,
572 .input = { { 583 .input = { {
573 .type = EM28XX_VMUX_COMPOSITE1, 584 .type = EM28XX_VMUX_COMPOSITE,
574 .vmux = 0, 585 .vmux = 0,
575 .amux = EM28XX_AMUX_VIDEO, 586 .amux = EM28XX_AMUX_VIDEO,
576 .gpio = silvercrest_reg_seq, 587 .gpio = silvercrest_reg_seq,
@@ -583,7 +594,7 @@ struct em28xx_board em28xx_boards[] = {
583 .decoder = EM28XX_SAA711X, 594 .decoder = EM28XX_SAA711X,
584 .tuner_type = TUNER_ABSENT, 595 .tuner_type = TUNER_ABSENT,
585 .input = { { 596 .input = { {
586 .type = EM28XX_VMUX_COMPOSITE1, 597 .type = EM28XX_VMUX_COMPOSITE,
587 .vmux = SAA7115_COMPOSITE0, 598 .vmux = SAA7115_COMPOSITE0,
588 .amux = EM28XX_AMUX_LINE_IN, 599 .amux = EM28XX_AMUX_LINE_IN,
589 }, { 600 }, {
@@ -605,7 +616,7 @@ struct em28xx_board em28xx_boards[] = {
605 .tuner_type = TUNER_ABSENT, 616 .tuner_type = TUNER_ABSENT,
606 .is_webcam = 1, 617 .is_webcam = 1,
607 .input = { { 618 .input = { {
608 .type = EM28XX_VMUX_COMPOSITE1, 619 .type = EM28XX_VMUX_COMPOSITE,
609 .vmux = 0, 620 .vmux = 0,
610 .amux = EM28XX_AMUX_VIDEO, 621 .amux = EM28XX_AMUX_VIDEO,
611 } }, 622 } },
@@ -616,7 +627,7 @@ struct em28xx_board em28xx_boards[] = {
616 .tda9887_conf = TDA9887_PRESENT, 627 .tda9887_conf = TDA9887_PRESENT,
617 .decoder = EM28XX_SAA711X, 628 .decoder = EM28XX_SAA711X,
618 .input = { { 629 .input = { {
619 .type = EM28XX_VMUX_COMPOSITE1, 630 .type = EM28XX_VMUX_COMPOSITE,
620 .vmux = SAA7115_COMPOSITE0, 631 .vmux = SAA7115_COMPOSITE0,
621 .amux = EM28XX_AMUX_LINE_IN, 632 .amux = EM28XX_AMUX_LINE_IN,
622 }, { 633 }, {
@@ -635,7 +646,7 @@ struct em28xx_board em28xx_boards[] = {
635 .vmux = SAA7115_COMPOSITE2, 646 .vmux = SAA7115_COMPOSITE2,
636 .amux = EM28XX_AMUX_LINE_IN, 647 .amux = EM28XX_AMUX_LINE_IN,
637 }, { 648 }, {
638 .type = EM28XX_VMUX_COMPOSITE1, 649 .type = EM28XX_VMUX_COMPOSITE,
639 .vmux = SAA7115_COMPOSITE0, 650 .vmux = SAA7115_COMPOSITE0,
640 .amux = EM28XX_AMUX_LINE_IN, 651 .amux = EM28XX_AMUX_LINE_IN,
641 }, { 652 }, {
@@ -655,7 +666,7 @@ struct em28xx_board em28xx_boards[] = {
655 .vmux = SAA7115_COMPOSITE2, 666 .vmux = SAA7115_COMPOSITE2,
656 .amux = EM28XX_AMUX_VIDEO, 667 .amux = EM28XX_AMUX_VIDEO,
657 }, { 668 }, {
658 .type = EM28XX_VMUX_COMPOSITE1, 669 .type = EM28XX_VMUX_COMPOSITE,
659 .vmux = SAA7115_COMPOSITE0, 670 .vmux = SAA7115_COMPOSITE0,
660 .amux = EM28XX_AMUX_LINE_IN, 671 .amux = EM28XX_AMUX_LINE_IN,
661 }, { 672 }, {
@@ -675,7 +686,7 @@ struct em28xx_board em28xx_boards[] = {
675 .vmux = SAA7115_COMPOSITE2, 686 .vmux = SAA7115_COMPOSITE2,
676 .amux = EM28XX_AMUX_VIDEO, 687 .amux = EM28XX_AMUX_VIDEO,
677 }, { 688 }, {
678 .type = EM28XX_VMUX_COMPOSITE1, 689 .type = EM28XX_VMUX_COMPOSITE,
679 .vmux = SAA7115_COMPOSITE0, 690 .vmux = SAA7115_COMPOSITE0,
680 .amux = EM28XX_AMUX_LINE_IN, 691 .amux = EM28XX_AMUX_LINE_IN,
681 }, { 692 }, {
@@ -715,7 +726,7 @@ struct em28xx_board em28xx_boards[] = {
715 .vmux = SAA7115_COMPOSITE2, 726 .vmux = SAA7115_COMPOSITE2,
716 .amux = EM28XX_AMUX_LINE_IN, 727 .amux = EM28XX_AMUX_LINE_IN,
717 }, { 728 }, {
718 .type = EM28XX_VMUX_COMPOSITE1, 729 .type = EM28XX_VMUX_COMPOSITE,
719 .vmux = SAA7115_COMPOSITE0, 730 .vmux = SAA7115_COMPOSITE0,
720 .amux = EM28XX_AMUX_LINE_IN, 731 .amux = EM28XX_AMUX_LINE_IN,
721 }, { 732 }, {
@@ -735,7 +746,7 @@ struct em28xx_board em28xx_boards[] = {
735 .vmux = SAA7115_COMPOSITE2, 746 .vmux = SAA7115_COMPOSITE2,
736 .amux = EM28XX_AMUX_LINE_IN, 747 .amux = EM28XX_AMUX_LINE_IN,
737 }, { 748 }, {
738 .type = EM28XX_VMUX_COMPOSITE1, 749 .type = EM28XX_VMUX_COMPOSITE,
739 .vmux = SAA7115_COMPOSITE0, 750 .vmux = SAA7115_COMPOSITE0,
740 .amux = EM28XX_AMUX_LINE_IN, 751 .amux = EM28XX_AMUX_LINE_IN,
741 }, { 752 }, {
@@ -755,7 +766,7 @@ struct em28xx_board em28xx_boards[] = {
755 .vmux = SAA7115_COMPOSITE2, 766 .vmux = SAA7115_COMPOSITE2,
756 .amux = EM28XX_AMUX_VIDEO, 767 .amux = EM28XX_AMUX_VIDEO,
757 }, { 768 }, {
758 .type = EM28XX_VMUX_COMPOSITE1, 769 .type = EM28XX_VMUX_COMPOSITE,
759 .vmux = SAA7115_COMPOSITE0, 770 .vmux = SAA7115_COMPOSITE0,
760 .amux = EM28XX_AMUX_LINE_IN, 771 .amux = EM28XX_AMUX_LINE_IN,
761 }, { 772 }, {
@@ -775,7 +786,7 @@ struct em28xx_board em28xx_boards[] = {
775 .vmux = SAA7115_COMPOSITE1, 786 .vmux = SAA7115_COMPOSITE1,
776 .amux = EM28XX_AMUX_LINE_IN, 787 .amux = EM28XX_AMUX_LINE_IN,
777 }, { 788 }, {
778 .type = EM28XX_VMUX_COMPOSITE1, 789 .type = EM28XX_VMUX_COMPOSITE,
779 .vmux = SAA7115_COMPOSITE0, 790 .vmux = SAA7115_COMPOSITE0,
780 .amux = EM28XX_AMUX_LINE_IN, 791 .amux = EM28XX_AMUX_LINE_IN,
781 }, { 792 }, {
@@ -800,7 +811,7 @@ struct em28xx_board em28xx_boards[] = {
800 .vmux = SAA7115_COMPOSITE4, 811 .vmux = SAA7115_COMPOSITE4,
801 .amux = EM28XX_AMUX_AUX, 812 .amux = EM28XX_AMUX_AUX,
802 }, { 813 }, {
803 .type = EM28XX_VMUX_COMPOSITE1, 814 .type = EM28XX_VMUX_COMPOSITE,
804 .vmux = SAA7115_COMPOSITE5, 815 .vmux = SAA7115_COMPOSITE5,
805 .amux = EM28XX_AMUX_LINE_IN, 816 .amux = EM28XX_AMUX_LINE_IN,
806 }, { 817 }, {
@@ -819,7 +830,7 @@ struct em28xx_board em28xx_boards[] = {
819 .tuner_type = TUNER_ABSENT, 830 .tuner_type = TUNER_ABSENT,
820 .is_webcam = 1, 831 .is_webcam = 1,
821 .input = { { 832 .input = { {
822 .type = EM28XX_VMUX_COMPOSITE1, 833 .type = EM28XX_VMUX_COMPOSITE,
823 .vmux = 0, 834 .vmux = 0,
824 .amux = EM28XX_AMUX_VIDEO, 835 .amux = EM28XX_AMUX_VIDEO,
825 } }, 836 } },
@@ -829,7 +840,7 @@ struct em28xx_board em28xx_boards[] = {
829 .tuner_type = TUNER_ABSENT, 840 .tuner_type = TUNER_ABSENT,
830 .is_webcam = 1, 841 .is_webcam = 1,
831 .input = { { 842 .input = { {
832 .type = EM28XX_VMUX_COMPOSITE1, 843 .type = EM28XX_VMUX_COMPOSITE,
833 .vmux = 0, 844 .vmux = 0,
834 .amux = EM28XX_AMUX_VIDEO, 845 .amux = EM28XX_AMUX_VIDEO,
835 .gpio = silvercrest_reg_seq, 846 .gpio = silvercrest_reg_seq,
@@ -848,7 +859,7 @@ struct em28xx_board em28xx_boards[] = {
848 .vmux = SAA7115_COMPOSITE2, 859 .vmux = SAA7115_COMPOSITE2,
849 .amux = EM28XX_AMUX_LINE_IN, 860 .amux = EM28XX_AMUX_LINE_IN,
850 }, { 861 }, {
851 .type = EM28XX_VMUX_COMPOSITE1, 862 .type = EM28XX_VMUX_COMPOSITE,
852 .vmux = SAA7115_COMPOSITE0, 863 .vmux = SAA7115_COMPOSITE0,
853 .amux = EM28XX_AMUX_VIDEO, 864 .amux = EM28XX_AMUX_VIDEO,
854 }, { 865 }, {
@@ -863,7 +874,7 @@ struct em28xx_board em28xx_boards[] = {
863 .tuner_type = TUNER_ABSENT, /* Capture only device */ 874 .tuner_type = TUNER_ABSENT, /* Capture only device */
864 .decoder = EM28XX_SAA711X, 875 .decoder = EM28XX_SAA711X,
865 .input = { { 876 .input = { {
866 .type = EM28XX_VMUX_COMPOSITE1, 877 .type = EM28XX_VMUX_COMPOSITE,
867 .vmux = SAA7115_COMPOSITE0, 878 .vmux = SAA7115_COMPOSITE0,
868 .amux = EM28XX_AMUX_LINE_IN, 879 .amux = EM28XX_AMUX_LINE_IN,
869 }, { 880 }, {
@@ -879,7 +890,7 @@ struct em28xx_board em28xx_boards[] = {
879 .tuner_type = TUNER_ABSENT, 890 .tuner_type = TUNER_ABSENT,
880 .is_webcam = 1, 891 .is_webcam = 1,
881 .input = { { 892 .input = { {
882 .type = EM28XX_VMUX_COMPOSITE1, 893 .type = EM28XX_VMUX_COMPOSITE,
883 .vmux = 0, 894 .vmux = 0,
884 .amux = EM28XX_AMUX_VIDEO, 895 .amux = EM28XX_AMUX_VIDEO,
885 } }, 896 } },
@@ -889,7 +900,7 @@ struct em28xx_board em28xx_boards[] = {
889 .decoder = EM28XX_SAA711X, 900 .decoder = EM28XX_SAA711X,
890 .tuner_type = TUNER_ABSENT, /* Capture only device */ 901 .tuner_type = TUNER_ABSENT, /* Capture only device */
891 .input = { { 902 .input = { {
892 .type = EM28XX_VMUX_COMPOSITE1, 903 .type = EM28XX_VMUX_COMPOSITE,
893 .vmux = SAA7115_COMPOSITE0, 904 .vmux = SAA7115_COMPOSITE0,
894 .amux = EM28XX_AMUX_LINE_IN, 905 .amux = EM28XX_AMUX_LINE_IN,
895 }, { 906 }, {
@@ -909,7 +920,7 @@ struct em28xx_board em28xx_boards[] = {
909 .vmux = SAA7115_COMPOSITE2, 920 .vmux = SAA7115_COMPOSITE2,
910 .amux = EM28XX_AMUX_VIDEO, 921 .amux = EM28XX_AMUX_VIDEO,
911 }, { 922 }, {
912 .type = EM28XX_VMUX_COMPOSITE1, 923 .type = EM28XX_VMUX_COMPOSITE,
913 .vmux = SAA7115_COMPOSITE0, 924 .vmux = SAA7115_COMPOSITE0,
914 .amux = EM28XX_AMUX_LINE_IN, 925 .amux = EM28XX_AMUX_LINE_IN,
915 }, { 926 }, {
@@ -930,7 +941,7 @@ struct em28xx_board em28xx_boards[] = {
930 .vmux = SAA7115_COMPOSITE2, 941 .vmux = SAA7115_COMPOSITE2,
931 .amux = EM28XX_AMUX_VIDEO, 942 .amux = EM28XX_AMUX_VIDEO,
932 }, { 943 }, {
933 .type = EM28XX_VMUX_COMPOSITE1, 944 .type = EM28XX_VMUX_COMPOSITE,
934 .vmux = SAA7115_COMPOSITE0, 945 .vmux = SAA7115_COMPOSITE0,
935 .amux = EM28XX_AMUX_LINE_IN, 946 .amux = EM28XX_AMUX_LINE_IN,
936 }, { 947 }, {
@@ -952,7 +963,7 @@ struct em28xx_board em28xx_boards[] = {
952 .amux = EM28XX_AMUX_VIDEO, 963 .amux = EM28XX_AMUX_VIDEO,
953 .gpio = hauppauge_wintv_hvr_900_analog, 964 .gpio = hauppauge_wintv_hvr_900_analog,
954 }, { 965 }, {
955 .type = EM28XX_VMUX_COMPOSITE1, 966 .type = EM28XX_VMUX_COMPOSITE,
956 .vmux = TVP5150_COMPOSITE1, 967 .vmux = TVP5150_COMPOSITE1,
957 .amux = EM28XX_AMUX_LINE_IN, 968 .amux = EM28XX_AMUX_LINE_IN,
958 .gpio = hauppauge_wintv_hvr_900_analog, 969 .gpio = hauppauge_wintv_hvr_900_analog,
@@ -974,7 +985,7 @@ struct em28xx_board em28xx_boards[] = {
974 .vmux = TVP5150_COMPOSITE0, 985 .vmux = TVP5150_COMPOSITE0,
975 .amux = EM28XX_AMUX_VIDEO, 986 .amux = EM28XX_AMUX_VIDEO,
976 }, { 987 }, {
977 .type = EM28XX_VMUX_COMPOSITE1, 988 .type = EM28XX_VMUX_COMPOSITE,
978 .vmux = TVP5150_COMPOSITE1, 989 .vmux = TVP5150_COMPOSITE1,
979 .amux = EM28XX_AMUX_LINE_IN, 990 .amux = EM28XX_AMUX_LINE_IN,
980 }, { 991 }, {
@@ -992,7 +1003,7 @@ struct em28xx_board em28xx_boards[] = {
992 .vmux = TVP5150_COMPOSITE0, 1003 .vmux = TVP5150_COMPOSITE0,
993 .amux = EM28XX_AMUX_VIDEO, 1004 .amux = EM28XX_AMUX_VIDEO,
994 }, { 1005 }, {
995 .type = EM28XX_VMUX_COMPOSITE1, 1006 .type = EM28XX_VMUX_COMPOSITE,
996 .vmux = TVP5150_COMPOSITE1, 1007 .vmux = TVP5150_COMPOSITE1,
997 .amux = EM28XX_AMUX_LINE_IN, 1008 .amux = EM28XX_AMUX_LINE_IN,
998 }, { 1009 }, {
@@ -1006,7 +1017,7 @@ struct em28xx_board em28xx_boards[] = {
1006 .tuner_type = TUNER_ABSENT, /* Capture only device */ 1017 .tuner_type = TUNER_ABSENT, /* Capture only device */
1007 .decoder = EM28XX_TVP5150, 1018 .decoder = EM28XX_TVP5150,
1008 .input = { { 1019 .input = { {
1009 .type = EM28XX_VMUX_COMPOSITE1, 1020 .type = EM28XX_VMUX_COMPOSITE,
1010 .vmux = TVP5150_COMPOSITE1, 1021 .vmux = TVP5150_COMPOSITE1,
1011 .amux = EM28XX_AMUX_LINE_IN, 1022 .amux = EM28XX_AMUX_LINE_IN,
1012 }, { 1023 }, {
@@ -1029,7 +1040,7 @@ struct em28xx_board em28xx_boards[] = {
1029 .amux = EM28XX_AMUX_LINE_IN, 1040 .amux = EM28XX_AMUX_LINE_IN,
1030 .gpio = pinnacle_hybrid_pro_analog, 1041 .gpio = pinnacle_hybrid_pro_analog,
1031 }, { 1042 }, {
1032 .type = EM28XX_VMUX_COMPOSITE1, 1043 .type = EM28XX_VMUX_COMPOSITE,
1033 .vmux = TVP5150_COMPOSITE1, 1044 .vmux = TVP5150_COMPOSITE1,
1034 .amux = EM28XX_AMUX_LINE_IN, 1045 .amux = EM28XX_AMUX_LINE_IN,
1035 .gpio = pinnacle_hybrid_pro_analog, 1046 .gpio = pinnacle_hybrid_pro_analog,
@@ -1100,7 +1111,7 @@ struct em28xx_board em28xx_boards[] = {
1100 .amux = EM28XX_AMUX_VIDEO, 1111 .amux = EM28XX_AMUX_VIDEO,
1101 .gpio = terratec_cinergy_USB_XS_FR_analog, 1112 .gpio = terratec_cinergy_USB_XS_FR_analog,
1102 }, { 1113 }, {
1103 .type = EM28XX_VMUX_COMPOSITE1, 1114 .type = EM28XX_VMUX_COMPOSITE,
1104 .vmux = TVP5150_COMPOSITE1, 1115 .vmux = TVP5150_COMPOSITE1,
1105 .amux = EM28XX_AMUX_LINE_IN, 1116 .amux = EM28XX_AMUX_LINE_IN,
1106 .gpio = terratec_cinergy_USB_XS_FR_analog, 1117 .gpio = terratec_cinergy_USB_XS_FR_analog,
@@ -1186,7 +1197,7 @@ struct em28xx_board em28xx_boards[] = {
1186 .amux = EM28XX_AMUX_VIDEO, 1197 .amux = EM28XX_AMUX_VIDEO,
1187 .gpio = hauppauge_wintv_hvr_900_analog, 1198 .gpio = hauppauge_wintv_hvr_900_analog,
1188 }, { 1199 }, {
1189 .type = EM28XX_VMUX_COMPOSITE1, 1200 .type = EM28XX_VMUX_COMPOSITE,
1190 .vmux = TVP5150_COMPOSITE1, 1201 .vmux = TVP5150_COMPOSITE1,
1191 .amux = EM28XX_AMUX_LINE_IN, 1202 .amux = EM28XX_AMUX_LINE_IN,
1192 .gpio = hauppauge_wintv_hvr_900_analog, 1203 .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1213,7 +1224,7 @@ struct em28xx_board em28xx_boards[] = {
1213 .amux = EM28XX_AMUX_VIDEO, 1224 .amux = EM28XX_AMUX_VIDEO,
1214 .gpio = hauppauge_wintv_hvr_900_analog, 1225 .gpio = hauppauge_wintv_hvr_900_analog,
1215 }, { 1226 }, {
1216 .type = EM28XX_VMUX_COMPOSITE1, 1227 .type = EM28XX_VMUX_COMPOSITE,
1217 .vmux = TVP5150_COMPOSITE1, 1228 .vmux = TVP5150_COMPOSITE1,
1218 .amux = EM28XX_AMUX_LINE_IN, 1229 .amux = EM28XX_AMUX_LINE_IN,
1219 .gpio = hauppauge_wintv_hvr_900_analog, 1230 .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1239,7 +1250,7 @@ struct em28xx_board em28xx_boards[] = {
1239 .amux = EM28XX_AMUX_VIDEO, 1250 .amux = EM28XX_AMUX_VIDEO,
1240 .gpio = hauppauge_wintv_hvr_900_analog, 1251 .gpio = hauppauge_wintv_hvr_900_analog,
1241 }, { 1252 }, {
1242 .type = EM28XX_VMUX_COMPOSITE1, 1253 .type = EM28XX_VMUX_COMPOSITE,
1243 .vmux = TVP5150_COMPOSITE1, 1254 .vmux = TVP5150_COMPOSITE1,
1244 .amux = EM28XX_AMUX_LINE_IN, 1255 .amux = EM28XX_AMUX_LINE_IN,
1245 .gpio = hauppauge_wintv_hvr_900_analog, 1256 .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1265,7 +1276,7 @@ struct em28xx_board em28xx_boards[] = {
1265 .amux = EM28XX_AMUX_VIDEO, 1276 .amux = EM28XX_AMUX_VIDEO,
1266 .gpio = hauppauge_wintv_hvr_900_analog, 1277 .gpio = hauppauge_wintv_hvr_900_analog,
1267 }, { 1278 }, {
1268 .type = EM28XX_VMUX_COMPOSITE1, 1279 .type = EM28XX_VMUX_COMPOSITE,
1269 .vmux = TVP5150_COMPOSITE1, 1280 .vmux = TVP5150_COMPOSITE1,
1270 .amux = EM28XX_AMUX_LINE_IN, 1281 .amux = EM28XX_AMUX_LINE_IN,
1271 .gpio = hauppauge_wintv_hvr_900_analog, 1282 .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1291,7 +1302,7 @@ struct em28xx_board em28xx_boards[] = {
1291 .amux = EM28XX_AMUX_VIDEO, 1302 .amux = EM28XX_AMUX_VIDEO,
1292 .gpio = hauppauge_wintv_hvr_900_analog, 1303 .gpio = hauppauge_wintv_hvr_900_analog,
1293 }, { 1304 }, {
1294 .type = EM28XX_VMUX_COMPOSITE1, 1305 .type = EM28XX_VMUX_COMPOSITE,
1295 .vmux = TVP5150_COMPOSITE1, 1306 .vmux = TVP5150_COMPOSITE1,
1296 .amux = EM28XX_AMUX_LINE_IN, 1307 .amux = EM28XX_AMUX_LINE_IN,
1297 .gpio = hauppauge_wintv_hvr_900_analog, 1308 .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1317,7 +1328,7 @@ struct em28xx_board em28xx_boards[] = {
1317 .amux = EM28XX_AMUX_VIDEO, 1328 .amux = EM28XX_AMUX_VIDEO,
1318 .gpio = hauppauge_wintv_hvr_900_analog, 1329 .gpio = hauppauge_wintv_hvr_900_analog,
1319 }, { 1330 }, {
1320 .type = EM28XX_VMUX_COMPOSITE1, 1331 .type = EM28XX_VMUX_COMPOSITE,
1321 .vmux = TVP5150_COMPOSITE1, 1332 .vmux = TVP5150_COMPOSITE1,
1322 .amux = EM28XX_AMUX_LINE_IN, 1333 .amux = EM28XX_AMUX_LINE_IN,
1323 .gpio = hauppauge_wintv_hvr_900_analog, 1334 .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1343,7 +1354,7 @@ struct em28xx_board em28xx_boards[] = {
1343 .amux = EM28XX_AMUX_VIDEO, 1354 .amux = EM28XX_AMUX_VIDEO,
1344 .gpio = default_analog, 1355 .gpio = default_analog,
1345 }, { 1356 }, {
1346 .type = EM28XX_VMUX_COMPOSITE1, 1357 .type = EM28XX_VMUX_COMPOSITE,
1347 .vmux = TVP5150_COMPOSITE1, 1358 .vmux = TVP5150_COMPOSITE1,
1348 .amux = EM28XX_AMUX_LINE_IN, 1359 .amux = EM28XX_AMUX_LINE_IN,
1349 .gpio = default_analog, 1360 .gpio = default_analog,
@@ -1368,7 +1379,7 @@ struct em28xx_board em28xx_boards[] = {
1368 .amux = EM28XX_AMUX_VIDEO, 1379 .amux = EM28XX_AMUX_VIDEO,
1369 .gpio = hauppauge_wintv_hvr_900_analog, 1380 .gpio = hauppauge_wintv_hvr_900_analog,
1370 }, { 1381 }, {
1371 .type = EM28XX_VMUX_COMPOSITE1, 1382 .type = EM28XX_VMUX_COMPOSITE,
1372 .vmux = TVP5150_COMPOSITE1, 1383 .vmux = TVP5150_COMPOSITE1,
1373 .amux = EM28XX_AMUX_LINE_IN, 1384 .amux = EM28XX_AMUX_LINE_IN,
1374 .gpio = hauppauge_wintv_hvr_900_analog, 1385 .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1392,7 +1403,7 @@ struct em28xx_board em28xx_boards[] = {
1392 .vmux = SAA7115_COMPOSITE4, 1403 .vmux = SAA7115_COMPOSITE4,
1393 .amux = EM28XX_AMUX_VIDEO, 1404 .amux = EM28XX_AMUX_VIDEO,
1394 }, { 1405 }, {
1395 .type = EM28XX_VMUX_COMPOSITE1, 1406 .type = EM28XX_VMUX_COMPOSITE,
1396 .vmux = SAA7115_COMPOSITE0, 1407 .vmux = SAA7115_COMPOSITE0,
1397 .amux = EM28XX_AMUX_LINE_IN, 1408 .amux = EM28XX_AMUX_LINE_IN,
1398 }, { 1409 }, {
@@ -1413,7 +1424,7 @@ struct em28xx_board em28xx_boards[] = {
1413 .vmux = SAA7115_COMPOSITE2, 1424 .vmux = SAA7115_COMPOSITE2,
1414 .amux = EM28XX_AMUX_VIDEO, 1425 .amux = EM28XX_AMUX_VIDEO,
1415 }, { 1426 }, {
1416 .type = EM28XX_VMUX_COMPOSITE1, 1427 .type = EM28XX_VMUX_COMPOSITE,
1417 .vmux = SAA7115_COMPOSITE0, 1428 .vmux = SAA7115_COMPOSITE0,
1418 .amux = EM28XX_AMUX_LINE_IN, 1429 .amux = EM28XX_AMUX_LINE_IN,
1419 }, { 1430 }, {
@@ -1428,7 +1439,7 @@ struct em28xx_board em28xx_boards[] = {
1428 .decoder = EM28XX_SAA711X, 1439 .decoder = EM28XX_SAA711X,
1429 .tuner_type = TUNER_ABSENT, /* capture only board */ 1440 .tuner_type = TUNER_ABSENT, /* capture only board */
1430 .input = { { 1441 .input = { {
1431 .type = EM28XX_VMUX_COMPOSITE1, 1442 .type = EM28XX_VMUX_COMPOSITE,
1432 .vmux = SAA7115_COMPOSITE0, 1443 .vmux = SAA7115_COMPOSITE0,
1433 .amux = EM28XX_AMUX_LINE_IN, 1444 .amux = EM28XX_AMUX_LINE_IN,
1434 }, { 1445 }, {
@@ -1443,7 +1454,7 @@ struct em28xx_board em28xx_boards[] = {
1443 .tuner_type = TUNER_ABSENT, /* Capture-only board */ 1454 .tuner_type = TUNER_ABSENT, /* Capture-only board */
1444 .decoder = EM28XX_SAA711X, 1455 .decoder = EM28XX_SAA711X,
1445 .input = { { 1456 .input = { {
1446 .type = EM28XX_VMUX_COMPOSITE1, 1457 .type = EM28XX_VMUX_COMPOSITE,
1447 .vmux = SAA7115_COMPOSITE0, 1458 .vmux = SAA7115_COMPOSITE0,
1448 .amux = EM28XX_AMUX_LINE_IN, 1459 .amux = EM28XX_AMUX_LINE_IN,
1449 .gpio = vc211a_enable, 1460 .gpio = vc211a_enable,
@@ -1465,7 +1476,7 @@ struct em28xx_board em28xx_boards[] = {
1465 .vmux = SAA7115_COMPOSITE2, 1476 .vmux = SAA7115_COMPOSITE2,
1466 .amux = EM28XX_AMUX_VIDEO, 1477 .amux = EM28XX_AMUX_VIDEO,
1467 }, { 1478 }, {
1468 .type = EM28XX_VMUX_COMPOSITE1, 1479 .type = EM28XX_VMUX_COMPOSITE,
1469 .vmux = SAA7115_COMPOSITE0, 1480 .vmux = SAA7115_COMPOSITE0,
1470 .amux = EM28XX_AMUX_LINE_IN, 1481 .amux = EM28XX_AMUX_LINE_IN,
1471 }, { 1482 }, {
@@ -1485,7 +1496,7 @@ struct em28xx_board em28xx_boards[] = {
1485 .vmux = SAA7115_COMPOSITE2, 1496 .vmux = SAA7115_COMPOSITE2,
1486 .amux = EM28XX_AMUX_VIDEO, 1497 .amux = EM28XX_AMUX_VIDEO,
1487 }, { 1498 }, {
1488 .type = EM28XX_VMUX_COMPOSITE1, 1499 .type = EM28XX_VMUX_COMPOSITE,
1489 .vmux = SAA7115_COMPOSITE0, 1500 .vmux = SAA7115_COMPOSITE0,
1490 .amux = EM28XX_AMUX_LINE_IN, 1501 .amux = EM28XX_AMUX_LINE_IN,
1491 }, { 1502 }, {
@@ -1500,7 +1511,7 @@ struct em28xx_board em28xx_boards[] = {
1500 .tuner_type = TUNER_ABSENT, /* capture only board */ 1511 .tuner_type = TUNER_ABSENT, /* capture only board */
1501 .decoder = EM28XX_SAA711X, 1512 .decoder = EM28XX_SAA711X,
1502 .input = { { 1513 .input = { {
1503 .type = EM28XX_VMUX_COMPOSITE1, 1514 .type = EM28XX_VMUX_COMPOSITE,
1504 .vmux = SAA7115_COMPOSITE0, 1515 .vmux = SAA7115_COMPOSITE0,
1505 .amux = EM28XX_AMUX_LINE_IN, 1516 .amux = EM28XX_AMUX_LINE_IN,
1506 }, { 1517 }, {
@@ -1520,7 +1531,7 @@ struct em28xx_board em28xx_boards[] = {
1520 .vmux = SAA7115_COMPOSITE2, 1531 .vmux = SAA7115_COMPOSITE2,
1521 .amux = EM28XX_AMUX_VIDEO, 1532 .amux = EM28XX_AMUX_VIDEO,
1522 }, { 1533 }, {
1523 .type = EM28XX_VMUX_COMPOSITE1, 1534 .type = EM28XX_VMUX_COMPOSITE,
1524 .vmux = SAA7115_COMPOSITE0, 1535 .vmux = SAA7115_COMPOSITE0,
1525 .amux = EM28XX_AMUX_LINE_IN, 1536 .amux = EM28XX_AMUX_LINE_IN,
1526 }, { 1537 }, {
@@ -1541,7 +1552,7 @@ struct em28xx_board em28xx_boards[] = {
1541 .aout = EM28XX_AOUT_MONO | /* I2S */ 1552 .aout = EM28XX_AOUT_MONO | /* I2S */
1542 EM28XX_AOUT_MASTER, /* Line out pin */ 1553 EM28XX_AOUT_MASTER, /* Line out pin */
1543 }, { 1554 }, {
1544 .type = EM28XX_VMUX_COMPOSITE1, 1555 .type = EM28XX_VMUX_COMPOSITE,
1545 .vmux = SAA7115_COMPOSITE0, 1556 .vmux = SAA7115_COMPOSITE0,
1546 .amux = EM28XX_AMUX_LINE_IN, 1557 .amux = EM28XX_AMUX_LINE_IN,
1547 }, { 1558 }, {
@@ -1555,6 +1566,7 @@ struct em28xx_board em28xx_boards[] = {
1555 .buttons = std_snapshot_button, 1566 .buttons = std_snapshot_button,
1556 .tda9887_conf = TDA9887_PRESENT, 1567 .tda9887_conf = TDA9887_PRESENT,
1557 .tuner_type = TUNER_YMEC_TVF_5533MF, 1568 .tuner_type = TUNER_YMEC_TVF_5533MF,
1569 .tuner_addr = 0x60,
1558 .decoder = EM28XX_SAA711X, 1570 .decoder = EM28XX_SAA711X,
1559 .input = { { 1571 .input = { {
1560 .type = EM28XX_VMUX_TELEVISION, 1572 .type = EM28XX_VMUX_TELEVISION,
@@ -1563,7 +1575,7 @@ struct em28xx_board em28xx_boards[] = {
1563 .aout = EM28XX_AOUT_MONO | /* I2S */ 1575 .aout = EM28XX_AOUT_MONO | /* I2S */
1564 EM28XX_AOUT_MASTER, /* Line out pin */ 1576 EM28XX_AOUT_MASTER, /* Line out pin */
1565 }, { 1577 }, {
1566 .type = EM28XX_VMUX_COMPOSITE1, 1578 .type = EM28XX_VMUX_COMPOSITE,
1567 .vmux = SAA7115_COMPOSITE0, 1579 .vmux = SAA7115_COMPOSITE0,
1568 .amux = EM28XX_AMUX_LINE_IN, 1580 .amux = EM28XX_AMUX_LINE_IN,
1569 }, { 1581 }, {
@@ -1581,7 +1593,7 @@ struct em28xx_board em28xx_boards[] = {
1581 .type = EM28XX_VMUX_SVIDEO, 1593 .type = EM28XX_VMUX_SVIDEO,
1582 .vmux = SAA7115_SVIDEO3, 1594 .vmux = SAA7115_SVIDEO3,
1583 }, { 1595 }, {
1584 .type = EM28XX_VMUX_COMPOSITE1, 1596 .type = EM28XX_VMUX_COMPOSITE,
1585 .vmux = SAA7115_COMPOSITE0, 1597 .vmux = SAA7115_COMPOSITE0,
1586 } }, 1598 } },
1587 }, 1599 },
@@ -1610,7 +1622,7 @@ struct em28xx_board em28xx_boards[] = {
1610 .amux = EM28XX_AMUX_VIDEO, 1622 .amux = EM28XX_AMUX_VIDEO,
1611 .gpio = em2880_msi_digivox_ad_analog, 1623 .gpio = em2880_msi_digivox_ad_analog,
1612 }, { 1624 }, {
1613 .type = EM28XX_VMUX_COMPOSITE1, 1625 .type = EM28XX_VMUX_COMPOSITE,
1614 .vmux = TVP5150_COMPOSITE1, 1626 .vmux = TVP5150_COMPOSITE1,
1615 .amux = EM28XX_AMUX_LINE_IN, 1627 .amux = EM28XX_AMUX_LINE_IN,
1616 .gpio = em2880_msi_digivox_ad_analog, 1628 .gpio = em2880_msi_digivox_ad_analog,
@@ -1633,7 +1645,7 @@ struct em28xx_board em28xx_boards[] = {
1633 .amux = EM28XX_AMUX_VIDEO, 1645 .amux = EM28XX_AMUX_VIDEO,
1634 .gpio = em2880_msi_digivox_ad_analog, 1646 .gpio = em2880_msi_digivox_ad_analog,
1635 }, { 1647 }, {
1636 .type = EM28XX_VMUX_COMPOSITE1, 1648 .type = EM28XX_VMUX_COMPOSITE,
1637 .vmux = TVP5150_COMPOSITE1, 1649 .vmux = TVP5150_COMPOSITE1,
1638 .amux = EM28XX_AMUX_LINE_IN, 1650 .amux = EM28XX_AMUX_LINE_IN,
1639 .gpio = em2880_msi_digivox_ad_analog, 1651 .gpio = em2880_msi_digivox_ad_analog,
@@ -1654,7 +1666,7 @@ struct em28xx_board em28xx_boards[] = {
1654 .vmux = TVP5150_COMPOSITE0, 1666 .vmux = TVP5150_COMPOSITE0,
1655 .amux = EM28XX_AMUX_VIDEO, 1667 .amux = EM28XX_AMUX_VIDEO,
1656 }, { 1668 }, {
1657 .type = EM28XX_VMUX_COMPOSITE1, 1669 .type = EM28XX_VMUX_COMPOSITE,
1658 .vmux = TVP5150_COMPOSITE1, 1670 .vmux = TVP5150_COMPOSITE1,
1659 .amux = EM28XX_AMUX_LINE_IN, 1671 .amux = EM28XX_AMUX_LINE_IN,
1660 }, { 1672 }, {
@@ -1677,7 +1689,7 @@ struct em28xx_board em28xx_boards[] = {
1677 .amux = EM28XX_AMUX_VIDEO, 1689 .amux = EM28XX_AMUX_VIDEO,
1678 .gpio = default_analog, 1690 .gpio = default_analog,
1679 }, { 1691 }, {
1680 .type = EM28XX_VMUX_COMPOSITE1, 1692 .type = EM28XX_VMUX_COMPOSITE,
1681 .vmux = TVP5150_COMPOSITE1, 1693 .vmux = TVP5150_COMPOSITE1,
1682 .amux = EM28XX_AMUX_LINE_IN, 1694 .amux = EM28XX_AMUX_LINE_IN,
1683 .gpio = default_analog, 1695 .gpio = default_analog,
@@ -1708,7 +1720,7 @@ struct em28xx_board em28xx_boards[] = {
1708 .gpio = em2882_kworld_315u_analog, 1720 .gpio = em2882_kworld_315u_analog,
1709 .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO, 1721 .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1710 }, { 1722 }, {
1711 .type = EM28XX_VMUX_COMPOSITE1, 1723 .type = EM28XX_VMUX_COMPOSITE,
1712 .vmux = SAA7115_COMPOSITE0, 1724 .vmux = SAA7115_COMPOSITE0,
1713 .amux = EM28XX_AMUX_LINE_IN, 1725 .amux = EM28XX_AMUX_LINE_IN,
1714 .gpio = em2882_kworld_315u_analog1, 1726 .gpio = em2882_kworld_315u_analog1,
@@ -1735,7 +1747,7 @@ struct em28xx_board em28xx_boards[] = {
1735 .amux = EM28XX_AMUX_VIDEO, 1747 .amux = EM28XX_AMUX_VIDEO,
1736 .gpio = default_analog, 1748 .gpio = default_analog,
1737 }, { 1749 }, {
1738 .type = EM28XX_VMUX_COMPOSITE1, 1750 .type = EM28XX_VMUX_COMPOSITE,
1739 .vmux = TVP5150_COMPOSITE1, 1751 .vmux = TVP5150_COMPOSITE1,
1740 .amux = EM28XX_AMUX_LINE_IN, 1752 .amux = EM28XX_AMUX_LINE_IN,
1741 .gpio = default_analog, 1753 .gpio = default_analog,
@@ -1758,7 +1770,7 @@ struct em28xx_board em28xx_boards[] = {
1758 .amux = EM28XX_AMUX_VIDEO, 1770 .amux = EM28XX_AMUX_VIDEO,
1759 .gpio = default_analog, 1771 .gpio = default_analog,
1760 }, { 1772 }, {
1761 .type = EM28XX_VMUX_COMPOSITE1, 1773 .type = EM28XX_VMUX_COMPOSITE,
1762 .vmux = TVP5150_COMPOSITE1, 1774 .vmux = TVP5150_COMPOSITE1,
1763 .amux = EM28XX_AMUX_LINE_IN, 1775 .amux = EM28XX_AMUX_LINE_IN,
1764 .gpio = default_analog, 1776 .gpio = default_analog,
@@ -1782,7 +1794,7 @@ struct em28xx_board em28xx_boards[] = {
1782 .amux = EM28XX_AMUX_VIDEO, 1794 .amux = EM28XX_AMUX_VIDEO,
1783 .gpio = pinnacle_hybrid_pro_analog, 1795 .gpio = pinnacle_hybrid_pro_analog,
1784 }, { 1796 }, {
1785 .type = EM28XX_VMUX_COMPOSITE1, 1797 .type = EM28XX_VMUX_COMPOSITE,
1786 .vmux = TVP5150_COMPOSITE1, 1798 .vmux = TVP5150_COMPOSITE1,
1787 .amux = EM28XX_AMUX_LINE_IN, 1799 .amux = EM28XX_AMUX_LINE_IN,
1788 .gpio = pinnacle_hybrid_pro_analog, 1800 .gpio = pinnacle_hybrid_pro_analog,
@@ -1808,7 +1820,7 @@ struct em28xx_board em28xx_boards[] = {
1808 .amux = EM28XX_AMUX_VIDEO, 1820 .amux = EM28XX_AMUX_VIDEO,
1809 .gpio = hauppauge_wintv_hvr_900_analog, 1821 .gpio = hauppauge_wintv_hvr_900_analog,
1810 }, { 1822 }, {
1811 .type = EM28XX_VMUX_COMPOSITE1, 1823 .type = EM28XX_VMUX_COMPOSITE,
1812 .vmux = TVP5150_COMPOSITE1, 1824 .vmux = TVP5150_COMPOSITE1,
1813 .amux = EM28XX_AMUX_LINE_IN, 1825 .amux = EM28XX_AMUX_LINE_IN,
1814 .gpio = hauppauge_wintv_hvr_900_analog, 1826 .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1834,7 +1846,7 @@ struct em28xx_board em28xx_boards[] = {
1834 .vmux = TVP5150_COMPOSITE0, 1846 .vmux = TVP5150_COMPOSITE0,
1835 .amux = EM28XX_AMUX_VIDEO, 1847 .amux = EM28XX_AMUX_VIDEO,
1836 }, { 1848 }, {
1837 .type = EM28XX_VMUX_COMPOSITE1, 1849 .type = EM28XX_VMUX_COMPOSITE,
1838 .vmux = TVP5150_COMPOSITE1, 1850 .vmux = TVP5150_COMPOSITE1,
1839 .amux = EM28XX_AMUX_LINE_IN, 1851 .amux = EM28XX_AMUX_LINE_IN,
1840 }, { 1852 }, {
@@ -1859,7 +1871,7 @@ struct em28xx_board em28xx_boards[] = {
1859 .amux = EM28XX_AMUX_VIDEO, 1871 .amux = EM28XX_AMUX_VIDEO,
1860 .gpio = hauppauge_wintv_hvr_900_analog, 1872 .gpio = hauppauge_wintv_hvr_900_analog,
1861 }, { 1873 }, {
1862 .type = EM28XX_VMUX_COMPOSITE1, 1874 .type = EM28XX_VMUX_COMPOSITE,
1863 .vmux = TVP5150_COMPOSITE1, 1875 .vmux = TVP5150_COMPOSITE1,
1864 .amux = EM28XX_AMUX_LINE_IN, 1876 .amux = EM28XX_AMUX_LINE_IN,
1865 .gpio = hauppauge_wintv_hvr_900_analog, 1877 .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1904,7 +1916,7 @@ struct em28xx_board em28xx_boards[] = {
1904 .gpio = kworld_330u_analog, 1916 .gpio = kworld_330u_analog,
1905 .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO, 1917 .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1906 }, { 1918 }, {
1907 .type = EM28XX_VMUX_COMPOSITE1, 1919 .type = EM28XX_VMUX_COMPOSITE,
1908 .vmux = TVP5150_COMPOSITE1, 1920 .vmux = TVP5150_COMPOSITE1,
1909 .amux = EM28XX_AMUX_LINE_IN, 1921 .amux = EM28XX_AMUX_LINE_IN,
1910 .gpio = kworld_330u_analog, 1922 .gpio = kworld_330u_analog,
@@ -1951,7 +1963,7 @@ struct em28xx_board em28xx_boards[] = {
1951 .amux = EM28XX_AMUX_VIDEO, 1963 .amux = EM28XX_AMUX_VIDEO,
1952 1964
1953 }, { 1965 }, {
1954 .type = EM28XX_VMUX_COMPOSITE1, 1966 .type = EM28XX_VMUX_COMPOSITE,
1955 .vmux = TVP5150_COMPOSITE1, 1967 .vmux = TVP5150_COMPOSITE1,
1956 .amux = EM28XX_AMUX_LINE_IN, 1968 .amux = EM28XX_AMUX_LINE_IN,
1957 }, { 1969 }, {
@@ -1970,7 +1982,7 @@ struct em28xx_board em28xx_boards[] = {
1970 .tuner_type = TUNER_ABSENT, 1982 .tuner_type = TUNER_ABSENT,
1971 .decoder = EM28XX_SAA711X, 1983 .decoder = EM28XX_SAA711X,
1972 .input = { { 1984 .input = { {
1973 .type = EM28XX_VMUX_COMPOSITE1, 1985 .type = EM28XX_VMUX_COMPOSITE,
1974 .vmux = SAA7115_COMPOSITE0, 1986 .vmux = SAA7115_COMPOSITE0,
1975 .amux = EM28XX_AMUX_LINE_IN, 1987 .amux = EM28XX_AMUX_LINE_IN,
1976 }, { 1988 }, {
@@ -1990,7 +2002,7 @@ struct em28xx_board em28xx_boards[] = {
1990 .vmux = TVP5150_COMPOSITE0, 2002 .vmux = TVP5150_COMPOSITE0,
1991 .amux = EM28XX_AMUX_VIDEO, 2003 .amux = EM28XX_AMUX_VIDEO,
1992 }, { /* Composite has not been tested yet */ 2004 }, { /* Composite has not been tested yet */
1993 .type = EM28XX_VMUX_COMPOSITE1, 2005 .type = EM28XX_VMUX_COMPOSITE,
1994 .vmux = TVP5150_COMPOSITE1, 2006 .vmux = TVP5150_COMPOSITE1,
1995 .amux = EM28XX_AMUX_VIDEO, 2007 .amux = EM28XX_AMUX_VIDEO,
1996 }, { /* S-video has not been tested yet */ 2008 }, { /* S-video has not been tested yet */
@@ -2006,7 +2018,7 @@ struct em28xx_board em28xx_boards[] = {
2006 .decoder = EM28XX_SAA711X, 2018 .decoder = EM28XX_SAA711X,
2007 .xclk = EM28XX_XCLK_FREQUENCY_12MHZ, 2019 .xclk = EM28XX_XCLK_FREQUENCY_12MHZ,
2008 .input = { { 2020 .input = { {
2009 .type = EM28XX_VMUX_COMPOSITE1, 2021 .type = EM28XX_VMUX_COMPOSITE,
2010 .vmux = SAA7115_COMPOSITE0, 2022 .vmux = SAA7115_COMPOSITE0,
2011 .amux = EM28XX_AMUX_LINE_IN, 2023 .amux = EM28XX_AMUX_LINE_IN,
2012 }, { 2024 }, {
@@ -2014,6 +2026,8 @@ struct em28xx_board em28xx_boards[] = {
2014 .vmux = SAA7115_SVIDEO3, 2026 .vmux = SAA7115_SVIDEO3,
2015 .amux = EM28XX_AMUX_LINE_IN, 2027 .amux = EM28XX_AMUX_LINE_IN,
2016 } }, 2028 } },
2029 .buttons = std_snapshot_button,
2030 .leds = terratec_grabby_leds,
2017 }, 2031 },
2018 [EM2860_BOARD_TERRATEC_AV350] = { 2032 [EM2860_BOARD_TERRATEC_AV350] = {
2019 .name = "Terratec AV350", 2033 .name = "Terratec AV350",
@@ -2023,7 +2037,7 @@ struct em28xx_board em28xx_boards[] = {
2023 .xclk = EM28XX_XCLK_FREQUENCY_12MHZ, 2037 .xclk = EM28XX_XCLK_FREQUENCY_12MHZ,
2024 .mute_gpio = terratec_av350_mute_gpio, 2038 .mute_gpio = terratec_av350_mute_gpio,
2025 .input = { { 2039 .input = { {
2026 .type = EM28XX_VMUX_COMPOSITE1, 2040 .type = EM28XX_VMUX_COMPOSITE,
2027 .vmux = TVP5150_COMPOSITE1, 2041 .vmux = TVP5150_COMPOSITE1,
2028 .amux = EM28XX_AUDIO_SRC_LINE, 2042 .amux = EM28XX_AUDIO_SRC_LINE,
2029 .gpio = terratec_av350_unmute_gpio, 2043 .gpio = terratec_av350_unmute_gpio,
@@ -2041,7 +2055,7 @@ struct em28xx_board em28xx_boards[] = {
2041 .decoder = EM28XX_SAA711X, 2055 .decoder = EM28XX_SAA711X,
2042 .tuner_type = TUNER_ABSENT, /* Capture only device */ 2056 .tuner_type = TUNER_ABSENT, /* Capture only device */
2043 .input = { { 2057 .input = { {
2044 .type = EM28XX_VMUX_COMPOSITE1, 2058 .type = EM28XX_VMUX_COMPOSITE,
2045 .vmux = SAA7115_COMPOSITE0, 2059 .vmux = SAA7115_COMPOSITE0,
2046 .amux = EM28XX_AMUX_LINE_IN, 2060 .amux = EM28XX_AMUX_LINE_IN,
2047 }, { 2061 }, {
@@ -2067,7 +2081,7 @@ struct em28xx_board em28xx_boards[] = {
2067 .amux = EM28XX_AMUX_VIDEO, 2081 .amux = EM28XX_AMUX_VIDEO,
2068 .gpio = evga_indtube_analog, 2082 .gpio = evga_indtube_analog,
2069 }, { 2083 }, {
2070 .type = EM28XX_VMUX_COMPOSITE1, 2084 .type = EM28XX_VMUX_COMPOSITE,
2071 .vmux = TVP5150_COMPOSITE1, 2085 .vmux = TVP5150_COMPOSITE1,
2072 .amux = EM28XX_AMUX_LINE_IN, 2086 .amux = EM28XX_AMUX_LINE_IN,
2073 .gpio = evga_indtube_analog, 2087 .gpio = evga_indtube_analog,
@@ -2125,7 +2139,7 @@ struct em28xx_board em28xx_boards[] = {
2125 .tuner_type = TUNER_ABSENT, 2139 .tuner_type = TUNER_ABSENT,
2126 .decoder = EM28XX_SAA711X, 2140 .decoder = EM28XX_SAA711X,
2127 .input = { { 2141 .input = { {
2128 .type = EM28XX_VMUX_COMPOSITE1, 2142 .type = EM28XX_VMUX_COMPOSITE,
2129 .vmux = SAA7115_COMPOSITE0, 2143 .vmux = SAA7115_COMPOSITE0,
2130 .amux = EM28XX_AMUX_LINE_IN, 2144 .amux = EM28XX_AMUX_LINE_IN,
2131 }, { 2145 }, {
@@ -2238,7 +2252,7 @@ struct em28xx_board em28xx_boards[] = {
2238 .tuner_type = TUNER_ABSENT, 2252 .tuner_type = TUNER_ABSENT,
2239 .is_webcam = 1, 2253 .is_webcam = 1,
2240 .input = { { 2254 .input = { {
2241 .type = EM28XX_VMUX_COMPOSITE1, 2255 .type = EM28XX_VMUX_COMPOSITE,
2242 .amux = EM28XX_AMUX_VIDEO, 2256 .amux = EM28XX_AMUX_VIDEO,
2243 .gpio = speedlink_vad_laplace_reg_seq, 2257 .gpio = speedlink_vad_laplace_reg_seq,
2244 } }, 2258 } },
@@ -2272,7 +2286,7 @@ struct em28xx_board em28xx_boards[] = {
2272 .tuner_type = TUNER_ABSENT, /* Capture only device */ 2286 .tuner_type = TUNER_ABSENT, /* Capture only device */
2273 .decoder = EM28XX_TVP5150, 2287 .decoder = EM28XX_TVP5150,
2274 .input = { { 2288 .input = { {
2275 .type = EM28XX_VMUX_COMPOSITE1, 2289 .type = EM28XX_VMUX_COMPOSITE,
2276 .vmux = TVP5150_COMPOSITE1, 2290 .vmux = TVP5150_COMPOSITE1,
2277 .amux = EM28XX_AMUX_LINE_IN, 2291 .amux = EM28XX_AMUX_LINE_IN,
2278 }, { 2292 }, {
@@ -2550,6 +2564,36 @@ static inline void em28xx_set_model(struct em28xx *dev)
2550 dev->def_i2c_bus = dev->board.def_i2c_bus; 2564 dev->def_i2c_bus = dev->board.def_i2c_bus;
2551} 2565}
2552 2566
2567/* Wait until AC97_RESET reports the expected value reliably before proceeding.
2568 * We also check that two unrelated registers accesses don't return the same
2569 * value to avoid premature return.
2570 * This procedure helps ensuring AC97 register accesses are reliable.
2571 */
2572static int em28xx_wait_until_ac97_features_equals(struct em28xx *dev,
2573 int expected_feat)
2574{
2575 unsigned long timeout = jiffies + msecs_to_jiffies(2000);
2576 int feat, powerdown;
2577
2578 while (time_is_after_jiffies(timeout)) {
2579 feat = em28xx_read_ac97(dev, AC97_RESET);
2580 if (feat < 0)
2581 return feat;
2582
2583 powerdown = em28xx_read_ac97(dev, AC97_POWERDOWN);
2584 if (powerdown < 0)
2585 return powerdown;
2586
2587 if (feat == expected_feat && feat != powerdown)
2588 return 0;
2589
2590 msleep(50);
2591 }
2592
2593 em28xx_warn("AC97 registers access is not reliable !\n");
2594 return -ETIMEDOUT;
2595}
2596
2553/* Since em28xx_pre_card_setup() requires a proper dev->model, 2597/* Since em28xx_pre_card_setup() requires a proper dev->model,
2554 * this won't work for boards with generic PCI IDs 2598 * this won't work for boards with generic PCI IDs
2555 */ 2599 */
@@ -2655,6 +2699,13 @@ static void em28xx_pre_card_setup(struct em28xx *dev)
2655 em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfd); 2699 em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfd);
2656 msleep(70); 2700 msleep(70);
2657 break; 2701 break;
2702
2703 case EM2860_BOARD_TERRATEC_GRABBY:
2704 /* HACK?: Ensure AC97 register reading is reliable before
2705 * proceeding. In practice, this will wait about 1.6 seconds.
2706 */
2707 em28xx_wait_until_ac97_features_equals(dev, 0x6a90);
2708 break;
2658 } 2709 }
2659 2710
2660 em28xx_gpio_set(dev, dev->board.tuner_gpio); 2711 em28xx_gpio_set(dev, dev->board.tuner_gpio);
@@ -3012,6 +3063,41 @@ static void flush_request_modules(struct em28xx *dev)
3012 flush_work(&dev->request_module_wk); 3063 flush_work(&dev->request_module_wk);
3013} 3064}
3014 3065
3066static int em28xx_media_device_init(struct em28xx *dev,
3067 struct usb_device *udev)
3068{
3069#ifdef CONFIG_MEDIA_CONTROLLER
3070 struct media_device *mdev;
3071
3072 mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
3073 if (!mdev)
3074 return -ENOMEM;
3075
3076 if (udev->product)
3077 media_device_usb_init(mdev, udev, udev->product);
3078 else if (udev->manufacturer)
3079 media_device_usb_init(mdev, udev, udev->manufacturer);
3080 else
3081 media_device_usb_init(mdev, udev, dev->name);
3082
3083 dev->media_dev = mdev;
3084#endif
3085 return 0;
3086}
3087
3088static void em28xx_unregister_media_device(struct em28xx *dev)
3089{
3090
3091#ifdef CONFIG_MEDIA_CONTROLLER
3092 if (dev->media_dev) {
3093 media_device_unregister(dev->media_dev);
3094 media_device_cleanup(dev->media_dev);
3095 kfree(dev->media_dev);
3096 dev->media_dev = NULL;
3097 }
3098#endif
3099}
3100
3015/* 3101/*
3016 * em28xx_release_resources() 3102 * em28xx_release_resources()
3017 * unregisters the v4l2,i2c and usb devices 3103 * unregisters the v4l2,i2c and usb devices
@@ -3023,6 +3109,8 @@ static void em28xx_release_resources(struct em28xx *dev)
3023 3109
3024 mutex_lock(&dev->lock); 3110 mutex_lock(&dev->lock);
3025 3111
3112 em28xx_unregister_media_device(dev);
3113
3026 if (dev->def_i2c_bus) 3114 if (dev->def_i2c_bus)
3027 em28xx_i2c_unregister(dev, 1); 3115 em28xx_i2c_unregister(dev, 1);
3028 em28xx_i2c_unregister(dev, 0); 3116 em28xx_i2c_unregister(dev, 0);
@@ -3167,6 +3255,8 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
3167 */ 3255 */
3168 snprintf(dev->name, sizeof(dev->name), "%s #%d", chip_name, dev->devno); 3256 snprintf(dev->name, sizeof(dev->name), "%s #%d", chip_name, dev->devno);
3169 3257
3258 em28xx_media_device_init(dev, udev);
3259
3170 if (dev->is_audio_only) { 3260 if (dev->is_audio_only) {
3171 retval = em28xx_audio_setup(dev); 3261 retval = em28xx_audio_setup(dev);
3172 if (retval) 3262 if (retval)
@@ -3467,7 +3557,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3467 /* save our data pointer in this interface device */ 3557 /* save our data pointer in this interface device */
3468 usb_set_intfdata(interface, dev); 3558 usb_set_intfdata(interface, dev);
3469 3559
3470 /* allocate device struct */ 3560 /* allocate device struct and check if the device is a webcam */
3471 mutex_init(&dev->lock); 3561 mutex_init(&dev->lock);
3472 retval = em28xx_init_dev(dev, udev, interface, nr); 3562 retval = em28xx_init_dev(dev, udev, interface, nr);
3473 if (retval) { 3563 if (retval) {
@@ -3483,6 +3573,15 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3483 try_bulk = usb_xfer_mode > 0; 3573 try_bulk = usb_xfer_mode > 0;
3484 } 3574 }
3485 3575
3576 /* Disable V4L2 if the device doesn't have a decoder */
3577 if (has_video &&
3578 dev->board.decoder == EM28XX_NODECODER && !dev->board.is_webcam) {
3579 printk(DRIVER_NAME
3580 ": Currently, V4L2 is not supported on this model\n");
3581 has_video = false;
3582 dev->has_video = false;
3583 }
3584
3486 /* Select USB transfer types to use */ 3585 /* Select USB transfer types to use */
3487 if (has_video) { 3586 if (has_video) {
3488 if (!dev->analog_ep_isoc || (try_bulk && dev->analog_ep_bulk)) 3587 if (!dev->analog_ep_isoc || (try_bulk && dev->analog_ep_bulk))
@@ -3501,9 +3600,14 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3501 3600
3502 request_modules(dev); 3601 request_modules(dev);
3503 3602
3504 /* Should be the last thing to do, to avoid newer udev's to 3603 /*
3505 open the device before fully initializing it 3604 * Do it at the end, to reduce dynamic configuration changes during
3605 * the device init. Yet, as request_modules() can be async, the
3606 * topology will likely change after the load of the em28xx subdrivers.
3506 */ 3607 */
3608#ifdef CONFIG_MEDIA_CONTROLLER
3609 retval = media_device_register(dev->media_dev);
3610#endif
3507 3611
3508 return 0; 3612 return 0;
3509 3613
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
index bf5c24467c65..5d209c7c54d5 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -905,6 +905,7 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module,
905 struct em28xx *dev, struct device *device) 905 struct em28xx *dev, struct device *device)
906{ 906{
907 int result; 907 int result;
908 bool create_rf_connector = false;
908 909
909 mutex_init(&dvb->lock); 910 mutex_init(&dvb->lock);
910 911
@@ -916,6 +917,9 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module,
916 dev->name, result); 917 dev->name, result);
917 goto fail_adapter; 918 goto fail_adapter;
918 } 919 }
920#ifdef CONFIG_MEDIA_CONTROLLER_DVB
921 dvb->adapter.mdev = dev->media_dev;
922#endif
919 923
920 /* Ensure all frontends negotiate bus access */ 924 /* Ensure all frontends negotiate bus access */
921 dvb->fe[0]->ops.ts_bus_ctrl = em28xx_dvb_bus_ctrl; 925 dvb->fe[0]->ops.ts_bus_ctrl = em28xx_dvb_bus_ctrl;
@@ -994,8 +998,19 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module,
994 998
995 /* register network adapter */ 999 /* register network adapter */
996 dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx); 1000 dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx);
1001
1002 /* If the analog part won't create RF connectors, DVB will do it */
1003 if (!dev->has_video || (dev->tuner_type == TUNER_ABSENT))
1004 create_rf_connector = true;
1005
1006 result = dvb_create_media_graph(&dvb->adapter, create_rf_connector);
1007 if (result < 0)
1008 goto fail_create_graph;
1009
997 return 0; 1010 return 0;
998 1011
1012fail_create_graph:
1013 dvb_net_release(&dvb->net);
999fail_fe_conn: 1014fail_fe_conn:
1000 dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); 1015 dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem);
1001fail_fe_mem: 1016fail_fe_mem:
@@ -1656,6 +1671,9 @@ static int em28xx_dvb_init(struct em28xx *dev)
1656 memset(&si2157_config, 0, sizeof(si2157_config)); 1671 memset(&si2157_config, 0, sizeof(si2157_config));
1657 si2157_config.fe = dvb->fe[0]; 1672 si2157_config.fe = dvb->fe[0];
1658 si2157_config.if_port = 1; 1673 si2157_config.if_port = 1;
1674#ifdef CONFIG_MEDIA_CONTROLLER_DVB
1675 si2157_config.mdev = dev->media_dev;
1676#endif
1659 memset(&info, 0, sizeof(struct i2c_board_info)); 1677 memset(&info, 0, sizeof(struct i2c_board_info));
1660 strlcpy(info.type, "si2157", I2C_NAME_SIZE); 1678 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
1661 info.addr = 0x60; 1679 info.addr = 0x60;
@@ -1717,6 +1735,9 @@ static int em28xx_dvb_init(struct em28xx *dev)
1717 memset(&si2157_config, 0, sizeof(si2157_config)); 1735 memset(&si2157_config, 0, sizeof(si2157_config));
1718 si2157_config.fe = dvb->fe[0]; 1736 si2157_config.fe = dvb->fe[0];
1719 si2157_config.if_port = 0; 1737 si2157_config.if_port = 0;
1738#ifdef CONFIG_MEDIA_CONTROLLER_DVB
1739 si2157_config.mdev = dev->media_dev;
1740#endif
1720 memset(&info, 0, sizeof(struct i2c_board_info)); 1741 memset(&info, 0, sizeof(struct i2c_board_info));
1721 strlcpy(info.type, "si2146", I2C_NAME_SIZE); 1742 strlcpy(info.type, "si2146", I2C_NAME_SIZE);
1722 info.addr = 0x60; 1743 info.addr = 0x60;
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index 0e86ff423c49..44834b2eff55 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -196,7 +196,6 @@ static void em28xx_wake_i2c(struct em28xx *dev)
196 v4l2_device_call_all(v4l2_dev, 0, core, reset, 0); 196 v4l2_device_call_all(v4l2_dev, 0, core, reset, 0);
197 v4l2_device_call_all(v4l2_dev, 0, video, s_routing, 197 v4l2_device_call_all(v4l2_dev, 0, video, s_routing,
198 INPUT(dev->ctl_input)->vmux, 0, 0); 198 INPUT(dev->ctl_input)->vmux, 0, 0);
199 v4l2_device_call_all(v4l2_dev, 0, video, s_stream, 0);
200} 199}
201 200
202static int em28xx_colorlevels_set_default(struct em28xx *dev) 201static int em28xx_colorlevels_set_default(struct em28xx *dev)
@@ -867,6 +866,147 @@ static void res_free(struct em28xx *dev, enum v4l2_buf_type f_type)
867 em28xx_videodbg("res: put %d\n", res_type); 866 em28xx_videodbg("res: put %d\n", res_type);
868} 867}
869 868
869static void em28xx_v4l2_media_release(struct em28xx *dev)
870{
871#ifdef CONFIG_MEDIA_CONTROLLER
872 int i;
873
874 for (i = 0; i < MAX_EM28XX_INPUT; i++) {
875 if (!INPUT(i)->type)
876 return;
877 media_device_unregister_entity(&dev->input_ent[i]);
878 }
879#endif
880}
881
882/*
883 * Media Controller helper functions
884 */
885
886static int em28xx_enable_analog_tuner(struct em28xx *dev)
887{
888#ifdef CONFIG_MEDIA_CONTROLLER
889 struct media_device *mdev = dev->media_dev;
890 struct em28xx_v4l2 *v4l2 = dev->v4l2;
891 struct media_entity *source;
892 struct media_link *link, *found_link = NULL;
893 int ret, active_links = 0;
894
895 if (!mdev || !v4l2->decoder)
896 return 0;
897
898 /*
899 * This will find the tuner that is connected into the decoder.
900 * Technically, this is not 100% correct, as the device may be
901 * using an analog input instead of the tuner. However, as we can't
902 * do DVB streaming while the DMA engine is being used for V4L2,
903 * this should be enough for the actual needs.
904 */
905 list_for_each_entry(link, &v4l2->decoder->links, list) {
906 if (link->sink->entity == v4l2->decoder) {
907 found_link = link;
908 if (link->flags & MEDIA_LNK_FL_ENABLED)
909 active_links++;
910 break;
911 }
912 }
913
914 if (active_links == 1 || !found_link)
915 return 0;
916
917 source = found_link->source->entity;
918 list_for_each_entry(link, &source->links, list) {
919 struct media_entity *sink;
920 int flags = 0;
921
922 sink = link->sink->entity;
923
924 if (sink == v4l2->decoder)
925 flags = MEDIA_LNK_FL_ENABLED;
926
927 ret = media_entity_setup_link(link, flags);
928 if (ret) {
929 pr_err("Couldn't change link %s->%s to %s. Error %d\n",
930 source->name, sink->name,
931 flags ? "enabled" : "disabled",
932 ret);
933 return ret;
934 } else
935 em28xx_videodbg("link %s->%s was %s\n",
936 source->name, sink->name,
937 flags ? "ENABLED" : "disabled");
938 }
939#endif
940 return 0;
941}
942
943static const char * const iname[] = {
944 [EM28XX_VMUX_COMPOSITE] = "Composite",
945 [EM28XX_VMUX_SVIDEO] = "S-Video",
946 [EM28XX_VMUX_TELEVISION] = "Television",
947 [EM28XX_RADIO] = "Radio",
948};
949
950static void em28xx_v4l2_create_entities(struct em28xx *dev)
951{
952#if defined(CONFIG_MEDIA_CONTROLLER)
953 struct em28xx_v4l2 *v4l2 = dev->v4l2;
954 int ret, i;
955
956 /* Initialize Video, VBI and Radio pads */
957 v4l2->video_pad.flags = MEDIA_PAD_FL_SINK;
958 ret = media_entity_pads_init(&v4l2->vdev.entity, 1, &v4l2->video_pad);
959 if (ret < 0)
960 pr_err("failed to initialize video media entity!\n");
961
962 if (em28xx_vbi_supported(dev)) {
963 v4l2->vbi_pad.flags = MEDIA_PAD_FL_SINK;
964 ret = media_entity_pads_init(&v4l2->vbi_dev.entity, 1,
965 &v4l2->vbi_pad);
966 if (ret < 0)
967 pr_err("failed to initialize vbi media entity!\n");
968 }
969
970 /* Webcams don't have input connectors */
971 if (dev->board.is_webcam)
972 return;
973
974 /* Create entities for each input connector */
975 for (i = 0; i < MAX_EM28XX_INPUT; i++) {
976 struct media_entity *ent = &dev->input_ent[i];
977
978 if (!INPUT(i)->type)
979 break;
980
981 ent->name = iname[INPUT(i)->type];
982 ent->flags = MEDIA_ENT_FL_CONNECTOR;
983 dev->input_pad[i].flags = MEDIA_PAD_FL_SOURCE;
984
985 switch (INPUT(i)->type) {
986 case EM28XX_VMUX_COMPOSITE:
987 ent->function = MEDIA_ENT_F_CONN_COMPOSITE;
988 break;
989 case EM28XX_VMUX_SVIDEO:
990 ent->function = MEDIA_ENT_F_CONN_SVIDEO;
991 break;
992 default: /* EM28XX_VMUX_TELEVISION or EM28XX_RADIO */
993 if (dev->tuner_type != TUNER_ABSENT)
994 ent->function = MEDIA_ENT_F_CONN_RF;
995 break;
996 }
997
998 ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]);
999 if (ret < 0)
1000 pr_err("failed to initialize input pad[%d]!\n", i);
1001
1002 ret = media_device_register_entity(dev->media_dev, ent);
1003 if (ret < 0)
1004 pr_err("failed to register input entity %d!\n", i);
1005 }
1006#endif
1007}
1008
1009
870/* ------------------------------------------------------------------ 1010/* ------------------------------------------------------------------
871 Videobuf2 operations 1011 Videobuf2 operations
872 ------------------------------------------------------------------*/ 1012 ------------------------------------------------------------------*/
@@ -884,6 +1024,9 @@ static int queue_setup(struct vb2_queue *vq,
884 return sizes[0] < size ? -EINVAL : 0; 1024 return sizes[0] < size ? -EINVAL : 0;
885 *nplanes = 1; 1025 *nplanes = 1;
886 sizes[0] = size; 1026 sizes[0] = size;
1027
1028 em28xx_enable_analog_tuner(dev);
1029
887 return 0; 1030 return 0;
888} 1031}
889 1032
@@ -962,6 +1105,9 @@ int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count)
962 f.type = V4L2_TUNER_ANALOG_TV; 1105 f.type = V4L2_TUNER_ANALOG_TV;
963 v4l2_device_call_all(&v4l2->v4l2_dev, 1106 v4l2_device_call_all(&v4l2->v4l2_dev,
964 0, tuner, s_frequency, &f); 1107 0, tuner, s_frequency, &f);
1108
1109 /* Enable video stream at TV decoder */
1110 v4l2_device_call_all(&v4l2->v4l2_dev, 0, video, s_stream, 1);
965 } 1111 }
966 1112
967 v4l2->streaming_users++; 1113 v4l2->streaming_users++;
@@ -981,6 +1127,9 @@ static void em28xx_stop_streaming(struct vb2_queue *vq)
981 res_free(dev, vq->type); 1127 res_free(dev, vq->type);
982 1128
983 if (v4l2->streaming_users-- == 1) { 1129 if (v4l2->streaming_users-- == 1) {
1130 /* Disable video stream at TV decoder */
1131 v4l2_device_call_all(&v4l2->v4l2_dev, 0, video, s_stream, 0);
1132
984 /* Last active user, so shutdown all the URBS */ 1133 /* Last active user, so shutdown all the URBS */
985 em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE); 1134 em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE);
986 } 1135 }
@@ -1013,6 +1162,9 @@ void em28xx_stop_vbi_streaming(struct vb2_queue *vq)
1013 res_free(dev, vq->type); 1162 res_free(dev, vq->type);
1014 1163
1015 if (v4l2->streaming_users-- == 1) { 1164 if (v4l2->streaming_users-- == 1) {
1165 /* Disable video stream at TV decoder */
1166 v4l2_device_call_all(&v4l2->v4l2_dev, 0, video, s_stream, 0);
1167
1016 /* Last active user, so shutdown all the URBS */ 1168 /* Last active user, so shutdown all the URBS */
1017 em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE); 1169 em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE);
1018 } 1170 }
@@ -1224,6 +1376,12 @@ static void scale_to_size(struct em28xx *dev,
1224 1376
1225 *width = (((unsigned long)maxw) << 12) / (hscale + 4096L); 1377 *width = (((unsigned long)maxw) << 12) / (hscale + 4096L);
1226 *height = (((unsigned long)maxh) << 12) / (vscale + 4096L); 1378 *height = (((unsigned long)maxh) << 12) / (vscale + 4096L);
1379
1380 /* Don't let width or height to be zero */
1381 if (*width < 1)
1382 *width = 1;
1383 if (*height < 1)
1384 *height = 1;
1227} 1385}
1228 1386
1229/* ------------------------------------------------------------------ 1387/* ------------------------------------------------------------------
@@ -1299,6 +1457,11 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
1299 v4l_bound_align_image(&width, 48, maxw, 1, &height, 32, maxh, 1457 v4l_bound_align_image(&width, 48, maxw, 1, &height, 32, maxh,
1300 1, 0); 1458 1, 0);
1301 } 1459 }
1460 /* Avoid division by zero at size_to_scale */
1461 if (width < 1)
1462 width = 1;
1463 if (height < 1)
1464 height = 1;
1302 1465
1303 size_to_scale(dev, width, height, &hscale, &vscale); 1466 size_to_scale(dev, width, height, &hscale, &vscale);
1304 scale_to_size(dev, hscale, vscale, &width, &height); 1467 scale_to_size(dev, hscale, vscale, &width, &height);
@@ -1434,18 +1597,6 @@ static int vidioc_s_parm(struct file *file, void *priv,
1434 0, video, s_parm, p); 1597 0, video, s_parm, p);
1435} 1598}
1436 1599
1437static const char *iname[] = {
1438 [EM28XX_VMUX_COMPOSITE1] = "Composite1",
1439 [EM28XX_VMUX_COMPOSITE2] = "Composite2",
1440 [EM28XX_VMUX_COMPOSITE3] = "Composite3",
1441 [EM28XX_VMUX_COMPOSITE4] = "Composite4",
1442 [EM28XX_VMUX_SVIDEO] = "S-Video",
1443 [EM28XX_VMUX_TELEVISION] = "Television",
1444 [EM28XX_VMUX_CABLE] = "Cable TV",
1445 [EM28XX_VMUX_DVB] = "DVB",
1446 [EM28XX_VMUX_DEBUG] = "for debug only",
1447};
1448
1449static int vidioc_enum_input(struct file *file, void *priv, 1600static int vidioc_enum_input(struct file *file, void *priv,
1450 struct v4l2_input *i) 1601 struct v4l2_input *i)
1451{ 1602{
@@ -1463,8 +1614,7 @@ static int vidioc_enum_input(struct file *file, void *priv,
1463 1614
1464 strcpy(i->name, iname[INPUT(n)->type]); 1615 strcpy(i->name, iname[INPUT(n)->type]);
1465 1616
1466 if ((EM28XX_VMUX_TELEVISION == INPUT(n)->type) || 1617 if ((EM28XX_VMUX_TELEVISION == INPUT(n)->type))
1467 (EM28XX_VMUX_CABLE == INPUT(n)->type))
1468 i->type = V4L2_INPUT_TYPE_TUNER; 1618 i->type = V4L2_INPUT_TYPE_TUNER;
1469 1619
1470 i->std = dev->v4l2->vdev.tvnorms; 1620 i->std = dev->v4l2->vdev.tvnorms;
@@ -1961,6 +2111,8 @@ static int em28xx_v4l2_fini(struct em28xx *dev)
1961 2111
1962 em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE); 2112 em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE);
1963 2113
2114 em28xx_v4l2_media_release(dev);
2115
1964 if (video_is_registered(&v4l2->radio_dev)) { 2116 if (video_is_registered(&v4l2->radio_dev)) {
1965 em28xx_info("V4L2 device %s deregistered\n", 2117 em28xx_info("V4L2 device %s deregistered\n",
1966 video_device_node_name(&v4l2->radio_dev)); 2118 video_device_node_name(&v4l2->radio_dev));
@@ -2284,6 +2436,9 @@ static int em28xx_v4l2_init(struct em28xx *dev)
2284 v4l2->dev = dev; 2436 v4l2->dev = dev;
2285 dev->v4l2 = v4l2; 2437 dev->v4l2 = v4l2;
2286 2438
2439#ifdef CONFIG_MEDIA_CONTROLLER
2440 v4l2->v4l2_dev.mdev = dev->media_dev;
2441#endif
2287 ret = v4l2_device_register(&dev->udev->dev, &v4l2->v4l2_dev); 2442 ret = v4l2_device_register(&dev->udev->dev, &v4l2->v4l2_dev);
2288 if (ret < 0) { 2443 if (ret < 0) {
2289 em28xx_errdev("Call to v4l2_device_register() failed!\n"); 2444 em28xx_errdev("Call to v4l2_device_register() failed!\n");
@@ -2556,6 +2711,18 @@ static int em28xx_v4l2_init(struct em28xx *dev)
2556 video_device_node_name(&v4l2->radio_dev)); 2711 video_device_node_name(&v4l2->radio_dev));
2557 } 2712 }
2558 2713
2714 /* Init entities at the Media Controller */
2715 em28xx_v4l2_create_entities(dev);
2716
2717#ifdef CONFIG_MEDIA_CONTROLLER
2718 ret = v4l2_mc_create_media_graph(dev->media_dev);
2719 if (ret) {
2720 em28xx_errdev("failed to create media graph\n");
2721 em28xx_v4l2_media_release(dev);
2722 goto unregister_dev;
2723 }
2724#endif
2725
2559 em28xx_info("V4L2 video device registered as %s\n", 2726 em28xx_info("V4L2 video device registered as %s\n",
2560 video_device_node_name(&v4l2->vdev)); 2727 video_device_node_name(&v4l2->vdev));
2561 2728
@@ -2577,6 +2744,22 @@ static int em28xx_v4l2_init(struct em28xx *dev)
2577 return 0; 2744 return 0;
2578 2745
2579unregister_dev: 2746unregister_dev:
2747 if (video_is_registered(&v4l2->radio_dev)) {
2748 em28xx_info("V4L2 device %s deregistered\n",
2749 video_device_node_name(&v4l2->radio_dev));
2750 video_unregister_device(&v4l2->radio_dev);
2751 }
2752 if (video_is_registered(&v4l2->vbi_dev)) {
2753 em28xx_info("V4L2 device %s deregistered\n",
2754 video_device_node_name(&v4l2->vbi_dev));
2755 video_unregister_device(&v4l2->vbi_dev);
2756 }
2757 if (video_is_registered(&v4l2->vdev)) {
2758 em28xx_info("V4L2 device %s deregistered\n",
2759 video_device_node_name(&v4l2->vdev));
2760 video_unregister_device(&v4l2->vdev);
2761 }
2762
2580 v4l2_ctrl_handler_free(&v4l2->ctrl_handler); 2763 v4l2_ctrl_handler_free(&v4l2->ctrl_handler);
2581 v4l2_device_unregister(&v4l2->v4l2_dev); 2764 v4l2_device_unregister(&v4l2->v4l2_dev);
2582err: 2765err:
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h
index 8ff066c977d9..267444961775 100644
--- a/drivers/media/usb/em28xx/em28xx.h
+++ b/drivers/media/usb/em28xx/em28xx.h
@@ -26,7 +26,7 @@
26#ifndef _EM28XX_H 26#ifndef _EM28XX_H
27#define _EM28XX_H 27#define _EM28XX_H
28 28
29#define EM28XX_VERSION "0.2.1" 29#define EM28XX_VERSION "0.2.2"
30#define DRIVER_DESC "Empia em28xx device driver" 30#define DRIVER_DESC "Empia em28xx device driver"
31 31
32#include <linux/workqueue.h> 32#include <linux/workqueue.h>
@@ -291,15 +291,9 @@ struct em28xx_dmaqueue {
291 291
292#define MAX_EM28XX_INPUT 4 292#define MAX_EM28XX_INPUT 4
293enum enum28xx_itype { 293enum enum28xx_itype {
294 EM28XX_VMUX_COMPOSITE1 = 1, 294 EM28XX_VMUX_COMPOSITE = 1,
295 EM28XX_VMUX_COMPOSITE2,
296 EM28XX_VMUX_COMPOSITE3,
297 EM28XX_VMUX_COMPOSITE4,
298 EM28XX_VMUX_SVIDEO, 295 EM28XX_VMUX_SVIDEO,
299 EM28XX_VMUX_TELEVISION, 296 EM28XX_VMUX_TELEVISION,
300 EM28XX_VMUX_CABLE,
301 EM28XX_VMUX_DVB,
302 EM28XX_VMUX_DEBUG,
303 EM28XX_RADIO, 297 EM28XX_RADIO,
304}; 298};
305 299
@@ -558,6 +552,11 @@ struct em28xx_v4l2 {
558 bool top_field; 552 bool top_field;
559 int vbi_read; 553 int vbi_read;
560 unsigned int field_count; 554 unsigned int field_count;
555
556#ifdef CONFIG_MEDIA_CONTROLLER
557 struct media_pad video_pad, vbi_pad;
558 struct media_entity *decoder;
559#endif
561}; 560};
562 561
563struct em28xx_audio { 562struct em28xx_audio {
@@ -718,6 +717,12 @@ struct em28xx {
718 /* Snapshot button input device */ 717 /* Snapshot button input device */
719 char snapshot_button_path[30]; /* path of the input dev */ 718 char snapshot_button_path[30]; /* path of the input dev */
720 struct input_dev *sbutton_input_dev; 719 struct input_dev *sbutton_input_dev;
720
721#ifdef CONFIG_MEDIA_CONTROLLER
722 struct media_device *media_dev;
723 struct media_entity input_ent[MAX_EM28XX_INPUT];
724 struct media_pad input_pad[MAX_EM28XX_INPUT];
725#endif
721}; 726};
722 727
723#define kref_to_dev(d) container_of(d, struct em28xx, ref) 728#define kref_to_dev(d) container_of(d, struct em28xx, ref)
diff --git a/drivers/media/usb/go7007/go7007-priv.h b/drivers/media/usb/go7007/go7007-priv.h
index 745185eb060b..bebee8ca9981 100644
--- a/drivers/media/usb/go7007/go7007-priv.h
+++ b/drivers/media/usb/go7007/go7007-priv.h
@@ -250,7 +250,7 @@ struct go7007 {
250 struct i2c_adapter i2c_adapter; 250 struct i2c_adapter i2c_adapter;
251 251
252 /* HPI driver */ 252 /* HPI driver */
253 struct go7007_hpi_ops *hpi_ops; 253 const struct go7007_hpi_ops *hpi_ops;
254 void *hpi_context; 254 void *hpi_context;
255 int interrupt_available; 255 int interrupt_available;
256 wait_queue_head_t interrupt_waitq; 256 wait_queue_head_t interrupt_waitq;
diff --git a/drivers/media/usb/go7007/go7007-usb.c b/drivers/media/usb/go7007/go7007-usb.c
index 3dbf14c85c5c..14d3f8c1ce4a 100644
--- a/drivers/media/usb/go7007/go7007-usb.c
+++ b/drivers/media/usb/go7007/go7007-usb.c
@@ -932,7 +932,7 @@ static void go7007_usb_release(struct go7007 *go)
932 kfree(go->hpi_context); 932 kfree(go->hpi_context);
933} 933}
934 934
935static struct go7007_hpi_ops go7007_usb_ezusb_hpi_ops = { 935static const struct go7007_hpi_ops go7007_usb_ezusb_hpi_ops = {
936 .interface_reset = go7007_usb_interface_reset, 936 .interface_reset = go7007_usb_interface_reset,
937 .write_interrupt = go7007_usb_ezusb_write_interrupt, 937 .write_interrupt = go7007_usb_ezusb_write_interrupt,
938 .read_interrupt = go7007_usb_read_interrupt, 938 .read_interrupt = go7007_usb_read_interrupt,
@@ -942,7 +942,7 @@ static struct go7007_hpi_ops go7007_usb_ezusb_hpi_ops = {
942 .release = go7007_usb_release, 942 .release = go7007_usb_release,
943}; 943};
944 944
945static struct go7007_hpi_ops go7007_usb_onboard_hpi_ops = { 945static const struct go7007_hpi_ops go7007_usb_onboard_hpi_ops = {
946 .interface_reset = go7007_usb_interface_reset, 946 .interface_reset = go7007_usb_interface_reset,
947 .write_interrupt = go7007_usb_onboard_write_interrupt, 947 .write_interrupt = go7007_usb_onboard_write_interrupt,
948 .read_interrupt = go7007_usb_read_interrupt, 948 .read_interrupt = go7007_usb_read_interrupt,
diff --git a/drivers/media/usb/gspca/ov519.c b/drivers/media/usb/gspca/ov519.c
index c95f32a0c02b..965372a5ff2f 100644
--- a/drivers/media/usb/gspca/ov519.c
+++ b/drivers/media/usb/gspca/ov519.c
@@ -360,40 +360,6 @@ static const struct v4l2_pix_format ov511_sif_mode[] = {
360 .priv = 0}, 360 .priv = 0},
361}; 361};
362 362
363static const struct v4l2_pix_format ovfx2_vga_mode[] = {
364 {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
365 .bytesperline = 320,
366 .sizeimage = 320 * 240,
367 .colorspace = V4L2_COLORSPACE_SRGB,
368 .priv = 1},
369 {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
370 .bytesperline = 640,
371 .sizeimage = 640 * 480,
372 .colorspace = V4L2_COLORSPACE_SRGB,
373 .priv = 0},
374};
375static const struct v4l2_pix_format ovfx2_cif_mode[] = {
376 {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
377 .bytesperline = 160,
378 .sizeimage = 160 * 120,
379 .colorspace = V4L2_COLORSPACE_SRGB,
380 .priv = 3},
381 {176, 144, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
382 .bytesperline = 176,
383 .sizeimage = 176 * 144,
384 .colorspace = V4L2_COLORSPACE_SRGB,
385 .priv = 1},
386 {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
387 .bytesperline = 320,
388 .sizeimage = 320 * 240,
389 .colorspace = V4L2_COLORSPACE_SRGB,
390 .priv = 2},
391 {352, 288, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
392 .bytesperline = 352,
393 .sizeimage = 352 * 288,
394 .colorspace = V4L2_COLORSPACE_SRGB,
395 .priv = 0},
396};
397static const struct v4l2_pix_format ovfx2_ov2610_mode[] = { 363static const struct v4l2_pix_format ovfx2_ov2610_mode[] = {
398 {800, 600, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 364 {800, 600, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
399 .bytesperline = 800, 365 .bytesperline = 800,
@@ -2042,6 +2008,9 @@ static void reg_w(struct sd *sd, u16 index, u16 value)
2042 if (sd->gspca_dev.usb_err < 0) 2008 if (sd->gspca_dev.usb_err < 0)
2043 return; 2009 return;
2044 2010
2011 /* Avoid things going to fast for the bridge with a xhci host */
2012 udelay(150);
2013
2045 switch (sd->bridge) { 2014 switch (sd->bridge) {
2046 case BRIDGE_OV511: 2015 case BRIDGE_OV511:
2047 case BRIDGE_OV511PLUS: 2016 case BRIDGE_OV511PLUS:
@@ -2103,6 +2072,8 @@ static int reg_r(struct sd *sd, u16 index)
2103 req = 1; 2072 req = 1;
2104 } 2073 }
2105 2074
2075 /* Avoid things going to fast for the bridge with a xhci host */
2076 udelay(150);
2106 ret = usb_control_msg(sd->gspca_dev.dev, 2077 ret = usb_control_msg(sd->gspca_dev.dev,
2107 usb_rcvctrlpipe(sd->gspca_dev.dev, 0), 2078 usb_rcvctrlpipe(sd->gspca_dev.dev, 0),
2108 req, 2079 req,
@@ -2131,6 +2102,8 @@ static int reg_r8(struct sd *sd,
2131 if (sd->gspca_dev.usb_err < 0) 2102 if (sd->gspca_dev.usb_err < 0)
2132 return -1; 2103 return -1;
2133 2104
2105 /* Avoid things going to fast for the bridge with a xhci host */
2106 udelay(150);
2134 ret = usb_control_msg(sd->gspca_dev.dev, 2107 ret = usb_control_msg(sd->gspca_dev.dev,
2135 usb_rcvctrlpipe(sd->gspca_dev.dev, 0), 2108 usb_rcvctrlpipe(sd->gspca_dev.dev, 0),
2136 1, /* REQ_IO */ 2109 1, /* REQ_IO */
@@ -2187,6 +2160,8 @@ static void ov518_reg_w32(struct sd *sd, u16 index, u32 value, int n)
2187 2160
2188 *((__le32 *) sd->gspca_dev.usb_buf) = __cpu_to_le32(value); 2161 *((__le32 *) sd->gspca_dev.usb_buf) = __cpu_to_le32(value);
2189 2162
2163 /* Avoid things going to fast for the bridge with a xhci host */
2164 udelay(150);
2190 ret = usb_control_msg(sd->gspca_dev.dev, 2165 ret = usb_control_msg(sd->gspca_dev.dev,
2191 usb_sndctrlpipe(sd->gspca_dev.dev, 0), 2166 usb_sndctrlpipe(sd->gspca_dev.dev, 0),
2192 1 /* REG_IO */, 2167 1 /* REG_IO */,
diff --git a/drivers/media/usb/gspca/touptek.c b/drivers/media/usb/gspca/touptek.c
index 7bac6bc96063..b8af4370d27c 100644
--- a/drivers/media/usb/gspca/touptek.c
+++ b/drivers/media/usb/gspca/touptek.c
@@ -203,7 +203,7 @@ static int val_reply(struct gspca_dev *gspca_dev, const char *reply, int rc)
203 return -EIO; 203 return -EIO;
204 } 204 }
205 if (reply[0] != 0x08) { 205 if (reply[0] != 0x08) {
206 PERR("Bad reply 0x%02X", reply[0]); 206 PERR("Bad reply 0x%02x", (int)reply[0]);
207 return -EIO; 207 return -EIO;
208 } 208 }
209 return 0; 209 return 0;
@@ -211,7 +211,7 @@ static int val_reply(struct gspca_dev *gspca_dev, const char *reply, int rc)
211 211
212static void reg_w(struct gspca_dev *gspca_dev, u16 value, u16 index) 212static void reg_w(struct gspca_dev *gspca_dev, u16 value, u16 index)
213{ 213{
214 char buff[1]; 214 char *buff = gspca_dev->usb_buf;
215 int rc; 215 int rc;
216 216
217 PDEBUG(D_USBO, 217 PDEBUG(D_USBO,
@@ -219,7 +219,7 @@ static void reg_w(struct gspca_dev *gspca_dev, u16 value, u16 index)
219 value, index); 219 value, index);
220 rc = usb_control_msg(gspca_dev->dev, usb_rcvctrlpipe(gspca_dev->dev, 0), 220 rc = usb_control_msg(gspca_dev->dev, usb_rcvctrlpipe(gspca_dev->dev, 0),
221 0x0B, 0xC0, value, index, buff, 1, 500); 221 0x0B, 0xC0, value, index, buff, 1, 500);
222 PDEBUG(D_USBO, "rc=%d, ret={0x%02X}", rc, buff[0]); 222 PDEBUG(D_USBO, "rc=%d, ret={0x%02x}", rc, (int)buff[0]);
223 if (rc < 0) { 223 if (rc < 0) {
224 PERR("Failed reg_w(0x0B, 0xC0, 0x%04X, 0x%04X) w/ rc %d\n", 224 PERR("Failed reg_w(0x0B, 0xC0, 0x%04X, 0x%04X) w/ rc %d\n",
225 value, index, rc); 225 value, index, rc);
@@ -438,7 +438,7 @@ static void configure_encrypted(struct gspca_dev *gspca_dev)
438static int configure(struct gspca_dev *gspca_dev) 438static int configure(struct gspca_dev *gspca_dev)
439{ 439{
440 int rc; 440 int rc;
441 uint8_t buff[4]; 441 char *buff = gspca_dev->usb_buf;
442 442
443 PDEBUG(D_STREAM, "configure()\n"); 443 PDEBUG(D_STREAM, "configure()\n");
444 444
diff --git a/drivers/media/usb/gspca/w996Xcf.c b/drivers/media/usb/gspca/w996Xcf.c
index fb9fe2ef3a6f..896f1b2b9179 100644
--- a/drivers/media/usb/gspca/w996Xcf.c
+++ b/drivers/media/usb/gspca/w996Xcf.c
@@ -79,6 +79,8 @@ static void w9968cf_write_fsb(struct sd *sd, u16* data)
79 value = *data++; 79 value = *data++;
80 memcpy(sd->gspca_dev.usb_buf, data, 6); 80 memcpy(sd->gspca_dev.usb_buf, data, 6);
81 81
82 /* Avoid things going to fast for the bridge with a xhci host */
83 udelay(150);
82 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0, 84 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0,
83 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, 85 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
84 value, 0x06, sd->gspca_dev.usb_buf, 6, 500); 86 value, 0x06, sd->gspca_dev.usb_buf, 6, 500);
@@ -99,6 +101,9 @@ static void w9968cf_write_sb(struct sd *sd, u16 value)
99 if (sd->gspca_dev.usb_err < 0) 101 if (sd->gspca_dev.usb_err < 0)
100 return; 102 return;
101 103
104 /* Avoid things going to fast for the bridge with a xhci host */
105 udelay(150);
106
102 /* We don't use reg_w here, as that would cause all writes when 107 /* We don't use reg_w here, as that would cause all writes when
103 bitbanging i2c to be logged, making the logs impossible to read */ 108 bitbanging i2c to be logged, making the logs impossible to read */
104 ret = usb_control_msg(sd->gspca_dev.dev, 109 ret = usb_control_msg(sd->gspca_dev.dev,
@@ -126,6 +131,9 @@ static int w9968cf_read_sb(struct sd *sd)
126 if (sd->gspca_dev.usb_err < 0) 131 if (sd->gspca_dev.usb_err < 0)
127 return -1; 132 return -1;
128 133
134 /* Avoid things going to fast for the bridge with a xhci host */
135 udelay(150);
136
129 /* We don't use reg_r here, as the w9968cf is special and has 16 137 /* We don't use reg_r here, as the w9968cf is special and has 16
130 bit registers instead of 8 bit */ 138 bit registers instead of 8 bit */
131 ret = usb_control_msg(sd->gspca_dev.dev, 139 ret = usb_control_msg(sd->gspca_dev.dev,
diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c b/drivers/media/usb/hdpvr/hdpvr-core.c
index 3fc64197b4e6..08f0ca7aa012 100644
--- a/drivers/media/usb/hdpvr/hdpvr-core.c
+++ b/drivers/media/usb/hdpvr/hdpvr-core.c
@@ -273,7 +273,9 @@ static int hdpvr_probe(struct usb_interface *interface,
273 struct hdpvr_device *dev; 273 struct hdpvr_device *dev;
274 struct usb_host_interface *iface_desc; 274 struct usb_host_interface *iface_desc;
275 struct usb_endpoint_descriptor *endpoint; 275 struct usb_endpoint_descriptor *endpoint;
276#if IS_ENABLED(CONFIG_I2C)
276 struct i2c_client *client; 277 struct i2c_client *client;
278#endif
277 size_t buffer_size; 279 size_t buffer_size;
278 int i; 280 int i;
279 int retval = -ENOMEM; 281 int retval = -ENOMEM;
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
index 7dee22deebf3..ba7f02270c83 100644
--- a/drivers/media/usb/hdpvr/hdpvr-video.c
+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
@@ -462,10 +462,8 @@ static ssize_t hdpvr_read(struct file *file, char __user *buffer, size_t count,
462 } 462 }
463 463
464 if (wait_event_interruptible(dev->wait_data, 464 if (wait_event_interruptible(dev->wait_data,
465 buf->status == BUFSTAT_READY)) { 465 buf->status == BUFSTAT_READY))
466 ret = -ERESTARTSYS; 466 return -ERESTARTSYS;
467 goto err;
468 }
469 } 467 }
470 468
471 if (buf->status != BUFSTAT_READY) 469 if (buf->status != BUFSTAT_READY)
diff --git a/drivers/media/usb/msi2500/msi2500.c b/drivers/media/usb/msi2500/msi2500.c
index c104315fdc17..2d33033682af 100644
--- a/drivers/media/usb/msi2500/msi2500.c
+++ b/drivers/media/usb/msi2500/msi2500.c
@@ -839,8 +839,6 @@ static int msi2500_set_usb_adc(struct msi2500_dev *dev)
839 goto err; 839 goto err;
840 840
841 ret = msi2500_ctrl_msg(dev, CMD_WREG, reg3); 841 ret = msi2500_ctrl_msg(dev, CMD_WREG, reg3);
842 if (ret)
843 goto err;
844err: 842err:
845 return ret; 843 return ret;
846} 844}
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-context.c b/drivers/media/usb/pvrusb2/pvrusb2-context.c
index fd888a604462..c45f30715dcd 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-context.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-context.c
@@ -196,7 +196,7 @@ int pvr2_context_global_init(void)
196 pvr2_context_thread_ptr = kthread_run(pvr2_context_thread_func, 196 pvr2_context_thread_ptr = kthread_run(pvr2_context_thread_func,
197 NULL, 197 NULL,
198 "pvrusb2-context"); 198 "pvrusb2-context");
199 return (pvr2_context_thread_ptr ? 0 : -ENOMEM); 199 return IS_ERR(pvr2_context_thread_ptr) ? -ENOMEM : 0;
200} 200}
201 201
202 202
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
index 0533ef20decf..1a093e5953fd 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
@@ -4903,6 +4903,9 @@ static void pvr2_hdw_state_log_state(struct pvr2_hdw *hdw)
4903 printk(KERN_INFO "%s %.*s\n",hdw->name,ccnt,buf); 4903 printk(KERN_INFO "%s %.*s\n",hdw->name,ccnt,buf);
4904 } 4904 }
4905 ccnt = pvr2_hdw_report_clients(hdw, buf, sizeof(buf)); 4905 ccnt = pvr2_hdw_report_clients(hdw, buf, sizeof(buf));
4906 if (ccnt >= sizeof(buf))
4907 ccnt = sizeof(buf);
4908
4906 ucnt = 0; 4909 ucnt = 0;
4907 while (ucnt < ccnt) { 4910 while (ucnt < ccnt) {
4908 lcnt = 0; 4911 lcnt = 0;
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-io.c b/drivers/media/usb/pvrusb2/pvrusb2-io.c
index d860344de84e..e68ce24f27e3 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-io.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-io.c
@@ -473,7 +473,7 @@ static void buffer_complete(struct urb *urb)
473 } 473 }
474 spin_unlock_irqrestore(&sp->list_lock,irq_flags); 474 spin_unlock_irqrestore(&sp->list_lock,irq_flags);
475 pvr2_buffer_set_ready(bp); 475 pvr2_buffer_set_ready(bp);
476 if (sp && sp->callback_func) { 476 if (sp->callback_func) {
477 sp->callback_func(sp->callback_data); 477 sp->callback_func(sp->callback_data);
478 } 478 }
479} 479}
diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c
index 086cf1c7bd7d..18aed5dd325e 100644
--- a/drivers/media/usb/pwc/pwc-if.c
+++ b/drivers/media/usb/pwc/pwc-if.c
@@ -91,6 +91,7 @@ static const struct usb_device_id pwc_device_table [] = {
91 { USB_DEVICE(0x0471, 0x0312) }, 91 { USB_DEVICE(0x0471, 0x0312) },
92 { USB_DEVICE(0x0471, 0x0313) }, /* the 'new' 720K */ 92 { USB_DEVICE(0x0471, 0x0313) }, /* the 'new' 720K */
93 { USB_DEVICE(0x0471, 0x0329) }, /* Philips SPC 900NC PC Camera */ 93 { USB_DEVICE(0x0471, 0x0329) }, /* Philips SPC 900NC PC Camera */
94 { USB_DEVICE(0x0471, 0x032C) }, /* Philips SPC 880NC PC Camera */
94 { USB_DEVICE(0x069A, 0x0001) }, /* Askey */ 95 { USB_DEVICE(0x069A, 0x0001) }, /* Askey */
95 { USB_DEVICE(0x046D, 0x08B0) }, /* Logitech QuickCam Pro 3000 */ 96 { USB_DEVICE(0x046D, 0x08B0) }, /* Logitech QuickCam Pro 3000 */
96 { USB_DEVICE(0x046D, 0x08B1) }, /* Logitech QuickCam Notebook Pro */ 97 { USB_DEVICE(0x046D, 0x08B1) }, /* Logitech QuickCam Notebook Pro */
@@ -810,6 +811,11 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
810 name = "Philips SPC 900NC webcam"; 811 name = "Philips SPC 900NC webcam";
811 type_id = 740; 812 type_id = 740;
812 break; 813 break;
814 case 0x032C:
815 PWC_INFO("Philips SPC 880NC USB webcam detected.\n");
816 name = "Philips SPC 880NC webcam";
817 type_id = 740;
818 break;
813 default: 819 default:
814 return -ENODEV; 820 return -ENODEV;
815 break; 821 break;
diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
index 8abbd3cc8eba..c2e25876e93b 100644
--- a/drivers/media/usb/siano/smsusb.c
+++ b/drivers/media/usb/siano/smsusb.c
@@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
27#include <linux/firmware.h> 27#include <linux/firmware.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/module.h> 29#include <linux/module.h>
30#include <media/media-device.h>
30 31
31#include "sms-cards.h" 32#include "sms-cards.h"
32#include "smsendian.h" 33#include "smsendian.h"
@@ -51,6 +52,9 @@ struct smsusb_urb_t {
51 struct smsusb_device_t *dev; 52 struct smsusb_device_t *dev;
52 53
53 struct urb urb; 54 struct urb urb;
55
56 /* For the bottom half */
57 struct work_struct wq;
54}; 58};
55 59
56struct smsusb_device_t { 60struct smsusb_device_t {
@@ -71,6 +75,18 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
71 struct smsusb_urb_t *surb); 75 struct smsusb_urb_t *surb);
72 76
73/** 77/**
78 * Completing URB's callback handler - bottom half (proccess context)
79 * submits the URB prepared on smsusb_onresponse()
80 */
81static void do_submit_urb(struct work_struct *work)
82{
83 struct smsusb_urb_t *surb = container_of(work, struct smsusb_urb_t, wq);
84 struct smsusb_device_t *dev = surb->dev;
85
86 smsusb_submit_urb(dev, surb);
87}
88
89/**
74 * Completing URB's callback handler - top half (interrupt context) 90 * Completing URB's callback handler - top half (interrupt context)
75 * adds completing sms urb to the global surbs list and activtes the worker 91 * adds completing sms urb to the global surbs list and activtes the worker
76 * thread the surb 92 * thread the surb
@@ -138,13 +154,15 @@ static void smsusb_onresponse(struct urb *urb)
138 154
139 155
140exit_and_resubmit: 156exit_and_resubmit:
141 smsusb_submit_urb(dev, surb); 157 INIT_WORK(&surb->wq, do_submit_urb);
158 schedule_work(&surb->wq);
142} 159}
143 160
144static int smsusb_submit_urb(struct smsusb_device_t *dev, 161static int smsusb_submit_urb(struct smsusb_device_t *dev,
145 struct smsusb_urb_t *surb) 162 struct smsusb_urb_t *surb)
146{ 163{
147 if (!surb->cb) { 164 if (!surb->cb) {
165 /* This function can sleep */
148 surb->cb = smscore_getbuffer(dev->coredev); 166 surb->cb = smscore_getbuffer(dev->coredev);
149 if (!surb->cb) { 167 if (!surb->cb) {
150 pr_err("smscore_getbuffer(...) returned NULL\n"); 168 pr_err("smscore_getbuffer(...) returned NULL\n");
@@ -353,15 +371,7 @@ static void *siano_media_device_register(struct smsusb_device_t *dev,
353 if (!mdev) 371 if (!mdev)
354 return NULL; 372 return NULL;
355 373
356 mdev->dev = &udev->dev; 374 media_device_usb_init(mdev, udev, board->name);
357 strlcpy(mdev->model, board->name, sizeof(mdev->model));
358 if (udev->serial)
359 strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial));
360 strcpy(mdev->bus_info, udev->devpath);
361 mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
362 mdev->driver_version = LINUX_VERSION_CODE;
363
364 media_device_init(mdev);
365 375
366 ret = media_device_register(mdev); 376 ret = media_device_register(mdev);
367 if (ret) { 377 if (ret) {
diff --git a/drivers/media/usb/stk1160/stk1160-video.c b/drivers/media/usb/stk1160/stk1160-video.c
index 46191d5262eb..6ecb0b48423f 100644
--- a/drivers/media/usb/stk1160/stk1160-video.c
+++ b/drivers/media/usb/stk1160/stk1160-video.c
@@ -98,7 +98,6 @@ void stk1160_buffer_done(struct stk1160 *dev)
98 98
99 buf->vb.sequence = dev->sequence++; 99 buf->vb.sequence = dev->sequence++;
100 buf->vb.field = V4L2_FIELD_INTERLACED; 100 buf->vb.field = V4L2_FIELD_INTERLACED;
101 buf->vb.vb2_buf.planes[0].bytesused = buf->bytesused;
102 buf->vb.vb2_buf.timestamp = ktime_get_ns(); 101 buf->vb.vb2_buf.timestamp = ktime_get_ns();
103 102
104 vb2_set_plane_payload(&buf->vb.vb2_buf, 0, buf->bytesused); 103 vb2_set_plane_payload(&buf->vb.vb2_buf, 0, buf->bytesused);
diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c
index 4ebb33943f9a..f6cfad46547e 100644
--- a/drivers/media/usb/usbtv/usbtv-video.c
+++ b/drivers/media/usb/usbtv/usbtv-video.c
@@ -312,20 +312,24 @@ static void usbtv_image_chunk(struct usbtv *usbtv, __be32 *chunk)
312 usbtv_chunk_to_vbuf(frame, &chunk[1], chunk_no, odd); 312 usbtv_chunk_to_vbuf(frame, &chunk[1], chunk_no, odd);
313 usbtv->chunks_done++; 313 usbtv->chunks_done++;
314 314
315 /* Last chunk in a frame, signalling an end */ 315 /* Last chunk in a field */
316 if (odd && chunk_no == usbtv->n_chunks-1) { 316 if (chunk_no == usbtv->n_chunks-1) {
317 int size = vb2_plane_size(&buf->vb.vb2_buf, 0); 317 /* Last chunk in a frame, signalling an end */
318 enum vb2_buffer_state state = usbtv->chunks_done == 318 if (odd && !usbtv->last_odd) {
319 usbtv->n_chunks ? 319 int size = vb2_plane_size(&buf->vb.vb2_buf, 0);
320 VB2_BUF_STATE_DONE : 320 enum vb2_buffer_state state = usbtv->chunks_done ==
321 VB2_BUF_STATE_ERROR; 321 usbtv->n_chunks ?
322 322 VB2_BUF_STATE_DONE :
323 buf->vb.field = V4L2_FIELD_INTERLACED; 323 VB2_BUF_STATE_ERROR;
324 buf->vb.sequence = usbtv->sequence++; 324
325 buf->vb.vb2_buf.timestamp = ktime_get_ns(); 325 buf->vb.field = V4L2_FIELD_INTERLACED;
326 vb2_set_plane_payload(&buf->vb.vb2_buf, 0, size); 326 buf->vb.sequence = usbtv->sequence++;
327 vb2_buffer_done(&buf->vb.vb2_buf, state); 327 buf->vb.vb2_buf.timestamp = ktime_get_ns();
328 list_del(&buf->list); 328 vb2_set_plane_payload(&buf->vb.vb2_buf, 0, size);
329 vb2_buffer_done(&buf->vb.vb2_buf, state);
330 list_del(&buf->list);
331 }
332 usbtv->last_odd = odd;
329 } 333 }
330 334
331 spin_unlock_irqrestore(&usbtv->buflock, flags); 335 spin_unlock_irqrestore(&usbtv->buflock, flags);
@@ -389,6 +393,10 @@ static struct urb *usbtv_setup_iso_transfer(struct usbtv *usbtv)
389 ip->transfer_flags = URB_ISO_ASAP; 393 ip->transfer_flags = URB_ISO_ASAP;
390 ip->transfer_buffer = kzalloc(size * USBTV_ISOC_PACKETS, 394 ip->transfer_buffer = kzalloc(size * USBTV_ISOC_PACKETS,
391 GFP_KERNEL); 395 GFP_KERNEL);
396 if (!ip->transfer_buffer) {
397 usb_free_urb(ip);
398 return NULL;
399 }
392 ip->complete = usbtv_iso_cb; 400 ip->complete = usbtv_iso_cb;
393 ip->number_of_packets = USBTV_ISOC_PACKETS; 401 ip->number_of_packets = USBTV_ISOC_PACKETS;
394 ip->transfer_buffer_length = size * USBTV_ISOC_PACKETS; 402 ip->transfer_buffer_length = size * USBTV_ISOC_PACKETS;
@@ -639,6 +647,7 @@ static int usbtv_start_streaming(struct vb2_queue *vq, unsigned int count)
639 if (usbtv->udev == NULL) 647 if (usbtv->udev == NULL)
640 return -ENODEV; 648 return -ENODEV;
641 649
650 usbtv->last_odd = 1;
642 usbtv->sequence = 0; 651 usbtv->sequence = 0;
643 return usbtv_start(usbtv); 652 return usbtv_start(usbtv);
644} 653}
diff --git a/drivers/media/usb/usbtv/usbtv.h b/drivers/media/usb/usbtv/usbtv.h
index 19cb8bf7c4e9..161b38d5cfa0 100644
--- a/drivers/media/usb/usbtv/usbtv.h
+++ b/drivers/media/usb/usbtv/usbtv.h
@@ -95,6 +95,7 @@ struct usbtv {
95 int width, height; 95 int width, height;
96 int n_chunks; 96 int n_chunks;
97 int iso_size; 97 int iso_size;
98 int last_odd;
98 unsigned int sequence; 99 unsigned int sequence;
99 struct urb *isoc_urbs[USBTV_ISOC_TRANSFERS]; 100 struct urb *isoc_urbs[USBTV_ISOC_TRANSFERS];
100 101
diff --git a/drivers/media/usb/usbvision/usbvision-video.c b/drivers/media/usb/usbvision/usbvision-video.c
index de9ff3bb8edd..12f5ebbd0436 100644
--- a/drivers/media/usb/usbvision/usbvision-video.c
+++ b/drivers/media/usb/usbvision/usbvision-video.c
@@ -162,8 +162,7 @@ MODULE_ALIAS(DRIVER_ALIAS);
162 162
163static inline struct usb_usbvision *cd_to_usbvision(struct device *cd) 163static inline struct usb_usbvision *cd_to_usbvision(struct device *cd)
164{ 164{
165 struct video_device *vdev = 165 struct video_device *vdev = to_video_device(cd);
166 container_of(cd, struct video_device, dev);
167 return video_get_drvdata(vdev); 166 return video_get_drvdata(vdev);
168} 167}
169 168
@@ -177,8 +176,7 @@ static DEVICE_ATTR(version, S_IRUGO, show_version, NULL);
177static ssize_t show_model(struct device *cd, 176static ssize_t show_model(struct device *cd,
178 struct device_attribute *attr, char *buf) 177 struct device_attribute *attr, char *buf)
179{ 178{
180 struct video_device *vdev = 179 struct video_device *vdev = to_video_device(cd);
181 container_of(cd, struct video_device, dev);
182 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 180 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
183 return sprintf(buf, "%s\n", 181 return sprintf(buf, "%s\n",
184 usbvision_device_data[usbvision->dev_model].model_string); 182 usbvision_device_data[usbvision->dev_model].model_string);
@@ -188,8 +186,7 @@ static DEVICE_ATTR(model, S_IRUGO, show_model, NULL);
188static ssize_t show_hue(struct device *cd, 186static ssize_t show_hue(struct device *cd,
189 struct device_attribute *attr, char *buf) 187 struct device_attribute *attr, char *buf)
190{ 188{
191 struct video_device *vdev = 189 struct video_device *vdev = to_video_device(cd);
192 container_of(cd, struct video_device, dev);
193 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 190 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
194 struct v4l2_control ctrl; 191 struct v4l2_control ctrl;
195 ctrl.id = V4L2_CID_HUE; 192 ctrl.id = V4L2_CID_HUE;
@@ -203,8 +200,7 @@ static DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL);
203static ssize_t show_contrast(struct device *cd, 200static ssize_t show_contrast(struct device *cd,
204 struct device_attribute *attr, char *buf) 201 struct device_attribute *attr, char *buf)
205{ 202{
206 struct video_device *vdev = 203 struct video_device *vdev = to_video_device(cd);
207 container_of(cd, struct video_device, dev);
208 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 204 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
209 struct v4l2_control ctrl; 205 struct v4l2_control ctrl;
210 ctrl.id = V4L2_CID_CONTRAST; 206 ctrl.id = V4L2_CID_CONTRAST;
@@ -218,8 +214,7 @@ static DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL);
218static ssize_t show_brightness(struct device *cd, 214static ssize_t show_brightness(struct device *cd,
219 struct device_attribute *attr, char *buf) 215 struct device_attribute *attr, char *buf)
220{ 216{
221 struct video_device *vdev = 217 struct video_device *vdev = to_video_device(cd);
222 container_of(cd, struct video_device, dev);
223 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 218 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
224 struct v4l2_control ctrl; 219 struct v4l2_control ctrl;
225 ctrl.id = V4L2_CID_BRIGHTNESS; 220 ctrl.id = V4L2_CID_BRIGHTNESS;
@@ -233,8 +228,7 @@ static DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL);
233static ssize_t show_saturation(struct device *cd, 228static ssize_t show_saturation(struct device *cd,
234 struct device_attribute *attr, char *buf) 229 struct device_attribute *attr, char *buf)
235{ 230{
236 struct video_device *vdev = 231 struct video_device *vdev = to_video_device(cd);
237 container_of(cd, struct video_device, dev);
238 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 232 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
239 struct v4l2_control ctrl; 233 struct v4l2_control ctrl;
240 ctrl.id = V4L2_CID_SATURATION; 234 ctrl.id = V4L2_CID_SATURATION;
@@ -248,8 +242,7 @@ static DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL);
248static ssize_t show_streaming(struct device *cd, 242static ssize_t show_streaming(struct device *cd,
249 struct device_attribute *attr, char *buf) 243 struct device_attribute *attr, char *buf)
250{ 244{
251 struct video_device *vdev = 245 struct video_device *vdev = to_video_device(cd);
252 container_of(cd, struct video_device, dev);
253 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 246 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
254 return sprintf(buf, "%s\n", 247 return sprintf(buf, "%s\n",
255 YES_NO(usbvision->streaming == stream_on ? 1 : 0)); 248 YES_NO(usbvision->streaming == stream_on ? 1 : 0));
@@ -259,8 +252,7 @@ static DEVICE_ATTR(streaming, S_IRUGO, show_streaming, NULL);
259static ssize_t show_compression(struct device *cd, 252static ssize_t show_compression(struct device *cd,
260 struct device_attribute *attr, char *buf) 253 struct device_attribute *attr, char *buf)
261{ 254{
262 struct video_device *vdev = 255 struct video_device *vdev = to_video_device(cd);
263 container_of(cd, struct video_device, dev);
264 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 256 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
265 return sprintf(buf, "%s\n", 257 return sprintf(buf, "%s\n",
266 YES_NO(usbvision->isoc_mode == ISOC_MODE_COMPRESS)); 258 YES_NO(usbvision->isoc_mode == ISOC_MODE_COMPRESS));
@@ -270,8 +262,7 @@ static DEVICE_ATTR(compression, S_IRUGO, show_compression, NULL);
270static ssize_t show_device_bridge(struct device *cd, 262static ssize_t show_device_bridge(struct device *cd,
271 struct device_attribute *attr, char *buf) 263 struct device_attribute *attr, char *buf)
272{ 264{
273 struct video_device *vdev = 265 struct video_device *vdev = to_video_device(cd);
274 container_of(cd, struct video_device, dev);
275 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 266 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
276 return sprintf(buf, "%d\n", usbvision->bridge_type); 267 return sprintf(buf, "%d\n", usbvision->bridge_type);
277} 268}
@@ -1156,6 +1147,7 @@ static int usbvision_radio_close(struct file *file)
1156 usbvision_audio_off(usbvision); 1147 usbvision_audio_off(usbvision);
1157 usbvision->radio = 0; 1148 usbvision->radio = 0;
1158 usbvision->user--; 1149 usbvision->user--;
1150 mutex_unlock(&usbvision->v4l2_lock);
1159 1151
1160 if (usbvision->remove_pending) { 1152 if (usbvision->remove_pending) {
1161 printk(KERN_INFO "%s: Final disconnect\n", __func__); 1153 printk(KERN_INFO "%s: Final disconnect\n", __func__);
@@ -1164,7 +1156,6 @@ static int usbvision_radio_close(struct file *file)
1164 return 0; 1156 return 0;
1165 } 1157 }
1166 1158
1167 mutex_unlock(&usbvision->v4l2_lock);
1168 PDEBUG(DBG_IO, "success"); 1159 PDEBUG(DBG_IO, "success");
1169 return v4l2_fh_release(file); 1160 return v4l2_fh_release(file);
1170} 1161}
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index 4e7148815a78..451e84e962e2 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -148,6 +148,26 @@ static struct uvc_format_desc uvc_fmts[] = {
148 .guid = UVC_GUID_FORMAT_H264, 148 .guid = UVC_GUID_FORMAT_H264,
149 .fcc = V4L2_PIX_FMT_H264, 149 .fcc = V4L2_PIX_FMT_H264,
150 }, 150 },
151 {
152 .name = "Greyscale 8 L/R (Y8I)",
153 .guid = UVC_GUID_FORMAT_Y8I,
154 .fcc = V4L2_PIX_FMT_Y8I,
155 },
156 {
157 .name = "Greyscale 12 L/R (Y12I)",
158 .guid = UVC_GUID_FORMAT_Y12I,
159 .fcc = V4L2_PIX_FMT_Y12I,
160 },
161 {
162 .name = "Depth data 16-bit (Z16)",
163 .guid = UVC_GUID_FORMAT_Z16,
164 .fcc = V4L2_PIX_FMT_Z16,
165 },
166 {
167 .name = "Bayer 10-bit (SRGGB10P)",
168 .guid = UVC_GUID_FORMAT_RW10,
169 .fcc = V4L2_PIX_FMT_SRGGB10P,
170 },
151}; 171};
152 172
153/* ------------------------------------------------------------------------ 173/* ------------------------------------------------------------------------
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index f0f2391e1b43..7e4d3eea371b 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -119,6 +119,18 @@
119#define UVC_GUID_FORMAT_H264 \ 119#define UVC_GUID_FORMAT_H264 \
120 { 'H', '2', '6', '4', 0x00, 0x00, 0x10, 0x00, \ 120 { 'H', '2', '6', '4', 0x00, 0x00, 0x10, 0x00, \
121 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} 121 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
122#define UVC_GUID_FORMAT_Y8I \
123 { 'Y', '8', 'I', ' ', 0x00, 0x00, 0x10, 0x00, \
124 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
125#define UVC_GUID_FORMAT_Y12I \
126 { 'Y', '1', '2', 'I', 0x00, 0x00, 0x10, 0x00, \
127 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
128#define UVC_GUID_FORMAT_Z16 \
129 { 'Z', '1', '6', ' ', 0x00, 0x00, 0x10, 0x00, \
130 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
131#define UVC_GUID_FORMAT_RW10 \
132 { 'R', 'W', '1', '0', 0x00, 0x00, 0x10, 0x00, \
133 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
122 134
123/* ------------------------------------------------------------------------ 135/* ------------------------------------------------------------------------
124 * Driver specific constants. 136 * Driver specific constants.
diff --git a/drivers/media/v4l2-core/Kconfig b/drivers/media/v4l2-core/Kconfig
index 9beece00869b..29b3436d0910 100644
--- a/drivers/media/v4l2-core/Kconfig
+++ b/drivers/media/v4l2-core/Kconfig
@@ -37,7 +37,6 @@ config VIDEO_PCI_SKELETON
37# Used by drivers that need tuner.ko 37# Used by drivers that need tuner.ko
38config VIDEO_TUNER 38config VIDEO_TUNER
39 tristate 39 tristate
40 depends on MEDIA_TUNER
41 40
42# Used by drivers that need v4l2-mem2mem.ko 41# Used by drivers that need v4l2-mem2mem.ko
43config V4L2_MEM2MEM_DEV 42config V4L2_MEM2MEM_DEV
diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile
index 1dc8bba2b198..795a5352761d 100644
--- a/drivers/media/v4l2-core/Makefile
+++ b/drivers/media/v4l2-core/Makefile
@@ -16,6 +16,7 @@ endif
16ifeq ($(CONFIG_TRACEPOINTS),y) 16ifeq ($(CONFIG_TRACEPOINTS),y)
17 videodev-objs += vb2-trace.o v4l2-trace.o 17 videodev-objs += vb2-trace.o v4l2-trace.o
18endif 18endif
19videodev-$(CONFIG_MEDIA_CONTROLLER) += v4l2-mc.o
19 20
20obj-$(CONFIG_VIDEO_V4L2) += videodev.o 21obj-$(CONFIG_VIDEO_V4L2) += videodev.o
21obj-$(CONFIG_VIDEO_V4L2) += v4l2-common.o 22obj-$(CONFIG_VIDEO_V4L2) += v4l2-common.o
diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
index 76496fd282aa..731487be5baa 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -696,16 +696,32 @@ static int tuner_probe(struct i2c_client *client,
696 /* Should be just before return */ 696 /* Should be just before return */
697register_client: 697register_client:
698#if defined(CONFIG_MEDIA_CONTROLLER) 698#if defined(CONFIG_MEDIA_CONTROLLER)
699 t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
700 t->pad[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
701 t->sd.entity.function = MEDIA_ENT_F_TUNER;
702 t->sd.entity.name = t->name; 699 t->sd.entity.name = t->name;
700 /*
701 * Handle the special case where the tuner has actually
702 * two stages: the PLL to tune into a frequency and the
703 * IF-PLL demodulator (tda988x).
704 */
705 if (t->type == TUNER_TDA9887) {
706 t->pad[IF_VID_DEC_PAD_IF_INPUT].flags = MEDIA_PAD_FL_SINK;
707 t->pad[IF_VID_DEC_PAD_OUT].flags = MEDIA_PAD_FL_SOURCE;
708 ret = media_entity_pads_init(&t->sd.entity,
709 IF_VID_DEC_PAD_NUM_PADS,
710 &t->pad[0]);
711 t->sd.entity.function = MEDIA_ENT_F_IF_VID_DECODER;
712 } else {
713 t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
714 t->pad[TUNER_PAD_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
715 t->pad[TUNER_PAD_AUD_OUT].flags = MEDIA_PAD_FL_SOURCE;
716 ret = media_entity_pads_init(&t->sd.entity, TUNER_NUM_PADS,
717 &t->pad[0]);
718 t->sd.entity.function = MEDIA_ENT_F_TUNER;
719 }
703 720
704 ret = media_entity_pads_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]);
705 if (ret < 0) { 721 if (ret < 0) {
706 tuner_err("failed to initialize media entity!\n"); 722 tuner_err("failed to initialize media entity!\n");
707 kfree(t); 723 kfree(t);
708 return -ENODEV; 724 return ret;
709 } 725 }
710#endif 726#endif
711 /* Sets a default mode */ 727 /* Sets a default mode */
diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
index 5bada202b2d3..a4b224d92572 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -119,6 +119,13 @@ static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier,
119 return ret; 119 return ret;
120 } 120 }
121 121
122 ret = v4l2_subdev_call(sd, core, registered_async);
123 if (ret < 0 && ret != -ENOIOCTLCMD) {
124 if (notifier->unbind)
125 notifier->unbind(notifier, sd, asd);
126 return ret;
127 }
128
122 if (list_empty(&notifier->waiting) && notifier->complete) 129 if (list_empty(&notifier->waiting) && notifier->complete)
123 return notifier->complete(notifier); 130 return notifier->complete(notifier);
124 131
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
index 8fd84a67478a..019644ff627d 100644
--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
@@ -415,7 +415,8 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
415 get_user(kp->index, &up->index) || 415 get_user(kp->index, &up->index) ||
416 get_user(kp->type, &up->type) || 416 get_user(kp->type, &up->type) ||
417 get_user(kp->flags, &up->flags) || 417 get_user(kp->flags, &up->flags) ||
418 get_user(kp->memory, &up->memory)) 418 get_user(kp->memory, &up->memory) ||
419 get_user(kp->length, &up->length))
419 return -EFAULT; 420 return -EFAULT;
420 421
421 if (V4L2_TYPE_IS_OUTPUT(kp->type)) 422 if (V4L2_TYPE_IS_OUTPUT(kp->type))
@@ -427,9 +428,6 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
427 return -EFAULT; 428 return -EFAULT;
428 429
429 if (V4L2_TYPE_IS_MULTIPLANAR(kp->type)) { 430 if (V4L2_TYPE_IS_MULTIPLANAR(kp->type)) {
430 if (get_user(kp->length, &up->length))
431 return -EFAULT;
432
433 num_planes = kp->length; 431 num_planes = kp->length;
434 if (num_planes == 0) { 432 if (num_planes == 0) {
435 kp->m.planes = NULL; 433 kp->m.planes = NULL;
@@ -462,16 +460,14 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
462 } else { 460 } else {
463 switch (kp->memory) { 461 switch (kp->memory) {
464 case V4L2_MEMORY_MMAP: 462 case V4L2_MEMORY_MMAP:
465 if (get_user(kp->length, &up->length) || 463 if (get_user(kp->m.offset, &up->m.offset))
466 get_user(kp->m.offset, &up->m.offset))
467 return -EFAULT; 464 return -EFAULT;
468 break; 465 break;
469 case V4L2_MEMORY_USERPTR: 466 case V4L2_MEMORY_USERPTR:
470 { 467 {
471 compat_long_t tmp; 468 compat_long_t tmp;
472 469
473 if (get_user(kp->length, &up->length) || 470 if (get_user(tmp, &up->m.userptr))
474 get_user(tmp, &up->m.userptr))
475 return -EFAULT; 471 return -EFAULT;
476 472
477 kp->m.userptr = (unsigned long)compat_ptr(tmp); 473 kp->m.userptr = (unsigned long)compat_ptr(tmp);
@@ -513,7 +509,8 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
513 copy_to_user(&up->timecode, &kp->timecode, sizeof(struct v4l2_timecode)) || 509 copy_to_user(&up->timecode, &kp->timecode, sizeof(struct v4l2_timecode)) ||
514 put_user(kp->sequence, &up->sequence) || 510 put_user(kp->sequence, &up->sequence) ||
515 put_user(kp->reserved2, &up->reserved2) || 511 put_user(kp->reserved2, &up->reserved2) ||
516 put_user(kp->reserved, &up->reserved)) 512 put_user(kp->reserved, &up->reserved) ||
513 put_user(kp->length, &up->length))
517 return -EFAULT; 514 return -EFAULT;
518 515
519 if (V4L2_TYPE_IS_MULTIPLANAR(kp->type)) { 516 if (V4L2_TYPE_IS_MULTIPLANAR(kp->type)) {
@@ -536,13 +533,11 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
536 } else { 533 } else {
537 switch (kp->memory) { 534 switch (kp->memory) {
538 case V4L2_MEMORY_MMAP: 535 case V4L2_MEMORY_MMAP:
539 if (put_user(kp->length, &up->length) || 536 if (put_user(kp->m.offset, &up->m.offset))
540 put_user(kp->m.offset, &up->m.offset))
541 return -EFAULT; 537 return -EFAULT;
542 break; 538 break;
543 case V4L2_MEMORY_USERPTR: 539 case V4L2_MEMORY_USERPTR:
544 if (put_user(kp->length, &up->length) || 540 if (put_user(kp->m.userptr, &up->m.userptr))
545 put_user(kp->m.userptr, &up->m.userptr))
546 return -EFAULT; 541 return -EFAULT;
547 break; 542 break;
548 case V4L2_MEMORY_OVERLAY: 543 case V4L2_MEMORY_OVERLAY:
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index c9d5537b6af7..8b321e0aae62 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -462,6 +462,14 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
462 "RGB full range (0-255)", 462 "RGB full range (0-255)",
463 NULL, 463 NULL,
464 }; 464 };
465 static const char * const dv_it_content_type[] = {
466 "Graphics",
467 "Photo",
468 "Cinema",
469 "Game",
470 "No IT Content",
471 NULL,
472 };
465 static const char * const detect_md_mode[] = { 473 static const char * const detect_md_mode[] = {
466 "Disabled", 474 "Disabled",
467 "Global", 475 "Global",
@@ -560,6 +568,9 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
560 case V4L2_CID_DV_TX_RGB_RANGE: 568 case V4L2_CID_DV_TX_RGB_RANGE:
561 case V4L2_CID_DV_RX_RGB_RANGE: 569 case V4L2_CID_DV_RX_RGB_RANGE:
562 return dv_rgb_range; 570 return dv_rgb_range;
571 case V4L2_CID_DV_TX_IT_CONTENT_TYPE:
572 case V4L2_CID_DV_RX_IT_CONTENT_TYPE:
573 return dv_it_content_type;
563 case V4L2_CID_DETECT_MD_MODE: 574 case V4L2_CID_DETECT_MD_MODE:
564 return detect_md_mode; 575 return detect_md_mode;
565 576
@@ -747,6 +758,7 @@ const char *v4l2_ctrl_get_name(u32 id)
747 case V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE: return "Horizontal MV Search Range"; 758 case V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE: return "Horizontal MV Search Range";
748 case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE: return "Vertical MV Search Range"; 759 case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE: return "Vertical MV Search Range";
749 case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER: return "Repeat Sequence Header"; 760 case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER: return "Repeat Sequence Header";
761 case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME: return "Force Key Frame";
750 762
751 /* VPX controls */ 763 /* VPX controls */
752 case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS: return "VPX Number of Partitions"; 764 case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS: return "VPX Number of Partitions";
@@ -881,8 +893,10 @@ const char *v4l2_ctrl_get_name(u32 id)
881 case V4L2_CID_DV_TX_EDID_PRESENT: return "EDID Present"; 893 case V4L2_CID_DV_TX_EDID_PRESENT: return "EDID Present";
882 case V4L2_CID_DV_TX_MODE: return "Transmit Mode"; 894 case V4L2_CID_DV_TX_MODE: return "Transmit Mode";
883 case V4L2_CID_DV_TX_RGB_RANGE: return "Tx RGB Quantization Range"; 895 case V4L2_CID_DV_TX_RGB_RANGE: return "Tx RGB Quantization Range";
896 case V4L2_CID_DV_TX_IT_CONTENT_TYPE: return "Tx IT Content Type";
884 case V4L2_CID_DV_RX_POWER_PRESENT: return "Power Present"; 897 case V4L2_CID_DV_RX_POWER_PRESENT: return "Power Present";
885 case V4L2_CID_DV_RX_RGB_RANGE: return "Rx RGB Quantization Range"; 898 case V4L2_CID_DV_RX_RGB_RANGE: return "Rx RGB Quantization Range";
899 case V4L2_CID_DV_RX_IT_CONTENT_TYPE: return "Rx IT Content Type";
886 900
887 case V4L2_CID_FM_RX_CLASS: return "FM Radio Receiver Controls"; 901 case V4L2_CID_FM_RX_CLASS: return "FM Radio Receiver Controls";
888 case V4L2_CID_TUNE_DEEMPHASIS: return "De-Emphasis"; 902 case V4L2_CID_TUNE_DEEMPHASIS: return "De-Emphasis";
@@ -985,6 +999,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
985 case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE: 999 case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE:
986 *type = V4L2_CTRL_TYPE_INTEGER; 1000 *type = V4L2_CTRL_TYPE_INTEGER;
987 break; 1001 break;
1002 case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME:
988 case V4L2_CID_PAN_RESET: 1003 case V4L2_CID_PAN_RESET:
989 case V4L2_CID_TILT_RESET: 1004 case V4L2_CID_TILT_RESET:
990 case V4L2_CID_FLASH_STROBE: 1005 case V4L2_CID_FLASH_STROBE:
@@ -1038,7 +1053,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
1038 case V4L2_CID_SCENE_MODE: 1053 case V4L2_CID_SCENE_MODE:
1039 case V4L2_CID_DV_TX_MODE: 1054 case V4L2_CID_DV_TX_MODE:
1040 case V4L2_CID_DV_TX_RGB_RANGE: 1055 case V4L2_CID_DV_TX_RGB_RANGE:
1056 case V4L2_CID_DV_TX_IT_CONTENT_TYPE:
1041 case V4L2_CID_DV_RX_RGB_RANGE: 1057 case V4L2_CID_DV_RX_RGB_RANGE:
1058 case V4L2_CID_DV_RX_IT_CONTENT_TYPE:
1042 case V4L2_CID_TEST_PATTERN: 1059 case V4L2_CID_TEST_PATTERN:
1043 case V4L2_CID_TUNE_DEEMPHASIS: 1060 case V4L2_CID_TUNE_DEEMPHASIS:
1044 case V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL: 1061 case V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL:
@@ -1185,6 +1202,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
1185 case V4L2_CID_DV_TX_RXSENSE: 1202 case V4L2_CID_DV_TX_RXSENSE:
1186 case V4L2_CID_DV_TX_EDID_PRESENT: 1203 case V4L2_CID_DV_TX_EDID_PRESENT:
1187 case V4L2_CID_DV_RX_POWER_PRESENT: 1204 case V4L2_CID_DV_RX_POWER_PRESENT:
1205 case V4L2_CID_DV_RX_IT_CONTENT_TYPE:
1188 case V4L2_CID_RDS_RX_PTY: 1206 case V4L2_CID_RDS_RX_PTY:
1189 case V4L2_CID_RDS_RX_PS_NAME: 1207 case V4L2_CID_RDS_RX_PS_NAME:
1190 case V4L2_CID_RDS_RX_RADIO_TEXT: 1208 case V4L2_CID_RDS_RX_RADIO_TEXT:
@@ -2211,22 +2229,6 @@ struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
2211} 2229}
2212EXPORT_SYMBOL(v4l2_ctrl_new_int_menu); 2230EXPORT_SYMBOL(v4l2_ctrl_new_int_menu);
2213 2231
2214/* Add a control from another handler to this handler */
2215struct v4l2_ctrl *v4l2_ctrl_add_ctrl(struct v4l2_ctrl_handler *hdl,
2216 struct v4l2_ctrl *ctrl)
2217{
2218 if (hdl == NULL || hdl->error)
2219 return NULL;
2220 if (ctrl == NULL) {
2221 handler_set_err(hdl, -EINVAL);
2222 return NULL;
2223 }
2224 if (ctrl->handler == hdl)
2225 return ctrl;
2226 return handler_new_ref(hdl, ctrl) ? NULL : ctrl;
2227}
2228EXPORT_SYMBOL(v4l2_ctrl_add_ctrl);
2229
2230/* Add the controls from another handler to our own. */ 2232/* Add the controls from another handler to our own. */
2231int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl, 2233int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
2232 struct v4l2_ctrl_handler *add, 2234 struct v4l2_ctrl_handler *add,
diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c b/drivers/media/v4l2-core/v4l2-dv-timings.c
index ec258b73001a..889de0a32152 100644
--- a/drivers/media/v4l2-core/v4l2-dv-timings.c
+++ b/drivers/media/v4l2-core/v4l2-dv-timings.c
@@ -165,7 +165,8 @@ bool v4l2_valid_dv_timings(const struct v4l2_dv_timings *t,
165 bt->width > cap->max_width || 165 bt->width > cap->max_width ||
166 bt->pixelclock < cap->min_pixelclock || 166 bt->pixelclock < cap->min_pixelclock ||
167 bt->pixelclock > cap->max_pixelclock || 167 bt->pixelclock > cap->max_pixelclock ||
168 (cap->standards && bt->standards && 168 (!(caps & V4L2_DV_BT_CAP_CUSTOM) &&
169 cap->standards && bt->standards &&
169 !(bt->standards & cap->standards)) || 170 !(bt->standards & cap->standards)) ||
170 (bt->interlaced && !(caps & V4L2_DV_BT_CAP_INTERLACED)) || 171 (bt->interlaced && !(caps & V4L2_DV_BT_CAP_INTERLACED)) ||
171 (!bt->interlaced && !(caps & V4L2_DV_BT_CAP_PROGRESSIVE))) 172 (!bt->interlaced && !(caps & V4L2_DV_BT_CAP_PROGRESSIVE)))
diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c
index c97067a25bd2..c183f0996fa1 100644
--- a/drivers/media/v4l2-core/v4l2-fh.c
+++ b/drivers/media/v4l2-core/v4l2-fh.c
@@ -29,6 +29,7 @@
29#include <media/v4l2-fh.h> 29#include <media/v4l2-fh.h>
30#include <media/v4l2-event.h> 30#include <media/v4l2-event.h>
31#include <media/v4l2-ioctl.h> 31#include <media/v4l2-ioctl.h>
32#include <media/v4l2-mc.h>
32 33
33void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev) 34void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev)
34{ 35{
@@ -92,6 +93,7 @@ void v4l2_fh_exit(struct v4l2_fh *fh)
92{ 93{
93 if (fh->vdev == NULL) 94 if (fh->vdev == NULL)
94 return; 95 return;
96 v4l_disable_media_source(fh->vdev);
95 v4l2_event_unsubscribe_all(fh); 97 v4l2_event_unsubscribe_all(fh);
96 fh->vdev = NULL; 98 fh->vdev = NULL;
97} 99}
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 8a018c6dd16a..170dd68d27f4 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -27,6 +27,7 @@
27#include <media/v4l2-event.h> 27#include <media/v4l2-event.h>
28#include <media/v4l2-device.h> 28#include <media/v4l2-device.h>
29#include <media/videobuf2-v4l2.h> 29#include <media/videobuf2-v4l2.h>
30#include <media/v4l2-mc.h>
30 31
31#include <trace/events/v4l2.h> 32#include <trace/events/v4l2.h>
32 33
@@ -1041,6 +1042,12 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops,
1041static int v4l_s_input(const struct v4l2_ioctl_ops *ops, 1042static int v4l_s_input(const struct v4l2_ioctl_ops *ops,
1042 struct file *file, void *fh, void *arg) 1043 struct file *file, void *fh, void *arg)
1043{ 1044{
1045 struct video_device *vfd = video_devdata(file);
1046 int ret;
1047
1048 ret = v4l_enable_media_source(vfd);
1049 if (ret)
1050 return ret;
1044 return ops->vidioc_s_input(file, fh, *(unsigned int *)arg); 1051 return ops->vidioc_s_input(file, fh, *(unsigned int *)arg);
1045} 1052}
1046 1053
@@ -1165,7 +1172,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
1165 case V4L2_PIX_FMT_YVYU: descr = "YVYU 4:2:2"; break; 1172 case V4L2_PIX_FMT_YVYU: descr = "YVYU 4:2:2"; break;
1166 case V4L2_PIX_FMT_UYVY: descr = "UYVY 4:2:2"; break; 1173 case V4L2_PIX_FMT_UYVY: descr = "UYVY 4:2:2"; break;
1167 case V4L2_PIX_FMT_VYUY: descr = "VYUY 4:2:2"; break; 1174 case V4L2_PIX_FMT_VYUY: descr = "VYUY 4:2:2"; break;
1168 case V4L2_PIX_FMT_YUV422P: descr = "Planar YVU 4:2:2"; break; 1175 case V4L2_PIX_FMT_YUV422P: descr = "Planar YUV 4:2:2"; break;
1169 case V4L2_PIX_FMT_YUV411P: descr = "Planar YUV 4:1:1"; break; 1176 case V4L2_PIX_FMT_YUV411P: descr = "Planar YUV 4:1:1"; break;
1170 case V4L2_PIX_FMT_Y41P: descr = "YUV 4:1:1 (Packed)"; break; 1177 case V4L2_PIX_FMT_Y41P: descr = "YUV 4:1:1 (Packed)"; break;
1171 case V4L2_PIX_FMT_YUV444: descr = "16-bit A/XYUV 4-4-4-4"; break; 1178 case V4L2_PIX_FMT_YUV444: descr = "16-bit A/XYUV 4-4-4-4"; break;
@@ -1191,6 +1198,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
1191 case V4L2_PIX_FMT_NV12MT_16X16: descr = "Y/CbCr 4:2:0 (16x16 MB, N-C)"; break; 1198 case V4L2_PIX_FMT_NV12MT_16X16: descr = "Y/CbCr 4:2:0 (16x16 MB, N-C)"; break;
1192 case V4L2_PIX_FMT_YUV420M: descr = "Planar YUV 4:2:0 (N-C)"; break; 1199 case V4L2_PIX_FMT_YUV420M: descr = "Planar YUV 4:2:0 (N-C)"; break;
1193 case V4L2_PIX_FMT_YVU420M: descr = "Planar YVU 4:2:0 (N-C)"; break; 1200 case V4L2_PIX_FMT_YVU420M: descr = "Planar YVU 4:2:0 (N-C)"; break;
1201 case V4L2_PIX_FMT_YUV422M: descr = "Planar YUV 4:2:2 (N-C)"; break;
1202 case V4L2_PIX_FMT_YVU422M: descr = "Planar YVU 4:2:2 (N-C)"; break;
1203 case V4L2_PIX_FMT_YUV444M: descr = "Planar YUV 4:4:4 (N-C)"; break;
1204 case V4L2_PIX_FMT_YVU444M: descr = "Planar YVU 4:4:4 (N-C)"; break;
1194 case V4L2_PIX_FMT_SBGGR8: descr = "8-bit Bayer BGBG/GRGR"; break; 1205 case V4L2_PIX_FMT_SBGGR8: descr = "8-bit Bayer BGBG/GRGR"; break;
1195 case V4L2_PIX_FMT_SGBRG8: descr = "8-bit Bayer GBGB/RGRG"; break; 1206 case V4L2_PIX_FMT_SGBRG8: descr = "8-bit Bayer GBGB/RGRG"; break;
1196 case V4L2_PIX_FMT_SGRBG8: descr = "8-bit Bayer GRGR/BGBG"; break; 1207 case V4L2_PIX_FMT_SGRBG8: descr = "8-bit Bayer GRGR/BGBG"; break;
@@ -1448,6 +1459,9 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
1448 bool is_tx = vfd->vfl_dir != VFL_DIR_RX; 1459 bool is_tx = vfd->vfl_dir != VFL_DIR_RX;
1449 int ret; 1460 int ret;
1450 1461
1462 ret = v4l_enable_media_source(vfd);
1463 if (ret)
1464 return ret;
1451 v4l_sanitize_format(p); 1465 v4l_sanitize_format(p);
1452 1466
1453 switch (p->type) { 1467 switch (p->type) {
@@ -1637,7 +1651,11 @@ static int v4l_s_tuner(const struct v4l2_ioctl_ops *ops,
1637{ 1651{
1638 struct video_device *vfd = video_devdata(file); 1652 struct video_device *vfd = video_devdata(file);
1639 struct v4l2_tuner *p = arg; 1653 struct v4l2_tuner *p = arg;
1654 int ret;
1640 1655
1656 ret = v4l_enable_media_source(vfd);
1657 if (ret)
1658 return ret;
1641 p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? 1659 p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
1642 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 1660 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1643 return ops->vidioc_s_tuner(file, fh, p); 1661 return ops->vidioc_s_tuner(file, fh, p);
@@ -1691,7 +1709,11 @@ static int v4l_s_frequency(const struct v4l2_ioctl_ops *ops,
1691 struct video_device *vfd = video_devdata(file); 1709 struct video_device *vfd = video_devdata(file);
1692 const struct v4l2_frequency *p = arg; 1710 const struct v4l2_frequency *p = arg;
1693 enum v4l2_tuner_type type; 1711 enum v4l2_tuner_type type;
1712 int ret;
1694 1713
1714 ret = v4l_enable_media_source(vfd);
1715 if (ret)
1716 return ret;
1695 if (vfd->vfl_type == VFL_TYPE_SDR) { 1717 if (vfd->vfl_type == VFL_TYPE_SDR) {
1696 if (p->type != V4L2_TUNER_SDR && p->type != V4L2_TUNER_RF) 1718 if (p->type != V4L2_TUNER_SDR && p->type != V4L2_TUNER_RF)
1697 return -EINVAL; 1719 return -EINVAL;
@@ -1746,7 +1768,11 @@ static int v4l_s_std(const struct v4l2_ioctl_ops *ops,
1746{ 1768{
1747 struct video_device *vfd = video_devdata(file); 1769 struct video_device *vfd = video_devdata(file);
1748 v4l2_std_id id = *(v4l2_std_id *)arg, norm; 1770 v4l2_std_id id = *(v4l2_std_id *)arg, norm;
1771 int ret;
1749 1772
1773 ret = v4l_enable_media_source(vfd);
1774 if (ret)
1775 return ret;
1750 norm = id & vfd->tvnorms; 1776 norm = id & vfd->tvnorms;
1751 if (vfd->tvnorms && !norm) /* Check if std is supported */ 1777 if (vfd->tvnorms && !norm) /* Check if std is supported */
1752 return -EINVAL; 1778 return -EINVAL;
@@ -1760,7 +1786,11 @@ static int v4l_querystd(const struct v4l2_ioctl_ops *ops,
1760{ 1786{
1761 struct video_device *vfd = video_devdata(file); 1787 struct video_device *vfd = video_devdata(file);
1762 v4l2_std_id *p = arg; 1788 v4l2_std_id *p = arg;
1789 int ret;
1763 1790
1791 ret = v4l_enable_media_source(vfd);
1792 if (ret)
1793 return ret;
1764 /* 1794 /*
1765 * If no signal is detected, then the driver should return 1795 * If no signal is detected, then the driver should return
1766 * V4L2_STD_UNKNOWN. Otherwise it should return tvnorms with 1796 * V4L2_STD_UNKNOWN. Otherwise it should return tvnorms with
@@ -1779,7 +1809,11 @@ static int v4l_s_hw_freq_seek(const struct v4l2_ioctl_ops *ops,
1779 struct video_device *vfd = video_devdata(file); 1809 struct video_device *vfd = video_devdata(file);
1780 struct v4l2_hw_freq_seek *p = arg; 1810 struct v4l2_hw_freq_seek *p = arg;
1781 enum v4l2_tuner_type type; 1811 enum v4l2_tuner_type type;
1812 int ret;
1782 1813
1814 ret = v4l_enable_media_source(vfd);
1815 if (ret)
1816 return ret;
1783 /* s_hw_freq_seek is not supported for SDR for now */ 1817 /* s_hw_freq_seek is not supported for SDR for now */
1784 if (vfd->vfl_type == VFL_TYPE_SDR) 1818 if (vfd->vfl_type == VFL_TYPE_SDR)
1785 return -EINVAL; 1819 return -EINVAL;
diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c
new file mode 100644
index 000000000000..2a7b79bc90fd
--- /dev/null
+++ b/drivers/media/v4l2-core/v4l2-mc.c
@@ -0,0 +1,403 @@
1/*
2 * Media Controller ancillary functions
3 *
4 * Copyright (c) 2016 Mauro Carvalho Chehab <mchehab@osg.samsung.com>
5 * Copyright (C) 2016 Shuah Khan <shuahkh@osg.samsung.com>
6 * Copyright (C) 2006-2010 Nokia Corporation
7 * Copyright (c) 2016 Intel Corporation.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 */
19
20#include <linux/module.h>
21#include <linux/pci.h>
22#include <linux/usb.h>
23#include <media/media-device.h>
24#include <media/media-entity.h>
25#include <media/v4l2-fh.h>
26#include <media/v4l2-mc.h>
27#include <media/v4l2-subdev.h>
28#include <media/media-device.h>
29#include <media/v4l2-mc.h>
30#include <media/videobuf2-core.h>
31
32int v4l2_mc_create_media_graph(struct media_device *mdev)
33
34{
35 struct media_entity *entity;
36 struct media_entity *if_vid = NULL, *if_aud = NULL;
37 struct media_entity *tuner = NULL, *decoder = NULL, *dtv_demod = NULL;
38 struct media_entity *io_v4l = NULL, *io_vbi = NULL, *io_swradio = NULL;
39 bool is_webcam = false;
40 u32 flags;
41 int ret;
42
43 if (!mdev)
44 return 0;
45
46 media_device_for_each_entity(entity, mdev) {
47 switch (entity->function) {
48 case MEDIA_ENT_F_IF_VID_DECODER:
49 if_vid = entity;
50 break;
51 case MEDIA_ENT_F_IF_AUD_DECODER:
52 if_aud = entity;
53 break;
54 case MEDIA_ENT_F_TUNER:
55 tuner = entity;
56 break;
57 case MEDIA_ENT_F_ATV_DECODER:
58 decoder = entity;
59 break;
60 case MEDIA_ENT_F_IO_V4L:
61 io_v4l = entity;
62 break;
63 case MEDIA_ENT_F_IO_VBI:
64 io_vbi = entity;
65 break;
66 case MEDIA_ENT_F_IO_SWRADIO:
67 io_swradio = entity;
68 break;
69 case MEDIA_ENT_F_CAM_SENSOR:
70 is_webcam = true;
71 break;
72 }
73 }
74
75 /* It should have at least one I/O entity */
76 if (!io_v4l && !io_vbi && !io_swradio)
77 return -EINVAL;
78
79 /*
80 * Here, webcams are modelled on a very simple way: the sensor is
81 * connected directly to the I/O entity. All dirty details, like
82 * scaler and crop HW are hidden. While such mapping is not enough
83 * for mc-centric hardware, it is enough for v4l2 interface centric
84 * PC-consumer's hardware.
85 */
86 if (is_webcam) {
87 if (!io_v4l)
88 return -EINVAL;
89
90 media_device_for_each_entity(entity, mdev) {
91 if (entity->function != MEDIA_ENT_F_CAM_SENSOR)
92 continue;
93 ret = media_create_pad_link(entity, 0,
94 io_v4l, 0,
95 MEDIA_LNK_FL_ENABLED);
96 if (ret)
97 return ret;
98 }
99 if (!decoder)
100 return 0;
101 }
102
103 /* The device isn't a webcam. So, it should have a decoder */
104 if (!decoder)
105 return -EINVAL;
106
107 /* Link the tuner and IF video output pads */
108 if (tuner) {
109 if (if_vid) {
110 ret = media_create_pad_link(tuner, TUNER_PAD_OUTPUT,
111 if_vid,
112 IF_VID_DEC_PAD_IF_INPUT,
113 MEDIA_LNK_FL_ENABLED);
114 if (ret)
115 return ret;
116 ret = media_create_pad_link(if_vid, IF_VID_DEC_PAD_OUT,
117 decoder, DEMOD_PAD_IF_INPUT,
118 MEDIA_LNK_FL_ENABLED);
119 if (ret)
120 return ret;
121 } else {
122 ret = media_create_pad_link(tuner, TUNER_PAD_OUTPUT,
123 decoder, DEMOD_PAD_IF_INPUT,
124 MEDIA_LNK_FL_ENABLED);
125 if (ret)
126 return ret;
127 }
128
129 if (if_aud) {
130 ret = media_create_pad_link(tuner, TUNER_PAD_AUD_OUT,
131 if_aud,
132 IF_AUD_DEC_PAD_IF_INPUT,
133 MEDIA_LNK_FL_ENABLED);
134 if (ret)
135 return ret;
136 } else {
137 if_aud = tuner;
138 }
139
140 }
141
142 /* Create demod to V4L, VBI and SDR radio links */
143 if (io_v4l) {
144 ret = media_create_pad_link(decoder, DEMOD_PAD_VID_OUT,
145 io_v4l, 0,
146 MEDIA_LNK_FL_ENABLED);
147 if (ret)
148 return ret;
149 }
150
151 if (io_swradio) {
152 ret = media_create_pad_link(decoder, DEMOD_PAD_VID_OUT,
153 io_swradio, 0,
154 MEDIA_LNK_FL_ENABLED);
155 if (ret)
156 return ret;
157 }
158
159 if (io_vbi) {
160 ret = media_create_pad_link(decoder, DEMOD_PAD_VBI_OUT,
161 io_vbi, 0,
162 MEDIA_LNK_FL_ENABLED);
163 if (ret)
164 return ret;
165 }
166
167 /* Create links for the media connectors */
168 flags = MEDIA_LNK_FL_ENABLED;
169 media_device_for_each_entity(entity, mdev) {
170 switch (entity->function) {
171 case MEDIA_ENT_F_CONN_RF:
172 if (!tuner)
173 continue;
174
175 ret = media_create_pad_link(entity, 0, tuner,
176 TUNER_PAD_RF_INPUT,
177 flags);
178 break;
179 case MEDIA_ENT_F_CONN_SVIDEO:
180 case MEDIA_ENT_F_CONN_COMPOSITE:
181 ret = media_create_pad_link(entity, 0, decoder,
182 DEMOD_PAD_IF_INPUT,
183 flags);
184 break;
185 default:
186 continue;
187 }
188 if (ret)
189 return ret;
190
191 flags = 0;
192 }
193
194 return 0;
195}
196EXPORT_SYMBOL_GPL(v4l2_mc_create_media_graph);
197
198int v4l_enable_media_source(struct video_device *vdev)
199{
200 struct media_device *mdev = vdev->entity.graph_obj.mdev;
201 int ret;
202
203 if (!mdev || !mdev->enable_source)
204 return 0;
205 ret = mdev->enable_source(&vdev->entity, &vdev->pipe);
206 if (ret)
207 return -EBUSY;
208 return 0;
209}
210EXPORT_SYMBOL_GPL(v4l_enable_media_source);
211
212void v4l_disable_media_source(struct video_device *vdev)
213{
214 struct media_device *mdev = vdev->entity.graph_obj.mdev;
215
216 if (mdev && mdev->disable_source)
217 mdev->disable_source(&vdev->entity);
218}
219EXPORT_SYMBOL_GPL(v4l_disable_media_source);
220
221int v4l_vb2q_enable_media_source(struct vb2_queue *q)
222{
223 struct v4l2_fh *fh = q->owner;
224
225 if (fh && fh->vdev)
226 return v4l_enable_media_source(fh->vdev);
227 return 0;
228}
229EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_source);
230
231/* -----------------------------------------------------------------------------
232 * Pipeline power management
233 *
234 * Entities must be powered up when part of a pipeline that contains at least
235 * one open video device node.
236 *
237 * To achieve this use the entity use_count field to track the number of users.
238 * For entities corresponding to video device nodes the use_count field stores
239 * the users count of the node. For entities corresponding to subdevs the
240 * use_count field stores the total number of users of all video device nodes
241 * in the pipeline.
242 *
243 * The v4l2_pipeline_pm_use() function must be called in the open() and
244 * close() handlers of video device nodes. It increments or decrements the use
245 * count of all subdev entities in the pipeline.
246 *
247 * To react to link management on powered pipelines, the link setup notification
248 * callback updates the use count of all entities in the source and sink sides
249 * of the link.
250 */
251
252/*
253 * pipeline_pm_use_count - Count the number of users of a pipeline
254 * @entity: The entity
255 *
256 * Return the total number of users of all video device nodes in the pipeline.
257 */
258static int pipeline_pm_use_count(struct media_entity *entity,
259 struct media_entity_graph *graph)
260{
261 int use = 0;
262
263 media_entity_graph_walk_start(graph, entity);
264
265 while ((entity = media_entity_graph_walk_next(graph))) {
266 if (is_media_entity_v4l2_io(entity))
267 use += entity->use_count;
268 }
269
270 return use;
271}
272
273/*
274 * pipeline_pm_power_one - Apply power change to an entity
275 * @entity: The entity
276 * @change: Use count change
277 *
278 * Change the entity use count by @change. If the entity is a subdev update its
279 * power state by calling the core::s_power operation when the use count goes
280 * from 0 to != 0 or from != 0 to 0.
281 *
282 * Return 0 on success or a negative error code on failure.
283 */
284static int pipeline_pm_power_one(struct media_entity *entity, int change)
285{
286 struct v4l2_subdev *subdev;
287 int ret;
288
289 subdev = is_media_entity_v4l2_subdev(entity)
290 ? media_entity_to_v4l2_subdev(entity) : NULL;
291
292 if (entity->use_count == 0 && change > 0 && subdev != NULL) {
293 ret = v4l2_subdev_call(subdev, core, s_power, 1);
294 if (ret < 0 && ret != -ENOIOCTLCMD)
295 return ret;
296 }
297
298 entity->use_count += change;
299 WARN_ON(entity->use_count < 0);
300
301 if (entity->use_count == 0 && change < 0 && subdev != NULL)
302 v4l2_subdev_call(subdev, core, s_power, 0);
303
304 return 0;
305}
306
307/*
308 * pipeline_pm_power - Apply power change to all entities in a pipeline
309 * @entity: The entity
310 * @change: Use count change
311 *
312 * Walk the pipeline to update the use count and the power state of all non-node
313 * entities.
314 *
315 * Return 0 on success or a negative error code on failure.
316 */
317static int pipeline_pm_power(struct media_entity *entity, int change,
318 struct media_entity_graph *graph)
319{
320 struct media_entity *first = entity;
321 int ret = 0;
322
323 if (!change)
324 return 0;
325
326 media_entity_graph_walk_start(graph, entity);
327
328 while (!ret && (entity = media_entity_graph_walk_next(graph)))
329 if (is_media_entity_v4l2_subdev(entity))
330 ret = pipeline_pm_power_one(entity, change);
331
332 if (!ret)
333 return ret;
334
335 media_entity_graph_walk_start(graph, first);
336
337 while ((first = media_entity_graph_walk_next(graph))
338 && first != entity)
339 if (is_media_entity_v4l2_subdev(first))
340 pipeline_pm_power_one(first, -change);
341
342 return ret;
343}
344
345int v4l2_pipeline_pm_use(struct media_entity *entity, int use)
346{
347 struct media_device *mdev = entity->graph_obj.mdev;
348 int change = use ? 1 : -1;
349 int ret;
350
351 mutex_lock(&mdev->graph_mutex);
352
353 /* Apply use count to node. */
354 entity->use_count += change;
355 WARN_ON(entity->use_count < 0);
356
357 /* Apply power change to connected non-nodes. */
358 ret = pipeline_pm_power(entity, change, &mdev->pm_count_walk);
359 if (ret < 0)
360 entity->use_count -= change;
361
362 mutex_unlock(&mdev->graph_mutex);
363
364 return ret;
365}
366EXPORT_SYMBOL_GPL(v4l2_pipeline_pm_use);
367
368int v4l2_pipeline_link_notify(struct media_link *link, u32 flags,
369 unsigned int notification)
370{
371 struct media_entity_graph *graph = &link->graph_obj.mdev->pm_count_walk;
372 struct media_entity *source = link->source->entity;
373 struct media_entity *sink = link->sink->entity;
374 int source_use;
375 int sink_use;
376 int ret = 0;
377
378 source_use = pipeline_pm_use_count(source, graph);
379 sink_use = pipeline_pm_use_count(sink, graph);
380
381 if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH &&
382 !(flags & MEDIA_LNK_FL_ENABLED)) {
383 /* Powering off entities is assumed to never fail. */
384 pipeline_pm_power(source, -sink_use, graph);
385 pipeline_pm_power(sink, -source_use, graph);
386 return 0;
387 }
388
389 if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH &&
390 (flags & MEDIA_LNK_FL_ENABLED)) {
391
392 ret = pipeline_pm_power(source, sink_use, graph);
393 if (ret < 0)
394 return ret;
395
396 ret = pipeline_pm_power(sink, source_use, graph);
397 if (ret < 0)
398 pipeline_pm_power(source, -sink_use, graph);
399 }
400
401 return ret;
402}
403EXPORT_SYMBOL_GPL(v4l2_pipeline_link_notify);
diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c
index b27cbb1f5afe..93b33681776c 100644
--- a/drivers/media/v4l2-core/v4l2-of.c
+++ b/drivers/media/v4l2-core/v4l2-of.c
@@ -146,7 +146,7 @@ static void v4l2_of_parse_parallel_bus(const struct device_node *node,
146 * variable without a low fixed limit. Please use 146 * variable without a low fixed limit. Please use
147 * v4l2_of_alloc_parse_endpoint() in new drivers instead. 147 * v4l2_of_alloc_parse_endpoint() in new drivers instead.
148 * 148 *
149 * Return: 0. 149 * Return: 0 on success or a negative error code on failure.
150 */ 150 */
151int v4l2_of_parse_endpoint(const struct device_node *node, 151int v4l2_of_parse_endpoint(const struct device_node *node,
152 struct v4l2_of_endpoint *endpoint) 152 struct v4l2_of_endpoint *endpoint)
diff --git a/drivers/media/v4l2-core/videobuf-core.c b/drivers/media/v4l2-core/videobuf-core.c
index 6c02989ee33f..def84753c4c3 100644
--- a/drivers/media/v4l2-core/videobuf-core.c
+++ b/drivers/media/v4l2-core/videobuf-core.c
@@ -75,7 +75,8 @@ struct videobuf_buffer *videobuf_alloc_vb(struct videobuf_queue *q)
75} 75}
76EXPORT_SYMBOL_GPL(videobuf_alloc_vb); 76EXPORT_SYMBOL_GPL(videobuf_alloc_vb);
77 77
78static int is_state_active_or_queued(struct videobuf_queue *q, struct videobuf_buffer *vb) 78static int state_neither_active_nor_queued(struct videobuf_queue *q,
79 struct videobuf_buffer *vb)
79{ 80{
80 unsigned long flags; 81 unsigned long flags;
81 bool rc; 82 bool rc;
@@ -95,7 +96,7 @@ int videobuf_waiton(struct videobuf_queue *q, struct videobuf_buffer *vb,
95 MAGIC_CHECK(vb->magic, MAGIC_BUFFER); 96 MAGIC_CHECK(vb->magic, MAGIC_BUFFER);
96 97
97 if (non_blocking) { 98 if (non_blocking) {
98 if (is_state_active_or_queued(q, vb)) 99 if (state_neither_active_nor_queued(q, vb))
99 return 0; 100 return 0;
100 return -EAGAIN; 101 return -EAGAIN;
101 } 102 }
@@ -107,9 +108,10 @@ int videobuf_waiton(struct videobuf_queue *q, struct videobuf_buffer *vb,
107 if (is_ext_locked) 108 if (is_ext_locked)
108 mutex_unlock(q->ext_lock); 109 mutex_unlock(q->ext_lock);
109 if (intr) 110 if (intr)
110 ret = wait_event_interruptible(vb->done, is_state_active_or_queued(q, vb)); 111 ret = wait_event_interruptible(vb->done,
112 state_neither_active_nor_queued(q, vb));
111 else 113 else
112 wait_event(vb->done, is_state_active_or_queued(q, vb)); 114 wait_event(vb->done, state_neither_active_nor_queued(q, vb));
113 /* Relock */ 115 /* Relock */
114 if (is_ext_locked) 116 if (is_ext_locked)
115 mutex_lock(q->ext_lock); 117 mutex_lock(q->ext_lock);
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index ff8953ae52d1..5d016f496e0e 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -25,6 +25,7 @@
25#include <linux/kthread.h> 25#include <linux/kthread.h>
26 26
27#include <media/videobuf2-core.h> 27#include <media/videobuf2-core.h>
28#include <media/v4l2-mc.h>
28 29
29#include <trace/events/vb2.h> 30#include <trace/events/vb2.h>
30 31
@@ -1227,6 +1228,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const void *pb)
1227 if (planes[plane].length < vb->planes[plane].min_length) { 1228 if (planes[plane].length < vb->planes[plane].min_length) {
1228 dprintk(1, "invalid dmabuf length for plane %d\n", 1229 dprintk(1, "invalid dmabuf length for plane %d\n",
1229 plane); 1230 plane);
1231 dma_buf_put(dbuf);
1230 ret = -EINVAL; 1232 ret = -EINVAL;
1231 goto err; 1233 goto err;
1232 } 1234 }
@@ -1886,6 +1888,9 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type)
1886 * are available. 1888 * are available.
1887 */ 1889 */
1888 if (q->queued_count >= q->min_buffers_needed) { 1890 if (q->queued_count >= q->min_buffers_needed) {
1891 ret = v4l_vb2q_enable_media_source(q);
1892 if (ret)
1893 return ret;
1889 ret = vb2_start_streaming(q); 1894 ret = vb2_start_streaming(q);
1890 if (ret) { 1895 if (ret) {
1891 __vb2_queue_cancel(q); 1896 __vb2_queue_cancel(q);
diff --git a/drivers/media/v4l2-core/videobuf2-dvb.c b/drivers/media/v4l2-core/videobuf2-dvb.c
index d09269846b7e..9f38b4218c0d 100644
--- a/drivers/media/v4l2-core/videobuf2-dvb.c
+++ b/drivers/media/v4l2-core/videobuf2-dvb.c
@@ -77,6 +77,7 @@ static int vb2_dvb_register_adapter(struct vb2_dvb_frontends *fe,
77 struct module *module, 77 struct module *module,
78 void *adapter_priv, 78 void *adapter_priv,
79 struct device *device, 79 struct device *device,
80 struct media_device *mdev,
80 char *adapter_name, 81 char *adapter_name,
81 short *adapter_nr, 82 short *adapter_nr,
82 int mfe_shared) 83 int mfe_shared)
@@ -94,7 +95,10 @@ static int vb2_dvb_register_adapter(struct vb2_dvb_frontends *fe,
94 } 95 }
95 fe->adapter.priv = adapter_priv; 96 fe->adapter.priv = adapter_priv;
96 fe->adapter.mfe_shared = mfe_shared; 97 fe->adapter.mfe_shared = mfe_shared;
97 98#ifdef CONFIG_MEDIA_CONTROLLER_DVB
99 if (mdev)
100 fe->adapter.mdev = mdev;
101#endif
98 return result; 102 return result;
99} 103}
100 104
@@ -193,6 +197,7 @@ int vb2_dvb_register_bus(struct vb2_dvb_frontends *f,
193 struct module *module, 197 struct module *module,
194 void *adapter_priv, 198 void *adapter_priv,
195 struct device *device, 199 struct device *device,
200 struct media_device *mdev,
196 short *adapter_nr, 201 short *adapter_nr,
197 int mfe_shared) 202 int mfe_shared)
198{ 203{
@@ -207,7 +212,7 @@ int vb2_dvb_register_bus(struct vb2_dvb_frontends *f,
207 } 212 }
208 213
209 /* Bring up the adapter */ 214 /* Bring up the adapter */
210 res = vb2_dvb_register_adapter(f, module, adapter_priv, device, 215 res = vb2_dvb_register_adapter(f, module, adapter_priv, device, mdev,
211 fe->dvb.name, adapter_nr, mfe_shared); 216 fe->dvb.name, adapter_nr, mfe_shared);
212 if (res < 0) { 217 if (res < 0) {
213 pr_warn("vb2_dvb_register_adapter failed (errno = %d)\n", res); 218 pr_warn("vb2_dvb_register_adapter failed (errno = %d)\n", res);
@@ -224,7 +229,11 @@ int vb2_dvb_register_bus(struct vb2_dvb_frontends *f,
224 fe->dvb.name, res); 229 fe->dvb.name, res);
225 goto err; 230 goto err;
226 } 231 }
232 res = dvb_create_media_graph(&f->adapter, false);
233 if (res < 0)
234 goto err;
227 } 235 }
236
228 mutex_unlock(&f->lock); 237 mutex_unlock(&f->lock);
229 return 0; 238 return 0;
230 239
diff --git a/drivers/staging/media/Kconfig b/drivers/staging/media/Kconfig
index 14697686eea5..0078b6a92f0b 100644
--- a/drivers/staging/media/Kconfig
+++ b/drivers/staging/media/Kconfig
@@ -27,10 +27,16 @@ source "drivers/staging/media/davinci_vpfe/Kconfig"
27 27
28source "drivers/staging/media/mn88472/Kconfig" 28source "drivers/staging/media/mn88472/Kconfig"
29 29
30source "drivers/staging/media/mn88473/Kconfig" 30source "drivers/staging/media/mx2/Kconfig"
31
32source "drivers/staging/media/mx3/Kconfig"
33
34source "drivers/staging/media/omap1/Kconfig"
31 35
32source "drivers/staging/media/omap4iss/Kconfig" 36source "drivers/staging/media/omap4iss/Kconfig"
33 37
38source "drivers/staging/media/timb/Kconfig"
39
34# Keep LIRC at the end, as it has sub-menus 40# Keep LIRC at the end, as it has sub-menus
35source "drivers/staging/media/lirc/Kconfig" 41source "drivers/staging/media/lirc/Kconfig"
36 42
diff --git a/drivers/staging/media/Makefile b/drivers/staging/media/Makefile
index 34c557b4c6d6..91495882a36c 100644
--- a/drivers/staging/media/Makefile
+++ b/drivers/staging/media/Makefile
@@ -2,6 +2,9 @@ obj-$(CONFIG_I2C_BCM2048) += bcm2048/
2obj-$(CONFIG_DVB_CXD2099) += cxd2099/ 2obj-$(CONFIG_DVB_CXD2099) += cxd2099/
3obj-$(CONFIG_LIRC_STAGING) += lirc/ 3obj-$(CONFIG_LIRC_STAGING) += lirc/
4obj-$(CONFIG_VIDEO_DM365_VPFE) += davinci_vpfe/ 4obj-$(CONFIG_VIDEO_DM365_VPFE) += davinci_vpfe/
5obj-$(CONFIG_VIDEO_MX2) += mx2/
6obj-$(CONFIG_VIDEO_MX3) += mx3/
7obj-$(CONFIG_VIDEO_OMAP1) += omap1/
5obj-$(CONFIG_VIDEO_OMAP4) += omap4iss/ 8obj-$(CONFIG_VIDEO_OMAP4) += omap4iss/
6obj-$(CONFIG_DVB_MN88472) += mn88472/ 9obj-$(CONFIG_DVB_MN88472) += mn88472/
7obj-$(CONFIG_DVB_MN88473) += mn88473/ 10obj-$(CONFIG_VIDEO_TIMBERDALE) += timb/
diff --git a/drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h b/drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h
index 7b7e7b26c1e8..3cc9be776f8b 100644
--- a/drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h
+++ b/drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h
@@ -538,7 +538,7 @@ struct vpfe_isif_raw_config {
538}; 538};
539 539
540/********************************************************************** 540/**********************************************************************
541 IPIPE API Structures 541* IPIPE API Structures
542**********************************************************************/ 542**********************************************************************/
543 543
544/* IPIPE module configurations */ 544/* IPIPE module configurations */
diff --git a/drivers/staging/media/lirc/lirc_parallel.c b/drivers/staging/media/lirc/lirc_parallel.c
index d009bcb439f0..68ede6c56e6d 100644
--- a/drivers/staging/media/lirc/lirc_parallel.c
+++ b/drivers/staging/media/lirc/lirc_parallel.c
@@ -193,7 +193,7 @@ static int lirc_claim(void)
193 return 0; 193 return 0;
194 } 194 }
195 } 195 }
196 out(LIRC_LP_CONTROL, LP_PSELECP|LP_PINITP); 196 out(LIRC_LP_CONTROL, LP_PSELECP | LP_PINITP);
197 is_claimed = 1; 197 is_claimed = 1;
198 return 1; 198 return 1;
199} 199}
@@ -264,7 +264,7 @@ static void lirc_lirc_irq_handler(void *blah)
264 init = 1; 264 init = 1;
265 } 265 }
266 266
267 timeout = timer/10; /* timeout after 1/10 sec. */ 267 timeout = timer / 10; /* timeout after 1/10 sec. */
268 signal = 1; 268 signal = 1;
269 level = lirc_get_timer(); 269 level = lirc_get_timer();
270 do { 270 do {
@@ -286,15 +286,15 @@ static void lirc_lirc_irq_handler(void *blah)
286 /* adjust value to usecs */ 286 /* adjust value to usecs */
287 __u64 helper; 287 __u64 helper;
288 288
289 helper = ((__u64) signal)*1000000; 289 helper = ((__u64)signal) * 1000000;
290 do_div(helper, timer); 290 do_div(helper, timer);
291 signal = (long) helper; 291 signal = (long)helper;
292 292
293 if (signal > LIRC_SFH506_DELAY) 293 if (signal > LIRC_SFH506_DELAY)
294 data = signal - LIRC_SFH506_DELAY; 294 data = signal - LIRC_SFH506_DELAY;
295 else 295 else
296 data = 1; 296 data = 1;
297 rbuf_write(PULSE_BIT|data); /* pulse */ 297 rbuf_write(PULSE_BIT | data); /* pulse */
298 } 298 }
299 lastkt = ktime_get(); 299 lastkt = ktime_get();
300#else 300#else
@@ -331,7 +331,7 @@ static ssize_t lirc_read(struct file *filep, char __user *buf, size_t n,
331 set_current_state(TASK_INTERRUPTIBLE); 331 set_current_state(TASK_INTERRUPTIBLE);
332 while (count < n) { 332 while (count < n) {
333 if (rptr != wptr) { 333 if (rptr != wptr) {
334 if (copy_to_user(buf+count, &rbuf[rptr], 334 if (copy_to_user(buf + count, &rbuf[rptr],
335 sizeof(int))) { 335 sizeof(int))) {
336 result = -EFAULT; 336 result = -EFAULT;
337 break; 337 break;
@@ -393,9 +393,9 @@ static ssize_t lirc_write(struct file *filep, const char __user *buf, size_t n,
393 for (i = 0; i < count; i++) { 393 for (i = 0; i < count; i++) {
394 __u64 helper; 394 __u64 helper;
395 395
396 helper = ((__u64) wbuf[i])*timer; 396 helper = ((__u64)wbuf[i]) * timer;
397 do_div(helper, 1000000); 397 do_div(helper, 1000000);
398 wbuf[i] = (int) helper; 398 wbuf[i] = (int)helper;
399 } 399 }
400 400
401 local_irq_save(flags); 401 local_irq_save(flags);
@@ -647,7 +647,7 @@ static int __init lirc_parallel_init(void)
647 goto exit_device_put; 647 goto exit_device_put;
648 648
649 pport = parport_find_base(io); 649 pport = parport_find_base(io);
650 if (pport == NULL) { 650 if (!pport) {
651 pr_notice("no port at %x found\n", io); 651 pr_notice("no port at %x found\n", io);
652 result = -ENXIO; 652 result = -ENXIO;
653 goto exit_device_put; 653 goto exit_device_put;
@@ -656,7 +656,7 @@ static int __init lirc_parallel_init(void)
656 pf, kf, lirc_lirc_irq_handler, 0, 656 pf, kf, lirc_lirc_irq_handler, 0,
657 NULL); 657 NULL);
658 parport_put_port(pport); 658 parport_put_port(pport);
659 if (ppdevice == NULL) { 659 if (!ppdevice) {
660 pr_notice("parport_register_device() failed\n"); 660 pr_notice("parport_register_device() failed\n");
661 result = -ENXIO; 661 result = -ENXIO;
662 goto exit_device_put; 662 goto exit_device_put;
@@ -664,7 +664,7 @@ static int __init lirc_parallel_init(void)
664 if (parport_claim(ppdevice) != 0) 664 if (parport_claim(ppdevice) != 0)
665 goto skip_init; 665 goto skip_init;
666 is_claimed = 1; 666 is_claimed = 1;
667 out(LIRC_LP_CONTROL, LP_PSELECP|LP_PINITP); 667 out(LIRC_LP_CONTROL, LP_PSELECP | LP_PINITP);
668 668
669#ifdef LIRC_TIMER 669#ifdef LIRC_TIMER
670 if (debug) 670 if (debug)
@@ -730,7 +730,7 @@ module_param(irq, int, S_IRUGO);
730MODULE_PARM_DESC(irq, "Interrupt (7 or 5)"); 730MODULE_PARM_DESC(irq, "Interrupt (7 or 5)");
731 731
732module_param(tx_mask, int, S_IRUGO); 732module_param(tx_mask, int, S_IRUGO);
733MODULE_PARM_DESC(tx_maxk, "Transmitter mask (default: 0x01)"); 733MODULE_PARM_DESC(tx_mask, "Transmitter mask (default: 0x01)");
734 734
735module_param(debug, bool, S_IRUGO | S_IWUSR); 735module_param(debug, bool, S_IRUGO | S_IWUSR);
736MODULE_PARM_DESC(debug, "Enable debugging messages"); 736MODULE_PARM_DESC(debug, "Enable debugging messages");
diff --git a/drivers/staging/media/lirc/lirc_zilog.c b/drivers/staging/media/lirc/lirc_zilog.c
index ce3b5f230e2e..3551aed589c0 100644
--- a/drivers/staging/media/lirc/lirc_zilog.c
+++ b/drivers/staging/media/lirc/lirc_zilog.c
@@ -1680,9 +1680,7 @@ module_init(zilog_init);
1680module_exit(zilog_exit); 1680module_exit(zilog_exit);
1681 1681
1682MODULE_DESCRIPTION("Zilog/Hauppauge infrared transmitter driver (i2c stack)"); 1682MODULE_DESCRIPTION("Zilog/Hauppauge infrared transmitter driver (i2c stack)");
1683MODULE_AUTHOR("Gerd Knorr, Michal Kochanowicz, Christoph Bartelmus, " 1683MODULE_AUTHOR("Gerd Knorr, Michal Kochanowicz, Christoph Bartelmus, Ulrich Mueller, Stefan Jahn, Jerome Brock, Mark Weaver, Andy Walls");
1684 "Ulrich Mueller, Stefan Jahn, Jerome Brock, Mark Weaver, "
1685 "Andy Walls");
1686MODULE_LICENSE("GPL"); 1684MODULE_LICENSE("GPL");
1687/* for compat with old name, which isn't all that accurate anymore */ 1685/* for compat with old name, which isn't all that accurate anymore */
1688MODULE_ALIAS("lirc_pvr150"); 1686MODULE_ALIAS("lirc_pvr150");
diff --git a/drivers/staging/media/mn88473/Kconfig b/drivers/staging/media/mn88473/Kconfig
deleted file mode 100644
index 6c9ebf51c2c7..000000000000
--- a/drivers/staging/media/mn88473/Kconfig
+++ /dev/null
@@ -1,7 +0,0 @@
1config DVB_MN88473
2 tristate "Panasonic MN88473"
3 depends on DVB_CORE && I2C
4 select REGMAP_I2C
5 default m if !MEDIA_SUBDRV_AUTOSELECT
6 help
7 Say Y when you want to support this frontend.
diff --git a/drivers/staging/media/mn88473/Makefile b/drivers/staging/media/mn88473/Makefile
deleted file mode 100644
index fac55410ce55..000000000000
--- a/drivers/staging/media/mn88473/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1obj-$(CONFIG_DVB_MN88473) += mn88473.o
2
3ccflags-y += -Idrivers/media/dvb-core/
4ccflags-y += -Idrivers/media/dvb-frontends/
5ccflags-y += -Idrivers/media/tuners/
diff --git a/drivers/staging/media/mn88473/TODO b/drivers/staging/media/mn88473/TODO
deleted file mode 100644
index b90a14be3beb..000000000000
--- a/drivers/staging/media/mn88473/TODO
+++ /dev/null
@@ -1,21 +0,0 @@
1Driver general quality is not good enough for mainline. Also, other
2device drivers (USB-bridge, tuner) needed for Astrometa receiver in
3question could need some changes. However, if that driver is mainlined
4due to some other device than Astrometa, unrelated TODOs could be
5skipped. In that case rtl28xxu driver needs module parameter to prevent
6driver loading.
7
8Required TODOs:
9* missing lock flags
10* I2C errors
11* tuner sensitivity
12
13*Do not* send any patch fixing checkpatch.pl issues. Currently it passes
14checkpatch.pl tests. I don't want waste my time to review this kind of
15trivial stuff. *Do not* add missing register I/O error checks. Those are
16missing for the reason it is much easier to compare I2C data sniffs when
17there is less lines. Those error checks are about the last thing to be added.
18
19Patches should be submitted to:
20linux-media@vger.kernel.org and Antti Palosaari <crope@iki.fi>
21
diff --git a/drivers/staging/media/mx2/Kconfig b/drivers/staging/media/mx2/Kconfig
new file mode 100644
index 000000000000..beaa885cf104
--- /dev/null
+++ b/drivers/staging/media/mx2/Kconfig
@@ -0,0 +1,15 @@
1config VIDEO_MX2
2 tristate "i.MX27 Camera Sensor Interface driver"
3 depends on VIDEO_DEV && SOC_CAMERA
4 depends on SOC_IMX27 || COMPILE_TEST
5 depends on HAS_DMA
6 select VIDEOBUF2_DMA_CONTIG
7 ---help---
8 This is a v4l2 driver for the i.MX27 Camera Sensor Interface
9
10 This driver is deprecated: it should become a stand-alone driver
11 instead of using the soc-camera framework.
12
13 Unless someone is willing to take this on (unlikely with such
14 ancient hardware) it is going to be removed from the kernel
15 soon.
diff --git a/drivers/staging/media/mx2/Makefile b/drivers/staging/media/mx2/Makefile
new file mode 100644
index 000000000000..fc5b2826a558
--- /dev/null
+++ b/drivers/staging/media/mx2/Makefile
@@ -0,0 +1,3 @@
1# Makefile for i.MX27 Camera Sensor driver
2
3obj-$(CONFIG_VIDEO_MX2) += mx2_camera.o
diff --git a/drivers/staging/media/mx2/TODO b/drivers/staging/media/mx2/TODO
new file mode 100644
index 000000000000..bc68fa443a3e
--- /dev/null
+++ b/drivers/staging/media/mx2/TODO
@@ -0,0 +1,10 @@
1This driver is deprecated: it should become a stand-alone driver instead of
2using the soc-camera framework.
3
4Unless someone is willing to take this on (unlikely with such ancient
5hardware) it is going to be removed from the kernel soon.
6
7Note that trivial patches will not be accepted anymore, only a full conversion.
8
9If you want to convert this driver, please contact the linux-media mailinglist
10(see http://linuxtv.org/lists.php).
diff --git a/drivers/media/platform/soc_camera/mx2_camera.c b/drivers/staging/media/mx2/mx2_camera.c
index 48dd5b7851b5..48dd5b7851b5 100644
--- a/drivers/media/platform/soc_camera/mx2_camera.c
+++ b/drivers/staging/media/mx2/mx2_camera.c
diff --git a/drivers/staging/media/mx3/Kconfig b/drivers/staging/media/mx3/Kconfig
new file mode 100644
index 000000000000..595d5fe7cad1
--- /dev/null
+++ b/drivers/staging/media/mx3/Kconfig
@@ -0,0 +1,15 @@
1config VIDEO_MX3
2 tristate "i.MX3x Camera Sensor Interface driver"
3 depends on VIDEO_DEV && MX3_IPU && SOC_CAMERA
4 depends on MX3_IPU || COMPILE_TEST
5 depends on HAS_DMA
6 select VIDEOBUF2_DMA_CONTIG
7 ---help---
8 This is a v4l2 driver for the i.MX3x Camera Sensor Interface
9
10 This driver is deprecated: it should become a stand-alone driver
11 instead of using the soc-camera framework.
12
13 Unless someone is willing to take this on (unlikely with such
14 ancient hardware) it is going to be removed from the kernel
15 soon.
diff --git a/drivers/staging/media/mx3/Makefile b/drivers/staging/media/mx3/Makefile
new file mode 100644
index 000000000000..6d91dcd80c1d
--- /dev/null
+++ b/drivers/staging/media/mx3/Makefile
@@ -0,0 +1,3 @@
1# Makefile for i.MX3x Camera Sensor driver
2
3obj-$(CONFIG_VIDEO_MX3) += mx3_camera.o
diff --git a/drivers/staging/media/mx3/TODO b/drivers/staging/media/mx3/TODO
new file mode 100644
index 000000000000..bc68fa443a3e
--- /dev/null
+++ b/drivers/staging/media/mx3/TODO
@@ -0,0 +1,10 @@
1This driver is deprecated: it should become a stand-alone driver instead of
2using the soc-camera framework.
3
4Unless someone is willing to take this on (unlikely with such ancient
5hardware) it is going to be removed from the kernel soon.
6
7Note that trivial patches will not be accepted anymore, only a full conversion.
8
9If you want to convert this driver, please contact the linux-media mailinglist
10(see http://linuxtv.org/lists.php).
diff --git a/drivers/media/platform/soc_camera/mx3_camera.c b/drivers/staging/media/mx3/mx3_camera.c
index 169ed1150226..aa39e9569b1a 100644
--- a/drivers/media/platform/soc_camera/mx3_camera.c
+++ b/drivers/staging/media/mx3/mx3_camera.c
@@ -146,8 +146,8 @@ static void mx3_cam_dma_done(void *arg)
146 struct idmac_channel *ichannel = to_idmac_chan(chan); 146 struct idmac_channel *ichannel = to_idmac_chan(chan);
147 struct mx3_camera_dev *mx3_cam = ichannel->client; 147 struct mx3_camera_dev *mx3_cam = ichannel->client;
148 148
149 dev_dbg(chan->device->dev, "callback cookie %d, active DMA 0x%08x\n", 149 dev_dbg(chan->device->dev, "callback cookie %d, active DMA %pad\n",
150 desc->txd.cookie, mx3_cam->active ? sg_dma_address(&mx3_cam->active->sg) : 0); 150 desc->txd.cookie, mx3_cam->active ? &sg_dma_address(&mx3_cam->active->sg) : NULL);
151 151
152 spin_lock(&mx3_cam->lock); 152 spin_lock(&mx3_cam->lock);
153 if (mx3_cam->active) { 153 if (mx3_cam->active) {
@@ -314,8 +314,8 @@ static void mx3_videobuf_queue(struct vb2_buffer *vb)
314 spin_unlock_irq(&mx3_cam->lock); 314 spin_unlock_irq(&mx3_cam->lock);
315 315
316 cookie = txd->tx_submit(txd); 316 cookie = txd->tx_submit(txd);
317 dev_dbg(icd->parent, "Submitted cookie %d DMA 0x%08x\n", 317 dev_dbg(icd->parent, "Submitted cookie %d DMA %pad\n",
318 cookie, sg_dma_address(&buf->sg)); 318 cookie, &sg_dma_address(&buf->sg));
319 319
320 if (cookie >= 0) 320 if (cookie >= 0)
321 return; 321 return;
@@ -344,8 +344,8 @@ static void mx3_videobuf_release(struct vb2_buffer *vb)
344 unsigned long flags; 344 unsigned long flags;
345 345
346 dev_dbg(icd->parent, 346 dev_dbg(icd->parent,
347 "Release%s DMA 0x%08x, queue %sempty\n", 347 "Release%s DMA %pad, queue %sempty\n",
348 mx3_cam->active == buf ? " active" : "", sg_dma_address(&buf->sg), 348 mx3_cam->active == buf ? " active" : "", &sg_dma_address(&buf->sg),
349 list_empty(&buf->queue) ? "" : "not "); 349 list_empty(&buf->queue) ? "" : "not ");
350 350
351 spin_lock_irqsave(&mx3_cam->lock, flags); 351 spin_lock_irqsave(&mx3_cam->lock, flags);
diff --git a/drivers/staging/media/omap1/Kconfig b/drivers/staging/media/omap1/Kconfig
new file mode 100644
index 000000000000..6cfab3a04ae1
--- /dev/null
+++ b/drivers/staging/media/omap1/Kconfig
@@ -0,0 +1,13 @@
1config VIDEO_OMAP1
2 tristate "OMAP1 Camera Interface driver"
3 depends on VIDEO_DEV && SOC_CAMERA
4 depends on ARCH_OMAP1
5 depends on HAS_DMA
6 select VIDEOBUF_DMA_CONTIG
7 select VIDEOBUF_DMA_SG
8 ---help---
9 This is a v4l2 driver for the TI OMAP1 camera interface
10
11 This driver is deprecated and will be removed soon unless someone
12 will start the work to convert this driver to the vb2 framework
13 and remove the soc-camera dependency.
diff --git a/drivers/staging/media/omap1/Makefile b/drivers/staging/media/omap1/Makefile
new file mode 100644
index 000000000000..2885622600f2
--- /dev/null
+++ b/drivers/staging/media/omap1/Makefile
@@ -0,0 +1,3 @@
1# Makefile for OMAP1 driver
2
3obj-$(CONFIG_VIDEO_OMAP1) += omap1_camera.o
diff --git a/drivers/staging/media/omap1/TODO b/drivers/staging/media/omap1/TODO
new file mode 100644
index 000000000000..1025f9f60ff0
--- /dev/null
+++ b/drivers/staging/media/omap1/TODO
@@ -0,0 +1,8 @@
1This driver is deprecated and will be removed soon unless someone will start
2the work to convert this driver to the vb2 framework and remove the
3soc-camera dependency.
4
5Note that trivial patches will not be accepted anymore, only a full conversion.
6
7If you want to convert this driver, please contact the linux-media mailinglist
8(see http://linuxtv.org/lists.php).
diff --git a/drivers/media/platform/soc_camera/omap1_camera.c b/drivers/staging/media/omap1/omap1_camera.c
index bd721e35474a..bd721e35474a 100644
--- a/drivers/media/platform/soc_camera/omap1_camera.c
+++ b/drivers/staging/media/omap1/omap1_camera.c
diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c
index 30b473cfb020..fb80d2bc5a25 100644
--- a/drivers/staging/media/omap4iss/iss.c
+++ b/drivers/staging/media/omap4iss/iss.c
@@ -363,215 +363,6 @@ static irqreturn_t iss_isr(int irq, void *_iss)
363} 363}
364 364
365/* ----------------------------------------------------------------------------- 365/* -----------------------------------------------------------------------------
366 * Pipeline power management
367 *
368 * Entities must be powered up when part of a pipeline that contains at least
369 * one open video device node.
370 *
371 * To achieve this use the entity use_count field to track the number of users.
372 * For entities corresponding to video device nodes the use_count field stores
373 * the users count of the node. For entities corresponding to subdevs the
374 * use_count field stores the total number of users of all video device nodes
375 * in the pipeline.
376 *
377 * The omap4iss_pipeline_pm_use() function must be called in the open() and
378 * close() handlers of video device nodes. It increments or decrements the use
379 * count of all subdev entities in the pipeline.
380 *
381 * To react to link management on powered pipelines, the link setup notification
382 * callback updates the use count of all entities in the source and sink sides
383 * of the link.
384 */
385
386/*
387 * iss_pipeline_pm_use_count - Count the number of users of a pipeline
388 * @entity: The entity
389 *
390 * Return the total number of users of all video device nodes in the pipeline.
391 */
392static int iss_pipeline_pm_use_count(struct media_entity *entity,
393 struct media_entity_graph *graph)
394{
395 int use = 0;
396
397 media_entity_graph_walk_start(graph, entity);
398
399 while ((entity = media_entity_graph_walk_next(graph))) {
400 if (is_media_entity_v4l2_io(entity))
401 use += entity->use_count;
402 }
403
404 return use;
405}
406
407/*
408 * iss_pipeline_pm_power_one - Apply power change to an entity
409 * @entity: The entity
410 * @change: Use count change
411 *
412 * Change the entity use count by @change. If the entity is a subdev update its
413 * power state by calling the core::s_power operation when the use count goes
414 * from 0 to != 0 or from != 0 to 0.
415 *
416 * Return 0 on success or a negative error code on failure.
417 */
418static int iss_pipeline_pm_power_one(struct media_entity *entity, int change)
419{
420 struct v4l2_subdev *subdev;
421
422 subdev = is_media_entity_v4l2_subdev(entity)
423 ? media_entity_to_v4l2_subdev(entity) : NULL;
424
425 if (entity->use_count == 0 && change > 0 && subdev) {
426 int ret;
427
428 ret = v4l2_subdev_call(subdev, core, s_power, 1);
429 if (ret < 0 && ret != -ENOIOCTLCMD)
430 return ret;
431 }
432
433 entity->use_count += change;
434 WARN_ON(entity->use_count < 0);
435
436 if (entity->use_count == 0 && change < 0 && subdev)
437 v4l2_subdev_call(subdev, core, s_power, 0);
438
439 return 0;
440}
441
442/*
443 * iss_pipeline_pm_power - Apply power change to all entities in a pipeline
444 * @entity: The entity
445 * @change: Use count change
446 *
447 * Walk the pipeline to update the use count and the power state of all non-node
448 * entities.
449 *
450 * Return 0 on success or a negative error code on failure.
451 */
452static int iss_pipeline_pm_power(struct media_entity *entity, int change,
453 struct media_entity_graph *graph)
454{
455 struct media_entity *first = entity;
456 int ret = 0;
457
458 if (!change)
459 return 0;
460
461 media_entity_graph_walk_start(graph, entity);
462
463 while (!ret && (entity = media_entity_graph_walk_next(graph)))
464 if (is_media_entity_v4l2_subdev(entity))
465 ret = iss_pipeline_pm_power_one(entity, change);
466
467 if (!ret)
468 return 0;
469
470 media_entity_graph_walk_start(graph, first);
471
472 while ((first = media_entity_graph_walk_next(graph)) &&
473 first != entity)
474 if (is_media_entity_v4l2_subdev(first))
475 iss_pipeline_pm_power_one(first, -change);
476
477 return ret;
478}
479
480/*
481 * omap4iss_pipeline_pm_use - Update the use count of an entity
482 * @entity: The entity
483 * @use: Use (1) or stop using (0) the entity
484 *
485 * Update the use count of all entities in the pipeline and power entities on or
486 * off accordingly.
487 *
488 * Return 0 on success or a negative error code on failure. Powering entities
489 * off is assumed to never fail. No failure can occur when the use parameter is
490 * set to 0.
491 */
492int omap4iss_pipeline_pm_use(struct media_entity *entity, int use,
493 struct media_entity_graph *graph)
494{
495 int change = use ? 1 : -1;
496 int ret;
497
498 mutex_lock(&entity->graph_obj.mdev->graph_mutex);
499
500 /* Apply use count to node. */
501 entity->use_count += change;
502 WARN_ON(entity->use_count < 0);
503
504 /* Apply power change to connected non-nodes. */
505 ret = iss_pipeline_pm_power(entity, change, graph);
506 if (ret < 0)
507 entity->use_count -= change;
508
509 mutex_unlock(&entity->graph_obj.mdev->graph_mutex);
510
511 return ret;
512}
513
514/*
515 * iss_pipeline_link_notify - Link management notification callback
516 * @link: The link
517 * @flags: New link flags that will be applied
518 *
519 * React to link management on powered pipelines by updating the use count of
520 * all entities in the source and sink sides of the link. Entities are powered
521 * on or off accordingly.
522 *
523 * Return 0 on success or a negative error code on failure. Powering entities
524 * off is assumed to never fail. This function will not fail for disconnection
525 * events.
526 */
527static int iss_pipeline_link_notify(struct media_link *link, u32 flags,
528 unsigned int notification)
529{
530 struct media_entity_graph *graph =
531 &container_of(link->graph_obj.mdev, struct iss_device,
532 media_dev)->pm_count_graph;
533 struct media_entity *source = link->source->entity;
534 struct media_entity *sink = link->sink->entity;
535 int source_use;
536 int sink_use;
537 int ret;
538
539 if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH) {
540 ret = media_entity_graph_walk_init(graph,
541 link->graph_obj.mdev);
542 if (ret)
543 return ret;
544 }
545
546 source_use = iss_pipeline_pm_use_count(source, graph);
547 sink_use = iss_pipeline_pm_use_count(sink, graph);
548
549 if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH &&
550 !(flags & MEDIA_LNK_FL_ENABLED)) {
551 /* Powering off entities is assumed to never fail. */
552 iss_pipeline_pm_power(source, -sink_use, graph);
553 iss_pipeline_pm_power(sink, -source_use, graph);
554 return 0;
555 }
556
557 if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH &&
558 (flags & MEDIA_LNK_FL_ENABLED)) {
559 ret = iss_pipeline_pm_power(source, sink_use, graph);
560 if (ret < 0)
561 return ret;
562
563 ret = iss_pipeline_pm_power(sink, source_use, graph);
564 if (ret < 0)
565 iss_pipeline_pm_power(source, -sink_use, graph);
566 }
567
568 if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH)
569 media_entity_graph_walk_cleanup(graph);
570
571 return ret;
572}
573
574/* -----------------------------------------------------------------------------
575 * Pipeline stream management 366 * Pipeline stream management
576 */ 367 */
577 368
@@ -1197,7 +988,7 @@ static int iss_register_entities(struct iss_device *iss)
1197 strlcpy(iss->media_dev.model, "TI OMAP4 ISS", 988 strlcpy(iss->media_dev.model, "TI OMAP4 ISS",
1198 sizeof(iss->media_dev.model)); 989 sizeof(iss->media_dev.model));
1199 iss->media_dev.hw_revision = iss->revision; 990 iss->media_dev.hw_revision = iss->revision;
1200 iss->media_dev.link_notify = iss_pipeline_link_notify; 991 iss->media_dev.link_notify = v4l2_pipeline_link_notify;
1201 ret = media_device_register(&iss->media_dev); 992 ret = media_device_register(&iss->media_dev);
1202 if (ret < 0) { 993 if (ret < 0) {
1203 dev_err(iss->dev, "Media device registration failed (%d)\n", 994 dev_err(iss->dev, "Media device registration failed (%d)\n",
diff --git a/drivers/staging/media/omap4iss/iss.h b/drivers/staging/media/omap4iss/iss.h
index 05f08a3caa19..760ee27da704 100644
--- a/drivers/staging/media/omap4iss/iss.h
+++ b/drivers/staging/media/omap4iss/iss.h
@@ -15,6 +15,8 @@
15#define _OMAP4_ISS_H_ 15#define _OMAP4_ISS_H_
16 16
17#include <media/v4l2-device.h> 17#include <media/v4l2-device.h>
18#include <media/v4l2-mc.h>
19
18#include <linux/device.h> 20#include <linux/device.h>
19#include <linux/io.h> 21#include <linux/io.h>
20#include <linux/platform_device.h> 22#include <linux/platform_device.h>
@@ -87,7 +89,6 @@ struct iss_reg {
87struct iss_device { 89struct iss_device {
88 struct v4l2_device v4l2_dev; 90 struct v4l2_device v4l2_dev;
89 struct media_device media_dev; 91 struct media_device media_dev;
90 struct media_entity_graph pm_count_graph;
91 struct device *dev; 92 struct device *dev;
92 u32 revision; 93 u32 revision;
93 94
@@ -152,9 +153,6 @@ void omap4iss_isp_subclk_enable(struct iss_device *iss,
152void omap4iss_isp_subclk_disable(struct iss_device *iss, 153void omap4iss_isp_subclk_disable(struct iss_device *iss,
153 enum iss_isp_subclk_resource res); 154 enum iss_isp_subclk_resource res);
154 155
155int omap4iss_pipeline_pm_use(struct media_entity *entity, int use,
156 struct media_entity_graph *graph);
157
158int omap4iss_register_entities(struct platform_device *pdev, 156int omap4iss_register_entities(struct platform_device *pdev,
159 struct v4l2_device *v4l2_dev); 157 struct v4l2_device *v4l2_dev);
160void omap4iss_unregister_entities(struct platform_device *pdev); 158void omap4iss_unregister_entities(struct platform_device *pdev);
diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c
index 058233a9de67..f54349bce4de 100644
--- a/drivers/staging/media/omap4iss/iss_video.c
+++ b/drivers/staging/media/omap4iss/iss_video.c
@@ -19,8 +19,10 @@
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/vmalloc.h> 20#include <linux/vmalloc.h>
21#include <linux/module.h> 21#include <linux/module.h>
22
22#include <media/v4l2-dev.h> 23#include <media/v4l2-dev.h>
23#include <media/v4l2-ioctl.h> 24#include <media/v4l2-ioctl.h>
25#include <media/v4l2-mc.h>
24 26
25#include "iss_video.h" 27#include "iss_video.h"
26#include "iss.h" 28#include "iss.h"
@@ -1009,13 +1011,7 @@ static int iss_video_open(struct file *file)
1009 goto done; 1011 goto done;
1010 } 1012 }
1011 1013
1012 ret = media_entity_graph_walk_init(&handle->graph, 1014 ret = v4l2_pipeline_pm_use(&video->video.entity, 1);
1013 &video->iss->media_dev);
1014 if (ret)
1015 goto done;
1016
1017 ret = omap4iss_pipeline_pm_use(&video->video.entity, 1,
1018 &handle->graph);
1019 if (ret < 0) { 1015 if (ret < 0) {
1020 omap4iss_put(video->iss); 1016 omap4iss_put(video->iss);
1021 goto done; 1017 goto done;
@@ -1054,7 +1050,6 @@ static int iss_video_open(struct file *file)
1054done: 1050done:
1055 if (ret < 0) { 1051 if (ret < 0) {
1056 v4l2_fh_del(&handle->vfh); 1052 v4l2_fh_del(&handle->vfh);
1057 media_entity_graph_walk_cleanup(&handle->graph);
1058 kfree(handle); 1053 kfree(handle);
1059 } 1054 }
1060 1055
@@ -1070,13 +1065,11 @@ static int iss_video_release(struct file *file)
1070 /* Disable streaming and free the buffers queue resources. */ 1065 /* Disable streaming and free the buffers queue resources. */
1071 iss_video_streamoff(file, vfh, video->type); 1066 iss_video_streamoff(file, vfh, video->type);
1072 1067
1073 omap4iss_pipeline_pm_use(&video->video.entity, 0, &handle->graph); 1068 v4l2_pipeline_pm_use(&video->video.entity, 0);
1074 1069
1075 /* Release the videobuf2 queue */ 1070 /* Release the videobuf2 queue */
1076 vb2_queue_release(&handle->queue); 1071 vb2_queue_release(&handle->queue);
1077 1072
1078 /* Release the file handle. */
1079 media_entity_graph_walk_cleanup(&handle->graph);
1080 v4l2_fh_del(vfh); 1073 v4l2_fh_del(vfh);
1081 kfree(handle); 1074 kfree(handle);
1082 file->private_data = NULL; 1075 file->private_data = NULL;
diff --git a/drivers/staging/media/omap4iss/iss_video.h b/drivers/staging/media/omap4iss/iss_video.h
index 34588b7176ca..c8bd2958a3f8 100644
--- a/drivers/staging/media/omap4iss/iss_video.h
+++ b/drivers/staging/media/omap4iss/iss_video.h
@@ -183,7 +183,6 @@ struct iss_video_fh {
183 struct vb2_queue queue; 183 struct vb2_queue queue;
184 struct v4l2_format format; 184 struct v4l2_format format;
185 struct v4l2_fract timeperframe; 185 struct v4l2_fract timeperframe;
186 struct media_entity_graph graph;
187}; 186};
188 187
189#define to_iss_video_fh(fh) container_of(fh, struct iss_video_fh, vfh) 188#define to_iss_video_fh(fh) container_of(fh, struct iss_video_fh, vfh)
diff --git a/drivers/staging/media/timb/Kconfig b/drivers/staging/media/timb/Kconfig
new file mode 100644
index 000000000000..e413fecc1e67
--- /dev/null
+++ b/drivers/staging/media/timb/Kconfig
@@ -0,0 +1,11 @@
1config VIDEO_TIMBERDALE
2 tristate "Support for timberdale Video In/LogiWIN"
3 depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API && HAS_DMA
4 depends on (MFD_TIMBERDALE && TIMB_DMA) || COMPILE_TEST
5 select VIDEO_ADV7180
6 select VIDEOBUF_DMA_CONTIG
7 ---help---
8 Add support for the Video In peripherial of the timberdale FPGA.
9
10 This driver is deprecated and will be removed soon unless someone
11 will start the work to convert this driver to the vb2 framework.
diff --git a/drivers/staging/media/timb/Makefile b/drivers/staging/media/timb/Makefile
new file mode 100644
index 000000000000..4c989c23a0e0
--- /dev/null
+++ b/drivers/staging/media/timb/Makefile
@@ -0,0 +1 @@
obj-$(CONFIG_VIDEO_TIMBERDALE) += timblogiw.o
diff --git a/drivers/media/platform/timblogiw.c b/drivers/staging/media/timb/timblogiw.c
index 113c9f3c0b3e..113c9f3c0b3e 100644
--- a/drivers/media/platform/timblogiw.c
+++ b/drivers/staging/media/timb/timblogiw.c
diff --git a/drivers/usb/musb/sunxi.c b/drivers/usb/musb/sunxi.c
index d9b0dc461439..fdab4232cfbf 100644
--- a/drivers/usb/musb/sunxi.c
+++ b/drivers/usb/musb/sunxi.c
@@ -752,6 +752,7 @@ static const struct of_device_id sunxi_musb_match[] = {
752 { .compatible = "allwinner,sun8i-a33-musb", }, 752 { .compatible = "allwinner,sun8i-a33-musb", },
753 {} 753 {}
754}; 754};
755MODULE_DEVICE_TABLE(of, sunxi_musb_match);
755 756
756static struct platform_driver sunxi_musb_driver = { 757static struct platform_driver sunxi_musb_driver = {
757 .probe = sunxi_musb_probe, 758 .probe = sunxi_musb_probe,
diff --git a/include/media/i2c/tvp5150.h b/include/dt-bindings/media/tvp5150.h
index 649908a25605..c852a35e916e 100644
--- a/include/media/i2c/tvp5150.h
+++ b/include/dt-bindings/media/tvp5150.h
@@ -18,16 +18,18 @@
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#ifndef _TVP5150_H_ 21#ifndef _DT_BINDINGS_MEDIA_TVP5150_H
22#define _TVP5150_H_ 22#define _DT_BINDINGS_MEDIA_TVP5150_H
23 23
24/* TVP5150 HW inputs */ 24/* TVP5150 HW inputs */
25#define TVP5150_COMPOSITE0 0 25#define TVP5150_COMPOSITE0 0
26#define TVP5150_COMPOSITE1 1 26#define TVP5150_COMPOSITE1 1
27#define TVP5150_SVIDEO 2 27#define TVP5150_SVIDEO 2
28 28
29#define TVP5150_INPUT_NUM 3
30
29/* TVP5150 HW outputs */ 31/* TVP5150 HW outputs */
30#define TVP5150_NORMAL 0 32#define TVP5150_NORMAL 0
31#define TVP5150_BLACK_SCREEN 1 33#define TVP5150_BLACK_SCREEN 1
32 34
33#endif 35#endif /* _DT_BINDINGS_MEDIA_TVP5150_H */
diff --git a/include/media/media-device.h b/include/media/media-device.h
index d3855898c3fc..df74cfa7da4a 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -265,9 +265,29 @@ struct ida;
265struct device; 265struct device;
266 266
267/** 267/**
268 * struct media_entity_notify - Media Entity Notify
269 *
270 * @list: List head
271 * @notify_data: Input data to invoke the callback
272 * @notify: Callback function pointer
273 *
274 * Drivers may register a callback to take action when
275 * new entities get registered with the media device.
276 */
277struct media_entity_notify {
278 struct list_head list;
279 void *notify_data;
280 void (*notify)(struct media_entity *entity, void *notify_data);
281};
282
283/**
268 * struct media_device - Media device 284 * struct media_device - Media device
269 * @dev: Parent device 285 * @dev: Parent device
270 * @devnode: Media device node 286 * @devnode: Media device node
287 * @driver_name: Optional device driver name. If not set, calls to
288 * %MEDIA_IOC_DEVICE_INFO will return dev->driver->name.
289 * This is needed for USB drivers for example, as otherwise
290 * they'll all appear as if the driver name was "usb".
271 * @model: Device model name 291 * @model: Device model name
272 * @serial: Device serial number (optional) 292 * @serial: Device serial number (optional)
273 * @bus_info: Unique and stable device location identifier 293 * @bus_info: Unique and stable device location identifier
@@ -283,8 +303,16 @@ struct device;
283 * @interfaces: List of registered interfaces 303 * @interfaces: List of registered interfaces
284 * @pads: List of registered pads 304 * @pads: List of registered pads
285 * @links: List of registered links 305 * @links: List of registered links
306 * @entity_notify: List of registered entity_notify callbacks
286 * @lock: Entities list lock 307 * @lock: Entities list lock
287 * @graph_mutex: Entities graph operation lock 308 * @graph_mutex: Entities graph operation lock
309 * @pm_count_walk: Graph walk for power state walk. Access serialised using
310 * graph_mutex.
311 *
312 * @source_priv: Driver Private data for enable/disable source handlers
313 * @enable_source: Enable Source Handler function pointer
314 * @disable_source: Disable Source Handler function pointer
315 *
288 * @link_notify: Link state change notification callback 316 * @link_notify: Link state change notification callback
289 * 317 *
290 * This structure represents an abstract high-level media device. It allows easy 318 * This structure represents an abstract high-level media device. It allows easy
@@ -296,6 +324,26 @@ struct device;
296 * 324 *
297 * @model is a descriptive model name exported through sysfs. It doesn't have to 325 * @model is a descriptive model name exported through sysfs. It doesn't have to
298 * be unique. 326 * be unique.
327 *
328 * @enable_source is a handler to find source entity for the
329 * sink entity and activate the link between them if source
330 * entity is free. Drivers should call this handler before
331 * accessing the source.
332 *
333 * @disable_source is a handler to find source entity for the
334 * sink entity and deactivate the link between them. Drivers
335 * should call this handler to release the source.
336 *
337 * Note: Bridge driver is expected to implement and set the
338 * handler when media_device is registered or when
339 * bridge driver finds the media_device during probe.
340 * Bridge driver sets source_priv with information
341 * necessary to run enable/disable source handlers.
342 *
343 * Use-case: find tuner entity connected to the decoder
344 * entity and check if it is available, and activate the
345 * the link between them from enable_source and deactivate
346 * from disable_source.
299 */ 347 */
300struct media_device { 348struct media_device {
301 /* dev->driver_data points to this struct. */ 349 /* dev->driver_data points to this struct. */
@@ -303,6 +351,7 @@ struct media_device {
303 struct media_devnode devnode; 351 struct media_devnode devnode;
304 352
305 char model[32]; 353 char model[32];
354 char driver_name[32];
306 char serial[40]; 355 char serial[40];
307 char bus_info[32]; 356 char bus_info[32];
308 u32 hw_revision; 357 u32 hw_revision;
@@ -319,15 +368,28 @@ struct media_device {
319 struct list_head pads; 368 struct list_head pads;
320 struct list_head links; 369 struct list_head links;
321 370
371 /* notify callback list invoked when a new entity is registered */
372 struct list_head entity_notify;
373
322 /* Protects the graph objects creation/removal */ 374 /* Protects the graph objects creation/removal */
323 spinlock_t lock; 375 spinlock_t lock;
324 /* Serializes graph operations. */ 376 /* Serializes graph operations. */
325 struct mutex graph_mutex; 377 struct mutex graph_mutex;
378 struct media_entity_graph pm_count_walk;
379
380 void *source_priv;
381 int (*enable_source)(struct media_entity *entity,
382 struct media_pipeline *pipe);
383 void (*disable_source)(struct media_entity *entity);
326 384
327 int (*link_notify)(struct media_link *link, u32 flags, 385 int (*link_notify)(struct media_link *link, u32 flags,
328 unsigned int notification); 386 unsigned int notification);
329}; 387};
330 388
389/* We don't need to include pci.h or usb.h here */
390struct pci_dev;
391struct usb_device;
392
331#ifdef CONFIG_MEDIA_CONTROLLER 393#ifdef CONFIG_MEDIA_CONTROLLER
332 394
333/* Supported link_notify @notification values. */ 395/* Supported link_notify @notification values. */
@@ -498,6 +560,31 @@ int __must_check media_device_register_entity(struct media_device *mdev,
498void media_device_unregister_entity(struct media_entity *entity); 560void media_device_unregister_entity(struct media_entity *entity);
499 561
500/** 562/**
563 * media_device_register_entity_notify() - Registers a media entity_notify
564 * callback
565 *
566 * @mdev: The media device
567 * @nptr: The media_entity_notify
568 *
569 * Note: When a new entity is registered, all the registered
570 * media_entity_notify callbacks are invoked.
571 */
572
573int __must_check media_device_register_entity_notify(struct media_device *mdev,
574 struct media_entity_notify *nptr);
575
576/**
577 * media_device_unregister_entity_notify() - Unregister a media entity notify
578 * callback
579 *
580 * @mdev: The media device
581 * @nptr: The media_entity_notify
582 *
583 */
584void media_device_unregister_entity_notify(struct media_device *mdev,
585 struct media_entity_notify *nptr);
586
587/**
501 * media_device_get_devres() - get media device as device resource 588 * media_device_get_devres() - get media device as device resource
502 * creates if one doesn't exist 589 * creates if one doesn't exist
503 * 590 *
@@ -536,6 +623,39 @@ struct media_device *media_device_find_devres(struct device *dev);
536/* Iterate over all links. */ 623/* Iterate over all links. */
537#define media_device_for_each_link(link, mdev) \ 624#define media_device_for_each_link(link, mdev) \
538 list_for_each_entry(link, &(mdev)->links, graph_obj.list) 625 list_for_each_entry(link, &(mdev)->links, graph_obj.list)
626
627/**
628 * media_device_pci_init() - create and initialize a
629 * struct &media_device from a PCI device.
630 *
631 * @mdev: pointer to struct &media_device
632 * @pci_dev: pointer to struct pci_dev
633 * @name: media device name. If %NULL, the routine will use the default
634 * name for the pci device, given by pci_name() macro.
635 */
636void media_device_pci_init(struct media_device *mdev,
637 struct pci_dev *pci_dev,
638 const char *name);
639/**
640 * __media_device_usb_init() - create and initialize a
641 * struct &media_device from a PCI device.
642 *
643 * @mdev: pointer to struct &media_device
644 * @udev: pointer to struct usb_device
645 * @board_name: media device name. If %NULL, the routine will use the usb
646 * product name, if available.
647 * @driver_name: name of the driver. if %NULL, the routine will use the name
648 * given by udev->dev->driver->name, with is usually the wrong
649 * thing to do.
650 *
651 * NOTE: It is better to call media_device_usb_init() instead, as
652 * such macro fills driver_name with %KBUILD_MODNAME.
653 */
654void __media_device_usb_init(struct media_device *mdev,
655 struct usb_device *udev,
656 const char *board_name,
657 const char *driver_name);
658
539#else 659#else
540static inline int media_device_register(struct media_device *mdev) 660static inline int media_device_register(struct media_device *mdev)
541{ 661{
@@ -552,6 +672,17 @@ static inline int media_device_register_entity(struct media_device *mdev,
552static inline void media_device_unregister_entity(struct media_entity *entity) 672static inline void media_device_unregister_entity(struct media_entity *entity)
553{ 673{
554} 674}
675static inline int media_device_register_entity_notify(
676 struct media_device *mdev,
677 struct media_entity_notify *nptr)
678{
679 return 0;
680}
681static inline void media_device_unregister_entity_notify(
682 struct media_device *mdev,
683 struct media_entity_notify *nptr)
684{
685}
555static inline struct media_device *media_device_get_devres(struct device *dev) 686static inline struct media_device *media_device_get_devres(struct device *dev)
556{ 687{
557 return NULL; 688 return NULL;
@@ -560,5 +691,23 @@ static inline struct media_device *media_device_find_devres(struct device *dev)
560{ 691{
561 return NULL; 692 return NULL;
562} 693}
694
695static inline void media_device_pci_init(struct media_device *mdev,
696 struct pci_dev *pci_dev,
697 char *name)
698{
699}
700
701static inline void __media_device_usb_init(struct media_device *mdev,
702 struct usb_device *udev,
703 char *board_name,
704 char *driver_name)
705{
706}
707
563#endif /* CONFIG_MEDIA_CONTROLLER */ 708#endif /* CONFIG_MEDIA_CONTROLLER */
709
710#define media_device_usb_init(mdev, udev, name) \
711 __media_device_usb_init(mdev, udev, name, KBUILD_MODNAME)
712
564#endif 713#endif
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index fe485d367985..6dc9e4e8cbd4 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -24,6 +24,7 @@
24#define _MEDIA_ENTITY_H 24#define _MEDIA_ENTITY_H
25 25
26#include <linux/bitmap.h> 26#include <linux/bitmap.h>
27#include <linux/bug.h>
27#include <linux/kernel.h> 28#include <linux/kernel.h>
28#include <linux/list.h> 29#include <linux/list.h>
29#include <linux/media.h> 30#include <linux/media.h>
@@ -832,6 +833,16 @@ media_entity_graph_walk_next(struct media_entity_graph *graph);
832 */ 833 */
833__must_check int media_entity_pipeline_start(struct media_entity *entity, 834__must_check int media_entity_pipeline_start(struct media_entity *entity,
834 struct media_pipeline *pipe); 835 struct media_pipeline *pipe);
836/**
837 * __media_entity_pipeline_start - Mark a pipeline as streaming
838 *
839 * @entity: Starting entity
840 * @pipe: Media pipeline to be assigned to all entities in the pipeline.
841 *
842 * Note: This is the non-locking version of media_entity_pipeline_start()
843 */
844__must_check int __media_entity_pipeline_start(struct media_entity *entity,
845 struct media_pipeline *pipe);
835 846
836/** 847/**
837 * media_entity_pipeline_stop - Mark a pipeline as not streaming 848 * media_entity_pipeline_stop - Mark a pipeline as not streaming
@@ -848,6 +859,15 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,
848void media_entity_pipeline_stop(struct media_entity *entity); 859void media_entity_pipeline_stop(struct media_entity *entity);
849 860
850/** 861/**
862 * __media_entity_pipeline_stop - Mark a pipeline as not streaming
863 *
864 * @entity: Starting entity
865 *
866 * Note: This is the non-locking version of media_entity_pipeline_stop()
867 */
868void __media_entity_pipeline_stop(struct media_entity *entity);
869
870/**
851 * media_devnode_create() - creates and initializes a device node interface 871 * media_devnode_create() - creates and initializes a device node interface
852 * 872 *
853 * @mdev: pointer to struct &media_device 873 * @mdev: pointer to struct &media_device
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index f6494709e230..0f77b3dffb37 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -60,6 +60,7 @@ enum rc_filter_type {
60/** 60/**
61 * struct rc_dev - represents a remote control device 61 * struct rc_dev - represents a remote control device
62 * @dev: driver model's view of this device 62 * @dev: driver model's view of this device
63 * @initialized: 1 if the device init has completed, 0 otherwise
63 * @sysfs_groups: sysfs attribute groups 64 * @sysfs_groups: sysfs attribute groups
64 * @input_name: name of the input child device 65 * @input_name: name of the input child device
65 * @input_phys: physical path to the input child device 66 * @input_phys: physical path to the input child device
@@ -121,6 +122,7 @@ enum rc_filter_type {
121 */ 122 */
122struct rc_dev { 123struct rc_dev {
123 struct device dev; 124 struct device dev;
125 atomic_t initialized;
124 const struct attribute_group *sysfs_groups[5]; 126 const struct attribute_group *sysfs_groups[5];
125 const char *input_name; 127 const char *input_name;
126 const char *input_phys; 128 const char *input_phys;
diff --git a/include/media/tuner.h b/include/media/tuner.h
index e5321fda5489..b3edc14e763f 100644
--- a/include/media/tuner.h
+++ b/include/media/tuner.h
@@ -20,14 +20,7 @@
20#ifdef __KERNEL__ 20#ifdef __KERNEL__
21 21
22#include <linux/videodev2.h> 22#include <linux/videodev2.h>
23 23#include <media/v4l2-mc.h>
24/* Tuner PADs */
25/* FIXME: is this the right place for it? */
26enum tuner_pad_index {
27 TUNER_PAD_RF_INPUT,
28 TUNER_PAD_IF_OUTPUT,
29 TUNER_NUM_PADS
30};
31 24
32#define ADDR_UNSET (255) 25#define ADDR_UNSET (255)
33 26
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index da6fe9802fee..0bc9b35b8f3e 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -535,18 +535,6 @@ struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
535 u32 id, u8 max, u8 def, const s64 *qmenu_int); 535 u32 id, u8 max, u8 def, const s64 *qmenu_int);
536 536
537/** 537/**
538 * v4l2_ctrl_add_ctrl() - Add a control from another handler to this handler.
539 * @hdl: The control handler.
540 * @ctrl: The control to add.
541 *
542 * It will return NULL if it was unable to add the control reference.
543 * If the control already belonged to the handler, then it will do
544 * nothing and just return @ctrl.
545 */
546struct v4l2_ctrl *v4l2_ctrl_add_ctrl(struct v4l2_ctrl_handler *hdl,
547 struct v4l2_ctrl *ctrl);
548
549/**
550 * v4l2_ctrl_add_handler() - Add all controls from handler @add to 538 * v4l2_ctrl_add_handler() - Add all controls from handler @add to
551 * handler @hdl. 539 * handler @hdl.
552 * @hdl: The control handler. 540 * @hdl: The control handler.
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index eeabf20e87a6..76056ab5c5bd 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -87,6 +87,7 @@ struct video_device
87#if defined(CONFIG_MEDIA_CONTROLLER) 87#if defined(CONFIG_MEDIA_CONTROLLER)
88 struct media_entity entity; 88 struct media_entity entity;
89 struct media_intf_devnode *intf_devnode; 89 struct media_intf_devnode *intf_devnode;
90 struct media_pipeline pipe;
90#endif 91#endif
91 /* device ops */ 92 /* device ops */
92 const struct v4l2_file_operations *fops; 93 const struct v4l2_file_operations *fops;
diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h
new file mode 100644
index 000000000000..98a938aabdfb
--- /dev/null
+++ b/include/media/v4l2-mc.h
@@ -0,0 +1,243 @@
1/*
2 * v4l2-mc.h - Media Controller V4L2 types and prototypes
3 *
4 * Copyright (C) 2016 Mauro Carvalho Chehab <mchehab@osg.samsung.com>
5 * Copyright (C) 2006-2010 Nokia Corporation
6 * Copyright (c) 2016 Intel Corporation.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19#ifndef _V4L2_MC_H
20#define _V4L2_MC_H
21
22#include <media/media-device.h>
23#include <media/v4l2-dev.h>
24#include <linux/types.h>
25
26/**
27 * enum tuner_pad_index - tuner pad index for MEDIA_ENT_F_TUNER
28 *
29 * @TUNER_PAD_RF_INPUT: Radiofrequency (RF) sink pad, usually linked to a
30 * RF connector entity.
31 * @TUNER_PAD_OUTPUT: Tuner video output source pad. Contains the video
32 * chrominance and luminance or the hole bandwidth
33 * of the signal converted to an Intermediate Frequency
34 * (IF) or to baseband (on zero-IF tuners).
35 * @TUNER_PAD_AUD_OUT: Tuner audio output source pad. Tuners used to decode
36 * analog TV signals have an extra pad for audio output.
37 * Old tuners use an analog stage with a saw filter for
38 * the audio IF frequency. The output of the pad is, in
39 * this case, the audio IF, with should be decoded either
40 * by the bridge chipset (that's the case of cx2388x
41 * chipsets) or may require an external IF sound
42 * processor, like msp34xx. On modern silicon tuners,
43 * the audio IF decoder is usually incorporated at the
44 * tuner. On such case, the output of this pad is an
45 * audio sampled data.
46 * @TUNER_NUM_PADS: Number of pads of the tuner.
47 */
48enum tuner_pad_index {
49 TUNER_PAD_RF_INPUT,
50 TUNER_PAD_OUTPUT,
51 TUNER_PAD_AUD_OUT,
52 TUNER_NUM_PADS
53};
54
55/**
56 * enum if_vid_dec_index - video IF-PLL pad index for
57 * MEDIA_ENT_F_IF_VID_DECODER
58 *
59 * @IF_VID_DEC_PAD_IF_INPUT: video Intermediate Frequency (IF) sink pad
60 * @IF_VID_DEC_PAD_OUT: IF-PLL video output source pad. Contains the
61 * video chrominance and luminance IF signals.
62 * @IF_VID_DEC_PAD_NUM_PADS: Number of pads of the video IF-PLL.
63 */
64enum if_vid_dec_pad_index {
65 IF_VID_DEC_PAD_IF_INPUT,
66 IF_VID_DEC_PAD_OUT,
67 IF_VID_DEC_PAD_NUM_PADS
68};
69
70/**
71 * enum if_aud_dec_index - audio/sound IF-PLL pad index for
72 * MEDIA_ENT_F_IF_AUD_DECODER
73 *
74 * @IF_AUD_DEC_PAD_IF_INPUT: audio Intermediate Frequency (IF) sink pad
75 * @IF_AUD_DEC_PAD_OUT: IF-PLL audio output source pad. Contains the
76 * audio sampled stream data, usually connected
77 * to the bridge bus via an Inter-IC Sound (I2S)
78 * bus.
79 * @IF_AUD_DEC_PAD_NUM_PADS: Number of pads of the audio IF-PLL.
80 */
81enum if_aud_dec_pad_index {
82 IF_AUD_DEC_PAD_IF_INPUT,
83 IF_AUD_DEC_PAD_OUT,
84 IF_AUD_DEC_PAD_NUM_PADS
85};
86
87/**
88 * enum demod_pad_index - analog TV pad index for MEDIA_ENT_F_ATV_DECODER
89 *
90 * @DEMOD_PAD_IF_INPUT: IF input sink pad.
91 * @DEMOD_PAD_VID_OUT: Video output source pad.
92 * @DEMOD_PAD_VBI_OUT: Vertical Blank Interface (VBI) output source pad.
93 * @DEMOD_PAD_AUDIO_OUT: Audio output source pad.
94 * @DEMOD_NUM_PADS: Maximum number of output pads.
95 */
96enum demod_pad_index {
97 DEMOD_PAD_IF_INPUT,
98 DEMOD_PAD_VID_OUT,
99 DEMOD_PAD_VBI_OUT,
100 DEMOD_PAD_AUDIO_OUT,
101 DEMOD_NUM_PADS
102};
103
104/* We don't need to include pci.h or usb.h here */
105struct pci_dev;
106struct usb_device;
107
108#ifdef CONFIG_MEDIA_CONTROLLER
109/**
110 * v4l2_mc_create_media_graph() - create Media Controller links at the graph.
111 *
112 * @mdev: pointer to the &media_device struct.
113 *
114 * Add links between the entities commonly found on PC customer's hardware at
115 * the V4L2 side: camera sensors, audio and video PLL-IF decoders, tuners,
116 * analog TV decoder and I/O entities (video, VBI and Software Defined Radio).
117 * NOTE: webcams are modelled on a very simple way: the sensor is
118 * connected directly to the I/O entity. All dirty details, like
119 * scaler and crop HW are hidden. While such mapping is enough for v4l2
120 * interface centric PC-consumer's hardware, V4L2 subdev centric camera
121 * hardware should not use this routine, as it will not build the right graph.
122 */
123int v4l2_mc_create_media_graph(struct media_device *mdev);
124
125/**
126 * v4l_enable_media_source() - Hold media source for exclusive use
127 * if free
128 *
129 * @vdev: pointer to struct video_device
130 *
131 * This interface calls enable_source handler to determine if
132 * media source is free for use. The enable_source handler is
133 * responsible for checking is the media source is free and
134 * start a pipeline between the media source and the media
135 * entity associated with the video device. This interface
136 * should be called from v4l2-core and dvb-core interfaces
137 * that change the source configuration.
138 *
139 * Return: returns zero on success or a negative error code.
140 */
141int v4l_enable_media_source(struct video_device *vdev);
142
143/**
144 * v4l_disable_media_source() - Release media source
145 *
146 * @vdev: pointer to struct video_device
147 *
148 * This interface calls disable_source handler to release
149 * the media source. The disable_source handler stops the
150 * active media pipeline between the media source and the
151 * media entity associated with the video device.
152 *
153 * Return: returns zero on success or a negative error code.
154 */
155void v4l_disable_media_source(struct video_device *vdev);
156
157/*
158 * v4l_vb2q_enable_media_tuner - Hold media source for exclusive use
159 * if free.
160 * @q - pointer to struct vb2_queue
161 *
162 * Wrapper for v4l_enable_media_source(). This function should
163 * be called from v4l2-core to enable the media source with
164 * pointer to struct vb2_queue as the input argument. Some
165 * v4l2-core interfaces don't have access to video device and
166 * this interface finds the struct video_device for the q and
167 * calls v4l_enable_media_source().
168 */
169int v4l_vb2q_enable_media_source(struct vb2_queue *q);
170
171
172/**
173 * v4l2_pipeline_pm_use - Update the use count of an entity
174 * @entity: The entity
175 * @use: Use (1) or stop using (0) the entity
176 *
177 * Update the use count of all entities in the pipeline and power entities on or
178 * off accordingly.
179 *
180 * This function is intended to be called in video node open (use ==
181 * 1) and release (use == 0). It uses struct media_entity.use_count to
182 * track the power status. The use of this function should be paired
183 * with v4l2_pipeline_link_notify().
184 *
185 * Return 0 on success or a negative error code on failure. Powering entities
186 * off is assumed to never fail. No failure can occur when the use parameter is
187 * set to 0.
188 */
189int v4l2_pipeline_pm_use(struct media_entity *entity, int use);
190
191
192/**
193 * v4l2_pipeline_link_notify - Link management notification callback
194 * @link: The link
195 * @flags: New link flags that will be applied
196 * @notification: The link's state change notification type (MEDIA_DEV_NOTIFY_*)
197 *
198 * React to link management on powered pipelines by updating the use count of
199 * all entities in the source and sink sides of the link. Entities are powered
200 * on or off accordingly. The use of this function should be paired
201 * with v4l2_pipeline_pm_use().
202 *
203 * Return 0 on success or a negative error code on failure. Powering entities
204 * off is assumed to never fail. This function will not fail for disconnection
205 * events.
206 */
207int v4l2_pipeline_link_notify(struct media_link *link, u32 flags,
208 unsigned int notification);
209
210#else /* CONFIG_MEDIA_CONTROLLER */
211
212static inline int v4l2_mc_create_media_graph(struct media_device *mdev)
213{
214 return 0;
215}
216
217static inline int v4l_enable_media_source(struct video_device *vdev)
218{
219 return 0;
220}
221
222static inline void v4l_disable_media_source(struct video_device *vdev)
223{
224}
225
226static inline int v4l_vb2q_enable_media_source(struct vb2_queue *q)
227{
228 return 0;
229}
230
231static inline int v4l2_pipeline_pm_use(struct media_entity *entity, int use)
232{
233 return 0;
234}
235
236static inline int v4l2_pipeline_link_notify(struct media_link *link, u32 flags,
237 unsigned int notification)
238{
239 return 0;
240}
241
242#endif /* CONFIG_MEDIA_CONTROLLER */
243#endif /* _V4L2_MC_H */
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index b273cf9ac047..11e2dfec0198 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -179,6 +179,8 @@ struct v4l2_subdev_io_pin_config {
179 * for it to be warned when the value of a control changes. 179 * for it to be warned when the value of a control changes.
180 * 180 *
181 * @unsubscribe_event: remove event subscription from the control framework. 181 * @unsubscribe_event: remove event subscription from the control framework.
182 *
183 * @registered_async: the subdevice has been registered async.
182 */ 184 */
183struct v4l2_subdev_core_ops { 185struct v4l2_subdev_core_ops {
184 int (*log_status)(struct v4l2_subdev *sd); 186 int (*log_status)(struct v4l2_subdev *sd);
@@ -211,6 +213,7 @@ struct v4l2_subdev_core_ops {
211 struct v4l2_event_subscription *sub); 213 struct v4l2_event_subscription *sub);
212 int (*unsubscribe_event)(struct v4l2_subdev *sd, struct v4l2_fh *fh, 214 int (*unsubscribe_event)(struct v4l2_subdev *sd, struct v4l2_fh *fh,
213 struct v4l2_event_subscription *sub); 215 struct v4l2_event_subscription *sub);
216 int (*registered_async)(struct v4l2_subdev *sd);
214}; 217};
215 218
216/** 219/**
diff --git a/include/media/videobuf2-dvb.h b/include/media/videobuf2-dvb.h
index 5b64c9eac2c9..87b559024b4a 100644
--- a/include/media/videobuf2-dvb.h
+++ b/include/media/videobuf2-dvb.h
@@ -8,6 +8,10 @@
8#include <dvb_frontend.h> 8#include <dvb_frontend.h>
9 9
10#include <media/videobuf2-v4l2.h> 10#include <media/videobuf2-v4l2.h>
11
12/* We don't actually need to include media-device.h here */
13struct media_device;
14
11/* 15/*
12 * TODO: This header file should be replaced with videobuf2-core.h 16 * TODO: This header file should be replaced with videobuf2-core.h
13 * Currently, vb2_thread is not a stuff of videobuf2-core, 17 * Currently, vb2_thread is not a stuff of videobuf2-core,
@@ -50,6 +54,7 @@ int vb2_dvb_register_bus(struct vb2_dvb_frontends *f,
50 struct module *module, 54 struct module *module,
51 void *adapter_priv, 55 void *adapter_priv,
52 struct device *device, 56 struct device *device,
57 struct media_device *mdev,
53 short *adapter_nr, 58 short *adapter_nr,
54 int mfe_shared); 59 int mfe_shared);
55 60
diff --git a/include/media/vsp1.h b/include/media/vsp1.h
new file mode 100644
index 000000000000..cc541753896f
--- /dev/null
+++ b/include/media/vsp1.h
@@ -0,0 +1,33 @@
1/*
2 * vsp1.h -- R-Car VSP1 API
3 *
4 * Copyright (C) 2015 Renesas Electronics Corporation
5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
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#ifndef __MEDIA_VSP1_H__
14#define __MEDIA_VSP1_H__
15
16#include <linux/types.h>
17
18struct device;
19struct v4l2_rect;
20
21int vsp1_du_init(struct device *dev);
22
23int vsp1_du_setup_lif(struct device *dev, unsigned int width,
24 unsigned int height);
25
26int vsp1_du_atomic_begin(struct device *dev);
27int vsp1_du_atomic_update(struct device *dev, unsigned int rpf, u32 pixelformat,
28 unsigned int pitch, dma_addr_t mem[2],
29 const struct v4l2_rect *src,
30 const struct v4l2_rect *dst);
31int vsp1_du_atomic_flush(struct device *dev);
32
33#endif /* __MEDIA_VSP1_H__ */
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index a8e3a8c0d85a..df59edee25d1 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -79,6 +79,22 @@ struct media_device_info {
79#define MEDIA_ENT_F_IO_SWRADIO (MEDIA_ENT_F_BASE + 0x01003) 79#define MEDIA_ENT_F_IO_SWRADIO (MEDIA_ENT_F_BASE + 0x01003)
80 80
81/* 81/*
82 * Analog TV IF-PLL decoders
83 *
84 * It is a responsibility of the master/bridge drivers to create links
85 * for MEDIA_ENT_F_IF_VID_DECODER and MEDIA_ENT_F_IF_AUD_DECODER.
86 */
87#define MEDIA_ENT_F_IF_VID_DECODER (MEDIA_ENT_F_BASE + 0x02001)
88#define MEDIA_ENT_F_IF_AUD_DECODER (MEDIA_ENT_F_BASE + 0x02002)
89
90/*
91 * Audio Entity Functions
92 */
93#define MEDIA_ENT_F_AUDIO_CAPTURE (MEDIA_ENT_F_BASE + 0x03001)
94#define MEDIA_ENT_F_AUDIO_PLAYBACK (MEDIA_ENT_F_BASE + 0x03002)
95#define MEDIA_ENT_F_AUDIO_MIXER (MEDIA_ENT_F_BASE + 0x03003)
96
97/*
82 * Connectors 98 * Connectors
83 */ 99 */
84/* It is a responsibility of the entity drivers to add connectors and links */ 100/* It is a responsibility of the entity drivers to add connectors and links */
@@ -113,8 +129,12 @@ struct media_device_info {
113#define MEDIA_ENT_F_LENS (MEDIA_ENT_F_OLD_SUBDEV_BASE + 3) 129#define MEDIA_ENT_F_LENS (MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
114#define MEDIA_ENT_F_ATV_DECODER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 4) 130#define MEDIA_ENT_F_ATV_DECODER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
115/* 131/*
116 * It is a responsibility of the entity drivers to add connectors and links 132 * It is a responsibility of the master/bridge drivers to add connectors
117 * for the tuner entities. 133 * and links for MEDIA_ENT_F_TUNER. Please notice that some old tuners
134 * may require the usage of separate I2C chips to decode analog TV signals,
135 * when the master/bridge chipset doesn't have its own TV standard decoder.
136 * On such cases, the IF-PLL staging is mapped via one or two entities:
137 * MEDIA_ENT_F_IF_VID_DECODER and/or MEDIA_ENT_F_IF_AUD_DECODER.
118 */ 138 */
119#define MEDIA_ENT_F_TUNER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 5) 139#define MEDIA_ENT_F_TUNER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
120 140
@@ -262,6 +282,7 @@ struct media_links_enum {
262 282
263#define MEDIA_INTF_T_DVB_BASE 0x00000100 283#define MEDIA_INTF_T_DVB_BASE 0x00000100
264#define MEDIA_INTF_T_V4L_BASE 0x00000200 284#define MEDIA_INTF_T_V4L_BASE 0x00000200
285#define MEDIA_INTF_T_ALSA_BASE 0x00000300
265 286
266/* Interface types */ 287/* Interface types */
267 288
@@ -277,6 +298,15 @@ struct media_links_enum {
277#define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3) 298#define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3)
278#define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4) 299#define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4)
279 300
301#define MEDIA_INTF_T_ALSA_PCM_CAPTURE (MEDIA_INTF_T_ALSA_BASE)
302#define MEDIA_INTF_T_ALSA_PCM_PLAYBACK (MEDIA_INTF_T_ALSA_BASE + 1)
303#define MEDIA_INTF_T_ALSA_CONTROL (MEDIA_INTF_T_ALSA_BASE + 2)
304#define MEDIA_INTF_T_ALSA_COMPRESS (MEDIA_INTF_T_ALSA_BASE + 3)
305#define MEDIA_INTF_T_ALSA_RAWMIDI (MEDIA_INTF_T_ALSA_BASE + 4)
306#define MEDIA_INTF_T_ALSA_HWDEP (MEDIA_INTF_T_ALSA_BASE + 5)
307#define MEDIA_INTF_T_ALSA_SEQUENCER (MEDIA_INTF_T_ALSA_BASE + 6)
308#define MEDIA_INTF_T_ALSA_TIMER (MEDIA_INTF_T_ALSA_BASE + 7)
309
280/* 310/*
281 * MC next gen API definitions 311 * MC next gen API definitions
282 * 312 *
@@ -296,7 +326,7 @@ struct media_links_enum {
296 * later, before the adding this API upstream. 326 * later, before the adding this API upstream.
297 */ 327 */
298 328
299#if 0 /* Let's postpone it to Kernel 4.6 */ 329
300struct media_v2_entity { 330struct media_v2_entity {
301 __u32 id; 331 __u32 id;
302 char name[64]; /* FIXME: move to a property? (RFC says so) */ 332 char name[64]; /* FIXME: move to a property? (RFC says so) */
@@ -357,21 +387,12 @@ struct media_v2_topology {
357 __u64 ptr_links; 387 __u64 ptr_links;
358} __attribute__ ((packed)); 388} __attribute__ ((packed));
359 389
360static inline void __user *media_get_uptr(__u64 arg)
361{
362 return (void __user *)(uintptr_t)arg;
363}
364#endif
365
366/* ioctls */ 390/* ioctls */
367 391
368#define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info) 392#define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info)
369#define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc) 393#define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc)
370#define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum) 394#define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum)
371#define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc) 395#define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc)
372
373#if 0 /* Let's postpone it to Kernel 4.6 */
374#define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology) 396#define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology)
375#endif
376 397
377#endif /* __LINUX_MEDIA_H */ 398#endif /* __LINUX_MEDIA_H */
diff --git a/include/uapi/linux/v4l2-common.h b/include/uapi/linux/v4l2-common.h
index 15273987093e..5b3f685a2d50 100644
--- a/include/uapi/linux/v4l2-common.h
+++ b/include/uapi/linux/v4l2-common.h
@@ -10,19 +10,43 @@
10 * Copyright (C) 2012 Nokia Corporation 10 * Copyright (C) 2012 Nokia Corporation
11 * Contact: Sakari Ailus <sakari.ailus@iki.fi> 11 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
12 * 12 *
13 * This program is free software; you can redistribute it and/or 13 * This program is free software; you can redistribute it and/or modify
14 * modify it under the terms of the GNU General Public License 14 * it under the terms of the GNU General Public License as published by
15 * version 2 as published by the Free Software Foundation. 15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
16 * 17 *
17 * This program is distributed in the hope that it will be useful, but 18 * This program is distributed in the hope that it will be useful,
18 * WITHOUT ANY WARRANTY; without even the implied warranty of 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * General Public License for more details. 21 * GNU General Public License for more details.
21 * 22 *
22 * You should have received a copy of the GNU General Public License 23 * Alternatively you can redistribute this file under the terms of the
23 * along with this program; if not, write to the Free Software 24 * BSD license as stated below:
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 *
25 * 02110-1301 USA 26 * Redistribution and use in source and binary forms, with or without
27 * modification, are permitted provided that the following conditions
28 * are met:
29 * 1. Redistributions of source code must retain the above copyright
30 * notice, this list of conditions and the following disclaimer.
31 * 2. Redistributions in binary form must reproduce the above copyright
32 * notice, this list of conditions and the following disclaimer in
33 * the documentation and/or other materials provided with the
34 * distribution.
35 * 3. The names of its contributors may not be used to endorse or promote
36 * products derived from this software without specific prior written
37 * permission.
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
40 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
41 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
42 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
43 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
45 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
47 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
48 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
49 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * 50 *
27 */ 51 */
28 52
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index 2d225bcdb831..b6a357a5f053 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -390,6 +390,7 @@ enum v4l2_mpeg_video_multi_slice_mode {
390#define V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER (V4L2_CID_MPEG_BASE+226) 390#define V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER (V4L2_CID_MPEG_BASE+226)
391#define V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE (V4L2_CID_MPEG_BASE+227) 391#define V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE (V4L2_CID_MPEG_BASE+227)
392#define V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE (V4L2_CID_MPEG_BASE+228) 392#define V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE (V4L2_CID_MPEG_BASE+228)
393#define V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME (V4L2_CID_MPEG_BASE+229)
393 394
394#define V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP (V4L2_CID_MPEG_BASE+300) 395#define V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP (V4L2_CID_MPEG_BASE+300)
395#define V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP (V4L2_CID_MPEG_BASE+301) 396#define V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP (V4L2_CID_MPEG_BASE+301)
@@ -912,8 +913,18 @@ enum v4l2_dv_rgb_range {
912 V4L2_DV_RGB_RANGE_FULL = 2, 913 V4L2_DV_RGB_RANGE_FULL = 2,
913}; 914};
914 915
916#define V4L2_CID_DV_TX_IT_CONTENT_TYPE (V4L2_CID_DV_CLASS_BASE + 6)
917enum v4l2_dv_it_content_type {
918 V4L2_DV_IT_CONTENT_TYPE_GRAPHICS = 0,
919 V4L2_DV_IT_CONTENT_TYPE_PHOTO = 1,
920 V4L2_DV_IT_CONTENT_TYPE_CINEMA = 2,
921 V4L2_DV_IT_CONTENT_TYPE_GAME = 3,
922 V4L2_DV_IT_CONTENT_TYPE_NO_ITC = 4,
923};
924
915#define V4L2_CID_DV_RX_POWER_PRESENT (V4L2_CID_DV_CLASS_BASE + 100) 925#define V4L2_CID_DV_RX_POWER_PRESENT (V4L2_CID_DV_CLASS_BASE + 100)
916#define V4L2_CID_DV_RX_RGB_RANGE (V4L2_CID_DV_CLASS_BASE + 101) 926#define V4L2_CID_DV_RX_RGB_RANGE (V4L2_CID_DV_CLASS_BASE + 101)
927#define V4L2_CID_DV_RX_IT_CONTENT_TYPE (V4L2_CID_DV_CLASS_BASE + 102)
917 928
918#define V4L2_CID_FM_RX_CLASS_BASE (V4L2_CTRL_CLASS_FM_RX | 0x900) 929#define V4L2_CID_FM_RX_CLASS_BASE (V4L2_CTRL_CLASS_FM_RX | 0x900)
919#define V4L2_CID_FM_RX_CLASS (V4L2_CTRL_CLASS_FM_RX | 1) 930#define V4L2_CID_FM_RX_CLASS (V4L2_CTRL_CLASS_FM_RX | 1)
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 14cd5ebfee6d..e895975c5b0e 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -546,6 +546,10 @@ struct v4l2_pix_format {
546/* three non contiguous planes - Y, Cb, Cr */ 546/* three non contiguous planes - Y, Cb, Cr */
547#define V4L2_PIX_FMT_YUV420M v4l2_fourcc('Y', 'M', '1', '2') /* 12 YUV420 planar */ 547#define V4L2_PIX_FMT_YUV420M v4l2_fourcc('Y', 'M', '1', '2') /* 12 YUV420 planar */
548#define V4L2_PIX_FMT_YVU420M v4l2_fourcc('Y', 'M', '2', '1') /* 12 YVU420 planar */ 548#define V4L2_PIX_FMT_YVU420M v4l2_fourcc('Y', 'M', '2', '1') /* 12 YVU420 planar */
549#define V4L2_PIX_FMT_YUV422M v4l2_fourcc('Y', 'M', '1', '6') /* 16 YUV422 planar */
550#define V4L2_PIX_FMT_YVU422M v4l2_fourcc('Y', 'M', '6', '1') /* 16 YVU422 planar */
551#define V4L2_PIX_FMT_YUV444M v4l2_fourcc('Y', 'M', '2', '4') /* 24 YUV444 planar */
552#define V4L2_PIX_FMT_YVU444M v4l2_fourcc('Y', 'M', '4', '2') /* 24 YVU444 planar */
549 553
550/* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */ 554/* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */
551#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') /* 8 BGBG.. GRGR.. */ 555#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') /* 8 BGBG.. GRGR.. */
@@ -621,6 +625,9 @@ struct v4l2_pix_format {
621#define V4L2_PIX_FMT_JPGL v4l2_fourcc('J', 'P', 'G', 'L') /* JPEG-Lite */ 625#define V4L2_PIX_FMT_JPGL v4l2_fourcc('J', 'P', 'G', 'L') /* JPEG-Lite */
622#define V4L2_PIX_FMT_SE401 v4l2_fourcc('S', '4', '0', '1') /* se401 janggu compressed rgb */ 626#define V4L2_PIX_FMT_SE401 v4l2_fourcc('S', '4', '0', '1') /* se401 janggu compressed rgb */
623#define V4L2_PIX_FMT_S5C_UYVY_JPG v4l2_fourcc('S', '5', 'C', 'I') /* S5C73M3 interleaved UYVY/JPEG */ 627#define V4L2_PIX_FMT_S5C_UYVY_JPG v4l2_fourcc('S', '5', 'C', 'I') /* S5C73M3 interleaved UYVY/JPEG */
628#define V4L2_PIX_FMT_Y8I v4l2_fourcc('Y', '8', 'I', ' ') /* Greyscale 8-bit L/R interleaved */
629#define V4L2_PIX_FMT_Y12I v4l2_fourcc('Y', '1', '2', 'I') /* Greyscale 12-bit L/R interleaved */
630#define V4L2_PIX_FMT_Z16 v4l2_fourcc('Z', '1', '6', ' ') /* Depth data 16-bit */
624 631
625/* SDR formats - used only for Software Defined Radio devices */ 632/* SDR formats - used only for Software Defined Radio devices */
626#define V4L2_SDR_FMT_CU8 v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */ 633#define V4L2_SDR_FMT_CU8 v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */
diff --git a/sound/usb/Kconfig b/sound/usb/Kconfig
index a452ad7cec40..d14bf411515b 100644
--- a/sound/usb/Kconfig
+++ b/sound/usb/Kconfig
@@ -15,6 +15,7 @@ config SND_USB_AUDIO
15 select SND_RAWMIDI 15 select SND_RAWMIDI
16 select SND_PCM 16 select SND_PCM
17 select BITREVERSE 17 select BITREVERSE
18 select SND_USB_AUDIO_USE_MEDIA_CONTROLLER if MEDIA_CONTROLLER && (MEDIA_SUPPORT=y || MEDIA_SUPPORT=SND_USB_AUDIO)
18 help 19 help
19 Say Y here to include support for USB audio and USB MIDI 20 Say Y here to include support for USB audio and USB MIDI
20 devices. 21 devices.
@@ -22,6 +23,9 @@ config SND_USB_AUDIO
22 To compile this driver as a module, choose M here: the module 23 To compile this driver as a module, choose M here: the module
23 will be called snd-usb-audio. 24 will be called snd-usb-audio.
24 25
26config SND_USB_AUDIO_USE_MEDIA_CONTROLLER
27 bool
28
25config SND_USB_UA101 29config SND_USB_UA101
26 tristate "Edirol UA-101/UA-1000 driver" 30 tristate "Edirol UA-101/UA-1000 driver"
27 select SND_PCM 31 select SND_PCM
diff --git a/sound/usb/Makefile b/sound/usb/Makefile
index 2d2d122b069f..8dca3c407f5a 100644
--- a/sound/usb/Makefile
+++ b/sound/usb/Makefile
@@ -15,6 +15,8 @@ snd-usb-audio-objs := card.o \
15 quirks.o \ 15 quirks.o \
16 stream.o 16 stream.o
17 17
18snd-usb-audio-$(CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER) += media.o
19
18snd-usbmidi-lib-objs := midi.o 20snd-usbmidi-lib-objs := midi.o
19 21
20# Toplevel Module Dependency 22# Toplevel Module Dependency
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 1f09d9591276..258cf7015ce2 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -66,6 +66,7 @@
66#include "format.h" 66#include "format.h"
67#include "power.h" 67#include "power.h"
68#include "stream.h" 68#include "stream.h"
69#include "media.h"
69 70
70MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>"); 71MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
71MODULE_DESCRIPTION("USB Audio"); 72MODULE_DESCRIPTION("USB Audio");
@@ -561,6 +562,11 @@ static int usb_audio_probe(struct usb_interface *intf,
561 if (err < 0) 562 if (err < 0)
562 goto __error; 563 goto __error;
563 564
565 if (quirk->media_device) {
566 /* don't want to fail when media_snd_device_create() fails */
567 media_snd_device_create(chip, intf);
568 }
569
564 usb_chip[chip->index] = chip; 570 usb_chip[chip->index] = chip;
565 chip->num_interfaces++; 571 chip->num_interfaces++;
566 usb_set_intfdata(intf, chip); 572 usb_set_intfdata(intf, chip);
@@ -617,6 +623,14 @@ static void usb_audio_disconnect(struct usb_interface *intf)
617 list_for_each(p, &chip->midi_list) { 623 list_for_each(p, &chip->midi_list) {
618 snd_usbmidi_disconnect(p); 624 snd_usbmidi_disconnect(p);
619 } 625 }
626 /*
627 * Nice to check quirk && quirk->media_device
628 * need some special handlings. Doesn't look like
629 * we have access to quirk here
630 * Acceses mixer_list
631 */
632 media_snd_device_delete(chip);
633
620 /* release mixer resources */ 634 /* release mixer resources */
621 list_for_each_entry(mixer, &chip->mixer_list, list) { 635 list_for_each_entry(mixer, &chip->mixer_list, list) {
622 snd_usb_mixer_disconnect(mixer); 636 snd_usb_mixer_disconnect(mixer);
diff --git a/sound/usb/card.h b/sound/usb/card.h
index 71778ca4b26a..34a0898e2238 100644
--- a/sound/usb/card.h
+++ b/sound/usb/card.h
@@ -105,6 +105,8 @@ struct snd_usb_endpoint {
105 struct list_head list; 105 struct list_head list;
106}; 106};
107 107
108struct media_ctl;
109
108struct snd_usb_substream { 110struct snd_usb_substream {
109 struct snd_usb_stream *stream; 111 struct snd_usb_stream *stream;
110 struct usb_device *dev; 112 struct usb_device *dev;
@@ -156,6 +158,7 @@ struct snd_usb_substream {
156 } dsd_dop; 158 } dsd_dop;
157 159
158 bool trigger_tstamp_pending_update; /* trigger timestamp being updated from initial estimate */ 160 bool trigger_tstamp_pending_update; /* trigger timestamp being updated from initial estimate */
161 struct media_ctl *media_ctl;
159}; 162};
160 163
161struct snd_usb_stream { 164struct snd_usb_stream {
diff --git a/sound/usb/media.c b/sound/usb/media.c
new file mode 100644
index 000000000000..93a50d01490c
--- /dev/null
+++ b/sound/usb/media.c
@@ -0,0 +1,318 @@
1/*
2 * media.c - Media Controller specific ALSA driver code
3 *
4 * Copyright (c) 2016 Shuah Khan <shuahkh@osg.samsung.com>
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6 *
7 * This file is released under the GPLv2.
8 */
9
10/*
11 * This file adds Media Controller support to ALSA driver
12 * to use the Media Controller API to share tuner with DVB
13 * and V4L2 drivers that control media device. Media device
14 * is created based on existing quirks framework. Using this
15 * approach, the media controller API usage can be added for
16 * a specific device.
17*/
18
19#include <linux/init.h>
20#include <linux/list.h>
21#include <linux/mutex.h>
22#include <linux/slab.h>
23#include <linux/usb.h>
24
25#include <sound/pcm.h>
26#include <sound/core.h>
27
28#include "usbaudio.h"
29#include "card.h"
30#include "mixer.h"
31#include "media.h"
32
33static int media_snd_enable_source(struct media_ctl *mctl)
34{
35 if (mctl && mctl->media_dev->enable_source)
36 return mctl->media_dev->enable_source(&mctl->media_entity,
37 &mctl->media_pipe);
38 return 0;
39}
40
41static void media_snd_disable_source(struct media_ctl *mctl)
42{
43 if (mctl && mctl->media_dev->disable_source)
44 mctl->media_dev->disable_source(&mctl->media_entity);
45}
46
47int media_snd_stream_init(struct snd_usb_substream *subs, struct snd_pcm *pcm,
48 int stream)
49{
50 struct media_device *mdev;
51 struct media_ctl *mctl;
52 struct device *pcm_dev = &pcm->streams[stream].dev;
53 u32 intf_type;
54 int ret = 0;
55 u16 mixer_pad;
56 struct media_entity *entity;
57
58 mdev = subs->stream->chip->media_dev;
59 if (!mdev)
60 return -ENODEV;
61
62 if (subs->media_ctl)
63 return 0;
64
65 /* allocate media_ctl */
66 mctl = kzalloc(sizeof(*mctl), GFP_KERNEL);
67 if (!mctl)
68 return -ENOMEM;
69
70 mctl->media_dev = mdev;
71 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
72 intf_type = MEDIA_INTF_T_ALSA_PCM_PLAYBACK;
73 mctl->media_entity.function = MEDIA_ENT_F_AUDIO_PLAYBACK;
74 mctl->media_pad.flags = MEDIA_PAD_FL_SOURCE;
75 mixer_pad = 1;
76 } else {
77 intf_type = MEDIA_INTF_T_ALSA_PCM_CAPTURE;
78 mctl->media_entity.function = MEDIA_ENT_F_AUDIO_CAPTURE;
79 mctl->media_pad.flags = MEDIA_PAD_FL_SINK;
80 mixer_pad = 2;
81 }
82 mctl->media_entity.name = pcm->name;
83 media_entity_pads_init(&mctl->media_entity, 1, &mctl->media_pad);
84 ret = media_device_register_entity(mctl->media_dev,
85 &mctl->media_entity);
86 if (ret)
87 goto free_mctl;
88
89 mctl->intf_devnode = media_devnode_create(mdev, intf_type, 0,
90 MAJOR(pcm_dev->devt),
91 MINOR(pcm_dev->devt));
92 if (!mctl->intf_devnode) {
93 ret = -ENOMEM;
94 goto unregister_entity;
95 }
96 mctl->intf_link = media_create_intf_link(&mctl->media_entity,
97 &mctl->intf_devnode->intf,
98 MEDIA_LNK_FL_ENABLED);
99 if (!mctl->intf_link) {
100 ret = -ENOMEM;
101 goto devnode_remove;
102 }
103
104 /* create link between mixer and audio */
105 media_device_for_each_entity(entity, mdev) {
106 switch (entity->function) {
107 case MEDIA_ENT_F_AUDIO_MIXER:
108 ret = media_create_pad_link(entity, mixer_pad,
109 &mctl->media_entity, 0,
110 MEDIA_LNK_FL_ENABLED);
111 if (ret)
112 goto remove_intf_link;
113 break;
114 }
115 }
116
117 subs->media_ctl = mctl;
118 return 0;
119
120remove_intf_link:
121 media_remove_intf_link(mctl->intf_link);
122devnode_remove:
123 media_devnode_remove(mctl->intf_devnode);
124unregister_entity:
125 media_device_unregister_entity(&mctl->media_entity);
126free_mctl:
127 kfree(mctl);
128 return ret;
129}
130
131void media_snd_stream_delete(struct snd_usb_substream *subs)
132{
133 struct media_ctl *mctl = subs->media_ctl;
134
135 if (mctl && mctl->media_dev) {
136 struct media_device *mdev;
137
138 mdev = subs->stream->chip->media_dev;
139 if (mdev && media_devnode_is_registered(&mdev->devnode)) {
140 media_devnode_remove(mctl->intf_devnode);
141 media_device_unregister_entity(&mctl->media_entity);
142 media_entity_cleanup(&mctl->media_entity);
143 }
144 kfree(mctl);
145 subs->media_ctl = NULL;
146 }
147}
148
149int media_snd_start_pipeline(struct snd_usb_substream *subs)
150{
151 struct media_ctl *mctl = subs->media_ctl;
152
153 if (mctl)
154 return media_snd_enable_source(mctl);
155 return 0;
156}
157
158void media_snd_stop_pipeline(struct snd_usb_substream *subs)
159{
160 struct media_ctl *mctl = subs->media_ctl;
161
162 if (mctl)
163 media_snd_disable_source(mctl);
164}
165
166int media_snd_mixer_init(struct snd_usb_audio *chip)
167{
168 struct device *ctl_dev = &chip->card->ctl_dev;
169 struct media_intf_devnode *ctl_intf;
170 struct usb_mixer_interface *mixer;
171 struct media_device *mdev = chip->media_dev;
172 struct media_mixer_ctl *mctl;
173 u32 intf_type = MEDIA_INTF_T_ALSA_CONTROL;
174 int ret;
175
176 if (!mdev)
177 return -ENODEV;
178
179 ctl_intf = chip->ctl_intf_media_devnode;
180 if (!ctl_intf) {
181 ctl_intf = media_devnode_create(mdev, intf_type, 0,
182 MAJOR(ctl_dev->devt),
183 MINOR(ctl_dev->devt));
184 if (!ctl_intf)
185 return -ENOMEM;
186 chip->ctl_intf_media_devnode = ctl_intf;
187 }
188
189 list_for_each_entry(mixer, &chip->mixer_list, list) {
190
191 if (mixer->media_mixer_ctl)
192 continue;
193
194 /* allocate media_mixer_ctl */
195 mctl = kzalloc(sizeof(*mctl), GFP_KERNEL);
196 if (!mctl)
197 return -ENOMEM;
198
199 mctl->media_dev = mdev;
200 mctl->media_entity.function = MEDIA_ENT_F_AUDIO_MIXER;
201 mctl->media_entity.name = chip->card->mixername;
202 mctl->media_pad[0].flags = MEDIA_PAD_FL_SINK;
203 mctl->media_pad[1].flags = MEDIA_PAD_FL_SOURCE;
204 mctl->media_pad[2].flags = MEDIA_PAD_FL_SOURCE;
205 media_entity_pads_init(&mctl->media_entity, MEDIA_MIXER_PAD_MAX,
206 mctl->media_pad);
207 ret = media_device_register_entity(mctl->media_dev,
208 &mctl->media_entity);
209 if (ret) {
210 kfree(mctl);
211 return ret;
212 }
213
214 mctl->intf_link = media_create_intf_link(&mctl->media_entity,
215 &ctl_intf->intf,
216 MEDIA_LNK_FL_ENABLED);
217 if (!mctl->intf_link) {
218 media_device_unregister_entity(&mctl->media_entity);
219 media_entity_cleanup(&mctl->media_entity);
220 kfree(mctl);
221 return -ENOMEM;
222 }
223 mctl->intf_devnode = ctl_intf;
224 mixer->media_mixer_ctl = mctl;
225 }
226 return 0;
227}
228
229static void media_snd_mixer_delete(struct snd_usb_audio *chip)
230{
231 struct usb_mixer_interface *mixer;
232 struct media_device *mdev = chip->media_dev;
233
234 if (!mdev)
235 return;
236
237 list_for_each_entry(mixer, &chip->mixer_list, list) {
238 struct media_mixer_ctl *mctl;
239
240 mctl = mixer->media_mixer_ctl;
241 if (!mixer->media_mixer_ctl)
242 continue;
243
244 if (media_devnode_is_registered(&mdev->devnode)) {
245 media_device_unregister_entity(&mctl->media_entity);
246 media_entity_cleanup(&mctl->media_entity);
247 }
248 kfree(mctl);
249 mixer->media_mixer_ctl = NULL;
250 }
251 if (media_devnode_is_registered(&mdev->devnode))
252 media_devnode_remove(chip->ctl_intf_media_devnode);
253 chip->ctl_intf_media_devnode = NULL;
254}
255
256int media_snd_device_create(struct snd_usb_audio *chip,
257 struct usb_interface *iface)
258{
259 struct media_device *mdev;
260 struct usb_device *usbdev = interface_to_usbdev(iface);
261 int ret;
262
263 mdev = media_device_get_devres(&usbdev->dev);
264 if (!mdev)
265 return -ENOMEM;
266 if (!mdev->dev) {
267 /* register media device */
268 mdev->dev = &usbdev->dev;
269 if (usbdev->product)
270 strlcpy(mdev->model, usbdev->product,
271 sizeof(mdev->model));
272 if (usbdev->serial)
273 strlcpy(mdev->serial, usbdev->serial,
274 sizeof(mdev->serial));
275 strcpy(mdev->bus_info, usbdev->devpath);
276 mdev->hw_revision = le16_to_cpu(usbdev->descriptor.bcdDevice);
277 media_device_init(mdev);
278 }
279 if (!media_devnode_is_registered(&mdev->devnode)) {
280 ret = media_device_register(mdev);
281 if (ret) {
282 dev_err(&usbdev->dev,
283 "Couldn't register media device. Error: %d\n",
284 ret);
285 return ret;
286 }
287 }
288
289 /* save media device - avoid lookups */
290 chip->media_dev = mdev;
291
292 /* Create media entities for mixer and control dev */
293 ret = media_snd_mixer_init(chip);
294 if (ret) {
295 dev_err(&usbdev->dev,
296 "Couldn't create media mixer entities. Error: %d\n",
297 ret);
298
299 /* clear saved media_dev */
300 chip->media_dev = NULL;
301
302 return ret;
303 }
304 return 0;
305}
306
307void media_snd_device_delete(struct snd_usb_audio *chip)
308{
309 struct media_device *mdev = chip->media_dev;
310
311 media_snd_mixer_delete(chip);
312
313 if (mdev) {
314 if (media_devnode_is_registered(&mdev->devnode))
315 media_device_unregister(mdev);
316 chip->media_dev = NULL;
317 }
318}
diff --git a/sound/usb/media.h b/sound/usb/media.h
new file mode 100644
index 000000000000..1dcdcdc5f7aa
--- /dev/null
+++ b/sound/usb/media.h
@@ -0,0 +1,72 @@
1/*
2 * media.h - Media Controller specific ALSA driver code
3 *
4 * Copyright (c) 2016 Shuah Khan <shuahkh@osg.samsung.com>
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6 *
7 * This file is released under the GPLv2.
8 */
9
10/*
11 * This file adds Media Controller support to ALSA driver
12 * to use the Media Controller API to share tuner with DVB
13 * and V4L2 drivers that control media device. Media device
14 * is created based on existing quirks framework. Using this
15 * approach, the media controller API usage can be added for
16 * a specific device.
17*/
18#ifndef __MEDIA_H
19
20#ifdef CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER
21
22#include <media/media-device.h>
23#include <media/media-entity.h>
24#include <sound/asound.h>
25
26struct media_ctl {
27 struct media_device *media_dev;
28 struct media_entity media_entity;
29 struct media_intf_devnode *intf_devnode;
30 struct media_link *intf_link;
31 struct media_pad media_pad;
32 struct media_pipeline media_pipe;
33};
34
35/*
36 * One source pad each for SNDRV_PCM_STREAM_CAPTURE and
37 * SNDRV_PCM_STREAM_PLAYBACK. One for sink pad to link
38 * to AUDIO Source
39*/
40#define MEDIA_MIXER_PAD_MAX (SNDRV_PCM_STREAM_LAST + 2)
41
42struct media_mixer_ctl {
43 struct media_device *media_dev;
44 struct media_entity media_entity;
45 struct media_intf_devnode *intf_devnode;
46 struct media_link *intf_link;
47 struct media_pad media_pad[MEDIA_MIXER_PAD_MAX];
48 struct media_pipeline media_pipe;
49};
50
51int media_snd_device_create(struct snd_usb_audio *chip,
52 struct usb_interface *iface);
53void media_snd_device_delete(struct snd_usb_audio *chip);
54int media_snd_stream_init(struct snd_usb_substream *subs, struct snd_pcm *pcm,
55 int stream);
56void media_snd_stream_delete(struct snd_usb_substream *subs);
57int media_snd_start_pipeline(struct snd_usb_substream *subs);
58void media_snd_stop_pipeline(struct snd_usb_substream *subs);
59#else
60static inline int media_snd_device_create(struct snd_usb_audio *chip,
61 struct usb_interface *iface)
62 { return 0; }
63static inline void media_snd_device_delete(struct snd_usb_audio *chip) { }
64static inline int media_snd_stream_init(struct snd_usb_substream *subs,
65 struct snd_pcm *pcm, int stream)
66 { return 0; }
67static inline void media_snd_stream_delete(struct snd_usb_substream *subs) { }
68static inline int media_snd_start_pipeline(struct snd_usb_substream *subs)
69 { return 0; }
70static inline void media_snd_stop_pipeline(struct snd_usb_substream *subs) { }
71#endif
72#endif /* __MEDIA_H */
diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h
index 3417ef347e40..f3789446ab9c 100644
--- a/sound/usb/mixer.h
+++ b/sound/usb/mixer.h
@@ -3,6 +3,8 @@
3 3
4#include <sound/info.h> 4#include <sound/info.h>
5 5
6struct media_mixer_ctl;
7
6struct usb_mixer_interface { 8struct usb_mixer_interface {
7 struct snd_usb_audio *chip; 9 struct snd_usb_audio *chip;
8 struct usb_host_interface *hostif; 10 struct usb_host_interface *hostif;
@@ -22,6 +24,7 @@ struct usb_mixer_interface {
22 struct urb *rc_urb; 24 struct urb *rc_urb;
23 struct usb_ctrlrequest *rc_setup_packet; 25 struct usb_ctrlrequest *rc_setup_packet;
24 u8 rc_buffer[6]; 26 u8 rc_buffer[6];
27 struct media_mixer_ctl *media_mixer_ctl;
25}; 28};
26 29
27#define MAX_CHANNELS 16 /* max logical channels */ 30#define MAX_CHANNELS 16 /* max logical channels */
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 9245f52d43bd..b0370d5f33f8 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -35,6 +35,7 @@
35#include "pcm.h" 35#include "pcm.h"
36#include "clock.h" 36#include "clock.h"
37#include "power.h" 37#include "power.h"
38#include "media.h"
38 39
39#define SUBSTREAM_FLAG_DATA_EP_STARTED 0 40#define SUBSTREAM_FLAG_DATA_EP_STARTED 0
40#define SUBSTREAM_FLAG_SYNC_EP_STARTED 1 41#define SUBSTREAM_FLAG_SYNC_EP_STARTED 1
@@ -715,10 +716,14 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
715 struct audioformat *fmt; 716 struct audioformat *fmt;
716 int ret; 717 int ret;
717 718
719 ret = media_snd_start_pipeline(subs);
720 if (ret)
721 return ret;
722
718 ret = snd_pcm_lib_alloc_vmalloc_buffer(substream, 723 ret = snd_pcm_lib_alloc_vmalloc_buffer(substream,
719 params_buffer_bytes(hw_params)); 724 params_buffer_bytes(hw_params));
720 if (ret < 0) 725 if (ret < 0)
721 return ret; 726 goto err_ret;
722 727
723 subs->pcm_format = params_format(hw_params); 728 subs->pcm_format = params_format(hw_params);
724 subs->period_bytes = params_period_bytes(hw_params); 729 subs->period_bytes = params_period_bytes(hw_params);
@@ -732,22 +737,27 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
732 dev_dbg(&subs->dev->dev, 737 dev_dbg(&subs->dev->dev,
733 "cannot set format: format = %#x, rate = %d, channels = %d\n", 738 "cannot set format: format = %#x, rate = %d, channels = %d\n",
734 subs->pcm_format, subs->cur_rate, subs->channels); 739 subs->pcm_format, subs->cur_rate, subs->channels);
735 return -EINVAL; 740 ret = -EINVAL;
741 goto err_ret;
736 } 742 }
737 743
738 ret = snd_usb_lock_shutdown(subs->stream->chip); 744 ret = snd_usb_lock_shutdown(subs->stream->chip);
739 if (ret < 0) 745 if (ret < 0)
740 return ret; 746 goto err_ret;
741 ret = set_format(subs, fmt); 747 ret = set_format(subs, fmt);
742 snd_usb_unlock_shutdown(subs->stream->chip); 748 snd_usb_unlock_shutdown(subs->stream->chip);
743 if (ret < 0) 749 if (ret < 0)
744 return ret; 750 goto err_ret;
745 751
746 subs->interface = fmt->iface; 752 subs->interface = fmt->iface;
747 subs->altset_idx = fmt->altset_idx; 753 subs->altset_idx = fmt->altset_idx;
748 subs->need_setup_ep = true; 754 subs->need_setup_ep = true;
749 755
750 return 0; 756 return 0;
757
758err_ret:
759 media_snd_stop_pipeline(subs);
760 return ret;
751} 761}
752 762
753/* 763/*
@@ -759,6 +769,7 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream)
759{ 769{
760 struct snd_usb_substream *subs = substream->runtime->private_data; 770 struct snd_usb_substream *subs = substream->runtime->private_data;
761 771
772 media_snd_stop_pipeline(subs);
762 subs->cur_audiofmt = NULL; 773 subs->cur_audiofmt = NULL;
763 subs->cur_rate = 0; 774 subs->cur_rate = 0;
764 subs->period_bytes = 0; 775 subs->period_bytes = 0;
@@ -1219,6 +1230,7 @@ static int snd_usb_pcm_open(struct snd_pcm_substream *substream, int direction)
1219 struct snd_usb_stream *as = snd_pcm_substream_chip(substream); 1230 struct snd_usb_stream *as = snd_pcm_substream_chip(substream);
1220 struct snd_pcm_runtime *runtime = substream->runtime; 1231 struct snd_pcm_runtime *runtime = substream->runtime;
1221 struct snd_usb_substream *subs = &as->substream[direction]; 1232 struct snd_usb_substream *subs = &as->substream[direction];
1233 int ret;
1222 1234
1223 subs->interface = -1; 1235 subs->interface = -1;
1224 subs->altset_idx = 0; 1236 subs->altset_idx = 0;
@@ -1232,7 +1244,12 @@ static int snd_usb_pcm_open(struct snd_pcm_substream *substream, int direction)
1232 subs->dsd_dop.channel = 0; 1244 subs->dsd_dop.channel = 0;
1233 subs->dsd_dop.marker = 1; 1245 subs->dsd_dop.marker = 1;
1234 1246
1235 return setup_hw_info(runtime, subs); 1247 ret = setup_hw_info(runtime, subs);
1248 if (ret == 0)
1249 ret = media_snd_stream_init(subs, as->pcm, direction);
1250 if (ret)
1251 snd_usb_autosuspend(subs->stream->chip);
1252 return ret;
1236} 1253}
1237 1254
1238static int snd_usb_pcm_close(struct snd_pcm_substream *substream, int direction) 1255static int snd_usb_pcm_close(struct snd_pcm_substream *substream, int direction)
@@ -1241,6 +1258,7 @@ static int snd_usb_pcm_close(struct snd_pcm_substream *substream, int direction)
1241 struct snd_usb_substream *subs = &as->substream[direction]; 1258 struct snd_usb_substream *subs = &as->substream[direction];
1242 1259
1243 stop_endpoints(subs, true); 1260 stop_endpoints(subs, true);
1261 media_snd_stop_pipeline(subs);
1244 1262
1245 if (subs->interface >= 0 && 1263 if (subs->interface >= 0 &&
1246 !snd_usb_lock_shutdown(subs->stream->chip)) { 1264 !snd_usb_lock_shutdown(subs->stream->chip)) {
diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
index c60a776e815d..9d087b19c70c 100644
--- a/sound/usb/quirks-table.h
+++ b/sound/usb/quirks-table.h
@@ -2886,6 +2886,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2886 .product_name = pname, \ 2886 .product_name = pname, \
2887 .ifnum = QUIRK_ANY_INTERFACE, \ 2887 .ifnum = QUIRK_ANY_INTERFACE, \
2888 .type = QUIRK_AUDIO_ALIGN_TRANSFER, \ 2888 .type = QUIRK_AUDIO_ALIGN_TRANSFER, \
2889 .media_device = 1, \
2889 } \ 2890 } \
2890} 2891}
2891 2892
diff --git a/sound/usb/stream.c b/sound/usb/stream.c
index c4dc577ab1bd..51258a15f653 100644
--- a/sound/usb/stream.c
+++ b/sound/usb/stream.c
@@ -36,6 +36,7 @@
36#include "format.h" 36#include "format.h"
37#include "clock.h" 37#include "clock.h"
38#include "stream.h" 38#include "stream.h"
39#include "media.h"
39 40
40/* 41/*
41 * free a substream 42 * free a substream
@@ -52,6 +53,7 @@ static void free_substream(struct snd_usb_substream *subs)
52 kfree(fp); 53 kfree(fp);
53 } 54 }
54 kfree(subs->rate_list.list); 55 kfree(subs->rate_list.list);
56 media_snd_stream_delete(subs);
55} 57}
56 58
57 59
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h
index b665d85555cb..a161c7c1b126 100644
--- a/sound/usb/usbaudio.h
+++ b/sound/usb/usbaudio.h
@@ -30,6 +30,9 @@
30 * 30 *
31 */ 31 */
32 32
33struct media_device;
34struct media_intf_devnode;
35
33struct snd_usb_audio { 36struct snd_usb_audio {
34 int index; 37 int index;
35 struct usb_device *dev; 38 struct usb_device *dev;
@@ -60,6 +63,8 @@ struct snd_usb_audio {
60 bool autoclock; /* from the 'autoclock' module param */ 63 bool autoclock; /* from the 'autoclock' module param */
61 64
62 struct usb_host_interface *ctrl_intf; /* the audio control interface */ 65 struct usb_host_interface *ctrl_intf; /* the audio control interface */
66 struct media_device *media_dev;
67 struct media_intf_devnode *ctl_intf_media_devnode;
63}; 68};
64 69
65#define usb_audio_err(chip, fmt, args...) \ 70#define usb_audio_err(chip, fmt, args...) \
@@ -110,6 +115,7 @@ struct snd_usb_audio_quirk {
110 const char *product_name; 115 const char *product_name;
111 int16_t ifnum; 116 int16_t ifnum;
112 uint16_t type; 117 uint16_t type;
118 bool media_device;
113 const void *data; 119 const void *data;
114}; 120};
115 121