aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2016-02-24 19:30:59 -0500
committerDave Airlie <airlied@redhat.com>2016-02-24 19:30:59 -0500
commit0041ee4d3642f9ad80a479fbe51a4bc7f3cd8294 (patch)
tree84434b300002445bbf170bebee148cc719cf7829
parentd2eaa59000c7717e68a75cf2c106f056d2bc30b4 (diff)
parent7863ac504bc5473eb99c4356120aa372d453143e (diff)
Merge branch 'drm/next/du' of git://linuxtv.org/pinchartl/fbdev into drm-next
rcar-du updates. * 'drm/next/du' of git://linuxtv.org/pinchartl/fbdev: (281 commits) drm: rcar-du: Add tri-planar memory formats support drm: rcar-du: Add probe deferral debug messages drm: rcar-du: lvds: Add R-Car Gen3 support drm: rcar-du: lvds: Rename PLLEN bit to PLLON drm: rcar-du: lvds: Fix PLL frequency-related configuration drm: rcar-du: lvds: Avoid duplication of clock clamp code drm: rcar-du: Add R8A7795 device support drm: rcar-du: Output the DISP signal on the ODDF pin drm: rcar-du: Output the DISP signal on the DISP pin drm: rcar-du: Support up to 4 CRTCs drm: rcar-du: Drop LVDS double dependency on OF drm: rcar-du: Enable compilation on ARM64 drm: rcar-du: Fix compile warning on 64-bit platforms drm: rcar-du: Expose the VSP1 compositor through KMS planes drm: rcar-du: Move plane allocator to rcar_du_plane.c drm: rcar-du: Restart the DU group when a plane source changes drm: rcar-du: Add VSP1 compositor support drm: rcar-du: Add VSP1 support to the planes allocator drm: rcar-du: Refactor plane setup drm: rcar-du: Compute plane DDCR4 register value directly ...
-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.xml33
-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.xml3
-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/display/renesas,du.txt16
-rw-r--r--Documentation/devicetree/bindings/media/i2c/mt9v032.txt2
-rw-r--r--Documentation/devicetree/bindings/media/i2c/tvp5150.txt88
-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/v4l2-controls.txt1
-rw-r--r--MAINTAINERS8
-rw-r--r--drivers/gpu/drm/rcar-du/Kconfig15
-rw-r--r--drivers/gpu/drm/rcar-du/Makefile2
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_crtc.c75
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_crtc.h4
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_drv.c218
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_drv.h12
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_encoder.c6
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_group.c74
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_group.h4
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c11
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_hdmienc.c16
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_kms.c313
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c11
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c142
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h6
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_plane.c465
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_plane.h21
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_regs.h21
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_vgacon.c11
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_vsp.c384
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_vsp.h76
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_lvds_regs.h26
-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.h8
-rw-r--r--drivers/media/dvb-core/dvb_frontend.c83
-rw-r--r--drivers/media/dvb-core/dvb_frontend.h3
-rw-r--r--drivers/media/dvb-core/dvbdev.c13
-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_dig.c4
-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.c4
-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.c4
-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.c27
-rw-r--r--drivers/media/dvb-frontends/dibx000_common.c2
-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/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.c4
-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.c4
-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/adp1653.c2
-rw-r--r--drivers/media/i2c/adv7511.c43
-rw-r--r--drivers/media/i2c/adv7604.c227
-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.c25
-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.c13
-rw-r--r--drivers/media/media-devnode.c1
-rw-r--r--drivers/media/media-entity.c18
-rw-r--r--drivers/media/pci/b2c2/flexcop-pci.c2
-rw-r--r--drivers/media/pci/bt8xx/bttv-driver.c27
-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.c3
-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/netup_unidvb/netup_unidvb_core.c7
-rw-r--r--drivers/media/pci/ngene/ngene-cards.c2
-rw-r--r--drivers/media/pci/saa7134/saa7134-cards.c1813
-rw-r--r--drivers/media/pci/saa7134/saa7134-core.c193
-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-tvaudio.c13
-rw-r--r--drivers/media/pci/saa7134/saa7134-video.c108
-rw-r--r--drivers/media/pci/saa7134/saa7134.h45
-rw-r--r--drivers/media/pci/ttpci/av7110.c2
-rw-r--r--drivers/media/pci/ttpci/budget.c4
-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/davinci/dm644x_ccdc.c2
-rw-r--r--drivers/media/platform/exynos-gsc/gsc-m2m.c2
-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.c13
-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.c103
-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/rcar_vin.c2
-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.c1971
-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.h2
-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/nuvoton-cir.c252
-rw-r--r--drivers/media/rc/nuvoton-cir.h12
-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.c45
-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/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.c172
-rw-r--r--drivers/media/usb/au0828/au0828-dvb.c12
-rw-r--r--drivers/media/usb/au0828/au0828-video.c166
-rw-r--r--drivers/media/usb/au0828/au0828.h21
-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.c70
-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.c4
-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.c17
-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.c8
-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.c17
-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.c12
-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.c2
-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.c196
-rw-r--r--drivers/media/usb/em28xx/em28xx-dvb.c21
-rw-r--r--drivers/media/usb/em28xx/em28xx-video.c211
-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/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/pwc/pwc-if.c6
-rw-r--r--drivers/media/usb/siano/smsusb.c32
-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/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-ioctl.c4
-rw-r--r--drivers/media/v4l2-core/v4l2-mc.c258
-rw-r--r--drivers/media/v4l2-core/v4l2-of.c2
-rw-r--r--drivers/media/v4l2-core/videobuf2-core.c1
-rw-r--r--drivers/media/v4l2-core/videobuf2-dvb.c13
-rw-r--r--drivers/staging/media/Kconfig2
-rw-r--r--drivers/staging/media/Makefile1
-rw-r--r--drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h2
-rw-r--r--drivers/staging/media/davinci_vpfe/vpfe_video.c2
-rw-r--r--drivers/staging/media/lirc/lirc_parallel.c24
-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--include/dt-bindings/media/tvp5150.h (renamed from include/media/i2c/tvp5150.h)8
-rw-r--r--include/media/media-device.h5
-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-mc.h172
-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.h43
-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.h4
342 files changed, 10717 insertions, 3969 deletions
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 1af384250910..8b4fa39cf611 100644
--- a/Documentation/DocBook/media/v4l/media-types.xml
+++ b/Documentation/DocBook/media/v4l/media-types.xml
@@ -57,10 +57,6 @@
57 <entry>Connector for a RGB composite signal.</entry> 57 <entry>Connector for a RGB composite signal.</entry>
58 </row> 58 </row>
59 <row> 59 <row>
60 <entry><constant>MEDIA_ENT_F_CONN_TEST</constant></entry>
61 <entry>Connector for a test generator.</entry>
62 </row>
63 <row>
64 <entry><constant>MEDIA_ENT_F_CAM_SENSOR</constant></entry> 60 <entry><constant>MEDIA_ENT_F_CAM_SENSOR</constant></entry>
65 <entry>Camera video sensor entity.</entry> 61 <entry>Camera video sensor entity.</entry>
66 </row> 62 </row>
@@ -84,7 +80,34 @@
84 </row> 80 </row>
85 <row> 81 <row>
86 <entry><constant>MEDIA_ENT_F_TUNER</constant></entry> 82 <entry><constant>MEDIA_ENT_F_TUNER</constant></entry>
87 <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>
88 </row> 111 </row>
89 </tbody> 112 </tbody>
90 </tgroup> 113 </tgroup>
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.xml b/Documentation/DocBook/media/v4l/pixfmt.xml
index d871245d2973..2f02f9441443 100644
--- a/Documentation/DocBook/media/v4l/pixfmt.xml
+++ b/Documentation/DocBook/media/v4l/pixfmt.xml
@@ -1628,7 +1628,8 @@ information.</para>
1628 &sub-y41p; 1628 &sub-y41p;
1629 &sub-yuv420; 1629 &sub-yuv420;
1630 &sub-yuv420m; 1630 &sub-yuv420m;
1631 &sub-yvu420m; 1631 &sub-yuv422m;
1632 &sub-yuv444m;
1632 &sub-yuv410; 1633 &sub-yuv410;
1633 &sub-yuv422p; 1634 &sub-yuv422p;
1634 &sub-yuv411p; 1635 &sub-yuv411p;
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/display/renesas,du.txt b/Documentation/devicetree/bindings/display/renesas,du.txt
index eccd4f4867b2..0d30e42e40be 100644
--- a/Documentation/devicetree/bindings/display/renesas,du.txt
+++ b/Documentation/devicetree/bindings/display/renesas,du.txt
@@ -8,6 +8,7 @@ Required Properties:
8 - "renesas,du-r8a7791" for R8A7791 (R-Car M2-W) compatible DU 8 - "renesas,du-r8a7791" for R8A7791 (R-Car M2-W) compatible DU
9 - "renesas,du-r8a7793" for R8A7793 (R-Car M2-N) compatible DU 9 - "renesas,du-r8a7793" for R8A7793 (R-Car M2-N) compatible DU
10 - "renesas,du-r8a7794" for R8A7794 (R-Car E2) compatible DU 10 - "renesas,du-r8a7794" for R8A7794 (R-Car E2) compatible DU
11 - "renesas,du-r8a7795" for R8A7795 (R-Car H3) compatible DU
11 12
12 - reg: A list of base address and length of each memory resource, one for 13 - reg: A list of base address and length of each memory resource, one for
13 each entry in the reg-names property. 14 each entry in the reg-names property.
@@ -24,7 +25,7 @@ Required Properties:
24 - clock-names: Name of the clocks. This property is model-dependent. 25 - clock-names: Name of the clocks. This property is model-dependent.
25 - R8A7779 uses a single functional clock. The clock doesn't need to be 26 - R8A7779 uses a single functional clock. The clock doesn't need to be
26 named. 27 named.
27 - R8A779[0134] use one functional clock per channel and one clock per LVDS 28 - R8A779[01345] use one functional clock per channel and one clock per LVDS
28 encoder (if available). The functional clocks must be named "du.x" with 29 encoder (if available). The functional clocks must be named "du.x" with
29 "x" being the channel numerical index. The LVDS clocks must be named 30 "x" being the channel numerical index. The LVDS clocks must be named
30 "lvds.x" with "x" being the LVDS encoder numerical index. 31 "lvds.x" with "x" being the LVDS encoder numerical index.
@@ -41,13 +42,14 @@ bindings specified in Documentation/devicetree/bindings/graph.txt.
41The following table lists for each supported model the port number 42The following table lists for each supported model the port number
42corresponding to each DU output. 43corresponding to each DU output.
43 44
44 Port 0 Port1 Port2 45 Port 0 Port1 Port2 Port3
45----------------------------------------------------------------------------- 46-----------------------------------------------------------------------------
46 R8A7779 (H1) DPAD 0 DPAD 1 - 47 R8A7779 (H1) DPAD 0 DPAD 1 - -
47 R8A7790 (H2) DPAD LVDS 0 LVDS 1 48 R8A7790 (H2) DPAD LVDS 0 LVDS 1 -
48 R8A7791 (M2-W) DPAD LVDS 0 - 49 R8A7791 (M2-W) DPAD LVDS 0 - -
49 R8A7793 (M2-N) DPAD LVDS 0 - 50 R8A7793 (M2-N) DPAD LVDS 0 - -
50 R8A7794 (E2) DPAD 0 DPAD 1 - 51 R8A7794 (E2) DPAD 0 DPAD 1 - -
52 R8A7795 (H3) DPAD HDMI 0 HDMI 1 LVDS
51 53
52 54
53Example: R8A7790 (R-Car H2) DU 55Example: R8A7790 (R-Car H2) DU
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..daa20e43a8e3
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/tvp5150.txt
@@ -0,0 +1,88 @@
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
15Optional nodes:
16- connectors: The input connectors of tvp5150 have to be defined under
17 a subnode name "connectors" using the following format:
18
19 input-connector-name {
20 input connector properties
21 };
22
23Each input connector must contain the following properties:
24
25 - label: a name for the connector.
26 - input: the input connector.
27
28The possible values for the "input" property are:
29 0: Composite0
30 1: Composite1
31 2: S-Video
32
33and on a tvp5150am1 and tvp5151 there is another:
34 4: Signal generator
35
36The list of valid input connectors are defined in dt-bindings/media/tvp5150.h
37header file and can be included by device tree source files.
38
39Each input connector can be defined only once.
40
41The device node must contain one 'port' child node for its digital output
42video port, in accordance with the video interface bindings defined in
43Documentation/devicetree/bindings/media/video-interfaces.txt.
44
45Required Endpoint Properties for parallel synchronization:
46
47- hsync-active: active state of the HSYNC signal. Must be <1> (HIGH).
48- vsync-active: active state of the VSYNC signal. Must be <1> (HIGH).
49- field-even-active: field signal level during the even field data
50 transmission. Must be <0>.
51
52If none of hsync-active, vsync-active and field-even-active is specified,
53the endpoint is assumed to use embedded BT.656 synchronization.
54
55Example:
56
57&i2c2 {
58 ...
59 tvp5150@5c {
60 compatible = "ti,tvp5150";
61 reg = <0x5c>;
62 pdn-gpios = <&gpio4 30 GPIO_ACTIVE_LOW>;
63 reset-gpios = <&gpio6 7 GPIO_ACTIVE_LOW>;
64
65 connectors {
66 composite0 {
67 label = "Composite0";
68 input = <TVP5150_COMPOSITE0>;
69 };
70
71 composite1 {
72 label = "Composite1";
73 input = <TVP5150_COMPOSITE1>;
74 };
75
76 s-video {
77 label = "S-Video";
78 input = <TVP5150_SVIDEO>;
79 };
80 };
81
82 port {
83 tvp5150_1: endpoint {
84 remote-endpoint = <&ccdc_ep>;
85 };
86 };
87 };
88};
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/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 c647c40e141d..5673421670a6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10855,6 +10855,14 @@ L: linux-omap@vger.kernel.org
10855S: Maintained 10855S: Maintained
10856F: drivers/thermal/ti-soc-thermal/ 10856F: drivers/thermal/ti-soc-thermal/
10857 10857
10858TI VPE/CAL DRIVERS
10859M: Benoit Parrot <bparrot@ti.com>
10860L: linux-media@vger.kernel.org
10861W: http://linuxtv.org/
10862Q: http://patchwork.linuxtv.org/project/linux-media/list/
10863S: Maintained
10864F: drivers/media/platform/ti-vpe/
10865
10858TI CDCE706 CLOCK DRIVER 10866TI CDCE706 CLOCK DRIVER
10859M: Max Filippov <jcmvbkbc@gmail.com> 10867M: Max Filippov <jcmvbkbc@gmail.com>
10860S: Maintained 10868S: Maintained
diff --git a/drivers/gpu/drm/rcar-du/Kconfig b/drivers/gpu/drm/rcar-du/Kconfig
index 96dcd4a78951..1f10fa0928b4 100644
--- a/drivers/gpu/drm/rcar-du/Kconfig
+++ b/drivers/gpu/drm/rcar-du/Kconfig
@@ -1,6 +1,7 @@
1config DRM_RCAR_DU 1config DRM_RCAR_DU
2 tristate "DRM Support for R-Car Display Unit" 2 tristate "DRM Support for R-Car Display Unit"
3 depends on DRM && ARM && OF 3 depends on DRM && OF
4 depends on ARM || ARM64
4 depends on ARCH_SHMOBILE || COMPILE_TEST 5 depends on ARCH_SHMOBILE || COMPILE_TEST
5 select DRM_KMS_HELPER 6 select DRM_KMS_HELPER
6 select DRM_KMS_CMA_HELPER 7 select DRM_KMS_CMA_HELPER
@@ -14,14 +15,18 @@ config DRM_RCAR_DU
14config DRM_RCAR_HDMI 15config DRM_RCAR_HDMI
15 bool "R-Car DU HDMI Encoder Support" 16 bool "R-Car DU HDMI Encoder Support"
16 depends on DRM_RCAR_DU 17 depends on DRM_RCAR_DU
17 depends on OF
18 help 18 help
19 Enable support for external HDMI encoders. 19 Enable support for external HDMI encoders.
20 20
21config DRM_RCAR_LVDS 21config DRM_RCAR_LVDS
22 bool "R-Car DU LVDS Encoder Support" 22 bool "R-Car DU LVDS Encoder Support"
23 depends on DRM_RCAR_DU 23 depends on DRM_RCAR_DU
24 depends on ARCH_R8A7790 || ARCH_R8A7791 || COMPILE_TEST
25 help 24 help
26 Enable support for the R-Car Display Unit embedded LVDS encoders 25 Enable support for the R-Car Display Unit embedded LVDS encoders.
27 (currently only on R8A7790 and R8A7791). 26
27config DRM_RCAR_VSP
28 bool "R-Car DU VSP Compositor Support"
29 depends on DRM_RCAR_DU
30 depends on VIDEO_RENESAS_VSP1
31 help
32 Enable support to expose the R-Car VSP Compositor as KMS planes.
diff --git a/drivers/gpu/drm/rcar-du/Makefile b/drivers/gpu/drm/rcar-du/Makefile
index 05de1c4097af..827711e28226 100644
--- a/drivers/gpu/drm/rcar-du/Makefile
+++ b/drivers/gpu/drm/rcar-du/Makefile
@@ -11,4 +11,6 @@ rcar-du-drm-$(CONFIG_DRM_RCAR_HDMI) += rcar_du_hdmicon.o \
11 rcar_du_hdmienc.o 11 rcar_du_hdmienc.o
12rcar-du-drm-$(CONFIG_DRM_RCAR_LVDS) += rcar_du_lvdsenc.o 12rcar-du-drm-$(CONFIG_DRM_RCAR_LVDS) += rcar_du_lvdsenc.o
13 13
14rcar-du-drm-$(CONFIG_DRM_RCAR_VSP) += rcar_du_vsp.o
15
14obj-$(CONFIG_DRM_RCAR_DU) += rcar-du-drm.o 16obj-$(CONFIG_DRM_RCAR_DU) += rcar-du-drm.o
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 4ec80ae1fa99..51e9e8ce551a 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * rcar_du_crtc.c -- R-Car Display Unit CRTCs 2 * rcar_du_crtc.c -- R-Car Display Unit CRTCs
3 * 3 *
4 * Copyright (C) 2013-2014 Renesas Electronics Corporation 4 * Copyright (C) 2013-2015 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
@@ -28,6 +28,7 @@
28#include "rcar_du_kms.h" 28#include "rcar_du_kms.h"
29#include "rcar_du_plane.h" 29#include "rcar_du_plane.h"
30#include "rcar_du_regs.h" 30#include "rcar_du_regs.h"
31#include "rcar_du_vsp.h"
31 32
32static u32 rcar_du_crtc_read(struct rcar_du_crtc *rcrtc, u32 reg) 33static u32 rcar_du_crtc_read(struct rcar_du_crtc *rcrtc, u32 reg)
33{ 34{
@@ -150,7 +151,7 @@ static void rcar_du_crtc_set_display_timing(struct rcar_du_crtc *rcrtc)
150 /* Signal polarities */ 151 /* Signal polarities */
151 value = ((mode->flags & DRM_MODE_FLAG_PVSYNC) ? 0 : DSMR_VSL) 152 value = ((mode->flags & DRM_MODE_FLAG_PVSYNC) ? 0 : DSMR_VSL)
152 | ((mode->flags & DRM_MODE_FLAG_PHSYNC) ? 0 : DSMR_HSL) 153 | ((mode->flags & DRM_MODE_FLAG_PHSYNC) ? 0 : DSMR_HSL)
153 | DSMR_DIPM_DE | DSMR_CSPM; 154 | DSMR_DIPM_DISP | DSMR_CSPM;
154 rcar_du_crtc_write(rcrtc, DSMR, value); 155 rcar_du_crtc_write(rcrtc, DSMR, value);
155 156
156 /* Display timings */ 157 /* Display timings */
@@ -207,6 +208,7 @@ plane_format(struct rcar_du_plane *plane)
207static void rcar_du_crtc_update_planes(struct rcar_du_crtc *rcrtc) 208static void rcar_du_crtc_update_planes(struct rcar_du_crtc *rcrtc)
208{ 209{
209 struct rcar_du_plane *planes[RCAR_DU_NUM_HW_PLANES]; 210 struct rcar_du_plane *planes[RCAR_DU_NUM_HW_PLANES];
211 struct rcar_du_device *rcdu = rcrtc->group->dev;
210 unsigned int num_planes = 0; 212 unsigned int num_planes = 0;
211 unsigned int dptsr_planes; 213 unsigned int dptsr_planes;
212 unsigned int hwplanes = 0; 214 unsigned int hwplanes = 0;
@@ -250,6 +252,17 @@ static void rcar_du_crtc_update_planes(struct rcar_du_crtc *rcrtc)
250 } 252 }
251 } 253 }
252 254
255 /* If VSP+DU integration is enabled the plane assignment is fixed. */
256 if (rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE)) {
257 if (rcdu->info->gen < 3) {
258 dspr = (rcrtc->index % 2) + 1;
259 hwplanes = 1 << (rcrtc->index % 2);
260 } else {
261 dspr = (rcrtc->index % 2) ? 3 : 1;
262 hwplanes = 1 << ((rcrtc->index % 2) ? 2 : 0);
263 }
264 }
265
253 /* Update the planes to display timing and dot clock generator 266 /* Update the planes to display timing and dot clock generator
254 * associations. 267 * associations.
255 * 268 *
@@ -272,6 +285,10 @@ static void rcar_du_crtc_update_planes(struct rcar_du_crtc *rcrtc)
272 rcar_du_group_restart(rcrtc->group); 285 rcar_du_group_restart(rcrtc->group);
273 } 286 }
274 287
288 /* Restart the group if plane sources have changed. */
289 if (rcrtc->group->need_restart)
290 rcar_du_group_restart(rcrtc->group);
291
275 mutex_unlock(&rcrtc->group->lock); 292 mutex_unlock(&rcrtc->group->lock);
276 293
277 rcar_du_group_write(rcrtc->group, rcrtc->index % 2 ? DS2PR : DS1PR, 294 rcar_du_group_write(rcrtc->group, rcrtc->index % 2 ? DS2PR : DS1PR,
@@ -365,6 +382,10 @@ static void rcar_du_crtc_start(struct rcar_du_crtc *rcrtc)
365 382
366 rcar_du_group_start_stop(rcrtc->group, true); 383 rcar_du_group_start_stop(rcrtc->group, true);
367 384
385 /* Enable the VSP compositor. */
386 if (rcar_du_has(rcrtc->group->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
387 rcar_du_vsp_enable(rcrtc);
388
368 /* Turn vertical blanking interrupt reporting back on. */ 389 /* Turn vertical blanking interrupt reporting back on. */
369 drm_crtc_vblank_on(crtc); 390 drm_crtc_vblank_on(crtc);
370 391
@@ -398,6 +419,10 @@ static void rcar_du_crtc_stop(struct rcar_du_crtc *rcrtc)
398 rcar_du_crtc_wait_page_flip(rcrtc); 419 rcar_du_crtc_wait_page_flip(rcrtc);
399 drm_crtc_vblank_off(crtc); 420 drm_crtc_vblank_off(crtc);
400 421
422 /* Disable the VSP compositor. */
423 if (rcar_du_has(rcrtc->group->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
424 rcar_du_vsp_disable(rcrtc);
425
401 /* Select switch sync mode. This stops display operation and configures 426 /* Select switch sync mode. This stops display operation and configures
402 * the HSYNC and VSYNC signals as inputs. 427 * the HSYNC and VSYNC signals as inputs.
403 */ 428 */
@@ -410,6 +435,9 @@ static void rcar_du_crtc_stop(struct rcar_du_crtc *rcrtc)
410 435
411void rcar_du_crtc_suspend(struct rcar_du_crtc *rcrtc) 436void rcar_du_crtc_suspend(struct rcar_du_crtc *rcrtc)
412{ 437{
438 if (rcar_du_has(rcrtc->group->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
439 rcar_du_vsp_disable(rcrtc);
440
413 rcar_du_crtc_stop(rcrtc); 441 rcar_du_crtc_stop(rcrtc);
414 rcar_du_crtc_put(rcrtc); 442 rcar_du_crtc_put(rcrtc);
415} 443}
@@ -418,20 +446,24 @@ void rcar_du_crtc_resume(struct rcar_du_crtc *rcrtc)
418{ 446{
419 unsigned int i; 447 unsigned int i;
420 448
421 if (!rcrtc->enabled) 449 if (!rcrtc->crtc.state->active)
422 return; 450 return;
423 451
424 rcar_du_crtc_get(rcrtc); 452 rcar_du_crtc_get(rcrtc);
425 rcar_du_crtc_start(rcrtc); 453 rcar_du_crtc_start(rcrtc);
426 454
427 /* Commit the planes state. */ 455 /* Commit the planes state. */
428 for (i = 0; i < rcrtc->group->num_planes; ++i) { 456 if (rcar_du_has(rcrtc->group->dev, RCAR_DU_FEATURE_VSP1_SOURCE)) {
429 struct rcar_du_plane *plane = &rcrtc->group->planes[i]; 457 rcar_du_vsp_enable(rcrtc);
458 } else {
459 for (i = 0; i < rcrtc->group->num_planes; ++i) {
460 struct rcar_du_plane *plane = &rcrtc->group->planes[i];
430 461
431 if (plane->plane.state->crtc != &rcrtc->crtc) 462 if (plane->plane.state->crtc != &rcrtc->crtc)
432 continue; 463 continue;
433 464
434 rcar_du_plane_setup(plane); 465 rcar_du_plane_setup(plane);
466 }
435 } 467 }
436 468
437 rcar_du_crtc_update_planes(rcrtc); 469 rcar_du_crtc_update_planes(rcrtc);
@@ -445,26 +477,17 @@ static void rcar_du_crtc_enable(struct drm_crtc *crtc)
445{ 477{
446 struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); 478 struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
447 479
448 if (rcrtc->enabled)
449 return;
450
451 rcar_du_crtc_get(rcrtc); 480 rcar_du_crtc_get(rcrtc);
452 rcar_du_crtc_start(rcrtc); 481 rcar_du_crtc_start(rcrtc);
453
454 rcrtc->enabled = true;
455} 482}
456 483
457static void rcar_du_crtc_disable(struct drm_crtc *crtc) 484static void rcar_du_crtc_disable(struct drm_crtc *crtc)
458{ 485{
459 struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); 486 struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
460 487
461 if (!rcrtc->enabled)
462 return;
463
464 rcar_du_crtc_stop(rcrtc); 488 rcar_du_crtc_stop(rcrtc);
465 rcar_du_crtc_put(rcrtc); 489 rcar_du_crtc_put(rcrtc);
466 490
467 rcrtc->enabled = false;
468 rcrtc->outputs = 0; 491 rcrtc->outputs = 0;
469} 492}
470 493
@@ -491,6 +514,9 @@ static void rcar_du_crtc_atomic_begin(struct drm_crtc *crtc,
491 rcrtc->event = event; 514 rcrtc->event = event;
492 spin_unlock_irqrestore(&dev->event_lock, flags); 515 spin_unlock_irqrestore(&dev->event_lock, flags);
493 } 516 }
517
518 if (rcar_du_has(rcrtc->group->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
519 rcar_du_vsp_atomic_begin(rcrtc);
494} 520}
495 521
496static void rcar_du_crtc_atomic_flush(struct drm_crtc *crtc, 522static void rcar_du_crtc_atomic_flush(struct drm_crtc *crtc,
@@ -499,6 +525,9 @@ static void rcar_du_crtc_atomic_flush(struct drm_crtc *crtc,
499 struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); 525 struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
500 526
501 rcar_du_crtc_update_planes(rcrtc); 527 rcar_du_crtc_update_planes(rcrtc);
528
529 if (rcar_du_has(rcrtc->group->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
530 rcar_du_vsp_atomic_flush(rcrtc);
502} 531}
503 532
504static const struct drm_crtc_helper_funcs crtc_helper_funcs = { 533static const struct drm_crtc_helper_funcs crtc_helper_funcs = {
@@ -547,13 +576,14 @@ static irqreturn_t rcar_du_crtc_irq(int irq, void *arg)
547int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int index) 576int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int index)
548{ 577{
549 static const unsigned int mmio_offsets[] = { 578 static const unsigned int mmio_offsets[] = {
550 DU0_REG_OFFSET, DU1_REG_OFFSET, DU2_REG_OFFSET 579 DU0_REG_OFFSET, DU1_REG_OFFSET, DU2_REG_OFFSET, DU3_REG_OFFSET
551 }; 580 };
552 581
553 struct rcar_du_device *rcdu = rgrp->dev; 582 struct rcar_du_device *rcdu = rgrp->dev;
554 struct platform_device *pdev = to_platform_device(rcdu->dev); 583 struct platform_device *pdev = to_platform_device(rcdu->dev);
555 struct rcar_du_crtc *rcrtc = &rcdu->crtcs[index]; 584 struct rcar_du_crtc *rcrtc = &rcdu->crtcs[index];
556 struct drm_crtc *crtc = &rcrtc->crtc; 585 struct drm_crtc *crtc = &rcrtc->crtc;
586 struct drm_plane *primary;
557 unsigned int irqflags; 587 unsigned int irqflags;
558 struct clk *clk; 588 struct clk *clk;
559 char clk_name[9]; 589 char clk_name[9];
@@ -589,10 +619,13 @@ int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int index)
589 rcrtc->group = rgrp; 619 rcrtc->group = rgrp;
590 rcrtc->mmio_offset = mmio_offsets[index]; 620 rcrtc->mmio_offset = mmio_offsets[index];
591 rcrtc->index = index; 621 rcrtc->index = index;
592 rcrtc->enabled = false;
593 622
594 ret = drm_crtc_init_with_planes(rcdu->ddev, crtc, 623 if (rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE))
595 &rgrp->planes[index % 2].plane, 624 primary = &rcrtc->vsp->planes[0].plane;
625 else
626 primary = &rgrp->planes[index % 2].plane;
627
628 ret = drm_crtc_init_with_planes(rcdu->ddev, crtc, primary,
596 NULL, &crtc_funcs, NULL); 629 NULL, &crtc_funcs, NULL);
597 if (ret < 0) 630 if (ret < 0)
598 return ret; 631 return ret;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
index 2bbe3f5aab65..6f08b7e7db06 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
@@ -21,6 +21,7 @@
21#include <drm/drm_crtc.h> 21#include <drm/drm_crtc.h>
22 22
23struct rcar_du_group; 23struct rcar_du_group;
24struct rcar_du_vsp;
24 25
25/** 26/**
26 * struct rcar_du_crtc - the CRTC, representing a DU superposition processor 27 * struct rcar_du_crtc - the CRTC, representing a DU superposition processor
@@ -33,7 +34,6 @@ struct rcar_du_group;
33 * @event: event to post when the pending page flip completes 34 * @event: event to post when the pending page flip completes
34 * @flip_wait: wait queue used to signal page flip completion 35 * @flip_wait: wait queue used to signal page flip completion
35 * @outputs: bitmask of the outputs (enum rcar_du_output) driven by this CRTC 36 * @outputs: bitmask of the outputs (enum rcar_du_output) driven by this CRTC
36 * @enabled: whether the CRTC is enabled, used to control system resume
37 * @group: CRTC group this CRTC belongs to 37 * @group: CRTC group this CRTC belongs to
38 */ 38 */
39struct rcar_du_crtc { 39struct rcar_du_crtc {
@@ -49,9 +49,9 @@ struct rcar_du_crtc {
49 wait_queue_head_t flip_wait; 49 wait_queue_head_t flip_wait;
50 50
51 unsigned int outputs; 51 unsigned int outputs;
52 bool enabled;
53 52
54 struct rcar_du_group *group; 53 struct rcar_du_group *group;
54 struct rcar_du_vsp *vsp;
55}; 55};
56 56
57#define to_rcar_crtc(c) container_of(c, struct rcar_du_crtc, crtc) 57#define to_rcar_crtc(c) container_of(c, struct rcar_du_crtc, crtc)
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 0bb2b31555bf..ed6006bf6bd8 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * rcar_du_drv.c -- R-Car Display Unit DRM driver 2 * rcar_du_drv.c -- R-Car Display Unit DRM driver
3 * 3 *
4 * Copyright (C) 2013-2014 Renesas Electronics Corporation 4 * Copyright (C) 2013-2015 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
@@ -36,6 +36,7 @@
36 */ 36 */
37 37
38static const struct rcar_du_device_info rcar_du_r8a7779_info = { 38static const struct rcar_du_device_info rcar_du_r8a7779_info = {
39 .gen = 2,
39 .features = 0, 40 .features = 0,
40 .num_crtcs = 2, 41 .num_crtcs = 2,
41 .routes = { 42 .routes = {
@@ -57,6 +58,7 @@ static const struct rcar_du_device_info rcar_du_r8a7779_info = {
57}; 58};
58 59
59static const struct rcar_du_device_info rcar_du_r8a7790_info = { 60static const struct rcar_du_device_info rcar_du_r8a7790_info = {
61 .gen = 2,
60 .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK 62 .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK
61 | RCAR_DU_FEATURE_EXT_CTRL_REGS, 63 | RCAR_DU_FEATURE_EXT_CTRL_REGS,
62 .quirks = RCAR_DU_QUIRK_ALIGN_128B | RCAR_DU_QUIRK_LVDS_LANES, 64 .quirks = RCAR_DU_QUIRK_ALIGN_128B | RCAR_DU_QUIRK_LVDS_LANES,
@@ -86,6 +88,7 @@ static const struct rcar_du_device_info rcar_du_r8a7790_info = {
86 88
87/* M2-W (r8a7791) and M2-N (r8a7793) are identical */ 89/* M2-W (r8a7791) and M2-N (r8a7793) are identical */
88static const struct rcar_du_device_info rcar_du_r8a7791_info = { 90static const struct rcar_du_device_info rcar_du_r8a7791_info = {
91 .gen = 2,
89 .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK 92 .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK
90 | RCAR_DU_FEATURE_EXT_CTRL_REGS, 93 | RCAR_DU_FEATURE_EXT_CTRL_REGS,
91 .num_crtcs = 2, 94 .num_crtcs = 2,
@@ -108,6 +111,7 @@ static const struct rcar_du_device_info rcar_du_r8a7791_info = {
108}; 111};
109 112
110static const struct rcar_du_device_info rcar_du_r8a7794_info = { 113static const struct rcar_du_device_info rcar_du_r8a7794_info = {
114 .gen = 2,
111 .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK 115 .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK
112 | RCAR_DU_FEATURE_EXT_CTRL_REGS, 116 | RCAR_DU_FEATURE_EXT_CTRL_REGS,
113 .num_crtcs = 2, 117 .num_crtcs = 2,
@@ -129,12 +133,37 @@ static const struct rcar_du_device_info rcar_du_r8a7794_info = {
129 .num_lvds = 0, 133 .num_lvds = 0,
130}; 134};
131 135
136static const struct rcar_du_device_info rcar_du_r8a7795_info = {
137 .gen = 3,
138 .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK
139 | RCAR_DU_FEATURE_EXT_CTRL_REGS
140 | RCAR_DU_FEATURE_VSP1_SOURCE,
141 .num_crtcs = 4,
142 .routes = {
143 /* R8A7795 has one RGB output, one LVDS output and two
144 * (currently unsupported) HDMI outputs.
145 */
146 [RCAR_DU_OUTPUT_DPAD0] = {
147 .possible_crtcs = BIT(3),
148 .encoder_type = DRM_MODE_ENCODER_NONE,
149 .port = 0,
150 },
151 [RCAR_DU_OUTPUT_LVDS0] = {
152 .possible_crtcs = BIT(0),
153 .encoder_type = DRM_MODE_ENCODER_LVDS,
154 .port = 3,
155 },
156 },
157 .num_lvds = 1,
158};
159
132static const struct of_device_id rcar_du_of_table[] = { 160static const struct of_device_id rcar_du_of_table[] = {
133 { .compatible = "renesas,du-r8a7779", .data = &rcar_du_r8a7779_info }, 161 { .compatible = "renesas,du-r8a7779", .data = &rcar_du_r8a7779_info },
134 { .compatible = "renesas,du-r8a7790", .data = &rcar_du_r8a7790_info }, 162 { .compatible = "renesas,du-r8a7790", .data = &rcar_du_r8a7790_info },
135 { .compatible = "renesas,du-r8a7791", .data = &rcar_du_r8a7791_info }, 163 { .compatible = "renesas,du-r8a7791", .data = &rcar_du_r8a7791_info },
136 { .compatible = "renesas,du-r8a7793", .data = &rcar_du_r8a7791_info }, 164 { .compatible = "renesas,du-r8a7793", .data = &rcar_du_r8a7791_info },
137 { .compatible = "renesas,du-r8a7794", .data = &rcar_du_r8a7794_info }, 165 { .compatible = "renesas,du-r8a7794", .data = &rcar_du_r8a7794_info },
166 { .compatible = "renesas,du-r8a7795", .data = &rcar_du_r8a7795_info },
138 { } 167 { }
139}; 168};
140 169
@@ -144,82 +173,6 @@ MODULE_DEVICE_TABLE(of, rcar_du_of_table);
144 * DRM operations 173 * DRM operations
145 */ 174 */
146 175
147static int rcar_du_unload(struct drm_device *dev)
148{
149 struct rcar_du_device *rcdu = dev->dev_private;
150
151 if (rcdu->fbdev)
152 drm_fbdev_cma_fini(rcdu->fbdev);
153
154 drm_kms_helper_poll_fini(dev);
155 drm_mode_config_cleanup(dev);
156 drm_vblank_cleanup(dev);
157
158 dev->irq_enabled = 0;
159 dev->dev_private = NULL;
160
161 return 0;
162}
163
164static int rcar_du_load(struct drm_device *dev, unsigned long flags)
165{
166 struct platform_device *pdev = dev->platformdev;
167 struct device_node *np = pdev->dev.of_node;
168 struct rcar_du_device *rcdu;
169 struct resource *mem;
170 int ret;
171
172 if (np == NULL) {
173 dev_err(dev->dev, "no platform data\n");
174 return -ENODEV;
175 }
176
177 rcdu = devm_kzalloc(&pdev->dev, sizeof(*rcdu), GFP_KERNEL);
178 if (rcdu == NULL) {
179 dev_err(dev->dev, "failed to allocate private data\n");
180 return -ENOMEM;
181 }
182
183 init_waitqueue_head(&rcdu->commit.wait);
184
185 rcdu->dev = &pdev->dev;
186 rcdu->info = of_match_device(rcar_du_of_table, rcdu->dev)->data;
187 rcdu->ddev = dev;
188 dev->dev_private = rcdu;
189
190 /* I/O resources */
191 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
192 rcdu->mmio = devm_ioremap_resource(&pdev->dev, mem);
193 if (IS_ERR(rcdu->mmio))
194 return PTR_ERR(rcdu->mmio);
195
196 /* Initialize vertical blanking interrupts handling. Start with vblank
197 * disabled for all CRTCs.
198 */
199 ret = drm_vblank_init(dev, (1 << rcdu->info->num_crtcs) - 1);
200 if (ret < 0) {
201 dev_err(&pdev->dev, "failed to initialize vblank\n");
202 goto done;
203 }
204
205 /* DRM/KMS objects */
206 ret = rcar_du_modeset_init(rcdu);
207 if (ret < 0) {
208 dev_err(&pdev->dev, "failed to initialize DRM/KMS (%d)\n", ret);
209 goto done;
210 }
211
212 dev->irq_enabled = 1;
213
214 platform_set_drvdata(pdev, rcdu);
215
216done:
217 if (ret)
218 rcar_du_unload(dev);
219
220 return ret;
221}
222
223static void rcar_du_lastclose(struct drm_device *dev) 176static void rcar_du_lastclose(struct drm_device *dev)
224{ 177{
225 struct rcar_du_device *rcdu = dev->dev_private; 178 struct rcar_du_device *rcdu = dev->dev_private;
@@ -260,10 +213,7 @@ static const struct file_operations rcar_du_fops = {
260static struct drm_driver rcar_du_driver = { 213static struct drm_driver rcar_du_driver = {
261 .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME 214 .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME
262 | DRIVER_ATOMIC, 215 | DRIVER_ATOMIC,
263 .load = rcar_du_load,
264 .unload = rcar_du_unload,
265 .lastclose = rcar_du_lastclose, 216 .lastclose = rcar_du_lastclose,
266 .set_busid = drm_platform_set_busid,
267 .get_vblank_counter = drm_vblank_no_hw_counter, 217 .get_vblank_counter = drm_vblank_no_hw_counter,
268 .enable_vblank = rcar_du_enable_vblank, 218 .enable_vblank = rcar_du_enable_vblank,
269 .disable_vblank = rcar_du_disable_vblank, 219 .disable_vblank = rcar_du_disable_vblank,
@@ -323,18 +273,116 @@ static const struct dev_pm_ops rcar_du_pm_ops = {
323 * Platform driver 273 * Platform driver
324 */ 274 */
325 275
326static int rcar_du_probe(struct platform_device *pdev) 276static int rcar_du_remove(struct platform_device *pdev)
327{ 277{
328 return drm_platform_init(&rcar_du_driver, pdev); 278 struct rcar_du_device *rcdu = platform_get_drvdata(pdev);
279 struct drm_device *ddev = rcdu->ddev;
280
281 mutex_lock(&ddev->mode_config.mutex);
282 drm_connector_unplug_all(ddev);
283 mutex_unlock(&ddev->mode_config.mutex);
284
285 drm_dev_unregister(ddev);
286
287 if (rcdu->fbdev)
288 drm_fbdev_cma_fini(rcdu->fbdev);
289
290 drm_kms_helper_poll_fini(ddev);
291 drm_mode_config_cleanup(ddev);
292 drm_vblank_cleanup(ddev);
293
294 drm_dev_unref(ddev);
295
296 return 0;
329} 297}
330 298
331static int rcar_du_remove(struct platform_device *pdev) 299static int rcar_du_probe(struct platform_device *pdev)
332{ 300{
333 struct rcar_du_device *rcdu = platform_get_drvdata(pdev); 301 struct device_node *np = pdev->dev.of_node;
302 struct rcar_du_device *rcdu;
303 struct drm_connector *connector;
304 struct drm_device *ddev;
305 struct resource *mem;
306 int ret;
334 307
335 drm_put_dev(rcdu->ddev); 308 if (np == NULL) {
309 dev_err(&pdev->dev, "no device tree node\n");
310 return -ENODEV;
311 }
312
313 /* Allocate and initialize the DRM and R-Car device structures. */
314 rcdu = devm_kzalloc(&pdev->dev, sizeof(*rcdu), GFP_KERNEL);
315 if (rcdu == NULL)
316 return -ENOMEM;
317
318 init_waitqueue_head(&rcdu->commit.wait);
319
320 rcdu->dev = &pdev->dev;
321 rcdu->info = of_match_device(rcar_du_of_table, rcdu->dev)->data;
322
323 ddev = drm_dev_alloc(&rcar_du_driver, &pdev->dev);
324 if (!ddev)
325 return -ENOMEM;
326
327 drm_dev_set_unique(ddev, dev_name(&pdev->dev));
328
329 rcdu->ddev = ddev;
330 ddev->dev_private = rcdu;
331
332 platform_set_drvdata(pdev, rcdu);
333
334 /* I/O resources */
335 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
336 rcdu->mmio = devm_ioremap_resource(&pdev->dev, mem);
337 if (IS_ERR(rcdu->mmio)) {
338 ret = PTR_ERR(rcdu->mmio);
339 goto error;
340 }
341
342 /* Initialize vertical blanking interrupts handling. Start with vblank
343 * disabled for all CRTCs.
344 */
345 ret = drm_vblank_init(ddev, (1 << rcdu->info->num_crtcs) - 1);
346 if (ret < 0) {
347 dev_err(&pdev->dev, "failed to initialize vblank\n");
348 goto error;
349 }
350
351 /* DRM/KMS objects */
352 ret = rcar_du_modeset_init(rcdu);
353 if (ret < 0) {
354 dev_err(&pdev->dev, "failed to initialize DRM/KMS (%d)\n", ret);
355 goto error;
356 }
357
358 ddev->irq_enabled = 1;
359
360 /* Register the DRM device with the core and the connectors with
361 * sysfs.
362 */
363 ret = drm_dev_register(ddev, 0);
364 if (ret)
365 goto error;
366
367 mutex_lock(&ddev->mode_config.mutex);
368 drm_for_each_connector(connector, ddev) {
369 ret = drm_connector_register(connector);
370 if (ret < 0)
371 break;
372 }
373 mutex_unlock(&ddev->mode_config.mutex);
374
375 if (ret < 0)
376 goto error;
377
378 DRM_INFO("Device %s probed\n", dev_name(&pdev->dev));
336 379
337 return 0; 380 return 0;
381
382error:
383 rcar_du_remove(pdev);
384
385 return ret;
338} 386}
339 387
340static struct platform_driver rcar_du_platform_driver = { 388static struct platform_driver rcar_du_platform_driver = {
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
index 9f34fc86436a..ed35467d96cf 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * rcar_du_drv.h -- R-Car Display Unit DRM driver 2 * rcar_du_drv.h -- R-Car Display Unit DRM driver
3 * 3 *
4 * Copyright (C) 2013-2014 Renesas Electronics Corporation 4 * Copyright (C) 2013-2015 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
@@ -19,6 +19,7 @@
19 19
20#include "rcar_du_crtc.h" 20#include "rcar_du_crtc.h"
21#include "rcar_du_group.h" 21#include "rcar_du_group.h"
22#include "rcar_du_vsp.h"
22 23
23struct clk; 24struct clk;
24struct device; 25struct device;
@@ -29,6 +30,7 @@ struct rcar_du_lvdsenc;
29 30
30#define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK (1 << 0) /* Per-CRTC IRQ and clock */ 31#define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK (1 << 0) /* Per-CRTC IRQ and clock */
31#define RCAR_DU_FEATURE_EXT_CTRL_REGS (1 << 1) /* Has extended control registers */ 32#define RCAR_DU_FEATURE_EXT_CTRL_REGS (1 << 1) /* Has extended control registers */
33#define RCAR_DU_FEATURE_VSP1_SOURCE (1 << 2) /* Has inputs from VSP1 */
32 34
33#define RCAR_DU_QUIRK_ALIGN_128B (1 << 0) /* Align pitches to 128 bytes */ 35#define RCAR_DU_QUIRK_ALIGN_128B (1 << 0) /* Align pitches to 128 bytes */
34#define RCAR_DU_QUIRK_LVDS_LANES (1 << 1) /* LVDS lanes 1 and 3 inverted */ 36#define RCAR_DU_QUIRK_LVDS_LANES (1 << 1) /* LVDS lanes 1 and 3 inverted */
@@ -51,6 +53,7 @@ struct rcar_du_output_routing {
51 53
52/* 54/*
53 * struct rcar_du_device_info - DU model-specific information 55 * struct rcar_du_device_info - DU model-specific information
56 * @gen: device generation (2 or 3)
54 * @features: device features (RCAR_DU_FEATURE_*) 57 * @features: device features (RCAR_DU_FEATURE_*)
55 * @quirks: device quirks (RCAR_DU_QUIRK_*) 58 * @quirks: device quirks (RCAR_DU_QUIRK_*)
56 * @num_crtcs: total number of CRTCs 59 * @num_crtcs: total number of CRTCs
@@ -58,6 +61,7 @@ struct rcar_du_output_routing {
58 * @num_lvds: number of internal LVDS encoders 61 * @num_lvds: number of internal LVDS encoders
59 */ 62 */
60struct rcar_du_device_info { 63struct rcar_du_device_info {
64 unsigned int gen;
61 unsigned int features; 65 unsigned int features;
62 unsigned int quirks; 66 unsigned int quirks;
63 unsigned int num_crtcs; 67 unsigned int num_crtcs;
@@ -65,9 +69,10 @@ struct rcar_du_device_info {
65 unsigned int num_lvds; 69 unsigned int num_lvds;
66}; 70};
67 71
68#define RCAR_DU_MAX_CRTCS 3 72#define RCAR_DU_MAX_CRTCS 4
69#define RCAR_DU_MAX_GROUPS DIV_ROUND_UP(RCAR_DU_MAX_CRTCS, 2) 73#define RCAR_DU_MAX_GROUPS DIV_ROUND_UP(RCAR_DU_MAX_CRTCS, 2)
70#define RCAR_DU_MAX_LVDS 2 74#define RCAR_DU_MAX_LVDS 2
75#define RCAR_DU_MAX_VSPS 4
71 76
72struct rcar_du_device { 77struct rcar_du_device {
73 struct device *dev; 78 struct device *dev;
@@ -82,6 +87,7 @@ struct rcar_du_device {
82 unsigned int num_crtcs; 87 unsigned int num_crtcs;
83 88
84 struct rcar_du_group groups[RCAR_DU_MAX_GROUPS]; 89 struct rcar_du_group groups[RCAR_DU_MAX_GROUPS];
90 struct rcar_du_vsp vsps[RCAR_DU_MAX_VSPS];
85 91
86 struct { 92 struct {
87 struct drm_property *alpha; 93 struct drm_property *alpha;
@@ -90,6 +96,8 @@ struct rcar_du_device {
90 } props; 96 } props;
91 97
92 unsigned int dpad0_source; 98 unsigned int dpad0_source;
99 unsigned int vspd1_sink;
100
93 struct rcar_du_lvdsenc *lvds[RCAR_DU_MAX_LVDS]; 101 struct rcar_du_lvdsenc *lvds[RCAR_DU_MAX_LVDS];
94 102
95 struct { 103 struct {
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
index c08700757feb..4e939e41f030 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
@@ -89,12 +89,8 @@ static int rcar_du_encoder_atomic_check(struct drm_encoder *encoder,
89 /* The flat panel mode is fixed, just copy it to the adjusted mode. */ 89 /* The flat panel mode is fixed, just copy it to the adjusted mode. */
90 drm_mode_copy(adjusted_mode, panel_mode); 90 drm_mode_copy(adjusted_mode, panel_mode);
91 91
92 /* The internal LVDS encoder has a clock frequency operating range of
93 * 30MHz to 150MHz. Clamp the clock accordingly.
94 */
95 if (renc->lvds) 92 if (renc->lvds)
96 adjusted_mode->clock = clamp(adjusted_mode->clock, 93 rcar_du_lvdsenc_atomic_check(renc->lvds, adjusted_mode);
97 30000, 150000);
98 94
99 return 0; 95 return 0;
100} 96}
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.c b/drivers/gpu/drm/rcar-du/rcar_du_group.c
index 8e2ffe025153..33b2fc53da3e 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_group.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_group.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * rcar_du_group.c -- R-Car Display Unit Channels Pair 2 * rcar_du_group.c -- R-Car Display Unit Channels Pair
3 * 3 *
4 * Copyright (C) 2013-2014 Renesas Electronics Corporation 4 * Copyright (C) 2013-2015 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
@@ -44,29 +44,64 @@ void rcar_du_group_write(struct rcar_du_group *rgrp, u32 reg, u32 data)
44 rcar_du_write(rgrp->dev, rgrp->mmio_offset + reg, data); 44 rcar_du_write(rgrp->dev, rgrp->mmio_offset + reg, data);
45} 45}
46 46
47static void rcar_du_group_setup_pins(struct rcar_du_group *rgrp)
48{
49 u32 defr6 = DEFR6_CODE | DEFR6_ODPM12_DISP;
50
51 if (rgrp->num_crtcs > 1)
52 defr6 |= DEFR6_ODPM22_DISP;
53
54 rcar_du_group_write(rgrp, DEFR6, defr6);
55}
56
47static void rcar_du_group_setup_defr8(struct rcar_du_group *rgrp) 57static void rcar_du_group_setup_defr8(struct rcar_du_group *rgrp)
48{ 58{
49 u32 defr8 = DEFR8_CODE | DEFR8_DEFE8; 59 struct rcar_du_device *rcdu = rgrp->dev;
60 unsigned int possible_crtcs =
61 rcdu->info->routes[RCAR_DU_OUTPUT_DPAD0].possible_crtcs;
62 u32 defr8 = DEFR8_CODE;
50 63
51 /* The DEFR8 register for the first group also controls RGB output 64 if (rcdu->info->gen < 3) {
52 * routing to DPAD0 for DU instances that support it. 65 defr8 |= DEFR8_DEFE8;
53 */ 66
54 if (rgrp->dev->info->routes[RCAR_DU_OUTPUT_DPAD0].possible_crtcs > 1 && 67 /* On Gen2 the DEFR8 register for the first group also controls
55 rgrp->index == 0) 68 * RGB output routing to DPAD0 and VSPD1 routing to DU0/1/2 for
56 defr8 |= DEFR8_DRGBS_DU(rgrp->dev->dpad0_source); 69 * DU instances that support it.
70 */
71 if (rgrp->index == 0) {
72 if (possible_crtcs > 1)
73 defr8 |= DEFR8_DRGBS_DU(rcdu->dpad0_source);
74 if (rgrp->dev->vspd1_sink == 2)
75 defr8 |= DEFR8_VSCS;
76 }
77 } else {
78 /* On Gen3 VSPD routing can't be configured, but DPAD routing
79 * needs to be set despite having a single option available.
80 */
81 u32 crtc = ffs(possible_crtcs) - 1;
82
83 if (crtc / 2 == rgrp->index)
84 defr8 |= DEFR8_DRGBS_DU(crtc);
85 }
57 86
58 rcar_du_group_write(rgrp, DEFR8, defr8); 87 rcar_du_group_write(rgrp, DEFR8, defr8);
59} 88}
60 89
61static void rcar_du_group_setup(struct rcar_du_group *rgrp) 90static void rcar_du_group_setup(struct rcar_du_group *rgrp)
62{ 91{
92 struct rcar_du_device *rcdu = rgrp->dev;
93
63 /* Enable extended features */ 94 /* Enable extended features */
64 rcar_du_group_write(rgrp, DEFR, DEFR_CODE | DEFR_DEFE); 95 rcar_du_group_write(rgrp, DEFR, DEFR_CODE | DEFR_DEFE);
65 rcar_du_group_write(rgrp, DEFR2, DEFR2_CODE | DEFR2_DEFE2G); 96 if (rcdu->info->gen < 3) {
66 rcar_du_group_write(rgrp, DEFR3, DEFR3_CODE | DEFR3_DEFE3); 97 rcar_du_group_write(rgrp, DEFR2, DEFR2_CODE | DEFR2_DEFE2G);
67 rcar_du_group_write(rgrp, DEFR4, DEFR4_CODE); 98 rcar_du_group_write(rgrp, DEFR3, DEFR3_CODE | DEFR3_DEFE3);
99 rcar_du_group_write(rgrp, DEFR4, DEFR4_CODE);
100 }
68 rcar_du_group_write(rgrp, DEFR5, DEFR5_CODE | DEFR5_DEFE5); 101 rcar_du_group_write(rgrp, DEFR5, DEFR5_CODE | DEFR5_DEFE5);
69 102
103 rcar_du_group_setup_pins(rgrp);
104
70 if (rcar_du_has(rgrp->dev, RCAR_DU_FEATURE_EXT_CTRL_REGS)) { 105 if (rcar_du_has(rgrp->dev, RCAR_DU_FEATURE_EXT_CTRL_REGS)) {
71 rcar_du_group_setup_defr8(rgrp); 106 rcar_du_group_setup_defr8(rgrp);
72 107
@@ -82,6 +117,9 @@ static void rcar_du_group_setup(struct rcar_du_group *rgrp)
82 DIDSR_PDCS_CLK(0, 0)); 117 DIDSR_PDCS_CLK(0, 0));
83 } 118 }
84 119
120 if (rcdu->info->gen >= 3)
121 rcar_du_group_write(rgrp, DEFR10, DEFR10_CODE | DEFR10_DEFE10);
122
85 /* Use DS1PR and DS2PR to configure planes priorities and connects the 123 /* Use DS1PR and DS2PR to configure planes priorities and connects the
86 * superposition 0 to DU0 pins. DU1 pins will be configured dynamically. 124 * superposition 0 to DU0 pins. DU1 pins will be configured dynamically.
87 */ 125 */
@@ -158,21 +196,23 @@ void rcar_du_group_start_stop(struct rcar_du_group *rgrp, bool start)
158 196
159void rcar_du_group_restart(struct rcar_du_group *rgrp) 197void rcar_du_group_restart(struct rcar_du_group *rgrp)
160{ 198{
199 rgrp->need_restart = false;
200
161 __rcar_du_group_start_stop(rgrp, false); 201 __rcar_du_group_start_stop(rgrp, false);
162 __rcar_du_group_start_stop(rgrp, true); 202 __rcar_du_group_start_stop(rgrp, true);
163} 203}
164 204
165static int rcar_du_set_dpad0_routing(struct rcar_du_device *rcdu) 205int rcar_du_set_dpad0_vsp1_routing(struct rcar_du_device *rcdu)
166{ 206{
167 int ret; 207 int ret;
168 208
169 if (!rcar_du_has(rcdu, RCAR_DU_FEATURE_EXT_CTRL_REGS)) 209 if (!rcar_du_has(rcdu, RCAR_DU_FEATURE_EXT_CTRL_REGS))
170 return 0; 210 return 0;
171 211
172 /* RGB output routing to DPAD0 is configured in the DEFR8 register of 212 /* RGB output routing to DPAD0 and VSP1D routing to DU0/1/2 are
173 * the first group. As this function can be called with the DU0 and DU1 213 * configured in the DEFR8 register of the first group. As this function
174 * CRTCs disabled, we need to enable the first group clock before 214 * can be called with the DU0 and DU1 CRTCs disabled, we need to enable
175 * accessing the register. 215 * the first group clock before accessing the register.
176 */ 216 */
177 ret = clk_prepare_enable(rcdu->crtcs[0].clock); 217 ret = clk_prepare_enable(rcdu->crtcs[0].clock);
178 if (ret < 0) 218 if (ret < 0)
@@ -203,5 +243,5 @@ int rcar_du_group_set_routing(struct rcar_du_group *rgrp)
203 243
204 rcar_du_group_write(rgrp, DORCR, dorcr); 244 rcar_du_group_write(rgrp, DORCR, dorcr);
205 245
206 return rcar_du_set_dpad0_routing(rgrp->dev); 246 return rcar_du_set_dpad0_vsp1_routing(rgrp->dev);
207} 247}
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.h b/drivers/gpu/drm/rcar-du/rcar_du_group.h
index d7318e1a6b00..5e3adc6b31b5 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_group.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_group.h
@@ -32,6 +32,7 @@ struct rcar_du_device;
32 * @dptsr_planes: bitmask of planes driven by dot-clock and timing generator 1 32 * @dptsr_planes: bitmask of planes driven by dot-clock and timing generator 1
33 * @num_planes: number of planes in the group 33 * @num_planes: number of planes in the group
34 * @planes: planes handled by the group 34 * @planes: planes handled by the group
35 * @need_restart: the group needs to be restarted due to a configuration change
35 */ 36 */
36struct rcar_du_group { 37struct rcar_du_group {
37 struct rcar_du_device *dev; 38 struct rcar_du_device *dev;
@@ -47,6 +48,7 @@ struct rcar_du_group {
47 48
48 unsigned int num_planes; 49 unsigned int num_planes;
49 struct rcar_du_plane planes[RCAR_DU_NUM_KMS_PLANES]; 50 struct rcar_du_plane planes[RCAR_DU_NUM_KMS_PLANES];
51 bool need_restart;
50}; 52};
51 53
52u32 rcar_du_group_read(struct rcar_du_group *rgrp, u32 reg); 54u32 rcar_du_group_read(struct rcar_du_group *rgrp, u32 reg);
@@ -58,4 +60,6 @@ void rcar_du_group_start_stop(struct rcar_du_group *rgrp, bool start);
58void rcar_du_group_restart(struct rcar_du_group *rgrp); 60void rcar_du_group_restart(struct rcar_du_group *rgrp);
59int rcar_du_group_set_routing(struct rcar_du_group *rgrp); 61int rcar_du_group_set_routing(struct rcar_du_group *rgrp);
60 62
63int rcar_du_set_dpad0_vsp1_routing(struct rcar_du_device *rcdu);
64
61#endif /* __RCAR_DU_GROUP_H__ */ 65#endif /* __RCAR_DU_GROUP_H__ */
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c b/drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c
index a37b6e2fe51a..6c927144b5c9 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c
@@ -55,12 +55,6 @@ static const struct drm_connector_helper_funcs connector_helper_funcs = {
55 .best_encoder = rcar_du_connector_best_encoder, 55 .best_encoder = rcar_du_connector_best_encoder,
56}; 56};
57 57
58static void rcar_du_hdmi_connector_destroy(struct drm_connector *connector)
59{
60 drm_connector_unregister(connector);
61 drm_connector_cleanup(connector);
62}
63
64static enum drm_connector_status 58static enum drm_connector_status
65rcar_du_hdmi_connector_detect(struct drm_connector *connector, bool force) 59rcar_du_hdmi_connector_detect(struct drm_connector *connector, bool force)
66{ 60{
@@ -79,7 +73,7 @@ static const struct drm_connector_funcs connector_funcs = {
79 .reset = drm_atomic_helper_connector_reset, 73 .reset = drm_atomic_helper_connector_reset,
80 .detect = rcar_du_hdmi_connector_detect, 74 .detect = rcar_du_hdmi_connector_detect,
81 .fill_modes = drm_helper_probe_single_connector_modes, 75 .fill_modes = drm_helper_probe_single_connector_modes,
82 .destroy = rcar_du_hdmi_connector_destroy, 76 .destroy = drm_connector_cleanup,
83 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, 77 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
84 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, 78 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
85}; 79};
@@ -108,9 +102,6 @@ int rcar_du_hdmi_connector_init(struct rcar_du_device *rcdu,
108 return ret; 102 return ret;
109 103
110 drm_connector_helper_add(connector, &connector_helper_funcs); 104 drm_connector_helper_add(connector, &connector_helper_funcs);
111 ret = drm_connector_register(connector);
112 if (ret < 0)
113 return ret;
114 105
115 connector->dpms = DRM_MODE_DPMS_OFF; 106 connector->dpms = DRM_MODE_DPMS_OFF;
116 drm_object_property_set_value(&connector->base, 107 drm_object_property_set_value(&connector->base,
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_hdmienc.c b/drivers/gpu/drm/rcar-du/rcar_du_hdmienc.c
index 2567efcbee36..461662d231e2 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_hdmienc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_hdmienc.c
@@ -71,12 +71,9 @@ static int rcar_du_hdmienc_atomic_check(struct drm_encoder *encoder,
71 struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode; 71 struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;
72 const struct drm_display_mode *mode = &crtc_state->mode; 72 const struct drm_display_mode *mode = &crtc_state->mode;
73 73
74 /* The internal LVDS encoder has a clock frequency operating range of
75 * 30MHz to 150MHz. Clamp the clock accordingly.
76 */
77 if (hdmienc->renc->lvds) 74 if (hdmienc->renc->lvds)
78 adjusted_mode->clock = clamp(adjusted_mode->clock, 75 rcar_du_lvdsenc_atomic_check(hdmienc->renc->lvds,
79 30000, 150000); 76 adjusted_mode);
80 77
81 if (sfuncs->mode_fixup == NULL) 78 if (sfuncs->mode_fixup == NULL)
82 return 0; 79 return 0;
@@ -134,12 +131,19 @@ int rcar_du_hdmienc_init(struct rcar_du_device *rcdu,
134 131
135 /* Locate the slave I2C device and driver. */ 132 /* Locate the slave I2C device and driver. */
136 i2c_slave = of_find_i2c_device_by_node(np); 133 i2c_slave = of_find_i2c_device_by_node(np);
137 if (!i2c_slave || !i2c_get_clientdata(i2c_slave)) 134 if (!i2c_slave || !i2c_get_clientdata(i2c_slave)) {
135 dev_dbg(rcdu->dev,
136 "can't get I2C slave for %s, deferring probe\n",
137 of_node_full_name(np));
138 return -EPROBE_DEFER; 138 return -EPROBE_DEFER;
139 }
139 140
140 hdmienc->dev = &i2c_slave->dev; 141 hdmienc->dev = &i2c_slave->dev;
141 142
142 if (hdmienc->dev->driver == NULL) { 143 if (hdmienc->dev->driver == NULL) {
144 dev_dbg(rcdu->dev,
145 "I2C slave %s not probed yet, deferring probe\n",
146 dev_name(hdmienc->dev));
143 ret = -EPROBE_DEFER; 147 ret = -EPROBE_DEFER;
144 goto error; 148 goto error;
145 } 149 }
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index 43bce69d8560..24725bf859b4 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * rcar_du_kms.c -- R-Car Display Unit Mode Setting 2 * rcar_du_kms.c -- R-Car Display Unit Mode Setting
3 * 3 *
4 * Copyright (C) 2013-2014 Renesas Electronics Corporation 4 * Copyright (C) 2013-2015 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
@@ -28,6 +28,7 @@
28#include "rcar_du_kms.h" 28#include "rcar_du_kms.h"
29#include "rcar_du_lvdsenc.h" 29#include "rcar_du_lvdsenc.h"
30#include "rcar_du_regs.h" 30#include "rcar_du_regs.h"
31#include "rcar_du_vsp.h"
31 32
32/* ----------------------------------------------------------------------------- 33/* -----------------------------------------------------------------------------
33 * Format helpers 34 * Format helpers
@@ -89,13 +90,44 @@ static const struct rcar_du_format_info rcar_du_format_infos[] = {
89 .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC, 90 .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC,
90 .edf = PnDDCR4_EDF_NONE, 91 .edf = PnDDCR4_EDF_NONE,
91 }, { 92 }, {
92 /* In YUV 4:2:2, only NV16 is supported (NV61 isn't) */
93 .fourcc = DRM_FORMAT_NV16, 93 .fourcc = DRM_FORMAT_NV16,
94 .bpp = 16, 94 .bpp = 16,
95 .planes = 2, 95 .planes = 2,
96 .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC, 96 .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC,
97 .edf = PnDDCR4_EDF_NONE, 97 .edf = PnDDCR4_EDF_NONE,
98 }, 98 },
99 /* The following formats are not supported on Gen2 and thus have no
100 * associated .pnmr or .edf settings.
101 */
102 {
103 .fourcc = DRM_FORMAT_NV61,
104 .bpp = 16,
105 .planes = 2,
106 }, {
107 .fourcc = DRM_FORMAT_YUV420,
108 .bpp = 12,
109 .planes = 3,
110 }, {
111 .fourcc = DRM_FORMAT_YVU420,
112 .bpp = 12,
113 .planes = 3,
114 }, {
115 .fourcc = DRM_FORMAT_YUV422,
116 .bpp = 16,
117 .planes = 3,
118 }, {
119 .fourcc = DRM_FORMAT_YVU422,
120 .bpp = 16,
121 .planes = 3,
122 }, {
123 .fourcc = DRM_FORMAT_YUV444,
124 .bpp = 24,
125 .planes = 3,
126 }, {
127 .fourcc = DRM_FORMAT_YVU444,
128 .bpp = 24,
129 .planes = 3,
130 },
99}; 131};
100 132
101const struct rcar_du_format_info *rcar_du_format_info(u32 fourcc) 133const struct rcar_du_format_info *rcar_du_format_info(u32 fourcc)
@@ -143,6 +175,7 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
143 unsigned int max_pitch; 175 unsigned int max_pitch;
144 unsigned int align; 176 unsigned int align;
145 unsigned int bpp; 177 unsigned int bpp;
178 unsigned int i;
146 179
147 format = rcar_du_format_info(mode_cmd->pixel_format); 180 format = rcar_du_format_info(mode_cmd->pixel_format);
148 if (format == NULL) { 181 if (format == NULL) {
@@ -155,7 +188,7 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
155 * The pitch and alignment constraints are expressed in pixels on the 188 * The pitch and alignment constraints are expressed in pixels on the
156 * hardware side and in bytes in the DRM API. 189 * hardware side and in bytes in the DRM API.
157 */ 190 */
158 bpp = format->planes == 2 ? 1 : format->bpp / 8; 191 bpp = format->planes == 1 ? format->bpp / 8 : 1;
159 max_pitch = 4096 * bpp; 192 max_pitch = 4096 * bpp;
160 193
161 if (rcar_du_needs(rcdu, RCAR_DU_QUIRK_ALIGN_128B)) 194 if (rcar_du_needs(rcdu, RCAR_DU_QUIRK_ALIGN_128B))
@@ -170,8 +203,8 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
170 return ERR_PTR(-EINVAL); 203 return ERR_PTR(-EINVAL);
171 } 204 }
172 205
173 if (format->planes == 2) { 206 for (i = 1; i < format->planes; ++i) {
174 if (mode_cmd->pitches[1] != mode_cmd->pitches[0]) { 207 if (mode_cmd->pitches[i] != mode_cmd->pitches[0]) {
175 dev_dbg(dev->dev, 208 dev_dbg(dev->dev,
176 "luma and chroma pitches do not match\n"); 209 "luma and chroma pitches do not match\n");
177 return ERR_PTR(-EINVAL); 210 return ERR_PTR(-EINVAL);
@@ -192,252 +225,20 @@ static void rcar_du_output_poll_changed(struct drm_device *dev)
192 * Atomic Check and Update 225 * Atomic Check and Update
193 */ 226 */
194 227
195/*
196 * Atomic hardware plane allocator
197 *
198 * The hardware plane allocator is solely based on the atomic plane states
199 * without keeping any external state to avoid races between .atomic_check()
200 * and .atomic_commit().
201 *
202 * The core idea is to avoid using a free planes bitmask that would need to be
203 * shared between check and commit handlers with a collective knowledge based on
204 * the allocated hardware plane(s) for each KMS plane. The allocator then loops
205 * over all plane states to compute the free planes bitmask, allocates hardware
206 * planes based on that bitmask, and stores the result back in the plane states.
207 *
208 * For this to work we need to access the current state of planes not touched by
209 * the atomic update. To ensure that it won't be modified, we need to lock all
210 * planes using drm_atomic_get_plane_state(). This effectively serializes atomic
211 * updates from .atomic_check() up to completion (when swapping the states if
212 * the check step has succeeded) or rollback (when freeing the states if the
213 * check step has failed).
214 *
215 * Allocation is performed in the .atomic_check() handler and applied
216 * automatically when the core swaps the old and new states.
217 */
218
219static bool rcar_du_plane_needs_realloc(struct rcar_du_plane *plane,
220 struct rcar_du_plane_state *state)
221{
222 const struct rcar_du_format_info *cur_format;
223
224 cur_format = to_rcar_plane_state(plane->plane.state)->format;
225
226 /* Lowering the number of planes doesn't strictly require reallocation
227 * as the extra hardware plane will be freed when committing, but doing
228 * so could lead to more fragmentation.
229 */
230 return !cur_format || cur_format->planes != state->format->planes;
231}
232
233static unsigned int rcar_du_plane_hwmask(struct rcar_du_plane_state *state)
234{
235 unsigned int mask;
236
237 if (state->hwindex == -1)
238 return 0;
239
240 mask = 1 << state->hwindex;
241 if (state->format->planes == 2)
242 mask |= 1 << ((state->hwindex + 1) % 8);
243
244 return mask;
245}
246
247static int rcar_du_plane_hwalloc(unsigned int num_planes, unsigned int free)
248{
249 unsigned int i;
250
251 for (i = 0; i < RCAR_DU_NUM_HW_PLANES; ++i) {
252 if (!(free & (1 << i)))
253 continue;
254
255 if (num_planes == 1 || free & (1 << ((i + 1) % 8)))
256 break;
257 }
258
259 return i == RCAR_DU_NUM_HW_PLANES ? -EBUSY : i;
260}
261
262static int rcar_du_atomic_check(struct drm_device *dev, 228static int rcar_du_atomic_check(struct drm_device *dev,
263 struct drm_atomic_state *state) 229 struct drm_atomic_state *state)
264{ 230{
265 struct rcar_du_device *rcdu = dev->dev_private; 231 struct rcar_du_device *rcdu = dev->dev_private;
266 unsigned int group_freed_planes[RCAR_DU_MAX_GROUPS] = { 0, };
267 unsigned int group_free_planes[RCAR_DU_MAX_GROUPS] = { 0, };
268 bool needs_realloc = false;
269 unsigned int groups = 0;
270 unsigned int i;
271 int ret; 232 int ret;
272 233
273 ret = drm_atomic_helper_check(dev, state); 234 ret = drm_atomic_helper_check(dev, state);
274 if (ret < 0) 235 if (ret < 0)
275 return ret; 236 return ret;
276 237
277 /* Check if hardware planes need to be reallocated. */ 238 if (rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE))
278 for (i = 0; i < dev->mode_config.num_total_plane; ++i) {
279 struct rcar_du_plane_state *plane_state;
280 struct rcar_du_plane *plane;
281 unsigned int index;
282
283 if (!state->planes[i])
284 continue;
285
286 plane = to_rcar_plane(state->planes[i]);
287 plane_state = to_rcar_plane_state(state->plane_states[i]);
288
289 dev_dbg(rcdu->dev, "%s: checking plane (%u,%u)\n", __func__,
290 plane->group->index, plane - plane->group->planes);
291
292 /* If the plane is being disabled we don't need to go through
293 * the full reallocation procedure. Just mark the hardware
294 * plane(s) as freed.
295 */
296 if (!plane_state->format) {
297 dev_dbg(rcdu->dev, "%s: plane is being disabled\n",
298 __func__);
299 index = plane - plane->group->planes;
300 group_freed_planes[plane->group->index] |= 1 << index;
301 plane_state->hwindex = -1;
302 continue;
303 }
304
305 /* If the plane needs to be reallocated mark it as such, and
306 * mark the hardware plane(s) as free.
307 */
308 if (rcar_du_plane_needs_realloc(plane, plane_state)) {
309 dev_dbg(rcdu->dev, "%s: plane needs reallocation\n",
310 __func__);
311 groups |= 1 << plane->group->index;
312 needs_realloc = true;
313
314 index = plane - plane->group->planes;
315 group_freed_planes[plane->group->index] |= 1 << index;
316 plane_state->hwindex = -1;
317 }
318 }
319
320 if (!needs_realloc)
321 return 0; 239 return 0;
322 240
323 /* Grab all plane states for the groups that need reallocation to ensure 241 return rcar_du_atomic_check_planes(dev, state);
324 * locking and avoid racy updates. This serializes the update operation,
325 * but there's not much we can do about it as that's the hardware
326 * design.
327 *
328 * Compute the used planes mask for each group at the same time to avoid
329 * looping over the planes separately later.
330 */
331 while (groups) {
332 unsigned int index = ffs(groups) - 1;
333 struct rcar_du_group *group = &rcdu->groups[index];
334 unsigned int used_planes = 0;
335
336 dev_dbg(rcdu->dev, "%s: finding free planes for group %u\n",
337 __func__, index);
338
339 for (i = 0; i < group->num_planes; ++i) {
340 struct rcar_du_plane *plane = &group->planes[i];
341 struct rcar_du_plane_state *plane_state;
342 struct drm_plane_state *s;
343
344 s = drm_atomic_get_plane_state(state, &plane->plane);
345 if (IS_ERR(s))
346 return PTR_ERR(s);
347
348 /* If the plane has been freed in the above loop its
349 * hardware planes must not be added to the used planes
350 * bitmask. However, the current state doesn't reflect
351 * the free state yet, as we've modified the new state
352 * above. Use the local freed planes list to check for
353 * that condition instead.
354 */
355 if (group_freed_planes[index] & (1 << i)) {
356 dev_dbg(rcdu->dev,
357 "%s: plane (%u,%u) has been freed, skipping\n",
358 __func__, plane->group->index,
359 plane - plane->group->planes);
360 continue;
361 }
362
363 plane_state = to_rcar_plane_state(plane->plane.state);
364 used_planes |= rcar_du_plane_hwmask(plane_state);
365
366 dev_dbg(rcdu->dev,
367 "%s: plane (%u,%u) uses %u hwplanes (index %d)\n",
368 __func__, plane->group->index,
369 plane - plane->group->planes,
370 plane_state->format ?
371 plane_state->format->planes : 0,
372 plane_state->hwindex);
373 }
374
375 group_free_planes[index] = 0xff & ~used_planes;
376 groups &= ~(1 << index);
377
378 dev_dbg(rcdu->dev, "%s: group %u free planes mask 0x%02x\n",
379 __func__, index, group_free_planes[index]);
380 }
381
382 /* Reallocate hardware planes for each plane that needs it. */
383 for (i = 0; i < dev->mode_config.num_total_plane; ++i) {
384 struct rcar_du_plane_state *plane_state;
385 struct rcar_du_plane *plane;
386 unsigned int crtc_planes;
387 unsigned int free;
388 int idx;
389
390 if (!state->planes[i])
391 continue;
392
393 plane = to_rcar_plane(state->planes[i]);
394 plane_state = to_rcar_plane_state(state->plane_states[i]);
395
396 dev_dbg(rcdu->dev, "%s: allocating plane (%u,%u)\n", __func__,
397 plane->group->index, plane - plane->group->planes);
398
399 /* Skip planes that are being disabled or don't need to be
400 * reallocated.
401 */
402 if (!plane_state->format ||
403 !rcar_du_plane_needs_realloc(plane, plane_state))
404 continue;
405
406 /* Try to allocate the plane from the free planes currently
407 * associated with the target CRTC to avoid restarting the CRTC
408 * group and thus minimize flicker. If it fails fall back to
409 * allocating from all free planes.
410 */
411 crtc_planes = to_rcar_crtc(plane_state->state.crtc)->index % 2
412 ? plane->group->dptsr_planes
413 : ~plane->group->dptsr_planes;
414 free = group_free_planes[plane->group->index];
415
416 idx = rcar_du_plane_hwalloc(plane_state->format->planes,
417 free & crtc_planes);
418 if (idx < 0)
419 idx = rcar_du_plane_hwalloc(plane_state->format->planes,
420 free);
421 if (idx < 0) {
422 dev_dbg(rcdu->dev, "%s: no available hardware plane\n",
423 __func__);
424 return idx;
425 }
426
427 dev_dbg(rcdu->dev, "%s: allocated %u hwplanes (index %u)\n",
428 __func__, plane_state->format->planes, idx);
429
430 plane_state->hwindex = idx;
431
432 group_free_planes[plane->group->index] &=
433 ~rcar_du_plane_hwmask(plane_state);
434
435 dev_dbg(rcdu->dev, "%s: group %u free planes mask 0x%02x\n",
436 __func__, plane->group->index,
437 group_free_planes[plane->group->index]);
438 }
439
440 return 0;
441} 242}
442 243
443struct rcar_du_commit { 244struct rcar_du_commit {
@@ -456,7 +257,7 @@ static void rcar_du_atomic_complete(struct rcar_du_commit *commit)
456 /* Apply the atomic update. */ 257 /* Apply the atomic update. */
457 drm_atomic_helper_commit_modeset_disables(dev, old_state); 258 drm_atomic_helper_commit_modeset_disables(dev, old_state);
458 drm_atomic_helper_commit_modeset_enables(dev, old_state); 259 drm_atomic_helper_commit_modeset_enables(dev, old_state);
459 drm_atomic_helper_commit_planes(dev, old_state, false); 260 drm_atomic_helper_commit_planes(dev, old_state, true);
460 261
461 drm_atomic_helper_wait_for_vblanks(dev, old_state); 262 drm_atomic_helper_wait_for_vblanks(dev, old_state);
462 263
@@ -775,14 +576,34 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
775 rgrp->num_crtcs = min(rcdu->num_crtcs - 2 * i, 2U); 576 rgrp->num_crtcs = min(rcdu->num_crtcs - 2 * i, 2U);
776 577
777 /* If we have more than one CRTCs in this group pre-associate 578 /* If we have more than one CRTCs in this group pre-associate
778 * planes 0-3 with CRTC 0 and planes 4-7 with CRTC 1 to minimize 579 * the low-order planes with CRTC 0 and the high-order planes
779 * flicker occurring when the association is changed. 580 * with CRTC 1 to minimize flicker occurring when the
581 * association is changed.
780 */ 582 */
781 rgrp->dptsr_planes = rgrp->num_crtcs > 1 ? 0xf0 : 0; 583 rgrp->dptsr_planes = rgrp->num_crtcs > 1
584 ? (rcdu->info->gen >= 3 ? 0x04 : 0xf0)
585 : 0;
782 586
783 ret = rcar_du_planes_init(rgrp); 587 if (!rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE)) {
784 if (ret < 0) 588 ret = rcar_du_planes_init(rgrp);
785 return ret; 589 if (ret < 0)
590 return ret;
591 }
592 }
593
594 /* Initialize the compositors. */
595 if (rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE)) {
596 for (i = 0; i < rcdu->num_crtcs; ++i) {
597 struct rcar_du_vsp *vsp = &rcdu->vsps[i];
598
599 vsp->index = i;
600 vsp->dev = rcdu;
601 rcdu->crtcs[i].vsp = vsp;
602
603 ret = rcar_du_vsp_init(vsp);
604 if (ret < 0)
605 return ret;
606 }
786 } 607 }
787 608
788 /* Create the CRTCs. */ 609 /* Create the CRTCs. */
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c b/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c
index 0c43032fc693..e905f5da7aaa 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c
@@ -62,12 +62,6 @@ static const struct drm_connector_helper_funcs connector_helper_funcs = {
62 .best_encoder = rcar_du_connector_best_encoder, 62 .best_encoder = rcar_du_connector_best_encoder,
63}; 63};
64 64
65static void rcar_du_lvds_connector_destroy(struct drm_connector *connector)
66{
67 drm_connector_unregister(connector);
68 drm_connector_cleanup(connector);
69}
70
71static enum drm_connector_status 65static enum drm_connector_status
72rcar_du_lvds_connector_detect(struct drm_connector *connector, bool force) 66rcar_du_lvds_connector_detect(struct drm_connector *connector, bool force)
73{ 67{
@@ -79,7 +73,7 @@ static const struct drm_connector_funcs connector_funcs = {
79 .reset = drm_atomic_helper_connector_reset, 73 .reset = drm_atomic_helper_connector_reset,
80 .detect = rcar_du_lvds_connector_detect, 74 .detect = rcar_du_lvds_connector_detect,
81 .fill_modes = drm_helper_probe_single_connector_modes, 75 .fill_modes = drm_helper_probe_single_connector_modes,
82 .destroy = rcar_du_lvds_connector_destroy, 76 .destroy = drm_connector_cleanup,
83 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, 77 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
84 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, 78 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
85}; 79};
@@ -117,9 +111,6 @@ int rcar_du_lvds_connector_init(struct rcar_du_device *rcdu,
117 return ret; 111 return ret;
118 112
119 drm_connector_helper_add(connector, &connector_helper_funcs); 113 drm_connector_helper_add(connector, &connector_helper_funcs);
120 ret = drm_connector_register(connector);
121 if (ret < 0)
122 return ret;
123 114
124 connector->dpms = DRM_MODE_DPMS_OFF; 115 connector->dpms = DRM_MODE_DPMS_OFF;
125 drm_object_property_set_value(&connector->base, 116 drm_object_property_set_value(&connector->base,
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c b/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c
index 85043c5bad03..ef3a50321ecc 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c
@@ -38,35 +38,106 @@ static void rcar_lvds_write(struct rcar_du_lvdsenc *lvds, u32 reg, u32 data)
38 iowrite32(data, lvds->mmio + reg); 38 iowrite32(data, lvds->mmio + reg);
39} 39}
40 40
41static int rcar_du_lvdsenc_start(struct rcar_du_lvdsenc *lvds, 41static void rcar_du_lvdsenc_start_gen2(struct rcar_du_lvdsenc *lvds,
42 struct rcar_du_crtc *rcrtc) 42 struct rcar_du_crtc *rcrtc)
43{ 43{
44 const struct drm_display_mode *mode = &rcrtc->crtc.mode; 44 const struct drm_display_mode *mode = &rcrtc->crtc.mode;
45 unsigned int freq = mode->clock; 45 unsigned int freq = mode->clock;
46 u32 lvdcr0; 46 u32 lvdcr0;
47 u32 lvdhcr;
48 u32 pllcr; 47 u32 pllcr;
49 int ret;
50
51 if (lvds->enabled)
52 return 0;
53
54 ret = clk_prepare_enable(lvds->clock);
55 if (ret < 0)
56 return ret;
57 48
58 /* PLL clock configuration */ 49 /* PLL clock configuration */
59 if (freq <= 38000) 50 if (freq < 39000)
60 pllcr = LVDPLLCR_CEEN | LVDPLLCR_COSEL | LVDPLLCR_PLLDLYCNT_38M; 51 pllcr = LVDPLLCR_CEEN | LVDPLLCR_COSEL | LVDPLLCR_PLLDLYCNT_38M;
61 else if (freq <= 60000) 52 else if (freq < 61000)
62 pllcr = LVDPLLCR_CEEN | LVDPLLCR_COSEL | LVDPLLCR_PLLDLYCNT_60M; 53 pllcr = LVDPLLCR_CEEN | LVDPLLCR_COSEL | LVDPLLCR_PLLDLYCNT_60M;
63 else if (freq <= 121000) 54 else if (freq < 121000)
64 pllcr = LVDPLLCR_CEEN | LVDPLLCR_COSEL | LVDPLLCR_PLLDLYCNT_121M; 55 pllcr = LVDPLLCR_CEEN | LVDPLLCR_COSEL | LVDPLLCR_PLLDLYCNT_121M;
65 else 56 else
66 pllcr = LVDPLLCR_PLLDLYCNT_150M; 57 pllcr = LVDPLLCR_PLLDLYCNT_150M;
67 58
68 rcar_lvds_write(lvds, LVDPLLCR, pllcr); 59 rcar_lvds_write(lvds, LVDPLLCR, pllcr);
69 60
61 /* Select the input, hardcode mode 0, enable LVDS operation and turn
62 * bias circuitry on.
63 */
64 lvdcr0 = LVDCR0_BEN | LVDCR0_LVEN;
65 if (rcrtc->index == 2)
66 lvdcr0 |= LVDCR0_DUSEL;
67 rcar_lvds_write(lvds, LVDCR0, lvdcr0);
68
69 /* Turn all the channels on. */
70 rcar_lvds_write(lvds, LVDCR1,
71 LVDCR1_CHSTBY_GEN2(3) | LVDCR1_CHSTBY_GEN2(2) |
72 LVDCR1_CHSTBY_GEN2(1) | LVDCR1_CHSTBY_GEN2(0) |
73 LVDCR1_CLKSTBY_GEN2);
74
75 /* Turn the PLL on, wait for the startup delay, and turn the output
76 * on.
77 */
78 lvdcr0 |= LVDCR0_PLLON;
79 rcar_lvds_write(lvds, LVDCR0, lvdcr0);
80
81 usleep_range(100, 150);
82
83 lvdcr0 |= LVDCR0_LVRES;
84 rcar_lvds_write(lvds, LVDCR0, lvdcr0);
85}
86
87static void rcar_du_lvdsenc_start_gen3(struct rcar_du_lvdsenc *lvds,
88 struct rcar_du_crtc *rcrtc)
89{
90 const struct drm_display_mode *mode = &rcrtc->crtc.mode;
91 unsigned int freq = mode->clock;
92 u32 lvdcr0;
93 u32 pllcr;
94
95 /* PLL clock configuration */
96 if (freq < 42000)
97 pllcr = LVDPLLCR_PLLDIVCNT_42M;
98 else if (freq < 85000)
99 pllcr = LVDPLLCR_PLLDIVCNT_85M;
100 else if (freq < 128000)
101 pllcr = LVDPLLCR_PLLDIVCNT_128M;
102 else
103 pllcr = LVDPLLCR_PLLDIVCNT_148M;
104
105 rcar_lvds_write(lvds, LVDPLLCR, pllcr);
106
107 /* Turn the PLL on, set it to LVDS normal mode, wait for the startup
108 * delay and turn the output on.
109 */
110 lvdcr0 = LVDCR0_PLLON;
111 rcar_lvds_write(lvds, LVDCR0, lvdcr0);
112
113 lvdcr0 |= LVDCR0_PWD;
114 rcar_lvds_write(lvds, LVDCR0, lvdcr0);
115
116 usleep_range(100, 150);
117
118 lvdcr0 |= LVDCR0_LVRES;
119 rcar_lvds_write(lvds, LVDCR0, lvdcr0);
120
121 /* Turn all the channels on. */
122 rcar_lvds_write(lvds, LVDCR1,
123 LVDCR1_CHSTBY_GEN3(3) | LVDCR1_CHSTBY_GEN3(2) |
124 LVDCR1_CHSTBY_GEN3(1) | LVDCR1_CHSTBY_GEN3(0) |
125 LVDCR1_CLKSTBY_GEN3);
126}
127
128static int rcar_du_lvdsenc_start(struct rcar_du_lvdsenc *lvds,
129 struct rcar_du_crtc *rcrtc)
130{
131 u32 lvdhcr;
132 int ret;
133
134 if (lvds->enabled)
135 return 0;
136
137 ret = clk_prepare_enable(lvds->clock);
138 if (ret < 0)
139 return ret;
140
70 /* Hardcode the channels and control signals routing for now. 141 /* Hardcode the channels and control signals routing for now.
71 * 142 *
72 * HSYNC -> CTRL0 143 * HSYNC -> CTRL0
@@ -87,30 +158,14 @@ static int rcar_du_lvdsenc_start(struct rcar_du_lvdsenc *lvds,
87 158
88 rcar_lvds_write(lvds, LVDCHCR, lvdhcr); 159 rcar_lvds_write(lvds, LVDCHCR, lvdhcr);
89 160
90 /* Select the input, hardcode mode 0, enable LVDS operation and turn 161 /* Perform generation-specific initialization. */
91 * bias circuitry on. 162 if (lvds->dev->info->gen < 3)
92 */ 163 rcar_du_lvdsenc_start_gen2(lvds, rcrtc);
93 lvdcr0 = LVDCR0_BEN | LVDCR0_LVEN; 164 else
94 if (rcrtc->index == 2) 165 rcar_du_lvdsenc_start_gen3(lvds, rcrtc);
95 lvdcr0 |= LVDCR0_DUSEL;
96 rcar_lvds_write(lvds, LVDCR0, lvdcr0);
97
98 /* Turn all the channels on. */
99 rcar_lvds_write(lvds, LVDCR1, LVDCR1_CHSTBY(3) | LVDCR1_CHSTBY(2) |
100 LVDCR1_CHSTBY(1) | LVDCR1_CHSTBY(0) | LVDCR1_CLKSTBY);
101
102 /* Turn the PLL on, wait for the startup delay, and turn the output
103 * on.
104 */
105 lvdcr0 |= LVDCR0_PLLEN;
106 rcar_lvds_write(lvds, LVDCR0, lvdcr0);
107
108 usleep_range(100, 150);
109
110 lvdcr0 |= LVDCR0_LVRES;
111 rcar_lvds_write(lvds, LVDCR0, lvdcr0);
112 166
113 lvds->enabled = true; 167 lvds->enabled = true;
168
114 return 0; 169 return 0;
115} 170}
116 171
@@ -140,6 +195,21 @@ int rcar_du_lvdsenc_enable(struct rcar_du_lvdsenc *lvds, struct drm_crtc *crtc,
140 return -EINVAL; 195 return -EINVAL;
141} 196}
142 197
198void rcar_du_lvdsenc_atomic_check(struct rcar_du_lvdsenc *lvds,
199 struct drm_display_mode *mode)
200{
201 struct rcar_du_device *rcdu = lvds->dev;
202
203 /* The internal LVDS encoder has a restricted clock frequency operating
204 * range (30MHz to 150MHz on Gen2, 25.175MHz to 148.5MHz on Gen3). Clamp
205 * the clock accordingly.
206 */
207 if (rcdu->info->gen < 3)
208 mode->clock = clamp(mode->clock, 30000, 150000);
209 else
210 mode->clock = clamp(mode->clock, 25175, 148500);
211}
212
143static int rcar_du_lvdsenc_get_resources(struct rcar_du_lvdsenc *lvds, 213static int rcar_du_lvdsenc_get_resources(struct rcar_du_lvdsenc *lvds,
144 struct platform_device *pdev) 214 struct platform_device *pdev)
145{ 215{
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h b/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h
index 9a6001c07303..dfdba746edf4 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h
@@ -30,6 +30,8 @@ enum rcar_lvds_input {
30int rcar_du_lvdsenc_init(struct rcar_du_device *rcdu); 30int rcar_du_lvdsenc_init(struct rcar_du_device *rcdu);
31int rcar_du_lvdsenc_enable(struct rcar_du_lvdsenc *lvds, 31int rcar_du_lvdsenc_enable(struct rcar_du_lvdsenc *lvds,
32 struct drm_crtc *crtc, bool enable); 32 struct drm_crtc *crtc, bool enable);
33void rcar_du_lvdsenc_atomic_check(struct rcar_du_lvdsenc *lvds,
34 struct drm_display_mode *mode);
33#else 35#else
34static inline int rcar_du_lvdsenc_init(struct rcar_du_device *rcdu) 36static inline int rcar_du_lvdsenc_init(struct rcar_du_device *rcdu)
35{ 37{
@@ -40,6 +42,10 @@ static inline int rcar_du_lvdsenc_enable(struct rcar_du_lvdsenc *lvds,
40{ 42{
41 return 0; 43 return 0;
42} 44}
45static inline void rcar_du_lvdsenc_atomic_check(struct rcar_du_lvdsenc *lvds,
46 struct drm_display_mode *mode)
47{
48}
43#endif 49#endif
44 50
45#endif /* __RCAR_DU_LVDSENC_H__ */ 51#endif /* __RCAR_DU_LVDSENC_H__ */
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
index c3ed9522c0e1..8460ae1ffa4b 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * rcar_du_plane.c -- R-Car Display Unit Planes 2 * rcar_du_plane.c -- R-Car Display Unit Planes
3 * 3 *
4 * Copyright (C) 2013-2014 Renesas Electronics Corporation 4 * Copyright (C) 2013-2015 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
@@ -12,6 +12,7 @@
12 */ 12 */
13 13
14#include <drm/drmP.h> 14#include <drm/drmP.h>
15#include <drm/drm_atomic.h>
15#include <drm/drm_atomic_helper.h> 16#include <drm/drm_atomic_helper.h>
16#include <drm/drm_crtc.h> 17#include <drm/drm_crtc.h>
17#include <drm/drm_crtc_helper.h> 18#include <drm/drm_crtc_helper.h>
@@ -20,21 +21,300 @@
20#include <drm/drm_plane_helper.h> 21#include <drm/drm_plane_helper.h>
21 22
22#include "rcar_du_drv.h" 23#include "rcar_du_drv.h"
24#include "rcar_du_group.h"
23#include "rcar_du_kms.h" 25#include "rcar_du_kms.h"
24#include "rcar_du_plane.h" 26#include "rcar_du_plane.h"
25#include "rcar_du_regs.h" 27#include "rcar_du_regs.h"
26 28
27#define RCAR_DU_COLORKEY_NONE (0 << 24) 29/* -----------------------------------------------------------------------------
28#define RCAR_DU_COLORKEY_SOURCE (1 << 24) 30 * Atomic hardware plane allocator
29#define RCAR_DU_COLORKEY_MASK (1 << 24) 31 *
32 * The hardware plane allocator is solely based on the atomic plane states
33 * without keeping any external state to avoid races between .atomic_check()
34 * and .atomic_commit().
35 *
36 * The core idea is to avoid using a free planes bitmask that would need to be
37 * shared between check and commit handlers with a collective knowledge based on
38 * the allocated hardware plane(s) for each KMS plane. The allocator then loops
39 * over all plane states to compute the free planes bitmask, allocates hardware
40 * planes based on that bitmask, and stores the result back in the plane states.
41 *
42 * For this to work we need to access the current state of planes not touched by
43 * the atomic update. To ensure that it won't be modified, we need to lock all
44 * planes using drm_atomic_get_plane_state(). This effectively serializes atomic
45 * updates from .atomic_check() up to completion (when swapping the states if
46 * the check step has succeeded) or rollback (when freeing the states if the
47 * check step has failed).
48 *
49 * Allocation is performed in the .atomic_check() handler and applied
50 * automatically when the core swaps the old and new states.
51 */
52
53static bool rcar_du_plane_needs_realloc(struct rcar_du_plane *plane,
54 struct rcar_du_plane_state *new_state)
55{
56 struct rcar_du_plane_state *cur_state;
57
58 cur_state = to_rcar_plane_state(plane->plane.state);
59
60 /* Lowering the number of planes doesn't strictly require reallocation
61 * as the extra hardware plane will be freed when committing, but doing
62 * so could lead to more fragmentation.
63 */
64 if (!cur_state->format ||
65 cur_state->format->planes != new_state->format->planes)
66 return true;
67
68 /* Reallocate hardware planes if the source has changed. */
69 if (cur_state->source != new_state->source)
70 return true;
30 71
31static u32 rcar_du_plane_read(struct rcar_du_group *rgrp, 72 return false;
32 unsigned int index, u32 reg) 73}
74
75static unsigned int rcar_du_plane_hwmask(struct rcar_du_plane_state *state)
76{
77 unsigned int mask;
78
79 if (state->hwindex == -1)
80 return 0;
81
82 mask = 1 << state->hwindex;
83 if (state->format->planes == 2)
84 mask |= 1 << ((state->hwindex + 1) % 8);
85
86 return mask;
87}
88
89/*
90 * The R8A7790 DU can source frames directly from the VSP1 devices VSPD0 and
91 * VSPD1. VSPD0 feeds DU0/1 plane 0, and VSPD1 feeds either DU2 plane 0 or
92 * DU0/1 plane 1.
93 *
94 * Allocate the correct fixed plane when sourcing frames from VSPD0 or VSPD1,
95 * and allocate planes in reverse index order otherwise to ensure maximum
96 * availability of planes 0 and 1.
97 *
98 * The caller is responsible for ensuring that the requested source is
99 * compatible with the DU revision.
100 */
101static int rcar_du_plane_hwalloc(struct rcar_du_plane *plane,
102 struct rcar_du_plane_state *state,
103 unsigned int free)
33{ 104{
34 return rcar_du_read(rgrp->dev, 105 unsigned int num_planes = state->format->planes;
35 rgrp->mmio_offset + index * PLANE_OFF + reg); 106 int fixed = -1;
107 int i;
108
109 if (state->source == RCAR_DU_PLANE_VSPD0) {
110 /* VSPD0 feeds plane 0 on DU0/1. */
111 if (plane->group->index != 0)
112 return -EINVAL;
113
114 fixed = 0;
115 } else if (state->source == RCAR_DU_PLANE_VSPD1) {
116 /* VSPD1 feeds plane 1 on DU0/1 or plane 0 on DU2. */
117 fixed = plane->group->index == 0 ? 1 : 0;
118 }
119
120 if (fixed >= 0)
121 return free & (1 << fixed) ? fixed : -EBUSY;
122
123 for (i = RCAR_DU_NUM_HW_PLANES - 1; i >= 0; --i) {
124 if (!(free & (1 << i)))
125 continue;
126
127 if (num_planes == 1 || free & (1 << ((i + 1) % 8)))
128 break;
129 }
130
131 return i < 0 ? -EBUSY : i;
36} 132}
37 133
134int rcar_du_atomic_check_planes(struct drm_device *dev,
135 struct drm_atomic_state *state)
136{
137 struct rcar_du_device *rcdu = dev->dev_private;
138 unsigned int group_freed_planes[RCAR_DU_MAX_GROUPS] = { 0, };
139 unsigned int group_free_planes[RCAR_DU_MAX_GROUPS] = { 0, };
140 bool needs_realloc = false;
141 unsigned int groups = 0;
142 unsigned int i;
143
144 /* Check if hardware planes need to be reallocated. */
145 for (i = 0; i < dev->mode_config.num_total_plane; ++i) {
146 struct rcar_du_plane_state *plane_state;
147 struct rcar_du_plane *plane;
148 unsigned int index;
149
150 if (!state->planes[i])
151 continue;
152
153 plane = to_rcar_plane(state->planes[i]);
154 plane_state = to_rcar_plane_state(state->plane_states[i]);
155
156 dev_dbg(rcdu->dev, "%s: checking plane (%u,%tu)\n", __func__,
157 plane->group->index, plane - plane->group->planes);
158
159 /* If the plane is being disabled we don't need to go through
160 * the full reallocation procedure. Just mark the hardware
161 * plane(s) as freed.
162 */
163 if (!plane_state->format) {
164 dev_dbg(rcdu->dev, "%s: plane is being disabled\n",
165 __func__);
166 index = plane - plane->group->planes;
167 group_freed_planes[plane->group->index] |= 1 << index;
168 plane_state->hwindex = -1;
169 continue;
170 }
171
172 /* If the plane needs to be reallocated mark it as such, and
173 * mark the hardware plane(s) as free.
174 */
175 if (rcar_du_plane_needs_realloc(plane, plane_state)) {
176 dev_dbg(rcdu->dev, "%s: plane needs reallocation\n",
177 __func__);
178 groups |= 1 << plane->group->index;
179 needs_realloc = true;
180
181 index = plane - plane->group->planes;
182 group_freed_planes[plane->group->index] |= 1 << index;
183 plane_state->hwindex = -1;
184 }
185 }
186
187 if (!needs_realloc)
188 return 0;
189
190 /* Grab all plane states for the groups that need reallocation to ensure
191 * locking and avoid racy updates. This serializes the update operation,
192 * but there's not much we can do about it as that's the hardware
193 * design.
194 *
195 * Compute the used planes mask for each group at the same time to avoid
196 * looping over the planes separately later.
197 */
198 while (groups) {
199 unsigned int index = ffs(groups) - 1;
200 struct rcar_du_group *group = &rcdu->groups[index];
201 unsigned int used_planes = 0;
202
203 dev_dbg(rcdu->dev, "%s: finding free planes for group %u\n",
204 __func__, index);
205
206 for (i = 0; i < group->num_planes; ++i) {
207 struct rcar_du_plane *plane = &group->planes[i];
208 struct rcar_du_plane_state *plane_state;
209 struct drm_plane_state *s;
210
211 s = drm_atomic_get_plane_state(state, &plane->plane);
212 if (IS_ERR(s))
213 return PTR_ERR(s);
214
215 /* If the plane has been freed in the above loop its
216 * hardware planes must not be added to the used planes
217 * bitmask. However, the current state doesn't reflect
218 * the free state yet, as we've modified the new state
219 * above. Use the local freed planes list to check for
220 * that condition instead.
221 */
222 if (group_freed_planes[index] & (1 << i)) {
223 dev_dbg(rcdu->dev,
224 "%s: plane (%u,%tu) has been freed, skipping\n",
225 __func__, plane->group->index,
226 plane - plane->group->planes);
227 continue;
228 }
229
230 plane_state = to_rcar_plane_state(plane->plane.state);
231 used_planes |= rcar_du_plane_hwmask(plane_state);
232
233 dev_dbg(rcdu->dev,
234 "%s: plane (%u,%tu) uses %u hwplanes (index %d)\n",
235 __func__, plane->group->index,
236 plane - plane->group->planes,
237 plane_state->format ?
238 plane_state->format->planes : 0,
239 plane_state->hwindex);
240 }
241
242 group_free_planes[index] = 0xff & ~used_planes;
243 groups &= ~(1 << index);
244
245 dev_dbg(rcdu->dev, "%s: group %u free planes mask 0x%02x\n",
246 __func__, index, group_free_planes[index]);
247 }
248
249 /* Reallocate hardware planes for each plane that needs it. */
250 for (i = 0; i < dev->mode_config.num_total_plane; ++i) {
251 struct rcar_du_plane_state *plane_state;
252 struct rcar_du_plane *plane;
253 unsigned int crtc_planes;
254 unsigned int free;
255 int idx;
256
257 if (!state->planes[i])
258 continue;
259
260 plane = to_rcar_plane(state->planes[i]);
261 plane_state = to_rcar_plane_state(state->plane_states[i]);
262
263 dev_dbg(rcdu->dev, "%s: allocating plane (%u,%tu)\n", __func__,
264 plane->group->index, plane - plane->group->planes);
265
266 /* Skip planes that are being disabled or don't need to be
267 * reallocated.
268 */
269 if (!plane_state->format ||
270 !rcar_du_plane_needs_realloc(plane, plane_state))
271 continue;
272
273 /* Try to allocate the plane from the free planes currently
274 * associated with the target CRTC to avoid restarting the CRTC
275 * group and thus minimize flicker. If it fails fall back to
276 * allocating from all free planes.
277 */
278 crtc_planes = to_rcar_crtc(plane_state->state.crtc)->index % 2
279 ? plane->group->dptsr_planes
280 : ~plane->group->dptsr_planes;
281 free = group_free_planes[plane->group->index];
282
283 idx = rcar_du_plane_hwalloc(plane, plane_state,
284 free & crtc_planes);
285 if (idx < 0)
286 idx = rcar_du_plane_hwalloc(plane, plane_state,
287 free);
288 if (idx < 0) {
289 dev_dbg(rcdu->dev, "%s: no available hardware plane\n",
290 __func__);
291 return idx;
292 }
293
294 dev_dbg(rcdu->dev, "%s: allocated %u hwplanes (index %u)\n",
295 __func__, plane_state->format->planes, idx);
296
297 plane_state->hwindex = idx;
298
299 group_free_planes[plane->group->index] &=
300 ~rcar_du_plane_hwmask(plane_state);
301
302 dev_dbg(rcdu->dev, "%s: group %u free planes mask 0x%02x\n",
303 __func__, plane->group->index,
304 group_free_planes[plane->group->index]);
305 }
306
307 return 0;
308}
309
310/* -----------------------------------------------------------------------------
311 * Plane Setup
312 */
313
314#define RCAR_DU_COLORKEY_NONE (0 << 24)
315#define RCAR_DU_COLORKEY_SOURCE (1 << 24)
316#define RCAR_DU_COLORKEY_MASK (1 << 24)
317
38static void rcar_du_plane_write(struct rcar_du_group *rgrp, 318static void rcar_du_plane_write(struct rcar_du_group *rgrp,
39 unsigned int index, u32 reg, u32 data) 319 unsigned int index, u32 reg, u32 data)
40{ 320{
@@ -42,34 +322,45 @@ static void rcar_du_plane_write(struct rcar_du_group *rgrp,
42 data); 322 data);
43} 323}
44 324
45static void rcar_du_plane_setup_fb(struct rcar_du_plane *plane) 325static void rcar_du_plane_setup_scanout(struct rcar_du_group *rgrp,
326 const struct rcar_du_plane_state *state)
46{ 327{
47 struct rcar_du_plane_state *state =
48 to_rcar_plane_state(plane->plane.state);
49 struct drm_framebuffer *fb = plane->plane.state->fb;
50 struct rcar_du_group *rgrp = plane->group;
51 unsigned int src_x = state->state.src_x >> 16; 328 unsigned int src_x = state->state.src_x >> 16;
52 unsigned int src_y = state->state.src_y >> 16; 329 unsigned int src_y = state->state.src_y >> 16;
53 unsigned int index = state->hwindex; 330 unsigned int index = state->hwindex;
54 struct drm_gem_cma_object *gem; 331 unsigned int pitch;
55 bool interlaced; 332 bool interlaced;
56 u32 mwr; 333 u32 dma[2];
57 334
58 interlaced = state->state.crtc->state->adjusted_mode.flags 335 interlaced = state->state.crtc->state->adjusted_mode.flags
59 & DRM_MODE_FLAG_INTERLACE; 336 & DRM_MODE_FLAG_INTERLACE;
60 337
338 if (state->source == RCAR_DU_PLANE_MEMORY) {
339 struct drm_framebuffer *fb = state->state.fb;
340 struct drm_gem_cma_object *gem;
341 unsigned int i;
342
343 if (state->format->planes == 2)
344 pitch = fb->pitches[0];
345 else
346 pitch = fb->pitches[0] * 8 / state->format->bpp;
347
348 for (i = 0; i < state->format->planes; ++i) {
349 gem = drm_fb_cma_get_gem_obj(fb, i);
350 dma[i] = gem->paddr + fb->offsets[i];
351 }
352 } else {
353 pitch = state->state.src_w >> 16;
354 dma[0] = 0;
355 dma[1] = 0;
356 }
357
61 /* Memory pitch (expressed in pixels). Must be doubled for interlaced 358 /* Memory pitch (expressed in pixels). Must be doubled for interlaced
62 * operation with 32bpp formats. 359 * operation with 32bpp formats.
63 */ 360 */
64 if (state->format->planes == 2) 361 rcar_du_plane_write(rgrp, index, PnMWR,
65 mwr = fb->pitches[0]; 362 (interlaced && state->format->bpp == 32) ?
66 else 363 pitch * 2 : pitch);
67 mwr = fb->pitches[0] * 8 / state->format->bpp;
68
69 if (interlaced && state->format->bpp == 32)
70 mwr *= 2;
71
72 rcar_du_plane_write(rgrp, index, PnMWR, mwr);
73 364
74 /* The Y position is expressed in raster line units and must be doubled 365 /* The Y position is expressed in raster line units and must be doubled
75 * for 32bpp formats, according to the R8A7790 datasheet. No mention of 366 * for 32bpp formats, according to the R8A7790 datasheet. No mention of
@@ -87,30 +378,25 @@ static void rcar_du_plane_setup_fb(struct rcar_du_plane *plane)
87 rcar_du_plane_write(rgrp, index, PnSPYR, src_y * 378 rcar_du_plane_write(rgrp, index, PnSPYR, src_y *
88 (!interlaced && state->format->bpp == 32 ? 2 : 1)); 379 (!interlaced && state->format->bpp == 32 ? 2 : 1));
89 380
90 gem = drm_fb_cma_get_gem_obj(fb, 0); 381 rcar_du_plane_write(rgrp, index, PnDSA0R, dma[0]);
91 rcar_du_plane_write(rgrp, index, PnDSA0R, gem->paddr + fb->offsets[0]);
92 382
93 if (state->format->planes == 2) { 383 if (state->format->planes == 2) {
94 index = (index + 1) % 8; 384 index = (index + 1) % 8;
95 385
96 rcar_du_plane_write(rgrp, index, PnMWR, fb->pitches[0]); 386 rcar_du_plane_write(rgrp, index, PnMWR, pitch);
97 387
98 rcar_du_plane_write(rgrp, index, PnSPXR, src_x); 388 rcar_du_plane_write(rgrp, index, PnSPXR, src_x);
99 rcar_du_plane_write(rgrp, index, PnSPYR, src_y * 389 rcar_du_plane_write(rgrp, index, PnSPYR, src_y *
100 (state->format->bpp == 16 ? 2 : 1) / 2); 390 (state->format->bpp == 16 ? 2 : 1) / 2);
101 391
102 gem = drm_fb_cma_get_gem_obj(fb, 1); 392 rcar_du_plane_write(rgrp, index, PnDSA0R, dma[1]);
103 rcar_du_plane_write(rgrp, index, PnDSA0R,
104 gem->paddr + fb->offsets[1]);
105 } 393 }
106} 394}
107 395
108static void rcar_du_plane_setup_mode(struct rcar_du_plane *plane, 396static void rcar_du_plane_setup_mode(struct rcar_du_group *rgrp,
109 unsigned int index) 397 unsigned int index,
398 const struct rcar_du_plane_state *state)
110{ 399{
111 struct rcar_du_plane_state *state =
112 to_rcar_plane_state(plane->plane.state);
113 struct rcar_du_group *rgrp = plane->group;
114 u32 colorkey; 400 u32 colorkey;
115 u32 pnmr; 401 u32 pnmr;
116 402
@@ -168,12 +454,10 @@ static void rcar_du_plane_setup_mode(struct rcar_du_plane *plane,
168 } 454 }
169} 455}
170 456
171static void __rcar_du_plane_setup(struct rcar_du_plane *plane, 457static void rcar_du_plane_setup_format_gen2(struct rcar_du_group *rgrp,
172 unsigned int index) 458 unsigned int index,
459 const struct rcar_du_plane_state *state)
173{ 460{
174 struct rcar_du_plane_state *state =
175 to_rcar_plane_state(plane->plane.state);
176 struct rcar_du_group *rgrp = plane->group;
177 u32 ddcr2 = PnDDCR2_CODE; 461 u32 ddcr2 = PnDDCR2_CODE;
178 u32 ddcr4; 462 u32 ddcr4;
179 463
@@ -182,11 +466,8 @@ static void __rcar_du_plane_setup(struct rcar_du_plane *plane,
182 * The data format is selected by the DDDF field in PnMR and the EDF 466 * The data format is selected by the DDDF field in PnMR and the EDF
183 * field in DDCR4. 467 * field in DDCR4.
184 */ 468 */
185 ddcr4 = rcar_du_plane_read(rgrp, index, PnDDCR4);
186 ddcr4 &= ~PnDDCR4_EDF_MASK;
187 ddcr4 |= state->format->edf | PnDDCR4_CODE;
188 469
189 rcar_du_plane_setup_mode(plane, index); 470 rcar_du_plane_setup_mode(rgrp, index, state);
190 471
191 if (state->format->planes == 2) { 472 if (state->format->planes == 2) {
192 if (state->hwindex != index) { 473 if (state->hwindex != index) {
@@ -204,31 +485,72 @@ static void __rcar_du_plane_setup(struct rcar_du_plane *plane,
204 } 485 }
205 486
206 rcar_du_plane_write(rgrp, index, PnDDCR2, ddcr2); 487 rcar_du_plane_write(rgrp, index, PnDDCR2, ddcr2);
488
489 ddcr4 = state->format->edf | PnDDCR4_CODE;
490 if (state->source != RCAR_DU_PLANE_MEMORY)
491 ddcr4 |= PnDDCR4_VSPS;
492
207 rcar_du_plane_write(rgrp, index, PnDDCR4, ddcr4); 493 rcar_du_plane_write(rgrp, index, PnDDCR4, ddcr4);
494}
495
496static void rcar_du_plane_setup_format_gen3(struct rcar_du_group *rgrp,
497 unsigned int index,
498 const struct rcar_du_plane_state *state)
499{
500 rcar_du_plane_write(rgrp, index, PnMR,
501 PnMR_SPIM_TP_OFF | state->format->pnmr);
502
503 rcar_du_plane_write(rgrp, index, PnDDCR4,
504 state->format->edf | PnDDCR4_CODE);
505}
506
507static void rcar_du_plane_setup_format(struct rcar_du_group *rgrp,
508 unsigned int index,
509 const struct rcar_du_plane_state *state)
510{
511 struct rcar_du_device *rcdu = rgrp->dev;
512
513 if (rcdu->info->gen < 3)
514 rcar_du_plane_setup_format_gen2(rgrp, index, state);
515 else
516 rcar_du_plane_setup_format_gen3(rgrp, index, state);
208 517
209 /* Destination position and size */ 518 /* Destination position and size */
210 rcar_du_plane_write(rgrp, index, PnDSXR, plane->plane.state->crtc_w); 519 rcar_du_plane_write(rgrp, index, PnDSXR, state->state.crtc_w);
211 rcar_du_plane_write(rgrp, index, PnDSYR, plane->plane.state->crtc_h); 520 rcar_du_plane_write(rgrp, index, PnDSYR, state->state.crtc_h);
212 rcar_du_plane_write(rgrp, index, PnDPXR, plane->plane.state->crtc_x); 521 rcar_du_plane_write(rgrp, index, PnDPXR, state->state.crtc_x);
213 rcar_du_plane_write(rgrp, index, PnDPYR, plane->plane.state->crtc_y); 522 rcar_du_plane_write(rgrp, index, PnDPYR, state->state.crtc_y);
214 523
215 /* Wrap-around and blinking, disabled */ 524 if (rcdu->info->gen < 3) {
216 rcar_du_plane_write(rgrp, index, PnWASPR, 0); 525 /* Wrap-around and blinking, disabled */
217 rcar_du_plane_write(rgrp, index, PnWAMWR, 4095); 526 rcar_du_plane_write(rgrp, index, PnWASPR, 0);
218 rcar_du_plane_write(rgrp, index, PnBTR, 0); 527 rcar_du_plane_write(rgrp, index, PnWAMWR, 4095);
219 rcar_du_plane_write(rgrp, index, PnMLR, 0); 528 rcar_du_plane_write(rgrp, index, PnBTR, 0);
529 rcar_du_plane_write(rgrp, index, PnMLR, 0);
530 }
220} 531}
221 532
222void rcar_du_plane_setup(struct rcar_du_plane *plane) 533void __rcar_du_plane_setup(struct rcar_du_group *rgrp,
534 const struct rcar_du_plane_state *state)
223{ 535{
224 struct rcar_du_plane_state *state = 536 struct rcar_du_device *rcdu = rgrp->dev;
225 to_rcar_plane_state(plane->plane.state);
226 537
227 __rcar_du_plane_setup(plane, state->hwindex); 538 rcar_du_plane_setup_format(rgrp, state->hwindex, state);
228 if (state->format->planes == 2) 539 if (state->format->planes == 2)
229 __rcar_du_plane_setup(plane, (state->hwindex + 1) % 8); 540 rcar_du_plane_setup_format(rgrp, (state->hwindex + 1) % 8,
541 state);
230 542
231 rcar_du_plane_setup_fb(plane); 543 if (rcdu->info->gen < 3)
544 rcar_du_plane_setup_scanout(rgrp, state);
545
546 if (state->source == RCAR_DU_PLANE_VSPD1) {
547 unsigned int vspd1_sink = rgrp->index ? 2 : 0;
548
549 if (rcdu->vspd1_sink != vspd1_sink) {
550 rcdu->vspd1_sink = vspd1_sink;
551 rcar_du_set_dpad0_vsp1_routing(rcdu);
552 }
553 }
232} 554}
233 555
234static int rcar_du_plane_atomic_check(struct drm_plane *plane, 556static int rcar_du_plane_atomic_check(struct drm_plane *plane,
@@ -263,9 +585,27 @@ static void rcar_du_plane_atomic_update(struct drm_plane *plane,
263 struct drm_plane_state *old_state) 585 struct drm_plane_state *old_state)
264{ 586{
265 struct rcar_du_plane *rplane = to_rcar_plane(plane); 587 struct rcar_du_plane *rplane = to_rcar_plane(plane);
588 struct rcar_du_plane_state *old_rstate;
589 struct rcar_du_plane_state *new_rstate;
590
591 if (!plane->state->crtc)
592 return;
593
594 rcar_du_plane_setup(rplane);
595
596 /* Check whether the source has changed from memory to live source or
597 * from live source to memory. The source has been configured by the
598 * VSPS bit in the PnDDCR4 register. Although the datasheet states that
599 * the bit is updated during vertical blanking, it seems that updates
600 * only occur when the DU group is held in reset through the DSYSR.DRES
601 * bit. We thus need to restart the group if the source changes.
602 */
603 old_rstate = to_rcar_plane_state(old_state);
604 new_rstate = to_rcar_plane_state(plane->state);
266 605
267 if (plane->state->crtc) 606 if ((old_rstate->source == RCAR_DU_PLANE_MEMORY) !=
268 rcar_du_plane_setup(rplane); 607 (new_rstate->source == RCAR_DU_PLANE_MEMORY))
608 rplane->group->need_restart = true;
269} 609}
270 610
271static const struct drm_plane_helper_funcs rcar_du_plane_helper_funcs = { 611static const struct drm_plane_helper_funcs rcar_du_plane_helper_funcs = {
@@ -313,6 +653,7 @@ static void rcar_du_plane_reset(struct drm_plane *plane)
313 return; 653 return;
314 654
315 state->hwindex = -1; 655 state->hwindex = -1;
656 state->source = RCAR_DU_PLANE_MEMORY;
316 state->alpha = 255; 657 state->alpha = 255;
317 state->colorkey = RCAR_DU_COLORKEY_NONE; 658 state->colorkey = RCAR_DU_COLORKEY_NONE;
318 state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1; 659 state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.h b/drivers/gpu/drm/rcar-du/rcar_du_plane.h
index 9732bff1911b..b18b7b25dbfa 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.h
@@ -28,6 +28,12 @@ struct rcar_du_group;
28#define RCAR_DU_NUM_KMS_PLANES 9 28#define RCAR_DU_NUM_KMS_PLANES 9
29#define RCAR_DU_NUM_HW_PLANES 8 29#define RCAR_DU_NUM_HW_PLANES 8
30 30
31enum rcar_du_plane_source {
32 RCAR_DU_PLANE_MEMORY,
33 RCAR_DU_PLANE_VSPD0,
34 RCAR_DU_PLANE_VSPD1,
35};
36
31struct rcar_du_plane { 37struct rcar_du_plane {
32 struct drm_plane plane; 38 struct drm_plane plane;
33 struct rcar_du_group *group; 39 struct rcar_du_group *group;
@@ -52,6 +58,7 @@ struct rcar_du_plane_state {
52 58
53 const struct rcar_du_format_info *format; 59 const struct rcar_du_format_info *format;
54 int hwindex; 60 int hwindex;
61 enum rcar_du_plane_source source;
55 62
56 unsigned int alpha; 63 unsigned int alpha;
57 unsigned int colorkey; 64 unsigned int colorkey;
@@ -64,8 +71,20 @@ to_rcar_plane_state(struct drm_plane_state *state)
64 return container_of(state, struct rcar_du_plane_state, state); 71 return container_of(state, struct rcar_du_plane_state, state);
65} 72}
66 73
74int rcar_du_atomic_check_planes(struct drm_device *dev,
75 struct drm_atomic_state *state);
76
67int rcar_du_planes_init(struct rcar_du_group *rgrp); 77int rcar_du_planes_init(struct rcar_du_group *rgrp);
68 78
69void rcar_du_plane_setup(struct rcar_du_plane *plane); 79void __rcar_du_plane_setup(struct rcar_du_group *rgrp,
80 const struct rcar_du_plane_state *state);
81
82static inline void rcar_du_plane_setup(struct rcar_du_plane *plane)
83{
84 struct rcar_du_plane_state *state =
85 to_rcar_plane_state(plane->plane.state);
86
87 return __rcar_du_plane_setup(plane->group, state);
88}
70 89
71#endif /* __RCAR_DU_PLANE_H__ */ 90#endif /* __RCAR_DU_PLANE_H__ */
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_regs.h b/drivers/gpu/drm/rcar-du/rcar_du_regs.h
index 70fcbc471ebd..d2f66068e52c 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_regs.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_regs.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * rcar_du_regs.h -- R-Car Display Unit Registers Definitions 2 * rcar_du_regs.h -- R-Car Display Unit Registers Definitions
3 * 3 *
4 * Copyright (C) 2013 Renesas Electronics Corporation 4 * Copyright (C) 2013-2015 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
@@ -16,6 +16,7 @@
16#define DU0_REG_OFFSET 0x00000 16#define DU0_REG_OFFSET 0x00000
17#define DU1_REG_OFFSET 0x30000 17#define DU1_REG_OFFSET 0x30000
18#define DU2_REG_OFFSET 0x40000 18#define DU2_REG_OFFSET 0x40000
19#define DU3_REG_OFFSET 0x70000
19 20
20/* ----------------------------------------------------------------------------- 21/* -----------------------------------------------------------------------------
21 * Display Control Registers 22 * Display Control Registers
@@ -186,7 +187,7 @@
186 187
187#define DEFR6 0x000e8 188#define DEFR6 0x000e8
188#define DEFR6_CODE (0x7778 << 16) 189#define DEFR6_CODE (0x7778 << 16)
189#define DEFR6_ODPM22_D2SMR (0 << 10) 190#define DEFR6_ODPM22_DSMR (0 << 10)
190#define DEFR6_ODPM22_DISP (2 << 10) 191#define DEFR6_ODPM22_DISP (2 << 10)
191#define DEFR6_ODPM22_CDE (3 << 10) 192#define DEFR6_ODPM22_CDE (3 << 10)
192#define DEFR6_ODPM22_MASK (3 << 10) 193#define DEFR6_ODPM22_MASK (3 << 10)
@@ -260,6 +261,21 @@
260#define DIDSR_PDCS_CLK(n, clk) (clk << ((n) * 2)) 261#define DIDSR_PDCS_CLK(n, clk) (clk << ((n) * 2))
261#define DIDSR_PDCS_MASK(n) (3 << ((n) * 2)) 262#define DIDSR_PDCS_MASK(n) (3 << ((n) * 2))
262 263
264#define DEFR10 0x20038
265#define DEFR10_CODE (0x7795 << 16)
266#define DEFR10_VSPF1_RGB (0 << 14)
267#define DEFR10_VSPF1_YC (1 << 14)
268#define DEFR10_DOCF1_RGB (0 << 12)
269#define DEFR10_DOCF1_YC (1 << 12)
270#define DEFR10_YCDF0_YCBCR444 (0 << 11)
271#define DEFR10_YCDF0_YCBCR422 (1 << 11)
272#define DEFR10_VSPF0_RGB (0 << 10)
273#define DEFR10_VSPF0_YC (1 << 10)
274#define DEFR10_DOCF0_RGB (0 << 8)
275#define DEFR10_DOCF0_YC (1 << 8)
276#define DEFR10_TSEL_H3_TCON1 (0 << 1) /* DEFR102 register only (DU2/DU3) */
277#define DEFR10_DEFE10 (1 << 0)
278
263/* ----------------------------------------------------------------------------- 279/* -----------------------------------------------------------------------------
264 * Display Timing Generation Registers 280 * Display Timing Generation Registers
265 */ 281 */
@@ -389,6 +405,7 @@
389 405
390#define PnDDCR4 0x00190 406#define PnDDCR4 0x00190
391#define PnDDCR4_CODE (0x7766 << 16) 407#define PnDDCR4_CODE (0x7766 << 16)
408#define PnDDCR4_VSPS (1 << 13)
392#define PnDDCR4_SDFS_RGB (0 << 4) 409#define PnDDCR4_SDFS_RGB (0 << 4)
393#define PnDDCR4_SDFS_YC (5 << 4) 410#define PnDDCR4_SDFS_YC (5 << 4)
394#define PnDDCR4_SDFS_MASK (7 << 4) 411#define PnDDCR4_SDFS_MASK (7 << 4)
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c b/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c
index e0a5d8f93963..9d7e5c99caf6 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c
@@ -31,12 +31,6 @@ static const struct drm_connector_helper_funcs connector_helper_funcs = {
31 .best_encoder = rcar_du_connector_best_encoder, 31 .best_encoder = rcar_du_connector_best_encoder,
32}; 32};
33 33
34static void rcar_du_vga_connector_destroy(struct drm_connector *connector)
35{
36 drm_connector_unregister(connector);
37 drm_connector_cleanup(connector);
38}
39
40static enum drm_connector_status 34static enum drm_connector_status
41rcar_du_vga_connector_detect(struct drm_connector *connector, bool force) 35rcar_du_vga_connector_detect(struct drm_connector *connector, bool force)
42{ 36{
@@ -48,7 +42,7 @@ static const struct drm_connector_funcs connector_funcs = {
48 .reset = drm_atomic_helper_connector_reset, 42 .reset = drm_atomic_helper_connector_reset,
49 .detect = rcar_du_vga_connector_detect, 43 .detect = rcar_du_vga_connector_detect,
50 .fill_modes = drm_helper_probe_single_connector_modes, 44 .fill_modes = drm_helper_probe_single_connector_modes,
51 .destroy = rcar_du_vga_connector_destroy, 45 .destroy = drm_connector_cleanup,
52 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, 46 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
53 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, 47 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
54}; 48};
@@ -76,9 +70,6 @@ int rcar_du_vga_connector_init(struct rcar_du_device *rcdu,
76 return ret; 70 return ret;
77 71
78 drm_connector_helper_add(connector, &connector_helper_funcs); 72 drm_connector_helper_add(connector, &connector_helper_funcs);
79 ret = drm_connector_register(connector);
80 if (ret < 0)
81 return ret;
82 73
83 connector->dpms = DRM_MODE_DPMS_OFF; 74 connector->dpms = DRM_MODE_DPMS_OFF;
84 drm_object_property_set_value(&connector->base, 75 drm_object_property_set_value(&connector->base,
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
new file mode 100644
index 000000000000..de7ef041182b
--- /dev/null
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
@@ -0,0 +1,384 @@
1/*
2 * rcar_du_vsp.h -- R-Car Display Unit VSP-Based Compositor
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 <drm/drmP.h>
15#include <drm/drm_atomic_helper.h>
16#include <drm/drm_crtc.h>
17#include <drm/drm_crtc_helper.h>
18#include <drm/drm_fb_cma_helper.h>
19#include <drm/drm_gem_cma_helper.h>
20#include <drm/drm_plane_helper.h>
21
22#include <linux/of_platform.h>
23#include <linux/videodev2.h>
24
25#include <media/vsp1.h>
26
27#include "rcar_du_drv.h"
28#include "rcar_du_kms.h"
29#include "rcar_du_vsp.h"
30
31void rcar_du_vsp_enable(struct rcar_du_crtc *crtc)
32{
33 const struct drm_display_mode *mode = &crtc->crtc.state->adjusted_mode;
34 struct rcar_du_device *rcdu = crtc->group->dev;
35 struct rcar_du_plane_state state = {
36 .state = {
37 .crtc = &crtc->crtc,
38 .crtc_x = 0,
39 .crtc_y = 0,
40 .crtc_w = mode->hdisplay,
41 .crtc_h = mode->vdisplay,
42 .src_x = 0,
43 .src_y = 0,
44 .src_w = mode->hdisplay << 16,
45 .src_h = mode->vdisplay << 16,
46 },
47 .format = rcar_du_format_info(DRM_FORMAT_ARGB8888),
48 .source = RCAR_DU_PLANE_VSPD1,
49 .alpha = 255,
50 .colorkey = 0,
51 .zpos = 0,
52 };
53
54 if (rcdu->info->gen >= 3)
55 state.hwindex = (crtc->index % 2) ? 2 : 0;
56 else
57 state.hwindex = crtc->index % 2;
58
59 __rcar_du_plane_setup(crtc->group, &state);
60
61 /* Ensure that the plane source configuration takes effect by requesting
62 * a restart of the group. See rcar_du_plane_atomic_update() for a more
63 * detailed explanation.
64 *
65 * TODO: Check whether this is still needed on Gen3.
66 */
67 crtc->group->need_restart = true;
68
69 vsp1_du_setup_lif(crtc->vsp->vsp, mode->hdisplay, mode->vdisplay);
70}
71
72void rcar_du_vsp_disable(struct rcar_du_crtc *crtc)
73{
74 vsp1_du_setup_lif(crtc->vsp->vsp, 0, 0);
75}
76
77void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc)
78{
79 vsp1_du_atomic_begin(crtc->vsp->vsp);
80}
81
82void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc)
83{
84 vsp1_du_atomic_flush(crtc->vsp->vsp);
85}
86
87/* Keep the two tables in sync. */
88static const u32 formats_kms[] = {
89 DRM_FORMAT_RGB332,
90 DRM_FORMAT_ARGB4444,
91 DRM_FORMAT_XRGB4444,
92 DRM_FORMAT_ARGB1555,
93 DRM_FORMAT_XRGB1555,
94 DRM_FORMAT_RGB565,
95 DRM_FORMAT_BGR888,
96 DRM_FORMAT_RGB888,
97 DRM_FORMAT_BGRA8888,
98 DRM_FORMAT_BGRX8888,
99 DRM_FORMAT_ARGB8888,
100 DRM_FORMAT_XRGB8888,
101 DRM_FORMAT_UYVY,
102 DRM_FORMAT_VYUY,
103 DRM_FORMAT_YUYV,
104 DRM_FORMAT_YVYU,
105 DRM_FORMAT_NV12,
106 DRM_FORMAT_NV21,
107 DRM_FORMAT_NV16,
108 DRM_FORMAT_NV61,
109 DRM_FORMAT_YUV420,
110 DRM_FORMAT_YVU420,
111 DRM_FORMAT_YUV422,
112 DRM_FORMAT_YVU422,
113 DRM_FORMAT_YUV444,
114 DRM_FORMAT_YVU444,
115};
116
117static const u32 formats_v4l2[] = {
118 V4L2_PIX_FMT_RGB332,
119 V4L2_PIX_FMT_ARGB444,
120 V4L2_PIX_FMT_XRGB444,
121 V4L2_PIX_FMT_ARGB555,
122 V4L2_PIX_FMT_XRGB555,
123 V4L2_PIX_FMT_RGB565,
124 V4L2_PIX_FMT_RGB24,
125 V4L2_PIX_FMT_BGR24,
126 V4L2_PIX_FMT_ARGB32,
127 V4L2_PIX_FMT_XRGB32,
128 V4L2_PIX_FMT_ABGR32,
129 V4L2_PIX_FMT_XBGR32,
130 V4L2_PIX_FMT_UYVY,
131 V4L2_PIX_FMT_VYUY,
132 V4L2_PIX_FMT_YUYV,
133 V4L2_PIX_FMT_YVYU,
134 V4L2_PIX_FMT_NV12M,
135 V4L2_PIX_FMT_NV21M,
136 V4L2_PIX_FMT_NV16M,
137 V4L2_PIX_FMT_NV61M,
138 V4L2_PIX_FMT_YUV420M,
139 V4L2_PIX_FMT_YVU420M,
140 V4L2_PIX_FMT_YUV422M,
141 V4L2_PIX_FMT_YVU422M,
142 V4L2_PIX_FMT_YUV444M,
143 V4L2_PIX_FMT_YVU444M,
144};
145
146static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane)
147{
148 struct rcar_du_vsp_plane_state *state =
149 to_rcar_vsp_plane_state(plane->plane.state);
150 struct drm_framebuffer *fb = plane->plane.state->fb;
151 struct v4l2_rect src;
152 struct v4l2_rect dst;
153 dma_addr_t paddr[2] = { 0, };
154 u32 pixelformat = 0;
155 unsigned int i;
156
157 src.left = state->state.src_x >> 16;
158 src.top = state->state.src_y >> 16;
159 src.width = state->state.src_w >> 16;
160 src.height = state->state.src_h >> 16;
161
162 dst.left = state->state.crtc_x;
163 dst.top = state->state.crtc_y;
164 dst.width = state->state.crtc_w;
165 dst.height = state->state.crtc_h;
166
167 for (i = 0; i < state->format->planes; ++i) {
168 struct drm_gem_cma_object *gem;
169
170 gem = drm_fb_cma_get_gem_obj(fb, i);
171 paddr[i] = gem->paddr + fb->offsets[i];
172 }
173
174 for (i = 0; i < ARRAY_SIZE(formats_kms); ++i) {
175 if (formats_kms[i] == state->format->fourcc) {
176 pixelformat = formats_v4l2[i];
177 break;
178 }
179 }
180
181 WARN_ON(!pixelformat);
182
183 vsp1_du_atomic_update(plane->vsp->vsp, plane->index, pixelformat,
184 fb->pitches[0], paddr, &src, &dst);
185}
186
187static int rcar_du_vsp_plane_atomic_check(struct drm_plane *plane,
188 struct drm_plane_state *state)
189{
190 struct rcar_du_vsp_plane_state *rstate = to_rcar_vsp_plane_state(state);
191 struct rcar_du_vsp_plane *rplane = to_rcar_vsp_plane(plane);
192 struct rcar_du_device *rcdu = rplane->vsp->dev;
193
194 if (!state->fb || !state->crtc) {
195 rstate->format = NULL;
196 return 0;
197 }
198
199 if (state->src_w >> 16 != state->crtc_w ||
200 state->src_h >> 16 != state->crtc_h) {
201 dev_dbg(rcdu->dev, "%s: scaling not supported\n", __func__);
202 return -EINVAL;
203 }
204
205 rstate->format = rcar_du_format_info(state->fb->pixel_format);
206 if (rstate->format == NULL) {
207 dev_dbg(rcdu->dev, "%s: unsupported format %08x\n", __func__,
208 state->fb->pixel_format);
209 return -EINVAL;
210 }
211
212 return 0;
213}
214
215static void rcar_du_vsp_plane_atomic_update(struct drm_plane *plane,
216 struct drm_plane_state *old_state)
217{
218 struct rcar_du_vsp_plane *rplane = to_rcar_vsp_plane(plane);
219
220 if (plane->state->crtc)
221 rcar_du_vsp_plane_setup(rplane);
222 else
223 vsp1_du_atomic_update(rplane->vsp->vsp, rplane->index, 0, 0, 0,
224 NULL, NULL);
225}
226
227static const struct drm_plane_helper_funcs rcar_du_vsp_plane_helper_funcs = {
228 .atomic_check = rcar_du_vsp_plane_atomic_check,
229 .atomic_update = rcar_du_vsp_plane_atomic_update,
230};
231
232static struct drm_plane_state *
233rcar_du_vsp_plane_atomic_duplicate_state(struct drm_plane *plane)
234{
235 struct rcar_du_vsp_plane_state *state;
236 struct rcar_du_vsp_plane_state *copy;
237
238 if (WARN_ON(!plane->state))
239 return NULL;
240
241 state = to_rcar_vsp_plane_state(plane->state);
242 copy = kmemdup(state, sizeof(*state), GFP_KERNEL);
243 if (copy == NULL)
244 return NULL;
245
246 __drm_atomic_helper_plane_duplicate_state(plane, &copy->state);
247
248 return &copy->state;
249}
250
251static void rcar_du_vsp_plane_atomic_destroy_state(struct drm_plane *plane,
252 struct drm_plane_state *state)
253{
254 __drm_atomic_helper_plane_destroy_state(plane, state);
255 kfree(to_rcar_vsp_plane_state(state));
256}
257
258static void rcar_du_vsp_plane_reset(struct drm_plane *plane)
259{
260 struct rcar_du_vsp_plane_state *state;
261
262 if (plane->state) {
263 rcar_du_vsp_plane_atomic_destroy_state(plane, plane->state);
264 plane->state = NULL;
265 }
266
267 state = kzalloc(sizeof(*state), GFP_KERNEL);
268 if (state == NULL)
269 return;
270
271 state->alpha = 255;
272
273 plane->state = &state->state;
274 plane->state->plane = plane;
275}
276
277static int rcar_du_vsp_plane_atomic_set_property(struct drm_plane *plane,
278 struct drm_plane_state *state, struct drm_property *property,
279 uint64_t val)
280{
281 struct rcar_du_vsp_plane_state *rstate = to_rcar_vsp_plane_state(state);
282 struct rcar_du_device *rcdu = to_rcar_vsp_plane(plane)->vsp->dev;
283
284 if (property == rcdu->props.alpha)
285 rstate->alpha = val;
286 else
287 return -EINVAL;
288
289 return 0;
290}
291
292static int rcar_du_vsp_plane_atomic_get_property(struct drm_plane *plane,
293 const struct drm_plane_state *state, struct drm_property *property,
294 uint64_t *val)
295{
296 const struct rcar_du_vsp_plane_state *rstate =
297 container_of(state, const struct rcar_du_vsp_plane_state, state);
298 struct rcar_du_device *rcdu = to_rcar_vsp_plane(plane)->vsp->dev;
299
300 if (property == rcdu->props.alpha)
301 *val = rstate->alpha;
302 else
303 return -EINVAL;
304
305 return 0;
306}
307
308static const struct drm_plane_funcs rcar_du_vsp_plane_funcs = {
309 .update_plane = drm_atomic_helper_update_plane,
310 .disable_plane = drm_atomic_helper_disable_plane,
311 .reset = rcar_du_vsp_plane_reset,
312 .set_property = drm_atomic_helper_plane_set_property,
313 .destroy = drm_plane_cleanup,
314 .atomic_duplicate_state = rcar_du_vsp_plane_atomic_duplicate_state,
315 .atomic_destroy_state = rcar_du_vsp_plane_atomic_destroy_state,
316 .atomic_set_property = rcar_du_vsp_plane_atomic_set_property,
317 .atomic_get_property = rcar_du_vsp_plane_atomic_get_property,
318};
319
320int rcar_du_vsp_init(struct rcar_du_vsp *vsp)
321{
322 struct rcar_du_device *rcdu = vsp->dev;
323 struct platform_device *pdev;
324 struct device_node *np;
325 unsigned int i;
326 int ret;
327
328 /* Find the VSP device and initialize it. */
329 np = of_parse_phandle(rcdu->dev->of_node, "vsps", vsp->index);
330 if (!np) {
331 dev_err(rcdu->dev, "vsps node not found\n");
332 return -ENXIO;
333 }
334
335 pdev = of_find_device_by_node(np);
336 of_node_put(np);
337 if (!pdev)
338 return -ENXIO;
339
340 vsp->vsp = &pdev->dev;
341
342 ret = vsp1_du_init(vsp->vsp);
343 if (ret < 0)
344 return ret;
345
346 /* The VSP2D (Gen3) has 5 RPFs, but the VSP1D (Gen2) is limited to
347 * 4 RPFs.
348 */
349 vsp->num_planes = rcdu->info->gen >= 3 ? 5 : 4;
350
351 vsp->planes = devm_kcalloc(rcdu->dev, vsp->num_planes,
352 sizeof(*vsp->planes), GFP_KERNEL);
353 if (!vsp->planes)
354 return -ENOMEM;
355
356 for (i = 0; i < vsp->num_planes; ++i) {
357 enum drm_plane_type type = i ? DRM_PLANE_TYPE_OVERLAY
358 : DRM_PLANE_TYPE_PRIMARY;
359 struct rcar_du_vsp_plane *plane = &vsp->planes[i];
360
361 plane->vsp = vsp;
362 plane->index = i;
363
364 ret = drm_universal_plane_init(rcdu->ddev, &plane->plane,
365 1 << vsp->index,
366 &rcar_du_vsp_plane_funcs,
367 formats_kms,
368 ARRAY_SIZE(formats_kms), type,
369 NULL);
370 if (ret < 0)
371 return ret;
372
373 drm_plane_helper_add(&plane->plane,
374 &rcar_du_vsp_plane_helper_funcs);
375
376 if (type == DRM_PLANE_TYPE_PRIMARY)
377 continue;
378
379 drm_object_attach_property(&plane->plane.base,
380 rcdu->props.alpha, 255);
381 }
382
383 return 0;
384}
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.h b/drivers/gpu/drm/rcar-du/rcar_du_vsp.h
new file mode 100644
index 000000000000..df3bf3805c69
--- /dev/null
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.h
@@ -0,0 +1,76 @@
1/*
2 * rcar_du_vsp.h -- R-Car Display Unit VSP-Based Compositor
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#ifndef __RCAR_DU_VSP_H__
15#define __RCAR_DU_VSP_H__
16
17#include <drm/drmP.h>
18#include <drm/drm_crtc.h>
19
20struct rcar_du_format_info;
21struct rcar_du_vsp;
22
23struct rcar_du_vsp_plane {
24 struct drm_plane plane;
25 struct rcar_du_vsp *vsp;
26 unsigned int index;
27};
28
29struct rcar_du_vsp {
30 unsigned int index;
31 struct device *vsp;
32 struct rcar_du_device *dev;
33 struct rcar_du_vsp_plane *planes;
34 unsigned int num_planes;
35};
36
37static inline struct rcar_du_vsp_plane *to_rcar_vsp_plane(struct drm_plane *p)
38{
39 return container_of(p, struct rcar_du_vsp_plane, plane);
40}
41
42/**
43 * struct rcar_du_vsp_plane_state - Driver-specific plane state
44 * @state: base DRM plane state
45 * @format: information about the pixel format used by the plane
46 * @alpha: value of the plane alpha property
47 */
48struct rcar_du_vsp_plane_state {
49 struct drm_plane_state state;
50
51 const struct rcar_du_format_info *format;
52
53 unsigned int alpha;
54};
55
56static inline struct rcar_du_vsp_plane_state *
57to_rcar_vsp_plane_state(struct drm_plane_state *state)
58{
59 return container_of(state, struct rcar_du_vsp_plane_state, state);
60}
61
62#ifdef CONFIG_DRM_RCAR_VSP
63int rcar_du_vsp_init(struct rcar_du_vsp *vsp);
64void rcar_du_vsp_enable(struct rcar_du_crtc *crtc);
65void rcar_du_vsp_disable(struct rcar_du_crtc *crtc);
66void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc);
67void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc);
68#else
69static inline int rcar_du_vsp_init(struct rcar_du_vsp *vsp) { return 0; };
70static inline void rcar_du_vsp_enable(struct rcar_du_crtc *crtc) { };
71static inline void rcar_du_vsp_disable(struct rcar_du_crtc *crtc) { };
72static inline void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc) { };
73static inline void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc) { };
74#endif
75
76#endif /* __RCAR_DU_VSP_H__ */
diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds_regs.h b/drivers/gpu/drm/rcar-du/rcar_lvds_regs.h
index 77cf9289ab65..d7d294ba2dbe 100644
--- a/drivers/gpu/drm/rcar-du/rcar_lvds_regs.h
+++ b/drivers/gpu/drm/rcar-du/rcar_lvds_regs.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * rcar_lvds_regs.h -- R-Car LVDS Interface Registers Definitions 2 * rcar_lvds_regs.h -- R-Car LVDS Interface Registers Definitions
3 * 3 *
4 * Copyright (C) 2013 Renesas Electronics Corporation 4 * Copyright (C) 2013-2015 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
@@ -15,28 +15,38 @@
15 15
16#define LVDCR0 0x0000 16#define LVDCR0 0x0000
17#define LVDCR0_DUSEL (1 << 15) 17#define LVDCR0_DUSEL (1 << 15)
18#define LVDCR0_DMD (1 << 12) 18#define LVDCR0_DMD (1 << 12) /* Gen2 only */
19#define LVDCR0_LVMD_MASK (0xf << 8) 19#define LVDCR0_LVMD_MASK (0xf << 8)
20#define LVDCR0_LVMD_SHIFT 8 20#define LVDCR0_LVMD_SHIFT 8
21#define LVDCR0_PLLEN (1 << 4) 21#define LVDCR0_PLLON (1 << 4)
22#define LVDCR0_BEN (1 << 2) 22#define LVDCR0_PWD (1 << 2) /* Gen3 only */
23#define LVDCR0_LVEN (1 << 1) 23#define LVDCR0_BEN (1 << 2) /* Gen2 only */
24#define LVDCR0_LVEN (1 << 1) /* Gen2 only */
24#define LVDCR0_LVRES (1 << 0) 25#define LVDCR0_LVRES (1 << 0)
25 26
26#define LVDCR1 0x0004 27#define LVDCR1 0x0004
27#define LVDCR1_CKSEL (1 << 15) 28#define LVDCR1_CKSEL (1 << 15) /* Gen2 only */
28#define LVDCR1_CHSTBY(n) (3 << (2 + (n) * 2)) 29#define LVDCR1_CHSTBY_GEN2(n) (3 << (2 + (n) * 2)) /* Gen2 only */
29#define LVDCR1_CLKSTBY (3 << 0) 30#define LVDCR1_CHSTBY_GEN3(n) (1 << (2 + (n) * 2)) /* Gen3 only */
31#define LVDCR1_CLKSTBY_GEN2 (3 << 0) /* Gen2 only */
32#define LVDCR1_CLKSTBY_GEN3 (1 << 0) /* Gen3 only */
30 33
31#define LVDPLLCR 0x0008 34#define LVDPLLCR 0x0008
32#define LVDPLLCR_CEEN (1 << 14) 35#define LVDPLLCR_CEEN (1 << 14)
33#define LVDPLLCR_FBEN (1 << 13) 36#define LVDPLLCR_FBEN (1 << 13)
34#define LVDPLLCR_COSEL (1 << 12) 37#define LVDPLLCR_COSEL (1 << 12)
38/* Gen2 */
35#define LVDPLLCR_PLLDLYCNT_150M (0x1bf << 0) 39#define LVDPLLCR_PLLDLYCNT_150M (0x1bf << 0)
36#define LVDPLLCR_PLLDLYCNT_121M (0x22c << 0) 40#define LVDPLLCR_PLLDLYCNT_121M (0x22c << 0)
37#define LVDPLLCR_PLLDLYCNT_60M (0x77b << 0) 41#define LVDPLLCR_PLLDLYCNT_60M (0x77b << 0)
38#define LVDPLLCR_PLLDLYCNT_38M (0x69a << 0) 42#define LVDPLLCR_PLLDLYCNT_38M (0x69a << 0)
39#define LVDPLLCR_PLLDLYCNT_MASK (0x7ff << 0) 43#define LVDPLLCR_PLLDLYCNT_MASK (0x7ff << 0)
44/* Gen3 */
45#define LVDPLLCR_PLLDIVCNT_42M (0x014cb << 0)
46#define LVDPLLCR_PLLDIVCNT_85M (0x00a45 << 0)
47#define LVDPLLCR_PLLDIVCNT_128M (0x006c3 << 0)
48#define LVDPLLCR_PLLDIVCNT_148M (0x046c1 << 0)
49#define LVDPLLCR_PLLDIVCNT_MASK (0x7ffff << 0)
40 50
41#define LVDCTRCR 0x000c 51#define LVDCTRCR 0x000c
42#define LVDCTRCR_CTR3SEL_ZERO (0 << 12) 52#define LVDCTRCR_CTR3SEL_ZERO (0 << 12)
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..dbdbb84294c5 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
@@ -247,6 +248,7 @@
247#define USB_PID_TECHNOTREND_CONNECT_CT3650 0x300d 248#define USB_PID_TECHNOTREND_CONNECT_CT3650 0x300d
248#define USB_PID_TECHNOTREND_CONNECT_S2_4600 0x3011 249#define USB_PID_TECHNOTREND_CONNECT_S2_4600 0x3011
249#define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI 0x3012 250#define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI 0x3012
251#define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI_2 0x3015
250#define USB_PID_TECHNOTREND_TVSTICK_CT2_4400 0x3014 252#define USB_PID_TECHNOTREND_TVSTICK_CT2_4400 0x3014
251#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a 253#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a
252#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081 254#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081
@@ -255,6 +257,10 @@
255#define USB_PID_TERRATEC_CINERGY_T_EXPRESS 0x0062 257#define USB_PID_TERRATEC_CINERGY_T_EXPRESS 0x0062
256#define USB_PID_TERRATEC_CINERGY_T_XXS 0x0078 258#define USB_PID_TERRATEC_CINERGY_T_XXS 0x0078
257#define USB_PID_TERRATEC_CINERGY_T_XXS_2 0x00ab 259#define USB_PID_TERRATEC_CINERGY_T_XXS_2 0x00ab
260#define USB_PID_TERRATEC_CINERGY_S2_R1 0x00a8
261#define USB_PID_TERRATEC_CINERGY_S2_R2 0x00b0
262#define USB_PID_TERRATEC_CINERGY_S2_R3 0x0102
263#define USB_PID_TERRATEC_CINERGY_S2_R4 0x0105
258#define USB_PID_TERRATEC_H7 0x10b4 264#define USB_PID_TERRATEC_H7 0x10b4
259#define USB_PID_TERRATEC_H7_2 0x10a3 265#define USB_PID_TERRATEC_H7_2 0x10a3
260#define USB_PID_TERRATEC_H7_3 0x10a5 266#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..4c35eb47472b 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -140,9 +140,12 @@ struct dvb_frontend_private {
140 140
141static void dvb_frontend_wakeup(struct dvb_frontend *fe); 141static void dvb_frontend_wakeup(struct dvb_frontend *fe);
142static int dtv_get_frontend(struct dvb_frontend *fe, 142static int dtv_get_frontend(struct dvb_frontend *fe,
143 struct dtv_frontend_properties *c,
143 struct dvb_frontend_parameters *p_out); 144 struct dvb_frontend_parameters *p_out);
144static int dtv_property_legacy_params_sync(struct dvb_frontend *fe, 145static int
145 struct dvb_frontend_parameters *p); 146dtv_property_legacy_params_sync(struct dvb_frontend *fe,
147 const struct dtv_frontend_properties *c,
148 struct dvb_frontend_parameters *p);
146 149
147static bool has_get_frontend(struct dvb_frontend *fe) 150static bool has_get_frontend(struct dvb_frontend *fe)
148{ 151{
@@ -202,6 +205,7 @@ static void dvb_frontend_add_event(struct dvb_frontend *fe,
202 enum fe_status status) 205 enum fe_status status)
203{ 206{
204 struct dvb_frontend_private *fepriv = fe->frontend_priv; 207 struct dvb_frontend_private *fepriv = fe->frontend_priv;
208 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
205 struct dvb_fe_events *events = &fepriv->events; 209 struct dvb_fe_events *events = &fepriv->events;
206 struct dvb_frontend_event *e; 210 struct dvb_frontend_event *e;
207 int wp; 211 int wp;
@@ -209,7 +213,7 @@ static void dvb_frontend_add_event(struct dvb_frontend *fe,
209 dev_dbg(fe->dvb->device, "%s:\n", __func__); 213 dev_dbg(fe->dvb->device, "%s:\n", __func__);
210 214
211 if ((status & FE_HAS_LOCK) && has_get_frontend(fe)) 215 if ((status & FE_HAS_LOCK) && has_get_frontend(fe))
212 dtv_get_frontend(fe, &fepriv->parameters_out); 216 dtv_get_frontend(fe, c, &fepriv->parameters_out);
213 217
214 mutex_lock(&events->mtx); 218 mutex_lock(&events->mtx);
215 219
@@ -687,6 +691,7 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe)
687static int dvb_frontend_thread(void *data) 691static int dvb_frontend_thread(void *data)
688{ 692{
689 struct dvb_frontend *fe = data; 693 struct dvb_frontend *fe = data;
694 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
690 struct dvb_frontend_private *fepriv = fe->frontend_priv; 695 struct dvb_frontend_private *fepriv = fe->frontend_priv;
691 enum fe_status s; 696 enum fe_status s;
692 enum dvbfe_algo algo; 697 enum dvbfe_algo algo;
@@ -807,7 +812,7 @@ restart:
807 fepriv->algo_status |= DVBFE_ALGO_SEARCH_AGAIN; 812 fepriv->algo_status |= DVBFE_ALGO_SEARCH_AGAIN;
808 fepriv->delay = HZ / 2; 813 fepriv->delay = HZ / 2;
809 } 814 }
810 dtv_property_legacy_params_sync(fe, &fepriv->parameters_out); 815 dtv_property_legacy_params_sync(fe, c, &fepriv->parameters_out);
811 fe->ops.read_status(fe, &s); 816 fe->ops.read_status(fe, &s);
812 if (s != fepriv->status) { 817 if (s != fepriv->status) {
813 dvb_frontend_add_event(fe, s); /* update event list */ 818 dvb_frontend_add_event(fe, s); /* update event list */
@@ -899,10 +904,10 @@ void dvb_frontend_sleep_until(ktime_t *waketime, u32 add_usec)
899 s32 delta; 904 s32 delta;
900 905
901 *waketime = ktime_add_us(*waketime, add_usec); 906 *waketime = ktime_add_us(*waketime, add_usec);
902 delta = ktime_us_delta(ktime_get_real(), *waketime); 907 delta = ktime_us_delta(ktime_get_boottime(), *waketime);
903 if (delta > 2500) { 908 if (delta > 2500) {
904 msleep((delta - 1500) / 1000); 909 msleep((delta - 1500) / 1000);
905 delta = ktime_us_delta(ktime_get_real(), *waketime); 910 delta = ktime_us_delta(ktime_get_boottime(), *waketime);
906 } 911 }
907 if (delta > 0) 912 if (delta > 0)
908 udelay(delta); 913 udelay(delta);
@@ -1162,18 +1167,24 @@ static struct dtv_cmds_h dtv_cmds[DTV_MAX_COMMAND + 1] = {
1162 _DTV_CMD(DTV_STAT_TOTAL_BLOCK_COUNT, 0, 0), 1167 _DTV_CMD(DTV_STAT_TOTAL_BLOCK_COUNT, 0, 0),
1163}; 1168};
1164 1169
1165static void dtv_property_dump(struct dvb_frontend *fe, struct dtv_property *tvp) 1170static void dtv_property_dump(struct dvb_frontend *fe,
1171 bool is_set,
1172 struct dtv_property *tvp)
1166{ 1173{
1167 int i; 1174 int i;
1168 1175
1169 if (tvp->cmd <= 0 || tvp->cmd > DTV_MAX_COMMAND) { 1176 if (tvp->cmd <= 0 || tvp->cmd > DTV_MAX_COMMAND) {
1170 dev_warn(fe->dvb->device, "%s: tvp.cmd = 0x%08x undefined\n", 1177 dev_warn(fe->dvb->device, "%s: %s tvp.cmd = 0x%08x undefined\n",
1171 __func__, tvp->cmd); 1178 __func__,
1179 is_set ? "SET" : "GET",
1180 tvp->cmd);
1172 return; 1181 return;
1173 } 1182 }
1174 1183
1175 dev_dbg(fe->dvb->device, "%s: tvp.cmd = 0x%08x (%s)\n", __func__, 1184 dev_dbg(fe->dvb->device, "%s: %s tvp.cmd = 0x%08x (%s)\n", __func__,
1176 tvp->cmd, dtv_cmds[tvp->cmd].name); 1185 is_set ? "SET" : "GET",
1186 tvp->cmd,
1187 dtv_cmds[tvp->cmd].name);
1177 1188
1178 if (dtv_cmds[tvp->cmd].buffer) { 1189 if (dtv_cmds[tvp->cmd].buffer) {
1179 dev_dbg(fe->dvb->device, "%s: tvp.u.buffer.len = 0x%02x\n", 1190 dev_dbg(fe->dvb->device, "%s: tvp.u.buffer.len = 0x%02x\n",
@@ -1268,11 +1279,11 @@ static int dtv_property_cache_sync(struct dvb_frontend *fe,
1268/* Ensure the cached values are set correctly in the frontend 1279/* Ensure the cached values are set correctly in the frontend
1269 * legacy tuning structures, for the advanced tuning API. 1280 * legacy tuning structures, for the advanced tuning API.
1270 */ 1281 */
1271static int dtv_property_legacy_params_sync(struct dvb_frontend *fe, 1282static int
1272 struct dvb_frontend_parameters *p) 1283dtv_property_legacy_params_sync(struct dvb_frontend *fe,
1284 const struct dtv_frontend_properties *c,
1285 struct dvb_frontend_parameters *p)
1273{ 1286{
1274 const struct dtv_frontend_properties *c = &fe->dtv_property_cache;
1275
1276 p->frequency = c->frequency; 1287 p->frequency = c->frequency;
1277 p->inversion = c->inversion; 1288 p->inversion = c->inversion;
1278 1289
@@ -1344,16 +1355,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. 1355 * If p_out is not null, it will update the DVBv3 params pointed by it.
1345 */ 1356 */
1346static int dtv_get_frontend(struct dvb_frontend *fe, 1357static int dtv_get_frontend(struct dvb_frontend *fe,
1358 struct dtv_frontend_properties *c,
1347 struct dvb_frontend_parameters *p_out) 1359 struct dvb_frontend_parameters *p_out)
1348{ 1360{
1349 int r; 1361 int r;
1350 1362
1351 if (fe->ops.get_frontend) { 1363 if (fe->ops.get_frontend) {
1352 r = fe->ops.get_frontend(fe); 1364 r = fe->ops.get_frontend(fe, c);
1353 if (unlikely(r < 0)) 1365 if (unlikely(r < 0))
1354 return r; 1366 return r;
1355 if (p_out) 1367 if (p_out)
1356 dtv_property_legacy_params_sync(fe, p_out); 1368 dtv_property_legacy_params_sync(fe, c, p_out);
1357 return 0; 1369 return 0;
1358 } 1370 }
1359 1371
@@ -1589,7 +1601,7 @@ static int dtv_property_process_get(struct dvb_frontend *fe,
1589 return r; 1601 return r;
1590 } 1602 }
1591 1603
1592 dtv_property_dump(fe, tvp); 1604 dtv_property_dump(fe, false, tvp);
1593 1605
1594 return 0; 1606 return 0;
1595} 1607}
@@ -1830,6 +1842,8 @@ static int dtv_property_process_set(struct dvb_frontend *fe,
1830 return r; 1842 return r;
1831 } 1843 }
1832 1844
1845 dtv_property_dump(fe, true, tvp);
1846
1833 switch(tvp->cmd) { 1847 switch(tvp->cmd) {
1834 case DTV_CLEAR: 1848 case DTV_CLEAR:
1835 /* 1849 /*
@@ -2073,6 +2087,8 @@ static int dvb_frontend_ioctl_properties(struct file *file,
2073 dev_dbg(fe->dvb->device, "%s: Property cache is full, tuning\n", __func__); 2087 dev_dbg(fe->dvb->device, "%s: Property cache is full, tuning\n", __func__);
2074 2088
2075 } else if (cmd == FE_GET_PROPERTY) { 2089 } else if (cmd == FE_GET_PROPERTY) {
2090 struct dtv_frontend_properties getp = fe->dtv_property_cache;
2091
2076 dev_dbg(fe->dvb->device, "%s: properties.num = %d\n", __func__, tvps->num); 2092 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); 2093 dev_dbg(fe->dvb->device, "%s: properties.props = %p\n", __func__, tvps->props);
2078 2094
@@ -2094,17 +2110,18 @@ static int dvb_frontend_ioctl_properties(struct file *file,
2094 } 2110 }
2095 2111
2096 /* 2112 /*
2097 * Fills the cache out struct with the cache contents, plus 2113 * Let's use our own copy of property cache, in order to
2098 * the data retrieved from get_frontend, if the frontend 2114 * avoid mangling with DTV zigzag logic, as drivers might
2099 * is not idle. Otherwise, returns the cached content 2115 * return crap, if they don't check if the data is available
2116 * before updating the properties cache.
2100 */ 2117 */
2101 if (fepriv->state != FESTATE_IDLE) { 2118 if (fepriv->state != FESTATE_IDLE) {
2102 err = dtv_get_frontend(fe, NULL); 2119 err = dtv_get_frontend(fe, &getp, NULL);
2103 if (err < 0) 2120 if (err < 0)
2104 goto out; 2121 goto out;
2105 } 2122 }
2106 for (i = 0; i < tvps->num; i++) { 2123 for (i = 0; i < tvps->num; i++) {
2107 err = dtv_property_process_get(fe, c, tvp + i, file); 2124 err = dtv_property_process_get(fe, &getp, tvp + i, file);
2108 if (err < 0) 2125 if (err < 0)
2109 goto out; 2126 goto out;
2110 (tvp + i)->result = err; 2127 (tvp + i)->result = err;
@@ -2139,7 +2156,7 @@ static int dtv_set_frontend(struct dvb_frontend *fe)
2139 * the user. FE_SET_FRONTEND triggers an initial frontend event 2156 * the user. FE_SET_FRONTEND triggers an initial frontend event
2140 * with status = 0, which copies output parameters to userspace. 2157 * with status = 0, which copies output parameters to userspace.
2141 */ 2158 */
2142 dtv_property_legacy_params_sync(fe, &fepriv->parameters_out); 2159 dtv_property_legacy_params_sync(fe, c, &fepriv->parameters_out);
2143 2160
2144 /* 2161 /*
2145 * Be sure that the bandwidth will be filled for all 2162 * Be sure that the bandwidth will be filled for all
@@ -2451,7 +2468,7 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
2451 u8 last = 1; 2468 u8 last = 1;
2452 if (dvb_frontend_debug) 2469 if (dvb_frontend_debug)
2453 printk("%s switch command: 0x%04lx\n", __func__, swcmd); 2470 printk("%s switch command: 0x%04lx\n", __func__, swcmd);
2454 nexttime = ktime_get_real(); 2471 nexttime = ktime_get_boottime();
2455 if (dvb_frontend_debug) 2472 if (dvb_frontend_debug)
2456 tv[0] = nexttime; 2473 tv[0] = nexttime;
2457 /* before sending a command, initialize by sending 2474 /* before sending a command, initialize by sending
@@ -2462,7 +2479,7 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
2462 2479
2463 for (i = 0; i < 9; i++) { 2480 for (i = 0; i < 9; i++) {
2464 if (dvb_frontend_debug) 2481 if (dvb_frontend_debug)
2465 tv[i+1] = ktime_get_real(); 2482 tv[i+1] = ktime_get_boottime();
2466 if ((swcmd & 0x01) != last) { 2483 if ((swcmd & 0x01) != last) {
2467 /* set voltage to (last ? 13V : 18V) */ 2484 /* set voltage to (last ? 13V : 18V) */
2468 fe->ops.set_voltage(fe, (last) ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18); 2485 fe->ops.set_voltage(fe, (last) ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18);
@@ -2509,10 +2526,18 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
2509 err = dvb_frontend_get_event (fe, parg, file->f_flags); 2526 err = dvb_frontend_get_event (fe, parg, file->f_flags);
2510 break; 2527 break;
2511 2528
2512 case FE_GET_FRONTEND: 2529 case FE_GET_FRONTEND: {
2513 err = dtv_get_frontend(fe, parg); 2530 struct dtv_frontend_properties getp = fe->dtv_property_cache;
2514 break;
2515 2531
2532 /*
2533 * Let's use our own copy of property cache, in order to
2534 * avoid mangling with DTV zigzag logic, as drivers might
2535 * return crap, if they don't check if the data is available
2536 * before updating the properties cache.
2537 */
2538 err = dtv_get_frontend(fe, &getp, parg);
2539 break;
2540 }
2516 case FE_SET_FRONTEND_TUNE_MODE: 2541 case FE_SET_FRONTEND_TUNE_MODE:
2517 fepriv->tune_mode_flags = (unsigned long) parg; 2542 fepriv->tune_mode_flags = (unsigned long) parg;
2518 err = 0; 2543 err = 0;
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..1b9732ee0a4f 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);
@@ -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/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_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/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..6ccbd86c9490 100644
--- a/drivers/media/dvb-frontends/cx24120.c
+++ b/drivers/media/dvb-frontends/cx24120.c
@@ -1502,9 +1502,9 @@ 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 1510
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..976ee034a430 100644
--- a/drivers/media/dvb-frontends/dib0090.c
+++ b/drivers/media/dvb-frontends/dib0090.c
@@ -2669,7 +2669,7 @@ free_mem:
2669} 2669}
2670EXPORT_SYMBOL(dib0090_fw_register); 2670EXPORT_SYMBOL(dib0090_fw_register);
2671 2671
2672MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>"); 2672MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
2673MODULE_AUTHOR("Olivier Grenie <olivier.grenie@dibcom.fr>"); 2673MODULE_AUTHOR("Olivier Grenie <olivier.grenie@parrot.com>");
2674MODULE_DESCRIPTION("Driver for the DiBcom 0090 base-band RF Tuner"); 2674MODULE_DESCRIPTION("Driver for the DiBcom 0090 base-band RF Tuner");
2675MODULE_LICENSE("GPL"); 2675MODULE_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..bab8c5a980a2 100644
--- a/drivers/media/dvb-frontends/dib9000.c
+++ b/drivers/media/dvb-frontends/dib9000.c
@@ -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/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/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..c2469fb42f12 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -575,11 +575,11 @@ err:
575 return ret; 575 return ret;
576} 576}
577 577
578static int rtl2832_get_frontend(struct dvb_frontend *fe) 578static int rtl2832_get_frontend(struct dvb_frontend *fe,
579 struct dtv_frontend_properties *c)
579{ 580{
580 struct rtl2832_dev *dev = fe->demodulator_priv; 581 struct rtl2832_dev *dev = fe->demodulator_priv;
581 struct i2c_client *client = dev->client; 582 struct i2c_client *client = dev->client;
582 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
583 int ret; 583 int ret;
584 u8 buf[3]; 584 u8 buf[3];
585 585
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..28239b1fd954 100644
--- a/drivers/media/dvb-frontends/stv0900_core.c
+++ b/drivers/media/dvb-frontends/stv0900_core.c
@@ -1859,9 +1859,9 @@ static int stv0900_sleep(struct dvb_frontend *fe)
1859 return 0; 1859 return 0;
1860} 1860}
1861 1861
1862static int stv0900_get_frontend(struct dvb_frontend *fe) 1862static int stv0900_get_frontend(struct dvb_frontend *fe,
1863 struct dtv_frontend_properties *p)
1863{ 1864{
1864 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1865 struct stv0900_state *state = fe->demodulator_priv; 1865 struct stv0900_state *state = fe->demodulator_priv;
1866 struct stv0900_internal *intp = state->internal; 1866 struct stv0900_internal *intp = state->internal;
1867 enum fe_stv0900_demod_num demod = state->demod; 1867 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/adp1653.c b/drivers/media/i2c/adp1653.c
index 7e9cbf757e95..fb7ed730d932 100644
--- a/drivers/media/i2c/adp1653.c
+++ b/drivers/media/i2c/adp1653.c
@@ -497,7 +497,7 @@ static int adp1653_probe(struct i2c_client *client,
497 if (!client->dev.platform_data) { 497 if (!client->dev.platform_data) {
498 dev_err(&client->dev, 498 dev_err(&client->dev,
499 "Neither DT not platform data provided\n"); 499 "Neither DT not platform data provided\n");
500 return EINVAL; 500 return -EINVAL;
501 } 501 }
502 flash->platform_data = client->dev.platform_data; 502 flash->platform_data = client->dev.platform_data;
503 } 503 }
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 f8dd7505b529..d35e0ba8b269 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)
@@ -2381,6 +2367,7 @@ static int adv76xx_subscribe_event(struct v4l2_subdev *sd,
2381 2367
2382static const struct v4l2_ctrl_ops adv76xx_ctrl_ops = { 2368static const struct v4l2_ctrl_ops adv76xx_ctrl_ops = {
2383 .s_ctrl = adv76xx_s_ctrl, 2369 .s_ctrl = adv76xx_s_ctrl,
2370 .g_volatile_ctrl = adv76xx_g_volatile_ctrl,
2384}; 2371};
2385 2372
2386static const struct v4l2_subdev_core_ops adv76xx_core_ops = { 2373static const struct v4l2_subdev_core_ops adv76xx_core_ops = {
@@ -2404,6 +2391,7 @@ static const struct v4l2_subdev_video_ops adv76xx_video_ops = {
2404 2391
2405static const struct v4l2_subdev_pad_ops adv76xx_pad_ops = { 2392static const struct v4l2_subdev_pad_ops adv76xx_pad_ops = {
2406 .enum_mbus_code = adv76xx_enum_mbus_code, 2393 .enum_mbus_code = adv76xx_enum_mbus_code,
2394 .get_selection = adv76xx_get_selection,
2407 .get_fmt = adv76xx_get_format, 2395 .get_fmt = adv76xx_get_format,
2408 .set_fmt = adv76xx_set_format, 2396 .set_fmt = adv76xx_set_format,
2409 .get_edid = adv76xx_get_edid, 2397 .get_edid = adv76xx_get_edid,
@@ -2799,6 +2787,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
2799 struct device_node *endpoint; 2787 struct device_node *endpoint;
2800 struct device_node *np; 2788 struct device_node *np;
2801 unsigned int flags; 2789 unsigned int flags;
2790 int ret;
2802 u32 v; 2791 u32 v;
2803 2792
2804 np = state->i2c_clients[ADV76XX_PAGE_IO]->dev.of_node; 2793 np = state->i2c_clients[ADV76XX_PAGE_IO]->dev.of_node;
@@ -2808,7 +2797,11 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
2808 if (!endpoint) 2797 if (!endpoint)
2809 return -EINVAL; 2798 return -EINVAL;
2810 2799
2811 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 }
2812 2805
2813 if (!of_property_read_u32(endpoint, "default-input", &v)) 2806 if (!of_property_read_u32(endpoint, "default-input", &v))
2814 state->pdata.default_input = v; 2807 state->pdata.default_input = v;
@@ -3010,6 +3003,7 @@ static int adv76xx_probe(struct i2c_client *client,
3010 V4L2_DV_BT_CEA_640X480P59_94; 3003 V4L2_DV_BT_CEA_640X480P59_94;
3011 struct adv76xx_state *state; 3004 struct adv76xx_state *state;
3012 struct v4l2_ctrl_handler *hdl; 3005 struct v4l2_ctrl_handler *hdl;
3006 struct v4l2_ctrl *ctrl;
3013 struct v4l2_subdev *sd; 3007 struct v4l2_subdev *sd;
3014 unsigned int i; 3008 unsigned int i;
3015 unsigned int val, val2; 3009 unsigned int val, val2;
@@ -3141,6 +3135,11 @@ static int adv76xx_probe(struct i2c_client *client,
3141 V4L2_CID_SATURATION, 0, 255, 1, 128); 3135 V4L2_CID_SATURATION, 0, 255, 1, 128);
3142 v4l2_ctrl_new_std(hdl, &adv76xx_ctrl_ops, 3136 v4l2_ctrl_new_std(hdl, &adv76xx_ctrl_ops,
3143 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;
3144 3143
3145 /* private controls */ 3144 /* private controls */
3146 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..da7469bc6e56 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)
@@ -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..ef393f5daf2a 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 7dae0ac0f3ae..5ebb3cd31345 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -55,7 +55,11 @@ static int media_device_get_info(struct media_device *dev,
55 55
56 memset(&info, 0, sizeof(info)); 56 memset(&info, 0, sizeof(info));
57 57
58 strlcpy(info.driver, dev->dev->driver->name, sizeof(info.driver)); 58 if (dev->driver_name[0])
59 strlcpy(info.driver, dev->driver_name, sizeof(info.driver));
60 else
61 strlcpy(info.driver, dev->dev->driver->name, sizeof(info.driver));
62
59 strlcpy(info.model, dev->model, sizeof(info.model)); 63 strlcpy(info.model, dev->model, sizeof(info.model));
60 strlcpy(info.serial, dev->serial, sizeof(info.serial)); 64 strlcpy(info.serial, dev->serial, sizeof(info.serial));
61 strlcpy(info.bus_info, dev->bus_info, sizeof(info.bus_info)); 65 strlcpy(info.bus_info, dev->bus_info, sizeof(info.bus_info));
@@ -234,7 +238,6 @@ static long media_device_setup_link(struct media_device *mdev,
234 return ret; 238 return ret;
235} 239}
236 240
237#if 0 /* Let's postpone it to Kernel 4.6 */
238static long __media_device_get_topology(struct media_device *mdev, 241static long __media_device_get_topology(struct media_device *mdev,
239 struct media_v2_topology *topo) 242 struct media_v2_topology *topo)
240{ 243{
@@ -390,7 +393,6 @@ static long media_device_get_topology(struct media_device *mdev,
390 393
391 return 0; 394 return 0;
392} 395}
393#endif
394 396
395static long media_device_ioctl(struct file *filp, unsigned int cmd, 397static long media_device_ioctl(struct file *filp, unsigned int cmd,
396 unsigned long arg) 398 unsigned long arg)
@@ -424,14 +426,13 @@ static long media_device_ioctl(struct file *filp, unsigned int cmd,
424 mutex_unlock(&dev->graph_mutex); 426 mutex_unlock(&dev->graph_mutex);
425 break; 427 break;
426 428
427#if 0 /* Let's postpone it to Kernel 4.6 */
428 case MEDIA_IOC_G_TOPOLOGY: 429 case MEDIA_IOC_G_TOPOLOGY:
429 mutex_lock(&dev->graph_mutex); 430 mutex_lock(&dev->graph_mutex);
430 ret = media_device_get_topology(dev, 431 ret = media_device_get_topology(dev,
431 (struct media_v2_topology __user *)arg); 432 (struct media_v2_topology __user *)arg);
432 mutex_unlock(&dev->graph_mutex); 433 mutex_unlock(&dev->graph_mutex);
433 break; 434 break;
434#endif 435
435 default: 436 default:
436 ret = -ENOIOCTLCMD; 437 ret = -ENOIOCTLCMD;
437 } 438 }
@@ -480,9 +481,7 @@ static long media_device_compat_ioctl(struct file *filp, unsigned int cmd,
480 case MEDIA_IOC_DEVICE_INFO: 481 case MEDIA_IOC_DEVICE_INFO:
481 case MEDIA_IOC_ENUM_ENTITIES: 482 case MEDIA_IOC_ENUM_ENTITIES:
482 case MEDIA_IOC_SETUP_LINK: 483 case MEDIA_IOC_SETUP_LINK:
483#if 0 /* Let's postpone it to Kernel 4.6 */
484 case MEDIA_IOC_G_TOPOLOGY: 484 case MEDIA_IOC_G_TOPOLOGY:
485#endif
486 return media_device_ioctl(filp, cmd, arg); 485 return media_device_ioctl(filp, cmd, arg);
487 486
488 case MEDIA_IOC_ENUM_LINKS32: 487 case MEDIA_IOC_ENUM_LINKS32:
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..f2e43603d6d2 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -452,9 +452,12 @@ error:
452 media_entity_graph_walk_start(graph, entity_err); 452 media_entity_graph_walk_start(graph, entity_err);
453 453
454 while ((entity_err = media_entity_graph_walk_next(graph))) { 454 while ((entity_err = media_entity_graph_walk_next(graph))) {
455 entity_err->stream_count--; 455 /* don't let the stream_count go negative */
456 if (entity_err->stream_count == 0) 456 if (entity->stream_count > 0) {
457 entity_err->pipe = NULL; 457 entity_err->stream_count--;
458 if (entity_err->stream_count == 0)
459 entity_err->pipe = NULL;
460 }
458 461
459 /* 462 /*
460 * We haven't increased stream_count further than this 463 * We haven't increased stream_count further than this
@@ -486,9 +489,12 @@ void media_entity_pipeline_stop(struct media_entity *entity)
486 media_entity_graph_walk_start(graph, entity); 489 media_entity_graph_walk_start(graph, entity);
487 490
488 while ((entity = media_entity_graph_walk_next(graph))) { 491 while ((entity = media_entity_graph_walk_next(graph))) {
489 entity->stream_count--; 492 /* don't let the stream_count go negative */
490 if (entity->stream_count == 0) 493 if (entity->stream_count > 0) {
491 entity->pipe = NULL; 494 entity->stream_count--;
495 if (entity->stream_count == 0)
496 entity->pipe = NULL;
497 }
492 } 498 }
493 499
494 if (!--pipe->streaming_count) 500 if (!--pipe->streaming_count)
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..2c412377507b 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)
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..5131c9f555fb 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -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/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/saa7134/saa7134-cards.c b/drivers/media/pci/saa7134/saa7134-cards.c
index 29d2094c42a0..9a2fdc78eb85 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,29 +5707,28 @@ 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 },
diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c
index e227b02cc122..42bc4172febd 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,153 @@ 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
832static void saa7134_create_entities(struct saa7134_dev *dev)
833{
834#if defined(CONFIG_MEDIA_CONTROLLER)
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 * saa713x is not using an external ATV demod.
848 * Register the internal one
849 */
850 if (!decoder) {
851 dev->demod.name = "saa713x";
852 dev->demod_pad[DEMOD_PAD_IF_INPUT].flags = MEDIA_PAD_FL_SINK;
853 dev->demod_pad[DEMOD_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
854 dev->demod_pad[DEMOD_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
855 dev->demod.function = MEDIA_ENT_F_ATV_DECODER;
856
857 ret = media_entity_pads_init(&dev->demod, DEMOD_NUM_PADS,
858 dev->demod_pad);
859 if (ret < 0)
860 pr_err("failed to initialize demod pad!\n");
861
862 ret = media_device_register_entity(dev->media_dev, &dev->demod);
863 if (ret < 0)
864 pr_err("failed to register demod entity!\n");
865
866 dev->decoder = &dev->demod;
867 } else {
868 dev->decoder = decoder;
869 }
870
871 /* Initialize Video, VBI and Radio pads */
872 dev->video_pad.flags = MEDIA_PAD_FL_SINK;
873 ret = media_entity_pads_init(&dev->video_dev->entity, 1,
874 &dev->video_pad);
875 if (ret < 0)
876 pr_err("failed to initialize video media entity!\n");
877
878 dev->vbi_pad.flags = MEDIA_PAD_FL_SINK;
879 ret = media_entity_pads_init(&dev->vbi_dev->entity, 1,
880 &dev->vbi_pad);
881 if (ret < 0)
882 pr_err("failed to initialize vbi media entity!\n");
883
884 /* Create entities for each input connector */
885 for (i = 0; i < SAA7134_INPUT_MAX; i++) {
886 struct media_entity *ent = &dev->input_ent[i];
887 struct saa7134_input *in = &card_in(dev, i);
888
889 if (in->type == SAA7134_NO_INPUT)
890 break;
891
892 /* This input uses the S-Video connector */
893 if (in->type == SAA7134_INPUT_COMPOSITE_OVER_SVIDEO)
894 continue;
895
896 ent->name = saa7134_input_name[in->type];
897 ent->flags = MEDIA_ENT_FL_CONNECTOR;
898 dev->input_pad[i].flags = MEDIA_PAD_FL_SOURCE;
899
900 switch (in->type) {
901 case SAA7134_INPUT_COMPOSITE:
902 case SAA7134_INPUT_COMPOSITE0:
903 case SAA7134_INPUT_COMPOSITE1:
904 case SAA7134_INPUT_COMPOSITE2:
905 case SAA7134_INPUT_COMPOSITE3:
906 case SAA7134_INPUT_COMPOSITE4:
907 ent->function = MEDIA_ENT_F_CONN_COMPOSITE;
908 break;
909 case SAA7134_INPUT_SVIDEO:
910 case SAA7134_INPUT_SVIDEO0:
911 case SAA7134_INPUT_SVIDEO1:
912 ent->function = MEDIA_ENT_F_CONN_SVIDEO;
913 break;
914 default:
915 /*
916 * SAA7134_INPUT_TV and SAA7134_INPUT_TV_MONO.
917 *
918 * Please notice that neither SAA7134_INPUT_MUTE or
919 * SAA7134_INPUT_RADIO are defined at
920 * saa7134_board.input.
921 */
922 ent->function = MEDIA_ENT_F_CONN_RF;
923 break;
924 }
925
926 ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]);
927 if (ret < 0)
928 pr_err("failed to initialize input pad[%d]!\n", i);
929
930 ret = media_device_register_entity(dev->media_dev, ent);
931 if (ret < 0)
932 pr_err("failed to register input entity %d!\n", i);
933 }
934
935 /* Create input for Radio RF connector */
936 if (card_has_radio(dev)) {
937 struct saa7134_input *in = &saa7134_boards[dev->board].radio;
938 struct media_entity *ent = &dev->input_ent[i];
939
940 ent->name = saa7134_input_name[in->type];
941 ent->flags = MEDIA_ENT_FL_CONNECTOR;
942 dev->input_pad[i].flags = MEDIA_PAD_FL_SOURCE;
943 ent->function = MEDIA_ENT_F_CONN_RF;
944
945 ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]);
946 if (ret < 0)
947 pr_err("failed to initialize input pad[%d]!\n", i);
948
949 ret = media_device_register_entity(dev->media_dev, ent);
950 if (ret < 0)
951 pr_err("failed to register input entity %d!\n", i);
952 }
953#endif
954}
955
809static struct video_device *vdev_init(struct saa7134_dev *dev, 956static struct video_device *vdev_init(struct saa7134_dev *dev,
810 struct video_device *template, 957 struct video_device *template,
811 char *type) 958 char *type)
@@ -826,6 +973,8 @@ static struct video_device *vdev_init(struct saa7134_dev *dev,
826 973
827static void saa7134_unregister_video(struct saa7134_dev *dev) 974static void saa7134_unregister_video(struct saa7134_dev *dev)
828{ 975{
976 saa7134_media_release(dev);
977
829 if (dev->video_dev) { 978 if (dev->video_dev) {
830 if (video_is_registered(dev->video_dev)) 979 if (video_is_registered(dev->video_dev))
831 video_unregister_device(dev->video_dev); 980 video_unregister_device(dev->video_dev);
@@ -889,6 +1038,18 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
889 if (NULL == dev) 1038 if (NULL == dev)
890 return -ENOMEM; 1039 return -ENOMEM;
891 1040
1041 dev->nr = saa7134_devcount;
1042 sprintf(dev->name, "saa%x[%d]", pci_dev->device, dev->nr);
1043
1044#ifdef CONFIG_MEDIA_CONTROLLER
1045 dev->media_dev = v4l2_mc_pci_media_device_init(pci_dev, dev->name);
1046 if (!dev->media_dev) {
1047 err = -ENOMEM;
1048 goto fail0;
1049 }
1050 dev->v4l2_dev.mdev = dev->media_dev;
1051#endif
1052
892 err = v4l2_device_register(&pci_dev->dev, &dev->v4l2_dev); 1053 err = v4l2_device_register(&pci_dev->dev, &dev->v4l2_dev);
893 if (err) 1054 if (err)
894 goto fail0; 1055 goto fail0;
@@ -900,9 +1061,6 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
900 goto fail1; 1061 goto fail1;
901 } 1062 }
902 1063
903 dev->nr = saa7134_devcount;
904 sprintf(dev->name,"saa%x[%d]",pci_dev->device,dev->nr);
905
906 /* pci quirks */ 1064 /* pci quirks */
907 if (pci_pci_problems) { 1065 if (pci_pci_problems) {
908 if (pci_pci_problems & PCIPCI_TRITON) 1066 if (pci_pci_problems & PCIPCI_TRITON)
@@ -1102,6 +1260,15 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
1102 dev->name, video_device_node_name(dev->radio_dev)); 1260 dev->name, video_device_node_name(dev->radio_dev));
1103 } 1261 }
1104 1262
1263#ifdef CONFIG_MEDIA_CONTROLLER
1264 saa7134_create_entities(dev);
1265
1266 err = v4l2_mc_create_media_graph(dev->media_dev);
1267 if (err) {
1268 pr_err("failed to create media graph\n");
1269 goto fail5;
1270 }
1271#endif
1105 /* everything worked */ 1272 /* everything worked */
1106 saa7134_devcount++; 1273 saa7134_devcount++;
1107 1274
@@ -1109,6 +1276,18 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
1109 saa7134_dmasound_init(dev); 1276 saa7134_dmasound_init(dev);
1110 1277
1111 request_submodules(dev); 1278 request_submodules(dev);
1279
1280 /*
1281 * Do it at the end, to reduce dynamic configuration changes during
1282 * the device init. Yet, as request_modules() can be async, the
1283 * topology will likely change after load the saa7134 subdrivers.
1284 */
1285#ifdef CONFIG_MEDIA_CONTROLLER
1286 err = media_device_register(dev->media_dev);
1287 if (err)
1288 goto fail5;
1289#endif
1290
1112 return 0; 1291 return 0;
1113 1292
1114 fail5: 1293 fail5:
@@ -1126,6 +1305,9 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
1126 fail1: 1305 fail1:
1127 v4l2_device_unregister(&dev->v4l2_dev); 1306 v4l2_device_unregister(&dev->v4l2_dev);
1128 fail0: 1307 fail0:
1308#ifdef CONFIG_MEDIA_CONTROLLER
1309 kfree(dev->media_dev);
1310#endif
1129 kfree(dev); 1311 kfree(dev);
1130 return err; 1312 return err;
1131} 1313}
@@ -1188,9 +1370,10 @@ static void saa7134_finidev(struct pci_dev *pci_dev)
1188 release_mem_region(pci_resource_start(pci_dev,0), 1370 release_mem_region(pci_resource_start(pci_dev,0),
1189 pci_resource_len(pci_dev,0)); 1371 pci_resource_len(pci_dev,0));
1190 1372
1191
1192 v4l2_device_unregister(&dev->v4l2_dev); 1373 v4l2_device_unregister(&dev->v4l2_dev);
1193 1374
1375 saa7134_unregister_media_device(dev);
1376
1194 /* free memory */ 1377 /* free memory */
1195 kfree(dev); 1378 kfree(dev);
1196} 1379}
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-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..8936568fab94 100644
--- a/drivers/media/pci/saa7134/saa7134.h
+++ b/drivers/media/pci/saa7134/saa7134.h
@@ -361,12 +361,29 @@ struct saa7134_card_ir {
361#define SET_CLOCK_INVERTED (1 << 2) 361#define SET_CLOCK_INVERTED (1 << 2)
362#define SET_VSYNC_OFF (1 << 3) 362#define SET_VSYNC_OFF (1 << 3)
363 363
364enum saa7134_input_types {
365 SAA7134_NO_INPUT = 0,
366 SAA7134_INPUT_MUTE,
367 SAA7134_INPUT_RADIO,
368 SAA7134_INPUT_TV,
369 SAA7134_INPUT_TV_MONO,
370 SAA7134_INPUT_COMPOSITE,
371 SAA7134_INPUT_COMPOSITE0,
372 SAA7134_INPUT_COMPOSITE1,
373 SAA7134_INPUT_COMPOSITE2,
374 SAA7134_INPUT_COMPOSITE3,
375 SAA7134_INPUT_COMPOSITE4,
376 SAA7134_INPUT_SVIDEO,
377 SAA7134_INPUT_SVIDEO0,
378 SAA7134_INPUT_SVIDEO1,
379 SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
380};
381
364struct saa7134_input { 382struct saa7134_input {
365 char *name; 383 enum saa7134_input_types type;
366 unsigned int vmux; 384 unsigned int vmux;
367 enum saa7134_audio_in amux; 385 enum saa7134_audio_in amux;
368 unsigned int gpio; 386 unsigned int gpio;
369 unsigned int tv:1;
370}; 387};
371 388
372enum saa7134_mpeg_type { 389enum saa7134_mpeg_type {
@@ -410,7 +427,7 @@ struct saa7134_board {
410 unsigned int ts_force_val:1; 427 unsigned int ts_force_val:1;
411}; 428};
412 429
413#define card_has_radio(dev) (NULL != saa7134_boards[dev->board].radio.name) 430#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) 431#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) 432#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) 433#define card_is_go7007(dev) (SAA7134_MPEG_GO7007 == saa7134_boards[dev->board].mpeg)
@@ -654,6 +671,19 @@ struct saa7134_dev {
654 /* I2C keyboard data */ 671 /* I2C keyboard data */
655 struct IR_i2c_init_data init_data; 672 struct IR_i2c_init_data init_data;
656 673
674#ifdef CONFIG_MEDIA_CONTROLLER
675 struct media_device *media_dev;
676
677 struct media_entity input_ent[SAA7134_INPUT_MAX + 1];
678 struct media_pad input_pad[SAA7134_INPUT_MAX + 1];
679
680 struct media_entity demod;
681 struct media_pad demod_pad[DEMOD_NUM_PADS];
682
683 struct media_pad video_pad, vbi_pad;
684 struct media_entity *decoder;
685#endif
686
657#if IS_ENABLED(CONFIG_VIDEO_SAA7134_DVB) 687#if IS_ENABLED(CONFIG_VIDEO_SAA7134_DVB)
658 /* SAA7134_MPEG_DVB only */ 688 /* SAA7134_MPEG_DVB only */
659 struct vb2_dvb_frontends frontends; 689 struct vb2_dvb_frontends frontends;
@@ -727,7 +757,7 @@ extern struct mutex saa7134_devlist_lock;
727extern int saa7134_no_overlay; 757extern int saa7134_no_overlay;
728extern bool saa7134_userptr; 758extern bool saa7134_userptr;
729 759
730void saa7134_track_gpio(struct saa7134_dev *dev, char *msg); 760void saa7134_track_gpio(struct saa7134_dev *dev, const char *msg);
731void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value); 761void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value);
732 762
733#define SAA7134_PGTABLE_SIZE 4096 763#define SAA7134_PGTABLE_SIZE 4096
@@ -760,6 +790,7 @@ extern int (*saa7134_dmasound_exit)(struct saa7134_dev *dev);
760/* saa7134-cards.c */ 790/* saa7134-cards.c */
761 791
762extern struct saa7134_board saa7134_boards[]; 792extern struct saa7134_board saa7134_boards[];
793extern const char * const saa7134_input_name[];
763extern const unsigned int saa7134_bcount; 794extern const unsigned int saa7134_bcount;
764extern struct pci_device_id saa7134_pci_tbl[]; 795extern struct pci_device_id saa7134_pci_tbl[];
765 796
diff --git a/drivers/media/pci/ttpci/av7110.c b/drivers/media/pci/ttpci/av7110.c
index a69dc6a0752b..18d229fa65cf 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,
diff --git a/drivers/media/pci/ttpci/budget.c b/drivers/media/pci/ttpci/budget.c
index de54310a2660..9f48100227f1 100644
--- a/drivers/media/pci/ttpci/budget.c
+++ b/drivers/media/pci/ttpci/budget.c
@@ -644,7 +644,7 @@ static void frontend_init(struct budget *budget)
644 } 644 }
645 645
646 case 0x101c: { /* TT S2-1600 */ 646 case 0x101c: { /* TT S2-1600 */
647 struct stv6110x_devctl *ctl; 647 const struct stv6110x_devctl *ctl;
648 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTLO); 648 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTLO);
649 msleep(50); 649 msleep(50);
650 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTHI); 650 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTHI);
@@ -697,7 +697,7 @@ static void frontend_init(struct budget *budget)
697 break; 697 break;
698 698
699 case 0x1020: { /* Omicom S2 */ 699 case 0x1020: { /* Omicom S2 */
700 struct stv6110x_devctl *ctl; 700 const struct stv6110x_devctl *ctl;
701 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTLO); 701 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTLO);
702 msleep(50); 702 msleep(50);
703 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTHI); 703 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 7d28899f89ce..6efe9d002961 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/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/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..f9e5245f26ac 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -449,7 +449,7 @@ void omap3isp_configure_bridge(struct isp_device *isp,
449 case CCDC_INPUT_PARALLEL: 449 case CCDC_INPUT_PARALLEL:
450 ispctrl_val |= ISPCTRL_PAR_SER_CLK_SEL_PARALLEL; 450 ispctrl_val |= ISPCTRL_PAR_SER_CLK_SEL_PARALLEL;
451 ispctrl_val |= parcfg->clk_pol << ISPCTRL_PAR_CLK_POL_SHIFT; 451 ispctrl_val |= parcfg->clk_pol << ISPCTRL_PAR_CLK_POL_SHIFT;
452 shift += parcfg->data_lane_shift * 2; 452 shift += parcfg->data_lane_shift;
453 break; 453 break;
454 454
455 case CCDC_INPUT_CSI2A: 455 case CCDC_INPUT_CSI2A:
@@ -2235,8 +2235,11 @@ static int isp_of_parse_node(struct device *dev, struct device_node *node,
2235 struct isp_bus_cfg *buscfg = &isd->bus; 2235 struct isp_bus_cfg *buscfg = &isd->bus;
2236 struct v4l2_of_endpoint vep; 2236 struct v4l2_of_endpoint vep;
2237 unsigned int i; 2237 unsigned int i;
2238 int ret;
2238 2239
2239 v4l2_of_parse_endpoint(node, &vep); 2240 ret = v4l2_of_parse_endpoint(node, &vep);
2241 if (ret)
2242 return ret;
2240 2243
2241 dev_dbg(dev, "parsing endpoint %s, interface %u\n", node->full_name, 2244 dev_dbg(dev, "parsing endpoint %s, interface %u\n", node->full_name,
2242 vep.base.port); 2245 vep.base.port);
@@ -2528,12 +2531,13 @@ static int isp_probe(struct platform_device *pdev)
2528 } 2531 }
2529 2532
2530 /* Interrupt */ 2533 /* Interrupt */
2531 isp->irq_num = platform_get_irq(pdev, 0); 2534 ret = platform_get_irq(pdev, 0);
2532 if (isp->irq_num <= 0) { 2535 if (ret <= 0) {
2533 dev_err(isp->dev, "No IRQ resource\n"); 2536 dev_err(isp->dev, "No IRQ resource\n");
2534 ret = -ENODEV; 2537 ret = -ENODEV;
2535 goto error_iommu; 2538 goto error_iommu;
2536 } 2539 }
2540 isp->irq_num = ret;
2537 2541
2538 if (devm_request_irq(isp->dev, isp->irq_num, isp_isr, IRQF_SHARED, 2542 if (devm_request_irq(isp->dev, isp->irq_num, isp_isr, IRQF_SHARED,
2539 "OMAP3 ISP", isp)) { 2543 "OMAP3 ISP", isp)) {
@@ -2599,6 +2603,7 @@ static const struct of_device_id omap3isp_of_table[] = {
2599 { .compatible = "ti,omap3-isp" }, 2603 { .compatible = "ti,omap3-isp" },
2600 { }, 2604 { },
2601}; 2605};
2606MODULE_DEVICE_TABLE(of, omap3isp_of_table);
2602 2607
2603static struct platform_driver omap3isp_driver = { 2608static struct platform_driver omap3isp_driver = {
2604 .probe = isp_probe, 2609 .probe = isp_probe,
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..2aff755ff77c 100644
--- a/drivers/media/platform/omap3isp/ispvideo.c
+++ b/drivers/media/platform/omap3isp/ispvideo.c
@@ -434,10 +434,68 @@ static void isp_video_buffer_queue(struct vb2_buffer *buf)
434 } 434 }
435} 435}
436 436
437/*
438 * omap3isp_video_return_buffers - Return all queued buffers to videobuf2
439 * @video: ISP video object
440 * @state: new state for the returned buffers
441 *
442 * Return all buffers queued on the video node to videobuf2 in the given state.
443 * The buffer state should be VB2_BUF_STATE_QUEUED if called due to an error
444 * when starting the stream, or VB2_BUF_STATE_ERROR otherwise.
445 *
446 * The function must be called with the video irqlock held.
447 */
448static void omap3isp_video_return_buffers(struct isp_video *video,
449 enum vb2_buffer_state state)
450{
451 while (!list_empty(&video->dmaqueue)) {
452 struct isp_buffer *buf;
453
454 buf = list_first_entry(&video->dmaqueue,
455 struct isp_buffer, irqlist);
456 list_del(&buf->irqlist);
457 vb2_buffer_done(&buf->vb.vb2_buf, state);
458 }
459}
460
461static int isp_video_start_streaming(struct vb2_queue *queue,
462 unsigned int count)
463{
464 struct isp_video_fh *vfh = vb2_get_drv_priv(queue);
465 struct isp_video *video = vfh->video;
466 struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity);
467 unsigned long flags;
468 int ret;
469
470 /* In sensor-to-memory mode, the stream can be started synchronously
471 * to the stream on command. In memory-to-memory mode, it will be
472 * started when buffers are queued on both the input and output.
473 */
474 if (pipe->input)
475 return 0;
476
477 ret = omap3isp_pipeline_set_stream(pipe,
478 ISP_PIPELINE_STREAM_CONTINUOUS);
479 if (ret < 0) {
480 spin_lock_irqsave(&video->irqlock, flags);
481 omap3isp_video_return_buffers(video, VB2_BUF_STATE_QUEUED);
482 spin_unlock_irqrestore(&video->irqlock, flags);
483 return ret;
484 }
485
486 spin_lock_irqsave(&video->irqlock, flags);
487 if (list_empty(&video->dmaqueue))
488 video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_UNDERRUN;
489 spin_unlock_irqrestore(&video->irqlock, flags);
490
491 return 0;
492}
493
437static const struct vb2_ops isp_video_queue_ops = { 494static const struct vb2_ops isp_video_queue_ops = {
438 .queue_setup = isp_video_queue_setup, 495 .queue_setup = isp_video_queue_setup,
439 .buf_prepare = isp_video_buffer_prepare, 496 .buf_prepare = isp_video_buffer_prepare,
440 .buf_queue = isp_video_buffer_queue, 497 .buf_queue = isp_video_buffer_queue,
498 .start_streaming = isp_video_start_streaming,
441}; 499};
442 500
443/* 501/*
@@ -459,7 +517,7 @@ static const struct vb2_ops isp_video_queue_ops = {
459struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video) 517struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video)
460{ 518{
461 struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity); 519 struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity);
462 enum isp_pipeline_state state; 520 enum vb2_buffer_state vb_state;
463 struct isp_buffer *buf; 521 struct isp_buffer *buf;
464 unsigned long flags; 522 unsigned long flags;
465 523
@@ -495,17 +553,19 @@ struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video)
495 553
496 /* Report pipeline errors to userspace on the capture device side. */ 554 /* Report pipeline errors to userspace on the capture device side. */
497 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pipe->error) { 555 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pipe->error) {
498 state = VB2_BUF_STATE_ERROR; 556 vb_state = VB2_BUF_STATE_ERROR;
499 pipe->error = false; 557 pipe->error = false;
500 } else { 558 } else {
501 state = VB2_BUF_STATE_DONE; 559 vb_state = VB2_BUF_STATE_DONE;
502 } 560 }
503 561
504 vb2_buffer_done(&buf->vb.vb2_buf, state); 562 vb2_buffer_done(&buf->vb.vb2_buf, vb_state);
505 563
506 spin_lock_irqsave(&video->irqlock, flags); 564 spin_lock_irqsave(&video->irqlock, flags);
507 565
508 if (list_empty(&video->dmaqueue)) { 566 if (list_empty(&video->dmaqueue)) {
567 enum isp_pipeline_state state;
568
509 spin_unlock_irqrestore(&video->irqlock, flags); 569 spin_unlock_irqrestore(&video->irqlock, flags);
510 570
511 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) 571 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
@@ -541,26 +601,16 @@ struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video)
541 * omap3isp_video_cancel_stream - Cancel stream on a video node 601 * omap3isp_video_cancel_stream - Cancel stream on a video node
542 * @video: ISP video object 602 * @video: ISP video object
543 * 603 *
544 * Cancelling a stream mark all buffers on the video node as erroneous and makes 604 * Cancelling a stream returns all buffers queued on the video node to videobuf2
545 * sure no new buffer can be queued. 605 * in the erroneous state and makes sure no new buffer can be queued.
546 */ 606 */
547void omap3isp_video_cancel_stream(struct isp_video *video) 607void omap3isp_video_cancel_stream(struct isp_video *video)
548{ 608{
549 unsigned long flags; 609 unsigned long flags;
550 610
551 spin_lock_irqsave(&video->irqlock, flags); 611 spin_lock_irqsave(&video->irqlock, flags);
552 612 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; 613 video->error = true;
563
564 spin_unlock_irqrestore(&video->irqlock, flags); 614 spin_unlock_irqrestore(&video->irqlock, flags);
565} 615}
566 616
@@ -1087,29 +1137,10 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
1087 if (ret < 0) 1137 if (ret < 0)
1088 goto err_check_format; 1138 goto err_check_format;
1089 1139
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); 1140 mutex_unlock(&video->stream_lock);
1106 1141
1107 return 0; 1142 return 0;
1108 1143
1109err_set_stream:
1110 mutex_lock(&video->queue_lock);
1111 vb2_streamoff(&vfh->queue, type);
1112 mutex_unlock(&video->queue_lock);
1113err_check_format: 1144err_check_format:
1114 media_entity_pipeline_stop(&video->video.entity); 1145 media_entity_pipeline_stop(&video->video.entity);
1115err_pipeline_start: 1146err_pipeline_start:
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/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index b7fd695b9ed5..dc75a80794fb 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -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,
@@ -1818,6 +1819,7 @@ static struct soc_camera_host_ops rcar_vin_host_ops = {
1818 1819
1819#ifdef CONFIG_OF 1820#ifdef CONFIG_OF
1820static const struct of_device_id rcar_vin_of_table[] = { 1821static const struct of_device_id rcar_vin_of_table[] = {
1822 { .compatible = "renesas,vin-r8a7795", .data = (void *)RCAR_GEN3 },
1821 { .compatible = "renesas,vin-r8a7794", .data = (void *)RCAR_GEN2 }, 1823 { .compatible = "renesas,vin-r8a7794", .data = (void *)RCAR_GEN2 },
1822 { .compatible = "renesas,vin-r8a7793", .data = (void *)RCAR_GEN2 }, 1824 { .compatible = "renesas,vin-r8a7793", .data = (void *)RCAR_GEN2 },
1823 { .compatible = "renesas,vin-r8a7791", .data = (void *)RCAR_GEN2 }, 1825 { .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..35fa1071c5b2
--- /dev/null
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -0,0 +1,1971 @@
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 ctrl = v4l2_ctrl_find(ctx->sensor->ctrl_handler, V4L2_CID_PIXEL_RATE);
808 if (!ctrl) {
809 ctx_err(ctx, "no pixel rate control in subdev: %s\n",
810 ctx->sensor->name);
811 return -EPIPE;
812 }
813
814 ctx->external_rate = v4l2_ctrl_g_ctrl_int64(ctrl);
815 ctx_dbg(3, ctx, "sensor Pixel Rate: %d\n", ctx->external_rate);
816
817 return 0;
818}
819
820static inline void cal_schedule_next_buffer(struct cal_ctx *ctx)
821{
822 struct cal_dmaqueue *dma_q = &ctx->vidq;
823 struct cal_buffer *buf;
824 unsigned long addr;
825
826 buf = list_entry(dma_q->active.next, struct cal_buffer, list);
827 ctx->next_frm = buf;
828 list_del(&buf->list);
829
830 addr = vb2_dma_contig_plane_dma_addr(&buf->vb.vb2_buf, 0);
831 cal_wr_dma_addr(ctx, addr);
832}
833
834static inline void cal_process_buffer_complete(struct cal_ctx *ctx)
835{
836 ctx->cur_frm->vb.vb2_buf.timestamp = ktime_get_ns();
837 ctx->cur_frm->vb.field = ctx->m_fmt.field;
838 ctx->cur_frm->vb.sequence = ctx->sequence++;
839
840 vb2_buffer_done(&ctx->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE);
841 ctx->cur_frm = ctx->next_frm;
842}
843
844#define isvcirqset(irq, vc, ff) (irq & \
845 (CAL_CSI2_VC_IRQENABLE_ ##ff ##_IRQ_##vc ##_MASK))
846
847#define isportirqset(irq, port) (irq & CAL_HL_IRQ_MASK(port))
848
849static irqreturn_t cal_irq(int irq_cal, void *data)
850{
851 struct cal_dev *dev = (struct cal_dev *)data;
852 struct cal_ctx *ctx;
853 struct cal_dmaqueue *dma_q;
854 u32 irqst2, irqst3;
855
856 /* Check which DMA just finished */
857 irqst2 = reg_read(dev, CAL_HL_IRQSTATUS(2));
858 if (irqst2) {
859 /* Clear Interrupt status */
860 reg_write(dev, CAL_HL_IRQSTATUS(2), irqst2);
861
862 /* Need to check both port */
863 if (isportirqset(irqst2, 1)) {
864 ctx = dev->ctx[0];
865
866 if (ctx->cur_frm != ctx->next_frm)
867 cal_process_buffer_complete(ctx);
868 }
869
870 if (isportirqset(irqst2, 2)) {
871 ctx = dev->ctx[1];
872
873 if (ctx->cur_frm != ctx->next_frm)
874 cal_process_buffer_complete(ctx);
875 }
876 }
877
878 /* Check which DMA just started */
879 irqst3 = reg_read(dev, CAL_HL_IRQSTATUS(3));
880 if (irqst3) {
881 /* Clear Interrupt status */
882 reg_write(dev, CAL_HL_IRQSTATUS(3), irqst3);
883
884 /* Need to check both port */
885 if (isportirqset(irqst3, 1)) {
886 ctx = dev->ctx[0];
887 dma_q = &ctx->vidq;
888
889 spin_lock(&ctx->slock);
890 if (!list_empty(&dma_q->active) &&
891 ctx->cur_frm == ctx->next_frm)
892 cal_schedule_next_buffer(ctx);
893 spin_unlock(&ctx->slock);
894 }
895
896 if (isportirqset(irqst3, 2)) {
897 ctx = dev->ctx[1];
898 dma_q = &ctx->vidq;
899
900 spin_lock(&ctx->slock);
901 if (!list_empty(&dma_q->active) &&
902 ctx->cur_frm == ctx->next_frm)
903 cal_schedule_next_buffer(ctx);
904 spin_unlock(&ctx->slock);
905 }
906 }
907
908 return IRQ_HANDLED;
909}
910
911/*
912 * video ioctls
913 */
914static int cal_querycap(struct file *file, void *priv,
915 struct v4l2_capability *cap)
916{
917 struct cal_ctx *ctx = video_drvdata(file);
918
919 strlcpy(cap->driver, CAL_MODULE_NAME, sizeof(cap->driver));
920 strlcpy(cap->card, CAL_MODULE_NAME, sizeof(cap->card));
921
922 snprintf(cap->bus_info, sizeof(cap->bus_info),
923 "platform:%s", ctx->v4l2_dev.name);
924 cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
925 V4L2_CAP_READWRITE;
926 cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
927 return 0;
928}
929
930static int cal_enum_fmt_vid_cap(struct file *file, void *priv,
931 struct v4l2_fmtdesc *f)
932{
933 struct cal_ctx *ctx = video_drvdata(file);
934 const struct cal_fmt *fmt = NULL;
935
936 if (f->index >= ctx->num_active_fmt)
937 return -EINVAL;
938
939 fmt = ctx->active_fmt[f->index];
940
941 f->pixelformat = fmt->fourcc;
942 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
943 return 0;
944}
945
946static int __subdev_get_format(struct cal_ctx *ctx,
947 struct v4l2_mbus_framefmt *fmt)
948{
949 struct v4l2_subdev_format sd_fmt;
950 struct v4l2_mbus_framefmt *mbus_fmt = &sd_fmt.format;
951 int ret;
952
953 if (!ctx->sensor)
954 return -EINVAL;
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 if (!ctx->sensor)
979 return -EINVAL;
980
981 sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
982 sd_fmt.pad = 0;
983 *mbus_fmt = *fmt;
984
985 ret = v4l2_subdev_call(ctx->sensor, pad, set_fmt, NULL, &sd_fmt);
986 if (ret)
987 return ret;
988
989 ctx_dbg(1, ctx, "%s %dx%d code:%04X\n", __func__,
990 fmt->width, fmt->height, fmt->code);
991
992 return 0;
993}
994
995static int cal_calc_format_size(struct cal_ctx *ctx,
996 const struct cal_fmt *fmt,
997 struct v4l2_format *f)
998{
999 if (!fmt) {
1000 ctx_dbg(3, ctx, "No cal_fmt provided!\n");
1001 return -EINVAL;
1002 }
1003
1004 v4l_bound_align_image(&f->fmt.pix.width, 48, MAX_WIDTH, 2,
1005 &f->fmt.pix.height, 32, MAX_HEIGHT, 0, 0);
1006 f->fmt.pix.bytesperline = bytes_per_line(f->fmt.pix.width,
1007 fmt->depth >> 3);
1008 f->fmt.pix.sizeimage = f->fmt.pix.height *
1009 f->fmt.pix.bytesperline;
1010
1011 ctx_dbg(3, ctx, "%s: fourcc: %s size: %dx%d bpl:%d img_size:%d\n",
1012 __func__, fourcc_to_str(f->fmt.pix.pixelformat),
1013 f->fmt.pix.width, f->fmt.pix.height,
1014 f->fmt.pix.bytesperline, f->fmt.pix.sizeimage);
1015
1016 return 0;
1017}
1018
1019static int cal_g_fmt_vid_cap(struct file *file, void *priv,
1020 struct v4l2_format *f)
1021{
1022 struct cal_ctx *ctx = video_drvdata(file);
1023
1024 *f = ctx->v_fmt;
1025
1026 return 0;
1027}
1028
1029static int cal_try_fmt_vid_cap(struct file *file, void *priv,
1030 struct v4l2_format *f)
1031{
1032 struct cal_ctx *ctx = video_drvdata(file);
1033 const struct cal_fmt *fmt;
1034 struct v4l2_subdev_frame_size_enum fse;
1035 int ret, found;
1036
1037 fmt = find_format_by_pix(ctx, f->fmt.pix.pixelformat);
1038 if (!fmt) {
1039 ctx_dbg(3, ctx, "Fourcc format (0x%08x) not found.\n",
1040 f->fmt.pix.pixelformat);
1041
1042 /* Just get the first one enumerated */
1043 fmt = ctx->active_fmt[0];
1044 f->fmt.pix.pixelformat = fmt->fourcc;
1045 }
1046
1047 f->fmt.pix.field = ctx->v_fmt.fmt.pix.field;
1048
1049 /* check for/find a valid width/height */
1050 ret = 0;
1051 found = false;
1052 fse.pad = 0;
1053 fse.code = fmt->code;
1054 fse.which = V4L2_SUBDEV_FORMAT_ACTIVE;
1055 for (fse.index = 0; ; fse.index++) {
1056 ret = v4l2_subdev_call(ctx->sensor, pad, enum_frame_size,
1057 NULL, &fse);
1058 if (ret)
1059 break;
1060
1061 if ((f->fmt.pix.width == fse.max_width) &&
1062 (f->fmt.pix.height == fse.max_height)) {
1063 found = true;
1064 break;
1065 } else if ((f->fmt.pix.width >= fse.min_width) &&
1066 (f->fmt.pix.width <= fse.max_width) &&
1067 (f->fmt.pix.height >= fse.min_height) &&
1068 (f->fmt.pix.height <= fse.max_height)) {
1069 found = true;
1070 break;
1071 }
1072 }
1073
1074 if (!found) {
1075 /* use existing values as default */
1076 f->fmt.pix.width = ctx->v_fmt.fmt.pix.width;
1077 f->fmt.pix.height = ctx->v_fmt.fmt.pix.height;
1078 }
1079
1080 /*
1081 * Use current colorspace for now, it will get
1082 * updated properly during s_fmt
1083 */
1084 f->fmt.pix.colorspace = ctx->v_fmt.fmt.pix.colorspace;
1085 return cal_calc_format_size(ctx, fmt, f);
1086}
1087
1088static int cal_s_fmt_vid_cap(struct file *file, void *priv,
1089 struct v4l2_format *f)
1090{
1091 struct cal_ctx *ctx = video_drvdata(file);
1092 struct vb2_queue *q = &ctx->vb_vidq;
1093 const struct cal_fmt *fmt;
1094 struct v4l2_mbus_framefmt mbus_fmt;
1095 int ret;
1096
1097 if (vb2_is_busy(q)) {
1098 ctx_dbg(3, ctx, "%s device busy\n", __func__);
1099 return -EBUSY;
1100 }
1101
1102 ret = cal_try_fmt_vid_cap(file, priv, f);
1103 if (ret < 0)
1104 return ret;
1105
1106 fmt = find_format_by_pix(ctx, f->fmt.pix.pixelformat);
1107
1108 v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, fmt->code);
1109
1110 ret = __subdev_set_format(ctx, &mbus_fmt);
1111 if (ret)
1112 return ret;
1113
1114 /* Just double check nothing has gone wrong */
1115 if (mbus_fmt.code != fmt->code) {
1116 ctx_dbg(3, ctx,
1117 "%s subdev changed format on us, this should not happen\n",
1118 __func__);
1119 return -EINVAL;
1120 }
1121
1122 v4l2_fill_pix_format(&ctx->v_fmt.fmt.pix, &mbus_fmt);
1123 ctx->v_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1124 ctx->v_fmt.fmt.pix.pixelformat = fmt->fourcc;
1125 cal_calc_format_size(ctx, fmt, &ctx->v_fmt);
1126 ctx->fmt = fmt;
1127 ctx->m_fmt = mbus_fmt;
1128 *f = ctx->v_fmt;
1129
1130 return 0;
1131}
1132
1133static int cal_enum_framesizes(struct file *file, void *fh,
1134 struct v4l2_frmsizeenum *fsize)
1135{
1136 struct cal_ctx *ctx = video_drvdata(file);
1137 const struct cal_fmt *fmt;
1138 struct v4l2_subdev_frame_size_enum fse;
1139 int ret;
1140
1141 /* check for valid format */
1142 fmt = find_format_by_pix(ctx, fsize->pixel_format);
1143 if (!fmt) {
1144 ctx_dbg(3, ctx, "Invalid pixel code: %x\n",
1145 fsize->pixel_format);
1146 return -EINVAL;
1147 }
1148
1149 fse.index = fsize->index;
1150 fse.pad = 0;
1151 fse.code = fmt->code;
1152
1153 ret = v4l2_subdev_call(ctx->sensor, pad, enum_frame_size, NULL, &fse);
1154 if (ret)
1155 return -EINVAL;
1156
1157 ctx_dbg(1, ctx, "%s: index: %d code: %x W:[%d,%d] H:[%d,%d]\n",
1158 __func__, fse.index, fse.code, fse.min_width, fse.max_width,
1159 fse.min_height, fse.max_height);
1160
1161 fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
1162 fsize->discrete.width = fse.max_width;
1163 fsize->discrete.height = fse.max_height;
1164
1165 return 0;
1166}
1167
1168static int cal_enum_input(struct file *file, void *priv,
1169 struct v4l2_input *inp)
1170{
1171 if (inp->index >= CAL_NUM_INPUT)
1172 return -EINVAL;
1173
1174 inp->type = V4L2_INPUT_TYPE_CAMERA;
1175 sprintf(inp->name, "Camera %u", inp->index);
1176 return 0;
1177}
1178
1179static int cal_g_input(struct file *file, void *priv, unsigned int *i)
1180{
1181 struct cal_ctx *ctx = video_drvdata(file);
1182
1183 *i = ctx->input;
1184 return 0;
1185}
1186
1187static int cal_s_input(struct file *file, void *priv, unsigned int i)
1188{
1189 struct cal_ctx *ctx = video_drvdata(file);
1190
1191 if (i >= CAL_NUM_INPUT)
1192 return -EINVAL;
1193
1194 ctx->input = i;
1195 return 0;
1196}
1197
1198/* timeperframe is arbitrary and continuous */
1199static int cal_enum_frameintervals(struct file *file, void *priv,
1200 struct v4l2_frmivalenum *fival)
1201{
1202 struct cal_ctx *ctx = video_drvdata(file);
1203 const struct cal_fmt *fmt;
1204 struct v4l2_subdev_frame_size_enum fse;
1205 int ret;
1206
1207 if (fival->index)
1208 return -EINVAL;
1209
1210 fmt = find_format_by_pix(ctx, fival->pixel_format);
1211 if (!fmt)
1212 return -EINVAL;
1213
1214 /* check for valid width/height */
1215 ret = 0;
1216 fse.pad = 0;
1217 fse.code = fmt->code;
1218 fse.which = V4L2_SUBDEV_FORMAT_ACTIVE;
1219 for (fse.index = 0; ; fse.index++) {
1220 ret = v4l2_subdev_call(ctx->sensor, pad, enum_frame_size,
1221 NULL, &fse);
1222 if (ret)
1223 return -EINVAL;
1224
1225 if ((fival->width == fse.max_width) &&
1226 (fival->height == fse.max_height))
1227 break;
1228 else if ((fival->width >= fse.min_width) &&
1229 (fival->width <= fse.max_width) &&
1230 (fival->height >= fse.min_height) &&
1231 (fival->height <= fse.max_height))
1232 break;
1233
1234 return -EINVAL;
1235 }
1236
1237 fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
1238 fival->discrete.numerator = 1;
1239 fival->discrete.denominator = 30;
1240
1241 return 0;
1242}
1243
1244/*
1245 * Videobuf operations
1246 */
1247static int cal_queue_setup(struct vb2_queue *vq,
1248 unsigned int *nbuffers, unsigned int *nplanes,
1249 unsigned int sizes[], void *alloc_ctxs[])
1250{
1251 struct cal_ctx *ctx = vb2_get_drv_priv(vq);
1252 unsigned size = ctx->v_fmt.fmt.pix.sizeimage;
1253
1254 if (vq->num_buffers + *nbuffers < 3)
1255 *nbuffers = 3 - vq->num_buffers;
1256 alloc_ctxs[0] = ctx->alloc_ctx;
1257
1258 if (*nplanes) {
1259 if (sizes[0] < size)
1260 return -EINVAL;
1261 size = sizes[0];
1262 }
1263
1264 *nplanes = 1;
1265 sizes[0] = size;
1266
1267 ctx_dbg(3, ctx, "nbuffers=%d, size=%d\n", *nbuffers, sizes[0]);
1268
1269 return 0;
1270}
1271
1272static int cal_buffer_prepare(struct vb2_buffer *vb)
1273{
1274 struct cal_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
1275 struct cal_buffer *buf = container_of(vb, struct cal_buffer,
1276 vb.vb2_buf);
1277 unsigned long size;
1278
1279 if (WARN_ON(!ctx->fmt))
1280 return -EINVAL;
1281
1282 size = ctx->v_fmt.fmt.pix.sizeimage;
1283 if (vb2_plane_size(vb, 0) < size) {
1284 ctx_err(ctx,
1285 "data will not fit into plane (%lu < %lu)\n",
1286 vb2_plane_size(vb, 0), size);
1287 return -EINVAL;
1288 }
1289
1290 vb2_set_plane_payload(&buf->vb.vb2_buf, 0, size);
1291 return 0;
1292}
1293
1294static void cal_buffer_queue(struct vb2_buffer *vb)
1295{
1296 struct cal_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
1297 struct cal_buffer *buf = container_of(vb, struct cal_buffer,
1298 vb.vb2_buf);
1299 struct cal_dmaqueue *vidq = &ctx->vidq;
1300 unsigned long flags = 0;
1301
1302 /* recheck locking */
1303 spin_lock_irqsave(&ctx->slock, flags);
1304 list_add_tail(&buf->list, &vidq->active);
1305 spin_unlock_irqrestore(&ctx->slock, flags);
1306}
1307
1308static int cal_start_streaming(struct vb2_queue *vq, unsigned int count)
1309{
1310 struct cal_ctx *ctx = vb2_get_drv_priv(vq);
1311 struct cal_dmaqueue *dma_q = &ctx->vidq;
1312 struct cal_buffer *buf, *tmp;
1313 unsigned long addr = 0;
1314 unsigned long flags;
1315 int ret;
1316
1317 spin_lock_irqsave(&ctx->slock, flags);
1318 if (list_empty(&dma_q->active)) {
1319 spin_unlock_irqrestore(&ctx->slock, flags);
1320 ctx_dbg(3, ctx, "buffer queue is empty\n");
1321 return -EIO;
1322 }
1323
1324 buf = list_entry(dma_q->active.next, struct cal_buffer, list);
1325 ctx->cur_frm = buf;
1326 ctx->next_frm = buf;
1327 list_del(&buf->list);
1328 spin_unlock_irqrestore(&ctx->slock, flags);
1329
1330 addr = vb2_dma_contig_plane_dma_addr(&ctx->cur_frm->vb.vb2_buf, 0);
1331 ctx->sequence = 0;
1332
1333 ret = cal_get_external_info(ctx);
1334 if (ret < 0)
1335 goto err;
1336
1337 cal_runtime_get(ctx->dev);
1338
1339 enable_irqs(ctx);
1340 camerarx_phy_enable(ctx);
1341 csi2_init(ctx);
1342 csi2_phy_config(ctx);
1343 csi2_lane_config(ctx);
1344 csi2_ctx_config(ctx);
1345 pix_proc_config(ctx);
1346 cal_wr_dma_config(ctx, ctx->v_fmt.fmt.pix.bytesperline);
1347 cal_wr_dma_addr(ctx, addr);
1348 csi2_ppi_enable(ctx);
1349
1350 if (ctx->sensor) {
1351 if (v4l2_subdev_call(ctx->sensor, video, s_stream, 1)) {
1352 ctx_err(ctx, "stream on failed in subdev\n");
1353 cal_runtime_put(ctx->dev);
1354 ret = -EINVAL;
1355 goto err;
1356 }
1357 }
1358
1359 if (debug >= 4)
1360 cal_quickdump_regs(ctx->dev);
1361
1362 return 0;
1363
1364err:
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_QUEUED);
1368 }
1369 return ret;
1370}
1371
1372static void cal_stop_streaming(struct vb2_queue *vq)
1373{
1374 struct cal_ctx *ctx = vb2_get_drv_priv(vq);
1375 struct cal_dmaqueue *dma_q = &ctx->vidq;
1376 struct cal_buffer *buf, *tmp;
1377 unsigned long flags;
1378
1379 if (ctx->sensor) {
1380 if (v4l2_subdev_call(ctx->sensor, video, s_stream, 0))
1381 ctx_err(ctx, "stream off failed in subdev\n");
1382 }
1383
1384 csi2_ppi_disable(ctx);
1385 disable_irqs(ctx);
1386
1387 /* Release all active buffers */
1388 spin_lock_irqsave(&ctx->slock, flags);
1389 list_for_each_entry_safe(buf, tmp, &dma_q->active, list) {
1390 list_del(&buf->list);
1391 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
1392 }
1393
1394 if (ctx->cur_frm == ctx->next_frm) {
1395 vb2_buffer_done(&ctx->cur_frm->vb.vb2_buf, VB2_BUF_STATE_ERROR);
1396 } else {
1397 vb2_buffer_done(&ctx->cur_frm->vb.vb2_buf, VB2_BUF_STATE_ERROR);
1398 vb2_buffer_done(&ctx->next_frm->vb.vb2_buf,
1399 VB2_BUF_STATE_ERROR);
1400 }
1401 ctx->cur_frm = NULL;
1402 ctx->next_frm = NULL;
1403 spin_unlock_irqrestore(&ctx->slock, flags);
1404
1405 cal_runtime_put(ctx->dev);
1406}
1407
1408static struct vb2_ops cal_video_qops = {
1409 .queue_setup = cal_queue_setup,
1410 .buf_prepare = cal_buffer_prepare,
1411 .buf_queue = cal_buffer_queue,
1412 .start_streaming = cal_start_streaming,
1413 .stop_streaming = cal_stop_streaming,
1414 .wait_prepare = vb2_ops_wait_prepare,
1415 .wait_finish = vb2_ops_wait_finish,
1416};
1417
1418static const struct v4l2_file_operations cal_fops = {
1419 .owner = THIS_MODULE,
1420 .open = v4l2_fh_open,
1421 .release = vb2_fop_release,
1422 .read = vb2_fop_read,
1423 .poll = vb2_fop_poll,
1424 .unlocked_ioctl = video_ioctl2, /* V4L2 ioctl handler */
1425 .mmap = vb2_fop_mmap,
1426};
1427
1428static const struct v4l2_ioctl_ops cal_ioctl_ops = {
1429 .vidioc_querycap = cal_querycap,
1430 .vidioc_enum_fmt_vid_cap = cal_enum_fmt_vid_cap,
1431 .vidioc_g_fmt_vid_cap = cal_g_fmt_vid_cap,
1432 .vidioc_try_fmt_vid_cap = cal_try_fmt_vid_cap,
1433 .vidioc_s_fmt_vid_cap = cal_s_fmt_vid_cap,
1434 .vidioc_enum_framesizes = cal_enum_framesizes,
1435 .vidioc_reqbufs = vb2_ioctl_reqbufs,
1436 .vidioc_create_bufs = vb2_ioctl_create_bufs,
1437 .vidioc_prepare_buf = vb2_ioctl_prepare_buf,
1438 .vidioc_querybuf = vb2_ioctl_querybuf,
1439 .vidioc_qbuf = vb2_ioctl_qbuf,
1440 .vidioc_dqbuf = vb2_ioctl_dqbuf,
1441 .vidioc_enum_input = cal_enum_input,
1442 .vidioc_g_input = cal_g_input,
1443 .vidioc_s_input = cal_s_input,
1444 .vidioc_enum_frameintervals = cal_enum_frameintervals,
1445 .vidioc_streamon = vb2_ioctl_streamon,
1446 .vidioc_streamoff = vb2_ioctl_streamoff,
1447 .vidioc_log_status = v4l2_ctrl_log_status,
1448 .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
1449 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
1450};
1451
1452static struct video_device cal_videodev = {
1453 .name = CAL_MODULE_NAME,
1454 .fops = &cal_fops,
1455 .ioctl_ops = &cal_ioctl_ops,
1456 .minor = -1,
1457 .release = video_device_release_empty,
1458};
1459
1460/* -----------------------------------------------------------------
1461 * Initialization and module stuff
1462 * ------------------------------------------------------------------
1463 */
1464static int cal_complete_ctx(struct cal_ctx *ctx);
1465
1466static int cal_async_bound(struct v4l2_async_notifier *notifier,
1467 struct v4l2_subdev *subdev,
1468 struct v4l2_async_subdev *asd)
1469{
1470 struct cal_ctx *ctx = notifier_to_ctx(notifier);
1471 struct v4l2_subdev_mbus_code_enum mbus_code;
1472 int ret = 0;
1473 int i, j, k;
1474
1475 if (ctx->sensor) {
1476 ctx_info(ctx, "Rejecting subdev %s (Already set!!)",
1477 subdev->name);
1478 return 0;
1479 }
1480
1481 ctx->sensor = subdev;
1482 ctx_dbg(1, ctx, "Using sensor %s for capture\n", subdev->name);
1483
1484 /* Enumerate sub device formats and enable all matching local formats */
1485 ctx->num_active_fmt = 0;
1486 for (j = 0, i = 0; ret != -EINVAL; ++j) {
1487 struct cal_fmt *fmt;
1488
1489 memset(&mbus_code, 0, sizeof(mbus_code));
1490 mbus_code.index = j;
1491 ret = v4l2_subdev_call(subdev, pad, enum_mbus_code,
1492 NULL, &mbus_code);
1493 if (ret)
1494 continue;
1495
1496 ctx_dbg(2, ctx,
1497 "subdev %s: code: %04x idx: %d\n",
1498 subdev->name, mbus_code.code, j);
1499
1500 for (k = 0; k < ARRAY_SIZE(cal_formats); k++) {
1501 fmt = &cal_formats[k];
1502
1503 if (mbus_code.code == fmt->code) {
1504 ctx->active_fmt[i] = fmt;
1505 ctx_dbg(2, ctx,
1506 "matched fourcc: %s: code: %04x idx: %d\n",
1507 fourcc_to_str(fmt->fourcc),
1508 fmt->code, i);
1509 ctx->num_active_fmt = ++i;
1510 }
1511 }
1512 }
1513
1514 if (i == 0) {
1515 ctx_err(ctx, "No suitable format reported by subdev %s\n",
1516 subdev->name);
1517 return -EINVAL;
1518 }
1519
1520 cal_complete_ctx(ctx);
1521
1522 return 0;
1523}
1524
1525static int cal_async_complete(struct v4l2_async_notifier *notifier)
1526{
1527 struct cal_ctx *ctx = notifier_to_ctx(notifier);
1528 const struct cal_fmt *fmt;
1529 struct v4l2_mbus_framefmt mbus_fmt;
1530 int ret;
1531
1532 ret = __subdev_get_format(ctx, &mbus_fmt);
1533 if (ret)
1534 return ret;
1535
1536 fmt = find_format_by_code(ctx, mbus_fmt.code);
1537 if (!fmt) {
1538 ctx_dbg(3, ctx, "mbus code format (0x%08x) not found.\n",
1539 mbus_fmt.code);
1540 return -EINVAL;
1541 }
1542
1543 /* Save current subdev format */
1544 v4l2_fill_pix_format(&ctx->v_fmt.fmt.pix, &mbus_fmt);
1545 ctx->v_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1546 ctx->v_fmt.fmt.pix.pixelformat = fmt->fourcc;
1547 cal_calc_format_size(ctx, fmt, &ctx->v_fmt);
1548 ctx->fmt = fmt;
1549 ctx->m_fmt = mbus_fmt;
1550
1551 return 0;
1552}
1553
1554static int cal_complete_ctx(struct cal_ctx *ctx)
1555{
1556 struct video_device *vfd;
1557 struct vb2_queue *q;
1558 int ret;
1559
1560 ctx->timeperframe = tpf_default;
1561 ctx->external_rate = 192000000;
1562
1563 /* initialize locks */
1564 spin_lock_init(&ctx->slock);
1565 mutex_init(&ctx->mutex);
1566
1567 /* initialize queue */
1568 q = &ctx->vb_vidq;
1569 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1570 q->io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ;
1571 q->drv_priv = ctx;
1572 q->buf_struct_size = sizeof(struct cal_buffer);
1573 q->ops = &cal_video_qops;
1574 q->mem_ops = &vb2_dma_contig_memops;
1575 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1576 q->lock = &ctx->mutex;
1577 q->min_buffers_needed = 3;
1578
1579 ret = vb2_queue_init(q);
1580 if (ret)
1581 return ret;
1582
1583 /* init video dma queues */
1584 INIT_LIST_HEAD(&ctx->vidq.active);
1585
1586 vfd = &ctx->vdev;
1587 *vfd = cal_videodev;
1588 vfd->v4l2_dev = &ctx->v4l2_dev;
1589 vfd->queue = q;
1590
1591 /*
1592 * Provide a mutex to v4l2 core. It will be used to protect
1593 * all fops and v4l2 ioctls.
1594 */
1595 vfd->lock = &ctx->mutex;
1596 video_set_drvdata(vfd, ctx);
1597
1598 ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr);
1599 if (ret < 0)
1600 return ret;
1601
1602 v4l2_info(&ctx->v4l2_dev, "V4L2 device registered as %s\n",
1603 video_device_node_name(vfd));
1604
1605 ctx->alloc_ctx = vb2_dma_contig_init_ctx(vfd->v4l2_dev->dev);
1606 if (IS_ERR(ctx->alloc_ctx)) {
1607 ctx_err(ctx, "Failed to alloc vb2 context\n");
1608 ret = PTR_ERR(ctx->alloc_ctx);
1609 goto vdev_unreg;
1610 }
1611
1612 return 0;
1613
1614vdev_unreg:
1615 video_unregister_device(vfd);
1616 return ret;
1617}
1618
1619static struct device_node *
1620of_get_next_port(const struct device_node *parent,
1621 struct device_node *prev)
1622{
1623 struct device_node *port = NULL;
1624
1625 if (!parent)
1626 return NULL;
1627
1628 if (!prev) {
1629 struct device_node *ports;
1630 /*
1631 * It's the first call, we have to find a port subnode
1632 * within this node or within an optional 'ports' node.
1633 */
1634 ports = of_get_child_by_name(parent, "ports");
1635 if (ports)
1636 parent = ports;
1637
1638 port = of_get_child_by_name(parent, "port");
1639
1640 /* release the 'ports' node */
1641 of_node_put(ports);
1642 } else {
1643 struct device_node *ports;
1644
1645 ports = of_get_parent(prev);
1646 if (!ports)
1647 return NULL;
1648
1649 do {
1650 port = of_get_next_child(ports, prev);
1651 if (!port) {
1652 of_node_put(ports);
1653 return NULL;
1654 }
1655 prev = port;
1656 } while (of_node_cmp(port->name, "port") != 0);
1657 }
1658
1659 return port;
1660}
1661
1662static struct device_node *
1663of_get_next_endpoint(const struct device_node *parent,
1664 struct device_node *prev)
1665{
1666 struct device_node *ep = NULL;
1667
1668 if (!parent)
1669 return NULL;
1670
1671 do {
1672 ep = of_get_next_child(parent, prev);
1673 if (!ep)
1674 return NULL;
1675 prev = ep;
1676 } while (of_node_cmp(ep->name, "endpoint") != 0);
1677
1678 return ep;
1679}
1680
1681static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
1682{
1683 struct platform_device *pdev = ctx->dev->pdev;
1684 struct device_node *ep_node, *port, *remote_ep,
1685 *sensor_node, *parent;
1686 struct v4l2_of_endpoint *endpoint;
1687 struct v4l2_async_subdev *asd;
1688 u32 regval = 0;
1689 int ret, index, found_port = 0, lane;
1690
1691 parent = pdev->dev.of_node;
1692
1693 asd = &ctx->asd;
1694 endpoint = &ctx->endpoint;
1695
1696 ep_node = NULL;
1697 port = NULL;
1698 remote_ep = NULL;
1699 sensor_node = NULL;
1700 ret = -EINVAL;
1701
1702 ctx_dbg(3, ctx, "Scanning Port node for csi2 port: %d\n", inst);
1703 for (index = 0; index < CAL_NUM_CSI2_PORTS; index++) {
1704 port = of_get_next_port(parent, port);
1705 if (!port) {
1706 ctx_dbg(1, ctx, "No port node found for csi2 port:%d\n",
1707 index);
1708 goto cleanup_exit;
1709 }
1710
1711 /* Match the slice number with <REG> */
1712 of_property_read_u32(port, "reg", &regval);
1713 ctx_dbg(3, ctx, "port:%d inst:%d <reg>:%d\n",
1714 index, inst, regval);
1715 if ((regval == inst) && (index == inst)) {
1716 found_port = 1;
1717 break;
1718 }
1719 }
1720
1721 if (!found_port) {
1722 ctx_dbg(1, ctx, "No port node matches csi2 port:%d\n",
1723 inst);
1724 goto cleanup_exit;
1725 }
1726
1727 ctx_dbg(3, ctx, "Scanning sub-device for csi2 port: %d\n",
1728 inst);
1729
1730 ep_node = of_get_next_endpoint(port, ep_node);
1731 if (!ep_node) {
1732 ctx_dbg(3, ctx, "can't get next endpoint\n");
1733 goto cleanup_exit;
1734 }
1735
1736 sensor_node = of_graph_get_remote_port_parent(ep_node);
1737 if (!sensor_node) {
1738 ctx_dbg(3, ctx, "can't get remote parent\n");
1739 goto cleanup_exit;
1740 }
1741 asd->match_type = V4L2_ASYNC_MATCH_OF;
1742 asd->match.of.node = sensor_node;
1743
1744 remote_ep = of_parse_phandle(ep_node, "remote-endpoint", 0);
1745 if (!remote_ep) {
1746 ctx_dbg(3, ctx, "can't get remote-endpoint\n");
1747 goto cleanup_exit;
1748 }
1749 v4l2_of_parse_endpoint(remote_ep, endpoint);
1750
1751 if (endpoint->bus_type != V4L2_MBUS_CSI2) {
1752 ctx_err(ctx, "Port:%d sub-device %s is not a CSI2 device\n",
1753 inst, sensor_node->name);
1754 goto cleanup_exit;
1755 }
1756
1757 /* Store Virtual Channel number */
1758 ctx->virtual_channel = endpoint->base.id;
1759
1760 ctx_dbg(3, ctx, "Port:%d v4l2-endpoint: CSI2\n", inst);
1761 ctx_dbg(3, ctx, "Virtual Channel=%d\n", ctx->virtual_channel);
1762 ctx_dbg(3, ctx, "flags=0x%08x\n", endpoint->bus.mipi_csi2.flags);
1763 ctx_dbg(3, ctx, "clock_lane=%d\n", endpoint->bus.mipi_csi2.clock_lane);
1764 ctx_dbg(3, ctx, "num_data_lanes=%d\n",
1765 endpoint->bus.mipi_csi2.num_data_lanes);
1766 ctx_dbg(3, ctx, "data_lanes= <\n");
1767 for (lane = 0; lane < endpoint->bus.mipi_csi2.num_data_lanes; lane++)
1768 ctx_dbg(3, ctx, "\t%d\n",
1769 endpoint->bus.mipi_csi2.data_lanes[lane]);
1770 ctx_dbg(3, ctx, "\t>\n");
1771
1772 ctx_dbg(1, ctx, "Port: %d found sub-device %s\n",
1773 inst, sensor_node->name);
1774
1775 ctx->asd_list[0] = asd;
1776 ctx->notifier.subdevs = ctx->asd_list;
1777 ctx->notifier.num_subdevs = 1;
1778 ctx->notifier.bound = cal_async_bound;
1779 ctx->notifier.complete = cal_async_complete;
1780 ret = v4l2_async_notifier_register(&ctx->v4l2_dev,
1781 &ctx->notifier);
1782 if (ret) {
1783 ctx_err(ctx, "Error registering async notifier\n");
1784 ret = -EINVAL;
1785 }
1786
1787cleanup_exit:
1788 if (!remote_ep)
1789 of_node_put(remote_ep);
1790 if (!sensor_node)
1791 of_node_put(sensor_node);
1792 if (!ep_node)
1793 of_node_put(ep_node);
1794 if (!port)
1795 of_node_put(port);
1796
1797 return ret;
1798}
1799
1800static struct cal_ctx *cal_create_instance(struct cal_dev *dev, int inst)
1801{
1802 struct cal_ctx *ctx;
1803 struct v4l2_ctrl_handler *hdl;
1804 int ret;
1805
1806 ctx = devm_kzalloc(&dev->pdev->dev, sizeof(*ctx), GFP_KERNEL);
1807 if (!ctx)
1808 return NULL;
1809
1810 /* save the cal_dev * for future ref */
1811 ctx->dev = dev;
1812
1813 snprintf(ctx->v4l2_dev.name, sizeof(ctx->v4l2_dev.name),
1814 "%s-%03d", CAL_MODULE_NAME, inst);
1815 ret = v4l2_device_register(&dev->pdev->dev, &ctx->v4l2_dev);
1816 if (ret)
1817 goto err_exit;
1818
1819 hdl = &ctx->ctrl_handler;
1820 ret = v4l2_ctrl_handler_init(hdl, 11);
1821 if (ret) {
1822 ctx_err(ctx, "Failed to init ctrl handler\n");
1823 goto unreg_dev;
1824 }
1825 ctx->v4l2_dev.ctrl_handler = hdl;
1826
1827 /* Make sure Camera Core H/W register area is available */
1828 ctx->cc = dev->cc[inst];
1829
1830 /* Store the instance id */
1831 ctx->csi2_port = inst + 1;
1832
1833 ret = of_cal_create_instance(ctx, inst);
1834 if (ret) {
1835 ret = -EINVAL;
1836 goto free_hdl;
1837 }
1838 return ctx;
1839
1840free_hdl:
1841 v4l2_ctrl_handler_free(hdl);
1842unreg_dev:
1843 v4l2_device_unregister(&ctx->v4l2_dev);
1844err_exit:
1845 return NULL;
1846}
1847
1848static int cal_probe(struct platform_device *pdev)
1849{
1850 struct cal_dev *dev;
1851 int ret;
1852 int irq;
1853
1854 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
1855 if (!dev)
1856 return -ENOMEM;
1857
1858 /* set pseudo v4l2 device name so we can use v4l2_printk */
1859 strlcpy(dev->v4l2_dev.name, CAL_MODULE_NAME,
1860 sizeof(dev->v4l2_dev.name));
1861
1862 /* save pdev pointer */
1863 dev->pdev = pdev;
1864
1865 dev->res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
1866 "cal_top");
1867 dev->base = devm_ioremap_resource(&pdev->dev, dev->res);
1868 if (IS_ERR(dev->base))
1869 return PTR_ERR(dev->base);
1870
1871 cal_dbg(1, dev, "ioresource %s at %pa - %pa\n",
1872 dev->res->name, &dev->res->start, &dev->res->end);
1873
1874 irq = platform_get_irq(pdev, 0);
1875 cal_dbg(1, dev, "got irq# %d\n", irq);
1876 ret = devm_request_irq(&pdev->dev, irq, cal_irq, 0, CAL_MODULE_NAME,
1877 dev);
1878 if (ret)
1879 return ret;
1880
1881 platform_set_drvdata(pdev, dev);
1882
1883 dev->cm = cm_create(dev);
1884 if (IS_ERR(dev->cm))
1885 return PTR_ERR(dev->cm);
1886
1887 dev->cc[0] = cc_create(dev, 0);
1888 if (IS_ERR(dev->cc[0]))
1889 return PTR_ERR(dev->cc[0]);
1890
1891 dev->cc[1] = cc_create(dev, 1);
1892 if (IS_ERR(dev->cc[1]))
1893 return PTR_ERR(dev->cc[1]);
1894
1895 dev->ctx[0] = NULL;
1896 dev->ctx[1] = NULL;
1897
1898 dev->ctx[0] = cal_create_instance(dev, 0);
1899 dev->ctx[1] = cal_create_instance(dev, 1);
1900 if (!dev->ctx[0] && !dev->ctx[1]) {
1901 cal_err(dev, "Neither port is configured, no point in staying up\n");
1902 return -ENODEV;
1903 }
1904
1905 pm_runtime_enable(&pdev->dev);
1906
1907 ret = cal_runtime_get(dev);
1908 if (ret)
1909 goto runtime_disable;
1910
1911 /* Just check we can actually access the module */
1912 cal_get_hwinfo(dev);
1913
1914 cal_runtime_put(dev);
1915
1916 return 0;
1917
1918runtime_disable:
1919 pm_runtime_disable(&pdev->dev);
1920 return ret;
1921}
1922
1923static int cal_remove(struct platform_device *pdev)
1924{
1925 struct cal_dev *dev =
1926 (struct cal_dev *)platform_get_drvdata(pdev);
1927 struct cal_ctx *ctx;
1928 int i;
1929
1930 cal_dbg(1, dev, "Removing %s\n", CAL_MODULE_NAME);
1931
1932 cal_runtime_get(dev);
1933
1934 for (i = 0; i < CAL_NUM_CONTEXT; i++) {
1935 ctx = dev->ctx[i];
1936 if (ctx) {
1937 ctx_dbg(1, ctx, "unregistering %s\n",
1938 video_device_node_name(&ctx->vdev));
1939 camerarx_phy_disable(ctx);
1940 v4l2_async_notifier_unregister(&ctx->notifier);
1941 vb2_dma_contig_cleanup_ctx(ctx->alloc_ctx);
1942 v4l2_ctrl_handler_free(&ctx->ctrl_handler);
1943 v4l2_device_unregister(&ctx->v4l2_dev);
1944 video_unregister_device(&ctx->vdev);
1945 }
1946 }
1947
1948 cal_runtime_put(dev);
1949 pm_runtime_disable(&pdev->dev);
1950
1951 return 0;
1952}
1953
1954#if defined(CONFIG_OF)
1955static const struct of_device_id cal_of_match[] = {
1956 { .compatible = "ti,dra72-cal", },
1957 {},
1958};
1959MODULE_DEVICE_TABLE(of, cal_of_match);
1960#endif
1961
1962static struct platform_driver cal_pdrv = {
1963 .probe = cal_probe,
1964 .remove = cal_remove,
1965 .driver = {
1966 .name = CAL_MODULE_NAME,
1967 .of_match_table = of_match_ptr(cal_of_match),
1968 },
1969};
1970
1971module_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.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/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..61ee0f92c1e5 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_io(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/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
index 18adf580f502..c96da3aaf00b 100644
--- a/drivers/media/rc/nuvoton-cir.c
+++ b/drivers/media/rc/nuvoton-cir.c
@@ -80,17 +80,24 @@ static inline void nvt_clear_reg_bit(struct nvt_dev *nvt, u8 val, u8 reg)
80} 80}
81 81
82/* enter extended function mode */ 82/* enter extended function mode */
83static inline void nvt_efm_enable(struct nvt_dev *nvt) 83static inline int nvt_efm_enable(struct nvt_dev *nvt)
84{ 84{
85 if (!request_muxed_region(nvt->cr_efir, 2, NVT_DRIVER_NAME))
86 return -EBUSY;
87
85 /* Enabling Extended Function Mode explicitly requires writing 2x */ 88 /* Enabling Extended Function Mode explicitly requires writing 2x */
86 outb(EFER_EFM_ENABLE, nvt->cr_efir); 89 outb(EFER_EFM_ENABLE, nvt->cr_efir);
87 outb(EFER_EFM_ENABLE, nvt->cr_efir); 90 outb(EFER_EFM_ENABLE, nvt->cr_efir);
91
92 return 0;
88} 93}
89 94
90/* exit extended function mode */ 95/* exit extended function mode */
91static inline void nvt_efm_disable(struct nvt_dev *nvt) 96static inline void nvt_efm_disable(struct nvt_dev *nvt)
92{ 97{
93 outb(EFER_EFM_DISABLE, nvt->cr_efir); 98 outb(EFER_EFM_DISABLE, nvt->cr_efir);
99
100 release_region(nvt->cr_efir, 2);
94} 101}
95 102
96/* 103/*
@@ -100,8 +107,25 @@ static inline void nvt_efm_disable(struct nvt_dev *nvt)
100 */ 107 */
101static inline void nvt_select_logical_dev(struct nvt_dev *nvt, u8 ldev) 108static inline void nvt_select_logical_dev(struct nvt_dev *nvt, u8 ldev)
102{ 109{
103 outb(CR_LOGICAL_DEV_SEL, nvt->cr_efir); 110 nvt_cr_write(nvt, ldev, CR_LOGICAL_DEV_SEL);
104 outb(ldev, nvt->cr_efdr); 111}
112
113/* select and enable logical device with setting EFM mode*/
114static inline void nvt_enable_logical_dev(struct nvt_dev *nvt, u8 ldev)
115{
116 nvt_efm_enable(nvt);
117 nvt_select_logical_dev(nvt, ldev);
118 nvt_cr_write(nvt, LOGICAL_DEV_ENABLE, CR_LOGICAL_DEV_EN);
119 nvt_efm_disable(nvt);
120}
121
122/* select and disable logical device with setting EFM mode*/
123static inline void nvt_disable_logical_dev(struct nvt_dev *nvt, u8 ldev)
124{
125 nvt_efm_enable(nvt);
126 nvt_select_logical_dev(nvt, ldev);
127 nvt_cr_write(nvt, LOGICAL_DEV_DISABLE, CR_LOGICAL_DEV_EN);
128 nvt_efm_disable(nvt);
105} 129}
106 130
107/* write val to cir config register */ 131/* write val to cir config register */
@@ -137,6 +161,22 @@ static u8 nvt_cir_wake_reg_read(struct nvt_dev *nvt, u8 offset)
137 return val; 161 return val;
138} 162}
139 163
164/* don't override io address if one is set already */
165static void nvt_set_ioaddr(struct nvt_dev *nvt, unsigned long *ioaddr)
166{
167 unsigned long old_addr;
168
169 old_addr = nvt_cr_read(nvt, CR_CIR_BASE_ADDR_HI) << 8;
170 old_addr |= nvt_cr_read(nvt, CR_CIR_BASE_ADDR_LO);
171
172 if (old_addr)
173 *ioaddr = old_addr;
174 else {
175 nvt_cr_write(nvt, *ioaddr >> 8, CR_CIR_BASE_ADDR_HI);
176 nvt_cr_write(nvt, *ioaddr & 0xff, CR_CIR_BASE_ADDR_LO);
177 }
178}
179
140/* dump current cir register contents */ 180/* dump current cir register contents */
141static void cir_dump_regs(struct nvt_dev *nvt) 181static void cir_dump_regs(struct nvt_dev *nvt)
142{ 182{
@@ -251,7 +291,7 @@ static inline const char *nvt_find_chip(struct nvt_dev *nvt, int id)
251 291
252 292
253/* detect hardware features */ 293/* detect hardware features */
254static void nvt_hw_detect(struct nvt_dev *nvt) 294static int nvt_hw_detect(struct nvt_dev *nvt)
255{ 295{
256 const char *chip_name; 296 const char *chip_name;
257 int chip_id; 297 int chip_id;
@@ -266,10 +306,17 @@ static void nvt_hw_detect(struct nvt_dev *nvt)
266 nvt_efm_enable(nvt); 306 nvt_efm_enable(nvt);
267 nvt->chip_major = nvt_cr_read(nvt, CR_CHIP_ID_HI); 307 nvt->chip_major = nvt_cr_read(nvt, CR_CHIP_ID_HI);
268 } 308 }
269
270 nvt->chip_minor = nvt_cr_read(nvt, CR_CHIP_ID_LO); 309 nvt->chip_minor = nvt_cr_read(nvt, CR_CHIP_ID_LO);
271 310
311 nvt_efm_disable(nvt);
312
272 chip_id = nvt->chip_major << 8 | nvt->chip_minor; 313 chip_id = nvt->chip_major << 8 | nvt->chip_minor;
314 if (chip_id == NVT_INVALID) {
315 dev_err(&nvt->pdev->dev,
316 "No device found on either EFM port\n");
317 return -ENODEV;
318 }
319
273 chip_name = nvt_find_chip(nvt, chip_id); 320 chip_name = nvt_find_chip(nvt, chip_id);
274 321
275 /* warn, but still let the driver load, if we don't know this chip */ 322 /* warn, but still let the driver load, if we don't know this chip */
@@ -282,7 +329,7 @@ static void nvt_hw_detect(struct nvt_dev *nvt)
282 "found %s or compatible: chip id: 0x%02x 0x%02x", 329 "found %s or compatible: chip id: 0x%02x 0x%02x",
283 chip_name, nvt->chip_major, nvt->chip_minor); 330 chip_name, nvt->chip_major, nvt->chip_minor);
284 331
285 nvt_efm_disable(nvt); 332 return 0;
286} 333}
287 334
288static void nvt_cir_ldev_init(struct nvt_dev *nvt) 335static void nvt_cir_ldev_init(struct nvt_dev *nvt)
@@ -305,12 +352,10 @@ static void nvt_cir_ldev_init(struct nvt_dev *nvt)
305 val |= psval; 352 val |= psval;
306 nvt_cr_write(nvt, val, psreg); 353 nvt_cr_write(nvt, val, psreg);
307 354
308 /* Select CIR logical device and enable */ 355 /* Select CIR logical device */
309 nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR); 356 nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR);
310 nvt_cr_write(nvt, LOGICAL_DEV_ENABLE, CR_LOGICAL_DEV_EN);
311 357
312 nvt_cr_write(nvt, nvt->cir_addr >> 8, CR_CIR_BASE_ADDR_HI); 358 nvt_set_ioaddr(nvt, &nvt->cir_addr);
313 nvt_cr_write(nvt, nvt->cir_addr & 0xff, CR_CIR_BASE_ADDR_LO);
314 359
315 nvt_cr_write(nvt, nvt->cir_irq, CR_CIR_IRQ_RSRC); 360 nvt_cr_write(nvt, nvt->cir_irq, CR_CIR_IRQ_RSRC);
316 361
@@ -320,7 +365,7 @@ static void nvt_cir_ldev_init(struct nvt_dev *nvt)
320 365
321static void nvt_cir_wake_ldev_init(struct nvt_dev *nvt) 366static void nvt_cir_wake_ldev_init(struct nvt_dev *nvt)
322{ 367{
323 /* Select ACPI logical device, enable it and CIR Wake */ 368 /* Select ACPI logical device and anable it */
324 nvt_select_logical_dev(nvt, LOGICAL_DEV_ACPI); 369 nvt_select_logical_dev(nvt, LOGICAL_DEV_ACPI);
325 nvt_cr_write(nvt, LOGICAL_DEV_ENABLE, CR_LOGICAL_DEV_EN); 370 nvt_cr_write(nvt, LOGICAL_DEV_ENABLE, CR_LOGICAL_DEV_EN);
326 371
@@ -330,12 +375,10 @@ static void nvt_cir_wake_ldev_init(struct nvt_dev *nvt)
330 /* enable pme interrupt of cir wakeup event */ 375 /* enable pme interrupt of cir wakeup event */
331 nvt_set_reg_bit(nvt, PME_INTR_CIR_PASS_BIT, CR_ACPI_IRQ_EVENTS2); 376 nvt_set_reg_bit(nvt, PME_INTR_CIR_PASS_BIT, CR_ACPI_IRQ_EVENTS2);
332 377
333 /* Select CIR Wake logical device and enable */ 378 /* Select CIR Wake logical device */
334 nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR_WAKE); 379 nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR_WAKE);
335 nvt_cr_write(nvt, LOGICAL_DEV_ENABLE, CR_LOGICAL_DEV_EN);
336 380
337 nvt_cr_write(nvt, nvt->cir_wake_addr >> 8, CR_CIR_BASE_ADDR_HI); 381 nvt_set_ioaddr(nvt, &nvt->cir_wake_addr);
338 nvt_cr_write(nvt, nvt->cir_wake_addr & 0xff, CR_CIR_BASE_ADDR_LO);
339 382
340 nvt_cr_write(nvt, nvt->cir_wake_irq, CR_CIR_IRQ_RSRC); 383 nvt_cr_write(nvt, nvt->cir_wake_irq, CR_CIR_IRQ_RSRC);
341 384
@@ -355,11 +398,19 @@ static void nvt_clear_cir_fifo(struct nvt_dev *nvt)
355/* clear out the hardware's cir wake rx fifo */ 398/* clear out the hardware's cir wake rx fifo */
356static void nvt_clear_cir_wake_fifo(struct nvt_dev *nvt) 399static void nvt_clear_cir_wake_fifo(struct nvt_dev *nvt)
357{ 400{
358 u8 val; 401 u8 val, config;
402
403 config = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRCON);
404
405 /* clearing wake fifo works in learning mode only */
406 nvt_cir_wake_reg_write(nvt, config & ~CIR_WAKE_IRCON_MODE0,
407 CIR_WAKE_IRCON);
359 408
360 val = nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFOCON); 409 val = nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFOCON);
361 nvt_cir_wake_reg_write(nvt, val | CIR_WAKE_FIFOCON_RXFIFOCLR, 410 nvt_cir_wake_reg_write(nvt, val | CIR_WAKE_FIFOCON_RXFIFOCLR,
362 CIR_WAKE_FIFOCON); 411 CIR_WAKE_FIFOCON);
412
413 nvt_cir_wake_reg_write(nvt, config, CIR_WAKE_IRCON);
363} 414}
364 415
365/* clear out the hardware's cir tx fifo */ 416/* clear out the hardware's cir tx fifo */
@@ -408,6 +459,9 @@ static void nvt_cir_regs_init(struct nvt_dev *nvt)
408 459
409 /* and finally, enable interrupts */ 460 /* and finally, enable interrupts */
410 nvt_set_cir_iren(nvt); 461 nvt_set_cir_iren(nvt);
462
463 /* enable the CIR logical device */
464 nvt_enable_logical_dev(nvt, LOGICAL_DEV_CIR);
411} 465}
412 466
413static void nvt_cir_wake_regs_init(struct nvt_dev *nvt) 467static void nvt_cir_wake_regs_init(struct nvt_dev *nvt)
@@ -442,10 +496,15 @@ static void nvt_cir_wake_regs_init(struct nvt_dev *nvt)
442 496
443 /* clear any and all stray interrupts */ 497 /* clear any and all stray interrupts */
444 nvt_cir_wake_reg_write(nvt, 0xff, CIR_WAKE_IRSTS); 498 nvt_cir_wake_reg_write(nvt, 0xff, CIR_WAKE_IRSTS);
499
500 /* enable the CIR WAKE logical device */
501 nvt_enable_logical_dev(nvt, LOGICAL_DEV_CIR_WAKE);
445} 502}
446 503
447static void nvt_enable_wake(struct nvt_dev *nvt) 504static void nvt_enable_wake(struct nvt_dev *nvt)
448{ 505{
506 unsigned long flags;
507
449 nvt_efm_enable(nvt); 508 nvt_efm_enable(nvt);
450 509
451 nvt_select_logical_dev(nvt, LOGICAL_DEV_ACPI); 510 nvt_select_logical_dev(nvt, LOGICAL_DEV_ACPI);
@@ -457,12 +516,16 @@ static void nvt_enable_wake(struct nvt_dev *nvt)
457 516
458 nvt_efm_disable(nvt); 517 nvt_efm_disable(nvt);
459 518
519 spin_lock_irqsave(&nvt->nvt_lock, flags);
520
460 nvt_cir_wake_reg_write(nvt, CIR_WAKE_IRCON_MODE0 | CIR_WAKE_IRCON_RXEN | 521 nvt_cir_wake_reg_write(nvt, CIR_WAKE_IRCON_MODE0 | CIR_WAKE_IRCON_RXEN |
461 CIR_WAKE_IRCON_R | CIR_WAKE_IRCON_RXINV | 522 CIR_WAKE_IRCON_R | CIR_WAKE_IRCON_RXINV |
462 CIR_WAKE_IRCON_SAMPLE_PERIOD_SEL, 523 CIR_WAKE_IRCON_SAMPLE_PERIOD_SEL,
463 CIR_WAKE_IRCON); 524 CIR_WAKE_IRCON);
464 nvt_cir_wake_reg_write(nvt, 0xff, CIR_WAKE_IRSTS); 525 nvt_cir_wake_reg_write(nvt, 0xff, CIR_WAKE_IRSTS);
465 nvt_cir_wake_reg_write(nvt, 0, CIR_WAKE_IREN); 526 nvt_cir_wake_reg_write(nvt, 0, CIR_WAKE_IREN);
527
528 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
466} 529}
467 530
468#if 0 /* Currently unused */ 531#if 0 /* Currently unused */
@@ -670,7 +733,6 @@ static void nvt_handle_rx_fifo_overrun(struct nvt_dev *nvt)
670/* copy data from hardware rx fifo into driver buffer */ 733/* copy data from hardware rx fifo into driver buffer */
671static void nvt_get_rx_ir_data(struct nvt_dev *nvt) 734static void nvt_get_rx_ir_data(struct nvt_dev *nvt)
672{ 735{
673 unsigned long flags;
674 u8 fifocount, val; 736 u8 fifocount, val;
675 unsigned int b_idx; 737 unsigned int b_idx;
676 bool overrun = false; 738 bool overrun = false;
@@ -689,8 +751,6 @@ static void nvt_get_rx_ir_data(struct nvt_dev *nvt)
689 751
690 nvt_dbg("attempting to fetch %u bytes from hw rx fifo", fifocount); 752 nvt_dbg("attempting to fetch %u bytes from hw rx fifo", fifocount);
691 753
692 spin_lock_irqsave(&nvt->nvt_lock, flags);
693
694 b_idx = nvt->pkts; 754 b_idx = nvt->pkts;
695 755
696 /* This should never happen, but lets check anyway... */ 756 /* This should never happen, but lets check anyway... */
@@ -712,8 +772,6 @@ static void nvt_get_rx_ir_data(struct nvt_dev *nvt)
712 772
713 if (overrun) 773 if (overrun)
714 nvt_handle_rx_fifo_overrun(nvt); 774 nvt_handle_rx_fifo_overrun(nvt);
715
716 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
717} 775}
718 776
719static void nvt_cir_log_irqs(u8 status, u8 iren) 777static void nvt_cir_log_irqs(u8 status, u8 iren)
@@ -736,16 +794,13 @@ static void nvt_cir_log_irqs(u8 status, u8 iren)
736static bool nvt_cir_tx_inactive(struct nvt_dev *nvt) 794static bool nvt_cir_tx_inactive(struct nvt_dev *nvt)
737{ 795{
738 unsigned long flags; 796 unsigned long flags;
739 bool tx_inactive;
740 u8 tx_state; 797 u8 tx_state;
741 798
742 spin_lock_irqsave(&nvt->tx.lock, flags); 799 spin_lock_irqsave(&nvt->tx.lock, flags);
743 tx_state = nvt->tx.tx_state; 800 tx_state = nvt->tx.tx_state;
744 spin_unlock_irqrestore(&nvt->tx.lock, flags); 801 spin_unlock_irqrestore(&nvt->tx.lock, flags);
745 802
746 tx_inactive = (tx_state == ST_TX_NONE); 803 return tx_state == ST_TX_NONE;
747
748 return tx_inactive;
749} 804}
750 805
751/* interrupt service routine for incoming and outgoing CIR data */ 806/* interrupt service routine for incoming and outgoing CIR data */
@@ -757,9 +812,7 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
757 812
758 nvt_dbg_verbose("%s firing", __func__); 813 nvt_dbg_verbose("%s firing", __func__);
759 814
760 nvt_efm_enable(nvt); 815 spin_lock_irqsave(&nvt->nvt_lock, flags);
761 nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR);
762 nvt_efm_disable(nvt);
763 816
764 /* 817 /*
765 * Get IR Status register contents. Write 1 to ack/clear 818 * Get IR Status register contents. Write 1 to ack/clear
@@ -775,9 +828,14 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
775 * 0: CIR_IRSTS_GH - Min Length Detected 828 * 0: CIR_IRSTS_GH - Min Length Detected
776 */ 829 */
777 status = nvt_cir_reg_read(nvt, CIR_IRSTS); 830 status = nvt_cir_reg_read(nvt, CIR_IRSTS);
778 if (!status) { 831 iren = nvt_cir_reg_read(nvt, CIR_IREN);
832
833 /* IRQ may be shared with CIR WAKE, therefore check for each
834 * status bit whether the related interrupt source is enabled
835 */
836 if (!(status & iren)) {
837 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
779 nvt_dbg_verbose("%s exiting, IRSTS 0x0", __func__); 838 nvt_dbg_verbose("%s exiting, IRSTS 0x0", __func__);
780 nvt_cir_reg_write(nvt, 0xff, CIR_IRSTS);
781 return IRQ_NONE; 839 return IRQ_NONE;
782 } 840 }
783 841
@@ -785,13 +843,6 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
785 nvt_cir_reg_write(nvt, status, CIR_IRSTS); 843 nvt_cir_reg_write(nvt, status, CIR_IRSTS);
786 nvt_cir_reg_write(nvt, 0, CIR_IRSTS); 844 nvt_cir_reg_write(nvt, 0, CIR_IRSTS);
787 845
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); 846 nvt_cir_log_irqs(status, iren);
796 847
797 if (status & CIR_IRSTS_RTR) { 848 if (status & CIR_IRSTS_RTR) {
@@ -805,16 +856,14 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
805 if (nvt_cir_tx_inactive(nvt)) 856 if (nvt_cir_tx_inactive(nvt))
806 nvt_get_rx_ir_data(nvt); 857 nvt_get_rx_ir_data(nvt);
807 858
808 spin_lock_irqsave(&nvt->nvt_lock, flags);
809
810 cur_state = nvt->study_state; 859 cur_state = nvt->study_state;
811 860
812 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
813
814 if (cur_state == ST_STUDY_NONE) 861 if (cur_state == ST_STUDY_NONE)
815 nvt_clear_cir_fifo(nvt); 862 nvt_clear_cir_fifo(nvt);
816 } 863 }
817 864
865 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
866
818 if (status & CIR_IRSTS_TE) 867 if (status & CIR_IRSTS_TE)
819 nvt_clear_tx_fifo(nvt); 868 nvt_clear_tx_fifo(nvt);
820 869
@@ -863,9 +912,18 @@ static irqreturn_t nvt_cir_wake_isr(int irq, void *data)
863 912
864 nvt_dbg_wake("%s firing", __func__); 913 nvt_dbg_wake("%s firing", __func__);
865 914
915 spin_lock_irqsave(&nvt->nvt_lock, flags);
916
866 status = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRSTS); 917 status = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRSTS);
867 if (!status) 918 iren = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IREN);
919
920 /* IRQ may be shared with CIR, therefore check for each
921 * status bit whether the related interrupt source is enabled
922 */
923 if (!(status & iren)) {
924 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
868 return IRQ_NONE; 925 return IRQ_NONE;
926 }
869 927
870 if (status & CIR_WAKE_IRSTS_IR_PENDING) 928 if (status & CIR_WAKE_IRSTS_IR_PENDING)
871 nvt_clear_cir_wake_fifo(nvt); 929 nvt_clear_cir_wake_fifo(nvt);
@@ -873,13 +931,6 @@ static irqreturn_t nvt_cir_wake_isr(int irq, void *data)
873 nvt_cir_wake_reg_write(nvt, status, CIR_WAKE_IRSTS); 931 nvt_cir_wake_reg_write(nvt, status, CIR_WAKE_IRSTS);
874 nvt_cir_wake_reg_write(nvt, 0, CIR_WAKE_IRSTS); 932 nvt_cir_wake_reg_write(nvt, 0, CIR_WAKE_IRSTS);
875 933
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) && 934 if ((status & CIR_WAKE_IRSTS_PE) &&
884 (nvt->wake_state == ST_WAKE_START)) { 935 (nvt->wake_state == ST_WAKE_START)) {
885 while (nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY_IDX)) { 936 while (nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY_IDX)) {
@@ -888,39 +939,21 @@ static irqreturn_t nvt_cir_wake_isr(int irq, void *data)
888 } 939 }
889 940
890 nvt_cir_wake_reg_write(nvt, 0, CIR_WAKE_IREN); 941 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; 942 nvt->wake_state = ST_WAKE_FINISH;
893 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
894 } 943 }
895 944
945 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
946
896 nvt_dbg_wake("%s done", __func__); 947 nvt_dbg_wake("%s done", __func__);
897 return IRQ_HANDLED; 948 return IRQ_HANDLED;
898} 949}
899 950
900static void nvt_enable_cir(struct nvt_dev *nvt) 951static void nvt_disable_cir(struct nvt_dev *nvt)
901{ 952{
902 /* set function enable flags */ 953 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 954
918 /* enable interrupts */ 955 spin_lock_irqsave(&nvt->nvt_lock, flags);
919 nvt_set_cir_iren(nvt);
920}
921 956
922static void nvt_disable_cir(struct nvt_dev *nvt)
923{
924 /* disable CIR interrupts */ 957 /* disable CIR interrupts */
925 nvt_cir_reg_write(nvt, 0, CIR_IREN); 958 nvt_cir_reg_write(nvt, 0, CIR_IREN);
926 959
@@ -934,13 +967,10 @@ static void nvt_disable_cir(struct nvt_dev *nvt)
934 nvt_clear_cir_fifo(nvt); 967 nvt_clear_cir_fifo(nvt);
935 nvt_clear_tx_fifo(nvt); 968 nvt_clear_tx_fifo(nvt);
936 969
937 nvt_efm_enable(nvt); 970 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
938 971
939 /* disable the CIR logical device */ 972 /* disable the CIR logical device */
940 nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR); 973 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} 974}
945 975
946static int nvt_open(struct rc_dev *dev) 976static int nvt_open(struct rc_dev *dev)
@@ -949,20 +979,31 @@ static int nvt_open(struct rc_dev *dev)
949 unsigned long flags; 979 unsigned long flags;
950 980
951 spin_lock_irqsave(&nvt->nvt_lock, flags); 981 spin_lock_irqsave(&nvt->nvt_lock, flags);
952 nvt_enable_cir(nvt); 982
983 /* set function enable flags */
984 nvt_cir_reg_write(nvt, CIR_IRCON_TXEN | CIR_IRCON_RXEN |
985 CIR_IRCON_RXINV | CIR_IRCON_SAMPLE_PERIOD_SEL,
986 CIR_IRCON);
987
988 /* clear all pending interrupts */
989 nvt_cir_reg_write(nvt, 0xff, CIR_IRSTS);
990
991 /* enable interrupts */
992 nvt_set_cir_iren(nvt);
993
953 spin_unlock_irqrestore(&nvt->nvt_lock, flags); 994 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
954 995
996 /* enable the CIR logical device */
997 nvt_enable_logical_dev(nvt, LOGICAL_DEV_CIR);
998
955 return 0; 999 return 0;
956} 1000}
957 1001
958static void nvt_close(struct rc_dev *dev) 1002static void nvt_close(struct rc_dev *dev)
959{ 1003{
960 struct nvt_dev *nvt = dev->priv; 1004 struct nvt_dev *nvt = dev->priv;
961 unsigned long flags;
962 1005
963 spin_lock_irqsave(&nvt->nvt_lock, flags);
964 nvt_disable_cir(nvt); 1006 nvt_disable_cir(nvt);
965 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
966} 1007}
967 1008
968/* Allocate memory, probe hardware, and initialize everything */ 1009/* Allocate memory, probe hardware, and initialize everything */
@@ -1024,7 +1065,9 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1024 1065
1025 init_waitqueue_head(&nvt->tx.queue); 1066 init_waitqueue_head(&nvt->tx.queue);
1026 1067
1027 nvt_hw_detect(nvt); 1068 ret = nvt_hw_detect(nvt);
1069 if (ret)
1070 goto exit_free_dev_rdev;
1028 1071
1029 /* Initialize CIR & CIR Wake Logical Devices */ 1072 /* Initialize CIR & CIR Wake Logical Devices */
1030 nvt_efm_enable(nvt); 1073 nvt_efm_enable(nvt);
@@ -1032,7 +1075,10 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1032 nvt_cir_wake_ldev_init(nvt); 1075 nvt_cir_wake_ldev_init(nvt);
1033 nvt_efm_disable(nvt); 1076 nvt_efm_disable(nvt);
1034 1077
1035 /* Initialize CIR & CIR Wake Config Registers */ 1078 /*
1079 * Initialize CIR & CIR Wake Config Registers
1080 * and enable logical devices
1081 */
1036 nvt_cir_regs_init(nvt); 1082 nvt_cir_regs_init(nvt);
1037 nvt_cir_wake_regs_init(nvt); 1083 nvt_cir_wake_regs_init(nvt);
1038 1084
@@ -1079,12 +1125,12 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1079 goto exit_unregister_device; 1125 goto exit_unregister_device;
1080 1126
1081 if (!devm_request_region(&pdev->dev, nvt->cir_wake_addr, 1127 if (!devm_request_region(&pdev->dev, nvt->cir_wake_addr,
1082 CIR_IOREG_LENGTH, NVT_DRIVER_NAME)) 1128 CIR_IOREG_LENGTH, NVT_DRIVER_NAME "-wake"))
1083 goto exit_unregister_device; 1129 goto exit_unregister_device;
1084 1130
1085 if (devm_request_irq(&pdev->dev, nvt->cir_wake_irq, 1131 if (devm_request_irq(&pdev->dev, nvt->cir_wake_irq,
1086 nvt_cir_wake_isr, IRQF_SHARED, 1132 nvt_cir_wake_isr, IRQF_SHARED,
1087 NVT_DRIVER_NAME, (void *)nvt)) 1133 NVT_DRIVER_NAME "-wake", (void *)nvt))
1088 goto exit_unregister_device; 1134 goto exit_unregister_device;
1089 1135
1090 device_init_wakeup(&pdev->dev, true); 1136 device_init_wakeup(&pdev->dev, true);
@@ -1109,15 +1155,11 @@ exit_free_dev_rdev:
1109static void nvt_remove(struct pnp_dev *pdev) 1155static void nvt_remove(struct pnp_dev *pdev)
1110{ 1156{
1111 struct nvt_dev *nvt = pnp_get_drvdata(pdev); 1157 struct nvt_dev *nvt = pnp_get_drvdata(pdev);
1112 unsigned long flags;
1113 1158
1114 spin_lock_irqsave(&nvt->nvt_lock, flags);
1115 /* disable CIR */
1116 nvt_cir_reg_write(nvt, 0, CIR_IREN);
1117 nvt_disable_cir(nvt); 1159 nvt_disable_cir(nvt);
1160
1118 /* enable CIR Wake (for IR power-on) */ 1161 /* enable CIR Wake (for IR power-on) */
1119 nvt_enable_wake(nvt); 1162 nvt_enable_wake(nvt);
1120 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
1121 1163
1122 rc_unregister_device(nvt->rdev); 1164 rc_unregister_device(nvt->rdev);
1123} 1165}
@@ -1129,26 +1171,23 @@ static int nvt_suspend(struct pnp_dev *pdev, pm_message_t state)
1129 1171
1130 nvt_dbg("%s called", __func__); 1172 nvt_dbg("%s called", __func__);
1131 1173
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); 1174 spin_lock_irqsave(&nvt->tx.lock, flags);
1139 nvt->tx.tx_state = ST_TX_NONE; 1175 nvt->tx.tx_state = ST_TX_NONE;
1140 spin_unlock_irqrestore(&nvt->tx.lock, flags); 1176 spin_unlock_irqrestore(&nvt->tx.lock, flags);
1141 1177
1178 spin_lock_irqsave(&nvt->nvt_lock, flags);
1179
1180 /* zero out misc state tracking */
1181 nvt->study_state = ST_STUDY_NONE;
1182 nvt->wake_state = ST_WAKE_NONE;
1183
1142 /* disable all CIR interrupts */ 1184 /* disable all CIR interrupts */
1143 nvt_cir_reg_write(nvt, 0, CIR_IREN); 1185 nvt_cir_reg_write(nvt, 0, CIR_IREN);
1144 1186
1145 nvt_efm_enable(nvt); 1187 spin_unlock_irqrestore(&nvt->nvt_lock, flags);
1146 1188
1147 /* disable cir logical dev */ 1189 /* disable cir logical dev */
1148 nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR); 1190 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 1191
1153 /* make sure wake is enabled */ 1192 /* make sure wake is enabled */
1154 nvt_enable_wake(nvt); 1193 nvt_enable_wake(nvt);
@@ -1162,16 +1201,6 @@ static int nvt_resume(struct pnp_dev *pdev)
1162 1201
1163 nvt_dbg("%s called", __func__); 1202 nvt_dbg("%s called", __func__);
1164 1203
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); 1204 nvt_cir_regs_init(nvt);
1176 nvt_cir_wake_regs_init(nvt); 1205 nvt_cir_wake_regs_init(nvt);
1177 1206
@@ -1181,6 +1210,7 @@ static int nvt_resume(struct pnp_dev *pdev)
1181static void nvt_shutdown(struct pnp_dev *pdev) 1210static void nvt_shutdown(struct pnp_dev *pdev)
1182{ 1211{
1183 struct nvt_dev *nvt = pnp_get_drvdata(pdev); 1212 struct nvt_dev *nvt = pnp_get_drvdata(pdev);
1213
1184 nvt_enable_wake(nvt); 1214 nvt_enable_wake(nvt);
1185} 1215}
1186 1216
diff --git a/drivers/media/rc/nuvoton-cir.h b/drivers/media/rc/nuvoton-cir.h
index 0ad15d34e9c9..4a5650dffa29 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
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..dcf20d9cbe09 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -723,12 +723,18 @@ int rc_open(struct rc_dev *rdev)
723 return -EINVAL; 723 return -EINVAL;
724 724
725 mutex_lock(&rdev->lock); 725 mutex_lock(&rdev->lock);
726 if (!rdev->initialized) {
727 rval = -EINVAL;
728 goto unlock;
729 }
730
726 if (!rdev->users++ && rdev->open != NULL) 731 if (!rdev->users++ && rdev->open != NULL)
727 rval = rdev->open(rdev); 732 rval = rdev->open(rdev);
728 733
729 if (rval) 734 if (rval)
730 rdev->users--; 735 rdev->users--;
731 736
737unlock:
732 mutex_unlock(&rdev->lock); 738 mutex_unlock(&rdev->lock);
733 739
734 return rval; 740 return rval;
@@ -874,6 +880,10 @@ static ssize_t show_protocols(struct device *device,
874 return -EINVAL; 880 return -EINVAL;
875 881
876 mutex_lock(&dev->lock); 882 mutex_lock(&dev->lock);
883 if (!dev->initialized) {
884 mutex_unlock(&dev->lock);
885 return -EINVAL;
886 }
877 887
878 if (fattr->type == RC_FILTER_NORMAL) { 888 if (fattr->type == RC_FILTER_NORMAL) {
879 enabled = dev->enabled_protocols; 889 enabled = dev->enabled_protocols;
@@ -1074,6 +1084,10 @@ static ssize_t store_protocols(struct device *device,
1074 } 1084 }
1075 1085
1076 mutex_lock(&dev->lock); 1086 mutex_lock(&dev->lock);
1087 if (!dev->initialized) {
1088 rc = -EINVAL;
1089 goto out;
1090 }
1077 1091
1078 old_protocols = *current_protocols; 1092 old_protocols = *current_protocols;
1079 new_protocols = old_protocols; 1093 new_protocols = old_protocols;
@@ -1154,12 +1168,17 @@ static ssize_t show_filter(struct device *device,
1154 if (!dev) 1168 if (!dev)
1155 return -EINVAL; 1169 return -EINVAL;
1156 1170
1171 mutex_lock(&dev->lock);
1172 if (!dev->initialized) {
1173 mutex_unlock(&dev->lock);
1174 return -EINVAL;
1175 }
1176
1157 if (fattr->type == RC_FILTER_NORMAL) 1177 if (fattr->type == RC_FILTER_NORMAL)
1158 filter = &dev->scancode_filter; 1178 filter = &dev->scancode_filter;
1159 else 1179 else
1160 filter = &dev->scancode_wakeup_filter; 1180 filter = &dev->scancode_wakeup_filter;
1161 1181
1162 mutex_lock(&dev->lock);
1163 if (fattr->mask) 1182 if (fattr->mask)
1164 val = filter->mask; 1183 val = filter->mask;
1165 else 1184 else
@@ -1222,6 +1241,10 @@ static ssize_t store_filter(struct device *device,
1222 return -EINVAL; 1241 return -EINVAL;
1223 1242
1224 mutex_lock(&dev->lock); 1243 mutex_lock(&dev->lock);
1244 if (!dev->initialized) {
1245 ret = -EINVAL;
1246 goto unlock;
1247 }
1225 1248
1226 new_filter = *filter; 1249 new_filter = *filter;
1227 if (fattr->mask) 1250 if (fattr->mask)
@@ -1419,14 +1442,6 @@ int rc_register_device(struct rc_dev *dev)
1419 dev->sysfs_groups[attr++] = &rc_dev_wakeup_protocol_attr_grp; 1442 dev->sysfs_groups[attr++] = &rc_dev_wakeup_protocol_attr_grp;
1420 dev->sysfs_groups[attr++] = NULL; 1443 dev->sysfs_groups[attr++] = NULL;
1421 1444
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); 1445 rc = device_add(&dev->dev);
1431 if (rc) 1446 if (rc)
1432 goto out_unlock; 1447 goto out_unlock;
@@ -1440,13 +1455,7 @@ int rc_register_device(struct rc_dev *dev)
1440 dev->input_dev->phys = dev->input_phys; 1455 dev->input_dev->phys = dev->input_phys;
1441 dev->input_dev->name = dev->input_name; 1456 dev->input_dev->name = dev->input_name;
1442 1457
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); 1458 rc = input_register_device(dev->input_dev);
1447
1448 mutex_lock(&dev->lock);
1449
1450 if (rc) 1459 if (rc)
1451 goto out_table; 1460 goto out_table;
1452 1461
@@ -1475,10 +1484,7 @@ int rc_register_device(struct rc_dev *dev)
1475 request_module_nowait("ir-lirc-codec"); 1484 request_module_nowait("ir-lirc-codec");
1476 raw_init = true; 1485 raw_init = true;
1477 } 1486 }
1478 /* calls ir_register_device so unlock mutex here*/
1479 mutex_unlock(&dev->lock);
1480 rc = ir_raw_event_register(dev); 1487 rc = ir_raw_event_register(dev);
1481 mutex_lock(&dev->lock);
1482 if (rc < 0) 1488 if (rc < 0)
1483 goto out_input; 1489 goto out_input;
1484 } 1490 }
@@ -1491,6 +1497,8 @@ int rc_register_device(struct rc_dev *dev)
1491 dev->enabled_protocols = rc_type; 1497 dev->enabled_protocols = rc_type;
1492 } 1498 }
1493 1499
1500 mutex_lock(&dev->lock);
1501 dev->initialized = true;
1494 mutex_unlock(&dev->lock); 1502 mutex_unlock(&dev->lock);
1495 1503
1496 IR_dprintk(1, "Registered rc%u (driver: %s, remote: %s, mode %s)\n", 1504 IR_dprintk(1, "Registered rc%u (driver: %s, remote: %s, mode %s)\n",
@@ -1512,7 +1520,6 @@ out_table:
1512out_dev: 1520out_dev:
1513 device_del(&dev->dev); 1521 device_del(&dev->dev);
1514out_unlock: 1522out_unlock:
1515 mutex_unlock(&dev->lock);
1516 ida_simple_remove(&rc_ida, minor); 1523 ida_simple_remove(&rc_ida, minor);
1517 return rc; 1524 return rc;
1518} 1525}
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/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..7cafe4dd5fd1 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -143,7 +143,7 @@ static void au0828_unregister_media_device(struct au0828_dev *dev)
143#endif 143#endif
144} 144}
145 145
146static void au0828_usb_release(struct au0828_dev *dev) 146void au0828_usb_release(struct au0828_dev *dev)
147{ 147{
148 au0828_unregister_media_device(dev); 148 au0828_unregister_media_device(dev);
149 149
@@ -153,33 +153,6 @@ static void au0828_usb_release(struct au0828_dev *dev)
153 kfree(dev); 153 kfree(dev);
154} 154}
155 155
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) 156static void au0828_usb_disconnect(struct usb_interface *interface)
184{ 157{
185 struct au0828_dev *dev = usb_get_intfdata(interface); 158 struct au0828_dev *dev = usb_get_intfdata(interface);
@@ -202,18 +175,13 @@ static void au0828_usb_disconnect(struct usb_interface *interface)
202 mutex_lock(&dev->mutex); 175 mutex_lock(&dev->mutex);
203 dev->usbdev = NULL; 176 dev->usbdev = NULL;
204 mutex_unlock(&dev->mutex); 177 mutex_unlock(&dev->mutex);
205#ifdef CONFIG_VIDEO_AU0828_V4L2 178 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 /* 179 /*
211 * No need to call au0828_usb_release() if V4L2 is enabled, 180 * No need to call au0828_usb_release() if V4L2 is enabled,
212 * as this is already called via au0828_usb_v4l2_release() 181 * as this is already called via au0828_usb_v4l2_release()
213 */ 182 */
214 return; 183 return;
215 } 184 }
216#endif
217 au0828_usb_release(dev); 185 au0828_usb_release(dev);
218} 186}
219 187
@@ -223,23 +191,12 @@ static int au0828_media_device_init(struct au0828_dev *dev,
223#ifdef CONFIG_MEDIA_CONTROLLER 191#ifdef CONFIG_MEDIA_CONTROLLER
224 struct media_device *mdev; 192 struct media_device *mdev;
225 193
226 mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
227 if (!mdev)
228 return -ENOMEM;
229
230 mdev->dev = &udev->dev;
231
232 if (!dev->board.name) 194 if (!dev->board.name)
233 strlcpy(mdev->model, "unknown au0828", sizeof(mdev->model)); 195 mdev = v4l2_mc_usb_media_device_init(udev, "unknown au0828");
234 else 196 else
235 strlcpy(mdev->model, dev->board.name, sizeof(mdev->model)); 197 mdev = v4l2_mc_usb_media_device_init(udev, dev->board.name);
236 if (udev->serial) 198 if (!mdev)
237 strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial)); 199 return -ENOMEM;
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 200
244 dev->media_dev = mdev; 201 dev->media_dev = mdev;
245#endif 202#endif
@@ -247,83 +204,6 @@ static int au0828_media_device_init(struct au0828_dev *dev,
247} 204}
248 205
249 206
250static int au0828_create_media_graph(struct au0828_dev *dev)
251{
252#ifdef CONFIG_MEDIA_CONTROLLER
253 struct media_device *mdev = dev->media_dev;
254 struct media_entity *entity;
255 struct media_entity *tuner = NULL, *decoder = NULL;
256 int i, ret;
257
258 if (!mdev)
259 return 0;
260
261 media_device_for_each_entity(entity, mdev) {
262 switch (entity->function) {
263 case MEDIA_ENT_F_TUNER:
264 tuner = entity;
265 break;
266 case MEDIA_ENT_F_ATV_DECODER:
267 decoder = entity;
268 break;
269 }
270 }
271
272 /* Analog setup, using tuner as a link */
273
274 /* Something bad happened! */
275 if (!decoder)
276 return -EINVAL;
277
278 if (tuner) {
279 ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT,
280 decoder, 0,
281 MEDIA_LNK_FL_ENABLED);
282 if (ret)
283 return ret;
284 }
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
294 for (i = 0; i < AU0828_MAX_INPUT; i++) {
295 struct media_entity *ent = &dev->input_ent[i];
296
297 if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
298 break;
299
300 switch (AUVI_INPUT(i).type) {
301 case AU0828_VMUX_CABLE:
302 case AU0828_VMUX_TELEVISION:
303 case AU0828_VMUX_DVB:
304 if (!tuner)
305 break;
306
307 ret = media_create_pad_link(ent, 0, tuner,
308 TUNER_PAD_RF_INPUT,
309 MEDIA_LNK_FL_ENABLED);
310 if (ret)
311 return ret;
312 break;
313 case AU0828_VMUX_COMPOSITE:
314 case AU0828_VMUX_SVIDEO:
315 default: /* AU0828_VMUX_DEBUG */
316 /* FIXME: fix the decoder PAD */
317 ret = media_create_pad_link(ent, 0, decoder, 0, 0);
318 if (ret)
319 return ret;
320 break;
321 }
322 }
323#endif
324 return 0;
325}
326
327static int au0828_usb_probe(struct usb_interface *interface, 207static int au0828_usb_probe(struct usb_interface *interface,
328 const struct usb_device_id *id) 208 const struct usb_device_id *id)
329{ 209{
@@ -378,32 +258,13 @@ static int au0828_usb_probe(struct usb_interface *interface,
378 return retval; 258 return retval;
379 } 259 }
380 260
381#ifdef CONFIG_VIDEO_AU0828_V4L2 261 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) { 262 if (retval) {
390 pr_err("%s() v4l2_device_register failed\n", 263 au0828_usb_v4l2_media_release(dev);
391 __func__);
392 mutex_unlock(&dev->lock); 264 mutex_unlock(&dev->lock);
393 kfree(dev); 265 kfree(dev);
394 return retval; 266 return retval;
395 } 267 }
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 268
408 /* Power Up the bridge */ 269 /* Power Up the bridge */
409 au0828_write(dev, REG_600, 1 << 4); 270 au0828_write(dev, REG_600, 1 << 4);
@@ -417,11 +278,13 @@ static int au0828_usb_probe(struct usb_interface *interface,
417 /* Setup */ 278 /* Setup */
418 au0828_card_setup(dev); 279 au0828_card_setup(dev);
419 280
420#ifdef CONFIG_VIDEO_AU0828_V4L2
421 /* Analog TV */ 281 /* Analog TV */
422 if (AUVI_INPUT(0).type != AU0828_VMUX_UNDEFINED) 282 retval = au0828_analog_register(dev, interface);
423 au0828_analog_register(dev, interface); 283 if (retval) {
424#endif 284 pr_err("%s() au0282_dev_register failed to register on V4L2\n",
285 __func__);
286 goto done;
287 }
425 288
426 /* Digital TV */ 289 /* Digital TV */
427 retval = au0828_dvb_register(dev); 290 retval = au0828_dvb_register(dev);
@@ -443,13 +306,6 @@ static int au0828_usb_probe(struct usb_interface *interface,
443 306
444 mutex_unlock(&dev->lock); 307 mutex_unlock(&dev->lock);
445 308
446 retval = au0828_create_media_graph(dev);
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 309#ifdef CONFIG_MEDIA_CONTROLLER
454 retval = media_device_register(dev->media_dev); 310 retval = media_device_register(dev->media_dev);
455#endif 311#endif
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 8c54fd21022e..2fc2b29d2dd9 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -638,6 +638,142 @@ static inline int au0828_isoc_copy(struct au0828_dev *dev, struct urb *urb)
638 return rc; 638 return rc;
639} 639}
640 640
641void au0828_usb_v4l2_media_release(struct au0828_dev *dev)
642{
643#ifdef CONFIG_MEDIA_CONTROLLER
644 int i;
645
646 for (i = 0; i < AU0828_MAX_INPUT; i++) {
647 if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
648 return;
649 media_device_unregister_entity(&dev->input_ent[i]);
650 }
651#endif
652}
653
654static int au0828_create_media_graph(struct au0828_dev *dev)
655{
656#ifdef CONFIG_MEDIA_CONTROLLER
657 struct media_device *mdev = dev->media_dev;
658 struct media_entity *entity;
659 struct media_entity *tuner = NULL, *decoder = NULL;
660 int i, ret;
661
662 if (!mdev)
663 return 0;
664
665 media_device_for_each_entity(entity, mdev) {
666 switch (entity->function) {
667 case MEDIA_ENT_F_TUNER:
668 tuner = entity;
669 break;
670 case MEDIA_ENT_F_ATV_DECODER:
671 decoder = entity;
672 break;
673 }
674 }
675
676 /* Analog setup, using tuner as a link */
677
678 /* Something bad happened! */
679 if (!decoder)
680 return -EINVAL;
681
682 if (tuner) {
683 ret = media_create_pad_link(tuner, TUNER_PAD_OUTPUT,
684 decoder, 0,
685 MEDIA_LNK_FL_ENABLED);
686 if (ret)
687 return ret;
688 }
689 ret = media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
690 MEDIA_LNK_FL_ENABLED);
691 if (ret)
692 return ret;
693 ret = media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0,
694 MEDIA_LNK_FL_ENABLED);
695 if (ret)
696 return ret;
697
698 for (i = 0; i < AU0828_MAX_INPUT; i++) {
699 struct media_entity *ent = &dev->input_ent[i];
700
701 switch (AUVI_INPUT(i).type) {
702 case AU0828_VMUX_UNDEFINED:
703 break;
704 case AU0828_VMUX_CABLE:
705 case AU0828_VMUX_TELEVISION:
706 case AU0828_VMUX_DVB:
707 if (!tuner)
708 break;
709
710 ret = media_create_pad_link(ent, 0, tuner,
711 TUNER_PAD_RF_INPUT,
712 MEDIA_LNK_FL_ENABLED);
713 if (ret)
714 return ret;
715 break;
716 case AU0828_VMUX_COMPOSITE:
717 case AU0828_VMUX_SVIDEO:
718 /* FIXME: fix the decoder PAD */
719 ret = media_create_pad_link(ent, 0, decoder, 0, 0);
720 if (ret)
721 return ret;
722 break;
723 }
724 }
725#endif
726 return 0;
727}
728
729static void au0828_usb_v4l2_release(struct v4l2_device *v4l2_dev)
730{
731 struct au0828_dev *dev =
732 container_of(v4l2_dev, struct au0828_dev, v4l2_dev);
733
734 v4l2_ctrl_handler_free(&dev->v4l2_ctrl_hdl);
735 v4l2_device_unregister(&dev->v4l2_dev);
736 au0828_usb_v4l2_media_release(dev);
737 au0828_usb_release(dev);
738}
739
740int au0828_v4l2_device_register(struct usb_interface *interface,
741 struct au0828_dev *dev)
742{
743 int retval;
744
745 if (AUVI_INPUT(0).type == AU0828_VMUX_UNDEFINED)
746 return 0;
747
748 /* Create the v4l2_device */
749#ifdef CONFIG_MEDIA_CONTROLLER
750 dev->v4l2_dev.mdev = dev->media_dev;
751#endif
752 retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev);
753 if (retval) {
754 pr_err("%s() v4l2_device_register failed\n",
755 __func__);
756 mutex_unlock(&dev->lock);
757 kfree(dev);
758 return retval;
759 }
760
761 dev->v4l2_dev.release = au0828_usb_v4l2_release;
762
763 /* This control handler will inherit the controls from au8522 */
764 retval = v4l2_ctrl_handler_init(&dev->v4l2_ctrl_hdl, 4);
765 if (retval) {
766 pr_err("%s() v4l2_ctrl_handler_init failed\n",
767 __func__);
768 mutex_unlock(&dev->lock);
769 kfree(dev);
770 return retval;
771 }
772 dev->v4l2_dev.ctrl_handler = &dev->v4l2_ctrl_hdl;
773
774 return 0;
775}
776
641static int au0828_enable_analog_tuner(struct au0828_dev *dev) 777static int au0828_enable_analog_tuner(struct au0828_dev *dev)
642{ 778{
643#ifdef CONFIG_MEDIA_CONTROLLER 779#ifdef CONFIG_MEDIA_CONTROLLER
@@ -949,13 +1085,23 @@ static struct vb2_ops au0828_video_qops = {
949 * au0828_analog_unregister 1085 * au0828_analog_unregister
950 * unregister v4l2 devices 1086 * unregister v4l2 devices
951 */ 1087 */
952void au0828_analog_unregister(struct au0828_dev *dev) 1088int au0828_analog_unregister(struct au0828_dev *dev)
953{ 1089{
954 dprintk(1, "au0828_analog_unregister called\n"); 1090 dprintk(1, "au0828_analog_unregister called\n");
1091
1092 /* No analog TV */
1093 if (AUVI_INPUT(0).type == AU0828_VMUX_UNDEFINED)
1094 return 0;
1095
955 mutex_lock(&au0828_sysfs_lock); 1096 mutex_lock(&au0828_sysfs_lock);
956 video_unregister_device(&dev->vdev); 1097 video_unregister_device(&dev->vdev);
957 video_unregister_device(&dev->vbi_dev); 1098 video_unregister_device(&dev->vbi_dev);
958 mutex_unlock(&au0828_sysfs_lock); 1099 mutex_unlock(&au0828_sysfs_lock);
1100
1101 v4l2_device_disconnect(&dev->v4l2_dev);
1102 v4l2_device_put(&dev->v4l2_dev);
1103
1104 return 1;
959} 1105}
960 1106
961/* This function ensures that video frames continue to be delivered even if 1107/* This function ensures that video frames continue to be delivered even if
@@ -1312,7 +1458,6 @@ static int vidioc_enum_input(struct file *file, void *priv,
1312 [AU0828_VMUX_CABLE] = "Cable TV", 1458 [AU0828_VMUX_CABLE] = "Cable TV",
1313 [AU0828_VMUX_TELEVISION] = "Television", 1459 [AU0828_VMUX_TELEVISION] = "Television",
1314 [AU0828_VMUX_DVB] = "DVB", 1460 [AU0828_VMUX_DVB] = "DVB",
1315 [AU0828_VMUX_DEBUG] = "tv debug"
1316 }; 1461 };
1317 1462
1318 dprintk(1, "%s called std_set %d dev_state %d\n", __func__, 1463 dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
@@ -1804,7 +1949,6 @@ static void au0828_analog_create_entities(struct au0828_dev *dev)
1804 [AU0828_VMUX_CABLE] = "Cable TV", 1949 [AU0828_VMUX_CABLE] = "Cable TV",
1805 [AU0828_VMUX_TELEVISION] = "Television", 1950 [AU0828_VMUX_TELEVISION] = "Television",
1806 [AU0828_VMUX_DVB] = "DVB", 1951 [AU0828_VMUX_DVB] = "DVB",
1807 [AU0828_VMUX_DEBUG] = "tv debug"
1808 }; 1952 };
1809 int ret, i; 1953 int ret, i;
1810 1954
@@ -1840,11 +1984,9 @@ static void au0828_analog_create_entities(struct au0828_dev *dev)
1840 case AU0828_VMUX_CABLE: 1984 case AU0828_VMUX_CABLE:
1841 case AU0828_VMUX_TELEVISION: 1985 case AU0828_VMUX_TELEVISION:
1842 case AU0828_VMUX_DVB: 1986 case AU0828_VMUX_DVB:
1987 default: /* Just to shut up a warning */
1843 ent->function = MEDIA_ENT_F_CONN_RF; 1988 ent->function = MEDIA_ENT_F_CONN_RF;
1844 break; 1989 break;
1845 default: /* AU0828_VMUX_DEBUG */
1846 ent->function = MEDIA_ENT_F_CONN_TEST;
1847 break;
1848 } 1990 }
1849 1991
1850 ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]); 1992 ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]);
@@ -1871,6 +2013,10 @@ int au0828_analog_register(struct au0828_dev *dev,
1871 dprintk(1, "au0828_analog_register called for intf#%d!\n", 2013 dprintk(1, "au0828_analog_register called for intf#%d!\n",
1872 interface->cur_altsetting->desc.bInterfaceNumber); 2014 interface->cur_altsetting->desc.bInterfaceNumber);
1873 2015
2016 /* No analog TV */
2017 if (AUVI_INPUT(0).type == AU0828_VMUX_UNDEFINED)
2018 return 0;
2019
1874 /* set au0828 usb interface0 to as5 */ 2020 /* set au0828 usb interface0 to as5 */
1875 retval = usb_set_interface(dev->usbdev, 2021 retval = usb_set_interface(dev->usbdev,
1876 interface->cur_altsetting->desc.bInterfaceNumber, 5); 2022 interface->cur_altsetting->desc.bInterfaceNumber, 5);
@@ -1976,6 +2122,14 @@ int au0828_analog_register(struct au0828_dev *dev,
1976 ret = -ENODEV; 2122 ret = -ENODEV;
1977 goto err_reg_vbi_dev; 2123 goto err_reg_vbi_dev;
1978 } 2124 }
2125 retval = au0828_create_media_graph(dev);
2126 if (retval) {
2127 pr_err("%s() au0282_dev_register failed to create graph\n",
2128 __func__);
2129 ret = -ENODEV;
2130 goto err_reg_vbi_dev;
2131 }
2132
1979 2133
1980 dprintk(1, "%s completed!\n", __func__); 2134 dprintk(1, "%s completed!\n", __func__);
1981 2135
diff --git a/drivers/media/usb/au0828/au0828.h b/drivers/media/usb/au0828/au0828.h
index 8276072bc55a..23f869cf11da 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 {
@@ -301,6 +300,7 @@ struct au0828_dev {
301/* au0828-core.c */ 300/* au0828-core.c */
302extern u32 au0828_read(struct au0828_dev *dev, u16 reg); 301extern u32 au0828_read(struct au0828_dev *dev, u16 reg);
303extern u32 au0828_write(struct au0828_dev *dev, u16 reg, u32 val); 302extern u32 au0828_write(struct au0828_dev *dev, u16 reg, u32 val);
303extern void au0828_usb_release(struct au0828_dev *dev);
304extern int au0828_debug; 304extern int au0828_debug;
305 305
306/* ----------------------------------------------------------- */ 306/* ----------------------------------------------------------- */
@@ -319,16 +319,29 @@ extern int au0828_i2c_unregister(struct au0828_dev *dev);
319 319
320/* ----------------------------------------------------------- */ 320/* ----------------------------------------------------------- */
321/* au0828-video.c */ 321/* 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, 322extern int au0828_start_analog_streaming(struct vb2_queue *vq,
326 unsigned int count); 323 unsigned int count);
327extern void au0828_stop_vbi_streaming(struct vb2_queue *vq); 324extern void au0828_stop_vbi_streaming(struct vb2_queue *vq);
328#ifdef CONFIG_VIDEO_AU0828_V4L2 325#ifdef CONFIG_VIDEO_AU0828_V4L2
326extern int au0828_v4l2_device_register(struct usb_interface *interface,
327 struct au0828_dev *dev);
328
329extern int au0828_analog_register(struct au0828_dev *dev,
330 struct usb_interface *interface);
331extern int au0828_analog_unregister(struct au0828_dev *dev);
332extern void au0828_usb_v4l2_media_release(struct au0828_dev *dev);
329extern void au0828_v4l2_suspend(struct au0828_dev *dev); 333extern void au0828_v4l2_suspend(struct au0828_dev *dev);
330extern void au0828_v4l2_resume(struct au0828_dev *dev); 334extern void au0828_v4l2_resume(struct au0828_dev *dev);
331#else 335#else
336static inline int au0828_v4l2_device_register(struct usb_interface *interface,
337 struct au0828_dev *dev)
338{ return 0; };
339static inline int au0828_analog_register(struct au0828_dev *dev,
340 struct usb_interface *interface)
341{ return 0; };
342static inline int au0828_analog_unregister(struct au0828_dev *dev)
343{ return 0; };
344static inline void au0828_usb_v4l2_media_release(struct au0828_dev *dev) { };
332static inline void au0828_v4l2_suspend(struct au0828_dev *dev) { }; 345static inline void au0828_v4l2_suspend(struct au0828_dev *dev) { };
333static inline void au0828_v4l2_resume(struct au0828_dev *dev) { }; 346static inline void au0828_v4l2_resume(struct au0828_dev *dev) { };
334#endif 347#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..9e3a5d2038c2 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1212,70 +1212,15 @@ static int cx231xx_media_device_init(struct cx231xx *dev,
1212#ifdef CONFIG_MEDIA_CONTROLLER 1212#ifdef CONFIG_MEDIA_CONTROLLER
1213 struct media_device *mdev; 1213 struct media_device *mdev;
1214 1214
1215 mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); 1215 mdev = v4l2_mc_usb_media_device_init(udev, dev->board.name);
1216 if (!mdev) 1216 if (!mdev)
1217 return -ENOMEM; 1217 return -ENOMEM;
1218 1218
1219 mdev->dev = dev->dev;
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
1229 dev->media_dev = mdev; 1219 dev->media_dev = mdev;
1230#endif 1220#endif
1231 return 0; 1221 return 0;
1232} 1222}
1233 1223
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/* 1224/*
1280 * cx231xx_init_dev() 1225 * cx231xx_init_dev()
1281 * allocates and inits the device structs, registers i2c bus and v4l device 1226 * allocates and inits the device structs, registers i2c bus and v4l device
@@ -1739,15 +1684,14 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
1739 /* load other modules required */ 1684 /* load other modules required */
1740 request_modules(dev); 1685 request_modules(dev);
1741 1686
1742 retval = cx231xx_create_media_graph(dev);
1743 if (retval < 0)
1744 goto done;
1745
1746#ifdef CONFIG_MEDIA_CONTROLLER 1687#ifdef CONFIG_MEDIA_CONTROLLER
1747 retval = media_device_register(dev->media_dev); 1688 /* Init entities at the Media Controller */
1748#endif 1689 cx231xx_v4l2_create_entities(dev);
1749 1690
1750done: 1691 retval = v4l2_mc_create_media_graph(dev->media_dev);
1692 if (!retval)
1693 retval = media_device_register(dev->media_dev);
1694#endif
1751 if (retval < 0) 1695 if (retval < 0)
1752 cx231xx_release_resources(dev); 1696 cx231xx_release_resources(dev);
1753 return retval; 1697 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..b3c09fe54d9b 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__,
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..4a8769781cea 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/v4l2-mc.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);
@@ -407,20 +408,10 @@ static int dvb_usbv2_media_device_init(struct dvb_usb_adapter *adap)
407 struct dvb_usb_device *d = adap_to_d(adap); 408 struct dvb_usb_device *d = adap_to_d(adap);
408 struct usb_device *udev = d->udev; 409 struct usb_device *udev = d->udev;
409 410
410 mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); 411 mdev = v4l2_mc_usb_media_device_init(udev, d->name);
411 if (!mdev) 412 if (!mdev)
412 return -ENOMEM; 413 return -ENOMEM;
413 414
414 mdev->dev = &udev->dev;
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
424 dvb_register_media_controller(&adap->dvb_adap, mdev); 415 dvb_register_media_controller(&adap->dvb_adap, mdev);
425 416
426 dev_info(&d->udev->dev, "media controller created\n"); 417 dev_info(&d->udev->dev, "media controller created\n");
@@ -1129,7 +1120,7 @@ int dvb_usbv2_reset_resume(struct usb_interface *intf)
1129EXPORT_SYMBOL(dvb_usbv2_reset_resume); 1120EXPORT_SYMBOL(dvb_usbv2_reset_resume);
1130 1121
1131MODULE_VERSION("2.0"); 1122MODULE_VERSION("2.0");
1132MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 1123MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
1133MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); 1124MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
1134MODULE_DESCRIPTION("DVB USB common"); 1125MODULE_DESCRIPTION("DVB USB common");
1135MODULE_LICENSE("GPL"); 1126MODULE_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..c4c6e92e8643 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);
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..513b0c14e4f0 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/v4l2-mc.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)
@@ -102,19 +103,7 @@ static int dvb_usb_media_device_init(struct dvb_usb_adapter *adap)
102 struct dvb_usb_device *d = adap->dev; 103 struct dvb_usb_device *d = adap->dev;
103 struct usb_device *udev = d->udev; 104 struct usb_device *udev = d->udev;
104 105
105 mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); 106 mdev = v4l2_mc_usb_media_device_init(udev, d->desc->name);
106 if (!mdev)
107 return -ENOMEM;
108
109 mdev->dev = &udev->dev;
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 107
119 dvb_register_media_controller(&adap->dvb_adap, mdev); 108 dvb_register_media_controller(&adap->dvb_adap, mdev);
120 109
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..dd46d6c78c4e 100644
--- a/drivers/media/usb/dvb-usb/dw2102.c
+++ b/drivers/media/usb/dvb-usb/dw2102.c
@@ -1688,6 +1688,7 @@ enum dw2102_table_entry {
1688 TECHNOTREND_S2_4600, 1688 TECHNOTREND_S2_4600,
1689 TEVII_S482_1, 1689 TEVII_S482_1,
1690 TEVII_S482_2, 1690 TEVII_S482_2,
1691 TERRATEC_CINERGY_S2_BOX,
1691}; 1692};
1692 1693
1693static struct usb_device_id dw2102_table[] = { 1694static struct usb_device_id dw2102_table[] = {
@@ -1702,19 +1703,20 @@ static struct usb_device_id dw2102_table[] = {
1702 [TEVII_S660] = {USB_DEVICE(0x9022, USB_PID_TEVII_S660)}, 1703 [TEVII_S660] = {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
1703 [PROF_7500] = {USB_DEVICE(0x3034, 0x7500)}, 1704 [PROF_7500] = {USB_DEVICE(0x3034, 0x7500)},
1704 [GENIATECH_SU3000] = {USB_DEVICE(0x1f4d, 0x3000)}, 1705 [GENIATECH_SU3000] = {USB_DEVICE(0x1f4d, 0x3000)},
1705 [TERRATEC_CINERGY_S2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00a8)}, 1706 [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)}, 1707 [TEVII_S480_1] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)},
1707 [TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)}, 1708 [TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)},
1708 [X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)}, 1709 [X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)},
1709 [TEVII_S421] = {USB_DEVICE(0x9022, USB_PID_TEVII_S421)}, 1710 [TEVII_S421] = {USB_DEVICE(0x9022, USB_PID_TEVII_S421)},
1710 [TEVII_S632] = {USB_DEVICE(0x9022, USB_PID_TEVII_S632)}, 1711 [TEVII_S632] = {USB_DEVICE(0x9022, USB_PID_TEVII_S632)},
1711 [TERRATEC_CINERGY_S2_R2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00b0)}, 1712 [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)}, 1713 [GOTVIEW_SAT_HD] = {USB_DEVICE(0x1FE1, USB_PID_GOTVIEW_SAT_HD)},
1713 [GENIATECH_T220] = {USB_DEVICE(0x1f4d, 0xD220)}, 1714 [GENIATECH_T220] = {USB_DEVICE(0x1f4d, 0xD220)},
1714 [TECHNOTREND_S2_4600] = {USB_DEVICE(USB_VID_TECHNOTREND, 1715 [TECHNOTREND_S2_4600] = {USB_DEVICE(USB_VID_TECHNOTREND,
1715 USB_PID_TECHNOTREND_CONNECT_S2_4600)}, 1716 USB_PID_TECHNOTREND_CONNECT_S2_4600)},
1716 [TEVII_S482_1] = {USB_DEVICE(0x9022, 0xd483)}, 1717 [TEVII_S482_1] = {USB_DEVICE(0x9022, 0xd483)},
1717 [TEVII_S482_2] = {USB_DEVICE(0x9022, 0xd484)}, 1718 [TEVII_S482_2] = {USB_DEVICE(0x9022, 0xd484)},
1719 [TERRATEC_CINERGY_S2_BOX] = {USB_DEVICE(USB_VID_TERRATEC, 0x0105)},
1718 { } 1720 { }
1719}; 1721};
1720 1722
@@ -2232,7 +2234,7 @@ static struct dvb_usb_device_properties tt_s2_4600_properties = {
2232 } }, 2234 } },
2233 } 2235 }
2234 }, 2236 },
2235 .num_device_descs = 3, 2237 .num_device_descs = 4,
2236 .devices = { 2238 .devices = {
2237 { "TechnoTrend TT-connect S2-4600", 2239 { "TechnoTrend TT-connect S2-4600",
2238 { &dw2102_table[TECHNOTREND_S2_4600], NULL }, 2240 { &dw2102_table[TECHNOTREND_S2_4600], NULL },
@@ -2246,6 +2248,10 @@ static struct dvb_usb_device_properties tt_s2_4600_properties = {
2246 { &dw2102_table[TEVII_S482_2], NULL }, 2248 { &dw2102_table[TEVII_S482_2], NULL },
2247 { NULL }, 2249 { NULL },
2248 }, 2250 },
2251 { "Terratec Cinergy S2 USB BOX",
2252 { &dw2102_table[TERRATEC_CINERGY_S2_BOX], NULL },
2253 { NULL },
2254 },
2249 } 2255 }
2250}; 2256};
2251 2257
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..51487d2f7764 100644
--- a/drivers/media/usb/dvb-usb/technisat-usb2.c
+++ b/drivers/media/usb/dvb-usb/technisat-usb2.c
@@ -512,7 +512,7 @@ static int technisat_usb2_frontend_attach(struct dvb_usb_adapter *a)
512 &a->dev->i2c_adap, STV090x_DEMODULATOR_0); 512 &a->dev->i2c_adap, STV090x_DEMODULATOR_0);
513 513
514 if (a->fe_adap[0].fe) { 514 if (a->fe_adap[0].fe) {
515 struct stv6110x_devctl *ctl; 515 const struct stv6110x_devctl *ctl;
516 516
517 ctl = dvb_attach(stv6110x_attach, 517 ctl = dvb_attach(stv6110x_attach,
518 a->fe_adap[0].fe, 518 a->fe_adap[0].fe,
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..389e95fb0211 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -32,7 +32,7 @@
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>
@@ -570,7 +570,7 @@ struct em28xx_board em28xx_boards[] = {
570 .tuner_type = TUNER_ABSENT, 570 .tuner_type = TUNER_ABSENT,
571 .is_webcam = 1, 571 .is_webcam = 1,
572 .input = { { 572 .input = { {
573 .type = EM28XX_VMUX_COMPOSITE1, 573 .type = EM28XX_VMUX_COMPOSITE,
574 .vmux = 0, 574 .vmux = 0,
575 .amux = EM28XX_AMUX_VIDEO, 575 .amux = EM28XX_AMUX_VIDEO,
576 .gpio = silvercrest_reg_seq, 576 .gpio = silvercrest_reg_seq,
@@ -583,7 +583,7 @@ struct em28xx_board em28xx_boards[] = {
583 .decoder = EM28XX_SAA711X, 583 .decoder = EM28XX_SAA711X,
584 .tuner_type = TUNER_ABSENT, 584 .tuner_type = TUNER_ABSENT,
585 .input = { { 585 .input = { {
586 .type = EM28XX_VMUX_COMPOSITE1, 586 .type = EM28XX_VMUX_COMPOSITE,
587 .vmux = SAA7115_COMPOSITE0, 587 .vmux = SAA7115_COMPOSITE0,
588 .amux = EM28XX_AMUX_LINE_IN, 588 .amux = EM28XX_AMUX_LINE_IN,
589 }, { 589 }, {
@@ -605,7 +605,7 @@ struct em28xx_board em28xx_boards[] = {
605 .tuner_type = TUNER_ABSENT, 605 .tuner_type = TUNER_ABSENT,
606 .is_webcam = 1, 606 .is_webcam = 1,
607 .input = { { 607 .input = { {
608 .type = EM28XX_VMUX_COMPOSITE1, 608 .type = EM28XX_VMUX_COMPOSITE,
609 .vmux = 0, 609 .vmux = 0,
610 .amux = EM28XX_AMUX_VIDEO, 610 .amux = EM28XX_AMUX_VIDEO,
611 } }, 611 } },
@@ -616,7 +616,7 @@ struct em28xx_board em28xx_boards[] = {
616 .tda9887_conf = TDA9887_PRESENT, 616 .tda9887_conf = TDA9887_PRESENT,
617 .decoder = EM28XX_SAA711X, 617 .decoder = EM28XX_SAA711X,
618 .input = { { 618 .input = { {
619 .type = EM28XX_VMUX_COMPOSITE1, 619 .type = EM28XX_VMUX_COMPOSITE,
620 .vmux = SAA7115_COMPOSITE0, 620 .vmux = SAA7115_COMPOSITE0,
621 .amux = EM28XX_AMUX_LINE_IN, 621 .amux = EM28XX_AMUX_LINE_IN,
622 }, { 622 }, {
@@ -635,7 +635,7 @@ struct em28xx_board em28xx_boards[] = {
635 .vmux = SAA7115_COMPOSITE2, 635 .vmux = SAA7115_COMPOSITE2,
636 .amux = EM28XX_AMUX_LINE_IN, 636 .amux = EM28XX_AMUX_LINE_IN,
637 }, { 637 }, {
638 .type = EM28XX_VMUX_COMPOSITE1, 638 .type = EM28XX_VMUX_COMPOSITE,
639 .vmux = SAA7115_COMPOSITE0, 639 .vmux = SAA7115_COMPOSITE0,
640 .amux = EM28XX_AMUX_LINE_IN, 640 .amux = EM28XX_AMUX_LINE_IN,
641 }, { 641 }, {
@@ -655,7 +655,7 @@ struct em28xx_board em28xx_boards[] = {
655 .vmux = SAA7115_COMPOSITE2, 655 .vmux = SAA7115_COMPOSITE2,
656 .amux = EM28XX_AMUX_VIDEO, 656 .amux = EM28XX_AMUX_VIDEO,
657 }, { 657 }, {
658 .type = EM28XX_VMUX_COMPOSITE1, 658 .type = EM28XX_VMUX_COMPOSITE,
659 .vmux = SAA7115_COMPOSITE0, 659 .vmux = SAA7115_COMPOSITE0,
660 .amux = EM28XX_AMUX_LINE_IN, 660 .amux = EM28XX_AMUX_LINE_IN,
661 }, { 661 }, {
@@ -675,7 +675,7 @@ struct em28xx_board em28xx_boards[] = {
675 .vmux = SAA7115_COMPOSITE2, 675 .vmux = SAA7115_COMPOSITE2,
676 .amux = EM28XX_AMUX_VIDEO, 676 .amux = EM28XX_AMUX_VIDEO,
677 }, { 677 }, {
678 .type = EM28XX_VMUX_COMPOSITE1, 678 .type = EM28XX_VMUX_COMPOSITE,
679 .vmux = SAA7115_COMPOSITE0, 679 .vmux = SAA7115_COMPOSITE0,
680 .amux = EM28XX_AMUX_LINE_IN, 680 .amux = EM28XX_AMUX_LINE_IN,
681 }, { 681 }, {
@@ -715,7 +715,7 @@ struct em28xx_board em28xx_boards[] = {
715 .vmux = SAA7115_COMPOSITE2, 715 .vmux = SAA7115_COMPOSITE2,
716 .amux = EM28XX_AMUX_LINE_IN, 716 .amux = EM28XX_AMUX_LINE_IN,
717 }, { 717 }, {
718 .type = EM28XX_VMUX_COMPOSITE1, 718 .type = EM28XX_VMUX_COMPOSITE,
719 .vmux = SAA7115_COMPOSITE0, 719 .vmux = SAA7115_COMPOSITE0,
720 .amux = EM28XX_AMUX_LINE_IN, 720 .amux = EM28XX_AMUX_LINE_IN,
721 }, { 721 }, {
@@ -735,7 +735,7 @@ struct em28xx_board em28xx_boards[] = {
735 .vmux = SAA7115_COMPOSITE2, 735 .vmux = SAA7115_COMPOSITE2,
736 .amux = EM28XX_AMUX_LINE_IN, 736 .amux = EM28XX_AMUX_LINE_IN,
737 }, { 737 }, {
738 .type = EM28XX_VMUX_COMPOSITE1, 738 .type = EM28XX_VMUX_COMPOSITE,
739 .vmux = SAA7115_COMPOSITE0, 739 .vmux = SAA7115_COMPOSITE0,
740 .amux = EM28XX_AMUX_LINE_IN, 740 .amux = EM28XX_AMUX_LINE_IN,
741 }, { 741 }, {
@@ -755,7 +755,7 @@ struct em28xx_board em28xx_boards[] = {
755 .vmux = SAA7115_COMPOSITE2, 755 .vmux = SAA7115_COMPOSITE2,
756 .amux = EM28XX_AMUX_VIDEO, 756 .amux = EM28XX_AMUX_VIDEO,
757 }, { 757 }, {
758 .type = EM28XX_VMUX_COMPOSITE1, 758 .type = EM28XX_VMUX_COMPOSITE,
759 .vmux = SAA7115_COMPOSITE0, 759 .vmux = SAA7115_COMPOSITE0,
760 .amux = EM28XX_AMUX_LINE_IN, 760 .amux = EM28XX_AMUX_LINE_IN,
761 }, { 761 }, {
@@ -775,7 +775,7 @@ struct em28xx_board em28xx_boards[] = {
775 .vmux = SAA7115_COMPOSITE1, 775 .vmux = SAA7115_COMPOSITE1,
776 .amux = EM28XX_AMUX_LINE_IN, 776 .amux = EM28XX_AMUX_LINE_IN,
777 }, { 777 }, {
778 .type = EM28XX_VMUX_COMPOSITE1, 778 .type = EM28XX_VMUX_COMPOSITE,
779 .vmux = SAA7115_COMPOSITE0, 779 .vmux = SAA7115_COMPOSITE0,
780 .amux = EM28XX_AMUX_LINE_IN, 780 .amux = EM28XX_AMUX_LINE_IN,
781 }, { 781 }, {
@@ -800,7 +800,7 @@ struct em28xx_board em28xx_boards[] = {
800 .vmux = SAA7115_COMPOSITE4, 800 .vmux = SAA7115_COMPOSITE4,
801 .amux = EM28XX_AMUX_AUX, 801 .amux = EM28XX_AMUX_AUX,
802 }, { 802 }, {
803 .type = EM28XX_VMUX_COMPOSITE1, 803 .type = EM28XX_VMUX_COMPOSITE,
804 .vmux = SAA7115_COMPOSITE5, 804 .vmux = SAA7115_COMPOSITE5,
805 .amux = EM28XX_AMUX_LINE_IN, 805 .amux = EM28XX_AMUX_LINE_IN,
806 }, { 806 }, {
@@ -819,7 +819,7 @@ struct em28xx_board em28xx_boards[] = {
819 .tuner_type = TUNER_ABSENT, 819 .tuner_type = TUNER_ABSENT,
820 .is_webcam = 1, 820 .is_webcam = 1,
821 .input = { { 821 .input = { {
822 .type = EM28XX_VMUX_COMPOSITE1, 822 .type = EM28XX_VMUX_COMPOSITE,
823 .vmux = 0, 823 .vmux = 0,
824 .amux = EM28XX_AMUX_VIDEO, 824 .amux = EM28XX_AMUX_VIDEO,
825 } }, 825 } },
@@ -829,7 +829,7 @@ struct em28xx_board em28xx_boards[] = {
829 .tuner_type = TUNER_ABSENT, 829 .tuner_type = TUNER_ABSENT,
830 .is_webcam = 1, 830 .is_webcam = 1,
831 .input = { { 831 .input = { {
832 .type = EM28XX_VMUX_COMPOSITE1, 832 .type = EM28XX_VMUX_COMPOSITE,
833 .vmux = 0, 833 .vmux = 0,
834 .amux = EM28XX_AMUX_VIDEO, 834 .amux = EM28XX_AMUX_VIDEO,
835 .gpio = silvercrest_reg_seq, 835 .gpio = silvercrest_reg_seq,
@@ -848,7 +848,7 @@ struct em28xx_board em28xx_boards[] = {
848 .vmux = SAA7115_COMPOSITE2, 848 .vmux = SAA7115_COMPOSITE2,
849 .amux = EM28XX_AMUX_LINE_IN, 849 .amux = EM28XX_AMUX_LINE_IN,
850 }, { 850 }, {
851 .type = EM28XX_VMUX_COMPOSITE1, 851 .type = EM28XX_VMUX_COMPOSITE,
852 .vmux = SAA7115_COMPOSITE0, 852 .vmux = SAA7115_COMPOSITE0,
853 .amux = EM28XX_AMUX_VIDEO, 853 .amux = EM28XX_AMUX_VIDEO,
854 }, { 854 }, {
@@ -863,7 +863,7 @@ struct em28xx_board em28xx_boards[] = {
863 .tuner_type = TUNER_ABSENT, /* Capture only device */ 863 .tuner_type = TUNER_ABSENT, /* Capture only device */
864 .decoder = EM28XX_SAA711X, 864 .decoder = EM28XX_SAA711X,
865 .input = { { 865 .input = { {
866 .type = EM28XX_VMUX_COMPOSITE1, 866 .type = EM28XX_VMUX_COMPOSITE,
867 .vmux = SAA7115_COMPOSITE0, 867 .vmux = SAA7115_COMPOSITE0,
868 .amux = EM28XX_AMUX_LINE_IN, 868 .amux = EM28XX_AMUX_LINE_IN,
869 }, { 869 }, {
@@ -879,7 +879,7 @@ struct em28xx_board em28xx_boards[] = {
879 .tuner_type = TUNER_ABSENT, 879 .tuner_type = TUNER_ABSENT,
880 .is_webcam = 1, 880 .is_webcam = 1,
881 .input = { { 881 .input = { {
882 .type = EM28XX_VMUX_COMPOSITE1, 882 .type = EM28XX_VMUX_COMPOSITE,
883 .vmux = 0, 883 .vmux = 0,
884 .amux = EM28XX_AMUX_VIDEO, 884 .amux = EM28XX_AMUX_VIDEO,
885 } }, 885 } },
@@ -889,7 +889,7 @@ struct em28xx_board em28xx_boards[] = {
889 .decoder = EM28XX_SAA711X, 889 .decoder = EM28XX_SAA711X,
890 .tuner_type = TUNER_ABSENT, /* Capture only device */ 890 .tuner_type = TUNER_ABSENT, /* Capture only device */
891 .input = { { 891 .input = { {
892 .type = EM28XX_VMUX_COMPOSITE1, 892 .type = EM28XX_VMUX_COMPOSITE,
893 .vmux = SAA7115_COMPOSITE0, 893 .vmux = SAA7115_COMPOSITE0,
894 .amux = EM28XX_AMUX_LINE_IN, 894 .amux = EM28XX_AMUX_LINE_IN,
895 }, { 895 }, {
@@ -909,7 +909,7 @@ struct em28xx_board em28xx_boards[] = {
909 .vmux = SAA7115_COMPOSITE2, 909 .vmux = SAA7115_COMPOSITE2,
910 .amux = EM28XX_AMUX_VIDEO, 910 .amux = EM28XX_AMUX_VIDEO,
911 }, { 911 }, {
912 .type = EM28XX_VMUX_COMPOSITE1, 912 .type = EM28XX_VMUX_COMPOSITE,
913 .vmux = SAA7115_COMPOSITE0, 913 .vmux = SAA7115_COMPOSITE0,
914 .amux = EM28XX_AMUX_LINE_IN, 914 .amux = EM28XX_AMUX_LINE_IN,
915 }, { 915 }, {
@@ -930,7 +930,7 @@ struct em28xx_board em28xx_boards[] = {
930 .vmux = SAA7115_COMPOSITE2, 930 .vmux = SAA7115_COMPOSITE2,
931 .amux = EM28XX_AMUX_VIDEO, 931 .amux = EM28XX_AMUX_VIDEO,
932 }, { 932 }, {
933 .type = EM28XX_VMUX_COMPOSITE1, 933 .type = EM28XX_VMUX_COMPOSITE,
934 .vmux = SAA7115_COMPOSITE0, 934 .vmux = SAA7115_COMPOSITE0,
935 .amux = EM28XX_AMUX_LINE_IN, 935 .amux = EM28XX_AMUX_LINE_IN,
936 }, { 936 }, {
@@ -952,7 +952,7 @@ struct em28xx_board em28xx_boards[] = {
952 .amux = EM28XX_AMUX_VIDEO, 952 .amux = EM28XX_AMUX_VIDEO,
953 .gpio = hauppauge_wintv_hvr_900_analog, 953 .gpio = hauppauge_wintv_hvr_900_analog,
954 }, { 954 }, {
955 .type = EM28XX_VMUX_COMPOSITE1, 955 .type = EM28XX_VMUX_COMPOSITE,
956 .vmux = TVP5150_COMPOSITE1, 956 .vmux = TVP5150_COMPOSITE1,
957 .amux = EM28XX_AMUX_LINE_IN, 957 .amux = EM28XX_AMUX_LINE_IN,
958 .gpio = hauppauge_wintv_hvr_900_analog, 958 .gpio = hauppauge_wintv_hvr_900_analog,
@@ -974,7 +974,7 @@ struct em28xx_board em28xx_boards[] = {
974 .vmux = TVP5150_COMPOSITE0, 974 .vmux = TVP5150_COMPOSITE0,
975 .amux = EM28XX_AMUX_VIDEO, 975 .amux = EM28XX_AMUX_VIDEO,
976 }, { 976 }, {
977 .type = EM28XX_VMUX_COMPOSITE1, 977 .type = EM28XX_VMUX_COMPOSITE,
978 .vmux = TVP5150_COMPOSITE1, 978 .vmux = TVP5150_COMPOSITE1,
979 .amux = EM28XX_AMUX_LINE_IN, 979 .amux = EM28XX_AMUX_LINE_IN,
980 }, { 980 }, {
@@ -992,7 +992,7 @@ struct em28xx_board em28xx_boards[] = {
992 .vmux = TVP5150_COMPOSITE0, 992 .vmux = TVP5150_COMPOSITE0,
993 .amux = EM28XX_AMUX_VIDEO, 993 .amux = EM28XX_AMUX_VIDEO,
994 }, { 994 }, {
995 .type = EM28XX_VMUX_COMPOSITE1, 995 .type = EM28XX_VMUX_COMPOSITE,
996 .vmux = TVP5150_COMPOSITE1, 996 .vmux = TVP5150_COMPOSITE1,
997 .amux = EM28XX_AMUX_LINE_IN, 997 .amux = EM28XX_AMUX_LINE_IN,
998 }, { 998 }, {
@@ -1006,7 +1006,7 @@ struct em28xx_board em28xx_boards[] = {
1006 .tuner_type = TUNER_ABSENT, /* Capture only device */ 1006 .tuner_type = TUNER_ABSENT, /* Capture only device */
1007 .decoder = EM28XX_TVP5150, 1007 .decoder = EM28XX_TVP5150,
1008 .input = { { 1008 .input = { {
1009 .type = EM28XX_VMUX_COMPOSITE1, 1009 .type = EM28XX_VMUX_COMPOSITE,
1010 .vmux = TVP5150_COMPOSITE1, 1010 .vmux = TVP5150_COMPOSITE1,
1011 .amux = EM28XX_AMUX_LINE_IN, 1011 .amux = EM28XX_AMUX_LINE_IN,
1012 }, { 1012 }, {
@@ -1029,7 +1029,7 @@ struct em28xx_board em28xx_boards[] = {
1029 .amux = EM28XX_AMUX_LINE_IN, 1029 .amux = EM28XX_AMUX_LINE_IN,
1030 .gpio = pinnacle_hybrid_pro_analog, 1030 .gpio = pinnacle_hybrid_pro_analog,
1031 }, { 1031 }, {
1032 .type = EM28XX_VMUX_COMPOSITE1, 1032 .type = EM28XX_VMUX_COMPOSITE,
1033 .vmux = TVP5150_COMPOSITE1, 1033 .vmux = TVP5150_COMPOSITE1,
1034 .amux = EM28XX_AMUX_LINE_IN, 1034 .amux = EM28XX_AMUX_LINE_IN,
1035 .gpio = pinnacle_hybrid_pro_analog, 1035 .gpio = pinnacle_hybrid_pro_analog,
@@ -1100,7 +1100,7 @@ struct em28xx_board em28xx_boards[] = {
1100 .amux = EM28XX_AMUX_VIDEO, 1100 .amux = EM28XX_AMUX_VIDEO,
1101 .gpio = terratec_cinergy_USB_XS_FR_analog, 1101 .gpio = terratec_cinergy_USB_XS_FR_analog,
1102 }, { 1102 }, {
1103 .type = EM28XX_VMUX_COMPOSITE1, 1103 .type = EM28XX_VMUX_COMPOSITE,
1104 .vmux = TVP5150_COMPOSITE1, 1104 .vmux = TVP5150_COMPOSITE1,
1105 .amux = EM28XX_AMUX_LINE_IN, 1105 .amux = EM28XX_AMUX_LINE_IN,
1106 .gpio = terratec_cinergy_USB_XS_FR_analog, 1106 .gpio = terratec_cinergy_USB_XS_FR_analog,
@@ -1186,7 +1186,7 @@ struct em28xx_board em28xx_boards[] = {
1186 .amux = EM28XX_AMUX_VIDEO, 1186 .amux = EM28XX_AMUX_VIDEO,
1187 .gpio = hauppauge_wintv_hvr_900_analog, 1187 .gpio = hauppauge_wintv_hvr_900_analog,
1188 }, { 1188 }, {
1189 .type = EM28XX_VMUX_COMPOSITE1, 1189 .type = EM28XX_VMUX_COMPOSITE,
1190 .vmux = TVP5150_COMPOSITE1, 1190 .vmux = TVP5150_COMPOSITE1,
1191 .amux = EM28XX_AMUX_LINE_IN, 1191 .amux = EM28XX_AMUX_LINE_IN,
1192 .gpio = hauppauge_wintv_hvr_900_analog, 1192 .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1213,7 +1213,7 @@ struct em28xx_board em28xx_boards[] = {
1213 .amux = EM28XX_AMUX_VIDEO, 1213 .amux = EM28XX_AMUX_VIDEO,
1214 .gpio = hauppauge_wintv_hvr_900_analog, 1214 .gpio = hauppauge_wintv_hvr_900_analog,
1215 }, { 1215 }, {
1216 .type = EM28XX_VMUX_COMPOSITE1, 1216 .type = EM28XX_VMUX_COMPOSITE,
1217 .vmux = TVP5150_COMPOSITE1, 1217 .vmux = TVP5150_COMPOSITE1,
1218 .amux = EM28XX_AMUX_LINE_IN, 1218 .amux = EM28XX_AMUX_LINE_IN,
1219 .gpio = hauppauge_wintv_hvr_900_analog, 1219 .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1239,7 +1239,7 @@ struct em28xx_board em28xx_boards[] = {
1239 .amux = EM28XX_AMUX_VIDEO, 1239 .amux = EM28XX_AMUX_VIDEO,
1240 .gpio = hauppauge_wintv_hvr_900_analog, 1240 .gpio = hauppauge_wintv_hvr_900_analog,
1241 }, { 1241 }, {
1242 .type = EM28XX_VMUX_COMPOSITE1, 1242 .type = EM28XX_VMUX_COMPOSITE,
1243 .vmux = TVP5150_COMPOSITE1, 1243 .vmux = TVP5150_COMPOSITE1,
1244 .amux = EM28XX_AMUX_LINE_IN, 1244 .amux = EM28XX_AMUX_LINE_IN,
1245 .gpio = hauppauge_wintv_hvr_900_analog, 1245 .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1265,7 +1265,7 @@ struct em28xx_board em28xx_boards[] = {
1265 .amux = EM28XX_AMUX_VIDEO, 1265 .amux = EM28XX_AMUX_VIDEO,
1266 .gpio = hauppauge_wintv_hvr_900_analog, 1266 .gpio = hauppauge_wintv_hvr_900_analog,
1267 }, { 1267 }, {
1268 .type = EM28XX_VMUX_COMPOSITE1, 1268 .type = EM28XX_VMUX_COMPOSITE,
1269 .vmux = TVP5150_COMPOSITE1, 1269 .vmux = TVP5150_COMPOSITE1,
1270 .amux = EM28XX_AMUX_LINE_IN, 1270 .amux = EM28XX_AMUX_LINE_IN,
1271 .gpio = hauppauge_wintv_hvr_900_analog, 1271 .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1291,7 +1291,7 @@ struct em28xx_board em28xx_boards[] = {
1291 .amux = EM28XX_AMUX_VIDEO, 1291 .amux = EM28XX_AMUX_VIDEO,
1292 .gpio = hauppauge_wintv_hvr_900_analog, 1292 .gpio = hauppauge_wintv_hvr_900_analog,
1293 }, { 1293 }, {
1294 .type = EM28XX_VMUX_COMPOSITE1, 1294 .type = EM28XX_VMUX_COMPOSITE,
1295 .vmux = TVP5150_COMPOSITE1, 1295 .vmux = TVP5150_COMPOSITE1,
1296 .amux = EM28XX_AMUX_LINE_IN, 1296 .amux = EM28XX_AMUX_LINE_IN,
1297 .gpio = hauppauge_wintv_hvr_900_analog, 1297 .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1317,7 +1317,7 @@ struct em28xx_board em28xx_boards[] = {
1317 .amux = EM28XX_AMUX_VIDEO, 1317 .amux = EM28XX_AMUX_VIDEO,
1318 .gpio = hauppauge_wintv_hvr_900_analog, 1318 .gpio = hauppauge_wintv_hvr_900_analog,
1319 }, { 1319 }, {
1320 .type = EM28XX_VMUX_COMPOSITE1, 1320 .type = EM28XX_VMUX_COMPOSITE,
1321 .vmux = TVP5150_COMPOSITE1, 1321 .vmux = TVP5150_COMPOSITE1,
1322 .amux = EM28XX_AMUX_LINE_IN, 1322 .amux = EM28XX_AMUX_LINE_IN,
1323 .gpio = hauppauge_wintv_hvr_900_analog, 1323 .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1343,7 +1343,7 @@ struct em28xx_board em28xx_boards[] = {
1343 .amux = EM28XX_AMUX_VIDEO, 1343 .amux = EM28XX_AMUX_VIDEO,
1344 .gpio = default_analog, 1344 .gpio = default_analog,
1345 }, { 1345 }, {
1346 .type = EM28XX_VMUX_COMPOSITE1, 1346 .type = EM28XX_VMUX_COMPOSITE,
1347 .vmux = TVP5150_COMPOSITE1, 1347 .vmux = TVP5150_COMPOSITE1,
1348 .amux = EM28XX_AMUX_LINE_IN, 1348 .amux = EM28XX_AMUX_LINE_IN,
1349 .gpio = default_analog, 1349 .gpio = default_analog,
@@ -1368,7 +1368,7 @@ struct em28xx_board em28xx_boards[] = {
1368 .amux = EM28XX_AMUX_VIDEO, 1368 .amux = EM28XX_AMUX_VIDEO,
1369 .gpio = hauppauge_wintv_hvr_900_analog, 1369 .gpio = hauppauge_wintv_hvr_900_analog,
1370 }, { 1370 }, {
1371 .type = EM28XX_VMUX_COMPOSITE1, 1371 .type = EM28XX_VMUX_COMPOSITE,
1372 .vmux = TVP5150_COMPOSITE1, 1372 .vmux = TVP5150_COMPOSITE1,
1373 .amux = EM28XX_AMUX_LINE_IN, 1373 .amux = EM28XX_AMUX_LINE_IN,
1374 .gpio = hauppauge_wintv_hvr_900_analog, 1374 .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1392,7 +1392,7 @@ struct em28xx_board em28xx_boards[] = {
1392 .vmux = SAA7115_COMPOSITE4, 1392 .vmux = SAA7115_COMPOSITE4,
1393 .amux = EM28XX_AMUX_VIDEO, 1393 .amux = EM28XX_AMUX_VIDEO,
1394 }, { 1394 }, {
1395 .type = EM28XX_VMUX_COMPOSITE1, 1395 .type = EM28XX_VMUX_COMPOSITE,
1396 .vmux = SAA7115_COMPOSITE0, 1396 .vmux = SAA7115_COMPOSITE0,
1397 .amux = EM28XX_AMUX_LINE_IN, 1397 .amux = EM28XX_AMUX_LINE_IN,
1398 }, { 1398 }, {
@@ -1413,7 +1413,7 @@ struct em28xx_board em28xx_boards[] = {
1413 .vmux = SAA7115_COMPOSITE2, 1413 .vmux = SAA7115_COMPOSITE2,
1414 .amux = EM28XX_AMUX_VIDEO, 1414 .amux = EM28XX_AMUX_VIDEO,
1415 }, { 1415 }, {
1416 .type = EM28XX_VMUX_COMPOSITE1, 1416 .type = EM28XX_VMUX_COMPOSITE,
1417 .vmux = SAA7115_COMPOSITE0, 1417 .vmux = SAA7115_COMPOSITE0,
1418 .amux = EM28XX_AMUX_LINE_IN, 1418 .amux = EM28XX_AMUX_LINE_IN,
1419 }, { 1419 }, {
@@ -1428,7 +1428,7 @@ struct em28xx_board em28xx_boards[] = {
1428 .decoder = EM28XX_SAA711X, 1428 .decoder = EM28XX_SAA711X,
1429 .tuner_type = TUNER_ABSENT, /* capture only board */ 1429 .tuner_type = TUNER_ABSENT, /* capture only board */
1430 .input = { { 1430 .input = { {
1431 .type = EM28XX_VMUX_COMPOSITE1, 1431 .type = EM28XX_VMUX_COMPOSITE,
1432 .vmux = SAA7115_COMPOSITE0, 1432 .vmux = SAA7115_COMPOSITE0,
1433 .amux = EM28XX_AMUX_LINE_IN, 1433 .amux = EM28XX_AMUX_LINE_IN,
1434 }, { 1434 }, {
@@ -1443,7 +1443,7 @@ struct em28xx_board em28xx_boards[] = {
1443 .tuner_type = TUNER_ABSENT, /* Capture-only board */ 1443 .tuner_type = TUNER_ABSENT, /* Capture-only board */
1444 .decoder = EM28XX_SAA711X, 1444 .decoder = EM28XX_SAA711X,
1445 .input = { { 1445 .input = { {
1446 .type = EM28XX_VMUX_COMPOSITE1, 1446 .type = EM28XX_VMUX_COMPOSITE,
1447 .vmux = SAA7115_COMPOSITE0, 1447 .vmux = SAA7115_COMPOSITE0,
1448 .amux = EM28XX_AMUX_LINE_IN, 1448 .amux = EM28XX_AMUX_LINE_IN,
1449 .gpio = vc211a_enable, 1449 .gpio = vc211a_enable,
@@ -1465,7 +1465,7 @@ struct em28xx_board em28xx_boards[] = {
1465 .vmux = SAA7115_COMPOSITE2, 1465 .vmux = SAA7115_COMPOSITE2,
1466 .amux = EM28XX_AMUX_VIDEO, 1466 .amux = EM28XX_AMUX_VIDEO,
1467 }, { 1467 }, {
1468 .type = EM28XX_VMUX_COMPOSITE1, 1468 .type = EM28XX_VMUX_COMPOSITE,
1469 .vmux = SAA7115_COMPOSITE0, 1469 .vmux = SAA7115_COMPOSITE0,
1470 .amux = EM28XX_AMUX_LINE_IN, 1470 .amux = EM28XX_AMUX_LINE_IN,
1471 }, { 1471 }, {
@@ -1485,7 +1485,7 @@ struct em28xx_board em28xx_boards[] = {
1485 .vmux = SAA7115_COMPOSITE2, 1485 .vmux = SAA7115_COMPOSITE2,
1486 .amux = EM28XX_AMUX_VIDEO, 1486 .amux = EM28XX_AMUX_VIDEO,
1487 }, { 1487 }, {
1488 .type = EM28XX_VMUX_COMPOSITE1, 1488 .type = EM28XX_VMUX_COMPOSITE,
1489 .vmux = SAA7115_COMPOSITE0, 1489 .vmux = SAA7115_COMPOSITE0,
1490 .amux = EM28XX_AMUX_LINE_IN, 1490 .amux = EM28XX_AMUX_LINE_IN,
1491 }, { 1491 }, {
@@ -1500,7 +1500,7 @@ struct em28xx_board em28xx_boards[] = {
1500 .tuner_type = TUNER_ABSENT, /* capture only board */ 1500 .tuner_type = TUNER_ABSENT, /* capture only board */
1501 .decoder = EM28XX_SAA711X, 1501 .decoder = EM28XX_SAA711X,
1502 .input = { { 1502 .input = { {
1503 .type = EM28XX_VMUX_COMPOSITE1, 1503 .type = EM28XX_VMUX_COMPOSITE,
1504 .vmux = SAA7115_COMPOSITE0, 1504 .vmux = SAA7115_COMPOSITE0,
1505 .amux = EM28XX_AMUX_LINE_IN, 1505 .amux = EM28XX_AMUX_LINE_IN,
1506 }, { 1506 }, {
@@ -1520,7 +1520,7 @@ struct em28xx_board em28xx_boards[] = {
1520 .vmux = SAA7115_COMPOSITE2, 1520 .vmux = SAA7115_COMPOSITE2,
1521 .amux = EM28XX_AMUX_VIDEO, 1521 .amux = EM28XX_AMUX_VIDEO,
1522 }, { 1522 }, {
1523 .type = EM28XX_VMUX_COMPOSITE1, 1523 .type = EM28XX_VMUX_COMPOSITE,
1524 .vmux = SAA7115_COMPOSITE0, 1524 .vmux = SAA7115_COMPOSITE0,
1525 .amux = EM28XX_AMUX_LINE_IN, 1525 .amux = EM28XX_AMUX_LINE_IN,
1526 }, { 1526 }, {
@@ -1541,7 +1541,7 @@ struct em28xx_board em28xx_boards[] = {
1541 .aout = EM28XX_AOUT_MONO | /* I2S */ 1541 .aout = EM28XX_AOUT_MONO | /* I2S */
1542 EM28XX_AOUT_MASTER, /* Line out pin */ 1542 EM28XX_AOUT_MASTER, /* Line out pin */
1543 }, { 1543 }, {
1544 .type = EM28XX_VMUX_COMPOSITE1, 1544 .type = EM28XX_VMUX_COMPOSITE,
1545 .vmux = SAA7115_COMPOSITE0, 1545 .vmux = SAA7115_COMPOSITE0,
1546 .amux = EM28XX_AMUX_LINE_IN, 1546 .amux = EM28XX_AMUX_LINE_IN,
1547 }, { 1547 }, {
@@ -1555,6 +1555,7 @@ struct em28xx_board em28xx_boards[] = {
1555 .buttons = std_snapshot_button, 1555 .buttons = std_snapshot_button,
1556 .tda9887_conf = TDA9887_PRESENT, 1556 .tda9887_conf = TDA9887_PRESENT,
1557 .tuner_type = TUNER_YMEC_TVF_5533MF, 1557 .tuner_type = TUNER_YMEC_TVF_5533MF,
1558 .tuner_addr = 0x60,
1558 .decoder = EM28XX_SAA711X, 1559 .decoder = EM28XX_SAA711X,
1559 .input = { { 1560 .input = { {
1560 .type = EM28XX_VMUX_TELEVISION, 1561 .type = EM28XX_VMUX_TELEVISION,
@@ -1563,7 +1564,7 @@ struct em28xx_board em28xx_boards[] = {
1563 .aout = EM28XX_AOUT_MONO | /* I2S */ 1564 .aout = EM28XX_AOUT_MONO | /* I2S */
1564 EM28XX_AOUT_MASTER, /* Line out pin */ 1565 EM28XX_AOUT_MASTER, /* Line out pin */
1565 }, { 1566 }, {
1566 .type = EM28XX_VMUX_COMPOSITE1, 1567 .type = EM28XX_VMUX_COMPOSITE,
1567 .vmux = SAA7115_COMPOSITE0, 1568 .vmux = SAA7115_COMPOSITE0,
1568 .amux = EM28XX_AMUX_LINE_IN, 1569 .amux = EM28XX_AMUX_LINE_IN,
1569 }, { 1570 }, {
@@ -1581,7 +1582,7 @@ struct em28xx_board em28xx_boards[] = {
1581 .type = EM28XX_VMUX_SVIDEO, 1582 .type = EM28XX_VMUX_SVIDEO,
1582 .vmux = SAA7115_SVIDEO3, 1583 .vmux = SAA7115_SVIDEO3,
1583 }, { 1584 }, {
1584 .type = EM28XX_VMUX_COMPOSITE1, 1585 .type = EM28XX_VMUX_COMPOSITE,
1585 .vmux = SAA7115_COMPOSITE0, 1586 .vmux = SAA7115_COMPOSITE0,
1586 } }, 1587 } },
1587 }, 1588 },
@@ -1610,7 +1611,7 @@ struct em28xx_board em28xx_boards[] = {
1610 .amux = EM28XX_AMUX_VIDEO, 1611 .amux = EM28XX_AMUX_VIDEO,
1611 .gpio = em2880_msi_digivox_ad_analog, 1612 .gpio = em2880_msi_digivox_ad_analog,
1612 }, { 1613 }, {
1613 .type = EM28XX_VMUX_COMPOSITE1, 1614 .type = EM28XX_VMUX_COMPOSITE,
1614 .vmux = TVP5150_COMPOSITE1, 1615 .vmux = TVP5150_COMPOSITE1,
1615 .amux = EM28XX_AMUX_LINE_IN, 1616 .amux = EM28XX_AMUX_LINE_IN,
1616 .gpio = em2880_msi_digivox_ad_analog, 1617 .gpio = em2880_msi_digivox_ad_analog,
@@ -1633,7 +1634,7 @@ struct em28xx_board em28xx_boards[] = {
1633 .amux = EM28XX_AMUX_VIDEO, 1634 .amux = EM28XX_AMUX_VIDEO,
1634 .gpio = em2880_msi_digivox_ad_analog, 1635 .gpio = em2880_msi_digivox_ad_analog,
1635 }, { 1636 }, {
1636 .type = EM28XX_VMUX_COMPOSITE1, 1637 .type = EM28XX_VMUX_COMPOSITE,
1637 .vmux = TVP5150_COMPOSITE1, 1638 .vmux = TVP5150_COMPOSITE1,
1638 .amux = EM28XX_AMUX_LINE_IN, 1639 .amux = EM28XX_AMUX_LINE_IN,
1639 .gpio = em2880_msi_digivox_ad_analog, 1640 .gpio = em2880_msi_digivox_ad_analog,
@@ -1654,7 +1655,7 @@ struct em28xx_board em28xx_boards[] = {
1654 .vmux = TVP5150_COMPOSITE0, 1655 .vmux = TVP5150_COMPOSITE0,
1655 .amux = EM28XX_AMUX_VIDEO, 1656 .amux = EM28XX_AMUX_VIDEO,
1656 }, { 1657 }, {
1657 .type = EM28XX_VMUX_COMPOSITE1, 1658 .type = EM28XX_VMUX_COMPOSITE,
1658 .vmux = TVP5150_COMPOSITE1, 1659 .vmux = TVP5150_COMPOSITE1,
1659 .amux = EM28XX_AMUX_LINE_IN, 1660 .amux = EM28XX_AMUX_LINE_IN,
1660 }, { 1661 }, {
@@ -1677,7 +1678,7 @@ struct em28xx_board em28xx_boards[] = {
1677 .amux = EM28XX_AMUX_VIDEO, 1678 .amux = EM28XX_AMUX_VIDEO,
1678 .gpio = default_analog, 1679 .gpio = default_analog,
1679 }, { 1680 }, {
1680 .type = EM28XX_VMUX_COMPOSITE1, 1681 .type = EM28XX_VMUX_COMPOSITE,
1681 .vmux = TVP5150_COMPOSITE1, 1682 .vmux = TVP5150_COMPOSITE1,
1682 .amux = EM28XX_AMUX_LINE_IN, 1683 .amux = EM28XX_AMUX_LINE_IN,
1683 .gpio = default_analog, 1684 .gpio = default_analog,
@@ -1708,7 +1709,7 @@ struct em28xx_board em28xx_boards[] = {
1708 .gpio = em2882_kworld_315u_analog, 1709 .gpio = em2882_kworld_315u_analog,
1709 .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO, 1710 .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1710 }, { 1711 }, {
1711 .type = EM28XX_VMUX_COMPOSITE1, 1712 .type = EM28XX_VMUX_COMPOSITE,
1712 .vmux = SAA7115_COMPOSITE0, 1713 .vmux = SAA7115_COMPOSITE0,
1713 .amux = EM28XX_AMUX_LINE_IN, 1714 .amux = EM28XX_AMUX_LINE_IN,
1714 .gpio = em2882_kworld_315u_analog1, 1715 .gpio = em2882_kworld_315u_analog1,
@@ -1735,7 +1736,7 @@ struct em28xx_board em28xx_boards[] = {
1735 .amux = EM28XX_AMUX_VIDEO, 1736 .amux = EM28XX_AMUX_VIDEO,
1736 .gpio = default_analog, 1737 .gpio = default_analog,
1737 }, { 1738 }, {
1738 .type = EM28XX_VMUX_COMPOSITE1, 1739 .type = EM28XX_VMUX_COMPOSITE,
1739 .vmux = TVP5150_COMPOSITE1, 1740 .vmux = TVP5150_COMPOSITE1,
1740 .amux = EM28XX_AMUX_LINE_IN, 1741 .amux = EM28XX_AMUX_LINE_IN,
1741 .gpio = default_analog, 1742 .gpio = default_analog,
@@ -1758,7 +1759,7 @@ struct em28xx_board em28xx_boards[] = {
1758 .amux = EM28XX_AMUX_VIDEO, 1759 .amux = EM28XX_AMUX_VIDEO,
1759 .gpio = default_analog, 1760 .gpio = default_analog,
1760 }, { 1761 }, {
1761 .type = EM28XX_VMUX_COMPOSITE1, 1762 .type = EM28XX_VMUX_COMPOSITE,
1762 .vmux = TVP5150_COMPOSITE1, 1763 .vmux = TVP5150_COMPOSITE1,
1763 .amux = EM28XX_AMUX_LINE_IN, 1764 .amux = EM28XX_AMUX_LINE_IN,
1764 .gpio = default_analog, 1765 .gpio = default_analog,
@@ -1782,7 +1783,7 @@ struct em28xx_board em28xx_boards[] = {
1782 .amux = EM28XX_AMUX_VIDEO, 1783 .amux = EM28XX_AMUX_VIDEO,
1783 .gpio = pinnacle_hybrid_pro_analog, 1784 .gpio = pinnacle_hybrid_pro_analog,
1784 }, { 1785 }, {
1785 .type = EM28XX_VMUX_COMPOSITE1, 1786 .type = EM28XX_VMUX_COMPOSITE,
1786 .vmux = TVP5150_COMPOSITE1, 1787 .vmux = TVP5150_COMPOSITE1,
1787 .amux = EM28XX_AMUX_LINE_IN, 1788 .amux = EM28XX_AMUX_LINE_IN,
1788 .gpio = pinnacle_hybrid_pro_analog, 1789 .gpio = pinnacle_hybrid_pro_analog,
@@ -1808,7 +1809,7 @@ struct em28xx_board em28xx_boards[] = {
1808 .amux = EM28XX_AMUX_VIDEO, 1809 .amux = EM28XX_AMUX_VIDEO,
1809 .gpio = hauppauge_wintv_hvr_900_analog, 1810 .gpio = hauppauge_wintv_hvr_900_analog,
1810 }, { 1811 }, {
1811 .type = EM28XX_VMUX_COMPOSITE1, 1812 .type = EM28XX_VMUX_COMPOSITE,
1812 .vmux = TVP5150_COMPOSITE1, 1813 .vmux = TVP5150_COMPOSITE1,
1813 .amux = EM28XX_AMUX_LINE_IN, 1814 .amux = EM28XX_AMUX_LINE_IN,
1814 .gpio = hauppauge_wintv_hvr_900_analog, 1815 .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1834,7 +1835,7 @@ struct em28xx_board em28xx_boards[] = {
1834 .vmux = TVP5150_COMPOSITE0, 1835 .vmux = TVP5150_COMPOSITE0,
1835 .amux = EM28XX_AMUX_VIDEO, 1836 .amux = EM28XX_AMUX_VIDEO,
1836 }, { 1837 }, {
1837 .type = EM28XX_VMUX_COMPOSITE1, 1838 .type = EM28XX_VMUX_COMPOSITE,
1838 .vmux = TVP5150_COMPOSITE1, 1839 .vmux = TVP5150_COMPOSITE1,
1839 .amux = EM28XX_AMUX_LINE_IN, 1840 .amux = EM28XX_AMUX_LINE_IN,
1840 }, { 1841 }, {
@@ -1859,7 +1860,7 @@ struct em28xx_board em28xx_boards[] = {
1859 .amux = EM28XX_AMUX_VIDEO, 1860 .amux = EM28XX_AMUX_VIDEO,
1860 .gpio = hauppauge_wintv_hvr_900_analog, 1861 .gpio = hauppauge_wintv_hvr_900_analog,
1861 }, { 1862 }, {
1862 .type = EM28XX_VMUX_COMPOSITE1, 1863 .type = EM28XX_VMUX_COMPOSITE,
1863 .vmux = TVP5150_COMPOSITE1, 1864 .vmux = TVP5150_COMPOSITE1,
1864 .amux = EM28XX_AMUX_LINE_IN, 1865 .amux = EM28XX_AMUX_LINE_IN,
1865 .gpio = hauppauge_wintv_hvr_900_analog, 1866 .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1904,7 +1905,7 @@ struct em28xx_board em28xx_boards[] = {
1904 .gpio = kworld_330u_analog, 1905 .gpio = kworld_330u_analog,
1905 .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO, 1906 .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1906 }, { 1907 }, {
1907 .type = EM28XX_VMUX_COMPOSITE1, 1908 .type = EM28XX_VMUX_COMPOSITE,
1908 .vmux = TVP5150_COMPOSITE1, 1909 .vmux = TVP5150_COMPOSITE1,
1909 .amux = EM28XX_AMUX_LINE_IN, 1910 .amux = EM28XX_AMUX_LINE_IN,
1910 .gpio = kworld_330u_analog, 1911 .gpio = kworld_330u_analog,
@@ -1951,7 +1952,7 @@ struct em28xx_board em28xx_boards[] = {
1951 .amux = EM28XX_AMUX_VIDEO, 1952 .amux = EM28XX_AMUX_VIDEO,
1952 1953
1953 }, { 1954 }, {
1954 .type = EM28XX_VMUX_COMPOSITE1, 1955 .type = EM28XX_VMUX_COMPOSITE,
1955 .vmux = TVP5150_COMPOSITE1, 1956 .vmux = TVP5150_COMPOSITE1,
1956 .amux = EM28XX_AMUX_LINE_IN, 1957 .amux = EM28XX_AMUX_LINE_IN,
1957 }, { 1958 }, {
@@ -1970,7 +1971,7 @@ struct em28xx_board em28xx_boards[] = {
1970 .tuner_type = TUNER_ABSENT, 1971 .tuner_type = TUNER_ABSENT,
1971 .decoder = EM28XX_SAA711X, 1972 .decoder = EM28XX_SAA711X,
1972 .input = { { 1973 .input = { {
1973 .type = EM28XX_VMUX_COMPOSITE1, 1974 .type = EM28XX_VMUX_COMPOSITE,
1974 .vmux = SAA7115_COMPOSITE0, 1975 .vmux = SAA7115_COMPOSITE0,
1975 .amux = EM28XX_AMUX_LINE_IN, 1976 .amux = EM28XX_AMUX_LINE_IN,
1976 }, { 1977 }, {
@@ -1990,7 +1991,7 @@ struct em28xx_board em28xx_boards[] = {
1990 .vmux = TVP5150_COMPOSITE0, 1991 .vmux = TVP5150_COMPOSITE0,
1991 .amux = EM28XX_AMUX_VIDEO, 1992 .amux = EM28XX_AMUX_VIDEO,
1992 }, { /* Composite has not been tested yet */ 1993 }, { /* Composite has not been tested yet */
1993 .type = EM28XX_VMUX_COMPOSITE1, 1994 .type = EM28XX_VMUX_COMPOSITE,
1994 .vmux = TVP5150_COMPOSITE1, 1995 .vmux = TVP5150_COMPOSITE1,
1995 .amux = EM28XX_AMUX_VIDEO, 1996 .amux = EM28XX_AMUX_VIDEO,
1996 }, { /* S-video has not been tested yet */ 1997 }, { /* S-video has not been tested yet */
@@ -2006,7 +2007,7 @@ struct em28xx_board em28xx_boards[] = {
2006 .decoder = EM28XX_SAA711X, 2007 .decoder = EM28XX_SAA711X,
2007 .xclk = EM28XX_XCLK_FREQUENCY_12MHZ, 2008 .xclk = EM28XX_XCLK_FREQUENCY_12MHZ,
2008 .input = { { 2009 .input = { {
2009 .type = EM28XX_VMUX_COMPOSITE1, 2010 .type = EM28XX_VMUX_COMPOSITE,
2010 .vmux = SAA7115_COMPOSITE0, 2011 .vmux = SAA7115_COMPOSITE0,
2011 .amux = EM28XX_AMUX_LINE_IN, 2012 .amux = EM28XX_AMUX_LINE_IN,
2012 }, { 2013 }, {
@@ -2023,7 +2024,7 @@ struct em28xx_board em28xx_boards[] = {
2023 .xclk = EM28XX_XCLK_FREQUENCY_12MHZ, 2024 .xclk = EM28XX_XCLK_FREQUENCY_12MHZ,
2024 .mute_gpio = terratec_av350_mute_gpio, 2025 .mute_gpio = terratec_av350_mute_gpio,
2025 .input = { { 2026 .input = { {
2026 .type = EM28XX_VMUX_COMPOSITE1, 2027 .type = EM28XX_VMUX_COMPOSITE,
2027 .vmux = TVP5150_COMPOSITE1, 2028 .vmux = TVP5150_COMPOSITE1,
2028 .amux = EM28XX_AUDIO_SRC_LINE, 2029 .amux = EM28XX_AUDIO_SRC_LINE,
2029 .gpio = terratec_av350_unmute_gpio, 2030 .gpio = terratec_av350_unmute_gpio,
@@ -2041,7 +2042,7 @@ struct em28xx_board em28xx_boards[] = {
2041 .decoder = EM28XX_SAA711X, 2042 .decoder = EM28XX_SAA711X,
2042 .tuner_type = TUNER_ABSENT, /* Capture only device */ 2043 .tuner_type = TUNER_ABSENT, /* Capture only device */
2043 .input = { { 2044 .input = { {
2044 .type = EM28XX_VMUX_COMPOSITE1, 2045 .type = EM28XX_VMUX_COMPOSITE,
2045 .vmux = SAA7115_COMPOSITE0, 2046 .vmux = SAA7115_COMPOSITE0,
2046 .amux = EM28XX_AMUX_LINE_IN, 2047 .amux = EM28XX_AMUX_LINE_IN,
2047 }, { 2048 }, {
@@ -2067,7 +2068,7 @@ struct em28xx_board em28xx_boards[] = {
2067 .amux = EM28XX_AMUX_VIDEO, 2068 .amux = EM28XX_AMUX_VIDEO,
2068 .gpio = evga_indtube_analog, 2069 .gpio = evga_indtube_analog,
2069 }, { 2070 }, {
2070 .type = EM28XX_VMUX_COMPOSITE1, 2071 .type = EM28XX_VMUX_COMPOSITE,
2071 .vmux = TVP5150_COMPOSITE1, 2072 .vmux = TVP5150_COMPOSITE1,
2072 .amux = EM28XX_AMUX_LINE_IN, 2073 .amux = EM28XX_AMUX_LINE_IN,
2073 .gpio = evga_indtube_analog, 2074 .gpio = evga_indtube_analog,
@@ -2125,7 +2126,7 @@ struct em28xx_board em28xx_boards[] = {
2125 .tuner_type = TUNER_ABSENT, 2126 .tuner_type = TUNER_ABSENT,
2126 .decoder = EM28XX_SAA711X, 2127 .decoder = EM28XX_SAA711X,
2127 .input = { { 2128 .input = { {
2128 .type = EM28XX_VMUX_COMPOSITE1, 2129 .type = EM28XX_VMUX_COMPOSITE,
2129 .vmux = SAA7115_COMPOSITE0, 2130 .vmux = SAA7115_COMPOSITE0,
2130 .amux = EM28XX_AMUX_LINE_IN, 2131 .amux = EM28XX_AMUX_LINE_IN,
2131 }, { 2132 }, {
@@ -2238,7 +2239,7 @@ struct em28xx_board em28xx_boards[] = {
2238 .tuner_type = TUNER_ABSENT, 2239 .tuner_type = TUNER_ABSENT,
2239 .is_webcam = 1, 2240 .is_webcam = 1,
2240 .input = { { 2241 .input = { {
2241 .type = EM28XX_VMUX_COMPOSITE1, 2242 .type = EM28XX_VMUX_COMPOSITE,
2242 .amux = EM28XX_AMUX_VIDEO, 2243 .amux = EM28XX_AMUX_VIDEO,
2243 .gpio = speedlink_vad_laplace_reg_seq, 2244 .gpio = speedlink_vad_laplace_reg_seq,
2244 } }, 2245 } },
@@ -2272,7 +2273,7 @@ struct em28xx_board em28xx_boards[] = {
2272 .tuner_type = TUNER_ABSENT, /* Capture only device */ 2273 .tuner_type = TUNER_ABSENT, /* Capture only device */
2273 .decoder = EM28XX_TVP5150, 2274 .decoder = EM28XX_TVP5150,
2274 .input = { { 2275 .input = { {
2275 .type = EM28XX_VMUX_COMPOSITE1, 2276 .type = EM28XX_VMUX_COMPOSITE,
2276 .vmux = TVP5150_COMPOSITE1, 2277 .vmux = TVP5150_COMPOSITE1,
2277 .amux = EM28XX_AMUX_LINE_IN, 2278 .amux = EM28XX_AMUX_LINE_IN,
2278 }, { 2279 }, {
@@ -3012,6 +3013,41 @@ static void flush_request_modules(struct em28xx *dev)
3012 flush_work(&dev->request_module_wk); 3013 flush_work(&dev->request_module_wk);
3013} 3014}
3014 3015
3016static int em28xx_media_device_init(struct em28xx *dev,
3017 struct usb_device *udev)
3018{
3019#ifdef CONFIG_MEDIA_CONTROLLER
3020 struct media_device *mdev;
3021
3022 if (udev->product) {
3023 mdev = v4l2_mc_usb_media_device_init(udev, udev->product);
3024 } else if (udev->manufacturer) {
3025 mdev = v4l2_mc_usb_media_device_init(udev, udev->manufacturer);
3026 } else {
3027 mdev = v4l2_mc_usb_media_device_init(udev, dev->name);
3028 }
3029
3030 if (!mdev)
3031 return -ENOMEM;
3032
3033 dev->media_dev = mdev;
3034#endif
3035 return 0;
3036}
3037
3038static void em28xx_unregister_media_device(struct em28xx *dev)
3039{
3040
3041#ifdef CONFIG_MEDIA_CONTROLLER
3042 if (dev->media_dev) {
3043 media_device_unregister(dev->media_dev);
3044 media_device_cleanup(dev->media_dev);
3045 kfree(dev->media_dev);
3046 dev->media_dev = NULL;
3047 }
3048#endif
3049}
3050
3015/* 3051/*
3016 * em28xx_release_resources() 3052 * em28xx_release_resources()
3017 * unregisters the v4l2,i2c and usb devices 3053 * unregisters the v4l2,i2c and usb devices
@@ -3023,6 +3059,8 @@ static void em28xx_release_resources(struct em28xx *dev)
3023 3059
3024 mutex_lock(&dev->lock); 3060 mutex_lock(&dev->lock);
3025 3061
3062 em28xx_unregister_media_device(dev);
3063
3026 if (dev->def_i2c_bus) 3064 if (dev->def_i2c_bus)
3027 em28xx_i2c_unregister(dev, 1); 3065 em28xx_i2c_unregister(dev, 1);
3028 em28xx_i2c_unregister(dev, 0); 3066 em28xx_i2c_unregister(dev, 0);
@@ -3167,6 +3205,8 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
3167 */ 3205 */
3168 snprintf(dev->name, sizeof(dev->name), "%s #%d", chip_name, dev->devno); 3206 snprintf(dev->name, sizeof(dev->name), "%s #%d", chip_name, dev->devno);
3169 3207
3208 em28xx_media_device_init(dev, udev);
3209
3170 if (dev->is_audio_only) { 3210 if (dev->is_audio_only) {
3171 retval = em28xx_audio_setup(dev); 3211 retval = em28xx_audio_setup(dev);
3172 if (retval) 3212 if (retval)
@@ -3467,7 +3507,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3467 /* save our data pointer in this interface device */ 3507 /* save our data pointer in this interface device */
3468 usb_set_intfdata(interface, dev); 3508 usb_set_intfdata(interface, dev);
3469 3509
3470 /* allocate device struct */ 3510 /* allocate device struct and check if the device is a webcam */
3471 mutex_init(&dev->lock); 3511 mutex_init(&dev->lock);
3472 retval = em28xx_init_dev(dev, udev, interface, nr); 3512 retval = em28xx_init_dev(dev, udev, interface, nr);
3473 if (retval) { 3513 if (retval) {
@@ -3483,6 +3523,15 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3483 try_bulk = usb_xfer_mode > 0; 3523 try_bulk = usb_xfer_mode > 0;
3484 } 3524 }
3485 3525
3526 /* Disable V4L2 if the device doesn't have a decoder */
3527 if (has_video &&
3528 dev->board.decoder == EM28XX_NODECODER && !dev->board.is_webcam) {
3529 printk(DRIVER_NAME
3530 ": Currently, V4L2 is not supported on this model\n");
3531 has_video = false;
3532 dev->has_video = false;
3533 }
3534
3486 /* Select USB transfer types to use */ 3535 /* Select USB transfer types to use */
3487 if (has_video) { 3536 if (has_video) {
3488 if (!dev->analog_ep_isoc || (try_bulk && dev->analog_ep_bulk)) 3537 if (!dev->analog_ep_isoc || (try_bulk && dev->analog_ep_bulk))
@@ -3501,9 +3550,14 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3501 3550
3502 request_modules(dev); 3551 request_modules(dev);
3503 3552
3504 /* Should be the last thing to do, to avoid newer udev's to 3553 /*
3505 open the device before fully initializing it 3554 * Do it at the end, to reduce dynamic configuration changes during
3555 * the device init. Yet, as request_modules() can be async, the
3556 * topology will likely change after the load of the em28xx subdrivers.
3506 */ 3557 */
3558#ifdef CONFIG_MEDIA_CONTROLLER
3559 retval = media_device_register(dev->media_dev);
3560#endif
3507 3561
3508 return 0; 3562 return 0;
3509 3563
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..f772e2612608 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,16 @@ 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 ret = v4l2_mc_create_media_graph(dev->media_dev);
2718 if (ret) {
2719 em28xx_errdev("failed to create media graph\n");
2720 em28xx_v4l2_media_release(dev);
2721 goto unregister_dev;
2722 }
2723
2559 em28xx_info("V4L2 video device registered as %s\n", 2724 em28xx_info("V4L2 video device registered as %s\n",
2560 video_device_node_name(&v4l2->vdev)); 2725 video_device_node_name(&v4l2->vdev));
2561 2726
@@ -2577,6 +2742,22 @@ static int em28xx_v4l2_init(struct em28xx *dev)
2577 return 0; 2742 return 0;
2578 2743
2579unregister_dev: 2744unregister_dev:
2745 if (video_is_registered(&v4l2->radio_dev)) {
2746 em28xx_info("V4L2 device %s deregistered\n",
2747 video_device_node_name(&v4l2->radio_dev));
2748 video_unregister_device(&v4l2->radio_dev);
2749 }
2750 if (video_is_registered(&v4l2->vbi_dev)) {
2751 em28xx_info("V4L2 device %s deregistered\n",
2752 video_device_node_name(&v4l2->vbi_dev));
2753 video_unregister_device(&v4l2->vbi_dev);
2754 }
2755 if (video_is_registered(&v4l2->vdev)) {
2756 em28xx_info("V4L2 device %s deregistered\n",
2757 video_device_node_name(&v4l2->vdev));
2758 video_unregister_device(&v4l2->vdev);
2759 }
2760
2580 v4l2_ctrl_handler_free(&v4l2->ctrl_handler); 2761 v4l2_ctrl_handler_free(&v4l2->ctrl_handler);
2581 v4l2_device_unregister(&v4l2->v4l2_dev); 2762 v4l2_device_unregister(&v4l2->v4l2_dev);
2582err: 2763err:
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/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/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..4dac499ed28e 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/v4l2-mc.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");
@@ -349,20 +367,10 @@ static void *siano_media_device_register(struct smsusb_device_t *dev,
349 struct sms_board *board = sms_get_board(board_id); 367 struct sms_board *board = sms_get_board(board_id);
350 int ret; 368 int ret;
351 369
352 mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); 370 mdev = v4l2_mc_usb_media_device_init(udev, board->name);
353 if (!mdev) 371 if (!mdev)
354 return NULL; 372 return NULL;
355 373
356 mdev->dev = &udev->dev;
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
366 ret = media_device_register(mdev); 374 ret = media_device_register(mdev);
367 if (ret) { 375 if (ret) {
368 media_device_cleanup(mdev); 376 media_device_cleanup(mdev);
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/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-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 8a018c6dd16a..14843090fd61 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1191,6 +1191,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; 1191 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; 1192 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; 1193 case V4L2_PIX_FMT_YVU420M: descr = "Planar YVU 4:2:0 (N-C)"; break;
1194 case V4L2_PIX_FMT_YUV422M: descr = "Planar YUV 4:2:2 (N-C)"; break;
1195 case V4L2_PIX_FMT_YVU422M: descr = "Planar YVU 4:2:2 (N-C)"; break;
1196 case V4L2_PIX_FMT_YUV444M: descr = "Planar YUV 4:4:4 (N-C)"; break;
1197 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; 1198 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; 1199 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; 1200 case V4L2_PIX_FMT_SGRBG8: descr = "8-bit Bayer GRGR/BGBG"; break;
diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c
new file mode 100644
index 000000000000..a7f41b323522
--- /dev/null
+++ b/drivers/media/v4l2-core/v4l2-mc.c
@@ -0,0 +1,258 @@
1/*
2 * Media Controller ancillary functions
3 *
4 * (c) 2016 Mauro Carvalho Chehab <mchehab@osg.samsung.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <linux/module.h>
18#include <linux/pci.h>
19#include <linux/usb.h>
20#include <media/media-entity.h>
21#include <media/v4l2-mc.h>
22
23
24struct media_device *v4l2_mc_pci_media_device_init(struct pci_dev *pci_dev,
25 const char *name)
26{
27#ifdef CONFIG_PCI
28 struct media_device *mdev;
29
30 mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
31 if (!mdev)
32 return NULL;
33
34 mdev->dev = &pci_dev->dev;
35
36 if (name)
37 strlcpy(mdev->model, name, sizeof(mdev->model));
38 else
39 strlcpy(mdev->model, pci_name(pci_dev), sizeof(mdev->model));
40
41 sprintf(mdev->bus_info, "PCI:%s", pci_name(pci_dev));
42
43 mdev->hw_revision = pci_dev->subsystem_vendor << 16
44 || pci_dev->subsystem_device;
45
46 mdev->driver_version = LINUX_VERSION_CODE;
47
48 media_device_init(mdev);
49
50 return mdev;
51#else
52 return NULL;
53#endif
54}
55EXPORT_SYMBOL_GPL(v4l2_mc_pci_media_device_init);
56
57struct media_device *__v4l2_mc_usb_media_device_init(struct usb_device *udev,
58 const char *board_name,
59 const char *driver_name)
60{
61#ifdef CONFIG_USB
62 struct media_device *mdev;
63
64 mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
65 if (!mdev)
66 return NULL;
67
68 mdev->dev = &udev->dev;
69
70 if (driver_name)
71 strlcpy(mdev->driver_name, driver_name,
72 sizeof(mdev->driver_name));
73
74 if (board_name)
75 strlcpy(mdev->model, board_name, sizeof(mdev->model));
76 else if (udev->product)
77 strlcpy(mdev->model, udev->product, sizeof(mdev->model));
78 else
79 strlcpy(mdev->model, "unknown model", sizeof(mdev->model));
80 if (udev->serial)
81 strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial));
82 usb_make_path(udev, mdev->bus_info, sizeof(mdev->bus_info));
83 mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
84 mdev->driver_version = LINUX_VERSION_CODE;
85
86 media_device_init(mdev);
87
88 return mdev;
89#else
90 return NULL;
91#endif
92}
93EXPORT_SYMBOL_GPL(__v4l2_mc_usb_media_device_init);
94
95int v4l2_mc_create_media_graph(struct media_device *mdev)
96
97{
98 struct media_entity *entity;
99 struct media_entity *if_vid = NULL, *if_aud = NULL;
100 struct media_entity *tuner = NULL, *decoder = NULL;
101 struct media_entity *io_v4l = NULL, *io_vbi = NULL, *io_swradio = NULL;
102 bool is_webcam = false;
103 u32 flags;
104 int ret;
105
106 if (!mdev)
107 return 0;
108
109 media_device_for_each_entity(entity, mdev) {
110 switch (entity->function) {
111 case MEDIA_ENT_F_IF_VID_DECODER:
112 if_vid = entity;
113 break;
114 case MEDIA_ENT_F_IF_AUD_DECODER:
115 if_aud = entity;
116 break;
117 case MEDIA_ENT_F_TUNER:
118 tuner = entity;
119 break;
120 case MEDIA_ENT_F_ATV_DECODER:
121 decoder = entity;
122 break;
123 case MEDIA_ENT_F_IO_V4L:
124 io_v4l = entity;
125 break;
126 case MEDIA_ENT_F_IO_VBI:
127 io_vbi = entity;
128 break;
129 case MEDIA_ENT_F_IO_SWRADIO:
130 io_swradio = entity;
131 break;
132 case MEDIA_ENT_F_CAM_SENSOR:
133 is_webcam = true;
134 break;
135 }
136 }
137
138 /* It should have at least one I/O entity */
139 if (!io_v4l && !io_vbi && !io_swradio)
140 return -EINVAL;
141
142 /*
143 * Here, webcams are modelled on a very simple way: the sensor is
144 * connected directly to the I/O entity. All dirty details, like
145 * scaler and crop HW are hidden. While such mapping is not enough
146 * for mc-centric hardware, it is enough for v4l2 interface centric
147 * PC-consumer's hardware.
148 */
149 if (is_webcam) {
150 if (!io_v4l)
151 return -EINVAL;
152
153 media_device_for_each_entity(entity, mdev) {
154 if (entity->function != MEDIA_ENT_F_CAM_SENSOR)
155 continue;
156 ret = media_create_pad_link(entity, 0,
157 io_v4l, 0,
158 MEDIA_LNK_FL_ENABLED);
159 if (ret)
160 return ret;
161 }
162 if (!decoder)
163 return 0;
164 }
165
166 /* The device isn't a webcam. So, it should have a decoder */
167 if (!decoder)
168 return -EINVAL;
169
170 /* Link the tuner and IF video output pads */
171 if (tuner) {
172 if (if_vid) {
173 ret = media_create_pad_link(tuner, TUNER_PAD_OUTPUT,
174 if_vid,
175 IF_VID_DEC_PAD_IF_INPUT,
176 MEDIA_LNK_FL_ENABLED);
177 if (ret)
178 return ret;
179 ret = media_create_pad_link(if_vid, IF_VID_DEC_PAD_OUT,
180 decoder, DEMOD_PAD_IF_INPUT,
181 MEDIA_LNK_FL_ENABLED);
182 if (ret)
183 return ret;
184 } else {
185 ret = media_create_pad_link(tuner, TUNER_PAD_OUTPUT,
186 decoder, DEMOD_PAD_IF_INPUT,
187 MEDIA_LNK_FL_ENABLED);
188 if (ret)
189 return ret;
190 }
191
192 if (if_aud) {
193 ret = media_create_pad_link(tuner, TUNER_PAD_AUD_OUT,
194 if_aud,
195 IF_AUD_DEC_PAD_IF_INPUT,
196 MEDIA_LNK_FL_ENABLED);
197 if (ret)
198 return ret;
199 } else {
200 if_aud = tuner;
201 }
202
203 }
204
205 /* Create demod to V4L, VBI and SDR radio links */
206 if (io_v4l) {
207 ret = media_create_pad_link(decoder, DEMOD_PAD_VID_OUT,
208 io_v4l, 0,
209 MEDIA_LNK_FL_ENABLED);
210 if (ret)
211 return ret;
212 }
213
214 if (io_swradio) {
215 ret = media_create_pad_link(decoder, DEMOD_PAD_VID_OUT,
216 io_swradio, 0,
217 MEDIA_LNK_FL_ENABLED);
218 if (ret)
219 return ret;
220 }
221
222 if (io_vbi) {
223 ret = media_create_pad_link(decoder, DEMOD_PAD_VBI_OUT,
224 io_vbi, 0,
225 MEDIA_LNK_FL_ENABLED);
226 if (ret)
227 return ret;
228 }
229
230 /* Create links for the media connectors */
231 flags = MEDIA_LNK_FL_ENABLED;
232 media_device_for_each_entity(entity, mdev) {
233 switch (entity->function) {
234 case MEDIA_ENT_F_CONN_RF:
235 if (!tuner)
236 continue;
237
238 ret = media_create_pad_link(entity, 0, tuner,
239 TUNER_PAD_RF_INPUT,
240 flags);
241 break;
242 case MEDIA_ENT_F_CONN_SVIDEO:
243 case MEDIA_ENT_F_CONN_COMPOSITE:
244 ret = media_create_pad_link(entity, 0, decoder,
245 DEMOD_PAD_IF_INPUT,
246 flags);
247 break;
248 default:
249 continue;
250 }
251 if (ret)
252 return ret;
253
254 flags = 0;
255 }
256 return 0;
257}
258EXPORT_SYMBOL_GPL(v4l2_mc_create_media_graph);
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/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index ff8953ae52d1..dab94080ec3a 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1227,6 +1227,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const void *pb)
1227 if (planes[plane].length < vb->planes[plane].min_length) { 1227 if (planes[plane].length < vb->planes[plane].min_length) {
1228 dprintk(1, "invalid dmabuf length for plane %d\n", 1228 dprintk(1, "invalid dmabuf length for plane %d\n",
1229 plane); 1229 plane);
1230 dma_buf_put(dbuf);
1230 ret = -EINVAL; 1231 ret = -EINVAL;
1231 goto err; 1232 goto err;
1232 } 1233 }
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..d48a5c29c417 100644
--- a/drivers/staging/media/Kconfig
+++ b/drivers/staging/media/Kconfig
@@ -31,6 +31,8 @@ source "drivers/staging/media/mn88473/Kconfig"
31 31
32source "drivers/staging/media/omap4iss/Kconfig" 32source "drivers/staging/media/omap4iss/Kconfig"
33 33
34source "drivers/staging/media/timb/Kconfig"
35
34# Keep LIRC at the end, as it has sub-menus 36# Keep LIRC at the end, as it has sub-menus
35source "drivers/staging/media/lirc/Kconfig" 37source "drivers/staging/media/lirc/Kconfig"
36 38
diff --git a/drivers/staging/media/Makefile b/drivers/staging/media/Makefile
index 34c557b4c6d6..fb94f045c40f 100644
--- a/drivers/staging/media/Makefile
+++ b/drivers/staging/media/Makefile
@@ -5,3 +5,4 @@ obj-$(CONFIG_VIDEO_DM365_VPFE) += davinci_vpfe/
5obj-$(CONFIG_VIDEO_OMAP4) += omap4iss/ 5obj-$(CONFIG_VIDEO_OMAP4) += omap4iss/
6obj-$(CONFIG_DVB_MN88472) += mn88472/ 6obj-$(CONFIG_DVB_MN88472) += mn88472/
7obj-$(CONFIG_DVB_MN88473) += mn88473/ 7obj-$(CONFIG_DVB_MN88473) += mn88473/
8obj-$(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/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c
index 3ec7e65a3ffa..db49af90217e 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c
@@ -147,7 +147,7 @@ static int vpfe_prepare_pipeline(struct vpfe_video_device *video)
147 mutex_lock(&mdev->graph_mutex); 147 mutex_lock(&mdev->graph_mutex);
148 ret = media_entity_graph_walk_init(&graph, entity->graph_obj.mdev); 148 ret = media_entity_graph_walk_init(&graph, entity->graph_obj.mdev);
149 if (ret) { 149 if (ret) {
150 mutex_unlock(&video->lock); 150 mutex_unlock(&mdev->graph_mutex);
151 return -ENOMEM; 151 return -ENOMEM;
152 } 152 }
153 media_entity_graph_walk_start(&graph, entity); 153 media_entity_graph_walk_start(&graph, entity);
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/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/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..165451bc3985 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -268,6 +268,10 @@ struct device;
268 * struct media_device - Media device 268 * struct media_device - Media device
269 * @dev: Parent device 269 * @dev: Parent device
270 * @devnode: Media device node 270 * @devnode: Media device node
271 * @driver_name: Optional device driver name. If not set, calls to
272 * %MEDIA_IOC_DEVICE_INFO will return dev->driver->name.
273 * This is needed for USB drivers for example, as otherwise
274 * they'll all appear as if the driver name was "usb".
271 * @model: Device model name 275 * @model: Device model name
272 * @serial: Device serial number (optional) 276 * @serial: Device serial number (optional)
273 * @bus_info: Unique and stable device location identifier 277 * @bus_info: Unique and stable device location identifier
@@ -303,6 +307,7 @@ struct media_device {
303 struct media_devnode devnode; 307 struct media_devnode devnode;
304 308
305 char model[32]; 309 char model[32];
310 char driver_name[32];
306 char serial[40]; 311 char serial[40];
307 char bus_info[32]; 312 char bus_info[32];
308 u32 hw_revision; 313 u32 hw_revision;
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index f6494709e230..c41dd7018fa8 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: true if the device init has completed
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 bool 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-mc.h b/include/media/v4l2-mc.h
new file mode 100644
index 000000000000..79d84bb3573c
--- /dev/null
+++ b/include/media/v4l2-mc.h
@@ -0,0 +1,172 @@
1/*
2 * v4l2-mc.h - Media Controller V4L2 types and prototypes
3 *
4 * Copyright (C) 2016 Mauro Carvalho Chehab <mchehab@osg.samsung.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#ifndef _V4L2_MC_H
18#define _V4L2_MC_H
19
20#include <media/media-device.h>
21
22/**
23 * enum tuner_pad_index - tuner pad index for MEDIA_ENT_F_TUNER
24 *
25 * @TUNER_PAD_RF_INPUT: Radiofrequency (RF) sink pad, usually linked to a
26 * RF connector entity.
27 * @TUNER_PAD_OUTPUT: Tuner video output source pad. Contains the video
28 * chrominance and luminance or the hole bandwidth
29 * of the signal converted to an Intermediate Frequency
30 * (IF) or to baseband (on zero-IF tuners).
31 * @TUNER_PAD_AUD_OUT: Tuner audio output source pad. Tuners used to decode
32 * analog TV signals have an extra pad for audio output.
33 * Old tuners use an analog stage with a saw filter for
34 * the audio IF frequency. The output of the pad is, in
35 * this case, the audio IF, with should be decoded either
36 * by the bridge chipset (that's the case of cx2388x
37 * chipsets) or may require an external IF sound
38 * processor, like msp34xx. On modern silicon tuners,
39 * the audio IF decoder is usually incorporated at the
40 * tuner. On such case, the output of this pad is an
41 * audio sampled data.
42 * @TUNER_NUM_PADS: Number of pads of the tuner.
43 */
44enum tuner_pad_index {
45 TUNER_PAD_RF_INPUT,
46 TUNER_PAD_OUTPUT,
47 TUNER_PAD_AUD_OUT,
48 TUNER_NUM_PADS
49};
50
51/**
52 * enum if_vid_dec_index - video IF-PLL pad index for
53 * MEDIA_ENT_F_IF_VID_DECODER
54 *
55 * @IF_VID_DEC_PAD_IF_INPUT: video Intermediate Frequency (IF) sink pad
56 * @IF_VID_DEC_PAD_OUT: IF-PLL video output source pad. Contains the
57 * video chrominance and luminance IF signals.
58 * @IF_VID_DEC_PAD_NUM_PADS: Number of pads of the video IF-PLL.
59 */
60enum if_vid_dec_pad_index {
61 IF_VID_DEC_PAD_IF_INPUT,
62 IF_VID_DEC_PAD_OUT,
63 IF_VID_DEC_PAD_NUM_PADS
64};
65
66/**
67 * enum if_aud_dec_index - audio/sound IF-PLL pad index for
68 * MEDIA_ENT_F_IF_AUD_DECODER
69 *
70 * @IF_AUD_DEC_PAD_IF_INPUT: audio Intermediate Frequency (IF) sink pad
71 * @IF_AUD_DEC_PAD_OUT: IF-PLL audio output source pad. Contains the
72 * audio sampled stream data, usually connected
73 * to the bridge bus via an Inter-IC Sound (I2S)
74 * bus.
75 * @IF_AUD_DEC_PAD_NUM_PADS: Number of pads of the audio IF-PLL.
76 */
77enum if_aud_dec_pad_index {
78 IF_AUD_DEC_PAD_IF_INPUT,
79 IF_AUD_DEC_PAD_OUT,
80 IF_AUD_DEC_PAD_NUM_PADS
81};
82
83/**
84 * enum demod_pad_index - analog TV pad index for MEDIA_ENT_F_ATV_DECODER
85 *
86 * @DEMOD_PAD_IF_INPUT: IF input sink pad.
87 * @DEMOD_PAD_VID_OUT: Video output source pad.
88 * @DEMOD_PAD_VBI_OUT: Vertical Blank Interface (VBI) output source pad.
89 * @DEMOD_NUM_PADS: Maximum number of output pads.
90 */
91enum demod_pad_index {
92 DEMOD_PAD_IF_INPUT,
93 DEMOD_PAD_VID_OUT,
94 DEMOD_PAD_VBI_OUT,
95 DEMOD_NUM_PADS
96};
97
98/* We don't need to include pci.h or usb.h here */
99struct pci_dev;
100struct usb_device;
101
102#ifdef CONFIG_MEDIA_CONTROLLER
103/**
104 * v4l2_mc_create_media_graph() - create Media Controller links at the graph.
105 *
106 * @mdev: pointer to the &media_device struct.
107 *
108 * Add links between the entities commonly found on PC customer's hardware at
109 * the V4L2 side: camera sensors, audio and video PLL-IF decoders, tuners,
110 * analog TV decoder and I/O entities (video, VBI and Software Defined Radio).
111 * NOTE: webcams are modelled on a very simple way: the sensor is
112 * connected directly to the I/O entity. All dirty details, like
113 * scaler and crop HW are hidden. While such mapping is enough for v4l2
114 * interface centric PC-consumer's hardware, V4L2 subdev centric camera
115 * hardware should not use this routine, as it will not build the right graph.
116 */
117int v4l2_mc_create_media_graph(struct media_device *mdev);
118
119/**
120 * v4l2_mc_pci_media_device_init() - create and initialize a
121 * struct &media_device from a PCI device.
122 *
123 * @pci_dev: pointer to struct pci_dev
124 * @name: media device name. If %NULL, the routine will use the default
125 * name for the pci device, given by pci_name() macro.
126 */
127struct media_device *v4l2_mc_pci_media_device_init(struct pci_dev *pci_dev,
128 const char *name);
129/**
130 * __v4l2_mc_usb_media_device_init() - create and initialize a
131 * struct &media_device from a PCI device.
132 *
133 * @udev: pointer to struct usb_device
134 * @board_name: media device name. If %NULL, the routine will use the usb
135 * product name, if available.
136 * @driver_name: name of the driver. if %NULL, the routine will use the name
137 * given by udev->dev->driver->name, with is usually the wrong
138 * thing to do.
139 *
140 * NOTE: It is better to call v4l2_mc_usb_media_device_init() instead, as
141 * such macro fills driver_name with %KBUILD_MODNAME.
142 */
143struct media_device *__v4l2_mc_usb_media_device_init(struct usb_device *udev,
144 const char *board_name,
145 const char *driver_name);
146
147#else
148static inline int v4l2_mc_create_media_graph(struct media_device *mdev)
149{
150 return 0;
151}
152
153static inline
154struct media_device *v4l2_mc_pci_media_device_init(struct pci_dev *pci_dev,
155 char *name)
156{
157 return NULL;
158}
159
160static inline
161struct media_device *__v4l2_mc_usb_media_device_init(struct usb_device *udev,
162 char *board_name,
163 char *driver_name)
164{
165 return NULL;
166}
167#endif
168
169#define v4l2_mc_usb_media_device_init(udev, name) \
170 __v4l2_mc_usb_media_device_init(udev, name, KBUILD_MODNAME)
171
172#endif
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 1e3c8cb43bd7..6aac2f035a5d 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -72,21 +72,28 @@ struct media_device_info {
72#define MEDIA_ENT_F_DTV_NET_DECAP (MEDIA_ENT_F_BASE + 4) 72#define MEDIA_ENT_F_DTV_NET_DECAP (MEDIA_ENT_F_BASE + 4)
73 73
74/* 74/*
75 * Connectors 75 * I/O entities
76 */ 76 */
77/* It is a responsibility of the entity drivers to add connectors and links */ 77#define MEDIA_ENT_F_IO_DTV (MEDIA_ENT_F_BASE + 1001)
78#define MEDIA_ENT_F_CONN_RF (MEDIA_ENT_F_BASE + 21) 78#define MEDIA_ENT_F_IO_VBI (MEDIA_ENT_F_BASE + 1002)
79#define MEDIA_ENT_F_CONN_SVIDEO (MEDIA_ENT_F_BASE + 22) 79#define MEDIA_ENT_F_IO_SWRADIO (MEDIA_ENT_F_BASE + 1003)
80#define MEDIA_ENT_F_CONN_COMPOSITE (MEDIA_ENT_F_BASE + 23)
81/* For internal test signal generators and other debug connectors */
82#define MEDIA_ENT_F_CONN_TEST (MEDIA_ENT_F_BASE + 24)
83 80
84/* 81/*
85 * I/O entities 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 + 2001)
88#define MEDIA_ENT_F_IF_AUD_DECODER (MEDIA_ENT_F_BASE + 2002)
89
90/*
91 * Connectors
86 */ 92 */
87#define MEDIA_ENT_F_IO_DTV (MEDIA_ENT_F_BASE + 31) 93/* It is a responsibility of the entity drivers to add connectors and links */
88#define MEDIA_ENT_F_IO_VBI (MEDIA_ENT_F_BASE + 32) 94#define MEDIA_ENT_F_CONN_RF (MEDIA_ENT_F_BASE + 10001)
89#define MEDIA_ENT_F_IO_SWRADIO (MEDIA_ENT_F_BASE + 33) 95#define MEDIA_ENT_F_CONN_SVIDEO (MEDIA_ENT_F_BASE + 10002)
96#define MEDIA_ENT_F_CONN_COMPOSITE (MEDIA_ENT_F_BASE + 10003)
90 97
91/* 98/*
92 * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and 99 * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and
@@ -107,8 +114,12 @@ struct media_device_info {
107#define MEDIA_ENT_F_LENS (MEDIA_ENT_F_OLD_SUBDEV_BASE + 3) 114#define MEDIA_ENT_F_LENS (MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
108#define MEDIA_ENT_F_ATV_DECODER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 4) 115#define MEDIA_ENT_F_ATV_DECODER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
109/* 116/*
110 * It is a responsibility of the entity drivers to add connectors and links 117 * It is a responsibility of the master/bridge drivers to add connectors
111 * for the tuner entities. 118 * and links for MEDIA_ENT_F_TUNER. Please notice that some old tuners
119 * may require the usage of separate I2C chips to decode analog TV signals,
120 * when the master/bridge chipset doesn't have its own TV standard decoder.
121 * On such cases, the IF-PLL staging is mapped via one or two entities:
122 * MEDIA_ENT_F_IF_VID_DECODER and/or MEDIA_ENT_F_IF_AUD_DECODER.
112 */ 123 */
113#define MEDIA_ENT_F_TUNER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 5) 124#define MEDIA_ENT_F_TUNER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
114 125
@@ -286,7 +297,7 @@ struct media_links_enum {
286 * later, before the adding this API upstream. 297 * later, before the adding this API upstream.
287 */ 298 */
288 299
289#if 0 /* Let's postpone it to Kernel 4.6 */ 300
290struct media_v2_entity { 301struct media_v2_entity {
291 __u32 id; 302 __u32 id;
292 char name[64]; /* FIXME: move to a property? (RFC says so) */ 303 char name[64]; /* FIXME: move to a property? (RFC says so) */
@@ -351,7 +362,6 @@ static inline void __user *media_get_uptr(__u64 arg)
351{ 362{
352 return (void __user *)(uintptr_t)arg; 363 return (void __user *)(uintptr_t)arg;
353} 364}
354#endif
355 365
356/* ioctls */ 366/* ioctls */
357 367
@@ -359,9 +369,6 @@ static inline void __user *media_get_uptr(__u64 arg)
359#define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc) 369#define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc)
360#define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum) 370#define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum)
361#define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc) 371#define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc)
362
363#if 0 /* Let's postpone it to Kernel 4.6 */
364#define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology) 372#define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology)
365#endif
366 373
367#endif /* __LINUX_MEDIA_H */ 374#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..466458422385 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.. */